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.
- package/.eslintrc.cjs +26 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.idea/git_toolbox_blame.xml +6 -0
- package/.idea/git_toolbox_prj.xml +15 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/material_theme_project_new.xml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/zaman-backoffice2.iml +12 -0
- package/.prettierrc +9 -0
- package/.travis.yml +10 -0
- package/client/index.html +12 -0
- package/client/main.tsx +84 -0
- package/client/style.css +62 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/support/commands.ts +38 -0
- package/cypress/support/component-index.html +12 -0
- package/cypress/support/component.ts +39 -0
- package/cypress/videos/Calendar/CalendarComponent.cy.tsx.mp4 +0 -0
- package/cypress/videos/DatePicker/DatePicker.cy.tsx.mp4 +0 -0
- package/cypress.config.ts +10 -0
- package/desktop.ini +2 -0
- package/help/banner.png +0 -0
- package/jest.config.ts +47 -0
- package/package.json +1 -1
- package/src/components/CalendarItem/CalendarItem.styled.tsx +96 -0
- package/src/components/CalendarItem/CalendarItem.types.ts +7 -0
- package/src/components/CalendarItem/index.ts +1 -0
- package/src/components/CalendarWrapper/CalendarWrapper.styled.tsx +19 -0
- package/src/components/CalendarWrapper/index.ts +1 -0
- package/src/components/FloatingElement/FloatingElement.styled.tsx +8 -0
- package/src/components/FloatingElement/FloatingElement.tsx +83 -0
- package/src/components/FloatingElement/FloatingElement.types.ts +8 -0
- package/src/components/FloatingElement/index.tsx +1 -0
- package/src/components/Header/Header.styled.tsx +40 -0
- package/src/components/Header/Header.tsx +46 -0
- package/src/components/Header/Header.types.ts +6 -0
- package/src/components/Header/index.ts +1 -0
- package/src/components/IconButton/IconButton.styled.tsx +22 -0
- package/src/components/IconButton/IconButton.tsx +3 -0
- package/src/components/IconButton/index.tsx +1 -0
- package/src/components/Icons/ChevronLeft/index.tsx +22 -0
- package/src/components/Icons/ChevronRight/index.tsx +22 -0
- package/src/components/Modal/Modal.styled.tsx +23 -0
- package/src/components/Modal/Modal.tsx +29 -0
- package/src/components/Modal/index.tsx +1 -0
- package/src/components/Modal/types.ts +7 -0
- package/src/components/MonthPicker/Month.styled.tsx +11 -0
- package/src/components/MonthPicker/MonthPicker.tsx +35 -0
- package/src/components/MonthPicker/MonthPicker.types.ts +4 -0
- package/src/components/MonthPicker/index.ts +1 -0
- package/src/components/RenderCalendar/RenderCalendar.tsx +31 -0
- package/src/components/RenderCalendar/RenderCalendar.types.ts +10 -0
- package/src/components/RenderCalendar/index.ts +1 -0
- package/src/components/YearPicker/YearPicker.styled.tsx +14 -0
- package/src/components/YearPicker/YearPicker.tsx +49 -0
- package/src/components/YearPicker/YearPicker.types.ts +4 -0
- package/src/components/YearPicker/index.ts +1 -0
- package/src/constants.ts +6 -0
- package/src/hooks/__tests__/useClickOutside.test.tsx +32 -0
- package/src/hooks/useCalendarHandlers.tsx +113 -0
- package/src/hooks/useClickOutside.tsx +23 -0
- package/src/hooks/useSlideCalendar.tsx +95 -0
- package/src/hooks/useTimePicker.tsx +95 -0
- package/src/index.tsx +4 -0
- package/src/packages/Calendar/Calendar.styled.tsx +42 -0
- package/src/packages/Calendar/Calendar.tsx +159 -0
- package/src/packages/Calendar/Calendar.types.ts +31 -0
- package/src/packages/Calendar/CalendarComponent.cy.tsx +69 -0
- package/src/packages/Calendar/index.ts +2 -0
- package/src/packages/CalendarProvider/CalendarProvider.tsx +30 -0
- package/src/packages/CalendarProvider/CalendarProvider.types.ts +6 -0
- package/src/packages/CalendarProvider/index.ts +2 -0
- package/src/packages/DatePicker/DatePicker.cy.tsx +54 -0
- package/src/packages/DatePicker/DatePicker.tsx +127 -0
- package/src/packages/DatePicker/DatePicker.types.ts +26 -0
- package/src/packages/DatePicker/index.ts +2 -0
- package/src/packages/TimePicker/TimePicker.styled.tsx +77 -0
- package/src/packages/TimePicker/TimePicker.tsx +121 -0
- package/src/packages/TimePicker/TimePicker.types.ts +16 -0
- package/src/packages/TimePicker/components/Numbers/Numbers.styled.tsx +36 -0
- package/src/packages/TimePicker/components/Numbers/Numbers.tsx +58 -0
- package/src/packages/TimePicker/components/Numbers/Numbers.types.ts +14 -0
- package/src/packages/TimePicker/components/Numbers/index.ts +1 -0
- package/src/packages/TimePicker/index.ts +2 -0
- package/src/style/animation.ts +23 -0
- package/src/style/classNames.ts +8 -0
- package/src/style/colorPallete.ts +16 -0
- package/src/style/colors.ts +15 -0
- package/src/style/hexToHSL.ts +52 -0
- package/src/style/radius.ts +28 -0
- package/src/types.ts +75 -0
- package/src/utils/dateHelper/dateHelper.ts +67 -0
- package/src/utils/dateHelper/index.ts +1 -0
- package/src/utils/dateTimeFormat/dateTimeFormat.ts +43 -0
- package/src/utils/dateTimeFormat/index.ts +1 -0
- package/src/utils/format/format.test.ts +37 -0
- package/src/utils/format/format.ts +56 -0
- package/src/utils/format/format.types.ts +11 -0
- package/src/utils/format/index.ts +1 -0
- package/src/utils/index.ts +21 -0
- package/src/utils/locale.ts +13 -0
- package/src/utils/locales/en.ts +89 -0
- package/src/utils/locales/fa.ts +89 -0
- package/src/utils/locales/index.ts +10 -0
- package/src/utils/locales/locales.types.ts +11 -0
- package/src/utils/month/index.ts +1 -0
- package/src/utils/month/month.ts +54 -0
- package/src/utils/month/month.types.ts +11 -0
- package/src/utils/timePicker.ts +107 -0
- package/src/utils/type.ts +0 -0
- package/tsconfig.json +22 -0
- package/tsconfig.test.json +7 -0
- 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
|
+
}
|