@volverjs/ui-vue 0.0.10-beta.22 → 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.
- 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 +250 -119
- package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +18 -6
- package/dist/components/VvAccordionGroup/index.d.ts +3 -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 +199 -169
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/VvInputFile/VvInputFile.vue.d.ts +55 -9
- package/dist/components/VvInputFile/index.d.ts +24 -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 +478 -324
- 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 +38 -14
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +259 -101
- 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 +140 -41
- package/src/components/VvAccordionGroup/index.ts +3 -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 +72 -47
- package/src/components/VvInputFile/index.ts +22 -3
- 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.test.ts +15 -9
- 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, Fragment, renderList, createBlock, mergeProps, withCtx, resolveDynamicComponent, mergeDefaults, createCommentVNode, createVNode, TransitionGroup, toHandlers, useSlots, isRef, h, onMounted, withDirectives, vModelCheckbox, createSlots, nextTick, 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;
|
|
879
|
-
}
|
|
880
|
-
if (modelValue.value === void 0 && typeof newValue === "boolean") {
|
|
881
|
-
localModelValue.value = newValue;
|
|
882
|
-
return;
|
|
772
|
+
bus.emit("register", { name: newValue });
|
|
883
773
|
}
|
|
884
|
-
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
immediate: true
|
|
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;
|
|
885
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,9 @@ const VvAccordionGroupProps = {
|
|
|
933
878
|
/**
|
|
934
879
|
* VModel
|
|
935
880
|
*/
|
|
936
|
-
modelValue:
|
|
881
|
+
modelValue: {
|
|
882
|
+
type: [String, Array]
|
|
883
|
+
},
|
|
937
884
|
/**
|
|
938
885
|
* Accordion items
|
|
939
886
|
* @type VvAccordionGroupItem
|
|
@@ -967,15 +914,8 @@ const VvAccordionGroupProps = {
|
|
|
967
914
|
storeKey: String
|
|
968
915
|
};
|
|
969
916
|
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
|
-
);
|
|
917
|
+
function useProvideGroupState(key, groupState) {
|
|
918
|
+
provide(key, groupState);
|
|
979
919
|
}
|
|
980
920
|
const __default__$q = {
|
|
981
921
|
name: "VvAccordionGroup"
|
|
@@ -984,58 +924,149 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
984
924
|
...__default__$q,
|
|
985
925
|
props: VvAccordionGroupProps,
|
|
986
926
|
emits: VvAccordionGroupEvents,
|
|
987
|
-
setup(__props, { emit: __emit }) {
|
|
927
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
988
928
|
const props = __props;
|
|
989
929
|
const emit = __emit;
|
|
990
|
-
const { disabled,
|
|
930
|
+
const { disabled, modifiers, itemModifiers, items } = toRefs(props);
|
|
991
931
|
watchEffect(() => {
|
|
992
|
-
if (typeof props.modelValue === "string" && collapse
|
|
932
|
+
if (typeof props.modelValue === "string" && props.collapse) {
|
|
993
933
|
console.warn(
|
|
994
934
|
`[VvAccordionGroup]: modelValue is a string but collapse is true.`
|
|
995
935
|
);
|
|
996
936
|
}
|
|
997
937
|
});
|
|
998
|
-
|
|
938
|
+
const accordionNames = reactive(/* @__PURE__ */ new Set());
|
|
939
|
+
let modelValue = ref(/* @__PURE__ */ new Set());
|
|
999
940
|
watch(
|
|
1000
941
|
() => props.storeKey,
|
|
1001
|
-
(newKey) => {
|
|
942
|
+
(newKey, oldKey) => {
|
|
943
|
+
if (oldKey && oldKey !== newKey) {
|
|
944
|
+
localStorage.removeItem(oldKey);
|
|
945
|
+
}
|
|
1002
946
|
if (newKey) {
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
localModelValue = ref([]);
|
|
947
|
+
modelValue = useLocalStorage(newKey, modelValue.value);
|
|
948
|
+
return;
|
|
1006
949
|
}
|
|
950
|
+
modelValue = ref(new Set(modelValue.value));
|
|
1007
951
|
},
|
|
1008
952
|
{ immediate: true }
|
|
1009
953
|
);
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
if (props.
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
954
|
+
watch(
|
|
955
|
+
[modelValue, accordionNames, () => props.not, () => props.collapse],
|
|
956
|
+
() => {
|
|
957
|
+
if (props.not) {
|
|
958
|
+
emit(
|
|
959
|
+
"update:modelValue",
|
|
960
|
+
[...accordionNames].filter(
|
|
961
|
+
(name) => !modelValue.value.has(name)
|
|
962
|
+
)
|
|
963
|
+
);
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
if (props.collapse) {
|
|
967
|
+
emit("update:modelValue", [...modelValue.value]);
|
|
968
|
+
return;
|
|
1018
969
|
}
|
|
1019
|
-
|
|
970
|
+
emit("update:modelValue", modelValue.value.values().next().value);
|
|
1020
971
|
},
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
972
|
+
{
|
|
973
|
+
deep: true,
|
|
974
|
+
immediate: true
|
|
975
|
+
}
|
|
976
|
+
);
|
|
977
|
+
watch(
|
|
978
|
+
() => props.modelValue,
|
|
979
|
+
(newValue, oldValue) => {
|
|
980
|
+
if (newValue === void 0 || newValue === null || JSON.stringify(newValue) === JSON.stringify(oldValue)) {
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
let toReturn = /* @__PURE__ */ new Set();
|
|
984
|
+
if (props.not) {
|
|
985
|
+
if (typeof newValue === "string") {
|
|
986
|
+
toReturn = new Set(
|
|
987
|
+
[...accordionNames].filter((name) => name !== newValue)
|
|
988
|
+
);
|
|
989
|
+
} else if (Array.isArray(newValue)) {
|
|
990
|
+
toReturn = new Set(
|
|
991
|
+
[...accordionNames].filter(
|
|
992
|
+
(name) => !newValue.includes(name)
|
|
993
|
+
)
|
|
994
|
+
);
|
|
1025
995
|
}
|
|
1026
|
-
|
|
996
|
+
} else if (typeof newValue === "string") {
|
|
997
|
+
toReturn = /* @__PURE__ */ new Set([newValue]);
|
|
998
|
+
} else if (Array.isArray(newValue)) {
|
|
999
|
+
toReturn = new Set(newValue);
|
|
1000
|
+
}
|
|
1001
|
+
for (const name of accordionNames) {
|
|
1002
|
+
bus.emit("toggle", { name, value: toReturn.has(name) });
|
|
1027
1003
|
}
|
|
1028
|
-
|
|
1004
|
+
modelValue.value = toReturn;
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
immediate: true
|
|
1029
1008
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
modelValue,
|
|
1009
|
+
);
|
|
1010
|
+
const bus = mitt();
|
|
1011
|
+
useProvideGroupState(INJECTION_KEY_ACCORDION_GROUP, {
|
|
1034
1012
|
disabled,
|
|
1035
|
-
collapse,
|
|
1036
1013
|
modifiers: itemModifiers,
|
|
1037
|
-
|
|
1014
|
+
bus
|
|
1038
1015
|
});
|
|
1016
|
+
bus.on("register", ({ name }) => {
|
|
1017
|
+
accordionNames.add(name);
|
|
1018
|
+
});
|
|
1019
|
+
bus.on("unregister", ({ name }) => {
|
|
1020
|
+
accordionNames.delete(name);
|
|
1021
|
+
});
|
|
1022
|
+
bus.on("toggle", ({ name, value }) => {
|
|
1023
|
+
if (value) {
|
|
1024
|
+
if (!props.collapse) {
|
|
1025
|
+
for (const item of modelValue.value) {
|
|
1026
|
+
if (item !== name) {
|
|
1027
|
+
bus.emit("toggle", { name: item, value: false });
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
modelValue.value.clear();
|
|
1031
|
+
}
|
|
1032
|
+
modelValue.value.add(name);
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
modelValue.value.delete(name);
|
|
1036
|
+
});
|
|
1037
|
+
const expand = (name) => {
|
|
1038
|
+
if (typeof name === "string") {
|
|
1039
|
+
bus.emit("toggle", { name, value: true });
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
if (Array.isArray(name)) {
|
|
1043
|
+
for (const item of name) {
|
|
1044
|
+
bus.emit("toggle", { name: item, value: true });
|
|
1045
|
+
}
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
for (const item of accordionNames) {
|
|
1049
|
+
bus.emit("toggle", { name: item, value: true });
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
bus.on("expand", ({ name }) => expand(name));
|
|
1053
|
+
const collapse = (name) => {
|
|
1054
|
+
if (typeof name === "string") {
|
|
1055
|
+
bus.emit("toggle", { name, value: false });
|
|
1056
|
+
return;
|
|
1057
|
+
}
|
|
1058
|
+
if (Array.isArray(name)) {
|
|
1059
|
+
for (const item of name) {
|
|
1060
|
+
bus.emit("toggle", { name: item, value: false });
|
|
1061
|
+
}
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
for (const item of accordionNames) {
|
|
1065
|
+
bus.emit("toggle", { name: item, value: false });
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
bus.on("collapse", ({ name }) => collapse(name));
|
|
1069
|
+
__expose({ modelValue, expand, collapse });
|
|
1039
1070
|
const bemCssClasses = useModifiers(
|
|
1040
1071
|
"vv-accordion-group",
|
|
1041
1072
|
modifiers,
|
|
@@ -1050,7 +1081,11 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
1050
1081
|
class: normalizeClass(unref(bemCssClasses))
|
|
1051
1082
|
},
|
|
1052
1083
|
[
|
|
1053
|
-
renderSlot(_ctx.$slots, "default", {
|
|
1084
|
+
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
|
|
1085
|
+
modelValue: unref(modelValue),
|
|
1086
|
+
expand,
|
|
1087
|
+
collapse
|
|
1088
|
+
})), () => [
|
|
1054
1089
|
(openBlock(true), createElementBlock(
|
|
1055
1090
|
Fragment,
|
|
1056
1091
|
null,
|
|
@@ -2147,14 +2182,11 @@ function useGroupProps$2(props, emit) {
|
|
|
2147
2182
|
const { id, iconPosition, icon, label, pressed } = toRefs(props);
|
|
2148
2183
|
const modelValue = getGroupOrLocalRef("modelValue", props, emit);
|
|
2149
2184
|
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);
|
|
2185
|
+
const unselectable = getGroupOrLocalRef("unselectable", props);
|
|
2186
|
+
const multiple = computed(() => (group == null ? void 0 : group.multiple.value) ?? false);
|
|
2155
2187
|
const modifiers = computed(() => {
|
|
2156
2188
|
let localModifiers = props.modifiers;
|
|
2157
|
-
let groupModifiers = group == null ? void 0 : group.
|
|
2189
|
+
let groupModifiers = group == null ? void 0 : group.modifiers.value;
|
|
2158
2190
|
const toReturn = /* @__PURE__ */ new Set();
|
|
2159
2191
|
if (localModifiers) {
|
|
2160
2192
|
if (!Array.isArray(localModifiers)) {
|
|
@@ -2171,10 +2203,7 @@ function useGroupProps$2(props, emit) {
|
|
|
2171
2203
|
return Array.from(toReturn);
|
|
2172
2204
|
});
|
|
2173
2205
|
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
|
-
}
|
|
2206
|
+
() => Boolean(props.disabled || (group == null ? void 0 : group.disabled.value))
|
|
2178
2207
|
);
|
|
2179
2208
|
return {
|
|
2180
2209
|
// group props
|
|
@@ -2194,6 +2223,111 @@ function useGroupProps$2(props, emit) {
|
|
|
2194
2223
|
label
|
|
2195
2224
|
};
|
|
2196
2225
|
}
|
|
2226
|
+
function equals(obj1, obj2, field) {
|
|
2227
|
+
if (field) {
|
|
2228
|
+
return resolveFieldData(obj1, field) === resolveFieldData(obj2, field);
|
|
2229
|
+
}
|
|
2230
|
+
return deepEquals(obj1, obj2);
|
|
2231
|
+
}
|
|
2232
|
+
function deepEquals(a, b) {
|
|
2233
|
+
if (a === b)
|
|
2234
|
+
return true;
|
|
2235
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
2236
|
+
const arrA = Array.isArray(a);
|
|
2237
|
+
const arrB = Array.isArray(b);
|
|
2238
|
+
let i, length, key;
|
|
2239
|
+
if (arrA && arrB) {
|
|
2240
|
+
length = a.length;
|
|
2241
|
+
if (length != b.length)
|
|
2242
|
+
return false;
|
|
2243
|
+
for (i = length; i-- !== 0; )
|
|
2244
|
+
if (!deepEquals(a[i], b[i]))
|
|
2245
|
+
return false;
|
|
2246
|
+
return true;
|
|
2247
|
+
}
|
|
2248
|
+
if (arrA != arrB)
|
|
2249
|
+
return false;
|
|
2250
|
+
const dateA = a instanceof Date, dateB = b instanceof Date;
|
|
2251
|
+
if (dateA != dateB)
|
|
2252
|
+
return false;
|
|
2253
|
+
if (dateA && dateB)
|
|
2254
|
+
return a.getTime() == b.getTime();
|
|
2255
|
+
const regexpA = a instanceof RegExp, regexpB = b instanceof RegExp;
|
|
2256
|
+
if (regexpA != regexpB)
|
|
2257
|
+
return false;
|
|
2258
|
+
if (regexpA && regexpB)
|
|
2259
|
+
return a.toString() == b.toString();
|
|
2260
|
+
const keys = Object.keys(a);
|
|
2261
|
+
length = keys.length;
|
|
2262
|
+
if (length !== Object.keys(b).length)
|
|
2263
|
+
return false;
|
|
2264
|
+
for (i = length; i-- !== 0; )
|
|
2265
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
2266
|
+
return false;
|
|
2267
|
+
for (i = length; i-- !== 0; ) {
|
|
2268
|
+
key = keys[i];
|
|
2269
|
+
if (!deepEquals(a[key], b[key]))
|
|
2270
|
+
return false;
|
|
2271
|
+
}
|
|
2272
|
+
return true;
|
|
2273
|
+
}
|
|
2274
|
+
return a !== a && b !== b;
|
|
2275
|
+
}
|
|
2276
|
+
function resolveFieldData(data, field) {
|
|
2277
|
+
if (data && Object.keys(data).length && field) {
|
|
2278
|
+
if (field.indexOf(".") === -1) {
|
|
2279
|
+
return data[field];
|
|
2280
|
+
} else {
|
|
2281
|
+
const fields = field.split(".");
|
|
2282
|
+
let value = data;
|
|
2283
|
+
for (let i = 0, len = fields.length; i < len; ++i) {
|
|
2284
|
+
if (data == null) {
|
|
2285
|
+
return null;
|
|
2286
|
+
}
|
|
2287
|
+
value = value[fields[i]];
|
|
2288
|
+
}
|
|
2289
|
+
return value;
|
|
2290
|
+
}
|
|
2291
|
+
} else {
|
|
2292
|
+
return null;
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
function findIndexInList(value, list) {
|
|
2296
|
+
let index = -1;
|
|
2297
|
+
if (list) {
|
|
2298
|
+
for (let i = 0; i < list.length; i++) {
|
|
2299
|
+
if (equals(list[i], value)) {
|
|
2300
|
+
index = i;
|
|
2301
|
+
break;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
return index;
|
|
2306
|
+
}
|
|
2307
|
+
function contains(value, list) {
|
|
2308
|
+
if (value != null && list && list.length) {
|
|
2309
|
+
for (const val of list) {
|
|
2310
|
+
if (equals(value, val)) {
|
|
2311
|
+
return true;
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
return false;
|
|
2316
|
+
}
|
|
2317
|
+
function isEmpty(value) {
|
|
2318
|
+
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));
|
|
2319
|
+
}
|
|
2320
|
+
function removeFromList(value, list) {
|
|
2321
|
+
const indexElToRemove = findIndexInList(value, list);
|
|
2322
|
+
if (indexElToRemove > -1) {
|
|
2323
|
+
return list.filter((el, elIndex) => elIndex !== indexElToRemove);
|
|
2324
|
+
} else {
|
|
2325
|
+
return list;
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
function isString(value) {
|
|
2329
|
+
return typeof value === "string" || value instanceof String;
|
|
2330
|
+
}
|
|
2197
2331
|
const _hoisted_1$g = {
|
|
2198
2332
|
key: 1,
|
|
2199
2333
|
class: "vv-button__label"
|
|
@@ -2407,8 +2541,7 @@ const _sfc_main$m = /* @__PURE__ */ defineComponent({
|
|
|
2407
2541
|
return emit("update:modelValue", newValue);
|
|
2408
2542
|
}
|
|
2409
2543
|
});
|
|
2410
|
-
useProvideGroupState({
|
|
2411
|
-
key: INJECTION_KEY_BUTTON_GROUP,
|
|
2544
|
+
useProvideGroupState(INJECTION_KEY_BUTTON_GROUP, {
|
|
2412
2545
|
modelValue,
|
|
2413
2546
|
disabled,
|
|
2414
2547
|
toggle,
|
|
@@ -2513,16 +2646,10 @@ function useGroupProps$1(props, emit) {
|
|
|
2513
2646
|
const valid = getGroupOrLocalRef("valid", props);
|
|
2514
2647
|
const invalid = getGroupOrLocalRef("invalid", props);
|
|
2515
2648
|
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
|
-
}
|
|
2649
|
+
() => Boolean(props.readonly || (group == null ? void 0 : group.readonly.value))
|
|
2520
2650
|
);
|
|
2521
2651
|
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
|
-
}
|
|
2652
|
+
() => Boolean(props.disabled || (group == null ? void 0 : group.disabled.value))
|
|
2526
2653
|
);
|
|
2527
2654
|
return {
|
|
2528
2655
|
// local props
|
|
@@ -2964,8 +3091,7 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
2964
3091
|
);
|
|
2965
3092
|
const modelValue = useVModel(props, "modelValue", emit);
|
|
2966
3093
|
const { disabled, readonly, vertical, valid, invalid, modifiers } = toRefs(props);
|
|
2967
|
-
useProvideGroupState({
|
|
2968
|
-
key: INJECTION_KEY_CHECK_GROUP,
|
|
3094
|
+
useProvideGroupState(INJECTION_KEY_CHECK_GROUP, {
|
|
2969
3095
|
modelValue,
|
|
2970
3096
|
disabled,
|
|
2971
3097
|
readonly,
|
|
@@ -6221,16 +6347,10 @@ function useGroupProps(props, emit) {
|
|
|
6221
6347
|
const valid = getGroupOrLocalRef("valid", props);
|
|
6222
6348
|
const invalid = getGroupOrLocalRef("invalid", props);
|
|
6223
6349
|
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
|
-
}
|
|
6350
|
+
() => Boolean(props.readonly || (group == null ? void 0 : group.readonly.value))
|
|
6228
6351
|
);
|
|
6229
6352
|
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
|
-
}
|
|
6353
|
+
() => Boolean(props.disabled || (group == null ? void 0 : group.disabled.value))
|
|
6234
6354
|
);
|
|
6235
6355
|
return {
|
|
6236
6356
|
// local props
|
|
@@ -6405,8 +6525,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
6405
6525
|
);
|
|
6406
6526
|
const modelValue = useVModel(props, "modelValue", emit);
|
|
6407
6527
|
const { disabled, readonly, vertical, valid, invalid, modifiers } = toRefs(props);
|
|
6408
|
-
useProvideGroupState({
|
|
6409
|
-
key: INJECTION_KEY_RADIO_GROUP,
|
|
6528
|
+
useProvideGroupState(INJECTION_KEY_RADIO_GROUP, {
|
|
6410
6529
|
modelValue,
|
|
6411
6530
|
disabled,
|
|
6412
6531
|
readonly,
|
|
@@ -6967,8 +7086,7 @@ const VvInputFileProps = {
|
|
|
6967
7086
|
* Input value
|
|
6968
7087
|
*/
|
|
6969
7088
|
modelValue: {
|
|
6970
|
-
type: Object
|
|
6971
|
-
required: true
|
|
7089
|
+
type: Object
|
|
6972
7090
|
},
|
|
6973
7091
|
/**
|
|
6974
7092
|
* Whether to show progress bar
|
|
@@ -6990,6 +7108,20 @@ const VvInputFileProps = {
|
|
|
6990
7108
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#multiple
|
|
6991
7109
|
*/
|
|
6992
7110
|
multiple: { type: Boolean, default: false },
|
|
7111
|
+
/**
|
|
7112
|
+
* Front or rear camera
|
|
7113
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture
|
|
7114
|
+
*/
|
|
7115
|
+
capture: {
|
|
7116
|
+
type: String,
|
|
7117
|
+
default: void 0,
|
|
7118
|
+
validation: (value) => {
|
|
7119
|
+
if (value === void 0) {
|
|
7120
|
+
return true;
|
|
7121
|
+
}
|
|
7122
|
+
return ["user", "environment"].includes(value);
|
|
7123
|
+
}
|
|
7124
|
+
},
|
|
6993
7125
|
/**
|
|
6994
7126
|
* Max number of files
|
|
6995
7127
|
*/
|
|
@@ -6998,6 +7130,10 @@ const VvInputFileProps = {
|
|
|
6998
7130
|
* Show drop area
|
|
6999
7131
|
*/
|
|
7000
7132
|
dropArea: { type: Boolean, default: false },
|
|
7133
|
+
/**
|
|
7134
|
+
* Enable sorting
|
|
7135
|
+
*/
|
|
7136
|
+
sortable: { type: Boolean, default: false },
|
|
7001
7137
|
/**
|
|
7002
7138
|
* Label for add button
|
|
7003
7139
|
*/
|
|
@@ -7055,14 +7191,13 @@ const _hoisted_1 = ["for"];
|
|
|
7055
7191
|
const _hoisted_2 = { class: "vv-input-file__preview" };
|
|
7056
7192
|
const _hoisted_3 = ["src", "alt"];
|
|
7057
7193
|
const _hoisted_4 = { class: "vv-input-file__wrapper" };
|
|
7058
|
-
const _hoisted_5 = ["id", "readonly", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "name"];
|
|
7194
|
+
const _hoisted_5 = ["id", "readonly", "placeholder", "aria-describedby", "aria-invalid", "aria-errormessage", "multiple", "accept", "capture", "name"];
|
|
7059
7195
|
const _hoisted_6 = ["value"];
|
|
7060
|
-
const _hoisted_7 =
|
|
7061
|
-
const _hoisted_8 = ["onClick"];
|
|
7062
|
-
const _hoisted_9 =
|
|
7063
|
-
const _hoisted_10 = { class: "vv-input-file__item-
|
|
7064
|
-
const _hoisted_11 =
|
|
7065
|
-
const _hoisted_12 = ["title", "onClick"];
|
|
7196
|
+
const _hoisted_7 = ["onClick"];
|
|
7197
|
+
const _hoisted_8 = ["title", "onClick"];
|
|
7198
|
+
const _hoisted_9 = { class: "vv-input-file__item-name" };
|
|
7199
|
+
const _hoisted_10 = { class: "vv-input-file__item-info" };
|
|
7200
|
+
const _hoisted_11 = ["title", "onClick"];
|
|
7066
7201
|
const __default__ = {
|
|
7067
7202
|
name: "VvInputFile"
|
|
7068
7203
|
};
|
|
@@ -7111,12 +7246,21 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7111
7246
|
hintSlotScope
|
|
7112
7247
|
} = HintSlotFactory(propsDefaults, slots);
|
|
7113
7248
|
const localModelValue = useVModel(props, "modelValue", emit);
|
|
7114
|
-
const files = computed(
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7249
|
+
const files = computed({
|
|
7250
|
+
get: () => {
|
|
7251
|
+
var _a;
|
|
7252
|
+
if (!localModelValue.value || !Array.isArray(localModelValue.value) && !((_a = localModelValue.value) == null ? void 0 : _a.name)) {
|
|
7253
|
+
return [];
|
|
7254
|
+
}
|
|
7255
|
+
return Array.isArray(localModelValue.value) ? localModelValue.value : [localModelValue.value];
|
|
7256
|
+
},
|
|
7257
|
+
set: (value) => {
|
|
7258
|
+
if (isMultiple.value) {
|
|
7259
|
+
localModelValue.value = value;
|
|
7260
|
+
return;
|
|
7261
|
+
}
|
|
7262
|
+
localModelValue.value = value == null ? void 0 : value[0];
|
|
7118
7263
|
}
|
|
7119
|
-
return Array.isArray(localModelValue.value) ? localModelValue.value : [localModelValue.value];
|
|
7120
7264
|
});
|
|
7121
7265
|
const hasMax = computed(() => {
|
|
7122
7266
|
return typeof props.max === "string" ? parseInt(props.max) : props.max;
|
|
@@ -7270,6 +7414,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7270
7414
|
}
|
|
7271
7415
|
return props.iconReplace;
|
|
7272
7416
|
});
|
|
7417
|
+
const onSortEnd = ({ newIndex }) => {
|
|
7418
|
+
if (newIndex !== null) {
|
|
7419
|
+
selectedFileIndex.value = newIndex;
|
|
7420
|
+
}
|
|
7421
|
+
};
|
|
7273
7422
|
return (_ctx, _cache) => {
|
|
7274
7423
|
return openBlock(), createElementBlock(
|
|
7275
7424
|
"div",
|
|
@@ -7338,6 +7487,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7338
7487
|
"aria-errormessage": unref(hasInvalidLabelOrSlot) ? hasHintId.value : void 0,
|
|
7339
7488
|
multiple: isMultiple.value,
|
|
7340
7489
|
accept: _ctx.accept,
|
|
7490
|
+
capture: _ctx.capture,
|
|
7341
7491
|
name: _ctx.name,
|
|
7342
7492
|
onChange
|
|
7343
7493
|
}, null, 40, _hoisted_5),
|
|
@@ -7355,60 +7505,64 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
7355
7505
|
/* FULL_PROPS */
|
|
7356
7506
|
)) : createCommentVNode("v-if", true)
|
|
7357
7507
|
]),
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7508
|
+
createVNode(unref(Sortable), {
|
|
7509
|
+
modelValue: files.value,
|
|
7510
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => files.value = $event),
|
|
7511
|
+
tag: "ul",
|
|
7512
|
+
class: "vv-input-file__list",
|
|
7513
|
+
"item-key": "name",
|
|
7514
|
+
move: () => _ctx.sortable,
|
|
7515
|
+
onEnd: onSortEnd
|
|
7516
|
+
}, {
|
|
7517
|
+
item: withCtx(({ element: file, index }) => [
|
|
7518
|
+
createElementVNode("li", {
|
|
7519
|
+
class: normalizeClass(["vv-input-file__item", {
|
|
7520
|
+
active: index === selectedFileIndex.value && hasDropArea.value && files.value.length > 1,
|
|
7521
|
+
"cursor-move": _ctx.sortable
|
|
7522
|
+
}]),
|
|
7523
|
+
onClick: withModifiers(($event) => onClickSelectFile(index), ["stop"])
|
|
7524
|
+
}, [
|
|
7525
|
+
unref(hasIconDownload) ? (openBlock(), createElementBlock("button", {
|
|
7526
|
+
key: 0,
|
|
7527
|
+
type: "button",
|
|
7528
|
+
class: "vv-input-file__item-action",
|
|
7529
|
+
title: _ctx.labelDownload,
|
|
7530
|
+
onClick: withModifiers(($event) => onClickDownloadFile(file), ["stop"])
|
|
7369
7531
|
}, [
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7404
|
-
onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
|
|
7405
|
-
}, null, 8, _hoisted_12)) : createCommentVNode("v-if", true)
|
|
7406
|
-
], 10, _hoisted_8);
|
|
7407
|
-
}),
|
|
7408
|
-
128
|
|
7409
|
-
/* KEYED_FRAGMENT */
|
|
7410
|
-
))
|
|
7411
|
-
]),
|
|
7532
|
+
createVNode(
|
|
7533
|
+
_sfc_main$u,
|
|
7534
|
+
normalizeProps(guardReactiveProps(unref(hasIconDownload))),
|
|
7535
|
+
null,
|
|
7536
|
+
16
|
|
7537
|
+
/* FULL_PROPS */
|
|
7538
|
+
)
|
|
7539
|
+
], 8, _hoisted_8)) : createCommentVNode("v-if", true),
|
|
7540
|
+
createElementVNode(
|
|
7541
|
+
"div",
|
|
7542
|
+
_hoisted_9,
|
|
7543
|
+
toDisplayString(file.name),
|
|
7544
|
+
1
|
|
7545
|
+
/* TEXT */
|
|
7546
|
+
),
|
|
7547
|
+
createElementVNode(
|
|
7548
|
+
"small",
|
|
7549
|
+
_hoisted_10,
|
|
7550
|
+
toDisplayString(sizeInKiB(file.size)) + " KB ",
|
|
7551
|
+
1
|
|
7552
|
+
/* TEXT */
|
|
7553
|
+
),
|
|
7554
|
+
!unref(readonly) ? (openBlock(), createElementBlock("button", {
|
|
7555
|
+
key: 1,
|
|
7556
|
+
type: "button",
|
|
7557
|
+
class: "vv-input-file__item-remove",
|
|
7558
|
+
title: _ctx.labelRemove,
|
|
7559
|
+
onClick: withModifiers(($event) => onClickRemoveFile(index), ["stop"])
|
|
7560
|
+
}, null, 8, _hoisted_11)) : createCommentVNode("v-if", true)
|
|
7561
|
+
], 10, _hoisted_7)
|
|
7562
|
+
]),
|
|
7563
|
+
_: 1
|
|
7564
|
+
/* STABLE */
|
|
7565
|
+
}, 8, ["modelValue", "move"]),
|
|
7412
7566
|
createVNode(unref(HintSlot), {
|
|
7413
7567
|
id: hasHintId.value,
|
|
7414
7568
|
class: "vv-input-file__hint"
|