-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vue): add id props and improve state exposition
BREAKING CHANGE: Update exposed context types and remove unnecessary expose calls Signed-off-by: Shyrro <zsahmane@gmail.com>
- Loading branch information
Showing
59 changed files
with
825 additions
and
758 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,49 @@ | ||
import { type Context } from '@zag-js/color-picker' | ||
import { defineComponent, type PropType } from 'vue' | ||
import type { ComponentWithProps } from '../utils' | ||
import type { HTMLArkProps } from '../factory' | ||
import type { Assign } from '../types' | ||
import { createVueProps, type ComponentWithProps } from '../utils' | ||
import { ColorPickerProvider } from './color-picker-context' | ||
import { useColorPicker, type UseColorPickerContext } from './use-color-picker' | ||
import { useColorPicker } from './use-color-picker' | ||
|
||
export type ColorPickerProps = UseColorPickerContext | ||
export type ColorPickerContext = Context & { | ||
modelValue?: Context['value'] | ||
} | ||
export type ColorPickerProps = Assign<HTMLArkProps<'div'>, ColorPickerContext> | ||
|
||
export const ColorPicker: ComponentWithProps<ColorPickerProps> = defineComponent({ | ||
name: 'ColorPicker', | ||
props: { | ||
dir: { | ||
type: String as PropType<ColorPickerProps['dir']>, | ||
}, | ||
id: { | ||
type: String as PropType<ColorPickerProps['id']>, | ||
}, | ||
getRootNode: { | ||
type: Function as PropType<ColorPickerProps['getRootNode']>, | ||
}, | ||
modelValue: { | ||
type: String as PropType<ColorPickerProps['modelValue']>, | ||
}, | ||
value: { | ||
type: String as PropType<ColorPickerProps['value']>, | ||
}, | ||
disabled: { | ||
type: Boolean as PropType<ColorPickerProps['disabled']>, | ||
}, | ||
readOnly: { | ||
type: Boolean as PropType<ColorPickerProps['readOnly']>, | ||
}, | ||
const VueColorPickerProps = createVueProps<ColorPickerProps>({ | ||
dir: { | ||
type: String as PropType<ColorPickerProps['dir']>, | ||
}, | ||
id: { | ||
type: String as PropType<ColorPickerProps['id']>, | ||
}, | ||
getRootNode: { | ||
type: Function as PropType<ColorPickerProps['getRootNode']>, | ||
}, | ||
modelValue: { | ||
type: String as PropType<ColorPickerProps['modelValue']>, | ||
}, | ||
value: { | ||
type: String as PropType<ColorPickerProps['value']>, | ||
}, | ||
disabled: { | ||
type: Boolean as PropType<ColorPickerProps['disabled']>, | ||
}, | ||
readOnly: { | ||
type: Boolean as PropType<ColorPickerProps['readOnly']>, | ||
}, | ||
}) | ||
|
||
export const ColorPicker: ComponentWithProps<Partial<ColorPickerContext>> = defineComponent({ | ||
name: 'ColorPicker', | ||
props: VueColorPickerProps, | ||
emits: ['change', 'change-end', 'update:modelValue'], | ||
setup(props, { slots, emit }) { | ||
const api = useColorPicker(emit, props) | ||
|
||
ColorPickerProvider(api) | ||
|
||
return () => slots.default?.({ ...api.value }) | ||
return () => slots.default?.(api.value) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.