@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,35 @@
|
|
|
1
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import { Input } from '../Input';
|
|
3
|
+
import { Hidden } from './styles';
|
|
4
|
+
export function AutosizeInput(props) {
|
|
5
|
+
const {
|
|
6
|
+
value,
|
|
7
|
+
placeholder,
|
|
8
|
+
isDisabled,
|
|
9
|
+
onChange,
|
|
10
|
+
onKeyUp,
|
|
11
|
+
onKeyDown,
|
|
12
|
+
onBlur
|
|
13
|
+
} = props;
|
|
14
|
+
const ref = useRef(null);
|
|
15
|
+
const [width, setWidth] = useState(12);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const {
|
|
18
|
+
offsetWidth
|
|
19
|
+
} = ref.current;
|
|
20
|
+
const addWidth = offsetWidth ? 12 : 16;
|
|
21
|
+
setWidth(offsetWidth + addWidth);
|
|
22
|
+
}, [value]);
|
|
23
|
+
return React.createElement(React.Fragment, null, React.createElement(Input, {
|
|
24
|
+
value: value,
|
|
25
|
+
placeholder: placeholder,
|
|
26
|
+
width: width,
|
|
27
|
+
isDisabled: isDisabled,
|
|
28
|
+
onChange: onChange,
|
|
29
|
+
onKeyUp: onKeyUp,
|
|
30
|
+
onKeyDown: onKeyDown,
|
|
31
|
+
onBlur: onBlur
|
|
32
|
+
}), React.createElement(Hidden, {
|
|
33
|
+
ref: ref
|
|
34
|
+
}, value || placeholder));
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AutosizeInput';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AutosizeInput';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Hidden: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChangeEvent, KeyboardEvent, FocusEvent } from 'react';
|
|
2
|
+
export interface AutosizeInputProps {
|
|
3
|
+
value: string;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
isDisabled?: boolean;
|
|
6
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
7
|
+
onKeyUp: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
8
|
+
onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
9
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { format } from '../../helpers';
|
|
4
|
+
import { CalendarBox } from '../../styles';
|
|
5
|
+
import { DecadeView } from '../DecadeView';
|
|
6
|
+
import { MonthView } from '../MonthView';
|
|
7
|
+
import { YearView } from '../YearView';
|
|
8
|
+
export function DatePicker(props) {
|
|
9
|
+
const {
|
|
10
|
+
value,
|
|
11
|
+
userInputDay,
|
|
12
|
+
minDate,
|
|
13
|
+
maxDate,
|
|
14
|
+
slotAfterMonth,
|
|
15
|
+
onChange
|
|
16
|
+
} = props;
|
|
17
|
+
const [view, setView] = useState('month');
|
|
18
|
+
const [month, setMonth] = useState(() => format(userInputDay || value || new Date(), 'year-month'));
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (userInputDay) {
|
|
21
|
+
setMonth(format(userInputDay, 'year-month'));
|
|
22
|
+
setView('month');
|
|
23
|
+
}
|
|
24
|
+
}, [userInputDay]);
|
|
25
|
+
return React.createElement(CalendarBox, null, view === 'month' && React.createElement(Vertical, {
|
|
26
|
+
"$gap": 16
|
|
27
|
+
}, React.createElement(MonthView, {
|
|
28
|
+
month: month,
|
|
29
|
+
activeDay: value ? format(value, 'year-month-day') : undefined,
|
|
30
|
+
userInputDay: userInputDay,
|
|
31
|
+
minDate: minDate,
|
|
32
|
+
maxDate: maxDate,
|
|
33
|
+
onChange: setMonth,
|
|
34
|
+
onDaySelect: onChange,
|
|
35
|
+
onShowYear: () => setView('year'),
|
|
36
|
+
onShowDecade: () => setView('decade')
|
|
37
|
+
}), slotAfterMonth && slotAfterMonth()), view === 'year' && React.createElement(YearView, {
|
|
38
|
+
year: format(month, 'year'),
|
|
39
|
+
activeDay: value ? format(value, 'year-month-day') : undefined,
|
|
40
|
+
onChange: setMonth,
|
|
41
|
+
onSelect: newMon => {
|
|
42
|
+
setMonth(newMon);
|
|
43
|
+
setView('month');
|
|
44
|
+
}
|
|
45
|
+
}), view === 'decade' && React.createElement(DecadeView, {
|
|
46
|
+
value: format(month, 'year'),
|
|
47
|
+
activeDay: value ? format(value, 'year-month-day') : undefined,
|
|
48
|
+
onChange: setMonth,
|
|
49
|
+
onSelect: newYear => {
|
|
50
|
+
setMonth(newYear);
|
|
51
|
+
setView('year');
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DatePicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DatePicker';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface DatePickerProps {
|
|
3
|
+
value?: string;
|
|
4
|
+
userInputDay?: string;
|
|
5
|
+
minDate?: Date;
|
|
6
|
+
maxDate?: Date;
|
|
7
|
+
slotAfterMonth?: () => ReactNode | null;
|
|
8
|
+
onChange: (day: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export type ViewType = 'month' | 'year' | 'decade';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useFloating, offset, autoPlacement } from '@floating-ui/react-dom';
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import { CalendarIcon } from '@pushwoosh/kit-icons';
|
|
4
|
+
import { format, monthName, get } from '../../helpers';
|
|
5
|
+
import { InputFrame } from '../../styles';
|
|
6
|
+
import { DatePicker } from '../DatePicker';
|
|
7
|
+
export function DatePickerField(props) {
|
|
8
|
+
const {
|
|
9
|
+
value,
|
|
10
|
+
error,
|
|
11
|
+
allowedPlacements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
|
|
12
|
+
zIndex = 1000,
|
|
13
|
+
onChange
|
|
14
|
+
} = props;
|
|
15
|
+
const [showPicker, setShowPicker] = useState(false);
|
|
16
|
+
const {
|
|
17
|
+
refs,
|
|
18
|
+
floatingStyles
|
|
19
|
+
} = useFloating({
|
|
20
|
+
middleware: [offset(4), autoPlacement({
|
|
21
|
+
allowedPlacements
|
|
22
|
+
})]
|
|
23
|
+
});
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!showPicker) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const handleClickListener = e => {
|
|
29
|
+
var _refs$floating$curren;
|
|
30
|
+
if (!((_refs$floating$curren = refs.floating.current) !== null && _refs$floating$curren !== void 0 && _refs$floating$curren.contains(e.target)) && !refs.reference.current.contains(e.target)) {
|
|
31
|
+
setShowPicker(false);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
document.addEventListener('click', handleClickListener);
|
|
35
|
+
return () => {
|
|
36
|
+
document.removeEventListener('click', handleClickListener);
|
|
37
|
+
};
|
|
38
|
+
}, [showPicker, refs]);
|
|
39
|
+
const onSelect = date => onChange(date);
|
|
40
|
+
return React.createElement(React.Fragment, null, React.createElement(InputFrame, {
|
|
41
|
+
ref: refs.setReference,
|
|
42
|
+
"$gap": 8,
|
|
43
|
+
"$error": error,
|
|
44
|
+
"$empty": !value,
|
|
45
|
+
onClick: () => setShowPicker(!showPicker)
|
|
46
|
+
}, React.createElement(CalendarIcon, {
|
|
47
|
+
size: "medium",
|
|
48
|
+
view: "lined"
|
|
49
|
+
}), value ? React.createElement(React.Fragment, null, format(value, 'day '), monthName(get(value, 'month'), 'long'), format(value, ' year')) : 'Select date'), showPicker && React.createElement("div", {
|
|
50
|
+
ref: refs.setFloating,
|
|
51
|
+
style: {
|
|
52
|
+
...floatingStyles,
|
|
53
|
+
zIndex
|
|
54
|
+
}
|
|
55
|
+
}, React.createElement(DatePicker, {
|
|
56
|
+
value: value,
|
|
57
|
+
onChange: onSelect
|
|
58
|
+
})));
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DatePickerField';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DatePickerField';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Collapse, Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { format, createUTCDate } from '../../helpers';
|
|
5
|
+
import { DatePicker } from '../DatePicker';
|
|
6
|
+
import { NumberPicker } from '../NumberPicker';
|
|
7
|
+
export function DateTimePicker(props) {
|
|
8
|
+
const {
|
|
9
|
+
value,
|
|
10
|
+
userInputDay,
|
|
11
|
+
onChange
|
|
12
|
+
} = props;
|
|
13
|
+
const date = value ? new Date(value) : new Date();
|
|
14
|
+
const handleChange = formattedDate => {
|
|
15
|
+
const [year, month, day] = formattedDate.split('-').map(Number);
|
|
16
|
+
const utcDate = createUTCDate(year, month, day, date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
|
|
17
|
+
onChange(utcDate.toUTCString());
|
|
18
|
+
};
|
|
19
|
+
const handleChangeHour = hours => {
|
|
20
|
+
date.setUTCHours(hours);
|
|
21
|
+
onChange(date.toUTCString());
|
|
22
|
+
};
|
|
23
|
+
const handleChangeMinutes = minutes => {
|
|
24
|
+
date.setUTCMinutes(minutes);
|
|
25
|
+
onChange(date.toUTCString());
|
|
26
|
+
};
|
|
27
|
+
const handleChangeSeconds = seconds => {
|
|
28
|
+
date.setUTCSeconds(seconds);
|
|
29
|
+
onChange(date.toUTCString());
|
|
30
|
+
};
|
|
31
|
+
return React.createElement(DatePicker, {
|
|
32
|
+
value: format(date, 'year-month-dayThour:minute:second'),
|
|
33
|
+
userInputDay: userInputDay,
|
|
34
|
+
onChange: handleChange,
|
|
35
|
+
slotAfterMonth: () => React.createElement(Collapse, {
|
|
36
|
+
expanded: !!value
|
|
37
|
+
}, React.createElement(Horizontal, {
|
|
38
|
+
"$padding": `0 ${Spacing.S5}`,
|
|
39
|
+
"$gap": 8
|
|
40
|
+
}, React.createElement(NumberPicker, {
|
|
41
|
+
placeholder: "00",
|
|
42
|
+
value: date.getUTCHours(),
|
|
43
|
+
onChange: handleChangeHour
|
|
44
|
+
}), React.createElement(NumberPicker, {
|
|
45
|
+
placeholder: "00",
|
|
46
|
+
value: date.getUTCMinutes(),
|
|
47
|
+
onChange: handleChangeMinutes
|
|
48
|
+
}), React.createElement(NumberPicker, {
|
|
49
|
+
placeholder: "00",
|
|
50
|
+
value: date.getUTCSeconds(),
|
|
51
|
+
onChange: handleChangeSeconds
|
|
52
|
+
})))
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DateTimePicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DateTimePicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useFloating, offset, autoPlacement } from '@floating-ui/react-dom';
|
|
2
|
+
import React, { useState, useEffect } from 'react';
|
|
3
|
+
import { Spacing } from '@pushwoosh/kit-constants';
|
|
4
|
+
import { CalendarIcon } from '@pushwoosh/kit-icons';
|
|
5
|
+
import { useUTCDate } from './helpers';
|
|
6
|
+
import { InputFrame } from '../../styles';
|
|
7
|
+
import { DateTimePicker } from '../DateTimePicker';
|
|
8
|
+
export function DateTimePickerField(props) {
|
|
9
|
+
const {
|
|
10
|
+
value,
|
|
11
|
+
error,
|
|
12
|
+
allowedPlacements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
|
|
13
|
+
zIndex = 1000,
|
|
14
|
+
onChange
|
|
15
|
+
} = props;
|
|
16
|
+
const [showPicker, setShowPicker] = useState(false);
|
|
17
|
+
const {
|
|
18
|
+
refs,
|
|
19
|
+
floatingStyles
|
|
20
|
+
} = useFloating({
|
|
21
|
+
middleware: [offset(4), autoPlacement({
|
|
22
|
+
allowedPlacements
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!showPicker) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const handleClickListener = e => {
|
|
30
|
+
var _refs$floating$curren;
|
|
31
|
+
if (!((_refs$floating$curren = refs.floating.current) !== null && _refs$floating$curren !== void 0 && _refs$floating$curren.contains(e.target)) && !refs.reference.current.contains(e.target)) {
|
|
32
|
+
setShowPicker(false);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
document.addEventListener('click', handleClickListener);
|
|
36
|
+
return () => {
|
|
37
|
+
document.removeEventListener('click', handleClickListener);
|
|
38
|
+
};
|
|
39
|
+
}, [showPicker, refs]);
|
|
40
|
+
const onSelect = date => onChange(date);
|
|
41
|
+
const {
|
|
42
|
+
year,
|
|
43
|
+
month,
|
|
44
|
+
day,
|
|
45
|
+
hours,
|
|
46
|
+
minutes
|
|
47
|
+
} = useUTCDate(value);
|
|
48
|
+
return React.createElement(React.Fragment, null, React.createElement(InputFrame, {
|
|
49
|
+
ref: refs.setReference,
|
|
50
|
+
"$gap": Spacing.S3,
|
|
51
|
+
"$empty": !value,
|
|
52
|
+
"$error": error,
|
|
53
|
+
onClick: () => setShowPicker(!showPicker)
|
|
54
|
+
}, React.createElement(CalendarIcon, {
|
|
55
|
+
size: "medium",
|
|
56
|
+
view: "lined"
|
|
57
|
+
}), value ? `${day} ${month} ${year} ${hours}:${minutes}` : 'Select date and time'), showPicker && React.createElement("div", {
|
|
58
|
+
ref: refs.setFloating,
|
|
59
|
+
style: {
|
|
60
|
+
...floatingStyles,
|
|
61
|
+
zIndex
|
|
62
|
+
}
|
|
63
|
+
}, React.createElement(DateTimePicker, {
|
|
64
|
+
value: value,
|
|
65
|
+
onChange: onSelect
|
|
66
|
+
})));
|
|
67
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const useUTCDate = dateString => {
|
|
2
|
+
const date = new Date(dateString);
|
|
3
|
+
return {
|
|
4
|
+
year: date.getUTCFullYear(),
|
|
5
|
+
month: date.toLocaleString('en-US', {
|
|
6
|
+
month: 'long'
|
|
7
|
+
}),
|
|
8
|
+
day: String(date.getUTCDate()).padStart(2, '0'),
|
|
9
|
+
hours: String(date.getUTCHours()).padStart(2, '0'),
|
|
10
|
+
minutes: String(date.getUTCMinutes()).padStart(2, '0'),
|
|
11
|
+
seconds: String(date.getUTCSeconds()).padStart(2, '0')
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DateTimePickerField';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DateTimePickerField';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Columns } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { format, parseStringToArray, addPeriod, setPeriod } from '../../helpers';
|
|
5
|
+
import { CellBox } from '../../styles';
|
|
6
|
+
import { PickerPlate } from '../PickerPlate';
|
|
7
|
+
export function DecadeView(props) {
|
|
8
|
+
const {
|
|
9
|
+
activeDay,
|
|
10
|
+
value,
|
|
11
|
+
onChange,
|
|
12
|
+
onSelect
|
|
13
|
+
} = props;
|
|
14
|
+
const [activeDayYear] = parseStringToArray(activeDay || '');
|
|
15
|
+
const valueYear = +value;
|
|
16
|
+
const firstYear = valueYear - valueYear % 12;
|
|
17
|
+
return React.createElement(PickerPlate, {
|
|
18
|
+
onPrev: () => onChange(format(addPeriod(value, 'year', -12), 'year')),
|
|
19
|
+
onNext: () => onChange(format(addPeriod(value, 'year', 12), 'year'))
|
|
20
|
+
}, React.createElement(Columns, {
|
|
21
|
+
"$sizes": 4,
|
|
22
|
+
"$gap": Spacing.S1
|
|
23
|
+
}, Array.from({
|
|
24
|
+
length: 12
|
|
25
|
+
}).map((_, i) => {
|
|
26
|
+
const year = firstYear + i;
|
|
27
|
+
return React.createElement(CellBox, {
|
|
28
|
+
key: year,
|
|
29
|
+
height: "59px",
|
|
30
|
+
"$isActive": year === activeDayYear,
|
|
31
|
+
onClick: () => onSelect(format(setPeriod(value, 'year', year), 'year'))
|
|
32
|
+
}, year);
|
|
33
|
+
})));
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DecadeView';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './DecadeView';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputStyled } from './styles';
|
|
3
|
+
export function Input(props) {
|
|
4
|
+
const {
|
|
5
|
+
width,
|
|
6
|
+
isDisabled,
|
|
7
|
+
...rest
|
|
8
|
+
} = props;
|
|
9
|
+
return React.createElement(InputStyled, {
|
|
10
|
+
type: "text",
|
|
11
|
+
disabled: isDisabled,
|
|
12
|
+
style: {
|
|
13
|
+
width: width || '100%'
|
|
14
|
+
},
|
|
15
|
+
...rest
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Input';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Input';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InputStyled: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChangeEvent, KeyboardEvent, FocusEvent } from 'react';
|
|
2
|
+
export interface InputProps {
|
|
3
|
+
value: string;
|
|
4
|
+
width?: number;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
onKeyUp: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
9
|
+
onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
10
|
+
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Columns } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { format, firstDayOfWeek, parseStringToDate, differenceInDays, isSamePeriod, isInRange } from '../../helpers';
|
|
5
|
+
import { CellBox, DayHeader } from '../../styles';
|
|
6
|
+
export function Month(props) {
|
|
7
|
+
const {
|
|
8
|
+
month,
|
|
9
|
+
activeDay,
|
|
10
|
+
userInputDay,
|
|
11
|
+
minDate,
|
|
12
|
+
maxDate,
|
|
13
|
+
onDaySelect
|
|
14
|
+
} = props;
|
|
15
|
+
const [firstDayDate, days] = useMemo(() => {
|
|
16
|
+
const monthDate = parseStringToDate(month);
|
|
17
|
+
const firstDayOfMonth = new Date(monthDate);
|
|
18
|
+
firstDayOfMonth.setUTCDate(1);
|
|
19
|
+
const lastDayOfMonth = new Date(month);
|
|
20
|
+
lastDayOfMonth.setUTCMonth(lastDayOfMonth.getUTCMonth() + 1);
|
|
21
|
+
lastDayOfMonth.setUTCDate(0);
|
|
22
|
+
const firstDayOfFirstWeek = firstDayOfWeek(firstDayOfMonth);
|
|
23
|
+
const firstDayOfLastWeek = firstDayOfWeek(lastDayOfMonth);
|
|
24
|
+
const daysInCalendar = differenceInDays(firstDayOfLastWeek, firstDayOfFirstWeek) + 7;
|
|
25
|
+
return [firstDayOfFirstWeek, daysInCalendar];
|
|
26
|
+
}, [month]);
|
|
27
|
+
return React.createElement(Columns, {
|
|
28
|
+
"$sizes": 7,
|
|
29
|
+
"$gap": Spacing.S1
|
|
30
|
+
}, React.createElement(DayHeader, null, "Sun"), React.createElement(DayHeader, null, "Mon"), React.createElement(DayHeader, null, "Tue"), React.createElement(DayHeader, null, "Wed"), React.createElement(DayHeader, null, "Thu"), React.createElement(DayHeader, null, "Fri"), React.createElement(DayHeader, null, "Sat"), Array.from({
|
|
31
|
+
length: days
|
|
32
|
+
}).map((_, i) => {
|
|
33
|
+
const curDay = new Date(firstDayDate.getUTCFullYear(), firstDayDate.getUTCMonth(), firstDayDate.getUTCDate() + i);
|
|
34
|
+
const isDisabled = isInRange({
|
|
35
|
+
value: curDay,
|
|
36
|
+
minDate: minDate || undefined,
|
|
37
|
+
maxDate: maxDate || undefined
|
|
38
|
+
});
|
|
39
|
+
return React.createElement(CellBox, {
|
|
40
|
+
key: `${curDay}`,
|
|
41
|
+
"$isActive": !!activeDay && isSamePeriod(curDay, activeDay, 'day'),
|
|
42
|
+
"$isDisabled": isDisabled,
|
|
43
|
+
"$secondary": !isSamePeriod(month, curDay, 'month'),
|
|
44
|
+
"$secondActive": !!userInputDay && isSamePeriod(curDay, userInputDay, 'day'),
|
|
45
|
+
onClick: () => onDaySelect(format(curDay, 'year-month-day'))
|
|
46
|
+
}, curDay.getUTCDate());
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Month';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Month';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|