@cngx/common 0.1.0-rc.6 → 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 (72) hide show
  1. package/card/README.md +2 -1
  2. package/chart/README.md +85 -0
  3. package/command/README.md +157 -0
  4. package/data/README.md +33 -1
  5. package/dialog/README.md +23 -1
  6. package/fesm2022/cngx-common-a11y.mjs +356 -180
  7. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  8. package/fesm2022/cngx-common-audio.mjs +84 -42
  9. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  10. package/fesm2022/cngx-common-card.mjs +311 -53
  11. package/fesm2022/cngx-common-card.mjs.map +1 -1
  12. package/fesm2022/cngx-common-chart.mjs +4360 -1625
  13. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  14. package/fesm2022/cngx-common-command.mjs +171 -0
  15. package/fesm2022/cngx-common-command.mjs.map +1 -0
  16. package/fesm2022/cngx-common-data.mjs +1556 -616
  17. package/fesm2022/cngx-common-data.mjs.map +1 -1
  18. package/fesm2022/cngx-common-dialog.mjs +518 -112
  19. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  20. package/fesm2022/cngx-common-display.mjs +468 -87
  21. package/fesm2022/cngx-common-display.mjs.map +1 -1
  22. package/fesm2022/cngx-common-interactive.mjs +2725 -1303
  23. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  24. package/fesm2022/cngx-common-layout.mjs +943 -164
  25. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  26. package/fesm2022/cngx-common-popover.mjs +769 -103
  27. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  28. package/fesm2022/cngx-common-stepper.mjs +816 -348
  29. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  30. package/fesm2022/cngx-common-tabs.mjs +2330 -1554
  31. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  32. package/fesm2022/cngx-common-timeline.mjs +1170 -0
  33. package/fesm2022/cngx-common-timeline.mjs.map +1 -0
  34. package/fesm2022/cngx-common.mjs +2 -2
  35. package/fesm2022/cngx-common.mjs.map +1 -1
  36. package/interactive/README.md +15 -4
  37. package/layout/README.md +21 -1
  38. package/package.json +11 -1
  39. package/popover/README.md +18 -2
  40. package/stepper/README.md +7 -5
  41. package/theming/components/cngx-accordion.css +4 -1
  42. package/theming/components/cngx-backdrop.css +12 -0
  43. package/theming/components/cngx-badge.css +22 -0
  44. package/theming/components/cngx-bottom-sheet.css +14 -2
  45. package/theming/components/cngx-breadcrumb.css +8 -0
  46. package/theming/components/cngx-button-toggle.css +73 -5
  47. package/theming/components/cngx-data-grid.css +234 -1
  48. package/theming/components/cngx-dialog.css +25 -0
  49. package/theming/components/cngx-divider.css +12 -0
  50. package/theming/components/cngx-listbox.css +48 -12
  51. package/theming/components/cngx-menu.css +91 -15
  52. package/theming/components/cngx-popover.css +24 -0
  53. package/theming/components/cngx-recycler-placeholder.css +196 -0
  54. package/theming/components/cngx-ripple.css +2 -2
  55. package/theming/components/cngx-slider.css +32 -1
  56. package/theming/components/cngx-tooltip.css +23 -0
  57. package/timeline/README.md +155 -0
  58. package/types/cngx-common-a11y.d.ts +101 -31
  59. package/types/cngx-common-audio.d.ts +32 -32
  60. package/types/cngx-common-card.d.ts +211 -20
  61. package/types/cngx-common-chart.d.ts +1605 -169
  62. package/types/cngx-common-command.d.ts +190 -0
  63. package/types/cngx-common-data.d.ts +842 -163
  64. package/types/cngx-common-dialog.d.ts +372 -28
  65. package/types/cngx-common-display.d.ts +432 -148
  66. package/types/cngx-common-interactive.d.ts +1553 -370
  67. package/types/cngx-common-layout.d.ts +613 -27
  68. package/types/cngx-common-popover.d.ts +376 -36
  69. package/types/cngx-common-stepper.d.ts +414 -114
  70. package/types/cngx-common-tabs.d.ts +597 -72
  71. package/types/cngx-common-timeline.d.ts +1125 -0
  72. package/types/cngx-common.d.ts +1 -1
