@volverjs/ui-vue 0.0.10-beta.24 → 0.0.10-beta.26

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 (121) hide show
  1. package/auto-imports.d.ts +1 -0
  2. package/dist/components/VvAccordion/VvAccordion.es.js +14 -12
  3. package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
  4. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +169 -89
  5. package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
  6. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +31 -5
  7. package/dist/components/VvAccordionGroup/index.d.ts +7 -4
  8. package/dist/components/VvAction/VvAction.es.js +14 -12
  9. package/dist/components/VvAction/VvAction.umd.js +1 -1
  10. package/dist/components/VvAction/VvAction.vue.d.ts +2 -11
  11. package/dist/components/VvAction/index.d.ts +1 -5
  12. package/dist/components/VvAlert/VvAlert.es.js +14 -12
  13. package/dist/components/VvAlert/VvAlert.umd.js +1 -1
  14. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +14 -12
  15. package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
  16. package/dist/components/VvAvatar/VvAvatar.es.js +14 -12
  17. package/dist/components/VvAvatar/VvAvatar.umd.js +1 -1
  18. package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +14 -12
  19. package/dist/components/VvAvatarGroup/VvAvatarGroup.umd.js +1 -1
  20. package/dist/components/VvBadge/VvBadge.es.js +14 -12
  21. package/dist/components/VvBadge/VvBadge.umd.js +1 -1
  22. package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +14 -12
  23. package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
  24. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +1 -1
  25. package/dist/components/VvButton/VvButton.es.js +14 -12
  26. package/dist/components/VvButton/VvButton.umd.js +1 -1
  27. package/dist/components/VvButton/VvButton.vue.d.ts +2 -19
  28. package/dist/components/VvButton/index.d.ts +1 -5
  29. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +14 -12
  30. package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
  31. package/dist/components/VvCard/VvCard.es.js +14 -12
  32. package/dist/components/VvCard/VvCard.umd.js +1 -1
  33. package/dist/components/VvCheckbox/VvCheckbox.es.js +14 -12
  34. package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
  35. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +14 -12
  36. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
  37. package/dist/components/VvCombobox/VvCombobox.es.js +58 -34
  38. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  39. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +2 -8
  40. package/dist/components/VvCombobox/index.d.ts +9 -2
  41. package/dist/components/VvDialog/VvDialog.es.js +14 -12
  42. package/dist/components/VvDialog/VvDialog.umd.js +1 -1
  43. package/dist/components/VvDropdown/VvDropdown.es.js +24 -16
  44. package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
  45. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +2 -19
  46. package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +13 -1
  47. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +9 -0
  48. package/dist/components/VvDropdown/index.d.ts +37 -0
  49. package/dist/components/VvDropdownAction/VvDropdownAction.es.js +64 -15
  50. package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
  51. package/dist/components/VvDropdownItem/VvDropdownItem.es.js +322 -1
  52. package/dist/components/VvDropdownItem/VvDropdownItem.umd.js +1 -1
  53. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +14 -12
  54. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
  55. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +131 -76
  56. package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -1
  57. package/dist/components/VvInputFile/VvInputFile.es.js +14 -12
  58. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
  59. package/dist/components/VvInputFile/index.d.ts +5 -5
  60. package/dist/components/VvInputText/VvInputText.es.js +979 -107
  61. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  62. package/dist/components/VvInputText/VvInputText.vue.d.ts +44 -1
  63. package/dist/components/VvInputText/index.d.ts +28 -0
  64. package/dist/components/VvNav/VvNav.es.js +14 -12
  65. package/dist/components/VvNav/VvNav.umd.js +1 -1
  66. package/dist/components/VvNav/VvNav.vue.d.ts +1 -1
  67. package/dist/components/VvNavItem/VvNavItem.es.js +14 -12
  68. package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
  69. package/dist/components/VvProgress/VvProgress.es.js +14 -12
  70. package/dist/components/VvProgress/VvProgress.umd.js +1 -1
  71. package/dist/components/VvRadio/VvRadio.es.js +14 -12
  72. package/dist/components/VvRadio/VvRadio.umd.js +1 -1
  73. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +14 -12
  74. package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
  75. package/dist/components/VvSelect/VvSelect.es.js +14 -12
  76. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  77. package/dist/components/VvTab/VvTab.es.js +14 -12
  78. package/dist/components/VvTab/VvTab.umd.js +1 -1
  79. package/dist/components/VvTab/VvTab.vue.d.ts +1 -1
  80. package/dist/components/VvTextarea/VvTextarea.es.js +14 -12
  81. package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
  82. package/dist/components/VvTooltip/VvTooltip.es.js +14 -12
  83. package/dist/components/VvTooltip/VvTooltip.umd.js +1 -1
  84. package/dist/components/index.es.js +435 -195
  85. package/dist/components/index.umd.js +1 -1
  86. package/dist/composables/dropdown/useInjectDropdown.d.ts +3 -23
  87. package/dist/composables/dropdown/useProvideDropdown.d.ts +2 -3
  88. package/dist/composables/usePersistence.d.ts +3 -0
  89. package/dist/constants.d.ts +24 -21
  90. package/dist/directives/index.es.js +14 -12
  91. package/dist/directives/index.umd.js +1 -1
  92. package/dist/directives/v-tooltip.es.js +14 -12
  93. package/dist/directives/v-tooltip.umd.js +1 -1
  94. package/dist/icons.es.js +3 -3
  95. package/dist/icons.umd.js +1 -1
  96. package/dist/props/index.d.ts +11 -11
  97. package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +51 -9
  98. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +327 -64
  99. package/dist/stories/Button/Button.settings.d.ts +0 -1
  100. package/dist/types/nav.d.ts +1 -2
  101. package/package.json +1 -1
  102. package/src/assets/icons/detailed.json +1 -1
  103. package/src/assets/icons/normal.json +1 -1
  104. package/src/assets/icons/simple.json +1 -1
  105. package/src/components/VvAccordionGroup/VvAccordionGroup.vue +86 -69
  106. package/src/components/VvAccordionGroup/index.ts +3 -5
  107. package/src/components/VvCombobox/VvCombobox.vue +2 -0
  108. package/src/components/VvDropdown/VvDropdown.vue +11 -2
  109. package/src/components/VvDropdown/VvDropdownItem.vue +4 -1
  110. package/src/components/VvDropdown/VvDropdownOption.vue +3 -21
  111. package/src/components/VvDropdown/index.ts +35 -1
  112. package/src/components/VvInputText/VvInputText.vue +98 -3
  113. package/src/components/VvInputText/index.ts +24 -1
  114. package/src/composables/dropdown/useProvideDropdown.ts +4 -4
  115. package/src/composables/usePersistence.ts +76 -0
  116. package/src/constants.ts +23 -18
  117. package/src/props/index.ts +12 -7
  118. package/src/stories/AccordionGroup/AccordionGroup.settings.ts +2 -2
  119. package/src/stories/AccordionGroup/AccordionGroup.test.ts +5 -5
  120. package/src/stories/Button/Button.settings.ts +1 -4
  121. package/src/types/nav.ts +1 -3
