diff --git a/docs/app/components/content/examples/table/TableColumnVisibilityExample.vue b/docs/app/components/content/examples/table/TableColumnVisibilityExample.vue index 848b18934f..bcad2461af 100644 --- a/docs/app/components/content/examples/table/TableColumnVisibilityExample.vue +++ b/docs/app/components/content/examples/table/TableColumnVisibilityExample.vue @@ -109,8 +109,8 @@ const columnVisibility = ref({ onUpdateChecked(checked: boolean) { table?.tableApi?.getColumn(column.id)?.toggleVisibility(!!checked) }, - onSelect(e?: Event) { - e?.preventDefault() + onSelect(e: Event) { + e.preventDefault() } }))" :content="{ align: 'end' }" diff --git a/docs/app/components/content/examples/table/TableExample.vue b/docs/app/components/content/examples/table/TableExample.vue index ae1bfc0891..ddf20e5933 100644 --- a/docs/app/components/content/examples/table/TableExample.vue +++ b/docs/app/components/content/examples/table/TableExample.vue @@ -286,8 +286,8 @@ function randomize() { onUpdateChecked(checked: boolean) { table?.tableApi?.getColumn(column.id)?.toggleVisibility(!!checked) }, - onSelect(e?: Event) { - e?.preventDefault() + onSelect(e: Event) { + e.preventDefault() } }))" :content="{ align: 'end' }" diff --git a/docs/app/components/content/examples/tree/TreeCheckboxItemsExample.vue b/docs/app/components/content/examples/tree/TreeCheckboxItemsExample.vue new file mode 100644 index 0000000000..b27101cb36 --- /dev/null +++ b/docs/app/components/content/examples/tree/TreeCheckboxItemsExample.vue @@ -0,0 +1,59 @@ + + + diff --git a/docs/app/components/content/examples/tree/TreeOnSelectExample.vue b/docs/app/components/content/examples/tree/TreeOnSelectExample.vue index 6974248e06..da3892b436 100644 --- a/docs/app/components/content/examples/tree/TreeOnSelectExample.vue +++ b/docs/app/components/content/examples/tree/TreeOnSelectExample.vue @@ -1,4 +1,5 @@ diff --git a/docs/app/components/content/examples/tree/TreeOnToggleExample.vue b/docs/app/components/content/examples/tree/TreeOnToggleExample.vue index f099905afe..65f3701887 100644 --- a/docs/app/components/content/examples/tree/TreeOnToggleExample.vue +++ b/docs/app/components/content/examples/tree/TreeOnToggleExample.vue @@ -1,4 +1,5 @@ diff --git a/docs/content/docs/2.components/command-palette.md b/docs/content/docs/2.components/command-palette.md index 9d021fb437..67f01232c2 100644 --- a/docs/content/docs/2.components/command-palette.md +++ b/docs/content/docs/2.components/command-palette.md @@ -110,7 +110,7 @@ Each group contains an `items` array of objects that define the commands. Each i - [`slot?: string`{lang="ts-type"}](#with-custom-slot) - `placeholder?: string`{lang="ts-type"} - `children?: CommandPaletteItem[]`{lang="ts-type"} -- `onSelect?(e?: Event): void`{lang="ts-type"} +- `onSelect?: (e: Event) => void`{lang="ts-type"} - `class?: any`{lang="ts-type"} - `ui?: { item?: ClassNameValue, itemLeadingIcon?: ClassNameValue, itemLeadingAvatarSize?: ClassNameValue, itemLeadingAvatar?: ClassNameValue, itemLeadingChipSize?: ClassNameValue, itemLeadingChip?: ClassNameValue, itemLabel?: ClassNameValue, itemLabelPrefix?: ClassNameValue, itemLabelBase?: ClassNameValue, itemLabelSuffix?: ClassNameValue, itemTrailing?: ClassNameValue, itemTrailingKbds?: ClassNameValue, itemTrailingKbdsSize?: ClassNameValue, itemTrailingHighlightedIcon?: ClassNameValue, itemTrailingIcon?: ClassNameValue }`{lang="ts-type"} diff --git a/docs/content/docs/2.components/context-menu.md b/docs/content/docs/2.components/context-menu.md index c4db2b7750..686844bbf1 100644 --- a/docs/content/docs/2.components/context-menu.md +++ b/docs/content/docs/2.components/context-menu.md @@ -95,8 +95,8 @@ Use the `items` prop as an array of objects with the following properties: - [`checked?: boolean`{lang="ts-type"}](#with-checkbox-items) - `disabled?: boolean`{lang="ts-type"} - [`slot?: string`{lang="ts-type"}](#with-custom-slot) -- `onSelect?(e: Event): void`{lang="ts-type"} -- [`onUpdateChecked?(checked: boolean): void`{lang="ts-type"}](#with-checkbox-items) +- `onSelect?: (e: Event) => void`{lang="ts-type"} +- [`onUpdateChecked?: (checked: boolean) => void`{lang="ts-type"}](#with-checkbox-items) - `children?: ContextMenuItem[] | ContextMenuItem[][]`{lang="ts-type"} - `class?: any`{lang="ts-type"} - `ui?: { item?: ClassNameValue, label?: ClassNameValue, separator?: ClassNameValue, itemLeadingIcon?: ClassNameValue, itemLeadingAvatarSize?: ClassNameValue, itemLeadingAvatar?: ClassNameValue, itemLabel?: ClassNameValue, itemLabelExternalIcon?: ClassNameValue, itemTrailing?: ClassNameValue, itemTrailingIcon?: ClassNameValue, itemTrailingKbds?: ClassNameValue, itemTrailingKbdsSize?: ClassNameValue }`{lang="ts-type"} diff --git a/docs/content/docs/2.components/dropdown-menu.md b/docs/content/docs/2.components/dropdown-menu.md index 1188f69eb7..d9991fcbb2 100644 --- a/docs/content/docs/2.components/dropdown-menu.md +++ b/docs/content/docs/2.components/dropdown-menu.md @@ -94,8 +94,8 @@ Use the `items` prop as an array of objects with the following properties: - [`checked?: boolean`{lang="ts-type"}](#with-checkbox-items) - `disabled?: boolean`{lang="ts-type"} - [`slot?: string`{lang="ts-type"}](#with-custom-slot) -- `onSelect?(e: Event): void`{lang="ts-type"} -- [`onUpdateChecked?(checked: boolean): void`{lang="ts-type"}](#with-checkbox-items) +- `onSelect?: (e: Event) => void`{lang="ts-type"} +- [`onUpdateChecked?: (checked: boolean) => void`{lang="ts-type"}](#with-checkbox-items) - `children?: DropdownMenuItem[] | DropdownMenuItem[][]`{lang="ts-type"} - `class?: any`{lang="ts-type"} - `ui?: { item?: ClassNameValue, label?: ClassNameValue, separator?: ClassNameValue, itemLeadingIcon?: ClassNameValue, itemLeadingAvatarSize?: ClassNameValue, itemLeadingAvatar?: ClassNameValue, itemLabel?: ClassNameValue, itemLabelExternalIcon?: ClassNameValue, itemTrailing?: ClassNameValue, itemTrailingIcon?: ClassNameValue, itemTrailingKbds?: ClassNameValue, itemTrailingKbdsSize?: ClassNameValue }`{lang="ts-type"} diff --git a/docs/content/docs/2.components/input-menu.md b/docs/content/docs/2.components/input-menu.md index eb4c81647f..1318a5f340 100644 --- a/docs/content/docs/2.components/input-menu.md +++ b/docs/content/docs/2.components/input-menu.md @@ -73,7 +73,7 @@ You can also pass an array of objects with the following properties: - [`avatar?: AvatarProps`{lang="ts-type"}](#with-avatar-in-items) - [`chip?: ChipProps`{lang="ts-type"}](#with-chip-in-items) - `disabled?: boolean`{lang="ts-type"} -- `onSelect?(e: Event): void`{lang="ts-type"} +- `onSelect?: (e: Event) => void`{lang="ts-type"} - `class?: any`{lang="ts-type"} - `ui?: { tagsItem?: ClassNameValue, tagsItemText?: ClassNameValue, tagsItemDelete?: ClassNameValue, tagsItemDeleteIcon?: ClassNameValue, label?: ClassNameValue, separator?: ClassNameValue, item?: ClassNameValue, itemLeadingIcon?: ClassNameValue, itemLeadingAvatarSize?: ClassNameValue, itemLeadingAvatar?: ClassNameValue, itemLeadingChip?: ClassNameValue, itemLeadingChipSize?: ClassNameValue, itemLabel?: ClassNameValue, itemTrailing?: ClassNameValue, itemTrailingIcon?: ClassNameValue }`{lang="ts-type"} diff --git a/docs/content/docs/2.components/navigation-menu.md b/docs/content/docs/2.components/navigation-menu.md index c54b2d2816..c468c6277a 100644 --- a/docs/content/docs/2.components/navigation-menu.md +++ b/docs/content/docs/2.components/navigation-menu.md @@ -118,7 +118,7 @@ Use the `items` prop as an array of objects with the following properties: - `value?: string`{lang="ts-type"} - `disabled?: boolean`{lang="ts-type"} - [`slot?: string`{lang="ts-type"}](#with-custom-slot) -- `onSelect?(e: Event): void`{lang="ts-type"} +- `onSelect?: (e: Event) => void`{lang="ts-type"} - `children?: NavigationMenuChildItem[]`{lang="ts-type"} - `class?: any`{lang="ts-type"} - `ui?: { linkLeadingAvatarSize?: ClassNameValue, linkLeadingAvatar?: ClassNameValue, linkLeadingIcon?: ClassNameValue, linkLabel?: ClassNameValue, linkLabelExternalIcon?: ClassNameValue, linkTrailing?: ClassNameValue, linkTrailingBadgeSize?: ClassNameValue, linkTrailingBadge?: ClassNameValue, linkTrailingIcon?: ClassNameValue, label?: ClassNameValue, link?: ClassNameValue, content?: ClassNameValue, childList?: ClassNameValue, childLabel?: ClassNameValue, childItem?: ClassNameValue, childLink?: ClassNameValue, childLinkIcon?: ClassNameValue, childLinkWrapper?: ClassNameValue, childLinkLabel?: ClassNameValue, childLinkLabelExternalIcon?: ClassNameValue, childLinkDescription?: ClassNameValue }`{lang="ts-type"} @@ -223,7 +223,7 @@ Each item can take a `children` array of objects with the following properties t - `label: string` - `description?: string` - `icon?: string` -- `onSelect?(e: Event): void` +- `onSelect?: (e: Event) => void` - `class?: any` :: diff --git a/docs/content/docs/2.components/select-menu.md b/docs/content/docs/2.components/select-menu.md index e9d11e500d..59ab209c18 100644 --- a/docs/content/docs/2.components/select-menu.md +++ b/docs/content/docs/2.components/select-menu.md @@ -79,7 +79,7 @@ You can also pass an array of objects with the following properties: - [`avatar?: AvatarProps`{lang="ts-type"}](#with-avatar-in-items) - [`chip?: ChipProps`{lang="ts-type"}](#with-chip-in-items) - `disabled?: boolean`{lang="ts-type"} -- `onSelect?(e: Event): void`{lang="ts-type"} +- `onSelect?: (e: Event) => void`{lang="ts-type"} - `class?: any`{lang="ts-type"} - `ui?: { label?: ClassNameValue, separator?: ClassNameValue, item?: ClassNameValue, itemLeadingIcon?: ClassNameValue, itemLeadingAvatarSize?: ClassNameValue, itemLeadingAvatar?: ClassNameValue, itemLeadingChipSize?: ClassNameValue, itemLeadingChip?: ClassNameValue, itemLabel?: ClassNameValue, itemTrailing?: ClassNameValue, itemTrailingIcon?: ClassNameValue }`{lang="ts-type"} diff --git a/docs/content/docs/2.components/tree.md b/docs/content/docs/2.components/tree.md index 11e456a990..562c1b1169 100644 --- a/docs/content/docs/2.components/tree.md +++ b/docs/content/docs/2.components/tree.md @@ -60,8 +60,8 @@ Use the `items` prop as an array of objects with the following properties: - `disabled?: boolean`{lang="ts-type"} - `slot?: string`{lang="ts-type"} - `children?: TreeItem[]`{lang="ts-type"} -- `onToggle?(e: Event): void`{lang="ts-type"} -- `onSelect?(e?: Event): void`{lang="ts-type"} +- `onToggle?: (e: TreeItemToggleEvent) => void`{lang="ts-type"} +- `onSelect?: (e: TreeItemSelectEvent) => void`{lang="ts-type"} - `class?: any`{lang="ts-type"} - `ui?: { item?: ClassNameValue, itemWithChildren?: ClassNameValue, link?: ClassNameValue, linkLeadingIcon?: ClassNameValue, linkLabel?: ClassNameValue, linkTrailing?: ClassNameValue, linkTrailingIcon?: ClassNameValue, listWithChildren?: ClassNameValue }`{lang="ts-type"} @@ -458,7 +458,7 @@ props: --- :: -If you want to prevent an item from being selected, you can use the `item.onSelect()`{lang="ts-type"} property: +If you want to prevent an item from being selected, you can use the `item.onSelect()`{lang="ts-type"} property or the global `select` event: ::component-example --- @@ -486,7 +486,7 @@ props: --- :: -If you want to prevent an item from being expanded, you can use the `item.onToggle()`{lang="ts-type"} property: +If you want to prevent an item from being expanded, you can use the `item.onToggle()`{lang="ts-type"} property or the global `toggle` event: ::component-example --- @@ -501,6 +501,23 @@ props: This lets you select a parent item without expanding or collapsing its children. :: +### With checkbox in items :badge{label="Soon"} + +You can use the `item-leading` slot to add a [Checkbox](/docs/components/checkbox) to the items. Use the `multiple`, `propagate-select` and `bubble-select` props to enable multi-selection with parent-child relationship and the `select` and `toggle` events to control the selected and expanded state of the items. + +::component-example +--- +name: 'tree-checkbox-items-example' +collapse: true +props: + class: 'w-60' +--- +:: + +::note +This example uses the `as` prop to change the items from `button` to `div` as the [`Checkbox`](/docs/components/checkbox) is also rendered as a `button`. +:: + ### With virtualization :badge{label="Soon"} Use the `virtualize` prop to enable virtualization for large lists as a boolean or an object with options like `{ estimateSize: 32, overscan: 12 }`. diff --git a/playgrounds/nuxt/app/pages/components/table.vue b/playgrounds/nuxt/app/pages/components/table.vue index 192785d011..e3cf090619 100644 --- a/playgrounds/nuxt/app/pages/components/table.vue +++ b/playgrounds/nuxt/app/pages/components/table.vue @@ -384,8 +384,8 @@ onMounted(() => { onUpdateChecked(checked: boolean) { table?.tableApi?.getColumn(column.id)?.toggleVisibility(!!checked) }, - onSelect(e?: Event) { - e?.preventDefault() + onSelect(e: Event) { + e.preventDefault() } }))" :content="{ align: 'end' }" diff --git a/src/runtime/components/CommandPalette.vue b/src/runtime/components/CommandPalette.vue index bb51dbff7f..0a213df0a2 100644 --- a/src/runtime/components/CommandPalette.vue +++ b/src/runtime/components/CommandPalette.vue @@ -32,7 +32,7 @@ export interface CommandPaletteItem extends Omit void class?: any ui?: Pick [key: string]: any diff --git a/src/runtime/components/ContextMenu.vue b/src/runtime/components/ContextMenu.vue index 994bd4f6ca..208e548dfd 100644 --- a/src/runtime/components/ContextMenu.vue +++ b/src/runtime/components/ContextMenu.vue @@ -31,8 +31,8 @@ export interface ContextMenuItem extends Omit - onSelect?(e: Event): void - onUpdateChecked?(checked: boolean): void + onSelect?: (e: Event) => void + onUpdateChecked?: (checked: boolean) => void class?: any ui?: Pick [key: string]: any diff --git a/src/runtime/components/DropdownMenu.vue b/src/runtime/components/DropdownMenu.vue index b0b895891c..5eb96481c1 100644 --- a/src/runtime/components/DropdownMenu.vue +++ b/src/runtime/components/DropdownMenu.vue @@ -31,8 +31,8 @@ export interface DropdownMenuItem extends Omit - onSelect?(e: Event): void - onUpdateChecked?(checked: boolean): void + onSelect?: (e: Event) => void + onUpdateChecked?: (checked: boolean) => void class?: any ui?: Pick [key: string]: any diff --git a/src/runtime/components/InputMenu.vue b/src/runtime/components/InputMenu.vue index 49594f32fb..be0fb4bd3c 100644 --- a/src/runtime/components/InputMenu.vue +++ b/src/runtime/components/InputMenu.vue @@ -25,7 +25,7 @@ export type InputMenuItem = InputMenuValue | { */ type?: 'label' | 'separator' | 'item' disabled?: boolean - onSelect?(e?: Event): void + onSelect?: (e: Event) => void class?: any ui?: Pick [key: string]: any diff --git a/src/runtime/components/NavigationMenu.vue b/src/runtime/components/NavigationMenu.vue index cbcdbbb2e7..b4641b77c8 100644 --- a/src/runtime/components/NavigationMenu.vue +++ b/src/runtime/components/NavigationMenu.vue @@ -57,7 +57,7 @@ export interface NavigationMenuItem extends Omit void class?: any ui?: Pick [key: string]: any diff --git a/src/runtime/components/Select.vue b/src/runtime/components/Select.vue index 67d1c0e510..96da5bacb5 100644 --- a/src/runtime/components/Select.vue +++ b/src/runtime/components/Select.vue @@ -25,7 +25,7 @@ export type SelectItem = SelectValue | { type?: 'label' | 'separator' | 'item' value?: SelectValue disabled?: boolean - onSelect?(e?: Event): void + onSelect?: (e: Event) => void class?: any ui?: Pick [key: string]: any diff --git a/src/runtime/components/SelectMenu.vue b/src/runtime/components/SelectMenu.vue index 86fb87e7a8..191b73f5cb 100644 --- a/src/runtime/components/SelectMenu.vue +++ b/src/runtime/components/SelectMenu.vue @@ -24,7 +24,7 @@ export type SelectMenuItem = SelectMenuValue | { */ type?: 'label' | 'separator' | 'item' disabled?: boolean - onSelect?(e?: Event): void + onSelect?: (e: Event) => void class?: any ui?: Pick [key: string]: any diff --git a/src/runtime/components/Tree.vue b/src/runtime/components/Tree.vue index ea3d996caa..6b52f7f657 100644 --- a/src/runtime/components/Tree.vue +++ b/src/runtime/components/Tree.vue @@ -1,6 +1,6 @@