zaman-backoffice 1.0.0 → 1.0.2

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 (115) hide show
  1. package/.eslintrc.cjs +26 -0
  2. package/.husky/commit-msg +4 -0
  3. package/.husky/pre-commit +4 -0
  4. package/.idea/git_toolbox_blame.xml +6 -0
  5. package/.idea/git_toolbox_prj.xml +15 -0
  6. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  7. package/.idea/material_theme_project_new.xml +12 -0
  8. package/.idea/modules.xml +8 -0
  9. package/.idea/vcs.xml +6 -0
  10. package/.idea/zaman-backoffice2.iml +12 -0
  11. package/.prettierrc +9 -0
  12. package/.travis.yml +10 -0
  13. package/client/index.html +12 -0
  14. package/client/main.tsx +84 -0
  15. package/client/style.css +62 -0
  16. package/cypress/fixtures/example.json +5 -0
  17. package/cypress/support/commands.ts +38 -0
  18. package/cypress/support/component-index.html +12 -0
  19. package/cypress/support/component.ts +39 -0
  20. package/cypress/videos/Calendar/CalendarComponent.cy.tsx.mp4 +0 -0
  21. package/cypress/videos/DatePicker/DatePicker.cy.tsx.mp4 +0 -0
  22. package/cypress.config.ts +10 -0
  23. package/desktop.ini +2 -0
  24. package/help/banner.png +0 -0
  25. package/jest.config.ts +47 -0
  26. package/package.json +1 -1
  27. package/src/components/CalendarItem/CalendarItem.styled.tsx +96 -0
  28. package/src/components/CalendarItem/CalendarItem.types.ts +7 -0
  29. package/src/components/CalendarItem/index.ts +1 -0
  30. package/src/components/CalendarWrapper/CalendarWrapper.styled.tsx +19 -0
  31. package/src/components/CalendarWrapper/index.ts +1 -0
  32. package/src/components/FloatingElement/FloatingElement.styled.tsx +8 -0
  33. package/src/components/FloatingElement/FloatingElement.tsx +83 -0
  34. package/src/components/FloatingElement/FloatingElement.types.ts +8 -0
  35. package/src/components/FloatingElement/index.tsx +1 -0
  36. package/src/components/Header/Header.styled.tsx +40 -0
  37. package/src/components/Header/Header.tsx +46 -0
  38. package/src/components/Header/Header.types.ts +6 -0
  39. package/src/components/Header/index.ts +1 -0
  40. package/src/components/IconButton/IconButton.styled.tsx +22 -0
  41. package/src/components/IconButton/IconButton.tsx +3 -0
  42. package/src/components/IconButton/index.tsx +1 -0
  43. package/src/components/Icons/ChevronLeft/index.tsx +22 -0
  44. package/src/components/Icons/ChevronRight/index.tsx +22 -0
  45. package/src/components/Modal/Modal.styled.tsx +23 -0
  46. package/src/components/Modal/Modal.tsx +29 -0
  47. package/src/components/Modal/index.tsx +1 -0
  48. package/src/components/Modal/types.ts +7 -0
  49. package/src/components/MonthPicker/Month.styled.tsx +11 -0
  50. package/src/components/MonthPicker/MonthPicker.tsx +35 -0
  51. package/src/components/MonthPicker/MonthPicker.types.ts +4 -0
  52. package/src/components/MonthPicker/index.ts +1 -0
  53. package/src/components/RenderCalendar/RenderCalendar.tsx +31 -0
  54. package/src/components/RenderCalendar/RenderCalendar.types.ts +10 -0
  55. package/src/components/RenderCalendar/index.ts +1 -0
  56. package/src/components/YearPicker/YearPicker.styled.tsx +14 -0
  57. package/src/components/YearPicker/YearPicker.tsx +49 -0
  58. package/src/components/YearPicker/YearPicker.types.ts +4 -0
  59. package/src/components/YearPicker/index.ts +1 -0
  60. package/src/constants.ts +6 -0
  61. package/src/hooks/__tests__/useClickOutside.test.tsx +32 -0
  62. package/src/hooks/useCalendarHandlers.tsx +113 -0
  63. package/src/hooks/useClickOutside.tsx +23 -0
  64. package/src/hooks/useSlideCalendar.tsx +95 -0
  65. package/src/hooks/useTimePicker.tsx +95 -0
  66. package/src/index.tsx +4 -0
  67. package/src/packages/Calendar/Calendar.styled.tsx +42 -0
  68. package/src/packages/Calendar/Calendar.tsx +159 -0
  69. package/src/packages/Calendar/Calendar.types.ts +31 -0
  70. package/src/packages/Calendar/CalendarComponent.cy.tsx +69 -0
  71. package/src/packages/Calendar/index.ts +2 -0
  72. package/src/packages/CalendarProvider/CalendarProvider.tsx +30 -0
  73. package/src/packages/CalendarProvider/CalendarProvider.types.ts +6 -0
  74. package/src/packages/CalendarProvider/index.ts +2 -0
  75. package/src/packages/DatePicker/DatePicker.cy.tsx +54 -0
  76. package/src/packages/DatePicker/DatePicker.tsx +127 -0
  77. package/src/packages/DatePicker/DatePicker.types.ts +26 -0
  78. package/src/packages/DatePicker/index.ts +2 -0
  79. package/src/packages/TimePicker/TimePicker.styled.tsx +77 -0
  80. package/src/packages/TimePicker/TimePicker.tsx +121 -0
  81. package/src/packages/TimePicker/TimePicker.types.ts +16 -0
  82. package/src/packages/TimePicker/components/Numbers/Numbers.styled.tsx +36 -0
  83. package/src/packages/TimePicker/components/Numbers/Numbers.tsx +58 -0
  84. package/src/packages/TimePicker/components/Numbers/Numbers.types.ts +14 -0
  85. package/src/packages/TimePicker/components/Numbers/index.ts +1 -0
  86. package/src/packages/TimePicker/index.ts +2 -0
  87. package/src/style/animation.ts +23 -0
  88. package/src/style/classNames.ts +8 -0
  89. package/src/style/colorPallete.ts +16 -0
  90. package/src/style/colors.ts +15 -0
  91. package/src/style/hexToHSL.ts +52 -0
  92. package/src/style/radius.ts +28 -0
  93. package/src/types.ts +75 -0
  94. package/src/utils/dateHelper/dateHelper.ts +67 -0
  95. package/src/utils/dateHelper/index.ts +1 -0
  96. package/src/utils/dateTimeFormat/dateTimeFormat.ts +43 -0
  97. package/src/utils/dateTimeFormat/index.ts +1 -0
  98. package/src/utils/format/format.test.ts +37 -0
  99. package/src/utils/format/format.ts +56 -0
  100. package/src/utils/format/format.types.ts +11 -0
  101. package/src/utils/format/index.ts +1 -0
  102. package/src/utils/index.ts +21 -0
  103. package/src/utils/locale.ts +13 -0
  104. package/src/utils/locales/en.ts +89 -0
  105. package/src/utils/locales/fa.ts +89 -0
  106. package/src/utils/locales/index.ts +10 -0
  107. package/src/utils/locales/locales.types.ts +11 -0
  108. package/src/utils/month/index.ts +1 -0
  109. package/src/utils/month/month.ts +54 -0
  110. package/src/utils/month/month.types.ts +11 -0
  111. package/src/utils/timePicker.ts +107 -0
  112. package/src/utils/type.ts +0 -0
  113. package/tsconfig.json +22 -0
  114. package/tsconfig.test.json +7 -0
  115. package/vite.config.ts +7 -0
