@liberation-data/desk 0.29.0 → 0.30.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/README.md +6 -1
- package/dist/css/controls.css +68 -0
- package/dist/desk.css +68 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/dist/react/outline.d.ts +22 -0
- package/dist/react/outline.d.ts.map +1 -0
- package/dist/react/outline.js +68 -0
- package/dist/react/outline.js.map +1 -0
- package/llms.txt +8 -0
- package/package.json +1 -1
- package/src/css/controls.css +68 -0
- package/src/react/index.ts +2 -0
- package/src/react/outline.tsx +113 -0
package/README.md
CHANGED
|
@@ -584,6 +584,7 @@ arriving.
|
|
|
584
584
|
sort={sort} onSortChange={setSort} empty={<p>No rides yet</p>} />
|
|
585
585
|
|
|
586
586
|
<Sidebar label="Bikes" sections={SECTIONS} value={bike} onChange={setBike} />
|
|
587
|
+
<Outline label="Manual" rows={HEADINGS} value={heading} onChange={setHeading} />
|
|
587
588
|
|
|
588
589
|
<PopUpButton label="Distance" options={UNITS} value={units} onChange={setUnits} />
|
|
589
590
|
<Checkbox checked={commutes} onChange={setCommutes} label="Count commutes towards wear" />
|
|
@@ -592,7 +593,11 @@ arriving.
|
|
|
592
593
|
|
|
593
594
|
A **table** renders what it is given — no paging, no fetching — and is one tab stop: arrow keys move the
|
|
594
595
|
selection, Enter or a double click opens a row, and a sortable heading says which way it is sorted. A
|
|
595
|
-
**sidebar** is navigation, so where you are is `aria-current` and stays put.
|
|
596
|
+
**sidebar** is navigation, so where you are is `aria-current` and stays put. An **outline** is a
|
|
597
|
+
hierarchy — a document's headings, a schema — given as a flat list in reading order with a `depth` on each
|
|
598
|
+
row. It is a tree to the keyboard: up and down through the rows, left out to the parent, right in to the first
|
|
599
|
+
child. Depth shows as weight, colour and a small indent, and stops changing at the fourth level, so a deep
|
|
600
|
+
hierarchy cannot indent itself out of the list. A row is one line, cut with an ellipsis and whole on hover. A **pop-up button** is what a
|
|
596
601
|
segmented control becomes when there are too many options to show at once; unlike a menu it takes focus, and
|
|
597
602
|
typing jumps to an option. A **checkbox** is for a setting that waits for Save (a Toggle applies at once),
|
|
598
603
|
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
|
@@ -930,6 +930,74 @@
|
|
|
930
930
|
|
|
931
931
|
/* ── Sidebar ── */
|
|
932
932
|
|
|
933
|
+
/*
|
|
934
|
+
* Outline. Depth is weight, colour and a small indent together, and all three stop at the fourth
|
|
935
|
+
* level, so a deep hierarchy cannot indent itself out of the list's width.
|
|
936
|
+
*/
|
|
937
|
+
.desk-outline {
|
|
938
|
+
display: flex;
|
|
939
|
+
flex-direction: column;
|
|
940
|
+
padding: var(--desk-space-2);
|
|
941
|
+
font-family: var(--desk-font);
|
|
942
|
+
overflow-y: auto;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
.desk-outline-row {
|
|
946
|
+
display: flex;
|
|
947
|
+
align-items: center;
|
|
948
|
+
flex: none;
|
|
949
|
+
width: 100%;
|
|
950
|
+
min-height: 28px;
|
|
951
|
+
padding: var(--desk-space-1) var(--desk-space-2);
|
|
952
|
+
padding-inline-start: calc(var(--desk-space-2) + var(--desk-outline-indent, 0px));
|
|
953
|
+
border: 0;
|
|
954
|
+
border-radius: 7px;
|
|
955
|
+
background: transparent;
|
|
956
|
+
color: var(--desk-ink);
|
|
957
|
+
font: inherit;
|
|
958
|
+
font-size: var(--desk-text-body);
|
|
959
|
+
text-align: start;
|
|
960
|
+
cursor: pointer;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
.desk-outline-row[data-depth="1"] { font-weight: 600; }
|
|
964
|
+
.desk-outline-row[data-depth="2"] { --desk-outline-indent: var(--desk-space-3); }
|
|
965
|
+
.desk-outline-row[data-depth="3"] { --desk-outline-indent: calc(var(--desk-space-3) * 2); color: var(--desk-muted); }
|
|
966
|
+
.desk-outline-row[data-depth="4"] { --desk-outline-indent: calc(var(--desk-space-3) * 3); color: var(--desk-muted); }
|
|
967
|
+
|
|
968
|
+
.desk-outline-row:hover:not(:disabled) {
|
|
969
|
+
background: color-mix(in srgb, var(--desk-ink) 7%, transparent);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/* Named with the hover it has to outrank: the chosen row stays the chosen colour under the pointer. */
|
|
973
|
+
.desk-outline-row[data-current],
|
|
974
|
+
.desk-outline-row[data-current]:hover:not(:disabled) {
|
|
975
|
+
background: color-mix(in srgb, var(--desk-accent) 18%, transparent);
|
|
976
|
+
color: var(--desk-ink);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
.desk-outline-row:focus-visible {
|
|
980
|
+
outline: 2px solid var(--desk-accent);
|
|
981
|
+
outline-offset: -2px;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
.desk-outline-row:disabled {
|
|
985
|
+
opacity: .45;
|
|
986
|
+
cursor: not-allowed;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
.desk-outline-label {
|
|
990
|
+
flex: 1;
|
|
991
|
+
min-width: 0;
|
|
992
|
+
overflow: hidden;
|
|
993
|
+
text-overflow: ellipsis;
|
|
994
|
+
white-space: nowrap;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
@media (pointer: coarse) {
|
|
998
|
+
.desk-outline-row { min-height: 44px; }
|
|
999
|
+
}
|
|
1000
|
+
|
|
933
1001
|
.desk-sidebar {
|
|
934
1002
|
display: flex;
|
|
935
1003
|
flex-direction: column;
|
package/dist/desk.css
CHANGED
|
@@ -2216,6 +2216,74 @@
|
|
|
2216
2216
|
|
|
2217
2217
|
/* ── Sidebar ── */
|
|
2218
2218
|
|
|
2219
|
+
/*
|
|
2220
|
+
* Outline. Depth is weight, colour and a small indent together, and all three stop at the fourth
|
|
2221
|
+
* level, so a deep hierarchy cannot indent itself out of the list's width.
|
|
2222
|
+
*/
|
|
2223
|
+
.desk-outline {
|
|
2224
|
+
display: flex;
|
|
2225
|
+
flex-direction: column;
|
|
2226
|
+
padding: var(--desk-space-2);
|
|
2227
|
+
font-family: var(--desk-font);
|
|
2228
|
+
overflow-y: auto;
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
.desk-outline-row {
|
|
2232
|
+
display: flex;
|
|
2233
|
+
align-items: center;
|
|
2234
|
+
flex: none;
|
|
2235
|
+
width: 100%;
|
|
2236
|
+
min-height: 28px;
|
|
2237
|
+
padding: var(--desk-space-1) var(--desk-space-2);
|
|
2238
|
+
padding-inline-start: calc(var(--desk-space-2) + var(--desk-outline-indent, 0px));
|
|
2239
|
+
border: 0;
|
|
2240
|
+
border-radius: 7px;
|
|
2241
|
+
background: transparent;
|
|
2242
|
+
color: var(--desk-ink);
|
|
2243
|
+
font: inherit;
|
|
2244
|
+
font-size: var(--desk-text-body);
|
|
2245
|
+
text-align: start;
|
|
2246
|
+
cursor: pointer;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
.desk-outline-row[data-depth="1"] { font-weight: 600; }
|
|
2250
|
+
.desk-outline-row[data-depth="2"] { --desk-outline-indent: var(--desk-space-3); }
|
|
2251
|
+
.desk-outline-row[data-depth="3"] { --desk-outline-indent: calc(var(--desk-space-3) * 2); color: var(--desk-muted); }
|
|
2252
|
+
.desk-outline-row[data-depth="4"] { --desk-outline-indent: calc(var(--desk-space-3) * 3); color: var(--desk-muted); }
|
|
2253
|
+
|
|
2254
|
+
.desk-outline-row:hover:not(:disabled) {
|
|
2255
|
+
background: color-mix(in srgb, var(--desk-ink) 7%, transparent);
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
/* Named with the hover it has to outrank: the chosen row stays the chosen colour under the pointer. */
|
|
2259
|
+
.desk-outline-row[data-current],
|
|
2260
|
+
.desk-outline-row[data-current]:hover:not(:disabled) {
|
|
2261
|
+
background: color-mix(in srgb, var(--desk-accent) 18%, transparent);
|
|
2262
|
+
color: var(--desk-ink);
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
.desk-outline-row:focus-visible {
|
|
2266
|
+
outline: 2px solid var(--desk-accent);
|
|
2267
|
+
outline-offset: -2px;
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
.desk-outline-row:disabled {
|
|
2271
|
+
opacity: .45;
|
|
2272
|
+
cursor: not-allowed;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
.desk-outline-label {
|
|
2276
|
+
flex: 1;
|
|
2277
|
+
min-width: 0;
|
|
2278
|
+
overflow: hidden;
|
|
2279
|
+
text-overflow: ellipsis;
|
|
2280
|
+
white-space: nowrap;
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
@media (pointer: coarse) {
|
|
2284
|
+
.desk-outline-row { min-height: 44px; }
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2219
2287
|
.desk-sidebar {
|
|
2220
2288
|
display: flex;
|
|
2221
2289
|
flex-direction: column;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export { Tabs } from './tabs.js';
|
|
|
44
44
|
export type { Tab, TabsProps } from './tabs.js';
|
|
45
45
|
export { Table } from './table.js';
|
|
46
46
|
export type { Column, Sort, TableProps } from './table.js';
|
|
47
|
+
export { Outline, OUTLINE_MAX_DEPTH } from './outline.js';
|
|
48
|
+
export type { OutlineProps, OutlineRow } from './outline.js';
|
|
47
49
|
export { Sidebar } from './sidebar.js';
|
|
48
50
|
export type { SidebarItem, SidebarProps, SidebarSection } from './sidebar.js';
|
|
49
51
|
export { Wizard } from './wizard.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC1E,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,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Q,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AACpD,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC5E,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC9E,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AACjH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC3G,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AACrG,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC/E,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/react/index.js
CHANGED
|
@@ -21,6 +21,7 @@ export { PopUpButton } from './popup.js';
|
|
|
21
21
|
export { Chip, Disclosure } from './disclosure.js';
|
|
22
22
|
export { Tabs } from './tabs.js';
|
|
23
23
|
export { Table } from './table.js';
|
|
24
|
+
export { Outline, OUTLINE_MAX_DEPTH } from './outline.js';
|
|
24
25
|
export { Sidebar } from './sidebar.js';
|
|
25
26
|
export { Wizard } from './wizard.js';
|
|
26
27
|
export { TourBar } from './tour.js';
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE1E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAWhG,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAExF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEnF,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAetH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAGrE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAGpD,OAAO,EAAE,IAAI,EAAE,UAAU,E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 -0,0 +1,22 @@
|
|
|
1
|
+
/** The deepest level drawn differently. Deeper rows look like this one. */
|
|
2
|
+
export declare const OUTLINE_MAX_DEPTH = 4;
|
|
3
|
+
export interface OutlineRow {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
/** 1 for the top level, 2 for a row inside one, and so on. */
|
|
7
|
+
readonly depth: number;
|
|
8
|
+
/** Listed, but with nothing to open: a heading with no words under it. */
|
|
9
|
+
readonly disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface OutlineProps {
|
|
12
|
+
/** In the order they are read, each saying how deep it sits. */
|
|
13
|
+
readonly rows: readonly OutlineRow[];
|
|
14
|
+
/** The chosen row, or null when none is. */
|
|
15
|
+
readonly value: string | null;
|
|
16
|
+
readonly onChange: (id: string) => void;
|
|
17
|
+
/** Names the outline for assistive technology: "Sections". */
|
|
18
|
+
readonly label: string;
|
|
19
|
+
readonly className?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function Outline({ rows, value, onChange, label, className }: OutlineProps): import("react").JSX.Element;
|
|
22
|
+
//# sourceMappingURL=outline.d.ts.map
|
|
@@ -0,0 +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;AAID,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,YAAY,+BAuEhF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
/*
|
|
4
|
+
* An outline: a list that shows how deep each row sits. A document's headings, a schema, a folder.
|
|
5
|
+
*
|
|
6
|
+
* It is not a sidebar. A sidebar is a few places to go, in sections, all at one level; an outline
|
|
7
|
+
* can be hundreds of rows in a hierarchy, and is moved through the way a tree is. The rows arrive
|
|
8
|
+
* flat and in order, each saying its depth, because that is how a hierarchy is usually held and it
|
|
9
|
+
* leaves nothing to fold or unfold by accident.
|
|
10
|
+
*
|
|
11
|
+
* Depth is drawn with weight, colour and a small indent, and all three stop changing at
|
|
12
|
+
* [OUTLINE_MAX_DEPTH]: a hierarchy twelve levels deep cannot indent the list out of its own width.
|
|
13
|
+
* A row is one line; a title too long for it is cut, and is whole on hover.
|
|
14
|
+
*/
|
|
15
|
+
/** The deepest level drawn differently. Deeper rows look like this one. */
|
|
16
|
+
export const OUTLINE_MAX_DEPTH = 4;
|
|
17
|
+
const drawnDepth = (depth) => Math.min(Math.max(1, Math.floor(depth)), OUTLINE_MAX_DEPTH);
|
|
18
|
+
export function Outline({ rows, value, onChange, label, className }) {
|
|
19
|
+
const tree = useRef(null);
|
|
20
|
+
const enabled = rows.filter(row => !row.disabled);
|
|
21
|
+
// One tab stop: the chosen row, or the first that can be chosen when none is.
|
|
22
|
+
const tabStop = enabled.some(row => row.id === value) ? value : enabled[0]?.id ?? null;
|
|
23
|
+
// Chosen from outside — Next, a link — it may be out of sight; bring it in without jumping.
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (value === null)
|
|
26
|
+
return;
|
|
27
|
+
tree.current?.querySelector(`[data-row="${CSS.escape(value)}"]`)?.scrollIntoView?.({ block: 'nearest' });
|
|
28
|
+
}, [value]);
|
|
29
|
+
const choose = (row) => {
|
|
30
|
+
if (!row)
|
|
31
|
+
return;
|
|
32
|
+
onChange(row.id);
|
|
33
|
+
tree.current?.querySelector(`[data-row="${CSS.escape(row.id)}"]`)?.focus();
|
|
34
|
+
};
|
|
35
|
+
const onKeyDown = (event) => {
|
|
36
|
+
const at = rows.findIndex(row => row.id === document.activeElement?.dataset.row);
|
|
37
|
+
if (at < 0)
|
|
38
|
+
return;
|
|
39
|
+
const here = rows[at];
|
|
40
|
+
const usable = (row) => !row.disabled;
|
|
41
|
+
const target = (() => {
|
|
42
|
+
switch (event.key) {
|
|
43
|
+
case 'ArrowDown': return rows.slice(at + 1).find(usable);
|
|
44
|
+
case 'ArrowUp': return rows.slice(0, at).reverse().find(usable);
|
|
45
|
+
case 'Home': return enabled[0];
|
|
46
|
+
case 'End': return enabled.at(-1);
|
|
47
|
+
// Out to what this row sits inside, as a tree does.
|
|
48
|
+
case 'ArrowLeft': return rows.slice(0, at).reverse().find(row => row.depth < here.depth && usable(row));
|
|
49
|
+
// In to the first row inside this one, if it has any.
|
|
50
|
+
case 'ArrowRight': {
|
|
51
|
+
const inside = rows.slice(at + 1);
|
|
52
|
+
const end = inside.findIndex(row => row.depth <= here.depth);
|
|
53
|
+
return (end < 0 ? inside : inside.slice(0, end)).find(usable);
|
|
54
|
+
}
|
|
55
|
+
default: return undefined;
|
|
56
|
+
}
|
|
57
|
+
})();
|
|
58
|
+
if (!['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key))
|
|
59
|
+
return;
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
choose(target);
|
|
62
|
+
};
|
|
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
|
+
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
|
+
}) }));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=outline.js.map
|
|
@@ -0,0 +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;AAsBlC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAA;AAEjG,MAAM,UAAU,OAAO,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAgB;IAC/E,MAAM,IAAI,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAA;IACzC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACjD,8EAA8E;IAC9E,MAAM,OAAO,GAA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string; direction: 'ascending' | 'descending' }
|
|
|
448
448
|
|
|
449
449
|
<Sidebar sections={{ id, label?, items: { id, label, icon?, badge?, disabled? }[] }[]}
|
|
450
450
|
value onChange label footer? />
|
|
451
|
+
|
|
452
|
+
<Outline rows={{ id, label, depth, disabled? }[]} value={string | null} onChange label />
|
|
451
453
|
```
|
|
452
454
|
|
|
455
|
+
Outline: a hierarchy as a flat list in reading order, each row saying its `depth` (1 is the top). Use it
|
|
456
|
+
for a document's headings, a schema, a folder — not `Sidebar`, which is a few places at one level. One tab
|
|
457
|
+
stop; up and down move through the rows, left goes out to the parent and right in to the first child, Home
|
|
458
|
+
and End to the ends. Depth is drawn with weight, colour and indent, and stops changing at the fourth level
|
|
459
|
+
(`OUTLINE_MAX_DEPTH`). A `disabled` row is listed and cannot be chosen.
|
|
460
|
+
|
|
453
461
|
Table: one tab stop, arrow keys move the selection, Enter or double click activates, `aria-sort` on
|
|
454
462
|
sortable headings. It renders what it is given — no paging, no fetching.
|
|
455
463
|
|
package/package.json
CHANGED
package/src/css/controls.css
CHANGED
|
@@ -929,6 +929,74 @@
|
|
|
929
929
|
|
|
930
930
|
/* ── Sidebar ── */
|
|
931
931
|
|
|
932
|
+
/*
|
|
933
|
+
* Outline. Depth is weight, colour and a small indent together, and all three stop at the fourth
|
|
934
|
+
* level, so a deep hierarchy cannot indent itself out of the list's width.
|
|
935
|
+
*/
|
|
936
|
+
.desk-outline {
|
|
937
|
+
display: flex;
|
|
938
|
+
flex-direction: column;
|
|
939
|
+
padding: var(--desk-space-2);
|
|
940
|
+
font-family: var(--desk-font);
|
|
941
|
+
overflow-y: auto;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
.desk-outline-row {
|
|
945
|
+
display: flex;
|
|
946
|
+
align-items: center;
|
|
947
|
+
flex: none;
|
|
948
|
+
width: 100%;
|
|
949
|
+
min-height: 28px;
|
|
950
|
+
padding: var(--desk-space-1) var(--desk-space-2);
|
|
951
|
+
padding-inline-start: calc(var(--desk-space-2) + var(--desk-outline-indent, 0px));
|
|
952
|
+
border: 0;
|
|
953
|
+
border-radius: 7px;
|
|
954
|
+
background: transparent;
|
|
955
|
+
color: var(--desk-ink);
|
|
956
|
+
font: inherit;
|
|
957
|
+
font-size: var(--desk-text-body);
|
|
958
|
+
text-align: start;
|
|
959
|
+
cursor: pointer;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
.desk-outline-row[data-depth="1"] { font-weight: 600; }
|
|
963
|
+
.desk-outline-row[data-depth="2"] { --desk-outline-indent: var(--desk-space-3); }
|
|
964
|
+
.desk-outline-row[data-depth="3"] { --desk-outline-indent: calc(var(--desk-space-3) * 2); color: var(--desk-muted); }
|
|
965
|
+
.desk-outline-row[data-depth="4"] { --desk-outline-indent: calc(var(--desk-space-3) * 3); color: var(--desk-muted); }
|
|
966
|
+
|
|
967
|
+
.desk-outline-row:hover:not(:disabled) {
|
|
968
|
+
background: color-mix(in srgb, var(--desk-ink) 7%, transparent);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/* Named with the hover it has to outrank: the chosen row stays the chosen colour under the pointer. */
|
|
972
|
+
.desk-outline-row[data-current],
|
|
973
|
+
.desk-outline-row[data-current]:hover:not(:disabled) {
|
|
974
|
+
background: color-mix(in srgb, var(--desk-accent) 18%, transparent);
|
|
975
|
+
color: var(--desk-ink);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
.desk-outline-row:focus-visible {
|
|
979
|
+
outline: 2px solid var(--desk-accent);
|
|
980
|
+
outline-offset: -2px;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
.desk-outline-row:disabled {
|
|
984
|
+
opacity: .45;
|
|
985
|
+
cursor: not-allowed;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
.desk-outline-label {
|
|
989
|
+
flex: 1;
|
|
990
|
+
min-width: 0;
|
|
991
|
+
overflow: hidden;
|
|
992
|
+
text-overflow: ellipsis;
|
|
993
|
+
white-space: nowrap;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
@media (pointer: coarse) {
|
|
997
|
+
.desk-outline-row { min-height: 44px; }
|
|
998
|
+
}
|
|
999
|
+
|
|
932
1000
|
.desk-sidebar {
|
|
933
1001
|
display: flex;
|
|
934
1002
|
flex-direction: column;
|
package/src/react/index.ts
CHANGED
|
@@ -66,6 +66,8 @@ export { Tabs } from './tabs.js'
|
|
|
66
66
|
export type { Tab, TabsProps } from './tabs.js'
|
|
67
67
|
export { Table } from './table.js'
|
|
68
68
|
export type { Column, Sort, TableProps } from './table.js'
|
|
69
|
+
export { Outline, OUTLINE_MAX_DEPTH } from './outline.js'
|
|
70
|
+
export type { OutlineProps, OutlineRow } from './outline.js'
|
|
69
71
|
export { Sidebar } from './sidebar.js'
|
|
70
72
|
export type { SidebarItem, SidebarProps, SidebarSection } from './sidebar.js'
|
|
71
73
|
export { Wizard } from './wizard.js'
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
|
+
import type { KeyboardEvent } from 'react'
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* An outline: a list that shows how deep each row sits. A document's headings, a schema, a folder.
|
|
6
|
+
*
|
|
7
|
+
* It is not a sidebar. A sidebar is a few places to go, in sections, all at one level; an outline
|
|
8
|
+
* can be hundreds of rows in a hierarchy, and is moved through the way a tree is. The rows arrive
|
|
9
|
+
* flat and in order, each saying its depth, because that is how a hierarchy is usually held and it
|
|
10
|
+
* leaves nothing to fold or unfold by accident.
|
|
11
|
+
*
|
|
12
|
+
* Depth is drawn with weight, colour and a small indent, and all three stop changing at
|
|
13
|
+
* [OUTLINE_MAX_DEPTH]: a hierarchy twelve levels deep cannot indent the list out of its own width.
|
|
14
|
+
* A row is one line; a title too long for it is cut, and is whole on hover.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** The deepest level drawn differently. Deeper rows look like this one. */
|
|
18
|
+
export const OUTLINE_MAX_DEPTH = 4
|
|
19
|
+
|
|
20
|
+
export interface OutlineRow {
|
|
21
|
+
readonly id: string
|
|
22
|
+
readonly label: string
|
|
23
|
+
/** 1 for the top level, 2 for a row inside one, and so on. */
|
|
24
|
+
readonly depth: number
|
|
25
|
+
/** Listed, but with nothing to open: a heading with no words under it. */
|
|
26
|
+
readonly disabled?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface OutlineProps {
|
|
30
|
+
/** In the order they are read, each saying how deep it sits. */
|
|
31
|
+
readonly rows: readonly OutlineRow[]
|
|
32
|
+
/** The chosen row, or null when none is. */
|
|
33
|
+
readonly value: string | null
|
|
34
|
+
readonly onChange: (id: string) => void
|
|
35
|
+
/** Names the outline for assistive technology: "Sections". */
|
|
36
|
+
readonly label: string
|
|
37
|
+
readonly className?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const drawnDepth = (depth: number) => Math.min(Math.max(1, Math.floor(depth)), OUTLINE_MAX_DEPTH)
|
|
41
|
+
|
|
42
|
+
export function Outline({ rows, value, onChange, label, className }: OutlineProps) {
|
|
43
|
+
const tree = useRef<HTMLDivElement>(null)
|
|
44
|
+
const enabled = rows.filter(row => !row.disabled)
|
|
45
|
+
// One tab stop: the chosen row, or the first that can be chosen when none is.
|
|
46
|
+
const tabStop = enabled.some(row => row.id === value) ? value : enabled[0]?.id ?? null
|
|
47
|
+
|
|
48
|
+
// Chosen from outside — Next, a link — it may be out of sight; bring it in without jumping.
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (value === null) return
|
|
51
|
+
tree.current?.querySelector<HTMLElement>(`[data-row="${CSS.escape(value)}"]`)?.scrollIntoView?.({ block: 'nearest' })
|
|
52
|
+
}, [value])
|
|
53
|
+
|
|
54
|
+
const choose = (row: OutlineRow | undefined) => {
|
|
55
|
+
if (!row) return
|
|
56
|
+
onChange(row.id)
|
|
57
|
+
tree.current?.querySelector<HTMLButtonElement>(`[data-row="${CSS.escape(row.id)}"]`)?.focus()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {
|
|
61
|
+
const at = rows.findIndex(row => row.id === (document.activeElement as HTMLElement | null)?.dataset.row)
|
|
62
|
+
if (at < 0) return
|
|
63
|
+
const here = rows[at]!
|
|
64
|
+
const usable = (row: OutlineRow) => !row.disabled
|
|
65
|
+
const target: OutlineRow | undefined = (() => {
|
|
66
|
+
switch (event.key) {
|
|
67
|
+
case 'ArrowDown': return rows.slice(at + 1).find(usable)
|
|
68
|
+
case 'ArrowUp': return rows.slice(0, at).reverse().find(usable)
|
|
69
|
+
case 'Home': return enabled[0]
|
|
70
|
+
case 'End': return enabled.at(-1)
|
|
71
|
+
// Out to what this row sits inside, as a tree does.
|
|
72
|
+
case 'ArrowLeft': return rows.slice(0, at).reverse().find(row => row.depth < here.depth && usable(row))
|
|
73
|
+
// In to the first row inside this one, if it has any.
|
|
74
|
+
case 'ArrowRight': {
|
|
75
|
+
const inside = rows.slice(at + 1)
|
|
76
|
+
const end = inside.findIndex(row => row.depth <= here.depth)
|
|
77
|
+
return (end < 0 ? inside : inside.slice(0, end)).find(usable)
|
|
78
|
+
}
|
|
79
|
+
default: return undefined
|
|
80
|
+
}
|
|
81
|
+
})()
|
|
82
|
+
if (!['ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return
|
|
83
|
+
event.preventDefault()
|
|
84
|
+
choose(target)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div ref={tree} role="tree" aria-label={label} className={['desk-outline', className].filter(Boolean).join(' ')} onKeyDown={onKeyDown}>
|
|
89
|
+
{rows.map(row => {
|
|
90
|
+
const current = row.id === value
|
|
91
|
+
return (
|
|
92
|
+
<button
|
|
93
|
+
key={row.id}
|
|
94
|
+
type="button"
|
|
95
|
+
role="treeitem"
|
|
96
|
+
aria-level={Math.max(1, Math.floor(row.depth))}
|
|
97
|
+
aria-selected={current}
|
|
98
|
+
data-row={row.id}
|
|
99
|
+
data-depth={drawnDepth(row.depth)}
|
|
100
|
+
data-current={current || undefined}
|
|
101
|
+
className="desk-outline-row"
|
|
102
|
+
disabled={row.disabled}
|
|
103
|
+
tabIndex={row.id === tabStop ? 0 : -1}
|
|
104
|
+
title={row.label}
|
|
105
|
+
onClick={() => onChange(row.id)}
|
|
106
|
+
>
|
|
107
|
+
<span className="desk-outline-label">{row.label}</span>
|
|
108
|
+
</button>
|
|
109
|
+
)
|
|
110
|
+
})}
|
|
111
|
+
</div>
|
|
112
|
+
)
|
|
113
|
+
}
|