@nxgt/material-core 0.11.1 → 0.12.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @nxgt/material-core
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#624](https://github.com/softistx/nxgt-material/pull/624) [`94a77a7`](https://github.com/softistx/nxgt-material/commit/94a77a76b54834bda18d1e2acc494d5a089d245d) Thanks [@SteveGT96](https://github.com/SteveGT96)! - `@nxgt/material-core/initials`: `initials(name)`, an avatar's initials from a name (`'Ada Lovelace'` → `'AL'`), the first letter of the first and last word, upper-cased, a whole code point each. Both libraries' new `AccountMenu` use it ([#585](https://github.com/softistx/nxgt-material/issues/585)).
8
+
3
9
  ## 0.11.1
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -104,6 +104,7 @@ built-in.
104
104
  | `/csp-nonce` | `getCspNonce`, `setCspNonce`, `claimCspNonce(nonce, depth)`, `createNoncedStyle`, and `getNonce` / `setNonce` (the `get-nonce` API) — the page's Content Security Policy nonce, for a `<style>` created at runtime; browser only |
105
105
  | `/lazy-object` | `lazyObject`, `buildOnce` — a value built on its first use rather than when its module loads: the libraries' zod schemas |
106
106
  | `/debounce` | `debounce`, the type `Debounced` — a function called once calls pause, with `cancel` and `flush` (`SearchField`'s `debounceMs`) |
107
+ | `/initials` | `initials` — an avatar's initials from a name, `'Ada Lovelace'` → `'AL'` (`AccountMenu`) |
107
108
  | `/text-match` | `foldText`, `matchesText` — case- and accent-insensitive matching (`'e'` finds "École"), lowercased for a locale |
108
109
  | `/async-search` | `createAsyncSearch`, `searchAnnouncement`, `DEFAULT_SEARCH_DEBOUNCE_MS`, `DEFAULT_MIN_QUERY_LENGTH` and the types `AsyncSearch`, `AsyncSearchConfig`, `AsyncSearchState`, `AsyncSearchStatus`, `SearchFn`, `SearchContext`, `SearchAnnouncement` — `Autocomplete`'s server search: debounced, each run aborting the last, a stale response dropped |
109
110
  | `/submit-guard` | `createSubmitGuard`, `busySettler` and the types `SubmitGuard`, `SubmitOnceOptions` — one submit in flight until its request ends, behind both libraries' `useSubmitOnce` |
@@ -407,6 +408,20 @@ save('ab'); // 300 ms later: "save ab", once
407
408
  save.flush(); // or now
408
409
  ```
409
410
 
411
+ ### An avatar's initials: `/initials`
412
+
413
+ What both libraries' `AccountMenu` shows in its avatar when there is no
414
+ picture: the first letter of the first and of the last word, upper-cased, a
415
+ whole code point each.
416
+
417
+ ```ts
418
+ import { initials } from '@nxgt/material-core/initials';
419
+
420
+ initials('Ada Lovelace'); // 'AL'
421
+ initials('Ada'); // 'A'
422
+ initials(' '); // ''
423
+ ```
424
+
410
425
  ### Matching text as the user types: `/text-match`
411
426
 
412
427
  `foldText(text, locale?)` lowercases `text` for `locale` (the runtime's when
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The initials an avatar shows in place of a picture: the first letter of the
3
+ * first and of the last word of `name`, upper-cased — `'Ada Lovelace'` →
4
+ * `'AL'`, `'Ada'` → `'A'`, `'Jean-Paul Sartre'` → `'JS'` — and `''` for a
5
+ * blank name. A letter is a whole code point, so an emoji or an astral
6
+ * character is never cut in half. Locale-free (`toUpperCase`, not
7
+ * `toLocaleUpperCase`): a server and a browser in Turkish or Azeri would
8
+ * otherwise upper-case an `i` differently, and the hydration would differ.
9
+ * Both libraries' `AccountMenu` use it.
10
+ */
11
+ export declare function initials(name: string): string;
12
+ //# sourceMappingURL=initials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initials.d.ts","sourceRoot":"","sources":["../../src/lib/initials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS7C"}
@@ -0,0 +1,15 @@
1
+ // src/lib/initials.ts
2
+ function initials(name) {
3
+ const words = name.trim().split(/\s+/).filter(Boolean);
4
+ if (words.length === 0)
5
+ return "";
6
+ const first = words[0];
7
+ const last = words.length > 1 ? words.at(-1) : "";
8
+ return [first, last].map((word) => Array.from(word)[0] ?? "").join("").toUpperCase();
9
+ }
10
+ export {
11
+ initials
12
+ };
13
+
14
+ //# debugId=BB7FB6C4C0A3758264756E2164756E21
15
+ //# sourceMappingURL=initials.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/initials.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * The initials an avatar shows in place of a picture: the first letter of the\n * first and of the last word of `name`, upper-cased — `'Ada Lovelace'` →\n * `'AL'`, `'Ada'` → `'A'`, `'Jean-Paul Sartre'` → `'JS'` — and `''` for a\n * blank name. A letter is a whole code point, so an emoji or an astral\n * character is never cut in half. Locale-free (`toUpperCase`, not\n * `toLocaleUpperCase`): a server and a browser in Turkish or Azeri would\n * otherwise upper-case an `i` differently, and the hydration would differ.\n * Both libraries' `AccountMenu` use it.\n */\nexport function initials(name: string): string {\n\tconst words = name.trim().split(/\\s+/).filter(Boolean);\n\tif (words.length === 0) return '';\n\tconst first = words[0] as string;\n\tconst last = words.length > 1 ? (words.at(-1) as string) : '';\n\treturn [first, last]\n\t\t.map((word) => Array.from(word)[0] ?? '')\n\t\t.join('')\n\t\t.toUpperCase();\n}\n"
6
+ ],
7
+ "mappings": ";AAUO,SAAS,QAAQ,CAAC,MAAsB;AAAA,EAC9C,MAAM,QAAQ,KAAK,KAAK,EAAE,MAAM,KAAK,EAAE,OAAO,OAAO;AAAA,EACrD,IAAI,MAAM,WAAW;AAAA,IAAG,OAAO;AAAA,EAC/B,MAAM,QAAQ,MAAM;AAAA,EACpB,MAAM,OAAO,MAAM,SAAS,IAAK,MAAM,GAAG,EAAE,IAAe;AAAA,EAC3D,OAAO,CAAC,OAAO,IAAI,EACjB,IAAI,CAAC,SAAS,MAAM,KAAK,IAAI,EAAE,MAAM,EAAE,EACvC,KAAK,EAAE,EACP,YAAY;AAAA;",
8
+ "debugId": "BB7FB6C4C0A3758264756E2164756E21",
9
+ "names": []
10
+ }
package/docs/roadmap.md CHANGED
@@ -76,6 +76,9 @@ Nothing is in progress.
76
76
 
77
77
  ## Shipped
78
78
 
79
+ - **An avatar's initials** (`/initials`) — the first letter of a name's
80
+ first and last word, upper-cased and never cut inside a character, behind
81
+ both libraries' `AccountMenu`.
79
82
  - **A repeatable row group's focus rules** (`/repeatable-group`) — where the
80
83
  focus goes after a row is added, removed or moved, the add and remove
81
84
  limits, and what the live region announces, behind both libraries'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nxgt/material-core",
3
- "version": "0.11.1",
4
- "description": "The framework-free core of @nxgt/material and @nxgt/material-vue: the PDF document model and its react-pdf renderer, print formatters, PDF file helpers, the PDF viewer's pure modules, the currency digits, the file-size formatter, the field-blur layers, a field's first focusable control, a repeatable row group's focus and announcement rules, the aria-describedby joiner, the inert background of a modal layer, Escape forwarded while an overlay closes, the Toaster's touch-hover guard and its focus hand-back, the page's Content Security Policy nonce, an object built on first use, the zod issue messages, the date range presets, the debounce, accent-insensitive text matching and the race-free async search behind Autocomplete and SearchField, the submit guard, the code error map, the two-factor helpers (a grouped TOTP secret, the recovery codes' file, a text download), printing one element of the page, the file preview's kind detection and text reader, the pdfkit fonts Vite plugin, a CSP-safe Vite assetsInlineLimit and the Node-only pdfkit fonts resolution for Next.js and Nuxt builds",
3
+ "version": "0.12.0",
4
+ "description": "The framework-free core of @nxgt/material and @nxgt/material-vue: the PDF document model and its react-pdf renderer, print formatters, PDF file helpers, the PDF viewer's pure modules, the currency digits, the file-size formatter, the field-blur layers, a field's first focusable control, a repeatable row group's focus and announcement rules, the aria-describedby joiner, the inert background of a modal layer, Escape forwarded while an overlay closes, the Toaster's touch-hover guard and its focus hand-back, the page's Content Security Policy nonce, an object built on first use, the zod issue messages, the date range presets, the debounce, accent-insensitive text matching and the race-free async search behind Autocomplete and SearchField, the submit guard, the code error map, an avatar's initials, the two-factor helpers (a grouped TOTP secret, the recovery codes' file, a text download), printing one element of the page, the file preview's kind detection and text reader, the pdfkit fonts Vite plugin, a CSP-safe Vite assetsInlineLimit and the Node-only pdfkit fonts resolution for Next.js and Nuxt builds",
5
5
  "license": "MIT",
6
6
  "bugs": {
7
7
  "email": "stevegires@gmail.com"
@@ -178,6 +178,11 @@
178
178
  "import": "./dist/lib/debounce.js",
179
179
  "default": "./dist/lib/debounce.js"
180
180
  },
181
+ "./initials": {
182
+ "types": "./dist/lib/initials.d.ts",
183
+ "import": "./dist/lib/initials.js",
184
+ "default": "./dist/lib/initials.js"
185
+ },
181
186
  "./text-match": {
182
187
  "types": "./dist/lib/text-match.d.ts",
183
188
  "import": "./dist/lib/text-match.js",
@@ -288,6 +293,7 @@
288
293
  "src/lib/csp-nonce.ts",
289
294
  "src/lib/lazy-object.ts",
290
295
  "src/lib/debounce.ts",
296
+ "src/lib/initials.ts",
291
297
  "src/lib/text-match.ts",
292
298
  "src/lib/async-search.ts",
293
299
  "src/lib/submit-guard.ts",