@cngx/common 0.1.0-rc.6 → 0.1.0-rc.7

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 (62) hide show
  1. package/chart/README.md +85 -0
  2. package/command/README.md +157 -0
  3. package/data/README.md +23 -0
  4. package/fesm2022/cngx-common-a11y.mjs +247 -85
  5. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  6. package/fesm2022/cngx-common-audio.mjs +37 -37
  7. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  8. package/fesm2022/cngx-common-card.mjs +13 -9
  9. package/fesm2022/cngx-common-card.mjs.map +1 -1
  10. package/fesm2022/cngx-common-chart.mjs +3404 -1392
  11. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  12. package/fesm2022/cngx-common-command.mjs +144 -0
  13. package/fesm2022/cngx-common-command.mjs.map +1 -0
  14. package/fesm2022/cngx-common-data.mjs +304 -213
  15. package/fesm2022/cngx-common-data.mjs.map +1 -1
  16. package/fesm2022/cngx-common-dialog.mjs +369 -100
  17. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  18. package/fesm2022/cngx-common-display.mjs +138 -24
  19. package/fesm2022/cngx-common-display.mjs.map +1 -1
  20. package/fesm2022/cngx-common-interactive.mjs +1089 -459
  21. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  22. package/fesm2022/cngx-common-layout.mjs +113 -61
  23. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  24. package/fesm2022/cngx-common-popover.mjs +430 -54
  25. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  26. package/fesm2022/cngx-common-stepper.mjs +107 -49
  27. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  28. package/fesm2022/cngx-common-tabs.mjs +1170 -752
  29. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  30. package/fesm2022/cngx-common-timeline.mjs +1086 -0
  31. package/fesm2022/cngx-common-timeline.mjs.map +1 -0
  32. package/fesm2022/cngx-common.mjs +2 -2
  33. package/fesm2022/cngx-common.mjs.map +1 -1
  34. package/package.json +11 -1
  35. package/stepper/README.md +1 -1
  36. package/theming/components/cngx-accordion.css +3 -0
  37. package/theming/components/cngx-badge.css +22 -0
  38. package/theming/components/cngx-bottom-sheet.css +14 -2
  39. package/theming/components/cngx-breadcrumb.css +8 -0
  40. package/theming/components/cngx-button-toggle.css +44 -2
  41. package/theming/components/cngx-data-grid.css +66 -0
  42. package/theming/components/cngx-dialog.css +12 -0
  43. package/theming/components/cngx-divider.css +12 -0
  44. package/theming/components/cngx-listbox.css +27 -0
  45. package/theming/components/cngx-menu.css +36 -0
  46. package/theming/components/cngx-ripple.css +1 -1
  47. package/theming/components/cngx-tooltip.css +11 -0
  48. package/types/cngx-common-a11y.d.ts +63 -17
  49. package/types/cngx-common-audio.d.ts +32 -32
  50. package/types/cngx-common-card.d.ts +10 -3
  51. package/types/cngx-common-chart.d.ts +1281 -141
  52. package/types/cngx-common-command.d.ts +167 -0
  53. package/types/cngx-common-data.d.ts +264 -98
  54. package/types/cngx-common-dialog.d.ts +214 -25
  55. package/types/cngx-common-display.d.ts +83 -13
  56. package/types/cngx-common-interactive.d.ts +708 -174
  57. package/types/cngx-common-layout.d.ts +48 -1
  58. package/types/cngx-common-popover.d.ts +120 -3
  59. package/types/cngx-common-stepper.d.ts +55 -5
  60. package/types/cngx-common-tabs.d.ts +386 -25
  61. package/types/cngx-common-timeline.d.ts +1059 -0
  62. package/types/cngx-common.d.ts +1 -1
