@eldrajs/ui 0.3.20 → 0.3.21

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +63 -31
  3. package/dist/{PhoneInput-CHTpjbtS.js → PhoneInput-f6wxvduD.js} +1 -1
  4. package/dist/{VariantPicker-BLuaCwee.js → VariantPicker-CCci26If.js} +523 -310
  5. package/dist/components/autocomplete/Autocomplete.vue.d.ts +2 -0
  6. package/dist/components/chip/Chip.vue.d.ts +2 -0
  7. package/dist/components/currency-input/CurrencyInput.vue.d.ts +5 -1
  8. package/dist/components/dialog/Dialog.vue.d.ts +2 -0
  9. package/dist/components/drawer/Drawer.vue.d.ts +2 -0
  10. package/dist/components/filter-panel/FilterGroup.vue.d.ts +2 -0
  11. package/dist/components/filter-panel/FilterPanel.vue.d.ts +2 -0
  12. package/dist/components/filter-panel/facets/ColourFacet.vue.d.ts +2 -0
  13. package/dist/components/filter-panel/facets/ListFacet.vue.d.ts +2 -0
  14. package/dist/components/filter-panel/facets/RangeFacet.vue.d.ts +2 -0
  15. package/dist/components/filter-panel/facets/SizeFacet.vue.d.ts +2 -0
  16. package/dist/components/filter-panel/facets/ToggleFacet.vue.d.ts +2 -0
  17. package/dist/components/lightbox/Lightbox.vue.d.ts +2 -0
  18. package/dist/components/load-more/LoadMore.vue.d.ts +1 -1
  19. package/dist/components/nav-menu/NavMenu.vue.d.ts +2 -0
  20. package/dist/components/pagination/Pagination.vue.d.ts +2 -0
  21. package/dist/components/range-slider/RangeSlider.vue.d.ts +2 -0
  22. package/dist/components/search-bar/SearchBar.vue.d.ts +2 -0
  23. package/dist/components/search-modal/SearchModal.vue.d.ts +2 -0
  24. package/dist/components/select/MultiSelect.vue.d.ts +2 -0
  25. package/dist/components/select/Select.vue.d.ts +2 -0
  26. package/dist/components/site-form/SiteForm.vue.d.ts +2 -0
  27. package/dist/components/toast/Toast.vue.d.ts +2 -0
  28. package/dist/components/toast/Toaster.vue.d.ts +2 -0
  29. package/dist/components/unit-input/UnitInput.vue.d.ts +8 -0
  30. package/dist/components/unit-input/types.d.ts +13 -1
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +3 -3
  33. package/dist/messages/en-US.d.ts +4 -0
  34. package/dist/messages/is-IS.js +3 -1
  35. package/dist/phone/PhoneInput.vue.d.ts +2 -0
  36. package/dist/phone/vee-validate.js +3 -3
  37. package/dist/phone.js +1 -1
  38. package/dist/{useFieldControl-B1JvPEeM.js → useFieldControl-BnO3B37W.js} +17 -6
  39. package/dist/{useMessages-BdN9F1cW.js → useMessages-D8bTGX7c.js} +5 -1
  40. package/dist/utils/amount.d.ts +71 -0
  41. package/dist/vee-validate/useFieldControl.d.ts +6 -0
  42. package/dist/vee-validate.js +35 -5
  43. package/dist/vue-i18n.js +1 -1
  44. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,9 @@ Release-please writes the generated notes from commit messages and does not repl
7
7
 
8
8
  ### Added
9
9
 
10
+ - **`parseAmount`, `readAmount` and `createAmountEditor`** (`src/utils/amount.ts`): the one amount parser and the format-while-typing editor behind `UnitInput` and `CurrencyInput`, for a consumer reading a typed or pasted amount the same way. Types `AmountReading`, `AmountText`, `AmountEdit`, `AmountEditor`, `AmountEditorOptions`, `AmountInvalidReason`.
11
+ - **`UnitInput` and `CurrencyInput` `fixedFraction`, `nullable` and `placeholder`**, the `update:valid` event, and `isValid` and `invalidReason` on the instance; `CurrencyInput` exposes the same three (WS-1390).
12
+ - **`FieldUnitInput` and `FieldCurrencyInput` fail on text they cannot read (WS-1390)**, before their `rules` run, so the form never submits the number the field held. New messages `amountNotANumber` ("Enter a number." / "Sláðu inn tölu.") and `amountNoDecimals` ("Enter a whole number." / "Sláðu inn heila tölu."). The check is a field rule, so a form-level `validationSchema` that replaces field rules does not see it.
10
13
  - **`NavMenu` draws cards (WS-1362).** An entry with `display: 'card'` and a resolved `card` is drawn as a card: its picture cropped to the new `cardAspect` prop (`width:height`, default `4:3`), the title, and `card.price` written with `formatPrice` in the ambient `CURRENCY_KEY` and `LOCALE_KEY` (a plain number without a currency). A column holding cards lays them two to a row in the bar and in the drawer; a plain entry beside them takes a whole row, and the heading, cards and plain entries of that column start at one edge. The column and the columns row carry `data-cards` for a theme to size it. The picture has an empty `alt` since the title beside it names the link. New parts `card`, `cardImage`, `cardTitle`, `cardPrice` (and `drawer…`), new helpers `isCard` and `cardAspectRatio` in `navLinks`. The `panelItem` slot still replaces the card; an entry without a resolved `card` stays a link.
