@pezeshk-book/modules 0.2.8 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/package.json +1 -1
  2. package/.eslintrc.json +0 -133
  3. package/calendar/calendar.props.ts +0 -25
  4. package/calendar/calendar.tsx +0 -185
  5. package/calendar/config/chunk.ts +0 -42
  6. package/calendar/config/create-date-range.ts +0 -14
  7. package/calendar/config/days-in-month.en.ts +0 -47
  8. package/calendar/config/days-in-month.fa.ts +0 -37
  9. package/calendar/config/index.ts +0 -16
  10. package/calendar/config/months.ts +0 -29
  11. package/calendar/config/week-day.ts +0 -19
  12. package/calendar/icons/arrow-left-icon.tsx +0 -14
  13. package/calendar/icons/arrow-right-icon.tsx +0 -14
  14. package/calendar/icons/index.ts +0 -7
  15. package/calendar/index.ts +0 -3
  16. package/calendar/shared/formatDate.tsx +0 -12
  17. package/calendar/sub-components/day/day.props.ts +0 -27
  18. package/calendar/sub-components/day/day.tsx +0 -31
  19. package/calendar/sub-components/days/days.props.ts +0 -51
  20. package/calendar/sub-components/days/days.tsx +0 -142
  21. package/calendar/sub-components/days-head/days-head.props.ts +0 -27
  22. package/calendar/sub-components/days-head/days-head.tsx +0 -122
  23. package/countdown-timer/countdown.props.ts +0 -18
  24. package/countdown-timer/countdown.tsx +0 -79
  25. package/countdown-timer/index.ts +0 -3
  26. package/data-table/data-table.props.ts +0 -7
  27. package/data-table/data-table.tsx +0 -17
  28. package/data-table/default/default-data-table.props.ts +0 -47
  29. package/data-table/default/default-data-table.tsx +0 -427
  30. package/data-table/default/index.ts +0 -3
  31. package/data-table/hooks/use-window-dimensions.tsx +0 -33
  32. package/data-table/icons/add.tsx +0 -10
  33. package/data-table/icons/arrow-down.tsx +0 -11
  34. package/data-table/icons/index.ts +0 -9
  35. package/data-table/icons/sort.tsx +0 -16
  36. package/data-table/index.ts +0 -3
  37. package/data-table/simple/index.ts +0 -3
  38. package/data-table/simple/simple-data-table.props.ts +0 -23
  39. package/data-table/simple/simple-data-table.tsx +0 -258
  40. package/index.ts +0 -13
  41. package/pagination/icons/arrow-Right.tsx +0 -22
  42. package/pagination/icons/arrow-left.tsx +0 -22
  43. package/pagination/icons/index.ts +0 -7
  44. package/pagination/index.ts +0 -3
  45. package/pagination/pagination.props.ts +0 -33
  46. package/pagination/pagination.tsx +0 -135
  47. package/pagination/use-pagination.ts +0 -49
  48. package/react-app-env.d.ts +0 -1
  49. package/slider/index.ts +0 -3
  50. package/slider/slider.props.ts +0 -39
  51. package/slider/slider.tsx +0 -292
  52. package/stories/calendar/calendar.stories.tsx +0 -25
  53. package/stories/calendar/calendar.tsx +0 -11
  54. package/stories/count-down/count-down.stories.tsx +0 -19
  55. package/stories/count-down/count-down.tsx +0 -11
  56. package/stories/data-table/data-table-columns.tsx +0 -70
  57. package/stories/data-table/default-data-table.stories.tsx +0 -22
  58. package/stories/data-table/default-data-table.tsx +0 -18
  59. package/stories/data-table/dummy-data.ts +0 -204
  60. package/stories/data-table/simple-data-table.stories.tsx +0 -22
  61. package/stories/data-table/simple-data-table.tsx +0 -18
  62. package/stories/pagination/pagination.stories.tsx +0 -35
  63. package/stories/pagination/pagination.tsx +0 -11
  64. package/stories/slider/slider.stories.tsx +0 -19
  65. package/stories/slider/slider.tsx +0 -45
  66. package/stories/wrapper.tsx +0 -11
  67. package/styles.css +0 -28
  68. package/utils/class-names.ts +0 -5
  69. package/utils/persian-to-english-number.ts +0 -4
  70. /package/{dist/calendar → calendar}/calendar.d.ts +0 -0
  71. /package/{dist/calendar → calendar}/calendar.js +0 -0
  72. /package/{dist/calendar → calendar}/calendar.js.map +0 -0
  73. /package/{dist/calendar → calendar}/calendar.props.d.ts +0 -0
  74. /package/{dist/calendar → calendar}/calendar.props.js +0 -0
  75. /package/{dist/calendar → calendar}/calendar.props.js.map +0 -0
  76. /package/{dist/calendar → calendar}/config/chunk.d.ts +0 -0
  77. /package/{dist/calendar → calendar}/config/chunk.js +0 -0
  78. /package/{dist/calendar → calendar}/config/chunk.js.map +0 -0
  79. /package/{dist/calendar → calendar}/config/create-date-range.d.ts +0 -0
  80. /package/{dist/calendar → calendar}/config/create-date-range.js +0 -0
  81. /package/{dist/calendar → calendar}/config/create-date-range.js.map +0 -0
  82. /package/{dist/calendar → calendar}/config/days-in-month.en.d.ts +0 -0
  83. /package/{dist/calendar → calendar}/config/days-in-month.en.js +0 -0
  84. /package/{dist/calendar → calendar}/config/days-in-month.en.js.map +0 -0
  85. /package/{dist/calendar → calendar}/config/days-in-month.fa.d.ts +0 -0
  86. /package/{dist/calendar → calendar}/config/days-in-month.fa.js +0 -0
  87. /package/{dist/calendar → calendar}/config/days-in-month.fa.js.map +0 -0
  88. /package/{dist/calendar → calendar}/config/index.d.ts +0 -0
  89. /package/{dist/calendar → calendar}/config/index.js +0 -0
  90. /package/{dist/calendar → calendar}/config/index.js.map +0 -0
  91. /package/{dist/calendar → calendar}/config/months.d.ts +0 -0
  92. /package/{dist/calendar → calendar}/config/months.js +0 -0
  93. /package/{dist/calendar → calendar}/config/months.js.map +0 -0
  94. /package/{dist/calendar → calendar}/config/week-day.d.ts +0 -0
  95. /package/{dist/calendar → calendar}/config/week-day.js +0 -0
  96. /package/{dist/calendar → calendar}/config/week-day.js.map +0 -0
  97. /package/{dist/calendar → calendar}/icons/arrow-left-icon.d.ts +0 -0
  98. /package/{dist/calendar → calendar}/icons/arrow-left-icon.js +0 -0
  99. /package/{dist/calendar → calendar}/icons/arrow-left-icon.js.map +0 -0
  100. /package/{dist/calendar → calendar}/icons/arrow-right-icon.d.ts +0 -0
  101. /package/{dist/calendar → calendar}/icons/arrow-right-icon.js +0 -0
  102. /package/{dist/calendar → calendar}/icons/arrow-right-icon.js.map +0 -0
  103. /package/{dist/calendar → calendar}/icons/index.d.ts +0 -0
  104. /package/{dist/calendar → calendar}/icons/index.js +0 -0
  105. /package/{dist/calendar → calendar}/icons/index.js.map +0 -0
  106. /package/{dist/calendar → calendar}/index.d.ts +0 -0
  107. /package/{dist/calendar → calendar}/index.js +0 -0
  108. /package/{dist/calendar → calendar}/index.js.map +0 -0
  109. /package/{dist/calendar → calendar}/shared/formatDate.d.ts +0 -0
  110. /package/{dist/calendar → calendar}/shared/formatDate.js +0 -0
  111. /package/{dist/calendar → calendar}/shared/formatDate.js.map +0 -0
  112. /package/{dist/calendar → calendar}/sub-components/day/day.d.ts +0 -0
  113. /package/{dist/calendar → calendar}/sub-components/day/day.js +0 -0
  114. /package/{dist/calendar → calendar}/sub-components/day/day.js.map +0 -0
  115. /package/{dist/calendar → calendar}/sub-components/day/day.props.d.ts +0 -0
  116. /package/{dist/calendar → calendar}/sub-components/day/day.props.js +0 -0
  117. /package/{dist/calendar → calendar}/sub-components/day/day.props.js.map +0 -0
  118. /package/{dist/calendar → calendar}/sub-components/days/days.d.ts +0 -0
  119. /package/{dist/calendar → calendar}/sub-components/days/days.js +0 -0
  120. /package/{dist/calendar → calendar}/sub-components/days/days.js.map +0 -0
  121. /package/{dist/calendar → calendar}/sub-components/days/days.props.d.ts +0 -0
  122. /package/{dist/calendar → calendar}/sub-components/days/days.props.js +0 -0
  123. /package/{dist/calendar → calendar}/sub-components/days/days.props.js.map +0 -0
  124. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.d.ts +0 -0
  125. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.js +0 -0
  126. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.js.map +0 -0
  127. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.d.ts +0 -0
  128. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.js +0 -0
  129. /package/{dist/calendar → calendar}/sub-components/days-head/days-head.props.js.map +0 -0
  130. /package/{dist/countdown-timer → countdown-timer}/countdown.d.ts +0 -0
  131. /package/{dist/countdown-timer → countdown-timer}/countdown.js +0 -0
  132. /package/{dist/countdown-timer → countdown-timer}/countdown.js.map +0 -0
  133. /package/{dist/countdown-timer → countdown-timer}/countdown.props.d.ts +0 -0
  134. /package/{dist/countdown-timer → countdown-timer}/countdown.props.js +0 -0
  135. /package/{dist/countdown-timer → countdown-timer}/countdown.props.js.map +0 -0
  136. /package/{dist/countdown-timer → countdown-timer}/index.d.ts +0 -0
  137. /package/{dist/countdown-timer → countdown-timer}/index.js +0 -0
  138. /package/{dist/countdown-timer → countdown-timer}/index.js.map +0 -0
  139. /package/{dist/data-table → data-table}/data-table.d.ts +0 -0
  140. /package/{dist/data-table → data-table}/data-table.js +0 -0
  141. /package/{dist/data-table → data-table}/data-table.js.map +0 -0
  142. /package/{dist/data-table → data-table}/data-table.props.d.ts +0 -0
  143. /package/{dist/data-table → data-table}/data-table.props.js +0 -0
  144. /package/{dist/data-table → data-table}/data-table.props.js.map +0 -0
  145. /package/{dist/data-table → data-table}/default/default-data-table.d.ts +0 -0
  146. /package/{dist/data-table → data-table}/default/default-data-table.js +0 -0
  147. /package/{dist/data-table → data-table}/default/default-data-table.js.map +0 -0
  148. /package/{dist/data-table → data-table}/default/default-data-table.props.d.ts +0 -0
  149. /package/{dist/data-table → data-table}/default/default-data-table.props.js +0 -0
  150. /package/{dist/data-table → data-table}/default/default-data-table.props.js.map +0 -0
  151. /package/{dist/data-table → data-table}/default/index.d.ts +0 -0
  152. /package/{dist/data-table → data-table}/default/index.js +0 -0
  153. /package/{dist/data-table → data-table}/default/index.js.map +0 -0
  154. /package/{dist/data-table → data-table}/hooks/use-window-dimensions.d.ts +0 -0
  155. /package/{dist/data-table → data-table}/hooks/use-window-dimensions.js +0 -0
  156. /package/{dist/data-table → data-table}/hooks/use-window-dimensions.js.map +0 -0
  157. /package/{dist/data-table → data-table}/icons/add.d.ts +0 -0
  158. /package/{dist/data-table → data-table}/icons/add.js +0 -0
  159. /package/{dist/data-table → data-table}/icons/add.js.map +0 -0
  160. /package/{dist/data-table → data-table}/icons/arrow-down.d.ts +0 -0
  161. /package/{dist/data-table → data-table}/icons/arrow-down.js +0 -0
  162. /package/{dist/data-table → data-table}/icons/arrow-down.js.map +0 -0
  163. /package/{dist/data-table → data-table}/icons/index.d.ts +0 -0
  164. /package/{dist/data-table → data-table}/icons/index.js +0 -0
  165. /package/{dist/data-table → data-table}/icons/index.js.map +0 -0
  166. /package/{dist/data-table → data-table}/icons/sort.d.ts +0 -0
  167. /package/{dist/data-table → data-table}/icons/sort.js +0 -0
  168. /package/{dist/data-table → data-table}/icons/sort.js.map +0 -0
  169. /package/{dist/data-table → data-table}/index.d.ts +0 -0
  170. /package/{dist/data-table → data-table}/index.js +0 -0
  171. /package/{dist/data-table → data-table}/index.js.map +0 -0
  172. /package/{dist/data-table → data-table}/simple/index.d.ts +0 -0
  173. /package/{dist/data-table → data-table}/simple/index.js +0 -0
  174. /package/{dist/data-table → data-table}/simple/index.js.map +0 -0
  175. /package/{dist/data-table → data-table}/simple/simple-data-table.d.ts +0 -0
  176. /package/{dist/data-table → data-table}/simple/simple-data-table.js +0 -0
  177. /package/{dist/data-table → data-table}/simple/simple-data-table.js.map +0 -0
  178. /package/{dist/data-table → data-table}/simple/simple-data-table.props.d.ts +0 -0
  179. /package/{dist/data-table → data-table}/simple/simple-data-table.props.js +0 -0
  180. /package/{dist/data-table → data-table}/simple/simple-data-table.props.js.map +0 -0
  181. /package/{dist/index.d.ts → index.d.ts} +0 -0
  182. /package/{dist/index.js → index.js} +0 -0
  183. /package/{dist/index.js.map → index.js.map} +0 -0
  184. /package/{dist/pagination → pagination}/icons/arrow-Right.d.ts +0 -0
  185. /package/{dist/pagination → pagination}/icons/arrow-Right.js +0 -0
  186. /package/{dist/pagination → pagination}/icons/arrow-Right.js.map +0 -0
  187. /package/{dist/pagination → pagination}/icons/arrow-left.d.ts +0 -0
  188. /package/{dist/pagination → pagination}/icons/arrow-left.js +0 -0
  189. /package/{dist/pagination → pagination}/icons/arrow-left.js.map +0 -0
  190. /package/{dist/pagination → pagination}/icons/index.d.ts +0 -0
  191. /package/{dist/pagination → pagination}/icons/index.js +0 -0
  192. /package/{dist/pagination → pagination}/icons/index.js.map +0 -0
  193. /package/{dist/pagination → pagination}/index.d.ts +0 -0
  194. /package/{dist/pagination → pagination}/index.js +0 -0
  195. /package/{dist/pagination → pagination}/index.js.map +0 -0
  196. /package/{dist/pagination → pagination}/pagination.d.ts +0 -0
  197. /package/{dist/pagination → pagination}/pagination.js +0 -0
  198. /package/{dist/pagination → pagination}/pagination.js.map +0 -0
  199. /package/{dist/pagination → pagination}/pagination.props.d.ts +0 -0
  200. /package/{dist/pagination → pagination}/pagination.props.js +0 -0
  201. /package/{dist/pagination → pagination}/pagination.props.js.map +0 -0
  202. /package/{dist/pagination → pagination}/use-pagination.d.ts +0 -0
  203. /package/{dist/pagination → pagination}/use-pagination.js +0 -0
  204. /package/{dist/pagination → pagination}/use-pagination.js.map +0 -0
  205. /package/{dist/slider → slider}/index.d.ts +0 -0
  206. /package/{dist/slider → slider}/index.js +0 -0
  207. /package/{dist/slider → slider}/index.js.map +0 -0
  208. /package/{dist/slider → slider}/slider.d.ts +0 -0
  209. /package/{dist/slider → slider}/slider.js +0 -0
  210. /package/{dist/slider → slider}/slider.js.map +0 -0
  211. /package/{dist/slider → slider}/slider.props.d.ts +0 -0
  212. /package/{dist/slider → slider}/slider.props.js +0 -0
  213. /package/{dist/slider → slider}/slider.props.js.map +0 -0
  214. /package/{dist/utils → utils}/class-names.d.ts +0 -0
  215. /package/{dist/utils → utils}/class-names.js +0 -0
  216. /package/{dist/utils → utils}/class-names.js.map +0 -0
  217. /package/{dist/utils → utils}/persian-to-english-number.d.ts +0 -0
  218. /package/{dist/utils → utils}/persian-to-english-number.js +0 -0
  219. /package/{dist/utils → utils}/persian-to-english-number.js.map +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pezeshk-book/modules",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "types": "./index.d.ts",
