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

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 (89) hide show
  1. package/dist/components/VvAccordion/VvAccordion.es.js +119 -79
  2. package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
  3. package/dist/components/VvAccordion/VvAccordion.vue.d.ts +18 -4
  4. package/dist/components/VvAccordion/index.d.ts +4 -8
  5. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +250 -119
  6. package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
  7. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +18 -6
  8. package/dist/components/VvAccordionGroup/index.d.ts +3 -1
  9. package/dist/components/VvAction/VvAction.vue.d.ts +1 -1
  10. package/dist/components/VvAlert/VvAlert.vue.d.ts +1 -1
  11. package/dist/components/VvButton/VvButton.es.js +92 -98
  12. package/dist/components/VvButton/VvButton.umd.js +1 -1
  13. package/dist/components/VvButton/VvButton.vue.d.ts +7 -7
  14. package/dist/components/VvButton/index.d.ts +11 -11
  15. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +7 -13
  16. package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
  17. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +3 -3
  18. package/dist/components/VvCheckbox/VvCheckbox.es.js +81 -87
  19. package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
  20. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +6 -6
  21. package/dist/components/VvCheckbox/index.d.ts +2 -2
  22. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +15 -29
  23. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
  24. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +5 -5
  25. package/dist/components/VvCombobox/VvCombobox.es.js +13 -16
  26. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  27. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +11 -11
  28. package/dist/components/VvCombobox/index.d.ts +1 -1
  29. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +5 -5
  30. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +1 -1
  31. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +1 -1
  32. package/dist/components/VvDropdown/index.d.ts +1 -1
  33. package/dist/components/VvInputFile/VvInputFile.es.js +183 -168
  34. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
  35. package/dist/components/VvInputFile/VvInputFile.vue.d.ts +16 -9
  36. package/dist/components/VvInputFile/index.d.ts +12 -3
  37. package/dist/components/VvInputText/VvInputClearAction.d.ts +1 -1
  38. package/dist/components/VvInputText/VvInputStepAction.d.ts +1 -1
  39. package/dist/components/VvInputText/VvInputText.vue.d.ts +6 -6
  40. package/dist/components/VvProgress/VvProgress.vue.d.ts +1 -1
  41. package/dist/components/VvRadio/VvRadio.es.js +64 -70
  42. package/dist/components/VvRadio/VvRadio.umd.js +1 -1
  43. package/dist/components/VvRadio/VvRadio.vue.d.ts +6 -6
  44. package/dist/components/VvRadio/index.d.ts +6 -6
  45. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +15 -29
  46. package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
  47. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +5 -5
  48. package/dist/components/VvSelect/VvSelect.vue.d.ts +8 -8
  49. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +5 -5
  50. package/dist/components/VvTooltip/VvTooltip.vue.d.ts +3 -3
  51. package/dist/components/VvTooltip/index.d.ts +1 -1
  52. package/dist/components/index.es.js +462 -323
  53. package/dist/components/index.umd.js +1 -1
  54. package/dist/composables/alert/useInjectAlert.d.ts +1 -6
  55. package/dist/composables/group/useInjectedGroupState.d.ts +4 -5
  56. package/dist/composables/group/useProvideGroupState.d.ts +3 -3
  57. package/dist/constants.d.ts +6 -10
  58. package/dist/icons.es.js +3 -3
  59. package/dist/icons.umd.js +1 -1
  60. package/dist/index.es.js +3 -2
  61. package/dist/index.umd.js +1 -1
  62. package/dist/props/index.d.ts +1 -1
  63. package/dist/resolvers/unplugin.es.js +3 -2
  64. package/dist/resolvers/unplugin.umd.js +1 -1
  65. package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +38 -14
  66. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +259 -101
  67. package/dist/types/group.d.ts +37 -15
  68. package/package.json +37 -36
  69. package/src/assets/icons/detailed.json +1 -1
  70. package/src/assets/icons/normal.json +1 -1
  71. package/src/assets/icons/simple.json +1 -1
  72. package/src/components/VvAccordion/VvAccordion.vue +119 -56
  73. package/src/components/VvAccordion/index.ts +8 -23
  74. package/src/components/VvAccordionGroup/VvAccordionGroup.vue +140 -41
  75. package/src/components/VvAccordionGroup/index.ts +3 -1
  76. package/src/components/VvButton/index.ts +7 -12
  77. package/src/components/VvButtonGroup/VvButtonGroup.vue +1 -2
  78. package/src/components/VvCheckbox/index.ts +2 -2
  79. package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +1 -2
  80. package/src/components/VvInputFile/VvInputFile.vue +71 -47
  81. package/src/components/VvInputFile/index.ts +5 -4
  82. package/src/components/VvRadio/index.ts +5 -5
  83. package/src/components/VvRadioGroup/VvRadioGroup.vue +1 -2
  84. package/src/composables/group/useInjectedGroupState.ts +20 -16
  85. package/src/composables/group/useProvideGroupState.ts +10 -15
  86. package/src/constants.ts +19 -14
  87. package/src/stories/AccordionGroup/AccordionGroup.test.ts +15 -9
  88. package/src/stories/AccordionGroup/AccordionGroupSlots.stories.ts +1 -1
  89. package/src/types/group.ts +22 -14