11
14
  - **`NavMenuLink.card` and `display` (WS-1326).** A resolved card (`{ image, title, price? }`) rides on the entry and reaches the `panelItem` slot as `link.card`. New type `NavMenuCard`.
12
15
  - **`NavMenu` sections (WS-1321).** `NavMenuItem.sections` (new type `NavMenuSection`: `heading`, `headingLink`, `links`, `seeAll`, `display`), which a resolved Studio link carries for a theme that declares `tree.sections`, draws one column per section in a `mega` panel: a heading that links when it has a page, the "see all" entry last (`data-see-all`, and `isSeeAll` in the `panelItem` slot props), a section with only a heading link headed by that link's label, a section with nothing to show left out. `children` and `groups` keep working for a link without sections. New helper `panelRuns` in `navLinks`.
@@ -178,6 +181,8 @@ Release-please writes the generated notes from commit messages and does not repl
178
181
 
179
182
  ### Fixed
180
183
 
184
+ - **`UnitInput` and `CurrencyInput` read every amount with one parser (WS-1390).** A paste into a selection, autofill, a virtual keyboard or dictation, an IME composition and a decimal mark arriving without a key event are read like typing, so an amount is no longer read 10 to 1000 times off. The field still formats while typing, with the caret kept. A paste in the other convention is read (`1,000,000` into an Icelandic field is a million); a typed keystroke that would make the text unreadable is refused; text that cannot be read is kept and marked invalid instead of having its characters stripped. A currency without decimals (ISK) takes none, a `,00` tail is dropped and a non-zero fraction is invalid. An emptied field emits `min` (or `null` with `nullable`) at once instead of on blur. The keydown handling of `,`, `.`, Backspace, Delete and the arrow keys over separators is gone: deleting a separator deletes the digit beyond it.
185
+
181
186
  - **`SearchBar` `autofocus` focuses after the page's own mount updates have rendered (WS-1277).** It focused inside `onMounted`, before updates other blocks queue in their mounted hooks had drawn, so the field was scrolled into view against a layout about to change and could end a pixel away from where the settled page puts it. It now focuses on the next tick.
182
187
  - **`SearchModal` shows its results in Safari, and long results scroll.** The results area took no height in Safari, so the dialog drew only the field and the footer. In every browser, results taller than the dialog's max height were cut off instead of scrolling. The `results` part is now a flex column sized by its content (`flex-auto`, was `flex-1`), and the panel inside it fills it and scrolls (`flex-auto`, was `h-full`).
183
188
  - **Opening a `Dialog`, `Drawer`, `Lightbox` or `SearchModal` no longer shifts the page sideways.** The scroll lock hid the page's scrollbar and the content widened into its space; `<html>` is now padded on the right by the scrollbar's width while a modal is open, added to any padding it already has and restored on close. Nothing changes with overlay scrollbars or on a page that does not scroll. A `position: fixed` element that spans the window pads itself with `--eldra-scrollbar-width` (under Added) to stay still too.
package/README.md CHANGED
@@ -1713,7 +1713,9 @@ aria-pressed>` that fills `primary`/`primary-contrast` when `selected`, the same
1713
1713
  that a store that knows those fields knows these; the handful of places this port deliberately
1714
1714
  departs from them is listed under the deviations below.
1715
1715
  - **`FieldUnitInput` and `FieldCurrencyInput`**, their `./vee-validate` wrappers, binding
1716
- `number | null`.
1716
+ `number | null`. Text the field cannot read fails the field before its `rules` run, with
1717
+ `amountNotANumber` or, for a fraction where the currency takes none, `amountNoDecimals`; the model
1718
+ keeps the number it held, so without this a rule would pass it and the form would submit it.
1717
1719
  - **`provideEldraUiLocale` / `useEldraUiLocale` / `LOCALE_KEY`** (`src/composables/useLocale.ts`) —
1718
1720
  the number locale as a provide/inject pair, the same shape as the messages one and deliberately a
1719
1721
  separate key: the strings a component renders and the locale its numbers are formatted in are
@@ -2322,40 +2324,70 @@ aria-busy aria-label="Loading product"`, `ContentCard`'s loading root now matche
2322
2324
  separator in the field to type after. `filterNumericBeforeInput` still accepts it on a
