@ckui/core 0.1.0-next.1 → 0.1.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +337 -4
- package/fesm2022/ckui-core-badge.mjs +169 -0
- package/fesm2022/ckui-core-badge.mjs.map +1 -0
- package/fesm2022/ckui-core-chip.mjs +300 -0
- package/fesm2022/ckui-core-chip.mjs.map +1 -0
- package/fesm2022/ckui-core-dialog.mjs +18 -286
- package/fesm2022/ckui-core-dialog.mjs.map +1 -1
- package/fesm2022/ckui-core-drawer.mjs +342 -0
- package/fesm2022/ckui-core-drawer.mjs.map +1 -0
- package/fesm2022/ckui-core-internal-dialog.mjs +296 -0
- package/fesm2022/ckui-core-internal-dialog.mjs.map +1 -0
- package/fesm2022/ckui-core-internal-overlay.mjs +479 -0
- package/fesm2022/ckui-core-internal-overlay.mjs.map +1 -0
- package/fesm2022/ckui-core-internal.mjs +2 -463
- package/fesm2022/ckui-core-internal.mjs.map +1 -1
- package/fesm2022/ckui-core-progress.mjs +165 -0
- package/fesm2022/ckui-core-progress.mjs.map +1 -0
- package/fesm2022/ckui-core-segmented.mjs +184 -8
- package/fesm2022/ckui-core-segmented.mjs.map +1 -1
- package/fesm2022/ckui-core-stepper.mjs +842 -0
- package/fesm2022/ckui-core-stepper.mjs.map +1 -0
- package/fesm2022/ckui-core-switch.mjs +327 -0
- package/fesm2022/ckui-core-switch.mjs.map +1 -0
- package/fesm2022/ckui-core-tabs.mjs +678 -0
- package/fesm2022/ckui-core-tabs.mjs.map +1 -0
- package/fesm2022/ckui-core.mjs +2 -0
- package/fesm2022/ckui-core.mjs.map +1 -1
- package/package.json +37 -1
- package/types/ckui-core-badge.d.ts +44 -0
- package/types/ckui-core-chip.d.ts +62 -0
- package/types/ckui-core-dialog.d.ts +5 -40
- package/types/ckui-core-drawer.d.ts +153 -0
- package/types/ckui-core-internal-dialog.d.ts +102 -0
- package/types/ckui-core-internal-overlay.d.ts +83 -0
- package/types/ckui-core-internal.d.ts +2 -75
- package/types/ckui-core-progress.d.ts +43 -0
- package/types/ckui-core-segmented.d.ts +26 -0
- package/types/ckui-core-stepper.d.ts +186 -0
- package/types/ckui-core-switch.d.ts +90 -0
- package/types/ckui-core-tabs.d.ts +212 -0
- package/types/ckui-core.d.ts +2 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ckui-core-stepper.mjs","names":[],"sources":["../../../../projects/core/stepper/stepper-math.ts","../../../../projects/core/stepper/stepper.ts"],"sourcesContent":["/** What the stepper needs to snap, clamp and format: all numbers already validated. */\nexport interface StepperGrid {\n readonly step: number;\n readonly min: number | null;\n readonly max: number | null;\n readonly digits: number;\n}\n\nexport interface StepperSeparators {\n readonly decimal: string;\n readonly group: string;\n}\n\nconst MAX_DIGITS = 10;\nconst EPSILON = 1e-9;\n/** Larger typed values are treated as a typo and reverted. */\nconst LIMIT = 1e15;\n\n/** Fraction digits of a number as written, `0.25` → 2, `1e-7` → 7. */\nexport function decimalsOf(value: number): number {\n if (!Number.isFinite(value)) {\n return 0;\n }\n const [mantissa, exponent] = String(Math.abs(value)).split('e');\n const fraction = mantissa.split('.')[1]?.length ?? 0;\n const shift = exponent === undefined ? 0 : -Number(exponent);\n return Math.min(Math.max(fraction + shift, 0), MAX_DIGITS);\n}\n\n/** Rounds to `digits` fraction digits, so 0.1 + 0.2 becomes 0.3, and never returns -0. */\nexport function roundTo(value: number, digits: number): number {\n const rounded = Number(value.toFixed(Math.min(digits, MAX_DIGITS)));\n return rounded === 0 ? 0 : rounded;\n}\n\n/** The nearest grid point inside the bounds. When `min` is above `max`, `min` wins. */\nexport function snap(value: number, grid: StepperGrid): number {\n const { step, min, max, digits } = grid;\n const base = min ?? 0;\n if (min !== null && max !== null && min > max) {\n return roundTo(min, digits);\n }\n let count = Math.round((value - base) / step);\n if (max !== null && base + count * step > max + EPSILON) {\n count = Math.floor((max - base) / step + EPSILON);\n }\n let snapped = base + count * step;\n if (min !== null && snapped < min) {\n snapped = min;\n }\n return roundTo(snapped, digits);\n}\n\n/** The first grid point beyond `value` in the direction; a value on the grid moves by one step. */\nexport function adjacent(value: number, direction: 1 | -1, grid: StepperGrid): number {\n const base = grid.min ?? 0;\n const position = (value - base) / grid.step;\n const nearest = Math.round(position);\n const onGrid = Math.abs(position - nearest) < EPSILON;\n let count: number;\n if (direction > 0) {\n count = onGrid ? nearest + 1 : Math.ceil(position);\n } else {\n count = onGrid ? nearest - 1 : Math.floor(position);\n }\n return snap(base + count * grid.step, grid);\n}\n\n/** `count` steps from the value; an off-grid value first moves to the adjacent grid point. */\nexport function moveBy(value: number, direction: 1 | -1, count: number, grid: StepperGrid): number {\n const first = adjacent(value, direction, grid);\n return count <= 1 ? first : snap(first + direction * (count - 1) * grid.step, grid);\n}\n\n/** Arabic-Indic and Persian digits and marks to ASCII, as `Intl` writes numbers in ar and fa. */\nfunction toAscii(text: string): string {\n return text\n .replace(/[\\u0660-\\u0669]/g, (digit) => String(digit.charCodeAt(0) - 0x0660))\n .replace(/[\\u06f0-\\u06f9]/g, (digit) => String(digit.charCodeAt(0) - 0x06f0))\n .replace(/\\u066b/g, '.')\n .replace(/\\u066c/g, ',')\n .replace(/[\\u061c\\u200e\\u200f]/g, '');\n}\n\nexport function separatorsOf(locale: string): StepperSeparators {\n try {\n const parts = new Intl.NumberFormat(locale).formatToParts(1000000.5);\n return {\n decimal: parts.find((part) => part.type === 'decimal')?.value ?? '.',\n group: parts.find((part) => part.type === 'group')?.value ?? ',',\n };\n } catch {\n return { decimal: '.', group: ',' };\n }\n}\n\nexport function createFormatter(\n locale: string,\n minDigits: number,\n maxDigits: number,\n): Intl.NumberFormat {\n const options = {\n useGrouping: false,\n minimumFractionDigits: minDigits,\n maximumFractionDigits: Math.max(minDigits, maxDigits),\n };\n try {\n return new Intl.NumberFormat(locale, options);\n } catch {\n return new Intl.NumberFormat('en', options);\n }\n}\n\n/**\n * Reads what a person typed. `null` is an empty field, `undefined` something that is no number.\n * Both `.` and `,` count as a decimal mark; a mark that is the locale's group separator and sits\n * in groups of three (`1.250` in German) is a group separator.\n */\nexport function parseNumber(\n text: string,\n separators: StepperSeparators,\n): number | null | undefined {\n const groupMark = toAscii(separators.group);\n let cleaned = toAscii(text)\n .replace(/[\\s'’]/g, '')\n .replace(/[−‒–]/g, '-');\n if (cleaned === '') {\n return null;\n }\n const dots = cleaned.split('.').length - 1;\n const commas = cleaned.split(',').length - 1;\n if (dots > 0 && commas > 0) {\n const decimalMark = cleaned.lastIndexOf('.') > cleaned.lastIndexOf(',') ? '.' : ',';\n const groupMark = decimalMark === '.' ? ',' : '.';\n cleaned = cleaned.split(groupMark).join('').replace(decimalMark, '.');\n } else if (dots + commas > 0) {\n const mark = dots > 0 ? '.' : ',';\n const count = Math.max(dots, commas);\n const grouped = /^[+-]?[1-9]\\d{0,2}([.,]\\d{3})+$/.test(cleaned);\n if (count > 1 || (grouped && groupMark === mark)) {\n if (!grouped) {\n return undefined;\n }\n cleaned = cleaned.split(mark).join('');\n } else {\n cleaned = cleaned.replace(mark, '.');\n }\n }\n if (!/^[+-]?(\\d+\\.?\\d*|\\.\\d+)$/.test(cleaned)) {\n return undefined;\n }\n const parsed = Number(cleaned);\n return Number.isFinite(parsed) && Math.abs(parsed) <= LIMIT ? parsed : undefined;\n}\n","import { DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n LOCALE_ID,\n PLATFORM_ID,\n Renderer2,\n ViewEncapsulation,\n afterNextRender,\n afterRenderEffect,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n viewChild,\n} from '@angular/core';\nimport { CK_CONFIG, CK_LABELS, CkSize } from '@ckui/core';\nimport {\n CkIcon,\n CkMedia,\n CkValueControl,\n hasAccessibleName,\n provideCkValueAccessor,\n} from '@ckui/core/internal';\nimport {\n StepperGrid,\n createFormatter,\n decimalsOf,\n moveBy,\n parseNumber,\n separatorsOf,\n snap,\n} from './stepper-math';\n\ndeclare const ngDevMode: unknown;\n\n/** A held button repeats after this delay, then at the interval, and speeds up after the ramp. */\nconst REPEAT_DELAY = 400;\nconst REPEAT_INTERVAL = 80;\nconst REPEAT_RAMP = 2000;\nconst REPEAT_RAMP_FACTOR = 5;\nconst DEFAULT_LARGE_FACTOR = 10;\nconst SHOWN_DIGITS = 6;\n\ntype Direction = 1 | -1;\n\n/** Accepts `50`, `'50'`, `null`, `undefined` and `''`; anything else that is no number is `NaN`. */\nfunction toNumber(value: unknown): number | null {\n if (value === null || value === undefined || value === '') {\n return null;\n }\n return typeof value === 'number' || typeof value === 'string' ? Number(value) : NaN;\n}\n\nconst finiteOrNull = (value: number | null): number | null =>\n value !== null && Number.isFinite(value) ? value : null;\n\n/**\n * A number field with a minus and a plus button. The value is a real text input with the\n * `spinbutton` role: type a number (committed on Enter or blur, snapped to `step` and clamped to\n * `min` / `max`), use the arrow keys, or press the buttons, which repeat while held. An empty\n * field is `null`. The buttons are outside the tab order; the input is the one tab stop.\n *\n * Name it with `aria-label` or `aria-labelledby` on `ck-stepper`, or wrap it in a `<label>`. The\n * attributes are inputs here and move to the input element.\n *\n * The input comes first in the DOM, so a wrapping `<label>` names it rather than a button; the\n * minus button is moved in front of it with CSS `order`.\n */\n@Component({\n selector: 'ck-stepper',\n imports: [CkIcon],\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n providers: [provideCkValueAccessor(CkStepper)],\n host: {\n class: 'ck-stepper',\n '[class]': 'modifierClasses()',\n '[class.ck-stepper--disabled]': 'isDisabled()',\n '[class.ck-stepper--readonly]': 'readonly()',\n '[style.--_ck-stepper-chars]': 'chars()',\n '(focusout)': 'onFocusOut($event)',\n '(click)': 'focusInput($event)',\n },\n template: `\n <span class=\"ck-stepper__field\">\n <input\n #input\n class=\"ck-stepper__input\"\n type=\"text\"\n role=\"spinbutton\"\n [attr.inputmode]=\"inputMode()\"\n autocomplete=\"off\"\n autocapitalize=\"off\"\n spellcheck=\"false\"\n enterkeyhint=\"done\"\n [attr.value]=\"displayValue()\"\n [readOnly]=\"readonly()\"\n [disabled]=\"isDisabled()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-labelledby]=\"ariaLabelledby()\"\n [attr.aria-describedby]=\"ariaDescribedby()\"\n [attr.aria-readonly]=\"readonly() ? 'true' : null\"\n [attr.aria-valuenow]=\"current()\"\n [attr.aria-valuemin]=\"bounds().min\"\n [attr.aria-valuemax]=\"bounds().max\"\n [attr.aria-valuetext]=\"valueText()\"\n (input)=\"editing = true\"\n (keydown)=\"onKeydown($event)\"\n />\n @if (unit()) {\n <span class=\"ck-stepper__unit\" aria-hidden=\"true\">{{ unit() }}</span>\n }\n </span>\n <button\n type=\"button\"\n class=\"ck-stepper__button ck-stepper__button--decrement\"\n tabindex=\"-1\"\n [attr.aria-label]=\"decrementText()\"\n [disabled]=\"decrementBlocked()\"\n (pointerdown)=\"onPress($event, -1)\"\n (pointermove)=\"onPressMove($event)\"\n (pointerup)=\"endPress()\"\n (pointercancel)=\"onPressCancel()\"\n (lostpointercapture)=\"endPress()\"\n (pointerleave)=\"endPress()\"\n (click)=\"onButtonClick(-1)\"\n (auxclick)=\"$event.preventDefault()\"\n (contextmenu)=\"$event.preventDefault()\"\n >\n <ck-icon name=\"minus\" />\n </button>\n <button\n type=\"button\"\n class=\"ck-stepper__button ck-stepper__button--increment\"\n tabindex=\"-1\"\n [attr.aria-label]=\"incrementText()\"\n [disabled]=\"incrementBlocked()\"\n (pointerdown)=\"onPress($event, 1)\"\n (pointermove)=\"onPressMove($event)\"\n (pointerup)=\"endPress()\"\n (pointercancel)=\"onPressCancel()\"\n (lostpointercapture)=\"endPress()\"\n (pointerleave)=\"endPress()\"\n (click)=\"onButtonClick(1)\"\n (auxclick)=\"$event.preventDefault()\"\n (contextmenu)=\"$event.preventDefault()\"\n >\n <ck-icon name=\"plus\" />\n </button>\n `,\n styleUrl: './stepper.css',\n})\nexport class CkStepper extends CkValueControl<number | null> {\n /** Smallest value. Without it the value has no lower limit. When above `max`, `min` wins. */\n readonly min = input<number | null, unknown>(null, { transform: toNumber });\n /** Largest value. Without it the value has no upper limit. */\n readonly max = input<number | null, unknown>(null, { transform: toNumber });\n /** Distance between values, counted from `min` (else 0). Not a number above 0 counts as 1. */\n readonly step = input<number | null, unknown>(null, { transform: toNumber });\n /** What Page Up and Page Down move by. Default: 10 steps. */\n readonly largeStep = input<number | null, unknown>(null, { transform: toNumber });\n /** Text after the value, part of the value text for assistive technology: `W` reads \"250 W\". */\n readonly unit = input('');\n /** `undefined` uses the size from `provideCkui`. */\n readonly size = input<CkSize | undefined>(undefined);\n /** The value can be read and focused, but not typed or stepped. */\n readonly readonly = input(false, { transform: booleanAttribute });\n /** Replaces the label of the minus button (\"FTP minus 5\"). */\n readonly decrementLabel = input('');\n /** Replaces the label of the plus button (\"FTP plus 5\"). */\n readonly incrementLabel = input('');\n /** The accessible name of the input. Moves from the host to the input element. */\n readonly ariaLabel = input<string | null>(null, { alias: 'aria-label' });\n /** The ids of the elements that name the input. Moves from the host to the input element. */\n readonly ariaLabelledby = input<string | null>(null, { alias: 'aria-labelledby' });\n /** The ids of a hint or error for the input. Moves from the host to the input element. */\n readonly ariaDescribedby = input<string | null>(null, { alias: 'aria-describedby' });\n\n private readonly config = inject(CK_CONFIG);\n private readonly labels = inject(CK_LABELS);\n private readonly locale = inject(LOCALE_ID);\n private readonly media = inject(CkMedia);\n private readonly document = inject(DOCUMENT);\n private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n private readonly inputRef = viewChild.required<ElementRef<HTMLInputElement>>('input');\n\n /** Typed text that is not committed yet. */\n protected editing = false;\n /** The text last written into the input, so the render after a commit does not redo it. */\n private shown: string | null = null;\n private holding = false;\n /** Set by an accepted pointerdown on a button; the click that follows it must not step again. */\n private pressed = false;\n private stopWatchingRelease: (() => void) | null = null;\n private repeatTimer: ReturnType<typeof setTimeout> | null = null;\n private repeatElapsed = 0;\n private repeatDirection: Direction = 1;\n\n protected readonly modifierClasses = computed(\n () => `ck-stepper ck-stepper--${this.size() ?? this.config.size}`,\n );\n\n /** The decimal keypad has no minus sign, so a range that allows negatives gets the text one. */\n protected readonly inputMode = computed(() => {\n const { min } = this.bounds();\n return min !== null && min < 0 ? 'text' : 'decimal';\n });\n\n protected readonly stepSize = computed(() => {\n const step = this.step();\n return step !== null && Number.isFinite(step) && step > 0 ? step : 1;\n });\n\n /** The limits, with `max` raised to `min` when they cross. */\n protected readonly bounds = computed(() => {\n const min = finiteOrNull(this.min());\n const max = finiteOrNull(this.max());\n return { min, max: min !== null && max !== null && max < min ? min : max };\n });\n\n private readonly digits = computed(() =>\n Math.max(decimalsOf(this.stepSize()), decimalsOf(this.bounds().min ?? 0)),\n );\n\n private readonly grid = computed<StepperGrid>(() => ({\n step: this.stepSize(),\n ...this.bounds(),\n digits: this.digits(),\n }));\n\n private readonly largeDelta = computed(() => {\n const large = this.largeStep();\n return large !== null && Number.isFinite(large) && large > 0\n ? large\n : this.stepSize() * DEFAULT_LARGE_FACTOR;\n });\n\n private readonly separators = computed(() => separatorsOf(this.locale));\n\n /** The committed value, `null` for none (or anything that is not a finite number). */\n protected readonly current = computed<number | null>(() => {\n const value = this.value();\n return typeof value === 'number' && Number.isFinite(value) ? value : null;\n });\n\n private format(value: number | null): string {\n if (value === null) {\n return '';\n }\n const shown = Math.min(decimalsOf(value), SHOWN_DIGITS);\n return createFormatter(this.locale, this.digits(), shown).format(value);\n }\n\n protected readonly displayValue = computed(() => this.format(this.current()));\n\n protected readonly valueText = computed(() => {\n const value = this.displayValue();\n return value === '' ? null : this.unit() ? `${value} ${this.unit()}` : value;\n });\n\n /** Width of the value in characters, from the formatted limits (else the value), at least 3. */\n protected readonly chars = computed(() => {\n const { min, max } = this.bounds();\n const sources = min !== null || max !== null ? [min, max] : [this.current()];\n const lengths = sources\n .filter((value): value is number => value !== null)\n .map((value) => this.format(value).length);\n return Math.max(3, ...lengths);\n });\n\n protected readonly decrementText = computed(\n () => this.decrementLabel() || this.labels().decrement,\n );\n protected readonly incrementText = computed(\n () => this.incrementLabel() || this.labels().increment,\n );\n\n private readonly locked = computed(() => this.isDisabled() || this.readonly());\n\n protected readonly decrementBlocked = computed(() => {\n const { min } = this.bounds();\n const value = this.current();\n return this.locked() || (value !== null && min !== null && value <= min);\n });\n\n protected readonly incrementBlocked = computed(() => {\n const { max } = this.bounds();\n const value = this.current();\n return this.locked() || (value !== null && max !== null && value >= max);\n });\n\n constructor() {\n super();\n // The names are inputs here, so the host must not also keep them as a (role-less) attribute.\n const renderer = inject(Renderer2);\n renderer.removeAttribute(this.element, 'aria-label');\n renderer.removeAttribute(this.element, 'aria-labelledby');\n renderer.removeAttribute(this.element, 'aria-describedby');\n\n inject(DestroyRef).onDestroy(() => {\n this.holding = false;\n this.clearRepeat();\n this.unwatchRelease();\n });\n\n effect(() => {\n if (this.locked()) {\n this.endPress();\n }\n });\n\n let firstRender = true;\n afterRenderEffect(() => {\n const text = this.displayValue();\n if (!this.browser) {\n return;\n }\n const wasFirst = firstRender;\n firstRender = false;\n // Server markup keeps what a visitor typed before the page took over, as a draft.\n if (wasFirst && this.inputRef().nativeElement.value !== text) {\n this.editing = true;\n this.shown = text;\n return;\n }\n // A commit already showed this text; typing since then is a new draft the render must keep.\n if (text !== this.shown) {\n this.show(text);\n }\n });\n\n if (typeof ngDevMode !== 'undefined' && ngDevMode && this.browser) {\n this.watchConfiguration();\n }\n }\n\n private watchConfiguration(): void {\n let destroyed = false;\n inject(DestroyRef).onDestroy(() => (destroyed = true));\n afterNextRender(() => {\n if (\n !destroyed &&\n !hasAccessibleName(this.inputRef().nativeElement, {\n title: false,\n text: false,\n labels: true,\n })\n ) {\n console.warn(\n '[ckui] ck-stepper has no accessible name. Add an aria-label or aria-labelledby, or wrap it in a <label>.',\n this.element,\n );\n }\n });\n let warnedStep = false;\n let warnedBounds = false;\n effect(() => {\n const step = this.step();\n if (!warnedStep && step !== null && !(Number.isFinite(step) && step > 0)) {\n warnedStep = true;\n console.warn(\n `[ckui] ck-stepper step must be a number above 0, got ${step}. Using 1.`,\n this.element,\n );\n }\n const min = finiteOrNull(this.min());\n const max = finiteOrNull(this.max());\n if (!warnedBounds && min !== null && max !== null && min > max) {\n warnedBounds = true;\n console.warn(\n `[ckui] ck-stepper min (${min}) is above max (${max}). The value is pinned to min.`,\n this.element,\n );\n }\n });\n }\n\n /** Writes text into the input and drops any uncommitted typing. */\n private show(text: string): void {\n const input = this.inputRef().nativeElement;\n this.editing = false;\n this.shown = text;\n if (input.value !== text) {\n input.value = text;\n }\n }\n\n /** The value arrows and buttons start from: the typed text when valid, else the value. */\n private base(): number | null {\n if (!this.editing) {\n return this.current();\n }\n const parsed = parseNumber(this.inputRef().nativeElement.value, this.separators());\n if (parsed === undefined) {\n return this.current();\n }\n return parsed === null ? null : snap(parsed, this.grid());\n }\n\n /** Moves by `count` steps from the base. Returns whether the committed value changed. */\n private stepBy(direction: Direction, count: number): boolean {\n const grid = this.grid();\n const base = this.base();\n const next =\n base === null\n ? snap(Math.min(grid.min ?? 0, grid.max ?? Infinity), grid)\n : moveBy(base, direction, count, grid);\n return this.settle(next);\n }\n\n /** Commits a value from the user and shows what the control then holds. */\n private settle(next: number | null): boolean {\n const before = this.current();\n if (next === before) {\n // Also an emptied field whose value was never set: `undefined` to `null` is no change.\n this.show(this.displayValue());\n return false;\n }\n this.commit(next);\n this.show(this.displayValue());\n return !Object.is(before, this.current());\n }\n\n private commitText(): void {\n if (!this.editing) {\n return;\n }\n const parsed = parseNumber(this.inputRef().nativeElement.value, this.separators());\n if (parsed === undefined) {\n this.show(this.displayValue());\n return;\n }\n this.settle(parsed === null ? null : snap(parsed, this.grid()));\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (this.isDisabled() || event.ctrlKey || event.metaKey || event.altKey) {\n return;\n }\n if (event.key === 'Enter') {\n this.commitText();\n return;\n }\n if (this.readonly()) {\n return;\n }\n const { min, max } = this.bounds();\n switch (event.key) {\n case 'ArrowUp':\n this.stepBy(1, 1);\n break;\n case 'ArrowDown':\n this.stepBy(-1, 1);\n break;\n case 'PageUp':\n this.stepBy(1, this.largeDelta() / this.stepSize());\n break;\n case 'PageDown':\n this.stepBy(-1, this.largeDelta() / this.stepSize());\n break;\n case 'Home':\n if (min === null) {\n return;\n }\n this.settle(snap(min, this.grid()));\n break;\n case 'End':\n if (max === null) {\n return;\n }\n this.settle(snap(max, this.grid()));\n break;\n default:\n return;\n }\n event.preventDefault();\n }\n\n protected onFocusOut(event: FocusEvent): void {\n if (this.isDisabled()) {\n return;\n }\n // Ending a hold counts as touched already, so a blur during one reports once.\n const onInput = event.target === this.inputRef().nativeElement;\n const endsHold = onInput && this.holding;\n if (onInput) {\n this.commitText();\n this.endPress();\n }\n const entering = event.relatedTarget;\n if (!endsHold && (!(entering instanceof Node) || !this.element.contains(entering))) {\n this.markTouched();\n }\n }\n\n /** A click on the field around the value (the unit, the padding) focuses the input. */\n protected focusInput(event: Event): void {\n const input = this.inputRef().nativeElement;\n const target = event.target;\n if (\n target instanceof Element &&\n target !== input &&\n target.closest('.ck-stepper__field') !== null &&\n !input.disabled\n ) {\n input.focus({ preventScroll: true });\n }\n }\n\n /** The press starts on pointerdown, so the first step happens at once and a hold can repeat. */\n protected onPress(event: PointerEvent, direction: Direction): void {\n const blocked = direction > 0 ? this.incrementBlocked() : this.decrementBlocked();\n // A button inside `<fieldset disabled>` is :disabled but still gets pointer events.\n const disabledByAncestor = (event.currentTarget as HTMLElement).matches(':disabled');\n if (event.button !== 0 || !event.isPrimary || blocked || disabledByAncestor) {\n return;\n }\n this.pressed = true;\n // Keeps focus where it is (the input, so arrows still work); the click still happens.\n event.preventDefault();\n if (!this.media.coarsePointer()) {\n this.inputRef().nativeElement.focus({ preventScroll: true });\n }\n this.endPress();\n this.holding = true;\n this.watchRelease();\n this.repeatDirection = direction;\n this.repeatElapsed = 0;\n if (this.stepBy(direction, 1)) {\n this.scheduleRepeat(REPEAT_DELAY);\n } else {\n this.endPress();\n }\n }\n\n /** A pointer that has moved off the button no longer holds it. */\n protected onPressMove(event: PointerEvent): void {\n if (!this.holding) {\n return;\n }\n const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();\n const inside =\n event.clientX >= rect.left &&\n event.clientX <= rect.right &&\n event.clientY >= rect.top &&\n event.clientY <= rect.bottom;\n if (!inside) {\n // Released elsewhere, so no click follows on this button.\n this.pressed = false;\n this.endPress();\n }\n }\n\n /** The browser took the pointer away: no click follows. */\n protected onPressCancel(): void {\n this.pressed = false;\n this.endPress();\n }\n\n /**\n * The click after a pointer press was handled on pointerdown and is skipped. A click without a\n * pointerdown (keyboard, a screen reader's activation, `button.click()`) steps once here.\n */\n protected onButtonClick(direction: Direction): void {\n if (this.pressed) {\n this.pressed = false;\n return;\n }\n if (this.locked()) {\n return;\n }\n this.stepBy(direction, 1);\n this.markTouched();\n }\n\n private scheduleRepeat(delay: number): void {\n this.repeatTimer = setTimeout(() => {\n this.repeatTimer = null;\n this.repeatElapsed += delay;\n if (!this.holding || this.locked() || this.inputRef().nativeElement.matches(':disabled')) {\n this.endPress();\n return;\n }\n const count = this.repeatElapsed >= REPEAT_RAMP ? REPEAT_RAMP_FACTOR : 1;\n if (this.stepBy(this.repeatDirection, count)) {\n this.scheduleRepeat(REPEAT_INTERVAL);\n } else {\n this.endPress();\n }\n }, delay);\n }\n\n /**\n * On a coarse pointer the input is not focused during a press, so the window losing focus and\n * the document turning hidden are the only signals that the finger will not be released here.\n */\n private watchRelease(): void {\n this.unwatchRelease();\n const view = this.document.defaultView;\n const onVisibility = (): void => {\n if (this.document.visibilityState === 'hidden') {\n this.endPress();\n }\n };\n const onBlur = (): void => this.endPress();\n this.document.addEventListener('visibilitychange', onVisibility);\n view?.addEventListener('blur', onBlur);\n this.stopWatchingRelease = () => {\n this.document.removeEventListener('visibilitychange', onVisibility);\n view?.removeEventListener('blur', onBlur);\n };\n }\n\n private unwatchRelease(): void {\n this.stopWatchingRelease?.();\n this.stopWatchingRelease = null;\n }\n\n private clearRepeat(): void {\n if (this.repeatTimer !== null) {\n clearTimeout(this.repeatTimer);\n this.repeatTimer = null;\n }\n }\n\n /** Release, cancel, lost capture, leave, blur, hidden, a bound or a lock: stops, counts as touched. */\n protected endPress(): void {\n this.clearRepeat();\n this.unwatchRelease();\n if (this.holding) {\n this.holding = false;\n this.markTouched();\n }\n }\n}\n"],"mappings":";;;;;AAaA,MAAM,aAAa;AACnB,MAAM,UAAU;AAEhB,MAAM,QAAQ;AAGd,SAAgB,WAAW,OAAa;CACtC,IAAI,CAAC,OAAO,SAAS,KAAK,GACxB,OAAO;CAET,MAAM,CAAC,UAAU,YAAY,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG;CAC9D,MAAM,WAAW,SAAS,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,UAAU;CACnD,MAAM,QAAQ,aAAa,SAAY,IAAI,CAAC,OAAO,QAAQ;CAC3D,OAAO,KAAK,IAAI,KAAK,IAAI,WAAW,OAAO,CAAC,GAAG,UAAU;AAC3D;AAGA,SAAgB,QAAQ,OAAe,QAAc;CACnD,MAAM,UAAU,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,UAAU,CAAC,CAAC;CAClE,OAAO,YAAY,IAAI,IAAI;AAC7B;AAGA,SAAgB,KAAK,OAAe,MAAiB;CACnD,MAAM,EAAE,MAAM,KAAK,KAAK,WAAW;CACnC,MAAM,OAAO,OAAO;CACpB,IAAI,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,KACxC,OAAO,QAAQ,KAAK,MAAM;CAE5B,IAAI,QAAQ,KAAK,OAAO,QAAQ,QAAQ,IAAI;CAC5C,IAAI,QAAQ,QAAQ,OAAO,QAAQ,OAAO,MAAM,SAC9C,QAAQ,KAAK,OAAO,MAAM,QAAQ,OAAO,OAAO;CAElD,IAAI,UAAU,OAAO,QAAQ;CAC7B,IAAI,QAA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AA,CAAA;EAAA,CAAA;EAAA,iBAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,UAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, Directive, ElementRef, PLATFORM_ID, Renderer2, ViewEncapsulation, afterNextRender, computed, contentChild, inject, input, model, viewChild } from "@angular/core";
|
|
3
|
+
import { isPlatformBrowser } from "@angular/common";
|
|
4
|
+
import { CK_CONFIG } from "@ckui/core";
|
|
5
|
+
import { CkValueControl, createCkId, hasAccessibleName, provideCkValueAccessor } from "@ckui/core/internal";
|
|
6
|
+
var CkSwitchHint = class CkSwitchHint {
|
|
7
|
+
id = input(createCkId("ck-switch-hint"), ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
|
|
8
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
9
|
+
minVersion: "12.0.0",
|
|
10
|
+
version: "22.2.4",
|
|
11
|
+
ngImport: i0,
|
|
12
|
+
type: CkSwitchHint,
|
|
13
|
+
deps: [],
|
|
14
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
15
|
+
});
|
|
16
|
+
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
17
|
+
minVersion: "17.1.0",
|
|
18
|
+
version: "22.2.4",
|
|
19
|
+
type: CkSwitchHint,
|
|
20
|
+
isStandalone: true,
|
|
21
|
+
selector: "ck-switch-hint",
|
|
22
|
+
inputs: { id: {
|
|
23
|
+
classPropertyName: "id",
|
|
24
|
+
publicName: "id",
|
|
25
|
+
isSignal: true,
|
|
26
|
+
isRequired: false,
|
|
27
|
+
transformFunction: null
|
|
28
|
+
} },
|
|
29
|
+
host: {
|
|
30
|
+
properties: { "attr.id": "id()" },
|
|
31
|
+
classAttribute: "ck-switch-hint"
|
|
32
|
+
},
|
|
33
|
+
ngImport: i0
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
37
|
+
minVersion: "12.0.0",
|
|
38
|
+
version: "22.2.4",
|
|
39
|
+
ngImport: i0,
|
|
40
|
+
type: CkSwitchHint,
|
|
41
|
+
decorators: [{
|
|
42
|
+
type: Directive,
|
|
43
|
+
args: [{
|
|
44
|
+
selector: "ck-switch-hint",
|
|
45
|
+
host: {
|
|
46
|
+
class: "ck-switch-hint",
|
|
47
|
+
"[attr.id]": "id()"
|
|
48
|
+
}
|
|
49
|
+
}]
|
|
50
|
+
}],
|
|
51
|
+
propDecorators: { id: [{
|
|
52
|
+
type: i0.Input,
|
|
53
|
+
args: [{
|
|
54
|
+
isSignal: true,
|
|
55
|
+
alias: "id",
|
|
56
|
+
required: false
|
|
57
|
+
}]
|
|
58
|
+
}] }
|
|
59
|
+
});
|
|
60
|
+
var CkSwitch = class CkSwitch extends CkValueControl {
|
|
61
|
+
value = model(false, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
|
|
62
|
+
size = input(void 0, ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
63
|
+
labelPosition = input("start", ...ngDevMode ? [{ debugName: "labelPosition" }] : /* istanbul ignore next */ []);
|
|
64
|
+
ariaLabel = input(null, {
|
|
65
|
+
...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
|
|
66
|
+
alias: "aria-label"
|
|
67
|
+
});
|
|
68
|
+
ariaLabelledby = input(null, {
|
|
69
|
+
...ngDevMode ? { debugName: "ariaLabelledby" } : /* istanbul ignore next */ {},
|
|
70
|
+
alias: "aria-labelledby"
|
|
71
|
+
});
|
|
72
|
+
ariaDescribedby = input(null, {
|
|
73
|
+
...ngDevMode ? { debugName: "ariaDescribedby" } : /* istanbul ignore next */ {},
|
|
74
|
+
alias: "aria-describedby"
|
|
75
|
+
});
|
|
76
|
+
config = inject(CK_CONFIG);
|
|
77
|
+
element = inject(ElementRef).nativeElement;
|
|
78
|
+
inputRef = viewChild.required("input", ...ngDevMode ? [{ debugName: "inputRef" }] : /* istanbul ignore next */ []);
|
|
79
|
+
hint = contentChild(CkSwitchHint, ...ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []);
|
|
80
|
+
textId = createCkId("ck-switch-text");
|
|
81
|
+
on = computed(() => this.value() === true, ...ngDevMode ? [{ debugName: "on" }] : /* istanbul ignore next */ []);
|
|
82
|
+
modifierClasses = computed(() => `ck-switch--${this.size() ?? this.config.size} ck-switch--label-${this.labelPosition() === "end" ? "end" : "start"}`, ...ngDevMode ? [{ debugName: "modifierClasses" }] : /* istanbul ignore next */ []);
|
|
83
|
+
labelledby = computed(() => this.ariaLabelledby() ?? (this.ariaLabel() ? null : this.textId), ...ngDevMode ? [{ debugName: "labelledby" }] : /* istanbul ignore next */ []);
|
|
84
|
+
describedby = computed(() => {
|
|
85
|
+
const ids = [this.hint()?.id(), this.ariaDescribedby()].filter((id) => !!id);
|
|
86
|
+
return ids.length > 0 ? ids.join(" ") : null;
|
|
87
|
+
}, ...ngDevMode ? [{ debugName: "describedby" }] : /* istanbul ignore next */ []);
|
|
88
|
+
constructor() {
|
|
89
|
+
super();
|
|
90
|
+
const renderer = inject(Renderer2);
|
|
91
|
+
renderer.removeAttribute(this.element, "aria-label");
|
|
92
|
+
renderer.removeAttribute(this.element, "aria-labelledby");
|
|
93
|
+
renderer.removeAttribute(this.element, "aria-describedby");
|
|
94
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode && isPlatformBrowser(inject(PLATFORM_ID))) {
|
|
95
|
+
let destroyed = false;
|
|
96
|
+
inject(DestroyRef).onDestroy(() => destroyed = true);
|
|
97
|
+
afterNextRender(() => {
|
|
98
|
+
if (!destroyed && !hasAccessibleName(this.inputRef().nativeElement, {
|
|
99
|
+
title: false,
|
|
100
|
+
text: false
|
|
101
|
+
})) console.warn("[ckui] ck-switch has no accessible name. Add text, or an aria-label or aria-labelledby.", this.element);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
onToggle() {
|
|
106
|
+
const input = this.inputRef().nativeElement;
|
|
107
|
+
this.commit(input.checked);
|
|
108
|
+
input.checked = this.on();
|
|
109
|
+
}
|
|
110
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
111
|
+
minVersion: "12.0.0",
|
|
112
|
+
version: "22.2.4",
|
|
113
|
+
ngImport: i0,
|
|
114
|
+
type: CkSwitch,
|
|
115
|
+
deps: [],
|
|
116
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
117
|
+
});
|
|
118
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
119
|
+
minVersion: "17.2.0",
|
|
120
|
+
version: "22.2.4",
|
|
121
|
+
type: CkSwitch,
|
|
122
|
+
isStandalone: true,
|
|
123
|
+
selector: "ck-switch",
|
|
124
|
+
inputs: {
|
|
125
|
+
value: {
|
|
126
|
+
classPropertyName: "value",
|
|
127
|
+
publicName: "value",
|
|
128
|
+
isSignal: true,
|
|
129
|
+
isRequired: false,
|
|
130
|
+
transformFunction: null
|
|
131
|
+
},
|
|
132
|
+
size: {
|
|
133
|
+
classPropertyName: "size",
|
|
134
|
+
publicName: "size",
|
|
135
|
+
isSignal: true,
|
|
136
|
+
isRequired: false,
|
|
137
|
+
transformFunction: null
|
|
138
|
+
},
|
|
139
|
+
labelPosition: {
|
|
140
|
+
classPropertyName: "labelPosition",
|
|
141
|
+
publicName: "labelPosition",
|
|
142
|
+
isSignal: true,
|
|
143
|
+
isRequired: false,
|
|
144
|
+
transformFunction: null
|
|
145
|
+
},
|
|
146
|
+
ariaLabel: {
|
|
147
|
+
classPropertyName: "ariaLabel",
|
|
148
|
+
publicName: "aria-label",
|
|
149
|
+
isSignal: true,
|
|
150
|
+
isRequired: false,
|
|
151
|
+
transformFunction: null
|
|
152
|
+
},
|
|
153
|
+
ariaLabelledby: {
|
|
154
|
+
classPropertyName: "ariaLabelledby",
|
|
155
|
+
publicName: "aria-labelledby",
|
|
156
|
+
isSignal: true,
|
|
157
|
+
isRequired: false,
|
|
158
|
+
transformFunction: null
|
|
159
|
+
},
|
|
160
|
+
ariaDescribedby: {
|
|
161
|
+
classPropertyName: "ariaDescribedby",
|
|
162
|
+
publicName: "aria-describedby",
|
|
163
|
+
isSignal: true,
|
|
164
|
+
isRequired: false,
|
|
165
|
+
transformFunction: null
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
outputs: { value: "valueChange" },
|
|
169
|
+
host: { classAttribute: "ck-switch-host" },
|
|
170
|
+
providers: [provideCkValueAccessor(CkSwitch)],
|
|
171
|
+
queries: [{
|
|
172
|
+
propertyName: "hint",
|
|
173
|
+
first: true,
|
|
174
|
+
predicate: CkSwitchHint,
|
|
175
|
+
descendants: true,
|
|
176
|
+
isSignal: true
|
|
177
|
+
}],
|
|
178
|
+
viewQueries: [{
|
|
179
|
+
propertyName: "inputRef",
|
|
180
|
+
first: true,
|
|
181
|
+
predicate: ["input"],
|
|
182
|
+
descendants: true,
|
|
183
|
+
isSignal: true
|
|
184
|
+
}],
|
|
185
|
+
usesInheritance: true,
|
|
186
|
+
ngImport: i0,
|
|
187
|
+
template: `
|
|
188
|
+
<label class="ck-switch" [class]="modifierClasses()" [class.ck-switch--disabled]="isDisabled()">
|
|
189
|
+
<span class="ck-switch__control">
|
|
190
|
+
<input
|
|
191
|
+
#input
|
|
192
|
+
class="ck-switch__input"
|
|
193
|
+
type="checkbox"
|
|
194
|
+
role="switch"
|
|
195
|
+
[checked]="on()"
|
|
196
|
+
[disabled]="isDisabled()"
|
|
197
|
+
[attr.aria-label]="ariaLabel()"
|
|
198
|
+
[attr.aria-labelledby]="labelledby()"
|
|
199
|
+
[attr.aria-describedby]="describedby()"
|
|
200
|
+
(change)="onToggle()"
|
|
201
|
+
(blur)="markTouched()"
|
|
202
|
+
/>
|
|
203
|
+
<span class="ck-switch__track" aria-hidden="true">
|
|
204
|
+
<span class="ck-switch__thumb"></span>
|
|
205
|
+
</span>
|
|
206
|
+
</span>
|
|
207
|
+
<span class="ck-switch__body">
|
|
208
|
+
<span class="ck-switch__text" [id]="textId"><ng-content /></span>
|
|
209
|
+
<ng-content select="ck-switch-hint" />
|
|
210
|
+
</span>
|
|
211
|
+
</label>
|
|
212
|
+
`,
|
|
213
|
+
isInline: true,
|
|
214
|
+
styles: ["@layer ckui{.ck-switch-host{display:block}.ck-switch{--_ck-switch-border: 1px;--_ck-switch-gap: var(--ck-switch-thumb-gap, .1875rem);--_ck-switch-thumb-size: calc( var(--_ck-switch-height) - 2 * (var(--_ck-switch-border) + var(--_ck-switch-gap)) );display:flex;align-items:center;box-sizing:border-box;min-block-size:var(--_ck-switch-row);padding-block:var(--ck-space-1);color:var(--ck-color-fg);color-scheme:var(--ck-color-scheme);font-family:inherit;font-size:var(--_ck-switch-font-size);line-height:var(--ck-line-height-tight);cursor:pointer;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}.ck-switch--sm{--_ck-switch-row: var(--ck-control-height-sm);--_ck-switch-font-size: var(--ck-control-font-size-sm);--_ck-switch-width: 2.25rem;--_ck-switch-height: 1.25rem}.ck-switch--md{--_ck-switch-row: var(--ck-control-height-md);--_ck-switch-font-size: var(--ck-control-font-size-md);--_ck-switch-width: 2.75rem;--_ck-switch-height: 1.5rem}.ck-switch--lg{--_ck-switch-row: var(--ck-control-height-lg);--_ck-switch-font-size: var(--ck-control-font-size-lg);--_ck-switch-width: 3.25rem;--_ck-switch-height: 1.75rem}.ck-switch--xl{--_ck-switch-row: var(--ck-control-height-xl);--_ck-switch-font-size: var(--ck-control-font-size-xl);--_ck-switch-width: 4rem;--_ck-switch-height: 2.25rem}.ck-switch__control{position:relative;flex:none;box-sizing:border-box;inline-size:var(--_ck-switch-width);block-size:var(--_ck-switch-height)}.ck-switch__input{position:absolute;inset:0;box-sizing:border-box;inline-size:100%;block-size:100%;margin:0;padding:0;border:0;opacity:0;appearance:none;cursor:inherit}.ck-switch__track{position:absolute;inset:0;box-sizing:border-box;border:var(--_ck-switch-border) solid var(--ck-switch-border-color, var(--ck-color-control-border));border-radius:var(--ck-switch-radius, var(--ck-radius-full));background:var(--ck-switch-track, var(--ck-color-control));pointer-events:none;transition:background-color var(--ck-duration-normal) var(--ck-ease-standard),border-color var(--ck-duration-normal) var(--ck-ease-standard)}.ck-switch__thumb{position:absolute;inset-block-start:var(--_ck-switch-gap);inset-inline-start:var(--_ck-switch-gap);box-sizing:border-box;inline-size:var(--_ck-switch-thumb-size);block-size:var(--_ck-switch-thumb-size);border-radius:var(--ck-radius-full);background:var(--ck-switch-thumb, var(--ck-color-fg-muted));transition:inset-inline-start var(--ck-duration-normal) var(--ck-ease-standard),background-color var(--ck-duration-normal) var(--ck-ease-standard)}.ck-switch__input:checked+.ck-switch__track{border-color:var(--ck-switch-track-on, var(--ck-color-primary));background:var(--ck-switch-track-on, var(--ck-color-primary))}.ck-switch__input:checked+.ck-switch__track .ck-switch__thumb{inset-inline-start:calc(100% - var(--_ck-switch-thumb-size) - var(--_ck-switch-gap));background:var(--ck-switch-thumb-on, var(--ck-color-on-primary))}.ck-switch__body{display:block;flex:1 1 auto;min-inline-size:0;overflow-wrap:break-word}.ck-switch--label-start .ck-switch__body{order:-1}.ck-switch--label-start .ck-switch__body:has(>:not(:empty)){margin-inline-end:var(--ck-space-3)}.ck-switch--label-end .ck-switch__body:has(>:not(:empty)){margin-inline-start:var(--ck-space-3)}.ck-switch__text{display:block}.ck-switch:not(:has(.ck-switch__body>:not(:empty))){inline-size:fit-content;max-inline-size:100%}.ck-switch:not(:has(.ck-switch__body>:not(:empty))) .ck-switch__body{flex:none}.ck-switch-hint{display:block;margin-block-start:var(--ck-space-1);color:var(--ck-color-fg-muted);font-size:var(--ck-font-size-sm);line-height:var(--ck-line-height-normal)}.ck-switch__input:focus-visible+.ck-switch__track{outline:var(--ck-focus-ring);outline-offset:var(--ck-focus-ring-offset)}.ck-switch--disabled,.ck-switch:has(.ck-switch__input:disabled){color:var(--ck-color-fg-disabled);cursor:not-allowed}.ck-switch:has(.ck-switch__input:disabled) .ck-switch-hint{color:var(--ck-color-fg-disabled)}.ck-switch__input:disabled+.ck-switch__track{border-color:var(--ck-color-fg-disabled)}.ck-switch__input:disabled+.ck-switch__track .ck-switch__thumb{background:var(--ck-color-fg-disabled)}.ck-switch__input:disabled:checked+.ck-switch__track{background:var(--ck-color-fg-disabled)}.ck-switch__input:disabled:checked+.ck-switch__track .ck-switch__thumb{background:var(--ck-color-on-primary)}@media(prefers-reduced-motion:reduce){.ck-switch__track,.ck-switch__thumb{transition:none}}@media(forced-colors:active){.ck-switch__track{border-color:CanvasText;background:Canvas}.ck-switch__thumb{background:CanvasText}.ck-switch__input:checked+.ck-switch__track{border-color:Highlight;background:Highlight}.ck-switch__input:checked+.ck-switch__track .ck-switch__thumb{background:HighlightText}.ck-switch__input:focus-visible+.ck-switch__track{outline:var(--ck-focus-ring-width) solid Highlight;outline-offset:var(--ck-focus-ring-offset)}.ck-switch--disabled,.ck-switch--disabled .ck-switch-hint,.ck-switch:has(.ck-switch__input:disabled),.ck-switch:has(.ck-switch__input:disabled) .ck-switch-hint{color:GrayText}.ck-switch__input:disabled+.ck-switch__track,.ck-switch__input:disabled:checked+.ck-switch__track{border-color:GrayText;background:Canvas}.ck-switch__input:disabled+.ck-switch__track .ck-switch__thumb,.ck-switch__input:disabled:checked+.ck-switch__track .ck-switch__thumb{background:GrayText}}}\n"],
|
|
215
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
216
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
220
|
+
minVersion: "12.0.0",
|
|
221
|
+
version: "22.2.4",
|
|
222
|
+
ngImport: i0,
|
|
223
|
+
type: CkSwitch,
|
|
224
|
+
decorators: [{
|
|
225
|
+
type: Component,
|
|
226
|
+
args: [{
|
|
227
|
+
selector: "ck-switch",
|
|
228
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
229
|
+
encapsulation: ViewEncapsulation.None,
|
|
230
|
+
providers: [provideCkValueAccessor(CkSwitch)],
|
|
231
|
+
host: { class: "ck-switch-host" },
|
|
232
|
+
template: `
|
|
233
|
+
<label class="ck-switch" [class]="modifierClasses()" [class.ck-switch--disabled]="isDisabled()">
|
|
234
|
+
<span class="ck-switch__control">
|
|
235
|
+
<input
|
|
236
|
+
#input
|
|
237
|
+
class="ck-switch__input"
|
|
238
|
+
type="checkbox"
|
|
239
|
+
role="switch"
|
|
240
|
+
[checked]="on()"
|
|
241
|
+
[disabled]="isDisabled()"
|
|
242
|
+
[attr.aria-label]="ariaLabel()"
|
|
243
|
+
[attr.aria-labelledby]="labelledby()"
|
|
244
|
+
[attr.aria-describedby]="describedby()"
|
|
245
|
+
(change)="onToggle()"
|
|
246
|
+
(blur)="markTouched()"
|
|
247
|
+
/>
|
|
248
|
+
<span class="ck-switch__track" aria-hidden="true">
|
|
249
|
+
<span class="ck-switch__thumb"></span>
|
|
250
|
+
</span>
|
|
251
|
+
</span>
|
|
252
|
+
<span class="ck-switch__body">
|
|
253
|
+
<span class="ck-switch__text" [id]="textId"><ng-content /></span>
|
|
254
|
+
<ng-content select="ck-switch-hint" />
|
|
255
|
+
</span>
|
|
256
|
+
</label>
|
|
257
|
+
`,
|
|
258
|
+
styles: ["@layer ckui{.ck-switch-host{display:block}.ck-switch{--_ck-switch-border: 1px;--_ck-switch-gap: var(--ck-switch-thumb-gap, .1875rem);--_ck-switch-thumb-size: calc( var(--_ck-switch-height) - 2 * (var(--_ck-switch-border) + var(--_ck-switch-gap)) );display:flex;align-items:center;box-sizing:border-box;min-block-size:var(--_ck-switch-row);padding-block:var(--ck-space-1);color:var(--ck-color-fg);color-scheme:var(--ck-color-scheme);font-family:inherit;font-size:var(--_ck-switch-font-size);line-height:var(--ck-line-height-tight);cursor:pointer;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}.ck-switch--sm{--_ck-switch-row: var(--ck-control-height-sm);--_ck-switch-font-size: var(--ck-control-font-size-sm);--_ck-switch-width: 2.25rem;--_ck-switch-height: 1.25rem}.ck-switch--md{--_ck-switch-row: var(--ck-control-height-md);--_ck-switch-font-size: var(--ck-control-font-size-md);--_ck-switch-width: 2.75rem;--_ck-switch-height: 1.5rem}.ck-switch--lg{--_ck-switch-row: var(--ck-control-height-lg);--_ck-switch-font-size: var(--ck-control-font-size-lg);--_ck-switch-width: 3.25rem;--_ck-switch-height: 1.75rem}.ck-switch--xl{--_ck-switch-row: var(--ck-control-height-xl);--_ck-switch-font-size: var(--ck-control-font-size-xl);--_ck-switch-width: 4rem;--_ck-switch-height: 2.25rem}.ck-switch__control{position:relative;flex:none;box-sizing:border-box;inline-size:var(--_ck-switch-width);block-size:var(--_ck-switch-height)}.ck-switch__input{position:absolute;inset:0;box-sizing:border-box;inline-size:100%;block-size:100%;margin:0;padding:0;border:0;opacity:0;appearance:none;cursor:inherit}.ck-switch__track{position:absolute;inset:0;box-sizing:border-box;border:var(--_ck-switch-border) solid var(--ck-switch-border-color, var(--ck-color-control-border));border-radius:var(--ck-switch-radius, var(--ck-radius-full));background:var(--ck-switch-track, var(--ck-color-control));pointer-events:none;transition:background-color var(--ck-duration-normal) var(--ck-ease-standard),border-color var(--ck-duration-normal) var(--ck-ease-standard)}.ck-switch__thumb{position:absolute;inset-block-start:var(--_ck-switch-gap);inset-inline-start:var(--_ck-switch-gap);box-sizing:border-box;inline-size:var(--_ck-switch-thumb-size);block-size:var(--_ck-switch-thumb-size);border-radius:var(--ck-radius-full);background:var(--ck-switch-thumb, var(--ck-color-fg-muted));transition:inset-inline-start var(--ck-duration-normal) var(--ck-ease-standard),background-color var(--ck-duration-normal) var(--ck-ease-standard)}.ck-switch__input:checked+.ck-switch__track{border-color:var(--ck-switch-track-on, var(--ck-color-primary));background:var(--ck-switch-track-on, var(--ck-color-primary))}.ck-switch__input:checked+.ck-switch__track .ck-switch__thumb{inset-inline-start:calc(100% - var(--_ck-switch-thumb-size) - var(--_ck-switch-gap));background:var(--ck-switch-thumb-on, var(--ck-color-on-primary))}.ck-switch__body{display:block;flex:1 1 auto;min-inline-size:0;overflow-wrap:break-word}.ck-switch--label-start .ck-switch__body{order:-1}.ck-switch--label-start .ck-switch__body:has(>:not(:empty)){margin-inline-end:var(--ck-space-3)}.ck-switch--label-end .ck-switch__body:has(>:not(:empty)){margin-inline-start:var(--ck-space-3)}.ck-switch__text{display:block}.ck-switch:not(:has(.ck-switch__body>:not(:empty))){inline-size:fit-content;max-inline-size:100%}.ck-switch:not(:has(.ck-switch__body>:not(:empty))) .ck-switch__body{flex:none}.ck-switch-hint{display:block;margin-block-start:var(--ck-space-1);color:var(--ck-color-fg-muted);font-size:var(--ck-font-size-sm);line-height:var(--ck-line-height-normal)}.ck-switch__input:focus-visible+.ck-switch__track{outline:var(--ck-focus-ring);outline-offset:var(--ck-focus-ring-offset)}.ck-switch--disabled,.ck-switch:has(.ck-switch__input:disabled){color:var(--ck-color-fg-disabled);cursor:not-allowed}.ck-switch:has(.ck-switch__input:disabled) .ck-switch-hint{color:var(--ck-color-fg-disabled)}.ck-switch__input:disabled+.ck-switch__track{border-color:var(--ck-color-fg-disabled)}.ck-switch__input:disabled+.ck-switch__track .ck-switch__thumb{background:var(--ck-color-fg-disabled)}.ck-switch__input:disabled:checked+.ck-switch__track{background:var(--ck-color-fg-disabled)}.ck-switch__input:disabled:checked+.ck-switch__track .ck-switch__thumb{background:var(--ck-color-on-primary)}@media(prefers-reduced-motion:reduce){.ck-switch__track,.ck-switch__thumb{transition:none}}@media(forced-colors:active){.ck-switch__track{border-color:CanvasText;background:Canvas}.ck-switch__thumb{background:CanvasText}.ck-switch__input:checked+.ck-switch__track{border-color:Highlight;background:Highlight}.ck-switch__input:checked+.ck-switch__track .ck-switch__thumb{background:HighlightText}.ck-switch__input:focus-visible+.ck-switch__track{outline:var(--ck-focus-ring-width) solid Highlight;outline-offset:var(--ck-focus-ring-offset)}.ck-switch--disabled,.ck-switch--disabled .ck-switch-hint,.ck-switch:has(.ck-switch__input:disabled),.ck-switch:has(.ck-switch__input:disabled) .ck-switch-hint{color:GrayText}.ck-switch__input:disabled+.ck-switch__track,.ck-switch__input:disabled:checked+.ck-switch__track{border-color:GrayText;background:Canvas}.ck-switch__input:disabled+.ck-switch__track .ck-switch__thumb,.ck-switch__input:disabled:checked+.ck-switch__track .ck-switch__thumb{background:GrayText}}}\n"]
|
|
259
|
+
}]
|
|
260
|
+
}],
|
|
261
|
+
ctorParameters: () => [],
|
|
262
|
+
propDecorators: {
|
|
263
|
+
value: [{
|
|
264
|
+
type: i0.Input,
|
|
265
|
+
args: [{
|
|
266
|
+
isSignal: true,
|
|
267
|
+
alias: "value",
|
|
268
|
+
required: false
|
|
269
|
+
}]
|
|
270
|
+
}, {
|
|
271
|
+
type: i0.Output,
|
|
272
|
+
args: ["valueChange"]
|
|
273
|
+
}],
|
|
274
|
+
size: [{
|
|
275
|
+
type: i0.Input,
|
|
276
|
+
args: [{
|
|
277
|
+
isSignal: true,
|
|
278
|
+
alias: "size",
|
|
279
|
+
required: false
|
|
280
|
+
}]
|
|
281
|
+
}],
|
|
282
|
+
labelPosition: [{
|
|
283
|
+
type: i0.Input,
|
|
284
|
+
args: [{
|
|
285
|
+
isSignal: true,
|
|
286
|
+
alias: "labelPosition",
|
|
287
|
+
required: false
|
|
288
|
+
}]
|
|
289
|
+
}],
|
|
290
|
+
ariaLabel: [{
|
|
291
|
+
type: i0.Input,
|
|
292
|
+
args: [{
|
|
293
|
+
isSignal: true,
|
|
294
|
+
alias: "aria-label",
|
|
295
|
+
required: false
|
|
296
|
+
}]
|
|
297
|
+
}],
|
|
298
|
+
ariaLabelledby: [{
|
|
299
|
+
type: i0.Input,
|
|
300
|
+
args: [{
|
|
301
|
+
isSignal: true,
|
|
302
|
+
alias: "aria-labelledby",
|
|
303
|
+
required: false
|
|
304
|
+
}]
|
|
305
|
+
}],
|
|
306
|
+
ariaDescribedby: [{
|
|
307
|
+
type: i0.Input,
|
|
308
|
+
args: [{
|
|
309
|
+
isSignal: true,
|
|
310
|
+
alias: "aria-describedby",
|
|
311
|
+
required: false
|
|
312
|
+
}]
|
|
313
|
+
}],
|
|
314
|
+
inputRef: [{
|
|
315
|
+
type: i0.ViewChild,
|
|
316
|
+
args: ["input", { isSignal: true }]
|
|
317
|
+
}],
|
|
318
|
+
hint: [{
|
|
319
|
+
type: i0.ContentChild,
|
|
320
|
+
args: [i0.forwardRef(() => CkSwitchHint), { isSignal: true }]
|
|
321
|
+
}]
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
const CK_SWITCH_IMPORTS = [CkSwitch, CkSwitchHint];
|
|
325
|
+
export { CK_SWITCH_IMPORTS, CkSwitch, CkSwitchHint };
|
|
326
|
+
|
|
327
|
+
//# sourceMappingURL=ckui-core-switch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ckui-core-switch.mjs","names":[],"sources":["../../../../projects/core/switch/switch-hint.ts","../../../../projects/core/switch/switch.ts","../../../../projects/core/switch/index.ts"],"sourcesContent":["import { Directive, input } from '@angular/core';\nimport { createCkId } from '@ckui/core/internal';\n\n/**\n * Help text under the label of a `ck-switch`. It is part of the row, so a click on it toggles the\n * switch, and the switch's input is described by it. Give it an `id` to choose the id.\n */\n@Directive({\n selector: 'ck-switch-hint',\n host: { class: 'ck-switch-hint', '[attr.id]': 'id()' },\n})\nexport class CkSwitchHint {\n readonly id = input(createCkId('ck-switch-hint'));\n}\n","import {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n ModelSignal,\n PLATFORM_ID,\n Renderer2,\n ViewEncapsulation,\n afterNextRender,\n computed,\n contentChild,\n inject,\n input,\n model,\n viewChild,\n} from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport { CK_CONFIG, CkSize } from '@ckui/core';\nimport {\n CkValueControl,\n createCkId,\n hasAccessibleName,\n provideCkValueAccessor,\n} from '@ckui/core/internal';\nimport { CkSwitchHint } from './switch-hint';\n\ndeclare const ngDevMode: unknown;\n\n/**\n * An on/off switch with a label. It is one native `<input type=\"checkbox\" role=\"switch\">`, so the\n * checked state, Space and a click on the whole row (label text, hint and switch) work natively.\n * The value is a `boolean`; `null` or `undefined` from a form counts as off.\n *\n * The projected text names the switch; a `ck-switch-hint` describes it. Without visible text, give\n * `ck-switch` an `aria-label` or `aria-labelledby`: they are inputs and move onto the input element.\n */\n@Component({\n selector: 'ck-switch',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n providers: [provideCkValueAccessor(CkSwitch)],\n host: { class: 'ck-switch-host' },\n template: `\n <label class=\"ck-switch\" [class]=\"modifierClasses()\" [class.ck-switch--disabled]=\"isDisabled()\">\n <span class=\"ck-switch__control\">\n <input\n #input\n class=\"ck-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [checked]=\"on()\"\n [disabled]=\"isDisabled()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-labelledby]=\"labelledby()\"\n [attr.aria-describedby]=\"describedby()\"\n (change)=\"onToggle()\"\n (blur)=\"markTouched()\"\n />\n <span class=\"ck-switch__track\" aria-hidden=\"true\">\n <span class=\"ck-switch__thumb\"></span>\n </span>\n </span>\n <span class=\"ck-switch__body\">\n <span class=\"ck-switch__text\" [id]=\"textId\"><ng-content /></span>\n <ng-content select=\"ck-switch-hint\" />\n </span>\n </label>\n `,\n styleUrl: './switch.css',\n})\nexport class CkSwitch extends CkValueControl<boolean> {\n /** On or off. `null` or `undefined` from a form counts as off. */\n override readonly value: ModelSignal<boolean> = model(false);\n /** `undefined` uses the size from `provideCkui`. */\n readonly size = input<CkSize | undefined>(undefined);\n /** Where the text goes: `start` puts it first and the switch at the end of the row. */\n readonly labelPosition = input<'start' | 'end'>('start');\n /** The accessible name for a switch without visible text. Moves from the host to the input. */\n readonly ariaLabel = input<string | null>(null, { alias: 'aria-label' });\n /** The ids of the elements that name the input. Moves from the host to the input. */\n readonly ariaLabelledby = input<string | null>(null, { alias: 'aria-labelledby' });\n /** More ids that describe the input, after the hint. Moves from the host to the input. */\n readonly ariaDescribedby = input<string | null>(null, { alias: 'aria-describedby' });\n\n private readonly config = inject(CK_CONFIG);\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n private readonly inputRef = viewChild.required<ElementRef<HTMLInputElement>>('input');\n private readonly hint = contentChild(CkSwitchHint);\n\n protected readonly textId = createCkId('ck-switch-text');\n\n protected readonly on = computed(() => this.value() === true);\n\n protected readonly modifierClasses = computed(\n () =>\n `ck-switch--${this.size() ?? this.config.size} ck-switch--label-${this.labelPosition() === 'end' ? 'end' : 'start'}`,\n );\n\n /** The consumer's names win; otherwise the projected text names the input. */\n protected readonly labelledby = computed(\n () => this.ariaLabelledby() ?? (this.ariaLabel() ? null : this.textId),\n );\n\n protected readonly describedby = computed(() => {\n const ids = [this.hint()?.id(), this.ariaDescribedby()].filter((id) => !!id);\n return ids.length > 0 ? ids.join(' ') : null;\n });\n\n constructor() {\n super();\n // The names are inputs here, so the host must not also keep them as a (role-less) attribute.\n const renderer = inject(Renderer2);\n renderer.removeAttribute(this.element, 'aria-label');\n renderer.removeAttribute(this.element, 'aria-labelledby');\n renderer.removeAttribute(this.element, 'aria-describedby');\n\n if (typeof ngDevMode !== 'undefined' && ngDevMode && isPlatformBrowser(inject(PLATFORM_ID))) {\n let destroyed = false;\n inject(DestroyRef).onDestroy(() => (destroyed = true));\n afterNextRender(() => {\n if (\n !destroyed &&\n !hasAccessibleName(this.inputRef().nativeElement, { title: false, text: false })\n ) {\n console.warn(\n '[ckui] ck-switch has no accessible name. Add text, or an aria-label or aria-labelledby.',\n this.element,\n );\n }\n });\n }\n }\n\n protected onToggle(): void {\n const input = this.inputRef().nativeElement;\n this.commit(input.checked);\n // A refused change (disabled in between) puts the native state back.\n input.checked = this.on();\n }\n}\n","import { CkSwitch } from './switch';\nimport { CkSwitchHint } from './switch-hint';\n\nexport { CkSwitch } from './switch';\nexport { CkSwitchHint } from './switch-hint';\n\n/** Everything a template needs for a switch: `imports: [CK_SWITCH_IMPORTS]`. */\nexport const CK_SWITCH_IMPORTS = [CkSwitch, CkSwitchHint] as const;\n"],"mappings":";;;;;AAWA,IAAa,eAAb,MAAa,aAAY;CACd,KAAK,MAAM,WAAW,gBAAgB,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CADtC,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAY,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAZ,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAY,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,IAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,MAAA;GAAA,YAAA,EAAA,WAAA,OAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;CAAA,CAAA;;AAAZ,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAY,YAAA,CAAA;EAJxB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,MAAM;IAAE,OAAO;IAAkB,aAAa;GAAM;EACrD,CAAA;;;;;;;;;;;AC6DD,IAAa,WAAb,MAAa,iBAAiB,eAAuB;CAEjC,QAA8B,MAAM,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAEnD,OAAO,MAA0B,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA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