@hydrateless/react 0.5.0 → 0.7.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/index.js CHANGED
@@ -2,12 +2,18 @@
2
2
  import { useEffect, useRef } from "react";
3
3
  function useEnhancer(enhance, deps = []) {
4
4
  const ref = useRef(null);
5
+ const api = useRef(null);
5
6
  useEffect(() => {
6
7
  const el = ref.current;
7
8
  if (!el) return;
8
- return enhance(el);
9
+ const handle = enhance(el);
10
+ api.current = handle.api;
11
+ return () => {
12
+ api.current = null;
13
+ handle.destroy();
14
+ };
9
15
  }, deps);
10
- return ref;
16
+ return { ref, api };
11
17
  }
12
18
 
13
19
  // src/hooks.ts
@@ -32,64 +38,116 @@ var useTocEnhancer = (options) => useEnhancer(
32
38
  );
33
39
 
34
40
  // src/Accordion.tsx
35
- import { useEffect as useEffect2, useRef as useRef2 } from "react";
41
+ import { useEffect as useEffect2, useRef as useRef3 } from "react";
36
42
  import { enhanceAccordion as enhanceAccordion2 } from "@hydrateless/enhancers";
43
+
44
+ // src/util.ts
45
+ import { useRef as useRef2 } from "react";
46
+ function cx(...classes) {
47
+ return classes.filter(Boolean).join(" ");
48
+ }
49
+ function useLatest(value) {
50
+ const ref = useRef2(value);
51
+ ref.current = value;
52
+ return ref;
53
+ }
54
+
55
+ // src/Accordion.tsx
37
56
  import { jsx, jsxs } from "react/jsx-runtime";
38
- function Accordion({ allowMultiple = false, children, ...rest }) {
39
- const ref = useRef2(null);
57
+ function Accordion({
58
+ allowMultiple = false,
59
+ value,
60
+ defaultValue,
61
+ onValueChange,
62
+ children,
63
+ ...rest
64
+ }) {
65
+ const onValueChangeRef = useLatest(onValueChange);
66
+ const initialValueRef = useLatest(value ?? defaultValue);
67
+ const { ref, api } = useEnhancer(
68
+ (el) => enhanceAccordion2(el, {
69
+ allowMultiple,
70
+ defaultValue: initialValueRef.current,
71
+ onValueChange: (next) => onValueChangeRef.current?.(next)
72
+ }),
73
+ [allowMultiple]
74
+ );
40
75
  useEffect2(() => {
41
- if (!ref.current) return;
42
- return enhanceAccordion2(ref.current, { allowMultiple });
43
- }, [allowMultiple]);
76
+ if (value != null) api.current?.setValue(value);
77
+ }, [value, api]);
44
78
  return /* @__PURE__ */ jsx("div", { ...rest, "data-hl-accordion": true, ref, children });
45
79
  }
