@robert-stackflow/oneui 0.6.40 → 0.6.42
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/CHANGELOG.md +14 -0
- package/README.md +9 -1
- package/components/AccountItem.module.css +103 -103
- package/components/AppShell.module.css +223 -223
- package/components/Badge.module.css +30 -30
- package/components/BarChart.module.css +35 -35
- package/components/Breadcrumb.module.css +97 -97
- package/components/Button.module.css +120 -120
- package/components/Checkbox.module.css +95 -95
- package/components/Control.module.css +86 -86
- package/components/DataTable.module.css +75 -75
- package/components/Form.d.ts +5 -1
- package/components/Form.js +5 -1
- package/components/FormField.js +1 -0
- package/components/HierarchyPicker.module.css +185 -185
- package/components/Indicator.module.css +83 -83
- package/components/Layout.module.css +82 -82
- package/components/Markdown.module.css +227 -227
- package/components/NativeForm.d.ts +10 -0
- package/components/NativeForm.js +155 -0
- package/components/NavBar.module.css +130 -130
- package/components/Progress.module.css +33 -33
- package/components/RadioGroup.module.css +87 -87
- package/components/RangeSlider.module.css +141 -141
- package/components/ResizablePanel.module.css +101 -101
- package/components/ResourceCard.module.css +98 -98
- package/components/Slider.module.css +19 -19
- package/components/Steps.module.css +176 -176
- package/components/Tab.module.css +148 -148
- package/components/ThemePicker.module.css +178 -178
- package/components/TimeColumns.module.css +47 -47
- package/components/Timeline.module.css +202 -202
- package/components/Toast.d.ts +7 -2
- package/components/Toast.js +146 -98
- package/components/Toast.module.css +182 -85
- package/components/ToastProvider.js +19 -62
- package/components/ToastStack.d.ts +8 -0
- package/components/ToastStack.js +190 -0
- package/components/TreeTable.module.css +57 -57
- package/components/UptimeChart.module.css +15 -15
- package/components/field.d.ts +1 -1
- package/components/field.js +2 -1
- package/components/form-validation.d.ts +4 -0
- package/components/form-validation.js +22 -0
- package/components/index.d.ts +4 -2
- package/components/index.js +9 -3
- package/package.json +1 -1
- package/styles/blue.css +270 -270
|
@@ -1,227 +1,227 @@
|
|
|
1
|
-
.markdown {
|
|
2
|
-
min-width: 0;
|
|
3
|
-
color: var(--fg);
|
|
4
|
-
font: 14px/1.75 var(--ui-font, system-ui, sans-serif);
|
|
5
|
-
overflow-wrap: anywhere;
|
|
6
|
-
}
|
|
7
|
-
.markdown.markdown :is(h1, h2, h3, h4, h5, h6) {
|
|
8
|
-
margin: 1.6em 0 0.6em;
|
|
9
|
-
color: var(--fg);
|
|
10
|
-
font-family: inherit;
|
|
11
|
-
font-weight: 600;
|
|
12
|
-
line-height: 1.4;
|
|
13
|
-
letter-spacing: -0.02em;
|
|
14
|
-
}
|
|
15
|
-
.markdown.markdown h1 {
|
|
16
|
-
font-size: 1.9em;
|
|
17
|
-
}
|
|
18
|
-
.markdown.markdown h2 {
|
|
19
|
-
font-size: 1.45em;
|
|
20
|
-
}
|
|
21
|
-
.markdown.markdown h3 {
|
|
22
|
-
font-size: 1.2em;
|
|
23
|
-
}
|
|
24
|
-
.markdown.markdown :is(h4, h5, h6) {
|
|
25
|
-
font-size: 1em;
|
|
26
|
-
}
|
|
27
|
-
.markdown :is(p, ul, ol, blockquote, figure, .tableScroll) {
|
|
28
|
-
margin: 0 0 1em;
|
|
29
|
-
}
|
|
30
|
-
.markdown.markdown > :first-child {
|
|
31
|
-
margin-top: 0;
|
|
32
|
-
}
|
|
33
|
-
.markdown.markdown > :last-child {
|
|
34
|
-
margin-bottom: 0;
|
|
35
|
-
}
|
|
36
|
-
.markdown :is(ul, ol) {
|
|
37
|
-
padding-left: 1.6em;
|
|
38
|
-
}
|
|
39
|
-
.markdown li + li {
|
|
40
|
-
margin-top: 0.3em;
|
|
41
|
-
}
|
|
42
|
-
.markdown li > :is(ul, ol) {
|
|
43
|
-
margin-block: 0.3em;
|
|
44
|
-
}
|
|
45
|
-
.markdown a {
|
|
46
|
-
color: var(--accent-ink, var(--accent));
|
|
47
|
-
text-decoration: underline;
|
|
48
|
-
text-underline-offset: 3px;
|
|
49
|
-
}
|
|
50
|
-
.markdown a:hover {
|
|
51
|
-
text-decoration-thickness: 2px;
|
|
52
|
-
}
|
|
53
|
-
.markdown :is(a, .tableScroll):focus-visible {
|
|
54
|
-
outline: 2px solid var(--accent-ink, var(--accent));
|
|
55
|
-
outline-offset: 3px;
|
|
56
|
-
}
|
|
57
|
-
.markdown blockquote {
|
|
58
|
-
padding: 0.3em 1em;
|
|
59
|
-
border-left: 3px solid var(--line);
|
|
60
|
-
color: var(--muted);
|
|
61
|
-
}
|
|
62
|
-
.markdown blockquote > :last-child {
|
|
63
|
-
margin-bottom: 0;
|
|
64
|
-
}
|
|
65
|
-
.markdown hr {
|
|
66
|
-
border: 0;
|
|
67
|
-
border-top: 1px solid var(--line);
|
|
68
|
-
margin: 1.5em 0;
|
|
69
|
-
}
|
|
70
|
-
.markdown img {
|
|
71
|
-
display: block;
|
|
72
|
-
max-width: 100%;
|
|
73
|
-
height: auto;
|
|
74
|
-
border-radius: var(--radius);
|
|
75
|
-
}
|
|
76
|
-
.markdown code {
|
|
77
|
-
font:
|
|
78
|
-
0.9em/1.65 ui-monospace,
|
|
79
|
-
SFMono-Regular,
|
|
80
|
-
Consolas,
|
|
81
|
-
monospace;
|
|
82
|
-
padding: 0.15em 0.4em;
|
|
83
|
-
border-radius: 4px;
|
|
84
|
-
background: var(--hover);
|
|
85
|
-
}
|
|
86
|
-
.codeBlock {
|
|
87
|
-
overflow: hidden;
|
|
88
|
-
border: 1px solid var(--line);
|
|
89
|
-
border-radius: var(--radius);
|
|
90
|
-
background: var(--canvas);
|
|
91
|
-
}
|
|
92
|
-
.codeBlock > figcaption {
|
|
93
|
-
display: flex;
|
|
94
|
-
align-items: center;
|
|
95
|
-
justify-content: space-between;
|
|
96
|
-
gap: 12px;
|
|
97
|
-
min-height: 38px;
|
|
98
|
-
padding: 5px 12px;
|
|
99
|
-
border-bottom: 1px solid var(--line);
|
|
100
|
-
color: var(--muted);
|
|
101
|
-
font-size: 11px;
|
|
102
|
-
}
|
|
103
|
-
.codeBlock > pre {
|
|
104
|
-
max-width: 100%;
|
|
105
|
-
margin: 0;
|
|
106
|
-
padding: 16px;
|
|
107
|
-
overflow: auto;
|
|
108
|
-
tab-size: 2;
|
|
109
|
-
}
|
|
110
|
-
.codeBlock code {
|
|
111
|
-
display: block;
|
|
112
|
-
padding: 0;
|
|
113
|
-
border-radius: 0;
|
|
114
|
-
background: transparent;
|
|
115
|
-
white-space: pre;
|
|
116
|
-
overflow-wrap: normal;
|
|
117
|
-
}
|
|
118
|
-
.tableScroll {
|
|
119
|
-
max-width: 100%;
|
|
120
|
-
overflow-x: auto;
|
|
121
|
-
border: 1px solid var(--line);
|
|
122
|
-
border-radius: var(--radius);
|
|
123
|
-
}
|
|
124
|
-
.markdown .table {
|
|
125
|
-
min-width: 400px;
|
|
126
|
-
white-space: normal;
|
|
127
|
-
}
|
|
128
|
-
.markdown :global(.contains-task-list) {
|
|
129
|
-
list-style: none;
|
|
130
|
-
padding-left: 0.2em;
|
|
131
|
-
}
|
|
132
|
-
.markdown input[type="checkbox"] {
|
|
133
|
-
width: 14px;
|
|
134
|
-
height: 14px;
|
|
135
|
-
margin: 0 0.5em 0 0;
|
|
136
|
-
vertical-align: -0.1em;
|
|
137
|
-
accent-color: var(--accent);
|
|
138
|
-
}
|
|
139
|
-
.markdown :global(.footnotes) {
|
|
140
|
-
margin-top: 2em;
|
|
141
|
-
padding-top: 1em;
|
|
142
|
-
border-top: 1px solid var(--line);
|
|
143
|
-
color: var(--muted);
|
|
144
|
-
font-size: 0.9em;
|
|
145
|
-
}
|
|
146
|
-
@media (max-width: 540px) {
|
|
147
|
-
.markdown {
|
|
148
|
-
font-size: 13px;
|
|
149
|
-
}
|
|
150
|
-
.codeBlock > pre {
|
|
151
|
-
padding: 12px;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.codeBlock {
|
|
156
|
-
--code-bg: #f6f8fa;
|
|
157
|
-
--code-fg: #24292f;
|
|
158
|
-
--code-keyword: #cf222e;
|
|
159
|
-
--code-string: #0a3069;
|
|
160
|
-
--code-number: #0550ae;
|
|
161
|
-
--code-title: #8250df;
|
|
162
|
-
--code-comment: #6e7781;
|
|
163
|
-
background: var(--code-bg);
|
|
164
|
-
color: var(--code-fg);
|
|
165
|
-
}
|
|
166
|
-
:global([data-theme="dark"]) .codeBlock[data-code-theme="auto"],
|
|
167
|
-
.codeBlock[data-code-theme="github-dark"] {
|
|
168
|
-
--code-bg: #0d1117;
|
|
169
|
-
--code-fg: #c9d1d9;
|
|
170
|
-
--code-keyword: #ff7b72;
|
|
171
|
-
--code-string: #a5d6ff;
|
|
172
|
-
--code-number: #79c0ff;
|
|
173
|
-
--code-title: #d2a8ff;
|
|
174
|
-
--code-comment: #8b949e;
|
|
175
|
-
}
|
|
176
|
-
.codeBlock[data-code-theme="nord"] {
|
|
177
|
-
--code-bg: #2e3440;
|
|
178
|
-
--code-fg: #d8dee9;
|
|
179
|
-
--code-keyword: #81a1c1;
|
|
180
|
-
--code-string: #a3be8c;
|
|
181
|
-
--code-number: #b48ead;
|
|
182
|
-
--code-title: #88c0d0;
|
|
183
|
-
--code-comment: #8a97ad;
|
|
184
|
-
}
|
|
185
|
-
.codeBlock[data-code-theme="dracula"] {
|
|
186
|
-
--code-bg: #282a36;
|
|
187
|
-
--code-fg: #f8f8f2;
|
|
188
|
-
--code-keyword: #ff79c6;
|
|
189
|
-
--code-string: #f1fa8c;
|
|
190
|
-
--code-number: #bd93f9;
|
|
191
|
-
--code-title: #50fa7b;
|
|
192
|
-
--code-comment: #9baddb;
|
|
193
|
-
}
|
|
194
|
-
.codeBlock > figcaption {
|
|
195
|
-
color: var(--code-comment);
|
|
196
|
-
border-color: color-mix(in srgb, var(--code-fg) 15%, transparent);
|
|
197
|
-
}
|
|
198
|
-
.codeBlock pre code {
|
|
199
|
-
color: var(--code-fg);
|
|
200
|
-
}
|
|
201
|
-
.codeBlock :global(.hljs-keyword),
|
|
202
|
-
.codeBlock :global(.hljs-selector-tag),
|
|
203
|
-
.codeBlock :global(.hljs-tag) {
|
|
204
|
-
color: var(--code-keyword);
|
|
205
|
-
}
|
|
206
|
-
.codeBlock :global(.hljs-string),
|
|
207
|
-
.codeBlock :global(.hljs-regexp),
|
|
208
|
-
.codeBlock :global(.hljs-addition) {
|
|
209
|
-
color: var(--code-string);
|
|
210
|
-
}
|
|
211
|
-
.codeBlock :global(.hljs-number),
|
|
212
|
-
.codeBlock :global(.hljs-literal),
|
|
213
|
-
.codeBlock :global(.hljs-attr) {
|
|
214
|
-
color: var(--code-number);
|
|
215
|
-
}
|
|
216
|
-
.codeBlock :global(.hljs-title),
|
|
217
|
-
.codeBlock :global(.hljs-function),
|
|
218
|
-
.codeBlock :global(.hljs-built_in) {
|
|
219
|
-
color: var(--code-title);
|
|
220
|
-
}
|
|
221
|
-
.codeBlock :global(.hljs-comment),
|
|
222
|
-
.codeBlock :global(.hljs-meta) {
|
|
223
|
-
color: var(--code-comment);
|
|
224
|
-
}
|
|
225
|
-
.markdown :is(h1, h2, h3, h4, h5, h6)[id] {
|
|
226
|
-
scroll-margin-top: 32px;
|
|
227
|
-
}
|
|
1
|
+
.markdown {
|
|
2
|
+
min-width: 0;
|
|
3
|
+
color: var(--fg);
|
|
4
|
+
font: 14px/1.75 var(--ui-font, system-ui, sans-serif);
|
|
5
|
+
overflow-wrap: anywhere;
|
|
6
|
+
}
|
|
7
|
+
.markdown.markdown :is(h1, h2, h3, h4, h5, h6) {
|
|
8
|
+
margin: 1.6em 0 0.6em;
|
|
9
|
+
color: var(--fg);
|
|
10
|
+
font-family: inherit;
|
|
11
|
+
font-weight: 600;
|
|
12
|
+
line-height: 1.4;
|
|
13
|
+
letter-spacing: -0.02em;
|
|
14
|
+
}
|
|
15
|
+
.markdown.markdown h1 {
|
|
16
|
+
font-size: 1.9em;
|
|
17
|
+
}
|
|
18
|
+
.markdown.markdown h2 {
|
|
19
|
+
font-size: 1.45em;
|
|
20
|
+
}
|
|
21
|
+
.markdown.markdown h3 {
|
|
22
|
+
font-size: 1.2em;
|
|
23
|
+
}
|
|
24
|
+
.markdown.markdown :is(h4, h5, h6) {
|
|
25
|
+
font-size: 1em;
|
|
26
|
+
}
|
|
27
|
+
.markdown :is(p, ul, ol, blockquote, figure, .tableScroll) {
|
|
28
|
+
margin: 0 0 1em;
|
|
29
|
+
}
|
|
30
|
+
.markdown.markdown > :first-child {
|
|
31
|
+
margin-top: 0;
|
|
32
|
+
}
|
|
33
|
+
.markdown.markdown > :last-child {
|
|
34
|
+
margin-bottom: 0;
|
|
35
|
+
}
|
|
36
|
+
.markdown :is(ul, ol) {
|
|
37
|
+
padding-left: 1.6em;
|
|
38
|
+
}
|
|
39
|
+
.markdown li + li {
|
|
40
|
+
margin-top: 0.3em;
|
|
41
|
+
}
|
|
42
|
+
.markdown li > :is(ul, ol) {
|
|
43
|
+
margin-block: 0.3em;
|
|
44
|
+
}
|
|
45
|
+
.markdown a {
|
|
46
|
+
color: var(--accent-ink, var(--accent));
|
|
47
|
+
text-decoration: underline;
|
|
48
|
+
text-underline-offset: 3px;
|
|
49
|
+
}
|
|
50
|
+
.markdown a:hover {
|
|
51
|
+
text-decoration-thickness: 2px;
|
|
52
|
+
}
|
|
53
|
+
.markdown :is(a, .tableScroll):focus-visible {
|
|
54
|
+
outline: 2px solid var(--accent-ink, var(--accent));
|
|
55
|
+
outline-offset: 3px;
|
|
56
|
+
}
|
|
57
|
+
.markdown blockquote {
|
|
58
|
+
padding: 0.3em 1em;
|
|
59
|
+
border-left: 3px solid var(--line);
|
|
60
|
+
color: var(--muted);
|
|
61
|
+
}
|
|
62
|
+
.markdown blockquote > :last-child {
|
|
63
|
+
margin-bottom: 0;
|
|
64
|
+
}
|
|
65
|
+
.markdown hr {
|
|
66
|
+
border: 0;
|
|
67
|
+
border-top: 1px solid var(--line);
|
|
68
|
+
margin: 1.5em 0;
|
|
69
|
+
}
|
|
70
|
+
.markdown img {
|
|
71
|
+
display: block;
|
|
72
|
+
max-width: 100%;
|
|
73
|
+
height: auto;
|
|
74
|
+
border-radius: var(--radius);
|
|
75
|
+
}
|
|
76
|
+
.markdown code {
|
|
77
|
+
font:
|
|
78
|
+
0.9em/1.65 ui-monospace,
|
|
79
|
+
SFMono-Regular,
|
|
80
|
+
Consolas,
|
|
81
|
+
monospace;
|
|
82
|
+
padding: 0.15em 0.4em;
|
|
83
|
+
border-radius: 4px;
|
|
84
|
+
background: var(--hover);
|
|
85
|
+
}
|
|
86
|
+
.codeBlock {
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
border: 1px solid var(--line);
|
|
89
|
+
border-radius: var(--radius);
|
|
90
|
+
background: var(--canvas);
|
|
91
|
+
}
|
|
92
|
+
.codeBlock > figcaption {
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
justify-content: space-between;
|
|
96
|
+
gap: 12px;
|
|
97
|
+
min-height: 38px;
|
|
98
|
+
padding: 5px 12px;
|
|
99
|
+
border-bottom: 1px solid var(--line);
|
|
100
|
+
color: var(--muted);
|
|
101
|
+
font-size: 11px;
|
|
102
|
+
}
|
|
103
|
+
.codeBlock > pre {
|
|
104
|
+
max-width: 100%;
|
|
105
|
+
margin: 0;
|
|
106
|
+
padding: 16px;
|
|
107
|
+
overflow: auto;
|
|
108
|
+
tab-size: 2;
|
|
109
|
+
}
|
|
110
|
+
.codeBlock code {
|
|
111
|
+
display: block;
|
|
112
|
+
padding: 0;
|
|
113
|
+
border-radius: 0;
|
|
114
|
+
background: transparent;
|
|
115
|
+
white-space: pre;
|
|
116
|
+
overflow-wrap: normal;
|
|
117
|
+
}
|
|
118
|
+
.tableScroll {
|
|
119
|
+
max-width: 100%;
|
|
120
|
+
overflow-x: auto;
|
|
121
|
+
border: 1px solid var(--line);
|
|
122
|
+
border-radius: var(--radius);
|
|
123
|
+
}
|
|
124
|
+
.markdown .table {
|
|
125
|
+
min-width: 400px;
|
|
126
|
+
white-space: normal;
|
|
127
|
+
}
|
|
128
|
+
.markdown :global(.contains-task-list) {
|
|
129
|
+
list-style: none;
|
|
130
|
+
padding-left: 0.2em;
|
|
131
|
+
}
|
|
132
|
+
.markdown input[type="checkbox"] {
|
|
133
|
+
width: 14px;
|
|
134
|
+
height: 14px;
|
|
135
|
+
margin: 0 0.5em 0 0;
|
|
136
|
+
vertical-align: -0.1em;
|
|
137
|
+
accent-color: var(--accent);
|
|
138
|
+
}
|
|
139
|
+
.markdown :global(.footnotes) {
|
|
140
|
+
margin-top: 2em;
|
|
141
|
+
padding-top: 1em;
|
|
142
|
+
border-top: 1px solid var(--line);
|
|
143
|
+
color: var(--muted);
|
|
144
|
+
font-size: 0.9em;
|
|
145
|
+
}
|
|
146
|
+
@media (max-width: 540px) {
|
|
147
|
+
.markdown {
|
|
148
|
+
font-size: 13px;
|
|
149
|
+
}
|
|
150
|
+
.codeBlock > pre {
|
|
151
|
+
padding: 12px;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.codeBlock {
|
|
156
|
+
--code-bg: #f6f8fa;
|
|
157
|
+
--code-fg: #24292f;
|
|
158
|
+
--code-keyword: #cf222e;
|
|
159
|
+
--code-string: #0a3069;
|
|
160
|
+
--code-number: #0550ae;
|
|
161
|
+
--code-title: #8250df;
|
|
162
|
+
--code-comment: #6e7781;
|
|
163
|
+
background: var(--code-bg);
|
|
164
|
+
color: var(--code-fg);
|
|
165
|
+
}
|
|
166
|
+
:global([data-theme="dark"]) .codeBlock[data-code-theme="auto"],
|
|
167
|
+
.codeBlock[data-code-theme="github-dark"] {
|
|
168
|
+
--code-bg: #0d1117;
|
|
169
|
+
--code-fg: #c9d1d9;
|
|
170
|
+
--code-keyword: #ff7b72;
|
|
171
|
+
--code-string: #a5d6ff;
|
|
172
|
+
--code-number: #79c0ff;
|
|
173
|
+
--code-title: #d2a8ff;
|
|
174
|
+
--code-comment: #8b949e;
|
|
175
|
+
}
|
|
176
|
+
.codeBlock[data-code-theme="nord"] {
|
|
177
|
+
--code-bg: #2e3440;
|
|
178
|
+
--code-fg: #d8dee9;
|
|
179
|
+
--code-keyword: #81a1c1;
|
|
180
|
+
--code-string: #a3be8c;
|
|
181
|
+
--code-number: #b48ead;
|
|
182
|
+
--code-title: #88c0d0;
|
|
183
|
+
--code-comment: #8a97ad;
|
|
184
|
+
}
|
|
185
|
+
.codeBlock[data-code-theme="dracula"] {
|
|
186
|
+
--code-bg: #282a36;
|
|
187
|
+
--code-fg: #f8f8f2;
|
|
188
|
+
--code-keyword: #ff79c6;
|
|
189
|
+
--code-string: #f1fa8c;
|
|
190
|
+
--code-number: #bd93f9;
|
|
191
|
+
--code-title: #50fa7b;
|
|
192
|
+
--code-comment: #9baddb;
|
|
193
|
+
}
|
|
194
|
+
.codeBlock > figcaption {
|
|
195
|
+
color: var(--code-comment);
|
|
196
|
+
border-color: color-mix(in srgb, var(--code-fg) 15%, transparent);
|
|
197
|
+
}
|
|
198
|
+
.codeBlock pre code {
|
|
199
|
+
color: var(--code-fg);
|
|
200
|
+
}
|
|
201
|
+
.codeBlock :global(.hljs-keyword),
|
|
202
|
+
.codeBlock :global(.hljs-selector-tag),
|
|
203
|
+
.codeBlock :global(.hljs-tag) {
|
|
204
|
+
color: var(--code-keyword);
|
|
205
|
+
}
|
|
206
|
+
.codeBlock :global(.hljs-string),
|
|
207
|
+
.codeBlock :global(.hljs-regexp),
|
|
208
|
+
.codeBlock :global(.hljs-addition) {
|
|
209
|
+
color: var(--code-string);
|
|
210
|
+
}
|
|
211
|
+
.codeBlock :global(.hljs-number),
|
|
212
|
+
.codeBlock :global(.hljs-literal),
|
|
213
|
+
.codeBlock :global(.hljs-attr) {
|
|
214
|
+
color: var(--code-number);
|
|
215
|
+
}
|
|
216
|
+
.codeBlock :global(.hljs-title),
|
|
217
|
+
.codeBlock :global(.hljs-function),
|
|
218
|
+
.codeBlock :global(.hljs-built_in) {
|
|
219
|
+
color: var(--code-title);
|
|
220
|
+
}
|
|
221
|
+
.codeBlock :global(.hljs-comment),
|
|
222
|
+
.codeBlock :global(.hljs-meta) {
|
|
223
|
+
color: var(--code-comment);
|
|
224
|
+
}
|
|
225
|
+
.markdown :is(h1, h2, h3, h4, h5, h6)[id] {
|
|
226
|
+
scroll-margin-top: 32px;
|
|
227
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type FormHTMLAttributes, type Ref, type FormEvent } from "react";
|
|
2
|
+
import { type FormLayoutOptions } from "./FormLayout";
|
|
3
|
+
export type NativeFormProps = Omit<FormHTMLAttributes<HTMLFormElement>, "onSubmit"> & FormLayoutOptions & {
|
|
4
|
+
controller?: never;
|
|
5
|
+
ref?: Ref<HTMLFormElement>;
|
|
6
|
+
onSubmit?(event: FormEvent<HTMLFormElement>): void | Promise<void>;
|
|
7
|
+
onSubmitError?(error: unknown): void;
|
|
8
|
+
validationMode?: "submit" | "blur" | "change";
|
|
9
|
+
};
|
|
10
|
+
export declare function NativeForm({ children, layout, labelWidth, validationMode, ref, onSubmit, onSubmitError, onReset, onInvalidCapture, onInput, onChange, onBlurCapture, ...props }: NativeFormProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
useRef,
|
|
5
|
+
useImperativeHandle,
|
|
6
|
+
useState
|
|
7
|
+
} from "react";
|
|
8
|
+
import { FormLayoutContext } from "./FormLayout.js";
|
|
9
|
+
import {
|
|
10
|
+
FormValidationContext,
|
|
11
|
+
formControls,
|
|
12
|
+
validateForm
|
|
13
|
+
} from "./form-validation.js";
|
|
14
|
+
import { FormErrorSummary } from "./FormErrorSummary.js";
|
|
15
|
+
import { useUIConfig } from "./UIProvider.js";
|
|
16
|
+
function NativeForm({
|
|
17
|
+
children,
|
|
18
|
+
layout = "stacked",
|
|
19
|
+
labelWidth,
|
|
20
|
+
validationMode = "submit",
|
|
21
|
+
ref,
|
|
22
|
+
onSubmit,
|
|
23
|
+
onSubmitError,
|
|
24
|
+
onReset,
|
|
25
|
+
onInvalidCapture,
|
|
26
|
+
onInput,
|
|
27
|
+
onChange,
|
|
28
|
+
onBlurCapture,
|
|
29
|
+
...props
|
|
30
|
+
}) {
|
|
31
|
+
const [errors, setErrors] = useState({}), [submitError, setSubmitError] = useState(""), [pending, setPending] = useState(false);
|
|
32
|
+
const formRef = useRef(null), attempted = useRef(false), locked = useRef(false), touched = useRef(/* @__PURE__ */ new Set());
|
|
33
|
+
const { locale } = useUIConfig();
|
|
34
|
+
useImperativeHandle(ref, () => formRef.current);
|
|
35
|
+
const fieldKey = (field) => field.id || field.name;
|
|
36
|
+
const message = (field) => {
|
|
37
|
+
if (!field.willValidate || field.validity.valid) return "";
|
|
38
|
+
if (field.validity.customError) return field.validationMessage;
|
|
39
|
+
const en = locale.startsWith("en"), tw = /tw|hant/i.test(locale);
|
|
40
|
+
if (field.validity.valueMissing)
|
|
41
|
+
return en ? "This field is required." : tw ? "\u8ACB\u586B\u5BEB\u6B64\u6B04\u4F4D\u3002" : "\u8BF7\u586B\u5199\u6B64\u5B57\u6BB5\u3002";
|
|
42
|
+
if (field.validity.typeMismatch || field.validity.patternMismatch)
|
|
43
|
+
return en ? "Enter a value in the required format." : tw ? "\u8ACB\u8F38\u5165\u6B63\u78BA\u683C\u5F0F\u3002" : "\u8BF7\u8F93\u5165\u6B63\u786E\u683C\u5F0F\u3002";
|
|
44
|
+
return field.validationMessage;
|
|
45
|
+
};
|
|
46
|
+
const update = (target, blur = false) => {
|
|
47
|
+
if (!(target instanceof HTMLInputElement || target instanceof HTMLSelectElement || target instanceof HTMLTextAreaElement))
|
|
48
|
+
return;
|
|
49
|
+
const key = fieldKey(target);
|
|
50
|
+
if (!key) return;
|
|
51
|
+
if (blur) touched.current.add(key);
|
|
52
|
+
if (attempted.current || validationMode === "change" || touched.current.has(key)) {
|
|
53
|
+
const error = message(target);
|
|
54
|
+
setErrors((old) => {
|
|
55
|
+
const next = { ...old };
|
|
56
|
+
if (error) next[key] = error;
|
|
57
|
+
else delete next[key];
|
|
58
|
+
return next;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const submit = async (event) => {
|
|
63
|
+
const form = event.currentTarget;
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
if (locked.current || props["aria-busy"] === true || props["aria-busy"] === "true")
|
|
66
|
+
return;
|
|
67
|
+
attempted.current = true;
|
|
68
|
+
setSubmitError("");
|
|
69
|
+
const next = {};
|
|
70
|
+
for (const field of formControls(form)) {
|
|
71
|
+
const error = message(field);
|
|
72
|
+
if (error && fieldKey(field)) next[fieldKey(field)] = error;
|
|
73
|
+
}
|
|
74
|
+
setErrors(next);
|
|
75
|
+
if (!validateForm(form)) return;
|
|
76
|
+
locked.current = true;
|
|
77
|
+
try {
|
|
78
|
+
const result = onSubmit?.(event);
|
|
79
|
+
if (result && typeof result.then === "function") {
|
|
80
|
+
setPending(true);
|
|
81
|
+
await result;
|
|
82
|
+
}
|
|
83
|
+
} catch (error) {
|
|
84
|
+
setSubmitError(
|
|
85
|
+
locale.startsWith("en") ? "Could not submit. Please try again." : /tw|hant/i.test(locale) ? "\u63D0\u4EA4\u5931\u6557\uFF0C\u8ACB\u91CD\u8A66\u3002" : "\u63D0\u4EA4\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002"
|
|
86
|
+
);
|
|
87
|
+
onSubmitError?.(error);
|
|
88
|
+
} finally {
|
|
89
|
+
locked.current = false;
|
|
90
|
+
setPending(false);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const unmatched = Object.fromEntries(
|
|
94
|
+
Object.entries(errors).filter(
|
|
95
|
+
([id]) => !formRef.current?.ownerDocument.getElementById(id)?.closest("[data-field-id]")
|
|
96
|
+
)
|
|
97
|
+
);
|
|
98
|
+
return /* @__PURE__ */ jsx(FormLayoutContext, { value: { layout, labelWidth }, children: /* @__PURE__ */ jsx(FormValidationContext, { value: errors, children: /* @__PURE__ */ jsxs(
|
|
99
|
+
"form",
|
|
100
|
+
{
|
|
101
|
+
...props,
|
|
102
|
+
noValidate: true,
|
|
103
|
+
ref: formRef,
|
|
104
|
+
"aria-busy": pending || props["aria-busy"] || void 0,
|
|
105
|
+
onSubmit: submit,
|
|
106
|
+
onReset: (event) => {
|
|
107
|
+
onReset?.(event);
|
|
108
|
+
if (!event.defaultPrevented) {
|
|
109
|
+
attempted.current = false;
|
|
110
|
+
touched.current.clear();
|
|
111
|
+
setErrors({});
|
|
112
|
+
setSubmitError("");
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
onInvalidCapture: (event) => {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
onInvalidCapture?.(event);
|
|
118
|
+
const field = event.target;
|
|
119
|
+
const key = fieldKey(field);
|
|
120
|
+
if (key) {
|
|
121
|
+
touched.current.add(key);
|
|
122
|
+
setErrors((old) => ({ ...old, [key]: message(field) }));
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
onInput: (event) => {
|
|
126
|
+
onInput?.(event);
|
|
127
|
+
const target = event.target;
|
|
128
|
+
queueMicrotask(() => update(target));
|
|
129
|
+
},
|
|
130
|
+
onChange: (event) => {
|
|
131
|
+
onChange?.(event);
|
|
132
|
+
const target = event.target;
|
|
133
|
+
queueMicrotask(() => update(target));
|
|
134
|
+
},
|
|
135
|
+
onBlurCapture: (event) => {
|
|
136
|
+
onBlurCapture?.(event);
|
|
137
|
+
if (validationMode === "blur") update(event.target, true);
|
|
138
|
+
},
|
|
139
|
+
children: [
|
|
140
|
+
children,
|
|
141
|
+
(Object.keys(unmatched).length > 0 || submitError) && /* @__PURE__ */ jsx(
|
|
142
|
+
FormErrorSummary,
|
|
143
|
+
{
|
|
144
|
+
submitError,
|
|
145
|
+
errors: unmatched,
|
|
146
|
+
onFocus: (id) => formControls(formRef.current).find((field) => fieldKey(field) === id)?.focus()
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
) }) });
|
|
152
|
+
}
|
|
153
|
+
export {
|
|
154
|
+
NativeForm
|
|
155
|
+
};
|