@cngx/common 0.1.0-rc.8 → 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.
Files changed (90) hide show
  1. package/a11y/README.md +15 -2
  2. package/button/README.md +258 -0
  3. package/command/README.md +42 -2
  4. package/data/README.md +15 -12
  5. package/fesm2022/cngx-common-a11y.mjs +1076 -319
  6. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  7. package/fesm2022/cngx-common-audio.mjs +99 -77
  8. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  9. package/fesm2022/cngx-common-button.mjs +1084 -0
  10. package/fesm2022/cngx-common-button.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +138 -78
  12. package/fesm2022/cngx-common-card.mjs.map +1 -1
  13. package/fesm2022/cngx-common-chart.mjs +799 -327
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  15. package/fesm2022/cngx-common-command.mjs +101 -25
  16. package/fesm2022/cngx-common-command.mjs.map +1 -1
  17. package/fesm2022/cngx-common-data.mjs +861 -423
  18. package/fesm2022/cngx-common-data.mjs.map +1 -1
  19. package/fesm2022/cngx-common-dialog.mjs +198 -160
  20. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  21. package/fesm2022/cngx-common-display.mjs +693 -329
  22. package/fesm2022/cngx-common-display.mjs.map +1 -1
  23. package/fesm2022/cngx-common-interactive.mjs +7303 -2774
  24. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  25. package/fesm2022/cngx-common-layout.mjs +2174 -442
  26. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  27. package/fesm2022/cngx-common-menu-button.mjs +557 -0
  28. package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
  29. package/fesm2022/cngx-common-popover.mjs +2109 -557
  30. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  31. package/fesm2022/cngx-common-stepper.mjs +548 -419
  32. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  33. package/fesm2022/cngx-common-tabs.mjs +442 -331
  34. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  35. package/fesm2022/cngx-common-timeline.mjs +44 -71
  36. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  37. package/fesm2022/cngx-common.mjs +10 -10
  38. package/fesm2022/cngx-common.mjs.map +1 -1
  39. package/interactive/README.md +30 -19
  40. package/layout/README.md +17 -1
  41. package/menu-button/README.md +234 -0
  42. package/package.json +31 -8
  43. package/popover/README.md +81 -4
  44. package/popover/tooltip-indicator.scss +52 -0
  45. package/schematics/collection.json +9 -0
  46. package/schematics/ng-add/index.js +9 -0
  47. package/schematics/ng-add/schema.json +96 -0
  48. package/schematics/package.json +3 -0
  49. package/stepper/README.md +5 -5
  50. package/theming/components/cngx-accordion.css +36 -7
  51. package/theming/components/cngx-async.css +185 -37
  52. package/theming/components/cngx-backdrop.css +3 -1
  53. package/theming/components/cngx-badge.css +20 -5
  54. package/theming/components/cngx-bottom-sheet.css +2 -0
  55. package/theming/components/cngx-breadcrumb.css +3 -1
  56. package/theming/components/cngx-button-group.css +325 -0
  57. package/theming/components/cngx-button-toggle.css +55 -23
  58. package/theming/components/cngx-button.css +975 -0
  59. package/theming/components/cngx-data-grid.css +2 -0
  60. package/theming/components/cngx-dialog.css +3 -1
  61. package/theming/components/cngx-divider.css +24 -9
  62. package/theming/components/cngx-drawer.css +153 -0
  63. package/theming/components/cngx-icon-glyph.css +76 -0
  64. package/theming/components/cngx-listbox.css +79 -25
  65. package/theming/components/cngx-menu.css +112 -52
  66. package/theming/components/cngx-nav.css +1220 -0
  67. package/theming/components/cngx-popover-sheet.css +434 -0
  68. package/theming/components/cngx-popover.css +37 -9
  69. package/theming/components/cngx-recycler-placeholder.css +2 -0
  70. package/theming/components/cngx-ripple.css +74 -16
  71. package/theming/components/cngx-sidebar.css +71 -0
  72. package/theming/components/cngx-slider.css +3 -1
  73. package/theming/components/cngx-tooltip.css +2 -0
  74. package/timeline/README.md +2 -2
  75. package/types/cngx-common-a11y.d.ts +488 -112
  76. package/types/cngx-common-audio.d.ts +60 -88
  77. package/types/cngx-common-button.d.ts +698 -0
  78. package/types/cngx-common-card.d.ts +104 -78
  79. package/types/cngx-common-chart.d.ts +677 -389
  80. package/types/cngx-common-command.d.ts +55 -41
  81. package/types/cngx-common-data.d.ts +506 -360
  82. package/types/cngx-common-dialog.d.ts +94 -127
  83. package/types/cngx-common-display.d.ts +475 -300
  84. package/types/cngx-common-interactive.d.ts +4383 -1721
  85. package/types/cngx-common-layout.d.ts +1399 -288
  86. package/types/cngx-common-menu-button.d.ts +382 -0
  87. package/types/cngx-common-popover.d.ts +990 -268
  88. package/types/cngx-common-stepper.d.ts +374 -465
  89. package/types/cngx-common-tabs.d.ts +309 -403
  90. package/types/cngx-common-timeline.d.ts +50 -109
