@cngx/common 0.1.0-rc.2 → 0.1.0-rc.4
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/data/README.md +10 -3
- package/display/README.md +1 -0
- package/fesm2022/cngx-common-a11y.mjs +123 -3
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +8 -8
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +999 -54
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +320 -8
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +1603 -75
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +187 -3
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +63 -8
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/interactive/README.md +101 -0
- package/layout/README.md +39 -1
- package/package.json +1 -1
- package/theming/components/cngx-accordion.css +147 -0
- package/theming/components/cngx-badge.css +6 -0
- package/theming/components/cngx-bottom-sheet.css +8 -1
- package/theming/components/cngx-breadcrumb.css +108 -0
- package/theming/components/cngx-button-toggle.css +6 -0
- package/theming/components/cngx-data-grid.css +154 -0
- package/theming/components/cngx-dialog.css +4 -0
- package/theming/components/cngx-divider.css +4 -0
- package/theming/components/cngx-listbox.css +6 -0
- package/theming/components/cngx-menu.css +7 -0
- package/theming/components/cngx-slider.css +237 -0
- package/theming/components/cngx-tooltip.css +6 -0
- package/types/cngx-common-a11y.d.ts +67 -2
- package/types/cngx-common-data.d.ts +837 -23
- package/types/cngx-common-display.d.ts +189 -1
- package/types/cngx-common-interactive.d.ts +1014 -31
- package/types/cngx-common-layout.d.ts +88 -3
- package/types/cngx-common-popover.d.ts +25 -4
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, DestroyRef, input, signal, computed, Directive, TemplateRef, isDevMode, contentChild, output, ViewEncapsulation, ChangeDetectionStrategy, Component, Injectable, InjectionToken, effect, afterNextRender, model,
|
|
2
|
+
import { inject, ElementRef, DestroyRef, input, signal, computed, Directive, TemplateRef, isDevMode, contentChild, output, ViewEncapsulation, ChangeDetectionStrategy, Component, Injectable, InjectionToken, effect, afterNextRender, model, booleanAttribute, linkedSignal, contentChildren, Renderer2, untracked, makeEnvironmentProviders, SkipSelf, Optional, PLATFORM_ID, provideEnvironmentInitializer } from '@angular/core';
|
|
3
3
|
import { buildAsyncStateView, nextUid, CNGX_SELECTION_CONTROLLER_FACTORY, CNGX_STATEFUL, matchesKeyCombo, parseKeyCombo } from '@cngx/core/utils';
|
|
4
4
|
import { isObservable, firstValueFrom, timer, take, fromEvent, filter, switchMap, merge, tap, takeUntil, map } from 'rxjs';
|
|
5
5
|
import { DOCUMENT, NgTemplateOutlet, NgComponentOutlet, isPlatformBrowser } from '@angular/common';
|
|
6
|
+
import { decimalPlaces, arrayEqual, setEqual, flattenTree, isNodeVisible, collectDescendantValues } from '@cngx/utils';
|
|
6
7
|
import { CNGX_FORM_FIELD_HOST, CNGX_FORM_FIELD_CONTROL } from '@cngx/core/tokens';
|
|
7
8
|
import * as i1 from '@cngx/common/a11y';
|
|
8
9
|
import { CngxRovingTabindex, CngxRovingItem, CngxActiveDescendant, CNGX_AD_ITEM } from '@cngx/common/a11y';
|
|
9
10
|
import { CngxCheckboxIndicator, CngxRadioIndicator } from '@cngx/common/display';
|
|
10
|
-
import { flattenTree, isNodeVisible, collectDescendantValues } from '@cngx/utils';
|
|
11
11
|
import { takeUntilDestroyed, toObservable, outputFromObservable, outputToObservable } from '@angular/core/rxjs-interop';
|
|
12
12
|
import { Router, NavigationStart } from '@angular/router';
|
|
13
13
|
|
|
@@ -568,7 +568,7 @@ class CngxCopyBlock {
|
|
|
568
568
|
{{ cp.copied() ? srAnnouncement() : '' }}
|
|
569
569
|
</span>
|
|
570
570
|
</button>
|
|
571
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-copy-block-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-copy-block-btn-border{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-bg{syntax: \"<color>\"; inherits: false; initial-value: transparent;}@property --cngx-copy-block-btn-color{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-copy-block-btn-padding{syntax: \"*\"; inherits:
|
|
571
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-copy-block-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-copy-block-btn-border{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-bg{syntax: \"<color>\"; inherits: false; initial-value: transparent;}@property --cngx-copy-block-btn-color{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-copy-block-btn-padding{syntax: \"*\"; inherits: true; initial-value: 4px 8px;}@property --cngx-copy-block-btn-font-size{syntax: \"*\"; inherits: false; initial-value: .75rem;}@property --cngx-copy-block-btn-copied-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(.96 .025 145);}@property --cngx-copy-block-btn-copied-border{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .12 145);}@property --cngx-copy-block-btn-copied-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .12 145);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-copy-block-btn-copied-bg: oklch(.32 .06 145);--cngx-copy-block-btn-copied-color: oklch(.85 .13 145)}}[data-color-scheme=dark],.dark{--cngx-copy-block-btn-copied-bg: oklch(.32 .06 145);--cngx-copy-block-btn-copied-color: oklch(.85 .13 145)}[data-color-scheme=light],.light{--cngx-copy-block-btn-copied-bg: oklch(.96 .025 145);--cngx-copy-block-btn-copied-color: oklch(.5 .12 145)}}@layer cngx.components{@scope(.cngx-copy-block){:scope{--cngx-copy-block-gap: var(--cngx-space-sm);--cngx-copy-block-btn-padding: var(--cngx-space-xs) var(--cngx-space-sm);display:flex;align-items:flex-start;gap:var(--cngx-copy-block-gap, var(--cngx-space-sm, 8px))}.cngx-copy-block__content{flex:1;min-width:0;overflow:hidden}.cngx-copy-block__button{flex-shrink:0;cursor:pointer;border:1px solid var(--cngx-copy-block-btn-border, currentColor);background:var(--cngx-copy-block-btn-bg, transparent);color:var(--cngx-copy-block-btn-color, inherit);border-radius:var(--cngx-copy-block-btn-radius, var(--cngx-radius-sm, 4px));padding:var(--cngx-copy-block-btn-padding, 4px 8px);font-size:var(--cngx-copy-block-btn-font-size, var(--cngx-font-size-sm, .75rem));transition:background .15s,border-color .15s}.cngx-copy-block__button--copied{background:var(--cngx-copy-block-btn-copied-bg, oklch(.96 .025 145));border-color:var( --cngx-copy-block-btn-copied-border, var(--cngx-color-success, oklch(.5 .12 145)) );color:var( --cngx-copy-block-btn-copied-color, var(--cngx-color-success, oklch(.5 .12 145)) )}.cngx-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}}\n"], dependencies: [{ kind: "directive", type: CngxCopyText, selector: "[cngxCopyText]", inputs: ["cngxCopyText", "resetDelay"], outputs: ["didCopy", "copyFailed"], exportAs: ["cngxCopyText"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
572
572
|
}
|
|
573
573
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCopyBlock, decorators: [{
|
|
574
574
|
type: Component,
|
|
@@ -590,7 +590,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
590
590
|
{{ cp.copied() ? srAnnouncement() : '' }}
|
|
591
591
|
</span>
|
|
592
592
|
</button>
|
|
593
|
-
`, styles: ["@layer cngx.tokens{@property --cngx-copy-block-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-copy-block-btn-border{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-bg{syntax: \"<color>\"; inherits: false; initial-value: transparent;}@property --cngx-copy-block-btn-color{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-copy-block-btn-padding{syntax: \"*\"; inherits:
|
|
593
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-copy-block-gap{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-copy-block-btn-border{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-bg{syntax: \"<color>\"; inherits: false; initial-value: transparent;}@property --cngx-copy-block-btn-color{syntax: \"*\"; inherits: false; initial-value: currentColor;}@property --cngx-copy-block-btn-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-copy-block-btn-padding{syntax: \"*\"; inherits: true; initial-value: 4px 8px;}@property --cngx-copy-block-btn-font-size{syntax: \"*\"; inherits: false; initial-value: .75rem;}@property --cngx-copy-block-btn-copied-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(.96 .025 145);}@property --cngx-copy-block-btn-copied-border{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .12 145);}@property --cngx-copy-block-btn-copied-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.5 .12 145);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-copy-block-btn-copied-bg: oklch(.32 .06 145);--cngx-copy-block-btn-copied-color: oklch(.85 .13 145)}}[data-color-scheme=dark],.dark{--cngx-copy-block-btn-copied-bg: oklch(.32 .06 145);--cngx-copy-block-btn-copied-color: oklch(.85 .13 145)}[data-color-scheme=light],.light{--cngx-copy-block-btn-copied-bg: oklch(.96 .025 145);--cngx-copy-block-btn-copied-color: oklch(.5 .12 145)}}@layer cngx.components{@scope(.cngx-copy-block){:scope{--cngx-copy-block-gap: var(--cngx-space-sm);--cngx-copy-block-btn-padding: var(--cngx-space-xs) var(--cngx-space-sm);display:flex;align-items:flex-start;gap:var(--cngx-copy-block-gap, var(--cngx-space-sm, 8px))}.cngx-copy-block__content{flex:1;min-width:0;overflow:hidden}.cngx-copy-block__button{flex-shrink:0;cursor:pointer;border:1px solid var(--cngx-copy-block-btn-border, currentColor);background:var(--cngx-copy-block-btn-bg, transparent);color:var(--cngx-copy-block-btn-color, inherit);border-radius:var(--cngx-copy-block-btn-radius, var(--cngx-radius-sm, 4px));padding:var(--cngx-copy-block-btn-padding, 4px 8px);font-size:var(--cngx-copy-block-btn-font-size, var(--cngx-font-size-sm, .75rem));transition:background .15s,border-color .15s}.cngx-copy-block__button--copied{background:var(--cngx-copy-block-btn-copied-bg, oklch(.96 .025 145));border-color:var( --cngx-copy-block-btn-copied-border, var(--cngx-color-success, oklch(.5 .12 145)) );color:var( --cngx-copy-block-btn-copied-color, var(--cngx-color-success, oklch(.5 .12 145)) )}.cngx-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}}\n"] }]
|
|
594
594
|
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], buttonLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "buttonLabel", required: false }] }], copiedLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "copiedLabel", required: false }] }], srAnnouncement: [{ type: i0.Input, args: [{ isSignal: true, alias: "srAnnouncement", required: false }] }] } });
|
|
595
595
|
|
|
596
596
|
/**
|
|
@@ -1486,6 +1486,116 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1486
1486
|
}]
|
|
1487
1487
|
}], propDecorators: { expandedInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxExpandableOpen", required: false }] }], controls: [{ type: i0.Input, args: [{ isSignal: true, alias: "controls", required: false }] }], expandedChange: [{ type: i0.Output, args: ["expandedChange"] }] } });
|
|
1488
1488
|
|
|
1489
|
+
/**
|
|
1490
|
+
* Optional DI fallback for `CngxHoverIntent`'s `enterDelay` / `leaveDelay`
|
|
1491
|
+
* input defaults. Resolution is `bound input -> injected default -> literal`
|
|
1492
|
+
* (120 / 0). A hostDirective input default cannot be overridden by the host
|
|
1493
|
+
* that composes it, so this token is the layered extension point any
|
|
1494
|
+
* hover-to-reveal organism uses to set app-wide dwell defaults. `optional`, so
|
|
1495
|
+
* standalone `[cngxHoverIntent]` stays byte-identical when the token is absent.
|
|
1496
|
+
*
|
|
1497
|
+
* @category common/interactive
|
|
1498
|
+
* @relatedTo CngxHoverIntent
|
|
1499
|
+
* @since 0.1.0
|
|
1500
|
+
*/
|
|
1501
|
+
const CNGX_HOVER_INTENT_DEFAULTS = new InjectionToken('CNGX_HOVER_INTENT_DEFAULTS');
|
|
1502
|
+
/**
|
|
1503
|
+
* Debounced hover-intent primitive. Turns raw pointer enter/leave into a
|
|
1504
|
+
* boolean signal that flips `true` only after the pointer has rested on the
|
|
1505
|
+
* host for `enterDelay` ms of continuous hover, and back to `false` after
|
|
1506
|
+
* `leaveDelay` ms of continuous un-hover.
|
|
1507
|
+
*
|
|
1508
|
+
* A pointer that merely passes over the host never fires: the pending timer
|
|
1509
|
+
* is cancelled by the opposite event before it elapses. Use it for
|
|
1510
|
+
* hover-to-reveal panels, hover-to-prefetch triggers, or any affordance that
|
|
1511
|
+
* reads as nervous when it reacts to an instant `mouseenter`.
|
|
1512
|
+
*
|
|
1513
|
+
* The `active` signal is read-only - it is derived from pointer events and is
|
|
1514
|
+
* never consumer-writable, so it is exposed via `asReadonly()` plus an
|
|
1515
|
+
* `intentChange` output rather than a two-way `model()`. Pointer-only, no
|
|
1516
|
+
* keyboard surface: hover intent is a mouse concept and carries no ARIA.
|
|
1517
|
+
*
|
|
1518
|
+
* ### Hover to reveal
|
|
1519
|
+
* ```html
|
|
1520
|
+
* <div cngxHoverIntent #hi="cngxHoverIntent" [enterDelay]="150">
|
|
1521
|
+
* <span>Card</span>
|
|
1522
|
+
* @if (hi.active()) { <div class="detail">…</div> }
|
|
1523
|
+
* </div>
|
|
1524
|
+
* ```
|
|
1525
|
+
*
|
|
1526
|
+
* ### Bind the edge
|
|
1527
|
+
* ```html
|
|
1528
|
+
* <a cngxHoverIntent (intentChange)="$event && prefetch()">Link</a>
|
|
1529
|
+
* ```
|
|
1530
|
+
*
|
|
1531
|
+
* @category common/interactive
|
|
1532
|
+
* @docsKind primary
|
|
1533
|
+
* @wcag AA
|
|
1534
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/hover-intent/hover-intent.directive.ts
|
|
1535
|
+
* @since 0.1.0
|
|
1536
|
+
* @relatedTo CngxHoverable, CngxLongPress, CngxExpandable
|
|
1537
|
+
* <example-url>http://localhost:4200/#/common/interactive/hover-intent/hover-to-reveal</example-url>
|
|
1538
|
+
* <example-url>http://localhost:4200/#/common/interactive/hover-intent/hover-to-prefetch</example-url>
|
|
1539
|
+
*/
|
|
1540
|
+
class CngxHoverIntent {
|
|
1541
|
+
/**
|
|
1542
|
+
* Optional app-wide dwell defaults. Declared first so the input initialisers
|
|
1543
|
+
* below can source their fallback from it. Absent by default - standalone
|
|
1544
|
+
* `[cngxHoverIntent]` then keeps the 120 / 0 literals.
|
|
1545
|
+
*/
|
|
1546
|
+
defaults = inject(CNGX_HOVER_INTENT_DEFAULTS, { optional: true });
|
|
1547
|
+
/** ms of continuous hover before `active` settles to `true`. */
|
|
1548
|
+
enterDelay = input(this.defaults?.enterDelay ?? 120, ...(ngDevMode ? [{ debugName: "enterDelay" }] : /* istanbul ignore next */ []));
|
|
1549
|
+
/** ms of continuous un-hover before `active` settles back to `false`. */
|
|
1550
|
+
leaveDelay = input(this.defaults?.leaveDelay ?? 0, ...(ngDevMode ? [{ debugName: "leaveDelay" }] : /* istanbul ignore next */ []));
|
|
1551
|
+
intentState = signal(false, ...(ngDevMode ? [{ debugName: "intentState" }] : /* istanbul ignore next */ []));
|
|
1552
|
+
/** Debounced hover-intent state. `true` only after `enterDelay` ms of continuous hover. */
|
|
1553
|
+
active = this.intentState.asReadonly();
|
|
1554
|
+
/** Emitted on every debounced edge: `true` on settle-in, `false` on settle-out. */
|
|
1555
|
+
intentChange = output();
|
|
1556
|
+
pendingTimer;
|
|
1557
|
+
constructor() {
|
|
1558
|
+
inject(DestroyRef).onDestroy(() => this.clearPending());
|
|
1559
|
+
}
|
|
1560
|
+
handleEnter() {
|
|
1561
|
+
this.schedule(true, this.enterDelay());
|
|
1562
|
+
}
|
|
1563
|
+
handleLeave() {
|
|
1564
|
+
this.schedule(false, this.leaveDelay());
|
|
1565
|
+
}
|
|
1566
|
+
schedule(target, delay) {
|
|
1567
|
+
this.clearPending();
|
|
1568
|
+
this.pendingTimer = setTimeout(() => {
|
|
1569
|
+
this.pendingTimer = undefined;
|
|
1570
|
+
if (this.intentState() === target) {
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
this.intentState.set(target);
|
|
1574
|
+
this.intentChange.emit(target);
|
|
1575
|
+
}, delay);
|
|
1576
|
+
}
|
|
1577
|
+
clearPending() {
|
|
1578
|
+
if (this.pendingTimer !== undefined) {
|
|
1579
|
+
clearTimeout(this.pendingTimer);
|
|
1580
|
+
this.pendingTimer = undefined;
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxHoverIntent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1584
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxHoverIntent, isStandalone: true, selector: "[cngxHoverIntent]", inputs: { enterDelay: { classPropertyName: "enterDelay", publicName: "enterDelay", isSignal: true, isRequired: false, transformFunction: null }, leaveDelay: { classPropertyName: "leaveDelay", publicName: "leaveDelay", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { intentChange: "intentChange" }, host: { listeners: { "pointerenter": "handleEnter()", "pointerleave": "handleLeave()" } }, exportAs: ["cngxHoverIntent"], ngImport: i0 });
|
|
1585
|
+
}
|
|
1586
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxHoverIntent, decorators: [{
|
|
1587
|
+
type: Directive,
|
|
1588
|
+
args: [{
|
|
1589
|
+
selector: '[cngxHoverIntent]',
|
|
1590
|
+
exportAs: 'cngxHoverIntent',
|
|
1591
|
+
standalone: true,
|
|
1592
|
+
host: {
|
|
1593
|
+
'(pointerenter)': 'handleEnter()',
|
|
1594
|
+
'(pointerleave)': 'handleLeave()',
|
|
1595
|
+
},
|
|
1596
|
+
}]
|
|
1597
|
+
}], ctorParameters: () => [], propDecorators: { enterDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "enterDelay", required: false }] }], leaveDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "leaveDelay", required: false }] }], intentChange: [{ type: i0.Output, args: ["intentChange"] }] } });
|
|
1598
|
+
|
|
1489
1599
|
/**
|
|
1490
1600
|
* DI token every cngx interactive atom registers via `useExisting:
|
|
1491
1601
|
* <self>` so its host element doubles as a value-shape contract for
|
|
@@ -1505,6 +1615,1451 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1505
1615
|
*/
|
|
1506
1616
|
const CNGX_CONTROL_VALUE = new InjectionToken('CngxControlValue');
|
|
1507
1617
|
|
|
1618
|
+
function snapToStep(raw, origin, step) {
|
|
1619
|
+
if (step <= 0 || !Number.isFinite(step)) {
|
|
1620
|
+
return raw;
|
|
1621
|
+
}
|
|
1622
|
+
const steps = Math.round((raw - origin) / step);
|
|
1623
|
+
const snapped = origin + steps * step;
|
|
1624
|
+
// Float-drift correction: 0.1 * 3 = 0.30000000000000004 otherwise leaks
|
|
1625
|
+
// into aria-valuenow. Round to the precision the step itself carries.
|
|
1626
|
+
const decimals = Math.max(decimalPlaces(step), decimalPlaces(origin));
|
|
1627
|
+
return Number(snapped.toFixed(decimals));
|
|
1628
|
+
}
|
|
1629
|
+
function clamp(value, lo, hi) {
|
|
1630
|
+
if (hi < lo) {
|
|
1631
|
+
return lo;
|
|
1632
|
+
}
|
|
1633
|
+
return Math.min(hi, Math.max(lo, value));
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Pure factory for a slider's value derivation - the brain shared by
|
|
1637
|
+
* {@link CngxSlider} and each {@link CngxSliderThumb} of a range slider. It
|
|
1638
|
+
* owns no DI and no DOM: hand it the source signals, get back the clamped
|
|
1639
|
+
* value, the track fraction, the `aria-valuetext` string, and the four
|
|
1640
|
+
* mutation helpers the keyboard / pointer handlers call. Snapping and
|
|
1641
|
+
* bound-clamping live in {@link CngxSliderCore.setValue}, so every write
|
|
1642
|
+
* path stays valid without an effect syncing state (Pillar 1).
|
|
1643
|
+
*
|
|
1644
|
+
* @category common/interactive/slider
|
|
1645
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/slider-core.ts
|
|
1646
|
+
* @since 0.1.0
|
|
1647
|
+
* @relatedTo CngxSlider, CngxRangeSlider, CngxSliderThumb
|
|
1648
|
+
*/
|
|
1649
|
+
function createSliderCore(options) {
|
|
1650
|
+
const { value, min, max, step } = options;
|
|
1651
|
+
const boundedMin = options.boundedMin ?? min;
|
|
1652
|
+
const boundedMax = options.boundedMax ?? max;
|
|
1653
|
+
const clampedValue = computed(() => clamp(snapToStep(value(), min(), step()), boundedMin(), boundedMax()), ...(ngDevMode ? [{ debugName: "clampedValue" }] : /* istanbul ignore next */ []));
|
|
1654
|
+
const fraction = computed(() => {
|
|
1655
|
+
const lo = min();
|
|
1656
|
+
const span = max() - lo;
|
|
1657
|
+
if (span <= 0) {
|
|
1658
|
+
return 0;
|
|
1659
|
+
}
|
|
1660
|
+
return clamp((clampedValue() - lo) / span, 0, 1);
|
|
1661
|
+
}, ...(ngDevMode ? [{ debugName: "fraction" }] : /* istanbul ignore next */ []));
|
|
1662
|
+
const percent = computed(() => fraction() * 100, ...(ngDevMode ? [{ debugName: "percent" }] : /* istanbul ignore next */ []));
|
|
1663
|
+
const ariaValueText = computed(() => {
|
|
1664
|
+
const current = clampedValue();
|
|
1665
|
+
const format = options.valueText;
|
|
1666
|
+
return format ? format(current) : String(current);
|
|
1667
|
+
}, ...(ngDevMode ? [{ debugName: "ariaValueText" }] : /* istanbul ignore next */ []));
|
|
1668
|
+
const atMin = computed(() => clampedValue() <= boundedMin(), ...(ngDevMode ? [{ debugName: "atMin" }] : /* istanbul ignore next */ []));
|
|
1669
|
+
const atMax = computed(() => clampedValue() >= boundedMax(), ...(ngDevMode ? [{ debugName: "atMax" }] : /* istanbul ignore next */ []));
|
|
1670
|
+
const setValue = (next) => {
|
|
1671
|
+
if (!Number.isFinite(next)) {
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
const resolved = clamp(snapToStep(next, min(), step()), boundedMin(), boundedMax());
|
|
1675
|
+
if (resolved !== value()) {
|
|
1676
|
+
value.set(resolved);
|
|
1677
|
+
}
|
|
1678
|
+
};
|
|
1679
|
+
return {
|
|
1680
|
+
value,
|
|
1681
|
+
clampedValue,
|
|
1682
|
+
fraction,
|
|
1683
|
+
percent,
|
|
1684
|
+
ariaValueText,
|
|
1685
|
+
atMin,
|
|
1686
|
+
atMax,
|
|
1687
|
+
setValue,
|
|
1688
|
+
setFromFraction: (f) => setValue(min() + clamp(f, 0, 1) * (max() - min())),
|
|
1689
|
+
stepBy: (stepCount) => setValue(clampedValue() + stepCount * (step() > 0 ? step() : 1)),
|
|
1690
|
+
stepToMin: () => setValue(boundedMin()),
|
|
1691
|
+
stepToMax: () => setValue(boundedMax()),
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* Maps a pointer position to a `0..1` track fraction against `el`'s geometry.
|
|
1697
|
+
* Vertical sliders measure bottom-up (fraction 0 at the lower edge) to match the
|
|
1698
|
+
* skin's bottom-anchored fill. Shared by the single slider and the range host so
|
|
1699
|
+
* the geometry math lives in exactly one place.
|
|
1700
|
+
*
|
|
1701
|
+
* @category common/interactive/slider
|
|
1702
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/slider-interaction.ts
|
|
1703
|
+
* @since 0.1.0
|
|
1704
|
+
*/
|
|
1705
|
+
function pointerFraction(el, orientation, clientX, clientY) {
|
|
1706
|
+
const rect = el.getBoundingClientRect();
|
|
1707
|
+
const fraction = orientation === 'vertical'
|
|
1708
|
+
? rect.height > 0
|
|
1709
|
+
? (rect.bottom - clientY) / rect.height
|
|
1710
|
+
: 0
|
|
1711
|
+
: rect.width > 0
|
|
1712
|
+
? (clientX - rect.left) / rect.width
|
|
1713
|
+
: 0;
|
|
1714
|
+
return Math.min(1, Math.max(0, fraction));
|
|
1715
|
+
}
|
|
1716
|
+
/**
|
|
1717
|
+
* Pure factory for a slider's keyboard + pointer-drag behaviour - the shared
|
|
1718
|
+
* interaction brain for both {@link CngxSlider} (single) and each
|
|
1719
|
+
* {@link CngxSliderThumb} (range). Arrow / Page / Home / End map onto the core's
|
|
1720
|
+
* step helpers; pointer-down captures the pointer and drags via the supplied
|
|
1721
|
+
* `fractionFromPointer`. Keeping this in one factory means the track and the
|
|
1722
|
+
* thumb cannot drift apart.
|
|
1723
|
+
*
|
|
1724
|
+
* @category common/interactive/slider
|
|
1725
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/slider-interaction.ts
|
|
1726
|
+
* @since 0.1.0
|
|
1727
|
+
* @relatedTo createSliderCore, CngxSlider, CngxSliderThumb
|
|
1728
|
+
*/
|
|
1729
|
+
function createSliderInteraction(options) {
|
|
1730
|
+
const { core, el } = options;
|
|
1731
|
+
let dragging = false;
|
|
1732
|
+
const updateFromPointer = (event) => {
|
|
1733
|
+
core.setFromFraction(options.fractionFromPointer(event.clientX, event.clientY));
|
|
1734
|
+
};
|
|
1735
|
+
return {
|
|
1736
|
+
handleKeydown(event) {
|
|
1737
|
+
if (options.disabled()) {
|
|
1738
|
+
return;
|
|
1739
|
+
}
|
|
1740
|
+
const big = options.pageStep();
|
|
1741
|
+
switch (event.key) {
|
|
1742
|
+
case 'ArrowRight':
|
|
1743
|
+
case 'ArrowUp':
|
|
1744
|
+
core.stepBy(1);
|
|
1745
|
+
break;
|
|
1746
|
+
case 'ArrowLeft':
|
|
1747
|
+
case 'ArrowDown':
|
|
1748
|
+
core.stepBy(-1);
|
|
1749
|
+
break;
|
|
1750
|
+
case 'PageUp':
|
|
1751
|
+
core.setValue(core.clampedValue() + big);
|
|
1752
|
+
break;
|
|
1753
|
+
case 'PageDown':
|
|
1754
|
+
core.setValue(core.clampedValue() - big);
|
|
1755
|
+
break;
|
|
1756
|
+
case 'Home':
|
|
1757
|
+
core.stepToMin();
|
|
1758
|
+
break;
|
|
1759
|
+
case 'End':
|
|
1760
|
+
core.stepToMax();
|
|
1761
|
+
break;
|
|
1762
|
+
default:
|
|
1763
|
+
return;
|
|
1764
|
+
}
|
|
1765
|
+
event.preventDefault();
|
|
1766
|
+
},
|
|
1767
|
+
handlePointerDown(event) {
|
|
1768
|
+
if (options.disabled()) {
|
|
1769
|
+
return;
|
|
1770
|
+
}
|
|
1771
|
+
try {
|
|
1772
|
+
el.setPointerCapture(event.pointerId);
|
|
1773
|
+
}
|
|
1774
|
+
catch {
|
|
1775
|
+
// setPointerCapture throws on an invalid pointerId (synthetic events in
|
|
1776
|
+
// some test envs) - the drag still works without capture.
|
|
1777
|
+
}
|
|
1778
|
+
dragging = true;
|
|
1779
|
+
el.focus();
|
|
1780
|
+
updateFromPointer(event);
|
|
1781
|
+
event.preventDefault();
|
|
1782
|
+
},
|
|
1783
|
+
handlePointerMove(event) {
|
|
1784
|
+
if (!dragging) {
|
|
1785
|
+
return;
|
|
1786
|
+
}
|
|
1787
|
+
updateFromPointer(event);
|
|
1788
|
+
},
|
|
1789
|
+
handlePointerUp(event) {
|
|
1790
|
+
if (!dragging) {
|
|
1791
|
+
return;
|
|
1792
|
+
}
|
|
1793
|
+
dragging = false;
|
|
1794
|
+
try {
|
|
1795
|
+
el.releasePointerCapture(event.pointerId);
|
|
1796
|
+
}
|
|
1797
|
+
catch {
|
|
1798
|
+
// Already released by the browser (e.g. on pointercancel) - ignore.
|
|
1799
|
+
}
|
|
1800
|
+
},
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* Headless single-thumb slider brain. Put `cngxSliderTrack` on your own track
|
|
1806
|
+
* element and the directive turns it into an APG-conformant `role="slider"`:
|
|
1807
|
+
* full keyboard (Arrow / Page / Home / End), pointer-drag with capture, and the
|
|
1808
|
+
* whole ARIA value surface (`aria-valuemin/max/now/valuetext/orientation`)
|
|
1809
|
+
* computed from `value`/`min`/`max`/`step`. The value is a `model<number>()`,
|
|
1810
|
+
* so Angular Signal Forms binds it two-way via `[control]` with no forms import.
|
|
1811
|
+
*
|
|
1812
|
+
* Most consumers want the finished {@link CngxSlider} component (`<cngx-slider>`)
|
|
1813
|
+
* which renders the track / fill / thumb for you and uses this directive as its
|
|
1814
|
+
* brain. Reach for `cngxSliderTrack` only when you want to own the skin markup.
|
|
1815
|
+
*
|
|
1816
|
+
* Positioning is left to the skin: the directive publishes the thumb position
|
|
1817
|
+
* as the inherited custom property `--cngx-slider-fraction` (0..1), which the
|
|
1818
|
+
* track / fill / thumb read. The default look ships as Track-B CSS in
|
|
1819
|
+
* `@cngx/themes/cngx.css`.
|
|
1820
|
+
*
|
|
1821
|
+
* ```html
|
|
1822
|
+
* <label id="vol-label">Volume</label>
|
|
1823
|
+
* <div cngxSliderTrack aria-labelledby="vol-label" [(value)]="volume" [min]="0" [max]="11">
|
|
1824
|
+
* <span class="cngx-slider__track"><span class="cngx-slider__fill"></span></span>
|
|
1825
|
+
* <span class="cngx-slider__thumb"></span>
|
|
1826
|
+
* </div>
|
|
1827
|
+
* ```
|
|
1828
|
+
*
|
|
1829
|
+
* Reach for {@link CngxRangeSliderTrack} when you need two thumbs (a min/max range).
|
|
1830
|
+
*
|
|
1831
|
+
* @category common/interactive/slider
|
|
1832
|
+
* @wcag AA
|
|
1833
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/slider.directive.ts
|
|
1834
|
+
* @since 0.1.0
|
|
1835
|
+
* @relatedTo CngxSlider, CngxRangeSliderTrack, CngxSliderThumb, createSliderCore
|
|
1836
|
+
*/
|
|
1837
|
+
class CngxSliderTrack {
|
|
1838
|
+
/** Two-way value. The only state the keyboard / pointer handlers write. */
|
|
1839
|
+
value = model(0, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
1840
|
+
/** Track lower bound (`aria-valuemin`). */
|
|
1841
|
+
min = input(0, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
|
|
1842
|
+
/** Track upper bound (`aria-valuemax`). */
|
|
1843
|
+
max = input(100, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
1844
|
+
/** Step granularity. `<= 0` makes the slider continuous. */
|
|
1845
|
+
step = input(1, ...(ngDevMode ? [{ debugName: "step" }] : /* istanbul ignore next */ []));
|
|
1846
|
+
/**
|
|
1847
|
+
* Page-key jump size (absolute, not a step multiple). Defaults to the
|
|
1848
|
+
* larger of one step and a tenth of the range.
|
|
1849
|
+
*/
|
|
1850
|
+
largeStep = input(undefined, ...(ngDevMode ? [{ debugName: "largeStep" }] : /* istanbul ignore next */ []));
|
|
1851
|
+
/** Whether the slider is disabled (blocks keyboard and pointer, `tabindex=-1`). */
|
|
1852
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
1853
|
+
/** Track axis. Drives `aria-orientation` and the pointer-to-fraction math. */
|
|
1854
|
+
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
1855
|
+
/** Optional `aria-valuetext` formatter (currency, dates, named stops). */
|
|
1856
|
+
valueText = input(undefined, ...(ngDevMode ? [{ debugName: "valueText" }] : /* istanbul ignore next */ []));
|
|
1857
|
+
el = inject((ElementRef)).nativeElement;
|
|
1858
|
+
/** Shared value/step/aria derivation. */
|
|
1859
|
+
core = createSliderCore({
|
|
1860
|
+
value: this.value,
|
|
1861
|
+
min: this.min,
|
|
1862
|
+
max: this.max,
|
|
1863
|
+
step: this.step,
|
|
1864
|
+
valueText: (v) => {
|
|
1865
|
+
const format = this.valueText();
|
|
1866
|
+
return format ? format(v) : String(v);
|
|
1867
|
+
},
|
|
1868
|
+
});
|
|
1869
|
+
/** Thumb position along the track in `[0, 1]`. For a skin to read. */
|
|
1870
|
+
fraction = this.core.fraction;
|
|
1871
|
+
/** Snapped + clamped value (`aria-valuenow`). For a skin to read. */
|
|
1872
|
+
currentValue = this.core.clampedValue;
|
|
1873
|
+
/** Formatted display string (`aria-valuetext`). For a visible value label. */
|
|
1874
|
+
displayValue = this.core.ariaValueText;
|
|
1875
|
+
pageStep = computed(() => {
|
|
1876
|
+
const explicit = this.largeStep();
|
|
1877
|
+
if (explicit && explicit > 0) {
|
|
1878
|
+
return explicit;
|
|
1879
|
+
}
|
|
1880
|
+
const grid = this.step() > 0 ? this.step() : 1;
|
|
1881
|
+
return Math.max(grid, (this.max() - this.min()) / 10);
|
|
1882
|
+
}, ...(ngDevMode ? [{ debugName: "pageStep" }] : /* istanbul ignore next */ []));
|
|
1883
|
+
/** Shared keyboard + pointer-drag handlers (same factory the range thumb uses). */
|
|
1884
|
+
interaction = createSliderInteraction({
|
|
1885
|
+
core: this.core,
|
|
1886
|
+
el: this.el,
|
|
1887
|
+
disabled: () => this.disabled(),
|
|
1888
|
+
pageStep: () => this.pageStep(),
|
|
1889
|
+
fractionFromPointer: (x, y) => pointerFraction(this.el, this.orientation(), x, y),
|
|
1890
|
+
});
|
|
1891
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSliderTrack, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1892
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxSliderTrack, isStandalone: true, selector: "[cngxSliderTrack]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, largeStep: { classPropertyName: "largeStep", publicName: "largeStep", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, valueText: { classPropertyName: "valueText", publicName: "valueText", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { attributes: { "role": "slider" }, listeners: { "keydown": "interaction.handleKeydown($event)", "pointerdown": "interaction.handlePointerDown($event)", "pointermove": "interaction.handlePointerMove($event)", "pointerup": "interaction.handlePointerUp($event)", "pointercancel": "interaction.handlePointerUp($event)" }, properties: { "attr.aria-valuemin": "min()", "attr.aria-valuemax": "max()", "attr.aria-valuenow": "core.clampedValue()", "attr.aria-valuetext": "core.ariaValueText()", "attr.aria-orientation": "orientation()", "attr.aria-disabled": "disabled() || null", "attr.tabindex": "disabled() ? -1 : 0", "style.touch-action": "'none'", "style.--cngx-slider-fraction": "core.fraction()" } }, exportAs: ["cngxSliderTrack"], ngImport: i0 });
|
|
1893
|
+
}
|
|
1894
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSliderTrack, decorators: [{
|
|
1895
|
+
type: Directive,
|
|
1896
|
+
args: [{
|
|
1897
|
+
selector: '[cngxSliderTrack]',
|
|
1898
|
+
exportAs: 'cngxSliderTrack',
|
|
1899
|
+
standalone: true,
|
|
1900
|
+
host: {
|
|
1901
|
+
role: 'slider',
|
|
1902
|
+
'[attr.aria-valuemin]': 'min()',
|
|
1903
|
+
'[attr.aria-valuemax]': 'max()',
|
|
1904
|
+
'[attr.aria-valuenow]': 'core.clampedValue()',
|
|
1905
|
+
'[attr.aria-valuetext]': 'core.ariaValueText()',
|
|
1906
|
+
'[attr.aria-orientation]': 'orientation()',
|
|
1907
|
+
'[attr.aria-disabled]': 'disabled() || null',
|
|
1908
|
+
'[attr.tabindex]': 'disabled() ? -1 : 0',
|
|
1909
|
+
'[style.touch-action]': "'none'",
|
|
1910
|
+
'[style.--cngx-slider-fraction]': 'core.fraction()',
|
|
1911
|
+
'(keydown)': 'interaction.handleKeydown($event)',
|
|
1912
|
+
'(pointerdown)': 'interaction.handlePointerDown($event)',
|
|
1913
|
+
'(pointermove)': 'interaction.handlePointerMove($event)',
|
|
1914
|
+
'(pointerup)': 'interaction.handlePointerUp($event)',
|
|
1915
|
+
'(pointercancel)': 'interaction.handlePointerUp($event)',
|
|
1916
|
+
},
|
|
1917
|
+
}]
|
|
1918
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], largeStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "largeStep", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], valueText: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueText", required: false }] }] } });
|
|
1919
|
+
|
|
1920
|
+
/**
|
|
1921
|
+
* Tick stops from `min` to `max` stepping by `step`, for rendering tick marks +
|
|
1922
|
+
* labels. Returns `[]` when the step grid is invalid or denser than `maxCount`
|
|
1923
|
+
* (a guard against pathological DOM, e.g. step 1 over a 0..10000 range).
|
|
1924
|
+
*
|
|
1925
|
+
* @category common/interactive/slider
|
|
1926
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/slider-ticks.ts
|
|
1927
|
+
* @since 0.1.0
|
|
1928
|
+
*/
|
|
1929
|
+
/**
|
|
1930
|
+
* Derives a slider's tick marks + labels from its bounds, shared by
|
|
1931
|
+
* {@link CngxSlider} and {@link CngxRangeSlider} so the math lives once. `marks`
|
|
1932
|
+
* gates the repeating-gradient interval; `labels` gates the numeric stops; both
|
|
1933
|
+
* are independent. The values signal is `arrayEqual`-guarded.
|
|
1934
|
+
*
|
|
1935
|
+
* @category common/interactive/slider
|
|
1936
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/slider-ticks.ts
|
|
1937
|
+
* @since 0.1.0
|
|
1938
|
+
*/
|
|
1939
|
+
function createSliderTicks(options) {
|
|
1940
|
+
const { min, max, step, marks, labels } = options;
|
|
1941
|
+
const interval = computed(() => {
|
|
1942
|
+
if (!marks()) {
|
|
1943
|
+
return null;
|
|
1944
|
+
}
|
|
1945
|
+
const span = max() - min();
|
|
1946
|
+
if (span <= 0 || step() <= 0) {
|
|
1947
|
+
return null;
|
|
1948
|
+
}
|
|
1949
|
+
return `${(step() / span) * 100}%`;
|
|
1950
|
+
}, ...(ngDevMode ? [{ debugName: "interval" }] : /* istanbul ignore next */ []));
|
|
1951
|
+
const values = computed(() => (labels() ? sliderTickValues(min(), max(), step()) : []), { ...(ngDevMode ? { debugName: "values" } : /* istanbul ignore next */ {}), equal: arrayEqual });
|
|
1952
|
+
return {
|
|
1953
|
+
interval,
|
|
1954
|
+
values,
|
|
1955
|
+
fractionOf: (value) => {
|
|
1956
|
+
const span = max() - min();
|
|
1957
|
+
return span > 0 ? (value - min()) / span : 0;
|
|
1958
|
+
},
|
|
1959
|
+
};
|
|
1960
|
+
}
|
|
1961
|
+
function sliderTickValues(min, max, step, maxCount = 21) {
|
|
1962
|
+
const span = max - min;
|
|
1963
|
+
if (step <= 0 || span <= 0) {
|
|
1964
|
+
return [];
|
|
1965
|
+
}
|
|
1966
|
+
const count = Math.floor(span / step);
|
|
1967
|
+
if (count + 1 > maxCount) {
|
|
1968
|
+
return [];
|
|
1969
|
+
}
|
|
1970
|
+
const decimals = decimalPlaces(step);
|
|
1971
|
+
const stops = [];
|
|
1972
|
+
for (let i = 0; i <= count; i++) {
|
|
1973
|
+
stops.push(Number((min + i * step).toFixed(decimals)));
|
|
1974
|
+
}
|
|
1975
|
+
return stops;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* Finished single-thumb slider. The 90% API: drop it in, bind `[(value)]`, done -
|
|
1980
|
+
* it renders the track, fill, and thumb for you and wires the full APG keyboard
|
|
1981
|
+
* and pointer-drag through its {@link CngxSliderTrack} brain (applied as a host
|
|
1982
|
+
* directive). The value is a `model<number>()`, so it binds two-way in Angular
|
|
1983
|
+
* Signal Forms via `[control]`; the `cngx-form-field` integration lives in
|
|
1984
|
+
* `@cngx/forms` ({@link CngxSliderFieldBridge}).
|
|
1985
|
+
*
|
|
1986
|
+
* Value display: `showValue` floats the formatted value permanently above the
|
|
1987
|
+
* thumb; `showValueBubble` shows it as a bubble only while the slider is focused
|
|
1988
|
+
* or dragged (Material-style). `showTicks` paints a step mark; `showTickLabels`
|
|
1989
|
+
* adds numeric labels (formatted through `valueText`); `thumbGlyph` projects your
|
|
1990
|
+
* own handle content; `orientation="vertical"` rotates the skin. Reach for the
|
|
1991
|
+
* headless {@link CngxSliderTrack} directive only when you need to own the skin;
|
|
1992
|
+
* use {@link CngxRangeSlider} for a two-thumb range.
|
|
1993
|
+
*
|
|
1994
|
+
* ```html
|
|
1995
|
+
* <label id="vol">Volume</label>
|
|
1996
|
+
* <cngx-slider aria-labelledby="vol" [(value)]="volume" [min]="0" [max]="100" [step]="5" showValueBubble />
|
|
1997
|
+
* ```
|
|
1998
|
+
*
|
|
1999
|
+
* @category common/interactive/slider
|
|
2000
|
+
* @docsKind primary
|
|
2001
|
+
* @wcag AA
|
|
2002
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/slider.component.ts
|
|
2003
|
+
* @since 0.1.0
|
|
2004
|
+
* @relatedTo CngxSliderTrack, CngxRangeSlider, CngxSliderFieldBridge
|
|
2005
|
+
*/
|
|
2006
|
+
class CngxSlider {
|
|
2007
|
+
/** Float the formatted current value permanently above the thumb (visual only). */
|
|
2008
|
+
showValue = input(false, { ...(ngDevMode ? { debugName: "showValue" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2009
|
+
/** Show the formatted value as a bubble only while focused / dragged (visual only). */
|
|
2010
|
+
showValueBubble = input(false, { ...(ngDevMode ? { debugName: "showValueBubble" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2011
|
+
/** Paint a tick mark every `step` along the track. */
|
|
2012
|
+
showTicks = input(false, { ...(ngDevMode ? { debugName: "showTicks" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2013
|
+
/** Render a numeric label at every step stop (independent of `showTicks`). */
|
|
2014
|
+
showTickLabels = input(false, { ...(ngDevMode ? { debugName: "showTickLabels" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2015
|
+
/** Optional content projected into the thumb (an icon, a dot, a custom handle). */
|
|
2016
|
+
thumbGlyph = input(null, ...(ngDevMode ? [{ debugName: "thumbGlyph" }] : /* istanbul ignore next */ []));
|
|
2017
|
+
/** The brain host directive - exposes the derived value/fraction the skin reads. */
|
|
2018
|
+
brain = inject(CngxSliderTrack);
|
|
2019
|
+
/** Tick marks + labels derivation (shared factory). */
|
|
2020
|
+
ticks = createSliderTicks({
|
|
2021
|
+
min: this.brain.min,
|
|
2022
|
+
max: this.brain.max,
|
|
2023
|
+
step: this.brain.step,
|
|
2024
|
+
marks: this.showTicks,
|
|
2025
|
+
labels: this.showTickLabels,
|
|
2026
|
+
});
|
|
2027
|
+
/** Format a value through the bound `valueText` (so tick labels match the thumb). */
|
|
2028
|
+
format(value) {
|
|
2029
|
+
const formatter = this.brain.valueText();
|
|
2030
|
+
return formatter ? formatter(value) : String(value);
|
|
2031
|
+
}
|
|
2032
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSlider, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2033
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxSlider, isStandalone: true, selector: "cngx-slider", inputs: { showValue: { classPropertyName: "showValue", publicName: "showValue", isSignal: true, isRequired: false, transformFunction: null }, showValueBubble: { classPropertyName: "showValueBubble", publicName: "showValueBubble", isSignal: true, isRequired: false, transformFunction: null }, showTicks: { classPropertyName: "showTicks", publicName: "showTicks", isSignal: true, isRequired: false, transformFunction: null }, showTickLabels: { classPropertyName: "showTickLabels", publicName: "showTickLabels", isSignal: true, isRequired: false, transformFunction: null }, thumbGlyph: { classPropertyName: "thumbGlyph", publicName: "thumbGlyph", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-slider--ticks": "showTicks()", "class.cngx-slider--bubble": "showValueBubble()", "style.--cngx-slider-tick-interval": "ticks.interval()" }, classAttribute: "cngx-slider" }, exportAs: ["cngxSlider"], hostDirectives: [{ directive: CngxSliderTrack, inputs: ["value", "value", "min", "min", "max", "max", "step", "step", "largeStep", "largeStep", "disabled", "disabled", "orientation", "orientation", "valueText", "valueText"], outputs: ["valueChange", "valueChange"] }], ngImport: i0, template: `
|
|
2034
|
+
<span class="cngx-slider__track"><span class="cngx-slider__fill"></span></span>
|
|
2035
|
+
<span class="cngx-slider__thumb">
|
|
2036
|
+
@if (thumbGlyph(); as glyph) {
|
|
2037
|
+
<ng-container *ngTemplateOutlet="glyph" />
|
|
2038
|
+
}
|
|
2039
|
+
</span>
|
|
2040
|
+
@if (ticks.values().length) {
|
|
2041
|
+
<span class="cngx-slider__ticks" aria-hidden="true">
|
|
2042
|
+
@for (tick of ticks.values(); track tick) {
|
|
2043
|
+
<span class="cngx-slider__tick-label" [style.--cngx-slider-tick-fraction]="ticks.fractionOf(tick)">
|
|
2044
|
+
{{ format(tick) }}
|
|
2045
|
+
</span>
|
|
2046
|
+
}
|
|
2047
|
+
</span>
|
|
2048
|
+
}
|
|
2049
|
+
@if (showValue() && !showValueBubble()) {
|
|
2050
|
+
<span class="cngx-slider__value" aria-hidden="true">{{ brain.displayValue() }}</span>
|
|
2051
|
+
}
|
|
2052
|
+
@if (showValueBubble()) {
|
|
2053
|
+
<span class="cngx-slider__bubble" aria-hidden="true">{{ brain.displayValue() }}</span>
|
|
2054
|
+
}
|
|
2055
|
+
`, isInline: true, styles: ["cngx-slider{position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-slider[aria-disabled=true]{opacity:.5;cursor:not-allowed}cngx-slider .cngx-slider__track{position:relative;flex:1 1 auto;block-size:var(--cngx-slider-track-size, 4px);border-radius:999px;background:var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250)))}cngx-slider .cngx-slider__fill{position:absolute;inset-block:0;inset-inline-start:0;inline-size:calc(var(--cngx-slider-fraction, 0) * 100%);border-radius:inherit;background:var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50)))}cngx-slider .cngx-slider__thumb{position:absolute;display:grid;place-items:center;inset-block-start:50%;inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-thumb-size, 16px);border-radius:50%;background:var(--cngx-slider-thumb-color, var(--cngx-color-surface, oklch(1 0 0)));border:var(--cngx-slider-thumb-border-width, 2px) solid var(--cngx-slider-thumb-border-color, var(--cngx-color-primary, oklch(.66 .19 50)));translate:-50% -50%;pointer-events:none}cngx-slider.cngx-slider--ticks .cngx-slider__track:before{content:\"\";position:absolute;inset:0;border-radius:inherit;background-image:repeating-linear-gradient(to right,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-slider .cngx-slider__value{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-value-gap, .25rem));inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;color:var(--cngx-color-text, oklch(.2 .01 250));pointer-events:none;white-space:nowrap}cngx-slider .cngx-slider__bubble{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-bubble-gap, .5rem));inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 0;padding:var(--cngx-slider-bubble-padding, .125rem .4rem);border-radius:var(--cngx-radius-sm, .25rem);background:var(--cngx-slider-bubble-bg, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-slider-bubble-color, var(--cngx-color-on-primary, oklch(.99 .01 250)));font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .12s ease}cngx-slider:focus .cngx-slider__bubble,cngx-slider:active .cngx-slider__bubble{opacity:1}cngx-slider .cngx-slider__ticks{position:absolute;inset-inline:0;inset-block-start:calc(100% + .35rem);block-size:1em;pointer-events:none}cngx-slider .cngx-slider__tick-label{position:absolute;inset-inline-start:calc(var(--cngx-slider-tick-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-slider-tick-font-size, .6875rem);font-variant-numeric:tabular-nums;color:var(--cngx-slider-tick-label-color, var(--cngx-color-text-muted, oklch(.55 .01 250)));white-space:nowrap}cngx-slider:focus-visible{outline:none}cngx-slider:focus-visible .cngx-slider__thumb{outline:var(--cngx-slider-focus-ring-width, 2px) solid var(--cngx-slider-focus-ring-color, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}cngx-slider[aria-orientation=vertical] .cngx-slider__ticks{inset-inline:auto;inset-block:0;inset-inline-start:calc(100% + .35rem);inline-size:3ch;block-size:auto}cngx-slider[aria-orientation=vertical] .cngx-slider__tick-label{inset-inline-start:auto;inset-inline-end:0;inset-block-start:calc(100% - var(--cngx-slider-tick-fraction, 0) * 100%);text-align:end;translate:0 -50%}cngx-slider[aria-orientation=vertical]{flex-direction:column;inline-size:max-content;min-inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-length, 9rem);min-block-size:0}cngx-slider[aria-orientation=vertical] .cngx-slider__track{flex:1 1 auto;inline-size:var(--cngx-slider-track-size, 4px);block-size:auto}cngx-slider[aria-orientation=vertical] .cngx-slider__fill{inset-inline:0;inset-block:auto 0;inline-size:100%;block-size:calc(var(--cngx-slider-fraction, 0) * 100%)}cngx-slider[aria-orientation=vertical].cngx-slider--ticks .cngx-slider__track:before{background-image:repeating-linear-gradient(to top,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-slider[aria-orientation=vertical] .cngx-slider__thumb{inset-inline-start:50%;inset-block-start:auto;inset-block-end:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 50%}cngx-slider[aria-orientation=vertical] .cngx-slider__value{inset-block-end:auto;inset-block-start:calc(100% - var(--cngx-slider-fraction, 0) * 100%);inset-inline-start:auto;inset-inline-end:calc(100% + .5rem);translate:0 -50%}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2056
|
+
}
|
|
2057
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSlider, decorators: [{
|
|
2058
|
+
type: Component,
|
|
2059
|
+
args: [{ selector: 'cngx-slider', exportAs: 'cngxSlider', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [NgTemplateOutlet], hostDirectives: [
|
|
2060
|
+
{
|
|
2061
|
+
directive: CngxSliderTrack,
|
|
2062
|
+
inputs: ['value', 'min', 'max', 'step', 'largeStep', 'disabled', 'orientation', 'valueText'],
|
|
2063
|
+
outputs: ['valueChange'],
|
|
2064
|
+
},
|
|
2065
|
+
], host: {
|
|
2066
|
+
class: 'cngx-slider',
|
|
2067
|
+
'[class.cngx-slider--ticks]': 'showTicks()',
|
|
2068
|
+
'[class.cngx-slider--bubble]': 'showValueBubble()',
|
|
2069
|
+
'[style.--cngx-slider-tick-interval]': 'ticks.interval()',
|
|
2070
|
+
}, template: `
|
|
2071
|
+
<span class="cngx-slider__track"><span class="cngx-slider__fill"></span></span>
|
|
2072
|
+
<span class="cngx-slider__thumb">
|
|
2073
|
+
@if (thumbGlyph(); as glyph) {
|
|
2074
|
+
<ng-container *ngTemplateOutlet="glyph" />
|
|
2075
|
+
}
|
|
2076
|
+
</span>
|
|
2077
|
+
@if (ticks.values().length) {
|
|
2078
|
+
<span class="cngx-slider__ticks" aria-hidden="true">
|
|
2079
|
+
@for (tick of ticks.values(); track tick) {
|
|
2080
|
+
<span class="cngx-slider__tick-label" [style.--cngx-slider-tick-fraction]="ticks.fractionOf(tick)">
|
|
2081
|
+
{{ format(tick) }}
|
|
2082
|
+
</span>
|
|
2083
|
+
}
|
|
2084
|
+
</span>
|
|
2085
|
+
}
|
|
2086
|
+
@if (showValue() && !showValueBubble()) {
|
|
2087
|
+
<span class="cngx-slider__value" aria-hidden="true">{{ brain.displayValue() }}</span>
|
|
2088
|
+
}
|
|
2089
|
+
@if (showValueBubble()) {
|
|
2090
|
+
<span class="cngx-slider__bubble" aria-hidden="true">{{ brain.displayValue() }}</span>
|
|
2091
|
+
}
|
|
2092
|
+
`, styles: ["cngx-slider{position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-slider[aria-disabled=true]{opacity:.5;cursor:not-allowed}cngx-slider .cngx-slider__track{position:relative;flex:1 1 auto;block-size:var(--cngx-slider-track-size, 4px);border-radius:999px;background:var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250)))}cngx-slider .cngx-slider__fill{position:absolute;inset-block:0;inset-inline-start:0;inline-size:calc(var(--cngx-slider-fraction, 0) * 100%);border-radius:inherit;background:var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50)))}cngx-slider .cngx-slider__thumb{position:absolute;display:grid;place-items:center;inset-block-start:50%;inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-thumb-size, 16px);border-radius:50%;background:var(--cngx-slider-thumb-color, var(--cngx-color-surface, oklch(1 0 0)));border:var(--cngx-slider-thumb-border-width, 2px) solid var(--cngx-slider-thumb-border-color, var(--cngx-color-primary, oklch(.66 .19 50)));translate:-50% -50%;pointer-events:none}cngx-slider.cngx-slider--ticks .cngx-slider__track:before{content:\"\";position:absolute;inset:0;border-radius:inherit;background-image:repeating-linear-gradient(to right,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-slider .cngx-slider__value{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-value-gap, .25rem));inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;color:var(--cngx-color-text, oklch(.2 .01 250));pointer-events:none;white-space:nowrap}cngx-slider .cngx-slider__bubble{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-bubble-gap, .5rem));inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 0;padding:var(--cngx-slider-bubble-padding, .125rem .4rem);border-radius:var(--cngx-radius-sm, .25rem);background:var(--cngx-slider-bubble-bg, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-slider-bubble-color, var(--cngx-color-on-primary, oklch(.99 .01 250)));font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .12s ease}cngx-slider:focus .cngx-slider__bubble,cngx-slider:active .cngx-slider__bubble{opacity:1}cngx-slider .cngx-slider__ticks{position:absolute;inset-inline:0;inset-block-start:calc(100% + .35rem);block-size:1em;pointer-events:none}cngx-slider .cngx-slider__tick-label{position:absolute;inset-inline-start:calc(var(--cngx-slider-tick-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-slider-tick-font-size, .6875rem);font-variant-numeric:tabular-nums;color:var(--cngx-slider-tick-label-color, var(--cngx-color-text-muted, oklch(.55 .01 250)));white-space:nowrap}cngx-slider:focus-visible{outline:none}cngx-slider:focus-visible .cngx-slider__thumb{outline:var(--cngx-slider-focus-ring-width, 2px) solid var(--cngx-slider-focus-ring-color, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}cngx-slider[aria-orientation=vertical] .cngx-slider__ticks{inset-inline:auto;inset-block:0;inset-inline-start:calc(100% + .35rem);inline-size:3ch;block-size:auto}cngx-slider[aria-orientation=vertical] .cngx-slider__tick-label{inset-inline-start:auto;inset-inline-end:0;inset-block-start:calc(100% - var(--cngx-slider-tick-fraction, 0) * 100%);text-align:end;translate:0 -50%}cngx-slider[aria-orientation=vertical]{flex-direction:column;inline-size:max-content;min-inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-length, 9rem);min-block-size:0}cngx-slider[aria-orientation=vertical] .cngx-slider__track{flex:1 1 auto;inline-size:var(--cngx-slider-track-size, 4px);block-size:auto}cngx-slider[aria-orientation=vertical] .cngx-slider__fill{inset-inline:0;inset-block:auto 0;inline-size:100%;block-size:calc(var(--cngx-slider-fraction, 0) * 100%)}cngx-slider[aria-orientation=vertical].cngx-slider--ticks .cngx-slider__track:before{background-image:repeating-linear-gradient(to top,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-slider[aria-orientation=vertical] .cngx-slider__thumb{inset-inline-start:50%;inset-block-start:auto;inset-block-end:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 50%}cngx-slider[aria-orientation=vertical] .cngx-slider__value{inset-block-end:auto;inset-block-start:calc(100% - var(--cngx-slider-fraction, 0) * 100%);inset-inline-start:auto;inset-inline-end:calc(100% + .5rem);translate:0 -50%}\n"] }]
|
|
2093
|
+
}], propDecorators: { showValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "showValue", required: false }] }], showValueBubble: [{ type: i0.Input, args: [{ isSignal: true, alias: "showValueBubble", required: false }] }], showTicks: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTicks", required: false }] }], showTickLabels: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTickLabels", required: false }] }], thumbGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "thumbGlyph", required: false }] }] } });
|
|
2094
|
+
|
|
2095
|
+
/**
|
|
2096
|
+
* DI token for the {@link CngxSliderRangeHost} contract. {@link CngxRangeSlider}
|
|
2097
|
+
* provides it via `useExisting`; each {@link CngxSliderThumb} injects it up the
|
|
2098
|
+
* element-injector hierarchy.
|
|
2099
|
+
*
|
|
2100
|
+
* @category common/interactive/slider
|
|
2101
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/range-slider.token.ts
|
|
2102
|
+
* @since 0.1.0
|
|
2103
|
+
* @relatedTo CngxRangeSlider, CngxSliderThumb
|
|
2104
|
+
*/
|
|
2105
|
+
const CNGX_SLIDER_RANGE = new InjectionToken('CNGX_SLIDER_RANGE');
|
|
2106
|
+
|
|
2107
|
+
/**
|
|
2108
|
+
* Headless dual-thumb (range) slider brain. Put `cngxRangeSliderTrack` on your
|
|
2109
|
+
* own track container and host two {@link CngxSliderThumb} children
|
|
2110
|
+
* (`start` / `end`); the value is a `model<[number, number]>()` tuple this
|
|
2111
|
+
* directive owns. It provides {@link CNGX_SLIDER_RANGE} so each thumb reads the
|
|
2112
|
+
* shared config, learns its sibling-clamped bounds, and commits its end. The
|
|
2113
|
+
* thumbs cannot cross because {@link boundsFor} narrows each thumb's range to
|
|
2114
|
+
* the other thumb's current value - clamp math, not an effect (Pillar 1).
|
|
2115
|
+
*
|
|
2116
|
+
* Most consumers want the finished {@link CngxRangeSlider} component
|
|
2117
|
+
* (`<cngx-range-slider>`) which renders the track, fill band, and both thumbs
|
|
2118
|
+
* and uses this directive as its brain. Reach for `cngxRangeSliderTrack` only
|
|
2119
|
+
* when you want to own the skin markup.
|
|
2120
|
+
*
|
|
2121
|
+
* ```html
|
|
2122
|
+
* <div cngxRangeSliderTrack role="group" aria-label="Price range" [(value)]="price" [min]="0" [max]="1000">
|
|
2123
|
+
* <span class="cngx-slider__track"></span>
|
|
2124
|
+
* <span cngxSliderThumb="start" aria-label="Minimum"></span>
|
|
2125
|
+
* <span cngxSliderThumb="end" aria-label="Maximum"></span>
|
|
2126
|
+
* </div>
|
|
2127
|
+
* ```
|
|
2128
|
+
*
|
|
2129
|
+
* @category common/interactive/slider
|
|
2130
|
+
* @wcag AA
|
|
2131
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/range-slider.directive.ts
|
|
2132
|
+
* @since 0.1.0
|
|
2133
|
+
* @relatedTo CngxRangeSlider, CngxSliderThumb, createSliderCore
|
|
2134
|
+
*/
|
|
2135
|
+
class CngxRangeSliderTrack {
|
|
2136
|
+
/** Two-way `[start, end]` tuple - the single source of truth for both thumbs. */
|
|
2137
|
+
value = model([0, 100], ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
2138
|
+
/** Track lower bound. */
|
|
2139
|
+
min = input(0, ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
|
|
2140
|
+
/** Track upper bound. */
|
|
2141
|
+
max = input(100, ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
|
|
2142
|
+
/** Step granularity shared by both thumbs. */
|
|
2143
|
+
step = input(1, ...(ngDevMode ? [{ debugName: "step" }] : /* istanbul ignore next */ []));
|
|
2144
|
+
/**
|
|
2145
|
+
* Page-key jump size for both thumbs (absolute, not a step multiple).
|
|
2146
|
+
* Defaults to the larger of one step and a tenth of the range.
|
|
2147
|
+
*/
|
|
2148
|
+
largeStep = input(undefined, ...(ngDevMode ? [{ debugName: "largeStep" }] : /* istanbul ignore next */ []));
|
|
2149
|
+
/** Whether the range slider is disabled. */
|
|
2150
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
2151
|
+
/** Track axis shared by both thumbs. */
|
|
2152
|
+
orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
|
|
2153
|
+
/** Optional `aria-valuetext` formatter shared across both thumbs. */
|
|
2154
|
+
valueText = input(undefined, ...(ngDevMode ? [{ debugName: "valueText" }] : /* istanbul ignore next */ []));
|
|
2155
|
+
// Sibling-clamp bounds. The start thumb's ceiling tracks the end value;
|
|
2156
|
+
// the end thumb's floor tracks the start value. Held as stable signals
|
|
2157
|
+
// (not recreated per boundsFor call) so each thumb's core reads one node.
|
|
2158
|
+
startBounds = {
|
|
2159
|
+
min: this.min,
|
|
2160
|
+
max: computed(() => this.value()[1]),
|
|
2161
|
+
};
|
|
2162
|
+
endBounds = {
|
|
2163
|
+
min: computed(() => this.value()[0]),
|
|
2164
|
+
max: this.max,
|
|
2165
|
+
};
|
|
2166
|
+
el = inject((ElementRef)).nativeElement;
|
|
2167
|
+
// Track fractions of each thumb, published as CSS vars so the skin can paint
|
|
2168
|
+
// a fill between them. Derived from the tuple - never synced (Pillar 1).
|
|
2169
|
+
startFraction = computed(() => this.fractionOf(this.value()[0]), ...(ngDevMode ? [{ debugName: "startFraction" }] : /* istanbul ignore next */ []));
|
|
2170
|
+
endFraction = computed(() => this.fractionOf(this.value()[1]), ...(ngDevMode ? [{ debugName: "endFraction" }] : /* istanbul ignore next */ []));
|
|
2171
|
+
fractionOf(value) {
|
|
2172
|
+
const span = this.max() - this.min();
|
|
2173
|
+
if (span <= 0) {
|
|
2174
|
+
return 0;
|
|
2175
|
+
}
|
|
2176
|
+
return Math.min(1, Math.max(0, (value - this.min()) / span));
|
|
2177
|
+
}
|
|
2178
|
+
boundsFor(position) {
|
|
2179
|
+
return position === 'start' ? this.startBounds : this.endBounds;
|
|
2180
|
+
}
|
|
2181
|
+
commit(position, value) {
|
|
2182
|
+
const [start, end] = this.value();
|
|
2183
|
+
if (position === 'start') {
|
|
2184
|
+
if (value !== start) {
|
|
2185
|
+
this.value.set([value, end]);
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
else if (value !== end) {
|
|
2189
|
+
this.value.set([start, value]);
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
fractionFromPointer(clientX, clientY) {
|
|
2193
|
+
return pointerFraction(this.el, this.orientation(), clientX, clientY);
|
|
2194
|
+
}
|
|
2195
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRangeSliderTrack, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2196
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxRangeSliderTrack, isStandalone: true, selector: "[cngxRangeSliderTrack]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, largeStep: { classPropertyName: "largeStep", publicName: "largeStep", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, valueText: { classPropertyName: "valueText", publicName: "valueText", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { attributes: { "role": "group" }, properties: { "attr.aria-disabled": "disabled() || null", "attr.aria-orientation": "orientation()", "style.--cngx-slider-start-fraction": "startFraction()", "style.--cngx-slider-end-fraction": "endFraction()" } }, providers: [{ provide: CNGX_SLIDER_RANGE, useExisting: CngxRangeSliderTrack }], exportAs: ["cngxRangeSliderTrack"], ngImport: i0 });
|
|
2197
|
+
}
|
|
2198
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRangeSliderTrack, decorators: [{
|
|
2199
|
+
type: Directive,
|
|
2200
|
+
args: [{
|
|
2201
|
+
selector: '[cngxRangeSliderTrack]',
|
|
2202
|
+
exportAs: 'cngxRangeSliderTrack',
|
|
2203
|
+
standalone: true,
|
|
2204
|
+
providers: [{ provide: CNGX_SLIDER_RANGE, useExisting: CngxRangeSliderTrack }],
|
|
2205
|
+
host: {
|
|
2206
|
+
role: 'group',
|
|
2207
|
+
'[attr.aria-disabled]': 'disabled() || null',
|
|
2208
|
+
'[attr.aria-orientation]': 'orientation()',
|
|
2209
|
+
'[style.--cngx-slider-start-fraction]': 'startFraction()',
|
|
2210
|
+
'[style.--cngx-slider-end-fraction]': 'endFraction()',
|
|
2211
|
+
},
|
|
2212
|
+
}]
|
|
2213
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], largeStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "largeStep", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], valueText: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueText", required: false }] }] } });
|
|
2214
|
+
|
|
2215
|
+
/**
|
|
2216
|
+
* Builds a `WritableSignal<number>` view over one end of the range tuple:
|
|
2217
|
+
* reads `range.value()[index]` reactively, routes writes through
|
|
2218
|
+
* `range.commit(position, …)`. Lets a thumb run an ordinary
|
|
2219
|
+
* {@link createSliderCore} (which writes a `WritableSignal`) while the tuple
|
|
2220
|
+
* stays the single source of truth - no local state, no effect sync.
|
|
2221
|
+
*/
|
|
2222
|
+
function createThumbValue(range, position) {
|
|
2223
|
+
const read = computed(() => {
|
|
2224
|
+
const [start, end] = range.value();
|
|
2225
|
+
return position() === 'start' ? start : end;
|
|
2226
|
+
}, ...(ngDevMode ? [{ debugName: "read" }] : /* istanbul ignore next */ []));
|
|
2227
|
+
const accessor = Object.assign(() => read(), {
|
|
2228
|
+
set: (next) => range.commit(position(), next),
|
|
2229
|
+
update: (updater) => range.commit(position(), updater(read())),
|
|
2230
|
+
asReadonly: () => read,
|
|
2231
|
+
});
|
|
2232
|
+
return accessor;
|
|
2233
|
+
}
|
|
2234
|
+
/**
|
|
2235
|
+
* One focusable thumb of a {@link CngxRangeSlider}. Place `cngxSliderThumb` on
|
|
2236
|
+
* each thumb element with `"start"` or `"end"`; the directive turns it into an
|
|
2237
|
+
* independent `role="slider"` with its own `aria-valuenow`/`valuetext` and APG
|
|
2238
|
+
* keyboard, bounded by the sibling thumb so the two can never cross. It reads
|
|
2239
|
+
* the shared track config from {@link CNGX_SLIDER_RANGE} (injected up the
|
|
2240
|
+
* element-injector hierarchy) and commits its end through the host.
|
|
2241
|
+
*
|
|
2242
|
+
* Two focusable thumbs cannot be derived from a single host element, so each
|
|
2243
|
+
* thumb is its own directive - the headless contract the skin marks up.
|
|
2244
|
+
*
|
|
2245
|
+
* @category common/interactive/slider
|
|
2246
|
+
* @wcag AA
|
|
2247
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/slider-thumb.directive.ts
|
|
2248
|
+
* @since 0.1.0
|
|
2249
|
+
* @relatedTo CngxRangeSlider, CngxRangeSliderTrack, createSliderCore
|
|
2250
|
+
*/
|
|
2251
|
+
class CngxSliderThumb {
|
|
2252
|
+
/** Which end of the range this thumb drives. Bound from the selector. */
|
|
2253
|
+
position = input.required({ ...(ngDevMode ? { debugName: "position" } : /* istanbul ignore next */ {}), alias: 'cngxSliderThumb' });
|
|
2254
|
+
range = inject(CNGX_SLIDER_RANGE);
|
|
2255
|
+
el = inject((ElementRef)).nativeElement;
|
|
2256
|
+
/** Sibling-clamped bounds for this thumb, selected reactively by position. */
|
|
2257
|
+
bounds = computed(() => this.range.boundsFor(this.position()), ...(ngDevMode ? [{ debugName: "bounds" }] : /* istanbul ignore next */ []));
|
|
2258
|
+
value = createThumbValue(this.range, this.position);
|
|
2259
|
+
/** Shared value/step/aria derivation, bounded by the sibling thumb. */
|
|
2260
|
+
core = createSliderCore({
|
|
2261
|
+
value: this.value,
|
|
2262
|
+
min: this.range.min,
|
|
2263
|
+
max: this.range.max,
|
|
2264
|
+
step: this.range.step,
|
|
2265
|
+
boundedMin: computed(() => this.bounds().min()),
|
|
2266
|
+
boundedMax: computed(() => this.bounds().max()),
|
|
2267
|
+
valueText: (v) => {
|
|
2268
|
+
const format = this.range.valueText();
|
|
2269
|
+
return format ? format(v) : String(v);
|
|
2270
|
+
},
|
|
2271
|
+
});
|
|
2272
|
+
pageStep = computed(() => {
|
|
2273
|
+
const explicit = this.range.largeStep();
|
|
2274
|
+
if (explicit && explicit > 0) {
|
|
2275
|
+
return explicit;
|
|
2276
|
+
}
|
|
2277
|
+
const grid = this.range.step() > 0 ? this.range.step() : 1;
|
|
2278
|
+
return Math.max(grid, (this.range.max() - this.range.min()) / 10);
|
|
2279
|
+
}, ...(ngDevMode ? [{ debugName: "pageStep" }] : /* istanbul ignore next */ []));
|
|
2280
|
+
// Shared keyboard + pointer-drag handlers. The pointer math measures against
|
|
2281
|
+
// the shared track (the range host owns the geometry), not this thumb's own
|
|
2282
|
+
// tiny handle element.
|
|
2283
|
+
interaction = createSliderInteraction({
|
|
2284
|
+
core: this.core,
|
|
2285
|
+
el: this.el,
|
|
2286
|
+
disabled: () => this.range.disabled(),
|
|
2287
|
+
pageStep: () => this.pageStep(),
|
|
2288
|
+
fractionFromPointer: (x, y) => this.range.fractionFromPointer(x, y),
|
|
2289
|
+
});
|
|
2290
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSliderThumb, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2291
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxSliderThumb, isStandalone: true, selector: "[cngxSliderThumb]", inputs: { position: { classPropertyName: "position", publicName: "cngxSliderThumb", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "slider" }, listeners: { "keydown": "interaction.handleKeydown($event)", "pointerdown": "interaction.handlePointerDown($event)", "pointermove": "interaction.handlePointerMove($event)", "pointerup": "interaction.handlePointerUp($event)", "pointercancel": "interaction.handlePointerUp($event)" }, properties: { "attr.aria-valuemin": "bounds().min()", "attr.aria-valuemax": "bounds().max()", "attr.aria-valuenow": "core.clampedValue()", "attr.aria-valuetext": "core.ariaValueText()", "attr.aria-orientation": "range.orientation()", "attr.aria-disabled": "range.disabled() || null", "attr.tabindex": "range.disabled() ? -1 : 0", "style.touch-action": "'none'", "style.--cngx-slider-fraction": "core.fraction()" } }, exportAs: ["cngxSliderThumb"], ngImport: i0 });
|
|
2292
|
+
}
|
|
2293
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSliderThumb, decorators: [{
|
|
2294
|
+
type: Directive,
|
|
2295
|
+
args: [{
|
|
2296
|
+
selector: '[cngxSliderThumb]',
|
|
2297
|
+
exportAs: 'cngxSliderThumb',
|
|
2298
|
+
standalone: true,
|
|
2299
|
+
host: {
|
|
2300
|
+
role: 'slider',
|
|
2301
|
+
'[attr.aria-valuemin]': 'bounds().min()',
|
|
2302
|
+
'[attr.aria-valuemax]': 'bounds().max()',
|
|
2303
|
+
'[attr.aria-valuenow]': 'core.clampedValue()',
|
|
2304
|
+
'[attr.aria-valuetext]': 'core.ariaValueText()',
|
|
2305
|
+
'[attr.aria-orientation]': 'range.orientation()',
|
|
2306
|
+
'[attr.aria-disabled]': 'range.disabled() || null',
|
|
2307
|
+
'[attr.tabindex]': 'range.disabled() ? -1 : 0',
|
|
2308
|
+
'[style.touch-action]': "'none'",
|
|
2309
|
+
'[style.--cngx-slider-fraction]': 'core.fraction()',
|
|
2310
|
+
'(keydown)': 'interaction.handleKeydown($event)',
|
|
2311
|
+
'(pointerdown)': 'interaction.handlePointerDown($event)',
|
|
2312
|
+
'(pointermove)': 'interaction.handlePointerMove($event)',
|
|
2313
|
+
'(pointerup)': 'interaction.handlePointerUp($event)',
|
|
2314
|
+
'(pointercancel)': 'interaction.handlePointerUp($event)',
|
|
2315
|
+
},
|
|
2316
|
+
}]
|
|
2317
|
+
}], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxSliderThumb", required: true }] }] } });
|
|
2318
|
+
|
|
2319
|
+
/**
|
|
2320
|
+
* Finished two-thumb (range) slider. Drop it in, bind `[(value)]` to a
|
|
2321
|
+
* `[number, number]` tuple - it renders the track, the fill band between the
|
|
2322
|
+
* thumbs, and both draggable handles, and wires the full APG keyboard +
|
|
2323
|
+
* pointer-drag through its {@link CngxRangeSliderTrack} brain. The thumbs cannot
|
|
2324
|
+
* cross because the brain clamps each to the other.
|
|
2325
|
+
*
|
|
2326
|
+
* `showValue` floats a single `start - end` label between the thumbs (so the two
|
|
2327
|
+
* never overlap); `showTicks` paints a step tick along the track; `thumbGlyph`
|
|
2328
|
+
* projects content into both handles; `orientation="vertical"` rotates the skin.
|
|
2329
|
+
* Reach for the headless {@link CngxRangeSliderTrack} directive only when you
|
|
2330
|
+
* need to own the skin markup; use {@link CngxSlider} for a single thumb.
|
|
2331
|
+
*
|
|
2332
|
+
* ```html
|
|
2333
|
+
* <cngx-range-slider aria-label="Price" [(value)]="price" [min]="0" [max]="1000" [step]="10" />
|
|
2334
|
+
* ```
|
|
2335
|
+
*
|
|
2336
|
+
* @category common/interactive/slider
|
|
2337
|
+
* @docsKind primary
|
|
2338
|
+
* @wcag AA
|
|
2339
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/slider/range-slider.component.ts
|
|
2340
|
+
* @since 0.1.0
|
|
2341
|
+
* @relatedTo CngxRangeSliderTrack, CngxSlider, CngxSliderThumb
|
|
2342
|
+
*/
|
|
2343
|
+
class CngxRangeSlider {
|
|
2344
|
+
/** Accessible name of the start (minimum) thumb. EN default. */
|
|
2345
|
+
startLabel = input('Minimum', ...(ngDevMode ? [{ debugName: "startLabel" }] : /* istanbul ignore next */ []));
|
|
2346
|
+
/** Accessible name of the end (maximum) thumb. EN default. */
|
|
2347
|
+
endLabel = input('Maximum', ...(ngDevMode ? [{ debugName: "endLabel" }] : /* istanbul ignore next */ []));
|
|
2348
|
+
/** Render the formatted `start - end` values centred between the thumbs (visual only). */
|
|
2349
|
+
showValue = input(false, { ...(ngDevMode ? { debugName: "showValue" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2350
|
+
/** Show the combined `start - end` value as a bubble only while focused / dragged. */
|
|
2351
|
+
showValueBubble = input(false, { ...(ngDevMode ? { debugName: "showValueBubble" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2352
|
+
/** Paint a tick mark every `step` along the track. */
|
|
2353
|
+
showTicks = input(false, { ...(ngDevMode ? { debugName: "showTicks" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2354
|
+
/** Render a numeric label at every step stop (independent of `showTicks`). */
|
|
2355
|
+
showTickLabels = input(false, { ...(ngDevMode ? { debugName: "showTickLabels" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
2356
|
+
/** Optional content projected into both thumbs. */
|
|
2357
|
+
thumbGlyph = input(null, ...(ngDevMode ? [{ debugName: "thumbGlyph" }] : /* istanbul ignore next */ []));
|
|
2358
|
+
/** The brain host directive - owns the tuple and the track geometry. */
|
|
2359
|
+
brain = inject(CngxRangeSliderTrack);
|
|
2360
|
+
/** Midpoint of the two thumbs (0..1) - anchors the single combined value label. */
|
|
2361
|
+
midFraction = computed(() => (this.brain.startFraction() + this.brain.endFraction()) / 2, ...(ngDevMode ? [{ debugName: "midFraction" }] : /* istanbul ignore next */ []));
|
|
2362
|
+
/** Tick marks + labels derivation (shared factory). */
|
|
2363
|
+
ticks = createSliderTicks({
|
|
2364
|
+
min: this.brain.min,
|
|
2365
|
+
max: this.brain.max,
|
|
2366
|
+
step: this.brain.step,
|
|
2367
|
+
marks: this.showTicks,
|
|
2368
|
+
labels: this.showTickLabels,
|
|
2369
|
+
});
|
|
2370
|
+
format(value) {
|
|
2371
|
+
const formatter = this.brain.valueText();
|
|
2372
|
+
return formatter ? formatter(value) : String(value);
|
|
2373
|
+
}
|
|
2374
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRangeSlider, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2375
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxRangeSlider, isStandalone: true, selector: "cngx-range-slider", inputs: { startLabel: { classPropertyName: "startLabel", publicName: "startLabel", isSignal: true, isRequired: false, transformFunction: null }, endLabel: { classPropertyName: "endLabel", publicName: "endLabel", isSignal: true, isRequired: false, transformFunction: null }, showValue: { classPropertyName: "showValue", publicName: "showValue", isSignal: true, isRequired: false, transformFunction: null }, showValueBubble: { classPropertyName: "showValueBubble", publicName: "showValueBubble", isSignal: true, isRequired: false, transformFunction: null }, showTicks: { classPropertyName: "showTicks", publicName: "showTicks", isSignal: true, isRequired: false, transformFunction: null }, showTickLabels: { classPropertyName: "showTickLabels", publicName: "showTickLabels", isSignal: true, isRequired: false, transformFunction: null }, thumbGlyph: { classPropertyName: "thumbGlyph", publicName: "thumbGlyph", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-slider--ticks": "showTicks()", "class.cngx-slider--bubble": "showValueBubble()", "style.--cngx-slider-tick-interval": "ticks.interval()" }, classAttribute: "cngx-slider cngx-range-slider" }, exportAs: ["cngxRangeSlider"], hostDirectives: [{ directive: CngxRangeSliderTrack, inputs: ["value", "value", "min", "min", "max", "max", "step", "step", "largeStep", "largeStep", "disabled", "disabled", "orientation", "orientation", "valueText", "valueText"], outputs: ["valueChange", "valueChange"] }], ngImport: i0, template: `
|
|
2376
|
+
<span class="cngx-slider__track"></span>
|
|
2377
|
+
<span cngxSliderThumb="start" [attr.aria-label]="startLabel()">
|
|
2378
|
+
@if (thumbGlyph(); as glyph) {
|
|
2379
|
+
<ng-container *ngTemplateOutlet="glyph" />
|
|
2380
|
+
}
|
|
2381
|
+
</span>
|
|
2382
|
+
<span cngxSliderThumb="end" [attr.aria-label]="endLabel()">
|
|
2383
|
+
@if (thumbGlyph(); as glyph) {
|
|
2384
|
+
<ng-container *ngTemplateOutlet="glyph" />
|
|
2385
|
+
}
|
|
2386
|
+
</span>
|
|
2387
|
+
@if (ticks.values().length) {
|
|
2388
|
+
<span class="cngx-slider__ticks" aria-hidden="true">
|
|
2389
|
+
@for (tick of ticks.values(); track tick) {
|
|
2390
|
+
<span class="cngx-slider__tick-label" [style.--cngx-slider-tick-fraction]="ticks.fractionOf(tick)">
|
|
2391
|
+
{{ format(tick) }}
|
|
2392
|
+
</span>
|
|
2393
|
+
}
|
|
2394
|
+
</span>
|
|
2395
|
+
}
|
|
2396
|
+
@if (showValue() || showValueBubble()) {
|
|
2397
|
+
<span
|
|
2398
|
+
class="cngx-slider__value cngx-slider__value--range"
|
|
2399
|
+
[class.cngx-slider__bubble]="showValueBubble()"
|
|
2400
|
+
aria-hidden="true"
|
|
2401
|
+
[style.--cngx-slider-mid-fraction]="midFraction()"
|
|
2402
|
+
>
|
|
2403
|
+
{{ format(brain.value()[0]) }} - {{ format(brain.value()[1]) }}
|
|
2404
|
+
</span>
|
|
2405
|
+
}
|
|
2406
|
+
`, isInline: true, styles: ["cngx-range-slider{position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-range-slider[aria-disabled=true]{opacity:.5;cursor:not-allowed}cngx-range-slider .cngx-slider__track{position:relative;flex:1 1 auto;block-size:var(--cngx-slider-track-size, 4px);border-radius:999px;background:linear-gradient(to right,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) 0,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-end-fraction, 1) * 100%),var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-end-fraction, 1) * 100%))}cngx-range-slider.cngx-slider--ticks .cngx-slider__track:before{content:\"\";position:absolute;inset:0;border-radius:inherit;background-image:repeating-linear-gradient(to right,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-range-slider [cngxSliderThumb]{position:absolute;display:grid;place-items:center;inset-block-start:50%;inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-thumb-size, 16px);border-radius:50%;background:var(--cngx-slider-thumb-color, var(--cngx-color-surface, oklch(1 0 0)));border:var(--cngx-slider-thumb-border-width, 2px) solid var(--cngx-slider-thumb-border-color, var(--cngx-color-primary, oklch(.66 .19 50)));translate:-50% -50%;cursor:grab}cngx-range-slider [cngxSliderThumb]:focus-visible{outline:var(--cngx-slider-focus-ring-width, 2px) solid var(--cngx-slider-focus-ring-color, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}cngx-range-slider .cngx-slider__ticks{position:absolute;inset-inline:0;inset-block-start:calc(100% + .35rem);block-size:1em;pointer-events:none}cngx-range-slider .cngx-slider__tick-label{position:absolute;inset-inline-start:calc(var(--cngx-slider-tick-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-slider-tick-font-size, .6875rem);font-variant-numeric:tabular-nums;color:var(--cngx-slider-tick-label-color, var(--cngx-color-text-muted, oklch(.55 .01 250)));white-space:nowrap}cngx-range-slider[aria-orientation=vertical] .cngx-slider__ticks{inset-inline:auto;inset-block:0;inset-inline-start:calc(100% + .35rem);inline-size:3ch;block-size:auto}cngx-range-slider[aria-orientation=vertical] .cngx-slider__tick-label{inset-inline-start:auto;inset-inline-end:0;inset-block-start:calc(100% - var(--cngx-slider-tick-fraction, 0) * 100%);text-align:end;translate:0 -50%}cngx-range-slider .cngx-slider__value--range{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-value-gap, .25rem));inset-inline-start:calc(var(--cngx-slider-mid-fraction, .5) * 100%);translate:-50% 0;font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;color:var(--cngx-color-text, oklch(.2 .01 250));pointer-events:none;white-space:nowrap}cngx-range-slider .cngx-slider__value--range.cngx-slider__bubble{inset-block-end:calc(100% + var(--cngx-slider-bubble-gap, .5rem));padding:var(--cngx-slider-bubble-padding, .125rem .4rem);border-radius:var(--cngx-radius-sm, .25rem);background:var(--cngx-slider-bubble-bg, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-slider-bubble-color, var(--cngx-color-on-primary, oklch(.99 .01 250)));opacity:0;transition:opacity .12s ease}cngx-range-slider:focus-within .cngx-slider__bubble,cngx-range-slider:active .cngx-slider__bubble{opacity:1}cngx-range-slider[aria-orientation=vertical]{flex-direction:column;inline-size:max-content;min-inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-length, 9rem);min-block-size:0}cngx-range-slider[aria-orientation=vertical] .cngx-slider__track{flex:1 1 auto;inline-size:var(--cngx-slider-track-size, 4px);block-size:auto;background:linear-gradient(to top,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) 0,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-end-fraction, 1) * 100%),var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-end-fraction, 1) * 100%))}cngx-range-slider[aria-orientation=vertical].cngx-slider--ticks .cngx-slider__track:before{background-image:repeating-linear-gradient(to top,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-range-slider[aria-orientation=vertical] [cngxSliderThumb]{inset-inline-start:50%;inset-block-start:auto;inset-block-end:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 50%}cngx-range-slider[aria-orientation=vertical] .cngx-slider__value--range{inset-block-end:auto;inset-block-start:calc(100% - var(--cngx-slider-mid-fraction, .5) * 100%);inset-inline-start:calc(100% + .5rem);translate:0 -50%}\n"], dependencies: [{ kind: "directive", type: CngxSliderThumb, selector: "[cngxSliderThumb]", inputs: ["cngxSliderThumb"], exportAs: ["cngxSliderThumb"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2407
|
+
}
|
|
2408
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRangeSlider, decorators: [{
|
|
2409
|
+
type: Component,
|
|
2410
|
+
args: [{ selector: 'cngx-range-slider', exportAs: 'cngxRangeSlider', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [CngxSliderThumb, NgTemplateOutlet], hostDirectives: [
|
|
2411
|
+
{
|
|
2412
|
+
directive: CngxRangeSliderTrack,
|
|
2413
|
+
inputs: ['value', 'min', 'max', 'step', 'largeStep', 'disabled', 'orientation', 'valueText'],
|
|
2414
|
+
outputs: ['valueChange'],
|
|
2415
|
+
},
|
|
2416
|
+
], host: {
|
|
2417
|
+
class: 'cngx-slider cngx-range-slider',
|
|
2418
|
+
'[class.cngx-slider--ticks]': 'showTicks()',
|
|
2419
|
+
'[class.cngx-slider--bubble]': 'showValueBubble()',
|
|
2420
|
+
'[style.--cngx-slider-tick-interval]': 'ticks.interval()',
|
|
2421
|
+
}, template: `
|
|
2422
|
+
<span class="cngx-slider__track"></span>
|
|
2423
|
+
<span cngxSliderThumb="start" [attr.aria-label]="startLabel()">
|
|
2424
|
+
@if (thumbGlyph(); as glyph) {
|
|
2425
|
+
<ng-container *ngTemplateOutlet="glyph" />
|
|
2426
|
+
}
|
|
2427
|
+
</span>
|
|
2428
|
+
<span cngxSliderThumb="end" [attr.aria-label]="endLabel()">
|
|
2429
|
+
@if (thumbGlyph(); as glyph) {
|
|
2430
|
+
<ng-container *ngTemplateOutlet="glyph" />
|
|
2431
|
+
}
|
|
2432
|
+
</span>
|
|
2433
|
+
@if (ticks.values().length) {
|
|
2434
|
+
<span class="cngx-slider__ticks" aria-hidden="true">
|
|
2435
|
+
@for (tick of ticks.values(); track tick) {
|
|
2436
|
+
<span class="cngx-slider__tick-label" [style.--cngx-slider-tick-fraction]="ticks.fractionOf(tick)">
|
|
2437
|
+
{{ format(tick) }}
|
|
2438
|
+
</span>
|
|
2439
|
+
}
|
|
2440
|
+
</span>
|
|
2441
|
+
}
|
|
2442
|
+
@if (showValue() || showValueBubble()) {
|
|
2443
|
+
<span
|
|
2444
|
+
class="cngx-slider__value cngx-slider__value--range"
|
|
2445
|
+
[class.cngx-slider__bubble]="showValueBubble()"
|
|
2446
|
+
aria-hidden="true"
|
|
2447
|
+
[style.--cngx-slider-mid-fraction]="midFraction()"
|
|
2448
|
+
>
|
|
2449
|
+
{{ format(brain.value()[0]) }} - {{ format(brain.value()[1]) }}
|
|
2450
|
+
</span>
|
|
2451
|
+
}
|
|
2452
|
+
`, styles: ["cngx-range-slider{position:relative;display:flex;align-items:center;box-sizing:border-box;inline-size:100%;min-block-size:var(--cngx-slider-thumb-size, 16px);cursor:pointer;touch-action:none}cngx-range-slider[aria-disabled=true]{opacity:.5;cursor:not-allowed}cngx-range-slider .cngx-slider__track{position:relative;flex:1 1 auto;block-size:var(--cngx-slider-track-size, 4px);border-radius:999px;background:linear-gradient(to right,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) 0,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-end-fraction, 1) * 100%),var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-end-fraction, 1) * 100%))}cngx-range-slider.cngx-slider--ticks .cngx-slider__track:before{content:\"\";position:absolute;inset:0;border-radius:inherit;background-image:repeating-linear-gradient(to right,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-range-slider [cngxSliderThumb]{position:absolute;display:grid;place-items:center;inset-block-start:50%;inset-inline-start:calc(var(--cngx-slider-fraction, 0) * 100%);inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-thumb-size, 16px);border-radius:50%;background:var(--cngx-slider-thumb-color, var(--cngx-color-surface, oklch(1 0 0)));border:var(--cngx-slider-thumb-border-width, 2px) solid var(--cngx-slider-thumb-border-color, var(--cngx-color-primary, oklch(.66 .19 50)));translate:-50% -50%;cursor:grab}cngx-range-slider [cngxSliderThumb]:focus-visible{outline:var(--cngx-slider-focus-ring-width, 2px) solid var(--cngx-slider-focus-ring-color, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}cngx-range-slider .cngx-slider__ticks{position:absolute;inset-inline:0;inset-block-start:calc(100% + .35rem);block-size:1em;pointer-events:none}cngx-range-slider .cngx-slider__tick-label{position:absolute;inset-inline-start:calc(var(--cngx-slider-tick-fraction, 0) * 100%);translate:-50% 0;font-size:var(--cngx-slider-tick-font-size, .6875rem);font-variant-numeric:tabular-nums;color:var(--cngx-slider-tick-label-color, var(--cngx-color-text-muted, oklch(.55 .01 250)));white-space:nowrap}cngx-range-slider[aria-orientation=vertical] .cngx-slider__ticks{inset-inline:auto;inset-block:0;inset-inline-start:calc(100% + .35rem);inline-size:3ch;block-size:auto}cngx-range-slider[aria-orientation=vertical] .cngx-slider__tick-label{inset-inline-start:auto;inset-inline-end:0;inset-block-start:calc(100% - var(--cngx-slider-tick-fraction, 0) * 100%);text-align:end;translate:0 -50%}cngx-range-slider .cngx-slider__value--range{position:absolute;inset-block-end:calc(100% + var(--cngx-slider-value-gap, .25rem));inset-inline-start:calc(var(--cngx-slider-mid-fraction, .5) * 100%);translate:-50% 0;font-size:var(--cngx-font-size-sm, .8125rem);font-variant-numeric:tabular-nums;color:var(--cngx-color-text, oklch(.2 .01 250));pointer-events:none;white-space:nowrap}cngx-range-slider .cngx-slider__value--range.cngx-slider__bubble{inset-block-end:calc(100% + var(--cngx-slider-bubble-gap, .5rem));padding:var(--cngx-slider-bubble-padding, .125rem .4rem);border-radius:var(--cngx-radius-sm, .25rem);background:var(--cngx-slider-bubble-bg, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-slider-bubble-color, var(--cngx-color-on-primary, oklch(.99 .01 250)));opacity:0;transition:opacity .12s ease}cngx-range-slider:focus-within .cngx-slider__bubble,cngx-range-slider:active .cngx-slider__bubble{opacity:1}cngx-range-slider[aria-orientation=vertical]{flex-direction:column;inline-size:max-content;min-inline-size:var(--cngx-slider-thumb-size, 16px);block-size:var(--cngx-slider-length, 9rem);min-block-size:0}cngx-range-slider[aria-orientation=vertical] .cngx-slider__track{flex:1 1 auto;inline-size:var(--cngx-slider-track-size, 4px);block-size:auto;background:linear-gradient(to top,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) 0,var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-start-fraction, 0) * 100%),var(--cngx-slider-fill-color, var(--cngx-color-primary, oklch(.66 .19 50))) calc(var(--cngx-slider-end-fraction, 1) * 100%),var(--cngx-slider-track-color, var(--cngx-color-border, oklch(.88 .005 250))) calc(var(--cngx-slider-end-fraction, 1) * 100%))}cngx-range-slider[aria-orientation=vertical].cngx-slider--ticks .cngx-slider__track:before{background-image:repeating-linear-gradient(to top,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) 0,var(--cngx-slider-tick-color, var(--cngx-color-border, oklch(.7 .01 250))) var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-width, 1px),transparent var(--cngx-slider-tick-interval, 10%))}cngx-range-slider[aria-orientation=vertical] [cngxSliderThumb]{inset-inline-start:50%;inset-block-start:auto;inset-block-end:calc(var(--cngx-slider-fraction, 0) * 100%);translate:-50% 50%}cngx-range-slider[aria-orientation=vertical] .cngx-slider__value--range{inset-block-end:auto;inset-block-start:calc(100% - var(--cngx-slider-mid-fraction, .5) * 100%);inset-inline-start:calc(100% + .5rem);translate:0 -50%}\n"] }]
|
|
2453
|
+
}], propDecorators: { startLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "startLabel", required: false }] }], endLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "endLabel", required: false }] }], showValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "showValue", required: false }] }], showValueBubble: [{ type: i0.Input, args: [{ isSignal: true, alias: "showValueBubble", required: false }] }], showTicks: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTicks", required: false }] }], showTickLabels: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTickLabels", required: false }] }], thumbGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "thumbGlyph", required: false }] }] } });
|
|
2454
|
+
|
|
2455
|
+
/**
|
|
2456
|
+
* Level-2 factory implementing the WAI-ARIA APG accordion keyboard model over
|
|
2457
|
+
* a registration model rather than `contentChildren` roving. Registration is
|
|
2458
|
+
* immune to component-view boundaries, so any accordion skin - the
|
|
2459
|
+
* `@cngx/ui/accordion` organism, or a future one that renders each header in
|
|
2460
|
+
* its own view - gets working Arrow/Home/End nav.
|
|
2461
|
+
*
|
|
2462
|
+
* Pillar 1 (Ableitung statt Verwaltung): the tab stop is derived from the
|
|
2463
|
+
* coordinator's `rovingActiveId`, not managed as a second index. Focus
|
|
2464
|
+
* movement is a DOM concern the factory owns - the coordinator only records
|
|
2465
|
+
* which header should be the stop; it never touches the DOM.
|
|
2466
|
+
*
|
|
2467
|
+
* @category common/interactive/accordion
|
|
2468
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/accordion/accordion-keyboard-nav.ts
|
|
2469
|
+
* @since 0.1.0
|
|
2470
|
+
* @relatedTo CngxAccordion, CngxAccordionPanel, createTabKeyboardNav
|
|
2471
|
+
*/
|
|
2472
|
+
function createAccordionKeyboardNav(opts) {
|
|
2473
|
+
// Registered headers sorted by DOM position. `compareDocumentPosition`
|
|
2474
|
+
// orders elements as they appear in the composed document, so headers
|
|
2475
|
+
// rendered inside separate item views still rove in visual order - the
|
|
2476
|
+
// whole reason this replaces `contentChildren` roving.
|
|
2477
|
+
const orderedHeaders = () => {
|
|
2478
|
+
return opts.host.headers().slice().sort((a, b) => {
|
|
2479
|
+
const relation = a.element.compareDocumentPosition(b.element);
|
|
2480
|
+
if (relation & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
2481
|
+
return -1;
|
|
2482
|
+
}
|
|
2483
|
+
if (relation & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
2484
|
+
return 1;
|
|
2485
|
+
}
|
|
2486
|
+
return 0;
|
|
2487
|
+
});
|
|
2488
|
+
};
|
|
2489
|
+
// Index of the header that currently owns the roving stop, clamped into the
|
|
2490
|
+
// sorted list. Navigation always originates from this header.
|
|
2491
|
+
const activeIndex = (headers) => {
|
|
2492
|
+
const id = opts.host.rovingActiveId();
|
|
2493
|
+
const found = headers.findIndex((h) => h.id === id);
|
|
2494
|
+
return found >= 0 ? found : 0;
|
|
2495
|
+
};
|
|
2496
|
+
// Next enabled header index in `direction`, looping at the edges. Mirrors the
|
|
2497
|
+
// step geometry of `createTabKeyboardNav`; the two copies are tolerated until
|
|
2498
|
+
// a third roving-nav factory justifies a shared primitive (rule of three).
|
|
2499
|
+
const step = (headers, from, direction) => {
|
|
2500
|
+
const len = headers.length;
|
|
2501
|
+
if (len === 0) {
|
|
2502
|
+
return null;
|
|
2503
|
+
}
|
|
2504
|
+
let idx = from + direction;
|
|
2505
|
+
for (let i = 0; i < len; i++) {
|
|
2506
|
+
idx = ((idx % len) + len) % len;
|
|
2507
|
+
if (!headers[idx].disabled()) {
|
|
2508
|
+
return idx;
|
|
2509
|
+
}
|
|
2510
|
+
idx += direction;
|
|
2511
|
+
}
|
|
2512
|
+
return null;
|
|
2513
|
+
};
|
|
2514
|
+
// First (direction 1) or last (direction -1) enabled header, for Home/End.
|
|
2515
|
+
const edge = (headers, direction) => {
|
|
2516
|
+
const len = headers.length;
|
|
2517
|
+
if (direction === 1) {
|
|
2518
|
+
for (let i = 0; i < len; i++) {
|
|
2519
|
+
if (!headers[i].disabled()) {
|
|
2520
|
+
return i;
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
else {
|
|
2525
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
2526
|
+
if (!headers[i].disabled()) {
|
|
2527
|
+
return i;
|
|
2528
|
+
}
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
return null;
|
|
2532
|
+
};
|
|
2533
|
+
return {
|
|
2534
|
+
headerTabindex: (handle) => (handle.id === opts.host.rovingActiveId() ? 0 : -1),
|
|
2535
|
+
handleKeydown: (event) => {
|
|
2536
|
+
const headers = orderedHeaders();
|
|
2537
|
+
if (headers.length === 0) {
|
|
2538
|
+
return;
|
|
2539
|
+
}
|
|
2540
|
+
const from = activeIndex(headers);
|
|
2541
|
+
let target;
|
|
2542
|
+
switch (event.key) {
|
|
2543
|
+
case 'ArrowDown':
|
|
2544
|
+
target = step(headers, from, 1);
|
|
2545
|
+
break;
|
|
2546
|
+
case 'ArrowUp':
|
|
2547
|
+
target = step(headers, from, -1);
|
|
2548
|
+
break;
|
|
2549
|
+
case 'Home':
|
|
2550
|
+
target = edge(headers, 1);
|
|
2551
|
+
break;
|
|
2552
|
+
case 'End':
|
|
2553
|
+
target = edge(headers, -1);
|
|
2554
|
+
break;
|
|
2555
|
+
default:
|
|
2556
|
+
return;
|
|
2557
|
+
}
|
|
2558
|
+
if (target === null) {
|
|
2559
|
+
return;
|
|
2560
|
+
}
|
|
2561
|
+
event.preventDefault();
|
|
2562
|
+
const header = headers[target];
|
|
2563
|
+
opts.host.setRovingActive(header.id);
|
|
2564
|
+
header.element.focus();
|
|
2565
|
+
},
|
|
2566
|
+
};
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2569
|
+
/**
|
|
2570
|
+
* DI token for the {@link CngxAccordionHost} contract. {@link CngxAccordion}
|
|
2571
|
+
* provides it via `useExisting`; each {@link CngxAccordionPanel} injects it up
|
|
2572
|
+
* the element-injector hierarchy.
|
|
2573
|
+
*
|
|
2574
|
+
* @category common/interactive/accordion
|
|
2575
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/accordion/accordion.token.ts
|
|
2576
|
+
* @since 0.1.0
|
|
2577
|
+
* @relatedTo CngxAccordion, CngxAccordionPanel
|
|
2578
|
+
*/
|
|
2579
|
+
const CNGX_ACCORDION = new InjectionToken('CNGX_ACCORDION');
|
|
2580
|
+
|
|
2581
|
+
/**
|
|
2582
|
+
* Coordinating directive for an accordion. Put `cngxAccordion` on the
|
|
2583
|
+
* container; each header carries {@link CngxAccordionPanel}. The container owns
|
|
2584
|
+
* two single sources of truth - one `openIds` set signal (expansion) and one
|
|
2585
|
+
* header registry (`rovingActiveId`) - and arbitrates single- vs multi-open. No
|
|
2586
|
+
* panel owns mutable expansion state and no effect syncs siblings: every
|
|
2587
|
+
* panel's `aria-expanded` derives from the open-set signal (Pillar 1).
|
|
2588
|
+
*
|
|
2589
|
+
* Header arrow-key navigation runs through {@link createAccordionKeyboardNav}
|
|
2590
|
+
* over a header registry rather than `contentChildren` roving. Panels register
|
|
2591
|
+
* their header handle on init, so navigation survives a skin that renders each
|
|
2592
|
+
* header inside its own component view - the reason {@link CngxAccordionPanel}
|
|
2593
|
+
* self-wires `tabindex`/`keydown` instead of relying on a container-level
|
|
2594
|
+
* roving directive.
|
|
2595
|
+
*
|
|
2596
|
+
* ```html
|
|
2597
|
+
* <div cngxAccordion #acc="cngxAccordion" [multi]="false">
|
|
2598
|
+
* <button cngxAccordionPanel id="head-a" panelId="a" controls="region-a">Section A</button>
|
|
2599
|
+
* <div role="region" id="region-a" aria-labelledby="head-a" [hidden]="!acc.isOpen('a')">…</div>
|
|
2600
|
+
* <button cngxAccordionPanel id="head-b" panelId="b" controls="region-b">Section B</button>
|
|
2601
|
+
* <div role="region" id="region-b" aria-labelledby="head-b" [hidden]="!acc.isOpen('b')">…</div>
|
|
2602
|
+
* </div>
|
|
2603
|
+
* ```
|
|
2604
|
+
*
|
|
2605
|
+
* @category common/interactive/accordion
|
|
2606
|
+
* @docsKind primary
|
|
2607
|
+
* @wcag AA
|
|
2608
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/accordion/accordion.directive.ts
|
|
2609
|
+
* @since 0.1.0
|
|
2610
|
+
* @relatedTo CngxAccordionPanel, createAccordionKeyboardNav
|
|
2611
|
+
*/
|
|
2612
|
+
class CngxAccordion {
|
|
2613
|
+
/** Whether more than one panel may stay open at once. */
|
|
2614
|
+
multi = input(false, ...(ngDevMode ? [{ debugName: "multi" }] : /* istanbul ignore next */ []));
|
|
2615
|
+
/**
|
|
2616
|
+
* Controlled set of open panel ids - the accordion's primary value, exposed
|
|
2617
|
+
* as a `model` so a consumer can seed initially-open panels or drive
|
|
2618
|
+
* expansion declaratively (router / SSR). `model()` takes no `equal`, so the
|
|
2619
|
+
* equality discipline lives on {@link effectiveOpenIds} below - the derived
|
|
2620
|
+
* set every panel reads. `toggle()` is the only writer on interaction; the
|
|
2621
|
+
* consumer may also write it. No effect syncs it (Pillar 1).
|
|
2622
|
+
*/
|
|
2623
|
+
openIds = model(new Set(), ...(ngDevMode ? [{ debugName: "openIds" }] : /* istanbul ignore next */ []));
|
|
2624
|
+
// Single-open arbitration is a derivation, never an effect: a consumer-seeded
|
|
2625
|
+
// multi-id set is clamped to the last id when `!multi()`, projecting an
|
|
2626
|
+
// invalid single-mode seed valid without writing it back (controlled-wins).
|
|
2627
|
+
// `setEqual` guards the collection so an identical open-set never re-fires the
|
|
2628
|
+
// panels' `aria-expanded` computeds (Pillar 1 equality discipline).
|
|
2629
|
+
effectiveOpenIds = computed(() => {
|
|
2630
|
+
const ids = this.openIds();
|
|
2631
|
+
return this.multi() || ids.size <= 1 ? ids : new Set([...ids].slice(-1));
|
|
2632
|
+
}, { ...(ngDevMode ? { debugName: "effectiveOpenIds" } : /* istanbul ignore next */ {}), equal: setEqual });
|
|
2633
|
+
// Header registry, keyed by handle identity. `headersEqual` is an
|
|
2634
|
+
// order-independent identity-set compare so a re-register of the same
|
|
2635
|
+
// handles never re-fires the roving derivation.
|
|
2636
|
+
headersState = signal([], { ...(ngDevMode ? { debugName: "headersState" } : /* istanbul ignore next */ {}), equal: headersEqual });
|
|
2637
|
+
headers = this.headersState.asReadonly();
|
|
2638
|
+
/**
|
|
2639
|
+
* The group's single tab stop, derived-not-managed from the registry. When
|
|
2640
|
+
* the registry changes, keep the previous stop while it is still registered
|
|
2641
|
+
* and enabled, else fall back to the first enabled header. Never reset by an
|
|
2642
|
+
* unrelated header registering or unregistering (Pillar 1 preserve-then-
|
|
2643
|
+
* default); `setRovingActive` writes it directly for keyboard movement.
|
|
2644
|
+
*/
|
|
2645
|
+
rovingActiveId = linkedSignal({ ...(ngDevMode ? { debugName: "rovingActiveId" } : /* istanbul ignore next */ {}), source: this.headers,
|
|
2646
|
+
computation: (headers, prev) => headers.some((h) => h.id === prev?.value && !h.disabled())
|
|
2647
|
+
? prev.value
|
|
2648
|
+
: (headers.find((h) => !h.disabled())?.id ?? null) });
|
|
2649
|
+
nav = createAccordionKeyboardNav({ host: this });
|
|
2650
|
+
registerHeader(handle) {
|
|
2651
|
+
this.headersState.update((headers) => headers.includes(handle) ? headers : [...headers, handle]);
|
|
2652
|
+
}
|
|
2653
|
+
unregisterHeader(handle) {
|
|
2654
|
+
this.headersState.update((headers) => headers.filter((h) => h !== handle));
|
|
2655
|
+
}
|
|
2656
|
+
setRovingActive(id) {
|
|
2657
|
+
this.rovingActiveId.set(id);
|
|
2658
|
+
}
|
|
2659
|
+
isOpen(panelId) {
|
|
2660
|
+
return this.effectiveOpenIds().has(panelId);
|
|
2661
|
+
}
|
|
2662
|
+
toggle(panelId) {
|
|
2663
|
+
// Read the clamped set, not the raw model, so the mutate base matches what
|
|
2664
|
+
// isOpen() reports: clicking a panel the clamp has hidden opens it rather
|
|
2665
|
+
// than acting on a stale raw-set membership. Identical to the raw model in
|
|
2666
|
+
// every valid case (clamp == model when multi, or the set holds <= 1 id).
|
|
2667
|
+
const open = this.effectiveOpenIds();
|
|
2668
|
+
// Single mode collapses every sibling by seeding an empty set; multi mode
|
|
2669
|
+
// preserves the others. Either way the coordinator is the only writer.
|
|
2670
|
+
const next = new Set(this.multi() ? open : []);
|
|
2671
|
+
if (open.has(panelId)) {
|
|
2672
|
+
next.delete(panelId);
|
|
2673
|
+
}
|
|
2674
|
+
else {
|
|
2675
|
+
next.add(panelId);
|
|
2676
|
+
}
|
|
2677
|
+
this.openIds.set(next);
|
|
2678
|
+
}
|
|
2679
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAccordion, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2680
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxAccordion, isStandalone: true, selector: "[cngxAccordion]", inputs: { multi: { classPropertyName: "multi", publicName: "multi", isSignal: true, isRequired: false, transformFunction: null }, openIds: { classPropertyName: "openIds", publicName: "openIds", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { openIds: "openIdsChange" }, providers: [{ provide: CNGX_ACCORDION, useExisting: CngxAccordion }], exportAs: ["cngxAccordion"], ngImport: i0 });
|
|
2681
|
+
}
|
|
2682
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAccordion, decorators: [{
|
|
2683
|
+
type: Directive,
|
|
2684
|
+
args: [{
|
|
2685
|
+
selector: '[cngxAccordion]',
|
|
2686
|
+
exportAs: 'cngxAccordion',
|
|
2687
|
+
standalone: true,
|
|
2688
|
+
providers: [{ provide: CNGX_ACCORDION, useExisting: CngxAccordion }],
|
|
2689
|
+
}]
|
|
2690
|
+
}], propDecorators: { multi: [{ type: i0.Input, args: [{ isSignal: true, alias: "multi", required: false }] }], openIds: [{ type: i0.Input, args: [{ isSignal: true, alias: "openIds", required: false }] }, { type: i0.Output, args: ["openIdsChange"] }] } });
|
|
2691
|
+
/**
|
|
2692
|
+
* Order-independent identity-set equality for the header registry. Two arrays
|
|
2693
|
+
* are equal when they hold the same handle references, regardless of
|
|
2694
|
+
* registration order. Handles are stable per panel (carrying `disabled` by
|
|
2695
|
+
* signal reference), so this comparator only suppresses re-fires from a
|
|
2696
|
+
* re-register of the same set; it does not gate the roving derivation on
|
|
2697
|
+
* disabled state - `rovingActiveId` reads each handle's `disabled()` directly,
|
|
2698
|
+
* so a disabled flip still re-runs it (which is what keeps the tab stop off a
|
|
2699
|
+
* newly-disabled header).
|
|
2700
|
+
*/
|
|
2701
|
+
function headersEqual(a, b) {
|
|
2702
|
+
if (a === b) {
|
|
2703
|
+
return true;
|
|
2704
|
+
}
|
|
2705
|
+
if (a.length !== b.length) {
|
|
2706
|
+
return false;
|
|
2707
|
+
}
|
|
2708
|
+
const seen = new Set(b);
|
|
2709
|
+
return a.every((handle) => seen.has(handle));
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
/**
|
|
2713
|
+
* Accordion header. Put `cngxAccordionPanel` on the header `<button>`; the
|
|
2714
|
+
* directive mirrors `aria-expanded` from the coordinator, points
|
|
2715
|
+
* `aria-controls` at the region, and toggles the panel on click. It registers
|
|
2716
|
+
* a header handle with the coordinator on init (and deregisters on destroy),
|
|
2717
|
+
* binds its own roving `tabindex`, and routes `keydown` through the
|
|
2718
|
+
* coordinator's keyboard-nav factory - so arrow/Home/End navigation works even
|
|
2719
|
+
* when a skin renders the header inside its own component view (registration is
|
|
2720
|
+
* immune to the `contentChildren` view boundary).
|
|
2721
|
+
*
|
|
2722
|
+
* Expansion state is never owned here: `aria-expanded` is a `computed()` over
|
|
2723
|
+
* the coordinator's open-set, so single-open arbitration is pure derivation,
|
|
2724
|
+
* not sibling syncing (Pillar 1). Use a native `<button>` so Enter / Space
|
|
2725
|
+
* activate it through the browser's own click synthesis.
|
|
2726
|
+
*
|
|
2727
|
+
* @category common/interactive/accordion
|
|
2728
|
+
* @wcag AA
|
|
2729
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/accordion/accordion-panel.directive.ts
|
|
2730
|
+
* @since 0.1.0
|
|
2731
|
+
* @relatedTo CngxAccordion, createAccordionKeyboardNav
|
|
2732
|
+
*/
|
|
2733
|
+
class CngxAccordionPanel {
|
|
2734
|
+
/** Stable id identifying this panel within its accordion. */
|
|
2735
|
+
panelId = input.required(...(ngDevMode ? [{ debugName: "panelId" }] : /* istanbul ignore next */ []));
|
|
2736
|
+
/** `id` of the region this header controls, bound to `aria-controls`. */
|
|
2737
|
+
controls = input(undefined, ...(ngDevMode ? [{ debugName: "controls" }] : /* istanbul ignore next */ []));
|
|
2738
|
+
/**
|
|
2739
|
+
* Disabled header: skipped by roving, reports `tabindex="-1"` +
|
|
2740
|
+
* `aria-disabled="true"`, and its click never flips the panel open. The
|
|
2741
|
+
* visually-hidden `aria-describedby` reason element is a skin concern owned
|
|
2742
|
+
* by the organism, not this brain directive.
|
|
2743
|
+
*/
|
|
2744
|
+
disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
2745
|
+
accordion = inject(CNGX_ACCORDION);
|
|
2746
|
+
element = inject(ElementRef).nativeElement;
|
|
2747
|
+
destroyRef = inject(DestroyRef);
|
|
2748
|
+
// Set once in ngOnInit. A signal (not a plain field) so the tabindex computed
|
|
2749
|
+
// tracks it reactively instead of relying on write-before-first-read ordering.
|
|
2750
|
+
handle = signal(null, ...(ngDevMode ? [{ debugName: "handle" }] : /* istanbul ignore next */ []));
|
|
2751
|
+
/** `aria-expanded`, derived from the coordinator's open-set. */
|
|
2752
|
+
expanded = computed(() => this.accordion.isOpen(this.panelId()), ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
2753
|
+
/**
|
|
2754
|
+
* Roving `tabindex` for this header, derived from the coordinator's single
|
|
2755
|
+
* `rovingActiveId` source (Pillar 1). `-1` until the handle registers.
|
|
2756
|
+
*/
|
|
2757
|
+
tabindex = computed(() => {
|
|
2758
|
+
const handle = this.handle();
|
|
2759
|
+
return handle ? this.accordion.nav.headerTabindex(handle) : -1;
|
|
2760
|
+
}, ...(ngDevMode ? [{ debugName: "tabindex" }] : /* istanbul ignore next */ []));
|
|
2761
|
+
ngOnInit() {
|
|
2762
|
+
// Register in ngOnInit, not the constructor: the bound `[panelId]` input is
|
|
2763
|
+
// not applied until the first change detection, and the id is the registry
|
|
2764
|
+
// key the coordinator roves and unregisters by.
|
|
2765
|
+
const handle = {
|
|
2766
|
+
id: this.panelId(),
|
|
2767
|
+
element: this.element,
|
|
2768
|
+
disabled: this.disabled,
|
|
2769
|
+
};
|
|
2770
|
+
this.handle.set(handle);
|
|
2771
|
+
this.accordion.registerHeader(handle);
|
|
2772
|
+
this.destroyRef.onDestroy(() => this.accordion.unregisterHeader(handle));
|
|
2773
|
+
}
|
|
2774
|
+
handleKeydown(event) {
|
|
2775
|
+
this.accordion.nav.handleKeydown(event);
|
|
2776
|
+
}
|
|
2777
|
+
toggle() {
|
|
2778
|
+
if (this.disabled()) {
|
|
2779
|
+
return;
|
|
2780
|
+
}
|
|
2781
|
+
this.accordion.toggle(this.panelId());
|
|
2782
|
+
}
|
|
2783
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAccordionPanel, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2784
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxAccordionPanel, isStandalone: true, selector: "[cngxAccordionPanel]", inputs: { panelId: { classPropertyName: "panelId", publicName: "panelId", isSignal: true, isRequired: true, transformFunction: null }, controls: { classPropertyName: "controls", publicName: "controls", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "toggle()", "keydown": "handleKeydown($event)" }, properties: { "attr.aria-expanded": "expanded()", "attr.aria-controls": "controls() ?? null", "attr.aria-disabled": "disabled() || null", "attr.tabindex": "tabindex()" } }, exportAs: ["cngxAccordionPanel"], ngImport: i0 });
|
|
2785
|
+
}
|
|
2786
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAccordionPanel, decorators: [{
|
|
2787
|
+
type: Directive,
|
|
2788
|
+
args: [{
|
|
2789
|
+
selector: '[cngxAccordionPanel]',
|
|
2790
|
+
exportAs: 'cngxAccordionPanel',
|
|
2791
|
+
standalone: true,
|
|
2792
|
+
host: {
|
|
2793
|
+
'[attr.aria-expanded]': 'expanded()',
|
|
2794
|
+
'[attr.aria-controls]': 'controls() ?? null',
|
|
2795
|
+
'[attr.aria-disabled]': 'disabled() || null',
|
|
2796
|
+
'[attr.tabindex]': 'tabindex()',
|
|
2797
|
+
'(click)': 'toggle()',
|
|
2798
|
+
'(keydown)': 'handleKeydown($event)',
|
|
2799
|
+
},
|
|
2800
|
+
}]
|
|
2801
|
+
}], propDecorators: { panelId: [{ type: i0.Input, args: [{ isSignal: true, alias: "panelId", required: true }] }], controls: [{ type: i0.Input, args: [{ isSignal: true, alias: "controls", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
2802
|
+
|
|
2803
|
+
/**
|
|
2804
|
+
* DI token for the {@link CngxBreadcrumbHost} contract. {@link CngxBreadcrumb}
|
|
2805
|
+
* provides it via `useExisting`; each {@link CngxBreadcrumbItem} injects it.
|
|
2806
|
+
*
|
|
2807
|
+
* @category common/interactive/breadcrumb
|
|
2808
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/breadcrumb/breadcrumb.token.ts
|
|
2809
|
+
* @since 0.1.0
|
|
2810
|
+
* @relatedTo CngxBreadcrumb, CngxBreadcrumbItem
|
|
2811
|
+
*/
|
|
2812
|
+
const CNGX_BREADCRUMB = new InjectionToken('CNGX_BREADCRUMB');
|
|
2813
|
+
|
|
2814
|
+
/**
|
|
2815
|
+
* A single crumb. Put `cngxBreadcrumbItem` on the crumb element. Intermediate
|
|
2816
|
+
* crumbs are links (`<a href>`); the terminal crumb may be either a `<span>` or
|
|
2817
|
+
* an `<a [attr.href]="null">` - both derive `aria-current="page"` purely from
|
|
2818
|
+
* position in the trail (no manual flag). The item hides itself with `[hidden]`
|
|
2819
|
+
* when the coordinator collapses it into the overflow menu.
|
|
2820
|
+
*
|
|
2821
|
+
* @category common/interactive/breadcrumb
|
|
2822
|
+
* @wcag AA
|
|
2823
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/breadcrumb/breadcrumb-item.directive.ts
|
|
2824
|
+
* @since 0.1.0
|
|
2825
|
+
* @relatedTo CngxBreadcrumb, CngxBreadcrumbSeparator
|
|
2826
|
+
* <example-url>http://localhost:4200/#/common/interactive/breadcrumb/basic-trail</example-url>
|
|
2827
|
+
*/
|
|
2828
|
+
class CngxBreadcrumbItem {
|
|
2829
|
+
breadcrumb = inject(CNGX_BREADCRUMB);
|
|
2830
|
+
host = inject(ElementRef);
|
|
2831
|
+
/**
|
|
2832
|
+
* Explicit accessible label for the overflow menu, when the crumb's rendered
|
|
2833
|
+
* text is not the right string to list (e.g. an icon-only crumb). Reactive:
|
|
2834
|
+
* bind it when the crumb text is dynamic.
|
|
2835
|
+
*/
|
|
2836
|
+
label = input('', { ...(ngDevMode ? { debugName: "label" } : /* istanbul ignore next */ {}), alias: 'cngxBreadcrumbItemLabel' });
|
|
2837
|
+
/** Whether this is the terminal crumb (the current page). */
|
|
2838
|
+
terminal = computed(() => this.breadcrumb.isTerminal(this), ...(ngDevMode ? [{ debugName: "terminal" }] : /* istanbul ignore next */ []));
|
|
2839
|
+
/** Whether this crumb is collapsed into the overflow menu. */
|
|
2840
|
+
collapsed = computed(() => this.breadcrumb.isCollapsed(this), ...(ngDevMode ? [{ debugName: "collapsed" }] : /* istanbul ignore next */ []));
|
|
2841
|
+
/**
|
|
2842
|
+
* Readable label for the collapsed-crumb list. Prefers the explicit
|
|
2843
|
+
* {@link label} input; otherwise falls back to the projected text.
|
|
2844
|
+
*
|
|
2845
|
+
* The fallback is a **one-shot DOM read at call time**, not reactive - it
|
|
2846
|
+
* reflects the text present when called. For crumbs whose text changes at
|
|
2847
|
+
* runtime, bind `[cngxBreadcrumbItemLabel]` so the reactive path is used.
|
|
2848
|
+
*/
|
|
2849
|
+
resolvedLabel() {
|
|
2850
|
+
const explicit = this.label();
|
|
2851
|
+
if (explicit) {
|
|
2852
|
+
return explicit;
|
|
2853
|
+
}
|
|
2854
|
+
return this.host.nativeElement.textContent?.trim() ?? '';
|
|
2855
|
+
}
|
|
2856
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBreadcrumbItem, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2857
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxBreadcrumbItem, isStandalone: true, selector: "[cngxBreadcrumbItem]", inputs: { label: { classPropertyName: "label", publicName: "cngxBreadcrumbItemLabel", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-current": "terminal() ? 'page' : null", "hidden": "collapsed()" } }, exportAs: ["cngxBreadcrumbItem"], ngImport: i0 });
|
|
2858
|
+
}
|
|
2859
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBreadcrumbItem, decorators: [{
|
|
2860
|
+
type: Directive,
|
|
2861
|
+
args: [{
|
|
2862
|
+
selector: '[cngxBreadcrumbItem]',
|
|
2863
|
+
exportAs: 'cngxBreadcrumbItem',
|
|
2864
|
+
standalone: true,
|
|
2865
|
+
host: {
|
|
2866
|
+
'[attr.aria-current]': "terminal() ? 'page' : null",
|
|
2867
|
+
'[hidden]': 'collapsed()',
|
|
2868
|
+
},
|
|
2869
|
+
}]
|
|
2870
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxBreadcrumbItemLabel", required: false }] }] } });
|
|
2871
|
+
|
|
2872
|
+
const NO_COLLAPSE = new Set();
|
|
2873
|
+
/**
|
|
2874
|
+
* The default collapse rule: keep the first crumb and the last
|
|
2875
|
+
* `maxVisible - 1`, folding the middle into the overflow menu. Returns an empty
|
|
2876
|
+
* set when `maxVisible` is unset/invalid (`< 1`) or the trail already fits
|
|
2877
|
+
* (`total <= maxVisible`), so a short trail never collapses.
|
|
2878
|
+
*
|
|
2879
|
+
* @category common/interactive/breadcrumb
|
|
2880
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/breadcrumb/breadcrumb-collapse.ts
|
|
2881
|
+
* @since 0.1.0
|
|
2882
|
+
* @relatedTo CngxBreadcrumb, CNGX_BREADCRUMB_COLLAPSE_STRATEGY
|
|
2883
|
+
*/
|
|
2884
|
+
function createBreadcrumbCollapse() {
|
|
2885
|
+
return (total, maxVisible) => {
|
|
2886
|
+
if (!maxVisible || maxVisible < 1 || total <= maxVisible) {
|
|
2887
|
+
return NO_COLLAPSE;
|
|
2888
|
+
}
|
|
2889
|
+
const keepTail = maxVisible - 1;
|
|
2890
|
+
const collapsed = new Set();
|
|
2891
|
+
for (let i = 1; i < total - keepTail; i++) {
|
|
2892
|
+
collapsed.add(i);
|
|
2893
|
+
}
|
|
2894
|
+
return collapsed;
|
|
2895
|
+
};
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
/**
|
|
2899
|
+
* DI token for the breadcrumb collapse rule. Defaults to
|
|
2900
|
+
* {@link createBreadcrumbCollapse} (keep the first crumb + the last
|
|
2901
|
+
* `maxVisible - 1`). Override it in `providers` (app-wide) or `viewProviders`
|
|
2902
|
+
* (per {@link CngxBreadcrumb} instance) to swap the rule - width-aware,
|
|
2903
|
+
* keep-first-N, mobile parent-only - without forking the coordinator.
|
|
2904
|
+
*
|
|
2905
|
+
* ```ts
|
|
2906
|
+
* viewProviders: [{
|
|
2907
|
+
* provide: CNGX_BREADCRUMB_COLLAPSE_STRATEGY,
|
|
2908
|
+
* useValue: (total, max) => new Set(range(2, total - 2)),
|
|
2909
|
+
* }]
|
|
2910
|
+
* ```
|
|
2911
|
+
*
|
|
2912
|
+
* @category common/interactive/breadcrumb
|
|
2913
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/breadcrumb/breadcrumb-collapse.token.ts
|
|
2914
|
+
* @since 0.1.0
|
|
2915
|
+
* @relatedTo CngxBreadcrumb, createBreadcrumbCollapse
|
|
2916
|
+
*/
|
|
2917
|
+
const CNGX_BREADCRUMB_COLLAPSE_STRATEGY = new InjectionToken('CNGX_BREADCRUMB_COLLAPSE_STRATEGY', { providedIn: 'root', factory: () => createBreadcrumbCollapse() });
|
|
2918
|
+
|
|
2919
|
+
/**
|
|
2920
|
+
* Linear breadcrumb navigation. Put `cngxBreadcrumb` on the `<nav>`; it names
|
|
2921
|
+
* the landmark (`aria-label`, EN default "Breadcrumb") and, when the trail
|
|
2922
|
+
* exceeds `[maxVisible]`, derives which middle crumbs collapse - keeping the
|
|
2923
|
+
* first crumb and the last `maxVisible - 1`. The collapse set is a `computed()`
|
|
2924
|
+
* over the projected items, so terminal-crumb marking and overflow are pure
|
|
2925
|
+
* derivation, never synced (Pillar 1). Consumers render the collapsed crumbs in
|
|
2926
|
+
* an ellipsis `CngxMenu` and may truncate long labels with `CngxTruncate`.
|
|
2927
|
+
*
|
|
2928
|
+
* ```html
|
|
2929
|
+
* <nav cngxBreadcrumb [maxVisible]="4" #bc="cngxBreadcrumb">
|
|
2930
|
+
* <ol>
|
|
2931
|
+
* <li><a cngxBreadcrumbItem href="/">Home</a></li>
|
|
2932
|
+
* <li cngxBreadcrumbSeparator>/</li>
|
|
2933
|
+
* <li><a cngxBreadcrumbItem href="/library">Library</a></li>
|
|
2934
|
+
* <li cngxBreadcrumbSeparator>/</li>
|
|
2935
|
+
* <li><span cngxBreadcrumbItem>Current page</span></li>
|
|
2936
|
+
* </ol>
|
|
2937
|
+
* </nav>
|
|
2938
|
+
* ```
|
|
2939
|
+
*
|
|
2940
|
+
* @category common/interactive/breadcrumb
|
|
2941
|
+
* @docsKind primary
|
|
2942
|
+
* @wcag AA
|
|
2943
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/breadcrumb/breadcrumb.directive.ts
|
|
2944
|
+
* @since 0.1.0
|
|
2945
|
+
* @relatedTo CngxBreadcrumbItem, CngxBreadcrumbSeparator, CngxBreadcrumbBar
|
|
2946
|
+
* <example-url>http://localhost:4200/#/common/interactive/breadcrumb/basic-trail</example-url>
|
|
2947
|
+
*/
|
|
2948
|
+
class CngxBreadcrumb {
|
|
2949
|
+
/** Accessible name of the navigation landmark. EN default. */
|
|
2950
|
+
label = input('Breadcrumb', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
2951
|
+
/** Maximum crumbs to show before the middle collapses. Unset = never collapse. */
|
|
2952
|
+
maxVisible = input(undefined, ...(ngDevMode ? [{ debugName: "maxVisible" }] : /* istanbul ignore next */ []));
|
|
2953
|
+
/** Swappable collapse rule; defaults to keep-first + last (max - 1). */
|
|
2954
|
+
collapse = inject(CNGX_BREADCRUMB_COLLAPSE_STRATEGY);
|
|
2955
|
+
/** Projected crumbs in DOM order (items may be nested in `<ol>`/`<li>`). */
|
|
2956
|
+
items = contentChildren(CngxBreadcrumbItem, { ...(ngDevMode ? { debugName: "items" } : /* istanbul ignore next */ {}), descendants: true });
|
|
2957
|
+
// Item -> index lookup for isTerminal/isCollapsed (O(1), was O(n) indexOf).
|
|
2958
|
+
// No `equal`: its sole dependency is items(), so it recomputes only when the
|
|
2959
|
+
// item set changes, at which point a fresh WeakMap is the correct downstream
|
|
2960
|
+
// signal - a WeakMap keyed by directive instances has no structural equality.
|
|
2961
|
+
indexByItem = computed(() => {
|
|
2962
|
+
const map = new WeakMap();
|
|
2963
|
+
this.items().forEach((item, index) => map.set(item, index));
|
|
2964
|
+
return map;
|
|
2965
|
+
}, ...(ngDevMode ? [{ debugName: "indexByItem" }] : /* istanbul ignore next */ []));
|
|
2966
|
+
collapsedIndices = computed(() => this.collapse(this.items().length, this.maxVisible() ?? 0), { ...(ngDevMode ? { debugName: "collapsedIndices" } : /* istanbul ignore next */ {}), equal: setEqual });
|
|
2967
|
+
/** The crumbs currently collapsed into the overflow menu, in order. */
|
|
2968
|
+
collapsedItems = computed(() => this.items().filter((_, index) => this.collapsedIndices().has(index)), { ...(ngDevMode ? { debugName: "collapsedItems" } : /* istanbul ignore next */ {}), equal: arrayEqual });
|
|
2969
|
+
/** Whether any crumb is collapsed (drives the ellipsis trigger's visibility). */
|
|
2970
|
+
hasCollapsed = computed(() => this.collapsedIndices().size > 0, ...(ngDevMode ? [{ debugName: "hasCollapsed" }] : /* istanbul ignore next */ []));
|
|
2971
|
+
isTerminal(item) {
|
|
2972
|
+
const index = this.indexByItem().get(item);
|
|
2973
|
+
return index !== undefined && index === this.items().length - 1;
|
|
2974
|
+
}
|
|
2975
|
+
isCollapsed(item) {
|
|
2976
|
+
const index = this.indexByItem().get(item);
|
|
2977
|
+
return index !== undefined && this.collapsedIndices().has(index);
|
|
2978
|
+
}
|
|
2979
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBreadcrumb, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2980
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxBreadcrumb, isStandalone: true, selector: "[cngxBreadcrumb]", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, maxVisible: { classPropertyName: "maxVisible", publicName: "maxVisible", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-label": "label()" } }, providers: [{ provide: CNGX_BREADCRUMB, useExisting: CngxBreadcrumb }], queries: [{ propertyName: "items", predicate: CngxBreadcrumbItem, descendants: true, isSignal: true }], exportAs: ["cngxBreadcrumb"], ngImport: i0 });
|
|
2981
|
+
}
|
|
2982
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBreadcrumb, decorators: [{
|
|
2983
|
+
type: Directive,
|
|
2984
|
+
args: [{
|
|
2985
|
+
selector: '[cngxBreadcrumb]',
|
|
2986
|
+
exportAs: 'cngxBreadcrumb',
|
|
2987
|
+
standalone: true,
|
|
2988
|
+
providers: [{ provide: CNGX_BREADCRUMB, useExisting: CngxBreadcrumb }],
|
|
2989
|
+
host: {
|
|
2990
|
+
'[attr.aria-label]': 'label()',
|
|
2991
|
+
},
|
|
2992
|
+
}]
|
|
2993
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], maxVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxVisible", required: false }] }], items: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => CngxBreadcrumbItem), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
2994
|
+
|
|
2995
|
+
/**
|
|
2996
|
+
* Visual separator between crumbs (slash, chevron, projected icon). Put
|
|
2997
|
+
* `cngxBreadcrumbSeparator` on the separator element; it is marked
|
|
2998
|
+
* `aria-hidden="true"` so assistive tech reads the trail as a clean list of
|
|
2999
|
+
* links without the decorative glyphs.
|
|
3000
|
+
*
|
|
3001
|
+
* @category common/interactive/breadcrumb
|
|
3002
|
+
* @wcag AA
|
|
3003
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/breadcrumb/breadcrumb-separator.directive.ts
|
|
3004
|
+
* @since 0.1.0
|
|
3005
|
+
* @relatedTo CngxBreadcrumb, CngxBreadcrumbItem
|
|
3006
|
+
* <example-url>http://localhost:4200/#/common/interactive/breadcrumb/custom-separator</example-url>
|
|
3007
|
+
*/
|
|
3008
|
+
class CngxBreadcrumbSeparator {
|
|
3009
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBreadcrumbSeparator, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3010
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxBreadcrumbSeparator, isStandalone: true, selector: "[cngxBreadcrumbSeparator]", host: { attributes: { "aria-hidden": "true" } }, exportAs: ["cngxBreadcrumbSeparator"], ngImport: i0 });
|
|
3011
|
+
}
|
|
3012
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBreadcrumbSeparator, decorators: [{
|
|
3013
|
+
type: Directive,
|
|
3014
|
+
args: [{
|
|
3015
|
+
selector: '[cngxBreadcrumbSeparator]',
|
|
3016
|
+
exportAs: 'cngxBreadcrumbSeparator',
|
|
3017
|
+
standalone: true,
|
|
3018
|
+
host: {
|
|
3019
|
+
'aria-hidden': 'true',
|
|
3020
|
+
},
|
|
3021
|
+
}]
|
|
3022
|
+
}] });
|
|
3023
|
+
|
|
3024
|
+
/**
|
|
3025
|
+
* Default width tiers, matching the headless `responsive-collapse` recipe: 640px
|
|
3026
|
+
* and up shows 6, 440px and up shows 4, anything narrower shows 2. The `0` floor
|
|
3027
|
+
* guarantees a match for every non-negative width.
|
|
3028
|
+
*/
|
|
3029
|
+
const DEFAULT_BREADCRUMB_WIDTH_TIERS = [
|
|
3030
|
+
{ minWidth: 640, maxVisible: 6 },
|
|
3031
|
+
{ minWidth: 440, maxVisible: 4 },
|
|
3032
|
+
{ minWidth: 0, maxVisible: 2 },
|
|
3033
|
+
];
|
|
3034
|
+
/**
|
|
3035
|
+
* Pure width->count resolver: returns the `maxVisible` of the tier with the
|
|
3036
|
+
* highest `minWidth` that is still `<= width`. Order-independent - the tier list
|
|
3037
|
+
* is normalised (sorted by descending `minWidth`) before matching, so a consumer
|
|
3038
|
+
* may pass tiers in any order. When `width` sits below every tier's `minWidth`
|
|
3039
|
+
* the narrowest tier's `maxVisible` is the floor; an empty tier list yields
|
|
3040
|
+
* `Number.POSITIVE_INFINITY` (never collapse), leaving the trail intact.
|
|
3041
|
+
*
|
|
3042
|
+
* No DOM, no Angular - the width source (a `CngxResizeObserver`) lives in the
|
|
3043
|
+
* bar; this stays jsdom-testable and shared by the bar and the headless recipe.
|
|
3044
|
+
*
|
|
3045
|
+
* @category common/interactive/breadcrumb
|
|
3046
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/breadcrumb/breadcrumb-responsive.ts
|
|
3047
|
+
* @since 0.1.0
|
|
3048
|
+
* @relatedTo CngxBreadcrumb, CngxBreadcrumbWidthTier, DEFAULT_BREADCRUMB_WIDTH_TIERS
|
|
3049
|
+
*/
|
|
3050
|
+
function resolveBreadcrumbTier(width, tiers) {
|
|
3051
|
+
if (tiers.length === 0) {
|
|
3052
|
+
return Number.POSITIVE_INFINITY;
|
|
3053
|
+
}
|
|
3054
|
+
const sorted = [...tiers].sort((a, b) => b.minWidth - a.minWidth);
|
|
3055
|
+
for (const tier of sorted) {
|
|
3056
|
+
if (width >= tier.minWidth) {
|
|
3057
|
+
return tier.maxVisible;
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
return sorted[sorted.length - 1].maxVisible;
|
|
3061
|
+
}
|
|
3062
|
+
|
|
1508
3063
|
/**
|
|
1509
3064
|
* DI token resolving to the nearest {@link CngxErrorAggregatorContract}
|
|
1510
3065
|
* ancestor.
|
|
@@ -1666,7 +3221,7 @@ class CngxToggle {
|
|
|
1666
3221
|
[attr.aria-hidden]="disabledReason() ? null : 'true'"
|
|
1667
3222
|
>{{ disabledReason() }}</span
|
|
1668
3223
|
>
|
|
1669
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-toggle-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-toggle-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-toggle-disabled-opacity{syntax: \"<number>\"; inherits: false; initial-value: .5;}@property --cngx-toggle-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-toggle-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-toggle-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}@property --cngx-toggle-transition{syntax: \"*\"; inherits: false; initial-value: .15s ease;}@property --cngx-toggle-track-width{syntax: \"*\"; inherits: false; initial-value: 2.25rem;}@property --cngx-toggle-track-height{syntax: \"*\"; inherits: false; initial-value: 1.25rem;}@property --cngx-toggle-track-radius{syntax: \"<length>\"; inherits: false; initial-value: 9999px;}@property --cngx-toggle-track-bg-off{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .25);}@property --cngx-toggle-track-bg-on{syntax: \"<color>\"; inherits: false; initial-value: oklch(.66 .19 50);}@property --cngx-toggle-thumb-inset{syntax: \"*\"; inherits:
|
|
3224
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-toggle-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-toggle-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-toggle-disabled-opacity{syntax: \"<number>\"; inherits: false; initial-value: .5;}@property --cngx-toggle-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-toggle-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-toggle-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}@property --cngx-toggle-transition{syntax: \"*\"; inherits: false; initial-value: .15s ease;}@property --cngx-toggle-track-width{syntax: \"*\"; inherits: false; initial-value: 2.25rem;}@property --cngx-toggle-track-height{syntax: \"*\"; inherits: false; initial-value: 1.25rem;}@property --cngx-toggle-track-radius{syntax: \"<length>\"; inherits: false; initial-value: 9999px;}@property --cngx-toggle-track-bg-off{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .25);}@property --cngx-toggle-track-bg-on{syntax: \"<color>\"; inherits: false; initial-value: oklch(.66 .19 50);}@property --cngx-toggle-thumb-inset{syntax: \"*\"; inherits: true; initial-value: .125rem;}@property --cngx-toggle-thumb-size{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-toggle-thumb-travel{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-toggle-thumb-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(1 0 0);}@property --cngx-toggle-thumb-shadow{syntax: \"*\"; inherits: false; initial-value: 0 1px 2px oklch(0 0 0 / .25);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-toggle-track-bg-off: oklch(1 0 0 / .25)}}[data-color-scheme=dark],.dark{--cngx-toggle-track-bg-off: oklch(1 0 0 / .25)}[data-color-scheme=light],.light{--cngx-toggle-track-bg-off: oklch(0 0 0 / .25)}}@layer cngx.components{@scope(.cngx-toggle){:scope{--cngx-toggle-gap: var(--cngx-space-sm);--cngx-toggle-thumb-inset: var(--cngx-space-xs);display:inline-flex;align-items:center;gap:var(--cngx-toggle-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-toggle-color, inherit)}:scope.cngx-toggle--label-before{flex-direction:row-reverse}:scope.cngx-toggle--disabled{cursor:not-allowed;opacity:var(--cngx-toggle-disabled-opacity, .5)}:scope:focus-visible{outline:var(--cngx-toggle-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-toggle-focus-offset, 2px);border-radius:var(--cngx-toggle-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-toggle__track{position:relative;flex:0 0 auto;inline-size:var(--cngx-toggle-track-width, 2.25rem);block-size:var(--cngx-toggle-track-height, 1.25rem);border-radius:var(--cngx-toggle-track-radius, var(--cngx-radius-pill, 9999px));background:var(--cngx-toggle-track-bg-off, oklch(0 0 0 / .25));transition:background-color var(--cngx-toggle-transition, .15s ease)}:scope.cngx-toggle--checked .cngx-toggle__track{background:var(--cngx-toggle-track-bg-on, var(--cngx-color-primary, oklch(.66 .19 50)))}.cngx-toggle__thumb{position:absolute;inset-block-start:var(--cngx-toggle-thumb-inset, .125rem);inset-inline-start:var(--cngx-toggle-thumb-inset, .125rem);inline-size:var(--cngx-toggle-thumb-size, 1rem);block-size:var(--cngx-toggle-thumb-size, 1rem);display:inline-flex;align-items:center;justify-content:center;line-height:1;border-radius:50%;background:var(--cngx-toggle-thumb-bg, oklch(1 0 0));box-shadow:var(--cngx-toggle-thumb-shadow, 0 1px 2px oklch(0 0 0 / .25));transition:transform var(--cngx-toggle-transition, .15s ease)}.cngx-toggle__thumb:has(*){background:transparent;box-shadow:none;font-size:var(--cngx-toggle-thumb-size, 1rem);color:var(--cngx-toggle-thumb-bg, oklch(1 0 0))}:scope.cngx-toggle--checked .cngx-toggle__thumb{transform:translate(var(--cngx-toggle-thumb-travel, 1rem))}.cngx-toggle__label{flex:0 1 auto;min-inline-size:0}.cngx-toggle__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(prefers-reduced-motion:reduce){.cngx-toggle__track,.cngx-toggle__thumb{transition:none}}}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1670
3225
|
}
|
|
1671
3226
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToggle, decorators: [{
|
|
1672
3227
|
type: Component,
|
|
@@ -1708,7 +3263,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1708
3263
|
[attr.aria-hidden]="disabledReason() ? null : 'true'"
|
|
1709
3264
|
>{{ disabledReason() }}</span
|
|
1710
3265
|
>
|
|
1711
|
-
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-toggle-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-toggle-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-toggle-disabled-opacity{syntax: \"<number>\"; inherits: false; initial-value: .5;}@property --cngx-toggle-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-toggle-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-toggle-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}@property --cngx-toggle-transition{syntax: \"*\"; inherits: false; initial-value: .15s ease;}@property --cngx-toggle-track-width{syntax: \"*\"; inherits: false; initial-value: 2.25rem;}@property --cngx-toggle-track-height{syntax: \"*\"; inherits: false; initial-value: 1.25rem;}@property --cngx-toggle-track-radius{syntax: \"<length>\"; inherits: false; initial-value: 9999px;}@property --cngx-toggle-track-bg-off{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .25);}@property --cngx-toggle-track-bg-on{syntax: \"<color>\"; inherits: false; initial-value: oklch(.66 .19 50);}@property --cngx-toggle-thumb-inset{syntax: \"*\"; inherits:
|
|
3266
|
+
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-toggle-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-toggle-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-toggle-disabled-opacity{syntax: \"<number>\"; inherits: false; initial-value: .5;}@property --cngx-toggle-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-toggle-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-toggle-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}@property --cngx-toggle-transition{syntax: \"*\"; inherits: false; initial-value: .15s ease;}@property --cngx-toggle-track-width{syntax: \"*\"; inherits: false; initial-value: 2.25rem;}@property --cngx-toggle-track-height{syntax: \"*\"; inherits: false; initial-value: 1.25rem;}@property --cngx-toggle-track-radius{syntax: \"<length>\"; inherits: false; initial-value: 9999px;}@property --cngx-toggle-track-bg-off{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .25);}@property --cngx-toggle-track-bg-on{syntax: \"<color>\"; inherits: false; initial-value: oklch(.66 .19 50);}@property --cngx-toggle-thumb-inset{syntax: \"*\"; inherits: true; initial-value: .125rem;}@property --cngx-toggle-thumb-size{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-toggle-thumb-travel{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-toggle-thumb-bg{syntax: \"<color>\"; inherits: false; initial-value: oklch(1 0 0);}@property --cngx-toggle-thumb-shadow{syntax: \"*\"; inherits: false; initial-value: 0 1px 2px oklch(0 0 0 / .25);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-toggle-track-bg-off: oklch(1 0 0 / .25)}}[data-color-scheme=dark],.dark{--cngx-toggle-track-bg-off: oklch(1 0 0 / .25)}[data-color-scheme=light],.light{--cngx-toggle-track-bg-off: oklch(0 0 0 / .25)}}@layer cngx.components{@scope(.cngx-toggle){:scope{--cngx-toggle-gap: var(--cngx-space-sm);--cngx-toggle-thumb-inset: var(--cngx-space-xs);display:inline-flex;align-items:center;gap:var(--cngx-toggle-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-toggle-color, inherit)}:scope.cngx-toggle--label-before{flex-direction:row-reverse}:scope.cngx-toggle--disabled{cursor:not-allowed;opacity:var(--cngx-toggle-disabled-opacity, .5)}:scope:focus-visible{outline:var(--cngx-toggle-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-toggle-focus-offset, 2px);border-radius:var(--cngx-toggle-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-toggle__track{position:relative;flex:0 0 auto;inline-size:var(--cngx-toggle-track-width, 2.25rem);block-size:var(--cngx-toggle-track-height, 1.25rem);border-radius:var(--cngx-toggle-track-radius, var(--cngx-radius-pill, 9999px));background:var(--cngx-toggle-track-bg-off, oklch(0 0 0 / .25));transition:background-color var(--cngx-toggle-transition, .15s ease)}:scope.cngx-toggle--checked .cngx-toggle__track{background:var(--cngx-toggle-track-bg-on, var(--cngx-color-primary, oklch(.66 .19 50)))}.cngx-toggle__thumb{position:absolute;inset-block-start:var(--cngx-toggle-thumb-inset, .125rem);inset-inline-start:var(--cngx-toggle-thumb-inset, .125rem);inline-size:var(--cngx-toggle-thumb-size, 1rem);block-size:var(--cngx-toggle-thumb-size, 1rem);display:inline-flex;align-items:center;justify-content:center;line-height:1;border-radius:50%;background:var(--cngx-toggle-thumb-bg, oklch(1 0 0));box-shadow:var(--cngx-toggle-thumb-shadow, 0 1px 2px oklch(0 0 0 / .25));transition:transform var(--cngx-toggle-transition, .15s ease)}.cngx-toggle__thumb:has(*){background:transparent;box-shadow:none;font-size:var(--cngx-toggle-thumb-size, 1rem);color:var(--cngx-toggle-thumb-bg, oklch(1 0 0))}:scope.cngx-toggle--checked .cngx-toggle__thumb{transform:translate(var(--cngx-toggle-thumb-travel, 1rem))}.cngx-toggle__label{flex:0 1 auto;min-inline-size:0}.cngx-toggle__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(prefers-reduced-motion:reduce){.cngx-toggle__track,.cngx-toggle__thumb{transition:none}}}}\n"] }]
|
|
1712
3267
|
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], disabledReason: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledReason", required: false }] }], labelPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelPosition", required: false }] }], thumbGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "thumbGlyph", required: false }] }] } });
|
|
1713
3268
|
|
|
1714
3269
|
/**
|
|
@@ -1869,7 +3424,7 @@ class CngxCheckbox {
|
|
|
1869
3424
|
[attr.aria-hidden]="disabledReason() ? null : 'true'"
|
|
1870
3425
|
>{{ disabledReason() }}</span
|
|
1871
3426
|
>
|
|
1872
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-checkbox-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-checkbox-sibling-gap{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-checkbox-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-checkbox-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-checkbox-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-checkbox){:scope{display:inline-flex;align-items:center;gap:var(--cngx-checkbox-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-checkbox-color, inherit);vertical-align:middle}:scope.cngx-checkbox--disabled{cursor:not-allowed;opacity:var(--cngx-checkbox-disabled-opacity, .5)}:scope:focus-visible{outline:var(--cngx-checkbox-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-checkbox-focus-offset, 2px);border-radius:var(--cngx-checkbox-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-checkbox__label{flex:0 1 auto;min-inline-size:0}.cngx-checkbox__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}.cngx-checkbox+.cngx-checkbox{margin-inline-start:var(--cngx-checkbox-sibling-gap, 1rem)}}\n"], dependencies: [{ kind: "component", type: CngxCheckboxIndicator, selector: "cngx-checkbox-indicator", inputs: ["variant", "checked", "indeterminate", "disabled", "size", "checkGlyph", "dashGlyph"], exportAs: ["cngxCheckboxIndicator"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
3427
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-checkbox-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-checkbox-sibling-gap{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-checkbox-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-checkbox-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-checkbox-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-checkbox){:scope{--cngx-checkbox-gap: var(--cngx-space-sm);--cngx-checkbox-sibling-gap: var(--cngx-space-md);display:inline-flex;align-items:center;gap:var(--cngx-checkbox-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-checkbox-color, inherit);vertical-align:middle}:scope.cngx-checkbox--disabled{cursor:not-allowed;opacity:var(--cngx-checkbox-disabled-opacity, .5)}:scope:focus-visible{outline:var(--cngx-checkbox-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-checkbox-focus-offset, 2px);border-radius:var(--cngx-checkbox-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-checkbox__label{flex:0 1 auto;min-inline-size:0}.cngx-checkbox__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}.cngx-checkbox+.cngx-checkbox{margin-inline-start:var(--cngx-checkbox-sibling-gap, 1rem)}}\n"], dependencies: [{ kind: "component", type: CngxCheckboxIndicator, selector: "cngx-checkbox-indicator", inputs: ["variant", "checked", "indeterminate", "disabled", "size", "checkGlyph", "dashGlyph"], exportAs: ["cngxCheckboxIndicator"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
1873
3428
|
}
|
|
1874
3429
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCheckbox, decorators: [{
|
|
1875
3430
|
type: Component,
|
|
@@ -1917,7 +3472,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1917
3472
|
[attr.aria-hidden]="disabledReason() ? null : 'true'"
|
|
1918
3473
|
>{{ disabledReason() }}</span
|
|
1919
3474
|
>
|
|
1920
|
-
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-checkbox-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-checkbox-sibling-gap{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-checkbox-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-checkbox-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-checkbox-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-checkbox){:scope{display:inline-flex;align-items:center;gap:var(--cngx-checkbox-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-checkbox-color, inherit);vertical-align:middle}:scope.cngx-checkbox--disabled{cursor:not-allowed;opacity:var(--cngx-checkbox-disabled-opacity, .5)}:scope:focus-visible{outline:var(--cngx-checkbox-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-checkbox-focus-offset, 2px);border-radius:var(--cngx-checkbox-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-checkbox__label{flex:0 1 auto;min-inline-size:0}.cngx-checkbox__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}.cngx-checkbox+.cngx-checkbox{margin-inline-start:var(--cngx-checkbox-sibling-gap, 1rem)}}\n"] }]
|
|
3475
|
+
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-checkbox-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-checkbox-sibling-gap{syntax: \"*\"; inherits: false; initial-value: 1rem;}@property --cngx-checkbox-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-checkbox-focus-offset{syntax: \"*\"; inherits: false; initial-value: 2px;}@property --cngx-checkbox-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-checkbox){:scope{--cngx-checkbox-gap: var(--cngx-space-sm);--cngx-checkbox-sibling-gap: var(--cngx-space-md);display:inline-flex;align-items:center;gap:var(--cngx-checkbox-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-checkbox-color, inherit);vertical-align:middle}:scope.cngx-checkbox--disabled{cursor:not-allowed;opacity:var(--cngx-checkbox-disabled-opacity, .5)}:scope:focus-visible{outline:var(--cngx-checkbox-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-checkbox-focus-offset, 2px);border-radius:var(--cngx-checkbox-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-checkbox__label{flex:0 1 auto;min-inline-size:0}.cngx-checkbox__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}.cngx-checkbox+.cngx-checkbox{margin-inline-start:var(--cngx-checkbox-sibling-gap, 1rem)}}\n"] }]
|
|
1921
3476
|
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], indeterminate: [{ type: i0.Input, args: [{ isSignal: true, alias: "indeterminate", required: false }] }, { type: i0.Output, args: ["indeterminateChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], disabledReason: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledReason", required: false }] }], checkGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "checkGlyph", required: false }] }], dashGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "dashGlyph", required: false }] }] } });
|
|
1922
3477
|
|
|
1923
3478
|
/**
|
|
@@ -2087,7 +3642,7 @@ class CngxCheckboxGroup {
|
|
|
2087
3642
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxCheckboxGroup, isStandalone: true, selector: "cngx-checkbox-group, [cngxCheckboxGroup]", inputs: { selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, allValues: { classPropertyName: "allValues", publicName: "allValues", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, keyFn: { classPropertyName: "keyFn", publicName: "keyFn", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedValues: "selectedValuesChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "group" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "ariaInvalid() ? \"true\" : null", "attr.aria-errormessage": "ariaInvalid() ? errorMessageId() : null", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-checkbox-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-checkbox-group" }, providers: [
|
|
2088
3643
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxCheckboxGroup },
|
|
2089
3644
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxCheckboxGroup },
|
|
2090
|
-
], exportAs: ["cngxCheckboxGroup"], hostDirectives: [{ directive: i1.CngxRovingTabindex, inputs: ["orientation", "orientation"] }], ngImport: i0, template: `<ng-content />`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-checkbox-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-checkbox-group){:scope{display:inline-flex;flex-direction:column;gap:var(--cngx-checkbox-group-gap, var(--cngx-space-sm, .5rem))}:scope.cngx-checkbox-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
3645
|
+
], exportAs: ["cngxCheckboxGroup"], hostDirectives: [{ directive: i1.CngxRovingTabindex, inputs: ["orientation", "orientation"] }], ngImport: i0, template: `<ng-content />`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-checkbox-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-checkbox-group){:scope{--cngx-checkbox-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var(--cngx-checkbox-group-gap, var(--cngx-space-sm, .5rem))}:scope.cngx-checkbox-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2091
3646
|
}
|
|
2092
3647
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCheckboxGroup, decorators: [{
|
|
2093
3648
|
type: Component,
|
|
@@ -2112,7 +3667,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2112
3667
|
}, providers: [
|
|
2113
3668
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxCheckboxGroup },
|
|
2114
3669
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxCheckboxGroup },
|
|
2115
|
-
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-checkbox-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-checkbox-group){:scope{display:inline-flex;flex-direction:column;gap:var(--cngx-checkbox-group-gap, var(--cngx-space-sm, .5rem))}:scope.cngx-checkbox-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"] }]
|
|
3670
|
+
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-checkbox-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-checkbox-group){:scope{--cngx-checkbox-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var(--cngx-checkbox-group-gap, var(--cngx-space-sm, .5rem))}:scope.cngx-checkbox-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"] }]
|
|
2116
3671
|
}], ctorParameters: () => [], propDecorators: { selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], allValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "allValues", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], keyFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyFn", required: false }] }] } });
|
|
2117
3672
|
|
|
2118
3673
|
/**
|
|
@@ -2152,13 +3707,14 @@ const CNGX_BUTTON_TOGGLE_GROUP = new InjectionToken('CngxButtonToggleGroup');
|
|
|
2152
3707
|
* `CNGX_BUTTON_MULTI_TOGGLE_GROUP` (`{ optional: true }` on both)
|
|
2153
3708
|
* and chooses its ARIA pattern at injection time, not at runtime.
|
|
2154
3709
|
*
|
|
2155
|
-
* Auto-select wiring follows the same
|
|
2156
|
-
*
|
|
2157
|
-
*
|
|
2158
|
-
* (
|
|
2159
|
-
* `(
|
|
2160
|
-
*
|
|
2161
|
-
*
|
|
3710
|
+
* Auto-select wiring follows the same contract as `CngxRadioGroup`:
|
|
3711
|
+
* the host `CngxRovingTabindex` raises its navigation-key intent before
|
|
3712
|
+
* it moves focus; each focused leaf consumes that intent in its
|
|
3713
|
+
* `(focus)` handler via `consumePendingArrowSelect()`, which reads
|
|
3714
|
+
* `roving.consumeNavigationKey()`. Reading an already-set fact (instead
|
|
3715
|
+
* of a group-owned `(keydown)` flag) closes the one-press-behind race
|
|
3716
|
+
* (#135). The value write happens inside a DOM event handler - never
|
|
3717
|
+
* inside an `effect()`.
|
|
2162
3718
|
*
|
|
2163
3719
|
* ```html
|
|
2164
3720
|
* <cngx-button-toggle-group label="Layout" [(value)]="view">
|
|
@@ -2178,9 +3734,6 @@ const CNGX_BUTTON_TOGGLE_GROUP = new InjectionToken('CngxButtonToggleGroup');
|
|
|
2178
3734
|
* <example-url>http://localhost:4200/#/common/interactive/button-toggle/group/basic-view-switcher</example-url>
|
|
2179
3735
|
* <example-url>http://localhost:4200/#/common/interactive/button-toggle/group/disabled-group-cascade-vs-per-toggle</example-url>
|
|
2180
3736
|
* <example-url>http://localhost:4200/#/common/interactive/button-toggle/group/vertical-orientation</example-url>
|
|
2181
|
-
* <example-url>http://localhost:4200/#/forms/field/form-primitives/coming-in-a-follow-up</example-url>
|
|
2182
|
-
* <example-url>http://localhost:4200/#/forms/field/form-primitives/reactive-forms-same-atom-just-bind-formcontrol</example-url>
|
|
2183
|
-
* <example-url>http://localhost:4200/#/forms/field/form-primitives/signal-forms-drop-the-atom-into-cngx-form-field</example-url>
|
|
2184
3737
|
*/
|
|
2185
3738
|
class CngxButtonToggleGroup {
|
|
2186
3739
|
value = model(undefined, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
@@ -2206,28 +3759,17 @@ class CngxButtonToggleGroup {
|
|
|
2206
3759
|
label = input(undefined, ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
2207
3760
|
state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
2208
3761
|
ariaBusy = computed(() => this.state()?.status() === 'loading', ...(ngDevMode ? [{ debugName: "ariaBusy" }] : /* istanbul ignore next */ []));
|
|
2209
|
-
|
|
3762
|
+
roving = inject(CngxRovingTabindex, { host: true });
|
|
2210
3763
|
consumePendingArrowSelect(value) {
|
|
2211
|
-
if (!this.
|
|
3764
|
+
if (!this.roving.consumeNavigationKey()) {
|
|
2212
3765
|
return false;
|
|
2213
3766
|
}
|
|
2214
|
-
this.pendingArrowSelect = false;
|
|
2215
3767
|
if (this.disabled()) {
|
|
2216
3768
|
return false;
|
|
2217
3769
|
}
|
|
2218
3770
|
this.value.set(value);
|
|
2219
3771
|
return true;
|
|
2220
3772
|
}
|
|
2221
|
-
handleKeydown(event) {
|
|
2222
|
-
const key = event.key;
|
|
2223
|
-
this.pendingArrowSelect =
|
|
2224
|
-
key === 'ArrowUp' ||
|
|
2225
|
-
key === 'ArrowDown' ||
|
|
2226
|
-
key === 'ArrowLeft' ||
|
|
2227
|
-
key === 'ArrowRight' ||
|
|
2228
|
-
key === 'Home' ||
|
|
2229
|
-
key === 'End';
|
|
2230
|
-
}
|
|
2231
3773
|
id = signal(nextUid('cngx-button-toggle-group-')).asReadonly();
|
|
2232
3774
|
focusedState = signal(false, ...(ngDevMode ? [{ debugName: "focusedState" }] : /* istanbul ignore next */ []));
|
|
2233
3775
|
focused = this.focusedState.asReadonly();
|
|
@@ -2247,7 +3789,7 @@ class CngxButtonToggleGroup {
|
|
|
2247
3789
|
this.fieldHost?.markAsTouched();
|
|
2248
3790
|
}
|
|
2249
3791
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxButtonToggleGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2250
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxButtonToggleGroup, isStandalone: true, selector: "cngx-button-toggle-group, [cngxButtonToggleGroup]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "radiogroup" }, listeners: { "
|
|
3792
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxButtonToggleGroup, isStandalone: true, selector: "cngx-button-toggle-group, [cngxButtonToggleGroup]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "radiogroup" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-orientation": "orientation()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-button-toggle-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-button-toggle-group" }, providers: [
|
|
2251
3793
|
{ provide: CNGX_BUTTON_TOGGLE_GROUP, useExisting: CngxButtonToggleGroup },
|
|
2252
3794
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxButtonToggleGroup },
|
|
2253
3795
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxButtonToggleGroup },
|
|
@@ -2272,7 +3814,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2272
3814
|
'[attr.aria-orientation]': 'orientation()',
|
|
2273
3815
|
'[attr.aria-busy]': 'ariaBusy() ? "true" : null',
|
|
2274
3816
|
'[class.cngx-button-toggle-group--horizontal]': 'orientation() === "horizontal"',
|
|
2275
|
-
'(keydown)': 'handleKeydown($event)',
|
|
2276
3817
|
'(focusin)': 'handleFocusIn()',
|
|
2277
3818
|
'(focusout)': 'handleFocusOut()',
|
|
2278
3819
|
}, providers: [
|
|
@@ -2660,16 +4201,17 @@ const CNGX_RADIO_GROUP = new InjectionToken('CngxRadioGroup');
|
|
|
2660
4201
|
* **Auto-select wiring (no signal-write-in-effect).** Per the
|
|
2661
4202
|
* pillar §6 hard rule, the group does NOT subscribe to
|
|
2662
4203
|
* `CngxRovingTabindex.activeIndex` via an effect that writes
|
|
2663
|
-
* `value`. Instead, the
|
|
2664
|
-
*
|
|
2665
|
-
*
|
|
2666
|
-
*
|
|
2667
|
-
* `
|
|
2668
|
-
*
|
|
2669
|
-
*
|
|
2670
|
-
*
|
|
2671
|
-
*
|
|
2672
|
-
* Tab leaves the
|
|
4204
|
+
* `value`. Instead, the host `CngxRovingTabindex` raises its
|
|
4205
|
+
* navigation-key intent before it moves focus; the newly-focused
|
|
4206
|
+
* leaf's `(focus)` handler calls
|
|
4207
|
+
* `group.consumePendingArrowSelect(this.value())`, which reads
|
|
4208
|
+
* `roving.consumeNavigationKey()` and writes `value` (a signal write
|
|
4209
|
+
* inside a DOM event handler, not an effect - legal under the pillar
|
|
4210
|
+
* rules). Reading an already-set fact instead of a group-owned
|
|
4211
|
+
* `(keydown)` flag closes the one-press-behind race (#135).
|
|
4212
|
+
* Tab-into-group fires focus without a preceding navigation key, so
|
|
4213
|
+
* the hook reads false and no auto-select happens - Tab leaves the
|
|
4214
|
+
* consumer's `value` untouched.
|
|
2673
4215
|
*
|
|
2674
4216
|
* ```html
|
|
2675
4217
|
* <cngx-radio-group [(value)]="payment" name="payment-method">
|
|
@@ -2690,9 +4232,6 @@ const CNGX_RADIO_GROUP = new InjectionToken('CngxRadioGroup');
|
|
|
2690
4232
|
* <example-url>http://localhost:4200/#/common/interactive/radio/custom-dot-glyph</example-url>
|
|
2691
4233
|
* <example-url>http://localhost:4200/#/common/interactive/radio/disabled-group-cascades-per-radio-overrides</example-url>
|
|
2692
4234
|
* <example-url>http://localhost:4200/#/common/interactive/radio/orientation-horizontal</example-url>
|
|
2693
|
-
* <example-url>http://localhost:4200/#/forms/field/form-primitives/coming-in-a-follow-up</example-url>
|
|
2694
|
-
* <example-url>http://localhost:4200/#/forms/field/form-primitives/reactive-forms-same-atom-just-bind-formcontrol</example-url>
|
|
2695
|
-
* <example-url>http://localhost:4200/#/forms/field/form-primitives/signal-forms-drop-the-atom-into-cngx-form-field</example-url>
|
|
2696
4235
|
*/
|
|
2697
4236
|
class CngxRadioGroup {
|
|
2698
4237
|
value = model(undefined, ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
@@ -2722,7 +4261,7 @@ class CngxRadioGroup {
|
|
|
2722
4261
|
fallbackName = nextUid('cngx-radio-group');
|
|
2723
4262
|
name = computed(() => this.nameInput() ?? this.fallbackName, ...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
2724
4263
|
registry = new Map();
|
|
2725
|
-
|
|
4264
|
+
roving = inject(CngxRovingTabindex, { host: true });
|
|
2726
4265
|
id = signal(nextUid('cngx-radio-group-')).asReadonly();
|
|
2727
4266
|
focusedState = signal(false, ...(ngDevMode ? [{ debugName: "focusedState" }] : /* istanbul ignore next */ []));
|
|
2728
4267
|
focused = this.focusedState.asReadonly();
|
|
@@ -2741,7 +4280,7 @@ class CngxRadioGroup {
|
|
|
2741
4280
|
direction only, never the keyboard axis. Force the host
|
|
2742
4281
|
roving directive to `'both'` so a vertical group still
|
|
2743
4282
|
responds to ArrowLeft / ArrowRight and vice versa. */
|
|
2744
|
-
|
|
4283
|
+
this.roving.orientation.set('both');
|
|
2745
4284
|
}
|
|
2746
4285
|
register(radio) {
|
|
2747
4286
|
this.registry.set(radio.id, radio);
|
|
@@ -2750,26 +4289,15 @@ class CngxRadioGroup {
|
|
|
2750
4289
|
this.registry.delete(id);
|
|
2751
4290
|
}
|
|
2752
4291
|
consumePendingArrowSelect(value) {
|
|
2753
|
-
if (!this.
|
|
4292
|
+
if (!this.roving.consumeNavigationKey()) {
|
|
2754
4293
|
return false;
|
|
2755
4294
|
}
|
|
2756
|
-
this.pendingArrowSelect = false;
|
|
2757
4295
|
if (this.disabled()) {
|
|
2758
4296
|
return false;
|
|
2759
4297
|
}
|
|
2760
4298
|
this.value.set(value);
|
|
2761
4299
|
return true;
|
|
2762
4300
|
}
|
|
2763
|
-
handleKeydown(event) {
|
|
2764
|
-
const key = event.key;
|
|
2765
|
-
this.pendingArrowSelect =
|
|
2766
|
-
key === 'ArrowUp' ||
|
|
2767
|
-
key === 'ArrowDown' ||
|
|
2768
|
-
key === 'ArrowLeft' ||
|
|
2769
|
-
key === 'ArrowRight' ||
|
|
2770
|
-
key === 'Home' ||
|
|
2771
|
-
key === 'End';
|
|
2772
|
-
}
|
|
2773
4301
|
handleFocusIn() {
|
|
2774
4302
|
this.focusedState.set(true);
|
|
2775
4303
|
}
|
|
@@ -2778,11 +4306,11 @@ class CngxRadioGroup {
|
|
|
2778
4306
|
this.fieldHost?.markAsTouched();
|
|
2779
4307
|
}
|
|
2780
4308
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRadioGroup, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2781
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxRadioGroup, isStandalone: true, selector: "cngx-radio-group, [cngxRadioGroup]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, nameInput: { classPropertyName: "nameInput", publicName: "name", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "radiogroup" }, listeners: { "
|
|
4309
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxRadioGroup, isStandalone: true, selector: "cngx-radio-group, [cngxRadioGroup]", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, nameInput: { classPropertyName: "nameInput", publicName: "name", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange" }, host: { attributes: { "role": "radiogroup" }, listeners: { "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "attr.id": "id()", "attr.aria-label": "label()", "attr.aria-disabled": "disabled() ? \"true\" : null", "attr.aria-required": "required() ? \"true\" : null", "attr.aria-invalid": "(invalid() || errorState()) ? \"true\" : null", "attr.aria-errormessage": "errorMessageId()", "attr.aria-orientation": "orientation()", "attr.aria-busy": "ariaBusy() ? \"true\" : null", "class.cngx-radio-group--horizontal": "orientation() === \"horizontal\"" }, classAttribute: "cngx-radio-group" }, providers: [
|
|
2782
4310
|
{ provide: CNGX_RADIO_GROUP, useExisting: CngxRadioGroup },
|
|
2783
4311
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxRadioGroup },
|
|
2784
4312
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxRadioGroup },
|
|
2785
|
-
], exportAs: ["cngxRadioGroup"], hostDirectives: [{ directive: i1.CngxRovingTabindex }], ngImport: i0, template: `<ng-content />`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-radio-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-radio-group){:scope{display:inline-flex;flex-direction:column;gap:var(--cngx-radio-group-gap, var(--cngx-space-sm, .5rem));vertical-align:top}:scope.cngx-radio-group--horizontal{flex-direction:row}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
4313
|
+
], exportAs: ["cngxRadioGroup"], hostDirectives: [{ directive: i1.CngxRovingTabindex }], ngImport: i0, template: `<ng-content />`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-radio-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-radio-group){:scope{--cngx-radio-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var(--cngx-radio-group-gap, var(--cngx-space-sm, .5rem));vertical-align:top}:scope.cngx-radio-group--horizontal{flex-direction:row}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2786
4314
|
}
|
|
2787
4315
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRadioGroup, decorators: [{
|
|
2788
4316
|
type: Component,
|
|
@@ -2798,14 +4326,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2798
4326
|
'[attr.aria-orientation]': 'orientation()',
|
|
2799
4327
|
'[attr.aria-busy]': 'ariaBusy() ? "true" : null',
|
|
2800
4328
|
'[class.cngx-radio-group--horizontal]': 'orientation() === "horizontal"',
|
|
2801
|
-
'(keydown)': 'handleKeydown($event)',
|
|
2802
4329
|
'(focusin)': 'handleFocusIn()',
|
|
2803
4330
|
'(focusout)': 'handleFocusOut()',
|
|
2804
4331
|
}, providers: [
|
|
2805
4332
|
{ provide: CNGX_RADIO_GROUP, useExisting: CngxRadioGroup },
|
|
2806
4333
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxRadioGroup },
|
|
2807
4334
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxRadioGroup },
|
|
2808
|
-
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-radio-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-radio-group){:scope{display:inline-flex;flex-direction:column;gap:var(--cngx-radio-group-gap, var(--cngx-space-sm, .5rem));vertical-align:top}:scope.cngx-radio-group--horizontal{flex-direction:row}}}\n"] }]
|
|
4335
|
+
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-radio-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-radio-group){:scope{--cngx-radio-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var(--cngx-radio-group-gap, var(--cngx-space-sm, .5rem));vertical-align:top}:scope.cngx-radio-group--horizontal{flex-direction:row}}}\n"] }]
|
|
2809
4336
|
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], nameInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }] } });
|
|
2810
4337
|
|
|
2811
4338
|
/**
|
|
@@ -2911,7 +4438,7 @@ class CngxRadio {
|
|
|
2911
4438
|
[attr.aria-hidden]="disabledReason() ? null : 'true'"
|
|
2912
4439
|
>{{ disabledReason() }}</span
|
|
2913
4440
|
>
|
|
2914
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-radio-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-radio-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-radio-disabled-opacity{syntax: \"<number>\"; inherits: false; initial-value: .5;}@property --cngx-radio-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid oklch(.66 .19 50);}@property --cngx-radio-focus-offset{syntax: \"*\"; inherits: false; initial-value: 3px;}@property --cngx-radio-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-radio){:scope{display:inline-flex;align-items:center;gap:var(--cngx-radio-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-radio-color, inherit)}:scope.cngx-radio--disabled{cursor:not-allowed;opacity:var(--cngx-radio-disabled-opacity, .5)}:scope:focus-visible{outline:var( --cngx-radio-focus-outline, 2px solid var(--cngx-color-primary, oklch(.66 .19 50)) );outline-offset:var(--cngx-radio-focus-offset, 3px);border-radius:var(--cngx-radio-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-radio__label{flex:0 1 auto;min-inline-size:0}.cngx-radio__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}}\n"], dependencies: [{ kind: "component", type: CngxRadioIndicator, selector: "cngx-radio-indicator", inputs: ["checked", "disabled", "size", "dotGlyph"], exportAs: ["cngxRadioIndicator"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
4441
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-radio-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-radio-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-radio-disabled-opacity{syntax: \"<number>\"; inherits: false; initial-value: .5;}@property --cngx-radio-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid oklch(.66 .19 50);}@property --cngx-radio-focus-offset{syntax: \"*\"; inherits: false; initial-value: 3px;}@property --cngx-radio-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-radio){:scope{--cngx-radio-gap: var(--cngx-space-sm);display:inline-flex;align-items:center;gap:var(--cngx-radio-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-radio-color, inherit)}:scope.cngx-radio--disabled{cursor:not-allowed;opacity:var(--cngx-radio-disabled-opacity, .5)}:scope:focus-visible{outline:var( --cngx-radio-focus-outline, 2px solid var(--cngx-color-primary, oklch(.66 .19 50)) );outline-offset:var(--cngx-radio-focus-offset, 3px);border-radius:var(--cngx-radio-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-radio__label{flex:0 1 auto;min-inline-size:0}.cngx-radio__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}}\n"], dependencies: [{ kind: "component", type: CngxRadioIndicator, selector: "cngx-radio-indicator", inputs: ["checked", "disabled", "size", "dotGlyph"], exportAs: ["cngxRadioIndicator"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2915
4442
|
}
|
|
2916
4443
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxRadio, decorators: [{
|
|
2917
4444
|
type: Component,
|
|
@@ -2948,7 +4475,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2948
4475
|
[attr.aria-hidden]="disabledReason() ? null : 'true'"
|
|
2949
4476
|
>{{ disabledReason() }}</span
|
|
2950
4477
|
>
|
|
2951
|
-
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-radio-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-radio-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-radio-disabled-opacity{syntax: \"<number>\"; inherits: false; initial-value: .5;}@property --cngx-radio-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid oklch(.66 .19 50);}@property --cngx-radio-focus-offset{syntax: \"*\"; inherits: false; initial-value: 3px;}@property --cngx-radio-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-radio){:scope{display:inline-flex;align-items:center;gap:var(--cngx-radio-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-radio-color, inherit)}:scope.cngx-radio--disabled{cursor:not-allowed;opacity:var(--cngx-radio-disabled-opacity, .5)}:scope:focus-visible{outline:var( --cngx-radio-focus-outline, 2px solid var(--cngx-color-primary, oklch(.66 .19 50)) );outline-offset:var(--cngx-radio-focus-offset, 3px);border-radius:var(--cngx-radio-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-radio__label{flex:0 1 auto;min-inline-size:0}.cngx-radio__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}}\n"] }]
|
|
4478
|
+
`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-radio-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}@property --cngx-radio-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-radio-disabled-opacity{syntax: \"<number>\"; inherits: false; initial-value: .5;}@property --cngx-radio-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid oklch(.66 .19 50);}@property --cngx-radio-focus-offset{syntax: \"*\"; inherits: false; initial-value: 3px;}@property --cngx-radio-focus-radius{syntax: \"*\"; inherits: false; initial-value: .25rem;}}@layer cngx.components{@scope(.cngx-radio){:scope{--cngx-radio-gap: var(--cngx-space-sm);display:inline-flex;align-items:center;gap:var(--cngx-radio-gap, var(--cngx-space-sm, .5rem));cursor:pointer;-webkit-user-select:none;user-select:none;outline:none;font:inherit;color:var(--cngx-radio-color, inherit)}:scope.cngx-radio--disabled{cursor:not-allowed;opacity:var(--cngx-radio-disabled-opacity, .5)}:scope:focus-visible{outline:var( --cngx-radio-focus-outline, 2px solid var(--cngx-color-primary, oklch(.66 .19 50)) );outline-offset:var(--cngx-radio-focus-offset, 3px);border-radius:var(--cngx-radio-focus-radius, var(--cngx-radius-sm, .25rem))}.cngx-radio__label{flex:0 1 auto;min-inline-size:0}.cngx-radio__sr-only{position:absolute;inline-size:1px;block-size:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}}\n"] }]
|
|
2952
4479
|
}], ctorParameters: () => [], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], disabledReason: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledReason", required: false }] }], dotGlyph: [{ type: i0.Input, args: [{ isSignal: true, alias: "dotGlyph", required: false }] }] } });
|
|
2953
4480
|
|
|
2954
4481
|
/**
|
|
@@ -3514,7 +5041,7 @@ class CngxChipGroup {
|
|
|
3514
5041
|
{ provide: CNGX_CHIP_GROUP_HOST, useExisting: CngxChipGroup },
|
|
3515
5042
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxChipGroup },
|
|
3516
5043
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxChipGroup },
|
|
3517
|
-
], exportAs: ["cngxChipGroup"], hostDirectives: [{ directive: i1.CngxRovingTabindex, inputs: ["orientation", "orientation"] }], ngImport: i0, template: `<ng-content />`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-chip-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-chip-group){:scope{display:inline-flex;flex-direction:column;gap:var(--cngx-chip-group-gap, var(--cngx-space-sm, .5rem))}:scope.cngx-chip-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
5044
|
+
], exportAs: ["cngxChipGroup"], hostDirectives: [{ directive: i1.CngxRovingTabindex, inputs: ["orientation", "orientation"] }], ngImport: i0, template: `<ng-content />`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-chip-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-chip-group){:scope{--cngx-chip-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var(--cngx-chip-group-gap, var(--cngx-space-sm, .5rem))}:scope.cngx-chip-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
3518
5045
|
}
|
|
3519
5046
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxChipGroup, decorators: [{
|
|
3520
5047
|
type: Component,
|
|
@@ -3540,7 +5067,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3540
5067
|
{ provide: CNGX_CHIP_GROUP_HOST, useExisting: CngxChipGroup },
|
|
3541
5068
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxChipGroup },
|
|
3542
5069
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxChipGroup },
|
|
3543
|
-
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-chip-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-chip-group){:scope{display:inline-flex;flex-direction:column;gap:var(--cngx-chip-group-gap, var(--cngx-space-sm, .5rem))}:scope.cngx-chip-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"] }]
|
|
5070
|
+
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-chip-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-chip-group){:scope{--cngx-chip-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var(--cngx-chip-group-gap, var(--cngx-space-sm, .5rem))}:scope.cngx-chip-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"] }]
|
|
3544
5071
|
}], propDecorators: { selected: [{ type: i0.Input, args: [{ isSignal: true, alias: "selected", required: false }] }, { type: i0.Output, args: ["selectedChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }] } });
|
|
3545
5072
|
|
|
3546
5073
|
/**
|
|
@@ -3695,7 +5222,7 @@ class CngxMultiChipGroup {
|
|
|
3695
5222
|
{ provide: CNGX_CHIP_GROUP_HOST, useExisting: CngxMultiChipGroup },
|
|
3696
5223
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxMultiChipGroup },
|
|
3697
5224
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxMultiChipGroup },
|
|
3698
|
-
], exportAs: ["cngxMultiChipGroup"], hostDirectives: [{ directive: i1.CngxRovingTabindex, inputs: ["orientation", "orientation"] }], ngImport: i0, template: `<ng-content />`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-multi-chip-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-multi-chip-group){:scope{display:inline-flex;flex-direction:column;gap:var( --cngx-multi-chip-group-gap, var(--cngx-chip-group-gap, var(--cngx-space-sm, .5rem)) )}:scope.cngx-multi-chip-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
5225
|
+
], exportAs: ["cngxMultiChipGroup"], hostDirectives: [{ directive: i1.CngxRovingTabindex, inputs: ["orientation", "orientation"] }], ngImport: i0, template: `<ng-content />`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-multi-chip-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-multi-chip-group){:scope{--cngx-multi-chip-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var( --cngx-multi-chip-group-gap, var(--cngx-chip-group-gap, var(--cngx-space-sm, .5rem)) )}:scope.cngx-multi-chip-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
3699
5226
|
}
|
|
3700
5227
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMultiChipGroup, decorators: [{
|
|
3701
5228
|
type: Component,
|
|
@@ -3722,7 +5249,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
3722
5249
|
{ provide: CNGX_CHIP_GROUP_HOST, useExisting: CngxMultiChipGroup },
|
|
3723
5250
|
{ provide: CNGX_CONTROL_VALUE, useExisting: CngxMultiChipGroup },
|
|
3724
5251
|
{ provide: CNGX_FORM_FIELD_CONTROL, useExisting: CngxMultiChipGroup },
|
|
3725
|
-
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-multi-chip-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-multi-chip-group){:scope{display:inline-flex;flex-direction:column;gap:var( --cngx-multi-chip-group-gap, var(--cngx-chip-group-gap, var(--cngx-space-sm, .5rem)) )}:scope.cngx-multi-chip-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"] }]
|
|
5252
|
+
], template: `<ng-content />`, encapsulation: ViewEncapsulation.None, styles: ["@layer cngx.tokens{@property --cngx-multi-chip-group-gap{syntax: \"*\"; inherits: false; initial-value: .5rem;}}@layer cngx.components{@scope(.cngx-multi-chip-group){:scope{--cngx-multi-chip-group-gap: var(--cngx-space-sm);display:inline-flex;flex-direction:column;gap:var( --cngx-multi-chip-group-gap, var(--cngx-chip-group-gap, var(--cngx-space-sm, .5rem)) )}:scope.cngx-multi-chip-group--horizontal{flex-direction:row;flex-wrap:wrap}}}\n"] }]
|
|
3726
5253
|
}], ctorParameters: () => [], propDecorators: { selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], keyFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyFn", required: false }] }] } });
|
|
3727
5254
|
|
|
3728
5255
|
/**
|
|
@@ -6026,7 +7553,7 @@ class CngxCloseButton {
|
|
|
6026
7553
|
}
|
|
6027
7554
|
</ng-content>
|
|
6028
7555
|
</button>
|
|
6029
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-close-button-bg{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-border{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-size{syntax: \"<length>\"; inherits: false; initial-value: 32px;}@property --cngx-close-button-padding{syntax: \"<length>\"; inherits:
|
|
7556
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-close-button-bg{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-border{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-size{syntax: \"<length>\"; inherits: false; initial-value: 32px;}@property --cngx-close-button-padding{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-close-button-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-close-button-opacity{syntax: \"<number>\"; inherits: false; initial-value: .5;}@property --cngx-close-button-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-close-button-transition{syntax: \"<time>\"; inherits: false; initial-value: .15s;}@property --cngx-close-button-hover-opacity{syntax: \"<number>\"; inherits: false; initial-value: 1;}@property --cngx-close-button-hover-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .04);}@property --cngx-close-button-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-close-button-focus-offset{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-close-button-active-opacity{syntax: \"<number>\"; inherits: false; initial-value: .8;}@property --cngx-close-button-icon-size{syntax: \"<length>\"; inherits: false; initial-value: 16px;}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-close-button-hover-bg: oklch(1 0 0 / .06)}}[data-color-scheme=dark],.dark{--cngx-close-button-hover-bg: oklch(1 0 0 / .06)}[data-color-scheme=light],.light{--cngx-close-button-hover-bg: oklch(0 0 0 / .04)}}@layer cngx.components{@scope(.cngx-close-button){:scope{--cngx-close-button-padding: var(--cngx-space-sm);display:inline-flex;align-items:center;justify-content:center;vertical-align:middle}.cngx-close-button__btn{display:inline-flex;align-items:center;justify-content:center;appearance:none;background:var(--cngx-close-button-bg, none);border:var(--cngx-close-button-border, none);min-width:var(--cngx-close-button-size, 32px);min-height:var(--cngx-close-button-size, 32px);padding:var(--cngx-close-button-padding, var(--cngx-space-sm, 8px));cursor:pointer;color:var(--cngx-close-button-color, inherit);opacity:var(--cngx-close-button-opacity, .5);border-radius:var(--cngx-close-button-radius, var(--cngx-radius-sm, 4px));transition:opacity var(--cngx-close-button-transition, .15s) ease}.cngx-close-button__btn:hover{opacity:var(--cngx-close-button-hover-opacity, 1);background:var(--cngx-close-button-hover-bg, oklch(0 0 0 / .04))}.cngx-close-button__btn:focus-visible{outline:var(--cngx-close-button-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-close-button-focus-offset, 2px);opacity:1}.cngx-close-button__btn:active{opacity:var(--cngx-close-button-active-opacity, .8)}.cngx-close-button__icon{width:var(--cngx-close-button-icon-size, 16px);height:var(--cngx-close-button-icon-size, 16px);flex-shrink:0}}}\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
6030
7557
|
}
|
|
6031
7558
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxCloseButton, decorators: [{
|
|
6032
7559
|
type: Component,
|
|
@@ -6054,7 +7581,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
6054
7581
|
}
|
|
6055
7582
|
</ng-content>
|
|
6056
7583
|
</button>
|
|
6057
|
-
`, styles: ["@layer cngx.tokens{@property --cngx-close-button-bg{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-border{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-size{syntax: \"<length>\"; inherits: false; initial-value: 32px;}@property --cngx-close-button-padding{syntax: \"<length>\"; inherits:
|
|
7584
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-close-button-bg{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-border{syntax: \"*\"; inherits: false; initial-value: none;}@property --cngx-close-button-size{syntax: \"<length>\"; inherits: false; initial-value: 32px;}@property --cngx-close-button-padding{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-close-button-color{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-close-button-opacity{syntax: \"<number>\"; inherits: false; initial-value: .5;}@property --cngx-close-button-radius{syntax: \"<length>\"; inherits: false; initial-value: 4px;}@property --cngx-close-button-transition{syntax: \"<time>\"; inherits: false; initial-value: .15s;}@property --cngx-close-button-hover-opacity{syntax: \"<number>\"; inherits: false; initial-value: 1;}@property --cngx-close-button-hover-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .04);}@property --cngx-close-button-focus-outline{syntax: \"*\"; inherits: false; initial-value: 2px solid currentColor;}@property --cngx-close-button-focus-offset{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-close-button-active-opacity{syntax: \"<number>\"; inherits: false; initial-value: .8;}@property --cngx-close-button-icon-size{syntax: \"<length>\"; inherits: false; initial-value: 16px;}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-close-button-hover-bg: oklch(1 0 0 / .06)}}[data-color-scheme=dark],.dark{--cngx-close-button-hover-bg: oklch(1 0 0 / .06)}[data-color-scheme=light],.light{--cngx-close-button-hover-bg: oklch(0 0 0 / .04)}}@layer cngx.components{@scope(.cngx-close-button){:scope{--cngx-close-button-padding: var(--cngx-space-sm);display:inline-flex;align-items:center;justify-content:center;vertical-align:middle}.cngx-close-button__btn{display:inline-flex;align-items:center;justify-content:center;appearance:none;background:var(--cngx-close-button-bg, none);border:var(--cngx-close-button-border, none);min-width:var(--cngx-close-button-size, 32px);min-height:var(--cngx-close-button-size, 32px);padding:var(--cngx-close-button-padding, var(--cngx-space-sm, 8px));cursor:pointer;color:var(--cngx-close-button-color, inherit);opacity:var(--cngx-close-button-opacity, .5);border-radius:var(--cngx-close-button-radius, var(--cngx-radius-sm, 4px));transition:opacity var(--cngx-close-button-transition, .15s) ease}.cngx-close-button__btn:hover{opacity:var(--cngx-close-button-hover-opacity, 1);background:var(--cngx-close-button-hover-bg, oklch(0 0 0 / .04))}.cngx-close-button__btn:focus-visible{outline:var(--cngx-close-button-focus-outline, 2px solid currentColor);outline-offset:var(--cngx-close-button-focus-offset, 2px);opacity:1}.cngx-close-button__btn:active{opacity:var(--cngx-close-button-active-opacity, .8)}.cngx-close-button__icon{width:var(--cngx-close-button-icon-size, 16px);height:var(--cngx-close-button-icon-size, 16px);flex-shrink:0}}}\n"] }]
|
|
6058
7585
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }] } });
|
|
6059
7586
|
|
|
6060
7587
|
/**
|
|
@@ -6601,6 +8128,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
6601
8128
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/interactive/listbox/listbox.directive.ts
|
|
6602
8129
|
* @since 0.1.0
|
|
6603
8130
|
* @relatedTo CngxListboxSearch, CngxListboxTrigger, CngxOption, CngxOptionGroup, CngxActiveDescendant
|
|
8131
|
+
* @playground Two synced listboxes ./examples/synced-listboxes/synced-listboxes.component.ts
|
|
6604
8132
|
* <example-url>http://localhost:4200/#/common/interactive/listbox/search/command-palette</example-url>
|
|
6605
8133
|
* <example-url>http://localhost:4200/#/common/interactive/listbox/trigger/select-dropdown</example-url>
|
|
6606
8134
|
* <example-url>http://localhost:4200/#/common/interactive/listbox/base/multi-select</example-url>
|
|
@@ -9805,5 +11333,5 @@ function withRevealOnNavigate() {
|
|
|
9805
11333
|
* Generated bundle index. Do not edit.
|
|
9806
11334
|
*/
|
|
9807
11335
|
|
|
9808
|
-
export { CNGX_BUTTON_MULTI_TOGGLE_GROUP, CNGX_BUTTON_TOGGLE_GROUP, CNGX_CHIP_GROUP_HOST, CNGX_CHIP_STRIP_ROVING_FACTORY, CNGX_CLOSE_ICON, CNGX_CONTROL_VALUE, CNGX_ERROR_AGGREGATOR, CNGX_ERROR_SCOPE, CNGX_HIERARCHICAL_NAV_STRATEGY, CNGX_MENU_ANNOUNCER_FACTORY, CNGX_MENU_CONFIG, CNGX_MENU_DISMISS_HANDLER_FACTORY, CNGX_MENU_HOST, CNGX_MENU_NAV_STRATEGY, CNGX_MENU_RADIO_GROUP, CNGX_MENU_SUBMENU_ITEM, CNGX_NAV_CONFIG, CNGX_OPTION_CONTAINER, CNGX_OPTION_FILTER_HOST, CNGX_OPTION_INTERACTION_HOST, CNGX_OPTION_STATUS_HOST, CNGX_RADIO_GROUP, CNGX_SUBMENU_TRY_FALLBACKS, CNGX_TREE_CONFIG, CNGX_TREE_CONTROLLER_FACTORY, CngxAsyncClick, CngxAsyncStatus, CngxBeforeUnload, CngxButtonMultiToggleGroup, CngxButtonToggle, CngxButtonToggleGroup, CngxCheckbox, CngxCheckboxGroup, CngxChipGroup, CngxChipInGroup, CngxChipInput, CngxChipInteraction, CngxClickOutside, CngxCloseButton, CngxContextMenuTrigger, CngxCopyBlock, CngxCopyText, CngxDisclosure, CngxErrorAggregator, CngxErrorRegistry, CngxErrorScope, CngxErrorSource, CngxErrorState, CngxExpandable, CngxFailed, CngxHierarchicalNav, CngxHoverable, CngxKeyboardShortcut, CngxListbox, CngxListboxSearch, CngxListboxTrigger, CngxLongPress, CngxMenu, CngxMenuAnnouncer, CngxMenuGroup, CngxMenuItem, CngxMenuItemCheckbox, CngxMenuItemIcon, CngxMenuItemKbd, CngxMenuItemLabel, CngxMenuItemRadio, CngxMenuItemSubmenu, CngxMenuItemSuffix, CngxMenuSeparator, CngxMenuTrigger, CngxMultiChipGroup, CngxNavBadge, CngxNavGroup, CngxNavGroupRegistry, CngxNavLabel, CngxNavLink, CngxOption, CngxOptionGroup, CngxPending, CngxPressRipple, CngxPressable, CngxRadio, CngxRadioGroup, CngxReorder, CngxRipple, CngxSearch, CngxSpeak, CngxSucceeded, CngxSwipe, CngxSwipeDismiss, CngxToggle, DEFAULT_MENU_CONFIG, canDeactivateWhenClean, createChipStripRoving, createMenuAnnouncer, createMenuDismissHandler, createMenuRadioController, createMenuTriggerDismissBinding, createTreeAdItems, createTreeController, createW3CMenuStrategy, createW3CTreeStrategy, injectErrorAggregator, injectErrorScope, injectMenuAnnouncer, injectMenuConfig, injectNavConfig, injectTreeConfig, optimistic, provideCngxMenu, provideErrorRegistry, provideMenuConfig, provideMenuConfigAt, provideNavConfig, provideTreeConfig, provideTreeConfigAt, reflectAsyncDisplayStatus, withAriaLabels, withCloseOnSelect, withDefaultInitiallyExpanded, withDefaultKeyFn, withDefaultLabelFn, withDefaultNodeIdFn, withDismissOnBlur, withDismissOnOutsideClick, withDismissOnScroll, withGlobalRevealOnSubmit, withNavAnimation, withNavIndent, withRetry, withRevealOnNavigate, withSingleAccordion, withSubmenuCloseDelay, withSubmenuOpenDelay, withTreeCacheLimit, withTypeaheadDebounce };
|
|
11336
|
+
export { CNGX_ACCORDION, CNGX_BREADCRUMB, CNGX_BREADCRUMB_COLLAPSE_STRATEGY, CNGX_BUTTON_MULTI_TOGGLE_GROUP, CNGX_BUTTON_TOGGLE_GROUP, CNGX_CHIP_GROUP_HOST, CNGX_CHIP_STRIP_ROVING_FACTORY, CNGX_CLOSE_ICON, CNGX_CONTROL_VALUE, CNGX_ERROR_AGGREGATOR, CNGX_ERROR_SCOPE, CNGX_HIERARCHICAL_NAV_STRATEGY, CNGX_HOVER_INTENT_DEFAULTS, CNGX_MENU_ANNOUNCER_FACTORY, CNGX_MENU_CONFIG, CNGX_MENU_DISMISS_HANDLER_FACTORY, CNGX_MENU_HOST, CNGX_MENU_NAV_STRATEGY, CNGX_MENU_RADIO_GROUP, CNGX_MENU_SUBMENU_ITEM, CNGX_NAV_CONFIG, CNGX_OPTION_CONTAINER, CNGX_OPTION_FILTER_HOST, CNGX_OPTION_INTERACTION_HOST, CNGX_OPTION_STATUS_HOST, CNGX_RADIO_GROUP, CNGX_SLIDER_RANGE, CNGX_SUBMENU_TRY_FALLBACKS, CNGX_TREE_CONFIG, CNGX_TREE_CONTROLLER_FACTORY, CngxAccordion, CngxAccordionPanel, CngxAsyncClick, CngxAsyncStatus, CngxBeforeUnload, CngxBreadcrumb, CngxBreadcrumbItem, CngxBreadcrumbSeparator, CngxButtonMultiToggleGroup, CngxButtonToggle, CngxButtonToggleGroup, CngxCheckbox, CngxCheckboxGroup, CngxChipGroup, CngxChipInGroup, CngxChipInput, CngxChipInteraction, CngxClickOutside, CngxCloseButton, CngxContextMenuTrigger, CngxCopyBlock, CngxCopyText, CngxDisclosure, CngxErrorAggregator, CngxErrorRegistry, CngxErrorScope, CngxErrorSource, CngxErrorState, CngxExpandable, CngxFailed, CngxHierarchicalNav, CngxHoverIntent, CngxHoverable, CngxKeyboardShortcut, CngxListbox, CngxListboxSearch, CngxListboxTrigger, CngxLongPress, CngxMenu, CngxMenuAnnouncer, CngxMenuGroup, CngxMenuItem, CngxMenuItemCheckbox, CngxMenuItemIcon, CngxMenuItemKbd, CngxMenuItemLabel, CngxMenuItemRadio, CngxMenuItemSubmenu, CngxMenuItemSuffix, CngxMenuSeparator, CngxMenuTrigger, CngxMultiChipGroup, CngxNavBadge, CngxNavGroup, CngxNavGroupRegistry, CngxNavLabel, CngxNavLink, CngxOption, CngxOptionGroup, CngxPending, CngxPressRipple, CngxPressable, CngxRadio, CngxRadioGroup, CngxRangeSlider, CngxRangeSliderTrack, CngxReorder, CngxRipple, CngxSearch, CngxSlider, CngxSliderThumb, CngxSliderTrack, CngxSpeak, CngxSucceeded, CngxSwipe, CngxSwipeDismiss, CngxToggle, DEFAULT_BREADCRUMB_WIDTH_TIERS, DEFAULT_MENU_CONFIG, canDeactivateWhenClean, createAccordionKeyboardNav, createBreadcrumbCollapse, createChipStripRoving, createMenuAnnouncer, createMenuDismissHandler, createMenuRadioController, createMenuTriggerDismissBinding, createSliderCore, createTreeAdItems, createTreeController, createW3CMenuStrategy, createW3CTreeStrategy, injectErrorAggregator, injectErrorScope, injectMenuAnnouncer, injectMenuConfig, injectNavConfig, injectTreeConfig, optimistic, provideCngxMenu, provideErrorRegistry, provideMenuConfig, provideMenuConfigAt, provideNavConfig, provideTreeConfig, provideTreeConfigAt, reflectAsyncDisplayStatus, resolveBreadcrumbTier, withAriaLabels, withCloseOnSelect, withDefaultInitiallyExpanded, withDefaultKeyFn, withDefaultLabelFn, withDefaultNodeIdFn, withDismissOnBlur, withDismissOnOutsideClick, withDismissOnScroll, withGlobalRevealOnSubmit, withNavAnimation, withNavIndent, withRetry, withRevealOnNavigate, withSingleAccordion, withSubmenuCloseDelay, withSubmenuOpenDelay, withTreeCacheLimit, withTypeaheadDebounce };
|
|
9809
11337
|
//# sourceMappingURL=cngx-common-interactive.mjs.map
|