@nxgt/material 3.51.0 → 3.52.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 (63) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{button-BWcr2b49.js → button-Ct0KRBsN.js} +1 -1
  3. package/dist/charts.js +3 -3
  4. package/dist/{chip-CmLW6ZrT.js → chip-Ca1SEd70.js} +2 -2
  5. package/dist/{code-editor-BKMaeIF6.js → code-editor-DtwRhK8B.js} +6 -6
  6. package/dist/code-editor.js +5 -5
  7. package/dist/{code-language-items-Cs1Pwd1h.js → code-language-items-CEclGxhA.js} +2 -2
  8. package/dist/{components-CuwU9Sux.js → components-CzELzsOi.js} +5610 -5576
  9. package/dist/components.js +18 -18
  10. package/dist/{dialog-TdT_5iUc.js → dialog-BIy04Hpd.js} +4 -4
  11. package/dist/dnd.js +1 -1
  12. package/dist/{dropdown-menu-BozV6Ikw.js → dropdown-menu-B0Kd8x3G.js} +1 -1
  13. package/dist/editor.js +9 -9
  14. package/dist/{empty-state-gzBPimAo.js → empty-state-CKxORwFE.js} +2 -2
  15. package/dist/{escape-owner-Bu-aDEEO.js → escape-owner-BGKjiglh.js} +1 -1
  16. package/dist/{field-blur-47zmuDkH.js → field-blur-Dz1zPaYK.js} +1 -1
  17. package/dist/{field-blur-context-6McYOnM8.js → field-blur-context-1T6GkSNc.js} +1 -1
  18. package/dist/hooks.js +2 -2
  19. package/dist/{hover-card-zHdZJpBG.js → hover-card-BwQ9IRxa.js} +2 -2
  20. package/dist/{i18n-provider-Ang2f31m.js → i18n-provider-BFNrM0Qu.js} +13 -11
  21. package/dist/i18n.js +3 -3
  22. package/dist/{icon-badge-CRFGIQPX.js → icon-badge-D5Ns7ndZ.js} +3 -3
  23. package/dist/{icon-button-CtG3Snfm.js → icon-button-VzdqY_Tv.js} +1 -1
  24. package/dist/lib/components/ui/collections/server-table/partials/filtered-server-table.d.ts +1 -0
  25. package/dist/lib/components/ui/collections/server-table/partials/server-table-band-view.d.ts +18 -0
  26. package/dist/lib/components/ui/collections/server-table/partials/use-server-table-list-root.d.ts +10 -0
  27. package/dist/lib/components/ui/collections/server-table/partials/use-server-table-phone-row.d.ts +3 -2
  28. package/dist/lib/components/ui/display/change-history/types.d.ts +2 -1
  29. package/dist/lib/components/ui/display/description/description.d.ts +2 -2
  30. package/dist/lib/components/ui/fields/verification-code/use-resend-focus.d.ts +4 -1
  31. package/dist/lib/components/ui/primitives/tabs/tabs-overflow-classes.d.ts +8 -5
  32. package/dist/lib/components/ui/primitives/tabs/use-tabs-overflow.d.ts +4 -3
  33. package/dist/lib/i18n/i18n-provider.d.ts +14 -3
  34. package/dist/lib/i18n/translate-material.d.ts +7 -1
  35. package/dist/lib/i18n/types.d.ts +6 -0
  36. package/dist/lib/i18n/use-material-translation.d.ts +4 -0
  37. package/dist/main.js +22 -22
  38. package/dist/map.js +8 -8
  39. package/dist/material.css +1 -1
  40. package/dist/pdf-reader.js +1 -1
  41. package/dist/print.js +5 -4
  42. package/dist/{public-CTZ5RK_Y.js → public-D-J3nZFm.js} +9 -9
  43. package/dist/{rich-code-block-oTgL-s4W.js → rich-code-block-Ig0ERAa2.js} +5 -5
  44. package/dist/{sortable-provider-CpA5NYgD.js → sortable-provider-DfPkSN90.js} +2 -2
  45. package/dist/{spinner-UvqlDsV8.js → spinner-KQb3YuR_.js} +1 -1
  46. package/dist/theme-picker.js +2 -2
  47. package/dist/{theme-toggle-BZVz6O5q.js → theme-toggle-BY-SpsFV.js} +1 -1
  48. package/dist/{toolbar-items-C09bJphe.js → toolbar-items-30w9rG5h.js} +4 -4
  49. package/dist/translate-material-BPl8TQLg.js +20 -0
  50. package/dist/{use-chat-composer-AZAj4tFJ.js → use-chat-composer-BSKJRYMB.js} +1676 -1654
  51. package/dist/{use-heading-spy-C9-A2md2.js → use-heading-spy-BgXA8uz6.js} +1 -1
  52. package/dist/use-material-translation-ByM3gD9R.js +14 -0
  53. package/docs/components/data-display.md +3 -3
  54. package/docs/components/primitives.md +1 -1
  55. package/docs/guides/helpers.md +1 -1
  56. package/docs/guides/i18n.md +30 -8
  57. package/docs/guides/two-factor.md +2 -1
  58. package/docs/previews/guides-i18n-i18nprovider.webp +0 -0
  59. package/docs/previews/guides-i18n-translated-components.webp +0 -0
  60. package/docs/troubleshooting.md +3 -2
  61. package/package.json +1 -1
  62. package/dist/translate-material-D6KCK21i.js +0 -12
  63. package/dist/use-material-translation-pLgSqqLw.js +0 -14