@@ -0,0 +1,1084 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, makeEnvironmentProviders, inject, ElementRef, computed, input, booleanAttribute, ApplicationRef, Injector, DestroyRef, afterNextRender, HostAttributeToken, Directive, ViewEncapsulation, ChangeDetectionStrategy, Component, contentChild } from '@angular/core';
3
+ import { NgComponentOutlet } from '@angular/common';
4
+ import { CNGX_ASYNC_RUN_STATE, CNGX_ACTION_STATUS, CNGX_HOST_INTERACTION_STATE } from '@cngx/common/interactive';
5
+ import { injectLazySelf, nextUid, injectLoadingConfig, createVisibilityGate, injectDescribedByContribution, CNGX_DESCRIBED_BY, injectActivationGuard, createDescribedByRegistry } from '@cngx/core/utils';
6
+ import { cngxDevWarn, CngxRuntimeError, CNGX_ICON_X } from '@cngx/utils';
7
+ import { CngxIconSvg } from '@cngx/common/display';
8
+
9
+ const ELEMENT_NODE = 1;
10
+ const TEXT_NODE = 3;
11
+ /**
12
+ * `true` for a non-blank `aria-label`, `aria-labelledby` or `title`, or non-blank text outside
13
+ * every `[aria-hidden="true"]` and `[hidden]` subtree. Feeds the dev-mode name check.
14
+ *
15
+ * @internal
16
+ */
17
+ function hasAccessibleName(host) {
18
+ const labelled = ['aria-label', 'aria-labelledby', 'title'].some((attr) => (host.getAttribute(attr) ?? '').trim() !== '');
19
+ return labelled || hasNamedContent(host);
20
+ }
21
+ function hasNamedContent(node) {
22
+ for (const child of Array.from(node.childNodes)) {
23
+ if (child.nodeType === TEXT_NODE && (child.textContent ?? '').trim() !== '') {
24
+ return true;
25
+ }
26
+ if (child.nodeType !== ELEMENT_NODE) {
27
+ continue;
28
+ }
29
+ const el = child;
30
+ if (el.getAttribute('aria-hidden') === 'true' || el.hasAttribute('hidden')) {
31
+ continue;
32
+ }
33
+ if (hasNamedContent(el)) {
34
+ return true;
35
+ }
36
+ }
37
+ return false;
38
+ }
39
+
40
+ /**
41
+ * The resolved {@link CngxButtonConfig}. Empty by default.
42
+ *
43
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-config.ts
44
+ * @since 0.3.0
45
+ * @relatedTo provideButtonConfig, injectButtonConfig, withButtonVariant, withButtonTone, withButtonSize
46
+ */
47
+ const CNGX_BUTTON_CONFIG = new InjectionToken('CngxButtonConfig', {
48
+ providedIn: 'root',
49
+ factory: () => ({}),
50
+ });
51
+ /**
52
+ * Default emphasis in scope. An input, a pinned axis or a group still wins.
53
+ *
54
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-config.ts
55
+ * @since 0.3.0
56
+ * @relatedTo provideButtonConfig, provideButtonConfigAt
57
+ */
58
+ function withButtonVariant(variant) {
59
+ return { config: { variant } };
60
+ }
61
+ /**
62
+ * Default intent in scope. An input or a pinned tone still wins, so the close button stays
63
+ * `neutral`.
64
+ *
65
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-config.ts
66
+ * @since 0.3.0
67
+ * @relatedTo provideButtonConfig, provideButtonConfigAt
68
+ */
69
+ function withButtonTone(tone) {
70
+ return { config: { tone } };
71
+ }
72
+ /**
73
+ * Default size in scope. An input, a pinned size or a group still wins.
74
+ *
75
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-config.ts
76
+ * @since 0.3.0
77
+ * @relatedTo provideButtonConfig, provideButtonConfigAt
78
+ */
79
+ function withButtonSize(size) {
80
+ return { config: { size } };
81
+ }
82
+ /** @internal */
83
+ function mergeFeatures(base, features) {
84
+ return features.reduce((acc, f) => ({ ...acc, ...f.config }), base);
85
+ }
86
+ /**
87
+ * App-wide button defaults from `withButton*` features.
88
+ *
89
+ * ```ts
90
+ * bootstrapApplication(AppComponent, {
91
+ * providers: [provideButtonConfig(withButtonVariant('outline'), withButtonSize('sm'))],
92
+ * });
93
+ * ```
94
+ *
95
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-config.ts
96
+ * @since 0.3.0
97
+ * @relatedTo withButtonVariant, withButtonTone, withButtonSize, provideButtonConfigAt
98
+ */
99
+ function provideButtonConfig(...features) {
100
+ if (features.length === 0) {
101
+ return makeEnvironmentProviders([]);
102
+ }
103
+ return makeEnvironmentProviders([
104
+ { provide: CNGX_BUTTON_CONFIG, useValue: mergeFeatures({}, features) },
105
+ ]);
106
+ }
107
+ /**
108
+ * `viewProviders` twin of {@link provideButtonConfig}. Merges over the parent scope's config, so
109
+ * nested scopes cascade.
110
+ *
111
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-config.ts
112
+ * @since 0.3.0
113
+ * @relatedTo provideButtonConfig, withButtonVariant, withButtonTone, withButtonSize
114
+ */
115
+ function provideButtonConfigAt(...features) {
116
+ if (features.length === 0) {
117
+ return [];
118
+ }
119
+ return [
120
+ {
121
+ provide: CNGX_BUTTON_CONFIG,
122
+ useFactory: () => mergeFeatures(inject(CNGX_BUTTON_CONFIG, { skipSelf: true }), features),
123
+ },
124
+ ];
125
+ }
126
+ /**
127
+ * The config resolved for the current injector. For custom hosts and segments that size
128
+ * themselves like a button, as `CngxButtonGroupAddon` does.
129
+ *
130
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-config.ts
131
+ * @since 0.3.0
132
+ * @relatedTo CNGX_BUTTON_CONFIG, provideButtonConfig
133
+ */
134
+ function injectButtonConfig() {
135
+ return inject(CNGX_BUTTON_CONFIG);
136
+ }
137
+
138
+ /**
139
+ * Provided by a button group so children read it without importing the group class.
140
+ *
141
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-group.token.ts
142
+ * @since 0.3.0
143
+ * @relatedTo CngxButton, CngxButtonGroup, CngxButtonGroupAddon, CngxButtonBrain
144
+ */
145
+ const CNGX_BUTTON_GROUP = new InjectionToken('CngxButtonGroup');
146
+
147
+ const DEFAULT_TONE = 'neutral';
148
+ const DEFAULT_SIZE = 'md';
149
+ /**
150
+ * `input ?? group ?? config ?? md`, shared with the group addon so it sits on the buttons' row.
151
+ *
152
+ * @internal
153
+ */
154
+ function resolveButtonSize(input, group, config) {
155
+ return input ?? group?.size() ?? config.size ?? DEFAULT_SIZE;
156
+ }
157
+ /**
158
+ * Derivation behind `CngxButtonBrain`. The activation guard is a capture-phase `click` /
159
+ * `auxclick` listener: while `blocked` it stops every same-element handler (`RouterLink`,
160
+ * `CngxAsyncClick` included) and prevents the default, implicit form submission included.
161
+ *
162
+ * @internal
163
+ */
164
+ function injectButtonCore(inputs, defaults) {
165
+ const host = inject(ElementRef).nativeElement;
166
+ const group = inject(CNGX_BUTTON_GROUP, { optional: true });
167
+ const config = injectButtonConfig();
168
+ // Resolved on first read, not at construction: the co-hosted runner injects
169
+ // the CNGX_HOST_INTERACTION_STATE this button provides, so an eager inject
170
+ // in either direction is a cycle.
171
+ const runState = injectLazySelf(CNGX_ASYNC_RUN_STATE, { optional: true });
172
+ const reasonId = nextUid('cngx-button-reason');
173
+ const describedByKey = nextUid('cngx-button-describedby');
174
+ const isButtonHost = host.tagName === 'BUTTON';
175
+ const fixed = defaults.fixed;
176
+ const variant = computed(() => inputs.variant() ?? fixed?.variant ?? group?.variant() ?? config.variant ?? defaults.variant, ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
177
+ const tone = computed(() => inputs.tone() ?? fixed?.tone ?? config.tone ?? DEFAULT_TONE, ...(ngDevMode ? [{ debugName: "tone" }] : /* istanbul ignore next */ []));
178
+ const size = computed(() => resolveButtonSize(inputs.size() ?? fixed?.size, group, config), ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
179
+ const hostBusy = inputs.hostBusy;
180
+ const busy = computed(() => (runState()?.pending() ?? false) || (hostBusy?.() ?? false), ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
181
+ // Without a co-hosted runner nothing gates a run the host reflects, so the
182
+ // core opens its own gate on the loading-config timing. With a runner its
183
+ // gate stays the source (it already folds the host's run in).
184
+ const loadingConfig = injectLoadingConfig();
185
+ const ownBusyVisible = createVisibilityGate(computed(() => runState() === null && (hostBusy?.() ?? false)), computed(() => loadingConfig.showDelay), computed(() => loadingConfig.minDwell));
186
+ const busyVisible = computed(() => {
187
+ const run = runState();
188
+ return run ? run.busyVisible() : ownBusyVisible();
189
+ }, ...(ngDevMode ? [{ debugName: "busyVisible" }] : /* istanbul ignore next */ []));
190
+ const asyncClickRefuses = computed(() => runState()?.enabled() === false, ...(ngDevMode ? [{ debugName: "asyncClickRefuses" }] : /* istanbul ignore next */ []));
191
+ // What is painted busy refuses activation: the busy visual holds the block
192
+ // through its dwell, after the run itself has settled.
193
+ const blocked = computed(() => inputs.disabled() || busy() || busyVisible() || asyncClickRefuses(), ...(ngDevMode ? [{ debugName: "blocked" }] : /* istanbul ignore next */ []));
194
+ const busyAttr = computed(() => (busyVisible() ? 'true' : null), ...(ngDevMode ? [{ debugName: "busyAttr" }] : /* istanbul ignore next */ []));
195
+ const pendingAttr = computed(() => (busy() ? 'true' : null), ...(ngDevMode ? [{ debugName: "pendingAttr" }] : /* istanbul ignore next */ []));
196
+ // The runner binds aria-disabled on the same host. When one is co-hosted
197
+ // the button renders the runner's own value rather than an independently
198
+ // computed equal one, so the two host bindings share a single source and
199
+ // can never diverge whatever the write order. Without a runner the button
200
+ // is the sole writer and uses its own blocked state. The fallback also
201
+ // covers a runner that does not fold the host's refusal in (CngxAsyncClick
202
+ // does, so for it the fallback never fires): blocked always reads disabled.
203
+ const ownAriaDisabled = computed(() => (blocked() ? 'true' : null), ...(ngDevMode ? [{ debugName: "ownAriaDisabled" }] : /* istanbul ignore next */ []));
204
+ const ariaDisabled = computed(() => runState()?.ariaDisabledAttr() ?? ownAriaDisabled(), ...(ngDevMode ? [{ debugName: "ariaDisabled" }] : /* istanbul ignore next */ []));
205
+ // Held with the busy visual, so what is painted busy reads busy and never
206
+ // as a bare disabled through the dwell. With a runner it is the value the
207
+ // runner renders on the same host (its run, its held busy visual, its
208
+ // `[busy]` override and the host's run), so the two writers agree.
209
+ const ariaBusy = computed(() => busy() || busyVisible() || (runState()?.busy() ?? false) ? 'true' : null, ...(ngDevMode ? [{ debugName: "ariaBusy" }] : /* istanbul ignore next */ []));
210
+ const reasonIds = computed(() => inputs.disabled() && inputs.disabledReason() ? reasonId : null, ...(ngDevMode ? [{ debugName: "reasonIds" }] : /* istanbul ignore next */ []));
211
+ // Contributed before the reason: the registry keeps registration order,
212
+ // so the consumer's dynamic ids sit between the static seed and the reason.
213
+ injectDescribedByContribution(describedByKey, inputs.describedBy);
214
+ injectDescribedByContribution(reasonId, reasonIds);
215
+ // CngxButtonBrain provides the registry on its own element.
216
+ const describedBy = inject(CNGX_DESCRIBED_BY, { self: true }).value;
217
+ const hostType = computed(() => isButtonHost ? (inputs.type() ?? 'button') : null, ...(ngDevMode ? [{ debugName: "hostType" }] : /* istanbul ignore next */ []));
218
+ // Keyed on `blocked`, not on the own refusal: a runner that refuses or
219
+ // runs renders aria-disabled too, and a co-located listener (RouterLink, a
220
+ // consumer handler) must not act on an element that reads as disabled,
221
+ // an expanded popup trigger included: its popup closes by Escape, Tab, an
222
+ // outside press or an item activation.
223
+ injectActivationGuard(blocked);
224
+ return {
225
+ variant,
226
+ tone,
227
+ size,
228
+ busy,
229
+ busyVisible,
230
+ blocked,
231
+ busyAttr,
232
+ pendingAttr,
233
+ ariaDisabled,
234
+ ariaBusy,
235
+ describedBy,
236
+ reasonId,
237
+ activeReasonId: reasonIds,
238
+ hostType,
239
+ };
240
+ }
241
+
242
+ /**
243
+ * The host descriptor of `CngxButtonBrain`, set through {@link provideButtonHost}. A host fact,
244
+ * not a consumer option.
245
+ *
246
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-host.token.ts
247
+ * @since 0.3.0
248
+ * @relatedTo CngxButtonBrain, provideButtonHost, CNGX_BUTTON_HOST_STATE
249
+ */
250
+ const CNGX_BUTTON_HOST = new InjectionToken('CngxButtonHost');
251
+ /**
252
+ * The {@link CNGX_BUTTON_HOST} descriptor. Goes in the `providers` of the class that declares
253
+ * `CngxButtonBrain` in its `hostDirectives`. Full host in the README, "Building a custom button
254
+ * host".
255
+ *
256
+ * ```ts
257
+ * providers: [provideButtonHost('appChipButton', { defaultVariant: 'outline' })]
258
+ * ```
259
+ *
260
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-host.token.ts
261
+ * @since 0.3.0
262
+ * @relatedTo CngxButtonBrain, CNGX_BUTTON_HOST, CngxActionButton
263
+ */
264
+ function provideButtonHost(name, descriptor) {
265
+ return { provide: CNGX_BUTTON_HOST, useValue: { ...descriptor, name } };
266
+ }
267
+ /**
268
+ * Optional host state on the host element. Read on first use, so a factory may inject the host
269
+ * component.
270
+ *
271
+ * ```ts
272
+ * providers: [
273
+ * { provide: CNGX_BUTTON_HOST_STATE, useFactory: () => inject(AppCaret).hostState },
274
+ * ]
275
+ * ```
276
+ *
277
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-host.token.ts
278
+ * @since 0.3.0
279
+ * @relatedTo CngxButtonBrain, CNGX_BUTTON_HOST, CngxSplitCaret
280
+ */
281
+ const CNGX_BUTTON_HOST_STATE = new InjectionToken('CngxButtonHostState');
282
+
283
+ /**
284
+ * Custom busy glyph in place of the built-in spinner. Only the glyph changes: the `aria-hidden`
285
+ * layer and its show delay and min-dwell stay.
286
+ *
287
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-spinner.token.ts
288
+ * @since 0.3.0
289
+ * @relatedTo provideButtonSpinner, injectButtonSpinner, CngxButtonBrain, CngxButton
290
+ * <example-url>/#/common/button/button/custom-spinner</example-url>
291
+ */
292
+ const CNGX_BUTTON_SPINNER = new InjectionToken('CngxButtonSpinner');
293
+ /**
294
+ * Busy glyph for every cngx button below. `providers` or `viewProviders`; the nearest wins.
295
+ *
296
+ * ```ts
297
+ * bootstrapApplication(App, { providers: [provideButtonSpinner(MyDotsSpinner)] });
298
+ * ```
299
+ *
300
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-spinner.token.ts
301
+ * @since 0.3.0
302
+ * @relatedTo CNGX_BUTTON_SPINNER, injectButtonSpinner
303
+ * <example-url>/#/common/button/button/custom-spinner</example-url>
304
+ */
305
+ function provideButtonSpinner(component) {
306
+ return { provide: CNGX_BUTTON_SPINNER, useValue: component };
307
+ }
308
+ /**
309
+ * The {@link provideButtonSpinner} glyph, or `null` for the built-in spinner.
310
+ *
311
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-spinner.token.ts
312
+ * @since 0.3.0
313
+ * @relatedTo CNGX_BUTTON_SPINNER, provideButtonSpinner
314
+ */
315
+ function injectButtonSpinner() {
316
+ return inject(CNGX_BUTTON_SPINNER, { optional: true });
317
+ }
318
+
319
+ /**
320
+ * Provided by every host on `CngxButtonBrain`. A split button reads its main action through it.
321
+ *
322
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-state.token.ts
323
+ * @since 0.3.0
324
+ * @relatedTo CngxButton, CngxIconButton, CngxSplitButton, CngxButtonBrain, CngxSplitCaret, CngxActionButton
325
+ */
326
+ const CNGX_BUTTON_STATE = new InjectionToken('CngxButtonState');
327
+
328
+ /**
329
+ * The state and ARIA contract of every cngx button, as a host directive. Declare it in
330
+ * `hostDirectives` and name the host with `provideButtonHost`; the host keeps its template and
331
+ * CSS. The attributes it writes and a full host are in the README, "Building a custom button
332
+ * host".
333
+ *
334
+ * Provides `CNGX_BUTTON_STATE` (read by `cngxSplitButton`), `CNGX_HOST_INTERACTION_STATE` (read
335
+ * by a co-hosted `cngxAsyncClick` or `cngxMenuTrigger`) and `CNGX_DESCRIBED_BY`.
336
+ *
337
+ * An `iconOnly` host without an accessible name after two stable cycles warns
338
+ * [`CNGX1071`](/error-codes/cngx1071.md). A host without `provideButtonHost` throws
339
+ * [`CNGX1075`](/error-codes/cngx1075.md).
340
+ *
341
+ * @wcag AA
342
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-brain.directive.ts
343
+ * @since 0.3.0
344
+ * @relatedTo provideButtonHost, CNGX_BUTTON_HOST_STATE, CNGX_BUTTON_STATE, CngxButton, CngxAsyncClick, CNGX_BUTTON_HOST, CngxIconButton, CngxCloseButton, CNGX_ASYNC_RUN_STATE, provideActionStatusHost
345
+ * <example-url>/#/common/button/composition/custom-host</example-url>
346
+ * @axis level molecule
347
+ */
348
+ class CngxButtonBrain {
349
+ /** Emphasis. Hosts alias it to their selector; `''` (bare attribute) falls through. */
350
+ variant = input(undefined, { ...(ngDevMode ? { debugName: "variant" } : /* istanbul ignore next */ {}), transform: (v) => (v === '' ? undefined : v) });
351
+ /** Intent. */
352
+ tone = input(undefined, ...(ngDevMode ? [{ debugName: "tone" }] : /* istanbul ignore next */ []));
353
+ /** Size. */
354
+ size = input(undefined, ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
355
+ /** Rendered as `aria-disabled`: stays focusable, activation is swallowed. */
356
+ disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
357
+ /** Why the button is disabled; referenced through `aria-describedby` while `disabled` is set. */
358
+ disabledReason = input(undefined, ...(ngDevMode ? [{ debugName: "disabledReason" }] : /* istanbul ignore next */ []));
359
+ /**
360
+ * Space-separated description ids. Bind runtime ids here, not through
361
+ * `[attr.aria-describedby]`: the static attribute is read once at creation. Merged after the
362
+ * static attribute, before the disabled reason and co-hosted contributors (`[cngxTooltip]`).
363
+ */
364
+ describedBy = input(null, { ...(ngDevMode ? { debugName: "describedBy" } : /* istanbul ignore next */ {}), alias: 'cngxDescribedBy' });
365
+ /** Native `type` on a `<button>` host, `'button'` by default; ignored on `<a>`. */
366
+ type = input(undefined, ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
367
+ descriptor = injectButtonHostDescriptor();
368
+ // Read on first use: the host's factory injects the host component, which
369
+ // injects this brain, so an eager read is a cycle.
370
+ hostState = injectLazySelf(CNGX_BUTTON_HOST_STATE, { optional: true });
371
+ hostBusy = computed(() => this.hostState()?.busy?.() ?? false, ...(ngDevMode ? [{ debugName: "hostBusy" }] : /* istanbul ignore next */ []));
372
+ /** `disabled`, the host's own refusal or a run the host reflects. */
373
+ refusing = computed(() => this.disabled() || (this.hostState()?.refusing() ?? false) || this.hostBusy(), ...(ngDevMode ? [{ debugName: "refusing" }] : /* istanbul ignore next */ []));
374
+ core = injectButtonCore({
375
+ variant: this.variant,
376
+ tone: this.tone,
377
+ size: this.size,
378
+ disabled: this.refusing,
379
+ // The reason describes the own `disabled` only, never the host's refusal.
380
+ disabledReason: computed(() => (this.disabled() ? this.disabledReason() : undefined)),
381
+ describedBy: this.describedBy,
382
+ type: this.type,
383
+ hostBusy: this.hostBusy,
384
+ }, { variant: this.descriptor.defaultVariant, fixed: this.descriptor.fixed });
385
+ /** Resolved emphasis. */
386
+ variantValue = this.core.variant;
387
+ /** Resolved intent. */
388
+ toneValue = this.core.tone;
389
+ /** Resolved size. */
390
+ sizeValue = this.core.size;
391
+ /** A co-hosted run is pending or the host reflects one. Ungated. */
392
+ busy = this.core.busy;
393
+ /**
394
+ * The busy layer shows, gated on the `CNGX_LOADING_CONFIG` show delay and min-dwell.
395
+ * `CngxButtonAdornment` renders it.
396
+ */
397
+ busyVisible = this.core.busyVisible;
398
+ /**
399
+ * Refusing, busy or refused by the co-hosted runner. Every click is swallowed, an expanded popup
400
+ * trigger's included.
401
+ */
402
+ blocked = this.core.blocked;
403
+ /** Busy glyph from `provideButtonSpinner`, or `null` for the built-in spinner. */
404
+ spinner = injectButtonSpinner();
405
+ /**
406
+ * @internal The action status on this element (`CngxActionStatusBrain`), or `null`. Read on
407
+ * self only, so a button projected into an action host never sees the outer host's status.
408
+ */
409
+ actionStatus = injectLazySelf(CNGX_ACTION_STATUS, { optional: true });
410
+ /** Id of the reason span `CngxButtonAdornment` renders. */
411
+ reasonId = this.core.reasonId;
412
+ /** `reasonId` while `disabled` has a reason, else `null`. */
413
+ activeReasonId = this.core.activeReasonId;
414
+ /**
415
+ * Folded in by a co-hosted runner or trigger. Spread it when overriding
416
+ * `CNGX_HOST_INTERACTION_STATE`.
417
+ */
418
+ interaction = {
419
+ disabled: this.refusing,
420
+ busy: this.hostBusy,
421
+ };
422
+ busyAttr = this.core.busyAttr;
423
+ pendingAttr = this.core.pendingAttr;
424
+ ariaDisabled = this.core.ariaDisabled;
425
+ ariaBusy = this.core.ariaBusy;
426
+ describedByValue = this.core.describedBy;
427
+ hostType = this.core.hostType;
428
+ constructor() {
429
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && this.descriptor.iconOnly) {
430
+ // After the app is stable, not after the first render: a label bound
431
+ // in a later pass is a name too. A miss is looked at once more on the
432
+ // next stable cycle, so a label that lands after the first one does
433
+ // not warn either.
434
+ const host = inject(ElementRef).nativeElement;
435
+ const appRef = inject(ApplicationRef);
436
+ const injector = inject(Injector);
437
+ let destroyed = false;
438
+ inject(DestroyRef).onDestroy(() => (destroyed = true));
439
+ const onStableCycle = (check) => {
440
+ afterNextRender(() => void appRef.whenStable().then(check), { injector });
441
+ };
442
+ onStableCycle(() => {
443
+ if (destroyed || hasAccessibleName(host)) {
444
+ return;
445
+ }
446
+ onStableCycle(() => {
447
+ if (destroyed || hasAccessibleName(host)) {
448
+ return;
449
+ }
450
+ cngxDevWarn('CNGX1071', `[${this.descriptor.name}] has no accessible name. Set aria-label, aria-labelledby or title on the host; the glyph alone is silent to assistive technology.`, host);
451
+ });
452
+ });
453
+ }
454
+ }
455
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonBrain, deps: [], target: i0.ɵɵFactoryTarget.Directive });
456
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxButtonBrain, isStandalone: true, inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, tone: { classPropertyName: "tone", publicName: "tone", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, disabledReason: { classPropertyName: "disabledReason", publicName: "disabledReason", isSignal: true, isRequired: false, transformFunction: null }, describedBy: { classPropertyName: "describedBy", publicName: "cngxDescribedBy", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-variant": "variantValue()", "attr.data-tone": "toneValue()", "attr.data-size": "sizeValue()", "attr.data-busy": "busyAttr()", "attr.data-pending": "pendingAttr()", "attr.aria-disabled": "ariaDisabled()", "attr.aria-busy": "ariaBusy()", "attr.aria-describedby": "describedByValue()", "attr.type": "hostType()", "attr.disabled": "null" } }, providers: [
457
+ { provide: CNGX_BUTTON_STATE, useExisting: CngxButtonBrain },
458
+ {
459
+ provide: CNGX_HOST_INTERACTION_STATE,
460
+ useFactory: () => inject(CngxButtonBrain).interaction,
461
+ },
462
+ {
463
+ provide: CNGX_DESCRIBED_BY,
464
+ useFactory: () => createDescribedByRegistry({
465
+ name: injectButtonHostDescriptor().name,
466
+ seed: inject(new HostAttributeToken('aria-describedby'), { optional: true }),
467
+ }),
468
+ },
469
+ ], exportAs: ["cngxButtonBrain"], ngImport: i0 });
470
+ }
471
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonBrain, decorators: [{
472
+ type: Directive,
473
+ args: [{
474
+ standalone: true,
475
+ exportAs: 'cngxButtonBrain',
476
+ providers: [
477
+ { provide: CNGX_BUTTON_STATE, useExisting: CngxButtonBrain },
478
+ {
479
+ provide: CNGX_HOST_INTERACTION_STATE,
480
+ useFactory: () => inject(CngxButtonBrain).interaction,
481
+ },
482
+ {
483
+ provide: CNGX_DESCRIBED_BY,
484
+ useFactory: () => createDescribedByRegistry({
485
+ name: injectButtonHostDescriptor().name,
486
+ seed: inject(new HostAttributeToken('aria-describedby'), { optional: true }),
487
+ }),
488
+ },
489
+ ],
490
+ host: {
491
+ '[attr.data-variant]': 'variantValue()',
492
+ '[attr.data-tone]': 'toneValue()',
493
+ '[attr.data-size]': 'sizeValue()',
494
+ '[attr.data-busy]': 'busyAttr()',
495
+ '[attr.data-pending]': 'pendingAttr()',
496
+ '[attr.aria-disabled]': 'ariaDisabled()',
497
+ '[attr.aria-busy]': 'ariaBusy()',
498
+ '[attr.aria-describedby]': 'describedByValue()',
499
+ '[attr.type]': 'hostType()',
500
+ // A static `disabled` attribute would make the native element
501
+ // unfocusable; the input renders it as aria-disabled instead.
502
+ '[attr.disabled]': 'null',
503
+ },
504
+ }]
505
+ }], ctorParameters: () => [], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], tone: [{ type: i0.Input, args: [{ isSignal: true, alias: "tone", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], disabledReason: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledReason", required: false }] }], describedBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxDescribedBy", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }] } });
506
+ /** The host's `CNGX_BUTTON_HOST` descriptor, or throws [`CNGX1075`](/error-codes/cngx1075.md). */
507
+ function injectButtonHostDescriptor() {
508
+ const descriptor = inject(CNGX_BUTTON_HOST, { self: true, optional: true });
509
+ if (descriptor) {
510
+ return descriptor;
511
+ }
512
+ const tag = inject(ElementRef).nativeElement.tagName.toLowerCase();
513
+ throw new CngxRuntimeError('CNGX1075', typeof ngDevMode !== 'undefined' &&
514
+ ngDevMode &&
515
+ `[cngxButtonBrain] on <${tag}> has no host descriptor. Add provideButtonHost(name, { defaultVariant }) to the providers of the component or directive that declares CngxButtonBrain in its hostDirectives.`);
516
+ }
517
+
518
+ /**
519
+ * The busy layer and the reason span of a button family host, rendered once for every host. Put
520
+ * it last in the host template. It reads the host's `CngxButtonBrain`: the busy layer shows while
521
+ * `busyVisible` holds (with `provideButtonSpinner`'s glyph, or the built-in ring), and the hidden
522
+ * reason span carries the id the brain's `aria-describedby` points at while `disabled` has a
523
+ * reason. On an action host (`CNGX_ACTION_STATUS` present) the busy layer yields to an active
524
+ * status label. The element is `display: contents`, so it adds no box and no flex gap.
525
+ *
526
+ * ```html
527
+ * <span class="cngx-button__label"><ng-content /></span>
528
+ * <cngx-button-adornment />
529
+ * ```
530
+ *
531
+ * @wcag AA
532
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-adornment.component.ts
533
+ * @since 0.3.0
534
+ * @relatedTo CngxButtonBrain, provideButtonHost, CngxActionStatusBrain
535
+ * <example-url>/#/common/button/button/async-click-busy</example-url>
536
+ * <example-url>/#/common/button/button/disabled-with-reason</example-url>
537
+ * @axis level atom
538
+ */
539
+ class CngxButtonAdornment {
540
+ /** @internal */
541
+ brain = inject(CngxButtonBrain);
542
+ /** @internal */
543
+ busy = computed(() => this.brain.busyVisible() && (this.brain.actionStatus()?.activeCell() ?? 'idle') === 'idle', ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
544
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonAdornment, deps: [], target: i0.ɵɵFactoryTarget.Component });
545
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxButtonAdornment, isStandalone: true, selector: "cngx-button-adornment", host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
546
+ @if (busy()) {
547
+ <span class="cngx-button__busy" aria-hidden="true">
548
+ @if (brain.spinner; as spinner) {
549
+ <ng-container *ngComponentOutlet="spinner" />
550
+ } @else {
551
+ <span class="cngx-button__spinner"></span>
552
+ }
553
+ </span>
554
+ }
555
+ @if (brain.disabledReason(); as reason) {
556
+ <span class="cngx-button__reason" [id]="brain.reasonId" hidden>{{ reason }}</span>
557
+ }
558
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
559
+ }
560
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonAdornment, decorators: [{
561
+ type: Component,
562
+ args: [{
563
+ selector: 'cngx-button-adornment',
564
+ standalone: true,
565
+ imports: [NgComponentOutlet],
566
+ changeDetection: ChangeDetectionStrategy.OnPush,
567
+ encapsulation: ViewEncapsulation.None,
568
+ host: { style: 'display: contents' },
569
+ template: `
570
+ @if (busy()) {
571
+ <span class="cngx-button__busy" aria-hidden="true">
572
+ @if (brain.spinner; as spinner) {
573
+ <ng-container *ngComponentOutlet="spinner" />
574
+ } @else {
575
+ <span class="cngx-button__spinner"></span>
576
+ }
577
+ </span>
578
+ }
579
+ @if (brain.disabledReason(); as reason) {
580
+ <span class="cngx-button__reason" [id]="brain.reasonId" hidden>{{ reason }}</span>
581
+ }
582
+ `,
583
+ }]
584
+ }] });
585
+
586
+ /**
587
+ * Content before the label: icon, avatar, badge or `<kbd>`. Trims the inline-start padding.
588
+ * Rendered by `cngxButton`, `cngxMenuButton`, `cngxActionButton`, `cngxPopoverAction` and
589
+ * `cngxPopoverDismiss`.
590
+ *
591
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/slots.ts
592
+ * @since 0.3.0
593
+ * @relatedTo CngxButton, CngxButtonEnd, CngxMenuButton
594
+ * <example-url>/#/common/button/button/start-and-end-slots</example-url>
595
+ */
596
+ class CngxButtonStart {
597
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonStart, deps: [], target: i0.ɵɵFactoryTarget.Directive });
598
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxButtonStart, isStandalone: true, selector: "[cngxButtonStart]", host: { classAttribute: "cngx-button__slot cngx-button__slot--start" }, ngImport: i0 });
599
+ }
600
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonStart, decorators: [{
601
+ type: Directive,
602
+ args: [{
603
+ selector: '[cngxButtonStart]',
604
+ standalone: true,
605
+ host: { class: 'cngx-button__slot cngx-button__slot--start' },
606
+ }]
607
+ }] });
608
+ /**
609
+ * Content after the label: caret, count or shortcut hint. Trims the inline-end padding.
610
+ * Rendered by `cngxButton`, `cngxMenuButton`, `cngxActionButton`, `cngxPopoverAction` and
611
+ * `cngxPopoverDismiss`.
612
+ *
613
+ * ```html
614
+ * <button cngxButton>Export <kbd cngxButtonEnd>E</kbd></button>
615
+ * ```
616
+ *
617
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/slots.ts
618
+ * @since 0.3.0
619
+ * @relatedTo CngxButton, CngxButtonStart, CngxMenuButton
620
+ * <example-url>/#/common/button/button/start-and-end-slots</example-url>
621
+ */
622
+ class CngxButtonEnd {
623
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonEnd, deps: [], target: i0.ɵɵFactoryTarget.Directive });
624
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxButtonEnd, isStandalone: true, selector: "[cngxButtonEnd]", host: { classAttribute: "cngx-button__slot cngx-button__slot--end" }, ngImport: i0 });
625
+ }
626
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonEnd, decorators: [{
627
+ type: Directive,
628
+ args: [{
629
+ selector: '[cngxButtonEnd]',
630
+ standalone: true,
631
+ host: { class: 'cngx-button__slot cngx-button__slot--end' },
632
+ }]
633
+ }] });
634
+
635
+ /**
636
+ * The base button, an attribute component on the native `<button>` or `<a>`. `variant` is the
637
+ * selector value. State and ARIA come from `CngxButtonBrain`; see the README for the axes and
638
+ * accessibility.
639
+ *
640
+ * ```html
641
+ * <button cngxButton="outline" tone="primary">Save draft</button>
642
+ * <button [cngxButton]="variant()" type="submit">Submit</button>
643
+ * <a cngxButton="link" routerLink="/help">Help</a>
644
+ * <button cngxButton [cngxAsyncClick]="save">
645
+ * <svg cngxButtonStart aria-hidden="true" viewBox="0 0 24 24">...</svg>
646
+ * Save
647
+ * </button>
648
+ * ```
649
+ *
650
+ * @wcag AA
651
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button.component.ts
652
+ * @since 0.3.0
653
+ * @relatedTo CngxIconButton, CngxButtonBrain, CngxButtonStart, CngxButtonEnd, CngxAsyncClick, provideButtonConfig, CngxMenuButton, CngxButtonGroup, CngxActionButton
654
+ * <example-url>/#/common/button/button/variants</example-url>
655
+ * <example-url>/#/common/button/button/tones</example-url>
656
+ * <example-url>/#/common/button/button/sizes</example-url>
657
+ * <example-url>/#/common/button/button/start-and-end-slots</example-url>
658
+ * <example-url>/#/common/button/button/disabled-with-reason</example-url>
659
+ * <example-url>/#/common/button/button/async-click-busy</example-url>
660
+ * <example-url>/#/common/button/button/aligned-with-inputs</example-url>
661
+ * <example-url>/#/common/button/button/link-host</example-url>
662
+ * @axis level atom
663
+ */
664
+ class CngxButton {
665
+ startSlot = contentChild(CngxButtonStart, ...(ngDevMode ? [{ debugName: "startSlot" }] : /* istanbul ignore next */ []));
666
+ endSlot = contentChild(CngxButtonEnd, ...(ngDevMode ? [{ debugName: "endSlot" }] : /* istanbul ignore next */ []));
667
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
668
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.4", type: CngxButton, isStandalone: true, selector: "button[cngxButton], a[cngxButton]", host: { properties: { "attr.data-start": "startSlot() ? \"\" : null", "attr.data-end": "endSlot() ? \"\" : null" }, classAttribute: "cngx-button" }, providers: [provideButtonHost('cngxButton', { defaultVariant: 'solid' })], queries: [{ propertyName: "startSlot", first: true, predicate: CngxButtonStart, descendants: true, isSignal: true }, { propertyName: "endSlot", first: true, predicate: CngxButtonEnd, descendants: true, isSignal: true }], exportAs: ["cngxButton"], hostDirectives: [{ directive: CngxButtonBrain, inputs: ["variant", "cngxButton", "tone", "tone", "size", "size", "disabled", "disabled", "disabledReason", "disabledReason", "cngxDescribedBy", "cngxDescribedBy", "type", "type"] }], ngImport: i0, template: `
669
+ <ng-content select="[cngxButtonStart]" />
670
+ <span class="cngx-button__label"><ng-content /></span>
671
+ <ng-content select="[cngxButtonEnd]" />
672
+ <cngx-button-adornment />
673
+ `, isInline: true, dependencies: [{ kind: "component", type: CngxButtonAdornment, selector: "cngx-button-adornment" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
674
+ }
675
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButton, decorators: [{
676
+ type: Component,
677
+ args: [{
678
+ // eslint-disable-next-line @angular-eslint/component-selector -- attribute selector by design (sits on the native button / anchor)
679
+ selector: 'button[cngxButton], a[cngxButton]',
680
+ standalone: true,
681
+ exportAs: 'cngxButton',
682
+ imports: [CngxButtonAdornment],
683
+ changeDetection: ChangeDetectionStrategy.OnPush,
684
+ encapsulation: ViewEncapsulation.None,
685
+ hostDirectives: [
686
+ {
687
+ directive: CngxButtonBrain,
688
+ inputs: [
689
+ 'variant: cngxButton',
690
+ 'tone',
691
+ 'size',
692
+ 'disabled',
693
+ 'disabledReason',
694
+ 'cngxDescribedBy',
695
+ 'type',
696
+ ],
697
+ },
698
+ ],
699
+ providers: [provideButtonHost('cngxButton', { defaultVariant: 'solid' })],
700
+ host: {
701
+ class: 'cngx-button',
702
+ '[attr.data-start]': 'startSlot() ? "" : null',
703
+ '[attr.data-end]': 'endSlot() ? "" : null',
704
+ },
705
+ template: `
706
+ <ng-content select="[cngxButtonStart]" />
707
+ <span class="cngx-button__label"><ng-content /></span>
708
+ <ng-content select="[cngxButtonEnd]" />
709
+ <cngx-button-adornment />
710
+ `,
711
+ }]
712
+ }], propDecorators: { startSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxButtonStart), { isSignal: true }] }], endSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxButtonEnd), { isSignal: true }] }] } });
713
+
714
+ /**
715
+ * Square icon-only button on the `CngxButton` brain, `ghost` by default. Project an `svg`, `img`
716
+ * or `cngx-icon`; wrap a `mat-icon` in a `cngx-icon`.
717
+ *
718
+ * The glyph is `aria-hidden`, so nothing projected becomes the name. Set `aria-label`,
719
+ * `aria-labelledby` or `title`, else it warns [`CNGX1071`](/error-codes/cngx1071.md). On a coarse
720
+ * pointer the box floors to `--cngx-target-min` on both axes; the icon keeps its size.
721
+ *
722
+ * @wcag AA
723
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/icon-button.component.ts
724
+ * @since 0.3.0
725
+ * @relatedTo CngxButton, CngxButtonBrain, CngxAsyncClick, provideButtonConfig, CngxSplitButton, CngxIconMenuButton, CngxCloseButton
726
+ * <example-url>/#/common/button/icon-button/basic</example-url>
727
+ * <example-url>/#/common/button/icon-button/with-badge</example-url>
728
+ * @axis level atom
729
+ */
730
+ class CngxIconButton {
731
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIconButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
732
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.4", type: CngxIconButton, isStandalone: true, selector: "button[cngxIconButton], a[cngxIconButton]", host: { classAttribute: "cngx-button cngx-icon-button" }, providers: [provideButtonHost('cngxIconButton', { defaultVariant: 'ghost', iconOnly: true })], exportAs: ["cngxIconButton"], hostDirectives: [{ directive: CngxButtonBrain, inputs: ["variant", "cngxIconButton", "tone", "tone", "size", "size", "disabled", "disabled", "disabledReason", "disabledReason", "cngxDescribedBy", "cngxDescribedBy", "type", "type"] }], ngImport: i0, template: `
733
+ <span class="cngx-button__label cngx-icon-button__glyph" aria-hidden="true"
734
+ ><ng-content
735
+ /></span>
736
+ <cngx-button-adornment />
737
+ `, isInline: true, dependencies: [{ kind: "component", type: CngxButtonAdornment, selector: "cngx-button-adornment" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
738
+ }
739
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxIconButton, decorators: [{
740
+ type: Component,
741
+ args: [{
742
+ // eslint-disable-next-line @angular-eslint/component-selector -- attribute selector by design (sits on the native button / anchor)
743
+ selector: 'button[cngxIconButton], a[cngxIconButton]',
744
+ standalone: true,
745
+ exportAs: 'cngxIconButton',
746
+ imports: [CngxButtonAdornment],
747
+ changeDetection: ChangeDetectionStrategy.OnPush,
748
+ encapsulation: ViewEncapsulation.None,
749
+ hostDirectives: [
750
+ {
751
+ directive: CngxButtonBrain,
752
+ inputs: [
753
+ 'variant: cngxIconButton',
754
+ 'tone',
755
+ 'size',
756
+ 'disabled',
757
+ 'disabledReason',
758
+ 'cngxDescribedBy',
759
+ 'type',
760
+ ],
761
+ },
762
+ ],
763
+ providers: [provideButtonHost('cngxIconButton', { defaultVariant: 'ghost', iconOnly: true })],
764
+ host: { class: 'cngx-button cngx-icon-button' },
765
+ template: `
766
+ <span class="cngx-button__label cngx-icon-button__glyph" aria-hidden="true"
767
+ ><ng-content
768
+ /></span>
769
+ <cngx-button-adornment />
770
+ `,
771
+ }]
772
+ }] });
773
+
774
+ /**
775
+ * Close glyph for every `button[cngxCloseButton]` that projects none.
776
+ * `provideFeedback(withCloseIcon(MyIcon))` forwards to it.
777
+ *
778
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/close-button.component.ts
779
+ * @since 0.3.0
780
+ * @relatedTo provideButtonCloseIcon, injectButtonCloseIcon, CngxCloseButton
781
+ * <example-url>/#/common/button/close-button/provided-icon</example-url>
782
+ */
783
+ const CNGX_BUTTON_CLOSE_ICON = new InjectionToken('CngxButtonCloseIcon');
784
+ /**
785
+ * Close glyph for every close button below that projects none. `providers` or `viewProviders`;
786
+ * the nearest wins.
787
+ *
788
+ * ```ts
789
+ * bootstrapApplication(App, { providers: [provideButtonCloseIcon(MaterialCloseIcon)] });
790
+ * ```
791
+ *
792
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/close-button.component.ts
793
+ * @since 0.3.0
794
+ * @relatedTo CNGX_BUTTON_CLOSE_ICON, injectButtonCloseIcon, CngxCloseButton
795
+ * <example-url>/#/common/button/close-button/provided-icon</example-url>
796
+ */
797
+ function provideButtonCloseIcon(component) {
798
+ return { provide: CNGX_BUTTON_CLOSE_ICON, useValue: component };
799
+ }
800
+ /**
801
+ * The {@link provideButtonCloseIcon} glyph, or `null` for the default X. For custom dismiss hosts.
802
+ *
803
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/close-button.component.ts
804
+ * @since 0.3.0
805
+ * @relatedTo CNGX_BUTTON_CLOSE_ICON, provideButtonCloseIcon
806
+ */
807
+ function injectButtonCloseIcon() {
808
+ return inject(CNGX_BUTTON_CLOSE_ICON, { optional: true });
809
+ }
810
+ /**
811
+ * Dismiss button with the X glyph, on the icon-button geometry. Name the dismissed thing in
812
+ * `aria-label` (`"Close session-expired alert"`, not `"Close"`), else it warns
813
+ * [`CNGX1071`](/error-codes/cngx1071.md).
814
+ *
815
+ * Pins `ghost`, `sm` and `neutral` against the group and the config; inputs still win. Under the
816
+ * Material bridge the default `sm` takes the 40px M3 icon-button box with a 24px glyph.
817
+ *
818
+ * ```html
819
+ * <button cngxCloseButton aria-label="Dismiss toast" [disabled]="saving()" disabledReason="Saving">
820
+ * <svg aria-hidden="true" viewBox="0 0 24 24">...</svg>
821
+ * </button>
822
+ * ```
823
+ *
824
+ * @wcag AA
825
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/close-button.component.ts
826
+ * @since 0.3.0
827
+ * @relatedTo provideButtonCloseIcon, CngxIconButton, CngxButtonBrain, CngxAlert, CngxToastOutlet, CngxPopoverPanel, withCloseIcon
828
+ * <example-url>/#/common/button/close-button/basic</example-url>
829
+ * <example-url>/#/common/button/close-button/projected-icon</example-url>
830
+ * <example-url>/#/common/button/close-button/provided-icon</example-url>
831
+ * <example-url>/#/common/button/close-button/contextual-labels</example-url>
832
+ * <example-url>/#/common/button/close-button/inside-a-dismissible-card</example-url>
833
+ * @axis level molecule
834
+ */
835
+ class CngxCloseButton {
836
+ /** @internal - app-wide glyph from `CNGX_BUTTON_CLOSE_ICON`. */
837
+ customIcon = injectButtonCloseIcon();
838
+ /** @internal - default X glyph from the shared icon set. */
839
+ closeIcon = CNGX_ICON_X;
840
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCloseButton, deps: [], target: i0.ɵɵFactoryTarget.Component });
841
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxCloseButton, isStandalone: true, selector: "button[cngxCloseButton]", host: { classAttribute: "cngx-button cngx-icon-button cngx-close-button" }, providers: [
842
+ provideButtonHost('cngxCloseButton', {
843
+ defaultVariant: 'ghost',
844
+ fixed: { variant: 'ghost', size: 'sm', tone: 'neutral' },
845
+ iconOnly: true,
846
+ }),
847
+ ], exportAs: ["cngxCloseButton"], hostDirectives: [{ directive: CngxButtonBrain, inputs: ["variant", "cngxCloseButton", "tone", "tone", "size", "size", "disabled", "disabled", "disabledReason", "disabledReason", "cngxDescribedBy", "cngxDescribedBy", "type", "type"] }], ngImport: i0, template: `
848
+ <span class="cngx-button__label cngx-icon-button__glyph" aria-hidden="true">
849
+ <ng-content>
850
+ @if (customIcon) {
851
+ <ng-container *ngComponentOutlet="customIcon" />
852
+ } @else {
853
+ <svg class="cngx-close-button__icon" [cngxIconSvg]="closeIcon"></svg>
854
+ }
855
+ </ng-content>
856
+ </span>
857
+ <cngx-button-adornment />
858
+ `, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-close-button-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-close-button-size{syntax: \"*\"; inherits: false;}@property --cngx-close-button-icon-size{syntax: \"*\"; inherits: true;}@property --cngx-close-button-radius{syntax: \"*\"; inherits: false;}@property --cngx-close-button-hover-bg{syntax: \"*\"; inherits: false;}@property --cngx-close-button-pressed-bg{syntax: \"*\"; inherits: false;}:where(.cngx-close-button){--cngx-close-button-color: var(--cngx-color-text-muted, oklch(.5 .01 250))}}@layer cngx.components{@scope(.cngx-close-button){:scope.cngx-button{--cngx-button-radius: var(--cngx-close-button-radius, var(--cngx-radius-sm, .25rem));inline-size:max(var(--cngx-close-button-size, var(--cngx-icon-button-size)),var(--cngx-target-min, 0px));block-size:max(var(--cngx-close-button-size, var(--cngx-icon-button-size)),var(--cngx-target-min, 0px))}:scope.cngx-button[data-variant=ghost][data-tone=neutral]:not([aria-disabled=true]){color:var(--cngx-close-button-color, currentColor)}:scope.cngx-button[data-variant=ghost][data-tone=neutral]:not([aria-disabled=true]):is(:hover,:focus-visible){color:var(--cngx-button-tone-text, currentColor)}:scope.cngx-button[data-variant=ghost]:not([aria-disabled=true]):hover{background:var( --cngx-close-button-hover-bg, color-mix(in oklch, var(--cngx-button-tone, currentColor) 8%, transparent) )}:scope.cngx-button[data-variant=ghost]:not([aria-disabled=true]):is(:active,.cngx-pressed){background:var( --cngx-close-button-pressed-bg, color-mix(in oklch, var(--cngx-button-tone, currentColor) var(--cngx-button-pressed-wash, 12%), transparent) )}.cngx-icon-button__glyph>:is(svg,img){inline-size:round(nearest,var(--cngx-close-button-icon-size, 1.25em),1px);block-size:round(nearest,var(--cngx-close-button-icon-size, 1.25em),1px);flex-shrink:0}.cngx-icon-button__glyph>:not(svg,img,.cngx-icon)>:is(svg,img){display:block;inline-size:round(nearest,var(--cngx-close-button-icon-size, 1.25em),1px);block-size:round(nearest,var(--cngx-close-button-icon-size, 1.25em),1px);flex-shrink:0}}}\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "component", type: CngxIconSvg, selector: "svg[cngxIconSvg]", inputs: ["cngxIconSvg"] }, { kind: "component", type: CngxButtonAdornment, selector: "cngx-button-adornment" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
859
+ }
860
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCloseButton, decorators: [{
861
+ type: Component,
862
+ args: [{ selector: 'button[cngxCloseButton]', standalone: true, exportAs: 'cngxCloseButton', imports: [NgComponentOutlet, CngxIconSvg, CngxButtonAdornment], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, hostDirectives: [
863
+ {
864
+ directive: CngxButtonBrain,
865
+ inputs: [
866
+ 'variant: cngxCloseButton',
867
+ 'tone',
868
+ 'size',
869
+ 'disabled',
870
+ 'disabledReason',
871
+ 'cngxDescribedBy',
872
+ 'type',
873
+ ],
874
+ },
875
+ ], providers: [
876
+ provideButtonHost('cngxCloseButton', {
877
+ defaultVariant: 'ghost',
878
+ fixed: { variant: 'ghost', size: 'sm', tone: 'neutral' },
879
+ iconOnly: true,
880
+ }),
881
+ ], host: { class: 'cngx-button cngx-icon-button cngx-close-button' }, template: `
882
+ <span class="cngx-button__label cngx-icon-button__glyph" aria-hidden="true">
883
+ <ng-content>
884
+ @if (customIcon) {
885
+ <ng-container *ngComponentOutlet="customIcon" />
886
+ } @else {
887
+ <svg class="cngx-close-button__icon" [cngxIconSvg]="closeIcon"></svg>
888
+ }
889
+ </ng-content>
890
+ </span>
891
+ <cngx-button-adornment />
892
+ `, styles: ["@layer cngx.tokens{@property --cngx-close-button-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-close-button-size{syntax: \"*\"; inherits: false;}@property --cngx-close-button-icon-size{syntax: \"*\"; inherits: true;}@property --cngx-close-button-radius{syntax: \"*\"; inherits: false;}@property --cngx-close-button-hover-bg{syntax: \"*\"; inherits: false;}@property --cngx-close-button-pressed-bg{syntax: \"*\"; inherits: false;}:where(.cngx-close-button){--cngx-close-button-color: var(--cngx-color-text-muted, oklch(.5 .01 250))}}@layer cngx.components{@scope(.cngx-close-button){:scope.cngx-button{--cngx-button-radius: var(--cngx-close-button-radius, var(--cngx-radius-sm, .25rem));inline-size:max(var(--cngx-close-button-size, var(--cngx-icon-button-size)),var(--cngx-target-min, 0px));block-size:max(var(--cngx-close-button-size, var(--cngx-icon-button-size)),var(--cngx-target-min, 0px))}:scope.cngx-button[data-variant=ghost][data-tone=neutral]:not([aria-disabled=true]){color:var(--cngx-close-button-color, currentColor)}:scope.cngx-button[data-variant=ghost][data-tone=neutral]:not([aria-disabled=true]):is(:hover,:focus-visible){color:var(--cngx-button-tone-text, currentColor)}:scope.cngx-button[data-variant=ghost]:not([aria-disabled=true]):hover{background:var( --cngx-close-button-hover-bg, color-mix(in oklch, var(--cngx-button-tone, currentColor) 8%, transparent) )}:scope.cngx-button[data-variant=ghost]:not([aria-disabled=true]):is(:active,.cngx-pressed){background:var( --cngx-close-button-pressed-bg, color-mix(in oklch, var(--cngx-button-tone, currentColor) var(--cngx-button-pressed-wash, 12%), transparent) )}.cngx-icon-button__glyph>:is(svg,img){inline-size:round(nearest,var(--cngx-close-button-icon-size, 1.25em),1px);block-size:round(nearest,var(--cngx-close-button-icon-size, 1.25em),1px);flex-shrink:0}.cngx-icon-button__glyph>:not(svg,img,.cngx-icon)>:is(svg,img){display:block;inline-size:round(nearest,var(--cngx-close-button-icon-size, 1.25em),1px);block-size:round(nearest,var(--cngx-close-button-icon-size, 1.25em),1px);flex-shrink:0}}}\n"] }]
893
+ }] });
894
+
895
+ /**
896
+ * Providers for a button host on `CngxActionStatusBrain`, next to {@link provideButtonHost}.
897
+ * `CNGX_HOST_INTERACTION_STATE` adds the `CNGX_ACTION_STATUS` announcement, so the runner's live
898
+ * region speaks what the host shows (without it the region stays silent).
899
+ * `CNGX_BUTTON_HOST_STATE` makes a bound `[externalState]` in flight refuse clicks and read busy.
900
+ *
901
+ * ```ts
902
+ * @Component({
903
+ * selector: 'button[appSaveButton]',
904
+ * hostDirectives: [
905
+ * CngxButtonBrain,
906
+ * { directive: CngxAsyncClick, inputs: ['cngxAsyncClick: action'] },
907
+ * { directive: CngxActionStatusBrain, inputs: ['succeededLabel', 'failedLabel'] },
908
+ * ],
909
+ * providers: [
910
+ * provideButtonHost('appSaveButton', { defaultVariant: 'solid' }),
911
+ * provideActionStatusHost(),
912
+ * ],
913
+ * template: '...',
914
+ * })
915
+ * class AppSaveButton {}
916
+ * ```
917
+ *
918
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/action-status-host.ts
919
+ * @since 0.3.0
920
+ * @relatedTo provideButtonHost, CngxButtonBrain, CngxActionStatusBrain, CNGX_ACTION_STATUS, CNGX_BUTTON_HOST_STATE, CngxActionButton
921
+ */
922
+ function provideActionStatusHost() {
923
+ return [
924
+ {
925
+ provide: CNGX_BUTTON_HOST_STATE,
926
+ useFactory: () => {
927
+ const status = inject(CNGX_ACTION_STATUS);
928
+ return { refusing: status.externalBusy, busy: status.externalBusy };
929
+ },
930
+ },
931
+ {
932
+ provide: CNGX_HOST_INTERACTION_STATE,
933
+ useFactory: () => ({
934
+ ...inject(CngxButtonBrain).interaction,
935
+ announcement: inject(CNGX_ACTION_STATUS).announcement,
936
+ }),
937
+ },
938
+ ];
939
+ }
940
+
941
+ /**
942
+ * Joins buttons, icon buttons, addons and separators into one framed `role="group"` row or
943
+ * column. Seams collapse to one border; a hovered or focused segment is lifted so its ring is
944
+ * never clipped. `variant` and `size` reach every button inside; `tone` is per button.
945
+ *
946
+ * A group with a group child is a toolbar: the sub-groups sit apart, the gap floored to
947
+ * `--cngx-target-gap` on a coarse pointer. Wrap a loose button next to sub-groups in its own
948
+ * group.
949
+ *
950
+ * Needs `aria-label` or `aria-labelledby`, else warns [`CNGX1072`](/error-codes/cngx1072.md).
951
+ * The geometry ships in the global `cngx.css` bundle, not on the directive.
952
+ *
953
+ * ```html
954
+ * <div cngxButtonGroup variant="outline" aria-label="History">
955
+ * <button cngxButton>Undo</button>
956
+ * <button cngxButton>Redo</button>
957
+ * </div>
958
+ * ```
959
+ *
960
+ * @wcag AA
961
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-group.directive.ts
962
+ * @since 0.3.0
963
+ * @relatedTo CngxButton, CngxIconButton, CngxButtonGroupAddon, CngxButtonGroupSeparator, CNGX_BUTTON_GROUP, CngxSplitButton, CngxIconMenuButton, CngxButtonToggleGroup
964
+ * <example-url>/#/common/button/group/basic</example-url>
965
+ * <example-url>/#/common/button/group/vertical</example-url>
966
+ * <example-url>/#/common/button/group/with-addon</example-url>
967
+ * <example-url>/#/common/button/group/icon-toolbar</example-url>
968
+ * <example-url>/#/common/menu-button/split-button/basic</example-url>
969
+ * @axis level molecule
970
+ */
971
+ class CngxButtonGroup {
972
+ parent = inject(CNGX_BUTTON_GROUP, { optional: true, skipSelf: true });
973
+ /** Emphasis for the buttons inside. Falls through to an outer group. */
974
+ variantInput = input(undefined, { ...(ngDevMode ? { debugName: "variantInput" } : /* istanbul ignore next */ {}), alias: 'variant' });
975
+ /** Size for the buttons and addons inside. Falls through to an outer group. */
976
+ sizeInput = input(undefined, { ...(ngDevMode ? { debugName: "sizeInput" } : /* istanbul ignore next */ {}), alias: 'size' });
977
+ /** `vertical` stacks the segments. */
978
+ orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
979
+ /** This group's input, else the outer group's. */
980
+ variant = computed(() => this.variantInput() ?? this.parent?.variant(), ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
981
+ /** This group's input, else the outer group's. */
982
+ size = computed(() => this.sizeInput() ?? this.parent?.size(), ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
983
+ constructor() {
984
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
985
+ const host = inject(ElementRef).nativeElement;
986
+ afterNextRender(() => {
987
+ const named = ['aria-label', 'aria-labelledby'].some((attr) => (host.getAttribute(attr) ?? '').trim() !== '');
988
+ if (named) {
989
+ return;
990
+ }
991
+ cngxDevWarn('CNGX1072', '[cngxButtonGroup] has no accessible name. Set aria-label or aria-labelledby on the host; a role="group" without a name gives assistive technology no context for the buttons inside.', host);
992
+ });
993
+ }
994
+ }
995
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive });
996
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxButtonGroup, isStandalone: true, selector: "[cngxButtonGroup]", inputs: { variantInput: { classPropertyName: "variantInput", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, sizeInput: { classPropertyName: "sizeInput", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "group" }, properties: { "attr.data-orientation": "orientation()", "attr.data-size": "size() ?? null" }, classAttribute: "cngx-button-group" }, providers: [{ provide: CNGX_BUTTON_GROUP, useExisting: CngxButtonGroup }], exportAs: ["cngxButtonGroup"], ngImport: i0 });
997
+ }
998
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonGroup, decorators: [{
999
+ type: Directive,
1000
+ args: [{
1001
+ selector: '[cngxButtonGroup]',
1002
+ standalone: true,
1003
+ exportAs: 'cngxButtonGroup',
1004
+ providers: [{ provide: CNGX_BUTTON_GROUP, useExisting: CngxButtonGroup }],
1005
+ host: {
1006
+ class: 'cngx-button-group',
1007
+ role: 'group',
1008
+ '[attr.data-orientation]': 'orientation()',
1009
+ '[attr.data-size]': 'size() ?? null',
1010
+ },
1011
+ }]
1012
+ }], ctorParameters: () => [], propDecorators: { variantInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], sizeInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }] } });
1013
+
1014
+ /**
1015
+ * A non-interactive segment in a `cngxButtonGroup` for an avatar, icon, count or short text. It
1016
+ * takes the row height of the buttons beside it and their padding and type tokens, so a theme
1017
+ * that re-sets them (the Material bridge) reaches it too. No role; its text is read in document
1018
+ * order.
1019
+ *
1020
+ * ```html
1021
+ * <div cngxButtonGroup variant="outline" aria-label="Assignee">
1022
+ * <span cngxButtonGroupAddon><cngx-avatar name="Ada Lovelace" size="sm" /></span>
1023
+ * <button cngxButton>Reassign</button>
1024
+ * </div>
1025
+ * ```
1026
+ *
1027
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-group-addon.directive.ts
1028
+ * @since 0.3.0
1029
+ * @relatedTo CngxButtonGroup, CngxButtonGroupSeparator, CngxButton
1030
+ * <example-url>/#/common/button/group/with-addon</example-url>
1031
+ */
1032
+ class CngxButtonGroupAddon {
1033
+ group = inject(CNGX_BUTTON_GROUP, { optional: true });
1034
+ config = injectButtonConfig();
1035
+ /** Resolved row size. */
1036
+ size = computed(() => resolveButtonSize(undefined, this.group, this.config), ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
1037
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonGroupAddon, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1038
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxButtonGroupAddon, isStandalone: true, selector: "[cngxButtonGroupAddon]", host: { properties: { "attr.data-size": "size()" }, classAttribute: "cngx-button-group__addon" }, ngImport: i0 });
1039
+ }
1040
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonGroupAddon, decorators: [{
1041
+ type: Directive,
1042
+ args: [{
1043
+ selector: '[cngxButtonGroupAddon]',
1044
+ standalone: true,
1045
+ host: {
1046
+ class: 'cngx-button-group__addon',
1047
+ '[attr.data-size]': 'size()',
1048
+ },
1049
+ }]
1050
+ }] });
1051
+
1052
+ /**
1053
+ * Divider between segments of a `cngxButtonGroup`, drawn as a border so it survives forced
1054
+ * colors, and follows the orientation. `aria-hidden="true"`: when the split carries meaning, use
1055
+ * two labelled groups.
1056
+ *
1057
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/button/button-group-separator.directive.ts
1058
+ * @since 0.3.0
1059
+ * @relatedTo CngxButtonGroup, CngxButtonGroupAddon
1060
+ * <example-url>/#/common/button/group/basic</example-url>
1061
+ */
1062
+ class CngxButtonGroupSeparator {
1063
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonGroupSeparator, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1064
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxButtonGroupSeparator, isStandalone: true, selector: "[cngxButtonGroupSeparator]", host: { attributes: { "aria-hidden": "true" }, classAttribute: "cngx-button-group__separator" }, ngImport: i0 });
1065
+ }
1066
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonGroupSeparator, decorators: [{
1067
+ type: Directive,
1068
+ args: [{
1069
+ selector: '[cngxButtonGroupSeparator]',
1070
+ standalone: true,
1071
+ host: { class: 'cngx-button-group__separator', 'aria-hidden': 'true' },
1072
+ }]
1073
+ }] });
1074
+
1075
+ /**
1076
+ * @module `@cngx/common/button`
1077
+ */
1078
+
1079
+ /**
1080
+ * Generated bundle index. Do not edit.
1081
+ */
1082
+
1083
+ export { CNGX_BUTTON_CLOSE_ICON, CNGX_BUTTON_CONFIG, CNGX_BUTTON_GROUP, CNGX_BUTTON_HOST, CNGX_BUTTON_HOST_STATE, CNGX_BUTTON_SPINNER, CNGX_BUTTON_STATE, CngxButton, CngxButtonAdornment, CngxButtonBrain, CngxButtonEnd, CngxButtonGroup, CngxButtonGroupAddon, CngxButtonGroupSeparator, CngxButtonStart, CngxCloseButton, CngxIconButton, injectButtonCloseIcon, injectButtonConfig, injectButtonSpinner, provideActionStatusHost, provideButtonCloseIcon, provideButtonConfig, provideButtonConfigAt, provideButtonHost, provideButtonSpinner, withButtonSize, withButtonTone, withButtonVariant };
1084
+ //# sourceMappingURL=cngx-common-button.mjs.map