@eldrajs/ui 0.3.6 → 0.3.8
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 +10 -0
- package/LICENSE-country-flag-icons +25 -0
- package/README.md +380 -79
- package/dist/PhoneInput-CYGpERg4.js +749 -0
- package/dist/{VariantPicker-BB-2Cj32.js → VariantPicker-D_Gg80So.js} +163 -2307
- package/dist/componentNames.d.ts +1 -1
- package/dist/components/badge/StockBadge.vue.d.ts +1 -1
- package/dist/components/chip/Chip.vue.d.ts +10 -0
- package/dist/components/dialog/Dialog.vue.d.ts +10 -0
- package/dist/components/drawer/Drawer.vue.d.ts +10 -0
- package/dist/components/filter-panel/FilterGroup.vue.d.ts +10 -0
- package/dist/components/filter-panel/FilterPanel.vue.d.ts +10 -0
- package/dist/components/filter-panel/facets/ColourFacet.vue.d.ts +10 -0
- package/dist/components/filter-panel/facets/ListFacet.vue.d.ts +10 -0
- package/dist/components/filter-panel/facets/RangeFacet.vue.d.ts +10 -0
- package/dist/components/filter-panel/facets/SizeFacet.vue.d.ts +10 -0
- package/dist/components/filter-panel/facets/ToggleFacet.vue.d.ts +10 -0
- package/dist/components/lightbox/Lightbox.vue.d.ts +10 -0
- package/dist/components/nav-menu/NavMenu.vue.d.ts +10 -0
- package/dist/components/notice/Notice.vue.d.ts +28 -0
- package/dist/components/notice/types.d.ts +38 -0
- package/dist/components/pagination/Pagination.vue.d.ts +10 -0
- package/dist/components/price/Price.vue.d.ts +1 -1
- package/dist/components/product-card/ProductCard.vue.d.ts +1 -1
- package/dist/components/radio/RadioGroup.vue.d.ts +4 -0
- package/dist/components/radio/recipes.d.ts +4 -2
- package/dist/components/radio/types.d.ts +8 -1
- package/dist/components/range-slider/RangeSlider.vue.d.ts +10 -0
- package/dist/components/search-bar/SearchBar.vue.d.ts +10 -0
- package/dist/components/search-modal/SearchModal.vue.d.ts +10 -0
- package/dist/components/select/MultiSelect.vue.d.ts +10 -0
- package/dist/components/select/Select.vue.d.ts +10 -0
- package/dist/components/site-form/SiteForm.vue.d.ts +10 -0
- package/dist/components/spinner/Spinner.vue.d.ts +4 -1
- package/dist/components/spinner/types.d.ts +9 -0
- package/dist/components/step-indicator/StepIndicator.vue.d.ts +7 -0
- package/dist/components/step-indicator/types.d.ts +30 -0
- package/dist/components/toast/Toast.vue.d.ts +10 -0
- package/dist/components/toast/Toaster.vue.d.ts +10 -0
- package/dist/components.css +153 -0
- package/dist/icons/paths.d.ts +8 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +621 -302
- package/dist/messages/en-US.d.ts +27 -0
- package/dist/messages/is-IS.js +11 -1
- package/dist/phone/PhoneFlag.vue.d.ts +6 -0
- package/dist/phone/PhoneInput.vue.d.ts +220 -0
- package/dist/phone/caret.d.ts +14 -0
- package/dist/phone/examples.d.ts +2 -0
- package/dist/phone/flags.d.ts +8 -0
- package/dist/phone/index.d.ts +13 -0
- package/dist/phone/phone.d.ts +62 -0
- package/dist/phone/phoneFlagData.d.ts +2 -0
- package/dist/phone/rule.d.ts +22 -0
- package/dist/phone/types.d.ts +63 -0
- package/dist/phone/vee-validate/FieldPhoneInput.vue.d.ts +24 -0
- package/dist/phone/vee-validate/index.d.ts +3 -0
- package/dist/phone/vee-validate/types.d.ts +3 -0
- package/dist/phone/vee-validate.js +96 -0
- package/dist/phone.js +1 -0
- package/dist/phoneFlagData-D9dDT2uC.js +261 -0
- package/dist/resolver.d.ts +9 -2
- package/dist/resolver.js +18 -4
- package/dist/style.css +153 -0
- package/dist/useFieldControl-D_b9SC9s.js +273 -0
- package/dist/{useMessages-B5nzZghs.js → useMessages-DQQPh1P_.js} +28 -1
- package/dist/usePopover-4CQR2hB5.js +2228 -0
- package/dist/utilities.css +37 -0
- package/dist/vee-validate/FieldCheckbox.vue.d.ts +5 -1
- package/dist/vee-validate/FieldCheckboxGroup.vue.d.ts +5 -1
- package/dist/vee-validate/FieldCurrencyInput.vue.d.ts +5 -1
- package/dist/vee-validate/FieldInput.vue.d.ts +5 -1
- package/dist/vee-validate/FieldMultiSelect.vue.d.ts +5 -1
- package/dist/vee-validate/FieldQuantityStepper.vue.d.ts +5 -1
- package/dist/vee-validate/FieldRadioGroup.vue.d.ts +5 -1
- package/dist/vee-validate/FieldSearchBar.vue.d.ts +5 -1
- package/dist/vee-validate/FieldSelect.vue.d.ts +5 -1
- package/dist/vee-validate/FieldSwitch.vue.d.ts +5 -1
- package/dist/vee-validate/FieldTextarea.vue.d.ts +5 -1
- package/dist/vee-validate/FieldUnitInput.vue.d.ts +5 -1
- package/dist/vee-validate/FieldVariantPicker.vue.d.ts +5 -1
- package/dist/vee-validate/context.d.ts +32 -7
- package/dist/vee-validate/index.d.ts +8 -5
- package/dist/vee-validate/types.d.ts +26 -0
- package/dist/vee-validate/useFieldControl.d.ts +59 -10
- package/dist/vee-validate.js +114 -197
- package/dist/vue-i18n.js +4 -1
- package/package.json +20 -3
package/README.md
CHANGED
|
@@ -24,6 +24,8 @@ Peer: **`vue ^3.5`**. The floor is 3.5, not 3.4: every control's ids come from `
|
|
|
24
24
|
added in 3.5, so on 3.4 the install succeeds and the first control to mount throws
|
|
25
25
|
`useId is not a function`. `vee-validate ^4.12` is an **optional** peer — only the `./vee-validate`
|
|
26
26
|
entry needs it, and nothing else in the package imports it.
|
|
27
|
+
`libphonenumber-js ^1.13` is an **optional** peer in the same way: only the [`./phone`](#phone)
|
|
28
|
+
entries need it.
|
|
27
29
|
|
|
28
30
|
## Styles
|
|
29
31
|
|
|
@@ -173,69 +175,73 @@ Every component supports all five of these; none hard-codes anything a store mig
|
|
|
173
175
|
token, a component-specific corner radius. Each one is documented on the component's own
|
|
174
176
|
Storybook docs page; the variables currently declared:
|
|
175
177
|
|
|
176
|
-
| Component
|
|
177
|
-
|
|
|
178
|
-
| `Accordion`
|
|
179
|
-
| `AccordionItem`
|
|
180
|
-
| `Avatar`
|
|
181
|
-
| `AvatarGroup`
|
|
182
|
-
| `Badge`
|
|
183
|
-
| `Breadcrumb`
|
|
184
|
-
| `Button`
|
|
185
|
-
| `ButtonGroup`
|
|
186
|
-
| `Carousel`
|
|
187
|
-
| `Checkbox`
|
|
188
|
-
| `CheckboxGroup`
|
|
189
|
-
| `Chip`
|
|
190
|
-
| `ChipGroup`
|
|
191
|
-
| `Container`
|
|
192
|
-
| `ContentCard`
|
|
193
|
-
| `CurrencyInput`
|
|
194
|
-
| `Dialog`
|
|
195
|
-
| `Drawer`
|
|
196
|
-
| `EditorPlaceholder`
|
|
197
|
-
| `EmptyState`
|
|
198
|
-
| `FeatureCard`
|
|
199
|
-
| `FieldWrapper`
|
|
200
|
-
| `FilterPanel`
|
|
201
|
-
| `FormLayout`
|
|
202
|
-
| `Icon`
|
|
203
|
-
| `Image`
|
|
204
|
-
| `Input`
|
|
205
|
-
| `Lightbox`
|
|
206
|
-
| `Link`
|
|
207
|
-
| `LoadMore`
|
|
208
|
-
| `LogoItem`
|
|
209
|
-
| `NavMenu`
|
|
210
|
-
| `
|
|
211
|
-
| `
|
|
212
|
-
| `
|
|
213
|
-
| `
|
|
214
|
-
| `
|
|
215
|
-
| `
|
|
216
|
-
| `
|
|
217
|
-
| `
|
|
218
|
-
| `
|
|
219
|
-
| `
|
|
220
|
-
| `
|
|
221
|
-
| `
|
|
222
|
-
| `
|
|
223
|
-
| `
|
|
224
|
-
| `
|
|
225
|
-
| `
|
|
226
|
-
| `
|
|
227
|
-
| `
|
|
228
|
-
| `
|
|
229
|
-
| `
|
|
230
|
-
| `
|
|
231
|
-
| `
|
|
232
|
-
| `
|
|
233
|
-
| `
|
|
234
|
-
| `
|
|
235
|
-
| `
|
|
236
|
-
| `
|
|
237
|
-
| `
|
|
238
|
-
| `
|
|
178
|
+
| Component | CSS variables |
|
|
179
|
+
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
180
|
+
| `Accordion` | none — the top divider is a stock `border-t`, no per-component variable |
|
|
181
|
+
| `AccordionItem` | `--eldra-accordion-title-line` (default `1.4`) — the label's line ratio, no token of its own |
|
|
182
|
+
| `Avatar` | `--eldra-avatar-initials-size-{sm,md,lg,xl}` (defaults `0.76rem`/`0.95rem`/`1.33rem`/`2.28rem`, "38% of diameter" — no token of its own), `--eldra-avatar-initials-tracking` (default `0.02em`), `--eldra-avatar-icon-size-{sm,md,lg,xl}` (defaults `0.857rem`/`1.071rem`/`1.5rem`/`2.571rem`, the spec's own lg number scaled proportionally to the other three diameters) |
|
|
183
|
+
| `AvatarGroup` | none — the overlap and stack order are plain Tailwind, no per-component variable |
|
|
184
|
+
| `Badge` | `--eldra-badge-line-height` (default `1`) — the badge text's line ratio, no token of its own |
|
|
185
|
+
| `Breadcrumb` | none — the collapse threshold reads `--container-tablet` (`Container`'s own 48rem gutter breakpoint), and the link/ellipsis boxes reuse `target-min`/`eldra-link-radius`/`radius-sm`, no per-component variable of its own |
|
|
186
|
+
| `Button` | `--eldra-button-radius` (default `var(--eldra-radius-md)`), `--eldra-button-border-width` (default `1px`; the height stays the same, and an attached `ButtonGroup` overlaps by this width), `--eldra-button-line-height` (default `1.2`), `--eldra-button-font-size-lg` (default `1.0625rem`, the one button size with no type token of its own) |
|
|
187
|
+
| `ButtonGroup` | none — reads only the shared tokens from layer 1 |
|
|
188
|
+
| `Carousel` | `--eldra-carousel-per-view-base`/`-md`/`-lg` (bound as an inline style on the track by `carouselPerViewStyle`, resolved into `--eldra-carousel-per-view` per container-query breakpoint by the `eldra-carousel-track` utility, no default of its own — a slide with none set stays full width) and `--eldra-carousel-gap` (default `var(--eldra-space-4)`), both read by the `eldra-carousel-slide` utility's width formula; `--eldra-carousel-dot-size` (default `0.5rem`) and `--eldra-carousel-dot-ring` (default `1.5px`), read by `eldra-carousel-dot`; `--eldra-carousel-bleed` (default `0px`) — the inline gutter the track bleeds out to, as its own padding, the negative margin that cancels that padding and its scroll padding at once, each `max()`-ed with the focus ring's reach so a bleed never costs the ring the room the track reserves for it (set it per breakpoint through `classes.track`, never a `px-*`/`-mx-*`/`scroll-px-*` utility of your own — those replace the reservation on that axis instead of composing with it) |
|
|
189
|
+
| `Checkbox` | `--eldra-checkbox-radius` (default `var(--eldra-radius-sm)`), `--eldra-checkbox-border-width` (default `1.5px`), `--eldra-checkbox-border-width-invalid` (default `2px`) |
|
|
190
|
+
| `CheckboxGroup` | none — reads only the shared tokens from layer 1 |
|
|
191
|
+
| `Chip` | none — the selected/hover fills are `color-mix()` over shared `--eldra-color-*` tokens, no per-component variable |
|
|
192
|
+
| `ChipGroup` | none — reads only the shared tokens from layer 1 |
|
|
193
|
+
| `Container` | none — the gutter widths (`--eldra-gutter-{mobile,tablet,desktop}`) are shared tokens, also read by `Section`; the three finite `width` values likewise read the shared `--eldra-container-{narrow,content,wide}` tokens directly, through `Container`'s own `eldra-container-{narrow,content,wide}` utilities rather than Tailwind's `max-w-narrow`/`-content`/`-wide` — see the Deviations entry below |
|
|
194
|
+
| `ContentCard` | `--eldra-content-card-title-size` (default `1.25rem`) and `--eldra-content-card-title-line` (default `1.3`) — the title's own size and line ratio, no token of its own; `--eldra-content-card-excerpt-size` (default `0.9375rem`) and `--eldra-content-card-excerpt-line` (default `1.5`) — the excerpt's own size and line ratio, shared by `FeatureCard`'s `body` (`text-content-card-excerpt` in `tailwind.css`), since both read the same spec number |
|
|
195
|
+
| `CurrencyInput` | `UnitInput`'s exactly (it renders a `UnitInput` with `isCurrency` always on) — see the `UnitInput` row |
|
|
196
|
+
| `Dialog` | `--eldra-dialog-title-size` (default `1.25rem`), `--eldra-dialog-title-line` (default `1.3`) — the title's own size/line, no token of its own; `--eldra-dialog-width` (default `32rem`), `--eldra-dialog-width-sm` (default `24rem`) — the panel's own width, always capped at the dialog's padded width (the viewport less `2rem`) inside the utility itself; `--eldra-dialog-max-height` (default `none`: a tall panel grows and the dialog scrolls like a page; set it to cap the panel and scroll the body inside it instead); the `eldra-dialog-fullscreen` utility pins the panel to the viewport edges with the body scrolling between header and footer, for a consumer to put under a viewport variant (`classes.panel: 'max-md:eldra-dialog-fullscreen'`); `--eldra-dialog-background` (default `var(--color-background)`), `--eldra-dialog-border` (default `var(--color-border)`), `--eldra-dialog-text` (default `var(--color-text)`, also the close button's hover and press tint), `--eldra-dialog-muted` (default `var(--color-muted)`, the description) and `--eldra-dialog-backdrop` (default `var(--color-overlay)`) — the chrome's own colours, read by the dialog's parts only, so setting them on the `<dialog>` (`class`) recolours it without re-theming the slotted content the way redefining `--eldra-color-*` there would |
|
|
197
|
+
| `Drawer` | `--eldra-drawer-title-size` (default `1.25rem`), `--eldra-drawer-title-line` (default `1.3`) — the title's own size/line, no token of its own (the same numbers as `Dialog`'s, but its own variable pair); `--eldra-drawer-width` (default `28rem`) — the panel's own maximum width, capped at the viewport inside the utility itself, which also carries the full-screen-below-a-48rem-_viewport_ media query; `--eldra-drawer-header-height` (default `4rem`) — the header row's least height, with `--eldra-drawer-header-padding` (default `var(--eldra-space-4)`) — its top and bottom padding, `0px` to centre the row's content in exactly that height, such as a site header's; `--eldra-drawer-gutter` (default `1.5rem`) — the header's, body's and footer's side padding. The device's safe areas (`env(safe-area-inset-*)`) are added around both, so a full-screen drawer clears a notch and the home indicator on a page with `viewport-fit=cover`; `--eldra-drawer-slide` (default `2rem`), `--eldra-drawer-enter-duration` (default `400ms`), `--eldra-drawer-exit-duration` (default `260ms`) — the panel's slide and fade in and out; `--eldra-drawer-swipe-threshold` (default `24px`) — how far a side swipe travels before the panel follows; with `mobileSheet`, `--eldra-drawer-sheet-gap` (default `3rem`), `--eldra-drawer-sheet-radius` (default `var(--eldra-radius-xl)`) and `--eldra-drawer-handle-color` (default `var(--eldra-color-border-strong)`) |
|
|
198
|
+
| `EditorPlaceholder` | `--eldra-editor-placeholder-border-width` (default `1.5px`) — the dashed boundary's width, distinct from `EmptyState`'s own stock `border` (1px) |
|
|
199
|
+
| `EmptyState` | `--eldra-empty-state-title-size` (default `1.25rem`) and `--eldra-empty-state-title-line` (default `1.3`) — the title's own size and line ratio, no token of its own |
|
|
200
|
+
| `FeatureCard` | Shares `ContentCard`'s `--eldra-content-card-excerpt-size`/`-line` for its own `body` text (`text-content-card-excerpt`); its `title` reads `text-h4` directly, no variable of its own |
|
|
201
|
+
| `FieldWrapper` | `--eldra-field-note-line-height` (default `1.45`) — the line the help and error text share |
|
|
202
|
+
| `FilterPanel` | `--eldra-filter-subheading-tracking` (default `0.06em`, a size-system sub-heading's letter spacing — the overline token's own 0.12em pushes "SOCKS (EU)" onto two lines in a 15rem sidebar), `--eldra-filter-swatch-edge-width` (default `1px`) and `--eldra-filter-swatch-ring-width` (default `1.5px`) for a colour swatch's edge and the ring it gains when picked, and `--eldra-filter-histogram-bar-min` / `--eldra-filter-histogram-bar-radius` (defaults `2px` / `1px`) for one histogram bar's minimum height and its two top corners. Everything else is a shared token or comes from the components it composes (`Checkbox`, `Switch`, `Chip`, `Badge`, `Input`, `Button`, `CurrencyInput`, `RangeSlider`), each restyled through its own row |
|
|
203
|
+
| `FormLayout` | `--eldra-form-summary-radius` (default `var(--eldra-radius-md)`) — the status summary box's corner radius |
|
|
204
|
+
| `Icon` | none — reads only the shared tokens from layer 1 |
|
|
205
|
+
| `Image` | `--eldra-image-hatch-gap` (default `0.75rem`) — the live "No image" placeholder's diagonal-line repeat distance |
|
|
206
|
+
| `Input` | `--eldra-input-radius` (default `var(--eldra-radius-md)`), `--eldra-control-font-size` (default `0.9375rem`), `--eldra-control-font-size-mobile` (default `1rem`), `--eldra-control-line-height` (default `1.5rem`), `--eldra-field-border-width` (default `1px`) |
|
|
207
|
+
| `Lightbox` | none of its own — the entrance keyframe (`eldra-lightbox-in`) and every size are either shared tokens or literal component-specific classes (`px-16`, `size-11`/`max-md:size-11`), the same "no dedicated variable" shape as `AvatarGroup`/`ButtonGroup` |
|
|
208
|
+
| `Link` | `--eldra-link-radius` (default `2px`) — the focus ring's corner radius on every variant |
|
|
209
|
+
| `LoadMore` | none — the status/meter/button sizes all reuse shared tokens (`text-body-sm`, `control-h`, `text-button-md`), no per-component variable |
|
|
210
|
+
| `LogoItem` | `--eldra-logo-image-max-height` (default `2.5rem`), `--eldra-logo-image-max-width` (default `9rem`) — the logo image's contain box; `--eldra-logo-wordmark-size` (default `1.25rem`) — the wordmark fallback's font size (its weight, line-height and letter-spacing reuse `h2`/`h3` tokens directly, see `text-logo-wordmark` in `tailwind.css`) |
|
|
211
|
+
| `NavMenu` | `--eldra-nav-menu-offset` (default `var(--eldra-space-2)`) — the gap between the bar and a panel, drawn as the panel's own top padding so a hovering pointer never leaves the menu; `--eldra-nav-menu-dropdown-min`/`-max` (defaults `14rem`/`24rem`, capped at `100vw - 2rem`) — a dropdown panel's width; `--eldra-nav-menu-column-min` (default `12rem`) — the narrowest a mega panel's column gets before the grid wraps (`classes.columns: 'grid-cols-5'` fixes the count instead). `--eldra-nav-menu-drawer-row-height` (default `3.5rem`) — every top-level row in the drawer, link, accordion row or section heading; `--eldra-nav-menu-drawer-indent` (default `var(--eldra-space-4)`) — how far a panel's links sit in from their row. The drawer itself and the badges are `Drawer` and `Badge`, each restyled through its own row |
|
|
212
|
+
| `Notice` | none — the three coloured tones tint their fill and border with `color-mix()` over the shared `--eldra-color-success`/`-warning`/`-danger` and `--eldra-color-background` tokens, no per-component variable |
|
|
213
|
+
| `MultiSelect` | everything `Select` reads, plus `--eldra-select-pill-line` (the "+N" pill's line box) and `--eldra-checkbox-radius`/`--eldra-checkbox-border-width`, shared with `Checkbox` so a consumer restyles both at once; the tags' own colours `--eldra-select-tag-background` (default `var(--color-surface-strong)`), `--eldra-select-tag-text` (default `var(--color-text)`, also the remove button's hover colour and tint) and `--eldra-select-tag-muted` (default `var(--color-muted)`, the remove button at rest) — read by the tag and remove-button parts only, so `Chip` and a `tag` slot's content keep the theme |
|
|
214
|
+
| `Pagination` | none — every size (the 2.5rem page link/`control-h` previous-next, the `target-touch` compact arrows, the 0.9375rem `text-control` compact status) reuses a shared token or a shared arbitrary spacing multiple, no per-component variable |
|
|
215
|
+
| `PhoneInput` (`@eldrajs/ui/phone`) | `--eldra-phone-flag-radius` (default `2px`), `--eldra-phone-flag-border` (the flag's hairline; default `var(--eldra-color-border)`), `--eldra-phone-flag-fill` (shown until the artwork has loaded; default `var(--eldra-color-surface-strong)`); the box is `Input`'s (`--eldra-input-radius`, `--eldra-field-border-width`, the `--eldra-control-*` type variables) and the country list is `Select`'s panel (every `--eldra-select-panel-*` variable) |
|
|
216
|
+
| `Popover` | `--eldra-z-popover` (default `30`), shared with the other popover panels; `--eldra-popover-background` (default `var(--color-background)`), `--eldra-popover-border` (default `var(--color-border)`) and `--eldra-popover-text` (no default: unset, the panel inherits its colour as before) — the panel chrome's own colours, read by the `panel` part only, so setting them recolours it without re-theming the slotted content the way redefining `--eldra-color-*` there would. No size variable: it has no fixed size to clamp, unlike `Select`'s panel |
|
|
217
|
+
| `Price` | `--eldra-price-current-sm-size` (default `0.9375rem`), `--eldra-price-current-lg-size` (default `1.5rem`) — only `sm`/`lg` need one: `md`'s current price inherits the surrounding text, and `compareAt`/`from`/`unit` scale off whichever size the root sets (`0.9em`, a literal ratio the spec itself gives, and a fixed `0.8125rem`), so neither needs a variable of its own |
|
|
218
|
+
| `ProductCard` | none of its own — it composes `Image`/`Badge`/`StockBadge`/`Price`/`Button`, each restyled through its own row above |
|
|
219
|
+
| `QuantityStepper` | `--eldra-stepper-radius` (default `var(--eldra-radius-md)`) |
|
|
220
|
+
| `Radio` | the radio circle reads `--eldra-checkbox-border-width`/`-invalid`, shared with `Checkbox` and `RadioGroup` |
|
|
221
|
+
| `RadioGroup` | `--eldra-radio-card-border-width` (default `1px`) and `--eldra-radio-card-radius` (default `radius-md`) for the card boundary; `--eldra-checkbox-border-width`/`-invalid` for the radio circle itself, shared with `Checkbox` |
|
|
222
|
+
| `RangeSlider` | `--eldra-range-thumb-size` (default `1.25rem`), `--eldra-range-thumb-border-width` (default `1.5px`), `--eldra-range-thumb-halo` (default `0.25rem`, the hover/dragging ring drawn outside the thumb) and `--eldra-range-track-height` (default `0.375rem`), read by the `eldra-range-thumb`/`-track`/`-gutter` utilities — the gutter that keeps a thumb, its focus ring **and** its pointer target inside the control is the larger of the ring's reach and half the target, `calc()`-ed from those variables (and switched on the same 48rem container edge the target is), so enlarging any of them moves the reservation with it |
|
|
223
|
+
| `Rating` | none — the half-star overlay (`eldra-rating-half`) is a fixed `clip-path`, no per-component variable |
|
|
224
|
+
| `SearchBar` | `--eldra-search-panel-max-height` (default `32rem`, clamped to `70vh`), `--eldra-search-text-line`, `--eldra-search-empty-line`, `--eldra-search-kbd-line`, `--eldra-input-radius`, `--eldra-field-border-width`, `--eldra-z-popover`, and `--eldra-popover-origin` (set by the panel itself from the placement it resolved to: `top left` below the field, `bottom left` above it); and `Select`'s `--eldra-select-panel-background`/`-border`/`-text`/`-muted`/`-active` (same defaults) for the results panel's surface, edge and hairlines, rows and chips, headings, minor rows, icons and no-results advice, and the active row and chip fill |
|
|
225
|
+
| `SearchModal` | `--eldra-search-modal-width` (default `40rem`), `--eldra-search-modal-max-height` (default `40rem`) — both clamped to the viewport inside their own utility, which also carries the full-screen-below-a-48rem-_viewport_ media query; `--eldra-search-modal-field-size` (default `1.0625rem`), `--eldra-search-modal-foot-size`/`-line` (defaults `0.75rem`/`1.4`), `--eldra-search-modal-kbd-size` (default `0.6875rem`) — none with a token of their own; plus everything `SearchBar`'s reused `SearchResultsPanel` reads (`--eldra-search-text-line`, `--eldra-search-empty-line`, `--eldra-control-line-height`) |
|
|
226
|
+
| `Section` | none — the vertical rhythm (`--eldra-section-{sm,md,lg}`) and the gutters it shares with `Container` are shared tokens |
|
|
227
|
+
| `Select` | `--eldra-select-panel-max-height` (default `20rem`), `--eldra-select-panel-max-width` (default `22rem`, clamped to `90vw`), `--eldra-z-popover` (default `30`), `--eldra-field-radius`, `--eldra-field-border-width`, `--eldra-select-group-tracking`, `--eldra-select-option-line`, `--eldra-select-swatch-edge`, the `--eldra-select-match-*` trio, and `--eldra-popover-origin` (`top left` / `bottom left`, set by the panel from the placement it resolved to); and the panel chrome's own colours, the `--eldra-select-panel-*` family `MultiSelect` and `SearchBar` read too: `--eldra-select-panel-background` (default `var(--color-background)`; the panel, `MultiSelect`'s footer and an unchosen option box), `--eldra-select-panel-border` (default `var(--color-border)`; the panel's edge, the search field's divider, group and create-row hairlines, the footer's top line), `--eldra-select-panel-text` (default `var(--color-text)` on the search field, the option and create rows; unset, the panel itself inherits its colour as before), `--eldra-select-panel-muted` (default `var(--color-muted)`; the search icon and placeholder, group headings, disabled rows, hints, untoned meta, the empty and loading rows, the footer count), `--eldra-select-panel-active` (default `var(--color-surface-strong)`; the active row's fill), `--eldra-select-panel-check` (the selected mark: default `var(--color-text)` for `Select`'s check, `var(--color-primary)` for `MultiSelect`'s filled box), `--eldra-select-panel-check-contrast` (default `var(--color-primary-contrast)`, `MultiSelect`'s tick) and `--eldra-select-panel-check-border` (default `var(--color-border-strong)`, an unchosen box's edge) — read by the panel's parts only, so setting them on `:root` or the teleport target recolours the panel without re-theming slotted option content the way redefining `--eldra-color-*` there would |
|
|
228
|
+
| `SiteForm` | none of its own: it composes `FormLayout`, `FieldWrapper`, `Input`, `Textarea`, `Select`, `Checkbox` and `Button`, each restyled through its own row; its `classes` reach their parts (see [Site forms](#site-forms)) |
|
|
229
|
+
| `Skeleton` | `--eldra-skeleton-line-height` (default `0.875rem`) and `--eldra-skeleton-line-gap` (default `0.3rem`, above and below) for `text` rows, `--eldra-skeleton-title-height` (default `1.5rem`), `--eldra-skeleton-box-height` (default `1rem`, an unsized `box`), `--eldra-skeleton-color` (default `surface-strong`, the shape's fill), `--eldra-skeleton-highlight` (default `background` at 60%, the glare) and `--eldra-skeleton-duration` (default `3s`, one sweep and its rest; the sweep is its first 60%); `width` still sets an inline style (see the Deviations entry) |
|
|
230
|
+
| `Spinner` | none — it is drawn in `currentColor` and sized by a class on the component (1.125rem without one) |
|
|
231
|
+
| `StepIndicator` | none — reads only the shared tokens from layer 1 |
|
|
232
|
+
| `StockBadge` | `--eldra-stock-status-line` (default `1.4`) — the status line text's line ratio, no token of its own |
|
|
233
|
+
| `Switch` | `--eldra-switch-radius` (default `var(--eldra-radius-full)`), `--eldra-switch-track-border-width` (default `1.5px`), `--eldra-switch-thumb-offset` (default `0.1875rem`, the thumb's rest inset from the track's start edge) |
|
|
234
|
+
| `Tab` | none — reads only the shared tokens from layer 1, plus `VariantPicker`'s `text-variant-pill` type style (no per-component variable of its own; see that component's row) |
|
|
235
|
+
| `TabPanel` | none — reads only the shared tokens from layer 1 |
|
|
236
|
+
| `TablerIcon` | none — reads only the shared tokens from layer 1, the same as `Icon` |
|
|
237
|
+
| `Tabs` | none — reads only the shared tokens from layer 1; the `eldra-scrollbar-hide` utility the tab list uses has no variable of its own. The pills list's own padding, the negative margin that cancels it and its scroll padding are all `calc(var(--eldra-focus-offset) + var(--eldra-focus-width))` — the focus ring's own reach, so raising either ring token widens the room the scrolling list keeps for a focused pill's ring instead of letting it clip (the underline variant reserves nothing: its tabs ring _inside_ their own box, per the design spec, and padding that list vertically would push its hairline off the tabs). Set a gutter through `classes.list` only if it is wider than that reach — a `px-*`/`-mx-*`/`scroll-px-*` utility of your own replaces the reservation on that axis rather than composing with it, the way `--eldra-carousel-bleed` does for the carousel |
|
|
238
|
+
| `Textarea` | `--eldra-textarea-radius` (default `var(--eldra-radius-md)`), `--eldra-textarea-min-height` (set from the `minHeight` prop, default `5rem`), `--eldra-counter-line-height` (default `1.5`) |
|
|
239
|
+
| `Toast` | `--eldra-toast-title-size` (default `0.9375rem`), `--eldra-toast-title-line` (default `1.4`) — the title's own size/line, sitting between two type-scale steps with no token of its own |
|
|
240
|
+
| `Toaster` | `--eldra-toast-width` (default `24rem`) — the fixed region's own width, always capped at `100vw - 2rem` inside the utility itself, the same shape as `Dialog`'s own width variables |
|
|
241
|
+
| `Tooltip` | `--eldra-tooltip-arrow-size` (default `0.3125rem`) — the arrow's side length, no token of its own; `--eldra-z-popover` (default `30`), shared with the popover panels |
|
|
242
|
+
| `UnitInput` | `Input`'s exactly, because it draws `Input`'s box: `--eldra-input-radius`, `--eldra-control-font-size`, `--eldra-control-font-size-mobile`, `--eldra-control-line-height`, `--eldra-field-border-width` (`CurrencyInput` is a `UnitInput`, so the same) |
|
|
243
|
+
| `VariantPicker` | `--eldra-variant-legend-line` (default `1.4`), `--eldra-variant-pill-border-width` (default `1px`), `--eldra-variant-pill-selected-color` (default `var(--eldra-color-text)`), `--eldra-variant-pill-radius` (default `var(--eldra-radius-md)`), `--eldra-variant-swatch-ring-width` (default `2px`), `--eldra-variant-swatch-edge-width` (default `1px`) |
|
|
244
|
+
| `VisuallyHidden` | none — reads only the shared tokens from layer 1 (it renders no visible box at all) |
|
|
239
245
|
|
|
240
246
|
Every component this package ships has a row above; `src/__tests__/readmeCoverage.spec.ts`
|
|
241
247
|
fails the build if `src/componentNames.ts` gains a name this table has not. "None" means the
|
|
@@ -1060,6 +1066,10 @@ EldraUiResolver({ prefix: 'Acme' }); // <AcmeButton> instead
|
|
|
1060
1066
|
Eldra library and its own resolver. Pass `{ prefix: 'Ui' }` yourself if a consumer genuinely wants
|
|
1061
1067
|
that name — the package itself never implies it.
|
|
1062
1068
|
|
|
1069
|
+
`<EldraPhoneInput>` resolves too, from `@eldrajs/ui/phone` instead of the root (the list is
|
|
1070
|
+
`phoneComponentNames`, exported beside `componentNames`). That entry needs the optional
|
|
1071
|
+
`libphonenumber-js` peer, so the tag only works in an app that has installed it.
|
|
1072
|
+
|
|
1063
1073
|
## `./vee-validate`
|
|
1064
1074
|
|
|
1065
1075
|
Everything above is validation-agnostic: `FieldWrapper` takes an `error` string, `Input` takes
|
|
@@ -1109,11 +1119,66 @@ Vue refuses a `v-slot` on a component that also has named slot templates as chil
|
|
|
1109
1119
|
go in an explicit `<template #default="{ errors }">` whenever there is an actions row — which there
|
|
1110
1120
|
almost always is.
|
|
1111
1121
|
|
|
1112
|
-
`errors` is keyed by each field's `name`, and holds only the messages
|
|
1113
|
-
**
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
`isSubmitting` and `submitCount`.
|
|
1122
|
+
`errors` is keyed by each field's `name`, and holds only the messages the fields are currently
|
|
1123
|
+
**showing**: each `Field*` reports the message it shows, and `errors` (and the error summary) is
|
|
1124
|
+
that report. So the wrapper, the control's own `aria-invalid` and the summary cannot disagree about
|
|
1125
|
+
whether a field is in error, and they change at the same moment. The other default-slot props are
|
|
1126
|
+
`values`, `meta`, `isSubmitting` and `submitCount`.
|
|
1127
|
+
|
|
1128
|
+
### When a field validates
|
|
1129
|
+
|
|
1130
|
+
Three boolean props on every `Field*` decide it, field by field:
|
|
1131
|
+
|
|
1132
|
+
| Prop | Default | What it does |
|
|
1133
|
+
| ----------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1134
|
+
| `validateOnBlur` | `true` | Validates the field when it loses focus and shows or clears its message then. `false`: a blur only marks the field touched. |
|
|
1135
|
+
| `validateOnValueUpdate` | `false` typed, `true` choice (below) | Validates on every change of the value; the message follows each change once the field has been touched or the form submitted. |
|
|
1136
|
+
| `validateOnMount` | `false` | Validates as soon as the field mounts **and shows the message at once**, without waiting for a blur or a submit (an edit form over stored data). |
|
|
1137
|
+
|
|
1138
|
+
Submitting the form always validates every field and shows every result, whatever the props say.
|
|
1139
|
+
|
|
1140
|
+
`validateOnValueUpdate` has two defaults, by the kind of control:
|
|
1141
|
+
|
|
1142
|
+
| Kind | Components | `validateOnValueUpdate` | Why |
|
|
1143
|
+
| ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1144
|
+
| Typed | `FieldInput`, `FieldTextarea`, `FieldCurrencyInput`, `FieldUnitInput`, `FieldSearchBar` | `false` | The value is built up one keystroke at a time, so validating each change would judge a half-typed value. |
|
|
1145
|
+
| Choice | `FieldCheckbox`, `FieldCheckboxGroup`, `FieldRadioGroup`, `FieldSwitch`, `FieldSelect`, `FieldMultiSelect`, `FieldVariantPicker`, `FieldQuantityStepper` | `true` | One click or selection is the whole value, often with no blur after it: a box that only validated on blur would go on saying "required" after it had been ticked. |
|
|
1146
|
+
|
|
1147
|
+
`FieldQuantityStepper` is a choice although it has a text field: a `QuantityStepper` writes its
|
|
1148
|
+
value only when a typed number is committed (on blur or `Enter`) or a button is pressed, never per
|
|
1149
|
+
keystroke, so every change it reports is a complete quantity.
|
|
1150
|
+
|
|
1151
|
+
So in a typed field, **typing never changes what the customer sees**: no message appears while a
|
|
1152
|
+
value is being typed, and a message already showing stays until the field is left or the form is
|
|
1153
|
+
submitted. A choice field answers the click: once it has been touched or the form submitted, its
|
|
1154
|
+
message appears or goes with each change. Every default can be overridden per field:
|
|
1155
|
+
|
|
1156
|
+
```vue
|
|
1157
|
+
<!-- Typed default: on blur, and on submit. -->
|
|
1158
|
+
<FieldInput name="email" type="email" />
|
|
1159
|
+
|
|
1160
|
+
<!-- Live: as the default, plus every change once the field is touched or the form submitted. -->
|
|
1161
|
+
<FieldInput name="email" type="email" validate-on-value-update />
|
|
1162
|
+
|
|
1163
|
+
<!-- Submit only: nothing until the form is submitted, and nothing again until the next submit. -->
|
|
1164
|
+
<FieldInput name="email" type="email" :validate-on-blur="false" />
|
|
1165
|
+
|
|
1166
|
+
<!-- Choice default: live. Turn it off to make a checkbox wait for a blur or a submit. -->
|
|
1167
|
+
<FieldCheckbox name="terms" :validate-on-value-update="false">I agree</FieldCheckbox>
|
|
1168
|
+
```
|
|
1169
|
+
|
|
1170
|
+
The same holds with `rules` on the field and with a `validationSchema` on the `Form`. A field
|
|
1171
|
+
holds the message it shows and changes it only at its own moments, because vee-validate's own
|
|
1172
|
+
error state can move at others: with a form-level schema, validating one field revalidates every
|
|
1173
|
+
field that has been validated before, so another field's blur would otherwise clear or change the
|
|
1174
|
+
message under a field that is still being typed in. A server error (`apiErrors`) is the exception
|
|
1175
|
+
in both directions: it shows at once, and goes the moment its own field is edited.
|
|
1176
|
+
|
|
1177
|
+
`validateOnValueUpdate` is vee-validate's own `useField` option and is read once, when the field is
|
|
1178
|
+
set up; the other two are read each time. There is no form-level switch: set the props per field.
|
|
1179
|
+
`FIELD_VALIDATION_DEFAULTS` (typed), `FIELD_CHOICE_VALIDATION_DEFAULTS` (choice) and
|
|
1180
|
+
`FIELD_VALIDATION_PROPS` are exported beside `FIELD_ONLY` for a wrapper of your own built on
|
|
1181
|
+
`useFieldControl`.
|
|
1117
1182
|
|
|
1118
1183
|
Three of the controls own an `error` prop of their own — `FieldRadioGroup`, `FieldCheckboxGroup`
|
|
1119
1184
|
and `FieldQuantityStepper` — and those draw their message themselves **only outside** a
|
|
@@ -1207,6 +1272,158 @@ status region are the ones documented above. It adds:
|
|
|
1207
1272
|
never visible: replacing the form with a confirmation, or navigating, stays the page's job (spec
|
|
1208
1273
|
"Form layout" → States, Success). An explicit `statusMessage` wins over it.
|
|
1209
1274
|
|
|
1275
|
+
<a id="phone"></a>
|
|
1276
|
+
|
|
1277
|
+
## `./phone`
|
|
1278
|
+
|
|
1279
|
+
`@eldrajs/ui/phone` is a phone number field with its country inside it. It is an entry of its own
|
|
1280
|
+
because it is the only part of the package that needs
|
|
1281
|
+
[`libphonenumber-js`](https://gitlab.com/catamphetamine/libphonenumber-js): an app that never
|
|
1282
|
+
imports this entry never installs or bundles it (a test proves it, in the source graph and in
|
|
1283
|
+
`dist/`).
|
|
1284
|
+
|
|
1285
|
+
```bash
|
|
1286
|
+
pnpm add libphonenumber-js # optional peer, ^1.13
|
|
1287
|
+
```
|
|
1288
|
+
|
|
1289
|
+
```vue
|
|
1290
|
+
<script setup lang="ts">
|
|
1291
|
+
import { FieldWrapper } from '@eldrajs/ui';
|
|
1292
|
+
import { PhoneInput } from '@eldrajs/ui/phone';
|
|
1293
|
+
import { ref } from 'vue';
|
|
1294
|
+
|
|
1295
|
+
const phone = ref(''); // '+3545812345'
|
|
1296
|
+
</script>
|
|
1297
|
+
|
|
1298
|
+
<template>
|
|
1299
|
+
<FieldWrapper label="Phone number">
|
|
1300
|
+
<PhoneInput v-model="phone" default-country="IS" :preferred-countries="['IS']" />
|
|
1301
|
+
</FieldWrapper>
|
|
1302
|
+
</template>
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
**Anatomy.** One field box holding a country button (flag, dialling code, chevron) and the number
|
|
1306
|
+
`<input type="tel">`. The button opens the country list under the whole field, as wide as it: a
|
|
1307
|
+
search field, then the countries, each with its flag, name and dialling code. Parts (`data-part`,
|
|
1308
|
+
each a `classes` key except `root`): `root`, `field`, `countryButton`, `flag`, `callingCode`,
|
|
1309
|
+
`chevron`, `control`, and the list's `panel`, `search`, `listbox`, `group`, `groupLabel`, `option`,
|
|
1310
|
+
`optionLabel`, `optionMeta`, `optionCheck`, `empty`. The list is the panel `Select` opens, built
|
|
1311
|
+
from the same parts, so it is styled by the same variables.
|
|
1312
|
+
|
|
1313
|
+
**Properties**
|
|
1314
|
+
|
|
1315
|
+
| Prop | Type | Default | |
|
|
1316
|
+
| ------------------------------------------ | ---------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1317
|
+
| `modelValue` | `string` | `''` | The whole number in E.164 (`+3545812345`). `''` while the field holds no digit; the dialling code and the digits so far while the number is incomplete, so a rule can judge it at any moment |
|
|
1318
|
+
| `country` | `string` | | The chosen country, ISO 3166-1 alpha-2. `v-model:country` follows it |
|
|
1319
|
+
| `defaultCountry` | `string` | see right | Where the field starts when `country` is not bound and the value does not say: the shop's own country. Without it, the first of `preferredCountries`, then of `countries`, then `US` |
|
|
1320
|
+
| `preferredCountries` | `string[]` | | Listed first, under "Suggested", in this order |
|
|
1321
|
+
| `countries` | `string[]` | every country | The only countries offered, and the only ones a typed `+` may switch to |
|
|
1322
|
+
| `locale` | `string` | `provideEldraUiLocale`'s | The locale countries are named and sorted in |
|
|
1323
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | `Input`'s heights |
|
|
1324
|
+
| `name` | `string` | | Posts the E.164 value under this name, through a hidden input |
|
|
1325
|
+
| `placeholder` | `string \| false` | an example number | A number the chosen country could have; `false` for none |
|
|
1326
|
+
| `autocomplete` | `string` | `'tel-national'` | |
|
|
1327
|
+
| `id`, `invalid`, `describedBy`, `required` | | the `FieldWrapper`'s | As on `Input` |
|
|
1328
|
+
| `readonly` | `boolean` | `false` | The number can be read and copied; the list does not open and the chevron is not drawn |
|
|
1329
|
+
| `disabled` | `boolean` | `false` | |
|
|
1330
|
+
| `messages`, `classes` | | | As on every component |
|
|
1331
|
+
|
|
1332
|
+
**Events**: `update:modelValue`, `update:country`, `change` (after every edit and every change of
|
|
1333
|
+
country: `{ e164, country, callingCode, nationalNumber, valid }`), `focus`, `blur`, `open`, `close`.
|
|
1334
|
+
**Slots**: `flag` (`{ country }`), drawn in the button and on every row in place of the built-in
|
|
1335
|
+
artwork. **Exposed**: `control` (the number `<input>`), `focus()`, `country`.
|
|
1336
|
+
|
|
1337
|
+
**Behaviour**
|
|
1338
|
+
|
|
1339
|
+
- The field shows the national number only, spaced the way the chosen country writes it, re-spaced
|
|
1340
|
+
on every keystroke. The caret stays with what was typed: it is put back after the same number of
|
|
1341
|
+
digits, so typing or deleting in the middle of a number does not send it to the end.
|
|
1342
|
+
- Typing or pasting a number that starts with `+` picks the country by itself. As soon as the
|
|
1343
|
+
dialling code is complete, the `+` and the code leave the text and the button shows them.
|
|
1344
|
+
- A dialling code several countries share (`+1` is 25 countries, `+44` four) keeps the current
|
|
1345
|
+
country when it is one of them and otherwise takes the country the code belongs to; once the
|
|
1346
|
+
digits say which country the number is in, the country follows them.
|
|
1347
|
+
- Choosing a country from the list keeps the digits, re-spaces them and moves focus to the number.
|
|
1348
|
+
- The list is `preferredCountries` first, then every other country from A to Z in the locale's own
|
|
1349
|
+
order, each listed once. Search finds a country by name (case and accents ignored), by dialling
|
|
1350
|
+
code with or without the `+`, or by ISO code; with no match it says so in text.
|
|
1351
|
+
- Spacing is the phone library's. Some countries are only spaced when the number is typed with its
|
|
1352
|
+
national prefix: a British `7400123456` stays unspaced, `07400 123456` is spaced. Both are the
|
|
1353
|
+
same E.164 value. A value bound from outside is shown in full national form.
|
|
1354
|
+
- Country names come from `Intl.DisplayNames` through `@eldrajs/sdk/format/display-names`, so
|
|
1355
|
+
Icelandic names are right on runtimes that ship without Icelandic.
|
|
1356
|
+
|
|
1357
|
+
**States**: empty (an example number as placeholder), focused, filled, invalid, read-only,
|
|
1358
|
+
disabled, list open. One focus ring, around the whole box: while the number or the button has
|
|
1359
|
+
keyboard focus, and while the list is open.
|
|
1360
|
+
|
|
1361
|
+
**Keyboard**
|
|
1362
|
+
|
|
1363
|
+
| Key | On | Does |
|
|
1364
|
+
| ---------------------------------------- | ---------------- | ------------------------------------------------------------------------ |
|
|
1365
|
+
| `Tab` | | The country button, then the number |
|
|
1366
|
+
| `Enter`, `Space`, `ArrowDown`, `ArrowUp` | the button | Opens the list; focus moves to its search field |
|
|
1367
|
+
| a letter or digit | the button | Opens the list with that character as the search |
|
|
1368
|
+
| `ArrowDown` / `ArrowUp` | the search field | Moves through the countries (`PageUp`/`PageDown` by ten) |
|
|
1369
|
+
| `Enter` | the search field | Chooses the active country; focus moves to the number |
|
|
1370
|
+
| `Escape` | the search field | Clears the search; pressed again, closes and returns focus to the button |
|
|
1371
|
+
| `Tab` | the search field | Closes the list |
|
|
1372
|
+
|
|
1373
|
+
**Accessibility.** The number is a native `<input type="tel">`, named by the `FieldWrapper`'s
|
|
1374
|
+
`<label for>` (or an `aria-label` of your own). The country button is a `combobox` with
|
|
1375
|
+
`aria-haspopup="listbox"`, named "Country: Iceland, +354" (`phoneCountry`); the list is a `listbox`
|
|
1376
|
+
named "Country" (`phoneCountryList`), its rows `option`s with `aria-selected`, the search field a
|
|
1377
|
+
`combobox` that owns `aria-activedescendant`. Flags are decorative (`aria-hidden`): the name and
|
|
1378
|
+
the code are always in text, so the country is never told by a flag alone.
|
|
1379
|
+
|
|
1380
|
+
**Flags.** The artwork is [country-flag-icons](https://gitlab.com/catamphetamine/country-flag-icons)
|
|
1381
|
+
(MIT; `LICENSE-country-flag-icons` ships in the package), copied into the package by
|
|
1382
|
+
`pnpm --filter @eldrajs/ui build-phone-flags`. It is one lazy chunk (about 46 kB gzipped), fetched
|
|
1383
|
+
when the first `PhoneInput` mounts in a browser; until then a flag is an empty box of the same
|
|
1384
|
+
size, so nothing moves. `preloadPhoneFlags()` fetches it sooner.
|
|
1385
|
+
|
|
1386
|
+
**Helpers**, from the same entry: `isValidPhone(value, country?)`, `parsePhone(value, country?)`
|
|
1387
|
+
(`{ e164, country, callingCode, nationalNumber, national, valid } | null`), `phoneCountries()`,
|
|
1388
|
+
`phoneCallingCode(country)`, `phoneCountryName(country, locale)`, `phoneExample(country)` and
|
|
1389
|
+
`phoneRule(options)`. Validity is the phone library's `min` metadata: landlines and mobiles both
|
|
1390
|
+
pass, and a number is refused when its length or its prefix is not one the country uses.
|
|
1391
|
+
|
|
1392
|
+
### With vee-validate
|
|
1393
|
+
|
|
1394
|
+
`@eldrajs/ui/phone/vee-validate` exports `FieldPhoneInput` and `phoneRule`. It is not part of
|
|
1395
|
+
`@eldrajs/ui/vee-validate`, which must load in an app that has not installed `libphonenumber-js`.
|
|
1396
|
+
|
|
1397
|
+
```vue
|
|
1398
|
+
<Form aria-label="Contact details" @submit="save">
|
|
1399
|
+
<template #default="{ errors }">
|
|
1400
|
+
<FieldWrapper label="Phone number" :error="errors.phone">
|
|
1401
|
+
<FieldPhoneInput name="phone" default-country="IS" />
|
|
1402
|
+
</FieldWrapper>
|
|
1403
|
+
</template>
|
|
1404
|
+
</Form>
|
|
1405
|
+
```
|
|
1406
|
+
|
|
1407
|
+
`FieldPhoneInput` takes every `PhoneInput` prop and the `Field*` binding props (`name`, `path`,
|
|
1408
|
+
`rules`, `label`, and the three [validation props](#when-a-field-validates) with the typed-control
|
|
1409
|
+
defaults: it validates when the field is left and on submit, not while a number is typed). With no
|
|
1410
|
+
`rules` it checks the number against the country the field is on and shows "Enter a valid phone
|
|
1411
|
+
number for Iceland." (`phoneInvalid`, the country named in the field's locale). An empty field
|
|
1412
|
+
passes; add a required rule where the number is required. `rules` replaces the built-in check, so
|
|
1413
|
+
combine the two yourself:
|
|
1414
|
+
|
|
1415
|
+
```ts
|
|
1416
|
+
import { phoneRule } from '@eldrajs/ui/phone/vee-validate';
|
|
1417
|
+
|
|
1418
|
+
const valid = phoneRule({ country: () => country.value, locale: 'is-IS', messages: isIS });
|
|
1419
|
+
const rules = (value: unknown) => (value ? valid(value) : 'Enter your phone number.');
|
|
1420
|
+
```
|
|
1421
|
+
|
|
1422
|
+
`phoneRule` imports nothing from vee-validate: it returns `true` or the message, so it serves a
|
|
1423
|
+
form `validationSchema`, zod's `refine`, or a check of your own. Its messages (`phoneInvalid`,
|
|
1424
|
+
`phoneInvalidNumber`) are part of the message set, so they translate through
|
|
1425
|
+
[`./vue-i18n`](#with-vue-i18n) like every other one.
|
|
1426
|
+
|
|
1210
1427
|
## Accessibility and testing
|
|
1211
1428
|
|
|
1212
1429
|
Every component in this package ships, as part of being done, not as an add-on:
|
|
@@ -1257,6 +1474,11 @@ during development, outside this repository's own history.
|
|
|
1257
1474
|
Things this package ships that design spec 1 does not name at all. Each is listed here so a reader
|
|
1258
1475
|
comparing the package against the spec can tell an addition from a drift.
|
|
1259
1476
|
|
|
1477
|
+
- **`PhoneInput`** (`@eldrajs/ui/phone`, WS-1006): a phone number field with a country picker, as-you-type
|
|
1478
|
+
spacing and per-country validation. The spec has no phone field; its anatomy, properties, states,
|
|
1479
|
+
keyboard and accessibility are written up under [`./phone`](#phone) above. Two utilities came
|
|
1480
|
+
with it: `eldra-focus-has-open` (the focus ring while a popup opened from inside the element is
|
|
1481
|
+
open) and `eldra-phone-flag`.
|
|
1260
1482
|
- **Wrapper hooks** (operator decision, 2026-11-08): options that let the private component library
|
|
1261
1483
|
render these components as designed instead of keeping copies of them. Each is opt-in, and output
|
|
1262
1484
|
is unchanged without it; see the changelog for the details. `Input`/`Textarea`: exposed `control`
|
|
@@ -1273,6 +1495,79 @@ comparing the package against the spec can tell an addition from a drift.
|
|
|
1273
1495
|
`tagPlacement: 'inside'` with `maxTagRows`, and `maxSummary: 'fit'`. `Tab`: `disabled`.
|
|
1274
1496
|
`Switch`: `thumb`/`trackStart`/`trackEnd` slots, `invalid`. `Checkbox`: box alone without a
|
|
1275
1497
|
label. `Button`: pressed fill on `ghost`, a static string `as` tag, `keepNameWhileLoading`.
|
|
1498
|
+
- **`Notice`, `StepIndicator` and an exported `Spinner`** (operator decision, 2026-11-15, for
|
|
1499
|
+
Eldra's hosted checkout; none is in spec 1, and none holds checkout wording or data). Each is
|
|
1500
|
+
written up here in the spec's own section shape, since the spec has no section to point at.
|
|
1501
|
+
|
|
1502
|
+
**`Notice`** — a message that stays in the page flow: guidance beside a form, or the outcome of
|
|
1503
|
+
something the visitor did. Not a `Toast` (which floats, times out and lives in a `Toaster`'s live
|
|
1504
|
+
region), not an `EmptyState` (a whole region with nothing to show), not a field error
|
|
1505
|
+
(`FieldWrapper`). No close button and no focus movement.
|
|
1506
|
+
|
|
1507
|
+
- _Anatomy_: `root` · `icon` (optional, first in the row) · `content` holding `title` (optional),
|
|
1508
|
+
`text` (the body) and `actions` (optional row of buttons or links).
|
|
1509
|
+
- _Properties_: `tone` (`info` default, `success`, `warning`, `danger`; also `data-tone` on the
|
|
1510
|
+
root), `title`, `text`, `icon` (a component replaces the tone's default, `null` removes it),
|
|
1511
|
+
`headingLevel` (2–6: the title becomes a heading; otherwise a `<p>`), `announce` (default
|
|
1512
|
+
`true`), `classes`. Slots: `default` (body, over `text`), `title`, `actions`.
|
|
1513
|
+
- _Sizes_: padding 0.75rem block / 1rem inline, 0.75rem gap, `radius-md`, 1px border, no shadow;
|
|
1514
|
+
icon 1.25rem at stroke 1.75, nudged 0.125rem down; title and body 0.875rem (`text-body-sm`), the
|
|
1515
|
+
title weight 600; actions 0.5rem below the body, 0.75rem apart.
|
|
1516
|
+
- _States_: `info` is `surface` with a `border` hairline and a `text` icon. The other three fill
|
|
1517
|
+
with their colour role mixed 92% toward `background`, border the same role mixed 60% toward
|
|
1518
|
+
`background`, icon in the full role colour; title and body are `text` on every tone. Default
|
|
1519
|
+
icons: `info-circle`, `circle-check`, `alert-triangle`, `alert-circle` (`Toast`'s own four), so
|
|
1520
|
+
colour is never the only signal (1.4.1).
|
|
1521
|
+
- _Keyboard_: none of its own. `Tab` reaches whatever the `actions` slot or the body holds, in
|
|
1522
|
+
document order.
|
|
1523
|
+
- _Accessibility_: `info`, `success` and `warning` are `role="status"` (polite); `danger` is
|
|
1524
|
+
`role="alert"` (assertive) — the same split `Toast` makes. `announce: false` drops the role,
|
|
1525
|
+
for a notice inside an element that is already a live region (two nested regions announce
|
|
1526
|
+
twice) or one that is static page content from the first render. Icons are `aria-hidden`.
|
|
1527
|
+
|
|
1528
|
+
**`StepIndicator`** — an ordered list showing how far something has come. It reports only: no
|
|
1529
|
+
step is a link or a button. Steps a visitor moves between are `Tabs`.
|
|
1530
|
+
|
|
1531
|
+
- _Anatomy_: `root` (an `<ol>`) · `step` (an `<li>`) holding `marker` and `content`; `content`
|
|
1532
|
+
holds `label` (with `labelIcon`, the check before a done label when horizontal, and `status`,
|
|
1533
|
+
the visually hidden state) and `description` (optional secondary line: a date, a place).
|
|
1534
|
+
- _Properties_: `steps` (`{ label, description? }[]`), `current` (index from 0; `steps.length`
|
|
1535
|
+
marks every step done, a negative number every step upcoming), `orientation` (`horizontal`
|
|
1536
|
+
default, `vertical`; also `data-orientation`), `classes`. Each step carries `data-state`
|
|
1537
|
+
(`done`, `current`, `upcoming`). Attributes reach the `<ol>`: name it with `aria-label`.
|
|
1538
|
+
- _Sizes_: horizontal — equal columns (`minmax(0, 1fr)` each) 0.5rem apart, marker a 0.25rem
|
|
1539
|
+
full-radius bar across the column, 0.5rem above the text. Vertical — steps 0.75rem apart, marker
|
|
1540
|
+
a 1.25rem circle 0.625rem before the text. Label 0.875rem, description 0.8125rem
|
|
1541
|
+
(`text-caption`); check 1rem (horizontal) or 0.875rem (in the circle) at stroke 2.25.
|
|
1542
|
+
- _States_: done — marker `primary`, label `text` weight 400, with a check (before the label
|
|
1543
|
+
when horizontal, inside the circle when vertical). Current — marker `primary` (vertical: a
|
|
1544
|
+
`primary-contrast` dot inside), label `text` weight 600. Upcoming — marker `border` (vertical:
|
|
1545
|
+
an empty `border-strong` ring), label `muted`, no icon. Every marker keeps a border, so it
|
|
1546
|
+
survives forced colours.
|
|
1547
|
+
- _Keyboard_: none. Nothing in it is focusable; `Tab` passes over it.
|
|
1548
|
+
- _Accessibility_: a real `<ol>`, so the count and each position are announced.
|
|
1549
|
+
`aria-current="step"` on the current step; the other two say "(completed)" / "(not started)"
|
|
1550
|
+
in visually hidden text after the label (`messages.stepCompleted`, `messages.stepNotStarted`).
|
|
1551
|
+
Markers and icons are `aria-hidden`. State never rests on colour alone: check, weight, or
|
|
1552
|
+
neither.
|
|
1553
|
+
|
|
1554
|
+
**`Spinner`** — the circle `Button`, `LoadMore`, `Price` and `StockBadge` already drew, exported
|
|
1555
|
+
for a wait that is not inside one of them. One prop, `label`: without it the spinner is
|
|
1556
|
+
decorative (`aria-hidden`), with it `role="img"` named by the label — `Icon`'s own rule. It is
|
|
1557
|
+
never a live region; the busy region around it announces the wait. 1.125rem unless a size class
|
|
1558
|
+
on the component says otherwise (the class replaces the default through `mergeClass`), drawn in
|
|
1559
|
+
`currentColor`. Turning every 700ms; a pulse instead under reduced motion.
|
|
1560
|
+
|
|
1561
|
+
- **`RadioGroup` cards' leading part** (operator decision, 2026-11-15): `icon` on an option and a
|
|
1562
|
+
`leading` slot (`{ option }`), for an icon or a logo between the radio and the title — the spec's
|
|
1563
|
+
card anatomy has radio, title, hint and meta only. Cards only, like `meta`. An option with an
|
|
1564
|
+
`icon`, or any option once the slot is given, takes a fourth grid column
|
|
1565
|
+
(`auto auto 1fr auto`): the `leading` part sits in column 2, centred against the title and the
|
|
1566
|
+
hint together (it spans both rows when there is a hint), and the hint and meta move one column
|
|
1567
|
+
on. A card with neither keeps its three columns and renders exactly as before. The part is
|
|
1568
|
+
inside the option's `<label>`, so a click on it selects the option; the `icon` is drawn
|
|
1569
|
+
`aria-hidden` at 1.25rem / stroke 1.75, and a logo in the slot that only repeats the title
|
|
1570
|
+
should be `alt=""`. Nothing about the keyboard changes.
|
|
1276
1571
|
- **`SiteForm` and `useSiteForm`**: a form from the platform's Forms API, drawn from its public
|
|
1277
1572
|
definition with this package's own controls, checked by the platform's rules and submitted
|
|
1278
1573
|
through `@eldrajs/sdk`. The spec has form controls and a form layout but no platform form; see
|
|
@@ -1590,8 +1885,8 @@ children?, layout?, groups? }`, one level of children. Children sharing a `group
|
|
|
1590
1885
|
While it is on, the value keeps its text and its place, dimmed to `--eldra-revalidating-opacity`
|
|
1591
1886
|
(a shared token, default `0.75`, applied through the `eldra-revalidating` utility — per value part,
|
|
1592
1887
|
never on the root, because CSS opacity composites and a dimmed root would take the spinner down
|
|
1593
|
-
with it); a `1em` spinner — the same shape `Button` draws,
|
|
1594
|
-
|
|
1888
|
+
with it); a `1em` spinner — the same shape `Button` draws, the package's own `Spinner`
|
|
1889
|
+
— is drawn beside it; the root carries `aria-busy="true"`; and a visually hidden
|
|
1595
1890
|
`aria-live="polite"` region reads `messages.updatingPrice` / `messages.updatingStock`.
|
|
1596
1891
|
|
|
1597
1892
|
**The spinner reserves no space at all.** It is a flex item of width `0` whose negative
|
|
@@ -2520,15 +2815,15 @@ aria-busy aria-label="Loading product"`, `ContentCard`'s loading root now matche
|
|
|
2520
2815
|
wrapper is in the root entry and cannot know about vee-validate, and a control cannot write to
|
|
2521
2816
|
the wrapper that provides its context — so `Form`'s default slot carries `errors`, keyed by field
|
|
2522
2817
|
`name`, and the wrapper is bound to it (`:error="errors.email"`). It carries only the messages
|
|
2523
|
-
|
|
2524
|
-
|
|
2818
|
+
the fields are currently showing — each `Field*` reports its own — so the wrapper and the
|
|
2819
|
+
control's `aria-invalid` cannot disagree.
|
|
2525
2820
|
- **`Form` adds `successMessage`, which is not in the spec's Form layout property table.** The
|
|
2526
2821
|
spec's Success state asks for the confirmation to be "announced in a polite live region", and
|
|
2527
2822
|
`FormLayout` already has that region (`statusMessage`) — `successMessage` is simply the half a
|
|
2528
2823
|
form component can own: it fills the region once a submit passes validation. The visible half —
|
|
2529
2824
|
replacing the form or navigating — stays the page's. An explicit `statusMessage` wins over it.
|
|
2530
|
-
- **A server error shows immediately, without waiting for a blur or a submit.**
|
|
2531
|
-
|
|
2825
|
+
- **A server error shows immediately, without waiting for a blur or a submit.** A rule message
|
|
2826
|
+
waits for one of those so it does not appear under a half-typed value; an `apiErrors` entry is
|
|
2532
2827
|
the answer to a submit that has already happened, so there is nothing left to wait for — and a
|
|
2533
2828
|
form rendered with errors from an earlier round trip would otherwise show none of them.
|
|
2534
2829
|
- **`FieldSearchBar` takes neither an `id` nor a `name` from the field.** A `SearchBar` sets its
|
|
@@ -2546,11 +2841,17 @@ aria-busy aria-label="Loading product"`, `ContentCard`'s loading root now matche
|
|
|
2546
2841
|
validate in the browser. `action` and `method` are still forwarded (they are `FormLayout`'s
|
|
2547
2842
|
props), and the hidden native `<select>` inside every `Select` still carries its value — so a
|
|
2548
2843
|
scripting-free post is one `FormLayout` away, without this entry.
|
|
2549
|
-
- **
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2844
|
+
- **A field validates on blur from the start, not only "for fields that were invalid after the
|
|
2845
|
+
first submit"** (operator decision, 2026-11-15). The spec's rule is "Validate on submit, then on
|
|
2846
|
+
blur for fields that were invalid after the first submit"; here every `Field*` validates on blur
|
|
2847
|
+
by default (`validateOnBlur`), before a first submit too. A typed field never validates while
|
|
2848
|
+
typing unless `validateOnValueUpdate` is set; a choice field (a checkbox, a select) validates on
|
|
2849
|
+
each change by default. Until 0.3.x a field revalidated on every change and its message
|
|
2850
|
+
followed each keystroke once it had been touched. See [When a field validates](#when-a-field-validates).
|
|
2851
|
+
- **Fields can be revalidated while submitting.** The spec's Submitting state says the fields "stay
|
|
2852
|
+
editable but aren't re-validated". A blur still validates its field while a submit is in flight
|
|
2853
|
+
(and a `validateOnValueUpdate` field still follows its value): suppressing that would leave a
|
|
2854
|
+
field edited mid-flight with a message that no longer matches its value.
|
|
2554
2855
|
- **A `group` `FieldWrapper` renders `tabindex="-1"` on its `<fieldset>`.** Not in the spec's
|
|
2555
2856
|
anatomy; it is what makes an error summary's link land. A group has no single control, so the
|
|
2556
2857
|
summary points `#<id>` at the fieldset itself, and a browser moves focus to a fragment's target
|