@prunellejs/ui 0.7.2 → 0.7.4

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/llms.txt CHANGED
@@ -50,7 +50,7 @@ export default defineConfig({
50
50
  - `Menu`: `{ id?, label, items: Array<{ id, label, href?, disabled?, onSelect? }>, variant?, onSelect? }`.
51
51
  - `Select`: `{ id?, options: Array<{ value, label, disabled? }>, value?: Signal<string>, defaultValue?, name?, placeholder?, ariaLabel?, onChange? }`. With no `value` or `defaultValue` it shows `placeholder` and submits `""` until the user picks. Outside a `Field` or `<label for>` it needs `ariaLabel`, or `prunelle check` warns `rgaa/form-label`.
52
52
  - `CommandPalette`: `{ id?, items?: CommandItem[], source?: CommandSource, shortcutKey? ('k'), open?: Signal<boolean>, onSelect?, ...labels }` (`source` is a lazy search function or `{ search(query) }`, e.g. `createSearchSource()` from `@prunellejs/search/client`, invoked only once opened).
53
- - `DataTable`: `{ rows, columns: Array<{ key, label, sortable? }>, rowKey? ('id'; every row needs a unique key, or the table throws), locale? (sort order; `<html lang>`), onSelect?(keys) (the selected keys, each time they change), rowLabelKey? (first column: names each row's checkbox), pageSize? (10), searchable? (true), selectable? (false), ...labels }`. With `selectable`, the header checkbox selects or clears every row the filter shows. A sort is announced (`ascendingLabel`, `descendingLabel`), and so is the page. `Sort is numeric and accent-aware (`Intl.Collator`), search and `CommandPalette` ignore case and accents, and the selection drops rows that leave `rows`. `createDataTable()` also has `setSelected(keys, on)` and `onSelect`.
53
+ - `DataTable`: `{ rows, columns: Array<{ key, label, sortable? }>, rowKey? ('id'; every row needs a unique key, or the table throws), locale? (sort order; `<html lang>`), onSelect?(keys) (the selected keys, each time they change), rowLabelKey? (first column: names each row's checkbox), pageSize? (10), searchable? (true), selectable? (false), ...labels }`. With `selectable`, the header checkbox selects or clears every row the filter shows. A sort is announced (`ascendingLabel`, `descendingLabel`), and so is the page. Sort is numeric and accent-aware (`Intl.Collator`), search and `CommandPalette` ignore case and accents, and the selection drops rows that leave `rows`. `createDataTable()` also has `setSelected(keys, on)` and `onSelect`.
54
54
  - `Toaster` + `toast`: mount `<Toaster dismissLabel? />` once in `_layout.tsx`; call `toast.show|info|success|warning|danger|error(title, description?, durationMs?)`, `toast.dismiss(id)`, `toast.clear()`. A `danger`/`error` toast stays until dismissed and the others stay 4.5 to 15 s by text length, unless `durationMs` is given (`0` keeps it). Hovering or focusing the stack pauses every timer, which then resumes with the time it had left; Escape closes the focused toast, and focus moves to the next toast, else back where it was.
55
55
 
56
56
  ## Example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prunellejs/ui",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "Platform-first headless UI primitives and pure CSS @layer kui Style Grammars for Prunelle",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,6 +29,6 @@
29
29
  "directory": "packages/ui"
30
30
  },
31
31
  "peerDependencies": {
32
- "prunelle": "^0.7.2"
32
+ "prunelle": "^0.7.4"
33
33
  }
34
34
  }
package/src/DataTable.tsx CHANGED
@@ -175,6 +175,7 @@ export function DataTable(props: DataTableProps) {
175
175
  <input
176
176
  type="checkbox"
177
177
  aria-label={selectAllLabel}
178
+ disabled={table.filtered.value.length === 0}
178
179
  checked={allShownSelected()}
179
180
  ref={(el: HTMLInputElement) => effect(() => { el.indeterminate = someShownSelected() && !allShownSelected() })}
180
181
  onChange={() => table.setSelected(shownKeys(), !allShownSelected())}
@@ -56,6 +56,8 @@
56
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
57
  @media (forced-colors: active) {
58
58
  :root [data-ui] [data-highlighted="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
59
- :root [data-ui][data-disabled="true"] { color: GrayText; }
59
+ :root [data-ui][data-disabled="true"],
60
+ :root [data-ui][aria-disabled="true"],
61
+ :root [data-ui] [data-disabled="true"] { color: GrayText; }
60
62
  }
61
63
  }
@@ -32,9 +32,9 @@
32
32
  --ui-btn-sm-pad: 0.3rem 0.55rem;
33
33
  --ui-btn-lg-fs: 0.85rem;
34
34
  --ui-btn-lg-pad: 0.6rem 1rem;
35
- &:hover:not(:disabled) { border-color: var(--ui-accent); color: var(--ui-accent); }
36
- &[data-tone="accent"]:hover:not(:disabled) { color: var(--ui-on-accent); filter: brightness(1.08); }
37
- &[data-tone="danger"] { background: color-mix(in srgb, var(--ui-danger) 12%, transparent); color: var(--ui-danger); &:hover:not(:disabled) { background: var(--ui-danger); color: var(--ui-on-accent); } }
35
+ &:hover:not(:disabled, [aria-disabled="true"]) { border-color: var(--ui-accent); color: var(--ui-accent); }
36
+ &[data-tone="accent"]:hover:not(:disabled, [aria-disabled="true"]) { color: var(--ui-on-accent); filter: brightness(1.08); }
37
+ &[data-tone="danger"] { background: color-mix(in srgb, var(--ui-danger) 12%, transparent); color: var(--ui-danger); &:hover:not(:disabled, [aria-disabled="true"]) { background: var(--ui-danger); color: var(--ui-on-accent); } }
38
38
  }
39
39
 
40
40
  [data-ui="card"] {
@@ -30,11 +30,11 @@
30
30
  --ui-btn-bd: 1px solid var(--ui-ink);
31
31
  --ui-btn-bg: var(--ui-ink);
32
32
  --ui-btn-fg: var(--ui-paper);
33
- &:hover:not(:disabled) { background: transparent; color: var(--ui-ink); }
34
- &[data-tone="accent"]:hover:not(:disabled) { background: transparent; color: var(--ui-accent); }
35
- &[data-variant="outline"]:hover:not(:disabled) { border-color: var(--ui-ink); }
33
+ &:hover:not(:disabled, [aria-disabled="true"]) { background: transparent; color: var(--ui-ink); }
34
+ &[data-tone="accent"]:hover:not(:disabled, [aria-disabled="true"]) { background: transparent; color: var(--ui-accent); }
35
+ &[data-variant="outline"]:hover:not(:disabled, [aria-disabled="true"]) { border-color: var(--ui-ink); }
36
36
  &[data-variant="ghost"] { border-bottom: 1px solid var(--ui-line); padding-inline: 0.15rem; }
37
- &[data-variant="ghost"]:hover:not(:disabled) { border-bottom-color: var(--ui-ink); }
37
+ &[data-variant="ghost"]:hover:not(:disabled, [aria-disabled="true"]) { border-bottom-color: var(--ui-ink); }
38
38
  }
39
39
 
40
40
  [data-ui="card"] {
@@ -32,6 +32,10 @@
32
32
  --ui-danger: light-dark(#b42318, #f58a8a);
33
33
  --ui-iris: light-dark(#7a3667, #e5c068);
34
34
  --ui-pupil: light-dark(#18111d, #130e16);
35
+ --ui-tst-accent: light-dark(#e5c068, #7a3667);
36
+ --ui-tst-success: light-dark(#7cc79a, #2c6b3a);
37
+ --ui-tst-warning: light-dark(#f2a65a, #7d5c00);
38
+ --ui-tst-danger: light-dark(#f58a8a, #b42318);
35
39
  --ui-font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
36
40
  --ui-font-body: 'Segoe UI Variable Text', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Noto Sans', Cantarell, Ubuntu, Arial, sans-serif;
37
41
  --ui-font-mono: ui-monospace, 'Cascadia Code', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
@@ -58,23 +62,23 @@
58
62
  min-inline-size: var(--ui-touch-min, auto);
59
63
  white-space: nowrap;
60
64
  box-shadow: inset 0 0 0 1px var(--ui-line-strong);
61
- &:hover:not(:disabled) { box-shadow: inset 0 0 0 1px var(--ui-ink); }
65
+ &:hover:not(:disabled, [aria-disabled="true"]) { box-shadow: inset 0 0 0 1px var(--ui-ink); }
62
66
  &[data-variant="ghost"] {
63
67
  padding-inline: 2px;
64
68
  text-decoration: underline 1px var(--ui-accent);
65
69
  text-underline-offset: 5px;
66
- &:hover:not(:disabled) { box-shadow: none; text-decoration-thickness: 2px; }
70
+ &:hover:not(:disabled, [aria-disabled="true"]) { box-shadow: none; text-decoration-thickness: 2px; }
67
71
  }
68
72
  &[data-tone="accent"] {
69
73
  box-shadow: none;
70
74
  color: var(--ui-on-primary);
71
- &:hover:not(:disabled) { box-shadow: none; background: color-mix(in srgb, var(--ui-accent-fill) 86%, var(--ui-paper)); }
75
+ &:hover:not(:disabled, [aria-disabled="true"]) { box-shadow: none; background: color-mix(in srgb, var(--ui-accent-fill) 86%, var(--ui-paper)); }
72
76
  }
73
77
  &[data-tone="danger"] {
74
78
  background: transparent;
75
79
  box-shadow: inset 0 0 0 1px var(--ui-danger);
76
80
  color: var(--ui-danger);
77
- &:hover:not(:disabled) { background: var(--ui-danger); box-shadow: none; color: var(--ui-on-accent); }
81
+ &:hover:not(:disabled, [aria-disabled="true"]) { background: var(--ui-danger); box-shadow: none; color: var(--ui-on-accent); }
78
82
  }
79
83
  }
80
84
 
@@ -188,10 +192,10 @@
188
192
  --ui-tst-pad: 10px 14px;
189
193
  font: 400 0.8125rem/1.45 var(--ui-font-body);
190
194
  &[data-tone] { box-shadow: inset 3px 0 0 var(--ui-tone); }
191
- &[data-tone="accent"] { --ui-tone: light-dark(#e5c068, #7a3667); }
192
- &[data-tone="success"] { --ui-tone: light-dark(#7cc79a, #2c6b3a); }
193
- &[data-tone="warning"] { --ui-tone: light-dark(#f2a65a, #7d5c00); }
194
- &[data-tone="danger"] { --ui-tone: light-dark(#f58a8a, #b42318); }
195
+ &[data-tone="accent"] { --ui-tone: var(--ui-tst-accent); }
196
+ &[data-tone="success"] { --ui-tone: var(--ui-tst-success); }
197
+ &[data-tone="warning"] { --ui-tone: var(--ui-tst-warning); }
198
+ &[data-tone="danger"] { --ui-tone: var(--ui-tst-danger); }
195
199
  }
196
200
 
197
201
  [data-ui="checkbox"] {
@@ -1,5 +1,5 @@
1
1
  // Static scanner detecting which `@prunellejs/ui` component parts a set of source files renders.
2
- // Checks both named imports from `@prunellejs/ui` and literal `data-ui="..."` / `data-layout="..."` attributes.
2
+ // Checks imports and re-exports from `@prunellejs/ui` plus literal `data-ui="..."` / `data-layout="..."` attributes.
3
3
 
4
4
  import type { UiComponentPart } from './split'
5
5
  import { existsSync, readFileSync } from 'node:fs'
@@ -9,9 +9,16 @@ import { UI_COMPONENT_PARTS, UI_EXPORT_TO_PARTS } from './split'
9
9
  const PART_SET = new Set<string>(UI_COMPONENT_PARTS)
10
10
  const UI_SRC_DIR = resolve(import.meta.dir, '..')
11
11
 
12
- const IMPORT_STMT_RE = /import\s+(?!type\b)([\s\S]*?)\s+from\s+['"]([^'"]+)['"]/g
12
+ const COMMENT_SRC = '//[^\\n]*|/\\*[\\s\\S]*?\\*/'
13
+ const WS_SRC = `(?:\\s|${COMMENT_SRC})*`
14
+ const NAMED_LIST_SRC = `\\{(?:[^/{}]|${COMMENT_SRC}|/(?![/*]))*\\}`
15
+ const IMPORT_EXPORT_RE = new RegExp(
16
+ `\\b(?:import\\b${WS_SRC}((?!type\\b)[A-Za-z_$][\\w$]*(?:${WS_SRC},${WS_SRC}(?:\\*${WS_SRC}as${WS_SRC}[A-Za-z_$][\\w$]*|${NAMED_LIST_SRC}))?|\\*${WS_SRC}as${WS_SRC}[A-Za-z_$][\\w$]*|${NAMED_LIST_SRC})|export\\b${WS_SRC}(\\*(?:${WS_SRC}as${WS_SRC}[A-Za-z_$][\\w$]*)?|${NAMED_LIST_SRC}))${WS_SRC}\\bfrom${WS_SRC}['"]([^'"]+)['"]`,
17
+ 'g',
18
+ )
13
19
  const NAMED_LIST_RE = /\{([\s\S]*?)\}/
14
- const NAMESPACE_RE = /\*\s+as\s+[A-Za-z_$]/
20
+ const NAMESPACE_RE = /^\s*\*(?:\s+as\s+[A-Za-z_$][\w$]*)?\s*$|,\s*\*\s+as\s+[A-Za-z_$][\w$]*/
21
+ const COMMENT_RE = /\/\/[^\n]*|\/\*[\s\S]*?\*\//g
15
22
  const DATA_UI_ATTR_RE = /\bdata-ui\s*=\s*(?:["']([^"']+)["']|\{([^}]*)\})/g
16
23
  const DATA_LAYOUT_ATTR_RE = /\bdata-layout\s*=/
17
24
  const STATIC_QUOTED_RE = /^\s*["']([^"']+)["']\s*$/
@@ -67,9 +74,9 @@ function scanSingleFile(file: string): FileUiScan {
67
74
  const parts = new Set<UiComponentPart>()
68
75
  let all = false
69
76
 
70
- for (const match of code.matchAll(IMPORT_STMT_RE)) {
71
- const clause = match[1]!
72
- const source = match[2]!
77
+ for (const match of code.matchAll(IMPORT_EXPORT_RE)) {
78
+ const clause = ((match[1] ?? match[2])!).replace(COMMENT_RE, ' ')
79
+ const source = match[3]!
73
80
  const fromPrunelle = source === 'prunelle'
74
81
  if (!fromPrunelle && !isUiImportSource(source))
75
82
  continue
@@ -81,7 +88,7 @@ function scanSingleFile(file: string): FileUiScan {
81
88
  if (named !== null) {
82
89
  for (const rawSpec of named[1]!.split(',')) {
83
90
  const spec = rawSpec.trim()
84
- if (spec === '' || spec.startsWith('type '))
91
+ if (spec === '' || /^type\s+/.test(spec))
85
92
  continue
86
93
  const imported = spec.split(/\s+as\s+/)[0]!.trim()
87
94
  const mapped = (fromPrunelle ? PRUNELLE_EXPORT_TO_PARTS : UI_EXPORT_TO_PARTS)[imported]