package/auto-imports.d.ts CHANGED
@@ -227,6 +227,7 @@ declare global {
227
227
  const useParentElement: typeof import('@vueuse/core')['useParentElement']
228
228
  const usePerformanceObserver: typeof import('@vueuse/core')['usePerformanceObserver']
229
229
  const usePermission: typeof import('@vueuse/core')['usePermission']
230
+ const usePersistence: typeof import('./src/composables/usePersistence')['usePersistence']
230
231
  const usePointer: typeof import('@vueuse/core')['usePointer']
231
232
  const usePointerLock: typeof import('@vueuse/core')['usePointerLock']
232
233
  const usePointerSwipe: typeof import('@vueuse/core')['usePointerSwipe']
@@ -1,6 +1,11 @@
1
1
  import { inject, computed, toRef, unref, defineComponent, useAttrs, toRefs, ref, watch, onBeforeUnmount, openBlock, createElementBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString } from "vue";
2
2
  import { uid } from "uid";
3
3
  import { useVModel } from "@vueuse/core";
4
+ var StorageType = /* @__PURE__ */ ((StorageType2) => {
5
+ StorageType2["local"] = "local";
6
+ StorageType2["session"] = "session";
7
+ return StorageType2;
8
+ })(StorageType || {});
4
9
  var Strategy = /* @__PURE__ */ ((Strategy2) => {
5
10
  Strategy2["absolute"] = "absolute";
6
11
  Strategy2["fixed"] = "fixed";
@@ -42,13 +47,6 @@ var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
42
47
  ActionTag2["button"] = "button";
43
48
  return ActionTag2;
44
49
  })(ActionTag || {});
45
- var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
46
- AnchorTarget2["_blank"] = "_blank";
47
- AnchorTarget2["_self"] = "_self";
48
- AnchorTarget2["_parent"] = "_parent";
49
- AnchorTarget2["_top"] = "_top";
50
- return AnchorTarget2;
51
- })(AnchorTarget || {});
52
50
  const INJECTION_KEY_ACCORDION_GROUP = Symbol.for(
53
51
  "accordionGroup"
54
52
  );
@@ -67,11 +65,7 @@ const LinkProps = {
67
65
  /**
68
66
  * Anchor target
69
67
  */
70
- target: {
71
- type: String,
72
- default: void 0,
73
- validator: (value) => Object.values(AnchorTarget).includes(value)
74
- },
68
+ target: String,
75
69
  /**
76
70
  * Anchor rel
77
71
  */
@@ -276,6 +270,14 @@ const ModifiersProps = {
276
270
  default: ActionTag.button
277
271
  }
278
272
  });
