@volverjs/ui-vue 0.0.10 → 0.0.12

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 (94) hide show
  1. package/bin/icons.js +1 -93
  2. package/dist/components/VvAccordion/VvAccordion.es.js +1 -366
  3. package/dist/components/VvAccordion/VvAccordion.vue.d.ts +2 -1
  4. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +2 -702
  5. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +3 -2
  6. package/dist/components/VvAction/VvAction.es.js +1 -302
  7. package/dist/components/VvAction/VvAction.vue.d.ts +2 -1
  8. package/dist/components/VvAlert/VvAlert.es.js +1 -527
  9. package/dist/components/VvAlert/VvAlert.umd.js +1 -1
  10. package/dist/components/VvAlert/VvAlert.vue.d.ts +2 -1
  11. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +1 -730
  12. package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
  13. package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +2 -1
  14. package/dist/components/VvAvatar/VvAvatar.es.js +1 -132
  15. package/dist/components/VvAvatar/VvAvatar.vue.d.ts +2 -1
  16. package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +1 -250
  17. package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +2 -1
  18. package/dist/components/VvBadge/VvBadge.es.js +1 -131
  19. package/dist/components/VvBadge/VvBadge.vue.d.ts +2 -1
  20. package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +1 -410
  21. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +2 -1
  22. package/dist/components/VvButton/VvButton.es.js +1 -882
  23. package/dist/components/VvButton/VvButton.umd.js +1 -1
  24. package/dist/components/VvButton/VvButton.vue.d.ts +2 -1
  25. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +1 -214
  26. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -1
  27. package/dist/components/VvCard/VvCard.es.js +1 -152
  28. package/dist/components/VvCard/VvCard.vue.d.ts +2 -1
  29. package/dist/components/VvCheckbox/VvCheckbox.es.js +1 -741
  30. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +3 -2
  31. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +1 -981
  32. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +2 -1
  33. package/dist/components/VvCombobox/VvCombobox.es.js +1 -3463
  34. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  35. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +263 -317
  36. package/dist/components/VvDialog/VvDialog.es.js +1 -317
  37. package/dist/components/VvDialog/VvDialog.vue.d.ts +2 -1
  38. package/dist/components/VvDropdown/VvDropdown.es.js +1 -750
  39. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +2 -1
  40. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +5 -4
  41. package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +2 -1
  42. package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +10 -2
  43. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +2 -1
  44. package/dist/components/VvDropdownAction/VvDropdownAction.es.js +1 -448
  45. package/dist/components/VvDropdownItem/VvDropdownItem.es.js +1 -149
  46. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +1 -104
  47. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
  48. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +1 -281
  49. package/dist/components/VvIcon/VvIcon.es.js +1 -143
  50. package/dist/components/VvIcon/VvIcon.umd.js +1 -1
  51. package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -1
  52. package/dist/components/VvInputFile/VvInputFile.es.js +1 -1704
  53. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
  54. package/dist/components/VvInputFile/VvInputFile.vue.d.ts +2 -1
  55. package/dist/components/VvInputText/VvInputText.es.js +4 -2790
  56. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  57. package/dist/components/VvInputText/VvInputText.vue.d.ts +2 -1
  58. package/dist/components/VvNav/VvNav.es.js +1 -438
  59. package/dist/components/VvNav/VvNav.vue.d.ts +2 -1
  60. package/dist/components/VvNav/VvNavItem.vue.d.ts +2 -1
  61. package/dist/components/VvNav/VvNavSeparator.vue.d.ts +2 -1
  62. package/dist/components/VvNavItem/VvNavItem.es.js +1 -337
  63. package/dist/components/VvNavSeparator/VvNavSeparator.es.js +1 -24
  64. package/dist/components/VvProgress/VvProgress.es.js +1 -163
  65. package/dist/components/VvProgress/VvProgress.vue.d.ts +2 -1
  66. package/dist/components/VvRadio/VvRadio.es.js +1 -661
  67. package/dist/components/VvRadio/VvRadio.vue.d.ts +3 -2
  68. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +1 -901
  69. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +2 -1
  70. package/dist/components/VvSelect/VvSelect.es.js +1 -1103
  71. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  72. package/dist/components/VvSelect/VvSelect.vue.d.ts +130 -71
  73. package/dist/components/VvTab/VvTab.es.js +1 -558
  74. package/dist/components/VvTab/VvTab.vue.d.ts +2 -1
  75. package/dist/components/VvTextarea/VvTextarea.es.js +2 -1989
  76. package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
  77. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +2 -1
  78. package/dist/components/VvTooltip/VvTooltip.es.js +1 -154
  79. package/dist/components/VvTooltip/VvTooltip.vue.d.ts +2 -1
  80. package/dist/components/index.es.js +6 -8558
  81. package/dist/components/index.umd.js +1 -1
  82. package/dist/composables/index.es.js +2 -247
  83. package/dist/composables/index.umd.js +1 -1
  84. package/dist/directives/index.es.js +2 -311
  85. package/dist/directives/index.umd.js +1 -1
  86. package/dist/directives/v-contextmenu.es.js +2 -142
  87. package/dist/directives/v-contextmenu.umd.js +1 -1
  88. package/dist/directives/v-tooltip.es.js +1 -172
  89. package/dist/icons.es.js +1 -39
  90. package/dist/icons.umd.js +1 -1
  91. package/dist/index.es.js +1 -219
  92. package/dist/resolvers/unplugin.es.js +1 -187
  93. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +14 -14
  94. package/package.json +37 -37
