@prunellejs/ui 0.0.0-stage → 0.7.2
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/llms.txt +78 -0
- package/package.json +32 -4
- package/src/CommandPalette.tsx +262 -0
- package/src/DataTable.tsx +244 -0
- package/src/Dialog.tsx +181 -0
- package/src/Drawer.tsx +4 -0
- package/src/Menu.tsx +117 -0
- package/src/Select.tsx +125 -0
- package/src/Tabs.tsx +64 -0
- package/src/Toaster.tsx +105 -0
- package/src/behaviors.ts +385 -0
- package/src/field-context.ts +21 -0
- package/src/fold.ts +7 -0
- package/src/index.ts +72 -0
- package/src/labels/dialog.ts +3 -0
- package/src/labels/fr/dialog.ts +3 -0
- package/src/labels/fr/palette.ts +8 -0
- package/src/labels/fr/select.ts +1 -0
- package/src/labels/fr/table.ts +13 -0
- package/src/labels/fr/toaster.ts +1 -0
- package/src/labels/palette.ts +8 -0
- package/src/labels/select.ts +1 -0
- package/src/labels/table.ts +13 -0
- package/src/labels/toaster.ts +1 -0
- package/src/platform-fallback.ts +36 -0
- package/src/plugin.ts +188 -0
- package/src/primitives.tsx +238 -0
- package/src/static.tsx +324 -0
- package/src/styles/bare.css +25 -0
- package/src/styles/base.css +61 -0
- package/src/styles/components/accordion.css +10 -0
- package/src/styles/components/badge.css +6 -0
- package/src/styles/components/button.css +11 -0
- package/src/styles/components/card.css +5 -0
- package/src/styles/components/checkbox.css +11 -0
- package/src/styles/components/command.css +25 -0
- package/src/styles/components/consent.css +38 -0
- package/src/styles/components/datatable.css +9 -0
- package/src/styles/components/dialog.css +16 -0
- package/src/styles/components/drawer.css +29 -0
- package/src/styles/components/field.css +8 -0
- package/src/styles/components/layout.css +69 -0
- package/src/styles/components/menu.css +21 -0
- package/src/styles/components/notice.css +5 -0
- package/src/styles/components/popover.css +8 -0
- package/src/styles/components/progress.css +14 -0
- package/src/styles/components/radio-group.css +11 -0
- package/src/styles/components/select.css +25 -0
- package/src/styles/components/switch.css +42 -0
- package/src/styles/components/tabs.css +4 -0
- package/src/styles/components/toast.css +28 -0
- package/src/styles/grammars/console.css +179 -0
- package/src/styles/grammars/editorial.css +164 -0
- package/src/styles/grammars/orbit.css +269 -0
- package/src/styles/grammars/prunelle.css +504 -0
- package/src/styles/grammars/soft.css +160 -0
- package/src/styles/grammars/workshop.css +172 -0
- package/src/styles/scan.ts +144 -0
- package/src/styles/split.ts +429 -0
- package/src/styles/theme.css +22 -0
- package/src/styles/themed/accordion.css +20 -0
- package/src/styles/themed/badge.css +20 -0
- package/src/styles/themed/button.css +24 -0
- package/src/styles/themed/card.css +23 -0
- package/src/styles/themed/checkbox.css +4 -0
- package/src/styles/themed/command.css +33 -0
- package/src/styles/themed/consent.css +33 -0
- package/src/styles/themed/datatable.css +28 -0
- package/src/styles/themed/dialog.css +13 -0
- package/src/styles/themed/drawer.css +13 -0
- package/src/styles/themed/field.css +22 -0
- package/src/styles/themed/menu.css +21 -0
- package/src/styles/themed/notice.css +17 -0
- package/src/styles/themed/popover.css +11 -0
- package/src/styles/themed/radio-group.css +12 -0
- package/src/styles/themed/select.css +32 -0
- package/src/styles/themed/switch.css +23 -0
- package/src/styles/themed/tabs.css +20 -0
- package/src/styles/themed/toast.css +18 -0
- package/src/table-state.ts +163 -0
- package/src/tabs-state.ts +39 -0
- package/src/toast.ts +110 -0
- package/README.md +0 -3
package/src/static.tsx
ADDED
|
@@ -0,0 +1,324 @@
|
|
|
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('&', '&').replaceAll('"', '"').replaceAll('<', '<').replaceAll('>', '>')
|
|
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
|
+
// A disabled link drops its href, so it neither follows nor takes focus, as a disabled <button> does.
|
|
63
|
+
return (
|
|
64
|
+
<a data-ui="button" data-variant={props.variant ?? 'solid'} data-tone={props.tone} data-size={props.size ?? 'md'} href={props.disabled ? undefined : props.href} aria-disabled={props.disabled ? 'true' : undefined} class={props.class} {...rest}>
|
|
65
|
+
{props.children}
|
|
66
|
+
</a>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
return (
|
|
70
|
+
<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}>
|
|
71
|
+
{props.children}
|
|
72
|
+
</button>
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function Notice(props: BoxProps & { tone?: Tone | undefined, role?: 'status' | 'alert' | 'note' | undefined }) {
|
|
77
|
+
const rest = restProps(props, ['tone', 'role', 'class'])
|
|
78
|
+
return <div data-ui="notice" data-tone={props.tone} role={props.role ?? 'status'} class={props.class} {...rest}>{props.children}</div>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Zero-JS form field wrapper that auto-wires `for`, `aria-describedby`, `aria-invalid`, hints, and action errors. */
|
|
82
|
+
export interface FieldProps {
|
|
83
|
+
id: string
|
|
84
|
+
/** Text or markup; it sits inside the `<label for>` that names the control. */
|
|
85
|
+
label: PrunelleChild
|
|
86
|
+
hint?: string | undefined
|
|
87
|
+
error?: string | undefined
|
|
88
|
+
required?: boolean | undefined
|
|
89
|
+
class?: string | undefined
|
|
90
|
+
children?: PrunelleChild | undefined
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function mergeTokenAttr(existing: string | null | undefined, addition: string): string {
|
|
94
|
+
const tokens = (existing ?? '').split(/\s+/).filter(Boolean)
|
|
95
|
+
for (const tok of addition.split(/\s+/).filter(Boolean)) {
|
|
96
|
+
if (!tokens.includes(tok))
|
|
97
|
+
tokens.push(tok)
|
|
98
|
+
}
|
|
99
|
+
return tokens.join(' ')
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
interface ScannedTag {
|
|
103
|
+
start: number
|
|
104
|
+
end: number
|
|
105
|
+
tag: string
|
|
106
|
+
rawAttrs: string
|
|
107
|
+
selfClose: string
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const OPEN_TAG_RE = /<([a-zA-Z][\w-]*)(?=[\s/>])((?:"[^"]*"|'[^']*'|[^>"'])*)>/g
|
|
111
|
+
|
|
112
|
+
/** Quote-aware HTML opening tag scanner so `>` inside attribute values (e.g. `placeholder="x > 0"`) never truncates a tag. */
|
|
113
|
+
function scanOpeningTags(html: string): ScannedTag[] {
|
|
114
|
+
const tags: ScannedTag[] = []
|
|
115
|
+
OPEN_TAG_RE.lastIndex = 0
|
|
116
|
+
let m: RegExpExecArray | null
|
|
117
|
+
while ((m = OPEN_TAG_RE.exec(html)) !== null) {
|
|
118
|
+
const body = m[2]!
|
|
119
|
+
const selfClose = body.endsWith('/') ? '/' : ''
|
|
120
|
+
tags.push({
|
|
121
|
+
start: m.index,
|
|
122
|
+
end: m.index + m[0].length,
|
|
123
|
+
tag: m[1]!,
|
|
124
|
+
rawAttrs: selfClose ? body.slice(0, -1) : body,
|
|
125
|
+
selfClose,
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
return tags
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const NATIVE_CTRL_RE = /^(?:input|textarea|select)$/i
|
|
132
|
+
|
|
133
|
+
function wireFieldHtml(html: string, wiring: FieldControlWiring): string {
|
|
134
|
+
const tags = scanOpeningTags(html)
|
|
135
|
+
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)))
|
|
136
|
+
?? tags.find(t => /\brole\s*=\s*["'](?:combobox|textbox|listbox|spinbutton)["']/i.test(t.rawAttrs))
|
|
137
|
+
if (target === undefined)
|
|
138
|
+
return html
|
|
139
|
+
|
|
140
|
+
let attrs = target.rawAttrs
|
|
141
|
+
if (!/\bid\s*=/i.test(attrs))
|
|
142
|
+
attrs += ` id="${escAttr(wiring.id)}"`
|
|
143
|
+
else if (/\bid\s*=\s*"kui-[^"]*"/i.test(attrs))
|
|
144
|
+
attrs = attrs.replace(/\bid\s*=\s*"kui-[^"]*"/i, `id="${escAttr(wiring.id)}"`)
|
|
145
|
+
|
|
146
|
+
if (wiring.describedBy) {
|
|
147
|
+
const descRe = /(\baria-describedby\s*=\s*")([^"]*)(")/i
|
|
148
|
+
attrs = descRe.test(attrs)
|
|
149
|
+
? attrs.replace(descRe, (_, p1: string, cur: string, p3: string) => `${p1}${escAttr(mergeTokenAttr(cur, wiring.describedBy!))}${p3}`)
|
|
150
|
+
: `${attrs} aria-describedby="${escAttr(wiring.describedBy)}"`
|
|
151
|
+
}
|
|
152
|
+
if (wiring.invalid && !/\baria-invalid\s*=/i.test(attrs))
|
|
153
|
+
attrs += ' aria-invalid="true"'
|
|
154
|
+
if (wiring.required) {
|
|
155
|
+
if (NATIVE_CTRL_RE.test(target.tag) && !/\brequired(?:\s|=|$)/i.test(attrs))
|
|
156
|
+
attrs += ' required'
|
|
157
|
+
if (!/\baria-required\s*=/i.test(attrs))
|
|
158
|
+
attrs += ' aria-required="true"'
|
|
159
|
+
}
|
|
160
|
+
return `${html.slice(0, target.start)}<${target.tag}${attrs}${target.selfClose}>${html.slice(target.end)}`
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const CTRL_SEL = 'input:not([type="hidden"]),textarea,select,[role="combobox"],[role="textbox"],[role="listbox"],[role="spinbutton"]'
|
|
164
|
+
|
|
165
|
+
function syncFieldAria(el: Element, id: string, err: string | undefined, hint: string | undefined, clearInvalid: boolean): void {
|
|
166
|
+
const errId = `${id}-error`
|
|
167
|
+
const hintId = `${id}-hint`
|
|
168
|
+
const tokens = (el.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(t => t && t !== errId && t !== hintId)
|
|
169
|
+
if (err)
|
|
170
|
+
tokens.push(errId)
|
|
171
|
+
if (hint)
|
|
172
|
+
tokens.push(hintId)
|
|
173
|
+
if (tokens.length > 0)
|
|
174
|
+
el.setAttribute('aria-describedby', tokens.join(' '))
|
|
175
|
+
else
|
|
176
|
+
el.removeAttribute('aria-describedby')
|
|
177
|
+
if (err)
|
|
178
|
+
el.setAttribute('aria-invalid', 'true')
|
|
179
|
+
else if (clearInvalid)
|
|
180
|
+
el.removeAttribute('aria-invalid')
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function wireFieldElement(el: Element, wiring: FieldControlWiring, err: string | undefined, hint: string | undefined): void {
|
|
184
|
+
const curId = el.getAttribute('id')
|
|
185
|
+
if (!curId || curId.startsWith('kui-'))
|
|
186
|
+
el.setAttribute('id', wiring.id)
|
|
187
|
+
syncFieldAria(el, wiring.id, err, hint, false)
|
|
188
|
+
if (wiring.required) {
|
|
189
|
+
if (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.tagName === 'SELECT')
|
|
190
|
+
el.setAttribute('required', '')
|
|
191
|
+
if (!el.hasAttribute('aria-required'))
|
|
192
|
+
el.setAttribute('aria-required', 'true')
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function findFieldControlInNode(node: Node): Element | null {
|
|
197
|
+
if (node.nodeType === 1) {
|
|
198
|
+
const el = node as Element
|
|
199
|
+
return el.matches(CTRL_SEL) ? el : el.querySelector(CTRL_SEL)
|
|
200
|
+
}
|
|
201
|
+
return node.nodeType === 11 ? (node as DocumentFragment).querySelector(CTRL_SEL) : null
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const RAW_HTML_BRAND = Symbol.for('pru.html')
|
|
205
|
+
|
|
206
|
+
// The client build defines it, which drops the server-rendered HTML wiring (and its tag scanner) from islands: there a child is a DOM node.
|
|
207
|
+
declare const PRUNELLE_BROWSER: boolean | undefined
|
|
208
|
+
|
|
209
|
+
function wireFieldChildren(
|
|
210
|
+
children: PrunelleChild,
|
|
211
|
+
wiring: FieldControlWiring,
|
|
212
|
+
err: string | undefined,
|
|
213
|
+
hint: string | undefined,
|
|
214
|
+
onControl: (el: Element) => void,
|
|
215
|
+
state: { done: boolean } = { done: false },
|
|
216
|
+
): PrunelleChild {
|
|
217
|
+
if (state.done || children == null || typeof children !== 'object')
|
|
218
|
+
return children
|
|
219
|
+
if (Array.isArray(children))
|
|
220
|
+
return children.map(child => (state.done ? child : wireFieldChildren(child, wiring, err, hint, onControl, state)))
|
|
221
|
+
if ((typeof PRUNELLE_BROWSER === 'undefined' || !PRUNELLE_BROWSER) && '__html' in children && (children as unknown as Record<symbol, unknown>)[RAW_HTML_BRAND] === true) {
|
|
222
|
+
const src = (children as Html).__html
|
|
223
|
+
const patched = wireFieldHtml(src, wiring)
|
|
224
|
+
if (patched !== src) {
|
|
225
|
+
state.done = true
|
|
226
|
+
return { [RAW_HTML_BRAND]: true, __html: patched } as unknown as Html
|
|
227
|
+
}
|
|
228
|
+
return children
|
|
229
|
+
}
|
|
230
|
+
if (typeof Node !== 'undefined' && children instanceof Node) {
|
|
231
|
+
const ctrl = findFieldControlInNode(children)
|
|
232
|
+
if (ctrl !== null) {
|
|
233
|
+
wireFieldElement(ctrl, wiring, err, hint)
|
|
234
|
+
onControl(ctrl)
|
|
235
|
+
state.done = true
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return children
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function Field(props: FieldProps) {
|
|
242
|
+
let ctrlEl: Element | null = null
|
|
243
|
+
let lastError: string | undefined
|
|
244
|
+
let ownedInvalid = false
|
|
245
|
+
|
|
246
|
+
const syncInvalid = (): 'true' | undefined => {
|
|
247
|
+
const err = props.error
|
|
248
|
+
lastError = err
|
|
249
|
+
if (typeof document !== 'undefined') {
|
|
250
|
+
const target = ctrlEl ?? document.getElementById(props.id)
|
|
251
|
+
if (target !== null && (target === ctrlEl || target.closest('[data-ui="field"]') !== null)) {
|
|
252
|
+
ctrlEl = target
|
|
253
|
+
syncFieldAria(target, props.id, err, props.hint, ownedInvalid)
|
|
254
|
+
ownedInvalid = Boolean(err)
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return err ? 'true' : undefined
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<div data-ui="field" data-invalid={syncInvalid()} class={props.class}>
|
|
262
|
+
<label data-part="label" for={props.id}>
|
|
263
|
+
{props.label}
|
|
264
|
+
{props.required && <span aria-hidden="true"> *</span>}
|
|
265
|
+
</label>
|
|
266
|
+
{(() => {
|
|
267
|
+
const wiring: FieldControlWiring = {
|
|
268
|
+
id: props.id,
|
|
269
|
+
describedBy: [lastError && `${props.id}-error`, props.hint && `${props.id}-hint`].filter(Boolean).join(' ') || undefined,
|
|
270
|
+
invalid: Boolean(lastError),
|
|
271
|
+
required: Boolean(props.required),
|
|
272
|
+
}
|
|
273
|
+
return provideContext(FieldContext, wiring, () => wireFieldChildren(props.children, wiring, lastError, props.hint, (el) => {
|
|
274
|
+
ctrlEl = el
|
|
275
|
+
if (wiring.invalid)
|
|
276
|
+
ownedInvalid = true
|
|
277
|
+
}))
|
|
278
|
+
})()}
|
|
279
|
+
{props.hint && <p data-part="hint" id={`${props.id}-hint`}>{props.hint}</p>}
|
|
280
|
+
{props.error && <p data-part="error" id={`${props.id}-error`} role="alert">{props.error}</p>}
|
|
281
|
+
</div>
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// ---- Every Layout primitives (pure CSS, 0 KB JS, strict-CSP safe) ----
|
|
286
|
+
|
|
287
|
+
export type SpaceToken = 'none' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'
|
|
288
|
+
export type TrackSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
289
|
+
export type SpaceValue = SpaceToken | (string & {})
|
|
290
|
+
export type TrackValue = TrackSize | (string & {})
|
|
291
|
+
|
|
292
|
+
const SPACE_TOKENS = new Set<string>(['none', '2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl'])
|
|
293
|
+
|
|
294
|
+
const isSpaceToken = (v: string | undefined): boolean => v !== undefined && SPACE_TOKENS.has(v)
|
|
295
|
+
|
|
296
|
+
export function Stack(props: BoxProps & { gap?: SpaceValue | undefined }) {
|
|
297
|
+
const rest = restProps(props, ['gap', 'class'])
|
|
298
|
+
return (
|
|
299
|
+
<div
|
|
300
|
+
data-layout="stack"
|
|
301
|
+
data-gap={isSpaceToken(props.gap) ? props.gap : undefined}
|
|
302
|
+
data-gap-value={props.gap && !isSpaceToken(props.gap) ? props.gap : undefined}
|
|
303
|
+
class={props.class}
|
|
304
|
+
{...rest}
|
|
305
|
+
>
|
|
306
|
+
{props.children}
|
|
307
|
+
</div>
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export function Cluster(props: BoxProps & { gap?: SpaceValue | undefined }) {
|
|
312
|
+
const rest = restProps(props, ['gap', 'class'])
|
|
313
|
+
return (
|
|
314
|
+
<div
|
|
315
|
+
data-layout="cluster"
|
|
316
|
+
data-gap={isSpaceToken(props.gap) ? props.gap : undefined}
|
|
317
|
+
data-gap-value={props.gap && !isSpaceToken(props.gap) ? props.gap : undefined}
|
|
318
|
+
class={props.class}
|
|
319
|
+
{...rest}
|
|
320
|
+
>
|
|
321
|
+
{props.children}
|
|
322
|
+
</div>
|
|
323
|
+
)
|
|
324
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
@import './base.css';
|
|
5
|
+
@import './components/layout.css';
|
|
6
|
+
@import './components/button.css';
|
|
7
|
+
@import './components/card.css';
|
|
8
|
+
@import './components/badge.css';
|
|
9
|
+
@import './components/notice.css';
|
|
10
|
+
@import './components/consent.css';
|
|
11
|
+
@import './components/field.css';
|
|
12
|
+
@import './components/checkbox.css';
|
|
13
|
+
@import './components/switch.css';
|
|
14
|
+
@import './components/radio-group.css';
|
|
15
|
+
@import './components/progress.css';
|
|
16
|
+
@import './components/accordion.css';
|
|
17
|
+
@import './components/tabs.css';
|
|
18
|
+
@import './components/dialog.css';
|
|
19
|
+
@import './components/drawer.css';
|
|
20
|
+
@import './components/command.css';
|
|
21
|
+
@import './components/popover.css';
|
|
22
|
+
@import './components/menu.css';
|
|
23
|
+
@import './components/select.css';
|
|
24
|
+
@import './components/toast.css';
|
|
25
|
+
@import './components/datatable.css';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* @prunellejs/ui base floor: box-sizing, screen-reader utility, single focus indicator, reduced motion & [hidden].
|
|
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-focus-color, 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 44px targets & iOS 16px input floor on phones */
|
|
45
|
+
@media (max-width: 600px) {
|
|
46
|
+
:root {
|
|
47
|
+
--ui-touch-min: 44px;
|
|
48
|
+
--ui-input-floor: max(1rem, 16px);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[hidden] {
|
|
53
|
+
display: none !important;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Windows high contrast drops backgrounds and box-shadows, so each state drawn with them is redrawn with system colors, here and in each component's themed sheet; `:root` outranks the themed and grammar rules. */
|
|
57
|
+
@media (forced-colors: active) {
|
|
58
|
+
:root [data-ui] [data-highlighted="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
|
|
59
|
+
:root [data-ui][data-disabled="true"] { color: GrayText; }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
@layer kui {
|
|
2
|
+
[data-ui="button"] {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
min-block-size: var(--ui-touch-min, auto);
|
|
7
|
+
text-decoration: none;
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
&:disabled, &[aria-disabled="true"] { cursor: not-allowed; }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
@layer kui {
|
|
2
|
+
[data-ui="checkbox"] {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--ui-check-gap, 0.55rem);
|
|
6
|
+
min-block-size: var(--ui-touch-min, auto);
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
user-select: none;
|
|
9
|
+
&[data-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@layer kui {
|
|
2
|
+
html:has(dialog[data-ui]:modal) { overflow: hidden; }
|
|
3
|
+
dialog[data-ui="command"] {
|
|
4
|
+
padding: 0;
|
|
5
|
+
margin: auto;
|
|
6
|
+
max-inline-size: min(32rem, calc(100vw - 2rem));
|
|
7
|
+
max-block-size: calc(100dvh - 2rem);
|
|
8
|
+
overflow: auto;
|
|
9
|
+
inline-size: min(34rem, calc(100vw - 2rem));
|
|
10
|
+
margin-block-start: min(14vh, 6rem);
|
|
11
|
+
}
|
|
12
|
+
dialog[data-ui="command"]::backdrop { background: rgb(0 0 0 / 0.45); }
|
|
13
|
+
dialog[data-ui="command"] [data-part="input"] {
|
|
14
|
+
width: 100%;
|
|
15
|
+
font-size: var(--ui-input-floor, inherit);
|
|
16
|
+
&:focus-visible { outline-offset: -2px; }
|
|
17
|
+
}
|
|
18
|
+
dialog[data-ui="command"] [data-part="item"] {
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: space-between;
|
|
21
|
+
align-items: center;
|
|
22
|
+
width: 100%;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@layer kui {
|
|
2
|
+
section[data-ui="consent"] {
|
|
3
|
+
position: fixed;
|
|
4
|
+
inset-inline: 1rem;
|
|
5
|
+
inset-block-end: 1rem;
|
|
6
|
+
z-index: 50;
|
|
7
|
+
max-inline-size: 40rem;
|
|
8
|
+
max-block-size: calc(100dvh - 2rem);
|
|
9
|
+
margin-inline: auto;
|
|
10
|
+
overflow: auto;
|
|
11
|
+
}
|
|
12
|
+
/* Refuse and Accept share the banner row at one width; on a page the preferences buttons keep their own. */
|
|
13
|
+
section[data-ui="consent"] [data-part="actions"] > button {
|
|
14
|
+
flex: 1 1 10rem;
|
|
15
|
+
}
|
|
16
|
+
[data-ui="consent"] {
|
|
17
|
+
& [data-part="actions"] {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
gap: 0.5rem;
|
|
21
|
+
}
|
|
22
|
+
& [data-part="choices"] {
|
|
23
|
+
display: grid;
|
|
24
|
+
margin: 0;
|
|
25
|
+
padding: 0;
|
|
26
|
+
border: 0;
|
|
27
|
+
}
|
|
28
|
+
& [data-part="choice"] {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
gap: 0.5rem;
|
|
32
|
+
min-block-size: 2.75rem;
|
|
33
|
+
}
|
|
34
|
+
& [data-part="details"] > summary {
|
|
35
|
+
padding-block: 0.75rem;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
@layer kui {
|
|
2
|
+
[data-ui="datatable"] { display: flex; flex-direction: column; gap: var(--ui-table-gap, 0.75rem); }
|
|
3
|
+
[data-ui="datatable"] [data-part="scroll"] { overflow-x: auto; }
|
|
4
|
+
[data-ui="datatable"] [data-part="search"] { min-block-size: var(--ui-touch-min, auto); font-size: var(--ui-input-floor, inherit); }
|
|
5
|
+
[data-ui="datatable"] [data-part="pagination"] [data-layout="cluster"] { --ui-gap: 0.4rem; }
|
|
6
|
+
table[data-ui="table"] { width: 100%; border-collapse: collapse; text-align: left; }
|
|
7
|
+
table[data-ui="table"] > caption { text-align: start; font-weight: 600; margin-block-end: 0.5rem; }
|
|
8
|
+
[data-ui="datatable"] [data-part="sort"] { background: transparent; border: 0; padding: 0; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; cursor: pointer; }
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@layer kui {
|
|
2
|
+
/* The page behind a modal does not scroll */
|
|
3
|
+
html:has(dialog[data-ui]:modal) {
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
}
|
|
6
|
+
dialog[data-ui="dialog"] {
|
|
7
|
+
padding: 0;
|
|
8
|
+
margin: auto;
|
|
9
|
+
max-inline-size: min(32rem, calc(100vw - 2rem));
|
|
10
|
+
max-block-size: calc(100dvh - 2rem);
|
|
11
|
+
overflow: auto;
|
|
12
|
+
}
|
|
13
|
+
dialog[data-ui="dialog"]::backdrop {
|
|
14
|
+
background: rgb(0 0 0 / 0.45);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@layer kui {
|
|
2
|
+
html:has(dialog[data-ui]:modal) {
|
|
3
|
+
overflow: hidden;
|
|
4
|
+
}
|
|
5
|
+
dialog[data-ui="drawer"] {
|
|
6
|
+
padding: 0;
|
|
7
|
+
margin: 0;
|
|
8
|
+
max-block-size: 100dvh;
|
|
9
|
+
block-size: 100dvh;
|
|
10
|
+
inline-size: min(26rem, 90vw);
|
|
11
|
+
max-inline-size: 90vw;
|
|
12
|
+
overflow: auto;
|
|
13
|
+
&[data-side="right"] { margin-inline-start: auto; }
|
|
14
|
+
&[data-side="left"] { margin-inline-end: auto; }
|
|
15
|
+
&[data-side="bottom"] {
|
|
16
|
+
margin-block-start: auto;
|
|
17
|
+
inline-size: 100vw;
|
|
18
|
+
max-inline-size: 100vw;
|
|
19
|
+
block-size: auto;
|
|
20
|
+
max-block-size: 80dvh;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
dialog[data-ui="drawer"] > [data-part="panel"] {
|
|
24
|
+
min-block-size: 100%;
|
|
25
|
+
}
|
|
26
|
+
dialog[data-ui="drawer"]::backdrop {
|
|
27
|
+
background: rgb(0 0 0 / 0.45);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
@layer kui {
|
|
2
|
+
[data-ui="field"] {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
& :is(input:not([type="checkbox"], [type="radio"]), select) { min-block-size: var(--ui-touch-min, auto); }
|
|
6
|
+
& :is(input:not([type="checkbox"], [type="radio"]), select, textarea) { font-size: var(--ui-input-floor, inherit); }
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
@layer kui {
|
|
2
|
+
/* Every Layout primitives (0 KB JS) */
|
|
3
|
+
[data-layout="stack"] {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
gap: var(--ui-gap, 1rem);
|
|
7
|
+
}
|
|
8
|
+
[data-layout="cluster"] {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: var(--ui-gap, 0.75rem);
|
|
13
|
+
}
|
|
14
|
+
[data-layout="grid"] {
|
|
15
|
+
display: grid;
|
|
16
|
+
grid-template-columns: repeat(auto-fit, minmax(min(var(--ui-min, 16rem), 100%), 1fr));
|
|
17
|
+
gap: var(--ui-gap, 1rem);
|
|
18
|
+
}
|
|
19
|
+
[data-layout="sidebar"] {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-wrap: wrap;
|
|
22
|
+
gap: var(--ui-gap, 1.5rem);
|
|
23
|
+
}
|
|
24
|
+
[data-layout="sidebar"] > :first-child {
|
|
25
|
+
flex-basis: var(--ui-side, 16rem);
|
|
26
|
+
flex-grow: 1;
|
|
27
|
+
}
|
|
28
|
+
[data-layout="sidebar"] > :last-child {
|
|
29
|
+
flex-basis: 0;
|
|
30
|
+
flex-grow: 999;
|
|
31
|
+
min-inline-size: var(--ui-content-min, 60%);
|
|
32
|
+
}
|
|
33
|
+
[data-layout="split"] {
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-wrap: wrap;
|
|
36
|
+
align-items: center;
|
|
37
|
+
justify-content: space-between;
|
|
38
|
+
gap: var(--ui-gap, 1rem);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* Layout scale tokens (0 KB JS, strict-CSP safe across all browsers) */
|
|
42
|
+
[data-layout][data-gap="none"] { --ui-gap: 0; }
|
|
43
|
+
[data-layout][data-gap="2xs"] { --ui-gap: var(--ui-space-2xs, 0.25rem); }
|
|
44
|
+
[data-layout][data-gap="xs"] { --ui-gap: var(--ui-space-xs, 0.5rem); }
|
|
45
|
+
[data-layout][data-gap="sm"] { --ui-gap: var(--ui-space-sm, 0.75rem); }
|
|
46
|
+
[data-layout][data-gap="md"] { --ui-gap: var(--ui-space-md, 1rem); }
|
|
47
|
+
[data-layout][data-gap="lg"] { --ui-gap: var(--ui-space-lg, 1.5rem); }
|
|
48
|
+
[data-layout][data-gap="xl"] { --ui-gap: var(--ui-space-xl, 2rem); }
|
|
49
|
+
[data-layout][data-gap="2xl"] { --ui-gap: var(--ui-space-2xl, 3rem); }
|
|
50
|
+
|
|
51
|
+
[data-layout="grid"][data-min="xs"] { --ui-min: 10rem; }
|
|
52
|
+
[data-layout="grid"][data-min="sm"] { --ui-min: 14rem; }
|
|
53
|
+
[data-layout="grid"][data-min="md"] { --ui-min: 16rem; }
|
|
54
|
+
[data-layout="grid"][data-min="lg"] { --ui-min: 20rem; }
|
|
55
|
+
[data-layout="grid"][data-min="xl"] { --ui-min: 24rem; }
|
|
56
|
+
|
|
57
|
+
[data-layout="sidebar"][data-side="xs"] { --ui-side: 10rem; }
|
|
58
|
+
[data-layout="sidebar"][data-side="sm"] { --ui-side: 12rem; }
|
|
59
|
+
[data-layout="sidebar"][data-side="md"] { --ui-side: 16rem; }
|
|
60
|
+
[data-layout="sidebar"][data-side="lg"] { --ui-side: 20rem; }
|
|
61
|
+
[data-layout="sidebar"][data-side="xl"] { --ui-side: 24rem; }
|
|
62
|
+
|
|
63
|
+
/* Progressive CSS Values 5 attr() support for custom CSS lengths without inline style attributes */
|
|
64
|
+
@supports (gap: attr(data-gap-value type(<length-percentage>))) {
|
|
65
|
+
[data-layout][data-gap-value] { --ui-gap: attr(data-gap-value type(<length-percentage>)); }
|
|
66
|
+
[data-layout="grid"][data-min-value] { --ui-min: attr(data-min-value type(<length-percentage>)); }
|
|
67
|
+
[data-layout="sidebar"][data-side-value] { --ui-side: attr(data-side-value type(<length-percentage>)); }
|
|
68
|
+
}
|
|
69
|
+
}
|