@hydrateless/react 0.3.0 → 0.4.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.d.ts +283 -2
- package/dist/index.js +720 -0
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { DependencyList, RefObject, HTMLAttributes, ReactNode, ReactElement, InputHTMLAttributes, AnchorHTMLAttributes } from 'react';
|
|
2
|
+
import { DependencyList, RefObject, HTMLAttributes, ReactNode, ReactElement, InputHTMLAttributes, AnchorHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, LabelHTMLAttributes, ButtonHTMLAttributes, ProgressHTMLAttributes } from 'react';
|
|
3
3
|
import { Disposer, EnhanceTocOptions, ToastApi } from '@hydrateless/enhancers';
|
|
4
4
|
export { Disposer } from '@hydrateless/enhancers';
|
|
5
5
|
|
|
@@ -180,4 +180,285 @@ declare function ToastProvider({ children }: ToastProviderProps): react.JSX.Elem
|
|
|
180
180
|
/** Access the toast API. Must be called within a {@link ToastProvider}. */
|
|
181
181
|
declare function useToast(): ToastApi;
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
interface MenuItemDef {
|
|
184
|
+
label: ReactNode;
|
|
185
|
+
href?: string;
|
|
186
|
+
onSelect?: () => void;
|
|
187
|
+
disabled?: boolean;
|
|
188
|
+
items?: MenuItemDef[];
|
|
189
|
+
}
|
|
190
|
+
interface MenuProps extends HTMLAttributes<HTMLUListElement> {
|
|
191
|
+
items: MenuItemDef[];
|
|
192
|
+
orientation?: 'horizontal' | 'vertical';
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Menubar / navigation menu. The enhancer wires roving tabindex, arrow
|
|
196
|
+
* navigation, and single-level submenu toggling per the WAI-ARIA menubar
|
|
197
|
+
* pattern.
|
|
198
|
+
*/
|
|
199
|
+
declare function Menu({ items, orientation, ...rest }: MenuProps): react.JSX.Element;
|
|
200
|
+
|
|
201
|
+
interface ComboboxOption {
|
|
202
|
+
value: string;
|
|
203
|
+
label?: ReactNode;
|
|
204
|
+
}
|
|
205
|
+
interface ComboboxProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
206
|
+
options: ComboboxOption[];
|
|
207
|
+
defaultValue?: string;
|
|
208
|
+
placeholder?: string;
|
|
209
|
+
onValueChange?: (value: string) => void;
|
|
210
|
+
inputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, 'role'>;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Editable combobox (input + listbox). The enhancer adds filtering,
|
|
214
|
+
* `aria-activedescendant` navigation, and selection; `onValueChange` fires when
|
|
215
|
+
* an option is committed.
|
|
216
|
+
*/
|
|
217
|
+
declare function Combobox({ options, defaultValue, placeholder, onValueChange, inputProps, ...rest }: ComboboxProps): react.JSX.Element;
|
|
218
|
+
|
|
219
|
+
interface CommandItemDef {
|
|
220
|
+
value: string;
|
|
221
|
+
label: ReactNode;
|
|
222
|
+
keywords?: string;
|
|
223
|
+
group?: string;
|
|
224
|
+
icon?: ReactNode;
|
|
225
|
+
href?: string;
|
|
226
|
+
onSelect?: () => void;
|
|
227
|
+
}
|
|
228
|
+
interface CommandProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {
|
|
229
|
+
items: CommandItemDef[];
|
|
230
|
+
placeholder?: string;
|
|
231
|
+
emptyLabel?: ReactNode;
|
|
232
|
+
/** Lowercased key that opens the palette's dialog with Cmd/Ctrl. */
|
|
233
|
+
hotkey?: string;
|
|
234
|
+
onSelect?: (value: string) => void;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Command palette. The enhancer filters items (text + keywords), provides arrow
|
|
238
|
+
* navigation and an empty state, and runs the active item on Enter; `onSelect`
|
|
239
|
+
* receives the chosen item's value. Place inside a `<dialog>` to use `hotkey`.
|
|
240
|
+
*/
|
|
241
|
+
declare function Command({ items, placeholder, emptyLabel, hotkey, onSelect, ...rest }: CommandProps): react.JSX.Element;
|
|
242
|
+
|
|
243
|
+
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
|
244
|
+
size?: 'sm' | 'md' | 'lg';
|
|
245
|
+
invalid?: boolean;
|
|
246
|
+
}
|
|
247
|
+
/** Text input styled with the `hl-input` primitive. */
|
|
248
|
+
declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
|
|
249
|
+
|
|
250
|
+
interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
251
|
+
invalid?: boolean;
|
|
252
|
+
}
|
|
253
|
+
/** Multi-line text input styled with the `hl-textarea` primitive. */
|
|
254
|
+
declare const Textarea: react.ForwardRefExoticComponent<TextareaProps & react.RefAttributes<HTMLTextAreaElement>>;
|
|
255
|
+
|
|
256
|
+
interface SelectOption {
|
|
257
|
+
label: ReactNode;
|
|
258
|
+
value: string;
|
|
259
|
+
disabled?: boolean;
|
|
260
|
+
}
|
|
261
|
+
interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
|
|
262
|
+
size?: 'sm' | 'md' | 'lg';
|
|
263
|
+
invalid?: boolean;
|
|
264
|
+
/** Convenience for simple option lists; or pass `children` directly. */
|
|
265
|
+
options?: SelectOption[];
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Native `<select>` styled with the `hl-select` primitive, wrapped so a custom
|
|
269
|
+
* caret can be drawn purely in CSS. Native selects keep full mobile/keyboard
|
|
270
|
+
* behavior for free.
|
|
271
|
+
*/
|
|
272
|
+
declare const Select: react.ForwardRefExoticComponent<SelectProps & react.RefAttributes<HTMLSelectElement>>;
|
|
273
|
+
|
|
274
|
+
interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
275
|
+
children?: ReactNode;
|
|
276
|
+
}
|
|
277
|
+
/** Checkbox built on a native `<input type="checkbox">`, label-wrapped. */
|
|
278
|
+
declare const Checkbox: react.ForwardRefExoticComponent<CheckboxProps & react.RefAttributes<HTMLInputElement>>;
|
|
279
|
+
|
|
280
|
+
interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
281
|
+
children?: ReactNode;
|
|
282
|
+
value: string;
|
|
283
|
+
}
|
|
284
|
+
/** A single radio built on a native `<input type="radio">`, label-wrapped. */
|
|
285
|
+
declare const Radio: react.ForwardRefExoticComponent<RadioProps & react.RefAttributes<HTMLInputElement>>;
|
|
286
|
+
interface RadioGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
287
|
+
name?: string;
|
|
288
|
+
value?: string;
|
|
289
|
+
onValueChange?: (value: string) => void;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Groups radios under a `role="radiogroup"`, sharing a name and managing the
|
|
293
|
+
* selected value. Pass `<Radio value="…">` children.
|
|
294
|
+
*/
|
|
295
|
+
declare function RadioGroup({ name, value, onValueChange, className, children, ...rest }: RadioGroupProps): react.JSX.Element;
|
|
296
|
+
|
|
297
|
+
interface FieldProps extends HTMLAttributes<HTMLDivElement> {
|
|
298
|
+
id?: string;
|
|
299
|
+
invalid?: boolean;
|
|
300
|
+
required?: boolean;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Layout + accessibility wrapper for a form control. Provides a shared id so
|
|
304
|
+
* `<Label>`, `<Help>`, and `<Error>` wire up `htmlFor`/`aria-describedby`
|
|
305
|
+
* automatically; spread {@link useField}'s result onto your control.
|
|
306
|
+
*/
|
|
307
|
+
declare function Field({ id, invalid, required, className, children, ...rest }: FieldProps): react.JSX.Element;
|
|
308
|
+
/**
|
|
309
|
+
* Props to spread onto the field's control (`id`, `aria-describedby`,
|
|
310
|
+
* `aria-invalid`). Must be called within a {@link Field}.
|
|
311
|
+
*/
|
|
312
|
+
declare function useField(): {
|
|
313
|
+
id: string;
|
|
314
|
+
'aria-describedby': string | undefined;
|
|
315
|
+
'aria-invalid': true | undefined;
|
|
316
|
+
};
|
|
317
|
+
type LabelProps = LabelHTMLAttributes<HTMLLabelElement>;
|
|
318
|
+
/** Label bound to the enclosing field's control via `htmlFor`. */
|
|
319
|
+
declare function Label({ className, children, ...rest }: LabelProps): react.JSX.Element;
|
|
320
|
+
/** Supplementary help text, referenced by the control's `aria-describedby`. */
|
|
321
|
+
declare function Help({ className, children, ...rest }: HTMLAttributes<HTMLParagraphElement>): react.JSX.Element;
|
|
322
|
+
/** Validation message; renders nothing unless given content. */
|
|
323
|
+
declare function FieldError({ className, children, ...rest }: HTMLAttributes<HTMLParagraphElement>): react.JSX.Element | null;
|
|
324
|
+
interface FieldsetProps extends HTMLAttributes<HTMLFieldSetElement> {
|
|
325
|
+
legend?: ReactNode;
|
|
326
|
+
}
|
|
327
|
+
/** Grouped fields with an optional legend. */
|
|
328
|
+
declare function Fieldset({ legend, className, children, ...rest }: FieldsetProps): react.JSX.Element;
|
|
329
|
+
|
|
330
|
+
interface SegmentedOption {
|
|
331
|
+
label: ReactNode;
|
|
332
|
+
value: string;
|
|
333
|
+
disabled?: boolean;
|
|
334
|
+
}
|
|
335
|
+
interface SegmentedControlProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
336
|
+
options: SegmentedOption[];
|
|
337
|
+
value?: string;
|
|
338
|
+
defaultValue?: string;
|
|
339
|
+
onValueChange?: (value: string) => void;
|
|
340
|
+
name?: string;
|
|
341
|
+
size?: 'sm' | 'md' | 'lg';
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Segmented control — `hl-segmented` radiogroup. Controlled via `value` or
|
|
345
|
+
* uncontrolled via `defaultValue`. Built on native radios for free keyboard
|
|
346
|
+
* navigation.
|
|
347
|
+
*/
|
|
348
|
+
declare function SegmentedControl({ options, value, defaultValue, onValueChange, name, size, className, ...rest }: SegmentedControlProps): react.JSX.Element;
|
|
349
|
+
|
|
350
|
+
type SliderProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'>;
|
|
351
|
+
/** Range slider primitive — `<input type="range" class="hl-slider">`. */
|
|
352
|
+
declare const Slider: react.ForwardRefExoticComponent<SliderProps & react.RefAttributes<HTMLInputElement>>;
|
|
353
|
+
|
|
354
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
355
|
+
variant?: 'solid' | 'soft' | 'outline' | 'ghost' | 'link';
|
|
356
|
+
intent?: 'neutral' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
|
|
357
|
+
size?: 'sm' | 'md' | 'lg';
|
|
358
|
+
/** Stretch to the container width. */
|
|
359
|
+
block?: boolean;
|
|
360
|
+
/** Square, icon-only button. */
|
|
361
|
+
icon?: boolean;
|
|
362
|
+
/** Show a spinner and disable interaction. */
|
|
363
|
+
loading?: boolean;
|
|
364
|
+
}
|
|
365
|
+
/** Button primitive — `hl-button` with intent/variant/size modifiers. */
|
|
366
|
+
declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
367
|
+
|
|
368
|
+
interface AlertProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
369
|
+
intent?: 'info' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
370
|
+
title?: ReactNode;
|
|
371
|
+
/** Leading icon, rendered before the body. */
|
|
372
|
+
icon?: ReactNode;
|
|
373
|
+
}
|
|
374
|
+
/** Alert primitive — `hl-alert` with intent, optional icon + title. */
|
|
375
|
+
declare const Alert: react.ForwardRefExoticComponent<AlertProps & react.RefAttributes<HTMLDivElement>>;
|
|
376
|
+
|
|
377
|
+
interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
378
|
+
intent?: 'neutral' | 'primary' | 'danger' | 'success' | 'warning' | 'info';
|
|
379
|
+
variant?: 'soft' | 'solid' | 'outline';
|
|
380
|
+
size?: 'sm' | 'md';
|
|
381
|
+
}
|
|
382
|
+
/** Badge primitive — `hl-badge` with intent/variant/size modifiers. */
|
|
383
|
+
declare const Badge: react.ForwardRefExoticComponent<BadgeProps & react.RefAttributes<HTMLSpanElement>>;
|
|
384
|
+
|
|
385
|
+
interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
386
|
+
/** Hover/active elevation for clickable cards. */
|
|
387
|
+
interactive?: boolean;
|
|
388
|
+
}
|
|
389
|
+
/** Card container — `hl-card`. Compose with the Card.* parts. */
|
|
390
|
+
declare const Card: react.ForwardRefExoticComponent<CardProps & react.RefAttributes<HTMLDivElement>>;
|
|
391
|
+
type CardSectionProps = HTMLAttributes<HTMLDivElement>;
|
|
392
|
+
declare const CardHeader: react.ForwardRefExoticComponent<CardSectionProps & react.RefAttributes<HTMLDivElement>>;
|
|
393
|
+
declare const CardBody: react.ForwardRefExoticComponent<CardSectionProps & react.RefAttributes<HTMLDivElement>>;
|
|
394
|
+
declare const CardFooter: react.ForwardRefExoticComponent<CardSectionProps & react.RefAttributes<HTMLDivElement>>;
|
|
395
|
+
declare const CardTitle: react.ForwardRefExoticComponent<HTMLAttributes<HTMLHeadingElement> & react.RefAttributes<HTMLHeadingElement>>;
|
|
396
|
+
declare const CardDescription: react.ForwardRefExoticComponent<HTMLAttributes<HTMLParagraphElement> & react.RefAttributes<HTMLParagraphElement>>;
|
|
397
|
+
|
|
398
|
+
interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
|
|
399
|
+
src?: string;
|
|
400
|
+
alt?: string;
|
|
401
|
+
/** Shown when there is no `src` or the image fails to load. */
|
|
402
|
+
fallback?: ReactNode;
|
|
403
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
404
|
+
shape?: 'circle' | 'square';
|
|
405
|
+
}
|
|
406
|
+
/** Avatar primitive — `hl-avatar` with image + graceful fallback. */
|
|
407
|
+
declare const Avatar: react.ForwardRefExoticComponent<AvatarProps & react.RefAttributes<HTMLSpanElement>>;
|
|
408
|
+
type AvatarGroupProps = HTMLAttributes<HTMLDivElement>;
|
|
409
|
+
/** Overlapping stack of avatars. */
|
|
410
|
+
declare const AvatarGroup: react.ForwardRefExoticComponent<AvatarGroupProps & react.RefAttributes<HTMLDivElement>>;
|
|
411
|
+
|
|
412
|
+
interface ProgressProps extends Omit<ProgressHTMLAttributes<HTMLProgressElement>, 'value'> {
|
|
413
|
+
/** Omit for an indeterminate bar. */
|
|
414
|
+
value?: number;
|
|
415
|
+
max?: number;
|
|
416
|
+
intent?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
|
417
|
+
size?: 'sm' | 'md' | 'lg';
|
|
418
|
+
}
|
|
419
|
+
/** Progress primitive — native `<progress class="hl-progress">`. */
|
|
420
|
+
declare const Progress: react.ForwardRefExoticComponent<ProgressProps & react.RefAttributes<HTMLProgressElement>>;
|
|
421
|
+
|
|
422
|
+
interface SpinnerProps extends HTMLAttributes<HTMLSpanElement> {
|
|
423
|
+
size?: 'sm' | 'md' | 'lg' | 'xl';
|
|
424
|
+
/** Accessible label; announced via `role="status"`. */
|
|
425
|
+
label?: string;
|
|
426
|
+
}
|
|
427
|
+
/** Spinner primitive — `hl-spinner`. Inherits `currentColor`. */
|
|
428
|
+
declare const Spinner: react.ForwardRefExoticComponent<SpinnerProps & react.RefAttributes<HTMLSpanElement>>;
|
|
429
|
+
|
|
430
|
+
interface SkeletonProps extends HTMLAttributes<HTMLSpanElement> {
|
|
431
|
+
variant?: 'rect' | 'text' | 'circle';
|
|
432
|
+
width?: string | number;
|
|
433
|
+
height?: string | number;
|
|
434
|
+
}
|
|
435
|
+
/** Skeleton placeholder primitive — `hl-skeleton`. */
|
|
436
|
+
declare const Skeleton: react.ForwardRefExoticComponent<SkeletonProps & react.RefAttributes<HTMLSpanElement>>;
|
|
437
|
+
|
|
438
|
+
interface PaginationProps extends Omit<HTMLAttributes<HTMLElement>, 'onChange'> {
|
|
439
|
+
page: number;
|
|
440
|
+
count: number;
|
|
441
|
+
onPageChange?: (page: number) => void;
|
|
442
|
+
/** Pages to show on each side of the current page. Defaults to 1. */
|
|
443
|
+
siblingCount?: number;
|
|
444
|
+
/** Render Previous/Next controls. Defaults to true. */
|
|
445
|
+
showControls?: boolean;
|
|
446
|
+
prevLabel?: ReactNode;
|
|
447
|
+
nextLabel?: ReactNode;
|
|
448
|
+
}
|
|
449
|
+
/** Pagination primitive — `hl-pagination` with smart ellipsis truncation. */
|
|
450
|
+
declare function Pagination({ page, count, onPageChange, siblingCount, showControls, prevLabel, nextLabel, className, ...rest }: PaginationProps): react.JSX.Element;
|
|
451
|
+
|
|
452
|
+
type KbdProps = HTMLAttributes<HTMLElement>;
|
|
453
|
+
/** Keyboard key primitive — `<kbd class="hl-kbd">`. */
|
|
454
|
+
declare const Kbd: react.ForwardRefExoticComponent<KbdProps & react.RefAttributes<HTMLElement>>;
|
|
455
|
+
|
|
456
|
+
interface SeparatorProps extends HTMLAttributes<HTMLHRElement> {
|
|
457
|
+
orientation?: 'horizontal' | 'vertical';
|
|
458
|
+
/** Purely decorative — removes it from the accessibility tree. */
|
|
459
|
+
decorative?: boolean;
|
|
460
|
+
}
|
|
461
|
+
/** Separator primitive — `<hr class="hl-separator">`. */
|
|
462
|
+
declare const Separator: react.ForwardRefExoticComponent<SeparatorProps & react.RefAttributes<HTMLHRElement>>;
|
|
463
|
+
|
|
464
|
+
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, Alert, type AlertProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, Badge, type BadgeProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, CardBody, CardDescription, CardFooter, CardHeader, type CardProps, type CardSectionProps, CardTitle, Checkbox, type CheckboxProps, Combobox, type ComboboxOption, type ComboboxProps, Command, type CommandItemDef, type CommandProps, Disclosure, type DisclosureProps, Drawer, type DrawerProps, Dropdown, type DropdownItem, type DropdownProps, Field, FieldError, type FieldProps, Fieldset, type FieldsetProps, Help, Input, type InputProps, Kbd, type KbdProps, Label, type LabelProps, Menu, type MenuItemDef, type MenuProps, Modal, type ModalProps, Pagination, type PaginationProps, Popover, type PopoverProps, Progress, type ProgressProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, Select, type SelectOption, type SelectProps, Separator, type SeparatorProps, Skeleton, type SkeletonProps, SkipLink, type SkipLinkProps, Slider, type SliderProps, Spinner, type SpinnerProps, Switch, type SwitchProps, type TabItem, Tabs, type TabsProps, Textarea, type TextareaProps, ToastProvider, type ToastProviderProps, Toc, type TocProps, Tooltip, type TooltipProps, useAccordion, useDisclosureGroup, useDropdown, useEnhancer, useField, useModalGroup, useTabs, useToast, useTocEnhancer, useTooltip };
|
package/dist/index.js
CHANGED
|
@@ -313,18 +313,737 @@ function useToast() {
|
|
|
313
313
|
}
|
|
314
314
|
return ctx;
|
|
315
315
|
}
|
|
316
|
+
|
|
317
|
+
// src/Menu.tsx
|
|
318
|
+
import { useEffect as useEffect11, useRef as useRef11 } from "react";
|
|
319
|
+
import { enhanceMenu } from "@hydrateless/enhancers";
|
|
320
|
+
import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
321
|
+
function renderItems(items) {
|
|
322
|
+
return items.map((item, i) => /* @__PURE__ */ jsxs10("li", { role: "none", children: [
|
|
323
|
+
item.href && !item.items ? /* @__PURE__ */ jsx14("a", { role: "menuitem", href: item.href, children: item.label }) : /* @__PURE__ */ jsx14("button", { type: "button", role: "menuitem", onClick: item.onSelect, disabled: item.disabled, children: item.label }),
|
|
324
|
+
item.items && /* @__PURE__ */ jsx14("ul", { role: "menu", "data-hl-menu-submenu": true, hidden: true, children: renderItems(item.items) })
|
|
325
|
+
] }, i));
|
|
326
|
+
}
|
|
327
|
+
function Menu({ items, orientation = "horizontal", ...rest }) {
|
|
328
|
+
const ref = useRef11(null);
|
|
329
|
+
useEffect11(() => {
|
|
330
|
+
if (!ref.current) return;
|
|
331
|
+
return enhanceMenu(ref.current, { orientation });
|
|
332
|
+
}, [items, orientation]);
|
|
333
|
+
return /* @__PURE__ */ jsx14(
|
|
334
|
+
"ul",
|
|
335
|
+
{
|
|
336
|
+
...rest,
|
|
337
|
+
ref,
|
|
338
|
+
"data-hl-menu": true,
|
|
339
|
+
role: orientation === "vertical" ? "menu" : "menubar",
|
|
340
|
+
"aria-orientation": orientation,
|
|
341
|
+
children: renderItems(items)
|
|
342
|
+
}
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/Combobox.tsx
|
|
347
|
+
import {
|
|
348
|
+
useEffect as useEffect12,
|
|
349
|
+
useRef as useRef12
|
|
350
|
+
} from "react";
|
|
351
|
+
import { enhanceCombobox } from "@hydrateless/enhancers";
|
|
352
|
+
import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
353
|
+
function Combobox({
|
|
354
|
+
options,
|
|
355
|
+
defaultValue,
|
|
356
|
+
placeholder,
|
|
357
|
+
onValueChange,
|
|
358
|
+
inputProps,
|
|
359
|
+
...rest
|
|
360
|
+
}) {
|
|
361
|
+
const ref = useRef12(null);
|
|
362
|
+
const onChangeRef = useRef12(onValueChange);
|
|
363
|
+
onChangeRef.current = onValueChange;
|
|
364
|
+
useEffect12(() => {
|
|
365
|
+
const el = ref.current;
|
|
366
|
+
if (!el) return;
|
|
367
|
+
const dispose = enhanceCombobox(el);
|
|
368
|
+
const handler = (e) => onChangeRef.current?.(e.detail.value);
|
|
369
|
+
el.addEventListener("hl:select", handler);
|
|
370
|
+
return () => {
|
|
371
|
+
el.removeEventListener("hl:select", handler);
|
|
372
|
+
dispose();
|
|
373
|
+
};
|
|
374
|
+
}, [options.length]);
|
|
375
|
+
return /* @__PURE__ */ jsxs11("div", { ...rest, ref, "data-hl-combobox": true, children: [
|
|
376
|
+
/* @__PURE__ */ jsx15(
|
|
377
|
+
"input",
|
|
378
|
+
{
|
|
379
|
+
...inputProps,
|
|
380
|
+
className: ["hl-input", inputProps?.className].filter(Boolean).join(" "),
|
|
381
|
+
placeholder,
|
|
382
|
+
defaultValue
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
/* @__PURE__ */ jsx15("ul", { role: "listbox", hidden: true, children: options.map((option) => /* @__PURE__ */ jsx15("li", { role: "option", "data-hl-value": option.value, children: option.label ?? option.value }, option.value)) })
|
|
386
|
+
] });
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// src/Command.tsx
|
|
390
|
+
import { useEffect as useEffect13, useRef as useRef13 } from "react";
|
|
391
|
+
import { enhanceCommand } from "@hydrateless/enhancers";
|
|
392
|
+
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
393
|
+
function groupItems(items) {
|
|
394
|
+
const groups = /* @__PURE__ */ new Map();
|
|
395
|
+
for (const item of items) {
|
|
396
|
+
const key = item.group ?? "";
|
|
397
|
+
const bucket = groups.get(key) ?? [];
|
|
398
|
+
bucket.push(item);
|
|
399
|
+
groups.set(key, bucket);
|
|
400
|
+
}
|
|
401
|
+
return [...groups.entries()];
|
|
402
|
+
}
|
|
403
|
+
function Command({
|
|
404
|
+
items,
|
|
405
|
+
placeholder = "Type a command\u2026",
|
|
406
|
+
emptyLabel = "No results found.",
|
|
407
|
+
hotkey,
|
|
408
|
+
onSelect,
|
|
409
|
+
...rest
|
|
410
|
+
}) {
|
|
411
|
+
const ref = useRef13(null);
|
|
412
|
+
const onSelectRef = useRef13(onSelect);
|
|
413
|
+
onSelectRef.current = onSelect;
|
|
414
|
+
useEffect13(() => {
|
|
415
|
+
const el = ref.current;
|
|
416
|
+
if (!el) return;
|
|
417
|
+
const dispose = enhanceCommand(el);
|
|
418
|
+
const handler = (e) => {
|
|
419
|
+
const { value, item } = e.detail;
|
|
420
|
+
const def = items.find((entry) => entry.value === (item.dataset.hlValue ?? value));
|
|
421
|
+
def?.onSelect?.();
|
|
422
|
+
onSelectRef.current?.(def?.value ?? value);
|
|
423
|
+
};
|
|
424
|
+
el.addEventListener("hl:command", handler);
|
|
425
|
+
return () => {
|
|
426
|
+
el.removeEventListener("hl:command", handler);
|
|
427
|
+
dispose();
|
|
428
|
+
};
|
|
429
|
+
}, [items]);
|
|
430
|
+
return /* @__PURE__ */ jsxs12("div", { ...rest, ref, "data-hl-command": true, "data-hl-command-hotkey": hotkey, children: [
|
|
431
|
+
/* @__PURE__ */ jsx16("input", { className: "hl-input", "data-hl-command-input": true, placeholder }),
|
|
432
|
+
/* @__PURE__ */ jsx16("div", { "data-hl-command-empty": true, hidden: true, children: emptyLabel }),
|
|
433
|
+
/* @__PURE__ */ jsx16("div", { "data-hl-command-list": true, role: "listbox", children: groupItems(items).map(([group, groupEntries]) => /* @__PURE__ */ jsxs12("div", { "data-hl-command-group": true, children: [
|
|
434
|
+
group && /* @__PURE__ */ jsx16("div", { className: "hl-command-group-label", role: "presentation", children: group }),
|
|
435
|
+
groupEntries.map((item) => /* @__PURE__ */ jsxs12(
|
|
436
|
+
"div",
|
|
437
|
+
{
|
|
438
|
+
role: "option",
|
|
439
|
+
"data-hl-value": item.value,
|
|
440
|
+
"data-hl-keywords": item.keywords,
|
|
441
|
+
children: [
|
|
442
|
+
item.icon,
|
|
443
|
+
/* @__PURE__ */ jsx16("span", { children: item.label })
|
|
444
|
+
]
|
|
445
|
+
},
|
|
446
|
+
item.value
|
|
447
|
+
))
|
|
448
|
+
] }, group || "_")) })
|
|
449
|
+
] });
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// src/Input.tsx
|
|
453
|
+
import { forwardRef } from "react";
|
|
454
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
455
|
+
var Input = forwardRef(function Input2({ size, invalid, className, ...rest }, ref) {
|
|
456
|
+
return /* @__PURE__ */ jsx17(
|
|
457
|
+
"input",
|
|
458
|
+
{
|
|
459
|
+
...rest,
|
|
460
|
+
ref,
|
|
461
|
+
className: ["hl-input", className].filter(Boolean).join(" "),
|
|
462
|
+
"data-hl-size": size,
|
|
463
|
+
"data-hl-invalid": invalid || void 0,
|
|
464
|
+
"aria-invalid": invalid || rest["aria-invalid"]
|
|
465
|
+
}
|
|
466
|
+
);
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
// src/Textarea.tsx
|
|
470
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
471
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
472
|
+
var Textarea = forwardRef2(function Textarea2({ invalid, className, ...rest }, ref) {
|
|
473
|
+
return /* @__PURE__ */ jsx18(
|
|
474
|
+
"textarea",
|
|
475
|
+
{
|
|
476
|
+
...rest,
|
|
477
|
+
ref,
|
|
478
|
+
className: ["hl-textarea", className].filter(Boolean).join(" "),
|
|
479
|
+
"data-hl-invalid": invalid || void 0,
|
|
480
|
+
"aria-invalid": invalid || rest["aria-invalid"]
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
// src/Select.tsx
|
|
486
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
487
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
488
|
+
var Select = forwardRef3(function Select2({ size, invalid, options, className, children, ...rest }, ref) {
|
|
489
|
+
return /* @__PURE__ */ jsx19("span", { className: "hl-select-wrapper", children: /* @__PURE__ */ jsx19(
|
|
490
|
+
"select",
|
|
491
|
+
{
|
|
492
|
+
...rest,
|
|
493
|
+
ref,
|
|
494
|
+
className: ["hl-select", className].filter(Boolean).join(" "),
|
|
495
|
+
"data-hl-size": size,
|
|
496
|
+
"data-hl-invalid": invalid || void 0,
|
|
497
|
+
"aria-invalid": invalid || rest["aria-invalid"],
|
|
498
|
+
children: options ? options.map((option) => /* @__PURE__ */ jsx19("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value)) : children
|
|
499
|
+
}
|
|
500
|
+
) });
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
// src/Checkbox.tsx
|
|
504
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
505
|
+
import { jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
506
|
+
var Checkbox = forwardRef4(function Checkbox2({ children, className, ...rest }, ref) {
|
|
507
|
+
return /* @__PURE__ */ jsxs13("label", { className: ["hl-checkbox", className].filter(Boolean).join(" "), children: [
|
|
508
|
+
/* @__PURE__ */ jsx20("input", { ...rest, ref, type: "checkbox" }),
|
|
509
|
+
children != null && /* @__PURE__ */ jsx20("span", { children })
|
|
510
|
+
] });
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// src/Radio.tsx
|
|
514
|
+
import {
|
|
515
|
+
createContext as createContext2,
|
|
516
|
+
forwardRef as forwardRef5,
|
|
517
|
+
useContext as useContext2
|
|
518
|
+
} from "react";
|
|
519
|
+
import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
520
|
+
var RadioGroupContext = createContext2(null);
|
|
521
|
+
var Radio = forwardRef5(function Radio2({ children, className, value, ...rest }, ref) {
|
|
522
|
+
const group = useContext2(RadioGroupContext);
|
|
523
|
+
const checked = group ? group.value === value : rest.checked;
|
|
524
|
+
return /* @__PURE__ */ jsxs14("label", { className: ["hl-radio", className].filter(Boolean).join(" "), children: [
|
|
525
|
+
/* @__PURE__ */ jsx21(
|
|
526
|
+
"input",
|
|
527
|
+
{
|
|
528
|
+
...rest,
|
|
529
|
+
ref,
|
|
530
|
+
type: "radio",
|
|
531
|
+
name: rest.name ?? group?.name,
|
|
532
|
+
value,
|
|
533
|
+
checked,
|
|
534
|
+
onChange: (e) => {
|
|
535
|
+
group?.onValueChange?.(value);
|
|
536
|
+
rest.onChange?.(e);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
),
|
|
540
|
+
children != null && /* @__PURE__ */ jsx21("span", { children })
|
|
541
|
+
] });
|
|
542
|
+
});
|
|
543
|
+
function RadioGroup({
|
|
544
|
+
name,
|
|
545
|
+
value,
|
|
546
|
+
onValueChange,
|
|
547
|
+
className,
|
|
548
|
+
children,
|
|
549
|
+
...rest
|
|
550
|
+
}) {
|
|
551
|
+
return /* @__PURE__ */ jsx21(RadioGroupContext.Provider, { value: { name, value, onValueChange }, children: /* @__PURE__ */ jsx21(
|
|
552
|
+
"div",
|
|
553
|
+
{
|
|
554
|
+
...rest,
|
|
555
|
+
role: "radiogroup",
|
|
556
|
+
className: ["hl-radio-group", className].filter(Boolean).join(" "),
|
|
557
|
+
children
|
|
558
|
+
}
|
|
559
|
+
) });
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// src/Field.tsx
|
|
563
|
+
import {
|
|
564
|
+
createContext as createContext3,
|
|
565
|
+
useContext as useContext3,
|
|
566
|
+
useId as useId2
|
|
567
|
+
} from "react";
|
|
568
|
+
import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
569
|
+
var FieldContext = createContext3(null);
|
|
570
|
+
function Field({
|
|
571
|
+
id,
|
|
572
|
+
invalid = false,
|
|
573
|
+
required = false,
|
|
574
|
+
className,
|
|
575
|
+
children,
|
|
576
|
+
...rest
|
|
577
|
+
}) {
|
|
578
|
+
const generated = useId2().replace(/:/g, "");
|
|
579
|
+
const baseId = id ?? `hl-field-${generated}`;
|
|
580
|
+
const value = {
|
|
581
|
+
id: baseId,
|
|
582
|
+
helpId: `${baseId}-help`,
|
|
583
|
+
errorId: `${baseId}-error`,
|
|
584
|
+
invalid,
|
|
585
|
+
required,
|
|
586
|
+
hasHelp: true,
|
|
587
|
+
hasError: invalid
|
|
588
|
+
};
|
|
589
|
+
return /* @__PURE__ */ jsx22(FieldContext.Provider, { value, children: /* @__PURE__ */ jsx22(
|
|
590
|
+
"div",
|
|
591
|
+
{
|
|
592
|
+
...rest,
|
|
593
|
+
className: ["hl-field", className].filter(Boolean).join(" "),
|
|
594
|
+
"data-hl-invalid": invalid || void 0,
|
|
595
|
+
children
|
|
596
|
+
}
|
|
597
|
+
) });
|
|
598
|
+
}
|
|
599
|
+
function useFieldContext(component) {
|
|
600
|
+
const ctx = useContext3(FieldContext);
|
|
601
|
+
if (!ctx) throw new Error(`<${component}> must be used within a <Field>`);
|
|
602
|
+
return ctx;
|
|
603
|
+
}
|
|
604
|
+
function useField() {
|
|
605
|
+
const ctx = useFieldContext("useField");
|
|
606
|
+
const describedBy = [ctx.hasHelp ? ctx.helpId : null, ctx.invalid ? ctx.errorId : null].filter(Boolean).join(" ");
|
|
607
|
+
return {
|
|
608
|
+
id: ctx.id,
|
|
609
|
+
"aria-describedby": describedBy || void 0,
|
|
610
|
+
"aria-invalid": ctx.invalid || void 0
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function Label({ className, children, ...rest }) {
|
|
614
|
+
const ctx = useFieldContext("Label");
|
|
615
|
+
return /* @__PURE__ */ jsx22(
|
|
616
|
+
"label",
|
|
617
|
+
{
|
|
618
|
+
...rest,
|
|
619
|
+
htmlFor: rest.htmlFor ?? ctx.id,
|
|
620
|
+
className: ["hl-label", className].filter(Boolean).join(" "),
|
|
621
|
+
"data-hl-required": ctx.required || void 0,
|
|
622
|
+
children
|
|
623
|
+
}
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
function Help({ className, children, ...rest }) {
|
|
627
|
+
const ctx = useFieldContext("Help");
|
|
628
|
+
return /* @__PURE__ */ jsx22("p", { ...rest, id: ctx.helpId, className: ["hl-help", className].filter(Boolean).join(" "), children });
|
|
629
|
+
}
|
|
630
|
+
function FieldError({ className, children, ...rest }) {
|
|
631
|
+
const ctx = useFieldContext("FieldError");
|
|
632
|
+
if (children == null || children === false) return null;
|
|
633
|
+
return /* @__PURE__ */ jsx22(
|
|
634
|
+
"p",
|
|
635
|
+
{
|
|
636
|
+
...rest,
|
|
637
|
+
id: ctx.errorId,
|
|
638
|
+
role: "alert",
|
|
639
|
+
className: ["hl-error", className].filter(Boolean).join(" "),
|
|
640
|
+
children
|
|
641
|
+
}
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
function Fieldset({ legend, className, children, ...rest }) {
|
|
645
|
+
return /* @__PURE__ */ jsxs15("fieldset", { ...rest, className: ["hl-fieldset", className].filter(Boolean).join(" "), children: [
|
|
646
|
+
legend != null && /* @__PURE__ */ jsx22("legend", { className: "hl-legend", children: legend }),
|
|
647
|
+
children
|
|
648
|
+
] });
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// src/SegmentedControl.tsx
|
|
652
|
+
import { useId as useId3, useState } from "react";
|
|
653
|
+
import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
654
|
+
function SegmentedControl({
|
|
655
|
+
options,
|
|
656
|
+
value,
|
|
657
|
+
defaultValue,
|
|
658
|
+
onValueChange,
|
|
659
|
+
name,
|
|
660
|
+
size,
|
|
661
|
+
className,
|
|
662
|
+
...rest
|
|
663
|
+
}) {
|
|
664
|
+
const generatedName = useId3();
|
|
665
|
+
const groupName = name ?? generatedName;
|
|
666
|
+
const [internal, setInternal] = useState(defaultValue ?? options[0]?.value);
|
|
667
|
+
const current = value ?? internal;
|
|
668
|
+
const select = (next) => {
|
|
669
|
+
if (value === void 0) setInternal(next);
|
|
670
|
+
onValueChange?.(next);
|
|
671
|
+
};
|
|
672
|
+
return /* @__PURE__ */ jsx23(
|
|
673
|
+
"div",
|
|
674
|
+
{
|
|
675
|
+
...rest,
|
|
676
|
+
role: "radiogroup",
|
|
677
|
+
className: ["hl-segmented", className].filter(Boolean).join(" "),
|
|
678
|
+
"data-hl-size": size,
|
|
679
|
+
children: options.map((option) => /* @__PURE__ */ jsxs16("label", { className: "hl-segmented-item", children: [
|
|
680
|
+
/* @__PURE__ */ jsx23(
|
|
681
|
+
"input",
|
|
682
|
+
{
|
|
683
|
+
type: "radio",
|
|
684
|
+
name: groupName,
|
|
685
|
+
value: option.value,
|
|
686
|
+
checked: current === option.value,
|
|
687
|
+
disabled: option.disabled,
|
|
688
|
+
onChange: () => select(option.value)
|
|
689
|
+
}
|
|
690
|
+
),
|
|
691
|
+
/* @__PURE__ */ jsx23("span", { children: option.label })
|
|
692
|
+
] }, option.value))
|
|
693
|
+
}
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// src/Slider.tsx
|
|
698
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
699
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
700
|
+
var Slider = forwardRef6(function Slider2({ className, ...rest }, ref) {
|
|
701
|
+
return /* @__PURE__ */ jsx24(
|
|
702
|
+
"input",
|
|
703
|
+
{
|
|
704
|
+
...rest,
|
|
705
|
+
ref,
|
|
706
|
+
type: "range",
|
|
707
|
+
className: ["hl-slider", className].filter(Boolean).join(" ")
|
|
708
|
+
}
|
|
709
|
+
);
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
// src/Button.tsx
|
|
713
|
+
import { forwardRef as forwardRef7 } from "react";
|
|
714
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
715
|
+
var Button = forwardRef7(function Button2({ variant, intent, size, block, icon, loading, className, children, disabled, type, ...rest }, ref) {
|
|
716
|
+
return /* @__PURE__ */ jsx25(
|
|
717
|
+
"button",
|
|
718
|
+
{
|
|
719
|
+
...rest,
|
|
720
|
+
ref,
|
|
721
|
+
type: type ?? "button",
|
|
722
|
+
className: ["hl-button", className].filter(Boolean).join(" "),
|
|
723
|
+
"data-hl-variant": variant,
|
|
724
|
+
"data-hl-intent": intent,
|
|
725
|
+
"data-hl-size": size,
|
|
726
|
+
"data-hl-block": block || void 0,
|
|
727
|
+
"data-hl-icon": icon || void 0,
|
|
728
|
+
"data-hl-loading": loading || void 0,
|
|
729
|
+
"aria-busy": loading || void 0,
|
|
730
|
+
disabled: disabled || loading,
|
|
731
|
+
children
|
|
732
|
+
}
|
|
733
|
+
);
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
// src/Alert.tsx
|
|
737
|
+
import { forwardRef as forwardRef8 } from "react";
|
|
738
|
+
import { jsx as jsx26, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
739
|
+
var Alert = forwardRef8(function Alert2({ intent, title, icon, className, children, ...rest }, ref) {
|
|
740
|
+
return /* @__PURE__ */ jsxs17(
|
|
741
|
+
"div",
|
|
742
|
+
{
|
|
743
|
+
...rest,
|
|
744
|
+
ref,
|
|
745
|
+
role: rest.role ?? "alert",
|
|
746
|
+
className: ["hl-alert", className].filter(Boolean).join(" "),
|
|
747
|
+
"data-hl-intent": intent,
|
|
748
|
+
children: [
|
|
749
|
+
icon,
|
|
750
|
+
/* @__PURE__ */ jsxs17("div", { className: "hl-alert-body", children: [
|
|
751
|
+
title != null && /* @__PURE__ */ jsx26("p", { className: "hl-alert-title", children: title }),
|
|
752
|
+
children
|
|
753
|
+
] })
|
|
754
|
+
]
|
|
755
|
+
}
|
|
756
|
+
);
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
// src/Badge.tsx
|
|
760
|
+
import { forwardRef as forwardRef9 } from "react";
|
|
761
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
762
|
+
var Badge = forwardRef9(function Badge2({ intent, variant, size, className, children, ...rest }, ref) {
|
|
763
|
+
return /* @__PURE__ */ jsx27(
|
|
764
|
+
"span",
|
|
765
|
+
{
|
|
766
|
+
...rest,
|
|
767
|
+
ref,
|
|
768
|
+
className: ["hl-badge", className].filter(Boolean).join(" "),
|
|
769
|
+
"data-hl-intent": intent,
|
|
770
|
+
"data-hl-variant": variant,
|
|
771
|
+
"data-hl-size": size,
|
|
772
|
+
children
|
|
773
|
+
}
|
|
774
|
+
);
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
// src/Card.tsx
|
|
778
|
+
import { forwardRef as forwardRef10 } from "react";
|
|
779
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
780
|
+
var Card = forwardRef10(function Card2({ interactive, className, children, ...rest }, ref) {
|
|
781
|
+
return /* @__PURE__ */ jsx28(
|
|
782
|
+
"div",
|
|
783
|
+
{
|
|
784
|
+
...rest,
|
|
785
|
+
ref,
|
|
786
|
+
className: ["hl-card", className].filter(Boolean).join(" "),
|
|
787
|
+
"data-hl-interactive": interactive || void 0,
|
|
788
|
+
children
|
|
789
|
+
}
|
|
790
|
+
);
|
|
791
|
+
});
|
|
792
|
+
var CardHeader = forwardRef10(function CardHeader2({ className, ...rest }, ref) {
|
|
793
|
+
return /* @__PURE__ */ jsx28("div", { ...rest, ref, className: ["hl-card-header", className].filter(Boolean).join(" ") });
|
|
794
|
+
});
|
|
795
|
+
var CardBody = forwardRef10(function CardBody2({ className, ...rest }, ref) {
|
|
796
|
+
return /* @__PURE__ */ jsx28("div", { ...rest, ref, className: ["hl-card-body", className].filter(Boolean).join(" ") });
|
|
797
|
+
});
|
|
798
|
+
var CardFooter = forwardRef10(function CardFooter2({ className, ...rest }, ref) {
|
|
799
|
+
return /* @__PURE__ */ jsx28("div", { ...rest, ref, className: ["hl-card-footer", className].filter(Boolean).join(" ") });
|
|
800
|
+
});
|
|
801
|
+
var CardTitle = forwardRef10(
|
|
802
|
+
function CardTitle2({ className, ...rest }, ref) {
|
|
803
|
+
return /* @__PURE__ */ jsx28("h3", { ...rest, ref, className: ["hl-card-title", className].filter(Boolean).join(" ") });
|
|
804
|
+
}
|
|
805
|
+
);
|
|
806
|
+
var CardDescription = forwardRef10(function CardDescription2({ className, ...rest }, ref) {
|
|
807
|
+
return /* @__PURE__ */ jsx28(
|
|
808
|
+
"p",
|
|
809
|
+
{
|
|
810
|
+
...rest,
|
|
811
|
+
ref,
|
|
812
|
+
className: ["hl-card-description", className].filter(Boolean).join(" ")
|
|
813
|
+
}
|
|
814
|
+
);
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
// src/Avatar.tsx
|
|
818
|
+
import { forwardRef as forwardRef11, useState as useState2 } from "react";
|
|
819
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
820
|
+
var Avatar = forwardRef11(function Avatar2({ src, alt = "", fallback, size, shape, className, children, ...rest }, ref) {
|
|
821
|
+
const [failed, setFailed] = useState2(false);
|
|
822
|
+
const showImage = src && !failed;
|
|
823
|
+
return /* @__PURE__ */ jsx29(
|
|
824
|
+
"span",
|
|
825
|
+
{
|
|
826
|
+
...rest,
|
|
827
|
+
ref,
|
|
828
|
+
className: ["hl-avatar", className].filter(Boolean).join(" "),
|
|
829
|
+
"data-hl-size": size,
|
|
830
|
+
"data-hl-shape": shape === "square" ? "square" : void 0,
|
|
831
|
+
children: showImage ? /* @__PURE__ */ jsx29("img", { src, alt, onError: () => setFailed(true) }) : fallback ?? children
|
|
832
|
+
}
|
|
833
|
+
);
|
|
834
|
+
});
|
|
835
|
+
var AvatarGroup = forwardRef11(function AvatarGroup2({ className, children, ...rest }, ref) {
|
|
836
|
+
return /* @__PURE__ */ jsx29("div", { ...rest, ref, className: ["hl-avatar-group", className].filter(Boolean).join(" "), children });
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
// src/Progress.tsx
|
|
840
|
+
import { forwardRef as forwardRef12 } from "react";
|
|
841
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
842
|
+
var Progress = forwardRef12(function Progress2({ value, max = 100, intent, size, className, ...rest }, ref) {
|
|
843
|
+
return /* @__PURE__ */ jsx30(
|
|
844
|
+
"progress",
|
|
845
|
+
{
|
|
846
|
+
...rest,
|
|
847
|
+
ref,
|
|
848
|
+
className: ["hl-progress", className].filter(Boolean).join(" "),
|
|
849
|
+
"data-hl-intent": intent,
|
|
850
|
+
"data-hl-size": size,
|
|
851
|
+
value,
|
|
852
|
+
max
|
|
853
|
+
}
|
|
854
|
+
);
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
// src/Spinner.tsx
|
|
858
|
+
import { forwardRef as forwardRef13 } from "react";
|
|
859
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
860
|
+
var Spinner = forwardRef13(function Spinner2({ size, label = "Loading", className, ...rest }, ref) {
|
|
861
|
+
return /* @__PURE__ */ jsx31(
|
|
862
|
+
"span",
|
|
863
|
+
{
|
|
864
|
+
...rest,
|
|
865
|
+
ref,
|
|
866
|
+
className: ["hl-spinner", className].filter(Boolean).join(" "),
|
|
867
|
+
"data-hl-size": size,
|
|
868
|
+
role: "status",
|
|
869
|
+
"aria-label": label
|
|
870
|
+
}
|
|
871
|
+
);
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
// src/Skeleton.tsx
|
|
875
|
+
import { forwardRef as forwardRef14 } from "react";
|
|
876
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
877
|
+
var Skeleton = forwardRef14(function Skeleton2({ variant, width, height, className, style, ...rest }, ref) {
|
|
878
|
+
const sizeStyle = {
|
|
879
|
+
...width != null && { inlineSize: width },
|
|
880
|
+
...height != null && { blockSize: height },
|
|
881
|
+
...style
|
|
882
|
+
};
|
|
883
|
+
return /* @__PURE__ */ jsx32(
|
|
884
|
+
"span",
|
|
885
|
+
{
|
|
886
|
+
...rest,
|
|
887
|
+
ref,
|
|
888
|
+
className: ["hl-skeleton", className].filter(Boolean).join(" "),
|
|
889
|
+
"data-hl-variant": variant,
|
|
890
|
+
style: sizeStyle,
|
|
891
|
+
"aria-hidden": "true"
|
|
892
|
+
}
|
|
893
|
+
);
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
// src/Pagination.tsx
|
|
897
|
+
import { jsx as jsx33, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
898
|
+
var ELLIPSIS = "ellipsis";
|
|
899
|
+
function range(start, end) {
|
|
900
|
+
return Array.from({ length: end - start + 1 }, (_, i) => start + i);
|
|
901
|
+
}
|
|
902
|
+
function paginationRange(page, count, siblingCount) {
|
|
903
|
+
const totalNumbers = siblingCount * 2 + 5;
|
|
904
|
+
if (totalNumbers >= count) return range(1, count);
|
|
905
|
+
const leftSibling = Math.max(page - siblingCount, 1);
|
|
906
|
+
const rightSibling = Math.min(page + siblingCount, count);
|
|
907
|
+
const showLeftDots = leftSibling > 2;
|
|
908
|
+
const showRightDots = rightSibling < count - 1;
|
|
909
|
+
if (!showLeftDots && showRightDots) {
|
|
910
|
+
return [...range(1, siblingCount * 2 + 3), ELLIPSIS, count];
|
|
911
|
+
}
|
|
912
|
+
if (showLeftDots && !showRightDots) {
|
|
913
|
+
return [1, ELLIPSIS, ...range(count - (siblingCount * 2 + 2), count)];
|
|
914
|
+
}
|
|
915
|
+
return [1, ELLIPSIS, ...range(leftSibling, rightSibling), ELLIPSIS, count];
|
|
916
|
+
}
|
|
917
|
+
function Pagination({
|
|
918
|
+
page,
|
|
919
|
+
count,
|
|
920
|
+
onPageChange,
|
|
921
|
+
siblingCount = 1,
|
|
922
|
+
showControls = true,
|
|
923
|
+
prevLabel = "\u2039",
|
|
924
|
+
nextLabel = "\u203A",
|
|
925
|
+
className,
|
|
926
|
+
...rest
|
|
927
|
+
}) {
|
|
928
|
+
const items = paginationRange(page, count, siblingCount);
|
|
929
|
+
const go = (target) => {
|
|
930
|
+
if (target >= 1 && target <= count && target !== page) onPageChange?.(target);
|
|
931
|
+
};
|
|
932
|
+
return /* @__PURE__ */ jsx33(
|
|
933
|
+
"nav",
|
|
934
|
+
{
|
|
935
|
+
...rest,
|
|
936
|
+
className: ["hl-pagination", className].filter(Boolean).join(" "),
|
|
937
|
+
"aria-label": rest["aria-label"] ?? "Pagination",
|
|
938
|
+
children: /* @__PURE__ */ jsxs18("ul", { children: [
|
|
939
|
+
showControls && /* @__PURE__ */ jsx33("li", { children: /* @__PURE__ */ jsx33(
|
|
940
|
+
"button",
|
|
941
|
+
{
|
|
942
|
+
type: "button",
|
|
943
|
+
className: "hl-pagination-item",
|
|
944
|
+
"aria-label": "Previous page",
|
|
945
|
+
disabled: page <= 1,
|
|
946
|
+
onClick: () => go(page - 1),
|
|
947
|
+
children: prevLabel
|
|
948
|
+
}
|
|
949
|
+
) }),
|
|
950
|
+
items.map(
|
|
951
|
+
(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(
|
|
952
|
+
"button",
|
|
953
|
+
{
|
|
954
|
+
type: "button",
|
|
955
|
+
className: "hl-pagination-item",
|
|
956
|
+
"aria-current": item === page ? "page" : void 0,
|
|
957
|
+
"aria-label": `Page ${item}`,
|
|
958
|
+
onClick: () => go(item),
|
|
959
|
+
children: item
|
|
960
|
+
}
|
|
961
|
+
) }, item)
|
|
962
|
+
),
|
|
963
|
+
showControls && /* @__PURE__ */ jsx33("li", { children: /* @__PURE__ */ jsx33(
|
|
964
|
+
"button",
|
|
965
|
+
{
|
|
966
|
+
type: "button",
|
|
967
|
+
className: "hl-pagination-item",
|
|
968
|
+
"aria-label": "Next page",
|
|
969
|
+
disabled: page >= count,
|
|
970
|
+
onClick: () => go(page + 1),
|
|
971
|
+
children: nextLabel
|
|
972
|
+
}
|
|
973
|
+
) })
|
|
974
|
+
] })
|
|
975
|
+
}
|
|
976
|
+
);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// src/Kbd.tsx
|
|
980
|
+
import { forwardRef as forwardRef15 } from "react";
|
|
981
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
982
|
+
var Kbd = forwardRef15(function Kbd2({ className, children, ...rest }, ref) {
|
|
983
|
+
return /* @__PURE__ */ jsx34("kbd", { ...rest, ref, className: ["hl-kbd", className].filter(Boolean).join(" "), children });
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
// src/Separator.tsx
|
|
987
|
+
import { forwardRef as forwardRef16 } from "react";
|
|
988
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
989
|
+
var Separator = forwardRef16(function Separator2({ orientation = "horizontal", decorative, className, ...rest }, ref) {
|
|
990
|
+
return /* @__PURE__ */ jsx35(
|
|
991
|
+
"hr",
|
|
992
|
+
{
|
|
993
|
+
...rest,
|
|
994
|
+
ref,
|
|
995
|
+
className: ["hl-separator", className].filter(Boolean).join(" "),
|
|
996
|
+
"data-hl-orientation": orientation === "vertical" ? "vertical" : void 0,
|
|
997
|
+
"aria-orientation": orientation,
|
|
998
|
+
role: decorative ? "presentation" : "separator"
|
|
999
|
+
}
|
|
1000
|
+
);
|
|
1001
|
+
});
|
|
316
1002
|
export {
|
|
317
1003
|
Accordion,
|
|
318
1004
|
AccordionItem,
|
|
1005
|
+
Alert,
|
|
1006
|
+
Avatar,
|
|
1007
|
+
AvatarGroup,
|
|
1008
|
+
Badge,
|
|
319
1009
|
Breadcrumb,
|
|
1010
|
+
Button,
|
|
1011
|
+
Card,
|
|
1012
|
+
CardBody,
|
|
1013
|
+
CardDescription,
|
|
1014
|
+
CardFooter,
|
|
1015
|
+
CardHeader,
|
|
1016
|
+
CardTitle,
|
|
1017
|
+
Checkbox,
|
|
1018
|
+
Combobox,
|
|
1019
|
+
Command,
|
|
320
1020
|
Disclosure,
|
|
321
1021
|
Drawer,
|
|
322
1022
|
Dropdown,
|
|
1023
|
+
Field,
|
|
1024
|
+
FieldError,
|
|
1025
|
+
Fieldset,
|
|
1026
|
+
Help,
|
|
1027
|
+
Input,
|
|
1028
|
+
Kbd,
|
|
1029
|
+
Label,
|
|
1030
|
+
Menu,
|
|
323
1031
|
Modal,
|
|
1032
|
+
Pagination,
|
|
324
1033
|
Popover,
|
|
1034
|
+
Progress,
|
|
1035
|
+
Radio,
|
|
1036
|
+
RadioGroup,
|
|
1037
|
+
SegmentedControl,
|
|
1038
|
+
Select,
|
|
1039
|
+
Separator,
|
|
1040
|
+
Skeleton,
|
|
325
1041
|
SkipLink,
|
|
1042
|
+
Slider,
|
|
1043
|
+
Spinner,
|
|
326
1044
|
Switch,
|
|
327
1045
|
Tabs,
|
|
1046
|
+
Textarea,
|
|
328
1047
|
ToastProvider,
|
|
329
1048
|
Toc,
|
|
330
1049
|
Tooltip,
|
|
@@ -332,6 +1051,7 @@ export {
|
|
|
332
1051
|
useDisclosureGroup,
|
|
333
1052
|
useDropdown,
|
|
334
1053
|
useEnhancer,
|
|
1054
|
+
useField,
|
|
335
1055
|
useModalGroup,
|
|
336
1056
|
useTabs,
|
|
337
1057
|
useToast,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydrateless/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "React bindings for Hydrateless — hooks and components that wire the framework-agnostic enhancers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test": "vitest run"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@hydrateless/enhancers": "^0.
|
|
31
|
+
"@hydrateless/enhancers": "^0.4.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">=18"
|
|
@@ -38,10 +38,12 @@
|
|
|
38
38
|
"@testing-library/react": "^16.1.0",
|
|
39
39
|
"@types/react": "^19.0.0",
|
|
40
40
|
"@types/react-dom": "^19.0.0",
|
|
41
|
+
"axe-core": "^4.12.0",
|
|
41
42
|
"jsdom": "^29.0.0",
|
|
42
43
|
"react": "^19.0.0",
|
|
43
44
|
"react-dom": "^19.0.0",
|
|
44
|
-
"vitest": "^4.1.0"
|
|
45
|
+
"vitest": "^4.1.0",
|
|
46
|
+
"vitest-axe": "^0.1.0"
|
|
45
47
|
},
|
|
46
48
|
"publishConfig": {
|
|
47
49
|
"access": "public"
|