@pezeshk-book/modules 0.2.8 → 0.2.10

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.
Files changed (221) hide show
  1. package/calendar/calendar.d.ts +3 -0
  2. package/{dist/calendar → calendar}/calendar.js +32 -8
  3. package/calendar/calendar.js.map +1 -0
  4. package/{dist/calendar → calendar}/calendar.props.d.ts +5 -2
  5. package/package.json +1 -1
  6. package/.eslintrc.json +0 -133
  7. package/calendar/calendar.props.ts +0 -25
  8. package/calendar/calendar.tsx +0 -185
  9. package/calendar/config/chunk.ts +0 -42
  10. package/calendar/config/create-date-range.ts +0 -14
  11. package/calendar/config/days-in-month.en.ts +0 -47
  12. package/calendar/config/days-in-month.fa.ts +0 -37
  13. package/calendar/config/index.ts +0 -16
  14. package/calendar/config/months.ts +0 -29
  15. package/calendar/config/week-day.ts +0 -19
  16. package/calendar/icons/arrow-left-icon.tsx +0 -14
  17. package/calendar/icons/arrow-right-icon.tsx +0 -14
  18. package/calendar/icons/index.ts +0 -7
  19. package/calendar/index.ts +0 -3
  20. package/calendar/shared/formatDate.tsx +0 -12
  21. package/calendar/sub-components/day/day.props.ts +0 -27
  22. package/calendar/sub-components/day/day.tsx +0 -31
  23. package/calendar/sub-components/days/days.props.ts +0 -51
  24. package/calendar/sub-components/days/days.tsx +0 -142
  25. package/calendar/sub-components/days-head/days-head.props.ts +0 -27
  26. package/calendar/sub-components/days-head/days-head.tsx +0 -122
  27. package/countdown-timer/countdown.props.ts +0 -18
  28. package/countdown-timer/countdown.tsx +0 -79
  29. package/countdown-timer/index.ts +0 -3
  30. package/data-table/data-table.props.ts +0 -7
  31. package/data-table/data-table.tsx +0 -17
  32. package/data-table/default/default-data-table.props.ts +0 -47
  33. package/data-table/default/default-data-table.tsx +0 -427
  34. package/data-table/default/index.ts +0 -3
  35. package/data-table/hooks/use-window-dimensions.tsx +0 -33
  36. package/data-table/icons/add.tsx +0 -10
  37. package/data-table/icons/arrow-down.tsx +0 -11
  38. package/data-table/icons/index.ts +0 -9
  39. package/data-table/icons/sort.tsx +0 -16
  40. package/data-table/index.ts +0 -3
  41. package/data-table/simple/index.ts +0 -3
  42. package/data-table/simple/simple-data-table.props.ts +0 -23
  43. package/data-table/simple/simple-data-table.tsx +0 -258
  44. package/dist/calendar/calendar.d.ts +0 -3
  45. package/dist/calendar/calendar.js.map +0 -1
  46. package/index.ts +0 -13
  47. package/pagination/icons/arrow-Right.tsx +0 -22
  48. package/pagination/icons/arrow-left.tsx +0 -22
  49. package/pagination/icons/index.ts +0 -7
  50. package/pagination/index.ts +0 -3
  51. package/pagination/pagination.props.ts +0 -33
  52. package/pagination/pagination.tsx +0 -135
  53. package/pagination/use-pagination.ts +0 -49
  54. package/react-app-env.d.ts +0 -1
  55. package/slider/index.ts +0 -3
  56. package/slider/slider.props.ts +0 -39
  57. package/slider/slider.tsx +0 -292
  58. package/stories/calendar/calendar.stories.tsx +0 -25
  59. package/stories/calendar/calendar.tsx +0 -11
  60. package/stories/count-down/count-down.stories.tsx +0 -19
  61. package/stories/count-down/count-down.tsx +0 -11
  62. package/stories/data-table/data-table-columns.tsx +0 -70
  63. package/stories/data-table/default-data-table.stories.tsx +0 -22
  64. package/stories/data-table/default-data-table.tsx +0 -18
  65. package/stories/data-table/dummy-data.ts +0 -204
  66. package/stories/data-table/simple-data-table.stories.tsx +0 -22
  67. package/stories/data-table/simple-data-table.tsx +0 -18
  68. package/stories/pagination/pagination.stories.tsx +0 -35
  69. package/stories/pagination/pagination.tsx +0 -11
  70. package/stories/slider/slider.stories.tsx +0 -19
  71. package/stories/slider/slider.tsx +0 -45
  72. package/stories/wrapper.tsx +0 -11
  73. package/styles.css +0 -28
  74. package/utils/class-names.ts +0 -5
  75. package/utils/persian-to-english-number.ts +0 -4
  76. /package/{dist/calendar → calendar}/calendar.props.js +0 -0
  77. /package/{dist/calendar → calendar}/calendar.props.js.map +0 -0
  78. /package/{dist/calendar → calendar}/config/chunk.d.ts +0 -0
  79. /package/{dist/calendar → calendar}/config/chunk.js +0 -0
  80. /package/{dist/calendar → calendar}/config/chunk.js.map +0 -0
  81. /package/{dist/calendar → calendar}/config/create-date-range.d.ts +0 -0
  82. /package/{dist/calendar → calendar}/config/create-date-range.js +0 -0
  83. /package/{dist/calendar → calendar}/config/create-date-range.js.map +0 -0
  84. /package/{dist/calendar → calendar}/config/days-in-month.en.d.ts +0 -0
  85. /package/{dist/calendar → calendar}/config/days-in-month.en.js +0 -0
  86. /package/{dist/calendar → calendar}/config/days-in-month.en.js.map +0 -0
  87. /package/{dist/calendar → calendar}/config/days-in-month.fa.d.ts +0 -0
  88. /package/{dist/calendar → calendar}/config/days-in-month.fa.js +0 -0
  89. /package/{dist/calendar → calendar}/config/days-in-month.fa.js.map +0 -0
  90. /package/{dist/calendar → calendar}/config/index.d.ts +0 -0
  91. /package/{dist/calendar → calendar}/config/index.js +0 -0
  92. /package/{dist/calendar → calendar}/config/index.js.map +0 -0
  93. /package/{dist/calendar → calendar}/config/months.d.ts +0 -0
  94. /package/{dist/calendar → calendar}/config/months.js +0 -0
  95. /package/{dist/calendar → calendar}/config/months.js.map +0 -0
  96. /package/{dist/calendar → calendar}/config/week-day.d.ts +0 -0
  97. /package/{dist/calendar → calendar}/config/week-day.js +0 -0
  98. /package/{dist/calendar → calendar}/config/week-day.js.map +0 -0
  99. /package/{dist/calendar → calendar}/icons/arrow-left-icon.d.ts +0 -0
  100. /package/{dist/calendar → calendar}/icons/arrow-left-icon.js +0 -0
  101. /package/{dist/calendar → calendar}/icons/arrow-left-icon.js.map +0 -0
  102. /package/{dist/calendar → calendar}/icons/arrow-right-icon.d.ts +0 -0
  103. /package/{dist/calendar → calendar}/icons/arrow-right-icon.js +0 -0
  104. /package/{dist/calendar → calendar}/icons/arrow-right-icon.js.map +0 -0
  105. /package/{dist/calendar → calendar}/icons/index.d.ts +0 -0
  106. /package/{dist/calendar → calendar}/icons/index.js +0 -0
  107. /package/{dist/calendar → calendar}/icons/index.js.map +0 -0
  108. /package/{dist/calendar → calendar}/index.d.ts +0 -0
  109. /package/{dist/calendar → calendar}/index.js +0 -0
  110. /package/{dist/calendar → calendar}/index.js.map +0 -0
  111. /package/{dist/calendar → calendar}/shared/formatDate.d.ts +0 -0
  112. /package/{dist/calendar → calendar}/shared/formatDate.js +0 -0
  113. /package/{dist/calendar → calendar}/shared/formatDate.js.map +0 -0
  114. /package/{dist/calendar → calendar}/sub-components/day/day.d.ts +0 -0
  115. /package/{dist/calendar → calendar}/sub-components/day/day.js +0 -0
  116. /package/{dist/calendar → calendar}/sub-components/day/day.js.map +0 -0
  117. /package/{dist/calendar → calendar}/sub-components/day/day.props.d.ts +0 -0
  118. /package/{dist/calendar → calendar}/sub-components/day/day.props.js +0 -0
  119. /package/{dist/calendar → calendar}/sub-components/day/day.props.js.map +0 -0
  120. /package/{dist/calendar → calendar}/sub-components/days/days.d.ts +0 -0
  121. /package/{dist/calendar → calendar}/sub-components/days/days.js +0 -0
  122. /package/{dist/calendar → calendar}/sub-components/days/days.js.map +0 -0
  123. /package/{dist/calendar → calendar}/sub-components/days/days.props.d.ts +0 -0
  124. /package/{dist/calendar → calendar}/sub-components/days/days.props.js +0 -0
  125. /package/{dist/calendar → calendar}/sub-components/days/days.props.js.map +0 -0
  126. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.d.ts +0 -0
  127. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.js +0 -0
  128. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.js.map +0 -0
  129. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.d.ts +0 -0
  130. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.js +0 -0
  131. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.js.map +0 -0
  132. /package/{dist/countdown-timer → countdown-timer}/countdown.d.ts +0 -0
  133. /package/{dist/countdown-timer → countdown-timer}/countdown.js +0 -0
  134. /package/{dist/countdown-timer → countdown-timer}/countdown.js.map +0 -0
  135. /package/{dist/countdown-timer → countdown-timer}/countdown.props.d.ts +0 -0
  136. /package/{dist/countdown-timer → countdown-timer}/countdown.props.js +0 -0
  137. /package/{dist/countdown-timer → countdown-timer}/countdown.props.js.map +0 -0
  138. /package/{dist/countdown-timer → countdown-timer}/index.d.ts +0 -0
  139. /package/{dist/countdown-timer → countdown-timer}/index.js +0 -0
  140. /package/{dist/countdown-timer → countdown-timer}/index.js.map +0 -0
  141. /package/{dist/data-table → data-table}/data-table.d.ts +0 -0
  142. /package/{dist/data-table → data-table}/data-table.js +0 -0
  143. /package/{dist/data-table → data-table}/data-table.js.map +0 -0
  144. /package/{dist/data-table → data-table}/data-table.props.d.ts +0 -0
  145. /package/{dist/data-table → data-table}/data-table.props.js +0 -0
  146. /package/{dist/data-table → data-table}/data-table.props.js.map +0 -0
  147. /package/{dist/data-table → data-table}/default/default-data-table.d.ts +0 -0
  148. /package/{dist/data-table → data-table}/default/default-data-table.js +0 -0
  149. /package/{dist/data-table → data-table}/default/default-data-table.js.map +0 -0
  150. /package/{dist/data-table → data-table}/default/default-data-table.props.d.ts +0 -0
  151. /package/{dist/data-table → data-table}/default/default-data-table.props.js +0 -0
  152. /package/{dist/data-table → data-table}/default/default-data-table.props.js.map +0 -0
  153. /package/{dist/data-table → data-table}/default/index.d.ts +0 -0
  154. /package/{dist/data-table → data-table}/default/index.js +0 -0
  155. /package/{dist/data-table → data-table}/default/index.js.map +0 -0
  156. /package/{dist/data-table → data-table}/hooks/use-window-dimensions.d.ts +0 -0
  157. /package/{dist/data-table → data-table}/hooks/use-window-dimensions.js +0 -0
  158. /package/{dist/data-table → data-table}/hooks/use-window-dimensions.js.map +0 -0
  159. /package/{dist/data-table → data-table}/icons/add.d.ts +0 -0
  160. /package/{dist/data-table → data-table}/icons/add.js +0 -0
  161. /package/{dist/data-table → data-table}/icons/add.js.map +0 -0
  162. /package/{dist/data-table → data-table}/icons/arrow-down.d.ts +0 -0
  163. /package/{dist/data-table → data-table}/icons/arrow-down.js +0 -0
  164. /package/{dist/data-table → data-table}/icons/arrow-down.js.map +0 -0
  165. /package/{dist/data-table → data-table}/icons/index.d.ts +0 -0
  166. /package/{dist/data-table → data-table}/icons/index.js +0 -0
  167. /package/{dist/data-table → data-table}/icons/index.js.map +0 -0
  168. /package/{dist/data-table → data-table}/icons/sort.d.ts +0 -0
  169. /package/{dist/data-table → data-table}/icons/sort.js +0 -0
  170. /package/{dist/data-table → data-table}/icons/sort.js.map +0 -0
  171. /package/{dist/data-table → data-table}/index.d.ts +0 -0
  172. /package/{dist/data-table → data-table}/index.js +0 -0
  173. /package/{dist/data-table → data-table}/index.js.map +0 -0
  174. /package/{dist/data-table → data-table}/simple/index.d.ts +0 -0
  175. /package/{dist/data-table → data-table}/simple/index.js +0 -0
  176. /package/{dist/data-table → data-table}/simple/index.js.map +0 -0
  177. /package/{dist/data-table → data-table}/simple/simple-data-table.d.ts +0 -0
  178. /package/{dist/data-table → data-table}/simple/simple-data-table.js +0 -0
  179. /package/{dist/data-table → data-table}/simple/simple-data-table.js.map +0 -0
  180. /package/{dist/data-table → data-table}/simple/simple-data-table.props.d.ts +0 -0
  181. /package/{dist/data-table → data-table}/simple/simple-data-table.props.js +0 -0
  182. /package/{dist/data-table → data-table}/simple/simple-data-table.props.js.map +0 -0
  183. /package/{dist/index.d.ts → index.d.ts} +0 -0
  184. /package/{dist/index.js → index.js} +0 -0
  185. /package/{dist/index.js.map → index.js.map} +0 -0
  186. /package/{dist/pagination → pagination}/icons/arrow-Right.d.ts +0 -0
  187. /package/{dist/pagination → pagination}/icons/arrow-Right.js +0 -0
  188. /package/{dist/pagination → pagination}/icons/arrow-Right.js.map +0 -0
  189. /package/{dist/pagination → pagination}/icons/arrow-left.d.ts +0 -0
  190. /package/{dist/pagination → pagination}/icons/arrow-left.js +0 -0
  191. /package/{dist/pagination → pagination}/icons/arrow-left.js.map +0 -0
  192. /package/{dist/pagination → pagination}/icons/index.d.ts +0 -0
  193. /package/{dist/pagination → pagination}/icons/index.js +0 -0
  194. /package/{dist/pagination → pagination}/icons/index.js.map +0 -0
  195. /package/{dist/pagination → pagination}/index.d.ts +0 -0
  196. /package/{dist/pagination → pagination}/index.js +0 -0
  197. /package/{dist/pagination → pagination}/index.js.map +0 -0
  198. /package/{dist/pagination → pagination}/pagination.d.ts +0 -0
  199. /package/{dist/pagination → pagination}/pagination.js +0 -0
  200. /package/{dist/pagination → pagination}/pagination.js.map +0 -0
  201. /package/{dist/pagination → pagination}/pagination.props.d.ts +0 -0
  202. /package/{dist/pagination → pagination}/pagination.props.js +0 -0
  203. /package/{dist/pagination → pagination}/pagination.props.js.map +0 -0
  204. /package/{dist/pagination → pagination}/use-pagination.d.ts +0 -0
  205. /package/{dist/pagination → pagination}/use-pagination.js +0 -0
  206. /package/{dist/pagination → pagination}/use-pagination.js.map +0 -0
  207. /package/{dist/slider → slider}/index.d.ts +0 -0
  208. /package/{dist/slider → slider}/index.js +0 -0
  209. /package/{dist/slider → slider}/index.js.map +0 -0
  210. /package/{dist/slider → slider}/slider.d.ts +0 -0
  211. /package/{dist/slider → slider}/slider.js +0 -0
  212. /package/{dist/slider → slider}/slider.js.map +0 -0
  213. /package/{dist/slider → slider}/slider.props.d.ts +0 -0
  214. /package/{dist/slider → slider}/slider.props.js +0 -0
  215. /package/{dist/slider → slider}/slider.props.js.map +0 -0
  216. /package/{dist/utils → utils}/class-names.d.ts +0 -0
  217. /package/{dist/utils → utils}/class-names.js +0 -0
  218. /package/{dist/utils → utils}/class-names.js.map +0 -0
  219. /package/{dist/utils → utils}/persian-to-english-number.d.ts +0 -0
  220. /package/{dist/utils → utils}/persian-to-english-number.js +0 -0
  221. /package/{dist/utils → utils}/persian-to-english-number.js.map +0 -0
