@volverjs/ui-vue 0.0.10-beta.23 → 0.0.10-beta.25
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.
- package/dist/components/VvAccordion/VvAccordion.es.js +119 -79
- package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
- package/dist/components/VvAccordion/VvAccordion.vue.d.ts +18 -4
- package/dist/components/VvAccordion/index.d.ts +4 -8
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +282 -124
- package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +34 -7
- package/dist/components/VvAccordionGroup/index.d.ts +4 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +1 -1
- package/dist/components/VvAlert/VvAlert.vue.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +92 -98
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +7 -7
- package/dist/components/VvButton/index.d.ts +11 -11
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +7 -13
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +3 -3
- package/dist/components/VvCheckbox/VvCheckbox.es.js +81 -87
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +6 -6
- package/dist/components/VvCheckbox/index.d.ts +2 -2
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +15 -29
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +5 -5
- package/dist/components/VvCombobox/VvCombobox.es.js +13 -16
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +11 -11
- package/dist/components/VvCombobox/index.d.ts +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +5 -5
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +1 -1
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +1 -1
- package/dist/components/VvDropdown/index.d.ts +1 -1
- package/dist/components/VvInputFile/VvInputFile.es.js +183 -168
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/VvInputFile/VvInputFile.vue.d.ts +16 -9
- package/dist/components/VvInputFile/index.d.ts +12 -3
- package/dist/components/VvInputText/VvInputClearAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputStepAction.d.ts +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +6 -6
- package/dist/components/VvProgress/VvProgress.vue.d.ts +1 -1
- package/dist/components/VvRadio/VvRadio.es.js +64 -70
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +6 -6
- package/dist/components/VvRadio/index.d.ts +6 -6
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +15 -29
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +5 -5
- package/dist/components/VvSelect/VvSelect.vue.d.ts +8 -8
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +5 -5
- package/dist/components/VvTooltip/VvTooltip.vue.d.ts +3 -3
- package/dist/components/VvTooltip/index.d.ts +1 -1
- package/dist/components/index.es.js +494 -328
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useInjectAlert.d.ts +1 -6
- package/dist/composables/group/useInjectedGroupState.d.ts +4 -5
- package/dist/composables/group/useProvideGroupState.d.ts +3 -3
- package/dist/constants.d.ts +6 -10
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/index.es.js +3 -2
- package/dist/index.umd.js +1 -1
- package/dist/props/index.d.ts +1 -1
- package/dist/resolvers/unplugin.es.js +3 -2
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +58 -15
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +381 -107
- package/dist/types/group.d.ts +37 -15
- package/package.json +37 -36
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvAccordion/VvAccordion.vue +119 -56
- package/src/components/VvAccordion/index.ts +8 -23
- package/src/components/VvAccordionGroup/VvAccordionGroup.vue +164 -42
- package/src/components/VvAccordionGroup/index.ts +4 -1
- package/src/components/VvButton/index.ts +7 -12
- package/src/components/VvButtonGroup/VvButtonGroup.vue +1 -2
- package/src/components/VvCheckbox/index.ts +2 -2
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +1 -2
- package/src/components/VvInputFile/VvInputFile.vue +71 -47
- package/src/components/VvInputFile/index.ts +5 -4
- package/src/components/VvRadio/index.ts +5 -5
- package/src/components/VvRadioGroup/VvRadioGroup.vue +1 -2
- package/src/composables/group/useInjectedGroupState.ts +20 -16
- package/src/composables/group/useProvideGroupState.ts +10 -15
- package/src/constants.ts +19 -14
- package/src/stories/AccordionGroup/AccordionGroup.settings.ts +2 -2
- package/src/stories/AccordionGroup/AccordionGroup.test.ts +16 -10
- package/src/stories/AccordionGroup/AccordionGroupSlots.stories.ts +1 -1
- package/src/types/group.ts +22 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
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(
|
|
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(() =>
|
|
281
|
+
const isInGroup = computed(() => group !== void 0);
|
|
283
282
|
function getGroupOrLocalRef(propName, props, emit) {
|
|
284
|
-
|
|
285
|
-
|
|
283
|
+
const groupPropValue = group == null ? void 0 : group[propName];
|
|
284
|
+
if (groupPropValue) {
|
|
286
285
|
return computed({
|
|
287
286
|
get() {
|
|
288
|
-
return groupPropValue
|
|
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
|
|
344
|
-
const { group, isInGroup
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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
|
-
|
|
470
|
-
return;
|
|
459
|
+
bus.emit("register", { name: newValue });
|
|
471
460
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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(
|
|
519
|
+
open: unref(isExpanded)
|
|
492
520
|
}, [
|
|
493
521
|
createElementVNode("summary", {
|
|
494
522
|
"aria-controls": unref(accordionName),
|
|
495
|
-
"aria-expanded": unref(
|
|
523
|
+
"aria-expanded": unref(isExpanded),
|
|
496
524
|
class: "vv-accordion__summary",
|
|
497
|
-
onClick: _cache[0] || (_cache[0] = withModifiers(($event) =>
|
|
525
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => onClick(), ["prevent"]))
|
|
498
526
|
}, [
|
|
499
|
-
renderSlot(_ctx.$slots, "summary", normalizeProps(guardReactiveProps({
|
|
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(
|
|
542
|
+
"aria-hidden": !unref(isExpanded),
|
|
509
543
|
class: "vv-accordion__content"
|
|
510
544
|
}, [
|
|
511
|
-
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
|
|
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,
|
|
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
|
-
}, {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
42
|
-
modelValue: globalThis.WritableComputedRef<any>;
|
|
43
|
-
not: Ref<boolean>;
|
|
41
|
+
export declare function useGroupProps(props: VvAccordionPropsTypes): {
|
|
44
42
|
isInGroup: globalThis.ComputedRef<boolean>;
|
|
45
|
-
group:
|
|
46
|
-
collapse: Ref<boolean>;
|
|
43
|
+
group: AccordionGroupState | undefined;
|
|
47
44
|
modifiers: globalThis.ComputedRef<string[]>;
|
|
48
45
|
disabled: globalThis.ComputedRef<boolean>;
|
|
49
|
-
|
|
50
|
-
content: Ref<string | undefined> | undefined;
|
|
46
|
+
bus: import("mitt").Emitter<import("../../types/group").AccordionGroupBusEvents> | undefined;
|
|
51
47
|
};
|