@@ -1,4 +1,4 @@
1
- import { r as e } from "./i18n-provider-Ang2f31m.js";
1
+ import { r as e } from "./i18n-provider-BFNrM0Qu.js";
2
2
  import { _ as t, g as n, h as r, n as i, v as a, y as o } from "./number.utils-BG_eEt5g.js";
3
3
  import { useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
4
4
  import { busySettler as f, busySettler as p, createSubmitGuard as m, createSubmitGuard as h } from "@nxgt/material-core/submit-guard";
@@ -0,0 +1,14 @@
1
+ import { r as e } from "./i18n-provider-BFNrM0Qu.js";
2
+ import { t } from "./translate-material-BPl8TQLg.js";
3
+ import { useCallback as n } from "react";
4
+ //#region lib/i18n/use-material-translation.ts
5
+ function r() {
6
+ let r = e(), i = r?.language, a = r?.resources;
7
+ return {
8
+ t: n((e, n, r) => t(i, e, n, r, a), [i, a]),
9
+ language: i,
10
+ hasProvider: !!r
11
+ };
12
+ }
13
+ //#endregion
14
+ export { r as t };
@@ -642,7 +642,7 @@ import { Description } from '@nxgt/material/components';
642
642
  </div>
643
643
  ```
644
644
 
645
- `label` and `value` are its main props; the rest go to the `div`. A `value` of `null`, `undefined`, `false` or `''` renders nothing (`0` is shown), so optional fields need no guard. Inside a `variant="panels"` list a `Description` must sit in a `DescriptionList.Group`; otherwise it renders its stand-alone markup. The label is a small
645
+ `label` and `value` are its main props; the rest go to the `div`. A `value` of `null`, `undefined`, `false` or `''` with no `lines` and no `children` renders nothing (`0` is shown), so optional fields need no guard. `children` alone are the value (`<Description label="Note">text</Description>`); after a `value` they follow it. Inside a `variant="panels"` list a `Description` must sit in a `DescriptionList.Group`; otherwise it renders its stand-alone markup. The label is a small
646
646
  muted caption above the value (not a title). `Description` takes one cell of
647
647
  the grid it is in; pass `className="col-start-full"` for a full-width row. It takes `lines` anywhere; inside a [`DescriptionList`](#descriptionlist) also `span` and `labelPosition`.
648
648
 
@@ -686,7 +686,7 @@ row) or a number of columns (used once that many fit; at most `maxColumns`, and
686
686
  field uses dense packing: the fields after it fill the cells before it, so they
687
687
  may be drawn above it while the DOM and reading order stay the source order.
688
688
  Put the full-width field where that reads fine, or last. A multi-line value
689
- (an address) takes `lines={[…]}` or `children`, never a string to split. Entries of `lines` that are `null`, `false` or `""` are skipped, and a `Description` whose `lines` are all empty and that has no `value` renders nothing.
689
+ (an address) takes `lines={[…]}` or `children`, never a string to split. Entries of `lines` that are `null`, `false` or `""` are skipped, and a `Description` whose `lines` are all empty and that has no `value` or `children` renders nothing.
690
690
 
691
691
  ```tsx
692
692
  <DescriptionList variant="panels">
@@ -1087,7 +1087,7 @@ yours, the component names no domain.
1087
1087
 
1088
1088
  | Prop | Type | Default | Effect |
1089
1089
  | --- | --- | --- | --- |
1090
- | `entries` | `ChangeHistoryEntry[]` | — | `id`, `kind`, `at` (`Date`, string or number), `author` (`name`, `src`), `changes` (`ChangeHistoryChange[]`: `field`, `before`, `after`, `redacted`) |
1090
+ | `entries` | `ChangeHistoryEntry[]` | — | `id`, `kind`, `at` (`Date`, string or number), `author` (`name`, `src`), `changes` (optional, `ChangeHistoryChange[]`: `field`, `before`, `after`, `redacted`; left out or `[]`, the entry shows its sentence, author and time with no change list) |
1091
1091
  | `kinds` | `Record<string, ChangeHistoryKindOverride>` | built-ins | `label`, `verb`, `icon` (`null` removes it), `tone` per kind; `creation` (default true for `created`) makes an entry list values only |
1092
1092
  | `variant` | `'rail' \| 'cards'` | `'rail'` | the look |
1093
1093
  | `groupBy` | `'day' \| 'none'` | `'day'` | a heading per day (sticky on the rail), or one list in the order given |
@@ -735,7 +735,7 @@ reached with the arrow keys. The list scrolls sideways when the tabs do not
735
735
  fit (its scrollbar hidden), which suits a phone or a narrow popover. While it
736
736
  overflows, each side with hidden tabs fades and gets a small scroll button
737
737
  ("Scroll tabs left" / "Scroll tabs right", from `material.tabs.*`; out of the
738
- tab order, 44px on a touch screen); the selected and the focused tab are
738
+ tab order; on a touch screen 44px wide and as tall as the list, so it never covers content); the selected and the focused tab are
739
739
  scrolled into view, instantly under reduced motion. A list that fits has
