@cngx/ui 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.
- package/README.md +0 -1
- package/a11y/README.md +11 -5
- package/accordion/README.md +4 -2
- package/breadcrumb/README.md +262 -0
- package/collection/README.md +6 -0
- package/command-palette/README.md +224 -0
- package/data-grid-accordion/README.md +76 -2
- package/feedback/README.md +40 -0
- package/fesm2022/cngx-ui-a11y.mjs +189 -57
- package/fesm2022/cngx-ui-a11y.mjs.map +1 -1
- package/fesm2022/cngx-ui-accordion.mjs +102 -35
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-action-button.mjs +112 -50
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +176 -96
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
- package/fesm2022/cngx-ui-chart-panel.mjs +180 -23
- package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -1
- package/fesm2022/cngx-ui-collection.mjs +194 -62
- package/fesm2022/cngx-ui-collection.mjs.map +1 -1
- package/fesm2022/cngx-ui-command-palette.mjs +395 -119
- package/fesm2022/cngx-ui-command-palette.mjs.map +1 -1
- package/fesm2022/cngx-ui-context-menu.mjs +149 -34
- package/fesm2022/cngx-ui-context-menu.mjs.map +1 -1
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +415 -98
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-empty-state.mjs +16 -6
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +1022 -439
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-accordion.mjs +75 -7
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-paginator.mjs +67 -24
- package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-stepper.mjs +72 -47
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +314 -141
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-overlay.mjs +69 -13
- package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
- package/fesm2022/cngx-ui-paginator.mjs +487 -178
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +327 -106
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-skeleton.mjs +4 -16
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
- package/fesm2022/cngx-ui-speak.mjs +107 -8
- package/fesm2022/cngx-ui-speak.mjs.map +1 -1
- package/fesm2022/cngx-ui-stat-card.mjs +146 -46
- package/fesm2022/cngx-ui-stat-card.mjs.map +1 -1
- package/fesm2022/cngx-ui-stepper.mjs +191 -68
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +10 -6
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-timeline.mjs +74 -21
- package/fesm2022/cngx-ui-timeline.mjs.map +1 -1
- package/fesm2022/cngx-ui-toc.mjs +70 -26
- package/fesm2022/cngx-ui-toc.mjs.map +1 -1
- package/fesm2022/cngx-ui.mjs +15 -20
- package/fesm2022/cngx-ui.mjs.map +1 -1
- package/mat-paginator/README.md +9 -2
- package/mat-tabs/styles/mat-tabs.css +9 -10
- package/overlay/README.md +9 -4
- package/package.json +4 -4
- package/paginator/README.md +8 -4
- package/sidenav/README.md +33 -11
- package/speak/README.md +3 -2
- package/stepper/README.md +13 -1
- package/timeline/README.md +1 -1
- package/toc/README.md +4 -1
- package/types/cngx-ui-a11y.d.ts +121 -30
- package/types/cngx-ui-accordion.d.ts +91 -26
- package/types/cngx-ui-action-button.d.ts +44 -3
- package/types/cngx-ui-breadcrumb.d.ts +154 -58
- package/types/cngx-ui-chart-panel.d.ts +122 -18
- package/types/cngx-ui-collection.d.ts +147 -55
- package/types/cngx-ui-command-palette.d.ts +297 -183
- package/types/cngx-ui-context-menu.d.ts +98 -6
- package/types/cngx-ui-data-grid-accordion.d.ts +274 -38
- package/types/cngx-ui-empty-state.d.ts +9 -2
- package/types/cngx-ui-feedback.d.ts +594 -56
- package/types/cngx-ui-mat-accordion.d.ts +29 -1
- package/types/cngx-ui-mat-paginator.d.ts +37 -8
- package/types/cngx-ui-mat-stepper.d.ts +23 -11
- package/types/cngx-ui-mat-tabs.d.ts +207 -14
- package/types/cngx-ui-overlay.d.ts +56 -10
- package/types/cngx-ui-paginator.d.ts +403 -129
- package/types/cngx-ui-sidenav.d.ts +248 -74
- package/types/cngx-ui-skeleton.d.ts +6 -7
- package/types/cngx-ui-speak.d.ts +118 -5
- package/types/cngx-ui-stat-card.d.ts +117 -33
- package/types/cngx-ui-stepper.d.ts +66 -27
- package/types/cngx-ui-tabs.d.ts +2 -2
- package/types/cngx-ui-timeline.d.ts +23 -7
- package/types/cngx-ui-toc.d.ts +80 -13
- package/types/cngx-ui.d.ts +7 -4
|
@@ -1,182 +1,88 @@
|
|
|
1
1
|
import * as _cngx_ui_command_palette from '@cngx/ui/command-palette';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { InjectionToken, Signal,
|
|
4
|
-
import {
|
|
3
|
+
import { TemplateRef, InjectionToken, Signal, EnvironmentProviders, Provider } from '@angular/core';
|
|
4
|
+
import { CngxMessage } from '@cngx/core/i18n';
|
|
5
|
+
import { CngxRankedCommand, CngxCommandGroup } from '@cngx/common/command';
|
|
5
6
|
import { CngxAsyncState, KeyCombo } from '@cngx/core/utils';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* native modal `<dialog cngxDialog>`, so `showModal()` traps focus and
|
|
14
|
-
* `CngxDialog` stores the trigger at open and returns focus after the close
|
|
15
|
-
* transition settles. The panel only needs to know it is open and to ask the
|
|
16
|
-
* surface to dismiss when a command runs.
|
|
17
|
-
*
|
|
18
|
-
* @category ui/command-palette
|
|
19
|
-
* @since 0.1.0
|
|
20
|
-
*/
|
|
21
|
-
interface CngxCommandPaletteHost {
|
|
22
|
-
/** Whether the palette surface is currently open. */
|
|
23
|
-
readonly isOpen: Signal<boolean>;
|
|
24
|
-
/** Dismiss the surface (e.g. after a command runs). */
|
|
25
|
-
dismiss(): void;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* DI token the panel injects (optional) to reach its hosting palette surface.
|
|
9
|
+
* The command-palette section of a {@link CngxLanguagePack}: the copy of
|
|
10
|
+
* `CngxCommandPalette` and its panel. It feeds the copy keys of
|
|
11
|
+
* `CNGX_COMMAND_PALETTE_CONFIG`; a key set through `withCommandPaletteLabels`,
|
|
12
|
+
* `withResultCountFormatter` or `withKeyboardLegend` still wins. Messages use
|
|
13
|
+
* `{name}` placeholders, numbers are formatted for the locale.
|
|
29
14
|
*
|
|
30
|
-
* @category ui/command-palette
|
|
15
|
+
* @category ui/command-palette/i18n
|
|
31
16
|
* @since 0.1.0
|
|
17
|
+
* @relatedTo CNGX_COMMAND_PALETTE_CONFIG, withCommandPaletteLabels
|
|
32
18
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
readonly
|
|
64
|
-
/**
|
|
65
|
-
readonly
|
|
66
|
-
/** Debounce for the search input. */
|
|
67
|
-
readonly debounceMs: i0.InputSignal<number>;
|
|
68
|
-
/** Accessible name for the dialog. */
|
|
69
|
-
readonly ariaLabel: i0.InputSignal<string>;
|
|
70
|
-
/**
|
|
71
|
-
* Per-instance open combo (parsed via `parseKeyCombo`, e.g. `'mod+shift+p'`).
|
|
72
|
-
* Wins over `CNGX_COMMAND_PALETTE_CONFIG.openShortcut` (`withPaletteShortcut`),
|
|
73
|
-
* which wins over the `'mod+k'` default. Changing it live re-installs the
|
|
74
|
-
* listener. For a full listener swap, override `CNGX_PALETTE_KEYBINDING_FACTORY`.
|
|
75
|
-
*/
|
|
76
|
-
readonly openShortcut: i0.InputSignal<string | undefined>;
|
|
77
|
-
/** Fired when the user asks to retry a failed result load. */
|
|
78
|
-
readonly retry: i0.OutputEmitterRef<void>;
|
|
79
|
-
protected readonly config: _cngx_ui_command_palette.CngxCommandPaletteConfig;
|
|
80
|
-
/** Mirror of the panel's debounced term, so the empty slot can read it. */
|
|
81
|
-
protected readonly term: i0.WritableSignal<string>;
|
|
82
|
-
private readonly rowSlot;
|
|
83
|
-
private readonly groupHeaderSlot;
|
|
84
|
-
private readonly emptySlot;
|
|
85
|
-
private readonly loadingSlot;
|
|
86
|
-
private readonly errorSlot;
|
|
87
|
-
private readonly footerSlot;
|
|
88
|
-
protected readonly rowTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandRowContext> | null>;
|
|
89
|
-
protected readonly groupHeaderTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandGroupHeaderContext> | null>;
|
|
90
|
-
protected readonly emptyTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandPaletteEmptyContext> | null>;
|
|
91
|
-
protected readonly loadingTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandPaletteLoadingContext> | null>;
|
|
92
|
-
protected readonly errorTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandPaletteErrorContext> | null>;
|
|
93
|
-
protected readonly footerTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandPaletteFooterContext> | null>;
|
|
94
|
-
private readonly dialog;
|
|
95
|
-
/** Whether the palette is open. Part of the {@link CngxCommandPaletteHost} contract. */
|
|
96
|
-
readonly isOpen: Signal<boolean>;
|
|
97
|
-
/** Resolved open combo: instance input > config > `'mod+k'` default. */
|
|
98
|
-
private readonly resolvedShortcut;
|
|
99
|
-
constructor();
|
|
100
|
-
/** Open the palette. */
|
|
101
|
-
open(): void;
|
|
102
|
-
/** Dismiss the palette. Focus returns to the trigger via `CngxDialog`. */
|
|
103
|
-
dismiss(): void;
|
|
104
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<CngxCommandPalette, never>;
|
|
105
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<CngxCommandPalette, "cngx-command-palette", never, { "results": { "alias": "results"; "required": false; "isSignal": true; }; "scope": { "alias": "scope"; "required": false; "isSignal": true; }; "debounceMs": { "alias": "debounceMs"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "openShortcut": { "alias": "openShortcut"; "required": false; "isSignal": true; }; }, { "scope": "scopeChange"; "retry": "retry"; }, ["rowSlot", "groupHeaderSlot", "emptySlot", "loadingSlot", "errorSlot", "footerSlot"], never, true, never>;
|
|
19
|
+
interface CngxCommandPaletteLanguageSection {
|
|
20
|
+
/** Placeholder and accessible name of the search input. */
|
|
21
|
+
readonly searchPlaceholder: string;
|
|
22
|
+
/** Accessible name of the result listbox. */
|
|
23
|
+
readonly listboxLabel: string;
|
|
24
|
+
/** Shown when no command matches. */
|
|
25
|
+
readonly emptyLabel: string;
|
|
26
|
+
/** Shown while the commands load. */
|
|
27
|
+
readonly loadingLabel: string;
|
|
28
|
+
/** Shown when the commands failed to load. */
|
|
29
|
+
readonly errorLabel: string;
|
|
30
|
+
/** Label of the retry button after a failed load. */
|
|
31
|
+
readonly retryLabel: string;
|
|
32
|
+
/** Accessible name of the palette dialog. */
|
|
33
|
+
readonly paletteLabel: string;
|
|
34
|
+
/** `{count}`: the announced number of matching commands. */
|
|
35
|
+
readonly resultCount: CngxMessage;
|
|
36
|
+
/** Keys of the footer legend's navigate entry, as shown. Never spoken. */
|
|
37
|
+
readonly navigateKeys: string;
|
|
38
|
+
/** The navigate entry's keys in words, as screen readers hear them. */
|
|
39
|
+
readonly navigateKeysSpoken: string;
|
|
40
|
+
/** Label of the footer legend's navigate entry. */
|
|
41
|
+
readonly navigateLabel: string;
|
|
42
|
+
/** Keys of the footer legend's run entry. */
|
|
43
|
+
readonly runKeys: string;
|
|
44
|
+
/** Label of the footer legend's run entry. */
|
|
45
|
+
readonly runLabel: string;
|
|
46
|
+
/** Keys of the footer legend's close entry. */
|
|
47
|
+
readonly closeKeys: string;
|
|
48
|
+
/** Label of the footer legend's close entry. */
|
|
49
|
+
readonly closeLabel: string;
|
|
50
|
+
/** `{keys}`, `{label}`: what a screen reader hears for one footer legend entry. */
|
|
51
|
+
readonly legendEntry: CngxMessage;
|
|
106
52
|
}
|
|
107
|
-
|
|
108
53
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* palette by template reference - orthogonal composition, no ancestor
|
|
112
|
-
* injection.
|
|
113
|
-
*
|
|
114
|
-
* ```html
|
|
115
|
-
* <button [cngxCommandPaletteTrigger]="palette">
|
|
116
|
-
* Search <kbd>Cmd K</kbd>
|
|
117
|
-
* </button>
|
|
118
|
-
* <cngx-command-palette #palette />
|
|
119
|
-
* ```
|
|
54
|
+
* The English command-palette section: the single source of the palette's
|
|
55
|
+
* English copy. The `CNGX_COMMAND_PALETTE_CONFIG` copy keys default to it.
|
|
120
56
|
*
|
|
121
|
-
* @category ui/command-palette
|
|
122
|
-
* @wcag AA
|
|
123
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/command-palette/palette/command-palette-trigger.directive.ts
|
|
57
|
+
* @category ui/command-palette/i18n
|
|
124
58
|
* @since 0.1.0
|
|
125
|
-
* @relatedTo
|
|
59
|
+
* @relatedTo CNGX_COMMAND_PALETTE_CONFIG
|
|
126
60
|
*/
|
|
127
|
-
declare
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<CngxCommandPaletteTrigger, "[cngxCommandPaletteTrigger]", ["cngxCommandPaletteTrigger"], { "palette": { "alias": "cngxCommandPaletteTrigger"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
61
|
+
declare const CNGX_COMMAND_PALETTE_LANGUAGE_EN: CngxCommandPaletteLanguageSection;
|
|
62
|
+
declare module '@cngx/core/i18n' {
|
|
63
|
+
interface CngxLanguagePack {
|
|
64
|
+
readonly commandPalette: CngxCommandPaletteLanguageSection;
|
|
65
|
+
}
|
|
133
66
|
}
|
|
134
67
|
|
|
135
68
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* changes and tears the previous one down, so nothing leaks document-wide.
|
|
69
|
+
* The command-palette copy of one section and locale, in the shape of the
|
|
70
|
+
* config copy keys.
|
|
139
71
|
*
|
|
140
|
-
* @
|
|
141
|
-
* @since 0.1.0
|
|
72
|
+
* @internal
|
|
142
73
|
*/
|
|
143
|
-
interface
|
|
144
|
-
|
|
145
|
-
|
|
74
|
+
interface CngxCommandPaletteSiteCopy {
|
|
75
|
+
readonly searchPlaceholder: string;
|
|
76
|
+
readonly listboxLabel: string;
|
|
77
|
+
readonly emptyLabel: string;
|
|
78
|
+
readonly loadingLabel: string;
|
|
79
|
+
readonly errorLabel: string;
|
|
80
|
+
readonly retryLabel: string;
|
|
81
|
+
readonly paletteLabel: string;
|
|
82
|
+
readonly resultCount: (count: number) => string;
|
|
83
|
+
readonly footerLegend: readonly CngxCommandPaletteLegendEntry[];
|
|
84
|
+
readonly legendEntry: (keys: string, label: string) => string;
|
|
146
85
|
}
|
|
147
|
-
/**
|
|
148
|
-
* Factory producing a {@link CngxPaletteKeybinding} for a combo. It installs a
|
|
149
|
-
* global listener that invokes `onOpen` whenever the combo is pressed. Captured
|
|
150
|
-
* as a type alias so an override matches the exact signature - a consumer can
|
|
151
|
-
* swap in an enterprise key-capture policy without touching the palette.
|
|
152
|
-
*
|
|
153
|
-
* @category ui/command-palette
|
|
154
|
-
* @since 0.1.0
|
|
155
|
-
*/
|
|
156
|
-
type CngxPaletteKeybindingFactory = (combo: KeyCombo, onOpen: () => void) => CngxPaletteKeybinding;
|
|
157
|
-
/**
|
|
158
|
-
* Default palette keybinding: installs a document keydown listener that calls
|
|
159
|
-
* `onOpen` whenever the combo is pressed (matched via `matchesKeyCombo`).
|
|
160
|
-
* Side-effectful by design - it owns the global listener - so its `teardown`
|
|
161
|
-
* must be called on destroy.
|
|
162
|
-
*
|
|
163
|
-
* `isMac` defaults to platform detection; pass it explicitly for deterministic
|
|
164
|
-
* tests.
|
|
165
|
-
*
|
|
166
|
-
* @category ui/command-palette
|
|
167
|
-
* @since 0.1.0
|
|
168
|
-
*/
|
|
169
|
-
declare function createPaletteKeybinding(combo: KeyCombo, onOpen: () => void, isMac?: boolean): CngxPaletteKeybinding;
|
|
170
|
-
/**
|
|
171
|
-
* Swappable open-trigger seam. Defaults to {@link createPaletteKeybinding}.
|
|
172
|
-
* Override it to install an enterprise key-capture policy without touching the
|
|
173
|
-
* palette. To only change the *combo*, prefer `withPaletteShortcut(...)` or the
|
|
174
|
-
* `[openShortcut]` input - this token is for replacing the whole listener.
|
|
175
|
-
*
|
|
176
|
-
* @category ui/command-palette
|
|
177
|
-
* @since 0.1.0
|
|
178
|
-
*/
|
|
179
|
-
declare const CNGX_PALETTE_KEYBINDING_FACTORY: InjectionToken<CngxPaletteKeybindingFactory>;
|
|
180
86
|
|
|
181
87
|
/**
|
|
182
88
|
* Context for the {@link CngxCommandRow} slot. Region granularity: the whole
|
|
@@ -188,14 +94,14 @@ declare const CNGX_PALETTE_KEYBINDING_FACTORY: InjectionToken<CngxPaletteKeybind
|
|
|
188
94
|
* @since 0.1.0
|
|
189
95
|
*/
|
|
190
96
|
interface CngxCommandRowContext {
|
|
191
|
-
readonly $implicit:
|
|
97
|
+
readonly $implicit: CngxRankedCommand;
|
|
192
98
|
readonly term: string;
|
|
193
99
|
readonly data: unknown;
|
|
194
100
|
readonly active: boolean;
|
|
195
101
|
}
|
|
196
102
|
/** Context for the {@link CngxCommandGroupHeader} slot. Recents is a group. */
|
|
197
103
|
interface CngxCommandGroupHeaderContext {
|
|
198
|
-
readonly $implicit:
|
|
104
|
+
readonly $implicit: CngxCommandGroup;
|
|
199
105
|
}
|
|
200
106
|
/** Context for the {@link CngxCommandPaletteEmpty} slot. */
|
|
201
107
|
interface CngxCommandPaletteEmptyContext {
|
|
@@ -310,7 +216,8 @@ interface CngxCommandPaletteTemplates {
|
|
|
310
216
|
}
|
|
311
217
|
/**
|
|
312
218
|
* One keyboard-legend row in the palette footer: the key glyphs and what they
|
|
313
|
-
* do.
|
|
219
|
+
* do. `keys` is shown, never spoken; screen readers hear `spokenKeys` (the key
|
|
220
|
+
* names in words, e.g. `'Up and Down arrows'` for `'↑ ↓'`), else `keys`.
|
|
314
221
|
*
|
|
315
222
|
* @category ui/command-palette
|
|
316
223
|
* @since 0.1.0
|
|
@@ -318,12 +225,14 @@ interface CngxCommandPaletteTemplates {
|
|
|
318
225
|
interface CngxCommandPaletteLegendEntry {
|
|
319
226
|
readonly keys: string;
|
|
320
227
|
readonly label: string;
|
|
228
|
+
readonly spokenKeys?: string;
|
|
321
229
|
}
|
|
322
230
|
/**
|
|
323
|
-
*
|
|
324
|
-
* default
|
|
325
|
-
*
|
|
326
|
-
*
|
|
231
|
+
* Configuration for the command palette. The copy keys hold overrides only:
|
|
232
|
+
* unset by default, a value or a `Signal` once a `with*` feature ran. Every
|
|
233
|
+
* copy key they leave out reads the `commandPalette` section of the language
|
|
234
|
+
* pack (English without one), so the palette follows a runtime language
|
|
235
|
+
* switch.
|
|
327
236
|
*
|
|
328
237
|
* @category ui/command-palette
|
|
329
238
|
* @since 0.1.0
|
|
@@ -335,21 +244,23 @@ interface CngxCommandPaletteConfig {
|
|
|
335
244
|
*/
|
|
336
245
|
readonly openShortcut: string;
|
|
337
246
|
/** Placeholder + accessible name for the search input. */
|
|
338
|
-
readonly searchPlaceholder
|
|
247
|
+
readonly searchPlaceholder?: string | Signal<string>;
|
|
339
248
|
/** Accessible label for the results listbox. */
|
|
340
|
-
readonly listboxLabel
|
|
249
|
+
readonly listboxLabel?: string | Signal<string>;
|
|
341
250
|
/** Empty-state copy (async source returned no results). */
|
|
342
|
-
readonly emptyLabel
|
|
251
|
+
readonly emptyLabel?: string | Signal<string>;
|
|
343
252
|
/** First-load skeleton copy. */
|
|
344
|
-
readonly loadingLabel
|
|
253
|
+
readonly loadingLabel?: string | Signal<string>;
|
|
345
254
|
/** Error-state copy. */
|
|
346
|
-
readonly errorLabel
|
|
255
|
+
readonly errorLabel?: string | Signal<string>;
|
|
347
256
|
/** Retry-button copy in the error state. */
|
|
348
|
-
readonly retryLabel
|
|
257
|
+
readonly retryLabel?: string | Signal<string>;
|
|
258
|
+
/** Accessible name of the palette dialog while its `[ariaLabel]` is unbound. */
|
|
259
|
+
readonly paletteLabel?: string | Signal<string>;
|
|
349
260
|
/** Builds the polite `aria-live` result-count message. */
|
|
350
|
-
readonly resultCount: (count: number) => string
|
|
261
|
+
readonly resultCount?: ((count: number) => string) | Signal<(count: number) => string>;
|
|
351
262
|
/** Keyboard-legend rows rendered in the footer. */
|
|
352
|
-
readonly footerLegend
|
|
263
|
+
readonly footerLegend?: readonly CngxCommandPaletteLegendEntry[] | Signal<readonly CngxCommandPaletteLegendEntry[]>;
|
|
353
264
|
/** Global default slot templates (config = strings, slots = structure). */
|
|
354
265
|
readonly templates?: CngxCommandPaletteTemplates;
|
|
355
266
|
}
|
|
@@ -405,14 +316,28 @@ declare function provideCommandPaletteConfigAt(...features: CngxCommandPaletteCo
|
|
|
405
316
|
* @since 0.1.0
|
|
406
317
|
*/
|
|
407
318
|
declare function injectCommandPaletteConfig(): CngxCommandPaletteConfig;
|
|
319
|
+
/**
|
|
320
|
+
* @internal - the config with every copy key unwrapped to a plain value. Still
|
|
321
|
+
* a {@link CngxCommandPaletteConfig}, so a reader keeps one config shape.
|
|
322
|
+
*/
|
|
323
|
+
type CngxCommandPaletteResolvedConfig = CngxCommandPaletteConfig & CngxCommandPaletteSiteCopy;
|
|
324
|
+
/**
|
|
325
|
+
* The text-label keys {@link withCommandPaletteLabels} overrides.
|
|
326
|
+
*
|
|
327
|
+
* @category ui/command-palette
|
|
328
|
+
* @since 0.1.0
|
|
329
|
+
*/
|
|
330
|
+
type CngxCommandPaletteLabelKey = 'searchPlaceholder' | 'listboxLabel' | 'emptyLabel' | 'loadingLabel' | 'errorLabel' | 'retryLabel' | 'paletteLabel';
|
|
408
331
|
/**
|
|
409
332
|
* Override any subset of the palette's text labels. Unset labels keep the
|
|
410
|
-
*
|
|
333
|
+
* inherited value. Pass a `Signal` of the overrides to switch the language at
|
|
334
|
+
* runtime; a key the Signal sets wins over the inherited value, an unset key
|
|
335
|
+
* follows it.
|
|
411
336
|
*
|
|
412
337
|
* @category ui/command-palette
|
|
413
338
|
* @since 0.1.0
|
|
414
339
|
*/
|
|
415
|
-
declare function withCommandPaletteLabels(labels: Partial<Pick<CngxCommandPaletteConfig,
|
|
340
|
+
declare function withCommandPaletteLabels(labels: Partial<Pick<CngxCommandPaletteConfig, CngxCommandPaletteLabelKey>> | Signal<Partial<Record<CngxCommandPaletteLabelKey, string>>>): CngxCommandPaletteConfigFeature;
|
|
416
341
|
/**
|
|
417
342
|
* Set the combo that opens the palette (parsed via `parseKeyCombo`, e.g.
|
|
418
343
|
* `'mod+k'`, `'mod+shift+p'`). Applies app-wide via `provideCommandPaletteConfig`
|
|
@@ -424,20 +349,22 @@ declare function withCommandPaletteLabels(labels: Partial<Pick<CngxCommandPalett
|
|
|
424
349
|
*/
|
|
425
350
|
declare function withPaletteShortcut(combo: string): CngxCommandPaletteConfigFeature;
|
|
426
351
|
/**
|
|
427
|
-
* Replace the footer keyboard legend.
|
|
352
|
+
* Replace the footer keyboard legend. Pass a `Signal` to switch the language at
|
|
353
|
+
* runtime.
|
|
428
354
|
*
|
|
429
355
|
* @category ui/command-palette
|
|
430
356
|
* @since 0.1.0
|
|
431
357
|
*/
|
|
432
|
-
declare function withKeyboardLegend(entries: readonly CngxCommandPaletteLegendEntry[]): CngxCommandPaletteConfigFeature;
|
|
358
|
+
declare function withKeyboardLegend(entries: readonly CngxCommandPaletteLegendEntry[] | Signal<readonly CngxCommandPaletteLegendEntry[]>): CngxCommandPaletteConfigFeature;
|
|
433
359
|
/**
|
|
434
360
|
* Replace the `aria-live` result-count formatter (e.g. for pluralisation in
|
|
435
|
-
* another locale).
|
|
361
|
+
* another locale). Pass a `Signal` of the formatter to switch the language at
|
|
362
|
+
* runtime; the live count speaks the new formatter on its next change.
|
|
436
363
|
*
|
|
437
364
|
* @category ui/command-palette
|
|
438
365
|
* @since 0.1.0
|
|
439
366
|
*/
|
|
440
|
-
declare function withResultCountFormatter(formatter: (count: number) => string): CngxCommandPaletteConfigFeature;
|
|
367
|
+
declare function withResultCountFormatter(formatter: ((count: number) => string) | Signal<(count: number) => string>): CngxCommandPaletteConfigFeature;
|
|
441
368
|
/**
|
|
442
369
|
* Register global default slot templates. Merged over any already set; a
|
|
443
370
|
* per-instance `*cngxCommand*` slot still wins over these.
|
|
@@ -447,5 +374,192 @@ declare function withResultCountFormatter(formatter: (count: number) => string):
|
|
|
447
374
|
*/
|
|
448
375
|
declare function withCommandPaletteTemplates(templates: CngxCommandPaletteTemplates): CngxCommandPaletteConfigFeature;
|
|
449
376
|
|
|
450
|
-
|
|
451
|
-
|
|
377
|
+
/**
|
|
378
|
+
* Contract the palette surface exposes to its panel body. One token, single
|
|
379
|
+
* surface today; the container-swap second token is the documented eject seam
|
|
380
|
+
* if a second surface ever lands (tracked debt), not built for one consumer.
|
|
381
|
+
*
|
|
382
|
+
* Focus restore is intentionally NOT on this contract - the palette renders a
|
|
383
|
+
* native modal `<dialog cngxDialog>`, so `showModal()` traps focus and
|
|
384
|
+
* `CngxDialog` stores the trigger at open and returns focus after the close
|
|
385
|
+
* transition settles. The panel only needs to know it is open and to ask the
|
|
386
|
+
* surface to dismiss when a command runs.
|
|
387
|
+
*
|
|
388
|
+
* @category ui/command-palette
|
|
389
|
+
* @since 0.1.0
|
|
390
|
+
*/
|
|
391
|
+
interface CngxCommandPaletteHost {
|
|
392
|
+
/**
|
|
393
|
+
* Whether the palette surface is currently open. Two documented consumers:
|
|
394
|
+
* the panel resets its term and highlight when this flips to `false` (state
|
|
395
|
+
* must not leak into the next open), and a composing consumer derives open
|
|
396
|
+
* state from it instead of tracking its own flag -
|
|
397
|
+
* `CngxCommandPaletteTrigger` binds its `aria-expanded` to the palette's
|
|
398
|
+
* implementation of this member.
|
|
399
|
+
*/
|
|
400
|
+
readonly isOpen: Signal<boolean>;
|
|
401
|
+
/** Dismiss the surface (e.g. after a command runs). */
|
|
402
|
+
dismiss(): void;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* DI token the panel injects (optional) to reach its hosting palette surface.
|
|
406
|
+
*
|
|
407
|
+
* @category ui/command-palette
|
|
408
|
+
* @since 0.1.0
|
|
409
|
+
*/
|
|
410
|
+
declare const CNGX_COMMAND_PALETTE_HOST: InjectionToken<CngxCommandPaletteHost>;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* The opinionated Cmd/Ctrl+K command palette preset. Renders the panel body +
|
|
414
|
+
* async-state shell inside a native modal `<dialog cngxDialog>`, so focus
|
|
415
|
+
* trapping, trigger storage at open, and focus restore after the close
|
|
416
|
+
* transition are handled by `CngxDialog` and the platform - no hand-rolled
|
|
417
|
+
* focus machinery. The palette provides `CNGX_COMMAND_PALETTE_HOST` so the
|
|
418
|
+
* panel can dismiss it when a command runs.
|
|
419
|
+
*
|
|
420
|
+
* Type-to-filter runs over the merged command registry (`injectCommands`) plus
|
|
421
|
+
* the consumer's async `[results]`; the palette commits no form value - it
|
|
422
|
+
* fires `command.run()`, the locked demarcation from `CngxCombobox`. The global
|
|
423
|
+
* Cmd/Ctrl+K open combo is wired by the keybinding factory, not here.
|
|
424
|
+
*
|
|
425
|
+
* ```html
|
|
426
|
+
* <cngx-command-palette #palette [results]="results()" />
|
|
427
|
+
* <button [cngxCommandPaletteTrigger]="palette">Search commands</button>
|
|
428
|
+
* ```
|
|
429
|
+
*
|
|
430
|
+
* @category ui/command-palette
|
|
431
|
+
* @docsKind primary
|
|
432
|
+
* @wcag AA
|
|
433
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/command-palette/palette/command-palette.component.ts
|
|
434
|
+
* @selector cngx-command-palette
|
|
435
|
+
* @since 0.1.0
|
|
436
|
+
* @relatedTo CngxCommandPaletteTrigger, provideCommands, CngxDialog
|
|
437
|
+
*/
|
|
438
|
+
declare class CngxCommandPalette implements CngxCommandPaletteHost {
|
|
439
|
+
/** Consumer-derived async result source. */
|
|
440
|
+
readonly results: i0.InputSignal<CngxAsyncState<CngxCommandGroup[]> | undefined>;
|
|
441
|
+
/** Two-way scope; feeds the matcher's scope filter and the panel chip. */
|
|
442
|
+
readonly scope: i0.ModelSignal<string | undefined>;
|
|
443
|
+
/** Debounce for the search input. */
|
|
444
|
+
readonly debounceMs: i0.InputSignal<number>;
|
|
445
|
+
private readonly config;
|
|
446
|
+
protected readonly copy: Signal<CngxCommandPaletteResolvedConfig>;
|
|
447
|
+
/**
|
|
448
|
+
* Accessible name for the dialog. Unbound, `paletteLabel` from
|
|
449
|
+
* `CNGX_COMMAND_PALETTE_CONFIG` (`withCommandPaletteLabels`) applies.
|
|
450
|
+
*/
|
|
451
|
+
readonly ariaLabel: i0.InputSignal<string | undefined>;
|
|
452
|
+
/** @internal */
|
|
453
|
+
protected readonly resolvedAriaLabel: Signal<string>;
|
|
454
|
+
/**
|
|
455
|
+
* Per-instance open combo (parsed via `parseKeyCombo`, e.g. `'mod+shift+p'`).
|
|
456
|
+
* Wins over `CNGX_COMMAND_PALETTE_CONFIG.openShortcut` (`withPaletteShortcut`),
|
|
457
|
+
* which wins over the `'mod+k'` default. Changing it live re-installs the
|
|
458
|
+
* listener. For a full listener swap, override `CNGX_PALETTE_KEYBINDING_FACTORY`.
|
|
459
|
+
*/
|
|
460
|
+
readonly openShortcut: i0.InputSignal<string | undefined>;
|
|
461
|
+
/** Fired when the user asks to retry a failed result load. */
|
|
462
|
+
readonly retry: i0.OutputEmitterRef<void>;
|
|
463
|
+
private readonly rowSlot;
|
|
464
|
+
private readonly groupHeaderSlot;
|
|
465
|
+
private readonly emptySlot;
|
|
466
|
+
private readonly loadingSlot;
|
|
467
|
+
private readonly errorSlot;
|
|
468
|
+
private readonly footerSlot;
|
|
469
|
+
protected readonly rowTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandRowContext> | null>;
|
|
470
|
+
protected readonly groupHeaderTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandGroupHeaderContext> | null>;
|
|
471
|
+
protected readonly emptyTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandPaletteEmptyContext> | null>;
|
|
472
|
+
protected readonly loadingTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandPaletteLoadingContext> | null>;
|
|
473
|
+
protected readonly errorTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandPaletteErrorContext> | null>;
|
|
474
|
+
protected readonly footerTpl: Signal<i0.TemplateRef<_cngx_ui_command_palette.CngxCommandPaletteFooterContext> | null>;
|
|
475
|
+
private readonly dialog;
|
|
476
|
+
/** Whether the palette is open. Part of the {@link CngxCommandPaletteHost} contract. */
|
|
477
|
+
readonly isOpen: Signal<boolean>;
|
|
478
|
+
/** Resolved open combo: instance input > config > `'mod+k'` default. */
|
|
479
|
+
private readonly resolvedShortcut;
|
|
480
|
+
constructor();
|
|
481
|
+
/** Open the palette. */
|
|
482
|
+
open(): void;
|
|
483
|
+
/** Dismiss the palette. Focus returns to the trigger via `CngxDialog`. */
|
|
484
|
+
dismiss(): void;
|
|
485
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CngxCommandPalette, never>;
|
|
486
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<CngxCommandPalette, "cngx-command-palette", never, { "results": { "alias": "results"; "required": false; "isSignal": true; }; "scope": { "alias": "scope"; "required": false; "isSignal": true; }; "debounceMs": { "alias": "debounceMs"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "openShortcut": { "alias": "openShortcut"; "required": false; "isSignal": true; }; }, { "scope": "scopeChange"; "retry": "retry"; }, ["rowSlot", "groupHeaderSlot", "emptySlot", "loadingSlot", "errorSlot", "footerSlot"], never, true, never>;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Optional explicit trigger for a {@link CngxCommandPalette}. Opens the palette
|
|
491
|
+
* on click and advertises the popup relationship to assistive tech:
|
|
492
|
+
* `aria-haspopup="dialog"` plus `aria-expanded` derived from the palette's
|
|
493
|
+
* `isOpen()` host seam, so the trigger communicates the open state without any
|
|
494
|
+
* synced local flag. Pass the palette by template reference - orthogonal
|
|
495
|
+
* composition, no ancestor injection.
|
|
496
|
+
*
|
|
497
|
+
* ```html
|
|
498
|
+
* <button [cngxCommandPaletteTrigger]="palette">
|
|
499
|
+
* Search <kbd>Cmd K</kbd>
|
|
500
|
+
* </button>
|
|
501
|
+
* <cngx-command-palette #palette />
|
|
502
|
+
* ```
|
|
503
|
+
*
|
|
504
|
+
* @category ui/command-palette
|
|
505
|
+
* @wcag AA
|
|
506
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/command-palette/palette/command-palette-trigger.directive.ts
|
|
507
|
+
* @since 0.1.0
|
|
508
|
+
* @relatedTo CngxCommandPalette
|
|
509
|
+
*/
|
|
510
|
+
declare class CngxCommandPaletteTrigger {
|
|
511
|
+
/** The palette this trigger opens. */
|
|
512
|
+
readonly palette: i0.InputSignal<CngxCommandPalette>;
|
|
513
|
+
protected open(): void;
|
|
514
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CngxCommandPaletteTrigger, never>;
|
|
515
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CngxCommandPaletteTrigger, "[cngxCommandPaletteTrigger]", ["cngxCommandPaletteTrigger"], { "palette": { "alias": "cngxCommandPaletteTrigger"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Handle returned by a palette keybinding: a teardown that removes the document
|
|
520
|
+
* listener. The palette recreates the keybinding whenever the resolved combo
|
|
521
|
+
* changes and tears the previous one down, so nothing leaks document-wide.
|
|
522
|
+
*
|
|
523
|
+
* @category ui/command-palette
|
|
524
|
+
* @since 0.1.0
|
|
525
|
+
*/
|
|
526
|
+
interface CngxPaletteKeybinding {
|
|
527
|
+
/** Removes the installed document keydown listener. */
|
|
528
|
+
teardown(): void;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Factory producing a {@link CngxPaletteKeybinding} for a combo. It installs a
|
|
532
|
+
* global listener that invokes `onOpen` whenever the combo is pressed. Captured
|
|
533
|
+
* as a type alias so an override matches the exact signature - a consumer can
|
|
534
|
+
* swap in an enterprise key-capture policy without touching the palette.
|
|
535
|
+
*
|
|
536
|
+
* @category ui/command-palette
|
|
537
|
+
* @since 0.1.0
|
|
538
|
+
*/
|
|
539
|
+
type CngxPaletteKeybindingFactory = (combo: KeyCombo, onOpen: () => void) => CngxPaletteKeybinding;
|
|
540
|
+
/**
|
|
541
|
+
* Default palette keybinding: installs a document keydown listener that calls
|
|
542
|
+
* `onOpen` whenever the combo is pressed (matched via `matchesKeyCombo`).
|
|
543
|
+
* Side-effectful by design - it owns the global listener - so its `teardown`
|
|
544
|
+
* must be called on destroy.
|
|
545
|
+
*
|
|
546
|
+
* `isMac` defaults to platform detection; pass it explicitly for deterministic
|
|
547
|
+
* tests.
|
|
548
|
+
*
|
|
549
|
+
* @category ui/command-palette
|
|
550
|
+
* @since 0.1.0
|
|
551
|
+
*/
|
|
552
|
+
declare function createPaletteKeybinding(combo: KeyCombo, onOpen: () => void, isMac?: boolean): CngxPaletteKeybinding;
|
|
553
|
+
/**
|
|
554
|
+
* Swappable open-trigger seam. Defaults to {@link createPaletteKeybinding}.
|
|
555
|
+
* Override it to install an enterprise key-capture policy without touching the
|
|
556
|
+
* palette. To only change the *combo*, prefer `withPaletteShortcut(...)` or the
|
|
557
|
+
* `[openShortcut]` input - this token is for replacing the whole listener.
|
|
558
|
+
*
|
|
559
|
+
* @category ui/command-palette
|
|
560
|
+
* @since 0.1.0
|
|
561
|
+
*/
|
|
562
|
+
declare const CNGX_PALETTE_KEYBINDING_FACTORY: InjectionToken<CngxPaletteKeybindingFactory>;
|
|
563
|
+
|
|
564
|
+
export { CNGX_COMMAND_PALETTE_CONFIG, CNGX_COMMAND_PALETTE_HOST, CNGX_COMMAND_PALETTE_LANGUAGE_EN, CNGX_PALETTE_KEYBINDING_FACTORY, CngxCommandGroupHeader, CngxCommandPalette, CngxCommandPaletteEmpty, CngxCommandPaletteError, CngxCommandPaletteFooter, CngxCommandPaletteLoading, CngxCommandPaletteTrigger, CngxCommandRow, createPaletteKeybinding, injectCommandPaletteConfig, provideCommandPaletteConfig, provideCommandPaletteConfigAt, withCommandPaletteLabels, withCommandPaletteTemplates, withKeyboardLegend, withPaletteShortcut, withResultCountFormatter };
|
|
565
|
+
export type { CngxCommandGroupHeaderContext, CngxCommandPaletteConfig, CngxCommandPaletteConfigFeature, CngxCommandPaletteEmptyContext, CngxCommandPaletteErrorContext, CngxCommandPaletteFooterContext, CngxCommandPaletteHost, CngxCommandPaletteLabelKey, CngxCommandPaletteLanguageSection, CngxCommandPaletteLegendEntry, CngxCommandPaletteLoadingContext, CngxCommandPaletteTemplates, CngxCommandRowContext, CngxPaletteKeybinding, CngxPaletteKeybindingFactory };
|