@techsio/ui-kit 0.59.3 → 0.60.0

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 (113) hide show
  1. package/README.md +32 -0
  2. package/dist/atoms/label.js +3 -2
  3. package/dist/atoms/numeric-input.js +12 -4
  4. package/dist/atoms/rating.js +21 -9
  5. package/dist/atoms/skeleton.js +9 -3
  6. package/dist/internal/popover-template-content.js +13 -0
  7. package/dist/internal/required-label-text.js +12 -0
  8. package/dist/messages/ui-messages-provider.js +47 -0
  9. package/dist/messages/ui-messages.js +273 -0
  10. package/dist/molecules/carousel.js +11 -4
  11. package/dist/molecules/cascade-select.js +10 -6
  12. package/dist/molecules/chart.js +12 -8
  13. package/dist/molecules/color-select.js +9 -6
  14. package/dist/molecules/combobox.js +22 -16
  15. package/dist/molecules/date-picker.js +46 -31
  16. package/dist/molecules/dialog.js +5 -3
  17. package/dist/molecules/drawer.js +3 -1
  18. package/dist/molecules/file-upload.js +19 -8
  19. package/dist/molecules/form-error-summary.js +4 -2
  20. package/dist/molecules/menu.js +4 -2
  21. package/dist/molecules/pagination.js +12 -3
  22. package/dist/molecules/phone-input.js +24 -7
  23. package/dist/molecules/popover.js +9 -1
  24. package/dist/molecules/search-form.js +9 -5
  25. package/dist/molecules/select.js +16 -6
  26. package/dist/molecules/steps.js +6 -3
  27. package/dist/molecules/tabs.js +3 -0
  28. package/dist/molecules/toast.js +5 -3
  29. package/dist/molecules/tour.js +10 -2
  30. package/dist/molecules/tree-view.js +9 -1
  31. package/dist/organisms/data-table.fields.js +82 -65
  32. package/dist/organisms/data-table.js +90 -74
  33. package/dist/organisms/gallery.js +6 -5
  34. package/dist/organisms/header.js +4 -2
  35. package/dist/src/atoms/label.d.ts +2 -2
  36. package/dist/src/atoms/label.d.ts.map +1 -1
  37. package/dist/src/atoms/numeric-input.d.ts +1 -1
  38. package/dist/src/atoms/numeric-input.d.ts.map +1 -1
  39. package/dist/src/atoms/rating.d.ts +1 -1
  40. package/dist/src/atoms/rating.d.ts.map +1 -1
  41. package/dist/src/atoms/skeleton.d.ts +1 -1
  42. package/dist/src/atoms/skeleton.d.ts.map +1 -1
  43. package/dist/src/internal/popover-template-content.d.ts +11 -0
  44. package/dist/src/internal/popover-template-content.d.ts.map +1 -0
  45. package/dist/src/internal/required-label-text.d.ts +3 -0
  46. package/dist/src/internal/required-label-text.d.ts.map +1 -0
  47. package/dist/src/messages/ui-messages-provider.d.ts +18 -0
  48. package/dist/src/messages/ui-messages-provider.d.ts.map +1 -0
  49. package/dist/src/messages/ui-messages.d.ts +331 -0
  50. package/dist/src/messages/ui-messages.d.ts.map +1 -0
  51. package/dist/src/molecules/carousel.d.ts +1 -1
  52. package/dist/src/molecules/carousel.d.ts.map +1 -1
  53. package/dist/src/molecules/cascade-select.d.ts +2 -2
  54. package/dist/src/molecules/cascade-select.d.ts.map +1 -1
  55. package/dist/src/molecules/chart.d.ts.map +1 -1
  56. package/dist/src/molecules/color-select.d.ts +1 -1
  57. package/dist/src/molecules/color-select.d.ts.map +1 -1
  58. package/dist/src/molecules/combobox.d.ts +2 -2
  59. package/dist/src/molecules/combobox.d.ts.map +1 -1
  60. package/dist/src/molecules/date-picker.d.ts +11 -8
  61. package/dist/src/molecules/date-picker.d.ts.map +1 -1
  62. package/dist/src/molecules/dialog.d.ts +1 -1
  63. package/dist/src/molecules/dialog.d.ts.map +1 -1
  64. package/dist/src/molecules/drawer.d.ts.map +1 -1
  65. package/dist/src/molecules/file-upload.d.ts +1 -1
  66. package/dist/src/molecules/file-upload.d.ts.map +1 -1
  67. package/dist/src/molecules/form-error-summary.d.ts +1 -1
  68. package/dist/src/molecules/form-error-summary.d.ts.map +1 -1
  69. package/dist/src/molecules/menu.d.ts +1 -1
  70. package/dist/src/molecules/menu.d.ts.map +1 -1
  71. package/dist/src/molecules/pagination.d.ts +1 -1
  72. package/dist/src/molecules/pagination.d.ts.map +1 -1
  73. package/dist/src/molecules/phone-input.d.ts +1 -1
  74. package/dist/src/molecules/phone-input.d.ts.map +1 -1
  75. package/dist/src/molecules/popover.d.ts +1 -1
  76. package/dist/src/molecules/popover.d.ts.map +1 -1
  77. package/dist/src/molecules/product-card.d.ts +1 -1
  78. package/dist/src/molecules/search-form.d.ts +1 -1
  79. package/dist/src/molecules/search-form.d.ts.map +1 -1
  80. package/dist/src/molecules/select.d.ts +1 -1
  81. package/dist/src/molecules/select.d.ts.map +1 -1
  82. package/dist/src/molecules/steps.d.ts.map +1 -1
  83. package/dist/src/molecules/tabs.d.ts.map +1 -1
  84. package/dist/src/molecules/toast.d.ts +4 -4
  85. package/dist/src/molecules/toast.d.ts.map +1 -1
  86. package/dist/src/molecules/tour.d.ts +1 -1
  87. package/dist/src/molecules/tour.d.ts.map +1 -1
  88. package/dist/src/molecules/tree-view.d.ts.map +1 -1
  89. package/dist/src/organisms/data-table.d.ts +4 -48
  90. package/dist/src/organisms/data-table.d.ts.map +1 -1
  91. package/dist/src/organisms/data-table.fields.d.ts +6 -1
  92. package/dist/src/organisms/data-table.fields.d.ts.map +1 -1
  93. package/dist/src/organisms/gallery.d.ts +2 -2
  94. package/dist/src/organisms/gallery.d.ts.map +1 -1
  95. package/dist/src/organisms/header.d.ts +1 -1
  96. package/dist/src/organisms/header.d.ts.map +1 -1
  97. package/dist/src/templates/carousel.d.ts +1 -1
  98. package/dist/src/templates/facet-filter-panel.d.ts +1 -1
  99. package/dist/src/templates/facet-filter-panel.d.ts.map +1 -1
  100. package/dist/src/templates/gallery.d.ts +1 -1
  101. package/dist/src/templates/numeric-input.d.ts +1 -1
  102. package/dist/src/templates/popover.d.ts +1 -1
  103. package/dist/src/templates/popover.d.ts.map +1 -1
  104. package/dist/src/templates/product-card.d.ts +1 -1
  105. package/dist/src/templates/product-card.d.ts.map +1 -1
  106. package/dist/src/templates/select.d.ts +1 -1
  107. package/dist/src/templates/tabs.d.ts +1 -1
  108. package/dist/src/theme/theme-toggle.d.ts.map +1 -1
  109. package/dist/templates/facet-filter-panel.js +16 -11
  110. package/dist/templates/popover.js +5 -4
  111. package/dist/templates/product-card.js +12 -8
  112. package/dist/theme/theme-toggle.js +10 -8
  113. package/package.json +5 -1
