@volverjs/ui-vue 0.0.6-beta.5 → 0.0.6-beta.7
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/auto-imports.d.ts +9 -0
- package/dist/Volver.d.ts +1 -1
- package/dist/components/VvAccordion/index.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +25 -19
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +151 -98
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +37 -1
- package/dist/components/VvCheckbox/index.d.ts +6 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +187 -101
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +36 -0
- package/dist/components/VvCheckboxGroup/index.d.ts +5 -0
- package/dist/components/VvCombobox/VvCombobox.es.js +236 -140
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +25 -1
- package/dist/components/VvDialog/VvDialog.es.js +25 -19
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +19 -4
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +8 -4
- package/dist/components/VvDropdown/index.d.ts +1 -1
- package/dist/components/VvIcon/VvIcon.es.js +25 -19
- package/dist/components/VvIcon/VvIcon.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -2
- package/dist/components/VvIcon/index.d.ts +2 -2
- package/dist/components/VvInputText/VvInputText.es.js +160 -136
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +24 -0
- package/dist/components/VvRadio/VvRadio.es.js +151 -98
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +37 -1
- package/dist/components/VvRadio/index.d.ts +6 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +187 -101
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +36 -0
- package/dist/components/VvRadioGroup/index.d.ts +5 -0
- package/dist/components/VvSelect/VvSelect.es.js +163 -137
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +24 -0
- package/dist/components/VvTextarea/VvTextarea.es.js +160 -136
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +24 -0
- package/dist/components/common/HintSlot.d.ts +38 -12
- package/dist/components/index.es.js +466 -168
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/group/useInjectedGroupState.d.ts +1 -1
- package/dist/composables/useOptions.d.ts +2 -2
- package/dist/directives/index.d.ts +2 -2
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +22 -0
- package/package.json +33 -33
- 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/VvCheckbox/VvCheckbox.vue +23 -2
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +15 -2
- package/src/components/VvCombobox/VvCombobox.vue +40 -16
- package/src/components/VvDropdown/VvDropdown.vue +20 -2
- package/src/components/VvIcon/VvIcon.vue +37 -34
- package/src/components/VvIcon/index.ts +2 -2
- package/src/components/VvInputText/VvInputText.vue +26 -9
- package/src/components/VvRadio/VvRadio.vue +23 -2
- package/src/components/VvRadioGroup/VvRadioGroup.vue +15 -2
- package/src/components/VvSelect/VvSelect.vue +26 -9
- package/src/components/VvTextarea/VvTextarea.vue +26 -9
- package/src/components/common/HintSlot.ts +129 -170
- package/src/composables/useOptions.ts +9 -7
- package/src/props/index.ts +2 -0
|
@@ -16,6 +16,11 @@ export declare const VvCheckboxProps: {
|
|
|
16
16
|
modifiers: globalThis.PropType<string | string[]>;
|
|
17
17
|
value: (StringConstructor | BooleanConstructor | NumberConstructor)[];
|
|
18
18
|
modelValue: (StringConstructor | BooleanConstructor | ObjectConstructor | NumberConstructor)[];
|
|
19
|
+
loading: BooleanConstructor;
|
|
20
|
+
loadingLabel: {
|
|
21
|
+
type: StringConstructor;
|
|
22
|
+
default: string;
|
|
23
|
+
};
|
|
19
24
|
label: (StringConstructor | NumberConstructor)[];
|
|
20
25
|
readonly: BooleanConstructor;
|
|
21
26
|
disabled: BooleanConstructor;
|
|
@@ -48,7 +53,7 @@ export declare function useGroupProps(props: VvCheckboxPropsTypes, emit: (event:
|
|
|
48
53
|
indeterminate: Ref<boolean>;
|
|
49
54
|
group: Ref<InputGroupState> | undefined;
|
|
50
55
|
isInGroup: globalThis.ComputedRef<boolean>;
|
|
51
|
-
modelValue: import("vue").WritableComputedRef<
|
|
56
|
+
modelValue: import("vue").WritableComputedRef<any>;
|
|
52
57
|
valid: Ref<boolean>;
|
|
53
58
|
invalid: Ref<boolean>;
|
|
54
59
|
readonly: globalThis.ComputedRef<boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { unref,
|
|
2
|
-
import { toReactive, useVModel } from "@vueuse/core";
|
|
1
|
+
import { unref, computed, defineComponent, h, inject, toRef, toRefs, useSlots, ref, watchEffect, watch, onMounted, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, isRef, vModelCheckbox, renderSlot, createTextVNode, toDisplayString, createVNode, createSlots, withCtx, normalizeProps, guardReactiveProps, provide, createCommentVNode, Fragment, renderList, createBlock, mergeProps } from "vue";
|
|
3
2
|
import { nanoid } from "nanoid";
|
|
3
|
+
import { useVModel } from "@vueuse/core";
|
|
4
4
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
5
5
|
Side2["left"] = "left";
|
|
6
6
|
Side2["right"] = "right";
|
|
@@ -123,111 +123,114 @@ function isEmpty(value) {
|
|
|
123
123
|
function isString(value) {
|
|
124
124
|
return typeof value === "string" || value instanceof String;
|
|
125
125
|
}
|
|
126
|
-
function joinLines(
|
|
127
|
-
if (Array.isArray(
|
|
128
|
-
return
|
|
126
|
+
function joinLines(items) {
|
|
127
|
+
if (Array.isArray(items)) {
|
|
128
|
+
return items.filter((item) => isString(item)).join(" ");
|
|
129
129
|
}
|
|
130
|
-
return
|
|
130
|
+
return items;
|
|
131
131
|
}
|
|
132
|
-
function HintSlotFactory(
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
valid,
|
|
143
|
-
validLabel,
|
|
144
|
-
invalid,
|
|
145
|
-
invalidLabel,
|
|
146
|
-
...otherProps
|
|
147
|
-
} = toRefs(parentProps);
|
|
148
|
-
const loading = resolveFieldData(otherProps, "loading");
|
|
149
|
-
const loadingLabel = resolveFieldData(otherProps, "loadingLabel");
|
|
150
|
-
const hasInvalid = computed(() => {
|
|
151
|
-
if (!invalid.value) {
|
|
152
|
-
return false;
|
|
153
|
-
}
|
|
154
|
-
if (invalid.value && invalidSlot) {
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
if ((invalidLabel == null ? void 0 : invalidLabel.value) && Array.isArray(invalidLabel.value) && invalidLabel.value.length > 0) {
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
if ((invalidLabel == null ? void 0 : invalidLabel.value) && !isEmpty(invalidLabel)) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
return false;
|
|
164
|
-
});
|
|
165
|
-
const hasHint = computed(
|
|
166
|
-
() => !!(hintLabel && hintLabel.value || hintSlot)
|
|
132
|
+
function HintSlotFactory(props, slots) {
|
|
133
|
+
const invalidLabel = computed(() => joinLines(props.invalidLabel));
|
|
134
|
+
const validLabel = computed(() => joinLines(props.validLabel));
|
|
135
|
+
const loadingLabel = computed(() => props.loadingLabel);
|
|
136
|
+
const hintLabel = computed(() => props.hintLabel);
|
|
137
|
+
const hasLoadingLabelOrSlot = computed(
|
|
138
|
+
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
139
|
+
);
|
|
140
|
+
const hasInvalidLabelOrSlot = computed(
|
|
141
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(props.invalid && (slots.invalid || invalidLabel.value))
|
|
167
142
|
);
|
|
168
|
-
const
|
|
169
|
-
() =>
|
|
143
|
+
const hasValidLabelOrSlot = computed(
|
|
144
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
170
145
|
);
|
|
171
|
-
const
|
|
172
|
-
() =>
|
|
146
|
+
const hasHintLabelOrSlot = computed(
|
|
147
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
173
148
|
);
|
|
174
149
|
const isVisible = computed(
|
|
175
|
-
() =>
|
|
150
|
+
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
176
151
|
);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
152
|
+
const hintSlotScope = computed(() => ({
|
|
153
|
+
modelValue: props.modelValue,
|
|
154
|
+
valid: props.valid,
|
|
155
|
+
invalid: props.invalid,
|
|
156
|
+
loading: props.loading
|
|
157
|
+
}));
|
|
158
|
+
const HintSlot = defineComponent({
|
|
159
|
+
name: "HintSlot",
|
|
160
|
+
props: {
|
|
161
|
+
tag: {
|
|
162
|
+
type: String,
|
|
163
|
+
default: "small"
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
setup() {
|
|
167
|
+
return {
|
|
168
|
+
isVisible,
|
|
169
|
+
invalidLabel,
|
|
170
|
+
validLabel,
|
|
171
|
+
loadingLabel,
|
|
172
|
+
hintLabel,
|
|
173
|
+
hasInvalidLabelOrSlot,
|
|
174
|
+
hasValidLabelOrSlot,
|
|
175
|
+
hasLoadingLabelOrSlot,
|
|
176
|
+
hasHintLabelOrSlot
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
render() {
|
|
180
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
181
|
+
if (this.isVisible) {
|
|
182
|
+
let role;
|
|
183
|
+
if (this.hasInvalidLabelOrSlot) {
|
|
184
|
+
role = "alert";
|
|
188
185
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
hintLabel,
|
|
194
|
-
modelValue,
|
|
195
|
-
valid,
|
|
196
|
-
validLabel,
|
|
197
|
-
invalid,
|
|
198
|
-
invalidLabel,
|
|
199
|
-
loading,
|
|
200
|
-
loadingLabel,
|
|
201
|
-
...props.params
|
|
202
|
-
});
|
|
203
|
-
if (invalid == null ? void 0 : invalid.value) {
|
|
204
|
-
return (invalidSlot == null ? void 0 : invalidSlot(slotProps)) || joinLines(invalidLabel == null ? void 0 : invalidLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
205
|
-
}
|
|
206
|
-
if (valid == null ? void 0 : valid.value)
|
|
207
|
-
return (validSlot == null ? void 0 : validSlot(slotProps)) || joinLines(validLabel == null ? void 0 : validLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
208
|
-
if (loading == null ? void 0 : loading.value)
|
|
209
|
-
return (loadingSlot == null ? void 0 : loadingSlot(slotProps)) || joinLines(loadingLabel == null ? void 0 : loadingLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
210
|
-
return (hintSlot == null ? void 0 : hintSlot(slotProps)) || joinLines(hintLabel == null ? void 0 : hintLabel.value) || (hintLabel == null ? void 0 : hintLabel.value);
|
|
211
|
-
});
|
|
212
|
-
return {
|
|
213
|
-
isVisible,
|
|
214
|
-
hasInvalid,
|
|
215
|
-
hasValid,
|
|
216
|
-
hintContent
|
|
217
|
-
};
|
|
218
|
-
},
|
|
219
|
-
render() {
|
|
220
|
-
if (this.isVisible) {
|
|
186
|
+
if (this.hasValidLabelOrSlot) {
|
|
187
|
+
role = "status";
|
|
188
|
+
}
|
|
189
|
+
if (this.hasLoadingLabelOrSlot) {
|
|
221
190
|
return h(
|
|
222
|
-
|
|
191
|
+
this.tag,
|
|
223
192
|
{
|
|
224
|
-
role
|
|
193
|
+
role
|
|
225
194
|
},
|
|
226
|
-
this.
|
|
195
|
+
((_b = (_a = this.$slots).loading) == null ? void 0 : _b.call(_a)) ?? this.loadingLabel
|
|
227
196
|
);
|
|
228
197
|
}
|
|
198
|
+
if (this.hasInvalidLabelOrSlot) {
|
|
199
|
+
return h(
|
|
200
|
+
this.tag,
|
|
201
|
+
{
|
|
202
|
+
role
|
|
203
|
+
},
|
|
204
|
+
((_d = (_c = this.$slots).invalid) == null ? void 0 : _d.call(_c)) ?? this.$slots.invalid ?? this.invalidLabel
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
if (this.hasValidLabelOrSlot) {
|
|
208
|
+
return h(
|
|
209
|
+
this.tag,
|
|
210
|
+
{
|
|
211
|
+
role
|
|
212
|
+
},
|
|
213
|
+
((_f = (_e = this.$slots).valid) == null ? void 0 : _f.call(_e)) ?? this.validLabel
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
return h(
|
|
217
|
+
this.tag,
|
|
218
|
+
{
|
|
219
|
+
role
|
|
220
|
+
},
|
|
221
|
+
((_h = (_g = this.$slots).hint) == null ? void 0 : _h.call(_g)) ?? this.$slots.hint ?? this.hintLabel
|
|
222
|
+
);
|
|
229
223
|
}
|
|
224
|
+
return null;
|
|
230
225
|
}
|
|
226
|
+
});
|
|
227
|
+
return {
|
|
228
|
+
hasInvalidLabelOrSlot,
|
|
229
|
+
hasHintLabelOrSlot,
|
|
230
|
+
hasValidLabelOrSlot,
|
|
231
|
+
hasLoadingLabelOrSlot,
|
|
232
|
+
hintSlotScope,
|
|
233
|
+
HintSlot
|
|
231
234
|
};
|
|
232
235
|
}
|
|
233
236
|
const LinkProps = {
|
|
@@ -277,6 +280,19 @@ const InvalidProps = {
|
|
|
277
280
|
*/
|
|
278
281
|
invalidLabel: [String, Array]
|
|
279
282
|
};
|
|
283
|
+
const LoadingProps = {
|
|
284
|
+
/**
|
|
285
|
+
* Loading status
|
|
286
|
+
*/
|
|
287
|
+
loading: Boolean,
|
|
288
|
+
/**
|
|
289
|
+
* Loading label
|
|
290
|
+
*/
|
|
291
|
+
loadingLabel: {
|
|
292
|
+
type: String,
|
|
293
|
+
default: "Loading..."
|
|
294
|
+
}
|
|
295
|
+
};
|
|
280
296
|
const DisabledProps = {
|
|
281
297
|
/**
|
|
282
298
|
* Whether the form control is disabled
|
|
@@ -481,6 +497,7 @@ const CheckboxRadioProps = {
|
|
|
481
497
|
...ReadonlyProps,
|
|
482
498
|
...ModifiersProps,
|
|
483
499
|
...LabelProps,
|
|
500
|
+
...LoadingProps,
|
|
484
501
|
/**
|
|
485
502
|
* Input value
|
|
486
503
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
|
|
@@ -500,6 +517,7 @@ const CheckboxRadioGroupProps = {
|
|
|
500
517
|
...ReadonlyProps,
|
|
501
518
|
...ModifiersProps,
|
|
502
519
|
...LabelProps,
|
|
520
|
+
...LoadingProps,
|
|
503
521
|
/**
|
|
504
522
|
* Input value
|
|
505
523
|
*/
|
|
@@ -635,7 +653,7 @@ function useModifiers(prefix, modifiers, others) {
|
|
|
635
653
|
});
|
|
636
654
|
}
|
|
637
655
|
const _hoisted_1$1 = ["for"];
|
|
638
|
-
const _hoisted_2$1 = ["id", "name", "disabled", "value", "tabindex", "aria-invalid"];
|
|
656
|
+
const _hoisted_2$1 = ["id", "name", "disabled", "value", "tabindex", "aria-invalid", "aria-describedby", "aria-errormessage"];
|
|
639
657
|
const __default__$1 = {
|
|
640
658
|
name: "VvCheckbox"
|
|
641
659
|
};
|
|
@@ -658,6 +676,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
658
676
|
isInGroup
|
|
659
677
|
} = useGroupProps(props, emit);
|
|
660
678
|
const hasId = useUniqueId(id);
|
|
679
|
+
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
661
680
|
const tabindex = computed(() => isDisabled.value ? -1 : props.tabindex);
|
|
662
681
|
const input = ref();
|
|
663
682
|
const isBinary = computed(
|
|
@@ -752,7 +771,12 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
752
771
|
input.value.indeterminate = true;
|
|
753
772
|
}
|
|
754
773
|
});
|
|
755
|
-
const {
|
|
774
|
+
const {
|
|
775
|
+
HintSlot,
|
|
776
|
+
hasHintLabelOrSlot,
|
|
777
|
+
hasInvalidLabelOrSlot,
|
|
778
|
+
hintSlotScope
|
|
779
|
+
} = HintSlotFactory(props, slots);
|
|
756
780
|
return (_ctx, _cache) => {
|
|
757
781
|
return openBlock(), createElementBlock("label", {
|
|
758
782
|
class: normalizeClass(unref(bemCssClasses)),
|
|
@@ -769,7 +793,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
769
793
|
disabled: unref(isDisabled),
|
|
770
794
|
value: unref(hasValue),
|
|
771
795
|
tabindex: unref(tabindex),
|
|
772
|
-
"aria-invalid": unref(isInvalid)
|
|
796
|
+
"aria-invalid": unref(isInvalid),
|
|
797
|
+
"aria-describedby": unref(hasHintLabelOrSlot) ? unref(hasHintId) : void 0,
|
|
798
|
+
"aria-errormessage": unref(hasInvalidLabelOrSlot) ? unref(hasHintId) : void 0
|
|
773
799
|
}, null, 8, _hoisted_2$1), [
|
|
774
800
|
[vModelCheckbox, unref(localModelValue)]
|
|
775
801
|
]),
|
|
@@ -777,9 +803,38 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
777
803
|
createTextVNode(toDisplayString(_ctx.label), 1)
|
|
778
804
|
]),
|
|
779
805
|
createVNode(unref(HintSlot), {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
},
|
|
806
|
+
id: unref(hasHintId),
|
|
807
|
+
class: "vv-checkbox__hint"
|
|
808
|
+
}, createSlots({ _: 2 }, [
|
|
809
|
+
_ctx.$slots.hint ? {
|
|
810
|
+
name: "hint",
|
|
811
|
+
fn: withCtx(() => [
|
|
812
|
+
renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
813
|
+
]),
|
|
814
|
+
key: "0"
|
|
815
|
+
} : void 0,
|
|
816
|
+
_ctx.$slots.loading ? {
|
|
817
|
+
name: "loading",
|
|
818
|
+
fn: withCtx(() => [
|
|
819
|
+
renderSlot(_ctx.$slots, "loading", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
820
|
+
]),
|
|
821
|
+
key: "1"
|
|
822
|
+
} : void 0,
|
|
823
|
+
_ctx.$slots.valid ? {
|
|
824
|
+
name: "valid",
|
|
825
|
+
fn: withCtx(() => [
|
|
826
|
+
renderSlot(_ctx.$slots, "valid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
827
|
+
]),
|
|
828
|
+
key: "2"
|
|
829
|
+
} : void 0,
|
|
830
|
+
_ctx.$slots.invalid ? {
|
|
831
|
+
name: "invalid",
|
|
832
|
+
fn: withCtx(() => [
|
|
833
|
+
renderSlot(_ctx.$slots, "invalid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
834
|
+
]),
|
|
835
|
+
key: "3"
|
|
836
|
+
} : void 0
|
|
837
|
+
]), 1032, ["id"])
|
|
783
838
|
], 10, _hoisted_1$1);
|
|
784
839
|
};
|
|
785
840
|
}
|
|
@@ -801,7 +856,9 @@ function useOptions(props) {
|
|
|
801
856
|
const getOptionLabel = (option) => {
|
|
802
857
|
if (typeof option !== "object" && option !== null)
|
|
803
858
|
return option;
|
|
804
|
-
return
|
|
859
|
+
return String(
|
|
860
|
+
typeof labelKey.value === "function" ? labelKey.value(option) : option[labelKey.value]
|
|
861
|
+
);
|
|
805
862
|
};
|
|
806
863
|
const getOptionValue = (option) => {
|
|
807
864
|
if (typeof option !== "object" && option !== null)
|
|
@@ -868,7 +925,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
868
925
|
value: getOptionValue(option)
|
|
869
926
|
};
|
|
870
927
|
};
|
|
871
|
-
const { HintSlot } = HintSlotFactory(props, slots);
|
|
928
|
+
const { HintSlot, hintSlotScope } = HintSlotFactory(props, slots);
|
|
872
929
|
return (_ctx, _cache) => {
|
|
873
930
|
return openBlock(), createElementBlock("fieldset", {
|
|
874
931
|
class: normalizeClass(unref(bemCssClasses))
|
|
@@ -882,7 +939,36 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
882
939
|
return openBlock(), createBlock(_sfc_main$1, mergeProps({ key: index }, getOptionProps(option, index)), null, 16);
|
|
883
940
|
}), 128)) : renderSlot(_ctx.$slots, "default", { key: 1 })
|
|
884
941
|
]),
|
|
885
|
-
createVNode(unref(HintSlot), { class: "vv-checkbox-group__hint" }
|
|
942
|
+
createVNode(unref(HintSlot), { class: "vv-checkbox-group__hint" }, createSlots({ _: 2 }, [
|
|
943
|
+
_ctx.$slots.hint ? {
|
|
944
|
+
name: "hint",
|
|
945
|
+
fn: withCtx(() => [
|
|
946
|
+
renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
947
|
+
]),
|
|
948
|
+
key: "0"
|
|
949
|
+
} : void 0,
|
|
950
|
+
_ctx.$slots.loading ? {
|
|
951
|
+
name: "loading",
|
|
952
|
+
fn: withCtx(() => [
|
|
953
|
+
renderSlot(_ctx.$slots, "loading", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
954
|
+
]),
|
|
955
|
+
key: "1"
|
|
956
|
+
} : void 0,
|
|
957
|
+
_ctx.$slots.valid ? {
|
|
958
|
+
name: "valid",
|
|
959
|
+
fn: withCtx(() => [
|
|
960
|
+
renderSlot(_ctx.$slots, "valid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
961
|
+
]),
|
|
962
|
+
key: "2"
|
|
963
|
+
} : void 0,
|
|
964
|
+
_ctx.$slots.invalid ? {
|
|
965
|
+
name: "invalid",
|
|
966
|
+
fn: withCtx(() => [
|
|
967
|
+
renderSlot(_ctx.$slots, "invalid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
968
|
+
]),
|
|
969
|
+
key: "3"
|
|
970
|
+
} : void 0
|
|
971
|
+
]), 1024)
|
|
886
972
|
], 2);
|
|
887
973
|
};
|
|
888
974
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@vueuse/core"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","@vueuse/core","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvCheckboxGroup=l(e.vue,e.core,e.nanoid)}(this,(function(e,l,n){"use strict";var t=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(t||{}),a=(e=>(e.before="before",e.after="after",e))(a||{}),o=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(o||{});const u=Symbol.for("checkGroup");function i(e,l,n){return n?d(e,n)===d(l,n):r(e,l)}function r(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const n=Array.isArray(e),t=Array.isArray(l);let a,o,u;if(n&&t){if(o=e.length,o!=l.length)return!1;for(a=o;0!=a--;)if(!r(e[a],l[a]))return!1;return!0}if(n!=t)return!1;const i=e instanceof Date,d=l instanceof Date;if(i!=d)return!1;if(i&&d)return e.getTime()==l.getTime();const v=e instanceof RegExp,c=l instanceof RegExp;if(v!=c)return!1;if(v&&c)return e.toString()==l.toString();const s=Object.keys(e);if(o=s.length,o!==Object.keys(l).length)return!1;for(a=o;0!=a--;)if(!Object.prototype.hasOwnProperty.call(l,s[a]))return!1;for(a=o;0!=a--;)if(u=s[a],!r(e[u],l[u]))return!1;return!0}return e!=e&&l!=l}function d(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const n=l.split(".");let t=e;for(let l=0,a=n.length;l<a;++l){if(null==e)return null;t=t[n[l]]}return t}}return null}function v(l){return null==(n=e.unref(l))||""===n||Array.isArray(n)&&0===n.length||!(n instanceof Date)&&"object"==typeof n&&0===Object.keys(n).length;var n}function c(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}function s(n,t){const{invalid:a,valid:o,hint:u,loading:i}=t,{hintLabel:r,modelValue:s,valid:f,validLabel:p,invalid:m,invalidLabel:b,...y}=e.toRefs(n),g=d(y,"loading"),h=d(y,"loadingLabel"),k=e.computed((()=>!!m.value&&(!(!m.value||!a)||(!!((null==b?void 0:b.value)&&Array.isArray(b.value)&&b.value.length>0)||!(!(null==b?void 0:b.value)||v(b)))))),S=e.computed((()=>!!(r&&r.value||u))),V=e.computed((()=>!!(p&&p.value||o))),B=e.computed((()=>!!((null==g?void 0:g.value)&&i||(null==g?void 0:g.value)&&(null==h?void 0:h.value)))),A=e.computed((()=>S.value||V.value||k.value||B.value));return{hasInvalid:k,hasHint:S,hasValid:V,hasLoading:B,HintSlot:{name:"HintSlot",props:{params:{type:Object,default:()=>({})}},setup(n){const t=e.computed((()=>{const e=l.toReactive({hintLabel:r,modelValue:s,valid:f,validLabel:p,invalid:m,invalidLabel:b,loading:g,loadingLabel:h,...n.params});return(null==m?void 0:m.value)?(null==a?void 0:a(e))||c(null==b?void 0:b.value)||(null==r?void 0:r.value):(null==f?void 0:f.value)?(null==o?void 0:o(e))||c(null==p?void 0:p.value)||(null==r?void 0:r.value):(null==g?void 0:g.value)?(null==i?void 0:i(e))||c(null==h?void 0:h.value)||(null==r?void 0:r.value):(null==u?void 0:u(e))||c(null==r?void 0:r.value)||(null==r?void 0:r.value)}));return{isVisible:A,hasInvalid:k,hasValid:V,hintContent:t}},render(){if(this.isVisible)return e.h("small",{role:this.hasInvalid?"alert":this.hasValid?"status":void 0},this.hintContent)}}}}const f={valid:Boolean,validLabel:[String,Array]},p={invalid:Boolean,invalidLabel:[String,Array]},m={disabled:Boolean},b=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},g={modifiers:[String,Array]},h={hintLabel:{type:String,default:""}},k={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}};a.before;const S={tabindex:{type:[String,Number],default:0}},V={id:[String,Number]};t.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const B={...{...V,name:{type:String,required:!0}},...S,...f,...p,...h,...m,...y,...g,...b,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},A={...f,...p,...k,...h,...m,...y,...g,...b,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};o.button;const x={...B,...g,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function O(l,n){const{group:t,isInGroup:a,getGroupOrLocalRef:o}=function(l){const n=e.inject(l,void 0),t=e.computed((()=>!v(n)));return{group:n,isInGroup:t,getGroupOrLocalRef:function(l,t,a){if(null==n?void 0:n.value){const t=e.unref(n.value)[l];return e.computed({get:()=>null==t?void 0:t.value,set(e){t.value=e}})}const o=e.toRef(t,l);return e.computed({get:()=>o.value,set(e){a&&a(`update:${l}`,e)}})}}}(u),{id:i,switch:r,indeterminate:d}=e.toRefs(l),c=o("modelValue",l,n),s=o("valid",l),f=o("invalid",l),p=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==t?void 0:t.value)?void 0:e.readonly.value))})),m=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==t?void 0:t.value)?void 0:e.disabled.value))}));return{id:i,propsSwitch:r,indeterminate:d,group:t,isInGroup:a,modelValue:c,valid:s,invalid:f,readonly:p,disabled:m}}function j(l,n,t){return e.computed((()=>{const a={[l]:!0},o="string"==typeof(null==n?void 0:n.value)?n.value.split(" "):null==n?void 0:n.value;return o&&Array.isArray(o)&&o.forEach((e=>{e&&(a[`${l}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((n=>{a[`${l}--${n}`]=e.unref(t.value[n])})),a}))}const L=["for"],C=["id","name","disabled","value","tabindex","aria-invalid"],w=e.defineComponent({name:"VvCheckbox",props:x,emits:["click","update:modelValue","change","blur"],setup(l,{emit:t}){const a=l,o=e.useSlots(),{id:u,disabled:r,readonly:d,valid:v,invalid:c,propsSwitch:f,modelValue:p,indeterminate:m,isInGroup:b}=O(a,t),y=(l=>e.computed((()=>String((null==l?void 0:l.value)||n.nanoid()))))(u),g=e.computed((()=>S.value?-1:a.tabindex)),h=e.ref(),k=e.computed((()=>void 0!==a.uncheckedValue&&!b.value)),S=e.computed((()=>r.value||d.value)),V=e.computed((()=>!0===c.value||!0!==v.value&&void 0)),B=e.computed((()=>k.value?p.value===a.value:Array.isArray(p.value)?function(e,l){if(null!=e&&l&&l.length)for(const n of l)if(i(e,n))return!0;return!1}(a.value,p.value):i(a.value,p.value))),A=e.computed((()=>!!m.value||!(B.value||!k.value||a.uncheckedValue===p.value))),x=e.computed((()=>{if(!k.value)return!["string","number","boolean"].includes(typeof a.value)||a.value})),w=e.computed({get:()=>B.value,set(e){if(k.value)p.value=e?a.value:a.uncheckedValue;else if(Array.isArray(p.value)||b.value){const l=new Set(Array.isArray(p.value)?p.value:void 0!==p.value?[p.value]:[]);e?l.add(a.value):l.delete(a.value),p.value=[...l]}else p.value=e?a.value:void 0;t("change",e)}}),{modifiers:N}=e.toRefs(a),R=j("vv-checkbox",N,e.computed((()=>({switch:f.value,valid:v.value,invalid:c.value,disabled:r.value,readonly:d.value,indeterminate:m.value}))));e.watchEffect((()=>{k.value&&Array.isArray(p.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")})),e.watch((()=>A.value),(e=>{h.value.indeterminate=!!e})),e.onMounted((()=>{A.value&&(h.value.indeterminate=!0)}));const{HintSlot:E}=s(a,o);return(l,n)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(R)),for:e.unref(y)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(y),ref_key:"input",ref:h,"onUpdate:modelValue":n[0]||(n[0]=l=>e.isRef(w)?w.value=l:null),type:"checkbox",class:"vv-checkbox__input",name:l.name,disabled:e.unref(S),value:e.unref(x),tabindex:e.unref(g),"aria-invalid":e.unref(V)},null,8,C),[[e.vModelCheckbox,e.unref(w)]]),e.renderSlot(l.$slots,"default",{value:e.unref(p)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(E),{class:"vv-checkbox__hint",params:{value:e.unref(p)}},null,8,["params"])],10,L))}}),N=A;const R=["textContent"],E={class:"vv-checkbox-group__wrapper"};return e.defineComponent({name:"VvCheckboxGroup",props:N,emits:["update:modelValue","change"],setup(n,{emit:t}){const a=n,o=e.useSlots(),i=l.useVModel(a,"modelValue",t),{disabled:r,readonly:d,vertical:v,valid:c,invalid:f,modifiers:p}=e.toRefs(a);!function(l){if(Object.keys(l).some((n=>"key"!==n&&!e.isRef(l[n]))))throw Error("One or more groupState props aren't ref.");e.provide(l.key,e.computed((()=>l)))}({key:u,modelValue:i,disabled:r,readonly:d,valid:c,invalid:f});const{getOptionLabel:m,getOptionValue:b}=function(l){const{options:n,labelKey:t,valueKey:a,disabledKey:o}=e.toRefs(l);return{options:n,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:"function"==typeof t.value?t.value(e):e[t.value],getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof a.value?a.value(e):e[a.value],getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof o.value?o.value(e):e[o.value]),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(a),y=j("vv-checkbox-group",p,e.computed((()=>({disabled:r.value,readonly:d.value,horizontal:!v.value,valid:c.value,invalid:f.value})))),{HintSlot:g}=s(a,o);return(l,n)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(y))},[l.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(l.label)},null,8,R)):e.createCommentVNode("",!0),e.createElementVNode("div",E,[l.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.options,((l,n)=>(e.openBlock(),e.createBlock(w,e.mergeProps({key:n},((e,l)=>({id:`${a.name}_opt${l}`,name:a.name,label:m(e),value:b(e)}))(l,n)),null,16)))),128)):e.renderSlot(l.$slots,"default",{key:1})]),e.createVNode(e.unref(g),{class:"vv-checkbox-group__hint"})],2))}})}));
|
|
1
|
+
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","nanoid","@vueuse/core"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvCheckboxGroup=l(e.vue,e.nanoid,e.core)}(this,(function(e,l,t){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),o=(e=>(e.before="before",e.after="after",e))(o||{}),n=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(n||{});const i=Symbol.for("checkGroup");function r(e,l,t){return t?d(e,t)===d(l,t):u(e,l)}function u(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const t=Array.isArray(e),a=Array.isArray(l);let o,n,i;if(t&&a){if(n=e.length,n!=l.length)return!1;for(o=n;0!=o--;)if(!u(e[o],l[o]))return!1;return!0}if(t!=a)return!1;const r=e instanceof Date,d=l instanceof Date;if(r!=d)return!1;if(r&&d)return e.getTime()==l.getTime();const s=e instanceof RegExp,v=l instanceof RegExp;if(s!=v)return!1;if(s&&v)return e.toString()==l.toString();const c=Object.keys(e);if(n=c.length,n!==Object.keys(l).length)return!1;for(o=n;0!=o--;)if(!Object.prototype.hasOwnProperty.call(l,c[o]))return!1;for(o=n;0!=o--;)if(i=c[o],!u(e[i],l[i]))return!1;return!0}return e!=e&&l!=l}function d(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const t=l.split(".");let a=e;for(let l=0,o=t.length;l<o;++l){if(null==e)return null;a=a[t[l]]}return a}}return null}function s(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}function v(l,t){const a=e.computed((()=>s(l.invalidLabel))),o=e.computed((()=>s(l.validLabel))),n=e.computed((()=>l.loadingLabel)),i=e.computed((()=>l.hintLabel)),r=e.computed((()=>Boolean(l.loading&&(t.loading||n.value)))),u=e.computed((()=>!r.value&&Boolean(l.invalid&&(t.invalid||a.value)))),d=e.computed((()=>!r.value&&!u.value&&Boolean(l.valid&&(t.valid||o.value)))),v=e.computed((()=>!r.value&&!u.value&&!d.value&&Boolean(t.hint||i.value))),c=e.computed((()=>u.value||d.value||r.value||v.value)),f=e.computed((()=>({modelValue:l.modelValue,valid:l.valid,invalid:l.invalid,loading:l.loading}))),p=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:c,invalidLabel:a,validLabel:o,loadingLabel:n,hintLabel:i,hasInvalidLabelOrSlot:u,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hasHintLabelOrSlot:v}),render(){var l,t,a,o,n,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(t=(l=this.$slots).loading)?void 0:t.call(l))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(o=(a=this.$slots).invalid)?void 0:o.call(a))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:u,hasHintLabelOrSlot:v,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hintSlotScope:f,HintSlot:p}}const c={valid:Boolean,validLabel:[String,Array]},f={invalid:Boolean,invalidLabel:[String,Array]},p={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},m={disabled:Boolean},b=(Boolean,Boolean,{label:[String,Number]}),h={readonly:Boolean},g={modifiers:[String,Array]},y={hintLabel:{type:String,default:""}},S={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}};o.before;const k={tabindex:{type:[String,Number],default:0}},L={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const B={...{...L,name:{type:String,required:!0}},...k,...c,...f,...y,...m,...h,...g,...b,...p,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},V={...c,...f,...S,...y,...m,...h,...g,...b,...p,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};function O(l){const t=e.inject(l,void 0),a=e.computed((()=>{return l=t,!(null==(a=e.unref(l))||""===a||Array.isArray(a)&&0===a.length||!(a instanceof Date)&&"object"==typeof a&&0===Object.keys(a).length);var l,a}));return{group:t,isInGroup:a,getGroupOrLocalRef:function(l,a,o){if(null==t?void 0:t.value){const a=e.unref(t.value)[l];return e.computed({get:()=>null==a?void 0:a.value,set(e){a.value=e}})}const n=e.toRef(a,l);return e.computed({get:()=>n.value,set(e){o&&o(`update:${l}`,e)}})}}}n.button;const x={...B,...g,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function $(l,t,a){return e.computed((()=>{const o={[l]:!0},n="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(o[`${l}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((t=>{o[`${l}--${t}`]=e.unref(a.value[t])})),o}))}const A=["for"],w=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],C=e.defineComponent({name:"VvCheckbox",props:x,emits:["click","update:modelValue","change","blur"],setup(t,{emit:a}){const o=t,n=e.useSlots(),{id:u,disabled:d,readonly:s,valid:c,invalid:f,propsSwitch:p,modelValue:m,indeterminate:b,isInGroup:h}=function(l,t){const{group:a,isInGroup:o,getGroupOrLocalRef:n}=O(i),{id:r,switch:u,indeterminate:d}=e.toRefs(l),s=n("modelValue",l,t),v=n("valid",l),c=n("invalid",l),f=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==a?void 0:a.value)?void 0:e.readonly.value))})),p=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==a?void 0:a.value)?void 0:e.disabled.value))}));return{id:r,propsSwitch:u,indeterminate:d,group:a,isInGroup:o,modelValue:s,valid:v,invalid:c,readonly:f,disabled:p}}(o,a),g=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(u),y=e.computed((()=>`${g.value}-hint`)),S=e.computed((()=>B.value?-1:o.tabindex)),k=e.ref(),L=e.computed((()=>void 0!==o.uncheckedValue&&!h.value)),B=e.computed((()=>d.value||s.value)),V=e.computed((()=>!0===f.value||!0!==c.value&&void 0)),x=e.computed((()=>L.value?m.value===o.value:Array.isArray(m.value)?function(e,l){if(null!=e&&l&&l.length)for(const t of l)if(r(e,t))return!0;return!1}(o.value,m.value):r(o.value,m.value))),C=e.computed((()=>!!b.value||!(x.value||!L.value||o.uncheckedValue===m.value))),R=e.computed((()=>{if(!L.value)return!["string","number","boolean"].includes(typeof o.value)||o.value})),j=e.computed({get:()=>x.value,set(e){if(L.value)m.value=e?o.value:o.uncheckedValue;else if(Array.isArray(m.value)||h.value){const l=new Set(Array.isArray(m.value)?m.value:void 0!==m.value?[m.value]:[]);e?l.add(o.value):l.delete(o.value),m.value=[...l]}else m.value=e?o.value:void 0;a("change",e)}}),{modifiers:P}=e.toRefs(o),N=$("vv-checkbox",P,e.computed((()=>({switch:p.value,valid:c.value,invalid:f.value,disabled:d.value,readonly:s.value,indeterminate:b.value}))));e.watchEffect((()=>{L.value&&Array.isArray(m.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")})),e.watch((()=>C.value),(e=>{k.value.indeterminate=!!e})),e.onMounted((()=>{C.value&&(k.value.indeterminate=!0)}));const{HintSlot:E,hasHintLabelOrSlot:_,hasInvalidLabelOrSlot:z,hintSlotScope:G}=v(o,n);return(l,t)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(N)),for:e.unref(g)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(g),ref_key:"input",ref:k,"onUpdate:modelValue":t[0]||(t[0]=l=>e.isRef(j)?j.value=l:null),type:"checkbox",class:"vv-checkbox__input",name:l.name,disabled:e.unref(B),value:e.unref(R),tabindex:e.unref(S),"aria-invalid":e.unref(V),"aria-describedby":e.unref(_)?e.unref(y):void 0,"aria-errormessage":e.unref(z)?e.unref(y):void 0},null,8,w),[[e.vModelCheckbox,e.unref(j)]]),e.renderSlot(l.$slots,"default",{value:e.unref(m)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(E),{id:e.unref(y),class:"vv-checkbox__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"3"}:void 0]),1032,["id"])],10,A))}}),R=V;const j=["textContent"],P={class:"vv-checkbox-group__wrapper"};return e.defineComponent({name:"VvCheckboxGroup",props:R,emits:["update:modelValue","change"],setup(l,{emit:a}){const o=l,n=e.useSlots(),r=t.useVModel(o,"modelValue",a),{disabled:u,readonly:d,vertical:s,valid:c,invalid:f,modifiers:p}=e.toRefs(o);!function(l){if(Object.keys(l).some((t=>"key"!==t&&!e.isRef(l[t]))))throw Error("One or more groupState props aren't ref.");e.provide(l.key,e.computed((()=>l)))}({key:i,modelValue:r,disabled:u,readonly:d,valid:c,invalid:f});const{getOptionLabel:m,getOptionValue:b}=function(l){const{options:t,labelKey:a,valueKey:o,disabledKey:n}=e.toRefs(l);return{options:t,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:String("function"==typeof a.value?a.value(e):e[a.value]),getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof o.value?o.value(e):e[o.value],getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof n.value?n.value(e):e[n.value]),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(o),h=$("vv-checkbox-group",p,e.computed((()=>({disabled:u.value,readonly:d.value,horizontal:!s.value,valid:c.value,invalid:f.value})))),{HintSlot:g,hintSlotScope:y}=v(o,n);return(l,t)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(h))},[l.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(l.label)},null,8,j)):e.createCommentVNode("",!0),e.createElementVNode("div",P,[l.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.options,((l,t)=>(e.openBlock(),e.createBlock(C,e.mergeProps({key:t},((e,l)=>({id:`${o.name}_opt${l}`,name:o.name,label:m(e),value:b(e)}))(l,t)),null,16)))),128)):e.renderSlot(l.$slots,"default",{key:1})]),e.createVNode(e.unref(g),{class:"vv-checkbox-group__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"3"}:void 0]),1024)],2))}})}));
|
|
@@ -6,6 +6,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
6
6
|
required: boolean;
|
|
7
7
|
};
|
|
8
8
|
vertical: BooleanConstructor;
|
|
9
|
+
loading: BooleanConstructor;
|
|
10
|
+
loadingLabel: {
|
|
11
|
+
type: StringConstructor;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
9
14
|
label: (StringConstructor | NumberConstructor)[];
|
|
10
15
|
modifiers: globalThis.PropType<string | string[]>;
|
|
11
16
|
readonly: BooleanConstructor;
|
|
@@ -41,6 +46,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
41
46
|
required: boolean;
|
|
42
47
|
};
|
|
43
48
|
vertical: BooleanConstructor;
|
|
49
|
+
loading: BooleanConstructor;
|
|
50
|
+
loadingLabel: {
|
|
51
|
+
type: StringConstructor;
|
|
52
|
+
default: string;
|
|
53
|
+
};
|
|
44
54
|
label: (StringConstructor | NumberConstructor)[];
|
|
45
55
|
modifiers: globalThis.PropType<string | string[]>;
|
|
46
56
|
readonly: BooleanConstructor;
|
|
@@ -74,6 +84,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
74
84
|
}, {
|
|
75
85
|
disabled: boolean;
|
|
76
86
|
options: (string | Option)[];
|
|
87
|
+
loading: boolean;
|
|
88
|
+
loadingLabel: string;
|
|
77
89
|
readonly: boolean;
|
|
78
90
|
hintLabel: string;
|
|
79
91
|
invalid: boolean;
|
|
@@ -84,6 +96,30 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
84
96
|
disabledKey: string | Function;
|
|
85
97
|
}>, {
|
|
86
98
|
default: (_: {}) => any;
|
|
99
|
+
hint: (_: {
|
|
100
|
+
modelValue: any;
|
|
101
|
+
valid: boolean;
|
|
102
|
+
invalid: boolean;
|
|
103
|
+
loading: boolean;
|
|
104
|
+
}) => any;
|
|
105
|
+
loading: (_: {
|
|
106
|
+
modelValue: any;
|
|
107
|
+
valid: boolean;
|
|
108
|
+
invalid: boolean;
|
|
109
|
+
loading: boolean;
|
|
110
|
+
}) => any;
|
|
111
|
+
valid: (_: {
|
|
112
|
+
modelValue: any;
|
|
113
|
+
valid: boolean;
|
|
114
|
+
invalid: boolean;
|
|
115
|
+
loading: boolean;
|
|
116
|
+
}) => any;
|
|
117
|
+
invalid: (_: {
|
|
118
|
+
modelValue: any;
|
|
119
|
+
valid: boolean;
|
|
120
|
+
invalid: boolean;
|
|
121
|
+
loading: boolean;
|
|
122
|
+
}) => any;
|
|
87
123
|
}>;
|
|
88
124
|
export default _default;
|
|
89
125
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
@@ -5,6 +5,11 @@ export declare const VvCheckboxGroupProps: {
|
|
|
5
5
|
required: boolean;
|
|
6
6
|
};
|
|
7
7
|
vertical: BooleanConstructor;
|
|
8
|
+
loading: BooleanConstructor;
|
|
9
|
+
loadingLabel: {
|
|
10
|
+
type: StringConstructor;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
8
13
|
label: (StringConstructor | NumberConstructor)[];
|
|
9
14
|
modifiers: globalThis.PropType<string | string[]>;
|
|
10
15
|
readonly: BooleanConstructor;
|