46
80
  function AccordionItem({
47
81
  summary,
82
+ value,
48
83
  defaultOpen = false,
49
84
  children,
50
85
  ...rest
51
86
  }) {
52
- const ref = useRef2(null);
87
+ const ref = useRef3(null);
53
88
  useEffect2(() => {
54
89
  if (ref.current && defaultOpen) ref.current.open = true;
55
90
  }, [defaultOpen]);
56
- return /* @__PURE__ */ jsxs("details", { ...rest, ref, children: [
91
+ return /* @__PURE__ */ jsxs("details", { ...rest, "data-hl-value": value, ref, children: [
57
92
  /* @__PURE__ */ jsx("summary", { children: summary }),
58
- /* @__PURE__ */ jsx("div", { className: "accordion-panel", children })
93
+ /* @__PURE__ */ jsx("div", { className: "hl-accordion-panel", children })
59
94
  ] });
60
95
  }
61
96
 
62
97
  // src/Disclosure.tsx
63
- import { useEffect as useEffect3, useRef as useRef3 } from "react";
98
+ import { useEffect as useEffect3, useRef as useRef4 } from "react";
64
99
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
65
- function Disclosure({ summary, defaultOpen = false, children, ...rest }) {
66
- const ref = useRef3(null);
100
+ function Disclosure({
101
+ summary,
102
+ defaultOpen = false,
103
+ className,
104
+ children,
105
+ ...rest
106
+ }) {
107
+ const ref = useRef4(null);
67
108
  useEffect3(() => {
68
109
  if (ref.current && defaultOpen) ref.current.open = true;
69
110
  }, [defaultOpen]);
70
- return /* @__PURE__ */ jsxs2("details", { ...rest, className: "hydrateless-disclosure", "data-hl-disclosure": true, ref, children: [
111
+ return /* @__PURE__ */ jsxs2("details", { ...rest, className: cx("hl-disclosure", className), "data-hl-disclosure": true, ref, children: [
71
112
  /* @__PURE__ */ jsx2("summary", { children: summary }),
72
- /* @__PURE__ */ jsx2("div", { className: "disclosure-panel", children })
113
+ /* @__PURE__ */ jsx2("div", { className: "hl-disclosure-panel", children })
73
114
  ] });
74
115
  }
75
116
 
76
117
  // src/Tabs.tsx
77
- import { useEffect as useEffect4, useRef as useRef4 } from "react";
118
+ import { useEffect as useEffect4 } from "react";
78
119
  import { enhanceTabs as enhanceTabs2 } from "@hydrateless/enhancers";
79
120
  import { jsx as jsx3 } from "react/jsx-runtime";
80
- function Tabs({ activation, orientation, children, ...rest }) {
81
- const ref = useRef4(null);
121
+ function Tabs({
122
+ activation,
123
+ orientation,
124
+ value,
125
+ defaultValue,
126
+ onValueChange,
127
+ children,
128
+ ...rest
129
+ }) {
130
+ const onValueChangeRef = useLatest(onValueChange);
131
+ const initialValueRef = useLatest(value ?? defaultValue);
132
+ const { ref, api } = useEnhancer(
133
+ (el) => enhanceTabs2(el, {
134
+ activation,
135
+ orientation,
136
+ defaultValue: initialValueRef.current,
137
+ onValueChange: (next) => onValueChangeRef.current?.(next)
138
+ }),
139
+ [activation, orientation]
140
+ );
82
141
  useEffect4(() => {
83
- if (!ref.current) return;
84
- return enhanceTabs2(ref.current, { activation, orientation });
85
- }, [activation, orientation]);
142
+ if (value != null) api.current?.setValue(value);
143
+ }, [value, api]);
86
144
  return /* @__PURE__ */ jsx3("div", { ...rest, "data-hl-tabs": true, ref, children });
87
145
  }
88
146
  function TabList({ children, ...rest }) {
89
147
  return /* @__PURE__ */ jsx3("div", { ...rest, role: "tablist", children });
90
148
  }
91
- function Tab({ children, type, ...rest }) {
92
- return /* @__PURE__ */ jsx3("button", { ...rest, type: type ?? "button", role: "tab", children });
149
+ function Tab({ children, type, value, ...rest }) {
150
+ return /* @__PURE__ */ jsx3("button", { ...rest, type: type ?? "button", role: "tab", "data-hl-value": value, children });
93
151
  }
94
152
  function TabPanel({ children, ...rest }) {
95
153
  return /* @__PURE__ */ jsx3("div", { ...rest, role: "tabpanel", children });
@@ -97,17 +155,33 @@ function TabPanel({ children, ...rest }) {
97
155
 
98
156
  // src/Dropdown.tsx
99
157
  import {
100
- useEffect as useEffect5,
101
- useRef as useRef5
158
+ useEffect as useEffect5
102
159
  } from "react";
103
- import { enhanceDropdown as enhanceDropdown2 } from "@hydrateless/enhancers";
160
+ import {
161
+ enhanceDropdown as enhanceDropdown2
162
+ } from "@hydrateless/enhancers";
104
163
  import { jsx as jsx4 } from "react/jsx-runtime";
105
- function Dropdown({ placement, children, ...rest }) {
106
- const ref = useRef5(null);
164
+ function Dropdown({
165
+ placement,
166
+ open,
167
+ defaultOpen,
168
+ onOpenChange,
169
+ children,
170
+ ...rest
171
+ }) {
172
+ const onOpenChangeRef = useLatest(onOpenChange);
173
+ const initialOpenRef = useLatest(open ?? defaultOpen);
174
+ const { ref, api } = useEnhancer(
175
+ (el) => enhanceDropdown2(el, {
176
+ placement,
177
+ defaultOpen: initialOpenRef.current,
178
+ onOpenChange: (next) => onOpenChangeRef.current?.(next)
179
+ }),
180
+ [placement]
181
+ );
107
182
  useEffect5(() => {
108
- if (!ref.current) return;
109
- return enhanceDropdown2(ref.current, { placement });
110
- }, [placement]);
183
+ if (open != null) api.current?.setOpen(open);
184
+ }, [open, api]);
111
185
  return /* @__PURE__ */ jsx4("div", { ...rest, "data-hl-dropdown": true, ref, children });
112
186
  }
113
187
  function DropdownTrigger({ children, type, ...rest }) {
@@ -138,15 +212,15 @@ function DropdownSeparator(props) {
138
212
  // src/Menu.tsx
139
213
  import {
140
214
  useEffect as useEffect6,
141
- useRef as useRef6
215
+ useRef as useRef5
142
216
  } from "react";
143
217
  import { enhanceMenu } from "@hydrateless/enhancers";
144
218
  import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
145
219
  function Menu({ orientation = "horizontal", children, ...rest }) {
146
- const ref = useRef6(null);
220
+ const ref = useRef5(null);
147
221
  useEffect6(() => {
148
222
  if (!ref.current) return;
149
- return enhanceMenu(ref.current, { orientation });
223
+ return enhanceMenu(ref.current, { orientation }).destroy;
150
224
  }, [orientation]);
151
225
  return /* @__PURE__ */ jsx5(
152
226
  "ul",
@@ -189,50 +263,29 @@ function MenuItem({
189
263
  }
190
264
 
191
265
  // src/Modal.tsx
192
- import { useEffect as useEffect7, useRef as useRef7 } from "react";
193
-
194
- // src/util.ts
195
- function cx(...classes) {
196
- return classes.filter(Boolean).join(" ");
197
- }
198
-
199
- // src/Modal.tsx
266
+ import { useEffect as useEffect7 } from "react";
267
+ import { enhanceModal as enhanceModal2 } from "@hydrateless/enhancers";
200
268
  import { jsx as jsx6 } from "react/jsx-runtime";
201
269
  function Modal({
202
270
  open,
203
- onClose,
271
+ onOpenChange,
204
272
  closeOnBackdrop = true,
205
273
  className,
206
274
  children,
207
275
  ...rest
208
276
  }) {
209
- const ref = useRef7(null);
210
- useEffect7(() => {
211
- const dialog = ref.current;
212
- if (!dialog) return;
213
- if (open && !dialog.open) dialog.showModal();
214
- else if (!open && dialog.open) dialog.close();
215
- }, [open]);
216
- useEffect7(() => {
217
- const dialog = ref.current;
218
- if (!dialog) return;
219
- const handleClose = () => onClose?.();
220
- dialog.addEventListener("close", handleClose);
221
- return () => dialog.removeEventListener("close", handleClose);
222
- }, [onClose]);
223
- const handleClick = (e) => {
224
- if (closeOnBackdrop && e.target === ref.current) onClose?.();
225
- };
226
- return /* @__PURE__ */ jsx6(
227
- "dialog",
228
- {
229
- ...rest,
230
- ref,
231
- className: cx("hydrateless-modal", className),
232
- onClick: handleClick,
233
- children
234
- }
277
+ const onOpenChangeRef = useLatest(onOpenChange);
278
+ const { ref, api } = useEnhancer(
279
+ (el) => enhanceModal2(el, {
280
+ closeOnBackdrop,
281
+ onOpenChange: (next) => onOpenChangeRef.current?.(next)
282
+ }),
283
+ [closeOnBackdrop]
235
284
  );
285
+ useEffect7(() => {
286
+ api.current?.setOpen(open);
287
+ }, [open, api]);
288
+ return /* @__PURE__ */ jsx6("dialog", { ...rest, ref, "data-hl-modal": true, className: cx("hl-modal", className), children });
236
289
  }
237
290
  function ModalHeader({ className, ...rest }) {
238
291
  return /* @__PURE__ */ jsx6("div", { ...rest, className: cx("hl-modal-header", className) });
@@ -245,42 +298,37 @@ function ModalFooter({ className, ...rest }) {
245
298
  }
246
299
 
247
300
  // src/Drawer.tsx
248
- import { useEffect as useEffect8, useRef as useRef8 } from "react";
301
+ import { useEffect as useEffect8 } from "react";
302
+ import { enhanceDrawer } from "@hydrateless/enhancers";
249
303
  import { jsx as jsx7 } from "react/jsx-runtime";
250
304
  function Drawer({
251
305
  open,
252
- onClose,
306
+ onOpenChange,
253
307
  side = "right",
254
308
  closeOnBackdrop = true,
255
309
  className,
256
310
  children,
257
311
  ...rest
258
312
  }) {
259
- const ref = useRef8(null);
260
- useEffect8(() => {
261
- const dialog = ref.current;
262
- if (!dialog) return;
263
- if (open && !dialog.open) dialog.showModal();
264
- else if (!open && dialog.open) dialog.close();
265
- }, [open]);
313
+ const onOpenChangeRef = useLatest(onOpenChange);
314
+ const { ref, api } = useEnhancer(
315
+ (el) => enhanceDrawer(el, {
316
+ closeOnBackdrop,
317
+ onOpenChange: (next) => onOpenChangeRef.current?.(next)
318
+ }),
319
+ [closeOnBackdrop]
320
+ );
266
321
  useEffect8(() => {
267
- const dialog = ref.current;
268
- if (!dialog) return;
269
- const handleClose = () => onClose?.();
270
- dialog.addEventListener("close", handleClose);
271
- return () => dialog.removeEventListener("close", handleClose);
272
- }, [onClose]);
273
- const handleClick = (e) => {
274
- if (closeOnBackdrop && e.target === ref.current) onClose?.();
275
- };
322
+ api.current?.setOpen(open);
323
+ }, [open, api]);
276
324
  return /* @__PURE__ */ jsx7(
277
325
  "dialog",
278
326
  {
279
327
  ...rest,
280
328
  ref,
329
+ "data-hl-drawer": true,
281
330
  "data-side": side,
282
- className: cx("hydrateless-drawer", className),
283
- onClick: handleClick,
331
+ className: cx("hl-drawer", className),
284
332
  children
285
333
  }
286
334
  );
@@ -296,28 +344,38 @@ function DrawerFooter({ className, ...rest }) {
296
344
  }
297
345
 
298
346
  // src/Popover.tsx
347
+ import { useEffect as useEffect9 } from "react";
348
+ import { enhancePopover } from "@hydrateless/enhancers";
299
349
  import { jsx as jsx8 } from "react/jsx-runtime";
300
- function Popover({ open, children, ...rest }) {
301
- return /* @__PURE__ */ jsx8("div", { ...rest, "data-hl-popover": true, role: "dialog", hidden: !open, children });
350
+ function Popover({ open, onOpenChange, children, ...rest }) {
351
+ const onOpenChangeRef = useLatest(onOpenChange);
352
+ const { ref, api } = useEnhancer(
353
+ (el) => enhancePopover(el, { onOpenChange: (next) => onOpenChangeRef.current?.(next) }),
354
+ []
355
+ );
356
+ useEffect9(() => {
357
+ api.current?.setOpen(open);
358
+ }, [open, api]);
359
+ return /* @__PURE__ */ jsx8("div", { ...rest, ref, "data-hl-popover": true, popover: "auto", role: "dialog", children });
302
360
  }
303
361
 
304
362
  // src/Tooltip.tsx
305
363
  import {
306
364
  cloneElement,
307
365
  isValidElement,
308
- useEffect as useEffect9,
366
+ useEffect as useEffect10,
309
367
  useId,
310
- useRef as useRef9
368
+ useRef as useRef6
311
369
  } from "react";
312
370
  import { enhanceTooltip as enhanceTooltip2 } from "@hydrateless/enhancers";
313
371
  import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
314
372
  function Tooltip({ label, children, id }) {
315
373
  const generatedId = useId().replace(/:/g, "");
316
374
  const tipId = id ?? `hl-tip-${generatedId}`;
317
- const ref = useRef9(null);
318
- useEffect9(() => {
375
+ const ref = useRef6(null);
376
+ useEffect10(() => {
319
377
  if (!ref.current) return;
320
- return enhanceTooltip2(ref.current);
378
+ return enhanceTooltip2(ref.current).destroy;
321
379
  }, [tipId]);
322
380
  const trigger = isValidElement(children) ? cloneElement(children, {
323
381
  "data-hl-tooltip": tipId,
@@ -356,86 +414,86 @@ function Switch({ children, className, ...rest }) {
356
414
  // src/SkipLink.tsx
357
415
  import { jsx as jsx12 } from "react/jsx-runtime";
358
416
  function SkipLink({ children = "Skip to content", className, ...rest }) {
359
- return /* @__PURE__ */ jsx12("a", { ...rest, className: ["a11y-skip-link", className].filter(Boolean).join(" "), children });
417
+ return /* @__PURE__ */ jsx12("a", { ...rest, className: cx("hl-skip-link", className), children });
360
418
  }
361
419
 
362
420
  // src/Toc.tsx
363
- import { useEffect as useEffect10, useRef as useRef10 } from "react";
421
+ import { useEffect as useEffect11, useRef as useRef7 } from "react";
364
422
  import { enhanceToc as enhanceToc2 } from "@hydrateless/enhancers";
365
423
  import { jsx as jsx13 } from "react/jsx-runtime";
366
424
  function Toc({ contentSelector, headings, scrollSpy, ...rest }) {
367
- const ref = useRef10(null);
368
- useEffect10(() => {
425
+ const ref = useRef7(null);
426
+ useEffect11(() => {
369
427
  if (!ref.current) return;
370
- return enhanceToc2(ref.current.ownerDocument, { contentSelector, headings, scrollSpy });
428
+ return enhanceToc2(ref.current.ownerDocument, { contentSelector, headings, scrollSpy }).destroy;
371
429
  }, [contentSelector, headings, scrollSpy]);
372
430
  return /* @__PURE__ */ jsx13("nav", { ...rest, "data-hl-toc": true, ref });
373
431
  }
374
432
 
375
433
  // src/Toast.tsx
376
- import { createContext, useContext, useEffect as useEffect11, useRef as useRef11 } from "react";
434
+ import { useEffect as useEffect12, useRef as useRef8 } from "react";
377
435
  import { enhanceToast } from "@hydrateless/enhancers";
378
- import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
379
- var ToastContext = createContext(null);
380
- function ToastProvider({ children }) {
381
- const apiRef = useRef11(null);
382
- const facade = useRef11({
383
- show: (message, options) => apiRef.current ? apiRef.current.show(message, options) : document.createElement("div"),
384
- dismiss: (toast) => apiRef.current?.dismiss(toast),
385
- destroy: () => apiRef.current?.destroy()
386
- });
387
- const regionRef = useRef11(null);
388
- useEffect11(() => {
389
- const region = regionRef.current;
390
- if (!region) return;
391
- const api = enhanceToast(region.ownerDocument);
392
- apiRef.current = api;
436
+ import { jsx as jsx14 } from "react/jsx-runtime";
437
+ var sharedApi = null;
438
+ function ensureApi() {
439
+ if (!sharedApi) {
440
+ const handle = enhanceToast(document);
441
+ sharedApi = handle.api;
442
+ }
443
+ return sharedApi;
444
+ }
445
+ var facade = {
446
+ show: (message, options) => ensureApi().show(message, options),
447
+ dismiss: (toast) => ensureApi().dismiss(toast)
448
+ };
449
+ function ToastRegion(props) {
450
+ const ref = useRef8(null);
451
+ useEffect12(() => {
452
+ if (!ref.current) return;
453
+ const handle = enhanceToast(ref.current.ownerDocument);
454
+ sharedApi = handle.api;
393
455
  return () => {
394
- api.destroy();
395
- apiRef.current = null;
456
+ handle.destroy();
457
+ sharedApi = null;
396
458
  };
397
459
  }, []);
398
- return /* @__PURE__ */ jsxs6(ToastContext.Provider, { value: facade.current, children: [
399
- children,
400
- /* @__PURE__ */ jsx14("div", { "data-hl-toast-region": true, ref: regionRef })
401
- ] });
460
+ return /* @__PURE__ */ jsx14("div", { ...props, "data-hl-toast-region": true, ref });
402
461
  }
403
462
  function useToast() {
404
- const ctx = useContext(ToastContext);
405
- if (!ctx) {
406
- throw new Error("useToast must be used within a <ToastProvider>");
407
- }
408
- return ctx;
463
+ return facade;
409
464
  }
410
465
 
411
466
  // src/Combobox.tsx
412
467
  import {
413
- useEffect as useEffect12,
414
- useRef as useRef12
468
+ useEffect as useEffect13
415
469
  } from "react";
416
- import { enhanceCombobox } from "@hydrateless/enhancers";
470
+ import {
471
+ enhanceCombobox
472
+ } from "@hydrateless/enhancers";
417
473
  import { jsx as jsx15 } from "react/jsx-runtime";
418
474
  function Combobox({
419
475
  filter,
420
476
  autoHighlight,
477
+ value,
478
+ defaultValue,
421
479
  onValueChange,
422
480
  children,
423
481
  ...rest
424
482
  }) {
425
- const ref = useRef12(null);
426
- const onChangeRef = useRef12(onValueChange);
427
- onChangeRef.current = onValueChange;
428
- useEffect12(() => {
429
- const el = ref.current;
430
- if (!el) return;
431
- const dispose = enhanceCombobox(el, { filter, autoHighlight });
432
- const handler = (e) => onChangeRef.current?.(e.detail.value);
433
- el.addEventListener("hl:select", handler);
434
- return () => {
435
- el.removeEventListener("hl:select", handler);
436
- dispose();
437
- };
438
- }, [filter, autoHighlight]);
483
+ const onValueChangeRef = useLatest(onValueChange);
484
+ const initialValueRef = useLatest(value ?? defaultValue);
485
+ const { ref, api } = useEnhancer(
486
+ (el) => enhanceCombobox(el, {
487
+ filter,
488
+ autoHighlight,
489
+ defaultValue: initialValueRef.current,
490
+ onValueChange: (next) => onValueChangeRef.current?.(next)
491
+ }),
492
+ [filter, autoHighlight]
493
+ );
494
+ useEffect13(() => {
495
+ if (value != null) api.current?.setValue(value);
496
+ }, [value, api]);
439
497
  return /* @__PURE__ */ jsx15("div", { ...rest, ref, "data-hl-combobox": true, children });
440
498
  }
441
499
  function ComboboxInput({ styled = true, className, ...rest }) {
@@ -450,28 +508,23 @@ function ComboboxOption({ value, children, ...rest }) {
450
508
 
451
509
  // src/Command.tsx
452
510
  import {
453
- useEffect as useEffect13,
454
- useRef as useRef13
511
+ useEffect as useEffect14,
512
+ useRef as useRef9
455
513
  } from "react";
456
514
  import { enhanceCommand } from "@hydrateless/enhancers";
457
- import { jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
515
+ import { jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
458
516
  function Command({ hotkey, onSelect, children, ...rest }) {
459
- const ref = useRef13(null);
460
- const onSelectRef = useRef13(onSelect);
517
+ const ref = useRef9(null);
518
+ const onSelectRef = useRef9(onSelect);
461
519
  onSelectRef.current = onSelect;
462
- useEffect13(() => {
520
+ useEffect14(() => {
463
521
  const el = ref.current;
464
522
  if (!el) return;
465
- const dispose = enhanceCommand(el, { hotkey });
466
- const handler = (e) => {
467
- const { value } = e.detail;
468
- onSelectRef.current?.(value);
469
- };
470
- el.addEventListener("hl:command", handler);
471
- return () => {
472
- el.removeEventListener("hl:command", handler);
473
- dispose();
474
- };
523
+ const handle = enhanceCommand(el, {
524
+ hotkey,
525
+ onCommand: (value) => onSelectRef.current?.(value)
526
+ });
527
+ return handle.destroy;
475
528
  }, [hotkey]);
476
529
  return /* @__PURE__ */ jsx16("div", { ...rest, ref, "data-hl-command": true, "data-hl-command-hotkey": hotkey, children });
477
530
  }
@@ -482,13 +535,13 @@ function CommandList({ children, ...rest }) {
482
535
  return /* @__PURE__ */ jsx16("div", { ...rest, "data-hl-command-list": true, role: "listbox", children });
483
536
  }
484
537
  function CommandGroup({ label, children, ...rest }) {
485
- return /* @__PURE__ */ jsxs7("div", { ...rest, "data-hl-command-group": true, children: [
538
+ return /* @__PURE__ */ jsxs6("div", { ...rest, "data-hl-command-group": true, children: [
486
539
  label != null && /* @__PURE__ */ jsx16("div", { className: "hl-command-group-label", role: "presentation", children: label }),
487
540
  children
488
541
  ] });
489
542
  }
490
543
  function CommandItem({ value, keywords, icon, children, ...rest }) {
491
- return /* @__PURE__ */ jsxs7("div", { ...rest, role: "option", "data-hl-value": value, "data-hl-keywords": keywords, children: [
544
+ return /* @__PURE__ */ jsxs6("div", { ...rest, role: "option", "data-hl-value": value, "data-hl-keywords": keywords, children: [
492
545
  icon,
493
546
  /* @__PURE__ */ jsx16("span", { children })
494
547
  ] });
@@ -550,9 +603,9 @@ var Select = forwardRef3(function Select2({ size, invalid, options, className, c
550
603
 
551
604
  // src/Checkbox.tsx
552
605
  import { forwardRef as forwardRef4 } from "react";
553
- import { jsx as jsx20, jsxs as jsxs8 } from "react/jsx-runtime";
606
+ import { jsx as jsx20, jsxs as jsxs7 } from "react/jsx-runtime";
554
607
  var Checkbox = forwardRef4(function Checkbox2({ children, className, ...rest }, ref) {
555
- return /* @__PURE__ */ jsxs8("label", { className: ["hl-checkbox", className].filter(Boolean).join(" "), children: [
608
+ return /* @__PURE__ */ jsxs7("label", { className: ["hl-checkbox", className].filter(Boolean).join(" "), children: [
556
609
  /* @__PURE__ */ jsx20("input", { ...rest, ref, type: "checkbox" }),
557
610
  children != null && /* @__PURE__ */ jsx20("span", { children })
558
611
  ] });
@@ -560,16 +613,16 @@ var Checkbox = forwardRef4(function Checkbox2({ children, className, ...rest },
560
613
 
561
614
  // src/Radio.tsx
562
615
  import {
563
- createContext as createContext2,
616
+ createContext,
564
617
  forwardRef as forwardRef5,
565
- useContext as useContext2
618
+ useContext
566
619
  } from "react";
567
- import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
568
- var RadioGroupContext = createContext2(null);
620
+ import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
621
+ var RadioGroupContext = createContext(null);
569
622
  var Radio = forwardRef5(function Radio2({ children, className, value, ...rest }, ref) {
570
- const group = useContext2(RadioGroupContext);
623
+ const group = useContext(RadioGroupContext);
571
624
  const checked = group ? group.value === value : rest.checked;
572
- return /* @__PURE__ */ jsxs9("label", { className: ["hl-radio", className].filter(Boolean).join(" "), children: [
625
+ return /* @__PURE__ */ jsxs8("label", { className: ["hl-radio", className].filter(Boolean).join(" "), children: [
573
626
  /* @__PURE__ */ jsx21(
574
627
  "input",
575
628
  {
@@ -609,12 +662,12 @@ function RadioGroup({
609
662
 
610
663
  // src/Field.tsx
611
664
  import {
612
- createContext as createContext3,
613
- useContext as useContext3,
665
+ createContext as createContext2,
666
+ useContext as useContext2,
614
667
  useId as useId2
615
668
  } from "react";
616
- import { jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
617
- var FieldContext = createContext3(null);
669
+ import { jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
670
+ var FieldContext = createContext2(null);
618
671
  function Field({
619
672
  id,
620
673
  invalid = false,
@@ -645,7 +698,7 @@ function Field({
645
698
  ) });
646
699
  }
647
700
  function useFieldContext(component) {
648
- const ctx = useContext3(FieldContext);
701
+ const ctx = useContext2(FieldContext);
649
702
  if (!ctx) throw new Error(`<${component}> must be used within a <Field>`);
650
703
  return ctx;
651
704
  }
@@ -690,7 +743,7 @@ function FieldError({ className, children, ...rest }) {
690
743
  );
691
744
  }
692
745
  function Fieldset({ legend, className, children, ...rest }) {
693
- return /* @__PURE__ */ jsxs10("fieldset", { ...rest, className: ["hl-fieldset", className].filter(Boolean).join(" "), children: [
746
+ return /* @__PURE__ */ jsxs9("fieldset", { ...rest, className: ["hl-fieldset", className].filter(Boolean).join(" "), children: [
694
747
  legend != null && /* @__PURE__ */ jsx22("legend", { className: "hl-legend", children: legend }),
695
748
  children
696
749
  ] });
@@ -698,7 +751,7 @@ function Fieldset({ legend, className, children, ...rest }) {
698
751
 
699
752
  // src/SegmentedControl.tsx
700
753
  import { useId as useId3, useState } from "react";
701
- import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
754
+ import { jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
702
755
  function SegmentedControl({
703
756
  options,
704
757
  value,
@@ -724,7 +777,7 @@ function SegmentedControl({
724
777
  role: "radiogroup",
725
778
  className: ["hl-segmented", className].filter(Boolean).join(" "),
726
779
  "data-hl-size": size,
727
- children: options.map((option) => /* @__PURE__ */ jsxs11("label", { className: "hl-segmented-item", children: [
780
+ children: options.map((option) => /* @__PURE__ */ jsxs10("label", { className: "hl-segmented-item", children: [
728
781
  /* @__PURE__ */ jsx23(
729
782
  "input",
730
783
  {
@@ -783,9 +836,9 @@ var Button = forwardRef7(function Button2({ variant, intent, size, block, icon,
783
836
 
784
837
  // src/Alert.tsx
785
838
  import { forwardRef as forwardRef8 } from "react";
786
- import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
839
+ import { jsx as jsx26, jsxs as jsxs11 } from "react/jsx-runtime";
787
840
  var Alert = forwardRef8(function Alert2({ intent, title, icon, className, children, ...rest }, ref) {
788
- return /* @__PURE__ */ jsxs12(
841
+ return /* @__PURE__ */ jsxs11(
789
842
  "div",
790
843
  {
791
844
  ...rest,
@@ -795,7 +848,7 @@ var Alert = forwardRef8(function Alert2({ intent, title, icon, className, childr
795
848
  "data-hl-intent": intent,
796
849
  children: [
797
850
  icon,
798
- /* @__PURE__ */ jsxs12("div", { className: "hl-alert-body", children: [
851
+ /* @__PURE__ */ jsxs11("div", { className: "hl-alert-body", children: [
799
852
  title != null && /* @__PURE__ */ jsx26("p", { className: "hl-alert-title", children: title }),
800
853
  children
801
854
  ] })
@@ -942,7 +995,7 @@ var Skeleton = forwardRef14(function Skeleton2({ variant, width, height, classNa
942
995
  });
943
996
 
944
997
  // src/Pagination.tsx
945
- import { jsx as jsx33, jsxs as jsxs13 } from "react/jsx-runtime";
998
+ import { jsx as jsx33, jsxs as jsxs12 } from "react/jsx-runtime";
946
999
  var ELLIPSIS = "ellipsis";
947
1000
  function range(start, end) {
948
1001
  return Array.from({ length: end - start + 1 }, (_, i) => start + i);
@@ -983,7 +1036,7 @@ function Pagination({
983
1036
  ...rest,
984
1037
  className: ["hl-pagination", className].filter(Boolean).join(" "),
985
1038
  "aria-label": rest["aria-label"] ?? "Pagination",
986
- children: /* @__PURE__ */ jsxs13("ul", { children: [
1039
+ children: /* @__PURE__ */ jsxs12("ul", { children: [
987
1040
  showControls && /* @__PURE__ */ jsx33("li", { children: /* @__PURE__ */ jsx33(
988
1041
  "button",
989
1042
  {
@@ -1115,7 +1168,7 @@ export {
1115
1168
  TabPanel,
1116
1169
  Tabs,
1117
1170
  Textarea,
1118
- ToastProvider,
1171
+ ToastRegion,
1119
1172
  Toc,
1120
1173
  Tooltip,
1121
1174
  cx,