@bitrix24/b24ui-nuxt 0.5.2 → 0.5.4

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.
Files changed (55) hide show
  1. package/.nuxt/b24ui/button.ts +10 -10
  2. package/.nuxt/b24ui/container.ts +1 -1
  3. package/.nuxt/b24ui/navigation-menu.ts +185 -11
  4. package/.nuxt/b24ui/switch.ts +1 -1
  5. package/.nuxt/b24ui/tabs.ts +1 -1
  6. package/dist/meta.cjs +48504 -45664
  7. package/dist/meta.d.cts +48504 -45664
  8. package/dist/meta.d.mts +48504 -45664
  9. package/dist/meta.d.ts +48504 -45664
  10. package/dist/meta.mjs +48504 -45664
  11. package/dist/module.cjs +1 -1
  12. package/dist/module.d.cts +2 -1
  13. package/dist/module.d.mts +2 -1
  14. package/dist/module.d.ts +2 -1
  15. package/dist/module.json +1 -1
  16. package/dist/module.mjs +1 -1
  17. package/dist/runtime/components/Alert.vue +1 -1
  18. package/dist/runtime/components/App.vue +1 -1
  19. package/dist/runtime/components/Button.vue +1 -1
  20. package/dist/runtime/components/Calendar.vue +40 -12
  21. package/dist/runtime/components/DescriptionList.vue +99 -85
  22. package/dist/runtime/components/DropdownMenu.vue +23 -12
  23. package/dist/runtime/components/DropdownMenuContent.vue +22 -15
  24. package/dist/runtime/components/InputMenu.vue +91 -53
  25. package/dist/runtime/components/Link.vue +3 -0
  26. package/dist/runtime/components/LinkBase.vue +1 -0
  27. package/dist/runtime/components/Modal.vue +1 -1
  28. package/dist/runtime/components/NavigationMenu.vue +65 -26
  29. package/dist/runtime/components/RadioGroup.vue +23 -12
  30. package/dist/runtime/components/Select.vue +74 -47
  31. package/dist/runtime/components/SelectMenu.vue +95 -56
  32. package/dist/runtime/components/Slideover.vue +1 -1
  33. package/dist/runtime/components/Tabs.vue +6 -5
  34. package/dist/runtime/components/Toast.vue +1 -1
  35. package/dist/runtime/composables/defineShortcuts.js +0 -1
  36. package/dist/runtime/composables/useComponentIcons.d.ts +2 -2
  37. package/dist/runtime/types/utils.d.ts +28 -7
  38. package/dist/runtime/utils/index.d.ts +1 -0
  39. package/dist/runtime/utils/index.js +3 -0
  40. package/dist/runtime/utils/link.d.ts +2 -25
  41. package/dist/runtime/utils/link.js +31 -1
  42. package/dist/runtime/vue/components/Link.vue +3 -0
  43. package/dist/runtime/vue/stubs.d.ts +3 -3
  44. package/dist/shared/{b24ui-nuxt.CKEqlXJP.cjs → b24ui-nuxt.BfU7TRfz.cjs} +311 -22
  45. package/dist/shared/{b24ui-nuxt.DQ3Ix7rC.mjs → b24ui-nuxt.CTERD7XY.mjs} +311 -22
  46. package/dist/types.d.mts +7 -1
  47. package/dist/types.d.ts +7 -1
  48. package/dist/unplugin.cjs +1 -1
  49. package/dist/unplugin.d.cts +2 -1
  50. package/dist/unplugin.d.mts +2 -1
  51. package/dist/unplugin.d.ts +2 -1
  52. package/dist/unplugin.mjs +1 -1
  53. package/dist/vite.cjs +1 -1
  54. package/dist/vite.mjs +1 -1
  55. package/package.json +34 -18
@@ -1,21 +1,29 @@
1
1
  <script lang="ts">
2
2
  import type { VariantProps } from 'tailwind-variants'
3
- import type { ComboboxRootProps, ComboboxRootEmits, ComboboxContentProps, ComboboxContentEmits, ComboboxArrowProps, AcceptableValue } from 'reka-ui'
3
+ import type { ComboboxRootProps, ComboboxRootEmits, ComboboxContentProps, ComboboxContentEmits, ComboboxArrowProps } from 'reka-ui'
4
4
  import type { AppConfig } from '@nuxt/schema'
5
5
  import _appConfig from '#build/app.config'
6
6
  import theme from '#build/b24ui/select-menu'
7
7
  import type { UseComponentIconsProps } from '../composables/useComponentIcons'
8
8
  import { tv } from '../utils/tv'
9
9
  import type { AvatarProps, ChipProps, InputProps, IconComponent } from '../types'
