@pezeshk-book/modules 0.2.5 → 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.
Files changed (278) hide show
  1. package/.eslintrc.json +133 -0
  2. package/calendar/calendar.props.ts +25 -0
  3. package/calendar/calendar.tsx +183 -0
  4. package/calendar/config/chunk.ts +42 -0
  5. package/calendar/config/create-date-range.ts +14 -0
  6. package/calendar/config/days-in-month.en.ts +47 -0
  7. package/calendar/config/days-in-month.fa.ts +37 -0
  8. package/calendar/config/index.ts +16 -0
  9. package/calendar/config/months.ts +29 -0
  10. package/calendar/config/week-day.ts +19 -0
  11. package/calendar/icons/arrow-left-icon.tsx +14 -0
  12. package/calendar/icons/arrow-right-icon.tsx +14 -0
  13. package/calendar/icons/index.ts +7 -0
  14. package/calendar/index.ts +3 -0
  15. package/calendar/shared/formatDate.tsx +12 -0
  16. package/calendar/sub-components/day/day.props.ts +27 -0
  17. package/calendar/sub-components/day/day.tsx +31 -0
  18. package/calendar/sub-components/days/days.props.ts +51 -0
  19. package/calendar/sub-components/days/days.tsx +142 -0
  20. package/calendar/sub-components/days-head/days-head.props.ts +27 -0
  21. package/calendar/sub-components/days-head/days-head.tsx +122 -0
  22. package/countdown-timer/countdown.props.ts +18 -0
  23. package/countdown-timer/countdown.tsx +78 -0
  24. package/countdown-timer/index.ts +3 -0
  25. package/data-table/data-table.props.ts +7 -0
  26. package/data-table/data-table.tsx +15 -0
  27. package/data-table/default/default-data-table.props.ts +47 -0
  28. package/data-table/default/default-data-table.tsx +427 -0
  29. package/data-table/default/index.ts +3 -0
  30. package/data-table/hooks/use-window-dimensions.tsx +33 -0
  31. package/data-table/icons/add.tsx +10 -0
  32. package/data-table/icons/arrow-down.tsx +11 -0
  33. package/data-table/icons/index.ts +9 -0
  34. package/data-table/icons/sort.tsx +16 -0
  35. package/data-table/index.ts +3 -0
  36. package/data-table/simple/index.ts +3 -0
  37. package/data-table/simple/simple-data-table.props.ts +23 -0
  38. package/data-table/simple/simple-data-table.tsx +258 -0
  39. package/dist/calendar/calendar.js.map +1 -0
  40. package/dist/calendar/calendar.props.js.map +1 -0
  41. package/dist/calendar/config/chunk.js.map +1 -0
  42. package/dist/calendar/config/create-date-range.js.map +1 -0
  43. package/dist/calendar/config/days-in-month.en.js.map +1 -0
  44. package/dist/calendar/config/days-in-month.fa.js.map +1 -0
  45. package/dist/calendar/config/index.js.map +1 -0
  46. package/dist/calendar/config/months.js.map +1 -0
  47. package/dist/calendar/config/week-day.js.map +1 -0
  48. package/dist/calendar/icons/arrow-left-icon.js.map +1 -0
  49. package/dist/calendar/icons/arrow-right-icon.js.map +1 -0
  50. package/dist/calendar/icons/index.js.map +1 -0
  51. package/dist/calendar/index.js.map +1 -0
  52. package/dist/calendar/shared/formatDate.js.map +1 -0
  53. package/dist/{modules/calendar → calendar}/sub-components/day/day.js +1 -1
  54. package/dist/calendar/sub-components/day/day.js.map +1 -0
  55. package/dist/calendar/sub-components/day/day.props.js.map +1 -0
  56. package/dist/calendar/sub-components/days/days.js.map +1 -0
  57. package/dist/calendar/sub-components/days/days.props.js.map +1 -0
  58. package/dist/{modules/calendar → calendar}/sub-components/days-head/days-head.js +2 -2
  59. package/dist/calendar/sub-components/days-head/days-head.js.map +1 -0
  60. package/dist/calendar/sub-components/days-head/days-head.props.js.map +1 -0
  61. package/dist/countdown-timer/countdown.js.map +1 -0
  62. package/dist/countdown-timer/countdown.props.js.map +1 -0
  63. package/dist/countdown-timer/index.js.map +1 -0
  64. package/dist/data-table/data-table.js.map +1 -0
  65. package/dist/data-table/data-table.props.js.map +1 -0
  66. package/dist/data-table/default/default-data-table.js.map +1 -0
  67. package/dist/data-table/default/default-data-table.props.js.map +1 -0
  68. package/dist/data-table/default/index.js.map +1 -0
  69. package/dist/data-table/hooks/use-window-dimensions.js.map +1 -0
  70. package/dist/data-table/icons/add.js.map +1 -0
  71. package/dist/data-table/icons/arrow-down.js.map +1 -0
  72. package/dist/data-table/icons/index.js.map +1 -0
  73. package/dist/data-table/icons/sort.js.map +1 -0
  74. package/dist/data-table/index.js.map +1 -0
  75. package/dist/data-table/simple/index.js.map +1 -0
  76. package/dist/data-table/simple/simple-data-table.js.map +1 -0
  77. package/dist/data-table/simple/simple-data-table.props.js.map +1 -0
  78. package/dist/index.d.ts +5 -5
  79. package/dist/index.js +5 -5
  80. package/dist/index.js.map +1 -1
  81. package/dist/pagination/icons/arrow-Right.js.map +1 -0
  82. package/dist/pagination/icons/arrow-left.js.map +1 -0
  83. package/dist/pagination/icons/index.js.map +1 -0
  84. package/dist/pagination/index.js.map +1 -0
  85. package/dist/pagination/pagination.js.map +1 -0
  86. package/dist/pagination/pagination.props.js.map +1 -0
  87. package/dist/pagination/use-pagination.js.map +1 -0
  88. package/dist/slider/index.js.map +1 -0
  89. package/dist/{modules/slider → slider}/slider.js +1 -1
  90. package/dist/slider/slider.js.map +1 -0
  91. package/dist/slider/slider.props.js.map +1 -0
  92. package/dist/stories/calendar/calendar.d.ts +1 -1
  93. package/dist/stories/calendar/calendar.js +1 -1
  94. package/dist/stories/calendar/calendar.js.map +1 -1
  95. package/dist/stories/count-down/count-down.d.ts +1 -1
  96. package/dist/stories/count-down/count-down.js +1 -1
  97. package/dist/stories/count-down/count-down.js.map +1 -1
  98. package/dist/stories/data-table/default-data-table.d.ts +1 -1
  99. package/dist/stories/data-table/default-data-table.js +1 -1
  100. package/dist/stories/data-table/default-data-table.js.map +1 -1
  101. package/dist/stories/data-table/simple-data-table.d.ts +1 -1
  102. package/dist/stories/data-table/simple-data-table.js +1 -1
  103. package/dist/stories/data-table/simple-data-table.js.map +1 -1
  104. package/dist/stories/pagination/pagination.d.ts +1 -1
  105. package/dist/stories/pagination/pagination.js +1 -1
  106. package/dist/stories/pagination/pagination.js.map +1 -1
  107. package/dist/stories/slider/slider.d.ts +1 -1
  108. package/dist/stories/slider/slider.js +1 -1
  109. package/dist/stories/slider/slider.js.map +1 -1
  110. package/index.ts +13 -0
  111. package/package.json +5 -10
  112. package/pagination/icons/arrow-Right.tsx +22 -0
  113. package/pagination/icons/arrow-left.tsx +22 -0
  114. package/pagination/icons/index.ts +7 -0
  115. package/pagination/index.ts +3 -0
  116. package/pagination/pagination.props.ts +33 -0
  117. package/pagination/pagination.tsx +133 -0
  118. package/pagination/use-pagination.ts +49 -0
  119. package/react-app-env.d.ts +1 -0
  120. package/slider/index.ts +3 -0
  121. package/slider/slider.props.ts +39 -0
  122. package/slider/slider.tsx +290 -0
  123. package/stories/calendar/calendar.stories.tsx +25 -0
  124. package/stories/calendar/calendar.tsx +11 -0
  125. package/stories/count-down/count-down.stories.tsx +19 -0
  126. package/stories/count-down/count-down.tsx +11 -0
  127. package/stories/data-table/data-table-columns.tsx +70 -0
  128. package/stories/data-table/default-data-table.stories.tsx +22 -0
  129. package/stories/data-table/default-data-table.tsx +18 -0
  130. package/stories/data-table/dummy-data.ts +204 -0
  131. package/stories/data-table/simple-data-table.stories.tsx +22 -0
  132. package/stories/data-table/simple-data-table.tsx +18 -0
  133. package/stories/pagination/pagination.stories.tsx +35 -0
  134. package/stories/pagination/pagination.tsx +11 -0
  135. package/stories/slider/slider.stories.tsx +19 -0
  136. package/stories/slider/slider.tsx +45 -0
  137. package/stories/wrapper.tsx +11 -0
  138. package/styles.css +28 -0
  139. package/utils/class-names.ts +5 -0
  140. package/utils/persian-to-english-number.ts +4 -0
  141. package/dist/modules/calendar/calendar.js.map +0 -1
  142. package/dist/modules/calendar/calendar.props.js.map +0 -1
  143. package/dist/modules/calendar/config/chunk.js.map +0 -1
  144. package/dist/modules/calendar/config/create-date-range.js.map +0 -1
  145. package/dist/modules/calendar/config/days-in-month.en.js.map +0 -1
  146. package/dist/modules/calendar/config/days-in-month.fa.js.map +0 -1
  147. package/dist/modules/calendar/config/index.js.map +0 -1
  148. package/dist/modules/calendar/config/months.js.map +0 -1
  149. package/dist/modules/calendar/config/week-day.js.map +0 -1
  150. package/dist/modules/calendar/icons/arrow-left-icon.js.map +0 -1
  151. package/dist/modules/calendar/icons/arrow-right-icon.js.map +0 -1
  152. package/dist/modules/calendar/icons/index.js.map +0 -1
  153. package/dist/modules/calendar/index.js.map +0 -1
  154. package/dist/modules/calendar/shared/formatDate.js.map +0 -1
  155. package/dist/modules/calendar/sub-components/day/day.js.map +0 -1
  156. package/dist/modules/calendar/sub-components/day/day.props.js.map +0 -1
  157. package/dist/modules/calendar/sub-components/days/days.js.map +0 -1
  158. package/dist/modules/calendar/sub-components/days/days.props.js.map +0 -1
  159. package/dist/modules/calendar/sub-components/days-head/days-head.js.map +0 -1
  160. package/dist/modules/calendar/sub-components/days-head/days-head.props.js.map +0 -1
  161. package/dist/modules/countdown-timer/countdown.js.map +0 -1
  162. package/dist/modules/countdown-timer/countdown.props.js.map +0 -1
  163. package/dist/modules/countdown-timer/index.js.map +0 -1
  164. package/dist/modules/data-table/data-table.js.map +0 -1
  165. package/dist/modules/data-table/data-table.props.js.map +0 -1
  166. package/dist/modules/data-table/default/default-data-table.js.map +0 -1
  167. package/dist/modules/data-table/default/default-data-table.props.js.map +0 -1
  168. package/dist/modules/data-table/default/index.js.map +0 -1
  169. package/dist/modules/data-table/hooks/use-window-dimensions.js.map +0 -1
  170. package/dist/modules/data-table/icons/add.js.map +0 -1
  171. package/dist/modules/data-table/icons/arrow-down.js.map +0 -1
  172. package/dist/modules/data-table/icons/index.js.map +0 -1
  173. package/dist/modules/data-table/icons/sort.js.map +0 -1
  174. package/dist/modules/data-table/index.js.map +0 -1
  175. package/dist/modules/data-table/simple/index.js.map +0 -1
  176. package/dist/modules/data-table/simple/simple-data-table.js.map +0 -1
  177. package/dist/modules/data-table/simple/simple-data-table.props.js.map +0 -1
  178. package/dist/modules/pagination/icons/arrow-Right.js.map +0 -1
  179. package/dist/modules/pagination/icons/arrow-left.js.map +0 -1
  180. package/dist/modules/pagination/icons/index.js.map +0 -1
  181. package/dist/modules/pagination/index.js.map +0 -1
  182. package/dist/modules/pagination/pagination.js.map +0 -1
  183. package/dist/modules/pagination/pagination.props.js.map +0 -1
  184. package/dist/modules/pagination/use-pagination.js.map +0 -1
  185. package/dist/modules/slider/index.js.map +0 -1
  186. package/dist/modules/slider/slider.js.map +0 -1
  187. package/dist/modules/slider/slider.props.js.map +0 -1
  188. /package/dist/{modules/calendar → calendar}/calendar.d.ts +0 -0
  189. /package/dist/{modules/calendar → calendar}/calendar.js +0 -0
  190. /package/dist/{modules/calendar → calendar}/calendar.props.d.ts +0 -0
  191. /package/dist/{modules/calendar → calendar}/calendar.props.js +0 -0
  192. /package/dist/{modules/calendar → calendar}/config/chunk.d.ts +0 -0
  193. /package/dist/{modules/calendar → calendar}/config/chunk.js +0 -0
  194. /package/dist/{modules/calendar → calendar}/config/create-date-range.d.ts +0 -0
  195. /package/dist/{modules/calendar → calendar}/config/create-date-range.js +0 -0
  196. /package/dist/{modules/calendar → calendar}/config/days-in-month.en.d.ts +0 -0
  197. /package/dist/{modules/calendar → calendar}/config/days-in-month.en.js +0 -0
  198. /package/dist/{modules/calendar → calendar}/config/days-in-month.fa.d.ts +0 -0
  199. /package/dist/{modules/calendar → calendar}/config/days-in-month.fa.js +0 -0
  200. /package/dist/{modules/calendar → calendar}/config/index.d.ts +0 -0
  201. /package/dist/{modules/calendar → calendar}/config/index.js +0 -0
  202. /package/dist/{modules/calendar → calendar}/config/months.d.ts +0 -0
  203. /package/dist/{modules/calendar → calendar}/config/months.js +0 -0
  204. /package/dist/{modules/calendar → calendar}/config/week-day.d.ts +0 -0
  205. /package/dist/{modules/calendar → calendar}/config/week-day.js +0 -0
  206. /package/dist/{modules/calendar → calendar}/icons/arrow-left-icon.d.ts +0 -0
  207. /package/dist/{modules/calendar → calendar}/icons/arrow-left-icon.js +0 -0
  208. /package/dist/{modules/calendar → calendar}/icons/arrow-right-icon.d.ts +0 -0
  209. /package/dist/{modules/calendar → calendar}/icons/arrow-right-icon.js +0 -0
  210. /package/dist/{modules/calendar → calendar}/icons/index.d.ts +0 -0
  211. /package/dist/{modules/calendar → calendar}/icons/index.js +0 -0
  212. /package/dist/{modules/calendar → calendar}/index.d.ts +0 -0
  213. /package/dist/{modules/calendar → calendar}/index.js +0 -0
  214. /package/dist/{modules/calendar → calendar}/shared/formatDate.d.ts +0 -0
  215. /package/dist/{modules/calendar → calendar}/shared/formatDate.js +0 -0
  216. /package/dist/{modules/calendar → calendar}/sub-components/day/day.d.ts +0 -0
  217. /package/dist/{modules/calendar → calendar}/sub-components/day/day.props.d.ts +0 -0
  218. /package/dist/{modules/calendar → calendar}/sub-components/day/day.props.js +0 -0
  219. /package/dist/{modules/calendar → calendar}/sub-components/days/days.d.ts +0 -0
  220. /package/dist/{modules/calendar → calendar}/sub-components/days/days.js +0 -0
  221. /package/dist/{modules/calendar → calendar}/sub-components/days/days.props.d.ts +0 -0
  222. /package/dist/{modules/calendar → calendar}/sub-components/days/days.props.js +0 -0
  223. /package/dist/{modules/calendar → calendar}/sub-components/days-head/days-head.d.ts +0 -0
  224. /package/dist/{modules/calendar → calendar}/sub-components/days-head/days-head.props.d.ts +0 -0
  225. /package/dist/{modules/calendar → calendar}/sub-components/days-head/days-head.props.js +0 -0
  226. /package/dist/{modules/countdown-timer → countdown-timer}/countdown.d.ts +0 -0
  227. /package/dist/{modules/countdown-timer → countdown-timer}/countdown.js +0 -0
  228. /package/dist/{modules/countdown-timer → countdown-timer}/countdown.props.d.ts +0 -0
  229. /package/dist/{modules/countdown-timer → countdown-timer}/countdown.props.js +0 -0
  230. /package/dist/{modules/countdown-timer → countdown-timer}/index.d.ts +0 -0
  231. /package/dist/{modules/countdown-timer → countdown-timer}/index.js +0 -0
  232. /package/dist/{modules/data-table → data-table}/data-table.d.ts +0 -0
  233. /package/dist/{modules/data-table → data-table}/data-table.js +0 -0
  234. /package/dist/{modules/data-table → data-table}/data-table.props.d.ts +0 -0
  235. /package/dist/{modules/data-table → data-table}/data-table.props.js +0 -0
  236. /package/dist/{modules/data-table → data-table}/default/default-data-table.d.ts +0 -0
  237. /package/dist/{modules/data-table → data-table}/default/default-data-table.js +0 -0
  238. /package/dist/{modules/data-table → data-table}/default/default-data-table.props.d.ts +0 -0
  239. /package/dist/{modules/data-table → data-table}/default/default-data-table.props.js +0 -0
  240. /package/dist/{modules/data-table → data-table}/default/index.d.ts +0 -0
  241. /package/dist/{modules/data-table → data-table}/default/index.js +0 -0
  242. /package/dist/{modules/data-table → data-table}/hooks/use-window-dimensions.d.ts +0 -0
  243. /package/dist/{modules/data-table → data-table}/hooks/use-window-dimensions.js +0 -0
  244. /package/dist/{modules/data-table → data-table}/icons/add.d.ts +0 -0
  245. /package/dist/{modules/data-table → data-table}/icons/add.js +0 -0
  246. /package/dist/{modules/data-table → data-table}/icons/arrow-down.d.ts +0 -0
  247. /package/dist/{modules/data-table → data-table}/icons/arrow-down.js +0 -0
  248. /package/dist/{modules/data-table → data-table}/icons/index.d.ts +0 -0
  249. /package/dist/{modules/data-table → data-table}/icons/index.js +0 -0
  250. /package/dist/{modules/data-table → data-table}/icons/sort.d.ts +0 -0
  251. /package/dist/{modules/data-table → data-table}/icons/sort.js +0 -0
  252. /package/dist/{modules/data-table → data-table}/index.d.ts +0 -0
  253. /package/dist/{modules/data-table → data-table}/index.js +0 -0
  254. /package/dist/{modules/data-table → data-table}/simple/index.d.ts +0 -0
  255. /package/dist/{modules/data-table → data-table}/simple/index.js +0 -0
  256. /package/dist/{modules/data-table → data-table}/simple/simple-data-table.d.ts +0 -0
  257. /package/dist/{modules/data-table → data-table}/simple/simple-data-table.js +0 -0
  258. /package/dist/{modules/data-table → data-table}/simple/simple-data-table.props.d.ts +0 -0
  259. /package/dist/{modules/data-table → data-table}/simple/simple-data-table.props.js +0 -0
  260. /package/dist/{modules/pagination → pagination}/icons/arrow-Right.d.ts +0 -0
  261. /package/dist/{modules/pagination → pagination}/icons/arrow-Right.js +0 -0
  262. /package/dist/{modules/pagination → pagination}/icons/arrow-left.d.ts +0 -0
  263. /package/dist/{modules/pagination → pagination}/icons/arrow-left.js +0 -0
  264. /package/dist/{modules/pagination → pagination}/icons/index.d.ts +0 -0
  265. /package/dist/{modules/pagination → pagination}/icons/index.js +0 -0
  266. /package/dist/{modules/pagination → pagination}/index.d.ts +0 -0
  267. /package/dist/{modules/pagination → pagination}/index.js +0 -0
  268. /package/dist/{modules/pagination → pagination}/pagination.d.ts +0 -0
  269. /package/dist/{modules/pagination → pagination}/pagination.js +0 -0
  270. /package/dist/{modules/pagination → pagination}/pagination.props.d.ts +0 -0
  271. /package/dist/{modules/pagination → pagination}/pagination.props.js +0 -0
  272. /package/dist/{modules/pagination → pagination}/use-pagination.d.ts +0 -0
  273. /package/dist/{modules/pagination → pagination}/use-pagination.js +0 -0
  274. /package/dist/{modules/slider → slider}/index.d.ts +0 -0
  275. /package/dist/{modules/slider → slider}/index.js +0 -0
  276. /package/dist/{modules/slider → slider}/slider.d.ts +0 -0
  277. /package/dist/{modules/slider → slider}/slider.props.d.ts +0 -0
  278. /package/dist/{modules/slider → slider}/slider.props.js +0 -0
