@cngx/common 0.1.0-rc.9 → 0.3.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/a11y/README.md +15 -2
- package/button/README.md +258 -0
- package/command/README.md +19 -8
- package/data/README.md +10 -10
- package/fesm2022/cngx-common-a11y.mjs +701 -263
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +83 -64
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-button.mjs +1084 -0
- package/fesm2022/cngx-common-button.mjs.map +1 -0
- package/fesm2022/cngx-common-card.mjs +135 -76
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +749 -296
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +51 -29
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +695 -405
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +112 -112
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +668 -308
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +7066 -2739
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +2121 -492
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-menu-button.mjs +557 -0
- package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
- package/fesm2022/cngx-common-popover.mjs +1207 -569
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +256 -261
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +202 -262
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +28 -61
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +10 -10
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +30 -19
- package/layout/README.md +1 -1
- package/menu-button/README.md +234 -0
- package/package.json +14 -4
- package/popover/README.md +42 -5
- package/popover/tooltip-indicator.scss +52 -0
- package/schematics/ng-add/index.js +7 -7
- package/schematics/ng-add/schema.json +5 -0
- package/stepper/README.md +0 -1
- package/theming/components/cngx-accordion.css +36 -7
- package/theming/components/cngx-async.css +185 -37
- package/theming/components/cngx-backdrop.css +3 -1
- package/theming/components/cngx-badge.css +20 -5
- package/theming/components/cngx-bottom-sheet.css +2 -0
- package/theming/components/cngx-breadcrumb.css +3 -1
- package/theming/components/cngx-button-group.css +325 -0
- package/theming/components/cngx-button-toggle.css +55 -23
- package/theming/components/cngx-button.css +975 -0
- package/theming/components/cngx-data-grid.css +2 -0
- package/theming/components/cngx-dialog.css +3 -1
- package/theming/components/cngx-divider.css +24 -9
- package/theming/components/cngx-drawer.css +153 -0
- package/theming/components/cngx-icon-glyph.css +76 -0
- package/theming/components/cngx-listbox.css +79 -25
- package/theming/components/cngx-menu.css +112 -52
- package/theming/components/cngx-nav.css +1220 -0
- package/theming/components/cngx-popover-sheet.css +43 -11
- package/theming/components/cngx-popover.css +37 -13
- package/theming/components/cngx-recycler-placeholder.css +2 -0
- package/theming/components/cngx-ripple.css +74 -16
- package/theming/components/cngx-sidebar.css +71 -0
- package/theming/components/cngx-slider.css +3 -1
- package/theming/components/cngx-tooltip.css +2 -0
- package/timeline/README.md +2 -2
- package/types/cngx-common-a11y.d.ts +343 -120
- package/types/cngx-common-audio.d.ts +60 -88
- package/types/cngx-common-button.d.ts +698 -0
- package/types/cngx-common-card.d.ts +104 -78
- package/types/cngx-common-chart.d.ts +671 -384
- package/types/cngx-common-command.d.ts +44 -47
- package/types/cngx-common-data.d.ts +350 -342
- package/types/cngx-common-dialog.d.ts +91 -120
- package/types/cngx-common-display.d.ts +475 -300
- package/types/cngx-common-interactive.d.ts +4350 -1723
- package/types/cngx-common-layout.d.ts +1365 -286
- package/types/cngx-common-menu-button.d.ts +382 -0
- package/types/cngx-common-popover.d.ts +671 -289
- package/types/cngx-common-stepper.d.ts +217 -347
- package/types/cngx-common-tabs.d.ts +173 -386
- package/types/cngx-common-timeline.d.ts +25 -104
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import { InjectionToken, inject, EnvironmentInjector, computed } from '@angular/core';
|
|
1
|
+
import { InjectionToken, inject, EnvironmentInjector, computed, isSignal } from '@angular/core';
|
|
2
|
+
import { cngxDevWarn } from '@cngx/utils';
|
|
2
3
|
import { foldForMatching, injectLocale } from '@cngx/core/utils';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Multi-token every `provideCommands` call contributes to.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* that
|
|
10
|
-
*
|
|
11
|
-
* This is the low-level form. Register through `provideCommands`, which also
|
|
12
|
-
* carries a level's sources into every scope below it. A raw multi-provider on
|
|
13
|
-
* this token is carried down only from a level that also calls
|
|
14
|
-
* `provideCommands`; on any other level it is read only when that level is the
|
|
15
|
-
* one `injectCommands` resolves as nearest.
|
|
16
|
-
*
|
|
17
|
-
* @category common/command
|
|
18
|
-
* @since 0.1.0
|
|
6
|
+
* @internal Multi-token every `provideCommands` call contributes to. The
|
|
7
|
+
* generic is the collected array (as with Angular's `HTTP_INTERCEPTORS`), so
|
|
8
|
+
* `inject(CNGX_COMMAND_SOURCE)` returns the sources of the nearest level that
|
|
9
|
+
* provides it. Not part of the public API: a raw multi-provider would bypass
|
|
10
|
+
* the registry that carries a level's sources into the scopes below it.
|
|
19
11
|
*/
|
|
20
12
|
const CNGX_COMMAND_SOURCE = new InjectionToken('CNGX_COMMAND_SOURCE');
|
|
21
13
|
/**
|
|
@@ -25,14 +17,24 @@ const CNGX_COMMAND_SOURCE = new InjectionToken('CNGX_COMMAND_SOURCE');
|
|
|
25
17
|
*/
|
|
26
18
|
const CNGX_COMMAND_REGISTRY = new InjectionToken('CNGX_COMMAND_REGISTRY');
|
|
27
19
|
/**
|
|
28
|
-
* Registers one or more command sources.
|
|
29
|
-
*
|
|
30
|
-
* and `injectCommands` merges all of them.
|
|
20
|
+
* Registers one or more command sources. Call `provideCommands` from several
|
|
21
|
+
* app parts and `injectCommands` merges all of them, without a central list.
|
|
31
22
|
*
|
|
32
23
|
* Returns `Provider[]` (not `EnvironmentProviders`), so it registers at any
|
|
33
24
|
* injector scope - app root, a lazy route, or a component's `providers` /
|
|
34
25
|
* `viewProviders` - letting a route or component contribute a scoped command
|
|
35
|
-
* set
|
|
26
|
+
* set.
|
|
27
|
+
*
|
|
28
|
+
* A source is a static list, a `Signal` of commands, or a
|
|
29
|
+
* {@link CngxCommandSourceFactory} for a source that needs injection. The
|
|
30
|
+
* factory runs once in the injection context of the level it is registered
|
|
31
|
+
* at. Return a `Signal` from it to stay reactive: a factory returning a plain
|
|
32
|
+
* array (`() => store.items()`) is read at that first call and never again.
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* // a source owned by a service
|
|
36
|
+
* { path: 'editor', providers: [provideCommands(() => inject(EditorStore).commands)] }
|
|
37
|
+
* ```
|
|
36
38
|
*
|
|
37
39
|
* A scoped call adds to the sets above it and never hides them, across route
|
|
38
40
|
* and component scopes: root and route scopes come first (outer to inner), then
|
|
@@ -50,8 +52,7 @@ const CNGX_COMMAND_REGISTRY = new InjectionToken('CNGX_COMMAND_REGISTRY');
|
|
|
50
52
|
* @Component({ viewProviders: [provideCommands(editorCommands)] })
|
|
51
53
|
* ```
|
|
52
54
|
*
|
|
53
|
-
* @
|
|
54
|
-
* @since 0.1.0
|
|
55
|
+
* @since 0.3.0
|
|
55
56
|
*/
|
|
56
57
|
function provideCommands(...sources) {
|
|
57
58
|
// Empty call: the parent registry flows through untouched.
|
|
@@ -59,7 +60,9 @@ function provideCommands(...sources) {
|
|
|
59
60
|
return [];
|
|
60
61
|
}
|
|
61
62
|
return [
|
|
62
|
-
...sources.map((source) => (
|
|
63
|
+
...sources.map((source) => isSourceValue(source)
|
|
64
|
+
? { provide: CNGX_COMMAND_SOURCE, useValue: source, multi: true }
|
|
65
|
+
: { provide: CNGX_COMMAND_SOURCE, useFactory: () => runFactory(source), multi: true }),
|
|
63
66
|
{
|
|
64
67
|
provide: CNGX_COMMAND_REGISTRY,
|
|
65
68
|
// The nearest CNGX_COMMAND_SOURCE is this level's own multi list, so the
|
|
@@ -78,8 +81,7 @@ function provideCommands(...sources) {
|
|
|
78
81
|
*
|
|
79
82
|
* Must run in an injection context.
|
|
80
83
|
*
|
|
81
|
-
* @
|
|
82
|
-
* @since 0.1.0
|
|
84
|
+
* @since 0.3.0
|
|
83
85
|
*/
|
|
84
86
|
function injectCommands() {
|
|
85
87
|
// A node resolves its element chain before its environment chain, so a
|
|
@@ -104,6 +106,28 @@ function dedupeById(commands) {
|
|
|
104
106
|
function mergeSources(...lists) {
|
|
105
107
|
return [...new Set(lists.flat())];
|
|
106
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* @internal A `Signal` is callable too, so `isSignal` must decide before any
|
|
111
|
+
* function is taken for a factory.
|
|
112
|
+
*/
|
|
113
|
+
function isSourceValue(source) {
|
|
114
|
+
return isSignal(source) || Array.isArray(source);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @internal Runs a factory source. A non-source result (a JS caller, a cast)
|
|
118
|
+
* would otherwise surface as a TypeError deep inside the merged `computed`, so
|
|
119
|
+
* it is dropped here instead.
|
|
120
|
+
*/
|
|
121
|
+
function runFactory(factory) {
|
|
122
|
+
const source = factory();
|
|
123
|
+
if (isSourceValue(source)) {
|
|
124
|
+
return source;
|
|
125
|
+
}
|
|
126
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
127
|
+
cngxDevWarn('CNGX1070', `provideCommands() factory returned ${source === null ? 'null' : typeof source}, not a command array or a Signal of one; it contributes no commands.`);
|
|
128
|
+
}
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
107
131
|
/** @internal Reads a source, unwrapping a signal or passing an array through. */
|
|
108
132
|
function readSource(source) {
|
|
109
133
|
return typeof source === 'function' ? source() : source;
|
|
@@ -135,8 +159,7 @@ function commandsEqual(a, b) {
|
|
|
135
159
|
* by its rules, e.g. Turkish `I` / `ı`; read inside a `computed()`, a locale
|
|
136
160
|
* switch re-ranks.
|
|
137
161
|
*
|
|
138
|
-
* @
|
|
139
|
-
* @since 0.1.0
|
|
162
|
+
* @since 0.3.0
|
|
140
163
|
*/
|
|
141
164
|
function createDefaultCommandMatcher(locale) {
|
|
142
165
|
// Folded label and keywords per command, re-folded only when the label, the
|
|
@@ -212,8 +235,7 @@ function scoreCommand({ label, keywords }, query) {
|
|
|
212
235
|
* without touching the panel. The fuzzy engine stays a consumer swap; the
|
|
213
236
|
* default bundle ships only the pure ranker.
|
|
214
237
|
*
|
|
215
|
-
* @
|
|
216
|
-
* @since 0.1.0
|
|
238
|
+
* @since 0.3.0
|
|
217
239
|
*/
|
|
218
240
|
const CNGX_COMMAND_MATCH_FACTORY = new InjectionToken('CNGX_COMMAND_MATCH_FACTORY', { providedIn: 'root', factory: () => () => createDefaultCommandMatcher(injectLocale()) });
|
|
219
241
|
|
|
@@ -221,5 +243,5 @@ const CNGX_COMMAND_MATCH_FACTORY = new InjectionToken('CNGX_COMMAND_MATCH_FACTOR
|
|
|
221
243
|
* Generated bundle index. Do not edit.
|
|
222
244
|
*/
|
|
223
245
|
|
|
224
|
-
export { CNGX_COMMAND_MATCH_FACTORY,
|
|
246
|
+
export { CNGX_COMMAND_MATCH_FACTORY, createDefaultCommandMatcher, injectCommands, provideCommands };
|
|
225
247
|
//# sourceMappingURL=cngx-common-command.mjs.map
|
|
@@ -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 EnvironmentInjector,\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 the sources of the nearest level\n * that provides it.\n *\n * This is the low-level form. Register through `provideCommands`, which also\n * carries a level's sources into every scope below it. A raw multi-provider on\n * this token is carried down only from a level that also calls\n * `provideCommands`; on any other level it is read only when that level is the\n * one `injectCommands` resolves as nearest.\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 * @internal Per-level registry: the sources of every `provideCommands` level\n * above, plus this level's own. Resolved once per injector by the factory in\n * `provideCommands`; not part of the public API.\n */\nconst CNGX_COMMAND_REGISTRY = new InjectionToken<readonly CngxCommandSource[]>(\n 'CNGX_COMMAND_REGISTRY',\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 * A scoped call adds to the sets above it and never hides them, across route\n * and component scopes: root and route scopes come first (outer to inner), then\n * component scopes outer to inner. The same source reference registered at two\n * levels is listed once. Command ids are unique in the merged list: a command\n * whose `id` is already registered further out replaces that command in place,\n * so a scope can swap a global command for its own version.\n *\n * ```ts\n * // app root\n * bootstrapApplication(AppComponent, { providers: [provideCommands(fileCommands)] });\n * // a lazy route adds its set; its pages see fileCommands + reportCommands\n * { path: 'reports', providers: [provideCommands(reportCommands)], component: Reports }\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 // Empty call: the parent registry flows through untouched.\n if (sources.length === 0) {\n return [];\n }\n return [\n ...sources.map((source) => ({ provide: CNGX_COMMAND_SOURCE, useValue: source, multi: true })),\n {\n provide: CNGX_COMMAND_REGISTRY,\n // The nearest CNGX_COMMAND_SOURCE is this level's own multi list, so the\n // same factory works for environment, providers and viewProviders scopes.\n useFactory: () =>\n mergeSources(\n inject(CNGX_COMMAND_REGISTRY, { skipSelf: true, optional: true }) ?? [],\n inject(CNGX_COMMAND_SOURCE, { optional: true }) ?? [],\n ),\n },\n ];\n}\n\n/**\n * Merges the command sources registered at this injector level and every level\n * above it - route and component scopes alike - 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 // A node resolves its element chain before its environment chain, so a\n // routed component under a shell registry never reaches the route's\n // registry. Read both trees once and join them: environment scopes first.\n const sources = mergeSources(\n inject(EnvironmentInjector).get(CNGX_COMMAND_REGISTRY, null) ?? [],\n inject(CNGX_COMMAND_REGISTRY, { optional: true }) ?? [],\n inject(CNGX_COMMAND_SOURCE, { optional: true }) ?? [],\n );\n return computed(() => dedupeById(sources.flatMap(readSource)), { equal: commandsEqual });\n}\n\n/**\n * @internal Keeps one command per `id`: the last registration (the innermost\n * scope) wins, at the position of the first. A Map keeps a key's insertion slot\n * when its value is replaced.\n */\nfunction dedupeById(commands: readonly CngxCommand[]): readonly CngxCommand[] {\n const byId = new Map<string, CngxCommand>();\n for (const command of commands) {\n byId.set(command.id, command);\n }\n return byId.size === commands.length ? commands : [...byId.values()];\n}\n\n/** @internal Concatenates in argument order and drops repeated source references. */\nfunction mergeSources(...lists: (readonly CngxCommandSource[])[]): readonly CngxCommandSource[] {\n return [...new Set(lists.flat())];\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":";;;AAqBA;;;;;;;;;;;;;;;AAeG;MACU,mBAAmB,GAAG,IAAI,cAAc,CACnD,qBAAqB;AAGvB;;;;AAIG;AACH,MAAM,qBAAqB,GAAG,IA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AAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;YACjC;QACF;;;AAGA,QAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;AACxC,QAAA,OAAO,MAAM;AACf,IAAA,CAAC;AACH;AAWA;AACA,SAAS,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAiB,EAAE,KAAa,EAAA;AACrE,IAAA,IAAI,KAAK,KAAK,KAAK,EAAE;AACnB,QAAA,OAAO,GAAG;IACZ;AACA,IAAA,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;AAC3B,QAAA,OAAO,EAAE;IACX;AACA,IAAA,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACzB,QAAA,OAAO,EAAE;IACX;AACA,IAAA,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE;AAC5B,QAAA,IAAI,KAAK,KAAK,KAAK,EAAE;AACnB,YAAA,OAAO,EAAE;QACX;AACA,QAAA,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;AAC3B,YAAA,OAAO,EAAE;QACX;AACA,QAAA,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;AACzB,YAAA,OAAO,EAAE;QACX;IACF;AACA,IAAA,OAAO,CAAC;AACV;;AC3HA;;;;;;;;;AASG;AACI,MAAM,0BAA0B,GAAG,IAAI,cAAc,CAC1D,4BAA4B,EAC5B,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,MAAM,2BAA2B,CAAC,YAAY,EAAE,CAAC,EAAE;;AC3B1F;;AAEG;;;;"}
|
|
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 EnvironmentInjector,\n inject,\n InjectionToken,\n isSignal,\n type Provider,\n type Signal,\n} from '@angular/core';\nimport { cngxDevWarn } from '@cngx/utils';\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 * @since 0.3.0\n */\nexport type CngxCommandSource = Signal<readonly CngxCommand[]> | readonly CngxCommand[];\n\n/**\n * A source that needs injection. `provideCommands` runs it once, as a provider\n * factory in the injection context of the level it is registered at, so it can\n * call `inject()`. It is not a `computed`: a factory returning a plain array is\n * frozen at that first call. Return a `Signal` to stay reactive. A factory that\n * returns anything else contributes no commands and warns in dev mode\n * ([`CNGX1070`](/error-codes/cngx1070.md)).\n *\n * The factory must not call `injectCommands()`, directly or through a service\n * it injects at the same level: that reads the registry the factory is still\n * building, and Angular throws a circular-dependency error (NG0200).\n *\n * @relatedTo provideCommands\n * @since 0.3.0\n */\nexport type CngxCommandSourceFactory = () => CngxCommandSource;\n\n/**\n * @internal Multi-token every `provideCommands` call contributes to. The\n * generic is the collected array (as with Angular's `HTTP_INTERCEPTORS`), so\n * `inject(CNGX_COMMAND_SOURCE)` returns the sources of the nearest level that\n * provides it. Not part of the public API: a raw multi-provider would bypass\n * the registry that carries a level's sources into the scopes below it.\n */\nconst CNGX_COMMAND_SOURCE = new InjectionToken<readonly CngxCommandSource[]>(\n 'CNGX_COMMAND_SOURCE',\n);\n\n/**\n * @internal Per-level registry: the sources of every `provideCommands` level\n * above, plus this level's own. Resolved once per injector by the factory in\n * `provideCommands`; not part of the public API.\n */\nconst CNGX_COMMAND_REGISTRY = new InjectionToken<readonly CngxCommandSource[]>(\n 'CNGX_COMMAND_REGISTRY',\n);\n\n/**\n * Registers one or more command sources. Call `provideCommands` from several\n * app parts and `injectCommands` merges all of them, without a central list.\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.\n *\n * A source is a static list, a `Signal` of commands, or a\n * {@link CngxCommandSourceFactory} for a source that needs injection. The\n * factory runs once in the injection context of the level it is registered\n * at. Return a `Signal` from it to stay reactive: a factory returning a plain\n * array (`() => store.items()`) is read at that first call and never again.\n *\n * ```ts\n * // a source owned by a service\n * { path: 'editor', providers: [provideCommands(() => inject(EditorStore).commands)] }\n * ```\n *\n * A scoped call adds to the sets above it and never hides them, across route\n * and component scopes: root and route scopes come first (outer to inner), then\n * component scopes outer to inner. The same source reference registered at two\n * levels is listed once. Command ids are unique in the merged list: a command\n * whose `id` is already registered further out replaces that command in place,\n * so a scope can swap a global command for its own version.\n *\n * ```ts\n * // app root\n * bootstrapApplication(AppComponent, { providers: [provideCommands(fileCommands)] });\n * // a lazy route adds its set; its pages see fileCommands + reportCommands\n * { path: 'reports', providers: [provideCommands(reportCommands)], component: Reports }\n * // or component scope\n * @Component({ viewProviders: [provideCommands(editorCommands)] })\n * ```\n *\n * @since 0.3.0\n */\nexport function provideCommands(\n ...sources: (CngxCommandSource | CngxCommandSourceFactory)[]\n): Provider[] {\n // Empty call: the parent registry flows through untouched.\n if (sources.length === 0) {\n return [];\n }\n return [\n ...sources.map((source) =>\n isSourceValue(source)\n ? { provide: CNGX_COMMAND_SOURCE, useValue: source, multi: true }\n : { provide: CNGX_COMMAND_SOURCE, useFactory: () => runFactory(source), multi: true },\n ),\n {\n provide: CNGX_COMMAND_REGISTRY,\n // The nearest CNGX_COMMAND_SOURCE is this level's own multi list, so the\n // same factory works for environment, providers and viewProviders scopes.\n useFactory: () =>\n mergeSources(\n inject(CNGX_COMMAND_REGISTRY, { skipSelf: true, optional: true }) ?? [],\n inject(CNGX_COMMAND_SOURCE, { optional: true }) ?? [],\n ),\n },\n ];\n}\n\n/**\n * Merges the command sources registered at this injector level and every level\n * above it - route and component scopes alike - 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 * @since 0.3.0\n */\nexport function injectCommands(): Signal<readonly CngxCommand[]> {\n // A node resolves its element chain before its environment chain, so a\n // routed component under a shell registry never reaches the route's\n // registry. Read both trees once and join them: environment scopes first.\n const sources = mergeSources(\n inject(EnvironmentInjector).get(CNGX_COMMAND_REGISTRY, null) ?? [],\n inject(CNGX_COMMAND_REGISTRY, { optional: true }) ?? [],\n inject(CNGX_COMMAND_SOURCE, { optional: true }) ?? [],\n );\n return computed(() => dedupeById(sources.flatMap(readSource)), { equal: commandsEqual });\n}\n\n/**\n * @internal Keeps one command per `id`: the last registration (the innermost\n * scope) wins, at the position of the first. A Map keeps a key's insertion slot\n * when its value is replaced.\n */\nfunction dedupeById(commands: readonly CngxCommand[]): readonly CngxCommand[] {\n const byId = new Map<string, CngxCommand>();\n for (const command of commands) {\n byId.set(command.id, command);\n }\n return byId.size === commands.length ? commands : [...byId.values()];\n}\n\n/** @internal Concatenates in argument order and drops repeated source references. */\nfunction mergeSources(...lists: (readonly CngxCommandSource[])[]): readonly CngxCommandSource[] {\n return [...new Set(lists.flat())];\n}\n\n/**\n * @internal A `Signal` is callable too, so `isSignal` must decide before any\n * function is taken for a factory.\n */\nfunction isSourceValue(source: unknown): source is CngxCommandSource {\n return isSignal(source) || Array.isArray(source);\n}\n\n/**\n * @internal Runs a factory source. A non-source result (a JS caller, a cast)\n * would otherwise surface as a TypeError deep inside the merged `computed`, so\n * it is dropped here instead.\n */\nfunction runFactory(factory: CngxCommandSourceFactory): CngxCommandSource {\n const source: unknown = factory();\n if (isSourceValue(source)) {\n return source;\n }\n if (typeof ngDevMode !== 'undefined' && ngDevMode) {\n cngxDevWarn(\n 'CNGX1070',\n `provideCommands() factory returned ${source === null ? 'null' : typeof source}, not a command array or a Signal of one; it contributes no commands.`,\n );\n }\n return [];\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 * @since 0.3.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 * @since 0.3.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 * @since 0.3.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 * @since 0.3.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 * @since 0.3.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 * @since 0.3.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":";;;;AAuCA;;;;;;AAMG;AACH,MAAM,mBAAmB,GAAG,IAAI,cAAc,CAC5C,qBAAqB,CACtB;AAED;;;;AAIG;AACH,MAAM,qBAAqB,GAAG,IAAI,cAAc,CAC9C,uBAAuB,CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCG;AACG,SAAU,eAAe,CAC7B,GAAG,OAAyD,EAAA;;AAG5D,IAAA,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;AACxB,QAAA,OAAO,EAAE;IACX;IACA,OAAO;AACL,QAAA,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,KACpB,aAAa,CAAC,MAAM;AAClB,cAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI;cAC7D,EAAE,OAAO,EAAE,mBAAmB,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