@sproutsocial/seeds-react-tree 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +21 -0
- package/CHANGELOG.md +112 -0
- package/README.md +51 -0
- package/dist/esm/index.js +887 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +102 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +926 -0
- package/dist/index.js.map +1 -0
- package/jest.config.js +12 -0
- package/package.json +61 -0
- package/src/Common/filterTree.ts +51 -0
- package/src/Common/treeContext.ts +52 -0
- package/src/Common/treeNavigation.ts +171 -0
- package/src/Common/types.ts +23 -0
- package/src/Common/useTreeKeyboard.ts +124 -0
- package/src/Common/useTreeState.ts +107 -0
- package/src/Tree.stories.tsx +231 -0
- package/src/Tree.tsx +181 -0
- package/src/TreeCombobox.stories.tsx +100 -0
- package/src/TreeCombobox.tsx +291 -0
- package/src/TreeItem.tsx +218 -0
- package/src/TreeStyles.tsx +114 -0
- package/src/__tests__/Tree.test.tsx +199 -0
- package/src/__tests__/TreeCombobox.test.tsx +230 -0
- package/src/index.ts +10 -0
- package/src/storyData.tsx +166 -0
- package/tsconfig.json +12 -0
- package/tsup.config.ts +12 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
yarn run v1.22.22
|
|
2
|
+
$ tsup --dts
|
|
3
|
+
[34mCLI[39m Building entry: src/index.ts
|
|
4
|
+
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
5
|
+
[34mCLI[39m tsup v8.5.0
|
|
6
|
+
[34mCLI[39m Using tsup config: /home/runner/_work/seeds/seeds/seeds-react/seeds-react-tree/tsup.config.ts
|
|
7
|
+
[34mCLI[39m Target: es2022
|
|
8
|
+
[34mCLI[39m Cleaning output folder
|
|
9
|
+
[34mCJS[39m Build start
|
|
10
|
+
[34mESM[39m Build start
|
|
11
|
+
[32mCJS[39m [1mdist/index.js [22m[32m29.75 KB[39m
|
|
12
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m58.64 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 26ms
|
|
14
|
+
[32mESM[39m [1mdist/esm/index.js [22m[32m26.95 KB[39m
|
|
15
|
+
[32mESM[39m [1mdist/esm/index.js.map [22m[32m58.29 KB[39m
|
|
16
|
+
[32mESM[39m ⚡️ Build success in 27ms
|
|
17
|
+
[34mDTS[39m Build start
|
|
18
|
+
[32mDTS[39m ⚡️ Build success in 1655ms
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m4.11 KB[39m
|
|
20
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m4.11 KB[39m
|
|
21
|
+
Done in 2.39s.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# @sproutsocial/seeds-react-tree
|
|
2
|
+
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [69c9d02]
|
|
8
|
+
- @sproutsocial/seeds-react-icon@2.4.0
|
|
9
|
+
|
|
10
|
+
## 0.3.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 1aa4c29: Add `TreeCombobox` — pairs `Tree` with a `role="combobox"` input following the
|
|
15
|
+
WAI-ARIA combobox pattern. DOM focus stays on the input; the active treeitem
|
|
16
|
+
is tracked via `aria-activedescendant`. Filters items by label and
|
|
17
|
+
auto-expands the ancestors of matches; restores user expansion state when the
|
|
18
|
+
query clears, and renders an `aria-live` empty state when nothing matches.
|
|
19
|
+
|
|
20
|
+
Keyboard support on the input: arrow keys, Home/End move the active item;
|
|
21
|
+
Enter selects/expands the active row (inheriting `Tree`'s selection
|
|
22
|
+
semantics); Escape clears the query. The query is controllable via
|
|
23
|
+
`query` / `defaultQuery` / `onQueryChange`.
|
|
24
|
+
|
|
25
|
+
`Tree` gains controlled `focusedId` / `onFocusedIdChange` props and a
|
|
26
|
+
`manageDomFocus` prop so hosts (like `TreeCombobox`) can drive the active
|
|
27
|
+
item externally without `Tree` calling `.focus()` on treeitems.
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [5892f44]
|
|
32
|
+
- @sproutsocial/seeds-react-system-props@3.1.1
|
|
33
|
+
- @sproutsocial/seeds-react-icon@2.3.13
|
|
34
|
+
|
|
35
|
+
## 0.2.5
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [5114a32]
|
|
40
|
+
- @sproutsocial/seeds-react-theme@4.1.0
|
|
41
|
+
- @sproutsocial/seeds-react-icon@2.3.12
|
|
42
|
+
- @sproutsocial/seeds-react-mixins@4.3.7
|
|
43
|
+
|
|
44
|
+
## 0.2.4
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [132ef9d]
|
|
49
|
+
- Updated dependencies [132ef9d]
|
|
50
|
+
- @sproutsocial/seeds-react-theme@4.0.0
|
|
51
|
+
- @sproutsocial/seeds-react-system-props@3.1.0
|
|
52
|
+
- @sproutsocial/seeds-react-icon@2.3.11
|
|
53
|
+
- @sproutsocial/seeds-react-mixins@4.3.6
|
|
54
|
+
|
|
55
|
+
## 0.2.3
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- @sproutsocial/seeds-react-icon@2.3.10
|
|
60
|
+
|
|
61
|
+
## 0.2.2
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- Updated dependencies [47c62b3]
|
|
66
|
+
- @sproutsocial/seeds-react-theme@3.7.1
|
|
67
|
+
- @sproutsocial/seeds-react-icon@2.3.9
|
|
68
|
+
- @sproutsocial/seeds-react-mixins@4.3.5
|
|
69
|
+
|
|
70
|
+
## 0.2.1
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Updated dependencies [06da9c2]
|
|
75
|
+
- @sproutsocial/seeds-react-theme@3.7.0
|
|
76
|
+
- @sproutsocial/seeds-react-icon@2.3.8
|
|
77
|
+
- @sproutsocial/seeds-react-mixins@4.3.4
|
|
78
|
+
|
|
79
|
+
## 0.2.0
|
|
80
|
+
|
|
81
|
+
### Minor Changes
|
|
82
|
+
|
|
83
|
+
- d7d64ab: Add new `@sproutsocial/seeds-react-tree` package with two components that
|
|
84
|
+
implement the WAI-ARIA treeview pattern.
|
|
85
|
+
|
|
86
|
+
**Components**
|
|
87
|
+
|
|
88
|
+
- `Tree` — composition root. Owns expansion + selection state, manages a single
|
|
89
|
+
roving `tabindex`, and applies `role="tree"` with the correct ARIA wiring.
|
|
90
|
+
- `TreeItem` — branch (when children are provided) or leaf. Renders `role="treeitem"`
|
|
91
|
+
with `aria-level`, `aria-expanded`, `aria-selected` / `aria-checked`,
|
|
92
|
+
`aria-disabled`, and `aria-labelledby`. Disclosure chevron sits on the
|
|
93
|
+
trailing edge (accordion-style).
|
|
94
|
+
|
|
95
|
+
**Behavior**
|
|
96
|
+
|
|
97
|
+
- Selection modes: `"single"`, `"multiple"`, or `"none"` (controlled or uncontrolled).
|
|
98
|
+
- `selectableNodes` prop: `"all"` (default) or `"leaves"` — in `"leaves"` mode,
|
|
99
|
+
parents are pure containers (no selection indicator rendered, click toggles
|
|
100
|
+
expansion only).
|
|
101
|
+
- `renderSelectionIndicator` render-prop slot for radio/checkbox/check variants.
|
|
102
|
+
- Full keyboard model: `↑/↓`, `←/→`, `Home`, `End`, `Enter`, `Space`, `*`
|
|
103
|
+
(expand all siblings), and first-letter type-ahead.
|
|
104
|
+
- Inset focus ring so the focused row doesn't bleed into adjacent rows or the
|
|
105
|
+
expanded children below.
|
|
106
|
+
|
|
107
|
+
**Accessibility**
|
|
108
|
+
|
|
109
|
+
Follows the [WAI-ARIA APG treeview pattern 1b](https://www.w3.org/WAI/ARIA/apg/patterns/treeview/examples/treeview-1b/),
|
|
110
|
+
including correct event-target handling so ancestor `treeitem`s don't intercept
|
|
111
|
+
keyboard navigation from their descendants. Stories include a `SelectionReadout`
|
|
112
|
+
helper with `aria-live="polite"` for announcing changes.
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @sproutsocial/seeds-react-tree
|
|
2
|
+
|
|
3
|
+
A WAI-ARIA treeview component for the Seeds design system. Provides a primitive
|
|
4
|
+
`Tree` + `TreeItem` API plus a `TreeCombobox` wrapper that pairs the tree with
|
|
5
|
+
a `role="combobox"` input following the WAI-ARIA combobox pattern.
|
|
6
|
+
|
|
7
|
+
> Status: **under development.** Exported under the `./base` subpath
|
|
8
|
+
> (`@sproutsocial/seeds-react-tree/base`) and shown in Storybook under
|
|
9
|
+
> "Really Under Development / Tree".
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Tree, TreeItem } from "@sproutsocial/seeds-react-tree/base";
|
|
15
|
+
|
|
16
|
+
<Tree aria-label="Files" defaultExpanded={["src"]}>
|
|
17
|
+
<TreeItem id="src" label="src">
|
|
18
|
+
<TreeItem id="Button.tsx" label="Button.tsx" />
|
|
19
|
+
<TreeItem id="Modal.tsx" label="Modal.tsx" />
|
|
20
|
+
</TreeItem>
|
|
21
|
+
<TreeItem id="package.json" label="package.json" />
|
|
22
|
+
</Tree>;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
For the combobox variant:
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { TreeCombobox } from "@sproutsocial/seeds-react-tree/base";
|
|
29
|
+
|
|
30
|
+
<TreeCombobox
|
|
31
|
+
aria-label="Pick a collection"
|
|
32
|
+
items={collections}
|
|
33
|
+
selectionMode="single"
|
|
34
|
+
renderSelectionIndicator={radioIndicator}
|
|
35
|
+
/>;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Accessibility
|
|
39
|
+
|
|
40
|
+
The base `Tree` follows [WAI-ARIA APG Treeview pattern 1b](https://www.w3.org/WAI/ARIA/apg/patterns/treeview/examples/treeview-1b/):
|
|
41
|
+
|
|
42
|
+
- `role="tree"`, `role="treeitem"`, `role="group"`
|
|
43
|
+
- `aria-level`, `aria-expanded`, `aria-selected` / `aria-checked`, `aria-disabled`
|
|
44
|
+
- Single tab stop with roving `tabindex`
|
|
45
|
+
- Keyboard: `↑/↓ ← → Home End Enter Space *` + type-ahead first-letter
|
|
46
|
+
|
|
47
|
+
`TreeCombobox` follows the [combobox-autocomplete-list](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-list/) example, with a tree as the popup:
|
|
48
|
+
|
|
49
|
+
- `<input role="combobox" aria-expanded aria-controls aria-haspopup="tree" aria-autocomplete="list" aria-activedescendant>`
|
|
50
|
+
- DOM focus stays on the input; the active treeitem is tracked via `aria-activedescendant`
|
|
51
|
+
- Keyboard on the input: `↑/↓ ← → Home End` move the active item, `Enter` toggles selection (or expansion for branches in `selectionMode="none"`), `Escape` clears a non-empty query
|