@@ -0,0 +1,290 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { SliderProps } from './slider.props';
3
+ import { Div, Button } from '@pezeshk-book/ui-kit';
4
+ import classNames from '../utils/class-names';
5
+
6
+ const Slider = (
7
+ {
8
+ children,
9
+ delay = 2500,
10
+ spaceBetween = 0,
11
+ slides = 1,
12
+ infiniteLoop = false,
13
+ pauseOnMouseOver = false,
14
+ autoMove = true,
15
+ indicatorActiveColor = 'primary',
16
+ indicator = true,
17
+ navigation = true,
18
+ prevNavigation,
19
+ nextNavigation,
20
+ direction = 'rtl',
21
+ rows = 1,
22
+ navigationColor = 'primary',
23
+ tabletSlides = 1,
24
+ mobileSlides = 1,
25
+ indicatorClassName,
26
+ }: SliderProps) => {
27
+ const [showSlides, setShowSlides] = useState<number>(1);
28
+ const [currentIndex, setCurrentIndex] = React.useState(0);
29
+ const [length, setLength] = useState(Math.round(children.length / rows));
30
+ const [transitionEnabled, setTransitionEnabled] = useState(true);
31
+ const [touchPosition, setTouchPosition] = useState(null);
32
+ const [pause, setPause] = useState(false);
33
+ const [sliders, setSliders] = useState<any>([]);
34
+
35
+ const timeoutRef = React.useRef<any>(null);
36
+ const ref = React.useRef<any>(null);
37
+
38
+ const dir = React.useMemo(() => {
39
+ if (direction === 'rtl') {
40
+ return '+';
41
+ }
42
+ return '-';
43
+ }, [direction]);
44
+ const limit = React.useMemo(() => {
45
+ if (rows !== 1) {
46
+ return showSlides * rows >= children.length + 1;
47
+ }
48
+ return showSlides >= children.length;
49
+ }, [showSlides, rows, children]);
50
+
51
+ useEffect(() => {
52
+ if (window && window.screen) {
53
+ if (window.screen.width > 1024) {
54
+ setShowSlides(slides);
55
+ } else if (window.screen.width < 640) {
56
+ setShowSlides(mobileSlides);
57
+ } else { setShowSlides(tabletSlides); }
58
+ }
59
+ }, [slides, tabletSlides, mobileSlides]);
60
+
61
+ useEffect(() => {
62
+ let final = [];
63
+ for (let i = 0; i < length; i++) {
64
+ let output = [];
65
+ for (let index = i * rows; index < rows * (i + 1); index++) {
66
+ output.push(children[index]);
67
+ }
68
+ final.push(output);
69
+ }
70
+ setSliders(final);
71
+ }, [children, length, rows]);
72
+
73
+ useEffect(() => {
74
+ setLength(Math.round(children.length / rows));
75
+ }, [children, infiniteLoop, showSlides]);
76
+
77
+ useEffect(() => {
78
+ if (currentIndex === length - 1 || currentIndex === 0) {
79
+ setTransitionEnabled(true);
80
+ }
81
+ }, [currentIndex, showSlides, length]);
82
+ // @ts-ignore
83
+ useEffect(() => {
84
+ if (!pause && autoMove) {
85
+ resetTimeout();
86
+ timeoutRef.current = setTimeout(
87
+ () => next(), delay,
88
+ );
89
+
90
+ return () => {
91
+ resetTimeout();
92
+ };
93
+ }
94
+ }, [currentIndex, delay, pause]);
95
+
96
+ useEffect(() => {
97
+ if (ref.current) {
98
+ for (const arg of ref.current.children) {
99
+ arg.style.width = `calc((100% / ${showSlides}) - (${spaceBetween}px))`;
100
+ arg.style.gap = `${spaceBetween}px`;
101
+ arg.style.marginLeft = `${spaceBetween / 2}px`;
102
+ arg.style.marginRight = `${spaceBetween / 2}px`;
103
+ arg.style.flexShrink = 0;
104
+ arg.style.flexGrow = 1;
105
+ }
106
+ }
107
+ }, [showSlides, spaceBetween]);
108
+
109
+ const resetTimeout = () => {
110
+ if (timeoutRef.current) {
111
+ clearTimeout(timeoutRef.current);
112
+ }
113
+ };
114
+
115
+ const next = () => {
116
+ if ((currentIndex < (length - showSlides) + 1) && currentIndex !== length) {
117
+ setCurrentIndex(prevState => prevState + 1);
118
+ }
119
+ };
120
+
121
+ const prev = () => {
122
+ if ((currentIndex > 0) && currentIndex !== showSlides) {
123
+ setCurrentIndex(prevState => prevState - 1);
124
+ }
125
+ };
126
+
127
+ const handleTouchStart = (e: any) => {
128
+ const touchDown = e.touches[0].clientX;
129
+ setTouchPosition(touchDown);
130
+ };
131
+
132
+ const handleTouchMove = (e: any) => {
133
+ const touchDown = touchPosition;
134
+
135
+ if (touchDown === null) {
136
+ return;
137
+ }
138
+
139
+ const currentTouch = e.touches[0].clientX;
140
+ const diff = touchDown - currentTouch;
141
+
142
+ if (diff > 5) {
143
+ next();
144
+ }
145
+
146
+ if (diff < -5) {
147
+ prev();
148
+ }
149
+
150
+ setTouchPosition(null);
151
+ };
152
+
153
+ const handleTransitionEnd = () => {
154
+ if (currentIndex === length - showSlides) {
155
+ setTimeout(
156
+ () => {
157
+ setTransitionEnabled(false);
158
+ setCurrentIndex(0);
159
+ }, delay / 2,
160
+ );
161
+ }
162
+ };
163
+
164
+ const handlePauseAutoMove = (state: boolean) => {
165
+ if (pauseOnMouseOver) {
166
+ setPause(state);
167
+ }
168
+ };
169
+
170
+ return (
171
+ <Div dir={direction} className={'w-full flex-col'} onMouseOver={() => handlePauseAutoMove(true)} onMouseLeave={() => handlePauseAutoMove(false)}>
172
+ <Div className={'w-full relative'}>
173
+ {navigation && !limit ? (
174
+ <Button ariaLabel={'previousNavigation'} startAdornment={<ArrowIcon className={'rotate-180'}/>} disabled={direction === 'rtl' ? currentIndex === length - showSlides : currentIndex === 0} onClick={direction === 'rtl' ? next : prev} color={navigationColor} rounded={'full'} shape={'square'} className={'absolute flex self-center items-center justify-center z-10 left-2'}/>
175
+ ) : null}
176
+ {prevNavigation && currentIndex > 0 ? (
177
+ <>
178
+ {prevNavigation(prev)}
179
+ </>
180
+ ) : null}
181
+ {limit ? (
182
+ <div ref={ref} className={'flex shrink-0 grow w-full'}>
183
+ {sliders.map((item: any, itemIndex: number) => (
184
+ <Div className={'flex-col w-1/2'} key={itemIndex}>
185
+ {item}
186
+ </Div>
187
+ ))}
188
+ </div>
189
+ ) : (
190
+ <div className={'overflow-hidden w-full h-full'}
191
+ onTouchStart={handleTouchStart}
192
+ onTouchMove={handleTouchMove}
193
+ >
194
+ <div className={`flex transition ease-linear duration-300 shrink-0 grow w-full`}
195
+ style={{
196
+ transform: `translateX(${dir}${currentIndex * (100 / showSlides)}%)`,
197
+ transition: !transitionEnabled ? 'none' : undefined,
198
+ }}
199
+ onTransitionEnd={handleTransitionEnd}
200
+ ref={ref}
201
+ >
202
+ {sliders.map((item: any, itemIndex: number) => (
203
+ <Div className={'flex-col w-full shrink-0'} key={itemIndex}>
204
+ {item}
205
+ </Div>
206
+ ))}
207
+ </div>
208
+ </div>
209
+ )}
210
+ {navigation && !limit ? (
211
+ <Button ariaLabel={'nextNavigation'} startAdornment={<ArrowIcon/>} color={navigationColor} disabled={direction === 'rtl' ? currentIndex === 0 : currentIndex === length - showSlides} onClick={direction === 'rtl' ? prev : next} rounded={'full'} shape={'square'} className={'absolute flex self-center items-center justify-center right-2'}/>
212
+ ) : null}
213
+ {nextNavigation && currentIndex < length ? (
214
+ <>
215
+ {nextNavigation(next)}
216
+ </>
217
+ ) : null}
218
+ </Div>
219
+ {indicator && !limit ? (
220
+ <Div className={'self-center items-center justify-center'}>
221
+ {children.length > 1 ? (
222
+ <div className={`flex w-[96px] justify-start gap-x-1 mt-20 pr-11 overflow-hidden ${indicatorClassName}`}>
223
+ {[...new Array(length - showSlides + 1)].map((_: any, idx: number) => {
224
+ return (
225
+ <Div
226
+ style={{
227
+ transform: `translateX(${dir}${currentIndex * (130)}%)`,
228
+ transition: !transitionEnabled ? 'none' : undefined,
229
+ }}
230
+ key={idx}
231
+ className={classNames(
232
+ 'w-4 h-4 min-h-4 min-w-4 rounded-full mb-0 transition-all duration-500 justify-center items-center',
233
+ currentIndex === idx ? `bg-${indicatorActiveColor}` : 'bg-transparent',
234
+ )}
235
+ onClick={() => {
236
+ setCurrentIndex(idx);
237
+ }}
238
+ >
239
+ <Div className={classNames(
240
+ currentIndex === idx ? `bg-${indicatorActiveColor}` : 'bg-grey-100',
241
+ `rounded-full transition-all duration-500 justify-center items-center`,
242
+ BulletWidth(Math.abs(4 - Math.abs(currentIndex - idx))),
243
+ )}
244
+ />
245
+ </Div>
246
+ );
247
+ })}
248
+ </div>
249
+ ) : null}
250
+ </Div>
251
+ ) : null}
252
+ </Div>
253
+ );
254
+ };
255
+
256
+ const ArrowIcon = ({ className }: { className?: string }) => {
257
+ return (
258
+ <svg
259
+ xmlns="http://www.w3.org/2000/svg"
260
+ width="256"
261
+ height="256"
262
+ viewBox="0 0 256 256"
263
+ fill={'currentColor'}
264
+ className={`h-3 w-3 ${className}`}
265
+ >
266
+ <path
267
+ fill={'currentColor'}
268
+ strokeMiterlimit="10"
269
+ strokeWidth="0"
270
+ d="M24.64 90L20.36 85.72 61.08 45 20.36 4.28 24.64 0 69.64 45z"
271
+ transform="matrix(2.81 0 0 2.81 1.407 1.407)"
272
+ />
273
+ </svg>
274
+ );
275
+ };
276
+
277
+ export default Slider;
278
+
279
+ const BulletWidth = (w: any) => {
280
+ switch (w) {
281
+ case 4:
282
+ return '!w-4 !h-4 !min-w-4 !min-h-4';
283
+ case 3:
284
+ return '!w-3 !h-3 !min-w-3 !min-h-3';
285
+ case 2:
286
+ return '!w-2 !h-2 !min-w-2 !min-h-2';
287
+ default:
288
+ return 'w-0 h-0';
289
+ }
290
+ };
@@ -0,0 +1,25 @@
1
+ import { useState } from 'react';
2
+ import { Meta, StoryObj } from '@storybook/react';
3
+ import { Calendar } from './calendar';
4
+
5
+ const meta: Meta<typeof Calendar> = {
6
+ title: 'Calendar',
7
+ component: Calendar,
8
+ argTypes: {
9
+ },
10
+ };
11
+
12
+ export default meta;
13
+ type Story = StoryObj<typeof Calendar>;
14
+
15
+ export const Default: Story = {
16
+ render: (args) => {
17
+ const [selectedDate, setSelectedDate] = useState<string>('');
18
+
19
+ const handleChange = (e: any) => {
20
+ setSelectedDate(e.jalaliDate);
21
+ };
22
+
23
+ return <Calendar {...args} selected={selectedDate} onChange={handleChange} />;
24
+ },
25
+ };
@@ -0,0 +1,11 @@
1
+ import CustomCalendar from '../../calendar';
2
+ import { CalendarProps } from '../../calendar/calendar.props';
3
+
4
+ /**
5
+ * Primary UI component for user interaction
6
+ */
7
+ export const Calendar = ({ ...props }: CalendarProps) => {
8
+ return (
9
+ <CustomCalendar {...props}/>
10
+ );
11
+ };
@@ -0,0 +1,19 @@
1
+ import { CountDown } from './count-down';
2
+ import { Meta, StoryObj } from '@storybook/react';
3
+
4
+ const meta: Meta<typeof CountDown> = {
5
+ title: 'CountDownTimer',
6
+ component: CountDown,
7
+ argTypes: {
8
+ },
9
+ };
10
+
11
+ export default meta;
12
+ type Story = StoryObj<typeof CountDown>;
13
+
14
+ export const Default: Story = {
15
+ render: (args) => {
16
+ return <CountDown {...args} />;
17
+ },
18
+ };
19
+
@@ -0,0 +1,11 @@
1
+ import CustomCountDown from '../../countdown-timer';
2
+ import { CountdownProps } from '../../countdown-timer/countdown.props';
3
+
4
+ /**
5
+ * Primary UI component for user interaction
6
+ */
7
+ export const CountDown = ({ ...props }: CountdownProps) => {
8
+ return (
9
+ <CustomCountDown {...props} />
10
+ );
11
+ };
@@ -0,0 +1,70 @@
1
+ import { ColumnDef } from '@tanstack/react-table';
2
+ import { Chip, Text } from '@pezeshk-book/ui-kit';
3
+
4
+ export const header = {
5
+ id: 'ID',
6
+ category_id: 'categoryId',
7
+ title: 'Title',
8
+ code: 'Code',
9
+ environment: 'Environment',
10
+ type: 'Type',
11
+ status: 'Status',
12
+ created_at: 'CreatedAt',
13
+ };
14
+
15
+ export const columns: ColumnDef<any>[] = [
16
+ {
17
+ id: 'id',
18
+ accessorKey: 'id',
19
+ header: header.id,
20
+ cell: info => <Text typography={'sm'}>{info.row.original.id || '-'}</Text>,
21
+ },
22
+ {
23
+ id: 'category_id',
24
+ accessorKey: 'category_id',
25
+ header: header.category_id,
26
+ cell: info => <Text typography={'sm'}>{info.row.original.category_id || '-'}</Text>,
27
+ },
28
+ {
29
+ id: 'title',
30
+ accessorKey: 'title',
31
+ header: header.title,
32
+ cell: info => <Text typography={'sm'}>{info.row.original.title || '-'}</Text>,
33
+ },
34
+ {
35
+ id: 'code',
36
+ accessorKey: 'code',
37
+ header: header.code,
38
+ cell: info => <Text typography={'sm'}>{info.row.original.code || '-'}</Text>,
39
+ },
40
+ {
41
+ id: 'environment',
42
+ accessorKey: 'environment',
43
+ header: header.environment,
44
+ cell: info => {
45
+ return <Text typography={'sm'} >{info.row.original.environment || '-'}</Text>;
46
+ },
47
+ },
48
+ {
49
+ id: 'type',
50
+ accessorKey: 'type',
51
+ header: header.type,
52
+ cell: info => {
53
+ return <Chip size={'small'} variant={'reverse'} color={info.row.original.type === 'Hardware' ? 'info' : 'secondary'} value={info.row.original.type}/>;
54
+ },
55
+ },
56
+ {
57
+ id: 'status',
58
+ accessorKey: 'status',
59
+ header: header.status,
60
+ cell: info => {
61
+ return <Chip size={'small'} variant={'reverse'} color={info.row.original.status === 'Active' ? 'green' : 'red'} value={info.row.original.status}/>;
62
+ },
63
+ },
64
+ {
65
+ id: 'created_at',
66
+ accessorKey: 'created_at',
67
+ header: header.created_at,
68
+ cell: info => <Text typography={'sm'}>{info.row.original.created_at}</Text>,
69
+ },
70
+ ];
@@ -0,0 +1,22 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { DefaultDataTableProps } from '../../data-table/default/default-data-table.props';
3
+ import { DefaultDataTable } from './default-data-table';
4
+
5
+ const meta: Meta<typeof DefaultDataTable> = {
6
+ title: 'DataTable',
7
+ component: DefaultDataTable,
8
+ argTypes: {
9
+ },
10
+ };
11
+
12
+ export default meta;
13
+ type Story = StoryObj<typeof DefaultDataTable>;
14
+
15
+ export const Default: Story = {
16
+ render: (args : { variant: 'default' } & DefaultDataTableProps) => {
17
+ return <DefaultDataTable {...args} />;
18
+ },
19
+ args: {
20
+ variant: 'default',
21
+ },
22
+ };
@@ -0,0 +1,18 @@
1
+ import CustomDataTable from '../../data-table';
2
+ import dummyData from './dummy-data';
3
+ import { columns, header } from './data-table-columns';
4
+ import { DefaultDataTableProps } from '../../data-table/default/default-data-table.props';
5
+
6
+ /**
7
+ * Primary UI component for user interaction
8
+ */
9
+ export const DefaultDataTable = (props: { variant: 'default' } & DefaultDataTableProps) => {
10
+ return (
11
+ <CustomDataTable
12
+ {...props}
13
+ data={dummyData}
14
+ header={header}
15
+ column={columns}
16
+ />
17
+ );
18
+ };
@@ -0,0 +1,204 @@
1
+ const dummyData = [
2
+ {
3
+ id: 1,
4
+ category_id: 101,
5
+ title: 'Item One',
6
+ code: 'X123A',
7
+ environment: 'Production',
8
+ type: 'Hardware',
9
+ status: 'Active',
10
+ created_at: '2024-02-01T10:15:30Z',
11
+ },
12
+ {
13
+ id: 2,
14
+ category_id: 102,
15
+ title: 'Item Two',
16
+ code: 'Y456B',
17
+ environment: 'Staging',
18
+ type: 'Software',
19
+ status: 'Inactive',
20
+ created_at: '2024-01-25T09:00:00Z',
21
+ },
22
+ {
23
+ id: 3,
24
+ category_id: 103,
25
+ title: 'Item Three',
26
+ code: 'Z789C',
27
+ environment: 'Development',
28
+ type: 'Network',
29
+ status: 'Pending',
30
+ created_at: '2024-02-10T14:30:15Z',
31
+ },
32
+ {
33
+ id: 4,
34
+ category_id: 101,
35
+ title: 'Item Four',
36
+ code: 'A111D',
37
+ environment: 'Production',
38
+ type: 'Hardware',
39
+ status: 'Active',
40
+ created_at: '2024-02-12T12:45:00Z',
41
+ },
42
+ {
43
+ id: 5,
44
+ category_id: 102,
45
+ title: 'Item Five',
46
+ code: 'B222E',
47
+ environment: 'Staging',
48
+ type: 'Software',
49
+ status: 'Inactive',
50
+ created_at: '2024-02-15T08:20:45Z',
51
+ },
52
+ {
53
+ id: 6,
54
+ category_id: 103,
55
+ title: 'Item Six',
56
+ code: 'C333F',
57
+ environment: 'Development',
58
+ type: 'Network',
59
+ status: 'Pending',
60
+ created_at: '2024-02-18T16:10:30Z',
61
+ },
62
+ {
63
+ id: 7,
64
+ category_id: 104,
65
+ title: 'Item Seven',
66
+ code: 'D444G',
67
+ environment: 'Production',
68
+ type: 'Hardware',
69
+ status: 'Active',
70
+ created_at: '2024-02-20T11:05:00Z',
71
+ },
72
+ {
73
+ id: 8,
74
+ category_id: 105,
75
+ title: 'Item Eight',
76
+ code: 'E555H',
77
+ environment: 'Staging',
78
+ type: 'Software',
79
+ status: 'Inactive',
80
+ created_at: '2024-02-22T14:50:25Z',
81
+ },
82
+ {
83
+ id: 9,
84
+ category_id: 106,
85
+ title: 'Item Nine',
86
+ code: 'F666I',
87
+ environment: 'Development',
88
+ type: 'Network',
89
+ status: 'Pending',
90
+ created_at: '2024-02-24T09:30:15Z',
91
+ },
92
+ {
93
+ id: 10,
94
+ category_id: 107,
95
+ title: 'Item Ten',
96
+ code: 'G777J',
97
+ environment: 'Production',
98
+ type: 'Hardware',
99
+ status: 'Active',
100
+ created_at: '2024-02-26T13:25:45Z',
101
+ },
102
+ {
103
+ id: 11,
104
+ category_id: 108,
105
+ title: 'Item Eleven',
106
+ code: 'H888K',
107
+ environment: 'Staging',
108
+ type: 'Software',
109
+ status: 'Inactive',
110
+ created_at: '2024-02-28T10:40:30Z',
111
+ },
112
+ {
113
+ id: 12,
114
+ category_id: 109,
115
+ title: 'Item Twelve',
116
+ code: 'I999L',
117
+ environment: 'Development',
118
+ type: 'Network',
119
+ status: 'Pending',
120
+ created_at: '2024-03-01T15:55:00Z',
121
+ },
122
+ {
123
+ id: 13,
124
+ category_id: 110,
125
+ title: 'Item Thirteen',
126
+ code: 'J000M',
127
+ environment: 'Production',
128
+ type: 'Hardware',
129
+ status: 'Active',
130
+ created_at: '2024-03-03T08:10:45Z',
131
+ },
132
+ {
133
+ id: 14,
134
+ category_id: 111,
135
+ title: 'Item Fourteen',
136
+ code: 'K111N',
137
+ environment: 'Staging',
138
+ type: 'Software',
139
+ status: 'Inactive',
140
+ created_at: '2024-03-05T12:20:30Z',
141
+ },
142
+ {
143
+ id: 15,
144
+ category_id: 112,
145
+ title: 'Item Fifteen',
146
+ code: 'L222O',
147
+ environment: 'Development',
148
+ type: 'Network',
149
+ status: 'Pending',
150
+ created_at: '2024-03-07T14:45:15Z',
151
+ },
152
+ {
153
+ id: 16,
154
+ category_id: 113,
155
+ title: 'Item Sixteen',
156
+ code: 'M333P',
157
+ environment: 'Production',
158
+ type: 'Hardware',
159
+ status: 'Active',
160
+ created_at: '2024-03-09T09:30:00Z',
161
+ },
162
+ {
163
+ id: 17,
164
+ category_id: 114,
165
+ title: 'Item Seventeen',
166
+ code: 'N444Q',
167
+ environment: 'Staging',
168
+ type: 'Software',
169
+ status: 'Inactive',
170
+ created_at: '2024-03-11T11:50:45Z',
171
+ },
172
+ {
173
+ id: 18,
174
+ category_id: 115,
175
+ title: 'Item Eighteen',
176
+ code: 'O555R',
177
+ environment: 'Development',
178
+ type: 'Network',
179
+ status: 'Pending',
180
+ created_at: '2024-03-13T16:40:30Z',
181
+ },
182
+ {
183
+ id: 19,
184
+ category_id: 116,
185
+ title: 'Item Nineteen',
186
+ code: 'P666S',
187
+ environment: 'Production',
188
+ type: 'Hardware',
189
+ status: 'Active',
190
+ created_at: '2024-03-15T10:05:15Z',
191
+ },
192
+ {
193
+ id: 20,
194
+ category_id: 117,
195
+ title: 'Item Twenty',
196
+ code: 'Q777T',
197
+ environment: 'Staging',
198
+ type: 'Software',
199
+ status: 'Inactive',
200
+ created_at: '2024-03-17T14:15:00Z',
201
+ },
202
+ ];
203
+
204
+ export default dummyData;
@@ -0,0 +1,22 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { SimpleDataTable } from './simple-data-table';
3
+ import { SimpleDataTableProps } from '../../data-table/simple/simple-data-table.props';
4
+
5
+ const meta: Meta<typeof SimpleDataTable> = {
6
+ title: 'DataTable',
7
+ component: SimpleDataTable,
8
+ argTypes: {
9
+ },
10
+ };
11
+
12
+ export default meta;
13
+ type Story = StoryObj<typeof SimpleDataTable>;
14
+
15
+ export const Simple: Story = {
16
+ render: (args : {variant: 'simple'} & SimpleDataTableProps) => {
17
+ return <SimpleDataTable {...args} />;
18
+ },
19
+ args: {
20
+ variant: 'simple',
21
+ },
22
+ };