@ckui/core 0.1.0-next.0 → 0.1.0-next.1

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.
@@ -0,0 +1,907 @@
1
+ import { isPlatformBrowser } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { ChangeDetectionStrategy, Component, DestroyRef, Directive, ElementRef, Injectable, InjectionToken, Injector, PLATFORM_ID, Renderer2, TemplateRef, ViewContainerRef, ViewEncapsulation, afterNextRender, afterRenderEffect, booleanAttribute, computed, contentChild, effect, inject, input, model, output, signal, untracked } from "@angular/core";
4
+ import { InteractivityChecker } from "@angular/cdk/a11y";
5
+ import { CkIcon, CkOverlayHost, createCkId } from "@ckui/core/internal";
6
+ import { CdkPortalOutlet, ComponentPortal, TemplatePortal } from "@angular/cdk/portal";
7
+ import { CK_LABELS } from "@ckui/core";
8
+ import { CkButton } from "@ckui/core/button";
9
+ const CK_DIALOG_DATA = new InjectionToken("CK_DIALOG_DATA");
10
+ var CkDialogIds = class {
11
+ entries = signal([], ...ngDevMode ? [{ debugName: "entries" }] : /* istanbul ignore next */ []);
12
+ current = computed(() => this.entries().at(-1)?.() ?? null, ...ngDevMode ? [{ debugName: "current" }] : /* istanbul ignore next */ []);
13
+ add(id) {
14
+ this.entries.update((entries) => [...entries, id]);
15
+ return () => this.entries.update((entries) => entries.filter((entry) => entry !== id));
16
+ }
17
+ };
18
+ var CkDialogContext = class {
19
+ titles = new CkDialogIds();
20
+ descriptions = new CkDialogIds();
21
+ titleId = this.titles.current;
22
+ descriptionId = this.descriptions.current;
23
+ mode = signal("modal", ...ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []);
24
+ };
25
+ const CK_DIALOG_CONTEXT = new InjectionToken("CK_DIALOG_CONTEXT");
26
+ var CkDialogRef = class {
27
+ closed;
28
+ closing;
29
+ controls;
30
+ constructor(controls) {
31
+ this.controls = controls;
32
+ this.closed = controls.closed;
33
+ this.closing = controls.closing;
34
+ }
35
+ close(result) {
36
+ this.controls.close(result);
37
+ }
38
+ };
39
+ const CK_DIALOG_SETUP = new InjectionToken("CK_DIALOG_SETUP");
40
+ var CkDialogContainer = class CkDialogContainer {
41
+ context = inject(CK_DIALOG_CONTEXT);
42
+ setup = inject(CK_DIALOG_SETUP);
43
+ labels = inject(CK_LABELS);
44
+ ref = inject(CkDialogRef);
45
+ portal;
46
+ constructor() {
47
+ const injector = inject(Injector);
48
+ this.portal = this.setup.content instanceof TemplateRef ? new TemplatePortal(this.setup.content, inject(ViewContainerRef), void 0, injector) : new ComponentPortal(this.setup.content, null, injector);
49
+ }
50
+ onAttached(attached) {
51
+ if (attached && "location" in attached) attached.location.nativeElement.classList.add("ck-dialog__component");
52
+ }
53
+ static ɵfac = i0.ɵɵngDeclareFactory({
54
+ minVersion: "12.0.0",
55
+ version: "22.2.4",
56
+ ngImport: i0,
57
+ type: CkDialogContainer,
58
+ deps: [],
59
+ target: i0.ɵɵFactoryTarget.Component
60
+ });
61
+ static ɵcmp = i0.ɵɵngDeclareComponent({
62
+ minVersion: "17.0.0",
63
+ version: "22.2.4",
64
+ type: CkDialogContainer,
65
+ isStandalone: true,
66
+ selector: "ck-dialog-container",
67
+ host: {
68
+ properties: {
69
+ "class.ck-dialog--sheet": "context.mode() === \"sheet\"",
70
+ "class.ck-dialog--grab": "context.mode() === \"sheet\" && setup.dismissible",
71
+ "class.ck-dialog--has-close": "setup.closeButton",
72
+ "class.ck-dialog--no-title": "context.titleId() === null"
73
+ },
74
+ classAttribute: "ck-dialog"
75
+ },
76
+ ngImport: i0,
77
+ template: `
78
+ <div class="ck-dialog__content">
79
+ <ng-template [cdkPortalOutlet]="portal" (attached)="onAttached($event)" />
80
+ </div>
81
+ @if (setup.closeButton) {
82
+ <button
83
+ ckButton
84
+ type="button"
85
+ variant="ghost"
86
+ size="md"
87
+ iconOnly
88
+ class="ck-dialog__close"
89
+ [attr.aria-label]="labels().close"
90
+ (click)="ref.close()"
91
+ >
92
+ <ck-icon name="close" />
93
+ </button>
94
+ }
95
+ `,
96
+ isInline: true,
97
+ styles: ["@layer ckui{.ck-dialog-panel{box-sizing:border-box;inline-size:min(var(--ck-dialog-max-width, var(--_ck-dialog-width, 32rem)),100%);border-radius:var(--ck-dialog-radius, var(--ck-radius-xl));background:var(--ck-dialog-bg, var(--ck-color-surface-raised));color:var(--ck-color-fg);color-scheme:var(--ck-color-scheme);box-shadow:var(--ck-dialog-shadow, var(--ck-shadow-lg));font-family:var(--ck-font-sans);font-size:var(--ck-font-size-md);line-height:var(--ck-line-height-normal);outline:none}.ck-dialog-panel:focus-visible{outline:var(--ck-focus-ring);outline-offset:calc(-1 * var(--ck-focus-ring-width, 2px))}.ck-dialog-panel--sm{--_ck-dialog-width: 24rem}.ck-dialog-panel--md{--_ck-dialog-width: 32rem}.ck-dialog-panel--lg{--_ck-dialog-width: 48rem}.ck-dialog-panel.ck-overlay--sheet{border-end-start-radius:0;border-end-end-radius:0}.ck-dialog-panel .ck-overlay-grab{border-start-start-radius:var(--ck-dialog-radius, var(--ck-radius-xl));border-start-end-radius:var(--ck-dialog-radius, var(--ck-radius-xl));background:var(--ck-dialog-bg, var(--ck-color-surface-raised))}.ck-dialog{--_ck-dialog-padding: var(--ck-dialog-padding, var(--ck-space-6));--_ck-dialog-padding-top: var(--_ck-dialog-padding);position:relative;display:flex;flex-direction:column;box-sizing:border-box;min-block-size:0;padding:var(--_ck-dialog-padding);padding-block-start:var(--_ck-dialog-padding-top)}.ck-dialog--sheet{--_ck-dialog-padding: var(--ck-dialog-padding, var(--ck-space-4));padding-block-end:calc(var(--_ck-dialog-padding) + env(safe-area-inset-bottom,0px))}.ck-dialog--grab{--_ck-dialog-padding-top: 0px}.ck-dialog__content,.ck-dialog__component{display:flex;flex:1 1 auto;flex-direction:column;gap:var(--ck-space-4);min-block-size:0;min-inline-size:0}.ck-dialog--has-close.ck-dialog--no-title .ck-dialog__content{padding-block-start:var(--ck-control-height-md)}.ck-dialog>.ck-dialog__close{position:absolute;inset-block-start:var(--_ck-dialog-padding-top);inset-inline-end:var(--_ck-dialog-padding)}.ck-dialog__title{margin:0;font-size:var(--ck-font-size-xl);font-weight:var(--ck-font-weight-semibold);line-height:var(--ck-line-height-tight);overflow-wrap:break-word}.ck-dialog--has-close .ck-dialog__title{display:block;align-content:center;min-block-size:var(--ck-control-height-md);padding-inline-end:calc(var(--ck-control-height-md) + var(--ck-space-2))}.ck-dialog__description{margin:0;color:var(--ck-color-fg-muted);overflow-wrap:break-word}.ck-dialog-body{display:block;flex:1 1 auto;min-block-size:0;overflow-y:auto;overscroll-behavior:contain;margin:calc(-1 * var(--ck-space-2));padding:var(--ck-space-2)}.ck-dialog-body__inner{display:flow-root;overflow-wrap:break-word}.ck-dialog-body:focus-visible{outline:var(--ck-focus-ring);outline-offset:calc(-1 * var(--ck-focus-ring-width, 2px))}.ck-dialog-actions{display:flex;flex:none;flex-wrap:wrap;justify-content:flex-end;margin-block-start:auto;gap:var(--ck-space-2)}.ck-dialog--sheet .ck-dialog-actions{flex-direction:column;flex-wrap:nowrap;align-items:stretch}}\n"],
98
+ dependencies: [
99
+ {
100
+ kind: "directive",
101
+ type: CdkPortalOutlet,
102
+ selector: "[cdkPortalOutlet]",
103
+ inputs: ["cdkPortalOutlet"],
104
+ outputs: ["attached"],
105
+ exportAs: ["cdkPortalOutlet"]
106
+ },
107
+ {
108
+ kind: "component",
109
+ type: CkButton,
110
+ selector: "button[ckButton], a[ckButton]",
111
+ inputs: [
112
+ "variant",
113
+ "size",
114
+ "iconOnly",
115
+ "loading",
116
+ "disabled"
117
+ ]
118
+ },
119
+ {
120
+ kind: "component",
121
+ type: CkIcon,
122
+ selector: "ck-icon",
123
+ inputs: ["name"]
124
+ }
125
+ ],
126
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
127
+ encapsulation: i0.ViewEncapsulation.None
128
+ });
129
+ };
130
+ i0.ɵɵngDeclareClassMetadata({
131
+ minVersion: "12.0.0",
132
+ version: "22.2.4",
133
+ ngImport: i0,
134
+ type: CkDialogContainer,
135
+ decorators: [{
136
+ type: Component,
137
+ args: [{
138
+ selector: "ck-dialog-container",
139
+ imports: [
140
+ CdkPortalOutlet,
141
+ CkButton,
142
+ CkIcon
143
+ ],
144
+ changeDetection: ChangeDetectionStrategy.OnPush,
145
+ encapsulation: ViewEncapsulation.None,
146
+ host: {
147
+ class: "ck-dialog",
148
+ "[class.ck-dialog--sheet]": "context.mode() === \"sheet\"",
149
+ "[class.ck-dialog--grab]": "context.mode() === \"sheet\" && setup.dismissible",
150
+ "[class.ck-dialog--has-close]": "setup.closeButton",
151
+ "[class.ck-dialog--no-title]": "context.titleId() === null"
152
+ },
153
+ template: `
154
+ <div class="ck-dialog__content">
155
+ <ng-template [cdkPortalOutlet]="portal" (attached)="onAttached($event)" />
156
+ </div>
157
+ @if (setup.closeButton) {
158
+ <button
159
+ ckButton
160
+ type="button"
161
+ variant="ghost"
162
+ size="md"
163
+ iconOnly
164
+ class="ck-dialog__close"
165
+ [attr.aria-label]="labels().close"
166
+ (click)="ref.close()"
167
+ >
168
+ <ck-icon name="close" />
169
+ </button>
170
+ }
171
+ `,
172
+ styles: ["@layer ckui{.ck-dialog-panel{box-sizing:border-box;inline-size:min(var(--ck-dialog-max-width, var(--_ck-dialog-width, 32rem)),100%);border-radius:var(--ck-dialog-radius, var(--ck-radius-xl));background:var(--ck-dialog-bg, var(--ck-color-surface-raised));color:var(--ck-color-fg);color-scheme:var(--ck-color-scheme);box-shadow:var(--ck-dialog-shadow, var(--ck-shadow-lg));font-family:var(--ck-font-sans);font-size:var(--ck-font-size-md);line-height:var(--ck-line-height-normal);outline:none}.ck-dialog-panel:focus-visible{outline:var(--ck-focus-ring);outline-offset:calc(-1 * var(--ck-focus-ring-width, 2px))}.ck-dialog-panel--sm{--_ck-dialog-width: 24rem}.ck-dialog-panel--md{--_ck-dialog-width: 32rem}.ck-dialog-panel--lg{--_ck-dialog-width: 48rem}.ck-dialog-panel.ck-overlay--sheet{border-end-start-radius:0;border-end-end-radius:0}.ck-dialog-panel .ck-overlay-grab{border-start-start-radius:var(--ck-dialog-radius, var(--ck-radius-xl));border-start-end-radius:var(--ck-dialog-radius, var(--ck-radius-xl));background:var(--ck-dialog-bg, var(--ck-color-surface-raised))}.ck-dialog{--_ck-dialog-padding: var(--ck-dialog-padding, var(--ck-space-6));--_ck-dialog-padding-top: var(--_ck-dialog-padding);position:relative;display:flex;flex-direction:column;box-sizing:border-box;min-block-size:0;padding:var(--_ck-dialog-padding);padding-block-start:var(--_ck-dialog-padding-top)}.ck-dialog--sheet{--_ck-dialog-padding: var(--ck-dialog-padding, var(--ck-space-4));padding-block-end:calc(var(--_ck-dialog-padding) + env(safe-area-inset-bottom,0px))}.ck-dialog--grab{--_ck-dialog-padding-top: 0px}.ck-dialog__content,.ck-dialog__component{display:flex;flex:1 1 auto;flex-direction:column;gap:var(--ck-space-4);min-block-size:0;min-inline-size:0}.ck-dialog--has-close.ck-dialog--no-title .ck-dialog__content{padding-block-start:var(--ck-control-height-md)}.ck-dialog>.ck-dialog__close{position:absolute;inset-block-start:var(--_ck-dialog-padding-top);inset-inline-end:var(--_ck-dialog-padding)}.ck-dialog__title{margin:0;font-size:var(--ck-font-size-xl);font-weight:var(--ck-font-weight-semibold);line-height:var(--ck-line-height-tight);overflow-wrap:break-word}.ck-dialog--has-close .ck-dialog__title{display:block;align-content:center;min-block-size:var(--ck-control-height-md);padding-inline-end:calc(var(--ck-control-height-md) + var(--ck-space-2))}.ck-dialog__description{margin:0;color:var(--ck-color-fg-muted);overflow-wrap:break-word}.ck-dialog-body{display:block;flex:1 1 auto;min-block-size:0;overflow-y:auto;overscroll-behavior:contain;margin:calc(-1 * var(--ck-space-2));padding:var(--ck-space-2)}.ck-dialog-body__inner{display:flow-root;overflow-wrap:break-word}.ck-dialog-body:focus-visible{outline:var(--ck-focus-ring);outline-offset:calc(-1 * var(--ck-focus-ring-width, 2px))}.ck-dialog-actions{display:flex;flex:none;flex-wrap:wrap;justify-content:flex-end;margin-block-start:auto;gap:var(--ck-space-2)}.ck-dialog--sheet .ck-dialog-actions{flex-direction:column;flex-wrap:nowrap;align-items:stretch}}\n"]
173
+ }]
174
+ }],
175
+ ctorParameters: () => []
176
+ });
177
+ const TABBABLE_CANDIDATES = "a[href], button, input, select, textarea, summary, [tabindex], [contenteditable], audio[controls], video[controls]";
178
+ var CkDialog = class CkDialog {
179
+ overlay = inject(CkOverlayHost);
180
+ checker = inject(InteractivityChecker);
181
+ injector = inject(Injector);
182
+ active = /* @__PURE__ */ new Set();
183
+ constructor() {
184
+ inject(DestroyRef).onDestroy(() => {
185
+ for (const dialog of [...this.active]) dialog.destroy();
186
+ this.active.clear();
187
+ });
188
+ }
189
+ open(content, config = {}) {
190
+ const dismissible = config.dismissible ?? true;
191
+ const closeButton = config.closeButton ?? true;
192
+ const context = new CkDialogContext();
193
+ let resolveClosed = () => void 0;
194
+ const closed = new Promise((resolve) => resolveClosed = resolve);
195
+ let resolveClosing = () => void 0;
196
+ const closing = new Promise((resolve) => resolveClosing = resolve);
197
+ let handle = null;
198
+ let requested = false;
199
+ let result;
200
+ let settled = false;
201
+ let labelling = null;
202
+ const dialog = {
203
+ close: () => ref.close(),
204
+ destroy: () => settle()
205
+ };
206
+ const settle = () => {
207
+ if (settled) return;
208
+ settled = true;
209
+ resolveClosing();
210
+ labelling?.destroy();
211
+ this.active.delete(dialog);
212
+ resolveClosed(result);
213
+ };
214
+ const ref = new CkDialogRef({
215
+ closed,
216
+ closing,
217
+ close: (value) => {
218
+ if (requested) return;
219
+ requested = true;
220
+ result = value;
221
+ resolveClosing();
222
+ handle?.close();
223
+ }
224
+ });
225
+ this.active.add(dialog);
226
+ const dialogInjector = Injector.create({
227
+ parent: config.injector ?? this.injector,
228
+ providers: [
229
+ {
230
+ provide: CK_DIALOG_CONTEXT,
231
+ useValue: context
232
+ },
233
+ {
234
+ provide: CkDialogRef,
235
+ useValue: ref
236
+ },
237
+ {
238
+ provide: CK_DIALOG_DATA,
239
+ useValue: config.data
240
+ },
241
+ {
242
+ provide: CK_DIALOG_SETUP,
243
+ useValue: {
244
+ content,
245
+ closeButton,
246
+ dismissible
247
+ }
248
+ }
249
+ ]
250
+ });
251
+ try {
252
+ handle = this.overlay.open(CkDialogContainer, {
253
+ mode: config.mode ?? "auto",
254
+ dismissible,
255
+ fullHeight: config.fullHeight ?? false,
256
+ role: config.role ?? "dialog",
257
+ ariaLabel: config.ariaLabel,
258
+ panelClass: ["ck-dialog-panel", `ck-dialog-panel--${config.width ?? "md"}`],
259
+ onDismissRequest: () => ref.close(),
260
+ initialFocus: () => handle ? this.initialFocus(handle.panel) : null
261
+ }, dialogInjector);
262
+ } catch (error) {
263
+ settle();
264
+ throw error;
265
+ }
266
+ const opened = handle;
267
+ context.mode.set(opened.mode);
268
+ labelling = effect(() => {
269
+ this.setAttribute(opened.panel, "aria-labelledby", context.titleId());
270
+ this.setAttribute(opened.panel, "aria-describedby", context.descriptionId());
271
+ }, { injector: this.injector });
272
+ opened.closed.then(settle);
273
+ if (requested) opened.close();
274
+ if (typeof ngDevMode !== "undefined" && ngDevMode) opened.opened.then(() => {
275
+ if (!settled && context.titleId() === null && !config.ariaLabel) console.warn("CkDialog: the dialog has no accessible name. Add [ckDialogTitle] to a heading in its content or set `ariaLabel` in the config.");
276
+ });
277
+ return ref;
278
+ }
279
+ closeAll() {
280
+ for (const dialog of [...this.active]) dialog.close();
281
+ }
282
+ setAttribute(element, name, value) {
283
+ if (value === null) element.removeAttribute(name);
284
+ else element.setAttribute(name, value);
285
+ }
286
+ initialFocus(panel) {
287
+ const marked = Array.from(panel.querySelectorAll("[data-ck-dialog-initial-focus]")).find((candidate) => this.checker.isFocusable(candidate));
288
+ if (marked) return marked;
289
+ const content = panel.querySelector(".ck-dialog__content");
290
+ return Array.from(content?.querySelectorAll(TABBABLE_CANDIDATES) ?? []).find((candidate) => !candidate.classList.contains("ck-dialog-body") && this.checker.isTabbable(candidate)) ?? panel;
291
+ }
292
+ static ɵfac = i0.ɵɵngDeclareFactory({
293
+ minVersion: "12.0.0",
294
+ version: "22.2.4",
295
+ ngImport: i0,
296
+ type: CkDialog,
297
+ deps: [],
298
+ target: i0.ɵɵFactoryTarget.Injectable
299
+ });
300
+ static ɵprov = i0.ɵɵngDeclareInjectable({
301
+ minVersion: "12.0.0",
302
+ version: "22.2.4",
303
+ ngImport: i0,
304
+ type: CkDialog,
305
+ providedIn: "root"
306
+ });
307
+ };
308
+ i0.ɵɵngDeclareClassMetadata({
309
+ minVersion: "12.0.0",
310
+ version: "22.2.4",
311
+ ngImport: i0,
312
+ type: CkDialog,
313
+ decorators: [{
314
+ type: Injectable,
315
+ args: [{ providedIn: "root" }]
316
+ }],
317
+ ctorParameters: () => []
318
+ });
319
+ var CkDialogComponent = class CkDialogComponent {
320
+ open = model(false, ...ngDevMode ? [{ debugName: "open" }] : /* istanbul ignore next */ []);
321
+ role = input("dialog", ...ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []);
322
+ width = input("md", ...ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []);
323
+ dismissible = input(true, {
324
+ ...ngDevMode ? { debugName: "dismissible" } : /* istanbul ignore next */ {},
325
+ transform: booleanAttribute
326
+ });
327
+ closeButton = input(true, {
328
+ ...ngDevMode ? { debugName: "closeButton" } : /* istanbul ignore next */ {},
329
+ transform: booleanAttribute
330
+ });
331
+ mode = input("auto", ...ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []);
332
+ fullHeight = input(false, {
333
+ ...ngDevMode ? { debugName: "fullHeight" } : /* istanbul ignore next */ {},
334
+ transform: booleanAttribute
335
+ });
336
+ ariaLabel = input(void 0, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
337
+ closed = output();
338
+ template = contentChild(TemplateRef, ...ngDevMode ? [{ debugName: "template" }] : /* istanbul ignore next */ []);
339
+ dialog = inject(CkDialog);
340
+ isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
341
+ ref = null;
342
+ destroyed = false;
343
+ constructor() {
344
+ inject(DestroyRef).onDestroy(() => {
345
+ this.destroyed = true;
346
+ this.ref?.close();
347
+ this.ref = null;
348
+ });
349
+ afterRenderEffect(() => {
350
+ const wanted = this.open();
351
+ if (!this.isBrowser) return;
352
+ untracked(() => this.sync(wanted));
353
+ });
354
+ }
355
+ sync(wanted) {
356
+ if (wanted && !this.ref) this.show();
357
+ else if (!wanted && this.ref) {
358
+ const ref = this.ref;
359
+ this.ref = null;
360
+ ref.close();
361
+ }
362
+ }
363
+ show() {
364
+ const template = this.template();
365
+ if (!template) {
366
+ if (typeof ngDevMode !== "undefined" && ngDevMode) console.warn("ck-dialog: put the content in an <ng-template> inside the element.");
367
+ this.open.set(false);
368
+ return;
369
+ }
370
+ const ref = this.dialog.open(template, {
371
+ role: this.role(),
372
+ width: this.width(),
373
+ dismissible: this.dismissible(),
374
+ closeButton: this.closeButton(),
375
+ mode: this.mode(),
376
+ fullHeight: this.fullHeight(),
377
+ ariaLabel: this.ariaLabel()
378
+ });
379
+ this.ref = ref;
380
+ ref.closing.then(() => {
381
+ if (!this.destroyed && this.ref === ref) {
382
+ this.ref = null;
383
+ this.open.set(false);
384
+ }
385
+ });
386
+ ref.closed.then((result) => {
387
+ if (!this.destroyed) this.closed.emit(result);
388
+ });
389
+ }
390
+ static ɵfac = i0.ɵɵngDeclareFactory({
391
+ minVersion: "12.0.0",
392
+ version: "22.2.4",
393
+ ngImport: i0,
394
+ type: CkDialogComponent,
395
+ deps: [],
396
+ target: i0.ɵɵFactoryTarget.Component
397
+ });
398
+ static ɵcmp = i0.ɵɵngDeclareComponent({
399
+ minVersion: "17.2.0",
400
+ version: "22.2.4",
401
+ type: CkDialogComponent,
402
+ isStandalone: true,
403
+ selector: "ck-dialog",
404
+ inputs: {
405
+ open: {
406
+ classPropertyName: "open",
407
+ publicName: "open",
408
+ isSignal: true,
409
+ isRequired: false,
410
+ transformFunction: null
411
+ },
412
+ role: {
413
+ classPropertyName: "role",
414
+ publicName: "role",
415
+ isSignal: true,
416
+ isRequired: false,
417
+ transformFunction: null
418
+ },
419
+ width: {
420
+ classPropertyName: "width",
421
+ publicName: "width",
422
+ isSignal: true,
423
+ isRequired: false,
424
+ transformFunction: null
425
+ },
426
+ dismissible: {
427
+ classPropertyName: "dismissible",
428
+ publicName: "dismissible",
429
+ isSignal: true,
430
+ isRequired: false,
431
+ transformFunction: null
432
+ },
433
+ closeButton: {
434
+ classPropertyName: "closeButton",
435
+ publicName: "closeButton",
436
+ isSignal: true,
437
+ isRequired: false,
438
+ transformFunction: null
439
+ },
440
+ mode: {
441
+ classPropertyName: "mode",
442
+ publicName: "mode",
443
+ isSignal: true,
444
+ isRequired: false,
445
+ transformFunction: null
446
+ },
447
+ fullHeight: {
448
+ classPropertyName: "fullHeight",
449
+ publicName: "fullHeight",
450
+ isSignal: true,
451
+ isRequired: false,
452
+ transformFunction: null
453
+ },
454
+ ariaLabel: {
455
+ classPropertyName: "ariaLabel",
456
+ publicName: "ariaLabel",
457
+ isSignal: true,
458
+ isRequired: false,
459
+ transformFunction: null
460
+ }
461
+ },
462
+ outputs: {
463
+ open: "openChange",
464
+ closed: "closed"
465
+ },
466
+ host: { styleAttribute: "display: none" },
467
+ queries: [{
468
+ propertyName: "template",
469
+ first: true,
470
+ predicate: TemplateRef,
471
+ descendants: true,
472
+ isSignal: true
473
+ }],
474
+ ngImport: i0,
475
+ template: ``,
476
+ isInline: true,
477
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
478
+ encapsulation: i0.ViewEncapsulation.None
479
+ });
480
+ };
481
+ i0.ɵɵngDeclareClassMetadata({
482
+ minVersion: "12.0.0",
483
+ version: "22.2.4",
484
+ ngImport: i0,
485
+ type: CkDialogComponent,
486
+ decorators: [{
487
+ type: Component,
488
+ args: [{
489
+ selector: "ck-dialog",
490
+ changeDetection: ChangeDetectionStrategy.OnPush,
491
+ encapsulation: ViewEncapsulation.None,
492
+ host: { style: "display: none" },
493
+ template: ``
494
+ }]
495
+ }],
496
+ ctorParameters: () => [],
497
+ propDecorators: {
498
+ open: [{
499
+ type: i0.Input,
500
+ args: [{
501
+ isSignal: true,
502
+ alias: "open",
503
+ required: false
504
+ }]
505
+ }, {
506
+ type: i0.Output,
507
+ args: ["openChange"]
508
+ }],
509
+ role: [{
510
+ type: i0.Input,
511
+ args: [{
512
+ isSignal: true,
513
+ alias: "role",
514
+ required: false
515
+ }]
516
+ }],
517
+ width: [{
518
+ type: i0.Input,
519
+ args: [{
520
+ isSignal: true,
521
+ alias: "width",
522
+ required: false
523
+ }]
524
+ }],
525
+ dismissible: [{
526
+ type: i0.Input,
527
+ args: [{
528
+ isSignal: true,
529
+ alias: "dismissible",
530
+ required: false
531
+ }]
532
+ }],
533
+ closeButton: [{
534
+ type: i0.Input,
535
+ args: [{
536
+ isSignal: true,
537
+ alias: "closeButton",
538
+ required: false
539
+ }]
540
+ }],
541
+ mode: [{
542
+ type: i0.Input,
543
+ args: [{
544
+ isSignal: true,
545
+ alias: "mode",
546
+ required: false
547
+ }]
548
+ }],
549
+ fullHeight: [{
550
+ type: i0.Input,
551
+ args: [{
552
+ isSignal: true,
553
+ alias: "fullHeight",
554
+ required: false
555
+ }]
556
+ }],
557
+ ariaLabel: [{
558
+ type: i0.Input,
559
+ args: [{
560
+ isSignal: true,
561
+ alias: "ariaLabel",
562
+ required: false
563
+ }]
564
+ }],
565
+ closed: [{
566
+ type: i0.Output,
567
+ args: ["closed"]
568
+ }],
569
+ template: [{
570
+ type: i0.ContentChild,
571
+ args: [i0.forwardRef(() => TemplateRef), { isSignal: true }]
572
+ }]
573
+ }
574
+ });
575
+ var CkDialogTitle = class CkDialogTitle {
576
+ id = input(createCkId("ck-dialog-title"), ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
577
+ constructor() {
578
+ const context = inject(CK_DIALOG_CONTEXT, { optional: true });
579
+ if (context) {
580
+ const remove = untracked(() => context.titles.add(this.id));
581
+ inject(DestroyRef).onDestroy(() => untracked(remove));
582
+ }
583
+ }
584
+ static ɵfac = i0.ɵɵngDeclareFactory({
585
+ minVersion: "12.0.0",
586
+ version: "22.2.4",
587
+ ngImport: i0,
588
+ type: CkDialogTitle,
589
+ deps: [],
590
+ target: i0.ɵɵFactoryTarget.Directive
591
+ });
592
+ static ɵdir = i0.ɵɵngDeclareDirective({
593
+ minVersion: "17.1.0",
594
+ version: "22.2.4",
595
+ type: CkDialogTitle,
596
+ isStandalone: true,
597
+ selector: "[ckDialogTitle]",
598
+ inputs: { id: {
599
+ classPropertyName: "id",
600
+ publicName: "id",
601
+ isSignal: true,
602
+ isRequired: false,
603
+ transformFunction: null
604
+ } },
605
+ host: {
606
+ properties: { "attr.id": "id()" },
607
+ classAttribute: "ck-dialog__title"
608
+ },
609
+ ngImport: i0
610
+ });
611
+ };
612
+ i0.ɵɵngDeclareClassMetadata({
613
+ minVersion: "12.0.0",
614
+ version: "22.2.4",
615
+ ngImport: i0,
616
+ type: CkDialogTitle,
617
+ decorators: [{
618
+ type: Directive,
619
+ args: [{
620
+ selector: "[ckDialogTitle]",
621
+ host: {
622
+ class: "ck-dialog__title",
623
+ "[attr.id]": "id()"
624
+ }
625
+ }]
626
+ }],
627
+ ctorParameters: () => [],
628
+ propDecorators: { id: [{
629
+ type: i0.Input,
630
+ args: [{
631
+ isSignal: true,
632
+ alias: "id",
633
+ required: false
634
+ }]
635
+ }] }
636
+ });
637
+ var CkDialogDescription = class CkDialogDescription {
638
+ id = input(createCkId("ck-dialog-description"), ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
639
+ constructor() {
640
+ const context = inject(CK_DIALOG_CONTEXT, { optional: true });
641
+ if (context) {
642
+ const remove = untracked(() => context.descriptions.add(this.id));
643
+ inject(DestroyRef).onDestroy(() => untracked(remove));
644
+ }
645
+ }
646
+ static ɵfac = i0.ɵɵngDeclareFactory({
647
+ minVersion: "12.0.0",
648
+ version: "22.2.4",
649
+ ngImport: i0,
650
+ type: CkDialogDescription,
651
+ deps: [],
652
+ target: i0.ɵɵFactoryTarget.Directive
653
+ });
654
+ static ɵdir = i0.ɵɵngDeclareDirective({
655
+ minVersion: "17.1.0",
656
+ version: "22.2.4",
657
+ type: CkDialogDescription,
658
+ isStandalone: true,
659
+ selector: "[ckDialogDescription]",
660
+ inputs: { id: {
661
+ classPropertyName: "id",
662
+ publicName: "id",
663
+ isSignal: true,
664
+ isRequired: false,
665
+ transformFunction: null
666
+ } },
667
+ host: {
668
+ properties: { "attr.id": "id()" },
669
+ classAttribute: "ck-dialog__description"
670
+ },
671
+ ngImport: i0
672
+ });
673
+ };
674
+ i0.ɵɵngDeclareClassMetadata({
675
+ minVersion: "12.0.0",
676
+ version: "22.2.4",
677
+ ngImport: i0,
678
+ type: CkDialogDescription,
679
+ decorators: [{
680
+ type: Directive,
681
+ args: [{
682
+ selector: "[ckDialogDescription]",
683
+ host: {
684
+ class: "ck-dialog__description",
685
+ "[attr.id]": "id()"
686
+ }
687
+ }]
688
+ }],
689
+ ctorParameters: () => [],
690
+ propDecorators: { id: [{
691
+ type: i0.Input,
692
+ args: [{
693
+ isSignal: true,
694
+ alias: "id",
695
+ required: false
696
+ }]
697
+ }] }
698
+ });
699
+ var CkDialogBody = class CkDialogBody {
700
+ constructor() {
701
+ const element = inject(ElementRef).nativeElement;
702
+ const renderer = inject(Renderer2);
703
+ const destroyRef = inject(DestroyRef);
704
+ let ownTabindex = false;
705
+ const update = () => {
706
+ const scrolls = element.scrollHeight > element.clientHeight + 1;
707
+ if (scrolls && !element.hasAttribute("tabindex")) {
708
+ renderer.setAttribute(element, "tabindex", "0");
709
+ ownTabindex = true;
710
+ } else if (!scrolls && ownTabindex) {
711
+ renderer.removeAttribute(element, "tabindex");
712
+ ownTabindex = false;
713
+ }
714
+ };
715
+ if (isPlatformBrowser(inject(PLATFORM_ID))) afterNextRender(() => {
716
+ const Observer = element.ownerDocument.defaultView?.ResizeObserver;
717
+ if (!Observer || destroyRef.destroyed) return;
718
+ const observer = new Observer(update);
719
+ observer.observe(element);
720
+ observer.observe(element.firstElementChild);
721
+ destroyRef.onDestroy(() => observer.disconnect());
722
+ update();
723
+ });
724
+ }
725
+ static ɵfac = i0.ɵɵngDeclareFactory({
726
+ minVersion: "12.0.0",
727
+ version: "22.2.4",
728
+ ngImport: i0,
729
+ type: CkDialogBody,
730
+ deps: [],
731
+ target: i0.ɵɵFactoryTarget.Component
732
+ });
733
+ static ɵcmp = i0.ɵɵngDeclareComponent({
734
+ minVersion: "14.0.0",
735
+ version: "22.2.4",
736
+ type: CkDialogBody,
737
+ isStandalone: true,
738
+ selector: "ck-dialog-body",
739
+ host: { classAttribute: "ck-dialog-body" },
740
+ ngImport: i0,
741
+ template: `<div class="ck-dialog-body__inner"><ng-content /></div>`,
742
+ isInline: true,
743
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
744
+ encapsulation: i0.ViewEncapsulation.None
745
+ });
746
+ };
747
+ i0.ɵɵngDeclareClassMetadata({
748
+ minVersion: "12.0.0",
749
+ version: "22.2.4",
750
+ ngImport: i0,
751
+ type: CkDialogBody,
752
+ decorators: [{
753
+ type: Component,
754
+ args: [{
755
+ selector: "ck-dialog-body",
756
+ changeDetection: ChangeDetectionStrategy.OnPush,
757
+ encapsulation: ViewEncapsulation.None,
758
+ host: { class: "ck-dialog-body" },
759
+ template: `<div class="ck-dialog-body__inner"><ng-content /></div>`
760
+ }]
761
+ }],
762
+ ctorParameters: () => []
763
+ });
764
+ var CkDialogActions = class CkDialogActions {
765
+ static ɵfac = i0.ɵɵngDeclareFactory({
766
+ minVersion: "12.0.0",
767
+ version: "22.2.4",
768
+ ngImport: i0,
769
+ type: CkDialogActions,
770
+ deps: [],
771
+ target: i0.ɵɵFactoryTarget.Component
772
+ });
773
+ static ɵcmp = i0.ɵɵngDeclareComponent({
774
+ minVersion: "14.0.0",
775
+ version: "22.2.4",
776
+ type: CkDialogActions,
777
+ isStandalone: true,
778
+ selector: "ck-dialog-actions",
779
+ host: { classAttribute: "ck-dialog-actions" },
780
+ ngImport: i0,
781
+ template: `<ng-content />`,
782
+ isInline: true,
783
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
784
+ encapsulation: i0.ViewEncapsulation.None
785
+ });
786
+ };
787
+ i0.ɵɵngDeclareClassMetadata({
788
+ minVersion: "12.0.0",
789
+ version: "22.2.4",
790
+ ngImport: i0,
791
+ type: CkDialogActions,
792
+ decorators: [{
793
+ type: Component,
794
+ args: [{
795
+ selector: "ck-dialog-actions",
796
+ changeDetection: ChangeDetectionStrategy.OnPush,
797
+ encapsulation: ViewEncapsulation.None,
798
+ host: { class: "ck-dialog-actions" },
799
+ template: `<ng-content />`
800
+ }]
801
+ }]
802
+ });
803
+ var CkDialogClose = class CkDialogClose {
804
+ result = input(void 0, {
805
+ ...ngDevMode ? { debugName: "result" } : /* istanbul ignore next */ {},
806
+ alias: "ckDialogClose"
807
+ });
808
+ ref = inject(CkDialogRef, { optional: true });
809
+ constructor() {
810
+ const element = inject(ElementRef).nativeElement;
811
+ if (element.tagName === "BUTTON" && !element.hasAttribute("type")) inject(Renderer2).setAttribute(element, "type", "button");
812
+ }
813
+ close() {
814
+ const result = this.result();
815
+ this.ref?.close(result === "" ? void 0 : result);
816
+ }
817
+ static ɵfac = i0.ɵɵngDeclareFactory({
818
+ minVersion: "12.0.0",
819
+ version: "22.2.4",
820
+ ngImport: i0,
821
+ type: CkDialogClose,
822
+ deps: [],
823
+ target: i0.ɵɵFactoryTarget.Directive
824
+ });
825
+ static ɵdir = i0.ɵɵngDeclareDirective({
826
+ minVersion: "17.1.0",
827
+ version: "22.2.4",
828
+ type: CkDialogClose,
829
+ isStandalone: true,
830
+ selector: "[ckDialogClose]",
831
+ inputs: { result: {
832
+ classPropertyName: "result",
833
+ publicName: "ckDialogClose",
834
+ isSignal: true,
835
+ isRequired: false,
836
+ transformFunction: null
837
+ } },
838
+ host: { listeners: { "click": "close()" } },
839
+ ngImport: i0
840
+ });
841
+ };
842
+ i0.ɵɵngDeclareClassMetadata({
843
+ minVersion: "12.0.0",
844
+ version: "22.2.4",
845
+ ngImport: i0,
846
+ type: CkDialogClose,
847
+ decorators: [{
848
+ type: Directive,
849
+ args: [{
850
+ selector: "[ckDialogClose]",
851
+ host: { "(click)": "close()" }
852
+ }]
853
+ }],
854
+ ctorParameters: () => [],
855
+ propDecorators: { result: [{
856
+ type: i0.Input,
857
+ args: [{
858
+ isSignal: true,
859
+ alias: "ckDialogClose",
860
+ required: false
861
+ }]
862
+ }] }
863
+ });
864
+ var CkDialogInitialFocus = class CkDialogInitialFocus {
865
+ static ɵfac = i0.ɵɵngDeclareFactory({
866
+ minVersion: "12.0.0",
867
+ version: "22.2.4",
868
+ ngImport: i0,
869
+ type: CkDialogInitialFocus,
870
+ deps: [],
871
+ target: i0.ɵɵFactoryTarget.Directive
872
+ });
873
+ static ɵdir = i0.ɵɵngDeclareDirective({
874
+ minVersion: "14.0.0",
875
+ version: "22.2.4",
876
+ type: CkDialogInitialFocus,
877
+ isStandalone: true,
878
+ selector: "[ckDialogInitialFocus]",
879
+ host: { attributes: { "data-ck-dialog-initial-focus": "" } },
880
+ ngImport: i0
881
+ });
882
+ };
883
+ i0.ɵɵngDeclareClassMetadata({
884
+ minVersion: "12.0.0",
885
+ version: "22.2.4",
886
+ ngImport: i0,
887
+ type: CkDialogInitialFocus,
888
+ decorators: [{
889
+ type: Directive,
890
+ args: [{
891
+ selector: "[ckDialogInitialFocus]",
892
+ host: { "data-ck-dialog-initial-focus": "" }
893
+ }]
894
+ }]
895
+ });
896
+ const CK_DIALOG_IMPORTS = [
897
+ CkDialogComponent,
898
+ CkDialogTitle,
899
+ CkDialogDescription,
900
+ CkDialogBody,
901
+ CkDialogActions,
902
+ CkDialogClose,
903
+ CkDialogInitialFocus
904
+ ];
905
+ export { CK_DIALOG_DATA, CK_DIALOG_IMPORTS, CkDialog, CkDialogActions, CkDialogBody, CkDialogClose, CkDialogComponent, CkDialogDescription, CkDialogInitialFocus, CkDialogRef, CkDialogTitle };
906
+
907
+ //# sourceMappingURL=ckui-core-dialog.mjs.map