10
- import type { PartialString, MaybeArrayOfArray, MaybeArrayOfArrayItem, SelectModelValue, SelectModelValueEmits, SelectItemKey, EmitsToProps } from '../types/utils'
10
+ import type {
11
+ AcceptableValue,
12
+ ArrayOrNested,
13
+ GetItemKeys,
14
+ GetItemValue,
15
+ GetModelValue,
16
+ GetModelValueEmits,
17
+ NestedItem,
18
+ PartialString,
19
+ EmitsToProps
20
+ } from '../types/utils'
11
21
 
12
22
  const appConfigSelectMenu = _appConfig as AppConfig & { b24ui: { selectMenu: Partial<typeof theme> } }
13
23
 
14
24
  const selectMenu = tv({ extend: tv(theme), ...(appConfigSelectMenu.b24ui?.selectMenu || {}) })
15
25
 
16
- type SelectMenuVariants = VariantProps<typeof selectMenu>
17
-
18
- export interface SelectMenuItem {
26
+ interface _SelectMenuItem {
19
27
  label?: string
20
28
  /**
21
29
  * Display an icon on the left side.
@@ -30,11 +38,16 @@ export interface SelectMenuItem {
30
38
  * @defaultValue 'item'
31
39
  */
32
40
  type?: 'label' | 'separator' | 'item'
41
+ value?: string | number
33
42
  disabled?: boolean
34
43
  onSelect?(e?: Event): void
44
+ [key: string]: any
35
45
  }
46
+ export type SelectMenuItem = _SelectMenuItem | AcceptableValue | boolean
47
+
48
+ type SelectMenuVariants = VariantProps<typeof selectMenu>
36
49
 
37
- export interface SelectMenuProps<T extends MaybeArrayOfArrayItem<I>, I extends MaybeArrayOfArray<SelectMenuItem | AcceptableValue | boolean> = MaybeArrayOfArray<SelectMenuItem | AcceptableValue | boolean>, V extends SelectItemKey<T> | undefined = undefined, M extends boolean = false> extends Pick<ComboboxRootProps<T>, 'open' | 'defaultOpen' | 'disabled' | 'name' | 'resetSearchTermOnBlur' | 'highlightOnHover'>, UseComponentIconsProps {
50
+ export interface SelectMenuProps<T extends ArrayOrNested<SelectMenuItem> = ArrayOrNested<SelectMenuItem>, VK extends GetItemKeys<T> | undefined = undefined, M extends boolean = false> extends Pick<ComboboxRootProps<T>, 'open' | 'defaultOpen' | 'disabled' | 'name' | 'resetSearchTermOnBlur' | 'highlightOnHover'>, UseComponentIconsProps {
38
51
  id?: string
39
52
  /** The placeholder text when the select is empty. */
40
53
  placeholder?: string
@@ -113,21 +126,21 @@ export interface SelectMenuProps<T extends MaybeArrayOfArrayItem<I>, I extends M
113
126
  * When `items` is an array of objects, select the field to use as the value instead of the object itself.
114
127
  * @defaultValue undefined
115
128
  */
116
- valueKey?: V
129
+ valueKey?: VK
117
130
  /**
118
131
  * When `items` is an array of objects, select the field to use as the label.
119
132
  * @defaultValue 'label'
120
133
  */
121
- labelKey?: V
122
- items?: I
134
+ labelKey?: keyof NestedItem<T>
135
+ items?: T
123
136
  /**
124
137
  * The value of the SelectMenu when initially rendered. Use when you do not need to control the state of the SelectMenu
125
138
  */
126
- defaultValue?: SelectModelValue<T, V, M>
139
+ defaultValue?: GetModelValue<T, VK, M>
127
140
  /**
128
141
  * The controlled value of the SelectMenu. Can be binded-with with `v-model`
129
142
  */
130
- modelValue?: SelectModelValue<T, V, M>
143
+ modelValue?: GetModelValue<T, VK, M>
131
144
  /**
132
145
  * Whether multiple options can be selected or not
133
146
  * @defaultValue false
@@ -157,19 +170,29 @@ export interface SelectMenuProps<T extends MaybeArrayOfArrayItem<I>, I extends M
157
170
  b24ui?: PartialString<typeof selectMenu.slots>
158
171
  }
159
172
 
160
- export type SelectMenuEmits<T, V, M extends boolean> = Omit<ComboboxRootEmits<T>, 'update:modelValue'> & {
173
+ export type SelectMenuEmits<A extends ArrayOrNested<SelectMenuItem>, VK extends GetItemKeys<A> | undefined, M extends boolean> = Pick<ComboboxRootEmits, 'update:open'> & {
161
174
  change: [payload: Event]
162
175
  blur: [payload: FocusEvent]
163
176
  focus: [payload: FocusEvent]
164
177
  create: [item: string]
165
- } & SelectModelValueEmits<T, V, M>
166
-
167
- type SlotProps<T> = (props: { item: T, index: number }) => any
168
-
169
- export interface SelectMenuSlots<T, M extends boolean> {
170
- 'leading'(props: { modelValue?: M extends true ? T[] : T, open: boolean, b24ui: any }): any
171
- 'default'(props: { modelValue?: M extends true ? T[] : T, open: boolean }): any
172
- 'trailing'(props: { modelValue?: M extends true ? T[] : T, open: boolean, b24ui: any }): any
178
+ /** Event handler when highlighted element changes. */
179
+ highlight: [payload: {
180
+ ref: HTMLElement
181
+ value: GetModelValue<A, VK, M>
182
+ } | undefined]
183
+ } & GetModelValueEmits<A, VK, M>
184
+
185
+ type SlotProps<T extends SelectMenuItem> = (props: { item: T, index: number }) => any
186
+
187
+ export interface SelectMenuSlots<
188
+ A extends ArrayOrNested<SelectMenuItem> = ArrayOrNested<SelectMenuItem>,
189
+ VK extends GetItemKeys<A> | undefined = undefined,
190
+ M extends boolean = false,
191
+ T extends NestedItem<A> = NestedItem<A>
192
+ > {
193
+ 'leading'(props: { modelValue?: GetModelValue<A, VK, M>, open: boolean, b24ui: ReturnType<typeof selectMenu> }): any
194
+ 'default'(props: { modelValue?: GetModelValue<A, VK, M>, open: boolean }): any
195
+ 'trailing'(props: { modelValue?: GetModelValue<A, VK, M>, open: boolean, b24ui: ReturnType<typeof selectMenu> }): any
173
196
  'empty'(props: { searchTerm?: string }): any
174
197
  'item': SlotProps<T>
175
198
  'item-leading': SlotProps<T>
@@ -179,7 +202,7 @@ export interface SelectMenuSlots<T, M extends boolean> {
179
202
  }
180
203
  </script>
181
204
 
182
- <script setup lang="ts" generic="T extends MaybeArrayOfArrayItem<I>, I extends MaybeArrayOfArray<SelectMenuItem | AcceptableValue | boolean> = MaybeArrayOfArray<SelectMenuItem | AcceptableValue | boolean>, V extends SelectItemKey<T> | undefined = undefined, M extends boolean = false">
205
+ <script setup lang="ts" generic="T extends ArrayOrNested<SelectMenuItem>, VK extends GetItemKeys<T> | undefined = undefined, M extends boolean = false">
183
206
  import { computed, toRef, toRaw } from 'vue'
184
207
  import {
185
208
  ComboboxRoot,
@@ -207,7 +230,7 @@ import { useButtonGroup } from '../composables/useButtonGroup'
207
230
  import { useComponentIcons } from '../composables/useComponentIcons'
208
231
  import { useFormField } from '../composables/useFormField'
209
232
  import { useLocale } from '../composables/useLocale'
210
- import { get, compare } from '../utils'
233
+ import { compare, get, isArrayOfArray } from '../utils'
211
234
  import icons from '../dictionary/icons'
212
235
  import B24Avatar from './Avatar.vue'
213
236
  import B24Chip from './Chip.vue'
@@ -215,14 +238,14 @@ import B24Input from './Input.vue'
215
238
 
216
239
  defineOptions({ inheritAttrs: false })
217
240
 
218
- const props = withDefaults(defineProps<SelectMenuProps<T, I, V, M>>(), {
241
+ const props = withDefaults(defineProps<SelectMenuProps<T, VK, M>>(), {
219
242
  portal: true,
220
243
  searchInput: true,
221
244
  labelKey: 'label' as never,
222
245
  resetSearchTermOnBlur: true
223
246
  })
224
- const emits = defineEmits<SelectMenuEmits<T, V, M>>()
225
- const slots = defineSlots<SelectMenuSlots<T, M>>()
247
+ const emits = defineEmits<SelectMenuEmits<T, VK, M>>()
248
+ const slots = defineSlots<SelectMenuSlots<T, VK, M>>()
226
249
 
227
250
  const searchTerm = defineModel<string>('searchTerm', { default: '' })
228
251
 
@@ -264,11 +287,7 @@ const b24ui = computed(() => selectMenu({
264
287
  buttonGroup: orientation.value
265
288
  }))
266
289
 
267
- const groups = computed(() => props.items?.length ? (Array.isArray(props.items[0]) ? props.items : [props.items]) as SelectMenuItem[][] : [])
268
- // eslint-disable-next-line vue/no-dupe-keys
269
- const items = computed(() => groups.value.flatMap(group => group) as T[])
270
-
271
- function displayValue(value: T | T[]): string {
290
+ function displayValue(value: GetItemValue<T, VK> | GetItemValue<T, VK>[]): string {
272
291
  if (props.multiple && Array.isArray(value)) {
273
292
  return value.map(v => displayValue(v)).filter(Boolean).join(', ')
274
293
  }
@@ -281,6 +300,16 @@ function displayValue(value: T | T[]): string {
281
300
  return item && (typeof item === 'object' ? get(item, props.labelKey as string) : item)
282
301
  }
283
302
 
303
+ const groups = computed<SelectMenuItem[][]>(() =>
304
+ props.items?.length
305
+ ? isArrayOfArray(props.items)
306
+ ? props.items
307
+ : [props.items]
308
+ : []
309
+ )
310
+ // eslint-disable-next-line vue/no-dupe-keys
311
+ const items = computed(() => groups.value.flatMap(group => group) as T[])
312
+
284
313
  const filteredGroups = computed(() => {
285
314
  if (props.ignoreFilter || !searchTerm.value) {
286
315
  return groups.value
@@ -289,8 +318,8 @@ const filteredGroups = computed(() => {
289
318
  const fields = Array.isArray(props.filterFields) ? props.filterFields : [props.labelKey] as string[]
290
319
 
291
320
  return groups.value.map(items => items.filter((item) => {
292
- if (typeof item !== 'object') {
293
- return contains(item, searchTerm.value)
321
+ if (typeof item !== 'object' || item === null) {
322
+ return contains(String(item), searchTerm.value)
294
323
  }
295
324
 
296
325
  if (item.type && ['label', 'separator'].includes(item.type)) {
@@ -298,19 +327,25 @@ const filteredGroups = computed(() => {
298
327
  }
299
328
 
300
329
  return fields.some(field => contains(get(item, field), searchTerm.value))
301
- })).filter(group => group.filter(item => !item.type || !['label', 'separator'].includes(item.type)).length > 0)
330
+ })).filter(group => group.filter(item =>
331
+ /**
332
+ * @memo fix not obj
333
+ * @see inputMenu
334
+ */
335
+ typeof item !== 'object' || (isSelectItem(item) && (!item.type || !['label', 'separator'].includes(item.type)))
336
+ ).length > 0)
302
337
  })
303
- const filteredItems = computed(() => filteredGroups.value.flatMap(group => group) as T[])
338
+ const filteredItems = computed(() => filteredGroups.value.flatMap(group => group))
304
339
 
305
340
  const createItem = computed(() => {
306
341
  if (!props.createItem || !searchTerm.value) {
307
342
  return false
308
343
  }
309
344
 
310
- const newItem = props.valueKey ? { [props.valueKey]: searchTerm.value } as T : searchTerm.value
345
+ const newItem = props.valueKey ? { [props.valueKey]: searchTerm.value } as NestedItem<T> : searchTerm.value
311
346
 
312
347
  if ((typeof props.createItem === 'object' && props.createItem.when === 'always') || props.createItem === 'always') {
313
- return !filteredItems.value.find(item => compare(item, newItem, props.valueKey))
348
+ return !filteredItems.value.find(item => compare(item, newItem, String(props.valueKey)))
314
349
  }
315
350
 
316
351
  return !filteredItems.value.length
@@ -356,6 +391,10 @@ function onUpdateOpen(value: boolean) {
356
391
  }
357
392
  }
358
393
  }
394
+
395
+ function isSelectItem(item: SelectMenuItem): item is _SelectMenuItem {
396
+ return typeof item === 'object' && item !== null
397
+ }
359
398
  </script>
360
399
 
361
400
  <!-- eslint-disable vue/no-template-shadow -->
@@ -398,7 +437,7 @@ function onUpdateOpen(value: boolean) {
398
437
  {{ props.tag }}
399
438
  </div>
400
439
  <span v-if="isLeading || !!avatar || !!slots.leading" :class="b24ui.leading({ class: props.b24ui?.leading })">
401
- <slot name="leading" :model-value="(modelValue as M extends true ? T[] : T)" :open="open" :b24ui="b24ui">
440
+ <slot name="leading" :model-value="(modelValue as GetModelValue<T, VK, M>)" :open="open" :b24ui="b24ui">
402
441
  <Component
403
442
  :is="leadingIconName"
404
443
  v-if="isLeading && leadingIconName"
@@ -408,8 +447,8 @@ function onUpdateOpen(value: boolean) {
408
447
  </slot>
409
448
  </span>
410
449
 
411
- <slot :model-value="(modelValue as M extends true ? T[] : T)" :open="open">
412
- <template v-for="displayedModelValue in [displayValue(modelValue as M extends true ? T[] : T)]" :key="displayedModelValue">
450
+ <slot :model-value="(modelValue as GetModelValue<T, VK, M>)" :open="open">
451
+ <template v-for="displayedModelValue in [displayValue(modelValue as GetModelValue<T, VK, M>)]" :key="displayedModelValue">
413
452
  <span v-if="displayedModelValue" :class="b24ui.value({ class: props.b24ui?.value })">
414
453
  {{ displayedModelValue }}
415
454
  </span>
@@ -420,7 +459,7 @@ function onUpdateOpen(value: boolean) {
420
459
  </slot>
421
460
 
422
461
  <span v-if="isTrailing || !!slots.trailing" :class="b24ui.trailing({ class: props.b24ui?.trailing })">
423
- <slot name="trailing" :model-value="(modelValue as M extends true ? T[] : T)" :open="open" :b24ui="b24ui">
462
+ <slot name="trailing" :model-value="(modelValue as GetModelValue<T, VK, M>)" :open="open" :b24ui="b24ui">
424
463
  <Component
425
464
  :is="trailingIconName"
426
465
  v-if="trailingIconName"
@@ -449,29 +488,29 @@ function onUpdateOpen(value: boolean) {
449
488
 
450
489
  <ComboboxGroup v-for="(group, groupIndex) in filteredGroups" :key="`group-${groupIndex}`" :class="b24ui.group({ class: props.b24ui?.group })">
451
490
  <template v-for="(item, index) in group" :key="`group-${groupIndex}-${index}`">
452
- <ComboboxLabel v-if="item?.type === 'label'" :class="b24ui.label({ class: props.b24ui?.label })">
491
+ <ComboboxLabel v-if="isSelectItem(item) && item.type === 'label'" :class="b24ui.label({ class: props.b24ui?.label })">
453
492
  {{ get(item, props.labelKey as string) }}
454
493
  </ComboboxLabel>
455
494
 
456
- <ComboboxSeparator v-else-if="item?.type === 'separator'" :class="b24ui.separator({ class: props.b24ui?.separator })" />
495
+ <ComboboxSeparator v-else-if="isSelectItem(item) && item.type === 'separator'" :class="b24ui.separator({ class: props.b24ui?.separator })" />
457
496
 
458
497
  <ComboboxItem
459
498
  v-else
460
- :class="b24ui.item({ class: props.b24ui?.item, colorItem: item?.color })"
461
- :disabled="item.disabled"
462
- :value="valueKey && typeof item === 'object' ? get(item, props.valueKey as string) : item"
463
- @select="item.onSelect"
499
+ :class="b24ui.item({ class: props.b24ui?.item, colorItem: isSelectItem(item) ? item?.color : undefined })"
500
+ :disabled="isSelectItem(item) && item.disabled"
501
+ :value="props.valueKey && isSelectItem(item) ? get(item, props.valueKey as string) : item"
502
+ @select="isSelectItem(item) && item.onSelect"
464
503
  >
465
- <slot name="item" :item="(item as T)" :index="index">
466
- <slot name="item-leading" :item="(item as T)" :index="index">
504
+ <slot name="item" :item="(item as NestedItem<T>)" :index="index">
505
+ <slot name="item-leading" :item="(item as NestedItem<T>)" :index="index">
467
506
  <Component
468
507
  :is="item.icon"
469
- v-if="item.icon"
508
+ v-if="isSelectItem(item) && item.icon"
470
509
  :class="b24ui.itemLeadingIcon({ class: props.b24ui?.itemLeadingIcon, colorItem: item?.color })"
471
510
  />
472
- <B24Avatar v-else-if="item.avatar" :size="((props.b24ui?.itemLeadingAvatarSize || b24ui.itemLeadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="b24ui.itemLeadingAvatar({ class: props.b24ui?.itemLeadingAvatar, colorItem: item?.color })" />
511
+ <B24Avatar v-else-if="isSelectItem(item) && item.avatar" :size="((props.b24ui?.itemLeadingAvatarSize || b24ui.itemLeadingAvatarSize()) as AvatarProps['size'])" v-bind="item.avatar" :class="b24ui.itemLeadingAvatar({ class: props.b24ui?.itemLeadingAvatar, colorItem: item?.color })" />
473
512
  <B24Chip
474
- v-else-if="item.chip"
513
+ v-else-if="isSelectItem(item) && item.chip"
475
514
  :size="((props.b24ui?.itemLeadingChipSize || b24ui.itemLeadingChipSize()) as ChipProps['size'])"
476
515
  inset
477
516
  standalone
@@ -481,18 +520,18 @@ function onUpdateOpen(value: boolean) {
481
520
  </slot>
482
521
 
483
522
  <span :class="b24ui.itemLabel({ class: props.b24ui?.itemLabel })">
484
- <slot name="item-label" :item="(item as T)" :index="index">
485
- {{ typeof item === 'object' ? get(item, props.labelKey as string) : item }}
523
+ <slot name="item-label" :item="(item as NestedItem<T>)" :index="index">
524
+ {{ isSelectItem(item) ? get(item, props.labelKey as string) : item }}
486
525
  </slot>
487
526
  </span>
488
527
 
489
- <span :class="b24ui.itemTrailing({ class: props.b24ui?.itemTrailing, colorItem: item?.color })">
490
- <slot name="item-trailing" :item="(item as T)" :index="index" />
528
+ <span :class="b24ui.itemTrailing({ class: props.b24ui?.itemTrailing, colorItem: isSelectItem(item) ? item?.color : undefined })">
529
+ <slot name="item-trailing" :item="(item as NestedItem<T>)" :index="index" />
491
530
 
492
531
  <ComboboxItemIndicator as-child>
493
532
  <Component
494
533
  :is="selectedIcon || icons.check"
495
- :class="b24ui.itemTrailingIcon({ class: props.b24ui?.itemTrailingIcon, colorItem: item?.color })"
534
+ :class="b24ui.itemTrailingIcon({ class: props.b24ui?.itemTrailingIcon, colorItem: isSelectItem(item) ? item?.color : undefined })"
496
535
  />
497
536
  </ComboboxItemIndicator>
498
537
  </span>
@@ -83,7 +83,7 @@ export interface SlideoverSlots {
83
83
  header(props?: {}): any
84
84
  title(props?: {}): any
85
85
  description(props?: {}): any
86
- close(props: { b24ui: any }): any
86
+ close(props: { b24ui: ReturnType<typeof slideover> }): any
87
87
  body(props?: {}): any
88
88
  footer(props?: {}): any
89
89
  }
@@ -24,11 +24,12 @@ export interface TabsItem {
24
24
  /** A unique value for the tab item. Defaults to the index. */
25
25
  value?: string | number
26
26
  disabled?: boolean
27
+ [key: string]: any
27
28
  }
28
29
 
29
30
  type TabsVariants = VariantProps<typeof tabs>
30
31
 
31
- export interface TabsProps<T> extends Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
32
+ export interface TabsProps<T extends TabsItem = TabsItem> extends Pick<TabsRootProps<string | number>, 'defaultValue' | 'modelValue' | 'activationMode' | 'unmountOnHide'> {
32
33
  /**
33
34
  * The element or component this component should render as.
34
35
  * @defaultValue 'div'
@@ -68,14 +69,14 @@ export interface TabsProps<T> extends Pick<TabsRootProps<string | number>, 'defa
68
69
 
69
70
  export interface TabsEmits extends TabsRootEmits<string | number> {}
70
71
 
71
- type SlotProps<T> = (props: { item: T, index: number }) => any
72
+ type SlotProps<T extends TabsItem> = (props: { item: T, index: number }) => any
72
73
 
73
- export type TabsSlots<T extends { slot?: string }> = {
74
+ export type TabsSlots<T extends TabsItem = TabsItem> = {
74
75
  leading: SlotProps<T>
75
76
  default: SlotProps<T>
76
77
  trailing: SlotProps<T>
77
78
  content: SlotProps<T>
78
- } & DynamicSlots<T, SlotProps<T>>
79
+ } & DynamicSlots<T, undefined, { index: number }>
79
80
  </script>
80
81
 
81
82
  <script setup lang="ts" generic="T extends TabsItem">
@@ -130,7 +131,7 @@ const b24ui = computed(() => tabs({
130
131
 
131
132
  <template v-if="!!content">
132
133
  <TabsContent v-for="(item, index) of items" :key="index" :value="item.value || String(index)" :class="b24ui.content({ class: props.b24ui?.content })">
133
- <slot :name="item.slot || 'content'" :item="item" :index="index">
134
+ <slot :name="((item.slot || 'content') as keyof TabsSlots<T>)" :item="(item as Extract<T, { slot: string; }>)" :index="index">
134
135
  {{ item.content }}
135
136
  </slot>
136
137
  </TabsContent>
@@ -66,7 +66,7 @@ export interface ToastSlots {
66
66
  title(props?: {}): any
67
67
  description(props?: {}): any
68
68
  actions(props?: {}): any
69
- close(props: { b24ui: any }): any
69
+ close(props: { b24ui: ReturnType<typeof toast> }): any
70
70
  }
71
71
  </script>
72
72
 
@@ -21,7 +21,6 @@ export function extractShortcuts(items) {
21
21
  traverse(items.flat());
22
22
  return shortcuts;
23
23
  }
24
- // @__NO_SIDE_EFFECTS__
25
24
  export function defineShortcuts(config, options = {}) {
26
25
  const chainedInputs = ref([]);
27
26
  const clearChainedInput = () => {
@@ -22,6 +22,6 @@ export interface UseComponentIconsProps {
22
22
  export declare function useComponentIcons(componentProps: MaybeRefOrGetter<UseComponentIconsProps>): {
23
23
  isLeading: import("vue").ComputedRef<any>;
24
24
  isTrailing: import("vue").ComputedRef<boolean>;
25
- leadingIconName: import("vue").ComputedRef<import("vue").FunctionalComponent<import("vue").HTMLAttributes & import("vue").VNodeProps, {}, any, {}> | undefined>;
26
- trailingIconName: import("vue").ComputedRef<import("vue").FunctionalComponent<import("vue").HTMLAttributes & import("vue").VNodeProps, {}, any, {}> | undefined>;
25
+ leadingIconName: import("vue").ComputedRef<IconComponent | undefined>;
26
+ trailingIconName: import("vue").ComputedRef<IconComponent | undefined>;
27
27
  };
@@ -1,3 +1,4 @@
1
+ import type { AcceptableValue as _AcceptableValue } from 'reka-ui';
1
2
  import type { VNode } from 'vue';
2
3
  export interface TightMap<O = any> {
3
4
  [key: string]: TightMap | O;
@@ -9,19 +10,39 @@ export type DeepPartial<T, O = any> = {
9
10
  };
10
11
  export type DynamicSlots<T extends {
11
12
  slot?: string;
12
- }, SlotProps, Slot = T['slot']> = Record<string, SlotProps> & (Slot extends string ? Record<Slot, SlotProps> : Record<string, never>);
13
+ }, S extends string | undefined = undefined, D extends object = {}> = {
14
+ [K in T['slot'] as K extends string ? S extends string ? (K | `${K}-${S}`) : K : never]?: (props: {
15
+ item: Extract<T, {
16
+ slot: K extends `${infer Base}-${S}` ? Base : K;
17
+ }>;
18
+ } & D) => any;
19
+ };
13
20
  export type GetObjectField<MaybeObject, Key extends string> = MaybeObject extends Record<string, any> ? MaybeObject[Key] : never;
14
21
  export type PartialString<T> = {
15
22
  [K in keyof T]?: string;
16
23
  };
17
- export type MaybeArrayOfArray<T> = T[] | T[][];
18
- export type MaybeArrayOfArrayItem<I> = I extends Array<infer T> ? T extends Array<infer U> ? U : T : never;
19
- export type SelectModelValue<T, V, M extends boolean = false, DV = T> = (T extends Record<string, any> ? V extends keyof T ? T[V] : DV : T) extends infer U ? M extends true ? U[] : U : never;
20
- export type SelectItemKey<T> = T extends Record<string, any> ? keyof T : string;
21
- export type SelectModelValueEmits<T, V, M extends boolean = false, DV = T> = {
22
- 'update:modelValue': [payload: SelectModelValue<T, V, M, DV>];
24
+ export type AcceptableValue = Exclude<_AcceptableValue, Record<string, any>>;
25
+ export type ArrayOrNested<T> = T[] | T[][];
26
+ export type NestedItem<T> = T extends Array<infer I> ? NestedItem<I> : T;
27
+ type AllKeys<T> = T extends any ? keyof T : never;
28
+ type NonCommonKeys<T extends object> = Exclude<AllKeys<T>, keyof T>;
29
+ type PickTypeOf<T, K extends string | number | symbol> = K extends AllKeys<T> ? T extends {
30
+ [k in K]?: any;
31
+ } ? T[K] : undefined : never;
32
+ export type MergeTypes<T extends object> = {
33
+ [k in keyof T]: PickTypeOf<T, k>;
34
+ } & {
35
+ [k in NonCommonKeys<T>]?: PickTypeOf<T, k>;
36
+ };
37
+ export type GetItemKeys<I> = keyof Extract<NestedItem<I>, object>;
38
+ export type GetItemValue<I, VK extends GetItemKeys<I> | undefined, T extends NestedItem<I> = NestedItem<I>> = T extends object ? VK extends undefined ? T : VK extends keyof T ? T[VK] : never : T;
39
+ export type GetModelValue<T, VK extends GetItemKeys<T> | undefined, M extends boolean> = M extends true ? GetItemValue<T, VK>[] : GetItemValue<T, VK>;
40
+ export type GetModelValueEmits<T, VK extends GetItemKeys<T> | undefined, M extends boolean> = {
41
+ /** Event handler called when the value changes. */
42
+ 'update:modelValue': [payload: GetModelValue<T, VK, M>];
23
43
  };
24
44
  export type StringOrVNode = string | VNode | (() => VNode);
25
45
  export type EmitsToProps<T> = {
26
46
  [K in keyof T as `on${Capitalize<string & K>}`]: T[K] extends [...args: infer Args] ? (...args: Args) => void : never;
27
47
  };
48
+ export {};
@@ -4,3 +4,4 @@ export declare function get(object: Record<string, any> | undefined, path: (stri
4
4
  export declare function set(object: Record<string, any>, path: (string | number)[] | string, value: any): void;
5
5
  export declare function looseToNumber(val: any): any;
6
6
  export declare function compare<T>(value?: T, currentValue?: T, comparator?: string | ((a: T, b: T) => boolean)): boolean;
7
+ export declare function isArrayOfArray<A>(item: A[] | A[][]): item is A[][];
@@ -61,3 +61,6 @@ export function compare(value, currentValue, comparator) {
61
61
  }
62
62
  return isEqual(value, currentValue);
63
63
  }
64
+ export function isArrayOfArray(item) {
65
+ return Array.isArray(item[0]);
66
+ }
@@ -1,29 +1,6 @@
1
1
  import type { LinkProps } from '../types';
2
2
  export declare function pickLinkProps(link: LinkProps & {
3
- ariaLabel?: string;
4
- title?: string;
3
+ [key: string]: any;
5
4
  }): {
6
- replace: any;
7
- type: any;
8
- title: any;
9
- active: any;
10
- activeClass: any;
11
- ariaCurrentValue: any;
12
- ariaLabel: any;
13
- as: any;
14
- disabled: any;
15
- exact: any;
16
- exactActiveClass: any;
17
- exactHash: any;
18
- exactQuery: any;
19
- external: any;
20
- href: any;
21
- inactiveClass: any;
22
- noPrefetch: any;
23
- noRel: any;
24
- prefetch: any;
25
- prefetchedClass: any;
26
- rel: any;
27
- target: any;
28
- to: any;
5
+ [x: string]: any;
29
6
  };
@@ -1,4 +1,34 @@
1
1
  import { reactivePick } from "@vueuse/core";
2
2
  export function pickLinkProps(link) {
3
- return reactivePick(link, "active", "activeClass", "ariaCurrentValue", "ariaLabel", "as", "disabled", "exact", "exactActiveClass", "exactHash", "exactQuery", "external", "href", "inactiveClass", "noPrefetch", "noRel", "prefetch", "prefetchedClass", "rel", "replace", "target", "to", "type", "title");
3
+ const keys = Object.keys(link);
4
+ const ariaKeys = keys.filter((key) => key.startsWith("aria-"));
5
+ const dataKeys = keys.filter((key) => key.startsWith("data-"));
6
+ const propsToInclude = [
7
+ "active",
8
+ "activeClass",
9
+ "ariaCurrentValue",
10
+ "as",
11
+ "disabled",
12
+ "exact",
13
+ "exactActiveClass",
14
+ "exactHash",
15
+ "exactQuery",
16
+ "external",
17
+ "href",
18
+ "inactiveClass",
19
+ "noPrefetch",
20
+ "noRel",
21
+ "prefetch",
22
+ "prefetchedClass",
23
+ "rel",
24
+ "replace",
25
+ "target",
26
+ "to",
27
+ "type",
28
+ "title",
29
+ "onClick",
30
+ ...ariaKeys,
31
+ ...dataKeys
32
+ ];
33
+ return reactivePick(link, ...propsToInclude);
4
34
  }
@@ -106,6 +106,7 @@ defineOptions({ inheritAttrs: false })
106
106
  const props = withDefaults(defineProps<LinkProps>(), {
107
107
  as: 'button',
108
108
  type: 'button',
109
+ ariaCurrentValue: 'page',
109
110
  active: undefined,
110
111
  isAction: false,
111
112
  activeClass: '',
@@ -213,6 +214,7 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
213
214
  <slot
214
215
  v-bind="{
215
216
  ...$attrs,
217
+ ...(exact && isExactActive ? { 'aria-current': props.ariaCurrentValue } : {}),
216
218
  as,
217
219
  type,
218
220
  disabled,
@@ -227,6 +229,7 @@ function resolveLinkClass({ route, isActive, isExactActive }: any = {}) {
227
229
  v-else
228
230
  v-bind="{
229
231
  ...$attrs,
232
+ ...(exact && isExactActive ? { 'aria-current': props.ariaCurrentValue } : {}),
230
233
  as,
231
234
  type,
232
235
  disabled,
@@ -9,10 +9,10 @@ export { useConfetti } from '../composables/useConfetti';
9
9
  export { useOverlay } from '../composables/useOverlay';
10
10
  export declare const useColorMode: () => {
11
11
  forced: boolean;
12
- preference?: undefined;
13
- readonly value?: undefined;
12
+ preference?: "dark" | "light" | "system";
13
+ readonly value?: import("@vueuse/core").BasicColorMode;
14
14
  } | {
15
- preference: "light" | "dark" | "system";
15
+ preference: "dark" | "light" | "system";
16
16
  readonly value: import("@vueuse/core").BasicColorMode;
17
17
  forced: boolean;
18
18
  };