abrplus-ui-kit 0.2.9
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/README.md +159 -0
- package/dist/antOverrides.cjs.js +127 -0
- package/dist/antOverrides.es.js +127 -0
- package/dist/atoms.cjs.js +391 -0
- package/dist/atoms.es.js +392 -0
- package/dist/colors-CztsZ6e_.js +2213 -0
- package/dist/colors-TPZkyKI4.cjs +2212 -0
- package/dist/deepMerge-CG1he8ZD.js +20 -0
- package/dist/deepMerge-Cn27K7-s.cjs +19 -0
- package/dist/index-2Q5IExhU.cjs +89 -0
- package/dist/index-BOfdgXvN.cjs +265 -0
- package/dist/index-BnnlMHRY.cjs +27 -0
- package/dist/index-BzahloOb.js +28 -0
- package/dist/index-C24zbKLS.js +350 -0
- package/dist/index-CCvWoynu.cjs +12 -0
- package/dist/index-CQKRmQkW.js +543 -0
- package/dist/index-CW9vyiq6.cjs +349 -0
- package/dist/index-D8BknfUe.js +266 -0
- package/dist/index-DCP3xelB.cjs +1629 -0
- package/dist/index-DCojd1ld.js +90 -0
- package/dist/index-DLUd_0LP.js +13 -0
- package/dist/index-WgcaHHjH.js +1630 -0
- package/dist/index-keKfh9ZW.cjs +542 -0
- package/dist/index.cjs.js +109 -0
- package/dist/index.css +1519 -0
- package/dist/index.es.js +109 -0
- package/dist/index2.css +3 -0
- package/dist/molecules.cjs.js +7823 -0
- package/dist/molecules.es.js +7825 -0
- package/dist/organisms.cjs.js +940 -0
- package/dist/organisms.es.js +940 -0
- package/dist/provider.cjs.js +48 -0
- package/dist/provider.es.js +48 -0
- package/dist/sortable.esm-CwrpjqII.cjs +3872 -0
- package/dist/sortable.esm-DfJu5xWT.js +3873 -0
- package/dist/theme.css +102 -0
- package/dist/types/antOverrides.d.ts +2 -0
- package/dist/types/assets/fonts/icomoon/selection.json.d.ts +3 -0
- package/dist/types/atoms.d.ts +2 -0
- package/dist/types/components/antOverrides/alert/index.d.ts +2 -0
- package/dist/types/components/antOverrides/avatar/index.d.ts +15 -0
- package/dist/types/components/antOverrides/breadcrumb/index.d.ts +4 -0
- package/dist/types/components/antOverrides/dropdown/index.d.ts +4 -0
- package/dist/types/components/antOverrides/flex/index.d.ts +4 -0
- package/dist/types/components/antOverrides/image/index.d.ts +7 -0
- package/dist/types/components/antOverrides/index.d.ts +18 -0
- package/dist/types/components/antOverrides/infiniteLoader/index.d.ts +12 -0
- package/dist/types/components/antOverrides/loading/index.d.ts +14 -0
- package/dist/types/components/antOverrides/menu/index.d.ts +8 -0
- package/dist/types/components/antOverrides/pagination/index.d.ts +3 -0
- package/dist/types/components/antOverrides/progress/index.d.ts +3 -0
- package/dist/types/components/antOverrides/segmented/index.d.ts +4 -0
- package/dist/types/components/antOverrides/skeleton/index.d.ts +10 -0
- package/dist/types/components/antOverrides/slider/index.d.ts +5 -0
- package/dist/types/components/antOverrides/steps/index.d.ts +11 -0
- package/dist/types/components/antOverrides/switch/index.d.ts +3 -0
- package/dist/types/components/antOverrides/text/index.d.ts +31 -0
- package/dist/types/components/antOverrides/timeline/index.d.ts +4 -0
- package/dist/types/components/antOverrides/tooltip/index.d.ts +8 -0
- package/dist/types/components/antOverrides/upload/index.d.ts +7 -0
- package/dist/types/components/atoms/badge/index.d.ts +3 -0
- package/dist/types/components/atoms/behavioralAtoms/index.d.ts +2 -0
- package/dist/types/components/atoms/behavioralAtoms/portalContainer/index.d.ts +7 -0
- package/dist/types/components/atoms/behavioralAtoms/render/index.d.ts +14 -0
- package/dist/types/components/atoms/borderedTitle/index.d.ts +9 -0
- package/dist/types/components/atoms/box/index.d.ts +7 -0
- package/dist/types/components/atoms/breadcrumbs/index.d.ts +5 -0
- package/dist/types/components/atoms/card/index.d.ts +5 -0
- package/dist/types/components/atoms/checkbox/index.d.ts +7 -0
- package/dist/types/components/atoms/clickAwayListener/index.d.ts +11 -0
- package/dist/types/components/atoms/collapse/index.d.ts +6 -0
- package/dist/types/components/atoms/datePicker/index.d.ts +16 -0
- package/dist/types/components/atoms/empty/index.d.ts +5 -0
- package/dist/types/components/atoms/fallback/index.d.ts +4 -0
- package/dist/types/components/atoms/horizontalLine/index.d.ts +9 -0
- package/dist/types/components/atoms/icon/constants/iconNames.d.ts +1 -0
- package/dist/types/components/atoms/icon/constants/iconsContent.d.ts +808 -0
- package/dist/types/components/atoms/icon/iconPack/index.d.ts +2 -0
- package/dist/types/components/atoms/icon/index.d.ts +26 -0
- package/dist/types/components/atoms/index.d.ts +24 -0
- package/dist/types/components/atoms/navigationTabs/index.d.ts +35 -0
- package/dist/types/components/atoms/popover/index.d.ts +14 -0
- package/dist/types/components/atoms/popover/link.d.ts +6 -0
- package/dist/types/components/atoms/radio/index.d.ts +7 -0
- package/dist/types/components/atoms/rangePicker/index.d.ts +14 -0
- package/dist/types/components/atoms/separator/index.d.ts +5 -0
- package/dist/types/components/atoms/tab/index.d.ts +9 -0
- package/dist/types/components/atoms/tooltip/index.d.ts +7 -0
- package/dist/types/components/atoms/tooltip/titleTooltip.d.ts +5 -0
- package/dist/types/components/atoms/upload/index.d.ts +11 -0
- package/dist/types/components/atoms/verticalLine/index.d.ts +7 -0
- package/dist/types/components/atoms/view/helper.d.ts +20 -0
- package/dist/types/components/atoms/view/index.d.ts +26 -0
- package/dist/types/components/index.d.ts +4 -0
- package/dist/types/components/molecules/accordion/index.d.ts +20 -0
- package/dist/types/components/molecules/actionHeader/index.d.ts +11 -0
- package/dist/types/components/molecules/audioVisualizer/index.d.ts +15 -0
- package/dist/types/components/molecules/avatarUpload/index.d.ts +15 -0
- package/dist/types/components/molecules/button/action/index.d.ts +5 -0
- package/dist/types/components/molecules/button/icon/index.d.ts +11 -0
- package/dist/types/components/molecules/button/index.d.ts +18 -0
- package/dist/types/components/molecules/button/negative/index.d.ts +5 -0
- package/dist/types/components/molecules/button/primary/index.d.ts +3 -0
- package/dist/types/components/molecules/button/secondary/index.d.ts +3 -0
- package/dist/types/components/molecules/button/secondaryQuiet/index.d.ts +3 -0
- package/dist/types/components/molecules/button/shared.d.ts +23 -0
- package/dist/types/components/molecules/button/tertiary/index.d.ts +3 -0
- package/dist/types/components/molecules/button/text/index.d.ts +10 -0
- package/dist/types/components/molecules/catch/index.d.ts +9 -0
- package/dist/types/components/molecules/chevronIcon/index.d.ts +6 -0
- package/dist/types/components/molecules/copyButton/index.d.ts +8 -0
- package/dist/types/components/molecules/index.d.ts +24 -0
- package/dist/types/components/molecules/input/TextArea/index.d.ts +25 -0
- package/dist/types/components/molecules/input/default/index.d.ts +23 -0
- package/dist/types/components/molecules/input/emojiPicker/index.d.ts +21 -0
- package/dist/types/components/molecules/input/ghost/index.d.ts +25 -0
- package/dist/types/components/molecules/input/index.d.ts +19 -0
- package/dist/types/components/molecules/input/number/index.d.ts +28 -0
- package/dist/types/components/molecules/input/search/index.d.ts +7 -0
- package/dist/types/components/molecules/input/tag/index.d.ts +13 -0
- package/dist/types/components/molecules/inputDatePicker/index.d.ts +17 -0
- package/dist/types/components/molecules/inputErrorMessage/index.d.ts +9 -0
- package/dist/types/components/molecules/inputRangePicker/index.d.ts +16 -0
- package/dist/types/components/molecules/logo/index.d.ts +25 -0
- package/dist/types/components/molecules/noResult/index.d.ts +8 -0
- package/dist/types/components/molecules/notification/index.d.ts +13 -0
- package/dist/types/components/molecules/select/components/clearIcon.d.ts +2 -0
- package/dist/types/components/molecules/select/components/index.d.ts +5 -0
- package/dist/types/components/molecules/select/components/label.d.ts +6 -0
- package/dist/types/components/molecules/select/components/notFound.d.ts +5 -0
- package/dist/types/components/molecules/select/components/placeholder.d.ts +7 -0
- package/dist/types/components/molecules/select/components/suffix.d.ts +10 -0
- package/dist/types/components/molecules/select/index.d.ts +13 -0
- package/dist/types/components/molecules/select/multiple/index.d.ts +5 -0
- package/dist/types/components/molecules/select/single/index.d.ts +5 -0
- package/dist/types/components/molecules/select/style.d.ts +8 -0
- package/dist/types/components/molecules/select/treeSelect/index.d.ts +2 -0
- package/dist/types/components/molecules/select/types.d.ts +108 -0
- package/dist/types/components/molecules/sortableList/index.d.ts +19 -0
- package/dist/types/components/molecules/spliter/index.d.ts +8 -0
- package/dist/types/components/molecules/tag/index.d.ts +17 -0
- package/dist/types/components/molecules/tagCollectionView/index.d.ts +14 -0
- package/dist/types/components/molecules/tagInput/components/notFoundAddItem.d.ts +4 -0
- package/dist/types/components/molecules/tagInput/index.d.ts +6 -0
- package/dist/types/components/molecules/tagInput/style.d.ts +9 -0
- package/dist/types/components/molecules/tagInput/types.d.ts +66 -0
- package/dist/types/components/molecules/timePicker/index.d.ts +6 -0
- package/dist/types/components/molecules/titleBox/index.d.ts +8 -0
- package/dist/types/components/molecules/titleBox/status.d.ts +5 -0
- package/dist/types/components/molecules/titleBox/title.d.ts +7 -0
- package/dist/types/components/molecules/tree/index.d.ts +29 -0
- package/dist/types/components/molecules/tree/searchBar/index.d.ts +7 -0
- package/dist/types/components/molecules/verticalTabs/index.d.ts +19 -0
- package/dist/types/components/organisms/avatarGroup/index.d.ts +25 -0
- package/dist/types/components/organisms/drawer/components/footer.d.ts +3 -0
- package/dist/types/components/organisms/drawer/components/headerTitle.d.ts +8 -0
- package/dist/types/components/organisms/drawer/index.d.ts +24 -0
- package/dist/types/components/organisms/index.d.ts +4 -0
- package/dist/types/components/organisms/modal/base.d.ts +6 -0
- package/dist/types/components/organisms/modal/confirm.d.ts +6 -0
- package/dist/types/components/organisms/modal/delete.d.ts +4 -0
- package/dist/types/components/organisms/modal/error.d.ts +4 -0
- package/dist/types/components/organisms/modal/index.d.ts +14 -0
- package/dist/types/components/organisms/modal/info.d.ts +4 -0
- package/dist/types/components/organisms/modal/type.d.ts +11 -0
- package/dist/types/components/organisms/table/column.d.ts +20 -0
- package/dist/types/components/organisms/table/components/cell/currencyCell.d.ts +7 -0
- package/dist/types/components/organisms/table/components/cell/dateCell.d.ts +6 -0
- package/dist/types/components/organisms/table/components/cell/index.d.ts +10 -0
- package/dist/types/components/organisms/table/components/cell/status.d.ts +8 -0
- package/dist/types/components/organisms/table/components/expandIcon.d.ts +7 -0
- package/dist/types/components/organisms/table/components/headerTitle.d.ts +10 -0
- package/dist/types/components/organisms/table/config.d.ts +8 -0
- package/dist/types/components/organisms/table/dndSort/context.d.ts +6 -0
- package/dist/types/components/organisms/table/dndSort/dragHandle.d.ts +1 -0
- package/dist/types/components/organisms/table/dndSort/index.d.ts +3 -0
- package/dist/types/components/organisms/table/dndSort/provider.d.ts +10 -0
- package/dist/types/components/organisms/table/dndSort/row.d.ts +6 -0
- package/dist/types/components/organisms/table/index.d.ts +30 -0
- package/dist/types/components/organisms/table/pagination/components.d.ts +18 -0
- package/dist/types/components/organisms/table/pagination/usePagination.d.ts +22 -0
- package/dist/types/configs/constructors/AbrplusUIKit.d.ts +17 -0
- package/dist/types/configs/constructors/index.d.ts +1 -0
- package/dist/types/configs/index.d.ts +6 -0
- package/dist/types/configs/locales/en.d.ts +1030 -0
- package/dist/types/configs/locales/fa.d.ts +1031 -0
- package/dist/types/configs/locales/i18nextTFunction.d.ts +5 -0
- package/dist/types/configs/locales/index.d.ts +10 -0
- package/dist/types/configs/providers/AbrplusUIKitProvider.d.ts +11 -0
- package/dist/types/configs/providers/index.d.ts +1 -0
- package/dist/types/configs/tailwindcss/index.d.ts +103 -0
- package/dist/types/configs/theme/colors.d.ts +114 -0
- package/dist/types/configs/theme/index.d.ts +1 -0
- package/dist/types/configs/types/index.d.ts +98 -0
- package/dist/types/constants/chartColors.d.ts +1 -0
- package/dist/types/constants/datepickerColors.d.ts +2 -0
- package/dist/types/constants/dimantions.d.ts +12 -0
- package/dist/types/constants/enum.d.ts +5 -0
- package/dist/types/constants/index.d.ts +3 -0
- package/dist/types/constants/variables.d.ts +2 -0
- package/dist/types/hooks/index.d.ts +6 -0
- package/dist/types/hooks/useAntConfig.d.ts +24 -0
- package/dist/types/hooks/useDebounce.d.ts +1 -0
- package/dist/types/hooks/useInteractions.d.ts +15 -0
- package/dist/types/hooks/useLocalStorageState.d.ts +3 -0
- package/dist/types/hooks/useObserveWindow.d.ts +9 -0
- package/dist/types/hooks/useWindowDimensions.d.ts +16 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/main.d.ts +3 -0
- package/dist/types/molecules.d.ts +2 -0
- package/dist/types/organisms.d.ts +2 -0
- package/dist/types/provider.d.ts +2 -0
- package/dist/types/theme.d.ts +1 -0
- package/dist/types/utilities/batch.d.ts +9 -0
- package/dist/types/utilities/createIcomoonIconSet.d.ts +9 -0
- package/dist/types/utilities/deepMerge.d.ts +1 -0
- package/dist/types/utilities/getErrorMessage.d.ts +1 -0
- package/dist/types/utilities/index.d.ts +7 -0
- package/dist/types/utilities/isPersian.d.ts +1 -0
- package/dist/types/utilities/mmss.d.ts +1 -0
- package/dist/types/utilities/testUtils/index.d.ts +3 -0
- package/dist/types/utilities/testUtils/withReactQuery.d.ts +2 -0
- package/dist/types/utilities/testUtils/withReactRouter.d.ts +2 -0
- package/package.json +195 -0
|
@@ -0,0 +1,940 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { L as Logo, c as arrayMove, D as DndContext, S as SortableContext, v as verticalListSortingStrategy, b as useSortable, C as CSS } from "./sortable.esm-DfJu5xWT.js";
|
|
3
|
+
import { u as useWindowDimensions, P as Popover, V as View } from "./index-D8BknfUe.js";
|
|
4
|
+
import { T as Text, F as Flex, R as Render, I as Icon, L as Loading } from "./index-C24zbKLS.js";
|
|
5
|
+
import { c as colors } from "./colors-CztsZ6e_.js";
|
|
6
|
+
import { Drawer as Drawer$1, ConfigProvider, Modal as Modal$1, Table as Table$1 } from "antd";
|
|
7
|
+
import { twMerge } from "tailwind-merge";
|
|
8
|
+
import { useTranslation } from "react-i18next";
|
|
9
|
+
import { B as Button, b as batch } from "./index-CQKRmQkW.js";
|
|
10
|
+
import { useState, useEffect, useCallback, createContext, useContext, useMemo, useReducer, useRef, Fragment as Fragment$1 } from "react";
|
|
11
|
+
import starkString from "starkstring";
|
|
12
|
+
import { d as deepMerge } from "./deepMerge-CG1he8ZD.js";
|
|
13
|
+
import { useNavigate, useSearchParams } from "react-router-dom";
|
|
14
|
+
function useLocalStorageState(key, initialValue) {
|
|
15
|
+
const initialStoredValue = localStorage.getItem(key);
|
|
16
|
+
const initial = initialStoredValue ? JSON.parse(initialStoredValue) : initialValue;
|
|
17
|
+
const [state, setState] = useState(initial);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
localStorage.setItem(key, JSON.stringify(state));
|
|
20
|
+
}, [key, state]);
|
|
21
|
+
return [state, setState];
|
|
22
|
+
}
|
|
23
|
+
const SMALL_SCREEN = 640;
|
|
24
|
+
const MEDIUM_SCREEN = 768;
|
|
25
|
+
const LARGE_SCREEN = 1024;
|
|
26
|
+
const EXTRA_LARGE_SCREEN = 1280;
|
|
27
|
+
function useObserveWindow() {
|
|
28
|
+
const { width } = useWindowDimensions();
|
|
29
|
+
const getIsWidthSmallerThan = useCallback(
|
|
30
|
+
(query) => {
|
|
31
|
+
if (typeof window === "undefined") return;
|
|
32
|
+
return width <= query;
|
|
33
|
+
},
|
|
34
|
+
[width]
|
|
35
|
+
);
|
|
36
|
+
const getIsWidthLargerThan = useCallback(
|
|
37
|
+
(query) => {
|
|
38
|
+
if (typeof window === "undefined") return;
|
|
39
|
+
return width > query;
|
|
40
|
+
},
|
|
41
|
+
[width]
|
|
42
|
+
);
|
|
43
|
+
const getIsWidthBetween = useCallback(
|
|
44
|
+
(queries) => {
|
|
45
|
+
if (queries[0] >= queries[1]) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`The second query: ${queries[1]}px must be greater than the first query: ${queries[0]}px`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
if (typeof window === "undefined") return;
|
|
51
|
+
return width > queries[0] && width <= queries[1];
|
|
52
|
+
},
|
|
53
|
+
[width]
|
|
54
|
+
);
|
|
55
|
+
const isSmallerThenLarge = getIsWidthSmallerThan(LARGE_SCREEN);
|
|
56
|
+
const isSmallerThanSmall = getIsWidthSmallerThan(SMALL_SCREEN);
|
|
57
|
+
const isSmallerThanMedium = getIsWidthSmallerThan(MEDIUM_SCREEN);
|
|
58
|
+
const isSmallerThanExtraLarge = getIsWidthLargerThan(EXTRA_LARGE_SCREEN);
|
|
59
|
+
return {
|
|
60
|
+
getIsWidthSmallerThan,
|
|
61
|
+
getIsWidthLargerThan,
|
|
62
|
+
getIsWidthBetween,
|
|
63
|
+
isSmallerThanExtraLarge,
|
|
64
|
+
isSmallerThanMedium,
|
|
65
|
+
isSmallerThanSmall,
|
|
66
|
+
isSmallerThenLarge
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const PAGINATION_SIZE = "PAGINATION_SIZE";
|
|
70
|
+
function AvatarGroup({
|
|
71
|
+
items = [],
|
|
72
|
+
max = 3,
|
|
73
|
+
avatarProps: { size } = {},
|
|
74
|
+
onClickAvatar,
|
|
75
|
+
hasAnimation = true,
|
|
76
|
+
nameExtractor,
|
|
77
|
+
renderItem,
|
|
78
|
+
itemLogoProps,
|
|
79
|
+
containerProps,
|
|
80
|
+
popoverProps
|
|
81
|
+
}) {
|
|
82
|
+
if (items.length === 0) {
|
|
83
|
+
return /* @__PURE__ */ jsx(Text, { children: "-" });
|
|
84
|
+
}
|
|
85
|
+
const getName = (item) => {
|
|
86
|
+
return nameExtractor?.(item) ?? (item.name || "--");
|
|
87
|
+
};
|
|
88
|
+
return /* @__PURE__ */ jsxs(Flex, { ...containerProps, children: [
|
|
89
|
+
items.slice(0, max).map((item, index) => /* @__PURE__ */ jsx(
|
|
90
|
+
Render,
|
|
91
|
+
{
|
|
92
|
+
when: !!renderItem,
|
|
93
|
+
fallback: /* @__PURE__ */ jsx(
|
|
94
|
+
Logo,
|
|
95
|
+
{
|
|
96
|
+
style: { marginInlineStart: index - 12, width: size, height: size },
|
|
97
|
+
imageSrc: item?.imageSrc,
|
|
98
|
+
hasToolTip: true,
|
|
99
|
+
toolTipTitle: getName(item),
|
|
100
|
+
hasAnimation,
|
|
101
|
+
onClick: () => onClickAvatar?.(item),
|
|
102
|
+
...itemLogoProps
|
|
103
|
+
},
|
|
104
|
+
item.id
|
|
105
|
+
),
|
|
106
|
+
children: renderItem?.(item)
|
|
107
|
+
}
|
|
108
|
+
)),
|
|
109
|
+
items.length > max && /* @__PURE__ */ jsx(
|
|
110
|
+
Popover,
|
|
111
|
+
{
|
|
112
|
+
arrow: true,
|
|
113
|
+
color: colors.primary_dark_1,
|
|
114
|
+
placement: "left",
|
|
115
|
+
overlayInnerStyle: {
|
|
116
|
+
backgroundColor: colors.primary_dark_1,
|
|
117
|
+
borderRadius: 4
|
|
118
|
+
},
|
|
119
|
+
trigger: ["hover"],
|
|
120
|
+
content: /* @__PURE__ */ jsx(View, { vertical: true, children: items.slice(max).map((item) => /* @__PURE__ */ jsx(Text, { color: colors.white_ff, children: getName(item) }, item.id)) }),
|
|
121
|
+
...popoverProps,
|
|
122
|
+
children: /* @__PURE__ */ jsx(
|
|
123
|
+
Flex,
|
|
124
|
+
{
|
|
125
|
+
align: "center",
|
|
126
|
+
justify: "center",
|
|
127
|
+
className: "z-50 -ms-3 h-6 w-6 rounded-full border-2 border-primary-light-3 bg-light-7",
|
|
128
|
+
style: { width: size, height: size },
|
|
129
|
+
...popoverProps?.containerProps,
|
|
130
|
+
children: `${items.length - max}+`
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
] });
|
|
136
|
+
}
|
|
137
|
+
const DrawerFooter = ({
|
|
138
|
+
discardTitle,
|
|
139
|
+
onDiscard,
|
|
140
|
+
onSubmit,
|
|
141
|
+
submitTitle,
|
|
142
|
+
isLoading,
|
|
143
|
+
isSubmitDisabled
|
|
144
|
+
}) => {
|
|
145
|
+
const { t } = useTranslation();
|
|
146
|
+
return /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 16, justify: "flex-end", children: [
|
|
147
|
+
discardTitle && /* @__PURE__ */ jsx(Button.Secondary, { disabled: isLoading, onClick: onDiscard, children: discardTitle }),
|
|
148
|
+
/* @__PURE__ */ jsx(Button.Primary, { disabled: isSubmitDisabled, isLoading, onClick: onSubmit, children: submitTitle || t("common.literal.apply") })
|
|
149
|
+
] });
|
|
150
|
+
};
|
|
151
|
+
const DrawerHeaderTitle = ({ title, closable, onClose }) => {
|
|
152
|
+
const getTitle = () => {
|
|
153
|
+
if (typeof title !== "string") {
|
|
154
|
+
return title;
|
|
155
|
+
}
|
|
156
|
+
return /* @__PURE__ */ jsx(Text, { size: 18, weight: "medium", color: colors.primary, children: title });
|
|
157
|
+
};
|
|
158
|
+
return /* @__PURE__ */ jsxs(Flex, { justify: "space-between", align: "center", children: [
|
|
159
|
+
getTitle(),
|
|
160
|
+
closable && /* @__PURE__ */ jsx("div", { className: "cursor-pointer", onClick: onClose, children: /* @__PURE__ */ jsx(Icon, { name: "Close", size: 20, color: colors.primary }) })
|
|
161
|
+
] });
|
|
162
|
+
};
|
|
163
|
+
const Drawer = ({
|
|
164
|
+
title,
|
|
165
|
+
closable = true,
|
|
166
|
+
transparent,
|
|
167
|
+
submitTitle,
|
|
168
|
+
discardTitle,
|
|
169
|
+
onClose,
|
|
170
|
+
onSubmit,
|
|
171
|
+
onDiscard,
|
|
172
|
+
classNames,
|
|
173
|
+
styles,
|
|
174
|
+
children,
|
|
175
|
+
isLoading,
|
|
176
|
+
headerHeight = 60,
|
|
177
|
+
wrapperClassName,
|
|
178
|
+
contentClassName,
|
|
179
|
+
noPadding,
|
|
180
|
+
isSubmitDisabled,
|
|
181
|
+
footer,
|
|
182
|
+
...rest
|
|
183
|
+
}) => {
|
|
184
|
+
return /* @__PURE__ */ jsx(
|
|
185
|
+
Drawer$1,
|
|
186
|
+
{
|
|
187
|
+
onClose,
|
|
188
|
+
styles: {
|
|
189
|
+
...styles,
|
|
190
|
+
header: {
|
|
191
|
+
minHeight: headerHeight,
|
|
192
|
+
backgroundColor: colors.light_2,
|
|
193
|
+
borderColor: colors.light_7,
|
|
194
|
+
paddingBlock: 12,
|
|
195
|
+
paddingInline: 24
|
|
196
|
+
},
|
|
197
|
+
body: {
|
|
198
|
+
backgroundColor: transparent ? "transparent" : colors.white_ff,
|
|
199
|
+
// margin: transparent ? 0 : 24,
|
|
200
|
+
// borderRadius: 10,
|
|
201
|
+
padding: 0
|
|
202
|
+
},
|
|
203
|
+
content: {
|
|
204
|
+
backgroundColor: colors.light_2,
|
|
205
|
+
padding: 0
|
|
206
|
+
},
|
|
207
|
+
footer: {
|
|
208
|
+
minHeight: 60,
|
|
209
|
+
paddingBlock: 12,
|
|
210
|
+
borderColor: colors.light_7,
|
|
211
|
+
paddingInline: 24,
|
|
212
|
+
margin: 0
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
classNames: {
|
|
216
|
+
...classNames,
|
|
217
|
+
body: "small-custom-scrollbar"
|
|
218
|
+
},
|
|
219
|
+
footer: footer || /* @__PURE__ */ jsx(
|
|
220
|
+
DrawerFooter,
|
|
221
|
+
{
|
|
222
|
+
...{ onSubmit, onDiscard, submitTitle, discardTitle, isLoading, isSubmitDisabled }
|
|
223
|
+
}
|
|
224
|
+
),
|
|
225
|
+
closable: false,
|
|
226
|
+
title: /* @__PURE__ */ jsx(DrawerHeaderTitle, { title, closable, onClose }),
|
|
227
|
+
...rest,
|
|
228
|
+
children: /* @__PURE__ */ jsx(
|
|
229
|
+
Flex,
|
|
230
|
+
{
|
|
231
|
+
className: twMerge(
|
|
232
|
+
"small-custom-scrollbar h-full flex-1 overflow-y-auto bg-light-2 p-6",
|
|
233
|
+
wrapperClassName
|
|
234
|
+
),
|
|
235
|
+
vertical: true,
|
|
236
|
+
gap: 16,
|
|
237
|
+
children: /* @__PURE__ */ jsx(
|
|
238
|
+
Flex,
|
|
239
|
+
{
|
|
240
|
+
className: twMerge(
|
|
241
|
+
"bg-white-ff",
|
|
242
|
+
noPadding ? "rounded-lg" : "rounded p-6",
|
|
243
|
+
!transparent ? "" : "bg-transparent",
|
|
244
|
+
contentClassName
|
|
245
|
+
),
|
|
246
|
+
vertical: true,
|
|
247
|
+
children
|
|
248
|
+
}
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
const BaseModal = ({
|
|
256
|
+
children,
|
|
257
|
+
submitTitle,
|
|
258
|
+
discardTitle,
|
|
259
|
+
onSubmit,
|
|
260
|
+
onDiscard,
|
|
261
|
+
title,
|
|
262
|
+
onClose,
|
|
263
|
+
isLoadingSubmit,
|
|
264
|
+
renderFooter,
|
|
265
|
+
...rest
|
|
266
|
+
}) => {
|
|
267
|
+
return /* @__PURE__ */ jsx(
|
|
268
|
+
ConfigProvider,
|
|
269
|
+
{
|
|
270
|
+
theme: {
|
|
271
|
+
components: {
|
|
272
|
+
Modal: {
|
|
273
|
+
borderRadius: 4,
|
|
274
|
+
borderRadiusOuter: 4,
|
|
275
|
+
borderRadiusLG: 4,
|
|
276
|
+
paddingMD: 0,
|
|
277
|
+
paddingContentHorizontalLG: 0,
|
|
278
|
+
margin: 0
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
children: /* @__PURE__ */ jsx(
|
|
283
|
+
Modal$1,
|
|
284
|
+
{
|
|
285
|
+
closeIcon: false,
|
|
286
|
+
classNames: { body: "!px-6 !py-4" },
|
|
287
|
+
footer: renderFooter !== void 0 ? renderFooter : submitTitle || discardTitle ? /* @__PURE__ */ jsxs(
|
|
288
|
+
Flex,
|
|
289
|
+
{
|
|
290
|
+
justify: "end",
|
|
291
|
+
align: "center",
|
|
292
|
+
className: "h-[58px] rounded-b border-t border-solid border-light-7 bg-light-2 px-6",
|
|
293
|
+
gap: 16,
|
|
294
|
+
children: [
|
|
295
|
+
discardTitle && /* @__PURE__ */ jsx(Button.Secondary, { onClick: onDiscard, children: discardTitle }),
|
|
296
|
+
submitTitle && /* @__PURE__ */ jsx(Button.Primary, { isLoading: isLoadingSubmit, onClick: onSubmit, children: submitTitle })
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
) : null,
|
|
300
|
+
title: typeof title === "string" ? /* @__PURE__ */ jsxs(
|
|
301
|
+
Flex,
|
|
302
|
+
{
|
|
303
|
+
className: "h-12 rounded-t border-b border-solid border-light-7 bg-light-2 px-6",
|
|
304
|
+
align: "center",
|
|
305
|
+
justify: "space-between",
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ jsx(Text, { size: 18, weight: "medium", color: colors.primary_dark_1, children: title }),
|
|
308
|
+
/* @__PURE__ */ jsx(
|
|
309
|
+
Icon,
|
|
310
|
+
{
|
|
311
|
+
name: "Close",
|
|
312
|
+
color: colors.primary,
|
|
313
|
+
onClick: onClose,
|
|
314
|
+
className: "cursor-pointer"
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
]
|
|
318
|
+
}
|
|
319
|
+
) : title,
|
|
320
|
+
...rest,
|
|
321
|
+
children
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
};
|
|
327
|
+
const ConfirmModal = ({
|
|
328
|
+
children,
|
|
329
|
+
title,
|
|
330
|
+
onSubmit,
|
|
331
|
+
onDiscard,
|
|
332
|
+
submitTitle,
|
|
333
|
+
discardTitle,
|
|
334
|
+
isLoadingSubmit,
|
|
335
|
+
renderFooter,
|
|
336
|
+
...rest
|
|
337
|
+
}) => {
|
|
338
|
+
const footerContent = renderFooter !== void 0 ? renderFooter : (submitTitle || discardTitle) && /* @__PURE__ */ jsxs(Flex, { gap: 16, align: "center", justify: "flex-end", className: "px-6 py-4", children: [
|
|
339
|
+
discardTitle && /* @__PURE__ */ jsx(Button.Secondary, { onClick: onDiscard, children: discardTitle }),
|
|
340
|
+
submitTitle && /* @__PURE__ */ jsx(Button.Primary, { isLoading: isLoadingSubmit, onClick: onSubmit, children: submitTitle })
|
|
341
|
+
] });
|
|
342
|
+
return /* @__PURE__ */ jsx(BaseModal, { ...rest, renderFooter: footerContent, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, children: [
|
|
343
|
+
/* @__PURE__ */ jsx(Flex, { vertical: true, className: "mb-2 border-b-[2px] border-light-7 pb-3", children: typeof title === "string" ? /* @__PURE__ */ jsx(Text, { size: 20, weight: "bold", color: colors.primary_dark_1, children: title }) : title }),
|
|
344
|
+
/* @__PURE__ */ jsx(Flex, { className: "pb-10 pt-4", children: typeof children === "string" ? /* @__PURE__ */ jsx(Text, { size: 16, weight: "normal", color: colors.primary, children }) : children })
|
|
345
|
+
] }) });
|
|
346
|
+
};
|
|
347
|
+
const DeleteModal = ({
|
|
348
|
+
children,
|
|
349
|
+
title,
|
|
350
|
+
onSubmit,
|
|
351
|
+
onDiscard,
|
|
352
|
+
submitTitle,
|
|
353
|
+
discardTitle,
|
|
354
|
+
isLoadingSubmit,
|
|
355
|
+
...rest
|
|
356
|
+
}) => {
|
|
357
|
+
return /* @__PURE__ */ jsx(BaseModal, { ...rest, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, children: [
|
|
358
|
+
/* @__PURE__ */ jsx(Flex, { vertical: true, className: "border-b-[2px] border-light-7 pb-3", children: typeof title === "string" ? /* @__PURE__ */ jsx(Text, { size: 20, weight: "bold", color: colors.primary_dark_1, children: title }) : title }),
|
|
359
|
+
/* @__PURE__ */ jsx(Flex, { className: "pb-10 pt-4", children: typeof children === "string" ? /* @__PURE__ */ jsx(Text, { size: 16, weight: "normal", color: colors.primary, children }) : children }),
|
|
360
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 16, align: "center", justify: "flex-end", children: [
|
|
361
|
+
/* @__PURE__ */ jsx(Button.Secondary, { onClick: onDiscard, children: discardTitle }),
|
|
362
|
+
/* @__PURE__ */ jsx(Button.Negative, { iconName: "Delete", isLoading: isLoadingSubmit, onClick: onSubmit, children: submitTitle })
|
|
363
|
+
] })
|
|
364
|
+
] }) });
|
|
365
|
+
};
|
|
366
|
+
const ErrorModal = ({
|
|
367
|
+
children,
|
|
368
|
+
title,
|
|
369
|
+
onSubmit,
|
|
370
|
+
submitTitle,
|
|
371
|
+
isLoadingSubmit,
|
|
372
|
+
...rest
|
|
373
|
+
}) => {
|
|
374
|
+
return /* @__PURE__ */ jsx(BaseModal, { ...rest, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, children: [
|
|
375
|
+
/* @__PURE__ */ jsxs(Flex, { className: "border-b-[2px] border-light-7 pb-3", align: "center", justify: "space-between", children: [
|
|
376
|
+
typeof title === "string" ? /* @__PURE__ */ jsx(Text, { size: 20, weight: "bold", color: colors.primary_dark_1, children: title }) : title,
|
|
377
|
+
/* @__PURE__ */ jsx(Icon, { name: "Alert", color: colors.negative, size: 18 })
|
|
378
|
+
] }),
|
|
379
|
+
/* @__PURE__ */ jsx(Flex, { className: "pb-10 pt-4", children: typeof children === "string" ? /* @__PURE__ */ jsx(Text, { size: 16, weight: "normal", color: colors.primary, children }) : children }),
|
|
380
|
+
/* @__PURE__ */ jsx(Flex, { justify: "flex-end", children: /* @__PURE__ */ jsx(Button.Primary, { isLoading: isLoadingSubmit, onClick: onSubmit, children: submitTitle }) })
|
|
381
|
+
] }) });
|
|
382
|
+
};
|
|
383
|
+
const InfoModal = ({
|
|
384
|
+
children,
|
|
385
|
+
title,
|
|
386
|
+
onSubmit,
|
|
387
|
+
onDiscard,
|
|
388
|
+
submitTitle,
|
|
389
|
+
discardTitle,
|
|
390
|
+
isLoadingSubmit,
|
|
391
|
+
error,
|
|
392
|
+
...rest
|
|
393
|
+
}) => {
|
|
394
|
+
return /* @__PURE__ */ jsx(BaseModal, { ...rest, children: /* @__PURE__ */ jsxs(Flex, { vertical: true, children: [
|
|
395
|
+
/* @__PURE__ */ jsx(Flex, { vertical: true, className: "border-b-[2px] border-light-7 pb-3", children: typeof title === "string" ? /* @__PURE__ */ jsx(Text, { size: 20, weight: "bold", color: colors.primary_dark_1, children: title }) : title }),
|
|
396
|
+
/* @__PURE__ */ jsx(Flex, { className: "pb-10 pt-4", children: typeof children === "string" ? /* @__PURE__ */ jsx(Text, { size: 16, weight: "normal", color: colors.primary, children }) : children }),
|
|
397
|
+
/* @__PURE__ */ jsx(Text, { size: 20, weight: "bold", color: colors.negative, children: error }),
|
|
398
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 16, align: "center", justify: "flex-end", children: [
|
|
399
|
+
/* @__PURE__ */ jsx(Button.SecondaryQuiet, { onClick: onDiscard, children: discardTitle }),
|
|
400
|
+
/* @__PURE__ */ jsx(Button.Primary, { isLoading: isLoadingSubmit, onClick: onSubmit, children: submitTitle })
|
|
401
|
+
] })
|
|
402
|
+
] }) });
|
|
403
|
+
};
|
|
404
|
+
const Modal = batch({
|
|
405
|
+
Base: BaseModal,
|
|
406
|
+
Confirm: ConfirmModal,
|
|
407
|
+
Error: ErrorModal,
|
|
408
|
+
Delete: DeleteModal,
|
|
409
|
+
Info: InfoModal
|
|
410
|
+
});
|
|
411
|
+
const Column = (_props) => {
|
|
412
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
413
|
+
};
|
|
414
|
+
const CurrencyCell = ({ value, includeCurrency, ...rest }) => {
|
|
415
|
+
const { t } = useTranslation();
|
|
416
|
+
return /* @__PURE__ */ jsxs(Text, { className: "w-full", size: 14, weight: "normal", color: colors.primary, ...rest, children: [
|
|
417
|
+
value ? starkString(value).scientificNotationToDecimal().toCurrency().toString() : "",
|
|
418
|
+
includeCurrency && ` ${t("common.literal.rial")}`
|
|
419
|
+
] });
|
|
420
|
+
};
|
|
421
|
+
const DateCell = ({ value, ...rest }) => {
|
|
422
|
+
return /* @__PURE__ */ jsx(Text, { className: "w-full", size: 14, weight: "normal", color: colors.primary, ...rest, children: value });
|
|
423
|
+
};
|
|
424
|
+
const StatusCell = ({ value, activeTitle, disableTitle, ...rest }) => {
|
|
425
|
+
const { t } = useTranslation();
|
|
426
|
+
return /* @__PURE__ */ jsx(
|
|
427
|
+
Flex,
|
|
428
|
+
{
|
|
429
|
+
className: twMerge(
|
|
430
|
+
"h-[26px] items-center justify-center rounded px-4",
|
|
431
|
+
value ? "bg-positive-light-2 bg-opacity-10" : "bg-light-6"
|
|
432
|
+
),
|
|
433
|
+
...rest,
|
|
434
|
+
children: value ? /* @__PURE__ */ jsx(Text, { size: 12, weight: "medium", color: colors.positive, children: activeTitle || t("common.literal.active") }) : /* @__PURE__ */ jsx(Text, { size: 12, weight: "medium", color: colors.primary_light_2, children: disableTitle || t("common.literal.disable") })
|
|
435
|
+
}
|
|
436
|
+
);
|
|
437
|
+
};
|
|
438
|
+
const TableCell = ({ children }) => {
|
|
439
|
+
if (typeof children === "string" || typeof children === "number") {
|
|
440
|
+
return /* @__PURE__ */ jsx(Text, { className: "w-full", size: 14, weight: "normal", color: colors.primary, children });
|
|
441
|
+
}
|
|
442
|
+
return children;
|
|
443
|
+
};
|
|
444
|
+
TableCell.Currency = CurrencyCell;
|
|
445
|
+
TableCell.Date = DateCell;
|
|
446
|
+
TableCell.StatusCell = StatusCell;
|
|
447
|
+
const ExpandIcon = ({ expandable, expanded, onExpand }) => {
|
|
448
|
+
const { i18n } = useTranslation();
|
|
449
|
+
if (!expandable) {
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
return /* @__PURE__ */ jsx("button", { className: "float-start h-full items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
453
|
+
Icon,
|
|
454
|
+
{
|
|
455
|
+
onClick: onExpand,
|
|
456
|
+
name: expanded ? "Chevron_Down" : i18n.language === "fa" ? "Chevron_Left" : "Chevron_Right"
|
|
457
|
+
}
|
|
458
|
+
) });
|
|
459
|
+
};
|
|
460
|
+
const TableHeaderTitle = ({ title, align, style, className }) => {
|
|
461
|
+
if (typeof title !== "string") {
|
|
462
|
+
return title;
|
|
463
|
+
}
|
|
464
|
+
return /* @__PURE__ */ jsx(
|
|
465
|
+
Flex,
|
|
466
|
+
{
|
|
467
|
+
style,
|
|
468
|
+
className: twMerge(
|
|
469
|
+
"w-full",
|
|
470
|
+
align === "start" && "justify-start",
|
|
471
|
+
align === "center" && "justify-center",
|
|
472
|
+
align === "end" && "justify-end",
|
|
473
|
+
className
|
|
474
|
+
),
|
|
475
|
+
children: /* @__PURE__ */ jsx(Text, { size: 14, weight: "normal", className: "whitespace-nowrap", color: colors.primary, children: title })
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
};
|
|
479
|
+
const CustomizedAntTableConfig = (theme) => deepMerge(
|
|
480
|
+
{
|
|
481
|
+
components: {
|
|
482
|
+
Table: {
|
|
483
|
+
borderColor: colors.light_7,
|
|
484
|
+
cellPaddingBlock: 0,
|
|
485
|
+
cellPaddingBlockMD: 0,
|
|
486
|
+
cellPaddingBlockSM: 0,
|
|
487
|
+
cellPaddingInline: 8,
|
|
488
|
+
cellPaddingInlineMD: 8,
|
|
489
|
+
cellPaddingInlineSM: 8,
|
|
490
|
+
fixedHeaderSortActiveBg: "transparent",
|
|
491
|
+
footerBg: colors.light_2,
|
|
492
|
+
headerBg: colors.light_2,
|
|
493
|
+
headerBorderRadius: 0,
|
|
494
|
+
headerColor: colors.primary,
|
|
495
|
+
bodySortBg: colors.white_ff,
|
|
496
|
+
headerSortHoverBg: colors.light_1,
|
|
497
|
+
headerSortActiveBg: colors.light_1,
|
|
498
|
+
headerSplitColor: "transparent",
|
|
499
|
+
rowExpandedBg: colors.light_3,
|
|
500
|
+
rowHoverBg: colors.light_4,
|
|
501
|
+
rowSelectedBg: colors.light_7,
|
|
502
|
+
rowSelectedHoverBg: colors.light_7,
|
|
503
|
+
selectionColumnWidth: 56
|
|
504
|
+
/* here is your component tokens */
|
|
505
|
+
},
|
|
506
|
+
Pagination: {
|
|
507
|
+
itemActiveBg: colors.white_ff,
|
|
508
|
+
itemActiveBgDisabled: colors.negative,
|
|
509
|
+
itemActiveColorDisabled: colors.negative,
|
|
510
|
+
colorPrimaryBorderHover: "red",
|
|
511
|
+
colorInfoBorderHover: "yellow",
|
|
512
|
+
colorWarningBorderHover: "green",
|
|
513
|
+
itemBg: colors.white_ff,
|
|
514
|
+
itemInputBg: colors.negative,
|
|
515
|
+
itemLinkBg: colors.negative,
|
|
516
|
+
itemSize: 30,
|
|
517
|
+
itemSizeSM: 30,
|
|
518
|
+
miniOptionsSizeChangerTop: 40,
|
|
519
|
+
colorPrimary: colors.primary,
|
|
520
|
+
fontFamily: "YekanBakhFaRegular"
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
theme ?? {}
|
|
525
|
+
);
|
|
526
|
+
const tailwindTableClasses = twMerge(
|
|
527
|
+
"[&_th]:!border-t h-full [&_.ant-spin-nested-loading]:h-full [&_.ant-spin-container]:h-full [&_.ant-table]:h-full [&_.ant-spin-container]:flex [&_.ant-spin-container]:flex-col [&_.ant-spin-container]:justify-between [&_.ant-table-column-title]:flex-[0] [&_th]:!border-t-light-7 [&_th]:!pt-4 [&_th]:!pb-1 [&_.ant-table-selection-column]:!ps-4 [&_.ant-table-wrapper]:!p-0 [&_.ant-table-measure-row]:!h-[1px] [&_.ant-table-body]:h-full [&_.ant-table-container]:h-full"
|
|
528
|
+
);
|
|
529
|
+
const tableTransparentHeaderClasses = twMerge(
|
|
530
|
+
"[&_th]:!bg-transparent h-full [&_th]:!border-t-0 [&_td]:!bg-transparent "
|
|
531
|
+
);
|
|
532
|
+
const rowHeightClassName = {
|
|
533
|
+
small: "h-[40px] max-h-[40px] min-h-[40px]",
|
|
534
|
+
middle: "h-[48px] max-h-[48px] min-h-[48px]",
|
|
535
|
+
large: "h-[56px] max-h-[56px] min-h-[56px]"
|
|
536
|
+
};
|
|
537
|
+
const RowContext = createContext({});
|
|
538
|
+
const DragHandle = () => {
|
|
539
|
+
const { setActivatorNodeRef, listeners } = useContext(RowContext);
|
|
540
|
+
return /* @__PURE__ */ jsx("button", { style: { cursor: "move" }, ref: setActivatorNodeRef, ...listeners, children: /* @__PURE__ */ jsx(Icon, { name: "drag_and_drop", color: colors.primary_light_2 }) });
|
|
541
|
+
};
|
|
542
|
+
const restrictToVerticalAxis = (_ref) => {
|
|
543
|
+
let {
|
|
544
|
+
transform
|
|
545
|
+
} = _ref;
|
|
546
|
+
return {
|
|
547
|
+
...transform,
|
|
548
|
+
x: 0
|
|
549
|
+
};
|
|
550
|
+
};
|
|
551
|
+
const DndSortProvider = ({
|
|
552
|
+
children,
|
|
553
|
+
onDragEnd,
|
|
554
|
+
dataSource = [],
|
|
555
|
+
rowKey
|
|
556
|
+
}) => {
|
|
557
|
+
const items = useMemo(
|
|
558
|
+
() => dataSource.map((item) => item[rowKey]),
|
|
559
|
+
[dataSource, rowKey]
|
|
560
|
+
);
|
|
561
|
+
const handleDragEnd = useCallback(
|
|
562
|
+
({ active, over }) => {
|
|
563
|
+
if (active.id !== over?.id) {
|
|
564
|
+
const activeIndex = dataSource.findIndex((record) => record[rowKey] === active?.id);
|
|
565
|
+
const overIndex = dataSource.findIndex((record) => record[rowKey] === over?.id);
|
|
566
|
+
const newSort = arrayMove(dataSource, activeIndex, overIndex);
|
|
567
|
+
onDragEnd(newSort);
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
[dataSource, rowKey, onDragEnd]
|
|
571
|
+
);
|
|
572
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(DndContext, { modifiers: [restrictToVerticalAxis], onDragEnd: handleDragEnd, children: /* @__PURE__ */ jsx(SortableContext, { items, strategy: verticalListSortingStrategy, children }) }) });
|
|
573
|
+
};
|
|
574
|
+
const DndRow = (props) => {
|
|
575
|
+
const {
|
|
576
|
+
attributes,
|
|
577
|
+
listeners,
|
|
578
|
+
setNodeRef,
|
|
579
|
+
setActivatorNodeRef,
|
|
580
|
+
transform,
|
|
581
|
+
transition,
|
|
582
|
+
isDragging
|
|
583
|
+
} = useSortable({ id: props["data-row-key"] });
|
|
584
|
+
const style = {
|
|
585
|
+
...props.style,
|
|
586
|
+
transform: CSS.Translate.toString(transform),
|
|
587
|
+
transition,
|
|
588
|
+
cursor: "default",
|
|
589
|
+
...isDragging ? { position: "relative", zIndex: 10 } : {}
|
|
590
|
+
};
|
|
591
|
+
const contextValue = useMemo(
|
|
592
|
+
() => ({ setActivatorNodeRef, listeners }),
|
|
593
|
+
[setActivatorNodeRef, listeners]
|
|
594
|
+
);
|
|
595
|
+
return /* @__PURE__ */ jsx(RowContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("tr", { ...props, ref: setNodeRef, style, ...attributes }) });
|
|
596
|
+
};
|
|
597
|
+
const ItemRender = ({ page, type, current, isFa }) => {
|
|
598
|
+
const isCurrentPage = Number(page) === current;
|
|
599
|
+
return /* @__PURE__ */ jsx(Flex, { className: "h-[30px] items-center justify-center", children: type === "page" ? /* @__PURE__ */ jsx(
|
|
600
|
+
Text,
|
|
601
|
+
{
|
|
602
|
+
weight: isCurrentPage ? "bold" : "normal",
|
|
603
|
+
size: isCurrentPage ? 20 : 18,
|
|
604
|
+
color: isCurrentPage ? colors.primary : colors.primary_dark_1,
|
|
605
|
+
children: page
|
|
606
|
+
}
|
|
607
|
+
) : type === "next" ? /* @__PURE__ */ jsx(Flex, { className: "me-4 h-[30px] w-[30px] items-center justify-center rounded border border-light-7", children: /* @__PURE__ */ jsx(Icon, { name: isFa ? "Chevron_Right" : "Chevron_Left", color: colors.primary }) }) : type === "prev" ? /* @__PURE__ */ jsx(Flex, { className: "h-[30px] w-[30px] items-center justify-center rounded border border-light-7", children: /* @__PURE__ */ jsx(Icon, { name: isFa ? "Chevron_Left" : "Chevron_Right", color: colors.primary }) }) : /* @__PURE__ */ jsx(Text, { size: 18, children: "..." }) });
|
|
608
|
+
};
|
|
609
|
+
const CHANGE_ORDER = "CHANGE_ORDER";
|
|
610
|
+
const CHANGE_PAGE = "CHANGE_PAGE";
|
|
611
|
+
const CHANGE = "CHANGE";
|
|
612
|
+
const PAGE_SEARCH_PARAM = "page";
|
|
613
|
+
const initialState = {
|
|
614
|
+
order: void 0,
|
|
615
|
+
orderBy: "",
|
|
616
|
+
pageSize: 10,
|
|
617
|
+
current: 1,
|
|
618
|
+
filters: {}
|
|
619
|
+
};
|
|
620
|
+
function reducer(state, action) {
|
|
621
|
+
switch (action.type) {
|
|
622
|
+
case CHANGE_ORDER:
|
|
623
|
+
return {
|
|
624
|
+
...state,
|
|
625
|
+
orderBy: action.payload.orderBy,
|
|
626
|
+
order: action.payload.order
|
|
627
|
+
};
|
|
628
|
+
case CHANGE_PAGE:
|
|
629
|
+
return {
|
|
630
|
+
...state,
|
|
631
|
+
current: action.payload.current,
|
|
632
|
+
pageSize: action.payload.pageSize === void 0 ? state.pageSize : action.payload.pageSize
|
|
633
|
+
};
|
|
634
|
+
case CHANGE:
|
|
635
|
+
return {
|
|
636
|
+
...state,
|
|
637
|
+
current: action.payload.current,
|
|
638
|
+
pageSize: action.payload.pageSize ?? state.pageSize,
|
|
639
|
+
order: action.payload.order,
|
|
640
|
+
orderBy: action.payload.orderBy,
|
|
641
|
+
filters: action.payload.filters
|
|
642
|
+
};
|
|
643
|
+
default:
|
|
644
|
+
return state;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
function usePagination({
|
|
648
|
+
defaultCurrent = 1,
|
|
649
|
+
defaultPageSize = 10,
|
|
650
|
+
hasQueryParams = false,
|
|
651
|
+
hideOnSinglePage,
|
|
652
|
+
style,
|
|
653
|
+
...rest
|
|
654
|
+
}) {
|
|
655
|
+
const { isSmallerThanMedium } = useObserveWindow();
|
|
656
|
+
const navigate = useNavigate();
|
|
657
|
+
const [searchParams] = useSearchParams();
|
|
658
|
+
const [localPageSize, setLocalPageSize] = useLocalStorageState(
|
|
659
|
+
PAGINATION_SIZE,
|
|
660
|
+
defaultPageSize
|
|
661
|
+
);
|
|
662
|
+
const [total, setTotal] = useState(0);
|
|
663
|
+
const { i18n } = useTranslation();
|
|
664
|
+
const [{ current, order, orderBy, pageSize, filters }, dispatch] = useReducer(
|
|
665
|
+
reducer,
|
|
666
|
+
{
|
|
667
|
+
...initialState,
|
|
668
|
+
pageSize: localPageSize,
|
|
669
|
+
current: hasQueryParams ? Number(searchParams.get(PAGE_SEARCH_PARAM) || String(defaultCurrent)) : defaultCurrent
|
|
670
|
+
}
|
|
671
|
+
);
|
|
672
|
+
localStorage.removeItem(PAGINATION_SIZE);
|
|
673
|
+
const onChange = useCallback(
|
|
674
|
+
(pagination2, filters2, sorter) => {
|
|
675
|
+
const sort = Array.isArray(sorter) ? sorter[0] : sorter;
|
|
676
|
+
setLocalPageSize(pagination2.pageSize || defaultPageSize);
|
|
677
|
+
dispatch({
|
|
678
|
+
type: CHANGE,
|
|
679
|
+
payload: {
|
|
680
|
+
filters: filters2,
|
|
681
|
+
current: pagination2.current,
|
|
682
|
+
pageSize: pagination2.pageSize,
|
|
683
|
+
orderBy: Array.isArray(sort?.field) ? sort?.field[0] : sort?.field,
|
|
684
|
+
order: sort?.order
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
},
|
|
688
|
+
[defaultPageSize, setLocalPageSize]
|
|
689
|
+
);
|
|
690
|
+
const handleInternalPagination = (page, pageSize2) => {
|
|
691
|
+
dispatch({ type: CHANGE_PAGE, payload: { current: page, pageSize: pageSize2 } });
|
|
692
|
+
};
|
|
693
|
+
const getTotal = (total2) => setTotal(total2 || defaultPageSize);
|
|
694
|
+
useEffect(() => {
|
|
695
|
+
if (hasQueryParams) {
|
|
696
|
+
navigate({ search: `?${PAGE_SEARCH_PARAM}=${current}` }, { replace: true });
|
|
697
|
+
}
|
|
698
|
+
}, [current, hasQueryParams]);
|
|
699
|
+
const pagination = {
|
|
700
|
+
total,
|
|
701
|
+
current,
|
|
702
|
+
pageSize,
|
|
703
|
+
defaultCurrent,
|
|
704
|
+
defaultPageSize,
|
|
705
|
+
onChange: handleInternalPagination,
|
|
706
|
+
pageSizeOptions: ["10", "20", "30"],
|
|
707
|
+
showSizeChanger: true,
|
|
708
|
+
hideOnSinglePage,
|
|
709
|
+
className: "border border-negative",
|
|
710
|
+
style: {
|
|
711
|
+
backgroundColor: colors.white_ff,
|
|
712
|
+
paddingInline: isSmallerThanMedium ? 4 : 24,
|
|
713
|
+
paddingBlock: 16,
|
|
714
|
+
margin: 0,
|
|
715
|
+
borderTop: `1px solid ${colors.light_7}`,
|
|
716
|
+
flexDirection: "row-reverse",
|
|
717
|
+
justifyContent: "flex-start",
|
|
718
|
+
border: "none",
|
|
719
|
+
...style
|
|
720
|
+
},
|
|
721
|
+
showPrevNextJumpers: true,
|
|
722
|
+
showQuickJumper: true,
|
|
723
|
+
rootClassName: "flex items-center [&_.ant-select-dropdown]:!p-0 [&_.ant-pagination-options]:flex [&_.ant-pagination-options]:items-center [&_.ant-pagination-options]:justify-between [&_.ant-pagination-options]:flex-1",
|
|
724
|
+
// selectComponentClass: () => SelectComponentClass({ filters, onChange, pageSize, pagination }),
|
|
725
|
+
itemRender: (page, type) => ItemRender({ current, page, type, isFa: i18n.language === "fa" }),
|
|
726
|
+
...rest
|
|
727
|
+
};
|
|
728
|
+
return {
|
|
729
|
+
filters,
|
|
730
|
+
current,
|
|
731
|
+
pageSize,
|
|
732
|
+
pagination,
|
|
733
|
+
order,
|
|
734
|
+
orderBy,
|
|
735
|
+
onChange,
|
|
736
|
+
getTotal
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
const Table = ({
|
|
740
|
+
className,
|
|
741
|
+
children,
|
|
742
|
+
expandable,
|
|
743
|
+
rowSelection,
|
|
744
|
+
size,
|
|
745
|
+
pagination,
|
|
746
|
+
loading,
|
|
747
|
+
transparentHeader,
|
|
748
|
+
internalScroll = true,
|
|
749
|
+
extraHeight = 100,
|
|
750
|
+
footer,
|
|
751
|
+
theme,
|
|
752
|
+
dndSort,
|
|
753
|
+
components,
|
|
754
|
+
...rest
|
|
755
|
+
}) => {
|
|
756
|
+
const [scrollY, setScrollY] = useState();
|
|
757
|
+
const ref = useRef(null);
|
|
758
|
+
useEffect(() => {
|
|
759
|
+
if (!ref.current) {
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
setScrollY(
|
|
763
|
+
window.innerHeight - ref.current.offsetTop - 46 - (pagination ? 65 : 0) - extraHeight
|
|
764
|
+
);
|
|
765
|
+
}, [pagination, theme?.components?.Table?.headerBg]);
|
|
766
|
+
const columns = useMemo(() => {
|
|
767
|
+
function getChildren(_children) {
|
|
768
|
+
if (!_children) {
|
|
769
|
+
return [];
|
|
770
|
+
}
|
|
771
|
+
if (typeof _children === "boolean" || typeof _children === "undefined" || _children === null) {
|
|
772
|
+
return [];
|
|
773
|
+
}
|
|
774
|
+
if (typeof _children !== "object") {
|
|
775
|
+
throw new Error("Table children must be Column");
|
|
776
|
+
}
|
|
777
|
+
if (!Array.isArray(_children)) {
|
|
778
|
+
if (_children.type === Column) {
|
|
779
|
+
const result = {
|
|
780
|
+
..._children.props,
|
|
781
|
+
child: _children
|
|
782
|
+
};
|
|
783
|
+
return [result];
|
|
784
|
+
}
|
|
785
|
+
if (_children.type === Fragment$1) {
|
|
786
|
+
return getChildren(_children.props?.children);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return (_children || [])?.flatMap((child) => {
|
|
790
|
+
return getChildren(child);
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
const mappedChildren = getChildren(children);
|
|
794
|
+
return mappedChildren;
|
|
795
|
+
}, [children]);
|
|
796
|
+
const Provider = ({ children: children2 }) => dndSort === void 0 ? /* @__PURE__ */ jsx(Fragment, { children: children2 }) : /* @__PURE__ */ jsx(
|
|
797
|
+
DndSortProvider,
|
|
798
|
+
{
|
|
799
|
+
children: children2,
|
|
800
|
+
onDragEnd: dndSort.onDragEnd,
|
|
801
|
+
dataSource: rest.dataSource,
|
|
802
|
+
rowKey: rest.rowKey
|
|
803
|
+
}
|
|
804
|
+
);
|
|
805
|
+
return /* @__PURE__ */ jsx(ConfigProvider, { theme: CustomizedAntTableConfig(theme), children: /* @__PURE__ */ jsx(Provider, { children: /* @__PURE__ */ jsxs(
|
|
806
|
+
Table$1,
|
|
807
|
+
{
|
|
808
|
+
ref,
|
|
809
|
+
loading: {
|
|
810
|
+
indicator: /* @__PURE__ */ jsx(Flex, { className: "items-center justify-center", children: /* @__PURE__ */ jsx(Loading, { isLoading: true, size: 32, thickness: 3 }) }),
|
|
811
|
+
spinning: !!loading
|
|
812
|
+
},
|
|
813
|
+
scroll: internalScroll ? { y: scrollY } : void 0,
|
|
814
|
+
className: twMerge(
|
|
815
|
+
tailwindTableClasses,
|
|
816
|
+
"abrplus-table-custom-scroll-bar w-full !animate-none [&_.ant-table-thead_th]:!pt-2",
|
|
817
|
+
!!expandable && !!rowSelection && "[&_.ant-table-selection-column]:!ps-0",
|
|
818
|
+
transparentHeader && tableTransparentHeaderClasses,
|
|
819
|
+
className
|
|
820
|
+
),
|
|
821
|
+
rowSelection,
|
|
822
|
+
expandable: expandable ? {
|
|
823
|
+
...expandable,
|
|
824
|
+
expandedRowClassName: () => "[&_.ant-table-cell]:!p-0 [&_.ant-table-row-expand-icon-cell]:!p-0 ",
|
|
825
|
+
expandIcon: ({ expandable: expandable2, expanded, onExpand, record }) => /* @__PURE__ */ jsx(
|
|
826
|
+
ExpandIcon,
|
|
827
|
+
{
|
|
828
|
+
...{ expandable: expandable2, expanded },
|
|
829
|
+
onExpand: (e) => onExpand?.(record, e)
|
|
830
|
+
}
|
|
831
|
+
)
|
|
832
|
+
} : void 0,
|
|
833
|
+
pagination,
|
|
834
|
+
footer,
|
|
835
|
+
components: dndSort ? { body: { row: DndRow } } : components,
|
|
836
|
+
...rest,
|
|
837
|
+
children: [
|
|
838
|
+
dndSort && /* @__PURE__ */ jsx(Table.Column, { align: "center", width: 80, render: () => /* @__PURE__ */ jsx(DragHandle, {}) }, "sort"),
|
|
839
|
+
columns.map(
|
|
840
|
+
({
|
|
841
|
+
render,
|
|
842
|
+
children: children2,
|
|
843
|
+
dataIndex,
|
|
844
|
+
align,
|
|
845
|
+
headerStyle,
|
|
846
|
+
headerClassName,
|
|
847
|
+
className: className2,
|
|
848
|
+
filtersOptions,
|
|
849
|
+
sortIconOptions,
|
|
850
|
+
...rest2
|
|
851
|
+
}, colIndex) => /* @__PURE__ */ jsx(
|
|
852
|
+
Table$1.Column,
|
|
853
|
+
{
|
|
854
|
+
...rest2,
|
|
855
|
+
dataIndex: dataIndex?.toString(),
|
|
856
|
+
className: twMerge("h-[56px] [&_.ant-table-column-title]:!flex-1", className2),
|
|
857
|
+
title: /* @__PURE__ */ jsxs(
|
|
858
|
+
Flex,
|
|
859
|
+
{
|
|
860
|
+
className: "ant-table-column-title-content items-center justify-between",
|
|
861
|
+
flex: 1,
|
|
862
|
+
children: [
|
|
863
|
+
/* @__PURE__ */ jsx(
|
|
864
|
+
TableHeaderTitle,
|
|
865
|
+
{
|
|
866
|
+
title: children2,
|
|
867
|
+
align,
|
|
868
|
+
style: headerStyle,
|
|
869
|
+
className: headerClassName
|
|
870
|
+
}
|
|
871
|
+
),
|
|
872
|
+
filtersOptions?.renderFilter?.()
|
|
873
|
+
]
|
|
874
|
+
}
|
|
875
|
+
),
|
|
876
|
+
render: (value, row, index) => /* @__PURE__ */ jsx(
|
|
877
|
+
Flex,
|
|
878
|
+
{
|
|
879
|
+
className: twMerge("items-center", rowHeightClassName[size || "large"]),
|
|
880
|
+
style: {
|
|
881
|
+
wordWrap: "break-word",
|
|
882
|
+
wordBreak: "break-word",
|
|
883
|
+
paddingInlineEnd: colIndex === columns.length - 1 ? 24 : void 0
|
|
884
|
+
},
|
|
885
|
+
children: render ? render({ index, row, value }) : /* @__PURE__ */ jsx(TableCell, { children: value })
|
|
886
|
+
}
|
|
887
|
+
),
|
|
888
|
+
showSorterTooltip: false,
|
|
889
|
+
sortIcon: ({ sortOrder }) => {
|
|
890
|
+
return /* @__PURE__ */ jsxs(
|
|
891
|
+
Flex,
|
|
892
|
+
{
|
|
893
|
+
vertical: true,
|
|
894
|
+
...sortIconOptions,
|
|
895
|
+
className: twMerge(
|
|
896
|
+
"table-filters-sort flex-[4] ps-2",
|
|
897
|
+
sortIconOptions?.className
|
|
898
|
+
),
|
|
899
|
+
children: [
|
|
900
|
+
/* @__PURE__ */ jsx(
|
|
901
|
+
Icon,
|
|
902
|
+
{
|
|
903
|
+
size: 12,
|
|
904
|
+
color: sortOrder === "ascend" ? colors.primary : colors.primary_light_3,
|
|
905
|
+
name: "Chevron_Up",
|
|
906
|
+
style: { marginBottom: -4 }
|
|
907
|
+
}
|
|
908
|
+
),
|
|
909
|
+
/* @__PURE__ */ jsx(
|
|
910
|
+
Icon,
|
|
911
|
+
{
|
|
912
|
+
size: 12,
|
|
913
|
+
color: sortOrder === "descend" ? colors.primary : colors.primary_light_3,
|
|
914
|
+
name: "Chevron_Down"
|
|
915
|
+
}
|
|
916
|
+
)
|
|
917
|
+
]
|
|
918
|
+
}
|
|
919
|
+
);
|
|
920
|
+
}
|
|
921
|
+
},
|
|
922
|
+
colIndex
|
|
923
|
+
)
|
|
924
|
+
)
|
|
925
|
+
]
|
|
926
|
+
}
|
|
927
|
+
) }) });
|
|
928
|
+
};
|
|
929
|
+
Table.Cell = TableCell;
|
|
930
|
+
Table.Column = Column;
|
|
931
|
+
Table.Currency = TableCell.Currency;
|
|
932
|
+
Table.Date = TableCell.Date;
|
|
933
|
+
Table.Status = TableCell.StatusCell;
|
|
934
|
+
Table.usePagination = usePagination;
|
|
935
|
+
export {
|
|
936
|
+
AvatarGroup,
|
|
937
|
+
Drawer,
|
|
938
|
+
Modal,
|
|
939
|
+
Table
|
|
940
|
+
};
|