2323
2325
  decimal field, for a consumer building one — someone pasting `1,234.50` means 1234.5.
2324
2326
 
2325
- **`UnitInput` and `CurrencyInput` do the opposite, on purpose** (see below): they let a
2326
- non-numeric keystroke land and strip it on the reformat.
2327
-
2328
- - **`UnitInput` and `CurrencyInput` are ports, and the behaviour is the private library's**
2329
- (operator decision, 2026-09-25). "The currency input, unit input should function identical to how
2330
- they do in the private ui." The field is formatted **while it is typed into** — there is no
2331
- editing mode and no focus-dependent text — because that is what a merchant already knows these
2332
- fields to do; a field that showed a plain number under the caret and a formatted one on blur was
2333
- rejected. Everything that follows from it (the caret mapped by numeric content, the arrow/
2334
- backspace/delete rules that step over separators and never eat the symbol, `,` and `.` both
2335
- inserting the locale's decimal, the empty-until-blur rule, the controlled reconciliation, the
2336
- drag handle) is ported case for case, and
2337
- `src/components/{unit-input,currency-input}/__tests__/` carries the private specs' own cases
2338
- under their own names.
2339
-
2340
- **Typing is not filtered in these two.** A non-numeric keystroke lands and the reformat removes
2341
- it — the opposite of `QuantityStepper`, and deliberate: this field's own text is full of
2342
- characters that are not digits (a symbol, group separators, a literal), so a filter judging the
2343
- resulting value would have to understand the formatted string it is judging. Pasting `12ab3`
2344
- leaves `123` either way.
2345
-
2346
- **Four deliberate departures from the private components**, each because the private behaviour is
2327
+ **`UnitInput` and `CurrencyInput` do the opposite, on purpose** (see below): their text always
2328
+ holds a symbol and grouping, and one parser reads whatever arrives.
2329
+
2330
+ - **`UnitInput` and `CurrencyInput` format while they are typed into** (operator decision,
2331
+ 2026-09-25, kept 2026-11-26): focused or not, the field shows `$1,234.5`, `1.234 kr.` or
2332
+ `1,234 km`, because that is what a merchant knows these fields to do; a field that showed a plain
2333
+ number under the caret and a formatted one on blur was rejected. Focus does not change the text.
2334
+
2335
+ **One path for every edit.** Each `input` event, however the text came (a keystroke, a paste into
2336
+ a selection, a drop, autofill, a virtual keyboard or dictation, the end of an IME composition),
2337
+ goes through `createAmountEditor().edit` in `src/utils/amount.ts`, exported. It compares the new
2338
+ text with the one the field showed around the caret to find what was inserted and what was
2339
+ removed; the symbol and the grouping in the old text are the field's own and are never read as
2340
+ typed marks. The result is read by one parser, `readAmount`, and formatted back, with the caret
2341
+ after the same digit it followed. Keydown inserts nothing and moves nothing (only the arrows step
2342
+ and Ctrl/Cmd+A selects the amount); during a composition nothing is read until `compositionend`.
2343
+ Earlier versions special-cased `,` and `.` on keydown and stripped every character on each
2344
+ reformat, which read amounts 10 to 1000 times off whenever a mark came without a key event.
2345
+
2346
+ **The parser** (`parseAmount`, strict) reads in the field's locale. Spaces, currency symbols and
2347
+ codes and the unit are stripped; full-width digits and marks read as ASCII. The locale's decimal
2348
+ mark is always the decimal mark, and more decimals than the field takes is unreadable, never
2349
+ grouping. The locale's grouping mark counts only as well-formed groups (`1,234,567`). The other
2350
+ convention is taken where the locale reading is impossible and the other is unambiguous: one
2351
+ other mark followed by one or two digits (`34.90` under `is-IS`), or both marks in a well-formed
2352
+ pattern (`1,234.50` under `is-IS`). A leading mark means `0,5`. In a currency without decimals
2353
+ (ISK; the field then takes no decimals whatever `maxFraction` says) either convention's grouping
2354
+ is accepted, a `,00` tail reads as nothing and a non-zero fraction is unreadable (`noDecimals`).
2355
+ `src/utils/__tests__/amount.spec.ts` holds the table.
2356
+
2357
+ **Text that arrives in bulk is read leniently** (`readAmount(…, lenient)`): when the locale
2358
+ cannot read it, it is read in the other convention, so `1,000,000` pasted into an Icelandic field
2359
+ is a million and shown `1.000.000 kr.`, and `1.000` pasted into an English money field a
2360
+ thousand. A single typed keystroke is read strictly, and a keystroke that would make readable
2361
+ text unreadable is refused: typing a third decimal into `1,00 €` leaves `1,00 €`, never `1.000 €`;
2362
+ a typed letter does nothing. A value above `max` is refused either way.
2363
+
2364
+ **What the text shows.** A typed decimal mark and trailing zeros stay while typing (`12,` and
2365
+ `12,50`), inside the number before a trailing symbol. Blur settles the text: grouped, a bare mark
2366
+ or a zero tail dropped, and with `fixedFraction` (currency only) the currency's own decimals
2367
+ padded (`34,90 €`). Deleting a symbol or a group mark alone deletes the digit beyond it, so
2368
+ Backspace after `1,` removes the `1` and the symbol can never be deleted. Text that cannot be
2369
+ read is left as it came, between the symbols, and marked invalid (`aria-invalid` and the error
2370
+ boundary): at once for unreadable text, on blur for text still being typed (`12,` under `en-US`,
2371
+ which may become `12,500`).
2372
+
2373
+ **What is emitted.** The number the text says, at once. Emptied: `null` with `nullable`, else
2374
+ `clamp(0)` (`min`), at once, and the field shows it on blur (an untouched empty field stays
2375
+ empty). While the text cannot be read the model is the value the field had when editing began,
2376
+ emitted once. `update:valid` (boolean) is emitted on every change of readability and once on
2377
+ mount; the instance exposes `isValid` and `invalidReason` (`notANumber`, `noDecimals` or `null`).
2378
+ A bound `modelValue` the parent does not write back is shown again after the edit, so a clamping
2379
+ or refusing parent is what the field shows; a parent echoing the number never rewrites `12,`.
2380
+
2381
+ **Two deliberate departures from the private components**, each because the private behaviour is
2347
2382
  wrong here rather than merely different:
