From 673064dee5011c588ca527e5f8cd8108eb0856f8 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Fri, 28 Jun 2024 18:13:03 +0200 Subject: [PATCH] chore(components): improve props --- cli/templates.mjs | 10 +++++--- src/runtime/components/Accordion.vue | 9 +++++-- src/runtime/components/Alert.vue | 14 ++++++---- src/runtime/components/Avatar.vue | 2 +- src/runtime/components/AvatarGroup.vue | 8 ++++-- src/runtime/components/Badge.vue | 12 ++++++--- src/runtime/components/Breadcrumb.vue | 10 +++++--- src/runtime/components/ButtonGroup.vue | 11 +++++--- src/runtime/components/Card.vue | 10 +++++--- src/runtime/components/Checkbox.vue | 8 +++--- src/runtime/components/Chip.vue | 10 +++++--- src/runtime/components/Collapsible.vue | 7 ++++- src/runtime/components/CommandPalette.vue | 12 ++++----- src/runtime/components/Container.vue | 10 +++++--- src/runtime/components/ContextMenu.vue | 4 +-- src/runtime/components/Drawer.vue | 9 +++++-- src/runtime/components/DropdownMenu.vue | 8 +++--- src/runtime/components/InputMenu.vue | 25 ++++++++++-------- src/runtime/components/Kbd.vue | 12 ++++++--- src/runtime/components/Link.vue | 12 +++++++-- src/runtime/components/Modal.vue | 6 ++--- src/runtime/components/NavigationMenu.vue | 13 +++++++--- src/runtime/components/Pagination.vue | 27 ++++++++++++-------- src/runtime/components/Popover.vue | 8 +++--- src/runtime/components/Progress.vue | 9 +++++-- src/runtime/components/RadioGroup.vue | 9 +++++-- src/runtime/components/Select.vue | 16 ++++++------ src/runtime/components/SelectMenu.vue | 18 ++++++------- src/runtime/components/Separator.vue | 10 +++++--- src/runtime/components/Skeleton.vue | 10 +++++--- src/runtime/components/Slideover.vue | 10 ++++---- src/runtime/components/Slider.vue | 9 +++++-- src/runtime/components/Switch.vue | 9 +++++-- src/runtime/components/Tabs.vue | 11 +++++--- src/runtime/components/Toast.vue | 15 ++++++++--- src/runtime/components/Toaster.vue | 2 +- src/runtime/components/Tooltip.vue | 10 +++++--- src/runtime/composables/useComponentIcons.ts | 2 +- 38 files changed, 260 insertions(+), 137 deletions(-) diff --git a/cli/templates.mjs b/cli/templates.mjs index 41236638..bad13252 100644 --- a/cli/templates.mjs +++ b/cli/templates.mjs @@ -31,7 +31,6 @@ const component = ({ name, primitive, pro, prose, content }) => { ? ` diff --git a/src/runtime/components/Breadcrumb.vue b/src/runtime/components/Breadcrumb.vue index ba6064f0..b214d89e 100644 --- a/src/runtime/components/Breadcrumb.vue +++ b/src/runtime/components/Breadcrumb.vue @@ -1,6 +1,5 @@ diff --git a/src/runtime/components/ContextMenu.vue b/src/runtime/components/ContextMenu.vue index 37588610..64689479 100644 --- a/src/runtime/components/ContextMenu.vue +++ b/src/runtime/components/ContextMenu.vue @@ -19,7 +19,7 @@ export interface ContextMenuItem extends Omit, Pic kbds?: KbdProps['value'][] | KbdProps[] /** * The item type. - * @defaultValue `'link'` + * @defaultValue 'link' */ type?: 'label' | 'separator' | 'link' slot?: string @@ -35,7 +35,7 @@ export interface ContextMenuProps extends Omit, content?: Omit /** * Render the menu in a portal. - * @defaultValue `true` + * @defaultValue true */ portal?: boolean class?: any diff --git a/src/runtime/components/Drawer.vue b/src/runtime/components/Drawer.vue index 7b8bd0a8..713e7a97 100644 --- a/src/runtime/components/Drawer.vue +++ b/src/runtime/components/Drawer.vue @@ -10,7 +10,12 @@ const appConfig = _appConfig as AppConfig & { ui: { drawer: Partial { +export interface DrawerProps extends Pick { + /** + * The element or component this component should render as. + * @defaultValue 'div' + */ + as?: any title?: string description?: string /** The content of the drawer. */ @@ -18,7 +23,7 @@ export interface DrawerProps extends Omit { overlay?: boolean /** * Render the drawer in a portal. - * @defaultValue `true` + * @defaultValue true */ portal?: boolean class?: any diff --git a/src/runtime/components/DropdownMenu.vue b/src/runtime/components/DropdownMenu.vue index 669a6f92..50159d3f 100644 --- a/src/runtime/components/DropdownMenu.vue +++ b/src/runtime/components/DropdownMenu.vue @@ -19,7 +19,7 @@ export interface DropdownMenuItem extends Omit, Pi kbds?: KbdProps['value'][] | KbdProps[] /** * The item type. - * @defaultValue `'link'` + * @defaultValue 'link' */ type?: 'label' | 'separator' | 'link' slot?: string @@ -36,17 +36,17 @@ export interface DropdownMenuProps extends Omit items?: T[] | T[][] /** * The content of the menu. - * @defaultValue `{ side: 'bottom', sideOffset: 8 }` + * @defaultValue { side: 'bottom', sideOffset: 8 } */ content?: Omit /** * Display an arrow alongside the menu. - * @defaultValue `false` + * @defaultValue false */ arrow?: boolean | Omit /** * Render the menu in a portal. - * @defaultValue `true` + * @defaultValue true */ portal?: boolean class?: any diff --git a/src/runtime/components/InputMenu.vue b/src/runtime/components/InputMenu.vue index e7e29b4e..55206a80 100644 --- a/src/runtime/components/InputMenu.vue +++ b/src/runtime/components/InputMenu.vue @@ -20,14 +20,19 @@ export interface InputMenuItem extends Pick { chip?: ChipProps /** * The item type. - * @defaultValue `'item'` + * @defaultValue 'item' */ type?: 'label' | 'separator' | 'item' } type InputMenuVariants = VariantProps -export interface InputMenuProps extends Omit, 'asChild' | 'dir' | 'filterFunction' | 'displayValue'>, UseComponentIconsProps { +export interface InputMenuProps extends Pick, 'modelValue' | 'defaultValue' | 'open' | 'defaultOpen' | 'searchTerm' | 'multiple' | 'disabled' | 'name' | 'resetSearchTermOnBlur'>, UseComponentIconsProps { + /** + * The element or component this component should render as. + * @defaultValue 'div' + */ + as?: any id?: string type?: InputHTMLAttributes['type'] /** The placeholder text when the input is empty. */ @@ -40,39 +45,39 @@ export interface InputMenuProps extends Omit, 'asChild' autofocusDelay?: number /** * The icon displayed to open the menu. - * @defaultValue `appConfig.ui.icons.chevronDown` + * @defaultValue appConfig.ui.icons.chevronDown */ trailingIcon?: string /** * The icon displayed when an item is selected. - * @defaultValue `appConfig.ui.icons.check` + * @defaultValue appConfig.ui.icons.check */ selectedIcon?: string /** * The icon displayed to delete a tag. * Works only when `multiple` is `true`. - * @defaultValue `appConfig.ui.icons.close` + * @defaultValue appConfig.ui.icons.close */ deleteIcon?: string /** * The content of the menu. - * @defaultValue `{ side: 'bottom', sideOffset: 8, position: 'popper' }` + * @defaultValue { side: 'bottom', sideOffset: 8, position: 'popper' } */ content?: Omit /** * Display an arrow alongside the menu. - * @defaultValue `false` + * @defaultValue false */ arrow?: boolean | Omit /** * Render the menu in a portal. - * @defaultValue `true` + * @defaultValue true */ portal?: boolean /** * Whether to filter items or not, can be an array of fields to filter. * When `false`, items will not be filtered which is useful for custom filtering. - * @defaultValue `['label']` + * @defaultValue ['label'] */ filter?: boolean | string[] items?: T[] | T[][] @@ -120,7 +125,7 @@ const slots = defineSlots>() const searchTerm = defineModel('searchTerm', { default: '' }) const appConfig = useAppConfig() -const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'open', 'defaultOpen', 'multiple'), emits) +const rootProps = useForwardPropsEmits(reactivePick(props, 'as', 'modelValue', 'defaultValue', 'open', 'defaultOpen', 'multiple', 'resetSearchTermOnBlur'), emits) const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, position: 'popper' }) as ComboboxContentProps) const { emitFormBlur, emitFormChange, size: formGroupSize, color, id, name, disabled } = useFormField(props) const { orientation, size: buttonGroupSize } = useButtonGroup(props) diff --git a/src/runtime/components/Kbd.vue b/src/runtime/components/Kbd.vue index a4b35297..b38ac2bc 100644 --- a/src/runtime/components/Kbd.vue +++ b/src/runtime/components/Kbd.vue @@ -1,6 +1,5 @@ @@ -17,7 +21,7 @@ export interface SkeletonProps extends Omit {