740
740
  neither, and neither is in the server markup. `segmented` does the same.
741
741
 
@@ -265,7 +265,7 @@ flag. Storybook: `Guides/Hooks/useSubmitOnce`.
265
265
  | `formatMessage(message, language, values?, { onError }?)` | Formats one ICU message (`{name}`, plurals, selects) in any BCP 47 `language` with the translator's engine, for a message that is not in a bundle (a server-side catalogue). Cached per message; one that does not format is logged and returned unformatted, or passed to `onError` as a `FormatMessageError` (reason, key, source) without logging. |
266
266
  | `createTypedTranslation(translate)` | Turns a translator into a typed `useTranslation()` hook. |
267
267
  | `translate`, `useMaterialTranslation()` | Translator / hook bound to the package's own `material.*` keys. `useMaterialTranslation().t(key, fallback)` returns `fallback` without a provider. |
268
- | `translateMaterial(language, key, fallback, values?)` | The same as `useMaterialTranslation().t`, with the language passed as a value: no provider, no hook. For a PDF `footer` function or a server. `'fr-CA'` reads `fr`; an unknown language formats `fallback`. |
268
+ | `translateMaterial(language, key, fallback, values?, resources?)` | The same as `useMaterialTranslation().t`, with the language passed as a value: no provider, no hook. `resources` is your merged bundle (stable object), read before the base one. For a PDF `footer` function or a server. `'fr-CA'` reads `fr`; an unknown language formats `fallback`. |
269
269
  | `getLanguage()` | Language read from `localStorage`, else `FALLBACK_LANGUAGE`. |
270
270
  | `LANGUAGE_KEY`, `FALLBACK_LANGUAGE`, `SUPPORTED_LANGUAGES` | Storage key (`'language'`), fallback (`'en'`) and supported languages (`en`, `fr`). |
271
271
 
@@ -63,6 +63,7 @@ function translateMaterial(
63
63
  key: MaterialLocaleKey,
64
64
  fallback: string,
65
65
  values?: TranslationContext,
66
+ resources?: ResourceBundle, // your merged bundle, a stable object (module scope)
66
67
  ): string;
67
68
  ```
68
69
 
@@ -189,6 +190,7 @@ if (failure) {
189
190
  | `initialLanguage` | `Language` | — | Used as-is for the first render when supported, and `localStorage` is not read. Set it in SSR. See [below](#server-rendering) |
190
191
  | `storageKey` | `string` | `'language'` | `localStorage` key the choice is read from and written to |
191
192
  | `supportedLanguages` | `Language[]` | `['en', 'fr']` | What `changeLanguage` accepts and `LanguageSwitcher` lists |
193
+ | `resources` | `ResourceBundle` | — | Your `mergeResources(...)` result: the components read their `material.*` words from it before the base bundle. Pass a stable object (module scope) |
192
194
  | `onLanguageChange` | `(language) => void` | — | Called after a successful change: save it to a cookie, a profile, analytics |
193
195
 
194
196
  `changeLanguage` with an unsupported value logs
@@ -208,7 +210,8 @@ const context = useOptionalI18nContext(); // null outside the provider
208
210
  third language is not in the type today, so adding one to
209
211
  `supportedLanguages` takes a cast. The runtime accepts it: your translator
210
212
  uses your strings for it, and the components fall back to their English copy,
211
- formatted.
213
+ formatted. A third language you define under `material.*` and give through
214
+ `resources` now reaches the components.
212
215
 
213
216
  ```tsx
214
217
  const LANGUAGES = ['en', 'fr', 'de'] as Language[];
@@ -498,8 +501,8 @@ material.emoji.groups.flags; // "Flags" / "Drapeaux"
498
501
 
499
502
  A group your `EmojiItem`s name that is not in this list (`hand_signs`) reads
