@imfusion/web-ui 0.11.1-dev.45.gf7b49f57 → 0.11.1-dev.48.g0fcb0d30

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.
@@ -8,15 +8,35 @@ consumed by document metadata or manifests, with a build step that serves the fi
8
8
  For the library's favicon set and social sharing image, read `BrandAssets.mdx` through the packaged user-guide route in
9
9
  `imf-web-ui`.
10
10
 
11
- ## Photographs: WebP
11
+ ## Photographs: AVIF and WebP
12
12
 
13
- Convert photographs to WebP before adding them:
13
+ Encode photographs as AVIF and WebP at 800 and 1600px wide. A source narrower than a width skips it, and `srcSet` lists only
14
+ the widths that exist:
14
15
 
15
16
  ```sh
16
- magick source.png -resize 2000x -quality 80 -define webp:method=6 src/assets/name.webp
17
+ for w in 800 1600; do
18
+ magick source.png -resize "${w}x>" -quality 55 src/assets/name-$w.avif
19
+ magick source.png -resize "${w}x>" -quality 80 -define webp:method=6 src/assets/name-$w.webp
20
+ done
17
21
  ```
18
22
 
19
- Keep the long edge at 2000px or less. WebP is supported by the browser floor.
23
+ Render them through `<picture>`: an AVIF `<source>`, then a WebP `<source>`, each with `srcSet` and `sizes`, then an `<img>`
24
+ fallback. The browser takes the first format it supports at the width that fits. Both formats are supported by the browser
25
+ floor.
26
+
27
+ ```tsx
28
+ <picture>
29
+ <source type="image/avif" srcSet={`${name800Avif} 800w, ${name1600Avif} 1600w`} sizes="(max-width: 40rem) 100vw, 40rem" />
30
+ <source type="image/webp" srcSet={`${name800Webp} 800w, ${name1600Webp} 1600w`} sizes="(max-width: 40rem) 100vw, 40rem" />
31
+ <img src={name800Webp} width={800} height={400} alt="…" />
32
+ </picture>
33
+ ```
34
+
35
+ ## Loading
36
+
37
+ Every `<img>` carries `width` and `height` in the source's aspect ratio, so the browser reserves its space before it loads.
38
+ An image below the fold gets `loading="lazy"` and `decoding="async"`. The one image that is the page's largest paint gets
39
+ `fetchpriority="high"` and loads eagerly.
20
40
 
21
41
  ## Other formats
22
42
 
@@ -53,3 +53,13 @@ Keep a component's stylesheet, tests, and local types beside the component. A co
53
53
  be a layout or dumb component instead.
54
54
 
55
55
  A route-local component keeps its stylesheet and tests in the route's `-` folder beside it.
