base-ui-vue 0.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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/button/Button.cjs +524 -0
- package/dist/button/Button.cjs.map +1 -0
- package/dist/button/Button.js +453 -0
- package/dist/button/Button.js.map +1 -0
- package/dist/composite/composite.cjs +56 -0
- package/dist/composite/composite.cjs.map +1 -0
- package/dist/composite/composite.js +21 -0
- package/dist/composite/composite.js.map +1 -0
- package/dist/control/FieldControl.cjs +576 -0
- package/dist/control/FieldControl.cjs.map +1 -0
- package/dist/control/FieldControl.js +511 -0
- package/dist/control/FieldControl.js.map +1 -0
- package/dist/control/FieldControlDataAttributes.cjs +42 -0
- package/dist/control/FieldControlDataAttributes.cjs.map +1 -0
- package/dist/control/FieldControlDataAttributes.js +36 -0
- package/dist/control/FieldControlDataAttributes.js.map +1 -0
- package/dist/description/FieldDescription.cjs +86 -0
- package/dist/description/FieldDescription.cjs.map +1 -0
- package/dist/description/FieldDescription.js +81 -0
- package/dist/description/FieldDescription.js.map +1 -0
- package/dist/direction-provider/DirectionContext.cjs +26 -0
- package/dist/direction-provider/DirectionContext.cjs.map +1 -0
- package/dist/direction-provider/DirectionContext.js +15 -0
- package/dist/direction-provider/DirectionContext.js.map +1 -0
- package/dist/direction-provider/DirectionProvider.cjs +37 -0
- package/dist/direction-provider/DirectionProvider.cjs.map +1 -0
- package/dist/direction-provider/DirectionProvider.js +32 -0
- package/dist/direction-provider/DirectionProvider.js.map +1 -0
- package/dist/error/FieldError.cjs +414 -0
- package/dist/error/FieldError.cjs.map +1 -0
- package/dist/error/FieldError.js +373 -0
- package/dist/error/FieldError.js.map +1 -0
- package/dist/fallback/AvatarFallback.cjs +165 -0
- package/dist/fallback/AvatarFallback.cjs.map +1 -0
- package/dist/fallback/AvatarFallback.js +136 -0
- package/dist/fallback/AvatarFallback.js.map +1 -0
- package/dist/form/Form.cjs +159 -0
- package/dist/form/Form.cjs.map +1 -0
- package/dist/form/Form.js +154 -0
- package/dist/form/Form.js.map +1 -0
- package/dist/header/AccordionHeader.cjs +189 -0
- package/dist/header/AccordionHeader.cjs.map +1 -0
- package/dist/header/AccordionHeader.js +148 -0
- package/dist/header/AccordionHeader.js.map +1 -0
- package/dist/image/AvatarImage.cjs +150 -0
- package/dist/image/AvatarImage.cjs.map +1 -0
- package/dist/image/AvatarImage.js +145 -0
- package/dist/image/AvatarImage.js.map +1 -0
- package/dist/image/AvatarImageDataAttributes.cjs +26 -0
- package/dist/image/AvatarImageDataAttributes.cjs.map +1 -0
- package/dist/image/AvatarImageDataAttributes.js +20 -0
- package/dist/image/AvatarImageDataAttributes.js.map +1 -0
- package/dist/index.cjs +64 -0
- package/dist/index.d.cts +1501 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +1501 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index2.cjs +2767 -0
- package/dist/index2.cjs.map +1 -0
- package/dist/index2.js +2618 -0
- package/dist/index2.js.map +1 -0
- package/package.json +77 -0
- package/src/accordion/accordion.types.ts +126 -0
- package/src/accordion/header/AccordionHeader.vue +36 -0
- package/src/accordion/index.ts +10 -0
- package/src/accordion/item/AccordionItem.vue +124 -0
- package/src/accordion/item/AccordionItemContext.ts +24 -0
- package/src/accordion/item/AccordionItemDataAttributes.ts +15 -0
- package/src/accordion/item/stateAttributesMapping.ts +14 -0
- package/src/accordion/panel/AccordionPanel.vue +156 -0
- package/src/accordion/panel/AccordionPanelCssVars.ts +12 -0
- package/src/accordion/root/AccordionRoot.vue +130 -0
- package/src/accordion/root/AccordionRootContext.ts +37 -0
- package/src/accordion/root/AccordionRootDataAttributes.ts +10 -0
- package/src/accordion/root/stateAttributesMapping.ts +6 -0
- package/src/accordion/trigger/AccordionTrigger.vue +186 -0
- package/src/avatar/fallback/AvatarFallback.vue +75 -0
- package/src/avatar/image/AvatarImage.vue +103 -0
- package/src/avatar/image/AvatarImageDataAttributes.ts +14 -0
- package/src/avatar/image/useImageLoadingStatus.ts +58 -0
- package/src/avatar/index.ts +19 -0
- package/src/avatar/root/AvatarRoot.vue +62 -0
- package/src/avatar/root/AvatarRootContext.ts +22 -0
- package/src/avatar/root/stateAttributesMapping.ts +7 -0
- package/src/button/Button.vue +59 -0
- package/src/button/ButtonDataAttributes.ts +6 -0
- package/src/button/button.types.ts +22 -0
- package/src/button/index.ts +2 -0
- package/src/collapsible/collapsible.types.ts +64 -0
- package/src/collapsible/index.ts +6 -0
- package/src/collapsible/panel/CollapsiblePanel.vue +145 -0
- package/src/collapsible/panel/CollapsiblePanelCssVars.ts +12 -0
- package/src/collapsible/panel/CollapsiblePanelDataAttributes.ts +18 -0
- package/src/collapsible/panel/useCollapsiblePanel.ts +489 -0
- package/src/collapsible/root/CollapsibleRoot.vue +60 -0
- package/src/collapsible/root/CollapsibleRootContext.ts +18 -0
- package/src/collapsible/root/stateAttributesMapping.ts +9 -0
- package/src/collapsible/root/useCollapsibleRoot.ts +252 -0
- package/src/collapsible/trigger/CollapsibleTrigger.vue +63 -0
- package/src/collapsible/trigger/CollapsibleTriggerDataAttributes.ts +6 -0
- package/src/composite/composite.ts +232 -0
- package/src/composite/constants.ts +1 -0
- package/src/composite/item/CompositeItem.vue +75 -0
- package/src/composite/item/useCompositeItem.ts +63 -0
- package/src/composite/list/CompositeList.vue +168 -0
- package/src/composite/list/CompositeListContext.ts +21 -0
- package/src/composite/list/useCompositeListItem.ts +130 -0
- package/src/composite/root/CompositeRoot.vue +106 -0
- package/src/composite/root/CompositeRootContext.ts +36 -0
- package/src/composite/root/index.ts +7 -0
- package/src/composite/root/useCompositeRoot.ts +418 -0
- package/src/direction-provider/DirectionContext.ts +29 -0
- package/src/direction-provider/DirectionProvider.vue +31 -0
- package/src/direction-provider/index.ts +8 -0
- package/src/field/control/FieldControl.vue +211 -0
- package/src/field/control/FieldControlDataAttributes.ts +30 -0
- package/src/field/description/FieldDescription.vue +62 -0
- package/src/field/description/FieldDescriptionDataAttributes.ts +30 -0
- package/src/field/error/FieldError.vue +159 -0
- package/src/field/error/FieldErrorDataAttributes.ts +38 -0
- package/src/field/index.ts +27 -0
- package/src/field/item/FieldItem.vue +63 -0
- package/src/field/item/FieldItemContext.ts +16 -0
- package/src/field/label/FieldLabel.vue +102 -0
- package/src/field/label/FieldLabelDataAttributes.ts +30 -0
- package/src/field/root/FieldRoot.vue +262 -0
- package/src/field/root/FieldRootContext.ts +97 -0
- package/src/field/root/FieldRootDataAttributes.ts +30 -0
- package/src/field/root/useFieldRootState.ts +81 -0
- package/src/field/root/useFieldValidation.ts +298 -0
- package/src/field/root/useFieldValidity.ts +30 -0
- package/src/field/useField.ts +73 -0
- package/src/field/utils/constants.ts +45 -0
- package/src/field/utils/getCombinedFieldValidityData.ts +18 -0
- package/src/field/validity/FieldValidity.vue +36 -0
- package/src/fieldset/index.ts +8 -0
- package/src/fieldset/legend/FieldsetLegend.vue +72 -0
- package/src/fieldset/root/FieldsetRoot.vue +74 -0
- package/src/fieldset/root/FieldsetRootContext.ts +26 -0
- package/src/floating-ui-vue/types.ts +4 -0
- package/src/floating-ui-vue/utils/composite.ts +475 -0
- package/src/floating-ui-vue/utils/constants.ts +4 -0
- package/src/floating-ui-vue/utils/event.ts +4 -0
- package/src/floating-ui-vue/utils.ts +2 -0
- package/src/form/Form.vue +188 -0
- package/src/form/FormContext.ts +59 -0
- package/src/form/index.ts +10 -0
- package/src/index.ts +14 -0
- package/src/labelable-provider/LabelableContext.ts +33 -0
- package/src/labelable-provider/LabelableProvider.vue +55 -0
- package/src/labelable-provider/index.ts +6 -0
- package/src/labelable-provider/useAriaLabelledBy.ts +100 -0
- package/src/labelable-provider/useLabelableId.ts +30 -0
- package/src/merge-props/index.ts +1 -0
- package/src/merge-props/mergeProps.ts +192 -0
- package/src/test/index.ts +1 -0
- package/src/test/utils.ts +9 -0
- package/src/types/index.ts +10 -0
- package/src/use-button/index.ts +1 -0
- package/src/use-button/useButton.ts +231 -0
- package/src/use-render/index.ts +1 -0
- package/src/use-render/useRender.spec.ts +90 -0
- package/src/use-render/useRender.ts +152 -0
- package/src/utils/collapsibleOpenStateMapping.ts +33 -0
- package/src/utils/constants.ts +1 -0
- package/src/utils/createBaseUIEventDetails.ts +127 -0
- package/src/utils/empty.ts +5 -0
- package/src/utils/error.ts +19 -0
- package/src/utils/getStateAttributesProps.ts +31 -0
- package/src/utils/isElementDisabled.ts +7 -0
- package/src/utils/noop.ts +1 -0
- package/src/utils/reasons.ts +69 -0
- package/src/utils/resolveRef.ts +9 -0
- package/src/utils/slot.ts +6 -0
- package/src/utils/stateAttributesMapping.ts +28 -0
- package/src/utils/transitionStatusMapping.ts +22 -0
- package/src/utils/types.ts +47 -0
- package/src/utils/useAnimationFrame.ts +130 -0
- package/src/utils/useAnimationsFinished.ts +101 -0
- package/src/utils/useBaseUiId.ts +9 -0
- package/src/utils/useControllableState.ts +44 -0
- package/src/utils/useFocusableWhenDisabled.ts +85 -0
- package/src/utils/useId.ts +26 -0
- package/src/utils/useMergedRefs.ts +91 -0
- package/src/utils/useOpenChangeComplete.ts +52 -0
- package/src/utils/useRenderElement.ts +162 -0
- package/src/utils/useTimeout.ts +48 -0
- package/src/utils/useTransitionStatus.ts +104 -0
- package/src/utils/warn.ts +15 -0
|
@@ -0,0 +1,511 @@
|
|
|
1
|
+
import { EMPTY_OBJECT, NOOP, mergeProps as mergeProps$1, useRenderElement } from "../button/Button.js";
|
|
2
|
+
import { computed, createBlock, createCommentVNode, defineComponent, inject, mergeProps, openBlock, ref, renderSlot, resolveDynamicComponent, shallowReadonly, shallowRef, unref, useAttrs, useId, watchEffect } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/useId.ts
|
|
5
|
+
let globalId = 0;
|
|
6
|
+
/**
|
|
7
|
+
* Generates a unique ID string, optionally prefixed.
|
|
8
|
+
* Uses Vue 3.5+ `useId()` when available, otherwise falls back to an
|
|
9
|
+
* incrementing counter (client-side only, not SSR-safe).
|
|
10
|
+
*
|
|
11
|
+
* @param idOverride - If provided, returned as-is.
|
|
12
|
+
* @param prefix - Optional prefix prepended to the generated id.
|
|
13
|
+
*/
|
|
14
|
+
function useId$1(idOverride, prefix) {
|
|
15
|
+
if (idOverride != null) return idOverride;
|
|
16
|
+
if (typeof useId === "function") {
|
|
17
|
+
const reactId = useId();
|
|
18
|
+
return prefix ? `${prefix}-${reactId}` : reactId;
|
|
19
|
+
}
|
|
20
|
+
globalId += 1;
|
|
21
|
+
const id = String(globalId);
|
|
22
|
+
return prefix ? `${prefix}-${id}` : id;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/utils/useBaseUiId.ts
|
|
27
|
+
/**
|
|
28
|
+
* Wraps `useId` and prefixes generated IDs with `base-ui-`.
|
|
29
|
+
* @param idOverride - If provided, returned as-is.
|
|
30
|
+
*/
|
|
31
|
+
function useBaseUiId(idOverride) {
|
|
32
|
+
return useId$1(idOverride, "base-ui");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/labelable-provider/LabelableContext.ts
|
|
37
|
+
const defaultContext$1 = {
|
|
38
|
+
controlId: shallowReadonly(shallowRef(void 0)),
|
|
39
|
+
setControlId: NOOP,
|
|
40
|
+
labelId: shallowReadonly(shallowRef(void 0)),
|
|
41
|
+
setLabelId: NOOP,
|
|
42
|
+
messageIds: shallowReadonly(shallowRef([])),
|
|
43
|
+
setMessageIds: NOOP,
|
|
44
|
+
getDescriptionProps: () => ({})
|
|
45
|
+
};
|
|
46
|
+
const labelableContextKey = Symbol("LabelableContext");
|
|
47
|
+
function useLabelableContext() {
|
|
48
|
+
return inject(labelableContextKey, defaultContext$1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/labelable-provider/useAriaLabelledBy.ts
|
|
53
|
+
function useAriaLabelledBy(params) {
|
|
54
|
+
const { ariaLabelledBy, labelId, labelSourceRef, enableFallback = true, labelSourceId } = params;
|
|
55
|
+
const fallbackAriaLabelledBy = ref(void 0);
|
|
56
|
+
const generatedLabelId = useBaseUiId(labelSourceId ? `${labelSourceId}-label` : void 0);
|
|
57
|
+
const resolvedAriaLabelledBy = computed(() => {
|
|
58
|
+
const explicit = ariaLabelledBy?.value;
|
|
59
|
+
const fromContext = labelId?.value;
|
|
60
|
+
return explicit ?? fromContext ?? fallbackAriaLabelledBy.value;
|
|
61
|
+
});
|
|
62
|
+
watchEffect(() => {
|
|
63
|
+
if (ariaLabelledBy?.value || labelId?.value || !enableFallback) {
|
|
64
|
+
fallbackAriaLabelledBy.value = void 0;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const next = getAriaLabelledBy(labelSourceRef.value, generatedLabelId);
|
|
68
|
+
if (fallbackAriaLabelledBy.value !== next) fallbackAriaLabelledBy.value = next;
|
|
69
|
+
});
|
|
70
|
+
return resolvedAriaLabelledBy;
|
|
71
|
+
}
|
|
72
|
+
function getAriaLabelledBy(labelSource, generatedLabelId) {
|
|
73
|
+
const label = findAssociatedLabel(labelSource);
|
|
74
|
+
if (!label) return;
|
|
75
|
+
if (!label.id && generatedLabelId) label.id = generatedLabelId;
|
|
76
|
+
return label.id || void 0;
|
|
77
|
+
}
|
|
78
|
+
function findAssociatedLabel(labelSource) {
|
|
79
|
+
if (!labelSource) return;
|
|
80
|
+
const parent = labelSource.parentElement;
|
|
81
|
+
if (parent && parent.tagName === "LABEL") return parent;
|
|
82
|
+
const controlId = labelSource.id;
|
|
83
|
+
if (controlId) {
|
|
84
|
+
const nextSibling = labelSource.nextElementSibling;
|
|
85
|
+
if (nextSibling && nextSibling.htmlFor === controlId) return nextSibling;
|
|
86
|
+
}
|
|
87
|
+
const labels = labelSource.labels;
|
|
88
|
+
return labels && labels[0] ? labels[0] : void 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/labelable-provider/useLabelableId.ts
|
|
93
|
+
function useLabelableId(params = {}) {
|
|
94
|
+
const { id } = params;
|
|
95
|
+
const { controlId, setControlId } = useLabelableContext();
|
|
96
|
+
const defaultId = useBaseUiId(id);
|
|
97
|
+
const resolvedId = id ?? defaultId;
|
|
98
|
+
watchEffect((onCleanup) => {
|
|
99
|
+
if (!resolvedId) {
|
|
100
|
+
setControlId(void 0);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
setControlId(resolvedId);
|
|
104
|
+
onCleanup(() => {
|
|
105
|
+
setControlId(void 0);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
return computed(() => controlId.value ?? defaultId);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/field/root/FieldRootDataAttributes.ts
|
|
113
|
+
let FieldRootDataAttributes = /* @__PURE__ */ function(FieldRootDataAttributes) {
|
|
114
|
+
/**
|
|
115
|
+
* Present when the field is disabled.
|
|
116
|
+
*/
|
|
117
|
+
FieldRootDataAttributes["disabled"] = "data-disabled";
|
|
118
|
+
/**
|
|
119
|
+
* Present when the field has been touched.
|
|
120
|
+
*/
|
|
121
|
+
FieldRootDataAttributes["touched"] = "data-touched";
|
|
122
|
+
/**
|
|
123
|
+
* Present when the field's value has changed.
|
|
124
|
+
*/
|
|
125
|
+
FieldRootDataAttributes["dirty"] = "data-dirty";
|
|
126
|
+
/**
|
|
127
|
+
* Present when the field is in valid state.
|
|
128
|
+
*/
|
|
129
|
+
FieldRootDataAttributes["valid"] = "data-valid";
|
|
130
|
+
/**
|
|
131
|
+
* Present when the field is in invalid state.
|
|
132
|
+
*/
|
|
133
|
+
FieldRootDataAttributes["invalid"] = "data-invalid";
|
|
134
|
+
/**
|
|
135
|
+
* Present when the field is filled.
|
|
136
|
+
*/
|
|
137
|
+
FieldRootDataAttributes["filled"] = "data-filled";
|
|
138
|
+
/**
|
|
139
|
+
* Present when the field control is focused.
|
|
140
|
+
*/
|
|
141
|
+
FieldRootDataAttributes["focused"] = "data-focused";
|
|
142
|
+
return FieldRootDataAttributes;
|
|
143
|
+
}({});
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/field/utils/constants.ts
|
|
147
|
+
const DEFAULT_VALIDITY_STATE = {
|
|
148
|
+
badInput: false,
|
|
149
|
+
customError: false,
|
|
150
|
+
patternMismatch: false,
|
|
151
|
+
rangeOverflow: false,
|
|
152
|
+
rangeUnderflow: false,
|
|
153
|
+
stepMismatch: false,
|
|
154
|
+
tooLong: false,
|
|
155
|
+
tooShort: false,
|
|
156
|
+
typeMismatch: false,
|
|
157
|
+
valid: null,
|
|
158
|
+
valueMissing: false
|
|
159
|
+
};
|
|
160
|
+
const DEFAULT_FIELD_STATE_ATTRIBUTES = {
|
|
161
|
+
valid: null,
|
|
162
|
+
touched: false,
|
|
163
|
+
dirty: false,
|
|
164
|
+
filled: false,
|
|
165
|
+
focused: false
|
|
166
|
+
};
|
|
167
|
+
const DEFAULT_FIELD_ROOT_STATE = {
|
|
168
|
+
disabled: false,
|
|
169
|
+
...DEFAULT_FIELD_STATE_ATTRIBUTES
|
|
170
|
+
};
|
|
171
|
+
const fieldValidityMapping = { valid(value) {
|
|
172
|
+
if (value === null) return null;
|
|
173
|
+
if (value) return { [FieldRootDataAttributes.valid]: "" };
|
|
174
|
+
return { [FieldRootDataAttributes.invalid]: "" };
|
|
175
|
+
} };
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/field/root/FieldRootContext.ts
|
|
179
|
+
function createDefaultContext() {
|
|
180
|
+
const defaultValidation = {
|
|
181
|
+
getValidationProps: () => ({}),
|
|
182
|
+
getInputValidationProps: () => ({}),
|
|
183
|
+
inputRef: shallowReadonly(shallowRef(null)),
|
|
184
|
+
setInputRef: () => {},
|
|
185
|
+
commit: async () => {}
|
|
186
|
+
};
|
|
187
|
+
return {
|
|
188
|
+
invalid: ref(void 0),
|
|
189
|
+
name: ref(void 0),
|
|
190
|
+
validityData: ref({
|
|
191
|
+
state: { ...DEFAULT_VALIDITY_STATE },
|
|
192
|
+
errors: [],
|
|
193
|
+
error: "",
|
|
194
|
+
value: "",
|
|
195
|
+
initialValue: null
|
|
196
|
+
}),
|
|
197
|
+
setValidityData: NOOP,
|
|
198
|
+
disabled: ref(false),
|
|
199
|
+
touched: ref(false),
|
|
200
|
+
setTouched: NOOP,
|
|
201
|
+
dirty: ref(false),
|
|
202
|
+
setDirty: NOOP,
|
|
203
|
+
filled: ref(false),
|
|
204
|
+
setFilled: NOOP,
|
|
205
|
+
focused: ref(false),
|
|
206
|
+
setFocused: NOOP,
|
|
207
|
+
validate: () => null,
|
|
208
|
+
validationMode: ref("onSubmit"),
|
|
209
|
+
validationDebounceTime: ref(0),
|
|
210
|
+
shouldValidateOnChange: () => false,
|
|
211
|
+
state: ref({ ...DEFAULT_FIELD_ROOT_STATE }),
|
|
212
|
+
markedDirtyRef: ref(false),
|
|
213
|
+
validation: defaultValidation
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
const fieldRootContextKey = Symbol("FieldRootContext");
|
|
217
|
+
let _defaultContext = null;
|
|
218
|
+
function useFieldRootContext(optional = true) {
|
|
219
|
+
const context = inject(fieldRootContextKey, void 0);
|
|
220
|
+
if (!context && !optional) throw new Error("Base UI Vue: FieldRootContext is missing. Field parts must be placed within <FieldRoot>.");
|
|
221
|
+
if (!context) {
|
|
222
|
+
if (!_defaultContext) _defaultContext = createDefaultContext();
|
|
223
|
+
return _defaultContext;
|
|
224
|
+
}
|
|
225
|
+
return context;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/form/FormContext.ts
|
|
230
|
+
const formContextKey = Symbol("FormContext");
|
|
231
|
+
const defaultContext = {
|
|
232
|
+
errors: { value: EMPTY_OBJECT },
|
|
233
|
+
clearErrors: NOOP,
|
|
234
|
+
formRef: { value: { fields: /* @__PURE__ */ new Map() } },
|
|
235
|
+
validationMode: { value: "onSubmit" },
|
|
236
|
+
submitAttempted: { value: false }
|
|
237
|
+
};
|
|
238
|
+
function useFormContext() {
|
|
239
|
+
return inject(formContextKey, defaultContext);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/field/utils/getCombinedFieldValidityData.ts
|
|
244
|
+
/**
|
|
245
|
+
* Combines the field's client-side, stateful validity data with the external
|
|
246
|
+
* invalid state to determine the field's true validity.
|
|
247
|
+
*/
|
|
248
|
+
function getCombinedFieldValidityData(validityData, invalid) {
|
|
249
|
+
return {
|
|
250
|
+
...validityData,
|
|
251
|
+
state: {
|
|
252
|
+
...validityData.state,
|
|
253
|
+
valid: !invalid && validityData.state.valid
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/field/useField.ts
|
|
260
|
+
function useField(params) {
|
|
261
|
+
const { enabled, value, id, name, controlRef, commit } = params;
|
|
262
|
+
const { formRef } = useFormContext();
|
|
263
|
+
const { invalid, markedDirtyRef, validityData, setValidityData } = useFieldRootContext();
|
|
264
|
+
const getValue = params.getValue ?? (() => value.value);
|
|
265
|
+
watchEffect(() => {
|
|
266
|
+
if (enabled && !enabled.value) return;
|
|
267
|
+
let initialValue = value.value;
|
|
268
|
+
if (initialValue === void 0) initialValue = getValue();
|
|
269
|
+
if (validityData.value.initialValue === null && initialValue !== null) setValidityData({
|
|
270
|
+
...validityData.value,
|
|
271
|
+
initialValue
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
watchEffect((onCleanup) => {
|
|
275
|
+
if (enabled && !enabled.value) return;
|
|
276
|
+
const currentId = id.value;
|
|
277
|
+
if (!currentId) return;
|
|
278
|
+
const fields = formRef.value.fields;
|
|
279
|
+
fields.set(currentId, {
|
|
280
|
+
getValue,
|
|
281
|
+
name: name?.value,
|
|
282
|
+
controlRef,
|
|
283
|
+
validityData: getCombinedFieldValidityData(validityData.value, invalid.value),
|
|
284
|
+
validate() {
|
|
285
|
+
let nextValue = value.value;
|
|
286
|
+
if (nextValue === void 0) nextValue = getValue();
|
|
287
|
+
markedDirtyRef.value = true;
|
|
288
|
+
commit(nextValue);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
onCleanup(() => {
|
|
292
|
+
fields.delete(currentId);
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/field/control/FieldControl.vue?vue&type=script&setup=true&lang.ts
|
|
299
|
+
var FieldControl_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
300
|
+
name: "FieldControl",
|
|
301
|
+
inheritAttrs: false,
|
|
302
|
+
__name: "FieldControl",
|
|
303
|
+
props: {
|
|
304
|
+
id: {
|
|
305
|
+
type: String,
|
|
306
|
+
required: false
|
|
307
|
+
},
|
|
308
|
+
name: {
|
|
309
|
+
type: String,
|
|
310
|
+
required: false
|
|
311
|
+
},
|
|
312
|
+
disabled: {
|
|
313
|
+
type: Boolean,
|
|
314
|
+
required: false,
|
|
315
|
+
default: false
|
|
316
|
+
},
|
|
317
|
+
value: {
|
|
318
|
+
type: String,
|
|
319
|
+
required: false
|
|
320
|
+
},
|
|
321
|
+
defaultValue: {
|
|
322
|
+
type: String,
|
|
323
|
+
required: false
|
|
324
|
+
},
|
|
325
|
+
autofocus: {
|
|
326
|
+
type: Boolean,
|
|
327
|
+
required: false,
|
|
328
|
+
default: false
|
|
329
|
+
},
|
|
330
|
+
type: {
|
|
331
|
+
type: String,
|
|
332
|
+
required: false
|
|
333
|
+
},
|
|
334
|
+
required: {
|
|
335
|
+
type: Boolean,
|
|
336
|
+
required: false
|
|
337
|
+
},
|
|
338
|
+
pattern: {
|
|
339
|
+
type: String,
|
|
340
|
+
required: false
|
|
341
|
+
},
|
|
342
|
+
minlength: {
|
|
343
|
+
type: Number,
|
|
344
|
+
required: false
|
|
345
|
+
},
|
|
346
|
+
maxlength: {
|
|
347
|
+
type: Number,
|
|
348
|
+
required: false
|
|
349
|
+
},
|
|
350
|
+
min: {
|
|
351
|
+
type: [String, Number],
|
|
352
|
+
required: false
|
|
353
|
+
},
|
|
354
|
+
max: {
|
|
355
|
+
type: [String, Number],
|
|
356
|
+
required: false
|
|
357
|
+
},
|
|
358
|
+
step: {
|
|
359
|
+
type: [String, Number],
|
|
360
|
+
required: false
|
|
361
|
+
},
|
|
362
|
+
placeholder: {
|
|
363
|
+
type: String,
|
|
364
|
+
required: false
|
|
365
|
+
},
|
|
366
|
+
as: {
|
|
367
|
+
type: null,
|
|
368
|
+
required: false,
|
|
369
|
+
default: "input"
|
|
370
|
+
},
|
|
371
|
+
class: {
|
|
372
|
+
type: Function,
|
|
373
|
+
required: false,
|
|
374
|
+
skipCheck: true
|
|
375
|
+
},
|
|
376
|
+
style: {
|
|
377
|
+
type: [
|
|
378
|
+
Boolean,
|
|
379
|
+
null,
|
|
380
|
+
String,
|
|
381
|
+
Object,
|
|
382
|
+
Array,
|
|
383
|
+
Function
|
|
384
|
+
],
|
|
385
|
+
required: false,
|
|
386
|
+
skipCheck: true
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
emits: ["valueChange"],
|
|
390
|
+
setup(__props, { emit: __emit }) {
|
|
391
|
+
const props = __props;
|
|
392
|
+
const emit = __emit;
|
|
393
|
+
const attrs = useAttrs();
|
|
394
|
+
const attrsObject = attrs;
|
|
395
|
+
const { state: fieldState, name: fieldName, disabled: fieldDisabled, setTouched, setDirty, markedDirtyRef, validityData, setFocused, setFilled, validationMode, validation } = useFieldRootContext();
|
|
396
|
+
const disabled = computed(() => fieldDisabled.value || props.disabled);
|
|
397
|
+
const name = computed(() => fieldName.value ?? props.name);
|
|
398
|
+
const state = computed(() => ({
|
|
399
|
+
...fieldState.value,
|
|
400
|
+
disabled: disabled.value
|
|
401
|
+
}));
|
|
402
|
+
const controlId = useLabelableId({ id: props.id });
|
|
403
|
+
const isControlled = computed(() => props.value !== void 0);
|
|
404
|
+
const internalValue = shallowRef(props.defaultValue ?? "");
|
|
405
|
+
const currentValue = computed(() => {
|
|
406
|
+
if (isControlled.value) return props.value;
|
|
407
|
+
return internalValue.value;
|
|
408
|
+
});
|
|
409
|
+
const inputElementRef = ref(null);
|
|
410
|
+
const { labelId } = useLabelableContext();
|
|
411
|
+
const ariaLabelledBy = useAriaLabelledBy({
|
|
412
|
+
ariaLabelledBy: computed(() => attrs["aria-labelledby"]),
|
|
413
|
+
labelId,
|
|
414
|
+
labelSourceRef: inputElementRef,
|
|
415
|
+
enableFallback: true,
|
|
416
|
+
labelSourceId: controlId.value ?? void 0
|
|
417
|
+
});
|
|
418
|
+
watchEffect(() => {
|
|
419
|
+
validation.setInputRef(inputElementRef.value);
|
|
420
|
+
});
|
|
421
|
+
useField({
|
|
422
|
+
id: controlId,
|
|
423
|
+
name,
|
|
424
|
+
commit: (v) => validation.commit(v),
|
|
425
|
+
value: currentValue,
|
|
426
|
+
getValue: () => inputElementRef.value?.value ?? internalValue.value,
|
|
427
|
+
controlRef: inputElementRef
|
|
428
|
+
});
|
|
429
|
+
watchEffect(() => {
|
|
430
|
+
const el = inputElementRef.value;
|
|
431
|
+
if (!el) return;
|
|
432
|
+
if (el.value || isControlled.value && props.value !== "") setFilled(true);
|
|
433
|
+
else if (isControlled.value && props.value === "") setFilled(false);
|
|
434
|
+
});
|
|
435
|
+
function handleInput(event) {
|
|
436
|
+
const target = event.target;
|
|
437
|
+
internalValue.value = target.value;
|
|
438
|
+
emit("valueChange", target.value, event);
|
|
439
|
+
setDirty(target.value !== validityData.value.initialValue);
|
|
440
|
+
setFilled(target.value !== "");
|
|
441
|
+
}
|
|
442
|
+
function handleInputCombined(event) {
|
|
443
|
+
handleInput(event);
|
|
444
|
+
validation.getInputValidationProps().onInput?.(event);
|
|
445
|
+
}
|
|
446
|
+
function handleFocus() {
|
|
447
|
+
setFocused(true);
|
|
448
|
+
}
|
|
449
|
+
function handleBlur(event) {
|
|
450
|
+
const target = event.target;
|
|
451
|
+
setTouched(true);
|
|
452
|
+
setFocused(false);
|
|
453
|
+
if (validationMode.value === "onBlur") validation.commit(target.value);
|
|
454
|
+
}
|
|
455
|
+
function handleKeydown(event) {
|
|
456
|
+
const target = event.target;
|
|
457
|
+
if (target.tagName === "INPUT" && event.key === "Enter") {
|
|
458
|
+
setTouched(true);
|
|
459
|
+
markedDirtyRef.value = true;
|
|
460
|
+
validation.commit(target.value);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
const { tag, mergedProps, renderless, ref: renderRef } = useRenderElement({
|
|
464
|
+
componentProps: props,
|
|
465
|
+
state,
|
|
466
|
+
props: computed(() => mergeProps$1(attrsObject, validation.getInputValidationProps(), {
|
|
467
|
+
"id": controlId.value,
|
|
468
|
+
"disabled": disabled.value,
|
|
469
|
+
"name": name.value,
|
|
470
|
+
"aria-labelledby": ariaLabelledBy.value,
|
|
471
|
+
"autofocus": props.autofocus || void 0,
|
|
472
|
+
"type": props.type,
|
|
473
|
+
"required": props.required,
|
|
474
|
+
"pattern": props.pattern,
|
|
475
|
+
"minlength": props.minlength,
|
|
476
|
+
"maxlength": props.maxlength,
|
|
477
|
+
"min": props.min,
|
|
478
|
+
"max": props.max,
|
|
479
|
+
"step": props.step,
|
|
480
|
+
"placeholder": props.placeholder,
|
|
481
|
+
"value": isControlled.value ? props.value : internalValue.value,
|
|
482
|
+
"onInput": handleInputCombined,
|
|
483
|
+
"onFocus": handleFocus,
|
|
484
|
+
"onBlur": handleBlur,
|
|
485
|
+
"onKeydown": handleKeydown
|
|
486
|
+
})),
|
|
487
|
+
stateAttributesMapping: fieldValidityMapping,
|
|
488
|
+
defaultTagName: "input",
|
|
489
|
+
ref: inputElementRef
|
|
490
|
+
});
|
|
491
|
+
return (_ctx, _cache) => {
|
|
492
|
+
return unref(renderless) ? renderSlot(_ctx.$slots, "default", {
|
|
493
|
+
key: 0,
|
|
494
|
+
ref: unref(renderRef),
|
|
495
|
+
props: unref(mergedProps),
|
|
496
|
+
state: state.value
|
|
497
|
+
}) : (openBlock(), createBlock(resolveDynamicComponent(unref(tag)), mergeProps({
|
|
498
|
+
key: 1,
|
|
499
|
+
ref: unref(renderRef)
|
|
500
|
+
}, unref(mergedProps)), null, 16));
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/field/control/FieldControl.vue
|
|
507
|
+
var FieldControl_default = FieldControl_vue_vue_type_script_setup_true_lang_default;
|
|
508
|
+
|
|
509
|
+
//#endregion
|
|
510
|
+
export { DEFAULT_VALIDITY_STATE, FieldControl_default, fieldRootContextKey, fieldValidityMapping, formContextKey, getCombinedFieldValidityData, labelableContextKey, useBaseUiId, useFieldRootContext, useFormContext, useLabelableContext };
|
|
511
|
+
//# sourceMappingURL=FieldControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldControl.js","names":["useId","vueUseId","useId","defaultContext"],"sources":["../../src/utils/useId.ts","../../src/utils/useBaseUiId.ts","../../src/labelable-provider/LabelableContext.ts","../../src/labelable-provider/useAriaLabelledBy.ts","../../src/labelable-provider/useLabelableId.ts","../../src/field/root/FieldRootDataAttributes.ts","../../src/field/utils/constants.ts","../../src/field/root/FieldRootContext.ts","../../src/form/FormContext.ts","../../src/field/utils/getCombinedFieldValidityData.ts","../../src/field/useField.ts","../../src/field/control/FieldControl.vue","../../src/field/control/FieldControl.vue"],"sourcesContent":[],"mappings":";;;;AAEA,IAAI,WAAW;;;;;;;;;AAUf,SAAgBA,QAAM,YAAqB,QAAqC;AAC9E,KAAI,cAAc,KAChB,QAAO;AAGT,KAAI,OAAOC,UAAa,YAAY;EAClC,MAAM,UAAUA,OAAU;AAC1B,SAAO,SAAS,GAAG,OAAO,GAAG,YAAY;;AAG3C,aAAY;CACZ,MAAM,KAAK,OAAO,SAAS;AAC3B,QAAO,SAAS,GAAG,OAAO,GAAG,OAAO;;;;;;;;;AClBtC,SA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AAEhB,OAAI,eAAe,UAAU,SAC3B,YAAW,OAAO,OAAO,MAAK;;EAIlC,SAAS,cAAc,OAAsB;GAC3C,MAAM,SAAS,MAAM;AACrB,OAAI,OAAO,YAAY,WAAW,MAAM,QAAQ,SAAS;AACvD,eAAW,KAAI;AACf,mBAAe,QAAQ;AACvB,eAAW,OAAO,OAAO,MAAK;;;EA8BlC,MAAM,EACJ,KACA,aACA,YACA,KAAK,cACH,iBAAiB;GACnB,gBAAgB;GAChB;GACA,OAlCmB,eAAe,aAClC,aACA,WAAW,yBAAyB,EACpC;IACE,MAAM,UAAU;IAChB,YAAY,SAAS;IACrB,QAAQ,KAAK;IACb,mBAAmB,eAAe;IAClC,aAAa,MAAM,aAAa;IAChC,QAAQ,MAAM;IACd,YAAY,MAAM;IAClB,WAAW,MAAM;IACjB,aAAa,MAAM;IACnB,aAAa,MAAM;IACnB,OAAO,MAAM;IACb,OAAO,MAAM;IACb,QAAQ,MAAM;IACd,eAAe,MAAM;IACrB,SAAS,aAAa,QAAQ,MAAM,QAAQ,cAAc;IAC1D,WAAW;IACX,WAAW;IACX,UAAU;IACV,aAAa;IACd,CACF,CAAA;GAWC,wBAAwB;GACxB,gBAAgB;GAChB,KAAK;GACN,CAAA;;UAIa,MAAA,WAAU,GAAtB,WAA+E,KAAA,QAAA,WAAA;;IAAtD,KAAK,MAAA,UAAS;IAAG,OAAO,MAAA,YAAW;IAAG,OAAO,MAAA;sBACtE,YAKE,wBAJK,MAAA,IAAG,CAAA,EADV,WAKE;;IAFC,KAAK,MAAA,UAAS;MACP,MAAA,YAAW,CAAA,EAAA,MAAA,GAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/field/control/FieldControlDataAttributes.ts
|
|
3
|
+
let FieldControlDataAttributes = /* @__PURE__ */ function(FieldControlDataAttributes) {
|
|
4
|
+
/**
|
|
5
|
+
* Present when the field is disabled.
|
|
6
|
+
*/
|
|
7
|
+
FieldControlDataAttributes["disabled"] = "data-disabled";
|
|
8
|
+
/**
|
|
9
|
+
* Present when the field is in valid state.
|
|
10
|
+
*/
|
|
11
|
+
FieldControlDataAttributes["valid"] = "data-valid";
|
|
12
|
+
/**
|
|
13
|
+
* Present when the field is in invalid state.
|
|
14
|
+
*/
|
|
15
|
+
FieldControlDataAttributes["invalid"] = "data-invalid";
|
|
16
|
+
/**
|
|
17
|
+
* Present when the field has been touched.
|
|
18
|
+
*/
|
|
19
|
+
FieldControlDataAttributes["touched"] = "data-touched";
|
|
20
|
+
/**
|
|
21
|
+
* Present when the field's value has changed.
|
|
22
|
+
*/
|
|
23
|
+
FieldControlDataAttributes["dirty"] = "data-dirty";
|
|
24
|
+
/**
|
|
25
|
+
* Present when the field is filled.
|
|
26
|
+
*/
|
|
27
|
+
FieldControlDataAttributes["filled"] = "data-filled";
|
|
28
|
+
/**
|
|
29
|
+
* Present when the field control is focused.
|
|
30
|
+
*/
|
|
31
|
+
FieldControlDataAttributes["focused"] = "data-focused";
|
|
32
|
+
return FieldControlDataAttributes;
|
|
33
|
+
}({});
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
Object.defineProperty(exports, 'FieldControlDataAttributes', {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return FieldControlDataAttributes;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=FieldControlDataAttributes.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldControlDataAttributes.cjs","names":[],"sources":["../../src/field/control/FieldControlDataAttributes.ts"],"sourcesContent":[],"mappings":";;AAAA,IAAY,kFAAL;;;;AAIL;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/field/control/FieldControlDataAttributes.ts
|
|
2
|
+
let FieldControlDataAttributes = /* @__PURE__ */ function(FieldControlDataAttributes) {
|
|
3
|
+
/**
|
|
4
|
+
* Present when the field is disabled.
|
|
5
|
+
*/
|
|
6
|
+
FieldControlDataAttributes["disabled"] = "data-disabled";
|
|
7
|
+
/**
|
|
8
|
+
* Present when the field is in valid state.
|
|
9
|
+
*/
|
|
10
|
+
FieldControlDataAttributes["valid"] = "data-valid";
|
|
11
|
+
/**
|
|
12
|
+
* Present when the field is in invalid state.
|
|
13
|
+
*/
|
|
14
|
+
FieldControlDataAttributes["invalid"] = "data-invalid";
|
|
15
|
+
/**
|
|
16
|
+
* Present when the field has been touched.
|
|
17
|
+
*/
|
|
18
|
+
FieldControlDataAttributes["touched"] = "data-touched";
|
|
19
|
+
/**
|
|
20
|
+
* Present when the field's value has changed.
|
|
21
|
+
*/
|
|
22
|
+
FieldControlDataAttributes["dirty"] = "data-dirty";
|
|
23
|
+
/**
|
|
24
|
+
* Present when the field is filled.
|
|
25
|
+
*/
|
|
26
|
+
FieldControlDataAttributes["filled"] = "data-filled";
|
|
27
|
+
/**
|
|
28
|
+
* Present when the field control is focused.
|
|
29
|
+
*/
|
|
30
|
+
FieldControlDataAttributes["focused"] = "data-focused";
|
|
31
|
+
return FieldControlDataAttributes;
|
|
32
|
+
}({});
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { FieldControlDataAttributes };
|
|
36
|
+
//# sourceMappingURL=FieldControlDataAttributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldControlDataAttributes.js","names":[],"sources":["../../src/field/control/FieldControlDataAttributes.ts"],"sourcesContent":[],"mappings":";AAAA,IAAY,kFAAL;;;;AAIL;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const require_button_Button = require('../button/Button.cjs');
|
|
2
|
+
const require_control_FieldControl = require('../control/FieldControl.cjs');
|
|
3
|
+
let vue = require("vue");
|
|
4
|
+
|
|
5
|
+
//#region src/field/description/FieldDescription.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var FieldDescription_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
7
|
+
name: "FieldDescription",
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
__name: "FieldDescription",
|
|
10
|
+
props: {
|
|
11
|
+
id: {
|
|
12
|
+
type: String,
|
|
13
|
+
required: false
|
|
14
|
+
},
|
|
15
|
+
as: {
|
|
16
|
+
type: null,
|
|
17
|
+
required: false,
|
|
18
|
+
default: "p"
|
|
19
|
+
},
|
|
20
|
+
class: {
|
|
21
|
+
type: Function,
|
|
22
|
+
required: false,
|
|
23
|
+
skipCheck: true
|
|
24
|
+
},
|
|
25
|
+
style: {
|
|
26
|
+
type: [
|
|
27
|
+
Boolean,
|
|
28
|
+
null,
|
|
29
|
+
String,
|
|
30
|
+
Object,
|
|
31
|
+
Array,
|
|
32
|
+
Function
|
|
33
|
+
],
|
|
34
|
+
required: false,
|
|
35
|
+
skipCheck: true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
setup(__props) {
|
|
39
|
+
const props = __props;
|
|
40
|
+
const attrs = (0, vue.useAttrs)();
|
|
41
|
+
const generatedId = require_control_FieldControl.useBaseUiId(void 0);
|
|
42
|
+
const id = (0, vue.computed)(() => props.id ?? generatedId);
|
|
43
|
+
const fieldRootContext = require_control_FieldControl.useFieldRootContext(false);
|
|
44
|
+
const { setMessageIds } = require_control_FieldControl.useLabelableContext();
|
|
45
|
+
(0, vue.watchEffect)((onCleanup) => {
|
|
46
|
+
const currentId = id.value;
|
|
47
|
+
if (currentId) {
|
|
48
|
+
setMessageIds((ids) => ids.concat(currentId));
|
|
49
|
+
onCleanup(() => setMessageIds((ids) => ids.filter((item) => item !== currentId)));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const { tag, mergedProps, renderless } = require_button_Button.useRenderElement({
|
|
53
|
+
componentProps: props,
|
|
54
|
+
state: fieldRootContext.state,
|
|
55
|
+
props: (0, vue.computed)(() => ({
|
|
56
|
+
...attrs,
|
|
57
|
+
id: id.value
|
|
58
|
+
})),
|
|
59
|
+
stateAttributesMapping: require_control_FieldControl.fieldValidityMapping,
|
|
60
|
+
defaultTagName: "p"
|
|
61
|
+
});
|
|
62
|
+
return (_ctx, _cache) => {
|
|
63
|
+
return (0, vue.unref)(renderless) ? (0, vue.renderSlot)(_ctx.$slots, "default", {
|
|
64
|
+
key: 0,
|
|
65
|
+
props: (0, vue.unref)(mergedProps),
|
|
66
|
+
state: (0, vue.unref)(fieldRootContext).state
|
|
67
|
+
}) : ((0, vue.openBlock)(), (0, vue.createBlock)((0, vue.resolveDynamicComponent)((0, vue.unref)(tag)), (0, vue.normalizeProps)((0, vue.mergeProps)({ key: 1 }, (0, vue.unref)(mergedProps))), {
|
|
68
|
+
default: (0, vue.withCtx)(() => [(0, vue.renderSlot)(_ctx.$slots, "default", { state: (0, vue.unref)(fieldRootContext).state })]),
|
|
69
|
+
_: 3
|
|
70
|
+
}, 16));
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/field/description/FieldDescription.vue
|
|
77
|
+
var FieldDescription_default = FieldDescription_vue_vue_type_script_setup_true_lang_default;
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
Object.defineProperty(exports, 'FieldDescription_default', {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () {
|
|
83
|
+
return FieldDescription_default;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=FieldDescription.cjs.map
|