@@ -1,702 +1,2 @@
1
- import { inject, computed, toRef, unref, defineComponent, useAttrs, useId, toRefs, ref, watch, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString, onMounted, isRef, provide, watchEffect, reactive, nextTick, Fragment, renderList, createBlock, mergeProps, createSlots, withCtx } from "vue";
2
- import mitt from "mitt";
3
- import { useVModel, useStorage } from "@vueuse/core";
4
- var StorageType = /* @__PURE__ */ ((StorageType2) => {
5
- StorageType2["local"] = "local";
6
- StorageType2["session"] = "session";
7
- return StorageType2;
8
- })(StorageType || {});
9
- var Side = /* @__PURE__ */ ((Side2) => {
10
- Side2["left"] = "left";
11
- Side2["right"] = "right";
12
- Side2["top"] = "top";
13
- Side2["bottom"] = "bottom";
14
- return Side2;
15
- })(Side || {});
16
- var Position = /* @__PURE__ */ ((Position2) => {
17
- Position2["before"] = "before";
18
- Position2["after"] = "after";
19
- return Position2;
20
- })(Position || {});
21
- var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
22
- ButtonType2["button"] = "button";
23
- ButtonType2["submit"] = "submit";
24
- ButtonType2["reset"] = "reset";
25
- return ButtonType2;
26
- })(ButtonType || {});
27
- var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
28
- ActionTag2["nuxtLink"] = "nuxt-link";
29
- ActionTag2["routerLink"] = "router-link";
30
- ActionTag2["a"] = "a";
31
- ActionTag2["button"] = "button";
32
- return ActionTag2;
33
- })(ActionTag || {});
34
- const INJECTION_KEY_ACCORDION_GROUP = Symbol.for(
35
- "accordionGroup"
36
- );
37
- const ModifiersProps = {
38
- /**
39
- * Component BEM modifiers
40
- */
41
- modifiers: {
42
- type: [String, Array],
43
- default: void 0
44
- }
45
- };
46
- ({
47
- /**
48
- * VvIcon position
49
- */
50
- iconPosition: {
51
- default: Position.before
52
- }
53
- });
54
- ({
55
- /**
56
- * Dropdown placement
57
- */
58
- placement: {
59
- default: Side.bottom
60
- }
61
- });
62
- ({
63
- /**
64
- * Button type
65
- */
66
- type: {
67
- default: ButtonType.button
68
- },
69
- /**
70
- * Default tag for the action
71
- */
72
- defaultTag: {
73
- default: ActionTag.button
74
- }
75
- });
76
- const StorageProps = {
77
- storageType: {
78
- type: String,
79
- default: StorageType.local,
80
- validator: (value) => Object.values(StorageType).includes(value)
81
- },
82
- storageKey: String
83
- };
84
- const VvAccordionGroupProps = {
85
- ...ModifiersProps,
86
- ...StorageProps,
87
- /**
88
- * VModel
89
- */
90
- modelValue: {
91
- type: [String, Array],
92
- default: void 0
93
- },
94
- /**
95
- * Accordion items
96
- * @type VvAccordionGroupItem
97
- */
98
- items: {
99
- type: Array,
100
- default: () => []
101
- },
102
- /**
103
- * If true, accordion items stay open when another item is opened
104
- */
105
- collapse: Boolean,
106
- /**
107
- * String or String[] of css classes (modifiers) that will be concatenated to prefix 'vv-accordion--'
108
- */
109
- itemModifiers: {
110
- type: [String, Array],
111
- default: ""
112
- },
113
- /**
114
- * If true, the accordion items will be disabled
115
- */
116
- disabled: Boolean,
117
- /**
118
- * If true, the accordion items will be opened by default
119
- */
120
- not: Boolean
121
- };
122
- const VvAccordionGroupEvents = ["update:modelValue"];
123
- function useGroupStateInject(groupKey) {
124
- const group = inject(groupKey, void 0);
125
- const isInGroup = computed(() => group !== void 0);
126
- function getGroupOrLocalRef(propName, props, emit) {
127
- const groupPropValue = group?.[propName];
128
- if (groupPropValue) {
129
- return computed({
130
- get() {
131
- return groupPropValue.value;
132
- },
133
- set(value) {
134
- groupPropValue.value = value;
135
- }
136
- });
137
- }
138
- const propRef = toRef(props, propName);
139
- return computed({
140
- get() {
141
- return propRef.value;
142
- },
143
- set(value) {
144
- if (emit) {
145
- emit(`update:${propName}`, value);
146
- }
147
- }
148
- });
149
- }
150
- return {
151
- group,
152
- isInGroup,
153
- getGroupOrLocalRef
154
- };
155
- }
156
- const VvAccordionProps = {
157
- ...ModifiersProps,
158
- /**
159
- * Accordion name
160
- */
161
- name: String,
162
- /**
163
- * Header title
164
- */
165
- title: String,
166
- /**
167
- * Content text
168
- */
169
- content: String,
170
- /**
171
- * (Optional) Defines if item is open. Event "update:modelValue" is emitted on accordion header click
172
- */
173
- modelValue: {
174
- type: Boolean,
175
- default: void 0
176
- },
177
- /**
178
- * If true, the accordion will be disabled
179
- */
180
- disabled: Boolean,
181
- /**
182
- * If true, the accordion will be opened by default
183
- */
184
- not: Boolean
185
- };
186
- const VvAccordionEvents = ["update:modelValue"];
187
- function useGroupProps(props) {
188
- const { group, isInGroup } = useGroupStateInject(
189
- INJECTION_KEY_ACCORDION_GROUP
190
- );
191
- const disabled = computed(
192
- () => Boolean(props.disabled || group?.disabled.value)
193
- );
194
- const modifiers = computed(() => {
195
- let localModifiers = props.modifiers;
196
- let groupModifiers = group?.modifiers.value;
197
- const toReturn = /* @__PURE__ */ new Set();
198
- if (localModifiers) {
199
- if (!Array.isArray(localModifiers)) {
200
- localModifiers = localModifiers.split(" ");
201
- }
202
- localModifiers.forEach((modifier) => toReturn.add(modifier));
203
- }
204
- if (groupModifiers) {
205
- if (!Array.isArray(groupModifiers)) {
206
- groupModifiers = groupModifiers.split(" ");
207
- }
208
- groupModifiers.forEach((modifier) => toReturn.add(modifier));
209
- }
210
- return Array.from(toReturn);
211
- });
212
- return {
213
- // group props
214
- isInGroup,
215
- group,
216
- modifiers,
217
- disabled,
218
- bus: group?.bus
219
- };
220
- }
221
- function useModifiers(prefix, modifiers, others) {
222
- return computed(() => {
223
- const toReturn = {
224
- [prefix]: true
225
- };
226
- const modifiersArray = typeof modifiers?.value === "string" ? modifiers.value.split(" ") : modifiers?.value;
227
- if (modifiersArray) {
228
- if (Array.isArray(modifiersArray)) {
229
- modifiersArray.forEach((modifier) => {
230
- if (modifier) {
231
- toReturn[`${prefix}--${modifier}`] = true;
232
- }
233
- });
234
- }
235
- }
236
- if (others) {
237
- Object.keys(others.value).forEach((key) => {
238
- toReturn[`${prefix}--${key}`] = unref(others.value[key]);
239
- });
240
- }
241
- return toReturn;
242
- });
243
- }
244
- const _hoisted_1 = ["id", "open"];
245
- const _hoisted_2 = ["aria-controls", "aria-expanded"];
246
- const _hoisted_3 = ["aria-hidden"];
247
- const __default__$1 = {
248
- name: "VvAccordion"
249
- };
250
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
251
- ...__default__$1,
252
- props: VvAccordionProps,
253
- emits: VvAccordionEvents,
254
- setup(__props, { expose: __expose, emit: __emit }) {
255
- const props = __props;
256
- const emit = __emit;
257
- const attrs = useAttrs();
258
- const modelValue = useVModel(props, "modelValue", emit);
259
- const accordionName = computed(
260
- () => props.name || attrs?.id || useId()
261
- );
262
- const { title, content, not } = toRefs(props);
263
- const { isInGroup, modifiers, disabled, bus } = useGroupProps(props);
264
- const isExpanded = ref(false);
265
- watch(
266
- modelValue,
267
- (newValue) => {
268
- if (typeof newValue === "boolean") {
269
- isExpanded.value = not.value ? !newValue : newValue;
270
- }
271
- },
272
- { immediate: true }
273
- );
274
- watch(isExpanded, (newValue) => {
275
- modelValue.value = not.value ? !newValue : newValue;
276
- });
277
- bus?.on("toggle", ({ name, value }) => {
278
- if (name !== accordionName.value) {
279
- return;
280
- }
281
- isExpanded.value = value;
282
- });
283
- function onClick() {
284
- if (disabled.value) {
285
- return;
286
- }
287
- if (isInGroup.value) {
288
- bus?.emit("toggle", {
289
- name: accordionName.value,
290
- value: !isExpanded.value
291
- });
292
- return;
293
- }
294
- isExpanded.value = !isExpanded.value;
295
- }
296
- watch(
297
- accordionName,
298
- (newValue, oldValue) => {
299
- if (bus) {
300
- if (oldValue && oldValue !== newValue) {
301
- bus.emit("unregister", { name: oldValue });
302
- }
303
- bus.emit("register", { name: newValue });
304
- }
305
- },
306
- {
307
- immediate: true
308
- }
309
- );
310
- onBeforeUnmount(() => {
311
- if (bus) {
312
- bus.emit("unregister", { name: accordionName.value });
313
- }
314
- });
315
- function expand() {
316
- if (isExpanded.value) {
317
- return;
318
- }
319
- onClick();
320
- }
321
- function collapse() {
322
- if (!isExpanded.value) {
323
- return;
324
- }
325
- onClick();
326
- }
327
- function groupExpand(name) {
328
- if (!bus) {
329
- console.warn(
330
- `[VvAccordion]: You are trying to expand accordion group of "${accordionName.value}" but it is not in a group`
331
- );
332
- return;
333
- }
334
- bus.emit("expand", { name });
335
- }
336
- function groupCollapse(name) {
337
- if (!bus) {
338
- console.warn(
339
- `[VvAccordion]: You are trying to collapse accordion group of "${accordionName.value}" but it is not in a group`
340
- );
341
- return;
342
- }
343
- bus?.emit("collapse", { name });
344
- }
345
- __expose({
346
- isExpanded,
347
- expand,
348
- collapse,
349
- groupExpand,
350
- groupCollapse
351
- });
352
- const bemCssClasses = useModifiers(
353
- "vv-accordion",
354
- modifiers,
355
- computed(() => ({
356
- disabled: disabled.value
357
- }))
358
- );
359
- return (_ctx, _cache) => {
360
- return openBlock(), createElementBlock("details", {
361
- id: unref(accordionName),
362
- class: normalizeClass(unref(bemCssClasses)),
363
- open: unref(isExpanded)
364
- }, [
365
- createElementVNode("summary", {
366
- "aria-controls": unref(accordionName),
367
- "aria-expanded": unref(isExpanded),
368
- class: "vv-accordion__summary",
369
- onClick: _cache[0] || (_cache[0] = withModifiers(($event) => onClick(), ["prevent"]))
370
- }, [
371
- renderSlot(_ctx.$slots, "summary", normalizeProps(guardReactiveProps({
372
- isExpanded: unref(isExpanded),
373
- expand,
374
- collapse,
375
- groupExpand,
376
- groupCollapse
377
- })), () => [
378
- createTextVNode(
379
- toDisplayString(unref(title)),
380
- 1
381
- /* TEXT */
382
- )
383
- ])
384
- ], 8, _hoisted_2),
385
- createElementVNode("div", {
386
- "aria-hidden": !unref(isExpanded),
387
- class: "vv-accordion__content"
388
- }, [
389
- renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
390
- isExpanded: unref(isExpanded),
391
- expand,
392
- collapse,
393
- groupExpand,
394
- groupCollapse
395
- })), () => [
396
- createTextVNode(
397
- toDisplayString(unref(content)),
398
- 1
399
- /* TEXT */
400
- )
401
- ])
402
- ], 8, _hoisted_3)
403
- ], 10, _hoisted_1);
404
- };
405
- }
406
- });
407
- function usePersistence(storageKey, storageType = StorageType.local, defaultValue) {
408
- const localValue = ref();
409
- if (defaultValue) {
410
- localValue.value = defaultValue;
411
- }
412
- let storageValue;
413
- onMounted(() => {
414
- if (storageKey) {
415
- watch(
416
- storageKey,
417
- (newKey, oldKey) => {
418
- const storage = unref(storageType) === StorageType.session ? sessionStorage : localStorage;
419
- if (oldKey && oldKey !== newKey) {
420
- storage.removeItem(oldKey);
421
- }
422
- if (newKey) {
423
- storageValue = useStorage(
424
- newKey,
425
- storageValue?.value ?? localValue.value,
426
- storage
427
- );
428
- if (storageValue.value) {
429
- localValue.value = storageValue.value;
430
- }
431
- return;
432
- }
433
- storageValue = void 0;
434
- },
435
- {
436
- immediate: true
437
- }
438
- );
439
- }
440
- if (isRef(storageType)) {
441
- watch(storageType, (newType, oldType) => {
442
- if (storageKey?.value) {
443
- if (newType) {
444
- const storage = newType === StorageType.session ? sessionStorage : localStorage;
445
- storageValue = useStorage(
446
- storageKey.value,
447
- storageValue?.value ?? localValue.value,
448
- storage
449
- );
450
- }
451
- if (oldType && oldType !== newType) {
452
- const oldStorage = oldType === StorageType.session ? sessionStorage : localStorage;
453
- oldStorage.removeItem(storageKey.value);
454
- }
455
- }
456
- });
457
- }
458
- });
459
- watch(localValue, (newValue) => {
460
- if (storageValue) {
461
- storageValue.value = newValue;
462
- }
463
- }, {
464
- deep: true,
465
- immediate: true
466
- });
467
- return localValue;
468
- }
469
- function useGroupStateProvide(key, groupState) {
470
- provide(key, groupState);
471
- }
472
- const __default__ = {
473
- name: "VvAccordionGroup"
474
- };
475
- const _sfc_main = /* @__PURE__ */ defineComponent({
476
- ...__default__,
477
- props: VvAccordionGroupProps,
478
- emits: VvAccordionGroupEvents,
479
- setup(__props, { expose: __expose, emit: __emit }) {
480
- const props = __props;
481
- const emit = __emit;
482
- const {
483
- disabled,
484
- modifiers,
485
- itemModifiers,
486
- items,
487
- storageKey,
488
- storageType
489
- } = toRefs(props);
490
- watchEffect(() => {
491
- if (typeof props.modelValue === "string" && props.collapse) {
492
- console.warn(
493
- `[VvAccordionGroup]: modelValue is a string but collapse is true.`
494
- );
495
- }
496
- });
497
- const accordionNames = reactive(/* @__PURE__ */ new Set());
498
- const storageModelValue = usePersistence(
499
- storageKey,
500
- storageType,
501
- []
502
- );
503
- const localModelValue = computed({
504
- get: () => {
505
- if (props.modelValue !== null && props.modelValue !== void 0) {
506
- return props.modelValue;
507
- }
508
- return storageModelValue.value;
509
- },
510
- set: (newValue) => {
511
- emit("update:modelValue", newValue);
512
- storageModelValue.value = newValue;
513
- }
514
- });
515
- const expandedAccordions = computed({
516
- get: () => {
517
- if (localModelValue.value === void 0) {
518
- return /* @__PURE__ */ new Set();
519
- }
520
- let toReturn = /* @__PURE__ */ new Set();
521
- if (props.not) {
522
- if (typeof localModelValue.value === "string") {
523
- toReturn = new Set(
524
- [...accordionNames].filter(
525
- (name) => name !== localModelValue.value
526
- )
527
- );
528
- } else if (Array.isArray(localModelValue.value)) {
529
- toReturn = new Set(
530
- [...accordionNames].filter(
531
- (name) => !localModelValue.value.includes(
532
- name
533
- )
534
- )
535
- );
536
- }
537
- } else if (typeof localModelValue.value === "string") {
538
- toReturn = /* @__PURE__ */ new Set([localModelValue.value]);
539
- } else if (Array.isArray(localModelValue.value)) {
540
- toReturn = new Set(localModelValue.value);
541
- }
542
- return toReturn;
543
- },
544
- set: (newValue) => {
545
- if (props.not) {
546
- localModelValue.value = [...accordionNames].filter(
547
- (name) => !newValue.has(name)
548
- );
549
- return;
550
- }
551
- if (props.collapse) {
552
- localModelValue.value = [...newValue];
553
- return;
554
- }
555
- localModelValue.value = newValue.values().next().value;
556
- }
557
- });
558
- onMounted(() => {
559
- if (props.not && localModelValue.value === void 0) {
560
- localModelValue.value = props.collapse ? [] : [...accordionNames.values()].splice(1, accordionNames.size);
561
- }
562
- nextTick(() => {
563
- for (const name of accordionNames) {
564
- bus.emit("toggle", {
565
- name,
566
- value: expandedAccordions.value.has(name)
567
- });
568
- }
569
- });
570
- });
571
- const bus = mitt();
572
- useGroupStateProvide(INJECTION_KEY_ACCORDION_GROUP, {
573
- disabled,
574
- modifiers: itemModifiers,
575
- bus
576
- });
577
- bus.on("register", ({ name }) => {
578
- accordionNames.add(name);
579
- });
580
- bus.on("unregister", ({ name }) => {
581
- accordionNames.delete(name);
582
- });
583
- bus.on("toggle", ({ name, value }) => {
584
- const newValue = new Set(expandedAccordions.value);
585
- if (value) {
586
- if (!props.collapse) {
587
- for (const item of newValue) {
588
- if (item !== name) {
589
- bus.emit("toggle", { name: item, value: false });
590
- }
591
- }
592
- newValue.clear();
593
- }
594
- newValue.add(name);
595
- expandedAccordions.value = newValue;
596
- return;
597
- }
598
- newValue.delete(name);
599
- expandedAccordions.value = newValue;
600
- });
601
- function expand(name) {
602
- if (typeof name === "string") {
603
- bus.emit("toggle", { name, value: true });
604
- return;
605
- }
606
- if (Array.isArray(name)) {
607
- for (const item of name) {
608
- bus.emit("toggle", { name: item, value: true });
609
- }
610
- return;
611
- }
612
- for (const item of accordionNames) {
613
- bus.emit("toggle", { name: item, value: true });
614
- }
615
- }
616
- bus.on("expand", ({ name }) => expand(name));
617
- function collapse(name) {
618
- if (typeof name === "string") {
619
- bus.emit("toggle", { name, value: false });
620
- return;
621
- }
622
- if (Array.isArray(name)) {
623
- for (const item of name) {
624
- bus.emit("toggle", { name: item, value: false });
625
- }
626
- return;
627
- }
628
- for (const item of accordionNames) {
629
- bus.emit("toggle", { name: item, value: false });
630
- }
631
- }
632
- bus.on("collapse", ({ name }) => collapse(name));
633
- __expose({ expandedAccordions, expand, collapse });
634
- const bemCssClasses = useModifiers(
635
- "vv-accordion-group",
636
- modifiers,
637
- computed(() => ({
638
- disabled: disabled.value
639
- }))
640
- );
641
- return (_ctx, _cache) => {
642
- return openBlock(), createElementBlock(
643
- "div",
644
- {
645
- class: normalizeClass(unref(bemCssClasses))
646
- },
647
- [
648
- renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
649
- expandedAccordions: unref(expandedAccordions),
650
- expand,
651
- collapse
652
- })), () => [
653
- (openBlock(true), createElementBlock(
654
- Fragment,
655
- null,
656
- renderList(unref(items), (item) => {
657
- return openBlock(), createBlock(
658
- _sfc_main$1,
659
- mergeProps({
660
- key: item.title
661
- }, { ref_for: true }, {
662
- name: item.name,
663
- title: item.title,
664
- content: item.content
665
- }),
666
- createSlots({
667
- _: 2
668
- /* DYNAMIC */
669
- }, [
670
- _ctx.$slots[`summary::${item.name}`] ? {
671
- name: "summary",
672
- fn: withCtx((data) => [
673
- renderSlot(_ctx.$slots, `summary::${item.name}`, mergeProps({ ref_for: true }, data))
674
- ]),
675
- key: "0"
676
- } : void 0,
677
- _ctx.$slots[`content::${item.name}`] ? {
678
- name: "default",
679
- fn: withCtx((data) => [
680
- renderSlot(_ctx.$slots, `content::${item.name}`, mergeProps({ ref_for: true }, data))
681
- ]),
682
- key: "1"
683
- } : void 0
684
- ]),
685
- 1040
686
- /* FULL_PROPS, DYNAMIC_SLOTS */
687
- );
688
- }),
689
- 128
690
- /* KEYED_FRAGMENT */
691
- ))
692
- ])
693
- ],
694
- 2
695
- /* CLASS */
696
- );
697
- };
698
- }
699
- });
700
- export {
701
- _sfc_main as default
702
- };
1
+ import{inject as e,computed as o,toRef as a,unref as t,defineComponent as n,useAttrs as l,useId as r,toRefs as i,ref as s,watch as u,onBeforeUnmount as d,createElementBlock as c,openBlock as v,normalizeClass as m,createElementVNode as p,withModifiers as f,renderSlot as g,normalizeProps as y,guardReactiveProps as b,createTextVNode as A,toDisplayString as x,onMounted as S,isRef as $,provide as V,watchEffect as w,reactive as h,nextTick as E,Fragment as k,renderList as G,createBlock as _,mergeProps as B,createSlots as I,withCtx as C}from"vue";import L from"mitt";import{useVModel as O,useStorage as j}from"@vueuse/core";var K=/* @__PURE__ */(e=>(e.local="local",e.session="session",e))(K||{}),M=/* @__PURE__ */(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(M||{}),T=/* @__PURE__ */(e=>(e.before="before",e.after="after",e))(T||{}),Y=/* @__PURE__ */(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(Y||{}),z=/* @__PURE__ */(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(z||{});const R=Symbol.for("accordionGroup"),q={modifiers:{type:[String,Array],default:void 0}};T.before,M.bottom,Y.button,z.button;const D={storageType:{type:String,default:K.local,validator:e=>Object.values(K).includes(e)},storageKey:String},F={...q,...D,modelValue:{type:[String,Array],default:void 0},items:{type:Array,default:()=>[]},collapse:Boolean,itemModifiers:{type:[String,Array],default:""},disabled:Boolean,not:Boolean};const H={...q,name:String,title:String,content:String,modelValue:{type:Boolean,default:void 0},disabled:Boolean,not:Boolean};function J(t){const{group:n,isInGroup:l}=function(t){const n=e(t,void 0),l=o(()=>void 0!==n);return{group:n,isInGroup:l,getGroupOrLocalRef:function(e,t,l){const r=n?.[e];if(r)return o({get:()=>r.value,set(e){r.value=e}});const i=a(t,e);return o({get:()=>i.value,set(o){l&&l(`update:${e}`,o)}})}}}(R),r=o(()=>Boolean(t.disabled||n?.disabled.value)),i=o(()=>{let e=t.modifiers,o=n?.modifiers.value;const a=/* @__PURE__ */new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach(e=>a.add(e))),o&&(Array.isArray(o)||(o=o.split(" ")),o.forEach(e=>a.add(e))),Array.from(a)});return{isInGroup:l,group:n,modifiers:i,disabled:r,bus:n?.bus}}function N(e,a,n){return o(()=>{const o={[e]:!0},l="string"==typeof a?.value?a.value.split(" "):a?.value;return l&&Array.isArray(l)&&l.forEach(a=>{a&&(o[`${e}--${a}`]=!0)}),n&&Object.keys(n.value).forEach(a=>{o[`${e}--${a}`]=t(n.value[a])}),o})}const P=["id","open"],Q=["aria-controls","aria-expanded"],U=["aria-hidden"],W=/* @__PURE__ */n({name:"VvAccordion",props:H,emits:["update:modelValue"],setup(e,{expose:a,emit:n}){const S=e,$=n,V=l(),w=O(S,"modelValue",$),h=o(()=>S.name||V?.id||r()),{title:E,content:k,not:G}=i(S),{isInGroup:_,modifiers:B,disabled:I,bus:C}=J(S),L=s(!1);function j(){I.value||(_.value?C?.emit("toggle",{name:h.value,value:!L.value}):L.value=!L.value)}function K(){L.value||j()}function M(){L.value&&j()}function T(e){C?C.emit("expand",{name:e}):console.warn(`[VvAccordion]: You are trying to expand accordion group of "${h.value}" but it is not in a group`)}function Y(e){C?C?.emit("collapse",{name:e}):console.warn(`[VvAccordion]: You are trying to collapse accordion group of "${h.value}" but it is not in a group`)}u(w,e=>{"boolean"==typeof e&&(L.value=G.value?!e:e)},{immediate:!0}),u(L,e=>{w.value=G.value?!e:e}),C?.on("toggle",({name:e,value:o})=>{e===h.value&&(L.value=o)}),u(h,(e,o)=>{C&&(o&&o!==e&&C.emit("unregister",{name:o}),C.emit("register",{name:e}))},{immediate:!0}),d(()=>{C&&C.emit("unregister",{name:h.value})}),a({isExpanded:L,expand:K,collapse:M,groupExpand:T,groupCollapse:Y});const z=N("vv-accordion",B,o(()=>({disabled:I.value})));return(e,o)=>(v(),c("details",{id:t(h),class:m(t(z)),open:t(L)},[p("summary",{"aria-controls":t(h),"aria-expanded":t(L),class:"vv-accordion__summary",onClick:o[0]||(o[0]=f(e=>j(),["prevent"]))},[g(e.$slots,"summary",y(b({isExpanded:t(L),expand:K,collapse:M,groupExpand:T,groupCollapse:Y})),()=>[A(x(t(E)),1)])],8,Q),p("div",{"aria-hidden":!t(L),class:"vv-accordion__content"},[g(e.$slots,"default",y(b({isExpanded:t(L),expand:K,collapse:M,groupExpand:T,groupCollapse:Y})),()=>[A(x(t(k)),1)])],8,U)],10,P))}});const X=/* @__PURE__ */n({name:"VvAccordionGroup",props:F,emits:["update:modelValue"],setup(e,{expose:a,emit:n}){const l=e,r=n,{disabled:d,modifiers:p,itemModifiers:f,items:A,storageKey:x,storageType:O}=i(l);w(()=>{"string"==typeof l.modelValue&&l.collapse&&console.warn("[VvAccordionGroup]: modelValue is a string but collapse is true.")});const M=h(/* @__PURE__ */new Set),T=function(e,o=K.local,a){const n=s();let l;return a&&(n.value=a),S(()=>{e&&u(e,(e,a)=>{const r=t(o)===K.session?sessionStorage:localStorage;if(a&&a!==e&&r.removeItem(a),e)return l=j(e,l?.value??n.value,r),void(l.value&&(n.value=l.value));l=void 0},{immediate:!0}),$(o)&&u(o,(o,a)=>{if(e?.value){if(o){const a=o===K.session?sessionStorage:localStorage;l=j(e.value,l?.value??n.value,a)}a&&a!==o&&(a===K.session?sessionStorage:localStorage).removeItem(e.value)}})}),u(n,e=>{l&&(l.value=e)},{deep:!0,immediate:!0}),n}(x,O,[]),Y=o({get:()=>null!==l.modelValue&&void 0!==l.modelValue?l.modelValue:T.value,set:e=>{r("update:modelValue",e),T.value=e}}),z=o({get:()=>{if(void 0===Y.value)/* @__PURE__ */
2
+ return new Set;let e=/* @__PURE__ */new Set;return l.not?"string"==typeof Y.value?e=new Set([...M].filter(e=>e!==Y.value)):Array.isArray(Y.value)&&(e=new Set([...M].filter(e=>!Y.value.includes(e)))):"string"==typeof Y.value?e=/* @__PURE__ */new Set([Y.value]):Array.isArray(Y.value)&&(e=new Set(Y.value)),e},set:e=>{l.not?Y.value=[...M].filter(o=>!e.has(o)):l.collapse?Y.value=[...e]:Y.value=e.values().next().value}});S(()=>{l.not&&void 0===Y.value&&(Y.value=l.collapse?[]:[...M.values()].splice(1,M.size)),E(()=>{for(const e of M)q.emit("toggle",{name:e,value:z.value.has(e)})})});const q=L();function D(e){if("string"!=typeof e)if(Array.isArray(e))for(const o of e)q.emit("toggle",{name:o,value:!0});else for(const o of M)q.emit("toggle",{name:o,value:!0});else q.emit("toggle",{name:e,value:!0})}function F(e){if("string"!=typeof e)if(Array.isArray(e))for(const o of e)q.emit("toggle",{name:o,value:!1});else for(const o of M)q.emit("toggle",{name:o,value:!1});else q.emit("toggle",{name:e,value:!1})}V(R,{disabled:d,modifiers:f,bus:q}),q.on("register",({name:e})=>{M.add(e)}),q.on("unregister",({name:e})=>{M.delete(e)}),q.on("toggle",({name:e,value:o})=>{const a=new Set(z.value);if(o){if(!l.collapse){for(const o of a)o!==e&&q.emit("toggle",{name:o,value:!1});a.clear()}return a.add(e),void(z.value=a)}a.delete(e),z.value=a}),q.on("expand",({name:e})=>D(e)),q.on("collapse",({name:e})=>F(e)),a({expandedAccordions:z,expand:D,collapse:F});const H=N("vv-accordion-group",p,o(()=>({disabled:d.value})));return(e,o)=>(v(),c("div",{class:m(t(H))},[g(e.$slots,"default",y(b({expandedAccordions:t(z),expand:D,collapse:F})),()=>[(v(!0),c(k,null,G(t(A),o=>(v(),_(W,B({key:o.title},{ref_for:!0},{name:o.name,title:o.title,content:o.content}),I({_:2},[e.$slots[`summary::${o.name}`]?{name:"summary",fn:C(a=>[g(e.$slots,`summary::${o.name}`,B({ref_for:!0},a))]),key:"0"}:void 0,e.$slots[`content::${o.name}`]?{name:"default",fn:C(a=>[g(e.$slots,`content::${o.name}`,B({ref_for:!0},a))]),key:"1"}:void 0]),1040))),128))])],2))}});export{X as default};