sv5ui 1.1.3 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/Alert/Alert.svelte +33 -22
- package/dist/Alert/Alert.svelte.d.ts +1 -1
- package/dist/Alert/alert.types.d.ts +4 -0
- package/dist/Avatar/Avatar.svelte +72 -46
- package/dist/Avatar/avatar.types.d.ts +36 -3
- package/dist/Avatar/avatar.variants.d.ts +138 -0
- package/dist/Avatar/avatar.variants.js +23 -12
- package/dist/Avatar/index.d.ts +1 -1
- package/dist/AvatarGroup/AvatarGroup.svelte +11 -6
- package/dist/AvatarGroup/AvatarGroup.svelte.d.ts +1 -1
- package/dist/AvatarGroup/avatar-group.types.d.ts +18 -3
- package/dist/AvatarGroup/avatar-group.variants.d.ts +85 -0
- package/dist/AvatarGroup/avatar-group.variants.js +19 -29
- package/dist/Badge/Badge.svelte +4 -3
- package/dist/Badge/Badge.svelte.d.ts +1 -1
- package/dist/Badge/badge.types.d.ts +9 -0
- package/dist/Breadcrumb/Breadcrumb.svelte +20 -7
- package/dist/Breadcrumb/Breadcrumb.svelte.d.ts +1 -1
- package/dist/Breadcrumb/breadcrumb.types.d.ts +5 -1
- package/dist/Breadcrumb/breadcrumb.variants.d.ts +15 -5
- package/dist/Breadcrumb/breadcrumb.variants.js +7 -3
- package/dist/Button/Button.svelte +71 -16
- package/dist/Button/Button.svelte.d.ts +0 -1
- package/dist/Button/button.types.d.ts +61 -2
- package/dist/Calendar/Calendar.svelte +4 -0
- package/dist/Calendar/Calendar.svelte.d.ts +1 -1
- package/dist/Calendar/calendar.types.d.ts +4 -0
- package/dist/Card/Card.svelte +5 -4
- package/dist/Card/Card.svelte.d.ts +1 -1
- package/dist/Card/card.types.d.ts +5 -1
- package/dist/Checkbox/Checkbox.svelte +37 -11
- package/dist/Checkbox/Checkbox.svelte.d.ts +1 -1
- package/dist/Checkbox/checkbox.types.d.ts +16 -1
- package/dist/Checkbox/checkbox.variants.d.ts +90 -0
- package/dist/Checkbox/checkbox.variants.js +73 -4
- package/dist/Chip/Chip.svelte +3 -2
- package/dist/Chip/Chip.svelte.d.ts +1 -1
- package/dist/Chip/chip.types.d.ts +5 -1
- package/dist/Chip/chip.variants.d.ts +135 -45
- package/dist/Chip/chip.variants.js +9 -9
- package/dist/ContextMenu/ContextMenu.svelte +87 -77
- package/dist/ContextMenu/ContextMenu.svelte.d.ts +1 -1
- package/dist/ContextMenu/context-menu.types.d.ts +9 -3
- package/dist/ContextMenu/context-menu.types.js +1 -1
- package/dist/ContextMenu/context-menu.variants.d.ts +74 -160
- package/dist/ContextMenu/context-menu.variants.js +63 -95
- package/dist/DropdownMenu/DropdownMenu.svelte +37 -43
- package/dist/DropdownMenu/DropdownMenu.svelte.d.ts +1 -1
- package/dist/DropdownMenu/dropdown-menu.types.d.ts +9 -3
- package/dist/DropdownMenu/dropdown-menu.types.js +1 -1
- package/dist/DropdownMenu/dropdown-menu.variants.d.ts +79 -230
- package/dist/DropdownMenu/dropdown-menu.variants.js +68 -111
- package/dist/DropdownMenu/index.d.ts +1 -1
- package/dist/Empty/Empty.svelte +68 -33
- package/dist/Empty/Empty.svelte.d.ts +1 -1
- package/dist/Empty/empty.types.d.ts +26 -9
- package/dist/Empty/empty.variants.d.ts +150 -130
- package/dist/Empty/empty.variants.js +33 -324
- package/dist/FieldGroup/FieldGroup.svelte +11 -6
- package/dist/FieldGroup/FieldGroup.svelte.d.ts +1 -1
- package/dist/FieldGroup/field-group.types.d.ts +4 -0
- package/dist/FormField/FormField.svelte +17 -18
- package/dist/FormField/FormField.svelte.d.ts +1 -1
- package/dist/FormField/form-field.types.d.ts +4 -0
- package/dist/Icon/Icon.svelte +13 -7
- package/dist/Icon/icon.types.d.ts +18 -9
- package/dist/Input/Input.svelte +30 -29
- package/dist/Kbd/Kbd.svelte +13 -3
- package/dist/Kbd/Kbd.svelte.d.ts +1 -1
- package/dist/Kbd/index.d.ts +1 -1
- package/dist/Kbd/kbd.types.d.ts +15 -1
- package/dist/Kbd/kbd.variants.d.ts +92 -30
- package/dist/Kbd/kbd.variants.js +55 -35
- package/dist/Kbd/useKbd.svelte.d.ts +2 -2
- package/dist/Kbd/useKbd.svelte.js +34 -41
- package/dist/Link/Link.svelte +69 -24
- package/dist/Link/Link.svelte.d.ts +1 -1
- package/dist/Link/link.types.d.ts +26 -8
- package/dist/Link/link.variants.d.ts +35 -60
- package/dist/Link/link.variants.js +8 -110
- package/dist/Modal/Modal.svelte +9 -1
- package/dist/Modal/modal.types.d.ts +5 -0
- package/dist/Modal/modal.variants.d.ts +5 -0
- package/dist/Modal/modal.variants.js +1 -0
- package/dist/Pagination/Pagination.svelte +143 -94
- package/dist/Pagination/Pagination.svelte.d.ts +1 -1
- package/dist/Pagination/index.d.ts +1 -1
- package/dist/Pagination/pagination.types.d.ts +21 -2
- package/dist/Pagination/pagination.variants.d.ts +21 -387
- package/dist/Pagination/pagination.variants.js +63 -59
- package/dist/Popover/Popover.svelte +9 -12
- package/dist/Popover/Popover.svelte.d.ts +1 -1
- package/dist/Popover/popover.types.d.ts +4 -0
- package/dist/Popover/popover.variants.d.ts +5 -75
- package/dist/Popover/popover.variants.js +6 -16
- package/dist/Progress/Progress.svelte +58 -30
- package/dist/Progress/progress.types.d.ts +9 -1
- package/dist/Progress/progress.variants.d.ts +55 -25
- package/dist/Progress/progress.variants.js +34 -28
- package/dist/RadioGroup/RadioGroup.svelte +105 -61
- package/dist/RadioGroup/RadioGroup.svelte.d.ts +1 -1
- package/dist/RadioGroup/radio-group.types.d.ts +16 -1
- package/dist/RadioGroup/radio-group.variants.d.ts +90 -0
- package/dist/RadioGroup/radio-group.variants.js +73 -4
- package/dist/Select/Select.svelte +9 -6
- package/dist/Select/Select.svelte.d.ts +1 -1
- package/dist/Select/select.types.d.ts +4 -0
- package/dist/SelectMenu/SelectMenu.svelte +436 -0
- package/dist/SelectMenu/SelectMenu.svelte.d.ts +5 -0
- package/dist/SelectMenu/index.d.ts +2 -0
- package/dist/SelectMenu/index.js +1 -0
- package/dist/SelectMenu/select-menu.types.d.ts +262 -0
- package/dist/SelectMenu/select-menu.types.js +1 -0
- package/dist/SelectMenu/select-menu.variants.d.ts +759 -0
- package/dist/SelectMenu/select-menu.variants.js +33 -0
- package/dist/Separator/Separator.svelte +1 -2
- package/dist/Separator/separator.variants.d.ts +1 -5
- package/dist/Separator/separator.variants.js +2 -2
- package/dist/Skeleton/Skeleton.svelte +18 -2
- package/dist/Skeleton/Skeleton.svelte.d.ts +1 -1
- package/dist/Skeleton/skeleton.types.d.ts +10 -1
- package/dist/Slideover/Slideover.svelte +9 -1
- package/dist/Slideover/slideover.types.d.ts +5 -0
- package/dist/Slideover/slideover.variants.d.ts +20 -5
- package/dist/Slideover/slideover.variants.js +4 -29
- package/dist/Switch/Switch.svelte +32 -31
- package/dist/Switch/Switch.svelte.d.ts +1 -1
- package/dist/Switch/switch.types.d.ts +6 -1
- package/dist/Switch/switch.variants.js +6 -6
- package/dist/Tabs/Tabs.svelte +6 -9
- package/dist/Tabs/Tabs.svelte.d.ts +1 -1
- package/dist/Tabs/tabs.types.d.ts +4 -0
- package/dist/Tabs/tabs.variants.js +2 -0
- package/dist/Textarea/Textarea.svelte +26 -25
- package/dist/ThemeModeButton/theme-mode-button.types.d.ts +7 -2
- package/dist/Timeline/Timeline.svelte +62 -19
- package/dist/Timeline/Timeline.svelte.d.ts +1 -1
- package/dist/Timeline/index.d.ts +1 -1
- package/dist/Timeline/timeline.types.d.ts +8 -0
- package/dist/Tooltip/Tooltip.svelte +12 -10
- package/dist/Tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/Tooltip/tooltip.types.d.ts +8 -4
- package/dist/Tooltip/tooltip.variants.d.ts +10 -75
- package/dist/Tooltip/tooltip.variants.js +8 -17
- package/dist/User/User.svelte +13 -9
- package/dist/User/User.svelte.d.ts +1 -1
- package/dist/User/user.types.d.ts +4 -0
- package/dist/User/user.variants.d.ts +60 -0
- package/dist/User/user.variants.js +13 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import type {
|
|
3
3
|
ContextMenuProps,
|
|
4
4
|
ContextMenuItem,
|
|
5
|
-
ContextMenuItemAction
|
|
5
|
+
ContextMenuItemAction,
|
|
6
|
+
ContextMenuItemCheckbox,
|
|
7
|
+
ContextMenuItemRadio,
|
|
8
|
+
ContextMenuItemSub
|
|
6
9
|
} from './context-menu.types.js'
|
|
7
10
|
|
|
8
11
|
export type Props = ContextMenuProps
|
|
@@ -13,21 +16,23 @@
|
|
|
13
16
|
import {
|
|
14
17
|
contextMenuVariants,
|
|
15
18
|
contextMenuDefaults,
|
|
16
|
-
|
|
19
|
+
itemColorClasses
|
|
17
20
|
} from './context-menu.variants.js'
|
|
18
21
|
import { getComponentConfig, iconsDefaults } from '../config.js'
|
|
19
22
|
import Icon from '../Icon/Icon.svelte'
|
|
20
23
|
import Kbd from '../Kbd/Kbd.svelte'
|
|
21
24
|
|
|
22
25
|
const config = getComponentConfig('contextMenu', contextMenuDefaults)
|
|
26
|
+
const icons = getComponentConfig('icons', iconsDefaults)
|
|
23
27
|
|
|
24
28
|
let {
|
|
29
|
+
ref = $bindable(null),
|
|
25
30
|
open = $bindable(false),
|
|
26
31
|
onOpenChange,
|
|
27
32
|
items = [],
|
|
28
33
|
radioGroups = [],
|
|
29
|
-
checkedIcon =
|
|
30
|
-
submenuIcon =
|
|
34
|
+
checkedIcon = icons.check,
|
|
35
|
+
submenuIcon = icons.chevronRight,
|
|
31
36
|
sideOffset = 4,
|
|
32
37
|
alignOffset = 0,
|
|
33
38
|
avoidCollisions = true,
|
|
@@ -57,73 +62,63 @@
|
|
|
57
62
|
const hasRadioItems = $derived(items.some((i) => i.type === 'radio'))
|
|
58
63
|
const firstRadioGroup = $derived(radioGroups[0])
|
|
59
64
|
|
|
60
|
-
// Compute variant classes once per transition/size/ui change
|
|
61
65
|
const variantSlots = $derived(contextMenuVariants({ transition, size }))
|
|
62
|
-
|
|
63
|
-
function resolveSlot(slot: keyof ReturnType<typeof contextMenuVariants>) {
|
|
64
|
-
return variantSlots[slot]({
|
|
65
|
-
class: [config.slots[slot], ui?.[slot]]
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
|
|
69
66
|
const classes = $derived({
|
|
70
|
-
content:
|
|
71
|
-
group:
|
|
72
|
-
separator:
|
|
73
|
-
label:
|
|
74
|
-
item:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const cache: Partial<Record<ColorKey, ReturnType<typeof contextMenuVariants>>> = {}
|
|
91
|
-
return (color: ColorKey) => {
|
|
92
|
-
cache[color] ??= contextMenuVariants({ size, color })
|
|
93
|
-
return cache[color]
|
|
94
|
-
}
|
|
67
|
+
content: variantSlots.content({ class: [config.slots.content, ui?.content] }),
|
|
68
|
+
group: variantSlots.group({ class: [config.slots.group, ui?.group] }),
|
|
69
|
+
separator: variantSlots.separator({ class: [config.slots.separator, ui?.separator] }),
|
|
70
|
+
label: variantSlots.label({ class: [config.slots.label, ui?.label] }),
|
|
71
|
+
item: variantSlots.item({ class: [config.slots.item, ui?.item] }),
|
|
72
|
+
itemLeadingIcon: variantSlots.itemLeadingIcon({
|
|
73
|
+
class: [config.slots.itemLeadingIcon, ui?.itemLeadingIcon]
|
|
74
|
+
}),
|
|
75
|
+
itemLabel: variantSlots.itemLabel({ class: [config.slots.itemLabel, ui?.itemLabel] }),
|
|
76
|
+
itemTrailingKbds: variantSlots.itemTrailingKbds({
|
|
77
|
+
class: [config.slots.itemTrailingKbds, ui?.itemTrailingKbds]
|
|
78
|
+
}),
|
|
79
|
+
itemIndicator: variantSlots.itemIndicator({
|
|
80
|
+
class: [config.slots.itemIndicator, ui?.itemIndicator]
|
|
81
|
+
}),
|
|
82
|
+
subTrigger: variantSlots.subTrigger({ class: [config.slots.subTrigger, ui?.subTrigger] }),
|
|
83
|
+
subTriggerIcon: variantSlots.subTriggerIcon({
|
|
84
|
+
class: [config.slots.subTriggerIcon, ui?.subTriggerIcon]
|
|
85
|
+
}),
|
|
86
|
+
subContent: variantSlots.subContent({ class: [config.slots.subContent, ui?.subContent] })
|
|
95
87
|
})
|
|
96
88
|
|
|
97
89
|
function close() {
|
|
98
90
|
open = false
|
|
99
91
|
}
|
|
100
92
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
// Type guards
|
|
94
|
+
function isActionItem(item: ContextMenuItem): item is ContextMenuItemAction {
|
|
95
|
+
return !item.type || item.type === 'item'
|
|
104
96
|
}
|
|
105
97
|
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
item: colorVariant.item({ class: [config.slots.item, ui?.item, item.class] }),
|
|
110
|
-
itemIcon: colorVariant.itemIcon({ class: [config.slots.itemIcon, ui?.itemIcon] })
|
|
111
|
-
}
|
|
98
|
+
function isCheckboxItem(item: ContextMenuItem): item is ContextMenuItemCheckbox {
|
|
99
|
+
return item.type === 'checkbox'
|
|
112
100
|
}
|
|
113
101
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
102
|
+
function isRadioItem(item: ContextMenuItem): item is ContextMenuItemRadio {
|
|
103
|
+
return item.type === 'radio'
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function isSubItem(item: ContextMenuItem): item is ContextMenuItemSub {
|
|
107
|
+
return item.type === 'sub'
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function isSeparator(item: ContextMenuItem): item is { type: 'separator' } {
|
|
111
|
+
return item.type === 'separator'
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function isLabel(item: ContextMenuItem): item is { type: 'label'; label: string } {
|
|
115
|
+
return item.type === 'label'
|
|
116
|
+
}
|
|
122
117
|
</script>
|
|
123
118
|
|
|
124
119
|
{#snippet renderKbds(kbds: ContextMenuItemAction['kbds'])}
|
|
125
120
|
{#if kbds?.length}
|
|
126
|
-
<span class={classes.
|
|
121
|
+
<span class={classes.itemTrailingKbds}>
|
|
127
122
|
{#each kbds as kbd, i (i)}
|
|
128
123
|
{#if typeof kbd === 'string'}
|
|
129
124
|
<Kbd value={kbd} size="sm" variant="subtle" />
|
|
@@ -136,22 +131,25 @@
|
|
|
136
131
|
{/snippet}
|
|
137
132
|
|
|
138
133
|
{#snippet renderItem(item: ContextMenuItem, index: number)}
|
|
139
|
-
{#if item
|
|
134
|
+
{#if isSeparator(item)}
|
|
140
135
|
<ContextMenu.Separator class={classes.separator} />
|
|
141
|
-
{:else if item
|
|
136
|
+
{:else if isLabel(item)}
|
|
142
137
|
<ContextMenu.GroupHeading class={classes.label}>{item.label}</ContextMenu.GroupHeading>
|
|
143
|
-
{:else if
|
|
144
|
-
{@const
|
|
138
|
+
{:else if isActionItem(item)}
|
|
139
|
+
{@const colorCls = itemColorClasses[item.color ?? 'default']}
|
|
145
140
|
<ContextMenu.Item
|
|
146
141
|
disabled={item.disabled}
|
|
147
|
-
closeOnSelect={
|
|
148
|
-
onSelect={
|
|
149
|
-
class={
|
|
142
|
+
closeOnSelect={item.closeOnSelect}
|
|
143
|
+
onSelect={item.onSelect}
|
|
144
|
+
class={[classes.item, colorCls.item, item.class]}
|
|
150
145
|
>
|
|
151
146
|
{#if itemLeading}
|
|
152
147
|
{@render itemLeading({ item, index })}
|
|
153
148
|
{:else if item.icon}
|
|
154
|
-
<Icon
|
|
149
|
+
<Icon
|
|
150
|
+
name={item.icon}
|
|
151
|
+
class={[classes.itemLeadingIcon, colorCls.itemLeadingIcon]}
|
|
152
|
+
/>
|
|
155
153
|
{/if}
|
|
156
154
|
|
|
157
155
|
{#if itemLabel}
|
|
@@ -163,10 +161,10 @@
|
|
|
163
161
|
{#if itemTrailing}
|
|
164
162
|
{@render itemTrailing({ item, index })}
|
|
165
163
|
{:else}
|
|
166
|
-
{@render renderKbds(
|
|
164
|
+
{@render renderKbds(item.kbds)}
|
|
167
165
|
{/if}
|
|
168
166
|
</ContextMenu.Item>
|
|
169
|
-
{:else if item
|
|
167
|
+
{:else if isCheckboxItem(item)}
|
|
170
168
|
<ContextMenu.CheckboxItem
|
|
171
169
|
checked={item.checked}
|
|
172
170
|
disabled={item.disabled}
|
|
@@ -177,9 +175,9 @@
|
|
|
177
175
|
{#if itemLeading}
|
|
178
176
|
{@render itemLeading({ item, index })}
|
|
179
177
|
{:else}
|
|
180
|
-
<span class={classes.
|
|
178
|
+
<span class={classes.itemIndicator}>
|
|
181
179
|
{#if item.checked}
|
|
182
|
-
<Icon name={checkedIcon}
|
|
180
|
+
<Icon name={checkedIcon} />
|
|
183
181
|
{/if}
|
|
184
182
|
</span>
|
|
185
183
|
{/if}
|
|
@@ -196,7 +194,7 @@
|
|
|
196
194
|
{@render renderKbds(item.kbds)}
|
|
197
195
|
{/if}
|
|
198
196
|
</ContextMenu.CheckboxItem>
|
|
199
|
-
{:else if item
|
|
197
|
+
{:else if isRadioItem(item)}
|
|
200
198
|
<ContextMenu.RadioItem
|
|
201
199
|
value={item.value}
|
|
202
200
|
disabled={item.disabled}
|
|
@@ -206,9 +204,9 @@
|
|
|
206
204
|
{#if itemLeading}
|
|
207
205
|
{@render itemLeading({ item, index })}
|
|
208
206
|
{:else}
|
|
209
|
-
<span class={classes.
|
|
207
|
+
<span class={classes.itemIndicator}>
|
|
210
208
|
{#if firstRadioGroup?.value === item.value}
|
|
211
|
-
<Icon name={checkedIcon}
|
|
209
|
+
<Icon name={checkedIcon} />
|
|
212
210
|
{/if}
|
|
213
211
|
</span>
|
|
214
212
|
{/if}
|
|
@@ -225,7 +223,7 @@
|
|
|
225
223
|
{@render renderKbds(item.kbds)}
|
|
226
224
|
{/if}
|
|
227
225
|
</ContextMenu.RadioItem>
|
|
228
|
-
{:else if item
|
|
226
|
+
{:else if isSubItem(item)}
|
|
229
227
|
<ContextMenu.Sub open={item.open} onOpenChange={item.onOpenChange}>
|
|
230
228
|
<ContextMenu.SubTrigger
|
|
231
229
|
disabled={item.disabled}
|
|
@@ -234,7 +232,7 @@
|
|
|
234
232
|
{#if itemLeading}
|
|
235
233
|
{@render itemLeading({ item, index })}
|
|
236
234
|
{:else if item.icon}
|
|
237
|
-
<Icon name={item.icon} class={classes.
|
|
235
|
+
<Icon name={item.icon} class={classes.itemLeadingIcon} />
|
|
238
236
|
{/if}
|
|
239
237
|
|
|
240
238
|
{#if itemLabel}
|
|
@@ -246,7 +244,14 @@
|
|
|
246
244
|
<Icon name={submenuIcon} class={classes.subTriggerIcon} />
|
|
247
245
|
</ContextMenu.SubTrigger>
|
|
248
246
|
|
|
249
|
-
<ContextMenu.SubContent
|
|
247
|
+
<ContextMenu.SubContent
|
|
248
|
+
{sideOffset}
|
|
249
|
+
{alignOffset}
|
|
250
|
+
{avoidCollisions}
|
|
251
|
+
{collisionBoundary}
|
|
252
|
+
{collisionPadding}
|
|
253
|
+
class={classes.subContent}
|
|
254
|
+
>
|
|
250
255
|
<div class={classes.group}>
|
|
251
256
|
{#each item.items as subItem, subIndex (subIndex)}
|
|
252
257
|
{@render renderItem(subItem, subIndex)}
|
|
@@ -276,7 +281,12 @@
|
|
|
276
281
|
|
|
277
282
|
{#snippet contextMenuContentEl()}
|
|
278
283
|
<ContextMenu.Content
|
|
279
|
-
|
|
284
|
+
bind:ref
|
|
285
|
+
{sideOffset}
|
|
286
|
+
{alignOffset}
|
|
287
|
+
{avoidCollisions}
|
|
288
|
+
{collisionBoundary}
|
|
289
|
+
{collisionPadding}
|
|
280
290
|
{hideWhenDetached}
|
|
281
291
|
{onEscapeKeydown}
|
|
282
292
|
{onInteractOutside}
|
|
@@ -295,9 +305,9 @@
|
|
|
295
305
|
<ContextMenu.Group class={classes.group}>
|
|
296
306
|
{#if itemSlot}
|
|
297
307
|
{#each items as item, index (index)}
|
|
298
|
-
{#if item
|
|
308
|
+
{#if isSeparator(item)}
|
|
299
309
|
<ContextMenu.Separator class={classes.separator} />
|
|
300
|
-
{:else if item
|
|
310
|
+
{:else if isLabel(item)}
|
|
301
311
|
<ContextMenu.GroupHeading class={classes.label}
|
|
302
312
|
>{item.label}</ContextMenu.GroupHeading
|
|
303
313
|
>
|
|
@@ -317,7 +327,7 @@
|
|
|
317
327
|
</ContextMenu.Content>
|
|
318
328
|
{/snippet}
|
|
319
329
|
|
|
320
|
-
<ContextMenu.Root bind:open onOpenChange
|
|
330
|
+
<ContextMenu.Root bind:open {onOpenChange}>
|
|
321
331
|
{#if children}
|
|
322
332
|
<ContextMenu.Trigger class={className as string}>
|
|
323
333
|
{@render children({ open })}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContextMenuProps } from './context-menu.types.js';
|
|
2
2
|
export type Props = ContextMenuProps;
|
|
3
3
|
import { ContextMenu } from 'bits-ui';
|
|
4
|
-
declare const ContextMenu: import("svelte").Component<ContextMenuProps, {}, "open">;
|
|
4
|
+
declare const ContextMenu: import("svelte").Component<ContextMenuProps, {}, "ref" | "open">;
|
|
5
5
|
type ContextMenu = ReturnType<typeof ContextMenu>;
|
|
6
6
|
export default ContextMenu;
|
|
@@ -3,6 +3,8 @@ import type { ClassNameValue } from 'tailwind-merge';
|
|
|
3
3
|
import type { ContextMenuSlots, ContextMenuVariantProps } from './context-menu.variants.js';
|
|
4
4
|
import type { KbdProps } from '../Kbd/kbd.types.js';
|
|
5
5
|
import type { ContextMenuRootPropsWithoutHTML, ContextMenuContentPropsWithoutHTML } from 'bits-ui';
|
|
6
|
+
import { itemColorClasses } from './context-menu.variants.js';
|
|
7
|
+
export type ContextMenuItemColor = Exclude<keyof typeof itemColorClasses, 'default'>;
|
|
6
8
|
/**
|
|
7
9
|
* Base item properties shared across all item types.
|
|
8
10
|
*/
|
|
@@ -49,7 +51,7 @@ export interface ContextMenuItemAction extends ContextMenuItemBase {
|
|
|
49
51
|
/**
|
|
50
52
|
* Color variant for the item (useful for destructive actions).
|
|
51
53
|
*/
|
|
52
|
-
color?:
|
|
54
|
+
color?: ContextMenuItemColor;
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
55
57
|
* Checkbox menu item for toggling boolean state.
|
|
@@ -166,6 +168,10 @@ type ContentProps = Pick<ContextMenuContentPropsWithoutHTML, 'sideOffset' | 'ali
|
|
|
166
168
|
* @see https://bits-ui.com/docs/components/context-menu
|
|
167
169
|
*/
|
|
168
170
|
export interface ContextMenuProps extends RootProps, ContentProps {
|
|
171
|
+
/**
|
|
172
|
+
* Bindable reference to the content DOM element.
|
|
173
|
+
*/
|
|
174
|
+
ref?: HTMLElement | null;
|
|
169
175
|
/**
|
|
170
176
|
* Array of menu items to render.
|
|
171
177
|
* Each item can be an action, checkbox, radio, separator, label, or submenu.
|
|
@@ -190,7 +196,7 @@ export interface ContextMenuProps extends RootProps, ContentProps {
|
|
|
190
196
|
* Animate the context menu on open and close.
|
|
191
197
|
* @default true
|
|
192
198
|
*/
|
|
193
|
-
transition?: ContextMenuVariantProps['transition']
|
|
199
|
+
transition?: NonNullable<ContextMenuVariantProps['transition']>;
|
|
194
200
|
/**
|
|
195
201
|
* Render the context menu content in a portal.
|
|
196
202
|
* @default true
|
|
@@ -200,7 +206,7 @@ export interface ContextMenuProps extends RootProps, ContentProps {
|
|
|
200
206
|
* Size variant for the context menu.
|
|
201
207
|
* @default 'md'
|
|
202
208
|
*/
|
|
203
|
-
size?: ContextMenuVariantProps['size']
|
|
209
|
+
size?: NonNullable<ContextMenuVariantProps['size']>;
|
|
204
210
|
/**
|
|
205
211
|
* Additional CSS class for the trigger wrapper.
|
|
206
212
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import { itemColorClasses } from './context-menu.variants.js';
|