wini-web-components 2.8.4 → 2.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js.js +11 -11
- package/dist/index.js.mjs +745 -882
- package/global.d.ts +6 -0
- package/package.json +3 -4
- package/dist/component/button/button.d.ts +0 -22
- package/dist/component/button/button.d.ts.map +0 -1
- package/dist/component/calendar/calendar.d.ts +0 -31
- package/dist/component/calendar/calendar.d.ts.map +0 -1
- package/dist/component/carousel/carousel.d.ts +0 -32
- package/dist/component/carousel/carousel.d.ts.map +0 -1
- package/dist/component/checkbox/checkbox.d.ts +0 -25
- package/dist/component/checkbox/checkbox.d.ts.map +0 -1
- package/dist/component/ck-editor/ckeditor.d.ts +0 -36
- package/dist/component/ck-editor/ckeditor.d.ts.map +0 -1
- package/dist/component/component-status.d.ts +0 -8
- package/dist/component/component-status.d.ts.map +0 -1
- package/dist/component/date-time-picker/date-time-picker.d.ts +0 -36
- package/dist/component/date-time-picker/date-time-picker.d.ts.map +0 -1
- package/dist/component/dialog/dialog.d.ts +0 -18
- package/dist/component/dialog/dialog.d.ts.map +0 -1
- package/dist/component/import-file/import-file.d.ts +0 -34
- package/dist/component/import-file/import-file.d.ts.map +0 -1
- package/dist/component/infinite-scroll/infinite-scroll.d.ts +0 -18
- package/dist/component/infinite-scroll/infinite-scroll.d.ts.map +0 -1
- package/dist/component/input-multi-select/input-multi-select.d.ts +0 -22
- package/dist/component/input-multi-select/input-multi-select.d.ts.map +0 -1
- package/dist/component/input-otp/input-otp.d.ts +0 -23
- package/dist/component/input-otp/input-otp.d.ts.map +0 -1
- package/dist/component/number-picker/number-picker.d.ts +0 -24
- package/dist/component/number-picker/number-picker.d.ts.map +0 -1
- package/dist/component/pagination/pagination.d.ts +0 -14
- package/dist/component/pagination/pagination.d.ts.map +0 -1
- package/dist/component/popup/popup.d.ts +0 -40
- package/dist/component/popup/popup.d.ts.map +0 -1
- package/dist/component/progress-bar/progress-bar.d.ts +0 -16
- package/dist/component/progress-bar/progress-bar.d.ts.map +0 -1
- package/dist/component/progress-circle/progress-circle.d.ts +0 -13
- package/dist/component/progress-circle/progress-circle.d.ts.map +0 -1
- package/dist/component/radio-button/radio-button.d.ts +0 -21
- package/dist/component/radio-button/radio-button.d.ts.map +0 -1
- package/dist/component/rating/rating.d.ts +0 -24
- package/dist/component/rating/rating.d.ts.map +0 -1
- package/dist/component/select1/select1.d.ts +0 -32
- package/dist/component/select1/select1.d.ts.map +0 -1
- package/dist/component/switch/switch.d.ts +0 -24
- package/dist/component/switch/switch.d.ts.map +0 -1
- package/dist/component/table/table.d.ts +0 -51
- package/dist/component/table/table.d.ts.map +0 -1
- package/dist/component/tag/tag.d.ts +0 -23
- package/dist/component/tag/tag.d.ts.map +0 -1
- package/dist/component/text/text.d.ts +0 -16
- package/dist/component/text/text.d.ts.map +0 -1
- package/dist/component/text-area/text-area.d.ts +0 -28
- package/dist/component/text-area/text-area.d.ts.map +0 -1
- package/dist/component/text-field/text-field.d.ts +0 -37
- package/dist/component/text-field/text-field.d.ts.map +0 -1
- package/dist/component/toast-noti/toast-noti.d.ts +0 -5
- package/dist/component/toast-noti/toast-noti.d.ts.map +0 -1
- package/dist/component/wini-icon/winicon.d.ts +0 -27
- package/dist/component/wini-icon/winicon.d.ts.map +0 -1
- package/dist/form/login/view.d.ts +0 -41
- package/dist/form/login/view.d.ts.map +0 -1
- package/dist/index.d.ts +0 -34
- package/dist/index.d.ts.map +0 -1
- package/dist/language/i18n.d.ts +0 -3
- package/dist/language/i18n.d.ts.map +0 -1
- package/src/component/button/button.module.css +0 -210
- package/src/component/button/button.tsx +0 -57
- package/src/component/calendar/calendar.module.css +0 -153
- package/src/component/calendar/calendar.tsx +0 -389
- package/src/component/carousel/carousel.css +0 -622
- package/src/component/carousel/carousel.tsx +0 -91
- package/src/component/checkbox/checkbox.module.css +0 -48
- package/src/component/checkbox/checkbox.tsx +0 -80
- package/src/component/ck-editor/ck-editor.css +0 -206
- package/src/component/ck-editor/ckeditor.tsx +0 -522
- package/src/component/component-status.tsx +0 -53
- package/src/component/date-time-picker/date-time-picker.module.css +0 -94
- package/src/component/date-time-picker/date-time-picker.tsx +0 -663
- package/src/component/dialog/dialog.module.css +0 -111
- package/src/component/dialog/dialog.tsx +0 -109
- package/src/component/import-file/import-file.module.css +0 -83
- package/src/component/import-file/import-file.tsx +0 -174
- package/src/component/infinite-scroll/infinite-scroll.module.css +0 -34
- package/src/component/infinite-scroll/infinite-scroll.tsx +0 -35
- package/src/component/input-multi-select/input-multi-select.module.css +0 -121
- package/src/component/input-multi-select/input-multi-select.tsx +0 -263
- package/src/component/input-otp/input-otp.module.css +0 -41
- package/src/component/input-otp/input-otp.tsx +0 -110
- package/src/component/number-picker/number-picker.module.css +0 -137
- package/src/component/number-picker/number-picker.tsx +0 -107
- package/src/component/pagination/pagination.module.css +0 -48
- package/src/component/pagination/pagination.tsx +0 -88
- package/src/component/popup/popup.css +0 -136
- package/src/component/popup/popup.tsx +0 -125
- package/src/component/progress-bar/progress-bar.module.css +0 -42
- package/src/component/progress-bar/progress-bar.tsx +0 -33
- package/src/component/progress-circle/progress-circle.css +0 -0
- package/src/component/progress-circle/progress-circle.tsx +0 -25
- package/src/component/radio-button/radio-button.module.css +0 -51
- package/src/component/radio-button/radio-button.tsx +0 -60
- package/src/component/rating/rating.module.css +0 -11
- package/src/component/rating/rating.tsx +0 -65
- package/src/component/select1/select1.module.css +0 -108
- package/src/component/select1/select1.tsx +0 -271
- package/src/component/switch/switch.module.css +0 -53
- package/src/component/switch/switch.tsx +0 -68
- package/src/component/table/table.css +0 -74
- package/src/component/table/table.tsx +0 -108
- package/src/component/tag/tag.module.css +0 -108
- package/src/component/tag/tag.tsx +0 -31
- package/src/component/text/text.css +0 -27
- package/src/component/text/text.tsx +0 -24
- package/src/component/text-area/text-area.module.css +0 -57
- package/src/component/text-area/text-area.tsx +0 -65
- package/src/component/text-field/text-field.module.css +0 -71
- package/src/component/text-field/text-field.tsx +0 -102
- package/src/component/toast-noti/toast-noti.css +0 -866
- package/src/component/toast-noti/toast-noti.tsx +0 -22
- package/src/component/wini-icon/winicon.module.css +0 -110
- package/src/component/wini-icon/winicon.tsx +0 -9424
- package/src/form/login/view.module.css +0 -80
- package/src/form/login/view.tsx +0 -138
- package/src/global.d.ts +0 -5
- package/src/index.tsx +0 -66
- package/src/language/i18n.tsx +0 -143
- package/src/skin/layout.css +0 -649
- package/src/skin/root.css +0 -294
- package/src/skin/typography.css +0 -314
- package/src/vite-env.d.ts +0 -1
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties, ReactNode, useEffect, useRef } from 'react';
|
|
2
|
-
import { Text } from '../text/text';
|
|
3
|
-
import styles from './button.module.css'
|
|
4
|
-
|
|
5
|
-
interface ButtonProps {
|
|
6
|
-
id?: string,
|
|
7
|
-
label: string,
|
|
8
|
-
prefix?: ReactNode,
|
|
9
|
-
suffix?: ReactNode,
|
|
10
|
-
disabled?: boolean,
|
|
11
|
-
linkTo?: string,
|
|
12
|
-
target?: string,
|
|
13
|
-
style?: CSSProperties,
|
|
14
|
-
type?: "button" | "reset" | "submit",
|
|
15
|
-
/**
|
|
16
|
-
* default: size32: button-text-3 \
|
|
17
|
-
* recommend: size64: button-text-1 | size56: button-text-1 | size48: button-text-1 | size40: button-text-3 | size32: button-text-3 | size24: button-text-5 \
|
|
18
|
-
* status button: button-primary | button-infor | button-warning | button-error | button-success | button-grey | button-neutral | button-infor-main | button-warning-main | button-error-main | button-success-main
|
|
19
|
-
* */
|
|
20
|
-
className?: string,
|
|
21
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function Button(props: ButtonProps) {
|
|
25
|
-
const btnRef = useRef<HTMLButtonElement>(null)
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (btnRef.current) {
|
|
29
|
-
switch (props.type) {
|
|
30
|
-
case "submit":
|
|
31
|
-
function handleSubmit(ev: any) {
|
|
32
|
-
switch (ev.key.toLowerCase()) {
|
|
33
|
-
case "enter":
|
|
34
|
-
btnRef.current!.click()
|
|
35
|
-
break;
|
|
36
|
-
default:
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
window.addEventListener("keydown", handleSubmit)
|
|
41
|
-
return () => { window.removeEventListener("keydown", handleSubmit) }
|
|
42
|
-
default:
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}, [props.type, btnRef.current])
|
|
47
|
-
|
|
48
|
-
return props.linkTo ? <a id={props.id} href={props.disabled ? undefined : props.linkTo} target={props.target} className={`${styles['button-container']} row ${props.className ?? "button-text-3"}`} style={props.style} onClick={props.onClick}>
|
|
49
|
-
{props.prefix}
|
|
50
|
-
<Text maxLine={1} className={styles['button-label']}>{props.label}</Text>
|
|
51
|
-
{props.suffix}
|
|
52
|
-
</a> : <button ref={btnRef} id={props.id} type={props.type ?? "button"} disabled={props.disabled} className={`${styles['button-container']} row ${props.className ?? "button-text-3"}`} style={props.style} onClick={props.onClick}>
|
|
53
|
-
{props.prefix}
|
|
54
|
-
<Text maxLine={1} className={styles['button-label']}>{props.label}</Text>
|
|
55
|
-
{props.suffix}
|
|
56
|
-
</button>
|
|
57
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
.calendar-container {
|
|
2
|
-
background-color: var(--neutral-absolute-background-color);
|
|
3
|
-
border-radius: 0.8rem;
|
|
4
|
-
align-items: stretch;
|
|
5
|
-
border: var(--neutral-main-border);
|
|
6
|
-
width: fit-content;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.calendar-sidebar-options {
|
|
10
|
-
padding: 0.8rem 2.4rem 0.8rem 0;
|
|
11
|
-
border-right: var(--neutral-main-border);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.calendar-sidebar-options>.calendar-sidebar-option-buttton {
|
|
15
|
-
color: var(--neutral-text-title-color);
|
|
16
|
-
padding: 0.8rem 1.6rem;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.picker-time-container {
|
|
20
|
-
border-left: var(--neutral-main-border);
|
|
21
|
-
height: 34.2rem;
|
|
22
|
-
align-items: center;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.picker-time-container>div[class*="heading-7"]:first-child {
|
|
26
|
-
width: 100%;
|
|
27
|
-
padding: 1.2rem 1.6rem;
|
|
28
|
-
border-bottom: var(--neutral-main-border);
|
|
29
|
-
text-align: center;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.picker-time-container div[class*="scroll-picker-"] {
|
|
33
|
-
flex: 1;
|
|
34
|
-
height: 100%;
|
|
35
|
-
gap: 0.4rem;
|
|
36
|
-
padding: 0.4rem 0;
|
|
37
|
-
overflow: hidden auto;
|
|
38
|
-
scrollbar-width: thin;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.picker-time-container .scroll-picker-minutes {
|
|
42
|
-
border-left: var(--neutral-main-border);
|
|
43
|
-
border-right: var(--neutral-main-border);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.picker-time-container div[class*="scroll-picker-"]>button {
|
|
47
|
-
width: 5.6rem;
|
|
48
|
-
padding: 0.4rem 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.picker-time-container div[class*="scroll-picker-"]>button.selected {
|
|
52
|
-
background-color: var(--primary-background);
|
|
53
|
-
color: var(--primary-main-color);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.picker-date-header {
|
|
57
|
-
padding: 1.2rem 1.6rem;
|
|
58
|
-
gap: 1.2rem;
|
|
59
|
-
background-color: transparent !important;
|
|
60
|
-
border-bottom: var(--neutral-main-border);
|
|
61
|
-
justify-content: space-between;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.picker-date-header>span {
|
|
65
|
-
width: 100%;
|
|
66
|
-
max-width: 15rem;
|
|
67
|
-
flex: 1;
|
|
68
|
-
text-align: center;
|
|
69
|
-
cursor: pointer;
|
|
70
|
-
border-radius: 0.8rem;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.picker-date-header>span:hover {
|
|
74
|
-
background-color: var(--neutral-hover-background-color);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.picker-date-header>button {
|
|
78
|
-
width: 1.6rem;
|
|
79
|
-
height: 1.6rem;
|
|
80
|
-
display: flex;
|
|
81
|
-
align-items: center;
|
|
82
|
-
justify-content: center;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.picker-date-header>button>svg {
|
|
86
|
-
font-size: 1.4rem;
|
|
87
|
-
color: var(--neutral-text-title-color);
|
|
88
|
-
pointer-events: none;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.picker-date-body {
|
|
92
|
-
padding: 1.2rem 1.6rem;
|
|
93
|
-
width: 31.2rem;
|
|
94
|
-
flex-wrap: wrap;
|
|
95
|
-
gap: 0.8rem 0;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
.picker-date-body>div {
|
|
99
|
-
height: 3.2rem;
|
|
100
|
-
padding: 0 0.4rem;
|
|
101
|
-
display: flex;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.picker-date-body>div>* {
|
|
105
|
-
border: 1px solid transparent;
|
|
106
|
-
justify-content: center;
|
|
107
|
-
height: 100%;
|
|
108
|
-
width: 100%;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.date-picker-circle {
|
|
112
|
-
width: calc(100% / 7);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
.date-picker-circle>* {
|
|
116
|
-
border-radius: 50%;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.month-picker-circle,
|
|
120
|
-
.year-picker-circle {
|
|
121
|
-
width: calc(100% / 3);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
.month-picker-circle>*,
|
|
125
|
-
.year-picker-circle>* {
|
|
126
|
-
border-radius: 2.4rem;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.picker-date-body>.in-range {
|
|
130
|
-
background-color: var(--neutral-main-background-color);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.picker-date-body:has(>.in-range, >.end-range)>.start-range {
|
|
134
|
-
background-image: linear-gradient(to right, transparent 50%, var(--neutral-main-background-color) 50%);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.end-range {
|
|
138
|
-
background-image: linear-gradient(to left, transparent 50%, var(--neutral-main-background-color) 50%) !important;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.picker-date-body>.today>* {
|
|
142
|
-
border-color: var(--primary-main-color)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.picker-date-body>.selected>* {
|
|
146
|
-
background-color: var(--primary-main-color);
|
|
147
|
-
color: var(--neutral-absolute-background-color);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.picker-date-body>.invalid {
|
|
151
|
-
opacity: 0.24 !important;
|
|
152
|
-
pointer-events: none !important;
|
|
153
|
-
}
|
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
import React, { CSSProperties, ReactNode } from "react"
|
|
2
|
-
import styles from './calendar.module.css'
|
|
3
|
-
import { differenceInCalendarDays } from "date-fns"
|
|
4
|
-
import { WithTranslation, withTranslation } from 'react-i18next';
|
|
5
|
-
import { Winicon } from "../wini-icon/winicon";
|
|
6
|
-
|
|
7
|
-
export const today = new Date()
|
|
8
|
-
export const startDate = new Date(
|
|
9
|
-
today.getFullYear() - 100,
|
|
10
|
-
today.getMonth(),
|
|
11
|
-
today.getDate()
|
|
12
|
-
)
|
|
13
|
-
export const endDate = new Date(
|
|
14
|
-
today.getFullYear() + 100,
|
|
15
|
-
today.getMonth(),
|
|
16
|
-
today.getDate()
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
export const inRangeTime = (date: Date, startDate: Date, endDate: Date) => (differenceInCalendarDays(date, startDate) > -1 && differenceInCalendarDays(endDate, date) > -1)
|
|
20
|
-
|
|
21
|
-
enum CalendarTab {
|
|
22
|
-
DATE = 0,
|
|
23
|
-
MONTH = 1,
|
|
24
|
-
YEAR = 2,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface CalendarProps extends WithTranslation {
|
|
28
|
-
id?: string,
|
|
29
|
-
value?: Date | { sTime: Date, eTime: Date },
|
|
30
|
-
range?: boolean,
|
|
31
|
-
min?: Date,
|
|
32
|
-
max?: Date,
|
|
33
|
-
onSelect?: (props: Date | { sTime: Date, eTime: Date }) => void,
|
|
34
|
-
disabled?: boolean,
|
|
35
|
-
helperText?: string,
|
|
36
|
-
helperTextColor?: string,
|
|
37
|
-
placeholder?: string,
|
|
38
|
-
className?: string,
|
|
39
|
-
style?: CSSProperties,
|
|
40
|
-
header?: ReactNode,
|
|
41
|
-
footer?: ReactNode,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
interface CalendarState {
|
|
45
|
-
value?: Date | { sTime: Date, eTime: Date },
|
|
46
|
-
selectMonth: number,
|
|
47
|
-
selectYear: number,
|
|
48
|
-
tab: CalendarTab,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const stateValue = (minDate: Date, maxDate: Date, value?: Date | { sTime: Date, eTime: Date }, range?: boolean) => {
|
|
52
|
-
let defaultValue: Date | { sTime: Date, eTime: Date }
|
|
53
|
-
if (value) {
|
|
54
|
-
if (range) {
|
|
55
|
-
if (value instanceof Date) defaultValue = { sTime: value, eTime: value }
|
|
56
|
-
else defaultValue = value
|
|
57
|
-
if (defaultValue.sTime.getTime() < minDate.getTime()) defaultValue.sTime = minDate
|
|
58
|
-
if (defaultValue.eTime.getTime() > maxDate.getTime()) defaultValue.eTime = maxDate
|
|
59
|
-
} else {
|
|
60
|
-
if (value instanceof Date) defaultValue = value
|
|
61
|
-
else defaultValue = value.sTime
|
|
62
|
-
if (defaultValue.getTime() < minDate.getTime()) defaultValue = minDate
|
|
63
|
-
if (defaultValue.getTime() > maxDate.getTime()) defaultValue = maxDate
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
defaultValue = range ? { sTime: today, eTime: today } : today
|
|
67
|
-
}
|
|
68
|
-
const defaultMonth = defaultValue instanceof Date ? defaultValue.getMonth() : defaultValue.sTime.getMonth()
|
|
69
|
-
const defaultYear = defaultValue instanceof Date ? defaultValue.getFullYear() : defaultValue.sTime.getFullYear()
|
|
70
|
-
return {
|
|
71
|
-
value: value ? defaultValue : undefined,
|
|
72
|
-
selectMonth: defaultMonth,
|
|
73
|
-
selectYear: defaultYear,
|
|
74
|
-
tab: CalendarTab.DATE,
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
class TCalendar extends React.Component<CalendarProps, CalendarState> {
|
|
79
|
-
private minDate: Date;
|
|
80
|
-
private maxDate: Date;
|
|
81
|
-
constructor(props: CalendarProps) {
|
|
82
|
-
super(props);
|
|
83
|
-
this.minDate = !this.props.min || this.props.min.getTime() < startDate.getTime() ? startDate : this.props.min
|
|
84
|
-
this.maxDate = !this.props.max || this.props.max.getTime() > endDate.getTime() ? endDate : this.props.max
|
|
85
|
-
this.state = stateValue(this.minDate, this.maxDate, this.props.value, this.props.range)
|
|
86
|
-
this.showDateInMonth = this.showDateInMonth.bind(this)
|
|
87
|
-
this.showMonthInYear = this.showMonthInYear.bind(this)
|
|
88
|
-
this.showYearInRange = this.showYearInRange.bind(this)
|
|
89
|
-
this.getTitle = this.getTitle.bind(this)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
componentDidUpdate(prevProps: Readonly<CalendarProps>, prevState: Readonly<CalendarState>, snapshot?: any): void {
|
|
93
|
-
if (prevProps.value !== this.props.value) {
|
|
94
|
-
this.setState(stateValue(this.minDate, this.maxDate, this.props.value, this.props.range))
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
private showDateInMonth() {
|
|
99
|
-
let firstDayOfMonth = new Date(this.state.selectYear, this.state.selectMonth, 1)
|
|
100
|
-
return <>
|
|
101
|
-
{Array.from({ length: 7 }).map((_, i) => {
|
|
102
|
-
switch (i) {
|
|
103
|
-
case 0:
|
|
104
|
-
var weekdayTitle = this.props.t("su")
|
|
105
|
-
break
|
|
106
|
-
case 1:
|
|
107
|
-
weekdayTitle = this.props.t("mo")
|
|
108
|
-
break
|
|
109
|
-
case 2:
|
|
110
|
-
weekdayTitle = this.props.t("tu")
|
|
111
|
-
break
|
|
112
|
-
case 3:
|
|
113
|
-
weekdayTitle = this.props.t("we")
|
|
114
|
-
break
|
|
115
|
-
case 4:
|
|
116
|
-
weekdayTitle = this.props.t("th")
|
|
117
|
-
break
|
|
118
|
-
case 5:
|
|
119
|
-
weekdayTitle = this.props.t("fr")
|
|
120
|
-
break
|
|
121
|
-
case 6:
|
|
122
|
-
weekdayTitle = this.props.t("sa")
|
|
123
|
-
break
|
|
124
|
-
default:
|
|
125
|
-
weekdayTitle = ''
|
|
126
|
-
break
|
|
127
|
-
}
|
|
128
|
-
return <div key={'dtwk-' + i} className={`${styles['date-picker-circle']} date-picker-circle`}><span className="label-4 row">{weekdayTitle}</span></div>
|
|
129
|
-
})}
|
|
130
|
-
{Array.from({ length: 42 }).map((_, i) => {
|
|
131
|
-
let dateNumber = (i % 7) + (Math.floor(i / 7) * 7) - firstDayOfMonth.getDay()
|
|
132
|
-
const timeValue = new Date(this.state.selectYear, this.state.selectMonth, dateNumber + 1)
|
|
133
|
-
let className = `${styles['date-picker-circle']} date-picker-circle`
|
|
134
|
-
let typoClassName = "body-3"
|
|
135
|
-
if (dateNumber + 1 === today.getDate() && this.state.selectMonth === today.getMonth() && this.state.selectYear === today.getFullYear()) {
|
|
136
|
-
className += ` ${styles['today']}`
|
|
137
|
-
}
|
|
138
|
-
let style: CSSProperties | undefined;
|
|
139
|
-
if (!inRangeTime(timeValue, this.minDate, this.maxDate)) {
|
|
140
|
-
className += ` ${styles['invalid']}`
|
|
141
|
-
} else if (this.state.value instanceof Date) {
|
|
142
|
-
if (this.state.value.getTime() === timeValue.getTime()) className += ` ${styles['selected']}`
|
|
143
|
-
} else if ((this.state.value?.sTime.getDate() === timeValue.getDate() && (Math.abs(differenceInCalendarDays(timeValue, this.state.value.sTime))) < 1) || (this.state.value?.eTime.getDate() === timeValue.getDate() && (Math.abs(differenceInCalendarDays(timeValue, this.state.value.eTime))) < 1)) {
|
|
144
|
-
className += ` ${styles['selected']} ${styles[`${this.state.value?.sTime.getDate() === timeValue.getDate() && (Math.abs(differenceInCalendarDays(timeValue, this.state.value.sTime))) < 1 ? "start" : "end"}-range`]}`
|
|
145
|
-
} else if (this.state.value && inRangeTime(timeValue, this.state.value.sTime, this.state.value.eTime)) {
|
|
146
|
-
className += ` ${styles['in-range']}`
|
|
147
|
-
}
|
|
148
|
-
if (timeValue.getMonth() !== this.state.selectMonth) {
|
|
149
|
-
typoClassName = "placeholder-2"
|
|
150
|
-
}
|
|
151
|
-
return <div key={timeValue.toString()} className={className} style={style}>
|
|
152
|
-
<button type="button" className={`${typoClassName} row`}
|
|
153
|
-
onClick={() => {
|
|
154
|
-
const currentValue = this.state.value as any
|
|
155
|
-
if (this.props.range) {
|
|
156
|
-
const newValue = (!currentValue || timeValue.getTime() < currentValue.sTime.getTime()) ? { sTime: timeValue, eTime: timeValue } : { sTime: currentValue.sTime, eTime: timeValue }
|
|
157
|
-
this.setState({ ...this.state, value: newValue })
|
|
158
|
-
if (this.props.onSelect) this.props.onSelect(newValue)
|
|
159
|
-
} else {
|
|
160
|
-
this.setState({ ...this.state, value: timeValue })
|
|
161
|
-
if (this.props.onSelect) this.props.onSelect(timeValue)
|
|
162
|
-
}
|
|
163
|
-
}} >
|
|
164
|
-
{timeValue.getDate()}
|
|
165
|
-
</button>
|
|
166
|
-
</div>
|
|
167
|
-
})}
|
|
168
|
-
</>
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
private showMonthInYear() {
|
|
172
|
-
return <>
|
|
173
|
-
{Array.from({ length: 12 }).map((_, i) => {
|
|
174
|
-
switch (i) {
|
|
175
|
-
case 0:
|
|
176
|
-
var monthTitle = this.props.i18n.language === "en" ? "Jan" : this.props.t('january')
|
|
177
|
-
break
|
|
178
|
-
case 1:
|
|
179
|
-
monthTitle = this.props.i18n.language === "en" ? "Feb" : this.props.t('february')
|
|
180
|
-
break
|
|
181
|
-
case 2:
|
|
182
|
-
monthTitle = this.props.i18n.language === "en" ? "Mar" : this.props.t('march')
|
|
183
|
-
break
|
|
184
|
-
case 3:
|
|
185
|
-
monthTitle = this.props.i18n.language === "en" ? "Apr" : this.props.t('april')
|
|
186
|
-
break
|
|
187
|
-
case 4:
|
|
188
|
-
monthTitle = this.props.i18n.language === "en" ? "May" : this.props.t('may')
|
|
189
|
-
break
|
|
190
|
-
case 5:
|
|
191
|
-
monthTitle = this.props.i18n.language === "en" ? "Jun" : this.props.t('june')
|
|
192
|
-
break
|
|
193
|
-
case 6:
|
|
194
|
-
monthTitle = this.props.i18n.language === "en" ? "Jul" : this.props.t('july')
|
|
195
|
-
break
|
|
196
|
-
case 7:
|
|
197
|
-
monthTitle = this.props.i18n.language === "en" ? "Aug" : this.props.t('august')
|
|
198
|
-
break
|
|
199
|
-
case 8:
|
|
200
|
-
monthTitle = this.props.i18n.language === "en" ? "Sep" : this.props.t('september')
|
|
201
|
-
break
|
|
202
|
-
case 9:
|
|
203
|
-
monthTitle = this.props.i18n.language === "en" ? "Oct" : this.props.t('october')
|
|
204
|
-
break
|
|
205
|
-
case 10:
|
|
206
|
-
monthTitle = this.props.i18n.language === "en" ? "Nov" : this.props.t('november')
|
|
207
|
-
break
|
|
208
|
-
case 11:
|
|
209
|
-
monthTitle = this.props.i18n.language === "en" ? "Dec" : this.props.t('december')
|
|
210
|
-
break
|
|
211
|
-
default:
|
|
212
|
-
monthTitle = ''
|
|
213
|
-
break
|
|
214
|
-
}
|
|
215
|
-
const timeValue = new Date(this.state.selectYear, i)
|
|
216
|
-
let className = `${styles['month-picker-circle']} month-picker-circle`
|
|
217
|
-
if (this.state.selectYear === today.getFullYear() && today.getMonth() === i) {
|
|
218
|
-
className += ` ${styles['today']}`
|
|
219
|
-
}
|
|
220
|
-
if (!inRangeTime(timeValue, this.minDate, this.maxDate)) {
|
|
221
|
-
className += ` ${styles['invalid']}`
|
|
222
|
-
} else if (this.state.value instanceof Date) {
|
|
223
|
-
if (this.state.selectYear === this.state.value.getFullYear() && i === this.state.value.getMonth()) className += ` ${styles['selected']}`
|
|
224
|
-
} else if (this.state.value && ((i === this.state.value.sTime.getMonth() && this.state.value.sTime.getFullYear() === this.state.selectYear) || (i === this.state.value.eTime.getMonth() && this.state.value.eTime.getFullYear() === this.state.selectYear))) {
|
|
225
|
-
className += ` ${styles['selected']} ${styles[`${i === this.state.value.sTime.getMonth() && this.state.value.sTime.getFullYear() === this.state.selectYear ? "start" : "end"}-range`]}`
|
|
226
|
-
} else if (this.state.value && inRangeTime(timeValue, this.state.value.sTime, this.state.value.eTime)) {
|
|
227
|
-
className += ` ${styles['in-range']}`
|
|
228
|
-
}
|
|
229
|
-
return <div key={timeValue.toString()} className={className}>
|
|
230
|
-
<button type="button" className="body-3 row" onClick={() => { this.setState({ ...this.state, selectMonth: i, tab: CalendarTab.DATE }) }}>
|
|
231
|
-
{monthTitle}
|
|
232
|
-
</button>
|
|
233
|
-
</div>
|
|
234
|
-
})}
|
|
235
|
-
</>
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
private showYearInRange() {
|
|
239
|
-
return Array.from({ length: 12 }).map((_, i) => {
|
|
240
|
-
let firstYearInTable = this.state.selectYear - ((this.state.selectYear - startDate.getFullYear()) % 12)
|
|
241
|
-
let yearNumber = i + firstYearInTable
|
|
242
|
-
let className = `${styles['year-picker-circle']} year-picker-circle`
|
|
243
|
-
if (yearNumber === today.getFullYear()) {
|
|
244
|
-
className += ` ${styles['today']}`
|
|
245
|
-
}
|
|
246
|
-
if (yearNumber < this.minDate.getFullYear() || yearNumber > this.maxDate.getFullYear()) {
|
|
247
|
-
className += ` ${styles['invalid']}`
|
|
248
|
-
} else if (this.state.value instanceof Date) {
|
|
249
|
-
if (yearNumber === this.state.value.getFullYear()) className += ` ${styles['selected']}`
|
|
250
|
-
} else if (yearNumber === this.state.value?.sTime.getFullYear() || yearNumber === this.state.value?.eTime.getFullYear()) {
|
|
251
|
-
className += ` ${styles['selected']} ${styles[`${yearNumber === this.state.value?.sTime.getFullYear() ? "start" : "end"}-range`]}`
|
|
252
|
-
} else if (this.state.value && yearNumber > this.state.value.sTime.getFullYear() && yearNumber < this.state.value.eTime.getFullYear()) {
|
|
253
|
-
className += ` ${styles['in-range']}`
|
|
254
|
-
}
|
|
255
|
-
return <div key={yearNumber.toString()} className={className}>
|
|
256
|
-
<button type="button" className="body-3 row" onClick={() => { this.setState({ ...this.state, tab: CalendarTab.MONTH, selectYear: yearNumber }) }}>
|
|
257
|
-
{yearNumber}
|
|
258
|
-
</button>
|
|
259
|
-
</div>
|
|
260
|
-
})
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
private getTitle() {
|
|
264
|
-
switch (this.state.tab) {
|
|
265
|
-
case CalendarTab.YEAR:
|
|
266
|
-
let firstYearInTable = this.state.selectYear - ((this.state.selectYear - startDate.getFullYear()) % 12)
|
|
267
|
-
return `${firstYearInTable}-${firstYearInTable + 11}`
|
|
268
|
-
case CalendarTab.MONTH:
|
|
269
|
-
return this.state.selectYear
|
|
270
|
-
default:
|
|
271
|
-
switch (this.state.selectMonth) {
|
|
272
|
-
case 0:
|
|
273
|
-
var monthName = this.props.t('january')
|
|
274
|
-
break
|
|
275
|
-
case 1:
|
|
276
|
-
monthName = this.props.t('february')
|
|
277
|
-
break
|
|
278
|
-
case 2:
|
|
279
|
-
monthName = this.props.t('march')
|
|
280
|
-
break
|
|
281
|
-
case 3:
|
|
282
|
-
monthName = this.props.t('april')
|
|
283
|
-
break
|
|
284
|
-
case 4:
|
|
285
|
-
monthName = this.props.t('may')
|
|
286
|
-
break
|
|
287
|
-
case 5:
|
|
288
|
-
monthName = this.props.t('june')
|
|
289
|
-
break
|
|
290
|
-
case 6:
|
|
291
|
-
monthName = this.props.t('july')
|
|
292
|
-
break
|
|
293
|
-
case 7:
|
|
294
|
-
monthName = this.props.t('august')
|
|
295
|
-
break
|
|
296
|
-
case 8:
|
|
297
|
-
monthName = this.props.t('september')
|
|
298
|
-
break
|
|
299
|
-
case 9:
|
|
300
|
-
monthName = this.props.t('october')
|
|
301
|
-
break
|
|
302
|
-
case 10:
|
|
303
|
-
monthName = this.props.t('november')
|
|
304
|
-
break
|
|
305
|
-
case 11:
|
|
306
|
-
monthName = this.props.t('december')
|
|
307
|
-
break
|
|
308
|
-
default:
|
|
309
|
-
monthName = ''
|
|
310
|
-
break
|
|
311
|
-
}
|
|
312
|
-
return `${monthName}${this.props.i18n.language === 'en' ? ' ' : '/'}${this.state.selectYear}`
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
render(): React.ReactNode {
|
|
317
|
-
return <div className={`${styles['calendar-container']} col ${this.props.className ?? ""}`} style={this.props.style}>
|
|
318
|
-
{this.props.header}
|
|
319
|
-
<div className={`${styles['picker-date-header']} row`}>
|
|
320
|
-
<button type='button'
|
|
321
|
-
onClick={() => {
|
|
322
|
-
switch (this.state.tab) {
|
|
323
|
-
case CalendarTab.YEAR:
|
|
324
|
-
if (this.state.selectYear - 10 < startDate.getFullYear()) {
|
|
325
|
-
this.setState({ ...this.state, selectYear: startDate.getFullYear() })
|
|
326
|
-
} else {
|
|
327
|
-
this.setState({ ...this.state, selectYear: this.state.selectYear - 10 })
|
|
328
|
-
}
|
|
329
|
-
break
|
|
330
|
-
case CalendarTab.MONTH:
|
|
331
|
-
const newTime = new Date(this.state.selectYear, this.state.selectMonth - 1)
|
|
332
|
-
if (newTime.getTime() >= startDate.getTime()) {
|
|
333
|
-
this.setState({ ...this.state, selectYear: this.state.selectYear - 1 })
|
|
334
|
-
}
|
|
335
|
-
break
|
|
336
|
-
default:
|
|
337
|
-
const newDataVl = new Date(this.state.selectYear, this.state.selectMonth - 1)
|
|
338
|
-
if (newDataVl.getTime() >= startDate.getTime()) {
|
|
339
|
-
this.setState({ ...this.state, selectMonth: newDataVl.getMonth(), selectYear: newDataVl.getFullYear() })
|
|
340
|
-
}
|
|
341
|
-
break
|
|
342
|
-
}
|
|
343
|
-
}}
|
|
344
|
-
>
|
|
345
|
-
<Winicon src={"fill/arrows/left-arrow"} size={'1.4rem'} />
|
|
346
|
-
</button>
|
|
347
|
-
<span className="heading-7" onClick={() => {
|
|
348
|
-
if (this.state.tab !== CalendarTab.YEAR)
|
|
349
|
-
this.setState({ ...this.state, tab: this.state.tab === CalendarTab.DATE ? CalendarTab.MONTH : CalendarTab.YEAR })
|
|
350
|
-
}}>
|
|
351
|
-
{this.getTitle()}
|
|
352
|
-
</span>
|
|
353
|
-
<button type='button'
|
|
354
|
-
onClick={() => {
|
|
355
|
-
switch (this.state.tab) {
|
|
356
|
-
case CalendarTab.YEAR:
|
|
357
|
-
if (this.state.selectYear + 10 > endDate.getFullYear()) {
|
|
358
|
-
this.setState({ ...this.state, selectYear: endDate.getFullYear() })
|
|
359
|
-
} else {
|
|
360
|
-
this.setState({ ...this.state, selectYear: this.state.selectYear + 10 })
|
|
361
|
-
}
|
|
362
|
-
break
|
|
363
|
-
case CalendarTab.MONTH:
|
|
364
|
-
const newTime = new Date(this.state.selectYear, this.state.selectMonth + 1)
|
|
365
|
-
if (newTime.getTime() <= endDate.getTime()) {
|
|
366
|
-
this.setState({ ...this.state, selectYear: this.state.selectYear + 1 })
|
|
367
|
-
}
|
|
368
|
-
break
|
|
369
|
-
default:
|
|
370
|
-
const newDataVl = new Date(this.state.selectYear, this.state.selectMonth + 1)
|
|
371
|
-
if (newDataVl.getTime() <= endDate.getTime()) {
|
|
372
|
-
this.setState({ ...this.state, selectMonth: newDataVl.getMonth(), selectYear: newDataVl.getFullYear() })
|
|
373
|
-
}
|
|
374
|
-
break
|
|
375
|
-
}
|
|
376
|
-
}}
|
|
377
|
-
>
|
|
378
|
-
<Winicon src={"fill/arrows/right-arrow"} size={'1.4rem'} />
|
|
379
|
-
</button>
|
|
380
|
-
</div>
|
|
381
|
-
<div className={`${styles['picker-date-body']} row`} >
|
|
382
|
-
{this.state.tab === CalendarTab.YEAR ? this.showYearInRange() : this.state.tab === CalendarTab.MONTH ? this.showMonthInYear() : this.showDateInMonth()}
|
|
383
|
-
</div>
|
|
384
|
-
{this.props.footer}
|
|
385
|
-
</div>
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
export const Calendar = withTranslation()(TCalendar)
|