@@ -0,0 +1,144 @@
1
+ import { InjectionToken, inject, computed } from '@angular/core';
2
+
3
+ /**
4
+ * Multi-token every `provideCommands` call contributes to. App parts register
5
+ * command sets against it without a central list, mirroring `provideCngxMenu`.
6
+ * The generic is the collected array (as with Angular's `HTTP_INTERCEPTORS`),
7
+ * so `inject(CNGX_COMMAND_SOURCE)` returns every contributed source.
8
+ *
9
+ * @category common/command
10
+ * @since 0.1.0
11
+ */
12
+ const CNGX_COMMAND_SOURCE = new InjectionToken('CNGX_COMMAND_SOURCE');
13
+ /**
14
+ * Registers one or more command sources. Each source becomes a `multi` entry
15
+ * on {@link CNGX_COMMAND_SOURCE}; call `provideCommands` from several app parts
16
+ * and `injectCommands` merges all of them.
17
+ *
18
+ * Returns `Provider[]` (not `EnvironmentProviders`), so it registers at any
19
+ * injector scope - app root, a lazy route, or a component's `providers` /
20
+ * `viewProviders` - letting a route or component contribute a scoped command
21
+ * set without reaching for the raw {@link CNGX_COMMAND_SOURCE} multi-provider.
22
+ *
23
+ * ```ts
24
+ * // app root
25
+ * bootstrapApplication(AppComponent, { providers: [provideCommands(fileCommands)] });
26
+ * // or component scope
27
+ * @Component({ viewProviders: [provideCommands(editorCommands)] })
28
+ * ```
29
+ *
30
+ * @category common/command
31
+ * @since 0.1.0
32
+ */
33
+ function provideCommands(...sources) {
34
+ return sources.map((source) => ({ provide: CNGX_COMMAND_SOURCE, useValue: source, multi: true }));
35
+ }
36
+ /**
37
+ * Merges every registered {@link CNGX_COMMAND_SOURCE} into one reactive
38
+ * `Signal<readonly CngxCommand[]>`. The merge carries an explicit `equal`
39
+ * (length + per-command identity) so re-emitting an identical set - the same
40
+ * command references in the same order - does not produce a fresh array and
41
+ * cascade the downstream match `computed()`.
42
+ *
43
+ * Must run in an injection context.
44
+ *
45
+ * @category common/command
46
+ * @since 0.1.0
47
+ */
48
+ function injectCommands() {
49
+ const sources = inject(CNGX_COMMAND_SOURCE, { optional: true }) ?? [];
50
+ return computed(() => sources.flatMap(readSource), { equal: commandsEqual });
51
+ }
52
+ /** @internal Reads a source, unwrapping a signal or passing an array through. */
53
+ function readSource(source) {
54
+ return typeof source === 'function' ? source() : source;
55
+ }
56
+ /**
57
+ * @internal Length + per-command identity. Identity subsumes id equality, so a
58
+ * re-provided set of the same references short-circuits without re-emitting.
59
+ */
60
+ function commandsEqual(a, b) {
61
+ if (a === b) {
62
+ return true;
63
+ }
64
+ if (a.length !== b.length) {
65
+ return false;
66
+ }
67
+ return a.every((command, i) => command === b[i]);
68
+ }
69
+
70
+ /**
71
+ * Builds the default matcher: a pure label/keyword ranker. An empty query
72
+ * returns every (scoped) command at score `0` in registration order; a
73
+ * non-empty query keeps only commands that match label or keyword, ranked
74
+ * label-exact > label-prefix > label-substring > keyword. The optional scope
75
+ * filters to commands whose `group` equals it.
76
+ *
77
+ * @category common/command
78
+ * @since 0.1.0
79
+ */
80
+ function createDefaultCommandMatcher() {
81
+ return (commands, term, scope) => {
82
+ const scoped = scope ? commands.filter((command) => command.group === scope) : commands;
83
+ const query = term.trim().toLowerCase();
84
+ if (query.length === 0) {
85
+ return scoped.map((command) => ({ command, score: 0 }));
86
+ }
87
+ const ranked = [];
88
+ for (const command of scoped) {
89
+ const score = scoreCommand(command, query);
90
+ if (score > 0) {
91
+ ranked.push({ command, score });
92
+ }
93
+ }
94
+ // Stable within equal scores: the sort is stable in V8, so registration
95
+ // order breaks ties.
96
+ ranked.sort((a, b) => b.score - a.score);
97
+ return ranked;
98
+ };
99
+ }
100
+ /** @internal Scores one command against a lower-cased query; `0` means no match. */
101
+ function scoreCommand(command, query) {
102
+ const label = command.label.toLowerCase();
103
+ if (label === query) {
104
+ return 100;
105
+ }
106
+ if (label.startsWith(query)) {
107
+ return 80;
108
+ }
109
+ if (label.includes(query)) {
110
+ return 60;
111
+ }
112
+ for (const keyword of command.keywords ?? []) {
113
+ const value = keyword.toLowerCase();
114
+ if (value === query) {
115
+ return 50;
116
+ }
117
+ if (value.startsWith(query)) {
118
+ return 40;
119
+ }
120
+ if (value.includes(query)) {
121
+ return 20;
122
+ }
123
+ }
124
+ return 0;
125
+ }
126
+
127
+ /**
128
+ * Swappable match-strategy seam. Defaults to {@link createDefaultCommandMatcher}
129
+ * (pure label/keyword ranking). Override it - app-wide via `providers` or
130
+ * per-component via `viewProviders` - to drop in a fuzzy/Levenshtein ranker
131
+ * without touching the panel. The fuzzy engine stays a consumer swap; the
132
+ * default bundle ships only the pure ranker.
133
+ *
134
+ * @category common/command
135
+ * @since 0.1.0
136
+ */
137
+ const CNGX_COMMAND_MATCH_FACTORY = new InjectionToken('CNGX_COMMAND_MATCH_FACTORY', { providedIn: 'root', factory: () => createDefaultCommandMatcher });
138
+
139
+ /**
140
+ * Generated bundle index. Do not edit.
141
+ */
142
+
143
+ export { CNGX_COMMAND_MATCH_FACTORY, CNGX_COMMAND_SOURCE, createDefaultCommandMatcher, injectCommands, provideCommands };
144
+ //# sourceMappingURL=cngx-common-command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cngx-common-command.mjs","sources":["../../../projects/common/command/provide-commands.ts","../../../projects/common/command/match.ts","../../../projects/common/command/match-strategy.token.ts","../../../projects/common/command/cngx-common-command.ts"],"sourcesContent":["import {\n computed,\n inject,\n InjectionToken,\n type Provider,\n type Signal,\n} from '@angular/core';\n\nimport type { CngxCommand } from './command';\n\n/**\n * A command contribution. Either a static list or a reactive `Signal` of\n * commands - a signal source lets a contributor add or remove commands (or\n * flip a command's `disabled`) live, and `injectCommands` tracks it.\n *\n * @category common/command\n * @since 0.1.0\n */\nexport type CngxCommandSource = Signal<readonly CngxCommand[]> | readonly CngxCommand[];\n\n/**\n * Multi-token every `provideCommands` call contributes to. App parts register\n * command sets against it without a central list, mirroring `provideCngxMenu`.\n * The generic is the collected array (as with Angular's `HTTP_INTERCEPTORS`),\n * so `inject(CNGX_COMMAND_SOURCE)` returns every contributed source.\n *\n * @category common/command\n * @since 0.1.0\n */\nexport const CNGX_COMMAND_SOURCE = new InjectionToken<readonly CngxCommandSource[]>(\n 'CNGX_COMMAND_SOURCE',\n);\n\n/**\n * Registers one or more command sources. Each source becomes a `multi` entry\n * on {@link CNGX_COMMAND_SOURCE}; call `provideCommands` from several app parts\n * and `injectCommands` merges all of them.\n *\n * Returns `Provider[]` (not `EnvironmentProviders`), so it registers at any\n * injector scope - app root, a lazy route, or a component's `providers` /\n * `viewProviders` - letting a route or component contribute a scoped command\n * set without reaching for the raw {@link CNGX_COMMAND_SOURCE} multi-provider.\n *\n * ```ts\n * // app root\n * bootstrapApplication(AppComponent, { providers: [provideCommands(fileCommands)] });\n * // or component scope\n * @Component({ viewProviders: [provideCommands(editorCommands)] })\n * ```\n *\n * @category common/command\n * @since 0.1.0\n */\nexport function provideCommands(...sources: CngxCommandSource[]): Provider[] {\n return sources.map((source) => ({ provide: CNGX_COMMAND_SOURCE, useValue: source, multi: true }));\n}\n\n/**\n * Merges every registered {@link CNGX_COMMAND_SOURCE} into one reactive\n * `Signal<readonly CngxCommand[]>`. The merge carries an explicit `equal`\n * (length + per-command identity) so re-emitting an identical set - the same\n * command references in the same order - does not produce a fresh array and\n * cascade the downstream match `computed()`.\n *\n * Must run in an injection context.\n *\n * @category common/command\n * @since 0.1.0\n */\nexport function injectCommands(): Signal<readonly CngxCommand[]> {\n const sources = inject(CNGX_COMMAND_SOURCE, { optional: true }) ?? [];\n return computed(() => sources.flatMap(readSource), { equal: commandsEqual });\n}\n\n/** @internal Reads a source, unwrapping a signal or passing an array through. */\nfunction readSource(source: CngxCommandSource): readonly CngxCommand[] {\n return typeof source === 'function' ? source() : source;\n}\n\n/**\n * @internal Length + per-command identity. Identity subsumes id equality, so a\n * re-provided set of the same references short-circuits without re-emitting.\n */\nfunction commandsEqual(a: readonly CngxCommand[], b: readonly CngxCommand[]): boolean {\n if (a === b) {\n return true;\n }\n if (a.length !== b.length) {\n return false;\n }\n return a.every((command, i) => command === b[i]);\n}\n","import type { CngxCommand } from './command';\n\n/**\n * A command paired with its match score for a given query. Higher scores rank\n * first. The palette renders these in order; the row slot reads `command` and\n * the term to highlight.\n *\n * @category common/command\n * @since 0.1.0\n */\nexport interface RankedCommand {\n /** The matched command. */\n readonly command: CngxCommand;\n /** Relevance score for the query; higher ranks first. `0` for an empty query. */\n readonly score: number;\n}\n\n/**\n * Ranks and filters a command set against a query and optional scope. Swappable\n * via {@link CNGX_COMMAND_MATCH_FACTORY} - a consumer drops in Levenshtein or a\n * fuzzy engine without touching the panel.\n *\n * @category common/command\n * @since 0.1.0\n */\nexport type CngxCommandMatcher = (\n commands: readonly CngxCommand[],\n term: string,\n scope?: string,\n) => readonly RankedCommand[];\n\n/**\n * Builds the default matcher: a pure label/keyword ranker. An empty query\n * returns every (scoped) command at score `0` in registration order; a\n * non-empty query keeps only commands that match label or keyword, ranked\n * label-exact > label-prefix > label-substring > keyword. The optional scope\n * filters to commands whose `group` equals it.\n *\n * @category common/command\n * @since 0.1.0\n */\nexport function createDefaultCommandMatcher(): CngxCommandMatcher {\n return (commands, term, scope) => {\n const scoped = scope ? commands.filter((command) => command.group === scope) : commands;\n const query = term.trim().toLowerCase();\n if (query.length === 0) {\n return scoped.map((command) => ({ command, score: 0 }));\n }\n\n const ranked: RankedCommand[] = [];\n for (const command of scoped) {\n const score = scoreCommand(command, query);\n if (score > 0) {\n ranked.push({ command, score });\n }\n }\n // Stable within equal scores: the sort is stable in V8, so registration\n // order breaks ties.\n ranked.sort((a, b) => b.score - a.score);\n return ranked;\n };\n}\n\n/** @internal Scores one command against a lower-cased query; `0` means no match. */\nfunction scoreCommand(command: CngxCommand, query: string): number {\n const label = command.label.toLowerCase();\n if (label === query) {\n return 100;\n }\n if (label.startsWith(query)) {\n return 80;\n }\n if (label.includes(query)) {\n return 60;\n }\n for (const keyword of command.keywords ?? []) {\n const value = keyword.toLowerCase();\n if (value === query) {\n return 50;\n }\n if (value.startsWith(query)) {\n return 40;\n }\n if (value.includes(query)) {\n return 20;\n }\n }\n return 0;\n}\n","import { InjectionToken } from '@angular/core';\n\nimport { createDefaultCommandMatcher, type CngxCommandMatcher } from './match';\n\n/**\n * Factory producing a {@link CngxCommandMatcher}. The exact signature is\n * captured so an override matches it precisely.\n *\n * @category common/command\n * @since 0.1.0\n */\nexport type CngxCommandMatchFactory = () => CngxCommandMatcher;\n\n/**\n * Swappable match-strategy seam. Defaults to {@link createDefaultCommandMatcher}\n * (pure label/keyword ranking). Override it - app-wide via `providers` or\n * per-component via `viewProviders` - to drop in a fuzzy/Levenshtein ranker\n * without touching the panel. The fuzzy engine stays a consumer swap; the\n * default bundle ships only the pure ranker.\n *\n * @category common/command\n * @since 0.1.0\n */\nexport const CNGX_COMMAND_MATCH_FACTORY = new InjectionToken<CngxCommandMatchFactory>(\n 'CNGX_COMMAND_MATCH_FACTORY',\n { providedIn: 'root', factory: () => createDefaultCommandMatcher },\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAoBA;;;;;;;;AAQG;MACU,mBAAmB,GAAG,IAAI,cAAc,CACnD,qBAAqB;AAGvB;;;;;;;;;;;;;;;;;;;AAmBG;AACG,SAAU,eAAe,CAAC,GAAG,OAA4B,EAAA;IAC7D,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACnG;AAEA;;;;;;;;;;;AAWG;SACa,cAAc,GAAA;AAC5B,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE;AACrE,IAAA,OAAO,QAAQ,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AAC9E;AAEA;AACA,SAAS,UAAU,CAAC,MAAyB,EAAA;AAC3C,IAAA,OAAO,OAAO,MAAM,KAAK,UAAU,GAAG,MAAM,EAAE,GAAG,MAAM;AACzD;AAEA;;;AAGG;AACH,SAAS,aAAa,CAAC,CAAyB,EAAE,CAAyB,EAAA;AACzE,IAAA,IAAI,CAAC,KAAK,CAAC,EAAE;AACX,QAAA,OAAO,IAAI;IACb;IACA,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE;AACzB,QAAA,OAAO,KAAK;IACd;AACA,IAAA,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EA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