273
+ ({
274
+ storageType: {
275
+ type: String,
276
+ default: StorageType.local,
277
+ validator: (value) => Object.values(StorageType).includes(value)
278
+ },
279
+ storageKey: String
280
+ });
279
281
  function useInjectedGroupState(groupKey) {
280
282
  const group = inject(groupKey, void 0);
281
283
  const isInGroup = computed(() => group !== void 0);
@@ -1 +1 @@
1
- !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue"),require("uid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","uid","@vueuse/core"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvAccordion=o(e.vue,e.uid,e.core)}(this,(function(e,o,n){"use strict";var t=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(t||{}),a=(e=>(e.before="before",e.after="after",e))(a||{}),r=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(r||{}),u=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(u||{});const l=Symbol.for("accordionGroup"),i=(Boolean,Boolean,Boolean,Boolean,{modifiers:{type:[String,Array],default:void 0}});a.before,t.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,r.button,u.button;const d={...i,name:String,title:String,content:String,modelValue:{type:Boolean,default:void 0},disabled:Boolean,not:Boolean};function s(o){const{group:n,isInGroup:t}=function(o){const n=e.inject(o,void 0),t=e.computed((()=>void 0!==n));return{group:n,isInGroup:t,getGroupOrLocalRef:function(o,t,a){const r=null==n?void 0:n[o];if(r)return e.computed({get:()=>r.value,set(e){r.value=e}});const u=e.toRef(t,o);return e.computed({get:()=>u.value,set(e){a&&a(`update:${o}`,e)}})}}}(l),a=e.computed((()=>Boolean(o.disabled||(null==n?void 0:n.disabled.value)))),r=e.computed((()=>{let e=o.modifiers,t=null==n?void 0:n.modifiers.value;const a=new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach((e=>a.add(e)))),t&&(Array.isArray(t)||(t=t.split(" ")),t.forEach((e=>a.add(e)))),Array.from(a)}));return{isInGroup:t,group:n,modifiers:r,disabled:a,bus:null==n?void 0:n.bus}}const c=["id","open"],p=["aria-controls","aria-expanded"],m=["aria-hidden"];return e.defineComponent({name:"VvAccordion",props:d,emits:["update:modelValue"],setup(t,{expose:a,emit:r}){const u=t,l=e.useAttrs(),i=r,d=n.useVModel(u,"modelValue",i),f=e.computed((()=>u.name||(null==l?void 0:l.id)||o.uid())),{title:v,content:g,not:b}=e.toRefs(u),{isInGroup:y,modifiers:x,disabled:B,bus:h}=s(u),A=e.ref(!1);e.watch(d,(e=>{"boolean"==typeof e&&(A.value=b.value?!e:e)}),{immediate:!0}),e.watch(A,(e=>{d.value=b.value?!e:e})),null==h||h.on("toggle",(({name:e,value:o})=>{e===f.value&&(A.value=o)}));const E=()=>{B.value||(y.value?null==h||h.emit("toggle",{name:f.value,value:!A.value}):A.value=!A.value)};e.watch(f,((e,o)=>{h&&(o&&o!==e&&h.emit("unregister",{name:o}),h.emit("register",{name:e}))}),{immediate:!0}),e.onBeforeUnmount((()=>{h&&h.emit("unregister",{name:f.value})}));const V=()=>{A.value||E()},S=()=>{A.value&&E()},$=e=>{h?h.emit("expand",{name:e}):console.warn(`[VvAccordion]: You are trying to expand accordion group of "${f.value}" but it is not in a group`)},k=e=>{h?null==h||h.emit("collapse",{name:e}):console.warn(`[VvAccordion]: You are trying to collapse accordion group of "${f.value}" but it is not in a group`)};a({isExpanded:A,expand:V,collapse:S,groupExpand:$,groupCollapse:k});const w=function(o,n,t){return e.computed((()=>{const a={[o]:!0},r="string"==typeof(null==n?void 0:n.value)?n.value.split(" "):null==n?void 0:n.value;return r&&Array.isArray(r)&&r.forEach((e=>{e&&(a[`${o}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((n=>{a[`${o}--${n}`]=e.unref(t.value[n])})),a}))}("vv-accordion",x,e.computed((()=>({disabled:B.value}))));return(o,n)=>(e.openBlock(),e.createElementBlock("details",{id:e.unref(f),class:e.normalizeClass(e.unref(w)),open:e.unref(A)},[e.createElementVNode("summary",{"aria-controls":e.unref(f),"aria-expanded":e.unref(A),class:"vv-accordion__summary",onClick:n[0]||(n[0]=e.withModifiers((e=>E()),["prevent"]))},[e.renderSlot(o.$slots,"summary",e.normalizeProps(e.guardReactiveProps({isExpanded:e.unref(A),expand:V,collapse:S,groupExpand:$,groupCollapse:k})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(v)),1)]))],8,p),e.createElementVNode("div",{"aria-hidden":!e.unref(A),class:"vv-accordion__content"},[e.renderSlot(o.$slots,"default",e.normalizeProps(e.guardReactiveProps({isExpanded:e.unref(A),expand:V,collapse:S,groupExpand:$,groupCollapse:k})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(g)),1)]))],8,m)],10,c))}})}));
1
+ !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue"),require("uid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","uid","@vueuse/core"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvAccordion=o(e.vue,e.uid,e.core)}(this,(function(e,o,n){"use strict";var t=(e=>(e.local="local",e.session="session",e))(t||{}),a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),r=(e=>(e.before="before",e.after="after",e))(r||{}),u=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(u||{}),l=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(l||{});const i=Symbol.for("accordionGroup"),d=(Boolean,Boolean,Boolean,Boolean,{modifiers:{type:[String,Array],default:void 0}});r.before,a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,u.button,l.button,t.local;const s={...d,name:String,title:String,content:String,modelValue:{type:Boolean,default:void 0},disabled:Boolean,not:Boolean};function c(o){const{group:n,isInGroup:t}=function(o){const n=e.inject(o,void 0),t=e.computed((()=>void 0!==n));return{group:n,isInGroup:t,getGroupOrLocalRef:function(o,t,a){const r=null==n?void 0:n[o];if(r)return e.computed({get:()=>r.value,set(e){r.value=e}});const u=e.toRef(t,o);return e.computed({get:()=>u.value,set(e){a&&a(`update:${o}`,e)}})}}}(i),a=e.computed((()=>Boolean(o.disabled||(null==n?void 0:n.disabled.value)))),r=e.computed((()=>{let e=o.modifiers,t=null==n?void 0:n.modifiers.value;const a=new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach((e=>a.add(e)))),t&&(Array.isArray(t)||(t=t.split(" ")),t.forEach((e=>a.add(e)))),Array.from(a)}));return{isInGroup:t,group:n,modifiers:r,disabled:a,bus:null==n?void 0:n.bus}}const p=["id","open"],m=["aria-controls","aria-expanded"],f=["aria-hidden"];return e.defineComponent({name:"VvAccordion",props:s,emits:["update:modelValue"],setup(t,{expose:a,emit:r}){const u=t,l=e.useAttrs(),i=r,d=n.useVModel(u,"modelValue",i),s=e.computed((()=>u.name||(null==l?void 0:l.id)||o.uid())),{title:v,content:g,not:b}=e.toRefs(u),{isInGroup:y,modifiers:x,disabled:B,bus:h}=c(u),A=e.ref(!1);e.watch(d,(e=>{"boolean"==typeof e&&(A.value=b.value?!e:e)}),{immediate:!0}),e.watch(A,(e=>{d.value=b.value?!e:e})),null==h||h.on("toggle",(({name:e,value:o})=>{e===s.value&&(A.value=o)}));const E=()=>{B.value||(y.value?null==h||h.emit("toggle",{name:s.value,value:!A.value}):A.value=!A.value)};e.watch(s,((e,o)=>{h&&(o&&o!==e&&h.emit("unregister",{name:o}),h.emit("register",{name:e}))}),{immediate:!0}),e.onBeforeUnmount((()=>{h&&h.emit("unregister",{name:s.value})}));const V=()=>{A.value||E()},S=()=>{A.value&&E()},$=e=>{h?h.emit("expand",{name:e}):console.warn(`[VvAccordion]: You are trying to expand accordion group of "${s.value}" but it is not in a group`)},k=e=>{h?null==h||h.emit("collapse",{name:e}):console.warn(`[VvAccordion]: You are trying to collapse accordion group of "${s.value}" but it is not in a group`)};a({isExpanded:A,expand:V,collapse:S,groupExpand:$,groupCollapse:k});const w=function(o,n,t){return e.computed((()=>{const a={[o]:!0},r="string"==typeof(null==n?void 0:n.value)?n.value.split(" "):null==n?void 0:n.value;return r&&Array.isArray(r)&&r.forEach((e=>{e&&(a[`${o}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((n=>{a[`${o}--${n}`]=e.unref(t.value[n])})),a}))}("vv-accordion",x,e.computed((()=>({disabled:B.value}))));return(o,n)=>(e.openBlock(),e.createElementBlock("details",{id:e.unref(s),class:e.normalizeClass(e.unref(w)),open:e.unref(A)},[e.createElementVNode("summary",{"aria-controls":e.unref(s),"aria-expanded":e.unref(A),class:"vv-accordion__summary",onClick:n[0]||(n[0]=e.withModifiers((e=>E()),["prevent"]))},[e.renderSlot(o.$slots,"summary",e.normalizeProps(e.guardReactiveProps({isExpanded:e.unref(A),expand:V,collapse:S,groupExpand:$,groupCollapse:k})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(v)),1)]))],8,m),e.createElementVNode("div",{"aria-hidden":!e.unref(A),class:"vv-accordion__content"},[e.renderSlot(o.$slots,"default",e.normalizeProps(e.guardReactiveProps({isExpanded:e.unref(A),expand:V,collapse:S,groupExpand:$,groupCollapse:k})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(g)),1)]))],8,f)],10,p))}})}));
@@ -1,7 +1,12 @@
1
- import { inject, computed, toRef, unref, defineComponent, useAttrs, toRefs, ref, watch, onBeforeUnmount, openBlock, createElementBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString, provide, watchEffect, reactive, Fragment, renderList, createBlock, mergeProps, withCtx } from "vue";
1
+ import { inject, computed, toRef, unref, defineComponent, useAttrs, toRefs, ref, watch, onBeforeUnmount, openBlock, createElementBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString, isRef, provide, watchEffect, reactive, onMounted, nextTick, Fragment, renderList, createBlock, mergeProps, createSlots, withCtx } from "vue";
2
2
  import mitt from "mitt";
3
3
  import { uid } from "uid";
4
- import { useVModel, useLocalStorage } from "@vueuse/core";
4
+ import { useVModel, useStorage } from "@vueuse/core";
5
+ var StorageType = /* @__PURE__ */ ((StorageType2) => {
6
+ StorageType2["local"] = "local";
7
+ StorageType2["session"] = "session";
8
+ return StorageType2;
9
+ })(StorageType || {});
5
10
  var Strategy = /* @__PURE__ */ ((Strategy2) => {
6
11
  Strategy2["absolute"] = "absolute";
7
12
  Strategy2["fixed"] = "fixed";
@@ -43,13 +48,6 @@ var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
43
48
  ActionTag2["button"] = "button";
44
49
  return ActionTag2;
45
50
  })(ActionTag || {});
46
- var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
47
- AnchorTarget2["_blank"] = "_blank";
48
- AnchorTarget2["_self"] = "_self";
49
- AnchorTarget2["_parent"] = "_parent";
50
- AnchorTarget2["_top"] = "_top";
51
- return AnchorTarget2;
52
- })(AnchorTarget || {});
53
51
  const INJECTION_KEY_ACCORDION_GROUP = Symbol.for(
54
52
  "accordionGroup"
55
53
  );
