@ckui/core 0.0.0-stage → 0.1.0-next.1
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/LICENSE +21 -0
- package/README.md +254 -2
- package/fesm2022/ckui-core-button.mjs +225 -0
- package/fesm2022/ckui-core-button.mjs.map +1 -0
- package/fesm2022/ckui-core-dialog.mjs +907 -0
- package/fesm2022/ckui-core-dialog.mjs.map +1 -0
- package/fesm2022/ckui-core-field.mjs +956 -0
- package/fesm2022/ckui-core-field.mjs.map +1 -0
- package/fesm2022/ckui-core-internal.mjs +965 -0
- package/fesm2022/ckui-core-internal.mjs.map +1 -0
- package/fesm2022/ckui-core-segmented.mjs +352 -0
- package/fesm2022/ckui-core-segmented.mjs.map +1 -0
- package/fesm2022/ckui-core-toast.mjs +883 -0
- package/fesm2022/ckui-core-toast.mjs.map +1 -0
- package/fesm2022/ckui-core.mjs +72 -0
- package/fesm2022/ckui-core.mjs.map +1 -0
- package/package.json +73 -3
- package/styles/base.css +23 -0
- package/styles/styles.css +3 -0
- package/styles/themes.css +146 -0
- package/styles/tokens.css +144 -0
- package/types/ckui-core-button.d.ts +58 -0
- package/types/ckui-core-dialog.d.ts +219 -0
- package/types/ckui-core-field.d.ts +142 -0
- package/types/ckui-core-internal.d.ts +238 -0
- package/types/ckui-core-segmented.d.ts +98 -0
- package/types/ckui-core-toast.d.ts +97 -0
- package/types/ckui-core.d.ts +29 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Christoph Kugler
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,255 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ckui/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Accessible, themeable Angular components that work equally well on phone and desktop.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @ckui/core@next @angular/cdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
0.1 is in prerelease (`next`). Pin an exact version (`npm install --save-exact @ckui/core@next`),
|
|
12
|
+
because prereleases can change between builds.
|
|
13
|
+
|
|
14
|
+
Peer dependencies: `@angular/common`, `@angular/core`, `@angular/forms` and `@angular/cdk`, all
|
|
15
|
+
`^22.2.0`.
|
|
16
|
+
|
|
17
|
+
## Styles
|
|
18
|
+
|
|
19
|
+
Import the stylesheet once, for example in `angular.json`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
"styles": ["node_modules/@ckui/core/styles/styles.css"]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
or in your global CSS: `@import '@ckui/core/styles.css';`
|
|
26
|
+
|
|
27
|
+
It only declares `--ck-*` custom properties and `.ck-*` classes, all inside `@layer ckui`, and
|
|
28
|
+
styles no element. Add the class `ck-root` to `<html>` to apply the font, text colour, background
|
|
29
|
+
and `color-scheme` (on `<body>`, `color-scheme` would not reach the viewport and scrollbars).
|
|
30
|
+
|
|
31
|
+
The light theme is the default and the dark theme follows `prefers-color-scheme`. Force a theme for
|
|
32
|
+
the whole page or any subtree with `data-ck-theme="light"` or `data-ck-theme="dark"`. Themes nest.
|
|
33
|
+
A nested theme switches only the tokens and `color-scheme`; to repaint the section, give it
|
|
34
|
+
`ck-root` as well (or your own `color` and `background` from the tokens).
|
|
35
|
+
|
|
36
|
+
A whole app look (colours, radii, font, focus ring) is one block of tokens in your own stylesheet, outside any layer, so it beats the library without `!important`. A theme with low-contrast lines must keep control and field boundaries at 3:1 itself (WCAG 1.4.11). The docs site has a copyable near-black example under Theming, Custom theme. Controls also read `--ck-color-control` and `--ck-color-control-border` (the secondary button) and `--ck-font-variant-numeric` (tabular numerals by default).
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { provideCkui } from '@ckui/core';
|
|
42
|
+
|
|
43
|
+
bootstrapApplication(App, {
|
|
44
|
+
providers: [
|
|
45
|
+
provideCkui({
|
|
46
|
+
size: 'md', // 'sm' | 'md' | 'lg' | 'xl', default 'md'
|
|
47
|
+
sheetBreakpoint: 640, // px; coarse pointer below this width uses sheets
|
|
48
|
+
labels: { close: 'Schließen' }, // or a Signal / () => Signal<Partial<CkLabels>>
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Built-in strings are a signal that resolves to the English defaults plus your overrides. Blank
|
|
55
|
+
values fall back to the default. To override them for one part of the app, provide `CK_LABELS`
|
|
56
|
+
yourself, as a `Signal<CkLabels>`, on that subtree's injector.
|
|
57
|
+
|
|
58
|
+
## Button
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { CkButton } from '@ckui/core/button';
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<button ckButton variant="primary">Save</button>
|
|
66
|
+
<button ckButton variant="ghost" [loading]="saving()">Send</button>
|
|
67
|
+
<button ckButton iconOnly aria-label="Close"><svg>...</svg></button>
|
|
68
|
+
<a ckButton routerLink="/settings">Settings</a>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`ckButton` styles a native `<button>` or `<a>`; there is no `<ck-button>` element, so `type`, `form`,
|
|
72
|
+
`aria-*` and `routerLink` stay on the real element. Inputs: `variant` (`'primary' | 'secondary' |
|
|
73
|
+
'ghost' | 'danger'`, default `secondary`), `size` (default from `provideCkui`), `iconOnly`,
|
|
74
|
+
`loading` and `disabled`. A button without a `type` gets `type="button"`. A loading button stays
|
|
75
|
+
focusable, ignores clicks and announces the `loading` label once; a disabled link gets
|
|
76
|
+
`aria-disabled` and leaves the tab order. An icon-only button needs an accessible name (development
|
|
77
|
+
builds warn). Component token: `--ck-button-radius`.
|
|
78
|
+
|
|
79
|
+
Global element styles: your own unlayered rules such as `a { color: … }` or
|
|
80
|
+
`a:hover { text-decoration: … }` beat the layered button, by design. Scope them with
|
|
81
|
+
`a:not(.ck-button)`, or put resets in a layer declared before ckui: `@layer reset, ckui;`.
|
|
82
|
+
|
|
83
|
+
## Field and input
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { CK_FIELD_IMPORTS } from '@ckui/core/field';
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<ck-field>
|
|
91
|
+
<label>Email</label>
|
|
92
|
+
<span ckPrefix>@</span>
|
|
93
|
+
<input ckInput type="email" autocomplete="email" formControlName="email" />
|
|
94
|
+
<button ckButton ckSuffix variant="ghost" iconOnly size="sm" aria-label="Clear">...</button>
|
|
95
|
+
<ck-hint>We only use it to send the receipt.</ck-hint>
|
|
96
|
+
<ck-error>Enter a valid email.</ck-error>
|
|
97
|
+
</ck-field>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`ck-field` wraps one native `<input>` or `<textarea>` marked with `ckInput` and draws the box, a
|
|
101
|
+
floating `<label>`, a hint, an error and prefix and suffix content. It works with Reactive Forms,
|
|
102
|
+
`ngModel` and Signal Forms (`[formField]`); there is no value accessor, the control stays native, so
|
|
103
|
+
`type`, `inputmode`, `enterkeyhint`, `autocomplete` and every other attribute stay on it. Inputs of
|
|
104
|
+
`ck-field`: `size` (default from `provideCkui`), `labelFloat` (`'auto' | 'always'`) and `invalid`
|
|
105
|
+
(`undefined` follows the control, `true` or `false` forces the state). Inputs of `textarea[ckInput]`:
|
|
106
|
+
`autosize`, `minRows` and `maxRows`. `ckInput` without a field draws its own box and takes a `size`.
|
|
107
|
+
|
|
108
|
+
The field links `<label for>` and the control `id`, merges the hint and error ids into
|
|
109
|
+
`aria-describedby` (your own tokens stay), sets `aria-invalid` while errors show and `aria-required`
|
|
110
|
+
for a required control, and puts the errors in one polite live region. A `<ck-error>` stays hidden
|
|
111
|
+
until the control is invalid and touched, or its form was submitted. The label floats while the
|
|
112
|
+
control is focused, has a value, a placeholder or an autofilled value, is a native date or time
|
|
113
|
+
control, or the field has a prefix. Under a coarse pointer the control is 44px high and its text is
|
|
114
|
+
at least 16px. Component tokens: `--ck-field-radius`, `--ck-field-bg`, `--ck-field-border-color`.
|
|
115
|
+
|
|
116
|
+
Linting: angular-eslint's `label-has-associated-control` flags `<ck-field><label>…</label><input ckInput>`
|
|
117
|
+
because the link is made at runtime. Either write `for` and `id` yourself (the field keeps both) or turn
|
|
118
|
+
the rule off for templates that use `ck-field`.
|
|
119
|
+
|
|
120
|
+
Global element styles: your own unlayered rules such as `input { font: … }` beat the layered field,
|
|
121
|
+
by design. Put resets in a layer declared before ckui: `@layer reset, ckui;`.
|
|
122
|
+
|
|
123
|
+
## Segmented control
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import { CK_SEGMENTED_IMPORTS } from '@ckui/core/segmented';
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```html
|
|
130
|
+
<ck-segmented aria-label="Calendar view" [(value)]="view">
|
|
131
|
+
<ck-segment value="day">Day</ck-segment>
|
|
132
|
+
<ck-segment value="week">Week</ck-segment>
|
|
133
|
+
<ck-segment value="month">Month</ck-segment>
|
|
134
|
+
</ck-segmented>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`ck-segmented` is one radio group of mutually exclusive options (`CkSegmented`, `CkSegment`). It is a
|
|
138
|
+
single tab stop; the arrow keys move and select (Left and Right swap in right-to-left text), `Home` and
|
|
139
|
+
`End` go to the first and last enabled segment, `Space` selects. It works with Reactive Forms,
|
|
140
|
+
`ngModel` and Signal Forms (`[formField]`) and with `[(value)]` on its own. Inputs of `ck-segmented`:
|
|
141
|
+
`value` (`T | null`; `null` selects nothing and hides the indicator), `size` (default from `provideCkui`),
|
|
142
|
+
`disabled` and `fullWidth`. Inputs of `ck-segment`: `value` (required) and `disabled`. A segment holds
|
|
143
|
+
text, a direct `svg` child (an icon, shown before the text), or both; font-icon elements land in the label. The group needs an `aria-label` or
|
|
144
|
+
`aria-labelledby`, and an icon-only segment needs an `aria-label` (development builds warn about both).
|
|
145
|
+
|
|
146
|
+
The group is as tall as the control height of its size and every segment is that tall to hit (44px for
|
|
147
|
+
`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`.
|
|
152
|
+
|
|
153
|
+
Global element styles: a global `:focus-visible { outline: … }` beats the layered control and draws a
|
|
154
|
+
second ring on the segment itself. Keep it off the segments (`:focus-visible:not(.ck-segment)`) or put
|
|
155
|
+
resets in a layer declared before ckui: `@layer reset, ckui;`.
|
|
156
|
+
|
|
157
|
+
## Toast
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
import { CkToast } from '@ckui/core/toast';
|
|
161
|
+
|
|
162
|
+
const toast = inject(CkToast);
|
|
163
|
+
const ref = toast.show({
|
|
164
|
+
tone: 'success',
|
|
165
|
+
title: 'Saved',
|
|
166
|
+
message: 'Your changes are stored.',
|
|
167
|
+
action: { label: 'Undo', run: () => restore() },
|
|
168
|
+
});
|
|
169
|
+
const reason = await ref.dismissed; // 'timeout' | 'user' | 'action' | 'replaced' | 'programmatic'
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`CkToast.show()` returns a `CkToastRef` (`dismiss()`, `update(partial)`, `dismissed`); `dismissAll()` closes
|
|
173
|
+
everything. Options: `message` (plain text), `title`, `tone` (`neutral`, `success`, `warning`, `danger`),
|
|
174
|
+
`action` (`{ label, run }`), `duration` (milliseconds) and `id`. A toast closes after 5 seconds, except one with
|
|
175
|
+
an `action` or the tone `danger`, which stays until dismissed unless you give a `duration`. The timer pauses
|
|
176
|
+
while the pointer is over the toast, while focus is inside it and while the page is hidden. Showing a toast with
|
|
177
|
+
the `id` of an open one replaces it in place and restarts the timer; the earlier ref reports `replaced`.
|
|
178
|
+
|
|
179
|
+
Every toast has a dismiss button and can be swiped away sideways. Each one is announced to screen readers
|
|
180
|
+
(`danger` assertively, the others politely, as title and message); changed text is announced again, nothing is
|
|
181
|
+
announced on the server. The toasts live in one `section` that is a direct child of `body`, exempt from `inert`
|
|
182
|
+
and painted above dialogs, so they stay clickable while a dialog is open.
|
|
183
|
+
|
|
184
|
+
`provideCkToast({ position, align, max, size })` is optional: `position` is `bottom` (default) or `top`, `align`
|
|
185
|
+
is `center` on a narrow screen and `end` otherwise unless you set it, `max` (default 3) is how many show at once
|
|
186
|
+
(the rest queue), and `size` is the size of the action and dismiss buttons (default from `provideCkui`; `xl` is
|
|
187
|
+
60px). The newest toast is always nearest the screen edge; safe-area insets are respected, and a narrow screen
|
|
188
|
+
gets the full width minus a `1rem` gutter. A toast that holds focus when it closes hands focus to the next toast,
|
|
189
|
+
else back to where it came from. Component tokens: `--ck-toast-bg` and `--ck-toast-fg` (neutral, success and
|
|
190
|
+
warning), `--ck-toast-danger-bg` and `--ck-toast-danger-fg`, `--ck-toast-radius`, `--ck-toast-max-width` and
|
|
191
|
+
`--ck-toast-shadow`.
|
|
192
|
+
|
|
193
|
+
Global element styles: a global `button:focus-visible { outline: … }` beats the layered toast buttons. Put
|
|
194
|
+
resets in a layer declared before ckui: `@layer reset, ckui;`.
|
|
195
|
+
|
|
196
|
+
## Dialog
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
import { CK_DIALOG_DATA, CK_DIALOG_IMPORTS, CkDialog, CkDialogRef } from '@ckui/core/dialog';
|
|
200
|
+
|
|
201
|
+
@Component({
|
|
202
|
+
imports: [CK_DIALOG_IMPORTS],
|
|
203
|
+
template: `
|
|
204
|
+
<h2 ckDialogTitle>Delete this workout?</h2>
|
|
205
|
+
<p ckDialogDescription>This cannot be undone.</p>
|
|
206
|
+
<ck-dialog-actions>
|
|
207
|
+
<button ckDialogInitialFocus ckDialogClose="keep">Keep it</button>
|
|
208
|
+
<button ckDialogClose="delete">Delete</button>
|
|
209
|
+
</ck-dialog-actions>
|
|
210
|
+
`,
|
|
211
|
+
})
|
|
212
|
+
class ConfirmDelete {}
|
|
213
|
+
|
|
214
|
+
const ref = inject(CkDialog).open<ConfirmDelete, void, 'keep' | 'delete'>(ConfirmDelete, {
|
|
215
|
+
role: 'alertdialog',
|
|
216
|
+
});
|
|
217
|
+
const answer = await ref.closed; // undefined when dismissed
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`CkDialog.open(componentOrTemplate, config)` returns a `CkDialogRef` (`close(result?)`, `closed`); `closeAll()`
|
|
221
|
+
closes everything. The content injects `CK_DIALOG_DATA` and `CkDialogRef`. Config: `data`, `role` (`dialog` or
|
|
222
|
+
`alertdialog`), `width` (`sm`, `md`, `lg`: 24, 32 or 48rem), `dismissible` (Escape, backdrop and swipe; default
|
|
223
|
+
`true`), `closeButton`, `mode` (`auto`, `modal`, `sheet`), `fullHeight`, `injector` and `ariaLabel`. A component dialog sees the providers of the app root; pass `injector: inject(Injector)` from the opener for route-level or component-level ones (`CK_DIALOG_DATA` and `CkDialogRef` are provided on top). `closed` resolves after
|
|
224
|
+
the dialog has left the screen, with the first result passed to `close()`; Escape, the backdrop, a swipe and
|
|
225
|
+
destroying the app resolve it with `undefined`.
|
|
226
|
+
|
|
227
|
+
The same dialog can be declared in a template: `<ck-dialog [(open)]="open" (closed)="onClosed($event)">` with one
|
|
228
|
+
`<ng-template>` inside, which is rendered only while the dialog is open. Building blocks: `ckDialogTitle` (names the
|
|
229
|
+
dialog), `ckDialogDescription`, `ck-dialog-body` (the only part that scrolls), `ck-dialog-actions`,
|
|
230
|
+
`ckDialogClose="result"` and `ckDialogInitialFocus`. Initial focus goes to the marked element, else the first
|
|
231
|
+
tabbable one of the content (never the close button), else the panel. Focus is trapped, the page behind is inert and
|
|
232
|
+
focus returns to the opener on close.
|
|
233
|
+
|
|
234
|
+
On a narrow screen with a coarse pointer (`mode: 'auto'`) the dialog is a bottom sheet as tall as its content, with a
|
|
235
|
+
swipe handle, stacked full-width actions and the safe-area inset; `fullHeight` makes it as tall as the screen allows.
|
|
236
|
+
Component tokens: `--ck-dialog-bg`, `--ck-dialog-radius`, `--ck-dialog-padding`, `--ck-dialog-max-width` and
|
|
237
|
+
`--ck-dialog-shadow`.
|
|
238
|
+
|
|
239
|
+
Global element styles: a global `h2`, `p` or `button:focus-visible` rule beats the layered dialog styles; scope it
|
|
240
|
+
with `:not(.ck-dialog__title)`, `:not(.ck-dialog__description)` and `:not(.ck-button)`, or put resets in a layer
|
|
241
|
+
declared before ckui: `@layer reset, ckui;`. A component opened through `CkDialog` must keep its host element a
|
|
242
|
+
flex column (the default styles do this); a global `display` on it stops the body from scrolling.
|
|
243
|
+
|
|
244
|
+
## Status
|
|
245
|
+
|
|
246
|
+
Pre-release. Version 0.1 is in progress and the API is not stable yet.
|
|
247
|
+
|
|
248
|
+
## Links
|
|
249
|
+
|
|
250
|
+
- Documentation: https://christophk93.github.io/ckui/
|
|
251
|
+
- Source and issues: https://github.com/ChristophK93/ckui
|
|
252
|
+
|
|
253
|
+
## Licence
|
|
254
|
+
|
|
255
|
+
MIT
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { isPlatformBrowser } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, PLATFORM_ID, Renderer2, ViewEncapsulation, afterNextRender, booleanAttribute, computed, effect, inject, input, untracked } from "@angular/core";
|
|
4
|
+
import { CK_CONFIG, CK_LABELS } from "@ckui/core";
|
|
5
|
+
import { CkAnnouncer, hasAccessibleName } from "@ckui/core/internal";
|
|
6
|
+
var CkButton = class CkButton {
|
|
7
|
+
variant = input("secondary", ...ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []);
|
|
8
|
+
size = input(void 0, ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
9
|
+
iconOnly = input(false, {
|
|
10
|
+
...ngDevMode ? { debugName: "iconOnly" } : /* istanbul ignore next */ {},
|
|
11
|
+
transform: booleanAttribute
|
|
12
|
+
});
|
|
13
|
+
loading = input(false, {
|
|
14
|
+
...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
|
|
15
|
+
transform: booleanAttribute
|
|
16
|
+
});
|
|
17
|
+
disabled = input(false, {
|
|
18
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
19
|
+
transform: booleanAttribute
|
|
20
|
+
});
|
|
21
|
+
element = inject(ElementRef).nativeElement;
|
|
22
|
+
renderer = inject(Renderer2);
|
|
23
|
+
config = inject(CK_CONFIG);
|
|
24
|
+
labels = inject(CK_LABELS);
|
|
25
|
+
announcer = inject(CkAnnouncer);
|
|
26
|
+
isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
27
|
+
isNativeButton = this.element.tagName === "BUTTON";
|
|
28
|
+
modifierClasses = computed(() => `ck-button--${this.variant()} ck-button--${this.size() ?? this.config.size}`, ...ngDevMode ? [{ debugName: "modifierClasses" }] : /* istanbul ignore next */ []);
|
|
29
|
+
overridden = /* @__PURE__ */ new Map();
|
|
30
|
+
previousLoading;
|
|
31
|
+
constructor() {
|
|
32
|
+
const destroyRef = inject(DestroyRef);
|
|
33
|
+
if (this.isNativeButton && !this.element.hasAttribute("type")) this.renderer.setAttribute(this.element, "type", "button");
|
|
34
|
+
const blockClick = (event) => {
|
|
35
|
+
if (this.loading() || this.disabled()) {
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
event.stopImmediatePropagation();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
for (const type of ["click", "auxclick"]) {
|
|
41
|
+
this.element.addEventListener(type, blockClick, { capture: true });
|
|
42
|
+
destroyRef.onDestroy(() => this.element.removeEventListener(type, blockClick, { capture: true }));
|
|
43
|
+
}
|
|
44
|
+
effect(() => {
|
|
45
|
+
const disabled = this.disabled();
|
|
46
|
+
const loading = this.loading();
|
|
47
|
+
const blockedLink = !this.isNativeButton && disabled;
|
|
48
|
+
this.override("disabled", this.isNativeButton && disabled ? "" : null);
|
|
49
|
+
this.override("aria-disabled", loading || blockedLink ? "true" : null);
|
|
50
|
+
this.override("tabindex", blockedLink ? "-1" : null);
|
|
51
|
+
});
|
|
52
|
+
effect(() => {
|
|
53
|
+
const loading = this.loading();
|
|
54
|
+
const started = this.previousLoading === false && loading;
|
|
55
|
+
this.previousLoading = loading;
|
|
56
|
+
if (started && this.isBrowser) {
|
|
57
|
+
const message = untracked(() => this.labels().loading);
|
|
58
|
+
this.announcer.announce(message);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
if (typeof ngDevMode !== "undefined" && ngDevMode) {
|
|
62
|
+
let destroyed = false;
|
|
63
|
+
destroyRef.onDestroy(() => destroyed = true);
|
|
64
|
+
afterNextRender(() => {
|
|
65
|
+
if (!destroyed && this.iconOnly() && !hasAccessibleName(this.element, {
|
|
66
|
+
title: true,
|
|
67
|
+
text: true
|
|
68
|
+
})) console.warn("[ckui] ckButton with iconOnly has no accessible name. Add an aria-label, aria-labelledby or title.", this.element);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
override(name, value) {
|
|
73
|
+
if (value !== null) {
|
|
74
|
+
if (!this.overridden.has(name)) this.overridden.set(name, this.element.getAttribute(name));
|
|
75
|
+
this.renderer.setAttribute(this.element, name, value);
|
|
76
|
+
} else if (this.overridden.has(name)) {
|
|
77
|
+
const previous = this.overridden.get(name) ?? null;
|
|
78
|
+
this.overridden.delete(name);
|
|
79
|
+
if (previous === null) this.renderer.removeAttribute(this.element, name);
|
|
80
|
+
else this.renderer.setAttribute(this.element, name, previous);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
84
|
+
minVersion: "12.0.0",
|
|
85
|
+
version: "22.2.4",
|
|
86
|
+
ngImport: i0,
|
|
87
|
+
type: CkButton,
|
|
88
|
+
deps: [],
|
|
89
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
90
|
+
});
|
|
91
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
92
|
+
minVersion: "17.1.0",
|
|
93
|
+
version: "22.2.4",
|
|
94
|
+
type: CkButton,
|
|
95
|
+
isStandalone: true,
|
|
96
|
+
selector: "button[ckButton], a[ckButton]",
|
|
97
|
+
inputs: {
|
|
98
|
+
variant: {
|
|
99
|
+
classPropertyName: "variant",
|
|
100
|
+
publicName: "variant",
|
|
101
|
+
isSignal: true,
|
|
102
|
+
isRequired: false,
|
|
103
|
+
transformFunction: null
|
|
104
|
+
},
|
|
105
|
+
size: {
|
|
106
|
+
classPropertyName: "size",
|
|
107
|
+
publicName: "size",
|
|
108
|
+
isSignal: true,
|
|
109
|
+
isRequired: false,
|
|
110
|
+
transformFunction: null
|
|
111
|
+
},
|
|
112
|
+
iconOnly: {
|
|
113
|
+
classPropertyName: "iconOnly",
|
|
114
|
+
publicName: "iconOnly",
|
|
115
|
+
isSignal: true,
|
|
116
|
+
isRequired: false,
|
|
117
|
+
transformFunction: null
|
|
118
|
+
},
|
|
119
|
+
loading: {
|
|
120
|
+
classPropertyName: "loading",
|
|
121
|
+
publicName: "loading",
|
|
122
|
+
isSignal: true,
|
|
123
|
+
isRequired: false,
|
|
124
|
+
transformFunction: null
|
|
125
|
+
},
|
|
126
|
+
disabled: {
|
|
127
|
+
classPropertyName: "disabled",
|
|
128
|
+
publicName: "disabled",
|
|
129
|
+
isSignal: true,
|
|
130
|
+
isRequired: false,
|
|
131
|
+
transformFunction: null
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
host: {
|
|
135
|
+
properties: {
|
|
136
|
+
"class": "modifierClasses()",
|
|
137
|
+
"class.ck-button--icon-only": "iconOnly()",
|
|
138
|
+
"class.ck-button--loading": "loading()",
|
|
139
|
+
"class.ck-button--disabled": "disabled()"
|
|
140
|
+
},
|
|
141
|
+
classAttribute: "ck-button"
|
|
142
|
+
},
|
|
143
|
+
ngImport: i0,
|
|
144
|
+
template: `
|
|
145
|
+
<span class="ck-button__content"><ng-content /></span>
|
|
146
|
+
<span class="ck-button__spinner" aria-hidden="true"></span>
|
|
147
|
+
`,
|
|
148
|
+
isInline: true,
|
|
149
|
+
styles: ["@layer ckui{.ck-button{position:relative;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;max-inline-size:100%;margin:0;border:1px solid transparent;border-radius:var(--ck-button-radius, var(--ck-control-radius));color-scheme:var(--ck-color-scheme);font-family:inherit;font-variant-numeric:var(--ck-font-variant-numeric);font-weight:var(--ck-font-weight-medium);line-height:var(--ck-line-height-tight);text-align:center;text-decoration:none;overflow-wrap:break-word;cursor:pointer;touch-action:manipulation;transition:background-color var(--ck-duration-fast) var(--ck-ease-standard)}.ck-button--sm{min-block-size:var(--ck-control-height-sm);padding-block:var(--ck-space-1);padding-inline:var(--ck-control-padding-inline-sm);font-size:var(--ck-control-font-size-sm)}.ck-button--md{min-block-size:var(--ck-control-height-md);padding-block:var(--ck-space-1);padding-inline:var(--ck-control-padding-inline-md);font-size:var(--ck-control-font-size-md)}.ck-button--lg{min-block-size:var(--ck-control-height-lg);padding-block:var(--ck-space-1);padding-inline:var(--ck-control-padding-inline-lg);font-size:var(--ck-control-font-size-lg)}.ck-button--xl{min-block-size:var(--ck-control-height-xl);padding-block:var(--ck-space-1);padding-inline:var(--ck-control-padding-inline-xl);font-size:var(--ck-control-font-size-xl)}.ck-button--icon-only{padding-inline:0}.ck-button--icon-only.ck-button--sm{inline-size:var(--ck-control-height-sm)}.ck-button--icon-only.ck-button--md{inline-size:var(--ck-control-height-md)}.ck-button--icon-only.ck-button--lg{inline-size:var(--ck-control-height-lg)}.ck-button--icon-only.ck-button--xl{inline-size:var(--ck-control-height-xl)}.ck-button__content{display:inline-flex;align-items:center;justify-content:center;gap:var(--ck-space-2);min-inline-size:0}.ck-button__content>svg,.ck-button__content>*>svg{flex:none;inline-size:1em;block-size:1em;color:currentColor}.ck-button--primary{background:var(--ck-color-primary);color:var(--ck-color-on-primary)}.ck-button--danger{background:var(--ck-color-danger);color:var(--ck-color-on-danger)}.ck-button--secondary{border-color:var(--ck-color-control-border);background:var(--ck-color-control);color:var(--ck-color-fg)}.ck-button--ghost{background:transparent;color:var(--ck-color-primary-fg)}@media(hover:hover){.ck-button--primary:hover{background:var(--ck-color-primary-hover)}.ck-button--danger:hover{background:var(--ck-color-danger-hover)}.ck-button--secondary:hover{background-image:linear-gradient(var(--ck-color-surface-hover),var(--ck-color-surface-hover))}.ck-button--ghost:hover{background:var(--ck-color-surface-hover)}}.ck-button--primary:active{background:var(--ck-color-primary-active)}.ck-button--danger:active{background:var(--ck-color-danger-active)}.ck-button--secondary:active{background-image:linear-gradient(var(--ck-color-surface-active),var(--ck-color-surface-active))}.ck-button--ghost:active{background:var(--ck-color-surface-active)}.ck-button:focus-visible{outline:var(--ck-focus-ring);outline-offset:var(--ck-focus-ring-offset)}.ck-button--loading{cursor:progress}.ck-button--loading .ck-button__content{opacity:0}.ck-button__spinner{display:none;position:absolute;inset-block-start:50%;inset-inline-start:50%;box-sizing:border-box;inline-size:1.25em;block-size:1.25em;margin-block-start:-.625em;margin-inline-start:-.625em;border:.15em solid color-mix(in oklch,currentColor 30%,transparent);border-block-start-color:currentColor;border-radius:var(--ck-radius-full);animation:ck-button-spin calc(var(--ck-duration-slow) * 3) linear infinite}.ck-button--loading .ck-button__spinner{display:block}:is(.ck-button--disabled,.ck-button:disabled),:is(.ck-button--disabled,.ck-button:disabled):hover,:is(.ck-button--disabled,.ck-button:disabled):active{border-color:transparent;background:var(--ck-color-surface-hover);color:var(--ck-color-fg-disabled);cursor:not-allowed}.ck-button--ghost:is(.ck-button--disabled,:disabled),.ck-button--ghost:is(.ck-button--disabled,:disabled):hover,.ck-button--ghost:is(.ck-button--disabled,:disabled):active{background:transparent}@keyframes ck-button-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.ck-button__spinner{animation:none}}@media(forced-colors:active){.ck-button{border-color:ButtonText}:is(.ck-button--disabled,.ck-button:disabled),:is(.ck-button--disabled,.ck-button:disabled):hover,:is(.ck-button--disabled,.ck-button:disabled):active{border-color:GrayText;color:GrayText}.ck-button__spinner{border-color:ButtonText;border-block-start-color:Highlight}}}\n"],
|
|
150
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
151
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
155
|
+
minVersion: "12.0.0",
|
|
156
|
+
version: "22.2.4",
|
|
157
|
+
ngImport: i0,
|
|
158
|
+
type: CkButton,
|
|
159
|
+
decorators: [{
|
|
160
|
+
type: Component,
|
|
161
|
+
args: [{
|
|
162
|
+
selector: "button[ckButton], a[ckButton]",
|
|
163
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
164
|
+
encapsulation: ViewEncapsulation.None,
|
|
165
|
+
host: {
|
|
166
|
+
class: "ck-button",
|
|
167
|
+
"[class]": "modifierClasses()",
|
|
168
|
+
"[class.ck-button--icon-only]": "iconOnly()",
|
|
169
|
+
"[class.ck-button--loading]": "loading()",
|
|
170
|
+
"[class.ck-button--disabled]": "disabled()"
|
|
171
|
+
},
|
|
172
|
+
template: `
|
|
173
|
+
<span class="ck-button__content"><ng-content /></span>
|
|
174
|
+
<span class="ck-button__spinner" aria-hidden="true"></span>
|
|
175
|
+
`,
|
|
176
|
+
styles: ["@layer ckui{.ck-button{position:relative;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;max-inline-size:100%;margin:0;border:1px solid transparent;border-radius:var(--ck-button-radius, var(--ck-control-radius));color-scheme:var(--ck-color-scheme);font-family:inherit;font-variant-numeric:var(--ck-font-variant-numeric);font-weight:var(--ck-font-weight-medium);line-height:var(--ck-line-height-tight);text-align:center;text-decoration:none;overflow-wrap:break-word;cursor:pointer;touch-action:manipulation;transition:background-color var(--ck-duration-fast) var(--ck-ease-standard)}.ck-button--sm{min-block-size:var(--ck-control-height-sm);padding-block:var(--ck-space-1);padding-inline:var(--ck-control-padding-inline-sm);font-size:var(--ck-control-font-size-sm)}.ck-button--md{min-block-size:var(--ck-control-height-md);padding-block:var(--ck-space-1);padding-inline:var(--ck-control-padding-inline-md);font-size:var(--ck-control-font-size-md)}.ck-button--lg{min-block-size:var(--ck-control-height-lg);padding-block:var(--ck-space-1);padding-inline:var(--ck-control-padding-inline-lg);font-size:var(--ck-control-font-size-lg)}.ck-button--xl{min-block-size:var(--ck-control-height-xl);padding-block:var(--ck-space-1);padding-inline:var(--ck-control-padding-inline-xl);font-size:var(--ck-control-font-size-xl)}.ck-button--icon-only{padding-inline:0}.ck-button--icon-only.ck-button--sm{inline-size:var(--ck-control-height-sm)}.ck-button--icon-only.ck-button--md{inline-size:var(--ck-control-height-md)}.ck-button--icon-only.ck-button--lg{inline-size:var(--ck-control-height-lg)}.ck-button--icon-only.ck-button--xl{inline-size:var(--ck-control-height-xl)}.ck-button__content{display:inline-flex;align-items:center;justify-content:center;gap:var(--ck-space-2);min-inline-size:0}.ck-button__content>svg,.ck-button__content>*>svg{flex:none;inline-size:1em;block-size:1em;color:currentColor}.ck-button--primary{background:var(--ck-color-primary);color:var(--ck-color-on-primary)}.ck-button--danger{background:var(--ck-color-danger);color:var(--ck-color-on-danger)}.ck-button--secondary{border-color:var(--ck-color-control-border);background:var(--ck-color-control);color:var(--ck-color-fg)}.ck-button--ghost{background:transparent;color:var(--ck-color-primary-fg)}@media(hover:hover){.ck-button--primary:hover{background:var(--ck-color-primary-hover)}.ck-button--danger:hover{background:var(--ck-color-danger-hover)}.ck-button--secondary:hover{background-image:linear-gradient(var(--ck-color-surface-hover),var(--ck-color-surface-hover))}.ck-button--ghost:hover{background:var(--ck-color-surface-hover)}}.ck-button--primary:active{background:var(--ck-color-primary-active)}.ck-button--danger:active{background:var(--ck-color-danger-active)}.ck-button--secondary:active{background-image:linear-gradient(var(--ck-color-surface-active),var(--ck-color-surface-active))}.ck-button--ghost:active{background:var(--ck-color-surface-active)}.ck-button:focus-visible{outline:var(--ck-focus-ring);outline-offset:var(--ck-focus-ring-offset)}.ck-button--loading{cursor:progress}.ck-button--loading .ck-button__content{opacity:0}.ck-button__spinner{display:none;position:absolute;inset-block-start:50%;inset-inline-start:50%;box-sizing:border-box;inline-size:1.25em;block-size:1.25em;margin-block-start:-.625em;margin-inline-start:-.625em;border:.15em solid color-mix(in oklch,currentColor 30%,transparent);border-block-start-color:currentColor;border-radius:var(--ck-radius-full);animation:ck-button-spin calc(var(--ck-duration-slow) * 3) linear infinite}.ck-button--loading .ck-button__spinner{display:block}:is(.ck-button--disabled,.ck-button:disabled),:is(.ck-button--disabled,.ck-button:disabled):hover,:is(.ck-button--disabled,.ck-button:disabled):active{border-color:transparent;background:var(--ck-color-surface-hover);color:var(--ck-color-fg-disabled);cursor:not-allowed}.ck-button--ghost:is(.ck-button--disabled,:disabled),.ck-button--ghost:is(.ck-button--disabled,:disabled):hover,.ck-button--ghost:is(.ck-button--disabled,:disabled):active{background:transparent}@keyframes ck-button-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.ck-button__spinner{animation:none}}@media(forced-colors:active){.ck-button{border-color:ButtonText}:is(.ck-button--disabled,.ck-button:disabled),:is(.ck-button--disabled,.ck-button:disabled):hover,:is(.ck-button--disabled,.ck-button:disabled):active{border-color:GrayText;color:GrayText}.ck-button__spinner{border-color:ButtonText;border-block-start-color:Highlight}}}\n"]
|
|
177
|
+
}]
|
|
178
|
+
}],
|
|
179
|
+
ctorParameters: () => [],
|
|
180
|
+
propDecorators: {
|
|
181
|
+
variant: [{
|
|
182
|
+
type: i0.Input,
|
|
183
|
+
args: [{
|
|
184
|
+
isSignal: true,
|
|
185
|
+
alias: "variant",
|
|
186
|
+
required: false
|
|
187
|
+
}]
|
|
188
|
+
}],
|
|
189
|
+
size: [{
|
|
190
|
+
type: i0.Input,
|
|
191
|
+
args: [{
|
|
192
|
+
isSignal: true,
|
|
193
|
+
alias: "size",
|
|
194
|
+
required: false
|
|
195
|
+
}]
|
|
196
|
+
}],
|
|
197
|
+
iconOnly: [{
|
|
198
|
+
type: i0.Input,
|
|
199
|
+
args: [{
|
|
200
|
+
isSignal: true,
|
|
201
|
+
alias: "iconOnly",
|
|
202
|
+
required: false
|
|
203
|
+
}]
|
|
204
|
+
}],
|
|
205
|
+
loading: [{
|
|
206
|
+
type: i0.Input,
|
|
207
|
+
args: [{
|
|
208
|
+
isSignal: true,
|
|
209
|
+
alias: "loading",
|
|
210
|
+
required: false
|
|
211
|
+
}]
|
|
212
|
+
}],
|
|
213
|
+
disabled: [{
|
|
214
|
+
type: i0.Input,
|
|
215
|
+
args: [{
|
|
216
|
+
isSignal: true,
|
|
217
|
+
alias: "disabled",
|
|
218
|
+
required: false
|
|
219
|
+
}]
|
|
220
|
+
}]
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
export { CkButton };
|
|
224
|
+
|
|
225
|
+
//# sourceMappingURL=ckui-core-button.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ckui-core-button.mjs","names":[],"sources":["../../../../projects/core/button/button.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n DestroyRef,\n ElementRef,\n PLATFORM_ID,\n Renderer2,\n ViewEncapsulation,\n afterNextRender,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n untracked,\n} from '@angular/core';\nimport { CK_CONFIG, CK_LABELS, CkSize } from '@ckui/core';\nimport { CkAnnouncer, hasAccessibleName } from '@ckui/core/internal';\n\ndeclare const ngDevMode: unknown;\n\nexport type CkButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';\n\n/**\n * Styles a native `<button>` or `<a>` as a button. The element keeps every native attribute\n * (`type`, `form`, `aria-*`, `routerLink`); there is no `<ck-button>` element.\n */\n@Component({\n selector: 'button[ckButton], a[ckButton]',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'ck-button',\n '[class]': 'modifierClasses()',\n '[class.ck-button--icon-only]': 'iconOnly()',\n '[class.ck-button--loading]': 'loading()',\n '[class.ck-button--disabled]': 'disabled()',\n },\n template: `\n <span class=\"ck-button__content\"><ng-content /></span>\n <span class=\"ck-button__spinner\" aria-hidden=\"true\"></span>\n `,\n styleUrl: './button.css',\n})\nexport class CkButton {\n readonly variant = input<CkButtonVariant>('secondary');\n /** `undefined` uses the size from `provideCkui`. */\n readonly size = input<CkSize | undefined>(undefined);\n readonly iconOnly = input(false, { transform: booleanAttribute });\n readonly loading = input(false, { transform: booleanAttribute });\n readonly disabled = input(false, { transform: booleanAttribute });\n\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n private readonly renderer = inject(Renderer2);\n private readonly config = inject(CK_CONFIG);\n private readonly labels = inject(CK_LABELS);\n private readonly announcer = inject(CkAnnouncer);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly isNativeButton = this.element.tagName === 'BUTTON';\n\n protected readonly modifierClasses = computed(\n () => `ck-button--${this.variant()} ck-button--${this.size() ?? this.config.size}`,\n );\n\n /** The consumer's own value of every attribute this component currently overrides. */\n private readonly overridden = new Map<string, string | null>();\n private previousLoading: boolean | 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.isNativeButton && !this.element.hasAttribute('type')) {\n this.renderer.setAttribute(this.element, 'type', 'button');\n }\n\n // Capture phase on the host runs before routerLink and consumer (click) listeners.\n const blockClick = (event: Event): void => {\n if (this.loading() || 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(() => {\n const disabled = this.disabled();\n const loading = this.loading();\n const blockedLink = !this.isNativeButton && disabled;\n this.override('disabled', this.isNativeButton && disabled ? '' : null);\n this.override('aria-disabled', loading || blockedLink ? 'true' : null);\n this.override('tabindex', blockedLink ? '-1' : null);\n });\n\n effect(() => {\n const loading = this.loading();\n const started = this.previousLoading === false && loading;\n this.previousLoading = loading;\n if (started && this.isBrowser) {\n const message = untracked(() => this.labels().loading);\n void this.announcer.announce(message);\n }\n });\n\n if (typeof ngDevMode !== 'undefined' && ngDevMode) {\n let destroyed = false;\n destroyRef.onDestroy(() => (destroyed = true));\n afterNextRender(() => {\n if (\n !destroyed &&\n this.iconOnly() &&\n !hasAccessibleName(this.element, { title: true, text: true })\n ) {\n console.warn(\n '[ckui] ckButton with iconOnly has no accessible name. Add an aria-label, aria-labelledby or title.',\n this.element,\n );\n }\n });\n }\n }\n\n /** Sets the attribute, or gives the consumer's own value back when `value` is null. */\n private override(name: string, value: string | null): void {\n if (value !== null) {\n if (!this.overridden.has(name)) {\n this.overridden.set(name, this.element.getAttribute(name));\n }\n this.renderer.setAttribute(this.element, name, value);\n } else if (this.overridden.has(name)) {\n const previous = this.overridden.get(name) ?? null;\n this.overridden.delete(name);\n if (previous === null) {\n this.renderer.removeAttribute(this.element, name);\n } else {\n this.renderer.setAttribute(this.element, name, previous);\n }\n }\n }\n}\n"],"mappings":";;;;;AA6CA,IAAa,WAAb,MAAa,SAAQ;CACV,UAAU,MAAuB,aAAY,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAE7C,OAAO,MAA0B,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAC3C,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAgB,CAAA;CACrD,UAAU,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EAAI,WAAW;CAAgB,CAAA;CACpD,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAgB,CAAA;CAE7C,UAAU,OAAgC,UAAU,CAAC,CAAC;CACtD,WAAW,OAAO,SAAS;CAC3B,SAAS,OAAO,SAAS;CACzB,SAAS,OAAO,SAAS;CACzB,YAAY,OAAO,WAAW;CAC9B,YAAY,kBAAkB,OAAO,WAAW,CAAC;CACjD,iBAAiB,KAAK,QAAQ,YAAY;CAExC,kBAAkB,eAC7B,cAAc,KAAK,QAAO,EAAE,cAAe,KAAK,KAAI,KA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