@eldrajs/ui 0.2.8 → 0.2.9
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 +45 -0
- package/README.md +259 -87
- package/dist/{VariantPicker-CjWUVhlm.js → VariantPicker-Da41_oGA.js} +2244 -1399
- package/dist/componentNames.d.ts +1 -1
- package/dist/components/button/Button.vue.d.ts +3 -0
- package/dist/components/button/types.d.ts +32 -3
- package/dist/components/card/ContentCard.vue.d.ts +1 -1
- package/dist/components/checkbox/Checkbox.vue.d.ts +2 -0
- package/dist/components/checkbox/types.d.ts +12 -1
- package/dist/components/chip/Chip.vue.d.ts +4 -3
- package/dist/components/dialog/Dialog.vue.d.ts +12 -7
- package/dist/components/dialog/types.d.ts +11 -2
- package/dist/components/drawer/Drawer.vue.d.ts +1 -0
- package/dist/components/field-wrapper/FieldWrapper.vue.d.ts +3 -0
- package/dist/components/field-wrapper/RequiredMark.vue.d.ts +15 -0
- package/dist/components/field-wrapper/context.d.ts +8 -0
- package/dist/components/field-wrapper/types.d.ts +12 -4
- package/dist/components/filter-panel/FilterGroup.vue.d.ts +1 -0
- package/dist/components/filter-panel/FilterPanel.vue.d.ts +3 -2
- package/dist/components/filter-panel/facets/ColourFacet.vue.d.ts +1 -0
- package/dist/components/filter-panel/facets/ListFacet.vue.d.ts +1 -0
- package/dist/components/filter-panel/facets/RangeFacet.vue.d.ts +2 -1
- package/dist/components/filter-panel/facets/SizeFacet.vue.d.ts +1 -0
- package/dist/components/filter-panel/facets/ToggleFacet.vue.d.ts +1 -0
- package/dist/components/input/Input.vue.d.ts +7 -2
- package/dist/components/input/classes.d.ts +9 -0
- package/dist/components/input/reassertValue.d.ts +13 -0
- package/dist/components/input/types.d.ts +14 -5
- package/dist/components/input/useAdornmentRoom.d.ts +15 -0
- package/dist/components/lightbox/Lightbox.vue.d.ts +1 -0
- package/dist/components/nav-menu/NavMenu.vue.d.ts +1 -0
- package/dist/components/pagination/Pagination.vue.d.ts +154 -0
- package/dist/components/pagination/types.d.ts +31 -0
- package/dist/components/popover/Popover.vue.d.ts +28 -1
- package/dist/components/popover/types.d.ts +57 -3
- package/dist/components/product-card/ProductCard.vue.d.ts +1 -1
- package/dist/components/radio/Radio.vue.d.ts +33 -0
- package/dist/components/radio/RadioGroup.vue.d.ts +4 -0
- package/dist/components/radio/recipes.d.ts +37 -0
- package/dist/components/radio/types.d.ts +64 -3
- package/dist/components/range-slider/RangeSlider.vue.d.ts +1 -0
- package/dist/components/search-bar/SearchBar.vue.d.ts +1 -0
- package/dist/components/search-modal/SearchModal.vue.d.ts +1 -0
- package/dist/components/select/MultiSelect.vue.d.ts +48 -1
- package/dist/components/select/Select.vue.d.ts +20 -0
- package/dist/components/select/SelectPanel.vue.d.ts +23 -0
- package/dist/components/select/SelectTags.vue.d.ts +50 -0
- package/dist/components/select/openRegistry.d.ts +14 -4
- package/dist/components/select/panelParts.d.ts +28 -2
- package/dist/components/select/types.d.ts +45 -7
- package/dist/components/select/useOptionList.d.ts +31 -4
- package/dist/components/select/usePopover.d.ts +36 -39
- package/dist/components/select/useSummaryFit.d.ts +21 -0
- package/dist/components/select/useTagRows.d.ts +17 -0
- package/dist/components/site-form/SiteForm.vue.d.ts +2 -1
- package/dist/components/switch/Switch.vue.d.ts +15 -8
- package/dist/components/switch/types.d.ts +25 -1
- package/dist/components/tabs/Tab.vue.d.ts +1 -0
- package/dist/components/tabs/context.d.ts +6 -2
- package/dist/components/tabs/types.d.ts +9 -0
- package/dist/components/textarea/Textarea.vue.d.ts +21 -1
- package/dist/components/textarea/types.d.ts +11 -2
- package/dist/components/toast/Toast.vue.d.ts +2 -0
- package/dist/components/toast/Toaster.vue.d.ts +7 -1
- package/dist/components/toast/types.d.ts +43 -2
- package/dist/components.css +312 -13
- package/dist/composables/useDialog.d.ts +7 -3
- package/dist/composables/useEldraScope.d.ts +26 -0
- package/dist/composables/useFloating.d.ts +21 -8
- package/dist/composables/useOverlay.d.ts +10 -5
- package/dist/composables/useToast.d.ts +3 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.js +1296 -405
- package/dist/messages/en-US.d.ts +2 -0
- package/dist/messages/is-IS.js +1 -0
- package/dist/resolver.js +1 -0
- package/dist/scoped.css +4623 -0
- package/dist/style.css +312 -13
- package/dist/tailwind.css +43 -12
- package/dist/useMessages-B5nzZghs.js +592 -0
- package/dist/vee-validate.js +42 -6
- package/dist/vue-i18n/index.d.ts +50 -0
- package/dist/vue-i18n/shapes.d.ts +40 -0
- package/dist/vue-i18n.js +289 -0
- package/package.json +16 -3
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
import { t as formatConjunctionList } from "./listFormat-D9ecpDMT.js";
|
|
2
|
+
import { computed, inject, provide, toValue } from "vue";
|
|
3
|
+
// src/messages/en-US.ts
|
|
4
|
+
/**
|
|
5
|
+
* The English strings the components emit on their own — the ones a consumer
|
|
6
|
+
* never passes in: an icon-only button's accessible name, a listbox's empty
|
|
7
|
+
* state, a character counter. Everything else is content and comes from props
|
|
8
|
+
* or slots.
|
|
9
|
+
*
|
|
10
|
+
* This object is the shape: `UiMessages` is `typeof enUS`, every other locale
|
|
11
|
+
* is typed against it, and `src/messages/__tests__/parity.spec.ts` fails if a
|
|
12
|
+
* locale is missing a key or changes a function's arity.
|
|
13
|
+
*
|
|
14
|
+
* Sentence case throughout, per the design spec's voice and content rules.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Shared between `rating` and `reviewCount` below, so the two sentences that both name a review
|
|
18
|
+
* count (`Rating`'s accessible sentence and the linked variant's visible "128 reviews" text) never
|
|
19
|
+
* drift onto two different plural rules.
|
|
20
|
+
*/
|
|
21
|
+
function reviewsWord(n) {
|
|
22
|
+
return n === 1 ? "review" : "reviews";
|
|
23
|
+
}
|
|
24
|
+
var enUS = {
|
|
25
|
+
/** Empties a field or a selection. */
|
|
26
|
+
clear: "Clear",
|
|
27
|
+
/** Dismisses a dialog, a drawer or a toast. */
|
|
28
|
+
close: "Close",
|
|
29
|
+
/**
|
|
30
|
+
* A `Drawer`'s close button, when the drawer has a name to put in it (spec "Drawer" →
|
|
31
|
+
* Accessibility: "Close button names the drawer: 'Close cart', 'Close menu', 'Close filters'").
|
|
32
|
+
* `name` is whatever names the drawer — its `title` text if it has one, else its `ariaLabel` —
|
|
33
|
+
* so a consumer names the exact wording by choosing that prop's value (`title="Cart"` reads
|
|
34
|
+
* "Close Cart"). Falls back to the plain `close` above when the drawer has neither.
|
|
35
|
+
*/
|
|
36
|
+
closeDrawer: (name) => `Close ${name}`,
|
|
37
|
+
/** The `SearchModal`'s close button (desktop and tablet) — distinct from the plain `close` above
|
|
38
|
+
* because the design spec gives it this exact wording (spec "Search modal" → Sizes, Close row:
|
|
39
|
+
* "'Close search'"), unlike `Dialog`/`Drawer`'s generic "Close". */
|
|
40
|
+
closeSearch: "Close search",
|
|
41
|
+
/** The `SearchModal`'s own text button on phones, replacing the icon `closeSearch` button there
|
|
42
|
+
* (spec "Search modal" → Sizes, Close row: "'Cancel' small ghost text button"). */
|
|
43
|
+
cancel: "Cancel",
|
|
44
|
+
/** The `SearchModal`'s clear button (spec "Search modal" → Sizes, Clear row: "'Clear search'") —
|
|
45
|
+
* distinct from the plain `clear` above for the same reason `closeSearch` is. */
|
|
46
|
+
clearSearch: "Clear search",
|
|
47
|
+
/** A `Toast`'s close button (spec "Toast" -> Accessibility: `aria-label="Dismiss notification"`)
|
|
48
|
+
* — distinct from `close` above, which is the generic word `Dialog` and future modal surfaces
|
|
49
|
+
* use for the same button. */
|
|
50
|
+
dismissNotification: "Dismiss notification",
|
|
51
|
+
/** A `Toaster`'s own region (spec "Toast" -> Accessibility: `aria-label="Notifications"`, on the
|
|
52
|
+
* `role="status" aria-live="polite"` element). */
|
|
53
|
+
notifications: "Notifications",
|
|
54
|
+
/** Accompanies a spinner or a busy region. */
|
|
55
|
+
loading: "Loading",
|
|
56
|
+
/**
|
|
57
|
+
* Marks a field that may be left empty. The `FieldWrapper` renders it in parentheses, so the
|
|
58
|
+
* spec's optional mark reads "(optional)" — hence the lower case here, unlike the labels above.
|
|
59
|
+
*/
|
|
60
|
+
optional: "optional",
|
|
61
|
+
/** Marks a field that must be filled in. */
|
|
62
|
+
required: "Required",
|
|
63
|
+
/** The search control's own label. */
|
|
64
|
+
search: "Search",
|
|
65
|
+
/**
|
|
66
|
+
* Shown by a `Select` with no value (spec "Select" -> Properties, `placeholder`: default
|
|
67
|
+
* `"Select"`). Two words would not fit a narrow filter bar's trigger, and the field's own label
|
|
68
|
+
* already says which choice this is.
|
|
69
|
+
*/
|
|
70
|
+
selectPlaceholder: "Select",
|
|
71
|
+
/**
|
|
72
|
+
* Shown by a `MultiSelect` with no value (spec "Multi-select" -> Properties, `placeholder`:
|
|
73
|
+
* default `"Any"`). It reads as a filter's "no filter applied", which is what a multi-select
|
|
74
|
+
* mostly is, and the field's own label says which choice it belongs to.
|
|
75
|
+
*/
|
|
76
|
+
multiSelectPlaceholder: "Any",
|
|
77
|
+
/** Shown when a filtered list has nothing to show. */
|
|
78
|
+
noResults: "No results",
|
|
79
|
+
/**
|
|
80
|
+
* A `SearchBar`'s no-results title (spec "Search bar" -> Panel views, `none`: '"No results for
|
|
81
|
+
* “q”"'). Deliberately not `noMatchesFor`, which is a `Select`'s own empty state and whose
|
|
82
|
+
* "matches" is that section's own word.
|
|
83
|
+
*/
|
|
84
|
+
noResultsFor: (query) => `No results for “${query}”`,
|
|
85
|
+
/**
|
|
86
|
+
* A `Select`'s empty state while a search query is showing (spec "Select" -> Behaviour, Search:
|
|
87
|
+
* 'With no matches, the empty state "No matches for “query”" shows as real text'). The
|
|
88
|
+
* curly quotation marks are the spec's own.
|
|
89
|
+
*/
|
|
90
|
+
noMatchesFor: (query) => `No matches for “${query}”`,
|
|
91
|
+
/** A creatable `Select`'s or `MultiSelect`'s last row, offering the query as a new option. */
|
|
92
|
+
createOption: (query) => `Create “${query}”`,
|
|
93
|
+
/** The overflow badge on a `MultiSelect` that cannot show every tag. */
|
|
94
|
+
moreSelected: (n) => `+${n}`,
|
|
95
|
+
/** The accessible name of a selected tag's remove button. */
|
|
96
|
+
removeTag: (label) => `Remove ${label}`,
|
|
97
|
+
/**
|
|
98
|
+
* Names a `MultiSelect`'s tag list. Inside a `FieldWrapper` it is joined with the field's own
|
|
99
|
+
* label, so the list reads "Selected categories".
|
|
100
|
+
*/
|
|
101
|
+
selected: "Selected",
|
|
102
|
+
/** A `MultiSelect` footer's live count. */
|
|
103
|
+
selectedCount: (n) => `${n} selected`,
|
|
104
|
+
/** A `MultiSelect` footer's live count with nothing chosen. */
|
|
105
|
+
noneSelected: "None selected",
|
|
106
|
+
/** Closes a `MultiSelect`'s popover. It commits nothing: every toggle already applied. */
|
|
107
|
+
done: "Done",
|
|
108
|
+
/** The accessible name of a `QuantityStepper`'s minus button. */
|
|
109
|
+
decrease: "Decrease",
|
|
110
|
+
/** The accessible name of a `QuantityStepper`'s plus button. */
|
|
111
|
+
increase: "Increase",
|
|
112
|
+
/** The accessible name of a `QuantityStepper`'s field. */
|
|
113
|
+
quantity: "Quantity",
|
|
114
|
+
/** A `QuantityStepper`'s polite live-region announcement after a settled change. */
|
|
115
|
+
quantityUpdated: (n) => `Quantity: ${n}`,
|
|
116
|
+
/** A `RangeSlider` thumb's and field's name with no visible group label to join it to. */
|
|
117
|
+
minimum: "Minimum",
|
|
118
|
+
/** The same, for the other end of the range. */
|
|
119
|
+
maximum: "Maximum",
|
|
120
|
+
/**
|
|
121
|
+
* A `RangeSlider` thumb's and field's name built from the visible group label, so a price
|
|
122
|
+
* filter's two ends read "Minimum price" and "Maximum price" (spec "Range slider" →
|
|
123
|
+
* Accessibility). `name` is the control's own `label`; the same shape as `closeDrawer` above.
|
|
124
|
+
*/
|
|
125
|
+
minimumOf: (name) => `Minimum ${name}`,
|
|
126
|
+
/** The same, for the other end of the range. */
|
|
127
|
+
maximumOf: (name) => `Maximum ${name}`,
|
|
128
|
+
/** The word between a `RangeSlider`'s two typed fields (spec "Range slider" → Anatomy item 6).
|
|
129
|
+
* Decorative: both fields are already named, so it is `aria-hidden`. */
|
|
130
|
+
to: "to",
|
|
131
|
+
/** Appended to a link that opens a new browsing context. */
|
|
132
|
+
opensInNewTab: "(opens in a new tab)",
|
|
133
|
+
/** A position-in-a-set counter, e.g. a carousel's slide count. */
|
|
134
|
+
counter: (n, max) => `${n} / ${max}`,
|
|
135
|
+
/** `Carousel`'s previous-arrow accessible name (spec "Carousel" → Accessibility: "'Previous
|
|
136
|
+
* slide' ... (galleries)"; used uniformly for product rows too — see `Carousel.vue`'s own
|
|
137
|
+
* comment on why one label serves both variants). */
|
|
138
|
+
previous: "Previous slide",
|
|
139
|
+
/** `Carousel`'s next-arrow accessible name. */
|
|
140
|
+
next: "Next slide",
|
|
141
|
+
/** `Carousel`'s Pause/Play button, both its visible text and (with no autoplay-specific
|
|
142
|
+
* "slideshow" suffix — a deliberate simplification, recorded under Deviations in the README)
|
|
143
|
+
* its accessible name while playing. */
|
|
144
|
+
pause: "Pause",
|
|
145
|
+
/** `Carousel`'s Pause/Play button while paused. */
|
|
146
|
+
play: "Play",
|
|
147
|
+
/** A `Carousel` slide's accessible label (spec "Carousel" → Accessibility: `aria-label="2 of
|
|
148
|
+
* 4"`), `position` and `total` both 1-based. */
|
|
149
|
+
slideOf: (position, total) => `${position} of ${total}`,
|
|
150
|
+
/** A `Carousel` dot's accessible name (spec "Carousel" → Accessibility: `aria-label="Go to
|
|
151
|
+
* slide 3"`), 1-based. */
|
|
152
|
+
goToSlide: (n) => `Go to slide ${n}`,
|
|
153
|
+
/** A `Carousel` track's own accessible name (spec "Carousel" → Accessibility: the track needs
|
|
154
|
+
* "a label" distinct from the region's own — the spec's own examples are "Bestsellers,
|
|
155
|
+
* scrollable list" for a product row and "Slides" for a gallery; this package uses the single
|
|
156
|
+
* generic word for both, recorded under Deviations in the README). */
|
|
157
|
+
slides: "Slides",
|
|
158
|
+
/** How to operate a `Carousel` whose slides hold their own links or buttons, read once when
|
|
159
|
+
* focus enters the carousel (it describes the carousel itself, not each slide — see
|
|
160
|
+
* `Carousel.vue`'s own `instructionsId` comment). Spec "Keyboard": a composite widget "take[s]
|
|
161
|
+
* one tab stop and use[s] arrow keys inside", which is worth saying out loud to the one visitor
|
|
162
|
+
* who cannot see the row of cards it applies to. */
|
|
163
|
+
slideInstructions: "Use the left and right arrow keys to move between slides. Press Tab to move within the current slide.",
|
|
164
|
+
/** A `Lightbox`'s close button (spec "Lightbox" → Anatomy, part 3: "'Close image viewer'") —
|
|
165
|
+
* distinct from `close` above, the same way `dismissNotification` is distinct from it for
|
|
166
|
+
* `Toast`: a full-screen image viewer is not "a dialog" to the person closing it. */
|
|
167
|
+
closeLightbox: "Close image viewer",
|
|
168
|
+
/** A `Lightbox` arrow's accessible name (spec "Lightbox" → Accessibility: "'Previous image' /
|
|
169
|
+
* 'Next image'"). Deliberately `*Image`, not `Carousel`'s own `previous`/`next` ("…slide"): the
|
|
170
|
+
* Lightbox spec's own wording never says "slide" anywhere in its Anatomy or Accessibility
|
|
171
|
+
* sections, even though it is built on the same track internally. */
|
|
172
|
+
previousImage: "Previous image",
|
|
173
|
+
/** A `Lightbox` arrow's accessible name. See `previousImage`. */
|
|
174
|
+
nextImage: "Next image",
|
|
175
|
+
/** A `Lightbox` slide's accessible label (spec "Lightbox" → Accessibility: `aria-label="2 of
|
|
176
|
+
* 4"`), `position` and `total` both 1-based — the same shape as `Carousel`'s own `slideOf`, but
|
|
177
|
+
* its own key: a consumer overriding one must not silently change the other's wording. */
|
|
178
|
+
imageOf: (position, total) => `${position} of ${total}`,
|
|
179
|
+
/**
|
|
180
|
+
* A `Lightbox` thumbnail's accessible name. The spec's own wording ("With thumbnails" → "each
|
|
181
|
+
* 'Go to slide n'") reuses `Carousel`'s dot phrasing verbatim, but this package gives `Lightbox`
|
|
182
|
+
* its own `*Image` vocabulary throughout (see `previousImage`/`imageOf` above) rather than
|
|
183
|
+
* surfacing "slide" — an internal implementation detail this component's own track shares with
|
|
184
|
+
* `Carousel` — to the person using it. Recorded under Deviations in the README.
|
|
185
|
+
*/
|
|
186
|
+
goToImage: (n) => `Go to image ${n}`,
|
|
187
|
+
/** A `Lightbox` track's own accessible name (spec "Lightbox" → Accessibility: "Track: focusable
|
|
188
|
+
* (`tabindex="0"`), `aria-label="Images"`") — the spec's own literal word, not `Carousel`'s
|
|
189
|
+
* `slides` key: unlike the rest of this component's vocabulary (see `previousImage`/`imageOf`/
|
|
190
|
+
* `goToImage` above), the spec gives the track a specific, real word here rather than leaving it
|
|
191
|
+
* to this package's own generic choice, so it gets its own key instead of reusing `slides`. */
|
|
192
|
+
lightboxImages: "Images",
|
|
193
|
+
/** A `Textarea`'s remaining-characters hint, announced once at 80% of the limit. */
|
|
194
|
+
charactersLeft: (n) => `${n} ${n === 1 ? "character" : "characters"} left`,
|
|
195
|
+
/** A `Textarea`'s over-the-limit hint, announced once when the limit is passed. */
|
|
196
|
+
overLimit: (n) => `Over the limit by ${n}`,
|
|
197
|
+
/** A product that cannot be bought. `ProductCard`'s own sold-out `Badge`, and `StockBadge`'s
|
|
198
|
+
* default copy for `level="out"` — one key, not two, for the same English/Icelandic phrase. */
|
|
199
|
+
soldOut: "Sold out",
|
|
200
|
+
/**
|
|
201
|
+
* `ProductCard`'s "New" badge (spec "Product card" → Anatomy, part 2). A plain string, unlike
|
|
202
|
+
* `quickAdd` below: the word never takes a value, so it needs no function.
|
|
203
|
+
*/
|
|
204
|
+
newBadge: "New",
|
|
205
|
+
/**
|
|
206
|
+
* `ProductCard`'s quick-add button's *visible* text (spec "Product card" → Anatomy, part 8:
|
|
207
|
+
* "Quick add"). Separate from `quickAdd` below — see that key's own comment for why the two are
|
|
208
|
+
* not the same string.
|
|
209
|
+
*/
|
|
210
|
+
quickAddLabel: "Quick add",
|
|
211
|
+
/**
|
|
212
|
+
* `ProductCard`'s quick-add button's full accessible name (spec "Product card" → Accessibility:
|
|
213
|
+
* "Quick add names the product: 'Quick add' + hidden ' Merino crew sweater'"), a *function*
|
|
214
|
+
* rather than the visible label plus an appended title: the English spec text always puts the
|
|
215
|
+
* product name last, but a locale's natural word order need not — `is-IS`'s own translation
|
|
216
|
+
* puts it in the middle ("Setja {title} í körfu") — so the whole sentence has to be one
|
|
217
|
+
* catalogue entry a locale can reorder freely, not `quickAddLabel` plus a raw suffix glued on
|
|
218
|
+
* by the component. Applied as the button's `aria-label`, which replaces the *visible* text for
|
|
219
|
+
* accessible-name purposes (confirmed: a fallthrough `aria-label` on `<Button>` overrides its
|
|
220
|
+
* own computed one — see `ProductCard.vue`'s own comment), so the visible/hidden split the spec
|
|
221
|
+
* draws for English is honoured without constraining every locale to the same shape.
|
|
222
|
+
*/
|
|
223
|
+
quickAdd: (title) => `Quick add ${title}`,
|
|
224
|
+
/**
|
|
225
|
+
* `ProductCard`'s loading skeleton's accessible name (spec "Product card" → Variants, Loading
|
|
226
|
+
* row: `aria-label="Loading product"`).
|
|
227
|
+
*/
|
|
228
|
+
loadingProduct: "Loading product",
|
|
229
|
+
/**
|
|
230
|
+
* `ProductCard`'s colour dots' hidden summary (spec "Product card" → Anatomy, part 7: 'hidden
|
|
231
|
+
* "Available in 5 colours"'; → Accessibility: "Colour dots are `aria-hidden`, summarised by
|
|
232
|
+
* hidden 'Available in 5 colours'"). The dots themselves carry no text of their own.
|
|
233
|
+
*/
|
|
234
|
+
swatchesAvailable: (n) => `Available in ${n} ${n === 1 ? "colour" : "colours"}`,
|
|
235
|
+
/** `Image`'s live placeholder text, shown next to the photo icon when there is no `media` (spec
|
|
236
|
+
* "Image" → Variants, "Placeholder (live)" row). */
|
|
237
|
+
noImage: "No image",
|
|
238
|
+
/** `Image`'s live placeholder's accessible name (spec "Image" → Accessibility: 'otherwise it
|
|
239
|
+
* gets `role="img"` and `aria-label="No image available"`'), omitted when `decorative` is on. */
|
|
240
|
+
noImageAvailable: "No image available",
|
|
241
|
+
/**
|
|
242
|
+
* `LogoItem`'s default `linkContext` (spec "Logo item" → Properties, `linkContext` row: `"
|
|
243
|
+
* (stockist site)"` when `href` is external), appended to a linked logo's accessible name —
|
|
244
|
+
* "Kiln Street (stockist site)". Only used when `href` looks external and no `linkContext` was
|
|
245
|
+
* given; an on-site stockist page link gets no extra context.
|
|
246
|
+
*/
|
|
247
|
+
stockistSite: " (stockist site)",
|
|
248
|
+
/** A `StockBadge`'s default copy for `level="in"` (spec "Badge" → Stock status line). */
|
|
249
|
+
stockIn: "In stock, ships in 1–2 days",
|
|
250
|
+
/**
|
|
251
|
+
* A `StockBadge`'s default copy for `level="low"` (spec "Badge" → Stock status line): "Low
|
|
252
|
+
* stock: only 3 left" is the spec's own example with a quantity of 3. With no `quantity` there
|
|
253
|
+
* is nothing to count, so the copy drops the count rather than fabricate one.
|
|
254
|
+
*/
|
|
255
|
+
stockLow: (n) => n === null ? "Low stock" : `Low stock: only ${n} left`,
|
|
256
|
+
/**
|
|
257
|
+
* A `StockBadge`'s default copy for `level="preorder"` (spec "Badge" → Stock status line): the
|
|
258
|
+
* spec's own example is "Pre-order, ships 14 Nov", but `StockBadge` has no `date` prop to fill
|
|
259
|
+
* that in — a store that knows the ship date passes it here or overrides the whole line with
|
|
260
|
+
* `message`. With no date this reads as plain "Pre-order".
|
|
261
|
+
*/
|
|
262
|
+
stockPreorder: (date) => date === void 0 || date === "" ? "Pre-order" : `Pre-order, ships ${date}`,
|
|
263
|
+
/**
|
|
264
|
+
* A `Price`'s visually hidden label before the current amount when on sale (spec "Price" →
|
|
265
|
+
* Anatomy, part 2). `labels.sale` overrides it per instance.
|
|
266
|
+
*/
|
|
267
|
+
salePrice: "Sale price",
|
|
268
|
+
/**
|
|
269
|
+
* A `Price`'s visually hidden label before the compare-at amount when on sale (spec "Price" →
|
|
270
|
+
* Anatomy, part 3). `labels.regular` overrides it per instance.
|
|
271
|
+
*/
|
|
272
|
+
regularPrice: "Regular price",
|
|
273
|
+
/**
|
|
274
|
+
* A `Price`'s "From" label for a product whose variants differ in price (spec "Price" →
|
|
275
|
+
* Properties, `from` row). `labels.from` overrides it per instance.
|
|
276
|
+
*/
|
|
277
|
+
from: "From",
|
|
278
|
+
/**
|
|
279
|
+
* A `Price`'s unit-price line (spec "Price" → Anatomy, part 4): "$6.00 / 100 g" — this is the
|
|
280
|
+
* separator and unit half, appended after the formatted per-unit amount.
|
|
281
|
+
*/
|
|
282
|
+
perUnit: (per) => `/ ${per}`,
|
|
283
|
+
/**
|
|
284
|
+
* What a `Price` says in its live region while `revalidating` — a prerendered amount that is
|
|
285
|
+
* still on screen, dimmed, while a fresher one is fetched. Its own sentence rather than the
|
|
286
|
+
* generic `loading` above, because the two states are different news for a shopper: `loading`
|
|
287
|
+
* means there is no price yet, this means the price shown may be a moment out of date.
|
|
288
|
+
*/
|
|
289
|
+
updatingPrice: "Updating price",
|
|
290
|
+
/**
|
|
291
|
+
* The `StockBadge` half of `updatingPrice` — the same state on the stock line. Two keys, not one
|
|
292
|
+
* "Updating" with the noun spliced on: a locale's own wording for each need not share a stem,
|
|
293
|
+
* and the two are announced separately.
|
|
294
|
+
*/
|
|
295
|
+
updatingStock: "Updating stock",
|
|
296
|
+
/**
|
|
297
|
+
* `Rating`'s one accessible sentence (spec "Rating" → Accessibility: "the wrapper has `role="img"`
|
|
298
|
+
* and `aria-label="Rated 4.5 out of 5, 128 reviews"`"), reused verbatim as the linked variant's
|
|
299
|
+
* `aria-label` too — see `Rating.vue`'s own comment for why both forms share one sentence rather
|
|
300
|
+
* than the spec's separately worded linked hidden text. `value` is the already-rounded rating.
|
|
301
|
+
*/
|
|
302
|
+
rating: (value, count) => `Rated ${value.toFixed(1)} out of 5, ${count} ${reviewsWord(count)}`,
|
|
303
|
+
/** `Rating`'s no-reviews state (spec "Rating" → Variants, "No reviews" row): "count = 0 renders
|
|
304
|
+
* the no-reviews state ... never '0.0'." Read as normal text, not an `aria-label`. */
|
|
305
|
+
noReviews: "No reviews yet",
|
|
306
|
+
/**
|
|
307
|
+
* `Rating`'s linked-variant visible count text (spec "Rating" → Anatomy, part 3: "'(128)' on
|
|
308
|
+
* cards; '128 reviews' underlined when linked") — the one piece of `Rating`'s own text the task
|
|
309
|
+
* API contract's two named keys (`rating`, `noReviews`) do not cover: the card form's `"(128)"` is a
|
|
310
|
+
* literal parenthesised number with no word to pluralise, but the linked form's visible text is a
|
|
311
|
+
* real English/Icelandic sentence fragment and so must come from `useMessages()` like every other
|
|
312
|
+
* word this package renders.
|
|
313
|
+
*/
|
|
314
|
+
reviewCount: (n) => `${n} ${reviewsWord(n)}`,
|
|
315
|
+
/** The `SearchModal`'s field label. */
|
|
316
|
+
searchTheShop: "Search the shop",
|
|
317
|
+
/** The `SearchBar`'s results-panel name, and the `SearchModal`'s. */
|
|
318
|
+
searchSuggestions: "Search suggestions",
|
|
319
|
+
/** The heading of a search panel's product group. */
|
|
320
|
+
searchProducts: "Products",
|
|
321
|
+
/** The heading of a search panel's collection group. */
|
|
322
|
+
searchCollections: "Collections",
|
|
323
|
+
/** The heading of a search panel's articles-and-pages group. */
|
|
324
|
+
searchJournal: "Journal and help",
|
|
325
|
+
/** The line under a search panel's "No results" title, above the suggestion chips. */
|
|
326
|
+
searchAdvice: "Check the spelling, or try one of these.",
|
|
327
|
+
/** The `SearchModal`'s history group heading. */
|
|
328
|
+
recentSearches: "Recent searches",
|
|
329
|
+
/** The `SearchModal`'s suggestions group heading. */
|
|
330
|
+
popularSearches: "Popular searches",
|
|
331
|
+
/** Empties the search history (the spec's own row label). */
|
|
332
|
+
clearRecent: "Clear recent searches",
|
|
333
|
+
/**
|
|
334
|
+
* The live-region announcement after a search (spec "Search bar" -> Behaviour, Announcements:
|
|
335
|
+
* 'announces "4 results for mer" (singular "1 result for mer")'). The query is optional: a
|
|
336
|
+
* results count with nothing to name — a filtered list, a Search page heading — reads "4 results".
|
|
337
|
+
*/
|
|
338
|
+
resultsCount: (n, query) => query === void 0 || query === "" ? `${n} ${n === 1 ? "result" : "results"}` : `${n} ${n === 1 ? "result" : "results"} for “${query}”`,
|
|
339
|
+
/**
|
|
340
|
+
* The last row of a search results panel, which opens the full results page (spec "Search bar":
|
|
341
|
+
* '"See all N results for “q”" is always the last row'). The query is optional, for a panel that
|
|
342
|
+
* has none to show — the Search modal's own "See all n results" row.
|
|
343
|
+
*/
|
|
344
|
+
viewAllResults: (n, query) => {
|
|
345
|
+
const count = n === 1 ? "See 1 result" : `See all ${n} results`;
|
|
346
|
+
return query === void 0 || query === "" ? count : `${count} for “${query}”`;
|
|
347
|
+
},
|
|
348
|
+
/**
|
|
349
|
+
* What a search control's live region says while a request for the current query is still out —
|
|
350
|
+
* `SearchBar`/`SearchModal` announce this instead of a count (spec "Search bar" → Behaviour,
|
|
351
|
+
* Announcements). Until a response for *that* query exists there is nothing to count, and
|
|
352
|
+
* `noResultsFor` would be a wrong answer rather than an empty one — the same distinction the
|
|
353
|
+
* `loading` and `none` panel views draw, in the channel a screen reader hears.
|
|
354
|
+
*/
|
|
355
|
+
searchLoading: "Searching…",
|
|
356
|
+
/** The keyboard hint beside a search control. */
|
|
357
|
+
shortcutHint: "Press / to search",
|
|
358
|
+
/** The `SearchModal`'s foot, first hint (spec "Search modal" → Anatomy, item 6: "↑↓ to move").
|
|
359
|
+
* Read after a key-cap pair, `aria-hidden` alongside it — screen readers get the combobox
|
|
360
|
+
* semantics instead (spec → Accessibility). */
|
|
361
|
+
searchMoveHint: "to move",
|
|
362
|
+
/** The `SearchModal`'s foot, second hint ("↵ to open"). */
|
|
363
|
+
searchOpenHint: "to open",
|
|
364
|
+
/** The `SearchModal`'s foot, third hint ("esc to clear or close"). */
|
|
365
|
+
searchEscHint: "to clear or close",
|
|
366
|
+
/** The label of an error region. */
|
|
367
|
+
error: "Error",
|
|
368
|
+
/** `EmptyState`'s built-in "Try again" button (`variant="error"`, no `actions` slot given). */
|
|
369
|
+
tryAgain: "Try again",
|
|
370
|
+
/**
|
|
371
|
+
* The error summary's own line in the `./vee-validate` entry's `Form` (spec "Form layout" ->
|
|
372
|
+
* States, Invalid on submit: "Long forms add an error summary alert at the top ... that lists a
|
|
373
|
+
* link to each error"). The links below it are the messages themselves, so this one only has to
|
|
374
|
+
* say how many there are.
|
|
375
|
+
*/
|
|
376
|
+
formErrors: (n) => n === 1 ? "There is 1 problem with this form" : `There are ${n} problems with this form`,
|
|
377
|
+
/**
|
|
378
|
+
* `AvatarGroup`'s one accessible sentence (spec "Avatar" → Accessibility: "A group gets one
|
|
379
|
+
* name: `role="group"`, `aria-label="Makers: Ingrid, Tomas, Maya and 4 more"`"). `names` is the
|
|
380
|
+
* visible avatars' own names, in order; `more` is however many more people the group holds
|
|
381
|
+
* beyond those — `0` when every person in the group already has a visible avatar, in which case
|
|
382
|
+
* the sentence is just `label` plus the plain conjunction list with nothing appended.
|
|
383
|
+
*/
|
|
384
|
+
avatarGroup: (label, names, more) => {
|
|
385
|
+
const items = more > 0 ? [...names, `${more} more`] : names;
|
|
386
|
+
return `${label}: ${formatConjunctionList(items, "en-US")}`;
|
|
387
|
+
},
|
|
388
|
+
/** A `FeatureCard`'s default link cue when linked (spec "Feature card" → Properties, `cue` row:
|
|
389
|
+
* default `"Learn more"`). `cue` overrides it per instance. */
|
|
390
|
+
learnMore: "Learn more",
|
|
391
|
+
/** `Breadcrumb`'s landmark name (spec "Breadcrumb" → Accessibility: `<nav aria-label=
|
|
392
|
+
* "Breadcrumb">`). */
|
|
393
|
+
breadcrumbLabel: "Breadcrumb",
|
|
394
|
+
/**
|
|
395
|
+
* `Breadcrumb`'s ellipsis button (spec "Breadcrumb" → Accessibility: `<button type="button"
|
|
396
|
+
* aria-label="Show 3 more levels">`, "the count is the number of hidden levels"). `n` is always
|
|
397
|
+
* the number of collapsed middle items, so the same rule reads "Show 1 more level" for a single
|
|
398
|
+
* hidden level rather than the spec's own three-level example.
|
|
399
|
+
*/
|
|
400
|
+
showMoreLevels: (n) => n === 1 ? "Show 1 more level" : `Show ${n} more levels`,
|
|
401
|
+
/** `NavMenu`'s landmark name, the default for its `ariaLabel` prop. */
|
|
402
|
+
navMenuLabel: "Main",
|
|
403
|
+
/** `NavMenu`'s narrow-screen menu button. */
|
|
404
|
+
navMenuOpen: "Menu",
|
|
405
|
+
/** The name of the drawer `NavMenu`'s menu button opens. */
|
|
406
|
+
navMenuDrawer: "Menu",
|
|
407
|
+
/** The link to a top-level entry's own page, first in its panel. */
|
|
408
|
+
navMenuOverview: (label) => `${label}: overview`,
|
|
409
|
+
/** `Pagination`'s `<nav>` accessible name (spec "Pagination" → Accessibility:
|
|
410
|
+
* `<nav aria-label="Pagination">`), the default for its `ariaLabel` prop. */
|
|
411
|
+
pagination: "Pagination",
|
|
412
|
+
/**
|
|
413
|
+
* `Pagination`'s previous control, in both forms: the numbered form's visible "Previous page"
|
|
414
|
+
* link text and the compact form's icon-only `aria-label`. The design spec's own anatomy gives
|
|
415
|
+
* the numbered form a shorter visible "Previous" — this package uses the one fuller phrase for
|
|
416
|
+
* both, rather than a second, unspecified sentence for the compact icon-only arrow (see the
|
|
417
|
+
* README's Deviations entry).
|
|
418
|
+
*/
|
|
419
|
+
previousPage: "Previous page",
|
|
420
|
+
/** `Pagination`'s next control — see `previousPage` above. */
|
|
421
|
+
nextPage: "Next page",
|
|
422
|
+
/**
|
|
423
|
+
* A `Pagination` page link's accessible name (spec "Pagination" → Accessibility: `aria-label="Page
|
|
424
|
+
* 7"`; the current one `aria-label="Page 6, current page"`). One message, not two: `current`
|
|
425
|
+
* defaults to `false`, so `pageN(7)` and `pageN(6, true)` share a single translatable sentence
|
|
426
|
+
* rather than a second key existing only to append four words.
|
|
427
|
+
*/
|
|
428
|
+
pageN: (n, current = false) => current ? `Page ${n}, current page` : `Page ${n}`,
|
|
429
|
+
/**
|
|
430
|
+
* `Pagination`'s compact-form status (spec "Pagination" → Anatomy, part 6: "Page 2 of 12"). Not
|
|
431
|
+
* one of the message keys the API contract names explicitly, but the compact form has no other way
|
|
432
|
+
* to say it: unlike `pageN`, the sentence needs the total baked in, and generating it from two
|
|
433
|
+
* separate calls would leave "of" untranslated. Recorded under the README's Deviations entry.
|
|
434
|
+
*/
|
|
435
|
+
pageOfTotal: (page, total) => `Page ${page} of ${total}`,
|
|
436
|
+
/**
|
|
437
|
+
* `LoadMore`'s live status (spec "Pagination" → Anatomy, part 7: "Showing 24 of 96 products").
|
|
438
|
+
* `noun` is the caller's own word (the `noun` prop), already declined for this sentence — the
|
|
439
|
+
* same shape `QuantityStepper`'s `unit` prop follows.
|
|
440
|
+
*/
|
|
441
|
+
showingOf: (shown, total, noun) => `Showing ${shown} of ${total} ${noun}`,
|
|
442
|
+
/** `LoadMore`'s button label (spec "Pagination" → Anatomy, part 9). */
|
|
443
|
+
loadMore: "Load more",
|
|
444
|
+
/** The `FilterPanel` head's visible title (spec "Filter panel" → Properties, `title`). */
|
|
445
|
+
filterPanelTitle: "Filters",
|
|
446
|
+
/** The `<form>`'s accessible name (spec → Properties, `label`). */
|
|
447
|
+
filterPanelLabel: "Product filters",
|
|
448
|
+
/**
|
|
449
|
+
* The head's reset button, and the drawer foot's (spec → Anatomy item 1). Deliberately not the
|
|
450
|
+
* plain `clear` above, which is a field's own "Clear": this one empties every facet at once, and
|
|
451
|
+
* the spec gives it these two words.
|
|
452
|
+
*/
|
|
453
|
+
filterPanelClearAll: "Clear all",
|
|
454
|
+
/** The applied-chip list's accessible name (spec → Accessibility: 'a list labelled "Active
|
|
455
|
+
* filters"'). */
|
|
456
|
+
filterPanelApplied: "Active filters",
|
|
457
|
+
/**
|
|
458
|
+
* An applied chip's remove button (spec → Accessibility: 'each remove button is labelled "Remove
|
|
459
|
+
* filter Colour: Brown"'). Both halves are named, because a chip reads "Brown" and a shopper
|
|
460
|
+
* with four chips has to hear which facet each one belongs to.
|
|
461
|
+
*/
|
|
462
|
+
filterPanelRemoveFilter: (facet, value) => `Remove filter ${facet}: ${value}`,
|
|
463
|
+
/** The button under a truncated list (spec → Anatomy item 5). `n` is the facet's *whole* count,
|
|
464
|
+
* not the hidden remainder — the spec's own "Show all 12" on a list of twelve. */
|
|
465
|
+
filterPanelShowAll: (n) => `Show all ${n}`,
|
|
466
|
+
/** The same button once the list is open (spec → Behaviour: "changes to **Show fewer**"). */
|
|
467
|
+
filterPanelShowFewer: "Show fewer",
|
|
468
|
+
/** A long list's search field, its accessible name (spec → Accessibility: 'labelled "Search
|
|
469
|
+
* material values"'). */
|
|
470
|
+
filterPanelSearchLabel: (facet) => `Search ${facet} values`,
|
|
471
|
+
/** The same field's placeholder (spec → Accessibility: 'placeholder "Search material"'). */
|
|
472
|
+
filterPanelSearchPlaceholder: (facet) => `Search ${facet}`,
|
|
473
|
+
/**
|
|
474
|
+
* One value's whole accessible name: its label and what it would leave (spec → Accessibility:
|
|
475
|
+
* '"Sweaters, 18 products"', '"Brown, 9 products"'). One sentence rather than a visible number
|
|
476
|
+
* with hidden words around it, so a translation can put the count where its own grammar wants it.
|
|
477
|
+
*/
|
|
478
|
+
filterPanelValueName: (label, count) => `${label}, ${count} ${count === 1 ? "product" : "products"}`,
|
|
479
|
+
/**
|
|
480
|
+
* A size tile's accessible name, which names its size system as well (spec → Accessibility:
|
|
481
|
+
* '"Knitwear M, 14 products"'). A size on its own is ambiguous the moment a store sells two
|
|
482
|
+
* systems — "42" is a shoe and a sock.
|
|
483
|
+
*/
|
|
484
|
+
filterPanelSizeName: (system, label, count) => `${system} ${label}, ${count} ${count === 1 ? "product" : "products"}`,
|
|
485
|
+
/** Appended to a value nothing is left for (spec → Accessibility: '", none available"'). Include
|
|
486
|
+
* the leading comma and space: the component renders it verbatim after the name above. */
|
|
487
|
+
filterPanelNoneAvailable: ", none available",
|
|
488
|
+
/**
|
|
489
|
+
* Said of a value ticked because its parent is, not because it is a filter of its own — the
|
|
490
|
+
* request carries the parent's value and the platform expands it. Said out loud because a
|
|
491
|
+
* ticked, disabled box with no explanation reads as a dead end. The leading space is the
|
|
492
|
+
* component's to add, not this string's.
|
|
493
|
+
*/
|
|
494
|
+
filterPanelImpliedBy: (parent) => `included in ${parent}`,
|
|
495
|
+
/** Names the nested rows under one value (spec: a real grouping, and no extra tab stop). */
|
|
496
|
+
filterPanelUnder: (parent) => `Under ${parent}`,
|
|
497
|
+
/** The link under a size facet's tiles (spec → Anatomy item 9). */
|
|
498
|
+
filterPanelSizeGuide: "Size guide",
|
|
499
|
+
/** The visible label of a range facet's lower field (spec → Anatomy item 12). */
|
|
500
|
+
filterPanelMin: "Min",
|
|
501
|
+
/** The upper one. */
|
|
502
|
+
filterPanelMax: "Max",
|
|
503
|
+
/**
|
|
504
|
+
* Appended to a range facet's **maximum** thumb while it sits at the facet's own limit (spec →
|
|
505
|
+
* Behaviour: 'the top thumb at the maximum adds " or more" ("$240 or more")'). Above the
|
|
506
|
+
* catalogue's highest value there is nothing left to exclude, and "$240" would claim otherwise.
|
|
507
|
+
* Include the leading space: the component appends it to the formatted number verbatim.
|
|
508
|
+
*/
|
|
509
|
+
filterPanelOrMore: " or more",
|
|
510
|
+
/** The drawer foot's apply button (spec → Anatomy item 14: "**Show N products**"). */
|
|
511
|
+
filterPanelShowResults: (n) => n === 1 ? "Show 1 product" : `Show ${n} products`,
|
|
512
|
+
/**
|
|
513
|
+
* The same button before any count has arrived. The drawer's number is the owning block's own
|
|
514
|
+
* pending-count read, which a panel mounted ahead of it does not have yet — and a button that
|
|
515
|
+
* said "Show 0 products" while the read was in flight would be a number nobody can trust.
|
|
516
|
+
*/
|
|
517
|
+
filterPanelShowProducts: "Show products",
|
|
518
|
+
/** `SiteForm`'s submit button. The field messages below are the platform's own `422` wording. */
|
|
519
|
+
formSubmit: "Send",
|
|
520
|
+
/** The submit button's accessible name while the submission is on its way. */
|
|
521
|
+
formSubmitting: "Sending",
|
|
522
|
+
formLoading: "Loading the form…",
|
|
523
|
+
formLoadFailed: "This form can’t be shown right now.",
|
|
524
|
+
formRequired: "This field is required.",
|
|
525
|
+
formRequiredCheckbox: "Tick this box to continue.",
|
|
526
|
+
formInvalidEmail: "Enter a valid email address.",
|
|
527
|
+
formInvalidNumber: "Enter a number, for example 12 or 3.5.",
|
|
528
|
+
formInvalidUrl: "Enter a full web address starting with http:// or https://.",
|
|
529
|
+
formInvalidOption: "Choose one of the options.",
|
|
530
|
+
formInvalidFormat: "Check the format of this value.",
|
|
531
|
+
formTooShort: (min) => `This is too short (at least ${min} ${min === 1 ? "character" : "characters"}).`,
|
|
532
|
+
formTooLong: (max) => `This is too long (at most ${max} ${max === 1 ? "character" : "characters"}).`,
|
|
533
|
+
/** A refusal the platform sent no message for. */
|
|
534
|
+
formRefused: "Check your answers and try again.",
|
|
535
|
+
formRateLimited: "Too many attempts. Wait a minute and try again.",
|
|
536
|
+
formTooLarge: "That is more than the form can take. Shorten your answers and try again.",
|
|
537
|
+
formUnavailable: "The form could not be sent just now. Try again in a minute.",
|
|
538
|
+
formSpamCheckRequired: "Complete the spam check and try again.",
|
|
539
|
+
formSpamCheckFailed: "The spam check could not load. Reload the page and try again.",
|
|
540
|
+
formSuccessTitle: "Thank you",
|
|
541
|
+
/** A subscribing form's success: the address is confirmed from an email. */
|
|
542
|
+
formPendingTitle: "Check your inbox",
|
|
543
|
+
formPendingMessage: "We sent you an email. Open the link in it to confirm."
|
|
544
|
+
};
|
|
545
|
+
// src/composables/useMessages.ts
|
|
546
|
+
/**
|
|
547
|
+
* The injection key the messages provider writes to. Exported so an app can
|
|
548
|
+
* set the messages from outside a `setup()` scope:
|
|
549
|
+
*
|
|
550
|
+
* ```ts
|
|
551
|
+
* import { MESSAGES_KEY } from '@eldrajs/ui';
|
|
552
|
+
* import { isIS } from '@eldrajs/ui/messages/is-IS';
|
|
553
|
+
* app.provide(MESSAGES_KEY, isIS);
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
556
|
+
var MESSAGES_KEY = Symbol("eldra-ui-messages");
|
|
557
|
+
/**
|
|
558
|
+
* Set the message overrides for this component and everything below it.
|
|
559
|
+
*
|
|
560
|
+
* Wraps Vue's `provide`, so it must be called during `setup()`. Use
|
|
561
|
+
* `app.provide(MESSAGES_KEY, messages)` for the app-wide case.
|
|
562
|
+
*/
|
|
563
|
+
function provideEldraUiMessages(messages) {
|
|
564
|
+
provide(MESSAGES_KEY, messages);
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Drops keys whose value is `undefined`, so a `messages` prop assembled from
|
|
568
|
+
* optional values (`{ close: props.closeLabel }`) cannot blank out a default.
|
|
569
|
+
*/
|
|
570
|
+
function defined(messages) {
|
|
571
|
+
if (!messages) return {};
|
|
572
|
+
const result = {};
|
|
573
|
+
for (const [key, value] of Object.entries(messages)) if (value !== void 0) result[key] = value;
|
|
574
|
+
return result;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* The messages a component should render, resolved in precedence order:
|
|
578
|
+
* the English defaults, then whatever an ancestor provided, then the
|
|
579
|
+
* component's own `messages` prop.
|
|
580
|
+
*
|
|
581
|
+
* No i18n library is involved; a store either accepts English, imports
|
|
582
|
+
* `@eldrajs/ui/messages/is-IS`, or passes its own strings.
|
|
583
|
+
*/
|
|
584
|
+
function useMessages(override) {
|
|
585
|
+
const provided = inject(MESSAGES_KEY, void 0);
|
|
586
|
+
return computed(() => ({
|
|
587
|
+
...enUS,
|
|
588
|
+
...defined(provided),
|
|
589
|
+
...defined(toValue(override))
|
|
590
|
+
}));
|
|
591
|
+
}
|
|
592
|
+
export { enUS as i, provideEldraUiMessages as n, useMessages as r, MESSAGES_KEY as t };
|