@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.
- package/chart/README.md +85 -0
- package/command/README.md +157 -0
- package/data/README.md +23 -0
- package/fesm2022/cngx-common-a11y.mjs +247 -85
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +37 -37
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +13 -9
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +3404 -1392
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +144 -0
- package/fesm2022/cngx-common-command.mjs.map +1 -0
- package/fesm2022/cngx-common-data.mjs +304 -213
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +369 -100
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +138 -24
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +1089 -459
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +113 -61
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +430 -54
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +107 -49
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1170 -752
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +1086 -0
- package/fesm2022/cngx-common-timeline.mjs.map +1 -0
- package/fesm2022/cngx-common.mjs +2 -2
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/package.json +11 -1
- package/stepper/README.md +1 -1
- package/theming/components/cngx-accordion.css +3 -0
- package/theming/components/cngx-badge.css +22 -0
- package/theming/components/cngx-bottom-sheet.css +14 -2
- package/theming/components/cngx-breadcrumb.css +8 -0
- package/theming/components/cngx-button-toggle.css +44 -2
- package/theming/components/cngx-data-grid.css +66 -0
- package/theming/components/cngx-dialog.css +12 -0
- package/theming/components/cngx-divider.css +12 -0
- package/theming/components/cngx-listbox.css +27 -0
- package/theming/components/cngx-menu.css +36 -0
- package/theming/components/cngx-ripple.css +1 -1
- package/theming/components/cngx-tooltip.css +11 -0
- package/types/cngx-common-a11y.d.ts +63 -17
- package/types/cngx-common-audio.d.ts +32 -32
- package/types/cngx-common-card.d.ts +10 -3
- package/types/cngx-common-chart.d.ts +1281 -141
- package/types/cngx-common-command.d.ts +167 -0
- package/types/cngx-common-data.d.ts +264 -98
- package/types/cngx-common-dialog.d.ts +214 -25
- package/types/cngx-common-display.d.ts +83 -13
- package/types/cngx-common-interactive.d.ts +708 -174
- package/types/cngx-common-layout.d.ts +48 -1
- package/types/cngx-common-popover.d.ts +120 -3
- package/types/cngx-common-stepper.d.ts +55 -5
- package/types/cngx-common-tabs.d.ts +386 -25
- package/types/cngx-common-timeline.d.ts +1059 -0
- package/types/cngx-common.d.ts +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { Signal, InjectionToken, Provider } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A single registrable command - a labelled action the command palette can
|
|
5
|
+
* surface, rank against a query, and run. Commands carry no rendered chrome;
|
|
6
|
+
* they are pure data plus a `run` callback, so a consumer registers them
|
|
7
|
+
* against `@cngx/common/command` without pulling in the UI preset.
|
|
8
|
+
*
|
|
9
|
+
* The list is heterogeneous by design, so there is no `CngxCommand<T>` type
|
|
10
|
+
* parameter: a payload rides on `data` as `unknown` and the row slot narrows
|
|
11
|
+
* it at the use-site.
|
|
12
|
+
*
|
|
13
|
+
* @category common/command
|
|
14
|
+
* @since 0.1.0
|
|
15
|
+
*/
|
|
16
|
+
interface CngxCommand {
|
|
17
|
+
/** Stable identity. Drives the merge `equal` and the `aria-activedescendant` id. */
|
|
18
|
+
readonly id: string;
|
|
19
|
+
/** Human-readable label; the primary target the default matcher ranks against. */
|
|
20
|
+
readonly label: string;
|
|
21
|
+
/** Extra terms the matcher ranks against besides the label. */
|
|
22
|
+
readonly keywords?: readonly string[];
|
|
23
|
+
/** Group key; also the value the default matcher's scope filter compares against. */
|
|
24
|
+
readonly group?: string;
|
|
25
|
+
/** Optional icon token; the consumer's row template resolves it against its own design system. */
|
|
26
|
+
readonly icon?: string;
|
|
27
|
+
/** Runs the command. May be async; the palette does not await the result. */
|
|
28
|
+
run(): void | Promise<void>;
|
|
29
|
+
/** Reactive disabled state. A disabled command stays perceivable and communicates its why. */
|
|
30
|
+
readonly disabled?: Signal<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Why the command is disabled. The default row wires `aria-describedby` to a
|
|
33
|
+
* node carrying this reason, gated on `disabled() && !!disabledReason`
|
|
34
|
+
* (Pillar 2 - a disabled control communicates its why).
|
|
35
|
+
*/
|
|
36
|
+
readonly disabledReason?: string;
|
|
37
|
+
/** Consumer payload the row slot narrows at the use-site. Heterogeneous, hence `unknown`. */
|
|
38
|
+
readonly data?: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A named cluster of commands. The palette renders grouped results (Recents on
|
|
42
|
+
* an empty query, then categories) and the consumer's async result source is a
|
|
43
|
+
* `CngxAsyncState<CommandGroup[]>`.
|
|
44
|
+
*
|
|
45
|
+
* @category common/command
|
|
46
|
+
* @since 0.1.0
|
|
47
|
+
*/
|
|
48
|
+
interface CommandGroup {
|
|
49
|
+
/** Stable identity for the group header slot and change detection. */
|
|
50
|
+
readonly id: string;
|
|
51
|
+
/** Header label rendered above the group's commands. */
|
|
52
|
+
readonly label: string;
|
|
53
|
+
/** The commands in this group, in render order. */
|
|
54
|
+
readonly commands: readonly CngxCommand[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A command contribution. Either a static list or a reactive `Signal` of
|
|
59
|
+
* commands - a signal source lets a contributor add or remove commands (or
|
|
60
|
+
* flip a command's `disabled`) live, and `injectCommands` tracks it.
|
|
61
|
+
*
|
|
62
|
+
* @category common/command
|
|
63
|
+
* @since 0.1.0
|
|
64
|
+
*/
|
|
65
|
+
type CngxCommandSource = Signal<readonly CngxCommand[]> | readonly CngxCommand[];
|
|
66
|
+
/**
|
|
67
|
+
* Multi-token every `provideCommands` call contributes to. App parts register
|
|
68
|
+
* command sets against it without a central list, mirroring `provideCngxMenu`.
|
|
69
|
+
* The generic is the collected array (as with Angular's `HTTP_INTERCEPTORS`),
|
|
70
|
+
* so `inject(CNGX_COMMAND_SOURCE)` returns every contributed source.
|
|
71
|
+
*
|
|
72
|
+
* @category common/command
|
|
73
|
+
* @since 0.1.0
|
|
74
|
+
*/
|
|
75
|
+
declare const CNGX_COMMAND_SOURCE: InjectionToken<readonly CngxCommandSource[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Registers one or more command sources. Each source becomes a `multi` entry
|
|
78
|
+
* on {@link CNGX_COMMAND_SOURCE}; call `provideCommands` from several app parts
|
|
79
|
+
* and `injectCommands` merges all of them.
|
|
80
|
+
*
|
|
81
|
+
* Returns `Provider[]` (not `EnvironmentProviders`), so it registers at any
|
|
82
|
+
* injector scope - app root, a lazy route, or a component's `providers` /
|
|
83
|
+
* `viewProviders` - letting a route or component contribute a scoped command
|
|
84
|
+
* set without reaching for the raw {@link CNGX_COMMAND_SOURCE} multi-provider.
|
|
85
|
+
*
|
|
86
|
+
* ```ts
|
|
87
|
+
* // app root
|
|
88
|
+
* bootstrapApplication(AppComponent, { providers: [provideCommands(fileCommands)] });
|
|
89
|
+
* // or component scope
|
|
90
|
+
* @Component({ viewProviders: [provideCommands(editorCommands)] })
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @category common/command
|
|
94
|
+
* @since 0.1.0
|
|
95
|
+
*/
|
|
96
|
+
declare function provideCommands(...sources: CngxCommandSource[]): Provider[];
|
|
97
|
+
/**
|
|
98
|
+
* Merges every registered {@link CNGX_COMMAND_SOURCE} into one reactive
|
|
99
|
+
* `Signal<readonly CngxCommand[]>`. The merge carries an explicit `equal`
|
|
100
|
+
* (length + per-command identity) so re-emitting an identical set - the same
|
|
101
|
+
* command references in the same order - does not produce a fresh array and
|
|
102
|
+
* cascade the downstream match `computed()`.
|
|
103
|
+
*
|
|
104
|
+
* Must run in an injection context.
|
|
105
|
+
*
|
|
106
|
+
* @category common/command
|
|
107
|
+
* @since 0.1.0
|
|
108
|
+
*/
|
|
109
|
+
declare function injectCommands(): Signal<readonly CngxCommand[]>;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A command paired with its match score for a given query. Higher scores rank
|
|
113
|
+
* first. The palette renders these in order; the row slot reads `command` and
|
|
114
|
+
* the term to highlight.
|
|
115
|
+
*
|
|
116
|
+
* @category common/command
|
|
117
|
+
* @since 0.1.0
|
|
118
|
+
*/
|
|
119
|
+
interface RankedCommand {
|
|
120
|
+
/** The matched command. */
|
|
121
|
+
readonly command: CngxCommand;
|
|
122
|
+
/** Relevance score for the query; higher ranks first. `0` for an empty query. */
|
|
123
|
+
readonly score: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Ranks and filters a command set against a query and optional scope. Swappable
|
|
127
|
+
* via {@link CNGX_COMMAND_MATCH_FACTORY} - a consumer drops in Levenshtein or a
|
|
128
|
+
* fuzzy engine without touching the panel.
|
|
129
|
+
*
|
|
130
|
+
* @category common/command
|
|
131
|
+
* @since 0.1.0
|
|
132
|
+
*/
|
|
133
|
+
type CngxCommandMatcher = (commands: readonly CngxCommand[], term: string, scope?: string) => readonly RankedCommand[];
|
|
134
|
+
/**
|
|
135
|
+
* Builds the default matcher: a pure label/keyword ranker. An empty query
|
|
136
|
+
* returns every (scoped) command at score `0` in registration order; a
|
|
137
|
+
* non-empty query keeps only commands that match label or keyword, ranked
|
|
138
|
+
* label-exact > label-prefix > label-substring > keyword. The optional scope
|
|
139
|
+
* filters to commands whose `group` equals it.
|
|
140
|
+
*
|
|
141
|
+
* @category common/command
|
|
142
|
+
* @since 0.1.0
|
|
143
|
+
*/
|
|
144
|
+
declare function createDefaultCommandMatcher(): CngxCommandMatcher;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Factory producing a {@link CngxCommandMatcher}. The exact signature is
|
|
148
|
+
* captured so an override matches it precisely.
|
|
149
|
+
*
|
|
150
|
+
* @category common/command
|
|
151
|
+
* @since 0.1.0
|
|
152
|
+
*/
|
|
153
|
+
type CngxCommandMatchFactory = () => CngxCommandMatcher;
|
|
154
|
+
/**
|
|
155
|
+
* Swappable match-strategy seam. Defaults to {@link createDefaultCommandMatcher}
|
|
156
|
+
* (pure label/keyword ranking). Override it - app-wide via `providers` or
|
|
157
|
+
* per-component via `viewProviders` - to drop in a fuzzy/Levenshtein ranker
|
|
158
|
+
* without touching the panel. The fuzzy engine stays a consumer swap; the
|
|
159
|
+
* default bundle ships only the pure ranker.
|
|
160
|
+
*
|
|
161
|
+
* @category common/command
|
|
162
|
+
* @since 0.1.0
|
|
163
|
+
*/
|
|
164
|
+
declare const CNGX_COMMAND_MATCH_FACTORY: InjectionToken<CngxCommandMatchFactory>;
|
|
165
|
+
|
|
166
|
+
export { CNGX_COMMAND_MATCH_FACTORY, CNGX_COMMAND_SOURCE, createDefaultCommandMatcher, injectCommands, provideCommands };
|
|
167
|
+
export type { CngxCommand, CngxCommandMatchFactory, CngxCommandMatcher, CngxCommandSource, CommandGroup, RankedCommand };
|