@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.
Files changed (41) hide show
  1. package/README.md +337 -4
  2. package/fesm2022/ckui-core-badge.mjs +169 -0
  3. package/fesm2022/ckui-core-badge.mjs.map +1 -0
  4. package/fesm2022/ckui-core-chip.mjs +300 -0
  5. package/fesm2022/ckui-core-chip.mjs.map +1 -0
  6. package/fesm2022/ckui-core-dialog.mjs +18 -286
  7. package/fesm2022/ckui-core-dialog.mjs.map +1 -1
  8. package/fesm2022/ckui-core-drawer.mjs +342 -0
  9. package/fesm2022/ckui-core-drawer.mjs.map +1 -0
  10. package/fesm2022/ckui-core-internal-dialog.mjs +296 -0
  11. package/fesm2022/ckui-core-internal-dialog.mjs.map +1 -0
  12. package/fesm2022/ckui-core-internal-overlay.mjs +479 -0
  13. package/fesm2022/ckui-core-internal-overlay.mjs.map +1 -0
  14. package/fesm2022/ckui-core-internal.mjs +2 -463
  15. package/fesm2022/ckui-core-internal.mjs.map +1 -1
  16. package/fesm2022/ckui-core-progress.mjs +165 -0
  17. package/fesm2022/ckui-core-progress.mjs.map +1 -0
  18. package/fesm2022/ckui-core-segmented.mjs +184 -8
  19. package/fesm2022/ckui-core-segmented.mjs.map +1 -1
  20. package/fesm2022/ckui-core-stepper.mjs +842 -0
  21. package/fesm2022/ckui-core-stepper.mjs.map +1 -0
  22. package/fesm2022/ckui-core-switch.mjs +327 -0
  23. package/fesm2022/ckui-core-switch.mjs.map +1 -0
  24. package/fesm2022/ckui-core-tabs.mjs +678 -0
  25. package/fesm2022/ckui-core-tabs.mjs.map +1 -0
  26. package/fesm2022/ckui-core.mjs +2 -0
  27. package/fesm2022/ckui-core.mjs.map +1 -1
  28. package/package.json +37 -1
  29. package/types/ckui-core-badge.d.ts +44 -0
  30. package/types/ckui-core-chip.d.ts +62 -0
  31. package/types/ckui-core-dialog.d.ts +5 -40
  32. package/types/ckui-core-drawer.d.ts +153 -0
  33. package/types/ckui-core-internal-dialog.d.ts +102 -0
  34. package/types/ckui-core-internal-overlay.d.ts +83 -0
  35. package/types/ckui-core-internal.d.ts +2 -75
  36. package/types/ckui-core-progress.d.ts +43 -0
  37. package/types/ckui-core-segmented.d.ts +26 -0
  38. package/types/ckui-core-stepper.d.ts +186 -0
  39. package/types/ckui-core-switch.d.ts +90 -0
  40. package/types/ckui-core-tabs.d.ts +212 -0
  41. package/types/ckui-core.d.ts +2 -0
package/README.md CHANGED
@@ -80,6 +80,54 @@ Global element styles: your own unlayered rules such as `a { color: … }` or
80
80
  `a:hover { text-decoration: … }` beat the layered button, by design. Scope them with
81
81
  `a:not(.ck-button)`, or put resets in a layer declared before ckui: `@layer reset, ckui;`.
82
82
 
83
+ ## Chip
84
+
85
+ ```ts
86
+ import { CK_CHIP_IMPORTS } from '@ckui/core/chip';
87
+ ```
88
+
89
+ ```html
90
+ <ck-chip-group aria-label="Category">
91
+ <button ckChip [(selected)]="endurance">Endurance</button>
92
+ <button ckChip [(selected)]="vo2">
93
+ <svg
94
+ ckChipIcon
95
+ viewBox="0 0 16 16"
96
+ fill="none"
97
+ stroke="currentColor"
98
+ stroke-width="2"
99
+ stroke-linecap="round"
100
+ stroke-linejoin="round"
101
+ >
102
+ <path d="M8 13.5L3.4 8.9a3 3 0 014.6-3.8 3 3 0 014.6 3.8L8 13.5z" />
103
+ </svg>
104
+ VO2max
105
+ </button>
106
+ </ck-chip-group>
107
+ ```
108
+
109
+ `ckChip` turns a native `<button>` into a compact toggle for filters (`CkChip`, `CkChipIcon`, `CkChipGroup`;
110
+ `CK_CHIP_IMPORTS` is all three). Inputs: `selected` (a `model<boolean>`, `false`; use `[(selected)]`; a click toggles it
111
+ and emits, a programmatic change never emits), `size` (`sm`, the default, `md`, `lg`, `xl`; an unknown value falls back
112
+ to `sm`) and `disabled` (the native attribute; `<fieldset disabled>` blocks and styles the chip the same). The button
113
+ keeps its own `type` (default `button`), `tabindex`, `aria-*` and classes; the chip owns `aria-pressed`. A selected chip
114
+ shows a check before the label (it replaces a projected `ckChipIcon` while on), so the state is never colour alone.
115
+ The label is cut with an ellipsis when it does not fit.
116
+
117
+ `ck-chip-group` is a `role="group"` flex row that wraps; give it an `aria-label` or `aria-labelledby`. Development
118
+ builds warn about a chip without a name and a group without one.
119
+
120
+ Keyboard: Tab moves between chips, Space or Enter toggles the focused chip. Height follows the control-height tokens
121
+ (2rem at `sm`, 2.75rem for `sm` and `md` under a coarse pointer, 3.75rem at `xl`). In forced colors a selected chip is
122
+ `Highlight`; motion stops under `prefers-reduced-motion`. Component tokens: `--ck-chip-bg` (default
123
+ `--ck-color-control`), `--ck-chip-fg` (`--ck-color-fg`), `--ck-chip-border-color` (`--ck-color-control-border`),
124
+ `--ck-chip-selected-bg` (`--ck-color-primary`), `--ck-chip-selected-fg` (`--ck-color-on-primary`), `--ck-chip-radius`
125
+ (`--ck-radius-full`) and `--ck-chip-group-gap` (`--ck-space-2`). Keep the selected fill 3:1 from the unselected one.
126
+
127
+ Global element styles: an unlayered `button { border: …; background: … }` or `svg { inline-size: 100% }` beats the
128
+ layered chip. Keep them off the chip (`button:not(.ck-chip)`) or put resets in a layer declared before ckui:
129
+ `@layer reset, ckui;`.
130
+
83
131
  ## Field and input
