@prunellejs/ui 0.7.0 → 0.7.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/package.json +2 -2
- package/src/DataTable.tsx +8 -2
- package/src/Toaster.tsx +1 -1
- package/src/styles/grammars/prunelle.css +55 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prunellejs/ui",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
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.
|
|
32
|
+
"prunelle": "^0.7.1"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/DataTable.tsx
CHANGED
|
@@ -63,9 +63,15 @@ function checkedRows(rows: Row[], rowKey: string): Row[] {
|
|
|
63
63
|
function Pager({ table, pageLabel, prevLabel, nextLabel }: { table: DataTableState<Row>, pageLabel: string, prevLabel: string, nextLabel: string }) {
|
|
64
64
|
const turn = (by: number, other: Element | null) => {
|
|
65
65
|
table.page.value += by
|
|
66
|
-
const
|
|
67
|
-
|
|
66
|
+
const page = table.page.peek()
|
|
67
|
+
const total = table.totalPages.peek()
|
|
68
|
+
const atEnd = by < 0 ? page <= 1 : page >= total
|
|
69
|
+
const otherEnabled = by < 0 ? page < total : page > 1
|
|
70
|
+
if (atEnd && otherEnabled && other instanceof HTMLButtonElement) {
|
|
71
|
+
// Enable before focusing: delegated onClick runs inside batch(), so reactive `disabled` updates flush after turn() returns.
|
|
72
|
+
other.disabled = false
|
|
68
73
|
other.focus()
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
76
|
return (
|
|
71
77
|
<div data-part="pagination" data-layout="split">
|
package/src/Toaster.tsx
CHANGED
|
@@ -37,7 +37,7 @@ export function Toaster({ dismissLabel = dismiss }: ToasterProps = {}) {
|
|
|
37
37
|
const target = sibling ?? returnTo
|
|
38
38
|
if (target?.isConnected)
|
|
39
39
|
target.focus()
|
|
40
|
-
if (root !== null && !root.contains(document.activeElement)) {
|
|
40
|
+
if (root !== null && (!root.contains(document.activeElement) || item.contains(document.activeElement))) {
|
|
41
41
|
focused = false
|
|
42
42
|
returnTo = null
|
|
43
43
|
resume()
|
|
@@ -220,6 +220,17 @@
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
+
/* @part: checkbox */
|
|
224
|
+
@media (forced-colors: active) {
|
|
225
|
+
:root [data-ui="checkbox"] input[type="checkbox"] {
|
|
226
|
+
border: 1.5px solid ButtonText;
|
|
227
|
+
background: Canvas;
|
|
228
|
+
&:checked { border-color: Highlight; background: Highlight; }
|
|
229
|
+
&:checked::after { border-color: HighlightText; }
|
|
230
|
+
&:disabled { border-color: GrayText; }
|
|
231
|
+
&:disabled:checked { border-color: GrayText; background: GrayText; }
|
|
232
|
+
}
|
|
233
|
+
}
|
|
223
234
|
|
|
224
235
|
/* The eye. A shut eye is its lower lid, a curve painted as the control's background; opening it fades the lid, grows the almond (::before) to full height and shows the pupil (::after), an upright oval. */
|
|
225
236
|
[data-ui="radio-group"] input[type="radio"],
|
|
@@ -281,6 +292,20 @@
|
|
|
281
292
|
&:disabled { cursor: not-allowed; }
|
|
282
293
|
}
|
|
283
294
|
}
|
|
295
|
+
/* @part: radio-group */
|
|
296
|
+
@media (forced-colors: active) {
|
|
297
|
+
:root [data-ui="radio-group"] input[type="radio"] {
|
|
298
|
+
border: 1.5px solid ButtonText;
|
|
299
|
+
border-radius: 50%;
|
|
300
|
+
background: Canvas;
|
|
301
|
+
&::before { display: none; }
|
|
302
|
+
&::after { inline-size: 50%; block-size: 50%; background: HighlightText; }
|
|
303
|
+
&:checked { border-color: Highlight; background: Highlight; }
|
|
304
|
+
&:checked::after { opacity: 1; transform: none; }
|
|
305
|
+
&:disabled { border-color: GrayText; }
|
|
306
|
+
&:disabled:checked { border-color: GrayText; background: GrayText; }
|
|
307
|
+
}
|
|
308
|
+
}
|
|
284
309
|
|
|
285
310
|
/* Switch: the input is the visible track (and carries base.css's focus-visible ring), the track part its sliding eye knob. */
|
|
286
311
|
[data-ui="switch"] {
|
|
@@ -332,6 +357,36 @@
|
|
|
332
357
|
inset-inline-start: 18px;
|
|
333
358
|
&::after { inset-inline-start: auto; transform: scaleY(var(--ui-lid)); }
|
|
334
359
|
}
|
|
360
|
+
/* @part: switch */
|
|
361
|
+
@media (forced-colors: active) {
|
|
362
|
+
:root [data-ui="switch"] input[type="checkbox"] {
|
|
363
|
+
border: 1.5px solid ButtonText;
|
|
364
|
+
background: Canvas;
|
|
365
|
+
&:checked { border-color: Highlight; background: Highlight; }
|
|
366
|
+
&:disabled { border-color: GrayText; }
|
|
367
|
+
&:disabled:checked { border-color: GrayText; background: GrayText; }
|
|
368
|
+
}
|
|
369
|
+
:root [data-ui="switch"] [data-part="track"] {
|
|
370
|
+
border: 1.5px solid ButtonText;
|
|
371
|
+
background: Canvas;
|
|
372
|
+
&::before { display: none; }
|
|
373
|
+
&::after { inline-size: 6px; block-size: 6px; border-radius: 50%; opacity: 1; transform: none; background: ButtonText; }
|
|
374
|
+
}
|
|
375
|
+
:root [data-ui="switch"] input:checked + [data-part="track"] {
|
|
376
|
+
border-color: HighlightText;
|
|
377
|
+
background: Highlight;
|
|
378
|
+
&::after { background: HighlightText; }
|
|
379
|
+
}
|
|
380
|
+
:root [data-ui="switch"] input:disabled + [data-part="track"] {
|
|
381
|
+
border-color: GrayText;
|
|
382
|
+
&::after { background: GrayText; }
|
|
383
|
+
}
|
|
384
|
+
:root [data-ui="switch"] input:disabled:checked + [data-part="track"] {
|
|
385
|
+
border-color: Canvas;
|
|
386
|
+
background: GrayText;
|
|
387
|
+
&::after { background: Canvas; }
|
|
388
|
+
}
|
|
389
|
+
}
|
|
335
390
|
|
|
336
391
|
/* Progress: the native bar stays for assistive tech and the eye shows it. */
|
|
337
392
|
[data-ui="progress"] {
|