@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,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
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, onMounted, nextTick, Fragment, renderList, createBlock, mergeProps, createSlots, withCtx, resolveDynamicComponent, mergeDefaults, createCommentVNode, createVNode, TransitionGroup, toHandlers, useSlots, isRef, h, withDirectives, vModelCheckbox, Transition, normalizeStyle, vShow, vModelSelect, vModelText, vModelRadio } from "vue";
|
|
2
2
|
import { uid } from "uid";
|
|
3
|
-
import {
|
|
4
|
-
import { iconExists, Icon, addIcon } from "@iconify/vue";
|
|
3
|
+
import { useVModel, useLocalStorage, useMutationObserver, onClickOutside, useFocusWithin, onKeyStroke, useElementHover, useFocus, useElementVisibility, refDebounced, computedAsync } from "@vueuse/core";
|
|
5
4
|
import mitt from "mitt";
|
|
5
|
+
import { iconExists, Icon, addIcon } from "@iconify/vue";
|
|
6
6
|
import { get } from "ts-dot-prop";
|
|
7
7
|
import { autoPlacement, flip, shift, size, offset, arrow, useFloating, autoUpdate } from "@floating-ui/vue";
|
|
8
8
|
import { useIMask } from "vue-imask";
|
|
9
|
+
import Sortable from "vuedraggable";
|
|
9
10
|
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
10
11
|
Strategy2["absolute"] = "absolute";
|
|
11
12
|
Strategy2["fixed"] = "fixed";
|
|
@@ -71,10 +72,18 @@ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
|
|
|
71
72
|
return AnchorTarget2;
|
|
72
73
|
})(AnchorTarget || {});
|
|
73
74
|
const INJECTION_KEY_VOLVER = Symbol.for("volver");
|
|
74
|
-
const INJECTION_KEY_BUTTON_GROUP = Symbol.for(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
75
|
+
const INJECTION_KEY_BUTTON_GROUP = Symbol.for(
|
|
76
|
+
"buttonGroup"
|
|
77
|
+
);
|
|
78
|
+
const INJECTION_KEY_RADIO_GROUP = Symbol.for(
|
|
79
|
+
"radioGroup"
|
|
80
|
+
);
|
|
81
|
+
const INJECTION_KEY_CHECK_GROUP = Symbol.for(
|
|
82
|
+
"checkGroup"
|
|
83
|
+
);
|
|
84
|
+
const INJECTION_KEY_ACCORDION_GROUP = Symbol.for(
|
|
85
|
+
"accordionGroup"
|
|
86
|
+
);
|
|
78
87
|
const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
|
|
79
88
|
"dropdownTrigger"
|
|
80
89
|
);
|
|
@@ -580,120 +589,15 @@ const NavProps = {
|
|
|
580
589
|
default: () => []
|
|
581
590
|
}
|
|
582
591
|
};
|
|
583
|
-
function equals(obj1, obj2, field) {
|
|
584
|
-
if (field) {
|
|
585
|
-
return resolveFieldData(obj1, field) === resolveFieldData(obj2, field);
|
|
586
|
-
}
|
|
587
|
-
return deepEquals(obj1, obj2);
|
|
588
|
-
}
|
|
589
|
-
function deepEquals(a, b) {
|
|
590
|
-
if (a === b)
|
|
591
|
-
return true;
|
|
592
|
-
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
593
|
-
const arrA = Array.isArray(a);
|
|
594
|
-
const arrB = Array.isArray(b);
|
|
595
|
-
let i, length, key;
|
|
596
|
-
if (arrA && arrB) {
|
|
597
|
-
length = a.length;
|
|
598
|
-
if (length != b.length)
|
|
599
|
-
return false;
|
|
600
|
-
for (i = length; i-- !== 0; )
|
|
601
|
-
if (!deepEquals(a[i], b[i]))
|
|
602
|
-
return false;
|
|
603
|
-
return true;
|
|
604
|
-
}
|
|
605
|
-
if (arrA != arrB)
|
|
606
|
-
return false;
|
|
607
|
-
const dateA = a instanceof Date, dateB = b instanceof Date;
|
|
608
|
-
if (dateA != dateB)
|
|
609
|
-
return false;
|
|
610
|
-
if (dateA && dateB)
|
|
611
|
-
return a.getTime() == b.getTime();
|
|
612
|
-
const regexpA = a instanceof RegExp, regexpB = b instanceof RegExp;
|
|
613
|
-
if (regexpA != regexpB)
|
|
614
|
-
return false;
|
|
615
|
-
if (regexpA && regexpB)
|
|
616
|
-
return a.toString() == b.toString();
|
|
617
|
-
const keys = Object.keys(a);
|
|
618
|
-
length = keys.length;
|
|
619
|
-
if (length !== Object.keys(b).length)
|
|
620
|
-
return false;
|
|
621
|
-
for (i = length; i-- !== 0; )
|
|
622
|
-
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
623
|
-
return false;
|
|
624
|
-
for (i = length; i-- !== 0; ) {
|
|
625
|
-
key = keys[i];
|
|
626
|
-
if (!deepEquals(a[key], b[key]))
|
|
627
|
-
return false;
|
|
628
|
-
}
|
|
629
|
-
return true;
|
|
630
|
-
}
|
|
631
|
-
return a !== a && b !== b;
|
|
632
|
-
}
|
|
633
|
-
function resolveFieldData(data, field) {
|
|
634
|
-
if (data && Object.keys(data).length && field) {
|
|
635
|
-
if (field.indexOf(".") === -1) {
|
|
636
|
-
return data[field];
|
|
637
|
-
} else {
|
|
638
|
-
const fields = field.split(".");
|
|
639
|
-
let value = data;
|
|
640
|
-
for (let i = 0, len = fields.length; i < len; ++i) {
|
|
641
|
-
if (data == null) {
|
|
642
|
-
return null;
|
|
643
|
-
}
|
|
644
|
-
value = value[fields[i]];
|
|
645
|
-
}
|
|
646
|
-
return value;
|
|
647
|
-
}
|
|
648
|
-
} else {
|
|
649
|
-
return null;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
function findIndexInList(value, list) {
|
|
653
|
-
let index = -1;
|
|
654
|
-
if (list) {
|
|
655
|
-
for (let i = 0; i < list.length; i++) {
|
|
656
|
-
if (equals(list[i], value)) {
|
|
657
|
-
index = i;
|
|
658
|
-
break;
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
return index;
|
|
663
|
-
}
|
|
664
|
-
function contains(value, list) {
|
|
665
|
-
if (value != null && list && list.length) {
|
|
666
|
-
for (const val of list) {
|
|
667
|
-
if (equals(value, val)) {
|
|
668
|
-
return true;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
return false;
|
|
673
|
-
}
|
|
674
|
-
function isEmpty(value) {
|
|
675
|
-
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));
|
|
676
|
-
}
|
|
677
|
-
function removeFromList(value, list) {
|
|
678
|
-
const indexElToRemove = findIndexInList(value, list);
|
|
679
|
-
if (indexElToRemove > -1) {
|
|
680
|
-
return list.filter((el, elIndex) => elIndex !== indexElToRemove);
|
|
681
|
-
} else {
|
|
682
|
-
return list;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
function isString(value) {
|
|
686
|
-
return typeof value === "string" || value instanceof String;
|
|
687
|
-
}
|
|
688
592
|
function useInjectedGroupState(groupKey) {
|
|
689
593
|
const group = inject(groupKey, void 0);
|
|
690
|
-
const isInGroup = computed(() =>
|
|
594
|
+
const isInGroup = computed(() => group !== void 0);
|
|
691
595
|
function getGroupOrLocalRef(propName, props, emit) {
|
|
692
|
-
|
|
693
|
-
|
|
596
|
+
const groupPropValue = group == null ? void 0 : group[propName];
|
|
597
|
+
if (groupPropValue) {
|
|
694
598
|
return computed({
|
|
695
599
|
get() {
|
|
696
|
-
return groupPropValue
|
|
600
|
+
return groupPropValue.value;
|
|
697
601
|
},
|
|
698
602
|
set(value) {
|
|
699
603
|
groupPropValue.value = value;
|
|
@@ -706,8 +610,9 @@ function useInjectedGroupState(groupKey) {
|
|
|
706
610
|
return propRef.value;
|
|
707
611
|
},
|
|
708
612
|
set(value) {
|
|
709
|
-
if (emit)
|
|
613
|
+
if (emit) {
|
|
710
614
|
emit(`update:${propName}`, value);
|
|
615
|
+
}
|
|
711
616
|
}
|
|
712
617
|
});
|
|
713
618
|
}
|
|
@@ -748,23 +653,16 @@ const VvAccordionProps = {
|
|
|
748
653
|
not: Boolean
|
|
749
654
|
};
|
|
750
655
|
const VvAccordionEvents = ["update:modelValue"];
|
|
751
|
-
function useGroupProps$3(props
|
|
752
|
-
const { group, isInGroup
|
|
656
|
+
function useGroupProps$3(props) {
|
|
657
|
+
const { group, isInGroup } = useInjectedGroupState(
|
|
753
658
|
INJECTION_KEY_ACCORDION_GROUP
|
|
754
659
|
);
|
|
755
|
-
const { title, content } = toRefs(props);
|
|
756
|
-
const modelValue = getGroupOrLocalRef("modelValue", props, emit);
|
|
757
|
-
const not = getGroupOrLocalRef("not", props);
|
|
758
|
-
const collapse = getGroupOrLocalRef("collapse", props);
|
|
759
660
|
const disabled = computed(
|
|
760
|
-
() =>
|
|
761
|
-
var _a;
|
|
762
|
-
return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
|
|
763
|
-
}
|
|
661
|
+
() => Boolean(props.disabled || (group == null ? void 0 : group.disabled.value))
|
|
764
662
|
);
|
|
765
663
|
const modifiers = computed(() => {
|
|
766
664
|
let localModifiers = props.modifiers;
|
|
767
|
-
let groupModifiers = group == null ? void 0 : group.
|
|
665
|
+
let groupModifiers = group == null ? void 0 : group.modifiers.value;
|
|
768
666
|
const toReturn = /* @__PURE__ */ new Set();
|
|
769
667
|
if (localModifiers) {
|
|
770
668
|
if (!Array.isArray(localModifiers)) {
|
|
@@ -782,16 +680,11 @@ function useGroupProps$3(props, emit) {
|
|
|
782
680
|
});
|
|
783
681
|
return {
|
|
784
682
|
// group props
|
|
785
|
-
modelValue,
|
|
786
|
-
not,
|
|
787
683
|
isInGroup,
|
|
788
684
|
group,
|
|
789
|
-
collapse,
|
|
790
685
|
modifiers,
|
|
791
686
|
disabled,
|
|
792
|
-
|
|
793
|
-
title,
|
|
794
|
-
content
|
|
687
|
+
bus: group == null ? void 0 : group.bus
|
|
795
688
|
};
|
|
796
689
|
}
|
|
797
690
|
function useModifiers(prefix, modifiers, others) {
|
|
@@ -827,62 +720,103 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
827
720
|
...__default__$r,
|
|
828
721
|
props: VvAccordionProps,
|
|
829
722
|
emits: VvAccordionEvents,
|
|
830
|
-
setup(__props, { emit: __emit }) {
|
|
723
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
831
724
|
const props = __props;
|
|
832
725
|
const attrs = useAttrs();
|
|
833
726
|
const emit = __emit;
|
|
727
|
+
const modelValue = useVModel(props, "modelValue", emit);
|
|
834
728
|
const accordionName = computed(
|
|
835
729
|
() => props.name || (attrs == null ? void 0 : attrs.id) || uid()
|
|
836
730
|
);
|
|
837
|
-
const {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
disabled,
|
|
842
|
-
collapse,
|
|
731
|
+
const { title, content, not } = toRefs(props);
|
|
732
|
+
const { isInGroup, modifiers, disabled, bus } = useGroupProps$3(props);
|
|
733
|
+
const isExpanded = ref(false);
|
|
734
|
+
watch(
|
|
843
735
|
modelValue,
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
const localModelValue = ref(false);
|
|
848
|
-
const isOpen = computed({
|
|
849
|
-
get: () => {
|
|
850
|
-
let toReturn = modelValue.value;
|
|
851
|
-
if (isInGroup.value) {
|
|
852
|
-
if (collapse.value && Array.isArray(modelValue.value)) {
|
|
853
|
-
toReturn = modelValue.value.includes(accordionName.value);
|
|
854
|
-
} else {
|
|
855
|
-
toReturn = modelValue.value === accordionName.value;
|
|
856
|
-
}
|
|
857
|
-
} else if (modelValue.value === void 0) {
|
|
858
|
-
toReturn = localModelValue.value;
|
|
736
|
+
(newValue) => {
|
|
737
|
+
if (typeof newValue === "boolean") {
|
|
738
|
+
isExpanded.value = not.value ? !newValue : newValue;
|
|
859
739
|
}
|
|
860
|
-
return not.value ? !toReturn : toReturn;
|
|
861
740
|
},
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
741
|
+
{ immediate: true }
|
|
742
|
+
);
|
|
743
|
+
watch(isExpanded, (newValue) => {
|
|
744
|
+
modelValue.value = not.value ? !newValue : newValue;
|
|
745
|
+
});
|
|
746
|
+
bus == null ? void 0 : bus.on("toggle", ({ name, value }) => {
|
|
747
|
+
if (name !== accordionName.value) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
isExpanded.value = value;
|
|
751
|
+
});
|
|
752
|
+
const onClick = () => {
|
|
753
|
+
if (disabled.value) {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
if (isInGroup.value) {
|
|
757
|
+
bus == null ? void 0 : bus.emit("toggle", {
|
|
758
|
+
name: accordionName.value,
|
|
759
|
+
value: !isExpanded.value
|
|
760
|
+
});
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
isExpanded.value = !isExpanded.value;
|
|
764
|
+
};
|
|
765
|
+
watch(
|
|
766
|
+
accordionName,
|
|
767
|
+
(newValue, oldValue) => {
|
|
768
|
+
if (bus) {
|
|
769
|
+
if (oldValue && oldValue !== newValue) {
|
|
770
|
+
bus.emit("unregister", { name: oldValue });
|
|
876
771
|
}
|
|
877
|
-
|
|
878
|
-
return;
|
|
772
|
+
bus.emit("register", { name: newValue });
|
|
879
773
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
}
|
|
884
|
-
modelValue.value = newValue;
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
immediate: true
|
|
885
777
|
}
|
|
778
|
+
);
|
|
779
|
+
onBeforeUnmount(() => {
|
|
780
|
+
if (bus) {
|
|
781
|
+
bus.emit("unregister", { name: accordionName.value });
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
const expand = () => {
|
|
785
|
+
if (isExpanded.value) {
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
onClick();
|
|
789
|
+
};
|
|
790
|
+
const collapse = () => {
|
|
791
|
+
if (!isExpanded.value) {
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
onClick();
|
|
795
|
+
};
|
|
796
|
+
const groupExpand = (name) => {
|
|
797
|
+
if (!bus) {
|
|
798
|
+
console.warn(
|
|
799
|
+
`[VvAccordion]: You are trying to expand accordion group of "${accordionName.value}" but it is not in a group`
|
|
800
|
+
);
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
bus.emit("expand", { name });
|
|
804
|
+
};
|
|
805
|
+
const groupCollapse = (name) => {
|
|
806
|
+
if (!bus) {
|
|
807
|
+
console.warn(
|
|
808
|
+
`[VvAccordion]: You are trying to collapse accordion group of "${accordionName.value}" but it is not in a group`
|
|
809
|
+
);
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
bus == null ? void 0 : bus.emit("collapse", { name });
|
|
813
|
+
};
|
|
814
|
+
__expose({
|
|
815
|
+
isExpanded,
|
|
816
|
+
expand,
|
|
817
|
+
collapse,
|
|
818
|
+
groupExpand,
|
|
819
|
+
groupCollapse
|
|
886
820
|
});
|
|
887
821
|
const bemCssClasses = useModifiers(
|
|
888
822
|
"vv-accordion",
|
|
@@ -891,20 +825,25 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
891
825
|
disabled: disabled.value
|
|
892
826
|
}))
|
|
893
827
|
);
|
|
894
|
-
const onClick = useToggle(isOpen);
|
|
895
828
|
return (_ctx, _cache) => {
|
|
896
829
|
return openBlock(), createElementBlock("details", {
|
|
897
830
|
id: unref(accordionName),
|
|
898
831
|
class: normalizeClass(unref(bemCssClasses)),
|
|
899
|
-
open: unref(
|
|
832
|
+
open: unref(isExpanded)
|
|
900
833
|
}, [
|
|
901
834
|
createElementVNode("summary", {
|
|
902
835
|
"aria-controls": unref(accordionName),
|
|
903
|
-
"aria-expanded": unref(
|
|
836
|
+
"aria-expanded": unref(isExpanded),
|
|
904
837
|
class: "vv-accordion__summary",
|
|
905
|
-
onClick: _cache[0] || (_cache[0] = withModifiers(($event) =>
|
|
838
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => onClick(), ["prevent"]))
|
|
906
839
|
}, [
|
|
907
|
-
renderSlot(_ctx.$slots, "summary", normalizeProps(guardReactiveProps({
|
|
840
|
+
renderSlot(_ctx.$slots, "summary", normalizeProps(guardReactiveProps({
|
|
841
|
+
isExpanded: unref(isExpanded),
|
|
842
|
+
expand,
|
|
843
|
+
collapse,
|
|
844
|
+
groupExpand,
|
|
845
|
+
groupCollapse
|
|
846
|
+
})), () => [
|
|
908
847
|
createTextVNode(
|
|
909
848
|
toDisplayString(unref(title)),
|
|
910
849
|
1
|
|
@@ -913,10 +852,16 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
913
852
|
])
|
|
914
853
|
], 8, _hoisted_2$f),
|
|
915
854
|
createElementVNode("div", {
|
|
916
|
-
"aria-hidden": !unref(
|
|
855
|
+
"aria-hidden": !unref(isExpanded),
|
|
917
856
|
class: "vv-accordion__content"
|
|
918
857
|
}, [
|
|
919
|
-
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
|
|
858
|
+
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
|
|
859
|
+
isExpanded: unref(isExpanded),
|
|
860
|
+
expand,
|
|
861
|
+
collapse,
|
|
862
|
+
groupExpand,
|
|
863
|
+
groupCollapse
|
|
864
|
+
})), () => [
|
|
920
865
|
createTextVNode(
|
|
921
866
|
toDisplayString(unref(content)),
|
|
922
867
|
1
|
|
@@ -933,7 +878,10 @@ const VvAccordionGroupProps = {
|
|
|
933
878
|
/**
|
|
934
879
|
* VModel
|
|
935
880
|
*/
|
|
936
|
-
modelValue:
|
|
881
|
+
modelValue: {
|
|
882
|
+
type: [String, Array],
|
|
883
|
+
default: void 0
|
|
884
|
+
},
|
|
937
885
|
/**
|
|
938
886
|
* Accordion items
|
|
939
887
|
* @type VvAccordionGroupItem
|
|
@@ -967,15 +915,8 @@ const VvAccordionGroupProps = {
|
|
|
967
915
|
storeKey: String
|
|
968
916
|
};
|
|
969
917
|
const VvAccordionGroupEvents = ["update:modelValue"];
|
|
970
|
-
function useProvideGroupState(groupState) {
|
|
971
|
-
|
|
972
|
-
(k) => k !== "key" && !isRef(groupState[k])
|
|
973
|
-
))
|
|
974
|
-
throw Error("One or more groupState props aren't ref.");
|
|
975
|
-
provide(
|
|
976
|
-
groupState.key,
|
|
977
|
-
computed(() => groupState)
|
|
978
|
-
);
|
|
918
|
+
function useProvideGroupState(key, groupState) {
|
|
919
|
+
provide(key, groupState);
|
|
979
920
|
}
|
|
980
921
|
const __default__$q = {
|
|
981
922
|
name: "VvAccordionGroup"
|
|
@@ -984,58 +925,166 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
984
925
|
...__default__$q,
|
|
985
926
|
props: VvAccordionGroupProps,
|
|
986
927
|
emits: VvAccordionGroupEvents,
|
|
987
|
-
setup(__props, { emit: __emit }) {
|
|
928
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
988
929
|
const props = __props;
|
|
989
930
|
const emit = __emit;
|
|
990
|
-
const { disabled,
|
|
931
|
+
const { disabled, modifiers, itemModifiers, items } = toRefs(props);
|
|
991
932
|
watchEffect(() => {
|
|
992
|
-
if (typeof props.modelValue === "string" && collapse
|
|
933
|
+
if (typeof props.modelValue === "string" && props.collapse) {
|
|
993
934
|
console.warn(
|
|
994
935
|
`[VvAccordionGroup]: modelValue is a string but collapse is true.`
|
|
995
936
|
);
|
|
996
937
|
}
|
|
997
938
|
});
|
|
998
|
-
|
|
939
|
+
const accordionNames = reactive(/* @__PURE__ */ new Set());
|
|
940
|
+
let storeModelValue = ref();
|
|
999
941
|
watch(
|
|
1000
942
|
() => props.storeKey,
|
|
1001
|
-
(newKey) => {
|
|
943
|
+
(newKey, oldKey) => {
|
|
944
|
+
if (oldKey && oldKey !== newKey) {
|
|
945
|
+
localStorage.removeItem(oldKey);
|
|
946
|
+
}
|
|
1002
947
|
if (newKey) {
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
localModelValue = ref([]);
|
|
948
|
+
storeModelValue = useLocalStorage(newKey, storeModelValue.value);
|
|
949
|
+
return;
|
|
1006
950
|
}
|
|
951
|
+
storeModelValue = ref(storeModelValue.value);
|
|
1007
952
|
},
|
|
1008
|
-
{
|
|
953
|
+
{
|
|
954
|
+
immediate: true
|
|
955
|
+
}
|
|
1009
956
|
);
|
|
1010
|
-
const
|
|
957
|
+
const localModelValue = computed({
|
|
1011
958
|
get: () => {
|
|
1012
|
-
|
|
1013
|
-
if (props.modelValue !== void 0) {
|
|
1014
|
-
if (!collapse.value) {
|
|
1015
|
-
return Array.isArray(props.modelValue) ? props.modelValue[0] : props.modelValue;
|
|
1016
|
-
}
|
|
959
|
+
if (props.modelValue !== null && props.modelValue !== void 0) {
|
|
1017
960
|
return props.modelValue;
|
|
1018
961
|
}
|
|
1019
|
-
return
|
|
962
|
+
return storeModelValue.value;
|
|
1020
963
|
},
|
|
1021
964
|
set: (newValue) => {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
965
|
+
emit("update:modelValue", newValue);
|
|
966
|
+
storeModelValue.value = newValue;
|
|
967
|
+
}
|
|
968
|
+
});
|
|
969
|
+
const expandedAccordions = computed({
|
|
970
|
+
get: () => {
|
|
971
|
+
if (localModelValue.value === void 0) {
|
|
972
|
+
return /* @__PURE__ */ new Set();
|
|
973
|
+
}
|
|
974
|
+
let toReturn = /* @__PURE__ */ new Set();
|
|
975
|
+
if (props.not) {
|
|
976
|
+
if (typeof localModelValue.value === "string") {
|
|
977
|
+
toReturn = new Set(
|
|
978
|
+
[...accordionNames].filter(
|
|
979
|
+
(name) => name !== localModelValue.value
|
|
980
|
+
)
|
|
981
|
+
);
|
|
982
|
+
} else if (Array.isArray(localModelValue.value)) {
|
|
983
|
+
toReturn = new Set(
|
|
984
|
+
[...accordionNames].filter(
|
|
985
|
+
(name) => !localModelValue.value.includes(
|
|
986
|
+
name
|
|
987
|
+
)
|
|
988
|
+
)
|
|
989
|
+
);
|
|
1025
990
|
}
|
|
1026
|
-
|
|
991
|
+
} else if (typeof localModelValue.value === "string") {
|
|
992
|
+
toReturn = /* @__PURE__ */ new Set([localModelValue.value]);
|
|
993
|
+
} else if (Array.isArray(localModelValue.value)) {
|
|
994
|
+
toReturn = new Set(localModelValue.value);
|
|
995
|
+
}
|
|
996
|
+
return toReturn;
|
|
997
|
+
},
|
|
998
|
+
set: (newValue) => {
|
|
999
|
+
if (props.not) {
|
|
1000
|
+
localModelValue.value = [...accordionNames].filter(
|
|
1001
|
+
(name) => !newValue.has(name)
|
|
1002
|
+
);
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
if (props.collapse) {
|
|
1006
|
+
localModelValue.value = [...newValue];
|
|
1007
|
+
return;
|
|
1027
1008
|
}
|
|
1028
|
-
localModelValue.value =
|
|
1009
|
+
localModelValue.value = newValue.values().next().value;
|
|
1029
1010
|
}
|
|
1030
1011
|
});
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1012
|
+
onMounted(() => {
|
|
1013
|
+
if (props.not && localModelValue.value === void 0) {
|
|
1014
|
+
localModelValue.value = props.collapse ? [] : [...accordionNames.values()].splice(1, accordionNames.size);
|
|
1015
|
+
}
|
|
1016
|
+
nextTick(() => {
|
|
1017
|
+
for (const name of accordionNames) {
|
|
1018
|
+
bus.emit("toggle", {
|
|
1019
|
+
name,
|
|
1020
|
+
value: expandedAccordions.value.has(name)
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
});
|
|
1025
|
+
const bus = mitt();
|
|
1026
|
+
useProvideGroupState(INJECTION_KEY_ACCORDION_GROUP, {
|
|
1034
1027
|
disabled,
|
|
1035
|
-
collapse,
|
|
1036
1028
|
modifiers: itemModifiers,
|
|
1037
|
-
|
|
1029
|
+
bus
|
|
1030
|
+
});
|
|
1031
|
+
bus.on("register", ({ name }) => {
|
|
1032
|
+
accordionNames.add(name);
|
|
1033
|
+
});
|
|
1034
|
+
bus.on("unregister", ({ name }) => {
|
|
1035
|
+
accordionNames.delete(name);
|
|
1038
1036
|
});
|
|
1037
|
+
bus.on("toggle", ({ name, value }) => {
|
|
1038
|
+
const newValue = new Set(expandedAccordions.value);
|
|
1039
|
+
if (value) {
|
|
1040
|
+
if (!props.collapse) {
|
|
1041
|
+
for (const item of newValue) {
|
|
1042
|
+
if (item !== name) {
|
|
1043
|
+
bus.emit("toggle", { name: item, value: false });
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
newValue.clear();
|
|
1047
|
+
}
|
|
1048
|
+
newValue.add(name);
|
|
1049
|
+
expandedAccordions.value = newValue;
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
newValue.delete(name);
|
|
1053
|
+
expandedAccordions.value = newValue;
|
|
1054
|
+
});
|
|
1055
|
+
const expand = (name) => {
|
|
1056
|
+
if (typeof name === "string") {
|
|
1057
|
+
bus.emit("toggle", { name, value: true });
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
if (Array.isArray(name)) {
|
|
1061
|
+
for (const item of name) {
|
|
1062
|
+
bus.emit("toggle", { name: item, value: true });
|
|
1063
|
+
}
|
|
1064
|
+
return;
|
|
1065
|
+
}
|
|
1066
|
+
for (const item of accordionNames) {
|
|
1067
|
+
bus.emit("toggle", { name: item, value: true });
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
bus.on("expand", ({ name }) => expand(name));
|
|
1071
|
+
const collapse = (name) => {
|
|
1072
|
+
if (typeof name === "string") {
|
|
1073
|
+
bus.emit("toggle", { name, value: false });
|
|
1074
|
+
return;
|
|
1075
|
+
}
|
|
1076
|
+
if (Array.isArray(name)) {
|
|
1077
|
+
for (const item of name) {
|
|
1078
|
+
bus.emit("toggle", { name: item, value: false });
|
|
1079
|
+
}
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
for (const item of accordionNames) {
|
|
1083
|
+
bus.emit("toggle", { name: item, value: false });
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
bus.on("collapse", ({ name }) => collapse(name));
|
|
1087
|
+
__expose({ expandedAccordions, expand, collapse });
|
|
1039
1088
|
const bemCssClasses = useModifiers(
|
|
1040
1089
|
"vv-accordion-group",
|
|
1041
1090
|
modifiers,
|
|
@@ -1050,7 +1099,11 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
1050
1099
|
class: normalizeClass(unref(bemCssClasses))
|
|
1051
1100
|
},
|
|
1052
1101
|
[
|
|
1053
|
-
renderSlot(_ctx.$slots, "default", {
|
|
1102
|
+
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
|
|
1103
|
+
expandedAccordions: unref(expandedAccordions),
|
|
1104
|
+
expand,
|
|
1105
|
+
collapse
|
|
1106
|
+
})), () => [
|
|
1054
1107
|
(openBlock(true), createElementBlock(
|
|
1055
1108
|
Fragment,
|
|
1056
1109
|
null,
|
|
@@ -1064,16 +1117,25 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
1064
1117
|
title: item.title,
|
|
1065
1118
|
content: item.content
|
|
1066
1119
|
}),
|
|
1067
|
-
{
|
|
1068
|
-
header: withCtx((data) => [
|
|
1069
|
-
renderSlot(_ctx.$slots, `header::${item.name}`, normalizeProps(guardReactiveProps(data)))
|
|
1070
|
-
]),
|
|
1071
|
-
details: withCtx((data) => [
|
|
1072
|
-
renderSlot(_ctx.$slots, `details::${item.name}`, normalizeProps(guardReactiveProps(data)))
|
|
1073
|
-
]),
|
|
1120
|
+
createSlots({
|
|
1074
1121
|
_: 2
|
|
1075
1122
|
/* DYNAMIC */
|
|
1076
|
-
},
|
|
1123
|
+
}, [
|
|
1124
|
+
_ctx.$slots[`summary::${item.name}`] ? {
|
|
1125
|
+
name: "summary",
|
|
1126
|
+
fn: withCtx((data) => [
|
|
1127
|
+
renderSlot(_ctx.$slots, `summary::${item.name}`, normalizeProps(guardReactiveProps(data)))
|
|
1128
|
+
]),
|
|
1129
|
+
key: "0"
|
|
1130
|
+
} : void 0,
|
|
1131
|
+
_ctx.$slots[`content::${item.name}`] ? {
|
|
1132
|
+
name: "default",
|
|
1133
|
+
fn: withCtx((data) => [
|
|
1134
|
+
renderSlot(_ctx.$slots, `content::${item.name}`, normalizeProps(guardReactiveProps(data)))
|
|
1135
|
+
]),
|
|
1136
|
+
key: "1"
|
|
1137
|
+
} : void 0
|
|
1138
|
+
]),
|
|
1077
1139
|
1040
|
|
1078
1140
|
/* FULL_PROPS, DYNAMIC_SLOTS */
|
|
1079
1141
|
);
|
|
@@ -2147,14 +2209,11 @@ function useGroupProps$2(props, emit) {
|
|
|
2147
2209
|
const { id, iconPosition, icon, label, pressed } = toRefs(props);
|
|
2148
2210
|
const modelValue = getGroupOrLocalRef("modelValue", props, emit);
|
|
2149
2211
|
const toggle = getGroupOrLocalRef("toggle", props);
|
|
2150
|
-
const unselectable = getGroupOrLocalRef(
|
|
2151
|
-
|
|
2152
|
-
props
|
|
2153
|
-
);
|
|
2154
|
-
const multiple = computed(() => (group == null ? void 0 : group.value.multiple.value) ?? false);
|
|
2212
|
+
const unselectable = getGroupOrLocalRef("unselectable", props);
|
|
2213
|
+
const multiple = computed(() => (group == null ? void 0 : group.multiple.value) ?? false);
|
|
2155
2214
|
const modifiers = computed(() => {
|
|
2156
2215
|
let localModifiers = props.modifiers;
|
|
2157
|
-
let groupModifiers = group == null ? void 0 : group.
|
|
2216
|
+
let groupModifiers = group == null ? void 0 : group.modifiers.value;
|
|
2158
2217
|
const toReturn = /* @__PURE__ */ new Set();
|
|
2159
2218
|
if (localModifiers) {
|
|
2160
2219
|
if (!Array.isArray(localModifiers)) {
|
|
@@ -2171,10 +2230,7 @@ function useGroupProps$2(props, emit) {
|
|
|
2171
2230
|
return Array.from(toReturn);
|
|
2172
2231
|
});
|
|
2173
2232
|
const disabled = computed(
|
|
2174
|
-
() =>
|
|
2175
|
-
var _a;
|
|
2176
|
-
return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
|
|
2177
|
-
}
|
|
2233
|
+
() => Boolean(props.disabled || (group == null ? void 0 : group.disabled.value))
|
|
2178
2234
|
);
|
|
2179
2235
|
return {
|
|
2180
2236
|
// group props
|
|
@@ -2194,6 +2250,111 @@ function useGroupProps$2(props, emit) {
|
|
|
2194
2250
|
label
|
|
2195
2251
|
};
|
|
2196
2252
|
}
|
|
2253
|
+
function equals(obj1, obj2, field) {
|
|
2254
|
+
if (field) {
|
|
2255
|
+
return resolveFieldData(obj1, field) === resolveFieldData(obj2, field);
|
|
2256
|
+
}
|
|
2257
|
+
return deepEquals(obj1, obj2);
|
|
2258
|
+
}
|
|
2259
|
+
function deepEquals(a, b) {
|
|
2260
|
+
if (a === b)
|
|
2261
|
+
return true;
|
|
2262
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
2263
|
+
const arrA = Array.isArray(a);
|
|
2264
|
+
const arrB = Array.isArray(b);
|
|
2265
|
+
let i, length, key;
|
|
2266
|
+
if (arrA && arrB) {
|
|
2267
|
+
length = a.length;
|
|
2268
|
+
if (length != b.length)
|
|
2269
|
+
return false;
|
|
2270
|
+
for (i = length; i-- !== 0; )
|
|
2271
|
+
if (!deepEquals(a[i], b[i]))
|
|
2272
|
+
return false;
|
|
2273
|
+
return true;
|
|
2274
|
+
}
|
|
2275
|
+
if (arrA != arrB)
|
|
2276
|
+
return false;
|
|
2277
|
+
const dateA = a instanceof Date, dateB = b instanceof Date;
|
|
2278
|
+
if (dateA != dateB)
|
|
2279
|
+
return false;
|
|
2280
|
+
if (dateA && dateB)
|
|
2281
|
+
return a.getTime() == b.getTime();
|
|
2282
|
+
const regexpA = a instanceof RegExp, regexpB = b instanceof RegExp;
|
|
2283
|
+
if (regexpA != regexpB)
|
|
2284
|
+
return false;
|
|
2285
|
+
if (regexpA && regexpB)
|
|
2286
|
+
return a.toString() == b.toString();
|
|
2287
|
+
const keys = Object.keys(a);
|
|
2288
|
+
length = keys.length;
|
|
2289
|
+
if (length !== Object.keys(b).length)
|
|
2290
|
+
return false;
|
|
2291
|
+
for (i = length; i-- !== 0; )
|
|
2292
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
2293
|
+
return false;
|
|
2294
|
+
for (i = length; i-- !== 0; ) {
|
|
2295
|
+
key = keys[i];
|
|
2296
|
+
if (!deepEquals(a[key], b[key]))
|
|
2297
|
+
return false;
|
|
2298
|
+
}
|
|
2299
|
+
return true;
|
|
2300
|
+
}
|
|
2301
|
+
return a !== a && b !== b;
|
|
2302
|
+
}
|
|
2303
|
+
function resolveFieldData(data, field) {
|
|
2304
|
+
if (data && Object.keys(data).length && field) {
|
|
2305
|
+
if (field.indexOf(".") === -1) {
|
|
2306
|
+
return data[field];
|
|
2307
|
+
} else {
|
|
2308
|
+
const fields = field.split(".");
|
|
2309
|
+
let value = data;
|
|
2310
|
+
for (let i = 0, len = fields.length; i < len; ++i) {
|
|
2311
|
+
if (data == null) {
|
|
2312
|
+
return null;
|
|
2313
|
+
}
|
|
2314
|
+
value = value[fields[i]];
|
|
2315
|
+
}
|
|
2316
|
+
return value;
|
|
2317
|
+
}
|
|
2318
|
+
} else {
|
|
2319
|
+
return null;
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
function findIndexInList(value, list) {
|
|
2323
|
+
let index = -1;
|
|
2324
|
+
if (list) {
|
|
2325
|
+
for (let i = 0; i < list.length; i++) {
|
|
2326
|
+
if (equals(list[i], value)) {
|
|
2327
|
+
index = i;
|
|
2328
|
+
break;
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
return index;
|
|
2333
|
+
}
|
|
2334
|
+
function contains(value, list) {
|
|
2335
|
+
if (value != null && list && list.length) {
|
|
2336
|
+
for (const val of list) {
|
|
2337
|
+
if (equals(value, val)) {
|
|
2338
|
+
return true;
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
return false;
|
|
2343
|
+
}
|
|
2344
|
+
function isEmpty(value) {
|
|
2345
|
+
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));
|
|
2346
|
+
}
|
|
2347
|
+
function removeFromList(value, list) {
|
|
2348
|
+
const indexElToRemove = findIndexInList(value, list);
|
|
2349
|
+
if (indexElToRemove > -1) {
|
|
2350
|
+
return list.filter((el, elIndex) => elIndex !== indexElToRemove);
|
|
2351
|
+
} else {
|
|
2352
|
+
return list;
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
function isString(value) {
|
|
2356
|
+
return typeof value === "string" || value instanceof String;
|
|
2357
|
+
}
|
|
2197
2358
|
const _hoisted_1$g = {
|
|
2198
2359
|
key: 1,
|
|
2199
2360
|
class: "vv-button__label"
|
|
@@ -2407,8 +2568,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
2407
2568
|
return emit("update:modelValue", newValue);
|
|
2408
2569
|
}
|
|
2409
2570
|
});
|
|
2410
|
-
useProvideGroupState({
|
|
2411
|
-
key: INJECTION_KEY_BUTTON_GROUP,
|
|
2571
|
+
useProvideGroupState(INJECTION_KEY_BUTTON_GROUP, {
|
|
2412
2572
|
modelValue,
|
|
2413
2573
|
disabled,
|
|
2414
2574
|
toggle,
|
|
@@ -2513,16 +2673,10 @@ function useGroupProps$1(props, emit) {
|
|
|
2513
2673
|
const valid = getGroupOrLocalRef("valid", props);
|
|
2514
2674
|
const invalid = getGroupOrLocalRef("invalid", props);
|
|
2515
2675
|
const readonly = computed(
|
|
2516
|
-
() =>
|
|
2517
|
-
var _a;
|
|
2518
|
-
return Boolean(props.readonly || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.readonly.value));
|
|
2519
|
-
}
|
|
2676
|
+
() => Boolean(props.readonly || (group == null ? void 0 : group.readonly.value))
|
|
2520
2677
|
);
|
|
2521
2678
|
const disabled = computed(
|
|
2522
|
-
() =>
|
|
2523
|
-
var _a;
|
|
2524
|
-
return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
|
|
2525
|
-
}
|
|
2679
|
+
() => Boolean(props.disabled || (group == null ? void 0 : group.disabled.value))
|
|
2526
2680
|
);
|
|
2527
2681
|
return {
|
|
2528
2682
|
// local props
|
|
@@ -2964,8 +3118,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2964
3118
|
);
|
|
2965
3119
|
const modelValue = useVModel(props, "modelValue", emit);
|
|
2966
3120
|
const { disabled, readonly, vertical, valid, invalid, modifiers } = toRefs(props);
|
|
2967
|
-
useProvideGroupState({
|
|
2968
|
-
key: INJECTION_KEY_CHECK_GROUP,
|
|
3121
|
+
useProvideGroupState(INJECTION_KEY_CHECK_GROUP, {
|
|
2969
3122
|
modelValue,
|
|
2970
3123
|
disabled,
|
|
2971
3124
|
readonly,
|
|
@@ -6221,16 +6374,10 @@ function useGroupProps(props, emit) {
|
|
|
6221
6374
|
const valid = getGroupOrLocalRef("valid", props);
|
|
6222
6375
|
const invalid = getGroupOrLocalRef("invalid", props);
|
|
6223
6376
|
const readonly = computed(
|
|
6224
|
-
() =>
|
|
6225
|
-
var _a;
|
|
6226
|
-
return Boolean(props.readonly || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.readonly.value));
|
|
6227
|
-
}
|
|
6377
|
+
() => Boolean(props.readonly || (group == null ? void 0 : group.readonly.value))
|
|
6228
6378
|
);
|
|
6229
6379
|
const disabled = computed(
|
|
6230
|
-
() =>
|
|
6231
|
-
var _a;
|
|
6232
|
-
return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
|
|
6233
|
-
}
|
|
6380
|
+
() => Boolean(props.disabled || (group == null ? void 0 : group.disabled.value))
|
|
6234
6381
|
);
|
|
6235
6382
|
return {
|
|
6236
6383
|
// local props
|
|
@@ -6405,8 +6552,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
6405
6552
|
);
|
|
6406
6553
|
const modelValue = useVModel(props, "modelValue", emit);
|
|
6407
6554
|
const { disabled, readonly, vertical, valid, invalid, modifiers } = toRefs(props);
|
|
6408
|
-
useProvideGroupState({
|
|
6409
|
-
key: INJECTION_KEY_RADIO_GROUP,
|
|
6555
|
+
useProvideGroupState(INJECTION_KEY_RADIO_GROUP, {
|
|
6410
6556
|
modelValue,
|
|
6411
6557
|
disabled,
|
|
6412
6558
|
readonly,
|
|
@@ -6967,8 +7113,7 @@ const VvInputFileProps = {
|
|
|
6967
7113
|
* Input value
|
|
6968
7114
|
*/
|
|
6969
7115
|
modelValue: {
|
|
6970
|
-
type: Object
|
|
6971
|
-
required: true
|
|
7116
|
+
type: Object
|
|
6972
7117
|
},
|
|
6973
7118
|
/**
|
|
6974
7119
|
* Whether to show progress bar
|
|
@@ -7012,6 +7157,10 @@ const VvInputFileProps = {
|
|
|
7012
7157
|
* Show drop area
|
|
7013
7158
|
*/
|
|
7014
7159
|
dropArea: { type: Boolean, default: false },
|
|
7160
|
+
/**
|
|
7161
|
+
* Enable sorting
|
|
7162
|
+
*/
|
|
7163
|
+
sortable: { type: Boolean, default: false },
|
|
7015
7164
|
/**
|
|
7016
7165
|
* Label for add button
|
|
7017
7166
|
*/
|
|
@@ -7071,12 +7220,11 @@ const _hoisted_3 = ["src", "alt"];
|
|
|
7071
7220
|
const _hoisted_4 = { class: "vv-input-file__wrapper" };
|
|
7072
7221
|
const _hoisted_5 = ["id", "readonly", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "capture", "name"];
|
|
7073
7222
|
const _hoisted_6 = ["value"];
|
|
7074
|
-
const _hoisted_7 =
|
|
7075
|
-
const _hoisted_8 = ["onClick"];
|
|
7076
|
-
const _hoisted_9 =
|
|
7077
|
-
const _hoisted_10 = { class: "vv-input-file__item-
|
|
7078
|
-
const _hoisted_11 =
|
|
7079
|
-
const _hoisted_12 = ["title", "onClick"];
|
|
7223
|
+
const _hoisted_7 = ["onClick"];
|
|
7224
|
+
const _hoisted_8 = ["title", "onClick"];
|
|
7225
|
+
const _hoisted_9 = { class: "vv-input-file__item-name" };
|
|
7226
|
+
const _hoisted_10 = { class: "vv-input-file__item-info" };
|
|
7227
|
+
const _hoisted_11 = ["title", "onClick"];
|
|
7080
7228
|
const __default__ = {
|
|
7081
7229
|
name: "VvInputFile"
|
|
7082
7230
|
};
|
|
@@ -7125,12 +7273,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7125
7273
|
hintSlotScope
|
|
7126
7274
|
} = HintSlotFactory(propsDefaults, slots);
|
|
7127
7275
|
const localModelValue = useVModel(props, "modelValue", emit);
|
|
7128
|
-
const files = computed(
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7276
|
+
const files = computed({
|
|
7277
|
+
get: () => {
|
|
7278
|
+
var _a;
|
|
7279
|
+
if (!localModelValue.value || !Array.isArray(localModelValue.value) && !((_a = localModelValue.value) == null ? void 0 : _a.name)) {
|
|
7280
|
+
return [];
|
|
7281
|
+
}
|
|
7282
|
+
return Array.isArray(localModelValue.value) ? localModelValue.value : [localModelValue.value];
|
|
7283
|
+
},
|
|
7284
|
+
set: (value) => {
|
|
7285
|
+
if (isMultiple.value) {
|
|
7286
|
+
localModelValue.value = value;
|
|
7287
|
+
return;
|
|
7288
|
+
}
|
|
7289
|
+
localModelValue.value = value == null ? void 0 : value[0];
|
|
7132
7290
|
}
|
|
7133
|
-
return Array.isArray(localModelValue.value) ? localModelValue.value : [localModelValue.value];
|
|
7134
7291
|
});
|
|
7135
7292
|
const hasMax = computed(() => {
|
|
7136
7293
|
return typeof props.max === "string" ? parseInt(props.max) : props.max;
|
|
@@ -7284,6 +7441,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7284
7441
|
}
|
|
7285
7442
|
return props.iconReplace;
|
|
7286
7443
|
});
|
|
7444
|
+
const onSortEnd = ({ newIndex }) => {
|
|
7445
|
+
if (newIndex !== null) {
|
|
7446
|
+
selectedFileIndex.value = newIndex;
|
|
7447
|
+
}
|
|
7448
|
+
};
|
|
7287
7449
|
return (_ctx, _cache) => {
|
|
7288
7450
|
return openBlock(), createElementBlock(
|
|
7289
7451
|
"div",
|
|
@@ -7370,60 +7532,64 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7370
7532
|
/* FULL_PROPS */
|
|
7371
7533
|
)) : createCommentVNode("v-if", true)
|
|
7372
7534
|
]),
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7535
|
+
createVNode(unref(Sortable), {
|
|
7536
|
+
modelValue: files.value,
|
|
7537
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => files.value = $event),
|
|
7538
|
+
tag: "ul",
|
|
7539
|
+
class: "vv-input-file__list",
|
|
7540
|
+
"item-key": "name",
|
|
7541
|
+
move: () => _ctx.sortable,
|
|
7542
|
+
onEnd: onSortEnd
|
|
7543
|
+
}, {
|
|
7544
|
+
item: withCtx(({ element: file, index }) => [
|
|
7545
|
+
createElementVNode("li", {
|
|
7546
|
+
class: normalizeClass(["vv-input-file__item", {
|
|
7547
|
+
active: index === selectedFileIndex.value && hasDropArea.value && files.value.length > 1,
|
|
7548
|
+
"cursor-move": _ctx.sortable
|
|
7549
|
+
}]),
|
|
7550
|
+
onClick: withModifiers(($event) => onClickSelectFile(index), ["stop"])
|
|
7551
|
+
}, [
|
|
7552
|
+
unref(hasIconDownload) ? (openBlock(), createElementBlock("button", {
|
|
7553
|
+
key: 0,
|
|
7554
|
+
type: "button",
|
|
7555
|
+
class: "vv-input-file__item-action",
|
|
7556
|
+
title: _ctx.labelDownload,
|
|
7557
|
+
onClick: withModifiers(($event) => onClickDownloadFile(file), ["stop"])
|
|
7384
7558
|
}, [
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
|
|
7420
|
-
}, null, 8, _hoisted_12)) : createCommentVNode("v-if", true)
|
|
7421
|
-
], 10, _hoisted_8);
|
|
7422
|
-
}),
|
|
7423
|
-
128
|
|
7424
|
-
/* KEYED_FRAGMENT */
|
|
7425
|
-
))
|
|
7426
|
-
]),
|
|
7559
|
+
createVNode(
|
|
7560
|
+
_sfc_main$u,
|
|
7561
|
+
normalizeProps(guardReactiveProps(unref(hasIconDownload))),
|
|
7562
|
+
null,
|
|
7563
|
+
16
|
|
7564
|
+
/* FULL_PROPS */
|
|
7565
|
+
)
|
|
7566
|
+
], 8, _hoisted_8)) : createCommentVNode("v-if", true),
|
|
7567
|
+
createElementVNode(
|
|
7568
|
+
"div",
|
|
7569
|
+
_hoisted_9,
|
|
7570
|
+
toDisplayString(file.name),
|
|
7571
|
+
1
|
|
7572
|
+
/* TEXT */
|
|
7573
|
+
),
|
|
7574
|
+
createElementVNode(
|
|
7575
|
+
"small",
|
|
7576
|
+
_hoisted_10,
|
|
7577
|
+
toDisplayString(sizeInKiB(file.size)) + " KB ",
|
|
7578
|
+
1
|
|
7579
|
+
/* TEXT */
|
|
7580
|
+
),
|
|
7581
|
+
!unref(readonly) ? (openBlock(), createElementBlock("button", {
|
|
7582
|
+
key: 1,
|
|
7583
|
+
type: "button",
|
|
7584
|
+
class: "vv-input-file__item-remove",
|
|
7585
|
+
title: _ctx.labelRemove,
|
|
7586
|
+
onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
|
|
7587
|
+
}, null, 8, _hoisted_11)) : createCommentVNode("v-if", true)
|
|
7588
|
+
], 10, _hoisted_7)
|
|
7589
|
+
]),
|
|
7590
|
+
_: 1
|
|
7591
|
+
/* STABLE */
|
|
7592
|
+
}, 8, ["modelValue", "move"]),
|
|
7427
7593
|
createVNode(unref(HintSlot), {
|
|
7428
7594
|
id: hasHintId.value,
|
|
7429
7595
|
class: "vv-input-file__hint"
|