@farmzone/fz-react-ui 1.0.4 → 1.0.6
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 +199 -27
- 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 +199 -28
- 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
|
+
}
|
|
6122
6155
|
}
|
|
6123
|
-
return
|
|
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;
|
|
6161
|
+
}
|
|
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,
|
|
@@ -7602,40 +7643,35 @@ function PageFilter(props) {
|
|
|
7602
7643
|
values,
|
|
7603
7644
|
primaryColor
|
|
7604
7645
|
} = props;
|
|
7605
|
-
const [localValues, setLocalValues] = useState(values);
|
|
7606
7646
|
const initialValuesRef = useRef(values);
|
|
7607
|
-
const updateLocal = (updates) => {
|
|
7608
|
-
setLocalValues((prev) => ({ ...prev, ...updates }));
|
|
7609
|
-
};
|
|
7610
7647
|
const handleInputChange = (key) => (e) => {
|
|
7611
|
-
|
|
7648
|
+
onChange({ [key]: e.target.value });
|
|
7612
7649
|
};
|
|
7613
7650
|
const handleSelectChange = (key) => (value) => {
|
|
7614
|
-
|
|
7651
|
+
onChange({ [key]: value });
|
|
7615
7652
|
};
|
|
7616
7653
|
const handleRadioChange = (key) => (value) => {
|
|
7617
|
-
|
|
7654
|
+
onChange({ [key]: value });
|
|
7618
7655
|
};
|
|
7619
7656
|
const handleDateChange = (key) => (date) => {
|
|
7620
|
-
|
|
7657
|
+
onChange({ [key]: date });
|
|
7621
7658
|
};
|
|
7622
7659
|
const handleRangeChangeCurried = (startKey, endKey) => (start, end) => {
|
|
7623
|
-
|
|
7660
|
+
onChange({ [startKey]: start, [endKey]: end });
|
|
7624
7661
|
};
|
|
7625
7662
|
const handleCheckboxChange = (key) => (checked) => {
|
|
7626
|
-
|
|
7663
|
+
onChange({ [key]: checked ? "true" : "false" });
|
|
7627
7664
|
};
|
|
7628
7665
|
const handleSubmit = () => {
|
|
7629
|
-
onChange(localValues);
|
|
7630
7666
|
onSubmit();
|
|
7631
7667
|
};
|
|
7632
7668
|
const handleReset = () => {
|
|
7633
|
-
|
|
7669
|
+
onChange(initialValuesRef.current);
|
|
7634
7670
|
onReset?.();
|
|
7635
7671
|
};
|
|
7636
7672
|
const renderFilterOption = (option, gap, index) => {
|
|
7637
7673
|
const optionKey = option.key;
|
|
7638
|
-
const currentValue = String(
|
|
7674
|
+
const currentValue = String(values[optionKey] ?? "");
|
|
7639
7675
|
const rowGap2 = index !== 0 ? option.label ? gap : 5 : 0;
|
|
7640
7676
|
switch (option.type) {
|
|
7641
7677
|
case "input":
|
|
@@ -7710,10 +7746,7 @@ function PageFilter(props) {
|
|
|
7710
7746
|
return /* @__PURE__ */ jsx(
|
|
7711
7747
|
"div",
|
|
7712
7748
|
{
|
|
7713
|
-
className: cn(
|
|
7714
|
-
"flex flex-col gap-3 bg-white py-3 px-5 border-t-main border-t-1 shadow-panel",
|
|
7715
|
-
containerClassName
|
|
7716
|
-
),
|
|
7749
|
+
className: cn("flex flex-col gap-3 bg-white py-3 px-5 border-t-main border-t-1 shadow-panel", containerClassName),
|
|
7717
7750
|
style: primaryColor ? { borderTopColor: primaryColor } : void 0,
|
|
7718
7751
|
children: /* @__PURE__ */ jsx("div", { className: "relative flex flex-col", style: { gap: `${colGap}px` }, children: rows.map((row, ix) => {
|
|
7719
7752
|
const isLastRow = rows.length - 1 === ix;
|
|
@@ -9807,6 +9840,144 @@ function useScrollToTop(containerId) {
|
|
|
9807
9840
|
return scrollToTop;
|
|
9808
9841
|
}
|
|
9809
9842
|
|
|
9810
|
-
|
|
9843
|
+
// src/hooks/useParams/config/utils.ts
|
|
9844
|
+
function paramsToSearchParams(params) {
|
|
9845
|
+
const searchParams = new URLSearchParams();
|
|
9846
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
9847
|
+
if (value === null || value === void 0) {
|
|
9848
|
+
return;
|
|
9849
|
+
}
|
|
9850
|
+
if (Array.isArray(value)) {
|
|
9851
|
+
value.forEach((item) => searchParams.append(key, String(item)));
|
|
9852
|
+
} else if (value !== "") {
|
|
9853
|
+
searchParams.set(key, String(value));
|
|
9854
|
+
}
|
|
9855
|
+
});
|
|
9856
|
+
return searchParams;
|
|
9857
|
+
}
|
|
9858
|
+
function useParams(initialParams) {
|
|
9859
|
+
if (!initialParams) {
|
|
9860
|
+
throw new Error("initialParams is required");
|
|
9861
|
+
}
|
|
9862
|
+
const [params, setParams] = useState(initialParams);
|
|
9863
|
+
const [localParams, setLocalParams] = useState(initialParams);
|
|
9864
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
9865
|
+
const isInitializedRef = useRef(false);
|
|
9866
|
+
const getInitialState = useCallback(() => {
|
|
9867
|
+
const result = { ...initialParams };
|
|
9868
|
+
Object.keys(initialParams).forEach((key) => {
|
|
9869
|
+
const initialValue = initialParams[key];
|
|
9870
|
+
if (Array.isArray(initialValue)) {
|
|
9871
|
+
const urlValue = searchParams.getAll(key);
|
|
9872
|
+
if (urlValue.length > 0) {
|
|
9873
|
+
result[key] = urlValue;
|
|
9874
|
+
}
|
|
9875
|
+
} else {
|
|
9876
|
+
const urlValue = searchParams.get(key);
|
|
9877
|
+
if (urlValue !== null) {
|
|
9878
|
+
if (urlValue === "null") {
|
|
9879
|
+
result[key] = null;
|
|
9880
|
+
} else if (urlValue === "undefined") {
|
|
9881
|
+
result[key] = void 0;
|
|
9882
|
+
} else {
|
|
9883
|
+
result[key] = urlValue;
|
|
9884
|
+
}
|
|
9885
|
+
}
|
|
9886
|
+
}
|
|
9887
|
+
});
|
|
9888
|
+
return result;
|
|
9889
|
+
}, [initialParams, searchParams]);
|
|
9890
|
+
useEffect(() => {
|
|
9891
|
+
if (!isInitializedRef.current) {
|
|
9892
|
+
const initialState = getInitialState();
|
|
9893
|
+
setLocalParams(initialState);
|
|
9894
|
+
setParams(initialState);
|
|
9895
|
+
if (!searchParams.toString()) {
|
|
9896
|
+
const newSearchParams = paramsToSearchParams(initialParams);
|
|
9897
|
+
setSearchParams(newSearchParams, { replace: true });
|
|
9898
|
+
}
|
|
9899
|
+
isInitializedRef.current = true;
|
|
9900
|
+
}
|
|
9901
|
+
}, [getInitialState, initialParams, searchParams, setSearchParams]);
|
|
9902
|
+
const updateLocalParam = useCallback(
|
|
9903
|
+
(key, value) => {
|
|
9904
|
+
setLocalParams((prev) => ({
|
|
9905
|
+
...prev,
|
|
9906
|
+
[key]: value
|
|
9907
|
+
}));
|
|
9908
|
+
},
|
|
9909
|
+
[setLocalParams]
|
|
9910
|
+
);
|
|
9911
|
+
const updateParams = useCallback(
|
|
9912
|
+
(updatedParams) => {
|
|
9913
|
+
const newParams = {
|
|
9914
|
+
...params,
|
|
9915
|
+
...updatedParams
|
|
9916
|
+
};
|
|
9917
|
+
setParams(newParams);
|
|
9918
|
+
setLocalParams(newParams);
|
|
9919
|
+
setSearchParams(paramsToSearchParams(newParams));
|
|
9920
|
+
},
|
|
9921
|
+
[params, setSearchParams]
|
|
9922
|
+
);
|
|
9923
|
+
const updateParam = useCallback(
|
|
9924
|
+
(key, value) => {
|
|
9925
|
+
const newParams = {
|
|
9926
|
+
...params,
|
|
9927
|
+
[key]: value
|
|
9928
|
+
};
|
|
9929
|
+
setParams(newParams);
|
|
9930
|
+
setLocalParams(newParams);
|
|
9931
|
+
setSearchParams(paramsToSearchParams(newParams));
|
|
9932
|
+
},
|
|
9933
|
+
[params, setSearchParams]
|
|
9934
|
+
);
|
|
9935
|
+
const update = useCallback(() => {
|
|
9936
|
+
const paramsWithResetPage = {
|
|
9937
|
+
...localParams,
|
|
9938
|
+
page: 0
|
|
9939
|
+
};
|
|
9940
|
+
const newSearchParams = paramsToSearchParams(paramsWithResetPage);
|
|
9941
|
+
setSearchParams(newSearchParams);
|
|
9942
|
+
setParams(paramsWithResetPage);
|
|
9943
|
+
setLocalParams(paramsWithResetPage);
|
|
9944
|
+
}, [localParams, setSearchParams]);
|
|
9945
|
+
const reset = useCallback(() => {
|
|
9946
|
+
setLocalParams(initialParams);
|
|
9947
|
+
setParams(initialParams);
|
|
9948
|
+
const newSearchParams = paramsToSearchParams(initialParams);
|
|
9949
|
+
setSearchParams(newSearchParams);
|
|
9950
|
+
}, [initialParams, setSearchParams]);
|
|
9951
|
+
const handleSortChange = useCallback(
|
|
9952
|
+
(sortKey, sortOrder) => {
|
|
9953
|
+
const newParams = {
|
|
9954
|
+
...params,
|
|
9955
|
+
sortBy: sortKey,
|
|
9956
|
+
sortOrder
|
|
9957
|
+
};
|
|
9958
|
+
updateParams(newParams);
|
|
9959
|
+
},
|
|
9960
|
+
[updateParams, params]
|
|
9961
|
+
);
|
|
9962
|
+
const sortOption = useMemo(() => {
|
|
9963
|
+
if (!params.sortBy || !params.sortOrder) return void 0;
|
|
9964
|
+
return {
|
|
9965
|
+
sortKey: params.sortBy,
|
|
9966
|
+
sortOrder: params.sortOrder
|
|
9967
|
+
};
|
|
9968
|
+
}, [params.sortBy, params.sortOrder]);
|
|
9969
|
+
return {
|
|
9970
|
+
localParams,
|
|
9971
|
+
params,
|
|
9972
|
+
updateParam,
|
|
9973
|
+
updateLocalParam,
|
|
9974
|
+
update,
|
|
9975
|
+
reset,
|
|
9976
|
+
handleSortChange,
|
|
9977
|
+
sortOption
|
|
9978
|
+
};
|
|
9979
|
+
}
|
|
9980
|
+
|
|
9981
|
+
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
9982
|
//# sourceMappingURL=index.js.map
|
|
9812
9983
|
//# sourceMappingURL=index.js.map
|