@kerfjs/ui 5.0.0-beta.126 → 5.0.0-beta.127
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/ai/component-props.json +20 -0
- package/ai/public-api-signatures-v1.md +7 -5
- package/ai/webawesome-jsx-signatures-v1.md +1 -1
- package/dist/browser/editor.js +3 -1
- package/dist/{chunk-NR3ZO4LK.js → chunk-7U65KLDL.js} +1 -1
- package/dist/chunk-7U65KLDL.js.map +1 -0
- package/dist/chunk-BMOZSNDU.js +133 -0
- package/dist/chunk-BMOZSNDU.js.map +1 -0
- package/dist/chunk-GHV36C6I.js +94 -0
- package/dist/chunk-GHV36C6I.js.map +1 -0
- package/dist/{chunk-Z3BT2SZE.js → chunk-GQUDCWOD.js} +8 -2
- package/dist/chunk-GQUDCWOD.js.map +1 -0
- package/dist/{chunk-3SCGTP5O.js → chunk-HD7ZLISK.js} +137 -11
- package/dist/chunk-HD7ZLISK.js.map +1 -0
- package/dist/column-explorer.d.ts +1 -1
- package/dist/column-explorer.js +16 -138
- package/dist/column-explorer.js.map +1 -1
- package/dist/editor.js +838 -115
- package/dist/editor.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/list-detail-dialog.js +1 -1
- package/dist/styles/components/surfaces/editor-frame/editor-frame.css +8 -1
- package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +32 -0
- package/dist/styles/editor/editor.css +23 -0
- package/dist/styles/editor-frame.css +8 -1
- package/dist/styles/surface-scaffold.css +32 -0
- package/dist/surface-scaffold.d.ts +3 -1
- package/dist/surface-scaffold.js +1 -1
- package/dist/tree-list.d.ts +2 -2
- package/dist/tree-list.js +2 -2
- package/dist/{tree-rows-eHnnGLGM.d.ts → tree-rows-Bms5QJvG.d.ts} +3 -0
- package/dist/wire-column-explorer.js +1 -92
- package/dist/wire-column-explorer.js.map +1 -1
- package/dist/workbench-dialog.js +1 -1
- package/docs/view.md +19 -0
- package/package.json +4 -2
- package/ux-demo/recipes/app-shell.tsx +48 -141
- package/ux-demo/recipes/collapsible-sidebar.tsx +43 -169
- package/ux-demo/recipes/compact-toolbar.tsx +22 -114
- package/ux-demo/recipes/composer-form.tsx +14 -104
- package/ux-demo/recipes/list-detail-dialog.tsx +38 -84
- package/ux-demo/recipes/list-workspace-states.tsx +29 -152
- package/ux-demo/recipes/loading-inspector.tsx +30 -174
- package/ux-demo/recipes/media-detail.tsx +29 -146
- package/ux-demo/recipes/navigation-sidebar.tsx +24 -113
- package/ux-demo/recipes/navigation-stack.tsx +7 -43
- package/ux-demo/recipes/workspace-header.tsx +2 -66
- package/view/generate.mjs +34 -14
- package/dist/chunk-3SCGTP5O.js.map +0 -1
- package/dist/chunk-NR3ZO4LK.js.map +0 -1
- package/dist/chunk-Z3BT2SZE.js.map +0 -1
package/ai/component-props.json
CHANGED
|
@@ -13465,6 +13465,16 @@
|
|
|
13465
13465
|
"default": "flow",
|
|
13466
13466
|
"description": "Body layout (default `flow`); `fill` lets one child own the body and\n`fill-last` stacks fixed rows above one filling last child."
|
|
13467
13467
|
},
|
|
13468
|
+
{
|
|
13469
|
+
"name": "resizeFromBottom",
|
|
13470
|
+
"type": {
|
|
13471
|
+
"kind": "boolean",
|
|
13472
|
+
"text": "boolean | undefined",
|
|
13473
|
+
"nullable": true
|
|
13474
|
+
},
|
|
13475
|
+
"required": false,
|
|
13476
|
+
"description": "Add a bottom-edge handle that pins and resizes an overlay by drag or arrow key."
|
|
13477
|
+
},
|
|
13468
13478
|
{
|
|
13469
13479
|
"name": "pinLabel",
|
|
13470
13480
|
"type": { "kind": "string", "text": "string", "nullable": true },
|
|
@@ -28884,6 +28894,16 @@
|
|
|
28884
28894
|
"required": false,
|
|
28885
28895
|
"description": "Drags with `wireTreeList`'s `onMove` (KF-WXP6AB)."
|
|
28886
28896
|
},
|
|
28897
|
+
{
|
|
28898
|
+
"name": "rootAttributes",
|
|
28899
|
+
"type": {
|
|
28900
|
+
"kind": "record",
|
|
28901
|
+
"text": "Readonly<Record<`data-${string}`, string | undefined>>",
|
|
28902
|
+
"nullable": true
|
|
28903
|
+
},
|
|
28904
|
+
"required": false,
|
|
28905
|
+
"description": "Safe data attributes carried by this row in either tree presentation."
|
|
28906
|
+
},
|
|
28887
28907
|
{
|
|
28888
28908
|
"name": "children",
|
|
28889
28909
|
"type": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Public API signatures for the UI authoring corpus
|
|
2
2
|
|
|
3
|
-
Generated from emitted declarations for `@kerfjs/ui@5.0.0-beta.
|
|
3
|
+
Generated from emitted declarations for `@kerfjs/ui@5.0.0-beta.127` and `kerfjs@5.0.0-beta.127`. This bounded reference covers only APIs used by the seven-task corpus. It is interface evidence, not an implementation or runtime guarantee.
|
|
4
4
|
|
|
5
5
|
## `@kerfjs/ui/css-values`
|
|
6
6
|
|
|
@@ -5499,6 +5499,8 @@ interface PinnablePopoverSurfaceProps {
|
|
|
5499
5499
|
* `fill-last` stacks fixed rows above one filling last child.
|
|
5500
5500
|
*/
|
|
5501
5501
|
bodyLayout?: DialogSurfaceBodyLayout;
|
|
5502
|
+
/** Add a bottom-edge handle that pins and resizes an overlay by drag or arrow key. */
|
|
5503
|
+
resizeFromBottom?: boolean;
|
|
5502
5504
|
/** The Pin toggle's accessible name (default `Pin`). */
|
|
5503
5505
|
pinLabel?: string;
|
|
5504
5506
|
/** The close button's accessible name (default `Close`). */
|
|
@@ -5521,7 +5523,7 @@ interface PinnablePopoverSurfaceProps {
|
|
|
5521
5523
|
* what `onChange` reports. Use `PopoverDialogSurface` for a dialog that only
|
|
5522
5524
|
* ever light-dismisses.
|
|
5523
5525
|
*/
|
|
5524
|
-
declare function PinnablePopoverSurface({ id, label, describedBy, children, headerActions, presentation, pinned, size, preferredWidth, height, maxHeight, viewportGutter, bodyLayout, pinLabel, closeLabel, moveDescription, rootAttributes, className, slot, }: PinnablePopoverSurfaceProps): kerfjs.SafeHtml;
|
|
5526
|
+
declare function PinnablePopoverSurface({ id, label, describedBy, children, headerActions, presentation, pinned, size, preferredWidth, height, maxHeight, viewportGutter, bodyLayout, resizeFromBottom, pinLabel, closeLabel, moveDescription, rootAttributes, className, slot, }: PinnablePopoverSurfaceProps): kerfjs.SafeHtml;
|
|
5525
5527
|
|
|
5526
5528
|
type PopupSurfaceInset = 'none' | 'compact' | 'default' | /** @deprecated Use default. */ 'standard' | /** @deprecated Use none. */ 'list-zero';
|
|
5527
5529
|
interface PopupSurfaceProps {
|
|
@@ -6131,8 +6133,8 @@ export { FramedList, type FramedListProps, FramedListRow, type FramedListRowProp
|
|
|
6131
6133
|
```ts
|
|
6132
6134
|
import * as kerfjs from 'kerfjs';
|
|
6133
6135
|
import { R as RootDataAttributes } from './extension-attributes-IJ4decoa.js';
|
|
6134
|
-
import { T as TreeListNode } from './tree-rows-
|
|
6135
|
-
export { a as TreeListRow, i as isExpandable, m as moveTreeListNode, t as treeListPath, b as treeListRows } from './tree-rows-
|
|
6136
|
+
import { T as TreeListNode } from './tree-rows-Bms5QJvG.js';
|
|
6137
|
+
export { a as TreeListRow, i as isExpandable, m as moveTreeListNode, t as treeListPath, b as treeListRows } from './tree-rows-Bms5QJvG.js';
|
|
6136
6138
|
import './semantic-content-BbzjvSu9.js';
|
|
6137
6139
|
|
|
6138
6140
|
interface TreeListProps {
|
|
@@ -6179,7 +6181,7 @@ export { TreeList, TreeListNode, type TreeListProps };
|
|
|
6179
6181
|
import { SafeHtml } from 'kerfjs';
|
|
6180
6182
|
import { R as RootDataAttributes } from './extension-attributes-IJ4decoa.js';
|
|
6181
6183
|
import { CssLength } from './css-values.js';
|
|
6182
|
-
import { T as TreeListNode } from './tree-rows-
|
|
6184
|
+
import { T as TreeListNode } from './tree-rows-Bms5QJvG.js';
|
|
6183
6185
|
import './semantic-content-BbzjvSu9.js';
|
|
6184
6186
|
|
|
6185
6187
|
/** One column: the children of the node chosen in the column before it. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Web Awesome JSX signatures for the UI authoring corpus
|
|
2
2
|
|
|
3
|
-
Generated from the emitted `@kerfjs/ui@5.0.0-beta.
|
|
3
|
+
Generated from the emitted `@kerfjs/ui@5.0.0-beta.127` declaration boundary. Import `@kerfjs/ui/webawesome` for type effects when authoring direct `wa-*` JSX. The module emits no runtime behavior and does not register custom elements.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { KerfCustomElement } from 'kerfjs/jsx-runtime';
|
package/dist/browser/editor.js
CHANGED
|
@@ -13,6 +13,7 @@ import '../styles/disclosure-arrow.css';
|
|
|
13
13
|
import '../styles/text.css';
|
|
14
14
|
import '../styles/list-header.css';
|
|
15
15
|
import '../styles/list-item.css';
|
|
16
|
+
import '../styles/tree-list.css';
|
|
16
17
|
import '../styles/value-table.css';
|
|
17
18
|
import '../styles/empty-state.css';
|
|
18
19
|
import '../styles/state-banner.css';
|
|
@@ -36,10 +37,11 @@ import '../styles/row.css';
|
|
|
36
37
|
import '../styles/grid.css';
|
|
37
38
|
import '../styles/checkbox.css';
|
|
38
39
|
import '../styles/checkbox-group.css';
|
|
40
|
+
import '../styles/column-track.css';
|
|
41
|
+
import '../styles/column-explorer.css';
|
|
39
42
|
import '../styles/segmented-control.css';
|
|
40
43
|
import '../styles/backdrop-image.css';
|
|
41
44
|
import '../styles/content-item.css';
|
|
42
|
-
import '../styles/tree-list.css';
|
|
43
45
|
import '../styles/summary-row.css';
|
|
44
46
|
import '../styles/anchored-surface.css';
|
|
45
47
|
import '../styles/color-swatches.css';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/collections/tree-list/model/tree-rows.ts"],"names":[],"mappings":";AAiDO,SAAS,aAAa,IAAA,EAA6B;AACxD,EAAA,OAAO,IAAA,CAAK,QAAA,KAAa,MAAA,IAAa,IAAA,CAAK,WAAA,KAAgB,IAAA;AAC7D;AAMO,SAAS,YAAA,CACd,OACA,QAAA,EACe;AACf,EAAA,MAAM,OAAO,QAAA,YAAoB,GAAA,GAAM,QAAA,GAA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AC,GAAI,IAAA,CAAK,QAAA,IAAY,EAAC,EAAI,KAAM,GAAG,CAAA;AAAA;AACrE,IACF;AACA,IAAA,OAAO,IAAA,CAAK,QAAA,GACR,CAAC,EAAE,GAAG,IAAA,EAAM,QAAA,EAAU,KAAA,CAAM,IAAA,CAAK,QAAQ,CAAA,EAAG,CAAA,GAC5C,CAAC,IAAI,CAAA;AAAA,EACX,CAAC,CAAA;AACH,EAAA,OAAO,MAAM,IAAI,CAAA;AACnB","file":"chunk-7U65KLDL.js","sourcesContent":["// KF-ECR4XG: the visible rows of a hierarchy. TreeList renders them, and a\n// column explorer can walk the same nodes, so the model stays DOM-free.\nimport type { SafeHtml } from 'kerfjs';\n\nimport type { KerfUiContent } from '../../../../shared/content/semantic-content.js';\nimport type { RootDataAttributes } from '../../../../shared/dom/extension-attributes.js';\n\n/** One node of a hierarchy the application owns. */\nexport interface TreeListNode {\n /** Stable id: the row's `data-item-id` and its key across re-renders. */\n readonly id: string;\n readonly label: string | SafeHtml;\n readonly description?: string | SafeHtml;\n /** A leading icon, normally an unsized LucideIcon. */\n readonly icon?: SafeHtml;\n /** Trailing content, such as a count Badge. */\n readonly trailing?: KerfUiContent;\n readonly disabled?: boolean;\n /** Drags with `wireTreeList`'s `onMove` (KF-WXP6AB). */\n readonly draggable?: boolean;\n /** Safe data attributes carried by this row in either tree presentation. */\n readonly rootAttributes?: RootDataAttributes;\n /** Child nodes. An empty array is an expandable node with no children yet. */\n readonly children?: readonly TreeListNode[];\n /**\n * Marks a node expandable before its children are loaded. The application\n * loads them when its `toggleAction` handler expands the node.\n */\n readonly hasChildren?: boolean;\n}\n\n/** One visible row: a node with its place in the hierarchy. */\nexport interface TreeListRow {\n readonly node: TreeListNode;\n /** 1 for a top-level node. */\n readonly level: number;\n /** 1-based position among its siblings. */\n readonly position: number;\n /** How many siblings it has, itself included. */\n readonly setSize: number;\n /** The parent's id, or undefined at the top level. */\n readonly parentId?: string;\n /** Whether the node can expand: it has children or `hasChildren`. */\n readonly expandable: boolean;\n /** Whether it is expanded (always false when not expandable). */\n readonly expanded: boolean;\n}\n\n/** Whether a node can expand: it has a children array or `hasChildren`. */\nexport function isExpandable(node: TreeListNode): boolean {\n return node.children !== undefined || node.hasChildren === true;\n}\n\n/**\n * The rows a tree shows: every top-level node, and the children of each\n * expanded node, depth first in order.\n */\nexport function treeListRows(\n nodes: readonly TreeListNode[],\n expanded: ReadonlySet<string> | readonly string[],\n): TreeListRow[] {\n const open = expanded instanceof Set ? expanded : new Set(expanded);\n const rows: TreeListRow[] = [];\n const visit = (\n siblings: readonly TreeListNode[],\n level: number,\n parentId: string | undefined,\n ) => {\n siblings.forEach((node, index) => {\n const expandable = isExpandable(node);\n const isOpen = expandable && open.has(node.id);\n rows.push({\n node,\n level,\n position: index + 1,\n setSize: siblings.length,\n ...(parentId === undefined ? {} : { parentId }),\n expandable,\n expanded: isOpen,\n });\n if (isOpen && node.children) visit(node.children, level + 1, node.id);\n });\n };\n visit(nodes, 1, undefined);\n return rows;\n}\n\n/** The ids on the path from the top level down to `id`, or [] when absent. */\nexport function treeListPath(\n nodes: readonly TreeListNode[],\n id: string,\n): string[] {\n for (const node of nodes) {\n if (node.id === id) return [id];\n const below = node.children ? treeListPath(node.children, id) : [];\n if (below.length) return [node.id, ...below];\n }\n return [];\n}\n\n/**\n * `nodes` with node `sourceId` moved before or after node `target.id`, or\n * appended inside it (KF-WXP6AB): the change `wireTreeList`'s `onMove`\n * reports, applied to a plain node tree. Returns a new tree; an unknown\n * node, a move onto itself, or a move into its own subtree leaves the tree\n * as it is.\n */\nexport function moveTreeListNode(\n nodes: readonly TreeListNode[],\n move: {\n readonly sourceId: string;\n readonly target: {\n readonly id: string;\n readonly position: 'before' | 'after' | 'inside';\n };\n },\n): TreeListNode[] {\n const { sourceId, target } = move;\n const path = treeListPath(nodes, target.id);\n if (!path.length || path.includes(sourceId)) return [...nodes];\n let moved: TreeListNode | undefined;\n const without = (list: readonly TreeListNode[]): TreeListNode[] =>\n list.flatMap((node) => {\n if (node.id === sourceId) {\n moved = node;\n return [];\n }\n return node.children\n ? [{ ...node, children: without(node.children) }]\n : [node];\n });\n const rest = without(nodes);\n if (!moved) return [...nodes];\n const place = (list: readonly TreeListNode[]): TreeListNode[] =>\n list.flatMap((node) => {\n if (node.id === target.id) {\n switch (target.position) {\n case 'before':\n return [moved!, node];\n case 'after':\n return [node, moved!];\n case 'inside':\n return [{ ...node, children: [...(node.children ?? []), moved!] }];\n }\n }\n return node.children\n ? [{ ...node, children: place(node.children) }]\n : [node];\n });\n return place(rest);\n}\n"]}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { isExpandable } from './chunk-7U65KLDL.js';
|
|
2
|
+
import { ColumnTrack } from './chunk-34FWYJX6.js';
|
|
3
|
+
import { ListItem } from './chunk-4UWLHKNU.js';
|
|
4
|
+
import { List } from './chunk-WVQDIOD7.js';
|
|
5
|
+
import { LucideIcon } from './chunk-CMG4OZPV.js';
|
|
6
|
+
import { filterDataAttributes } from './chunk-COQI4OMZ.js';
|
|
7
|
+
import { ChevronRight } from 'lucide';
|
|
8
|
+
import { jsx, jsxs, Fragment } from 'kerfjs/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
// src/components/collections/column-explorer/model/columns.ts
|
|
11
|
+
function explorerColumns(nodes, path) {
|
|
12
|
+
const columns = [];
|
|
13
|
+
let siblings = nodes;
|
|
14
|
+
let parent;
|
|
15
|
+
for (let level = 0; ; level += 1) {
|
|
16
|
+
const chosen = siblings.find((node) => node.id === path[level]);
|
|
17
|
+
columns.push({
|
|
18
|
+
level,
|
|
19
|
+
...parent ? { parent } : {},
|
|
20
|
+
nodes: siblings,
|
|
21
|
+
...chosen ? { chosen: chosen.id } : {}
|
|
22
|
+
});
|
|
23
|
+
if (!chosen || !isExpandable(chosen)) return columns;
|
|
24
|
+
parent = chosen;
|
|
25
|
+
siblings = chosen.children ?? [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function explorerChosen(nodes, path) {
|
|
29
|
+
let siblings = nodes;
|
|
30
|
+
let node;
|
|
31
|
+
for (const id of path) {
|
|
32
|
+
node = siblings.find((candidate) => candidate.id === id);
|
|
33
|
+
if (!node) return void 0;
|
|
34
|
+
siblings = node.children ?? [];
|
|
35
|
+
}
|
|
36
|
+
return node;
|
|
37
|
+
}
|
|
38
|
+
var COLUMN_EXPLORER_PROTECTED = /* @__PURE__ */ new Set([
|
|
39
|
+
"data-component",
|
|
40
|
+
"data-column-explorer-id"
|
|
41
|
+
]);
|
|
42
|
+
var chevron = LucideIcon({ icon: ChevronRight, name: "chevron-right" });
|
|
43
|
+
function ColumnExplorer({
|
|
44
|
+
id,
|
|
45
|
+
label,
|
|
46
|
+
nodes,
|
|
47
|
+
path,
|
|
48
|
+
action,
|
|
49
|
+
preview,
|
|
50
|
+
layout,
|
|
51
|
+
minColumnWidth,
|
|
52
|
+
peek,
|
|
53
|
+
density = "default",
|
|
54
|
+
className = "",
|
|
55
|
+
rootAttributes = {},
|
|
56
|
+
slot
|
|
57
|
+
}) {
|
|
58
|
+
const columns = explorerColumns(nodes, path);
|
|
59
|
+
const chosen = explorerChosen(nodes, path);
|
|
60
|
+
const showPreview = preview !== void 0 && chosen !== void 0 && !isExpandable(chosen);
|
|
61
|
+
return /* @__PURE__ */ jsx(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
...filterDataAttributes(rootAttributes, COLUMN_EXPLORER_PROTECTED),
|
|
65
|
+
id,
|
|
66
|
+
role: "region",
|
|
67
|
+
class: `kui-column-explorer ${className}`.trim(),
|
|
68
|
+
"aria-label": label,
|
|
69
|
+
"data-component": "column-explorer",
|
|
70
|
+
"data-column-explorer-id": id,
|
|
71
|
+
slot,
|
|
72
|
+
children: /* @__PURE__ */ jsxs(ColumnTrack, { layout, minColumnWidth, peek, children: [
|
|
73
|
+
columns.map((column) => {
|
|
74
|
+
const stop = column.chosen ?? column.nodes[0]?.id;
|
|
75
|
+
return /* @__PURE__ */ jsx(
|
|
76
|
+
List,
|
|
77
|
+
{
|
|
78
|
+
scrollable: true,
|
|
79
|
+
fill: true,
|
|
80
|
+
rootAttributes: {
|
|
81
|
+
role: "group",
|
|
82
|
+
"aria-label": column.parent ? String(column.parent.label) : label,
|
|
83
|
+
"data-column-explorer-level": String(column.level)
|
|
84
|
+
},
|
|
85
|
+
children: column.nodes.map((node) => /* @__PURE__ */ jsx(
|
|
86
|
+
ListItem,
|
|
87
|
+
{
|
|
88
|
+
action,
|
|
89
|
+
itemId: node.id,
|
|
90
|
+
label: node.label,
|
|
91
|
+
description: node.description,
|
|
92
|
+
icon: node.icon,
|
|
93
|
+
trailing: isExpandable(node) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
94
|
+
node.trailing,
|
|
95
|
+
chevron
|
|
96
|
+
] }) : node.trailing,
|
|
97
|
+
selected: node.id === column.chosen,
|
|
98
|
+
disabled: node.disabled,
|
|
99
|
+
draggable: node.draggable,
|
|
100
|
+
density,
|
|
101
|
+
tabIndex: node.id === stop ? 0 : -1,
|
|
102
|
+
rootAttributes: {
|
|
103
|
+
...node.rootAttributes,
|
|
104
|
+
"data-key": node.id,
|
|
105
|
+
"data-column-explorer-level": String(column.level),
|
|
106
|
+
"data-expandable": isExpandable(node) ? "true" : void 0
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
))
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
}),
|
|
113
|
+
showPreview ? /* @__PURE__ */ jsx(
|
|
114
|
+
List,
|
|
115
|
+
{
|
|
116
|
+
scrollable: true,
|
|
117
|
+
fill: true,
|
|
118
|
+
rootAttributes: {
|
|
119
|
+
role: "group",
|
|
120
|
+
"aria-label": `${String(chosen.label)} preview`,
|
|
121
|
+
"data-column-explorer-preview": "true"
|
|
122
|
+
},
|
|
123
|
+
children: preview
|
|
124
|
+
}
|
|
125
|
+
) : null
|
|
126
|
+
] })
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { ColumnExplorer, explorerChosen, explorerColumns };
|
|
132
|
+
|
|
133
|
+
//# sourceMappingURL=chunk-BMOZSNDU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/collections/column-explorer/model/columns.ts","../src/components/collections/column-explorer/column-explorer.tsx"],"names":[],"mappings":";;;;;;;;;;AAuBO,SAAS,eAAA,CACd,OACA,IAAA,EACkB;AAClB,EAAA,MAAM,UAA4B,EAAC;AACnC,EAAA,IAAI,QAAA,GAAoC,KAAA;AACxC,EAAA,IAAI,MAAA;AACJ,EAAA,KAAA,IAAS,KAAA,GAAQ,CAAA,IAAK,KAAA,IAAS,CAAA,EAAG;AAChC,IAAA,MAAM,MAAA,GAAS,SAAS,IAAA,CAAK,CAAC,SAAS,IAAA,CAAK,EAAA,KAAO,IAAA,CAAK,KAAK,CAAC,CAAA;AAC9D,IAAA,OAAA,CAAQ,IAAA,CAAK;AAAA,MACX,KAAA;AAAA,MACA,GAAI,MAAA,GAAS,EAAE,MAAA,KAAW,EAAC;AAAA,MAC3B,KAAA,EAAO,QAAA;AAAA,MACP,GAAI,MAAA,GAAS,EAAE,QAAQ,MAAA,CAAO,EAAA,KAAO;AAAC,KACvC,CAAA;AACD,IAAA,IAAI,CAAC,MAAA,IAAU,CAAC,YAAA,CAAa,MAAM,GAAG,OAAO,OAAA;AAC7C,IAAA,MAAA,GAAS,MAAA;AACT,IAAA,QAAA,GAAW,MAAA,CAAO,YAAY,EAAC;AAAA,EACjC;AACF;AAGO,SAAS,cAAA,CACd,OACA,IAAA,EAC0B;AAC1B,EAAA,IAAI,QAAA,GAAoC,KAAA;AACxC,EAAA,IAAI,IAAA;AACJ,EAAA,KAAA,MAAW,MAAM,IAAA,EAAM;AACrB,IAAA,IAAA,GAAO,SAAS,IAAA,CAAK,CAAC,SAAA,KAAc,SAAA,CAAU,OAAO,EAAE,CAAA;AACvD,IAAA,IAAI,CAAC,MAAM,OAAO,MAAA;AAClB,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G,IAAA,CAAK,cAAA;AAAA,oBACR,YAAY,IAAA,CAAK,EAAA;AAAA,oBACjB,4BAAA,EAA8B,MAAA,CAAO,MAAA,CAAO,KAAK,CAAA;AAAA,oBACjD,iBAAA,EAAmB,YAAA,CAAa,IAAI,CAAA,GAAI,MAAA,GAAS;AAAA;AACnD;AAAA,eAEH;AAAA;AAAA,WACH;AAAA,QAEJ,CAAC,CAAA;AAAA,QACA,WAAA,mBACC,GAAA;AAAA,UAAC,IAAA;AAAA,UAAA;AAAA,YACC,UAAA,EAAU,IAAA;AAAA,YACV,IAAA,EAAI,IAAA;AAAA,YACJ,cAAA,EAAgB;AAAA,cACd,IAAA,EAAM,OAAA;AAAA,cACN,YAAA,EAAc,CAAA,EAAG,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA,QAAA,CAAA;AAAA,cACrC,8BAAA,EAAgC;AAAA,aAClC;AAAA,YAEC,QAAA,EAAA;AAAA;AAAA,SACH,GACE;AAAA,OAAA,EACN;AAAA;AAAA,GACF;AAEJ","file":"chunk-BMOZSNDU.js","sourcesContent":["// KF-JY68DQ: the columns a column explorer shows for a chosen path through a\n// hierarchy. It walks the same TreeListNode model as TreeList, DOM-free.\nimport {\n isExpandable,\n type TreeListNode,\n} from '../../tree-list/model/tree-rows.js';\n\n/** One column: the children of the node chosen in the column before it. */\nexport interface ExplorerColumn {\n /** 0 for the top level. */\n readonly level: number;\n /** The node whose children this column lists, or undefined at the top. */\n readonly parent?: TreeListNode;\n readonly nodes: readonly TreeListNode[];\n /** The id chosen in this column, when the path reaches it. */\n readonly chosen?: string;\n}\n\n/**\n * The columns for `path` (ids from the top level down): the top level, then\n * the children of each chosen node that can expand. A path id that is not a\n * child of the column before it ends the walk there.\n */\nexport function explorerColumns(\n nodes: readonly TreeListNode[],\n path: readonly string[],\n): ExplorerColumn[] {\n const columns: ExplorerColumn[] = [];\n let siblings: readonly TreeListNode[] = nodes;\n let parent: TreeListNode | undefined;\n for (let level = 0; ; level += 1) {\n const chosen = siblings.find((node) => node.id === path[level]);\n columns.push({\n level,\n ...(parent ? { parent } : {}),\n nodes: siblings,\n ...(chosen ? { chosen: chosen.id } : {}),\n });\n if (!chosen || !isExpandable(chosen)) return columns;\n parent = chosen;\n siblings = chosen.children ?? [];\n }\n}\n\n/** The node at the end of `path`, when the whole path resolves. */\nexport function explorerChosen(\n nodes: readonly TreeListNode[],\n path: readonly string[],\n): TreeListNode | undefined {\n let siblings: readonly TreeListNode[] = nodes;\n let node: TreeListNode | undefined;\n for (const id of path) {\n node = siblings.find((candidate) => candidate.id === id);\n if (!node) return undefined;\n siblings = node.children ?? [];\n }\n return node;\n}\n","import type { SafeHtml } from 'kerfjs';\nimport { ChevronRight } from 'lucide';\n\nimport {\n filterDataAttributes,\n type RootDataAttributes,\n} from '../../../shared/dom/extension-attributes.js';\nimport type { CssLength } from '../../../shared/styles/css-values.js';\nimport { ColumnTrack } from '../../layout/column-track/column-track.js';\nimport { LucideIcon } from '../../media/lucide-icon/lucide-icon.js';\nimport { List } from '../list/list.js';\nimport { ListItem } from '../list-item/list-item.js';\nimport {\n isExpandable,\n type TreeListNode,\n} from '../tree-list/model/tree-rows.js';\nimport { explorerChosen, explorerColumns } from './model/columns.js';\n\nexport {\n explorerChosen,\n type ExplorerColumn,\n explorerColumns,\n} from './model/columns.js';\n\nconst COLUMN_EXPLORER_PROTECTED = new Set([\n 'data-component',\n 'data-column-explorer-id',\n]);\n\nexport interface ColumnExplorerProps {\n /** Identifies the explorer for `wireColumnExplorer` and in tests. */\n id: string;\n /** The explorer's accessible name, such as \"Files\". */\n label: string;\n /** The hierarchy, as TreeList's nodes. The application owns it. */\n nodes: readonly TreeListNode[];\n /**\n * The chosen ids from the top level down, one per column. The application\n * owns it: set it to `treeListPath(nodes, id)` when `action` reports a row.\n */\n path: readonly string[];\n /** Delegated action for choosing a row; the row's `data-item-id` names it. */\n action: string;\n /**\n * Content for a last column when the chosen node is a leaf, such as a\n * file's details.\n */\n preview?: SafeHtml;\n /** ColumnTrack's layout: `scroll` (default) or `paged` for a phone. */\n layout?: 'scroll' | 'paged';\n /** Each column's minimum width (ColumnTrack's default 250px). */\n minColumnWidth?: CssLength;\n /** How much of the next column a paged layout shows. */\n peek?: CssLength;\n /** Row density: `default` or `compact`. */\n density?: 'default' | 'compact' | /** @deprecated Use default. */ 'standard';\n className?: string;\n /** Safe `data-*` metadata for the explorer element. */\n rootAttributes?: RootDataAttributes;\n /** Native named-slot assignment when composed inside a web component. */\n slot?: string;\n}\n\nconst chevron = LucideIcon({ icon: ChevronRight, name: 'chevron-right' });\n\n/**\n * A macOS-style column explorer for a hierarchy: one column per level in a\n * ColumnTrack, where choosing a row with children opens the next column of\n * its children. The application owns the nodes and the chosen path and\n * handles `action`; wire the keyboard with `wireColumnExplorer`.\n */\nexport function ColumnExplorer({\n id,\n label,\n nodes,\n path,\n action,\n preview,\n layout,\n minColumnWidth,\n peek,\n density = 'default',\n className = '',\n rootAttributes = {},\n slot,\n}: ColumnExplorerProps) {\n const columns = explorerColumns(nodes, path);\n const chosen = explorerChosen(nodes, path);\n const showPreview =\n preview !== undefined && chosen !== undefined && !isExpandable(chosen);\n return (\n <div\n {...filterDataAttributes(rootAttributes, COLUMN_EXPLORER_PROTECTED)}\n id={id}\n role=\"region\"\n class={`kui-column-explorer ${className}`.trim()}\n aria-label={label}\n data-component=\"column-explorer\"\n data-column-explorer-id={id}\n slot={slot}\n >\n <ColumnTrack layout={layout} minColumnWidth={minColumnWidth} peek={peek}>\n {columns.map((column) => {\n // One Tab stop per column: its chosen row, else its first.\n const stop = column.chosen ?? column.nodes[0]?.id;\n return (\n <List\n scrollable\n fill\n rootAttributes={{\n role: 'group',\n 'aria-label': column.parent\n ? String(column.parent.label)\n : label,\n 'data-column-explorer-level': String(column.level),\n }}\n >\n {column.nodes.map((node) => (\n <ListItem\n action={action}\n itemId={node.id}\n label={node.label}\n description={node.description}\n icon={node.icon}\n trailing={\n isExpandable(node) ? (\n <>\n {node.trailing}\n {chevron}\n </>\n ) : (\n node.trailing\n )\n }\n selected={node.id === column.chosen}\n disabled={node.disabled}\n draggable={node.draggable}\n density={density}\n tabIndex={node.id === stop ? 0 : -1}\n rootAttributes={{\n ...node.rootAttributes,\n 'data-key': node.id,\n 'data-column-explorer-level': String(column.level),\n 'data-expandable': isExpandable(node) ? 'true' : undefined,\n }}\n />\n ))}\n </List>\n );\n })}\n {showPreview ? (\n <List\n scrollable\n fill\n rootAttributes={{\n role: 'group',\n 'aria-label': `${String(chosen.label)} preview`,\n 'data-column-explorer-preview': 'true',\n }}\n >\n {preview}\n </List>\n ) : null}\n </ColumnTrack>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { delegate } from 'kerfjs';
|
|
2
|
+
|
|
3
|
+
// src/components/collections/column-explorer/wiring/wire-column-explorer.ts
|
|
4
|
+
var EXPLORER = '[data-component="column-explorer"]';
|
|
5
|
+
var ROW = `${EXPLORER} .kui-list-item[data-column-explorer-level]`;
|
|
6
|
+
var TYPEAHEAD_RESET_MS = 500;
|
|
7
|
+
var levelOf = (row) => Number(row.dataset.columnExplorerLevel);
|
|
8
|
+
function columnRows(from, level) {
|
|
9
|
+
return [
|
|
10
|
+
...from.closest(EXPLORER).querySelectorAll(
|
|
11
|
+
`.kui-list-item[data-column-explorer-level="${level}"]`
|
|
12
|
+
)
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
function focusRow(row) {
|
|
16
|
+
if (!row) return;
|
|
17
|
+
for (const other of columnRows(row, levelOf(row)))
|
|
18
|
+
other.tabIndex = other === row ? 0 : -1;
|
|
19
|
+
row.focus();
|
|
20
|
+
}
|
|
21
|
+
function stopOf(rows) {
|
|
22
|
+
return rows.find((row) => row.getAttribute("aria-current")) ?? rows[0];
|
|
23
|
+
}
|
|
24
|
+
function revealLastColumn(explorer) {
|
|
25
|
+
const track = explorer.querySelector(".kui-column-track");
|
|
26
|
+
track.scrollLeft = track.scrollWidth;
|
|
27
|
+
}
|
|
28
|
+
function wireColumnExplorer(root) {
|
|
29
|
+
let typed = "";
|
|
30
|
+
let typedAt = 0;
|
|
31
|
+
const view = root.ownerDocument.defaultView;
|
|
32
|
+
for (const explorer of root.querySelectorAll(EXPLORER))
|
|
33
|
+
revealLastColumn(explorer);
|
|
34
|
+
const stopChoose = delegate(root, "click", ROW, (_e, row) => {
|
|
35
|
+
const explorer = row.closest(EXPLORER);
|
|
36
|
+
view.requestAnimationFrame(() => revealLastColumn(explorer));
|
|
37
|
+
});
|
|
38
|
+
const stopKeys = delegate(root, "keydown", ROW, (event, row) => {
|
|
39
|
+
const key = event;
|
|
40
|
+
if (key.ctrlKey || key.metaKey || key.altKey) return;
|
|
41
|
+
const level = levelOf(row);
|
|
42
|
+
const rows = columnRows(row, level);
|
|
43
|
+
const index = rows.indexOf(row);
|
|
44
|
+
let handled = true;
|
|
45
|
+
switch (key.key) {
|
|
46
|
+
case "ArrowDown":
|
|
47
|
+
focusRow(rows[index + 1]);
|
|
48
|
+
break;
|
|
49
|
+
case "ArrowUp":
|
|
50
|
+
focusRow(rows[index - 1]);
|
|
51
|
+
break;
|
|
52
|
+
case "Home":
|
|
53
|
+
focusRow(rows[0]);
|
|
54
|
+
break;
|
|
55
|
+
case "End":
|
|
56
|
+
focusRow(rows.at(-1));
|
|
57
|
+
break;
|
|
58
|
+
case "ArrowRight":
|
|
59
|
+
if (row.dataset.expandable && row.dataset.action) {
|
|
60
|
+
if (!row.getAttribute("aria-current")) row.click();
|
|
61
|
+
focusRow(stopOf(columnRows(row, level + 1)));
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case "ArrowLeft":
|
|
65
|
+
focusRow(stopOf(columnRows(row, level - 1)));
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
handled = typeahead(key, rows, index);
|
|
69
|
+
}
|
|
70
|
+
if (handled) key.preventDefault();
|
|
71
|
+
});
|
|
72
|
+
function typeahead(key, rows, index) {
|
|
73
|
+
if (key.key.length !== 1 || key.key === " ") return false;
|
|
74
|
+
const now = Date.now();
|
|
75
|
+
typed = now - typedAt > TYPEAHEAD_RESET_MS ? key.key.toLowerCase() : typed + key.key.toLowerCase();
|
|
76
|
+
typedAt = now;
|
|
77
|
+
const start = typed.length === 1 ? index + 1 : index;
|
|
78
|
+
const ordered = [...rows.slice(start), ...rows.slice(0, start)];
|
|
79
|
+
focusRow(
|
|
80
|
+
ordered.find(
|
|
81
|
+
(candidate) => (candidate.querySelector(".kui-list-item__primary-label")?.textContent ?? "").trim().toLowerCase().startsWith(typed)
|
|
82
|
+
)
|
|
83
|
+
);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
return () => {
|
|
87
|
+
stopChoose();
|
|
88
|
+
stopKeys();
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { wireColumnExplorer };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=chunk-GHV36C6I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/collections/column-explorer/wiring/wire-column-explorer.ts"],"names":[],"mappings":";;;AAKA,IAAM,QAAA,GAAW,oCAAA;AACjB,IAAM,GAAA,GAAM,GAAG,QAAQ,CAAA,2CAAA,CAAA;AACvB,IAAM,kBAAA,GAAqB,GAAA;AAE3B,IAAM,UAAU,CAAC,GAAA,KAAqB,MAAA,CAAO,GAAA,CAAI,QAAQ,mBAAmB,CAAA;AAG5E,SAAS,UAAA,CAAW,MAAmB,KAAA,EAA8B;AACnE,EAAA,OAAO;AAAA,IACL,GAAG,IAAA,CACA,OAAA,CAAQ,QAAQ,CAAA,CAChB,gBAAA;AAAA,MACC,8CAA8C,KAAK,CAAA,EAAA;AAAA;AACrD,GACJ;AACF;AAGA,SAAS,SAAS,GAAA,EAA8B;AAC9C,EAAA,IAAI,CAAC,GAAA,EAAK;AACV,EAAA,KAAA,MAAW,KAAA,IAAS,UAAA,CAAW,GAAA,EAAK,OAAA,CAAQ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S,SAAA,CACP,GAAA,EACA,IAAA,EACA,KAAA,EACS;AACT,IAAA,IAAI,IAAI,GAAA,CAAI,MAAA,KAAW,KAAK,GAAA,CAAI,GAAA,KAAQ,KAAK,OAAO,KAAA;AACpD,IAAA,MAAM,GAAA,GAAM,KAAK,GAAA,EAAI;AACrB,IAAA,KAAA,GACE,GAAA,GAAM,OAAA,GAAU,kBAAA,GACZ,GAAA,CAAI,GAAA,CAAI,aAAY,GACpB,KAAA,GAAQ,GAAA,CAAI,GAAA,CAAI,WAAA,EAAY;AAClC,IAAA,OAAA,GAAU,GAAA;AACV,IAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,MAAA,KAAW,CAAA,GAAI,QAAQ,CAAA,GAAI,KAAA;AAC/C,IAAA,MAAM,OAAA,GAAU,CAAC,GAAG,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA,EAAG,GAAG,IAAA,CAAK,KAAA,CAAM,CAAA,EAAG,KAAK,CAAC,CAAA;AAC9D,IAAA,QAAA;AAAA,MACE,OAAA,CAAQ,IAAA;AAAA,QAAK,CAAC,SAAA,KAAA,CAEV,SAAA,CAAU,aAAA,CAAc,+BAA+B,CAAA,EACnD,WAAA,IAAe,EAAA,EAElB,IAAA,EAAK,CACL,WAAA,EAAY,CACZ,WAAW,KAAK;AAAA;AACrB,KACF;AACA,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,MAAM;AACX,IAAA,UAAA,EAAW;AACX,IAAA,QAAA,EAAS;AAAA,EACX,CAAA;AACF","file":"chunk-GHV36C6I.js","sourcesContent":["// KF-JY68DQ: keyboard navigation for ColumnExplorer, and bringing a newly\n// opened column into view. Choosing a row clicks it, so the application's\n// `action` handler stays the one owner of the chosen path.\nimport { delegate } from 'kerfjs';\n\nconst EXPLORER = '[data-component=\"column-explorer\"]';\nconst ROW = `${EXPLORER} .kui-list-item[data-column-explorer-level]`;\nconst TYPEAHEAD_RESET_MS = 500;\n\nconst levelOf = (row: HTMLElement) => Number(row.dataset.columnExplorerLevel);\n\n/** The rows of one column of the explorer that holds `from`. */\nfunction columnRows(from: HTMLElement, level: number): HTMLElement[] {\n return [\n ...from\n .closest(EXPLORER)!\n .querySelectorAll<HTMLElement>(\n `.kui-list-item[data-column-explorer-level=\"${level}\"]`,\n ),\n ];\n}\n\n/** Moves a column's single Tab stop to `row` and focuses it. */\nfunction focusRow(row: HTMLElement | undefined) {\n if (!row) return;\n for (const other of columnRows(row, levelOf(row)))\n other.tabIndex = other === row ? 0 : -1;\n row.focus();\n}\n\n/** The column's chosen row, or its first. */\nfunction stopOf(rows: HTMLElement[]) {\n return rows.find((row) => row.getAttribute('aria-current')) ?? rows[0];\n}\n\n/**\n * Brings the explorer's last column into view by scrolling its track to the\n * end (a paged track snaps there). Only the track scrolls, never the page.\n */\nfunction revealLastColumn(explorer: Element) {\n const track = explorer.querySelector<HTMLElement>('.kui-column-track')!;\n track.scrollLeft = track.scrollWidth;\n}\n\n/**\n * Wires every ColumnExplorer under `root`:\n * - Down and Up move within a column; Home and End go to its first and last.\n * - Right opens the focused row's column (choosing it) and moves into it;\n * Left returns to the chosen row of the column before.\n * - Enter and Space choose the row (its native button click sends `action`).\n * - Typing letters moves to the next row in the column that starts with them.\n * The deepest column starts in view, and choosing a row brings the column it\n * opens into view. Returns a disposer.\n */\nexport function wireColumnExplorer(root: HTMLElement): () => void {\n let typed = '';\n let typedAt = 0;\n const view = root.ownerDocument.defaultView!;\n for (const explorer of root.querySelectorAll(EXPLORER))\n revealLastColumn(explorer);\n\n const stopChoose = delegate<HTMLElement>(root, 'click', ROW, (_e, row) => {\n const explorer = row.closest(EXPLORER)!;\n view.requestAnimationFrame(() => revealLastColumn(explorer));\n });\n\n const stopKeys = delegate<HTMLElement>(root, 'keydown', ROW, (event, row) => {\n const key = event as KeyboardEvent;\n if (key.ctrlKey || key.metaKey || key.altKey) return;\n const level = levelOf(row);\n const rows = columnRows(row, level);\n const index = rows.indexOf(row);\n let handled = true;\n switch (key.key) {\n case 'ArrowDown':\n focusRow(rows[index + 1]);\n break;\n case 'ArrowUp':\n focusRow(rows[index - 1]);\n break;\n case 'Home':\n focusRow(rows[0]);\n break;\n case 'End':\n focusRow(rows.at(-1));\n break;\n case 'ArrowRight':\n if (row.dataset.expandable && row.dataset.action) {\n if (!row.getAttribute('aria-current')) row.click();\n focusRow(stopOf(columnRows(row, level + 1)));\n }\n break;\n case 'ArrowLeft':\n focusRow(stopOf(columnRows(row, level - 1)));\n break;\n default:\n handled = typeahead(key, rows, index);\n }\n if (handled) key.preventDefault();\n });\n\n function typeahead(\n key: KeyboardEvent,\n rows: HTMLElement[],\n index: number,\n ): boolean {\n if (key.key.length !== 1 || key.key === ' ') return false;\n const now = Date.now();\n typed =\n now - typedAt > TYPEAHEAD_RESET_MS\n ? key.key.toLowerCase()\n : typed + key.key.toLowerCase();\n typedAt = now;\n const start = typed.length === 1 ? index + 1 : index;\n const ordered = [...rows.slice(start), ...rows.slice(0, start)];\n focusRow(\n ordered.find((candidate) =>\n (\n candidate.querySelector('.kui-list-item__primary-label')\n ?.textContent ?? ''\n )\n .trim()\n .toLowerCase()\n .startsWith(typed),\n ),\n );\n return true;\n }\n\n return () => {\n stopChoose();\n stopKeys();\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { treeListRows, treeListPath } from './chunk-
|
|
1
|
+
import { treeListRows, treeListPath } from './chunk-7U65KLDL.js';
|
|
2
2
|
import { DisclosureArrow } from './chunk-RPJOLDSR.js';
|
|
3
3
|
import { listItemContent } from './chunk-QR7MGGOM.js';
|
|
4
4
|
import { remify } from './chunk-IQSRHXZR.js';
|
|
@@ -20,6 +20,7 @@ function ListTreeItem({
|
|
|
20
20
|
focusable,
|
|
21
21
|
disabled = false,
|
|
22
22
|
draggable,
|
|
23
|
+
rootAttributes = {},
|
|
23
24
|
density,
|
|
24
25
|
action,
|
|
25
26
|
toggleAction
|
|
@@ -27,6 +28,10 @@ function ListTreeItem({
|
|
|
27
28
|
return /* @__PURE__ */ jsxs(
|
|
28
29
|
"button",
|
|
29
30
|
{
|
|
31
|
+
...filterDataAttributes(
|
|
32
|
+
rootAttributes,
|
|
33
|
+
/* @__PURE__ */ new Set(["data-component", "data-key", "data-action", "data-item-id"])
|
|
34
|
+
),
|
|
30
35
|
type: "button",
|
|
31
36
|
role: "treeitem",
|
|
32
37
|
class: "kui-list-item",
|
|
@@ -109,6 +114,7 @@ function TreeList({
|
|
|
109
114
|
focusable: row.node.id === focusId,
|
|
110
115
|
disabled: row.node.disabled,
|
|
111
116
|
draggable: row.node.draggable,
|
|
117
|
+
rootAttributes: row.node.rootAttributes,
|
|
112
118
|
density,
|
|
113
119
|
action,
|
|
114
120
|
toggleAction
|
|
@@ -120,4 +126,4 @@ function TreeList({
|
|
|
120
126
|
|
|
121
127
|
export { TreeList };
|
|
122
128
|
|
|
123
|
-
//# sourceMappingURL=chunk-
|
|
129
|
+
//# sourceMappingURL=chunk-GQUDCWOD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/collections/list-item/parts/tree-item.tsx","../src/components/collections/tree-list/tree-list.tsx"],"names":["jsx"],"mappings":";;;;;;;AA4CO,SAAS,YAAA,CAAa;AAAA,EAC3B,MAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA,GAAW,KAAA;AAAA,EACX,SAAA;AAAA,EACA,iBAAiB,EAAC;AAAA,EAClB,OAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA,EAAsB;AACpB,EAAA,uBACE,IAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACE,GAAG,oBAAA;AAAA,QACF,cAAA;AAAA,4BACI,GAAA,CAAI,CAAC,kBAAkB,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A,EAAK,MAAA;AAAA,MACL,KAAA,EAAO,CAAA,cAAA,EAAiB,SAAS,CAAA,CAAA,CAAG,IAAA,EAAK;AAAA,MACzC,YAAA,EAAY,KAAA;AAAA,MACZ,gBAAA,EAAe,WAAA;AAAA,MACf,mBAAA,EAAmB,EAAA;AAAA,MACnB,IAAA;AAAA,MAEC,QAAA,EAAA,IAAA,CAAK,GAAA,CAAI,CAAC,GAAA,qBACTA,GAAAA;AAAA,QAAC,YAAA;AAAA,QAAA;AAAA,UACC,MAAA,EAAQ,IAAI,IAAA,CAAK,EAAA;AAAA,UACjB,KAAA,EAAO,IAAI,IAAA,CAAK,KAAA;AAAA,UAChB,WAAA,EAAa,IAAI,IAAA,CAAK,WAAA;AAAA,UACtB,IAAA,EAAM,IAAI,IAAA,CAAK,IAAA;AAAA,UACf,QAAA,EAAU,IAAI,IAAA,CAAK,QAAA;AAAA,UACnB,OAAO,GAAA,CAAI,KAAA;AAAA,UACX,UAAU,GAAA,CAAI,QAAA;AAAA,UACd,SAAS,GAAA,CAAI,OAAA;AAAA,UACb,YAAY,GAAA,CAAI,UAAA;AAAA,UAChB,UAAU,GAAA,CAAI,QAAA;AAAA,UACd,QAAA,EAAU,GAAA,CAAI,IAAA,CAAK,EAAA,KAAO,QAAA;AAAA,UAC1B,SAAA,EAAW,GAAA,CAAI,IAAA,CAAK,EAAA,KAAO,OAAA;AAAA,UAC3B,QAAA,EAAU,IAAI,IAAA,CAAK,QAAA;AAAA,UACnB,SAAA,EAAW,IAAI,IAAA,CAAK,SAAA;AAAA,UACpB,cAAA,EAAgB,IAAI,IAAA,CAAK,cAAA;AAAA,UACzB,OAAA;AAAA,UACA,MAAA;AAAA,UACA;AAAA;AAAA,OAEH;AAAA;AAAA,GACH;AAEJ","file":"chunk-GQUDCWOD.js","sourcesContent":["// KF-ECR4XG: ListItem's treeitem form, the row TreeList renders. It is a\n// ListItem (same geometry, hover, selected tint) that also carries its tree\n// position, an indent for its level, and a disclosure arrow. Internal: the\n// `@kerfjs/ui/list-item` facade does not re-export it.\nimport type { SafeHtml } from 'kerfjs';\n\nimport type { KerfUiContent } from '../../../../shared/content/semantic-content.js';\nimport {\n filterDataAttributes,\n type RootDataAttributes,\n} from '../../../../shared/dom/extension-attributes.js';\nimport { remify } from '../../../../shared/styles/css-values.js';\nimport { DisclosureArrow } from '../../../navigation/disclosure-arrow/disclosure-arrow.js';\nimport { listItemContent } from '../internal/list-item-content.js';\n\nexport interface ListTreeItemProps {\n readonly itemId: string;\n readonly label: string | SafeHtml;\n readonly description?: string | SafeHtml;\n readonly icon?: SafeHtml;\n readonly trailing?: KerfUiContent;\n readonly level: number;\n readonly position: number;\n readonly setSize: number;\n readonly expandable: boolean;\n readonly expanded: boolean;\n readonly selected: boolean;\n /** The one row in the tree's Tab order (roving tabindex). */\n readonly focusable: boolean;\n readonly disabled?: boolean;\n /** A native drag source for TreeList drag-and-drop. */\n readonly draggable?: boolean;\n readonly rootAttributes?: RootDataAttributes;\n readonly density: 'default' | 'compact' | 'standard';\n /** Delegated action for choosing the row. */\n readonly action: string;\n /** Delegated action for its disclosure arrow. */\n readonly toggleAction: string;\n}\n\n/**\n * A `role=\"treeitem\"` ListItem. A disabled row stays focusable for keyboard\n * navigation (`aria-disabled`) but carries no actions.\n */\nexport function ListTreeItem({\n itemId,\n label,\n description,\n icon,\n trailing,\n level,\n position,\n setSize,\n expandable,\n expanded,\n selected,\n focusable,\n disabled = false,\n draggable,\n rootAttributes = {},\n density,\n action,\n toggleAction,\n}: ListTreeItemProps) {\n return (\n <button\n {...filterDataAttributes(\n rootAttributes,\n new Set(['data-component', 'data-key', 'data-action', 'data-item-id']),\n )}\n type=\"button\"\n role=\"treeitem\"\n class=\"kui-list-item\"\n style={`--_kui-list-item-tree-level:${level}`}\n tabindex={focusable ? 0 : -1}\n data-component=\"list-item\"\n data-key={itemId}\n data-action={disabled ? undefined : action}\n data-item-id={itemId}\n data-has-icon={String(Boolean(icon))}\n data-has-description={String(Boolean(description))}\n data-density={density === 'standard' ? 'default' : density}\n data-divider=\"none\"\n data-kui-disabled={disabled ? 'true' : undefined}\n draggable={draggable && !disabled ? 'true' : undefined}\n aria-level={String(level)}\n aria-posinset={String(position)}\n aria-setsize={String(setSize)}\n aria-expanded={expandable ? String(expanded) : undefined}\n aria-selected={String(selected)}\n aria-disabled={disabled ? 'true' : undefined}\n >\n <span\n class=\"kui-list-item__disclosure\"\n aria-hidden=\"true\"\n data-action={expandable && !disabled ? toggleAction : undefined}\n data-item-id={expandable ? itemId : undefined}\n >\n {expandable ? (\n <DisclosureArrow open={expanded} size={remify(16)} />\n ) : null}\n </span>\n {listItemContent({ label, description, icon, trailing, tile: null })}\n </button>\n );\n}\n","import {\n filterDataAttributes,\n type RootDataAttributes,\n} from '../../../shared/dom/extension-attributes.js';\nimport { ListTreeItem } from '../list-item/parts/tree-item.js';\nimport {\n type TreeListNode,\n treeListPath,\n treeListRows,\n} from './model/tree-rows.js';\n\nexport {\n isExpandable,\n moveTreeListNode,\n type TreeListNode,\n treeListPath,\n type TreeListRow,\n treeListRows,\n} from './model/tree-rows.js';\n\nconst TREE_LIST_PROTECTED = new Set(['data-component', 'data-tree-list-id']);\n\nexport interface TreeListProps {\n /** Identifies the tree for `wireTreeList` and in tests. */\n id: string;\n /** The tree's accessible name, such as \"Document outline\". */\n label: string;\n /** The hierarchy. The application owns it. */\n nodes: readonly TreeListNode[];\n /** Ids of the expanded nodes. The application owns this state. */\n expanded: ReadonlySet<string> | readonly string[];\n /** The selected node's id. */\n selected?: string;\n /** Delegated action for choosing a row; the row's `data-item-id` names it. */\n action: string;\n /**\n * Delegated action for expanding or collapsing a row, from its disclosure\n * arrow or the keyboard (Right and Left). Flip the id in `expanded`.\n */\n toggleAction: string;\n /** Row density: `default` (44px rows) or `compact` (36px). */\n density?: 'default' | 'compact' | /** @deprecated Use default. */ 'standard';\n className?: string;\n /** Safe `data-*` metadata for the tree element. */\n rootAttributes?: RootDataAttributes;\n /** Native named-slot assignment when composed inside a web component. */\n slot?: string;\n}\n\n/**\n * A hierarchical list: ListItem rows indented by depth, with a disclosure\n * arrow on each row that has children. The tree is an ARIA `tree` of flat\n * `treeitem` rows; the application owns the nodes, which are expanded, and\n * which is selected, and handles `action` and `toggleAction`. Wire keyboard\n * navigation with `wireTreeList`.\n */\nexport function TreeList({\n id,\n label,\n nodes,\n expanded,\n selected,\n action,\n toggleAction,\n density = 'default',\n className = '',\n rootAttributes = {},\n slot,\n}: TreeListProps) {\n const rows = treeListRows(nodes, expanded);\n const visible = new Set(rows.map((row) => row.node.id));\n // The Tab stop: the selected row, or the nearest visible ancestor of a\n // selection inside a collapsed node, or else the first row.\n const focusId =\n (selected === undefined\n ? undefined\n : treeListPath(nodes, selected)\n .reverse()\n .find((pathId) => visible.has(pathId))) ?? rows[0]?.node.id;\n return (\n <div\n {...filterDataAttributes(rootAttributes, TREE_LIST_PROTECTED)}\n id={id}\n role=\"tree\"\n class={`kui-tree-list ${className}`.trim()}\n aria-label={label}\n data-component=\"tree-list\"\n data-tree-list-id={id}\n slot={slot}\n >\n {rows.map((row) => (\n <ListTreeItem\n itemId={row.node.id}\n label={row.node.label}\n description={row.node.description}\n icon={row.node.icon}\n trailing={row.node.trailing}\n level={row.level}\n position={row.position}\n setSize={row.setSize}\n expandable={row.expandable}\n expanded={row.expanded}\n selected={row.node.id === selected}\n focusable={row.node.id === focusId}\n disabled={row.node.disabled}\n draggable={row.node.draggable}\n rootAttributes={row.node.rootAttributes}\n density={density}\n action={action}\n toggleAction={toggleAction}\n />\n ))}\n </div>\n );\n}\n"]}
|