500
503
  as its words in English (`Hand signs`). As for every `material.*` key above,
501
- the components read their own bundle: your own translator sees a key you add,
502
- the tab does not.
504
+ your own translator sees a key you add; the components see it too once you hand
505
+ them the merged resources (see "Overriding a component's words" below).
503
506
 
504
507
  ```tsx
505
508
  // Under <I18nProvider defaultLanguage="fr">
@@ -509,11 +512,30 @@ the tab does not.
509
512
  <Spinner variant="4" /> // role="img" aria-label="Chargement..."
510
513
  ```
511
514
 
512
- That override is visible only through **your** translator. The components
513
- translate through the package's own bundle, so defining
514
- `material.command.title` in your resources changes what
515
- `t('material.command.title')` returns in your code, but not the title
516
- `CommandDialog` renders.
515
+ ### Overriding a component's words
516
+
517
+ Give the provider the merged resources and every component translates through
518
+ them, so an override under `material.*` changes what it renders:
519
+
520
+ ```tsx
521
+ import { mergeResources, resources as materialResources } from '@nxgt/material/i18n';
522
+
523
+ const resources = mergeResources(materialResources, {
524
+ en: { material: { 'recovery-codes-status': { title: 'Backup codes' } } },
525
+ });
526
+
527
+ <I18nProvider defaultLanguage="en" resources={resources}>
528
+ <RecoveryCodesStatus remaining={3} onRegenerate={regenerate} /> {/* title: "Backup codes" */}
529
+ </I18nProvider>
530
+ ```
531
+
532
+ Without `resources`, the components read the package's own bundle: an override
533
+ is visible only through **your** translator, and defining `material.command.title`
534
+ does not change the title `CommandDialog` renders. Pass a stable object
535
+ (module scope), not one built in a render. A component's `labels` prop still
536
+ wins over both. Outside a component, `translateMaterial` takes the merged
537
+ resources as a fifth argument and `zodLocaleError` takes `translate`; the
538
+ toast presets and the toast close label still read the package's bundle.
517
539
 
518
540
  Each time `mergeResources` runs outside production, overlapping leaves are
519
541
  reported, one line per language:
@@ -62,7 +62,8 @@ in `@nxgt/material-core/two-factor`.
62
62
  What stays in the app: every request, the mapping of a server error to the
63
63
  props above, where the challenge is kept, the replay of the action a step-up
64
64
  unblocked, the leave guard around the new recovery codes, and all wording
65
- (`labels`, or your translations under `material.*`).
65
+ (`labels`, or your translations under `material.*`, given to
66
+ `I18nProvider` as `resources`, see [i18n](i18n.md#overriding-a-components-words)).
66
67
 
67
68
  ## On a phone and for assistive technology
68
69
 
@@ -3902,8 +3902,9 @@ followed by the list of keys, e.g. `"en": material.command.title. App resources
3902
3902
  take precedence over the base bundle at these keys.`
3903
3903
  **Why:** your resources define leaves under the `material` namespace, which
3904
3904
  this package reserves for its own strings. The override reaches your app's
3905
- own translator only: the package's components translate from their own
3906
- bundle, so their text does **not** change.
3905
+ own translator only, unless you also give the merged object to
3906
+ `<I18nProvider resources={resources}>`: without it the package's components
3907
+ translate from their own bundle, so their text does **not** change.
3907
3908
  **Fix:**
3908
3909
 
3909
3910
  ```ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxgt/material",
3
- "version": "3.51.0",
3
+ "version": "3.52.0",
4
4
  "license": "MIT",
5
5
  "bugs": {
6
6
  "email": "stevegires@gmail.com"
@@ -1,12 +0,0 @@
1
- import "./stored-language-Cb9FMEwk.js";
2
- import { a as e, r as t } from "./translator-BnQXtpSZ.js";
3
- //#region lib/i18n/translate-material.ts
4
- function n(n, r, i, a) {
5
- if (n) for (let e of /* @__PURE__ */ new Set([n, n.split("-")[0]])) {
6
- let n = t(r, a, () => e);
7
- if (n !== r) return n;
8
- }
9
- return e(i, n || "en", a);
10
- }
11
- //#endregion
12
- export { n as t };
@@ -1,14 +0,0 @@
1
- import { r as e } from "./i18n-provider-Ang2f31m.js";
2
- import { t } from "./translate-material-D6KCK21i.js";
3
- import { useCallback as n } from "react";
4
- //#region lib/i18n/use-material-translation.ts
5
- function r() {
6
- let r = e(), i = r?.language;
7
- return {
8
- t: n((e, n, r) => t(i, e, n, r), [i]),
9
- language: i,
10
- hasProvider: !!r
11
- };
12
- }
13
- //#endregion
14
- export { r as t };