84
132
 
85
133
  ```ts
@@ -145,15 +193,238 @@ text, a direct `svg` child (an icon, shown before the text), or both; font-icon
145
193
 
146
194
  The group is as tall as the control height of its size and every segment is that tall to hit (44px for
147
195
  `sm` and `md` under a coarse pointer, 60px at `xl`). The selected segment is marked by a raised indicator
148
- with its own 3:1 border, not by colour alone. Labels that do not fit are cut with an ellipsis, the full
149
- text stays in the accessible name. Component tokens: `--ck-segmented-bg`, `--ck-segmented-border-color`,
150
- `--ck-segmented-fg`, `--ck-segmented-indicator-bg`, `--ck-segmented-indicator-fg`,
151
- `--ck-segmented-radius` and `--ck-segmented-padding`.
196
+ with its own 3:1 border, not by colour alone, and it slides to a new selection over
197
+ `--ck-duration-normal` (not under reduced motion, and not when it first appears). A segment is as wide
198
+ as an equal share of the group or its label (with icon and padding), whichever is larger, so a long
199
+ label never cuts a short neighbour's share: its column grows and the others shrink. Only when the
200
+ labels at their natural width cannot fit together does the group switch to equal columns and cut the
201
+ labels with an ellipsis (the full text stays in the accessible name); it never overflows its
202
+ container, and goes back to content widths as soon as there is room, also when only a label, the size or a loading font changes. Component tokens:
203
+ `--ck-segmented-bg`, `--ck-segmented-border-color`, `--ck-segmented-fg`,
204
+ `--ck-segmented-indicator-bg`, `--ck-segmented-indicator-fg`, `--ck-segmented-radius`,
205
+ `--ck-segmented-padding` (the gap around the indicator) and `--ck-segmented-padding-inline`
206
+ (horizontal padding of a segment, for a tighter control; the size's control padding by default).
152
207
 
153
208
  Global element styles: a global `:focus-visible { outline: … }` beats the layered control and draws a
154
209
  second ring on the segment itself. Keep it off the segments (`:focus-visible:not(.ck-segment)`) or put
155
210
  resets in a layer declared before ckui: `@layer reset, ckui;`.
156
211
 
212
+ ## Badge
213
+
214
+ ```ts
215
+ import { CK_BADGE_IMPORTS } from '@ckui/core/badge';
216
+ ```
217
+
218
+ ```html
219
+ <ck-badge tone="success" dot>Connected</ck-badge>
220
+ <ck-badge tone="danger">
221
+ <svg
222
+ ckBadgeIcon
223
+ viewBox="0 0 16 16"
224
+ fill="none"
225
+ stroke="currentColor"
226
+ stroke-width="2"
227
+ stroke-linecap="round"
228
+ stroke-linejoin="round"
229
+ >
230
+ <path d="M8 3v6M8 12.5v.5" />
231
+ </svg>
232
+ Upload failed
233
+ </ck-badge>
234
+ ```
235
+
236
+ `ck-badge` is a small, non-interactive status pill (`CkBadge`, `CkBadgeIcon`). Inputs: `tone` (`neutral`
237
+ default, `success`, `warning`, `danger`), `dot` (a leading dot in the text colour) and `size` (`md`, a 1.5rem
238
+ pill, default; `sm`, 1.25rem, for dense lists). `ckBadgeIcon` on a projected `svg` makes it the leading icon,
239
+ drawn one em wide and hidden from assistive technology. The badge never wraps: text that does not fit its
240
+ container is cut with an ellipsis.
241
+
242
+ A badge has no role and is not a live region. The text has to state the status, since a dot, an icon or a
243
+ colour alone says nothing to a screen reader, and development builds warn about a badge without text. When a
244
+ change must be heard, announce it yourself, for instance in a `role="status"` element or a toast. Component
245
+ tokens: `--ck-badge-bg`, `--ck-badge-fg`, `--ck-badge-dot` (the dot's own colour, default the text colour; a coloured dot is decoration, so the text must still state the status) and `--ck-badge-radius` (they apply to every tone; scope them by `.ck-badge--<tone>` to restyle one tone).
246
+
247
+ Global element styles: a global rule such as `span { overflow: visible }` (no truncation) or
248
+ `svg { inline-size: 100% }` (a huge icon) beats the layered badge. Scope it away from the badge or put
249
+ resets in a layer declared before ckui: `@layer reset, ckui;`.
250
+
251
+ ## Progress
252
+
253
+ ```ts
254
+ import { CkProgress } from '@ckui/core/progress';
255
+ ```
256
+
257
+ ```html
258
+ <ck-progress aria-label="Upload" [value]="percent()" />
259
+ <ck-progress
260
+ aria-label="Workout"
261
+ [value]="step()"
262
+ [max]="7"
263
+ [valueText]="'Step ' + step() + ' of 7'"
264
+ />
265
+ <ck-progress aria-label="Connecting" [value]="null" />
266
+ ```
267
+
268
+ `ck-progress` is a horizontal progress bar (`CkProgress`, `role="progressbar"`). Inputs: `value` (a number
269
+ from 0 to `max`; below 0 counts as 0 and above `max` as `max`; `null`, `undefined`, `NaN` or any non-number
270
+ shows the indeterminate bar without `aria-valuenow`), `max` (default 100; anything that is not a finite number
271
+ above 0 counts as 100) and `valueText` (`aria-valuetext`, e.g. "Step 2 of 7"). The bar needs an `aria-label`
272
+ or `aria-labelledby` (development builds warn without one) and is not a live region: announce milestones
273
+ yourself.
274
+
275
+ The fill grows with a transform from the start edge (mirrored in right-to-left text) over
276
+ `--ck-duration-normal`, and not at all under `prefers-reduced-motion`, where the indeterminate bar is a still,
277
+ half-width fill. In forced colors the track gets an outline and the fill is `Highlight`. Component tokens:
278
+ `--ck-progress-track`, `--ck-progress-fill`, `--ck-progress-thickness` and `--ck-progress-radius`; keep the
279
+ fill at 3:1 against the track.
280
+
281
+ ## Stepper
282
+
283
+ ```ts
284
+ import { CkStepper } from '@ckui/core/stepper';
285
+ ```
286
+
287
+ ```html
288
+ <ck-stepper aria-label="FTP" unit="W" [min]="50" [max]="600" [step]="5" [(value)]="ftp" />
289
+ <ck-stepper
290
+ aria-label="FTP"
291
+ decrementLabel="FTP minus 5"
292
+ incrementLabel="FTP plus 5"
293
+ [formControl]="ftp"
294
+ />
295
+ ```
296
+
297
+ `ck-stepper` is a number field with a minus and a plus button (`CkStepper`, a form control for Reactive Forms,
298
+ `ngModel` and Signal Forms). The value is a `number` or `null`. Inputs: `min`, `max`, `step` (default 1, counted
299
+ from `min`; it also sets the fraction digits), `largeStep` (Page Up/Down, default 10 steps), `unit` (text after the
300
+ value, read as part of the value text: "250 W"), `size`, `readonly`, `disabled`, `decrementLabel` and
301
+ `incrementLabel` (per-instance names for the buttons; the defaults come from the labels token).
302
+
303
+ The value is a real text input with `role="spinbutton"` and the only tab stop; the buttons are outside the tab
304
+ order. Name it with `aria-label` or `aria-labelledby` on `ck-stepper` (they are inputs and move onto the input
305
+ element, like `aria-describedby` for a hint or an error; bind them as `[aria-label]`) or wrap it in a `<label>`;
306
+ development builds warn without a name. The input uses `inputmode="decimal"`, and `text` when `min` is below 0. Arrow
307
+ Up/Down step, Page Up/Down move by `largeStep`, Home/End jump to `min`/`max` when set. Typed text is read on Enter or
308
+ blur: it is parsed with the locale (`LOCALE_ID`; both `.` and `,` count as a decimal mark), clamped, snapped to the
309
+ step, and text that is no number goes back to the last value. An empty field is `null`; from `null` the first arrow
310
+ or button press starts at `min`, else at 0. A held button repeats after 400 ms, every 80 ms, and by five steps after
311
+ two seconds; it stops on release, on leaving the button and at a limit. A `min` above `max` pins the value to `min`,
312
+ and a `step` that is 0, negative or not a number counts as 1; development builds warn about both. `(valueChange)`
313
+ fires once per user change and never for a programmatic write.
314
+
315
+ The buttons are squares of the control height (44px or more on a coarse pointer, 60px at `xl`). Component tokens:
316
+ `--ck-stepper-bg`, `--ck-stepper-border-color`, `--ck-stepper-radius` and `--ck-stepper-value-width` (default: as
317
+ wide as the formatted `min` and `max`).
318
+
319
+ Global element styles: an unlayered `button { border: … }` or `input { … }` beats the layered parts, and a global
320
+ `:focus-visible { outline: … }` draws a second ring on the input. Keep them off the stepper
321
+ (`button:not(.ck-stepper__button)`) or put resets in a layer declared before ckui: `@layer reset, ckui;`.
322
+
323
+ ## Switch
324
+
325
+ ```ts
326
+ import { CK_SWITCH_IMPORTS } from '@ckui/core/switch';
327
+ ```
328
+
329
+ ```html
330
+ <ck-switch [(value)]="autoUpload">
331
+ Auto-upload
332
+ <ck-switch-hint>Uploads every finished ride to Strava.</ck-switch-hint>
333
+ </ck-switch>
334
+ <ck-switch aria-label="Audio cues" labelPosition="end" [formControl]="audio" />
335
+ ```
336
+
337
+ `ck-switch` is an on/off switch with a label (`CkSwitch`, a form control for Reactive Forms, `ngModel` and Signal
338
+ Forms; `CK_SWITCH_IMPORTS` is `[CkSwitch, CkSwitchHint]`). The value is a `boolean`, off by default; `null` from a
339
+ form counts as off. Inputs: `size` (`sm`, `md`, `lg`, `xl`, default from `provideCkui`), `disabled`, `labelPosition`
340
+ (`start`, the default, puts the text first and the switch at the end of the row; `end` puts the switch first) and
341
+ `aria-label` / `aria-labelledby` / `aria-describedby` (inputs that move onto the input element; bind them as
342
+ `[aria-label]`). `(valueChange)` fires once per user change and never for a programmatic write; the control is
343
+ touched when focus leaves it.
344
+
345
+ The row is a `<label>` around one native `<input type="checkbox" role="switch">`, so the checked state, Space and a
346
+ click on the text, the hint or the switch all work natively. The projected text names the switch; a
347
+ `<ck-switch-hint>` is its description (it takes an `id`, else it gets one) and is part of the row, so a click on it
348
+ toggles too. A switch without visible text needs an `aria-label` or `aria-labelledby`; development builds warn
349
+ otherwise. The state is shown by the thumb's position, never by colour alone, and the thumb moves to the other side
350
+ in right-to-left text. `<fieldset disabled>` blocks and styles the switch like `disabled`.
351
+
352
+ The row is at least the control height of its size (44px or more on a coarse pointer, 60px at `xl`); the track is
353
+ 2.25 × 1.25rem at `sm`, 2.75 × 1.5rem at `md`, 3.25 × 1.75rem at `lg` and 4 × 2.25rem at `xl`. Component tokens:
354
+ `--ck-switch-track` (off, default `--ck-color-control`), `--ck-switch-track-on` (default `--ck-color-primary`),
355
+ `--ck-switch-thumb` (off, default `--ck-color-fg-muted`), `--ck-switch-thumb-on` (default `--ck-color-on-primary`),
356
+ `--ck-switch-border-color` (off track, default `--ck-color-control-border`), `--ck-switch-radius` and
357
+ `--ck-switch-thumb-gap`. Keep the on track 3:1 from the off track. In forced colors the track border and thumb are
358
+ `CanvasText` and the on track is `Highlight`; motion stops under `prefers-reduced-motion`.
359
+
360
+ Global element styles: an unlayered `input { … }` or `label { … }` beats the layered parts. Keep them off the switch
361
+ (`input:not(.ck-switch__input)`) or put resets in a layer declared before ckui: `@layer reset, ckui;`.
362
+
363
+ ## Tabs
364
+
365
+ ```ts
366
+ import { CK_TABS_IMPORTS } from '@ckui/core/tabs';
367
+ ```
368
+
369
+ ```html
370
+ <ck-tabs [(value)]="source">
371
+ <ck-tab-list aria-label="Workout source">
372
+ <ck-tab value="predefined">Predefined</ck-tab>
373
+ <ck-tab value="mine">Mine</ck-tab>
374
+ <ck-tab value="shared">Shared</ck-tab>
375
+ </ck-tab-list>
376
+ <ck-tab-panel>One list for the selected source.</ck-tab-panel>
377
+ </ck-tabs>
378
+ ```
379
+
380
+ `ck-tabs` switches between views on one page: underlined tabs and the panel of the selected one. It is not a
381
+ form control and not navigation between pages (`CkTabs`, `CkTabList`, `CkTab`, `CkTabPanel`, `CkTabContent`;
382
+ `CK_TABS_IMPORTS` is all five). Inputs of `ck-tabs`: `value` (two-way; `null` shows the first enabled tab),
383
+ `activation` (`auto`, the default, selects a tab as soon as the arrow keys focus it; `manual` waits for Enter or
384
+ Space), `size` (`sm`, `md`, `lg`, `xl`, default from `provideCkui`) and `fullWidth` (the tabs share the row
385
+ equally). `ck-tab` takes a required `value`, `disabled` and `id`; `ck-tab-panel` takes an optional `value` and
386
+ `id`. `(valueChange)` fires when the user picks a tab.
387
+
388
+ A panel with a `value` belongs to the tab of that value and is hidden (`hidden` attribute, content kept) unless
389
+ that tab is selected; a development build warns about a panel whose value matches no tab. A panel without a
390
+ `value` is shared: every tab points at it with `aria-controls`, and it is labelled by whichever tab is selected.
391
+ Put an `<ng-template ckTabContent>` inside a panel to create its content only while the panel is shown and destroy
392
+ it when it is hidden. Lazy content in a shared panel lives on across tab switches: the panel stays shown, so it is
393
+ created once.
394
+
395
+ A `value` of `null`, one no tab has, or one that names a disabled tab shows the first enabled tab. That is only
396
+ reflected: the model is written when the user picks a tab, never for the implicit default, and tabs may be added
397
+ and removed at any time (removing the selected one shows the first tab). Values are compared with `Object.is`
398
+ and must not be `null`.
399
+
400
+ The row follows the WAI-ARIA tabs pattern: `role="tablist"` (it needs an `aria-label` or `aria-labelledby`;
401
+ development builds warn without one), `role="tab"` with `aria-selected`, `aria-controls` and a roving `tabindex`
402
+ (one tab stop, on the selected tab), and panels with `role="tabpanel"`, `aria-labelledby` and `tabindex="0"`.
403
+ Keys: `ArrowRight` / `ArrowLeft` move between enabled tabs and wrap (swapped in right-to-left text), `Home` and
404
+ `End` jump, and `Enter` or `Space` select the focused tab; with `activation="auto"` the arrow keys, `Home` and
405
+ `End` select too. A disabled tab is skipped by the arrow keys (`tabindex="-1"`, never the tab stop). When the tabs do not fit, the row scrolls
406
+ sideways inside itself (the page never does), keeps the selected and the focused tab in view and cuts a label
407
+ wider than the row with an ellipsis. A fine pointer keeps a thin scrollbar (a plain wheel does not scroll a
408
+ horizontal row); touch hides it.
409
+
410
+ Each tab is at least the control height of its size (44px or more on a coarse pointer, 60px at `xl`). The selected
411
+ tab is marked by an underline, a heavier weight and the stronger text colour, never by colour alone; keep a custom
412
+ underline 3:1 from the page. The focus ring is drawn inside the tab on keyboard focus only. In forced colors the
413
+ underline is `Highlight`, the selected text and the line under the row are `CanvasText`, and a disabled tab is
414
+ `GrayText`; the underline grows in over `--ck-duration-fast` and not at all under `prefers-reduced-motion`.
415
+
416
+ Component tokens: `--ck-tabs-fg` (unselected text, default `--ck-color-fg-muted`), `--ck-tabs-fg-selected`
417
+ (default `--ck-color-fg`), `--ck-tabs-indicator` (underline, default `--ck-color-primary`),
418
+ `--ck-tabs-indicator-thickness` (default `--ck-space-1`), `--ck-tabs-border-color` (the 1px line under the row,
419
+ default `--ck-color-border-subtle`), `--ck-tabs-gap` (between tabs, default `0`), `--ck-tabs-padding-inline`
420
+ (default the control padding of the size), `--ck-tabs-font-weight` (unselected, default `--ck-font-weight-medium`)
421
+ and `--ck-tabs-font-weight-selected` (default `--ck-font-weight-semibold`). Set the two weights equal and no tab
422
+ changes width when it is selected.
423
+
424
+ Global element styles: an unlayered `ck-tab-panel { display: … }` keeps hidden panels on screen (use
425
+ `ck-tab-panel:not([hidden])`), and a global `:focus-visible { outline: … }` adds a second ring on the tab itself
426
+ (use `:focus-visible:not(.ck-tab)`). Or put resets in a layer declared before ckui: `@layer reset, ckui;`.
427
+
157
428
  ## Toast
158
429
 
159
430
  ```ts
