@vuecs/forms 5.0.0 → 5.1.0
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/form-checkbox/FormCheckbox.vue.d.ts.map +1 -1
- package/dist/components/form-checkbox-group/FormCheckboxGroup.vue.d.ts.map +1 -1
- package/dist/components/form-group/FormGroup.vue.d.ts.map +1 -1
- package/dist/components/form-group/context.d.ts +46 -0
- package/dist/components/form-group/context.d.ts.map +1 -0
- package/dist/components/form-group/index.d.ts +2 -0
- package/dist/components/form-group/index.d.ts.map +1 -1
- package/dist/components/form-input/FormInput.vue.d.ts +30 -10
- package/dist/components/form-input/FormInput.vue.d.ts.map +1 -1
- package/dist/components/form-number/FormNumber.vue.d.ts.map +1 -1
- package/dist/components/form-pin/FormPin.vue.d.ts.map +1 -1
- package/dist/components/form-radio/FormRadio.vue.d.ts.map +1 -1
- package/dist/components/form-radio-group/FormRadioGroup.vue.d.ts.map +1 -1
- package/dist/components/form-select/FormSelect.vue.d.ts.map +1 -1
- package/dist/components/form-select-search/FormSelectSearch.vue.d.ts.map +1 -1
- package/dist/components/form-slider/FormSlider.vue.d.ts.map +1 -1
- package/dist/components/form-switch/FormSwitch.vue.d.ts.map +1 -1
- package/dist/components/form-tags/FormTags.vue.d.ts.map +1 -1
- package/dist/components/form-textarea/FormTextarea.vue.d.ts +30 -10
- package/dist/components/form-textarea/FormTextarea.vue.d.ts.map +1 -1
- package/dist/components/validation-group/ValidationGroup.vue.d.ts +1 -1
- package/dist/components/validation-group/ValidationGroup.vue.d.ts.map +1 -1
- package/dist/index.mjs +82 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,46 @@
|
|
|
1
|
-
import { installDefaultsManager, installThemeManager, useComponentDefaults, useComponentTheme, useId } from "@vuecs/core";
|
|
1
|
+
import { installDefaultsManager, installThemeManager, useComponentDefaults, useComponentTheme, useId, useThemeProps } from "@vuecs/core";
|
|
2
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, h, inject, mergeProps, normalizeClass, openBlock, provide, ref, renderList, renderSlot, resolveComponent, toDisplayString, toRef, toValue, vModelText, vShow, watch, withCtx, withDirectives } from "vue";
|
|
2
3
|
import { CheckboxGroupRoot, CheckboxIndicator, CheckboxRoot, NumberFieldDecrement, NumberFieldIncrement, NumberFieldInput, NumberFieldRoot, PinInputInput, PinInputRoot, RadioGroupIndicator, RadioGroupItem, RadioGroupRoot, SelectContent, SelectGroup, SelectIcon, SelectItem, SelectItemIndicator, SelectItemText, SelectLabel, SelectPortal, SelectRoot, SelectTrigger, SelectValue, SelectViewport, SliderRange, SliderRoot, SliderThumb, SliderTrack, SwitchRoot, SwitchThumb, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText, TagsInputRoot } from "reka-ui";
|
|
3
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, h, mergeProps, normalizeClass, openBlock, ref, renderList, renderSlot, resolveComponent, toDisplayString, toRef, toValue, vModelText, vShow, watch, withCtx, withDirectives } from "vue";
|
|
4
4
|
import { onClickOutside, useDebounceFn, useInfiniteScroll } from "@vueuse/core";
|
|
5
|
+
//#region src/components/form-group/context.ts
|
|
6
|
+
const FORM_GROUP_CONTEXT_KEY = Symbol("vcFormGroupContext");
|
|
7
|
+
function provideFormGroupContext(ctx) {
|
|
8
|
+
provide(FORM_GROUP_CONTEXT_KEY, ctx);
|
|
9
|
+
}
|
|
10
|
+
function useFormGroupContext() {
|
|
11
|
+
return inject(FORM_GROUP_CONTEXT_KEY, null);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Wrap a form-input component's props so that any inherited severity
|
|
15
|
+
* from the surrounding `<VCFormGroup>` flows into `themeVariant.severity`
|
|
16
|
+
* — lighting up the theme's `severity` variant on the input without
|
|
17
|
+
* the consumer wiring it per-instance.
|
|
18
|
+
*
|
|
19
|
+
* Per-instance values win: if the caller's `themeVariant` already has
|
|
20
|
+
* a `severity` key (even one set to `undefined`), the inherited value
|
|
21
|
+
* is ignored. Outside a `<VCFormGroup>` the helper is a pass-through.
|
|
22
|
+
*
|
|
23
|
+
* Pass directly to `useComponentTheme(name, useFormInputThemeProps(props), defaults)`.
|
|
24
|
+
*/
|
|
25
|
+
function useFormInputThemeProps(props) {
|
|
26
|
+
const ctx = useFormGroupContext();
|
|
27
|
+
return {
|
|
28
|
+
get themeClass() {
|
|
29
|
+
return props.themeClass;
|
|
30
|
+
},
|
|
31
|
+
get themeVariant() {
|
|
32
|
+
const own = props.themeVariant;
|
|
33
|
+
if (own && "severity" in own) return own;
|
|
34
|
+
const inherited = ctx?.severity();
|
|
35
|
+
if (inherited === void 0) return own;
|
|
36
|
+
return {
|
|
37
|
+
...own ?? {},
|
|
38
|
+
severity: inherited
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
5
44
|
//#region src/components/form-checkbox/FormCheckbox.vue?vue&type=script&lang.ts
|
|
6
45
|
const formCheckboxThemeDefaults = { classes: {
|
|
7
46
|
root: "vc-form-checkbox",
|
|
@@ -79,7 +118,7 @@ var FormCheckbox_default = defineComponent({
|
|
|
79
118
|
emits: ["update:modelValue"],
|
|
80
119
|
slots: Object,
|
|
81
120
|
setup(props, { attrs, emit, slots }) {
|
|
82
|
-
const theme = useComponentTheme("formCheckbox", props, formCheckboxThemeDefaults);
|
|
121
|
+
const theme = useComponentTheme("formCheckbox", useFormInputThemeProps(props), formCheckboxThemeDefaults);
|
|
83
122
|
const defaults = useComponentDefaults("formCheckbox", props, behavioralDefaults$3);
|
|
84
123
|
const fallbackId = useId(void 0, "vc-form-checkbox");
|
|
85
124
|
return () => {
|
|
@@ -165,7 +204,7 @@ var FormCheckboxGroup_default = defineComponent({
|
|
|
165
204
|
},
|
|
166
205
|
emits: ["update:modelValue"],
|
|
167
206
|
setup(props, { attrs, emit, slots }) {
|
|
168
|
-
const theme = useComponentTheme("formCheckboxGroup", props, formCheckboxGroupThemeDefaults);
|
|
207
|
+
const theme = useComponentTheme("formCheckboxGroup", useFormInputThemeProps(props), formCheckboxGroupThemeDefaults);
|
|
169
208
|
return () => h(CheckboxGroupRoot, mergeProps(attrs, {
|
|
170
209
|
name: props.name,
|
|
171
210
|
orientation: props.orientation,
|
|
@@ -234,7 +273,7 @@ var ValidationGroup_default = defineComponent({
|
|
|
234
273
|
},
|
|
235
274
|
slots: Object,
|
|
236
275
|
setup(props, { slots }) {
|
|
237
|
-
const theme = useComponentTheme("validationGroup", props, validationGroupThemeDefaults);
|
|
276
|
+
const theme = useComponentTheme("validationGroup", useThemeProps(props, "severity"), validationGroupThemeDefaults);
|
|
238
277
|
return () => {
|
|
239
278
|
const resolved = theme.value;
|
|
240
279
|
let errors;
|
|
@@ -358,6 +397,12 @@ var FormGroup_default = defineComponent({
|
|
|
358
397
|
slots: Object,
|
|
359
398
|
setup(props, { attrs, slots }) {
|
|
360
399
|
const theme = useComponentTheme("formGroup", props, formGroupThemeDefaults);
|
|
400
|
+
provideFormGroupContext({ severity: () => {
|
|
401
|
+
if (props.validation != null) return props.validation.severity;
|
|
402
|
+
if (props.validationSeverity !== void 0) return props.validationSeverity;
|
|
403
|
+
const messages = props.validationMessages;
|
|
404
|
+
return !!messages && (Array.isArray(messages) ? messages.length > 0 : Object.keys(messages).length > 0) ? "error" : void 0;
|
|
405
|
+
} });
|
|
361
406
|
return () => {
|
|
362
407
|
const resolved = theme.value;
|
|
363
408
|
const children = [];
|
|
@@ -407,11 +452,16 @@ var FormInput_default = defineComponent({
|
|
|
407
452
|
name: "VCFormInput",
|
|
408
453
|
inheritAttrs: false,
|
|
409
454
|
props: {
|
|
410
|
-
/**
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
455
|
+
/**
|
|
456
|
+
* Controlled string value (v-model). `null` is the documented "unset" value.
|
|
457
|
+
*
|
|
458
|
+
* No `default` on purpose: vue-tsc strips `null`/`undefined` (via `NonNullable`)
|
|
459
|
+
* when folding a prop default into the emitted `DefaultProps`, which then
|
|
460
|
+
* intersects `$props['modelValue']` back down to `string` and breaks v-model
|
|
461
|
+
* against nullable entity fields (#1613). The render coerces `null`/`undefined`
|
|
462
|
+
* to `''`, so the empty-input behaviour is unchanged.
|
|
463
|
+
*/
|
|
464
|
+
modelValue: { type: [String, null] },
|
|
415
465
|
/** Native `<input type>` attribute. */
|
|
416
466
|
type: {
|
|
417
467
|
type: String,
|
|
@@ -461,7 +511,7 @@ var FormInput_default = defineComponent({
|
|
|
461
511
|
emits: ["update:modelValue"],
|
|
462
512
|
slots: Object,
|
|
463
513
|
setup(props, { attrs, emit, slots }) {
|
|
464
|
-
const theme = useComponentTheme("formInput", props, formInputThemeDefaults);
|
|
514
|
+
const theme = useComponentTheme("formInput", useFormInputThemeProps(props), formInputThemeDefaults);
|
|
465
515
|
const localValue = ref(props.modelValue);
|
|
466
516
|
watch(() => props.modelValue, (value) => {
|
|
467
517
|
localValue.value = value;
|
|
@@ -592,7 +642,7 @@ var FormNumber_default = defineComponent({
|
|
|
592
642
|
},
|
|
593
643
|
emits: ["update:modelValue"],
|
|
594
644
|
setup(props, { attrs, emit }) {
|
|
595
|
-
const theme = useComponentTheme("formNumber", props, formNumberThemeDefaults);
|
|
645
|
+
const theme = useComponentTheme("formNumber", useFormInputThemeProps(props), formNumberThemeDefaults);
|
|
596
646
|
return () => h(NumberFieldRoot, mergeProps(attrs, {
|
|
597
647
|
focusOnChange: props.focusOnChange,
|
|
598
648
|
name: props.name,
|
|
@@ -692,7 +742,7 @@ var FormPin_default = defineComponent({
|
|
|
692
742
|
},
|
|
693
743
|
emits: ["update:modelValue", "complete"],
|
|
694
744
|
setup(props, { attrs, emit }) {
|
|
695
|
-
const theme = useComponentTheme("formPin", props, formPinThemeDefaults);
|
|
745
|
+
const theme = useComponentTheme("formPin", useFormInputThemeProps(props), formPinThemeDefaults);
|
|
696
746
|
return () => h(PinInputRoot, mergeProps(attrs, {
|
|
697
747
|
name: props.name,
|
|
698
748
|
id: props.id,
|
|
@@ -781,7 +831,7 @@ var FormRadio_default = defineComponent({
|
|
|
781
831
|
},
|
|
782
832
|
slots: Object,
|
|
783
833
|
setup(props, { attrs, slots }) {
|
|
784
|
-
const theme = useComponentTheme("formRadio", props, formRadioThemeDefaults);
|
|
834
|
+
const theme = useComponentTheme("formRadio", useFormInputThemeProps(props), formRadioThemeDefaults);
|
|
785
835
|
const defaults = useComponentDefaults("formRadio", props, behavioralDefaults$2);
|
|
786
836
|
const fallbackId = useId(void 0, "vc-form-radio");
|
|
787
837
|
return () => {
|
|
@@ -870,7 +920,7 @@ var FormRadioGroup_default = defineComponent({
|
|
|
870
920
|
},
|
|
871
921
|
emits: ["update:modelValue"],
|
|
872
922
|
setup(props, { attrs, emit, slots }) {
|
|
873
|
-
const theme = useComponentTheme("formRadioGroup", props, formRadioGroupThemeDefaults);
|
|
923
|
+
const theme = useComponentTheme("formRadioGroup", useFormInputThemeProps(props), formRadioGroupThemeDefaults);
|
|
874
924
|
return () => h(RadioGroupRoot, mergeProps(attrs, {
|
|
875
925
|
name: props.name,
|
|
876
926
|
orientation: props.orientation,
|
|
@@ -975,7 +1025,7 @@ var FormSelect_default = defineComponent({
|
|
|
975
1025
|
},
|
|
976
1026
|
emits: ["update:modelValue"],
|
|
977
1027
|
setup(props, { attrs, emit }) {
|
|
978
|
-
const theme = useComponentTheme("formSelect", props, formSelectThemeDefaults);
|
|
1028
|
+
const theme = useComponentTheme("formSelect", useFormInputThemeProps(props), formSelectThemeDefaults);
|
|
979
1029
|
const defaults = useComponentDefaults("formSelect", props, behavioralDefaults$1);
|
|
980
1030
|
return () => {
|
|
981
1031
|
const resolved = theme.value;
|
|
@@ -1113,7 +1163,7 @@ var FormSelectSearch_vue_vue_type_script_lang_default = defineComponent({
|
|
|
1113
1163
|
},
|
|
1114
1164
|
emits: ["update:modelValue", "change"],
|
|
1115
1165
|
setup(props, { emit }) {
|
|
1116
|
-
const theme = useComponentTheme("formSelectSearch", props, formSelectSearchThemeDefaults);
|
|
1166
|
+
const theme = useComponentTheme("formSelectSearch", useFormInputThemeProps(props), formSelectSearchThemeDefaults);
|
|
1117
1167
|
const listElement = ref(null);
|
|
1118
1168
|
const inputElement = ref(null);
|
|
1119
1169
|
const q = ref("");
|
|
@@ -1416,7 +1466,7 @@ var FormSlider_default = defineComponent({
|
|
|
1416
1466
|
},
|
|
1417
1467
|
emits: ["update:modelValue", "valueCommit"],
|
|
1418
1468
|
setup(props, { attrs, emit }) {
|
|
1419
|
-
const theme = useComponentTheme("formSlider", props, formSliderThemeDefaults);
|
|
1469
|
+
const theme = useComponentTheme("formSlider", useFormInputThemeProps(props), formSliderThemeDefaults);
|
|
1420
1470
|
const isScalar = computed(() => typeof props.modelValue === "number");
|
|
1421
1471
|
const internalValue = computed(() => {
|
|
1422
1472
|
if (props.modelValue === void 0 || props.modelValue === null) return [props.min];
|
|
@@ -1519,7 +1569,7 @@ var FormSwitch_default = defineComponent({
|
|
|
1519
1569
|
emits: ["update:modelValue"],
|
|
1520
1570
|
slots: Object,
|
|
1521
1571
|
setup(props, { attrs, emit, slots }) {
|
|
1522
|
-
const theme = useComponentTheme("formSwitch", props, formSwitchThemeDefaults);
|
|
1572
|
+
const theme = useComponentTheme("formSwitch", useFormInputThemeProps(props), formSwitchThemeDefaults);
|
|
1523
1573
|
const defaults = useComponentDefaults("formSwitch", props, behavioralDefaults);
|
|
1524
1574
|
const fallbackId = useId(void 0, "vc-form-switch");
|
|
1525
1575
|
return () => {
|
|
@@ -1636,7 +1686,7 @@ var FormTags_default = defineComponent({
|
|
|
1636
1686
|
},
|
|
1637
1687
|
emits: ["update:modelValue", "invalid"],
|
|
1638
1688
|
setup(props, { attrs, emit }) {
|
|
1639
|
-
const theme = useComponentTheme("formTags", props, formTagsThemeDefaults);
|
|
1689
|
+
const theme = useComponentTheme("formTags", useFormInputThemeProps(props), formTagsThemeDefaults);
|
|
1640
1690
|
return () => h(TagsInputRoot, mergeProps(attrs, {
|
|
1641
1691
|
placeholder: props.placeholder,
|
|
1642
1692
|
addOnBlur: props.addOnBlur,
|
|
@@ -1671,11 +1721,16 @@ const formTextareaThemeDefaults = { classes: { root: "" } };
|
|
|
1671
1721
|
var FormTextarea_default = defineComponent({
|
|
1672
1722
|
name: "VCFormTextarea",
|
|
1673
1723
|
props: {
|
|
1674
|
-
/**
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1724
|
+
/**
|
|
1725
|
+
* Controlled string value (v-model). `null` is the documented "unset" value.
|
|
1726
|
+
*
|
|
1727
|
+
* No `default` on purpose: vue-tsc strips `null`/`undefined` (via `NonNullable`)
|
|
1728
|
+
* when folding a prop default into the emitted `DefaultProps`, which then
|
|
1729
|
+
* intersects `$props['modelValue']` back down to `string` and breaks v-model
|
|
1730
|
+
* against nullable entity fields (#1613). The render coerces `null`/`undefined`
|
|
1731
|
+
* to `''`, so the empty-textarea behaviour is unchanged.
|
|
1732
|
+
*/
|
|
1733
|
+
modelValue: { type: [String, null] },
|
|
1679
1734
|
/** Debounce window (ms) for `update:modelValue` emissions. `0` disables debouncing. */
|
|
1680
1735
|
debounce: {
|
|
1681
1736
|
type: Number,
|
|
@@ -1694,7 +1749,7 @@ var FormTextarea_default = defineComponent({
|
|
|
1694
1749
|
},
|
|
1695
1750
|
emits: ["update:modelValue"],
|
|
1696
1751
|
setup(props, { attrs, emit }) {
|
|
1697
|
-
const theme = useComponentTheme("formTextarea", props, formTextareaThemeDefaults);
|
|
1752
|
+
const theme = useComponentTheme("formTextarea", useFormInputThemeProps(props), formTextareaThemeDefaults);
|
|
1698
1753
|
const localValue = ref(props.modelValue);
|
|
1699
1754
|
watch(() => props.modelValue, (value) => {
|
|
1700
1755
|
localValue.value = value;
|
|
@@ -1794,6 +1849,6 @@ function install(instance, options = {}) {
|
|
|
1794
1849
|
}
|
|
1795
1850
|
var src_default = { install };
|
|
1796
1851
|
//#endregion
|
|
1797
|
-
export { FormCheckbox_default as VCFormCheckbox, FormCheckboxGroup_default as VCFormCheckboxGroup, FormGroup_default as VCFormGroup, FormInput_default as VCFormInput, FormNumber_default as VCFormNumber, FormPin_default as VCFormPin, FormRadio_default as VCFormRadio, FormRadioGroup_default as VCFormRadioGroup, FormSelect_default as VCFormSelect, FormSelectSearch_default as VCFormSelectSearch, FormSlider_default as VCFormSlider, FormSwitch_default as VCFormSwitch, FormTags_default as VCFormTags, FormTextarea_default as VCFormTextarea, ValidationGroup_default as VCValidationGroup, ValidationSeverity, src_default as default, formCheckboxGroupThemeDefaults, formCheckboxThemeDefaults, formGroupThemeDefaults, formInputThemeDefaults, formNumberThemeDefaults, formPinThemeDefaults, formRadioGroupThemeDefaults, formRadioThemeDefaults, formSelectSearchThemeDefaults, formSelectThemeDefaults, formSliderThemeDefaults, formSwitchThemeDefaults, formTagsThemeDefaults, formTextareaThemeDefaults, install, isFormOptionGroup, useSubmitButton, validationGroupThemeDefaults };
|
|
1852
|
+
export { FormCheckbox_default as VCFormCheckbox, FormCheckboxGroup_default as VCFormCheckboxGroup, FormGroup_default as VCFormGroup, FormInput_default as VCFormInput, FormNumber_default as VCFormNumber, FormPin_default as VCFormPin, FormRadio_default as VCFormRadio, FormRadioGroup_default as VCFormRadioGroup, FormSelect_default as VCFormSelect, FormSelectSearch_default as VCFormSelectSearch, FormSlider_default as VCFormSlider, FormSwitch_default as VCFormSwitch, FormTags_default as VCFormTags, FormTextarea_default as VCFormTextarea, ValidationGroup_default as VCValidationGroup, ValidationSeverity, src_default as default, formCheckboxGroupThemeDefaults, formCheckboxThemeDefaults, formGroupThemeDefaults, formInputThemeDefaults, formNumberThemeDefaults, formPinThemeDefaults, formRadioGroupThemeDefaults, formRadioThemeDefaults, formSelectSearchThemeDefaults, formSelectThemeDefaults, formSliderThemeDefaults, formSwitchThemeDefaults, formTagsThemeDefaults, formTextareaThemeDefaults, install, isFormOptionGroup, provideFormGroupContext, useFormGroupContext, useFormInputThemeProps, useSubmitButton, validationGroupThemeDefaults };
|
|
1798
1853
|
|
|
1799
1854
|
//# sourceMappingURL=index.mjs.map
|