@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,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `beforeinput` filter that makes a numeric text field actually numeric.
|
|
3
|
+
*
|
|
4
|
+
* `QuantityStepper` draws a `type="text"` field rather than `type="number"` — see its own doc
|
|
5
|
+
* comment for why (a native number input's DOM value cannot hold a locale-grouped string, which is
|
|
6
|
+
* the whole point of parsing with `parseLocaleNumber`). The cost of that decision, reported by the
|
|
7
|
+
* operator as "I can type anything into it", is that the browser's own numeric input filtering
|
|
8
|
+
* goes with it: the field accepted letters happily and only corrected itself on blur.
|
|
9
|
+
*
|
|
10
|
+
* `UnitInput` and `CurrencyInput` deliberately do **not** use this filter. Their text is full of
|
|
11
|
+
* characters that are not digits (a symbol, group separators, a literal), so a keystroke lands
|
|
12
|
+
* there and the reformat strips it — the private library's own behaviour, which this package
|
|
13
|
+
* ported.
|
|
14
|
+
*
|
|
15
|
+
* `beforeinput` is where a control gets that back. It is cancelable, it fires for every way text
|
|
16
|
+
* can arrive (typing, pasting, dropping, an IME composition), and it names *what kind* of edit is
|
|
17
|
+
* about to happen in `inputType` — so deletions, undo and redo pass untouched while insertions are
|
|
18
|
+
* checked. It is not `keydown`: a `keydown` filter has to guess at the resulting value, misses
|
|
19
|
+
* paste entirely, and eats modifier combinations.
|
|
20
|
+
*
|
|
21
|
+
* **Pasting is sanitised, never refused.** Pasting `"12ab3"` into a quantity field inserts `123`
|
|
22
|
+
* rather than nothing: a customer who copied a quantity out of a table with a stray label attached
|
|
23
|
+
* meant the digits, and refusing the whole paste is a dead end with no message. The same rule
|
|
24
|
+
* applies to typing, where it degenerates into "the one character is either allowed or it is not".
|
|
25
|
+
*/
|
|
26
|
+
export interface NumericInputFilterOptions {
|
|
27
|
+
/** Allow a leading `-`. `QuantityStepper` passes `min < 0`; a consumer's own field decides. */
|
|
28
|
+
allowNegative?: boolean;
|
|
29
|
+
/** Allow one decimal separator. `false` for a whole-number field like a quantity. */
|
|
30
|
+
allowDecimal?: boolean;
|
|
31
|
+
/** Which locale's separators to accept. Defaults to `en-US`. */
|
|
32
|
+
locale?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Filters one `beforeinput` event on a numeric text field.
|
|
36
|
+
*
|
|
37
|
+
* Returns `true` when the event was cancelled — either because nothing of what arrived was
|
|
38
|
+
* numeric, or because only part of it was and that part has been inserted directly — and `false`
|
|
39
|
+
* when the edit was left to the browser. Callers do not need the return value; it is there for
|
|
40
|
+
* tests and for a caller that wants to know an edit was rewritten.
|
|
41
|
+
*/
|
|
42
|
+
export declare function filterNumericBeforeInput(event: InputEvent, options?: NumericInputFilterOptions): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Rating`'s own rounding and star-fill logic (spec "Rating" → Properties, `value` row: "Stars
|
|
3
|
+
* round to the nearest 0.5; the value shows one decimal (4.0, 4.5)."), pulled out of the component
|
|
4
|
+
* so the rounding boundary — the one guard the API contract calls out for mutation testing — has a
|
|
5
|
+
* unit test with nothing else in the render path to obscure a broken mutant.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Rounds a 0–5 rating to the nearest half star. Out-of-range input is clamped first (`5.3` or
|
|
9
|
+
* `-1`), so a caller's bad data renders a legal 0–5 rating rather than a sixth star or a negative
|
|
10
|
+
* one — `Rating` has no prop validation of its own beyond TypeScript's `number`.
|
|
11
|
+
*
|
|
12
|
+
* The boundary case is exactness at `x.25`/`x.75`: `Math.round` breaks ties up for positive
|
|
13
|
+
* numbers, so `4.25 * 2 = 8.5` rounds to `9` (→ `4.5`) while `4.24 * 2 = 8.48` rounds to `8`
|
|
14
|
+
* (→ `4.0`) — the API contract's own two guard cases.
|
|
15
|
+
*/
|
|
16
|
+
export declare function roundRatingToHalf(value: number): number;
|
|
17
|
+
/** One star's fill (spec "Rating" → Anatomy, part 1): "each filled, half-filled or empty
|
|
18
|
+
* (outline)." */
|
|
19
|
+
export type RatingStarState = 'full' | 'half' | 'empty';
|
|
20
|
+
/**
|
|
21
|
+
* The five stars' fill states for a rating, most-significant star first. Star `i` (1-indexed) is
|
|
22
|
+
* `full` once the rounded rating reaches it, `half` when the rounded rating lands exactly on its
|
|
23
|
+
* own half step, and `empty` otherwise — so `4.5` yields four `full` stars and one `half`, never a
|
|
24
|
+
* `half` anywhere but the single star the rounded value actually lands on.
|
|
25
|
+
*/
|
|
26
|
+
export declare function ratingStarStates(value: number): RatingStarState[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ImageMedia, ImageRatio } from '../components/image/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The frame's `aspect-ratio` CSS value (spec "Image" → Properties, `ratio` row: "`auto` uses the
|
|
4
|
+
* image's own ratio, or 4:3 when empty").
|
|
5
|
+
*
|
|
6
|
+
* - A fixed preset always wins outright — its own literal `w / h` ratio, whatever `media` is.
|
|
7
|
+
* - `auto` with a `media.width`/`height` pair uses the image's own intrinsic ratio, computed here
|
|
8
|
+
* rather than left to the browser's native `aspect-ratio: auto` resolution: that keyword only
|
|
9
|
+
* sizes a *replaced* element (the `<img>` itself) from its intrinsic size, but the frame that
|
|
10
|
+
* needs the ratio is the wrapping `<div>` the `<img>` is stretched to fill (`object-fit: cover`
|
|
11
|
+
* needs a sized box to crop into), so the ratio has to be computed and handed to the frame
|
|
12
|
+
* directly — this is also what reserves the frame's space before the image has loaded (spec
|
|
13
|
+
* "Behaviour & motion": "Reserve space with `width`/`height` attributes or the ratio").
|
|
14
|
+
* - `auto` with a `media` that carries no width/height falls back to the CSS keyword `auto`: there
|
|
15
|
+
* is nothing to precompute, so the frame's height tracks its content the way a plain image would.
|
|
16
|
+
* - `auto` with no `media` at all falls back to 4:3 (the spec's own fallback for an empty frame).
|
|
17
|
+
*/
|
|
18
|
+
export declare function frameAspectRatio(ratio: ImageRatio, media: Pick<ImageMedia, 'width' | 'height'> | null | undefined): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The "small chip" recipe (spec "Multi-select" → Sizes, Tags row): "min 1.75rem tall, 0.8125rem
|
|
3
|
+
* text, 0.625rem start padding, `surface-strong` fill, `radius-full`. Remove button 1.5rem circle
|
|
4
|
+
* with a 0.875rem icon (hover `text` at 11%)."
|
|
5
|
+
*
|
|
6
|
+
* `MultiSelect.vue`'s own tag row and `Chip`'s `sm` size (`src/components/chip/Chip.vue`) draw the
|
|
7
|
+
* exact same pill, so the class strings live here once rather than twice — the API contract for
|
|
8
|
+
* `Chip` asks for it explicitly ("reuse the tag recipe: extract it into a shared constant if that
|
|
9
|
+
* avoids duplicating class strings"). It sits in `utils/`, not under either component's folder, so
|
|
10
|
+
* neither one appears to depend on the other: `MultiSelect` shipped first and `Chip` reuses its
|
|
11
|
+
* visual language, but the recipe itself belongs to neither.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TAG_FILL = "bg-surface-strong text-text";
|
|
14
|
+
/** The pill shape and type: rounded-full, min 1.75rem tall, the caption size, `space-1` gap. */
|
|
15
|
+
export declare const TAG_SHAPE = "inline-flex min-h-7 items-center gap-1 rounded-full text-caption";
|
|
16
|
+
/**
|
|
17
|
+
* Start padding is 0.625rem either way; the end padding is the remove button's own room, so a tag
|
|
18
|
+
* with no remove button is padded evenly instead of ending short.
|
|
19
|
+
*/
|
|
20
|
+
export declare function tagPadding(hasRemoveButton: boolean): string;
|
|
21
|
+
/** The remove button: a 1.5rem circle, `muted` at rest, `text` on hover at 11% opacity. */
|
|
22
|
+
export declare const TAG_REMOVE_BUTTON: string;
|
|
23
|
+
/** The remove button's icon: Tabler's `x` at 0.875rem, 1.75 stroke. */
|
|
24
|
+
export declare const TAG_REMOVE_ICON_SIZE = "size-3.5";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fade a refreshed value plays when its text changes — `Price`'s amount and compare-at,
|
|
3
|
+
* `StockBadge`'s status line. Internal to the package, like `tagRecipe.ts`; `ValueText.vue` is its
|
|
4
|
+
* only caller.
|
|
5
|
+
*
|
|
6
|
+
* **Why it exists.** `revalidating` keeps a prerendered value on screen while a fresher one is
|
|
7
|
+
* fetched, dimmed, with a spinner beside it. When the fresher value finally arrives the old text
|
|
8
|
+
* is simply replaced — one frame, no signal — so a visitor who looked away sees a number that was
|
|
9
|
+
* never seen changing, and one who was looking sees it blink. The dim says "this may be a moment
|
|
10
|
+
* old"; this says "and here is the new one".
|
|
11
|
+
*
|
|
12
|
+
* **Enter only, on the element that already holds the new text.** The value is swapped in the same
|
|
13
|
+
* render as every other signal about it (`aria-busy`, the dim, the spinner) and *then* fades from
|
|
14
|
+
* transparent to its settled opacity. Nothing fades out, because there is nothing stale left to
|
|
15
|
+
* show: a leaving half would keep the previous value on screen for the length of the fade, after
|
|
16
|
+
* the component had already stopped saying it was busy — which is precisely what a visitor must
|
|
17
|
+
* not be shown on a price.
|
|
18
|
+
*
|
|
19
|
+
* That is also why this is a one-element animation rather than a Vue `<Transition>` keyed on the
|
|
20
|
+
* text. A `<Transition mode="out-in">` renders a placeholder as soon as the key changes and brings
|
|
21
|
+
* the new child in on a *later* render pass, so the DOM's text lags the props by one pass for
|
|
22
|
+
* every value change in the package — refresh or not. (Measured, not assumed: with that shape the
|
|
23
|
+
* starter's cart line total still read the old amount a tick after the stepper click, and emptying
|
|
24
|
+
* the leave classes did not change it — the extra pass is the mode.) The default mode does not
|
|
25
|
+
* help either: it keeps the leaving element in the DOM for two animation frames, which is a second
|
|
26
|
+
* copy of the value in the accessibility tree. One element with its text interpolated normally has
|
|
27
|
+
* neither problem: the text is always the current one, synchronously, and there is exactly one
|
|
28
|
+
* copy of it at every instant.
|
|
29
|
+
*
|
|
30
|
+
* **Reduced motion is answered twice.** `prefersReducedMotion()` asks the visitor's setting, and
|
|
31
|
+
* the duration is read from `--eldra-duration-base` on the element itself, which `tokens.css`
|
|
32
|
+
* zeroes under `prefers-reduced-motion: reduce` — either one skips the animation outright, and the
|
|
33
|
+
* second keeps working for a consumer who ships their own token file. The same read is what makes
|
|
34
|
+
* the timing and easing a consumer's to change: both come from the element's computed style, never
|
|
35
|
+
* from a literal (the house pattern `AccordionItem`'s panel animation already follows).
|
|
36
|
+
*
|
|
37
|
+
* **Layout.** Nothing here moves or sizes anything: one element, one animated `opacity`. The value
|
|
38
|
+
* parts are already `tabular-nums` (`text-price-current`/`text-price-secondary`), so a number
|
|
39
|
+
* whose digit count does not change keeps exactly the width it had; a change in digit count does
|
|
40
|
+
* change the width, at the moment the value changes, which is the value changing and not this.
|
|
41
|
+
*/
|
|
42
|
+
export declare function fadeInChangedValue(el: HTMLElement | null | undefined): Animation | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldCheckboxProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldCheckboxProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldCheckboxProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldCheckboxGroupProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldCheckboxGroupProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldCheckboxGroupProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldCurrencyInputProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldCurrencyInputProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldCurrencyInputProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldInputProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldInputProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldInputProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldMultiSelectProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldMultiSelectProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldMultiSelectProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldQuantityStepperProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldQuantityStepperProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldQuantityStepperProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldRadioGroupProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldRadioGroupProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldRadioGroupProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldSearchBarProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldSearchBarProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldSearchBarProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldSelectProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldSelectProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldSelectProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldSwitchProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldSwitchProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldSwitchProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldTextareaProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldTextareaProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldTextareaProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldUnitInputProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldUnitInputProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldUnitInputProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldVariantPickerProps } from './types.js';
|
|
2
|
+
declare var __VLS_12: string, __VLS_13: any;
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
[K in NonNullable<typeof __VLS_12>]?: (props: typeof __VLS_13) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldVariantPickerProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<FieldVariantPickerProps> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
10
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
11
|
+
new (): {
|
|
12
|
+
$slots: S;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SubmissionContext } from 'vee-validate';
|
|
2
|
+
import { FormProps, FormSlotProps, FormValues } from './types.js';
|
|
3
|
+
type __VLS_Slots = {
|
|
4
|
+
/** The fields. */
|
|
5
|
+
default: (props: FormSlotProps) => unknown;
|
|
6
|
+
/** The actions row, exactly as `FormLayout`'s. */
|
|
7
|
+
actions?: (props: FormSlotProps) => unknown;
|
|
8
|
+
/** Replaces the default list inside the summary alert. The alert itself is still drawn for you. */
|
|
9
|
+
errorSummary?: (props: FormSlotProps) => unknown;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_base: import('vue').DefineComponent<FormProps, {
|
|
12
|
+
form: import('vee-validate').FormContext<FormValues, FormValues>;
|
|
13
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
14
|
+
submit: (values: FormValues, ctx: SubmissionContext<FormValues>) => any;
|
|
15
|
+
invalid: (errors: Record<string, string | undefined>) => any;
|
|
16
|
+
}, string, import('vue').PublicProps, Readonly<FormProps> & Readonly<{
|
|
17
|
+
onSubmit?: ((values: FormValues, ctx: SubmissionContext<FormValues>) => any) | undefined;
|
|
18
|
+
onInvalid?: ((errors: Record<string, string | undefined>) => any) | undefined;
|
|
19
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
20
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
21
|
+
declare const _default: typeof __VLS_export;
|
|
22
|
+
export default _default;
|
|
23
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
24
|
+
new (): {
|
|
25
|
+
$slots: S;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { InjectionKey, Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* The server's field errors, keyed by the path a `Field*` validates under (its `path`, or its
|
|
4
|
+
* `name` when there is none).
|
|
5
|
+
*
|
|
6
|
+
* `Form` provides it from its `apiErrors` prop and applies it to the form with vee-validate's own
|
|
7
|
+
* `setErrors`, so a 422 from the shop's API lands on the field it belongs to rather than in a
|
|
8
|
+
* banner above the form. Every `Field*` injects it and removes **its own** entry the moment its
|
|
9
|
+
* value changes — a server error is a statement about the value that was sent, so it stops being
|
|
10
|
+
* true as soon as the customer edits it, and nothing else would reliably clear it (a rule that
|
|
11
|
+
* already passes has no new message to overwrite it with).
|
|
12
|
+
*
|
|
13
|
+
* How long an entry survives a change to a *different* field is vee-validate's, not this key's.
|
|
14
|
+
* Before the first submit — and with per-field `rules` at any time — only the changed field is
|
|
15
|
+
* revalidated, so another field's server error stays put. After a submit, with a form-level
|
|
16
|
+
* `validationSchema`, every already-validated field is revalidated on each change
|
|
17
|
+
* (`validated-only`), and a field that now passes has its manually set error replaced by that
|
|
18
|
+
* pass — so the server's message for it goes too. Send the current map with each response rather
|
|
19
|
+
* than treating one as sticky; `src/vee-validate/__tests__/vee-validate.spec.ts` pins both halves.
|
|
20
|
+
*
|
|
21
|
+
* It is a plain `Ref`, so a consumer can provide one itself and drive server errors from outside a
|
|
22
|
+
* `Form`:
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { API_ERRORS_KEY } from '@eldrajs/ui/vee-validate';
|
|
26
|
+
* provide(API_ERRORS_KEY, ref({ email: 'That address is already subscribed.' }));
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const API_ERRORS_KEY: InjectionKey<Ref<Record<string, string>>>;
|
|
30
|
+
/**
|
|
31
|
+
* How a `Field*` tells the `Form` above it which element its error summary should link to.
|
|
32
|
+
*
|
|
33
|
+
* The summary lists one link per error and the anchor is the field's own control — the `id` a
|
|
34
|
+
* `FieldWrapper` generated and tied its `<label for>` to, or the one the `Field*` handed the
|
|
35
|
+
* control when it stands on its own. Only the `Field*` can resolve that, so it registers it here
|
|
36
|
+
* rather than the `Form` guessing from the DOM.
|
|
37
|
+
*
|
|
38
|
+
* Internal: not exported from the entry. A `Field*` outside a `Form` injects nothing and registers
|
|
39
|
+
* nothing.
|
|
40
|
+
*/
|
|
41
|
+
export interface FieldAnchorRegistry {
|
|
42
|
+
/** Record (or update) the element id the field called `name` should be linked to. */
|
|
43
|
+
register(name: string, id: string | undefined): void;
|
|
44
|
+
/** Forget `name`, when the field unmounts or is renamed. */
|
|
45
|
+
unregister(name: string): void;
|
|
46
|
+
}
|
|
47
|
+
/** The key a `Form` provides its {@link FieldAnchorRegistry} on. Internal to this entry. */
|
|
48
|
+
export declare const FIELD_ANCHORS_KEY: InjectionKey<FieldAnchorRegistry>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { default as Form } from './Form.vue.js';
|
|
2
|
+
export { default as FieldCheckbox } from './FieldCheckbox.vue.js';
|
|
3
|
+
export { default as FieldCheckboxGroup } from './FieldCheckboxGroup.vue.js';
|
|
4
|
+
export { default as FieldCurrencyInput } from './FieldCurrencyInput.vue.js';
|
|
5
|
+
export { default as FieldInput } from './FieldInput.vue.js';
|
|
6
|
+
export { default as FieldMultiSelect } from './FieldMultiSelect.vue.js';
|
|
7
|
+
export { default as FieldQuantityStepper } from './FieldQuantityStepper.vue.js';
|
|
8
|
+
export { default as FieldRadioGroup } from './FieldRadioGroup.vue.js';
|
|
9
|
+
export { default as FieldSearchBar } from './FieldSearchBar.vue.js';
|
|
10
|
+
export { default as FieldSelect } from './FieldSelect.vue.js';
|
|
11
|
+
export { default as FieldSwitch } from './FieldSwitch.vue.js';
|
|
12
|
+
export { default as FieldTextarea } from './FieldTextarea.vue.js';
|
|
13
|
+
export { default as FieldUnitInput } from './FieldUnitInput.vue.js';
|
|
14
|
+
export { default as FieldVariantPicker } from './FieldVariantPicker.vue.js';
|
|
15
|
+
export { API_ERRORS_KEY } from './context.js';
|
|
16
|
+
export type { FieldBinding, FieldCheckboxGroupProps, FieldCheckboxProps, FieldCurrencyInputProps, FieldInputProps, FieldMultiSelectProps, FieldQuantityStepperProps, FieldRadioGroupProps, FieldSearchBarProps, FieldSelectProps, FieldSwitchProps, FieldTextareaProps, FieldUnitInputProps, FieldVariantPickerProps, FormProps, FormSlotProps, FormValidationSchema, FormValues, } from './types.js';
|
|
17
|
+
/**
|
|
18
|
+
* The building block the thirteen `Field*` components are made of, exported so a consumer wrapping a
|
|
19
|
+
* control this package does not ship — or one of its own — binds it the same way: the value, the
|
|
20
|
+
* message gated on "touched or submitted", the `id` the error summary links to, and the server
|
|
21
|
+
* error that clears when the value changes.
|
|
22
|
+
*
|
|
23
|
+
* `FIELD_ONLY` comes with it: the prop names a `Field*` keeps for itself and must **not** forward
|
|
24
|
+
* to the control it wraps (`path`, `rules`, `label`, `id`). Without it a consumer writing their own
|
|
25
|
+
* wrapper has to rediscover the list by reading this package's source.
|
|
26
|
+
*/
|
|
27
|
+
export { FIELD_ONLY, useFieldControl, type UseFieldControlOptions, type UseFieldControlReturn, } from './useFieldControl.js';
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { FormMeta, FormOptions, RuleExpression } from 'vee-validate';
|
|
2
|
+
import { CheckboxGroupProps, CheckboxProps } from '../components/checkbox/types.js';
|
|
3
|
+
import { FormLayoutProps } from '../components/form-layout/types.js';
|
|
4
|
+
import { InputProps } from '../components/input/types.js';
|
|
5
|
+
import { CurrencyInputProps } from '../components/currency-input/types.js';
|
|
6
|
+
import { QuantityStepperProps } from '../components/quantity-stepper/types.js';
|
|
7
|
+
import { RadioGroupProps } from '../components/radio/types.js';
|
|
8
|
+
import { SearchBarProps } from '../components/search-bar/types.js';
|
|
9
|
+
import { MultiSelectProps, SelectProps } from '../components/select/types.js';
|
|
10
|
+
import { SwitchProps } from '../components/switch/types.js';
|
|
11
|
+
import { TextareaProps } from '../components/textarea/types.js';
|
|
12
|
+
import { UnitInputProps } from '../components/unit-input/types.js';
|
|
13
|
+
import { VariantPickerProps } from '../components/variant-picker/types.js';
|
|
14
|
+
/**
|
|
15
|
+
* What every `Field*` adds to the agnostic component it wraps.
|
|
16
|
+
*
|
|
17
|
+
* `rules` is vee-validate's own `RuleExpression`: a rule string (`'required|email'`), an object
|
|
18
|
+
* (`{ required: true, min: 3 }`), a validator function, or a typed schema (yup, or zod through
|
|
19
|
+
* `@vee-validate/zod`). A `Form` carrying a `validationSchema` needs none of it — the schema names
|
|
20
|
+
* the fields itself — so `rules` is for the per-field case.
|
|
21
|
+
*/
|
|
22
|
+
export interface FieldBinding<TValue = unknown> {
|
|
23
|
+
/**
|
|
24
|
+
* The control's own `name` — and, unless `path` overrides it, the field's path in the form's
|
|
25
|
+
* values.
|
|
26
|
+
*
|
|
27
|
+
* The two are the same thing for every control whose `name` is the native form field name. They
|
|
28
|
+
* are **not** for `VariantPicker`, whose `name` is the visible option name ("Size", "Colour") as
|
|
29
|
+
* well as the radios' shared native name: there, `name` stays the legend and `path` says where
|
|
30
|
+
* the value lives.
|
|
31
|
+
*/
|
|
32
|
+
name: string;
|
|
33
|
+
/**
|
|
34
|
+
* The field's path in the form's values, when it should not be `name` — the key `initialValues`,
|
|
35
|
+
* `validationSchema`, `apiErrors` and the `errors` slot prop all use.
|
|
36
|
+
*/
|
|
37
|
+
path?: string;
|
|
38
|
+
/** Per-field rules. Leave it out when the `Form` carries a `validationSchema`. */
|
|
39
|
+
rules?: RuleExpression<TValue>;
|
|
40
|
+
/** The name a rule message uses for this field ("Email address"), not a visible label. */
|
|
41
|
+
label?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Every `Field*` takes its component's own props, minus the ones it owns itself: `modelValue`
|
|
45
|
+
* (vee-validate holds the value) and `invalid` / `error` (the field's own validation state). They
|
|
46
|
+
* are `Omit`ted rather than ignored, so passing one is a compile error rather than a prop that
|
|
47
|
+
* silently does nothing.
|
|
48
|
+
*/
|
|
49
|
+
export type FieldInputProps = Omit<InputProps, 'modelValue' | 'invalid'> & FieldBinding<string>;
|
|
50
|
+
export type FieldTextareaProps = Omit<TextareaProps, 'modelValue' | 'invalid'> & FieldBinding<string>;
|
|
51
|
+
/** `number | null`, not a string: a rule compares numbers and the form submits one. */
|
|
52
|
+
export type FieldUnitInputProps = Omit<UnitInputProps, 'modelValue' | 'invalid'> & FieldBinding<number | null>;
|
|
53
|
+
/** The same value as `FieldUnitInput`'s, for the money field. */
|
|
54
|
+
export type FieldCurrencyInputProps = Omit<CurrencyInputProps, 'modelValue' | 'invalid'> & FieldBinding<number | null>;
|
|
55
|
+
export type FieldCheckboxProps = Omit<CheckboxProps, 'modelValue' | 'invalid'> & FieldBinding<boolean>;
|
|
56
|
+
export type FieldCheckboxGroupProps = Omit<CheckboxGroupProps, 'modelValue' | 'error'> & FieldBinding<string[]>;
|
|
57
|
+
export type FieldRadioGroupProps = Omit<RadioGroupProps, 'modelValue' | 'error'> & FieldBinding<string>;
|
|
58
|
+
export type FieldSwitchProps = Omit<SwitchProps, 'modelValue'> & FieldBinding<boolean>;
|
|
59
|
+
export type FieldSelectProps = Omit<SelectProps, 'modelValue' | 'invalid'> & FieldBinding<string>;
|
|
60
|
+
export type FieldMultiSelectProps = Omit<MultiSelectProps, 'modelValue' | 'invalid'> & FieldBinding<string[]>;
|
|
61
|
+
export type FieldQuantityStepperProps = Omit<QuantityStepperProps, 'modelValue' | 'error'> & FieldBinding<number>;
|
|
62
|
+
export type FieldVariantPickerProps = Omit<VariantPickerProps, 'modelValue'> & FieldBinding<string>;
|
|
63
|
+
/**
|
|
64
|
+
* `SearchBar`'s own `label` is the field's accessible name and `FieldBinding`'s is the name rule
|
|
65
|
+
* messages use — the same string in practice, so the one prop serves both here: it is handed to
|
|
66
|
+
* `useField` *and* forwarded to the control.
|
|
67
|
+
*/
|
|
68
|
+
export type FieldSearchBarProps = Omit<SearchBarProps, 'modelValue'> & FieldBinding<string>;
|
|
69
|
+
/** The values a `Form` holds, keyed by each field's `name`. */
|
|
70
|
+
export type FormValues = Record<string, unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* A form-level validation schema, exactly as `useForm` takes it: vee-validate's own rule map
|
|
73
|
+
* (`{ email: 'required|email' }`) or a typed schema (yup, or zod through `@vee-validate/zod`).
|
|
74
|
+
*/
|
|
75
|
+
export type FormValidationSchema = FormOptions<FormValues>['validationSchema'];
|
|
76
|
+
/**
|
|
77
|
+
* Everything `FormLayout` takes except `focusOnInvalid`: a `Form` owns where focus lands on a
|
|
78
|
+
* failed submit (it has to, because on the first attempt nothing is marked invalid yet), so it
|
|
79
|
+
* turns the layout's own focus move off rather than letting a caller ask for two of them.
|
|
80
|
+
*/
|
|
81
|
+
export interface FormProps extends Omit<FormLayoutProps, 'focusOnInvalid'> {
|
|
82
|
+
/** The values the form starts with, keyed by each field's path (its `path`, else its `name`). */
|
|
83
|
+
initialValues?: FormValues;
|
|
84
|
+
/** A form-level schema. Fields then need no `rules` of their own. */
|
|
85
|
+
validationSchema?: FormValidationSchema;
|
|
86
|
+
/**
|
|
87
|
+
* Field errors from the server, keyed by each field's path (its `path`, else its `name`). Applied
|
|
88
|
+
* with `setErrors`, and each one is dropped again the moment its own field changes.
|
|
89
|
+
*/
|
|
90
|
+
apiErrors?: Record<string, string>;
|
|
91
|
+
/**
|
|
92
|
+
* Announced in the form's polite live region once a submit has passed validation. It is never
|
|
93
|
+
* visible: the visible confirmation — replacing the form, or navigating — stays the page's job.
|
|
94
|
+
* `statusMessage` wins over it when both are set.
|
|
95
|
+
*/
|
|
96
|
+
successMessage?: string;
|
|
97
|
+
}
|
|
98
|
+
/** What the default slot receives, so a `FieldWrapper` can show the message itself. */
|
|
99
|
+
export interface FormSlotProps {
|
|
100
|
+
/**
|
|
101
|
+
* The errors that should currently be **shown**, keyed by each field's path (its `path`, else its
|
|
102
|
+
* `name`): a field's message appears here once that field has been touched, the form has been
|
|
103
|
+
* submitted, or the server sent one — the same gate each `Field*` applies to its own `invalid`
|
|
104
|
+
* state.
|
|
105
|
+
*/
|
|
106
|
+
errors: Record<string, string>;
|
|
107
|
+
/** The form's current values. */
|
|
108
|
+
values: FormValues;
|
|
109
|
+
/** vee-validate's form-level meta: `touched`, `dirty`, `valid`, `pending`. */
|
|
110
|
+
meta: FormMeta<FormValues>;
|
|
111
|
+
/** True between a valid submit and the end of the submit handler. */
|
|
112
|
+
isSubmitting: boolean;
|
|
113
|
+
/** How many times the form has been submitted. `0` before the first attempt. */
|
|
114
|
+
submitCount: number;
|
|
115
|
+
}
|