@xui/tree 2.0.0-alpha.11
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 +201 -0
- package/README.md +217 -0
- package/fesm2022/xui-tree.mjs +330 -0
- package/fesm2022/xui-tree.mjs.map +1 -0
- package/package.json +50 -0
- package/types/xui-tree.d.ts +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Rikarin
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
<p style="font-size: 5rem; font-weight: 700; text-align: center">
|
|
2
|
+
<span style="color: #1f75cb">x</span>UI
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
[](https://xuijs.org/)
|
|
9
|
+
[](https://www.npmjs.com/org/xui)
|
|
10
|
+
[](/LICENSE)
|
|
11
|
+
[](https://app.netlify.com/sites/xui/deploys)
|
|
12
|
+
|
|
13
|
+
xUI is a customizable Angular 22 UI Library with full support of TailwindCSS styling based on popular React library ShardCN and its Angular alternative SpartanUI.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **35+ High-Quality Angular Components:** Ready to use out of the box.
|
|
18
|
+
- **Powerful Theme Customization:** Detailed customization options with default themes.
|
|
19
|
+
- **High Performance:** Supports Zoneless, OnPush mode, and Signals for optimized performance.
|
|
20
|
+
- **Accessibility:** Supports WCAG 2.0 standards.
|
|
21
|
+
- **Powerful Theme Customization:** Install each visual component and customize it according your needs
|
|
22
|
+
- **TypeScript:** Written with predictable static types.
|
|
23
|
+
|
|
24
|
+
## Table of Contents
|
|
25
|
+
|
|
26
|
+
- [Storybook](https://develop--67d2b4c756077a325913e5d9.chromatic.com/?globals=theme:dark)
|
|
27
|
+
- [StackBlitz Demo](https://stackblitz.com/fork/xui)
|
|
28
|
+
- [Documentation](https://xuijs.org)
|
|
29
|
+
- [Live Demo](https://cord.dj/r)
|
|
30
|
+
- [Packages](#packages)
|
|
31
|
+
- [Installation](#installation)
|
|
32
|
+
- [Browser Support](#browser-support)
|
|
33
|
+
- [Development](#development)
|
|
34
|
+
- [Issues](#issues)
|
|
35
|
+
- [Roadmap](#roadmap)
|
|
36
|
+
|
|
37
|
+
## Packages
|
|
38
|
+
|
|
39
|
+
| Package | Usage | Description |
|
|
40
|
+
| ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
|
|
41
|
+
| Core | [](https://www.npmjs.com/package/%40xui/core)<br />[](https://www.npmjs.com/package/%40xui/core)<br />[](https://bundlephobia.com/result?p=%40xui/core) | Core package required by all other packages |
|
|
42
|
+
| Badge | [](https://www.npmjs.com/package/%40xui/badge)<br />[](https://www.npmjs.com/package/%40xui/badge)<br />[](https://bundlephobia.com/result?p=%40xui/badge) | Badge component |
|
|
43
|
+
| Breadcrumb | [](https://www.npmjs.com/package/%40xui/breadcrumb)<br />[](https://www.npmjs.com/package/%40xui/breadcrumb)<br />[](https://bundlephobia.com/result?p=%40xui/breadcrumb) | Breadcrumb component |
|
|
44
|
+
| Button | [](https://www.npmjs.com/package/%40xui/button)<br />[](https://www.npmjs.com/package/%40xui/button)<br />[](https://bundlephobia.com/result?p=%40xui/button) | Button component |
|
|
45
|
+
| Button Group | [](https://www.npmjs.com/package/%40xui/button-group)<br />[](https://www.npmjs.com/package/%40xui/button-group)<br />[](https://bundlephobia.com/result?p=%40xui/button-group) | Button Group component |
|
|
46
|
+
| Checkbox | [](https://www.npmjs.com/package/%40xui/checkbox)<br />[](https://www.npmjs.com/package/%40xui/checkbox)<br />[](https://bundlephobia.com/result?p=%40xui/checkbox) | Checkbox component |
|
|
47
|
+
| Form Field | [](https://www.npmjs.com/package/%40xui/form-field)<br />[](https://www.npmjs.com/package/%40xui/form-field)<br />[](https://bundlephobia.com/result?p=%40xui/form-field) | Form Field component |
|
|
48
|
+
| Icon | [](https://www.npmjs.com/package/%40xui/icon)<br />[](https://www.npmjs.com/package/%40xui/icon)<br />[](https://bundlephobia.com/result?p=%40xui/icon) | Icon component |
|
|
49
|
+
| Input | [](https://www.npmjs.com/package/%40xui/input)<br />[](https://www.npmjs.com/package/%40xui/input)<br />[](https://bundlephobia.com/result?p=%40xui/input) | Input component |
|
|
50
|
+
| Label | [](https://www.npmjs.com/package/%40xui/label)<br />[](https://www.npmjs.com/package/%40xui/label)<br />[](https://bundlephobia.com/result?p=%40xui/label) | Label component |
|
|
51
|
+
| Skeleton | [](https://www.npmjs.com/package/%40xui/skeleton)<br />[](https://www.npmjs.com/package/%40xui/skeleton)<br />[](https://bundlephobia.com/result?p=%40xui/skeleton) | Skeleton component |
|
|
52
|
+
| Spinner | [](https://www.npmjs.com/package/%40xui/spinner)<br />[](https://www.npmjs.com/package/%40xui/spinner)<br />[](https://bundlephobia.com/result?p=%40xui/spinner) | Spinner component |
|
|
53
|
+
| Status | [](https://www.npmjs.com/package/%40xui/status)<br />[](https://www.npmjs.com/package/%40xui/status)<br />[](https://bundlephobia.com/result?p=%40xui/status) | Status component |
|
|
54
|
+
| Table | [](https://www.npmjs.com/package/%40xui/table)<br />[](https://www.npmjs.com/package/%40xui/table)<br />[](https://bundlephobia.com/result?p=%40xui/table) | Table component |
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
Install package with **PNPM**
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pnpm i @xui/core ....
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Theming
|
|
65
|
+
|
|
66
|
+
Every `@xui/*` component styles itself with semantic Tailwind utilities — `bg-surface`,
|
|
67
|
+
`text-foreground-muted`, `border-error-muted` — that resolve through the token layer shipped with
|
|
68
|
+
`@xui/core`. Import it once, after Tailwind:
|
|
69
|
+
|
|
70
|
+
```css
|
|
71
|
+
@import 'tailwindcss';
|
|
72
|
+
@import '@xui/core/styles/theme.css';
|
|
73
|
+
|
|
74
|
+
/* Only needed if you use an overlay surface — popover, tooltip, menu, dialog,
|
|
75
|
+
drawer or toast. Without it overlays render in the document flow. */
|
|
76
|
+
@import '@angular/cdk/overlay-prebuilt.css';
|
|
77
|
+
|
|
78
|
+
/* Tell Tailwind to scan the component sources for utility classes. */
|
|
79
|
+
@source '../node_modules/@xui';
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Switch themes by putting `.dark` (or `[data-theme='dark']`) on `<html>`; with neither class
|
|
83
|
+
present the theme follows `prefers-color-scheme`. Both selectors also work on any element, so a
|
|
84
|
+
subtree can render in the opposite theme.
|
|
85
|
+
|
|
86
|
+
Re-theme by overriding tokens after the import — the `darker` / `lighter` / `subtle` / `muted` /
|
|
87
|
+
`emphasis` steps of each intent are derived, so one declaration re-colours the whole ramp:
|
|
88
|
+
|
|
89
|
+
```css
|
|
90
|
+
:root {
|
|
91
|
+
--primary: var(--color-violet-600);
|
|
92
|
+
--surface-inset: var(--color-zinc-50);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The full token reference, rendered in both themes, is the **Design Tokens** page in
|
|
97
|
+
[Storybook](https://develop--67d2b4c756077a325913e5d9.chromatic.com/?globals=theme:dark).
|
|
98
|
+
|
|
99
|
+
## Browser Support
|
|
100
|
+
|
|
101
|
+
xUI Supports most recent browsers according to Angular [support](https://angular.io/guide/browser-support).
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
The project uses `NX` and `Angular` to build the package.
|
|
106
|
+
|
|
107
|
+
To start docs page use
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pnpm start
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
To start storybook use
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
pnpm storybook
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## AI coding agents
|
|
120
|
+
|
|
121
|
+
Two pieces of tooling teach coding agents how to build with xUI.
|
|
122
|
+
|
|
123
|
+
**MCP server** — [`@xui/mcp`](https://github.com/Rikarin/xui/blob/HEAD/libs/mcp/README.md) exposes every package's real API (selectors,
|
|
124
|
+
signal inputs, variant axes, outputs), the design tokens, the docs and the Storybook examples as
|
|
125
|
+
MCP tools. It extracts them from the library sources, so all ~90 packages are covered and the
|
|
126
|
+
answers match the installed version.
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"mcpServers": {
|
|
131
|
+
"xui": { "command": "npx", "args": ["-y", "@xui/mcp"] }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
In this repo, `.mcp.json` already points at `dist/libs/mcp/src/server.js` — run `pnpm nx build mcp`
|
|
137
|
+
once so it exists.
|
|
138
|
+
|
|
139
|
+
**Skill** — [`skills/xui`](https://github.com/Rikarin/xui/blob/HEAD/skills/xui/SKILL.md) is the procedural knowledge: the three-layer
|
|
140
|
+
architecture, discovery through the MCP server, composition and styling rules, theming, the
|
|
141
|
+
generators, and the conventions for authoring a package inside the monorepo. `.claude/skills/xui`
|
|
142
|
+
links to it for agents working in this repository.
|
|
143
|
+
|
|
144
|
+
## Issues
|
|
145
|
+
|
|
146
|
+
If you find any issues in the library or have and idea for an improvement feel free to open an [issue](https://github.com/Rikarin/xui/issues).
|
|
147
|
+
|
|
148
|
+
## Roadmap
|
|
149
|
+
|
|
150
|
+
- [ ] Accordion
|
|
151
|
+
- [ ] Alert
|
|
152
|
+
- [ ] Alert Dialog
|
|
153
|
+
- [ ] Avatar
|
|
154
|
+
- [ ] Calendar
|
|
155
|
+
- [ ] Card
|
|
156
|
+
- [ ] Carousel
|
|
157
|
+
- [ ] Collapsible
|
|
158
|
+
- [ ] Combobox
|
|
159
|
+
- [ ] Command
|
|
160
|
+
- [ ] Date Picker
|
|
161
|
+
- [ ] Date Range Picker
|
|
162
|
+
- [ ] Dialog
|
|
163
|
+
- [ ] Hover Card
|
|
164
|
+
- [ ] Menu
|
|
165
|
+
- [ ] Pagination
|
|
166
|
+
- [ ] Popover
|
|
167
|
+
- [ ] Progress
|
|
168
|
+
- [ ] Radio Group
|
|
169
|
+
- [ ] Scroll Area
|
|
170
|
+
- [ ] Select
|
|
171
|
+
- [ ] Separator
|
|
172
|
+
- [ ] Sheet
|
|
173
|
+
- [ ] Slider
|
|
174
|
+
- [ ] Switch
|
|
175
|
+
- [ ] Tabs
|
|
176
|
+
- [ ] Toggle
|
|
177
|
+
- [ ] Tooltip
|
|
178
|
+
- [ ] Typography
|
|
179
|
+
- [ ] Input OTP
|
|
180
|
+
- [ ] Toggle Group
|
|
181
|
+
|
|
182
|
+
### Additional
|
|
183
|
+
|
|
184
|
+
- [ ] Decagram
|
|
185
|
+
- [ ] Settings
|
|
186
|
+
- [ ] Drawer
|
|
187
|
+
- [ ] Panel Bar
|
|
188
|
+
- [ ] Textarea
|
|
189
|
+
- [ ] Time Picker
|
|
190
|
+
- [ ] Image Upload
|
|
191
|
+
- [ ] Banner
|
|
192
|
+
- [ ] Snack bar
|
|
193
|
+
|
|
194
|
+
## Opinionated "components"
|
|
195
|
+
|
|
196
|
+
- [ ] Graph View (Nodes)
|
|
197
|
+
- [ ] Analysis
|
|
198
|
+
- [ ] Charts (NG Charts?)
|
|
199
|
+
|
|
200
|
+
## CLI
|
|
201
|
+
|
|
202
|
+
Make cli to install the components
|
|
203
|
+
|
|
204
|
+
## TODO
|
|
205
|
+
|
|
206
|
+
- Button
|
|
207
|
+
|
|
208
|
+
- Icon
|
|
209
|
+
- Shine
|
|
210
|
+
|
|
211
|
+
- Breadcrumb
|
|
212
|
+
|
|
213
|
+
- fix styling issues
|
|
214
|
+
- on hover stuff
|
|
215
|
+
- data driven component
|
|
216
|
+
|
|
217
|
+
- adjust generator to generate stories into the apps/storybook
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, ElementRef, input, model, output, signal, computed, effect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
import { provideIcons, NgIcon } from '@ng-icons/core';
|
|
5
|
+
import { matChevronRightRound } from '@ng-icons/material-icons/round';
|
|
6
|
+
import { xui } from '@xui/core';
|
|
7
|
+
import { injectXDirection, arrowDirectionOnAxis } from '@xui/core/a11y';
|
|
8
|
+
import { XuiIcon } from '@xui/icon';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A hierarchical tree of {@link XuiTreeNode}s with expand/collapse carets, single
|
|
12
|
+
* selection, optional icons and secondary labels, and full keyboard support
|
|
13
|
+
* (Up/Down move, Right/Left expand/collapse or step in/out, Enter/Space select).
|
|
14
|
+
*/
|
|
15
|
+
class XuiTree {
|
|
16
|
+
host = inject(ElementRef);
|
|
17
|
+
direction = injectXDirection();
|
|
18
|
+
class = input('', /* @ts-ignore */
|
|
19
|
+
...(ngDevMode ? [{ debugName: "class" }] : /* istanbul ignore next */ []));
|
|
20
|
+
ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: 'aria-label' });
|
|
21
|
+
nodes = input([], /* @ts-ignore */
|
|
22
|
+
...(ngDevMode ? [{ debugName: "nodes" }] : /* istanbul ignore next */ []));
|
|
23
|
+
/** The selected node id. Two-way bindable with `[(selectedId)]`. */
|
|
24
|
+
selectedId = model(null, /* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [{ debugName: "selectedId" }] : /* istanbul ignore next */ []));
|
|
26
|
+
nodeClick = output();
|
|
27
|
+
nodeExpanded = output();
|
|
28
|
+
nodeCollapsed = output();
|
|
29
|
+
expanded = signal(new Set(), /* @ts-ignore */
|
|
30
|
+
...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
31
|
+
focusedId = signal(null, /* @ts-ignore */
|
|
32
|
+
...(ngDevMode ? [{ debugName: "focusedId" }] : /* istanbul ignore next */ []));
|
|
33
|
+
computedClass = computed(() => xui('block text-sm select-none', this.class()), /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "computedClass" }] : /* istanbul ignore next */ []));
|
|
35
|
+
/** Every node flattened in visual (depth-first) order, respecting expansion. */
|
|
36
|
+
visible = computed(() => {
|
|
37
|
+
const out = [];
|
|
38
|
+
const walk = (list, level, parentId) => {
|
|
39
|
+
for (const node of list) {
|
|
40
|
+
const expandable = this.isExpandable(node);
|
|
41
|
+
out.push({ node, level, parentId, expandable });
|
|
42
|
+
if (expandable && this.expanded().has(node.id)) {
|
|
43
|
+
walk(node.childNodes ?? [], level + 1, node.id);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
walk(this.nodes(), 0, null);
|
|
48
|
+
return out;
|
|
49
|
+
}, /* @ts-ignore */
|
|
50
|
+
...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
51
|
+
constructor() {
|
|
52
|
+
// Seed expansion from each node's `isExpanded` flag, and the initial focus.
|
|
53
|
+
effect(() => {
|
|
54
|
+
const nodes = this.nodes();
|
|
55
|
+
untracked(() => {
|
|
56
|
+
const set = new Set();
|
|
57
|
+
const seed = (list) => {
|
|
58
|
+
for (const n of list) {
|
|
59
|
+
if (n.isExpanded) {
|
|
60
|
+
set.add(n.id);
|
|
61
|
+
}
|
|
62
|
+
if (n.childNodes) {
|
|
63
|
+
seed(n.childNodes);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
seed(nodes);
|
|
68
|
+
this.expanded.set(set);
|
|
69
|
+
if (this.focusedId() == null && nodes.length) {
|
|
70
|
+
this.focusedId.set(nodes[0].id);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
isExpandable(node) {
|
|
76
|
+
return !!node.hasCaret || !!node.childNodes?.length;
|
|
77
|
+
}
|
|
78
|
+
isExpanded(node) {
|
|
79
|
+
return this.expanded().has(node.id);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The expand caret. It is drawn pointing right, so a collapsed node has to be
|
|
83
|
+
* flipped in RTL to keep pointing "further in"; expanded always points down.
|
|
84
|
+
*/
|
|
85
|
+
caretClass(expanded) {
|
|
86
|
+
return xui('transition-transform', expanded ? 'rotate-90' : this.direction() === 'rtl' && 'rotate-180');
|
|
87
|
+
}
|
|
88
|
+
rowClass(node) {
|
|
89
|
+
return xui('flex items-center gap-1.5 rounded py-1 pe-2 transition-colors', node.disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer hover:bg-surface-inset/60', 'focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-focus', node.id === this.selectedId() && 'bg-primary/10 text-primary');
|
|
90
|
+
}
|
|
91
|
+
toggle(node) {
|
|
92
|
+
if (node.disabled || !this.isExpandable(node)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const set = new Set(this.expanded());
|
|
96
|
+
if (set.has(node.id)) {
|
|
97
|
+
set.delete(node.id);
|
|
98
|
+
this.nodeCollapsed.emit(node);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
set.add(node.id);
|
|
102
|
+
this.nodeExpanded.emit(node);
|
|
103
|
+
}
|
|
104
|
+
this.expanded.set(set);
|
|
105
|
+
}
|
|
106
|
+
expand(node) {
|
|
107
|
+
if (!this.isExpanded(node)) {
|
|
108
|
+
this.toggle(node);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
collapse(node) {
|
|
112
|
+
if (this.isExpanded(node)) {
|
|
113
|
+
this.toggle(node);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
onRowClick(node) {
|
|
117
|
+
if (node.disabled) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.focusedId.set(node.id);
|
|
121
|
+
this.selectedId.set(node.id);
|
|
122
|
+
this.nodeClick.emit(node);
|
|
123
|
+
}
|
|
124
|
+
onKeydown(event, node) {
|
|
125
|
+
const flat = this.visible();
|
|
126
|
+
const index = flat.findIndex(f => f.node.id === node.id);
|
|
127
|
+
// Expanding walks *into* the tree, which is the inline-end arrow — ArrowLeft
|
|
128
|
+
// in RTL. Collapsing walks back out.
|
|
129
|
+
const inline = arrowDirectionOnAxis(event.key, this.direction(), 'horizontal');
|
|
130
|
+
if (inline === 'next') {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
if (this.isExpandable(node) && !this.isExpanded(node)) {
|
|
133
|
+
this.expand(node);
|
|
134
|
+
}
|
|
135
|
+
else if (this.isExpandable(node)) {
|
|
136
|
+
this.focusIndex(index + 1); // step into the first child
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (inline === 'previous') {
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
if (this.isExpandable(node) && this.isExpanded(node)) {
|
|
143
|
+
this.collapse(node);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
// Step out to the parent.
|
|
147
|
+
const parentId = flat[index]?.parentId;
|
|
148
|
+
const parentIndex = flat.findIndex(f => f.node.id === parentId);
|
|
149
|
+
if (parentIndex >= 0) {
|
|
150
|
+
this.focusIndex(parentIndex);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
switch (event.key) {
|
|
156
|
+
case 'ArrowDown':
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
this.focusIndex(index + 1);
|
|
159
|
+
break;
|
|
160
|
+
case 'ArrowUp':
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
this.focusIndex(index - 1);
|
|
163
|
+
break;
|
|
164
|
+
case 'Home':
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
this.focusIndex(0);
|
|
167
|
+
break;
|
|
168
|
+
case 'End':
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
this.focusIndex(flat.length - 1);
|
|
171
|
+
break;
|
|
172
|
+
case 'Enter':
|
|
173
|
+
case ' ':
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
this.onRowClick(node);
|
|
176
|
+
break;
|
|
177
|
+
default:
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
focusIndex(index) {
|
|
182
|
+
const flat = this.visible();
|
|
183
|
+
const target = flat[Math.max(0, Math.min(flat.length - 1, index))];
|
|
184
|
+
if (!target) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
this.focusedId.set(target.node.id);
|
|
188
|
+
// Roving tabindex updates on the next tick; move DOM focus to the row.
|
|
189
|
+
queueMicrotask(() => {
|
|
190
|
+
this.host.nativeElement.querySelector(`[data-node-id="${target.node.id}"]`)?.focus();
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: XuiTree, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
194
|
+
/** @nocollapse */ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: XuiTree, isStandalone: true, selector: "xui-tree", inputs: { class: { classPropertyName: "class", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, nodes: { classPropertyName: "nodes", publicName: "nodes", isSignal: true, isRequired: false, transformFunction: null }, selectedId: { classPropertyName: "selectedId", publicName: "selectedId", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedId: "selectedIdChange", nodeClick: "nodeClick", nodeExpanded: "nodeExpanded", nodeCollapsed: "nodeCollapsed" }, host: { properties: { "class": "computedClass()" } }, ngImport: i0, template: `
|
|
195
|
+
<ng-template #nodeTpl let-node let-level="level">
|
|
196
|
+
<li
|
|
197
|
+
role="treeitem"
|
|
198
|
+
[attr.aria-expanded]="isExpandable(node) ? isExpanded(node) : null"
|
|
199
|
+
[attr.aria-selected]="node.id === selectedId()"
|
|
200
|
+
>
|
|
201
|
+
<div
|
|
202
|
+
[class]="rowClass(node)"
|
|
203
|
+
[style.padding-inline-start.rem]="0.5 + level * 1.25"
|
|
204
|
+
[attr.data-node-id]="node.id"
|
|
205
|
+
[tabindex]="node.id === focusedId() ? 0 : -1"
|
|
206
|
+
(click)="onRowClick(node)"
|
|
207
|
+
(keydown)="onKeydown($event, node)"
|
|
208
|
+
>
|
|
209
|
+
<span class="flex size-5 shrink-0 items-center justify-center">
|
|
210
|
+
@if (isExpandable(node)) {
|
|
211
|
+
<ng-icon
|
|
212
|
+
xui
|
|
213
|
+
name="matChevronRightRound"
|
|
214
|
+
size="sm"
|
|
215
|
+
[class]="caretClass(isExpanded(node))"
|
|
216
|
+
(click)="toggle(node); $event.stopPropagation()"
|
|
217
|
+
/>
|
|
218
|
+
}
|
|
219
|
+
</span>
|
|
220
|
+
|
|
221
|
+
@if (node.icon) {
|
|
222
|
+
<ng-icon xui [name]="node.icon" size="sm" class="text-foreground-muted shrink-0" />
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
<span class="flex-1 truncate">{{ node.label }}</span>
|
|
226
|
+
|
|
227
|
+
@if (node.secondaryLabel) {
|
|
228
|
+
<span class="text-foreground-muted ms-2 shrink-0 text-xs">{{ node.secondaryLabel }}</span>
|
|
229
|
+
}
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
@if (isExpandable(node) && isExpanded(node)) {
|
|
233
|
+
<ul role="group" class="m-0 list-none p-0">
|
|
234
|
+
@for (child of node.childNodes ?? []; track child.id) {
|
|
235
|
+
<ng-container
|
|
236
|
+
[ngTemplateOutlet]="nodeTpl"
|
|
237
|
+
[ngTemplateOutletContext]="{ $implicit: child, level: level + 1 }"
|
|
238
|
+
/>
|
|
239
|
+
}
|
|
240
|
+
</ul>
|
|
241
|
+
}
|
|
242
|
+
</li>
|
|
243
|
+
</ng-template>
|
|
244
|
+
|
|
245
|
+
<ul role="tree" class="m-0 list-none p-0" [attr.aria-label]="ariaLabel()">
|
|
246
|
+
@for (node of nodes(); track node.id) {
|
|
247
|
+
<ng-container [ngTemplateOutlet]="nodeTpl" [ngTemplateOutletContext]="{ $implicit: node, level: 0 }" />
|
|
248
|
+
}
|
|
249
|
+
</ul>
|
|
250
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: NgIcon, selector: "ng-icon", inputs: ["name", "svg", "size", "strokeWidth", "color"] }, { kind: "directive", type: XuiIcon, selector: "ng-icon[xui]", inputs: ["class", "size", "color", "title"], exportAs: ["xuiIcon"] }], viewProviders: [provideIcons({ matChevronRightRound })], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
251
|
+
}
|
|
252
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: XuiTree, decorators: [{
|
|
253
|
+
type: Component,
|
|
254
|
+
args: [{
|
|
255
|
+
selector: 'xui-tree',
|
|
256
|
+
imports: [NgTemplateOutlet, NgIcon, XuiIcon],
|
|
257
|
+
template: `
|
|
258
|
+
<ng-template #nodeTpl let-node let-level="level">
|
|
259
|
+
<li
|
|
260
|
+
role="treeitem"
|
|
261
|
+
[attr.aria-expanded]="isExpandable(node) ? isExpanded(node) : null"
|
|
262
|
+
[attr.aria-selected]="node.id === selectedId()"
|
|
263
|
+
>
|
|
264
|
+
<div
|
|
265
|
+
[class]="rowClass(node)"
|
|
266
|
+
[style.padding-inline-start.rem]="0.5 + level * 1.25"
|
|
267
|
+
[attr.data-node-id]="node.id"
|
|
268
|
+
[tabindex]="node.id === focusedId() ? 0 : -1"
|
|
269
|
+
(click)="onRowClick(node)"
|
|
270
|
+
(keydown)="onKeydown($event, node)"
|
|
271
|
+
>
|
|
272
|
+
<span class="flex size-5 shrink-0 items-center justify-center">
|
|
273
|
+
@if (isExpandable(node)) {
|
|
274
|
+
<ng-icon
|
|
275
|
+
xui
|
|
276
|
+
name="matChevronRightRound"
|
|
277
|
+
size="sm"
|
|
278
|
+
[class]="caretClass(isExpanded(node))"
|
|
279
|
+
(click)="toggle(node); $event.stopPropagation()"
|
|
280
|
+
/>
|
|
281
|
+
}
|
|
282
|
+
</span>
|
|
283
|
+
|
|
284
|
+
@if (node.icon) {
|
|
285
|
+
<ng-icon xui [name]="node.icon" size="sm" class="text-foreground-muted shrink-0" />
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
<span class="flex-1 truncate">{{ node.label }}</span>
|
|
289
|
+
|
|
290
|
+
@if (node.secondaryLabel) {
|
|
291
|
+
<span class="text-foreground-muted ms-2 shrink-0 text-xs">{{ node.secondaryLabel }}</span>
|
|
292
|
+
}
|
|
293
|
+
</div>
|
|
294
|
+
|
|
295
|
+
@if (isExpandable(node) && isExpanded(node)) {
|
|
296
|
+
<ul role="group" class="m-0 list-none p-0">
|
|
297
|
+
@for (child of node.childNodes ?? []; track child.id) {
|
|
298
|
+
<ng-container
|
|
299
|
+
[ngTemplateOutlet]="nodeTpl"
|
|
300
|
+
[ngTemplateOutletContext]="{ $implicit: child, level: level + 1 }"
|
|
301
|
+
/>
|
|
302
|
+
}
|
|
303
|
+
</ul>
|
|
304
|
+
}
|
|
305
|
+
</li>
|
|
306
|
+
</ng-template>
|
|
307
|
+
|
|
308
|
+
<ul role="tree" class="m-0 list-none p-0" [attr.aria-label]="ariaLabel()">
|
|
309
|
+
@for (node of nodes(); track node.id) {
|
|
310
|
+
<ng-container [ngTemplateOutlet]="nodeTpl" [ngTemplateOutletContext]="{ $implicit: node, level: 0 }" />
|
|
311
|
+
}
|
|
312
|
+
</ul>
|
|
313
|
+
`,
|
|
314
|
+
host: {
|
|
315
|
+
'[class]': 'computedClass()'
|
|
316
|
+
},
|
|
317
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
318
|
+
encapsulation: ViewEncapsulation.None,
|
|
319
|
+
viewProviders: [provideIcons({ matChevronRightRound })]
|
|
320
|
+
}]
|
|
321
|
+
}], ctorParameters: () => [], propDecorators: { class: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], nodes: [{ type: i0.Input, args: [{ isSignal: true, alias: "nodes", required: false }] }], selectedId: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedId", required: false }] }, { type: i0.Output, args: ["selectedIdChange"] }], nodeClick: [{ type: i0.Output, args: ["nodeClick"] }], nodeExpanded: [{ type: i0.Output, args: ["nodeExpanded"] }], nodeCollapsed: [{ type: i0.Output, args: ["nodeCollapsed"] }] } });
|
|
322
|
+
|
|
323
|
+
const XuiTreeImports = [XuiTree];
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Generated bundle index. Do not edit.
|
|
327
|
+
*/
|
|
328
|
+
|
|
329
|
+
export { XuiTree, XuiTreeImports };
|
|
330
|
+
//# sourceMappingURL=xui-tree.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xui-tree.mjs","sources":["../../../../../../libs/ui/tree/xui/src/lib/tree.ts","../../../../../../libs/ui/tree/xui/src/index.ts","../../../../../../libs/ui/tree/xui/src/xui-tree.ts"],"sourcesContent":["import { NgTemplateOutlet } from '@angular/common';\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n effect,\n ElementRef,\n inject,\n input,\n model,\n output,\n signal,\n untracked,\n ViewEncapsulation\n} from '@angular/core';\nimport { NgIcon, provideIcons } from '@ng-icons/core';\nimport { matChevronRightRound } from '@ng-icons/material-icons/round';\nimport { xui } from '@xui/core';\nimport { arrowDirectionOnAxis, injectXDirection } from '@xui/core/a11y';\nimport { XuiIcon } from '@xui/icon';\nimport type { ClassValue } from 'clsx';\nimport type { XuiTreeNode } from './tree.types';\n\ninterface FlatNode {\n node: XuiTreeNode;\n level: number;\n parentId: string | number | null;\n expandable: boolean;\n}\n\n/**\n * A hierarchical tree of {@link XuiTreeNode}s with expand/collapse carets, single\n * selection, optional icons and secondary labels, and full keyboard support\n * (Up/Down move, Right/Left expand/collapse or step in/out, Enter/Space select).\n */\n@Component({\n selector: 'xui-tree',\n imports: [NgTemplateOutlet, NgIcon, XuiIcon],\n template: `\n <ng-template #nodeTpl let-node let-level=\"level\">\n <li\n role=\"treeitem\"\n [attr.aria-expanded]=\"isExpandable(node) ? isExpanded(node) : null\"\n [attr.aria-selected]=\"node.id === selectedId()\"\n >\n <div\n [class]=\"rowClass(node)\"\n [style.padding-inline-start.rem]=\"0.5 + level * 1.25\"\n [attr.data-node-id]=\"node.id\"\n [tabindex]=\"node.id === focusedId() ? 0 : -1\"\n (click)=\"onRowClick(node)\"\n (keydown)=\"onKeydown($event, node)\"\n >\n <span class=\"flex size-5 shrink-0 items-center justify-center\">\n @if (isExpandable(node)) {\n <ng-icon\n xui\n name=\"matChevronRightRound\"\n size=\"sm\"\n [class]=\"caretClass(isExpanded(node))\"\n (click)=\"toggle(node); $event.stopPropagation()\"\n />\n }\n </span>\n\n @if (node.icon) {\n <ng-icon xui [name]=\"node.icon\" size=\"sm\" class=\"text-foreground-muted shrink-0\" />\n }\n\n <span class=\"flex-1 truncate\">{{ node.label }}</span>\n\n @if (node.secondaryLabel) {\n <span class=\"text-foreground-muted ms-2 shrink-0 text-xs\">{{ node.secondaryLabel }}</span>\n }\n </div>\n\n @if (isExpandable(node) && isExpanded(node)) {\n <ul role=\"group\" class=\"m-0 list-none p-0\">\n @for (child of node.childNodes ?? []; track child.id) {\n <ng-container\n [ngTemplateOutlet]=\"nodeTpl\"\n [ngTemplateOutletContext]=\"{ $implicit: child, level: level + 1 }\"\n />\n }\n </ul>\n }\n </li>\n </ng-template>\n\n <ul role=\"tree\" class=\"m-0 list-none p-0\" [attr.aria-label]=\"ariaLabel()\">\n @for (node of nodes(); track node.id) {\n <ng-container [ngTemplateOutlet]=\"nodeTpl\" [ngTemplateOutletContext]=\"{ $implicit: node, level: 0 }\" />\n }\n </ul>\n `,\n host: {\n '[class]': 'computedClass()'\n },\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n viewProviders: [provideIcons({ matChevronRightRound })]\n})\nexport class XuiTree {\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n protected readonly direction = injectXDirection();\n\n readonly class = input<ClassValue>('');\n readonly ariaLabel = input<string | null>(null, { alias: 'aria-label' });\n\n readonly nodes = input<XuiTreeNode[]>([]);\n\n /** The selected node id. Two-way bindable with `[(selectedId)]`. */\n readonly selectedId = model<string | number | null>(null);\n\n readonly nodeClick = output<XuiTreeNode>();\n readonly nodeExpanded = output<XuiTreeNode>();\n readonly nodeCollapsed = output<XuiTreeNode>();\n\n private readonly expanded = signal(new Set<string | number>());\n protected readonly focusedId = signal<string | number | null>(null);\n\n protected readonly computedClass = computed(() => xui('block text-sm select-none', this.class()));\n\n /** Every node flattened in visual (depth-first) order, respecting expansion. */\n private readonly visible = computed<FlatNode[]>(() => {\n const out: FlatNode[] = [];\n const walk = (list: XuiTreeNode[], level: number, parentId: string | number | null) => {\n for (const node of list) {\n const expandable = this.isExpandable(node);\n out.push({ node, level, parentId, expandable });\n if (expandable && this.expanded().has(node.id)) {\n walk(node.childNodes ?? [], level + 1, node.id);\n }\n }\n };\n walk(this.nodes(), 0, null);\n return out;\n });\n\n constructor() {\n // Seed expansion from each node's `isExpanded` flag, and the initial focus.\n effect(() => {\n const nodes = this.nodes();\n untracked(() => {\n const set = new Set<string | number>();\n const seed = (list: XuiTreeNode[]) => {\n for (const n of list) {\n if (n.isExpanded) {\n set.add(n.id);\n }\n if (n.childNodes) {\n seed(n.childNodes);\n }\n }\n };\n seed(nodes);\n this.expanded.set(set);\n if (this.focusedId() == null && nodes.length) {\n this.focusedId.set(nodes[0].id);\n }\n });\n });\n }\n\n protected isExpandable(node: XuiTreeNode): boolean {\n return !!node.hasCaret || !!node.childNodes?.length;\n }\n\n protected isExpanded(node: XuiTreeNode): boolean {\n return this.expanded().has(node.id);\n }\n\n /**\n * The expand caret. It is drawn pointing right, so a collapsed node has to be\n * flipped in RTL to keep pointing \"further in\"; expanded always points down.\n */\n protected caretClass(expanded: boolean): string {\n return xui('transition-transform', expanded ? 'rotate-90' : this.direction() === 'rtl' && 'rotate-180');\n }\n\n protected rowClass(node: XuiTreeNode): string {\n return xui(\n 'flex items-center gap-1.5 rounded py-1 pe-2 transition-colors',\n node.disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer hover:bg-surface-inset/60',\n 'focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-focus',\n node.id === this.selectedId() && 'bg-primary/10 text-primary'\n );\n }\n\n protected toggle(node: XuiTreeNode): void {\n if (node.disabled || !this.isExpandable(node)) {\n return;\n }\n\n const set = new Set(this.expanded());\n if (set.has(node.id)) {\n set.delete(node.id);\n this.nodeCollapsed.emit(node);\n } else {\n set.add(node.id);\n this.nodeExpanded.emit(node);\n }\n this.expanded.set(set);\n }\n\n private expand(node: XuiTreeNode): void {\n if (!this.isExpanded(node)) {\n this.toggle(node);\n }\n }\n\n private collapse(node: XuiTreeNode): void {\n if (this.isExpanded(node)) {\n this.toggle(node);\n }\n }\n\n protected onRowClick(node: XuiTreeNode): void {\n if (node.disabled) {\n return;\n }\n\n this.focusedId.set(node.id);\n this.selectedId.set(node.id);\n this.nodeClick.emit(node);\n }\n\n protected onKeydown(event: KeyboardEvent, node: XuiTreeNode): void {\n const flat = this.visible();\n const index = flat.findIndex(f => f.node.id === node.id);\n\n // Expanding walks *into* the tree, which is the inline-end arrow — ArrowLeft\n // in RTL. Collapsing walks back out.\n const inline = arrowDirectionOnAxis(event.key, this.direction(), 'horizontal');\n\n if (inline === 'next') {\n event.preventDefault();\n if (this.isExpandable(node) && !this.isExpanded(node)) {\n this.expand(node);\n } else if (this.isExpandable(node)) {\n this.focusIndex(index + 1); // step into the first child\n }\n return;\n }\n\n if (inline === 'previous') {\n event.preventDefault();\n if (this.isExpandable(node) && this.isExpanded(node)) {\n this.collapse(node);\n } else {\n // Step out to the parent.\n const parentId = flat[index]?.parentId;\n const parentIndex = flat.findIndex(f => f.node.id === parentId);\n if (parentIndex >= 0) {\n this.focusIndex(parentIndex);\n }\n }\n return;\n }\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.focusIndex(index + 1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.focusIndex(index - 1);\n break;\n case 'Home':\n event.preventDefault();\n this.focusIndex(0);\n break;\n case 'End':\n event.preventDefault();\n this.focusIndex(flat.length - 1);\n break;\n case 'Enter':\n case ' ':\n event.preventDefault();\n this.onRowClick(node);\n break;\n default:\n return;\n }\n }\n\n private focusIndex(index: number): void {\n const flat = this.visible();\n const target = flat[Math.max(0, Math.min(flat.length - 1, index))];\n if (!target) {\n return;\n }\n\n this.focusedId.set(target.node.id);\n // Roving tabindex updates on the next tick; move DOM focus to the row.\n queueMicrotask(() => {\n this.host.nativeElement.querySelector<HTMLElement>(`[data-node-id=\"${target.node.id}\"]`)?.focus();\n });\n }\n}\n","import { XuiTree } from './lib/tree';\n\nexport * from './lib/tree';\nexport * from './lib/tree.types';\n\nexport const XuiTreeImports = [XuiTree] as const;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AA8BA;;;;AAIG;MAoEU,OAAO,CAAA;AACD,IAAA,IAAI,GAAG,MAAM,CAA0B,UAAU,CAAC;IAChD,SAAS,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BAAA,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDT,EAAA,CAAA;AACD,oBAAA,IAAI,EAAE;AACJ,wBAAA,SAAS,EAAE;AACZ,qBAAA;oBACD,eAAe,EAAE,uBAAuB,CAAC,MAAM;oBAC/C,aAAa,EAAE,iBAAiB,CAAC,IAAI;oBACrC,aAAa,EAAE,CAAC,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;AACvD,iBAAA;;;AChGM,MAAM,cAAc,GAAG,CAAC,OAAO;;ACLtC;;AAEG;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xui/tree",
|
|
3
|
+
"version": "2.0.0-alpha.11",
|
|
4
|
+
"description": "Modern Angular 22 UI Library based on TailwindCSS",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"ui",
|
|
8
|
+
"components",
|
|
9
|
+
"tailwindcss"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://xuijs.org",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/rikarin/xui/issues"
|
|
14
|
+
},
|
|
15
|
+
"repository": "https://github.com/Rikarin/xui",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "Jiu",
|
|
18
|
+
"maintainers": [
|
|
19
|
+
"Jiu",
|
|
20
|
+
"Rikarin"
|
|
21
|
+
],
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
"./package.json": {
|
|
26
|
+
"default": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./types/xui-tree.d.ts",
|
|
30
|
+
"default": "./fesm2022/xui-tree.mjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"module": "fesm2022/xui-tree.mjs",
|
|
34
|
+
"typings": "types/xui-tree.d.ts",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"tslib": "^2.3.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@angular/common": "22",
|
|
40
|
+
"@angular/core": "22",
|
|
41
|
+
"@ng-icons/core": "34",
|
|
42
|
+
"@ng-icons/material-icons": "34",
|
|
43
|
+
"@xui/core": "2.0.0-alpha.11",
|
|
44
|
+
"@xui/icon": "2.0.0-alpha.11",
|
|
45
|
+
"clsx": "^2.1.1"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import * as _xui_core_a11y from '@xui/core/a11y';
|
|
3
|
+
import { ClassValue } from 'clsx';
|
|
4
|
+
|
|
5
|
+
/** A single node in a {@link XuiTree}. */
|
|
6
|
+
interface XuiTreeNode {
|
|
7
|
+
/** Stable identifier, unique across the whole tree. */
|
|
8
|
+
id: string | number;
|
|
9
|
+
/** Primary label text. */
|
|
10
|
+
label: string;
|
|
11
|
+
/** Muted text shown at the trailing edge of the row. */
|
|
12
|
+
secondaryLabel?: string;
|
|
13
|
+
/** Optional leading icon name (from the app's icon registry). */
|
|
14
|
+
icon?: string;
|
|
15
|
+
/** Child nodes; presence (or `hasCaret`) makes the node expandable. */
|
|
16
|
+
childNodes?: XuiTreeNode[];
|
|
17
|
+
/** Start expanded. */
|
|
18
|
+
isExpanded?: boolean;
|
|
19
|
+
/** Force a caret even without loaded children (e.g. lazy loading). */
|
|
20
|
+
hasCaret?: boolean;
|
|
21
|
+
/** Non-selectable, non-expandable. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Arbitrary payload echoed back on events. */
|
|
24
|
+
data?: unknown;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A hierarchical tree of {@link XuiTreeNode}s with expand/collapse carets, single
|
|
29
|
+
* selection, optional icons and secondary labels, and full keyboard support
|
|
30
|
+
* (Up/Down move, Right/Left expand/collapse or step in/out, Enter/Space select).
|
|
31
|
+
*/
|
|
32
|
+
declare class XuiTree {
|
|
33
|
+
private readonly host;
|
|
34
|
+
protected readonly direction: _angular_core.Signal<_xui_core_a11y.XDirection>;
|
|
35
|
+
readonly class: _angular_core.InputSignal<ClassValue>;
|
|
36
|
+
readonly ariaLabel: _angular_core.InputSignal<string | null>;
|
|
37
|
+
readonly nodes: _angular_core.InputSignal<XuiTreeNode[]>;
|
|
38
|
+
/** The selected node id. Two-way bindable with `[(selectedId)]`. */
|
|
39
|
+
readonly selectedId: _angular_core.ModelSignal<string | number | null>;
|
|
40
|
+
readonly nodeClick: _angular_core.OutputEmitterRef<XuiTreeNode>;
|
|
41
|
+
readonly nodeExpanded: _angular_core.OutputEmitterRef<XuiTreeNode>;
|
|
42
|
+
readonly nodeCollapsed: _angular_core.OutputEmitterRef<XuiTreeNode>;
|
|
43
|
+
private readonly expanded;
|
|
44
|
+
protected readonly focusedId: _angular_core.WritableSignal<string | number | null>;
|
|
45
|
+
protected readonly computedClass: _angular_core.Signal<string>;
|
|
46
|
+
/** Every node flattened in visual (depth-first) order, respecting expansion. */
|
|
47
|
+
private readonly visible;
|
|
48
|
+
constructor();
|
|
49
|
+
protected isExpandable(node: XuiTreeNode): boolean;
|
|
50
|
+
protected isExpanded(node: XuiTreeNode): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The expand caret. It is drawn pointing right, so a collapsed node has to be
|
|
53
|
+
* flipped in RTL to keep pointing "further in"; expanded always points down.
|
|
54
|
+
*/
|
|
55
|
+
protected caretClass(expanded: boolean): string;
|
|
56
|
+
protected rowClass(node: XuiTreeNode): string;
|
|
57
|
+
protected toggle(node: XuiTreeNode): void;
|
|
58
|
+
private expand;
|
|
59
|
+
private collapse;
|
|
60
|
+
protected onRowClick(node: XuiTreeNode): void;
|
|
61
|
+
protected onKeydown(event: KeyboardEvent, node: XuiTreeNode): void;
|
|
62
|
+
private focusIndex;
|
|
63
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<XuiTree, never>;
|
|
64
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<XuiTree, "xui-tree", never, { "class": { "alias": "class"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "nodes": { "alias": "nodes"; "required": false; "isSignal": true; }; "selectedId": { "alias": "selectedId"; "required": false; "isSignal": true; }; }, { "selectedId": "selectedIdChange"; "nodeClick": "nodeClick"; "nodeExpanded": "nodeExpanded"; "nodeCollapsed": "nodeCollapsed"; }, never, never, true, never>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
declare const XuiTreeImports: readonly [typeof XuiTree];
|
|
68
|
+
|
|
69
|
+
export { XuiTree, XuiTreeImports };
|
|
70
|
+
export type { XuiTreeNode };
|