5
5
  "main": "./index.ts",
6
6
  "module": "./index.js",
package/.eslintrc.json DELETED
@@ -1,133 +0,0 @@
1
- {
2
- "plugins": [
3
- "react-hooks"
4
- ],
5
- "root": true,
6
- "rules": {
7
- "react-hooks/rules-of-hooks": "off",
8
- "react-hooks/exhaustive-deps": "off",
9
- "@next/next/no-img-element": "off",
10
-
11
- "quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
12
- "object-curly-spacing": ["error", "always"],
13
- "semi": ["error", "always", {"omitLastInOneLineClassBody": true}],
14
- "semi-style": ["error", "last"],
15
- "comma-dangle": ["error", "always-multiline"],
16
- "arrow-spacing": ["error", { "before": true, "after": true }],
17
- "block-spacing": ["error", "always"],
18
- "brace-style": [2, "1tbs", { "allowSingleLine": true }],
19
- "camelcase": ["error", { "properties": "never" }],
20
- "comma-spacing": ["error", { "before": false, "after": true }],
21
- "comma-style": ["error", "last"],
22
- "constructor-super": "error",
23
- "curly": ["error"],
24
- "dot-location": ["error", "property"],
25
-
26
-
27
- "eol-last": 2,
28
- "eqeqeq": [2, "allow-null"],
29
- "func-call-spacing": [2, "never"],
30
- "handle-callback-err": [2, "^(err|error)$" ],
31
- "indent": [2, 2, { "SwitchCase": 1 }],
32
- "key-spacing": [2, { "beforeColon": false, "afterColon": true }],
33
- "keyword-spacing": [2, { "before": true, "after": true }],
34
- "new-cap": [2, { "newIsCap": true, "capIsNew": false }],
35
- "new-parens": 2,
36
- "no-array-constructor": 2,
37
- "no-caller": 2,
38
- "no-class-assign": 2,
39
- "no-cond-assign": 2,
40
- "no-const-assign": 2,
41
- "no-constant-condition": [2, { "checkLoops": false }],
42
- "no-control-regex": 2,
43
- "no-debugger": 2,
44
- "no-delete-var": 2,
45
- "no-dupe-args": 2,
46
- "no-dupe-class-members": 2,
47
- "no-dupe-keys": 2,
48
- "no-duplicate-case": 2,
49
- "no-duplicate-imports": 2,
50
- "no-empty-character-class": 2,
51
- "no-empty-pattern": 2,
52
- "no-eval": 2,
53
- "no-ex-assign": 2,
54
- "no-extend-native": 2,
55
- "no-extra-bind": 2,
56
- "no-extra-parens": [2, "functions"],
57
- "no-fallthrough": 2,
58
- "no-floating-decimal": 2,
59
- "no-func-assign": 2,
60
- "no-global-assign": 2,
61
- "no-implied-eval": 2,
62
- "no-inner-declarations": [2, "functions"],
63
- "no-invalid-regexp": 2,
64
- "no-irregular-whitespace": 2,
65
- "no-iterator": 2,
66
- "no-label-var": 2,
67
- "no-labels": [2, { "allowLoop": false, "allowSwitch": false }],
68
- "no-lone-blocks": 2,
69
- "no-mixed-spaces-and-tabs": 2,
70
- "no-multi-spaces": 2,
71
- "no-multi-str": 2,
72
- "no-multiple-empty-lines": [2, { "max": 1 }],
73
- "no-native-reassign": 2,
74
- "no-negated-in-lhs": 2,
75
- "no-new": 2,
76
- "no-new-func": 2,
77
- "no-new-object": 2,
78
- "no-new-require": 2,
79
- "no-new-symbol": 2,
80
- "no-new-wrappers": 2,
81
- "no-obj-calls": 2,
82
- "no-octal": 2,
83
- "no-octal-escape": 2,
84
- "no-path-concat": 2,
85
- "no-proto": 2,
86
- "no-redeclare": 2,
87
- "no-regex-spaces": 2,
88
- "no-return-assign": [2, "except-parens"],
89
- "no-self-assign": 2,
90
- "no-self-compare": 2,
91
- "no-sequences": 2,
92
- "no-shadow-restricted-names": 2,
93
- "no-sparse-arrays": 2,
94
- "no-tabs": 2,
95
- "no-template-curly-in-string": 2,
96
- "no-this-before-super": 2,
97
- "no-throw-literal": 2,
98
- "no-trailing-spaces": 2,
99
- "no-unexpected-multiline": 2,
100
- "no-unmodified-loop-condition": 2,
101
- "no-unneeded-ternary": [2, { "defaultAssignment": false }],
102
- "no-unreachable": 2,
103
- "no-unsafe-finally": 2,
104
- "no-unsafe-negation": 2,
105
- "no-unused-vars": [2, { "vars": "all", "args": "none" }],
106
- "no-useless-call": 2,
107
- "no-useless-computed-key": 2,
108
- "no-useless-constructor": 2,
109
- "no-useless-escape": 2,
110
- "no-useless-rename": 2,
111
- "no-whitespace-before-property": 2,
112
- "no-with": 2,
113
- "object-property-newline": [2, { "allowMultiplePropertiesPerLine": true }],
114
- "one-var": [2, { "initialized": "never" }],
115
- "operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }],
116
- "padded-blocks": [2, "never"],
117
- "rest-spread-spacing": [2, "never"],
118
- "semi-spacing": [2, { "before": false, "after": true }],
119
- "space-before-blocks": [2, "always"],
120
- "space-infix-ops": 2,
121
- "space-unary-ops": [2, { "words": true, "nonwords": false }],
122
- "template-curly-spacing": [2, "never"],
123
- "unicode-bom": [2, "never"],
124
- "use-isnan": 2,
125
- "valid-typeof": 2,
126
- "wrap-iife": [2, "any", { "functionPrototypeMethods": true }],
127
- "yield-star-spacing": [2, "both"],
128
- "yoda": [2, "never"]
129
- },
130
- "extends": [
131
- "react-app"
132
- ]
133
- }
@@ -1,25 +0,0 @@
1
- export interface CalendarProps {
2
- dateFormat?: string
3
-
4
- selectedDate?: string | Date;
5
-
6
- disablePreviousMonths?: boolean;
7
-
8
- disableSubsequentMonths?: boolean;
9
-
10
- disablePreviousDays?: boolean;
11
-
12
- disableSubsequentDays?: boolean;
13
-
14
- onChange: (e: any) => void;
15
-
16
- selected?: string | Date
17
-
18
- type?: 'gregorian' | 'jalali'
19
-
20
- holidays?: Array<string>
21
-
22
- variant?: 'range' | 'simple'
23
-
24
- size?: 'tiny' | 'small' | 'medium' | 'large' | 'huge'
25
- }
@@ -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
- }