@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
@@ -1,10 +1,12 @@
1
1
  import { BreakpointObserver } from "@angular/cdk/layout";
2
2
  import * as i0 from "@angular/core";
3
- import { ChangeDetectionStrategy, Component, Injectable, Injector, ViewEncapsulation, afterNextRender, computed, inject, input } from "@angular/core";
3
+ import { ChangeDetectionStrategy, Component, Directive, Injectable, Injector, PLATFORM_ID, ViewEncapsulation, afterNextRender, booleanAttribute, computed, forwardRef, inject, input, model, signal } from "@angular/core";
4
4
  import { toSignal } from "@angular/core/rxjs-interop";
5
5
  import { CK_CONFIG } from "@ckui/core";
6
6
  import { FocusTrapFactory, LiveAnnouncer } from "@angular/cdk/a11y";
7
- import { DOCUMENT } from "@angular/common";
7
+ import { _CdkPrivateStyleLoader, _VisuallyHiddenLoader } from "@angular/cdk/private";
8
+ import { DOCUMENT, isPlatformBrowser } from "@angular/common";
9
+ import { NG_VALUE_ACCESSOR } from "@angular/forms";
8
10
  let counter = 0;
9
11
  function createCkId(prefix) {
10
12
  if (typeof prefix !== "string" || prefix.trim() === "") throw new TypeError("createCkId needs a non-empty prefix string.");
@@ -51,15 +53,68 @@ i0.ɵɵngDeclareClassMetadata({
51
53
  args: [{ providedIn: "root" }]
52
54
  }]
53
55
  });
56
+ function join(messages) {
57
+ return messages.reduce((text, message) => {
58
+ const trimmed = message.trim();
59
+ if (text === "") return trimmed;
60
+ return /[.!?:;,]$/.test(text) ? `${text} ${trimmed}` : `${text}. ${trimmed}`;
61
+ }, "");
62
+ }
63
+ const READ_OUT_WINDOW = 150;
54
64
  var CkAnnouncer = class CkAnnouncer {
55
65
  liveAnnouncer = inject(LiveAnnouncer);
66
+ pending = [];
67
+ waiters = [];
68
+ scheduled = false;
69
+ view = inject(DOCUMENT).defaultView;
70
+ last = null;
71
+ constructor() {
72
+ if (isPlatformBrowser(inject(PLATFORM_ID))) inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
73
+ }
56
74
  announce(message, politeness = "polite") {
57
75
  if (typeof message !== "string" || message.trim() === "") return Promise.resolve();
58
- return this.liveAnnouncer.announce(message, politeness);
76
+ this.pending.push({
77
+ message,
78
+ politeness
79
+ });
80
+ const done = new Promise((resolve) => this.waiters.push(resolve));
81
+ if (!this.scheduled) {
82
+ this.scheduled = true;
83
+ queueMicrotask(() => this.flush());
84
+ }
85
+ return done;
59
86
  }
60
87
  clear() {
88
+ this.pending = [];
89
+ this.last = null;
90
+ this.release();
61
91
  this.liveAnnouncer.clear();
62
92
  }
93
+ flush() {
94
+ this.scheduled = false;
95
+ const items = this.pending;
96
+ if (items.length === 0) return;
97
+ this.pending = [];
98
+ const waiters = this.waiters;
99
+ this.waiters = [];
100
+ const now = this.view?.performance.now() ?? Date.now();
101
+ const previous = this.last && now - this.last.at < READ_OUT_WINDOW ? this.last : null;
102
+ const fresh = join(items.map((item) => item.message));
103
+ const all = previous && previous.message !== fresh ? [previous, ...items] : items;
104
+ const politeness = all.some((item) => item.politeness === "assertive") ? "assertive" : "polite";
105
+ const message = all === items ? fresh : join(all.map((item) => item.message));
106
+ this.last = {
107
+ message,
108
+ politeness,
109
+ at: now
110
+ };
111
+ this.liveAnnouncer.announce(message, politeness).then(() => waiters.forEach((resolve) => resolve()));
112
+ }
113
+ release() {
114
+ const waiters = this.waiters;
115
+ this.waiters = [];
116
+ waiters.forEach((resolve) => resolve());
117
+ }
63
118
  static ɵfac = i0.ɵɵngDeclareFactory({
64
119
  minVersion: "12.0.0",
65
120
  version: "22.2.4",
@@ -84,7 +139,8 @@ i0.ɵɵngDeclareClassMetadata({
84
139
  decorators: [{
85
140
  type: Injectable,
86
141
  args: [{ providedIn: "root" }]
87
- }]
142
+ }],
143
+ ctorParameters: () => []
88
144
  });
89
145
  var CkFocusTrapFactory = class CkFocusTrapFactory {
90
146
  focusTrapFactory = inject(FocusTrapFactory);
@@ -96,11 +152,19 @@ var CkFocusTrapFactory = class CkFocusTrapFactory {
96
152
  let previous = null;
97
153
  let released = false;
98
154
  return {
99
- activate: () => {
155
+ activate: (initialFocus) => {
100
156
  if (released) return Promise.resolve(false);
101
157
  previous ??= document.activeElement instanceof HTMLElement ? document.activeElement : null;
102
158
  return new Promise((resolve) => {
103
- afterNextRender(() => resolve(released ? false : trap.focusInitialElement()), { injector });
159
+ afterNextRender(() => {
160
+ if (released) return resolve(false);
161
+ const target = initialFocus?.() ?? null;
162
+ if (target) {
163
+ target.focus();
164
+ if (document.activeElement === target) return resolve(true);
165
+ }
166
+ resolve(trap.focusInitialElement());
167
+ }, { injector });
104
168
  });
105
169
  },
106
170
  release: () => {
@@ -140,11 +204,15 @@ i0.ɵɵngDeclareClassMetadata({
140
204
  }]
141
205
  });
142
206
  const ICON_PATHS = {
207
+ "alert-octagon": "M5.2 2h5.6L14 5.2v5.6L10.8 14H5.2L2 10.8V5.2L5.2 2zM8 5.5v3M8 11v.01",
208
+ "alert-triangle": "M8 2.5l6 10.5H2L8 2.5zM8 6.5v3M8 11.5v.01",
143
209
  check: "M3 8.5l3.5 3.5L13 4.5",
144
210
  "chevron-down": "M4 6l4 4 4-4",
145
211
  "chevron-end": "M6 4l4 4-4 4",
146
212
  close: "M4 4l8 8M12 4l-8 8",
147
- minus: "M3.5 8h9"
213
+ info: "M8 14A6 6 0 108 2a6 6 0 000 12zM8 7.5v3.5M8 5v.01",
214
+ minus: "M3.5 8h9",
215
+ plus: "M8 3.5v9M3.5 8h9"
148
216
  };
149
217
  var CkIcon = class CkIcon {
150
218
  name = input.required(...ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []);
@@ -236,6 +304,201 @@ i0.ɵɵngDeclareClassMetadata({
236
304
  }]
237
305
  }] }
238
306
  });