@@ -68,11 +66,7 @@ const LinkProps = {
68
66
  /**
69
67
  * Anchor target
70
68
  */
71
- target: {
72
- type: String,
73
- default: void 0,
74
- validator: (value) => Object.values(AnchorTarget).includes(value)
75
- },
69
+ target: String,
76
70
  /**
77
71
  * Anchor rel
78
72
  */
@@ -277,6 +271,14 @@ const ModifiersProps = {
277
271
  default: ActionTag.button
278
272
  }
279
273
  });
274
+ const StorageProps = {
275
+ storageType: {
276
+ type: String,
277
+ default: StorageType.local,
278
+ validator: (value) => Object.values(StorageType).includes(value)
279
+ },
280
+ storageKey: String
281
+ };
280
282
  function useInjectedGroupState(groupKey) {
281
283
  const group = inject(groupKey, void 0);
282
284
  const isInGroup = computed(() => group !== void 0);
@@ -563,11 +565,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
563
565
  });
564
566
  const VvAccordionGroupProps = {
565
567
  ...ModifiersProps,
568
+ ...StorageProps,
566
569
  /**
567
570
  * VModel
568
571
  */
569
572
  modelValue: {
570
- type: [String, Array]
573
+ type: [String, Array],
574
+ default: void 0
571
575
  },
572
576
  /**
573
577
  * Accordion items
@@ -595,13 +599,69 @@ const VvAccordionGroupProps = {
595
599
  /**
596
600
  * If true, the accordion items will be opened by default
597
601
  */
598
- not: Boolean,
599
- /**
600
- * Enable local storage persistence
601
- */
602
- storeKey: String
602
+ not: Boolean
603
603
  };
604
604
  const VvAccordionGroupEvents = ["update:modelValue"];
605
+ const usePersistence = (storageKey, storageType = StorageType.local, defaultValue) => {
606
+ const localValue = ref();
607
+ if (defaultValue) {
608
+ localValue.value = defaultValue;
609
+ }
610
+ let storageValue;
611
+ if (storageKey) {
612
+ watch(
613
+ storageKey,
614
+ (newKey, oldKey) => {
615
+ const storage = unref(storageType) === StorageType.session ? sessionStorage : localStorage;
616
+ if (oldKey && oldKey !== newKey) {
617
+ storage.removeItem(oldKey);
618
+ }
619
+ if (newKey) {
620
+ storageValue = useStorage(
621
+ newKey,
622
+ (storageValue == null ? void 0 : storageValue.value) ?? localValue.value,
623
+ storage
624
+ );
625
+ return;
626
+ }
627
+ storageValue = void 0;
628
+ },
629
+ {
630
+ immediate: true
631
+ }
632
+ );
633
+ }
634
+ if (isRef(storageType)) {
635
+ watch(storageType, (newType, oldType) => {
636
+ if (storageKey == null ? void 0 : storageKey.value) {
637
+ if (newType) {
638
+ const storage = newType === StorageType.session ? sessionStorage : localStorage;
639
+ storageValue = useStorage(
640
+ storageKey.value,
641
+ (storageValue == null ? void 0 : storageValue.value) ?? localValue.value,
642
+ storage
643
+ );
644
+ }
645
+ if (oldType && oldType !== newType) {
646
+ const oldStorage = oldType === StorageType.session ? sessionStorage : localStorage;
647
+ oldStorage.removeItem(storageKey.value);
648
+ }
649
+ }
650
+ });
651
+ }
652
+ return computed({
653
+ get: () => {
654
+ return (storageValue == null ? void 0 : storageValue.value) ?? localValue.value;
655
+ },
656
+ set: (value) => {
657
+ if (storageValue) {
658
+ storageValue.value = value;
659
+ return;
660
+ }
661
+ localValue.value = value;
662
+ }
663
+ });
664
+ };
605
665
  function useProvideGroupState(key, groupState) {
606
666
  provide(key, groupState);
607
667
  }
