@eldrajs/ui 0.0.0-stage → 0.1.1
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/CHANGELOG.md +1724 -0
- package/LICENSE +21 -0
- package/README.md +3177 -2
- package/dist/VariantPicker-CKw8hmxt.js +9009 -0
- package/dist/componentNames.d.ts +19 -0
- package/dist/components/accordion/Accordion.vue.d.ts +18 -0
- package/dist/components/accordion/AccordionItem.vue.d.ts +26 -0
- package/dist/components/accordion/context.d.ts +20 -0
- package/dist/components/accordion/detailsExclusivity.d.ts +3 -0
- package/dist/components/accordion/heightTransition.d.ts +59 -0
- package/dist/components/accordion/types.d.ts +40 -0
- package/dist/components/avatar/Avatar.vue.d.ts +10 -0
- package/dist/components/avatar/AvatarGroup.vue.d.ts +7 -0
- package/dist/components/avatar/types.d.ts +61 -0
- package/dist/components/badge/Badge.vue.d.ts +24 -0
- package/dist/components/badge/StockBadge.vue.d.ts +10 -0
- package/dist/components/badge/types.d.ts +79 -0
- package/dist/components/breadcrumb/Breadcrumb.vue.d.ts +10 -0
- package/dist/components/breadcrumb/types.d.ts +53 -0
- package/dist/components/button/Button.vue.d.ts +37 -0
- package/dist/components/button/ButtonGroup.vue.d.ts +17 -0
- package/dist/components/button/types.d.ts +68 -0
- package/dist/components/card/ContentCard.vue.d.ts +36 -0
- package/dist/components/card/FeatureCard.vue.d.ts +27 -0
- package/dist/components/card/cueArrow.d.ts +10 -0
- package/dist/components/card/stretchedLink.d.ts +45 -0
- package/dist/components/card/types.d.ts +92 -0
- package/dist/components/carousel/Carousel.vue.d.ts +39 -0
- package/dist/components/carousel/types.d.ts +75 -0
- package/dist/components/carousel/useCarousel.d.ts +152 -0
- package/dist/components/checkbox/Checkbox.vue.d.ts +36 -0
- package/dist/components/checkbox/CheckboxGroup.vue.d.ts +16 -0
- package/dist/components/checkbox/types.d.ts +78 -0
- package/dist/components/chip/Chip.vue.d.ts +37 -0
- package/dist/components/chip/ChipGroup.vue.d.ts +21 -0
- package/dist/components/chip/context.d.ts +22 -0
- package/dist/components/chip/types.d.ts +84 -0
- package/dist/components/container/Container.vue.d.ts +18 -0
- package/dist/components/container/types.d.ts +17 -0
- package/dist/components/currency-input/CurrencyInput.vue.d.ts +17 -0
- package/dist/components/currency-input/types.d.ts +8 -0
- package/dist/components/dialog/Dialog.vue.d.ts +34 -0
- package/dist/components/dialog/types.d.ts +25 -0
- package/dist/components/drawer/Drawer.vue.d.ts +36 -0
- package/dist/components/drawer/types.d.ts +30 -0
- package/dist/components/empty-state/EditorPlaceholder.vue.d.ts +9 -0
- package/dist/components/empty-state/EmptyState.vue.d.ts +28 -0
- package/dist/components/empty-state/types.d.ts +59 -0
- package/dist/components/field-wrapper/FieldError.vue.d.ts +37 -0
- package/dist/components/field-wrapper/FieldWrapper.vue.d.ts +30 -0
- package/dist/components/field-wrapper/context.d.ts +44 -0
- package/dist/components/field-wrapper/types.d.ts +38 -0
- package/dist/components/filter-panel/FilterGroup.vue.d.ts +48 -0
- package/dist/components/filter-panel/FilterPanel.vue.d.ts +77 -0
- package/dist/components/filter-panel/Histogram.vue.d.ts +15 -0
- package/dist/components/filter-panel/facets/ColourFacet.vue.d.ts +12 -0
- package/dist/components/filter-panel/facets/ListFacet.vue.d.ts +12 -0
- package/dist/components/filter-panel/facets/RangeFacet.vue.d.ts +20 -0
- package/dist/components/filter-panel/facets/SizeFacet.vue.d.ts +12 -0
- package/dist/components/filter-panel/facets/ToggleFacet.vue.d.ts +12 -0
- package/dist/components/filter-panel/facets/shared.d.ts +39 -0
- package/dist/components/filter-panel/northwind.d.ts +32 -0
- package/dist/components/filter-panel/swatchInk.d.ts +50 -0
- package/dist/components/filter-panel/types.d.ts +183 -0
- package/dist/components/filter-panel/useFilterPanel.d.ts +230 -0
- package/dist/components/form-layout/FormLayout.vue.d.ts +36 -0
- package/dist/components/form-layout/context.d.ts +33 -0
- package/dist/components/form-layout/focusInvalid.d.ts +18 -0
- package/dist/components/form-layout/types.d.ts +52 -0
- package/dist/components/icon/Icon.vue.d.ts +8 -0
- package/dist/components/icon/types.d.ts +29 -0
- package/dist/components/image/Image.vue.d.ts +21 -0
- package/dist/components/image/types.d.ts +81 -0
- package/dist/components/input/Input.vue.d.ts +47 -0
- package/dist/components/input/classes.d.ts +110 -0
- package/dist/components/input/types.d.ts +55 -0
- package/dist/components/internal/ValueText.vue.d.ts +7 -0
- package/dist/components/lightbox/Lightbox.vue.d.ts +19 -0
- package/dist/components/lightbox/types.d.ts +47 -0
- package/dist/components/link/Link.vue.d.ts +23 -0
- package/dist/components/link/types.d.ts +40 -0
- package/dist/components/load-more/LoadMore.vue.d.ts +12 -0
- package/dist/components/load-more/types.d.ts +21 -0
- package/dist/components/logo-item/LogoItem.vue.d.ts +10 -0
- package/dist/components/logo-item/types.d.ts +37 -0
- package/dist/components/pagination/Pagination.vue.d.ts +15 -0
- package/dist/components/pagination/types.d.ts +51 -0
- package/dist/components/popover/Popover.vue.d.ts +31 -0
- package/dist/components/popover/types.d.ts +53 -0
- package/dist/components/price/Price.vue.d.ts +25 -0
- package/dist/components/price/types.d.ts +104 -0
- package/dist/components/product-card/ProductCard.vue.d.ts +22 -0
- package/dist/components/product-card/types.d.ts +123 -0
- package/dist/components/quantity-stepper/QuantityStepper.vue.d.ts +26 -0
- package/dist/components/quantity-stepper/types.d.ts +35 -0
- package/dist/components/radio/RadioGroup.vue.d.ts +38 -0
- package/dist/components/radio/types.d.ts +39 -0
- package/dist/components/range-slider/RangeSlider.vue.d.ts +70 -0
- package/dist/components/range-slider/types.d.ts +151 -0
- package/dist/components/range-slider/useRangeSlider.d.ts +106 -0
- package/dist/components/rating/Rating.vue.d.ts +22 -0
- package/dist/components/rating/RatingStars.vue.d.ts +16 -0
- package/dist/components/rating/types.d.ts +45 -0
- package/dist/components/search-bar/SearchBar.vue.d.ts +47 -0
- package/dist/components/search-bar/SearchResultsPanel.vue.d.ts +93 -0
- package/dist/components/search-bar/shortcutOwner.d.ts +39 -0
- package/dist/components/search-bar/types.d.ts +122 -0
- package/dist/components/search-modal/SearchModal.vue.d.ts +53 -0
- package/dist/components/search-modal/types.d.ts +59 -0
- package/dist/components/section/Section.vue.d.ts +21 -0
- package/dist/components/section/context.d.ts +23 -0
- package/dist/components/section/types.d.ts +34 -0
- package/dist/components/select/MultiSelect.vue.d.ts +62 -0
- package/dist/components/select/Select.vue.d.ts +57 -0
- package/dist/components/select/SelectPanel.vue.d.ts +97 -0
- package/dist/components/select/openRegistry.d.ts +11 -0
- package/dist/components/select/panelParts.d.ts +91 -0
- package/dist/components/select/types.d.ts +129 -0
- package/dist/components/select/useListbox.d.ts +106 -0
- package/dist/components/select/useOptionList.d.ts +61 -0
- package/dist/components/select/usePopover.d.ts +147 -0
- package/dist/components/skeleton/Skeleton.vue.d.ts +12 -0
- package/dist/components/skeleton/types.d.ts +38 -0
- package/dist/components/spinner/Spinner.vue.d.ts +3 -0
- package/dist/components/switch/Switch.vue.d.ts +30 -0
- package/dist/components/switch/types.d.ts +20 -0
- package/dist/components/tabs/Tab.vue.d.ts +17 -0
- package/dist/components/tabs/TabPanel.vue.d.ts +16 -0
- package/dist/components/tabs/Tabs.vue.d.ts +28 -0
- package/dist/components/tabs/context.d.ts +48 -0
- package/dist/components/tabs/types.d.ts +63 -0
- package/dist/components/textarea/Textarea.vue.d.ts +27 -0
- package/dist/components/textarea/supportsFieldSizing.d.ts +10 -0
- package/dist/components/textarea/types.d.ts +32 -0
- package/dist/components/toast/Toast.vue.d.ts +16 -0
- package/dist/components/toast/Toaster.vue.d.ts +13 -0
- package/dist/components/toast/types.d.ts +44 -0
- package/dist/components/tooltip/Tooltip.vue.d.ts +9 -0
- package/dist/components/tooltip/supportsFocusVisible.d.ts +17 -0
- package/dist/components/tooltip/types.d.ts +46 -0
- package/dist/components/unit-input/UnitInput.vue.d.ts +55 -0
- package/dist/components/unit-input/types.d.ts +68 -0
- package/dist/components/unit-input/undo-redo.d.ts +6 -0
- package/dist/components/variant-picker/VariantPicker.vue.d.ts +15 -0
- package/dist/components/variant-picker/types.d.ts +49 -0
- package/dist/components/visually-hidden/VisuallyHidden.vue.d.ts +18 -0
- package/dist/components/visually-hidden/types.d.ts +14 -0
- package/dist/composables/dialogStack.d.ts +52 -0
- package/dist/composables/teleportTarget.d.ts +79 -0
- package/dist/composables/useControllableModel.d.ts +16 -0
- package/dist/composables/useDialog.d.ts +84 -0
- package/dist/composables/useFloating.d.ts +82 -0
- package/dist/composables/useHeadingTag.d.ts +24 -0
- package/dist/composables/useLocale.d.ts +81 -0
- package/dist/composables/useMessages.d.ts +30 -0
- package/dist/composables/useOverlay.d.ts +88 -0
- package/dist/composables/useSlotPresence.d.ts +29 -0
- package/dist/composables/useToast.d.ts +53 -0
- package/dist/icons/paths.d.ts +10 -0
- package/dist/index.d.ts +135 -0
- package/dist/index.js +12586 -0
- package/dist/listFormat-1UrH38f2.js +39 -0
- package/dist/messages/en-US.d.ts +485 -0
- package/dist/messages/index.d.ts +2 -0
- package/dist/messages/is-IS.d.ts +16 -0
- package/dist/messages/is-IS.js +169 -0
- package/dist/resolver.d.ts +43 -0
- package/dist/resolver.js +121 -0
- package/dist/style.css +5251 -0
- package/dist/tailwind.css +2057 -0
- package/dist/tokens.css +134 -0
- package/dist/utils/avatar.d.ts +15 -0
- package/dist/utils/color.d.ts +11 -0
- package/dist/utils/cssTiming.d.ts +40 -0
- package/dist/utils/cx.d.ts +31 -0
- package/dist/utils/date.d.ts +45 -0
- package/dist/utils/id.d.ts +36 -0
- package/dist/utils/listFormat.d.ts +22 -0
- package/dist/utils/mask.d.ts +48 -0
- package/dist/utils/number-format.d.ts +250 -0
- package/dist/utils/numeric-input.d.ts +42 -0
- package/dist/utils/rating.d.ts +26 -0
- package/dist/utils/ratio.d.ts +18 -0
- package/dist/utils/tagRecipe.d.ts +24 -0
- package/dist/utils/valueFade.d.ts +42 -0
- package/dist/vee-validate/FieldCheckbox.vue.d.ts +14 -0
- package/dist/vee-validate/FieldCheckboxGroup.vue.d.ts +14 -0
- package/dist/vee-validate/FieldCurrencyInput.vue.d.ts +14 -0
- package/dist/vee-validate/FieldInput.vue.d.ts +14 -0
- package/dist/vee-validate/FieldMultiSelect.vue.d.ts +14 -0
- package/dist/vee-validate/FieldQuantityStepper.vue.d.ts +14 -0
- package/dist/vee-validate/FieldRadioGroup.vue.d.ts +14 -0
- package/dist/vee-validate/FieldSearchBar.vue.d.ts +14 -0
- package/dist/vee-validate/FieldSelect.vue.d.ts +14 -0
- package/dist/vee-validate/FieldSwitch.vue.d.ts +14 -0
- package/dist/vee-validate/FieldTextarea.vue.d.ts +14 -0
- package/dist/vee-validate/FieldUnitInput.vue.d.ts +14 -0
- package/dist/vee-validate/FieldVariantPicker.vue.d.ts +14 -0
- package/dist/vee-validate/Form.vue.d.ts +27 -0
- package/dist/vee-validate/context.d.ts +48 -0
- package/dist/vee-validate/index.d.ts +27 -0
- package/dist/vee-validate/types.d.ts +115 -0
- package/dist/vee-validate/useFieldControl.d.ts +67 -0
- package/dist/vee-validate.js +1154 -0
- package/package.json +105 -3
|
@@ -0,0 +1,1154 @@
|
|
|
1
|
+
import { O as CurrencyInput_default, b as focusInvalid, d as MultiSelect_default, ht as useMessages, i as SearchBar_default, it as CheckboxGroup_default, k as UnitInput_default, l as RadioGroup_default, n as Textarea_default, ot as Checkbox_default, r as Select_default, st as FIELD_KEY, t as VariantPicker_default, u as QuantityStepper_default, w as Input_default, x as Switch_default, y as FormLayout_default, yt as useUiId } from "./VariantPicker-CKw8hmxt.js";
|
|
2
|
+
import { Fragment, computed, createBlock, createElementBlock, createElementVNode, createSlots, createTextVNode, defineComponent, guardReactiveProps, inject, isRef, mergeProps, nextTick, normalizeClass, normalizeProps, onMounted, onScopeDispose, openBlock, provide, ref, renderList, renderSlot, toDisplayString, unref, watch, withCtx } from "vue";
|
|
3
|
+
import { FormContextKey, useField, useForm } from "vee-validate";
|
|
4
|
+
//#region src/vee-validate/context.ts
|
|
5
|
+
/**
|
|
6
|
+
* The server's field errors, keyed by the path a `Field*` validates under (its `path`, or its
|
|
7
|
+
* `name` when there is none).
|
|
8
|
+
*
|
|
9
|
+
* `Form` provides it from its `apiErrors` prop and applies it to the form with vee-validate's own
|
|
10
|
+
* `setErrors`, so a 422 from the shop's API lands on the field it belongs to rather than in a
|
|
11
|
+
* banner above the form. Every `Field*` injects it and removes **its own** entry the moment its
|
|
12
|
+
* value changes — a server error is a statement about the value that was sent, so it stops being
|
|
13
|
+
* true as soon as the customer edits it, and nothing else would reliably clear it (a rule that
|
|
14
|
+
* already passes has no new message to overwrite it with).
|
|
15
|
+
*
|
|
16
|
+
* How long an entry survives a change to a *different* field is vee-validate's, not this key's.
|
|
17
|
+
* Before the first submit — and with per-field `rules` at any time — only the changed field is
|
|
18
|
+
* revalidated, so another field's server error stays put. After a submit, with a form-level
|
|
19
|
+
* `validationSchema`, every already-validated field is revalidated on each change
|
|
20
|
+
* (`validated-only`), and a field that now passes has its manually set error replaced by that
|
|
21
|
+
* pass — so the server's message for it goes too. Send the current map with each response rather
|
|
22
|
+
* than treating one as sticky; `src/vee-validate/__tests__/vee-validate.spec.ts` pins both halves.
|
|
23
|
+
*
|
|
24
|
+
* It is a plain `Ref`, so a consumer can provide one itself and drive server errors from outside a
|
|
25
|
+
* `Form`:
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { API_ERRORS_KEY } from '@eldrajs/ui/vee-validate';
|
|
29
|
+
* provide(API_ERRORS_KEY, ref({ email: 'That address is already subscribed.' }));
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
var API_ERRORS_KEY = Symbol("eldra-ui:api-errors");
|
|
33
|
+
/** The key a `Form` provides its {@link FieldAnchorRegistry} on. Internal to this entry. */
|
|
34
|
+
var FIELD_ANCHORS_KEY = Symbol("eldra-ui:field-anchors");
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/vee-validate/useFieldControl.ts
|
|
37
|
+
/** The props a `Field*` keeps for itself and never forwards to the component it wraps. */
|
|
38
|
+
var FIELD_ONLY = [
|
|
39
|
+
"path",
|
|
40
|
+
"rules",
|
|
41
|
+
"label",
|
|
42
|
+
"id"
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* The whole of what a `Field*` does, minus the one component it renders.
|
|
46
|
+
*
|
|
47
|
+
* Each `Field*` is a thin SFC over this: `useField(name, rules, { label })` for the value and the
|
|
48
|
+
* message, a gate that keeps a message hidden until the customer has left the field or submitted
|
|
49
|
+
* the form, the `id` the form's error summary links to, and the server error that stops being true
|
|
50
|
+
* as soon as the value changes. Keeping it here is what makes the eleven components agree on all
|
|
51
|
+
* of that rather than eleven files drifting apart.
|
|
52
|
+
*
|
|
53
|
+
* **The gate** is the spec's own rule (Form layout → Behaviour & motion: "Validate on submit, then
|
|
54
|
+
* on blur for fields that were invalid after the first submit"). vee-validate revalidates on every
|
|
55
|
+
* keystroke, so the field always *knows* its message; showing it only once `meta.touched` or the
|
|
56
|
+
* form has been submitted is what stops an error appearing under a half-typed email address.
|
|
57
|
+
*/
|
|
58
|
+
function useFieldControl(props, options) {
|
|
59
|
+
/**
|
|
60
|
+
* Where the value lives. `name` for every control whose `name` is the native form field name;
|
|
61
|
+
* `path` for the one whose is not — a `VariantPicker`'s `name` is the visible option name, so it
|
|
62
|
+
* would otherwise be both the legend and the key in `values`, and one of the two would be wrong.
|
|
63
|
+
*/
|
|
64
|
+
const path = computed(() => props.path ?? props.name);
|
|
65
|
+
const rules = computed(() => props.rules);
|
|
66
|
+
const { value, errorMessage, handleBlur, meta } = useField(path, rules, {
|
|
67
|
+
label: () => props.label,
|
|
68
|
+
initialValue: options.initialValue
|
|
69
|
+
});
|
|
70
|
+
const model = computed({
|
|
71
|
+
get: () => value.value ?? options.empty,
|
|
72
|
+
set: (next) => {
|
|
73
|
+
value.value = next;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* The form above, for `submitCount`. Injected rather than taken from `useFormContext()` so a
|
|
78
|
+
* `Field*` used on its own — a single validated search box, say — works with no form at all.
|
|
79
|
+
*/
|
|
80
|
+
const form = inject(FormContextKey, null);
|
|
81
|
+
const submitted = computed(() => (form?.submitCount.value ?? 0) > 0);
|
|
82
|
+
const apiErrors = inject(API_ERRORS_KEY, null);
|
|
83
|
+
const hasApiError = computed(() => apiErrors !== null && apiErrors.value[path.value] !== void 0);
|
|
84
|
+
/**
|
|
85
|
+
* A server error is never held back: it is the answer to a submit the customer has already made,
|
|
86
|
+
* so there is nothing left to wait for — which also covers a form rendered with errors from a
|
|
87
|
+
* round trip that happened before this page existed.
|
|
88
|
+
*/
|
|
89
|
+
const error = computed(() => meta.touched || submitted.value || hasApiError.value ? errorMessage.value : void 0);
|
|
90
|
+
const invalid = computed(() => error.value !== void 0);
|
|
91
|
+
const wrapper = inject(FIELD_KEY, null);
|
|
92
|
+
const ownError = computed(() => wrapper === null ? error.value : void 0);
|
|
93
|
+
/**
|
|
94
|
+
* The id. A `FieldWrapper` already owns one and has tied its `<label for>` to it, so nothing is
|
|
95
|
+
* forwarded there — handing a `Checkbox` or a `Switch` an explicit `id` is what tells it the
|
|
96
|
+
* wrapper is *not* naming it, and it would draw a second label. Standing on its own, the field
|
|
97
|
+
* generates one so the error summary has something to link to.
|
|
98
|
+
*/
|
|
99
|
+
const ownId = useUiId("field");
|
|
100
|
+
const id = computed(() => props.id ?? (wrapper === null && options.hasIdProp !== false ? ownId.value : void 0));
|
|
101
|
+
const anchorId = computed(() => props.id ?? wrapper?.value.id ?? (options.hasIdProp !== false ? ownId.value : void 0));
|
|
102
|
+
const anchors = inject(FIELD_ANCHORS_KEY, null);
|
|
103
|
+
if (anchors !== null) {
|
|
104
|
+
watch([path, anchorId], ([current, target], previous) => {
|
|
105
|
+
const previousPath = previous?.[0];
|
|
106
|
+
if (previousPath !== void 0 && previousPath !== current) anchors.unregister(previousPath);
|
|
107
|
+
anchors.register(current, target);
|
|
108
|
+
}, { immediate: true });
|
|
109
|
+
onScopeDispose(() => anchors.unregister(path.value));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A server error is a statement about the value that was sent, so it stops being true the moment
|
|
113
|
+
* the customer edits the field — and nothing else would clear it, because a rule that already
|
|
114
|
+
* passes produces no new message to overwrite it with. Dropping the entry is what tells the
|
|
115
|
+
* `Form` to unset it (see `context.ts`).
|
|
116
|
+
*/
|
|
117
|
+
if (apiErrors !== null) watch(value, () => {
|
|
118
|
+
if (!(path.value in apiErrors.value)) return;
|
|
119
|
+
const next = { ...apiErrors.value };
|
|
120
|
+
delete next[path.value];
|
|
121
|
+
apiErrors.value = next;
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
model,
|
|
125
|
+
error,
|
|
126
|
+
invalid,
|
|
127
|
+
ownError,
|
|
128
|
+
id,
|
|
129
|
+
onBlur: handleBlur
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Everything the `Field*` was given, minus what it keeps for itself — the props it forwards to the
|
|
134
|
+
* agnostic component underneath, typed as exactly that `Omit`.
|
|
135
|
+
*
|
|
136
|
+
* Built by walking the props object rather than by destructuring, so a prop added to any of the
|
|
137
|
+
* eleven components is forwarded the day it is added and nothing here has to be told about it.
|
|
138
|
+
* `undefined` values are forwarded too, which is exactly right: Vue applies a component's own
|
|
139
|
+
* `withDefaults` value for a prop that is `undefined`, so an unset prop still lands on its default.
|
|
140
|
+
*/
|
|
141
|
+
function useControlProps(props, omit) {
|
|
142
|
+
return computed(() => {
|
|
143
|
+
const forwarded = {};
|
|
144
|
+
for (const [key, value] of Object.entries(props)) {
|
|
145
|
+
if (omit.includes(key)) continue;
|
|
146
|
+
forwarded[key] = value;
|
|
147
|
+
}
|
|
148
|
+
return forwarded;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/vee-validate/Form.vue?vue&type=script&setup=true&lang.ts
|
|
153
|
+
var _hoisted_1 = ["href"];
|
|
154
|
+
var SUMMARY_TITLE = "font-semibold";
|
|
155
|
+
var SUMMARY_LIST = "mt-1 list-disc ps-4";
|
|
156
|
+
var SUMMARY_LINK = "underline";
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/vee-validate/Form.vue
|
|
159
|
+
var Form_default = /* @__PURE__ */ defineComponent({
|
|
160
|
+
__name: "Form",
|
|
161
|
+
props: {
|
|
162
|
+
initialValues: {},
|
|
163
|
+
validationSchema: {},
|
|
164
|
+
apiErrors: {},
|
|
165
|
+
successMessage: {},
|
|
166
|
+
layout: {},
|
|
167
|
+
heading: {},
|
|
168
|
+
headingLevel: {},
|
|
169
|
+
ariaLabel: {},
|
|
170
|
+
action: {},
|
|
171
|
+
method: {},
|
|
172
|
+
novalidate: { type: Boolean },
|
|
173
|
+
submitting: { type: Boolean },
|
|
174
|
+
statusMessage: {},
|
|
175
|
+
classes: {}
|
|
176
|
+
},
|
|
177
|
+
emits: ["submit", "invalid"],
|
|
178
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
179
|
+
const props = __props;
|
|
180
|
+
const emit = __emit;
|
|
181
|
+
const m = useMessages();
|
|
182
|
+
const form = useForm({
|
|
183
|
+
initialValues: props.initialValues,
|
|
184
|
+
validationSchema: computed(() => props.validationSchema)
|
|
185
|
+
});
|
|
186
|
+
const { errors, values, meta, isSubmitting, submitCount, handleSubmit, setErrors, setFieldError } = form;
|
|
187
|
+
/**
|
|
188
|
+
* The server's field errors. Held in a ref of this form's own rather than read straight from the
|
|
189
|
+
* prop, because a `Field*` drops its own entry the moment its value changes (see `context.ts`) —
|
|
190
|
+
* and a prop is not the field's to write to.
|
|
191
|
+
*/
|
|
192
|
+
const apiErrors = ref({ ...props.apiErrors });
|
|
193
|
+
provide(API_ERRORS_KEY, apiErrors);
|
|
194
|
+
/**
|
|
195
|
+
* The errors that should currently be **shown**, which is not the same set as the errors that
|
|
196
|
+
* exist. vee-validate revalidates on every keystroke, so a field knows its message long before the
|
|
197
|
+
* customer is done typing; the spec's rule (Form layout → Behaviour & motion) is to validate on
|
|
198
|
+
* submit and then on blur, so a message surfaces once its field has been touched or the form has
|
|
199
|
+
* been submitted. Each `Field*` applies the same gate to its own `invalid` state, so what a
|
|
200
|
+
* `FieldWrapper` shows and what the control marks itself as cannot disagree.
|
|
201
|
+
*/
|
|
202
|
+
const visibleErrors = computed(() => {
|
|
203
|
+
const shown = {};
|
|
204
|
+
for (const [path, message] of Object.entries(errors.value)) {
|
|
205
|
+
if (message === void 0) continue;
|
|
206
|
+
if (submitCount.value > 0 || form.isFieldTouched(path) || path in apiErrors.value) shown[path] = message;
|
|
207
|
+
}
|
|
208
|
+
return shown;
|
|
209
|
+
});
|
|
210
|
+
/**
|
|
211
|
+
* Where the summary's links point. Only a `Field*` can resolve its control's id — it may be the one
|
|
212
|
+
* a `FieldWrapper` generated and tied its `<label for>` to — so each one registers it here rather
|
|
213
|
+
* than the form hunting through the DOM for it.
|
|
214
|
+
*/
|
|
215
|
+
const anchors = ref({});
|
|
216
|
+
provide(FIELD_ANCHORS_KEY, {
|
|
217
|
+
register(name, id) {
|
|
218
|
+
if (id === void 0) delete anchors.value[name];
|
|
219
|
+
else anchors.value[name] = id;
|
|
220
|
+
},
|
|
221
|
+
unregister(name) {
|
|
222
|
+
delete anchors.value[name];
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
const summary = computed(() => Object.entries(visibleErrors.value).map(([name, message]) => {
|
|
226
|
+
const id = anchors.value[name];
|
|
227
|
+
return {
|
|
228
|
+
name,
|
|
229
|
+
message,
|
|
230
|
+
href: id === void 0 ? void 0 : `#${id}`
|
|
231
|
+
};
|
|
232
|
+
}));
|
|
233
|
+
/**
|
|
234
|
+
* Spec "Form layout" → States, Invalid on submit: "Long forms add an error summary alert at the
|
|
235
|
+
* top … that lists a link to each error". After a submit, and only then — before the first attempt
|
|
236
|
+
* an alert listing everything still to fill in is noise, not help.
|
|
237
|
+
*/
|
|
238
|
+
const showSummary = computed(() => submitCount.value > 0 && summary.value.length > 0);
|
|
239
|
+
watch(() => props.apiErrors, (next) => {
|
|
240
|
+
apiErrors.value = { ...next };
|
|
241
|
+
}, { deep: true });
|
|
242
|
+
/** The paths currently carrying a server error, so one that goes away is actually unset. */
|
|
243
|
+
let applied = [];
|
|
244
|
+
function applyApiErrors(next) {
|
|
245
|
+
for (const path of applied) if (!(path in next)) setFieldError(path, void 0);
|
|
246
|
+
if (Object.keys(next).length > 0) setErrors(next);
|
|
247
|
+
applied = Object.keys(next);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* On mount, not immediately: `setFieldError` on a path no field has registered yet does nothing,
|
|
251
|
+
* and a `Form`'s own `setup()` runs before its fields exist. A parent's `onMounted` runs after
|
|
252
|
+
* every child's, which is exactly when the fields are there to receive them.
|
|
253
|
+
*/
|
|
254
|
+
onMounted(() => applyApiErrors(apiErrors.value));
|
|
255
|
+
watch(() => ({ ...apiErrors.value }), applyApiErrors);
|
|
256
|
+
/** A new attempt makes the last response stale: its errors describe values that are being resent. */
|
|
257
|
+
function clearApiErrors() {
|
|
258
|
+
const previous = applied;
|
|
259
|
+
applied = [];
|
|
260
|
+
apiErrors.value = {};
|
|
261
|
+
for (const path of previous) setFieldError(path, void 0);
|
|
262
|
+
}
|
|
263
|
+
const layout = ref(null);
|
|
264
|
+
/**
|
|
265
|
+
* Focus the first invalid field after vee-validate has rejected a submit.
|
|
266
|
+
*
|
|
267
|
+
* `FormLayout` can do this itself, but it can only refuse what the DOM already says is invalid —
|
|
268
|
+
* and on the **first** attempt nothing is marked yet, because no field has been touched. So this
|
|
269
|
+
* form owns the move, over the same `[aria-invalid="true"]` query and the same `focusInvalid`,
|
|
270
|
+
* falling back to the first summary anchor for a control with no invalid state of its own (a
|
|
271
|
+
* `Switch`, a `VariantPicker`). The layout's own move is turned off (`:focus-on-invalid="false"`),
|
|
272
|
+
* so a refused submit moves focus once rather than to one element and then to another.
|
|
273
|
+
*/
|
|
274
|
+
function focusFirstInvalid() {
|
|
275
|
+
const root = layout.value?.$el;
|
|
276
|
+
if (!(root instanceof HTMLElement)) return;
|
|
277
|
+
const marked = root.querySelector("[aria-invalid=\"true\"]");
|
|
278
|
+
if (marked !== null) {
|
|
279
|
+
focusInvalid(marked);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const first = summary.value.find((entry) => entry.href !== void 0);
|
|
283
|
+
if (first?.href === void 0) return;
|
|
284
|
+
const target = root.ownerDocument.getElementById(first.href.slice(1));
|
|
285
|
+
if (target !== null) focusInvalid(target);
|
|
286
|
+
}
|
|
287
|
+
/** Set by a submit that validated, and cleared by the next attempt. Drives `successMessage`. */
|
|
288
|
+
const submitted = ref(false);
|
|
289
|
+
const runSubmit = handleSubmit((submitValues, ctx) => {
|
|
290
|
+
submitted.value = true;
|
|
291
|
+
emit("submit", submitValues, ctx);
|
|
292
|
+
}, ({ errors: failed }) => {
|
|
293
|
+
emit("invalid", failed);
|
|
294
|
+
nextTick(focusFirstInvalid);
|
|
295
|
+
});
|
|
296
|
+
/**
|
|
297
|
+
* `FormLayout` emits `submit` when the DOM holds no invalid field and `invalid` when it does, and
|
|
298
|
+
* both mean the same thing here: run the form's own validation. Taking only `submit` would leave a
|
|
299
|
+
* form whose first touched field is already invalid unable to validate the *rest* of itself — the
|
|
300
|
+
* layout would stop the submit, `submitCount` would never rise, and the untouched fields would
|
|
301
|
+
* keep their messages to themselves.
|
|
302
|
+
*
|
|
303
|
+
* vee-validate's `handleSubmit` calls `preventDefault()` on the event it is given, so the form does
|
|
304
|
+
* not also post; without an event (the `invalid` path, which the layout has already prevented)
|
|
305
|
+
* there is nothing to prevent.
|
|
306
|
+
*/
|
|
307
|
+
function onLayoutSubmit(payload) {
|
|
308
|
+
submitted.value = false;
|
|
309
|
+
clearApiErrors();
|
|
310
|
+
runSubmit(payload.event);
|
|
311
|
+
}
|
|
312
|
+
function onLayoutInvalid() {
|
|
313
|
+
submitted.value = false;
|
|
314
|
+
clearApiErrors();
|
|
315
|
+
runSubmit();
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Spec "Form layout" → States, Success: "announce it in a polite live region". `FormLayout`'s
|
|
319
|
+
* status region is never visible, so this is the announcement and nothing more — replacing the form
|
|
320
|
+
* with a confirmation, or navigating, stays the page's job. An explicit `statusMessage` wins, which
|
|
321
|
+
* is how a consumer announces the *server's* answer rather than the submit.
|
|
322
|
+
*/
|
|
323
|
+
const statusMessage = computed(() => props.statusMessage ?? (submitted.value ? props.successMessage : void 0));
|
|
324
|
+
/** `submitting` is the form's own state or the consumer's, whichever is true. */
|
|
325
|
+
const submitting = computed(() => props.submitting === true || isSubmitting.value);
|
|
326
|
+
const layoutProps = useControlProps(props, [
|
|
327
|
+
"initialValues",
|
|
328
|
+
"validationSchema",
|
|
329
|
+
"apiErrors",
|
|
330
|
+
"successMessage",
|
|
331
|
+
"statusMessage",
|
|
332
|
+
"submitting"
|
|
333
|
+
]);
|
|
334
|
+
const slotProps = computed(() => ({
|
|
335
|
+
errors: visibleErrors.value,
|
|
336
|
+
values,
|
|
337
|
+
meta: meta.value,
|
|
338
|
+
isSubmitting: isSubmitting.value,
|
|
339
|
+
submitCount: submitCount.value
|
|
340
|
+
}));
|
|
341
|
+
/** The vee-validate form context, for a consumer that needs `resetForm`, `setErrors` or `values`. */
|
|
342
|
+
__expose({ form });
|
|
343
|
+
/** The summary's own type, kept off the error box's `text-body-sm` body copy. */
|
|
344
|
+
return (_ctx, _cache) => {
|
|
345
|
+
return openBlock(), createBlock(FormLayout_default, mergeProps({
|
|
346
|
+
ref_key: "layout",
|
|
347
|
+
ref: layout
|
|
348
|
+
}, unref(layoutProps), {
|
|
349
|
+
submitting: submitting.value,
|
|
350
|
+
"status-message": statusMessage.value,
|
|
351
|
+
"focus-on-invalid": false,
|
|
352
|
+
onSubmit: onLayoutSubmit,
|
|
353
|
+
onInvalid: onLayoutInvalid
|
|
354
|
+
}), createSlots({
|
|
355
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(slotProps.value)))]),
|
|
356
|
+
_: 2
|
|
357
|
+
}, [showSummary.value ? {
|
|
358
|
+
name: "errorSummary",
|
|
359
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "errorSummary", normalizeProps(guardReactiveProps(slotProps.value)), () => [createElementVNode("p", { class: normalizeClass(SUMMARY_TITLE) }, toDisplayString(unref(m).formErrors(summary.value.length)), 1), createElementVNode("ul", { class: normalizeClass(SUMMARY_LIST) }, [(openBlock(true), createElementBlock(Fragment, null, renderList(summary.value, (entry) => {
|
|
360
|
+
return openBlock(), createElementBlock("li", { key: entry.name }, [entry.href !== void 0 ? (openBlock(), createElementBlock("a", {
|
|
361
|
+
key: 0,
|
|
362
|
+
href: entry.href,
|
|
363
|
+
class: normalizeClass(SUMMARY_LINK)
|
|
364
|
+
}, toDisplayString(entry.message), 9, _hoisted_1)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(entry.message), 1)], 64))]);
|
|
365
|
+
}), 128))])])]),
|
|
366
|
+
key: "0"
|
|
367
|
+
} : void 0, _ctx.$slots.actions ? {
|
|
368
|
+
name: "actions",
|
|
369
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "actions", normalizeProps(guardReactiveProps(slotProps.value)))]),
|
|
370
|
+
key: "1"
|
|
371
|
+
} : void 0]), 1040, ["submitting", "status-message"]);
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/vee-validate/FieldCheckbox.vue
|
|
377
|
+
var FieldCheckbox_default = /* @__PURE__ */ defineComponent({
|
|
378
|
+
__name: "FieldCheckbox",
|
|
379
|
+
props: {
|
|
380
|
+
indeterminate: { type: Boolean },
|
|
381
|
+
value: {},
|
|
382
|
+
name: {},
|
|
383
|
+
size: {},
|
|
384
|
+
hint: {},
|
|
385
|
+
required: { type: Boolean },
|
|
386
|
+
disabled: { type: Boolean },
|
|
387
|
+
controls: {},
|
|
388
|
+
id: {},
|
|
389
|
+
describedBy: {},
|
|
390
|
+
classes: {},
|
|
391
|
+
path: {},
|
|
392
|
+
rules: { type: [
|
|
393
|
+
String,
|
|
394
|
+
Object,
|
|
395
|
+
Function,
|
|
396
|
+
Array
|
|
397
|
+
] },
|
|
398
|
+
label: {}
|
|
399
|
+
},
|
|
400
|
+
setup(__props) {
|
|
401
|
+
/**
|
|
402
|
+
* A single `Checkbox` — a consent box, "Billing address is the same" — bound to a **boolean**
|
|
403
|
+
* field. The multi-choice fieldset is `FieldCheckboxGroup`.
|
|
404
|
+
*
|
|
405
|
+
* Deliberately not `useField`'s `type: 'checkbox'` mode: that one keeps an array of checked values
|
|
406
|
+
* across several inputs sharing a name, which is the group's job. Here the field simply holds
|
|
407
|
+
* `true` or `false`, so `rules: 'required'` reads as "this box must be ticked".
|
|
408
|
+
*/
|
|
409
|
+
const props = __props;
|
|
410
|
+
const { model, invalid, id, onBlur } = useFieldControl(props, { empty: false });
|
|
411
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
412
|
+
return (_ctx, _cache) => {
|
|
413
|
+
return openBlock(), createBlock(Checkbox_default, mergeProps(unref(control), {
|
|
414
|
+
id: unref(id),
|
|
415
|
+
modelValue: unref(model),
|
|
416
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
417
|
+
invalid: unref(invalid),
|
|
418
|
+
onBlur: unref(onBlur)
|
|
419
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
420
|
+
return {
|
|
421
|
+
name: slotName,
|
|
422
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
423
|
+
};
|
|
424
|
+
})]), 1040, [
|
|
425
|
+
"id",
|
|
426
|
+
"modelValue",
|
|
427
|
+
"invalid",
|
|
428
|
+
"onBlur"
|
|
429
|
+
]);
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/vee-validate/FieldCheckboxGroup.vue
|
|
435
|
+
var FieldCheckboxGroup_default = /* @__PURE__ */ defineComponent({
|
|
436
|
+
__name: "FieldCheckboxGroup",
|
|
437
|
+
props: {
|
|
438
|
+
legend: {},
|
|
439
|
+
options: {},
|
|
440
|
+
layout: {},
|
|
441
|
+
name: {},
|
|
442
|
+
classes: {},
|
|
443
|
+
path: {},
|
|
444
|
+
rules: { type: [
|
|
445
|
+
String,
|
|
446
|
+
Object,
|
|
447
|
+
Function,
|
|
448
|
+
Array
|
|
449
|
+
] },
|
|
450
|
+
label: {}
|
|
451
|
+
},
|
|
452
|
+
setup(__props) {
|
|
453
|
+
/**
|
|
454
|
+
* `CheckboxGroup` bound to a **string array** field — one question, several answers ("Material").
|
|
455
|
+
*
|
|
456
|
+
* A `<fieldset>` cannot take focus and native `blur` does not bubble, so the touch comes from
|
|
457
|
+
* `focusout`, which does. The group draws its own error row only when it is standing on its own:
|
|
458
|
+
* inside a `FieldWrapper` the wrapper owns that row (see `useFieldControl`'s `ownError`).
|
|
459
|
+
*/
|
|
460
|
+
const EMPTY = [];
|
|
461
|
+
const props = __props;
|
|
462
|
+
const { model, ownError, onBlur } = useFieldControl(props, {
|
|
463
|
+
empty: EMPTY,
|
|
464
|
+
hasIdProp: false
|
|
465
|
+
});
|
|
466
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
467
|
+
return (_ctx, _cache) => {
|
|
468
|
+
return openBlock(), createBlock(CheckboxGroup_default, mergeProps(unref(control), {
|
|
469
|
+
modelValue: unref(model),
|
|
470
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
471
|
+
error: unref(ownError),
|
|
472
|
+
onFocusout: unref(onBlur)
|
|
473
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
474
|
+
return {
|
|
475
|
+
name: slotName,
|
|
476
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
477
|
+
};
|
|
478
|
+
})]), 1040, [
|
|
479
|
+
"modelValue",
|
|
480
|
+
"error",
|
|
481
|
+
"onFocusout"
|
|
482
|
+
]);
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/vee-validate/FieldCurrencyInput.vue
|
|
488
|
+
var FieldCurrencyInput_default = /* @__PURE__ */ defineComponent({
|
|
489
|
+
__name: "FieldCurrencyInput",
|
|
490
|
+
props: {
|
|
491
|
+
locale: {},
|
|
492
|
+
label: {},
|
|
493
|
+
maxFraction: {},
|
|
494
|
+
max: {},
|
|
495
|
+
min: {},
|
|
496
|
+
step: {},
|
|
497
|
+
enableDragAdjust: { type: Boolean },
|
|
498
|
+
clearable: { type: Boolean },
|
|
499
|
+
currency: {},
|
|
500
|
+
narrowSymbol: { type: Boolean },
|
|
501
|
+
size: {},
|
|
502
|
+
id: {},
|
|
503
|
+
name: {},
|
|
504
|
+
leadingIcon: {},
|
|
505
|
+
describedBy: {},
|
|
506
|
+
required: { type: Boolean },
|
|
507
|
+
readonly: { type: Boolean },
|
|
508
|
+
disabled: { type: Boolean },
|
|
509
|
+
classes: {},
|
|
510
|
+
path: {},
|
|
511
|
+
rules: { type: [
|
|
512
|
+
String,
|
|
513
|
+
Object,
|
|
514
|
+
Function,
|
|
515
|
+
Array
|
|
516
|
+
] }
|
|
517
|
+
},
|
|
518
|
+
setup(__props) {
|
|
519
|
+
/**
|
|
520
|
+
* `CurrencyInput` bound to a vee-validate field — `FieldUnitInput` for money, with the same
|
|
521
|
+
* `number | null` value. See `FieldUnitInput` for what is forwarded and why the value is a number.
|
|
522
|
+
*/
|
|
523
|
+
const props = __props;
|
|
524
|
+
const { model, invalid, id, onBlur } = useFieldControl(props, { empty: null });
|
|
525
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
526
|
+
return (_ctx, _cache) => {
|
|
527
|
+
return openBlock(), createBlock(CurrencyInput_default, mergeProps(unref(control), {
|
|
528
|
+
id: unref(id),
|
|
529
|
+
modelValue: unref(model),
|
|
530
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
531
|
+
invalid: unref(invalid),
|
|
532
|
+
onBlur: unref(onBlur)
|
|
533
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
534
|
+
return {
|
|
535
|
+
name: slotName,
|
|
536
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
537
|
+
};
|
|
538
|
+
})]), 1040, [
|
|
539
|
+
"id",
|
|
540
|
+
"modelValue",
|
|
541
|
+
"invalid",
|
|
542
|
+
"onBlur"
|
|
543
|
+
]);
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region src/vee-validate/FieldInput.vue
|
|
549
|
+
var FieldInput_default = /* @__PURE__ */ defineComponent({
|
|
550
|
+
__name: "FieldInput",
|
|
551
|
+
props: {
|
|
552
|
+
type: {},
|
|
553
|
+
size: {},
|
|
554
|
+
id: {},
|
|
555
|
+
name: {},
|
|
556
|
+
placeholder: {},
|
|
557
|
+
autocomplete: {},
|
|
558
|
+
inputmode: {},
|
|
559
|
+
min: {},
|
|
560
|
+
max: {},
|
|
561
|
+
step: {},
|
|
562
|
+
leadingIcon: {},
|
|
563
|
+
clearable: { type: Boolean },
|
|
564
|
+
describedBy: {},
|
|
565
|
+
required: { type: Boolean },
|
|
566
|
+
readonly: { type: Boolean },
|
|
567
|
+
disabled: { type: Boolean },
|
|
568
|
+
mask: {},
|
|
569
|
+
classes: {},
|
|
570
|
+
path: {},
|
|
571
|
+
rules: { type: [
|
|
572
|
+
String,
|
|
573
|
+
Object,
|
|
574
|
+
Function,
|
|
575
|
+
Array
|
|
576
|
+
] },
|
|
577
|
+
label: {}
|
|
578
|
+
},
|
|
579
|
+
setup(__props) {
|
|
580
|
+
/**
|
|
581
|
+
* `Input` bound to a vee-validate field.
|
|
582
|
+
*
|
|
583
|
+
* Everything an `Input` takes is forwarded (`type`, `size`, `mask`, `leadingIcon`, `autocomplete`,
|
|
584
|
+
* `classes`, every slot and every attribute); `name` doubles as the field's path and the control's
|
|
585
|
+
* native `name`. The value, `invalid` and the blur that reveals the message are this component's.
|
|
586
|
+
*/
|
|
587
|
+
const props = __props;
|
|
588
|
+
const { model, invalid, id, onBlur } = useFieldControl(props, { empty: "" });
|
|
589
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
590
|
+
return (_ctx, _cache) => {
|
|
591
|
+
return openBlock(), createBlock(Input_default, mergeProps(unref(control), {
|
|
592
|
+
id: unref(id),
|
|
593
|
+
modelValue: unref(model),
|
|
594
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
595
|
+
invalid: unref(invalid),
|
|
596
|
+
onBlur: unref(onBlur)
|
|
597
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
598
|
+
return {
|
|
599
|
+
name: slotName,
|
|
600
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
601
|
+
};
|
|
602
|
+
})]), 1040, [
|
|
603
|
+
"id",
|
|
604
|
+
"modelValue",
|
|
605
|
+
"invalid",
|
|
606
|
+
"onBlur"
|
|
607
|
+
]);
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
//#endregion
|
|
612
|
+
//#region src/vee-validate/FieldMultiSelect.vue
|
|
613
|
+
var FieldMultiSelect_default = /* @__PURE__ */ defineComponent({
|
|
614
|
+
__name: "FieldMultiSelect",
|
|
615
|
+
props: {
|
|
616
|
+
placeholder: {},
|
|
617
|
+
showTags: { type: Boolean },
|
|
618
|
+
maxSummary: {},
|
|
619
|
+
classes: {},
|
|
620
|
+
options: {},
|
|
621
|
+
name: {},
|
|
622
|
+
id: {},
|
|
623
|
+
size: {},
|
|
624
|
+
searchable: { type: Boolean },
|
|
625
|
+
searchPlaceholder: {},
|
|
626
|
+
leadingIcon: {},
|
|
627
|
+
describedBy: {},
|
|
628
|
+
required: { type: Boolean },
|
|
629
|
+
disabled: { type: Boolean },
|
|
630
|
+
readonly: { type: Boolean },
|
|
631
|
+
placement: {},
|
|
632
|
+
teleport: { type: [Boolean, String] },
|
|
633
|
+
messages: {},
|
|
634
|
+
path: {},
|
|
635
|
+
rules: { type: [
|
|
636
|
+
String,
|
|
637
|
+
Object,
|
|
638
|
+
Function,
|
|
639
|
+
Array
|
|
640
|
+
] },
|
|
641
|
+
label: {}
|
|
642
|
+
},
|
|
643
|
+
setup(__props) {
|
|
644
|
+
/**
|
|
645
|
+
* `MultiSelect` bound to a **string array** field.
|
|
646
|
+
*
|
|
647
|
+
* The empty selection is a module-level array rather than a fresh `[]` per read: a new identity on
|
|
648
|
+
* every render would restart the control's own watchers for no reason.
|
|
649
|
+
*/
|
|
650
|
+
const EMPTY = [];
|
|
651
|
+
const props = __props;
|
|
652
|
+
const { model, invalid, id, onBlur } = useFieldControl(props, { empty: EMPTY });
|
|
653
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
654
|
+
return (_ctx, _cache) => {
|
|
655
|
+
return openBlock(), createBlock(MultiSelect_default, mergeProps(unref(control), {
|
|
656
|
+
id: unref(id),
|
|
657
|
+
modelValue: unref(model),
|
|
658
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
659
|
+
invalid: unref(invalid),
|
|
660
|
+
onBlur: unref(onBlur)
|
|
661
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
662
|
+
return {
|
|
663
|
+
name: slotName,
|
|
664
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
665
|
+
};
|
|
666
|
+
})]), 1040, [
|
|
667
|
+
"id",
|
|
668
|
+
"modelValue",
|
|
669
|
+
"invalid",
|
|
670
|
+
"onBlur"
|
|
671
|
+
]);
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
//#endregion
|
|
676
|
+
//#region src/vee-validate/FieldQuantityStepper.vue
|
|
677
|
+
var FieldQuantityStepper_default = /* @__PURE__ */ defineComponent({
|
|
678
|
+
__name: "FieldQuantityStepper",
|
|
679
|
+
props: {
|
|
680
|
+
min: {},
|
|
681
|
+
max: {},
|
|
682
|
+
size: {},
|
|
683
|
+
itemName: {},
|
|
684
|
+
name: {},
|
|
685
|
+
disabled: { type: Boolean },
|
|
686
|
+
id: {},
|
|
687
|
+
locale: {},
|
|
688
|
+
classes: {},
|
|
689
|
+
path: {},
|
|
690
|
+
rules: { type: [
|
|
691
|
+
String,
|
|
692
|
+
Object,
|
|
693
|
+
Function,
|
|
694
|
+
Array
|
|
695
|
+
] },
|
|
696
|
+
label: {}
|
|
697
|
+
},
|
|
698
|
+
setup(__props) {
|
|
699
|
+
/**
|
|
700
|
+
* `QuantityStepper` bound to a **number** field.
|
|
701
|
+
*
|
|
702
|
+
* The field starts at the stepper's own default — its `min`, spec "Quantity stepper" → Properties:
|
|
703
|
+
* "Defaults to `min` when unset, never 0 on a cart line" — rather than at `undefined`, so what the
|
|
704
|
+
* form submits is the quantity that is on screen. A `Form`'s `initialValues` still wins over it. It
|
|
705
|
+
* draws the error itself only outside a `FieldWrapper`.
|
|
706
|
+
*/
|
|
707
|
+
const props = __props;
|
|
708
|
+
/** `QuantityStepper`'s own `min` default, read once exactly as the component reads it. */
|
|
709
|
+
const initial = props.min ?? 1;
|
|
710
|
+
const { model, ownError, id, onBlur } = useFieldControl(props, {
|
|
711
|
+
empty: initial,
|
|
712
|
+
initialValue: initial
|
|
713
|
+
});
|
|
714
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
715
|
+
return (_ctx, _cache) => {
|
|
716
|
+
return openBlock(), createBlock(QuantityStepper_default, mergeProps(unref(control), {
|
|
717
|
+
id: unref(id),
|
|
718
|
+
modelValue: unref(model),
|
|
719
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
720
|
+
error: unref(ownError),
|
|
721
|
+
onBlur: unref(onBlur)
|
|
722
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
723
|
+
return {
|
|
724
|
+
name: slotName,
|
|
725
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
726
|
+
};
|
|
727
|
+
})]), 1040, [
|
|
728
|
+
"id",
|
|
729
|
+
"modelValue",
|
|
730
|
+
"error",
|
|
731
|
+
"onBlur"
|
|
732
|
+
]);
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
//#endregion
|
|
737
|
+
//#region src/vee-validate/FieldRadioGroup.vue
|
|
738
|
+
var FieldRadioGroup_default = /* @__PURE__ */ defineComponent({
|
|
739
|
+
__name: "FieldRadioGroup",
|
|
740
|
+
props: {
|
|
741
|
+
name: {},
|
|
742
|
+
legend: {},
|
|
743
|
+
options: {},
|
|
744
|
+
layout: {},
|
|
745
|
+
size: {},
|
|
746
|
+
required: { type: Boolean },
|
|
747
|
+
classes: {},
|
|
748
|
+
path: {},
|
|
749
|
+
rules: { type: [
|
|
750
|
+
String,
|
|
751
|
+
Object,
|
|
752
|
+
Function,
|
|
753
|
+
Array
|
|
754
|
+
] },
|
|
755
|
+
label: {}
|
|
756
|
+
},
|
|
757
|
+
setup(__props) {
|
|
758
|
+
/**
|
|
759
|
+
* `RadioGroup` bound to a vee-validate field. Like every fieldset control here it is touched by
|
|
760
|
+
* `focusout` (native `blur` does not bubble out of the radios), and it renders its own error row
|
|
761
|
+
* only outside a `FieldWrapper`.
|
|
762
|
+
*/
|
|
763
|
+
const props = __props;
|
|
764
|
+
const { model, ownError, onBlur } = useFieldControl(props, {
|
|
765
|
+
empty: "",
|
|
766
|
+
hasIdProp: false
|
|
767
|
+
});
|
|
768
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
769
|
+
return (_ctx, _cache) => {
|
|
770
|
+
return openBlock(), createBlock(RadioGroup_default, mergeProps(unref(control), {
|
|
771
|
+
modelValue: unref(model),
|
|
772
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
773
|
+
error: unref(ownError),
|
|
774
|
+
onFocusout: unref(onBlur)
|
|
775
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
776
|
+
return {
|
|
777
|
+
name: slotName,
|
|
778
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
779
|
+
};
|
|
780
|
+
})]), 1040, [
|
|
781
|
+
"modelValue",
|
|
782
|
+
"error",
|
|
783
|
+
"onFocusout"
|
|
784
|
+
]);
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
//#endregion
|
|
789
|
+
//#region src/vee-validate/FieldSearchBar.vue
|
|
790
|
+
var FieldSearchBar_default = /* @__PURE__ */ defineComponent({
|
|
791
|
+
__name: "FieldSearchBar",
|
|
792
|
+
props: {
|
|
793
|
+
size: {},
|
|
794
|
+
pill: { type: Boolean },
|
|
795
|
+
action: {},
|
|
796
|
+
label: {},
|
|
797
|
+
placeholder: {},
|
|
798
|
+
results: {},
|
|
799
|
+
loading: { type: Boolean },
|
|
800
|
+
recent: {},
|
|
801
|
+
popular: {},
|
|
802
|
+
showRecent: { type: Boolean },
|
|
803
|
+
resultTypes: {},
|
|
804
|
+
shortcut: { type: Boolean },
|
|
805
|
+
autofocus: { type: Boolean },
|
|
806
|
+
teleport: { type: [Boolean, String] },
|
|
807
|
+
messages: {},
|
|
808
|
+
classes: {},
|
|
809
|
+
name: {},
|
|
810
|
+
path: {},
|
|
811
|
+
rules: { type: [
|
|
812
|
+
String,
|
|
813
|
+
Object,
|
|
814
|
+
Function,
|
|
815
|
+
Array
|
|
816
|
+
] }
|
|
817
|
+
},
|
|
818
|
+
setup(__props) {
|
|
819
|
+
/**
|
|
820
|
+
* `SearchBar` bound to a vee-validate field, for a Search page whose query is validated before it
|
|
821
|
+
* is sent.
|
|
822
|
+
*
|
|
823
|
+
* `label` is the one prop that means the same thing on both sides — the field's accessible name and
|
|
824
|
+
* the name a rule message uses — so it is handed to `useField` *and* forwarded to the control,
|
|
825
|
+
* rather than being kept back like `rules`.
|
|
826
|
+
*/
|
|
827
|
+
const props = __props;
|
|
828
|
+
/**
|
|
829
|
+
* `hasIdProp: false`: a `SearchBar` sets the id on its own field after its attribute fall-through,
|
|
830
|
+
* and its native `name` is always `q` (its form posts to the Search page) — so neither is this
|
|
831
|
+
* component's to hand over, and a `Form`'s error summary lists this field by name rather than
|
|
832
|
+
* linking to an id that would not exist.
|
|
833
|
+
*/
|
|
834
|
+
const { model, onBlur } = useFieldControl(props, {
|
|
835
|
+
empty: "",
|
|
836
|
+
hasIdProp: false
|
|
837
|
+
});
|
|
838
|
+
const control = useControlProps(props, [
|
|
839
|
+
"path",
|
|
840
|
+
"rules",
|
|
841
|
+
"id",
|
|
842
|
+
"name"
|
|
843
|
+
]);
|
|
844
|
+
return (_ctx, _cache) => {
|
|
845
|
+
return openBlock(), createBlock(SearchBar_default, mergeProps(unref(control), {
|
|
846
|
+
modelValue: unref(model),
|
|
847
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
848
|
+
onBlur: unref(onBlur)
|
|
849
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
850
|
+
return {
|
|
851
|
+
name: slotName,
|
|
852
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
853
|
+
};
|
|
854
|
+
})]), 1040, ["modelValue", "onBlur"]);
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
//#endregion
|
|
859
|
+
//#region src/vee-validate/FieldSelect.vue
|
|
860
|
+
var FieldSelect_default = /* @__PURE__ */ defineComponent({
|
|
861
|
+
__name: "FieldSelect",
|
|
862
|
+
props: {
|
|
863
|
+
options: {},
|
|
864
|
+
name: {},
|
|
865
|
+
id: {},
|
|
866
|
+
size: {},
|
|
867
|
+
searchable: { type: Boolean },
|
|
868
|
+
searchPlaceholder: {},
|
|
869
|
+
clearable: { type: Boolean },
|
|
870
|
+
placeholder: {},
|
|
871
|
+
leadingIcon: {},
|
|
872
|
+
describedBy: {},
|
|
873
|
+
required: { type: Boolean },
|
|
874
|
+
disabled: { type: Boolean },
|
|
875
|
+
readonly: { type: Boolean },
|
|
876
|
+
placement: {},
|
|
877
|
+
teleport: { type: [Boolean, String] },
|
|
878
|
+
messages: {},
|
|
879
|
+
classes: {},
|
|
880
|
+
path: {},
|
|
881
|
+
rules: { type: [
|
|
882
|
+
String,
|
|
883
|
+
Object,
|
|
884
|
+
Function,
|
|
885
|
+
Array
|
|
886
|
+
] },
|
|
887
|
+
label: {}
|
|
888
|
+
},
|
|
889
|
+
setup(__props) {
|
|
890
|
+
/**
|
|
891
|
+
* `Select` bound to a vee-validate field. The hidden native `<select>` still carries `name`, so the
|
|
892
|
+
* form posts the same value with or without scripting.
|
|
893
|
+
*/
|
|
894
|
+
const props = __props;
|
|
895
|
+
const { model, invalid, id, onBlur } = useFieldControl(props, { empty: "" });
|
|
896
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
897
|
+
return (_ctx, _cache) => {
|
|
898
|
+
return openBlock(), createBlock(Select_default, mergeProps(unref(control), {
|
|
899
|
+
id: unref(id),
|
|
900
|
+
modelValue: unref(model),
|
|
901
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
902
|
+
invalid: unref(invalid),
|
|
903
|
+
onBlur: unref(onBlur)
|
|
904
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
905
|
+
return {
|
|
906
|
+
name: slotName,
|
|
907
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
908
|
+
};
|
|
909
|
+
})]), 1040, [
|
|
910
|
+
"id",
|
|
911
|
+
"modelValue",
|
|
912
|
+
"invalid",
|
|
913
|
+
"onBlur"
|
|
914
|
+
]);
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
//#endregion
|
|
919
|
+
//#region src/vee-validate/FieldSwitch.vue
|
|
920
|
+
var FieldSwitch_default = /* @__PURE__ */ defineComponent({
|
|
921
|
+
__name: "FieldSwitch",
|
|
922
|
+
props: {
|
|
923
|
+
size: {},
|
|
924
|
+
description: {},
|
|
925
|
+
disabled: { type: Boolean },
|
|
926
|
+
id: {},
|
|
927
|
+
name: {},
|
|
928
|
+
classes: {},
|
|
929
|
+
path: {},
|
|
930
|
+
rules: { type: [
|
|
931
|
+
String,
|
|
932
|
+
Object,
|
|
933
|
+
Function,
|
|
934
|
+
Array
|
|
935
|
+
] },
|
|
936
|
+
label: {}
|
|
937
|
+
},
|
|
938
|
+
setup(__props) {
|
|
939
|
+
/**
|
|
940
|
+
* `Switch` bound to a boolean field.
|
|
941
|
+
*
|
|
942
|
+
* A `Switch` has neither an `invalid` nor an `error` prop — the spec gives it no error state — so
|
|
943
|
+
* the message is the `FieldWrapper`'s to show, through the `Form`'s `errors` slot prop.
|
|
944
|
+
*/
|
|
945
|
+
const props = __props;
|
|
946
|
+
const { model, id, onBlur } = useFieldControl(props, { empty: false });
|
|
947
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
948
|
+
return (_ctx, _cache) => {
|
|
949
|
+
return openBlock(), createBlock(Switch_default, mergeProps(unref(control), {
|
|
950
|
+
id: unref(id),
|
|
951
|
+
modelValue: unref(model),
|
|
952
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
953
|
+
onBlur: unref(onBlur)
|
|
954
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
955
|
+
return {
|
|
956
|
+
name: slotName,
|
|
957
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
958
|
+
};
|
|
959
|
+
})]), 1040, [
|
|
960
|
+
"id",
|
|
961
|
+
"modelValue",
|
|
962
|
+
"onBlur"
|
|
963
|
+
]);
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/vee-validate/FieldTextarea.vue
|
|
969
|
+
var FieldTextarea_default = /* @__PURE__ */ defineComponent({
|
|
970
|
+
__name: "FieldTextarea",
|
|
971
|
+
props: {
|
|
972
|
+
placeholder: {},
|
|
973
|
+
maxLength: {},
|
|
974
|
+
counter: { type: Boolean },
|
|
975
|
+
hardLimit: { type: Boolean },
|
|
976
|
+
minHeight: {},
|
|
977
|
+
required: { type: Boolean },
|
|
978
|
+
readonly: { type: Boolean },
|
|
979
|
+
disabled: { type: Boolean },
|
|
980
|
+
id: {},
|
|
981
|
+
name: {},
|
|
982
|
+
describedBy: {},
|
|
983
|
+
classes: {},
|
|
984
|
+
path: {},
|
|
985
|
+
rules: { type: [
|
|
986
|
+
String,
|
|
987
|
+
Object,
|
|
988
|
+
Function,
|
|
989
|
+
Array
|
|
990
|
+
] },
|
|
991
|
+
label: {}
|
|
992
|
+
},
|
|
993
|
+
setup(__props) {
|
|
994
|
+
/**
|
|
995
|
+
* `Textarea` bound to a vee-validate field. The counter, `maxLength`, `hardLimit` and `minHeight`
|
|
996
|
+
* are forwarded untouched; the value, `invalid` and the blur are this component's.
|
|
997
|
+
*/
|
|
998
|
+
const props = __props;
|
|
999
|
+
const { model, invalid, id, onBlur } = useFieldControl(props, { empty: "" });
|
|
1000
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
1001
|
+
return (_ctx, _cache) => {
|
|
1002
|
+
return openBlock(), createBlock(Textarea_default, mergeProps(unref(control), {
|
|
1003
|
+
id: unref(id),
|
|
1004
|
+
modelValue: unref(model),
|
|
1005
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
1006
|
+
invalid: unref(invalid),
|
|
1007
|
+
onBlur: unref(onBlur)
|
|
1008
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
1009
|
+
return {
|
|
1010
|
+
name: slotName,
|
|
1011
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
1012
|
+
};
|
|
1013
|
+
})]), 1040, [
|
|
1014
|
+
"id",
|
|
1015
|
+
"modelValue",
|
|
1016
|
+
"invalid",
|
|
1017
|
+
"onBlur"
|
|
1018
|
+
]);
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
});
|
|
1022
|
+
//#endregion
|
|
1023
|
+
//#region src/vee-validate/FieldUnitInput.vue
|
|
1024
|
+
var FieldUnitInput_default = /* @__PURE__ */ defineComponent({
|
|
1025
|
+
__name: "FieldUnitInput",
|
|
1026
|
+
props: {
|
|
1027
|
+
unit: {},
|
|
1028
|
+
locale: {},
|
|
1029
|
+
label: {},
|
|
1030
|
+
maxFraction: {},
|
|
1031
|
+
max: {},
|
|
1032
|
+
min: {},
|
|
1033
|
+
step: {},
|
|
1034
|
+
enableDragAdjust: { type: Boolean },
|
|
1035
|
+
clearable: { type: Boolean },
|
|
1036
|
+
isCurrency: { type: Boolean },
|
|
1037
|
+
currency: {},
|
|
1038
|
+
narrowSymbol: { type: Boolean },
|
|
1039
|
+
size: {},
|
|
1040
|
+
id: {},
|
|
1041
|
+
name: {},
|
|
1042
|
+
leadingIcon: {},
|
|
1043
|
+
describedBy: {},
|
|
1044
|
+
required: { type: Boolean },
|
|
1045
|
+
readonly: { type: Boolean },
|
|
1046
|
+
disabled: { type: Boolean },
|
|
1047
|
+
classes: {},
|
|
1048
|
+
path: {},
|
|
1049
|
+
rules: { type: [
|
|
1050
|
+
String,
|
|
1051
|
+
Object,
|
|
1052
|
+
Function,
|
|
1053
|
+
Array
|
|
1054
|
+
] }
|
|
1055
|
+
},
|
|
1056
|
+
setup(__props) {
|
|
1057
|
+
/**
|
|
1058
|
+
* `UnitInput` bound to a vee-validate field.
|
|
1059
|
+
*
|
|
1060
|
+
* Everything a `UnitInput` takes is forwarded (`unit`, `locale`, `min`, `max`, `step`,
|
|
1061
|
+
* `maxFraction`, `clearable`, `enableDragAdjust`, `size`, `classes`, every slot and every
|
|
1062
|
+
* attribute); `name` doubles as the field's path and the name the hidden input posts under. The
|
|
1063
|
+
* value, `invalid` and the blur that reveals the message are this component's.
|
|
1064
|
+
*
|
|
1065
|
+
* The bound value is `number | null`, not a string — so a rule reads a number (`min_value:1`
|
|
1066
|
+
* compares numerically) and a form submits one.
|
|
1067
|
+
*/
|
|
1068
|
+
const props = __props;
|
|
1069
|
+
const { model, invalid, id, onBlur } = useFieldControl(props, { empty: null });
|
|
1070
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
1071
|
+
return (_ctx, _cache) => {
|
|
1072
|
+
return openBlock(), createBlock(UnitInput_default, mergeProps(unref(control), {
|
|
1073
|
+
id: unref(id),
|
|
1074
|
+
modelValue: unref(model),
|
|
1075
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
1076
|
+
invalid: unref(invalid),
|
|
1077
|
+
onBlur: unref(onBlur)
|
|
1078
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
1079
|
+
return {
|
|
1080
|
+
name: slotName,
|
|
1081
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
1082
|
+
};
|
|
1083
|
+
})]), 1040, [
|
|
1084
|
+
"id",
|
|
1085
|
+
"modelValue",
|
|
1086
|
+
"invalid",
|
|
1087
|
+
"onBlur"
|
|
1088
|
+
]);
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
//#endregion
|
|
1093
|
+
//#region src/vee-validate/FieldVariantPicker.vue
|
|
1094
|
+
var FieldVariantPicker_default = /* @__PURE__ */ defineComponent({
|
|
1095
|
+
__name: "FieldVariantPicker",
|
|
1096
|
+
props: {
|
|
1097
|
+
name: {},
|
|
1098
|
+
legend: {},
|
|
1099
|
+
type: {},
|
|
1100
|
+
options: {},
|
|
1101
|
+
classes: {},
|
|
1102
|
+
path: {},
|
|
1103
|
+
rules: { type: [
|
|
1104
|
+
String,
|
|
1105
|
+
Object,
|
|
1106
|
+
Function,
|
|
1107
|
+
Array
|
|
1108
|
+
] },
|
|
1109
|
+
label: {}
|
|
1110
|
+
},
|
|
1111
|
+
setup(__props) {
|
|
1112
|
+
/**
|
|
1113
|
+
* `VariantPicker` bound to a vee-validate field.
|
|
1114
|
+
*
|
|
1115
|
+
* The one control here whose `name` is **visible**: it is the option name ("Size", "Colour"), drawn
|
|
1116
|
+
* in the legend as well as used as the radios' shared native name. So `name` stays the legend and
|
|
1117
|
+
* **`path`** says where the value lives — without it the field would be called "Size" in
|
|
1118
|
+
* `initialValues`, `validationSchema`, `apiErrors` and the `errors` slot prop, and either the
|
|
1119
|
+
* legend or the key would have to be wrong. `path` defaults to `name`, so a picker whose option
|
|
1120
|
+
* name already reads as a key needs nothing extra.
|
|
1121
|
+
*
|
|
1122
|
+
* The picker's documented default is the first available option, and a controlled picker cannot
|
|
1123
|
+
* choose it for itself — so the field starts there instead (`initialValue`), which a `Form`'s
|
|
1124
|
+
* `initialValues` still overrides.
|
|
1125
|
+
*/
|
|
1126
|
+
const props = __props;
|
|
1127
|
+
/**
|
|
1128
|
+
* Read once, at setup, exactly as `VariantPicker`'s own uncontrolled fallback is: the first
|
|
1129
|
+
* available option, or the very first one when the product is sold out end to end, so a fully
|
|
1130
|
+
* sold-out picker still starts on a real choice rather than on nothing.
|
|
1131
|
+
*/
|
|
1132
|
+
const initial = props.options.find((option) => option.available)?.value ?? props.options[0]?.value ?? "";
|
|
1133
|
+
const { model, onBlur } = useFieldControl(props, {
|
|
1134
|
+
empty: initial,
|
|
1135
|
+
initialValue: initial,
|
|
1136
|
+
hasIdProp: false
|
|
1137
|
+
});
|
|
1138
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
1139
|
+
return (_ctx, _cache) => {
|
|
1140
|
+
return openBlock(), createBlock(VariantPicker_default, mergeProps(unref(control), {
|
|
1141
|
+
modelValue: unref(model),
|
|
1142
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
1143
|
+
onFocusout: unref(onBlur)
|
|
1144
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
1145
|
+
return {
|
|
1146
|
+
name: slotName,
|
|
1147
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
1148
|
+
};
|
|
1149
|
+
})]), 1040, ["modelValue", "onFocusout"]);
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
//#endregion
|
|
1154
|
+
export { API_ERRORS_KEY, FIELD_ONLY, FieldCheckbox_default as FieldCheckbox, FieldCheckboxGroup_default as FieldCheckboxGroup, FieldCurrencyInput_default as FieldCurrencyInput, FieldInput_default as FieldInput, FieldMultiSelect_default as FieldMultiSelect, FieldQuantityStepper_default as FieldQuantityStepper, FieldRadioGroup_default as FieldRadioGroup, FieldSearchBar_default as FieldSearchBar, FieldSelect_default as FieldSelect, FieldSwitch_default as FieldSwitch, FieldTextarea_default as FieldTextarea, FieldUnitInput_default as FieldUnitInput, FieldVariantPicker_default as FieldVariantPicker, Form_default as Form, useFieldControl };
|