@prunellejs/ui 0.1.1 → 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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/llms.txt +19 -11
  3. package/package.json +2 -2
  4. package/src/CommandPalette.tsx +130 -75
  5. package/src/DataTable.tsx +137 -58
  6. package/src/Dialog.tsx +30 -14
  7. package/src/Menu.tsx +10 -8
  8. package/src/Select.tsx +19 -8
  9. package/src/Tabs.tsx +2 -1
  10. package/src/Toaster.tsx +79 -5
  11. package/src/behaviors.ts +104 -6
  12. package/src/fold.ts +7 -0
  13. package/src/index.ts +1 -1
  14. package/src/labels/dialog.ts +3 -0
  15. package/src/labels/fr/dialog.ts +3 -0
  16. package/src/labels/fr/palette.ts +8 -0
  17. package/src/labels/fr/select.ts +1 -0
  18. package/src/labels/fr/table.ts +13 -0
  19. package/src/labels/fr/toaster.ts +1 -0
  20. package/src/labels/palette.ts +8 -0
  21. package/src/labels/select.ts +1 -0
  22. package/src/labels/table.ts +13 -0
  23. package/src/labels/toaster.ts +1 -0
  24. package/src/plugin.ts +114 -31
  25. package/src/primitives.tsx +3 -2
  26. package/src/static.tsx +11 -6
  27. package/src/styles/bare.css +22 -312
  28. package/src/styles/base.css +61 -0
  29. package/src/styles/components/accordion.css +10 -0
  30. package/src/styles/components/badge.css +6 -0
  31. package/src/styles/components/button.css +11 -0
  32. package/src/styles/components/card.css +5 -0
  33. package/src/styles/components/checkbox.css +11 -0
  34. package/src/styles/components/command.css +25 -0
  35. package/src/styles/components/consent.css +38 -0
  36. package/src/styles/components/datatable.css +9 -0
  37. package/src/styles/components/dialog.css +16 -0
  38. package/src/styles/components/drawer.css +29 -0
  39. package/src/styles/components/field.css +8 -0
  40. package/src/styles/components/layout.css +69 -0
  41. package/src/styles/components/menu.css +21 -0
  42. package/src/styles/components/notice.css +5 -0
  43. package/src/styles/components/popover.css +8 -0
  44. package/src/styles/components/progress.css +14 -0
  45. package/src/styles/components/radio-group.css +11 -0
  46. package/src/styles/components/select.css +25 -0
  47. package/src/styles/components/switch.css +42 -0
  48. package/src/styles/components/tabs.css +4 -0
  49. package/src/styles/components/toast.css +28 -0
  50. package/src/styles/grammars/console.css +114 -256
  51. package/src/styles/grammars/editorial.css +101 -271
  52. package/src/styles/grammars/orbit.css +121 -390
  53. package/src/styles/grammars/prunelle.css +209 -357
  54. package/src/styles/grammars/soft.css +106 -240
  55. package/src/styles/grammars/workshop.css +110 -251
  56. package/src/styles/scan.ts +144 -0
  57. package/src/styles/split.ts +429 -0
  58. package/src/styles/theme.css +22 -0
  59. package/src/styles/themed/accordion.css +20 -0
  60. package/src/styles/themed/badge.css +20 -0
  61. package/src/styles/themed/button.css +24 -0
  62. package/src/styles/themed/card.css +23 -0
  63. package/src/styles/themed/checkbox.css +4 -0
  64. package/src/styles/themed/command.css +33 -0
  65. package/src/styles/themed/consent.css +33 -0
  66. package/src/styles/themed/datatable.css +28 -0
  67. package/src/styles/themed/dialog.css +13 -0
  68. package/src/styles/themed/drawer.css +13 -0
  69. package/src/styles/themed/field.css +22 -0
  70. package/src/styles/themed/menu.css +21 -0
  71. package/src/styles/themed/notice.css +17 -0
  72. package/src/styles/themed/popover.css +11 -0
  73. package/src/styles/themed/radio-group.css +12 -0
  74. package/src/styles/themed/select.css +32 -0
  75. package/src/styles/themed/switch.css +23 -0
  76. package/src/styles/themed/tabs.css +20 -0
  77. package/src/styles/themed/toast.css +18 -0
  78. package/src/table-state.ts +53 -16
  79. package/src/toast.ts +50 -8
