@pezeshk-book/modules 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +133 -0
- package/calendar/calendar.props.ts +25 -0
- package/calendar/calendar.tsx +183 -0
- package/calendar/config/chunk.ts +42 -0
- package/calendar/config/create-date-range.ts +14 -0
- package/calendar/config/days-in-month.en.ts +47 -0
- package/calendar/config/days-in-month.fa.ts +37 -0
- package/calendar/config/index.ts +16 -0
- package/calendar/config/months.ts +29 -0
- package/calendar/config/week-day.ts +19 -0
- package/calendar/icons/arrow-left-icon.tsx +14 -0
- package/calendar/icons/arrow-right-icon.tsx +14 -0
- package/calendar/icons/index.ts +7 -0
- package/calendar/index.ts +3 -0
- package/calendar/shared/formatDate.tsx +12 -0
- package/calendar/sub-components/day/day.props.ts +27 -0
- package/calendar/sub-components/day/day.tsx +31 -0
- package/calendar/sub-components/days/days.props.ts +51 -0
- package/calendar/sub-components/days/days.tsx +142 -0
- package/calendar/sub-components/days-head/days-head.props.ts +27 -0
- package/calendar/sub-components/days-head/days-head.tsx +122 -0
- package/countdown-timer/countdown.props.ts +18 -0
- package/countdown-timer/countdown.tsx +78 -0
- package/countdown-timer/index.ts +3 -0
- package/data-table/data-table.props.ts +7 -0
- package/data-table/data-table.tsx +15 -0
- package/data-table/default/default-data-table.props.ts +47 -0
- package/data-table/default/default-data-table.tsx +427 -0
- package/data-table/default/index.ts +3 -0
- package/data-table/hooks/use-window-dimensions.tsx +33 -0
- package/data-table/icons/add.tsx +10 -0
- package/data-table/icons/arrow-down.tsx +11 -0
- package/data-table/icons/index.ts +9 -0
- package/data-table/icons/sort.tsx +16 -0
- package/data-table/index.ts +3 -0
- package/data-table/simple/index.ts +3 -0
- package/data-table/simple/simple-data-table.props.ts +23 -0
- package/data-table/simple/simple-data-table.tsx +258 -0
- package/dist/calendar/calendar.js.map +1 -0
- package/dist/calendar/calendar.props.js.map +1 -0
- package/dist/calendar/config/chunk.js.map +1 -0
- package/dist/calendar/config/create-date-range.js.map +1 -0
- package/dist/calendar/config/days-in-month.en.js.map +1 -0
- package/dist/calendar/config/days-in-month.fa.js.map +1 -0
- package/dist/calendar/config/index.js.map +1 -0
- package/dist/calendar/config/months.js.map +1 -0
- package/dist/calendar/config/week-day.js.map +1 -0
- package/dist/calendar/icons/arrow-left-icon.js.map +1 -0
- package/dist/calendar/icons/arrow-right-icon.js.map +1 -0
- package/dist/calendar/icons/index.js.map +1 -0
- package/dist/calendar/index.js.map +1 -0
- package/dist/calendar/shared/formatDate.js.map +1 -0
- package/dist/{modules/calendar → calendar}/sub-components/day/day.js +1 -1
- package/dist/calendar/sub-components/day/day.js.map +1 -0
- package/dist/calendar/sub-components/day/day.props.js.map +1 -0
- package/dist/calendar/sub-components/days/days.js.map +1 -0
- package/dist/calendar/sub-components/days/days.props.js.map +1 -0
- package/dist/{modules/calendar → calendar}/sub-components/days-head/days-head.js +2 -2
- package/dist/calendar/sub-components/days-head/days-head.js.map +1 -0
- package/dist/calendar/sub-components/days-head/days-head.props.js.map +1 -0
- package/dist/countdown-timer/countdown.js.map +1 -0
- package/dist/countdown-timer/countdown.props.js.map +1 -0
- package/dist/countdown-timer/index.js.map +1 -0
- package/dist/data-table/data-table.js.map +1 -0
- package/dist/data-table/data-table.props.js.map +1 -0
- package/dist/{modules/data-table → data-table}/default/default-data-table.js +1 -1
- package/dist/data-table/default/default-data-table.js.map +1 -0
- package/dist/data-table/default/default-data-table.props.js.map +1 -0
- package/dist/data-table/default/index.js.map +1 -0
- package/dist/data-table/hooks/use-window-dimensions.js.map +1 -0
- package/dist/data-table/icons/add.js.map +1 -0
- package/dist/data-table/icons/arrow-down.js.map +1 -0
- package/dist/data-table/icons/index.js.map +1 -0
- package/dist/data-table/icons/sort.js.map +1 -0
- package/dist/data-table/index.js.map +1 -0
- package/dist/data-table/simple/index.js.map +1 -0
- package/dist/data-table/simple/simple-data-table.js.map +1 -0
- package/dist/data-table/simple/simple-data-table.props.js.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/pagination/icons/arrow-Right.js.map +1 -0
- package/dist/pagination/icons/arrow-left.js.map +1 -0
- package/dist/pagination/icons/index.js.map +1 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/pagination/pagination.js.map +1 -0
- package/dist/pagination/pagination.props.js.map +1 -0
- package/dist/pagination/use-pagination.js.map +1 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/{modules/slider → slider}/slider.js +1 -1
- package/dist/slider/slider.js.map +1 -0
- package/dist/slider/slider.props.js.map +1 -0
- package/dist/stories/calendar/calendar.d.ts +1 -1
- package/dist/stories/calendar/calendar.js +1 -1
- package/dist/stories/calendar/calendar.js.map +1 -1
- package/dist/stories/count-down/count-down.d.ts +1 -1
- package/dist/stories/count-down/count-down.js +1 -1
- package/dist/stories/count-down/count-down.js.map +1 -1
- package/dist/stories/data-table/default-data-table.d.ts +1 -1
- package/dist/stories/data-table/default-data-table.js +1 -1
- package/dist/stories/data-table/default-data-table.js.map +1 -1
- package/dist/stories/data-table/simple-data-table.d.ts +1 -1
- package/dist/stories/data-table/simple-data-table.js +1 -1
- package/dist/stories/data-table/simple-data-table.js.map +1 -1
- package/dist/stories/pagination/pagination.d.ts +1 -1
- package/dist/stories/pagination/pagination.js +1 -1
- package/dist/stories/pagination/pagination.js.map +1 -1
- package/dist/stories/slider/slider.d.ts +1 -1
- package/dist/stories/slider/slider.js +1 -1
- package/dist/stories/slider/slider.js.map +1 -1
- package/index.ts +13 -0
- package/package.json +5 -10
- package/pagination/icons/arrow-Right.tsx +22 -0
- package/pagination/icons/arrow-left.tsx +22 -0
- package/pagination/icons/index.ts +7 -0
- package/pagination/index.ts +3 -0
- package/pagination/pagination.props.ts +33 -0
- package/pagination/pagination.tsx +133 -0
- package/pagination/use-pagination.ts +49 -0
- package/react-app-env.d.ts +1 -0
- package/slider/index.ts +3 -0
- package/slider/slider.props.ts +39 -0
- package/slider/slider.tsx +290 -0
- package/stories/calendar/calendar.stories.tsx +25 -0
- package/stories/calendar/calendar.tsx +11 -0
- package/stories/count-down/count-down.stories.tsx +19 -0
- package/stories/count-down/count-down.tsx +11 -0
- package/stories/data-table/data-table-columns.tsx +70 -0
- package/stories/data-table/default-data-table.stories.tsx +22 -0
- package/stories/data-table/default-data-table.tsx +18 -0
- package/stories/data-table/dummy-data.ts +204 -0
- package/stories/data-table/simple-data-table.stories.tsx +22 -0
- package/stories/data-table/simple-data-table.tsx +18 -0
- package/stories/pagination/pagination.stories.tsx +35 -0
- package/stories/pagination/pagination.tsx +11 -0
- package/stories/slider/slider.stories.tsx +19 -0
- package/stories/slider/slider.tsx +45 -0
- package/stories/wrapper.tsx +11 -0
- package/styles.css +28 -0
- package/utils/class-names.ts +5 -0
- package/utils/persian-to-english-number.ts +4 -0
- package/dist/modules/calendar/calendar.js.map +0 -1
- package/dist/modules/calendar/calendar.props.js.map +0 -1
- package/dist/modules/calendar/config/chunk.js.map +0 -1
- package/dist/modules/calendar/config/create-date-range.js.map +0 -1
- package/dist/modules/calendar/config/days-in-month.en.js.map +0 -1
- package/dist/modules/calendar/config/days-in-month.fa.js.map +0 -1
- package/dist/modules/calendar/config/index.js.map +0 -1
- package/dist/modules/calendar/config/months.js.map +0 -1
- package/dist/modules/calendar/config/week-day.js.map +0 -1
- package/dist/modules/calendar/icons/arrow-left-icon.js.map +0 -1
- package/dist/modules/calendar/icons/arrow-right-icon.js.map +0 -1
- package/dist/modules/calendar/icons/index.js.map +0 -1
- package/dist/modules/calendar/index.js.map +0 -1
- package/dist/modules/calendar/shared/formatDate.js.map +0 -1
- package/dist/modules/calendar/sub-components/day/day.js.map +0 -1
- package/dist/modules/calendar/sub-components/day/day.props.js.map +0 -1
- package/dist/modules/calendar/sub-components/days/days.js.map +0 -1
- package/dist/modules/calendar/sub-components/days/days.props.js.map +0 -1
- package/dist/modules/calendar/sub-components/days-head/days-head.js.map +0 -1
- package/dist/modules/calendar/sub-components/days-head/days-head.props.js.map +0 -1
- package/dist/modules/countdown-timer/countdown.js.map +0 -1
- package/dist/modules/countdown-timer/countdown.props.js.map +0 -1
- package/dist/modules/countdown-timer/index.js.map +0 -1
- package/dist/modules/data-table/data-table.js.map +0 -1
- package/dist/modules/data-table/data-table.props.js.map +0 -1
- package/dist/modules/data-table/default/default-data-table.js.map +0 -1
- package/dist/modules/data-table/default/default-data-table.props.js.map +0 -1
- package/dist/modules/data-table/default/index.js.map +0 -1
- package/dist/modules/data-table/hooks/use-window-dimensions.js.map +0 -1
- package/dist/modules/data-table/icons/add.js.map +0 -1
- package/dist/modules/data-table/icons/arrow-down.js.map +0 -1
- package/dist/modules/data-table/icons/index.js.map +0 -1
- package/dist/modules/data-table/icons/sort.js.map +0 -1
- package/dist/modules/data-table/index.js.map +0 -1
- package/dist/modules/data-table/simple/index.js.map +0 -1
- package/dist/modules/data-table/simple/simple-data-table.js.map +0 -1
- package/dist/modules/data-table/simple/simple-data-table.props.js.map +0 -1
- package/dist/modules/pagination/icons/arrow-Right.js.map +0 -1
- package/dist/modules/pagination/icons/arrow-left.js.map +0 -1
- package/dist/modules/pagination/icons/index.js.map +0 -1
- package/dist/modules/pagination/index.js.map +0 -1
- package/dist/modules/pagination/pagination.js.map +0 -1
- package/dist/modules/pagination/pagination.props.js.map +0 -1
- package/dist/modules/pagination/use-pagination.js.map +0 -1
- package/dist/modules/slider/index.js.map +0 -1
- package/dist/modules/slider/slider.js.map +0 -1
- package/dist/modules/slider/slider.props.js.map +0 -1
- /package/dist/{modules/calendar → calendar}/calendar.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/calendar.js +0 -0
- /package/dist/{modules/calendar → calendar}/calendar.props.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/calendar.props.js +0 -0
- /package/dist/{modules/calendar → calendar}/config/chunk.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/config/chunk.js +0 -0
- /package/dist/{modules/calendar → calendar}/config/create-date-range.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/config/create-date-range.js +0 -0
- /package/dist/{modules/calendar → calendar}/config/days-in-month.en.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/config/days-in-month.en.js +0 -0
- /package/dist/{modules/calendar → calendar}/config/days-in-month.fa.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/config/days-in-month.fa.js +0 -0
- /package/dist/{modules/calendar → calendar}/config/index.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/config/index.js +0 -0
- /package/dist/{modules/calendar → calendar}/config/months.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/config/months.js +0 -0
- /package/dist/{modules/calendar → calendar}/config/week-day.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/config/week-day.js +0 -0
- /package/dist/{modules/calendar → calendar}/icons/arrow-left-icon.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/icons/arrow-left-icon.js +0 -0
- /package/dist/{modules/calendar → calendar}/icons/arrow-right-icon.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/icons/arrow-right-icon.js +0 -0
- /package/dist/{modules/calendar → calendar}/icons/index.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/icons/index.js +0 -0
- /package/dist/{modules/calendar → calendar}/index.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/index.js +0 -0
- /package/dist/{modules/calendar → calendar}/shared/formatDate.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/shared/formatDate.js +0 -0
- /package/dist/{modules/calendar → calendar}/sub-components/day/day.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/sub-components/day/day.props.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/sub-components/day/day.props.js +0 -0
- /package/dist/{modules/calendar → calendar}/sub-components/days/days.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/sub-components/days/days.js +0 -0
- /package/dist/{modules/calendar → calendar}/sub-components/days/days.props.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/sub-components/days/days.props.js +0 -0
- /package/dist/{modules/calendar → calendar}/sub-components/days-head/days-head.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/sub-components/days-head/days-head.props.d.ts +0 -0
- /package/dist/{modules/calendar → calendar}/sub-components/days-head/days-head.props.js +0 -0
- /package/dist/{modules/countdown-timer → countdown-timer}/countdown.d.ts +0 -0
- /package/dist/{modules/countdown-timer → countdown-timer}/countdown.js +0 -0
- /package/dist/{modules/countdown-timer → countdown-timer}/countdown.props.d.ts +0 -0
- /package/dist/{modules/countdown-timer → countdown-timer}/countdown.props.js +0 -0
- /package/dist/{modules/countdown-timer → countdown-timer}/index.d.ts +0 -0
- /package/dist/{modules/countdown-timer → countdown-timer}/index.js +0 -0
- /package/dist/{modules/data-table → data-table}/data-table.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/data-table.js +0 -0
- /package/dist/{modules/data-table → data-table}/data-table.props.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/data-table.props.js +0 -0
- /package/dist/{modules/data-table → data-table}/default/default-data-table.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/default/default-data-table.props.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/default/default-data-table.props.js +0 -0
- /package/dist/{modules/data-table → data-table}/default/index.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/default/index.js +0 -0
- /package/dist/{modules/data-table → data-table}/hooks/use-window-dimensions.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/hooks/use-window-dimensions.js +0 -0
- /package/dist/{modules/data-table → data-table}/icons/add.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/icons/add.js +0 -0
- /package/dist/{modules/data-table → data-table}/icons/arrow-down.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/icons/arrow-down.js +0 -0
- /package/dist/{modules/data-table → data-table}/icons/index.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/icons/index.js +0 -0
- /package/dist/{modules/data-table → data-table}/icons/sort.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/icons/sort.js +0 -0
- /package/dist/{modules/data-table → data-table}/index.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/index.js +0 -0
- /package/dist/{modules/data-table → data-table}/simple/index.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/simple/index.js +0 -0
- /package/dist/{modules/data-table → data-table}/simple/simple-data-table.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/simple/simple-data-table.js +0 -0
- /package/dist/{modules/data-table → data-table}/simple/simple-data-table.props.d.ts +0 -0
- /package/dist/{modules/data-table → data-table}/simple/simple-data-table.props.js +0 -0
- /package/dist/{modules/pagination → pagination}/icons/arrow-Right.d.ts +0 -0
- /package/dist/{modules/pagination → pagination}/icons/arrow-Right.js +0 -0
- /package/dist/{modules/pagination → pagination}/icons/arrow-left.d.ts +0 -0
- /package/dist/{modules/pagination → pagination}/icons/arrow-left.js +0 -0
- /package/dist/{modules/pagination → pagination}/icons/index.d.ts +0 -0
- /package/dist/{modules/pagination → pagination}/icons/index.js +0 -0
- /package/dist/{modules/pagination → pagination}/index.d.ts +0 -0
- /package/dist/{modules/pagination → pagination}/index.js +0 -0
- /package/dist/{modules/pagination → pagination}/pagination.d.ts +0 -0
- /package/dist/{modules/pagination → pagination}/pagination.js +0 -0
- /package/dist/{modules/pagination → pagination}/pagination.props.d.ts +0 -0
- /package/dist/{modules/pagination → pagination}/pagination.props.js +0 -0
- /package/dist/{modules/pagination → pagination}/use-pagination.d.ts +0 -0
- /package/dist/{modules/pagination → pagination}/use-pagination.js +0 -0
- /package/dist/{modules/slider → slider}/index.d.ts +0 -0
- /package/dist/{modules/slider → slider}/index.js +0 -0
- /package/dist/{modules/slider → slider}/slider.d.ts +0 -0
- /package/dist/{modules/slider → slider}/slider.props.d.ts +0 -0
- /package/dist/{modules/slider → slider}/slider.props.js +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface DaysProps {
|
|
2
|
+
days: Array<object>;
|
|
3
|
+
|
|
4
|
+
monthName: string;
|
|
5
|
+
|
|
6
|
+
selectedDay: string;
|
|
7
|
+
|
|
8
|
+
disablePreviousMonths: boolean;
|
|
9
|
+
|
|
10
|
+
disableSubsequentMonths: boolean;
|
|
11
|
+
|
|
12
|
+
disablePreviousDays: boolean;
|
|
13
|
+
|
|
14
|
+
disableSubsequentDays: boolean;
|
|
15
|
+
|
|
16
|
+
daysEventListeners: any;
|
|
17
|
+
|
|
18
|
+
increaseMonth: () => void;
|
|
19
|
+
|
|
20
|
+
decreaseMonth: () => void;
|
|
21
|
+
|
|
22
|
+
isDatePicker: boolean;
|
|
23
|
+
|
|
24
|
+
selected: string | Date | undefined;
|
|
25
|
+
|
|
26
|
+
selectDateHandlers: any;
|
|
27
|
+
|
|
28
|
+
year: string;
|
|
29
|
+
|
|
30
|
+
date: any;
|
|
31
|
+
|
|
32
|
+
dateFormat: string;
|
|
33
|
+
|
|
34
|
+
type: 'gregorian' | 'jalali'
|
|
35
|
+
|
|
36
|
+
holidays?: Array<string>
|
|
37
|
+
|
|
38
|
+
variant: 'simple' | 'range'
|
|
39
|
+
|
|
40
|
+
selectDateRangeHandlers: any
|
|
41
|
+
|
|
42
|
+
rangeDate: any
|
|
43
|
+
|
|
44
|
+
rangeDates: Array<string>
|
|
45
|
+
|
|
46
|
+
size?: 'tiny' | 'small' | 'medium' | 'large' | 'huge'
|
|
47
|
+
|
|
48
|
+
changeMonth: (monthIndex: number) => void
|
|
49
|
+
|
|
50
|
+
changeYear: (year: string) => void
|
|
51
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { DaysProps } from './days.props';
|
|
2
|
+
import DaysHead from '../days-head/days-head';
|
|
3
|
+
import { Day } from '../day/day';
|
|
4
|
+
import { chunk, fa, IDays, weekDayNames } from '../../config';
|
|
5
|
+
import DateObject from 'react-date-object';
|
|
6
|
+
import persian from 'react-date-object/calendars/persian';
|
|
7
|
+
import gregorian from 'react-date-object/calendars/gregorian';
|
|
8
|
+
import { Div, Divider, Text } from '@pezeshk-book/ui-kit';
|
|
9
|
+
|
|
10
|
+
const boolDataset = (arg: boolean) => {
|
|
11
|
+
if (arg) {
|
|
12
|
+
return {
|
|
13
|
+
'data-disable': arg,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const Days = (props: DaysProps) => {
|
|
20
|
+
const {
|
|
21
|
+
days,
|
|
22
|
+
selected,
|
|
23
|
+
selectDateHandlers,
|
|
24
|
+
monthName,
|
|
25
|
+
disablePreviousMonths,
|
|
26
|
+
disableSubsequentMonths,
|
|
27
|
+
disablePreviousDays,
|
|
28
|
+
disableSubsequentDays,
|
|
29
|
+
increaseMonth,
|
|
30
|
+
decreaseMonth,
|
|
31
|
+
selectedDay,
|
|
32
|
+
year,
|
|
33
|
+
date,
|
|
34
|
+
dateFormat,
|
|
35
|
+
type,
|
|
36
|
+
holidays,
|
|
37
|
+
variant,
|
|
38
|
+
selectDateRangeHandlers,
|
|
39
|
+
rangeDate,
|
|
40
|
+
rangeDates,
|
|
41
|
+
size,
|
|
42
|
+
changeMonth,
|
|
43
|
+
changeYear,
|
|
44
|
+
} = props;
|
|
45
|
+
|
|
46
|
+
const handleDayClick = (day: IDays): void => {
|
|
47
|
+
selectDateHandlers(day);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const handleRangeClick = (day: IDays): void => {
|
|
51
|
+
if (rangeDate.start && !rangeDate.end && rangeDate.start.gregorianDate < day.gregorianDate) {
|
|
52
|
+
selectDateRangeHandlers({ start: rangeDate.start, end: day });
|
|
53
|
+
} else if (rangeDate.start && !rangeDate.end && rangeDate.start.gregorianDate > day.gregorianDate) {
|
|
54
|
+
selectDateRangeHandlers({ start: day, end: rangeDate.start });
|
|
55
|
+
} else {
|
|
56
|
+
selectDateRangeHandlers({ start: day, end: null });
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const weeks = chunk(days, 7);
|
|
61
|
+
const dates = new DateObject({ date: date, calendar: type === 'gregorian' ? gregorian : persian }).format(dateFormat);
|
|
62
|
+
if (!days.length) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const weekDays = size === 'huge' || size === 'large' ? weekDayNames[type].normal : weekDayNames[type].short;
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Div className={'flex-1 flex-col self-center relative overflow-auto mx-1 bg-white'}>
|
|
70
|
+
<DaysHead
|
|
71
|
+
year={year}
|
|
72
|
+
monthName={monthName}
|
|
73
|
+
days={days}
|
|
74
|
+
date={date}
|
|
75
|
+
dateFormat={dateFormat}
|
|
76
|
+
disablePreviousMonths={disablePreviousMonths}
|
|
77
|
+
disableSubsequentMonths={disableSubsequentMonths}
|
|
78
|
+
increaseMonth={increaseMonth}
|
|
79
|
+
decreaseMonth={decreaseMonth}
|
|
80
|
+
changeMonth={changeMonth}
|
|
81
|
+
changeYear={changeYear}
|
|
82
|
+
type={type}
|
|
83
|
+
size={size}
|
|
84
|
+
/>
|
|
85
|
+
<Div className={'flex-col items-center flex-1 gap-4'} data-testid="days-wrapper">
|
|
86
|
+
<Div dir={type === 'gregorian' ? 'ltr' : 'rtl'} className={'grid grid-cols-7 w-full'}>
|
|
87
|
+
{weekDays.map(name => (
|
|
88
|
+
<Text typography={'xs'} type={'regular'} color={'black'} key={name}>{name}</Text>
|
|
89
|
+
))}
|
|
90
|
+
</Div>
|
|
91
|
+
<Divider color={'control'}/>
|
|
92
|
+
<Div className={'flex-col w-full gap-y-4'}>
|
|
93
|
+
{weeks.map((week, idx) => {
|
|
94
|
+
return (
|
|
95
|
+
<Div dir={type === 'gregorian' ? 'ltr' : 'rtl'} className={'grid grid-flow-col grid-cols-7 w-full'} data-testid="days" key={`rdp-weeks-${idx}`}>
|
|
96
|
+
{week.map((day: IDays, id: any) => {
|
|
97
|
+
return (
|
|
98
|
+
<Day
|
|
99
|
+
key={type === 'gregorian' ? day.gregorianDate : day.jalaliDate}
|
|
100
|
+
passedDay={disablePreviousDays && (type === 'gregorian' ? day.gregorianDate : day.jalaliDate) < dates}
|
|
101
|
+
comingDay={disableSubsequentDays && (type === 'gregorian' ? day.gregorianDate : day.jalaliDate) > dates}
|
|
102
|
+
holidays={holidays && holidays.indexOf(day.gregorianDate) !== -1}
|
|
103
|
+
data-testid={`day-${idx * 7 + id + 1}`}
|
|
104
|
+
data-fadate={`${type === 'gregorian' ? day.gregorianDate : day.jalaliDate}`}
|
|
105
|
+
disabledDay={week.length === 7 && id === 6}
|
|
106
|
+
selectedDay={selectedDay === (type === 'gregorian' ? day.gregorianDate : day.jalaliDate)}
|
|
107
|
+
selected={
|
|
108
|
+
variant === 'simple' ? (selected === day.jalaliDate || selected === day.gregorianDate)
|
|
109
|
+
: (rangeDate.start?.jalaliDate === day.jalaliDate || rangeDate.start?.gregorianDate === day.gregorianDate) ||
|
|
110
|
+
(rangeDate.end?.jalaliDate === day.jalaliDate || rangeDate.end?.gregorianDate === day.gregorianDate)
|
|
111
|
+
}
|
|
112
|
+
isRange={rangeDates.indexOf(day.gregorianDate) !== -1}
|
|
113
|
+
startRange={type === 'jalali'
|
|
114
|
+
? rangeDate.start?.jalaliDate === day.jalaliDate || rangeDate.start?.gregorianDate === day.gregorianDate
|
|
115
|
+
: rangeDate.end?.jalaliDate === day.jalaliDate || rangeDate.end?.gregorianDate === day.gregorianDate
|
|
116
|
+
}
|
|
117
|
+
endRange={type === 'jalali'
|
|
118
|
+
? rangeDate.end?.jalaliDate === day.jalaliDate || rangeDate.end?.gregorianDate === day.gregorianDate
|
|
119
|
+
: rangeDate.start?.jalaliDate === day.jalaliDate || rangeDate.start?.gregorianDate === day.gregorianDate
|
|
120
|
+
}
|
|
121
|
+
handleDay={variant === 'simple' ? () => handleDayClick(day) : () => handleRangeClick(day)}
|
|
122
|
+
size={size}
|
|
123
|
+
{...boolDataset(day.disabled)}>
|
|
124
|
+
{!day.disabled ? fa(day.day) : null}
|
|
125
|
+
</Day>
|
|
126
|
+
);
|
|
127
|
+
})}
|
|
128
|
+
</Div>
|
|
129
|
+
);
|
|
130
|
+
})}
|
|
131
|
+
</Div>
|
|
132
|
+
</Div>
|
|
133
|
+
</Div>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
Days.defaultProps = {
|
|
138
|
+
monthName: '',
|
|
139
|
+
disableDays: [],
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export default Days;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface DaysHeadProps {
|
|
2
|
+
monthName: string;
|
|
3
|
+
|
|
4
|
+
increaseMonth?: () => void;
|
|
5
|
+
|
|
6
|
+
decreaseMonth?: () => void;
|
|
7
|
+
|
|
8
|
+
year: string;
|
|
9
|
+
|
|
10
|
+
disablePreviousMonths: boolean;
|
|
11
|
+
|
|
12
|
+
disableSubsequentMonths: boolean;
|
|
13
|
+
|
|
14
|
+
days: any;
|
|
15
|
+
|
|
16
|
+
date: string;
|
|
17
|
+
|
|
18
|
+
dateFormat: string;
|
|
19
|
+
|
|
20
|
+
type: 'gregorian' | 'jalali'
|
|
21
|
+
|
|
22
|
+
changeMonth: (monthIndex: number) => void
|
|
23
|
+
|
|
24
|
+
size?: 'tiny' | 'small' | 'medium' | 'large' | 'huge'
|
|
25
|
+
|
|
26
|
+
changeYear: (year: string) => void
|
|
27
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DaysHeadProps } from './days-head.props';
|
|
3
|
+
import { Button, Div, Text, Popper, PopperContent, PopperHandler, TextField } from '@pezeshk-book/ui-kit';
|
|
4
|
+
import { ArrowLeftIcon, ArrowRightIcon } from '../../icons';
|
|
5
|
+
import DateObject from 'react-date-object';
|
|
6
|
+
import persian from 'react-date-object/calendars/persian';
|
|
7
|
+
import gregorian from 'react-date-object/calendars/gregorian';
|
|
8
|
+
import { useState } from 'react';
|
|
9
|
+
import classNames from '../../../utils/class-names';
|
|
10
|
+
import { gregorianMonths, jalaliMonths } from '../../config/months';
|
|
11
|
+
import { persianToEnglish } from '../../../utils/persian-to-english-number';
|
|
12
|
+
|
|
13
|
+
const DaysHead = ({ decreaseMonth, increaseMonth, monthName, year, disablePreviousMonths, disableSubsequentMonths, days, date, dateFormat, type, changeMonth, size = 'medium', changeYear }: DaysHeadProps) => {
|
|
14
|
+
const [monthPopper, setMonthPopper] = useState<boolean>(false);
|
|
15
|
+
const [yearPopper, setYearPopper] = useState<boolean>(false);
|
|
16
|
+
|
|
17
|
+
const [selectedYear, setSelectedYear] = useState<string>('');
|
|
18
|
+
|
|
19
|
+
const handleMonthPoppers = () => {
|
|
20
|
+
setMonthPopper(!monthPopper);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const handleYearPoppers = () => {
|
|
24
|
+
setYearPopper(!yearPopper);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const handleSelectMonth = (value: number) => {
|
|
28
|
+
changeMonth(value);
|
|
29
|
+
handleMonthPoppers();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const handleYearValue = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
33
|
+
setSelectedYear(e.target.value);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const handleChangeYear = () => {
|
|
37
|
+
changeYear(persianToEnglish(selectedYear));
|
|
38
|
+
handleYearPoppers();
|
|
39
|
+
handleMonthPoppers();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const comparedFromCurrentMonth = (amount: number): boolean => {
|
|
43
|
+
const sideDatesMonth = new DateObject({ date: date, calendar: type === 'gregorian' ? gregorian : persian }).add(amount, 'month').setDay(31).format(dateFormat);
|
|
44
|
+
const lastDaySideMonthCalendarShow = new DateObject(type === 'gregorian' ? { date: days.at(-1).gregorianDate, calendar: gregorian } : { date: days.at(-1).jalaliDate, calendar: persian }).add(amount, 'month').setDay(31).format(dateFormat);
|
|
45
|
+
|
|
46
|
+
return sideDatesMonth === lastDaySideMonthCalendarShow;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Div className={'justify-center items-center bg-white w-full self-center mb-5'}>
|
|
51
|
+
<Div className={'w-full items-center justify-between h-12'}>
|
|
52
|
+
<Button ariaLabel={'previousMonth'} variant={'text'} size={'small'} color={'control'} className={'flex items-center'} onClick={decreaseMonth} shape={'square'} disabled={disablePreviousMonths && comparedFromCurrentMonth(-1)}>
|
|
53
|
+
<Div className={'h-3 w-2.5 relative'}>
|
|
54
|
+
<ArrowRightIcon/>
|
|
55
|
+
</Div>
|
|
56
|
+
</Button>
|
|
57
|
+
<Div className={'flex items-center gap-2'}>
|
|
58
|
+
<Popper
|
|
59
|
+
handlePopper={handleMonthPoppers}
|
|
60
|
+
showPopper={monthPopper}
|
|
61
|
+
position={'bottom'}
|
|
62
|
+
className={'flex-1 z-20'}
|
|
63
|
+
>
|
|
64
|
+
<PopperHandler>
|
|
65
|
+
<Text className={'cursor-pointer'} color={'grey.900'} type={'bold'} typography={'lg'}>{monthName}</Text>
|
|
66
|
+
</PopperHandler>
|
|
67
|
+
<PopperContent className={'shadow-xl mr-10 md:mr-14'}>
|
|
68
|
+
<Div className={classNames(
|
|
69
|
+
'bg-white p-2 md:w-48 w-40 items-center justify-center',
|
|
70
|
+
size === 'medium' && 'w-56',
|
|
71
|
+
size === 'large' && 'w-64',
|
|
72
|
+
size === 'huge' && 'w-72',
|
|
73
|
+
)}>
|
|
74
|
+
{type === 'gregorian' ? (
|
|
75
|
+
<Div className={'grid grid-cols-3 gap-8 justify-between'}>
|
|
76
|
+
{gregorianMonths.map(month => (
|
|
77
|
+
<Button className={'!px-0'} onClick={() => handleSelectMonth(month.value)} variant={'text'} size={size}>{month.name}</Button>
|
|
78
|
+
))}
|
|
79
|
+
</Div>
|
|
80
|
+
) : (
|
|
81
|
+
<Div className={'grid grid-cols-3 gap-2'}>
|
|
82
|
+
{jalaliMonths.map(month => (
|
|
83
|
+
<Button className={'!px-0'} onClick={() => handleSelectMonth(month.value)} variant={'text'} size={size}>{month.name}</Button>
|
|
84
|
+
))}
|
|
85
|
+
</Div>
|
|
86
|
+
)}
|
|
87
|
+
</Div>
|
|
88
|
+
</PopperContent>
|
|
89
|
+
</Popper>
|
|
90
|
+
<Popper
|
|
91
|
+
handlePopper={handleYearPoppers}
|
|
92
|
+
showPopper={yearPopper}
|
|
93
|
+
position={'bottom'}
|
|
94
|
+
className={'flex-1 z-20'}
|
|
95
|
+
>
|
|
96
|
+
<PopperHandler>
|
|
97
|
+
<Text className={'cursor-pointer'} color={'grey.900'} type={'bold'} typography={'lg'}>{year}</Text>
|
|
98
|
+
</PopperHandler>
|
|
99
|
+
<PopperContent className={'shadow-xl md:ml-10 ml-8 rounded-lg'}>
|
|
100
|
+
<Div className={classNames(
|
|
101
|
+
'bg-white px-2 py-8 md:w-48 w-40 items-center justify-center flex-col gap-4 rounded-lg',
|
|
102
|
+
size === 'medium' && 'w-56',
|
|
103
|
+
size === 'large' && 'w-64',
|
|
104
|
+
size === 'huge' && 'w-72',
|
|
105
|
+
)}>
|
|
106
|
+
<TextField value={selectedYear} onChange={handleYearValue} label={'سال'} size={size === 'tiny' || size === 'small' ? 'tiny' : 'medium'} />
|
|
107
|
+
<Button onClick={handleChangeYear} size={size === 'tiny' || size === 'small' ? 'tiny' : 'medium'}>برو به سال</Button>
|
|
108
|
+
</Div>
|
|
109
|
+
</PopperContent>
|
|
110
|
+
</Popper>
|
|
111
|
+
</Div>
|
|
112
|
+
<Button ariaLabel={'nextMonth'} variant={'text'} size={'small'} color={'control'} className={'flex items-center'} onClick={increaseMonth} shape={'square'} disabled={disableSubsequentMonths && comparedFromCurrentMonth(1)}>
|
|
113
|
+
<Div className={'h-3 w-2.5 relative'}>
|
|
114
|
+
<ArrowLeftIcon/>
|
|
115
|
+
</Div>
|
|
116
|
+
</Button>
|
|
117
|
+
</Div>
|
|
118
|
+
</Div>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default DaysHead;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TextProps } from '@pezeshk-book/ui-kit/text/text.props';
|
|
2
|
+
|
|
3
|
+
export interface CountdownProps {
|
|
4
|
+
|
|
5
|
+
sec: number
|
|
6
|
+
|
|
7
|
+
parentCallback?: any
|
|
8
|
+
|
|
9
|
+
reset?: boolean
|
|
10
|
+
|
|
11
|
+
variant?: 'contained' | 'outlined'
|
|
12
|
+
|
|
13
|
+
className?: string
|
|
14
|
+
|
|
15
|
+
textProps?: Omit<TextProps, 'children'>
|
|
16
|
+
|
|
17
|
+
initialColor?: 'primary' | 'success'
|
|
18
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { CountdownProps } from './countdown.props';
|
|
4
|
+
import { classNames, Div, Text } from '@pezeshk-book/ui-kit';
|
|
5
|
+
|
|
6
|
+
const CountDown = ({ sec, parentCallback, reset, variant = 'contained', className, textProps, initialColor = 'primary' }: CountdownProps) => {
|
|
7
|
+
const [timerSec, setTimerSec] = useState<number>(sec);
|
|
8
|
+
const [timerMin, setTimerMin] = useState<number>(0);
|
|
9
|
+
const [timerHour, setTimerHour] = useState<number>(0);
|
|
10
|
+
const [color, setColor] = useState<'success' | 'warning' | 'danger' | 'primary'>(initialColor);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (sec >= 3600) {
|
|
14
|
+
setTimerHour(Math.floor(sec / 3600));
|
|
15
|
+
setTimerMin(Math.floor((sec % 3600) / 60));
|
|
16
|
+
setTimerSec(Math.floor((sec % 3600) % 60));
|
|
17
|
+
} else {
|
|
18
|
+
setTimerMin(Math.floor(sec / 60));
|
|
19
|
+
setTimerSec(Math.floor(sec % 60));
|
|
20
|
+
}
|
|
21
|
+
}, [reset]);
|
|
22
|
+
|
|
23
|
+
const id = useRef(null);
|
|
24
|
+
const clear = () => {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
clearInterval(id.current);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
id.current = setInterval(() => {
|
|
32
|
+
setTimerSec((time) => time - 1);
|
|
33
|
+
}, 1000);
|
|
34
|
+
return () => clear();
|
|
35
|
+
}, [reset]);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (timerSec === 0 && timerMin === 0 && timerHour === 0) {
|
|
39
|
+
parentCallback(true);
|
|
40
|
+
clear();
|
|
41
|
+
} else if (timerSec === -1 && timerMin !== 0) {
|
|
42
|
+
setTimerSec(59);
|
|
43
|
+
setTimerMin((time) => time - 1);
|
|
44
|
+
} else if (timerSec === -1 && timerMin === 0 && timerHour !== 0) {
|
|
45
|
+
setTimerSec(59);
|
|
46
|
+
setTimerMin(59);
|
|
47
|
+
setTimerHour((time) => time - 1);
|
|
48
|
+
}
|
|
49
|
+
const remainingTime = (timerSec + timerMin * 60 + timerHour * 3600);
|
|
50
|
+
setColor((remainingTime <= (sec / 10) ? 'danger' : (remainingTime <= (sec * 30 / 100) ? 'warning' : initialColor)));
|
|
51
|
+
}, [timerSec]);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Div dir={'rtl'} className={classNames(
|
|
55
|
+
'items-center justify-center h-full rounded',
|
|
56
|
+
variant === 'contained' ? 'bg-primary' : 'bg-transparent',
|
|
57
|
+
className,
|
|
58
|
+
)}>
|
|
59
|
+
<Text typography={'base'} color={variant === 'contained' ? 'white' : color} {...textProps}>
|
|
60
|
+
{timerSec < 10 ? '0' + timerSec : timerSec}
|
|
61
|
+
</Text>
|
|
62
|
+
<Text className={'mx-1'} typography={'base'} color={variant === 'contained' ? 'white' : color} {...textProps}>:</Text>
|
|
63
|
+
<Text typography={'base'} color={variant === 'contained' ? 'white' : color} {...textProps}>
|
|
64
|
+
{timerMin < 10 ? '0' + timerMin : timerMin}
|
|
65
|
+
</Text>
|
|
66
|
+
{sec >= 3600
|
|
67
|
+
? <>
|
|
68
|
+
<Text className={'mx-1'} typography={'base'} color={variant === 'contained' ? 'white' : color} {...textProps}>:</Text>
|
|
69
|
+
<Text typography={'base'} color={variant === 'contained' ? 'white' : color} {...textProps}>
|
|
70
|
+
{timerHour < 10 ? '0' + timerHour : timerHour}
|
|
71
|
+
</Text>
|
|
72
|
+
</> : null
|
|
73
|
+
}
|
|
74
|
+
</Div>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default CountDown;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DefaultDataTableProps } from './default/default-data-table.props';
|
|
2
|
+
import { SimpleDataTableProps } from './simple/simple-data-table.props';
|
|
3
|
+
|
|
4
|
+
export type TableVariant = 'simple' | 'default';
|
|
5
|
+
export type DataTableProps<T extends TableVariant> = T extends 'simple' ?
|
|
6
|
+
{ variant: 'simple' } & SimpleDataTableProps :
|
|
7
|
+
{ variant: 'default' } & DefaultDataTableProps;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DataTableProps, TableVariant } from './data-table.props';
|
|
2
|
+
import DefaultDataTable from './default';
|
|
3
|
+
import SimpleDataTable from './simple';
|
|
4
|
+
import { DefaultDataTableProps } from './default/default-data-table.props';
|
|
5
|
+
import { SimpleDataTableProps } from './simple/simple-data-table.props';
|
|
6
|
+
|
|
7
|
+
const DataTable = <T extends TableVariant>(props: DataTableProps<T>) => {
|
|
8
|
+
if (props.variant === 'default') {
|
|
9
|
+
return <DefaultDataTable {...(props as DefaultDataTableProps)} />;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return <SimpleDataTable {...(props as SimpleDataTableProps)} />;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default DataTable;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
|
|
3
|
+
export interface DefaultDataTableProps {
|
|
4
|
+
data: Array<any>
|
|
5
|
+
|
|
6
|
+
header: any
|
|
7
|
+
|
|
8
|
+
column: Array<ColumnDef<any>>
|
|
9
|
+
|
|
10
|
+
mobileColumns?: Array<string>
|
|
11
|
+
|
|
12
|
+
expandable?: boolean
|
|
13
|
+
|
|
14
|
+
expandedComponent?: any
|
|
15
|
+
|
|
16
|
+
serverSideSorting?: (sort: any) => void
|
|
17
|
+
|
|
18
|
+
isLoading?: boolean
|
|
19
|
+
|
|
20
|
+
getCurrentPage: (n: number) => void
|
|
21
|
+
|
|
22
|
+
lastPage: number
|
|
23
|
+
|
|
24
|
+
perPage: number
|
|
25
|
+
|
|
26
|
+
currentPage: number
|
|
27
|
+
|
|
28
|
+
total: number
|
|
29
|
+
|
|
30
|
+
nextPage: any
|
|
31
|
+
|
|
32
|
+
previousPage: any
|
|
33
|
+
|
|
34
|
+
getLimit?: (event: string) => void
|
|
35
|
+
|
|
36
|
+
columnOrder?: boolean
|
|
37
|
+
|
|
38
|
+
updateData?: (value: string, info?: string | object) => void
|
|
39
|
+
|
|
40
|
+
select?: boolean
|
|
41
|
+
|
|
42
|
+
selectedRows?: (rows: Array<ColumnDef<any>>) => void
|
|
43
|
+
|
|
44
|
+
expandAll?: boolean
|
|
45
|
+
|
|
46
|
+
visitedRows?: Array<number>
|
|
47
|
+
}
|