@nxgt/material-core 0.5.0 → 0.6.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,15 @@
1
1
  # @nxgt/material-core
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#468](https://github.com/softistx/nxgt-material/pull/468) [`5f984fa`](https://github.com/softistx/nxgt-material/commit/5f984fa95a2944e6c71acd81d0272730d87c2c0a) Thanks [@SteveGT96](https://github.com/SteveGT96)! - New subpath `@nxgt/material-core/emoji-groups`: `groupKey`, `groupEmojis`, `searchEmojis`, `groupName`, `GROUP_NAMES` and the type `EmojiItem`, the emoji list's grouping, search and group names that both libraries kept a copy of.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#470](https://github.com/softistx/nxgt-material/pull/470) [`853d093`](https://github.com/softistx/nxgt-material/commit/853d093f0620dc6940ea1ce69e025b61e3b0094d) Thanks [@SteveGT96](https://github.com/SteveGT96)! - The roadmap names the release that ships the two Tabs looks and the emoji groups.
12
+
3
13
  ## 0.5.0
4
14
 
5
15
  ### Minor Changes
package/README.md CHANGED
@@ -5,9 +5,9 @@ The framework-free core that [`@nxgt/material`](https://www.npmjs.com/package/@n
5
5
  (Vue) share, as one copy: the PDF document model and its react-pdf renderer,
6
6
  the print formatters, the PDF file helpers, the PDF viewer's framework-free
7
7
  half (page geometry, scroll spy, text search), the currency field's decimals,
8
- the file-size formatter, the slider's tick marks, the date range presets, the
9
- file preview's kind detection, the fields' blur rule, a field's first
10
- reachable control (`/focus-control`) and its `aria-describedby`
8
+ the file-size formatter, the slider's tick marks, the emoji list's groups,
9
+ the date range presets, the file preview's kind detection, the fields' blur
10
+ rule, a field's first reachable control (`/focus-control`) and its `aria-describedby`
11
11
  (`/described-by`), the page behind a modal layer made inert
12
12
  (`/inert-others`), Escape pressed while an overlay closes
13
13
  (`/escape-forward`), the Toaster's guard against a tap's emulated hover
@@ -89,6 +89,7 @@ built-in.
89
89
  | `/row-activation` | `isRowActivation`, `followRowLink`, `ROW_CONTROL_SELECTOR`, `ROW_LINK_SELECTOR`, `RowClick` — whether a click on a table row follows its link, and following it |
90
90
  | `/format-file-size` | `formatFileSize` — a byte count as `'1.5 KB'` |
91
91
  | `/slider-ticks` | `tickValues` — where a slider's tick marks sit |
92
+ | `/emoji-groups` | `groupKey`, `groupEmojis`, `searchEmojis`, `groupName`, `GROUP_NAMES` and the type `EmojiItem` — how the emoji list groups, searches and names its emojis |
92
93
  | `/date-range` | `DATE_RANGE_PRESET_IDS`, `presetRange`, `resolvePresetRange`, `isSameDayRange`, `isRangeDisabled`, `withTimeOf`, `endOfDayTime`, `clampRangeEnd`, `keepRangeTimes` and the types `DayRange`, `PartialDayRange`, `DateRangePreset`, `DateRangePresetId`, `DateRangePresetOption`, `DateRangeRules` — `DateRangeField`'s presets and times |
93
94
  | `/file-preview` | `fileKind`, `describeFile`, `safePreviewUrl`, `readTextPreview`, `FilePreviewHttpError`, `FilePreviewUnsafeUrlError`, `TEXT_PREVIEW_MAX_BYTES`, `fileExtension`, `fileNameFromUrl`, `dataUrlType`, `kindOfMimeType`, `normaliseMimeType`, `isTextFileKind`, `TEXT_FILE_KINDS` and the types `FileKind`, `FileKindInput`, `DescribedFile`, `FilePreviewSource`, `TextPreview` — `FilePreview`'s kind detection, URL allow-list and text reader |
94
95
  | `/vite` | `pdfkitStandardFonts()` — see below |
@@ -372,6 +373,22 @@ tickValues(0, 100, true, 1).length; // 21 — capped
372
373
  tickValues(5, 5, true); // [5] — min === max
373
374
  ```
374
375
 
376
+ ### The emoji list's groups: `/emoji-groups`
377
+
378
+ How both libraries' `EmojiList` groups, searches and names its emojis:
379
+ `groupKey` turns a catalog group into a key, `groupEmojis` builds the tabs
380
+ (`all`, `recent`, then one per group), `searchEmojis` filters by name or
381
+ shortcode, `groupName` gives a key's English name (a key it does not know
382
+ reads as its words).
383
+
384
+ ```ts
385
+ import { groupName, searchEmojis } from '@nxgt/material-core/emoji-groups';
386
+
387
+ groupName('people_body'); // 'People & body'
388
+ groupName('hand_signs'); // 'Hand signs'
389
+ searchEmojis([{ name: 'fire' }], 'FIR'); // [{ name: 'fire' }]
390
+ ```
391
+
375
392
  ### A date range's presets and times: `/date-range`
376
393
 
377
394
  The pure half of both libraries' `DateRangeField` (`presets`, `withTime` /
@@ -0,0 +1,20 @@
1
+ /** What the grouping functions read of an emoji. */
2
+ export type EmojiItem = {
3
+ name: string;
4
+ emoji?: string;
5
+ group?: string | null;
6
+ shortcodes?: string[];
7
+ };
8
+ export declare function groupKey(group?: string | null): string;
9
+ export declare function groupEmojis(emojis: EmojiItem[], recent: string[]): {
10
+ [k: string]: EmojiItem[];
11
+ };
12
+ export declare function searchEmojis(emojis: EmojiItem[], query: string): EmojiItem[] | null;
13
+ export declare const GROUP_NAMES: Record<string, string>;
14
+ /**
15
+ * A group's English name, the fallback of `material.emoji.groups.<key>`: the
16
+ * name of the icon-only tab that shows it. A key the bundles do not name
17
+ * (`hand_signs`) reads as its words (`Hand signs`).
18
+ */
19
+ export declare function groupName(key: string): string;
20
+ //# sourceMappingURL=emoji-groups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emoji-groups.d.ts","sourceRoot":"","sources":["../../src/lib/emoji-groups.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,MAAM,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,UAI7C;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;;EAehE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,sBAO9D;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAa9C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,UAGpC"}
@@ -0,0 +1,58 @@
1
+ // src/lib/emoji-groups.ts
2
+ function groupKey(group) {
3
+ const raw = group?.trim();
4
+ if (!raw)
5
+ return "general";
6
+ return raw.toLowerCase().replace(/ & /g, "_").replace(/\s+/g, "_");
7
+ }
8
+ function groupEmojis(emojis, recent) {
9
+ const groups = {
10
+ all: emojis
11
+ };
12
+ const recentItems = recent.map((name) => emojis.find((item) => item.name === name)).filter((item) => Boolean(item));
13
+ if (recentItems.length > 0)
14
+ groups.recent = recentItems;
15
+ for (const item of emojis) {
16
+ const key = groupKey(item.group);
17
+ groups[key] = [...groups[key] ?? [], item];
18
+ }
19
+ return Object.fromEntries(Object.entries(groups).filter(([, items]) => items.length > 0));
20
+ }
21
+ function searchEmojis(emojis, query) {
22
+ const needle = query.trim().toLowerCase();
23
+ if (!needle)
24
+ return null;
25
+ return emojis.filter((item) => {
26
+ if (item.name.toLowerCase().includes(needle))
27
+ return true;
28
+ return item.shortcodes?.some((code) => code.toLowerCase().includes(needle));
29
+ });
30
+ }
31
+ var GROUP_NAMES = {
32
+ all: "All",
33
+ recent: "Recent",
34
+ general: "General",
35
+ people_body: "People & body",
36
+ components: "Components",
37
+ animals_nature: "Animals & nature",
38
+ food_drink: "Food & drink",
39
+ travel_places: "Travel & places",
40
+ activities: "Activities",
41
+ objects: "Objects",
42
+ symbols: "Symbols",
43
+ flags: "Flags"
44
+ };
45
+ function groupName(key) {
46
+ const words = key.replace(/_/g, " ");
47
+ return GROUP_NAMES[key] ?? words.charAt(0).toUpperCase() + words.slice(1);
48
+ }
49
+ export {
50
+ GROUP_NAMES,
51
+ groupEmojis,
52
+ groupKey,
53
+ groupName,
54
+ searchEmojis
55
+ };
56
+
57
+ //# debugId=78A2C18812F7925A64756E2164756E21
58
+ //# sourceMappingURL=emoji-groups.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lib/emoji-groups.ts"],
4
+ "sourcesContent": [
5
+ "/** What the grouping functions read of an emoji. */\nexport type EmojiItem = {\n\tname: string;\n\temoji?: string;\n\tgroup?: string | null;\n\tshortcodes?: string[];\n};\n\nexport function groupKey(group?: string | null) {\n\tconst raw = group?.trim();\n\tif (!raw) return 'general';\n\treturn raw.toLowerCase().replace(/ & /g, '_').replace(/\\s+/g, '_');\n}\n\nexport function groupEmojis(emojis: EmojiItem[], recent: string[]) {\n\tconst groups: Record<string, EmojiItem[]> = {\n\t\tall: emojis,\n\t};\n\tconst recentItems = recent\n\t\t.map((name) => emojis.find((item) => item.name === name))\n\t\t.filter((item): item is EmojiItem => Boolean(item));\n\tif (recentItems.length > 0) groups.recent = recentItems;\n\tfor (const item of emojis) {\n\t\tconst key = groupKey(item.group);\n\t\tgroups[key] = [...(groups[key] ?? []), item];\n\t}\n\treturn Object.fromEntries(\n\t\tObject.entries(groups).filter(([, items]) => items.length > 0),\n\t);\n}\n\nexport function searchEmojis(emojis: EmojiItem[], query: string) {\n\tconst needle = query.trim().toLowerCase();\n\tif (!needle) return null;\n\treturn emojis.filter((item) => {\n\t\tif (item.name.toLowerCase().includes(needle)) return true;\n\t\treturn item.shortcodes?.some((code) => code.toLowerCase().includes(needle));\n\t});\n}\n\nexport const GROUP_NAMES: Record<string, string> = {\n\tall: 'All',\n\trecent: 'Recent',\n\tgeneral: 'General',\n\tpeople_body: 'People & body',\n\tcomponents: 'Components',\n\tanimals_nature: 'Animals & nature',\n\tfood_drink: 'Food & drink',\n\ttravel_places: 'Travel & places',\n\tactivities: 'Activities',\n\tobjects: 'Objects',\n\tsymbols: 'Symbols',\n\tflags: 'Flags',\n};\n\n/**\n * A group's English name, the fallback of `material.emoji.groups.<key>`: the\n * name of the icon-only tab that shows it. A key the bundles do not name\n * (`hand_signs`) reads as its words (`Hand signs`).\n */\nexport function groupName(key: string) {\n\tconst words = key.replace(/_/g, ' ');\n\treturn GROUP_NAMES[key] ?? words.charAt(0).toUpperCase() + words.slice(1);\n}\n"
6
+ ],
7
+ "mappings": ";AAQO,SAAS,QAAQ,CAAC,OAAuB;AAAA,EAC/C,MAAM,MAAM,OAAO,KAAK;AAAA,EACxB,IAAI,CAAC;AAAA,IAAK,OAAO;AAAA,EACjB,OAAO,IAAI,YAAY,EAAE,QAAQ,QAAQ,GAAG,EAAE,QAAQ,QAAQ,GAAG;AAAA;AAG3D,SAAS,WAAW,CAAC,QAAqB,QAAkB;AAAA,EAClE,MAAM,SAAsC;AAAA,IAC3C,KAAK;AAAA,EACN;AAAA,EACA,MAAM,cAAc,OAClB,IAAI,CAAC,SAAS,OAAO,KAAK,CAAC,SAAS,KAAK,SAAS,IAAI,CAAC,EACvD,OAAO,CAAC,SAA4B,QAAQ,IAAI,CAAC;AAAA,EACnD,IAAI,YAAY,SAAS;AAAA,IAAG,OAAO,SAAS;AAAA,EAC5C,WAAW,QAAQ,QAAQ;AAAA,IAC1B,MAAM,MAAM,SAAS,KAAK,KAAK;AAAA,IAC/B,OAAO,OAAO,CAAC,GAAI,OAAO,QAAQ,CAAC,GAAI,IAAI;AAAA,EAC5C;AAAA,EACA,OAAO,OAAO,YACb,OAAO,QAAQ,MAAM,EAAE,OAAO,IAAI,WAAW,MAAM,SAAS,CAAC,CAC9D;AAAA;AAGM,SAAS,YAAY,CAAC,QAAqB,OAAe;AAAA,EAChE,MAAM,SAAS,MAAM,KAAK,EAAE,YAAY;AAAA,EACxC,IAAI,CAAC;AAAA,IAAQ,OAAO;AAAA,EACpB,OAAO,OAAO,OAAO,CAAC,SAAS;AAAA,IAC9B,IAAI,KAAK,KAAK,YAAY,EAAE,SAAS,MAAM;AAAA,MAAG,OAAO;AAAA,IACrD,OAAO,KAAK,YAAY,KAAK,CAAC,SAAS,KAAK,YAAY,EAAE,SAAS,MAAM,CAAC;AAAA,GAC1E;AAAA;AAGK,IAAM,cAAsC;AAAA,EAClD,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AACR;AAOO,SAAS,SAAS,CAAC,KAAa;AAAA,EACtC,MAAM,QAAQ,IAAI,QAAQ,MAAM,GAAG;AAAA,EACnC,OAAO,YAAY,QAAQ,MAAM,OAAO,CAAC,EAAE,YAAY,IAAI,MAAM,MAAM,CAAC;AAAA;",
8
+ "debugId": "78A2C18812F7925A64756E2164756E21",
9
+ "names": []
10
+ }
package/docs/roadmap.md CHANGED
@@ -64,6 +64,8 @@ Nothing in progress right now; see Next.
64
64
  - **Slider ticks** (`/slider-ticks`) — the values a slider's tick marks sit
65
65
  at, which both libraries' `SliderField` (`ticks`) read from here instead of
66
66
  keeping a copy each. 0.3.0.
67
+ - **Emoji groups** (`/emoji-groups`) — how the emoji list groups, searches
68
+ and names its emojis, which both libraries' `EmojiList` read from here. 0.6.0.
67
69
  - **`formatFileSize` and the pdfkit fonts resolution** — the byte-count
68
70
  formatter both libraries' file list and upload field use
69
71
  (`/format-file-size`), and the Node-only resolution of pdfkit's standard
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxgt/material-core",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
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, the aria-describedby joiner, the inert background of a modal layer, Escape forwarded while an overlay closes, the Toaster's touch-hover guard, the zod issue messages, the date range presets, the file preview's kind detection and text reader, the pdfkit fonts Vite plugin and the Node-only pdfkit fonts resolution for Next.js and Nuxt builds",
5
5
  "license": "MIT",
6
6
  "bugs": {
@@ -138,6 +138,11 @@
138
138
  "import": "./dist/lib/slider-ticks.js",
139
139
  "default": "./dist/lib/slider-ticks.js"
140
140
  },
141
+ "./emoji-groups": {
142
+ "types": "./dist/lib/emoji-groups.d.ts",
143
+ "import": "./dist/lib/emoji-groups.js",
144
+ "default": "./dist/lib/emoji-groups.js"
145
+ },
141
146
  "./date-range": {
142
147
  "types": "./dist/lib/date-range.d.ts",
143
148
  "import": "./dist/lib/date-range.js",
@@ -216,6 +221,7 @@
216
221
  "src/lib/row-activation.ts",
217
222
  "src/lib/format-file-size.ts",
218
223
  "src/lib/slider-ticks.ts",
224
+ "src/lib/emoji-groups.ts",
219
225
  "src/lib/date-range.ts",
220
226
  "src/file-preview/index.ts",
221
227
  "src/pdf-viewer/index.ts",