@@ -0,0 +1,107 @@
1
+ import type React from 'react'
2
+ /**
3
+ * numberPosition functions
4
+ * These functions find position X-axis and Y-axis from half of the clock width
5
+ * Its start from 30 deg and each time this degree increase as much as 30 deg
6
+ */
7
+ export function numberPositionX(
8
+ idx: number,
9
+ width: number = 130,
10
+ padding: number = 20
11
+ ) {
12
+ const circleWith = width - padding
13
+ const thirtyDegInRad = 0.5235987755982988
14
+
15
+ return Math.round(circleWith * Math.sin(thirtyDegInRad * idx))
16
+ }
17
+
18
+ export function numberPositionY(
19
+ idx: number,
20
+ width: number = 130,
21
+ padding: number = 17
22
+ ) {
23
+ const circleWith = width - padding
24
+ const thirtyDegInRad = 0.5235987755982988
25
+ const y = Math.round(circleWith * Math.cos(thirtyDegInRad * idx))
26
+ // because the Y-axis in computer starts from the screen corner
27
+ return -y + width - padding
28
+ }
29
+ // clock center
30
+ export const center = {
31
+ x: 260 / 2,
32
+ y: 260 / 2
33
+ }
34
+
35
+ // change radian to deg
36
+ export const radianToDeg = (rad: number) => rad * 57.29577951308232
37
+
38
+ // calculate offsetX and offsetY
39
+ export const calculateOffset = (elem: unknown) => {
40
+ const el = elem as React.MouseEvent<HTMLElement>
41
+ const touchElement = elem as React.TouchEvent<HTMLElement>
42
+ let { offsetX, offsetY } = el.nativeEvent
43
+ if (typeof offsetX === 'undefined') {
44
+ const rect = touchElement.currentTarget.getBoundingClientRect()
45
+ if (touchElement.changedTouches.length !== 0) {
46
+ offsetX = touchElement.changedTouches[0].clientX - rect.left
47
+ offsetY = touchElement.changedTouches[0].clientY - rect.top
48
+ } else {
49
+ offsetX = el.clientX - rect.left
50
+ offsetY = el.clientY - rect.top
51
+ }
52
+ }
53
+ return {
54
+ offsetX,
55
+ offsetY
56
+ }
57
+ }
58
+
59
+ export const getValue = (deg: number, delta: number, steps: number) => {
60
+ const valueBySteps = Math.floor(deg * (1 / steps))
61
+ // minutes selecting
62
+ if (steps === 6) {
63
+ return valueBySteps
64
+ }
65
+ // hour selecting
66
+ if (Math.round(delta) > 85) {
67
+ return valueBySteps === 0 ? -12 : valueBySteps
68
+ }
69
+ // inside hour selecting
70
+ return valueBySteps === 0 ? 12 : valueBySteps
71
+ }
72
+
73
+ /**
74
+ * calculate the value from where the mouse clicked or tapped
75
+ * step1: calculate deg from the center of the circle not (0, 0)
76
+ * step1-1: calculate deg with atan2 but instead of using atan2 in this way (y, x) -
77
+ * I used atan2(x, y) because atan2(y, x) get an angel from (0, 0) not the center of the circle
78
+ * step-2: decrease atan2 by Math.PI because- * this function returns two degrees that one of them is valid and another isn't. like 90 deg and -90deg and -90deg should be 270
79
+ * step3: delta: determine the distance of each place that is clicked by the user. calculating the distance between the center of the circle
80
+ * step4: make value by division deg into the hour or minutes angles. in the hour is 30 deg and in minutes is 6 deg
81
+ */
82
+ interface IGetAngelValues {
83
+ value: number
84
+ delta: number
85
+ }
86
+ export const getAngelValues = (
87
+ e: React.MouseEvent | React.TouchEvent,
88
+ steps: number = 30
89
+ ): IGetAngelValues => {
90
+ const { offsetX, offsetY } = calculateOffset(e)
91
+ const x = offsetX - center.x
92
+ const y = offsetY - center.y
93
+ const atan = Math.PI - Math.atan2(x, y)
94
+ const delta = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))
95
+ const deg = radianToDeg(atan)
96
+ const value = getValue(deg, delta, steps)
97
+
98
+ return {
99
+ value,
100
+ delta
101
+ }
102
+ }
103
+
104
+ // numbers
105
+ export const hours = [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
106
+ export const hours24 = [0, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
107
+ export const minutes = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]
File without changes
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2015",
4
+ "module": "esnext",
5
+ "allowJs": true,
6
+ "baseUrl": "./zaman",
7
+ "outDir": "./dist",
8
+ "declaration": true,
9
+ "declarationDir": "./",
10
+ "moduleResolution": "node",
11
+ "noEmitOnError": true,
12
+ "lib": ["ESNext", "DOM"],
13
+ "strict": true,
14
+ "esModuleInterop": true,
15
+ "skipLibCheck": true,
16
+ "allowSyntheticDefaultImports": true,
17
+ "jsx": "react",
18
+ "types": ["cypress", "node", "@testing-library/cypress"]
19
+ },
20
+ "include": ["src/**/*", "client/**/*", "**/*.ts", "**/*.tsx"],
21
+ "exclude": ["node_modules", "**/*.test.tsx", "**/*.test.ts"]
22
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "compilerOptions": {
3
+ "types": ["jest", "node"]
4
+ },
5
+ "extends": "./tsconfig.json",
6
+ "include": ["**/*.test.tsx", "**/*.test.ts"]
7
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+
4
+ export default defineConfig({
5
+ root: './client',
6
+ plugins: [react()],
7
+ })