@@ -615,7 +675,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
615
675
  setup(__props, { expose: __expose, emit: __emit }) {
616
676
  const props = __props;
617
677
  const emit = __emit;
618
- const { disabled, modifiers, itemModifiers, items } = toRefs(props);
678
+ const {
679
+ disabled,
680
+ modifiers,
681
+ itemModifiers,
682
+ items,
683
+ storageKey,
684
+ storageType
685
+ } = toRefs(props);
619
686
  watchEffect(() => {
620
687
  if (typeof props.modelValue === "string" && props.collapse) {
621
688
  console.warn(
@@ -624,77 +691,78 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
624
691
  }
625
692
  });
626
693
  const accordionNames = reactive(/* @__PURE__ */ new Set());
627
- let modelValue = ref(/* @__PURE__ */ new Set());
628
- watch(
629
- () => props.storeKey,
630
- (newKey, oldKey) => {
631
- if (oldKey && oldKey !== newKey) {
632
- localStorage.removeItem(oldKey);
633
- }
634
- if (newKey) {
635
- modelValue = useLocalStorage(newKey, modelValue.value);
636
- return;
637
- }
638
- modelValue = ref(new Set(modelValue.value));
639
- },
640
- { immediate: true }
694
+ const storageModelValue = usePersistence(
695
+ storageKey,
696
+ storageType
641
697
  );
642
- watch(
643
- [modelValue, accordionNames, () => props.not, () => props.collapse],
644
- () => {
645
- if (props.not) {
646
- emit(
647
- "update:modelValue",
648
- [...accordionNames].filter(
649
- (name) => !modelValue.value.has(name)
650
- )
651
- );
652
- return;
698
+ const localModelValue = computed({
699
+ get: () => {
700
+ if (props.modelValue !== null && props.modelValue !== void 0) {
701
+ return props.modelValue;
653
702
  }
654
- if (props.collapse) {
655
- emit("update:modelValue", [...modelValue.value]);
656
- return;
657
- }
658
- emit("update:modelValue", modelValue.value.values().next().value);
703
+ return storageModelValue.value;
659
704
  },
660
- {
661
- deep: true,
662
- immediate: true
705
+ set: (newValue) => {
706
+ emit("update:modelValue", newValue);
707
+ storageModelValue.value = newValue;
663
708
  }
664
- );
665
- watch(
666
- () => props.modelValue,
667
- (newValue, oldValue) => {
668
- if (newValue === void 0 || newValue === null || JSON.stringify(newValue) === JSON.stringify(oldValue)) {
669
- return;
709
+ });
710
+ const expandedAccordions = computed({
711
+ get: () => {
712
+ if (localModelValue.value === void 0) {
713
+ return /* @__PURE__ */ new Set();
670
714
  }
671
715
  let toReturn = /* @__PURE__ */ new Set();
672
716
  if (props.not) {
673
- if (typeof newValue === "string") {
717
+ if (typeof localModelValue.value === "string") {
674
718
  toReturn = new Set(
675
- [...accordionNames].filter((name) => name !== newValue)
719
+ [...accordionNames].filter(
720
+ (name) => name !== localModelValue.value
721
+ )
676
722
  );
677
- } else if (Array.isArray(newValue)) {
723
+ } else if (Array.isArray(localModelValue.value)) {
678
724
  toReturn = new Set(
679
725
  [...accordionNames].filter(
680
- (name) => !newValue.includes(name)
726
+ (name) => !localModelValue.value.includes(
727
+ name
728
+ )
681
729
  )
682
730
  );
683
731
  }
684
- } else if (typeof newValue === "string") {
685
- toReturn = /* @__PURE__ */ new Set([newValue]);
686
- } else if (Array.isArray(newValue)) {
687
- toReturn = new Set(newValue);
732
+ } else if (typeof localModelValue.value === "string") {
733
+ toReturn = /* @__PURE__ */ new Set([localModelValue.value]);
734
+ } else if (Array.isArray(localModelValue.value)) {
735
+ toReturn = new Set(localModelValue.value);
688
736
  }
689
- for (const name of accordionNames) {
690
- bus.emit("toggle", { name, value: toReturn.has(name) });
691
- }
692
- modelValue.value = toReturn;
737
+ return toReturn;
693
738
  },
694
- {
695
- immediate: true
739
+ set: (newValue) => {
740
+ if (props.not) {
741
+ localModelValue.value = [...accordionNames].filter(
742
+ (name) => !newValue.has(name)
743
+ );
744
+ return;
745
+ }
746
+ if (props.collapse) {
747
+ localModelValue.value = [...newValue];
748
+ return;
749
+ }
750
+ localModelValue.value = newValue.values().next().value;
696
751
  }
697
- );
752
+ });
753
+ onMounted(() => {
754
+ if (props.not && localModelValue.value === void 0) {
755
+ localModelValue.value = props.collapse ? [] : [...accordionNames.values()].splice(1, accordionNames.size);
756
+ }
757
+ nextTick(() => {
758
+ for (const name of accordionNames) {
759
+ bus.emit("toggle", {
760
+ name,
761
+ value: expandedAccordions.value.has(name)
762
+ });
763
+ }
764
+ });
765
+ });
698
766
  const bus = mitt();
699
767
  useProvideGroupState(INJECTION_KEY_ACCORDION_GROUP, {
700
768
  disabled,
@@ -708,19 +776,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
708
776
  accordionNames.delete(name);
709
777
  });
710
778
  bus.on("toggle", ({ name, value }) => {
779
+ const newValue = new Set(expandedAccordions.value);
711
780
  if (value) {
712
781
  if (!props.collapse) {
713
- for (const item of modelValue.value) {
782
+ for (const item of newValue) {
714
783
  if (item !== name) {
715
784
  bus.emit("toggle", { name: item, value: false });
716
785
  }
717
786
  }
718
- modelValue.value.clear();
787
+ newValue.clear();
719
788
  }
720
- modelValue.value.add(name);
789
+ newValue.add(name);
790
+ expandedAccordions.value = newValue;
721
791
  return;
722
792
  }
723
- modelValue.value.delete(name);
793
+ newValue.delete(name);
794
+ expandedAccordions.value = newValue;
724
795
  });
725
796
  const expand = (name) => {
726
797
  if (typeof name === "string") {
@@ -754,7 +825,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
754
825
  }
755
826
  };
756
827
  bus.on("collapse", ({ name }) => collapse(name));
757
- __expose({ modelValue, expand, collapse });
828
+ __expose({ expandedAccordions, expand, collapse });
758
829
  const bemCssClasses = useModifiers(
759
830
  "vv-accordion-group",
760
831
  modifiers,
@@ -770,7 +841,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
770
841
  },
771
842
  [
772
843
  renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
773
- modelValue: unref(modelValue),
844
+ expandedAccordions: unref(expandedAccordions),
774
845
  expand,
775
846
  collapse
776
847
  })), () => [
@@ -787,16 +858,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
787
858
  title: item.title,
788
859
  content: item.content
789
860
  }),
790
- {
791
- header: withCtx((data) => [
792
- renderSlot(_ctx.$slots, `header::${item.name}`, normalizeProps(guardReactiveProps(data)))
793
- ]),
794
- details: withCtx((data) => [
795
- renderSlot(_ctx.$slots, `details::${item.name}`, normalizeProps(guardReactiveProps(data)))
796
- ]),
861
+ createSlots({
797
862
  _: 2
798
863
  /* DYNAMIC */
799
- },
864
+ }, [
865
+ _ctx.$slots[`summary::${item.name}`] ? {
866
+ name: "summary",
867
+ fn: withCtx((data) => [
868
+ renderSlot(_ctx.$slots, `summary::${item.name}`, normalizeProps(guardReactiveProps(data)))
869
+ ]),
870
+ key: "0"
871
+ } : void 0,
872
+ _ctx.$slots[`content::${item.name}`] ? {
873
+ name: "default",
874
+ fn: withCtx((data) => [
875
+ renderSlot(_ctx.$slots, `content::${item.name}`, normalizeProps(guardReactiveProps(data)))
876
+ ]),
877
+ key: "1"
878
+ } : void 0
879
+ ]),
800
880
  1040
801
881
  /* FULL_PROPS, DYNAMIC_SLOTS */
802
882
  );
@@ -1 +1 @@
1
- !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue"),require("mitt"),require("uid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","mitt","uid","@vueuse/core"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvAccordionGroup=o(e.vue,e.mitt,e.uid,e.core)}(this,(function(e,o,t,a){"use strict";var n=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(n||{}),r=(e=>(e.before="before",e.after="after",e))(r||{}),l=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(l||{}),i=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(i||{});const u=Symbol.for("accordionGroup"),s=(Boolean,Boolean,Boolean,Boolean,{modifiers:{type:[String,Array],default:void 0}});r.before,n.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,l.button,i.button;const d={...s,name:String,title:String,content:String,modelValue:{type:Boolean,default:void 0},disabled:Boolean,not:Boolean};function c(o){const{group:t,isInGroup:a}=function(o){const t=e.inject(o,void 0),a=e.computed((()=>void 0!==t));return{group:t,isInGroup:a,getGroupOrLocalRef:function(o,a,n){const r=null==t?void 0:t[o];if(r)return e.computed({get:()=>r.value,set(e){r.value=e}});const l=e.toRef(a,o);return e.computed({get:()=>l.value,set(e){n&&n(`update:${o}`,e)}})}}}(u),n=e.computed((()=>Boolean(o.disabled||(null==t?void 0:t.disabled.value)))),r=e.computed((()=>{let e=o.modifiers,a=null==t?void 0:t.modifiers.value;const n=new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach((e=>n.add(e)))),a&&(Array.isArray(a)||(a=a.split(" ")),a.forEach((e=>n.add(e)))),Array.from(n)}));return{isInGroup:a,group:t,modifiers:r,disabled:n,bus:null==t?void 0:t.bus}}function m(o,t,a){return e.computed((()=>{const n={[o]:!0},r="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return r&&Array.isArray(r)&&r.forEach((e=>{e&&(n[`${o}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((t=>{n[`${o}--${t}`]=e.unref(a.value[t])})),n}))}const p=["id","open"],f=["aria-controls","aria-expanded"],v=["aria-hidden"],g=e.defineComponent({name:"VvAccordion",props:d,emits:["update:modelValue"],setup(o,{expose:n,emit:r}){const l=o,i=e.useAttrs(),u=r,s=a.useVModel(l,"modelValue",u),d=e.computed((()=>l.name||(null==i?void 0:i.id)||t.uid())),{title:g,content:y,not:b}=e.toRefs(l),{isInGroup:B,modifiers:S,disabled:x,bus:A}=c(l),h=e.ref(!1);e.watch(s,(e=>{"boolean"==typeof e&&(h.value=b.value?!e:e)}),{immediate:!0}),e.watch(h,(e=>{s.value=b.value?!e:e})),null==A||A.on("toggle",(({name:e,value:o})=>{e===d.value&&(h.value=o)}));const V=()=>{x.value||(B.value?null==A||A.emit("toggle",{name:d.value,value:!h.value}):h.value=!h.value)};e.watch(d,((e,o)=>{A&&(o&&o!==e&&A.emit("unregister",{name:o}),A.emit("register",{name:e}))}),{immediate:!0}),e.onBeforeUnmount((()=>{A&&A.emit("unregister",{name:d.value})}));const w=()=>{h.value||V()},E=()=>{h.value&&V()},k=e=>{A?A.emit("expand",{name:e}):console.warn(`[VvAccordion]: You are trying to expand accordion group of "${d.value}" but it is not in a group`)},$=e=>{A?null==A||A.emit("collapse",{name:e}):console.warn(`[VvAccordion]: You are trying to collapse accordion group of "${d.value}" but it is not in a group`)};n({isExpanded:h,expand:w,collapse:E,groupExpand:k,groupCollapse:$});const P=m("vv-accordion",S,e.computed((()=>({disabled:x.value}))));return(o,t)=>(e.openBlock(),e.createElementBlock("details",{id:e.unref(d),class:e.normalizeClass(e.unref(P)),open:e.unref(h)},[e.createElementVNode("summary",{"aria-controls":e.unref(d),"aria-expanded":e.unref(h),class:"vv-accordion__summary",onClick:t[0]||(t[0]=e.withModifiers((e=>V()),["prevent"]))},[e.renderSlot(o.$slots,"summary",e.normalizeProps(e.guardReactiveProps({isExpanded:e.unref(h),expand:w,collapse:E,groupExpand:k,groupCollapse:$})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(g)),1)]))],8,f),e.createElementVNode("div",{"aria-hidden":!e.unref(h),class:"vv-accordion__content"},[e.renderSlot(o.$slots,"default",e.normalizeProps(e.guardReactiveProps({isExpanded:e.unref(h),expand:w,collapse:E,groupExpand:k,groupCollapse:$})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(y)),1)]))],8,v)],10,p))}}),y={...s,modelValue:{type:[String,Array]},items:{type:Array,default:()=>[]},collapse:Boolean,itemModifiers:{type:[String,Array],default:""},disabled:Boolean,not:Boolean,storeKey:String};return e.defineComponent({name:"VvAccordionGroup",props:y,emits:["update:modelValue"],setup(t,{expose:n,emit:r}){const l=t,i=r,{disabled:s,modifiers:d,itemModifiers:c,items:p}=e.toRefs(l);e.watchEffect((()=>{"string"==typeof l.modelValue&&l.collapse&&console.warn("[VvAccordionGroup]: modelValue is a string but collapse is true.")}));const f=e.reactive(new Set);let v=e.ref(new Set);e.watch((()=>l.storeKey),((o,t)=>{t&&t!==o&&localStorage.removeItem(t),v=o?a.useLocalStorage(o,v.value):e.ref(new Set(v.value))}),{immediate:!0}),e.watch([v,f,()=>l.not,()=>l.collapse],(()=>{l.not?i("update:modelValue",[...f].filter((e=>!v.value.has(e)))):l.collapse?i("update:modelValue",[...v.value]):i("update:modelValue",v.value.values().next().value)}),{deep:!0,immediate:!0}),e.watch((()=>l.modelValue),((e,o)=>{if(null==e||JSON.stringify(e)===JSON.stringify(o))return;let t=new Set;l.not?"string"==typeof e?t=new Set([...f].filter((o=>o!==e))):Array.isArray(e)&&(t=new Set([...f].filter((o=>!e.includes(o))))):"string"==typeof e?t=new Set([e]):Array.isArray(e)&&(t=new Set(e));for(const a of f)y.emit("toggle",{name:a,value:t.has(a)});v.value=t}),{immediate:!0});const y=o();var b,B;b=u,B={disabled:s,modifiers:c,bus:y},e.provide(b,B),y.on("register",(({name:e})=>{f.add(e)})),y.on("unregister",(({name:e})=>{f.delete(e)})),y.on("toggle",(({name:e,value:o})=>{if(o){if(!l.collapse){for(const o of v.value)o!==e&&y.emit("toggle",{name:o,value:!1});v.value.clear()}v.value.add(e)}else v.value.delete(e)}));const S=e=>{if("string"!=typeof e)if(Array.isArray(e))for(const o of e)y.emit("toggle",{name:o,value:!0});else for(const o of f)y.emit("toggle",{name:o,value:!0});else y.emit("toggle",{name:e,value:!0})};y.on("expand",(({name:e})=>S(e)));const x=e=>{if("string"!=typeof e)if(Array.isArray(e))for(const o of e)y.emit("toggle",{name:o,value:!1});else for(const o of f)y.emit("toggle",{name:o,value:!1});else y.emit("toggle",{name:e,value:!1})};y.on("collapse",(({name:e})=>x(e))),n({modelValue:v,expand:S,collapse:x});const A=m("vv-accordion-group",d,e.computed((()=>({disabled:s.value}))));return(o,t)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(A))},[e.renderSlot(o.$slots,"default",e.normalizeProps(e.guardReactiveProps({modelValue:e.unref(v),expand:S,collapse:x})),(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(p),(t=>(e.openBlock(),e.createBlock(g,e.mergeProps({key:t.title},{name:t.name,title:t.title,content:t.content}),{header:e.withCtx((a=>[e.renderSlot(o.$slots,`header::${t.name}`,e.normalizeProps(e.guardReactiveProps(a)))])),details:e.withCtx((a=>[e.renderSlot(o.$slots,`details::${t.name}`,e.normalizeProps(e.guardReactiveProps(a)))])),_:2},1040)))),128))]))],2))}})}));
1
+ !function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(require("vue"),require("mitt"),require("uid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","mitt","uid","@vueuse/core"],o):(e="undefined"!=typeof globalThis?globalThis:e||self).VvAccordionGroup=o(e.vue,e.mitt,e.uid,e.core)}(this,(function(e,o,t,a){"use strict";var n=(e=>(e.local="local",e.session="session",e))(n||{}),l=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(l||{}),r=(e=>(e.before="before",e.after="after",e))(r||{}),u=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(u||{}),i=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(i||{});const s=Symbol.for("accordionGroup"),d=(Boolean,Boolean,Boolean,Boolean,{modifiers:{type:[String,Array],default:void 0}});r.before,l.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,u.button,i.button;const c={storageType:{type:String,default:n.local,validator:e=>Object.values(n).includes(e)},storageKey:String};const m={...d,name:String,title:String,content:String,modelValue:{type:Boolean,default:void 0},disabled:Boolean,not:Boolean};function v(o){const{group:t,isInGroup:a}=function(o){const t=e.inject(o,void 0),a=e.computed((()=>void 0!==t));return{group:t,isInGroup:a,getGroupOrLocalRef:function(o,a,n){const l=null==t?void 0:t[o];if(l)return e.computed({get:()=>l.value,set(e){l.value=e}});const r=e.toRef(a,o);return e.computed({get:()=>r.value,set(e){n&&n(`update:${o}`,e)}})}}}(s),n=e.computed((()=>Boolean(o.disabled||(null==t?void 0:t.disabled.value)))),l=e.computed((()=>{let e=o.modifiers,a=null==t?void 0:t.modifiers.value;const n=new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach((e=>n.add(e)))),a&&(Array.isArray(a)||(a=a.split(" ")),a.forEach((e=>n.add(e)))),Array.from(n)}));return{isInGroup:a,group:t,modifiers:l,disabled:n,bus:null==t?void 0:t.bus}}function p(o,t,a){return e.computed((()=>{const n={[o]:!0},l="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return l&&Array.isArray(l)&&l.forEach((e=>{e&&(n[`${o}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((t=>{n[`${o}--${t}`]=e.unref(a.value[t])})),n}))}const f=["id","open"],g=["aria-controls","aria-expanded"],y=["aria-hidden"],b=e.defineComponent({name:"VvAccordion",props:m,emits:["update:modelValue"],setup(o,{expose:n,emit:l}){const r=o,u=e.useAttrs(),i=l,s=a.useVModel(r,"modelValue",i),d=e.computed((()=>r.name||(null==u?void 0:u.id)||t.uid())),{title:c,content:m,not:b}=e.toRefs(r),{isInGroup:S,modifiers:x,disabled:A,bus:B}=v(r),h=e.ref(!1);e.watch(s,(e=>{"boolean"==typeof e&&(h.value=b.value?!e:e)}),{immediate:!0}),e.watch(h,(e=>{s.value=b.value?!e:e})),null==B||B.on("toggle",(({name:e,value:o})=>{e===d.value&&(h.value=o)}));const V=()=>{A.value||(S.value?null==B||B.emit("toggle",{name:d.value,value:!h.value}):h.value=!h.value)};e.watch(d,((e,o)=>{B&&(o&&o!==e&&B.emit("unregister",{name:o}),B.emit("register",{name:e}))}),{immediate:!0}),e.onBeforeUnmount((()=>{B&&B.emit("unregister",{name:d.value})}));const w=()=>{h.value||V()},k=()=>{h.value&&V()},$=e=>{B?B.emit("expand",{name:e}):console.warn(`[VvAccordion]: You are trying to expand accordion group of "${d.value}" but it is not in a group`)},E=e=>{B?null==B||B.emit("collapse",{name:e}):console.warn(`[VvAccordion]: You are trying to collapse accordion group of "${d.value}" but it is not in a group`)};n({isExpanded:h,expand:w,collapse:k,groupExpand:$,groupCollapse:E});const P=p("vv-accordion",x,e.computed((()=>({disabled:A.value}))));return(o,t)=>(e.openBlock(),e.createElementBlock("details",{id:e.unref(d),class:e.normalizeClass(e.unref(P)),open:e.unref(h)},[e.createElementVNode("summary",{"aria-controls":e.unref(d),"aria-expanded":e.unref(h),class:"vv-accordion__summary",onClick:t[0]||(t[0]=e.withModifiers((e=>V()),["prevent"]))},[e.renderSlot(o.$slots,"summary",e.normalizeProps(e.guardReactiveProps({isExpanded:e.unref(h),expand:w,collapse:k,groupExpand:$,groupCollapse:E})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(c)),1)]))],8,g),e.createElementVNode("div",{"aria-hidden":!e.unref(h),class:"vv-accordion__content"},[e.renderSlot(o.$slots,"default",e.normalizeProps(e.guardReactiveProps({isExpanded:e.unref(h),expand:w,collapse:k,groupExpand:$,groupCollapse:E})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(m)),1)]))],8,y)],10,f))}}),S={...d,...c,modelValue:{type:[String,Array],default:void 0},items:{type:Array,default:()=>[]},collapse:Boolean,itemModifiers:{type:[String,Array],default:""},disabled:Boolean,not:Boolean};return e.defineComponent({name:"VvAccordionGroup",props:S,emits:["update:modelValue"],setup(t,{expose:l,emit:r}){const u=t,i=r,{disabled:d,modifiers:c,itemModifiers:m,items:v,storageKey:f,storageType:g}=e.toRefs(u);e.watchEffect((()=>{"string"==typeof u.modelValue&&u.collapse&&console.warn("[VvAccordionGroup]: modelValue is a string but collapse is true.")}));const y=e.reactive(new Set),S=((o,t=n.local,l)=>{const r=e.ref();let u;return l&&(r.value=l),o&&e.watch(o,((o,l)=>{const i=e.unref(t)===n.session?sessionStorage:localStorage;l&&l!==o&&i.removeItem(l),u=o?a.useStorage(o,(null==u?void 0:u.value)??r.value,i):void 0}),{immediate:!0}),e.isRef(t)&&e.watch(t,((e,t)=>{if(null==o?void 0:o.value){if(e){const t=e===n.session?sessionStorage:localStorage;u=a.useStorage(o.value,(null==u?void 0:u.value)??r.value,t)}t&&t!==e&&(t===n.session?sessionStorage:localStorage).removeItem(o.value)}})),e.computed({get:()=>(null==u?void 0:u.value)??r.value,set:e=>{u?u.value=e:r.value=e}})})(f,g),x=e.computed({get:()=>null!==u.modelValue&&void 0!==u.modelValue?u.modelValue:S.value,set:e=>{i("update:modelValue",e),S.value=e}}),A=e.computed({get:()=>{if(void 0===x.value)return new Set;let e=new Set;return u.not?"string"==typeof x.value?e=new Set([...y].filter((e=>e!==x.value))):Array.isArray(x.value)&&(e=new Set([...y].filter((e=>!x.value.includes(e))))):"string"==typeof x.value?e=new Set([x.value]):Array.isArray(x.value)&&(e=new Set(x.value)),e},set:e=>{u.not?x.value=[...y].filter((o=>!e.has(o))):u.collapse?x.value=[...e]:x.value=e.values().next().value}});e.onMounted((()=>{u.not&&void 0===x.value&&(x.value=u.collapse?[]:[...y.values()].splice(1,y.size)),e.nextTick((()=>{for(const e of y)B.emit("toggle",{name:e,value:A.value.has(e)})}))}));const B=o();var h,V;h=s,V={disabled:d,modifiers:m,bus:B},e.provide(h,V),B.on("register",(({name:e})=>{y.add(e)})),B.on("unregister",(({name:e})=>{y.delete(e)})),B.on("toggle",(({name:e,value:o})=>{const t=new Set(A.value);if(o){if(!u.collapse){for(const o of t)o!==e&&B.emit("toggle",{name:o,value:!1});t.clear()}return t.add(e),void(A.value=t)}t.delete(e),A.value=t}));const w=e=>{if("string"!=typeof e)if(Array.isArray(e))for(const o of e)B.emit("toggle",{name:o,value:!0});else for(const o of y)B.emit("toggle",{name:o,value:!0});else B.emit("toggle",{name:e,value:!0})};B.on("expand",(({name:e})=>w(e)));const k=e=>{if("string"!=typeof e)if(Array.isArray(e))for(const o of e)B.emit("toggle",{name:o,value:!1});else for(const o of y)B.emit("toggle",{name:o,value:!1});else B.emit("toggle",{name:e,value:!1})};B.on("collapse",(({name:e})=>k(e))),l({expandedAccordions:A,expand:w,collapse:k});const $=p("vv-accordion-group",c,e.computed((()=>({disabled:d.value}))));return(o,t)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref($))},[e.renderSlot(o.$slots,"default",e.normalizeProps(e.guardReactiveProps({expandedAccordions:e.unref(A),expand:w,collapse:k})),(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(v),(t=>(e.openBlock(),e.createBlock(b,e.mergeProps({key:t.title},{name:t.name,title:t.title,content:t.content}),e.createSlots({_:2},[o.$slots[`summary::${t.name}`]?{name:"summary",fn:e.withCtx((a=>[e.renderSlot(o.$slots,`summary::${t.name}`,e.normalizeProps(e.guardReactiveProps(a)))])),key:"0"}:void 0,o.$slots[`content::${t.name}`]?{name:"default",fn:e.withCtx((a=>[e.renderSlot(o.$slots,`content::${t.name}`,e.normalizeProps(e.guardReactiveProps(a)))])),key:"1"}:void 0]),1040)))),128))]))],2))}})}));
@@ -1,6 +1,7 @@
1
1
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
2
2
  modelValue: {
3
3
  type: globalThis.PropType<string | string[] | undefined>;
4
+ default: undefined;
4
5
  };
