@lostgradient/cinder 0.25.0 → 0.26.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/CHANGELOG.md +233 -0
- package/components.json +13 -6
- package/dist/components/accordion-item/accordion-item.css +0 -10
- package/dist/components/action-row/action-row.css +0 -9
- package/dist/components/alert/alert.css +0 -1
- package/dist/components/alert-dialog/index.js +2 -2
- package/dist/components/approval-card/index.js +2 -2
- package/dist/components/area-chart/index.js +2 -2
- package/dist/components/autocomplete/index.js +2 -2
- package/dist/components/avatar-group/avatar-group.css +0 -2
- package/dist/components/avatar-group/index.js +2 -2
- package/dist/components/backdrop/index.js +2 -2
- package/dist/components/bar-chart/index.js +2 -2
- package/dist/components/button/button.css +4 -4
- package/dist/components/button/button.variables.js +2 -2
- package/dist/components/card/card.css +0 -2
- package/dist/components/carousel/carousel.css +0 -5
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/code-block/code-block.css +0 -5
- package/dist/components/code-block/index.js +2 -2
- package/dist/components/color-field/index.js +2 -2
- package/dist/components/combobox/index.js +2 -2
- package/dist/components/command-menu/index.js +2 -2
- package/dist/components/command-palette/command-palette.css +50 -46
- package/dist/components/command-palette/index.js +2 -2
- package/dist/components/confirm-dialog/index.js +2 -2
- package/dist/components/context-menu/index.js +2 -2
- package/dist/components/data-table/data-table.css +0 -2
- package/dist/components/data-table/index.js +2 -2
- package/dist/components/date-picker/index.js +2 -2
- package/dist/components/date-range-field/index.js +2 -2
- package/dist/components/drawer/index.js +2 -2
- package/dist/components/dropdown/index.js +2 -2
- package/dist/components/dropdown-menu/index.js +2 -2
- package/dist/components/feed-event/feed-event.css +0 -2
- package/dist/components/file-upload/file-upload.css +0 -5
- package/dist/components/find-bar/find-bar.css +9 -1
- package/dist/components/focus-trap/index.js +2 -2
- package/dist/components/form-field/index.js +2 -2
- package/dist/components/guidance-region/index.css +1 -1
- package/dist/components/hover-card/index.js +2 -2
- package/dist/components/inline-confirm/index.js +2 -2
- package/dist/components/input/index.js +2 -2
- package/dist/components/input/input.css +95 -6
- package/dist/components/invocation-rule-builder/index.js +2 -2
- package/dist/components/json-editor/index.js +2 -2
- package/dist/components/json-schema-editor/index.js +4 -4
- package/dist/components/kanban-board/kanban-board.css +0 -10
- package/dist/components/key-value-editor/index.css +1 -1
- package/dist/components/line-chart/index.js +2 -2
- package/dist/components/marquee/marquee.css +0 -2
- package/dist/components/matrix-chart/index.js +2 -2
- package/dist/components/menu-bar/index.js +3 -3
- package/dist/components/modal/index.js +2 -2
- package/dist/components/modal/modal.css +0 -26
- package/dist/components/modal-region/index.css +1 -1
- package/dist/components/multi-select/index.js +2 -2
- package/dist/components/navigation-bar/index.js +2 -2
- package/dist/components/parameter-field/index.js +2 -2
- package/dist/components/permission-matrix/index.js +2 -2
- package/dist/components/policy-lock/index.js +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/radio-group/index.js +2 -2
- package/dist/components/schedule-builder/index.js +2 -2
- package/dist/components/schema-form/index.js +2 -2
- package/dist/components/scroll-area/index.js +2 -2
- package/dist/components/select/index.js +2 -2
- package/dist/components/selectable-row/selectable-row.css +0 -6
- package/dist/components/selection-popover/index.js +2 -2
- package/dist/components/share-card/index.js +2 -2
- package/dist/components/side-navigation/side-navigation.css +0 -1
- package/dist/components/sidebar/index.js +2 -2
- package/dist/components/speed-dial/index.js +2 -2
- package/dist/components/statistic/statistic.css +0 -8
- package/dist/components/statistic-group/index.js +2 -2
- package/dist/components/statistic-group/statistic-group.css +116 -69
- package/dist/components/status-dot/status-dot.css +0 -3
- package/dist/components/table/index.js +2 -2
- package/dist/components/table-of-contents/table-of-contents.css +0 -4
- package/dist/components/textarea/index.js +2 -2
- package/dist/components/time-field/index.js +2 -2
- package/dist/components/time-field/time-field.css +9 -8
- package/dist/components/toast-region/index.js +2 -2
- package/dist/components/toggle/toggle.variables.js +2 -2
- package/dist/components/tooltip/index.js +2 -2
- package/dist/components/transfer-list/index.js +2 -2
- package/dist/components/tree/tree.css +0 -3
- package/dist/components/virtual-list/_internal/adaptive-overscan.d.ts +87 -0
- package/dist/components/virtual-list/_internal/edge-proximity.d.ts +75 -0
- package/dist/components/virtual-list/_internal/frame-scheduler.d.ts +76 -0
- package/dist/components/virtual-list/_internal/geometry.d.ts +170 -0
- package/dist/components/virtual-list/_internal/list-semantics.d.ts +93 -0
- package/dist/components/virtual-list/_internal/measurement-window.d.ts +125 -0
- package/dist/components/virtual-list/_internal/reverse-order.d.ts +87 -0
- package/dist/components/virtual-list/_internal/scroll-restoration.d.ts +98 -0
- package/dist/components/virtual-list/_internal/sticky-items.d.ts +48 -0
- package/dist/components/virtual-list/_internal/virtual-list-measurement-store.svelte.d.ts +69 -0
- package/dist/components/virtual-list/index.d.ts +1 -1
- package/dist/components/virtual-list/index.js +2 -2
- package/dist/components/virtual-list/virtual-list.css +153 -2
- package/dist/components/virtual-list/virtual-list.schema.js +69 -6
- package/dist/components/virtual-list/virtual-list.svelte.d.ts +11 -8
- package/dist/components/virtual-list/virtual-list.types.d.ts +177 -4
- package/dist/index.browser.css +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -18
- package/dist/server/components/alert-dialog/index.js +1 -1
- package/dist/server/components/approval-card/index.js +1 -1
- package/dist/server/components/area-chart/index.js +1 -1
- package/dist/server/components/autocomplete/index.js +1 -1
- package/dist/server/components/avatar-group/index.js +1 -1
- package/dist/server/components/backdrop/index.js +1 -1
- package/dist/server/components/bar-chart/index.js +1 -1
- package/dist/server/components/checkbox/index.js +1 -1
- package/dist/server/components/code-block/index.js +1 -1
- package/dist/server/components/color-field/index.js +1 -1
- package/dist/server/components/combobox/index.js +1 -1
- package/dist/server/components/command-menu/index.js +1 -1
- package/dist/server/components/command-palette/index.js +2 -2
- package/dist/server/components/confirm-dialog/index.js +1 -1
- package/dist/server/components/context-menu/index.js +1 -1
- package/dist/server/components/data-table/index.js +1 -1
- package/dist/server/components/date-picker/index.js +1 -1
- package/dist/server/components/date-range-field/index.js +1 -1
- package/dist/server/components/drawer/index.js +1 -1
- package/dist/server/components/dropdown/index.js +1 -1
- package/dist/server/components/dropdown-menu/index.js +2 -2
- package/dist/server/components/focus-trap/index.js +1 -1
- package/dist/server/components/form-field/index.js +1 -1
- package/dist/server/components/hover-card/index.js +1 -1
- package/dist/server/components/inline-confirm/index.js +1 -1
- package/dist/server/components/input/index.js +1 -1
- package/dist/server/components/invocation-rule-builder/index.js +1 -1
- package/dist/server/components/json-editor/index.js +1 -1
- package/dist/server/components/json-schema-editor/index.js +1 -1
- package/dist/server/components/line-chart/index.js +1 -1
- package/dist/server/components/matrix-chart/index.js +1 -1
- package/dist/server/components/menu-bar/index.js +2 -2
- package/dist/server/components/modal/index.js +1 -1
- package/dist/server/components/multi-select/index.js +1 -1
- package/dist/server/components/navigation-bar/index.js +2 -2
- package/dist/server/components/parameter-field/index.js +1 -1
- package/dist/server/components/permission-matrix/index.js +1 -1
- package/dist/server/components/policy-lock/index.js +1 -1
- package/dist/server/components/popover/index.js +1 -1
- package/dist/server/components/radio-group/index.js +1 -1
- package/dist/server/components/schedule-builder/index.js +1 -1
- package/dist/server/components/schema-form/index.js +1 -1
- package/dist/server/components/scroll-area/index.js +1 -1
- package/dist/server/components/select/index.js +1 -1
- package/dist/server/components/selection-popover/index.js +1 -1
- package/dist/server/components/share-card/index.js +1 -1
- package/dist/server/components/sidebar/index.js +1 -1
- package/dist/server/components/speed-dial/index.js +2 -2
- package/dist/server/components/statistic-group/index.js +1 -1
- package/dist/server/components/table/index.js +1 -1
- package/dist/server/components/textarea/index.js +1 -1
- package/dist/server/components/time-field/index.js +1 -1
- package/dist/server/components/toast-region/index.js +1 -1
- package/dist/server/components/tooltip/index.js +1 -1
- package/dist/server/components/transfer-list/index.js +1 -1
- package/dist/server/components/virtual-list/index.js +2 -2
- package/dist/server/index.js +2 -2
- package/dist/server/{index.server-skq0f5sr.js → index.server-0jw25w9w.js} +1 -1
- package/dist/server/index.server-0kk20wvp.js +4 -0
- package/dist/server/{index.server-fzsqdajc.js → index.server-2awq6q9m.js} +1 -1
- package/dist/server/{index.server-e4hmhaeh.js → index.server-3xwvw6w2.js} +3 -3
- package/dist/server/{index.server-95h7xy01.js → index.server-428dh2t9.js} +2 -2
- package/dist/server/{index.server-jd88r74m.js → index.server-5dq66aja.js} +2 -2
- package/dist/server/{index.server-dvwfhf77.js → index.server-5s94r0kk.js} +2 -2
- package/dist/server/{index.server-qv6z5ta3.js → index.server-80qgcjnm.js} +1 -1
- package/dist/server/{index.server-7k2732ky.js → index.server-81abtrsw.js} +1 -1
- package/dist/server/{index.server-csmqnx5w.js → index.server-83q1gv2c.js} +1 -1
- package/dist/server/{index.server-qw8k9rjg.js → index.server-8fyav10d.js} +1 -1
- package/dist/server/{index.server-4dgjj4k1.js → index.server-8h5caecr.js} +2 -2
- package/dist/server/{index.server-emyqytmm.js → index.server-90n8sd9e.js} +1 -1
- package/dist/server/{index.server-0xrdyzvh.js → index.server-99penx1m.js} +1 -1
- package/dist/server/{index.server-p94j3jah.js → index.server-9g9d15z1.js} +1 -1
- package/dist/server/{index.server-xp9hkc81.js → index.server-9kbdx511.js} +1 -1
- package/dist/server/index.server-a2yhk45s.js +3 -0
- package/dist/server/{index.server-g8d2m2tk.js → index.server-acq55gjs.js} +1 -1
- package/dist/server/{index.server-ewze54tv.js → index.server-afjftjmr.js} +1 -1
- package/dist/server/{index.server-ejyye4gv.js → index.server-bfed6a8a.js} +1 -1
- package/dist/server/{index.server-z5ng08q2.js → index.server-c1746s0z.js} +1 -1
- package/dist/server/{index.server-gt1tfc1w.js → index.server-dmeztywe.js} +1 -1
- package/dist/server/{index.server-kzsppq0n.js → index.server-dyj3jdx9.js} +1 -1
- package/dist/server/index.server-dz92zvx6.js +4 -0
- package/dist/server/{index.server-3md8kdcr.js → index.server-e6682k08.js} +1 -1
- package/dist/server/{index.server-t1pshh65.js → index.server-ewkv461x.js} +1 -1
- package/dist/server/{index.server-zfgwhtmp.js → index.server-fa449wd3.js} +1 -1
- package/dist/server/{index.server-1kgwayct.js → index.server-fhfypmgw.js} +1 -1
- package/dist/server/{index.server-s4z8hsby.js → index.server-ge4adxs2.js} +1 -1
- package/dist/server/{index.server-68xyfsg3.js → index.server-gggkq22y.js} +2 -2
- package/dist/server/{index.server-acgwdamx.js → index.server-j52rbk57.js} +1 -1
- package/dist/server/{index.server-z0nwftx6.js → index.server-jm89hxfb.js} +1 -1
- package/dist/server/{index.server-xa98r8p2.js → index.server-jw0v64se.js} +1 -1
- package/dist/server/index.server-m321p69g.js +3 -0
- package/dist/server/{index.server-xyervw3d.js → index.server-m7q2tc41.js} +1 -1
- package/dist/server/{index.server-tnrxy86j.js → index.server-mak7dmj2.js} +1 -1
- package/dist/server/{index.server-n5g5h5k1.js → index.server-mw5r2524.js} +1 -1
- package/dist/server/{index.server-caf7s6m7.js → index.server-nwq1cg55.js} +1 -1
- package/dist/server/{index.server-3wdvs0wr.js → index.server-p423fy4q.js} +2 -2
- package/dist/server/{index.server-ks7fvwxt.js → index.server-prk5syj2.js} +1 -1
- package/dist/server/{index.server-6w9fp018.js → index.server-q4hytsq3.js} +1 -1
- package/dist/server/{index.server-5w2qw8fm.js → index.server-q597a1ck.js} +1 -1
- package/dist/server/{index.server-fz1pkvda.js → index.server-qgne9v2w.js} +1 -1
- package/dist/server/{index.server-1f2app32.js → index.server-rvdavf92.js} +1 -1
- package/dist/server/index.server-rwq20a22.js +3 -0
- package/dist/server/{index.server-0rvmnrw2.js → index.server-s9tjs45r.js} +1 -1
- package/dist/server/{index.server-cm2prec7.js → index.server-sqgxyfsw.js} +1 -1
- package/dist/server/{index.server-v6777tgn.js → index.server-t761nwvb.js} +1 -1
- package/dist/server/index.server-tbds8nwq.js +4 -0
- package/dist/server/index.server-tyhta5n3.js +3 -0
- package/dist/server/{index.server-yw7rah51.js → index.server-v5dxham4.js} +1 -1
- package/dist/server/index.server-va98cpyf.js +3 -0
- package/dist/server/index.server-vq1k69xt.js +3 -0
- package/dist/server/{index.server-egd355s6.js → index.server-wnf9btp7.js} +2 -2
- package/dist/server/{index.server-sjcbaztf.js → index.server-y3zgdtbv.js} +1 -1
- package/dist/server/{index.server-4tjtgzf9.js → index.server-y6vtbmyj.js} +1 -1
- package/dist/server/{index.server-2p2mjzzb.js → index.server-zff2qp1v.js} +1 -1
- package/dist/server/tokens/registry.generated.js +2 -2
- package/dist/tokens/registry.generated.js +2 -2
- package/package.json +2 -2
- package/src/_internal/form-field-frame.svelte +5 -0
- package/src/_internal/overlay.ts +14 -1
- package/src/components/_internal/create-command-list-state.svelte.ts +4 -0
- package/src/components/accordion-item/accordion-item.css +0 -10
- package/src/components/action-row/action-row.css +0 -9
- package/src/components/alert/alert.css +0 -1
- package/src/components/avatar-group/avatar-group.css +0 -2
- package/src/components/button/button.css +4 -4
- package/src/components/button/button.variables.json +31 -1
- package/src/components/button/button.variables.ts +31 -1
- package/src/components/card/card.css +0 -2
- package/src/components/carousel/carousel.css +0 -5
- package/src/components/code-block/code-block.css +0 -5
- package/src/components/command-menu/command-menu.svelte +63 -7
- package/src/components/command-palette/command-palette.css +50 -46
- package/src/components/command-palette/command-palette.svelte +68 -78
- package/src/components/data-table/data-table.css +0 -2
- package/src/components/dropdown/dropdown.svelte +73 -18
- package/src/components/dropdown-menu/dropdown-menu.svelte +63 -7
- package/src/components/feed-event/feed-event.css +0 -2
- package/src/components/file-upload/file-upload.css +0 -5
- package/src/components/find-bar/find-bar.css +9 -1
- package/src/components/input/input.css +95 -6
- package/src/components/input/input.svelte +44 -81
- package/src/components/kanban-board/kanban-board.css +0 -10
- package/src/components/marquee/marquee.css +0 -2
- package/src/components/menu-bar/menu-bar.svelte +12 -1
- package/src/components/modal/modal.css +0 -26
- package/src/components/multi-select/multi-select.svelte +7 -0
- package/src/components/navigation-bar/navigation-bar.svelte +82 -6
- package/src/components/selectable-row/selectable-row.css +0 -6
- package/src/components/selection-popover/selection-popover.svelte +24 -10
- package/src/components/share-card/share-card.svelte +24 -44
- package/src/components/side-navigation/side-navigation.css +0 -1
- package/src/components/speed-dial/speed-dial.svelte +23 -5
- package/src/components/statistic/statistic.css +0 -8
- package/src/components/statistic-group/statistic-group.css +116 -69
- package/src/components/statistic-group/statistic-group.examples.json +6 -0
- package/src/components/statistic-group/statistic-group.svelte +13 -1
- package/src/components/status-dot/status-dot.css +0 -3
- package/src/components/table-of-contents/table-of-contents.css +0 -4
- package/src/components/time-field/time-field.css +9 -8
- package/src/components/toast-region/toast-region.svelte +9 -0
- package/src/components/toggle/toggle.variables.json +1 -1
- package/src/components/toggle/toggle.variables.ts +4 -1
- package/src/components/tree/tree.css +0 -3
- package/src/components/virtual-list/_internal/adaptive-overscan.ts +248 -0
- package/src/components/virtual-list/_internal/edge-proximity.ts +130 -0
- package/src/components/virtual-list/_internal/frame-scheduler.ts +136 -0
- package/src/components/virtual-list/_internal/geometry.ts +236 -0
- package/src/components/virtual-list/_internal/list-semantics.ts +151 -0
- package/src/components/virtual-list/_internal/measurement-window.ts +300 -0
- package/src/components/virtual-list/_internal/reverse-order.ts +146 -0
- package/src/components/virtual-list/_internal/scroll-restoration.ts +209 -0
- package/src/components/virtual-list/_internal/sticky-items.ts +111 -0
- package/src/components/virtual-list/_internal/virtual-list-measurement-store.svelte.ts +145 -0
- package/src/components/virtual-list/index.ts +7 -1
- package/src/components/virtual-list/virtual-list.css +153 -2
- package/src/components/virtual-list/virtual-list.examples.json +42 -0
- package/src/components/virtual-list/virtual-list.schema.json +53 -3
- package/src/components/virtual-list/virtual-list.schema.ts +64 -3
- package/src/components/virtual-list/virtual-list.svelte +1527 -36
- package/src/components/virtual-list/virtual-list.types.ts +181 -4
- package/src/index.ts +3 -0
- package/src/styles/tokens-base.css +57 -22
- package/src/tokens/cinder.resolver.json +8 -0
- package/src/tokens/index.json +1 -1
- package/src/tokens/registry.generated.json +30 -4
- package/src/tokens/registry.generated.ts +32 -4
- package/src/tokens/resolved/dark-reduced-motion.json +47 -17
- package/src/tokens/resolved/dark.json +47 -17
- package/src/tokens/resolved/light-reduced-motion.json +48 -18
- package/src/tokens/resolved/light.json +48 -18
- package/src/tokens/sets/components.tokens.json +1 -1
- package/src/tokens/sets/semantic.tokens.json +120 -30
- package/src/tokens/themes/dark.tokens.json +115 -19
- package/src/tokens/themes/light.tokens.json +51 -3
- package/dist/server/index.server-191cnacw.js +0 -3
- package/dist/server/index.server-25dqx151.js +0 -3
- package/dist/server/index.server-77jyqvbv.js +0 -4
- package/dist/server/index.server-bgjrzr70.js +0 -3
- package/dist/server/index.server-khsp90vh.js +0 -3
- package/dist/server/index.server-ryk2pgbe.js +0 -4
- package/dist/server/index.server-tajr81bm.js +0 -3
- package/dist/server/index.server-vjzcrw3d.js +0 -4
- package/dist/server/index.server-zg3fx1n1.js +0 -3
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure axis and writing-direction geometry for `horizontal` and RTL support
|
|
3
|
+
* (CIN-191, CIN-192).
|
|
4
|
+
*
|
|
5
|
+
* Everything below is dependency-free: no `ResizeObserver`, no runes, and —
|
|
6
|
+
* with the sole exception of {@link domWritingDirectionReader}'s two
|
|
7
|
+
* one-line DOM reads — no direct DOM access either. It is held to the
|
|
8
|
+
* 100%-lines/100%-functions coverage floor (see `coverage-ratchet.json`)
|
|
9
|
+
* because none of it needs live layout to exercise every branch; the reader
|
|
10
|
+
* indirection in {@link resolveWritingDirection} is exactly what makes that
|
|
11
|
+
* true for RTL detection too, despite happy-dom's `getComputedStyle` being
|
|
12
|
+
* blind to the `dir` attribute (see that function's doc comment).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** A CSS writing direction, resolved to exactly one of the two real values. */
|
|
16
|
+
export type WritingDirection = 'ltr' | 'rtl';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Reads the two direction signals {@link resolveWritingDirection} needs,
|
|
20
|
+
* behind an interface so a test can inject a fake instead of depending on a
|
|
21
|
+
* real, connected DOM tree and a browser that reflects `dir` through
|
|
22
|
+
* `getComputedStyle` — which happy-dom does not (see that function's doc
|
|
23
|
+
* comment).
|
|
24
|
+
*/
|
|
25
|
+
export type WritingDirectionReader = {
|
|
26
|
+
/** Should return the raw `getComputedStyle(element).direction` value in production. */
|
|
27
|
+
readonly getComputedDirection: (element: Element) => string;
|
|
28
|
+
/** Should return `element.closest('[dir]')?.getAttribute('dir') ?? null` in production. */
|
|
29
|
+
readonly closestDirAttribute: (element: Element) => string | null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the writing direction that should govern scroll-offset reading
|
|
34
|
+
* for `element`.
|
|
35
|
+
*
|
|
36
|
+
* Reads the reader's computed-direction value FIRST — this is CIN-192's
|
|
37
|
+
* literal AC text ("RTL is detected via `getComputedStyle(element).direction`"),
|
|
38
|
+
* so computed style must genuinely be the primary source, not a fallback. If
|
|
39
|
+
* it reports `'rtl'`, that wins outright, with no further reads. If it
|
|
40
|
+
* reports `'ltr'`, this falls back to the nearest `[dir]` ancestor
|
|
41
|
+
* attribute — the seam that makes this function testable at all under
|
|
42
|
+
* happy-dom, whose `getComputedStyle` always answers `'ltr'` regardless of
|
|
43
|
+
* any `dir="rtl"` ancestor attribute.
|
|
44
|
+
*
|
|
45
|
+
* The injectable {@link WritingDirectionReader} is the whole point: it lets
|
|
46
|
+
* a test assert the PRIORITY RULE — computed style wins even over a
|
|
47
|
+
* conflicting `dir` attribute — which a hard-coded `getComputedStyle` call
|
|
48
|
+
* could never demonstrate under happy-dom, since there both signals would
|
|
49
|
+
* always agree.
|
|
50
|
+
*
|
|
51
|
+
* Accepted, documented gap: a real element with an explicit
|
|
52
|
+
* `direction: ltr` CSS override nested inside a `dir="rtl"` ancestor is
|
|
53
|
+
* misread as `rtl` by the fallback, because the fallback only looks at the
|
|
54
|
+
* attribute, never at computed style further up the tree. Narrow and
|
|
55
|
+
* disclosed, not silent — the AC's own detection mechanism is computed
|
|
56
|
+
* style on `element` itself, not on every ancestor.
|
|
57
|
+
*
|
|
58
|
+
* The attribute fallback is compared case-insensitively: HTML's `dir`
|
|
59
|
+
* attribute is defined case-insensitively (`dir="RTL"` is exactly as valid
|
|
60
|
+
* as `dir="rtl"`), matching this codebase's own `_internal/text-direction.ts`.
|
|
61
|
+
*/
|
|
62
|
+
export function resolveWritingDirection(
|
|
63
|
+
element: Element | null | undefined,
|
|
64
|
+
reader: WritingDirectionReader,
|
|
65
|
+
): WritingDirection {
|
|
66
|
+
if (!element) return 'ltr';
|
|
67
|
+
|
|
68
|
+
// Computed style is authoritative WHENEVER IT ANSWERS — including when it
|
|
69
|
+
// answers 'ltr'. An earlier version fell through to the `dir` attribute on
|
|
70
|
+
// anything that was not 'rtl', which inverted the priority CIN-192 asks for: an
|
|
71
|
+
// element carrying an explicit `direction: ltr` override inside a `dir="rtl"`
|
|
72
|
+
// ancestor was reported as rtl, contradicting what the browser actually renders.
|
|
73
|
+
const computed = reader.getComputedDirection(element)?.toLowerCase();
|
|
74
|
+
if (computed === 'rtl') return 'rtl';
|
|
75
|
+
if (computed === 'ltr') return 'ltr';
|
|
76
|
+
|
|
77
|
+
// Only when computed style yields nothing usable — a detached element, or an
|
|
78
|
+
// environment that does not compute style — does the attribute get a say.
|
|
79
|
+
return reader.closestDirAttribute(element)?.toLowerCase() === 'rtl' ? 'rtl' : 'ltr';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The real {@link WritingDirectionReader}, backed by `getComputedStyle` and
|
|
84
|
+
* `Element.closest`.
|
|
85
|
+
*
|
|
86
|
+
* Both lookups live inside the method bodies below — `getComputedStyle` is
|
|
87
|
+
* never referenced at module scope — so importing this module never
|
|
88
|
+
* touches it; it is only evaluated the first time a caller actually invokes
|
|
89
|
+
* `getComputedDirection`, which in `virtual-list.svelte` happens
|
|
90
|
+
* exclusively inside a mount `$effect`. That keeps this module safely
|
|
91
|
+
* importable during server rendering (CIN-205), where `getComputedStyle`
|
|
92
|
+
* does not exist. Under happy-dom both methods return a defined value for
|
|
93
|
+
* any real `Element` — `getComputedStyle` a direction string, `closest` a
|
|
94
|
+
* matching ancestor or `null` — so every line here is exercised by a plain
|
|
95
|
+
* Bun test, with no need to stub or delete either global.
|
|
96
|
+
*/
|
|
97
|
+
export const domWritingDirectionReader: WritingDirectionReader = {
|
|
98
|
+
getComputedDirection: (element) => getComputedStyle(element).direction,
|
|
99
|
+
closestDirAttribute: (element) => element.closest('[dir]')?.getAttribute('dir') ?? null,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The historical `scrollLeft` conventions browsers have used for
|
|
104
|
+
* right-to-left content. Irrelevant under `ltr`, where `scrollLeft` has
|
|
105
|
+
* always meant the same thing everywhere.
|
|
106
|
+
*/
|
|
107
|
+
export type RtlScrollType = 'default' | 'negative' | 'reverse';
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Classifies which RTL `scrollLeft` convention a browser implements, from two
|
|
111
|
+
* probe readings taken on a throwaway right-to-left scroll container.
|
|
112
|
+
*
|
|
113
|
+
* Pure, so the classification is testable without a browser — the caller supplies
|
|
114
|
+
* the readings. The probe itself is a handful of DOM writes and lives in the
|
|
115
|
+
* component, because nothing in this module may touch the DOM.
|
|
116
|
+
*
|
|
117
|
+
* Detection rather than assumption is deliberate. The three conventions are told
|
|
118
|
+
* apart by observable behaviour, and picking one by name is how the sign silently
|
|
119
|
+
* inverts: `'default'` sounds safe and is in fact the legacy Edge/IE behaviour.
|
|
120
|
+
*
|
|
121
|
+
* @param startScrollLeft `scrollLeft` while scrolled to the start (right) edge.
|
|
122
|
+
* @param scrollLeftAfterWritingNegativeOne `scrollLeft` read back after writing -1.
|
|
123
|
+
*/
|
|
124
|
+
export function classifyRtlScrollType(
|
|
125
|
+
startScrollLeft: number,
|
|
126
|
+
scrollLeftAfterWritingNegativeOne: number,
|
|
127
|
+
): RtlScrollType {
|
|
128
|
+
// Only 'reverse' starts at a positive maximum rather than at 0.
|
|
129
|
+
if (startScrollLeft > 0) return 'reverse';
|
|
130
|
+
// Of the two that start at 0, only 'negative' accepts a negative write.
|
|
131
|
+
return scrollLeftAfterWritingNegativeOne < 0 ? 'negative' : 'default';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Converts a raw `element.scrollLeft` into a normalized "distance from the
|
|
136
|
+
* start edge": always `>= 0`, and increasing as the user scrolls away from
|
|
137
|
+
* the start, regardless of which of the three historical RTL `scrollLeft`
|
|
138
|
+
* conventions the current browser implements.
|
|
139
|
+
*
|
|
140
|
+
* Under `ltr` the raw value passes through unchanged — `rtlScrollType` is
|
|
141
|
+
* meaningless there — regardless of which convention was passed. Under
|
|
142
|
+
* `rtl`:
|
|
143
|
+
*
|
|
144
|
+
* - `'negative'` — **what current browsers do.** `scrollLeft` is 0 at the
|
|
145
|
+
* start (right) edge and grows NEGATIVE toward the end. Chrome aligned
|
|
146
|
+
* with Firefox and Safari on this in Chrome 85; it is the CSSOM-View
|
|
147
|
+
* behaviour. The normalized value is its negation.
|
|
148
|
+
* - `'default'` — 0 at the start edge, growing POSITIVE toward the end.
|
|
149
|
+
* Legacy Edge/IE. Already the normalized shape, so it passes through.
|
|
150
|
+
* - `'reverse'` — `scrollLeft` equals `scrollWidth - clientWidth` at the
|
|
151
|
+
* start edge and decreases to 0 at the end. Pre-85 Chrome and old
|
|
152
|
+
* WebKit. The normalized value is that maximum minus the raw value.
|
|
153
|
+
*
|
|
154
|
+
* The names are this module's own and do NOT rank the conventions: `'default'`
|
|
155
|
+
* is a legacy behaviour despite its name, and callers must not treat it as a
|
|
156
|
+
* safe default. Detect the convention rather than assuming one — pinning
|
|
157
|
+
* `'default'` would invert the sign in every browser shipping today.
|
|
158
|
+
*/
|
|
159
|
+
export function normalizeInlineScrollOffset(
|
|
160
|
+
rawScrollLeft: number,
|
|
161
|
+
scrollWidth: number,
|
|
162
|
+
clientWidth: number,
|
|
163
|
+
direction: WritingDirection,
|
|
164
|
+
rtlScrollType: RtlScrollType,
|
|
165
|
+
): number {
|
|
166
|
+
if (direction === 'ltr') return rawScrollLeft;
|
|
167
|
+
// `0 - rawScrollLeft` rather than `-rawScrollLeft`: negating a raw value of
|
|
168
|
+
// exactly 0 (the start edge) with unary minus produces IEEE-754 negative
|
|
169
|
+
// zero, which fails a strict `Object.is`-based equality check against `0`.
|
|
170
|
+
if (rtlScrollType === 'negative') return 0 - rawScrollLeft;
|
|
171
|
+
if (rtlScrollType === 'reverse') {
|
|
172
|
+
const maxScrollOffset = Math.max(0, scrollWidth - clientWidth);
|
|
173
|
+
return maxScrollOffset - rawScrollLeft;
|
|
174
|
+
}
|
|
175
|
+
return rawScrollLeft;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Which axis the list scrolls and lays rows out along. */
|
|
179
|
+
export type AxisMode = 'vertical' | 'horizontal';
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* The logical CSS property names that carry a row's size and offset along
|
|
183
|
+
* `axis`. Logical, not physical (`block-size`/`inset-block-start` rather
|
|
184
|
+
* than `height`/`top`), so RTL flips the inline axis correctly for free —
|
|
185
|
+
* no separate RTL branch is needed at the layout layer.
|
|
186
|
+
*/
|
|
187
|
+
export type RowLayoutDescriptor = {
|
|
188
|
+
readonly sizeProperty: 'block-size' | 'inline-size';
|
|
189
|
+
readonly offsetProperty: 'inset-block-start' | 'inset-inline-start';
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
/** Resolves the logical CSS property names a row on `axis` is sized and positioned with. */
|
|
193
|
+
export function resolveRowLayoutDescriptor(axis: AxisMode): RowLayoutDescriptor {
|
|
194
|
+
return axis === 'horizontal'
|
|
195
|
+
? { sizeProperty: 'inline-size', offsetProperty: 'inset-inline-start' }
|
|
196
|
+
: { sizeProperty: 'block-size', offsetProperty: 'inset-block-start' };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Returns one dynamic style string for a per-row-absolute row (Wave 4
|
|
201
|
+
* sticky mode only): the row's offset and size along `axis`, as logical CSS
|
|
202
|
+
* declarations.
|
|
203
|
+
*
|
|
204
|
+
* A single string, not per-property `style:` directives, because the CSS
|
|
205
|
+
* property NAME itself varies by axis (`inset-block-start` vs
|
|
206
|
+
* `inset-inline-start`, `block-size` vs `inline-size`) and Svelte's
|
|
207
|
+
* `style:prop={value}` directive requires a static property name — a
|
|
208
|
+
* computed string built from a function call is unambiguously dynamic
|
|
209
|
+
* instead. `position: absolute` is deliberately NOT included here: it is
|
|
210
|
+
* static across every row in this mode and lives in the CSS sidecar
|
|
211
|
+
* (`.cinder-virtual-list__row[data-cinder-absolute]`) rather than being
|
|
212
|
+
* repeated as an inline declaration on every row.
|
|
213
|
+
*/
|
|
214
|
+
export function resolveAbsoluteRowStyle(axis: AxisMode, start: number, size: number): string {
|
|
215
|
+
const { offsetProperty, sizeProperty } = resolveRowLayoutDescriptor(axis);
|
|
216
|
+
return `${offsetProperty}:${start}px;${sizeProperty}:${size}px;`;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The main-axis size of an observed row, from a `ResizeObserver` entry's two
|
|
221
|
+
* possible size sources.
|
|
222
|
+
*
|
|
223
|
+
* `borderBoxSize` is already writing-mode relative, so its `inlineSize` is the
|
|
224
|
+
* correct main-axis size under a horizontal list in both writing directions. The
|
|
225
|
+
* `contentRect` fallback is physical, so the axis has to be chosen by hand — and
|
|
226
|
+
* an older engine that reports only `contentRect` is exactly where picking the
|
|
227
|
+
* wrong one goes unnoticed.
|
|
228
|
+
*/
|
|
229
|
+
export function resolveObservedMainAxisSize(
|
|
230
|
+
borderBoxSize: { readonly blockSize: number; readonly inlineSize: number } | undefined,
|
|
231
|
+
contentRect: { readonly width: number; readonly height: number },
|
|
232
|
+
axis: AxisMode,
|
|
233
|
+
): number {
|
|
234
|
+
if (axis === 'horizontal') return borderBoxSize?.inlineSize ?? contentRect.width;
|
|
235
|
+
return borderBoxSize?.blockSize ?? contentRect.height;
|
|
236
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure ARIA row-semantics and keyboard-navigation arithmetic for the virtual
|
|
3
|
+
* list. See CIN-201.
|
|
4
|
+
*
|
|
5
|
+
* A virtualized list only ever mounts a small window of rows, so assistive
|
|
6
|
+
* technology reading `aria-posinset`/`aria-setsize` off the mounted DOM
|
|
7
|
+
* alone would announce something like "3 of 12" for a list of 10,000 items
|
|
8
|
+
* — the window length, not the true list size. `resolveRowSemantics` exists
|
|
9
|
+
* to hand the component the FULL-list numbers to stamp onto each mounted
|
|
10
|
+
* row instead of that.
|
|
11
|
+
*
|
|
12
|
+
* `resolveKeyboardTargetIndex` is the companion arithmetic for arrow/Page/
|
|
13
|
+
* Home/End navigation: it resolves which index a keypress should move focus
|
|
14
|
+
* to, independent of which rows happen to be mounted right now, so
|
|
15
|
+
* navigation keeps working identically across mount and unmount cycles as
|
|
16
|
+
* the window scrolls past a given row.
|
|
17
|
+
*
|
|
18
|
+
* Dependency-free, matching the rest of `_internal/`: no DOM, no runes. The
|
|
19
|
+
* component owns reading the real `KeyboardEvent.key`, moving focus to the
|
|
20
|
+
* resolved index (mounting it first if it currently sits outside the
|
|
21
|
+
* window), and the actual scrolling.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** `aria-posinset`/`aria-setsize` values for one row of a virtualized list. */
|
|
25
|
+
export type RowSemantics = {
|
|
26
|
+
/** 1-based position within the FULL list — never the zero-based `index` passed in. */
|
|
27
|
+
readonly ariaPosInSet: number;
|
|
28
|
+
/** The FULL item count, not the length of the rendered window — see the module doc for why that distinction is the point. */
|
|
29
|
+
readonly ariaSetSize: number;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the `aria-posinset`/`aria-setsize` pair for the row at `index`.
|
|
34
|
+
*
|
|
35
|
+
* `aria-posinset` is 1-BASED: `index` is the zero-based array position, so
|
|
36
|
+
* this adds 1 rather than passing `index` straight through — passing the
|
|
37
|
+
* zero-based index through unchanged is the single most common way to get
|
|
38
|
+
* this attribute wrong.
|
|
39
|
+
*
|
|
40
|
+
* `aria-setsize` is `itemCount`, the FULL logical list size, not the number
|
|
41
|
+
* of rows currently mounted in the virtualization window. That distinction
|
|
42
|
+
* is the entire reason a virtualized list needs these attributes in the
|
|
43
|
+
* first place: without it, assistive technology would announce something
|
|
44
|
+
* like "3 of 12" for a list of 10,000 items, reading only what happens to
|
|
45
|
+
* be in the DOM right now.
|
|
46
|
+
*/
|
|
47
|
+
export function resolveRowSemantics(index: number, itemCount: number): RowSemantics {
|
|
48
|
+
return { ariaPosInSet: index + 1, ariaSetSize: itemCount };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Which axis `resolveKeyboardTargetIndex` treats as "forward"/"backward" for the Arrow keys. */
|
|
52
|
+
export type VirtualListOrientation = 'vertical' | 'horizontal';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Resolves the index a navigation keypress should move focus to.
|
|
56
|
+
*
|
|
57
|
+
* Returns `null` when `key` is not one of the keys this list handles, so
|
|
58
|
+
* the component can tell "not a navigation key, leave the event alone"
|
|
59
|
+
* apart from "navigation key, but the move happens to be a no-op." The
|
|
60
|
+
* latter still returns the (unchanged) index rather than `null` — the
|
|
61
|
+
* component still needs to consume the event (stopping it from scrolling
|
|
62
|
+
* the page via the browser's own default handling, for instance) even when
|
|
63
|
+
* the reader is already at the boundary they pressed toward.
|
|
64
|
+
*
|
|
65
|
+
* `Home` resolves to 0 and `End` to `itemCount - 1`. Every result is clamped
|
|
66
|
+
* to `[0, itemCount - 1]`; `itemCount <= 0` has no valid index to move to at
|
|
67
|
+
* all, so every key resolves to `null` in that case, including `Home` and
|
|
68
|
+
* `End`.
|
|
69
|
+
*
|
|
70
|
+
* `PageUp`/`PageDown` resolve to `null` here, deliberately. Paging is a PIXEL
|
|
71
|
+
* move of one uncovered viewport, which an index cannot express once rows vary
|
|
72
|
+
* in height — any row count this returned would be wrong at some boundary, in
|
|
73
|
+
* one direction or the other. The component scrolls for those keys directly.
|
|
74
|
+
*
|
|
75
|
+
* The horizontal arrow mapping DOES branch on writing direction, and has to.
|
|
76
|
+
* `KeyboardEvent.key` is derived from the physical key and the keyboard layout;
|
|
77
|
+
* it is not remapped by `dir`, so the right arrow reports `'ArrowRight'` in a
|
|
78
|
+
* right-to-left list exactly as it does in a left-to-right one. Meanwhile the
|
|
79
|
+
* component positions horizontal rows with logical properties, so under RTL a
|
|
80
|
+
* higher index sits visually to the LEFT. Mapping `'ArrowRight'` to "forward"
|
|
81
|
+
* there would walk the reader backwards from where they pressed.
|
|
82
|
+
*
|
|
83
|
+
* This is what the WAI-ARIA Authoring Practices mean by "if the direction is
|
|
84
|
+
* RTL, Right Arrow performs as Left Arrow and vice versa" — guidance that exists
|
|
85
|
+
* precisely because the reversal is not automatic. `writingDirection` is ignored
|
|
86
|
+
* for a vertical list, where the block axis does not flip.
|
|
87
|
+
*/
|
|
88
|
+
export function resolveKeyboardTargetIndex(options: {
|
|
89
|
+
key: string;
|
|
90
|
+
currentIndex: number;
|
|
91
|
+
itemCount: number;
|
|
92
|
+
orientation: VirtualListOrientation;
|
|
93
|
+
writingDirection?: 'ltr' | 'rtl';
|
|
94
|
+
/**
|
|
95
|
+
* Indexes rendered as sticky headers. Stepping keys move between content rows
|
|
96
|
+
* and pass over these.
|
|
97
|
+
*/
|
|
98
|
+
stickyIndexes?: ReadonlySet<number>;
|
|
99
|
+
}): number | null {
|
|
100
|
+
if (options.itemCount <= 0) return null;
|
|
101
|
+
|
|
102
|
+
const lastIndex = options.itemCount - 1;
|
|
103
|
+
const clampToListRange = (index: number): number => Math.max(0, Math.min(lastIndex, index));
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Steps past sticky rows in the direction of travel.
|
|
107
|
+
*
|
|
108
|
+
* A sticky header is held at the leading edge for as long as its section is in
|
|
109
|
+
* view, so it is on screen already and scrolling to it moves nothing. Worse, it
|
|
110
|
+
* is the row a step lands on coming back UP to a section: the destination's
|
|
111
|
+
* inset is zero exactly there, so the target resolves to the position the reader
|
|
112
|
+
* is already at and the key does nothing at all.
|
|
113
|
+
*
|
|
114
|
+
* Running off the end means every row that way is sticky, so there is no content
|
|
115
|
+
* row to reach; the boundary itself is as close as the reader gets.
|
|
116
|
+
*/
|
|
117
|
+
const skipStickyRows = (index: number, direction: number): number => {
|
|
118
|
+
const sticky = options.stickyIndexes;
|
|
119
|
+
if (sticky === undefined || sticky.size === 0) return index;
|
|
120
|
+
let candidate = index;
|
|
121
|
+
while (candidate >= 0 && candidate <= lastIndex && sticky.has(candidate)) {
|
|
122
|
+
candidate += direction;
|
|
123
|
+
}
|
|
124
|
+
return candidate < 0 || candidate > lastIndex ? index : candidate;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Home and End are absolute: they mean the ends of the list, sticky or not.
|
|
128
|
+
if (options.key === 'Home') return 0;
|
|
129
|
+
if (options.key === 'End') return lastIndex;
|
|
130
|
+
|
|
131
|
+
if (options.orientation === 'vertical') {
|
|
132
|
+
if (options.key === 'ArrowDown')
|
|
133
|
+
return skipStickyRows(clampToListRange(options.currentIndex + 1), 1);
|
|
134
|
+
if (options.key === 'ArrowUp')
|
|
135
|
+
return skipStickyRows(clampToListRange(options.currentIndex - 1), -1);
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Under RTL the inline axis runs right-to-left, so the arrow that moves the
|
|
140
|
+
// reader visually forward is the left one.
|
|
141
|
+
const isRightToLeft = options.writingDirection === 'rtl';
|
|
142
|
+
const forwardKey = isRightToLeft ? 'ArrowLeft' : 'ArrowRight';
|
|
143
|
+
const backwardKey = isRightToLeft ? 'ArrowRight' : 'ArrowLeft';
|
|
144
|
+
|
|
145
|
+
if (options.key === forwardKey)
|
|
146
|
+
return skipStickyRows(clampToListRange(options.currentIndex + 1), 1);
|
|
147
|
+
if (options.key === backwardKey)
|
|
148
|
+
return skipStickyRows(clampToListRange(options.currentIndex - 1), -1);
|
|
149
|
+
|
|
150
|
+
return null;
|
|
151
|
+
}
|