@lo-tek/interfaces 0.42.0 → 0.43.0
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 +82 -0
- package/agent/astro.md +1 -1
- package/agent/bundles.md +1 -1
- package/agent/datastar.md +50 -50
- package/agent/html.md +53 -53
- package/agent/kotlin.md +4 -4
- package/agent/react.md +1 -1
- package/agent/templates.md +50 -50
- package/dist/components/frame/dialog/lt-dialog.d.ts +11 -3
- package/dist/components/frame/dialog/lt-dialog.d.ts.map +1 -1
- package/dist/components/frame/dialog/lt-dialog.js +59 -46
- package/dist/components/frame/dialog/lt-dialog.js.map +1 -1
- package/dist/components/frame/error-summary/lt-error-summary.d.ts +9 -6
- package/dist/components/frame/error-summary/lt-error-summary.d.ts.map +1 -1
- package/dist/components/frame/error-summary/lt-error-summary.js +38 -57
- package/dist/components/frame/error-summary/lt-error-summary.js.map +1 -1
- package/dist/components/frame/field/lt-field.d.ts +17 -26
- package/dist/components/frame/field/lt-field.d.ts.map +1 -1
- package/dist/components/frame/field/lt-field.js +81 -143
- package/dist/components/frame/field/lt-field.js.map +1 -1
- package/dist/components/frame/popover/lt-popover.d.ts +1 -1
- package/dist/components/frame/popover/lt-popover.d.ts.map +1 -1
- package/dist/components/frame/popover/lt-popover.js +31 -33
- package/dist/components/frame/popover/lt-popover.js.map +1 -1
- package/dist/components/frame/session-timeout/lt-session-timeout.d.ts +14 -2
- package/dist/components/frame/session-timeout/lt-session-timeout.d.ts.map +1 -1
- package/dist/components/frame/session-timeout/lt-session-timeout.js +73 -46
- package/dist/components/frame/session-timeout/lt-session-timeout.js.map +1 -1
- package/dist/components/frame/suggestion/lt-suggestion.d.ts +5 -7
- package/dist/components/frame/suggestion/lt-suggestion.d.ts.map +1 -1
- package/dist/components/frame/suggestion/lt-suggestion.js +57 -72
- package/dist/components/frame/suggestion/lt-suggestion.js.map +1 -1
- package/dist/components/frame/tabs/lt-tabs.d.ts +14 -5
- package/dist/components/frame/tabs/lt-tabs.d.ts.map +1 -1
- package/dist/components/frame/tabs/lt-tabs.js +86 -106
- package/dist/components/frame/tabs/lt-tabs.js.map +1 -1
- package/dist/components/frame/term/lt-term.d.ts +5 -1
- package/dist/components/frame/term/lt-term.d.ts.map +1 -1
- package/dist/components/frame/term/lt-term.js +23 -21
- package/dist/components/frame/term/lt-term.js.map +1 -1
- package/dist/components/host-element.d.ts +137 -2
- package/dist/components/host-element.d.ts.map +1 -1
- package/dist/components/host-element.js +187 -4
- package/dist/components/host-element.js.map +1 -1
- package/dist/lotek.css +1 -1
- package/dist/react.d.ts +51 -437
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +48 -208
- package/dist/react.js.map +1 -1
- package/manifest/manifest.json +1 -1
- package/package.json +7 -3
- package/src/components/frame/dialog/lt-dialog.ts +56 -50
- package/src/components/frame/error-summary/lt-error-summary.ts +33 -46
- package/src/components/frame/field/lt-field.ts +99 -207
- package/src/components/frame/popover/lt-popover.ts +37 -35
- package/src/components/frame/session-timeout/lt-session-timeout.ts +88 -46
- package/src/components/frame/suggestion/lt-suggestion.ts +59 -73
- package/src/components/frame/tabs/lt-tabs.ts +96 -122
- package/src/components/frame/term/lt-term.ts +27 -21
- package/src/components/host-element.ts +306 -3
- package/src/react.ts +125 -240
- package/web-types.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1,51 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { avatar } from "./components/css/avatar/avatar.js";
|
|
4
|
-
import { badge } from "./components/css/badge/badge.js";
|
|
5
|
-
import { breadcrumbs } from "./components/css/breadcrumbs/breadcrumbs.js";
|
|
6
|
-
import { button } from "./components/css/button/button.js";
|
|
7
|
-
import { card } from "./components/css/card/card.js";
|
|
8
|
-
import { checkbox } from "./components/css/checkbox/checkbox.js";
|
|
9
|
-
import { divider } from "./components/css/divider/divider.js";
|
|
10
|
-
import { errorText } from "./components/css/error-text/error-text.js";
|
|
11
|
-
import { fieldset, legend } from "./components/css/fieldset/fieldset.js";
|
|
12
|
-
import { fileUpload } from "./components/css/file-upload/file-upload.js";
|
|
13
|
-
import { heading } from "./components/css/heading/heading.js";
|
|
14
|
-
import { helpText } from "./components/css/help-text/help-text.js";
|
|
15
|
-
import { icon } from "./components/css/icon/icon.js";
|
|
16
|
-
import { input } from "./components/css/input/input.js";
|
|
17
|
-
import { label } from "./components/css/label/label.js";
|
|
18
|
-
import { link } from "./components/css/link/link.js";
|
|
19
|
-
import { list } from "./components/css/list/list.js";
|
|
20
|
-
import { pagination } from "./components/css/pagination/pagination.js";
|
|
21
|
-
import { paragraph } from "./components/css/paragraph/paragraph.js";
|
|
22
|
-
import { progress } from "./components/css/progress/progress.js";
|
|
23
|
-
import { radio } from "./components/css/radio/radio.js";
|
|
24
|
-
import { search } from "./components/css/search/search.js";
|
|
25
|
-
import { select } from "./components/css/select/select.js";
|
|
26
|
-
import { fieldStates, isFieldState, isRequiredMarker, managedNames, rememberManaged, requiredMarkers, } from "./components/css/shared.js";
|
|
27
|
-
import { skeleton } from "./components/css/skeleton/skeleton.js";
|
|
28
|
-
import { skipLink } from "./components/css/skip-link/skip-link.js";
|
|
29
|
-
import { spinner } from "./components/css/spinner/spinner.js";
|
|
30
|
-
import { srOnly } from "./components/css/sr-only/sr-only.js";
|
|
31
|
-
import { steps } from "./components/css/steps/steps.js";
|
|
32
|
-
import { switchControl } from "./components/css/switch/switch.js";
|
|
33
|
-
import { table, tableSort } from "./components/css/table/table.js";
|
|
34
|
-
import { tag } from "./components/css/tag/tag.js";
|
|
35
|
-
import { textarea } from "./components/css/textarea/textarea.js";
|
|
36
|
-
import { toggleGroup } from "./components/css/toggle-group/toggle-group.js";
|
|
37
|
-
import { tooltip } from "./components/css/tooltip/tooltip.js";
|
|
38
|
-
import { dialog } from "./components/frame/dialog/dialog.js";
|
|
39
|
-
import { errorSummary } from "./components/frame/error-summary/error-summary.js";
|
|
40
|
-
import { computeFieldAttributes, createFieldId, } from "./components/frame/field/field-core.js";
|
|
41
|
-
import { popover } from "./components/frame/popover/popover.js";
|
|
42
|
-
import { sessionTimeout } from "./components/frame/session-timeout/session-timeout.js";
|
|
43
|
-
import { suggestion } from "./components/frame/suggestion/suggestion.js";
|
|
1
|
+
import { managedNames, rememberManaged } from "./components/css/shared.js";
|
|
2
|
+
import { createFieldId } from "./components/frame/field/field-core.js";
|
|
44
3
|
import { tabsWithState, } from "./components/frame/tabs/tabs.js";
|
|
45
4
|
import { termWithState } from "./components/frame/term/term.js";
|
|
46
|
-
import { connectionStatus } from "./components/standalone/connection-status/connection-status.js";
|
|
47
|
-
import { toast } from "./components/standalone/toast/toast.js";
|
|
48
5
|
import { setAttributes as setHtmlAttributes } from "./dom.js";
|
|
6
|
+
import { lt as html } from "./lt.js";
|
|
49
7
|
/**
|
|
50
8
|
* The attributes that have another name in React.
|
|
51
9
|
*
|
|
@@ -118,16 +76,48 @@ export function setAttributes(element, ...sets) {
|
|
|
118
76
|
setHtmlAttributes(element, ...sets.map((set) => toHtmlAttributes(set)));
|
|
119
77
|
}
|
|
120
78
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
|
|
125
|
-
|
|
79
|
+
* The result with the React names. A set is recognised by what
|
|
80
|
+
* `attributes()` notes on every set a builder function makes, not by its
|
|
81
|
+
* shape, so a compound whose parts are all absent is not taken for one.
|
|
82
|
+
*/
|
|
83
|
+
function toReactResult(value) {
|
|
84
|
+
if (Array.isArray(value))
|
|
85
|
+
return value.map(toReactResult);
|
|
86
|
+
if (!value || typeof value !== "object")
|
|
87
|
+
return value;
|
|
88
|
+
if (managedNames(value))
|
|
89
|
+
return toReactAttributes(value);
|
|
90
|
+
return Object.fromEntries(Object.entries(value).map(([name, child]) => [name, toReactResult(child)]));
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Wraps a builder function so the result gets the React names, and keeps
|
|
94
|
+
* what hangs on the function: `variants`, `isVariant` and the others.
|
|
126
95
|
*/
|
|
127
96
|
function forReact(fn) {
|
|
128
|
-
const wrapped = (
|
|
97
|
+
const wrapped = (...args) => toReactResult(fn(...args));
|
|
129
98
|
return Object.assign(wrapped, fn);
|
|
130
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* A guard on `lt`, such as `isState`: it builds nothing, and passes through
|
|
102
|
+
* as the same function. Named `is` and a capital letter, as every guard in
|
|
103
|
+
* the package is.
|
|
104
|
+
*/
|
|
105
|
+
const isGuard = (name) => /^is[A-Z]/.test(name);
|
|
106
|
+
/**
|
|
107
|
+
* What stands by hand in `lt` below: the two that give the whole state, and
|
|
108
|
+
* `setAttributes`, which takes an element and builds nothing.
|
|
109
|
+
*/
|
|
110
|
+
const BY_HAND = ["tabs", "term", "setAttributes"];
|
|
111
|
+
function everyBuilder() {
|
|
112
|
+
const result = {};
|
|
113
|
+
for (const [name, value] of Object.entries(html))
|
|
114
|
+
if (!BY_HAND.includes(name))
|
|
115
|
+
result[name] =
|
|
116
|
+
typeof value === "function" && !isGuard(name)
|
|
117
|
+
? forReact(value)
|
|
118
|
+
: value;
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
131
121
|
/**
|
|
132
122
|
* Re-exported from the main entry point.
|
|
133
123
|
*
|
|
@@ -138,173 +128,23 @@ function forReact(fn) {
|
|
|
138
128
|
* also in an app without a server.
|
|
139
129
|
*/
|
|
140
130
|
export { createFieldId };
|
|
131
|
+
/**
|
|
132
|
+
* Every builder function from the main entry, with the React names. A new
|
|
133
|
+
* component comes along by itself; only the exceptions stand here.
|
|
134
|
+
*/
|
|
141
135
|
export const lt = {
|
|
142
|
-
|
|
143
|
-
alert: forReact(alert),
|
|
144
|
-
avatar: forReact(avatar),
|
|
145
|
-
badge: forReact(badge),
|
|
146
|
-
breadcrumbs: forReact(breadcrumbs),
|
|
147
|
-
button: forReact(button),
|
|
148
|
-
card: forReact(card),
|
|
149
|
-
checkbox: forReact(checkbox),
|
|
150
|
-
divider: forReact(divider),
|
|
151
|
-
errorText: forReact(errorText),
|
|
152
|
-
fieldset: forReact(fieldset),
|
|
153
|
-
heading: forReact(heading),
|
|
154
|
-
fileUpload: forReact(fileUpload),
|
|
155
|
-
helpText: forReact(helpText),
|
|
156
|
-
icon: forReact(icon),
|
|
157
|
-
input: forReact(input),
|
|
158
|
-
label: forReact(label),
|
|
159
|
-
legend: forReact(legend),
|
|
160
|
-
link: forReact(link),
|
|
161
|
-
list: forReact(list),
|
|
162
|
-
pagination: forReact(pagination),
|
|
163
|
-
paragraph: forReact(paragraph),
|
|
164
|
-
radio: forReact(radio),
|
|
165
|
-
search: forReact(search),
|
|
166
|
-
select: forReact(select),
|
|
167
|
-
skeleton: forReact(skeleton),
|
|
168
|
-
skipLink: forReact(skipLink),
|
|
169
|
-
progress: forReact(progress),
|
|
170
|
-
spinner: forReact(spinner),
|
|
171
|
-
srOnly: forReact(srOnly),
|
|
172
|
-
steps: forReact(steps),
|
|
173
|
-
switch: forReact(switchControl),
|
|
174
|
-
toggleGroup: forReact(toggleGroup),
|
|
175
|
-
tooltip: forReact(tooltip),
|
|
176
|
-
table: forReact(table),
|
|
177
|
-
tableSort: Object.assign((options) => {
|
|
178
|
-
const built = tableSort(options);
|
|
179
|
-
return {
|
|
180
|
-
header: built.header,
|
|
181
|
-
button: toReactAttributes(built.button),
|
|
182
|
-
};
|
|
183
|
-
}, { isDirection: tableSort.isDirection }),
|
|
184
|
-
tag: forReact(tag),
|
|
185
|
-
textarea: forReact(textarea),
|
|
186
|
-
/**
|
|
187
|
-
* Wires a whole field, with `className` and `htmlFor` on the label.
|
|
188
|
-
*
|
|
189
|
-
* `control`, `help` and `error` have no keys that need renaming, and are
|
|
190
|
-
* therefore the same in both entry points.
|
|
191
|
-
*/
|
|
192
|
-
field: (options) => {
|
|
193
|
-
const field = computeFieldAttributes(options);
|
|
194
|
-
return { ...field, label: toReactAttributes(field.label) };
|
|
195
|
-
},
|
|
196
|
-
/**
|
|
197
|
-
* The compound builder functions return one attribute set per element,
|
|
198
|
-
* and each set must be renamed on its own. `host` has `tabindex`, and the
|
|
199
|
-
* panels in `lt.tabs()` have both `tabindex` and `class`.
|
|
200
|
-
*/
|
|
201
|
-
errorSummary: (options = {}) => {
|
|
202
|
-
const built = errorSummary(options);
|
|
203
|
-
return {
|
|
204
|
-
host: toReactAttributes(built.host),
|
|
205
|
-
title: toReactAttributes(built.title),
|
|
206
|
-
};
|
|
207
|
-
},
|
|
208
|
-
dialog: Object.assign((options) => {
|
|
209
|
-
const built = dialog(options);
|
|
210
|
-
return {
|
|
211
|
-
host: built.host,
|
|
212
|
-
dialog: toReactAttributes(built.dialog),
|
|
213
|
-
header: toReactAttributes(built.header),
|
|
214
|
-
title: toReactAttributes(built.title),
|
|
215
|
-
subtitle: toReactAttributes(built.subtitle),
|
|
216
|
-
body: toReactAttributes(built.body),
|
|
217
|
-
footer: toReactAttributes(built.footer),
|
|
218
|
-
};
|
|
219
|
-
}, {
|
|
220
|
-
dialog: dialog.dialog,
|
|
221
|
-
header: dialog.header,
|
|
222
|
-
title: dialog.title,
|
|
223
|
-
subtitle: dialog.subtitle,
|
|
224
|
-
body: dialog.body,
|
|
225
|
-
footer: dialog.footer,
|
|
226
|
-
colors: dialog.colors,
|
|
227
|
-
isColor: dialog.isColor,
|
|
228
|
-
}),
|
|
229
|
-
popover: Object.assign((options) => {
|
|
230
|
-
const built = popover(options);
|
|
231
|
-
return {
|
|
232
|
-
host: built.host,
|
|
233
|
-
trigger: toReactAttributes(built.trigger),
|
|
234
|
-
panel: toReactAttributes(built.panel),
|
|
235
|
-
};
|
|
236
|
-
}, { isPlacement: popover.isPlacement }),
|
|
136
|
+
...everyBuilder(),
|
|
237
137
|
/**
|
|
238
138
|
* The whole state, not just the links: React reports a mismatch for every
|
|
239
139
|
* attribute the component writes on an element React has rendered. See
|
|
240
140
|
* `tabsWithState`.
|
|
241
141
|
*/
|
|
242
|
-
tabs: (options) =>
|
|
243
|
-
const built = tabsWithState(options);
|
|
244
|
-
return {
|
|
245
|
-
list: toReactAttributes(built.list),
|
|
246
|
-
item: toReactAttributes(built.item),
|
|
247
|
-
tabs: built.tabs.map(toReactAttributes),
|
|
248
|
-
panels: built.panels.map(toReactAttributes),
|
|
249
|
-
};
|
|
250
|
-
},
|
|
142
|
+
tabs: (options) => toReactResult(tabsWithState(options)),
|
|
251
143
|
/**
|
|
252
144
|
* With `aria-expanded`, which `<lt-term>` writes: React reports a mismatch
|
|
253
145
|
* for an attribute it did not render. See `termWithState`.
|
|
254
146
|
*/
|
|
255
|
-
term: (options) =>
|
|
256
|
-
const built = termWithState(options);
|
|
257
|
-
return {
|
|
258
|
-
word: toReactAttributes(built.word),
|
|
259
|
-
entry: toReactAttributes(built.entry),
|
|
260
|
-
};
|
|
261
|
-
},
|
|
262
|
-
suggestion: (options) => {
|
|
263
|
-
const built = suggestion(options);
|
|
264
|
-
return {
|
|
265
|
-
...built,
|
|
266
|
-
label: toReactAttributes(built.label),
|
|
267
|
-
control: toReactAttributes(built.control),
|
|
268
|
-
list: toReactAttributes(built.list),
|
|
269
|
-
options: built.options.map(toReactAttributes),
|
|
270
|
-
empty: toReactAttributes(built.empty),
|
|
271
|
-
status: toReactAttributes(built.status),
|
|
272
|
-
value: toReactAttributes(built.value),
|
|
273
|
-
};
|
|
274
|
-
},
|
|
275
|
-
toast: (options = {}) => {
|
|
276
|
-
const built = toast(options);
|
|
277
|
-
return {
|
|
278
|
-
host: toReactAttributes(built.host),
|
|
279
|
-
message: toReactAttributes(built.message),
|
|
280
|
-
close: toReactAttributes(built.close),
|
|
281
|
-
};
|
|
282
|
-
},
|
|
283
|
-
sessionTimeout: Object.assign((options) => {
|
|
284
|
-
const built = sessionTimeout(options);
|
|
285
|
-
return {
|
|
286
|
-
host: toReactAttributes(built.host),
|
|
287
|
-
dialog: toReactAttributes(built.dialog),
|
|
288
|
-
title: toReactAttributes(built.title),
|
|
289
|
-
text: toReactAttributes(built.text),
|
|
290
|
-
count: toReactAttributes(built.count),
|
|
291
|
-
live: toReactAttributes(built.live),
|
|
292
|
-
actions: toReactAttributes(built.actions),
|
|
293
|
-
extend: toReactAttributes(built.extend),
|
|
294
|
-
logout: toReactAttributes(built.logout),
|
|
295
|
-
};
|
|
296
|
-
}, {
|
|
297
|
-
dialog: sessionTimeout.dialog,
|
|
298
|
-
title: sessionTimeout.title,
|
|
299
|
-
text: sessionTimeout.text,
|
|
300
|
-
count: sessionTimeout.count,
|
|
301
|
-
actions: sessionTimeout.actions,
|
|
302
|
-
}),
|
|
303
|
-
connectionStatus: forReact(connectionStatus),
|
|
147
|
+
term: (options) => toReactResult(termWithState(options)),
|
|
304
148
|
setAttributes,
|
|
305
|
-
states: fieldStates,
|
|
306
|
-
isState: isFieldState,
|
|
307
|
-
markers: requiredMarkers,
|
|
308
|
-
isMarker: isRequiredMarker,
|
|
309
149
|
};
|
|
310
150
|
//# sourceMappingURL=react.js.map
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AACtE,OAAO,EAEL,aAAa,GACd,MAAM,iCAAiC,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAC/D,OAAO,EAAmB,aAAa,IAAI,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC9E,OAAO,EAAE,EAAE,IAAI,IAAI,EAAW,MAAM,SAAS,CAAA;AAqD7C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,GAA2B;IAC1C,KAAK,EAAE,WAAW;IAClB,GAAG,EAAE,SAAS;IACd,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,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EAAE,CAA6B,CAAA;AAC/D,CAAC;AAuBD;;;;GAIG;AACH,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEvD;;;GAGG;AACH,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAU,CAAA;AAa1D,SAAS,YAAY;IACnB,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QAC9C,IAAI,CAAE,OAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC;YAChD,MAAM,CAAC,IAAI,CAAC;gBACV,OAAO,KAAK,KAAK,UAAU,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;oBAC3C,CAAC,CAAC,QAAQ,CAAC,KAAsC,CAAC;oBAClD,CAAC,CAAC,KAAK,CAAA;IACf,OAAO,MAAkB,CAAA;AAC3B,CAAC;AAED;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,CAAA;AAuBxB;;;GAGG;AACH,MAAM,CAAC,MAAM,EAAE,GAAY;IACzB,GAAG,YAAY,EAAE;IAEjB;;;;OAIG;IACH,IAAI,EAAE,CAAC,OAA6B,EAAE,EAAE,CACtC,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAEnC;IAEH;;;OAGG;IACH,IAAI,EAAE,CAAC,OAA4C,EAAE,EAAE,CACrD,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAEnC;IAEH,aAAa;CACd,CAAA"}
|
package/manifest/manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lo-tek/interfaces",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "Framework-agnostic design system: tokens, CSS components and web components.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "August Søberg-Klyver",
|
|
@@ -367,14 +367,14 @@
|
|
|
367
367
|
"access": "public"
|
|
368
368
|
},
|
|
369
369
|
"scripts": {
|
|
370
|
-
"generate": "bun scripts/generate-matrix.ts && bun scripts/generate-tokens.ts && bun scripts/generate-tailwind.ts && bun scripts/generate-vocabulary.ts && bun scripts/generate-agent.ts && bun scripts/generate-manifest.ts",
|
|
370
|
+
"generate": "bun scripts/extract-recipes.ts && bun scripts/generate-matrix.ts && bun scripts/generate-tokens.ts && bun scripts/generate-tailwind.ts && bun scripts/generate-vocabulary.ts && bun scripts/generate-agent.ts && bun scripts/generate-manifest.ts",
|
|
371
371
|
"build:css": "bun scripts/build-css.ts",
|
|
372
372
|
"pack": "bun run core && rm -rf dist && tsc -b --force && bun run build:css && npm pack --ignore-scripts",
|
|
373
373
|
"build:browser": "tsc -b && bun run build:css",
|
|
374
374
|
"vocabulary": "bun scripts/generate-vocabulary.ts",
|
|
375
375
|
"check:vocabulary": "bun scripts/check-vocabulary.ts",
|
|
376
376
|
"core": "bun ../core/scripts/build.ts && mkdir -p core && cp ../core/dist/lotek-core.wasm ../core/dist/lotek.wasm core/",
|
|
377
|
-
"build": "bun run core && bun run generate && rm -rf dist && tsc -b --force && bun run build:css && bun run check:exports && bun run check:server && bun run check:types && bun run check:writes && bun run check:test-files && bun run check:texts && bun run check:identifiers && bun run check:agent && bun run check:vocabulary && bun run check:css-witness && bun run check:wording && bun run check:cli && bun run check:version && bun run check:package",
|
|
377
|
+
"build": "bun run core && bun run generate && rm -rf dist && tsc -b --force && bun run build:css && bun run check:exports && bun run check:server && bun run check:types && bun run check:writes && bun run check:layers && bun run check:test-files && bun run check:texts && bun run check:identifiers && bun run check:agent && bun run check:vocabulary && bun run check:css-witness && bun run check:wording && bun run check:cli && bun run check:version && bun run check:package",
|
|
378
378
|
"typecheck": "tsc --noEmit",
|
|
379
379
|
"typecheck:tests": "tsc --noEmit -p tsconfig.tests.json",
|
|
380
380
|
"test:browser": "vitest --config vitest.config.ts --run",
|
|
@@ -391,6 +391,7 @@
|
|
|
391
391
|
"check:package": "publint",
|
|
392
392
|
"prepublishOnly": "bun run build",
|
|
393
393
|
"check:writes": "bun scripts/check-writes.ts",
|
|
394
|
+
"check:layers": "bun scripts/check-layers.ts",
|
|
394
395
|
"check:test-files": "bun scripts/check-test-files.ts",
|
|
395
396
|
"check:identifiers": "bun scripts/check-identifiers.ts",
|
|
396
397
|
"typecheck:scripts": "tsc --noEmit -p scripts/tsconfig.json",
|
|
@@ -411,7 +412,10 @@
|
|
|
411
412
|
"publint": "^0.3.24",
|
|
412
413
|
"react": "19",
|
|
413
414
|
"react-dom": "19",
|
|
415
|
+
"remark-mdx": "3.1.1",
|
|
416
|
+
"remark-parse": "11.0.0",
|
|
414
417
|
"tailwindcss": "4.3.0",
|
|
418
|
+
"unified": "11.0.5",
|
|
415
419
|
"vite": "7.3.7",
|
|
416
420
|
"vitest": "4.1.12"
|
|
417
421
|
}
|
|
@@ -2,12 +2,17 @@ import {
|
|
|
2
2
|
addClass,
|
|
3
3
|
defineElement,
|
|
4
4
|
HostElement,
|
|
5
|
+
hasName,
|
|
5
6
|
isServerControlled,
|
|
7
|
+
nameFromHeading,
|
|
8
|
+
ownership,
|
|
9
|
+
restoreModalOpen,
|
|
6
10
|
SERVER_CONTROLLED,
|
|
7
11
|
setAttr,
|
|
8
12
|
setFlag,
|
|
9
13
|
uniqueId,
|
|
10
14
|
warnAboutMarkup,
|
|
15
|
+
watcher,
|
|
11
16
|
} from "../../host-element.js"
|
|
12
17
|
import {
|
|
13
18
|
DIALOG_BODY_CLASS,
|
|
@@ -89,7 +94,23 @@ const upgradeChecked = new WeakSet<HTMLDialogElement>()
|
|
|
89
94
|
export class LtDialog extends HostElement {
|
|
90
95
|
static observedAttributes = ["open", SERVER_CONTROLLED] as const
|
|
91
96
|
|
|
92
|
-
private
|
|
97
|
+
private readonly watch = watcher(
|
|
98
|
+
(records) => {
|
|
99
|
+
const swapped = records.some(
|
|
100
|
+
(record) => record.type === "childList" && record.target === this,
|
|
101
|
+
)
|
|
102
|
+
if (swapped) this.sync()
|
|
103
|
+
else this.rewire()
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
childList: true,
|
|
107
|
+
subtree: true,
|
|
108
|
+
attributes: true,
|
|
109
|
+
// `aria-label` too: removed, the dialog is named after its title
|
|
110
|
+
// again, and without it here the dialog was left without a name.
|
|
111
|
+
attributeFilter: ["class", "id", "aria-labelledby", "aria-label"],
|
|
112
|
+
},
|
|
113
|
+
)
|
|
93
114
|
/**
|
|
94
115
|
* A separate observer for `open` on the `<dialog>` itself.
|
|
95
116
|
*
|
|
@@ -98,9 +119,12 @@ export class LtDialog extends HostElement {
|
|
|
98
119
|
* an observer running all of `sync()` there would have seen a host still
|
|
99
120
|
* saying "open" and a dialog that was not modal, and opened it again before
|
|
100
121
|
* `close` was handled. This one does only one thing: it puts the attribute
|
|
101
|
-
* back on a dialog that is still in the top layer.
|
|
122
|
+
* back on a dialog that is still in the top layer. It is started again on
|
|
123
|
+
* a dialog the server replaced.
|
|
102
124
|
*/
|
|
103
|
-
private
|
|
125
|
+
private readonly openWatch = watcher(() => this.repairOpen(), {
|
|
126
|
+
attributeFilter: ["open"],
|
|
127
|
+
})
|
|
104
128
|
private dialogElement?: HTMLDialogElement
|
|
105
129
|
/**
|
|
106
130
|
* What the component last reported, so it reports only when the state
|
|
@@ -148,29 +172,13 @@ export class LtDialog extends HostElement {
|
|
|
148
172
|
* and opened it again before the close was handled. Every write compares
|
|
149
173
|
* first, or the observer would trigger itself.
|
|
150
174
|
*/
|
|
151
|
-
this.
|
|
152
|
-
const swapped = records.some(
|
|
153
|
-
(record) => record.type === "childList" && record.target === this,
|
|
154
|
-
)
|
|
155
|
-
if (swapped) this.sync()
|
|
156
|
-
else this.rewire()
|
|
157
|
-
})
|
|
158
|
-
this.observer.observe(this, {
|
|
159
|
-
childList: true,
|
|
160
|
-
subtree: true,
|
|
161
|
-
attributes: true,
|
|
162
|
-
// `aria-label` too: removed, the dialog is named after its title
|
|
163
|
-
// again, and without it here the dialog was left without a name.
|
|
164
|
-
attributeFilter: ["class", "id", "aria-labelledby", "aria-label"],
|
|
165
|
-
})
|
|
175
|
+
this.watch.start(this)
|
|
166
176
|
this.sync()
|
|
167
177
|
}
|
|
168
178
|
|
|
169
179
|
disconnectedCallback(): void {
|
|
170
|
-
this.
|
|
171
|
-
this.
|
|
172
|
-
this.openObserver?.disconnect()
|
|
173
|
-
this.openObserver = undefined
|
|
180
|
+
this.watch.stop()
|
|
181
|
+
this.openWatch.stop()
|
|
174
182
|
this.dialogElement?.removeEventListener("close", this.handleClose)
|
|
175
183
|
this.dialogElement = undefined
|
|
176
184
|
}
|
|
@@ -191,6 +199,13 @@ export class LtDialog extends HostElement {
|
|
|
191
199
|
|
|
192
200
|
/** The id the component gave the heading, so a patch gets the same one back. */
|
|
193
201
|
private titleId?: string
|
|
202
|
+
/**
|
|
203
|
+
* The `aria-labelledby` the component wrote on the `<dialog>`. Another
|
|
204
|
+
* value there is the server's, and stays; the component's own follows the
|
|
205
|
+
* title, so a patch that replaces the title does not leave the name
|
|
206
|
+
* pointing at an id that is gone.
|
|
207
|
+
*/
|
|
208
|
+
private readonly own = ownership()
|
|
194
209
|
|
|
195
210
|
/** The wiring alone, for an attribute record. See the observer. */
|
|
196
211
|
private rewire(): void {
|
|
@@ -230,8 +245,7 @@ export class LtDialog extends HostElement {
|
|
|
230
245
|
private nameless(dialog: HTMLDialogElement): boolean {
|
|
231
246
|
return (
|
|
232
247
|
dialog.childElementCount > 0 &&
|
|
233
|
-
!dialog
|
|
234
|
-
!dialog.hasAttribute("aria-label") &&
|
|
248
|
+
!hasName(dialog) &&
|
|
235
249
|
this.headingOf(dialog) === null
|
|
236
250
|
)
|
|
237
251
|
}
|
|
@@ -248,22 +262,27 @@ export class LtDialog extends HostElement {
|
|
|
248
262
|
private wire(dialog: HTMLDialogElement): void {
|
|
249
263
|
addClass(dialog, DIALOG_CLASS)
|
|
250
264
|
|
|
251
|
-
const
|
|
252
|
-
|
|
265
|
+
const name = nameFromHeading(this.own, this, dialog, () => {
|
|
266
|
+
const title = this.headingOf(dialog)
|
|
267
|
+
if (!title) return null
|
|
268
|
+
addClass(title, DIALOG_TITLE_CLASS)
|
|
269
|
+
if (!title.id) {
|
|
270
|
+
this.titleId ??= uniqueId("lt-dialog-title")
|
|
271
|
+
setAttr(title, "id", this.titleId)
|
|
272
|
+
}
|
|
273
|
+
return title.id
|
|
274
|
+
})
|
|
275
|
+
if (name === "server") {
|
|
253
276
|
// The attribute can list several ids. The title is the first one that
|
|
254
277
|
// is inside the dialog.
|
|
278
|
+
const named = (dialog.getAttribute("aria-labelledby") ?? "").trim()
|
|
255
279
|
const root = this.getRootNode() as Document | ShadowRoot
|
|
256
280
|
const title = named
|
|
257
281
|
.split(/\s+/)
|
|
258
282
|
.map((id) => root.getElementById?.(id) ?? null)
|
|
259
283
|
.find((element) => element !== null && dialog.contains(element))
|
|
260
284
|
if (title) addClass(title, DIALOG_TITLE_CLASS)
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
if (dialog.hasAttribute("aria-label")) return
|
|
264
|
-
|
|
265
|
-
const title = this.headingOf(dialog)
|
|
266
|
-
if (!title) {
|
|
285
|
+
} else if (name === "none") {
|
|
267
286
|
warnAboutMarkup(
|
|
268
287
|
this,
|
|
269
288
|
"the dialog has no name: it has no aria-labelledby, no " +
|
|
@@ -275,14 +294,7 @@ export class LtDialog extends HostElement {
|
|
|
275
294
|
return now !== null && this.nameless(now)
|
|
276
295
|
},
|
|
277
296
|
)
|
|
278
|
-
return
|
|
279
297
|
}
|
|
280
|
-
addClass(title, DIALOG_TITLE_CLASS)
|
|
281
|
-
if (!title.id) {
|
|
282
|
-
this.titleId ??= uniqueId("lt-dialog-title")
|
|
283
|
-
setAttr(title, "id", this.titleId)
|
|
284
|
-
}
|
|
285
|
-
setAttr(dialog, "aria-labelledby", title.id)
|
|
286
298
|
}
|
|
287
299
|
|
|
288
300
|
private notify(open: boolean, returnValue = ""): void {
|
|
@@ -316,14 +328,10 @@ export class LtDialog extends HostElement {
|
|
|
316
328
|
*/
|
|
317
329
|
private repairOpen(): void {
|
|
318
330
|
const dialog = this.dialogElement
|
|
319
|
-
if (!dialog?.isConnected || !dialog.matches(":modal") || dialog.open) {
|
|
320
|
-
return
|
|
321
|
-
}
|
|
322
|
-
|
|
323
331
|
// The attribute must come back either way: without it `close()` does
|
|
324
332
|
// nothing, and the dialog stayed in the top layer, invisible, with the
|
|
325
333
|
// rest of the page inert.
|
|
326
|
-
|
|
334
|
+
if (!dialog || !restoreModalOpen(dialog)) return
|
|
327
335
|
if (!isServerControlled(this)) return
|
|
328
336
|
|
|
329
337
|
/*
|
|
@@ -370,8 +378,7 @@ export class LtDialog extends HostElement {
|
|
|
370
378
|
// listener stayed attached to a detached node for as long as the host
|
|
371
379
|
// lived.
|
|
372
380
|
if (!dialog) {
|
|
373
|
-
this.
|
|
374
|
-
this.openObserver = undefined
|
|
381
|
+
this.openWatch.stop()
|
|
375
382
|
this.dialogElement?.removeEventListener("close", this.handleClose)
|
|
376
383
|
this.dialogElement = undefined
|
|
377
384
|
}
|
|
@@ -384,7 +391,8 @@ export class LtDialog extends HostElement {
|
|
|
384
391
|
// If the component is detached, a morph is building the server's
|
|
385
392
|
// version in a separate tree, and there is nothing to report. An
|
|
386
393
|
// empty element is a region the server has not filled yet.
|
|
387
|
-
() => this.
|
|
394
|
+
() => this.dialog === null,
|
|
395
|
+
{ silentWhenEmpty: true },
|
|
388
396
|
)
|
|
389
397
|
return
|
|
390
398
|
}
|
|
@@ -397,9 +405,7 @@ export class LtDialog extends HostElement {
|
|
|
397
405
|
this.dialogElement = dialog
|
|
398
406
|
dialog.addEventListener("close", this.handleClose)
|
|
399
407
|
|
|
400
|
-
this.
|
|
401
|
-
this.openObserver = new MutationObserver(() => this.repairOpen())
|
|
402
|
-
this.openObserver.observe(dialog, { attributeFilter: ["open"] })
|
|
408
|
+
this.openWatch.start(dialog)
|
|
403
409
|
}
|
|
404
410
|
|
|
405
411
|
this.repairOpen()
|