@@ -1,427 +0,0 @@
1
- import { Fragment, useEffect, useState } from 'react';
2
- import { Button, Checkbox, classNames, Div, FormControlLabel, LoadingIndicator, Skeleton, Text } from '@pezeshk-book/ui-kit';
3
- import Pagination from '../../pagination';
4
- import { DefaultDataTableProps } from './default-data-table.props';
5
- import {
6
- ColumnDef,
7
- flexRender,
8
- getCoreRowModel,
9
- getExpandedRowModel,
10
- getSortedRowModel,
11
- RowData,
12
- SortingState,
13
- useReactTable,
14
- } from '@tanstack/react-table';
15
- import useWindowDimensions from '../hooks/use-window-dimensions';
16
- import { ArrowDownIcon, AddIcon, SortIcon } from '../icons';
17
- import { AnimatePresence, motion } from 'motion/react';
18
-
19
- declare module '@tanstack/react-table' {
20
- // eslint-disable-next-line no-unused-vars
21
- interface TableMeta<TData extends RowData> {
22
- updateData: (value: string, info?: string | object) => void
23
- }
24
- }
25
-
26
- const fillArray = (n: number) => Array.from({ length: n + 1 }, (_, i) => i);
27
-
28
- const DefaultDataTable = (
29
- {
30
- header,
31
- data,
32
- column,
33
- mobileColumns,
34
- expandable = false,
35
- expandedComponent,
36
- serverSideSorting,
37
- isLoading = false,
38
- getCurrentPage,
39
- lastPage,
40
- perPage,
41
- currentPage,
42
- total,
43
- previousPage,
44
- nextPage,
45
- getLimit,
46
- columnOrder = false,
47
- updateData,
48
- select,
49
- selectedRows,
50
- expandAll = false,
51
- visitedRows = [],
52
- }: DefaultDataTableProps) => {
53
- const [rowSelection, setRowSelection] = useState({});
54
- const [sorting, setSorting] = useState<SortingState>([]);
55
- const [scrollPosition, setScrollPosition] = useState(0);
56
- const [showGoTop, setShowGoTop] = useState(false);
57
- const [columnVisibility, setColumnVisibility] = useState<any>({});
58
- const [rowExpander, setRowExpander] = useState<Array<any>>([]);
59
-
60
- const dimensions = useWindowDimensions();
61
-
62
- const handleMobileExpander = (row: { index: number }) => {
63
- if (rowExpander.indexOf(row.index) === -1) {
64
- setRowExpander([...rowExpander, row.index]);
65
- } else {
66
- setRowExpander(value => value.filter(item => item !== row.index));
67
- }
68
- };
69
- const columns: ColumnDef<any>[] = [
70
- {
71
- id: 'mobileExpander',
72
- accessorKey: 'mobileExpander',
73
- header: () => null,
74
- cell: ({ row }) => {
75
- return (
76
- <Button
77
- onClick={() => handleMobileExpander(row)}
78
- startAdornment={
79
- <AddIcon
80
- className={classNames(
81
- 'absolute transition-all duration-500',
82
- rowExpander.indexOf(row.index) !== -1 ? 'rotate-[225deg]' : '',
83
- )}
84
- />
85
- }
86
- variant={'text'}
87
- size={'tiny'}
88
- className={'!p-0'}
89
- />
90
- );
91
- },
92
- enableSorting: false,
93
- },
94
- {
95
- id: 'select',
96
- accessorKey: 'select',
97
- header: ({ table }) => {
98
- return select ? (
99
- <Checkbox
100
- size={'small'}
101
- indeterminate={table.getIsSomeRowsSelected()}
102
- checked={table.getIsAllRowsSelected()}
103
- onChange={table.getToggleAllRowsSelectedHandler()}
104
- />
105
- ) : null;
106
- },
107
- cell: ({ row }) => {
108
- return row.getCanSelect() && select ? (
109
- <Checkbox
110
- size={'small'}
111
- onChange={row.getToggleSelectedHandler()}
112
- checked={row.getIsSelected()}
113
- />
114
- ) : null;
115
- },
116
- enableSorting: false,
117
- },
118
- ...column,
119
- {
120
- id: 'expander',
121
- accessorKey: 'expander',
122
- header: () => null,
123
- cell: ({ row }) => {
124
- return row.getCanExpand() ? (
125
- <Button
126
- className={'!p-0'}
127
- variant={'text'}
128
- size={'tiny'}
129
- {...{
130
- onClick: row.getToggleExpandedHandler(),
131
- style: { cursor: 'pointer' },
132
- }}
133
- >
134
- <ArrowDownIcon
135
- className={classNames(
136
- 'transition-all duration-300',
137
- row.getIsExpanded() ? 'rotate-180' : '')}
138
- />
139
- </Button>
140
- ) : null;
141
- },
142
- enableSorting: false,
143
- },
144
- ];
145
- const table = useReactTable({
146
- data,
147
- columns,
148
- getCoreRowModel: getCoreRowModel(),
149
- getSortedRowModel: getSortedRowModel(),
150
- getRowCanExpand: () => true,
151
- getExpandedRowModel: getExpandedRowModel(),
152
- state: {
153
- columnVisibility,
154
- rowSelection,
155
- sorting,
156
- },
157
- onColumnVisibilityChange: setColumnVisibility,
158
- onRowSelectionChange: setRowSelection,
159
- onSortingChange: setSorting,
160
- manualSorting: !!serverSideSorting,
161
- meta: {
162
- updateData: (value, info) => {
163
- if (updateData) {
164
- updateData(value, info);
165
- }
166
- },
167
- },
168
- });
169
-
170
- useEffect(() => {
171
- if (selectedRows) {
172
- selectedRows(table.getSelectedRowModel().rows.map((row) => {
173
- return row.original;
174
- }));
175
- }
176
- }, [rowSelection]);
177
-
178
- useEffect(() => {
179
- window.addEventListener('scroll', handleVisibleButton);
180
- });
181
-
182
- useEffect(() => {
183
- if (serverSideSorting && sorting.length > 0) {
184
- serverSideSorting(sorting);
185
- }
186
- }, [sorting]);
187
-
188
- useEffect(() => {
189
- const obj: any = {};
190
- if (dimensions.width < 640) {
191
- columns.forEach((value) => {
192
- if (value.id) {
193
- obj[value.id] = mobileColumns?.includes(value.id);
194
- }
195
- });
196
- setColumnVisibility({ ...obj, mobileExpander: true, expander: expandable, select: select });
197
- } else {
198
- columns.forEach((value) => {
199
- if (value.id) {
200
- obj[value.id] = true;
201
- }
202
- });
203
- setColumnVisibility({ ...obj, mobileExpander: false, expander: expandable, select: select });
204
- }
205
- }, [dimensions.width]);
206
-
207
- useEffect(() => {
208
- if (expandAll && dimensions.width < 640) {
209
- setRowExpander(fillArray(perPage));
210
- }
211
- if (expandAll && dimensions.width >= 640) {
212
- setRowExpander([]);
213
- }
214
- }, [expandAll, perPage, currentPage, dimensions.width]);
215
-
216
- const handleVisibleButton = () => {
217
- const position = window.scrollY;
218
- setScrollPosition(position);
219
-
220
- if (scrollPosition > 150) {
221
- return setShowGoTop(true);
222
- } else if (scrollPosition < 150) {
223
- return setShowGoTop(false);
224
- }
225
- };
226
-
227
- const handleScrollUp = () => {
228
- window.scrollTo({ behavior: 'smooth', top: 0 });
229
- };
230
-
231
- return (
232
- <Div className={'w-full flex-col relative'}>
233
- {isLoading && data.length > 0 ? (
234
- <Div className={'absolute bg-control bg-opacity-25 w-full h-full items-center justify-center z-50 rounded-xl'}>
235
- <LoadingIndicator size={'huge'} color={'control'}/>
236
- </Div>
237
- ) : null}
238
- <Div className={'gap-0 md:gap-4 flex-col md:flex-row'}>
239
- {columnOrder && table.getAllLeafColumns().map(column => {
240
- if (column.id === 'mobileExpander' || column.id === 'expander') {
241
- return null;
242
- }
243
- return (
244
- <FormControlLabel key={column.id} className={'p-2'} label={header[column.id]}>
245
- <Checkbox checked={column.getIsVisible()} onChange={column.getToggleVisibilityHandler()}/>
246
- </FormControlLabel>
247
- );
248
- })}
249
- </Div>
250
- <Div className={'bg-white md:border w-full border-control-300 border-opacity-50 p-2 rounded-xl max-w-full flex-col relative'}>
251
- <table className={'w-full table-auto'}>
252
- <thead className={'bg-control-50 h-14 sticky top-0 z-[9]'}>
253
- {table.getHeaderGroups().map(headerGroup => (
254
- <tr key={headerGroup.id}>
255
- {headerGroup.headers.map(header => (
256
- <th
257
- className={'hover:cursor-pointer'}
258
- onClick={header.column.getToggleSortingHandler()}
259
- key={header.id}>
260
- <Div className={'justify-center items-center gap-1'}>
261
- {header.column.getCanSort() ? (
262
- <Div className={'text-control-800'}>
263
- <SortIcon direction={header.column.getIsSorted() as string}/>
264
- </Div>
265
- ) : null}
266
- <Text color={header.column.getIsSorted() ? 'primary' : 'grey.800'} typography={'sm'} type={'bold'}>
267
- {header.isPlaceholder
268
- ? null
269
- : flexRender(
270
- header.column.columnDef.header,
271
- header.getContext(),
272
- )}
273
- </Text>
274
- </Div>
275
- </th>
276
- ))}
277
- </tr>
278
- ))}
279
- </thead>
280
- {isLoading && !data.length ? (
281
- <tbody>
282
- {[...new Array(15)].map((_, index) => (
283
- <tr key={`loadingItem_${index}`} className={'h-16'}>
284
- {table.getFlatHeaders().map(cell => {
285
- return (
286
- <td className={'px-1'} key={cell.id}>
287
- <Skeleton color={'control'} className={'!max-w-full !min-w-full'}/>
288
- </td>
289
- );
290
- })}
291
- </tr>
292
- ))}
293
- </tbody>
294
- ) : !isLoading && !data.length ? (
295
- <tbody>
296
- <tr className={'h-48'}>
297
- <td colSpan={table.getFlatHeaders().length}>
298
- <Text typography={'lg'} type={'bold'}>اطلاعاتی برای نمایش وجود ندارد!</Text>
299
- </td>
300
- </tr>
301
- </tbody>
302
- ) : (
303
- <tbody>
304
- {table.getRowModel().rows.map((row, index) => {
305
- return (
306
- <Fragment key={row.id}>
307
- {/* @ts-ignore */}
308
- <AnimatePresence mode="wait">
309
- <motion.tr
310
- key={row ? row.id : 'empty'}
311
- initial={{ y: 100, opacity: 0 }}
312
- animate={{ y: 0, opacity: 1 }}
313
- exit={{ y: -100, opacity: 0 }}
314
- transition={{ duration: 0.5, delay: index * 0.01 }}
315
- className={classNames('h-16 hover:bg-primary-50',
316
- row.getIsSelected() && 'bg-slate-200',
317
- visitedRows?.indexOf(row.index) !== -1 ? 'bg-slate-100' : '')}>
318
- {row.getVisibleCells().map(cell => {
319
- return (
320
- <td className={'px-1'} key={cell.id}>
321
- <Div className={'flex-col items-center'}>
322
- {
323
- flexRender(
324
- cell.column.columnDef.cell,
325
- cell.getContext(),
326
- )
327
- }
328
- </Div>
329
- </td>
330
- );
331
- })}
332
- </motion.tr>
333
- </AnimatePresence>
334
- {/* @ts-ignore */}
335
- <AnimatePresence>
336
- {row.getIsExpanded() && (
337
- <motion.tr
338
- initial={{ height: 0, opacity: 0 }}
339
- animate={{ height: 'auto', opacity: 1 }}
340
- exit={{ height: 0, opacity: 0 }}
341
- transition={{ duration: 0.5, ease: 'easeInOut' }}
342
- >
343
- <td colSpan={row.getVisibleCells().length}>
344
- <motion.div
345
- initial={{ height: 0, opacity: 0 }}
346
- animate={{ height: row.getIsExpanded() ? 'auto' : 0, opacity: 1 }}
347
- exit={{ height: 0, opacity: 0 }}
348
- transition={{ duration: 0.5, ease: 'easeInOut' }}
349
- className={'flex flex-col overflow-hidden'}>
350
- {expandedComponent(row.original)}
351
- </motion.div>
352
- </td>
353
- </motion.tr>
354
- )}
355
- </AnimatePresence>
356
- {/* @ts-ignore */}
357
- <AnimatePresence>
358
- {rowExpander.indexOf(row.index) !== -1 && (
359
- <motion.tr
360
- initial={{ height: 0, opacity: 0 }}
361
- animate={{ height: 'auto', opacity: 1 }}
362
- exit={{ height: 0, opacity: 0 }}
363
- transition={{ duration: 0.5, ease: 'easeInOut' }}
364
- className={classNames('bg-primary-50')}>
365
- <td colSpan={row.getVisibleCells().length}>
366
- <motion.div
367
- initial={{ height: 0, opacity: 0 }}
368
- animate={{ height: row.getVisibleCells().length ? 'auto' : 0, opacity: 1 }}
369
- exit={{ height: 0, opacity: 0 }}
370
- transition={{ duration: 0.5, ease: 'easeInOut' }}
371
- className={'flex flex-col overflow-hidden'}>
372
- {row.getAllCells().map((mobileCell) => {
373
- if (!mobileCell.column.getIsVisible() && mobileCell.column.id !== 'expander') {
374
- return (
375
- <Div
376
- key={mobileCell.id}
377
- className={'gap-2 p-2 items-start'}>
378
- {/*@ts-ignore*/}
379
- <Text typography={'sm'} type={'bold'}>{header[mobileCell.column.id]}:</Text>
380
- {flexRender(
381
- mobileCell.column.columnDef.cell,
382
- mobileCell.getContext(),
383
- )}
384
- </Div>
385
- );
386
- }
387
- return null;
388
- })}
389
- </motion.div>
390
- </td>
391
- </motion.tr>
392
- )}
393
- </AnimatePresence>
394
- </Fragment>
395
- );
396
- })}
397
- </tbody>
398
- )}
399
- </table>
400
- <Button onClick={handleScrollUp} shape={'square'} rounded={'full'} className={classNames('rotate-180 sticky !p-0 bottom-1 self-center duration-500 transition',
401
- showGoTop ? 'opacity-100 translate-y-0 !h-auto !min-h-12' : 'translate-y-full opacity-0 !h-0 !min-h-[0px]',
402
- )}>
403
- <ArrowDownIcon/>
404
- </Button>
405
- {!isLoading && data.length ? (
406
- <Div className={'mt-4 bg-control-50 md:h-14 py-2 md:py-0 justify-center items-center rounded-b-xl flex-col'}>
407
- <Pagination
408
- color={'primary'}
409
- variant={'filled'}
410
- getCurrentPage={getCurrentPage}
411
- isLoading={isLoading}
412
- lastPage={lastPage}
413
- perPage={perPage}
414
- currentPage={currentPage}
415
- total={total}
416
- nextPage={nextPage}
417
- previousPage={previousPage}
418
- getLimit={getLimit}
419
- />
420
- </Div>
421
- ) : null}
422
- </Div>
423
- </Div>
424
- );
425
- };
426
- export default DefaultDataTable;
427
-
@@ -1,3 +0,0 @@
1
- import DefaultDataTable from './default-data-table';
2
-
3
- export default DefaultDataTable;
@@ -1,33 +0,0 @@
1
- 'use clients';
2
- import { useState, useEffect } from 'react';
3
- import { useDebouncedCallback } from 'use-debounce';
4
- const useWindowDimensions = () => {
5
- const [windowDimensions, setWindowDimensions] = useState({
6
- width: window.innerWidth,
7
- height: window.innerHeight,
8
- });
9
-
10
- useEffect(() => {
11
- setWindowDimensions({
12
- width: window.innerWidth,
13
- height: window.innerHeight,
14
- });
15
- }, []);
16
-
17
- const handleResize = useDebouncedCallback(() => {
18
- setWindowDimensions({
19
- width: window.innerWidth,
20
- height: window.innerHeight,
21
- });
22
- }, 500);
23
-
24
- useEffect(() => {
25
- window.addEventListener('resize', handleResize);
26
-
27
- return () => window.removeEventListener('resize', handleResize);
28
- }, []);
29
-
30
- return windowDimensions;
31
- };
32
-
33
- export default useWindowDimensions;
@@ -1,10 +0,0 @@
1
- const AddIcon = ({ className }: {className?: string}) => {
2
- return (
3
- <svg className={className} width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'>
4
- <path d='M8 12H16' stroke='currentColor' strokeWidth='1.5' strokeLinecap='round' strokeLinejoin='round' />
5
- <path d='M12 16V8' stroke='currentColor' strokeWidth='1.5' strokeLinecap='round' strokeLinejoin='round' />
6
- </svg>
7
- );
8
- };
9
-
10
- export default AddIcon;
@@ -1,11 +0,0 @@
1
- const ArrowDownIcon = ({ fill = 'none', className = 'h-6 w-6' }: any) => {
2
- return (
3
- <svg width="20" height="20" viewBox="0 0 20 20" fill={fill} className={className} xmlns="http://www.w3.org/2000/svg">
4
- <path fillRule="evenodd" clipRule="evenodd"
5
- d="M4.4107 6.91073C4.73614 6.5853 5.26378 6.5853 5.58922 6.91073L9.99996 11.3215L14.4107 6.91074C14.7361 6.5853 15.2638 6.5853 15.5892 6.91074C15.9147 7.23617 15.9147 7.76381 15.5892 8.08925L10.5892 13.0892C10.2638 13.4147 9.73614 13.4147 9.4107 13.0892L4.4107 8.08925C4.08527 7.76381 4.08527 7.23617 4.4107 6.91073Z"
6
- fill="currentColor"/>
7
- </svg>
8
- );
9
- };
10
-
11
- export default ArrowDownIcon;
@@ -1,9 +0,0 @@
1
- import AddIcon from './add';
2
- import SortIcon from './sort';
3
- import ArrowDownIcon from './arrow-down';
4
-
5
- export {
6
- AddIcon,
7
- ArrowDownIcon,
8
- SortIcon,
9
- };
@@ -1,16 +0,0 @@
1
- const SortIcon = ({ direction } : { direction: string }) => {
2
- return (
3
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
4
- <g>
5
- <g>
6
- <path d="M9.00999 20.5L3.98999 15.49" stroke={direction === 'desc' ? 'currentColor' : '#A8A8A8'} strokeWidth="1.5" strokeMiterlimit="10" strokeLinecap="round" strokeLinejoin="round"/>
7
- <path d="M9.01001 3.5V20.5" stroke={direction === 'desc' ? 'currentColor' : '#A8A8A8'} strokeWidth="1.5" strokeMiterlimit="10" strokeLinecap="round" strokeLinejoin="round"/>
8
- <path d="M14.99 3.5L20.01 8.51" stroke={direction === 'asc' ? 'currentColor' : '#A8A8A8'} strokeWidth="1.5" strokeMiterlimit="10" strokeLinecap="round" strokeLinejoin="round"/>
9
- <path d="M14.99 20.5V3.5" stroke={direction === 'asc' ? 'currentColor' : '#A8A8A8'} strokeWidth="1.5" strokeMiterlimit="10" strokeLinecap="round" strokeLinejoin="round"/>
10
- </g>
11
- </g>
12
- </svg>
13
- );
14
- };
15
-
16
- export default SortIcon;
@@ -1,3 +0,0 @@
1
- import DataTable from './data-table';
2
-
3
- export default DataTable;
@@ -1,3 +0,0 @@
1
- import SimpleDataTable from './simple-data-table';
2
-
3
- export default SimpleDataTable;
@@ -1,23 +0,0 @@
1
- import { ColumnDef } from '@tanstack/react-table';
2
-
3
- export interface SimpleDataTableProps {
4
- data: Array<any>
5
-
6
- header: any
7
-
8
- column: Array<ColumnDef<any>>
9
-
10
- mobileColumns?: Array<string>
11
-
12
- isLoading?: boolean
13
-
14
- updateData?: (value: string, info?: string | object) => void
15
-
16
- select?: boolean
17
-
18
- selectedRows?: (rows: Array<ColumnDef<any>>) => void
19
-
20
- expandAll?: boolean
21
-
22
- visitedRows?: Array<number>
23
- }