@ckui/core 0.1.0-next.1 → 0.1.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +337 -4
- package/fesm2022/ckui-core-badge.mjs +169 -0
- package/fesm2022/ckui-core-badge.mjs.map +1 -0
- package/fesm2022/ckui-core-chip.mjs +300 -0
- package/fesm2022/ckui-core-chip.mjs.map +1 -0
- package/fesm2022/ckui-core-dialog.mjs +18 -286
- package/fesm2022/ckui-core-dialog.mjs.map +1 -1
- package/fesm2022/ckui-core-drawer.mjs +342 -0
- package/fesm2022/ckui-core-drawer.mjs.map +1 -0
- package/fesm2022/ckui-core-internal-dialog.mjs +296 -0
- package/fesm2022/ckui-core-internal-dialog.mjs.map +1 -0
- package/fesm2022/ckui-core-internal-overlay.mjs +479 -0
- package/fesm2022/ckui-core-internal-overlay.mjs.map +1 -0
- package/fesm2022/ckui-core-internal.mjs +2 -463
- package/fesm2022/ckui-core-internal.mjs.map +1 -1
- package/fesm2022/ckui-core-progress.mjs +165 -0
- package/fesm2022/ckui-core-progress.mjs.map +1 -0
- package/fesm2022/ckui-core-segmented.mjs +184 -8
- package/fesm2022/ckui-core-segmented.mjs.map +1 -1
- package/fesm2022/ckui-core-stepper.mjs +842 -0
- package/fesm2022/ckui-core-stepper.mjs.map +1 -0
- package/fesm2022/ckui-core-switch.mjs +327 -0
- package/fesm2022/ckui-core-switch.mjs.map +1 -0
- package/fesm2022/ckui-core-tabs.mjs +678 -0
- package/fesm2022/ckui-core-tabs.mjs.map +1 -0
- package/fesm2022/ckui-core.mjs +2 -0
- package/fesm2022/ckui-core.mjs.map +1 -1
- package/package.json +37 -1
- package/types/ckui-core-badge.d.ts +44 -0
- package/types/ckui-core-chip.d.ts +62 -0
- package/types/ckui-core-dialog.d.ts +5 -40
- package/types/ckui-core-drawer.d.ts +153 -0
- package/types/ckui-core-internal-dialog.d.ts +102 -0
- package/types/ckui-core-internal-overlay.d.ts +83 -0
- package/types/ckui-core-internal.d.ts +2 -75
- package/types/ckui-core-progress.d.ts +43 -0
- package/types/ckui-core-segmented.d.ts +26 -0
- package/types/ckui-core-stepper.d.ts +186 -0
- package/types/ckui-core-switch.d.ts +90 -0
- package/types/ckui-core-tabs.d.ts +212 -0
- package/types/ckui-core.d.ts +2 -0
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { BreakpointObserver } from "@angular/cdk/layout";
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
|
-
import { ChangeDetectionStrategy, Component,
|
|
3
|
+
import { ChangeDetectionStrategy, Component, Directive, Injectable, Injector, PLATFORM_ID, ViewEncapsulation, afterNextRender, booleanAttribute, computed, forwardRef, inject, input, model, signal } from "@angular/core";
|
|
4
4
|
import { toSignal } from "@angular/core/rxjs-interop";
|
|
5
5
|
import { CK_CONFIG } from "@ckui/core";
|
|
6
6
|
import { FocusTrapFactory, LiveAnnouncer } from "@angular/cdk/a11y";
|
|
7
7
|
import { _CdkPrivateStyleLoader, _VisuallyHiddenLoader } from "@angular/cdk/private";
|
|
8
8
|
import { DOCUMENT, isPlatformBrowser } from "@angular/common";
|
|
9
9
|
import { NG_VALUE_ACCESSOR } from "@angular/forms";
|
|
10
|
-
import { Overlay, OverlayContainer } from "@angular/cdk/overlay";
|
|
11
|
-
import { CdkPortalOutlet, ComponentPortal, TemplatePortal } from "@angular/cdk/portal";
|
|
12
10
|
let counter = 0;
|
|
13
11
|
function createCkId(prefix) {
|
|
14
12
|
if (typeof prefix !== "string" || prefix.trim() === "") throw new TypeError("createCkId needs a non-empty prefix string.");
|
|
@@ -488,465 +486,6 @@ function provideCkValueAccessor(type) {
|
|
|
488
486
|
multi: true
|
|
489
487
|
};
|
|
490
488
|
}
|
|
491
|
-
var CkOverlayPane = class CkOverlayPane {
|
|
492
|
-
grab = input(false, ...ngDevMode ? [{ debugName: "grab" }] : /* istanbul ignore next */ []);
|
|
493
|
-
outlet = viewChild.required(CdkPortalOutlet, ...ngDevMode ? [{ debugName: "outlet" }] : /* istanbul ignore next */ []);
|
|
494
|
-
viewContainerRef = inject(ViewContainerRef);
|
|
495
|
-
attach(portal) {
|
|
496
|
-
this.outlet().attach(portal);
|
|
497
|
-
}
|
|
498
|
-
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
499
|
-
minVersion: "12.0.0",
|
|
500
|
-
version: "22.2.4",
|
|
501
|
-
ngImport: i0,
|
|
502
|
-
type: CkOverlayPane,
|
|
503
|
-
deps: [],
|
|
504
|
-
target: i0.ɵɵFactoryTarget.Component
|
|
505
|
-
});
|
|
506
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
507
|
-
minVersion: "17.0.0",
|
|
508
|
-
version: "22.2.4",
|
|
509
|
-
type: CkOverlayPane,
|
|
510
|
-
isStandalone: true,
|
|
511
|
-
selector: "ck-overlay-pane",
|
|
512
|
-
inputs: { grab: {
|
|
513
|
-
classPropertyName: "grab",
|
|
514
|
-
publicName: "grab",
|
|
515
|
-
isSignal: true,
|
|
516
|
-
isRequired: false,
|
|
517
|
-
transformFunction: null
|
|
518
|
-
} },
|
|
519
|
-
host: { classAttribute: "ck-overlay-pane" },
|
|
520
|
-
viewQueries: [{
|
|
521
|
-
propertyName: "outlet",
|
|
522
|
-
first: true,
|
|
523
|
-
predicate: CdkPortalOutlet,
|
|
524
|
-
descendants: true,
|
|
525
|
-
isSignal: true
|
|
526
|
-
}],
|
|
527
|
-
ngImport: i0,
|
|
528
|
-
template: `
|
|
529
|
-
@if (grab()) {
|
|
530
|
-
<div class="ck-overlay-grab" data-ck-sheet-grab aria-hidden="true">
|
|
531
|
-
<span class="ck-overlay-grab-bar"></span>
|
|
532
|
-
</div>
|
|
533
|
-
}
|
|
534
|
-
<ng-template cdkPortalOutlet />
|
|
535
|
-
`,
|
|
536
|
-
isInline: true,
|
|
537
|
-
styles: ["@layer ckui{.ck-overlay-backdrop{position:absolute;inset:0;z-index:-1;background:var(--ck-color-backdrop);pointer-events:auto;touch-action:manipulation}@media(forced-colors:active){.ck-overlay-backdrop{forced-color-adjust:none}}.ck-overlay-pane{position:relative;display:flex;flex:1 1 auto;flex-direction:column;min-inline-size:0;min-block-size:0;max-block-size:100%}.ck-overlay-pane>:not(.ck-overlay-grab){flex:1 1 auto;min-block-size:0}.ck-overlay-grab{display:flex;flex:none;justify-content:center;block-size:var(--ck-target-min);border-start-start-radius:var(--ck-radius-xl);border-start-end-radius:var(--ck-radius-xl);background:var(--ck-sheet-grab-bg, var(--ck-color-surface-raised));touch-action:none}.ck-overlay-grab-bar{margin-block-start:var(--ck-space-2);inline-size:var(--ck-space-10);block-size:var(--ck-space-1);border-radius:var(--ck-radius-full);background:var(--ck-color-border)}@media(forced-colors:active){.ck-overlay{border:1px solid CanvasText}.ck-overlay-grab-bar{background:CanvasText}}}\n"],
|
|
538
|
-
dependencies: [{
|
|
539
|
-
kind: "directive",
|
|
540
|
-
type: CdkPortalOutlet,
|
|
541
|
-
selector: "[cdkPortalOutlet]",
|
|
542
|
-
inputs: ["cdkPortalOutlet"],
|
|
543
|
-
outputs: ["attached"],
|
|
544
|
-
exportAs: ["cdkPortalOutlet"]
|
|
545
|
-
}],
|
|
546
|
-
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
547
|
-
encapsulation: i0.ViewEncapsulation.None
|
|
548
|
-
});
|
|
549
|
-
};
|
|
550
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
551
|
-
minVersion: "12.0.0",
|
|
552
|
-
version: "22.2.4",
|
|
553
|
-
ngImport: i0,
|
|
554
|
-
type: CkOverlayPane,
|
|
555
|
-
decorators: [{
|
|
556
|
-
type: Component,
|
|
557
|
-
args: [{
|
|
558
|
-
selector: "ck-overlay-pane",
|
|
559
|
-
imports: [CdkPortalOutlet],
|
|
560
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
561
|
-
encapsulation: ViewEncapsulation.None,
|
|
562
|
-
host: { class: "ck-overlay-pane" },
|
|
563
|
-
template: `
|
|
564
|
-
@if (grab()) {
|
|
565
|
-
<div class="ck-overlay-grab" data-ck-sheet-grab aria-hidden="true">
|
|
566
|
-
<span class="ck-overlay-grab-bar"></span>
|
|
567
|
-
</div>
|
|
568
|
-
}
|
|
569
|
-
<ng-template cdkPortalOutlet />
|
|
570
|
-
`,
|
|
571
|
-
styles: ["@layer ckui{.ck-overlay-backdrop{position:absolute;inset:0;z-index:-1;background:var(--ck-color-backdrop);pointer-events:auto;touch-action:manipulation}@media(forced-colors:active){.ck-overlay-backdrop{forced-color-adjust:none}}.ck-overlay-pane{position:relative;display:flex;flex:1 1 auto;flex-direction:column;min-inline-size:0;min-block-size:0;max-block-size:100%}.ck-overlay-pane>:not(.ck-overlay-grab){flex:1 1 auto;min-block-size:0}.ck-overlay-grab{display:flex;flex:none;justify-content:center;block-size:var(--ck-target-min);border-start-start-radius:var(--ck-radius-xl);border-start-end-radius:var(--ck-radius-xl);background:var(--ck-sheet-grab-bg, var(--ck-color-surface-raised));touch-action:none}.ck-overlay-grab-bar{margin-block-start:var(--ck-space-2);inline-size:var(--ck-space-10);block-size:var(--ck-space-1);border-radius:var(--ck-radius-full);background:var(--ck-color-border)}@media(forced-colors:active){.ck-overlay{border:1px solid CanvasText}.ck-overlay-grab-bar{background:CanvasText}}}\n"]
|
|
572
|
-
}]
|
|
573
|
-
}],
|
|
574
|
-
propDecorators: {
|
|
575
|
-
grab: [{
|
|
576
|
-
type: i0.Input,
|
|
577
|
-
args: [{
|
|
578
|
-
isSignal: true,
|
|
579
|
-
alias: "grab",
|
|
580
|
-
required: false
|
|
581
|
-
}]
|
|
582
|
-
}],
|
|
583
|
-
outlet: [{
|
|
584
|
-
type: i0.ViewChild,
|
|
585
|
-
args: [i0.forwardRef(() => CdkPortalOutlet), { isSignal: true }]
|
|
586
|
-
}]
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
const VELOCITY_WINDOW = 100;
|
|
590
|
-
function shouldDismissSwipe(distance, height, velocity) {
|
|
591
|
-
if (distance <= 0 || height <= 0) return false;
|
|
592
|
-
return distance > height * .3333333333333333 || velocity >= .5 && distance >= 16;
|
|
593
|
-
}
|
|
594
|
-
function attachSheetSwipe(options) {
|
|
595
|
-
const { pane, panel, backdrop } = options;
|
|
596
|
-
const doc = pane.ownerDocument;
|
|
597
|
-
const now = () => doc.defaultView.performance.now();
|
|
598
|
-
let pointerId = null;
|
|
599
|
-
let startY = 0;
|
|
600
|
-
let height = 0;
|
|
601
|
-
let offset = 0;
|
|
602
|
-
let samples = [];
|
|
603
|
-
function setOffset(next) {
|
|
604
|
-
offset = Math.max(0, next);
|
|
605
|
-
panel.style.transform = `translateY(${offset}px)`;
|
|
606
|
-
backdrop.style.opacity = String(Math.max(0, 1 - offset / Math.max(height, 1)));
|
|
607
|
-
samples.push({
|
|
608
|
-
offset,
|
|
609
|
-
time: now()
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
function velocity() {
|
|
613
|
-
const current = now();
|
|
614
|
-
const recent = samples.filter((sample) => current - sample.time <= VELOCITY_WINDOW);
|
|
615
|
-
const first = recent[0];
|
|
616
|
-
const last = recent[recent.length - 1];
|
|
617
|
-
if (!first || !last) return 0;
|
|
618
|
-
return (last.offset - first.offset) / Math.max(1, current - first.time);
|
|
619
|
-
}
|
|
620
|
-
function stopTracking() {
|
|
621
|
-
pointerId = null;
|
|
622
|
-
doc.removeEventListener("pointermove", onMove);
|
|
623
|
-
doc.removeEventListener("pointerup", onUp);
|
|
624
|
-
doc.removeEventListener("pointercancel", onCancel);
|
|
625
|
-
}
|
|
626
|
-
function snapBack() {
|
|
627
|
-
const from = offset;
|
|
628
|
-
panel.style.transform = "";
|
|
629
|
-
backdrop.style.opacity = "";
|
|
630
|
-
offset = 0;
|
|
631
|
-
const duration = options.duration();
|
|
632
|
-
if (from > 0 && duration > 0 && typeof panel.animate === "function") {
|
|
633
|
-
const timing = {
|
|
634
|
-
duration,
|
|
635
|
-
easing: options.easing()
|
|
636
|
-
};
|
|
637
|
-
panel.animate([{ transform: `translateY(${from}px)` }, { transform: "none" }], timing);
|
|
638
|
-
backdrop.animate([{ opacity: String(Math.max(0, 1 - from / Math.max(height, 1))) }, { opacity: "1" }], timing);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
function onDown(event) {
|
|
642
|
-
const target = event.target;
|
|
643
|
-
if (pointerId !== null || !event.isPrimary || event.button !== 0 || !(target instanceof Element) || !target.closest("[data-ck-sheet-grab]")) return;
|
|
644
|
-
pointerId = event.pointerId;
|
|
645
|
-
startY = event.clientY;
|
|
646
|
-
height = panel.getBoundingClientRect().height;
|
|
647
|
-
offset = 0;
|
|
648
|
-
samples = [{
|
|
649
|
-
offset: 0,
|
|
650
|
-
time: now()
|
|
651
|
-
}];
|
|
652
|
-
try {
|
|
653
|
-
target.setPointerCapture?.(event.pointerId);
|
|
654
|
-
} catch {}
|
|
655
|
-
doc.addEventListener("pointermove", onMove);
|
|
656
|
-
doc.addEventListener("pointerup", onUp);
|
|
657
|
-
doc.addEventListener("pointercancel", onCancel);
|
|
658
|
-
}
|
|
659
|
-
function onMove(event) {
|
|
660
|
-
if (event.pointerId === pointerId) setOffset(event.clientY - startY);
|
|
661
|
-
}
|
|
662
|
-
function onUp(event) {
|
|
663
|
-
if (event.pointerId !== pointerId) return;
|
|
664
|
-
setOffset(event.clientY - startY);
|
|
665
|
-
const dismiss = shouldDismissSwipe(offset, height, velocity());
|
|
666
|
-
stopTracking();
|
|
667
|
-
if (!options.onRelease(dismiss)) snapBack();
|
|
668
|
-
}
|
|
669
|
-
function onCancel(event) {
|
|
670
|
-
if (event.pointerId === pointerId) {
|
|
671
|
-
stopTracking();
|
|
672
|
-
snapBack();
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
pane.addEventListener("pointerdown", onDown);
|
|
676
|
-
return () => {
|
|
677
|
-
pane.removeEventListener("pointerdown", onDown);
|
|
678
|
-
stopTracking();
|
|
679
|
-
};
|
|
680
|
-
}
|
|
681
|
-
const DEFAULT_DURATION = 200;
|
|
682
|
-
const SHEET_MAX_HEIGHT = "calc(100dvh - env(safe-area-inset-top, 0px))";
|
|
683
|
-
const MODAL_MARGIN = "var(--ck-space-4, 1rem)";
|
|
684
|
-
function parseDuration(value) {
|
|
685
|
-
const match = /^\s*(-?[\d.]+)(ms|s)\s*$/.exec(value);
|
|
686
|
-
if (!match) return DEFAULT_DURATION;
|
|
687
|
-
const amount = Number(match[1]) * (match[2] === "s" ? 1e3 : 1);
|
|
688
|
-
return Number.isFinite(amount) && amount >= 0 ? amount : DEFAULT_DURATION;
|
|
689
|
-
}
|
|
690
|
-
var CkOverlayHost = class CkOverlayHost {
|
|
691
|
-
overlay = inject(Overlay);
|
|
692
|
-
overlayContainer = inject(OverlayContainer);
|
|
693
|
-
media = inject(CkMedia);
|
|
694
|
-
inert = inject(CkInert);
|
|
695
|
-
focusTraps = inject(CkFocusTrapFactory);
|
|
696
|
-
injector = inject(Injector);
|
|
697
|
-
document = inject(DOCUMENT);
|
|
698
|
-
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
699
|
-
stack = [];
|
|
700
|
-
entries = /* @__PURE__ */ new Set();
|
|
701
|
-
scrollStrategy = null;
|
|
702
|
-
scrollLocks = 0;
|
|
703
|
-
listening = false;
|
|
704
|
-
constructor() {
|
|
705
|
-
inject(DestroyRef).onDestroy(() => {
|
|
706
|
-
for (const entry of [...this.entries]) entry.destroy();
|
|
707
|
-
this.entries.clear();
|
|
708
|
-
this.stack.length = 0;
|
|
709
|
-
this.listen(false);
|
|
710
|
-
if (this.scrollLocks > 0) {
|
|
711
|
-
this.scrollLocks = 0;
|
|
712
|
-
this.scrollStrategy?.disable();
|
|
713
|
-
}
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
open(content, config = {}, injector) {
|
|
717
|
-
const requested = config.mode ?? "auto";
|
|
718
|
-
const mode = requested === "auto" ? this.media.sheet() ? "sheet" : "modal" : requested;
|
|
719
|
-
if (!this.isBrowser) return this.inertHandle(mode);
|
|
720
|
-
const sheet = mode === "sheet";
|
|
721
|
-
const dismissible = config.dismissible ?? true;
|
|
722
|
-
const container = this.overlayContainer.getContainerElement();
|
|
723
|
-
container.style.zIndex = "var(--ck-z-overlay, 1000)";
|
|
724
|
-
const overlayRef = this.overlay.create({
|
|
725
|
-
positionStrategy: sheet ? this.overlay.position().global().bottom("0").centerHorizontally() : this.overlay.position().global().centerHorizontally().centerVertically(),
|
|
726
|
-
scrollStrategy: this.overlay.scrollStrategies.noop(),
|
|
727
|
-
width: sheet ? "100%" : void 0,
|
|
728
|
-
height: sheet && config.fullHeight ? SHEET_MAX_HEIGHT : void 0,
|
|
729
|
-
maxWidth: sheet ? void 0 : `calc(100% - 2 * ${MODAL_MARGIN})`,
|
|
730
|
-
maxHeight: sheet ? SHEET_MAX_HEIGHT : `calc(100dvh - 2 * ${MODAL_MARGIN})`,
|
|
731
|
-
panelClass: [
|
|
732
|
-
"ck-overlay",
|
|
733
|
-
sheet ? "ck-overlay--sheet" : "ck-overlay--modal",
|
|
734
|
-
...config.panelClass === void 0 ? [] : [config.panelClass].flat()
|
|
735
|
-
],
|
|
736
|
-
disposeOnNavigation: false,
|
|
737
|
-
usePopover: false
|
|
738
|
-
});
|
|
739
|
-
const panel = overlayRef.overlayElement;
|
|
740
|
-
const host = overlayRef.hostElement;
|
|
741
|
-
let paneRef;
|
|
742
|
-
try {
|
|
743
|
-
paneRef = overlayRef.attach(new ComponentPortal(CkOverlayPane, null, this.injector));
|
|
744
|
-
paneRef.setInput("grab", sheet && dismissible);
|
|
745
|
-
paneRef.changeDetectorRef.detectChanges();
|
|
746
|
-
paneRef.instance.attach(this.contentPortal(content, paneRef.instance, injector));
|
|
747
|
-
} catch (error) {
|
|
748
|
-
overlayRef.dispose();
|
|
749
|
-
throw error;
|
|
750
|
-
}
|
|
751
|
-
panel.setAttribute("role", config.role ?? "dialog");
|
|
752
|
-
panel.setAttribute("aria-modal", "true");
|
|
753
|
-
panel.tabIndex = -1;
|
|
754
|
-
for (const [attribute, value] of [
|
|
755
|
-
["aria-label", config.ariaLabel],
|
|
756
|
-
["aria-labelledby", config.ariaLabelledBy],
|
|
757
|
-
["aria-describedby", config.ariaDescribedBy]
|
|
758
|
-
]) if (value) panel.setAttribute(attribute, value);
|
|
759
|
-
const backdrop = this.document.createElement("div");
|
|
760
|
-
backdrop.className = "ck-overlay-backdrop";
|
|
761
|
-
host.prepend(backdrop);
|
|
762
|
-
const opener = this.document.activeElement instanceof HTMLElement ? this.document.activeElement : null;
|
|
763
|
-
const trap = this.focusTraps.create(panel);
|
|
764
|
-
const activation = trap.activate(config.initialFocus);
|
|
765
|
-
const releaseInert = this.inert.hold([...this.inert.backgroundElements(container), ...this.stack.map((other) => other.overlayRef.hostElement)]);
|
|
766
|
-
this.lockScroll();
|
|
767
|
-
let resolveClosed = () => void 0;
|
|
768
|
-
const closed = new Promise((resolve) => resolveClosed = resolve);
|
|
769
|
-
let closing = null;
|
|
770
|
-
let released = false;
|
|
771
|
-
let finishedOnce = false;
|
|
772
|
-
let openAnimations = [];
|
|
773
|
-
const view = this.document.defaultView;
|
|
774
|
-
const motion = () => {
|
|
775
|
-
const style = view.getComputedStyle(panel);
|
|
776
|
-
return {
|
|
777
|
-
duration: this.media.reducedMotion() ? 0 : parseDuration(style.getPropertyValue("--ck-duration-normal")),
|
|
778
|
-
easing: style.getPropertyValue("--ck-ease-standard").trim() || "ease"
|
|
779
|
-
};
|
|
780
|
-
};
|
|
781
|
-
const play = (element, keyframes, fill) => {
|
|
782
|
-
const { duration, easing } = motion();
|
|
783
|
-
if (duration <= 0 || typeof element.animate !== "function") return null;
|
|
784
|
-
return element.animate(keyframes, {
|
|
785
|
-
duration,
|
|
786
|
-
easing,
|
|
787
|
-
fill
|
|
788
|
-
});
|
|
789
|
-
};
|
|
790
|
-
const finished = (animation) => animation ? animation.finished.catch(() => void 0) : Promise.resolve();
|
|
791
|
-
const entry = {
|
|
792
|
-
overlayRef,
|
|
793
|
-
dismissible,
|
|
794
|
-
state: "open",
|
|
795
|
-
openers: opener ? [opener] : [],
|
|
796
|
-
dismiss: (reason) => {
|
|
797
|
-
if (config.onDismissRequest) config.onDismissRequest(reason);
|
|
798
|
-
else close();
|
|
799
|
-
},
|
|
800
|
-
destroy: () => {
|
|
801
|
-
release();
|
|
802
|
-
finish();
|
|
803
|
-
}
|
|
804
|
-
};
|
|
805
|
-
this.entries.add(entry);
|
|
806
|
-
this.stack.push(entry);
|
|
807
|
-
this.listen(true);
|
|
808
|
-
const detachSwipe = sheet && dismissible ? attachSheetSwipe({
|
|
809
|
-
pane: paneRef.location.nativeElement,
|
|
810
|
-
panel,
|
|
811
|
-
backdrop,
|
|
812
|
-
duration: () => motion().duration,
|
|
813
|
-
easing: () => motion().easing,
|
|
814
|
-
onRelease: (dismissed) => {
|
|
815
|
-
if (dismissed) entry.dismiss("swipe");
|
|
816
|
-
return entry.state !== "open";
|
|
817
|
-
}
|
|
818
|
-
}) : () => void 0;
|
|
819
|
-
const onBackdropClick = () => {
|
|
820
|
-
if (entry.state === "open" && dismissible && this.stack.at(-1) === entry) entry.dismiss("backdrop");
|
|
821
|
-
};
|
|
822
|
-
backdrop.addEventListener("click", onBackdropClick);
|
|
823
|
-
const release = () => {
|
|
824
|
-
if (released) return;
|
|
825
|
-
released = true;
|
|
826
|
-
entry.state = "closing";
|
|
827
|
-
const index = this.stack.indexOf(entry);
|
|
828
|
-
this.stack.splice(index, 1);
|
|
829
|
-
this.stack[index]?.openers.unshift(...entry.openers);
|
|
830
|
-
detachSwipe();
|
|
831
|
-
backdrop.removeEventListener("click", onBackdropClick);
|
|
832
|
-
for (const animation of openAnimations) animation.cancel();
|
|
833
|
-
releaseInert();
|
|
834
|
-
host.inert = true;
|
|
835
|
-
trap.release();
|
|
836
|
-
this.restoreFocus(entry);
|
|
837
|
-
};
|
|
838
|
-
const finish = () => {
|
|
839
|
-
if (finishedOnce) return;
|
|
840
|
-
finishedOnce = true;
|
|
841
|
-
entry.state = "closed";
|
|
842
|
-
this.entries.delete(entry);
|
|
843
|
-
overlayRef.dispose();
|
|
844
|
-
backdrop.remove();
|
|
845
|
-
this.unlockScroll();
|
|
846
|
-
if (this.entries.size === 0) this.listen(false);
|
|
847
|
-
resolveClosed();
|
|
848
|
-
};
|
|
849
|
-
openAnimations = [play(panel, sheet ? [{ transform: "translateY(100%)" }, { transform: "none" }] : [{
|
|
850
|
-
opacity: 0,
|
|
851
|
-
transform: "scale(0.96)"
|
|
852
|
-
}, {
|
|
853
|
-
opacity: 1,
|
|
854
|
-
transform: "none"
|
|
855
|
-
}], "none"), play(backdrop, [{ opacity: 0 }, { opacity: 1 }], "none")].filter((animation) => animation !== null);
|
|
856
|
-
activation.then((focused) => {
|
|
857
|
-
if (entry.state === "open" && !focused) panel.focus({ preventScroll: true });
|
|
858
|
-
});
|
|
859
|
-
const opened = Promise.all([activation, ...openAnimations.map((animation) => finished(animation))]).then(() => void 0);
|
|
860
|
-
const close = () => {
|
|
861
|
-
if (closing) return closing;
|
|
862
|
-
release();
|
|
863
|
-
const animations = [play(panel, sheet ? [{ transform: "translateY(100%)" }] : [{
|
|
864
|
-
opacity: 0,
|
|
865
|
-
transform: "scale(0.96)"
|
|
866
|
-
}], "forwards"), play(backdrop, [{ opacity: 0 }], "forwards")];
|
|
867
|
-
closing = Promise.all(animations.map(finished)).then(finish);
|
|
868
|
-
return closing;
|
|
869
|
-
};
|
|
870
|
-
return {
|
|
871
|
-
mode,
|
|
872
|
-
panel,
|
|
873
|
-
opened,
|
|
874
|
-
closed,
|
|
875
|
-
close
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
restoreFocus(closed) {
|
|
879
|
-
const top = this.stack.at(-1);
|
|
880
|
-
const active = this.document.activeElement;
|
|
881
|
-
if (top?.overlayRef.overlayElement.contains(active)) return;
|
|
882
|
-
const openers = [...closed.openers].reverse().filter((candidate) => candidate.isConnected);
|
|
883
|
-
if (active && openers.includes(active)) return;
|
|
884
|
-
for (const candidate of openers) {
|
|
885
|
-
candidate.focus();
|
|
886
|
-
if (this.document.activeElement === candidate) return;
|
|
887
|
-
}
|
|
888
|
-
top?.overlayRef.overlayElement.focus({ preventScroll: true });
|
|
889
|
-
}
|
|
890
|
-
contentPortal(content, pane, injector) {
|
|
891
|
-
return content instanceof TemplateRef ? new TemplatePortal(content, pane.viewContainerRef, void 0, injector) : new ComponentPortal(content, null, injector ?? this.injector);
|
|
892
|
-
}
|
|
893
|
-
inertHandle(mode) {
|
|
894
|
-
return {
|
|
895
|
-
mode,
|
|
896
|
-
panel: this.document.createElement("div"),
|
|
897
|
-
opened: Promise.resolve(),
|
|
898
|
-
closed: Promise.resolve(),
|
|
899
|
-
close: () => Promise.resolve()
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
lockScroll() {
|
|
903
|
-
this.scrollStrategy ??= this.overlay.scrollStrategies.block();
|
|
904
|
-
if (this.scrollLocks++ === 0) this.scrollStrategy.enable();
|
|
905
|
-
}
|
|
906
|
-
unlockScroll() {
|
|
907
|
-
if (this.scrollLocks > 0 && --this.scrollLocks === 0) this.scrollStrategy?.disable();
|
|
908
|
-
}
|
|
909
|
-
listen(active) {
|
|
910
|
-
if (active === this.listening) return;
|
|
911
|
-
this.listening = active;
|
|
912
|
-
if (active) this.document.addEventListener("keydown", this.onKeydown);
|
|
913
|
-
else this.document.removeEventListener("keydown", this.onKeydown);
|
|
914
|
-
}
|
|
915
|
-
onKeydown = (event) => {
|
|
916
|
-
if (event.key !== "Escape" || event.defaultPrevented || event.isComposing) return;
|
|
917
|
-
const top = this.stack.at(-1);
|
|
918
|
-
if (top?.dismissible) {
|
|
919
|
-
event.preventDefault();
|
|
920
|
-
top.dismiss("escape");
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
924
|
-
minVersion: "12.0.0",
|
|
925
|
-
version: "22.2.4",
|
|
926
|
-
ngImport: i0,
|
|
927
|
-
type: CkOverlayHost,
|
|
928
|
-
deps: [],
|
|
929
|
-
target: i0.ɵɵFactoryTarget.Injectable
|
|
930
|
-
});
|
|
931
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
932
|
-
minVersion: "12.0.0",
|
|
933
|
-
version: "22.2.4",
|
|
934
|
-
ngImport: i0,
|
|
935
|
-
type: CkOverlayHost,
|
|
936
|
-
providedIn: "root"
|
|
937
|
-
});
|
|
938
|
-
};
|
|
939
|
-
i0.ɵɵngDeclareClassMetadata({
|
|
940
|
-
minVersion: "12.0.0",
|
|
941
|
-
version: "22.2.4",
|
|
942
|
-
ngImport: i0,
|
|
943
|
-
type: CkOverlayHost,
|
|
944
|
-
decorators: [{
|
|
945
|
-
type: Injectable,
|
|
946
|
-
args: [{ providedIn: "root" }]
|
|
947
|
-
}],
|
|
948
|
-
ctorParameters: () => []
|
|
949
|
-
});
|
|
950
489
|
function hasAccessibleName(element, sources) {
|
|
951
490
|
const attribute = (name) => (element.getAttribute(name) ?? "").trim() !== "";
|
|
952
491
|
if (attribute("aria-label") || sources.title && attribute("title")) return true;
|
|
@@ -960,6 +499,6 @@ function visibleText(node) {
|
|
|
960
499
|
if (node instanceof Element && (node.getAttribute("aria-hidden") === "true" || node.hasAttribute("hidden"))) return "";
|
|
961
500
|
return Array.from(node.childNodes, visibleText).join("");
|
|
962
501
|
}
|
|
963
|
-
export { CkAnnouncer, CkFocusTrapFactory, CkIcon, CkInert, CkMedia,
|
|
502
|
+
export { CkAnnouncer, CkFocusTrapFactory, CkIcon, CkInert, CkMedia, CkValueControl, createCkId, hasAccessibleName, provideCkValueAccessor };
|
|
964
503
|
|
|
965
504
|
//# sourceMappingURL=ckui-core-internal.mjs.map
|