@liberation-data/desk 0.34.0 → 0.35.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/README.md +3 -1
- package/dist/css/controls.css +19 -5
- package/dist/desk.css +19 -5
- package/dist/react/outline.d.ts +6 -1
- package/dist/react/outline.d.ts.map +1 -1
- package/dist/react/outline.js +4 -3
- package/dist/react/outline.js.map +1 -1
- package/llms.txt +5 -2
- package/package.json +1 -1
- package/src/css/controls.css +19 -5
- package/src/react/outline.tsx +11 -3
package/README.md
CHANGED
|
@@ -662,7 +662,9 @@ selection, Enter or a double click opens a row, and a sortable heading says whic
|
|
|
662
662
|
hierarchy — a document's headings, a schema — given as a flat list in reading order with a `depth` on each
|
|
663
663
|
row. It is a tree to the keyboard: up and down through the rows, left out to the parent, right in to the first
|
|
664
664
|
child. Depth shows as weight, colour and a small indent, and stops changing at the fourth level, so a deep
|
|
665
|
-
hierarchy cannot indent itself out of the list. A row is one line, cut with an ellipsis and whole on hover.
|
|
665
|
+
hierarchy cannot indent itself out of the list. A row is one line, cut with an ellipsis and whole on hover.
|
|
666
|
+
When what is on show runs past the chosen row — a page that holds three headings — name the others in
|
|
667
|
+
`showing` and they are marked with it; marked rows that touch read as one block, round only at its two ends. A **pop-up button** is what a
|
|
666
668
|
segmented control becomes when there are too many options to show at once; unlike a menu it takes focus, and
|
|
667
669
|
typing jumps to an option. A **checkbox** is for a setting that waits for Save (a Toggle applies at once),
|
|
668
670
|
and can stand for a mixed set. A **slider** reads its value in words for people who cannot see it.
|
package/dist/css/controls.css
CHANGED
|
@@ -971,20 +971,34 @@
|
|
|
971
971
|
|
|
972
972
|
/* Named with the hover it has to outrank: the chosen row stays the chosen colour under the pointer. */
|
|
973
973
|
.desk-outline-row[data-current],
|
|
974
|
-
.desk-outline-row[data-current]:hover:not(:disabled)
|
|
974
|
+
.desk-outline-row[data-current]:hover:not(:disabled),
|
|
975
|
+
.desk-outline-row[data-showing],
|
|
976
|
+
.desk-outline-row[data-showing]:hover:not(:disabled) {
|
|
975
977
|
background: color-mix(in srgb, var(--desk-accent) 18%, transparent);
|
|
976
978
|
color: var(--desk-ink);
|
|
977
979
|
}
|
|
978
980
|
|
|
981
|
+
/* Marked rows that touch read as one block: only its first and last corners are round. */
|
|
982
|
+
.desk-outline-row:is([data-current], [data-showing]):has(+ :is([data-current], [data-showing])) {
|
|
983
|
+
border-end-start-radius: 0;
|
|
984
|
+
border-end-end-radius: 0;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
.desk-outline-row:is([data-current], [data-showing]) + :is([data-current], [data-showing]) {
|
|
988
|
+
border-start-start-radius: 0;
|
|
989
|
+
border-start-end-radius: 0;
|
|
990
|
+
}
|
|
991
|
+
|
|
979
992
|
.desk-outline-row:focus-visible {
|
|
980
993
|
outline: 2px solid var(--desk-accent);
|
|
981
994
|
outline-offset: -2px;
|
|
982
995
|
}
|
|
983
996
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
}
|
|
997
|
+
/* The label dims, not the row: a row that cannot be chosen can still be marked, and its mark is
|
|
998
|
+
the same strength as its neighbours'. The row's own opacity is stated, so a page that dims every
|
|
999
|
+
disabled button does not dim the mark with it. */
|
|
1000
|
+
.desk-outline-row:disabled { opacity: 1; cursor: not-allowed; }
|
|
1001
|
+
.desk-outline-row:disabled .desk-outline-label { opacity: .45; }
|
|
988
1002
|
|
|
989
1003
|
.desk-outline-label {
|
|
990
1004
|
flex: 1;
|
package/dist/desk.css
CHANGED
|
@@ -2287,20 +2287,34 @@
|
|
|
2287
2287
|
|
|
2288
2288
|
/* Named with the hover it has to outrank: the chosen row stays the chosen colour under the pointer. */
|
|
2289
2289
|
.desk-outline-row[data-current],
|
|
2290
|
-
.desk-outline-row[data-current]:hover:not(:disabled)
|
|
2290
|
+
.desk-outline-row[data-current]:hover:not(:disabled),
|
|
2291
|
+
.desk-outline-row[data-showing],
|
|
2292
|
+
.desk-outline-row[data-showing]:hover:not(:disabled) {
|
|
2291
2293
|
background: color-mix(in srgb, var(--desk-accent) 18%, transparent);
|
|
2292
2294
|
color: var(--desk-ink);
|
|
2293
2295
|
}
|
|
2294
2296
|
|
|
2297
|
+
/* Marked rows that touch read as one block: only its first and last corners are round. */
|
|
2298
|
+
.desk-outline-row:is([data-current], [data-showing]):has(+ :is([data-current], [data-showing])) {
|
|
2299
|
+
border-end-start-radius: 0;
|
|
2300
|
+
border-end-end-radius: 0;
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
.desk-outline-row:is([data-current], [data-showing]) + :is([data-current], [data-showing]) {
|
|
2304
|
+
border-start-start-radius: 0;
|
|
2305
|
+
border-start-end-radius: 0;
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2295
2308
|
.desk-outline-row:focus-visible {
|
|
2296
2309
|
outline: 2px solid var(--desk-accent);
|
|
2297
2310
|
outline-offset: -2px;
|
|
2298
2311
|
}
|
|
2299
2312
|
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
}
|
|
2313
|
+
/* The label dims, not the row: a row that cannot be chosen can still be marked, and its mark is
|
|
2314
|
+
the same strength as its neighbours'. The row's own opacity is stated, so a page that dims every
|
|
2315
|
+
disabled button does not dim the mark with it. */
|
|
2316
|
+
.desk-outline-row:disabled { opacity: 1; cursor: not-allowed; }
|
|
2317
|
+
.desk-outline-row:disabled .desk-outline-label { opacity: .45; }
|
|
2304
2318
|
|
|
2305
2319
|
.desk-outline-label {
|
|
2306
2320
|
flex: 1;
|
package/dist/react/outline.d.ts
CHANGED
|
@@ -14,9 +14,14 @@ export interface OutlineProps {
|
|
|
14
14
|
/** The chosen row, or null when none is. */
|
|
15
15
|
readonly value: string | null;
|
|
16
16
|
readonly onChange: (id: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* The rows on show along with the chosen one: the headings a page holds after the one it starts
|
|
19
|
+
* at. They are marked as the chosen row is, and the chosen row stays the one the keyboard is on.
|
|
20
|
+
*/
|
|
21
|
+
readonly showing?: readonly string[];
|
|
17
22
|
/** Names the outline for assistive technology: "Sections". */
|
|
18
23
|
readonly label: string;
|
|
19
24
|
readonly className?: string;
|
|
20
25
|
}
|
|
21
|
-
export declare function Outline({ rows, value, onChange, label, className }: OutlineProps): import("react").JSX.Element;
|
|
26
|
+
export declare function Outline({ rows, value, onChange, showing, label, className }: OutlineProps): import("react").JSX.Element;
|
|
22
27
|
//# sourceMappingURL=outline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/react/outline.tsx"],"names":[],"mappings":"AAgBA,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,CAAA;IACpC,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;
|
|
1
|
+
{"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/react/outline.tsx"],"names":[],"mappings":"AAgBA,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,CAAA;IACpC,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAMD,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAc,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,YAAY,+BAwEhG"}
|
package/dist/react/outline.js
CHANGED
|
@@ -15,7 +15,8 @@ import { useEffect, useRef } from 'react';
|
|
|
15
15
|
/** The deepest level drawn differently. Deeper rows look like this one. */
|
|
16
16
|
export const OUTLINE_MAX_DEPTH = 4;
|
|
17
17
|
const drawnDepth = (depth) => Math.min(Math.max(1, Math.floor(depth)), OUTLINE_MAX_DEPTH);
|
|
18
|
-
|
|
18
|
+
const NONE = [];
|
|
19
|
+
export function Outline({ rows, value, onChange, showing = NONE, label, className }) {
|
|
19
20
|
const tree = useRef(null);
|
|
20
21
|
const enabled = rows.filter(row => !row.disabled);
|
|
21
22
|
// One tab stop: the chosen row, or the first that can be chosen when none is.
|
|
@@ -60,9 +61,9 @@ export function Outline({ rows, value, onChange, label, className }) {
|
|
|
60
61
|
event.preventDefault();
|
|
61
62
|
choose(target);
|
|
62
63
|
};
|
|
63
|
-
return (_jsx("div", { ref: tree, role: "tree", "aria-label": label, className: ['desk-outline', className].filter(Boolean).join(' '), onKeyDown: onKeyDown, children: rows.map(row => {
|
|
64
|
+
return (_jsx("div", { ref: tree, role: "tree", "aria-label": label, "aria-multiselectable": showing.length > 0 || undefined, className: ['desk-outline', className].filter(Boolean).join(' '), onKeyDown: onKeyDown, children: rows.map(row => {
|
|
64
65
|
const current = row.id === value;
|
|
65
|
-
return (_jsx("button", { type: "button", role: "treeitem", "aria-level": Math.max(1, Math.floor(row.depth)), "aria-selected": current, "data-row": row.id, "data-depth": drawnDepth(row.depth), "data-current": current || undefined, className: "desk-outline-row", disabled: row.disabled, tabIndex: row.id === tabStop ? 0 : -1, title: row.label, onClick: () => onChange(row.id), children: _jsx("span", { className: "desk-outline-label", children: row.label }) }, row.id));
|
|
66
|
+
return (_jsx("button", { type: "button", role: "treeitem", "aria-level": Math.max(1, Math.floor(row.depth)), "aria-selected": current || showing.includes(row.id), "data-row": row.id, "data-depth": drawnDepth(row.depth), "data-current": current || undefined, "data-showing": (!current && showing.includes(row.id)) || undefined, className: "desk-outline-row", disabled: row.disabled, tabIndex: row.id === tabStop ? 0 : -1, title: row.label, onClick: () => onChange(row.id), children: _jsx("span", { className: "desk-outline-label", children: row.label }) }, row.id));
|
|
66
67
|
}) }));
|
|
67
68
|
}
|
|
68
69
|
//# sourceMappingURL=outline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outline.js","sourceRoot":"","sources":["../../src/react/outline.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAGzC;;;;;;;;;;;GAWG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"outline.js","sourceRoot":"","sources":["../../src/react/outline.tsx"],"names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AK,CAAA;YAChC,OAAO,CACL,iBAEE,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,UAAU,gBACH,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,mBAC/B,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,cACxC,GAAG,CAAC,EAAE,gBACJ,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,kBACnB,OAAO,IAAI,SAAS,kBACpB,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,SAAS,EACjE,SAAS,EAAC,kBAAkB,EAC5B,QAAQ,EAAE,GAAG,CAAC,QAAQ,EACtB,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACrC,KAAK,EAAE,GAAG,CAAC,KAAK,EAChB,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,YAE/B,eAAM,SAAS,EAAC,oBAAoB,YAAE,GAAG,CAAC,KAAK,GAAQ,IAflD,GAAG,CAAC,EAAE,CAgBJ,CACV,CAAA;QACH,CAAC,CAAC,GACE,CACP,CAAA;AACH,CAAC"}
|
package/llms.txt
CHANGED
|
@@ -493,14 +493,17 @@ interface Sort { key: string; direction: 'ascending' | 'descending' }
|
|
|
493
493
|
<Sidebar sections={{ id, label?, items: { id, label, icon?, badge?, disabled? }[] }[]}
|
|
494
494
|
value onChange label footer? />
|
|
495
495
|
|
|
496
|
-
<Outline rows={{ id, label, depth, disabled? }[]} value={string | null} onChange label />
|
|
496
|
+
<Outline rows={{ id, label, depth, disabled? }[]} value={string | null} onChange showing? label />
|
|
497
497
|
```
|
|
498
498
|
|
|
499
499
|
Outline: a hierarchy as a flat list in reading order, each row saying its `depth` (1 is the top). Use it
|
|
500
500
|
for a document's headings, a schema, a folder — not `Sidebar`, which is a few places at one level. One tab
|
|
501
501
|
stop; up and down move through the rows, left goes out to the parent and right in to the first child, Home
|
|
502
502
|
and End to the ends. Depth is drawn with weight, colour and indent, and stops changing at the fourth level
|
|
503
|
-
(`OUTLINE_MAX_DEPTH`). A `disabled` row is listed and cannot be chosen.
|
|
503
|
+
(`OUTLINE_MAX_DEPTH`). A `disabled` row is listed and cannot be chosen. `showing` names the rows on show
|
|
504
|
+
along with `value` (a page that holds several headings): they are marked as the chosen row is, and
|
|
505
|
+
`value` stays where the keyboard is. Marked rows that touch are drawn as one block, a `disabled` row
|
|
506
|
+
among them included.
|
|
504
507
|
|
|
505
508
|
Table: one tab stop, arrow keys move the selection, Enter or double click activates, `aria-sort` on
|
|
506
509
|
sortable headings. It renders what it is given — no paging, no fetching.
|
package/package.json
CHANGED
package/src/css/controls.css
CHANGED
|
@@ -970,20 +970,34 @@
|
|
|
970
970
|
|
|
971
971
|
/* Named with the hover it has to outrank: the chosen row stays the chosen colour under the pointer. */
|
|
972
972
|
.desk-outline-row[data-current],
|
|
973
|
-
.desk-outline-row[data-current]:hover:not(:disabled)
|
|
973
|
+
.desk-outline-row[data-current]:hover:not(:disabled),
|
|
974
|
+
.desk-outline-row[data-showing],
|
|
975
|
+
.desk-outline-row[data-showing]:hover:not(:disabled) {
|
|
974
976
|
background: color-mix(in srgb, var(--desk-accent) 18%, transparent);
|
|
975
977
|
color: var(--desk-ink);
|
|
976
978
|
}
|
|
977
979
|
|
|
980
|
+
/* Marked rows that touch read as one block: only its first and last corners are round. */
|
|
981
|
+
.desk-outline-row:is([data-current], [data-showing]):has(+ :is([data-current], [data-showing])) {
|
|
982
|
+
border-end-start-radius: 0;
|
|
983
|
+
border-end-end-radius: 0;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
.desk-outline-row:is([data-current], [data-showing]) + :is([data-current], [data-showing]) {
|
|
987
|
+
border-start-start-radius: 0;
|
|
988
|
+
border-start-end-radius: 0;
|
|
989
|
+
}
|
|
990
|
+
|
|
978
991
|
.desk-outline-row:focus-visible {
|
|
979
992
|
outline: 2px solid var(--desk-accent);
|
|
980
993
|
outline-offset: -2px;
|
|
981
994
|
}
|
|
982
995
|
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
}
|
|
996
|
+
/* The label dims, not the row: a row that cannot be chosen can still be marked, and its mark is
|
|
997
|
+
the same strength as its neighbours'. The row's own opacity is stated, so a page that dims every
|
|
998
|
+
disabled button does not dim the mark with it. */
|
|
999
|
+
.desk-outline-row:disabled { opacity: 1; cursor: not-allowed; }
|
|
1000
|
+
.desk-outline-row:disabled .desk-outline-label { opacity: .45; }
|
|
987
1001
|
|
|
988
1002
|
.desk-outline-label {
|
|
989
1003
|
flex: 1;
|
package/src/react/outline.tsx
CHANGED
|
@@ -32,6 +32,11 @@ export interface OutlineProps {
|
|
|
32
32
|
/** The chosen row, or null when none is. */
|
|
33
33
|
readonly value: string | null
|
|
34
34
|
readonly onChange: (id: string) => void
|
|
35
|
+
/**
|
|
36
|
+
* The rows on show along with the chosen one: the headings a page holds after the one it starts
|
|
37
|
+
* at. They are marked as the chosen row is, and the chosen row stays the one the keyboard is on.
|
|
38
|
+
*/
|
|
39
|
+
readonly showing?: readonly string[]
|
|
35
40
|
/** Names the outline for assistive technology: "Sections". */
|
|
36
41
|
readonly label: string
|
|
37
42
|
readonly className?: string
|
|
@@ -39,7 +44,9 @@ export interface OutlineProps {
|
|
|
39
44
|
|
|
40
45
|
const drawnDepth = (depth: number) => Math.min(Math.max(1, Math.floor(depth)), OUTLINE_MAX_DEPTH)
|
|
41
46
|
|
|
42
|
-
|
|
47
|
+
const NONE: readonly string[] = []
|
|
48
|
+
|
|
49
|
+
export function Outline({ rows, value, onChange, showing = NONE, label, className }: OutlineProps) {
|
|
43
50
|
const tree = useRef<HTMLDivElement>(null)
|
|
44
51
|
const enabled = rows.filter(row => !row.disabled)
|
|
45
52
|
// One tab stop: the chosen row, or the first that can be chosen when none is.
|
|
@@ -85,7 +92,7 @@ export function Outline({ rows, value, onChange, label, className }: OutlineProp
|
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
return (
|
|
88
|
-
<div ref={tree} role="tree" aria-label={label} className={['desk-outline', className].filter(Boolean).join(' ')} onKeyDown={onKeyDown}>
|
|
95
|
+
<div ref={tree} role="tree" aria-label={label} aria-multiselectable={showing.length > 0 || undefined} className={['desk-outline', className].filter(Boolean).join(' ')} onKeyDown={onKeyDown}>
|
|
89
96
|
{rows.map(row => {
|
|
90
97
|
const current = row.id === value
|
|
91
98
|
return (
|
|
@@ -94,10 +101,11 @@ export function Outline({ rows, value, onChange, label, className }: OutlineProp
|
|
|
94
101
|
type="button"
|
|
95
102
|
role="treeitem"
|
|
96
103
|
aria-level={Math.max(1, Math.floor(row.depth))}
|
|
97
|
-
aria-selected={current}
|
|
104
|
+
aria-selected={current || showing.includes(row.id)}
|
|
98
105
|
data-row={row.id}
|
|
99
106
|
data-depth={drawnDepth(row.depth)}
|
|
100
107
|
data-current={current || undefined}
|
|
108
|
+
data-showing={(!current && showing.includes(row.id)) || undefined}
|
|
101
109
|
className="desk-outline-row"
|
|
102
110
|
disabled={row.disabled}
|
|
103
111
|
tabIndex={row.id === tabStop ? 0 : -1}
|