@luxalgo/vela-ui 0.1.0 → 0.2.0
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/CHANGELOG.md +48 -0
- package/README.md +5 -2
- package/dist/badge.js +2 -2
- package/dist/bar-chart.d.ts +1 -1
- package/dist/bar-chart.js +2 -2
- package/dist/button.d.ts +18 -4
- package/dist/button.js +4 -3
- package/dist/calendar.d.ts +3 -1
- package/dist/calendar.js +1 -1
- package/dist/callout-bubble.d.ts +7 -2
- package/dist/callout-bubble.js +12 -8
- package/dist/checkbox.js +4 -4
- package/dist/{chunk-SAPURP46.js → chunk-7VMN7NKJ.js} +3 -3
- package/dist/{chunk-OBLIX3VN.js → chunk-B5ZSRUDQ.js} +3 -3
- package/dist/{chunk-6NXY62JS.js → chunk-C3ICYMI3.js} +2 -2
- package/dist/chunk-CC3DDNFC.js +117 -0
- package/dist/{chunk-FCO3YZLT.js → chunk-E2FE6V2N.js} +2 -2
- package/dist/{chunk-V6TTTMTE.js → chunk-GVRX3UAV.js} +4 -1
- package/dist/{chunk-2Q4JRINP.js → chunk-MJ4RUGX7.js} +4 -4
- package/dist/{chunk-X4YPSIW6.js → chunk-U3EH42YY.js} +2 -2
- package/dist/{chunk-AJ2IYSOI.js → chunk-V2Q4MRMS.js} +23 -3
- package/dist/{chunk-XJAPCCOJ.js → chunk-WBGSYCV2.js} +3 -3
- package/dist/{chunk-5QHXOAZA.js → chunk-WGULXRWD.js} +4 -4
- package/dist/{chunk-ZB3BZHSN.js → chunk-WXH3EFV5.js} +3 -3
- package/dist/chunk-XBEL4K33.js +142 -0
- package/dist/{chunk-CH3DV6FD.js → chunk-Z5PINFQO.js} +4 -4
- package/dist/collapsible.d.ts +49 -0
- package/dist/collapsible.js +106 -0
- package/dist/color-picker.js +6 -6
- package/dist/context-menu.js +5 -5
- package/dist/css.d.ts +3 -1
- package/dist/css.js +1 -1
- package/dist/data-table.d.ts +39 -2
- package/dist/data-table.js +2 -2
- package/dist/date-picker.d.ts +1 -1
- package/dist/date-picker.js +3 -3
- package/dist/dialog.d.ts +1 -1
- package/dist/dialog.js +5 -5
- package/dist/donut.d.ts +1 -1
- package/dist/donut.js +2 -2
- package/dist/drawer.d.ts +1 -1
- package/dist/drawer.js +3 -3
- package/dist/dropdown-menu.d.ts +1 -1
- package/dist/dropdown-menu.js +4 -4
- package/dist/empty.d.ts +1 -1
- package/dist/empty.js +2 -2
- package/dist/field.js +12 -12
- package/dist/glyph-select.js +5 -5
- package/dist/h-Bl37qUis.d.ts +24 -0
- package/dist/hover-card.d.ts +1 -1
- package/dist/hover-card.js +3 -3
- package/dist/index.d.ts +7 -1
- package/dist/index.js +3 -3
- package/dist/input-group.d.ts +1 -1
- package/dist/input-group.js +4 -3
- package/dist/input.js +3 -3
- package/dist/item.d.ts +72 -0
- package/dist/item.js +131 -0
- package/dist/kbd.d.ts +1 -1
- package/dist/kbd.js +3 -3
- package/dist/line-chart.d.ts +1 -1
- package/dist/line-chart.js +2 -2
- package/dist/manifest.json +665 -11
- package/dist/month-grid.d.ts +45 -0
- package/dist/month-grid.js +157 -0
- package/dist/number-input.d.ts +1 -1
- package/dist/number-input.js +4 -4
- package/dist/popover.js +4 -4
- package/dist/scatter-chart.d.ts +1 -1
- package/dist/scatter-chart.js +2 -2
- package/dist/select.js +6 -6
- package/dist/slider.d.ts +46 -0
- package/dist/slider.js +111 -0
- package/dist/sort-button.d.ts +41 -0
- package/dist/sort-button.js +88 -0
- package/dist/sparkline.d.ts +1 -1
- package/dist/sparkline.js +2 -2
- package/dist/stat.d.ts +1 -1
- package/dist/stat.js +2 -2
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +3 -3
- package/dist/tabs.d.ts +3 -1
- package/dist/tabs.js +12 -7
- package/dist/text-area.d.ts +1 -1
- package/dist/text-area.js +3 -3
- package/dist/theme.d.ts +17 -6
- package/dist/theme.js +2 -2
- package/dist/theme.schema.json +250 -1
- package/dist/toggle-group.d.ts +1 -1
- package/dist/toggle-group.js +3 -3
- package/dist/tooltip.js +3 -3
- package/docs/theming.md +6 -0
- package/docs/writing-a-component.md +4 -1
- package/llms.txt +8 -3
- package/package.json +1 -1
- package/registry/button.ts +97 -21
- package/registry/callout-bubble.ts +14 -3
- package/registry/collapsible.ts +271 -0
- package/registry/dropdown-menu.ts +3 -3
- package/registry/item.ts +376 -0
- package/registry/month-grid.ts +328 -0
- package/registry/slider.ts +259 -0
- package/registry/sort-button.ts +189 -0
- package/registry/tabs.ts +38 -4
- package/skills/using-vela-ui-components/SKILL.md +12 -9
- package/src/components/button.ts +97 -21
- package/src/components/callout-bubble.ts +14 -3
- package/src/components/collapsible.ts +271 -0
- package/src/components/dropdown-menu.ts +3 -3
- package/src/components/item.ts +376 -0
- package/src/components/month-grid.ts +328 -0
- package/src/components/slider.ts +259 -0
- package/src/components/sort-button.ts +189 -0
- package/src/components/tabs.ts +38 -4
- package/src/lib/calendar.ts +5 -0
- package/src/lib/component-index.ts +22 -2
- package/src/lib/css.ts +6 -2
- package/src/lib/scope.ts +135 -0
- package/src/lib/theme.ts +15 -5
- package/dist/chunk-EZQXTO6K.js +0 -89
- package/dist/chunk-IDA2BT7D.js +0 -29
- package/dist/data-table-DtU3FX9j.d.ts +0 -61
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// SortButton: the header of a column that sorts a list which is not a table (a watchlist's
|
|
2
|
+
// Last and Day %). A press steps the sort: `firstDirection`, the other direction, then none
|
|
3
|
+
// when `clearable`. An arrow shows the direction, and a screen reader hears it after the
|
|
4
|
+
// label. Several of them sort one list: the host keeps one sorted and clears the others with
|
|
5
|
+
// `setDirection(null)`.
|
|
6
|
+
import { css, defineStyles } from '../lib/css';
|
|
7
|
+
import { defineComponent } from '../lib/define';
|
|
8
|
+
import { msg, textOf, type Translator } from '../lib/i18n';
|
|
9
|
+
import { h } from '../lib/h';
|
|
10
|
+
import { iconEl } from '../lib/icons';
|
|
11
|
+
import { kitTranslator } from '../lib/kit-text';
|
|
12
|
+
import { t } from '../lib/t';
|
|
13
|
+
import { variants, type VariantProps } from '../lib/variants';
|
|
14
|
+
import { nextUid } from '../lib/zag';
|
|
15
|
+
|
|
16
|
+
export const sortButtonDef = defineComponent({
|
|
17
|
+
name: 'sort-button',
|
|
18
|
+
parts: ['root', 'icon', 'state'],
|
|
19
|
+
settings: { radius: t.radius.sm },
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const sortButtonVariants = variants({ align: ['start', 'end'] });
|
|
23
|
+
|
|
24
|
+
export type SortDirection = 'asc' | 'desc';
|
|
25
|
+
|
|
26
|
+
export interface SortButtonProps extends VariantProps<typeof sortButtonVariants> {
|
|
27
|
+
/** The column's name. */
|
|
28
|
+
label: string;
|
|
29
|
+
/** The sort it starts with (default none). */
|
|
30
|
+
direction?: SortDirection | null;
|
|
31
|
+
/** What the first press sorts by (default `desc`: the largest first). */
|
|
32
|
+
firstDirection?: SortDirection;
|
|
33
|
+
/** A press after both directions clears the sort (default true). */
|
|
34
|
+
clearable?: boolean;
|
|
35
|
+
/** A press changed the sort; null: unsorted. */
|
|
36
|
+
onSortChange?: (direction: SortDirection | null) => void;
|
|
37
|
+
/** A tooltip (`Sort by Last`). */
|
|
38
|
+
title?: string;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/** The translator of the words a screen reader hears ("sorted ascending"). Default: the
|
|
41
|
+
* kit build's, else English. */
|
|
42
|
+
i18n?: Translator;
|
|
43
|
+
/** Extra class names (layout hooks). */
|
|
44
|
+
className?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface SortButtonHandle {
|
|
48
|
+
readonly el: HTMLButtonElement;
|
|
49
|
+
readonly direction: SortDirection | null;
|
|
50
|
+
/** Show a sort without calling `onSortChange`. */
|
|
51
|
+
setDirection(direction: SortDirection | null): void;
|
|
52
|
+
setDisabled(disabled: boolean): void;
|
|
53
|
+
destroy(): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const TEXT = {
|
|
57
|
+
asc: msg('ui.sortButton.ascending', 'sorted ascending'),
|
|
58
|
+
desc: msg('ui.sortButton.descending', 'sorted descending'),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const injectStyles = defineStyles(
|
|
62
|
+
'vela-ui-sort-button',
|
|
63
|
+
css`
|
|
64
|
+
@layer vela.ui {
|
|
65
|
+
[data-slot='sort-button']:where(:not([hidden])) {
|
|
66
|
+
all: unset;
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
gap: 3px;
|
|
71
|
+
max-width: 100%;
|
|
72
|
+
border-radius: ${sortButtonDef.vars.radius};
|
|
73
|
+
color: ${t.fg.muted};
|
|
74
|
+
font-size: 11px;
|
|
75
|
+
font-weight: 500;
|
|
76
|
+
white-space: nowrap;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
user-select: none;
|
|
79
|
+
transition: color ${t.dur.fast} ease;
|
|
80
|
+
|
|
81
|
+
&[data-align='end'] {
|
|
82
|
+
justify-content: flex-end;
|
|
83
|
+
text-align: end;
|
|
84
|
+
}
|
|
85
|
+
&:disabled {
|
|
86
|
+
cursor: default;
|
|
87
|
+
opacity: 0.5;
|
|
88
|
+
}
|
|
89
|
+
&:focus-visible {
|
|
90
|
+
outline: 2px solid ${t.focus};
|
|
91
|
+
outline-offset: 1px;
|
|
92
|
+
}
|
|
93
|
+
&:not(:disabled):hover,
|
|
94
|
+
&[data-direction] {
|
|
95
|
+
color: ${t.fg.bright};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
[data-slot='sort-button-icon'] {
|
|
99
|
+
flex: none;
|
|
100
|
+
width: 1em;
|
|
101
|
+
height: 1em;
|
|
102
|
+
font-size: 11px;
|
|
103
|
+
line-height: 0;
|
|
104
|
+
|
|
105
|
+
& > svg {
|
|
106
|
+
width: 100%;
|
|
107
|
+
height: 100%;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
[data-slot='sort-button-state'] {
|
|
111
|
+
position: absolute;
|
|
112
|
+
width: 1px;
|
|
113
|
+
height: 1px;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
clip-path: inset(50%);
|
|
116
|
+
white-space: nowrap;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
`,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
class SortButtonImpl implements SortButtonHandle {
|
|
123
|
+
readonly el: HTMLButtonElement;
|
|
124
|
+
private readonly state: HTMLElement;
|
|
125
|
+
private readonly i18n: Translator | null;
|
|
126
|
+
private current: SortDirection | null;
|
|
127
|
+
|
|
128
|
+
constructor(private readonly props: SortButtonProps) {
|
|
129
|
+
injectStyles(document);
|
|
130
|
+
this.i18n = props.i18n ?? kitTranslator();
|
|
131
|
+
this.current = props.direction ?? null;
|
|
132
|
+
const stateId = nextUid('vela-sort');
|
|
133
|
+
this.state = h('span', { slot: sortButtonDef.slot('state'), attrs: { id: stateId } });
|
|
134
|
+
this.el = h(
|
|
135
|
+
'button',
|
|
136
|
+
{
|
|
137
|
+
className: props.className,
|
|
138
|
+
slot: sortButtonDef.slot('root'),
|
|
139
|
+
attrs: { type: 'button', title: props.title ?? null, 'aria-label': props.label, 'aria-describedby': stateId, ...sortButtonVariants(props) },
|
|
140
|
+
on: { click: () => this.step() },
|
|
141
|
+
},
|
|
142
|
+
props.label,
|
|
143
|
+
this.state,
|
|
144
|
+
);
|
|
145
|
+
this.el.disabled = props.disabled ?? false;
|
|
146
|
+
this.paint();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
get direction(): SortDirection | null {
|
|
150
|
+
return this.current;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
setDirection(direction: SortDirection | null): void {
|
|
154
|
+
this.current = direction;
|
|
155
|
+
this.paint();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
setDisabled(disabled: boolean): void {
|
|
159
|
+
this.el.disabled = disabled;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
destroy(): void {}
|
|
163
|
+
|
|
164
|
+
private step(): void {
|
|
165
|
+
const first = this.props.firstDirection ?? 'desc';
|
|
166
|
+
const second: SortDirection = first === 'desc' ? 'asc' : 'desc';
|
|
167
|
+
const clearable = this.props.clearable ?? true;
|
|
168
|
+
this.current = this.current === null ? first : this.current === first ? second : clearable ? null : first;
|
|
169
|
+
this.paint();
|
|
170
|
+
this.props.onSortChange?.(this.current);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private paint(): void {
|
|
174
|
+
const dir = this.current;
|
|
175
|
+
this.el.querySelector(`[data-slot="${sortButtonDef.slot('icon')}"]`)?.remove();
|
|
176
|
+
if (dir) {
|
|
177
|
+
const icon = iconEl(dir === 'asc' ? 'arrow-up' : 'arrow-down', document);
|
|
178
|
+
icon.dataset.slot = sortButtonDef.slot('icon');
|
|
179
|
+
this.state.before(icon);
|
|
180
|
+
}
|
|
181
|
+
this.el.toggleAttribute('data-direction', dir !== null);
|
|
182
|
+
if (dir) this.el.dataset.direction = dir;
|
|
183
|
+
this.state.textContent = dir ? textOf(this.i18n, TEXT[dir]) : '';
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function createSortButton(props: SortButtonProps): SortButtonHandle {
|
|
188
|
+
return new SortButtonImpl(props);
|
|
189
|
+
}
|
package/src/components/tabs.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// select; the caller shows what the selected tab stands for, through panels it attaches or as
|
|
4
4
|
// a filter of one view. `default` puts the tabs on one tinted track, `line` underlines the
|
|
5
5
|
// selected one (the indicator dialog), `filled` is the symbol picker's market strip, `soft`
|
|
6
|
-
// the drawings drawer's category strip, `nav` a vertical settings rail.
|
|
6
|
+
// the drawings drawer's category strip, `nav` a vertical settings rail. A tab with a
|
|
7
|
+
// `description` reads on two lines, its label over it (a day strip: the weekday, then the date).
|
|
7
8
|
import * as tabs from '@zag-js/tabs';
|
|
8
9
|
import { css, defineStyles } from '../lib/css';
|
|
9
10
|
import { defineComponent } from '../lib/define';
|
|
@@ -16,7 +17,7 @@ import { nextUid, normalizeProps, runMachine, spreadProps, type HandleOf } from
|
|
|
16
17
|
|
|
17
18
|
export const tabsDef = defineComponent({
|
|
18
19
|
name: 'tabs',
|
|
19
|
-
parts: ['list', 'trigger', 'icon', 'count', 'content'],
|
|
20
|
+
parts: ['list', 'trigger', 'icon', 'count', 'label', 'description', 'content'],
|
|
20
21
|
settings: { 'track-radius': '8px', 'trigger-radius': t.radius.md, 'filled-radius': '5px', 'soft-radius': '8px', 'count-radius': '8px' },
|
|
21
22
|
});
|
|
22
23
|
|
|
@@ -34,6 +35,8 @@ export interface TabItem {
|
|
|
34
35
|
icon?: string;
|
|
35
36
|
/** A count after the label (open orders, trades); null shows none. */
|
|
36
37
|
count?: number | null;
|
|
38
|
+
/** A second line under the label (a day strip's date under its weekday). */
|
|
39
|
+
description?: string;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
export interface TabsProps extends VariantProps<typeof tabsVariants> {
|
|
@@ -234,6 +237,30 @@ export const TABS_CSS = css`
|
|
|
234
237
|
background: ${t.active};
|
|
235
238
|
color: ${t.fg.bright};
|
|
236
239
|
}
|
|
240
|
+
&[data-description] {
|
|
241
|
+
display: inline-flex;
|
|
242
|
+
flex-direction: column;
|
|
243
|
+
align-items: center;
|
|
244
|
+
justify-content: center;
|
|
245
|
+
gap: 2px;
|
|
246
|
+
}
|
|
247
|
+
&[data-description]:not([data-variant='line']) {
|
|
248
|
+
padding-block: 6px;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
[data-slot='tabs-list'][data-variant='default']:has(> [data-description]) {
|
|
252
|
+
height: auto;
|
|
253
|
+
}
|
|
254
|
+
[data-slot='tabs-label'] {
|
|
255
|
+
display: inline-flex;
|
|
256
|
+
align-items: center;
|
|
257
|
+
line-height: 16px;
|
|
258
|
+
}
|
|
259
|
+
[data-slot='tabs-description'] {
|
|
260
|
+
font-size: 11px;
|
|
261
|
+
font-weight: 400;
|
|
262
|
+
line-height: 14px;
|
|
263
|
+
opacity: 0.85;
|
|
237
264
|
}
|
|
238
265
|
}
|
|
239
266
|
`;
|
|
@@ -333,7 +360,7 @@ class TabsImpl implements TabsHandle {
|
|
|
333
360
|
this.items = this.items.map((i) => (i.value === value ? { ...i, count } : i));
|
|
334
361
|
b.querySelector(`[data-slot="${tabsDef.slot('count')}"]`)?.remove();
|
|
335
362
|
const el = countEl(count);
|
|
336
|
-
if (el) b.appendChild(el);
|
|
363
|
+
if (el) (b.querySelector(`[data-slot="${tabsDef.slot('label')}"]`) ?? b).appendChild(el);
|
|
337
364
|
}
|
|
338
365
|
|
|
339
366
|
trigger(value: string): HTMLButtonElement | null {
|
|
@@ -364,7 +391,14 @@ class TabsImpl implements TabsHandle {
|
|
|
364
391
|
icon = iconEl(item.icon, document);
|
|
365
392
|
icon.dataset.slot = tabsDef.slot('icon');
|
|
366
393
|
}
|
|
367
|
-
const b =
|
|
394
|
+
const b = item.description
|
|
395
|
+
? h(
|
|
396
|
+
'button',
|
|
397
|
+
{ className, slot: tabsDef.slot('trigger'), data: { variant: this.variant, description: true } },
|
|
398
|
+
h('span', { slot: tabsDef.slot('label') }, icon, item.label, countEl(item.count)),
|
|
399
|
+
h('span', { slot: tabsDef.slot('description'), text: item.description }),
|
|
400
|
+
)
|
|
401
|
+
: h('button', { className, slot: tabsDef.slot('trigger'), data: { variant: this.variant } }, icon, item.label, countEl(item.count));
|
|
368
402
|
this.triggers.set(item.value, b);
|
|
369
403
|
return b;
|
|
370
404
|
}),
|
package/src/lib/calendar.ts
CHANGED
|
@@ -83,6 +83,11 @@ export function weekdayNames(settings: CalendarSettings): string[] {
|
|
|
83
83
|
return Array.from({ length: 7 }, (_, d) => stripBidiMarks(dtf.format(Date.UTC(2000, 0, 2 + d))));
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/** A day in words, for a screen reader (`Friday, November 6, 2026`). `month` counts from 0. */
|
|
87
|
+
export function longDate(settings: CalendarSettings, year: number, month: number, day: number): string {
|
|
88
|
+
return stripBidiMarks(dateFormat(settings, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }).format(Date.UTC(year, month, day)));
|
|
89
|
+
}
|
|
90
|
+
|
|
86
91
|
/** A year as a header label (`2026`, `2026年`). */
|
|
87
92
|
export function yearLabel(settings: CalendarSettings, year: number): string {
|
|
88
93
|
if (settings.english) return localizeDigits(String(year), settings);
|
|
@@ -13,7 +13,7 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
|
|
|
13
13
|
settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg'],
|
|
14
14
|
},
|
|
15
15
|
button: {
|
|
16
|
-
parts: ['root', 'icon'],
|
|
16
|
+
parts: ['root', 'icon', 'keys'],
|
|
17
17
|
settings: ['radius', 'height', 'height-xs', 'height-sm', 'height-lg', 'font-size', 'font-size-xs', 'font-size-sm'],
|
|
18
18
|
},
|
|
19
19
|
'callout-bubble': {
|
|
@@ -24,6 +24,10 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
|
|
|
24
24
|
parts: ['root', 'icon'],
|
|
25
25
|
settings: ['radius'],
|
|
26
26
|
},
|
|
27
|
+
collapsible: {
|
|
28
|
+
parts: ['root', 'trigger', 'icon', 'title', 'count', 'chevron', 'content'],
|
|
29
|
+
settings: ['trigger-height', 'radius'],
|
|
30
|
+
},
|
|
27
31
|
'color-picker': {
|
|
28
32
|
parts: ['root', 'trigger', 'swatch', 'content'],
|
|
29
33
|
settings: ['swatch-ring', 'circle-swatch-radius', 'content-radius'],
|
|
@@ -76,6 +80,10 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
|
|
|
76
80
|
parts: ['root', 'control', 'addon', 'text'],
|
|
77
81
|
settings: ['radius', 'height', 'height-sm', 'focus-ring'],
|
|
78
82
|
},
|
|
83
|
+
item: {
|
|
84
|
+
parts: ['root', 'media', 'content', 'title', 'description', 'meta', 'actions', 'group'],
|
|
85
|
+
settings: ['radius', 'gap'],
|
|
86
|
+
},
|
|
79
87
|
kbd: {
|
|
80
88
|
parts: ['root'],
|
|
81
89
|
settings: ['radius', 'shadow'],
|
|
@@ -84,6 +92,10 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
|
|
|
84
92
|
parts: ['root', 'label', 'area', 'line', 'dot', 'tip'],
|
|
85
93
|
settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg', 'stroke-width'],
|
|
86
94
|
},
|
|
95
|
+
'month-grid': {
|
|
96
|
+
parts: ['root', 'weekday', 'day', 'date', 'value', 'detail', 'blank'],
|
|
97
|
+
settings: ['radius', 'day-height', 'gap', 'selected-ring'],
|
|
98
|
+
},
|
|
87
99
|
'number-input': {
|
|
88
100
|
parts: ['root', 'input', 'steps', 'step'],
|
|
89
101
|
settings: ['radius', 'step-radius', 'focus-ring'],
|
|
@@ -100,6 +112,14 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
|
|
|
100
112
|
parts: ['root', 'trigger', 'value', 'icon', 'sizer', 'native', 'content', 'viewport', 'item', 'rail', 'thumb'],
|
|
101
113
|
settings: ['radius', 'content-radius', 'thumb-radius', 'focus-ring'],
|
|
102
114
|
},
|
|
115
|
+
slider: {
|
|
116
|
+
parts: ['root', 'control', 'track', 'range', 'thumb'],
|
|
117
|
+
settings: ['track-height', 'thumb-size', 'radius', 'focus-ring'],
|
|
118
|
+
},
|
|
119
|
+
'sort-button': {
|
|
120
|
+
parts: ['root', 'icon', 'state'],
|
|
121
|
+
settings: ['radius'],
|
|
122
|
+
},
|
|
103
123
|
sparkline: {
|
|
104
124
|
parts: ['root', 'area', 'baseline', 'line'],
|
|
105
125
|
settings: ['stroke-width'],
|
|
@@ -113,7 +133,7 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
|
|
|
113
133
|
settings: ['width', 'height', 'thumb-size', 'width-sm', 'height-sm', 'thumb-size-sm'],
|
|
114
134
|
},
|
|
115
135
|
tabs: {
|
|
116
|
-
parts: ['list', 'trigger', 'icon', 'count', 'content'],
|
|
136
|
+
parts: ['list', 'trigger', 'icon', 'count', 'label', 'description', 'content'],
|
|
117
137
|
settings: ['track-radius', 'trigger-radius', 'filled-radius', 'soft-radius', 'count-radius'],
|
|
118
138
|
},
|
|
119
139
|
'text-area': {
|
package/src/lib/css.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Component CSS: written in `css` templates (editors highlight them, stylelint checks them
|
|
2
2
|
// through the postcss-lit syntax) and injected once per document or shadow root.
|
|
3
3
|
import { pageState } from './page';
|
|
4
|
+
import { scopeToKit } from './scope';
|
|
4
5
|
import { injectLayerOrder, injectStyles } from './styles';
|
|
5
6
|
|
|
6
7
|
export { injectLayerOrder, LAYER_ORDER } from './styles';
|
|
@@ -30,14 +31,17 @@ export function acceptCss(text: string): void {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/** A component's stylesheet: call the result with the root it renders in, at creation, never
|
|
33
|
-
* at import (a component nobody creates injects nothing).
|
|
34
|
+
* at import (a component nobody creates injects nothing). Its rules apply inside kit hosts,
|
|
35
|
+
* their floating layers and themed hosts only: the page's own elements may carry the same
|
|
36
|
+
* part names. */
|
|
34
37
|
export function defineStyles(id: string, text: string): (root?: Document | ShadowRoot) => void {
|
|
35
38
|
// The sheet each root got, so later creations skip the lookup while it stays in place.
|
|
36
39
|
const injected = new WeakMap<Document | ShadowRoot, Element>();
|
|
40
|
+
let scoped: string | undefined;
|
|
37
41
|
return (root = document) => {
|
|
38
42
|
if (injected.get(root)?.isConnected) return;
|
|
39
43
|
injectLayerOrder(root);
|
|
40
|
-
injectStyles(id, text, root);
|
|
44
|
+
injectStyles(id, (scoped ??= scopeToKit(text)), root);
|
|
41
45
|
const sheet = root.getElementById?.(id) ?? (root instanceof Document ? null : root.querySelector(`#${CSS.escape(id)}`));
|
|
42
46
|
if (sheet) injected.set(root, sheet);
|
|
43
47
|
};
|
package/src/lib/scope.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Component CSS keys on `data-slot`, and a page's own components often carry the same part
|
|
2
|
+
// names (`select-trigger`, `popover-content`, `switch`, `button`). Each rule of a component's
|
|
3
|
+
// stylesheet is kept to where kit components live, so the page's elements never match it.
|
|
4
|
+
|
|
5
|
+
/** Kit hosts (`ensureUIHost`), the floating layers they portal (`vela-ui-layer`) and themed
|
|
6
|
+
* hosts (`applyTheme`), each with everything inside it. `:where()` adds no weight. */
|
|
7
|
+
export const KIT_SCOPE = ':where(.vela-ui, .vela-ui *, .vela-ui-layer, .vela-ui-layer *, [data-vela-theme], [data-vela-theme] *)';
|
|
8
|
+
|
|
9
|
+
// At-rules whose block holds style rules, scoped like the top level. Any other block holds
|
|
10
|
+
// no selectors (`@keyframes` steps, `@font-face` descriptors).
|
|
11
|
+
const GROUPING = /^@(?:layer|media|supports|container|scope|starting-style)\b/i;
|
|
12
|
+
// Pseudo-elements written with one colon: like `::x`, they close a compound.
|
|
13
|
+
const LEGACY_PSEUDO_ELEMENT = /^:(?:before|after|first-line|first-letter)(?![\w-])/i;
|
|
14
|
+
const SPACE = /\s/;
|
|
15
|
+
|
|
16
|
+
/** The index after the string, comment or escape at `i`, or `i` when none starts there. */
|
|
17
|
+
function skipOpaque(text: string, i: number): number {
|
|
18
|
+
const c = text[i];
|
|
19
|
+
if (c === '\\') return i + 2;
|
|
20
|
+
if (c === '"' || c === "'") {
|
|
21
|
+
let j = i + 1;
|
|
22
|
+
while (j < text.length && text[j] !== c) j += text[j] === '\\' ? 2 : 1;
|
|
23
|
+
return j + 1;
|
|
24
|
+
}
|
|
25
|
+
if (c === '/' && text[i + 1] === '*') {
|
|
26
|
+
const end = text.indexOf('*/', i + 2);
|
|
27
|
+
return end < 0 ? text.length : end + 2;
|
|
28
|
+
}
|
|
29
|
+
return i;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function withoutComments(text: string): string {
|
|
33
|
+
let out = '';
|
|
34
|
+
for (let i = 0; i < text.length; ) {
|
|
35
|
+
const next = skipOpaque(text, i);
|
|
36
|
+
if (next === i) out += text[i++];
|
|
37
|
+
else {
|
|
38
|
+
if (text[i] !== '/') out += text.slice(i, next);
|
|
39
|
+
i = next;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A selector list's selectors: its commas outside brackets, parentheses and strings. */
|
|
46
|
+
function selectorsOf(list: string): string[] {
|
|
47
|
+
const out: string[] = [];
|
|
48
|
+
let depth = 0;
|
|
49
|
+
let start = 0;
|
|
50
|
+
for (let i = 0; i < list.length; ) {
|
|
51
|
+
const next = skipOpaque(list, i);
|
|
52
|
+
if (next !== i) {
|
|
53
|
+
i = next;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const c = list[i];
|
|
57
|
+
if (c === '(' || c === '[') depth += 1;
|
|
58
|
+
else if (c === ')' || c === ']') depth -= 1;
|
|
59
|
+
else if (c === ',' && depth === 0) {
|
|
60
|
+
out.push(list.slice(start, i).trim());
|
|
61
|
+
start = i + 1;
|
|
62
|
+
}
|
|
63
|
+
i += 1;
|
|
64
|
+
}
|
|
65
|
+
out.push(list.slice(start).trim());
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The selector with the scope joined to its first compound, ahead of any pseudo-element. A
|
|
70
|
+
* selector the page drops (empty, or opening on a combinator) stays as it is. */
|
|
71
|
+
function scopeSelector(selector: string): string {
|
|
72
|
+
if (!selector || /^[>+~]/.test(selector)) return selector;
|
|
73
|
+
let depth = 0;
|
|
74
|
+
let i = 0;
|
|
75
|
+
while (i < selector.length) {
|
|
76
|
+
const next = skipOpaque(selector, i);
|
|
77
|
+
if (next !== i) {
|
|
78
|
+
i = next;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const c = selector[i]!;
|
|
82
|
+
if (c === '(' || c === '[') depth += 1;
|
|
83
|
+
else if (c === ')' || c === ']') depth -= 1;
|
|
84
|
+
else if (depth === 0 && (SPACE.test(c) || c === '>' || c === '+' || c === '~')) break;
|
|
85
|
+
else if (depth === 0 && c === ':' && (selector[i + 1] === ':' || LEGACY_PSEUDO_ELEMENT.test(selector.slice(i)))) break;
|
|
86
|
+
i += 1;
|
|
87
|
+
}
|
|
88
|
+
return selector.slice(0, i) + KIT_SCOPE + selector.slice(i);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A stylesheet whose top-level rules apply only where kit components live: {@link KIT_SCOPE}
|
|
93
|
+
* joins the first compound of each of their selectors, so a rule weighs the same and matches
|
|
94
|
+
* the same elements inside a kit host, and none outside. Rules nested in a rule follow their
|
|
95
|
+
* parent; those in `@layer`, `@media`, `@supports` and `@container` blocks are scoped too.
|
|
96
|
+
*/
|
|
97
|
+
export function scopeToKit(text: string): string {
|
|
98
|
+
let out = '';
|
|
99
|
+
let copied = 0;
|
|
100
|
+
let start = 0;
|
|
101
|
+
let scoping = true;
|
|
102
|
+
const outer: boolean[] = [];
|
|
103
|
+
for (let i = 0; i < text.length; ) {
|
|
104
|
+
const next = skipOpaque(text, i);
|
|
105
|
+
if (next !== i) {
|
|
106
|
+
i = next;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const c = text[i];
|
|
110
|
+
if (c === ';') {
|
|
111
|
+
start = i + 1;
|
|
112
|
+
} else if (c === '{') {
|
|
113
|
+
const prelude = text.slice(start, i);
|
|
114
|
+
const head = withoutComments(prelude).trim();
|
|
115
|
+
outer.push(scoping);
|
|
116
|
+
if (head.startsWith('@')) {
|
|
117
|
+
scoping &&= GROUPING.test(head);
|
|
118
|
+
} else {
|
|
119
|
+
if (scoping && head) {
|
|
120
|
+
const lead = /^\s*/.exec(prelude)![0];
|
|
121
|
+
const trail = /\s*$/.exec(prelude)![0];
|
|
122
|
+
out += text.slice(copied, start) + lead + selectorsOf(head).map(scopeSelector).join(', ') + trail;
|
|
123
|
+
copied = i;
|
|
124
|
+
}
|
|
125
|
+
scoping = false;
|
|
126
|
+
}
|
|
127
|
+
start = i + 1;
|
|
128
|
+
} else if (c === '}') {
|
|
129
|
+
scoping = outer.pop() ?? true;
|
|
130
|
+
start = i + 1;
|
|
131
|
+
}
|
|
132
|
+
i += 1;
|
|
133
|
+
}
|
|
134
|
+
return out + text.slice(copied);
|
|
135
|
+
}
|
package/src/lib/theme.ts
CHANGED
|
@@ -28,10 +28,15 @@ import type { selectDef } from '../components/select';
|
|
|
28
28
|
import type { sparklineDef } from '../components/sparkline';
|
|
29
29
|
import type { statDef } from '../components/stat';
|
|
30
30
|
import type { checkboxDef } from '../components/checkbox';
|
|
31
|
+
import type { collapsibleDef } from '../components/collapsible';
|
|
31
32
|
import type { tabsDef } from '../components/tabs';
|
|
32
33
|
import type { textAreaDef } from '../components/text-area';
|
|
33
34
|
import type { inputDef } from '../components/input';
|
|
34
35
|
import type { inputGroupDef } from '../components/input-group';
|
|
36
|
+
import type { itemDef } from '../components/item';
|
|
37
|
+
import type { monthGridDef } from '../components/month-grid';
|
|
38
|
+
import type { sliderDef } from '../components/slider';
|
|
39
|
+
import type { sortButtonDef } from '../components/sort-button';
|
|
35
40
|
import type { switchDef } from '../components/switch';
|
|
36
41
|
import type { toggleGroupDef } from '../components/toggle-group';
|
|
37
42
|
import type { tooltipDef } from '../components/tooltip';
|
|
@@ -136,31 +141,36 @@ export interface ComponentDefs {
|
|
|
136
141
|
'bar-chart': typeof barChartDef;
|
|
137
142
|
button: typeof buttonDef;
|
|
138
143
|
'callout-bubble': typeof calloutBubbleDef;
|
|
144
|
+
checkbox: typeof checkboxDef;
|
|
145
|
+
collapsible: typeof collapsibleDef;
|
|
139
146
|
'color-picker': typeof colorPickerDef;
|
|
140
147
|
'data-table': typeof dataTableDef;
|
|
141
148
|
'date-picker': typeof datePickerDef;
|
|
142
149
|
dialog: typeof dialogDef;
|
|
143
150
|
donut: typeof donutDef;
|
|
144
151
|
drawer: typeof drawerDef;
|
|
152
|
+
'dropdown-menu': typeof dropdownMenuDef;
|
|
145
153
|
empty: typeof emptyDef;
|
|
146
154
|
field: typeof fieldDef;
|
|
147
155
|
'glyph-select': typeof glyphSelectDef;
|
|
148
156
|
'hover-card': typeof hoverCardDef;
|
|
157
|
+
'input-group': typeof inputGroupDef;
|
|
158
|
+
input: typeof inputDef;
|
|
159
|
+
item: typeof itemDef;
|
|
149
160
|
kbd: typeof kbdDef;
|
|
150
161
|
'line-chart': typeof lineChartDef;
|
|
151
|
-
'
|
|
162
|
+
'month-grid': typeof monthGridDef;
|
|
152
163
|
'number-input': typeof numberInputDef;
|
|
153
164
|
popover: typeof popoverDef;
|
|
154
165
|
'scatter-chart': typeof scatterChartDef;
|
|
155
166
|
select: typeof selectDef;
|
|
167
|
+
slider: typeof sliderDef;
|
|
168
|
+
'sort-button': typeof sortButtonDef;
|
|
156
169
|
sparkline: typeof sparklineDef;
|
|
157
170
|
stat: typeof statDef;
|
|
158
|
-
|
|
171
|
+
switch: typeof switchDef;
|
|
159
172
|
tabs: typeof tabsDef;
|
|
160
173
|
'text-area': typeof textAreaDef;
|
|
161
|
-
input: typeof inputDef;
|
|
162
|
-
'input-group': typeof inputGroupDef;
|
|
163
|
-
switch: typeof switchDef;
|
|
164
174
|
'toggle-group': typeof toggleGroupDef;
|
|
165
175
|
tooltip: typeof tooltipDef;
|
|
166
176
|
}
|
package/dist/chunk-EZQXTO6K.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { variants } from './chunk-LZWZV2ZS.js';
|
|
2
|
-
import { iconEl } from './chunk-G7IQLY3A.js';
|
|
3
|
-
import { h } from './chunk-Q6WTDVH6.js';
|
|
4
|
-
import { t } from './chunk-6QCILIT2.js';
|
|
5
|
-
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
6
|
-
import { css, defineStyles } from './chunk-IDA2BT7D.js';
|
|
7
|
-
|
|
8
|
-
// src/components/button.ts
|
|
9
|
-
var buttonDef = defineComponent({
|
|
10
|
-
name: "button",
|
|
11
|
-
parts: ["root", "icon"],
|
|
12
|
-
settings: {
|
|
13
|
-
radius: t.radius.md,
|
|
14
|
-
height: "34px",
|
|
15
|
-
"height-xs": "26px",
|
|
16
|
-
"height-sm": "30px",
|
|
17
|
-
"height-lg": "40px",
|
|
18
|
-
"font-size": "14px",
|
|
19
|
-
"font-size-xs": "12px",
|
|
20
|
-
"font-size-sm": "13px"
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
var buttonVariants = variants({
|
|
24
|
-
variant: ["default", "outline", "secondary", "ghost", "destructive", "link", "up", "down"],
|
|
25
|
-
size: ["default", "xs", "sm", "lg", "icon", "icon-xs", "icon-sm", "icon-lg"]
|
|
26
|
-
});
|
|
27
|
-
var BUTTON_STYLE_ID = "vela-ui-button";
|
|
28
|
-
var BUTTON_CSS = css`@layer vela.ui{[data-slot=button]{cursor:pointer;height:${buttonDef.vars.height};border-radius:${buttonDef.vars.radius};border:1px solid ${t.border.strong};color:${t.fg};font-weight:400;font-size:${buttonDef.vars["font-size"]};white-space:nowrap;transition:background ${t.dur.fast} ease, color ${t.dur.fast} ease, opacity ${t.dur.fast} ease, border-color ${t.dur.fast} ease;background:0 0;padding:0 11px;font-family:inherit}[data-slot=button]:where(:not([hidden])){justify-content:center;align-items:center;gap:6px;display:inline-flex}[data-slot=button]>[data-icon]{flex:none;width:1em;height:1em;font-size:16px}[data-slot=button]>[data-icon]>svg{width:100%;height:100%}[data-slot=button][data-size=xs]>[data-icon],[data-slot=button][data-size=icon-xs]>[data-icon]{font-size:12px}[data-slot=button][data-size=sm],[data-slot=button][data-size=icon-sm]{height:${buttonDef.vars["height-sm"]};font-size:${buttonDef.vars["font-size-sm"]}}[data-slot=button][data-size=xs],[data-slot=button][data-size=icon-xs]{height:${buttonDef.vars["height-xs"]};font-size:${buttonDef.vars["font-size-xs"]};border-radius:${t.radius.sm};padding:0 8px}[data-slot=button][data-size=lg],[data-slot=button][data-size=icon-lg]{height:${buttonDef.vars["height-lg"]};padding:0 14px}[data-slot=button][data-size=icon]{width:${buttonDef.vars.height};padding:0}[data-slot=button][data-size=icon-sm]{width:${buttonDef.vars["height-sm"]};padding:0}[data-slot=button][data-size=icon-xs]{width:${buttonDef.vars["height-xs"]};padding:0}[data-slot=button][data-size=icon-lg]{width:${buttonDef.vars["height-lg"]};padding:0}[data-slot=button]:disabled{cursor:default;opacity:.5}[data-slot=button]:focus-visible{outline:2px solid ${t.focus};outline-offset:1px}[data-slot=button]:not(:disabled):hover,[data-slot=button][aria-expanded=true]{background:${t.hover};color:${t.fg.bright};border-color:${t.fg.muted}}[data-slot=button][data-variant=default]{border-color:${t.selected.bg};background:${t.selected.bg};color:${t.selected.fg}}[data-slot=button][data-variant=default]:not(:disabled):hover,[data-slot=button][data-variant=default][aria-expanded=true]{background:${t.selected.bg};color:${t.selected.fg};opacity:.85;border-color:${t.selected.bg}}[data-slot=button][data-variant=secondary]{background:${t.surface.sunken};border-color:${t.border}}[data-slot=button][data-variant=secondary]:not(:disabled):hover,[data-slot=button][data-variant=secondary][aria-expanded=true]{border-color:${t.border.strong}}[data-slot=button][data-variant=ghost]{color:${t.fg.muted};border-color:#0000}[data-slot=button][data-variant=ghost]:not(:disabled):hover,[data-slot=button][data-variant=ghost][aria-expanded=true]{border-color:#0000}[data-slot=button][data-variant=destructive]{background:color-mix(in srgb, ${t.danger} 14%, transparent);color:${t.danger};border-color:#0000}[data-slot=button][data-variant=destructive]:not(:disabled):hover{background:color-mix(in srgb, ${t.danger} 24%, transparent);color:${t.danger};border-color:#0000}[data-slot=button][data-variant=link]{color:${t.accent};text-underline-offset:4px;background:0 0;border-color:#0000;padding-inline:0}[data-slot=button][data-variant=link]:not(:disabled):hover{color:${t.accent};background:0 0;border-color:#0000;text-decoration:underline}[data-slot=button][data-variant=up],[data-slot=button][data-variant=up]:not(:disabled):hover{background:${t.up};color:${t.fg.onFill};border-color:#0000}[data-slot=button][data-variant=down],[data-slot=button][data-variant=down]:not(:disabled):hover{background:${t.down};color:${t.fg.onFill};border-color:#0000}[data-slot=button][data-variant=up]:not(:disabled):hover,[data-slot=button][data-variant=down]:not(:disabled):hover{opacity:.88}[data-slot=button][data-pressed]{background:${t.active};color:${t.fg.bright}}}`;
|
|
29
|
-
var injectStyles = defineStyles(BUTTON_STYLE_ID, BUTTON_CSS);
|
|
30
|
-
var ButtonImpl = class {
|
|
31
|
-
constructor(props) {
|
|
32
|
-
injectStyles(document);
|
|
33
|
-
const { variant, size } = buttonVariants.resolve(props);
|
|
34
|
-
this.iconOnly = size.startsWith("icon");
|
|
35
|
-
this.label = props.label ?? props.text;
|
|
36
|
-
this.pressedState = props.pressed;
|
|
37
|
-
const icon = (id, side) => {
|
|
38
|
-
const el = iconEl(id, document);
|
|
39
|
-
el.dataset.slot = buttonDef.slot("icon");
|
|
40
|
-
el.dataset.icon = side;
|
|
41
|
-
return el;
|
|
42
|
-
};
|
|
43
|
-
this.textNode = !this.iconOnly && props.text !== void 0 ? document.createTextNode(props.text) : null;
|
|
44
|
-
this.el = h(
|
|
45
|
-
"button",
|
|
46
|
-
{
|
|
47
|
-
className: props.className ? `vela-btn ${props.className}` : "vela-btn",
|
|
48
|
-
slot: buttonDef.slot("root"),
|
|
49
|
-
attrs: { type: "button", ...buttonVariants({ variant, size }) },
|
|
50
|
-
on: props.onClick ? { click: props.onClick } : void 0
|
|
51
|
-
},
|
|
52
|
-
props.icon ? icon(props.icon, "inline-start") : null,
|
|
53
|
-
this.textNode,
|
|
54
|
-
props.iconEnd && !this.iconOnly ? icon(props.iconEnd, "inline-end") : null
|
|
55
|
-
);
|
|
56
|
-
this.el.disabled = props.disabled ?? false;
|
|
57
|
-
this.paint();
|
|
58
|
-
}
|
|
59
|
-
get pressed() {
|
|
60
|
-
return this.pressedState;
|
|
61
|
-
}
|
|
62
|
-
setPressed(pressed) {
|
|
63
|
-
this.pressedState = pressed;
|
|
64
|
-
this.paint();
|
|
65
|
-
}
|
|
66
|
-
setDisabled(disabled) {
|
|
67
|
-
this.el.disabled = disabled;
|
|
68
|
-
}
|
|
69
|
-
setText(text) {
|
|
70
|
-
this.label = text;
|
|
71
|
-
if (this.textNode) this.textNode.data = text;
|
|
72
|
-
this.paint();
|
|
73
|
-
}
|
|
74
|
-
destroy() {
|
|
75
|
-
}
|
|
76
|
-
paint() {
|
|
77
|
-
const el = this.el;
|
|
78
|
-
el.toggleAttribute("data-pressed", this.pressedState === true);
|
|
79
|
-
if (this.pressedState === void 0) el.removeAttribute("aria-pressed");
|
|
80
|
-
else el.setAttribute("aria-pressed", String(this.pressedState));
|
|
81
|
-
if (this.iconOnly && this.label !== void 0) el.setAttribute("aria-label", this.label);
|
|
82
|
-
else el.removeAttribute("aria-label");
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
function createButton(props = {}) {
|
|
86
|
-
return new ButtonImpl(props);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export { BUTTON_CSS, BUTTON_STYLE_ID, buttonDef, buttonVariants, createButton };
|