package/src/plugin.ts CHANGED
@@ -1,38 +1,41 @@
1
1
  // @prunellejs/ui PrunellePlugin — wires a pure CSS Grammar (`editorial | workshop | console | soft | orbit | prunelle | bare`)
2
- // and adds `prunelle ui-eject <grammar> [dest]` so apps can copy & own the entire look in ONE ~200-line CSS file.
2
+ // and adds `prunelle ui-eject <grammar> [dest]` so apps can copy & own the entire look in ONE CSS file.
3
3
 
4
- import type { PrunellePlugin } from 'prunelle/config'
5
- import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
4
+ import type { BunPlugin } from 'bun'
5
+ import type { BuildPluginContext, PrunellePlugin } from 'prunelle/config'
6
+ import type { GrammarName, UiComponentPart } from './styles/split'
7
+ import { createHash } from 'node:crypto'
8
+ import { mkdirSync, writeFileSync } from 'node:fs'
6
9
  import { dirname, join, resolve } from 'node:path'
7
- import { definePlugin, serviceKey } from 'prunelle/config'
10
+ import { definePlugin, minifyCss, UI_KUI_LAYER_SERVICE } from 'prunelle/config'
8
11
  import { FALLBACK_FILE, FALLBACK_GUARD, FALLBACK_JS, withPlatformFallback } from './platform-fallback'
12
+ import { createUiPartScanner } from './styles/scan'
13
+ import {
14
+ GRAMMAR_NAMES,
15
+ grammarCssPath,
16
+ renderGrammarBaseCss,
17
+ renderGrammarCss as renderFullGrammarCss,
18
+ renderGrammarPartsCss,
19
+ UI_COMPONENT_PARTS,
20
+ UI_EXPORT_TO_PARTS,
21
+ } from './styles/split'
9
22
 
