@hydrateless/react 0.10.0 → 0.11.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
@@ -1,1422 +1,2 @@
1
- 'use client';
2
-
3
- // src/useEnhancer.ts
4
- import { useEffect, useRef as useRef2 } from "react";
5
-
6
- // src/internal/useLatest.ts
7
- import { useRef } from "react";
8
- function useLatest(value) {
9
- const ref = useRef(value);
10
- ref.current = value;
11
- return ref;
12
- }
13
-
14
- // src/useEnhancer.ts
15
- function useEnhancer(ref, enhancer, options, deps = []) {
16
- const api = useRef2(null);
17
- const latest = useLatest(options);
18
- useEffect(() => {
19
- const el = ref.current;
20
- if (!el) return;
21
- const live = {};
22
- for (const [key, value] of Object.entries(latest.current ?? {})) {
23
- if (value === void 0) continue;
24
- live[key] = typeof value === "function" ? (...args) => {
25
- const fn = latest.current?.[key];
26
- return typeof fn === "function" ? fn(...args) : void 0;
27
- } : value;
28
- }
29
- const handle = enhancer(el, live);
30
- api.current = handle.api;
31
- return () => {
32
- api.current = null;
33
- handle.destroy();
34
- };
35
- }, deps);
36
- return api;
37
- }
38
-
39
- // src/Accordion.tsx
40
- import { createContext as createContext2, forwardRef, useContext } from "react";
41
- import {
42
- enhanceAccordion
43
- } from "@hydrateless/enhancers";
44
-
45
- // src/internal/useControlled.ts
46
- import { useCallback, useState } from "react";
47
- function useControlled(controlled, defaultValue, onChange) {
48
- const [internal, setInternal] = useState(defaultValue);
49
- const isControlled = useLatest(controlled !== void 0);
50
- const onChangeRef = useLatest(onChange);
51
- const setValue = useCallback(
52
- (next) => {
53
- if (!isControlled.current) setInternal(next);
54
- onChangeRef.current?.(next);
55
- },
56
- [isControlled, onChangeRef]
57
- );
58
- return [controlled !== void 0 ? controlled : internal, setValue];
59
- }
60
-
61
- // src/internal/useSyncApi.ts
62
- import { useEffect as useEffect2 } from "react";
63
- function useSyncApi(api, value, sync) {
64
- useEffect2(() => {
65
- if (value !== void 0 && api.current) sync(api.current, value);
66
- }, [value, api]);
67
- }
68
-
69
- // src/internal/useForwardedRef.ts
70
- import { useCallback as useCallback2, useRef as useRef3 } from "react";
71
- function useForwardedRef(forwarded) {
72
- const inner = useRef3(null);
73
- const forwardedRef = useRef3(forwarded);
74
- forwardedRef.current = forwarded;
75
- const callback = useCallback2((node) => {
76
- inner.current = node;
77
- const target = forwardedRef.current;
78
- if (typeof target === "function") target(node);
79
- else if (target) target.current = node;
80
- }, []);
81
- const ref = callback;
82
- Object.defineProperty(ref, "current", {
83
- configurable: true,
84
- get: () => inner.current,
85
- set: (node) => {
86
- inner.current = node;
87
- }
88
- });
89
- return ref;
90
- }
91
-
92
- // src/internal/indexChildren.ts
93
- import { Children, createContext, createElement, isValidElement } from "react";
94
- var IndexContext = createContext(0);
95
- function indexChildren(children, type) {
96
- let index = 0;
97
- return Children.map(children, (child) => {
98
- if (!isValidElement(child) || child.type !== type) return child;
99
- return createElement(IndexContext.Provider, { value: index++, key: child.key }, child);
100
- });
101
- }
102
-
103
- // src/Accordion.tsx
104
- import { jsx, jsxs } from "react/jsx-runtime";
105
- var AccordionContext = createContext2([]);
106
- var Accordion = forwardRef(function Accordion2({ allowMultiple = false, value: valueProp, defaultValue, onValueChange, children, ...rest }, forwardedRef) {
107
- const ref = useForwardedRef(forwardedRef);
108
- const [value = [], setValue] = useControlled(valueProp, defaultValue, onValueChange);
109
- const api = useEnhancer(
110
- ref,
111
- enhanceAccordion,
112
- { allowMultiple, defaultValue: value, onValueChange: setValue },
113
- [allowMultiple]
114
- );
115
- useSyncApi(api, valueProp, (api2, value2) => api2.setValue(value2));
116
- return /* @__PURE__ */ jsx(AccordionContext.Provider, { value, children: /* @__PURE__ */ jsx("div", { ...rest, ref, "data-hl-accordion": true, children: indexChildren(children, AccordionItem) }) });
117
- });
118
- var AccordionItem = forwardRef(
119
- function AccordionItem2({ summary, value, children, ...rest }, ref) {
120
- const open = useContext(AccordionContext);
121
- const index = useContext(IndexContext);
122
- return /* @__PURE__ */ jsxs(
123
- "details",
124
- {
125
- ...rest,
126
- ref,
127
- "data-hl-value": value,
128
- open: open.includes(value ?? String(index)),
129
- children: [
130
- /* @__PURE__ */ jsx("summary", { children: summary }),
131
- /* @__PURE__ */ jsx("div", { className: "hl-accordion-panel", children })
132
- ]
133
- }
134
- );
135
- }
136
- );
137
-
138
- // src/Disclosure.tsx
139
- import { forwardRef as forwardRef2 } from "react";
140
- import {
141
- enhanceDisclosure
142
- } from "@hydrateless/enhancers";
143
-
144
- // src/util.ts
145
- function cx(...classes) {
146
- return classes.filter(Boolean).join(" ");
147
- }
148
-
149
- // src/Disclosure.tsx
150
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
151
- var Disclosure = forwardRef2(function Disclosure2({ summary, open: openProp, defaultOpen, onOpenChange, name, className, children, ...rest }, forwardedRef) {
152
- const ref = useForwardedRef(forwardedRef);
153
- const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
154
- const api = useEnhancer(ref, enhanceDisclosure, {
155
- defaultOpen: open,
156
- onOpenChange: setOpen
157
- });
158
- useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2));
159
- return /* @__PURE__ */ jsxs2(
160
- "details",
161
- {
162
- ...rest,
163
- ref,
164
- name,
165
- open,
166
- className: cx("hl-disclosure", className),
167
- "data-hl-disclosure": true,
168
- children: [
169
- /* @__PURE__ */ jsx2("summary", { children: summary }),
170
- /* @__PURE__ */ jsx2("div", { className: "hl-disclosure-panel", children })
171
- ]
172
- }
173
- );
174
- });
175
-
176
- // src/Tabs.tsx
177
- import {
178
- Children as Children2,
179
- createContext as createContext3,
180
- forwardRef as forwardRef3,
181
- isValidElement as isValidElement2,
182
- useContext as useContext2
183
- } from "react";
184
- import { enhanceTabs } from "@hydrateless/enhancers";
185
- import { jsx as jsx3 } from "react/jsx-runtime";
186
- var TabsContext = createContext3({ selected: void 0, selectedIndex: 0 });
187
- function tabValues(children) {
188
- const list = Children2.toArray(children).find((c) => isValidElement2(c) && c.type === TabList);
189
- if (!isValidElement2(list)) return null;
190
- return Children2.toArray(list.props.children).filter((c) => isValidElement2(c) && c.type === Tab).map((tab, i) => tab.props.value ?? String(i));
191
- }
192
- function useSelected(value) {
193
- const { selected, selectedIndex } = useContext2(TabsContext);
194
- const index = useContext2(IndexContext);
195
- return value != null && selected != null ? value === selected : index === selectedIndex;
196
- }
197
- var Tabs = forwardRef3(function Tabs2({ activation, orientation, value: valueProp, defaultValue, onValueChange, children, ...rest }, forwardedRef) {
198
- const ref = useForwardedRef(forwardedRef);
199
- const [selected, setValue] = useControlled(valueProp, defaultValue, onValueChange);
200
- const api = useEnhancer(
201
- ref,
202
- enhanceTabs,
203
- { activation, orientation, defaultValue: selected, onValueChange: setValue },
204
- [activation, orientation]
205
- );
206
- useSyncApi(api, valueProp, (api2, value) => api2.setValue(value));
207
- const values = tabValues(children);
208
- const selectedIndex = selected == null ? 0 : values ? values.indexOf(selected) : Number(selected);
209
- return /* @__PURE__ */ jsx3(TabsContext.Provider, { value: { selected, selectedIndex }, children: /* @__PURE__ */ jsx3("div", { ...rest, ref, "data-hl-tabs": true, children: indexChildren(children, TabPanel) }) });
210
- });
211
- var TabList = forwardRef3(function TabList2({ children, ...rest }, ref) {
212
- return /* @__PURE__ */ jsx3("div", { ...rest, ref, role: "tablist", children: indexChildren(children, Tab) });
213
- });
214
- var Tab = forwardRef3(function Tab2({ children, type, value, ...rest }, ref) {
215
- const selected = useSelected(value);
216
- return /* @__PURE__ */ jsx3(
217
- "button",
218
- {
219
- ...rest,
220
- ref,
221
- type: type ?? "button",
222
- role: "tab",
223
- "aria-selected": selected,
224
- tabIndex: selected ? 0 : -1,
225
- "data-hl-value": value,
226
- children
227
- }
228
- );
229
- });
230
- var TabPanel = forwardRef3(function TabPanel2({ children, ...rest }, ref) {
231
- const selected = useSelected(void 0);
232
- return /* @__PURE__ */ jsx3("div", { ...rest, ref, role: "tabpanel", hidden: !selected, children });
233
- });
234
-
235
- // src/Dropdown.tsx
236
- import {
237
- createContext as createContext4,
238
- forwardRef as forwardRef4,
239
- useContext as useContext3
240
- } from "react";
241
- import {
242
- enhanceDropdown
243
- } from "@hydrateless/enhancers";
244
-
245
- // src/internal/useHlId.ts
246
- import { useId } from "react";
247
- function useHlId(prefix, id) {
248
- const generated = useId();
249
- return id ?? `hl-${prefix}-${generated.replace(/[^\w-]/g, "")}`;
250
- }
251
-
252
- // src/Dropdown.tsx
253
- import { jsx as jsx4 } from "react/jsx-runtime";
254
- var DropdownContext = createContext4(void 0);
255
- var Dropdown = forwardRef4(function Dropdown2({
256
- placement,
257
- closeOnSelect,
258
- open: openProp,
259
- defaultOpen,
260
- onOpenChange,
261
- onSelect,
262
- children,
263
- ...rest
264
- }, forwardedRef) {
265
- const ref = useForwardedRef(forwardedRef);
266
- const menuId = useHlId("dropdown-menu");
267
- const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
268
- const api = useEnhancer(
269
- ref,
270
- enhanceDropdown,
271
- { placement, closeOnSelect, defaultOpen: open, onOpenChange: setOpen, onSelect },
272
- [placement, closeOnSelect]
273
- );
274
- useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2, { focus: !api2.open }));
275
- return /* @__PURE__ */ jsx4(DropdownContext.Provider, { value: menuId, children: /* @__PURE__ */ jsx4("div", { ...rest, ref, "data-hl-dropdown": true, children }) });
276
- });
277
- var DropdownTrigger = forwardRef4(
278
- function DropdownTrigger2({ children, type, ...rest }, ref) {
279
- const menuId = useContext3(DropdownContext);
280
- const target = { popovertarget: rest.popoverTarget ?? menuId };
281
- return /* @__PURE__ */ jsx4(
282
- "button",
283
- {
284
- ...rest,
285
- ...target,
286
- popoverTarget: void 0,
287
- ref,
288
- type: type ?? "button",
289
- "data-hl-dropdown-trigger": true,
290
- children
291
- }
292
- );
293
- }
294
- );
295
- var DropdownMenu = forwardRef4(function DropdownMenu2({ id, children, ...rest }, ref) {
296
- const menuId = useContext3(DropdownContext);
297
- return /* @__PURE__ */ jsx4("ul", { ...rest, ref, id: id ?? menuId, popover: "auto", "data-hl-dropdown-menu": true, children });
298
- });
299
- var DropdownItem = forwardRef4(function DropdownItem2({ children, value, role = "menuitem", checked, disabled, type, ...rest }, ref) {
300
- return /* @__PURE__ */ jsx4("li", { role: "none", children: /* @__PURE__ */ jsx4(
301
- "button",
302
- {
303
- ...rest,
304
- ref,
305
- type: type ?? "button",
306
- role,
307
- "aria-checked": role === "menuitem" ? void 0 : checked ?? false,
308
- "aria-disabled": disabled || void 0,
309
- disabled,
310
- "data-hl-value": value,
311
- children
312
- }
313
- ) });
314
- });
315
- var DropdownGroup = forwardRef4(
316
- function DropdownGroup2({ label, children, ...rest }, ref) {
317
- return /* @__PURE__ */ jsx4("li", { role: "none", children: /* @__PURE__ */ jsx4("ul", { ...rest, ref, role: "group", "aria-label": label, children }) });
318
- }
319
- );
320
- var DropdownSeparator = forwardRef4(
321
- function DropdownSeparator2({ className, ...rest }, ref) {
322
- return /* @__PURE__ */ jsx4("li", { ...rest, ref, role: "separator", className: cx("hl-dropdown-separator", className) });
323
- }
324
- );
325
-
326
- // src/Menu.tsx
327
- import {
328
- forwardRef as forwardRef5
329
- } from "react";
330
- import { enhanceMenu } from "@hydrateless/enhancers";
331
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
332
- var Menu = forwardRef5(function Menu2({
333
- orientation = "horizontal",
334
- value: valueProp,
335
- defaultValue,
336
- onValueChange,
337
- onSelect,
338
- children,
339
- ...rest
340
- }, forwardedRef) {
341
- const ref = useForwardedRef(forwardedRef);
342
- const [value, setValue] = useControlled(
343
- valueProp,
344
- defaultValue ?? null,
345
- onValueChange
346
- );
347
- const api = useEnhancer(
348
- ref,
349
- enhanceMenu,
350
- { orientation, defaultValue: value, onValueChange: setValue, onSelect },
351
- [orientation]
352
- );
353
- useSyncApi(api, valueProp, (api2, value2) => api2.setValue(value2));
354
- return /* @__PURE__ */ jsx5(
355
- "ul",
356
- {
357
- ...rest,
358
- ref,
359
- "data-hl-menu": true,
360
- role: orientation === "vertical" ? "menu" : "menubar",
361
- "aria-orientation": orientation,
362
- children
363
- }
364
- );
365
- });
366
- var MenuItem = forwardRef5(function MenuItem2({ href, value, role = "menuitem", checked, disabled, anchorProps, children, ...rest }, ref) {
367
- const shared = {
368
- role,
369
- "aria-checked": role === "menuitem" ? void 0 : checked ?? false,
370
- "aria-disabled": disabled || void 0,
371
- "data-hl-value": value
372
- };
373
- return /* @__PURE__ */ jsx5("li", { role: "none", children: href ? /* @__PURE__ */ jsx5("a", { ...anchorProps, ...shared, ref, href, children }) : /* @__PURE__ */ jsx5(
374
- "button",
375
- {
376
- ...rest,
377
- ...shared,
378
- ref,
379
- type: "button",
380
- disabled,
381
- children
382
- }
383
- ) });
384
- });
385
- var MenuSubmenu = forwardRef5(function MenuSubmenu2({ label, value, disabled, triggerProps, children, ...rest }, ref) {
386
- return /* @__PURE__ */ jsxs3("li", { role: "none", children: [
387
- /* @__PURE__ */ jsx5(
388
- "button",
389
- {
390
- ...triggerProps,
391
- type: "button",
392
- role: "menuitem",
393
- "aria-disabled": disabled || void 0,
394
- disabled,
395
- "data-hl-value": value,
396
- children: label
397
- }
398
- ),
399
- /* @__PURE__ */ jsx5("ul", { ...rest, ref, role: "menu", "data-hl-submenu": true, children })
400
- ] });
401
- });
402
-
403
- // src/Modal.tsx
404
- import { forwardRef as forwardRef6 } from "react";
405
- import { enhanceModal } from "@hydrateless/enhancers";
406
- import { jsx as jsx6 } from "react/jsx-runtime";
407
- var Modal = forwardRef6(function Modal2({
408
- open: openProp,
409
- defaultOpen,
410
- onOpenChange,
411
- closeOnBackdrop = true,
412
- className,
413
- children,
414
- ...rest
415
- }, forwardedRef) {
416
- const ref = useForwardedRef(forwardedRef);
417
- const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
418
- const api = useEnhancer(
419
- ref,
420
- enhanceModal,
421
- { closeOnBackdrop, defaultOpen: open, onOpenChange: setOpen },
422
- [closeOnBackdrop]
423
- );
424
- useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2));
425
- return /* @__PURE__ */ jsx6("dialog", { ...rest, ref, "data-hl-modal": true, className: cx("hl-modal", className), children });
426
- });
427
- var ModalHeader = forwardRef6(function ModalHeader2({ className, ...rest }, ref) {
428
- return /* @__PURE__ */ jsx6("div", { ...rest, ref, className: cx("hl-modal-header", className) });
429
- });
430
- var ModalBody = forwardRef6(function ModalBody2({ className, ...rest }, ref) {
431
- return /* @__PURE__ */ jsx6("div", { ...rest, ref, className: cx("hl-modal-body", className) });
432
- });
433
- var ModalFooter = forwardRef6(function ModalFooter2({ className, ...rest }, ref) {
434
- return /* @__PURE__ */ jsx6("div", { ...rest, ref, className: cx("hl-modal-footer", className) });
435
- });
436
-
437
- // src/Drawer.tsx
438
- import { forwardRef as forwardRef7 } from "react";
439
- import { enhanceDrawer } from "@hydrateless/enhancers";
440
- import { jsx as jsx7 } from "react/jsx-runtime";
441
- var Drawer = forwardRef7(function Drawer2({
442
- open: openProp,
443
- defaultOpen,
444
- onOpenChange,
445
- side = "end",
446
- closeOnBackdrop = true,
447
- className,
448
- children,
449
- ...rest
450
- }, forwardedRef) {
451
- const ref = useForwardedRef(forwardedRef);
452
- const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
453
- const api = useEnhancer(
454
- ref,
455
- enhanceDrawer,
456
- { closeOnBackdrop, defaultOpen: open, onOpenChange: setOpen },
457
- [closeOnBackdrop]
458
- );
459
- useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2));
460
- return /* @__PURE__ */ jsx7(
461
- "dialog",
462
- {
463
- ...rest,
464
- ref,
465
- "data-hl-drawer": true,
466
- "data-hl-side": side,
467
- className: cx("hl-drawer", className),
468
- children
469
- }
470
- );
471
- });
472
- var DrawerHeader = forwardRef7(function DrawerHeader2({ className, ...rest }, ref) {
473
- return /* @__PURE__ */ jsx7("div", { ...rest, ref, className: cx("hl-drawer-header", className) });
474
- });
475
- var DrawerBody = forwardRef7(function DrawerBody2({ className, ...rest }, ref) {
476
- return /* @__PURE__ */ jsx7("div", { ...rest, ref, className: cx("hl-drawer-body", className) });
477
- });
478
- var DrawerFooter = forwardRef7(function DrawerFooter2({ className, ...rest }, ref) {
479
- return /* @__PURE__ */ jsx7("div", { ...rest, ref, className: cx("hl-drawer-footer", className) });
480
- });
481
-
482
- // src/Popover.tsx
483
- import { forwardRef as forwardRef8 } from "react";
484
- import {
485
- enhancePopover
486
- } from "@hydrateless/enhancers";
487
- import { jsx as jsx8 } from "react/jsx-runtime";
488
- var Popover = forwardRef8(function Popover2({ open: openProp, defaultOpen, onOpenChange, placement, hover, children, ...rest }, forwardedRef) {
489
- const ref = useForwardedRef(forwardedRef);
490
- const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
491
- const api = useEnhancer(
492
- ref,
493
- enhancePopover,
494
- {
495
- placement,
496
- triggerEvent: hover ? "hover" : "click",
497
- defaultOpen: open,
498
- onOpenChange: setOpen
499
- },
500
- [placement, hover]
501
- );
502
- useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2));
503
- return /* @__PURE__ */ jsx8("div", { ...rest, ref, "data-hl-popover": true, popover: "auto", role: "dialog", children });
504
- });
505
-
506
- // src/Tooltip.tsx
507
- import {
508
- cloneElement,
509
- forwardRef as forwardRef9,
510
- isValidElement as isValidElement3
511
- } from "react";
512
- import {
513
- enhanceTooltip
514
- } from "@hydrateless/enhancers";
515
- import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
516
- var Tooltip = forwardRef9(function Tooltip2({
517
- content,
518
- children,
519
- placement,
520
- showDelay,
521
- hideDelay,
522
- open: openProp,
523
- onOpenChange,
524
- id,
525
- style,
526
- ...rest
527
- }, forwardedRef) {
528
- const ref = useForwardedRef(forwardedRef);
529
- const tipId = useHlId("tip");
530
- const [, setOpen] = useControlled(openProp, false, onOpenChange);
531
- const api = useEnhancer(
532
- ref,
533
- enhanceTooltip,
534
- { placement, showDelay, hideDelay, onOpenChange: setOpen },
535
- [placement, showDelay, hideDelay]
536
- );
537
- useSyncApi(api, openProp, (api2, open) => api2.setOpen(open));
538
- const trigger = isValidElement3(children) ? cloneElement(children, {
539
- "data-hl-tooltip": tipId,
540
- "aria-describedby": tipId
541
- }) : children;
542
- return /* @__PURE__ */ jsxs4(
543
- "span",
544
- {
545
- ...rest,
546
- ref,
547
- id,
548
- style: { position: "relative", display: "inline-block", ...style },
549
- children: [
550
- trigger,
551
- /* @__PURE__ */ jsx9("span", { id: tipId, role: "tooltip", children: content })
552
- ]
553
- }
554
- );
555
- });
556
-
557
- // src/Breadcrumb.tsx
558
- import {
559
- forwardRef as forwardRef10
560
- } from "react";
561
- import { jsx as jsx10 } from "react/jsx-runtime";
562
- var Breadcrumb = forwardRef10(function Breadcrumb2({ children, ...rest }, ref) {
563
- return /* @__PURE__ */ jsx10("nav", { ...rest, ref, "data-hl-breadcrumb": true, "aria-label": rest["aria-label"] ?? "Breadcrumb", children: /* @__PURE__ */ jsx10("ol", { children }) });
564
- });
565
- var BreadcrumbItem = forwardRef10(
566
- function BreadcrumbItem2({ href, current, anchorProps, children, ...rest }, ref) {
567
- return /* @__PURE__ */ jsx10("li", { ...rest, ref, children: current || !href ? /* @__PURE__ */ jsx10("span", { "aria-current": current ? "page" : void 0, children }) : /* @__PURE__ */ jsx10("a", { ...anchorProps, href, children }) });
568
- }
569
- );
570
-
571
- // src/Switch.tsx
572
- import { forwardRef as forwardRef12 } from "react";
573
-
574
- // src/Field.tsx
575
- import {
576
- createContext as createContext5,
577
- forwardRef as forwardRef11,
578
- useContext as useContext4
579
- } from "react";
580
- import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
581
- var FieldContext = createContext5(null);
582
- function useField() {
583
- const ctx = useContext4(FieldContext);
584
- if (!ctx) return null;
585
- const describedBy = [ctx.helpId, ctx.invalid ? ctx.errorId : null].filter(Boolean).join(" ");
586
- return {
587
- id: ctx.id,
588
- describedBy: describedBy || void 0,
589
- invalid: ctx.invalid,
590
- required: ctx.required
591
- };
592
- }
593
- var Field = forwardRef11(function Field2({
594
- id,
595
- label,
596
- description,
597
- error,
598
- invalid = false,
599
- required = false,
600
- className,
601
- children,
602
- ...rest
603
- }, ref) {
604
- const baseId = useHlId("field", id);
605
- const hasError = error != null && error !== false;
606
- const value = {
607
- id: baseId,
608
- helpId: `${baseId}-help`,
609
- errorId: `${baseId}-error`,
610
- invalid: invalid || hasError,
611
- required
612
- };
613
- return /* @__PURE__ */ jsx11(FieldContext.Provider, { value, children: /* @__PURE__ */ jsxs5(
614
- "div",
615
- {
616
- ...rest,
617
- ref,
618
- className: cx("hl-field", className),
619
- "data-hl-invalid": value.invalid || void 0,
620
- children: [
621
- label != null && /* @__PURE__ */ jsx11(FieldLabel, { children: label }),
622
- children,
623
- description != null && /* @__PURE__ */ jsx11(FieldHelp, { children: description }),
624
- hasError && /* @__PURE__ */ jsx11(FieldError, { children: error })
625
- ]
626
- }
627
- ) });
628
- });
629
- var FieldLabel = forwardRef11(function FieldLabel2({ className, children, ...rest }, ref) {
630
- const ctx = useContext4(FieldContext);
631
- return /* @__PURE__ */ jsx11(
632
- "label",
633
- {
634
- ...rest,
635
- ref,
636
- htmlFor: rest.htmlFor ?? ctx?.id,
637
- className: cx("hl-label", className),
638
- "data-hl-required": ctx?.required || void 0,
639
- children
640
- }
641
- );
642
- });
643
- var FieldHelp = forwardRef11(function FieldHelp2({ className, children, ...rest }, ref) {
644
- const ctx = useContext4(FieldContext);
645
- return /* @__PURE__ */ jsx11("p", { ...rest, ref, id: rest.id ?? ctx?.helpId, className: cx("hl-help", className), children });
646
- });
647
- var FieldError = forwardRef11(function FieldError2({ className, children, ...rest }, ref) {
648
- const ctx = useContext4(FieldContext);
649
- if (children == null || children === false) return null;
650
- return /* @__PURE__ */ jsx11(
651
- "p",
652
- {
653
- ...rest,
654
- ref,
655
- id: rest.id ?? ctx?.errorId,
656
- role: "alert",
657
- className: cx("hl-error", className),
658
- children
659
- }
660
- );
661
- });
662
- var Fieldset = forwardRef11(function Fieldset2({ legend, className, children, ...rest }, ref) {
663
- return /* @__PURE__ */ jsxs5("fieldset", { ...rest, ref, className: cx("hl-fieldset", className), children: [
664
- legend != null && /* @__PURE__ */ jsx11("legend", { className: "hl-legend", children: legend }),
665
- children
666
- ] });
667
- });
668
-
669
- // src/internal/useFieldControl.ts
670
- function useFieldControl(props, invalid) {
671
- const field = useField();
672
- const isInvalid = invalid || props["aria-invalid"] || field?.invalid || void 0;
673
- return {
674
- ...props,
675
- id: props.id ?? field?.id,
676
- required: props.required ?? field?.required,
677
- "aria-describedby": props["aria-describedby"] ?? field?.describedBy,
678
- "aria-invalid": isInvalid
679
- };
680
- }
681
-
682
- // src/Switch.tsx
683
- import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
684
- var Switch = forwardRef12(function Switch2({ children, className, ...rest }, ref) {
685
- const props = useFieldControl(rest);
686
- return /* @__PURE__ */ jsxs6("label", { "data-hl-switch": true, className, children: [
687
- /* @__PURE__ */ jsx12("input", { ...props, ref, type: "checkbox", role: "switch" }),
688
- children
689
- ] });
690
- });
691
-
692
- // src/SkipLink.tsx
693
- import { forwardRef as forwardRef13 } from "react";
694
- import { jsx as jsx13 } from "react/jsx-runtime";
695
- var SkipLink = forwardRef13(function SkipLink2({ children = "Skip to content", className, ...rest }, ref) {
696
- return /* @__PURE__ */ jsx13("a", { ...rest, ref, className: cx("hl-skip-link", className), children });
697
- });
698
-
699
- // src/Toc.tsx
700
- import { forwardRef as forwardRef14 } from "react";
701
- import { enhanceToc } from "@hydrateless/enhancers";
702
- import { jsx as jsx14 } from "react/jsx-runtime";
703
- var Toc = forwardRef14(function Toc2({ contentSelector, headings, scrollSpy, ...rest }, forwardedRef) {
704
- const ref = useForwardedRef(forwardedRef);
705
- useEnhancer(
706
- ref,
707
- // The content lives outside the nav, so scan from the document.
708
- (nav, options) => enhanceToc(nav.ownerDocument, options),
709
- { contentSelector, headings, scrollSpy },
710
- [contentSelector, headings, scrollSpy]
711
- );
712
- return /* @__PURE__ */ jsx14("nav", { ...rest, ref, "data-hl-toc": true });
713
- });
714
-
715
- // src/Toast.tsx
716
- import { forwardRef as forwardRef15 } from "react";
717
- import { enhanceToast } from "@hydrateless/enhancers";
718
- import { jsx as jsx15 } from "react/jsx-runtime";
719
- var sharedApi = null;
720
- function ensureApi() {
721
- if (!sharedApi) {
722
- const handle = enhanceToast(document);
723
- sharedApi = handle.api;
724
- }
725
- return sharedApi;
726
- }
727
- var facade = {
728
- show: (message, options) => ensureApi().show(message, options),
729
- dismiss: (toast) => ensureApi().dismiss(toast),
730
- dismissAll: () => ensureApi().dismissAll()
731
- };
732
- var ToastRegion = forwardRef15(function ToastRegion2({ duration, onOpenChange, ...props }, forwardedRef) {
733
- const ref = useForwardedRef(forwardedRef);
734
- useEnhancer(
735
- ref,
736
- (region, options) => {
737
- const handle = enhanceToast(region.ownerDocument, options);
738
- sharedApi = handle.api;
739
- return {
740
- ...handle,
741
- destroy: () => {
742
- handle.destroy();
743
- sharedApi = null;
744
- }
745
- };
746
- },
747
- { duration, onOpenChange },
748
- [duration]
749
- );
750
- return /* @__PURE__ */ jsx15("div", { ...props, ref, "data-hl-toast-region": true });
751
- });
752
- function useToast() {
753
- return facade;
754
- }
755
-
756
- // src/Combobox.tsx
757
- import {
758
- forwardRef as forwardRef16
759
- } from "react";
760
- import {
761
- enhanceCombobox
762
- } from "@hydrateless/enhancers";
763
- import { jsx as jsx16 } from "react/jsx-runtime";
764
- var Combobox = forwardRef16(function Combobox2({
765
- filter,
766
- autoHighlight,
767
- value: valueProp,
768
- defaultValue,
769
- onValueChange,
770
- open: openProp,
771
- defaultOpen,
772
- onOpenChange,
773
- children,
774
- ...rest
775
- }, forwardedRef) {
776
- const ref = useForwardedRef(forwardedRef);
777
- const [value, setValue] = useControlled(valueProp, defaultValue, onValueChange);
778
- const [open, setOpen] = useControlled(openProp, defaultOpen ?? false, onOpenChange);
779
- const api = useEnhancer(
780
- ref,
781
- enhanceCombobox,
782
- {
783
- filter,
784
- autoHighlight,
785
- defaultValue: value,
786
- defaultOpen: open,
787
- onValueChange: setValue,
788
- onOpenChange: setOpen
789
- },
790
- [filter, autoHighlight]
791
- );
792
- useSyncApi(api, valueProp, (api2, value2) => api2.setValue(value2));
793
- useSyncApi(api, openProp, (api2, open2) => api2.setOpen(open2));
794
- return /* @__PURE__ */ jsx16("div", { ...rest, ref, "data-hl-combobox": true, children });
795
- });
796
- var ComboboxInput = forwardRef16(
797
- function ComboboxInput2({ styled = true, className, ...rest }, ref) {
798
- const props = useFieldControl(rest);
799
- return /* @__PURE__ */ jsx16("input", { ...props, ref, className: cx(styled && "hl-input", className) });
800
- }
801
- );
802
- var ComboboxList = forwardRef16(function ComboboxList2({ children, ...rest }, ref) {
803
- return /* @__PURE__ */ jsx16("ul", { ...rest, ref, role: "listbox", children });
804
- });
805
- var ComboboxOption = forwardRef16(
806
- function ComboboxOption2({ value, disabled, children, ...rest }, ref) {
807
- return /* @__PURE__ */ jsx16(
808
- "li",
809
- {
810
- ...rest,
811
- ref,
812
- role: "option",
813
- "aria-disabled": disabled || void 0,
814
- "data-hl-value": value,
815
- children: children ?? value
816
- }
817
- );
818
- }
819
- );
820
-
821
- // src/Command.tsx
822
- import { forwardRef as forwardRef17 } from "react";
823
- import {
824
- enhanceCommand
825
- } from "@hydrateless/enhancers";
826
- import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
827
- var Command = forwardRef17(function Command2({ hotkey, query: queryProp, defaultQuery, onQueryChange, onCommand, children, ...rest }, forwardedRef) {
828
- const ref = useForwardedRef(forwardedRef);
829
- const [query, setQuery] = useControlled(queryProp, defaultQuery, onQueryChange);
830
- const api = useEnhancer(
831
- ref,
832
- enhanceCommand,
833
- { hotkey, defaultValue: query, onValueChange: setQuery, onCommand },
834
- [hotkey]
835
- );
836
- useSyncApi(api, queryProp, (api2, query2) => api2.setValue(query2));
837
- return /* @__PURE__ */ jsx17("div", { ...rest, ref, "data-hl-command": true, "data-hl-hotkey": hotkey, children });
838
- });
839
- var CommandInput = forwardRef17(function CommandInput2({ styled = true, className, ...rest }, ref) {
840
- return /* @__PURE__ */ jsx17(
841
- "input",
842
- {
843
- ...rest,
844
- ref,
845
- className: cx(styled && "hl-input", className),
846
- "data-hl-command-input": true
847
- }
848
- );
849
- });
850
- var CommandList = forwardRef17(function CommandList2({ children, ...rest }, ref) {
851
- return /* @__PURE__ */ jsx17("div", { ...rest, ref, "data-hl-command-list": true, role: "listbox", children });
852
- });
853
- var CommandGroup = forwardRef17(function CommandGroup2({ label, children, ...rest }, ref) {
854
- return /* @__PURE__ */ jsxs7("div", { ...rest, ref, "data-hl-command-group": true, children: [
855
- label != null && /* @__PURE__ */ jsx17("div", { className: "hl-command-group-label", role: "presentation", children: label }),
856
- children
857
- ] });
858
- });
859
- var CommandItem = forwardRef17(function CommandItem2({ value, keywords, icon, children, ...rest }, ref) {
860
- return /* @__PURE__ */ jsxs7("div", { ...rest, ref, role: "option", "data-hl-value": value, "data-hl-keywords": keywords, children: [
861
- icon,
862
- /* @__PURE__ */ jsx17("span", { children })
863
- ] });
864
- });
865
- var CommandEmpty = forwardRef17(function CommandEmpty2({ children = "No results found.", ...rest }, ref) {
866
- return /* @__PURE__ */ jsx17("div", { ...rest, ref, "data-hl-command-empty": true, hidden: true, children });
867
- });
868
-
869
- // src/Input.tsx
870
- import { forwardRef as forwardRef18 } from "react";
871
- import { jsx as jsx18 } from "react/jsx-runtime";
872
- var Input = forwardRef18(function Input2({ size, invalid, className, ...rest }, ref) {
873
- const props = useFieldControl(rest, invalid);
874
- return /* @__PURE__ */ jsx18(
875
- "input",
876
- {
877
- ...props,
878
- ref,
879
- className: cx("hl-input", className),
880
- "data-hl-size": size,
881
- "data-hl-invalid": props["aria-invalid"] || void 0
882
- }
883
- );
884
- });
885
-
886
- // src/Textarea.tsx
887
- import { forwardRef as forwardRef19 } from "react";
888
- import { jsx as jsx19 } from "react/jsx-runtime";
889
- var Textarea = forwardRef19(function Textarea2({ invalid, autosize, className, ...rest }, ref) {
890
- const props = useFieldControl(rest, invalid);
891
- return /* @__PURE__ */ jsx19(
892
- "textarea",
893
- {
894
- ...props,
895
- ref,
896
- className: cx("hl-textarea", className),
897
- "data-hl-autosize": autosize || void 0,
898
- "data-hl-invalid": props["aria-invalid"] || void 0
899
- }
900
- );
901
- });
902
-
903
- // src/Select.tsx
904
- import { forwardRef as forwardRef20 } from "react";
905
- import { jsx as jsx20 } from "react/jsx-runtime";
906
- var Select = forwardRef20(function Select2({ size, invalid, options, className, children, ...rest }, ref) {
907
- const props = useFieldControl(rest, invalid);
908
- return /* @__PURE__ */ jsx20("span", { className: "hl-select-wrapper", children: /* @__PURE__ */ jsx20(
909
- "select",
910
- {
911
- ...props,
912
- ref,
913
- className: cx("hl-select", className),
914
- "data-hl-size": size,
915
- "data-hl-invalid": props["aria-invalid"] || void 0,
916
- children: options ? options.map((option) => /* @__PURE__ */ jsx20("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value)) : children
917
- }
918
- ) });
919
- });
920
-
921
- // src/Checkbox.tsx
922
- import { forwardRef as forwardRef21 } from "react";
923
- import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
924
- var Checkbox = forwardRef21(function Checkbox2({ children, className, ...rest }, ref) {
925
- const props = useFieldControl(rest);
926
- return /* @__PURE__ */ jsxs8("label", { className: cx("hl-checkbox", className), children: [
927
- /* @__PURE__ */ jsx21("input", { ...props, ref, type: "checkbox" }),
928
- children != null && /* @__PURE__ */ jsx21("span", { children })
929
- ] });
930
- });
931
-
932
- // src/Radio.tsx
933
- import {
934
- createContext as createContext6,
935
- forwardRef as forwardRef22,
936
- useContext as useContext5
937
- } from "react";
938
- import { jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
939
- var RadioGroupContext = createContext6(null);
940
- var Radio = forwardRef22(function Radio2({ children, className, value, ...rest }, ref) {
941
- const group = useContext5(RadioGroupContext);
942
- return /* @__PURE__ */ jsxs9("label", { className: cx("hl-radio", className), children: [
943
- /* @__PURE__ */ jsx22(
944
- "input",
945
- {
946
- ...rest,
947
- ref,
948
- type: "radio",
949
- name: rest.name ?? group?.name,
950
- value,
951
- checked: group ? group.value === value : rest.checked,
952
- onChange: (e) => {
953
- group?.setValue(value);
954
- rest.onChange?.(e);
955
- }
956
- }
957
- ),
958
- children != null && /* @__PURE__ */ jsx22("span", { children })
959
- ] });
960
- });
961
- var RadioGroup = forwardRef22(function RadioGroup2({
962
- name,
963
- value: valueProp,
964
- defaultValue,
965
- onValueChange,
966
- orientation,
967
- className,
968
- children,
969
- ...rest
970
- }, ref) {
971
- const [value, setValue] = useControlled(valueProp, defaultValue, onValueChange);
972
- const groupName = useHlId("radio", name);
973
- return /* @__PURE__ */ jsx22(RadioGroupContext.Provider, { value: { name: groupName, value, setValue }, children: /* @__PURE__ */ jsx22(
974
- "div",
975
- {
976
- ...rest,
977
- ref,
978
- role: "radiogroup",
979
- className: cx("hl-radio-group", className),
980
- "data-hl-orientation": orientation,
981
- "aria-orientation": orientation,
982
- children
983
- }
984
- ) });
985
- });
986
-
987
- // src/SegmentedControl.tsx
988
- import { forwardRef as forwardRef23 } from "react";
989
- import { jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
990
- var SegmentedControl = forwardRef23(
991
- function SegmentedControl2({ options, value: valueProp, defaultValue, onValueChange, name, size, className, ...rest }, ref) {
992
- const [value, setValue] = useControlled(
993
- valueProp,
994
- defaultValue ?? options[0]?.value,
995
- onValueChange
996
- );
997
- const groupName = useHlId("segmented", name);
998
- return /* @__PURE__ */ jsx23(
999
- "div",
1000
- {
1001
- ...rest,
1002
- ref,
1003
- role: "radiogroup",
1004
- className: cx("hl-segmented", className),
1005
- "data-hl-size": size,
1006
- children: options.map((option) => /* @__PURE__ */ jsxs10("label", { className: "hl-segmented-item", children: [
1007
- /* @__PURE__ */ jsx23(
1008
- "input",
1009
- {
1010
- type: "radio",
1011
- name: groupName,
1012
- value: option.value,
1013
- checked: value === option.value,
1014
- disabled: option.disabled,
1015
- onChange: () => setValue(option.value)
1016
- }
1017
- ),
1018
- /* @__PURE__ */ jsx23("span", { children: option.label })
1019
- ] }, option.value))
1020
- }
1021
- );
1022
- }
1023
- );
1024
-
1025
- // src/Slider.tsx
1026
- import { forwardRef as forwardRef24 } from "react";
1027
- import { jsx as jsx24 } from "react/jsx-runtime";
1028
- var Slider = forwardRef24(function Slider2({ className, ...rest }, ref) {
1029
- const props = useFieldControl(rest);
1030
- return /* @__PURE__ */ jsx24("input", { ...props, ref, type: "range", className: cx("hl-slider", className) });
1031
- });
1032
-
1033
- // src/Button.tsx
1034
- import { forwardRef as forwardRef25 } from "react";
1035
- import { jsx as jsx25 } from "react/jsx-runtime";
1036
- var Button = forwardRef25(function Button2({ variant, intent, size, block, icon, loading, className, children, disabled, type, ...rest }, ref) {
1037
- return /* @__PURE__ */ jsx25(
1038
- "button",
1039
- {
1040
- ...rest,
1041
- ref,
1042
- type: type ?? "button",
1043
- className: ["hl-button", className].filter(Boolean).join(" "),
1044
- "data-hl-variant": variant,
1045
- "data-hl-intent": intent,
1046
- "data-hl-size": size,
1047
- "data-hl-block": block || void 0,
1048
- "data-hl-icon": icon || void 0,
1049
- "data-hl-loading": loading || void 0,
1050
- "aria-busy": loading || void 0,
1051
- disabled: disabled || loading,
1052
- children
1053
- }
1054
- );
1055
- });
1056
-
1057
- // src/Alert.tsx
1058
- import { forwardRef as forwardRef26 } from "react";
1059
- import { jsx as jsx26, jsxs as jsxs11 } from "react/jsx-runtime";
1060
- var Alert = forwardRef26(function Alert2({ intent, title, icon, className, children, ...rest }, ref) {
1061
- return /* @__PURE__ */ jsxs11(
1062
- "div",
1063
- {
1064
- ...rest,
1065
- ref,
1066
- role: rest.role ?? "alert",
1067
- className: ["hl-alert", className].filter(Boolean).join(" "),
1068
- "data-hl-intent": intent,
1069
- children: [
1070
- icon,
1071
- /* @__PURE__ */ jsxs11("div", { className: "hl-alert-body", children: [
1072
- title != null && /* @__PURE__ */ jsx26("p", { className: "hl-alert-title", children: title }),
1073
- children
1074
- ] })
1075
- ]
1076
- }
1077
- );
1078
- });
1079
-
1080
- // src/Badge.tsx
1081
- import { forwardRef as forwardRef27 } from "react";
1082
- import { jsx as jsx27 } from "react/jsx-runtime";
1083
- var Badge = forwardRef27(function Badge2({ intent, variant, size, className, children, ...rest }, ref) {
1084
- return /* @__PURE__ */ jsx27(
1085
- "span",
1086
- {
1087
- ...rest,
1088
- ref,
1089
- className: ["hl-badge", className].filter(Boolean).join(" "),
1090
- "data-hl-intent": intent,
1091
- "data-hl-variant": variant,
1092
- "data-hl-size": size,
1093
- children
1094
- }
1095
- );
1096
- });
1097
-
1098
- // src/Card.tsx
1099
- import { forwardRef as forwardRef28 } from "react";
1100
- import { jsx as jsx28 } from "react/jsx-runtime";
1101
- var Card = forwardRef28(function Card2({ interactive, className, children, ...rest }, ref) {
1102
- return /* @__PURE__ */ jsx28(
1103
- "div",
1104
- {
1105
- ...rest,
1106
- ref,
1107
- className: ["hl-card", className].filter(Boolean).join(" "),
1108
- "data-hl-interactive": interactive || void 0,
1109
- children
1110
- }
1111
- );
1112
- });
1113
- var CardHeader = forwardRef28(function CardHeader2({ className, ...rest }, ref) {
1114
- return /* @__PURE__ */ jsx28("div", { ...rest, ref, className: ["hl-card-header", className].filter(Boolean).join(" ") });
1115
- });
1116
- var CardBody = forwardRef28(function CardBody2({ className, ...rest }, ref) {
1117
- return /* @__PURE__ */ jsx28("div", { ...rest, ref, className: ["hl-card-body", className].filter(Boolean).join(" ") });
1118
- });
1119
- var CardFooter = forwardRef28(function CardFooter2({ className, ...rest }, ref) {
1120
- return /* @__PURE__ */ jsx28("div", { ...rest, ref, className: ["hl-card-footer", className].filter(Boolean).join(" ") });
1121
- });
1122
- var CardTitle = forwardRef28(
1123
- function CardTitle2({ className, ...rest }, ref) {
1124
- return /* @__PURE__ */ jsx28("h3", { ...rest, ref, className: ["hl-card-title", className].filter(Boolean).join(" ") });
1125
- }
1126
- );
1127
- var CardDescription = forwardRef28(function CardDescription2({ className, ...rest }, ref) {
1128
- return /* @__PURE__ */ jsx28(
1129
- "p",
1130
- {
1131
- ...rest,
1132
- ref,
1133
- className: ["hl-card-description", className].filter(Boolean).join(" ")
1134
- }
1135
- );
1136
- });
1137
-
1138
- // src/Avatar.tsx
1139
- import { forwardRef as forwardRef29, useState as useState2 } from "react";
1140
- import { jsx as jsx29 } from "react/jsx-runtime";
1141
- var Avatar = forwardRef29(function Avatar2({ src, alt = "", fallback, size, shape, className, children, ...rest }, ref) {
1142
- const [failed, setFailed] = useState2(false);
1143
- const showImage = src && !failed;
1144
- return /* @__PURE__ */ jsx29(
1145
- "span",
1146
- {
1147
- ...rest,
1148
- ref,
1149
- className: ["hl-avatar", className].filter(Boolean).join(" "),
1150
- "data-hl-size": size,
1151
- "data-hl-shape": shape === "square" ? "square" : void 0,
1152
- children: showImage ? /* @__PURE__ */ jsx29("img", { src, alt, onError: () => setFailed(true) }) : fallback ?? children
1153
- }
1154
- );
1155
- });
1156
- var AvatarGroup = forwardRef29(function AvatarGroup2({ className, children, ...rest }, ref) {
1157
- return /* @__PURE__ */ jsx29("div", { ...rest, ref, className: ["hl-avatar-group", className].filter(Boolean).join(" "), children });
1158
- });
1159
-
1160
- // src/Progress.tsx
1161
- import { forwardRef as forwardRef30 } from "react";
1162
- import { jsx as jsx30 } from "react/jsx-runtime";
1163
- var Progress = forwardRef30(function Progress2({ value, max = 100, intent, size, className, ...rest }, ref) {
1164
- return /* @__PURE__ */ jsx30(
1165
- "progress",
1166
- {
1167
- ...rest,
1168
- ref,
1169
- className: ["hl-progress", className].filter(Boolean).join(" "),
1170
- "data-hl-intent": intent,
1171
- "data-hl-size": size,
1172
- value,
1173
- max
1174
- }
1175
- );
1176
- });
1177
-
1178
- // src/Spinner.tsx
1179
- import { forwardRef as forwardRef31 } from "react";
1180
- import { jsx as jsx31 } from "react/jsx-runtime";
1181
- var Spinner = forwardRef31(function Spinner2({ size, label = "Loading", className, ...rest }, ref) {
1182
- return /* @__PURE__ */ jsx31(
1183
- "span",
1184
- {
1185
- ...rest,
1186
- ref,
1187
- className: ["hl-spinner", className].filter(Boolean).join(" "),
1188
- "data-hl-size": size,
1189
- role: "status",
1190
- "aria-label": label
1191
- }
1192
- );
1193
- });
1194
-
1195
- // src/Skeleton.tsx
1196
- import { forwardRef as forwardRef32 } from "react";
1197
- import { jsx as jsx32 } from "react/jsx-runtime";
1198
- var Skeleton = forwardRef32(function Skeleton2({ shape, width, height, className, style, ...rest }, ref) {
1199
- const sizeStyle = {
1200
- ...width != null && { inlineSize: width },
1201
- ...height != null && { blockSize: height },
1202
- ...style
1203
- };
1204
- return /* @__PURE__ */ jsx32(
1205
- "span",
1206
- {
1207
- ...rest,
1208
- ref,
1209
- className: cx("hl-skeleton", className),
1210
- "data-hl-shape": shape,
1211
- style: sizeStyle,
1212
- "aria-hidden": "true"
1213
- }
1214
- );
1215
- });
1216
-
1217
- // src/Pagination.tsx
1218
- import { forwardRef as forwardRef33 } from "react";
1219
- import { jsx as jsx33, jsxs as jsxs12 } from "react/jsx-runtime";
1220
- var ELLIPSIS = "ellipsis";
1221
- function range(start, end) {
1222
- return Array.from({ length: end - start + 1 }, (_, i) => start + i);
1223
- }
1224
- function paginationRange(page, count, siblingCount) {
1225
- const totalNumbers = siblingCount * 2 + 5;
1226
- if (totalNumbers >= count) return range(1, count);
1227
- const leftSibling = Math.max(page - siblingCount, 1);
1228
- const rightSibling = Math.min(page + siblingCount, count);
1229
- const showLeftDots = leftSibling > 2;
1230
- const showRightDots = rightSibling < count - 1;
1231
- if (!showLeftDots && showRightDots) {
1232
- return [...range(1, siblingCount * 2 + 3), ELLIPSIS, count];
1233
- }
1234
- if (showLeftDots && !showRightDots) {
1235
- return [1, ELLIPSIS, ...range(count - (siblingCount * 2 + 2), count)];
1236
- }
1237
- return [1, ELLIPSIS, ...range(leftSibling, rightSibling), ELLIPSIS, count];
1238
- }
1239
- var Pagination = forwardRef33(function Pagination2({
1240
- page,
1241
- count,
1242
- onPageChange,
1243
- siblingCount = 1,
1244
- showControls = true,
1245
- prevLabel = "\u2039",
1246
- nextLabel = "\u203A",
1247
- className,
1248
- ...rest
1249
- }, ref) {
1250
- const items = paginationRange(page, count, siblingCount);
1251
- const go = (target) => {
1252
- if (target >= 1 && target <= count && target !== page) onPageChange?.(target);
1253
- };
1254
- return /* @__PURE__ */ jsx33(
1255
- "nav",
1256
- {
1257
- ...rest,
1258
- ref,
1259
- className: cx("hl-pagination", className),
1260
- "aria-label": rest["aria-label"] ?? "Pagination",
1261
- children: /* @__PURE__ */ jsxs12("ul", { children: [
1262
- showControls && /* @__PURE__ */ jsx33("li", { children: /* @__PURE__ */ jsx33(
1263
- "button",
1264
- {
1265
- type: "button",
1266
- className: "hl-pagination-item",
1267
- "aria-label": "Previous page",
1268
- disabled: page <= 1,
1269
- onClick: () => go(page - 1),
1270
- children: prevLabel
1271
- }
1272
- ) }),
1273
- items.map(
1274
- (item, i) => item === ELLIPSIS ? /* @__PURE__ */ jsx33("li", { "aria-hidden": "true", children: /* @__PURE__ */ jsx33("span", { className: "hl-pagination-ellipsis", children: "\u2026" }) }, `e${i}`) : /* @__PURE__ */ jsx33("li", { children: /* @__PURE__ */ jsx33(
1275
- "button",
1276
- {
1277
- type: "button",
1278
- className: "hl-pagination-item",
1279
- "aria-current": item === page ? "page" : void 0,
1280
- "aria-label": `Page ${item}`,
1281
- onClick: () => go(item),
1282
- children: item
1283
- }
1284
- ) }, item)
1285
- ),
1286
- showControls && /* @__PURE__ */ jsx33("li", { children: /* @__PURE__ */ jsx33(
1287
- "button",
1288
- {
1289
- type: "button",
1290
- className: "hl-pagination-item",
1291
- "aria-label": "Next page",
1292
- disabled: page >= count,
1293
- onClick: () => go(page + 1),
1294
- children: nextLabel
1295
- }
1296
- ) })
1297
- ] })
1298
- }
1299
- );
1300
- });
1301
-
1302
- // src/Kbd.tsx
1303
- import { forwardRef as forwardRef34 } from "react";
1304
- import { jsx as jsx34 } from "react/jsx-runtime";
1305
- var Kbd = forwardRef34(function Kbd2({ className, children, ...rest }, ref) {
1306
- return /* @__PURE__ */ jsx34("kbd", { ...rest, ref, className: ["hl-kbd", className].filter(Boolean).join(" "), children });
1307
- });
1308
-
1309
- // src/Separator.tsx
1310
- import { forwardRef as forwardRef35 } from "react";
1311
- import { jsx as jsx35 } from "react/jsx-runtime";
1312
- var Separator = forwardRef35(function Separator2({ orientation = "horizontal", decorative, className, ...rest }, ref) {
1313
- return /* @__PURE__ */ jsx35(
1314
- "hr",
1315
- {
1316
- ...rest,
1317
- ref,
1318
- className: ["hl-separator", className].filter(Boolean).join(" "),
1319
- "data-hl-orientation": orientation === "vertical" ? "vertical" : void 0,
1320
- "aria-orientation": orientation,
1321
- role: decorative ? "presentation" : "separator"
1322
- }
1323
- );
1324
- });
1325
-
1326
- // src/Table.tsx
1327
- import { forwardRef as forwardRef36 } from "react";
1328
- import { jsx as jsx36 } from "react/jsx-runtime";
1329
- var Table = forwardRef36(function Table2({ striped, hover, align, size, className, children, ...rest }, ref) {
1330
- return /* @__PURE__ */ jsx36(
1331
- "table",
1332
- {
1333
- ...rest,
1334
- ref,
1335
- className: cx("hl-table", className),
1336
- "data-hl-striped": striped || void 0,
1337
- "data-hl-hover": hover || void 0,
1338
- "data-hl-align": align,
1339
- "data-hl-size": size,
1340
- children
1341
- }
1342
- );
1343
- });
1344
- export {
1345
- Accordion,
1346
- AccordionItem,
1347
- Alert,
1348
- Avatar,
1349
- AvatarGroup,
1350
- Badge,
1351
- Breadcrumb,
1352
- BreadcrumbItem,
1353
- Button,
1354
- Card,
1355
- CardBody,
1356
- CardDescription,
1357
- CardFooter,
1358
- CardHeader,
1359
- CardTitle,
1360
- Checkbox,
1361
- Combobox,
1362
- ComboboxInput,
1363
- ComboboxList,
1364
- ComboboxOption,
1365
- Command,
1366
- CommandEmpty,
1367
- CommandGroup,
1368
- CommandInput,
1369
- CommandItem,
1370
- CommandList,
1371
- Disclosure,
1372
- Drawer,
1373
- DrawerBody,
1374
- DrawerFooter,
1375
- DrawerHeader,
1376
- Dropdown,
1377
- DropdownGroup,
1378
- DropdownItem,
1379
- DropdownMenu,
1380
- DropdownSeparator,
1381
- DropdownTrigger,
1382
- Field,
1383
- FieldError,
1384
- FieldHelp,
1385
- FieldLabel,
1386
- Fieldset,
1387
- Input,
1388
- Kbd,
1389
- Menu,
1390
- MenuItem,
1391
- MenuSubmenu,
1392
- Modal,
1393
- ModalBody,
1394
- ModalFooter,
1395
- ModalHeader,
1396
- Pagination,
1397
- Popover,
1398
- Progress,
1399
- Radio,
1400
- RadioGroup,
1401
- SegmentedControl,
1402
- Select,
1403
- Separator,
1404
- Skeleton,
1405
- SkipLink,
1406
- Slider,
1407
- Spinner,
1408
- Switch,
1409
- Tab,
1410
- TabList,
1411
- TabPanel,
1412
- Table,
1413
- Tabs,
1414
- Textarea,
1415
- ToastRegion,
1416
- Toc,
1417
- Tooltip,
1418
- cx,
1419
- useEnhancer,
1420
- useField,
1421
- useToast
1422
- };
1
+ export * from './server.js';
2
+ export * from './client.js';