@@ -0,0 +1,190 @@
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<CngxCommandGroup[]>`.
44
+ *
45
+ * @category common/command
46
+ * @since 0.1.0
47
+ */
48
+ interface CngxCommandGroup {
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
+ * @deprecated Use {@link CngxCommandGroup}. Published under the unprefixed
58
+ * name by mistake; the alias remains for compatibility and will be removed in
59
+ * a future major.
60
+ * @category common/command
61
+ * @since 0.1.0
62
+ */
63
+ type CommandGroup = CngxCommandGroup;
64
+
65
+ /**
66
+ * A command contribution. Either a static list or a reactive `Signal` of
67
+ * commands - a signal source lets a contributor add or remove commands (or
68
+ * flip a command's `disabled`) live, and `injectCommands` tracks it.
69
+ *
70
+ * @category common/command
71
+ * @since 0.1.0
72
+ */
73
+ type CngxCommandSource = Signal<readonly CngxCommand[]> | readonly CngxCommand[];
74
+ /**
75
+ * Multi-token every `provideCommands` call contributes to. App parts register
76
+ * command sets against it without a central list, mirroring `provideCngxMenu`.
77
+ * The generic is the collected array (as with Angular's `HTTP_INTERCEPTORS`),
78
+ * so `inject(CNGX_COMMAND_SOURCE)` returns every contributed source.
79
+ *
80
+ * @category common/command
81
+ * @since 0.1.0
82
+ */
83
+ declare const CNGX_COMMAND_SOURCE: InjectionToken<readonly CngxCommandSource[]>;
84
+ /**
85
+ * Registers one or more command sources. Each source becomes a `multi` entry
86
+ * on {@link CNGX_COMMAND_SOURCE}; call `provideCommands` from several app parts
87
+ * and `injectCommands` merges all of them.
88
+ *
89
+ * Returns `Provider[]` (not `EnvironmentProviders`), so it registers at any
90
+ * injector scope - app root, a lazy route, or a component's `providers` /
91
+ * `viewProviders` - letting a route or component contribute a scoped command
92
+ * set without reaching for the raw {@link CNGX_COMMAND_SOURCE} multi-provider.
93
+ *
94
+ * ```ts
95
+ * // app root
96
+ * bootstrapApplication(AppComponent, { providers: [provideCommands(fileCommands)] });
97
+ * // or component scope
98
+ * @Component({ viewProviders: [provideCommands(editorCommands)] })
99
+ * ```
100
+ *
101
+ * @category common/command
102
+ * @since 0.1.0
103
+ */
104
+ declare function provideCommands(...sources: CngxCommandSource[]): Provider[];
105
+ /**
106
+ * Merges every registered {@link CNGX_COMMAND_SOURCE} into one reactive
107
+ * `Signal<readonly CngxCommand[]>`. The merge carries an explicit `equal`
108
+ * (length + per-command identity) so re-emitting an identical set - the same
109
+ * command references in the same order - does not produce a fresh array and
110
+ * cascade the downstream match `computed()`.
111
+ *
112
+ * Must run in an injection context.
113
+ *
114
+ * @category common/command
115
+ * @since 0.1.0
116
+ */
117
+ declare function injectCommands(): Signal<readonly CngxCommand[]>;
118
+
119
+ /**
120
+ * A command paired with its match score for a given query. Higher scores rank
121
+ * first. The palette renders these in order; the row slot reads `command` and
122
+ * the term to highlight.
123
+ *
124
+ * @category common/command
125
+ * @since 0.1.0
126
+ */
127
+ interface CngxRankedCommand {
128
+ /** The matched command. */
129
+ readonly command: CngxCommand;
130
+ /** Relevance score for the query; higher ranks first. `0` for an empty query. */
131
+ readonly score: number;
132
+ }
133
+ /**
134
+ * @deprecated Use {@link CngxRankedCommand}. Published under the unprefixed
135
+ * name by mistake; the alias remains for compatibility and will be removed in
136
+ * a future major.
137
+ * @category common/command
138
+ * @since 0.1.0
139
+ */
140
+ type RankedCommand = CngxRankedCommand;
141
+ /**
142
+ * Ranks and filters a command set against a query and optional scope. Swappable
143
+ * via {@link CNGX_COMMAND_MATCH_FACTORY} - a consumer drops in Levenshtein or a
144
+ * fuzzy engine without touching the panel.
145
+ *
146
+ * @category common/command
147
+ * @since 0.1.0
148
+ */
149
+ type CngxCommandMatcher = (commands: readonly CngxCommand[], term: string, scope?: string) => readonly CngxRankedCommand[];
150
+ /**
151
+ * Builds the default matcher: a pure label/keyword ranker. An empty query
152
+ * returns every (scoped) command at score `0` in registration order; a
153
+ * non-empty query keeps only commands that match label or keyword, ranked
154
+ * label-exact > label-prefix > label-substring > keyword. The optional scope
155
+ * filters to commands whose `group` equals it.
156
+ *
157
+ * Query, labels and keywords are compared case- and accent-tolerant
158
+ * ({@link foldForMatching}): `uber` finds `Über`. Pass the app locale (the
159
+ * default `CNGX_COMMAND_MATCH_FACTORY` passes `injectLocale()`) so case folds
160
+ * by its rules, e.g. Turkish `I` / `ı`; read inside a `computed()`, a locale
161
+ * switch re-ranks.
162
+ *
163
+ * @category common/command
164
+ * @since 0.1.0
165
+ */
166
+ declare function createDefaultCommandMatcher(locale?: Signal<string>): CngxCommandMatcher;
167
+
168
+ /**
169
+ * Factory producing a {@link CngxCommandMatcher}. The exact signature is
170
+ * captured so an override matches it precisely. The panel calls it in an
171
+ * injection context, so a factory may `inject()` what its matcher needs.
172
+ *
173
+ * @category common/command
174
+ * @since 0.1.0
175
+ */
176
+ type CngxCommandMatchFactory = () => CngxCommandMatcher;
177
+ /**
178
+ * Swappable match-strategy seam. Defaults to {@link createDefaultCommandMatcher}
179
+ * (pure label/keyword ranking, case- and accent-tolerant in the app locale). Override it - app-wide via `providers` or
180
+ * per-component via `viewProviders` - to drop in a fuzzy/Levenshtein ranker
181
+ * without touching the panel. The fuzzy engine stays a consumer swap; the
182
+ * default bundle ships only the pure ranker.
183
+ *
184
+ * @category common/command
185
+ * @since 0.1.0
186
+ */
187
+ declare const CNGX_COMMAND_MATCH_FACTORY: InjectionToken<CngxCommandMatchFactory>;
188
+
189
+ export { CNGX_COMMAND_MATCH_FACTORY, CNGX_COMMAND_SOURCE, createDefaultCommandMatcher, injectCommands, provideCommands };
190
+ export type { CngxCommand, CngxCommandGroup, CngxCommandMatchFactory, CngxCommandMatcher, CngxCommandSource, CngxRankedCommand, CommandGroup, RankedCommand };