239
- export { CkAnnouncer, CkFocusTrapFactory, CkIcon, CkMedia, createCkId };
307
+ const SKIPPED = "script, style, link, template, noscript, [data-ck-inert-exempt], .cdk-live-announcer-element";
308
+ var CkInert = class CkInert {
309
+ document = inject(DOCUMENT);
310
+ holds = /* @__PURE__ */ new Map();
311
+ hold(elements) {
312
+ const held = new Set(elements);
313
+ for (const element of held) {
314
+ const entry = this.holds.get(element);
315
+ if (entry) {
316
+ entry.count++;
317
+ continue;
318
+ }
319
+ const original = element.getAttribute("inert");
320
+ this.holds.set(element, {
321
+ count: 1,
322
+ original
323
+ });
324
+ if (original === null) element.setAttribute("inert", "");
325
+ }
326
+ let released = false;
327
+ return () => {
328
+ if (released) return;
329
+ released = true;
330
+ for (const element of held) {
331
+ const entry = this.holds.get(element);
332
+ if (!entry || --entry.count > 0) continue;
333
+ this.holds.delete(element);
334
+ if (entry.original === null) element.removeAttribute("inert");
335
+ }
336
+ };
337
+ }
338
+ backgroundElements(keep) {
339
+ return Array.from(this.document.body.children).filter((element) => element !== keep && !element.matches(SKIPPED));
340
+ }
341
+ static ɵfac = i0.ɵɵngDeclareFactory({
342
+ minVersion: "12.0.0",
343
+ version: "22.2.4",
344
+ ngImport: i0,
345
+ type: CkInert,
346
+ deps: [],
347
+ target: i0.ɵɵFactoryTarget.Injectable
348
+ });
349
+ static ɵprov = i0.ɵɵngDeclareInjectable({
350
+ minVersion: "12.0.0",
351
+ version: "22.2.4",
352
+ ngImport: i0,
353
+ type: CkInert,
354
+ providedIn: "root"
355
+ });
356
+ };
357
+ i0.ɵɵngDeclareClassMetadata({
358
+ minVersion: "12.0.0",
359
+ version: "22.2.4",
360
+ ngImport: i0,
361
+ type: CkInert,
362
+ decorators: [{
363
+ type: Injectable,
364
+ args: [{ providedIn: "root" }]
365
+ }]
366
+ });
367
+ const noop = () => void 0;
368
+ var CkValueControl = class CkValueControl {
369
+ value = model(void 0, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
370
+ disabled = input(false, {
371
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
372
+ transform: booleanAttribute
373
+ });
374
+ touched = model(false, ...ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []);
375
+ controlDisabled = signal(false, ...ngDevMode ? [{ debugName: "controlDisabled" }] : /* istanbul ignore next */ []);
376
+ onChange = noop;
377
+ onTouched = noop;
378
+ isDisabled = computed(() => this.disabled() || this.controlDisabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
379
+ writeValue(value) {
380
+ this.value.set(value);
381
+ }
382
+ registerOnChange(onChange) {
383
+ this.onChange = onChange;
384
+ }
385
+ registerOnTouched(onTouched) {
386
+ this.onTouched = onTouched;
387
+ }
388
+ setDisabledState(isDisabled) {
389
+ this.controlDisabled.set(isDisabled);
390
+ }
391
+ commit(value) {
392
+ if (this.isDisabled() || Object.is(value, this.value())) return;
393
+ this.value.set(value);
394
+ this.onChange(value);
395
+ }
396
+ markTouched() {
397
+ this.touched.set(true);
398
+ this.onTouched();
399
+ }
400
+ static ɵfac = i0.ɵɵngDeclareFactory({
401
+ minVersion: "12.0.0",
402
+ version: "22.2.4",
403
+ ngImport: i0,
404
+ type: CkValueControl,
405
+ deps: [],
406
+ target: i0.ɵɵFactoryTarget.Directive
407
+ });
408
+ static ɵdir = i0.ɵɵngDeclareDirective({
409
+ minVersion: "17.1.0",
410
+ version: "22.2.4",
411
+ type: CkValueControl,
412
+ isStandalone: true,
413
+ inputs: {
414
+ value: {
415
+ classPropertyName: "value",
416
+ publicName: "value",
417
+ isSignal: true,
418
+ isRequired: false,
419
+ transformFunction: null
420
+ },
421
+ disabled: {
422
+ classPropertyName: "disabled",
423
+ publicName: "disabled",
424
+ isSignal: true,
425
+ isRequired: false,
426
+ transformFunction: null
427
+ },
428
+ touched: {
429
+ classPropertyName: "touched",
430
+ publicName: "touched",
431
+ isSignal: true,
432
+ isRequired: false,
433
+ transformFunction: null
434
+ }
435
+ },
436
+ outputs: {
437
+ value: "valueChange",
438
+ touched: "touchedChange"
439
+ },
440
+ ngImport: i0
441
+ });
442
+ };
443
+ i0.ɵɵngDeclareClassMetadata({
444
+ minVersion: "12.0.0",
445
+ version: "22.2.4",
446
+ ngImport: i0,
447
+ type: CkValueControl,
448
+ decorators: [{ type: Directive }],
449
+ propDecorators: {
450
+ value: [{
451
+ type: i0.Input,
452
+ args: [{
453
+ isSignal: true,
454
+ alias: "value",
455
+ required: false
456
+ }]
457
+ }, {
458
+ type: i0.Output,
459
+ args: ["valueChange"]
460
+ }],
461
+ disabled: [{
462
+ type: i0.Input,
463
+ args: [{
464
+ isSignal: true,
465
+ alias: "disabled",
466
+ required: false
467
+ }]
468
+ }],
469
+ touched: [{
470
+ type: i0.Input,
471
+ args: [{
472
+ isSignal: true,
473
+ alias: "touched",
474
+ required: false
475
+ }]
476
+ }, {
477
+ type: i0.Output,
478
+ args: ["touchedChange"]
479
+ }]
480
+ }
481
+ });
482
+ function provideCkValueAccessor(type) {
483
+ return {
484
+ provide: NG_VALUE_ACCESSOR,
485
+ useExisting: forwardRef(() => type),
486
+ multi: true
487
+ };
488
+ }
489
+ function hasAccessibleName(element, sources) {
490
+ const attribute = (name) => (element.getAttribute(name) ?? "").trim() !== "";
491
+ if (attribute("aria-label") || sources.title && attribute("title")) return true;
492
+ if (sources.text && visibleText(element) !== "") return true;
493
+ const named = (node) => (node?.textContent ?? "").trim() !== "";
494
+ const labels = element.labels;
495
+ return (element.getAttribute("aria-labelledby") ?? "").split(/\s+/).some((id) => id !== "" && named(element.ownerDocument.getElementById(id))) || sources.labels === true && Array.from(labels ?? []).some(named);
496
+ }
497
+ function visibleText(node) {
498
+ if (node.nodeType === Node.TEXT_NODE) return (node.textContent ?? "").trim();
499
+ if (node instanceof Element && (node.getAttribute("aria-hidden") === "true" || node.hasAttribute("hidden"))) return "";
500
+ return Array.from(node.childNodes, visibleText).join("");
501
+ }
502
+ export { CkAnnouncer, CkFocusTrapFactory, CkIcon, CkInert, CkMedia, CkValueControl, createCkId, hasAccessibleName, provideCkValueAccessor };
240
503
 
241
504
  //# sourceMappingURL=ckui-core-internal.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ckui-core-internal.mjs","names":[],"sources":["../../../../projects/core/internal/id.ts","../../../../projects/core/internal/media.ts","../../../../projects/core/internal/announcer.ts","../../../../projects/core/internal/focus-trap.ts","../../../../projects/core/internal/icon.ts"],"sourcesContent":["let counter = 0;\n\n/** Returns an id that is unique within the running page, e.g. `ck-field-3`. */\nexport function createCkId(prefix: string): string {\n if (typeof prefix !== 'string' || prefix.trim() === '') {\n throw new TypeError('createCkId needs a non-empty prefix string.');\n }\n counter += 1;\n return `${prefix}-${counter}`;\n}\n","import { BreakpointObserver } from '@angular/cdk/layout';\nimport { Injectable, Signal, computed, inject } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { CK_CONFIG } from '@ckui/core';\n\n/** Viewport and user-preference signals. All `false` on the server, where nothing can match. */\n@Injectable({ providedIn: 'root' })\nexport class CkMedia {\n private readonly breakpointObserver = inject(BreakpointObserver);\n private readonly config = inject(CK_CONFIG);\n\n /** `(pointer: coarse)` */\n readonly coarsePointer: Signal<boolean> = this.watch('(pointer: coarse)');\n /** Viewport narrower than `CK_CONFIG.sheetBreakpoint`. */\n readonly narrow: Signal<boolean> = this.watch(\n `(max-width: ${this.config.sheetBreakpoint - 0.02}px)`,\n );\n /** `(prefers-reduced-motion: reduce)` */\n readonly reducedMotion: Signal<boolean> = this.watch('(prefers-reduced-motion: reduce)');\n /** Coarse pointer and a narrow viewport: overlays render as sheets. */\n readonly sheet: Signal<boolean> = computed(() => this.coarsePointer() && this.narrow());\n\n private watch(query: string): Signal<boolean> {\n const state = toSignal(this.breakpointObserver.observe(query), {\n initialValue: { matches: this.breakpointObserver.isMatched(query), breakpoints: {} },\n });\n return computed(() => state().matches);\n }\n}\n","import { LiveAnnouncer } from '@angular/cdk/a11y';\nimport { Injectable, inject } from '@angular/core';\n\n/** Screen-reader announcements through one shared live region. */\n@Injectable({ providedIn: 'root' })\nexport class CkAnnouncer {\n private readonly liveAnnouncer = inject(LiveAnnouncer);\n\n /** Resolves once the message is in the live region. A blank message does nothing. */\n announce(message: string, politeness: 'polite' | 'assertive' = 'polite'): Promise<void> {\n if (typeof message !== 'string' || message.trim() === '') {\n return Promise.resolve();\n }\n return this.liveAnnouncer.announce(message, politeness);\n }\n\n clear(): void {\n this.liveAnnouncer.clear();\n }\n}\n","import { FocusTrap, FocusTrapFactory } from '@angular/cdk/a11y';\nimport { DOCUMENT } from '@angular/common';\nimport { Injectable, Injector, afterNextRender, inject } from '@angular/core';\n\nexport interface CkFocusTrap {\n /** Remembers the focused element, then focuses the first tabbable one inside. Resolves `false` if nothing could be focused. */\n activate(): Promise<boolean>;\n /** Destroys the trap and gives focus back if the remembered element is still connected. Safe to call repeatedly. */\n release(): void;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class CkFocusTrapFactory {\n private readonly focusTrapFactory = inject(FocusTrapFactory);\n private readonly document = inject(DOCUMENT);\n private readonly injector = inject(Injector);\n\n create(element: HTMLElement): CkFocusTrap {\n const trap: FocusTrap = this.focusTrapFactory.create(element);\n const { document, injector } = this;\n let previous: HTMLElement | null = null;\n let released = false;\n\n return {\n activate: () => {\n if (released) {\n return Promise.resolve(false);\n }\n previous ??= document.activeElement instanceof HTMLElement ? document.activeElement : null;\n // The CDK's own deferred variant would still focus after a release in between.\n return new Promise<boolean>((resolve) => {\n afterNextRender(() => resolve(released ? false : trap.focusInitialElement()), {\n injector,\n });\n });\n },\n release: () => {\n if (released) {\n return;\n }\n released = true;\n trap.destroy();\n const target = previous;\n previous = null;\n if (target?.isConnected) {\n target.focus();\n }\n },\n };\n }\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n ViewEncapsulation,\n computed,\n input,\n} from '@angular/core';\n\nexport type CkIconName = 'check' | 'chevron-down' | 'chevron-end' | 'close' | 'minus';\n\nconst ICON_PATHS: Readonly<Record<CkIconName, string>> = {\n check: 'M3 8.5l3.5 3.5L13 4.5',\n 'chevron-down': 'M4 6l4 4 4-4',\n 'chevron-end': 'M6 4l4 4-4 4',\n close: 'M4 4l8 8M12 4l-8 8',\n minus: 'M3.5 8h9',\n};\n\n/** Decorative icon at the surrounding font size and colour. The control carries its own accessible name. */\n@Component({\n selector: 'ck-icon',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'ck-icon',\n 'aria-hidden': 'true',\n '[class.ck-icon--mirror]': 'name() === \"chevron-end\"',\n },\n template: `\n <svg\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n focusable=\"false\"\n >\n <path [attr.d]=\"path()\" />\n </svg>\n `,\n styles: `\n @layer ckui {\n .ck-icon {\n display: inline-block;\n flex: none;\n inline-size: var(--ck-icon-size, 1em);\n block-size: var(--ck-icon-size, 1em);\n color: currentColor;\n vertical-align: -0.125em;\n }\n\n .ck-icon > svg {\n display: block;\n inline-size: 100%;\n block-size: 100%;\n }\n\n .ck-icon--mirror:dir(rtl) {\n transform: scaleX(-1);\n }\n }\n `,\n})\nexport class CkIcon {\n readonly name = input.required<CkIconName>();\n protected readonly path = computed(() => ICON_PATHS[this.name()] ?? '');\n}\n"],"mappings":";;;;;;;AAAA,IAAI,UAAU;AAGd,SAAgB,WAAW,QAAc;CACvC,IAAI,OAAO,WAAW,YAAY,OAAO,KAAI,MAAO,IAClD,MAAM,IAAI,UAAU,6CAA6C;CAEnE,WAAW;CACX,OAAO,GAAG,OAAM,GAAI;AACtB;ACFA,IAAa,UAAb,MAAa,QAAO;CACD,qBAAqB,OAAO,kBAAkB;CAC9C,SAAS,OAAO,SAAS;CAGjC,gBAAiC,KAAK,MAAM,mBAAmB;CAE/D,SAA0B,KAAK,MACtC,eAAe,KAAK,OAAO,kBAAkB,IAAI,IAAK;CAG/C,gBAAiC,KAAK,MAAM,kCAAkC;CAE9E,QAAyB,eAAe,KAAK,cAAa,KAAM,KAAK,OAAM,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAA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AAe,WAAW,KAAK,KAAI,MAAO,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAF5D,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAM,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAN,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAM,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,MAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,MAAA;GAAA,YAAA,EAAA,eAAA,OAAA;GAAA,YAAA,EAAA,yBAAA,6BAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UApCP;;;;;;;;;;;;;EAYT,UAAA;EAAA,QAAA,CAAA,uRAAA;EAAA,iBAAA,GAAA,wBAAA;EAAA,eAAA,GAAA,kBAAA;CAAA,CAAA;;AAwBU,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAM,YAAA,CAAA;EA7ClB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAS,iBACF,wBAAwB;GAAM,eAChC,kBAAkB;GAAI,MAC/B;IACJ,OAAO;IACP,eAAe;IACf,2BAA2B;GAC5B;GAAA,UACS;;;;;;;;;;;;;GAYT,QAAA,CAAA,uRAAA;EAAA,CAAA"}
1
+ {"version":3,"file":"ckui-core-internal.mjs","names":[],"sources":["../../../../projects/core/internal/id.ts","../../../../projects/core/internal/media.ts","../../../../projects/core/internal/announcer.ts","../../../../projects/core/internal/focus-trap.ts","../../../../projects/core/internal/icon.ts","../../../../projects/core/internal/inert.ts","../../../../projects/core/internal/value-control.ts","../../../../projects/core/internal/accessible-name.ts"],"sourcesContent":["let counter = 0;\n\n/** Returns an id that is unique within the running page, e.g. `ck-field-3`. */\nexport function createCkId(prefix: string): string {\n if (typeof prefix !== 'string' || prefix.trim() === '') {\n throw new TypeError('createCkId needs a non-empty prefix string.');\n }\n counter += 1;\n return `${prefix}-${counter}`;\n}\n","import { BreakpointObserver } from '@angular/cdk/layout';\nimport { Injectable, Signal, computed, inject } from '@angular/core';\nimport { toSignal } from '@angular/core/rxjs-interop';\nimport { CK_CONFIG } from '@ckui/core';\n\n/** Viewport and user-preference signals. All `false` on the server, where nothing can match. */\n@Injectable({ providedIn: 'root' })\nexport class CkMedia {\n private readonly breakpointObserver = inject(BreakpointObserver);\n private readonly config = inject(CK_CONFIG);\n\n /** `(pointer: coarse)` */\n readonly coarsePointer: Signal<boolean> = this.watch('(pointer: coarse)');\n /** Viewport narrower than `CK_CONFIG.sheetBreakpoint`. */\n readonly narrow: Signal<boolean> = this.watch(\n `(max-width: ${this.config.sheetBreakpoint - 0.02}px)`,\n );\n /** `(prefers-reduced-motion: reduce)` */\n readonly reducedMotion: Signal<boolean> = this.watch('(prefers-reduced-motion: reduce)');\n /** Coarse pointer and a narrow viewport: overlays render as sheets. */\n readonly sheet: Signal<boolean> = computed(() => this.coarsePointer() && this.narrow());\n\n private watch(query: string): Signal<boolean> {\n const state = toSignal(this.breakpointObserver.observe(query), {\n initialValue: { matches: this.breakpointObserver.isMatched(query), breakpoints: {} },\n });\n return computed(() => state().matches);\n }\n}\n","import { LiveAnnouncer } from '@angular/cdk/a11y';\nimport { _CdkPrivateStyleLoader, _VisuallyHiddenLoader } from '@angular/cdk/private';\nimport { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { Injectable, PLATFORM_ID, inject } from '@angular/core';\n\ntype Politeness = 'polite' | 'assertive';\n\ninterface Pending {\n readonly message: string;\n readonly politeness: Politeness;\n}\n\n/** Joins messages in order, with \". \" unless the earlier one already ends in punctuation. */\nfunction join(messages: readonly string[]): string {\n return messages.reduce((text, message) => {\n const trimmed = message.trim();\n if (text === '') {\n return trimmed;\n }\n return /[.!?:;,]$/.test(text) ? `${text} ${trimmed}` : `${text}. ${trimmed}`;\n }, '');\n}\n\n/** A message handed to the live region this recently (ms) may not have been read out yet. */\nconst READ_OUT_WINDOW = 150;\n\n/**\n * Screen-reader announcements through one shared live region. The CDK live region keeps only the\n * last message, so announcements made in the same tick are collected and spoken as one message, in\n * order (joined with \". \"); it is assertive if any of them is. A batch that follows within 150 ms\n * of the previous hand-over (the previous one may not be read out yet, and the CDK would replace\n * it) is spoken together with the previous text, again in order and assertive if either is; after\n * a longer pause only the new text is written. The region is hidden visually by the CDK styles,\n * which this service loads itself.\n */\n@Injectable({ providedIn: 'root' })\nexport class CkAnnouncer {\n private readonly liveAnnouncer = inject(LiveAnnouncer);\n private pending: Pending[] = [];\n private waiters: (() => void)[] = [];\n private scheduled = false;\n private readonly view = inject(DOCUMENT).defaultView;\n private last: (Pending & { at: number }) | null = null;\n\n constructor() {\n if (isPlatformBrowser(inject(PLATFORM_ID))) {\n inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);\n }\n }\n\n /**\n * Resolves once the message is in the live region. A blank message does nothing. Messages from\n * the same tick share one live-region update and one promise result.\n */\n announce(message: string, politeness: Politeness = 'polite'): Promise<void> {\n if (typeof message !== 'string' || message.trim() === '') {\n return Promise.resolve();\n }\n this.pending.push({ message, politeness });\n const done = new Promise<void>((resolve) => this.waiters.push(resolve));\n if (!this.scheduled) {\n this.scheduled = true;\n queueMicrotask(() => this.flush());\n }\n return done;\n }\n\n /** Empties the live region and drops announcements that have not been written yet. */\n clear(): void {\n this.pending = [];\n this.last = null;\n this.release();\n this.liveAnnouncer.clear();\n }\n\n private flush(): void {\n this.scheduled = false;\n const items = this.pending;\n if (items.length === 0) {\n return;\n }\n this.pending = [];\n const waiters = this.waiters;\n this.waiters = [];\n const now = this.view?.performance.now() ?? Date.now();\n const previous = this.last && now - this.last.at < READ_OUT_WINDOW ? this.last : null;\n const fresh = join(items.map((item) => item.message));\n // The same words again are repeated on their own, not stacked onto themselves.\n const all = previous && previous.message !== fresh ? [previous, ...items] : items;\n const politeness = all.some((item) => item.politeness === 'assertive') ? 'assertive' : 'polite';\n const message = all === items ? fresh : join(all.map((item) => item.message));\n this.last = { message, politeness, at: now };\n void this.liveAnnouncer\n .announce(message, politeness)\n .then(() => waiters.forEach((resolve) => resolve()));\n }\n\n private release(): void {\n const waiters = this.waiters;\n this.waiters = [];\n waiters.forEach((resolve) => resolve());\n }\n}\n","import { FocusTrap, FocusTrapFactory } from '@angular/cdk/a11y';\nimport { DOCUMENT } from '@angular/common';\nimport { Injectable, Injector, afterNextRender, inject } from '@angular/core';\n\nexport interface CkFocusTrap {\n /**\n * Remembers the focused element, then focuses `initialFocus()` if it returns an element that takes\n * focus, else the first tabbable one inside. Resolves `false` if nothing could be focused.\n */\n activate(initialFocus?: () => HTMLElement | null): Promise<boolean>;\n /** Destroys the trap and gives focus back if the remembered element is still connected. Safe to call repeatedly. */\n release(): void;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class CkFocusTrapFactory {\n private readonly focusTrapFactory = inject(FocusTrapFactory);\n private readonly document = inject(DOCUMENT);\n private readonly injector = inject(Injector);\n\n create(element: HTMLElement): CkFocusTrap {\n const trap: FocusTrap = this.focusTrapFactory.create(element);\n const { document, injector } = this;\n let previous: HTMLElement | null = null;\n let released = false;\n\n return {\n activate: (initialFocus) => {\n if (released) {\n return Promise.resolve(false);\n }\n previous ??= document.activeElement instanceof HTMLElement ? document.activeElement : null;\n // The CDK's own deferred variant would still focus after a release in between.\n return new Promise<boolean>((resolve) => {\n afterNextRender(\n () => {\n if (released) {\n return resolve(false);\n }\n const target = initialFocus?.() ?? null;\n if (target) {\n target.focus();\n if (document.activeElement === target) {\n return resolve(true);\n }\n }\n resolve(trap.focusInitialElement());\n },\n { injector },\n );\n });\n },\n release: () => {\n if (released) {\n return;\n }\n released = true;\n trap.destroy();\n const target = previous;\n previous = null;\n if (target?.isConnected) {\n target.focus();\n }\n },\n };\n }\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n ViewEncapsulation,\n computed,\n input,\n} from '@angular/core';\n\nexport type CkIconName =\n | 'alert-octagon'\n | 'alert-triangle'\n | 'check'\n | 'chevron-down'\n | 'chevron-end'\n | 'close'\n | 'info'\n | 'minus'\n | 'plus';\n\nconst ICON_PATHS: Readonly<Record<CkIconName, string>> = {\n 'alert-octagon': 'M5.2 2h5.6L14 5.2v5.6L10.8 14H5.2L2 10.8V5.2L5.2 2zM8 5.5v3M8 11v.01',\n 'alert-triangle': 'M8 2.5l6 10.5H2L8 2.5zM8 6.5v3M8 11.5v.01',\n check: 'M3 8.5l3.5 3.5L13 4.5',\n 'chevron-down': 'M4 6l4 4 4-4',\n 'chevron-end': 'M6 4l4 4-4 4',\n close: 'M4 4l8 8M12 4l-8 8',\n info: 'M8 14A6 6 0 108 2a6 6 0 000 12zM8 7.5v3.5M8 5v.01',\n minus: 'M3.5 8h9',\n plus: 'M8 3.5v9M3.5 8h9',\n};\n\n/** Decorative icon at the surrounding font size and colour. The control carries its own accessible name. */\n@Component({\n selector: 'ck-icon',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'ck-icon',\n 'aria-hidden': 'true',\n '[class.ck-icon--mirror]': 'name() === \"chevron-end\"',\n },\n template: `\n <svg\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n focusable=\"false\"\n >\n <path [attr.d]=\"path()\" />\n </svg>\n `,\n styles: `\n @layer ckui {\n .ck-icon {\n display: inline-block;\n flex: none;\n inline-size: var(--ck-icon-size, 1em);\n block-size: var(--ck-icon-size, 1em);\n color: currentColor;\n vertical-align: -0.125em;\n }\n\n .ck-icon > svg {\n display: block;\n inline-size: 100%;\n block-size: 100%;\n }\n\n .ck-icon--mirror:dir(rtl) {\n transform: scaleX(-1);\n }\n }\n `,\n})\nexport class CkIcon {\n readonly name = input.required<CkIconName>();\n protected readonly path = computed(() => ICON_PATHS[this.name()] ?? '');\n}\n","import { DOCUMENT } from '@angular/common';\nimport { Injectable, inject } from '@angular/core';\n\n/** Never made inert: they render nothing, or must keep announcing while an overlay is open. */\nconst SKIPPED =\n 'script, style, link, template, noscript, [data-ck-inert-exempt], .cdk-live-announcer-element';\n\ninterface Hold {\n count: number;\n /** The `inert` attribute value the element had before the first hold; `null` if it had none. */\n original: string | null;\n}\n\n/** Reference-counted `inert`: an element stays inert until every hold on it is released. */\n@Injectable({ providedIn: 'root' })\nexport class CkInert {\n private readonly document = inject(DOCUMENT);\n private readonly holds = new Map<Element, Hold>();\n\n /**\n * Makes the elements inert and returns the release function (safe to call more than once).\n * An element that was already inert keeps its own attribute value when the last hold ends.\n */\n hold(elements: Iterable<Element>): () => void {\n const held = new Set(elements);\n for (const element of held) {\n const entry = this.holds.get(element);\n if (entry) {\n entry.count++;\n continue;\n }\n const original = element.getAttribute('inert');\n this.holds.set(element, { count: 1, original });\n if (original === null) {\n element.setAttribute('inert', '');\n }\n }\n let released = false;\n return () => {\n if (released) {\n return;\n }\n released = true;\n for (const element of held) {\n const entry = this.holds.get(element);\n if (!entry || --entry.count > 0) {\n continue;\n }\n this.holds.delete(element);\n if (entry.original === null) {\n element.removeAttribute('inert');\n }\n }\n };\n }\n\n /** Body children that an overlay hides from the user: all but `keep`, exempt elements and non-rendered tags. */\n backgroundElements(keep: Element): Element[] {\n return Array.from(this.document.body.children).filter(\n (element) => element !== keep && !element.matches(SKIPPED),\n );\n }\n}\n","import {\n Directive,\n ModelSignal,\n Provider,\n Type,\n booleanAttribute,\n computed,\n forwardRef,\n input,\n model,\n signal,\n} from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport type { FormValueControl } from '@angular/forms/signals';\n\nconst noop = (): void => undefined;\n\n/**\n * Base for components that edit one value.\n *\n * Reactive Forms, `ngModel` and Signal Forms all talk to the component through the\n * `ControlValueAccessor` registered by `provideCkValueAccessor`: Angular's `[formField]` prefers a\n * value accessor on the same node over the `value` model contract, so only that one path is ever\n * active. The `value` model and `disabled` input are for standalone use (`[(value)]`) and for the\n * template.\n *\n * `value` is `undefined` until something sets it; a subclass with a `null` default reads\n * `value() ?? null`.\n */\n@Directive()\nexport abstract class CkValueControl<T> implements ControlValueAccessor, FormValueControl<T> {\n readonly value: ModelSignal<T> = model(undefined as T);\n readonly disabled = input(false, { transform: booleanAttribute });\n /**\n * Only ever becomes `true` here: `markAsUntouched()` and `reset()` do not travel through a value\n * accessor. Do not style from it; read the form's own state (`ng-touched`, the field's `touched()`).\n */\n readonly touched = model(false);\n\n private readonly controlDisabled = signal(false);\n private onChange: (value: T) => void = noop;\n private onTouched: () => void = noop;\n\n /** The `disabled` input or the forms API (`control.disable()`, a disabled field) says so. */\n protected readonly isDisabled = computed(() => this.disabled() || this.controlDisabled());\n\n writeValue(value: T): void {\n this.value.set(value);\n }\n\n registerOnChange(onChange: (value: T) => void): void {\n this.onChange = onChange;\n }\n\n registerOnTouched(onTouched: () => void): void {\n this.onTouched = onTouched;\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.controlDisabled.set(isDisabled);\n }\n\n /** A change made by the user. Ignored while disabled or when the value is the current one. */\n protected commit(value: T): void {\n if (this.isDisabled() || Object.is(value, this.value())) {\n return;\n }\n this.value.set(value);\n this.onChange(value);\n }\n\n /** Call when focus leaves the whole control, not a part of it. */\n protected markTouched(): void {\n this.touched.set(true);\n this.onTouched();\n }\n}\n\n/** Registers the component as a value accessor: `providers: [provideCkValueAccessor(CkSegmented)]`. */\nexport function provideCkValueAccessor(type: Type<unknown>): Provider {\n return { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => type), multi: true };\n}\n","export interface CkNameSources {\n /** Count `title` as a name. */\n readonly title: boolean;\n /** Count the element's own visible text (not `aria-hidden` or `hidden` parts). */\n readonly text: boolean;\n /** Count the text of the `<label>` elements of a form control. */\n readonly labels?: boolean;\n}\n\n/** Whether the element has an accessible name: a label attribute, a label reference or readable text. */\nexport function hasAccessibleName(element: Element, sources: CkNameSources): boolean {\n const attribute = (name: string): boolean => (element.getAttribute(name) ?? '').trim() !== '';\n if (attribute('aria-label') || (sources.title && attribute('title'))) {\n return true;\n }\n if (sources.text && visibleText(element) !== '') {\n return true;\n }\n const named = (node: Element | null): boolean => (node?.textContent ?? '').trim() !== '';\n const labels = (element as Partial<HTMLInputElement>).labels;\n return (\n (element.getAttribute('aria-labelledby') ?? '')\n .split(/\\s+/)\n .some((id) => id !== '' && named(element.ownerDocument.getElementById(id))) ||\n (sources.labels === true && Array.from(labels ?? []).some(named))\n );\n}\n\n/** Text that is neither in an `aria-hidden` nor in a `hidden` subtree. */\nfunction visibleText(node: Node): string {\n if (node.nodeType === Node.TEXT_NODE) {\n return (node.textContent ?? '').trim();\n }\n if (\n node instanceof Element &&\n (node.getAttribute('aria-hidden') === 'true' || node.hasAttribute('hidden'))\n ) {\n return '';\n }\n return Array.from(node.childNodes, visibleText).join('');\n}\n"],"mappings":";;;;;;;;;AAAA,IAAI,UAAU;AAGd,SAAgB,WAAW,QAAc;CACvC,IAAI,OAAO,WAAW,YAAY,OAAO,KAAI,MAAO,IAClD,MAAM,IAAI,UAAU,6CAA6C;CAEnE,WAAW;CACX,OAAO,GAAG,OAAM,GAAI;AACtB;ACFA,IAAa,UAAb,MAAa,QAAO;CACD,qBAAqB,OAAO,kBAAkB;CAC9C,SAAS,OAAO,SAAS;CAGjC,gBAAiC,KAAK,MAAM,mBAAmB;CAE/D,SAA0B,KAAK,MACtC,eAAe,KAAK,OAAO,kBAAkB,IAAI,IAAK;CAG/C,gBAAiC,KAAK,MAAM,kCAAkC;CAE9E,QAAyB,eAAe,KAAK,cAAa,KAAM,KAAK,OAAM,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAE/E,MAAM,OAAa;EACzB,MAAM,QAAQ,SAAS,KAAK,mBAAmB,QAAQ,KAAK,GAAG,EAC7D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KAAK,KAAK;AAEnE;AAGA,SAAS,YAAY,MAAU;CAC7B,IAAI,KAAK,aAAa,KAAK,WACzB,QAAQ,KAAK,eAAe,GAAA,CAAI,KAAI;CAEtC,IACE,gBAAgB,YACf,KAAK,aAAa,aAAa,MAAM,UAAU,KAAK,aAAa,QAAQ,IAE1E,OAAO;CAET,OAAO,MAAM,KAAK,KAAK,YAAY,WAAW,CAAC,CAAC,KAAK,EAAE;AACzD"}
@@ -0,0 +1,165 @@
1
+ import { isPlatformBrowser } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, PLATFORM_ID, ViewEncapsulation, afterNextRender, computed, effect, inject, input } from "@angular/core";
4
+ import { hasAccessibleName } from "@ckui/core/internal";
5
+ const DEFAULT_MAX = 100;
6
+ const isValidMax = (max) => typeof max === "number" && Number.isFinite(max) && max > 0;
7
+ var CkProgress = class CkProgress {
8
+ value = input(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
9
+ max = input(DEFAULT_MAX, ...ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []);
10
+ valueText = input(void 0, ...ngDevMode ? [{ debugName: "valueText" }] : /* istanbul ignore next */ []);
11
+ element = inject(ElementRef).nativeElement;
12
+ limit = computed(() => {
13
+ const max = this.max();
14
+ return isValidMax(max) ? max : DEFAULT_MAX;
15
+ }, ...ngDevMode ? [{ debugName: "limit" }] : /* istanbul ignore next */ []);
16
+ current = computed(() => {
17
+ const value = this.value();
18
+ if (typeof value !== "number" || Number.isNaN(value)) return null;
19
+ return Math.min(Math.max(value, 0), this.limit());
20
+ }, ...ngDevMode ? [{ debugName: "current" }] : /* istanbul ignore next */ []);
21
+ indeterminate = computed(() => this.current() === null, ...ngDevMode ? [{ debugName: "indeterminate" }] : /* istanbul ignore next */ []);
22
+ fraction = computed(() => (this.current() ?? 0) / this.limit(), ...ngDevMode ? [{ debugName: "fraction" }] : /* istanbul ignore next */ []);
23
+ constructor() {
24
+ if (typeof ngDevMode !== "undefined" && ngDevMode && isPlatformBrowser(inject(PLATFORM_ID))) {
25
+ let destroyed = false;
26
+ inject(DestroyRef).onDestroy(() => destroyed = true);
27
+ let warnedMax = false;
28
+ effect(() => {
29
+ const max = this.max();
30
+ if (!warnedMax && !destroyed && !isValidMax(max)) {
31
+ warnedMax = true;
32
+ console.warn(`[ckui] ck-progress got max=${String(max)}, which is not a number above 0. It counts as ${DEFAULT_MAX}.`, this.element);
33
+ }
34
+ });
35
+ afterNextRender(() => {
36
+ if (!destroyed && !hasAccessibleName(this.element, {
37
+ title: false,
38
+ text: false
39
+ })) console.warn("[ckui] ck-progress has no accessible name. Add an aria-label or aria-labelledby.", this.element);
40
+ });
41
+ }
42
+ }
43
+ static ɵfac = i0.ɵɵngDeclareFactory({
44
+ minVersion: "12.0.0",
45
+ version: "22.2.4",
46
+ ngImport: i0,
47
+ type: CkProgress,
48
+ deps: [],
49
+ target: i0.ɵɵFactoryTarget.Component
50
+ });
51
+ static ɵcmp = i0.ɵɵngDeclareComponent({
52
+ minVersion: "17.0.0",
53
+ version: "22.2.4",
54
+ type: CkProgress,
55
+ isStandalone: true,
56
+ selector: "ck-progress",
57
+ inputs: {
58
+ value: {
59
+ classPropertyName: "value",
60
+ publicName: "value",
61
+ isSignal: true,
62
+ isRequired: false,
63
+ transformFunction: null
64
+ },
65
+ max: {
66
+ classPropertyName: "max",
67
+ publicName: "max",
68
+ isSignal: true,
69
+ isRequired: false,
70
+ transformFunction: null
71
+ },
72
+ valueText: {
73
+ classPropertyName: "valueText",
74
+ publicName: "valueText",
75
+ isSignal: true,
76
+ isRequired: false,
77
+ transformFunction: null
78
+ }
79
+ },
80
+ host: {
81
+ attributes: {
82
+ "role": "progressbar",
83
+ "aria-valuemin": "0"
84
+ },
85
+ properties: {
86
+ "class.ck-progress--indeterminate": "indeterminate()",
87
+ "attr.aria-valuemax": "limit()",
88
+ "attr.aria-valuenow": "current()",
89
+ "attr.aria-valuetext": "valueText() || null",
90
+ "style.--_ck-progress-fraction": "fraction()"
91
+ },
92
+ classAttribute: "ck-progress"
93
+ },
94
+ ngImport: i0,
95
+ template: `@if (indeterminate()) {
96
+ <span class="ck-progress__fill ck-progress__fill--slide"></span>
97
+ } @else {
98
+ <span class="ck-progress__fill"></span>
99
+ }`,
100
+ isInline: true,
101
+ styles: ["@layer ckui{.ck-progress{--_ck-progress-direction: 1;position:relative;display:block;box-sizing:border-box;inline-size:100%;block-size:var(--ck-progress-thickness, var(--ck-space-1));overflow:hidden;border-radius:var(--ck-progress-radius, var(--ck-radius-full));background:var(--ck-progress-track, var(--ck-color-control));color-scheme:var(--ck-color-scheme)}.ck-progress:dir(rtl){--_ck-progress-direction: -1}.ck-progress__fill{position:absolute;inset:0;border-radius:inherit;background:var(--ck-progress-fill, var(--ck-color-primary));transform:scaleX(var(--_ck-progress-fraction, 0));transform-origin:left center;transition:transform var(--ck-duration-normal) var(--ck-ease-standard)}.ck-progress:dir(rtl)>.ck-progress__fill{transform-origin:right center}.ck-progress--indeterminate>.ck-progress__fill{inset-inline-end:auto;inline-size:40%;transform:translate(calc(var(--_ck-progress-direction) * -100%));transition:none;animation:ck-progress-slide calc(var(--ck-duration-slow) * 5) var(--ck-ease-standard) infinite}@keyframes ck-progress-slide{0%{transform:translate(calc(var(--_ck-progress-direction) * -100%))}to{transform:translate(calc(var(--_ck-progress-direction) * 250%))}}@media(prefers-reduced-motion:reduce){.ck-progress__fill{transition:none}.ck-progress--indeterminate>.ck-progress__fill{inline-size:50%;transform:none;animation:none}}@media(forced-colors:active){.ck-progress{outline:1px solid CanvasText}.ck-progress__fill{forced-color-adjust:none;background:Highlight}}}\n"],
102
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
103
+ encapsulation: i0.ViewEncapsulation.None
104
+ });
105
+ };
106
+ i0.ɵɵngDeclareClassMetadata({
107
+ minVersion: "12.0.0",
108
+ version: "22.2.4",
109
+ ngImport: i0,
110
+ type: CkProgress,
111
+ decorators: [{
112
+ type: Component,
113
+ args: [{
114
+ selector: "ck-progress",
115
+ changeDetection: ChangeDetectionStrategy.OnPush,
116
+ encapsulation: ViewEncapsulation.None,
117
+ host: {
118
+ class: "ck-progress",
119
+ role: "progressbar",
120
+ "aria-valuemin": "0",
121
+ "[class.ck-progress--indeterminate]": "indeterminate()",
122
+ "[attr.aria-valuemax]": "limit()",
123
+ "[attr.aria-valuenow]": "current()",
124
+ "[attr.aria-valuetext]": "valueText() || null",
125
+ "[style.--_ck-progress-fraction]": "fraction()"
126
+ },
127
+ template: `@if (indeterminate()) {
128
+ <span class="ck-progress__fill ck-progress__fill--slide"></span>
129
+ } @else {
130
+ <span class="ck-progress__fill"></span>
131
+ }`,
132
+ styles: ["@layer ckui{.ck-progress{--_ck-progress-direction: 1;position:relative;display:block;box-sizing:border-box;inline-size:100%;block-size:var(--ck-progress-thickness, var(--ck-space-1));overflow:hidden;border-radius:var(--ck-progress-radius, var(--ck-radius-full));background:var(--ck-progress-track, var(--ck-color-control));color-scheme:var(--ck-color-scheme)}.ck-progress:dir(rtl){--_ck-progress-direction: -1}.ck-progress__fill{position:absolute;inset:0;border-radius:inherit;background:var(--ck-progress-fill, var(--ck-color-primary));transform:scaleX(var(--_ck-progress-fraction, 0));transform-origin:left center;transition:transform var(--ck-duration-normal) var(--ck-ease-standard)}.ck-progress:dir(rtl)>.ck-progress__fill{transform-origin:right center}.ck-progress--indeterminate>.ck-progress__fill{inset-inline-end:auto;inline-size:40%;transform:translate(calc(var(--_ck-progress-direction) * -100%));transition:none;animation:ck-progress-slide calc(var(--ck-duration-slow) * 5) var(--ck-ease-standard) infinite}@keyframes ck-progress-slide{0%{transform:translate(calc(var(--_ck-progress-direction) * -100%))}to{transform:translate(calc(var(--_ck-progress-direction) * 250%))}}@media(prefers-reduced-motion:reduce){.ck-progress__fill{transition:none}.ck-progress--indeterminate>.ck-progress__fill{inline-size:50%;transform:none;animation:none}}@media(forced-colors:active){.ck-progress{outline:1px solid CanvasText}.ck-progress__fill{forced-color-adjust:none;background:Highlight}}}\n"]
133
+ }]
134
+ }],
135
+ ctorParameters: () => [],
136
+ propDecorators: {
137
+ value: [{
138
+ type: i0.Input,
139
+ args: [{
140
+ isSignal: true,
141
+ alias: "value",
142
+ required: false
143
+ }]
144
+ }],
145
+ max: [{
146
+ type: i0.Input,
147
+ args: [{
148
+ isSignal: true,
149
+ alias: "max",
150
+ required: false
151
+ }]
152
+ }],
153
+ valueText: [{
154
+ type: i0.Input,
155
+ args: [{
156
+ isSignal: true,
157
+ alias: "valueText",
158
+ required: false
159
+ }]
160
+ }]
161
+ }
162
+ });
163
+ export { CkProgress };
164
+
165
+ //# sourceMappingURL=ckui-core-progress.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ckui-core-progress.mjs","names":[],"sources":["../../../../projects/core/progress/progress.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n PLATFORM_ID,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n} from '@angular/core';\nimport { hasAccessibleName } from '@ckui/core/internal';\n\ndeclare const ngDevMode: unknown;\n\nconst DEFAULT_MAX = 100;\n\nconst isValidMax = (max: unknown): max is number =>\n typeof max === 'number' && Number.isFinite(max) && max > 0;\n\n/**\n * A horizontal progress bar. A number `value` fills the track up to `value / max`; `null` (or a\n * value that is not a number) shows an indeterminate bar. It is not a live region: announce\n * milestones yourself.\n */\n@Component({\n selector: 'ck-progress',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'ck-progress',\n role: 'progressbar',\n 'aria-valuemin': '0',\n '[class.ck-progress--indeterminate]': 'indeterminate()',\n '[attr.aria-valuemax]': 'limit()',\n '[attr.aria-valuenow]': 'current()',\n '[attr.aria-valuetext]': 'valueText() || null',\n '[style.--_ck-progress-fraction]': 'fraction()',\n },\n // Two elements, so a switch between the two states starts the fill from its final style, not\n // from the sliding segment's transform and width.\n template: `@if (indeterminate()) {\n <span class=\"ck-progress__fill ck-progress__fill--slide\"></span>\n } @else {\n <span class=\"ck-progress__fill\"></span>\n }`,\n styleUrl: './progress.css',\n})\nexport class CkProgress {\n /**\n * The progress, from 0 to `max`. Below 0 counts as 0 and above `max` as `max`. `null`,\n * `undefined` and `NaN` show an indeterminate bar without `aria-valuenow`.\n */\n readonly value = input<number | null | undefined>(null);\n /** The value that means done. Anything that is not a number above 0 counts as 100. */\n readonly max = input<number>(DEFAULT_MAX);\n /** Text for `aria-valuetext`, such as \"Step 2 of 7\". Without it assistive technology reads the percentage. */\n readonly valueText = input<string | undefined>(undefined);\n\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n\n /** @internal */\n protected readonly limit = computed(() => {\n const max = this.max();\n return isValidMax(max) ? max : DEFAULT_MAX;\n });\n\n /** The clamped value, or `null` while the bar is indeterminate. */\n protected readonly current = computed<number | null>(() => {\n const value = this.value();\n if (typeof value !== 'number' || Number.isNaN(value)) {\n return null;\n }\n return Math.min(Math.max(value, 0), this.limit());\n });\n\n protected readonly indeterminate = computed(() => this.current() === null);\n protected readonly fraction = computed(() => (this.current() ?? 0) / this.limit());\n\n constructor() {\n if (typeof ngDevMode !== 'undefined' && ngDevMode && isPlatformBrowser(inject(PLATFORM_ID))) {\n let destroyed = false;\n inject(DestroyRef).onDestroy(() => (destroyed = true));\n let warnedMax = false;\n effect(() => {\n const max = this.max();\n if (!warnedMax && !destroyed && !isValidMax(max)) {\n warnedMax = true;\n console.warn(\n `[ckui] ck-progress got max=${String(max)}, which is not a number above 0. It counts as ${DEFAULT_MAX}.`,\n this.element,\n );\n }\n });\n afterNextRender(() => {\n if (!destroyed && !hasAccessibleName(this.element, { title: false, text: false })) {\n console.warn(\n '[ckui] ck-progress has no accessible name. Add an aria-label or aria-labelledby.',\n this.element,\n );\n }\n });\n }\n }\n}\n"],"mappings":";;;;AAkBA,MAAM,cAAc;A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