@nuxt/ui 2.9.0 → 2.10.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.
Files changed (71) hide show
  1. package/dist/module.d.mts +270 -2
  2. package/dist/module.d.ts +270 -2
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +21 -2
  5. package/dist/runtime/components/data/Table.vue +8 -6
  6. package/dist/runtime/components/data/Table.vue.d.ts +2 -1
  7. package/dist/runtime/components/elements/Accordion.vue +15 -13
  8. package/dist/runtime/components/elements/Accordion.vue.d.ts +5 -2
  9. package/dist/runtime/components/elements/Button.vue.d.ts +2 -2
  10. package/dist/runtime/components/elements/Dropdown.vue +31 -25
  11. package/dist/runtime/components/elements/Dropdown.vue.d.ts +2 -0
  12. package/dist/runtime/components/elements/Meter.vue +166 -0
  13. package/dist/runtime/components/elements/Meter.vue.d.ts +123 -0
  14. package/dist/runtime/components/elements/MeterGroup.d.ts +78 -0
  15. package/dist/runtime/components/elements/MeterGroup.mjs +172 -0
  16. package/dist/runtime/components/elements/Progress.vue +284 -0
  17. package/dist/runtime/components/elements/Progress.vue.d.ts +2 -0
  18. package/dist/runtime/components/forms/Checkbox.vue.d.ts +2 -2
  19. package/dist/runtime/components/forms/Form.vue +32 -7
  20. package/dist/runtime/components/forms/Form.vue.d.ts +2 -1
  21. package/dist/runtime/components/forms/Input.vue +5 -1
  22. package/dist/runtime/components/forms/Input.vue.d.ts +12 -3
  23. package/dist/runtime/components/forms/Radio.vue +10 -9
  24. package/dist/runtime/components/forms/Radio.vue.d.ts +3 -3
  25. package/dist/runtime/components/forms/RadioGroup.vue +136 -0
  26. package/dist/runtime/components/forms/RadioGroup.vue.d.ts +118 -0
  27. package/dist/runtime/components/forms/Range.vue.d.ts +3 -3
  28. package/dist/runtime/components/forms/Select.vue.d.ts +2 -2
  29. package/dist/runtime/components/forms/SelectMenu.vue +62 -57
  30. package/dist/runtime/components/forms/SelectMenu.vue.d.ts +6 -5
  31. package/dist/runtime/components/forms/Textarea.vue +5 -1
  32. package/dist/runtime/components/forms/Textarea.vue.d.ts +11 -2
  33. package/dist/runtime/components/forms/Toggle.vue.d.ts +2 -2
  34. package/dist/runtime/components/layout/Divider.vue +107 -0
  35. package/dist/runtime/components/layout/Divider.vue.d.ts +82 -0
  36. package/dist/runtime/components/navigation/CommandPalette.vue +10 -3
  37. package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +1 -1
  38. package/dist/runtime/components/navigation/Pagination.vue +65 -9
  39. package/dist/runtime/components/navigation/Pagination.vue.d.ts +41 -3
  40. package/dist/runtime/components/navigation/Tabs.vue +1 -1
  41. package/dist/runtime/components/overlays/ContextMenu.vue +7 -2
  42. package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +2 -1
  43. package/dist/runtime/components/overlays/Modal.vue +1 -1
  44. package/dist/runtime/components/overlays/Modal.vue.d.ts +1 -1
  45. package/dist/runtime/components/overlays/Notification.vue +7 -1
  46. package/dist/runtime/components/overlays/Notifications.vue +1 -1
  47. package/dist/runtime/components/overlays/Popover.vue +22 -7
  48. package/dist/runtime/components/overlays/Popover.vue.d.ts +14 -0
  49. package/dist/runtime/components/overlays/Slideover.vue.d.ts +1 -1
  50. package/dist/runtime/components/overlays/Tooltip.vue +16 -10
  51. package/dist/runtime/components/overlays/Tooltip.vue.d.ts +1 -0
  52. package/dist/runtime/composables/useFormGroup.d.ts +3 -3
  53. package/dist/runtime/composables/useFormGroup.mjs +17 -6
  54. package/dist/runtime/composables/usePopper.d.ts +3 -3
  55. package/dist/runtime/composables/usePopper.mjs +7 -1
  56. package/dist/runtime/composables/useUI.d.ts +2 -2
  57. package/dist/runtime/composables/useUI.mjs +2 -2
  58. package/dist/runtime/types/command-palette.d.ts +1 -0
  59. package/dist/runtime/types/form.d.ts +13 -6
  60. package/dist/runtime/types/index.d.ts +2 -0
  61. package/dist/runtime/types/meter.d.ts +5 -0
  62. package/dist/runtime/types/popper.d.ts +1 -0
  63. package/dist/runtime/types/progress.d.ts +4 -0
  64. package/dist/runtime/types/utils.d.ts +1 -1
  65. package/dist/runtime/ui.config.d.ts +263 -0
  66. package/dist/runtime/ui.config.mjs +263 -19
  67. package/dist/types.d.mts +1 -1
  68. package/dist/types.d.ts +1 -1
  69. package/package.json +19 -19
  70. package/dist/runtime/utils/StateEmitter.d.ts +0 -17
  71. package/dist/runtime/utils/StateEmitter.mjs +0 -21
