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

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/card/README.md +2 -1
  2. package/data/README.md +10 -1
  3. package/dialog/README.md +23 -1
  4. package/fesm2022/cngx-common-a11y.mjs +125 -111
  5. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  6. package/fesm2022/cngx-common-audio.mjs +47 -5
  7. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  8. package/fesm2022/cngx-common-card.mjs +300 -46
  9. package/fesm2022/cngx-common-card.mjs.map +1 -1
  10. package/fesm2022/cngx-common-chart.mjs +1176 -453
  11. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  12. package/fesm2022/cngx-common-command.mjs +37 -10
  13. package/fesm2022/cngx-common-command.mjs.map +1 -1
  14. package/fesm2022/cngx-common-data.mjs +1318 -469
  15. package/fesm2022/cngx-common-data.mjs.map +1 -1
  16. package/fesm2022/cngx-common-dialog.mjs +151 -14
  17. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  18. package/fesm2022/cngx-common-display.mjs +340 -73
  19. package/fesm2022/cngx-common-display.mjs.map +1 -1
  20. package/fesm2022/cngx-common-interactive.mjs +1744 -952
  21. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  22. package/fesm2022/cngx-common-layout.mjs +841 -114
  23. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  24. package/fesm2022/cngx-common-popover.mjs +350 -60
  25. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  26. package/fesm2022/cngx-common-stepper.mjs +727 -317
  27. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  28. package/fesm2022/cngx-common-tabs.mjs +1601 -1243
  29. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  30. package/fesm2022/cngx-common-timeline.mjs +137 -53
  31. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  32. package/fesm2022/cngx-common.mjs +1 -1
  33. package/interactive/README.md +15 -4
  34. package/layout/README.md +21 -1
  35. package/package.json +3 -3
  36. package/popover/README.md +18 -2
  37. package/stepper/README.md +6 -4
  38. package/theming/components/cngx-accordion.css +1 -1
  39. package/theming/components/cngx-backdrop.css +12 -0
  40. package/theming/components/cngx-button-toggle.css +29 -3
  41. package/theming/components/cngx-data-grid.css +168 -1
  42. package/theming/components/cngx-dialog.css +13 -0
  43. package/theming/components/cngx-listbox.css +21 -12
  44. package/theming/components/cngx-menu.css +56 -16
  45. package/theming/components/cngx-popover.css +24 -0
  46. package/theming/components/cngx-recycler-placeholder.css +196 -0
  47. package/theming/components/cngx-ripple.css +1 -1
  48. package/theming/components/cngx-slider.css +32 -1
  49. package/theming/components/cngx-tooltip.css +12 -0
  50. package/timeline/README.md +155 -0
  51. package/types/cngx-common-a11y.d.ts +42 -18
  52. package/types/cngx-common-card.d.ts +201 -17
  53. package/types/cngx-common-chart.d.ts +343 -47
  54. package/types/cngx-common-command.d.ts +31 -8
  55. package/types/cngx-common-data.d.ts +581 -68
  56. package/types/cngx-common-dialog.d.ts +158 -3
  57. package/types/cngx-common-display.d.ts +356 -142
  58. package/types/cngx-common-interactive.d.ts +859 -210
  59. package/types/cngx-common-layout.d.ts +567 -28
  60. package/types/cngx-common-popover.d.ts +262 -39
  61. package/types/cngx-common-stepper.d.ts +366 -116
  62. package/types/cngx-common-tabs.d.ts +214 -50
  63. package/types/cngx-common-timeline.d.ts +82 -16
@@ -1,4 +1,5 @@
1
1
  import { InjectionToken, inject, computed } from '@angular/core';
2
+ import { foldForMatching, injectLocale } from '@cngx/core/utils';
2
3
 
3
4
  /**
4
5
  * Multi-token every `provideCommands` call contributes to. App parts register
@@ -74,19 +75,47 @@ function commandsEqual(a, b) {
74
75
  * label-exact > label-prefix > label-substring > keyword. The optional scope
75
76
  * filters to commands whose `group` equals it.
76
77
  *
78
+ * Query, labels and keywords are compared case- and accent-tolerant
79
+ * ({@link foldForMatching}): `uber` finds `Über`. Pass the app locale (the
80
+ * default `CNGX_COMMAND_MATCH_FACTORY` passes `injectLocale()`) so case folds
81
+ * by its rules, e.g. Turkish `I` / `ı`; read inside a `computed()`, a locale
82
+ * switch re-ranks.
83
+ *
77
84
  * @category common/command
78
85
  * @since 0.1.0
79
86
  */
