@hussmartinez/ui 0.2.0 → 0.3.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/dist/react.js ADDED
@@ -0,0 +1,1287 @@
1
+ "use client";
2
+ import { a as uiMessages, i as warnInDevelopment, n as cssWriterOf, o as UiError, t as isThemePair } from "./shared/pair-DLVFV6vU.js";
3
+ import { createMessages, sdkCoreMessages } from "@hussmartinez/sdk-core";
4
+ import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { flushSync } from "react-dom";
7
+ // src/internal/single-copy.ts
8
+ var REGISTRY = /* @__PURE__ */ Symbol.for("@hussmartinez/ui");
9
+ var THIS_COPY = {};
10
+ var checked = false;
11
+ function ownVersion() {
12
+ return "0.3.0";
13
+ }
14
+ function checkSingleCopy() {
15
+ if (checked || !(typeof process !== "undefined" && process.env.NODE_ENV !== "production")) return;
16
+ checked = true;
17
+ const global = globalThis;
18
+ const copies = global[REGISTRY] ?? /* @__PURE__ */ new Map();
19
+ global[REGISTRY] = copies;
20
+ copies.set(THIS_COPY, ownVersion());
21
+ if (copies.size > 1) {
22
+ if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment(`${copies.size} copies of @hussmartinez/ui are in use (${[...copies.values()].join(", ")}). Providers from one copy don't reach components from another, so text falls back to English and announcements are lost. Install a single version: \`npm ls @hussmartinez/ui\` shows where each comes from, and every SDK and your application should use the same minor version.`);
23
+ }
24
+ }
25
+ // src/components/announcer/Announcer.tsx
26
+ var AnnouncerContext = /* @__PURE__ */ createContext(void 0);
27
+ function AnnouncerProvider({ children }) {
28
+ checkSingleCopy();
29
+ const [polite, setPolite] = useState({
30
+ message: "",
31
+ count: 0
32
+ });
33
+ const [assertive, setAssertive] = useState({
34
+ message: "",
35
+ count: 0
36
+ });
37
+ const frames = useRef({});
38
+ useEffect(() => () => {
39
+ for (const frame of Object.values(frames.current)) cancelAnimationFrame(frame);
40
+ }, []);
41
+ const announce = useCallback((message, options) => {
42
+ const politeness = options?.politeness ?? "polite";
43
+ const set = politeness === "assertive" ? setAssertive : setPolite;
44
+ set((region) => ({
45
+ message: "",
46
+ count: region.count
47
+ }));
48
+ const pending = frames.current[politeness];
49
+ if (pending !== void 0) cancelAnimationFrame(pending);
50
+ frames.current[politeness] = requestAnimationFrame(() => {
51
+ delete frames.current[politeness];
52
+ set((region) => ({
53
+ message,
54
+ count: region.count + 1
55
+ }));
56
+ });
57
+ }, []);
58
+ return /* @__PURE__ */ jsxs(AnnouncerContext.Provider, {
59
+ value: announce,
60
+ children: [children, /* @__PURE__ */ jsxs("div", {
61
+ className: "hm-visually-hidden hm-announcer",
62
+ children: [/* @__PURE__ */ jsx("div", {
63
+ role: "status",
64
+ "aria-live": "polite",
65
+ "aria-atomic": "true",
66
+ children: polite.message
67
+ }), /* @__PURE__ */ jsx("div", {
68
+ role: "alert",
69
+ "aria-live": "assertive",
70
+ "aria-atomic": "true",
71
+ children: assertive.message
72
+ })]
73
+ })]
74
+ });
75
+ }
76
+ function missingProvider() {
77
+ if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment("useAnnounce needs an AnnouncerProvider above it; the message wasn't announced.");
78
+ }
79
+ function useAnnounce() {
80
+ checkSingleCopy();
81
+ return useContext(AnnouncerContext) ?? missingProvider;
82
+ }
83
+ // src/components/shared/style-props.ts
84
+ function cx(...values) {
85
+ const joined = values.filter(Boolean).join(" ");
86
+ return joined === "" ? void 0 : joined;
87
+ }
88
+ function unstyledAttribute(unstyled) {
89
+ return unstyled ? "" : void 0;
90
+ }
91
+ // src/components/button/Button.tsx
92
+ function Icon({ children, className }) {
93
+ return /* @__PURE__ */ jsx("span", {
94
+ className: cx("hm-button-icon", className),
95
+ "aria-hidden": "true",
96
+ children
97
+ });
98
+ }
99
+ var Button = /* @__PURE__ */ forwardRef(function Button({ variant = "secondary", size = "medium", pressed, startIcon, endIcon, focusableWhenDisabled, disabled, className, classNames, unstyled, type = "button", onClick, children, ...props }, ref) {
100
+ const softDisabled = Boolean(focusableWhenDisabled && disabled);
101
+ const handleClick = (event) => {
102
+ if (softDisabled) {
103
+ event.preventDefault();
104
+ return;
105
+ }
106
+ onClick?.(event);
107
+ };
108
+ return /* @__PURE__ */ jsxs("button", {
109
+ ...props,
110
+ ref,
111
+ type,
112
+ className: cx("hm-button", `hm-button--${variant}`, size === "small" && "hm-button--small", classNames?.root, className),
113
+ "data-hm-unstyled": unstyledAttribute(unstyled),
114
+ "aria-pressed": pressed,
115
+ disabled: softDisabled ? void 0 : disabled,
116
+ "aria-disabled": softDisabled ? true : props["aria-disabled"],
117
+ onClick: handleClick,
118
+ children: [
119
+ startIcon == null ? null : /* @__PURE__ */ jsx(Icon, {
120
+ className: classNames?.icon,
121
+ children: startIcon
122
+ }),
123
+ children == null ? null : /* @__PURE__ */ jsx("span", {
124
+ className: cx("hm-button-label", classNames?.label),
125
+ children
126
+ }),
127
+ endIcon == null ? null : /* @__PURE__ */ jsx(Icon, {
128
+ className: classNames?.icon,
129
+ children: endIcon
130
+ })
131
+ ]
132
+ });
133
+ });
134
+ // src/components/button/IconButton.tsx
135
+ var IconButton = /* @__PURE__ */ forwardRef(function IconButton({ label, icon, className, ...props }, ref) {
136
+ if (label.trim() === "") {
137
+ if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment("IconButton needs a label: it's the button's only accessible name. Pass text from your message catalogue.");
138
+ }
139
+ return /* @__PURE__ */ jsx(Button, {
140
+ ...props,
141
+ ref,
142
+ "aria-label": label,
143
+ className: cx("hm-icon-button", className),
144
+ startIcon: icon
145
+ });
146
+ });
147
+ // src/components/messages/UiMessagesProvider.tsx
148
+ var UiMessagesContext = /* @__PURE__ */ createContext(void 0);
149
+ var english;
150
+ function defaultMessages() {
151
+ english ??= createMessages({
152
+ ...sdkCoreMessages,
153
+ ...uiMessages
154
+ });
155
+ return english;
156
+ }
157
+ function UiMessagesProvider({ messages, children }) {
158
+ checkSingleCopy();
159
+ return /* @__PURE__ */ jsx(UiMessagesContext.Provider, {
160
+ value: messages,
161
+ children
162
+ });
163
+ }
164
+ function useUiMessages() {
165
+ checkSingleCopy();
166
+ return useContext(UiMessagesContext) ?? defaultMessages();
167
+ }
168
+ function useUiText(key) {
169
+ checkSingleCopy();
170
+ const messages = useContext(UiMessagesContext);
171
+ return messages ? messages.t(key) : uiMessages[key];
172
+ }
173
+ function useUiLocale() {
174
+ checkSingleCopy();
175
+ return useContext(UiMessagesContext)?.locale ?? "en";
176
+ }
177
+ // src/components/dialog/CloseIcon.tsx
178
+ function CloseIcon$1() {
179
+ return /* @__PURE__ */ jsx("svg", {
180
+ viewBox: "0 0 24 24",
181
+ fill: "none",
182
+ stroke: "currentColor",
183
+ strokeWidth: 2,
184
+ strokeLinecap: "round",
185
+ "aria-hidden": "true",
186
+ focusable: "false",
187
+ children: /* @__PURE__ */ jsx("path", { d: "M6 6l12 12M18 6 6 18" })
188
+ });
189
+ }
190
+ // src/components/dialog/Dialog.tsx
191
+ function useMergedRef$1(forwarded) {
192
+ const local = useRef(null);
193
+ return [local, useCallback((node) => {
194
+ local.current = node;
195
+ if (typeof forwarded === "function") forwarded(node);
196
+ else if (forwarded) forwarded.current = node;
197
+ }, [forwarded])];
198
+ }
199
+ var Dialog = /* @__PURE__ */ forwardRef(function Dialog({ open, onOpenChange, title, description, footer, closeLabel, closeIcon, initialFocus, size = "medium", className, classNames, unstyled, children, onCancel, onClose, ...props }, forwardedRef) {
200
+ const defaultCloseLabel = useUiText("dialog.close");
201
+ const [ref, setRef] = useMergedRef$1(forwardedRef);
202
+ const body = useRef(null);
203
+ const titleId = useId();
204
+ const descriptionId = useId();
205
+ useEffect(() => {
206
+ const dialog = ref.current;
207
+ if (!dialog) return;
208
+ if (open && !dialog.open) {
209
+ dialog.showModal();
210
+ initialFocus?.current?.focus();
211
+ } else if (!open && dialog.open) dialog.close();
212
+ }, [
213
+ open,
214
+ initialFocus,
215
+ ref
216
+ ]);
217
+ useEffect(() => {
218
+ const element = body.current;
219
+ if (!element || typeof ResizeObserver === "undefined") return;
220
+ const update = () => {
221
+ if (element.scrollHeight > element.clientHeight) element.tabIndex = 0;
222
+ else element.removeAttribute("tabindex");
223
+ };
224
+ const resizes = new ResizeObserver(update);
225
+ resizes.observe(element);
226
+ for (const child of element.children) resizes.observe(child);
227
+ const children = new MutationObserver((records) => {
228
+ for (const record of records) for (const node of record.addedNodes) if (node instanceof Element) resizes.observe(node);
229
+ update();
230
+ });
231
+ children.observe(element, { childList: true });
232
+ update();
233
+ return () => {
234
+ resizes.disconnect();
235
+ children.disconnect();
236
+ };
237
+ }, []);
238
+ const handleCancel = (event) => {
239
+ onCancel?.(event);
240
+ event.preventDefault();
241
+ onOpenChange(false);
242
+ };
243
+ const handleClose = (event) => {
244
+ onClose?.(event);
245
+ if (open) onOpenChange(false);
246
+ };
247
+ return /* @__PURE__ */ jsxs("dialog", {
248
+ ...props,
249
+ ref: setRef,
250
+ "aria-labelledby": titleId,
251
+ "aria-describedby": description == null ? void 0 : descriptionId,
252
+ className: cx("hm-dialog", size !== "medium" && `hm-dialog--${size}`, classNames?.root, className),
253
+ "data-hm-unstyled": unstyledAttribute(unstyled),
254
+ onCancel: handleCancel,
255
+ onClose: handleClose,
256
+ children: [
257
+ /* @__PURE__ */ jsxs("div", {
258
+ className: cx("hm-dialog-header", classNames?.header),
259
+ children: [/* @__PURE__ */ jsx("h2", {
260
+ id: titleId,
261
+ className: cx("hm-dialog-title", classNames?.title),
262
+ children: title
263
+ }), /* @__PURE__ */ jsx(IconButton, {
264
+ variant: "quiet",
265
+ size: "small",
266
+ label: closeLabel ?? defaultCloseLabel,
267
+ icon: closeIcon ?? /* @__PURE__ */ jsx(CloseIcon$1, {}),
268
+ className: cx("hm-dialog-close", classNames?.close),
269
+ unstyled,
270
+ onClick: () => onOpenChange(false)
271
+ })]
272
+ }),
273
+ description == null ? null : /* @__PURE__ */ jsx("p", {
274
+ id: descriptionId,
275
+ className: cx("hm-dialog-description", classNames?.description),
276
+ children: description
277
+ }),
278
+ /* @__PURE__ */ jsx("div", {
279
+ ref: body,
280
+ className: cx("hm-dialog-body", classNames?.body),
281
+ children
282
+ }),
283
+ footer == null ? null : /* @__PURE__ */ jsx("div", {
284
+ className: cx("hm-dialog-footer", classNames?.footer),
285
+ children: footer
286
+ })
287
+ ]
288
+ });
289
+ });
290
+ // src/components/field/field-context.ts
291
+ var FieldContext = /* @__PURE__ */ createContext(void 0);
292
+ function useFieldControl() {
293
+ checkSingleCopy();
294
+ return useContext(FieldContext);
295
+ }
296
+ function joinIds(...ids) {
297
+ const joined = ids.filter(Boolean).join(" ");
298
+ return joined === "" ? void 0 : joined;
299
+ }
300
+ function useFieldProps(own, label) {
301
+ const field = useFieldControl();
302
+ if (!field) return {
303
+ id: own.id,
304
+ "aria-describedby": own["aria-describedby"],
305
+ "aria-invalid": own["aria-invalid"]
306
+ };
307
+ if (label !== void 0 || own["aria-label"] !== void 0) {
308
+ if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment("A control inside Field has its own label or aria-label, which replaces the field's visible label for screen readers. Leave it out, and set Field's label instead.");
309
+ }
310
+ if (own.id !== void 0 && own.id !== field.id) {
311
+ if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment("A control inside Field has its own id, so the field's label doesn't point at it. Pass the id to Field's controlId instead.");
312
+ }
313
+ return {
314
+ id: own.id ?? field.id,
315
+ "aria-describedby": joinIds(field["aria-describedby"], own["aria-describedby"]),
316
+ "aria-invalid": own["aria-invalid"] ?? field["aria-invalid"]
317
+ };
318
+ }
319
+ // src/components/field/Field.tsx
320
+ var Field = /* @__PURE__ */ forwardRef(function Field({ label, description, error, controlId, className, classNames, unstyled, children, ...props }, ref) {
321
+ const generated = useId();
322
+ const id = controlId ?? `${generated}-control`;
323
+ const descriptionId = `${generated}-description`;
324
+ const errorId = `${generated}-error`;
325
+ const hasDescription = description != null && description !== false;
326
+ const hasError = error != null && error !== false;
327
+ const control = {
328
+ id,
329
+ "aria-describedby": joinIds(hasDescription ? descriptionId : void 0, hasError ? errorId : void 0),
330
+ "aria-invalid": hasError ? true : void 0
331
+ };
332
+ return /* @__PURE__ */ jsxs("div", {
333
+ ...props,
334
+ ref,
335
+ className: cx("hm-field", classNames?.root, className),
336
+ "data-hm-unstyled": unstyledAttribute(unstyled),
337
+ children: [
338
+ /* @__PURE__ */ jsx("label", {
339
+ htmlFor: id,
340
+ className: cx("hm-field-label", classNames?.label),
341
+ children: label
342
+ }),
343
+ hasDescription ? /* @__PURE__ */ jsx("div", {
344
+ id: descriptionId,
345
+ className: cx("hm-field-description", classNames?.description),
346
+ children: description
347
+ }) : null,
348
+ /* @__PURE__ */ jsx(FieldContext.Provider, {
349
+ value: control,
350
+ children: typeof children === "function" ? children(control) : children
351
+ }),
352
+ hasError ? /* @__PURE__ */ jsx("div", {
353
+ id: errorId,
354
+ className: cx("hm-field-error", classNames?.error),
355
+ children: error
356
+ }) : null
357
+ ]
358
+ });
359
+ });
360
+ // src/components/file-drop-zone/FileDropZone.tsx
361
+ var hasFiles = (event) => event.dataTransfer?.types.includes("Files") ?? false;
362
+ function accepts(file, accept) {
363
+ const tokens = (accept ?? "").split(",").map((token) => token.trim().toLowerCase()).filter(Boolean);
364
+ if (tokens.length === 0) return true;
365
+ const name = file.name.toLowerCase();
366
+ const type = file.type.toLowerCase();
367
+ return tokens.some((token) => token.startsWith(".") ? name.endsWith(token) : token.endsWith("/*") ? type.startsWith(token.slice(0, -1)) : type === token);
368
+ }
369
+ function check(files, directories, accept, multiple) {
370
+ const accepted = [];
371
+ const rejected = [];
372
+ files.forEach((file, index) => {
373
+ if (directories.has(index)) rejected.push({
374
+ file,
375
+ reason: "directory"
376
+ });
377
+ else if (!multiple && files.length > 1) rejected.push({
378
+ file,
379
+ reason: "count"
380
+ });
381
+ else if (!accepts(file, accept)) rejected.push({
382
+ file,
383
+ reason: "type"
384
+ });
385
+ else accepted.push(file);
386
+ });
387
+ return {
388
+ accepted,
389
+ rejected
390
+ };
391
+ }
392
+ function refuseStrayDrop(event) {
393
+ if (event.defaultPrevented || !hasFiles(event)) return;
394
+ event.preventDefault();
395
+ if (event.dataTransfer && event.type === "dragover") event.dataTransfer.dropEffect = "none";
396
+ }
397
+ var FileDropZone = /* @__PURE__ */ forwardRef(function FileDropZone({ onFiles, onFilesRejected, accept, multiple = false, disabled = false, preventStrayDrops = true, buttonLabel, buttonVariant = "primary", buttonRef, hint, className, classNames, unstyled, children, ...props }, ref) {
398
+ const input = useRef(null);
399
+ const entered = useRef(/* @__PURE__ */ new Set());
400
+ const [dragging, setDragging] = useState(false);
401
+ const hintId = useId();
402
+ const defaultLabel = useUiText(multiple ? "fileDropZone.chooseMultiple" : "fileDropZone.choose");
403
+ const defaultHint = useUiText(multiple ? "fileDropZone.hintMultiple" : "fileDropZone.hint");
404
+ useEffect(() => {
405
+ if (!preventStrayDrops) return;
406
+ window.addEventListener("dragover", refuseStrayDrop);
407
+ window.addEventListener("drop", refuseStrayDrop);
408
+ return () => {
409
+ window.removeEventListener("dragover", refuseStrayDrop);
410
+ window.removeEventListener("drop", refuseStrayDrop);
411
+ };
412
+ }, [preventStrayDrops]);
413
+ useEffect(() => {
414
+ if (disabled) {
415
+ entered.current.clear();
416
+ setDragging(false);
417
+ }
418
+ }, [disabled]);
419
+ const deliver = (files, directories = /* @__PURE__ */ new Set()) => {
420
+ const { accepted, rejected } = check(files, directories, accept, multiple);
421
+ if (accepted.length > 0) onFiles(accepted);
422
+ if (rejected.length > 0) onFilesRejected?.(rejected);
423
+ };
424
+ const choose = (event) => {
425
+ const files = [...event.currentTarget.files ?? []];
426
+ event.currentTarget.value = "";
427
+ deliver(files);
428
+ };
429
+ const handleDragEnter = (event) => {
430
+ if (!hasFiles(event)) return;
431
+ event.preventDefault();
432
+ if (disabled) return;
433
+ entered.current.add(event.target);
434
+ setDragging(true);
435
+ };
436
+ const handleDragOver = (event) => {
437
+ if (!hasFiles(event)) return;
438
+ event.preventDefault();
439
+ event.dataTransfer.dropEffect = disabled ? "none" : "copy";
440
+ };
441
+ const handleDragLeave = (event) => {
442
+ if (!hasFiles(event)) return;
443
+ const zone = event.currentTarget;
444
+ entered.current.delete(event.target);
445
+ for (const target of entered.current) if (!(target instanceof Node) || !zone.contains(target)) entered.current.delete(target);
446
+ if (entered.current.size === 0) setDragging(false);
447
+ };
448
+ const handleDrop = (event) => {
449
+ if (!hasFiles(event)) return;
450
+ event.preventDefault();
451
+ entered.current.clear();
452
+ setDragging(false);
453
+ if (disabled) return;
454
+ const files = [...event.dataTransfer.files];
455
+ const directories = /* @__PURE__ */ new Set();
456
+ [...event.dataTransfer.items].filter((item) => item.kind === "file").forEach((item, index) => {
457
+ if (item.webkitGetAsEntry?.()?.isDirectory) directories.add(index);
458
+ });
459
+ deliver(files, directories);
460
+ };
461
+ return /* @__PURE__ */ jsxs("div", {
462
+ ...props,
463
+ ref,
464
+ className: cx("hm-file-drop-zone", classNames?.root, className),
465
+ "data-hm-unstyled": unstyledAttribute(unstyled),
466
+ "data-hm-dragging": dragging ? "" : void 0,
467
+ "data-hm-disabled": disabled ? "" : void 0,
468
+ onDragEnter: handleDragEnter,
469
+ onDragOver: handleDragOver,
470
+ onDragLeave: handleDragLeave,
471
+ onDrop: handleDrop,
472
+ children: [
473
+ children,
474
+ /* @__PURE__ */ jsx(Button, {
475
+ ref: buttonRef,
476
+ variant: buttonVariant,
477
+ className: cx("hm-file-drop-zone-button", classNames?.button),
478
+ unstyled,
479
+ disabled,
480
+ "aria-describedby": hintId,
481
+ onClick: () => input.current?.click(),
482
+ children: buttonLabel ?? defaultLabel
483
+ }),
484
+ /* @__PURE__ */ jsx("div", {
485
+ id: hintId,
486
+ className: cx("hm-file-drop-zone-hint", classNames?.hint),
487
+ children: hint ?? defaultHint
488
+ }),
489
+ /* @__PURE__ */ jsx("input", {
490
+ ref: input,
491
+ type: "file",
492
+ accept,
493
+ multiple,
494
+ disabled,
495
+ tabIndex: -1,
496
+ "aria-hidden": "true",
497
+ hidden: true,
498
+ onChange: choose
499
+ })
500
+ ]
501
+ });
502
+ });
503
+ // src/components/shared/number.ts
504
+ function decimals(value) {
505
+ const text = String(value);
506
+ const exponent = /e-(\d+)$/.exec(text);
507
+ if (exponent) return Number(exponent[1]);
508
+ const point = text.indexOf(".");
509
+ return point === -1 ? 0 : text.length - point - 1;
510
+ }
511
+ function roundTo(value, places) {
512
+ return Number(value.toFixed(Math.min(places, 100)));
513
+ }
514
+ // src/components/number-field/NumberField.tsx
515
+ function notationOf(locale) {
516
+ const parts = new Intl.NumberFormat(locale).formatToParts(-12345.6);
517
+ const digits = /* @__PURE__ */ new Map();
518
+ [...new Intl.NumberFormat(locale, { useGrouping: false }).format(9876543210)].forEach((digit, index) => {
519
+ digits.set(digit, String(9 - index));
520
+ });
521
+ return {
522
+ group: parts.find((part) => part.type === "group")?.value ?? ",",
523
+ decimal: parts.find((part) => part.type === "decimal")?.value ?? ".",
524
+ digits
525
+ };
526
+ }
527
+ var SPACE = /[\s\u00a0\u202f]/;
528
+ var escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
529
+ function groupPattern(group) {
530
+ if (SPACE.test(group)) return /[\s\u00a0\u202f]/;
531
+ if (/^['\u2019]$/.test(group)) return /['\u2019]/;
532
+ return new RegExp(escapeRegExp(group));
533
+ }
534
+ function groupsInPlace(groups) {
535
+ const last = groups.length - 1;
536
+ return groups.every((group, index) => index === 0 ? /^\d{1,3}$/.test(group) : index === last ? /^\d{3}$/.test(group) : /^\d{2,3}$/.test(group));
537
+ }
538
+ function parseIn(notation, text) {
539
+ let normal = "";
540
+ for (const character of text.replace(/[\u061c\u200e\u200f]/g, "").trim()) normal += notation.digits.get(character) ?? character;
541
+ const sign = /^[-+\u2212]/.exec(normal)?.[0];
542
+ if (sign !== void 0) normal = normal.slice(1);
543
+ const parts = normal.split(notation.decimal);
544
+ if (parts.length > 2) return;
545
+ const groups = (parts[0] ?? "").split(groupPattern(notation.group));
546
+ if (groups.length > 1 && !groupsInPlace(groups)) return;
547
+ const integer = groups.join("");
548
+ const fraction = parts[1] ?? "";
549
+ if (!/^\d*$/.test(integer) || !/^\d*$/.test(fraction) || integer + fraction === "") return;
550
+ const value = Number(`${sign === "+" || sign === void 0 ? "" : "-"}${integer || "0"}.${fraction || "0"}`);
551
+ return Number.isFinite(value) ? value : void 0;
552
+ }
553
+ var NumberField = /* @__PURE__ */ forwardRef(function NumberField({ value: controlled, defaultValue, onValueChange, min, max, step = 1, largeStep, locale, parse, format, label, name, form, disabled, readOnly, className, classNames, unstyled, onBlur, onKeyDown, ...props }, ref) {
554
+ const lower = min ?? Number.NEGATIVE_INFINITY;
555
+ const upper = max ?? Number.POSITIVE_INFINITY;
556
+ const clamp = (n) => Math.min(Math.max(n, lower), Math.max(lower, upper));
557
+ const [uncontrolled, setUncontrolled] = useState(() => clamp(defaultValue ?? 0));
558
+ const [draft, setDraft] = useState(null);
559
+ const value = clamp(controlled ?? uncontrolled) || 0;
560
+ const contextLocale = useUiLocale();
561
+ const resolvedLocale = locale ?? contextLocale;
562
+ const notation = useMemo(() => notationOf(resolvedLocale), [resolvedLocale]);
563
+ const places = Math.min(20, Math.max(decimals(step), decimals(value)));
564
+ const formatter = useMemo(() => new Intl.NumberFormat(resolvedLocale, { maximumFractionDigits: places }), [resolvedLocale, places]);
565
+ const formatted = format ? format(value) : formatter.format(value);
566
+ const read = (text) => {
567
+ const parsed = parse ? parse(text) : parseIn(notation, text);
568
+ return parsed !== void 0 && Number.isFinite(parsed) ? parsed : void 0;
569
+ };
570
+ const fieldProps = useFieldProps(props, label);
571
+ if (label === void 0 && !props["aria-label"] && !props["aria-labelledby"] && fieldProps.id === void 0) {
572
+ if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment("NumberField needs an accessible name: pass label, or put it in a Field. Use text from your message catalogue.");
573
+ }
574
+ const commit = (next) => {
575
+ setDraft(null);
576
+ const settled = clamp(next) || 0;
577
+ if (settled === value) return;
578
+ if (controlled === void 0) setUncontrolled(settled);
579
+ onValueChange?.(settled);
580
+ };
581
+ const commitDraft = () => {
582
+ if (draft === null) return;
583
+ const parsed = read(draft);
584
+ if (parsed === void 0) setDraft(null);
585
+ else commit(parsed);
586
+ };
587
+ const handleChange = (event) => {
588
+ setDraft(event.currentTarget.value);
589
+ };
590
+ const handleBlur = (event) => {
591
+ commitDraft();
592
+ onBlur?.(event);
593
+ };
594
+ const handleKeyDown = (event) => {
595
+ onKeyDown?.(event);
596
+ if (event.defaultPrevented || event.nativeEvent.isComposing) return;
597
+ if (event.key === "Enter") {
598
+ flushSync(commitDraft);
599
+ return;
600
+ }
601
+ if (event.key === "Escape") {
602
+ if (draft !== null) {
603
+ event.preventDefault();
604
+ setDraft(null);
605
+ }
606
+ return;
607
+ }
608
+ if (readOnly || event.altKey || event.ctrlKey || event.metaKey) return;
609
+ const large = largeStep ?? step * 10;
610
+ const delta = {
611
+ ArrowUp: step,
612
+ ArrowDown: -step,
613
+ PageUp: large,
614
+ PageDown: -large
615
+ }[event.key];
616
+ if (delta === void 0) return;
617
+ event.preventDefault();
618
+ const base = (draft === null ? void 0 : read(draft)) ?? value;
619
+ const precision = Math.max(decimals(base), decimals(delta), min === void 0 ? 0 : decimals(min));
620
+ commit(roundTo(base + delta, precision));
621
+ };
622
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("input", {
623
+ ...props,
624
+ ...fieldProps,
625
+ ref,
626
+ type: "text",
627
+ role: "spinbutton",
628
+ inputMode: props.inputMode ?? (lower >= 0 ? "decimal" : "text"),
629
+ autoComplete: props.autoComplete ?? "off",
630
+ autoCorrect: props.autoCorrect ?? "off",
631
+ spellCheck: props.spellCheck ?? false,
632
+ disabled,
633
+ readOnly,
634
+ value: draft ?? formatted,
635
+ "aria-label": label ?? props["aria-label"],
636
+ "aria-valuenow": value,
637
+ "aria-valuemin": min,
638
+ "aria-valuemax": max,
639
+ "aria-valuetext": formatted,
640
+ className: cx("hm-number-field", classNames?.root, className),
641
+ "data-hm-unstyled": unstyledAttribute(unstyled),
642
+ onChange: handleChange,
643
+ onBlur: handleBlur,
644
+ onKeyDown: handleKeyDown
645
+ }), name === void 0 ? null : /* @__PURE__ */ jsx("input", {
646
+ type: "hidden",
647
+ name,
648
+ form,
649
+ disabled,
650
+ value
651
+ })] });
652
+ });
653
+ // src/components/progress-bar/ProgressBar.tsx
654
+ var ProgressBar = /* @__PURE__ */ forwardRef(function ProgressBar({ value, max = 100, label, valueText, className, classNames, unstyled, ...props }, ref) {
655
+ const defaultLabel = useUiText("progress.label");
656
+ const clamped = value === void 0 ? void 0 : Math.min(Math.max(value, 0), max);
657
+ return /* @__PURE__ */ jsx("progress", {
658
+ ...props,
659
+ ref,
660
+ value: clamped,
661
+ max,
662
+ "aria-label": label ?? defaultLabel,
663
+ "aria-valuetext": valueText,
664
+ className: cx("hm-progress-bar", classNames?.root, className),
665
+ "data-hm-unstyled": unstyledAttribute(unstyled)
666
+ });
667
+ });
668
+ // src/components/toolbar/toolbar-context.ts
669
+ var ToolbarContext = /* @__PURE__ */ createContext(void 0);
670
+ function useToolbar() {
671
+ checkSingleCopy();
672
+ return useContext(ToolbarContext);
673
+ }
674
+ // src/components/segmented-control/SegmentedControl.tsx
675
+ function SegmentedControlImpl({ label, value, onValueChange, options, size = "medium", className, classNames, unstyled, onKeyDown, ...props }, ref) {
676
+ const inToolbar = useToolbar() !== void 0;
677
+ const enabled = options.filter((option) => !option.disabled);
678
+ const tabStop = enabled.find((option) => option.value === value) ?? enabled[0];
679
+ const handleKeyDown = (event) => {
680
+ onKeyDown?.(event);
681
+ if (inToolbar || event.defaultPrevented) return;
682
+ const step = event.key === "ArrowRight" || event.key === "ArrowDown" ? 1 : event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 0;
683
+ if (step === 0 || enabled.length === 0) return;
684
+ event.preventDefault();
685
+ const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
686
+ const horizontal = event.key === "ArrowRight" || event.key === "ArrowLeft";
687
+ const direction = rtl && horizontal ? -step : step;
688
+ const current = Math.max(0, enabled.findIndex((option) => option.value === value));
689
+ const next = enabled[(current + direction + enabled.length) % enabled.length];
690
+ if (next) {
691
+ onValueChange(next.value);
692
+ event.currentTarget.querySelector(`[data-hm-value="${CSS.escape(next.value)}"]`)?.focus();
693
+ }
694
+ };
695
+ return /* @__PURE__ */ jsx("div", {
696
+ ...props,
697
+ ref,
698
+ role: "radiogroup",
699
+ "aria-label": label,
700
+ className: cx("hm-segmented-control", size === "small" && "hm-segmented-control--small", classNames?.root, className),
701
+ "data-hm-unstyled": unstyledAttribute(unstyled),
702
+ onKeyDown: handleKeyDown,
703
+ children: options.map((option) => {
704
+ const checked = option.value === value;
705
+ return /* @__PURE__ */ jsxs("button", {
706
+ type: "button",
707
+ role: "radio",
708
+ "aria-checked": checked,
709
+ "aria-label": option.hideLabel ? option.label : void 0,
710
+ disabled: option.disabled,
711
+ tabIndex: inToolbar ? void 0 : option === tabStop ? 0 : -1,
712
+ "data-hm-value": option.value,
713
+ className: cx("hm-segmented-control-option", classNames?.option),
714
+ onClick: () => {
715
+ if (!checked) onValueChange(option.value);
716
+ },
717
+ children: [option.icon == null ? null : /* @__PURE__ */ jsx("span", {
718
+ className: cx("hm-segmented-control-icon", classNames?.icon),
719
+ "aria-hidden": "true",
720
+ children: option.icon
721
+ }), option.hideLabel ? null : /* @__PURE__ */ jsx("span", {
722
+ className: cx("hm-segmented-control-label", classNames?.label),
723
+ children: option.label
724
+ })]
725
+ }, option.value);
726
+ })
727
+ });
728
+ }
729
+ var SegmentedControl = /* @__PURE__ */ forwardRef(SegmentedControlImpl);
730
+ // src/components/slider/Slider.tsx
731
+ function snap(value, min, max, step) {
732
+ const precision = Math.max(decimals(min), decimals(step));
733
+ const round = (n) => roundTo(n, precision);
734
+ const upper = Math.max(min, max);
735
+ const stepped = round(step > 0 ? min + Math.round((value - min) / step) * step : value);
736
+ const inRange = stepped > upper && step > 0 ? round(stepped - step) : stepped;
737
+ return Math.min(Math.max(inRange, min), upper);
738
+ }
739
+ var Slider = /* @__PURE__ */ forwardRef(function Slider({ value: controlled, defaultValue, onValueChange, min = 0, max = 100, step = 1, largeStep, formatValue, label, className, classNames, unstyled, onKeyDown, ...props }, ref) {
740
+ const [uncontrolled, setUncontrolled] = useState(() => snap(defaultValue ?? min, min, max, step));
741
+ const value = snap(controlled ?? uncontrolled, min, max, step);
742
+ const fieldProps = useFieldProps(props, label);
743
+ if (label === void 0 && !props["aria-label"] && !props["aria-labelledby"] && fieldProps.id === void 0) {
744
+ if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment("Slider needs an accessible name: pass label, or point a visible <label> at its id. Use text from your message catalogue.");
745
+ }
746
+ const change = (next) => {
747
+ const snapped = snap(next, min, max, step);
748
+ if (snapped === value) return;
749
+ if (controlled === void 0) setUncontrolled(snapped);
750
+ onValueChange?.(snapped);
751
+ };
752
+ const handleChange = (event) => {
753
+ change(event.currentTarget.valueAsNumber);
754
+ };
755
+ const handleKeyDown = (event) => {
756
+ onKeyDown?.(event);
757
+ if (event.defaultPrevented || event.altKey || event.metaKey) return;
758
+ const large = largeStep ?? Math.max(step, Math.round((max - min) / 10 / step) * step);
759
+ const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
760
+ const next = {
761
+ ArrowUp: value + step,
762
+ ArrowDown: value - step,
763
+ ArrowRight: rtl ? value - step : value + step,
764
+ ArrowLeft: rtl ? value + step : value - step,
765
+ PageUp: value + large,
766
+ PageDown: value - large,
767
+ Home: min,
768
+ End: max
769
+ }[event.key];
770
+ if (next === void 0) return;
771
+ event.preventDefault();
772
+ change(next);
773
+ };
774
+ return /* @__PURE__ */ jsx("input", {
775
+ ...props,
776
+ ...fieldProps,
777
+ ref,
778
+ type: "range",
779
+ min,
780
+ max,
781
+ step,
782
+ value,
783
+ "aria-label": label ?? props["aria-label"],
784
+ "aria-valuetext": formatValue?.(value),
785
+ className: cx("hm-slider", classNames?.root, className),
786
+ "data-hm-unstyled": unstyledAttribute(unstyled),
787
+ onChange: handleChange,
788
+ onKeyDown: handleKeyDown
789
+ });
790
+ });
791
+ // src/components/spinner/Spinner.tsx
792
+ var Spinner = /* @__PURE__ */ forwardRef(function Spinner({ label, className, classNames, unstyled, ...props }, ref) {
793
+ const defaultLabel = useUiText("spinner.label");
794
+ return /* @__PURE__ */ jsx("span", {
795
+ ...props,
796
+ ref,
797
+ role: "progressbar",
798
+ "aria-label": label ?? defaultLabel,
799
+ className: cx("hm-spinner", classNames?.root, className),
800
+ "data-hm-unstyled": unstyledAttribute(unstyled)
801
+ });
802
+ });
803
+ // src/components/toggle-button/ToggleButton.tsx
804
+ var ToggleButton = /* @__PURE__ */ forwardRef(function ToggleButton({ pressed: controlled, defaultPressed = false, onPressedChange, onClick, icon, label, className, ...props }, ref) {
805
+ const [uncontrolled, setUncontrolled] = useState(defaultPressed);
806
+ const pressed = controlled ?? uncontrolled;
807
+ const iconOnly = label !== void 0;
808
+ if (iconOnly && label.trim() === "") {
809
+ if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") warnInDevelopment("ToggleButton needs a label when it shows only an icon: it's the button's only accessible name. Pass text from your message catalogue.");
810
+ }
811
+ const handleClick = (event) => {
812
+ onClick?.(event);
813
+ if (event.defaultPrevented) return;
814
+ if (controlled === void 0) setUncontrolled(!pressed);
815
+ onPressedChange?.(!pressed);
816
+ };
817
+ return /* @__PURE__ */ jsx(Button, {
818
+ ...props,
819
+ ref,
820
+ ...iconOnly ? {
821
+ "aria-label": label,
822
+ startIcon: icon
823
+ } : {},
824
+ className: cx("hm-toggle-button", iconOnly && "hm-icon-button", className),
825
+ pressed,
826
+ onClick: handleClick
827
+ });
828
+ });
829
+ // src/components/toolbar/roving-focus.ts
830
+ var FOCUSABLE = "button:not(:disabled), a[href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex^=\"-\"]):not(button, a, input, select, textarea), [data-hm-roving]:not(:disabled)";
831
+ function items(toolbar) {
832
+ return [...toolbar.querySelectorAll(FOCUSABLE)].filter((element) => !element.closest("[hidden], [inert]") && element.getClientRects().length > 0);
833
+ }
834
+ function syncTabStop(toolbar, active) {
835
+ const list = items(toolbar);
836
+ const current = list.find((item) => item === active) ?? list.find((item) => item.tabIndex === 0 && item.dataset["hmTabStop"] !== void 0) ?? list[0];
837
+ for (const item of list) {
838
+ const isStop = item === current;
839
+ item.dataset["hmRoving"] = "";
840
+ item.tabIndex = isStop ? 0 : -1;
841
+ if (isStop) item.dataset["hmTabStop"] = "";
842
+ else delete item.dataset["hmTabStop"];
843
+ }
844
+ }
845
+ function editsText(target) {
846
+ if (!(target instanceof HTMLElement)) return false;
847
+ return target.isContentEditable || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement || target instanceof HTMLInputElement && ![
848
+ "button",
849
+ "checkbox",
850
+ "radio",
851
+ "reset",
852
+ "submit"
853
+ ].includes(target.type);
854
+ }
855
+ function moveFocus(toolbar, event, orientation) {
856
+ if (editsText(event.target)) return false;
857
+ const rtl = getComputedStyle(toolbar).direction === "rtl";
858
+ const next = orientation === "vertical" ? "ArrowDown" : rtl ? "ArrowLeft" : "ArrowRight";
859
+ const previous = orientation === "vertical" ? "ArrowUp" : rtl ? "ArrowRight" : "ArrowLeft";
860
+ const list = items(toolbar);
861
+ if (list.length === 0) return false;
862
+ const index = list.indexOf(event.target);
863
+ let target;
864
+ switch (event.key) {
865
+ case next:
866
+ target = list[(index + 1) % list.length];
867
+ break;
868
+ case previous:
869
+ target = list[(index - 1 + list.length) % list.length];
870
+ break;
871
+ case "Home":
872
+ target = list[0];
873
+ break;
874
+ case "End":
875
+ target = list[list.length - 1];
876
+ break;
877
+ default: return false;
878
+ }
879
+ if (target) {
880
+ syncTabStop(toolbar, target);
881
+ target.focus();
882
+ }
883
+ return true;
884
+ }
885
+ // src/components/toolbar/Toolbar.tsx
886
+ function useMergedRef(forwarded) {
887
+ const local = useRef(null);
888
+ return [local, useCallback((node) => {
889
+ local.current = node;
890
+ if (typeof forwarded === "function") forwarded(node);
891
+ else if (forwarded) forwarded.current = node;
892
+ }, [forwarded])];
893
+ }
894
+ var Toolbar = /* @__PURE__ */ forwardRef(function Toolbar({ label, orientation = "horizontal", className, classNames, unstyled, onKeyDown, onFocus, children, ...props }, forwardedRef) {
895
+ const [ref, setRef] = useMergedRef(forwardedRef);
896
+ useEffect(() => {
897
+ const toolbar = ref.current;
898
+ if (!toolbar) return;
899
+ syncTabStop(toolbar);
900
+ const observer = new MutationObserver(() => syncTabStop(toolbar, document.activeElement));
901
+ observer.observe(toolbar, {
902
+ childList: true,
903
+ subtree: true,
904
+ attributes: true,
905
+ attributeFilter: ["disabled", "hidden"]
906
+ });
907
+ return () => observer.disconnect();
908
+ }, [ref]);
909
+ const handleKeyDown = (event) => {
910
+ onKeyDown?.(event);
911
+ if (!event.defaultPrevented && ref.current && moveFocus(ref.current, event, orientation)) event.preventDefault();
912
+ };
913
+ const handleFocus = (event) => {
914
+ onFocus?.(event);
915
+ if (ref.current && event.target !== ref.current) syncTabStop(ref.current, event.target);
916
+ };
917
+ return /* @__PURE__ */ jsx(ToolbarContext.Provider, {
918
+ value: { orientation },
919
+ children: /* @__PURE__ */ jsx("div", {
920
+ ...props,
921
+ ref: setRef,
922
+ role: "toolbar",
923
+ "aria-label": label,
924
+ "aria-orientation": orientation,
925
+ className: cx("hm-toolbar", orientation === "vertical" && "hm-toolbar--vertical", classNames?.root, className),
926
+ "data-hm-unstyled": unstyledAttribute(unstyled),
927
+ onKeyDown: handleKeyDown,
928
+ onFocus: handleFocus,
929
+ children
930
+ })
931
+ });
932
+ });
933
+ // src/components/toolbar/ToolbarGroup.tsx
934
+ var ToolbarGroup = /* @__PURE__ */ forwardRef(function ToolbarGroup({ label, className, ...props }, ref) {
935
+ return /* @__PURE__ */ jsx("div", {
936
+ ...props,
937
+ ref,
938
+ role: "group",
939
+ "aria-label": label,
940
+ className: cx("hm-toolbar-group", className)
941
+ });
942
+ });
943
+ // src/components/toolbar/ToolbarSeparator.tsx
944
+ var ToolbarSeparator = /* @__PURE__ */ forwardRef(function ToolbarSeparator({ className, ...props }, ref) {
945
+ const toolbar = useToolbar();
946
+ return /* @__PURE__ */ jsx("hr", {
947
+ ...props,
948
+ ref,
949
+ "aria-orientation": toolbar?.orientation === "vertical" ? "horizontal" : "vertical",
950
+ className: cx("hm-toolbar-separator", className)
951
+ });
952
+ });
953
+ // src/components/visually-hidden/VisuallyHidden.tsx
954
+ var VisuallyHidden = /* @__PURE__ */ forwardRef(function VisuallyHidden({ as: Element = "span", className, ...props }, ref) {
955
+ return /* @__PURE__ */ jsx(Element, {
956
+ ...props,
957
+ ref,
958
+ className: cx("hm-visually-hidden", className)
959
+ });
960
+ });
961
+ // src/icons/create-icon.tsx
962
+ function renderIcon(name, nodes, mirror, { label, className, ...props }) {
963
+ return /* @__PURE__ */ jsx("svg", {
964
+ ...props,
965
+ xmlns: "http://www.w3.org/2000/svg",
966
+ viewBox: "0 0 24 24",
967
+ fill: "none",
968
+ stroke: "currentColor",
969
+ strokeWidth: 2,
970
+ strokeLinecap: "round",
971
+ strokeLinejoin: "round",
972
+ className: cx("hm-icon", className),
973
+ "data-hm-icon": name,
974
+ "data-hm-mirror": mirror ? "" : void 0,
975
+ focusable: "false",
976
+ role: label === void 0 ? void 0 : "img",
977
+ "aria-label": label,
978
+ "aria-hidden": label === void 0 ? true : void 0,
979
+ children: nodes.map(([Shape, attributes], index) => /* @__PURE__ */ jsx(Shape, { ...attributes }, index))
980
+ });
981
+ }
982
+ // src/icons/icons.generated.tsx
983
+ /*! Icons from Lucide (https://lucide.dev), ISC licence; those derived from Feather, MIT licence. See THIRD_PARTY_NOTICES.md in @hussmartinez/ui. */
984
+ function AddIcon(props) {
985
+ return renderIcon("add", [["path", { d: "M5 12h14" }], ["path", { d: "M12 5v14" }]], false, props);
986
+ }
987
+ function CheckIcon(props) {
988
+ return renderIcon("check", [["path", { d: "M20 6 9 17l-5-5" }]], false, props);
989
+ }
990
+ function ChevronDownIcon(props) {
991
+ return renderIcon("chevron-down", [["path", { d: "m6 9 6 6 6-6" }]], false, props);
992
+ }
993
+ function ChevronLeftIcon(props) {
994
+ return renderIcon("chevron-left", [["path", { d: "m15 18-6-6 6-6" }]], false, props);
995
+ }
996
+ function ChevronRightIcon(props) {
997
+ return renderIcon("chevron-right", [["path", { d: "m9 18 6-6-6-6" }]], false, props);
998
+ }
999
+ function CloseIcon(props) {
1000
+ return renderIcon("close", [["path", { d: "M18 6 6 18" }], ["path", { d: "m6 6 12 12" }]], false, props);
1001
+ }
1002
+ function DeleteIcon(props) {
1003
+ return renderIcon("delete", [
1004
+ ["path", { d: "M10 11v6" }],
1005
+ ["path", { d: "M14 11v6" }],
1006
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }],
1007
+ ["path", { d: "M3 6h18" }],
1008
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }]
1009
+ ], false, props);
1010
+ }
1011
+ function DownloadIcon(props) {
1012
+ return renderIcon("download", [
1013
+ ["path", { d: "M12 15V3" }],
1014
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }],
1015
+ ["path", { d: "m7 10 5 5 5-5" }]
1016
+ ], false, props);
1017
+ }
1018
+ function HighlighterIcon(props) {
1019
+ return renderIcon("highlighter", [["path", { d: "m9 11-6 6v3h9l3-3" }], ["path", { d: "m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" }]], false, props);
1020
+ }
1021
+ function InfoIcon(props) {
1022
+ return renderIcon("info", [
1023
+ ["circle", {
1024
+ cx: "12",
1025
+ cy: "12",
1026
+ r: "10"
1027
+ }],
1028
+ ["path", { d: "M12 16v-4" }],
1029
+ ["path", { d: "M12 8h.01" }]
1030
+ ], false, props);
1031
+ }
1032
+ function LoopIcon(props) {
1033
+ return renderIcon("loop", [
1034
+ ["path", { d: "m17 2 4 4-4 4" }],
1035
+ ["path", { d: "M3 11v-1a4 4 0 0 1 4-4h14" }],
1036
+ ["path", { d: "m7 22-4-4 4-4" }],
1037
+ ["path", { d: "M21 13v1a4 4 0 0 1-4 4H3" }]
1038
+ ], false, props);
1039
+ }
1040
+ function MenuIcon(props) {
1041
+ return renderIcon("menu", [
1042
+ ["path", { d: "M4 5h16" }],
1043
+ ["path", { d: "M4 12h16" }],
1044
+ ["path", { d: "M4 19h16" }]
1045
+ ], false, props);
1046
+ }
1047
+ function MoreIcon(props) {
1048
+ return renderIcon("more", [
1049
+ ["circle", {
1050
+ cx: "12",
1051
+ cy: "12",
1052
+ r: "1"
1053
+ }],
1054
+ ["circle", {
1055
+ cx: "19",
1056
+ cy: "12",
1057
+ r: "1"
1058
+ }],
1059
+ ["circle", {
1060
+ cx: "5",
1061
+ cy: "12",
1062
+ r: "1"
1063
+ }]
1064
+ ], false, props);
1065
+ }
1066
+ function MutedIcon(props) {
1067
+ return renderIcon("muted", [
1068
+ ["path", { d: "M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z" }],
1069
+ ["path", { d: "m16.5 14.5 5-5" }],
1070
+ ["path", { d: "m16.5 9.5 5 5" }]
1071
+ ], false, props);
1072
+ }
1073
+ function OpenIcon(props) {
1074
+ return renderIcon("open", [["path", { d: "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" }]], false, props);
1075
+ }
1076
+ function PageGridIcon(props) {
1077
+ return renderIcon("page-grid", [
1078
+ ["path", { d: "M12 3v18" }],
1079
+ ["path", { d: "M3 12h18" }],
1080
+ ["rect", {
1081
+ x: "3",
1082
+ y: "3",
1083
+ width: "18",
1084
+ height: "18",
1085
+ rx: "2"
1086
+ }]
1087
+ ], false, props);
1088
+ }
1089
+ function PageSingleIcon(props) {
1090
+ return renderIcon("page-single", [["path", { d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" }], ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5" }]], false, props);
1091
+ }
1092
+ function PanIcon(props) {
1093
+ return renderIcon("pan", [
1094
+ ["path", { d: "M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2" }],
1095
+ ["path", { d: "M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2" }],
1096
+ ["path", { d: "M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8" }],
1097
+ ["path", { d: "M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15" }]
1098
+ ], false, props);
1099
+ }
1100
+ function PauseIcon(props) {
1101
+ return renderIcon("pause", [["rect", {
1102
+ x: "14",
1103
+ y: "3",
1104
+ width: "5",
1105
+ height: "18",
1106
+ rx: "1"
1107
+ }], ["rect", {
1108
+ x: "5",
1109
+ y: "3",
1110
+ width: "5",
1111
+ height: "18",
1112
+ rx: "1"
1113
+ }]], false, props);
1114
+ }
1115
+ function PenIcon(props) {
1116
+ return renderIcon("pen", [["path", { d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }]], false, props);
1117
+ }
1118
+ function PlayIcon(props) {
1119
+ return renderIcon("play", [["path", { d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z" }]], false, props);
1120
+ }
1121
+ function RedoIcon(props) {
1122
+ return renderIcon("redo", [["path", { d: "m15 14 5-5-5-5" }], ["path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" }]], true, props);
1123
+ }
1124
+ function RemoveIcon(props) {
1125
+ return renderIcon("remove", [["path", { d: "M5 12h14" }]], false, props);
1126
+ }
1127
+ function RotateLeftIcon(props) {
1128
+ return renderIcon("rotate-left", [["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }], ["path", { d: "M3 3v5h5" }]], false, props);
1129
+ }
1130
+ function RotateRightIcon(props) {
1131
+ return renderIcon("rotate-right", [["path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8" }], ["path", { d: "M21 3v5h-5" }]], false, props);
1132
+ }
1133
+ function SearchIcon(props) {
1134
+ return renderIcon("search", [["path", { d: "m21 21-4.34-4.34" }], ["circle", {
1135
+ cx: "11",
1136
+ cy: "11",
1137
+ r: "8"
1138
+ }]], false, props);
1139
+ }
1140
+ function SelectIcon(props) {
1141
+ return renderIcon("select", [["path", { d: "M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z" }]], false, props);
1142
+ }
1143
+ function SkipBackIcon(props) {
1144
+ return renderIcon("skip-back", [["path", { d: "M17.971 4.285A2 2 0 0 1 21 6v12a2 2 0 0 1-3.029 1.715l-9.997-5.998a2 2 0 0 1-.003-3.432z" }], ["path", { d: "M3 20V4" }]], false, props);
1145
+ }
1146
+ function SkipForwardIcon(props) {
1147
+ return renderIcon("skip-forward", [["path", { d: "M21 4v16" }], ["path", { d: "M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z" }]], false, props);
1148
+ }
1149
+ function SplitIcon(props) {
1150
+ return renderIcon("split", [
1151
+ ["circle", {
1152
+ cx: "6",
1153
+ cy: "6",
1154
+ r: "3"
1155
+ }],
1156
+ ["path", { d: "M8.12 8.12 12 12" }],
1157
+ ["path", { d: "M20 4 8.12 15.88" }],
1158
+ ["circle", {
1159
+ cx: "6",
1160
+ cy: "18",
1161
+ r: "3"
1162
+ }],
1163
+ ["path", { d: "M14.8 14.8 20 20" }]
1164
+ ], false, props);
1165
+ }
1166
+ function StopIcon(props) {
1167
+ return renderIcon("stop", [["rect", {
1168
+ width: "18",
1169
+ height: "18",
1170
+ x: "3",
1171
+ y: "3",
1172
+ rx: "2"
1173
+ }]], false, props);
1174
+ }
1175
+ function UndoIcon(props) {
1176
+ return renderIcon("undo", [["path", { d: "M9 14 4 9l5-5" }], ["path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" }]], true, props);
1177
+ }
1178
+ function UploadIcon(props) {
1179
+ return renderIcon("upload", [
1180
+ ["path", { d: "M12 3v12" }],
1181
+ ["path", { d: "m17 8-5-5-5 5" }],
1182
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }]
1183
+ ], false, props);
1184
+ }
1185
+ function VolumeIcon(props) {
1186
+ return renderIcon("volume", [
1187
+ ["path", { d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z" }],
1188
+ ["path", { d: "M16 9a5 5 0 0 1 0 6" }],
1189
+ ["path", { d: "M19.364 18.364a9 9 0 0 0 0-12.728" }]
1190
+ ], false, props);
1191
+ }
1192
+ function WarningIcon(props) {
1193
+ return renderIcon("warning", [
1194
+ ["path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }],
1195
+ ["path", { d: "M12 9v4" }],
1196
+ ["path", { d: "M12 17h.01" }]
1197
+ ], false, props);
1198
+ }
1199
+ function ZoomInIcon(props) {
1200
+ return renderIcon("zoom-in", [
1201
+ ["circle", {
1202
+ cx: "11",
1203
+ cy: "11",
1204
+ r: "8"
1205
+ }],
1206
+ ["line", {
1207
+ x1: "21",
1208
+ x2: "16.65",
1209
+ y1: "21",
1210
+ y2: "16.65"
1211
+ }],
1212
+ ["line", {
1213
+ x1: "11",
1214
+ x2: "11",
1215
+ y1: "8",
1216
+ y2: "14"
1217
+ }],
1218
+ ["line", {
1219
+ x1: "8",
1220
+ x2: "14",
1221
+ y1: "11",
1222
+ y2: "11"
1223
+ }]
1224
+ ], false, props);
1225
+ }
1226
+ function ZoomOutIcon(props) {
1227
+ return renderIcon("zoom-out", [
1228
+ ["circle", {
1229
+ cx: "11",
1230
+ cy: "11",
1231
+ r: "8"
1232
+ }],
1233
+ ["line", {
1234
+ x1: "21",
1235
+ x2: "16.65",
1236
+ y1: "21",
1237
+ y2: "16.65"
1238
+ }],
1239
+ ["line", {
1240
+ x1: "8",
1241
+ x2: "14",
1242
+ y1: "11",
1243
+ y2: "11"
1244
+ }]
1245
+ ], false, props);
1246
+ }
1247
+ // src/react/ThemeProvider.tsx
1248
+ var cssCache = /* @__PURE__ */ new WeakMap();
1249
+ function cachedCss(theme, selector) {
1250
+ let bySelector = cssCache.get(theme);
1251
+ if (!bySelector) {
1252
+ bySelector = /* @__PURE__ */ new Map();
1253
+ cssCache.set(theme, bySelector);
1254
+ }
1255
+ let css = bySelector.get(selector);
1256
+ if (css === void 0) {
1257
+ const [light, dark] = isThemePair(theme) ? [theme.light, theme.dark] : [theme, void 0];
1258
+ const write = cssWriterOf(light);
1259
+ if (!write || dark !== void 0 && !cssWriterOf(dark)) throw new UiError("INVALID_THEME_TOKEN", "ThemeProvider takes themes from createTheme.", { details: {
1260
+ token: "theme",
1261
+ value: "",
1262
+ reason: "pass themes created with createTheme"
1263
+ } });
1264
+ css = write(light, dark, selector);
1265
+ bySelector.set(selector, css);
1266
+ }
1267
+ return css;
1268
+ }
1269
+ function ThemeProvider(props) {
1270
+ checkSingleCopy();
1271
+ const { theme, mode, density, nonce, children } = props;
1272
+ const scopeId = `hm${useId().replace(/[^A-Za-z0-9_-]/g, "-")}`;
1273
+ const single = theme !== void 0 && !isThemePair(theme);
1274
+ const css = theme === void 0 ? void 0 : cachedCss(theme, `[data-hm-theme-scope="${scopeId}"]`);
1275
+ return /* @__PURE__ */ jsxs("div", {
1276
+ "data-hm-theme-scope": scopeId,
1277
+ "data-hm-theme": single ? void 0 : mode ?? "system",
1278
+ "data-hm-density": density,
1279
+ children: [css === void 0 ? null : /* @__PURE__ */ jsx("style", {
1280
+ nonce,
1281
+ dangerouslySetInnerHTML: { __html: css }
1282
+ }), children]
1283
+ });
1284
+ }
1285
+ export { AddIcon, AnnouncerProvider, Button, CheckIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, CloseIcon, DeleteIcon, Dialog, DownloadIcon, Field, FileDropZone, HighlighterIcon, IconButton, InfoIcon, LoopIcon, MenuIcon, MoreIcon, MutedIcon, NumberField, OpenIcon, PageGridIcon, PageSingleIcon, PanIcon, PauseIcon, PenIcon, PlayIcon, ProgressBar, RedoIcon, RemoveIcon, RotateLeftIcon, RotateRightIcon, SearchIcon, SegmentedControl, SelectIcon, SkipBackIcon, SkipForwardIcon, Slider, Spinner, SplitIcon, StopIcon, ThemeProvider, ToggleButton, Toolbar, ToolbarGroup, ToolbarSeparator, UiMessagesProvider, UndoIcon, UploadIcon, VisuallyHidden, VolumeIcon, WarningIcon, ZoomInIcon, ZoomOutIcon, uiMessages, useAnnounce, useUiMessages };
1286
+
1287
+ //# sourceMappingURL=react.js.map