56
+
57
+ ## Semantic elements
58
+
59
+ Inside `AppShell`, the shell's parts render the landmarks: `AppShell.Header` a `<header>`, `AppShell.Navbar` a `<nav>`,
60
+ `AppShell.Aside` an `<aside>`, `AppShell.Main` the page's one `<main>`, and `AppShell.Footer` a `<footer>`. A page puts its
61
+ content inside those parts.
62
+
63
+ Custom markup uses the element for its meaning: `<section>` and `<article>` for content groups, `<time dateTime>` for a date,
64
+ `Button` for an action, and the router's `Link` for a destination. A page has one `Typo.H1`, and heading levels descend
65
+ without skipping.
@@ -1,423 +0,0 @@
1
- import { a as e, o as t, s as n } from "./utils-RZJAXfcf.js";
2
- import { _M as r, mh as i } from "./icons-vc1WZCxX.js";
3
- import { t as a } from "./meta-V_KyLeGn.js";
4
- import { cva as o, cx as s } from "class-variance-authority";
5
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
6
- import { Children as u, createContext as d, useCallback as f, useContext as p } from "react";
7
- import { Toggle as ee } from "@base-ui/react/toggle";
8
- import { ToggleGroup as te } from "@base-ui/react/toggle-group";
9
- import { Switch as m } from "@base-ui/react/switch";
10
- import { Tabs as h } from "@base-ui/react/tabs";
11
- var g = {
12
- flat: "imf-ui-kbd-module-flat",
13
- icon: "imf-ui-kbd-module-icon",
14
- primary: "imf-ui-kbd-module-primary",
15
- root: "imf-ui-kbd-module-root"
16
- }, _ = o(g.root, { variants: { variant: {
17
- default: null,
18
- primary: g.primary,
19
- flat: g.flat
20
- } } });
21
- function v({ variant: e = "default", icon: t = !1, children: n, ...a }) {
22
- return /* @__PURE__ */ l("kbd", {
23
- ...a,
24
- "data-imf-ui-component": "Kbd",
25
- className: _({
26
- variant: e,
27
- className: a.className
28
- }),
29
- children: [t && /* @__PURE__ */ c(r, {
30
- glyph: i,
31
- strokeWidth: 2,
32
- "aria-hidden": !0,
33
- className: g.icon
34
- }), n]
35
- });
36
- }
37
- //#endregion
38
- //#region src/components/kbd/kbd.meta.ts
39
- var y = {
40
- name: "Kbd",
41
- category: a.display,
42
- status: "experimental",
43
- description: "Shows a keyboard key or shortcut, such as the letter that activates a button. Also called a key hint; Button and Toggle render it through their `shortcut` prop.",
44
- origin: "native",
45
- internalDependencies: ["Icon"]
46
- }, ne = {
47
- ctrl: "Control",
48
- control: "Control",
49
- cmd: "Meta",
50
- "⌘": "Meta",
51
- meta: "Meta",
52
- opt: "Alt",
53
- option: "Alt",
54
- "⌥": "Alt",
55
- alt: "Alt",
56
- shift: "Shift",
57
- "⇧": "Shift",
58
- esc: "Escape",
59
- escape: "Escape"
60
- };
61
- function b(e) {
62
- let t = e.trim().split(/\s+/).filter(Boolean);
63
- if (t.length !== 0) return t.map((e) => ne[e.toLowerCase()] ?? (e.length === 1 ? e.toUpperCase() : e)).join("+");
64
- }
65
- //#endregion
66
- //#region src/components/toggle-group/toggle-group-size.ts
67
- var x = d("md"), S = {
68
- root: "imf-ui-toggle-module-root",
69
- shortcut: "imf-ui-toggle-module-shortcut",
70
- sizeSm: "imf-ui-toggle-module-sizeSm"
71
- }, re = o(S.root, { variants: { size: {
72
- sm: S.sizeSm,
73
- md: null
74
- } } }), C = 2;
75
- function ie(e) {
76
- let t = 0;
77
- return u.forEach(e, (e) => {
78
- typeof e == "string" || typeof e == "number" ? t += String(e).trim().length : e != null && typeof e != "boolean" && (t += C);
79
- }), t;
80
- }
81
- function w({ style: n, shortcut: r, size: i, children: a, ...o }) {
82
- let s = p(x), u = {
83
- "--glyph-count": ie(a),
84
- "--max-glyphs": C
85
- };
86
- return /* @__PURE__ */ l(ee, {
87
- "aria-keyshortcuts": r ? b(r) : void 0,
88
- ...o,
89
- "data-imf-ui-component": "Toggle",
90
- style: (e) => ({
91
- ...u,
92
- ...t(n, e)
93
- }),
94
- className: (t) => re({
95
- size: i ?? s,
96
- className: e(o.className, t)
97
- }),
98
- children: [a, r && /* @__PURE__ */ c(v, {
99
- variant: "flat",
100
- className: S.shortcut,
101
- "aria-hidden": !0,
102
- children: r
103
- })]
104
- });
105
- }
106
- var T = {
107
- root: "imf-ui-toggle-group-module-root",
108
- sizeSm: "imf-ui-toggle-group-module-sizeSm"
109
- }, E = o(T.root, { variants: { size: {
110
- sm: T.sizeSm,
111
- md: null
112
- } } });
113
- function D({ size: t = "md", ...n }) {
114
- return /* @__PURE__ */ c(x.Provider, {
115
- value: t ?? "md",
116
- children: /* @__PURE__ */ c(te, {
117
- ...n,
118
- "data-imf-ui-component": "ToggleGroup",
119
- className: (r) => E({
120
- size: t,
121
- className: e(n.className, r)
122
- })
123
- })
124
- });
125
- }
126
- var O = {
127
- alignCenter: "imf-ui-stack-module-alignCenter",
128
- alignEnd: "imf-ui-stack-module-alignEnd",
129
- alignStart: "imf-ui-stack-module-alignStart",
130
- alignStretch: "imf-ui-stack-module-alignStretch",
131
- gap0: "imf-ui-stack-module-gap0",
132
- gap1: "imf-ui-stack-module-gap1",
133
- gap10: "imf-ui-stack-module-gap10",
134
- gap2: "imf-ui-stack-module-gap2",
135
- gap3: "imf-ui-stack-module-gap3",
136
- gap4: "imf-ui-stack-module-gap4",
137
- gap5: "imf-ui-stack-module-gap5",
138
- gap6: "imf-ui-stack-module-gap6",
139
- gap7: "imf-ui-stack-module-gap7",
140
- gap8: "imf-ui-stack-module-gap8",
141
- gap9: "imf-ui-stack-module-gap9",
142
- justifyAround: "imf-ui-stack-module-justifyAround",
143
- justifyBetween: "imf-ui-stack-module-justifyBetween",
144
- justifyCenter: "imf-ui-stack-module-justifyCenter",
145
- justifyEnd: "imf-ui-stack-module-justifyEnd",
146
- justifyEvenly: "imf-ui-stack-module-justifyEvenly",
147
- justifyStart: "imf-ui-stack-module-justifyStart",
148
- root: "imf-ui-stack-module-root"
149
- }, k = o(O.root, { variants: {
150
- gap: {
151
- 0: O.gap0,
152
- 1: O.gap1,
153
- 2: O.gap2,
154
- 3: O.gap3,
155
- 4: O.gap4,
156
- 5: O.gap5,
157
- 6: O.gap6,
158
- 7: O.gap7,
159
- 8: O.gap8,
160
- 9: O.gap9,
161
- 10: O.gap10
162
- },
163
- align: {
164
- start: O.alignStart,
165
- center: O.alignCenter,
166
- end: O.alignEnd,
167
- stretch: O.alignStretch
168
- },
169
- justify: {
170
- start: O.justifyStart,
171
- center: O.justifyCenter,
172
- end: O.justifyEnd,
173
- between: O.justifyBetween,
174
- around: O.justifyAround,
175
- evenly: O.justifyEvenly
176
- }
177
- } });
178
- function ae({ gap: e = "4", align: t = "stretch", justify: n = "start", ...r }) {
179
- return /* @__PURE__ */ c("div", {
180
- ...r,
181
- "data-imf-ui-component": "Stack",
182
- className: k({
183
- gap: e,
184
- align: t,
185
- justify: n,
186
- className: r.className
187
- })
188
- });
189
- }
190
- var A = {
191
- root: "imf-ui-switch-module-root",
192
- thumb: "imf-ui-switch-module-thumb"
193
- }, oe = /* @__PURE__ */ n({
194
- Root: () => j,
195
- Thumb: () => M
196
- }), se = o(A.root), ce = o(A.thumb);
197
- function j(t) {
198
- return /* @__PURE__ */ c(m.Root, {
199
- ...t,
200
- "data-imf-ui-component": "Switch.Root",
201
- className: (n) => se({ className: e(t.className, n) })
202
- });
203
- }
204
- j.displayName = "Switch.Root";
205
- function M(t) {
206
- return /* @__PURE__ */ c(m.Thumb, {
207
- ...t,
208
- "data-imf-ui-component": "Switch.Thumb",
209
- className: (n) => ce({ className: e(t.className, n) })
210
- });
211
- }
212
- M.displayName = "Switch.Thumb";
213
- var N = {
214
- alignCenter: "imf-ui-row-module-alignCenter",
215
- alignEnd: "imf-ui-row-module-alignEnd",
216
- alignStart: "imf-ui-row-module-alignStart",
217
- alignStretch: "imf-ui-row-module-alignStretch",
218
- gap1: "imf-ui-row-module-gap1",
219
- gap10: "imf-ui-row-module-gap10",
220
- gap2: "imf-ui-row-module-gap2",
221
- gap3: "imf-ui-row-module-gap3",
222
- gap4: "imf-ui-row-module-gap4",
223
- gap5: "imf-ui-row-module-gap5",
224
- gap6: "imf-ui-row-module-gap6",
225
- gap7: "imf-ui-row-module-gap7",
226
- gap8: "imf-ui-row-module-gap8",
227
- gap9: "imf-ui-row-module-gap9",
228
- justifyAround: "imf-ui-row-module-justifyAround",
229
- justifyBetween: "imf-ui-row-module-justifyBetween",
230
- justifyCenter: "imf-ui-row-module-justifyCenter",
231
- justifyEnd: "imf-ui-row-module-justifyEnd",
232
- justifyEvenly: "imf-ui-row-module-justifyEvenly",
233
- justifyStart: "imf-ui-row-module-justifyStart",
234
- root: "imf-ui-row-module-root",
235
- wrap: "imf-ui-row-module-wrap"
236
- }, P = o(N.root, { variants: {
237
- gap: {
238
- 1: N.gap1,
239
- 2: N.gap2,
240
- 3: N.gap3,
241
- 4: N.gap4,
242
- 5: N.gap5,
243
- 6: N.gap6,
244
- 7: N.gap7,
245
- 8: N.gap8,
246
- 9: N.gap9,
247
- 10: N.gap10
248
- },
249
- align: {
250
- start: N.alignStart,
251
- center: N.alignCenter,
252
- end: N.alignEnd,
253
- stretch: N.alignStretch
254
- },
255
- justify: {
256
- start: N.justifyStart,
257
- center: N.justifyCenter,
258
- end: N.justifyEnd,
259
- between: N.justifyBetween,
260
- around: N.justifyAround,
261
- evenly: N.justifyEvenly
262
- },
263
- wrap: {
264
- true: N.wrap,
265
- false: null
266
- }
267
- } });
268
- function F({ gap: e = "2", align: t = "stretch", justify: n = "start", wrap: r = !1, ...i }) {
269
- return /* @__PURE__ */ c("div", {
270
- ...i,
271
- "data-imf-ui-component": "Row",
272
- className: P({
273
- gap: e,
274
- align: t,
275
- justify: n,
276
- wrap: r,
277
- className: i.className
278
- })
279
- });
280
- }
281
- var I = {
282
- item: "imf-ui-tabs-underline-module-item",
283
- rule: "imf-ui-tabs-underline-module-rule"
284
- }, L = o(I.rule), R = o(I.item), z = {
285
- indicator: "imf-ui-tabs-module-indicator",
286
- indicatorUnderline: "imf-ui-tabs-module-indicatorUnderline",
287
- list: "imf-ui-tabs-module-list",
288
- listFill: "imf-ui-tabs-module-listFill",
289
- listUnderline: "imf-ui-tabs-module-listUnderline",
290
- panel: "imf-ui-tabs-module-panel",
291
- panelUnderline: "imf-ui-tabs-module-panelUnderline",
292
- panelViewport: "imf-ui-tabs-module-panelViewport",
293
- panelViewportUnderline: "imf-ui-tabs-module-panelViewportUnderline",
294
- root: "imf-ui-tabs-module-root",
295
- tab: "imf-ui-tabs-module-tab",
296
- tabUnderline: "imf-ui-tabs-module-tabUnderline"
297
- }, B = /* @__PURE__ */ n({
298
- Indicator: () => Z,
299
- List: () => Y,
300
- Panel: () => $,
301
- PanelViewport: () => Q,
302
- Root: () => J,
303
- Tab: () => X
304
- }), V = o(z.list, { variants: {
305
- fill: {
306
- true: z.listFill,
307
- false: null
308
- },
309
- appearance: {
310
- boxed: null,
311
- underline: s(z.listUnderline, L())
312
- }
313
- } }), H = o(z.root), U = o(null, { variants: { appearance: {
314
- boxed: z.tab,
315
- underline: s(z.tabUnderline, R())
316
- } } }), W = o(null, { variants: { appearance: {
317
- boxed: z.indicator,
318
- underline: z.indicatorUnderline
319
- } } }), G = o(z.panelViewport, { variants: { appearance: {
320
- boxed: null,
321
- underline: z.panelViewportUnderline
322
- } } }), le = o(z.panel, { variants: { appearance: {
323
- boxed: null,
324
- underline: z.panelUnderline
325
- } } }), K = d("boxed");
326
- function q(e, t) {
327
- typeof e == "function" ? e(t) : e && (e.current = t);
328
- }
329
- function ue(e) {
330
- let t = new ResizeObserver(() => {
331
- let t = e.dataset.orientation === "vertical" ? e.scrollHeight > e.clientHeight : e.scrollWidth > e.clientWidth;
332
- e.toggleAttribute("data-overflowing", t);
333
- }), n = () => {
334
- t.disconnect(), t.observe(e);
335
- for (let n of e.children) t.observe(n);
336
- }, r = new MutationObserver(n);
337
- return r.observe(e, { childList: !0 }), n(), () => {
338
- t.disconnect(), r.disconnect();
339
- };
340
- }
341
- function J({ appearance: t = "boxed", ...n }) {
342
- let r = n.orientation === "vertical" ? "boxed" : t;
343
- return /* @__PURE__ */ c(K, {
344
- value: r,
345
- children: /* @__PURE__ */ c(h.Root, {
346
- ...n,
347
- "data-imf-ui-component": "Tabs.Root",
348
- className: (t) => H({ className: e(n.className, t) })
349
- })
350
- });
351
- }
352
- J.displayName = "Tabs.Root";
353
- function Y({ fill: t = !1, ref: n, ...r }) {
354
- let i = p(K), a = f((e) => {
355
- if (!e) return;
356
- q(n, e);
357
- let t = ue(e);
358
- return () => {
359
- t(), q(n, null);
360
- };
361
- }, [n]);
362
- return /* @__PURE__ */ c(h.List, {
363
- ...r,
364
- ref: a,
365
- "data-imf-ui-component": "Tabs.List",
366
- className: (n) => V({
367
- fill: t,
368
- appearance: i,
369
- className: e(r.className, n)
370
- })
371
- });
372
- }
373
- Y.displayName = "Tabs.List";
374
- function X(t) {
375
- let n = p(K);
376
- return /* @__PURE__ */ c(h.Tab, {
377
- ...t,
378
- "data-imf-ui-component": "Tabs.Tab",
379
- className: (r) => U({
380
- appearance: n,
381
- className: e(t.className, r)
382
- })
383
- });
384
- }
385
- X.displayName = "Tabs.Tab";
386
- function Z(t) {
387
- let n = p(K);
388
- return /* @__PURE__ */ c(h.Indicator, {
389
- ...t,
390
- "data-imf-ui-component": "Tabs.Indicator",
391
- className: (r) => W({
392
- appearance: n,
393
- className: e(t.className, r)
394
- })
395
- });
396
- }
397
- Z.displayName = "Tabs.Indicator";
398
- function Q(e) {
399
- let t = p(K);
400
- return /* @__PURE__ */ c("div", {
401
- ...e,
402
- "data-imf-ui-component": "Tabs.PanelViewport",
403
- className: G({
404
- appearance: t,
405
- className: e.className
406
- })
407
- });
408
- }
409
- Q.displayName = "Tabs.PanelViewport";
410
- function $(t) {
411
- let n = p(K);
412
- return /* @__PURE__ */ c(h.Panel, {
413
- ...t,
414
- "data-imf-ui-component": "Tabs.Panel",
415
- className: (r) => le({
416
- appearance: n,
417
- className: e(t.className, r)
418
- })
419
- });
420
- }
421
- $.displayName = "Tabs.Panel";
422
- //#endregion
423
- export { b as _, J as a, R as c, j as d, M as f, w as g, D as h, Q as i, L as l, ae as m, Y as n, X as o, oe as p, $ as r, B as s, Z as t, F as u, y as v, v as y };