@pushwoosh/dumb-components 1.0.13 → 1.0.15
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/DateTimePicker/components/AutosizeInput/AutosizeInput.d.ts +3 -0
- package/DateTimePicker/components/AutosizeInput/AutosizeInput.js +35 -0
- package/DateTimePicker/components/AutosizeInput/index.d.ts +1 -0
- package/DateTimePicker/components/AutosizeInput/index.js +1 -0
- package/DateTimePicker/components/AutosizeInput/styles.d.ts +1 -0
- package/DateTimePicker/components/AutosizeInput/styles.js +5 -0
- package/DateTimePicker/components/AutosizeInput/types.d.ts +10 -0
- package/DateTimePicker/components/AutosizeInput/types.js +1 -0
- package/DateTimePicker/components/DatePicker/DatePicker.d.ts +3 -0
- package/DateTimePicker/components/DatePicker/DatePicker.js +54 -0
- package/DateTimePicker/components/DatePicker/index.d.ts +1 -0
- package/DateTimePicker/components/DatePicker/index.js +1 -0
- package/DateTimePicker/components/DatePicker/types.d.ts +10 -0
- package/DateTimePicker/components/DatePicker/types.js +1 -0
- package/DateTimePicker/components/DatePickerField/DatePickerField.d.ts +3 -0
- package/DateTimePicker/components/DatePickerField/DatePickerField.js +59 -0
- package/DateTimePicker/components/DatePickerField/index.d.ts +1 -0
- package/DateTimePicker/components/DatePickerField/index.js +1 -0
- package/DateTimePicker/components/DatePickerField/types.d.ts +8 -0
- package/DateTimePicker/components/DatePickerField/types.js +1 -0
- package/DateTimePicker/components/DateTimePicker/DateTimePicker.d.ts +3 -0
- package/DateTimePicker/components/DateTimePicker/DateTimePicker.js +54 -0
- package/DateTimePicker/components/DateTimePicker/index.d.ts +1 -0
- package/DateTimePicker/components/DateTimePicker/index.js +1 -0
- package/DateTimePicker/components/DateTimePicker/types.d.ts +5 -0
- package/DateTimePicker/components/DateTimePicker/types.js +1 -0
- package/DateTimePicker/components/DateTimePickerField/DateTimePickerField.d.ts +3 -0
- package/DateTimePicker/components/DateTimePickerField/DateTimePickerField.js +67 -0
- package/DateTimePicker/components/DateTimePickerField/helpers.d.ts +8 -0
- package/DateTimePicker/components/DateTimePickerField/helpers.js +13 -0
- package/DateTimePicker/components/DateTimePickerField/index.d.ts +1 -0
- package/DateTimePicker/components/DateTimePickerField/index.js +1 -0
- package/DateTimePicker/components/DateTimePickerField/types.d.ts +8 -0
- package/DateTimePicker/components/DateTimePickerField/types.js +1 -0
- package/DateTimePicker/components/DecadeView/DecadeView.d.ts +3 -0
- package/DateTimePicker/components/DecadeView/DecadeView.js +34 -0
- package/DateTimePicker/components/DecadeView/index.d.ts +1 -0
- package/DateTimePicker/components/DecadeView/index.js +1 -0
- package/DateTimePicker/components/DecadeView/types.d.ts +6 -0
- package/DateTimePicker/components/DecadeView/types.js +1 -0
- package/DateTimePicker/components/Input/Input.d.ts +3 -0
- package/DateTimePicker/components/Input/Input.js +17 -0
- package/DateTimePicker/components/Input/index.d.ts +1 -0
- package/DateTimePicker/components/Input/index.js +1 -0
- package/DateTimePicker/components/Input/styles.d.ts +1 -0
- package/DateTimePicker/components/Input/styles.js +6 -0
- package/DateTimePicker/components/Input/types.d.ts +11 -0
- package/DateTimePicker/components/Input/types.js +1 -0
- package/DateTimePicker/components/Month/Month.d.ts +3 -0
- package/DateTimePicker/components/Month/Month.js +48 -0
- package/DateTimePicker/components/Month/index.d.ts +1 -0
- package/DateTimePicker/components/Month/index.js +1 -0
- package/DateTimePicker/components/Month/types.d.ts +8 -0
- package/DateTimePicker/components/Month/types.js +1 -0
- package/DateTimePicker/components/MonthView/MonthView.d.ts +3 -0
- package/DateTimePicker/components/MonthView/MonthView.js +37 -0
- package/DateTimePicker/components/MonthView/index.d.ts +1 -0
- package/DateTimePicker/components/MonthView/index.js +1 -0
- package/DateTimePicker/components/MonthView/types.d.ts +11 -0
- package/DateTimePicker/components/MonthView/types.js +1 -0
- package/DateTimePicker/components/NumberPicker/NumberPicker.d.ts +3 -0
- package/DateTimePicker/components/NumberPicker/NumberPicker.js +125 -0
- package/DateTimePicker/components/NumberPicker/helpers.d.ts +2 -0
- package/DateTimePicker/components/NumberPicker/helpers.js +5 -0
- package/DateTimePicker/components/NumberPicker/index.d.ts +1 -0
- package/DateTimePicker/components/NumberPicker/index.js +1 -0
- package/DateTimePicker/components/NumberPicker/styles.d.ts +1 -0
- package/DateTimePicker/components/NumberPicker/styles.js +6 -0
- package/DateTimePicker/components/NumberPicker/types.d.ts +13 -0
- package/DateTimePicker/components/NumberPicker/types.js +1 -0
- package/DateTimePicker/components/PickerPlate/PickerPlate.d.ts +3 -0
- package/DateTimePicker/components/PickerPlate/PickerPlate.js +25 -0
- package/DateTimePicker/components/PickerPlate/index.d.ts +1 -0
- package/DateTimePicker/components/PickerPlate/index.js +1 -0
- package/DateTimePicker/components/PickerPlate/styles.d.ts +3 -0
- package/DateTimePicker/components/PickerPlate/styles.js +9 -0
- package/DateTimePicker/components/PickerPlate/types.d.ts +7 -0
- package/DateTimePicker/components/PickerPlate/types.js +1 -0
- package/DateTimePicker/components/YearView/YearView.d.ts +3 -0
- package/DateTimePicker/components/YearView/YearView.js +33 -0
- package/DateTimePicker/components/YearView/index.d.ts +1 -0
- package/DateTimePicker/components/YearView/index.js +1 -0
- package/DateTimePicker/components/YearView/types.d.ts +6 -0
- package/DateTimePicker/components/YearView/types.js +1 -0
- package/DateTimePicker/constants.d.ts +5 -0
- package/DateTimePicker/constants.js +9 -0
- package/DateTimePicker/helpers.d.ts +15 -0
- package/DateTimePicker/helpers.js +79 -0
- package/DateTimePicker/index.d.ts +4 -0
- package/DateTimePicker/index.js +4 -0
- package/DateTimePicker/styles.d.ts +67 -0
- package/DateTimePicker/styles.js +64 -0
- package/DateTimePicker/types.d.ts +6 -0
- package/DateTimePicker/types.js +1 -0
- package/DropdownMenu/components/DropdownMenu/DropdownMenu.js +2 -0
- package/DropdownMenu/components/DropdownMenu/styles.d.ts +1 -0
- package/DropdownMenu/components/DropdownMenu/styles.js +5 -2
- package/DropdownMenu/components/DropdownMenu/types.d.ts +1 -0
- package/DropdownMenu/components/DropdownMenuButton/DropdownMenuButton.js +2 -0
- package/DropdownMenu/components/DropdownMenuButton/types.d.ts +1 -0
- package/DropdownMenu/components/DropdownMenuItem/styles.js +1 -1
- package/Modal/components/ModalContent/index.d.ts +1 -1
- package/Modal/components/ModalContent/index.js +1 -1
- package/Modal/components/ModalContent/{styled.js → styles.js} +5 -5
- package/Radio/Radio.js +1 -1
- package/Radio/{styled.js → styles.js} +2 -2
- package/index.d.ts +2 -1
- package/index.js +2 -1
- package/package.json +1 -1
- /package/Modal/components/ModalContent/{styled.d.ts → styles.d.ts} +0 -0
- /package/Radio/{styled.d.ts → styles.d.ts} +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { addPeriod, format, monthName } from '../../helpers';
|
|
4
|
+
import { DateInfo } from '../../styles';
|
|
5
|
+
import { Month } from '../Month';
|
|
6
|
+
import { PickerPlate } from '../PickerPlate';
|
|
7
|
+
export function MonthView(props) {
|
|
8
|
+
const {
|
|
9
|
+
month,
|
|
10
|
+
activeDay,
|
|
11
|
+
userInputDay,
|
|
12
|
+
minDate,
|
|
13
|
+
maxDate,
|
|
14
|
+
onDaySelect,
|
|
15
|
+
onShowYear,
|
|
16
|
+
onShowDecade,
|
|
17
|
+
onChange
|
|
18
|
+
} = props;
|
|
19
|
+
return React.createElement(PickerPlate, {
|
|
20
|
+
onPrev: () => onChange(format(addPeriod(month, 'month', -1), 'year-month')),
|
|
21
|
+
onNext: () => onChange(format(addPeriod(month, 'month', 1), 'year-month')),
|
|
22
|
+
slot: React.createElement(Horizontal, {
|
|
23
|
+
"$gap": 4
|
|
24
|
+
}, React.createElement(DateInfo, {
|
|
25
|
+
onClick: onShowYear
|
|
26
|
+
}, monthName(+format(month, 'month'))), React.createElement(DateInfo, {
|
|
27
|
+
onClick: onShowDecade
|
|
28
|
+
}, format(month, 'year')))
|
|
29
|
+
}, React.createElement(Month, {
|
|
30
|
+
month: month,
|
|
31
|
+
activeDay: activeDay,
|
|
32
|
+
userInputDay: userInputDay,
|
|
33
|
+
minDate: minDate,
|
|
34
|
+
maxDate: maxDate,
|
|
35
|
+
onDaySelect: onDaySelect
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MonthView';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MonthView';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface MonthViewProps {
|
|
2
|
+
month: string;
|
|
3
|
+
activeDay?: string;
|
|
4
|
+
userInputDay?: string;
|
|
5
|
+
minDate?: Date;
|
|
6
|
+
maxDate?: Date;
|
|
7
|
+
onDaySelect: (day: string) => void;
|
|
8
|
+
onShowYear: () => void;
|
|
9
|
+
onShowDecade: () => void;
|
|
10
|
+
onChange: (day: string) => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import { Vertical, useMount, usePersistentFunction } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { ChevronIcon } from '@pushwoosh/kit-icons';
|
|
4
|
+
import { intVal, isStringInteger } from './helpers';
|
|
5
|
+
import { SingleInputFrame } from '../../styles';
|
|
6
|
+
import { AutosizeInput } from '../AutosizeInput';
|
|
7
|
+
import { Input } from '../Input';
|
|
8
|
+
import { Hint } from './styles';
|
|
9
|
+
export function NumberPicker(props) {
|
|
10
|
+
const {
|
|
11
|
+
value,
|
|
12
|
+
hint,
|
|
13
|
+
step = 1,
|
|
14
|
+
placeholder,
|
|
15
|
+
focusOnMount,
|
|
16
|
+
minValue,
|
|
17
|
+
maxValue,
|
|
18
|
+
autoSize,
|
|
19
|
+
isDisabled,
|
|
20
|
+
onChange,
|
|
21
|
+
onSubmit
|
|
22
|
+
} = props;
|
|
23
|
+
const ref = useRef(null);
|
|
24
|
+
const [autoDiff, setAutoDiff] = useState(0);
|
|
25
|
+
const [localValue, setLocalValue] = useState(value.toString() || '');
|
|
26
|
+
const onChangeDiff = usePersistentFunction(diff => {
|
|
27
|
+
const newValue = intVal(value) + diff;
|
|
28
|
+
const minValueValid = minValue === undefined || newValue >= minValue;
|
|
29
|
+
const maxValueValid = maxValue === undefined || newValue <= maxValue;
|
|
30
|
+
if (minValueValid && maxValueValid) {
|
|
31
|
+
onChange(newValue);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
setLocalValue(value.toString() || '');
|
|
36
|
+
}, [value]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!autoDiff) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const interval = setInterval(() => {
|
|
42
|
+
onChangeDiff(autoDiff);
|
|
43
|
+
}, 250);
|
|
44
|
+
return () => clearInterval(interval);
|
|
45
|
+
}, [autoDiff, onChangeDiff]);
|
|
46
|
+
useMount(() => {
|
|
47
|
+
if (focusOnMount && ref.current) {
|
|
48
|
+
ref.current.children[0].focus();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const handleChange = event => {
|
|
52
|
+
const val = event.target.value;
|
|
53
|
+
if (val === '' || val === '-') {
|
|
54
|
+
setLocalValue(val);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const parsedValue = intVal(val);
|
|
58
|
+
if (parsedValue === 0 && val !== '0') {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setLocalValue(val);
|
|
62
|
+
const minValueValid = minValue === undefined || parsedValue >= minValue;
|
|
63
|
+
const maxValueValid = maxValue === undefined || parsedValue <= maxValue;
|
|
64
|
+
if (isStringInteger(val) && minValueValid && maxValueValid) {
|
|
65
|
+
onChange(parsedValue);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const handleKeyDown = event => {
|
|
69
|
+
if (onSubmit && event.key === 'Enter' && isStringInteger(localValue)) {
|
|
70
|
+
onSubmit();
|
|
71
|
+
}
|
|
72
|
+
if (event.key === 'ArrowUp') {
|
|
73
|
+
onChangeDiff(1);
|
|
74
|
+
setAutoDiff(1);
|
|
75
|
+
}
|
|
76
|
+
if (event.key === 'ArrowDown') {
|
|
77
|
+
onChangeDiff(-1);
|
|
78
|
+
setAutoDiff(-1);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const resetAutoDiff = () => setAutoDiff(0);
|
|
82
|
+
const InputComponent = autoSize ? AutosizeInput : Input;
|
|
83
|
+
return React.createElement(SingleInputFrame, {
|
|
84
|
+
ref: ref,
|
|
85
|
+
"$hasHint": !!hint,
|
|
86
|
+
"$isDisabled": isDisabled
|
|
87
|
+
}, React.createElement(InputComponent, {
|
|
88
|
+
value: localValue,
|
|
89
|
+
placeholder: placeholder,
|
|
90
|
+
isDisabled: isDisabled,
|
|
91
|
+
onChange: handleChange,
|
|
92
|
+
onKeyDown: handleKeyDown,
|
|
93
|
+
onKeyUp: resetAutoDiff,
|
|
94
|
+
onBlur: event => {
|
|
95
|
+
let blurValue = intVal(event.target.value);
|
|
96
|
+
const minValueValid = minValue === undefined || blurValue >= minValue;
|
|
97
|
+
const maxValueValid = maxValue === undefined || blurValue <= maxValue;
|
|
98
|
+
if (!maxValueValid) {
|
|
99
|
+
blurValue = maxValue;
|
|
100
|
+
} else if (!minValueValid) {
|
|
101
|
+
blurValue = minValue;
|
|
102
|
+
}
|
|
103
|
+
onChange(blurValue);
|
|
104
|
+
setLocalValue(blurValue.toString());
|
|
105
|
+
}
|
|
106
|
+
}), hint && React.createElement(Hint, null, hint), React.createElement(Vertical, {
|
|
107
|
+
"$gap": 1
|
|
108
|
+
}, React.createElement("div", null, React.createElement(ChevronIcon, {
|
|
109
|
+
direction: "up",
|
|
110
|
+
size: "small",
|
|
111
|
+
"aria-disabled": "true",
|
|
112
|
+
onClick: () => onChangeDiff(step),
|
|
113
|
+
onMouseDown: () => setAutoDiff(step),
|
|
114
|
+
onMouseUp: resetAutoDiff,
|
|
115
|
+
onMouseLeave: resetAutoDiff
|
|
116
|
+
})), React.createElement("div", null, React.createElement(ChevronIcon, {
|
|
117
|
+
size: "small",
|
|
118
|
+
direction: "down",
|
|
119
|
+
"aria-disabled": isDisabled,
|
|
120
|
+
onClick: () => onChangeDiff(-1 * step),
|
|
121
|
+
onMouseDown: () => setAutoDiff(-1 * step),
|
|
122
|
+
onMouseUp: resetAutoDiff,
|
|
123
|
+
onMouseLeave: resetAutoDiff
|
|
124
|
+
}))));
|
|
125
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NumberPicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NumberPicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Hint: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color, Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
export const Hint = styled.div.withConfig({
|
|
4
|
+
displayName: "Hint",
|
|
5
|
+
componentId: "sc-170ev2t-0"
|
|
6
|
+
})(["display:flex;align-items:center;font-size:100%;line-height:initial;padding-right:", ";color:", ";pointer-events:none;"], Spacing.S3, Color.PHANTOM);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface NumberPickerProps {
|
|
2
|
+
value: number;
|
|
3
|
+
hint?: string;
|
|
4
|
+
step?: number;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
focusOnMount?: boolean;
|
|
7
|
+
minValue?: number;
|
|
8
|
+
maxValue?: number;
|
|
9
|
+
autoSize?: boolean;
|
|
10
|
+
isDisabled?: boolean;
|
|
11
|
+
onChange: (value: number) => void;
|
|
12
|
+
onSubmit?: () => void;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Vertical, Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { Arrow } from './styles';
|
|
5
|
+
export function PickerPlate(props) {
|
|
6
|
+
const {
|
|
7
|
+
slot,
|
|
8
|
+
children,
|
|
9
|
+
onPrev,
|
|
10
|
+
onNext
|
|
11
|
+
} = props;
|
|
12
|
+
return React.createElement(Vertical, {
|
|
13
|
+
"$gap": Spacing.S5
|
|
14
|
+
}, React.createElement(Horizontal, {
|
|
15
|
+
"$justifyContent": "space-between"
|
|
16
|
+
}, slot, React.createElement(Horizontal, {
|
|
17
|
+
"$gap": Spacing.S1
|
|
18
|
+
}, React.createElement(Arrow, {
|
|
19
|
+
direction: "left",
|
|
20
|
+
onClick: onPrev
|
|
21
|
+
}), React.createElement(Arrow, {
|
|
22
|
+
direction: "right",
|
|
23
|
+
onClick: onNext
|
|
24
|
+
}))), children);
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PickerPlate';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PickerPlate';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { ArrowIcon } from '@pushwoosh/kit-icons';
|
|
4
|
+
export const Arrow = styled(ArrowIcon).attrs({
|
|
5
|
+
size: 'medium'
|
|
6
|
+
}).withConfig({
|
|
7
|
+
displayName: "Arrow",
|
|
8
|
+
componentId: "sc-1icudiw-0"
|
|
9
|
+
})(["color:", ";cursor:pointer;&:hover{color:", ";}"], Color.BRIGHT, Color.BRIGHT_HOVER);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Columns } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { format, addPeriod, setPeriod, monthName, isSamePeriod } from '../../helpers';
|
|
5
|
+
import { CellBox, DateInfo } from '../../styles';
|
|
6
|
+
import { PickerPlate } from '../PickerPlate';
|
|
7
|
+
export function YearView(props) {
|
|
8
|
+
const {
|
|
9
|
+
activeDay,
|
|
10
|
+
year,
|
|
11
|
+
onChange,
|
|
12
|
+
onSelect
|
|
13
|
+
} = props;
|
|
14
|
+
return React.createElement(PickerPlate, {
|
|
15
|
+
onPrev: () => onChange(format(addPeriod(year, 'year', -1), 'year')),
|
|
16
|
+
onNext: () => onChange(format(addPeriod(year, 'year', 1), 'year')),
|
|
17
|
+
slot: React.createElement(DateInfo, null, year)
|
|
18
|
+
}, React.createElement(Columns, {
|
|
19
|
+
"$sizes": 4,
|
|
20
|
+
"$gap": Spacing.S1,
|
|
21
|
+
"$justifyContent": "space-between"
|
|
22
|
+
}, Array.from({
|
|
23
|
+
length: 12
|
|
24
|
+
}).map((_, i) => {
|
|
25
|
+
const month = format(setPeriod(year, 'month', i + 1), 'year-month');
|
|
26
|
+
return React.createElement(CellBox, {
|
|
27
|
+
key: `${year}-${month}`,
|
|
28
|
+
height: "59px",
|
|
29
|
+
"$isActive": !!activeDay && isSamePeriod(month, activeDay, 'month'),
|
|
30
|
+
onClick: () => onSelect(month)
|
|
31
|
+
}, monthName(i + 1, 'short'));
|
|
32
|
+
})));
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './YearView';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './YearView';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Period, RangeOptions } from './types';
|
|
2
|
+
export declare const parseStringToArray: <T extends string>(datetime: T) => number[];
|
|
3
|
+
export declare const createUTCDate: (year: number, month?: number, day?: number, hour?: number, minute?: number, second?: number) => Date;
|
|
4
|
+
export declare const parseStringToDate: (date: string) => Date;
|
|
5
|
+
export declare const get: (d: string | Date, period: Period) => number;
|
|
6
|
+
export declare const format: (d: string | Date, template: string) => string;
|
|
7
|
+
export declare const addPeriod: <T extends string>(d: T, period: Period, value: number) => Date;
|
|
8
|
+
export declare const setPeriod: <T extends string>(d: T, period: Period, value: number) => Date;
|
|
9
|
+
export declare const differenceInDays: (d1: Date, d2: Date) => number;
|
|
10
|
+
export declare const monthName: (month: number, monthFormat?: "short" | "long") => string;
|
|
11
|
+
export declare const isSamePeriod: (d1: string | Date, d2: string | Date, period: Period) => boolean;
|
|
12
|
+
export declare const firstDayOfWeek: (date: Date) => Date;
|
|
13
|
+
export declare const startOfYear: (date: Date) => Date;
|
|
14
|
+
export declare const endOfYear: (date: Date) => Date;
|
|
15
|
+
export declare const isInRange: (options: RangeOptions) => boolean;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { allPeriods, periodMethodMap } from './constants';
|
|
2
|
+
export const parseStringToArray = datetime => datetime.split(/[\s-T:]/).map(Number);
|
|
3
|
+
export const createUTCDate = (year, month = 1, day = 1, hour = 0, minute = 0, second = 0) => new Date(Date.UTC(year, month - 1, day, hour, minute, second));
|
|
4
|
+
export const parseStringToDate = date => {
|
|
5
|
+
const args = parseStringToArray(date);
|
|
6
|
+
return createUTCDate(...args);
|
|
7
|
+
};
|
|
8
|
+
export const get = (d, period) => {
|
|
9
|
+
const date = d instanceof Date ? d : parseStringToDate(d);
|
|
10
|
+
const value = date[`getUTC${periodMethodMap[period]}`]();
|
|
11
|
+
return period === 'month' ? value + 1 : value;
|
|
12
|
+
};
|
|
13
|
+
const padStart = value => `${value}`.padStart(2, '0');
|
|
14
|
+
export const format = (d, template) => {
|
|
15
|
+
const date = d instanceof Date ? d : parseStringToDate(d);
|
|
16
|
+
return template.replace(/[a-z]+/g, match => padStart(get(date, match)));
|
|
17
|
+
};
|
|
18
|
+
export const addPeriod = (d, period, value) => {
|
|
19
|
+
const date = parseStringToDate(d);
|
|
20
|
+
const method = periodMethodMap[period];
|
|
21
|
+
date[`setUTC${method}`](date[`getUTC${method}`]() + value);
|
|
22
|
+
return date;
|
|
23
|
+
};
|
|
24
|
+
export const setPeriod = (d, period, value) => {
|
|
25
|
+
const date = parseStringToDate(d);
|
|
26
|
+
const method = periodMethodMap[period];
|
|
27
|
+
date[`setUTC${method}`](period === 'month' ? value - 1 : value);
|
|
28
|
+
return date;
|
|
29
|
+
};
|
|
30
|
+
export const differenceInDays = (d1, d2) => {
|
|
31
|
+
const diff = d1.getTime() - d2.getTime();
|
|
32
|
+
return Math.floor(diff / (1000 * 3600 * 24));
|
|
33
|
+
};
|
|
34
|
+
export const monthName = (month, monthFormat = 'long') => {
|
|
35
|
+
const date = new Date(2023, month - 1, 1);
|
|
36
|
+
return date.toLocaleString('default', {
|
|
37
|
+
month: monthFormat
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
export const isSamePeriod = (d1, d2, period) => {
|
|
41
|
+
const date1 = d1 instanceof Date ? d1 : parseStringToDate(d1);
|
|
42
|
+
const date2 = d2 instanceof Date ? d2 : parseStringToDate(d2);
|
|
43
|
+
const periodIdx = allPeriods.indexOf(period);
|
|
44
|
+
for (let i = 0; i <= periodIdx; i += 1) {
|
|
45
|
+
const method = `getUTC${periodMethodMap[allPeriods[i]]}`;
|
|
46
|
+
if (date1[method]() !== date2[method]()) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
};
|
|
52
|
+
export const firstDayOfWeek = date => {
|
|
53
|
+
const d = new Date(date);
|
|
54
|
+
const day = d.getUTCDay();
|
|
55
|
+
const diff = d.getUTCDate() - day + (day === 0 ? -6 : 1);
|
|
56
|
+
d.setUTCDate(diff);
|
|
57
|
+
return d;
|
|
58
|
+
};
|
|
59
|
+
export const startOfYear = date => new Date(date.getFullYear(), 0, 1, 0, 0, 0, 0);
|
|
60
|
+
export const endOfYear = date => new Date(date.getFullYear(), 11, 31, 23, 59, 59, 999);
|
|
61
|
+
export const isInRange = options => {
|
|
62
|
+
const {
|
|
63
|
+
value,
|
|
64
|
+
minDate,
|
|
65
|
+
maxDate
|
|
66
|
+
} = options;
|
|
67
|
+
let result = false;
|
|
68
|
+
if (minDate) {
|
|
69
|
+
if (value.getTime() < minDate.getTime()) {
|
|
70
|
+
result = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (maxDate) {
|
|
74
|
+
if (value.getTime() > maxDate.getTime()) {
|
|
75
|
+
result = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare const CellBox: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
$isActive?: boolean;
|
|
3
|
+
$isDisabled?: boolean;
|
|
4
|
+
$secondary?: boolean;
|
|
5
|
+
$secondActive?: boolean;
|
|
6
|
+
height?: number | string;
|
|
7
|
+
}, never>;
|
|
8
|
+
export declare const DayHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const DateInfo: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
+
export declare const RoundedBlock: import("styled-components").StyledComponent<"div", any, {
|
|
11
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
12
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
13
|
+
$gap?: string | number | undefined;
|
|
14
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
15
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
16
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
17
|
+
$margin?: string | number | undefined;
|
|
18
|
+
$padding?: string | number | undefined;
|
|
19
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
20
|
+
} & {
|
|
21
|
+
$gridAutoFlow: string;
|
|
22
|
+
} & {
|
|
23
|
+
$alignItems: string;
|
|
24
|
+
$padding: string;
|
|
25
|
+
}, "$gridAutoFlow" | "$alignItems" | "$padding">;
|
|
26
|
+
export declare const InputFrame: import("styled-components").StyledComponent<"div", any, {
|
|
27
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
28
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
29
|
+
$gap?: string | number | undefined;
|
|
30
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
31
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
32
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
33
|
+
$margin?: string | number | undefined;
|
|
34
|
+
$padding?: string | number | undefined;
|
|
35
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
36
|
+
} & {
|
|
37
|
+
$gridAutoFlow: string;
|
|
38
|
+
} & {
|
|
39
|
+
$alignItems: string;
|
|
40
|
+
$padding: string;
|
|
41
|
+
} & {
|
|
42
|
+
$empty?: boolean;
|
|
43
|
+
$error?: boolean;
|
|
44
|
+
}, "$gridAutoFlow" | "$alignItems" | "$padding">;
|
|
45
|
+
export declare const SingleInputFrame: import("styled-components").StyledComponent<"div", any, {
|
|
46
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
47
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
48
|
+
$gap?: string | number | undefined;
|
|
49
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
50
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
51
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
52
|
+
$margin?: string | number | undefined;
|
|
53
|
+
$padding?: string | number | undefined;
|
|
54
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
55
|
+
} & {
|
|
56
|
+
$gridAutoFlow: string;
|
|
57
|
+
} & {
|
|
58
|
+
$alignItems: string;
|
|
59
|
+
$padding: string;
|
|
60
|
+
} & {
|
|
61
|
+
$empty?: boolean;
|
|
62
|
+
$error?: boolean;
|
|
63
|
+
} & {
|
|
64
|
+
$hasHint: boolean;
|
|
65
|
+
$isDisabled?: boolean;
|
|
66
|
+
}, "$gridAutoFlow" | "$alignItems" | "$padding">;
|
|
67
|
+
export declare const CalendarBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { Color, Spacing, ShapeRadius, FontSize, FontWeight, LineHeight, Shadow } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
+
const disabled = css(["border:1px solid ", ";background:linear-gradient( to top left,rgba(0,0,0,0) 0%,rgba(0,0,0,0) calc(50% - 0.8px),", " 50%,rgba(0,0,0,0) calc(50% + 0.8px),rgba(0,0,0,0) 100% );opacity:0.8;pointer-events:none;"], Color.FORM, Color.FORM);
|
|
5
|
+
const CalendarCellBaseStyled = styled.div.withConfig({
|
|
6
|
+
displayName: "CalendarCellBaseStyled",
|
|
7
|
+
componentId: "sc-t3ruuk-0"
|
|
8
|
+
})(["display:flex;justify-content:center;align-items:center;"]);
|
|
9
|
+
export const CellBox = styled(CalendarCellBaseStyled).withConfig({
|
|
10
|
+
displayName: "CellBox",
|
|
11
|
+
componentId: "sc-t3ruuk-1"
|
|
12
|
+
})(["height:", ";color:", ";background-color:", ";border-radius:", ";opacity:", ";outline:", ";cursor:pointer;", " &:hover{background-color:", ";}"], ({
|
|
13
|
+
height
|
|
14
|
+
}) => height || '32px', ({
|
|
15
|
+
$isActive
|
|
16
|
+
}) => $isActive ? Color.CLEAR : Color.MAIN, ({
|
|
17
|
+
$isActive
|
|
18
|
+
}) => $isActive ? Color.BRIGHT : Color.CLEAR, ShapeRadius.CONTROL, ({
|
|
19
|
+
$secondary
|
|
20
|
+
}) => $secondary ? 0.8 : 1, ({
|
|
21
|
+
$isActive,
|
|
22
|
+
$secondActive
|
|
23
|
+
}) => $secondActive && !$isActive ? '1px solid #00a2ff5a' : 'none', ({
|
|
24
|
+
$isDisabled
|
|
25
|
+
}) => $isDisabled && disabled, ({
|
|
26
|
+
$isActive
|
|
27
|
+
}) => $isActive ? Color.BRIGHT_HOVER : Color.SOFT_LIGHT);
|
|
28
|
+
export const DayHeader = styled(CalendarCellBaseStyled).withConfig({
|
|
29
|
+
displayName: "DayHeader",
|
|
30
|
+
componentId: "sc-t3ruuk-2"
|
|
31
|
+
})(["height:32px;color:", ";font-weight:", ";font-size:", ";line-height:", ";"], Color.LOCKED, FontWeight.REGULAR, FontSize.SMALL, LineHeight.SMALL);
|
|
32
|
+
export const DateInfo = styled.div.withConfig({
|
|
33
|
+
displayName: "DateInfo",
|
|
34
|
+
componentId: "sc-t3ruuk-3"
|
|
35
|
+
})(["display:flex;align-items:center;height:24px;color:", ";background:", ";padding:", " ", ";font-weight:", ";font-size:", ";line-height:", ";border-radius:", ";cursor:pointer;"], Color.MAIN, Color.SOFT_LIGHT, Spacing.S0, Spacing.S3, FontWeight.MEDIUM, FontSize.SMALL, LineHeight.SMALL, ShapeRadius.CONTROL);
|
|
36
|
+
export const RoundedBlock = styled(Horizontal).attrs({
|
|
37
|
+
$alignItems: 'center',
|
|
38
|
+
$padding: '0 12px'
|
|
39
|
+
}).withConfig({
|
|
40
|
+
displayName: "RoundedBlock",
|
|
41
|
+
componentId: "sc-t3ruuk-4"
|
|
42
|
+
})(["display:inline-grid;height:36px;border-radius:", ";"], ShapeRadius.CONTROL);
|
|
43
|
+
export const InputFrame = styled(RoundedBlock).withConfig({
|
|
44
|
+
displayName: "InputFrame",
|
|
45
|
+
componentId: "sc-t3ruuk-5"
|
|
46
|
+
})(["position:relative;color:", ";border:1px solid ", ";box-sizing:border-box;cursor:pointer;&:focus-within{border-color:", ";}& > input{color:#4b5057;height:34px;border:none;padding:0;outline:none;line-height:140%;}"], ({
|
|
47
|
+
$empty
|
|
48
|
+
}) => $empty ? Color.BRIGHT : Color.MAIN, ({
|
|
49
|
+
$error
|
|
50
|
+
}) => $error ? '#ff0000' : Color.FORM, Color.BRIGHT);
|
|
51
|
+
export const SingleInputFrame = styled(InputFrame).withConfig({
|
|
52
|
+
displayName: "SingleInputFrame",
|
|
53
|
+
componentId: "sc-t3ruuk-6"
|
|
54
|
+
})(["grid-template-columns:", ";padding-right:0;background-color:", ";pointer-events:", ";& > div:last-of-type{height:34px;padding-left:1px;background-color:", ";border-radius:0 ", " ", " 0;& > div{display:flex;justify-content:center;align-items:center;color:black;background-color:", ";cursor:pointer;&:hover > *{transform:scale(1.3);}&:first-of-type{border-top-right-radius:", ";}&:last-of-type{border-bottom-right-radius:", ";}}}"], ({
|
|
55
|
+
$hasHint
|
|
56
|
+
}) => $hasHint ? '1fr max-content 21px' : '1fr 21px', ({
|
|
57
|
+
$isDisabled
|
|
58
|
+
}) => $isDisabled ? Color.FROZEN : Color.CLEAR, ({
|
|
59
|
+
$isDisabled
|
|
60
|
+
}) => $isDisabled ? 'none' : 'auto', Color.FORM, ShapeRadius.CONTROL, ShapeRadius.CONTROL, Color.FROZEN, ShapeRadius.CONTROL, ShapeRadius.CONTROL);
|
|
61
|
+
export const CalendarBox = styled.div.withConfig({
|
|
62
|
+
displayName: "CalendarBox",
|
|
63
|
+
componentId: "sc-t3ruuk-7"
|
|
64
|
+
})(["width:282px;background-color:", ";padding:", ";border:1px solid ", ";border-radius:", ";box-shadow:", ";box-sizing:border-box;z-index:1;"], Color.CLEAR, Spacing.S5, Color.FORM, ShapeRadius.CONTROL, Shadow.REGULAR);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,6 +6,7 @@ const defaultPlacements = ['top-start', 'top-end', 'bottom-start', 'bottom-end']
|
|
|
6
6
|
export const DropdownMenu = ({
|
|
7
7
|
renderHandler,
|
|
8
8
|
children,
|
|
9
|
+
isScrollable,
|
|
9
10
|
menuZIndex,
|
|
10
11
|
menuPlacement
|
|
11
12
|
}) => {
|
|
@@ -41,6 +42,7 @@ export const DropdownMenu = ({
|
|
|
41
42
|
}), isOpen && React.createElement(Place, {
|
|
42
43
|
ref: refs.setFloating,
|
|
43
44
|
style: floatingStyles,
|
|
45
|
+
"$scrollable": isScrollable,
|
|
44
46
|
"$zIndex": menuZIndex
|
|
45
47
|
}, typeof children === 'function' ? children() : children));
|
|
46
48
|
};
|