@ckui/core 0.1.0-next.2 → 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 +215 -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 -287
- 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 +19 -8
- package/fesm2022/ckui-core-internal-overlay.mjs.map +1 -1
- 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/package.json +21 -1
- 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 +12 -5
- package/types/ckui-core-switch.d.ts +90 -0
- package/types/ckui-core-tabs.d.ts +212 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ckui-core-internal-dialog.mjs","names":[],"sources":["../../../../projects/core/internal/dialog/dialog-context.ts","../../../../projects/core/internal/dialog/dialog-ref.ts","../../../../projects/core/internal/dialog/dialog-container.ts","../../../../projects/core/internal/dialog/dialog-opener.ts"],"sourcesContent":["import { InjectionToken, Signal, computed, signal } from '@angular/core';\n\n/** The ids of every title (or description) in the dialog; the newest one names it. */\nexport class CkDialogIds {\n private readonly entries = signal<readonly Signal<string>[]>([]);\n readonly current = computed(() => this.entries().at(-1)?.() ?? null);\n\n /** Returns the function that takes the entry out again; it leaves the others alone. */\n add(id: Signal<string>): () => void {\n this.entries.update((entries) => [...entries, id]);\n return () => this.entries.update((entries) => entries.filter((entry) => entry !== id));\n }\n}\n\n/** What the building blocks inside a dialog tell the dialog: the ids that name it. */\nexport class CkDialogContext {\n readonly titles = new CkDialogIds();\n readonly descriptions = new CkDialogIds();\n readonly titleId = this.titles.current;\n readonly descriptionId = this.descriptions.current;\n /** Resolved when the dialog opens. */\n readonly mode = signal<'modal' | 'sheet' | 'side'>('modal');\n}\n\nexport const CK_DIALOG_CONTEXT = new InjectionToken<CkDialogContext>('CK_DIALOG_CONTEXT');\n","/** What a `CkDialogRef` calls into; supplied by `CkDialog`, not by consumers. */\nexport interface CkDialogRefControls<R> {\n readonly closing: Promise<void>;\n readonly closed: Promise<R | undefined>;\n close(result: R | undefined): void;\n}\n\n/** Controls one open dialog or drawer. Returned by `CkDialog.open` and `CkDrawer.open`, injected by its content; never constructed directly. */\nexport class CkDialogRef<R = unknown> {\n /**\n * Resolves once, after the dialog has left the screen, with the result of the first `close()`.\n * Escape, a click on the backdrop and a swipe resolve it with `undefined`, and so does destroying\n * the app.\n */\n readonly closed: Promise<R | undefined>;\n /**\n * Resolves once, the moment the dialog starts to close (before the leave animation), whatever\n * the cause. `closed` follows when it has left the screen.\n */\n readonly closing: Promise<void>;\n private readonly controls: CkDialogRefControls<R>;\n\n constructor(controls: CkDialogRefControls<R>) {\n this.controls = controls;\n this.closed = controls.closed;\n this.closing = controls.closing;\n }\n\n /** Closes the dialog. Only the first call counts; later ones, with another result too, do nothing. */\n close(result?: R): void {\n this.controls.close(result);\n }\n}\n","import { CdkPortalOutlet, ComponentPortal, Portal, TemplatePortal } from '@angular/cdk/portal';\nimport {\n ChangeDetectionStrategy,\n Component,\n ComponentRef,\n EmbeddedViewRef,\n InjectionToken,\n Injector,\n TemplateRef,\n ViewContainerRef,\n ViewEncapsulation,\n inject,\n} from '@angular/core';\nimport { ComponentType } from '@angular/cdk/portal';\nimport { CK_LABELS } from '@ckui/core';\nimport { CkButton } from '@ckui/core/button';\nimport { CkIcon } from '@ckui/core/internal';\nimport { CK_DIALOG_CONTEXT } from './dialog-context';\nimport { CkDialogRef } from './dialog-ref';\n\n/** What the service hands the container: the consumer's content and the parts of the config it shows. */\nexport interface CkDialogContainerSetup {\n readonly content: ComponentType<unknown> | TemplateRef<unknown>;\n readonly closeButton: boolean;\n readonly dismissible: boolean;\n}\n\nexport const CK_DIALOG_SETUP = new InjectionToken<CkDialogContainerSetup>('CK_DIALOG_SETUP');\n\n/** The dialog's (or drawer's) own element inside the overlay: the padding, the close button and the consumer's content. */\n@Component({\n selector: 'ck-dialog-container',\n imports: [CdkPortalOutlet, CkButton, CkIcon],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'ck-dialog',\n '[class.ck-dialog--sheet]': 'context.mode() === \"sheet\"',\n '[class.ck-dialog--side]': 'context.mode() === \"side\"',\n '[class.ck-dialog--grab]': 'context.mode() === \"sheet\" && setup.dismissible',\n '[class.ck-dialog--has-close]': 'setup.closeButton',\n '[class.ck-dialog--no-title]': 'context.titleId() === null',\n },\n template: `\n <div class=\"ck-dialog__content\">\n <ng-template [cdkPortalOutlet]=\"portal\" (attached)=\"onAttached($event)\" />\n </div>\n @if (setup.closeButton) {\n <button\n ckButton\n type=\"button\"\n variant=\"ghost\"\n size=\"md\"\n iconOnly\n class=\"ck-dialog__close\"\n [attr.aria-label]=\"labels().close\"\n (click)=\"ref.close()\"\n >\n <ck-icon name=\"close\" />\n </button>\n }\n `,\n styleUrls: ['./dialog.css', './drawer.css'],\n})\nexport class CkDialogContainer {\n protected readonly context = inject(CK_DIALOG_CONTEXT);\n protected readonly setup = inject(CK_DIALOG_SETUP);\n protected readonly labels = inject(CK_LABELS);\n protected readonly ref = inject(CkDialogRef);\n\n protected readonly portal: Portal<unknown>;\n\n constructor() {\n const injector = inject(Injector);\n this.portal =\n this.setup.content instanceof TemplateRef\n ? new TemplatePortal(this.setup.content, inject(ViewContainerRef), undefined, injector)\n : new ComponentPortal(this.setup.content, null, injector);\n }\n\n /** A component's host element has to be a flex column too, or its body could not scroll. */\n protected onAttached(attached: ComponentRef<unknown> | EmbeddedViewRef<unknown> | null): void {\n if (attached && 'location' in attached) {\n (attached.location.nativeElement as HTMLElement).classList.add('ck-dialog__component');\n }\n }\n}\n","import { InteractivityChecker } from '@angular/cdk/a11y';\nimport { ComponentType } from '@angular/cdk/portal';\nimport {\n DestroyRef,\n EffectRef,\n InjectionToken,\n Injector,\n TemplateRef,\n effect,\n inject,\n} from '@angular/core';\nimport { CkOverlayHandle, CkOverlayHost, CkOverlayMode } from '@ckui/core/internal/overlay';\nimport { CK_DIALOG_CONTEXT, CkDialogContext } from './dialog-context';\nimport { CK_DIALOG_SETUP, CkDialogContainer } from './dialog-container';\nimport { CkDialogRef } from './dialog-ref';\n\ndeclare const ngDevMode: unknown;\n\n/** The `data` of the config, for a dialog or drawer opened with a component. */\nexport const CK_DIALOG_DATA = new InjectionToken<unknown>('CK_DIALOG_DATA');\n\nconst TABBABLE_CANDIDATES =\n 'a[href], button, input, select, textarea, summary, [tabindex], [contenteditable], audio[controls], video[controls]';\n\nexport interface CkDialogOpenOptions<D> {\n /** Names the opener in dev warnings. */\n readonly kind: 'CkDialog' | 'CkDrawer';\n readonly mode: CkOverlayMode;\n readonly side?: 'start' | 'end';\n readonly data?: D;\n readonly role: 'dialog' | 'alertdialog';\n readonly dismissible: boolean;\n readonly closeButton: boolean;\n readonly fullHeight: boolean;\n readonly injector?: Injector;\n readonly ariaLabel?: string;\n readonly panelClass: string[];\n}\n\ninterface ActiveDialog {\n close(): void;\n /** Settles the result promise and stops everything that outlives the overlay. */\n destroy(): void;\n}\n\n/**\n * What dialog and drawer share: the ref, the result promise, the labelling from the building\n * blocks, the initial focus and the teardown. One instance per service, created in its field\n * initialiser (an injection context).\n */\nexport class CkDialogOpener {\n private readonly overlay = inject(CkOverlayHost);\n private readonly checker = inject(InteractivityChecker);\n private readonly injector = inject(Injector);\n private readonly active = new Set<ActiveDialog>();\n\n constructor() {\n inject(DestroyRef).onDestroy(() => {\n for (const dialog of [...this.active]) {\n dialog.destroy();\n }\n this.active.clear();\n });\n }\n\n open<C, D, R>(\n content: ComponentType<C> | TemplateRef<unknown>,\n options: CkDialogOpenOptions<D>,\n ): CkDialogRef<R> {\n const context = new CkDialogContext();\n\n let resolveClosed: (result: R | undefined) => void = () => undefined;\n const closed = new Promise<R | undefined>((resolve) => (resolveClosed = resolve));\n let resolveClosing: () => void = () => undefined;\n const closing = new Promise<void>((resolve) => (resolveClosing = resolve));\n let handle: CkOverlayHandle | null = null;\n let requested = false;\n let result: R | undefined;\n let settled = false;\n let labelling: EffectRef | null = null;\n const dialog: ActiveDialog = { close: () => ref.close(), destroy: () => settle() };\n\n const settle = (): void => {\n if (settled) {\n return;\n }\n settled = true;\n resolveClosing();\n labelling?.destroy();\n this.active.delete(dialog);\n resolveClosed(result);\n };\n\n const ref = new CkDialogRef<R>({\n closed,\n closing,\n close: (value) => {\n if (requested) {\n return;\n }\n requested = true;\n result = value;\n resolveClosing();\n // Closed from the content's constructor, before the overlay exists: it closes right after opening.\n void handle?.close();\n },\n });\n\n this.active.add(dialog);\n\n const dialogInjector = Injector.create({\n parent: options.injector ?? this.injector,\n providers: [\n { provide: CK_DIALOG_CONTEXT, useValue: context },\n { provide: CkDialogRef, useValue: ref },\n { provide: CK_DIALOG_DATA, useValue: options.data },\n {\n provide: CK_DIALOG_SETUP,\n useValue: {\n content,\n closeButton: options.closeButton,\n dismissible: options.dismissible,\n },\n },\n ],\n });\n\n try {\n handle = this.overlay.open(\n CkDialogContainer,\n {\n mode: options.mode,\n side: options.side,\n dismissible: options.dismissible,\n fullHeight: options.fullHeight,\n role: options.role,\n ariaLabel: options.ariaLabel,\n panelClass: options.panelClass,\n onDismissRequest: () => ref.close(),\n initialFocus: () => (handle ? this.initialFocus(handle.panel) : null),\n },\n dialogInjector,\n );\n } catch (error) {\n settle();\n throw error;\n }\n\n const opened = handle;\n context.mode.set(opened.mode);\n labelling = effect(\n () => {\n this.setAttribute(opened.panel, 'aria-labelledby', context.titleId());\n this.setAttribute(opened.panel, 'aria-describedby', context.descriptionId());\n },\n { injector: this.injector },\n );\n void opened.closed.then(settle);\n if (requested) {\n void opened.close();\n }\n if (typeof ngDevMode !== 'undefined' && ngDevMode) {\n void opened.opened.then(() => {\n if (!settled && context.titleId() === null && !options.ariaLabel) {\n console.warn(\n `${options.kind}: the ${options.kind === 'CkDrawer' ? 'drawer' : 'dialog'} has no accessible name. Add [ckDialogTitle] to a heading in its content or set \\`ariaLabel\\` in the config.`,\n );\n }\n });\n }\n return ref;\n }\n\n /** Closes every open one as if each `close()` had been called without a result. */\n closeAll(): void {\n for (const dialog of [...this.active]) {\n dialog.close();\n }\n }\n\n private setAttribute(element: HTMLElement, name: string, value: string | null): void {\n if (value === null) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, value);\n }\n }\n\n /**\n * The marked element, else the first tabbable one of the content (the close button comes last in\n * the DOM, and the scrolling body itself is skipped), else the panel.\n */\n private initialFocus(panel: HTMLElement): HTMLElement {\n const marked = Array.from(\n panel.querySelectorAll<HTMLElement>('[data-ck-dialog-initial-focus]'),\n ).find((candidate) => this.checker.isFocusable(candidate));\n if (marked) {\n return marked;\n }\n const content = panel.querySelector<HTMLElement>('.ck-dialog__content');\n const first = Array.from(\n content?.querySelectorAll<HTMLElement>(TABBABLE_CANDIDATES) ?? [],\n ).find(\n (candidate) =>\n !candidate.classList.contains('ck-dialog-body') && this.checker.isTabbable(candidate),\n );\n return first ?? panel;\n }\n}\n"],"mappings":";;;;;;;;AAGA,IAAa,cAAb,MAAwB;CACL,UAAU,OAAkC,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CACvD,UAAU,eAAe,KAAK,QAAO,CAAE,CAAC,GAAG,EAAE,CAAC,GAAE,KAAM,M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IAAI,QACF,OAAO;EAET,MAAM,UAAU,MAAM,cAA2B,qBAAqB;EAOtE,OANc,MAAM,KAClB,SAAS,iBAA8B,mBAAmB,KAAK,CAAA,CAAE,CAClE,CAAC,MACC,cACC,CAAC,UAAU,UAAU,SAAS,gBAAgB,KAAK,KAAK,QAAQ,WAAW,SAAS,CAEjF,KAAS;CAClB;AACD"}
|
|
@@ -197,6 +197,7 @@ function attachSheetSwipe(options) {
|
|
|
197
197
|
const DEFAULT_DURATION = 200;
|
|
198
198
|
const SHEET_MAX_HEIGHT = "calc(100dvh - env(safe-area-inset-top, 0px))";
|
|
199
199
|
const MODAL_MARGIN = "var(--ck-space-4, 1rem)";
|
|
200
|
+
const SIDE_HEIGHT = "100dvh";
|
|
200
201
|
function parseDuration(value) {
|
|
201
202
|
const match = /^\s*(-?[\d.]+)(ms|s)\s*$/.exec(value);
|
|
202
203
|
if (!match) return DEFAULT_DURATION;
|
|
@@ -234,19 +235,25 @@ var CkOverlayHost = class CkOverlayHost {
|
|
|
234
235
|
const mode = requested === "auto" ? this.media.sheet() ? "sheet" : "modal" : requested;
|
|
235
236
|
if (!this.isBrowser) return this.inertHandle(mode);
|
|
236
237
|
const sheet = mode === "sheet";
|
|
238
|
+
const side = mode === "side";
|
|
237
239
|
const dismissible = config.dismissible ?? true;
|
|
238
240
|
const container = this.overlayContainer.getContainerElement();
|
|
239
241
|
container.style.zIndex = "var(--ck-z-overlay, 1000)";
|
|
242
|
+
const view = this.document.defaultView;
|
|
243
|
+
const rtl = view?.getComputedStyle(container).direction === "rtl";
|
|
244
|
+
const onRight = (config.side ?? "end") === "end" ? !rtl : rtl;
|
|
240
245
|
const overlayRef = this.overlay.create({
|
|
241
|
-
|
|
246
|
+
direction: rtl ? "rtl" : "ltr",
|
|
247
|
+
positionStrategy: side ? this.sidePosition(onRight) : sheet ? this.overlay.position().global().bottom("0").centerHorizontally() : this.overlay.position().global().centerHorizontally().centerVertically(),
|
|
242
248
|
scrollStrategy: this.overlay.scrollStrategies.noop(),
|
|
243
249
|
width: sheet ? "100%" : void 0,
|
|
244
|
-
height: sheet && config.fullHeight ? SHEET_MAX_HEIGHT : void 0,
|
|
245
|
-
maxWidth: sheet ? void 0 : `calc(100% - 2 * ${MODAL_MARGIN})`,
|
|
246
|
-
maxHeight: sheet ? SHEET_MAX_HEIGHT : `calc(100dvh - 2 * ${MODAL_MARGIN})`,
|
|
250
|
+
height: side ? SIDE_HEIGHT : sheet && config.fullHeight ? SHEET_MAX_HEIGHT : void 0,
|
|
251
|
+
maxWidth: sheet ? void 0 : side ? `calc(100% - ${MODAL_MARGIN})` : `calc(100% - 2 * ${MODAL_MARGIN})`,
|
|
252
|
+
maxHeight: side ? SIDE_HEIGHT : sheet ? SHEET_MAX_HEIGHT : `calc(100dvh - 2 * ${MODAL_MARGIN})`,
|
|
247
253
|
panelClass: [
|
|
248
254
|
"ck-overlay",
|
|
249
|
-
|
|
255
|
+
`ck-overlay--${mode}`,
|
|
256
|
+
...side ? [`ck-overlay--${onRight ? "right" : "left"}`] : [],
|
|
250
257
|
...config.panelClass === void 0 ? [] : [config.panelClass].flat()
|
|
251
258
|
],
|
|
252
259
|
disposeOnNavigation: false,
|
|
@@ -286,7 +293,6 @@ var CkOverlayHost = class CkOverlayHost {
|
|
|
286
293
|
let released = false;
|
|
287
294
|
let finishedOnce = false;
|
|
288
295
|
let openAnimations = [];
|
|
289
|
-
const view = this.document.defaultView;
|
|
290
296
|
const motion = () => {
|
|
291
297
|
const style = view.getComputedStyle(panel);
|
|
292
298
|
return {
|
|
@@ -362,7 +368,8 @@ var CkOverlayHost = class CkOverlayHost {
|
|
|
362
368
|
if (this.entries.size === 0) this.listen(false);
|
|
363
369
|
resolveClosed();
|
|
364
370
|
};
|
|
365
|
-
|
|
371
|
+
const offscreen = side ? `translateX(${onRight ? "" : "-"}100%)` : "translateY(100%)";
|
|
372
|
+
openAnimations = [play(panel, sheet || side ? [{ transform: offscreen }, { transform: "none" }] : [{
|
|
366
373
|
opacity: 0,
|
|
367
374
|
transform: "scale(0.96)"
|
|
368
375
|
}, {
|
|
@@ -376,7 +383,7 @@ var CkOverlayHost = class CkOverlayHost {
|
|
|
376
383
|
const close = () => {
|
|
377
384
|
if (closing) return closing;
|
|
378
385
|
release();
|
|
379
|
-
const animations = [play(panel, sheet ? [{ transform:
|
|
386
|
+
const animations = [play(panel, sheet || side ? [{ transform: offscreen }] : [{
|
|
380
387
|
opacity: 0,
|
|
381
388
|
transform: "scale(0.96)"
|
|
382
389
|
}], "forwards"), play(backdrop, [{ opacity: 0 }], "forwards")];
|
|
@@ -403,6 +410,10 @@ var CkOverlayHost = class CkOverlayHost {
|
|
|
403
410
|
}
|
|
404
411
|
top?.overlayRef.overlayElement.focus({ preventScroll: true });
|
|
405
412
|
}
|
|
413
|
+
sidePosition(right) {
|
|
414
|
+
const position = this.overlay.position().global().top("0");
|
|
415
|
+
return right ? position.right("0") : position.left("0");
|
|
416
|
+
}
|
|
406
417
|
contentPortal(content, pane, injector) {
|
|
407
418
|
return content instanceof TemplateRef ? new TemplatePortal(content, pane.viewContainerRef, void 0, injector) : new ComponentPortal(content, null, injector ?? this.injector);
|
|
408
419
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ckui-core-internal-overlay.mjs","names":[],"sources":["../../../../projects/core/internal/overlay/overlay-pane.ts","../../../../projects/core/internal/overlay/sheet-swipe.ts","../../../../projects/core/internal/overlay/overlay-host.ts"],"sourcesContent":["import { CdkPortalOutlet, Portal } from '@angular/cdk/portal';\nimport {\n ChangeDetectionStrategy,\n Component,\n ViewContainerRef,\n ViewEncapsulation,\n inject,\n input,\n viewChild,\n} from '@angular/core';\n\n/** What the overlay host puts inside every CDK pane: the grab area of a sheet and the caller's content. */\n@Component({\n selector: 'ck-overlay-pane',\n imports: [CdkPortalOutlet],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: { class: 'ck-overlay-pane' },\n template: `\n @if (grab()) {\n <div class=\"ck-overlay-grab\" data-ck-sheet-grab aria-hidden=\"true\">\n <span class=\"ck-overlay-grab-bar\"></span>\n </div>\n }\n <ng-template cdkPortalOutlet />\n `,\n styles: `\n @layer ckui {\n .ck-overlay-backdrop {\n position: absolute;\n inset: 0;\n z-index: -1;\n background: var(--ck-color-backdrop);\n pointer-events: auto;\n touch-action: manipulation;\n }\n\n @media (forced-colors: active) {\n .ck-overlay-backdrop {\n forced-color-adjust: none;\n }\n }\n\n .ck-overlay-pane {\n position: relative;\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n min-inline-size: 0;\n min-block-size: 0;\n max-block-size: 100%;\n }\n\n .ck-overlay-pane > :not(.ck-overlay-grab) {\n flex: 1 1 auto;\n min-block-size: 0;\n }\n\n .ck-overlay-grab {\n display: flex;\n flex: none;\n justify-content: center;\n block-size: var(--ck-target-min);\n border-start-start-radius: var(--ck-radius-xl);\n border-start-end-radius: var(--ck-radius-xl);\n background: var(--ck-sheet-grab-bg, var(--ck-color-surface-raised));\n touch-action: none;\n }\n\n .ck-overlay-grab-bar {\n margin-block-start: var(--ck-space-2);\n inline-size: var(--ck-space-10);\n block-size: var(--ck-space-1);\n border-radius: var(--ck-radius-full);\n background: var(--ck-color-border);\n }\n\n @media (forced-colors: active) {\n .ck-overlay {\n border: 1px solid CanvasText;\n }\n\n .ck-overlay-grab-bar {\n background: CanvasText;\n }\n }\n }\n `,\n})\nexport class CkOverlayPane {\n readonly grab = input(false);\n\n private readonly outlet = viewChild.required(CdkPortalOutlet);\n readonly viewContainerRef = inject(ViewContainerRef);\n\n attach(portal: Portal<unknown>): void {\n this.outlet().attach(portal);\n }\n}\n","/** A sheet is dismissed by a drag past this share of its height... */\nexport const SWIPE_DISTANCE_RATIO = 1 / 3;\n/** ...or by a flick at least this fast (px per ms) that has moved a little. */\nexport const SWIPE_FLICK_VELOCITY = 0.5;\nexport const SWIPE_FLICK_MIN_DISTANCE = 16;\n/** The speed is measured over this many ms before release. */\nconst VELOCITY_WINDOW = 100;\n\nexport function shouldDismissSwipe(distance: number, height: number, velocity: number): boolean {\n if (distance <= 0 || height <= 0) {\n return false;\n }\n return (\n distance > height * SWIPE_DISTANCE_RATIO ||\n (velocity >= SWIPE_FLICK_VELOCITY && distance >= SWIPE_FLICK_MIN_DISTANCE)\n );\n}\n\nexport interface SheetSwipeOptions {\n /** Contains the grab area (`[data-ck-sheet-grab]`); the swipe starts there. */\n readonly pane: HTMLElement;\n /** The element that follows the finger. */\n readonly panel: HTMLElement;\n readonly backdrop: HTMLElement;\n readonly duration: () => number;\n readonly easing: () => string;\n /** Called on release. `dismiss` says the swipe passed the threshold; return whether the overlay closed. */\n readonly onRelease: (dismiss: boolean) => boolean;\n}\n\ninterface Sample {\n readonly offset: number;\n readonly time: number;\n}\n\n/** Makes the grab area of a bottom sheet draggable. Returns the function that removes it. */\nexport function attachSheetSwipe(options: SheetSwipeOptions): () => void {\n const { pane, panel, backdrop } = options;\n const doc = pane.ownerDocument;\n const now = (): number => (doc.defaultView as Window).performance.now();\n let pointerId: number | null = null;\n let startY = 0;\n let height = 0;\n let offset = 0;\n let samples: Sample[] = [];\n\n function setOffset(next: number): void {\n offset = Math.max(0, next);\n panel.style.transform = `translateY(${offset}px)`;\n backdrop.style.opacity = String(Math.max(0, 1 - offset / Math.max(height, 1)));\n samples.push({ offset, time: now() });\n }\n\n function velocity(): number {\n const current = now();\n const recent = samples.filter((sample) => current - sample.time <= VELOCITY_WINDOW);\n const first = recent[0];\n const last = recent[recent.length - 1];\n if (!first || !last) {\n return 0;\n }\n return (last.offset - first.offset) / Math.max(1, current - first.time);\n }\n\n function stopTracking(): void {\n pointerId = null;\n doc.removeEventListener('pointermove', onMove);\n doc.removeEventListener('pointerup', onUp);\n doc.removeEventListener('pointercancel', onCancel);\n }\n\n function snapBack(): void {\n const from = offset;\n panel.style.transform = '';\n backdrop.style.opacity = '';\n offset = 0;\n const duration = options.duration();\n if (from > 0 && duration > 0 && typeof panel.animate === 'function') {\n const timing = { duration, easing: options.easing() };\n panel.animate([{ transform: `translateY(${from}px)` }, { transform: 'none' }], timing);\n backdrop.animate(\n [{ opacity: String(Math.max(0, 1 - from / Math.max(height, 1))) }, { opacity: '1' }],\n timing,\n );\n }\n }\n\n function onDown(event: PointerEvent): void {\n const target = event.target;\n if (\n pointerId !== null ||\n !event.isPrimary ||\n event.button !== 0 ||\n !(target instanceof Element) ||\n !target.closest('[data-ck-sheet-grab]')\n ) {\n return;\n }\n pointerId = event.pointerId;\n startY = event.clientY;\n height = panel.getBoundingClientRect().height;\n offset = 0;\n samples = [{ offset: 0, time: now() }];\n try {\n (target as HTMLElement).setPointerCapture?.(event.pointerId);\n } catch {\n // A pointer that is already gone cannot be captured; the document listeners still work.\n }\n doc.addEventListener('pointermove', onMove);\n doc.addEventListener('pointerup', onUp);\n doc.addEventListener('pointercancel', onCancel);\n }\n\n function onMove(event: PointerEvent): void {\n if (event.pointerId === pointerId) {\n setOffset(event.clientY - startY);\n }\n }\n\n function onUp(event: PointerEvent): void {\n if (event.pointerId !== pointerId) {\n return;\n }\n setOffset(event.clientY - startY);\n const dismiss = shouldDismissSwipe(offset, height, velocity());\n stopTracking();\n if (!options.onRelease(dismiss)) {\n snapBack();\n }\n }\n\n function onCancel(event: PointerEvent): void {\n if (event.pointerId === pointerId) {\n stopTracking();\n snapBack();\n }\n }\n\n pane.addEventListener('pointerdown', onDown);\n return () => {\n pane.removeEventListener('pointerdown', onDown);\n stopTracking();\n };\n}\n","import { Overlay, OverlayContainer, OverlayRef, ScrollStrategy } from '@angular/cdk/overlay';\nimport { ComponentPortal, ComponentType, Portal, TemplatePortal } from '@angular/cdk/portal';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Injectable, Injector, PLATFORM_ID, TemplateRef, inject } from '@angular/core';\nimport { CkFocusTrap, CkFocusTrapFactory, CkInert, CkMedia } from '@ckui/core/internal';\nimport { CkOverlayPane } from './overlay-pane';\nimport { attachSheetSwipe } from './sheet-swipe';\n\nexport type CkOverlayMode = 'auto' | 'modal' | 'sheet';\nexport type CkOverlayDismissReason = 'escape' | 'backdrop' | 'swipe';\n\nexport interface CkOverlayConfig {\n /** `auto` becomes a sheet when `CkMedia.sheet()` is true at the moment of opening. Default `auto`. */\n mode?: CkOverlayMode;\n /** Escape, a click on the backdrop and a swipe down may close the overlay. Default `true`. */\n dismissible?: boolean;\n /** A sheet as tall as the viewport allows instead of as tall as its content. */\n fullHeight?: boolean;\n panelClass?: string | string[];\n /** Default `dialog`. */\n role?: 'dialog' | 'alertdialog';\n ariaLabel?: string;\n ariaLabelledBy?: string;\n ariaDescribedBy?: string;\n /**\n * Called when the user asks to dismiss (Escape, backdrop, swipe) a dismissible overlay. It is\n * expected to call `handle.close()` straight away; without it the host closes the overlay itself.\n * A sheet that is still open after a swipe snaps back.\n */\n onDismissRequest?: (reason: CkOverlayDismissReason) => void;\n /**\n * Picks the element that takes focus once the overlay has rendered. Without it, or when it\n * returns `null` or something that cannot take focus, the first tabbable element does.\n */\n initialFocus?: () => HTMLElement | null;\n}\n\nexport interface CkOverlayHandle {\n /** The mode resolved when the overlay opened. */\n readonly mode: 'modal' | 'sheet';\n /** The element that carries `role`, `aria-modal` and the labels; set `aria-labelledby` here when the title appears later. */\n readonly panel: HTMLElement;\n /** Resolves once the opening animation and the initial focus are done. */\n readonly opened: Promise<void>;\n /** Resolves once the overlay is detached. */\n readonly closed: Promise<void>;\n /** Animates out, then detaches. Repeated calls return the same promise. */\n close(): Promise<void>;\n}\n\nconst DEFAULT_DURATION = 200;\nconst SHEET_MAX_HEIGHT = 'calc(100dvh - env(safe-area-inset-top, 0px))';\nconst MODAL_MARGIN = 'var(--ck-space-4, 1rem)';\n\ntype State = 'open' | 'closing' | 'closed';\n\ninterface Entry {\n readonly overlayRef: OverlayRef;\n readonly dismissible: boolean;\n readonly dismiss: (reason: CkOverlayDismissReason) => void;\n /** Elements that had focus before this overlay (and ones it inherited) that focus can return to. */\n readonly openers: HTMLElement[];\n /** Runs the whole teardown at once, without animation. Safe to call repeatedly. */\n readonly destroy: () => void;\n state: State;\n}\n\nfunction parseDuration(value: string): number {\n const match = /^\\s*(-?[\\d.]+)(ms|s)\\s*$/.exec(value);\n if (!match) {\n return DEFAULT_DURATION;\n }\n const amount = Number(match[1]) * (match[2] === 's' ? 1000 : 1);\n return Number.isFinite(amount) && amount >= 0 ? amount : DEFAULT_DURATION;\n}\n\n/**\n * Opens modal dialogs and bottom sheets on the CDK overlay: backdrop, scroll lock, focus trap and\n * restore, `inert` background, Escape / backdrop / swipe dismissal and the open and close animation.\n */\n@Injectable({ providedIn: 'root' })\nexport class CkOverlayHost {\n private readonly overlay = inject(Overlay);\n private readonly overlayContainer = inject(OverlayContainer);\n private readonly media = inject(CkMedia);\n private readonly inert = inject(CkInert);\n private readonly focusTraps = inject(CkFocusTrapFactory);\n private readonly injector = inject(Injector);\n private readonly document = inject(DOCUMENT);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /** Open overlays, topmost last. A closing overlay has already left it. */\n private readonly stack: Entry[] = [];\n private readonly entries = new Set<Entry>();\n private scrollStrategy: ScrollStrategy | null = null;\n private scrollLocks = 0;\n private listening = false;\n\n constructor() {\n inject(DestroyRef).onDestroy(() => {\n for (const entry of [...this.entries]) {\n entry.destroy();\n }\n this.entries.clear();\n this.stack.length = 0;\n this.listen(false);\n if (this.scrollLocks > 0) {\n this.scrollLocks = 0;\n this.scrollStrategy?.disable();\n }\n });\n }\n\n open<C>(\n content: ComponentType<C> | TemplateRef<unknown>,\n config: CkOverlayConfig = {},\n injector?: Injector,\n ): CkOverlayHandle {\n const requested = config.mode ?? 'auto';\n const mode = requested === 'auto' ? (this.media.sheet() ? 'sheet' : 'modal') : requested;\n if (!this.isBrowser) {\n return this.inertHandle(mode);\n }\n\n const sheet = mode === 'sheet';\n const dismissible = config.dismissible ?? true;\n const container = this.overlayContainer.getContainerElement();\n container.style.zIndex = 'var(--ck-z-overlay, 1000)';\n\n const overlayRef = this.overlay.create({\n positionStrategy: sheet\n ? this.overlay.position().global().bottom('0').centerHorizontally()\n : this.overlay.position().global().centerHorizontally().centerVertically(),\n scrollStrategy: this.overlay.scrollStrategies.noop(),\n width: sheet ? '100%' : undefined,\n height: sheet && config.fullHeight ? SHEET_MAX_HEIGHT : undefined,\n maxWidth: sheet ? undefined : `calc(100% - 2 * ${MODAL_MARGIN})`,\n maxHeight: sheet ? SHEET_MAX_HEIGHT : `calc(100dvh - 2 * ${MODAL_MARGIN})`,\n panelClass: [\n 'ck-overlay',\n sheet ? 'ck-overlay--sheet' : 'ck-overlay--modal',\n ...(config.panelClass === undefined ? [] : [config.panelClass].flat()),\n ],\n disposeOnNavigation: false,\n // The top layer would put every overlay above the toast host; the z-index tokens order them instead.\n usePopover: false,\n });\n const panel = overlayRef.overlayElement;\n const host = overlayRef.hostElement;\n\n let paneRef;\n try {\n paneRef = overlayRef.attach(new ComponentPortal(CkOverlayPane, null, this.injector));\n paneRef.setInput('grab', sheet && dismissible);\n paneRef.changeDetectorRef.detectChanges();\n paneRef.instance.attach(this.contentPortal(content, paneRef.instance, injector));\n } catch (error) {\n overlayRef.dispose();\n throw error;\n }\n\n panel.setAttribute('role', config.role ?? 'dialog');\n panel.setAttribute('aria-modal', 'true');\n panel.tabIndex = -1;\n for (const [attribute, value] of [\n ['aria-label', config.ariaLabel],\n ['aria-labelledby', config.ariaLabelledBy],\n ['aria-describedby', config.ariaDescribedBy],\n ] as const) {\n if (value) {\n panel.setAttribute(attribute, value);\n }\n }\n\n const backdrop = this.document.createElement('div');\n backdrop.className = 'ck-overlay-backdrop';\n host.prepend(backdrop);\n\n // The opener is recorded before the background turns inert; inert would blur it.\n const opener =\n this.document.activeElement instanceof HTMLElement ? this.document.activeElement : null;\n const trap: CkFocusTrap = this.focusTraps.create(panel);\n const activation = trap.activate(config.initialFocus);\n\n const releaseInert = this.inert.hold([\n ...this.inert.backgroundElements(container),\n ...this.stack.map((other) => other.overlayRef.hostElement),\n ]);\n this.lockScroll();\n\n let resolveClosed: () => void = () => undefined;\n const closed = new Promise<void>((resolve) => (resolveClosed = resolve));\n let closing: Promise<void> | null = null;\n let released = false;\n let finishedOnce = false;\n let openAnimations: Animation[] = [];\n const view = this.document.defaultView;\n\n const motion = () => {\n const style = view!.getComputedStyle(panel);\n return {\n duration: this.media.reducedMotion()\n ? 0\n : parseDuration(style.getPropertyValue('--ck-duration-normal')),\n easing: style.getPropertyValue('--ck-ease-standard').trim() || 'ease',\n };\n };\n\n const play = (\n element: HTMLElement,\n keyframes: Keyframe[],\n fill: FillMode,\n ): Animation | null => {\n const { duration, easing } = motion();\n if (duration <= 0 || typeof element.animate !== 'function') {\n return null;\n }\n return element.animate(keyframes, { duration, easing, fill });\n };\n\n const finished = (animation: Animation | null): Promise<unknown> =>\n animation ? animation.finished.catch(() => undefined) : Promise.resolve();\n\n const entry: Entry = {\n overlayRef,\n dismissible,\n state: 'open',\n openers: opener ? [opener] : [],\n dismiss: (reason) => {\n if (config.onDismissRequest) {\n config.onDismissRequest(reason);\n } else {\n void close();\n }\n },\n destroy: () => {\n release();\n finish();\n },\n };\n this.entries.add(entry);\n this.stack.push(entry);\n this.listen(true);\n\n const detachSwipe =\n sheet && dismissible\n ? attachSheetSwipe({\n pane: paneRef.location.nativeElement as HTMLElement,\n panel,\n backdrop,\n duration: () => motion().duration,\n easing: () => motion().easing,\n onRelease: (dismissed) => {\n if (dismissed) {\n entry.dismiss('swipe');\n }\n return entry.state !== 'open';\n },\n })\n : () => undefined;\n\n const onBackdropClick = (): void => {\n if (entry.state === 'open' && dismissible && this.stack.at(-1) === entry) {\n entry.dismiss('backdrop');\n }\n };\n backdrop.addEventListener('click', onBackdropClick);\n\n /** Everything that must stop the moment the overlay starts closing. */\n const release = (): void => {\n if (released) {\n return;\n }\n released = true;\n entry.state = 'closing';\n const index = this.stack.indexOf(entry);\n this.stack.splice(index, 1);\n // An overlay above this one gets its openers, so focus can still reach the page later.\n this.stack[index]?.openers.unshift(...entry.openers);\n detachSwipe();\n backdrop.removeEventListener('click', onBackdropClick);\n for (const animation of openAnimations) {\n animation.cancel();\n }\n // The background has to be live again before the opener can take focus back.\n releaseInert();\n host.inert = true;\n trap.release();\n this.restoreFocus(entry);\n };\n\n /** Everything that happens once the overlay is gone. */\n const finish = (): void => {\n if (finishedOnce) {\n return;\n }\n finishedOnce = true;\n entry.state = 'closed';\n this.entries.delete(entry);\n overlayRef.dispose();\n backdrop.remove();\n this.unlockScroll();\n if (this.entries.size === 0) {\n this.listen(false);\n }\n resolveClosed();\n };\n\n const enter: Keyframe[] = sheet\n ? [{ transform: 'translateY(100%)' }, { transform: 'none' }]\n : [\n { opacity: 0, transform: 'scale(0.96)' },\n { opacity: 1, transform: 'none' },\n ];\n openAnimations = [\n play(panel, enter, 'none'),\n play(backdrop, [{ opacity: 0 }, { opacity: 1 }], 'none'),\n ].filter((animation): animation is Animation => animation !== null);\n\n // Nothing focusable inside: the panel takes focus right away, not after the animation.\n void activation.then((focused) => {\n if (entry.state === 'open' && !focused) {\n panel.focus({ preventScroll: true });\n }\n });\n const opened = Promise.all([\n activation,\n ...openAnimations.map((animation) => finished(animation)),\n ]).then(() => undefined);\n\n const close = (): Promise<void> => {\n if (closing) {\n return closing;\n }\n release();\n const leave: Keyframe[] = sheet\n ? [{ transform: 'translateY(100%)' }]\n : [{ opacity: 0, transform: 'scale(0.96)' }];\n const animations = [\n play(panel, leave, 'forwards'),\n play(backdrop, [{ opacity: 0 }], 'forwards'),\n ];\n closing = Promise.all(animations.map(finished)).then(finish);\n return closing;\n };\n\n return { mode, panel, opened, closed, close };\n }\n\n /** Focus did not return to where it came from (opener disabled, inert or gone): find it a home. */\n private restoreFocus(closed: Entry): void {\n const top = this.stack.at(-1);\n const active = this.document.activeElement;\n if (top?.overlayRef.overlayElement.contains(active)) {\n return;\n }\n const openers = [...closed.openers].reverse().filter((candidate) => candidate.isConnected);\n if (active && openers.includes(active as HTMLElement)) {\n return;\n }\n for (const candidate of openers) {\n candidate.focus();\n if (this.document.activeElement === candidate) {\n return;\n }\n }\n top?.overlayRef.overlayElement.focus({ preventScroll: true });\n }\n\n private contentPortal<C>(\n content: ComponentType<C> | TemplateRef<unknown>,\n pane: CkOverlayPane,\n injector: Injector | undefined,\n ): Portal<unknown> {\n return content instanceof TemplateRef\n ? new TemplatePortal(content, pane.viewContainerRef, undefined, injector)\n : new ComponentPortal(content, null, injector ?? this.injector);\n }\n\n /** What the server gets: nothing is rendered, and the overlay counts as closed. */\n private inertHandle(mode: 'modal' | 'sheet'): CkOverlayHandle {\n return {\n mode,\n panel: this.document.createElement('div'),\n opened: Promise.resolve(),\n closed: Promise.resolve(),\n close: () => Promise.resolve(),\n };\n }\n\n private lockScroll(): void {\n this.scrollStrategy ??= this.overlay.scrollStrategies.block();\n if (this.scrollLocks++ === 0) {\n this.scrollStrategy.enable();\n }\n }\n\n private unlockScroll(): void {\n if (this.scrollLocks > 0 && --this.scrollLocks === 0) {\n this.scrollStrategy?.disable();\n }\n }\n\n private listen(active: boolean): void {\n if (active === this.listening) {\n return;\n }\n this.listening = active;\n if (active) {\n this.document.addEventListener('keydown', this.onKeydown);\n } else {\n this.document.removeEventListener('keydown', this.onKeydown);\n }\n }\n\n private readonly onKeydown = (event: KeyboardEvent): void => {\n if (event.key !== 'Escape' || event.defaultPrevented || event.isComposing) {\n return;\n }\n const top = this.stack.at(-1);\n if (top?.dismissible) {\n event.preventDefault();\n top.dismiss('escape');\n }\n };\n}\n"],"mappings":";;;;;;AAyFA,IAAa,gBAAb,MAAa,cAAa;CACf,OAAO,MAAM,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAEX,SAAS,UAAU,SAAS,iBAAgB,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CACpD,mBAAmB,OAAO,gBAAgB;CAEnD,OAAO,QAAuB;EAC5B,KAAK,OAAM,CAAE,CAAC,OAAO,MAAM;CAC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,QAAA,GAAA,sBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAa,YADA;CAAM,CAAA;;AACnB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAa,YAAA,CAAA;EADzB,MAAA;EAAW,MAAA,CAAA,EAAE,YAAY,OAAM,CAAE"}
|
|
1
|
+
{"version":3,"file":"ckui-core-internal-overlay.mjs","names":[],"sources":["../../../../projects/core/internal/overlay/overlay-pane.ts","../../../../projects/core/internal/overlay/sheet-swipe.ts","../../../../projects/core/internal/overlay/overlay-host.ts"],"sourcesContent":["import { CdkPortalOutlet, Portal } from '@angular/cdk/portal';\nimport {\n ChangeDetectionStrategy,\n Component,\n ViewContainerRef,\n ViewEncapsulation,\n inject,\n input,\n viewChild,\n} from '@angular/core';\n\n/** What the overlay host puts inside every CDK pane: the grab area of a sheet and the caller's content. */\n@Component({\n selector: 'ck-overlay-pane',\n imports: [CdkPortalOutlet],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: { class: 'ck-overlay-pane' },\n template: `\n @if (grab()) {\n <div class=\"ck-overlay-grab\" data-ck-sheet-grab aria-hidden=\"true\">\n <span class=\"ck-overlay-grab-bar\"></span>\n </div>\n }\n <ng-template cdkPortalOutlet />\n `,\n styles: `\n @layer ckui {\n .ck-overlay-backdrop {\n position: absolute;\n inset: 0;\n z-index: -1;\n background: var(--ck-color-backdrop);\n pointer-events: auto;\n touch-action: manipulation;\n }\n\n @media (forced-colors: active) {\n .ck-overlay-backdrop {\n forced-color-adjust: none;\n }\n }\n\n .ck-overlay-pane {\n position: relative;\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n min-inline-size: 0;\n min-block-size: 0;\n max-block-size: 100%;\n }\n\n .ck-overlay-pane > :not(.ck-overlay-grab) {\n flex: 1 1 auto;\n min-block-size: 0;\n }\n\n .ck-overlay-grab {\n display: flex;\n flex: none;\n justify-content: center;\n block-size: var(--ck-target-min);\n border-start-start-radius: var(--ck-radius-xl);\n border-start-end-radius: var(--ck-radius-xl);\n background: var(--ck-sheet-grab-bg, var(--ck-color-surface-raised));\n touch-action: none;\n }\n\n .ck-overlay-grab-bar {\n margin-block-start: var(--ck-space-2);\n inline-size: var(--ck-space-10);\n block-size: var(--ck-space-1);\n border-radius: var(--ck-radius-full);\n background: var(--ck-color-border);\n }\n\n @media (forced-colors: active) {\n .ck-overlay {\n border: 1px solid CanvasText;\n }\n\n .ck-overlay-grab-bar {\n background: CanvasText;\n }\n }\n }\n `,\n})\nexport class CkOverlayPane {\n readonly grab = input(false);\n\n private readonly outlet = viewChild.required(CdkPortalOutlet);\n readonly viewContainerRef = inject(ViewContainerRef);\n\n attach(portal: Portal<unknown>): void {\n this.outlet().attach(portal);\n }\n}\n","/** A sheet is dismissed by a drag past this share of its height... */\nexport const SWIPE_DISTANCE_RATIO = 1 / 3;\n/** ...or by a flick at least this fast (px per ms) that has moved a little. */\nexport const SWIPE_FLICK_VELOCITY = 0.5;\nexport const SWIPE_FLICK_MIN_DISTANCE = 16;\n/** The speed is measured over this many ms before release. */\nconst VELOCITY_WINDOW = 100;\n\nexport function shouldDismissSwipe(distance: number, height: number, velocity: number): boolean {\n if (distance <= 0 || height <= 0) {\n return false;\n }\n return (\n distance > height * SWIPE_DISTANCE_RATIO ||\n (velocity >= SWIPE_FLICK_VELOCITY && distance >= SWIPE_FLICK_MIN_DISTANCE)\n );\n}\n\nexport interface SheetSwipeOptions {\n /** Contains the grab area (`[data-ck-sheet-grab]`); the swipe starts there. */\n readonly pane: HTMLElement;\n /** The element that follows the finger. */\n readonly panel: HTMLElement;\n readonly backdrop: HTMLElement;\n readonly duration: () => number;\n readonly easing: () => string;\n /** Called on release. `dismiss` says the swipe passed the threshold; return whether the overlay closed. */\n readonly onRelease: (dismiss: boolean) => boolean;\n}\n\ninterface Sample {\n readonly offset: number;\n readonly time: number;\n}\n\n/** Makes the grab area of a bottom sheet draggable. Returns the function that removes it. */\nexport function attachSheetSwipe(options: SheetSwipeOptions): () => void {\n const { pane, panel, backdrop } = options;\n const doc = pane.ownerDocument;\n const now = (): number => (doc.defaultView as Window).performance.now();\n let pointerId: number | null = null;\n let startY = 0;\n let height = 0;\n let offset = 0;\n let samples: Sample[] = [];\n\n function setOffset(next: number): void {\n offset = Math.max(0, next);\n panel.style.transform = `translateY(${offset}px)`;\n backdrop.style.opacity = String(Math.max(0, 1 - offset / Math.max(height, 1)));\n samples.push({ offset, time: now() });\n }\n\n function velocity(): number {\n const current = now();\n const recent = samples.filter((sample) => current - sample.time <= VELOCITY_WINDOW);\n const first = recent[0];\n const last = recent[recent.length - 1];\n if (!first || !last) {\n return 0;\n }\n return (last.offset - first.offset) / Math.max(1, current - first.time);\n }\n\n function stopTracking(): void {\n pointerId = null;\n doc.removeEventListener('pointermove', onMove);\n doc.removeEventListener('pointerup', onUp);\n doc.removeEventListener('pointercancel', onCancel);\n }\n\n function snapBack(): void {\n const from = offset;\n panel.style.transform = '';\n backdrop.style.opacity = '';\n offset = 0;\n const duration = options.duration();\n if (from > 0 && duration > 0 && typeof panel.animate === 'function') {\n const timing = { duration, easing: options.easing() };\n panel.animate([{ transform: `translateY(${from}px)` }, { transform: 'none' }], timing);\n backdrop.animate(\n [{ opacity: String(Math.max(0, 1 - from / Math.max(height, 1))) }, { opacity: '1' }],\n timing,\n );\n }\n }\n\n function onDown(event: PointerEvent): void {\n const target = event.target;\n if (\n pointerId !== null ||\n !event.isPrimary ||\n event.button !== 0 ||\n !(target instanceof Element) ||\n !target.closest('[data-ck-sheet-grab]')\n ) {\n return;\n }\n pointerId = event.pointerId;\n startY = event.clientY;\n height = panel.getBoundingClientRect().height;\n offset = 0;\n samples = [{ offset: 0, time: now() }];\n try {\n (target as HTMLElement).setPointerCapture?.(event.pointerId);\n } catch {\n // A pointer that is already gone cannot be captured; the document listeners still work.\n }\n doc.addEventListener('pointermove', onMove);\n doc.addEventListener('pointerup', onUp);\n doc.addEventListener('pointercancel', onCancel);\n }\n\n function onMove(event: PointerEvent): void {\n if (event.pointerId === pointerId) {\n setOffset(event.clientY - startY);\n }\n }\n\n function onUp(event: PointerEvent): void {\n if (event.pointerId !== pointerId) {\n return;\n }\n setOffset(event.clientY - startY);\n const dismiss = shouldDismissSwipe(offset, height, velocity());\n stopTracking();\n if (!options.onRelease(dismiss)) {\n snapBack();\n }\n }\n\n function onCancel(event: PointerEvent): void {\n if (event.pointerId === pointerId) {\n stopTracking();\n snapBack();\n }\n }\n\n pane.addEventListener('pointerdown', onDown);\n return () => {\n pane.removeEventListener('pointerdown', onDown);\n stopTracking();\n };\n}\n","import { Overlay, OverlayContainer, OverlayRef, ScrollStrategy } from '@angular/cdk/overlay';\nimport { ComponentPortal, ComponentType, Portal, TemplatePortal } from '@angular/cdk/portal';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { DestroyRef, Injectable, Injector, PLATFORM_ID, TemplateRef, inject } from '@angular/core';\nimport { CkFocusTrap, CkFocusTrapFactory, CkInert, CkMedia } from '@ckui/core/internal';\nimport { CkOverlayPane } from './overlay-pane';\nimport { attachSheetSwipe } from './sheet-swipe';\n\nexport type CkOverlayMode = 'auto' | 'modal' | 'sheet' | 'side';\nexport type CkOverlayDismissReason = 'escape' | 'backdrop' | 'swipe';\n\nexport interface CkOverlayConfig {\n /**\n * `auto` becomes a sheet when `CkMedia.sheet()` is true at the moment of opening, else a modal;\n * it never becomes `side`. Default `auto`.\n */\n mode?: CkOverlayMode;\n /** The edge a `side` panel sits on; `end` is the right edge in a left-to-right page. Resolved when opening. Default `end`. */\n side?: 'start' | 'end';\n /** Escape and a click on the backdrop, and for a sheet a swipe down, may close the overlay. Default `true`. */\n dismissible?: boolean;\n /** A sheet as tall as the viewport allows instead of as tall as its content. */\n fullHeight?: boolean;\n panelClass?: string | string[];\n /** Default `dialog`. */\n role?: 'dialog' | 'alertdialog';\n ariaLabel?: string;\n ariaLabelledBy?: string;\n ariaDescribedBy?: string;\n /**\n * Called when the user asks to dismiss (Escape, backdrop, swipe) a dismissible overlay. It is\n * expected to call `handle.close()` straight away; without it the host closes the overlay itself.\n * A sheet that is still open after a swipe snaps back.\n */\n onDismissRequest?: (reason: CkOverlayDismissReason) => void;\n /**\n * Picks the element that takes focus once the overlay has rendered. Without it, or when it\n * returns `null` or something that cannot take focus, the first tabbable element does.\n */\n initialFocus?: () => HTMLElement | null;\n}\n\nexport interface CkOverlayHandle {\n /** The mode resolved when the overlay opened. */\n readonly mode: 'modal' | 'sheet' | 'side';\n /** The element that carries `role`, `aria-modal` and the labels; set `aria-labelledby` here when the title appears later. */\n readonly panel: HTMLElement;\n /** Resolves once the opening animation and the initial focus are done. */\n readonly opened: Promise<void>;\n /** Resolves once the overlay is detached. */\n readonly closed: Promise<void>;\n /** Animates out, then detaches. Repeated calls return the same promise. */\n close(): Promise<void>;\n}\n\nconst DEFAULT_DURATION = 200;\nconst SHEET_MAX_HEIGHT = 'calc(100dvh - env(safe-area-inset-top, 0px))';\nconst MODAL_MARGIN = 'var(--ck-space-4, 1rem)';\nconst SIDE_HEIGHT = '100dvh';\n\ntype State = 'open' | 'closing' | 'closed';\n\ninterface Entry {\n readonly overlayRef: OverlayRef;\n readonly dismissible: boolean;\n readonly dismiss: (reason: CkOverlayDismissReason) => void;\n /** Elements that had focus before this overlay (and ones it inherited) that focus can return to. */\n readonly openers: HTMLElement[];\n /** Runs the whole teardown at once, without animation. Safe to call repeatedly. */\n readonly destroy: () => void;\n state: State;\n}\n\nfunction parseDuration(value: string): number {\n const match = /^\\s*(-?[\\d.]+)(ms|s)\\s*$/.exec(value);\n if (!match) {\n return DEFAULT_DURATION;\n }\n const amount = Number(match[1]) * (match[2] === 's' ? 1000 : 1);\n return Number.isFinite(amount) && amount >= 0 ? amount : DEFAULT_DURATION;\n}\n\n/**\n * Opens modal dialogs, bottom sheets and side panels on the CDK overlay: backdrop, scroll lock, focus trap and\n * restore, `inert` background, Escape / backdrop / swipe dismissal and the open and close animation.\n */\n@Injectable({ providedIn: 'root' })\nexport class CkOverlayHost {\n private readonly overlay = inject(Overlay);\n private readonly overlayContainer = inject(OverlayContainer);\n private readonly media = inject(CkMedia);\n private readonly inert = inject(CkInert);\n private readonly focusTraps = inject(CkFocusTrapFactory);\n private readonly injector = inject(Injector);\n private readonly document = inject(DOCUMENT);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /** Open overlays, topmost last. A closing overlay has already left it. */\n private readonly stack: Entry[] = [];\n private readonly entries = new Set<Entry>();\n private scrollStrategy: ScrollStrategy | null = null;\n private scrollLocks = 0;\n private listening = false;\n\n constructor() {\n inject(DestroyRef).onDestroy(() => {\n for (const entry of [...this.entries]) {\n entry.destroy();\n }\n this.entries.clear();\n this.stack.length = 0;\n this.listen(false);\n if (this.scrollLocks > 0) {\n this.scrollLocks = 0;\n this.scrollStrategy?.disable();\n }\n });\n }\n\n open<C>(\n content: ComponentType<C> | TemplateRef<unknown>,\n config: CkOverlayConfig = {},\n injector?: Injector,\n ): CkOverlayHandle {\n const requested = config.mode ?? 'auto';\n const mode: 'modal' | 'sheet' | 'side' =\n requested === 'auto' ? (this.media.sheet() ? 'sheet' : 'modal') : requested;\n if (!this.isBrowser) {\n return this.inertHandle(mode);\n }\n\n const sheet = mode === 'sheet';\n const side = mode === 'side';\n const dismissible = config.dismissible ?? true;\n const container = this.overlayContainer.getContainerElement();\n container.style.zIndex = 'var(--ck-z-overlay, 1000)';\n const view = this.document.defaultView;\n // The physical edge is resolved now, from the written direction of the page.\n const rtl = view?.getComputedStyle(container).direction === 'rtl';\n const onRight = (config.side ?? 'end') === 'end' ? !rtl : rtl;\n\n const overlayRef = this.overlay.create({\n // Content direction follows the same reading as the edge, not the CDK's startup snapshot.\n direction: rtl ? 'rtl' : 'ltr',\n positionStrategy: side\n ? this.sidePosition(onRight)\n : sheet\n ? this.overlay.position().global().bottom('0').centerHorizontally()\n : this.overlay.position().global().centerHorizontally().centerVertically(),\n scrollStrategy: this.overlay.scrollStrategies.noop(),\n width: sheet ? '100%' : undefined,\n height: side ? SIDE_HEIGHT : sheet && config.fullHeight ? SHEET_MAX_HEIGHT : undefined,\n maxWidth: sheet\n ? undefined\n : side\n ? `calc(100% - ${MODAL_MARGIN})`\n : `calc(100% - 2 * ${MODAL_MARGIN})`,\n maxHeight: side\n ? SIDE_HEIGHT\n : sheet\n ? SHEET_MAX_HEIGHT\n : `calc(100dvh - 2 * ${MODAL_MARGIN})`,\n panelClass: [\n 'ck-overlay',\n `ck-overlay--${mode}`,\n ...(side ? [`ck-overlay--${onRight ? 'right' : 'left'}`] : []),\n ...(config.panelClass === undefined ? [] : [config.panelClass].flat()),\n ],\n disposeOnNavigation: false,\n // The top layer would put every overlay above the toast host; the z-index tokens order them instead.\n usePopover: false,\n });\n const panel = overlayRef.overlayElement;\n const host = overlayRef.hostElement;\n\n let paneRef;\n try {\n paneRef = overlayRef.attach(new ComponentPortal(CkOverlayPane, null, this.injector));\n paneRef.setInput('grab', sheet && dismissible);\n paneRef.changeDetectorRef.detectChanges();\n paneRef.instance.attach(this.contentPortal(content, paneRef.instance, injector));\n } catch (error) {\n overlayRef.dispose();\n throw error;\n }\n\n panel.setAttribute('role', config.role ?? 'dialog');\n panel.setAttribute('aria-modal', 'true');\n panel.tabIndex = -1;\n for (const [attribute, value] of [\n ['aria-label', config.ariaLabel],\n ['aria-labelledby', config.ariaLabelledBy],\n ['aria-describedby', config.ariaDescribedBy],\n ] as const) {\n if (value) {\n panel.setAttribute(attribute, value);\n }\n }\n\n const backdrop = this.document.createElement('div');\n backdrop.className = 'ck-overlay-backdrop';\n host.prepend(backdrop);\n\n // The opener is recorded before the background turns inert; inert would blur it.\n const opener =\n this.document.activeElement instanceof HTMLElement ? this.document.activeElement : null;\n const trap: CkFocusTrap = this.focusTraps.create(panel);\n const activation = trap.activate(config.initialFocus);\n\n const releaseInert = this.inert.hold([\n ...this.inert.backgroundElements(container),\n ...this.stack.map((other) => other.overlayRef.hostElement),\n ]);\n this.lockScroll();\n\n let resolveClosed: () => void = () => undefined;\n const closed = new Promise<void>((resolve) => (resolveClosed = resolve));\n let closing: Promise<void> | null = null;\n let released = false;\n let finishedOnce = false;\n let openAnimations: Animation[] = [];\n\n const motion = () => {\n const style = view!.getComputedStyle(panel);\n return {\n duration: this.media.reducedMotion()\n ? 0\n : parseDuration(style.getPropertyValue('--ck-duration-normal')),\n easing: style.getPropertyValue('--ck-ease-standard').trim() || 'ease',\n };\n };\n\n const play = (\n element: HTMLElement,\n keyframes: Keyframe[],\n fill: FillMode,\n ): Animation | null => {\n const { duration, easing } = motion();\n if (duration <= 0 || typeof element.animate !== 'function') {\n return null;\n }\n return element.animate(keyframes, { duration, easing, fill });\n };\n\n const finished = (animation: Animation | null): Promise<unknown> =>\n animation ? animation.finished.catch(() => undefined) : Promise.resolve();\n\n const entry: Entry = {\n overlayRef,\n dismissible,\n state: 'open',\n openers: opener ? [opener] : [],\n dismiss: (reason) => {\n if (config.onDismissRequest) {\n config.onDismissRequest(reason);\n } else {\n void close();\n }\n },\n destroy: () => {\n release();\n finish();\n },\n };\n this.entries.add(entry);\n this.stack.push(entry);\n this.listen(true);\n\n const detachSwipe =\n sheet && dismissible\n ? attachSheetSwipe({\n pane: paneRef.location.nativeElement as HTMLElement,\n panel,\n backdrop,\n duration: () => motion().duration,\n easing: () => motion().easing,\n onRelease: (dismissed) => {\n if (dismissed) {\n entry.dismiss('swipe');\n }\n return entry.state !== 'open';\n },\n })\n : () => undefined;\n\n const onBackdropClick = (): void => {\n if (entry.state === 'open' && dismissible && this.stack.at(-1) === entry) {\n entry.dismiss('backdrop');\n }\n };\n backdrop.addEventListener('click', onBackdropClick);\n\n /** Everything that must stop the moment the overlay starts closing. */\n const release = (): void => {\n if (released) {\n return;\n }\n released = true;\n entry.state = 'closing';\n const index = this.stack.indexOf(entry);\n this.stack.splice(index, 1);\n // An overlay above this one gets its openers, so focus can still reach the page later.\n this.stack[index]?.openers.unshift(...entry.openers);\n detachSwipe();\n backdrop.removeEventListener('click', onBackdropClick);\n for (const animation of openAnimations) {\n animation.cancel();\n }\n // The background has to be live again before the opener can take focus back.\n releaseInert();\n host.inert = true;\n trap.release();\n this.restoreFocus(entry);\n };\n\n /** Everything that happens once the overlay is gone. */\n const finish = (): void => {\n if (finishedOnce) {\n return;\n }\n finishedOnce = true;\n entry.state = 'closed';\n this.entries.delete(entry);\n overlayRef.dispose();\n backdrop.remove();\n this.unlockScroll();\n if (this.entries.size === 0) {\n this.listen(false);\n }\n resolveClosed();\n };\n\n // Out of the screen towards the edge the panel sits on.\n const offscreen = side ? `translateX(${onRight ? '' : '-'}100%)` : 'translateY(100%)';\n const enter: Keyframe[] =\n sheet || side\n ? [{ transform: offscreen }, { transform: 'none' }]\n : [\n { opacity: 0, transform: 'scale(0.96)' },\n { opacity: 1, transform: 'none' },\n ];\n openAnimations = [\n play(panel, enter, 'none'),\n play(backdrop, [{ opacity: 0 }, { opacity: 1 }], 'none'),\n ].filter((animation): animation is Animation => animation !== null);\n\n // Nothing focusable inside: the panel takes focus right away, not after the animation.\n void activation.then((focused) => {\n if (entry.state === 'open' && !focused) {\n panel.focus({ preventScroll: true });\n }\n });\n const opened = Promise.all([\n activation,\n ...openAnimations.map((animation) => finished(animation)),\n ]).then(() => undefined);\n\n const close = (): Promise<void> => {\n if (closing) {\n return closing;\n }\n release();\n const leave: Keyframe[] =\n sheet || side ? [{ transform: offscreen }] : [{ opacity: 0, transform: 'scale(0.96)' }];\n const animations = [\n play(panel, leave, 'forwards'),\n play(backdrop, [{ opacity: 0 }], 'forwards'),\n ];\n closing = Promise.all(animations.map(finished)).then(finish);\n return closing;\n };\n\n return { mode, panel, opened, closed, close };\n }\n\n /** Focus did not return to where it came from (opener disabled, inert or gone): find it a home. */\n private restoreFocus(closed: Entry): void {\n const top = this.stack.at(-1);\n const active = this.document.activeElement;\n if (top?.overlayRef.overlayElement.contains(active)) {\n return;\n }\n const openers = [...closed.openers].reverse().filter((candidate) => candidate.isConnected);\n if (active && openers.includes(active as HTMLElement)) {\n return;\n }\n for (const candidate of openers) {\n candidate.focus();\n if (this.document.activeElement === candidate) {\n return;\n }\n }\n top?.overlayRef.overlayElement.focus({ preventScroll: true });\n }\n\n /** Full height, flush against the physical left or right edge. */\n private sidePosition(right: boolean) {\n const position = this.overlay.position().global().top('0');\n return right ? position.right('0') : position.left('0');\n }\n\n private contentPortal<C>(\n content: ComponentType<C> | TemplateRef<unknown>,\n pane: CkOverlayPane,\n injector: Injector | undefined,\n ): Portal<unknown> {\n return content instanceof TemplateRef\n ? new TemplatePortal(content, pane.viewContainerRef, undefined, injector)\n : new ComponentPortal(content, null, injector ?? this.injector);\n }\n\n /** What the server gets: nothing is rendered, and the overlay counts as closed. */\n private inertHandle(mode: 'modal' | 'sheet' | 'side'): CkOverlayHandle {\n return {\n mode,\n panel: this.document.createElement('div'),\n opened: Promise.resolve(),\n closed: Promise.resolve(),\n close: () => Promise.resolve(),\n };\n }\n\n private lockScroll(): void {\n this.scrollStrategy ??= this.overlay.scrollStrategies.block();\n if (this.scrollLocks++ === 0) {\n this.scrollStrategy.enable();\n }\n }\n\n private unlockScroll(): void {\n if (this.scrollLocks > 0 && --this.scrollLocks === 0) {\n this.scrollStrategy?.disable();\n }\n }\n\n private listen(active: boolean): void {\n if (active === this.listening) {\n return;\n }\n this.listening = active;\n if (active) {\n this.document.addEventListener('keydown', this.onKeydown);\n } else {\n this.document.removeEventListener('keydown', this.onKeydown);\n }\n }\n\n private readonly onKeydown = (event: KeyboardEvent): void => {\n if (event.key !== 'Escape' || event.defaultPrevented || event.isComposing) {\n return;\n }\n const top = this.stack.at(-1);\n if (top?.dismissible) {\n event.preventDefault();\n top.dismiss('escape');\n }\n };\n}\n"],"mappings":";;;;;;AAyFA,IAAa,gBAAb,MAAa,cAAa;CACf,OAAO,MAAM,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAEX,SAAS,UAAU,SAAS,iBAAgB,GAAA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,IAAI,KAAK,kBAAkB,GACzB,KAAK,eAAe,OAAM;CAE9B;CAEQ,eAAY;EAClB,IAAI,KAAK,cAAc,KAAK,EAAE,KAAK,gBAAgB,GACjD,KAAK,gBAAgB,QAAO;CAEhC;CAEQ,OAAO,QAAe;EAC5B,IAAI,WAAW,KAAK,WAClB;EAEF,KAAK,YAAY;EACjB,IAAI,QACF,KAAK,SAAS,iBAAiB,WAAW,KAAK,SAAS;OAExD,KAAK,SAAS,oBAAoB,WAAW,KAAK,SAAS;CAE/D;CAEiB,aAAa,UAA8B;EAC1D,IAAI,MAAM,QAAQ,YAAY,MAAM,oBAAoB,MAAM,aAC5D;EAEF,MAAM,MAAM,KAAK,MAAM,GAAG,EAAE;EAC5B,IAAI,KAAK,aAAa;GACpB,MAAM,eAAc;GACpB,IAAI,QAAQ,QAAQ;EACtB;CACF;CAjXW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAa,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAb,OAAA,QAAA,GAAA,sBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAa,YADA;CAAM,CAAA;;AACnB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAa,YAAA,CAAA;EADzB,MAAA;EAAW,MAAA,CAAA,EAAE,YAAY,OAAM,CAAE"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, Directive, ElementRef, PLATFORM_ID, Renderer2, ViewEncapsulation, afterNextRender, computed, contentChild, inject, input, model, viewChild } from "@angular/core";
|
|
3
|
+
import { isPlatformBrowser } from "@angular/common";
|
|
4
|
+
import { CK_CONFIG } from "@ckui/core";
|
|
5
|
+
import { CkValueControl, createCkId, hasAccessibleName, provideCkValueAccessor } from "@ckui/core/internal";
|
|
6
|
+
var CkSwitchHint = class CkSwitchHint {
|
|
7
|
+
id = input(createCkId("ck-switch-hint"), ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
|
|
8
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
9
|
+
minVersion: "12.0.0",
|
|
10
|
+
version: "22.2.4",
|
|
11
|
+
ngImport: i0,
|
|
12
|
+
type: CkSwitchHint,
|
|
13
|
+
deps: [],
|
|
14
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
15
|
+
});
|
|
16
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
17
|
+
minVersion: "17.1.0",
|
|
18
|
+
version: "22.2.4",
|
|
19
|
+
type: CkSwitchHint,
|
|
20
|
+
isStandalone: true,
|
|
21
|
+
selector: "ck-switch-hint",
|
|
22
|
+
inputs: { id: {
|
|
23
|
+
classPropertyName: "id",
|
|
24
|
+
publicName: "id",
|
|
25
|
+
isSignal: true,
|
|
26
|
+
isRequired: false,
|
|
27
|
+
transformFunction: null
|
|
28
|
+
} },
|
|
29
|
+
host: {
|
|
30
|
+
properties: { "attr.id": "id()" },
|
|
31
|
+
classAttribute: "ck-switch-hint"
|
|
32
|
+
},
|
|
33
|
+
ngImport: i0
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
37
|
+
minVersion: "12.0.0",
|
|
38
|
+
version: "22.2.4",
|
|
39
|
+
ngImport: i0,
|
|
40
|
+
type: CkSwitchHint,
|
|
41
|
+
decorators: [{
|
|
42
|
+
type: Directive,
|
|
43
|
+
args: [{
|
|
44
|
+
selector: "ck-switch-hint",
|
|
45
|
+
host: {
|
|
46
|
+
class: "ck-switch-hint",
|
|
47
|
+
"[attr.id]": "id()"
|
|
48
|
+
}
|
|
49
|
+
}]
|
|
50
|
+
}],
|
|
51
|
+
propDecorators: { id: [{
|
|
52
|
+
type: i0.Input,
|
|
53
|
+
args: [{
|
|
54
|
+
isSignal: true,
|
|
55
|
+
alias: "id",
|
|
56
|
+
required: false
|
|
57
|
+
}]
|
|
58
|
+
}] }
|
|
59
|
+
});
|
|
60
|
+
var CkSwitch = class CkSwitch extends CkValueControl {
|
|
61
|
+
value = model(false, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
62
|
+
size = input(void 0, ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
63
|
+
labelPosition = input("start", ...ngDevMode ? [{ debugName: "labelPosition" }] : /* istanbul ignore next */ []);
|
|
64
|
+
ariaLabel = input(null, {
|
|
65
|
+
...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
|
|
66
|
+
alias: "aria-label"
|
|
67
|
+
});
|
|
68
|
+
ariaLabelledby = input(null, {
|
|
69
|
+
...ngDevMode ? { debugName: "ariaLabelledby" } : /* istanbul ignore next */ {},
|
|
70
|
+
alias: "aria-labelledby"
|
|
71
|
+
});
|
|
72
|
+
ariaDescribedby = input(null, {
|
|
73
|
+
...ngDevMode ? { debugName: "ariaDescribedby" } : /* istanbul ignore next */ {},
|
|
74
|
+
alias: "aria-describedby"
|
|
75
|
+
});
|
|
76
|
+
config = inject(CK_CONFIG);
|
|
77
|
+
element = inject(ElementRef).nativeElement;
|
|
78
|
+
inputRef = viewChild.required("input", ...ngDevMode ? [{ debugName: "inputRef" }] : /* istanbul ignore next */ []);
|
|
79
|
+
hint = contentChild(CkSwitchHint, ...ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []);
|
|
80
|
+
textId = createCkId("ck-switch-text");
|
|
81
|
+
on = computed(() => this.value() === true, ...ngDevMode ? [{ debugName: "on" }] : /* istanbul ignore next */ []);
|
|
82
|
+
modifierClasses = computed(() => `ck-switch--${this.size() ?? this.config.size} ck-switch--label-${this.labelPosition() === "end" ? "end" : "start"}`, ...ngDevMode ? [{ debugName: "modifierClasses" }] : /* istanbul ignore next */ []);
|
|
83
|
+
labelledby = computed(() => this.ariaLabelledby() ?? (this.ariaLabel() ? null : this.textId), ...ngDevMode ? [{ debugName: "labelledby" }] : /* istanbul ignore next */ []);
|
|
84
|
+
describedby = computed(() => {
|
|
85
|
+
const ids = [this.hint()?.id(), this.ariaDescribedby()].filter((id) => !!id);
|
|
86
|
+
return ids.length > 0 ? ids.join(" ") : null;
|
|
87
|
+
}, ...ngDevMode ? [{ debugName: "describedby" }] : /* istanbul ignore next */ []);
|
|
88
|
+
constructor() {
|
|
89
|
+
super();
|
|
90
|
+
const renderer = inject(Renderer2);
|
|
91
|
+
renderer.removeAttribute(this.element, "aria-label");
|
|
92
|
+
renderer.removeAttribute(this.element, "aria-labelledby");
|
|
93
|
+
renderer.removeAttribute(this.element, "aria-describedby");
|
|
94
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode && isPlatformBrowser(inject(PLATFORM_ID))) {
|
|
95
|
+
let destroyed = false;
|
|
96
|
+
inject(DestroyRef).onDestroy(() => destroyed = true);
|
|
97
|
+
afterNextRender(() => {
|
|
98
|
+
if (!destroyed && !hasAccessibleName(this.inputRef().nativeElement, {
|
|
99
|
+
title: false,
|
|
100
|
+
text: false
|
|
101
|
+
})) console.warn("[ckui] ck-switch has no accessible name. Add text, or an aria-label or aria-labelledby.", this.element);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
onToggle() {
|
|
106
|
+
const input = this.inputRef().nativeElement;
|
|
107
|
+
this.commit(input.checked);
|
|
108
|
+
input.checked = this.on();
|
|
109
|
+
}
|
|
110
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
111
|
+
minVersion: "12.0.0",
|
|
112
|
+
version: "22.2.4",
|
|
113
|
+
ngImport: i0,
|
|
114
|
+
type: CkSwitch,
|
|
115
|
+
deps: [],
|
|
116
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
117
|
+
});
|
|
118
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
119
|
+
minVersion: "17.2.0",
|
|
120
|
+
version: "22.2.4",
|
|
121
|
+
type: CkSwitch,
|
|
122
|
+
isStandalone: true,
|
|
123
|
+
selector: "ck-switch",
|
|
124
|
+
inputs: {
|
|
125
|
+
value: {
|
|
126
|
+
classPropertyName: "value",
|
|
127
|
+
publicName: "value",
|
|
128
|
+
isSignal: true,
|
|
129
|
+
isRequired: false,
|
|
130
|
+
transformFunction: null
|
|
131
|
+
},
|
|
132
|
+
size: {
|
|
133
|
+
classPropertyName: "size",
|
|
134
|
+
publicName: "size",
|
|
135
|
+
isSignal: true,
|
|
136
|
+
isRequired: false,
|
|
137
|
+
transformFunction: null
|
|
138
|
+
},
|
|
139
|
+
labelPosition: {
|
|
140
|
+
classPropertyName: "labelPosition",
|
|
141
|
+
publicName: "labelPosition",
|
|
142
|
+
isSignal: true,
|
|
143
|
+
isRequired: false,
|
|
144
|
+
transformFunction: null
|
|
145
|
+
},
|
|
146
|
+
ariaLabel: {
|
|
147
|
+
classPropertyName: "ariaLabel",
|
|
148
|
+
publicName: "aria-label",
|
|
149
|
+
isSignal: true,
|
|
150
|
+
isRequired: false,
|
|
151
|
+
transformFunction: null
|
|
152
|
+
},
|
|
153
|
+
ariaLabelledby: {
|
|
154
|
+
classPropertyName: "ariaLabelledby",
|
|
155
|
+
publicName: "aria-labelledby",
|
|
156
|
+
isSignal: true,
|
|
157
|
+
isRequired: false,
|
|
158
|
+
transformFunction: null
|
|
159
|
+
},
|
|
160
|
+
ariaDescribedby: {
|
|
161
|
+
classPropertyName: "ariaDescribedby",
|
|
162
|
+
publicName: "aria-describedby",
|
|
163
|
+
isSignal: true,
|
|
164
|
+
isRequired: false,
|
|
165
|
+
transformFunction: null
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
outputs: { value: "valueChange" },
|
|
169
|
+
host: { classAttribute: "ck-switch-host" },
|
|
170
|
+
providers: [provideCkValueAccessor(CkSwitch)],
|
|
171
|
+
queries: [{
|
|
172
|
+
propertyName: "hint",
|
|
173
|
+
first: true,
|
|
174
|
+
predicate: CkSwitchHint,
|
|
175
|
+
descendants: true,
|
|
176
|
+
isSignal: true
|
|
177
|
+
}],
|
|
178
|
+
viewQueries: [{
|
|
179
|
+
propertyName: "inputRef",
|
|
180
|
+
first: true,
|
|
181
|
+
predicate: ["input"],
|
|
182
|
+
descendants: true,
|
|
183
|
+
isSignal: true
|
|
184
|
+
}],
|
|
185
|
+
usesInheritance: true,
|
|
186
|
+
ngImport: i0,
|
|
187
|
+
template: `
|
|
188
|
+
<label class="ck-switch" [class]="modifierClasses()" [class.ck-switch--disabled]="isDisabled()">
|
|
189
|
+
<span class="ck-switch__control">
|
|
190
|
+
<input
|
|
191
|
+
#input
|
|
192
|
+
class="ck-switch__input"
|
|
193
|
+
type="checkbox"
|
|
194
|
+
role="switch"
|
|
195
|
+
[checked]="on()"
|
|
196
|
+
[disabled]="isDisabled()"
|
|
197
|
+
[attr.aria-label]="ariaLabel()"
|
|
198
|
+
[attr.aria-labelledby]="labelledby()"
|
|
199
|
+
[attr.aria-describedby]="describedby()"
|
|
200
|
+
(change)="onToggle()"
|
|
201
|
+
(blur)="markTouched()"
|
|
202
|
+
/>
|
|
203
|
+
<span class="ck-switch__track" aria-hidden="true">
|
|
204
|
+
<span class="ck-switch__thumb"></span>
|
|
205
|
+
</span>
|
|
206
|
+
</span>
|
|
207
|
+
<span class="ck-switch__body">
|
|
208
|
+
<span class="ck-switch__text" [id]="textId"><ng-content /></span>
|
|
209
|
+
<ng-content select="ck-switch-hint" />
|
|
210
|
+
</span>
|
|
211
|
+
</label>
|
|
212
|
+
`,
|
|
213
|
+
isInline: true,
|
|
214
|
+
styles: ["@layer ckui{.ck-switch-host{display:block}.ck-switch{--_ck-switch-border: 1px;--_ck-switch-gap: var(--ck-switch-thumb-gap, .1875rem);--_ck-switch-thumb-size: calc( var(--_ck-switch-height) - 2 * (var(--_ck-switch-border) + var(--_ck-switch-gap)) );display:flex;align-items:center;box-sizing:border-box;min-block-size:var(--_ck-switch-row);padding-block:var(--ck-space-1);color:var(--ck-color-fg);color-scheme:var(--ck-color-scheme);font-family:inherit;font-size:var(--_ck-switch-font-size);line-height:var(--ck-line-height-tight);cursor:pointer;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}.ck-switch--sm{--_ck-switch-row: var(--ck-control-height-sm);--_ck-switch-font-size: var(--ck-control-font-size-sm);--_ck-switch-width: 2.25rem;--_ck-switch-height: 1.25rem}.ck-switch--md{--_ck-switch-row: var(--ck-control-height-md);--_ck-switch-font-size: var(--ck-control-font-size-md);--_ck-switch-width: 2.75rem;--_ck-switch-height: 1.5rem}.ck-switch--lg{--_ck-switch-row: var(--ck-control-height-lg);--_ck-switch-font-size: var(--ck-control-font-size-lg);--_ck-switch-width: 3.25rem;--_ck-switch-height: 1.75rem}.ck-switch--xl{--_ck-switch-row: var(--ck-control-height-xl);--_ck-switch-font-size: var(--ck-control-font-size-xl);--_ck-switch-width: 4rem;--_ck-switch-height: 2.25rem}.ck-switch__control{position:relative;flex:none;box-sizing:border-box;inline-size:var(--_ck-switch-width);block-size:var(--_ck-switch-height)}.ck-switch__input{position:absolute;inset:0;box-sizing:border-box;inline-size:100%;block-size:100%;margin:0;padding:0;border:0;opacity:0;appearance:none;cursor:inherit}.ck-switch__track{position:absolute;inset:0;box-sizing:border-box;border:var(--_ck-switch-border) solid var(--ck-switch-border-color, var(--ck-color-control-border));border-radius:var(--ck-switch-radius, var(--ck-radius-full));background:var(--ck-switch-track, var(--ck-color-control));pointer-events:none;transition:background-color var(--ck-duration-normal) var(--ck-ease-standard),border-color var(--ck-duration-normal) var(--ck-ease-standard)}.ck-switch__thumb{position:absolute;inset-block-start:var(--_ck-switch-gap);inset-inline-start:var(--_ck-switch-gap);box-sizing:border-box;inline-size:var(--_ck-switch-thumb-size);block-size:var(--_ck-switch-thumb-size);border-radius:var(--ck-radius-full);background:var(--ck-switch-thumb, var(--ck-color-fg-muted));transition:inset-inline-start var(--ck-duration-normal) var(--ck-ease-standard),background-color var(--ck-duration-normal) var(--ck-ease-standard)}.ck-switch__input:checked+.ck-switch__track{border-color:var(--ck-switch-track-on, var(--ck-color-primary));background:var(--ck-switch-track-on, var(--ck-color-primary))}.ck-switch__input:checked+.ck-switch__track .ck-switch__thumb{inset-inline-start:calc(100% - var(--_ck-switch-thumb-size) - var(--_ck-switch-gap));background:var(--ck-switch-thumb-on, var(--ck-color-on-primary))}.ck-switch__body{display:block;flex:1 1 auto;min-inline-size:0;overflow-wrap:break-word}.ck-switch--label-start .ck-switch__body{order:-1}.ck-switch--label-start .ck-switch__body:has(>:not(:empty)){margin-inline-end:var(--ck-space-3)}.ck-switch--label-end .ck-switch__body:has(>:not(:empty)){margin-inline-start:var(--ck-space-3)}.ck-switch__text{display:block}.ck-switch:not(:has(.ck-switch__body>:not(:empty))){inline-size:fit-content;max-inline-size:100%}.ck-switch:not(:has(.ck-switch__body>:not(:empty))) .ck-switch__body{flex:none}.ck-switch-hint{display:block;margin-block-start:var(--ck-space-1);color:var(--ck-color-fg-muted);font-size:var(--ck-font-size-sm);line-height:var(--ck-line-height-normal)}.ck-switch__input:focus-visible+.ck-switch__track{outline:var(--ck-focus-ring);outline-offset:var(--ck-focus-ring-offset)}.ck-switch--disabled,.ck-switch:has(.ck-switch__input:disabled){color:var(--ck-color-fg-disabled);cursor:not-allowed}.ck-switch:has(.ck-switch__input:disabled) .ck-switch-hint{color:var(--ck-color-fg-disabled)}.ck-switch__input:disabled+.ck-switch__track{border-color:var(--ck-color-fg-disabled)}.ck-switch__input:disabled+.ck-switch__track .ck-switch__thumb{background:var(--ck-color-fg-disabled)}.ck-switch__input:disabled:checked+.ck-switch__track{background:var(--ck-color-fg-disabled)}.ck-switch__input:disabled:checked+.ck-switch__track .ck-switch__thumb{background:var(--ck-color-on-primary)}@media(prefers-reduced-motion:reduce){.ck-switch__track,.ck-switch__thumb{transition:none}}@media(forced-colors:active){.ck-switch__track{border-color:CanvasText;background:Canvas}.ck-switch__thumb{background:CanvasText}.ck-switch__input:checked+.ck-switch__track{border-color:Highlight;background:Highlight}.ck-switch__input:checked+.ck-switch__track .ck-switch__thumb{background:HighlightText}.ck-switch__input:focus-visible+.ck-switch__track{outline:var(--ck-focus-ring-width) solid Highlight;outline-offset:var(--ck-focus-ring-offset)}.ck-switch--disabled,.ck-switch--disabled .ck-switch-hint,.ck-switch:has(.ck-switch__input:disabled),.ck-switch:has(.ck-switch__input:disabled) .ck-switch-hint{color:GrayText}.ck-switch__input:disabled+.ck-switch__track,.ck-switch__input:disabled:checked+.ck-switch__track{border-color:GrayText;background:Canvas}.ck-switch__input:disabled+.ck-switch__track .ck-switch__thumb,.ck-switch__input:disabled:checked+.ck-switch__track .ck-switch__thumb{background:GrayText}}}\n"],
|
|
215
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
216
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
220
|
+
minVersion: "12.0.0",
|
|
221
|
+
version: "22.2.4",
|
|
222
|
+
ngImport: i0,
|
|
223
|
+
type: CkSwitch,
|
|
224
|
+
decorators: [{
|
|
225
|
+
type: Component,
|
|
226
|
+
args: [{
|
|
227
|
+
selector: "ck-switch",
|
|
228
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
229
|
+
encapsulation: ViewEncapsulation.None,
|
|
230
|
+
providers: [provideCkValueAccessor(CkSwitch)],
|
|
231
|
+
host: { class: "ck-switch-host" },
|
|
232
|
+
template: `
|
|
233
|
+
<label class="ck-switch" [class]="modifierClasses()" [class.ck-switch--disabled]="isDisabled()">
|
|
234
|
+
<span class="ck-switch__control">
|
|
235
|
+
<input
|
|
236
|
+
#input
|
|
237
|
+
class="ck-switch__input"
|
|
238
|
+
type="checkbox"
|
|
239
|
+
role="switch"
|
|
240
|
+
[checked]="on()"
|
|
241
|
+
[disabled]="isDisabled()"
|
|
242
|
+
[attr.aria-label]="ariaLabel()"
|
|
243
|
+
[attr.aria-labelledby]="labelledby()"
|
|
244
|
+
[attr.aria-describedby]="describedby()"
|
|
245
|
+
(change)="onToggle()"
|
|
246
|
+
(blur)="markTouched()"
|
|
247
|
+
/>
|
|
248
|
+
<span class="ck-switch__track" aria-hidden="true">
|
|
249
|
+
<span class="ck-switch__thumb"></span>
|
|
250
|
+
</span>
|
|
251
|
+
</span>
|
|
252
|
+
<span class="ck-switch__body">
|
|
253
|
+
<span class="ck-switch__text" [id]="textId"><ng-content /></span>
|
|
254
|
+
<ng-content select="ck-switch-hint" />
|
|
255
|
+
</span>
|
|
256
|
+
</label>
|
|
257
|
+
`,
|
|
258
|
+
styles: ["@layer ckui{.ck-switch-host{display:block}.ck-switch{--_ck-switch-border: 1px;--_ck-switch-gap: var(--ck-switch-thumb-gap, .1875rem);--_ck-switch-thumb-size: calc( var(--_ck-switch-height) - 2 * (var(--_ck-switch-border) + var(--_ck-switch-gap)) );display:flex;align-items:center;box-sizing:border-box;min-block-size:var(--_ck-switch-row);padding-block:var(--ck-space-1);color:var(--ck-color-fg);color-scheme:var(--ck-color-scheme);font-family:inherit;font-size:var(--_ck-switch-font-size);line-height:var(--ck-line-height-tight);cursor:pointer;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}.ck-switch--sm{--_ck-switch-row: var(--ck-control-height-sm);--_ck-switch-font-size: var(--ck-control-font-size-sm);--_ck-switch-width: 2.25rem;--_ck-switch-height: 1.25rem}.ck-switch--md{--_ck-switch-row: var(--ck-control-height-md);--_ck-switch-font-size: var(--ck-control-font-size-md);--_ck-switch-width: 2.75rem;--_ck-switch-height: 1.5rem}.ck-switch--lg{--_ck-switch-row: var(--ck-control-height-lg);--_ck-switch-font-size: var(--ck-control-font-size-lg);--_ck-switch-width: 3.25rem;--_ck-switch-height: 1.75rem}.ck-switch--xl{--_ck-switch-row: var(--ck-control-height-xl);--_ck-switch-font-size: var(--ck-control-font-size-xl);--_ck-switch-width: 4rem;--_ck-switch-height: 2.25rem}.ck-switch__control{position:relative;flex:none;box-sizing:border-box;inline-size:var(--_ck-switch-width);block-size:var(--_ck-switch-height)}.ck-switch__input{position:absolute;inset:0;box-sizing:border-box;inline-size:100%;block-size:100%;margin:0;padding:0;border:0;opacity:0;appearance:none;cursor:inherit}.ck-switch__track{position:absolute;inset:0;box-sizing:border-box;border:var(--_ck-switch-border) solid var(--ck-switch-border-color, var(--ck-color-control-border));border-radius:var(--ck-switch-radius, var(--ck-radius-full));background:var(--ck-switch-track, var(--ck-color-control));pointer-events:none;transition:background-color var(--ck-duration-normal) var(--ck-ease-standard),border-color var(--ck-duration-normal) var(--ck-ease-standard)}.ck-switch__thumb{position:absolute;inset-block-start:var(--_ck-switch-gap);inset-inline-start:var(--_ck-switch-gap);box-sizing:border-box;inline-size:var(--_ck-switch-thumb-size);block-size:var(--_ck-switch-thumb-size);border-radius:var(--ck-radius-full);background:var(--ck-switch-thumb, var(--ck-color-fg-muted));transition:inset-inline-start var(--ck-duration-normal) var(--ck-ease-standard),background-color var(--ck-duration-normal) var(--ck-ease-standard)}.ck-switch__input:checked+.ck-switch__track{border-color:var(--ck-switch-track-on, var(--ck-color-primary));background:var(--ck-switch-track-on, var(--ck-color-primary))}.ck-switch__input:checked+.ck-switch__track .ck-switch__thumb{inset-inline-start:calc(100% - var(--_ck-switch-thumb-size) - var(--_ck-switch-gap));background:var(--ck-switch-thumb-on, var(--ck-color-on-primary))}.ck-switch__body{display:block;flex:1 1 auto;min-inline-size:0;overflow-wrap:break-word}.ck-switch--label-start .ck-switch__body{order:-1}.ck-switch--label-start .ck-switch__body:has(>:not(:empty)){margin-inline-end:var(--ck-space-3)}.ck-switch--label-end .ck-switch__body:has(>:not(:empty)){margin-inline-start:var(--ck-space-3)}.ck-switch__text{display:block}.ck-switch:not(:has(.ck-switch__body>:not(:empty))){inline-size:fit-content;max-inline-size:100%}.ck-switch:not(:has(.ck-switch__body>:not(:empty))) .ck-switch__body{flex:none}.ck-switch-hint{display:block;margin-block-start:var(--ck-space-1);color:var(--ck-color-fg-muted);font-size:var(--ck-font-size-sm);line-height:var(--ck-line-height-normal)}.ck-switch__input:focus-visible+.ck-switch__track{outline:var(--ck-focus-ring);outline-offset:var(--ck-focus-ring-offset)}.ck-switch--disabled,.ck-switch:has(.ck-switch__input:disabled){color:var(--ck-color-fg-disabled);cursor:not-allowed}.ck-switch:has(.ck-switch__input:disabled) .ck-switch-hint{color:var(--ck-color-fg-disabled)}.ck-switch__input:disabled+.ck-switch__track{border-color:var(--ck-color-fg-disabled)}.ck-switch__input:disabled+.ck-switch__track .ck-switch__thumb{background:var(--ck-color-fg-disabled)}.ck-switch__input:disabled:checked+.ck-switch__track{background:var(--ck-color-fg-disabled)}.ck-switch__input:disabled:checked+.ck-switch__track .ck-switch__thumb{background:var(--ck-color-on-primary)}@media(prefers-reduced-motion:reduce){.ck-switch__track,.ck-switch__thumb{transition:none}}@media(forced-colors:active){.ck-switch__track{border-color:CanvasText;background:Canvas}.ck-switch__thumb{background:CanvasText}.ck-switch__input:checked+.ck-switch__track{border-color:Highlight;background:Highlight}.ck-switch__input:checked+.ck-switch__track .ck-switch__thumb{background:HighlightText}.ck-switch__input:focus-visible+.ck-switch__track{outline:var(--ck-focus-ring-width) solid Highlight;outline-offset:var(--ck-focus-ring-offset)}.ck-switch--disabled,.ck-switch--disabled .ck-switch-hint,.ck-switch:has(.ck-switch__input:disabled),.ck-switch:has(.ck-switch__input:disabled) .ck-switch-hint{color:GrayText}.ck-switch__input:disabled+.ck-switch__track,.ck-switch__input:disabled:checked+.ck-switch__track{border-color:GrayText;background:Canvas}.ck-switch__input:disabled+.ck-switch__track .ck-switch__thumb,.ck-switch__input:disabled:checked+.ck-switch__track .ck-switch__thumb{background:GrayText}}}\n"]
|
|
259
|
+
}]
|
|
260
|
+
}],
|
|
261
|
+
ctorParameters: () => [],
|
|
262
|
+
propDecorators: {
|
|
263
|
+
value: [{
|
|
264
|
+
type: i0.Input,
|
|
265
|
+
args: [{
|
|
266
|
+
isSignal: true,
|
|
267
|
+
alias: "value",
|
|
268
|
+
required: false
|
|
269
|
+
}]
|
|
270
|
+
}, {
|
|
271
|
+
type: i0.Output,
|
|
272
|
+
args: ["valueChange"]
|
|
273
|
+
}],
|
|
274
|
+
size: [{
|
|
275
|
+
type: i0.Input,
|
|
276
|
+
args: [{
|
|
277
|
+
isSignal: true,
|
|
278
|
+
alias: "size",
|
|
279
|
+
required: false
|
|
280
|
+
}]
|
|
281
|
+
}],
|
|
282
|
+
labelPosition: [{
|
|
283
|
+
type: i0.Input,
|
|
284
|
+
args: [{
|
|
285
|
+
isSignal: true,
|
|
286
|
+
alias: "labelPosition",
|
|
287
|
+
required: false
|
|
288
|
+
}]
|
|
289
|
+
}],
|
|
290
|
+
ariaLabel: [{
|
|
291
|
+
type: i0.Input,
|
|
292
|
+
args: [{
|
|
293
|
+
isSignal: true,
|
|
294
|
+
alias: "aria-label",
|
|
295
|
+
required: false
|
|
296
|
+
}]
|
|
297
|
+
}],
|
|
298
|
+
ariaLabelledby: [{
|
|
299
|
+
type: i0.Input,
|
|
300
|
+
args: [{
|
|
301
|
+
isSignal: true,
|
|
302
|
+
alias: "aria-labelledby",
|
|
303
|
+
required: false
|
|
304
|
+
}]
|
|
305
|
+
}],
|
|
306
|
+
ariaDescribedby: [{
|
|
307
|
+
type: i0.Input,
|
|
308
|
+
args: [{
|
|
309
|
+
isSignal: true,
|
|
310
|
+
alias: "aria-describedby",
|
|
311
|
+
required: false
|
|
312
|
+
}]
|
|
313
|
+
}],
|
|
314
|
+
inputRef: [{
|
|
315
|
+
type: i0.ViewChild,
|
|
316
|
+
args: ["input", { isSignal: true }]
|
|
317
|
+
}],
|
|
318
|
+
hint: [{
|
|
319
|
+
type: i0.ContentChild,
|
|
320
|
+
args: [i0.forwardRef(() => CkSwitchHint), { isSignal: true }]
|
|
321
|
+
}]
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
const CK_SWITCH_IMPORTS = [CkSwitch, CkSwitchHint];
|
|
325
|
+
export { CK_SWITCH_IMPORTS, CkSwitch, CkSwitchHint };
|
|
326
|
+
|
|
327
|
+
//# sourceMappingURL=ckui-core-switch.mjs.map
|