package/README.md CHANGED
@@ -49,6 +49,38 @@ export function CheckoutAction() {
49
49
  }
50
50
  ```
51
51
 
52
+ ## Language
53
+
54
+ The kit has no fixed language. Every word a component shows or announces on
55
+ its own (placeholders, close buttons, table and filter labels, screen-reader
56
+ announcements, validation messages, zag-js labels) comes from one typed
57
+ catalog, `UiMessages`. English ships as `enUiMessages` and applies without
58
+ setup. An app in another language passes its catalog once, near the root:
59
+
60
+ ```tsx
61
+ import type { UiMessagesInput } from '@techsio/ui-kit/messages/ui-messages'
62
+ import { UiMessagesProvider } from '@techsio/ui-kit/messages/ui-messages-provider'
63
+
64
+ const csMessages: UiMessagesInput = {
65
+ locale: 'cs-CZ',
66
+ label: { required: '(povinné)' },
67
+ dialog: { close: 'Zavřít dialog' },
68
+ dataTable: { selectRowLabel: (row) => `Vybrat ${row}` },
69
+ }
70
+
71
+ export function AppProviders({ children }: { children: React.ReactNode }) {
72
+ return <UiMessagesProvider messages={csMessages}>{children}</UiMessagesProvider>
73
+ }
74
+ ```
75
+
76
+ - Any subset works; missing entries fall back to an outer provider, then English.
77
+ - Messages that include a value are functions, so a translation orders words its own way.
78
+ - `locale` is the default formatting locale for components that format numbers or dates.
79
+ - A text passed as a prop to one component (`placeholder`, `closeLabel`, `translations`, …) still wins over the catalog.
80
+ - Define the catalog as a module constant or memoize it, so components do not re-render.
81
+ - Server components stay server components; only the parts that read the catalog run on the client.
82
+ - One provider covers every copy of the kit on the page, so module-federation remotes that bundle their own copy follow the host's provider.
83
+
52
84
  ## Brands and modes
53
85
 
54
86
  Brand selection uses `data-theme` on `html`; mode uses one `.light` or `.dark`
@@ -1,4 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { RequiredLabelText } from "../internal/required-label-text.js";
2
3
  import { tv } from "../utils.js";
3
4
  const labelVariants = tv({
4
5
  base: [
@@ -22,7 +23,7 @@ const labelVariants = tv({
22
23
  disabled: false
23
24
  }
24
25
  });
25
- function Label({ size, disabled, required, requiredLabel = "(required)", children, className, ...props }) {
26
+ function Label({ size, disabled, required, requiredLabel, children, className, ...props }) {
26
27
  return /*#__PURE__*/ jsxs("label", {
27
28
  className: labelVariants({
28
29
  size,
@@ -40,7 +41,7 @@ function Label({ size, disabled, required, requiredLabel = "(required)", childre
40
41
  className: "ms-label-required text-label-fg-required",
41
42
  children: "*"
42
43
  }),
43
- requiredLabel && /*#__PURE__*/ jsx("span", {
44
+ void 0 === requiredLabel ? /*#__PURE__*/ jsx(RequiredLabelText, {}) : requiredLabel && /*#__PURE__*/ jsx("span", {
44
45
  className: "sr-only",
45
46
  children: ` ${requiredLabel}`
46
47
  })
@@ -6,6 +6,8 @@ import { flushSync } from "react-dom";
6
6
  import { isSilentChoiceReset, mergeChoiceInputProps, runSilentChoiceReset, trackChoiceFormControl } from "../internal/choice-control.js";
7
7
  import { joinDescribedBy, useDescribedBy, useRegisterDescription } from "../internal/described-by.js";
8
8
  import { createNumericInputEditing, syncNumericInputValue } from "../internal/numeric-input-editing.js";
9
+ import { definedEntries } from "../messages/ui-messages.js";
10
+ import { useUiMessages } from "../messages/ui-messages-provider.js";
9
11
  import { tv } from "../utils.js";
10
12
  import { Button } from "./button.js";
11
13
  import { Input } from "./input.js";
@@ -203,7 +205,9 @@ function useNumericInputContext() {
203
205
  if (!context) throw new Error("NumericInput components must be used within NumericInput.Root");
204
206
  return context;
205
207
  }
206
- function NumericInput({ density, id, size, value, defaultValue, onChange, validateStatus = "default", dir = "ltr", describedBy, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, "aria-invalid": ariaInvalid, precision, children, ref, className, locale = "cs-CZ", ...props }) {
208
+ function NumericInput({ density, id, size, value, defaultValue, onChange, validateStatus = "default", dir = "ltr", describedBy, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, "aria-invalid": ariaInvalid, precision, children, ref, className, locale, ...props }) {
209
+ const messages = useUiMessages();
210
+ const resolvedLocale = locale ?? messages.locale ?? "cs-CZ";
207
211
  const generatedId = useId();
208
212
  const [inputId, setInputId] = useState();
209
213
  const description = useDescribedBy();
@@ -219,7 +223,7 @@ function NumericInput({ density, id, size, value, defaultValue, onChange, valida
219
223
  const formatValue = (inputValue)=>{
220
224
  if ("number" == typeof inputValue && !Number.isFinite(inputValue)) return "";
221
225
  if ("string" == typeof inputValue || !resolvedFormatOptions) return String(inputValue);
222
- return new Intl.NumberFormat(locale, resolvedFormatOptions).format(inputValue);
226
+ return new Intl.NumberFormat(resolvedLocale, resolvedFormatOptions).format(inputValue);
223
227
  };
224
228
  const parseDraft = useRef(Number.parseFloat);
225
229
  const [editing] = useState(()=>createNumericInputEditing((draft)=>parseDraft.current(draft)));
@@ -286,7 +290,11 @@ function NumericInput({ density, id, size, value, defaultValue, onChange, valida
286
290
  input: inputId ?? machineProps.ids?.input ?? id
287
291
  } : machineProps.ids,
288
292
  dir,
289
- locale,
293
+ locale: resolvedLocale,
294
+ translations: {
295
+ ...messages.numericInput.translations,
296
+ ...definedEntries(machineProps.translations)
297
+ },
290
298
  value: resolvedValue,
291
299
  defaultValue: void 0 === defaultValue ? void 0 : formatValue(defaultValue),
292
300
  formatOptions: resolvedFormatOptions,
@@ -324,7 +332,7 @@ function NumericInput({ density, id, size, value, defaultValue, onChange, valida
324
332
  let isValidInputDraft;
325
333
  if (resolvedFormatOptions) {
326
334
  if (0 === resolvedFormatOptions.maximumFractionDigits && (!resolvedFormatOptions.style || "decimal" === resolvedFormatOptions.style)) {
327
- const separator = new Intl.NumberFormat(locale).formatToParts(1.1).find((part)=>"decimal" === part.type)?.value;
335
+ const separator = new Intl.NumberFormat(resolvedLocale).formatToParts(1.1).find((part)=>"decimal" === part.type)?.value;
328
336
  if (separator) isValidInputDraft = (draft)=>{
329
337
  const integerDraft = draft.replace(separator, "");
330
338
  return !integerDraft.includes(separator) && service.computed("parser").isValidPartialNumber(integerDraft);
@@ -7,6 +7,8 @@ import { isSilentChoiceReset, runSilentChoiceReset, trackChoiceFormControl, useC
7
7
  import { joinDescribedBy } from "../internal/described-by.js";
8
8
  import { isEffectivelyDisabled, syncReactFormControl } from "../internal/form-control-lifecycle.js";
9
9
  import { useEffectiveDisabled } from "../internal/use-effective-disabled.js";
10
+ import { definedEntries } from "../messages/ui-messages.js";
11
+ import { useUiMessages } from "../messages/ui-messages-provider.js";
10
12
  import { tv } from "../utils.js";
11
13
  import { Label } from "./label.js";
12
14
  import { StatusText } from "./status-text.js";
@@ -145,6 +147,11 @@ const rating = tv({
145
147
  });
146
148
  function Rating({ value, defaultValue = 0, count = 5, labelText, readOnly: readOnlyProp = false, displayOnly = false, disabled: disabledProp = false, allowHalf = true, name, dir = "ltr", translations, helpText, validateStatus = "default", onChange, onHoverChange, size = "md", className, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
147
149
  const readOnly = readOnlyProp || displayOnly;
150
+ const messages = useUiMessages();
151
+ const zagTranslations = {
152
+ ...messages.rating.translations,
153
+ ...definedEntries(translations)
154
+ };
148
155
  const [controlElement, setControlElement] = useState(null);
149
156
  const disabled = useEffectiveDisabled(controlElement, disabledProp);
150
157
  const generatedId = useId();
@@ -174,7 +181,7 @@ function Rating({ value, defaultValue = 0, count = 5, labelText, readOnly: readO
174
181
  allowHalf,
175
182
  name,
176
183
  dir,
177
- translations,
184
+ translations: zagTranslations,
178
185
  onValueChange: ({ value: newValue })=>{
179
186
  if (interactive && !isSilentChoiceReset(service.context)) onChange?.(newValue);
180
187
  },
@@ -234,7 +241,7 @@ function Rating({ value, defaultValue = 0, count = 5, labelText, readOnly: readO
234
241
  }),
235
242
  /*#__PURE__*/ jsx("div", {
236
243
  className: styles.control(),
237
- ...getRatingControlProps(api, isDisplay, labelText, ariaLabel, ariaLabelledBy),
244
+ ...getRatingControlProps(api, isDisplay, labelText, ariaLabel, ariaLabelledBy, messages),
238
245
  "aria-describedby": describedBy,
239
246
  "aria-errormessage": errorMessageId,
240
247
  "aria-invalid": invalid || void 0,
@@ -248,9 +255,10 @@ function Rating({ value, defaultValue = 0, count = 5, labelText, readOnly: readO
248
255
  errorMessageId: errorMessageId,
249
256
  invalid: invalid,
250
257
  isDisplay: isDisplay,
258
+ itemValueText: messages.rating.itemValueText,
251
259
  showExactValue: readOnly,
252
260
  styles: styles,
253
- translations: translations
261
+ translations: zagTranslations
254
262
  })
255
263
  }),
256
264
  /*#__PURE__*/ jsx("span", {
@@ -288,24 +296,28 @@ function RatingLabel({ api, labelText, size, isDisplay, disabled }) {
288
296
  children: labelText
289
297
  });
290
298
  }
291
- function getRatingControlProps(api, isDisplay, labelText, ariaLabel, ariaLabelledBy) {
299
+ function getRatingControlProps(api, isDisplay, labelText, ariaLabel, ariaLabelledBy, messages) {
292
300
  if (isDisplay) {
293
301
  const label = labelText ?? ariaLabel;
294
302
  return {
295
303
  role: "img",
296
304
  "aria-labelledby": ariaLabelledBy,
297
- "aria-label": `${label ? `${label}: ` : ""}${Math.max(0, api.value)} out of ${api.count}`,
298
- "aria-description": "Average rating"
305
+ "aria-label": messages.rating.valueText({
306
+ label,
307
+ value: Math.max(0, api.value),
308
+ count: api.count
309
+ }),
310
+ "aria-description": messages.rating.averageDescription
299
311
  };
300
312
  }
301
313
  const visibleLabelId = labelText && !ariaLabel ? api.getLabelProps().id : void 0;
302
314
  return {
303
315
  ...api.getControlProps(),
304
- "aria-label": ariaLabel ?? (labelText || ariaLabelledBy ? void 0 : "Rating"),
316
+ "aria-label": ariaLabel ?? (labelText || ariaLabelledBy ? void 0 : messages.rating.label),
305
317
  "aria-labelledby": ariaLabelledBy ?? visibleLabelId
306
318
  };
307
319
  }
308
- function RatingItems({ api, dir, styles, isDisplay, showExactValue, describedBy, errorMessageId, invalid, translations }) {
320
+ function RatingItems({ api, dir, styles, isDisplay, showExactValue, describedBy, errorMessageId, invalid, translations, itemValueText }) {
309
321
  return /*#__PURE__*/ jsx(Fragment, {
310
322
  children: api.items.map((index)=>{
311
323
  const itemProps = api.getItemProps({
@@ -319,7 +331,7 @@ function RatingItems({ api, dir, styles, isDisplay, showExactValue, describedBy,
319
331
  ...itemProps,
320
332
  "aria-checked": checked,
321
333
  tabIndex: itemProps["aria-disabled"] ? void 0 : tabIndex,
322
- "aria-label": checked ? translations?.ratingValueText?.(api.value) ?? `${api.value} stars` : itemProps["aria-label"]
334
+ "aria-label": checked ? translations?.ratingValueText?.(api.value) ?? itemValueText(api.value) : itemProps["aria-label"]
323
335
  };
324
336
  return /*#__PURE__*/ jsxs("span", {
325
337
  className: styles.item(),
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
3
  import { createContext, useContext } from "react";
4
+ import { useUiMessages } from "../messages/ui-messages-provider.js";
4
5
  import { tv } from "../utils.js";
5
6
  const skeletonVariants = tv({
6
7
  slots: {
@@ -86,11 +87,11 @@ function useResolvedSkeletonProps(props) {
86
87
  }
87
88
  const LOADING_STATUS_PROPS = {
88
89
  role: "status",
89
- "aria-busy": true,
90
- "aria-label": "Loading content"
90
+ "aria-busy": true
91
91
  };
92
92
  function useSkeletonA11yProps(ariaHidden) {
93
93
  const context = useSkeletonContext();
94
+ const messages = useUiMessages();
94
95
  if (context) return {
95
96
  "aria-hidden": true
96
97
  };
@@ -98,13 +99,17 @@ function useSkeletonA11yProps(ariaHidden) {
98
99
  "aria-busy": true,
99
100
  "aria-hidden": true
100
101
  };
101
- return LOADING_STATUS_PROPS;
102
+ return {
103
+ ...LOADING_STATUS_PROPS,
104
+ "aria-label": messages.skeleton.loading
105
+ };
102
106
  }
103
107
  function Skeleton({ isLoaded = false, variant, children, speed, className, ref, ...props }) {
104
108
  const styles = skeletonVariants({
105
109
  variant,
106
110
  speed
107
111
  });
112
+ const messages = useUiMessages();
108
113
  return /*#__PURE__*/ jsx(SkeletonContext.Provider, {
109
114
  value: {
110
115
  isLoaded,
@@ -113,6 +118,7 @@ function Skeleton({ isLoaded = false, variant, children, speed, className, ref,
113
118
  },
114
119
  children: isLoaded ? children : /*#__PURE__*/ jsx("div", {
115
120
  ...LOADING_STATUS_PROPS,
121
+ "aria-label": messages.skeleton.loading,
116
122
  className: styles.root({
117
123
  className
118
124
  }),
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ "use client";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { useUiMessages } from "../messages/ui-messages-provider.js";
5
+ import { Popover } from "../molecules/popover.js";
6
+ function PopoverTemplateContent({ fallbackName, unnamed, "aria-label": ariaLabel, ...props }) {
7
+ const messages = useUiMessages();
8
+ return /*#__PURE__*/ jsx(Popover.Content, {
9
+ ...props,
10
+ "aria-label": ariaLabel ?? (unnamed ? fallbackName ?? messages.popover.details : void 0)
11
+ });
12
+ }
13
+ export { PopoverTemplateContent };
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ "use client";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { useUiMessages } from "../messages/ui-messages-provider.js";
5
+ function RequiredLabelText() {
6
+ const text = useUiMessages().label.required;
7
+ return text ? /*#__PURE__*/ jsx("span", {
8
+ className: "sr-only",
9
+ children: ` ${text}`
10
+ }) : null;
11
+ }
12
+ export { RequiredLabelText };
@@ -0,0 +1,47 @@
1
+ "use client";
2
+ "use client";
3
+ import { jsx } from "react/jsx-runtime";
4
+ import { createContext, useContext, useMemo } from "react";
5
+ import { enUiMessages, mergeUiMessages } from "./ui-messages.js";
6
+ const NO_LAYERS = [];
7
+ const contextKey = Symbol.for("@techsio/ui-kit/ui-messages");
8
+ function sharedContext() {
9
+ const registry = globalThis;
10
+ registry[contextKey] ??= /*#__PURE__*/ createContext(NO_LAYERS);
11
+ return registry[contextKey];
12
+ }
13
+ const UiMessagesContext = sharedContext();
14
+ const resolved = new WeakMap();
15
+ function resolve(layers) {
16
+ const cached = resolved.get(layers);
17
+ if (cached) return cached;
18
+ const messages = layers.reduce(mergeUiMessages, enUiMessages);
19
+ resolved.set(layers, messages);
20
+ return messages;
21
+ }
22
+ function UiMessagesProvider({ messages, locale, children }) {
23
+ const outer = useContext(UiMessagesContext);
24
+ const layers = useMemo(()=>{
25
+ const own = [];
26
+ if (messages) own.push(messages);
27
+ if (void 0 !== locale) own.push({
28
+ locale
29
+ });
30
+ return 0 === own.length ? outer : [
31
+ ...outer,
32
+ ...own
33
+ ];
34
+ }, [
35
+ outer,
36
+ messages,
37
+ locale
38
+ ]);
39
+ return /*#__PURE__*/ jsx(UiMessagesContext.Provider, {
40
+ value: layers,
41
+ children: children
42
+ });
43
+ }
44
+ function useUiMessages() {
45
+ return resolve(useContext(UiMessagesContext));
46
+ }
47
+ export { UiMessagesProvider, useUiMessages };
@@ -0,0 +1,273 @@
1
+ const enUiMessages = {
2
+ label: {
3
+ required: "(required)"
4
+ },
5
+ skeleton: {
6
+ loading: "Loading content"
7
+ },
8
+ rating: {
9
+ label: "Rating",
10
+ averageDescription: "Average rating",
11
+ valueText: ({ label, value, count })=>`${label ? `${label}: ` : ""}${value} out of ${count}`,
12
+ itemValueText: (value)=>`${value} stars`
13
+ },
14
+ numericInput: {},
15
+ accordion: {},
16
+ carousel: {},
17
+ cascadeSelect: {
18
+ placeholder: "Select an option",
19
+ clear: "Clear selection",
20
+ rootLabel: "Options"
21
+ },
22
+ chart: {
23
+ dataTableLabel: "View chart data",
24
+ emptyLabel: "No data to display.",
25
+ invalidLabel: "Pie and donut values must be finite, non-negative numbers with a positive total.",
26
+ seriesHeader: "Series",
27
+ categoryHeader: "Category",
28
+ valueHeader: "Value"
29
+ },
30
+ colorSelect: {
31
+ label: "Color",
32
+ selectColor: (color)=>`Select color ${color}`,
33
+ readOnly: "Read-only color selection"
34
+ },
35
+ combobox: {
36
+ placeholder: "Select option",
37
+ noResults: 'No results found for "{inputValue}"',
38
+ loading: "Loading results",
39
+ retry: "Retry",
40
+ clear: "Clear value",
41
+ chooseSuggestion: "Select an option from the suggestions.",
42
+ selectedValues: "Selected values",
43
+ selectedStatus: (selected)=>`Selected: ${selected}`,
44
+ removeValue: (value)=>`Remove ${value}`
45
+ },
46
+ datePicker: {
47
+ segments: {
48
+ era: "Era",
49
+ year: "Year",
50
+ month: "Month",
51
+ day: "Day",
52
+ hour: "Hour",
53
+ minute: "Minute",
54
+ second: "Second",
55
+ dayPeriod: "AM/PM",
56
+ timeZoneName: "Time zone"
57
+ },
58
+ emptySegment: "Empty",
59
+ incompleteValue: "Complete every date and time segment before submitting.",
60
+ unavailableValue: "Complete an available date and time.",
61
+ outOfRange: ({ min, max })=>`Choose an available date and time${min ? ` on or after ${min}` : ""}${max ? ` on or before ${max}` : ""}.`,
62
+ start: "Start",
63
+ end: "End",
64
+ time: "Time",
65
+ startTime: "Start time",
66
+ endTime: "End time",
67
+ startAndEndTimes: "Start and end times",
68
+ dayPeriod: "Day period",
69
+ am: "AM",
70
+ pm: "PM",
71
+ dayPeriodOf: (field)=>`${field} day period`,
72
+ cancel: "Cancel",
73
+ confirm: "Confirm"
74
+ },
75
+ dialog: {
76
+ open: "Open",
77
+ close: "Close dialog"
78
+ },
79
+ drawer: {
80
+ close: "Close drawer"
81
+ },
82
+ fileUpload: {
83
+ processingFailed: "Files could not be processed. Choose the files again to retry.",
84
+ readOnly: "Read-only files. Uploading and removing files is unavailable.",
85
+ clear: "Clear files"
86
+ },
87
+ formErrorSummary: {
88
+ title: "There is a problem"
89
+ },
90
+ menu: {
91
+ trigger: "Menu"
92
+ },
93
+ pagination: {
94
+ unavailable: "Page unavailable. Choose a page within the current results.",
95
+ compact: ({ page, totalPages })=>`${page} of ${totalPages}`
96
+ },
97
+ phoneInput: {
98
+ placeholder: "Phone number",
99
+ invalid: "Enter a valid phone number.",
100
+ countries: {
101
+ SK: "Slovakia",
102
+ CZ: "Czechia",
103
+ HU: "Hungary",
104
+ RO: "Romania",
105
+ PL: "Poland",
106
+ AT: "Austria",
107
+ DE: "Germany"
108
+ }
109
+ },
110
+ popover: {
111
+ close: "Close popover",
112
+ details: "Additional details"
113
+ },
114
+ searchForm: {
115
+ placeholder: "Search...",
116
+ search: "Search",
117
+ clear: (query)=>`Clear search: ${query}`
118
+ },
119
+ select: {
120
+ placeholder: "Select an option",
121
+ clear: "Clear selection",
122
+ readOnly: "Read-only selection"
123
+ },
124
+ steps: {
125
+ progress: "Step progress",
126
+ complete: "Workflow complete"
127
+ },
128
+ tabs: {},
129
+ toast: {
130
+ close: "Close notification",
131
+ loading: "loading..."
132
+ },
133
+ tour: {
134
+ guidance: "Tour guidance"
135
+ },
136
+ treeView: {
137
+ expand: (name)=>`Expand ${name}`,
138
+ collapse: (name)=>`Collapse ${name}`
139
+ },
140
+ dataTable: {
141
+ scrollLabel: "Scrollable records",
142
+ searchPlaceholder: "Search…",
143
+ searchLabel: "Search",
144
+ clearSearchLabel: "Clear search",
145
+ searchButtonLabel: "Submit search",
146
+ columnsLabel: "Column settings",
147
+ emptyTitle: "No records",
148
+ emptyDescription: "There is no data to display.",
149
+ pageSizeLabel: "Rows per page",
150
+ actionsLabel: "Actions",
151
+ filtersLabel: "Column filters",
152
+ selectAllLabel: "Select all rows",
153
+ selectionLabel: "Select rows",
154
+ reorderLabel: "Reorder rows",
155
+ loadingLabel: "Loading data",
156
+ operatorLabels: {
157
+ contains: "Contains",
158
+ notContains: "Does not contain",
159
+ equals: "Equals",
160
+ notEquals: "Does not equal",
161
+ startsWith: "Starts with",
162
+ endsWith: "Ends with",
163
+ empty: "Is empty",
164
+ notEmpty: "Is not empty",
165
+ between: "Between"
166
+ },
167
+ numberOperatorLabels: {
168
+ equals: "=",
169
+ notEquals: "≠",
170
+ gt: ">",
171
+ gte: "≥",
172
+ lt: "<",
173
+ lte: "≤",
174
+ between: "Between",
175
+ empty: "Is empty",
176
+ notEmpty: "Is not empty"
177
+ },
178
+ rowFallbackLabel: (rowId)=>`row ${rowId}`,
179
+ editingLabel: "Editing a row — other table controls are locked",
180
+ rangeLabel: ({ start, end, total })=>`${start}–${end} of ${total}`,
181
+ pageLabel: ({ page, pageCount })=>null == pageCount ? `Page ${page}` : `Page ${page} of ${pageCount}`,
182
+ previousPageLabel: "Previous page",
183
+ nextPageLabel: "Next page",
184
+ paginationPendingLabel: "Page unavailable — requesting an available page.",
185
+ invalidRangeLabel: "Enter valid dates with the start on or before the end.",
186
+ savePendingLabel: "Saving row…",
187
+ saveErrorLabel: "Could not save this row. Your changes are kept; try Save again.",
188
+ requiredLabel: "Enter a value before saving this row.",
189
+ selectRowLabel: (rowLabel)=>`Select ${rowLabel}`,
190
+ editRowLabel: (rowLabel)=>`Edit ${rowLabel}`,
191
+ dragHandleLabel: (label)=>`Drag to reorder ${label}`,
192
+ reorderInstructions: "To reorder, focus a drag handle and press Space or Enter. Use Up and Down for rows, or Left and Right for columns. Press Space or Enter to drop, or Escape to cancel.",
193
+ reorderPickedUp: ({ label, position })=>`Picked up ${label}, position ${position}.`,
194
+ reorderMoving: ({ label, target, side })=>`${label} will move ${side} ${target}.`,
195
+ reorderDropped: ({ label, position })=>`Dropped ${label}, position ${position}.`,
196
+ reorderCanceled: (label)=>`Reordering ${label} canceled.`,
197
+ resizeColumnLabel: (column)=>`Resize ${column}`,
198
+ resizeColumnDescription: "Use Left and Right arrows to resize; Shift changes by 50 pixels. Enter resets the width.",
199
+ cancelEditLabel: "Cancel edit",
200
+ saveRowLabel: "Save row",
201
+ expandRowLabel: "Expand row",
202
+ collapseRowLabel: "Collapse row",
203
+ filterLabel: (column)=>`Filter ${column}`,
204
+ filterConditionLabel: (column)=>`Filter condition for ${column}`,
205
+ filterConditionValueLabel: ({ column, condition })=>`Filter condition for ${column}: ${condition}`,
206
+ filterValueLabel: (column)=>`Filter value for ${column}`,
207
+ filterUpperBoundLabel: (column)=>`Filter upper bound for ${column}`,
208
+ filterFromLabel: (column)=>`Filter ${column} from`,
209
+ filterToLabel: (column)=>`Filter ${column} to`,
210
+ filterValuePlaceholder: "Value",
211
+ filterFromPlaceholder: "From",
212
+ filterToPlaceholder: "To",
213
+ filterAllLabel: "All",
214
+ booleanTrueLabel: "Yes",
215
+ booleanFalseLabel: "No",
216
+ editCellLabel: (column)=>`Edit ${column}`,
217
+ editCellFromLabel: (column)=>`Edit ${column} from`,
218
+ editCellToLabel: (column)=>`Edit ${column} to`
219
+ },
220
+ gallery: {
221
+ images: "Product images",
222
+ showSlide: (index)=>`Show slide ${index}`
223
+ },
224
+ header: {
225
+ toggleMenu: "Toggle mobile menu"
226
+ },
227
+ facetFilterPanel: {
228
+ activeFilters: "Active filters",
229
+ reset: "Clear filters",
230
+ showMore: (hiddenCount)=>`Show ${hiddenCount} more`,
231
+ showLess: "Show less",
232
+ minimum: (group)=>`Minimum ${group.toLocaleLowerCase()}`,
233
+ maximum: (group)=>`Maximum ${group.toLocaleLowerCase()}`
234
+ },
235
+ productCard: {
236
+ originalPrice: "Original price",
237
+ currentPrice: "Current price",
238
+ addToCart: "Add to Cart",
239
+ viewDetails: "View Details",
240
+ addToWishlist: "Add to Wishlist"
241
+ },
242
+ themeToggle: {
243
+ brand: "Brand",
244
+ mode: "Mode",
245
+ light: "Light",
246
+ dark: "Dark",
247
+ system: "System"
248
+ }
249
+ };
250
+ const isPlainObject = (value)=>{
251
+ if ("object" != typeof value || null === value || Array.isArray(value)) return false;
252
+ const prototype = Object.getPrototypeOf(value);
253
+ return prototype === Object.prototype || null === prototype;
254
+ };
255
+ function mergeInto(base, input) {
256
+ const merged = {
257
+ ...base
258
+ };
259
+ for (const [key, value] of Object.entries(input)){
260
+ if (void 0 === value) continue;
261
+ const current = merged[key];
262
+ merged[key] = isPlainObject(current) && isPlainObject(value) ? mergeInto(current, value) : value;
263
+ }
264
+ return merged;
265
+ }
266
+ function definedEntries(value) {
267
+ return Object.fromEntries(Object.entries(value ?? {}).filter(([, entry])=>void 0 !== entry));
268
+ }
269
+ function mergeUiMessages(base, input) {
270
+ if (!input) return base;
271
+ return mergeInto(base, input);
272
+ }
273
+ export { definedEntries, enUiMessages, mergeUiMessages };
@@ -6,6 +6,8 @@ import { createContext, useContext, useId } from "react";
6
6
  import { ActionIcon } from "../atoms/action-icon.js";
7
7
  import { Image, ImageWithFallback } from "../atoms/image.js";
8
8
  import { usePrefersReducedMotion } from "../internal/reduced-motion.js";
9
+ import { definedEntries } from "../messages/ui-messages.js";
10
+ import { useUiMessages } from "../messages/ui-messages-provider.js";
9
11
  import { tv } from "../utils.js";
10
12
  const carouselMachine = {
11
13
  ...machine,
@@ -319,6 +321,7 @@ function Carousel({ id, size, objectFit, aspectRatio, orientation = "horizontal"
319
321
  });
320
322
  }
321
323
  };
324
+ const messages = useUiMessages();
322
325
  const service = useMachine(motionAwareMachine, {
323
326
  id: id ?? fallbackId,
324
327
  slideCount,
@@ -333,7 +336,11 @@ function Carousel({ id, size, objectFit, aspectRatio, orientation = "horizontal"
333
336
  dir,
334
337
  snapType,
335
338
  onPageChange,
336
- ...props
339
+ ...props,
340
+ translations: {
341
+ ...messages.carousel.translations,
342
+ ...definedEntries(props.translations)
343
+ }
337
344
  });
338
345
  const api = connect(service, normalizeProps);
339
346
  const { wrapper, root } = carouselVariants({
@@ -462,7 +469,7 @@ Carousel.Previous = function({ className, icon }) {
462
469
  size: toTriggerSize(size),
463
470
  ...triggerProps,
464
471
  "aria-disabled": disabled,
465
- "aria-label": triggerProps["aria-label"] ?? "Previous slide",
472
+ "aria-label": triggerProps["aria-label"],
466
473
  "data-disabled": disabled ? "" : void 0,
467
474
  disabled: disabled,
468
475
  icon: resolvedIcon,
@@ -486,7 +493,7 @@ Carousel.Next = function({ className, icon }) {
486
493
  size: toTriggerSize(size),
487
494
  ...triggerProps,
488
495
  "aria-disabled": disabled,
489
- "aria-label": triggerProps["aria-label"] ?? "Next slide",
496
+ "aria-label": triggerProps["aria-label"],
490
497
  "data-disabled": disabled ? "" : void 0,
491
498
  disabled: disabled,
492
499
  icon: resolvedIcon,
@@ -542,7 +549,7 @@ Carousel.Autoplay = function({ className }) {
542
549
  icon: api.isPlaying ? "token-icon-carousel-pause" : "token-icon-carousel-play",
543
550
  size: toTriggerSize(size),
544
551
  ...triggerProps,
545
- "aria-label": triggerProps["aria-label"] ?? (api.isPlaying ? "Stop slide rotation" : "Start slide rotation")
552
+ "aria-label": triggerProps["aria-label"]
546
553
  });
547
554
  };
548
555
  Carousel.Control = function({ children, className, controlPosition, controls }) {