@@ -1,6 +1,6 @@
1
- import { unref, inject, computed, toRef, toRefs, defineComponent, useAttrs, ref, openBlock, createElementBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString } from "vue";
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
- import { useToggle } from "@vueuse/core";
3
+ import { useVModel } from "@vueuse/core";
4
4
  var Strategy = /* @__PURE__ */ ((Strategy2) => {
5
5
  Strategy2["absolute"] = "absolute";
6
6
  Strategy2["fixed"] = "fixed";
@@ -49,7 +49,9 @@ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
49
49
  AnchorTarget2["_top"] = "_top";
50
50
  return AnchorTarget2;
51
51
  })(AnchorTarget || {});
52
- const INJECTION_KEY_ACCORDION_GROUP = Symbol.for("accordionGroup");
52
+ const INJECTION_KEY_ACCORDION_GROUP = Symbol.for(
53
+ "accordionGroup"
54
+ );
53
55
  const LinkProps = {
54
56
  /**
55
57
  * The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
@@ -274,18 +276,15 @@ const ModifiersProps = {
274
276
  default: ActionTag.button
275
277
  }
276
278
  });
277
- function isEmpty(value) {
278
- return ((value2) => value2 === null || value2 === void 0 || value2 === "" || Array.isArray(value2) && value2.length === 0 || !(value2 instanceof Date) && typeof value2 === "object" && Object.keys(value2).length === 0)(unref(value));
279
- }
280
279
  function useInjectedGroupState(groupKey) {
281
280
  const group = inject(groupKey, void 0);
282
- const isInGroup = computed(() => !isEmpty(group));
281
+ const isInGroup = computed(() => group !== void 0);
283
282
  function getGroupOrLocalRef(propName, props, emit) {
284
- if (group == null ? void 0 : group.value) {
285
- const groupPropValue = unref(group.value)[propName];
283
+ const groupPropValue = group == null ? void 0 : group[propName];
284
+ if (groupPropValue) {
286
285
  return computed({
287
286
  get() {
288
- return groupPropValue == null ? void 0 : groupPropValue.value;
287
+ return groupPropValue.value;
289
288
  },
290
289
  set(value) {
291
290
  groupPropValue.value = value;
@@ -298,8 +297,9 @@ function useInjectedGroupState(groupKey) {
298
297
  return propRef.value;
299
298
  },
300
299
  set(value) {
301
- if (emit)
300
+ if (emit) {
302
301
  emit(`update:${propName}`, value);
302
+ }
303
303
  }
304
304
  });
305
305
  }
@@ -340,23 +340,16 @@ const VvAccordionProps = {
340
340
  not: Boolean
341
341
  };
342
342
  const VvAccordionEvents = ["update:modelValue"];
343
- function useGroupProps(props, emit) {
344
- const { group, isInGroup, getGroupOrLocalRef } = useInjectedGroupState(
343
+ function useGroupProps(props) {
344
+ const { group, isInGroup } = useInjectedGroupState(
345
345
  INJECTION_KEY_ACCORDION_GROUP
346
346
  );
347
- const { title, content } = toRefs(props);
348
- const modelValue = getGroupOrLocalRef("modelValue", props, emit);
349
- const not = getGroupOrLocalRef("not", props);
350
- const collapse = getGroupOrLocalRef("collapse", props);
351
347
  const disabled = computed(
352
- () => {
353
- var _a;
354
- return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
355
- }
348
+ () => Boolean(props.disabled || (group == null ? void 0 : group.disabled.value))
356
349
  );
357
350
  const modifiers = computed(() => {
358
351
  let localModifiers = props.modifiers;
359
- let groupModifiers = group == null ? void 0 : group.value.modifiers.value;
352
+ let groupModifiers = group == null ? void 0 : group.modifiers.value;
360
353
  const toReturn = /* @__PURE__ */ new Set();
361
354
  if (localModifiers) {
362
355
  if (!Array.isArray(localModifiers)) {
@@ -374,16 +367,11 @@ function useGroupProps(props, emit) {
374
367
  });
375
368
  return {
376
369
  // group props
377
- modelValue,
378
- not,
379
370
  isInGroup,
380
371
  group,
381
- collapse,
382
372
  modifiers,
383
373
  disabled,
384
- // local props
385
- title,
386
- content
374
+ bus: group == null ? void 0 : group.bus
387
375
  };
388
376
  }
389
377
  function useModifiers(prefix, modifiers, others) {
@@ -419,62 +407,103 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
419
407
  ...__default__,
420
408
  props: VvAccordionProps,
421
409
  emits: VvAccordionEvents,
422
- setup(__props, { emit: __emit }) {
410
+ setup(__props, { expose: __expose, emit: __emit }) {
423
411
  const props = __props;
424
412
  const attrs = useAttrs();
425
413
  const emit = __emit;
414
+ const modelValue = useVModel(props, "modelValue", emit);
426
415
  const accordionName = computed(
427
416
  () => props.name || (attrs == null ? void 0 : attrs.id) || uid()
428
417
  );
429
- const {
430
- modifiers,
431
- title,
432
- content,
433
- disabled,
434
- collapse,
418
+ const { title, content, not } = toRefs(props);
419
+ const { isInGroup, modifiers, disabled, bus } = useGroupProps(props);
420
+ const isExpanded = ref(false);
421
+ watch(
435
422
  modelValue,
436
- isInGroup,
437
- not
438
- } = useGroupProps(props, emit);
439
- const localModelValue = ref(false);
440
- const isOpen = computed({
441
- get: () => {
442
- let toReturn = modelValue.value;
443
- if (isInGroup.value) {
444
- if (collapse.value && Array.isArray(modelValue.value)) {
445
- toReturn = modelValue.value.includes(accordionName.value);
446
- } else {
447
- toReturn = modelValue.value === accordionName.value;
448
- }
449
- } else if (modelValue.value === void 0) {
450
- toReturn = localModelValue.value;
423
+ (newValue) => {
424
+ if (typeof newValue === "boolean") {
425
+ isExpanded.value = not.value ? !newValue : newValue;
451
426
  }
452
- return not.value ? !toReturn : toReturn;
453
427
  },
454
- set: (newValue) => {
455
- if (not.value) {
456
- newValue = !newValue;
457
- }
458
- if (isInGroup.value) {
459
- if (collapse.value && Array.isArray(modelValue.value)) {
460
- if (newValue) {
461
- modelValue.value.push(accordionName.value);
462
- return;
463
- }
464
- modelValue.value = modelValue.value.filter(
465
- (name) => name !== accordionName.value
466
- );
467
- return;
428
+ { immediate: true }
429
+ );
430
+ watch(isExpanded, (newValue) => {
431
+ modelValue.value = not.value ? !newValue : newValue;
432
+ });
433
+ bus == null ? void 0 : bus.on("toggle", ({ name, value }) => {
434
+ if (name !== accordionName.value) {
435
+ return;
436
+ }
437
+ isExpanded.value = value;
438
+ });
439
+ const onClick = () => {
440
+ if (disabled.value) {
441
+ return;
442
+ }
443
+ if (isInGroup.value) {
444
+ bus == null ? void 0 : bus.emit("toggle", {
445
+ name: accordionName.value,
446
+ value: !isExpanded.value
447
+ });
448
+ return;
449
+ }
450
+ isExpanded.value = !isExpanded.value;
451
+ };
452
+ watch(
453
+ accordionName,
454
+ (newValue, oldValue) => {
455
+ if (bus) {
456
+ if (oldValue && oldValue !== newValue) {
457
+ bus.emit("unregister", { name: oldValue });
468
458
  }
469
- modelValue.value = newValue ? accordionName.value : null;
470
- return;
459
+ bus.emit("register", { name: newValue });
471
460
  }
472
- if (modelValue.value === void 0 && typeof newValue === "boolean") {
473
- localModelValue.value = newValue;
474
- return;
475
- }
476
- modelValue.value = newValue;
461
+ },
462
+ {
463
+ immediate: true
464
+ }
465
+ );
466
+ onBeforeUnmount(() => {
467
+ if (bus) {
468
+ bus.emit("unregister", { name: accordionName.value });
469
+ }
470
+ });
471
+ const expand = () => {
472
+ if (isExpanded.value) {
473
+ return;
474
+ }
475
+ onClick();
476
+ };
477
+ const collapse = () => {
478
+ if (!isExpanded.value) {
479
+ return;
480
+ }
481
+ onClick();
482
+ };
483
+ const groupExpand = (name) => {
484
+ if (!bus) {
485
+ console.warn(
486
+ `[VvAccordion]: You are trying to expand accordion group of "${accordionName.value}" but it is not in a group`
487
+ );
488
+ return;
477
489
  }
490
+ bus.emit("expand", { name });
491
+ };
492
+ const groupCollapse = (name) => {
493
+ if (!bus) {
494
+ console.warn(
495
+ `[VvAccordion]: You are trying to collapse accordion group of "${accordionName.value}" but it is not in a group`
496
+ );
497
+ return;
498
+ }
499
+ bus == null ? void 0 : bus.emit("collapse", { name });
500
+ };
501
+ __expose({
502
+ isExpanded,
503
+ expand,
504
+ collapse,
505
+ groupExpand,
506
+ groupCollapse
478
507
  });
479
508
  const bemCssClasses = useModifiers(
480
509
  "vv-accordion",
@@ -483,20 +512,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
483
512
  disabled: disabled.value
484
513
  }))
485
514
  );
486
- const onClick = useToggle(isOpen);
487
515
  return (_ctx, _cache) => {
488
516
  return openBlock(), createElementBlock("details", {
489
517
  id: unref(accordionName),
490
518
  class: normalizeClass(unref(bemCssClasses)),
491
- open: unref(isOpen)
519
+ open: unref(isExpanded)
492
520
  }, [
493
521
  createElementVNode("summary", {
494
522
  "aria-controls": unref(accordionName),
495
- "aria-expanded": unref(isOpen),
523
+ "aria-expanded": unref(isExpanded),
496
524
  class: "vv-accordion__summary",
497
- onClick: _cache[0] || (_cache[0] = withModifiers(($event) => unref(onClick)(), ["prevent"]))
525
+ onClick: _cache[0] || (_cache[0] = withModifiers(($event) => onClick(), ["prevent"]))
498
526
  }, [
499
- renderSlot(_ctx.$slots, "summary", normalizeProps(guardReactiveProps({ open: unref(isOpen) })), () => [
527
+ renderSlot(_ctx.$slots, "summary", normalizeProps(guardReactiveProps({
528
+ isExpanded: unref(isExpanded),
529
+ expand,
530
+ collapse,
531
+ groupExpand,
532
+ groupCollapse
533
+ })), () => [
500
534
  createTextVNode(
501
535
  toDisplayString(unref(title)),
502
536
  1
@@ -505,10 +539,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
505
539
  ])
506
540
  ], 8, _hoisted_2),
507
541
  createElementVNode("div", {
508
- "aria-hidden": !unref(isOpen),
542
+ "aria-hidden": !unref(isExpanded),
509
543
  class: "vv-accordion__content"
510
544
  }, [
511
- renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ open: unref(isOpen) })), () => [
545
+ renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
546
+ isExpanded: unref(isExpanded),
547
+ expand,
548
+ collapse,
549
+ groupExpand,
550
+ groupCollapse
551
+ })), () => [
512
552
  createTextVNode(
513
553
  toDisplayString(unref(content)),
514
554
  1
@@ -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,t){"use strict";var r=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(r||{}),n=(e=>(e.before="before",e.after="after",e))(n||{}),u=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(u||{}),a=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(a||{});const l=Symbol.for("accordionGroup"),i=(Boolean,Boolean,Boolean,Boolean,{modifiers:{type:[String,Array],default:void 0}});function d(o){const t=e.inject(o,void 0),r=e.computed((()=>{return o=t,!(null==(r=e.unref(o))||""===r||Array.isArray(r)&&0===r.length||!(r instanceof Date)&&"object"==typeof r&&0===Object.keys(r).length);var o,r}));return{group:t,isInGroup:r,getGroupOrLocalRef:function(o,r,n){if(null==t?void 0:t.value){const r=e.unref(t.value)[o];return e.computed({get:()=>null==r?void 0:r.value,set(e){r.value=e}})}const u=e.toRef(r,o);return e.computed({get:()=>u.value,set(e){n&&n(`update:${o}`,e)}})}}}n.before,r.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,u.button,a.button;const s={...i,name:String,title:String,content:String,modelValue:{type:Boolean,default:void 0},disabled:Boolean,not:Boolean};const c=["id","open"],v=["aria-controls","aria-expanded"],f=["aria-hidden"];return e.defineComponent({name:"VvAccordion",props:s,emits:["update:modelValue"],setup(r,{emit:n}){const u=r,a=e.useAttrs(),i=n,s=e.computed((()=>u.name||(null==a?void 0:a.id)||o.uid())),{modifiers:p,title:m,content:y,disabled:b,collapse:g,modelValue:B,isInGroup:A,not:h}=function(o,t){const{group:r,isInGroup:n,getGroupOrLocalRef:u}=d(l),{title:a,content:i}=e.toRefs(o),s=u("modelValue",o,t),c=u("not",o),v=u("collapse",o),f=e.computed((()=>{var e;return Boolean(o.disabled||(null==(e=null==r?void 0:r.value)?void 0:e.disabled.value))})),p=e.computed((()=>{let e=o.modifiers,t=null==r?void 0:r.value.modifiers.value;const n=new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach((e=>n.add(e)))),t&&(Array.isArray(t)||(t=t.split(" ")),t.forEach((e=>n.add(e)))),Array.from(n)}));return{modelValue:s,not:c,isInGroup:n,group:r,collapse:v,modifiers:p,disabled:f,title:a,content:i}}(u,i),V=e.ref(!1),S=e.computed({get:()=>{let e=B.value;return A.value?e=g.value&&Array.isArray(B.value)?B.value.includes(s.value):B.value===s.value:void 0===B.value&&(e=V.value),h.value?!e:e},set:e=>{if(h.value&&(e=!e),A.value)return g.value&&Array.isArray(B.value)?e?void B.value.push(s.value):void(B.value=B.value.filter((e=>e!==s.value))):void(B.value=e?s.value:null);void 0!==B.value||"boolean"!=typeof e?B.value=e:V.value=e}}),k=function(o,t,r){return e.computed((()=>{const n={[o]:!0},u="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return u&&Array.isArray(u)&&u.forEach((e=>{e&&(n[`${o}--${e}`]=!0)})),r&&Object.keys(r.value).forEach((t=>{n[`${o}--${t}`]=e.unref(r.value[t])})),n}))}("vv-accordion",p,e.computed((()=>({disabled:b.value})))),x=t.useToggle(S);return(o,t)=>(e.openBlock(),e.createElementBlock("details",{id:e.unref(s),class:e.normalizeClass(e.unref(k)),open:e.unref(S)},[e.createElementVNode("summary",{"aria-controls":e.unref(s),"aria-expanded":e.unref(S),class:"vv-accordion__summary",onClick:t[0]||(t[0]=e.withModifiers((o=>e.unref(x)()),["prevent"]))},[e.renderSlot(o.$slots,"summary",e.normalizeProps(e.guardReactiveProps({open:e.unref(S)})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(m)),1)]))],8,v),e.createElementVNode("div",{"aria-hidden":!e.unref(S),class:"vv-accordion__content"},[e.renderSlot(o.$slots,"default",e.normalizeProps(e.guardReactiveProps({open:e.unref(S)})),(()=>[e.createTextVNode(e.toDisplayString(e.unref(y)),1)]))],8,f)],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.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))}})}));
@@ -12,7 +12,13 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
12
12
  type: globalThis.PropType<string | string[]>;
13
13
  default: undefined;
14
14
  };
15
- }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
15
+ }, {
16
+ isExpanded: globalThis.Ref<boolean>;
17
+ expand: () => void;
18
+ collapse: () => void;
19
+ groupExpand: (name?: string | string[]) => void;
20
+ groupCollapse: (name?: string | string[]) => void;
21
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
22
  [x: string]: (...args: any[]) => void;
17
23
  }, string, import("vue").PublicProps, Readonly<globalThis.ExtractPropTypes<{
18
24
  name: StringConstructor;
@@ -31,14 +37,22 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
31
37
  }>>, {
32
38
  disabled: boolean;
33
39
  modelValue: boolean;
34
- modifiers: string | string[];
35
40
  not: boolean;
41
+ modifiers: string | string[];
36
42
  }, {}>, {
37
43
  summary?(_: {
38
- open: boolean;
44
+ isExpanded: boolean;
45
+ expand: () => void;
46
+ collapse: () => void;
47
+ groupExpand: (name?: string | string[]) => void;
48
+ groupCollapse: (name?: string | string[]) => void;
39
49
  }): any;
40
50
  default?(_: {
41
- open: boolean;
51
+ isExpanded: boolean;
52
+ expand: () => void;
53
+ collapse: () => void;
54
+ groupExpand: (name?: string | string[]) => void;
55
+ groupCollapse: (name?: string | string[]) => void;
42
56
  }): any;
43
57
  }>;
44
58
  export default _default;
@@ -1,4 +1,4 @@
1
- import type { ExtractPropTypes, Ref } from 'vue';
1
+ import type { ExtractPropTypes } from 'vue';
2
2
  import type { AccordionGroupState } from '../../types/group';
3
3
  export declare const VvAccordionProps: {
4
4
  /**
@@ -38,14 +38,10 @@ export type VvAccordionPropsTypes = ExtractPropTypes<typeof VvAccordionProps>;
38
38
  /**
39
39
  * Merges local and group props
40
40
  */
41
- export declare function useGroupProps(props: VvAccordionPropsTypes, emit: (event: string, value: unknown) => void): {
42
- modelValue: globalThis.WritableComputedRef<any>;
43
- not: Ref<boolean>;
41
+ export declare function useGroupProps(props: VvAccordionPropsTypes): {
44
42
  isInGroup: globalThis.ComputedRef<boolean>;
45
- group: Ref<AccordionGroupState> | undefined;
46
- collapse: Ref<boolean>;
43
+ group: AccordionGroupState | undefined;
47
44
  modifiers: globalThis.ComputedRef<string[]>;
48
45
  disabled: globalThis.ComputedRef<boolean>;
49
- title: Ref<string | undefined> | undefined;
50
- content: Ref<string | undefined> | undefined;
46
+ bus: import("mitt").Emitter<import("../../types/group").AccordionGroupBusEvents> | undefined;
51
47
  };