@eldrajs/ui 0.0.0 → 0.1.2
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 +1725 -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 +12587 -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 +5259 -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 +99 -2
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The design spec's three sizes (spec "Price" → Sizes). `md` is the odd one out: its current
|
|
3
|
+
* price has no size of its own and inherits whatever the surrounding text sets (1rem by default),
|
|
4
|
+
* which is why `PriceProps.size` defaults to `md` rather than to a fixed rem value.
|
|
5
|
+
*/
|
|
6
|
+
export type PriceSize = 'sm' | 'md' | 'lg';
|
|
7
|
+
/** The parts a consumer can restyle through `classes`, named as the spec's anatomy names them.
|
|
8
|
+
* `srText` covers both hidden labels (the "Sale price" before `current` and the "Regular price"
|
|
9
|
+
* before `compareAt`) — two elements sharing one part name, the same shape as a repeated part in
|
|
10
|
+
* any list-like component. Named `srText`, not `srLabel`, to match the same visually-hidden part
|
|
11
|
+
* on `Avatar`/`LogoItem` — see this package's README for the naming rule.
|
|
12
|
+
*
|
|
13
|
+
* `currentValue` and `compareAtValue` are the inner spans holding the formatted amounts inside
|
|
14
|
+
* `current`/`compareAt`. They exist so the refresh dim (on the part) and the fade a changed amount
|
|
15
|
+
* plays (on the span) are not the same element fighting over `opacity`; they add no box of their
|
|
16
|
+
* own, and a consumer who only wants to restyle the amount's text can reach either one. */
|
|
17
|
+
export type PricePart = 'root' | 'current' | 'currentValue' | 'compareAt' | 'compareAtValue' | 'from' | 'unit' | 'srText' | 'skeleton' | 'spinner' | 'srStatus';
|
|
18
|
+
export interface PriceProps {
|
|
19
|
+
/**
|
|
20
|
+
* The current price, in minor units (cents) — for a zero-decimal currency like `ISK`, whole
|
|
21
|
+
* units, since that currency has no minor unit to count in. Converted to major units with
|
|
22
|
+
* `currencyFractionDigits(currency, locale)` before formatting.
|
|
23
|
+
*/
|
|
24
|
+
amount: number;
|
|
25
|
+
/**
|
|
26
|
+
* The regular price, in minor units, same shape as `amount`. Sale state turns on automatically
|
|
27
|
+
* only when this is greater than `amount`; a `compareAt` that is equal to or lower than `amount`
|
|
28
|
+
* is ignored entirely (spec "Price" → Properties, `compareAt` row).
|
|
29
|
+
*/
|
|
30
|
+
compareAt?: number | null;
|
|
31
|
+
/**
|
|
32
|
+
* ISO 4217 currency code, e.g. `"USD"`, `"ISK"`. Defaults to `useEldraUiCurrency()`, and with
|
|
33
|
+
* no currency from either the amount is rendered as a plain number — there is no default code
|
|
34
|
+
* (see that composable). `""` means "no currency" here too, the same as it does there.
|
|
35
|
+
*/
|
|
36
|
+
currency?: string;
|
|
37
|
+
/** BCP 47 locale tag, e.g. `"en-US"`, `"is-IS"`. Defaults to `useEldraUiLocale()`. */
|
|
38
|
+
locale?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the currency's **narrow** sign is used — `"kr 2,800"` rather than `"ISK 2,800"` under
|
|
41
|
+
* `en-US`/`ISK`, `"$"` rather than `"US$"` in a locale that distinguishes the two. `false` by
|
|
42
|
+
* default, the same default `CurrencyInput.narrowSymbol` carries, so a price and a currency
|
|
43
|
+
* field on the same page can only write the same sign, and an English price reads `ISK 2,800`:
|
|
44
|
+
* a bare "kr" is also the Danish, Norwegian and Swedish krone.
|
|
45
|
+
*
|
|
46
|
+
* It changes only the sign: the fraction digits stay the currency's own either way (none for
|
|
47
|
+
* `ISK`, two for `USD`), and a locale whose narrow and wide signs are the same (`is-IS`'s `kr.`)
|
|
48
|
+
* is unaffected.
|
|
49
|
+
*/
|
|
50
|
+
narrowSymbol?: boolean;
|
|
51
|
+
/** See `PriceSize`. */
|
|
52
|
+
size?: PriceSize;
|
|
53
|
+
/** Shows the `labels.from` text before the price, for a product whose variants differ in price. */
|
|
54
|
+
from?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* A per-unit price rendered on its own line ("$6.00 / 100 g"), required by law in some markets.
|
|
57
|
+
* `amount` is in minor units, same conversion as the main price; `per` is rendered verbatim
|
|
58
|
+
* after `messages.perUnit`'s separator (e.g. `"100 g"`).
|
|
59
|
+
*/
|
|
60
|
+
unitPrice?: {
|
|
61
|
+
amount: number;
|
|
62
|
+
per: string;
|
|
63
|
+
} | null;
|
|
64
|
+
/**
|
|
65
|
+
* Overrides the three labels the component otherwise reads from `useMessages()`
|
|
66
|
+
* (`salePrice`, `regularPrice`, `from`). Each key falls back to its message independently, so a
|
|
67
|
+
* consumer overriding only `from` still gets the default hidden sale/regular labels.
|
|
68
|
+
*/
|
|
69
|
+
labels?: Partial<{
|
|
70
|
+
sale: string;
|
|
71
|
+
regular: string;
|
|
72
|
+
from: string;
|
|
73
|
+
}>;
|
|
74
|
+
/** Set on the root when the price's language differs from the page's, e.g. `"is"`. */
|
|
75
|
+
lang?: string | null;
|
|
76
|
+
/** Renders a text skeleton at 35% width instead of the price (spec "Price" → Properties). */
|
|
77
|
+
loading?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* The price is on screen but a fresher one is on its way — a prerendered amount being refreshed
|
|
80
|
+
* after load, say. The amount stays exactly where it is and keeps its text, dimmed to
|
|
81
|
+
* `--eldra-revalidating-opacity`, with a small spinner beside it (drawn outside the root's own
|
|
82
|
+
* box, so nothing moves) and `aria-busy="true"` on the root; a visually hidden live region says
|
|
83
|
+
* `messages.updatingPrice`. Distinct from `loading`, which means there is no price yet and shows
|
|
84
|
+
* a skeleton instead — and `loading` wins when both are set.
|
|
85
|
+
*
|
|
86
|
+
* Independently of this flag, a changed `amount`/`compareAt` fades in over
|
|
87
|
+
* `--eldra-duration-base` rather than simply appearing — enter only, on the element that already
|
|
88
|
+
* holds the new text, so the amount is correct the instant the prop changes and a stale one is
|
|
89
|
+
* never left on screen; instantly, with no animation at all, under
|
|
90
|
+
* `prefers-reduced-motion: reduce`. The value never regresses to a skeleton, and there is never
|
|
91
|
+
* more than one copy of it in the accessibility tree.
|
|
92
|
+
*/
|
|
93
|
+
revalidating?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Whether this price announces its own refresh. `true` by default: while `revalidating`, the
|
|
96
|
+
* visually hidden `aria-live="polite"` region reads `messages.updatingPrice`. Set it to `false`
|
|
97
|
+
* when the page announces the refresh once itself — a grid of 24 refreshing cards would
|
|
98
|
+
* otherwise hold 48 polite regions, all speaking at once. `aria-busy`, the dim and the spinner
|
|
99
|
+
* are unaffected; only the region goes.
|
|
100
|
+
*/
|
|
101
|
+
announce?: boolean;
|
|
102
|
+
/** Per-part class overrides, merged with `tailwind-merge`. */
|
|
103
|
+
classes?: Partial<Record<PricePart, string>>;
|
|
104
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ProductCardProduct, ProductCardProps } from './types.js';
|
|
2
|
+
declare const __VLS_export: import('vue').DefineComponent<ProductCardProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
3
|
+
quickAdd: (product: ProductCardProduct) => any;
|
|
4
|
+
}, string, import('vue').PublicProps, Readonly<ProductCardProps> & Readonly<{
|
|
5
|
+
onQuickAdd?: ((product: ProductCardProduct) => any) | undefined;
|
|
6
|
+
}>, {
|
|
7
|
+
classes: Partial<Record<import('./types.js').ProductCardPart, string>>;
|
|
8
|
+
headingLevel: import('../../index.js').HeadingLevel;
|
|
9
|
+
loading: boolean;
|
|
10
|
+
quickAdd: boolean;
|
|
11
|
+
linkAs: string | import('vue').Component;
|
|
12
|
+
ratio: import('./types.js').ProductCardRatio;
|
|
13
|
+
locale: string;
|
|
14
|
+
currency: string;
|
|
15
|
+
revalidating: boolean;
|
|
16
|
+
announce: boolean;
|
|
17
|
+
showVendor: boolean;
|
|
18
|
+
showRating: boolean;
|
|
19
|
+
showSwatches: boolean;
|
|
20
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
21
|
+
declare const _default: typeof __VLS_export;
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
import { HeadingLevel } from '../../composables/useHeadingTag.js';
|
|
3
|
+
import { ImageMedia } from '../image/types.js';
|
|
4
|
+
import { StockLevel } from '../badge/types.js';
|
|
5
|
+
/**
|
|
6
|
+
* The media ratios `ProductCard` itself offers (spec "Product card" → Properties, `ratio` row):
|
|
7
|
+
* a subset of `Image`'s own `ImageRatio` — the three the spec names for commerce grids, not
|
|
8
|
+
* every preset `Image` supports (a product card is never `16x9` or `3x2`).
|
|
9
|
+
*/
|
|
10
|
+
export type ProductCardRatio = '4x5' | '1x1' | '3x4';
|
|
11
|
+
/**
|
|
12
|
+
* One product, exactly the API contract's own `ProductCardProduct` type. `price` mirrors `Price`'s
|
|
13
|
+
* own minor-units/`compareAt`/`from` inputs verbatim, so it passes straight through; `colours` is
|
|
14
|
+
* the swatch-dot data (`swatch` is a colour string from product data, the one per-item colour the
|
|
15
|
+
* design spec allows — see `VariantPicker`'s own precedent); `badge` is the caller's own sale/new
|
|
16
|
+
* decision (the spec's "derived automatically... when tagged `new`" needs a tag vocabulary this
|
|
17
|
+
* type does not carry, so the card trusts this field instead of re-deriving it — see
|
|
18
|
+
* `ProductCard.vue`'s own comment); `stock`, kept deliberately separate from `available`, is an
|
|
19
|
+
* addition beyond the spec's own 8-part anatomy — see `ProductCard.vue`'s comment on
|
|
20
|
+
* `showStockLine` for why it exists and how it composes `StockBadge`.
|
|
21
|
+
*/
|
|
22
|
+
export interface ProductCardProduct {
|
|
23
|
+
/** The product's full name — also the link's accessible name in full, even while the visible
|
|
24
|
+
* title is clamped to two lines. */
|
|
25
|
+
title: string;
|
|
26
|
+
/** The product page. Also what `quickAdd` events identify the product by, alongside `title`. */
|
|
27
|
+
url: string;
|
|
28
|
+
/** Shown above the title when `showVendor` is on. */
|
|
29
|
+
vendor?: string;
|
|
30
|
+
/** `null`/omitted renders `Image`'s own live "No image" placeholder at the same ratio. */
|
|
31
|
+
featuredImage?: ImageMedia | null;
|
|
32
|
+
/** `Price`'s own inputs, in minor units. Sale styling and the sale badge's percentage both
|
|
33
|
+
* derive from `compareAt > amount` — see `ProductCard.vue`'s `discountPercent`. */
|
|
34
|
+
price: {
|
|
35
|
+
amount: number;
|
|
36
|
+
compareAt?: number | null;
|
|
37
|
+
from?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** `null`/omitted hides `Rating` regardless of `showRating` — spec: "Hide when the store has
|
|
40
|
+
* no reviews at all." */
|
|
41
|
+
rating?: {
|
|
42
|
+
value: number;
|
|
43
|
+
count: number;
|
|
44
|
+
} | null;
|
|
45
|
+
/** The swatch dots' data. `swatch` is an arbitrary CSS colour from product data — data, not a
|
|
46
|
+
* design token, the same allowance `VariantPicker` has for its own swatches. */
|
|
47
|
+
colours?: Array<{
|
|
48
|
+
name: string;
|
|
49
|
+
swatch: string;
|
|
50
|
+
}>;
|
|
51
|
+
/** The caller's own sale/new decision (spec anatomy part 2). `null`/omitted renders no
|
|
52
|
+
* sale/new badge. Ignored while `available` is `false` — the "Sold out" badge replaces it
|
|
53
|
+
* rather than stacking a third badge (`Badge`'s own acceptance criterion: "a third badge is
|
|
54
|
+
* never rendered"). */
|
|
55
|
+
badge?: {
|
|
56
|
+
variant: 'sale' | 'new';
|
|
57
|
+
} | null;
|
|
58
|
+
/** An additional stock status line beyond the spec's own 8-part anatomy — see
|
|
59
|
+
* `ProductCard.vue`'s `showStockLine` comment. Ignored while `available` is `false`. */
|
|
60
|
+
stock?: StockLevel | null;
|
|
61
|
+
/** `false` renders the sold-out state (spec "Product card" → Variants, "Sold out" row):
|
|
62
|
+
* media at 60% opacity, an outline "Sold out" badge, and quick add replaced by a disabled
|
|
63
|
+
* "Sold out" button. Omitted/`true` is the ordinary available state. */
|
|
64
|
+
available?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** The parts a consumer can restyle through `classes`, named as the spec's anatomy names them,
|
|
67
|
+
* plus `stockLine` for the addition beyond it (see `ProductCardProduct.stock`). */
|
|
68
|
+
export type ProductCardPart = 'root' | 'media' | 'badges' | 'body' | 'vendor' | 'title' | 'link' | 'price' | 'rating' | 'stockLine' | 'swatches' | 'swatch' | 'swatchOverflow' | 'quickAdd' | 'skeleton';
|
|
69
|
+
export interface ProductCardProps {
|
|
70
|
+
/** The product. See `ProductCardProduct`. */
|
|
71
|
+
product: ProductCardProduct;
|
|
72
|
+
/** Shows the vendor line. Defaults to `false` (spec "Product card" → Properties). */
|
|
73
|
+
showVendor?: boolean;
|
|
74
|
+
/** Shows `Rating`, when the product has one. Defaults to `true` — turn it off store-wide when
|
|
75
|
+
* the shop has no reviews at all. */
|
|
76
|
+
showRating?: boolean;
|
|
77
|
+
/** Shows the colour dots, when the product has any. Defaults to `true`. */
|
|
78
|
+
showSwatches?: boolean;
|
|
79
|
+
/** Shows the quick-add control (the live button when available, the disabled "Sold out"
|
|
80
|
+
* button when not). Defaults to `true`. */
|
|
81
|
+
quickAdd?: boolean;
|
|
82
|
+
/** The media's aspect ratio; one ratio per grid (spec "Product card" → Properties). Defaults
|
|
83
|
+
* to `'4x5'`. */
|
|
84
|
+
ratio?: ProductCardRatio;
|
|
85
|
+
/** The title heading's level; follows the surrounding block. Defaults to `3` (h3 under a
|
|
86
|
+
* block h2, spec "Product card" → Anatomy, part 4). */
|
|
87
|
+
headingLevel?: HeadingLevel;
|
|
88
|
+
/** Renders the loading skeleton (spec "Product card" → Variants, Loading row) instead of the
|
|
89
|
+
* card. */
|
|
90
|
+
loading?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The card's volatile values — the price and the stock line — are on screen but fresher ones are
|
|
93
|
+
* on their way, which is what a prerendered grid does after load. Passed straight through to
|
|
94
|
+
* `Price` and `StockBadge`, each of which dims its own value, draws a spinner beside it and
|
|
95
|
+
* announces the refresh; the rest of the card (title, media, badges, quick add) is untouched and
|
|
96
|
+
* stays interactive. Ignored while `loading`, which replaces the whole card with a skeleton.
|
|
97
|
+
*/
|
|
98
|
+
revalidating?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Whether the card's price and stock line announce their own refresh, passed straight through to
|
|
101
|
+
* both. `true` by default. A grid should set it to `false` and announce once at page level:
|
|
102
|
+
* 24 refreshing cards otherwise hold 48 polite live regions, all speaking at once. `aria-busy`
|
|
103
|
+
* on each value, the dim and the spinners are unaffected.
|
|
104
|
+
*/
|
|
105
|
+
announce?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* `Price`'s own `currency` prop, passed straight through. Defaults to `useEldraUiCurrency()`,
|
|
108
|
+
* which has no default code: with no currency from either, the price is a plain number.
|
|
109
|
+
*/
|
|
110
|
+
currency?: string;
|
|
111
|
+
/** `Price`'s own `locale` prop, passed straight through. Defaults to `useEldraUiLocale()`. */
|
|
112
|
+
locale?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Render the title link as a different component (e.g. a router link), which receives the
|
|
115
|
+
* destination as `to` instead of `href` — the same contract as `Link`/`Rating`'s `as`. Named
|
|
116
|
+
* `linkAs`, not `as`: this card's own root is a fixed `<article>`/`<div>` (loading), so `as`
|
|
117
|
+
* would be ambiguous with `Badge`/`Container`/`Section`'s `as`, which picks the root tag itself —
|
|
118
|
+
* see this package's README "as vs linkAs" note.
|
|
119
|
+
*/
|
|
120
|
+
linkAs?: string | Component;
|
|
121
|
+
/** Per-part class overrides, merged with `tailwind-merge`. */
|
|
122
|
+
classes?: Partial<Record<ProductCardPart, string>>;
|
|
123
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { QuantityStepperProps, QuantityStepperSize } from './types.js';
|
|
2
|
+
declare const __VLS_export: import('vue').DefineComponent<QuantityStepperProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
3
|
+
blur: (event: FocusEvent) => any;
|
|
4
|
+
"update:modelValue": (value: number) => any;
|
|
5
|
+
focus: (event: FocusEvent) => any;
|
|
6
|
+
change: (value: number) => any;
|
|
7
|
+
}, string, import('vue').PublicProps, Readonly<QuantityStepperProps> & Readonly<{
|
|
8
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
9
|
+
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
10
|
+
onFocus?: ((event: FocusEvent) => any) | undefined;
|
|
11
|
+
onChange?: ((value: number) => any) | undefined;
|
|
12
|
+
}>, {
|
|
13
|
+
size: QuantityStepperSize;
|
|
14
|
+
name: string;
|
|
15
|
+
classes: Partial<Record<import('./types.js').QuantityStepperPart, string>>;
|
|
16
|
+
modelValue: number;
|
|
17
|
+
error: string;
|
|
18
|
+
max: number;
|
|
19
|
+
id: string;
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
locale: string;
|
|
22
|
+
min: number;
|
|
23
|
+
itemName: string;
|
|
24
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const _default: typeof __VLS_export;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The parts a consumer can restyle through `classes`, named as this package's own contract names
|
|
2
|
+
* them (spec "Quantity stepper" → Anatomy draws the same four controls plus the error row every
|
|
3
|
+
* other field in this package shows the same way). */
|
|
4
|
+
export type QuantityStepperPart = 'root' | 'decrease' | 'input' | 'increase' | 'error';
|
|
5
|
+
/** The spec's two sizes (spec "Quantity stepper" → Sizes): the default and the cart-line/filter
|
|
6
|
+
* compact one. */
|
|
7
|
+
export type QuantityStepperSize = 'md' | 'sm';
|
|
8
|
+
export interface QuantityStepperProps {
|
|
9
|
+
/** The quantity (two-way). Defaults to `min` when unset, never 0 on a cart line. */
|
|
10
|
+
modelValue?: number;
|
|
11
|
+
/** Lowest value. Spec default `1` — "Never 0 on a cart line." */
|
|
12
|
+
min?: number;
|
|
13
|
+
/** Stock or a per-order limit. Spec default `99`. */
|
|
14
|
+
max?: number;
|
|
15
|
+
/** Buttons 2.5 × 2.5rem / input 2.75rem (`md`, the default) or 2 × 2rem / 2.25rem (`sm`). */
|
|
16
|
+
size?: QuantityStepperSize;
|
|
17
|
+
/** Appended to the button names in lists, e.g. "Increase quantity, Stoneware mug". */
|
|
18
|
+
itemName?: string;
|
|
19
|
+
/** Native form field name, carried by the input. */
|
|
20
|
+
name?: string;
|
|
21
|
+
/** Sold out: the whole stepper is disabled. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** A server rejection message shown below the group, with the new max. */
|
|
24
|
+
error?: string;
|
|
25
|
+
/** The control's id. Comes from the `FieldWrapper` when there is one; this wins over it. */
|
|
26
|
+
id?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The BCP 47 locale for display formatting and for parsing a typed value (`parseLocaleNumber`) —
|
|
29
|
+
* not part of the design spec's own Properties table, which the API contract adds. Defaults to
|
|
30
|
+
* whatever `provideEldraUiLocale` set for the app, and to `"en-US"` with nothing provided.
|
|
31
|
+
*/
|
|
32
|
+
locale?: string;
|
|
33
|
+
/** Per-part class overrides, merged with `tailwind-merge`. */
|
|
34
|
+
classes?: Partial<Record<QuantityStepperPart, string>>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RadioGroupOption, RadioGroupProps, RadioGroupSize } from './types.js';
|
|
2
|
+
declare var __VLS_1: {
|
|
3
|
+
option: RadioGroupOption;
|
|
4
|
+
}, __VLS_3: {
|
|
5
|
+
option: RadioGroupOption;
|
|
6
|
+
}, __VLS_5: {
|
|
7
|
+
option: RadioGroupOption;
|
|
8
|
+
};
|
|
9
|
+
type __VLS_Slots = {} & {
|
|
10
|
+
label?: (props: typeof __VLS_1) => any;
|
|
11
|
+
} & {
|
|
12
|
+
hint?: (props: typeof __VLS_3) => any;
|
|
13
|
+
} & {
|
|
14
|
+
meta?: (props: typeof __VLS_5) => any;
|
|
15
|
+
};
|
|
16
|
+
declare const __VLS_base: import('vue').DefineComponent<RadioGroupProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
17
|
+
"update:modelValue": (value: string) => any;
|
|
18
|
+
change: (value: string) => any;
|
|
19
|
+
}, string, import('vue').PublicProps, Readonly<RadioGroupProps> & Readonly<{
|
|
20
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
21
|
+
onChange?: ((value: string) => any) | undefined;
|
|
22
|
+
}>, {
|
|
23
|
+
size: RadioGroupSize;
|
|
24
|
+
name: string;
|
|
25
|
+
classes: Partial<Record<import('./types.js').RadioGroupPart, string>>;
|
|
26
|
+
modelValue: string;
|
|
27
|
+
required: boolean;
|
|
28
|
+
error: string;
|
|
29
|
+
layout: import('./types.js').RadioGroupLayout;
|
|
30
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
export default _default;
|
|
34
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
35
|
+
new (): {
|
|
36
|
+
$slots: S;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** The parts a consumer can restyle through `classes`, named as the spec's anatomy names them. */
|
|
2
|
+
export type RadioGroupPart = 'root' | 'legend' | 'options' | 'option' | 'radio' | 'label' | 'hint' | 'meta' | 'error' | 'errorIcon';
|
|
3
|
+
/** The spec's two radio sizes: 1.125rem or 1.5rem. Plain layouts only — a card's radio is fixed. */
|
|
4
|
+
export type RadioGroupSize = 'md' | 'lg';
|
|
5
|
+
/** `vertical` (default), `row` (wraps, for short labels) or `cards` (the whole option is a card). */
|
|
6
|
+
export type RadioGroupLayout = 'vertical' | 'row' | 'cards';
|
|
7
|
+
/** One option of a radio group. For `cards`, `label` is the card title and `meta` is the price. */
|
|
8
|
+
export interface RadioGroupOption {
|
|
9
|
+
/** The value posted, and the one the group's `modelValue` holds when this option is chosen. */
|
|
10
|
+
value: string;
|
|
11
|
+
/** The label text (plain rows), or the card title (cards). */
|
|
12
|
+
label: string;
|
|
13
|
+
/** A secondary line under the label. */
|
|
14
|
+
hint?: string;
|
|
15
|
+
/** Cards only: a price or note, end-aligned, tabular numerals ("Free", "$12.00"). */
|
|
16
|
+
meta?: string;
|
|
17
|
+
/** Native `disabled` for this option alone. Say why in `hint`. */
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface RadioGroupProps {
|
|
21
|
+
/** The selected value (two-way). */
|
|
22
|
+
modelValue?: string;
|
|
23
|
+
/** The shared native `name`. Generated when absent, so every option still posts as one field. */
|
|
24
|
+
name?: string;
|
|
25
|
+
/** The question, rendered as the fieldset's `<legend>`. */
|
|
26
|
+
legend: string;
|
|
27
|
+
/** The options. At most about 6 — past that, use `Select`. */
|
|
28
|
+
options: RadioGroupOption[];
|
|
29
|
+
/** `vertical` (default), `row` (wraps) or `cards` (the whole option is a bordered card). */
|
|
30
|
+
layout?: RadioGroupLayout;
|
|
31
|
+
/** Radio 1.125rem (`md`, the default) or 1.5rem (`lg`). Plain layouts only. */
|
|
32
|
+
size?: RadioGroupSize;
|
|
33
|
+
/** Native `required` on every radio. */
|
|
34
|
+
required?: boolean;
|
|
35
|
+
/** The group's error message. Sets `aria-invalid="true"` on every radio, linked by id. */
|
|
36
|
+
error?: string;
|
|
37
|
+
/** Per-part class overrides, merged with `tailwind-merge`. */
|
|
38
|
+
classes?: Partial<Record<RadioGroupPart, string>>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { RangeSliderEnd, RangeSliderInputsSlotProps, RangeSliderProps, RangeSliderTrackSlotProps, RangeSliderValue } from './types.js';
|
|
2
|
+
type __VLS_Slots = {
|
|
3
|
+
/**
|
|
4
|
+
* The typed row under the track, for a consumer whose numbers are not generic numbers (a store's
|
|
5
|
+
* own currency field). Omitted, the built-in min / "to" / max fields render — they are this slot's
|
|
6
|
+
* default content, not a separate code path. Only drawn at all when `inputs` is set.
|
|
7
|
+
*/
|
|
8
|
+
inputs?: (props: RangeSliderInputsSlotProps) => unknown;
|
|
9
|
+
/**
|
|
10
|
+
* A decoration spanning exactly the track's own width, above the rail — the design spec's price
|
|
11
|
+
* histogram is the one this exists for. It sits inside the gutter box, so it needs to know
|
|
12
|
+
* nothing about the reservation that keeps a thumb and its ring inside the control; see
|
|
13
|
+
* `RangeSliderTrackSlotProps`. It is drawn before the rail, so it never takes a pointer press
|
|
14
|
+
* away from the track: a decoration is not a second way to set the value.
|
|
15
|
+
*/
|
|
16
|
+
track?: (props: RangeSliderTrackSlotProps) => unknown;
|
|
17
|
+
};
|
|
18
|
+
declare const __VLS_base: import('vue').DefineComponent<RangeSliderProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
19
|
+
"update:modelValue": (value: RangeSliderValue) => any;
|
|
20
|
+
change: (value: RangeSliderValue) => any;
|
|
21
|
+
}, string, import('vue').PublicProps, Readonly<RangeSliderProps> & Readonly<{
|
|
22
|
+
"onUpdate:modelValue"?: ((value: RangeSliderValue) => any) | undefined;
|
|
23
|
+
onChange?: ((value: RangeSliderValue) => any) | undefined;
|
|
24
|
+
}>, {
|
|
25
|
+
label: string;
|
|
26
|
+
classes: Partial<Record<import('./types.js').RangeSliderPart, string>>;
|
|
27
|
+
modelValue: RangeSliderValue;
|
|
28
|
+
max: number;
|
|
29
|
+
step: number;
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
messages: Partial<import('../../index.js').UiMessages>;
|
|
32
|
+
min: number;
|
|
33
|
+
formatValue: (value: number, end
|
|
34
|
+
/**
|
|
35
|
+
* The design spec's **Range slider**: two thumbs on one track for a span of numbers, with an
|
|
36
|
+
* optional row of typed fields that are the same value by another route.
|
|
37
|
+
*
|
|
38
|
+
* Two shape decisions worth knowing before reading the rest:
|
|
39
|
+
*
|
|
40
|
+
* 1. **Each thumb is a `<div role="slider" tabindex="0">`, not a `<button>`.** `slider` is not one
|
|
41
|
+
* of the roles ARIA-in-HTML allows on a `<button>` (that list is checkbox, combobox, link,
|
|
42
|
+
* menuitem*, option, radio, switch, tab), so a `<button role="slider">` is a conformance error
|
|
43
|
+
* axe reports as `aria-allowed-role`. The WAI-ARIA Authoring Practices' own multi-thumb slider
|
|
44
|
+
* uses a `div` with `tabindex="0"`, and the keys this control needs (arrows, page, home, end)
|
|
45
|
+
* are implemented here in full either way — a `<button>` would contribute only `Enter`/`Space`
|
|
46
|
+
* activation, which a slider has no use for.
|
|
47
|
+
* 2. **Two tab stops, no roving tabindex.** Both ends of the range must be reachable, so the
|
|
48
|
+
* composite-widget rule ("one tab stop, arrow keys inside") does not apply: there is nothing to
|
|
49
|
+
* arrow *between*, and a roving tabindex would make one end unreachable by keyboard.
|
|
50
|
+
*
|
|
51
|
+
* Pointer presses are handled on the **rail** rather than on the thumbs. The rail is the band the
|
|
52
|
+
* spec sizes as the touch target, so a press anywhere in it moves the nearer thumb and keeps
|
|
53
|
+
* dragging it — a press is a drag of no distance — and the two thumbs' own (deliberately
|
|
54
|
+
* overlapping, 44px) targets can never argue about which one a press belongs to.
|
|
55
|
+
*/
|
|
56
|
+
?: RangeSliderEnd) => string;
|
|
57
|
+
inputs: boolean;
|
|
58
|
+
largeStep: number;
|
|
59
|
+
minLabel: string;
|
|
60
|
+
maxLabel: string;
|
|
61
|
+
trackVisible: boolean;
|
|
62
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
63
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
64
|
+
declare const _default: typeof __VLS_export;
|
|
65
|
+
export default _default;
|
|
66
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
67
|
+
new (): {
|
|
68
|
+
$slots: S;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { UiMessages } from '../../messages/en-US.js';
|
|
2
|
+
/**
|
|
3
|
+
* The parts a consumer can restyle through `classes`, named as the design spec's "Range slider"
|
|
4
|
+
* anatomy names them. Both thumbs share the `thumb` part and both fields share the `input` part —
|
|
5
|
+
* one class string styles the pair, and each element carries a `data-thumb` / `data-input`
|
|
6
|
+
* attribute of `"min"` or `"max"` for the rare rule that has to tell them apart.
|
|
7
|
+
*/
|
|
8
|
+
export type RangeSliderPart = 'root' | 'label' | 'group' | 'rail' | 'track' | 'range' | 'thumb' | 'inputs' | 'input' | 'separator';
|
|
9
|
+
/** Which end of the range a value, a thumb or a field belongs to. */
|
|
10
|
+
export type RangeSliderThumb = 'min' | 'max';
|
|
11
|
+
/**
|
|
12
|
+
* Which end of the range a value belongs to: `0` the minimum, `1` the maximum. It is what a
|
|
13
|
+
* slot's `commit` addresses, and what `formatValue` is told when the number it is formatting is a
|
|
14
|
+
* thumb's own (see `RangeSliderProps.formatValue`).
|
|
15
|
+
*/
|
|
16
|
+
export type RangeSliderEnd = 0 | 1;
|
|
17
|
+
/**
|
|
18
|
+
* What the `inputs` slot is handed — everything a replacement field needs to be *this* control's
|
|
19
|
+
* field rather than a second source of truth beside it.
|
|
20
|
+
*
|
|
21
|
+
* The slot exists because the numbers a control like this edits are often not generic numbers. A
|
|
22
|
+
* store filtering by price wants its own currency field — grouping, the symbol, the store's
|
|
23
|
+
* fraction digits, the caret behaviour money fields have — and the built-in fields cannot be that
|
|
24
|
+
* without this package deciding a consumer's money formatting for them. So the row is replaceable
|
|
25
|
+
* and the *value* is not: `commit` applies the same rules the built-in fields do (snap to the step
|
|
26
|
+
* grid, clamp to `[min, max]`, clamp against the other thumb, then emit `change`), so a slotted
|
|
27
|
+
* field and a dragged thumb cannot disagree about what the range is.
|
|
28
|
+
*/
|
|
29
|
+
export interface RangeSliderInputsSlotProps {
|
|
30
|
+
/** The current span as the control holds it: snapped into the bounds, lowest first. */
|
|
31
|
+
value: RangeSliderValue;
|
|
32
|
+
min: number;
|
|
33
|
+
max: number;
|
|
34
|
+
step: number;
|
|
35
|
+
disabled: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The names the two thumbs already carry (`minLabel`/`maxLabel`, else the `minimum`/`maximum`
|
|
38
|
+
* message joined with `label`) and the word between the fields. A replacement field should name
|
|
39
|
+
* itself with the same string its thumb does, or a screen reader hears two different names for
|
|
40
|
+
* one end of the range.
|
|
41
|
+
*/
|
|
42
|
+
labels: {
|
|
43
|
+
min: string;
|
|
44
|
+
max: string;
|
|
45
|
+
separator: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* **Apply one end of the range**, exactly as a built-in field's blur or `Enter` does: `next` is
|
|
49
|
+
* snapped to the step grid, clamped to the bounds and clamped against the other thumb, the model
|
|
50
|
+
* is updated and `change` is emitted. `null` is an emptied field, which falls back to that end of
|
|
51
|
+
* the range — the gesture that clears half a filter.
|
|
52
|
+
*
|
|
53
|
+
* It returns the number that was actually applied, which is what a controlled field should show:
|
|
54
|
+
* a parent has not applied the write yet when this returns, and an `Enter` commit leaves the
|
|
55
|
+
* field focused, so re-reading `value` would show the old number until the parent's update
|
|
56
|
+
* arrived.
|
|
57
|
+
*
|
|
58
|
+
* Call it on **blur or `Enter`**, never per keystroke (spec "Range slider" → Behaviour & motion):
|
|
59
|
+
* a commit per character would snap and clamp a half-typed number.
|
|
60
|
+
*/
|
|
61
|
+
commit: (end: RangeSliderEnd, next: number | null) => number;
|
|
62
|
+
}
|
|
63
|
+
/** The selected span, lowest first. The two may meet but never cross. */
|
|
64
|
+
export type RangeSliderValue = [number, number];
|
|
65
|
+
/**
|
|
66
|
+
* What the `track` slot is handed — enough to draw something *over the same span the track
|
|
67
|
+
* covers* without re-deriving it.
|
|
68
|
+
*
|
|
69
|
+
* The slot exists for the one decoration the design spec puts above a range: a price histogram,
|
|
70
|
+
* 24 bars showing where the products sit, which has to line up with the track to the pixel or it
|
|
71
|
+
* says the wrong thing about the range. It renders inside the control's gutter box and above the
|
|
72
|
+
* rail, so its width is exactly the track's width — the gutter that keeps a thumb, its focus ring
|
|
73
|
+
* and its pointer target inside the control (`eldra-range-gutter`) is already applied to that box,
|
|
74
|
+
* and nothing in the slot has to know what that reservation currently is.
|
|
75
|
+
*
|
|
76
|
+
* `percent` is the filled part's own two edges as percentages of the track, which is what a
|
|
77
|
+
* decoration needs to tell "inside the range" from "outside" (a histogram bar is "in" when its
|
|
78
|
+
* bucket centre lies between the thumbs). It is derived from `value` and the bounds, so a slot can
|
|
79
|
+
* ignore it; it is handed over because every consumer of this slot would otherwise write the same
|
|
80
|
+
* two `((v - min) / (max - min)) * 100` lines.
|
|
81
|
+
*/
|
|
82
|
+
export interface RangeSliderTrackSlotProps {
|
|
83
|
+
/** The current span as the control holds it: snapped into the bounds, lowest first. */
|
|
84
|
+
value: RangeSliderValue;
|
|
85
|
+
min: number;
|
|
86
|
+
max: number;
|
|
87
|
+
step: number;
|
|
88
|
+
disabled: boolean;
|
|
89
|
+
/** The filled part's start and end as percentages of the track, `0`–`100`. */
|
|
90
|
+
percent: [number, number];
|
|
91
|
+
}
|
|
92
|
+
export interface RangeSliderProps {
|
|
93
|
+
/** The selected span (two-way). Unset, the control starts at `[min, max]`. */
|
|
94
|
+
modelValue?: RangeSliderValue;
|
|
95
|
+
/** The lowest value either thumb can reach. Spec default `0`. */
|
|
96
|
+
min?: number;
|
|
97
|
+
/** The highest value either thumb can reach. Spec default `100`. */
|
|
98
|
+
max?: number;
|
|
99
|
+
/**
|
|
100
|
+
* The granularity of every move — an arrow key, a pointer press and a typed value all land on a
|
|
101
|
+
* multiple of it, counted from `min`. A store picks a sensible unit of its currency (ISK 100,
|
|
102
|
+
* USD 1). The two endpoints stay reachable even when they are not on that grid.
|
|
103
|
+
*/
|
|
104
|
+
step?: number;
|
|
105
|
+
/** The coarse move, for `Shift` + an arrow and for `PageUp` / `PageDown`. Defaults to `step` × 10. */
|
|
106
|
+
largeStep?: number;
|
|
107
|
+
/** The whole control: both thumbs, the rail and both fields. */
|
|
108
|
+
disabled?: boolean;
|
|
109
|
+
/** The visible group label ("Price"). It names the group and both thumbs. */
|
|
110
|
+
label?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The minimum thumb's and minimum field's name. Defaults to the `minimum` message joined with
|
|
113
|
+
* the visible `label` ("Minimum price"), or to `minimum` alone with no label.
|
|
114
|
+
*/
|
|
115
|
+
minLabel?: string;
|
|
116
|
+
/** The maximum thumb's and maximum field's name ("Maximum price"). */
|
|
117
|
+
maxLabel?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Formats every number the control speaks or prints: both `aria-valuetext`s and both fields'
|
|
120
|
+
* resting text. A store passes its currency formatter, so a thumb announces "$1,200" rather
|
|
121
|
+
* than "1200". Unset, the numbers are formatted for the ambient locale with as many fraction
|
|
122
|
+
* digits as `step` has.
|
|
123
|
+
*
|
|
124
|
+
* **`end` is given only for a thumb's own text**, as `0` (the minimum) or `1` (the maximum), so
|
|
125
|
+
* a formatter can say something about one end that is only true of that end — a price filter's
|
|
126
|
+
* maximum thumb sitting at `max` announces "$240 or more", because above the catalogue's highest
|
|
127
|
+
* price there is nothing to exclude. It is deliberately **not** passed for the typed fields: a
|
|
128
|
+
* field holds a number the shopper edits, and "$240 or more" is not one. A one-argument
|
|
129
|
+
* formatter is unaffected either way, which is what keeps this additive.
|
|
130
|
+
*/
|
|
131
|
+
formatValue?: (value: number, end?: RangeSliderEnd) => string;
|
|
132
|
+
/**
|
|
133
|
+
* Render the typed min / "to" / max row under the track. The fields are generic number fields;
|
|
134
|
+
* a consumer with its own (a currency field, say) replaces them through the `inputs` slot while
|
|
135
|
+
* this prop still decides whether the row exists at all — see `RangeSliderInputsSlotProps`.
|
|
136
|
+
*/
|
|
137
|
+
inputs?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Draw the rail, the track, the `track` slot and both thumbs. Default `true`. `false` is for a
|
|
140
|
+
* consumer whose span is better read than dragged — a catalogue whose prices sit in a few tight
|
|
141
|
+
* clusters a track cannot separate — and keeps only the `inputs` row: every clamping, snapping
|
|
142
|
+
* and commit rule is exactly the one the thumbs use, because it is the same `commit` function and
|
|
143
|
+
* the same model either way. Nothing is unmounted twice over: with `inputs` also `false` there is
|
|
144
|
+
* nothing left to render at all, which is this prop's business to allow, not to guard against.
|
|
145
|
+
*/
|
|
146
|
+
trackVisible?: boolean;
|
|
147
|
+
/** Per-part class overrides, merged with `tailwind-merge`. */
|
|
148
|
+
classes?: Partial<Record<RangeSliderPart, string>>;
|
|
149
|
+
/** Overrides for the strings this component renders itself (the thumb names, the word "to"). */
|
|
150
|
+
messages?: Partial<UiMessages>;
|
|
151
|
+
}
|