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

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