@c2n/tree 0.0.9
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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/tree-item-C6XnvUA1.js +242 -0
- package/dist/tree-item.js +2 -0
- package/dist/tree-types.js +0 -0
- package/dist/tree.js +607 -0
- package/package.json +85 -0
- package/react.d.ts +26 -0
- package/react.js +3 -0
- package/types/src/tree-item.d.ts +153 -0
- package/types/src/tree-item.d.ts.map +1 -0
- package/types/src/tree-types.d.ts +87 -0
- package/types/src/tree-types.d.ts.map +1 -0
- package/types/src/tree.d.ts +176 -0
- package/types/src/tree.d.ts.map +1 -0
- package/vue.d.ts +52 -0
- package/vue.js +3 -0
package/react.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// GENERATED by @c2n/framework-types. Do not edit by hand.
|
|
2
|
+
//
|
|
3
|
+
// JSX types for the custom elements of @c2n/tree. Import once, anywhere in the program:
|
|
4
|
+
//
|
|
5
|
+
// import '@c2n/tree/react'
|
|
6
|
+
//
|
|
7
|
+
// Register the elements at module scope before React renders, or React writes an object prop as an
|
|
8
|
+
// attribute and it stringifies.
|
|
9
|
+
|
|
10
|
+
import type { DetailedHTMLProps, HTMLAttributes } from 'react'
|
|
11
|
+
import type { Tree } from '@c2n/tree'
|
|
12
|
+
import type { TreeItem } from '@c2n/tree/tree-item.js'
|
|
13
|
+
|
|
14
|
+
/** Standard React host-element attributes plus the element's own public properties. */
|
|
15
|
+
type C2Props<T> = DetailedHTMLProps<HTMLAttributes<T>, T> & Partial<Omit<T, keyof HTMLElement>>
|
|
16
|
+
|
|
17
|
+
declare module 'react' {
|
|
18
|
+
namespace JSX {
|
|
19
|
+
interface IntrinsicElements {
|
|
20
|
+
'c2-tree': C2Props<Tree>
|
|
21
|
+
'c2-tree-item': C2Props<TreeItem>
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {}
|
package/react.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
2
|
+
import type { TypedAddEventListener, TypedRemoveEventListener } from '@c2n/core/event-helper.js';
|
|
3
|
+
import '@c2n/checkbox';
|
|
4
|
+
import '@c2n/spinner';
|
|
5
|
+
import type { TreeNode } from './tree-types';
|
|
6
|
+
/** Fired when an item joins, leaves or changes identity, so its `c2-tree` can resync. */
|
|
7
|
+
export declare const TREE_ITEM_CHANGE_EVENT = "c2-tree-item-change";
|
|
8
|
+
/** Fired when the disclosure toggle is activated. */
|
|
9
|
+
export declare const TREE_ITEM_TOGGLE_EVENT = "c2-tree-item-toggle";
|
|
10
|
+
/** Fired when the row's checkbox is ticked or cleared. */
|
|
11
|
+
export declare const TREE_ITEM_CHECK_EVENT = "c2-tree-item-check";
|
|
12
|
+
/** Events fired by {@link TreeItem}, keyed for `addEventListener`. */
|
|
13
|
+
export interface TreeItemEventMap {
|
|
14
|
+
'c2-tree-item-change': CustomEvent<void>;
|
|
15
|
+
'c2-tree-item-toggle': CustomEvent<void>;
|
|
16
|
+
'c2-tree-item-check': CustomEvent<boolean>;
|
|
17
|
+
}
|
|
18
|
+
export interface TreeItem {
|
|
19
|
+
addEventListener: TypedAddEventListener<TreeItem, TreeItemEventMap>;
|
|
20
|
+
removeEventListener: TypedRemoveEventListener<TreeItem, TreeItemEventMap>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One row of a {@link https://github.com/code2nguyen/web-components | `c2-tree`}.
|
|
24
|
+
*
|
|
25
|
+
* Nest items to build the hierarchy — a branch's children are its own `c2-tree-item` element children:
|
|
26
|
+
*
|
|
27
|
+
* ```html
|
|
28
|
+
* <c2-tree>
|
|
29
|
+
* <c2-tree-item value="src" label="src">
|
|
30
|
+
* <c2-tree-item value="app.ts" label="app.ts"></c2-tree-item>
|
|
31
|
+
* </c2-tree-item>
|
|
32
|
+
* </c2-tree>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* The item draws a row and nothing else: `expanded`, `selected`, `indeterminate`, `level` and the roving
|
|
36
|
+
* `tabindex` are all written by the parent `c2-tree`, which owns the tree's state. Setting them by hand works
|
|
37
|
+
* but is overwritten on the tree's next sync — drive the tree's `value` and `expanded-items` instead.
|
|
38
|
+
*
|
|
39
|
+
* The children slot is only rendered while the row is expanded, so a collapsed subtree is not laid out and
|
|
40
|
+
* stays out of the accessibility tree. The child elements themselves still exist in the DOM.
|
|
41
|
+
*
|
|
42
|
+
* @tag c2-tree-item
|
|
43
|
+
*
|
|
44
|
+
* @slot - The nested `c2-tree-item` children of this row.
|
|
45
|
+
* @slot label - Rich label content, replacing the `label` attribute.
|
|
46
|
+
* @slot icon - Icon shown between the disclosure toggle and the label.
|
|
47
|
+
* @slot actions - Trailing content, revealed on hover and focus by default.
|
|
48
|
+
* @slot toggle-icon - Replaces the default chevron. It is rotated by the component, so supply the collapsed orientation.
|
|
49
|
+
*
|
|
50
|
+
* @csspart row - The clickable row, excluding any nested children.
|
|
51
|
+
* @csspart toggle - The disclosure toggle.
|
|
52
|
+
* @csspart label - The label box.
|
|
53
|
+
* @csspart actions - The trailing actions box.
|
|
54
|
+
* @csspart group - The container holding the nested children.
|
|
55
|
+
*
|
|
56
|
+
* @cssproperty {pixel} [--c2-tree-item__row--min-height=28px] - Height of a row.
|
|
57
|
+
* @cssproperty {pixel} [--c2-tree-item__row--indent=16px] - Extra inset added per level of depth.
|
|
58
|
+
* @cssproperty {padding} [--c2-tree-item__row--padding-top=0px] - Space above the row's content. `row--min-height` is a floor, so this only grows the row once content plus padding passes it.
|
|
59
|
+
* @cssproperty {padding} [--c2-tree-item__row--padding-bottom=0px] - Space below the row's content. See `row--padding-top` for how it interacts with `row--min-height`.
|
|
60
|
+
* @cssproperty {padding} [--c2-tree-item__row--padding-inline-start=8px] - Inset of a root-level row.
|
|
61
|
+
* @cssproperty {padding} [--c2-tree-item__row--padding-inline-end=8px] - Space after the trailing actions.
|
|
62
|
+
* @cssproperty {pixel} [--c2-tree-item__row--gap=6px] - Space between toggle, checkbox, icon, label and actions.
|
|
63
|
+
* @cssproperty {border-radius} [--c2-tree-item__row--border-radius=4px] - Corner radius of the row highlight. Set `0` for edge-to-edge bands.
|
|
64
|
+
* @cssproperty {color} [--c2-tree-item--color=#18181b] - Label colour.
|
|
65
|
+
* @cssproperty {color} [--c2-tree-item--background=transparent] - Row background at rest.
|
|
66
|
+
* @cssproperty {font-size} [--c2-tree-item--font-size=14px] - Label size.
|
|
67
|
+
* @cssproperty {font-weight} --c2-tree-item--font-weight - Label weight.
|
|
68
|
+
* @cssproperty {font-family} --c2-tree-item--font-family - Label family.
|
|
69
|
+
* @cssproperty {pixel} [--c2-tree-item--line-height=20px] - Label line height.
|
|
70
|
+
* @cssproperty {color} --c2-tree-item__hover--color - Label colour while hovered. Defaults to the resting colour.
|
|
71
|
+
* @cssproperty {color} [--c2-tree-item__hover--background=#f4f4f5] - Row background while hovered.
|
|
72
|
+
* @cssproperty {color} [--c2-tree-item__selected--color=rgb(2, 101, 220)] - Label colour while selected.
|
|
73
|
+
* @cssproperty {color} [--c2-tree-item__selected--background=#edf1fe] - Row background while selected.
|
|
74
|
+
* @cssproperty {color} [--c2-tree-item__selected__hover--background=#e2e9fd] - Row background while selected and hovered.
|
|
75
|
+
* @cssproperty {outline} [--c2-tree-item__focus--outline=2px solid rgba(2, 101, 220, 0.4)] - Focus ring.
|
|
76
|
+
* @cssproperty {pixel} [--c2-tree-item__focus--outline-offset=-2px] - Focus ring inset.
|
|
77
|
+
* @cssproperty {opacity} [--c2-tree-item__disabled--opacity=0.38] - Opacity of a disabled row.
|
|
78
|
+
* @cssproperty {pixel} [--c2-tree-item__toggle--size=16px] - Size of the disclosure toggle.
|
|
79
|
+
* @cssproperty {color} [--c2-tree-item__toggle--color=#71717a] - Colour of the disclosure toggle.
|
|
80
|
+
* @cssproperty {angle} [--c2-tree-item__toggle--rotate=90deg] - Toggle rotation while expanded.
|
|
81
|
+
* @cssproperty {angle} [--c2-tree-item__toggle--rotate-collapsed=0deg] - Toggle rotation while collapsed.
|
|
82
|
+
* @cssproperty {time} [--c2-tree-item__toggle--transition-duration=150ms] - Length of the toggle rotation.
|
|
83
|
+
* @cssproperty {pixel} [--c2-tree-item__icon--size=16px] - Size of slotted icons.
|
|
84
|
+
* @cssproperty {color} --c2-tree-item__icon--color - Colour of slotted icons.
|
|
85
|
+
* @cssproperty {color} [--c2-tree-item__guide--color=#e4e4e7] - Colour of the indent guides.
|
|
86
|
+
* @cssproperty {pixel} [--c2-tree-item__guide--width=1px] - Thickness of the indent guides.
|
|
87
|
+
* @cssproperty {pixel} [--c2-tree-item__actions--gap=2px] - Space between trailing actions.
|
|
88
|
+
* @cssproperty {opacity} [--c2-tree-item__actions--opacity=0] - Opacity of the trailing actions at rest. Set `1` to always show them.
|
|
89
|
+
* @cssproperty {opacity} [--c2-tree-item__actions__hover--opacity=1] - Opacity of the trailing actions while the row is hovered or focused.
|
|
90
|
+
* @cssproperty {pixel} [--c2-tree-item__checkbox--margin-inline-end=2px] - Space after the selection checkbox.
|
|
91
|
+
*/
|
|
92
|
+
export declare class TreeItem extends LitElement {
|
|
93
|
+
#private;
|
|
94
|
+
static styles: import("lit").CSSResult;
|
|
95
|
+
/** Identity of the row. Selection and expansion are tracked by this value, so it must be unique in the tree. */
|
|
96
|
+
value: string;
|
|
97
|
+
/** Text of the row. Ignored when the `label` slot is filled; falls back to `value` when empty. */
|
|
98
|
+
label: string;
|
|
99
|
+
/** Blocks selection and expansion, and takes the row out of checkbox propagation. */
|
|
100
|
+
disabled: boolean;
|
|
101
|
+
/** Marks a branch whose children load on demand: the toggle shows before any child exists. */
|
|
102
|
+
hasChildren: boolean;
|
|
103
|
+
/** Turns the row into a link. The whole row becomes the click target; the toggle still only expands. */
|
|
104
|
+
href: string;
|
|
105
|
+
/** Browsing context for `href`, e.g. `_blank`. A `_blank` row gets `rel="noopener noreferrer"`. */
|
|
106
|
+
target?: string;
|
|
107
|
+
/** Arbitrary payload handed back on the tree's events. */
|
|
108
|
+
data?: unknown;
|
|
109
|
+
/** Whether the children are shown. Written by the parent `c2-tree`. */
|
|
110
|
+
expanded: boolean;
|
|
111
|
+
/** Whether the row is selected. Written by the parent `c2-tree`. */
|
|
112
|
+
selected: boolean;
|
|
113
|
+
/** Whether only part of the subtree is selected. Derived and written by the parent `c2-tree`. */
|
|
114
|
+
indeterminate: boolean;
|
|
115
|
+
/** Whether the children are being fetched. Written by the parent `c2-tree`. */
|
|
116
|
+
loading: boolean;
|
|
117
|
+
/** Depth of the row, `0` at the root. Written by the parent `c2-tree`. */
|
|
118
|
+
level: number;
|
|
119
|
+
/** Whether the parent `c2-tree` renders a selection checkbox. Written by the parent `c2-tree`. */
|
|
120
|
+
checkboxSelection: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Whether to draw the indent guides. Written by the parent `c2-tree`, and reflected because the rules are
|
|
123
|
+
* drawn in CSS and the stylesheet has to see it.
|
|
124
|
+
*/
|
|
125
|
+
childrenOutline: boolean;
|
|
126
|
+
/** Number of siblings in this row's group, for `aria-setsize`. Written by the parent `c2-tree`. */
|
|
127
|
+
setSize: number;
|
|
128
|
+
/** 1-based index of this row among its siblings, for `aria-posinset`. Written by the parent `c2-tree`. */
|
|
129
|
+
posInSet: number;
|
|
130
|
+
/** Whether the parent `c2-tree` tracks selection at all, so a leaf knows whether to claim `aria-selected`. */
|
|
131
|
+
selectable: boolean;
|
|
132
|
+
private labelSlot?;
|
|
133
|
+
/** The row as a {@link TreeNode}, so both authoring modes produce the same event details and renderer input. */
|
|
134
|
+
get node(): TreeNode;
|
|
135
|
+
/** The nested rows, in document order. */
|
|
136
|
+
get childItems(): TreeItem[];
|
|
137
|
+
/** Whether the row can be expanded — it already has children, or declares that it will load some. */
|
|
138
|
+
get isBranch(): boolean;
|
|
139
|
+
/** The accessible name of the row, resolved from the `label` slot, the `label` attribute or `value`. */
|
|
140
|
+
get resolvedLabel(): string;
|
|
141
|
+
connectedCallback(): void;
|
|
142
|
+
disconnectedCallback(): void;
|
|
143
|
+
willUpdate(changed: PropertyValues<this>): void;
|
|
144
|
+
updated(changed: PropertyValues<this>): void;
|
|
145
|
+
firstUpdated(): void;
|
|
146
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
147
|
+
}
|
|
148
|
+
declare global {
|
|
149
|
+
interface HTMLElementTagNameMap {
|
|
150
|
+
'c2-tree-item': TreeItem;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=tree-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-item.d.ts","sourceRoot":"","sources":["../../src/tree-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4B,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAM/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAChG,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE5C,yFAAyF;AACzF,eAAO,MAAM,sBAAsB,wBAAwB,CAAA;AAC3D,qDAAqD;AACrD,eAAO,MAAM,sBAAsB,wBAAwB,CAAA;AAC3D,0DAA0D;AAC1D,eAAO,MAAM,qBAAqB,uBAAuB,CAAA;AAEzD,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,qBAAqB,EAAE,WAAW,CAAC,IAAI,CAAC,CAAA;IACxC,qBAAqB,EAAE,WAAW,CAAC,IAAI,CAAC,CAAA;IACxC,oBAAoB,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;CAC3C;AAED,MAAM,WAAW,QAAQ;IACvB,gBAAgB,EAAE,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;IACnE,mBAAmB,EAAE,wBAAwB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;CAC1E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,qBACa,QAAS,SAAQ,UAAU;;IACtC,OAAgB,MAAM,0BAAoB;IAE1C,gHAAgH;IACrE,KAAK,SAAK;IAErD,kGAAkG;IACtE,KAAK,SAAK;IAEtC,qFAAqF;IACzC,QAAQ,UAAQ;IAE5D,8FAA8F;IACvB,WAAW,UAAQ;IAE1F,wGAAwG;IAC5E,IAAI,SAAK;IAErC,mGAAmG;IACvE,MAAM,CAAC,EAAE,MAAM,CAAA;IAE3C,0DAA0D;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAA;IAE9C,uEAAuE;IAC3B,QAAQ,UAAQ;IAE5D,oEAAoE;IACxB,QAAQ,UAAQ;IAE5D,iGAAiG;IACrD,aAAa,UAAQ;IAEjE,+EAA+E;IACnC,OAAO,UAAQ;IAE3D,0EAA0E;IAC1C,KAAK,SAAI;IAEzC,kGAAkG;IAClE,iBAAiB,UAAQ;IAEzD;;;OAGG;IACwE,eAAe,UAAQ;IAElG,mGAAmG;IACnE,OAAO,SAAI;IAE3C,0GAA0G;IAC1E,QAAQ,SAAI;IAE5C,8GAA8G;IAC9E,UAAU,UAAO;IAEpB,OAAO,CAAC,SAAS,CAAC,CAAiB;IAKhE,gHAAgH;IAChH,IAAI,IAAI,IAAI,QAAQ,CAInB;IAED,0CAA0C;IAC1C,IAAI,UAAU,IAAI,QAAQ,EAAE,CAI3B;IAED,qGAAqG;IACrG,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,wGAAwG;IACxG,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEQ,iBAAiB;IAKjB,oBAAoB;IAapB,UAAU,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC;IAKxC,OAAO,CAAC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC;IAKrC,YAAY;IAwDZ,MAAM;CA+DhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,cAAc,EAAE,QAAQ,CAAA;KACzB;CACF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types shared by `c2-tree` and `c2-tree-item`.
|
|
3
|
+
*
|
|
4
|
+
* The tree can be authored two ways — nested `<c2-tree-item>` elements, or a `TreeNode[]` handed to the
|
|
5
|
+
* `items` property — and {@link TreeNode} is the single shape both speak. A declarative item synthesizes one
|
|
6
|
+
* from its own attributes through its `node` getter, so event details, renderers and the lazy loader never
|
|
7
|
+
* have to care which mode produced a row.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* One node of a tree.
|
|
11
|
+
*
|
|
12
|
+
* Shaped after `CascaderOption` so the two hierarchical components read alike. `children` is only meaningful
|
|
13
|
+
* in the data-driven mode: a declarative item's `node` deliberately leaves it `undefined` rather than walking
|
|
14
|
+
* its subtree on every event dispatch.
|
|
15
|
+
*/
|
|
16
|
+
export interface TreeNode {
|
|
17
|
+
/** Identity of the node. Selection and expansion are both tracked by this value, so it must be unique. */
|
|
18
|
+
value: string;
|
|
19
|
+
/** Text shown on the row. Falls back to {@link TreeNode.value} when omitted. */
|
|
20
|
+
label?: string;
|
|
21
|
+
/** Child nodes. Leave undefined and set {@link TreeNode.hasChildren} for a branch that loads on demand. */
|
|
22
|
+
children?: TreeNode[];
|
|
23
|
+
/** Blocks selection and expansion, and excludes the node from checkbox propagation. */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Marks a branch whose children are not loaded yet, so the row shows a toggle before anything is known
|
|
27
|
+
* about its contents. Expanding it runs the tree's `loadChildren`.
|
|
28
|
+
*/
|
|
29
|
+
hasChildren?: boolean;
|
|
30
|
+
/** Arbitrary payload carried back to the consumer on `selection-change` and in the renderers. */
|
|
31
|
+
data?: unknown;
|
|
32
|
+
}
|
|
33
|
+
/** What a renderer or loader is told about the row it is being called for. */
|
|
34
|
+
export interface TreeItemContext {
|
|
35
|
+
/** The node being rendered. */
|
|
36
|
+
node: TreeNode;
|
|
37
|
+
/** Depth of the node, `0` for a root. */
|
|
38
|
+
level: number;
|
|
39
|
+
/** Whether the node is currently expanded. */
|
|
40
|
+
expanded: boolean;
|
|
41
|
+
/** Whether the node is currently selected. */
|
|
42
|
+
selected: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** Replaces part of a row's content. Returns anything Lit can render. */
|
|
45
|
+
export type TreeItemRenderer = (context: TreeItemContext) => unknown;
|
|
46
|
+
/** Resolves the children of a branch the first time it is expanded. */
|
|
47
|
+
export type TreeChildrenLoader = (context: TreeItemContext) => Promise<TreeNode[]>;
|
|
48
|
+
/** Detail of `c2-tree`'s `selection-change` event. */
|
|
49
|
+
export interface TreeSelectionChangeEventDetail {
|
|
50
|
+
/** Values of every selected node, in tree order. */
|
|
51
|
+
value: string[];
|
|
52
|
+
/** The selected nodes themselves. */
|
|
53
|
+
nodes: TreeNode[];
|
|
54
|
+
}
|
|
55
|
+
/** Detail of `c2-tree`'s `expansion-change` event. */
|
|
56
|
+
export interface TreeExpansionChangeEventDetail {
|
|
57
|
+
/** Values of every expanded node after the change. */
|
|
58
|
+
expandedItems: string[];
|
|
59
|
+
/** The node that was toggled. */
|
|
60
|
+
node: TreeNode;
|
|
61
|
+
/** Whether that node is now expanded. */
|
|
62
|
+
expanded: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** Detail of `c2-tree`'s `item-click` event. */
|
|
65
|
+
export interface TreeItemClickEventDetail {
|
|
66
|
+
/** The node whose row was clicked. */
|
|
67
|
+
node: TreeNode;
|
|
68
|
+
}
|
|
69
|
+
/** Detail of `c2-tree`'s `item-expand` event, the hook a declarative consumer loads children from. */
|
|
70
|
+
export interface TreeItemExpandEventDetail {
|
|
71
|
+
/** The node being expanded. */
|
|
72
|
+
node: TreeNode;
|
|
73
|
+
/** True while the node's children still have to be produced. */
|
|
74
|
+
loading: boolean;
|
|
75
|
+
}
|
|
76
|
+
/** Detail of `c2-tree`'s `item-load-error` event. */
|
|
77
|
+
export interface TreeItemLoadErrorEventDetail {
|
|
78
|
+
/** The node whose children failed to load. */
|
|
79
|
+
node: TreeNode;
|
|
80
|
+
/** Whatever `loadChildren` rejected with. */
|
|
81
|
+
error: unknown;
|
|
82
|
+
}
|
|
83
|
+
/** How a checkbox tick travels between a node and its relatives. */
|
|
84
|
+
export type TreeSelectionPropagation = 'none' | 'descendants' | 'parents' | 'both';
|
|
85
|
+
/** How many rows may be selected at once. */
|
|
86
|
+
export type TreeSelectionMode = 'none' | 'single' | 'multiple';
|
|
87
|
+
//# sourceMappingURL=tree-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-types.d.ts","sourceRoot":"","sources":["../../src/tree-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,0GAA0G;IAC1G,KAAK,EAAE,MAAM,CAAA;IACb,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2GAA2G;IAC3G,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAA;IACrB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,iGAAiG;IACjG,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,IAAI,EAAE,QAAQ,CAAA;IACd,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAA;IACb,8CAA8C;IAC9C,QAAQ,EAAE,OAAO,CAAA;IACjB,8CAA8C;IAC9C,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,yEAAyE;AACzE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAA;AAEpE,uEAAuE;AACvE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;AAElF,sDAAsD;AACtD,MAAM,WAAW,8BAA8B;IAC7C,oDAAoD;IACpD,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,qCAAqC;IACrC,KAAK,EAAE,QAAQ,EAAE,CAAA;CAClB;AAED,sDAAsD;AACtD,MAAM,WAAW,8BAA8B;IAC7C,sDAAsD;IACtD,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,iCAAiC;IACjC,IAAI,EAAE,QAAQ,CAAA;IACd,yCAAyC;IACzC,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,gDAAgD;AAChD,MAAM,WAAW,wBAAwB;IACvC,sCAAsC;IACtC,IAAI,EAAE,QAAQ,CAAA;CACf;AAED,sGAAsG;AACtG,MAAM,WAAW,yBAAyB;IACxC,+BAA+B;IAC/B,IAAI,EAAE,QAAQ,CAAA;IACd,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,qDAAqD;AACrD,MAAM,WAAW,4BAA4B;IAC3C,8CAA8C;IAC9C,IAAI,EAAE,QAAQ,CAAA;IACd,6CAA6C;IAC7C,KAAK,EAAE,OAAO,CAAA;CACf;AAED,oEAAoE;AACpE,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,GAAG,MAAM,CAAA;AAElF,6CAA6C;AAC7C,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAA"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { LitElement, type PropertyValues } from 'lit';
|
|
2
|
+
import type { TypedAddEventListener, TypedRemoveEventListener } from '@c2n/core/event-helper.js';
|
|
3
|
+
import './tree-item';
|
|
4
|
+
import { TreeItem } from './tree-item';
|
|
5
|
+
import type { TreeChildrenLoader, TreeExpansionChangeEventDetail, TreeItemClickEventDetail, TreeItemExpandEventDetail, TreeItemLoadErrorEventDetail, TreeItemRenderer, TreeNode, TreeSelectionChangeEventDetail, TreeSelectionMode, TreeSelectionPropagation } from './tree-types';
|
|
6
|
+
/** Events fired by {@link Tree}, keyed for `addEventListener`. */
|
|
7
|
+
export interface TreeEventMap {
|
|
8
|
+
'selection-change': CustomEvent<TreeSelectionChangeEventDetail>;
|
|
9
|
+
'expansion-change': CustomEvent<TreeExpansionChangeEventDetail>;
|
|
10
|
+
'item-click': CustomEvent<TreeItemClickEventDetail>;
|
|
11
|
+
'item-expand': CustomEvent<TreeItemExpandEventDetail>;
|
|
12
|
+
'item-load-error': CustomEvent<TreeItemLoadErrorEventDetail>;
|
|
13
|
+
}
|
|
14
|
+
export interface Tree {
|
|
15
|
+
addEventListener: TypedAddEventListener<Tree, TreeEventMap>;
|
|
16
|
+
removeEventListener: TypedRemoveEventListener<Tree, TreeEventMap>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Hierarchical tree view with expansion, selection and lazy loading.
|
|
20
|
+
*
|
|
21
|
+
* It can be authored two ways, and both produce the same DOM and the same events. Nest the rows in markup:
|
|
22
|
+
*
|
|
23
|
+
* ```html
|
|
24
|
+
* <c2-tree expanded-items="src">
|
|
25
|
+
* <c2-tree-item value="src" label="src">
|
|
26
|
+
* <c2-tree-item value="app.ts" label="app.ts"></c2-tree-item>
|
|
27
|
+
* </c2-tree-item>
|
|
28
|
+
* </c2-tree>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* …or hand it data, which it renders into the same `c2-tree-item` elements:
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* tree.items = [{ value: 'src', label: 'src', children: [{ value: 'app.ts', label: 'app.ts' }] }]
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* The tree owns all state. `value` holds the selected rows, `expanded-items` the expanded ones, and every
|
|
38
|
+
* row's `expanded`, `selected`, `indeterminate`, `level` and roving `tabindex` are written from here on each
|
|
39
|
+
* sync — so drive those two arrays rather than the rows.
|
|
40
|
+
*
|
|
41
|
+
* In the data-driven mode `renderItem` takes over a row's whole content, or `renderIcon`, `renderLabel` and
|
|
42
|
+
* `renderActions` replace one part each. They are handed to Lit, so they return a Lit template or a DOM node —
|
|
43
|
+
* not framework markup such as JSX.
|
|
44
|
+
*
|
|
45
|
+
* `children-outline` draws a vertical rule per level of depth, the way a file explorer marks which branch each
|
|
46
|
+
* row belongs to. It is off by default; `--c2-tree-item__guide--color` and `--c2-tree-item__guide--width` style
|
|
47
|
+
* the rules once it is on.
|
|
48
|
+
*
|
|
49
|
+
* Only expanded rows render their children slot, which keeps a collapsed subtree out of both layout and the
|
|
50
|
+
* accessibility tree — though the child elements are still created. Reach for virtualization rather than this
|
|
51
|
+
* component once a tree runs to many thousands of rows.
|
|
52
|
+
*
|
|
53
|
+
* ### Keyboard
|
|
54
|
+
*
|
|
55
|
+
* Arrow Up and Down walk the visible rows. Arrow Right expands a collapsed branch, then moves to its first
|
|
56
|
+
* child; Arrow Left collapses an expanded one, then moves to its parent. Home and End jump to the ends, Enter
|
|
57
|
+
* and Space select, `*` expands every sibling of the focused row, and typing a few letters jumps to the
|
|
58
|
+
* matching row. With `selection="multiple"`, Shift extends a range and Ctrl or Cmd toggles a single row.
|
|
59
|
+
*
|
|
60
|
+
* @tag c2-tree
|
|
61
|
+
*
|
|
62
|
+
* @slot - The root `c2-tree-item` rows, when authoring in markup.
|
|
63
|
+
* @slot empty - Shown instead of the rows when the tree holds nothing.
|
|
64
|
+
*
|
|
65
|
+
* @slotcomponent c2-tree-item
|
|
66
|
+
*
|
|
67
|
+
* @csspart tree - The scrolling container holding the rows.
|
|
68
|
+
*
|
|
69
|
+
* @event {CustomEvent<TreeSelectionChangeEventDetail>} selection-change - Fired after the user changes the selection. Does not bubble: several components fire `selection-change`, so a listener belongs on the element itself.
|
|
70
|
+
* @event {CustomEvent<TreeExpansionChangeEventDetail>} expansion-change - Fired after a row is expanded or collapsed. Does not bubble.
|
|
71
|
+
* @event {CustomEvent<TreeItemClickEventDetail>} item-click - Fired when a row is clicked, selected or not.
|
|
72
|
+
* @event {CustomEvent<TreeItemExpandEventDetail>} item-expand - Fired when a row expands. Call `preventDefault()` to keep it closed. This is where a consumer authoring in markup appends children for a lazily loaded branch.
|
|
73
|
+
* @event {CustomEvent<TreeItemLoadErrorEventDetail>} item-load-error - Fired when `loadChildren` rejects.
|
|
74
|
+
*
|
|
75
|
+
* @cssproperty {color} [--c2-tree--background=#ffffff] - Background of the tree.
|
|
76
|
+
* @cssproperty {padding} [--c2-tree--padding-top=4px] - Space above the first row.
|
|
77
|
+
* @cssproperty {padding} [--c2-tree--padding-right=0px] - Space right of the rows.
|
|
78
|
+
* @cssproperty {padding} [--c2-tree--padding-bottom=4px] - Space below the last row.
|
|
79
|
+
* @cssproperty {padding} [--c2-tree--padding-left=0px] - Space left of the rows.
|
|
80
|
+
* @cssproperty {border} --c2-tree--border-top - Top border.
|
|
81
|
+
* @cssproperty {border} --c2-tree--border-right - Right border.
|
|
82
|
+
* @cssproperty {border} --c2-tree--border-bottom - Bottom border.
|
|
83
|
+
* @cssproperty {border} --c2-tree--border-left - Left border.
|
|
84
|
+
* @cssproperty {border-radius} [--c2-tree--border-top-left-radius=8px] - Top-left corner radius.
|
|
85
|
+
* @cssproperty {border-radius} [--c2-tree--border-top-right-radius=8px] - Top-right corner radius.
|
|
86
|
+
* @cssproperty {border-radius} [--c2-tree--border-bottom-left-radius=8px] - Bottom-left corner radius.
|
|
87
|
+
* @cssproperty {border-radius} [--c2-tree--border-bottom-right-radius=8px] - Bottom-right corner radius.
|
|
88
|
+
* @cssproperty {pixel} --c2-tree--max-height - Height at which the tree starts scrolling.
|
|
89
|
+
* @cssproperty {font-size} [--c2-tree--font-size=14px] - Base font size, inherited by the rows.
|
|
90
|
+
* @cssproperty {font-family} --c2-tree--font-family - Base font family, inherited by the rows.
|
|
91
|
+
* @cssproperty {opacity} [--c2-tree__disabled--opacity=0.38] - Opacity of a disabled tree.
|
|
92
|
+
* @cssproperty {color} [--c2-tree__empty--color=#71717a] - Colour of the empty message.
|
|
93
|
+
* @cssproperty {padding} [--c2-tree__empty--padding=18px] - Space around the empty message.
|
|
94
|
+
*/
|
|
95
|
+
export declare class Tree extends LitElement {
|
|
96
|
+
#private;
|
|
97
|
+
static styles: import("lit").CSSResult;
|
|
98
|
+
/** Nodes to render. Leave empty and nest `c2-tree-item` elements instead to author the tree in markup. */
|
|
99
|
+
items: TreeNode[];
|
|
100
|
+
/** Values of the selected rows. Reflected as a `;`-separated attribute. */
|
|
101
|
+
value: string[];
|
|
102
|
+
/** Values of the expanded rows. Reflected as a `;`-separated attribute. */
|
|
103
|
+
expandedItems: string[];
|
|
104
|
+
/** How many rows may be selected at once. */
|
|
105
|
+
selection: TreeSelectionMode;
|
|
106
|
+
/** Shows a checkbox on every row. Implies `selection="multiple"`. */
|
|
107
|
+
checkboxSelection: boolean;
|
|
108
|
+
/** How a checkbox tick travels between a row and its relatives. */
|
|
109
|
+
selectionPropagation: TreeSelectionPropagation;
|
|
110
|
+
/** Draws a vertical rule per level of depth, marking which branch each row belongs to. */
|
|
111
|
+
childrenOutline: boolean;
|
|
112
|
+
/** Freezes the whole tree. */
|
|
113
|
+
disabled: boolean;
|
|
114
|
+
/** Expands a branch when its row is clicked — or activated with Enter or Space — not only when its toggle is. */
|
|
115
|
+
expandOnClick: boolean;
|
|
116
|
+
/** Resolves the children of a branch the first time it is expanded. */
|
|
117
|
+
loadChildren?: TreeChildrenLoader;
|
|
118
|
+
/**
|
|
119
|
+
* Replaces the whole content of every row — icon, label and trailing actions together. Takes precedence over
|
|
120
|
+
* `renderIcon`, `renderLabel` and `renderActions`. The toggle and the selection checkbox are structural and
|
|
121
|
+
* stay. Only used in the data-driven mode; author the slots directly when the rows are written in markup.
|
|
122
|
+
*/
|
|
123
|
+
renderItem?: TreeItemRenderer;
|
|
124
|
+
/** Replaces the label of every row. Only used in the data-driven mode. */
|
|
125
|
+
renderLabel?: TreeItemRenderer;
|
|
126
|
+
/** Adds an icon to every row. Only used in the data-driven mode. */
|
|
127
|
+
renderIcon?: TreeItemRenderer;
|
|
128
|
+
/** Adds trailing content to every row. Only used in the data-driven mode. */
|
|
129
|
+
renderActions?: TreeItemRenderer;
|
|
130
|
+
private container?;
|
|
131
|
+
private rootSlot?;
|
|
132
|
+
/** Every row in the tree, in document order, expanded or not. */
|
|
133
|
+
get allItems(): TreeItem[];
|
|
134
|
+
/**
|
|
135
|
+
* The rows a user can actually see and move to — every row whose ancestors are all expanded, skipping any row
|
|
136
|
+
* `hidden` takes off the page. A filtered-out row must not stay in the keyboard order, or Arrow Down walks
|
|
137
|
+
* onto something nobody can see.
|
|
138
|
+
*/
|
|
139
|
+
get visibleItems(): TreeItem[];
|
|
140
|
+
/**
|
|
141
|
+
* The root rows, from whichever mode produced them. Data-driven rows live in this shadow root and slotted
|
|
142
|
+
* rows in the light DOM, so both sources are read; below the root the two modes are identical and
|
|
143
|
+
* `TreeItem.childItems` serves both.
|
|
144
|
+
*/
|
|
145
|
+
get rootItems(): TreeItem[];
|
|
146
|
+
/** The rows that are currently selected, in tree order. */
|
|
147
|
+
getSelectedNodes(): TreeNode[];
|
|
148
|
+
/** Expands a row. Unknown or disabled values are ignored. */
|
|
149
|
+
expand(value: string): void;
|
|
150
|
+
/** Collapses a row. Unknown values are ignored. */
|
|
151
|
+
collapse(value: string): void;
|
|
152
|
+
/** Expands a collapsed row, or collapses an expanded one. */
|
|
153
|
+
toggle(value: string): void;
|
|
154
|
+
/** Expands every branch already present in the tree. Branches that load on demand are left alone. */
|
|
155
|
+
expandAll(): void;
|
|
156
|
+
/** Collapses every branch. */
|
|
157
|
+
collapseAll(): void;
|
|
158
|
+
/** Selects every enabled row. Only meaningful while several rows may be selected. */
|
|
159
|
+
selectAll(): void;
|
|
160
|
+
/** Clears the selection. */
|
|
161
|
+
clearSelection(): void;
|
|
162
|
+
/** Moves focus to a row, expanding its ancestors if needed. */
|
|
163
|
+
focusItem(value: string): void;
|
|
164
|
+
/** Drops the cached "already loaded" mark so the next expand runs `loadChildren` again. */
|
|
165
|
+
reload(value?: string): void;
|
|
166
|
+
connectedCallback(): void;
|
|
167
|
+
willUpdate(changed: PropertyValues<this>): void;
|
|
168
|
+
updated(changed: PropertyValues<this>): void;
|
|
169
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
170
|
+
}
|
|
171
|
+
declare global {
|
|
172
|
+
interface HTMLElementTagNameMap {
|
|
173
|
+
'c2-tree': Tree;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/tree.ts"],"names":[],"mappings":"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"}
|
package/vue.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// GENERATED by @c2n/framework-types. Do not edit by hand.
|
|
2
|
+
//
|
|
3
|
+
// Vue template types for the custom elements of @c2n/tree. Import once, anywhere in the program:
|
|
4
|
+
//
|
|
5
|
+
// import '@c2n/tree/vue'
|
|
6
|
+
//
|
|
7
|
+
// Tell the compiler about the tags as well, or every c2-* tag is resolved as a Vue component and renders
|
|
8
|
+
// nothing: template.compilerOptions.isCustomElement = (tag) => tag.startsWith('c2-') in vite.config.ts.
|
|
9
|
+
|
|
10
|
+
import type { DefineComponent, HTMLAttributes } from 'vue'
|
|
11
|
+
import type { Tree, TreeEventMap } from '@c2n/tree'
|
|
12
|
+
import type { TreeItem, TreeItemEventMap } from '@c2n/tree/tree-item.js'
|
|
13
|
+
|
|
14
|
+
/** The element's own public properties, plus every attribute Vue understands on a host element. */
|
|
15
|
+
type C2Props<T> = Partial<Omit<T, keyof HTMLElement>> & HTMLAttributes
|
|
16
|
+
|
|
17
|
+
declare module 'vue' {
|
|
18
|
+
interface GlobalComponents {
|
|
19
|
+
'c2-tree': DefineComponent<
|
|
20
|
+
C2Props<Tree> & {
|
|
21
|
+
'expanded-items'?: unknown
|
|
22
|
+
'checkbox-selection'?: unknown
|
|
23
|
+
'selection-propagation'?: unknown
|
|
24
|
+
'children-outline'?: unknown
|
|
25
|
+
'expand-on-click'?: unknown
|
|
26
|
+
onExpansionChange?: (event: TreeEventMap['expansion-change']) => void
|
|
27
|
+
onItemLoadError?: (event: TreeEventMap['item-load-error']) => void
|
|
28
|
+
onSelectionChange?: (event: TreeEventMap['selection-change']) => void
|
|
29
|
+
onItemClick?: (event: TreeEventMap['item-click']) => void
|
|
30
|
+
onItemExpand?: (event: TreeEventMap['item-expand']) => void
|
|
31
|
+
}
|
|
32
|
+
>
|
|
33
|
+
'c2-tree-item': DefineComponent<
|
|
34
|
+
C2Props<TreeItem> & {
|
|
35
|
+
'has-children'?: unknown
|
|
36
|
+
'children-outline'?: unknown
|
|
37
|
+
onTREE_ITEM_CHANGE_EVENT?: (event: TreeItemEventMap['TREE_ITEM_CHANGE_EVENT']) => void
|
|
38
|
+
onTREE_ITEM_TOGGLE_EVENT?: (event: TreeItemEventMap['TREE_ITEM_TOGGLE_EVENT']) => void
|
|
39
|
+
onTREE_ITEM_CHECK_EVENT?: (event: TreeItemEventMap['TREE_ITEM_CHECK_EVENT']) => void
|
|
40
|
+
}
|
|
41
|
+
>
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare module '@vue/runtime-dom' {
|
|
46
|
+
interface HTMLAttributes {
|
|
47
|
+
/** Vue's own definition omits it, and slotting a plain element into a component needs it. */
|
|
48
|
+
slot?: string
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {}
|
package/vue.js
ADDED