hazo_ui 6.1.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGE_LOG.md +64 -1
- package/dist/announce-DAnQDTld.d.cts +92 -0
- package/dist/announce-DAnQDTld.d.ts +92 -0
- package/dist/index.cjs +256 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +141 -3
- package/dist/index.d.ts +141 -3
- package/dist/index.js +249 -2
- package/dist/index.js.map +1 -1
- package/dist/index.utils.cjs +72 -0
- package/dist/index.utils.cjs.map +1 -1
- package/dist/index.utils.d.cts +31 -1
- package/dist/index.utils.d.ts +31 -1
- package/dist/index.utils.js +64 -1
- package/dist/index.utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/index.utils-DZVbQXFR.d.cts +0 -20
- package/dist/index.utils-DZVbQXFR.d.ts +0 -20
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { c as cn, s as safeHref } from './
|
|
1
|
+
export { A as AnnounceOptions, a as AnnouncePriority, D as DEFAULT_ANNOUNCE_EVENT, L as LiveAnnouncement, b as announce, c as cn, h as hasUrlParam, r as readRememberedState, s as safeHref, w as writeRememberedState } from './announce-DAnQDTld.cjs';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
|
-
import { ReactNode, RefObject } from 'react';
|
|
3
|
+
import { ReactNode, RefObject, PointerEvent, MouseEvent } from 'react';
|
|
4
4
|
import { ICommand } from '@uiw/react-md-editor';
|
|
5
5
|
export { ICommand as MarkdownEditorCommand } from '@uiw/react-md-editor';
|
|
6
6
|
import { Node, Extension } from '@tiptap/core';
|
|
@@ -2718,4 +2718,142 @@ interface AppFooterProps {
|
|
|
2718
2718
|
}
|
|
2719
2719
|
declare function AppFooter({ variant, footer, identity, className }: AppFooterProps): React$1.JSX.Element;
|
|
2720
2720
|
|
|
2721
|
-
|
|
2721
|
+
interface UseRememberedStateOptions<T> {
|
|
2722
|
+
/** Full localStorage key. Callers own their own namespacing/prefix. */
|
|
2723
|
+
key: string;
|
|
2724
|
+
/** Current serialisable state to remember. */
|
|
2725
|
+
snapshot: T;
|
|
2726
|
+
/** Feed a remembered snapshot back into the caller. Called at most once, on mount. */
|
|
2727
|
+
restore: (snapshot: T) => void;
|
|
2728
|
+
/** Default `true`; when `false` the hook is entirely inert (no read, no write). */
|
|
2729
|
+
enabled?: boolean;
|
|
2730
|
+
/** Debounce delay (ms) before a changed snapshot is written. Default `600`. */
|
|
2731
|
+
debounceMs?: number;
|
|
2732
|
+
/**
|
|
2733
|
+
* When set, restore-on-mount is skipped if this URL query param is present
|
|
2734
|
+
* in `window.location.search` — an explicit shared-link or saved-record
|
|
2735
|
+
* load should always win over remembered state. Omit to never skip.
|
|
2736
|
+
*/
|
|
2737
|
+
skipWhenUrlParam?: string;
|
|
2738
|
+
}
|
|
2739
|
+
/**
|
|
2740
|
+
* Remembers a snapshot of state in localStorage and restores it on mount.
|
|
2741
|
+
*
|
|
2742
|
+
* - Restore is attempted **once** per mount (a ref-based guard, independent
|
|
2743
|
+
* of prop/dependency changes — `restore`'s identity may change every
|
|
2744
|
+
* render without retriggering it).
|
|
2745
|
+
* - If `skipWhenUrlParam` is set and that query param is present in the
|
|
2746
|
+
* current URL, the restore-on-mount step is skipped entirely (an explicit
|
|
2747
|
+
* link/record load wins over remembered state).
|
|
2748
|
+
* - Writes are debounced by `debounceMs` and keyed off the snapshot's
|
|
2749
|
+
* serialised JSON (not object identity), so a structurally-equal-but-new
|
|
2750
|
+
* snapshot object doesn't reschedule a write.
|
|
2751
|
+
*
|
|
2752
|
+
* @example
|
|
2753
|
+
* useRememberedState({
|
|
2754
|
+
* key: `myapp:tool:${slug}`,
|
|
2755
|
+
* snapshot: currentSeed,
|
|
2756
|
+
* restore: (seed) => applySeed(seed),
|
|
2757
|
+
* skipWhenUrlParam: "restore",
|
|
2758
|
+
* });
|
|
2759
|
+
*/
|
|
2760
|
+
declare function useRememberedState<T>({ key, snapshot, restore, enabled, debounceMs, skipWhenUrlParam, }: UseRememberedStateOptions<T>): void;
|
|
2761
|
+
|
|
2762
|
+
interface UseLongPressOptions {
|
|
2763
|
+
onLongPress: (e: PointerEvent) => void;
|
|
2764
|
+
/** ms to hold before firing. Default 500. */
|
|
2765
|
+
delayMs?: number;
|
|
2766
|
+
/** Pixels of movement that cancel the press. Default 8. */
|
|
2767
|
+
moveThresholdPx?: number;
|
|
2768
|
+
/** Vibration ms on fire. Default 10. Set 0 to disable. */
|
|
2769
|
+
hapticMs?: number;
|
|
2770
|
+
}
|
|
2771
|
+
interface UseLongPressResult {
|
|
2772
|
+
onPointerDown: (e: PointerEvent) => void;
|
|
2773
|
+
onPointerMove: (e: PointerEvent) => void;
|
|
2774
|
+
onPointerUp: (e: PointerEvent) => void;
|
|
2775
|
+
onPointerCancel: (e: PointerEvent) => void;
|
|
2776
|
+
/** Spread onto the same element to suppress the trailing click that
|
|
2777
|
+
* fires after the long-press triggers. Without this, the touch that
|
|
2778
|
+
* ends the press also opens the hover card or detail panel — double
|
|
2779
|
+
* action. */
|
|
2780
|
+
onClick: (e: MouseEvent) => void;
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* Touch-only long-press hook. On fine-pointer devices (mouse), every
|
|
2784
|
+
* returned handler is a no-op — desktop relies on `onContextMenu` for
|
|
2785
|
+
* right-click instead. The returned event handlers should be spread onto
|
|
2786
|
+
* the target element via `<div {...longPress}>`.
|
|
2787
|
+
*
|
|
2788
|
+
* @param options.onLongPress - Fired once the press has been held for `delayMs`.
|
|
2789
|
+
* @param options.delayMs - ms to hold before firing. Default `500`.
|
|
2790
|
+
* @param options.moveThresholdPx - Pixels of movement that cancel the press. Default `8`.
|
|
2791
|
+
* @param options.hapticMs - Vibration ms on fire (`navigator.vibrate`). Default `10`; `0` disables.
|
|
2792
|
+
*
|
|
2793
|
+
* @example
|
|
2794
|
+
* const longPress = useLongPress({ onLongPress: (e) => openContextMenu(e) });
|
|
2795
|
+
* <div {...longPress}>Hold me</div>
|
|
2796
|
+
*/
|
|
2797
|
+
declare function useLongPress({ onLongPress, delayMs, moveThresholdPx, hapticMs, }: UseLongPressOptions): UseLongPressResult;
|
|
2798
|
+
|
|
2799
|
+
interface LiveRegionProps {
|
|
2800
|
+
/** Custom-event name to listen on. Must match the `eventName` passed to `announce()`. Default `DEFAULT_ANNOUNCE_EVENT`. */
|
|
2801
|
+
eventName?: string;
|
|
2802
|
+
/** className applied to both region `<div>`s. Default `"sr-only"` (Tailwind's screen-reader-only utility). */
|
|
2803
|
+
className?: string;
|
|
2804
|
+
/** Milliseconds a message stays in the DOM before self-clearing. Default `6000`. */
|
|
2805
|
+
clearAfterMs?: number;
|
|
2806
|
+
}
|
|
2807
|
+
/**
|
|
2808
|
+
* Mount once per `eventName` channel (typically once, at the app root).
|
|
2809
|
+
* Renders two visually-hidden `aria-live` regions (`polite` / `assertive`)
|
|
2810
|
+
* that receive text pushed by `announce()` calls dispatched on the same
|
|
2811
|
+
* `eventName`.
|
|
2812
|
+
*
|
|
2813
|
+
* @example
|
|
2814
|
+
* // root layout
|
|
2815
|
+
* <LiveRegion />
|
|
2816
|
+
* // elsewhere in the client tree
|
|
2817
|
+
* announce("Saved");
|
|
2818
|
+
*
|
|
2819
|
+
* @example
|
|
2820
|
+
* // namespaced channel — LiveRegion and announce() must agree on eventName
|
|
2821
|
+
* <LiveRegion eventName="myapp:announce" />
|
|
2822
|
+
* announce("Saved", "polite", { eventName: "myapp:announce" });
|
|
2823
|
+
*/
|
|
2824
|
+
declare function LiveRegion({ eventName, className, clearAfterMs, }: LiveRegionProps): React$1.JSX.Element;
|
|
2825
|
+
|
|
2826
|
+
interface UseScrollRestoreOptions {
|
|
2827
|
+
/** localStorage key prefix. Callers own their own namespacing. Default `DEFAULT_SCROLL_RESTORE_PREFIX` ("hazo_ui:scrollPos"). */
|
|
2828
|
+
prefix?: string;
|
|
2829
|
+
}
|
|
2830
|
+
interface UseScrollRestoreResult {
|
|
2831
|
+
/** Persist a scroll position (rounded to the nearest pixel). */
|
|
2832
|
+
save: (scrollY: number) => void;
|
|
2833
|
+
/** Read back the persisted scroll position, or `null` if none / unreadable. */
|
|
2834
|
+
load: () => number | null;
|
|
2835
|
+
}
|
|
2836
|
+
/**
|
|
2837
|
+
* localStorage-backed scroll-position save/load, keyed by
|
|
2838
|
+
* `${prefix}.${treeId}.${viewName}`. SSR-safe (no-ops when `window` is
|
|
2839
|
+
* undefined) and quota-safe (write failures are swallowed).
|
|
2840
|
+
*
|
|
2841
|
+
* @param treeId - Identifies the scrollable subject (e.g. a document/tree id).
|
|
2842
|
+
* @param viewName - Identifies which view/pane within that subject.
|
|
2843
|
+
* @param options.prefix - Storage-key prefix. Default `"hazo_ui:scrollPos"`.
|
|
2844
|
+
*
|
|
2845
|
+
* @example
|
|
2846
|
+
* const { save, load } = useScrollRestore(treeId, "canvas");
|
|
2847
|
+
* useEffect(() => {
|
|
2848
|
+
* const y = load();
|
|
2849
|
+
* if (y !== null) containerRef.current?.scrollTo(0, y);
|
|
2850
|
+
* }, []);
|
|
2851
|
+
* const onScroll = (e: React.UIEvent<HTMLDivElement>) => save(e.currentTarget.scrollTop);
|
|
2852
|
+
*
|
|
2853
|
+
* @example
|
|
2854
|
+
* // namespaced prefix — avoids collisions with other apps sharing a domain
|
|
2855
|
+
* useScrollRestore(treeId, "canvas", { prefix: "myapp:scrollPos" });
|
|
2856
|
+
*/
|
|
2857
|
+
declare function useScrollRestore(treeId: string, viewName: string, options?: UseScrollRestoreOptions): UseScrollRestoreResult;
|
|
2858
|
+
|
|
2859
|
+
export { ANIMATION_PRESETS, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, type AnimationPreset, AppFooter, type AppFooterProps, AppHeader, type AppHeaderProps, type BaseCommandInputProps, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CELEBRATION_GRADIENT, Calendar, CanvasTextToolbar, type CanvasTextToolbarProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CelebrationPayload, CelebrationProvider, type CelebrationProviderProps, type CelebrationShareableCard, type ChartDataPoint, type ChartDataSeries, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type CommandEditContext, type CommandItem$1 as CommandItem, CommandNodeExtension, CommandPill, type CommandPillProps, CommandPopover, type CommandPopoverProps, type CommandTextOutput, type ConfirmDialogVariant, type DateRangeOption, DateRangeSelector, type DateRangeSelectorProps, type DialogVariant, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, type EmptyStateProps, ErrorBanner, type ErrorBannerProps, type ErrorBannerSeverity, ErrorPage, type ErrorPageProps, type EtaProgressHandle, type FilterConfig, type FilterField, FunnelChart, type FunnelChartProps, type FunnelStep, HazoContextProvider, type HazoContextProviderProps, type HazoUiConfig, HazoUiConfirmDialog, type HazoUiConfirmDialogProps, HazoUiDialog, DialogClose as HazoUiDialogClose, DialogContent as HazoUiDialogContent, DialogDescription as HazoUiDialogDescription, DialogFooter as HazoUiDialogFooter, DialogHeader as HazoUiDialogHeader, type HazoUiDialogKind, DialogOverlay as HazoUiDialogOverlay, DialogPortal as HazoUiDialogPortal, type HazoUiDialogProps, Dialog as HazoUiDialogRoot, DialogTitle as HazoUiDialogTitle, DialogTrigger as HazoUiDialogTrigger, HazoUiEtaProgress, type HazoUiEtaProgressProps, HazoUiFlexInput, type HazoUiFlexInputProps, HazoUiFlexRadio, type HazoUiFlexRadioItem, type HazoUiFlexRadioProps, HazoUiIcon, HazoUiIconPicker, type HazoUiIconPickerProps, type HazoUiIconProps, HazoUiImageCropper, HazoUiImageCropperDialog, type HazoUiImageCropperDialogProps, type HazoUiImageCropperHandle, type HazoUiImageCropperProps, HazoUiKanban, HazoUiKanbanFilter, type HazoUiKanbanFilterProps, type HazoUiKanbanProps, HazoUiMemoryDropdown, type HazoUiMemoryDropdownProps, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiPillRadio, type HazoUiPillRadioItem, type HazoUiPillRadioProps, HazoUiProgressBar, type HazoUiProgressBarProps, HazoUiRte, type HazoUiRteProps, HazoUiTable, type HazoUiTablePagination, type HazoUiTableProps, type HazoUiTableServerLoadArgs, type HazoUiTableServerLoadResult, HazoUiTextarea, type HazoUiTextareaProps, HazoUiTextbox, type HazoUiTextboxProps, HazoUiToaster, type HazoUiToasterProps, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputAffix, type InputAffixProps, type InsertedCommand, InverseSparkline, type InverseSparklineProps, type KanbanAnnouncements, type KanbanColumn, type KanbanEditorCtx, type KanbanEditorField, type KanbanEditorFieldType, type KanbanFilterValue, type KanbanItem, type KanbanMoveEvent, type KanbanMoveHandle, type KanbanPriority, type KanbanReorderEvent, type KanbanSaveEvent, Label, LiveRegion, type LiveRegionProps, LoadingTimeout, type LoadingTimeoutProps, type Logger, Logo, type LogoProps, MarkdownEditor, type MarkdownEditorProps, type MarkdownEmbed, type MemoryEntry, NotificationCountBadge, type NotificationCountBadgeProps, NotificationItem, type NotificationItemProps, NotificationPanel, type NotificationPanelProps, type PermissionToastOptions, Popover, PopoverContent, PopoverTrigger, type PrefixColor, type PrefixConfig, ProgressiveImage, type ProgressiveImageProps, RadioGroup, RadioGroupItem, type RteAttachment, type RteOutput, type RteVariable, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Command as ShadcnCommand, CommandEmpty as ShadcnCommandEmpty, CommandGroup as ShadcnCommandGroup, CommandInput as ShadcnCommandInput, CommandItem as ShadcnCommandItem, CommandList as ShadcnCommandList, Skeleton, SkeletonBar, type SkeletonBarProps, SkeletonCircle, type SkeletonCircleProps, SkeletonGroup, type SkeletonGroupProps, SkeletonRect, type SkeletonRectProps, Slider, type SortConfig, type SortField, Sparkline, type SparklineProps, Spinner, type StackedBar, StackedBars, type StackedBarsProps, type SuggestionState, Switch, Table, TableBody, TableCaption, TableCell, type TableColumn, type TableFilter, TableFooter, type TableFormatter, TableHead, TableHeader, TableRow, type TableSort, type TableSortEntry, type TableSortProp, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, type ToastOptions, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseCopyToClipboardResult, type UseErrorDisplayResult, type UseEtaProgressOptions, type UseFullscreenRefResult, type UseFullscreenResult, type UseLoadingStateResult, type UseLongPressOptions, type UseLongPressResult, type UseRememberedStateOptions, type UseScrollRestoreOptions, type UseScrollRestoreResult, type UseWakeLockResult, applyKanbanFilter, buttonGroupVariants, celebrate, computeEta, create_command_suggestion_extension, easeToward, errorToast, format_num, generateUUID, get_hazo_ui_config, get_logger, isLucideValue, median, parse_commands_from_text, permissionToast, pick_x_label_indices, reset_hazo_ui_config, resolve_animation_classes, set_hazo_ui_config, set_logger, successToast, text_to_tiptap_content, toggleVariants, upsertEntry as upsertMemoryEntry, useClickOutside, useCopyToClipboard, useDebounce, useErrorDisplay, useEtaProgress, useFullscreen, useIsMobile, useLoadingState, useLocalStorage, useLongPress, useMediaQuery, useRememberedState, useScrollRestore, useSessionStorage, useViewport, useWakeLock, use_fullscreen, use_wake_lock };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { c as cn, s as safeHref } from './
|
|
1
|
+
export { A as AnnounceOptions, a as AnnouncePriority, D as DEFAULT_ANNOUNCE_EVENT, L as LiveAnnouncement, b as announce, c as cn, h as hasUrlParam, r as readRememberedState, s as safeHref, w as writeRememberedState } from './announce-DAnQDTld.js';
|
|
2
2
|
import * as React$1 from 'react';
|
|
3
|
-
import { ReactNode, RefObject } from 'react';
|
|
3
|
+
import { ReactNode, RefObject, PointerEvent, MouseEvent } from 'react';
|
|
4
4
|
import { ICommand } from '@uiw/react-md-editor';
|
|
5
5
|
export { ICommand as MarkdownEditorCommand } from '@uiw/react-md-editor';
|
|
6
6
|
import { Node, Extension } from '@tiptap/core';
|
|
@@ -2718,4 +2718,142 @@ interface AppFooterProps {
|
|
|
2718
2718
|
}
|
|
2719
2719
|
declare function AppFooter({ variant, footer, identity, className }: AppFooterProps): React$1.JSX.Element;
|
|
2720
2720
|
|
|
2721
|
-
|
|
2721
|
+
interface UseRememberedStateOptions<T> {
|
|
2722
|
+
/** Full localStorage key. Callers own their own namespacing/prefix. */
|
|
2723
|
+
key: string;
|
|
2724
|
+
/** Current serialisable state to remember. */
|
|
2725
|
+
snapshot: T;
|
|
2726
|
+
/** Feed a remembered snapshot back into the caller. Called at most once, on mount. */
|
|
2727
|
+
restore: (snapshot: T) => void;
|
|
2728
|
+
/** Default `true`; when `false` the hook is entirely inert (no read, no write). */
|
|
2729
|
+
enabled?: boolean;
|
|
2730
|
+
/** Debounce delay (ms) before a changed snapshot is written. Default `600`. */
|
|
2731
|
+
debounceMs?: number;
|
|
2732
|
+
/**
|
|
2733
|
+
* When set, restore-on-mount is skipped if this URL query param is present
|
|
2734
|
+
* in `window.location.search` — an explicit shared-link or saved-record
|
|
2735
|
+
* load should always win over remembered state. Omit to never skip.
|
|
2736
|
+
*/
|
|
2737
|
+
skipWhenUrlParam?: string;
|
|
2738
|
+
}
|
|
2739
|
+
/**
|
|
2740
|
+
* Remembers a snapshot of state in localStorage and restores it on mount.
|
|
2741
|
+
*
|
|
2742
|
+
* - Restore is attempted **once** per mount (a ref-based guard, independent
|
|
2743
|
+
* of prop/dependency changes — `restore`'s identity may change every
|
|
2744
|
+
* render without retriggering it).
|
|
2745
|
+
* - If `skipWhenUrlParam` is set and that query param is present in the
|
|
2746
|
+
* current URL, the restore-on-mount step is skipped entirely (an explicit
|
|
2747
|
+
* link/record load wins over remembered state).
|
|
2748
|
+
* - Writes are debounced by `debounceMs` and keyed off the snapshot's
|
|
2749
|
+
* serialised JSON (not object identity), so a structurally-equal-but-new
|
|
2750
|
+
* snapshot object doesn't reschedule a write.
|
|
2751
|
+
*
|
|
2752
|
+
* @example
|
|
2753
|
+
* useRememberedState({
|
|
2754
|
+
* key: `myapp:tool:${slug}`,
|
|
2755
|
+
* snapshot: currentSeed,
|
|
2756
|
+
* restore: (seed) => applySeed(seed),
|
|
2757
|
+
* skipWhenUrlParam: "restore",
|
|
2758
|
+
* });
|
|
2759
|
+
*/
|
|
2760
|
+
declare function useRememberedState<T>({ key, snapshot, restore, enabled, debounceMs, skipWhenUrlParam, }: UseRememberedStateOptions<T>): void;
|
|
2761
|
+
|
|
2762
|
+
interface UseLongPressOptions {
|
|
2763
|
+
onLongPress: (e: PointerEvent) => void;
|
|
2764
|
+
/** ms to hold before firing. Default 500. */
|
|
2765
|
+
delayMs?: number;
|
|
2766
|
+
/** Pixels of movement that cancel the press. Default 8. */
|
|
2767
|
+
moveThresholdPx?: number;
|
|
2768
|
+
/** Vibration ms on fire. Default 10. Set 0 to disable. */
|
|
2769
|
+
hapticMs?: number;
|
|
2770
|
+
}
|
|
2771
|
+
interface UseLongPressResult {
|
|
2772
|
+
onPointerDown: (e: PointerEvent) => void;
|
|
2773
|
+
onPointerMove: (e: PointerEvent) => void;
|
|
2774
|
+
onPointerUp: (e: PointerEvent) => void;
|
|
2775
|
+
onPointerCancel: (e: PointerEvent) => void;
|
|
2776
|
+
/** Spread onto the same element to suppress the trailing click that
|
|
2777
|
+
* fires after the long-press triggers. Without this, the touch that
|
|
2778
|
+
* ends the press also opens the hover card or detail panel — double
|
|
2779
|
+
* action. */
|
|
2780
|
+
onClick: (e: MouseEvent) => void;
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* Touch-only long-press hook. On fine-pointer devices (mouse), every
|
|
2784
|
+
* returned handler is a no-op — desktop relies on `onContextMenu` for
|
|
2785
|
+
* right-click instead. The returned event handlers should be spread onto
|
|
2786
|
+
* the target element via `<div {...longPress}>`.
|
|
2787
|
+
*
|
|
2788
|
+
* @param options.onLongPress - Fired once the press has been held for `delayMs`.
|
|
2789
|
+
* @param options.delayMs - ms to hold before firing. Default `500`.
|
|
2790
|
+
* @param options.moveThresholdPx - Pixels of movement that cancel the press. Default `8`.
|
|
2791
|
+
* @param options.hapticMs - Vibration ms on fire (`navigator.vibrate`). Default `10`; `0` disables.
|
|
2792
|
+
*
|
|
2793
|
+
* @example
|
|
2794
|
+
* const longPress = useLongPress({ onLongPress: (e) => openContextMenu(e) });
|
|
2795
|
+
* <div {...longPress}>Hold me</div>
|
|
2796
|
+
*/
|
|
2797
|
+
declare function useLongPress({ onLongPress, delayMs, moveThresholdPx, hapticMs, }: UseLongPressOptions): UseLongPressResult;
|
|
2798
|
+
|
|
2799
|
+
interface LiveRegionProps {
|
|
2800
|
+
/** Custom-event name to listen on. Must match the `eventName` passed to `announce()`. Default `DEFAULT_ANNOUNCE_EVENT`. */
|
|
2801
|
+
eventName?: string;
|
|
2802
|
+
/** className applied to both region `<div>`s. Default `"sr-only"` (Tailwind's screen-reader-only utility). */
|
|
2803
|
+
className?: string;
|
|
2804
|
+
/** Milliseconds a message stays in the DOM before self-clearing. Default `6000`. */
|
|
2805
|
+
clearAfterMs?: number;
|
|
2806
|
+
}
|
|
2807
|
+
/**
|
|
2808
|
+
* Mount once per `eventName` channel (typically once, at the app root).
|
|
2809
|
+
* Renders two visually-hidden `aria-live` regions (`polite` / `assertive`)
|
|
2810
|
+
* that receive text pushed by `announce()` calls dispatched on the same
|
|
2811
|
+
* `eventName`.
|
|
2812
|
+
*
|
|
2813
|
+
* @example
|
|
2814
|
+
* // root layout
|
|
2815
|
+
* <LiveRegion />
|
|
2816
|
+
* // elsewhere in the client tree
|
|
2817
|
+
* announce("Saved");
|
|
2818
|
+
*
|
|
2819
|
+
* @example
|
|
2820
|
+
* // namespaced channel — LiveRegion and announce() must agree on eventName
|
|
2821
|
+
* <LiveRegion eventName="myapp:announce" />
|
|
2822
|
+
* announce("Saved", "polite", { eventName: "myapp:announce" });
|
|
2823
|
+
*/
|
|
2824
|
+
declare function LiveRegion({ eventName, className, clearAfterMs, }: LiveRegionProps): React$1.JSX.Element;
|
|
2825
|
+
|
|
2826
|
+
interface UseScrollRestoreOptions {
|
|
2827
|
+
/** localStorage key prefix. Callers own their own namespacing. Default `DEFAULT_SCROLL_RESTORE_PREFIX` ("hazo_ui:scrollPos"). */
|
|
2828
|
+
prefix?: string;
|
|
2829
|
+
}
|
|
2830
|
+
interface UseScrollRestoreResult {
|
|
2831
|
+
/** Persist a scroll position (rounded to the nearest pixel). */
|
|
2832
|
+
save: (scrollY: number) => void;
|
|
2833
|
+
/** Read back the persisted scroll position, or `null` if none / unreadable. */
|
|
2834
|
+
load: () => number | null;
|
|
2835
|
+
}
|
|
2836
|
+
/**
|
|
2837
|
+
* localStorage-backed scroll-position save/load, keyed by
|
|
2838
|
+
* `${prefix}.${treeId}.${viewName}`. SSR-safe (no-ops when `window` is
|
|
2839
|
+
* undefined) and quota-safe (write failures are swallowed).
|
|
2840
|
+
*
|
|
2841
|
+
* @param treeId - Identifies the scrollable subject (e.g. a document/tree id).
|
|
2842
|
+
* @param viewName - Identifies which view/pane within that subject.
|
|
2843
|
+
* @param options.prefix - Storage-key prefix. Default `"hazo_ui:scrollPos"`.
|
|
2844
|
+
*
|
|
2845
|
+
* @example
|
|
2846
|
+
* const { save, load } = useScrollRestore(treeId, "canvas");
|
|
2847
|
+
* useEffect(() => {
|
|
2848
|
+
* const y = load();
|
|
2849
|
+
* if (y !== null) containerRef.current?.scrollTo(0, y);
|
|
2850
|
+
* }, []);
|
|
2851
|
+
* const onScroll = (e: React.UIEvent<HTMLDivElement>) => save(e.currentTarget.scrollTop);
|
|
2852
|
+
*
|
|
2853
|
+
* @example
|
|
2854
|
+
* // namespaced prefix — avoids collisions with other apps sharing a domain
|
|
2855
|
+
* useScrollRestore(treeId, "canvas", { prefix: "myapp:scrollPos" });
|
|
2856
|
+
*/
|
|
2857
|
+
declare function useScrollRestore(treeId: string, viewName: string, options?: UseScrollRestoreOptions): UseScrollRestoreResult;
|
|
2858
|
+
|
|
2859
|
+
export { ANIMATION_PRESETS, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, type AnimationPreset, AppFooter, type AppFooterProps, AppHeader, type AppHeaderProps, type BaseCommandInputProps, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CELEBRATION_GRADIENT, Calendar, CanvasTextToolbar, type CanvasTextToolbarProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CelebrationPayload, CelebrationProvider, type CelebrationProviderProps, type CelebrationShareableCard, type ChartDataPoint, type ChartDataSeries, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, type CommandEditContext, type CommandItem$1 as CommandItem, CommandNodeExtension, CommandPill, type CommandPillProps, CommandPopover, type CommandPopoverProps, type CommandTextOutput, type ConfirmDialogVariant, type DateRangeOption, DateRangeSelector, type DateRangeSelectorProps, type DialogVariant, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, type EmptyStateProps, ErrorBanner, type ErrorBannerProps, type ErrorBannerSeverity, ErrorPage, type ErrorPageProps, type EtaProgressHandle, type FilterConfig, type FilterField, FunnelChart, type FunnelChartProps, type FunnelStep, HazoContextProvider, type HazoContextProviderProps, type HazoUiConfig, HazoUiConfirmDialog, type HazoUiConfirmDialogProps, HazoUiDialog, DialogClose as HazoUiDialogClose, DialogContent as HazoUiDialogContent, DialogDescription as HazoUiDialogDescription, DialogFooter as HazoUiDialogFooter, DialogHeader as HazoUiDialogHeader, type HazoUiDialogKind, DialogOverlay as HazoUiDialogOverlay, DialogPortal as HazoUiDialogPortal, type HazoUiDialogProps, Dialog as HazoUiDialogRoot, DialogTitle as HazoUiDialogTitle, DialogTrigger as HazoUiDialogTrigger, HazoUiEtaProgress, type HazoUiEtaProgressProps, HazoUiFlexInput, type HazoUiFlexInputProps, HazoUiFlexRadio, type HazoUiFlexRadioItem, type HazoUiFlexRadioProps, HazoUiIcon, HazoUiIconPicker, type HazoUiIconPickerProps, type HazoUiIconProps, HazoUiImageCropper, HazoUiImageCropperDialog, type HazoUiImageCropperDialogProps, type HazoUiImageCropperHandle, type HazoUiImageCropperProps, HazoUiKanban, HazoUiKanbanFilter, type HazoUiKanbanFilterProps, type HazoUiKanbanProps, HazoUiMemoryDropdown, type HazoUiMemoryDropdownProps, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiPillRadio, type HazoUiPillRadioItem, type HazoUiPillRadioProps, HazoUiProgressBar, type HazoUiProgressBarProps, HazoUiRte, type HazoUiRteProps, HazoUiTable, type HazoUiTablePagination, type HazoUiTableProps, type HazoUiTableServerLoadArgs, type HazoUiTableServerLoadResult, HazoUiTextarea, type HazoUiTextareaProps, HazoUiTextbox, type HazoUiTextboxProps, HazoUiToaster, type HazoUiToasterProps, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputAffix, type InputAffixProps, type InsertedCommand, InverseSparkline, type InverseSparklineProps, type KanbanAnnouncements, type KanbanColumn, type KanbanEditorCtx, type KanbanEditorField, type KanbanEditorFieldType, type KanbanFilterValue, type KanbanItem, type KanbanMoveEvent, type KanbanMoveHandle, type KanbanPriority, type KanbanReorderEvent, type KanbanSaveEvent, Label, LiveRegion, type LiveRegionProps, LoadingTimeout, type LoadingTimeoutProps, type Logger, Logo, type LogoProps, MarkdownEditor, type MarkdownEditorProps, type MarkdownEmbed, type MemoryEntry, NotificationCountBadge, type NotificationCountBadgeProps, NotificationItem, type NotificationItemProps, NotificationPanel, type NotificationPanelProps, type PermissionToastOptions, Popover, PopoverContent, PopoverTrigger, type PrefixColor, type PrefixConfig, ProgressiveImage, type ProgressiveImageProps, RadioGroup, RadioGroupItem, type RteAttachment, type RteOutput, type RteVariable, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Command as ShadcnCommand, CommandEmpty as ShadcnCommandEmpty, CommandGroup as ShadcnCommandGroup, CommandInput as ShadcnCommandInput, CommandItem as ShadcnCommandItem, CommandList as ShadcnCommandList, Skeleton, SkeletonBar, type SkeletonBarProps, SkeletonCircle, type SkeletonCircleProps, SkeletonGroup, type SkeletonGroupProps, SkeletonRect, type SkeletonRectProps, Slider, type SortConfig, type SortField, Sparkline, type SparklineProps, Spinner, type StackedBar, StackedBars, type StackedBarsProps, type SuggestionState, Switch, Table, TableBody, TableCaption, TableCell, type TableColumn, type TableFilter, TableFooter, type TableFormatter, TableHead, TableHeader, TableRow, type TableSort, type TableSortEntry, type TableSortProp, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, type ToastOptions, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type UseCopyToClipboardResult, type UseErrorDisplayResult, type UseEtaProgressOptions, type UseFullscreenRefResult, type UseFullscreenResult, type UseLoadingStateResult, type UseLongPressOptions, type UseLongPressResult, type UseRememberedStateOptions, type UseScrollRestoreOptions, type UseScrollRestoreResult, type UseWakeLockResult, applyKanbanFilter, buttonGroupVariants, celebrate, computeEta, create_command_suggestion_extension, easeToward, errorToast, format_num, generateUUID, get_hazo_ui_config, get_logger, isLucideValue, median, parse_commands_from_text, permissionToast, pick_x_label_indices, reset_hazo_ui_config, resolve_animation_classes, set_hazo_ui_config, set_logger, successToast, text_to_tiptap_content, toggleVariants, upsertEntry as upsertMemoryEntry, useClickOutside, useCopyToClipboard, useDebounce, useErrorDisplay, useEtaProgress, useFullscreen, useIsMobile, useLoadingState, useLocalStorage, useLongPress, useMediaQuery, useRememberedState, useScrollRestore, useSessionStorage, useViewport, useWakeLock, use_fullscreen, use_wake_lock };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
import * as React27 from 'react';
|
|
5
|
-
import React27__default, { lazy, useRef, useState, useCallback, useEffect, useMemo, Fragment, Suspense } from 'react';
|
|
5
|
+
import React27__default, { lazy, useRef, useState, useCallback, useEffect, useMemo, Fragment, Suspense, useSyncExternalStore } from 'react';
|
|
6
6
|
import { generateRequestId } from 'hazo_core';
|
|
7
7
|
import { withContext, setBrowserCorrelationId } from 'hazo_core/client';
|
|
8
8
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
@@ -11874,6 +11874,253 @@ function AppFooter({ variant, footer, identity, className }) {
|
|
|
11874
11874
|
);
|
|
11875
11875
|
}
|
|
11876
11876
|
|
|
11877
|
-
|
|
11877
|
+
// src/lib/remembered_state.ts
|
|
11878
|
+
function readRememberedState(key) {
|
|
11879
|
+
if (typeof window === "undefined") return null;
|
|
11880
|
+
try {
|
|
11881
|
+
const raw = window.localStorage.getItem(key);
|
|
11882
|
+
return raw ? JSON.parse(raw) : null;
|
|
11883
|
+
} catch {
|
|
11884
|
+
return null;
|
|
11885
|
+
}
|
|
11886
|
+
}
|
|
11887
|
+
function writeRememberedState(key, snapshot) {
|
|
11888
|
+
if (typeof window === "undefined") return;
|
|
11889
|
+
try {
|
|
11890
|
+
window.localStorage.setItem(key, JSON.stringify(snapshot));
|
|
11891
|
+
} catch {
|
|
11892
|
+
}
|
|
11893
|
+
}
|
|
11894
|
+
function hasUrlParam(search, paramName) {
|
|
11895
|
+
try {
|
|
11896
|
+
return new URLSearchParams(search).has(paramName);
|
|
11897
|
+
} catch {
|
|
11898
|
+
return false;
|
|
11899
|
+
}
|
|
11900
|
+
}
|
|
11901
|
+
|
|
11902
|
+
// src/hooks/use_remembered_state.ts
|
|
11903
|
+
function useRememberedState({
|
|
11904
|
+
key,
|
|
11905
|
+
snapshot,
|
|
11906
|
+
restore,
|
|
11907
|
+
enabled = true,
|
|
11908
|
+
debounceMs = 600,
|
|
11909
|
+
skipWhenUrlParam
|
|
11910
|
+
}) {
|
|
11911
|
+
const restoreRef = useRef(restore);
|
|
11912
|
+
useEffect(() => {
|
|
11913
|
+
restoreRef.current = restore;
|
|
11914
|
+
});
|
|
11915
|
+
const didRestore = useRef(false);
|
|
11916
|
+
useEffect(() => {
|
|
11917
|
+
if (didRestore.current) return;
|
|
11918
|
+
didRestore.current = true;
|
|
11919
|
+
if (!enabled) return;
|
|
11920
|
+
if (typeof window === "undefined") return;
|
|
11921
|
+
if (skipWhenUrlParam && hasUrlParam(window.location.search, skipWhenUrlParam)) return;
|
|
11922
|
+
const remembered = readRememberedState(key);
|
|
11923
|
+
if (remembered === null) return;
|
|
11924
|
+
try {
|
|
11925
|
+
restoreRef.current(remembered);
|
|
11926
|
+
} catch {
|
|
11927
|
+
}
|
|
11928
|
+
}, [key, enabled, skipWhenUrlParam]);
|
|
11929
|
+
const snapshotJson = JSON.stringify(snapshot);
|
|
11930
|
+
const writeTimer = useRef(null);
|
|
11931
|
+
useEffect(() => {
|
|
11932
|
+
if (!enabled) return;
|
|
11933
|
+
if (writeTimer.current) clearTimeout(writeTimer.current);
|
|
11934
|
+
writeTimer.current = setTimeout(() => {
|
|
11935
|
+
writeRememberedState(key, snapshot);
|
|
11936
|
+
}, debounceMs);
|
|
11937
|
+
return () => {
|
|
11938
|
+
if (writeTimer.current) clearTimeout(writeTimer.current);
|
|
11939
|
+
};
|
|
11940
|
+
}, [key, snapshotJson, enabled, debounceMs]);
|
|
11941
|
+
}
|
|
11942
|
+
var COARSE_QUERY = "(pointer: coarse)";
|
|
11943
|
+
function subscribe_coarse(notify) {
|
|
11944
|
+
if (typeof window === "undefined") return () => {
|
|
11945
|
+
};
|
|
11946
|
+
const mql = window.matchMedia(COARSE_QUERY);
|
|
11947
|
+
mql.addEventListener("change", notify);
|
|
11948
|
+
return () => mql.removeEventListener("change", notify);
|
|
11949
|
+
}
|
|
11950
|
+
function get_coarse_snapshot() {
|
|
11951
|
+
return window.matchMedia(COARSE_QUERY).matches;
|
|
11952
|
+
}
|
|
11953
|
+
function get_coarse_server_snapshot() {
|
|
11954
|
+
return false;
|
|
11955
|
+
}
|
|
11956
|
+
function useLongPress({
|
|
11957
|
+
onLongPress,
|
|
11958
|
+
delayMs = 500,
|
|
11959
|
+
moveThresholdPx = 8,
|
|
11960
|
+
hapticMs = 10
|
|
11961
|
+
}) {
|
|
11962
|
+
const isCoarse = useSyncExternalStore(
|
|
11963
|
+
subscribe_coarse,
|
|
11964
|
+
get_coarse_snapshot,
|
|
11965
|
+
get_coarse_server_snapshot
|
|
11966
|
+
);
|
|
11967
|
+
const timerRef = useRef(null);
|
|
11968
|
+
const originRef = useRef(null);
|
|
11969
|
+
const firedRef = useRef(false);
|
|
11970
|
+
const eventRef = useRef(null);
|
|
11971
|
+
const cancel = useCallback(() => {
|
|
11972
|
+
if (timerRef.current !== null) {
|
|
11973
|
+
clearTimeout(timerRef.current);
|
|
11974
|
+
timerRef.current = null;
|
|
11975
|
+
}
|
|
11976
|
+
originRef.current = null;
|
|
11977
|
+
eventRef.current = null;
|
|
11978
|
+
}, []);
|
|
11979
|
+
useEffect(() => () => cancel(), [cancel]);
|
|
11980
|
+
const noop = useCallback(() => {
|
|
11981
|
+
}, []);
|
|
11982
|
+
const handlePointerDown = useCallback(
|
|
11983
|
+
(e) => {
|
|
11984
|
+
if (originRef.current && originRef.current.pointerId !== e.pointerId) {
|
|
11985
|
+
cancel();
|
|
11986
|
+
return;
|
|
11987
|
+
}
|
|
11988
|
+
firedRef.current = false;
|
|
11989
|
+
originRef.current = { x: e.clientX, y: e.clientY, pointerId: e.pointerId };
|
|
11990
|
+
eventRef.current = e;
|
|
11991
|
+
timerRef.current = setTimeout(() => {
|
|
11992
|
+
timerRef.current = null;
|
|
11993
|
+
firedRef.current = true;
|
|
11994
|
+
if (hapticMs > 0 && typeof navigator !== "undefined" && "vibrate" in navigator) {
|
|
11995
|
+
try {
|
|
11996
|
+
navigator.vibrate?.(hapticMs);
|
|
11997
|
+
} catch {
|
|
11998
|
+
}
|
|
11999
|
+
}
|
|
12000
|
+
const evt = eventRef.current;
|
|
12001
|
+
if (evt) onLongPress(evt);
|
|
12002
|
+
}, delayMs);
|
|
12003
|
+
},
|
|
12004
|
+
[delayMs, hapticMs, cancel, onLongPress]
|
|
12005
|
+
);
|
|
12006
|
+
const handlePointerMove = useCallback(
|
|
12007
|
+
(e) => {
|
|
12008
|
+
if (!originRef.current) return;
|
|
12009
|
+
const dx = e.clientX - originRef.current.x;
|
|
12010
|
+
const dy = e.clientY - originRef.current.y;
|
|
12011
|
+
if (Math.hypot(dx, dy) > moveThresholdPx) cancel();
|
|
12012
|
+
},
|
|
12013
|
+
[moveThresholdPx, cancel]
|
|
12014
|
+
);
|
|
12015
|
+
const handlePointerUpOrCancel = useCallback(() => {
|
|
12016
|
+
cancel();
|
|
12017
|
+
}, [cancel]);
|
|
12018
|
+
const handleClick = useCallback((e) => {
|
|
12019
|
+
if (firedRef.current) {
|
|
12020
|
+
e.preventDefault();
|
|
12021
|
+
e.stopPropagation();
|
|
12022
|
+
firedRef.current = false;
|
|
12023
|
+
}
|
|
12024
|
+
}, []);
|
|
12025
|
+
if (!isCoarse) {
|
|
12026
|
+
return {
|
|
12027
|
+
onPointerDown: noop,
|
|
12028
|
+
onPointerMove: noop,
|
|
12029
|
+
onPointerUp: noop,
|
|
12030
|
+
onPointerCancel: noop,
|
|
12031
|
+
onClick: noop
|
|
12032
|
+
};
|
|
12033
|
+
}
|
|
12034
|
+
return {
|
|
12035
|
+
onPointerDown: handlePointerDown,
|
|
12036
|
+
onPointerMove: handlePointerMove,
|
|
12037
|
+
onPointerUp: handlePointerUpOrCancel,
|
|
12038
|
+
onPointerCancel: handlePointerUpOrCancel,
|
|
12039
|
+
onClick: handleClick
|
|
12040
|
+
};
|
|
12041
|
+
}
|
|
12042
|
+
|
|
12043
|
+
// src/lib/announce.ts
|
|
12044
|
+
var DEFAULT_ANNOUNCE_EVENT = "hazo_ui:announce";
|
|
12045
|
+
function announce(message, priority = "polite", options) {
|
|
12046
|
+
if (typeof window === "undefined") return;
|
|
12047
|
+
const trimmed = message.trim();
|
|
12048
|
+
if (!trimmed) return;
|
|
12049
|
+
const eventName = options?.eventName ?? DEFAULT_ANNOUNCE_EVENT;
|
|
12050
|
+
window.dispatchEvent(
|
|
12051
|
+
new CustomEvent(eventName, {
|
|
12052
|
+
detail: { message: trimmed, priority }
|
|
12053
|
+
})
|
|
12054
|
+
);
|
|
12055
|
+
}
|
|
12056
|
+
function LiveRegion({
|
|
12057
|
+
eventName = DEFAULT_ANNOUNCE_EVENT,
|
|
12058
|
+
className = "sr-only",
|
|
12059
|
+
clearAfterMs = 6e3
|
|
12060
|
+
}) {
|
|
12061
|
+
const [polite, set_polite] = useState("");
|
|
12062
|
+
const [assertive, set_assertive] = useState("");
|
|
12063
|
+
const polite_timer = useRef(null);
|
|
12064
|
+
const assertive_timer = useRef(null);
|
|
12065
|
+
useEffect(() => {
|
|
12066
|
+
const handler = (e) => {
|
|
12067
|
+
const detail = e.detail;
|
|
12068
|
+
if (!detail?.message) return;
|
|
12069
|
+
if (detail.priority === "assertive") {
|
|
12070
|
+
if (assertive_timer.current) clearTimeout(assertive_timer.current);
|
|
12071
|
+
set_assertive((prev) => prev === detail.message ? `${detail.message} ` : detail.message);
|
|
12072
|
+
assertive_timer.current = setTimeout(() => set_assertive(""), clearAfterMs);
|
|
12073
|
+
} else {
|
|
12074
|
+
if (polite_timer.current) clearTimeout(polite_timer.current);
|
|
12075
|
+
set_polite((prev) => prev === detail.message ? `${detail.message} ` : detail.message);
|
|
12076
|
+
polite_timer.current = setTimeout(() => set_polite(""), clearAfterMs);
|
|
12077
|
+
}
|
|
12078
|
+
};
|
|
12079
|
+
window.addEventListener(eventName, handler);
|
|
12080
|
+
return () => {
|
|
12081
|
+
window.removeEventListener(eventName, handler);
|
|
12082
|
+
if (polite_timer.current) clearTimeout(polite_timer.current);
|
|
12083
|
+
if (assertive_timer.current) clearTimeout(assertive_timer.current);
|
|
12084
|
+
};
|
|
12085
|
+
}, [eventName, clearAfterMs]);
|
|
12086
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
12087
|
+
/* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className, children: polite }),
|
|
12088
|
+
/* @__PURE__ */ jsx("div", { role: "alert", "aria-live": "assertive", "aria-atomic": "true", className, children: assertive })
|
|
12089
|
+
] });
|
|
12090
|
+
}
|
|
12091
|
+
|
|
12092
|
+
// src/lib/scroll_restore.ts
|
|
12093
|
+
var DEFAULT_SCROLL_RESTORE_PREFIX = "hazo_ui:scrollPos";
|
|
12094
|
+
function buildScrollRestoreKey(prefix, treeId, viewName) {
|
|
12095
|
+
return `${prefix}.${treeId}.${viewName}`;
|
|
12096
|
+
}
|
|
12097
|
+
function saveScrollPos(key, scrollY) {
|
|
12098
|
+
if (typeof window === "undefined") return;
|
|
12099
|
+
try {
|
|
12100
|
+
window.localStorage.setItem(key, String(Math.round(scrollY)));
|
|
12101
|
+
} catch {
|
|
12102
|
+
}
|
|
12103
|
+
}
|
|
12104
|
+
function loadScrollPos(key) {
|
|
12105
|
+
if (typeof window === "undefined") return null;
|
|
12106
|
+
try {
|
|
12107
|
+
const raw = window.localStorage.getItem(key);
|
|
12108
|
+
if (!raw) return null;
|
|
12109
|
+
const n = Number.parseInt(raw, 10);
|
|
12110
|
+
return Number.isFinite(n) ? n : null;
|
|
12111
|
+
} catch {
|
|
12112
|
+
return null;
|
|
12113
|
+
}
|
|
12114
|
+
}
|
|
12115
|
+
|
|
12116
|
+
// src/hooks/use_scroll_restore.ts
|
|
12117
|
+
function useScrollRestore(treeId, viewName, options) {
|
|
12118
|
+
const key = buildScrollRestoreKey(options?.prefix ?? DEFAULT_SCROLL_RESTORE_PREFIX, treeId, viewName);
|
|
12119
|
+
const save = useCallback((scrollY) => saveScrollPos(key, scrollY), [key]);
|
|
12120
|
+
const load = useCallback(() => loadScrollPos(key), [key]);
|
|
12121
|
+
return { save, load };
|
|
12122
|
+
}
|
|
12123
|
+
|
|
12124
|
+
export { ANIMATION_PRESETS, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AppFooter, AppHeader, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CELEBRATION_GRADIENT, Calendar, CanvasTextToolbar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CelebrationProvider, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CommandNodeExtension, CommandPill, CommandPopover, DEFAULT_ANNOUNCE_EVENT, DateRangeSelector, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, ErrorBanner, ErrorPage, FunnelChart, HazoContextProvider, HazoUiConfirmDialog, HazoUiDialog, DialogClose as HazoUiDialogClose, DialogContent as HazoUiDialogContent, DialogDescription as HazoUiDialogDescription, DialogFooter as HazoUiDialogFooter, DialogHeader as HazoUiDialogHeader, DialogOverlay as HazoUiDialogOverlay, DialogPortal as HazoUiDialogPortal, Dialog as HazoUiDialogRoot, DialogTitle as HazoUiDialogTitle, DialogTrigger as HazoUiDialogTrigger, HazoUiEtaProgress, HazoUiFlexInput, HazoUiFlexRadio, HazoUiIcon, HazoUiIconPicker, HazoUiImageCropper, HazoUiImageCropperDialog, HazoUiKanban, HazoUiKanbanFilter, HazoUiMemoryDropdown, HazoUiMultiFilterDialog, HazoUiMultiSortDialog, HazoUiPillRadio, HazoUiProgressBar, HazoUiRte, HazoUiTable, HazoUiTextarea, HazoUiTextbox, HazoUiToaster, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputAffix, InverseSparkline, Label3 as Label, LiveRegion, LoadingTimeout, Logo, MarkdownEditor, NotificationCountBadge, NotificationItem, NotificationPanel, Popover, PopoverContent, PopoverTrigger, ProgressiveImage, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator3 as Separator, Command as ShadcnCommand, CommandEmpty as ShadcnCommandEmpty, CommandGroup as ShadcnCommandGroup, CommandInput as ShadcnCommandInput, CommandItem as ShadcnCommandItem, CommandList as ShadcnCommandList, Skeleton, SkeletonBar, SkeletonCircle, SkeletonGroup, SkeletonRect, Slider, Sparkline, Spinner, StackedBars, Switch, Table2 as Table, TableBody, TableCaption, TableCell2 as TableCell, TableFooter, TableHead, TableHeader2 as TableHeader, TableRow2 as TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, announce, applyKanbanFilter, buttonGroupVariants, celebrate, cn, computeEta, create_command_suggestion_extension, easeToward, errorToast, format_num, generateUUID, get_hazo_ui_config, get_logger, hasUrlParam, isLucideValue, median, parse_commands_from_text, permissionToast, pick_x_label_indices, readRememberedState, reset_hazo_ui_config, resolve_animation_classes, safeHref, set_hazo_ui_config, set_logger, successToast, text_to_tiptap_content, toggleVariants, upsertEntry as upsertMemoryEntry, useClickOutside, useCopyToClipboard, useDebounce, useErrorDisplay, useEtaProgress, useFullscreen, useIsMobile, useLoadingState, useLocalStorage, useLongPress, useMediaQuery, useRememberedState, useScrollRestore, useSessionStorage, useViewport, useWakeLock, use_fullscreen, use_wake_lock, writeRememberedState };
|
|
11878
12125
|
//# sourceMappingURL=index.js.map
|
|
11879
12126
|
//# sourceMappingURL=index.js.map
|