@ckui/core 0.1.0-next.2 → 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 +215 -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 -287
- 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 +19 -8
- package/fesm2022/ckui-core-internal-overlay.mjs.map +1 -1
- 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/package.json +21 -1
- 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 +12 -5
- package/types/ckui-core-switch.d.ts +90 -0
- package/types/ckui-core-tabs.d.ts +212 -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
|
|
@@ -272,6 +320,111 @@ Global element styles: an unlayered `button { border: … }` or `input { … }`
|
|
|
272
320
|
`:focus-visible { outline: … }` draws a second ring on the input. Keep them off the stepper
|
|
273
321
|
(`button:not(.ck-stepper__button)`) or put resets in a layer declared before ckui: `@layer reset, ckui;`.
|
|
274
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
|
+
|
|
275
428
|
## Toast
|
|
276
429
|
|
|
277
430
|
```ts
|
|
@@ -359,6 +512,68 @@ with `:not(.ck-dialog__title)`, `:not(.ck-dialog__description)` and `:not(.ck-bu
|
|
|
359
512
|
declared before ckui: `@layer reset, ckui;`. A component opened through `CkDialog` must keep its host element a
|
|
360
513
|
flex column (the default styles do this); a global `display` on it stops the body from scrolling.
|
|
361
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
|
+
|
|
362
577
|
## Status
|
|
363
578
|
|
|
364
579
|
Pre-release. Version 0.1 is in progress and the API is not stable yet.
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { isPlatformBrowser } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, Directive, ElementRef, PLATFORM_ID, Renderer2, ViewEncapsulation, afterNextRender, booleanAttribute, computed, effect, inject, input, model } from "@angular/core";
|
|
4
|
+
import { CkIcon, hasAccessibleName } from "@ckui/core/internal";
|
|
5
|
+
const SIZES = [
|
|
6
|
+
"sm",
|
|
7
|
+
"md",
|
|
8
|
+
"lg",
|
|
9
|
+
"xl"
|
|
10
|
+
];
|
|
11
|
+
var CkChipIcon = class CkChipIcon {
|
|
12
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
13
|
+
minVersion: "12.0.0",
|
|
14
|
+
version: "22.2.4",
|
|
15
|
+
ngImport: i0,
|
|
16
|
+
type: CkChipIcon,
|
|
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: CkChipIcon,
|
|
24
|
+
isStandalone: true,
|
|
25
|
+
selector: "[ckChipIcon]",
|
|
26
|
+
host: {
|
|
27
|
+
attributes: { "aria-hidden": "true" },
|
|
28
|
+
classAttribute: "ck-chip__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: CkChipIcon,
|
|
38
|
+
decorators: [{
|
|
39
|
+
type: Directive,
|
|
40
|
+
args: [{
|
|
41
|
+
selector: "[ckChipIcon]",
|
|
42
|
+
host: {
|
|
43
|
+
class: "ck-chip__icon",
|
|
44
|
+
"aria-hidden": "true"
|
|
45
|
+
}
|
|
46
|
+
}]
|
|
47
|
+
}]
|
|
48
|
+
});
|
|
49
|
+
var CkChip = class CkChip {
|
|
50
|
+
selected = model(false, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
|
|
51
|
+
size = input("sm", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
52
|
+
disabled = input(false, {
|
|
53
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
54
|
+
transform: booleanAttribute
|
|
55
|
+
});
|
|
56
|
+
element = inject(ElementRef).nativeElement;
|
|
57
|
+
renderer = inject(Renderer2);
|
|
58
|
+
modifierClasses = computed(() => {
|
|
59
|
+
return `ck-chip ck-chip--${SIZES.includes(this.size()) ? this.size() : "sm"}`;
|
|
60
|
+
}, ...ngDevMode ? [{ debugName: "modifierClasses" }] : /* istanbul ignore next */ []);
|
|
61
|
+
consumerDisabled;
|
|
62
|
+
constructor() {
|
|
63
|
+
const destroyRef = inject(DestroyRef);
|
|
64
|
+
if (!this.element.hasAttribute("type")) this.renderer.setAttribute(this.element, "type", "button");
|
|
65
|
+
if (this.element.hasAttribute("data-ck-chip-disabled")) this.consumerDisabled = null;
|
|
66
|
+
const blockClick = (event) => {
|
|
67
|
+
if (this.disabled()) {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
event.stopImmediatePropagation();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
for (const type of ["click", "auxclick"]) {
|
|
73
|
+
this.element.addEventListener(type, blockClick, { capture: true });
|
|
74
|
+
destroyRef.onDestroy(() => this.element.removeEventListener(type, blockClick, { capture: true }));
|
|
75
|
+
}
|
|
76
|
+
effect(() => this.writeDisabled(this.disabled()));
|
|
77
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode && isPlatformBrowser(inject(PLATFORM_ID))) {
|
|
78
|
+
let destroyed = false;
|
|
79
|
+
destroyRef.onDestroy(() => destroyed = true);
|
|
80
|
+
afterNextRender(() => {
|
|
81
|
+
if (!destroyed && !hasAccessibleName(this.element, {
|
|
82
|
+
title: true,
|
|
83
|
+
text: true
|
|
84
|
+
})) console.warn("[ckui] ckChip has no accessible name. Give it a label, an aria-label or an aria-labelledby.", this.element);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
toggle() {
|
|
89
|
+
if (this.disabled() || this.element.matches(":disabled")) return;
|
|
90
|
+
this.selected.update((selected) => !selected);
|
|
91
|
+
}
|
|
92
|
+
writeDisabled(disabled) {
|
|
93
|
+
if (disabled) {
|
|
94
|
+
if (this.consumerDisabled === void 0) {
|
|
95
|
+
this.consumerDisabled = this.element.getAttribute("disabled");
|
|
96
|
+
this.renderer.setAttribute(this.element, "data-ck-chip-disabled", "");
|
|
97
|
+
}
|
|
98
|
+
this.renderer.setAttribute(this.element, "disabled", "");
|
|
99
|
+
} else if (this.consumerDisabled !== void 0) {
|
|
100
|
+
const previous = this.consumerDisabled;
|
|
101
|
+
this.consumerDisabled = void 0;
|
|
102
|
+
this.renderer.removeAttribute(this.element, "data-ck-chip-disabled");
|
|
103
|
+
if (previous === null) this.renderer.removeAttribute(this.element, "disabled");
|
|
104
|
+
else this.renderer.setAttribute(this.element, "disabled", previous);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
108
|
+
minVersion: "12.0.0",
|
|
109
|
+
version: "22.2.4",
|
|
110
|
+
ngImport: i0,
|
|
111
|
+
type: CkChip,
|
|
112
|
+
deps: [],
|
|
113
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
114
|
+
});
|
|
115
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
116
|
+
minVersion: "17.0.0",
|
|
117
|
+
version: "22.2.4",
|
|
118
|
+
type: CkChip,
|
|
119
|
+
isStandalone: true,
|
|
120
|
+
selector: "button[ckChip]",
|
|
121
|
+
inputs: {
|
|
122
|
+
selected: {
|
|
123
|
+
classPropertyName: "selected",
|
|
124
|
+
publicName: "selected",
|
|
125
|
+
isSignal: true,
|
|
126
|
+
isRequired: false,
|
|
127
|
+
transformFunction: null
|
|
128
|
+
},
|
|
129
|
+
size: {
|
|
130
|
+
classPropertyName: "size",
|
|
131
|
+
publicName: "size",
|
|
132
|
+
isSignal: true,
|
|
133
|
+
isRequired: false,
|
|
134
|
+
transformFunction: null
|
|
135
|
+
},
|
|
136
|
+
disabled: {
|
|
137
|
+
classPropertyName: "disabled",
|
|
138
|
+
publicName: "disabled",
|
|
139
|
+
isSignal: true,
|
|
140
|
+
isRequired: false,
|
|
141
|
+
transformFunction: null
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
outputs: { selected: "selectedChange" },
|
|
145
|
+
host: {
|
|
146
|
+
listeners: { "click": "toggle()" },
|
|
147
|
+
properties: {
|
|
148
|
+
"class": "modifierClasses()",
|
|
149
|
+
"class.ck-chip--selected": "!!selected()",
|
|
150
|
+
"class.ck-chip--disabled": "disabled()",
|
|
151
|
+
"attr.aria-pressed": "selected() ? \"true\" : \"false\""
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
ngImport: i0,
|
|
155
|
+
template: `
|
|
156
|
+
@if (selected()) {
|
|
157
|
+
<ck-icon class="ck-chip__check" name="check" />
|
|
158
|
+
}
|
|
159
|
+
<ng-content select="[ckChipIcon]" /><span class="ck-chip__label"><ng-content /></span>
|
|
160
|
+
`,
|
|
161
|
+
isInline: true,
|
|
162
|
+
styles: ["@layer ckui{.ck-chip{--_ck-chip-height: var(--ck-control-height-sm);--_ck-chip-padding-inline: var(--ck-control-padding-inline-sm);--_ck-chip-font-size: var(--ck-control-font-size-sm);--_ck-chip-border: var(--ck-chip-border-color, var(--ck-color-control-border));--_ck-chip-bg: var(--ck-chip-bg, var(--ck-color-control));--_ck-chip-fg: var(--ck-chip-fg, var(--ck-color-fg));display:inline-flex;align-items:center;justify-content:center;gap:var(--ck-space-1);box-sizing:border-box;min-inline-size:0;max-inline-size:100%;min-block-size:var(--_ck-chip-height);margin:0;padding-block:0;padding-inline:var(--_ck-chip-padding-inline);border:1px solid var(--_ck-chip-border);border-radius:var(--ck-chip-radius, var(--ck-radius-full));background-color:var(--_ck-chip-bg);color:var(--_ck-chip-fg);color-scheme:var(--ck-color-scheme);font-family:inherit;font-size:var(--_ck-chip-font-size);font-variant-numeric:var(--ck-font-variant-numeric);font-weight:var(--ck-font-weight-medium);line-height:var(--ck-line-height-tight);cursor:pointer;touch-action:manipulation;transition:background-color var(--ck-duration-fast) var(--ck-ease-standard)}.ck-chip--md{--_ck-chip-height: var(--ck-control-height-md);--_ck-chip-padding-inline: var(--ck-control-padding-inline-md);--_ck-chip-font-size: var(--ck-control-font-size-md)}.ck-chip--lg{--_ck-chip-height: var(--ck-control-height-lg);--_ck-chip-padding-inline: var(--ck-control-padding-inline-lg);--_ck-chip-font-size: var(--ck-control-font-size-lg)}.ck-chip--xl{--_ck-chip-height: var(--ck-control-height-xl);--_ck-chip-padding-inline: var(--ck-control-padding-inline-xl);--_ck-chip-font-size: var(--ck-control-font-size-xl)}.ck-chip--selected{--_ck-chip-border: var(--ck-chip-selected-bg, var(--ck-color-primary));--_ck-chip-bg: var(--ck-chip-selected-bg, var(--ck-color-primary));--_ck-chip-fg: var(--ck-chip-selected-fg, var(--ck-color-on-primary))}.ck-chip__label{display:block;min-inline-size:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ck-chip__icon,.ck-chip__check{flex:none;inline-size:1em;block-size:1em}.ck-chip__icon>svg{display:block;inline-size:100%;block-size:100%}.ck-chip--selected .ck-chip__icon{display:none}@media(hover:hover){.ck-chip:hover{background-image:linear-gradient(var(--ck-color-surface-hover),var(--ck-color-surface-hover))}}.ck-chip:active{background-image:linear-gradient(var(--ck-color-surface-active),var(--ck-color-surface-active))}.ck-chip:focus-visible{outline:var(--ck-focus-ring);outline-offset:var(--ck-focus-ring-offset)}:is(.ck-chip--disabled,.ck-chip:disabled),:is(.ck-chip--disabled,.ck-chip:disabled):hover,:is(.ck-chip--disabled,.ck-chip:disabled):active{border-color:transparent;background-color:var(--ck-color-surface-hover);background-image:none;color:var(--ck-color-fg-disabled);cursor:not-allowed}@media(prefers-reduced-motion:reduce){.ck-chip{transition:none}}@media(forced-colors:active){.ck-chip{border-color:ButtonText}.ck-chip--selected{forced-color-adjust:none;border-color:Highlight;background-color:Highlight;color:HighlightText}.ck-chip--selected,.ck-chip--selected:hover,.ck-chip--selected:active{background-image:none}.ck-chip--selected:focus-visible{outline-color:CanvasText}:is(.ck-chip--disabled,.ck-chip:disabled),:is(.ck-chip--disabled,.ck-chip:disabled):hover,:is(.ck-chip--disabled,.ck-chip:disabled):active{border-color:GrayText;background-color:Canvas;color:GrayText}}}\n"],
|
|
163
|
+
dependencies: [{
|
|
164
|
+
kind: "component",
|
|
165
|
+
type: CkIcon,
|
|
166
|
+
selector: "ck-icon",
|
|
167
|
+
inputs: ["name"]
|
|
168
|
+
}],
|
|
169
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
170
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
174
|
+
minVersion: "12.0.0",
|
|
175
|
+
version: "22.2.4",
|
|
176
|
+
ngImport: i0,
|
|
177
|
+
type: CkChip,
|
|
178
|
+
decorators: [{
|
|
179
|
+
type: Component,
|
|
180
|
+
args: [{
|
|
181
|
+
selector: "button[ckChip]",
|
|
182
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
183
|
+
encapsulation: ViewEncapsulation.None,
|
|
184
|
+
host: {
|
|
185
|
+
"[class]": "modifierClasses()",
|
|
186
|
+
"[class.ck-chip--selected]": "!!selected()",
|
|
187
|
+
"[class.ck-chip--disabled]": "disabled()",
|
|
188
|
+
"[attr.aria-pressed]": "selected() ? \"true\" : \"false\"",
|
|
189
|
+
"(click)": "toggle()"
|
|
190
|
+
},
|
|
191
|
+
imports: [CkIcon],
|
|
192
|
+
template: `
|
|
193
|
+
@if (selected()) {
|
|
194
|
+
<ck-icon class="ck-chip__check" name="check" />
|
|
195
|
+
}
|
|
196
|
+
<ng-content select="[ckChipIcon]" /><span class="ck-chip__label"><ng-content /></span>
|
|
197
|
+
`,
|
|
198
|
+
styles: ["@layer ckui{.ck-chip{--_ck-chip-height: var(--ck-control-height-sm);--_ck-chip-padding-inline: var(--ck-control-padding-inline-sm);--_ck-chip-font-size: var(--ck-control-font-size-sm);--_ck-chip-border: var(--ck-chip-border-color, var(--ck-color-control-border));--_ck-chip-bg: var(--ck-chip-bg, var(--ck-color-control));--_ck-chip-fg: var(--ck-chip-fg, var(--ck-color-fg));display:inline-flex;align-items:center;justify-content:center;gap:var(--ck-space-1);box-sizing:border-box;min-inline-size:0;max-inline-size:100%;min-block-size:var(--_ck-chip-height);margin:0;padding-block:0;padding-inline:var(--_ck-chip-padding-inline);border:1px solid var(--_ck-chip-border);border-radius:var(--ck-chip-radius, var(--ck-radius-full));background-color:var(--_ck-chip-bg);color:var(--_ck-chip-fg);color-scheme:var(--ck-color-scheme);font-family:inherit;font-size:var(--_ck-chip-font-size);font-variant-numeric:var(--ck-font-variant-numeric);font-weight:var(--ck-font-weight-medium);line-height:var(--ck-line-height-tight);cursor:pointer;touch-action:manipulation;transition:background-color var(--ck-duration-fast) var(--ck-ease-standard)}.ck-chip--md{--_ck-chip-height: var(--ck-control-height-md);--_ck-chip-padding-inline: var(--ck-control-padding-inline-md);--_ck-chip-font-size: var(--ck-control-font-size-md)}.ck-chip--lg{--_ck-chip-height: var(--ck-control-height-lg);--_ck-chip-padding-inline: var(--ck-control-padding-inline-lg);--_ck-chip-font-size: var(--ck-control-font-size-lg)}.ck-chip--xl{--_ck-chip-height: var(--ck-control-height-xl);--_ck-chip-padding-inline: var(--ck-control-padding-inline-xl);--_ck-chip-font-size: var(--ck-control-font-size-xl)}.ck-chip--selected{--_ck-chip-border: var(--ck-chip-selected-bg, var(--ck-color-primary));--_ck-chip-bg: var(--ck-chip-selected-bg, var(--ck-color-primary));--_ck-chip-fg: var(--ck-chip-selected-fg, var(--ck-color-on-primary))}.ck-chip__label{display:block;min-inline-size:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ck-chip__icon,.ck-chip__check{flex:none;inline-size:1em;block-size:1em}.ck-chip__icon>svg{display:block;inline-size:100%;block-size:100%}.ck-chip--selected .ck-chip__icon{display:none}@media(hover:hover){.ck-chip:hover{background-image:linear-gradient(var(--ck-color-surface-hover),var(--ck-color-surface-hover))}}.ck-chip:active{background-image:linear-gradient(var(--ck-color-surface-active),var(--ck-color-surface-active))}.ck-chip:focus-visible{outline:var(--ck-focus-ring);outline-offset:var(--ck-focus-ring-offset)}:is(.ck-chip--disabled,.ck-chip:disabled),:is(.ck-chip--disabled,.ck-chip:disabled):hover,:is(.ck-chip--disabled,.ck-chip:disabled):active{border-color:transparent;background-color:var(--ck-color-surface-hover);background-image:none;color:var(--ck-color-fg-disabled);cursor:not-allowed}@media(prefers-reduced-motion:reduce){.ck-chip{transition:none}}@media(forced-colors:active){.ck-chip{border-color:ButtonText}.ck-chip--selected{forced-color-adjust:none;border-color:Highlight;background-color:Highlight;color:HighlightText}.ck-chip--selected,.ck-chip--selected:hover,.ck-chip--selected:active{background-image:none}.ck-chip--selected:focus-visible{outline-color:CanvasText}:is(.ck-chip--disabled,.ck-chip:disabled),:is(.ck-chip--disabled,.ck-chip:disabled):hover,:is(.ck-chip--disabled,.ck-chip:disabled):active{border-color:GrayText;background-color:Canvas;color:GrayText}}}\n"]
|
|
199
|
+
}]
|
|
200
|
+
}],
|
|
201
|
+
ctorParameters: () => [],
|
|
202
|
+
propDecorators: {
|
|
203
|
+
selected: [{
|
|
204
|
+
type: i0.Input,
|
|
205
|
+
args: [{
|
|
206
|
+
isSignal: true,
|
|
207
|
+
alias: "selected",
|
|
208
|
+
required: false
|
|
209
|
+
}]
|
|
210
|
+
}, {
|
|
211
|
+
type: i0.Output,
|
|
212
|
+
args: ["selectedChange"]
|
|
213
|
+
}],
|
|
214
|
+
size: [{
|
|
215
|
+
type: i0.Input,
|
|
216
|
+
args: [{
|
|
217
|
+
isSignal: true,
|
|
218
|
+
alias: "size",
|
|
219
|
+
required: false
|
|
220
|
+
}]
|
|
221
|
+
}],
|
|
222
|
+
disabled: [{
|
|
223
|
+
type: i0.Input,
|
|
224
|
+
args: [{
|
|
225
|
+
isSignal: true,
|
|
226
|
+
alias: "disabled",
|
|
227
|
+
required: false
|
|
228
|
+
}]
|
|
229
|
+
}]
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
var CkChipGroup = class CkChipGroup {
|
|
233
|
+
element = inject(ElementRef).nativeElement;
|
|
234
|
+
constructor() {
|
|
235
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode && isPlatformBrowser(inject(PLATFORM_ID))) {
|
|
236
|
+
let destroyed = false;
|
|
237
|
+
inject(DestroyRef).onDestroy(() => destroyed = true);
|
|
238
|
+
afterNextRender(() => {
|
|
239
|
+
if (!destroyed && !hasAccessibleName(this.element, {
|
|
240
|
+
title: false,
|
|
241
|
+
text: false
|
|
242
|
+
})) console.warn("[ckui] ck-chip-group has no accessible name. Add an aria-label or aria-labelledby.", this.element);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
247
|
+
minVersion: "12.0.0",
|
|
248
|
+
version: "22.2.4",
|
|
249
|
+
ngImport: i0,
|
|
250
|
+
type: CkChipGroup,
|
|
251
|
+
deps: [],
|
|
252
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
253
|
+
});
|
|
254
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
255
|
+
minVersion: "14.0.0",
|
|
256
|
+
version: "22.2.4",
|
|
257
|
+
type: CkChipGroup,
|
|
258
|
+
isStandalone: true,
|
|
259
|
+
selector: "ck-chip-group",
|
|
260
|
+
host: {
|
|
261
|
+
attributes: { "role": "group" },
|
|
262
|
+
classAttribute: "ck-chip-group"
|
|
263
|
+
},
|
|
264
|
+
ngImport: i0,
|
|
265
|
+
template: "<ng-content />",
|
|
266
|
+
isInline: true,
|
|
267
|
+
styles: ["@layer ckui{.ck-chip-group{display:flex;flex-wrap:wrap;align-items:center;gap:var(--ck-chip-group-gap, var(--ck-space-2));min-inline-size:0}}\n"],
|
|
268
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
269
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
273
|
+
minVersion: "12.0.0",
|
|
274
|
+
version: "22.2.4",
|
|
275
|
+
ngImport: i0,
|
|
276
|
+
type: CkChipGroup,
|
|
277
|
+
decorators: [{
|
|
278
|
+
type: Component,
|
|
279
|
+
args: [{
|
|
280
|
+
selector: "ck-chip-group",
|
|
281
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
282
|
+
encapsulation: ViewEncapsulation.None,
|
|
283
|
+
host: {
|
|
284
|
+
class: "ck-chip-group",
|
|
285
|
+
role: "group"
|
|
286
|
+
},
|
|
287
|
+
template: "<ng-content />",
|
|
288
|
+
styles: ["@layer ckui{.ck-chip-group{display:flex;flex-wrap:wrap;align-items:center;gap:var(--ck-chip-group-gap, var(--ck-space-2));min-inline-size:0}}\n"]
|
|
289
|
+
}]
|
|
290
|
+
}],
|
|
291
|
+
ctorParameters: () => []
|
|
292
|
+
});
|
|
293
|
+
const CK_CHIP_IMPORTS = [
|
|
294
|
+
CkChip,
|
|
295
|
+
CkChipIcon,
|
|
296
|
+
CkChipGroup
|
|
297
|
+
];
|
|
298
|
+
export { CK_CHIP_IMPORTS, CkChip, CkChipGroup, CkChipIcon };
|
|
299
|
+
|
|
300
|
+
//# sourceMappingURL=ckui-core-chip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ckui-core-chip.mjs","names":[],"sources":["../../../../projects/core/chip/chip.ts","../../../../projects/core/chip/chip-group.ts","../../../../projects/core/chip/index.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n Renderer2,\n ViewEncapsulation,\n afterNextRender,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n model,\n} from '@angular/core';\nimport { CkSize } from '@ckui/core';\nimport { CkIcon, hasAccessibleName } from '@ckui/core/internal';\n\ndeclare const ngDevMode: unknown;\n\nexport type CkChipSize = CkSize;\n\nconst SIZES: readonly CkChipSize[] = ['sm', 'md', 'lg', 'xl'];\n\n/** Marks a projected element (usually an `svg`) as the chip's leading icon. It is decorative. */\n@Directive({\n selector: '[ckChipIcon]',\n host: { class: 'ck-chip__icon', 'aria-hidden': 'true' },\n})\nexport class CkChipIcon {}\n\n/**\n * A compact toggle button for filters: a native `<button>` with `aria-pressed`. Selected shows a\n * check before the label, so the state is never colour alone. Every native attribute stays\n * yours; `aria-pressed` belongs to the chip.\n */\n@Component({\n selector: 'button[ckChip]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n '[class]': 'modifierClasses()',\n '[class.ck-chip--selected]': '!!selected()',\n '[class.ck-chip--disabled]': 'disabled()',\n '[attr.aria-pressed]': 'selected() ? \"true\" : \"false\"',\n '(click)': 'toggle()',\n },\n imports: [CkIcon],\n template: `\n @if (selected()) {\n <ck-icon class=\"ck-chip__check\" name=\"check\" />\n }\n <ng-content select=\"[ckChipIcon]\" /><span class=\"ck-chip__label\"><ng-content /></span>\n `,\n styleUrl: './chip.css',\n})\nexport class CkChip {\n /** Whether the chip is on. Use `[(selected)]`. Only a click changes it from inside. */\n readonly selected = model(false);\n /** `sm`, `md`, `lg` or `xl`. An unknown value falls back to `sm`. */\n readonly size = input<CkChipSize>('sm');\n readonly disabled = input(false, { transform: booleanAttribute });\n\n private readonly element = inject<ElementRef<HTMLButtonElement>>(ElementRef).nativeElement;\n private readonly renderer = inject(Renderer2);\n\n protected readonly modifierClasses = computed(() => {\n const size = SIZES.includes(this.size()) ? this.size() : 'sm';\n return `ck-chip ck-chip--${size}`;\n });\n\n /** The consumer's own `disabled` attribute from before the chip wrote one; undefined while the chip writes none. */\n private consumerDisabled: string | null | undefined;\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n\n // A later `[type]` binding or a static type wins; only a missing type gets the default.\n if (!this.element.hasAttribute('type')) {\n this.renderer.setAttribute(this.element, 'type', 'button');\n }\n\n // Server-rendered markup already carries the disabled attribute the chip wrote.\n if (this.element.hasAttribute('data-ck-chip-disabled')) {\n this.consumerDisabled = null;\n }\n\n // Capture phase on the host runs before consumer (click) listeners.\n const blockClick = (event: Event): void => {\n if (this.disabled()) {\n event.preventDefault();\n event.stopImmediatePropagation();\n }\n };\n for (const type of ['click', 'auxclick']) {\n this.element.addEventListener(type, blockClick, { capture: true });\n destroyRef.onDestroy(() =>\n this.element.removeEventListener(type, blockClick, { capture: true }),\n );\n }\n\n effect(() => this.writeDisabled(this.disabled()));\n\n if (typeof ngDevMode !== 'undefined' && ngDevMode && isPlatformBrowser(inject(PLATFORM_ID))) {\n let destroyed = false;\n destroyRef.onDestroy(() => (destroyed = true));\n afterNextRender(() => {\n if (!destroyed && !hasAccessibleName(this.element, { title: true, text: true })) {\n console.warn(\n '[ckui] ckChip has no accessible name. Give it a label, an aria-label or an aria-labelledby.',\n this.element,\n );\n }\n });\n }\n }\n\n protected toggle(): void {\n if (this.disabled() || this.element.matches(':disabled')) {\n return;\n }\n this.selected.update((selected) => !selected);\n }\n\n /** Writes the native `disabled`, and gives the consumer's own value back when it turns off. */\n private writeDisabled(disabled: boolean): void {\n if (disabled) {\n if (this.consumerDisabled === undefined) {\n this.consumerDisabled = this.element.getAttribute('disabled');\n this.renderer.setAttribute(this.element, 'data-ck-chip-disabled', '');\n }\n this.renderer.setAttribute(this.element, 'disabled', '');\n } else if (this.consumerDisabled !== undefined) {\n const previous = this.consumerDisabled;\n this.consumerDisabled = undefined;\n this.renderer.removeAttribute(this.element, 'data-ck-chip-disabled');\n if (previous === null) {\n this.renderer.removeAttribute(this.element, 'disabled');\n } else {\n this.renderer.setAttribute(this.element, 'disabled', previous);\n }\n }\n }\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n PLATFORM_ID,\n ViewEncapsulation,\n afterNextRender,\n inject,\n} from '@angular/core';\nimport { hasAccessibleName } from '@ckui/core/internal';\n\ndeclare const ngDevMode: unknown;\n\n/**\n * A wrapping row of chips. It is a `group` and needs a name: `aria-label` or `aria-labelledby`.\n * The gap between the chips is `--ck-chip-group-gap`.\n */\n@Component({\n selector: 'ck-chip-group',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: { class: 'ck-chip-group', role: 'group' },\n template: '<ng-content />',\n styleUrl: './chip-group.css',\n})\nexport class CkChipGroup {\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\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 if (!destroyed && !hasAccessibleName(this.element, { title: false, text: false })) {\n console.warn(\n '[ckui] ck-chip-group has no accessible name. Add an aria-label or aria-labelledby.',\n this.element,\n );\n }\n });\n }\n }\n}\n","import { CkChip, CkChipIcon } from './chip';\nimport { CkChipGroup } from './chip-group';\n\nexport type { CkChipSize } from './chip';\nexport { CkChip, CkChipIcon } from './chip';\nexport { CkChipGroup } from './chip-group';\n\n/** Everything a template needs for chips: `imports: [CK_CHIP_IMPORTS]`. */\nexport const CK_CHIP_IMPORTS = [CkChip, CkChipIcon, CkChipGroup] as const;\n"],"mappings":";;;;AAyBA,MAAM,QAA+B;CAAC;CAAM;CAAM;CAAM;AAAI;AAO5D,IAAa,aAAb,MAAa,WAAU;CAAV,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MA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