cssints 0.18.0 → 0.19.0
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/docs/API.md +213 -1
- package/package.json +2 -2
package/docs/API.md
CHANGED
|
@@ -1465,6 +1465,40 @@ createTable(options: {
|
|
|
1465
1465
|
|
|
1466
1466
|
Selection is over ids, so it survives the host's re-sort. `rowProps` carries `aria-selected` and a click that selects; `toggleRow` / `toggleAll` are the programmatic path, and the row's checkbox stops its click from reaching the row so the two controls never toggle the same row twice. `selectAllProps` and `rowCheckboxProps` are `undefined` unless `selection` is `"multiple"` (one control over one selection is meaningless), and the select-all is a `role="checkbox"` rather than a native `input` because the mixed state a screen reader must hear is `aria-checked="mixed"`, not the DOM-only `indeterminate` property. It toggles the rows the table renders: a windowed table toggles its window and keeps the rest of the selection. A table that renders all of its rows and columns carries no `aria-rowcount` / `aria-colcount` (the markup already says it); pass them, and every cell gets its `aria-colindex`, only when the host windows. `numeric` is a layout hint for the host's skin: HTML has no attribute for it.
|
|
1467
1467
|
|
|
1468
|
+
### Headless: `createTabs` (`@cssints/headless`)
|
|
1469
|
+
|
|
1470
|
+
The APG tablist as state and attribute objects: roving tabindex, wrapping arrows, Home/End, automatic or manual activation, disabled tabs, and a selection that is a request (`value` + `onValueChange`) or uncontrolled (`defaultSelected`). `packages/apg-specs/specs/apg/tabs.qnt` is its model; `packages/headless/test/tabs.browser.test.tsx` replays it in Chromium.
|
|
1471
|
+
|
|
1472
|
+
Close and rename are an **extension** (bean `cssints-gdv2`, the docs playground's file tabs), off by default so the plain tabs are untouched. The primitive owns no list: it asks (`onClose`, `onRename`), the host removes or renames. `packages/headless/test/tabs-close.browser.test.tsx` is their oracle.
|
|
1473
|
+
|
|
1474
|
+
```ts skip
|
|
1475
|
+
createTabs(options?: {
|
|
1476
|
+
...; // the plain tabs: items, value, defaultSelected, orientation, activation, disabled, focusablePanels, id, onValueChange
|
|
1477
|
+
closable?: boolean; // false: closeProps and the Delete key; the host removes from onClose
|
|
1478
|
+
renamable?: boolean; // false: a double click edits the label inline; the host renames from onRename
|
|
1479
|
+
label?(index: number): string | undefined; // the tab's name: the buttons' labels and the rename draft
|
|
1480
|
+
onClose?(index: number): void; // a request: the host removes the tab and may ignore it
|
|
1481
|
+
onRename?(index: number, label: string): void; // a request with a non-empty label
|
|
1482
|
+
}): {
|
|
1483
|
+
...;
|
|
1484
|
+
editing(): number | null; // the tab being renamed inline
|
|
1485
|
+
focusAfterClose(index: number): number; // the tab to focus once the removal landed
|
|
1486
|
+
closeProps(index): { "aria-label": string; tabindex: -1; onClick: () => void };
|
|
1487
|
+
renameProps(index): {
|
|
1488
|
+
onDblClick: () => void;
|
|
1489
|
+
editing(): boolean;
|
|
1490
|
+
begin(index: number): void;
|
|
1491
|
+
commit(label: string): void;
|
|
1492
|
+
cancel(): void;
|
|
1493
|
+
inputProps: { type: "text"; value; "aria-label"; onInput; onKeyDown; onBlur };
|
|
1494
|
+
};
|
|
1495
|
+
};
|
|
1496
|
+
```
|
|
1497
|
+
|
|
1498
|
+
- **Close.** `closeProps(index)` is the tab's close button: `aria-label="Close <label>"` and `tabindex=-1`, because a tablist's tab stops are its tabs; the keyboard path is Delete on the focused tab. Focus after a close goes to the tab that slid into the closed one's place, or to the previous tab when the last one closed: `focusAfterClose(index)` names that index in the shortened list (call it before the host removes the tab). Closing the last remaining tab is refused, as the spec refuses an empty tablist; a closed tab that was selected asks for the tab that takes the focus.
|
|
1499
|
+
- **Rename.** A double click begins; the tab renders `inputProps` instead of its label. Enter commits, Escape reverts, blur commits, and a label that trims to nothing cancels. While editing, the input owns the keys: the tablist's roving does not move. `begin(index)` is the programmatic start, for a tab the host has just added (append it, then `focusTab(index)` and `begin(index)`).
|
|
1500
|
+
- **The host's list.** `items` is read from the option on every read, so the bounds, the roving tab stop and `firstEnabled` follow a host that shrinks its list. `label` is read lazily too, so a renamed tab renames its buttons with it.
|
|
1501
|
+
- The spec models a `deletable` flavour (Delete, focus to the next tab, the last refused) but neither a rename nor the callbacks, so the browser test, not the model, holds the extension.
|
|
1468
1502
|
|
|
1469
1503
|
### Headless: `createHotkeys` (`@cssints/headless`)
|
|
1470
1504
|
|
|
@@ -1488,7 +1522,6 @@ hotkeys.dispose(); // unbinds all and removes the document listener; a later bin
|
|
|
1488
1522
|
|
|
1489
1523
|
There is one `keydown` listener on the document in the capture phase, added when the first binding is bound and removed when the last is unbound or on `dispose`. The most recently bound match is the only one that fires, so a modal's `/` shadows the page's and unbinding it brings the page's back; a binding whose `when` returns false falls through to the next match instead of blocking it. By default a binding does not fire while the focus is in an `input`, a `textarea` or a `contenteditable` (an inherited one included) unless it sets `allowInEditable`. An unknown modifier or a chord with no key throws a `TypeError` at `bind`.
|
|
1490
1524
|
|
|
1491
|
-
|
|
1492
1525
|
### Headless: `createScrollspy` (`@cssints/headless`)
|
|
1493
1526
|
|
|
1494
1527
|
A table of contents whose current entry is the last heading to reach the top of the scrollport, marked `aria-current="location"` on the link. **No APG pattern exists for a scrollspy**, so it has no Quint spec and no ported scenarios: the contract is WAI-ARIA (the `aria-current` value, `role="list"` / `role="listitem"`, a named navigation landmark) and HTML, and `packages/headless/test/scrollspy.browser.test.tsx` is its oracle.
|
|
@@ -1559,6 +1592,185 @@ Wheel zooms **only with `ctrl` / `meta`** held: the browser's pinch gesture arri
|
|
|
1559
1592
|
|
|
1560
1593
|
The host owns the box and the look: the viewport's size and `overflow: hidden`, `touch-action: none` if a touch drag should pan, `transform-origin: 50% 50%` (the default this maths assumes), and any transition on the transform. Controlled is `scale` + `onScaleChange`; the offset has no controlled prop, so a host that ignores a scale request also gets the offset resolved for the scale it refused. Not modelled: inertia, rotation, and pinching on platforms without `PointerEvent` (the browser's own pinch is the `ctrl+wheel` path).
|
|
1561
1594
|
|
|
1595
|
+
### Headless: `createSlider` and `createSpinbutton` (`@cssints/headless`)
|
|
1596
|
+
|
|
1597
|
+
The two number controls. Their behaviour is `packages/apg-specs/specs/apg/slider.qnt` and `spinbutton.qnt`, checked against the real DOM by the differential walk in `packages/headless/test/slider.browser.test.tsx` and `spinbutton.browser.test.tsx`. Options are plain and read lazily (a getter is fine); `value` + `onValueChange` make the widget controlled, `defaultValue` is the uncontrolled start.
|
|
1598
|
+
|
|
1599
|
+
```ts skip
|
|
1600
|
+
createSlider(options?: {
|
|
1601
|
+
min?: number; // 0
|
|
1602
|
+
max?: number; // 10
|
|
1603
|
+
step?: number; // 1
|
|
1604
|
+
largeStep?: number; // 3: the jump of PageUp / PageDown
|
|
1605
|
+
value?: number | undefined; // controlled; undefined = uncontrolled
|
|
1606
|
+
defaultValue?: number; // 5, clamped into the range
|
|
1607
|
+
orientation?: "horizontal" | "vertical"; // "horizontal"
|
|
1608
|
+
direction?: "ltr" | "rtl"; // "ltr": under rtl the horizontal arrows flip
|
|
1609
|
+
disabled?: boolean; // aria-disabled on the thumb; a key or rail press changes nothing
|
|
1610
|
+
id?: string; // base of the thumb id
|
|
1611
|
+
onValueChange?(value: number): void; // a request the host may ignore
|
|
1612
|
+
}): {
|
|
1613
|
+
value(): number;
|
|
1614
|
+
focused(): boolean;
|
|
1615
|
+
setValue(value: number): void;
|
|
1616
|
+
focus(): void;
|
|
1617
|
+
blur(): void;
|
|
1618
|
+
keyDown(key: string): boolean; // true when the key was consumed (preventDefault it)
|
|
1619
|
+
pointerDown(position: number): void; // a rail press at a 0..1 fraction of the track
|
|
1620
|
+
thumbProps: {
|
|
1621
|
+
id;
|
|
1622
|
+
role: "slider";
|
|
1623
|
+
"aria-valuenow";
|
|
1624
|
+
"aria-valuemin";
|
|
1625
|
+
"aria-valuemax";
|
|
1626
|
+
"aria-valuetext";
|
|
1627
|
+
"aria-orientation";
|
|
1628
|
+
"aria-disabled": "true" | undefined;
|
|
1629
|
+
tabindex: 0;
|
|
1630
|
+
onFocus;
|
|
1631
|
+
onBlur;
|
|
1632
|
+
onKeyDown;
|
|
1633
|
+
};
|
|
1634
|
+
trackProps: { onPointerDown };
|
|
1635
|
+
};
|
|
1636
|
+
```
|
|
1637
|
+
|
|
1638
|
+
```ts skip
|
|
1639
|
+
createSpinbutton(options?: {
|
|
1640
|
+
min?: number; // 1
|
|
1641
|
+
max?: number; // 12
|
|
1642
|
+
step?: number; // 1: the arrows and the buttons
|
|
1643
|
+
largeStep?: number; // 3: PageUp / PageDown
|
|
1644
|
+
value?: number | undefined; // controlled; undefined = uncontrolled
|
|
1645
|
+
defaultValue?: number; // 5, clamped into the range
|
|
1646
|
+
wrap?: boolean; // false: clamp at the bounds (true wraps)
|
|
1647
|
+
disabled?: boolean; // aria-disabled and the native disabled; keys, typing and both steppers change nothing
|
|
1648
|
+
id?: string; // base of the input and button ids
|
|
1649
|
+
onValueChange?(value: number): void; // a request the host may ignore
|
|
1650
|
+
}): {
|
|
1651
|
+
value(): number;
|
|
1652
|
+
focused(): boolean;
|
|
1653
|
+
editing(): boolean;
|
|
1654
|
+
draft(): string;
|
|
1655
|
+
displayed(): string; // the draft while editing, else the value
|
|
1656
|
+
setValue(value: number): void;
|
|
1657
|
+
focus(): void;
|
|
1658
|
+
blur(): void; // commits a valid draft
|
|
1659
|
+
keyDown(key: string): boolean;
|
|
1660
|
+
typeInput(text: string): void; // replaces the draft; needs focus
|
|
1661
|
+
commit(): void;
|
|
1662
|
+
revert(): void;
|
|
1663
|
+
increment(): void;
|
|
1664
|
+
decrement(): void;
|
|
1665
|
+
setWrap(wrap: boolean): void;
|
|
1666
|
+
inputProps: {
|
|
1667
|
+
id;
|
|
1668
|
+
role: "spinbutton";
|
|
1669
|
+
"aria-valuenow";
|
|
1670
|
+
"aria-valuemin";
|
|
1671
|
+
"aria-valuemax";
|
|
1672
|
+
"aria-valuetext";
|
|
1673
|
+
"aria-invalid": "true" | undefined;
|
|
1674
|
+
"aria-disabled": "true" | undefined;
|
|
1675
|
+
disabled: boolean; // this is an <input>: the native attribute is a form control's disabled
|
|
1676
|
+
tabindex: 0;
|
|
1677
|
+
value;
|
|
1678
|
+
onFocus;
|
|
1679
|
+
onBlur;
|
|
1680
|
+
onKeyDown;
|
|
1681
|
+
onInput;
|
|
1682
|
+
};
|
|
1683
|
+
incrementProps: { role: "button"; tabindex: -1; "aria-label"; "aria-disabled"; onMouseDown; onClick };
|
|
1684
|
+
decrementProps: { role: "button"; tabindex: -1; "aria-label"; "aria-disabled"; onMouseDown; onClick };
|
|
1685
|
+
};
|
|
1686
|
+
```
|
|
1687
|
+
|
|
1688
|
+
`disabled` is **a widget-level extension of the APG patterns**, and the specs say so: `slider.qnt` lists it under its deliberate omissions, and `spinbutton.qnt` models the steppers' at-bound state only (`DisabledOnlyAtBound`). Neither machine has a `disabled` var, so the DOM tests, not the model, hold the primitive to these rules:
|
|
1689
|
+
|
|
1690
|
+
- a disabled slider **keeps the thumb as its tab stop** (`tabindex="0"`, the same choice `createButton` makes with `aria-disabled`) and announces `aria-disabled="true"` on the thumb; every key and every rail press is dropped before it becomes a request, so `onValueChange` never fires and `keyDown` returns `false` (nothing to preventDefault);
|
|
1691
|
+
- a disabled spinbutton's field announces `aria-disabled` **and carries the native `disabled`** (the field is an `<input>`, so the platform's own form-control rule applies); the spin keys, the typed draft (Enter and blur included) and both steppers change nothing, and **both** steppers announce `aria-disabled="true"` — the at-bound rule of the spec stays, and a disabled widget adds the other side;
|
|
1692
|
+
- both read the option on every attribute read, so a host may flip `disabled` on a mounted widget and the attributes and the guards follow in the same tick.
|
|
1693
|
+
|
|
1694
|
+
### Headless: `createDropZone` (`@cssints/headless`)
|
|
1695
|
+
|
|
1696
|
+
A file drop target. **There is no APG pattern and no Quint spec for a drop zone** — the contract is HTML's file input plus WAI-ARIA's live region — so `packages/headless/test/dropzone.browser.test.tsx` (real Chromium) is its oracle. It is the replacement for the bare `<input type="file">` fields of cms-admin's image field and kocharin's dashboard upload.
|
|
1697
|
+
|
|
1698
|
+
```ts skip
|
|
1699
|
+
createDropZone(options: {
|
|
1700
|
+
accept?: string | undefined; // the HTML accept grammar: ".png", "image/png", "image/*"
|
|
1701
|
+
multiple?: boolean | undefined; // the input's multiple, and an accept of several files per drop
|
|
1702
|
+
maxSize?: number | undefined; // bytes; a larger file is rejected with "size"
|
|
1703
|
+
disabled?: boolean | undefined; // zone aria-disabled, native disabled input and button, drops ignored
|
|
1704
|
+
onFiles(files: File[]): void; // the accepted files of one batch; not called when none passed
|
|
1705
|
+
onReject?({ file, reason }: { file: File; reason: "type" | "size" }): void; // once per refused file
|
|
1706
|
+
labels?: { zone?: string | undefined; browse?: string | undefined };
|
|
1707
|
+
}): {
|
|
1708
|
+
dragging(): boolean; // a drag is over the zone; a child's dragleave does not clear it
|
|
1709
|
+
message(): string | undefined; // "2 files, 1 rejected: too large"; undefined before the first batch
|
|
1710
|
+
inputProps: {
|
|
1711
|
+
id; // the id the browse button clicks
|
|
1712
|
+
type: "file";
|
|
1713
|
+
accept: string | undefined;
|
|
1714
|
+
multiple: true | undefined;
|
|
1715
|
+
disabled: true | undefined;
|
|
1716
|
+
hidden: true;
|
|
1717
|
+
onChange;
|
|
1718
|
+
};
|
|
1719
|
+
zoneProps: {
|
|
1720
|
+
role: "group";
|
|
1721
|
+
"aria-label": string | undefined;
|
|
1722
|
+
"aria-disabled": "true" | undefined;
|
|
1723
|
+
onDragEnter;
|
|
1724
|
+
onDragOver;
|
|
1725
|
+
onDragLeave;
|
|
1726
|
+
onDrop;
|
|
1727
|
+
};
|
|
1728
|
+
browseProps: { type: "button"; disabled: true | undefined; "aria-disabled"; "aria-label"; onClick };
|
|
1729
|
+
statusProps: { role: "status"; "aria-live": "polite"; "aria-atomic": "true" };
|
|
1730
|
+
};
|
|
1731
|
+
```
|
|
1732
|
+
|
|
1733
|
+
Principles:
|
|
1734
|
+
|
|
1735
|
+
- **The zone is never drag-only.** `browseProps` spreads onto a real `<button type="button">` that clicks the hidden input, so the picker is the keyboard path (Enter and Space are the platform's) and a pointer user can click too. The drop handlers add nothing the button cannot do.
|
|
1736
|
+
- **Validation happens once per file**, in the order type then size, with a reason the host can show: `onReject` gets the file and `"type" | "size"`, and `onFiles` gets the rest in one batch. A batch with nothing accepted calls `onFiles` not at all — not with an empty array.
|
|
1737
|
+
- **A folder or an empty `DataTransfer` is a no-op** (Chromium marks a dropped directory as a `file` item whose `webkitGetAsEntry().isDirectory` is true): no callback, no rejection, and `message()` keeps the previous sentence.
|
|
1738
|
+
- **`dragleave` counts.** A child's `dragleave` bubbles to the zone, so `dragging()` is a depth counter: it clears when the drag leaves the zone, or on a drop. It is the styling hook; the primitive writes no `data-dragging`.
|
|
1739
|
+
- **`message()` is a default sentence for the host's status region** ("2 files, 1 rejected: too large", `undefined` before the first batch): the primitive tracks the counts of the last batch, the host decides the words. Render `statusProps` once and keep it mounted, or a change of its text is not announced.
|
|
1740
|
+
- Picking through the input is the same path as a drop and clears `input.value` afterwards, so choosing the same file twice fires `change` again.
|
|
1741
|
+
|
|
1742
|
+
### Headless: `createTimeline` (`@cssints/headless`)
|
|
1743
|
+
|
|
1744
|
+
Two modes over one axis. Without `rows` it is the package's demo tree of five fixed spans (collapsing, a zoom window, checked against `specs/apg/timeline.qnt` by the differential walk in `packages/headless/test/timeline.browser.test.tsx`). With `rows` it is a trace waterfall: real span data laid out in percentages of the rows' own extent. The rows mode has **no APG pattern** to follow, so its contract is `packages/headless/test/timeline-rows.browser.test.tsx`.
|
|
1745
|
+
|
|
1746
|
+
```ts skip
|
|
1747
|
+
createTimeline(options: {
|
|
1748
|
+
rows: ReadonlyArray<{ id: string; label: string; start: number; end: number; depth?: number; status?: "ok" | "error" | "unset" }>; // in display order
|
|
1749
|
+
axis?: { unit?: "ms" | "us" | "s" } | undefined; // "ms": the ruler's labels
|
|
1750
|
+
selected?: string | undefined; // controlled; undefined = uncontrolled
|
|
1751
|
+
onSelect?(id: string): void; // a request the host may ignore
|
|
1752
|
+
}): {
|
|
1753
|
+
extent(): { start: number; end: number }; // min start, max end; { 0, 0 } when empty
|
|
1754
|
+
depthOf(id: string): number; // 0 for a root span
|
|
1755
|
+
listProps: { role: "list"; "aria-label": string };
|
|
1756
|
+
rowProps(id: string): { role: "listitem"; "aria-level": number; "aria-current": "true" | undefined; "data-status"; tabindex; onClick; onKeyDown };
|
|
1757
|
+
barProps(id: string): { "aria-hidden": "true"; style: { left; width; "--depth" } };
|
|
1758
|
+
labelProps(id: string): { style: { "--depth" } };
|
|
1759
|
+
rulerProps: { role: "presentation"; "aria-hidden": "true"; ticks: ReadonlyArray<{ value: number; left: number; label: string }> };
|
|
1760
|
+
select(id: string): void;
|
|
1761
|
+
selectedId(): string | undefined;
|
|
1762
|
+
};
|
|
1763
|
+
```
|
|
1764
|
+
|
|
1765
|
+
`createTimeline()` with no `rows` keeps the tree API exactly as it was (`rows()`, `treeProps`, `rowProps`, zoom, collapse).
|
|
1766
|
+
|
|
1767
|
+
- **Role.** A waterfall is neither a tree (nothing collapses in rows mode) nor a grid (nothing is edited), and `aria-selected` is not allowed on a `listitem`. So the rows are `role="list"` / `role="listitem"`, the depth is `aria-level` (`depth + 1`, which `listitem` supports) and the selected row is `aria-current="true"`, which any element may carry. The demo tree keeps `role="tree"` / `"treeitem"` because it does collapse.
|
|
1768
|
+
- **Geometry.** `extent()` is across every row, so a child span is a percentage of the whole trace: `barProps(id).style.left` / `.width` are percentages of it, and a zero-length span (`start === end`) still paints because every bar has a **0.5% width floor** — 2 px on a 400 px track, the floor the o11y dashboard used when it hand-rolled these rows. An empty extent (`{ 0, 0 }`) puts every bar at `left: 0%` with that floor rather than dividing by zero.
|
|
1769
|
+
- **Depth is `--depth`** on `barProps` and `labelProps`, not nested DOM: the host indents with `padding-inline-start: calc(var(--depth) * 0.75rem)`, and the bar keeps its track when the panel is narrow.
|
|
1770
|
+
- **Ruler.** `ticks` steps the extent by 1, 2 or 5 times a power of ten (about five ticks), each with `value` on the axis, `left` in percent and a `label` in the axis unit. The ruler element is decorative; the host renders ticks as its children.
|
|
1771
|
+
- **Selection.** A click selects and moves the tab stop; ArrowUp / ArrowDown / Home / End move a roving tab stop; Enter or Space selects the focused row. The host moves real DOM focus after an arrow key, as the demo fixture does; `selected` + `onSelect` make it controlled, `select(id)` is the programmatic request.
|
|
1772
|
+
- **`status` is `data-status`** on the row, a styling hook for the host's colour. The primitive never invents the label: the host's data holds it.
|
|
1773
|
+
|
|
1562
1774
|
### Publishing a library (decided 2026-10-02, cssints-0l3f)
|
|
1563
1775
|
|
|
1564
1776
|
A package written on cssints ships JavaScript that still has the attribute, and its `.d.ts`. The app that installs it evaluates the package with its own engine: one sheet, the app's browserslist and themes, and a token, a kernel or an `@property` of the package is made once however many modules use it. Nothing is declared: the engine recognises a file by `with { type: "cssints" }`, the same marker as in app code.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cssints",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "CSS in TypeScript: typed css.* calls compiled to atomic CSS at build time (a Vite plugin)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@cssints/css-grammar": "^0.
|
|
75
|
+
"@cssints/css-grammar": "^0.19.0",
|
|
76
76
|
"culori": "^4.0.2",
|
|
77
77
|
"effect": "4.0.6",
|
|
78
78
|
"happy-dom": "^20.14.5",
|