package/dist/module.d.ts CHANGED
@@ -283,6 +283,14 @@ declare const dropdown: {
283
283
  placement: string;
284
284
  strategy: string;
285
285
  };
286
+ arrow: {
287
+ ring: string;
288
+ background: string;
289
+ base: string;
290
+ rounded: string;
291
+ shadow: string;
292
+ placement: string;
293
+ };
286
294
  };
287
295
  declare const accordion: {
288
296
  wrapper: string;
@@ -357,6 +365,167 @@ declare const kbd: {
357
365
  size: string;
358
366
  };
359
367
  };
368
+ declare const progress: {
369
+ wrapper: string;
370
+ indicator: {
371
+ container: {
372
+ base: string;
373
+ width: string;
374
+ transition: string;
375
+ };
376
+ align: string;
377
+ width: string;
378
+ color: string;
379
+ size: {
380
+ '2xs': string;
381
+ xs: string;
382
+ sm: string;
383
+ md: string;
384
+ lg: string;
385
+ xl: string;
386
+ '2xl': string;
387
+ };
388
+ };
389
+ progress: {
390
+ base: string;
391
+ width: string;
392
+ size: {
393
+ '2xs': string;
394
+ xs: string;
395
+ sm: string;
396
+ md: string;
397
+ lg: string;
398
+ xl: string;
399
+ '2xl': string;
400
+ };
401
+ rounded: string;
402
+ track: string;
403
+ bar: string;
404
+ color: string;
405
+ background: string;
406
+ indeterminate: {
407
+ base: string;
408
+ rounded: string;
409
+ };
410
+ };
411
+ steps: {
412
+ base: string;
413
+ color: string;
414
+ size: {
415
+ '2xs': string;
416
+ xs: string;
417
+ sm: string;
418
+ md: string;
419
+ lg: string;
420
+ xl: string;
421
+ '2xl': string;
422
+ };
423
+ };
424
+ step: {
425
+ base: string;
426
+ align: string;
427
+ active: string;
428
+ first: string;
429
+ };
430
+ animation: {
431
+ carousel: string;
432
+ 'carousel-inverse': string;
433
+ swing: string;
434
+ elastic: string;
435
+ };
436
+ default: {
437
+ color: string;
438
+ size: string;
439
+ animation: string;
440
+ };
441
+ };
442
+ declare const meter: {
443
+ wrapper: string;
444
+ indicator: {
445
+ container: string;
446
+ text: string;
447
+ size: {
448
+ '2xs': string;
449
+ xs: string;
450
+ sm: string;
451
+ md: string;
452
+ lg: string;
453
+ xl: string;
454
+ '2xl': string;
455
+ };
456
+ };
457
+ meter: {
458
+ base: string;
459
+ background: string;
460
+ color: string;
461
+ ring: string;
462
+ rounded: string;
463
+ shadow: string;
464
+ size: {
465
+ '2xs': string;
466
+ xs: string;
467
+ sm: string;
468
+ md: string;
469
+ lg: string;
470
+ xl: string;
471
+ '2xl': string;
472
+ };
473
+ appearance: {
474
+ inner: string;
475
+ meter: string;
476
+ bar: string;
477
+ value: string;
478
+ };
479
+ bar: {
480
+ transition: string;
481
+ ring: string;
482
+ rounded: string;
483
+ size: {
484
+ '2xs': string;
485
+ xs: string;
486
+ sm: string;
487
+ md: string;
488
+ lg: string;
489
+ xl: string;
490
+ '2xl': string;
491
+ };
492
+ };
493
+ };
494
+ label: {
495
+ base: string;
496
+ text: string;
497
+ color: string;
498
+ size: {
499
+ '2xs': string;
500
+ xs: string;
501
+ sm: string;
502
+ md: string;
503
+ lg: string;
504
+ xl: string;
505
+ '2xl': string;
506
+ };
507
+ };
508
+ color: {
509
+ white: string;
510
+ black: string;
511
+ gray: string;
512
+ };
513
+ default: {
514
+ size: string;
515
+ color: string;
516
+ };
517
+ };
518
+ declare const meterGroup: {
519
+ wrapper: string;
520
+ base: string;
521
+ background: string;
522
+ transition: string;
523
+ rounded: string;
524
+ shadow: string;
525
+ default: {
526
+ size: string;
527
+ };
528
+ };
360
529
  declare const input: {
361
530
  wrapper: string;
362
531
  base: string;
@@ -745,6 +914,21 @@ declare const selectMenu: {
745
914
  default: {
746
915
  selectedIcon: string;
747
916
  };
917
+ arrow: {
918
+ ring: string;
919
+ background: string;
920
+ base: string;
921
+ rounded: string;
922
+ shadow: string;
923
+ placement: string;
924
+ };
925
+ };
926
+ declare const radioGroup: {
927
+ wrapper: string;
928
+ legend: string;
929
+ default: {
930
+ color: string;
931
+ };
748
932
  };
749
933
  declare const radio: {
750
934
  wrapper: string;
@@ -810,9 +994,13 @@ declare const range: {
810
994
  rounded: string;
811
995
  background: string;
812
996
  size: {
997
+ '2xs': string;
998
+ xs: string;
813
999
  sm: string;
814
1000
  md: string;
815
1001
  lg: string;
1002
+ xl: string;
1003
+ '2xl': string;
816
1004
  };
817
1005
  };
818
1006
  thumb: {
@@ -821,9 +1009,13 @@ declare const range: {
821
1009
  background: string;
822
1010
  ring: string;
823
1011
  size: {
1012
+ '2xs': string;
1013
+ xs: string;
824
1014
  sm: string;
825
1015
  md: string;
826
1016
  lg: string;
1017
+ xl: string;
1018
+ '2xl': string;
827
1019
  };
828
1020
  };
829
1021
  track: {
@@ -831,15 +1023,23 @@ declare const range: {
831
1023
  background: string;
832
1024
  rounded: string;
833
1025
  size: {
1026
+ '2xs': string;
1027
+ xs: string;
834
1028
  sm: string;
835
1029
  md: string;
836
1030
  lg: string;
1031
+ xl: string;
1032
+ '2xl': string;
837
1033
  };
838
1034
  };
839
1035
  size: {
1036
+ '2xs': string;
1037
+ xs: string;
840
1038
  sm: string;
841
1039
  md: string;
842
1040
  lg: string;
1041
+ xl: string;
1042
+ '2xl': string;
843
1043
  };
844
1044
  default: {
845
1045
  size: string;
@@ -879,6 +1079,35 @@ declare const skeleton: {
879
1079
  background: string;
880
1080
  rounded: string;
881
1081
  };
1082
+ declare const divider: {
1083
+ wrapper: {
1084
+ base: string;
1085
+ horizontal: string;
1086
+ vertical: string;
1087
+ };
1088
+ container: {
1089
+ base: string;
1090
+ horizontal: string;
1091
+ vertical: string;
1092
+ };
1093
+ border: {
1094
+ base: string;
1095
+ horizontal: string;
1096
+ vertical: string;
1097
+ size: {
1098
+ horizontal: string;
1099
+ vertical: string;
1100
+ };
1101
+ };
1102
+ icon: {
1103
+ base: string;
1104
+ };
1105
+ avatar: {
1106
+ base: string;
1107
+ size: string;
1108
+ };
1109
+ label: string;
1110
+ };
882
1111
  declare const verticalNavigation: {
883
1112
  wrapper: string;
884
1113
  base: string;
@@ -985,6 +1214,16 @@ declare const pagination: {
985
1214
  inactiveButton: {
986
1215
  color: string;
987
1216
  };
1217
+ firstButton: {
1218
+ color: string;
1219
+ class: string;
1220
+ icon: string;
1221
+ };
1222
+ lastButton: {
1223
+ color: string;
1224
+ class: string;
1225
+ icon: string;
1226
+ };
988
1227
  prevButton: {
989
1228
  color: string;
990
1229
  class: string;
@@ -1112,6 +1351,14 @@ declare const tooltip: {
1112
1351
  popper: {
1113
1352
  strategy: string;
1114
1353
  };
1354
+ arrow: {
1355
+ base: string;
1356
+ ring: string;
1357
+ rounded: string;
1358
+ background: string;
1359
+ shadow: string;
1360
+ placement: string;
1361
+ };
1115
1362
  };
1116
1363
  declare const popover: {
1117
1364
  wrapper: string;
@@ -1133,6 +1380,14 @@ declare const popover: {
1133
1380
  popper: {
1134
1381
  strategy: string;
1135
1382
  };
1383
+ arrow: {
1384
+ base: string;
1385
+ ring: string;
1386
+ rounded: string;
1387
+ background: string;
1388
+ shadow: string;
1389
+ placement: string;
1390
+ };
1136
1391
  };
1137
1392
  declare const contextMenu: {
1138
1393
  wrapper: string;
@@ -1155,6 +1410,14 @@ declare const contextMenu: {
1155
1410
  placement: string;
1156
1411
  scroll: boolean;
1157
1412
  };
1413
+ arrow: {
1414
+ base: string;
1415
+ ring: string;
1416
+ rounded: string;
1417
+ background: string;
1418
+ shadow: string;
1419
+ placement: string;
1420
+ };
1158
1421
  };
1159
1422
  declare const notification: {
1160
1423
  wrapper: string;
@@ -1220,16 +1483,21 @@ declare const config_checkbox: typeof checkbox;
1220
1483
  declare const config_commandPalette: typeof commandPalette;
1221
1484
  declare const config_container: typeof container;
1222
1485
  declare const config_contextMenu: typeof contextMenu;
1486
+ declare const config_divider: typeof divider;
1223
1487
  declare const config_dropdown: typeof dropdown;
1224
1488
  declare const config_formGroup: typeof formGroup;
1225
1489
  declare const config_input: typeof input;
1226
1490
  declare const config_kbd: typeof kbd;
1491
+ declare const config_meter: typeof meter;
1492
+ declare const config_meterGroup: typeof meterGroup;
1227
1493
  declare const config_modal: typeof modal;
1228
1494
  declare const config_notification: typeof notification;
1229
1495
  declare const config_notifications: typeof notifications;
1230
1496
  declare const config_pagination: typeof pagination;
1231
1497
  declare const config_popover: typeof popover;
1498
+ declare const config_progress: typeof progress;
1232
1499
  declare const config_radio: typeof radio;
1500
+ declare const config_radioGroup: typeof radioGroup;
1233
1501
  declare const config_range: typeof range;
1234
1502
  declare const config_select: typeof select;
1235
1503
  declare const config_selectMenu: typeof selectMenu;
@@ -1242,13 +1510,13 @@ declare const config_toggle: typeof toggle;
1242
1510
  declare const config_tooltip: typeof tooltip;
1243
1511
  declare const config_verticalNavigation: typeof verticalNavigation;
1244
1512
  declare namespace config {
1245
- export { config_accordion as accordion, config_alert as alert, config_avatar as avatar, config_avatarGroup as avatarGroup, config_badge as badge, config_button as button, config_buttonGroup as buttonGroup, config_card as card, config_checkbox as checkbox, config_commandPalette as commandPalette, config_container as container, config_contextMenu as contextMenu, config_dropdown as dropdown, config_formGroup as formGroup, config_input as input, config_kbd as kbd, config_modal as modal, config_notification as notification, config_notifications as notifications, config_pagination as pagination, config_popover as popover, config_radio as radio, config_range as range, config_select as select, config_selectMenu as selectMenu, config_skeleton as skeleton, config_slideover as slideover, config_table as table, config_tabs as tabs, config_textarea as textarea, config_toggle as toggle, config_tooltip as tooltip, config_verticalNavigation as verticalNavigation };
1513
+ export { config_accordion as accordion, config_alert as alert, config_avatar as avatar, config_avatarGroup as avatarGroup, config_badge as badge, config_button as button, config_buttonGroup as buttonGroup, config_card as card, config_checkbox as checkbox, config_commandPalette as commandPalette, config_container as container, config_contextMenu as contextMenu, config_divider as divider, config_dropdown as dropdown, config_formGroup as formGroup, config_input as input, config_kbd as kbd, config_meter as meter, config_meterGroup as meterGroup, config_modal as modal, config_notification as notification, config_notifications as notifications, config_pagination as pagination, config_popover as popover, config_progress as progress, config_radio as radio, config_radioGroup as radioGroup, config_range as range, config_select as select, config_selectMenu as selectMenu, config_skeleton as skeleton, config_slideover as slideover, config_table as table, config_tabs as tabs, config_textarea as textarea, config_toggle as toggle, config_tooltip as tooltip, config_verticalNavigation as verticalNavigation };
1246
1514
  }
1247
1515
 
1248
1516
  type Strategy = 'merge' | 'override';
1249
1517
 
1250
1518
  type DeepPartial<T> = Partial<{
1251
- [P in keyof T]: DeepPartial<T[P]> | { [key: string]: string };
1519
+ [P in keyof T]: DeepPartial<T[P]> | { [key: string]: string | object };
1252
1520
  }>;
1253
1521
 
1254
1522
  type UI = {
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/ui",
3
- "version": "2.9.0",
3
+ "version": "2.10.0",
4
4
  "configKey": "ui",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.0.0-rc.8"
package/dist/module.mjs CHANGED
@@ -15,7 +15,7 @@ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
15
15
  const __dirname = __cjs_path__.dirname(__filename);
16
16
  const require = __cjs_mod__.createRequire(import.meta.url);
17
17
  const name = "@nuxt/ui";
18
- const version = "2.9.0";
18
+ const version = "2.10.0";
19
19
 
20
20
  function omit(object, keysToOmit) {
21
21
  const result = { ...object };
@@ -194,6 +194,23 @@ const safelistByComponent = {
194
194
  pattern: new RegExp(`ring-(${colorsAsRegex2})-500`),
195
195
  variants: ["focus-visible"]
196
196
  }],
197
+ progress: (colorsAsRegex2) => [{
198
+ pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
199
+ variants: ["dark"]
200
+ }, {
201
+ pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
202
+ }],
203
+ meter: (colorsAsRegex2) => [{
204
+ pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
205
+ variants: ["dark"]
206
+ }, {
207
+ pattern: new RegExp(`bg-(${colorsAsRegex2})-500`)
208
+ }, {
209
+ pattern: new RegExp(`text-(${colorsAsRegex2})-400`),
210
+ variants: ["dark"]
211
+ }, {
212
+ pattern: new RegExp(`text-(${colorsAsRegex2})-500`)
213
+ }],
197
214
  notification: (colorsAsRegex2) => [{
198
215
  pattern: new RegExp(`bg-(${colorsAsRegex2})-400`),
199
216
  variants: ["dark"]
@@ -209,7 +226,9 @@ const safelistByComponent = {
209
226
  const safelistComponentAliasesMap = {
210
227
  "USelect": "UInput",
211
228
  "USelectMenu": "UInput",
212
- "UTextarea": "UInput"
229
+ "UTextarea": "UInput",
230
+ "URadioGroup": "URadio",
231
+ "UMeterGroup": "UMeter"
213
232
  };
214
233
  const colorsAsRegex = (colors) => colors.join("|");
215
234
  const excludeColors = (colors) => {
@@ -146,19 +146,20 @@ export default defineComponent({
146
146
  default: void 0
147
147
  }
148
148
  },
149
- emits: ["update:modelValue"],
149
+ emits: ["update:modelValue", "update:sort"],
150
150
  setup(props, { emit, attrs: $attrs }) {
151
151
  const { ui, attrs } = useUI("table", toRef(props, "ui"), config, toRef(props, "class"));
152
152
  const columns = computed(() => props.columns ?? Object.keys(omit(props.rows[0] ?? {}, ["click"])).map((key) => ({ key, label: upperFirst(key), sortable: false })));
153
153
  const sort = ref(defu({}, props.sort, { column: null, direction: "asc" }));
154
+ const defaultSort = { column: sort.value.column, direction: null };
154
155
  const rows = computed(() => {
155
156
  if (!sort.value?.column) {
156
157
  return props.rows;
157
158
  }
158
159
  const { column, direction } = sort.value;
159
160
  return props.rows.slice().sort((a, b) => {
160
- const aValue = a[column];
161
- const bValue = b[column];
161
+ const aValue = get(a, column);
162
+ const bValue = get(b, column);
162
163
  if (aValue === bValue) {
163
164
  return 0;
164
165
  }
@@ -205,13 +206,14 @@ export default defineComponent({
205
206
  if (sort.value.column === column.key) {
206
207
  const direction = !column.direction || column.direction === "asc" ? "desc" : "asc";
207
208
  if (sort.value.direction === direction) {
208
- sort.value = defu({}, props.sort, { column: null, direction: "asc" });
209
+ sort.value = defu({}, defaultSort, { column: null, direction: "asc" });
209
210
  } else {
210
211
  sort.value.direction = sort.value.direction === "asc" ? "desc" : "asc";
211
212
  }
212
213
  } else {
213
214
  sort.value = { column: column.key, direction: column.direction || "asc" };
214
215
  }
216
+ emit("update:sort", sort.value);
215
217
  }
216
218
  function onSelect(row) {
217
219
  if (!$attrs.onSelect) {
@@ -221,10 +223,10 @@ export default defineComponent({
221
223
  }
222
224
  function selectAllRows() {
223
225
  props.rows.forEach((row) => {
224
- if (selected.value.some((item) => compare(toRaw(item), toRaw(row)))) {
226
+ if (isSelected(row)) {
225
227
  return;
226
228
  }
227
- $attrs.onSelect ? $attrs.onSelect(row) : selected.value.push(row);
229
+ selected.value.push(row);
228
230
  });
229
231
  }
230
232
  function onChange(event) {
@@ -108,7 +108,7 @@ declare const _default: import("vue").DefineComponent<{
108
108
  onSelect: (row: any) => void;
109
109
  onChange: (event: any) => void;
110
110
  getRowData: (row: Object, rowKey: string | string[], defaultValue?: any) => any;
111
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
111
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "update:sort")[], "update:modelValue" | "update:sort", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
112
112
  modelValue: {
113
113
  type: ArrayConstructor;
114
114
  default: null;
@@ -185,6 +185,7 @@ declare const _default: import("vue").DefineComponent<{
185
185
  };
186
186
  }>> & {
187
187
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
188
+ "onUpdate:sort"?: ((...args: any[]) => any) | undefined;
188
189
  }, {
189
190
  sort: {
190
191
  column: string;
@@ -1,7 +1,14 @@
1
1
  <template>
2
2
  <div :class="ui.wrapper">
3
3
  <HDisclosure v-for="(item, index) in items" v-slot="{ open, close }" :key="index" :default-open="defaultOpen || item.defaultOpen">
4
- <HDisclosureButton :ref="() => buttonRefs[index] = close" as="template" :disabled="item.disabled">
4
+ <HDisclosureButton
5
+ :ref="() => buttonRefs[index] = { open, close }"
6
+ as="template"
7
+ :disabled="item.disabled"
8
+ @click="closeOthers(index, $event)"
9
+ @keydown.enter="closeOthers(index, $event)"
10
+ @keydown.space="closeOthers(index, $event)"
11
+ >
5
12
  <slot :item="item" :index="index" :open="open" :close="close">
6
13
  <UButton v-bind="{ ...omit(ui.default, ['openIcon', 'closeIcon']), ...attrs, ...omit(item, ['slot', 'disabled', 'content', 'defaultOpen']) }">
7
14
  <template #trailing>
@@ -18,8 +25,6 @@
18
25
  </slot>
19
26
  </HDisclosureButton>
20
27
 
21
- <StateEmitter :open="open" @open="closeOthers(index)" />
22
-
23
28
  <Transition
24
29
  v-bind="ui.transition"
25
30
  @enter="onEnter"
@@ -46,7 +51,6 @@ import UIcon from "../elements/Icon.vue";
46
51
  import UButton from "../elements/Button.vue";
47
52
  import { useUI } from "../../composables/useUI";
48
53
  import { mergeConfig, omit } from "../../utils";
49
- import StateEmitter from "../../utils/StateEmitter";
50
54
  import appConfig from "#build/app.config";
51
55
  import { accordion, button } from "#ui/ui.config";
52
56
  const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.accordion, accordion);
@@ -57,8 +61,7 @@ export default defineComponent({
57
61
  HDisclosureButton,
58
62
  HDisclosurePanel,
59
63
  UIcon,
60
- UButton,
61
- StateEmitter
64
+ UButton
62
65
  },
63
66
  inheritAttrs: false,
64
67
  props: {
@@ -95,16 +98,15 @@ export default defineComponent({
95
98
  const { ui, attrs } = useUI("accordion", toRef(props, "ui"), config, toRef(props, "class"));
96
99
  const uiButton = computed(() => configButton);
97
100
  const buttonRefs = ref([]);
98
- function closeOthers(currentIndex) {
101
+ function closeOthers(currentIndex, e) {
99
102
  if (!props.items[currentIndex].closeOthers && props.multiple) {
100
103
  return;
101
104
  }
102
- const totalItems = buttonRefs.value.length;
103
- const order = Array.from({ length: totalItems }, (_, i) => (currentIndex + i) % totalItems).filter((index) => index !== currentIndex).reverse();
104
- for (const index of order) {
105
- const close = buttonRefs.value[index];
106
- close();
107
- }
105
+ buttonRefs.value.forEach((button2) => {
106
+ if (button2.open) {
107
+ button2.close(e.target);
108
+ }
109
+ });
108
110
  }
109
111
  function onEnter(el, done) {
110
112
  el.style.height = "0";
@@ -36,8 +36,11 @@ declare const _default: import("vue").DefineComponent<{
36
36
  attrs: import("vue").ComputedRef<Pick<{
37
37
  [x: string]: unknown;
38
38
  }, string>>;
39
- buttonRefs: import("vue").Ref<Function[]>;
40
- closeOthers: (currentIndex: number) => void;
39
+ buttonRefs: import("vue").Ref<{
40
+ open: boolean;
41
+ close: (e: EventTarget) => {};
42
+ }[]>;
43
+ closeOthers: (currentIndex: number, e: Event) => void;
41
44
  omit: typeof omit;
42
45
  onEnter: (el: HTMLElement, done: any) => void;
43
46
  onBeforeLeave: (el: HTMLElement) => void;
@@ -173,13 +173,14 @@ declare const _default: import("vue").DefineComponent<{
173
173
  default: undefined;
174
174
  };
175
175
  }>>, {
176
+ truncate: boolean;
176
177
  icon: string;
177
178
  color: any;
178
179
  ui: Partial<any>;
179
180
  class: any;
180
181
  label: string;
181
- type: string;
182
182
  loading: boolean;
183
+ type: string;
183
184
  disabled: boolean;
184
185
  variant: ButtonVariant;
185
186
  size: "sm" | "md" | "xs" | "2xs" | "lg" | "xl";
@@ -191,6 +192,5 @@ declare const _default: import("vue").DefineComponent<{
191
192
  trailing: boolean;
192
193
  leading: boolean;
193
194
  square: boolean;
194
- truncate: boolean;
195
195
  }, {}>;
196
196
  export default _default;