80
- function createDefaultCommandMatcher() {
87
+ function createDefaultCommandMatcher(locale) {
88
+ // Folded label and keywords per command, re-folded only when the label, the
89
+ // keywords array or the locale changes - not on every keystroke.
90
+ const folded = new WeakMap();
91
+ const foldedFor = (command, activeLocale) => {
92
+ const hit = folded.get(command);
93
+ if (hit !== undefined &&
94
+ hit.locale === activeLocale &&
95
+ hit.sourceLabel === command.label &&
96
+ hit.sourceKeywords === command.keywords) {
97
+ return hit;
98
+ }
99
+ const entry = {
100
+ locale: activeLocale,
101
+ sourceLabel: command.label,
102
+ sourceKeywords: command.keywords,
103
+ label: foldForMatching(command.label, activeLocale),
104
+ keywords: (command.keywords ?? []).map((keyword) => foldForMatching(keyword, activeLocale)),
105
+ };
106
+ folded.set(command, entry);
107
+ return entry;
108
+ };
81
109
  return (commands, term, scope) => {
82
110
  const scoped = scope ? commands.filter((command) => command.group === scope) : commands;
83
- const query = term.trim().toLowerCase();
111
+ const activeLocale = locale?.();
112
+ const query = foldForMatching(term.trim(), activeLocale);
84
113
  if (query.length === 0) {
85
114
  return scoped.map((command) => ({ command, score: 0 }));
86
115
  }
87
116
  const ranked = [];
88
117
  for (const command of scoped) {
89
- const score = scoreCommand(command, query);
118
+ const score = scoreCommand(foldedFor(command, activeLocale), query);
90
119
  if (score > 0) {
91
120
  ranked.push({ command, score });
92
121
  }
@@ -97,9 +126,8 @@ function createDefaultCommandMatcher() {
97
126
  return ranked;
98
127
  };
99
128
  }
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();
129
+ /** @internal Scores one folded command against a folded query; `0` means no match. */
130
+ function scoreCommand({ label, keywords }, query) {
103
131
  if (label === query) {
104
132
  return 100;
105
133
  }
@@ -109,8 +137,7 @@ function scoreCommand(command, query) {
109
137
  if (label.includes(query)) {
110
138
  return 60;
111
139
  }
112
- for (const keyword of command.keywords ?? []) {
113
- const value = keyword.toLowerCase();
140
+ for (const value of keywords) {
114
141
  if (value === query) {
115
142
  return 50;
116
143
  }
@@ -126,7 +153,7 @@ function scoreCommand(command, query) {
126
153
 
127
154
  /**
128
155
  * Swappable match-strategy seam. Defaults to {@link createDefaultCommandMatcher}
129
- * (pure label/keyword ranking). Override it - app-wide via `providers` or
156
+ * (pure label/keyword ranking, case- and accent-tolerant in the app locale). Override it - app-wide via `providers` or
130
157
  * per-component via `viewProviders` - to drop in a fuzzy/Levenshtein ranker
131
158
  * without touching the panel. The fuzzy engine stays a consumer swap; the
132
159
  * default bundle ships only the pure ranker.
@@ -134,7 +161,7 @@ function scoreCommand(command, query) {
134
161
  * @category common/command
135
162
  * @since 0.1.0
136
163
  */
137
- const CNGX_COMMAND_MATCH_FACTORY = new InjectionToken('CNGX_COMMAND_MATCH_FACTORY', { providedIn: 'root', factory: () => createDefaultCommandMatcher });
164
+ const CNGX_COMMAND_MATCH_FACTORY = new InjectionToken('CNGX_COMMAND_MATCH_FACTORY', { providedIn: 'root', factory: () => () => createDefaultCommandMatcher(injectLocale()) });
138
165
 
139
166
  /**
140
167
  * Generated bundle index. Do not edit.
@@ -1 +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,E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+ {"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 { Signal } from '@angular/core';\nimport { foldForMatching } from '@cngx/core/utils';\n\nimport 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 CngxRankedCommand {\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 * @deprecated Use {@link CngxRankedCommand}. Published under the unprefixed\n * name by mistake; the alias remains for compatibility and will be removed in\n * a future major.\n * @category common/command\n * @since 0.1.0\n */\nexport type RankedCommand = CngxRankedCommand;\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 CngxRankedCommand[];\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 * Query, labels and keywords are compared case- and accent-tolerant\n * ({@link foldForMatching}): `uber` finds `Über`. Pass the app locale (the\n * default `CNGX_COMMAND_MATCH_FACTORY` passes `injectLocale()`) so case folds\n * by its rules, e.g. Turkish `I` / `ı`; read inside a `computed()`, a locale\n * switch re-ranks.\n *\n * @category common/command\n * @since 0.1.0\n */\nexport function createDefaultCommandMatcher(locale?: Signal<string>): CngxCommandMatcher {\n // Folded label and keywords per command, re-folded only when the label, the\n // keywords array or the locale changes - not on every keystroke.\n const folded = new WeakMap<CngxCommand, FoldedCommand>();\n const foldedFor = (command: CngxCommand, activeLocale: string | undefined): FoldedCommand => {\n const hit = folded.get(command);\n if (\n hit !== undefined &&\n hit.locale === activeLocale &&\n hit.sourceLabel === command.label &&\n hit.sourceKeywords === command.keywords\n ) {\n return hit;\n }\n const entry: FoldedCommand = {\n locale: activeLocale,\n sourceLabel: command.label,\n sourceKeywords: command.keywords,\n label: foldForMatching(command.label, activeLocale),\n keywords: (command.keywords ?? []).map((keyword) => foldForMatching(keyword, activeLocale)),\n };\n folded.set(command, entry);\n return entry;\n };\n\n return (commands, term, scope) => {\n const scoped = scope ? commands.filter((command) => command.group === scope) : commands;\n const activeLocale = locale?.();\n const query = foldForMatching(term.trim(), activeLocale);\n if (query.length === 0) {\n return scoped.map((command) => ({ command, score: 0 }));\n }\n\n const ranked: CngxRankedCommand[] = [];\n for (const command of scoped) {\n const score = scoreCommand(foldedFor(command, activeLocale), 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 A command's label and keywords, folded for one locale. */\ninterface FoldedCommand {\n readonly locale: string | undefined;\n readonly sourceLabel: string;\n readonly sourceKeywords: CngxCommand['keywords'];\n readonly label: string;\n readonly keywords: readonly string[];\n}\n\n/** @internal Scores one folded command against a folded query; `0` means no match. */\nfunction scoreCommand({ label, keywords }: FoldedCommand, query: string): number {\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 value of keywords) {\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';\nimport { injectLocale } from '@cngx/core/utils';\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. The panel calls it in an\n * injection context, so a factory may `inject()` what its matcher needs.\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, case- and accent-tolerant in the app locale). 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(injectLocale()) },\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,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