@pezeshk-book/modules 0.2.7 → 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.
Files changed (346) hide show
  1. package/calendar/calendar.js +95 -0
  2. package/calendar/calendar.js.map +1 -0
  3. package/calendar/calendar.props.js +3 -0
  4. package/{dist/calendar → calendar}/config/chunk.js +5 -1
  5. package/calendar/config/chunk.js.map +1 -0
  6. package/calendar/config/create-date-range.js +17 -0
  7. package/calendar/config/create-date-range.js.map +1 -0
  8. package/calendar/config/days-in-month.en.js +36 -0
  9. package/calendar/config/days-in-month.en.js.map +1 -0
  10. package/calendar/config/days-in-month.fa.js +36 -0
  11. package/calendar/config/days-in-month.fa.js.map +1 -0
  12. package/calendar/config/index.js +13 -0
  13. package/calendar/config/index.js.map +1 -0
  14. package/{dist/calendar → calendar}/config/months.js +5 -2
  15. package/calendar/config/months.js.map +1 -0
  16. package/{dist/calendar → calendar}/config/week-day.js +6 -2
  17. package/calendar/config/week-day.js.map +1 -0
  18. package/calendar/icons/arrow-left-icon.js +9 -0
  19. package/calendar/icons/arrow-left-icon.js.map +1 -0
  20. package/calendar/icons/arrow-right-icon.js +9 -0
  21. package/calendar/icons/arrow-right-icon.js.map +1 -0
  22. package/calendar/icons/index.js +9 -0
  23. package/calendar/icons/index.js.map +1 -0
  24. package/calendar/index.js +6 -0
  25. package/calendar/index.js.map +1 -0
  26. package/calendar/shared/formatDate.js +17 -0
  27. package/calendar/shared/formatDate.js.map +1 -0
  28. package/calendar/sub-components/day/day.js +18 -0
  29. package/calendar/sub-components/day/day.js.map +1 -0
  30. package/calendar/sub-components/day/day.props.js +3 -0
  31. package/{dist/calendar → calendar}/sub-components/days/days.js +19 -17
  32. package/calendar/sub-components/days/days.js.map +1 -0
  33. package/calendar/sub-components/days/days.props.js +3 -0
  34. package/calendar/sub-components/days-head/days-head.js +45 -0
  35. package/calendar/sub-components/days-head/days-head.js.map +1 -0
  36. package/calendar/sub-components/days-head/days-head.props.js +3 -0
  37. package/countdown-timer/countdown.js +58 -0
  38. package/countdown-timer/countdown.js.map +1 -0
  39. package/countdown-timer/countdown.props.js +3 -0
  40. package/countdown-timer/index.js +6 -0
  41. package/countdown-timer/index.js.map +1 -0
  42. package/data-table/data-table.js +15 -0
  43. package/data-table/data-table.js.map +1 -0
  44. package/data-table/data-table.props.js +3 -0
  45. package/data-table/default/default-data-table.js +169 -0
  46. package/data-table/default/default-data-table.js.map +1 -0
  47. package/data-table/default/default-data-table.props.js +3 -0
  48. package/data-table/default/index.js +6 -0
  49. package/data-table/default/index.js.map +1 -0
  50. package/{dist/data-table → data-table}/hooks/use-window-dimensions.js +9 -7
  51. package/data-table/hooks/use-window-dimensions.js.map +1 -0
  52. package/data-table/icons/add.js +10 -0
  53. package/data-table/icons/add.js.map +1 -0
  54. package/data-table/icons/arrow-down.js +10 -0
  55. package/data-table/icons/arrow-down.js.map +1 -0
  56. package/data-table/icons/index.js +11 -0
  57. package/data-table/icons/index.js.map +1 -0
  58. package/data-table/icons/sort.js +10 -0
  59. package/data-table/icons/sort.js.map +1 -0
  60. package/data-table/index.js +6 -0
  61. package/data-table/index.js.map +1 -0
  62. package/data-table/simple/index.js +6 -0
  63. package/data-table/simple/index.js.map +1 -0
  64. package/data-table/simple/simple-data-table.js +118 -0
  65. package/data-table/simple/simple-data-table.js.map +1 -0
  66. package/data-table/simple/simple-data-table.props.js +3 -0
  67. package/index.js +15 -0
  68. package/index.js.map +1 -0
  69. package/package.json +1 -1
  70. package/pagination/icons/arrow-Right.js +10 -0
  71. package/pagination/icons/arrow-Right.js.map +1 -0
  72. package/pagination/icons/arrow-left.js +10 -0
  73. package/pagination/icons/arrow-left.js.map +1 -0
  74. package/pagination/icons/index.js +9 -0
  75. package/pagination/icons/index.js.map +1 -0
  76. package/pagination/index.js +6 -0
  77. package/pagination/index.js.map +1 -0
  78. package/pagination/pagination.js +55 -0
  79. package/pagination/pagination.js.map +1 -0
  80. package/pagination/pagination.props.js +3 -0
  81. package/{dist/pagination → pagination}/use-pagination.js +3 -1
  82. package/pagination/use-pagination.js.map +1 -0
  83. package/slider/index.js +6 -0
  84. package/slider/index.js.map +1 -0
  85. package/{dist/slider → slider}/slider.js +31 -29
  86. package/slider/slider.js.map +1 -0
  87. package/slider/slider.props.js +3 -0
  88. package/{dist/utils → utils}/class-names.js +3 -1
  89. package/utils/class-names.js.map +1 -0
  90. package/utils/persian-to-english-number.js +9 -0
  91. package/utils/persian-to-english-number.js.map +1 -0
  92. package/.eslintrc.json +0 -133
  93. package/calendar/calendar.props.ts +0 -25
  94. package/calendar/calendar.tsx +0 -185
  95. package/calendar/config/chunk.ts +0 -42
  96. package/calendar/config/create-date-range.ts +0 -14
  97. package/calendar/config/days-in-month.en.ts +0 -47
  98. package/calendar/config/days-in-month.fa.ts +0 -37
  99. package/calendar/config/index.ts +0 -16
  100. package/calendar/config/months.ts +0 -29
  101. package/calendar/config/week-day.ts +0 -19
  102. package/calendar/icons/arrow-left-icon.tsx +0 -14
  103. package/calendar/icons/arrow-right-icon.tsx +0 -14
  104. package/calendar/icons/index.ts +0 -7
  105. package/calendar/index.ts +0 -3
  106. package/calendar/shared/formatDate.tsx +0 -12
  107. package/calendar/sub-components/day/day.props.ts +0 -27
  108. package/calendar/sub-components/day/day.tsx +0 -31
  109. package/calendar/sub-components/days/days.props.ts +0 -51
  110. package/calendar/sub-components/days/days.tsx +0 -142
  111. package/calendar/sub-components/days-head/days-head.props.ts +0 -27
  112. package/calendar/sub-components/days-head/days-head.tsx +0 -122
  113. package/countdown-timer/countdown.props.ts +0 -18
  114. package/countdown-timer/countdown.tsx +0 -79
  115. package/countdown-timer/index.ts +0 -3
  116. package/data-table/data-table.props.ts +0 -7
  117. package/data-table/data-table.tsx +0 -17
  118. package/data-table/default/default-data-table.props.ts +0 -47
  119. package/data-table/default/default-data-table.tsx +0 -427
  120. package/data-table/default/index.ts +0 -3
  121. package/data-table/hooks/use-window-dimensions.tsx +0 -33
  122. package/data-table/icons/add.tsx +0 -10
  123. package/data-table/icons/arrow-down.tsx +0 -11
  124. package/data-table/icons/index.ts +0 -9
  125. package/data-table/icons/sort.tsx +0 -16
  126. package/data-table/index.ts +0 -3
  127. package/data-table/simple/index.ts +0 -3
  128. package/data-table/simple/simple-data-table.props.ts +0 -23
  129. package/data-table/simple/simple-data-table.tsx +0 -258
  130. package/dist/calendar/calendar.js +0 -93
  131. package/dist/calendar/calendar.js.map +0 -1
  132. package/dist/calendar/calendar.props.js +0 -2
  133. package/dist/calendar/config/chunk.js.map +0 -1
  134. package/dist/calendar/config/create-date-range.js +0 -14
  135. package/dist/calendar/config/create-date-range.js.map +0 -1
  136. package/dist/calendar/config/days-in-month.en.js +0 -32
  137. package/dist/calendar/config/days-in-month.en.js.map +0 -1
  138. package/dist/calendar/config/days-in-month.fa.js +0 -32
  139. package/dist/calendar/config/days-in-month.fa.js.map +0 -1
  140. package/dist/calendar/config/index.js +0 -6
  141. package/dist/calendar/config/index.js.map +0 -1
  142. package/dist/calendar/config/months.js.map +0 -1
  143. package/dist/calendar/config/week-day.js.map +0 -1
  144. package/dist/calendar/icons/arrow-left-icon.js +0 -7
  145. package/dist/calendar/icons/arrow-left-icon.js.map +0 -1
  146. package/dist/calendar/icons/arrow-right-icon.js +0 -7
  147. package/dist/calendar/icons/arrow-right-icon.js.map +0 -1
  148. package/dist/calendar/icons/index.js +0 -4
  149. package/dist/calendar/icons/index.js.map +0 -1
  150. package/dist/calendar/index.js +0 -3
  151. package/dist/calendar/index.js.map +0 -1
  152. package/dist/calendar/shared/formatDate.js +0 -13
  153. package/dist/calendar/shared/formatDate.js.map +0 -1
  154. package/dist/calendar/sub-components/day/day.js +0 -14
  155. package/dist/calendar/sub-components/day/day.js.map +0 -1
  156. package/dist/calendar/sub-components/day/day.props.js +0 -2
  157. package/dist/calendar/sub-components/days/days.js.map +0 -1
  158. package/dist/calendar/sub-components/days/days.props.js +0 -2
  159. package/dist/calendar/sub-components/days-head/days-head.js +0 -43
  160. package/dist/calendar/sub-components/days-head/days-head.js.map +0 -1
  161. package/dist/calendar/sub-components/days-head/days-head.props.js +0 -2
  162. package/dist/countdown-timer/countdown.js +0 -56
  163. package/dist/countdown-timer/countdown.js.map +0 -1
  164. package/dist/countdown-timer/countdown.props.js +0 -2
  165. package/dist/countdown-timer/index.js +0 -3
  166. package/dist/countdown-timer/index.js.map +0 -1
  167. package/dist/data-table/data-table.js +0 -13
  168. package/dist/data-table/data-table.js.map +0 -1
  169. package/dist/data-table/data-table.props.js +0 -2
  170. package/dist/data-table/default/default-data-table.js +0 -167
  171. package/dist/data-table/default/default-data-table.js.map +0 -1
  172. package/dist/data-table/default/default-data-table.props.js +0 -2
  173. package/dist/data-table/default/index.js +0 -3
  174. package/dist/data-table/default/index.js.map +0 -1
  175. package/dist/data-table/hooks/use-window-dimensions.js.map +0 -1
  176. package/dist/data-table/icons/add.js +0 -8
  177. package/dist/data-table/icons/add.js.map +0 -1
  178. package/dist/data-table/icons/arrow-down.js +0 -8
  179. package/dist/data-table/icons/arrow-down.js.map +0 -1
  180. package/dist/data-table/icons/index.js +0 -5
  181. package/dist/data-table/icons/index.js.map +0 -1
  182. package/dist/data-table/icons/sort.js +0 -8
  183. package/dist/data-table/icons/sort.js.map +0 -1
  184. package/dist/data-table/index.js +0 -3
  185. package/dist/data-table/index.js.map +0 -1
  186. package/dist/data-table/simple/index.js +0 -3
  187. package/dist/data-table/simple/index.js.map +0 -1
  188. package/dist/data-table/simple/simple-data-table.js +0 -116
  189. package/dist/data-table/simple/simple-data-table.js.map +0 -1
  190. package/dist/data-table/simple/simple-data-table.props.js +0 -2
  191. package/dist/index.js +0 -7
  192. package/dist/index.js.map +0 -1
  193. package/dist/pagination/icons/arrow-Right.js +0 -8
  194. package/dist/pagination/icons/arrow-Right.js.map +0 -1
  195. package/dist/pagination/icons/arrow-left.js +0 -8
  196. package/dist/pagination/icons/arrow-left.js.map +0 -1
  197. package/dist/pagination/icons/index.js +0 -4
  198. package/dist/pagination/icons/index.js.map +0 -1
  199. package/dist/pagination/index.js +0 -3
  200. package/dist/pagination/index.js.map +0 -1
  201. package/dist/pagination/pagination.js +0 -51
  202. package/dist/pagination/pagination.js.map +0 -1
  203. package/dist/pagination/pagination.props.js +0 -2
  204. package/dist/pagination/use-pagination.js.map +0 -1
  205. package/dist/slider/index.js +0 -3
  206. package/dist/slider/index.js.map +0 -1
  207. package/dist/slider/slider.js.map +0 -1
  208. package/dist/slider/slider.props.js +0 -2
  209. package/dist/stories/calendar/calendar.d.ts +0 -5
  210. package/dist/stories/calendar/calendar.js +0 -11
  211. package/dist/stories/calendar/calendar.js.map +0 -1
  212. package/dist/stories/calendar/calendar.stories.d.ts +0 -6
  213. package/dist/stories/calendar/calendar.stories.js +0 -20
  214. package/dist/stories/calendar/calendar.stories.js.map +0 -1
  215. package/dist/stories/count-down/count-down.d.ts +0 -5
  216. package/dist/stories/count-down/count-down.js +0 -11
  217. package/dist/stories/count-down/count-down.js.map +0 -1
  218. package/dist/stories/count-down/count-down.stories.d.ts +0 -6
  219. package/dist/stories/count-down/count-down.stories.js +0 -15
  220. package/dist/stories/count-down/count-down.stories.js.map +0 -1
  221. package/dist/stories/data-table/data-table-columns.d.ts +0 -12
  222. package/dist/stories/data-table/data-table-columns.js +0 -70
  223. package/dist/stories/data-table/data-table-columns.js.map +0 -1
  224. package/dist/stories/data-table/default-data-table.d.ts +0 -7
  225. package/dist/stories/data-table/default-data-table.js +0 -12
  226. package/dist/stories/data-table/default-data-table.js.map +0 -1
  227. package/dist/stories/data-table/default-data-table.stories.d.ts +0 -6
  228. package/dist/stories/data-table/default-data-table.stories.js +0 -18
  229. package/dist/stories/data-table/default-data-table.stories.js.map +0 -1
  230. package/dist/stories/data-table/dummy-data.d.ts +0 -11
  231. package/dist/stories/data-table/dummy-data.js +0 -204
  232. package/dist/stories/data-table/dummy-data.js.map +0 -1
  233. package/dist/stories/data-table/simple-data-table.d.ts +0 -7
  234. package/dist/stories/data-table/simple-data-table.js +0 -12
  235. package/dist/stories/data-table/simple-data-table.js.map +0 -1
  236. package/dist/stories/data-table/simple-data-table.stories.d.ts +0 -6
  237. package/dist/stories/data-table/simple-data-table.stories.js +0 -18
  238. package/dist/stories/data-table/simple-data-table.stories.js.map +0 -1
  239. package/dist/stories/pagination/pagination.d.ts +0 -5
  240. package/dist/stories/pagination/pagination.js +0 -11
  241. package/dist/stories/pagination/pagination.js.map +0 -1
  242. package/dist/stories/pagination/pagination.stories.d.ts +0 -6
  243. package/dist/stories/pagination/pagination.stories.js +0 -23
  244. package/dist/stories/pagination/pagination.stories.js.map +0 -1
  245. package/dist/stories/slider/slider.d.ts +0 -5
  246. package/dist/stories/slider/slider.js +0 -11
  247. package/dist/stories/slider/slider.js.map +0 -1
  248. package/dist/stories/slider/slider.stories.d.ts +0 -6
  249. package/dist/stories/slider/slider.stories.js +0 -15
  250. package/dist/stories/slider/slider.stories.js.map +0 -1
  251. package/dist/stories/wrapper.d.ts +0 -7
  252. package/dist/stories/wrapper.js +0 -8
  253. package/dist/stories/wrapper.js.map +0 -1
  254. package/dist/utils/class-names.js.map +0 -1
  255. package/dist/utils/persian-to-english-number.js +0 -5
  256. package/dist/utils/persian-to-english-number.js.map +0 -1
  257. package/index.ts +0 -13
  258. package/pagination/icons/arrow-Right.tsx +0 -22
  259. package/pagination/icons/arrow-left.tsx +0 -22
  260. package/pagination/icons/index.ts +0 -7
  261. package/pagination/index.ts +0 -3
  262. package/pagination/pagination.props.ts +0 -33
  263. package/pagination/pagination.tsx +0 -135
  264. package/pagination/use-pagination.ts +0 -49
  265. package/react-app-env.d.ts +0 -1
  266. package/slider/index.ts +0 -3
  267. package/slider/slider.props.ts +0 -39
  268. package/slider/slider.tsx +0 -292
  269. package/stories/calendar/calendar.stories.tsx +0 -25
  270. package/stories/calendar/calendar.tsx +0 -11
  271. package/stories/count-down/count-down.stories.tsx +0 -19
  272. package/stories/count-down/count-down.tsx +0 -11
  273. package/stories/data-table/data-table-columns.tsx +0 -70
  274. package/stories/data-table/default-data-table.stories.tsx +0 -22
  275. package/stories/data-table/default-data-table.tsx +0 -18
  276. package/stories/data-table/dummy-data.ts +0 -204
  277. package/stories/data-table/simple-data-table.stories.tsx +0 -22
  278. package/stories/data-table/simple-data-table.tsx +0 -18
  279. package/stories/pagination/pagination.stories.tsx +0 -35
  280. package/stories/pagination/pagination.tsx +0 -11
  281. package/stories/slider/slider.stories.tsx +0 -19
  282. package/stories/slider/slider.tsx +0 -45
  283. package/stories/wrapper.tsx +0 -11
  284. package/styles.css +0 -28
  285. package/utils/class-names.ts +0 -5
  286. package/utils/persian-to-english-number.ts +0 -4
  287. /package/{dist/calendar → calendar}/calendar.d.ts +0 -0
  288. /package/{dist/calendar → calendar}/calendar.props.d.ts +0 -0
  289. /package/{dist/calendar → calendar}/calendar.props.js.map +0 -0
  290. /package/{dist/calendar → calendar}/config/chunk.d.ts +0 -0
  291. /package/{dist/calendar → calendar}/config/create-date-range.d.ts +0 -0
  292. /package/{dist/calendar → calendar}/config/days-in-month.en.d.ts +0 -0
  293. /package/{dist/calendar → calendar}/config/days-in-month.fa.d.ts +0 -0
  294. /package/{dist/calendar → calendar}/config/index.d.ts +0 -0
  295. /package/{dist/calendar → calendar}/config/months.d.ts +0 -0
  296. /package/{dist/calendar → calendar}/config/week-day.d.ts +0 -0
  297. /package/{dist/calendar → calendar}/icons/arrow-left-icon.d.ts +0 -0
  298. /package/{dist/calendar → calendar}/icons/arrow-right-icon.d.ts +0 -0
  299. /package/{dist/calendar → calendar}/icons/index.d.ts +0 -0
  300. /package/{dist/calendar → calendar}/index.d.ts +0 -0
  301. /package/{dist/calendar → calendar}/shared/formatDate.d.ts +0 -0
  302. /package/{dist/calendar → calendar}/sub-components/day/day.d.ts +0 -0
  303. /package/{dist/calendar → calendar}/sub-components/day/day.props.d.ts +0 -0
  304. /package/{dist/calendar → calendar}/sub-components/day/day.props.js.map +0 -0
  305. /package/{dist/calendar → calendar}/sub-components/days/days.d.ts +0 -0
  306. /package/{dist/calendar → calendar}/sub-components/days/days.props.d.ts +0 -0
  307. /package/{dist/calendar → calendar}/sub-components/days/days.props.js.map +0 -0
  308. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.d.ts +0 -0
  309. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.d.ts +0 -0
  310. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.js.map +0 -0
  311. /package/{dist/countdown-timer → countdown-timer}/countdown.d.ts +0 -0
  312. /package/{dist/countdown-timer → countdown-timer}/countdown.props.d.ts +0 -0
  313. /package/{dist/countdown-timer → countdown-timer}/countdown.props.js.map +0 -0
  314. /package/{dist/countdown-timer → countdown-timer}/index.d.ts +0 -0
  315. /package/{dist/data-table → data-table}/data-table.d.ts +0 -0
  316. /package/{dist/data-table → data-table}/data-table.props.d.ts +0 -0
  317. /package/{dist/data-table → data-table}/data-table.props.js.map +0 -0
  318. /package/{dist/data-table → data-table}/default/default-data-table.d.ts +0 -0
  319. /package/{dist/data-table → data-table}/default/default-data-table.props.d.ts +0 -0
  320. /package/{dist/data-table → data-table}/default/default-data-table.props.js.map +0 -0
  321. /package/{dist/data-table → data-table}/default/index.d.ts +0 -0
  322. /package/{dist/data-table → data-table}/hooks/use-window-dimensions.d.ts +0 -0
  323. /package/{dist/data-table → data-table}/icons/add.d.ts +0 -0
  324. /package/{dist/data-table → data-table}/icons/arrow-down.d.ts +0 -0
  325. /package/{dist/data-table → data-table}/icons/index.d.ts +0 -0
  326. /package/{dist/data-table → data-table}/icons/sort.d.ts +0 -0
  327. /package/{dist/data-table → data-table}/index.d.ts +0 -0
  328. /package/{dist/data-table → data-table}/simple/index.d.ts +0 -0
  329. /package/{dist/data-table → data-table}/simple/simple-data-table.d.ts +0 -0
  330. /package/{dist/data-table → data-table}/simple/simple-data-table.props.d.ts +0 -0
  331. /package/{dist/data-table → data-table}/simple/simple-data-table.props.js.map +0 -0
  332. /package/{dist/index.d.ts → index.d.ts} +0 -0
  333. /package/{dist/pagination → pagination}/icons/arrow-Right.d.ts +0 -0
  334. /package/{dist/pagination → pagination}/icons/arrow-left.d.ts +0 -0
  335. /package/{dist/pagination → pagination}/icons/index.d.ts +0 -0
  336. /package/{dist/pagination → pagination}/index.d.ts +0 -0
  337. /package/{dist/pagination → pagination}/pagination.d.ts +0 -0
  338. /package/{dist/pagination → pagination}/pagination.props.d.ts +0 -0
  339. /package/{dist/pagination → pagination}/pagination.props.js.map +0 -0
  340. /package/{dist/pagination → pagination}/use-pagination.d.ts +0 -0
  341. /package/{dist/slider → slider}/index.d.ts +0 -0
  342. /package/{dist/slider → slider}/slider.d.ts +0 -0
  343. /package/{dist/slider → slider}/slider.props.d.ts +0 -0
  344. /package/{dist/slider → slider}/slider.props.js.map +0 -0
  345. /package/{dist/utils → utils}/class-names.d.ts +0 -0
  346. /package/{dist/utils → utils}/persian-to-english-number.d.ts +0 -0
