@prunellejs/ui 0.0.0-stage → 0.1.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/src/static.tsx ADDED
@@ -0,0 +1,319 @@
1
+ /** @jsxImportSource prunelle */
2
+ // Zero-JS static & native-platform primitives (`0 KB` client JS!).
3
+ // Emit only semantic `data-ui`, `data-part`, `data-variant`, `data-tone`, `data-layout` attributes.
4
+
5
+ import type { Context, Html, PrunelleChild } from 'prunelle'
6
+ import type { FieldControlWiring } from './field-context'
7
+ import { provideContext } from 'prunelle'
8
+ import { FIELD_CONTEXT_ID } from './field-context'
9
+
10
+ export type { FieldControlWiring } from './field-context'
11
+ export { useFieldContext } from './field-context'
12
+
13
+ export const FieldContext: Context<FieldControlWiring | undefined> = {
14
+ id: FIELD_CONTEXT_ID,
15
+ defaultValue: undefined,
16
+ Provider(props) {
17
+ return provideContext(FieldContext, props.value, () => {
18
+ const c = props.children
19
+ return typeof c === 'function' ? (c as () => PrunelleChild)() : c
20
+ })
21
+ },
22
+ }
23
+
24
+ function escAttr(value: string): string {
25
+ return value.replaceAll('&', '&amp;').replaceAll('"', '&quot;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')
26
+ }
27
+
28
+ export type Tone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger'
29
+ export type ButtonVariant = 'solid' | 'outline' | 'ghost'
30
+ export type Size = 'sm' | 'md' | 'lg'
31
+
32
+ interface BoxProps {
33
+ class?: string | undefined
34
+ children?: PrunelleChild | undefined
35
+ [attr: string]: unknown
36
+ }
37
+
38
+ export interface ButtonProps {
39
+ variant?: ButtonVariant | undefined
40
+ tone?: Tone | undefined
41
+ size?: Size | undefined
42
+ href?: string | undefined
43
+ type?: 'button' | 'submit' | 'reset' | undefined
44
+ disabled?: boolean | undefined
45
+ class?: string | undefined
46
+ children?: PrunelleChild | undefined
47
+ [attr: string]: unknown
48
+ }
49
+
50
+ function restProps(props: Record<string, unknown>, skip: readonly string[]): Record<string, unknown> {
51
+ const out: Record<string, unknown> = {}
52
+ for (const k of Object.keys(props)) {
53
+ if (k !== 'children' && !skip.includes(k))
54
+ out[k] = props[k]
55
+ }
56
+ return out
57
+ }
58
+
59
+ export function Button(props: ButtonProps) {
60
+ const rest = restProps(props as unknown as Record<string, unknown>, ['variant', 'tone', 'size', 'href', 'type', 'disabled', 'class'])
61
+ if (props.href !== undefined) {
62
+ return (
63
+ <a data-ui="button" data-variant={props.variant ?? 'solid'} data-tone={props.tone} data-size={props.size ?? 'md'} href={props.href} class={props.class} {...rest}>
64
+ {props.children}
65
+ </a>
66
+ )
67
+ }
68
+ return (
69
+ <button data-ui="button" data-variant={props.variant ?? 'solid'} data-tone={props.tone} data-size={props.size ?? 'md'} type={props.type ?? 'button'} disabled={props.disabled} class={props.class} {...rest}>
70
+ {props.children}
71
+ </button>
72
+ )
73
+ }
74
+
75
+ export function Notice(props: BoxProps & { tone?: Tone | undefined, role?: 'status' | 'alert' | 'note' | undefined }) {
76
+ const rest = restProps(props, ['tone', 'role', 'class'])
77
+ return <div data-ui="notice" data-tone={props.tone} role={props.role ?? 'status'} class={props.class} {...rest}>{props.children}</div>
78
+ }
79
+
80
+ /** Zero-JS form field wrapper that auto-wires `for`, `aria-describedby`, `aria-invalid`, hints, and action errors. */
81
+ export interface FieldProps {
82
+ id: string
83
+ label: string
84
+ hint?: string | undefined
85
+ error?: string | undefined
86
+ required?: boolean | undefined
87
+ class?: string | undefined
88
+ children?: PrunelleChild | undefined
89
+ }
90
+
91
+ function mergeTokenAttr(existing: string | null | undefined, addition: string): string {
92
+ const tokens = (existing ?? '').split(/\s+/).filter(Boolean)
93
+ for (const tok of addition.split(/\s+/).filter(Boolean)) {
94
+ if (!tokens.includes(tok))
95
+ tokens.push(tok)
96
+ }
97
+ return tokens.join(' ')
98
+ }
99
+
100
+ interface ScannedTag {
101
+ start: number
102
+ end: number
103
+ tag: string
104
+ rawAttrs: string
105
+ selfClose: string
106
+ }
107
+
108
+ const OPEN_TAG_RE = /<([a-zA-Z][\w-]*)(?=[\s/>])((?:"[^"]*"|'[^']*'|[^>"'])*)>/g
109
+
110
+ /** Quote-aware HTML opening tag scanner so `>` inside attribute values (e.g. `placeholder="x > 0"`) never truncates a tag. */
111
+ function scanOpeningTags(html: string): ScannedTag[] {
112
+ const tags: ScannedTag[] = []
113
+ OPEN_TAG_RE.lastIndex = 0
114
+ let m: RegExpExecArray | null
115
+ while ((m = OPEN_TAG_RE.exec(html)) !== null) {
116
+ const body = m[2]!
117
+ const selfClose = body.endsWith('/') ? '/' : ''
118
+ tags.push({
119
+ start: m.index,
120
+ end: m.index + m[0].length,
121
+ tag: m[1]!,
122
+ rawAttrs: selfClose ? body.slice(0, -1) : body,
123
+ selfClose,
124
+ })
125
+ }
126
+ return tags
127
+ }
128
+
129
+ const NATIVE_CTRL_RE = /^(?:input|textarea|select)$/i
130
+
131
+ function wireFieldHtml(html: string, wiring: FieldControlWiring): string {
132
+ const tags = scanOpeningTags(html)
133
+ const target = tags.find(t => NATIVE_CTRL_RE.test(t.tag) && !(/\btype\s*=\s*(?:"hidden"|'hidden'|hidden\b)/i.test(t.rawAttrs) && /^input$/i.test(t.tag)))
134
+ ?? tags.find(t => /\brole\s*=\s*["'](?:combobox|textbox|listbox|spinbutton)["']/i.test(t.rawAttrs))
135
+ if (target === undefined)
136
+ return html
137
+
138
+ let attrs = target.rawAttrs
139
+ if (!/\bid\s*=/i.test(attrs))
140
+ attrs += ` id="${escAttr(wiring.id)}"`
141
+ else if (/\bid\s*=\s*"kui-[^"]*"/i.test(attrs))
142
+ attrs = attrs.replace(/\bid\s*=\s*"kui-[^"]*"/i, `id="${escAttr(wiring.id)}"`)
143
+
144
+ if (wiring.describedBy) {
145
+ const descRe = /(\baria-describedby\s*=\s*")([^"]*)(")/i
146
+ attrs = descRe.test(attrs)
147
+ ? attrs.replace(descRe, (_, p1: string, cur: string, p3: string) => `${p1}${escAttr(mergeTokenAttr(cur, wiring.describedBy!))}${p3}`)
148
+ : `${attrs} aria-describedby="${escAttr(wiring.describedBy)}"`
149
+ }
150
+ if (wiring.invalid && !/\baria-invalid\s*=/i.test(attrs))
151
+ attrs += ' aria-invalid="true"'
152
+ if (wiring.required) {
153
+ if (NATIVE_CTRL_RE.test(target.tag) && !/\brequired(?:\s|=|$)/i.test(attrs))
154
+ attrs += ' required'
155
+ if (!/\baria-required\s*=/i.test(attrs))
156
+ attrs += ' aria-required="true"'
157
+ }
158
+ return `${html.slice(0, target.start)}<${target.tag}${attrs}${target.selfClose}>${html.slice(target.end)}`
159
+ }
160
+
161
+ const CTRL_SEL = 'input:not([type="hidden"]),textarea,select,[role="combobox"],[role="textbox"],[role="listbox"],[role="spinbutton"]'
162
+
163
+ function syncFieldAria(el: Element, id: string, err: string | undefined, hint: string | undefined, clearInvalid: boolean): void {
164
+ const errId = `${id}-error`
165
+ const hintId = `${id}-hint`
166
+ const tokens = (el.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(t => t && t !== errId && t !== hintId)
167
+ if (err)
168
+ tokens.push(errId)
169
+ else if (hint)
170
+ tokens.push(hintId)
171
+ if (tokens.length > 0)
172
+ el.setAttribute('aria-describedby', tokens.join(' '))
173
+ else
174
+ el.removeAttribute('aria-describedby')
175
+ if (err)
176
+ el.setAttribute('aria-invalid', 'true')
177
+ else if (clearInvalid)
178
+ el.removeAttribute('aria-invalid')
179
+ }
180
+
181
+ function wireFieldElement(el: Element, wiring: FieldControlWiring, err: string | undefined, hint: string | undefined): void {
182
+ const curId = el.getAttribute('id')
183
+ if (!curId || curId.startsWith('kui-'))
184
+ el.setAttribute('id', wiring.id)
185
+ syncFieldAria(el, wiring.id, err, hint, false)
186
+ if (wiring.required) {
187
+ if (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.tagName === 'SELECT')
188
+ el.setAttribute('required', '')
189
+ if (!el.hasAttribute('aria-required'))
190
+ el.setAttribute('aria-required', 'true')
191
+ }
192
+ }
193
+
194
+ function findFieldControlInNode(node: Node): Element | null {
195
+ if (node.nodeType === 1) {
196
+ const el = node as Element
197
+ return el.matches(CTRL_SEL) ? el : el.querySelector(CTRL_SEL)
198
+ }
199
+ return node.nodeType === 11 ? (node as DocumentFragment).querySelector(CTRL_SEL) : null
200
+ }
201
+
202
+ const RAW_HTML_BRAND = Symbol.for('pru.html')
203
+
204
+ function wireFieldChildren(
205
+ children: PrunelleChild,
206
+ wiring: FieldControlWiring,
207
+ err: string | undefined,
208
+ hint: string | undefined,
209
+ onControl: (el: Element) => void,
210
+ state: { done: boolean } = { done: false },
211
+ ): PrunelleChild {
212
+ if (state.done || children == null || typeof children !== 'object')
213
+ return children
214
+ if (Array.isArray(children))
215
+ return children.map(child => (state.done ? child : wireFieldChildren(child, wiring, err, hint, onControl, state)))
216
+ if ('__html' in children && (children as unknown as Record<symbol, unknown>)[RAW_HTML_BRAND] === true) {
217
+ const src = (children as Html).__html
218
+ const patched = wireFieldHtml(src, wiring)
219
+ if (patched !== src) {
220
+ state.done = true
221
+ return { [RAW_HTML_BRAND]: true, __html: patched } as unknown as Html
222
+ }
223
+ return children
224
+ }
225
+ if (typeof Node !== 'undefined' && children instanceof Node) {
226
+ const ctrl = findFieldControlInNode(children)
227
+ if (ctrl !== null) {
228
+ wireFieldElement(ctrl, wiring, err, hint)
229
+ onControl(ctrl)
230
+ state.done = true
231
+ }
232
+ }
233
+ return children
234
+ }
235
+
236
+ export function Field(props: FieldProps) {
237
+ let ctrlEl: Element | null = null
238
+ let lastError: string | undefined
239
+ let ownedInvalid = false
240
+
241
+ const syncInvalid = (): 'true' | undefined => {
242
+ const err = props.error
243
+ lastError = err
244
+ if (typeof document !== 'undefined') {
245
+ const target = ctrlEl ?? document.getElementById(props.id)
246
+ if (target !== null && (target === ctrlEl || target.closest('[data-ui="field"]') !== null)) {
247
+ ctrlEl = target
248
+ syncFieldAria(target, props.id, err, props.hint, ownedInvalid)
249
+ ownedInvalid = Boolean(err)
250
+ }
251
+ }
252
+ return err ? 'true' : undefined
253
+ }
254
+
255
+ return (
256
+ <div data-ui="field" data-invalid={syncInvalid()} class={props.class}>
257
+ <label data-part="label" for={props.id}>
258
+ {props.label}
259
+ {props.required && <span aria-hidden="true"> *</span>}
260
+ </label>
261
+ {(() => {
262
+ const wiring: FieldControlWiring = {
263
+ id: props.id,
264
+ describedBy: lastError ? `${props.id}-error` : props.hint ? `${props.id}-hint` : undefined,
265
+ invalid: Boolean(lastError),
266
+ required: Boolean(props.required),
267
+ }
268
+ return provideContext(FieldContext, wiring, () => wireFieldChildren(props.children, wiring, lastError, props.hint, (el) => {
269
+ ctrlEl = el
270
+ if (wiring.invalid)
271
+ ownedInvalid = true
272
+ }))
273
+ })()}
274
+ {props.hint && !props.error && <p data-part="hint" id={`${props.id}-hint`}>{props.hint}</p>}
275
+ {props.error && <p data-part="error" id={`${props.id}-error`} role="alert">{props.error}</p>}
276
+ </div>
277
+ )
278
+ }
279
+
280
+ // ---- Every Layout primitives (pure CSS, 0 KB JS, strict-CSP safe) ----
281
+
282
+ export type SpaceToken = 'none' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'
283
+ export type TrackSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
284
+ export type SpaceValue = SpaceToken | (string & {})
285
+ export type TrackValue = TrackSize | (string & {})
286
+
287
+ const SPACE_TOKENS = new Set<string>(['none', '2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl'])
288
+
289
+ const isSpaceToken = (v: string | undefined): boolean => v !== undefined && SPACE_TOKENS.has(v)
290
+
291
+ export function Stack(props: BoxProps & { gap?: SpaceValue | undefined }) {
292
+ const rest = restProps(props, ['gap', 'class'])
293
+ return (
294
+ <div
295
+ data-layout="stack"
296
+ data-gap={isSpaceToken(props.gap) ? props.gap : undefined}
297
+ data-gap-value={props.gap && !isSpaceToken(props.gap) ? props.gap : undefined}
298
+ class={props.class}
299
+ {...rest}
300
+ >
301
+ {props.children}
302
+ </div>
303
+ )
304
+ }
305
+
306
+ export function Cluster(props: BoxProps & { gap?: SpaceValue | undefined }) {
307
+ const rest = restProps(props, ['gap', 'class'])
308
+ return (
309
+ <div
310
+ data-layout="cluster"
311
+ data-gap={isSpaceToken(props.gap) ? props.gap : undefined}
312
+ data-gap-value={props.gap && !isSpaceToken(props.gap) ? props.gap : undefined}
313
+ class={props.class}
314
+ {...rest}
315
+ >
316
+ {props.children}
317
+ </div>
318
+ )
319
+ }
@@ -0,0 +1,315 @@
1
+ /* @prunellejs/ui bare floor: behavior, layout primitives, accessibility & top-layer positioning only.
2
+ * Everything sits inside @layer kui so Tailwind utilities and user CSS always win without !important. */
3
+
4
+ @layer kui {
5
+ [data-ui] *,
6
+ [data-ui] *::before,
7
+ [data-ui] *::after {
8
+ box-sizing: border-box;
9
+ }
10
+
11
+ .kui-sr-only {
12
+ position: absolute;
13
+ width: 1px;
14
+ height: 1px;
15
+ padding: 0;
16
+ margin: -1px;
17
+ overflow: hidden;
18
+ clip: rect(0, 0, 0, 0);
19
+ white-space: nowrap;
20
+ border: 0;
21
+ }
22
+
23
+ [data-ui] :focus-visible,
24
+ [data-ui]:focus-visible {
25
+ outline: 2px solid var(--ui-accent, currentColor);
26
+ outline-offset: 2px;
27
+ }
28
+
29
+ @media (prefers-reduced-motion: reduce) {
30
+ :root {
31
+ --ui-motion: 0.01ms;
32
+ }
33
+ [data-ui],
34
+ [data-ui] *,
35
+ [data-ui] *::before,
36
+ [data-ui] *::after {
37
+ animation-duration: 0.01ms !important;
38
+ animation-iteration-count: 1 !important;
39
+ transition-duration: 0.01ms !important;
40
+ scroll-behavior: auto !important;
41
+ }
42
+ }
43
+
44
+ /* Touch-friendly targets & iOS 16px input floor on small viewports */
45
+ @media (max-width: 600px) {
46
+ [data-ui="button"],
47
+ [data-ui="field"] :is(input, select),
48
+ [data-ui="select"] [data-part="trigger"],
49
+ [data-ui="tabs"] [data-part="trigger"],
50
+ [data-ui="accordion"] summary[data-part="trigger"],
51
+ [data-ui="radio-group"] label,
52
+ [data-ui="checkbox"],
53
+ [data-ui="switch"] {
54
+ min-block-size: 44px;
55
+ }
56
+ [data-ui="radio-group"] label {
57
+ display: flex;
58
+ align-items: center;
59
+ }
60
+ [data-ui="field"] :is(input, select, textarea),
61
+ dialog[data-ui="command"] [data-part="input"],
62
+ [data-ui="datatable"] [data-part="search"] {
63
+ font-size: max(1rem, 16px);
64
+ }
65
+ }
66
+
67
+ /* Every Layout primitives (0 KB JS) */
68
+ [data-layout="stack"] {
69
+ display: flex;
70
+ flex-direction: column;
71
+ gap: var(--ui-gap, 1rem);
72
+ }
73
+ [data-layout="cluster"] {
74
+ display: flex;
75
+ flex-wrap: wrap;
76
+ align-items: center;
77
+ gap: var(--ui-gap, 0.75rem);
78
+ }
79
+ [data-layout="grid"] {
80
+ display: grid;
81
+ grid-template-columns: repeat(auto-fit, minmax(min(var(--ui-min, 16rem), 100%), 1fr));
82
+ gap: var(--ui-gap, 1rem);
83
+ }
84
+ [data-layout="sidebar"] {
85
+ display: flex;
86
+ flex-wrap: wrap;
87
+ gap: var(--ui-gap, 1.5rem);
88
+ }
89
+ [data-layout="sidebar"] > :first-child {
90
+ flex-basis: var(--ui-side, 16rem);
91
+ flex-grow: 1;
92
+ }
93
+ [data-layout="sidebar"] > :last-child {
94
+ flex-basis: 0;
95
+ flex-grow: 999;
96
+ min-inline-size: var(--ui-content-min, 60%);
97
+ }
98
+ [data-layout="split"] {
99
+ display: flex;
100
+ flex-wrap: wrap;
101
+ align-items: center;
102
+ justify-content: space-between;
103
+ gap: var(--ui-gap, 1rem);
104
+ }
105
+
106
+ /* Layout scale tokens (0 KB JS, strict-CSP safe across all browsers) */
107
+ [data-layout][data-gap="none"] { --ui-gap: 0; }
108
+ [data-layout][data-gap="2xs"] { --ui-gap: var(--ui-space-2xs, 0.25rem); }
109
+ [data-layout][data-gap="xs"] { --ui-gap: var(--ui-space-xs, 0.5rem); }
110
+ [data-layout][data-gap="sm"] { --ui-gap: var(--ui-space-sm, 0.75rem); }
111
+ [data-layout][data-gap="md"] { --ui-gap: var(--ui-space-md, 1rem); }
112
+ [data-layout][data-gap="lg"] { --ui-gap: var(--ui-space-lg, 1.5rem); }
113
+ [data-layout][data-gap="xl"] { --ui-gap: var(--ui-space-xl, 2rem); }
114
+ [data-layout][data-gap="2xl"] { --ui-gap: var(--ui-space-2xl, 3rem); }
115
+
116
+ [data-layout="grid"][data-min="xs"] { --ui-min: 10rem; }
117
+ [data-layout="grid"][data-min="sm"] { --ui-min: 14rem; }
118
+ [data-layout="grid"][data-min="md"] { --ui-min: 16rem; }
119
+ [data-layout="grid"][data-min="lg"] { --ui-min: 20rem; }
120
+ [data-layout="grid"][data-min="xl"] { --ui-min: 24rem; }
121
+
122
+ [data-layout="sidebar"][data-side="xs"] { --ui-side: 10rem; }
123
+ [data-layout="sidebar"][data-side="sm"] { --ui-side: 12rem; }
124
+ [data-layout="sidebar"][data-side="md"] { --ui-side: 16rem; }
125
+ [data-layout="sidebar"][data-side="lg"] { --ui-side: 20rem; }
126
+ [data-layout="sidebar"][data-side="xl"] { --ui-side: 24rem; }
127
+
128
+ /* Progressive CSS Values 5 attr() support for custom CSS lengths without inline style attributes */
129
+ @supports (gap: attr(data-gap-value type(<length-percentage>))) {
130
+ [data-layout][data-gap-value] { --ui-gap: attr(data-gap-value type(<length-percentage>)); }
131
+ [data-layout="grid"][data-min-value] { --ui-min: attr(data-min-value type(<length-percentage>)); }
132
+ [data-layout="sidebar"][data-side-value] { --ui-side: attr(data-side-value type(<length-percentage>)); }
133
+ }
134
+
135
+ /* Native top-layer & overlay positioning */
136
+ dialog[data-ui="dialog"],
137
+ dialog[data-ui="drawer"],
138
+ dialog[data-ui="command"] {
139
+ padding: 0;
140
+ }
141
+ dialog[data-ui="drawer"] > [data-part="panel"] {
142
+ min-block-size: 100%;
143
+ }
144
+ /* The page behind a modal does not scroll */
145
+ html:has(dialog[data-ui]:modal) {
146
+ overflow: hidden;
147
+ }
148
+ dialog[data-ui="dialog"],
149
+ dialog[data-ui="command"] {
150
+ margin: auto;
151
+ max-inline-size: min(32rem, calc(100vw - 2rem));
152
+ max-block-size: calc(100dvh - 2rem);
153
+ overflow: auto;
154
+ }
155
+ dialog[data-ui="command"] {
156
+ inline-size: min(34rem, calc(100vw - 2rem));
157
+ margin-block-start: min(14vh, 6rem);
158
+ }
159
+ dialog[data-ui="drawer"] {
160
+ margin: 0;
161
+ max-block-size: 100dvh;
162
+ block-size: 100dvh;
163
+ inline-size: min(26rem, 90vw);
164
+ max-inline-size: 90vw;
165
+ overflow: auto;
166
+ &[data-side="right"] { margin-inline-start: auto; }
167
+ &[data-side="left"] { margin-inline-end: auto; }
168
+ &[data-side="bottom"] {
169
+ margin-block-start: auto;
170
+ inline-size: 100vw;
171
+ max-inline-size: 100vw;
172
+ block-size: auto;
173
+ max-block-size: 80dvh;
174
+ }
175
+ }
176
+ dialog[data-ui="dialog"]::backdrop,
177
+ dialog[data-ui="drawer"]::backdrop,
178
+ dialog[data-ui="command"]::backdrop {
179
+ background: rgb(0 0 0 / 0.45);
180
+ }
181
+
182
+ /* Native Switch & Check controls */
183
+ [data-ui="checkbox"],
184
+ [data-ui="switch"] {
185
+ display: inline-flex;
186
+ align-items: center;
187
+ gap: 0.55rem;
188
+ cursor: pointer;
189
+ user-select: none;
190
+ &[data-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
191
+ }
192
+ [data-ui="switch"] input[type="checkbox"] {
193
+ position: absolute;
194
+ opacity: 0;
195
+ inline-size: 1px;
196
+ block-size: 1px;
197
+ pointer-events: none;
198
+ }
199
+ [data-ui="switch"] [data-part="track"] {
200
+ position: relative;
201
+ display: inline-block;
202
+ inline-size: 2.25rem;
203
+ block-size: 1.25rem;
204
+ flex-shrink: 0;
205
+ &::after {
206
+ content: '';
207
+ position: absolute;
208
+ inset-block: 2px;
209
+ inset-inline-start: 2px;
210
+ aspect-ratio: 1;
211
+ transition: inset-inline-start 140ms ease, transform 140ms ease;
212
+ }
213
+ }
214
+ [data-ui="switch"] input:checked + [data-part="track"]::after {
215
+ inset-inline-start: calc(100% - 2px);
216
+ transform: translateX(-100%);
217
+ }
218
+ [data-ui="switch"]:has(input:focus-visible) [data-part="track"],
219
+ [data-ui="switch"] input:focus-visible + [data-part="track"] {
220
+ outline: 2px solid var(--ui-accent, currentColor);
221
+ outline-offset: 2px;
222
+ }
223
+ [data-ui="radio-group"] {
224
+ border: 0;
225
+ padding: 0;
226
+ margin: 0;
227
+ }
228
+ [data-ui="radio-group"] [data-part="options"] {
229
+ display: flex;
230
+ flex-direction: column;
231
+ gap: 0.45rem;
232
+ }
233
+ [data-ui="radio-group"] [data-part="option"] {
234
+ display: inline-flex;
235
+ align-items: center;
236
+ gap: 0.5rem;
237
+ cursor: pointer;
238
+ }
239
+
240
+ /* DataTable scroll & pagination */
241
+ [data-ui="datatable"] [data-part="scroll"] {
242
+ overflow-x: auto;
243
+ }
244
+ [data-ui="datatable"] [data-part="pagination"] [data-layout="cluster"] {
245
+ --ui-gap: 0.4rem;
246
+ }
247
+ table[data-ui="table"] {
248
+ width: 100%;
249
+ border-collapse: collapse;
250
+ text-align: left;
251
+ }
252
+ table[data-ui="table"] > caption {
253
+ text-align: start;
254
+ font-weight: 600;
255
+ margin-block-end: 0.5rem;
256
+ }
257
+
258
+ /* Progress: the native bar; a grammar may draw the eye instead */
259
+ [data-ui="progress"] {
260
+ display: inline-flex;
261
+ align-items: center;
262
+ gap: 0.6rem;
263
+ }
264
+ [data-ui="progress"] [data-part="eye"] {
265
+ display: none;
266
+ }
267
+ [data-ui="progress"] progress {
268
+ accent-color: var(--ui-accent-fill, var(--ui-accent, currentColor));
269
+ }
270
+
271
+ [data-ui="popover"][popover] {
272
+ inset: auto;
273
+ margin: 0;
274
+ position-area: block-end span-inline-end;
275
+ position-try-fallbacks: flip-block, flip-inline;
276
+ }
277
+
278
+ [data-ui="menu"],
279
+ [data-ui="select"] {
280
+ display: inline-block;
281
+ }
282
+ [data-ui="menu"] [data-part="content"],
283
+ [data-ui="select"] [data-part="listbox"] {
284
+ inset: auto;
285
+ margin: 4px 0;
286
+ position-area: block-end span-inline-end;
287
+ position-try-fallbacks: flip-block, flip-inline;
288
+ min-inline-size: anchor-size(inline);
289
+ }
290
+
291
+ [data-ui="toaster"] {
292
+ position: fixed;
293
+ inset-block-end: 1rem;
294
+ inset-inline-end: 1rem;
295
+ z-index: 60;
296
+ display: flex;
297
+ flex-direction: column;
298
+ gap: 0.5rem;
299
+ max-inline-size: min(24rem, calc(100vw - 2rem));
300
+ }
301
+ [data-ui="toast"] [data-part="description"] {
302
+ margin: 0.2rem 0 0;
303
+ }
304
+ [data-ui="toast"] [data-part="close"] {
305
+ background: transparent;
306
+ border: 0;
307
+ color: inherit;
308
+ cursor: pointer;
309
+ padding: 0 0.25rem;
310
+ }
311
+
312
+ [hidden] {
313
+ display: none !important;
314
+ }
315
+ }