@farmzone/fz-react-ui 1.0.4 → 1.0.5
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.cjs +190 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +190 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -613,7 +613,16 @@ interface TableFooterProps {
|
|
|
613
613
|
renderRight?: ReactNode;
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
+
interface PageParams {
|
|
617
|
+
page: number;
|
|
618
|
+
size: number;
|
|
619
|
+
}
|
|
616
620
|
type SortOrder = "asc" | "desc";
|
|
621
|
+
interface SortParams {
|
|
622
|
+
sortBy: string;
|
|
623
|
+
sortOrder: SortOrder;
|
|
624
|
+
}
|
|
625
|
+
type BaseParams = PageParams & SortParams;
|
|
617
626
|
|
|
618
627
|
type TableFixed = "left" | "right";
|
|
619
628
|
interface SortOption {
|
|
@@ -1329,6 +1338,18 @@ declare function useFilePreviewViewer<T extends string = string>(files: FilePrev
|
|
|
1329
1338
|
viewerProps: FilePreviewViewerProps<T>;
|
|
1330
1339
|
};
|
|
1331
1340
|
|
|
1341
|
+
interface UseParams<P extends BaseParams> {
|
|
1342
|
+
localParams: P;
|
|
1343
|
+
params: P;
|
|
1344
|
+
updateParam: (key: keyof P, value: P[keyof P]) => void;
|
|
1345
|
+
updateLocalParam: (key: keyof P, value: P[keyof P]) => void;
|
|
1346
|
+
update: () => void;
|
|
1347
|
+
reset: () => void;
|
|
1348
|
+
handleSortChange: (sortKey: string, sortOrder: SortOrder) => void;
|
|
1349
|
+
sortOption: SortOption | undefined;
|
|
1350
|
+
}
|
|
1351
|
+
declare function useParams<P extends BaseParams>(initialParams: P): UseParams<P>;
|
|
1352
|
+
|
|
1332
1353
|
interface ArrowIconProps extends SVGProps<SVGSVGElement> {
|
|
1333
1354
|
direction?: "up" | "down";
|
|
1334
1355
|
}
|
|
@@ -1373,4 +1394,4 @@ declare const Z_INDEX: {
|
|
|
1373
1394
|
};
|
|
1374
1395
|
type ZIndexKey = keyof typeof Z_INDEX;
|
|
1375
1396
|
|
|
1376
|
-
export { ArrowIcon, Badge, type BadgeProps, BaseUploader, type BaseUploaderProps, BreadCrumb, type BreadCrumbItem, type BreadCrumbMenuItem, type BreadCrumbProps, type BreadCrumbRoot, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CalendarYearRange, Carousel, type CarouselProps, type CarouselRef, Checkbox, type CheckboxProps, type Column, type ConfirmOptions, DatePicker, DebouncedButton, type DebouncedButtonProps, DetailContent, type DetailContentProps, type DetailField, type DetailFieldOrSection, DetailModalFrame, type DetailMode, DetailPageFrame, Empty, ExcelUploader, FilePreviewViewer, FileUploader, type FilterRow, type FormFieldConfig, Input, type InputProps, Loading, LoadingOverlay, type LoadingOverlayProps, type LoadingProps, type MenuChild, type MenuGrandchild, type MenuItem, type MenuSection, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, ModalIconHeader, type ModalIconHeaderProps, ModalOverlay, type ModalProps, type ModalType, MultiTabBar as MultiTab, type MultiTab as MultiTabItem, PageFilter, Pagination, type PaginationProps, Popover, type PopoverAlign, PopoverAnchor, PopoverClose, PopoverContent, type PopoverContentProps, PopoverDescription, PopoverFooter, PopoverHeader, type PopoverPosition, PopoverTitle, PopoverTrigger, Radio, RadioGroup, type RadioGroupProps, type RadioOptionType, type RadioProps, ScrollArea, ScrollBar, SearchAddress, type SearchAddressProps, SearchBar, type SearchBarProps, Select, Select$1 as SelectBase, SelectContent, SelectGroup, SelectItem, SelectLabel, type SelectOptionType, type SelectProps, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Sidebar, type SidebarProps, SimplePopover, type SimplePopoverProps, Skeleton, type SkeletonProps, Slider, type SliderProps, type SortOption, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, SubmitForm, Switch, type SwitchProps, Tab, type TabItem, type TabProps, Table, Textarea, type TextareaProps, type ToastPosition, type ToastProps, ToastProvider, type ToastType, ToggleSwitch, Tooltip, type TooltipProps, type YmdDateString, type ZIndexKey, Z_INDEX, buildBreadCrumbItems, buttonVariants, cn, confirmModal, findParentMenuItem, findParentMenuName, formatDate, getFileLabel, getPreviewFileType, isCalendarDayAfterMax, isDateInRange, switchTrackSizes, textVariants, toast, useBlockModalConfirm, useBreadCrumbItems, useCustomBlocker, useDetailController, useFilePreviewViewer, useModal, useMultiTabStore, useScrollToTop, useStableImageSrc, useToast, validateAndFormatInput };
|
|
1397
|
+
export { ArrowIcon, Badge, type BadgeProps, type BaseParams, BaseUploader, type BaseUploaderProps, BreadCrumb, type BreadCrumbItem, type BreadCrumbMenuItem, type BreadCrumbProps, type BreadCrumbRoot, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CalendarYearRange, Carousel, type CarouselProps, type CarouselRef, Checkbox, type CheckboxProps, type Column, type ConfirmOptions, DatePicker, DebouncedButton, type DebouncedButtonProps, DetailContent, type DetailContentProps, type DetailField, type DetailFieldOrSection, DetailModalFrame, type DetailMode, DetailPageFrame, Empty, ExcelUploader, FilePreviewViewer, FileUploader, type FilterRow, type FormFieldConfig, Input, type InputProps, Loading, LoadingOverlay, type LoadingOverlayProps, type LoadingProps, type MenuChild, type MenuGrandchild, type MenuItem, type MenuSection, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, ModalIconHeader, type ModalIconHeaderProps, ModalOverlay, type ModalProps, type ModalType, MultiTabBar as MultiTab, type MultiTab as MultiTabItem, PageFilter, type PageParams, Pagination, type PaginationProps, Popover, type PopoverAlign, PopoverAnchor, PopoverClose, PopoverContent, type PopoverContentProps, PopoverDescription, PopoverFooter, PopoverHeader, type PopoverPosition, PopoverTitle, PopoverTrigger, Radio, RadioGroup, type RadioGroupProps, type RadioOptionType, type RadioProps, ScrollArea, ScrollBar, SearchAddress, type SearchAddressProps, SearchBar, type SearchBarProps, Select, Select$1 as SelectBase, SelectContent, SelectGroup, SelectItem, SelectLabel, type SelectOptionType, type SelectProps, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Sidebar, type SidebarProps, SimplePopover, type SimplePopoverProps, Skeleton, type SkeletonProps, Slider, type SliderProps, type SortOption, type SortOrder, type SortParams, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, SubmitForm, Switch, type SwitchProps, Tab, type TabItem, type TabProps, Table, Textarea, type TextareaProps, type ToastPosition, type ToastProps, ToastProvider, type ToastType, ToggleSwitch, Tooltip, type TooltipProps, type UseParams, type YmdDateString, type ZIndexKey, Z_INDEX, buildBreadCrumbItems, buttonVariants, cn, confirmModal, findParentMenuItem, findParentMenuName, formatDate, getFileLabel, getPreviewFileType, isCalendarDayAfterMax, isDateInRange, switchTrackSizes, textVariants, toast, useBlockModalConfirm, useBreadCrumbItems, useCustomBlocker, useDetailController, useFilePreviewViewer, useModal, useMultiTabStore, useParams, useScrollToTop, useStableImageSrc, useToast, validateAndFormatInput };
|
package/dist/index.d.ts
CHANGED
|
@@ -613,7 +613,16 @@ interface TableFooterProps {
|
|
|
613
613
|
renderRight?: ReactNode;
|
|
614
614
|
}
|
|
615
615
|
|
|
616
|
+
interface PageParams {
|
|
617
|
+
page: number;
|
|
618
|
+
size: number;
|
|
619
|
+
}
|
|
616
620
|
type SortOrder = "asc" | "desc";
|
|
621
|
+
interface SortParams {
|
|
622
|
+
sortBy: string;
|
|
623
|
+
sortOrder: SortOrder;
|
|
624
|
+
}
|
|
625
|
+
type BaseParams = PageParams & SortParams;
|
|
617
626
|
|
|
618
627
|
type TableFixed = "left" | "right";
|
|
619
628
|
interface SortOption {
|
|
@@ -1329,6 +1338,18 @@ declare function useFilePreviewViewer<T extends string = string>(files: FilePrev
|
|
|
1329
1338
|
viewerProps: FilePreviewViewerProps<T>;
|
|
1330
1339
|
};
|
|
1331
1340
|
|
|
1341
|
+
interface UseParams<P extends BaseParams> {
|
|
1342
|
+
localParams: P;
|
|
1343
|
+
params: P;
|
|
1344
|
+
updateParam: (key: keyof P, value: P[keyof P]) => void;
|
|
1345
|
+
updateLocalParam: (key: keyof P, value: P[keyof P]) => void;
|
|
1346
|
+
update: () => void;
|
|
1347
|
+
reset: () => void;
|
|
1348
|
+
handleSortChange: (sortKey: string, sortOrder: SortOrder) => void;
|
|
1349
|
+
sortOption: SortOption | undefined;
|
|
1350
|
+
}
|
|
1351
|
+
declare function useParams<P extends BaseParams>(initialParams: P): UseParams<P>;
|
|
1352
|
+
|
|
1332
1353
|
interface ArrowIconProps extends SVGProps<SVGSVGElement> {
|
|
1333
1354
|
direction?: "up" | "down";
|
|
1334
1355
|
}
|
|
@@ -1373,4 +1394,4 @@ declare const Z_INDEX: {
|
|
|
1373
1394
|
};
|
|
1374
1395
|
type ZIndexKey = keyof typeof Z_INDEX;
|
|
1375
1396
|
|
|
1376
|
-
export { ArrowIcon, Badge, type BadgeProps, BaseUploader, type BaseUploaderProps, BreadCrumb, type BreadCrumbItem, type BreadCrumbMenuItem, type BreadCrumbProps, type BreadCrumbRoot, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CalendarYearRange, Carousel, type CarouselProps, type CarouselRef, Checkbox, type CheckboxProps, type Column, type ConfirmOptions, DatePicker, DebouncedButton, type DebouncedButtonProps, DetailContent, type DetailContentProps, type DetailField, type DetailFieldOrSection, DetailModalFrame, type DetailMode, DetailPageFrame, Empty, ExcelUploader, FilePreviewViewer, FileUploader, type FilterRow, type FormFieldConfig, Input, type InputProps, Loading, LoadingOverlay, type LoadingOverlayProps, type LoadingProps, type MenuChild, type MenuGrandchild, type MenuItem, type MenuSection, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, ModalIconHeader, type ModalIconHeaderProps, ModalOverlay, type ModalProps, type ModalType, MultiTabBar as MultiTab, type MultiTab as MultiTabItem, PageFilter, Pagination, type PaginationProps, Popover, type PopoverAlign, PopoverAnchor, PopoverClose, PopoverContent, type PopoverContentProps, PopoverDescription, PopoverFooter, PopoverHeader, type PopoverPosition, PopoverTitle, PopoverTrigger, Radio, RadioGroup, type RadioGroupProps, type RadioOptionType, type RadioProps, ScrollArea, ScrollBar, SearchAddress, type SearchAddressProps, SearchBar, type SearchBarProps, Select, Select$1 as SelectBase, SelectContent, SelectGroup, SelectItem, SelectLabel, type SelectOptionType, type SelectProps, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Sidebar, type SidebarProps, SimplePopover, type SimplePopoverProps, Skeleton, type SkeletonProps, Slider, type SliderProps, type SortOption, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, SubmitForm, Switch, type SwitchProps, Tab, type TabItem, type TabProps, Table, Textarea, type TextareaProps, type ToastPosition, type ToastProps, ToastProvider, type ToastType, ToggleSwitch, Tooltip, type TooltipProps, type YmdDateString, type ZIndexKey, Z_INDEX, buildBreadCrumbItems, buttonVariants, cn, confirmModal, findParentMenuItem, findParentMenuName, formatDate, getFileLabel, getPreviewFileType, isCalendarDayAfterMax, isDateInRange, switchTrackSizes, textVariants, toast, useBlockModalConfirm, useBreadCrumbItems, useCustomBlocker, useDetailController, useFilePreviewViewer, useModal, useMultiTabStore, useScrollToTop, useStableImageSrc, useToast, validateAndFormatInput };
|
|
1397
|
+
export { ArrowIcon, Badge, type BadgeProps, type BaseParams, BaseUploader, type BaseUploaderProps, BreadCrumb, type BreadCrumbItem, type BreadCrumbMenuItem, type BreadCrumbProps, type BreadCrumbRoot, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CalendarYearRange, Carousel, type CarouselProps, type CarouselRef, Checkbox, type CheckboxProps, type Column, type ConfirmOptions, DatePicker, DebouncedButton, type DebouncedButtonProps, DetailContent, type DetailContentProps, type DetailField, type DetailFieldOrSection, DetailModalFrame, type DetailMode, DetailPageFrame, Empty, ExcelUploader, FilePreviewViewer, FileUploader, type FilterRow, type FormFieldConfig, Input, type InputProps, Loading, LoadingOverlay, type LoadingOverlayProps, type LoadingProps, type MenuChild, type MenuGrandchild, type MenuItem, type MenuSection, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, ModalIconHeader, type ModalIconHeaderProps, ModalOverlay, type ModalProps, type ModalType, MultiTabBar as MultiTab, type MultiTab as MultiTabItem, PageFilter, type PageParams, Pagination, type PaginationProps, Popover, type PopoverAlign, PopoverAnchor, PopoverClose, PopoverContent, type PopoverContentProps, PopoverDescription, PopoverFooter, PopoverHeader, type PopoverPosition, PopoverTitle, PopoverTrigger, Radio, RadioGroup, type RadioGroupProps, type RadioOptionType, type RadioProps, ScrollArea, ScrollBar, SearchAddress, type SearchAddressProps, SearchBar, type SearchBarProps, Select, Select$1 as SelectBase, SelectContent, SelectGroup, SelectItem, SelectLabel, type SelectOptionType, type SelectProps, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Sidebar, type SidebarProps, SimplePopover, type SimplePopoverProps, Skeleton, type SkeletonProps, Slider, type SliderProps, type SortOption, type SortOrder, type SortParams, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, SubmitForm, Switch, type SwitchProps, Tab, type TabItem, type TabProps, Table, Textarea, type TextareaProps, type ToastPosition, type ToastProps, ToastProvider, type ToastType, ToggleSwitch, Tooltip, type TooltipProps, type UseParams, type YmdDateString, type ZIndexKey, Z_INDEX, buildBreadCrumbItems, buttonVariants, cn, confirmModal, findParentMenuItem, findParentMenuName, formatDate, getFileLabel, getPreviewFileType, isCalendarDayAfterMax, isDateInRange, switchTrackSizes, textVariants, toast, useBlockModalConfirm, useBreadCrumbItems, useCustomBlocker, useDetailController, useFilePreviewViewer, useModal, useMultiTabStore, useParams, useScrollToTop, useStableImageSrc, useToast, validateAndFormatInput };
|
package/dist/index.js
CHANGED
|
@@ -4985,7 +4985,7 @@ function Table(props) {
|
|
|
4985
4985
|
id: `${col.key}-body`,
|
|
4986
4986
|
"data-row-cell": "true",
|
|
4987
4987
|
"data-col-key": col.key,
|
|
4988
|
-
className: `${isCheckbox ? "p-0" : "px-2 py-
|
|
4988
|
+
className: `${isCheckbox ? "p-0" : "px-2 py-3"} whitespace-nowrap text-sm text-gray-900 border-r border-b border-gray-200 last:border-r-0 bg-inherit group-hover:bg-gray-100 transition-all`,
|
|
4989
4989
|
style: {
|
|
4990
4990
|
width,
|
|
4991
4991
|
minWidth: minWidth || width,
|
|
@@ -6113,14 +6113,53 @@ function resolveValueColSpan(colspan) {
|
|
|
6113
6113
|
const span = colspan ?? 10;
|
|
6114
6114
|
return COL_SPAN_CLASS[span] ?? COL_SPAN_CLASS[10];
|
|
6115
6115
|
}
|
|
6116
|
+
var THREE_DIGIT_AREA_CODES = /* @__PURE__ */ new Set([
|
|
6117
|
+
"031",
|
|
6118
|
+
"032",
|
|
6119
|
+
"033",
|
|
6120
|
+
"041",
|
|
6121
|
+
"042",
|
|
6122
|
+
"043",
|
|
6123
|
+
"051",
|
|
6124
|
+
"052",
|
|
6125
|
+
"053",
|
|
6126
|
+
"054",
|
|
6127
|
+
"055",
|
|
6128
|
+
"061",
|
|
6129
|
+
"062",
|
|
6130
|
+
"063"
|
|
6131
|
+
]);
|
|
6116
6132
|
function formatPhoneNumber(value) {
|
|
6117
|
-
|
|
6118
|
-
if (
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6133
|
+
let digits = value.replace(/\D/g, "");
|
|
6134
|
+
if (digits.startsWith("02")) {
|
|
6135
|
+
if (digits.length > 2 && digits.length <= 6) {
|
|
6136
|
+
return `${digits.slice(0, 2)}-${digits.slice(2)}`;
|
|
6137
|
+
}
|
|
6138
|
+
if (digits.length > 6) {
|
|
6139
|
+
return `${digits.slice(0, 2)}-${digits.slice(2, 6)}-${digits.slice(6)}`;
|
|
6140
|
+
}
|
|
6141
|
+
} else if (THREE_DIGIT_AREA_CODES.has(digits.slice(0, 3))) {
|
|
6142
|
+
if (digits.length > 3 && digits.length <= 6) {
|
|
6143
|
+
return `${digits.slice(0, 3)}-${digits.slice(3)}`;
|
|
6144
|
+
}
|
|
6145
|
+
if (digits.length > 6) {
|
|
6146
|
+
return `${digits.slice(0, 3)}-${digits.slice(3, 6)}-${digits.slice(6)}`;
|
|
6147
|
+
}
|
|
6148
|
+
} else {
|
|
6149
|
+
if (digits.length > 3 && digits.length <= 7) {
|
|
6150
|
+
return `${digits.slice(0, 3)}-${digits.slice(3)}`;
|
|
6151
|
+
}
|
|
6152
|
+
if (digits.length > 7) {
|
|
6153
|
+
return `${digits.slice(0, 3)}-${digits.slice(3, 7)}-${digits.slice(7)}`;
|
|
6154
|
+
}
|
|
6155
|
+
}
|
|
6156
|
+
return digits;
|
|
6157
|
+
}
|
|
6158
|
+
function resolvePhoneMaxLength(formattedValue) {
|
|
6159
|
+
if (formattedValue.startsWith("02") || THREE_DIGIT_AREA_CODES.has(formattedValue.slice(0, 3))) {
|
|
6160
|
+
return 12;
|
|
6122
6161
|
}
|
|
6123
|
-
return
|
|
6162
|
+
return 13;
|
|
6124
6163
|
}
|
|
6125
6164
|
function formatNumberWithCommas(value) {
|
|
6126
6165
|
const numStr = String(value).replace(/,/g, "");
|
|
@@ -6944,11 +6983,13 @@ function PhoneField(props) {
|
|
|
6944
6983
|
hasError = false
|
|
6945
6984
|
} = props;
|
|
6946
6985
|
const { placeholder = "010-0000-0000", disabled = false, readOnly = false, className = "" } = config;
|
|
6986
|
+
const phoneValue = String(value ?? "");
|
|
6987
|
+
const phoneMaxLength = resolvePhoneMaxLength(phoneValue);
|
|
6947
6988
|
const handleChange = (e) => {
|
|
6948
6989
|
onChange(formatPhoneNumber(e.target.value));
|
|
6949
6990
|
};
|
|
6950
6991
|
if (readOnly) {
|
|
6951
|
-
return /* @__PURE__ */ jsx("div", { className: fieldControlWrapClass(className), children: /* @__PURE__ */ jsx("span", { className: FIELD_READONLY_TEXT_CLASS, children:
|
|
6992
|
+
return /* @__PURE__ */ jsx("div", { className: fieldControlWrapClass(className), children: /* @__PURE__ */ jsx("span", { className: FIELD_READONLY_TEXT_CLASS, children: phoneValue || "\u2014" }) });
|
|
6952
6993
|
}
|
|
6953
6994
|
return /* @__PURE__ */ jsx("div", { className: fieldControlWrapClass(className), children: /* @__PURE__ */ jsx(
|
|
6954
6995
|
Input2,
|
|
@@ -6956,12 +6997,12 @@ function PhoneField(props) {
|
|
|
6956
6997
|
name,
|
|
6957
6998
|
ref,
|
|
6958
6999
|
onBlur,
|
|
6959
|
-
value:
|
|
7000
|
+
value: phoneValue,
|
|
6960
7001
|
type: "text",
|
|
6961
7002
|
placeholder,
|
|
6962
7003
|
disabled,
|
|
6963
7004
|
readOnly,
|
|
6964
|
-
maxLength:
|
|
7005
|
+
maxLength: phoneMaxLength,
|
|
6965
7006
|
status: "default",
|
|
6966
7007
|
className: formControlClass(hasError),
|
|
6967
7008
|
bare: true,
|
|
@@ -9807,6 +9848,144 @@ function useScrollToTop(containerId) {
|
|
|
9807
9848
|
return scrollToTop;
|
|
9808
9849
|
}
|
|
9809
9850
|
|
|
9810
|
-
|
|
9851
|
+
// src/hooks/useParams/config/utils.ts
|
|
9852
|
+
function paramsToSearchParams(params) {
|
|
9853
|
+
const searchParams = new URLSearchParams();
|
|
9854
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
9855
|
+
if (value === null || value === void 0) {
|
|
9856
|
+
return;
|
|
9857
|
+
}
|
|
9858
|
+
if (Array.isArray(value)) {
|
|
9859
|
+
value.forEach((item) => searchParams.append(key, String(item)));
|
|
9860
|
+
} else if (value !== "") {
|
|
9861
|
+
searchParams.set(key, String(value));
|
|
9862
|
+
}
|
|
9863
|
+
});
|
|
9864
|
+
return searchParams;
|
|
9865
|
+
}
|
|
9866
|
+
function useParams(initialParams) {
|
|
9867
|
+
if (!initialParams) {
|
|
9868
|
+
throw new Error("initialParams is required");
|
|
9869
|
+
}
|
|
9870
|
+
const [params, setParams] = useState(initialParams);
|
|
9871
|
+
const [localParams, setLocalParams] = useState(initialParams);
|
|
9872
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
9873
|
+
const isInitializedRef = useRef(false);
|
|
9874
|
+
const getInitialState = useCallback(() => {
|
|
9875
|
+
const result = { ...initialParams };
|
|
9876
|
+
Object.keys(initialParams).forEach((key) => {
|
|
9877
|
+
const initialValue = initialParams[key];
|
|
9878
|
+
if (Array.isArray(initialValue)) {
|
|
9879
|
+
const urlValue = searchParams.getAll(key);
|
|
9880
|
+
if (urlValue.length > 0) {
|
|
9881
|
+
result[key] = urlValue;
|
|
9882
|
+
}
|
|
9883
|
+
} else {
|
|
9884
|
+
const urlValue = searchParams.get(key);
|
|
9885
|
+
if (urlValue !== null) {
|
|
9886
|
+
if (urlValue === "null") {
|
|
9887
|
+
result[key] = null;
|
|
9888
|
+
} else if (urlValue === "undefined") {
|
|
9889
|
+
result[key] = void 0;
|
|
9890
|
+
} else {
|
|
9891
|
+
result[key] = urlValue;
|
|
9892
|
+
}
|
|
9893
|
+
}
|
|
9894
|
+
}
|
|
9895
|
+
});
|
|
9896
|
+
return result;
|
|
9897
|
+
}, [initialParams, searchParams]);
|
|
9898
|
+
useEffect(() => {
|
|
9899
|
+
if (!isInitializedRef.current) {
|
|
9900
|
+
const initialState = getInitialState();
|
|
9901
|
+
setLocalParams(initialState);
|
|
9902
|
+
setParams(initialState);
|
|
9903
|
+
if (!searchParams.toString()) {
|
|
9904
|
+
const newSearchParams = paramsToSearchParams(initialParams);
|
|
9905
|
+
setSearchParams(newSearchParams, { replace: true });
|
|
9906
|
+
}
|
|
9907
|
+
isInitializedRef.current = true;
|
|
9908
|
+
}
|
|
9909
|
+
}, [getInitialState, initialParams, searchParams, setSearchParams]);
|
|
9910
|
+
const updateLocalParam = useCallback(
|
|
9911
|
+
(key, value) => {
|
|
9912
|
+
setLocalParams((prev) => ({
|
|
9913
|
+
...prev,
|
|
9914
|
+
[key]: value
|
|
9915
|
+
}));
|
|
9916
|
+
},
|
|
9917
|
+
[setLocalParams]
|
|
9918
|
+
);
|
|
9919
|
+
const updateParams = useCallback(
|
|
9920
|
+
(updatedParams) => {
|
|
9921
|
+
const newParams = {
|
|
9922
|
+
...params,
|
|
9923
|
+
...updatedParams
|
|
9924
|
+
};
|
|
9925
|
+
setParams(newParams);
|
|
9926
|
+
setLocalParams(newParams);
|
|
9927
|
+
setSearchParams(paramsToSearchParams(newParams));
|
|
9928
|
+
},
|
|
9929
|
+
[params, setSearchParams]
|
|
9930
|
+
);
|
|
9931
|
+
const updateParam = useCallback(
|
|
9932
|
+
(key, value) => {
|
|
9933
|
+
const newParams = {
|
|
9934
|
+
...params,
|
|
9935
|
+
[key]: value
|
|
9936
|
+
};
|
|
9937
|
+
setParams(newParams);
|
|
9938
|
+
setLocalParams(newParams);
|
|
9939
|
+
setSearchParams(paramsToSearchParams(newParams));
|
|
9940
|
+
},
|
|
9941
|
+
[params, setSearchParams]
|
|
9942
|
+
);
|
|
9943
|
+
const update = useCallback(() => {
|
|
9944
|
+
const paramsWithResetPage = {
|
|
9945
|
+
...localParams,
|
|
9946
|
+
page: 0
|
|
9947
|
+
};
|
|
9948
|
+
const newSearchParams = paramsToSearchParams(paramsWithResetPage);
|
|
9949
|
+
setSearchParams(newSearchParams);
|
|
9950
|
+
setParams(paramsWithResetPage);
|
|
9951
|
+
setLocalParams(paramsWithResetPage);
|
|
9952
|
+
}, [localParams, setSearchParams]);
|
|
9953
|
+
const reset = useCallback(() => {
|
|
9954
|
+
setLocalParams(initialParams);
|
|
9955
|
+
setParams(initialParams);
|
|
9956
|
+
const newSearchParams = paramsToSearchParams(initialParams);
|
|
9957
|
+
setSearchParams(newSearchParams);
|
|
9958
|
+
}, [initialParams, setSearchParams]);
|
|
9959
|
+
const handleSortChange = useCallback(
|
|
9960
|
+
(sortKey, sortOrder) => {
|
|
9961
|
+
const newParams = {
|
|
9962
|
+
...params,
|
|
9963
|
+
sortBy: sortKey,
|
|
9964
|
+
sortOrder
|
|
9965
|
+
};
|
|
9966
|
+
updateParams(newParams);
|
|
9967
|
+
},
|
|
9968
|
+
[updateParams, params]
|
|
9969
|
+
);
|
|
9970
|
+
const sortOption = useMemo(() => {
|
|
9971
|
+
if (!params.sortBy || !params.sortOrder) return void 0;
|
|
9972
|
+
return {
|
|
9973
|
+
sortKey: params.sortBy,
|
|
9974
|
+
sortOrder: params.sortOrder
|
|
9975
|
+
};
|
|
9976
|
+
}, [params.sortBy, params.sortOrder]);
|
|
9977
|
+
return {
|
|
9978
|
+
localParams,
|
|
9979
|
+
params,
|
|
9980
|
+
updateParam,
|
|
9981
|
+
updateLocalParam,
|
|
9982
|
+
update,
|
|
9983
|
+
reset,
|
|
9984
|
+
handleSortChange,
|
|
9985
|
+
sortOption
|
|
9986
|
+
};
|
|
9987
|
+
}
|
|
9988
|
+
|
|
9989
|
+
export { ArrowIcon, Badge, BaseUploader, BreadCrumb, Button, Carousel_default as Carousel, Checkbox, DatePicker, DebouncedButton, DetailContent, DetailModalFrame, DetailPageFrame, Empty, ExcelUploader, FilePreviewViewer, FileUploader, Input2 as Input, Loading, LoadingOverlay, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, ModalIconHeader, ModalOverlay, MultiTabBar as MultiTab, PageFilter, Pagination, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverDescription, PopoverFooter, PopoverHeader, PopoverTitle, PopoverTrigger, Radio, RadioGroup, ScrollArea_default as ScrollArea, ScrollBar, SearchAddress, SearchBar, Select2 as Select, Select as SelectBase, SelectContent, SelectGroup2 as SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Sidebar, SimplePopover, Skeleton, Slider, Spinner, SubmitForm, Switch, Tab, Table, Textarea, ToastProvider, ToggleSwitch, Tooltip2 as Tooltip, Z_INDEX, buildBreadCrumbItems, buttonVariants, cn, confirmModal, findParentMenuItem, findParentMenuName, formatDate, getFileLabel, getPreviewFileType, isCalendarDayAfterMax, isDateInRange, switchTrackSizes, textVariants, toast, useBlockModalConfirm, useBreadCrumbItems, useCustomBlocker, useDetailController, useFilePreviewViewer, useModal, useMultiTabStore, useParams, useScrollToTop, useStableImageSrc, useToast, validateAndFormatInput };
|
|
9811
9990
|
//# sourceMappingURL=index.js.map
|
|
9812
9991
|
//# sourceMappingURL=index.js.map
|