@@ -1,185 +0,0 @@
1
- 'use client';
2
-
3
- import React, { useEffect, useState } from 'react';
4
- import Days from './sub-components/days/days';
5
- import { daysInMonthEn, daysInMonthFa, IDays } from './config';
6
- import { CalendarProps } from './calendar.props';
7
- import formatDate from './shared/formatDate';
8
- import { Div } from '@pezeshk-book/ui-kit';
9
- import DateObject from 'react-date-object';
10
- import persian from 'react-date-object/calendars/persian';
11
- import persianFa from 'react-date-object/locales/persian_fa';
12
- import createDateRange from './config/create-date-range';
13
-
14
- interface IState {
15
- value: any
16
- initialValue?: any
17
- cloneDays: any
18
- monthName: string
19
- month: number | string
20
- year: string
21
- days: IDays[]
22
- }
23
-
24
- const Calender = (props: CalendarProps) => {
25
- const {
26
- dateFormat = 'YYYY-MM-DD',
27
- selectedDate = new Date(),
28
- disablePreviousMonths = false,
29
- disableSubsequentMonths = false,
30
- disablePreviousDays = false,
31
- disableSubsequentDays = false,
32
- selected,
33
- onChange,
34
- type = 'jalali',
35
- holidays,
36
- variant = 'simple',
37
- size = 'medium',
38
- } = props;
39
-
40
- const date = new DateObject({ date: selectedDate });
41
- const [datepicker, setDatepicker] = useState<IState>({
42
- value: formatDate(selectedDate, dateFormat, type),
43
- cloneDays: date,
44
- monthName: '',
45
- month: '',
46
- year: '',
47
- days: [],
48
- });
49
- const [dateRangePicker, setDateRangePicker] = useState<{start: any, end: any}>({
50
- start: null,
51
- end: null,
52
- });
53
- const [rangeDates, setRangeDates] = useState<Array<string>>([]);
54
- const [holidayList, setHolidayList] = useState<Array<string>>();
55
-
56
- useEffect(() => {
57
- const { monthName, month, days, year } = type === 'gregorian' ? daysInMonthEn(datepicker.cloneDays, dateFormat) : daysInMonthFa(datepicker.cloneDays, dateFormat);
58
- setDatepicker({
59
- ...datepicker,
60
- year: year,
61
- monthName: monthName,
62
- month: month,
63
- days: days,
64
- initialValue: null,
65
- });
66
- }, [type]);
67
-
68
- useEffect(() => {
69
- if (holidays && holidays.length) {
70
- const holidaysFormatList = holidays.map((item) => new DateObject(item).format(dateFormat));
71
- setHolidayList(holidaysFormatList);
72
- }
73
- }, [holidays, dateFormat]);
74
-
75
- const changeMonths = (amount: number, changeType: 'inc' | 'select'): void => {
76
- setDatepicker(prevState => {
77
- const updatedCloneDays = changeType === 'inc' ? prevState.cloneDays.add(amount, 'month') : prevState.cloneDays.setMonth(amount);
78
- const { monthName, month, days, year } = type === 'gregorian' ? daysInMonthEn(updatedCloneDays, dateFormat) : daysInMonthFa(updatedCloneDays, dateFormat);
79
-
80
- return {
81
- ...prevState,
82
- year,
83
- monthName,
84
- month,
85
- days,
86
- cloneDays: updatedCloneDays,
87
- };
88
- });
89
- };
90
-
91
- const changeYear = (selectedYear: string): void => {
92
- setDatepicker(prevState => {
93
- const updatedCloneDays = prevState.cloneDays.setYear(parseInt(selectedYear));
94
- const { monthName, month, days, year } = type === 'gregorian' ? daysInMonthEn(updatedCloneDays, dateFormat) : daysInMonthFa(updatedCloneDays, dateFormat);
95
-
96
- return {
97
- ...prevState,
98
- year,
99
- monthName,
100
- month,
101
- days,
102
- cloneDays: updatedCloneDays,
103
- };
104
- });
105
- };
106
-
107
- const selectDay = (e: React.SyntheticEvent<EventTarget>) => {
108
- const faDate = (e.target as HTMLHtmlElement).dataset.jalaliDate;
109
- setDatepicker({
110
- ...datepicker,
111
- value: faDate,
112
- });
113
- };
114
-
115
- const daysEventListeners = () => {
116
- return {
117
- onClick: selectDay,
118
- };
119
- };
120
-
121
- const selectDateHandler = (day: any): void => {
122
- const clickedDate = new DateObject({ date: day.gregorianDate, calendar: persian, locale: persianFa });
123
- const jalaliDate = new DateObject({ date: day.jalaliDate, calendar: persian }).format(dateFormat);
124
- const gregorianDate = new DateObject({ date: day.gregorianDate }).format(dateFormat);
125
- onChange({ calendarDate: clickedDate, gregorianDate, jalaliDate });
126
- };
127
-
128
- const selectDateRangeHandler = ({ start, end } : {start: any, end: any}): void => {
129
- setDateRangePicker({ start: start, end: end });
130
-
131
- const clickedStartDate = new DateObject({ date: start?.gregorianDate, calendar: persian, locale: persianFa });
132
- const jalaliStartDate = new DateObject({ date: start?.jalaliDate, calendar: persian }).format(dateFormat);
133
- const gregorianStartDate = new DateObject({ date: start?.gregorianDate }).format(dateFormat);
134
-
135
- const clickedEndDate = new DateObject({ date: end?.gregorianDate, calendar: persian, locale: persianFa });
136
- const jalaliEndDate = new DateObject({ date: end?.jalaliDate, calendar: persian }).format(dateFormat);
137
- const gregorianEndDate = new DateObject({ date: end?.gregorianDate }).format(dateFormat);
138
-
139
- onChange({
140
- start: start ? { calendarDate: clickedStartDate, gregorianStartDate, jalaliStartDate } : null,
141
- end: end ? { calendarDate: clickedEndDate, gregorianEndDate, jalaliEndDate } : null,
142
- });
143
-
144
- if (start && end) {
145
- const range = createDateRange({ startDate: start.gregorianDate, stopDate: end.gregorianDate });
146
- setRangeDates(range);
147
- } else {
148
- setRangeDates([]);
149
- }
150
- };
151
-
152
- return (
153
- <Div dir={'rtl'} className={'items-center flex flex-col justify-center bg-white rounded py-4 !w-full'}>
154
- <Days
155
- days={datepicker.days}
156
- monthName={datepicker.monthName}
157
- year={datepicker.year}
158
- selectedDay={datepicker.value}
159
- disablePreviousMonths={disablePreviousMonths}
160
- disableSubsequentMonths={disableSubsequentMonths}
161
- disablePreviousDays={disablePreviousDays}
162
- disableSubsequentDays={disableSubsequentDays}
163
- daysEventListeners={daysEventListeners}
164
- selectDateHandlers={selectDateHandler}
165
- selectDateRangeHandlers={selectDateRangeHandler}
166
- selected={new DateObject({ date: selected }).format(dateFormat)}
167
- date={date}
168
- increaseMonth={() => changeMonths(1, 'inc')}
169
- decreaseMonth={() => changeMonths(-1, 'inc')}
170
- changeMonth={(monthIndex : number) => changeMonths(monthIndex, 'select')}
171
- isDatePicker={true}
172
- dateFormat={dateFormat}
173
- type={type}
174
- holidays={holidayList}
175
- variant={variant}
176
- rangeDate={dateRangePicker}
177
- rangeDates={rangeDates}
178
- size={size}
179
- changeYear={changeYear}
180
- />
181
- </Div>
182
- );
183
- };
184
-
185
- export default Calender;
@@ -1,42 +0,0 @@
1
- function slice(array: [], start: number, end: number) {
2
- let length = array == null ? 0 : array.length;
3
- if (!length) {
4
- return [];
5
- }
6
- start = start == null ? 0 : start;
7
- end = end === undefined ? length : end;
8
-
9
- if (start < 0) {
10
- start = -start > length ? 0 : length + start;
11
- }
12
- end = end > length ? length : end;
13
- if (end < 0) {
14
- end += length;
15
- }
16
- // @ts-ignore
17
- length = start > end ? 0 : (end - start) >>> 0;
18
- start >>>= 0;
19
-
20
- let index = -1;
21
- const result = new Array(length);
22
- while (++index < length) {
23
- result[index] = array[index + start];
24
- }
25
- return result;
26
- }
27
-
28
- export function chunk(array: any, size: any) {
29
- size = Math.max(size, 0);
30
- const length = array == null ? 0 : array.length;
31
- if (!length || size < 1) {
32
- return [];
33
- }
34
- let index = 0;
35
- let resIndex = 0;
36
- const result = new Array(Math.ceil(length / size));
37
-
38
- while (index < length) {
39
- result[resIndex++] = slice(array, index, (index += size));
40
- }
41
- return result;
42
- }
@@ -1,14 +0,0 @@
1
- import DateObject from 'react-date-object';
2
-
3
- const createDateRange = ({ startDate, stopDate } : {startDate: string, stopDate: string}): Array<string> => {
4
- const dateArray = [];
5
- let start = new DateObject(startDate);
6
- const end = new DateObject(stopDate);
7
- while (start <= end) {
8
- dateArray.push( new DateObject(start).format('YYYY-MM-DD') );
9
- start = new DateObject(start).add(1, 'days');
10
- }
11
- return dateArray;
12
- };
13
-
14
- export default createDateRange;
@@ -1,47 +0,0 @@
1
- import persian from 'react-date-object/calendars/persian';
2
- import gregorianEn from 'react-date-object/locales/gregorian_en';
3
- import DateObject from 'react-date-object';
4
- import gregorian from 'react-date-object/calendars/gregorian';
5
-
6
- export interface IDays {
7
- day: number;
8
- gregorianDate: string;
9
- jalaliDate: string;
10
- disabled: boolean;
11
- }
12
-
13
- export interface IDaysInMonth {
14
- days: IDays[];
15
- monthName: string;
16
- month: number;
17
- today?: string;
18
- year: string
19
- }
20
-
21
- export const daysInMonthEn = (date: any, dateFormat: string): IDaysInMonth => {
22
- date.calendar = gregorian;
23
- date.locale = gregorianEn;
24
- const monthName = date.month.name;
25
- const { month, year } = date;
26
- const firstDayWeekDay = new DateObject({ date: `${year} ${month} 1`, calendar: gregorian }).weekDay.number;
27
- // Calculate the number of empty cells needed before the first day of the month
28
- const emptyCellsCount = (firstDayWeekDay + 7) % 7;
29
- const lastDayOfPreviousMonth = new DateObject({date: `${year} ${month - 1} 31`, calendar: gregorian});
30
- // Calculate the empty days from the previous month
31
- const emptyDays = [...Array(emptyCellsCount)].map((_, i) => lastDayOfPreviousMonth.month.length - emptyCellsCount + i + 1);
32
- // Create an array of day objects for the current month
33
- const currentMonthDays = Array.from({ length: date.month.length }, (_, i) => {
34
- const dayNumber = i + 1;
35
- const gregorianDate = new DateObject({ date: (`${year} ${month} ${dayNumber}`), calendar: gregorian }).format(dateFormat);
36
- const jalaliDate = new DateObject({ date: (`${year} ${month} ${dayNumber}`), calendar: gregorian }).convert(persian).format(dateFormat);
37
- return { day: dayNumber, gregorianDate, jalaliDate, disabled: false };
38
- });
39
- const allDays = [...emptyDays.map((day) => ({
40
- day,
41
- gregorianDate: new DateObject({date: (`${year} ${month} ${day}`), calendar: gregorian}).format(dateFormat),
42
- jalaliDate: new DateObject({date: (`${year} ${month} ${day}`), calendar: gregorian}).convert(persian).format(dateFormat),
43
- disabled: true
44
- })), ...currentMonthDays];
45
-
46
- return { monthName, month, days: allDays, year };
47
- };
@@ -1,37 +0,0 @@
1
- import persian from 'react-date-object/calendars/persian';
2
- import persianFa from 'react-date-object/locales/persian_fa';
3
- import DateObject from 'react-date-object';
4
- import gregorian from 'react-date-object/calendars/gregorian';
5
- import { IDaysInMonth } from './days-in-month.en';
6
- export const daysInMonthFa = (date: any, dateFormat: string): IDaysInMonth => {
7
- date.calendar = persian;
8
- date.locale = persianFa;
9
- const monthName = date.month.name;
10
- const { month, year } = date;
11
- const firstDayWeekDay = new DateObject({ date: `${year} ${month} 1`, calendar: persian }).weekDay.number;
12
-
13
- // Calculate the number of empty cells needed before the first day of the month
14
- const emptyCellsCount = (firstDayWeekDay + 6) % 7;
15
-
16
- const lastDayOfPreviousMonth = new DateObject({ date: `${year} ${month - 1} 31`, calendar: persian });
17
-
18
- // Calculate the empty days from the previous month
19
- const emptyDays = [...Array(emptyCellsCount)].map((_, i) => lastDayOfPreviousMonth.month.length - emptyCellsCount + i + 1);
20
-
21
- // Create an array of day objects for the current month
22
- const currentMonthDays = Array.from({ length: date.month.length }, (_, i) => {
23
- const dayNumber = i + 1;
24
- const gregorianDate = new DateObject({ date: (`${year} ${month} ${dayNumber}`), calendar: persian }).convert(gregorian).format(dateFormat);
25
- const jalaliDate = new DateObject({ date: (`${year} ${month} ${dayNumber}`), calendar: persian }).format(dateFormat);
26
- return { day: dayNumber, gregorianDate, jalaliDate, disabled: false };
27
- });
28
-
29
- const allDays = [...emptyDays.map((day) => ({
30
- day,
31
- gregorianDate: new DateObject({ date: (`${year} ${month} ${day}`), calendar: persian }).convert(gregorian).format(dateFormat),
32
- jalaliDate: new DateObject({ date: (`${year} ${month} ${day}`), calendar: persian }).format(dateFormat),
33
- disabled: true,
34
- })), ...currentMonthDays];
35
-
36
- return { monthName, month, days: allDays, year };
37
- };
@@ -1,16 +0,0 @@
1
- import { fa, weekDayNames } from './week-day';
2
- import { chunk } from './chunk';
3
- import { daysInMonthEn, IDays, IDaysInMonth } from './days-in-month.en';
4
- import { daysInMonthFa } from './days-in-month.fa';
5
-
6
- export {
7
- daysInMonthEn,
8
- daysInMonthFa,
9
- fa,
10
- weekDayNames,
11
- chunk,
12
- };
13
- export type {
14
- IDaysInMonth,
15
- IDays,
16
- };
@@ -1,29 +0,0 @@
1
- export const jalaliMonths = [
2
- { name: 'فروردین', value: 1 },
3
- { name: 'اردیبهشت', value: 2 },
4
- { name: 'خرداد', value: 3 },
5
- { name: 'تیر', value: 4 },
6
- { name: 'مرداد', value: 5 },
7
- { name: 'شهریور', value: 6 },
8
- { name: 'مهر', value: 7 },
9
- { name: 'آبان', value: 8 },
10
- { name: 'آذر', value: 9 },
11
- { name: 'دی', value: 10 },
12
- { name: 'بهمن', value: 11 },
13
- { name: 'اسفند', value: 12 },
14
- ];
15
-
16
- export const gregorianMonths = [
17
- { name: 'Jan', value: 1 },
18
- { name: 'Feb', value: 2 },
19
- { name: 'Mar', value: 3 },
20
- { name: 'Apr', value: 4 },
21
- { name: 'May', value: 5 },
22
- { name: 'Jun', value: 6 },
23
- { name: 'Jul', value: 7 },
24
- { name: 'Aug', value: 8 },
25
- { name: 'Sep', value: 9 },
26
- { name: 'Oct', value: 10 },
27
- { name: 'Nov', value: 11 },
28
- { name: 'Dec', value: 12 },
29
- ];
@@ -1,19 +0,0 @@
1
- export const fa = (n: any) => {
2
- if (process.env.NODE_ENV === 'test') {
3
- return n;
4
- }
5
- return Number(n).toLocaleString('fa', {
6
- useGrouping: false,
7
- });
8
- };
9
-
10
- export const weekDayNames = {
11
- jalali: {
12
- normal: ['شنبه', 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه'],
13
- short: ['ش', 'ی', 'د', 'س', 'چ', 'پ', 'ج'],
14
- },
15
- gregorian: {
16
- normal: ['Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
17
- short: ['Sat', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
18
- },
19
- };
@@ -1,14 +0,0 @@
1
- const ArrowLeftIcon = () => {
2
- return (
3
- <svg xmlns="http://www.w3.org/2000/svg" width="6" height="12" viewBox="0 0 6 12">
4
- <path
5
- fill={'currentColor'}
6
- transform="rotate(-90 6 6)"
7
- data-name="Path 28691"
8
- d="M5.29.253a1.121 1.121 0 0 1 1.419 0l5 4.28a.775.775 0 0 1 0 1.215 1.126 1.126 0 0 1-1.419 0L6 2.068l-4.287 3.68a1.126 1.126 0 0 1-1.419 0 .775.775 0 0 1 0-1.215z"
9
- />
10
- </svg>
11
- );
12
- };
13
-
14
- export default ArrowLeftIcon;
@@ -1,14 +0,0 @@
1
- const ArrowRightIcon = () => {
2
- return (
3
- <svg xmlns="http://www.w3.org/2000/svg" width="6" height="12" viewBox="0 0 6 12">
4
- <path
5
- fill={'currentColor'}
6
- transform="rotate(-90 6 6)"
7
- data-name="Path 28692"
8
- d="M5.29 5.747a1.121 1.121 0 0 0 1.419 0l5-4.28a.775.775 0 0 0 0-1.215 1.126 1.126 0 0 0-1.419 0L6 3.932 1.713.252a1.126 1.126 0 0 0-1.419 0 .775.775 0 0 0 0 1.215z"
9
- />
10
- </svg>
11
- );
12
- };
13
-
14
- export default ArrowRightIcon;
@@ -1,7 +0,0 @@
1
- import ArrowLeftIcon from './arrow-left-icon';
2
- import ArrowRightIcon from './arrow-right-icon';
3
-
4
- export {
5
- ArrowLeftIcon,
6
- ArrowRightIcon,
7
- };
package/calendar/index.ts DELETED
@@ -1,3 +0,0 @@
1
- import Calendar from './calendar';
2
-
3
- export default Calendar;
@@ -1,12 +0,0 @@
1
- import DateObject from 'react-date-object';
2
- import persian from 'react-date-object/calendars/persian';
3
- import gregorian from 'react-date-object/calendars/gregorian';
4
-
5
- export default function formatDate(data: Date | number | string, format: string = 'YYYY-MM-DD', type: 'gregorian' | 'jalali') {
6
- if (data) {
7
- const date = new DateObject(data);
8
- date.calendar = type === 'gregorian' ? gregorian : persian;
9
- return date.format(format);
10
- }
11
- return null;
12
- }
@@ -1,27 +0,0 @@
1
- export interface DayProps {
2
- isSelecting?: boolean;
3
-
4
- selectedDay?: boolean;
5
-
6
- selected: boolean;
7
-
8
- handleDay: ((event: string) => void);
9
-
10
- children: any;
11
-
12
- disabledDay?: boolean;
13
-
14
- holidays?: boolean;
15
-
16
- passedDay?: boolean;
17
-
18
- comingDay?: boolean;
19
-
20
- isRange?: boolean
21
-
22
- size?: 'tiny' | 'small' | 'medium' | 'large' | 'huge'
23
-
24
- startRange?: boolean
25
-
26
- endRange?: boolean
27
- }
@@ -1,31 +0,0 @@
1
- import { DayProps } from './day.props';
2
- import classNames from '../../../utils/class-names';
3
- import { Button, Div } from '@pezeshk-book/ui-kit';
4
-
5
- export const Day = (props: DayProps) => {
6
- const { children, disabledDay, holidays, passedDay, comingDay, selectedDay, selected, handleDay, isRange, startRange, endRange } = props;
7
-
8
- if (!children) {
9
- return <Div {...props}/>;
10
- }
11
-
12
- const color = passedDay ? 'control' : selected ? 'primary' : isRange ? 'slate' : selectedDay ? 'primary' : (disabledDay || holidays ? 'danger' : 'inherit');
13
- const variant = selected ? 'filled' : (isRange ? 'outlined' : 'text');
14
- return (
15
- <Button
16
- disabled={comingDay || passedDay}
17
- variant={variant}
18
- rounded={isRange ? 'none' : 'medium'}
19
- size={'medium'}
20
- shape={'square'}
21
- color={color}
22
- className={classNames(
23
- isRange ? 'border-l-0 border-r-0 border-dashed' : '',
24
- startRange && isRange ? 'rounded-r-lg rounded-l-none' : '',
25
- endRange && isRange ? 'rounded-l-lg rounded-r-none' : '',
26
- )}
27
- onClick={handleDay}
28
- {...props}
29
- />
30
- );
31
- };
@@ -1,51 +0,0 @@
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
- }