10
- const UI_KUI_LAYER_SERVICE = serviceKey<boolean>('prunelle.ui.kuiLayer')
11
-
12
- export type GrammarName = 'bare' | 'editorial' | 'workshop' | 'console' | 'soft' | 'orbit' | 'prunelle'
13
-
14
- export const GRAMMAR_NAMES: readonly GrammarName[] = ['bare', 'editorial', 'workshop', 'console', 'soft', 'orbit', 'prunelle']
15
-
16
- const STYLES_DIR = join(import.meta.dir, 'styles')
17
- const BARE_IMPORT_RE = /^@import\s+['"]\.\.\/bare\.css['"];?\s*/gm
18
-
19
- export function grammarCssPath(grammar: GrammarName): string {
20
- return grammar === 'bare'
21
- ? join(STYLES_DIR, 'bare.css')
22
- : join(STYLES_DIR, 'grammars', `${grammar}.css`)
23
+ export {
24
+ GRAMMAR_NAMES,
25
+ grammarCssPath,
26
+ renderGrammarBaseCss,
27
+ renderGrammarPartsCss,
28
+ UI_COMPONENT_PARTS,
29
+ UI_EXPORT_TO_PARTS,
23
30
  }
31
+ export type { GrammarName, UiComponentPart }
24
32
 
25
- /** Returns the self-contained CSS source for a grammar (with `bare.css` inlined). */
26
- export function renderGrammarCss(grammar: GrammarName, bareCss?: string): string {
27
- const bare = bareCss ?? readFileSync(join(STYLES_DIR, 'bare.css'), 'utf8')
28
- if (grammar === 'bare')
29
- return bare
30
- const rawGrammar = readFileSync(grammarCssPath(grammar), 'utf8')
31
- const withoutImport = rawGrammar.replace(BARE_IMPORT_RE, '')
32
- return `${bare}\n${withoutImport}`
33
+ /** Returns the self-contained CSS source for a grammar (with `base.css` and component sheets inlined). */
34
+ export function renderGrammarCss(grammar: GrammarName): string {
35
+ return renderFullGrammarCss(grammar)
33
36
  }
34
37
 
35
- /** Ejects a complete, self-contained CSS Grammar file (with bare.css inlined) into the app! */
38
+ /** Ejects a complete, self-contained CSS Grammar file into the app. */
36
39
  export function ejectGrammar(root: string, grammar: GrammarName = 'editorial', destRel = 'src/styles/ui.css'): string {
37
40
  const outPath = resolve(root, destRel)
38
41
  mkdirSync(dirname(outPath), { recursive: true })
@@ -66,23 +69,103 @@ function resolveEmitGrammars(opt: UiPluginOptions['emitGrammars']): { dir: strin
66
69
  return { dir, grammars: opts.grammars ?? GRAMMAR_NAMES }
67
70
  }
68
71
 
72
+ function cssHash(css: string): string {
73
+ return createHash('sha256').update(css).digest('hex').slice(0, 8)
74
+ }
75
+
76
+ function emitGrammarStyles(ctx: BuildPluginContext, grammar: GrammarName): void {
77
+ const prepGlobal = ctx.prependStyle ?? ctx.addStyle
78
+ const prepRoute = ctx.prependRouteStyle ?? ctx.addRouteStyle
79
+ if (prepGlobal === undefined)
80
+ return
81
+ const format = (css: string): string => ctx.minify ? minifyCss(css) : css
82
+
83
+ if (ctx.routeSourceFiles === undefined) {
84
+ const full = format(renderGrammarCss(grammar))
85
+ prepGlobal(ctx.emitAsset(`${grammar}-${cssHash(full)}.css`, full))
86
+ return
87
+ }
88
+
89
+ const scan = createUiPartScanner()
90
+ const globalParts = scan(ctx.globalSourceFiles ?? [])
91
+ const routes = ctx.routes ?? []
92
+ const perRoute = new Map<string, Set<UiComponentPart>>()
93
+ for (const route of routes)
94
+ perRoute.set(route.path, scan(ctx.routeSourceFiles.get(route.path) ?? []))
95
+
96
+ // Any UI component part rendered on every route belongs in the site-wide sheet so it is cached across navigations.
97
+ if (routes.length > 0) {
98
+ const firstParts = perRoute.get(routes[0]!.path)!
99
+ for (const part of firstParts) {
100
+ if (routes.every(r => perRoute.get(r.path)!.has(part)))
101
+ globalParts.add(part)
102
+ }
103
+ }
104
+
105
+ const baseSource = globalParts.size > 0
106
+ ? `${renderGrammarBaseCss(grammar)}\n${renderGrammarPartsCss(grammar, globalParts)}`
107
+ : renderGrammarBaseCss(grammar)
108
+ const baseCss = format(baseSource)
109
+ prepGlobal(ctx.emitAsset(`${grammar}-${cssHash(baseCss)}.css`, baseCss))
110
+
111
+ if (prepRoute === undefined)
112
+ return
113
+ const routeCache = new Map<string, string>()
114
+ for (const route of routes) {
115
+ const routeParts = perRoute.get(route.path)!
116
+ const extra = UI_COMPONENT_PARTS.filter(p => routeParts.has(p) && !globalParts.has(p))
117
+ if (extra.length === 0)
118
+ continue
119
+ const key = extra.join(',')
120
+ let href = routeCache.get(key)
121
+ if (href === undefined) {
122
+ const partsCss = format(renderGrammarPartsCss(grammar, extra))
123
+ href = ctx.emitAsset(`${grammar}-parts-${cssHash(partsCss)}.css`, partsCss)
124
+ routeCache.set(key, href)
125
+ }
126
+ prepRoute(route.path, href)
127
+ }
128
+ }
129
+
130
+ const LABELS_DIR = join(import.meta.dir, 'labels')
131
+ const LABELS_FILTER = new RegExp(`^${LABELS_DIR.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\\\/](\\w+)\\.ts$`)
132
+ const FRENCH_RE = /^fr(?:-|$)/i
133
+
134
+ // A French app loads labels/fr/<name>.ts wherever ui imports labels/<name>.ts, so each island ships its own labels in one language.
135
+ function frenchLabels(lang: string | undefined): BunPlugin[] {
136
+ if (lang === undefined || !FRENCH_RE.test(lang))
137
+ return []
138
+ return [{
139
+ name: 'prunelle-ui-labels',
140
+ setup(build) {
141
+ build.onLoad({ filter: LABELS_FILTER }, async args => ({
142
+ contents: await Bun.file(join(LABELS_DIR, 'fr', `${LABELS_FILTER.exec(args.path)![1]}.ts`)).text(),
143
+ loader: 'ts',
144
+ }))
145
+ },
146
+ }]
147
+ }
148
+
69
149
  export function ui(options: UiPluginOptions = {}): PrunellePlugin {
70
150
  const grammar = options.grammar === undefined ? 'editorial' : options.grammar
71
151
  const emit = resolveEmitGrammars(options.emitGrammars)
72
152
  let assetPrefix = '/_pru'
73
153
  return definePlugin({
74
154
  name: '@prunellejs/ui',
75
- css: grammar === false ? undefined : [grammarCssPath(grammar)],
76
155
  inlineScripts: [FALLBACK_GUARD],
156
+ bunPlugins: ({ lang }) => frenchLabels(lang),
77
157
  build(ctx) {
78
158
  ctx.emitAsset(FALLBACK_FILE, FALLBACK_JS)
79
- if (grammar !== false)
159
+ if (grammar !== false) {
80
160
  ctx.provide?.(UI_KUI_LAYER_SERVICE, true)
161
+ emitGrammarStyles(ctx, grammar)
162
+ }
81
163
  if (emit !== undefined) {
82
- const bare = readFileSync(join(STYLES_DIR, 'bare.css'), 'utf8')
83
164
  const prefix = emit.dir ? `${emit.dir}/` : ''
84
- for (const g of emit.grammars)
85
- ctx.emitPublic(`${prefix}${g}.css`, renderGrammarCss(g, bare))
165
+ for (const g of emit.grammars) {
166
+ const css = renderGrammarCss(g)
167
+ ctx.emitPublic(`${prefix}${g}.css`, ctx.minify ? minifyCss(css) : css)
168
+ }
86
169
  }
87
170
  },
88
171
  server(api) {
@@ -150,7 +150,8 @@ export interface CheckControlProps {
150
150
  id?: string | undefined
151
151
  name?: string | undefined
152
152
  value?: string | undefined
153
- label: string
153
+ /** Text or markup (a link to the privacy policy); it sits inside the wrapping `<label>`, so it names the control. */
154
+ label: PrunelleChild
154
155
  checked?: boolean | undefined
155
156
  disabled?: boolean | undefined
156
157
  class?: string | undefined
@@ -178,7 +179,7 @@ export function Switch({ id, name, value, label, checked, disabled, class: cls,
178
179
 
179
180
  export interface RadioOption {
180
181
  value: string
181
- label: string
182
+ label: PrunelleChild
182
183
  hint?: string | undefined
183
184
  disabled?: boolean | undefined
184
185
  }
package/src/static.tsx CHANGED
@@ -59,8 +59,9 @@ function restProps(props: Record<string, unknown>, skip: readonly string[]): Rec
59
59
  export function Button(props: ButtonProps) {
60
60
  const rest = restProps(props as unknown as Record<string, unknown>, ['variant', 'tone', 'size', 'href', 'type', 'disabled', 'class'])
61
61
  if (props.href !== undefined) {
62
+ // A disabled link drops its href, so it neither follows nor takes focus, as a disabled <button> does.
62
63
  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
+ <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}>
64
65
  {props.children}
65
66
  </a>
66
67
  )
@@ -80,7 +81,8 @@ export function Notice(props: BoxProps & { tone?: Tone | undefined, role?: 'stat
80
81
  /** Zero-JS form field wrapper that auto-wires `for`, `aria-describedby`, `aria-invalid`, hints, and action errors. */
81
82
  export interface FieldProps {
82
83
  id: string
83
- label: string
84
+ /** Text or markup; it sits inside the `<label for>` that names the control. */
85
+ label: PrunelleChild
84
86
  hint?: string | undefined
85
87
  error?: string | undefined
86
88
  required?: boolean | undefined
@@ -166,7 +168,7 @@ function syncFieldAria(el: Element, id: string, err: string | undefined, hint: s
166
168
  const tokens = (el.getAttribute('aria-describedby') ?? '').split(/\s+/).filter(t => t && t !== errId && t !== hintId)
167
169
  if (err)
168
170
  tokens.push(errId)
169
- else if (hint)
171
+ if (hint)
170
172
  tokens.push(hintId)
171
173
  if (tokens.length > 0)
172
174
  el.setAttribute('aria-describedby', tokens.join(' '))
@@ -201,6 +203,9 @@ function findFieldControlInNode(node: Node): Element | null {
201
203
 
202
204
  const RAW_HTML_BRAND = Symbol.for('pru.html')
203
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
+
204
209
  function wireFieldChildren(
205
210
  children: PrunelleChild,
206
211
  wiring: FieldControlWiring,
@@ -213,7 +218,7 @@ function wireFieldChildren(
213
218
  return children
214
219
  if (Array.isArray(children))
215
220
  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) {
221
+ if ((typeof PRUNELLE_BROWSER === 'undefined' || !PRUNELLE_BROWSER) && '__html' in children && (children as unknown as Record<symbol, unknown>)[RAW_HTML_BRAND] === true) {
217
222
  const src = (children as Html).__html
218
223
  const patched = wireFieldHtml(src, wiring)
219
224
  if (patched !== src) {
@@ -261,7 +266,7 @@ export function Field(props: FieldProps) {
261
266
  {(() => {
262
267
  const wiring: FieldControlWiring = {
263
268
  id: props.id,
264
- describedBy: lastError ? `${props.id}-error` : props.hint ? `${props.id}-hint` : undefined,
269
+ describedBy: [lastError && `${props.id}-error`, props.hint && `${props.id}-hint`].filter(Boolean).join(' ') || undefined,
265
270
  invalid: Boolean(lastError),
266
271
  required: Boolean(props.required),
267
272
  }
@@ -271,7 +276,7 @@ export function Field(props: FieldProps) {
271
276
  ownedInvalid = true
272
277
  }))
273
278
  })()}
274
- {props.hint && !props.error && <p data-part="hint" id={`${props.id}-hint`}>{props.hint}</p>}
279
+ {props.hint && <p data-part="hint" id={`${props.id}-hint`}>{props.hint}</p>}
275
280
  {props.error && <p data-part="error" id={`${props.id}-error`} role="alert">{props.error}</p>}
276
281
  </div>
277
282
  )
@@ -1,315 +1,25 @@
1
1
  /* @prunellejs/ui bare floor: behavior, layout primitives, accessibility & top-layer positioning only.
2
2
  * Everything sits inside @layer kui so Tailwind utilities and user CSS always win without !important. */
3
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
- }
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,10 @@
1
+ @layer kui {
2
+ [data-ui="accordion"] summary[data-part="trigger"] {
3
+ list-style: none;
4
+ cursor: pointer;
5
+ display: flex;
6
+ align-items: center;
7
+ min-block-size: var(--ui-touch-min, auto);
8
+ &::-webkit-details-marker { display: none; }
9
+ }
10
+ }
@@ -0,0 +1,6 @@
1
+ @layer kui {
2
+ [data-ui="badge"] {
3
+ display: inline-flex;
4
+ align-items: center;
5
+ }
6
+ }