2348
2383
 
2349
- 1. **A typed decimal separator is put back inside the number, not appended to the string.** The
2350
- private component appends it, which is right for `$1,234.` and wrong for every suffix-symbol
2351
- format — it produced `1,234 km.` and `1.234 kr.,`.
2352
- 2. **`CurrencyInput` forwards only the props that were actually passed.** The private wrapper
2384
+ 1. **`CurrencyInput` forwards only the props that were actually passed.** The private wrapper
2353
2385
  spreads all of them, so `UnitInput` sees a bound `modelValue` on a field nobody bound and the
2354
2386
  reconciliation clears an uncontrolled field a tick after every keystroke.
2355
- 3. **Double-click is wired to the native `dblclick` event.** The private wrapper listens for a
2356
- `doubleClick` that nothing emits, so selecting the digits by double-click never worked there.
2357
- 4. **Read-only and disabled fields do nothing at all** — no editing, no caret placement, no
2358
- stepping, no drag, no clear button. The private component has no read-only state.
2387
+ 2. **Read-only and disabled fields do nothing at all** — no editing, no caret placement, no
2388
+ stepping, no drag, no clear button.
2389
+
2390
+ The private library's `UnitInput` renders this one, so the two behave the same.
2359
2391
 
2360
2392
  And the package conventions on top of the port: the `data-part` anatomy and `classes`, the three
2361
2393
  field sizes, the `FieldWrapper` context (`id`, `invalid`, `required`, composed `describedBy`),
@@ -1,6 +1,6 @@
1
1
  import { $ as FIELD_KEY, W as FIELD_RADIUS, Y as FIELD_TEXT, d as useEldraUiLocale, i as SelectPanel_default, nt as joinIds, p as usePopover, r as useOptionList, rt as useUiId, tt as useControllableModel, y as useListbox } from "./useOptionList-UMUMayec.js";
2
2
  import { r as useEldraScope } from "./useEldraScope-BDbGzt7R.js";
3
- import { i as enUS, r as useMessages } from "./useMessages-BdN9F1cW.js";
3
+ import { i as enUS, r as useMessages } from "./useMessages-D8bTGX7c.js";
4
4
  import { t as CountryFlag_default } from "./CountryFlag-DOa8lOHp.js";
5
5
  import { Fragment, Teleport, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, inject, mergeProps, nextTick, normalizeClass, onMounted, openBlock, ref, renderSlot, toDisplayString, toValue, unref, watch, withCtx } from "vue";
6
6
  import { comparator } from "@eldrajs/sdk/format";