@@ -241,6 +512,68 @@ with `:not(.ck-dialog__title)`, `:not(.ck-dialog__description)` and `:not(.ck-bu
241
512
  declared before ckui: `@layer reset, ckui;`. A component opened through `CkDialog` must keep its host element a
242
513
  flex column (the default styles do this); a global `display` on it stops the body from scrolling.
243
514
 
515
+ ## Drawer
516
+
517
+ ```ts
518
+ import { CK_DRAWER_DATA, CK_DRAWER_IMPORTS, CkDrawer, CkDrawerRef } from '@ckui/core/drawer';
519
+
520
+ @Component({
521
+ imports: [CK_DRAWER_IMPORTS],
522
+ template: `
523
+ <h2 ckDialogTitle>Devices</h2>
524
+ <ck-dialog-body>
525
+ @for (device of data.devices; track device) {
526
+ <button (click)="ref.close(device)">{{ device }}</button>
527
+ }
528
+ </ck-dialog-body>
529
+ <ck-dialog-actions><button ckDialogClose>Cancel</button></ck-dialog-actions>
530
+ `,
531
+ })
532
+ class DeviceSheet {
533
+ protected readonly data = inject<{ devices: string[] }>(CK_DRAWER_DATA);
534
+ protected readonly ref = inject<CkDrawerRef<string>>(CkDrawerRef);
535
+ }
536
+
537
+ const ref = inject(CkDrawer).open<DeviceSheet, { devices: string[] }, string>(DeviceSheet, {
538
+ side: 'end',
539
+ data: { devices: ['Bike', 'Treadmill'] },
540
+ });
541
+ const device = await ref.closed; // undefined when dismissed
542
+ ```
543
+
544
+ A drawer is a modal panel that slides in from the side of the screen. On a tablet or desktop it is a full-height side
545
+ panel; on a narrow screen with a coarse pointer it is the dialog's bottom sheet. It is written with the dialog's
546
+ building blocks, which `CK_DRAWER_IMPORTS` re-exports: `ckDialogTitle` (names the drawer), `ckDialogDescription`,
547
+ `ck-dialog-body` (the only part that scrolls), `ck-dialog-actions`, `ckDialogClose="result"` and
548
+ `ckDialogInitialFocus`.
549
+
550
+ `CkDrawer.open(componentOrTemplate, config)` returns a `CkDrawerRef` (`close(result?)`, `closed`, `closing`); it is
551
+ the ref of `CkDialog`, and `CK_DRAWER_DATA` is the token of `CK_DIALOG_DATA`, so content written for a dialog works in
552
+ a drawer. `closeAll()` closes the drawers and leaves dialogs open. Config: `data`, `side` (`start` or `end`, default
553
+ `end`: the right edge in a left-to-right page, the left edge in a right-to-left one), `mode` (`auto`, `side`,
554
+ `sheet`; `auto` is decided when the drawer opens), `width` (`sm`, `md`, `lg`: 20, 24 or 32rem, never wider than the
555
+ screen minus a margin), `role` (`dialog` or `alertdialog`), `dismissible` (Escape and backdrop, and a swipe on a
556
+ sheet; default `true`), `closeButton`, `fullHeight` (a sheet as tall as the screen allows), `injector` and
557
+ `ariaLabel`. `closed` resolves after the drawer has left the screen, with the first result passed to `close()`;
558
+ Escape, the backdrop, a swipe and destroying the app resolve it with `undefined`.
559
+
560
+ The same drawer can be declared in a template: `<ck-drawer [(open)]="open" side="end" (closed)="onClosed($event)">`
561
+ with one `<ng-template>` inside, which is rendered only while the drawer is open.
562
+
563
+ The drawer is modal like a dialog: `role="dialog"` (or `alertdialog`) with `aria-modal`, a focus trap, an inert page
564
+ behind it, Escape and backdrop close when dismissible, and focus returns to the opener. A side panel has no swipe; a
565
+ dialog opened from a drawer sits above it. The panel keeps its content out of display cut-outs (safe-area insets),
566
+ does not slide under `prefers-reduced-motion` and has a visible border in forced-colors mode.
567
+
568
+ Component tokens: `--ck-drawer-bg` (panel and grab area; falls back to `--ck-color-surface-raised`),
569
+ `--ck-drawer-width` (side panel; falls back to the 20, 24 or 32rem of `width`), `--ck-drawer-padding` (falls back to
570
+ `--ck-space-6`, `--ck-space-4` on a sheet) and `--ck-drawer-shadow` (falls back to `--ck-shadow-lg`). The drawer
571
+ does not read the `--ck-dialog-*` tokens.
572
+
573
+ Global element styles: as for the dialog, scope a global `h2`, `p` or `button:focus-visible` rule with
574
+ `:not(.ck-dialog__title)`, `:not(.ck-dialog__description)` and `:not(.ck-button)`, or put resets in a layer declared
575
+ before ckui: `@layer reset, ckui;`.
576
+
244
577
  ## Status
245
578
 
246
579
  Pre-release. Version 0.1 is in progress and the API is not stable yet.
@@ -0,0 +1,169 @@
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, DestroyRef, Directive, ElementRef, PLATFORM_ID, ViewEncapsulation, afterNextRender, booleanAttribute, computed, inject, input } from "@angular/core";
3
+ import { isPlatformBrowser } from "@angular/common";
4
+ const TONES = [
5
+ "neutral",
6
+ "success",
7
+ "warning",
8
+ "danger"
9
+ ];
10
+ const SIZES = ["sm", "md"];
11
+ var CkBadgeIcon = class CkBadgeIcon {
12
+ static ɵfac = i0.ɵɵngDeclareFactory({
13
+ minVersion: "12.0.0",
14
+ version: "22.2.4",
15
+ ngImport: i0,
16
+ type: CkBadgeIcon,
17
+ deps: [],
18
+ target: i0.ɵɵFactoryTarget.Directive
19
+ });
20
+ static ɵdir = i0.ɵɵngDeclareDirective({
21
+ minVersion: "14.0.0",
22
+ version: "22.2.4",
23
+ type: CkBadgeIcon,
24
+ isStandalone: true,
25
+ selector: "[ckBadgeIcon]",
26
+ host: {
27
+ attributes: { "aria-hidden": "true" },
28
+ classAttribute: "ck-badge__icon"
29
+ },
30
+ ngImport: i0
31
+ });
32
+ };
33
+ i0.ɵɵngDeclareClassMetadata({
34
+ minVersion: "12.0.0",
35
+ version: "22.2.4",
36
+ ngImport: i0,
37
+ type: CkBadgeIcon,
38
+ decorators: [{
39
+ type: Directive,
40
+ args: [{
41
+ selector: "[ckBadgeIcon]",
42
+ host: {
43
+ class: "ck-badge__icon",
44
+ "aria-hidden": "true"
45
+ }
46
+ }]
47
+ }]
48
+ });
49
+ var CkBadge = class CkBadge {
50
+ tone = input("neutral", ...ngDevMode ? [{ debugName: "tone" }] : /* istanbul ignore next */ []);
51
+ dot = input(false, {
52
+ ...ngDevMode ? { debugName: "dot" } : /* istanbul ignore next */ {},
53
+ transform: booleanAttribute
54
+ });
55
+ size = input("md", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
56
+ element = inject(ElementRef).nativeElement;
57
+ modifierClasses = computed(() => {
58
+ return `ck-badge ck-badge--${TONES.includes(this.tone()) ? this.tone() : "neutral"} ck-badge--${SIZES.includes(this.size()) ? this.size() : "md"}`;
59
+ }, ...ngDevMode ? [{ debugName: "modifierClasses" }] : /* istanbul ignore next */ []);
60
+ constructor() {
61
+ if (typeof ngDevMode !== "undefined" && ngDevMode && isPlatformBrowser(inject(PLATFORM_ID))) {
62
+ let destroyed = false;
63
+ inject(DestroyRef).onDestroy(() => destroyed = true);
64
+ afterNextRender(() => {
65
+ const text = this.element.querySelector(".ck-badge__text");
66
+ if (!destroyed && (text?.textContent ?? "").trim() === "") console.warn("[ckui] ck-badge has no text. The text must state the status; a dot or an icon alone is colour alone.", this.element);
67
+ });
68
+ }
69
+ }
70
+ static ɵfac = i0.ɵɵngDeclareFactory({
71
+ minVersion: "12.0.0",
72
+ version: "22.2.4",
73
+ ngImport: i0,
74
+ type: CkBadge,
75
+ deps: [],
76
+ target: i0.ɵɵFactoryTarget.Component
77
+ });
78
+ static ɵcmp = i0.ɵɵngDeclareComponent({
79
+ minVersion: "17.0.0",
80
+ version: "22.2.4",
81
+ type: CkBadge,
82
+ isStandalone: true,
83
+ selector: "ck-badge",
84
+ inputs: {
85
+ tone: {
86
+ classPropertyName: "tone",
87
+ publicName: "tone",
88
+ isSignal: true,
89
+ isRequired: false,
90
+ transformFunction: null
91
+ },
92
+ dot: {
93
+ classPropertyName: "dot",
94
+ publicName: "dot",
95
+ isSignal: true,
96
+ isRequired: false,
97
+ transformFunction: null
98
+ },
99
+ size: {
100
+ classPropertyName: "size",
101
+ publicName: "size",
102
+ isSignal: true,
103
+ isRequired: false,
104
+ transformFunction: null
105
+ }
106
+ },
107
+ host: { properties: { "class": "modifierClasses()" } },
108
+ ngImport: i0,
109
+ template: `@if (dot()) {
110
+ <span class="ck-badge__dot" aria-hidden="true"></span>
111
+ }
112
+ <ng-content select="[ckBadgeIcon]" /><span class="ck-badge__text"><ng-content /></span>`,
113
+ isInline: true,
114
+ styles: ["@layer ckui{.ck-badge{--_ck-badge-bg: var(--ck-color-control);--_ck-badge-fg: var(--ck-color-fg);--_ck-badge-height: 1.5rem;--_ck-badge-font-size: var(--ck-font-size-sm);--_ck-badge-padding-inline: var(--ck-space-2);--_ck-badge-gap: calc(var(--ck-space-1) * 1.5);display:inline-flex;align-items:center;gap:var(--_ck-badge-gap);box-sizing:border-box;min-inline-size:0;max-inline-size:100%;block-size:var(--_ck-badge-height);padding-inline:var(--_ck-badge-padding-inline);border-radius:var(--ck-badge-radius, var(--ck-radius-full));background:var(--ck-badge-bg, var(--_ck-badge-bg));color:var(--ck-badge-fg, var(--_ck-badge-fg));color-scheme:var(--ck-color-scheme);font-family:inherit;font-size:var(--_ck-badge-font-size);font-weight:var(--ck-font-weight-semibold);font-variant-numeric:var(--ck-font-variant-numeric);line-height:var(--ck-line-height-tight);white-space:nowrap;vertical-align:middle}.ck-badge--sm{--_ck-badge-height: 1.25rem;--_ck-badge-font-size: var(--ck-font-size-xs);--_ck-badge-padding-inline: calc(var(--ck-space-1) * 1.5);--_ck-badge-gap: var(--ck-space-1)}.ck-badge--success{--_ck-badge-fg: var(--ck-color-success-fg)}.ck-badge--warning{--_ck-badge-fg: var(--ck-color-warning-fg)}.ck-badge--danger{--_ck-badge-bg: var(--ck-color-danger);--_ck-badge-fg: var(--ck-color-on-danger)}.ck-badge__text{display:block;min-inline-size:0;overflow:hidden;text-overflow:ellipsis}.ck-badge__dot{flex:none;inline-size:.5em;block-size:.5em;border-radius:var(--ck-radius-full);background:var(--ck-badge-dot, currentColor)}.ck-badge__icon{flex:none;inline-size:1em;block-size:1em}@media(forced-colors:active){.ck-badge{border:1px solid CanvasText}.ck-badge__dot{forced-color-adjust:none;background:CanvasText}}}\n"],
115
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
116
+ encapsulation: i0.ViewEncapsulation.None
117
+ });
118
+ };
119
+ i0.ɵɵngDeclareClassMetadata({
120
+ minVersion: "12.0.0",
121
+ version: "22.2.4",
122
+ ngImport: i0,
123
+ type: CkBadge,
124
+ decorators: [{
125
+ type: Component,
126
+ args: [{
127
+ selector: "ck-badge",
128
+ changeDetection: ChangeDetectionStrategy.OnPush,
129
+ encapsulation: ViewEncapsulation.None,
130
+ host: { "[class]": "modifierClasses()" },
131
+ template: `@if (dot()) {
132
+ <span class="ck-badge__dot" aria-hidden="true"></span>
133
+ }
134
+ <ng-content select="[ckBadgeIcon]" /><span class="ck-badge__text"><ng-content /></span>`,
135
+ styles: ["@layer ckui{.ck-badge{--_ck-badge-bg: var(--ck-color-control);--_ck-badge-fg: var(--ck-color-fg);--_ck-badge-height: 1.5rem;--_ck-badge-font-size: var(--ck-font-size-sm);--_ck-badge-padding-inline: var(--ck-space-2);--_ck-badge-gap: calc(var(--ck-space-1) * 1.5);display:inline-flex;align-items:center;gap:var(--_ck-badge-gap);box-sizing:border-box;min-inline-size:0;max-inline-size:100%;block-size:var(--_ck-badge-height);padding-inline:var(--_ck-badge-padding-inline);border-radius:var(--ck-badge-radius, var(--ck-radius-full));background:var(--ck-badge-bg, var(--_ck-badge-bg));color:var(--ck-badge-fg, var(--_ck-badge-fg));color-scheme:var(--ck-color-scheme);font-family:inherit;font-size:var(--_ck-badge-font-size);font-weight:var(--ck-font-weight-semibold);font-variant-numeric:var(--ck-font-variant-numeric);line-height:var(--ck-line-height-tight);white-space:nowrap;vertical-align:middle}.ck-badge--sm{--_ck-badge-height: 1.25rem;--_ck-badge-font-size: var(--ck-font-size-xs);--_ck-badge-padding-inline: calc(var(--ck-space-1) * 1.5);--_ck-badge-gap: var(--ck-space-1)}.ck-badge--success{--_ck-badge-fg: var(--ck-color-success-fg)}.ck-badge--warning{--_ck-badge-fg: var(--ck-color-warning-fg)}.ck-badge--danger{--_ck-badge-bg: var(--ck-color-danger);--_ck-badge-fg: var(--ck-color-on-danger)}.ck-badge__text{display:block;min-inline-size:0;overflow:hidden;text-overflow:ellipsis}.ck-badge__dot{flex:none;inline-size:.5em;block-size:.5em;border-radius:var(--ck-radius-full);background:var(--ck-badge-dot, currentColor)}.ck-badge__icon{flex:none;inline-size:1em;block-size:1em}@media(forced-colors:active){.ck-badge{border:1px solid CanvasText}.ck-badge__dot{forced-color-adjust:none;background:CanvasText}}}\n"]
136
+ }]
137
+ }],
138
+ ctorParameters: () => [],
139
+ propDecorators: {
140
+ tone: [{
141
+ type: i0.Input,
142
+ args: [{
143
+ isSignal: true,
144
+ alias: "tone",
145
+ required: false
146
+ }]
147
+ }],
148
+ dot: [{
149
+ type: i0.Input,
150
+ args: [{
151
+ isSignal: true,
152
+ alias: "dot",
153
+ required: false
154
+ }]
155
+ }],
156
+ size: [{
157
+ type: i0.Input,
158
+ args: [{
159
+ isSignal: true,
160
+ alias: "size",
161
+ required: false
162
+ }]
163
+ }]
164
+ }
165
+ });
166
+ const CK_BADGE_IMPORTS = [CkBadge, CkBadgeIcon];
167
+ export { CK_BADGE_IMPORTS, CkBadge, CkBadgeIcon };
168
+
169
+ //# sourceMappingURL=ckui-core-badge.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ckui-core-badge.mjs","names":[],"sources":["../../../../projects/core/badge/badge.ts","../../../../projects/core/badge/index.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n ViewEncapsulation,\n afterNextRender,\n booleanAttribute,\n computed,\n inject,\n input,\n} from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\n\ndeclare const ngDevMode: unknown;\n\nexport type CkBadgeTone = 'neutral' | 'success' | 'warning' | 'danger';\nexport type CkBadgeSize = 'sm' | 'md';\n\nconst TONES: readonly CkBadgeTone[] = ['neutral', 'success', 'warning', 'danger'];\nconst SIZES: readonly CkBadgeSize[] = ['sm', 'md'];\n\n/** Marks a projected element (usually an `svg`) as the badge's leading icon. It is decorative. */\n@Directive({\n selector: '[ckBadgeIcon]',\n host: { class: 'ck-badge__icon', 'aria-hidden': 'true' },\n})\nexport class CkBadgeIcon {}\n\n/**\n * A small, non-interactive status label: a pill with text, an optional leading dot or icon. It is\n * not a live region and has no role; the text must say what the status is, colour never does.\n */\n@Component({\n selector: 'ck-badge',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n '[class]': 'modifierClasses()',\n },\n template: `@if (dot()) {\n <span class=\"ck-badge__dot\" aria-hidden=\"true\"></span>\n }\n <ng-content select=\"[ckBadgeIcon]\" /><span class=\"ck-badge__text\"><ng-content /></span>`,\n styleUrl: './badge.css',\n})\nexport class CkBadge {\n /** Colours of the badge. An unknown value falls back to `neutral`. */\n readonly tone = input<CkBadgeTone>('neutral');\n /** Adds a leading dot in the text colour. */\n readonly dot = input(false, { transform: booleanAttribute });\n /** `md` is a 1.5rem pill, `sm` a smaller one for dense lists. An unknown value falls back to `md`. */\n readonly size = input<CkBadgeSize>('md');\n\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n\n protected readonly modifierClasses = computed(() => {\n const tone = TONES.includes(this.tone()) ? this.tone() : 'neutral';\n const size = SIZES.includes(this.size()) ? this.size() : 'md';\n return `ck-badge ck-badge--${tone} ck-badge--${size}`;\n });\n\n constructor() {\n if (typeof ngDevMode !== 'undefined' && ngDevMode && isPlatformBrowser(inject(PLATFORM_ID))) {\n let destroyed = false;\n inject(DestroyRef).onDestroy(() => (destroyed = true));\n afterNextRender(() => {\n const text = this.element.querySelector('.ck-badge__text');\n if (!destroyed && (text?.textContent ?? '').trim() === '') {\n console.warn(\n '[ckui] ck-badge has no text. The text must state the status; a dot or an icon alone is colour alone.',\n this.element,\n );\n }\n });\n }\n }\n}\n","import { CkBadge, CkBadgeIcon } from './badge';\n\nexport type { CkBadgeSize, CkBadgeTone } from './badge';\nexport { CkBadge, CkBadgeIcon } from './badge';\n\n/** Everything a template needs for a badge: `imports: [CK_BADGE_IMPORTS]`. */\nexport const CK_BADGE_IMPORTS = [CkBadge, CkBadgeIcon] as const;\n"],"mappings":"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"}