5
6
  items: {
6
7
  type: globalThis.PropType<import(".").VvAccordionGroupItem[]>;
@@ -13,13 +14,18 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
13
14
  };
14
15
  disabled: BooleanConstructor;
15
16
  not: BooleanConstructor;
16
- storeKey: StringConstructor;
17
+ storageType: {
18
+ type: globalThis.PropType<"local" | "session">;
19
+ default: import("../../constants").StorageType;
20
+ validator: (value: import("../../constants").StorageType) => boolean;
21
+ };
22
+ storageKey: StringConstructor;
17
23
  modifiers: {
18
24
  type: globalThis.PropType<string | string[]>;
19
25
  default: undefined;
20
26
  };
21
27
  }, {
22
- modelValue: globalThis.Ref<Set<string> & Omit<Set<string>, keyof Set<any>>>;
28
+ expandedAccordions: globalThis.WritableComputedRef<Set<string>>;
23
29
  expand: (name?: string | string[]) => void;
24
30
  collapse: (name?: string | string[]) => void;
25
31
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
@@ -27,6 +33,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
27
33
  }, string, import("vue").PublicProps, Readonly<globalThis.ExtractPropTypes<{
28
34
  modelValue: {
29
35
  type: globalThis.PropType<string | string[] | undefined>;
36
+ default: undefined;
30
37
  };
31
38
  items: {
32
39
  type: globalThis.PropType<import(".").VvAccordionGroupItem[]>;
@@ -39,7 +46,12 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
39
46
  };
40
47
  disabled: BooleanConstructor;
41
48
  not: BooleanConstructor;
42
- storeKey: StringConstructor;
49
+ storageType: {
50
+ type: globalThis.PropType<"local" | "session">;
51
+ default: import("../../constants").StorageType;
52
+ validator: (value: import("../../constants").StorageType) => boolean;
53
+ };
54
+ storageKey: StringConstructor;
43
55
  modifiers: {
44
56
  type: globalThis.PropType<string | string[]>;
45
57
  default: undefined;
@@ -47,13 +59,27 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
47
59
  }>>, {
48
60
  collapse: boolean;
49
61
  disabled: boolean;
62
+ modelValue: string | string[] | undefined;
50
63
  not: boolean;
51
64
  modifiers: string | string[];
52
65
  items: import(".").VvAccordionGroupItem[];
53
66
  itemModifiers: string | string[];
54
- }, {}>, Partial<Record<`header::${string}`, (_: any) => any>> & Partial<Record<`details::${string}`, (_: any) => any>> & {
67
+ storageType: "local" | "session";
68
+ }, {}>, Partial<Record<`summary::${string}`, (_: {
69
+ isExpanded: boolean;
70
+ expand: () => void;
71
+ collapse: () => void;
72
+ groupExpand: (name?: string | string[] | undefined) => void;
73
+ groupCollapse: (name?: string | string[] | undefined) => void;
74
+ }) => any>> & Partial<Record<`content::${string}`, (_: {
75
+ isExpanded: boolean;
76
+ expand: () => void;
77
+ collapse: () => void;
78
+ groupExpand: (name?: string | string[] | undefined) => void;
79
+ groupCollapse: (name?: string | string[] | undefined) => void;
80
+ }) => any>> & {
55
81
  default?(_: {
56
- modelValue: Set<string> & Omit<Set<string>, keyof Set<any>>;
82
+ expandedAccordions: Set<string>;
57
83
  expand: (name?: string | string[]) => void;
58
84
  collapse: (name?: string | string[]) => void;
59
85
  }): any;
@@ -11,6 +11,7 @@ export declare const VvAccordionGroupProps: {
11
11
  */
12
12
  modelValue: {
13
13
  type: globalThis.PropType<string | string[] | undefined>;
14
+ default: undefined;
14
15
  };
15
16
  /**
16
17
  * Accordion items
@@ -39,10 +40,12 @@ export declare const VvAccordionGroupProps: {
39
40
  * If true, the accordion items will be opened by default
40
41
  */
41
42
  not: BooleanConstructor;
42
- /**
43
- * Enable local storage persistence
44
- */
45
- storeKey: StringConstructor;
43
+ storageType: {
44
+ type: globalThis.PropType<"local" | "session">;
45
+ default: import("../../constants").StorageType;
46
+ validator: (value: import("../../constants").StorageType) => boolean;
47
+ };
48
+ storageKey: StringConstructor;
46
49
  modifiers: {
47
50
  type: globalThis.PropType<string | string[]>;
48
51
  default: undefined;