@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,842 @@
1
+ import { DOCUMENT, isPlatformBrowser } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, LOCALE_ID, PLATFORM_ID, Renderer2, ViewEncapsulation, afterNextRender, afterRenderEffect, booleanAttribute, computed, effect, inject, input, viewChild } from "@angular/core";
4
+ import { CK_CONFIG, CK_LABELS } from "@ckui/core";
5
+ import { CkIcon, CkMedia, CkValueControl, hasAccessibleName, provideCkValueAccessor } from "@ckui/core/internal";
6
+ const MAX_DIGITS = 10;
7
+ const EPSILON = 1e-9;
8
+ const LIMIT = 0x38d7ea4c68000;
9
+ function decimalsOf(value) {
10
+ if (!Number.isFinite(value)) return 0;
11
+ const [mantissa, exponent] = String(Math.abs(value)).split("e");
12
+ const fraction = mantissa.split(".")[1]?.length ?? 0;
13
+ const shift = exponent === void 0 ? 0 : -Number(exponent);
14
+ return Math.min(Math.max(fraction + shift, 0), MAX_DIGITS);
15
+ }
16
+ function roundTo(value, digits) {
17
+ const rounded = Number(value.toFixed(Math.min(digits, MAX_DIGITS)));
18
+ return rounded === 0 ? 0 : rounded;
19
+ }
20
+ function snap(value, grid) {
21
+ const { step, min, max, digits } = grid;
22
+ const base = min ?? 0;
23
+ if (min !== null && max !== null && min > max) return roundTo(min, digits);
24
+ let count = Math.round((value - base) / step);
25
+ if (max !== null && base + count * step > max + EPSILON) count = Math.floor((max - base) / step + EPSILON);
26
+ let snapped = base + count * step;
27
+ if (min !== null && snapped < min) snapped = min;
28
+ return roundTo(snapped, digits);
29
+ }
30
+ function adjacent(value, direction, grid) {
31
+ const base = grid.min ?? 0;
32
+ const position = (value - base) / grid.step;
33
+ const nearest = Math.round(position);
34
+ const onGrid = Math.abs(position - nearest) < EPSILON;
35
+ let count;
36
+ if (direction > 0) count = onGrid ? nearest + 1 : Math.ceil(position);
37
+ else count = onGrid ? nearest - 1 : Math.floor(position);
38
+ return snap(base + count * grid.step, grid);
39
+ }
40
+ function moveBy(value, direction, count, grid) {
41
+ const first = adjacent(value, direction, grid);
42
+ return count <= 1 ? first : snap(first + direction * (count - 1) * grid.step, grid);
43
+ }
44
+ function toAscii(text) {
45
+ return text.replace(/[\u0660-\u0669]/g, (digit) => String(digit.charCodeAt(0) - 1632)).replace(/[\u06f0-\u06f9]/g, (digit) => String(digit.charCodeAt(0) - 1776)).replace(/\u066b/g, ".").replace(/\u066c/g, ",").replace(/[\u061c\u200e\u200f]/g, "");
46
+ }
47
+ function separatorsOf(locale) {
48
+ try {
49
+ const parts = new Intl.NumberFormat(locale).formatToParts(1000000.5);
50
+ return {
51
+ decimal: parts.find((part) => part.type === "decimal")?.value ?? ".",
52
+ group: parts.find((part) => part.type === "group")?.value ?? ","
53
+ };
54
+ } catch {
55
+ return {
56
+ decimal: ".",
57
+ group: ","
58
+ };
59
+ }
60
+ }
61
+ function createFormatter(locale, minDigits, maxDigits) {
62
+ const options = {
63
+ useGrouping: false,
64
+ minimumFractionDigits: minDigits,
65
+ maximumFractionDigits: Math.max(minDigits, maxDigits)
66
+ };
67
+ try {
68
+ return new Intl.NumberFormat(locale, options);
69
+ } catch {
70
+ return new Intl.NumberFormat("en", options);
71
+ }
72
+ }
73
+ function parseNumber(text, separators) {
74
+ const groupMark = toAscii(separators.group);
75
+ let cleaned = toAscii(text).replace(/[\s'’]/g, "").replace(/[−‒–]/g, "-");
76
+ if (cleaned === "") return null;
77
+ const dots = cleaned.split(".").length - 1;
78
+ const commas = cleaned.split(",").length - 1;
79
+ if (dots > 0 && commas > 0) {
80
+ const decimalMark = cleaned.lastIndexOf(".") > cleaned.lastIndexOf(",") ? "." : ",";
81
+ const groupMark = decimalMark === "." ? "," : ".";
82
+ cleaned = cleaned.split(groupMark).join("").replace(decimalMark, ".");
83
+ } else if (dots + commas > 0) {
84
+ const mark = dots > 0 ? "." : ",";
85
+ const count = Math.max(dots, commas);
86
+ const grouped = /^[+-]?[1-9]\d{0,2}([.,]\d{3})+$/.test(cleaned);
87
+ if (count > 1 || grouped && groupMark === mark) {
88
+ if (!grouped) return;
89
+ cleaned = cleaned.split(mark).join("");
90
+ } else cleaned = cleaned.replace(mark, ".");
91
+ }
92
+ if (!/^[+-]?(\d+\.?\d*|\.\d+)$/.test(cleaned)) return;
93
+ const parsed = Number(cleaned);
94
+ return Number.isFinite(parsed) && Math.abs(parsed) <= LIMIT ? parsed : void 0;
95
+ }
96
+ const REPEAT_DELAY = 400;
97
+ const REPEAT_INTERVAL = 80;
98
+ const REPEAT_RAMP = 2e3;
99
+ const REPEAT_RAMP_FACTOR = 5;
100
+ const DEFAULT_LARGE_FACTOR = 10;
101
+ const SHOWN_DIGITS = 6;
102
+ function toNumber(value) {
103
+ if (value === null || value === void 0 || value === "") return null;
104
+ return typeof value === "number" || typeof value === "string" ? Number(value) : NaN;
105
+ }
106
+ const finiteOrNull = (value) => value !== null && Number.isFinite(value) ? value : null;
107
+ var CkStepper = class CkStepper extends CkValueControl {
108
+ min = input(null, {
109
+ ...ngDevMode ? { debugName: "min" } : /* istanbul ignore next */ {},
110
+ transform: toNumber
111
+ });
112
+ max = input(null, {
113
+ ...ngDevMode ? { debugName: "max" } : /* istanbul ignore next */ {},
114
+ transform: toNumber
115
+ });
116
+ step = input(null, {
117
+ ...ngDevMode ? { debugName: "step" } : /* istanbul ignore next */ {},
118
+ transform: toNumber
119
+ });
120
+ largeStep = input(null, {
121
+ ...ngDevMode ? { debugName: "largeStep" } : /* istanbul ignore next */ {},
122
+ transform: toNumber
123
+ });
124
+ unit = input("", ...ngDevMode ? [{ debugName: "unit" }] : /* istanbul ignore next */ []);
125
+ size = input(void 0, ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
126
+ readonly = input(false, {
127
+ ...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
128
+ transform: booleanAttribute
129
+ });
130
+ decrementLabel = input("", ...ngDevMode ? [{ debugName: "decrementLabel" }] : /* istanbul ignore next */ []);
131
+ incrementLabel = input("", ...ngDevMode ? [{ debugName: "incrementLabel" }] : /* istanbul ignore next */ []);
132
+ ariaLabel = input(null, {
133
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
134
+ alias: "aria-label"
135
+ });
136
+ ariaLabelledby = input(null, {
137
+ ...ngDevMode ? { debugName: "ariaLabelledby" } : /* istanbul ignore next */ {},
138
+ alias: "aria-labelledby"
139
+ });
140
+ ariaDescribedby = input(null, {
141
+ ...ngDevMode ? { debugName: "ariaDescribedby" } : /* istanbul ignore next */ {},
142
+ alias: "aria-describedby"
143
+ });
144
+ config = inject(CK_CONFIG);
145
+ labels = inject(CK_LABELS);
146
+ locale = inject(LOCALE_ID);
147
+ media = inject(CkMedia);
148
+ document = inject(DOCUMENT);
149
+ browser = isPlatformBrowser(inject(PLATFORM_ID));
150
+ element = inject(ElementRef).nativeElement;
151
+ inputRef = viewChild.required("input", ...ngDevMode ? [{ debugName: "inputRef" }] : /* istanbul ignore next */ []);
152
+ editing = false;
153
+ shown = null;
154
+ holding = false;
155
+ pressed = false;
156
+ stopWatchingRelease = null;
157
+ repeatTimer = null;
158
+ repeatElapsed = 0;
159
+ repeatDirection = 1;
160
+ modifierClasses = computed(() => `ck-stepper ck-stepper--${this.size() ?? this.config.size}`, ...ngDevMode ? [{ debugName: "modifierClasses" }] : /* istanbul ignore next */ []);
161
+ inputMode = computed(() => {
162
+ const { min } = this.bounds();
163
+ return min !== null && min < 0 ? "text" : "decimal";
164
+ }, ...ngDevMode ? [{ debugName: "inputMode" }] : /* istanbul ignore next */ []);
165
+ stepSize = computed(() => {
166
+ const step = this.step();
167
+ return step !== null && Number.isFinite(step) && step > 0 ? step : 1;
168
+ }, ...ngDevMode ? [{ debugName: "stepSize" }] : /* istanbul ignore next */ []);
169
+ bounds = computed(() => {
170
+ const min = finiteOrNull(this.min());
171
+ const max = finiteOrNull(this.max());
172
+ return {
173
+ min,
174
+ max: min !== null && max !== null && max < min ? min : max
175
+ };
176
+ }, ...ngDevMode ? [{ debugName: "bounds" }] : /* istanbul ignore next */ []);
177
+ digits = computed(() => Math.max(decimalsOf(this.stepSize()), decimalsOf(this.bounds().min ?? 0)), ...ngDevMode ? [{ debugName: "digits" }] : /* istanbul ignore next */ []);
178
+ grid = computed(() => ({
179
+ step: this.stepSize(),
180
+ ...this.bounds(),
181
+ digits: this.digits()
182
+ }), ...ngDevMode ? [{ debugName: "grid" }] : /* istanbul ignore next */ []);
183
+ largeDelta = computed(() => {
184
+ const large = this.largeStep();
185
+ return large !== null && Number.isFinite(large) && large > 0 ? large : this.stepSize() * DEFAULT_LARGE_FACTOR;
186
+ }, ...ngDevMode ? [{ debugName: "largeDelta" }] : /* istanbul ignore next */ []);
187
+ separators = computed(() => separatorsOf(this.locale), ...ngDevMode ? [{ debugName: "separators" }] : /* istanbul ignore next */ []);
188
+ current = computed(() => {
189
+ const value = this.value();
190
+ return typeof value === "number" && Number.isFinite(value) ? value : null;
191
+ }, ...ngDevMode ? [{ debugName: "current" }] : /* istanbul ignore next */ []);
192
+ format(value) {
193
+ if (value === null) return "";
194
+ const shown = Math.min(decimalsOf(value), SHOWN_DIGITS);
195
+ return createFormatter(this.locale, this.digits(), shown).format(value);
196
+ }
197
+ displayValue = computed(() => this.format(this.current()), ...ngDevMode ? [{ debugName: "displayValue" }] : /* istanbul ignore next */ []);
198
+ valueText = computed(() => {
199
+ const value = this.displayValue();
200
+ return value === "" ? null : this.unit() ? `${value} ${this.unit()}` : value;
201
+ }, ...ngDevMode ? [{ debugName: "valueText" }] : /* istanbul ignore next */ []);
202
+ chars = computed(() => {
203
+ const { min, max } = this.bounds();
204
+ const lengths = (min !== null || max !== null ? [min, max] : [this.current()]).filter((value) => value !== null).map((value) => this.format(value).length);
205
+ return Math.max(3, ...lengths);
206
+ }, ...ngDevMode ? [{ debugName: "chars" }] : /* istanbul ignore next */ []);
207
+ decrementText = computed(() => this.decrementLabel() || this.labels().decrement, ...ngDevMode ? [{ debugName: "decrementText" }] : /* istanbul ignore next */ []);
208
+ incrementText = computed(() => this.incrementLabel() || this.labels().increment, ...ngDevMode ? [{ debugName: "incrementText" }] : /* istanbul ignore next */ []);
209
+ locked = computed(() => this.isDisabled() || this.readonly(), ...ngDevMode ? [{ debugName: "locked" }] : /* istanbul ignore next */ []);
210
+ decrementBlocked = computed(() => {
211
+ const { min } = this.bounds();
212
+ const value = this.current();
213
+ return this.locked() || value !== null && min !== null && value <= min;
214
+ }, ...ngDevMode ? [{ debugName: "decrementBlocked" }] : /* istanbul ignore next */ []);
215
+ incrementBlocked = computed(() => {
216
+ const { max } = this.bounds();
217
+ const value = this.current();
218
+ return this.locked() || value !== null && max !== null && value >= max;
219
+ }, ...ngDevMode ? [{ debugName: "incrementBlocked" }] : /* istanbul ignore next */ []);
220
+ constructor() {
221
+ super();
222
+ const renderer = inject(Renderer2);
223
+ renderer.removeAttribute(this.element, "aria-label");
224
+ renderer.removeAttribute(this.element, "aria-labelledby");
225
+ renderer.removeAttribute(this.element, "aria-describedby");
226
+ inject(DestroyRef).onDestroy(() => {
227
+ this.holding = false;
228
+ this.clearRepeat();
229
+ this.unwatchRelease();
230
+ });
231
+ effect(() => {
232
+ if (this.locked()) this.endPress();
233
+ });
234
+ let firstRender = true;
235
+ afterRenderEffect(() => {
236
+ const text = this.displayValue();
237
+ if (!this.browser) return;
238
+ const wasFirst = firstRender;
239
+ firstRender = false;
240
+ if (wasFirst && this.inputRef().nativeElement.value !== text) {
241
+ this.editing = true;
242
+ this.shown = text;
243
+ return;
244
+ }
245
+ if (text !== this.shown) this.show(text);
246
+ });
247
+ if (typeof ngDevMode !== "undefined" && ngDevMode && this.browser) this.watchConfiguration();
248
+ }
249
+ watchConfiguration() {
250
+ let destroyed = false;
251
+ inject(DestroyRef).onDestroy(() => destroyed = true);
252
+ afterNextRender(() => {
253
+ if (!destroyed && !hasAccessibleName(this.inputRef().nativeElement, {
254
+ title: false,
255
+ text: false,
256
+ labels: true
257
+ })) console.warn("[ckui] ck-stepper has no accessible name. Add an aria-label or aria-labelledby, or wrap it in a <label>.", this.element);
258
+ });
259
+ let warnedStep = false;
260
+ let warnedBounds = false;
261
+ effect(() => {
262
+ const step = this.step();
263
+ if (!warnedStep && step !== null && !(Number.isFinite(step) && step > 0)) {
264
+ warnedStep = true;
265
+ console.warn(`[ckui] ck-stepper step must be a number above 0, got ${step}. Using 1.`, this.element);
266
+ }
267
+ const min = finiteOrNull(this.min());
268
+ const max = finiteOrNull(this.max());
269
+ if (!warnedBounds && min !== null && max !== null && min > max) {
270
+ warnedBounds = true;
271
+ console.warn(`[ckui] ck-stepper min (${min}) is above max (${max}). The value is pinned to min.`, this.element);
272
+ }
273
+ });
274
+ }
275
+ show(text) {
276
+ const input = this.inputRef().nativeElement;
277
+ this.editing = false;
278
+ this.shown = text;
279
+ if (input.value !== text) input.value = text;
280
+ }
281
+ base() {
282
+ if (!this.editing) return this.current();
283
+ const parsed = parseNumber(this.inputRef().nativeElement.value, this.separators());
284
+ if (parsed === void 0) return this.current();
285
+ return parsed === null ? null : snap(parsed, this.grid());
286
+ }
287
+ stepBy(direction, count) {
288
+ const grid = this.grid();
289
+ const base = this.base();
290
+ const next = base === null ? snap(Math.min(grid.min ?? 0, grid.max ?? Infinity), grid) : moveBy(base, direction, count, grid);
291
+ return this.settle(next);
292
+ }
293
+ settle(next) {
294
+ const before = this.current();
295
+ if (next === before) {
296
+ this.show(this.displayValue());
297
+ return false;
298
+ }
299
+ this.commit(next);
300
+ this.show(this.displayValue());
301
+ return !Object.is(before, this.current());
302
+ }
303
+ commitText() {
304
+ if (!this.editing) return;
305
+ const parsed = parseNumber(this.inputRef().nativeElement.value, this.separators());
306
+ if (parsed === void 0) {
307
+ this.show(this.displayValue());
308
+ return;
309
+ }
310
+ this.settle(parsed === null ? null : snap(parsed, this.grid()));
311
+ }
312
+ onKeydown(event) {
313
+ if (this.isDisabled() || event.ctrlKey || event.metaKey || event.altKey) return;
314
+ if (event.key === "Enter") {
315
+ this.commitText();
316
+ return;
317
+ }
318
+ if (this.readonly()) return;
319
+ const { min, max } = this.bounds();
320
+ switch (event.key) {
321
+ case "ArrowUp":
322
+ this.stepBy(1, 1);
323
+ break;
324
+ case "ArrowDown":
325
+ this.stepBy(-1, 1);
326
+ break;
327
+ case "PageUp":
328
+ this.stepBy(1, this.largeDelta() / this.stepSize());
329
+ break;
330
+ case "PageDown":
331
+ this.stepBy(-1, this.largeDelta() / this.stepSize());
332
+ break;
333
+ case "Home":
334
+ if (min === null) return;
335
+ this.settle(snap(min, this.grid()));
336
+ break;
337
+ case "End":
338
+ if (max === null) return;
339
+ this.settle(snap(max, this.grid()));
340
+ break;
341
+ default: return;
342
+ }
343
+ event.preventDefault();
344
+ }
345
+ onFocusOut(event) {
346
+ if (this.isDisabled()) return;
347
+ const onInput = event.target === this.inputRef().nativeElement;
348
+ const endsHold = onInput && this.holding;
349
+ if (onInput) {
350
+ this.commitText();
351
+ this.endPress();
352
+ }
353
+ const entering = event.relatedTarget;
354
+ if (!endsHold && (!(entering instanceof Node) || !this.element.contains(entering))) this.markTouched();
355
+ }
356
+ focusInput(event) {
357
+ const input = this.inputRef().nativeElement;
358
+ const target = event.target;
359
+ if (target instanceof Element && target !== input && target.closest(".ck-stepper__field") !== null && !input.disabled) input.focus({ preventScroll: true });
360
+ }
361
+ onPress(event, direction) {
362
+ const blocked = direction > 0 ? this.incrementBlocked() : this.decrementBlocked();
363
+ const disabledByAncestor = event.currentTarget.matches(":disabled");
364
+ if (event.button !== 0 || !event.isPrimary || blocked || disabledByAncestor) return;
365
+ this.pressed = true;
366
+ event.preventDefault();
367
+ if (!this.media.coarsePointer()) this.inputRef().nativeElement.focus({ preventScroll: true });
368
+ this.endPress();
369
+ this.holding = true;
370
+ this.watchRelease();
371
+ this.repeatDirection = direction;
372
+ this.repeatElapsed = 0;
373
+ if (this.stepBy(direction, 1)) this.scheduleRepeat(REPEAT_DELAY);
374
+ else this.endPress();
375
+ }
376
+ onPressMove(event) {
377
+ if (!this.holding) return;
378
+ const rect = event.currentTarget.getBoundingClientRect();
379
+ if (!(event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom)) {
380
+ this.pressed = false;
381
+ this.endPress();
382
+ }
383
+ }
384
+ onPressCancel() {
385
+ this.pressed = false;
386
+ this.endPress();
387
+ }
388
+ onButtonClick(direction) {
389
+ if (this.pressed) {
390
+ this.pressed = false;
391
+ return;
392
+ }
393
+ if (this.locked()) return;
394
+ this.stepBy(direction, 1);
395
+ this.markTouched();
396
+ }
397
+ scheduleRepeat(delay) {
398
+ this.repeatTimer = setTimeout(() => {
399
+ this.repeatTimer = null;
400
+ this.repeatElapsed += delay;
401
+ if (!this.holding || this.locked() || this.inputRef().nativeElement.matches(":disabled")) {
402
+ this.endPress();
403
+ return;
404
+ }
405
+ const count = this.repeatElapsed >= REPEAT_RAMP ? REPEAT_RAMP_FACTOR : 1;
406
+ if (this.stepBy(this.repeatDirection, count)) this.scheduleRepeat(REPEAT_INTERVAL);
407
+ else this.endPress();
408
+ }, delay);
409
+ }
410
+ watchRelease() {
411
+ this.unwatchRelease();
412
+ const view = this.document.defaultView;
413
+ const onVisibility = () => {
414
+ if (this.document.visibilityState === "hidden") this.endPress();
415
+ };
416
+ const onBlur = () => this.endPress();
417
+ this.document.addEventListener("visibilitychange", onVisibility);
418
+ view?.addEventListener("blur", onBlur);
419
+ this.stopWatchingRelease = () => {
420
+ this.document.removeEventListener("visibilitychange", onVisibility);
421
+ view?.removeEventListener("blur", onBlur);
422
+ };
423
+ }
424
+ unwatchRelease() {
425
+ this.stopWatchingRelease?.();
426
+ this.stopWatchingRelease = null;
427
+ }
428
+ clearRepeat() {
429
+ if (this.repeatTimer !== null) {
430
+ clearTimeout(this.repeatTimer);
431
+ this.repeatTimer = null;
432
+ }
433
+ }
434
+ endPress() {
435
+ this.clearRepeat();
436
+ this.unwatchRelease();
437
+ if (this.holding) {
438
+ this.holding = false;
439
+ this.markTouched();
440
+ }
441
+ }
442
+ static ɵfac = i0.ɵɵngDeclareFactory({
443
+ minVersion: "12.0.0",
444
+ version: "22.2.4",
445
+ ngImport: i0,
446
+ type: CkStepper,
447
+ deps: [],
448
+ target: i0.ɵɵFactoryTarget.Component
449
+ });
450
+ static ɵcmp = i0.ɵɵngDeclareComponent({
451
+ minVersion: "17.0.0",
452
+ version: "22.2.4",
453
+ type: CkStepper,
454
+ isStandalone: true,
455
+ selector: "ck-stepper",
456
+ inputs: {
457
+ min: {
458
+ classPropertyName: "min",
459
+ publicName: "min",
460
+ isSignal: true,
461
+ isRequired: false,
462
+ transformFunction: null
463
+ },
464
+ max: {
465
+ classPropertyName: "max",
466
+ publicName: "max",
467
+ isSignal: true,
468
+ isRequired: false,
469
+ transformFunction: null
470
+ },
471
+ step: {
472
+ classPropertyName: "step",
473
+ publicName: "step",
474
+ isSignal: true,
475
+ isRequired: false,
476
+ transformFunction: null
477
+ },
478
+ largeStep: {
479
+ classPropertyName: "largeStep",
480
+ publicName: "largeStep",
481
+ isSignal: true,
482
+ isRequired: false,
483
+ transformFunction: null
484
+ },
485
+ unit: {
486
+ classPropertyName: "unit",
487
+ publicName: "unit",
488
+ isSignal: true,
489
+ isRequired: false,
490
+ transformFunction: null
491
+ },
492
+ size: {
493
+ classPropertyName: "size",
494
+ publicName: "size",
495
+ isSignal: true,
496
+ isRequired: false,
497
+ transformFunction: null
498
+ },
499
+ readonly: {
500
+ classPropertyName: "readonly",
501
+ publicName: "readonly",
502
+ isSignal: true,
503
+ isRequired: false,
504
+ transformFunction: null
505
+ },
506
+ decrementLabel: {
507
+ classPropertyName: "decrementLabel",
508
+ publicName: "decrementLabel",
509
+ isSignal: true,
510
+ isRequired: false,
511
+ transformFunction: null
512
+ },
513
+ incrementLabel: {
514
+ classPropertyName: "incrementLabel",
515
+ publicName: "incrementLabel",
516
+ isSignal: true,
517
+ isRequired: false,
518
+ transformFunction: null
519
+ },
520
+ ariaLabel: {
521
+ classPropertyName: "ariaLabel",
522
+ publicName: "aria-label",
523
+ isSignal: true,
524
+ isRequired: false,
525
+ transformFunction: null
526
+ },
527
+ ariaLabelledby: {
528
+ classPropertyName: "ariaLabelledby",
529
+ publicName: "aria-labelledby",
530
+ isSignal: true,
531
+ isRequired: false,
532
+ transformFunction: null
533
+ },
534
+ ariaDescribedby: {
535
+ classPropertyName: "ariaDescribedby",
536
+ publicName: "aria-describedby",
537
+ isSignal: true,
538
+ isRequired: false,
539
+ transformFunction: null
540
+ }
541
+ },
542
+ host: {
543
+ listeners: {
544
+ "focusout": "onFocusOut($event)",
545
+ "click": "focusInput($event)"
546
+ },
547
+ properties: {
548
+ "class": "modifierClasses()",
549
+ "class.ck-stepper--disabled": "isDisabled()",
550
+ "class.ck-stepper--readonly": "readonly()",
551
+ "style.--_ck-stepper-chars": "chars()"
552
+ },
553
+ classAttribute: "ck-stepper"
554
+ },
555
+ providers: [provideCkValueAccessor(CkStepper)],
556
+ viewQueries: [{
557
+ propertyName: "inputRef",
558
+ first: true,
559
+ predicate: ["input"],
560
+ descendants: true,
561
+ isSignal: true
562
+ }],
563
+ usesInheritance: true,
564
+ ngImport: i0,
565
+ template: `
566
+ <span class="ck-stepper__field">
567
+ <input
568
+ #input
569
+ class="ck-stepper__input"
570
+ type="text"
571
+ role="spinbutton"
572
+ [attr.inputmode]="inputMode()"
573
+ autocomplete="off"
574
+ autocapitalize="off"
575
+ spellcheck="false"
576
+ enterkeyhint="done"
577
+ [attr.value]="displayValue()"
578
+ [readOnly]="readonly()"
579
+ [disabled]="isDisabled()"
580
+ [attr.aria-label]="ariaLabel()"
581
+ [attr.aria-labelledby]="ariaLabelledby()"
582
+ [attr.aria-describedby]="ariaDescribedby()"
583
+ [attr.aria-readonly]="readonly() ? 'true' : null"
584
+ [attr.aria-valuenow]="current()"
585
+ [attr.aria-valuemin]="bounds().min"
586
+ [attr.aria-valuemax]="bounds().max"
587
+ [attr.aria-valuetext]="valueText()"
588
+ (input)="editing = true"
589
+ (keydown)="onKeydown($event)"
590
+ />
591
+ @if (unit()) {
592
+ <span class="ck-stepper__unit" aria-hidden="true">{{ unit() }}</span>
593
+ }
594
+ </span>
595
+ <button
596
+ type="button"
597
+ class="ck-stepper__button ck-stepper__button--decrement"
598
+ tabindex="-1"
599
+ [attr.aria-label]="decrementText()"
600
+ [disabled]="decrementBlocked()"
601
+ (pointerdown)="onPress($event, -1)"
602
+ (pointermove)="onPressMove($event)"
603
+ (pointerup)="endPress()"
604
+ (pointercancel)="onPressCancel()"
605
+ (lostpointercapture)="endPress()"
606
+ (pointerleave)="endPress()"
607
+ (click)="onButtonClick(-1)"
608
+ (auxclick)="$event.preventDefault()"
609
+ (contextmenu)="$event.preventDefault()"
610
+ >
611
+ <ck-icon name="minus" />
612
+ </button>
613
+ <button
614
+ type="button"
615
+ class="ck-stepper__button ck-stepper__button--increment"
616
+ tabindex="-1"
617
+ [attr.aria-label]="incrementText()"
618
+ [disabled]="incrementBlocked()"
619
+ (pointerdown)="onPress($event, 1)"
620
+ (pointermove)="onPressMove($event)"
621
+ (pointerup)="endPress()"
622
+ (pointercancel)="onPressCancel()"
623
+ (lostpointercapture)="endPress()"
624
+ (pointerleave)="endPress()"
625
+ (click)="onButtonClick(1)"
626
+ (auxclick)="$event.preventDefault()"
627
+ (contextmenu)="$event.preventDefault()"
628
+ >
629
+ <ck-icon name="plus" />
630
+ </button>
631
+ `,
632
+ isInline: true,
633
+ styles: ["@layer ckui{.ck-stepper{--_ck-stepper-radius: var(--ck-stepper-radius, var(--ck-control-radius));display:inline-flex;align-items:stretch;box-sizing:border-box;max-inline-size:100%;block-size:var(--_ck-stepper-height);border-radius:var(--_ck-stepper-radius);background:var(--ck-stepper-bg, var(--ck-color-control));box-shadow:inset 0 0 0 1px var(--ck-stepper-border-color, var(--ck-color-control-border));color:var(--ck-color-fg);color-scheme:var(--ck-color-scheme);font-family:inherit;font-size:var(--_ck-stepper-font-size);font-variant-numeric:var(--ck-font-variant-numeric);line-height:var(--ck-line-height-tight);vertical-align:middle}.ck-stepper--sm{--_ck-stepper-height: var(--ck-control-height-sm);--_ck-stepper-font-size: var(--ck-control-font-size-sm)}.ck-stepper--md{--_ck-stepper-height: var(--ck-control-height-md);--_ck-stepper-font-size: var(--ck-control-font-size-md)}.ck-stepper--lg{--_ck-stepper-height: var(--ck-control-height-lg);--_ck-stepper-font-size: var(--ck-control-font-size-lg)}.ck-stepper--xl{--_ck-stepper-height: var(--ck-control-height-xl);--_ck-stepper-font-size: var(--ck-control-font-size-xl)}.ck-stepper__button{display:grid;flex:none;place-items:center;box-sizing:border-box;inline-size:var(--_ck-stepper-height);block-size:100%;margin:0;padding:0;border:0;background:transparent;color:inherit;font:inherit;font-size:calc(var(--_ck-stepper-font-size) * 1.25);cursor:pointer;touch-action:manipulation;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent}.ck-stepper__button--decrement{order:-1;border-start-start-radius:var(--_ck-stepper-radius);border-end-start-radius:var(--_ck-stepper-radius)}.ck-stepper__button--increment{border-start-end-radius:var(--_ck-stepper-radius);border-end-end-radius:var(--_ck-stepper-radius)}.ck-stepper__field{display:flex;flex:0 1 auto;align-items:center;justify-content:center;min-inline-size:0;cursor:text}.ck-stepper__input{box-sizing:content-box;flex:0 1 auto;inline-size:var(--ck-stepper-value-width, calc(var(--_ck-stepper-chars, 4) * 1ch + 1ch));min-inline-size:0;block-size:100%;margin:0;padding:0;border:0;border-radius:0;outline:none;background:transparent;color:inherit;font:inherit;font-size:var(--_ck-stepper-font-size);font-weight:var(--ck-font-weight-bold);font-variant-numeric:inherit;text-align:center;appearance:none;-moz-appearance:textfield}.ck-stepper__unit{flex:none;margin-inline-start:var(--ck-space-1);color:var(--ck-color-fg-muted);font-size:var(--_ck-stepper-font-size);white-space:nowrap;pointer-events:none}@media(hover:hover){.ck-stepper__button:not(:disabled):hover{background:var(--ck-color-surface-hover)}}.ck-stepper__button:not(:disabled):active{background:var(--ck-color-surface-active)}.ck-stepper:has(.ck-stepper__input:focus-visible){outline:var(--ck-focus-ring);outline-offset:var(--ck-focus-ring-offset)}.ck-stepper__button:disabled{color:var(--ck-color-fg-disabled);cursor:not-allowed}.ck-stepper--disabled .ck-stepper__input,.ck-stepper--disabled .ck-stepper__unit,.ck-stepper:has(.ck-stepper__input:disabled) .ck-stepper__unit,.ck-stepper__input:disabled{color:var(--ck-color-fg-disabled);cursor:not-allowed}.ck-stepper--disabled .ck-stepper__field,.ck-stepper:has(.ck-stepper__input:disabled) .ck-stepper__field{cursor:not-allowed}.ck-stepper--readonly .ck-stepper__input{cursor:default}@media(forced-colors:active){.ck-stepper{box-shadow:none;outline:1px solid ButtonText;outline-offset:-1px}.ck-stepper:has(.ck-stepper__input:focus-visible){outline:2px solid Highlight;outline-offset:2px}.ck-stepper__unit{color:CanvasText}.ck-stepper__button:disabled,.ck-stepper--disabled .ck-stepper__input,.ck-stepper--disabled .ck-stepper__unit,.ck-stepper:has(.ck-stepper__input:disabled) .ck-stepper__unit,.ck-stepper__input:disabled{color:GrayText}.ck-stepper--disabled,.ck-stepper:has(.ck-stepper__input:disabled){outline-color:GrayText}}}\n"],
634
+ dependencies: [{
635
+ kind: "component",
636
+ type: CkIcon,
637
+ selector: "ck-icon",
638
+ inputs: ["name"]
639
+ }],
640
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
641
+ encapsulation: i0.ViewEncapsulation.None
642
+ });
643
+ };
644
+ i0.ɵɵngDeclareClassMetadata({
645
+ minVersion: "12.0.0",
646
+ version: "22.2.4",
647
+ ngImport: i0,
648
+ type: CkStepper,
649
+ decorators: [{
650
+ type: Component,
651
+ args: [{
652
+ selector: "ck-stepper",
653
+ imports: [CkIcon],
654
+ changeDetection: ChangeDetectionStrategy.OnPush,
655
+ encapsulation: ViewEncapsulation.None,
656
+ providers: [provideCkValueAccessor(CkStepper)],
657
+ host: {
658
+ class: "ck-stepper",
659
+ "[class]": "modifierClasses()",
660
+ "[class.ck-stepper--disabled]": "isDisabled()",
661
+ "[class.ck-stepper--readonly]": "readonly()",
662
+ "[style.--_ck-stepper-chars]": "chars()",
663
+ "(focusout)": "onFocusOut($event)",
664
+ "(click)": "focusInput($event)"
665
+ },
666
+ template: `
667
+ <span class="ck-stepper__field">
668
+ <input
669
+ #input
670
+ class="ck-stepper__input"
671
+ type="text"
672
+ role="spinbutton"
673
+ [attr.inputmode]="inputMode()"
674
+ autocomplete="off"
675
+ autocapitalize="off"
676
+ spellcheck="false"
677
+ enterkeyhint="done"
678
+ [attr.value]="displayValue()"
679
+ [readOnly]="readonly()"
680
+ [disabled]="isDisabled()"
681
+ [attr.aria-label]="ariaLabel()"
682
+ [attr.aria-labelledby]="ariaLabelledby()"
683
+ [attr.aria-describedby]="ariaDescribedby()"
684
+ [attr.aria-readonly]="readonly() ? 'true' : null"
685
+ [attr.aria-valuenow]="current()"
686
+ [attr.aria-valuemin]="bounds().min"
687
+ [attr.aria-valuemax]="bounds().max"
688
+ [attr.aria-valuetext]="valueText()"
689
+ (input)="editing = true"
690
+ (keydown)="onKeydown($event)"
691
+ />
692
+ @if (unit()) {
693
+ <span class="ck-stepper__unit" aria-hidden="true">{{ unit() }}</span>
694
+ }
695
+ </span>
696
+ <button
697
+ type="button"
698
+ class="ck-stepper__button ck-stepper__button--decrement"
699
+ tabindex="-1"
700
+ [attr.aria-label]="decrementText()"
701
+ [disabled]="decrementBlocked()"
702
+ (pointerdown)="onPress($event, -1)"
703
+ (pointermove)="onPressMove($event)"
704
+ (pointerup)="endPress()"
705
+ (pointercancel)="onPressCancel()"
706
+ (lostpointercapture)="endPress()"
707
+ (pointerleave)="endPress()"
708
+ (click)="onButtonClick(-1)"
709
+ (auxclick)="$event.preventDefault()"
710
+ (contextmenu)="$event.preventDefault()"
711
+ >
712
+ <ck-icon name="minus" />
713
+ </button>
714
+ <button
715
+ type="button"
716
+ class="ck-stepper__button ck-stepper__button--increment"
717
+ tabindex="-1"
718
+ [attr.aria-label]="incrementText()"
719
+ [disabled]="incrementBlocked()"
720
+ (pointerdown)="onPress($event, 1)"
721
+ (pointermove)="onPressMove($event)"
722
+ (pointerup)="endPress()"
723
+ (pointercancel)="onPressCancel()"
724
+ (lostpointercapture)="endPress()"
725
+ (pointerleave)="endPress()"
726
+ (click)="onButtonClick(1)"
727
+ (auxclick)="$event.preventDefault()"
728
+ (contextmenu)="$event.preventDefault()"
729
+ >
730
+ <ck-icon name="plus" />
731
+ </button>
732
+ `,
733
+ styles: ["@layer ckui{.ck-stepper{--_ck-stepper-radius: var(--ck-stepper-radius, var(--ck-control-radius));display:inline-flex;align-items:stretch;box-sizing:border-box;max-inline-size:100%;block-size:var(--_ck-stepper-height);border-radius:var(--_ck-stepper-radius);background:var(--ck-stepper-bg, var(--ck-color-control));box-shadow:inset 0 0 0 1px var(--ck-stepper-border-color, var(--ck-color-control-border));color:var(--ck-color-fg);color-scheme:var(--ck-color-scheme);font-family:inherit;font-size:var(--_ck-stepper-font-size);font-variant-numeric:var(--ck-font-variant-numeric);line-height:var(--ck-line-height-tight);vertical-align:middle}.ck-stepper--sm{--_ck-stepper-height: var(--ck-control-height-sm);--_ck-stepper-font-size: var(--ck-control-font-size-sm)}.ck-stepper--md{--_ck-stepper-height: var(--ck-control-height-md);--_ck-stepper-font-size: var(--ck-control-font-size-md)}.ck-stepper--lg{--_ck-stepper-height: var(--ck-control-height-lg);--_ck-stepper-font-size: var(--ck-control-font-size-lg)}.ck-stepper--xl{--_ck-stepper-height: var(--ck-control-height-xl);--_ck-stepper-font-size: var(--ck-control-font-size-xl)}.ck-stepper__button{display:grid;flex:none;place-items:center;box-sizing:border-box;inline-size:var(--_ck-stepper-height);block-size:100%;margin:0;padding:0;border:0;background:transparent;color:inherit;font:inherit;font-size:calc(var(--_ck-stepper-font-size) * 1.25);cursor:pointer;touch-action:manipulation;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent}.ck-stepper__button--decrement{order:-1;border-start-start-radius:var(--_ck-stepper-radius);border-end-start-radius:var(--_ck-stepper-radius)}.ck-stepper__button--increment{border-start-end-radius:var(--_ck-stepper-radius);border-end-end-radius:var(--_ck-stepper-radius)}.ck-stepper__field{display:flex;flex:0 1 auto;align-items:center;justify-content:center;min-inline-size:0;cursor:text}.ck-stepper__input{box-sizing:content-box;flex:0 1 auto;inline-size:var(--ck-stepper-value-width, calc(var(--_ck-stepper-chars, 4) * 1ch + 1ch));min-inline-size:0;block-size:100%;margin:0;padding:0;border:0;border-radius:0;outline:none;background:transparent;color:inherit;font:inherit;font-size:var(--_ck-stepper-font-size);font-weight:var(--ck-font-weight-bold);font-variant-numeric:inherit;text-align:center;appearance:none;-moz-appearance:textfield}.ck-stepper__unit{flex:none;margin-inline-start:var(--ck-space-1);color:var(--ck-color-fg-muted);font-size:var(--_ck-stepper-font-size);white-space:nowrap;pointer-events:none}@media(hover:hover){.ck-stepper__button:not(:disabled):hover{background:var(--ck-color-surface-hover)}}.ck-stepper__button:not(:disabled):active{background:var(--ck-color-surface-active)}.ck-stepper:has(.ck-stepper__input:focus-visible){outline:var(--ck-focus-ring);outline-offset:var(--ck-focus-ring-offset)}.ck-stepper__button:disabled{color:var(--ck-color-fg-disabled);cursor:not-allowed}.ck-stepper--disabled .ck-stepper__input,.ck-stepper--disabled .ck-stepper__unit,.ck-stepper:has(.ck-stepper__input:disabled) .ck-stepper__unit,.ck-stepper__input:disabled{color:var(--ck-color-fg-disabled);cursor:not-allowed}.ck-stepper--disabled .ck-stepper__field,.ck-stepper:has(.ck-stepper__input:disabled) .ck-stepper__field{cursor:not-allowed}.ck-stepper--readonly .ck-stepper__input{cursor:default}@media(forced-colors:active){.ck-stepper{box-shadow:none;outline:1px solid ButtonText;outline-offset:-1px}.ck-stepper:has(.ck-stepper__input:focus-visible){outline:2px solid Highlight;outline-offset:2px}.ck-stepper__unit{color:CanvasText}.ck-stepper__button:disabled,.ck-stepper--disabled .ck-stepper__input,.ck-stepper--disabled .ck-stepper__unit,.ck-stepper:has(.ck-stepper__input:disabled) .ck-stepper__unit,.ck-stepper__input:disabled{color:GrayText}.ck-stepper--disabled,.ck-stepper:has(.ck-stepper__input:disabled){outline-color:GrayText}}}\n"]
734
+ }]
735
+ }],
736
+ ctorParameters: () => [],
737
+ propDecorators: {
738
+ min: [{
739
+ type: i0.Input,
740
+ args: [{
741
+ isSignal: true,
742
+ alias: "min",
743
+ required: false
744
+ }]
745
+ }],
746
+ max: [{
747
+ type: i0.Input,
748
+ args: [{
749
+ isSignal: true,
750
+ alias: "max",
751
+ required: false
752
+ }]
753
+ }],
754
+ step: [{
755
+ type: i0.Input,
756
+ args: [{
757
+ isSignal: true,
758
+ alias: "step",
759
+ required: false
760
+ }]
761
+ }],
762
+ largeStep: [{
763
+ type: i0.Input,
764
+ args: [{
765
+ isSignal: true,
766
+ alias: "largeStep",
767
+ required: false
768
+ }]
769
+ }],
770
+ unit: [{
771
+ type: i0.Input,
772
+ args: [{
773
+ isSignal: true,
774
+ alias: "unit",
775
+ required: false
776
+ }]
777
+ }],
778
+ size: [{
779
+ type: i0.Input,
780
+ args: [{
781
+ isSignal: true,
782
+ alias: "size",
783
+ required: false
784
+ }]
785
+ }],
786
+ readonly: [{
787
+ type: i0.Input,
788
+ args: [{
789
+ isSignal: true,
790
+ alias: "readonly",
791
+ required: false
792
+ }]
793
+ }],
794
+ decrementLabel: [{
795
+ type: i0.Input,
796
+ args: [{
797
+ isSignal: true,
798
+ alias: "decrementLabel",
799
+ required: false
800
+ }]
801
+ }],
802
+ incrementLabel: [{
803
+ type: i0.Input,
804
+ args: [{
805
+ isSignal: true,
806
+ alias: "incrementLabel",
807
+ required: false
808
+ }]
809
+ }],
810
+ ariaLabel: [{
811
+ type: i0.Input,
812
+ args: [{
813
+ isSignal: true,
814
+ alias: "aria-label",
815
+ required: false
816
+ }]
817
+ }],
818
+ ariaLabelledby: [{
819
+ type: i0.Input,
820
+ args: [{
821
+ isSignal: true,
822
+ alias: "aria-labelledby",
823
+ required: false
824
+ }]
825
+ }],
826
+ ariaDescribedby: [{
827
+ type: i0.Input,
828
+ args: [{
829
+ isSignal: true,
830
+ alias: "aria-describedby",
831
+ required: false
832
+ }]
833
+ }],
834
+ inputRef: [{
835
+ type: i0.ViewChild,
836
+ args: ["input", { isSignal: true }]
837
+ }]
838
+ }
839
+ });
840
+ export { CkStepper };
841
+
842
+ //# sourceMappingURL=ckui-core-stepper.mjs.map