@ignite-ember/ui-react 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +260 -2
- package/dist/CopySource.d.ts +4 -0
- package/dist/CopySource.d.ts.map +1 -0
- package/dist/CopySource.js +50 -0
- package/dist/CopySource.js.map +1 -0
- package/dist/DataTable.d.ts +77 -0
- package/dist/DataTable.d.ts.map +1 -0
- package/dist/DataTable.js +45 -0
- package/dist/DataTable.js.map +1 -0
- package/dist/Dialog.d.ts +41 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +94 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/ErrorBoundary.d.ts +97 -0
- package/dist/ErrorBoundary.d.ts.map +1 -0
- package/dist/ErrorBoundary.js +97 -0
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/LiveRegion.d.ts +41 -0
- package/dist/LiveRegion.d.ts.map +1 -0
- package/dist/LiveRegion.js +76 -0
- package/dist/LiveRegion.js.map +1 -0
- package/dist/Markdown.d.ts +22 -0
- package/dist/Markdown.d.ts.map +1 -0
- package/dist/Markdown.js +56 -0
- package/dist/Markdown.js.map +1 -0
- package/dist/MarkdownInline.d.ts +53 -0
- package/dist/MarkdownInline.d.ts.map +1 -0
- package/dist/MarkdownInline.js +159 -0
- package/dist/MarkdownInline.js.map +1 -0
- package/dist/MenuIcon.d.ts +60 -0
- package/dist/MenuIcon.d.ts.map +1 -0
- package/dist/MenuIcon.js +102 -0
- package/dist/MenuIcon.js.map +1 -0
- package/dist/Mermaid.d.ts +40 -0
- package/dist/Mermaid.d.ts.map +1 -0
- package/dist/Mermaid.js +121 -0
- package/dist/Mermaid.js.map +1 -0
- package/dist/Monogram.d.ts +46 -0
- package/dist/Monogram.d.ts.map +1 -0
- package/dist/Monogram.js +96 -0
- package/dist/Monogram.js.map +1 -0
- package/dist/OverflowMenu.d.ts +60 -0
- package/dist/OverflowMenu.d.ts.map +1 -0
- package/dist/OverflowMenu.js +149 -0
- package/dist/OverflowMenu.js.map +1 -0
- package/dist/Shell.d.ts +67 -0
- package/dist/Shell.d.ts.map +1 -0
- package/dist/Shell.js +44 -0
- package/dist/Shell.js.map +1 -0
- package/dist/Skeleton.d.ts +62 -0
- package/dist/Skeleton.d.ts.map +1 -0
- package/dist/Skeleton.js +56 -0
- package/dist/Skeleton.js.map +1 -0
- package/dist/Split.d.ts +85 -0
- package/dist/Split.d.ts.map +1 -0
- package/dist/Split.js +156 -0
- package/dist/Split.js.map +1 -0
- package/dist/Tabs.d.ts +77 -0
- package/dist/Tabs.d.ts.map +1 -0
- package/dist/Tabs.js +91 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Toast.d.ts +98 -0
- package/dist/Toast.d.ts.map +1 -0
- package/dist/Toast.js +129 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Tooltip.d.ts +24 -0
- package/dist/Tooltip.d.ts.map +1 -0
- package/dist/Tooltip.js +166 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/controls.d.ts +117 -0
- package/dist/controls.d.ts.map +1 -0
- package/dist/controls.js +59 -0
- package/dist/controls.js.map +1 -0
- package/dist/cx.d.ts +3 -0
- package/dist/cx.d.ts.map +1 -0
- package/dist/cx.js +5 -0
- package/dist/cx.js.map +1 -0
- package/dist/fenceInfo.d.ts +26 -0
- package/dist/fenceInfo.d.ts.map +1 -0
- package/dist/fenceInfo.js +22 -0
- package/dist/fenceInfo.js.map +1 -0
- package/dist/formControls.d.ts +143 -0
- package/dist/formControls.d.ts.map +1 -0
- package/dist/formControls.js +108 -0
- package/dist/formControls.js.map +1 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/layout.d.ts +95 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +93 -0
- package/dist/layout.js.map +1 -0
- package/dist/primitives.d.ts +33 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +33 -0
- package/dist/primitives.js.map +1 -0
- package/dist/progress.d.ts +64 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +51 -0
- package/dist/progress.js.map +1 -0
- package/dist/text.d.ts +63 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +61 -0
- package/dist/text.js.map +1 -0
- package/package.json +56 -4
- package/src/CopySource.tsx +67 -0
- package/src/DataTable.tsx +120 -0
- package/src/Dialog.tsx +158 -0
- package/src/ErrorBoundary.tsx +137 -0
- package/src/LiveRegion.tsx +127 -0
- package/src/Markdown.tsx +75 -0
- package/src/MarkdownInline.tsx +177 -0
- package/src/MenuIcon.tsx +209 -0
- package/src/Mermaid.tsx +144 -0
- package/src/Monogram.tsx +112 -0
- package/src/OverflowMenu.tsx +359 -0
- package/src/Shell.tsx +99 -0
- package/src/Skeleton.tsx +98 -0
- package/src/Split.tsx +267 -0
- package/src/Tabs.tsx +194 -0
- package/src/Toast.tsx +269 -0
- package/src/Tooltip.tsx +213 -0
- package/src/controls.tsx +159 -0
- package/src/cx.ts +4 -0
- package/src/fenceInfo.ts +36 -0
- package/src/formControls.tsx +249 -0
- package/src/index.ts +149 -0
- package/src/layout.tsx +141 -0
- package/src/primitives.tsx +33 -0
- package/src/progress.tsx +129 -0
- package/src/text.tsx +99 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,261 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@ignite-ember/ui-react`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Full documentation:** [igni.sh/docs/sdk/ui-react](https://igni.sh/docs/sdk/ui-react) — guides and the complete API reference, a page per topic.
|
|
4
|
+
|
|
5
|
+
The React components an igni extension is allowed to build on.
|
|
6
|
+
Everything exported here is under the compatibility floor: removing
|
|
7
|
+
one, renaming it, or changing a prop's meaning is a breaking change
|
|
8
|
+
under [`docs/EXTENSIBILITY.md`](https://github.com/ignite-ember/igni-core/blob/main/docs/EXTENSIBILITY.md) §8.
|
|
9
|
+
|
|
10
|
+
From npm, with the stylesheet it is drawn with:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @ignite-ember/ui-react @ignite-ember/ui-css
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { AppShell, Scroll, Table, Toolbar } from "@ignite-ember/ui-react";
|
|
18
|
+
import "@ignite-ember/ui-css";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
A page that fills its frame, with a toolbar, a scrolling list and a
|
|
24
|
+
footer:
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { createRoot } from "react-dom/client";
|
|
28
|
+
import { AppShell, Scroll, Toolbar, Button, Text, Empty } from "@ignite-ember/ui-react";
|
|
29
|
+
import { connect } from "@ignite-ember/extension-bridge";
|
|
30
|
+
import "@ignite-ember/ui-css";
|
|
31
|
+
|
|
32
|
+
interface Note {
|
|
33
|
+
id: string;
|
|
34
|
+
title: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function main() {
|
|
38
|
+
const bridge = await connect();
|
|
39
|
+
const notes = await bridge.rpc<Note[]>("ext.example.teamnotes.list");
|
|
40
|
+
|
|
41
|
+
createRoot(document.getElementById("root")!).render(
|
|
42
|
+
<AppShell
|
|
43
|
+
header={<Toolbar>Notes</Toolbar>}
|
|
44
|
+
footer={<Button variant="primary">New note</Button>}
|
|
45
|
+
>
|
|
46
|
+
<Scroll>
|
|
47
|
+
{notes.length === 0 ? (
|
|
48
|
+
<Empty>Nothing here yet.</Empty>
|
|
49
|
+
) : (
|
|
50
|
+
notes.map((note) => (
|
|
51
|
+
<Text key={note.id}>{note.title}</Text>
|
|
52
|
+
))
|
|
53
|
+
)}
|
|
54
|
+
</Scroll>
|
|
55
|
+
</AppShell>,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void main();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The page's `index.html` gives its body the `igni-root` class, holds
|
|
63
|
+
`<div id="root"></div>` and loads the built script from a file (an
|
|
64
|
+
extension's page may not run inline script):
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<!doctype html>
|
|
68
|
+
<html>
|
|
69
|
+
<body class="igni-root">
|
|
70
|
+
<div id="root"></div>
|
|
71
|
+
<script type="module" src="./main.js"></script>
|
|
72
|
+
</body>
|
|
73
|
+
</html>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`igni-root` is what puts the stylesheet's background, font and spacing on
|
|
77
|
+
the page; neither `connect()` nor `AppShell` adds it. Without it the page
|
|
78
|
+
renders unstyled — a transparent background, the browser's serif font, and
|
|
79
|
+
its 8px body margin, so the frame scrolls by 8px.
|
|
80
|
+
|
|
81
|
+
Three things to know before you write more:
|
|
82
|
+
|
|
83
|
+
- **Every component here is a thin wrapper over a class.** `Button` with
|
|
84
|
+
`variant="primary"` renders `<button class="btn btn-primary">`. The
|
|
85
|
+
appearance is in the stylesheet, shared with igni's own app; the
|
|
86
|
+
component adds the prop names, the types and the defaults.
|
|
87
|
+
- **You need the stylesheet too.** `@ignite-ember/ui-css` is not optional
|
|
88
|
+
and not a suggestion — see below.
|
|
89
|
+
- **You bring your own React.** These are React components, not web
|
|
90
|
+
components, and your extension bundles its own React.
|
|
91
|
+
|
|
92
|
+
## The floor
|
|
93
|
+
|
|
94
|
+
"Everything exported here is under the compatibility floor" is a promise
|
|
95
|
+
about *this* list, not about igni's app. Two rules follow from it, and
|
|
96
|
+
they point in opposite directions:
|
|
97
|
+
|
|
98
|
+
- **You may build against anything exported here.** A component's name,
|
|
99
|
+
its props and the meaning of those props will not change without a
|
|
100
|
+
major version. If you need to know what a prop means, the reference
|
|
101
|
+
page says so — every prop of every component is listed with its type
|
|
102
|
+
and what it is for.
|
|
103
|
+
- **You may not build against anything else.** A class in igni's app
|
|
104
|
+
that is not exported here is ours to change: it may be renamed, or
|
|
105
|
+
restyled, or removed, and nothing an extension depends on will break
|
|
106
|
+
in a way we would have to warn you about.
|
|
107
|
+
|
|
108
|
+
The list is deliberately short. It is not "everything an extension might
|
|
109
|
+
want" — it is what the extensions actually import, measured rather
|
|
110
|
+
than estimated.
|
|
111
|
+
|
|
112
|
+
Two rules decide whether something joins the floor, and both are checked
|
|
113
|
+
by tests:
|
|
114
|
+
|
|
115
|
+
1. **It must render outside this repository.** A component whose CSS
|
|
116
|
+
lives only in igni's `theme.css` is unstyled in the one place it is
|
|
117
|
+
promised for, because an extension runs on its own origin under
|
|
118
|
+
`default-src 'self'` and cannot link ours. `styled.test.ts` checks
|
|
119
|
+
every class named here against `clients/ui/igni-ui.css` and fails on
|
|
120
|
+
the first one that is missing. This was not hypothetical: seven
|
|
121
|
+
components shipped under the floor naming thirty-two classes that no
|
|
122
|
+
published stylesheet defined, and the reference extension did not
|
|
123
|
+
catch it because it happens to import only from `primitives`, which
|
|
124
|
+
was the half that was covered.
|
|
125
|
+
2. **It must not drag the app behind it.** `boundary.test.ts` fails on
|
|
126
|
+
an import — static or dynamic — that leaves this directory for
|
|
127
|
+
anywhere but `react` and the published dependencies. `SpecBlock`
|
|
128
|
+
left the floor for this reason: it loaded
|
|
129
|
+
`../components/JsonRenderView`, a path that does not exist in a
|
|
130
|
+
published package, through a dynamic import that no compiler would
|
|
131
|
+
flag.
|
|
132
|
+
|
|
133
|
+
## Choosing a component
|
|
134
|
+
|
|
135
|
+
There are two kinds of thing in this package, and they answer different
|
|
136
|
+
questions.
|
|
137
|
+
|
|
138
|
+
**The primitives** are the vocabulary: `Button`, `Input`, `Select`,
|
|
139
|
+
`Textarea`, `Checkbox`, `Radio`, `Switch`, `Field`, `Row`, `Actions`,
|
|
140
|
+
`List`, `Toolbar`, `Card`, `Item`, `Table`, `Chip`, `Badge`, `Empty`,
|
|
141
|
+
`Dialog`, `Tabs`, `TabPanel`, `Heading`, `Text`, `Code`, `Divider`,
|
|
142
|
+
`Spinner`, `Progress`. They are thin, they hold no state, and they make
|
|
143
|
+
no decisions. Reach for one of these first — it is the thing that will
|
|
144
|
+
still be here next release. `Chip` and `Badge` take a `tone` of
|
|
145
|
+
`"neutral"`, `"success"`, `"warning"` or `"danger"`.
|
|
146
|
+
|
|
147
|
+
**The composites** are the parts of a page that have to be a page:
|
|
148
|
+
`AppShell` and `Scroll` (the frame), `DataTable`'s `SortableTh` and
|
|
149
|
+
`Status` (a table with a sortable header and a status cell), `ToastHost`
|
|
150
|
+
and `useToast` (saying something) and `Banner` (a condition that is still
|
|
151
|
+
true), `LiveRegion` and
|
|
152
|
+
`useAnnounce` (announcing it), `ErrorBoundary` (catching what falls
|
|
153
|
+
over), `Markdown` and `MarkdownInline` and `MermaidBlock` (reading what
|
|
154
|
+
igni said), with `fenceInfo` and `loadMermaid` for the pieces beneath them.
|
|
155
|
+
|
|
156
|
+
**The utilities** are the small pieces: `Split`, `MenuIcon`,
|
|
157
|
+
`Monogram`, `OverflowMenu`, `Skeleton`, `Tooltip`.
|
|
158
|
+
|
|
159
|
+
One thing is deliberately absent: there is no `Title` component, because
|
|
160
|
+
the app's titles varied across four type steps and that variation is the
|
|
161
|
+
design — a heading level, not drift. Use `Heading`, or the type scale
|
|
162
|
+
and a weight.
|
|
163
|
+
|
|
164
|
+
`Dialog` is the one primitive that is not thin. A dialog is behaviour,
|
|
165
|
+
not just a box: it traps focus, closes on escape, and restores focus
|
|
166
|
+
when it closes. That is why it is a component and not a class.
|
|
167
|
+
|
|
168
|
+
## Styling
|
|
169
|
+
|
|
170
|
+
The components do not carry styles. They carry **class names**, and the
|
|
171
|
+
stylesheet carries the styles — so the same CSS decides what your
|
|
172
|
+
extension looks like and what igni's app looks like.
|
|
173
|
+
|
|
174
|
+
That is why `@ignite-ember/ui-css` is required: without it, every
|
|
175
|
+
component renders unstyled, and an unstyled button is not a subtle
|
|
176
|
+
difference.
|
|
177
|
+
|
|
178
|
+
Two things follow from sharing the stylesheet:
|
|
179
|
+
|
|
180
|
+
- **The theme is live.** The bridge pushes the computed token values
|
|
181
|
+
before your first paint, so your page follows dark mode, light mode,
|
|
182
|
+
and whatever a group's policy pack has branded, without a line of your
|
|
183
|
+
own. Your layout is written against tokens (`var(--space-4)`), never
|
|
184
|
+
against colours.
|
|
185
|
+
- **Your own class names still work.** `className` is passed through on
|
|
186
|
+
every component, so you can add your own classes alongside. Write them
|
|
187
|
+
in your own stylesheet; do not edit the published one.
|
|
188
|
+
|
|
189
|
+
## Peer dependencies
|
|
190
|
+
|
|
191
|
+
You already have `react` and `react-dom`. `react-markdown` and
|
|
192
|
+
`remark-gfm` are peers too, and not optional: `Markdown` and
|
|
193
|
+
`MarkdownInline` import them, and the package's entry exports both, so
|
|
194
|
+
every import from `@ignite-ember/ui-react` reaches them. npm 7 and later
|
|
195
|
+
(and pnpm) install them with the package; with another installer, add
|
|
196
|
+
them yourself. (They were optional peers, and a
|
|
197
|
+
Vite build without them succeeded and then threw `Could not resolve
|
|
198
|
+
"react-markdown"` when the page loaded, before anything rendered.)
|
|
199
|
+
|
|
200
|
+
Type-checking a page takes three more, as dev dependencies:
|
|
201
|
+
`typescript`, `@types/react` and `@types/react-dom`. The package's
|
|
202
|
+
declarations import React's types, and without `@types/react` `tsc`
|
|
203
|
+
stops in them with `TS7016: Could not find a declaration file for module
|
|
204
|
+
'react'`, then reports every component's props as missing:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
npm install --save-dev typescript @types/react @types/react-dom
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
`mermaid` is **optional** and loaded on demand — a page with no
|
|
211
|
+
diagram in it never downloads the 700KB, and an extension that never
|
|
212
|
+
renders one does not need the dependency at all. Install it only if
|
|
213
|
+
you use `MermaidBlock`.
|
|
214
|
+
|
|
215
|
+
## Changed since 0.1.0, on purpose
|
|
216
|
+
|
|
217
|
+
- `loadMermaid()` configures mermaid on every call, with the theme in
|
|
218
|
+
force at that moment, so a diagram drawn after a light/dark switch is
|
|
219
|
+
drawn in the new theme. Each call returns a new promise, a failed load
|
|
220
|
+
is tried again on the next call rather than kept, and an
|
|
221
|
+
`initialize(...)` of your own is overwritten by the next
|
|
222
|
+
`MermaidBlock` render. The returned `initialize` takes igni's fixed
|
|
223
|
+
config (`startOnLoad`, `securityLevel: "strict"`, `theme`,
|
|
224
|
+
`themeVariables`) rather than any record.
|
|
225
|
+
- A diagram's copy button draws the `copy` and `check` icons instead of
|
|
226
|
+
the `⧉` and `✓` glyphs, so it has no text. It carries `data-state`
|
|
227
|
+
(`idle`, `copied` or `failed`). A blocked or missing clipboard is no
|
|
228
|
+
longer silent: the button goes to `failed`, says "Copy failed — the
|
|
229
|
+
clipboard is blocked" in its title and label, and resets after 1.3s,
|
|
230
|
+
as "Copied" does.
|
|
231
|
+
- `MenuIconName` has two more names, `copy` and `check`.
|
|
232
|
+
|
|
233
|
+
## The stylesheet is not optional
|
|
234
|
+
|
|
235
|
+
`@ignite-ember/ui-css` must be bundled into your extension, not linked from
|
|
236
|
+
igni's origin. Your page runs under its own origin with
|
|
237
|
+
`default-src 'self'`, so a cross-origin stylesheet is refused — and
|
|
238
|
+
that refusal is deliberate.
|
|
239
|
+
|
|
240
|
+
Inside igni the bridge pushes live token values before your first
|
|
241
|
+
paint, so the same markup follows dark mode, light mode and whatever
|
|
242
|
+
a deployment has branded. Standalone, the fallbacks in the stylesheet
|
|
243
|
+
are igni's own values, checked against them by a test.
|
|
244
|
+
|
|
245
|
+
## The source, and a build beside it
|
|
246
|
+
|
|
247
|
+
This package ships TypeScript source, and a compiled build beside it.
|
|
248
|
+
|
|
249
|
+
An extension bundles its own React and runs its own build, so a
|
|
250
|
+
bundler takes the source: it tree-shakes with the rest of your
|
|
251
|
+
extension, and it does not pin a JSX runtime or a target you may not
|
|
252
|
+
share. A consumer that does not compile `node_modules` — Node itself, a
|
|
253
|
+
test runner that is not told to transform it — takes the build instead:
|
|
254
|
+
plain JavaScript, and the declarations that go with it.
|
|
255
|
+
|
|
256
|
+
The build is ES2022 modules with source maps back to the TypeScript.
|
|
257
|
+
React stays a peer dependency, and so does the JSX runtime the build
|
|
258
|
+
imports. `exports` points at the build for `node`, and the `types`
|
|
259
|
+
condition at its declarations for everyone, so `import { Button } from
|
|
260
|
+
"@ignite-ember/ui-react"` names the same thing in a bundler and in
|
|
261
|
+
Node, and `tsc` finds it under `moduleResolution: node16`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopySource.d.ts","sourceRoot":"","sources":["../src/CopySource.tsx"],"names":[],"mappings":"AA0BA,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,+BAwCxD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Copies a diagram's fenced source, not the rendered SVG.
|
|
4
|
+
*
|
|
5
|
+
* What somebody wants from a diagram is the text that made it —
|
|
6
|
+
* to paste into another document, or to fix. Nobody wants the
|
|
7
|
+
* markup a renderer produced.
|
|
8
|
+
*
|
|
9
|
+
* A blocked clipboard says so, on the button itself: a click that
|
|
10
|
+
* appears to work and leaves nothing to paste is worse than one
|
|
11
|
+
* that admits it failed.
|
|
12
|
+
*/
|
|
13
|
+
import { useEffect, useRef, useState } from "react";
|
|
14
|
+
import { MenuIcon } from "./MenuIcon.js";
|
|
15
|
+
/** How long "Copied" or "Copy failed" stays before the button resets. */
|
|
16
|
+
const FEEDBACK_MS = 1300;
|
|
17
|
+
const LABEL = {
|
|
18
|
+
idle: "Copy source",
|
|
19
|
+
copied: "Copied",
|
|
20
|
+
failed: "Copy failed — the clipboard is blocked",
|
|
21
|
+
};
|
|
22
|
+
export function CopySource({ source }) {
|
|
23
|
+
const [state, setState] = useState("idle");
|
|
24
|
+
const timer = useRef(undefined);
|
|
25
|
+
// A pending reset must not outlive the button, nor cut a later
|
|
26
|
+
// click's feedback short.
|
|
27
|
+
const alive = useRef(true);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
alive.current = true;
|
|
30
|
+
return () => {
|
|
31
|
+
alive.current = false;
|
|
32
|
+
window.clearTimeout(timer.current);
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
const copy = async () => {
|
|
36
|
+
try {
|
|
37
|
+
await navigator.clipboard.writeText(source);
|
|
38
|
+
setState("copied");
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
setState("failed");
|
|
42
|
+
}
|
|
43
|
+
if (!alive.current)
|
|
44
|
+
return;
|
|
45
|
+
window.clearTimeout(timer.current);
|
|
46
|
+
timer.current = window.setTimeout(() => setState("idle"), FEEDBACK_MS);
|
|
47
|
+
};
|
|
48
|
+
return (_jsx("button", { type: "button", className: "diagram-copy", "data-state": state, title: LABEL[state], "aria-label": LABEL[state], onClick: () => void copy(), children: _jsx(MenuIcon, { name: state === "copied" ? "check" : "copy" }) }));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=CopySource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopySource.js","sourceRoot":"","sources":["../src/CopySource.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAIzC,yEAAyE;AACzE,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,MAAM,KAAK,GAA8B;IACvC,IAAI,EAAE,aAAa;IACnB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,wCAAwC;CACjD,CAAC;AAEF,MAAM,UAAU,UAAU,CAAC,EAAE,MAAM,EAAsB;IACvD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAY,MAAM,CAAC,CAAC;IAEtD,MAAM,KAAK,GAAG,MAAM,CAAqB,SAAS,CAAC,CAAC;IAEpD,+DAA+D;IAC/D,0BAA0B;IAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QACrB,OAAO,GAAG,EAAE;YACV,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;YACtB,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;QACtB,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAC5C,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,OAAO;YAAE,OAAO;QAC3B,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACnC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;IACzE,CAAC,CAAC;IAEF,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,cAAc,gBACZ,KAAK,EACjB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,gBACP,KAAK,CAAC,KAAK,CAAC,EACxB,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,EAAE,YAE1B,KAAC,QAAQ,IAAC,IAAI,EAAE,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,GAAI,GAClD,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts of a table the floor was missing.
|
|
3
|
+
*
|
|
4
|
+
* `Table` is a bare `<table>` and stays one — the markup inside is
|
|
5
|
+
* the extension's, per EXTENSIBILITY §8, and a `DataTable` that owns
|
|
6
|
+
* rows would have to own sorting, selection, paging and
|
|
7
|
+
* virtualisation with it. What was missing is narrower and entirely
|
|
8
|
+
* behaviour: a sortable header nobody announces wrongly, and a
|
|
9
|
+
* selection state that reads as selected.
|
|
10
|
+
*
|
|
11
|
+
* `.ui-table` was three CSS declarations until now — width,
|
|
12
|
+
* border-collapse, font-size — so cell padding, the header rule and
|
|
13
|
+
* the sticky header were every extension's problem too. Those are in
|
|
14
|
+
* `igni-ui.css` now; these are the components that drive them.
|
|
15
|
+
*/
|
|
16
|
+
import type { ReactNode, ThHTMLAttributes } from "react";
|
|
17
|
+
/** Which way a column is sorted, or not. */
|
|
18
|
+
export type SortDirection = "ascending" | "descending";
|
|
19
|
+
/** What a {@link SortableTh} takes. */
|
|
20
|
+
export interface SortableThProps extends Omit<ThHTMLAttributes<HTMLTableCellElement>, "onClick" | "aria-sort"> {
|
|
21
|
+
/** The heading. */
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* How this column is currently sorted, or `undefined` when the
|
|
25
|
+
* table is sorted by some other column.
|
|
26
|
+
*/
|
|
27
|
+
direction?: SortDirection;
|
|
28
|
+
/** Asked to sort by this column. Gets the direction to go to. */
|
|
29
|
+
onSort: (direction: SortDirection) => void;
|
|
30
|
+
/** Right-align and use tabular figures. */
|
|
31
|
+
numeric?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A column heading you can sort by.
|
|
35
|
+
*
|
|
36
|
+
* `aria-sort` goes on the `th` and nowhere else, which is what a
|
|
37
|
+
* screen reader reads; the arrow is `aria-hidden` so the state is
|
|
38
|
+
* not announced twice. Hand-rolled versions usually do the reverse —
|
|
39
|
+
* an arrow glyph with no `aria-sort` — and the sort is then
|
|
40
|
+
* invisible to the people most reliant on being told.
|
|
41
|
+
*
|
|
42
|
+
* The button fills the cell so the whole heading is the target
|
|
43
|
+
* rather than a word inside it.
|
|
44
|
+
*
|
|
45
|
+
* @param children — the heading.
|
|
46
|
+
* @param direction — how this column is currently sorted, or
|
|
47
|
+
* `undefined` when the table is sorted by another column.
|
|
48
|
+
* @param onSort — asked to sort by this column; it gets the direction
|
|
49
|
+
* to go to.
|
|
50
|
+
* @param numeric — right-align the column and use tabular figures.
|
|
51
|
+
* @param className — added to the element's classes, beside the one the
|
|
52
|
+
* theme gives it.
|
|
53
|
+
* @param rest — the remaining props, spread onto the `th`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function SortableTh({ children, direction, onSort, numeric, className, ...rest }: SortableThProps): import("react").JSX.Element;
|
|
56
|
+
/** What a {@link Status} takes. */
|
|
57
|
+
export interface StatusProps {
|
|
58
|
+
/** The four states the health contract defines. */
|
|
59
|
+
state: "READY" | "PREPARING" | "DISABLED" | "FAILED";
|
|
60
|
+
/**
|
|
61
|
+
* What to show beside the dot. Defaults to the state itself.
|
|
62
|
+
*
|
|
63
|
+
* There is always a word. The dot is a colour, and a colour on its
|
|
64
|
+
* own is not a message — it says nothing when read aloud and
|
|
65
|
+
* nothing to somebody who cannot tell green from amber.
|
|
66
|
+
*/
|
|
67
|
+
children?: ReactNode;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A state, as a coloured dot and the word it stands for.
|
|
71
|
+
*
|
|
72
|
+
* @param state — the four states the health contract defines.
|
|
73
|
+
* @param children — what to show beside the dot; it defaults to the
|
|
74
|
+
* state itself.
|
|
75
|
+
*/
|
|
76
|
+
export declare function Status({ state, children }: StatusProps): import("react").JSX.Element;
|
|
77
|
+
//# sourceMappingURL=DataTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../src/DataTable.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAMzD,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,YAAY,CAAC;AAEvD,uCAAuC;AACvC,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAC7E,mBAAmB;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,iEAAiE;IACjE,MAAM,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IAC3C,2CAA2C;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAe,EACf,SAAS,EACT,GAAG,IAAI,EACR,EAAE,eAAe,+BAqBjB;AAED,mCAAmC;AACnC,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;IACrD;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,WAAW,+BAMtD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
function cx(...parts) {
|
|
3
|
+
return parts.filter(Boolean).join(" ");
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A column heading you can sort by.
|
|
7
|
+
*
|
|
8
|
+
* `aria-sort` goes on the `th` and nowhere else, which is what a
|
|
9
|
+
* screen reader reads; the arrow is `aria-hidden` so the state is
|
|
10
|
+
* not announced twice. Hand-rolled versions usually do the reverse —
|
|
11
|
+
* an arrow glyph with no `aria-sort` — and the sort is then
|
|
12
|
+
* invisible to the people most reliant on being told.
|
|
13
|
+
*
|
|
14
|
+
* The button fills the cell so the whole heading is the target
|
|
15
|
+
* rather than a word inside it.
|
|
16
|
+
*
|
|
17
|
+
* @param children — the heading.
|
|
18
|
+
* @param direction — how this column is currently sorted, or
|
|
19
|
+
* `undefined` when the table is sorted by another column.
|
|
20
|
+
* @param onSort — asked to sort by this column; it gets the direction
|
|
21
|
+
* to go to.
|
|
22
|
+
* @param numeric — right-align the column and use tabular figures.
|
|
23
|
+
* @param className — added to the element's classes, beside the one the
|
|
24
|
+
* theme gives it.
|
|
25
|
+
* @param rest — the remaining props, spread onto the `th`.
|
|
26
|
+
*/
|
|
27
|
+
export function SortableTh({ children, direction, onSort, numeric = false, className, ...rest }) {
|
|
28
|
+
// Clicking the sorted column reverses it; clicking any other
|
|
29
|
+
// column starts ascending. Starting descending is defensible for
|
|
30
|
+
// dates and wrong for everything else, so the caller re-sorts if
|
|
31
|
+
// it wants that.
|
|
32
|
+
const next = direction === "ascending" ? "descending" : "ascending";
|
|
33
|
+
return (_jsx("th", { ...rest, scope: "col", "aria-sort": direction ?? "none", className: cx(numeric && "ui-num", className), children: _jsxs("button", { type: "button", className: "ui-th-sort", onClick: () => onSort(next), children: [children, _jsx("span", { className: "ui-th-arrow", "aria-hidden": "true", children: direction === "descending" ? "▾" : "▴" })] }) }));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A state, as a coloured dot and the word it stands for.
|
|
37
|
+
*
|
|
38
|
+
* @param state — the four states the health contract defines.
|
|
39
|
+
* @param children — what to show beside the dot; it defaults to the
|
|
40
|
+
* state itself.
|
|
41
|
+
*/
|
|
42
|
+
export function Status({ state, children }) {
|
|
43
|
+
return (_jsx("span", { className: "ui-status", "data-state": state, children: children ?? state }));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=DataTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTable.js","sourceRoot":"","sources":["../src/DataTable.tsx"],"names":[],"mappings":";AAiBA,SAAS,EAAE,CAAC,GAAG,KAA4C;IACzD,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAqBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,GAAG,KAAK,EACf,SAAS,EACT,GAAG,IAAI,EACS;IAChB,6DAA6D;IAC7D,iEAAiE;IACjE,iEAAiE;IACjE,iBAAiB;IACjB,MAAM,IAAI,GAAkB,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;IACnF,OAAO,CACL,gBACM,IAAI,EACR,KAAK,EAAC,KAAK,eACA,SAAS,IAAI,MAAM,EAC9B,SAAS,EAAE,EAAE,CAAC,OAAO,IAAI,QAAQ,EAAE,SAAS,CAAC,YAE7C,kBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,YAAY,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aACrE,QAAQ,EACT,eAAM,SAAS,EAAC,aAAa,iBAAa,MAAM,YAC7C,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAClC,IACA,GACN,CACN,CAAC;AACJ,CAAC;AAgBD;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAe;IACrD,OAAO,CACL,eAAM,SAAS,EAAC,WAAW,gBAAa,KAAK,YAC1C,QAAQ,IAAI,KAAK,GACb,CACR,CAAC;AACJ,CAAC"}
|