@pezeshk-book/modules 0.2.8 → 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/package.json +1 -1
- package/.eslintrc.json +0 -133
- package/calendar/calendar.props.ts +0 -25
- package/calendar/calendar.tsx +0 -185
- package/calendar/config/chunk.ts +0 -42
- package/calendar/config/create-date-range.ts +0 -14
- package/calendar/config/days-in-month.en.ts +0 -47
- package/calendar/config/days-in-month.fa.ts +0 -37
- package/calendar/config/index.ts +0 -16
- package/calendar/config/months.ts +0 -29
- package/calendar/config/week-day.ts +0 -19
- package/calendar/icons/arrow-left-icon.tsx +0 -14
- package/calendar/icons/arrow-right-icon.tsx +0 -14
- package/calendar/icons/index.ts +0 -7
- package/calendar/index.ts +0 -3
- package/calendar/shared/formatDate.tsx +0 -12
- package/calendar/sub-components/day/day.props.ts +0 -27
- package/calendar/sub-components/day/day.tsx +0 -31
- package/calendar/sub-components/days/days.props.ts +0 -51
- package/calendar/sub-components/days/days.tsx +0 -142
- package/calendar/sub-components/days-head/days-head.props.ts +0 -27
- package/calendar/sub-components/days-head/days-head.tsx +0 -122
- package/countdown-timer/countdown.props.ts +0 -18
- package/countdown-timer/countdown.tsx +0 -79
- package/countdown-timer/index.ts +0 -3
- package/data-table/data-table.props.ts +0 -7
- package/data-table/data-table.tsx +0 -17
- package/data-table/default/default-data-table.props.ts +0 -47
- package/data-table/default/default-data-table.tsx +0 -427
- package/data-table/default/index.ts +0 -3
- package/data-table/hooks/use-window-dimensions.tsx +0 -33
- package/data-table/icons/add.tsx +0 -10
- package/data-table/icons/arrow-down.tsx +0 -11
- package/data-table/icons/index.ts +0 -9
- package/data-table/icons/sort.tsx +0 -16
- package/data-table/index.ts +0 -3
- package/data-table/simple/index.ts +0 -3
- package/data-table/simple/simple-data-table.props.ts +0 -23
- package/data-table/simple/simple-data-table.tsx +0 -258
- package/index.ts +0 -13
- package/pagination/icons/arrow-Right.tsx +0 -22
- package/pagination/icons/arrow-left.tsx +0 -22
- package/pagination/icons/index.ts +0 -7
- package/pagination/index.ts +0 -3
- package/pagination/pagination.props.ts +0 -33
- package/pagination/pagination.tsx +0 -135
- package/pagination/use-pagination.ts +0 -49
- package/react-app-env.d.ts +0 -1
- package/slider/index.ts +0 -3
- package/slider/slider.props.ts +0 -39
- package/slider/slider.tsx +0 -292
- package/stories/calendar/calendar.stories.tsx +0 -25
- package/stories/calendar/calendar.tsx +0 -11
- package/stories/count-down/count-down.stories.tsx +0 -19
- package/stories/count-down/count-down.tsx +0 -11
- package/stories/data-table/data-table-columns.tsx +0 -70
- package/stories/data-table/default-data-table.stories.tsx +0 -22
- package/stories/data-table/default-data-table.tsx +0 -18
- package/stories/data-table/dummy-data.ts +0 -204
- package/stories/data-table/simple-data-table.stories.tsx +0 -22
- package/stories/data-table/simple-data-table.tsx +0 -18
- package/stories/pagination/pagination.stories.tsx +0 -35
- package/stories/pagination/pagination.tsx +0 -11
- package/stories/slider/slider.stories.tsx +0 -19
- package/stories/slider/slider.tsx +0 -45
- package/stories/wrapper.tsx +0 -11
- package/styles.css +0 -28
- package/utils/class-names.ts +0 -5
- package/utils/persian-to-english-number.ts +0 -4
- /package/{dist/calendar → calendar}/calendar.d.ts +0 -0
- /package/{dist/calendar → calendar}/calendar.js +0 -0
- /package/{dist/calendar → calendar}/calendar.js.map +0 -0
- /package/{dist/calendar → calendar}/calendar.props.d.ts +0 -0
- /package/{dist/calendar → calendar}/calendar.props.js +0 -0
- /package/{dist/calendar → calendar}/calendar.props.js.map +0 -0
- /package/{dist/calendar → calendar}/config/chunk.d.ts +0 -0
- /package/{dist/calendar → calendar}/config/chunk.js +0 -0
- /package/{dist/calendar → calendar}/config/chunk.js.map +0 -0
- /package/{dist/calendar → calendar}/config/create-date-range.d.ts +0 -0
- /package/{dist/calendar → calendar}/config/create-date-range.js +0 -0
- /package/{dist/calendar → calendar}/config/create-date-range.js.map +0 -0
- /package/{dist/calendar → calendar}/config/days-in-month.en.d.ts +0 -0
- /package/{dist/calendar → calendar}/config/days-in-month.en.js +0 -0
- /package/{dist/calendar → calendar}/config/days-in-month.en.js.map +0 -0
- /package/{dist/calendar → calendar}/config/days-in-month.fa.d.ts +0 -0
- /package/{dist/calendar → calendar}/config/days-in-month.fa.js +0 -0
- /package/{dist/calendar → calendar}/config/days-in-month.fa.js.map +0 -0
- /package/{dist/calendar → calendar}/config/index.d.ts +0 -0
- /package/{dist/calendar → calendar}/config/index.js +0 -0
- /package/{dist/calendar → calendar}/config/index.js.map +0 -0
- /package/{dist/calendar → calendar}/config/months.d.ts +0 -0
- /package/{dist/calendar → calendar}/config/months.js +0 -0
- /package/{dist/calendar → calendar}/config/months.js.map +0 -0
- /package/{dist/calendar → calendar}/config/week-day.d.ts +0 -0
- /package/{dist/calendar → calendar}/config/week-day.js +0 -0
- /package/{dist/calendar → calendar}/config/week-day.js.map +0 -0
- /package/{dist/calendar → calendar}/icons/arrow-left-icon.d.ts +0 -0
- /package/{dist/calendar → calendar}/icons/arrow-left-icon.js +0 -0
- /package/{dist/calendar → calendar}/icons/arrow-left-icon.js.map +0 -0
- /package/{dist/calendar → calendar}/icons/arrow-right-icon.d.ts +0 -0
- /package/{dist/calendar → calendar}/icons/arrow-right-icon.js +0 -0
- /package/{dist/calendar → calendar}/icons/arrow-right-icon.js.map +0 -0
- /package/{dist/calendar → calendar}/icons/index.d.ts +0 -0
- /package/{dist/calendar → calendar}/icons/index.js +0 -0
- /package/{dist/calendar → calendar}/icons/index.js.map +0 -0
- /package/{dist/calendar → calendar}/index.d.ts +0 -0
- /package/{dist/calendar → calendar}/index.js +0 -0
- /package/{dist/calendar → calendar}/index.js.map +0 -0
- /package/{dist/calendar → calendar}/shared/formatDate.d.ts +0 -0
- /package/{dist/calendar → calendar}/shared/formatDate.js +0 -0
- /package/{dist/calendar → calendar}/shared/formatDate.js.map +0 -0
- /package/{dist/calendar → calendar}/sub-components/day/day.d.ts +0 -0
- /package/{dist/calendar → calendar}/sub-components/day/day.js +0 -0
- /package/{dist/calendar → calendar}/sub-components/day/day.js.map +0 -0
- /package/{dist/calendar → calendar}/sub-components/day/day.props.d.ts +0 -0
- /package/{dist/calendar → calendar}/sub-components/day/day.props.js +0 -0
- /package/{dist/calendar → calendar}/sub-components/day/day.props.js.map +0 -0
- /package/{dist/calendar → calendar}/sub-components/days/days.d.ts +0 -0
- /package/{dist/calendar → calendar}/sub-components/days/days.js +0 -0
- /package/{dist/calendar → calendar}/sub-components/days/days.js.map +0 -0
- /package/{dist/calendar → calendar}/sub-components/days/days.props.d.ts +0 -0
- /package/{dist/calendar → calendar}/sub-components/days/days.props.js +0 -0
- /package/{dist/calendar → calendar}/sub-components/days/days.props.js.map +0 -0
- /package/{dist/calendar → calendar}/sub-components/days-head/days-head.d.ts +0 -0
- /package/{dist/calendar → calendar}/sub-components/days-head/days-head.js +0 -0
- /package/{dist/calendar → calendar}/sub-components/days-head/days-head.js.map +0 -0
- /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.d.ts +0 -0
- /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.js +0 -0
- /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.js.map +0 -0
- /package/{dist/countdown-timer → countdown-timer}/countdown.d.ts +0 -0
- /package/{dist/countdown-timer → countdown-timer}/countdown.js +0 -0
- /package/{dist/countdown-timer → countdown-timer}/countdown.js.map +0 -0
- /package/{dist/countdown-timer → countdown-timer}/countdown.props.d.ts +0 -0
- /package/{dist/countdown-timer → countdown-timer}/countdown.props.js +0 -0
- /package/{dist/countdown-timer → countdown-timer}/countdown.props.js.map +0 -0
- /package/{dist/countdown-timer → countdown-timer}/index.d.ts +0 -0
- /package/{dist/countdown-timer → countdown-timer}/index.js +0 -0
- /package/{dist/countdown-timer → countdown-timer}/index.js.map +0 -0
- /package/{dist/data-table → data-table}/data-table.d.ts +0 -0
- /package/{dist/data-table → data-table}/data-table.js +0 -0
- /package/{dist/data-table → data-table}/data-table.js.map +0 -0
- /package/{dist/data-table → data-table}/data-table.props.d.ts +0 -0
- /package/{dist/data-table → data-table}/data-table.props.js +0 -0
- /package/{dist/data-table → data-table}/data-table.props.js.map +0 -0
- /package/{dist/data-table → data-table}/default/default-data-table.d.ts +0 -0
- /package/{dist/data-table → data-table}/default/default-data-table.js +0 -0
- /package/{dist/data-table → data-table}/default/default-data-table.js.map +0 -0
- /package/{dist/data-table → data-table}/default/default-data-table.props.d.ts +0 -0
- /package/{dist/data-table → data-table}/default/default-data-table.props.js +0 -0
- /package/{dist/data-table → data-table}/default/default-data-table.props.js.map +0 -0
- /package/{dist/data-table → data-table}/default/index.d.ts +0 -0
- /package/{dist/data-table → data-table}/default/index.js +0 -0
- /package/{dist/data-table → data-table}/default/index.js.map +0 -0
- /package/{dist/data-table → data-table}/hooks/use-window-dimensions.d.ts +0 -0
- /package/{dist/data-table → data-table}/hooks/use-window-dimensions.js +0 -0
- /package/{dist/data-table → data-table}/hooks/use-window-dimensions.js.map +0 -0
- /package/{dist/data-table → data-table}/icons/add.d.ts +0 -0
- /package/{dist/data-table → data-table}/icons/add.js +0 -0
- /package/{dist/data-table → data-table}/icons/add.js.map +0 -0
- /package/{dist/data-table → data-table}/icons/arrow-down.d.ts +0 -0
- /package/{dist/data-table → data-table}/icons/arrow-down.js +0 -0
- /package/{dist/data-table → data-table}/icons/arrow-down.js.map +0 -0
- /package/{dist/data-table → data-table}/icons/index.d.ts +0 -0
- /package/{dist/data-table → data-table}/icons/index.js +0 -0
- /package/{dist/data-table → data-table}/icons/index.js.map +0 -0
- /package/{dist/data-table → data-table}/icons/sort.d.ts +0 -0
- /package/{dist/data-table → data-table}/icons/sort.js +0 -0
- /package/{dist/data-table → data-table}/icons/sort.js.map +0 -0
- /package/{dist/data-table → data-table}/index.d.ts +0 -0
- /package/{dist/data-table → data-table}/index.js +0 -0
- /package/{dist/data-table → data-table}/index.js.map +0 -0
- /package/{dist/data-table → data-table}/simple/index.d.ts +0 -0
- /package/{dist/data-table → data-table}/simple/index.js +0 -0
- /package/{dist/data-table → data-table}/simple/index.js.map +0 -0
- /package/{dist/data-table → data-table}/simple/simple-data-table.d.ts +0 -0
- /package/{dist/data-table → data-table}/simple/simple-data-table.js +0 -0
- /package/{dist/data-table → data-table}/simple/simple-data-table.js.map +0 -0
- /package/{dist/data-table → data-table}/simple/simple-data-table.props.d.ts +0 -0
- /package/{dist/data-table → data-table}/simple/simple-data-table.props.js +0 -0
- /package/{dist/data-table → data-table}/simple/simple-data-table.props.js.map +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.js.map → index.js.map} +0 -0
- /package/{dist/pagination → pagination}/icons/arrow-Right.d.ts +0 -0
- /package/{dist/pagination → pagination}/icons/arrow-Right.js +0 -0
- /package/{dist/pagination → pagination}/icons/arrow-Right.js.map +0 -0
- /package/{dist/pagination → pagination}/icons/arrow-left.d.ts +0 -0
- /package/{dist/pagination → pagination}/icons/arrow-left.js +0 -0
- /package/{dist/pagination → pagination}/icons/arrow-left.js.map +0 -0
- /package/{dist/pagination → pagination}/icons/index.d.ts +0 -0
- /package/{dist/pagination → pagination}/icons/index.js +0 -0
- /package/{dist/pagination → pagination}/icons/index.js.map +0 -0
- /package/{dist/pagination → pagination}/index.d.ts +0 -0
- /package/{dist/pagination → pagination}/index.js +0 -0
- /package/{dist/pagination → pagination}/index.js.map +0 -0
- /package/{dist/pagination → pagination}/pagination.d.ts +0 -0
- /package/{dist/pagination → pagination}/pagination.js +0 -0
- /package/{dist/pagination → pagination}/pagination.js.map +0 -0
- /package/{dist/pagination → pagination}/pagination.props.d.ts +0 -0
- /package/{dist/pagination → pagination}/pagination.props.js +0 -0
- /package/{dist/pagination → pagination}/pagination.props.js.map +0 -0
- /package/{dist/pagination → pagination}/use-pagination.d.ts +0 -0
- /package/{dist/pagination → pagination}/use-pagination.js +0 -0
- /package/{dist/pagination → pagination}/use-pagination.js.map +0 -0
- /package/{dist/slider → slider}/index.d.ts +0 -0
- /package/{dist/slider → slider}/index.js +0 -0
- /package/{dist/slider → slider}/index.js.map +0 -0
- /package/{dist/slider → slider}/slider.d.ts +0 -0
- /package/{dist/slider → slider}/slider.js +0 -0
- /package/{dist/slider → slider}/slider.js.map +0 -0
- /package/{dist/slider → slider}/slider.props.d.ts +0 -0
- /package/{dist/slider → slider}/slider.props.js +0 -0
- /package/{dist/slider → slider}/slider.props.js.map +0 -0
- /package/{dist/utils → utils}/class-names.d.ts +0 -0
- /package/{dist/utils → utils}/class-names.js +0 -0
- /package/{dist/utils → utils}/class-names.js.map +0 -0
- /package/{dist/utils → utils}/persian-to-english-number.d.ts +0 -0
- /package/{dist/utils → utils}/persian-to-english-number.js +0 -0
- /package/{dist/utils → utils}/persian-to-english-number.js.map +0 -0
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { Fragment, useEffect, useState } from 'react';
|
|
2
|
-
import { ColumnDef, flexRender, getCoreRowModel, RowData, useReactTable } from '@tanstack/react-table';
|
|
3
|
-
import useWindowDimensions from '../hooks/use-window-dimensions';
|
|
4
|
-
import { Button, Checkbox, classNames, Div, LoadingIndicator, Skeleton, Text } from '@pezeshk-book/ui-kit';
|
|
5
|
-
import { AddIcon } from '../icons';
|
|
6
|
-
import { SimpleDataTableProps } from './simple-data-table.props';
|
|
7
|
-
|
|
8
|
-
declare module '@tanstack/react-table' {
|
|
9
|
-
// eslint-disable-next-line no-unused-vars
|
|
10
|
-
interface TableMeta<TData extends RowData> {
|
|
11
|
-
updateData: (value: string, info?: string | object) => void
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const fillArray = (n: number) => Array.from({ length: n + 1 }, (_, i) => i);
|
|
16
|
-
|
|
17
|
-
const SimpleDataTable = ( { header,
|
|
18
|
-
data,
|
|
19
|
-
column,
|
|
20
|
-
mobileColumns,
|
|
21
|
-
isLoading = false,
|
|
22
|
-
updateData,
|
|
23
|
-
select,
|
|
24
|
-
selectedRows,
|
|
25
|
-
expandAll = false,
|
|
26
|
-
visitedRows = [],
|
|
27
|
-
} : SimpleDataTableProps) => {
|
|
28
|
-
const [rowSelection, setRowSelection] = useState({});
|
|
29
|
-
const [columnVisibility, setColumnVisibility] = useState<any>({});
|
|
30
|
-
const [rowExpander, setRowExpander] = useState<Array<any>>([]);
|
|
31
|
-
|
|
32
|
-
const dimensions = useWindowDimensions();
|
|
33
|
-
|
|
34
|
-
const handleMobileExpander = (row: { index: number }) => {
|
|
35
|
-
if (rowExpander.indexOf(row.index) === -1) {
|
|
36
|
-
setRowExpander([...rowExpander, row.index]);
|
|
37
|
-
} else {
|
|
38
|
-
setRowExpander(value => value.filter(item => item !== row.index));
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const columns: ColumnDef<any>[] = [
|
|
43
|
-
{
|
|
44
|
-
id: 'mobileExpander',
|
|
45
|
-
accessorKey: 'mobileExpander',
|
|
46
|
-
header: () => null,
|
|
47
|
-
cell: ({ row }) => {
|
|
48
|
-
return (
|
|
49
|
-
<Button
|
|
50
|
-
onClick={() => handleMobileExpander(row)}
|
|
51
|
-
startAdornment={
|
|
52
|
-
<AddIcon
|
|
53
|
-
className={classNames(
|
|
54
|
-
'absolute transition-all duration-500',
|
|
55
|
-
rowExpander.indexOf(row.index) !== -1 ? 'rotate-[225deg]' : '',
|
|
56
|
-
)}
|
|
57
|
-
/>
|
|
58
|
-
}
|
|
59
|
-
variant={'text'}
|
|
60
|
-
size={'tiny'}
|
|
61
|
-
className={'!p-0'}
|
|
62
|
-
/>
|
|
63
|
-
);
|
|
64
|
-
},
|
|
65
|
-
enableSorting: false,
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
id: 'select',
|
|
69
|
-
accessorKey: 'select',
|
|
70
|
-
header: ({ table }) => {
|
|
71
|
-
return select ? (
|
|
72
|
-
<Checkbox
|
|
73
|
-
size={'small'}
|
|
74
|
-
indeterminate={table.getIsSomeRowsSelected()}
|
|
75
|
-
checked={table.getIsAllRowsSelected()}
|
|
76
|
-
onChange={table.getToggleAllRowsSelectedHandler()}
|
|
77
|
-
/>
|
|
78
|
-
) : null;
|
|
79
|
-
},
|
|
80
|
-
cell: ({ row }) => {
|
|
81
|
-
return row.getCanSelect() && select ? (
|
|
82
|
-
<Checkbox
|
|
83
|
-
size={'small'}
|
|
84
|
-
onChange={row.getToggleSelectedHandler()}
|
|
85
|
-
checked={row.getIsSelected()}
|
|
86
|
-
/>
|
|
87
|
-
) : null;
|
|
88
|
-
},
|
|
89
|
-
enableSorting: false,
|
|
90
|
-
},
|
|
91
|
-
...column,
|
|
92
|
-
];
|
|
93
|
-
const table = useReactTable({
|
|
94
|
-
data,
|
|
95
|
-
columns,
|
|
96
|
-
getCoreRowModel: getCoreRowModel(),
|
|
97
|
-
state: {
|
|
98
|
-
columnVisibility,
|
|
99
|
-
rowSelection,
|
|
100
|
-
},
|
|
101
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
102
|
-
onRowSelectionChange: setRowSelection,
|
|
103
|
-
meta: {
|
|
104
|
-
updateData: (value, info) => {
|
|
105
|
-
if (updateData) {
|
|
106
|
-
updateData(value, info);
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if (selectedRows) {
|
|
113
|
-
selectedRows(table.getSelectedRowModel().rows.map((row) => {
|
|
114
|
-
return row.original;
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
}, [rowSelection]);
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
const obj: any = {};
|
|
120
|
-
if (dimensions.width < 640) {
|
|
121
|
-
columns.forEach((value) => {
|
|
122
|
-
if (value.id) {
|
|
123
|
-
obj[value.id] = mobileColumns?.includes(value.id);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
setColumnVisibility({ ...obj, mobileExpander: true, select: select });
|
|
127
|
-
} else {
|
|
128
|
-
columns.forEach((value) => {
|
|
129
|
-
if (value.id) {
|
|
130
|
-
obj[value.id] = true;
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
setColumnVisibility({ ...obj, mobileExpander: false, select: select });
|
|
134
|
-
}
|
|
135
|
-
}, [dimensions.width]);
|
|
136
|
-
|
|
137
|
-
useEffect(() => {
|
|
138
|
-
if (expandAll && dimensions.width < 640) {
|
|
139
|
-
setRowExpander(fillArray(data.length));
|
|
140
|
-
}
|
|
141
|
-
if (expandAll && dimensions.width >= 640) {
|
|
142
|
-
setRowExpander([]);
|
|
143
|
-
}
|
|
144
|
-
}, [expandAll, dimensions.width]);
|
|
145
|
-
|
|
146
|
-
return (
|
|
147
|
-
<Div className={'w-full flex-col relative'}>
|
|
148
|
-
{isLoading && data.length > 0 ? (
|
|
149
|
-
<Div className={'absolute bg-control bg-opacity-25 w-full h-full items-center justify-center z-50 rounded-xl'}>
|
|
150
|
-
<LoadingIndicator size={'huge'} color={'control'}/>
|
|
151
|
-
</Div>
|
|
152
|
-
) : null}
|
|
153
|
-
<Div className={'bg-white border w-full border-control-300 border-opacity-50 p-2 rounded-xl max-w-full flex-col relative'}>
|
|
154
|
-
<table
|
|
155
|
-
className={'w-full table-auto'}>
|
|
156
|
-
<thead className={'bg-control-50 h-14 sticky top-0 z-10'}>
|
|
157
|
-
{table.getHeaderGroups().map(headerGroup => (
|
|
158
|
-
<tr key={headerGroup.id}>
|
|
159
|
-
{headerGroup.headers.map(header => (
|
|
160
|
-
<th
|
|
161
|
-
className={'hover:cursor-pointer'}
|
|
162
|
-
key={header.id}>
|
|
163
|
-
<Div className={'justify-center items-center gap-1'}>
|
|
164
|
-
<Text color={'grey.800'} typography={'sm'} type={'bold'}>
|
|
165
|
-
{header.isPlaceholder
|
|
166
|
-
? null
|
|
167
|
-
: flexRender(
|
|
168
|
-
header.column.columnDef.header,
|
|
169
|
-
header.getContext(),
|
|
170
|
-
)}
|
|
171
|
-
</Text>
|
|
172
|
-
</Div>
|
|
173
|
-
</th>
|
|
174
|
-
))}
|
|
175
|
-
</tr>
|
|
176
|
-
))}
|
|
177
|
-
</thead>
|
|
178
|
-
{isLoading && !data.length ? (
|
|
179
|
-
<tbody>
|
|
180
|
-
{[...new Array(5)].map((_, index) => (
|
|
181
|
-
<tr key={`loadingItem_${index}`} className={'h-16'}>
|
|
182
|
-
{table.getFlatHeaders().map(cell => {
|
|
183
|
-
return (
|
|
184
|
-
<td className={'px-1'} key={cell.id}>
|
|
185
|
-
<Skeleton color={'control'} className={'!max-w-full !min-w-full'}/>
|
|
186
|
-
</td>
|
|
187
|
-
);
|
|
188
|
-
})}
|
|
189
|
-
</tr>
|
|
190
|
-
))}
|
|
191
|
-
</tbody>
|
|
192
|
-
) : !isLoading && !data.length ? (
|
|
193
|
-
<tbody>
|
|
194
|
-
<tr className={'h-48'}>
|
|
195
|
-
<td colSpan={table.getFlatHeaders().length}>
|
|
196
|
-
<Text typography={'lg'} type={'bold'}>اطلاعاتی برای نمایش وجود ندارد!</Text>
|
|
197
|
-
</td>
|
|
198
|
-
</tr>
|
|
199
|
-
</tbody>
|
|
200
|
-
) : (
|
|
201
|
-
<tbody>
|
|
202
|
-
{table.getRowModel().rows.map((row) => {
|
|
203
|
-
return (
|
|
204
|
-
<Fragment key={row.id}>
|
|
205
|
-
<tr className={classNames('h-16 hover:bg-primary-50',
|
|
206
|
-
row.getIsSelected() && 'bg-slate-200',
|
|
207
|
-
visitedRows?.indexOf(row.index) !== -1 ? 'bg-slate-300' : '')}>
|
|
208
|
-
{row.getVisibleCells().map(cell => {
|
|
209
|
-
return (
|
|
210
|
-
<td className={'px-1'} key={cell.id}>
|
|
211
|
-
{isLoading ? (
|
|
212
|
-
<Skeleton color={'control'} className={'!max-w-full !min-w-full'}/>
|
|
213
|
-
) : <Div className={'flex-col items-center'}>
|
|
214
|
-
{
|
|
215
|
-
flexRender(
|
|
216
|
-
cell.column.columnDef.cell,
|
|
217
|
-
cell.getContext(),
|
|
218
|
-
)
|
|
219
|
-
}
|
|
220
|
-
</Div>}
|
|
221
|
-
</td>
|
|
222
|
-
);
|
|
223
|
-
})}
|
|
224
|
-
</tr>
|
|
225
|
-
{rowExpander.indexOf(row.index) !== -1 && (
|
|
226
|
-
<tr className={classNames('bg-primary-50')}>
|
|
227
|
-
<td colSpan={row.getVisibleCells().length}>
|
|
228
|
-
<Div className={'flex-col'}>
|
|
229
|
-
{row.getAllCells().map((mobileCell) => {
|
|
230
|
-
if (mobileCell.column.getIsVisible() || mobileCell.column.id === 'expander') {
|
|
231
|
-
return null;
|
|
232
|
-
}
|
|
233
|
-
return (
|
|
234
|
-
<Div key={mobileCell.id} className={'gap-2 p-2 items-start'}>
|
|
235
|
-
<Text typography={'sm'} type={'bold'}>{header[mobileCell.column.id]}:</Text>
|
|
236
|
-
{flexRender(
|
|
237
|
-
mobileCell.column.columnDef.cell,
|
|
238
|
-
mobileCell.getContext(),
|
|
239
|
-
)}
|
|
240
|
-
</Div>
|
|
241
|
-
);
|
|
242
|
-
})}
|
|
243
|
-
</Div>
|
|
244
|
-
</td>
|
|
245
|
-
</tr>
|
|
246
|
-
)}
|
|
247
|
-
</Fragment>
|
|
248
|
-
);
|
|
249
|
-
})}
|
|
250
|
-
</tbody>
|
|
251
|
-
)}
|
|
252
|
-
</table>
|
|
253
|
-
</Div>
|
|
254
|
-
</Div>
|
|
255
|
-
);
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
export default SimpleDataTable;
|
package/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import Slider from './slider/slider';
|
|
2
|
-
import Calendar from './calendar/calendar';
|
|
3
|
-
import Pagination from './pagination/pagination';
|
|
4
|
-
import CountDown from './countdown-timer/countdown';
|
|
5
|
-
import DataTable from './data-table/data-table';
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
Slider,
|
|
9
|
-
Calendar,
|
|
10
|
-
Pagination,
|
|
11
|
-
CountDown,
|
|
12
|
-
DataTable,
|
|
13
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const ArrowRight = ({ fill = 'none', className = 'h-3 w-3' }: {fill?: string, className?: string}) => {
|
|
2
|
-
return (
|
|
3
|
-
<svg
|
|
4
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
-
width="256"
|
|
6
|
-
height="256"
|
|
7
|
-
viewBox="0 0 256 256"
|
|
8
|
-
fill={fill}
|
|
9
|
-
className={className}
|
|
10
|
-
>
|
|
11
|
-
<path
|
|
12
|
-
fill={'currentColor'}
|
|
13
|
-
strokeMiterlimit="10"
|
|
14
|
-
strokeWidth="0"
|
|
15
|
-
d="M24.64 90L20.36 85.72 61.08 45 20.36 4.28 24.64 0 69.64 45z"
|
|
16
|
-
transform="matrix(2.81 0 0 2.81 1.407 1.407)"
|
|
17
|
-
/>
|
|
18
|
-
</svg>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default ArrowRight;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const ArrowLeft = ({ fill = 'none', className = 'h-3 w-3' }: {fill?: string, className?: string}) => {
|
|
2
|
-
return (
|
|
3
|
-
<svg
|
|
4
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
-
width="256"
|
|
6
|
-
height="256"
|
|
7
|
-
viewBox="0 0 256 256"
|
|
8
|
-
className={className}
|
|
9
|
-
fill={fill}
|
|
10
|
-
>
|
|
11
|
-
<path
|
|
12
|
-
fill={'currentColor'}
|
|
13
|
-
strokeMiterlimit="10"
|
|
14
|
-
strokeWidth="0"
|
|
15
|
-
d="M65.36 0L69.64 4.28 28.92 45 69.64 85.72 65.36 90 20.36 45z"
|
|
16
|
-
transform="matrix(2.81 0 0 2.81 1.407 1.407)"
|
|
17
|
-
/>
|
|
18
|
-
</svg>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default ArrowLeft;
|
package/pagination/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Colors } from '@pezeshk-book/ui-kit/types';
|
|
2
|
-
|
|
3
|
-
export interface PaginationProps {
|
|
4
|
-
currentPage?: number
|
|
5
|
-
|
|
6
|
-
perPage: number
|
|
7
|
-
|
|
8
|
-
lastPage: number
|
|
9
|
-
|
|
10
|
-
getCurrentPage: (number: number) => void
|
|
11
|
-
|
|
12
|
-
getLimit?: (event: string) => void
|
|
13
|
-
|
|
14
|
-
previousPage?: () => void
|
|
15
|
-
|
|
16
|
-
nextPage?: () => void
|
|
17
|
-
|
|
18
|
-
isLoading: boolean
|
|
19
|
-
|
|
20
|
-
total?: number
|
|
21
|
-
|
|
22
|
-
hasLimit?: boolean
|
|
23
|
-
|
|
24
|
-
showTotal?: boolean
|
|
25
|
-
|
|
26
|
-
color?: Colors
|
|
27
|
-
|
|
28
|
-
variant?: 'outlined' | 'filled' | 'text'
|
|
29
|
-
|
|
30
|
-
rounded?: 'tiny' | 'small' | 'medium' | 'large' | 'huge' | 'full' | 'none'
|
|
31
|
-
|
|
32
|
-
type?: 'simple' | 'default'
|
|
33
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
4
|
-
import { Button, Div, Text, Select } from '@pezeshk-book/ui-kit';
|
|
5
|
-
import { ArrowLeft, ArrowRight } from './icons';
|
|
6
|
-
import { PaginationProps } from './pagination.props';
|
|
7
|
-
import usePagination from './use-pagination';
|
|
8
|
-
|
|
9
|
-
const Limits = [
|
|
10
|
-
{
|
|
11
|
-
id: '10',
|
|
12
|
-
count: 10,
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
id: '25',
|
|
16
|
-
count: 25,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
id: '50',
|
|
20
|
-
count: 50,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
id: '75',
|
|
24
|
-
count: 75,
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
id: '100',
|
|
28
|
-
count: 100,
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
export const Pagination = ({ isLoading, currentPage = 1, lastPage, getCurrentPage, previousPage, nextPage, perPage = 10, total = 0, getLimit, hasLimit = true, showTotal = true, color = 'control', variant = 'outlined', rounded = 'medium', type = 'default' }: PaginationProps) => {
|
|
32
|
-
const pageNumbers = usePagination(currentPage, lastPage, type);
|
|
33
|
-
const [limit, setLimit] = useState(perPage.toString());
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const position = Limits.find((value) => {
|
|
37
|
-
return perPage <= value.count;
|
|
38
|
-
});
|
|
39
|
-
setLimit(prevState => position?.id ? position?.id : prevState);
|
|
40
|
-
}, [perPage]);
|
|
41
|
-
|
|
42
|
-
const limitHandler = (event: string) => {
|
|
43
|
-
setLimit(event);
|
|
44
|
-
if (getLimit && hasLimit) {
|
|
45
|
-
getLimit(event);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Div className={'flex-col-reverse sm:flex-row w-full justify-between items-center gap-y-2 px-4'}>
|
|
51
|
-
<Div className={'flex justify-start items-center'}>
|
|
52
|
-
<Div className={'items-center gap-6 justify-start md:absolute'}>
|
|
53
|
-
{showTotal ? (
|
|
54
|
-
<Text color={'grey.500'} className={'text-ellipsis whitespace-nowrap'}>
|
|
55
|
-
{`نمایش ${(currentPage - 1) * parseInt(limit) + 1} تا ${lastPage === currentPage ? total : parseInt(limit) * currentPage} از ${total}`}
|
|
56
|
-
</Text>
|
|
57
|
-
) : null}
|
|
58
|
-
{hasLimit ? (
|
|
59
|
-
<Div className={'w-20'}>
|
|
60
|
-
<Select
|
|
61
|
-
disabled={isLoading}
|
|
62
|
-
id={'id'}
|
|
63
|
-
size={'small'}
|
|
64
|
-
value={limit}
|
|
65
|
-
onChange={limitHandler}
|
|
66
|
-
text={'count'}
|
|
67
|
-
optionsList={Limits}
|
|
68
|
-
variant={'outlined'}
|
|
69
|
-
color={'control'}
|
|
70
|
-
/>
|
|
71
|
-
</Div>
|
|
72
|
-
) : null}
|
|
73
|
-
</Div>
|
|
74
|
-
</Div>
|
|
75
|
-
<ul dir={'ltr'} className={'flex flex-row gap-x-0.5 md:gap-x-2 items-center md:justify-start justify-center'}>
|
|
76
|
-
<li>
|
|
77
|
-
<Button
|
|
78
|
-
disabled={currentPage === 1 || isLoading}
|
|
79
|
-
variant={variant}
|
|
80
|
-
shape={'square'}
|
|
81
|
-
size={'small'}
|
|
82
|
-
onClick={previousPage}
|
|
83
|
-
ariaLabel={'previousPage'}
|
|
84
|
-
loading={isLoading}
|
|
85
|
-
color={color}
|
|
86
|
-
rounded={rounded}
|
|
87
|
-
className={'!px-0'}>
|
|
88
|
-
<ArrowLeft/>
|
|
89
|
-
</Button>
|
|
90
|
-
</li>
|
|
91
|
-
{ type === 'default' ? pageNumbers.map((number) => {
|
|
92
|
-
return (
|
|
93
|
-
<li key={`pagination_${number}`}>
|
|
94
|
-
<Button
|
|
95
|
-
disabled={number === currentPage || number === '...' || isLoading}
|
|
96
|
-
variant={variant}
|
|
97
|
-
shape={'square'}
|
|
98
|
-
rounded={rounded}
|
|
99
|
-
size={'small'}
|
|
100
|
-
color={color}
|
|
101
|
-
className={'!px-0'}
|
|
102
|
-
ariaLabel={number.toString()}
|
|
103
|
-
onClick={() => getCurrentPage(+number)}>
|
|
104
|
-
{number}
|
|
105
|
-
</Button>
|
|
106
|
-
</li>
|
|
107
|
-
);
|
|
108
|
-
}) : null}
|
|
109
|
-
<li>
|
|
110
|
-
<Button
|
|
111
|
-
disabled={lastPage === currentPage || isLoading}
|
|
112
|
-
variant={variant}
|
|
113
|
-
shape={'square'}
|
|
114
|
-
size={'small'}
|
|
115
|
-
rounded={rounded}
|
|
116
|
-
onClick={nextPage}
|
|
117
|
-
ariaLabel={'nextPage'}
|
|
118
|
-
loading={isLoading}
|
|
119
|
-
color={color}
|
|
120
|
-
className={'!px-0'}>
|
|
121
|
-
<ArrowRight/>
|
|
122
|
-
</Button>
|
|
123
|
-
</li>
|
|
124
|
-
{type === 'simple' ? (
|
|
125
|
-
<Div className={'gap-2'}>
|
|
126
|
-
<Text typography={'sm'}>{currentPage} / {lastPage}</Text>
|
|
127
|
-
<Text typography={'sm'}>صفحه</Text>
|
|
128
|
-
</Div>
|
|
129
|
-
) : null}
|
|
130
|
-
</ul>
|
|
131
|
-
</Div>
|
|
132
|
-
);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export default Pagination;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const usePagination = (currentPage: number, lastPage: number, type: 'simple' | 'default') => {
|
|
2
|
-
if (type === 'simple') {
|
|
3
|
-
return [];
|
|
4
|
-
}
|
|
5
|
-
let situation = 'NONE';
|
|
6
|
-
if (lastPage > 7) {
|
|
7
|
-
if ((currentPage <= 4)) {
|
|
8
|
-
situation = 'BEGINNING';
|
|
9
|
-
} else if (lastPage - currentPage <= 3) {
|
|
10
|
-
situation = 'END';
|
|
11
|
-
} else if (currentPage > 4 || lastPage - currentPage > 3) {
|
|
12
|
-
situation = 'MIDDLE';
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const temp: Array<number | string> = [];
|
|
17
|
-
|
|
18
|
-
switch (situation) {
|
|
19
|
-
case 'BEGINNING': {
|
|
20
|
-
for (let i = 1; i <= 5; i++) {
|
|
21
|
-
temp.push(i);
|
|
22
|
-
}
|
|
23
|
-
temp.push('...', lastPage);
|
|
24
|
-
return temp;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
case 'MIDDLE': {
|
|
28
|
-
temp.push(1, '...', currentPage - 1, currentPage, currentPage + 1, '...', lastPage);
|
|
29
|
-
return temp;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
case 'END': {
|
|
33
|
-
for (let i = lastPage; i > (lastPage - 5); i--) {
|
|
34
|
-
temp.push(i);
|
|
35
|
-
}
|
|
36
|
-
temp.push('...', 1);
|
|
37
|
-
return temp.reverse();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
default : {
|
|
41
|
-
for (let i = 1; i <= lastPage; i++) {
|
|
42
|
-
temp.push(i);
|
|
43
|
-
}
|
|
44
|
-
return temp;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default usePagination;
|
package/react-app-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="react-scripts" />
|
package/slider/index.ts
DELETED
package/slider/slider.props.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Colors } from '@pezeshk-book/ui-kit/types';
|
|
2
|
-
|
|
3
|
-
export interface SliderProps {
|
|
4
|
-
children: any
|
|
5
|
-
|
|
6
|
-
delay?: number
|
|
7
|
-
|
|
8
|
-
spaceBetween?: number
|
|
9
|
-
|
|
10
|
-
slides?: number
|
|
11
|
-
|
|
12
|
-
tabletSlides?: number
|
|
13
|
-
|
|
14
|
-
mobileSlides?: number
|
|
15
|
-
|
|
16
|
-
infiniteLoop?: boolean
|
|
17
|
-
|
|
18
|
-
pauseOnMouseOver?: boolean
|
|
19
|
-
|
|
20
|
-
autoMove?: boolean
|
|
21
|
-
|
|
22
|
-
indicator?: boolean
|
|
23
|
-
|
|
24
|
-
indicatorActiveColor?: Colors
|
|
25
|
-
|
|
26
|
-
navigation?: boolean
|
|
27
|
-
|
|
28
|
-
nextNavigation?: (onClick: any) => any
|
|
29
|
-
|
|
30
|
-
prevNavigation?: (onClick: any) => any
|
|
31
|
-
|
|
32
|
-
direction?: 'ltr' | 'rtl'
|
|
33
|
-
|
|
34
|
-
rows?: number
|
|
35
|
-
|
|
36
|
-
navigationColor?: Colors
|
|
37
|
-
|
|
38
|
-
indicatorClassName?: string
|
|
39
|
-
}
|