@classytic/fluid 0.3.4 → 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/client/core.d.mts +14 -18
- package/dist/client/core.mjs +105 -279
- package/dist/client/hooks.mjs +52 -26
- package/dist/client/table.d.mts +41 -5
- package/dist/client/table.mjs +54 -7
- package/dist/dashboard.d.mts +2 -0
- package/dist/dashboard.mjs +1 -1
- package/dist/dropdown-wrapper-B86u9Fri.mjs +357 -0
- package/dist/forms.mjs +22 -7
- package/package.json +1 -1
- package/dist/api-pagination-DBTE0yk4.mjs +0 -190
package/dist/client/core.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as ApiPaginationData, r as ApiPaginationProps, t as ApiPagination } from "../api-pagination-CJ0vR_w6.mjs";
|
|
2
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
import * as react from "react";
|
|
4
|
-
import { ComponentType, ElementType, HTMLAttributes, ReactNode, RefObject } from "react";
|
|
4
|
+
import { ComponentPropsWithoutRef, ComponentType, ElementType, HTMLAttributes, ReactNode, RefObject } from "react";
|
|
5
5
|
import { LucideIcon, LucideProps } from "lucide-react";
|
|
6
6
|
import { VariantProps } from "class-variance-authority";
|
|
7
7
|
import * as class_variance_authority_types0 from "class-variance-authority/types";
|
|
@@ -1186,32 +1186,28 @@ declare function SimpleTable({
|
|
|
1186
1186
|
}: SimpleTableProps): react_jsx_runtime0.JSX.Element;
|
|
1187
1187
|
//#endregion
|
|
1188
1188
|
//#region src/components/tabs-wrapper.d.ts
|
|
1189
|
-
|
|
1189
|
+
type TabPreset = "default" | "line";
|
|
1190
|
+
interface TabsWrapperProps extends Omit<ComponentPropsWithoutRef<"div">, "defaultValue" | "dir"> {
|
|
1190
1191
|
defaultValue?: string;
|
|
1191
1192
|
value?: string;
|
|
1192
1193
|
onValueChange?: (value: string) => void;
|
|
1193
|
-
|
|
1194
|
-
|
|
1194
|
+
/** Elements rendered inside TabsList. */
|
|
1195
|
+
triggers: ReactNode;
|
|
1195
1196
|
listClassName?: string;
|
|
1196
|
-
|
|
1197
|
+
preset?: TabPreset;
|
|
1198
|
+
fullWidth?: boolean;
|
|
1197
1199
|
orientation?: "horizontal" | "vertical";
|
|
1198
1200
|
layout?: "default" | "flex" | "sidebar";
|
|
1199
1201
|
}
|
|
1200
1202
|
declare const TabsWrapper: react.NamedExoticComponent<TabsWrapperProps>;
|
|
1201
|
-
interface TabTriggerProps {
|
|
1203
|
+
interface TabTriggerProps extends Omit<ComponentPropsWithoutRef<"button">, "value"> {
|
|
1202
1204
|
value: string;
|
|
1203
|
-
children: ReactNode;
|
|
1204
|
-
className?: string;
|
|
1205
|
-
variant?: "default" | "primary" | "secondary" | "outline" | "ghost" | "underline";
|
|
1206
1205
|
icon?: ReactNode;
|
|
1207
1206
|
hideTextOnMobile?: boolean;
|
|
1208
|
-
disabled?: boolean;
|
|
1209
1207
|
}
|
|
1210
1208
|
declare const TabTrigger: react.NamedExoticComponent<TabTriggerProps>;
|
|
1211
|
-
interface TabContentProps {
|
|
1209
|
+
interface TabContentProps extends Omit<ComponentPropsWithoutRef<"div">, "value"> {
|
|
1212
1210
|
value: string;
|
|
1213
|
-
children: ReactNode;
|
|
1214
|
-
className?: string;
|
|
1215
1211
|
withScrollArea?: boolean;
|
|
1216
1212
|
scrollAreaClassName?: string;
|
|
1217
1213
|
padding?: boolean;
|
|
@@ -1226,16 +1222,16 @@ interface DynamicTabItem {
|
|
|
1226
1222
|
disabled?: boolean;
|
|
1227
1223
|
hideTextOnMobile?: boolean;
|
|
1228
1224
|
}
|
|
1229
|
-
interface DynamicTabsProps {
|
|
1225
|
+
interface DynamicTabsProps extends Omit<ComponentPropsWithoutRef<"div">, "defaultValue" | "dir"> {
|
|
1230
1226
|
tabs?: DynamicTabItem[];
|
|
1231
1227
|
defaultValue?: string;
|
|
1232
1228
|
value?: string;
|
|
1233
1229
|
onValueChange?: (value: string) => void;
|
|
1234
|
-
|
|
1230
|
+
preset?: TabPreset;
|
|
1231
|
+
fullWidth?: boolean;
|
|
1232
|
+
orientation?: "horizontal" | "vertical";
|
|
1235
1233
|
layout?: "default" | "flex" | "sidebar";
|
|
1236
|
-
className?: string;
|
|
1237
1234
|
listClassName?: string;
|
|
1238
|
-
listWrapperClassName?: string;
|
|
1239
1235
|
contentClassName?: string;
|
|
1240
1236
|
scrollable?: boolean;
|
|
1241
1237
|
}
|
|
@@ -1611,4 +1607,4 @@ declare function AnimatedCounter({
|
|
|
1611
1607
|
as
|
|
1612
1608
|
}: AnimatedCounterProps): react.ReactElement<any, string | react.JSXElementConstructor<any>>;
|
|
1613
1609
|
//#endregion
|
|
1614
|
-
export { AccordionSection, type AccordionSectionProps, ActionDropdown, type ActionDropdownItem, type ActionDropdownProps, ActionTooltip, type ActionTooltipProps, type AnimateBaseProps, AnimatedCounter, type AnimatedCounterProps, AnimatedText, type AnimatedTextProps, type Animation, ApiPagination, type ApiPaginationData, type ApiPaginationProps, ButtonTooltip, type ButtonTooltipProps, CardWrapper, type CardWrapperProps, CheckboxDropdown, type CheckboxDropdownProps, ClientSubmitButton, type ClientSubmitButtonProps, CollapsibleCard, type CollapsibleCardProps, CollapsibleSection, type CollapsibleSectionProps, CollapsibleWrapper, type CollapsibleWrapperProps, ConfirmDialog, type ConfirmDialogProps, ConfirmSheet, type ConfirmSheetProps, CopyButton, type CopyButtonProps, CopyCodeBlock, type CopyCodeBlockProps, CopyText, type CopyTextProps, CustomPagination, type CustomPaginationProps, DEFAULT_COUNTRIES, DataCard, type DataCardProps, DeleteConfirmDialog, type DeleteConfirmDialogProps, DetailItem, type DetailItemProps, DetailView, type DetailViewItemData, type DetailViewProps, DialogWrapper, type DialogWrapperProps, type DragHandleProps, DraggableCard, type DraggableCardProps, DropdownWrapper, type DropdownWrapperProps, type DynamicTabItem, DynamicTabs, type DynamicTabsProps, ErrorState, ErrorStateInline, type ErrorStateInlineProps, type ErrorStateProps, FadeIn, FadeInUp, FaqAccordion, type FaqAccordionProps, type FaqItem, FeatureItem, type FeatureItemProps, FeatureList, type FeatureListItem, type FeatureListProps, FormDialog, type FormDialogProps, FormSheet, type FormSheetProps, IconItemMedia, type IconItemMediaProps, IconTooltip, type IconTooltipProps, InfoAlert, type InfoAlertProps, InfoRow, type InfoRowProps, InfoTooltip, type InfoTooltipProps, LoadingCard, type LoadingCardProps, PaginationInfo, type PaginationInfoProps, type PhoneCountry, PhoneInput, type PhoneInputProps, Pill, PillAvatar, PillAvatarGroup, type PillAvatarGroupProps, type PillAvatarProps, PillButton, type PillButtonProps, PillDelta, type PillDeltaProps, PillIcon, type PillIconProps, PillIndicator, type PillIndicatorProps, type PillProps, PillStatus, type PillStatusProps, RadioDropdown, type RadioDropdownProps, ResponsiveSplitLayout, type ResponsiveSplitLayoutProps, ScaleIn, SelectDropdown, type SelectDropdownOption, type SelectDropdownProps, SheetWrapper, type SheetWrapperProps, SimpleTable, type SimpleTableProps, type SlideDirection, SlideIn, type SlideInProps, StaggerChildren, type StaggerChildrenProps, StatsCard, type StatsCardProps, StatusBanner, type StatusBannerProps, type StatusBannerVariant, StepContent, type StepContentProps, Stepper, type StepperProps, type StepperStep, TabContent, type TabContentProps, TabTrigger, type TabTriggerProps, TableWrapper, type TableWrapperColumn, type TableWrapperEmptyState, type TableWrapperProps, TabsWrapper, type TabsWrapperProps, Thumbnail, type ThumbnailProps, Timeline, type TimelineItem, type TimelineProps, type TimelineStatus, TooltipWrapper, type TooltipWrapperProps, type UseInViewOptions, useInView };
|
|
1610
|
+
export { AccordionSection, type AccordionSectionProps, ActionDropdown, type ActionDropdownItem, type ActionDropdownProps, ActionTooltip, type ActionTooltipProps, type AnimateBaseProps, AnimatedCounter, type AnimatedCounterProps, AnimatedText, type AnimatedTextProps, type Animation, ApiPagination, type ApiPaginationData, type ApiPaginationProps, ButtonTooltip, type ButtonTooltipProps, CardWrapper, type CardWrapperProps, CheckboxDropdown, type CheckboxDropdownProps, ClientSubmitButton, type ClientSubmitButtonProps, CollapsibleCard, type CollapsibleCardProps, CollapsibleSection, type CollapsibleSectionProps, CollapsibleWrapper, type CollapsibleWrapperProps, ConfirmDialog, type ConfirmDialogProps, ConfirmSheet, type ConfirmSheetProps, CopyButton, type CopyButtonProps, CopyCodeBlock, type CopyCodeBlockProps, CopyText, type CopyTextProps, CustomPagination, type CustomPaginationProps, DEFAULT_COUNTRIES, DataCard, type DataCardProps, DeleteConfirmDialog, type DeleteConfirmDialogProps, DetailItem, type DetailItemProps, DetailView, type DetailViewItemData, type DetailViewProps, DialogWrapper, type DialogWrapperProps, type DragHandleProps, DraggableCard, type DraggableCardProps, DropdownWrapper, type DropdownWrapperProps, type DynamicTabItem, DynamicTabs, type DynamicTabsProps, ErrorState, ErrorStateInline, type ErrorStateInlineProps, type ErrorStateProps, FadeIn, FadeInUp, FaqAccordion, type FaqAccordionProps, type FaqItem, FeatureItem, type FeatureItemProps, FeatureList, type FeatureListItem, type FeatureListProps, FormDialog, type FormDialogProps, FormSheet, type FormSheetProps, IconItemMedia, type IconItemMediaProps, IconTooltip, type IconTooltipProps, InfoAlert, type InfoAlertProps, InfoRow, type InfoRowProps, InfoTooltip, type InfoTooltipProps, LoadingCard, type LoadingCardProps, PaginationInfo, type PaginationInfoProps, type PhoneCountry, PhoneInput, type PhoneInputProps, Pill, PillAvatar, PillAvatarGroup, type PillAvatarGroupProps, type PillAvatarProps, PillButton, type PillButtonProps, PillDelta, type PillDeltaProps, PillIcon, type PillIconProps, PillIndicator, type PillIndicatorProps, type PillProps, PillStatus, type PillStatusProps, RadioDropdown, type RadioDropdownProps, ResponsiveSplitLayout, type ResponsiveSplitLayoutProps, ScaleIn, SelectDropdown, type SelectDropdownOption, type SelectDropdownProps, SheetWrapper, type SheetWrapperProps, SimpleTable, type SimpleTableProps, type SlideDirection, SlideIn, type SlideInProps, StaggerChildren, type StaggerChildrenProps, StatsCard, type StatsCardProps, StatusBanner, type StatusBannerProps, type StatusBannerVariant, StepContent, type StepContentProps, Stepper, type StepperProps, type StepperStep, TabContent, type TabContentProps, type TabPreset, TabTrigger, type TabTriggerProps, TableWrapper, type TableWrapperColumn, type TableWrapperEmptyState, type TableWrapperProps, TabsWrapper, type TabsWrapperProps, Thumbnail, type ThumbnailProps, Timeline, type TimelineItem, type TimelineProps, type TimelineStatus, TooltipWrapper, type TooltipWrapperProps, type UseInViewOptions, useInView };
|
package/dist/client/core.mjs
CHANGED
|
@@ -2,20 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
import { t as cn } from "../utils-DQ5SCVoW.mjs";
|
|
4
4
|
import { t as useMediaQuery } from "../use-media-query-BnVNIKT4.mjs";
|
|
5
|
-
import { n as
|
|
5
|
+
import { a as SelectDropdown, c as PaginationInfo, i as RadioDropdown, n as CheckboxDropdown, o as ApiPagination, r as DropdownWrapper, s as CustomPagination, t as ActionDropdown } from "../dropdown-wrapper-B86u9Fri.mjs";
|
|
6
6
|
import { i as ClientSubmitButton, n as FormSheet, r as SheetWrapper, t as ConfirmSheet } from "../sheet-wrapper-C13Y-Q6w.mjs";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
|
9
9
|
import * as React$1 from "react";
|
|
10
|
-
import { Children, Fragment as Fragment$1, createElement, isValidElement, memo, useEffect, useMemo, useRef, useState } from "react";
|
|
11
|
-
import { AlertCircle, AlertTriangle, ArrowLeft, ArrowRight, Check, CheckCircle2, ChevronDown, ChevronDownIcon, ChevronUp, ChevronUpIcon, Circle, Copy, Info, Loader2, MinusIcon,
|
|
10
|
+
import { Children, Fragment as Fragment$1, createContext, createElement, isValidElement, memo, use, useEffect, useMemo, useRef, useState } from "react";
|
|
11
|
+
import { AlertCircle, AlertTriangle, ArrowLeft, ArrowRight, Check, CheckCircle2, ChevronDown, ChevronDownIcon, ChevronUp, ChevronUpIcon, Circle, Copy, Info, Loader2, MinusIcon, RefreshCw, X } from "lucide-react";
|
|
12
12
|
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion";
|
|
13
13
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card";
|
|
14
14
|
import { Button } from "@/components/ui/button";
|
|
15
15
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
|
16
16
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog";
|
|
17
17
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
|
18
|
-
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
|
19
18
|
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
|
|
20
19
|
import { cva } from "class-variance-authority";
|
|
21
20
|
import { Item, ItemContent, ItemDescription } from "@/components/ui/item";
|
|
@@ -642,170 +641,6 @@ function FormDialog({ open, onOpenChange, title, description, children, onSubmit
|
|
|
642
641
|
});
|
|
643
642
|
}
|
|
644
643
|
|
|
645
|
-
//#endregion
|
|
646
|
-
//#region src/components/dropdown-wrapper.tsx
|
|
647
|
-
function DropdownWrapper({ trigger, children, align = "end", side = "bottom", sideOffset = 4, className, contentClassName, ...props }) {
|
|
648
|
-
return /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
649
|
-
...props,
|
|
650
|
-
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, { render: trigger }), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
651
|
-
align,
|
|
652
|
-
side,
|
|
653
|
-
sideOffset,
|
|
654
|
-
className: cn("min-w-[160px]", contentClassName),
|
|
655
|
-
children
|
|
656
|
-
})]
|
|
657
|
-
});
|
|
658
|
-
}
|
|
659
|
-
function ActionDropdown({ items = [], triggerIcon: TriggerIcon = MoreHorizontal, triggerVariant = "ghost", triggerSize = "sm", triggerClassName, triggerLabel, showOnHover = false, align = "end", contentClassName, onOpenChange, stopPropagation = true, ...props }) {
|
|
660
|
-
const handleTriggerClick = (e) => {
|
|
661
|
-
if (stopPropagation) e.stopPropagation();
|
|
662
|
-
};
|
|
663
|
-
const trigger = /* @__PURE__ */ jsxs(Button, {
|
|
664
|
-
variant: triggerVariant,
|
|
665
|
-
size: triggerSize,
|
|
666
|
-
onClick: handleTriggerClick,
|
|
667
|
-
className: cn(showOnHover && "opacity-0 group-hover:opacity-100 transition-opacity", triggerClassName),
|
|
668
|
-
children: [
|
|
669
|
-
/* @__PURE__ */ jsx(TriggerIcon, { className: "h-4 w-4" }),
|
|
670
|
-
triggerLabel && /* @__PURE__ */ jsx("span", {
|
|
671
|
-
className: "ml-2",
|
|
672
|
-
children: triggerLabel
|
|
673
|
-
}),
|
|
674
|
-
/* @__PURE__ */ jsx("span", {
|
|
675
|
-
className: "sr-only",
|
|
676
|
-
children: "Open menu"
|
|
677
|
-
})
|
|
678
|
-
]
|
|
679
|
-
});
|
|
680
|
-
const handleItemClick = (item) => (e) => {
|
|
681
|
-
if (stopPropagation) e.stopPropagation();
|
|
682
|
-
item.onClick?.(e);
|
|
683
|
-
};
|
|
684
|
-
return /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
685
|
-
onOpenChange,
|
|
686
|
-
...props,
|
|
687
|
-
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, { render: trigger }), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
688
|
-
align,
|
|
689
|
-
className: cn("min-w-[180px]", contentClassName),
|
|
690
|
-
children: items.map((item, index) => {
|
|
691
|
-
if (item.hidden) return null;
|
|
692
|
-
if (item.type === "separator") return /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, item.key || `separator-${index}`);
|
|
693
|
-
if (item.type === "label") return /* @__PURE__ */ jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsx(DropdownMenuLabel, {
|
|
694
|
-
className: item.className,
|
|
695
|
-
children: item.label
|
|
696
|
-
}) }, item.key || `label-${index}`);
|
|
697
|
-
if (item.type === "group") return /* @__PURE__ */ jsx(DropdownMenuGroup, { children: item.items?.map((groupItem, groupIndex) => {
|
|
698
|
-
if (groupItem.hidden) return null;
|
|
699
|
-
const GroupItemIcon = groupItem.icon;
|
|
700
|
-
const groupItemLabel = typeof groupItem.label === "function" ? groupItem.label() : groupItem.label;
|
|
701
|
-
return /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
702
|
-
onClick: handleItemClick(groupItem),
|
|
703
|
-
disabled: groupItem.disabled,
|
|
704
|
-
className: cn(groupItem.variant === "destructive" && "text-destructive focus:text-destructive", groupItem.className),
|
|
705
|
-
children: [
|
|
706
|
-
GroupItemIcon && /* @__PURE__ */ jsx(GroupItemIcon, { className: "h-4 w-4" }),
|
|
707
|
-
/* @__PURE__ */ jsx("span", { children: groupItemLabel }),
|
|
708
|
-
groupItem.shortcut && /* @__PURE__ */ jsx("span", {
|
|
709
|
-
className: "ml-auto text-xs tracking-widest text-muted-foreground",
|
|
710
|
-
children: groupItem.shortcut
|
|
711
|
-
})
|
|
712
|
-
]
|
|
713
|
-
}, groupItem.key || `group-item-${groupIndex}`);
|
|
714
|
-
}) }, item.key || `group-${index}`);
|
|
715
|
-
const ItemIcon = item.icon;
|
|
716
|
-
const displayLabel = typeof item.label === "function" ? item.label() : item.label;
|
|
717
|
-
return /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
718
|
-
onClick: handleItemClick(item),
|
|
719
|
-
disabled: item.disabled,
|
|
720
|
-
className: cn(item.variant === "destructive" && "text-destructive focus:text-destructive", item.className),
|
|
721
|
-
children: [
|
|
722
|
-
ItemIcon && /* @__PURE__ */ jsx(ItemIcon, { className: "h-4 w-4" }),
|
|
723
|
-
/* @__PURE__ */ jsx("span", { children: displayLabel }),
|
|
724
|
-
item.shortcut && /* @__PURE__ */ jsx("span", {
|
|
725
|
-
className: "ml-auto text-xs tracking-widest text-muted-foreground",
|
|
726
|
-
children: item.shortcut
|
|
727
|
-
})
|
|
728
|
-
]
|
|
729
|
-
}, item.key || `item-${index}`);
|
|
730
|
-
})
|
|
731
|
-
})]
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
function SelectDropdown({ value, onValueChange, placeholder = "Select option...", options = [], triggerClassName, contentClassName, disabled = false, ...props }) {
|
|
735
|
-
const selectedOption = options.find((option) => option.value === value);
|
|
736
|
-
const trigger = /* @__PURE__ */ jsxs(Button, {
|
|
737
|
-
variant: "outline",
|
|
738
|
-
disabled,
|
|
739
|
-
className: cn("w-full justify-between", !selectedOption && "text-muted-foreground", triggerClassName),
|
|
740
|
-
children: [selectedOption ? selectedOption.label : placeholder, /* @__PURE__ */ jsx(ChevronDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })]
|
|
741
|
-
});
|
|
742
|
-
return /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
743
|
-
...props,
|
|
744
|
-
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, { render: trigger }), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
745
|
-
align: "start",
|
|
746
|
-
className: cn("w-full min-w-(--anchor-width)", contentClassName),
|
|
747
|
-
children: options.map((option) => /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
748
|
-
onClick: () => onValueChange?.(option.value),
|
|
749
|
-
className: cn("cursor-pointer", value === option.value && "bg-accent"),
|
|
750
|
-
children: [option.icon && /* @__PURE__ */ jsx(option.icon, { className: "mr-2 h-4 w-4" }), option.label]
|
|
751
|
-
}, option.value))
|
|
752
|
-
})]
|
|
753
|
-
});
|
|
754
|
-
}
|
|
755
|
-
function CheckboxDropdown({ values = [], onValuesChange, placeholder = "Select options...", options = [], triggerClassName, contentClassName, disabled = false, showSelectedCount = true, ...props }) {
|
|
756
|
-
const selectedOptions = options.filter((option) => values.includes(option.value));
|
|
757
|
-
const displayText = selectedOptions.length > 0 ? showSelectedCount ? `${selectedOptions.length} selected` : selectedOptions.map((opt) => opt.label).join(", ") : placeholder;
|
|
758
|
-
const trigger = /* @__PURE__ */ jsxs(Button, {
|
|
759
|
-
variant: "outline",
|
|
760
|
-
disabled,
|
|
761
|
-
className: cn("w-full justify-between", selectedOptions.length === 0 && "text-muted-foreground", triggerClassName),
|
|
762
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
763
|
-
className: "truncate",
|
|
764
|
-
children: displayText
|
|
765
|
-
}), /* @__PURE__ */ jsx(ChevronDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })]
|
|
766
|
-
});
|
|
767
|
-
const handleCheckedChange = (optionValue, checked) => {
|
|
768
|
-
if (checked) onValuesChange?.([...values, optionValue]);
|
|
769
|
-
else onValuesChange?.(values.filter((value) => value !== optionValue));
|
|
770
|
-
};
|
|
771
|
-
return /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
772
|
-
...props,
|
|
773
|
-
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, { render: trigger }), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
774
|
-
align: "start",
|
|
775
|
-
className: cn("w-full min-w-(--anchor-width)", contentClassName),
|
|
776
|
-
children: options.map((option) => /* @__PURE__ */ jsxs(DropdownMenuCheckboxItem, {
|
|
777
|
-
checked: values.includes(option.value),
|
|
778
|
-
onCheckedChange: (checked) => handleCheckedChange(option.value, checked),
|
|
779
|
-
children: [option.icon && /* @__PURE__ */ jsx(option.icon, { className: "mr-2 h-4 w-4" }), option.label]
|
|
780
|
-
}, option.value))
|
|
781
|
-
})]
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
function RadioDropdown({ value, onValueChange, placeholder = "Select option...", options = [], triggerClassName, contentClassName, disabled = false, ...props }) {
|
|
785
|
-
const selectedOption = options.find((option) => option.value === value);
|
|
786
|
-
const trigger = /* @__PURE__ */ jsxs(Button, {
|
|
787
|
-
variant: "outline",
|
|
788
|
-
disabled,
|
|
789
|
-
className: cn("w-full justify-between", !selectedOption && "text-muted-foreground", triggerClassName),
|
|
790
|
-
children: [selectedOption ? selectedOption.label : placeholder, /* @__PURE__ */ jsx(ChevronDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })]
|
|
791
|
-
});
|
|
792
|
-
return /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
793
|
-
...props,
|
|
794
|
-
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, { render: trigger }), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
795
|
-
align: "start",
|
|
796
|
-
className: cn("w-full min-w-(--anchor-width)", contentClassName),
|
|
797
|
-
children: /* @__PURE__ */ jsx(DropdownMenuRadioGroup, {
|
|
798
|
-
value,
|
|
799
|
-
onValueChange,
|
|
800
|
-
children: options.map((option) => /* @__PURE__ */ jsxs(DropdownMenuRadioItem, {
|
|
801
|
-
value: option.value,
|
|
802
|
-
children: [option.icon && /* @__PURE__ */ jsx(option.icon, { className: "mr-2 h-4 w-4" }), option.label]
|
|
803
|
-
}, option.value))
|
|
804
|
-
})
|
|
805
|
-
})]
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
|
|
809
644
|
//#endregion
|
|
810
645
|
//#region src/components/error-state.tsx
|
|
811
646
|
/**
|
|
@@ -1481,58 +1316,73 @@ function PillAvatarGroup({ children, className, ...props }) {
|
|
|
1481
1316
|
|
|
1482
1317
|
//#endregion
|
|
1483
1318
|
//#region src/components/tabs-wrapper.tsx
|
|
1484
|
-
const
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
primary: "border border-primary/30 bg-primary/10",
|
|
1488
|
-
secondary: "border border-secondary/40 bg-secondary/10",
|
|
1489
|
-
outline: "border border-border bg-background",
|
|
1490
|
-
ghost: "border border-transparent bg-transparent shadow-none",
|
|
1491
|
-
underline: "w-full mb-4 rounded-none border-b border-border/60 bg-transparent p-0 shadow-none gap-6"
|
|
1319
|
+
const PRESET_VARIANT = {
|
|
1320
|
+
default: "default",
|
|
1321
|
+
line: "line"
|
|
1492
1322
|
};
|
|
1493
|
-
const
|
|
1494
|
-
default:
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1323
|
+
const PRESETS = {
|
|
1324
|
+
default: {
|
|
1325
|
+
list: "",
|
|
1326
|
+
trigger: ""
|
|
1327
|
+
},
|
|
1328
|
+
line: {
|
|
1329
|
+
list: [
|
|
1330
|
+
"justify-start p-0 shadow-none flex-nowrap",
|
|
1331
|
+
"group-data-horizontal/tabs:w-full group-data-horizontal/tabs:border-b group-data-horizontal/tabs:border-border/60 group-data-horizontal/tabs:gap-5 group-data-horizontal/tabs:h-auto",
|
|
1332
|
+
"group-data-vertical/tabs:border-r group-data-vertical/tabs:border-border/60 group-data-vertical/tabs:gap-1"
|
|
1333
|
+
].join(" "),
|
|
1334
|
+
trigger: [
|
|
1335
|
+
"flex-initial",
|
|
1336
|
+
"group-data-horizontal/tabs:px-2 group-data-horizontal/tabs:pb-2.5 group-data-horizontal/tabs:pt-1.5",
|
|
1337
|
+
"group-data-vertical/tabs:py-2 group-data-vertical/tabs:px-3",
|
|
1338
|
+
"after:bg-primary",
|
|
1339
|
+
"data-active:text-primary",
|
|
1340
|
+
"dark:data-active:text-primary"
|
|
1341
|
+
].join(" ")
|
|
1342
|
+
}
|
|
1500
1343
|
};
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1344
|
+
const TabPresetContext = createContext({
|
|
1345
|
+
preset: "default",
|
|
1346
|
+
fullWidth: false
|
|
1347
|
+
});
|
|
1348
|
+
const TabsWrapper = memo(function TabsWrapper({ defaultValue, value, onValueChange, children, className, triggers, listClassName, preset = "default", fullWidth = false, orientation = "horizontal", layout = "default", ...props }) {
|
|
1349
|
+
const isFlexLayout = layout === "flex" || layout === "sidebar";
|
|
1350
|
+
const rootClassName = useMemo(() => cn("w-full", isFlexLayout && "flex-1 min-h-0", className), [isFlexLayout, className]);
|
|
1351
|
+
const listClass = useMemo(() => cn(PRESETS[preset].list, fullWidth && "w-full", listClassName), [
|
|
1352
|
+
preset,
|
|
1353
|
+
fullWidth,
|
|
1510
1354
|
listClassName
|
|
1511
1355
|
]);
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1356
|
+
return /* @__PURE__ */ jsx(TabPresetContext, {
|
|
1357
|
+
value: {
|
|
1358
|
+
preset,
|
|
1359
|
+
fullWidth
|
|
1360
|
+
},
|
|
1361
|
+
children: /* @__PURE__ */ jsxs(Tabs, {
|
|
1362
|
+
defaultValue,
|
|
1363
|
+
value,
|
|
1364
|
+
onValueChange,
|
|
1365
|
+
orientation,
|
|
1366
|
+
className: rootClassName,
|
|
1367
|
+
...props,
|
|
1368
|
+
children: [/* @__PURE__ */ jsx(TabsList, {
|
|
1369
|
+
variant: PRESET_VARIANT[preset],
|
|
1370
|
+
className: listClass,
|
|
1371
|
+
children: triggers
|
|
1372
|
+
}), children]
|
|
1373
|
+
})
|
|
1529
1374
|
});
|
|
1530
1375
|
});
|
|
1531
|
-
const TabTrigger = memo(function TabTrigger({ value, children, className,
|
|
1376
|
+
const TabTrigger = memo(function TabTrigger({ value, children, className, icon, hideTextOnMobile = false, disabled = false, ...props }) {
|
|
1377
|
+
const { preset, fullWidth } = use(TabPresetContext);
|
|
1532
1378
|
return /* @__PURE__ */ jsxs(TabsTrigger, {
|
|
1533
1379
|
value,
|
|
1534
1380
|
disabled,
|
|
1535
|
-
className: useMemo(() => cn(
|
|
1381
|
+
className: useMemo(() => cn(PRESETS[preset].trigger, fullWidth && "flex-1", className), [
|
|
1382
|
+
preset,
|
|
1383
|
+
fullWidth,
|
|
1384
|
+
className
|
|
1385
|
+
]),
|
|
1536
1386
|
...props,
|
|
1537
1387
|
children: [icon, hideTextOnMobile ? /* @__PURE__ */ jsx("span", {
|
|
1538
1388
|
className: "hidden sm:inline",
|
|
@@ -1561,77 +1411,52 @@ const TabContent = memo(function TabContent({ value, children, className, withSc
|
|
|
1561
1411
|
}) : children
|
|
1562
1412
|
});
|
|
1563
1413
|
});
|
|
1564
|
-
const DynamicTabs = memo(function DynamicTabs({ tabs = [], defaultValue, value, onValueChange,
|
|
1565
|
-
const isFlexLayout =
|
|
1566
|
-
const
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
flexList: cn("flex flex-wrap items-center justify-center gap-1 h-auto", variant === "underline" ? "rounded-none border-b border-border/60 bg-transparent p-0 shadow-none gap-6" : "rounded-md p-1 shadow-sm backdrop-blur-sm", LIST_VARIANTS[variant] ?? LIST_VARIANTS.default, useSheetDefaults && "mb-4 gap-0.5", listClassName),
|
|
1571
|
-
standardList: cn(LIST_BASE_CLASS, variant !== "underline" && "w-fit mb-6", LIST_VARIANTS[variant] ?? LIST_VARIANTS.default, listClassName),
|
|
1572
|
-
contentWrapper: cn(isFlexLayout && "flex-1 min-h-0 overflow-hidden"),
|
|
1573
|
-
flexContent: cn("mt-0 h-full", useSheetDefaults && "px-1", contentClassName),
|
|
1574
|
-
standardContent: cn(isFlexLayout ? "h-full" : "space-y-4 mt-6", contentClassName)
|
|
1575
|
-
}), [
|
|
1414
|
+
const DynamicTabs = memo(function DynamicTabs({ tabs = [], defaultValue, value, onValueChange, preset = "default", fullWidth = false, orientation = "horizontal", layout = "default", className, listClassName, contentClassName, scrollable = false, ...props }) {
|
|
1415
|
+
const isFlexLayout = layout === "flex" || layout === "sidebar";
|
|
1416
|
+
const rootClassName = useMemo(() => cn("w-full", isFlexLayout && "flex-1 min-h-0", className), [isFlexLayout, className]);
|
|
1417
|
+
const listClass = useMemo(() => cn(PRESETS[preset].list, fullWidth && "w-full", isFlexLayout && "justify-center", listClassName), [
|
|
1418
|
+
preset,
|
|
1419
|
+
fullWidth,
|
|
1576
1420
|
isFlexLayout,
|
|
1577
|
-
|
|
1578
|
-
className,
|
|
1579
|
-
listWrapperClassName,
|
|
1580
|
-
listClassName,
|
|
1581
|
-
variant,
|
|
1582
|
-
contentClassName
|
|
1421
|
+
listClassName
|
|
1583
1422
|
]);
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1423
|
+
const contentClass = useMemo(() => cn(isFlexLayout ? "mt-0 h-full" : "space-y-4 mt-6", contentClassName), [isFlexLayout, contentClassName]);
|
|
1424
|
+
const content = isFlexLayout && scrollable ? /* @__PURE__ */ jsx(ScrollArea, {
|
|
1425
|
+
className: "h-full w-full flex-1 min-h-0",
|
|
1426
|
+
children: tabs.map((tab) => /* @__PURE__ */ jsx(TabsContent, {
|
|
1427
|
+
value: tab.value,
|
|
1428
|
+
className: contentClass,
|
|
1429
|
+
children: tab.content
|
|
1430
|
+
}, tab.value))
|
|
1431
|
+
}) : tabs.map((tab) => /* @__PURE__ */ jsx(TabsContent, {
|
|
1432
|
+
value: tab.value,
|
|
1433
|
+
className: contentClass,
|
|
1434
|
+
children: tab.content
|
|
1435
|
+
}, tab.value));
|
|
1436
|
+
return /* @__PURE__ */ jsx(TabPresetContext, {
|
|
1437
|
+
value: {
|
|
1438
|
+
preset,
|
|
1439
|
+
fullWidth
|
|
1440
|
+
},
|
|
1441
|
+
children: /* @__PURE__ */ jsxs(Tabs, {
|
|
1442
|
+
defaultValue,
|
|
1443
|
+
value,
|
|
1444
|
+
onValueChange,
|
|
1445
|
+
orientation,
|
|
1446
|
+
className: rootClassName,
|
|
1447
|
+
...props,
|
|
1448
|
+
children: [/* @__PURE__ */ jsx(TabsList, {
|
|
1449
|
+
variant: PRESET_VARIANT[preset],
|
|
1450
|
+
className: listClass,
|
|
1451
|
+
children: tabs.map((tab) => /* @__PURE__ */ jsx(TabTrigger, {
|
|
1595
1452
|
value: tab.value,
|
|
1596
|
-
variant,
|
|
1597
1453
|
disabled: tab.disabled,
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
className: "hidden sm:inline",
|
|
1601
|
-
children: tab.label
|
|
1602
|
-
}) : tab.label]
|
|
1603
|
-
}, tab.value))
|
|
1604
|
-
})
|
|
1605
|
-
}) : /* @__PURE__ */ jsx(TabsList, {
|
|
1606
|
-
className: computedClasses.standardList,
|
|
1607
|
-
children: tabs.map((tab) => /* @__PURE__ */ jsxs(TabTrigger, {
|
|
1608
|
-
value: tab.value,
|
|
1609
|
-
variant,
|
|
1610
|
-
disabled: tab.disabled,
|
|
1611
|
-
className: "whitespace-nowrap",
|
|
1612
|
-
children: [tab.icon, tab.hideTextOnMobile ? /* @__PURE__ */ jsx("span", {
|
|
1613
|
-
className: "hidden sm:inline text-sm",
|
|
1614
|
-
children: tab.label
|
|
1615
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
1616
|
-
className: "text-sm",
|
|
1454
|
+
icon: tab.icon,
|
|
1455
|
+
hideTextOnMobile: tab.hideTextOnMobile,
|
|
1617
1456
|
children: tab.label
|
|
1618
|
-
})]
|
|
1619
|
-
}, tab.value))
|
|
1620
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
1621
|
-
className: computedClasses.contentWrapper,
|
|
1622
|
-
children: isFlexLayout && scrollable ? /* @__PURE__ */ jsx(ScrollArea, {
|
|
1623
|
-
className: "h-full w-full",
|
|
1624
|
-
children: tabs.map((tab) => /* @__PURE__ */ jsx(TabsContent, {
|
|
1625
|
-
value: tab.value,
|
|
1626
|
-
className: computedClasses.flexContent,
|
|
1627
|
-
children: tab.content
|
|
1628
1457
|
}, tab.value))
|
|
1629
|
-
})
|
|
1630
|
-
|
|
1631
|
-
className: computedClasses.standardContent,
|
|
1632
|
-
children: tab.content
|
|
1633
|
-
}, tab.value))
|
|
1634
|
-
})]
|
|
1458
|
+
}), content]
|
|
1459
|
+
})
|
|
1635
1460
|
});
|
|
1636
1461
|
});
|
|
1637
1462
|
|
|
@@ -1684,10 +1509,11 @@ function ResponsiveSplitLayout({ leftPanel, rightPanel, className, leftPanelClas
|
|
|
1684
1509
|
defaultValue: "left",
|
|
1685
1510
|
value: mobileView,
|
|
1686
1511
|
onValueChange: (val) => setMobileView(val),
|
|
1687
|
-
|
|
1512
|
+
preset: "default",
|
|
1513
|
+
fullWidth: true,
|
|
1688
1514
|
layout: "flex",
|
|
1689
1515
|
className: "h-full",
|
|
1690
|
-
|
|
1516
|
+
listClassName: "mx-3 mt-3 mb-1 flex-shrink-0",
|
|
1691
1517
|
contentClassName: "mt-0 flex-1 min-h-0"
|
|
1692
1518
|
})
|
|
1693
1519
|
});
|
|
@@ -1761,7 +1587,7 @@ function ResponsiveSplitLayout({ leftPanel, rightPanel, className, leftPanelClas
|
|
|
1761
1587
|
return /* @__PURE__ */ jsxs(ResizablePanelGroup, {
|
|
1762
1588
|
direction: "horizontal",
|
|
1763
1589
|
className: cn("h-full", className),
|
|
1764
|
-
autoSaveId: persistLayoutKey,
|
|
1590
|
+
...persistLayoutKey ? { autoSaveId: persistLayoutKey } : {},
|
|
1765
1591
|
children: [
|
|
1766
1592
|
/* @__PURE__ */ jsx(ResizablePanel, {
|
|
1767
1593
|
defaultSize: defaultLayout[0],
|
package/dist/client/hooks.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { t as useMediaQuery } from "../use-media-query-BnVNIKT4.mjs";
|
|
|
6
6
|
import { t as useScrollDetection } from "../use-scroll-detection-CsgsQYvy.mjs";
|
|
7
7
|
import { n as useDebouncedCallback, t as useDebounce } from "../use-debounce-xmZucz5e.mjs";
|
|
8
8
|
import { t as useKeyboardShortcut } from "../use-keyboard-shortcut-Bl6YM5Q7.mjs";
|
|
9
|
-
import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
9
|
+
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
10
10
|
import { useRouter, useSearchParams } from "next/navigation";
|
|
11
11
|
|
|
12
12
|
//#region src/hooks/use-base-search.ts
|
|
@@ -391,6 +391,30 @@ const storage = {
|
|
|
391
391
|
|
|
392
392
|
//#endregion
|
|
393
393
|
//#region src/hooks/use-local-storage.ts
|
|
394
|
+
function parseSnapshot(rawValue, initialValue) {
|
|
395
|
+
try {
|
|
396
|
+
const parsed = JSON.parse(rawValue);
|
|
397
|
+
if (parsed && typeof parsed === "object" && "__expiresAt" in parsed && typeof parsed.__expiresAt === "number") {
|
|
398
|
+
if (Date.now() > parsed.__expiresAt) return {
|
|
399
|
+
value: initialValue,
|
|
400
|
+
expired: true
|
|
401
|
+
};
|
|
402
|
+
return {
|
|
403
|
+
value: parsed.value ?? initialValue,
|
|
404
|
+
expired: false
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
return {
|
|
408
|
+
value: parsed ?? initialValue,
|
|
409
|
+
expired: false
|
|
410
|
+
};
|
|
411
|
+
} catch {
|
|
412
|
+
return {
|
|
413
|
+
value: initialValue,
|
|
414
|
+
expired: false
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
}
|
|
394
418
|
/**
|
|
395
419
|
* useLocalStorage — Persist state in localStorage with type safety and optional expiry.
|
|
396
420
|
*
|
|
@@ -411,12 +435,14 @@ const storage = {
|
|
|
411
435
|
function useLocalStorage(key, initialValue, ttl) {
|
|
412
436
|
const ttlRef = useRef(ttl);
|
|
413
437
|
ttlRef.current = ttl;
|
|
438
|
+
const initialValueRef = useRef(initialValue);
|
|
439
|
+
const serializedInitialRef = useRef(() => JSON.stringify(initialValue));
|
|
414
440
|
const getSnapshot = useCallback(() => {
|
|
415
|
-
if (typeof window === "undefined") return
|
|
416
|
-
return window.localStorage.getItem(key) ??
|
|
417
|
-
}, [key
|
|
418
|
-
const getServerSnapshot = useCallback(() =>
|
|
419
|
-
useSyncExternalStore(useCallback((onStoreChange) => {
|
|
441
|
+
if (typeof window === "undefined") return serializedInitialRef.current();
|
|
442
|
+
return window.localStorage.getItem(key) ?? serializedInitialRef.current();
|
|
443
|
+
}, [key]);
|
|
444
|
+
const getServerSnapshot = useCallback(() => serializedInitialRef.current(), []);
|
|
445
|
+
const rawValue = useSyncExternalStore(useCallback((onStoreChange) => {
|
|
420
446
|
const handleStorage = (e) => {
|
|
421
447
|
if (e.key === key || e.key === null) onStoreChange();
|
|
422
448
|
};
|
|
@@ -430,30 +456,30 @@ function useLocalStorage(key, initialValue, ttl) {
|
|
|
430
456
|
window.removeEventListener("local-storage-change", handleLocal);
|
|
431
457
|
};
|
|
432
458
|
}, [key]), getSnapshot, getServerSnapshot);
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
459
|
+
const parsedSnapshot = useMemo(() => parseSnapshot(rawValue, initialValueRef.current), [rawValue]);
|
|
460
|
+
useEffect(() => {
|
|
461
|
+
if (!parsedSnapshot.expired || typeof window === "undefined") return;
|
|
462
|
+
storage.remove(key);
|
|
463
|
+
window.dispatchEvent(new CustomEvent("local-storage-change", { detail: { key } }));
|
|
464
|
+
}, [key, parsedSnapshot.expired]);
|
|
437
465
|
const notifyChange = useCallback(() => {
|
|
438
466
|
window.dispatchEvent(new CustomEvent("local-storage-change", { detail: { key } }));
|
|
439
467
|
}, [key]);
|
|
468
|
+
const setValue = useCallback((updater) => {
|
|
469
|
+
const init = initialValueRef.current;
|
|
470
|
+
const current = parseSnapshot(typeof window === "undefined" ? JSON.stringify(init) : window.localStorage.getItem(key) ?? JSON.stringify(init), init).value;
|
|
471
|
+
const nextValue = updater instanceof Function ? updater(current) : updater;
|
|
472
|
+
storage.set(key, nextValue, ttlRef.current);
|
|
473
|
+
notifyChange();
|
|
474
|
+
}, [key, notifyChange]);
|
|
475
|
+
const removeValue = useCallback(() => {
|
|
476
|
+
storage.remove(key);
|
|
477
|
+
notifyChange();
|
|
478
|
+
}, [key, notifyChange]);
|
|
440
479
|
return [
|
|
441
|
-
value,
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
const current = currentValue !== null ? currentValue : initialValue;
|
|
445
|
-
const nextValue = updater instanceof Function ? updater(current) : updater;
|
|
446
|
-
storage.set(key, nextValue, ttlRef.current);
|
|
447
|
-
notifyChange();
|
|
448
|
-
}, [
|
|
449
|
-
key,
|
|
450
|
-
initialValue,
|
|
451
|
-
notifyChange
|
|
452
|
-
]),
|
|
453
|
-
useCallback(() => {
|
|
454
|
-
storage.remove(key);
|
|
455
|
-
notifyChange();
|
|
456
|
-
}, [key, notifyChange])
|
|
480
|
+
parsedSnapshot.value,
|
|
481
|
+
setValue,
|
|
482
|
+
removeValue
|
|
457
483
|
];
|
|
458
484
|
}
|
|
459
485
|
|