@pushwoosh/dumb-components 2.12.2 → 3.0.1
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/Alert/styles.d.ts +6 -14
- package/Banner/maps.d.ts +2 -6
- package/Banner/styles.d.ts +2 -6
- package/Button/maps.d.ts +12 -36
- package/Button/styles.d.ts +12 -36
- package/Calendar/CalendarMonth/styles.d.ts +2 -6
- package/Calendar/CalendarMonthSlider/styles.d.ts +5 -9
- package/CodeEditor/styles.d.ts +3 -7
- package/Drawer/components/Drawer/styles.d.ts +2 -2
- package/Drawer/components/DrawerDocs/styles.d.ts +1 -3
- package/DropdownMenu/components/DropdownMenuSection/styles.d.ts +3 -7
- package/DropdownMenu/shared/styles.d.ts +3 -7
- package/EmailTemplatePreview/components/NoEmailTemplatePreview/styles.d.ts +6 -14
- package/EnhancedInput/styles.d.ts +2 -6
- package/ExportResult/styles.d.ts +9 -21
- package/FieldBox/styles.d.ts +7 -15
- package/FrequencyCapping/styles.d.ts +6 -14
- package/GetStartedPage/styles.d.ts +1 -3
- package/InboxPreview/components/InboxCellCarousel/styles.d.ts +9 -21
- package/InboxPreview/styles.d.ts +7 -17
- package/InputFile/styles.d.ts +1 -3
- package/Modal/components/Modal/styles.d.ts +2 -2
- package/Modal/components/ModalContent/styles.d.ts +9 -21
- package/Modal/components/ModalTitle/styles.d.ts +3 -7
- package/NativeRichMediaPreview/components/NativeRichMediaRewardPanel/styles.d.ts +3 -7
- package/NativeRichMediaPreview/components/NativeRichMediaThemeChip/styles.d.ts +1 -3
- package/NativeRichMediaPreview/components/NativeRichMediaTitle/styles.d.ts +3 -7
- package/NativeRichMediaPreview/views/NativeRichMediaModalView/styles.d.ts +2 -6
- package/NativeRichMediaPreview/views/NativeRichMediaScratchcardView/styles.d.ts +2 -6
- package/NativeRichMediaPreview/views/NativeRichMediaSpinwheelView/styles.d.ts +2 -6
- package/NotificationInbox/styles.d.ts +21 -51
- package/Pagination/styles.d.ts +2 -6
- package/ProgressBar/styles.d.ts +1 -3
- package/PushPreview/styles.d.ts +7 -15
- package/Radio/styles.d.ts +3 -7
- package/RadioCard/styles.d.ts +7 -15
- package/RichMessageEditor/slate/styles.d.ts +2 -4
- package/RichMessageEditor/styles.d.ts +7 -15
- package/RichmediaPreview/styles.d.ts +3 -7
- package/SendRate/styles.d.ts +6 -14
- package/Switch/styles.d.ts +2 -2
- package/Tabs/components/TabBarScrollableFrame/styles.d.ts +1 -3
- package/Tooltip/styles.d.ts +3 -7
- package/Tooltip/useTooltipPosition.d.ts +1 -1
- package/WhatsAppPreview/components/WhatsAppAttachment/styles.d.ts +46 -102
- package/WhatsAppPreview/components/WhatsAppMessageContent/styles.d.ts +3 -7
- package/WhatsAppPreview/styles.d.ts +40 -92
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/package.json +6 -6
- package/shared/dropdownField/styles.d.ts +2 -2
- package/DateTimePicker/components/AutosizeInput/AutosizeInput.d.ts +0 -3
- package/DateTimePicker/components/AutosizeInput/AutosizeInput.js +0 -39
- package/DateTimePicker/components/AutosizeInput/index.d.ts +0 -1
- package/DateTimePicker/components/AutosizeInput/index.js +0 -1
- package/DateTimePicker/components/AutosizeInput/styles.d.ts +0 -3
- package/DateTimePicker/components/AutosizeInput/styles.js +0 -5
- package/DateTimePicker/components/AutosizeInput/types.d.ts +0 -10
- package/DateTimePicker/components/AutosizeInput/types.js +0 -1
- package/DateTimePicker/components/DatePicker/DatePicker.d.ts +0 -8
- package/DateTimePicker/components/DatePicker/DatePicker.js +0 -65
- package/DateTimePicker/components/DatePicker/index.d.ts +0 -1
- package/DateTimePicker/components/DatePicker/index.js +0 -1
- package/DateTimePicker/components/DatePicker/types.d.ts +0 -20
- package/DateTimePicker/components/DatePicker/types.js +0 -1
- package/DateTimePicker/components/DatePickerField/DatePickerField.d.ts +0 -8
- package/DateTimePicker/components/DatePickerField/DatePickerField.js +0 -86
- package/DateTimePicker/components/DatePickerField/index.d.ts +0 -1
- package/DateTimePicker/components/DatePickerField/index.js +0 -1
- package/DateTimePicker/components/DatePickerField/types.d.ts +0 -20
- package/DateTimePicker/components/DatePickerField/types.js +0 -1
- package/DateTimePicker/components/DateTimePicker/DateTimePicker.d.ts +0 -8
- package/DateTimePicker/components/DateTimePicker/DateTimePicker.js +0 -64
- package/DateTimePicker/components/DateTimePicker/index.d.ts +0 -1
- package/DateTimePicker/components/DateTimePicker/index.js +0 -1
- package/DateTimePicker/components/DateTimePicker/types.d.ts +0 -13
- package/DateTimePicker/components/DateTimePicker/types.js +0 -1
- package/DateTimePicker/components/DateTimePickerField/DateTimePickerField.d.ts +0 -8
- package/DateTimePicker/components/DateTimePickerField/DateTimePickerField.js +0 -91
- package/DateTimePicker/components/DateTimePickerField/helpers.d.ts +0 -8
- package/DateTimePicker/components/DateTimePickerField/helpers.js +0 -13
- package/DateTimePicker/components/DateTimePickerField/index.d.ts +0 -1
- package/DateTimePicker/components/DateTimePickerField/index.js +0 -1
- package/DateTimePicker/components/DateTimePickerField/types.d.ts +0 -20
- package/DateTimePicker/components/DateTimePickerField/types.js +0 -1
- package/DateTimePicker/components/DecadeView/DecadeView.d.ts +0 -3
- package/DateTimePicker/components/DecadeView/DecadeView.js +0 -35
- package/DateTimePicker/components/DecadeView/index.d.ts +0 -1
- package/DateTimePicker/components/DecadeView/index.js +0 -1
- package/DateTimePicker/components/DecadeView/types.d.ts +0 -6
- package/DateTimePicker/components/DecadeView/types.js +0 -1
- package/DateTimePicker/components/Input/Input.d.ts +0 -3
- package/DateTimePicker/components/Input/Input.js +0 -17
- package/DateTimePicker/components/Input/index.d.ts +0 -1
- package/DateTimePicker/components/Input/index.js +0 -1
- package/DateTimePicker/components/Input/styles.d.ts +0 -3
- package/DateTimePicker/components/Input/styles.js +0 -6
- package/DateTimePicker/components/Input/types.d.ts +0 -11
- package/DateTimePicker/components/Input/types.js +0 -1
- package/DateTimePicker/components/Month/Month.d.ts +0 -3
- package/DateTimePicker/components/Month/Month.js +0 -78
- package/DateTimePicker/components/Month/index.d.ts +0 -1
- package/DateTimePicker/components/Month/index.js +0 -1
- package/DateTimePicker/components/Month/types.d.ts +0 -8
- package/DateTimePicker/components/Month/types.js +0 -1
- package/DateTimePicker/components/MonthView/MonthView.d.ts +0 -3
- package/DateTimePicker/components/MonthView/MonthView.js +0 -41
- package/DateTimePicker/components/MonthView/index.d.ts +0 -1
- package/DateTimePicker/components/MonthView/index.js +0 -1
- package/DateTimePicker/components/MonthView/types.d.ts +0 -11
- package/DateTimePicker/components/MonthView/types.js +0 -1
- package/DateTimePicker/components/NumberPicker/NumberPicker.d.ts +0 -3
- package/DateTimePicker/components/NumberPicker/NumberPicker.js +0 -133
- package/DateTimePicker/components/NumberPicker/helpers.d.ts +0 -2
- package/DateTimePicker/components/NumberPicker/helpers.js +0 -5
- package/DateTimePicker/components/NumberPicker/index.d.ts +0 -1
- package/DateTimePicker/components/NumberPicker/index.js +0 -1
- package/DateTimePicker/components/NumberPicker/styles.d.ts +0 -3
- package/DateTimePicker/components/NumberPicker/styles.js +0 -6
- package/DateTimePicker/components/NumberPicker/types.d.ts +0 -13
- package/DateTimePicker/components/NumberPicker/types.js +0 -1
- package/DateTimePicker/components/PickerPlate/PickerPlate.d.ts +0 -3
- package/DateTimePicker/components/PickerPlate/PickerPlate.js +0 -27
- package/DateTimePicker/components/PickerPlate/index.d.ts +0 -1
- package/DateTimePicker/components/PickerPlate/index.js +0 -1
- package/DateTimePicker/components/PickerPlate/styles.d.ts +0 -17
- package/DateTimePicker/components/PickerPlate/styles.js +0 -9
- package/DateTimePicker/components/PickerPlate/types.d.ts +0 -7
- package/DateTimePicker/components/PickerPlate/types.js +0 -1
- package/DateTimePicker/components/YearView/YearView.d.ts +0 -3
- package/DateTimePicker/components/YearView/YearView.js +0 -36
- package/DateTimePicker/components/YearView/index.d.ts +0 -1
- package/DateTimePicker/components/YearView/index.js +0 -1
- package/DateTimePicker/components/YearView/types.d.ts +0 -6
- package/DateTimePicker/components/YearView/types.js +0 -1
- package/DateTimePicker/constants.d.ts +0 -5
- package/DateTimePicker/constants.js +0 -9
- package/DateTimePicker/helpers.d.ts +0 -13
- package/DateTimePicker/helpers.js +0 -81
- package/DateTimePicker/index.d.ts +0 -8
- package/DateTimePicker/index.js +0 -8
- package/DateTimePicker/polyglot/index.d.ts +0 -2
- package/DateTimePicker/polyglot/index.js +0 -33
- package/DateTimePicker/polyglot/messages_ar.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_ar.js +0 -11
- package/DateTimePicker/polyglot/messages_bn.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_bn.js +0 -11
- package/DateTimePicker/polyglot/messages_de.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_de.js +0 -11
- package/DateTimePicker/polyglot/messages_en.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_en.js +0 -11
- package/DateTimePicker/polyglot/messages_es.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_es.js +0 -11
- package/DateTimePicker/polyglot/messages_fr.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_fr.js +0 -11
- package/DateTimePicker/polyglot/messages_he.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_he.js +0 -11
- package/DateTimePicker/polyglot/messages_hi.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_hi.js +0 -11
- package/DateTimePicker/polyglot/messages_ja.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_ja.js +0 -11
- package/DateTimePicker/polyglot/messages_ko.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_ko.js +0 -11
- package/DateTimePicker/polyglot/messages_pt.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_pt.js +0 -11
- package/DateTimePicker/polyglot/messages_ru.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_ru.js +0 -11
- package/DateTimePicker/polyglot/messages_th.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_th.js +0 -11
- package/DateTimePicker/polyglot/messages_zh.d.ts +0 -3
- package/DateTimePicker/polyglot/messages_zh.js +0 -11
- package/DateTimePicker/polyglot/types.d.ts +0 -12
- package/DateTimePicker/polyglot/types.js +0 -1
- package/DateTimePicker/styles.d.ts +0 -371
- package/DateTimePicker/styles.js +0 -66
- package/DateTimePicker/types.d.ts +0 -11
- package/DateTimePicker/types.js +0 -1
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useFloating, offset, autoPlacement } from '@floating-ui/react-dom';
|
|
3
|
-
import { useState, useEffect } from 'react';
|
|
4
|
-
import { CalendarIcon } from '@pushwoosh/kit-icons';
|
|
5
|
-
import { useUTCDate } from './helpers';
|
|
6
|
-
import { Lang } from '../../polyglot';
|
|
7
|
-
import { InputFrame } from '../../styles';
|
|
8
|
-
import { DateTimePicker } from '../DateTimePicker';
|
|
9
|
-
/**
|
|
10
|
-
* Read-only field showing the selected date-time that opens a {@link DateTimePicker} popover on click.
|
|
11
|
-
*
|
|
12
|
-
* @deprecated Use `CalendarDropdown` or `CalendarSuperForm` from Calendar instead.
|
|
13
|
-
*/
|
|
14
|
-
export function DateTimePickerField(props) {
|
|
15
|
-
const {
|
|
16
|
-
value,
|
|
17
|
-
minDate,
|
|
18
|
-
maxDate,
|
|
19
|
-
error,
|
|
20
|
-
allowedPlacements = ['bottom-start', 'bottom-end', 'top-start', 'top-end'],
|
|
21
|
-
zIndex = 1000,
|
|
22
|
-
closeOnSelect = false,
|
|
23
|
-
onChange
|
|
24
|
-
} = props;
|
|
25
|
-
const [showPicker, setShowPicker] = useState(false);
|
|
26
|
-
const {
|
|
27
|
-
refs,
|
|
28
|
-
floatingStyles
|
|
29
|
-
} = useFloating({
|
|
30
|
-
middleware: [offset(4), autoPlacement({
|
|
31
|
-
allowedPlacements
|
|
32
|
-
})]
|
|
33
|
-
});
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!showPicker) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const handleClickListener = event => {
|
|
39
|
-
const path = event.composedPath();
|
|
40
|
-
const isInsideFloating = refs.floating.current && path.includes(refs.floating.current);
|
|
41
|
-
const isInsideReference = refs.reference.current && path.includes(refs.reference.current);
|
|
42
|
-
if (!isInsideFloating && !isInsideReference) {
|
|
43
|
-
setShowPicker(false);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
document.addEventListener('click', handleClickListener);
|
|
47
|
-
return () => {
|
|
48
|
-
document.removeEventListener('click', handleClickListener);
|
|
49
|
-
};
|
|
50
|
-
}, [showPicker, refs]);
|
|
51
|
-
const onSelect = date => {
|
|
52
|
-
onChange(date);
|
|
53
|
-
if (closeOnSelect) {
|
|
54
|
-
setShowPicker(false);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const {
|
|
58
|
-
year,
|
|
59
|
-
month,
|
|
60
|
-
day,
|
|
61
|
-
hours,
|
|
62
|
-
minutes
|
|
63
|
-
} = useUTCDate(value);
|
|
64
|
-
return _jsxs(_Fragment, {
|
|
65
|
-
children: [_jsxs(InputFrame, {
|
|
66
|
-
ref: refs.setReference,
|
|
67
|
-
"$empty": !value,
|
|
68
|
-
"$error": error,
|
|
69
|
-
"$gap": 8,
|
|
70
|
-
onClick: () => setShowPicker(!showPicker),
|
|
71
|
-
children: [_jsx(CalendarIcon, {
|
|
72
|
-
size: "medium",
|
|
73
|
-
view: "lined"
|
|
74
|
-
}), value ? `${day} ${month} ${year} ${hours}:${minutes}` : _jsx(Lang, {
|
|
75
|
-
message: "DUMB.DATE_TIME_PICKER.SELECT_DATE_TIME"
|
|
76
|
-
})]
|
|
77
|
-
}), showPicker && _jsx("div", {
|
|
78
|
-
ref: refs.setFloating,
|
|
79
|
-
style: {
|
|
80
|
-
...floatingStyles,
|
|
81
|
-
zIndex
|
|
82
|
-
},
|
|
83
|
-
children: _jsx(DateTimePicker, {
|
|
84
|
-
value: value,
|
|
85
|
-
minDate: minDate,
|
|
86
|
-
maxDate: maxDate,
|
|
87
|
-
onChange: onSelect
|
|
88
|
-
})
|
|
89
|
-
})]
|
|
90
|
-
});
|
|
91
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './DateTimePickerField';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './DateTimePickerField';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { Placement } from '@floating-ui/react-dom';
|
|
2
|
-
/** Props of {@link DateTimePickerField}. */
|
|
3
|
-
export interface DateTimePickerFieldProps {
|
|
4
|
-
/** Currently selected date-time string. */
|
|
5
|
-
value: string;
|
|
6
|
-
/** Earliest selectable date. */
|
|
7
|
-
minDate?: Date | string;
|
|
8
|
-
/** Latest selectable date. */
|
|
9
|
-
maxDate?: Date | string;
|
|
10
|
-
/** Render the field in the error state. */
|
|
11
|
-
error?: boolean;
|
|
12
|
-
/** Allowed floating placements for the popover (default bottom/top start/end). */
|
|
13
|
-
allowedPlacements?: Placement[];
|
|
14
|
-
/** Popover z-index (default `1000`). */
|
|
15
|
-
zIndex?: number;
|
|
16
|
-
/** Close the popover when a value is picked (default `false`). */
|
|
17
|
-
closeOnSelect?: boolean;
|
|
18
|
-
/** Fires with the picked date-time string. */
|
|
19
|
-
onChange: (day: string) => void;
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Columns } from '@pushwoosh/kit-helpers';
|
|
3
|
-
import { format, parseStringToArray, addPeriod, setPeriod } from '../../helpers';
|
|
4
|
-
import { CellBox } from '../../styles';
|
|
5
|
-
import { PickerPlate } from '../PickerPlate';
|
|
6
|
-
export function DecadeView(props) {
|
|
7
|
-
const {
|
|
8
|
-
activeDay,
|
|
9
|
-
value,
|
|
10
|
-
onChange,
|
|
11
|
-
onSelect
|
|
12
|
-
} = props;
|
|
13
|
-
const [activeDayYear] = parseStringToArray(activeDay || '');
|
|
14
|
-
const valueYear = +value;
|
|
15
|
-
const firstYear = valueYear - valueYear % 12;
|
|
16
|
-
return _jsx(PickerPlate, {
|
|
17
|
-
onPrev: () => onChange(format(addPeriod(value, 'year', -12), 'year')),
|
|
18
|
-
onNext: () => onChange(format(addPeriod(value, 'year', 12), 'year')),
|
|
19
|
-
children: _jsx(Columns, {
|
|
20
|
-
"$sizes": 4,
|
|
21
|
-
"$gap": 4,
|
|
22
|
-
children: Array.from({
|
|
23
|
-
length: 12
|
|
24
|
-
}).map((_, i) => {
|
|
25
|
-
const year = firstYear + i;
|
|
26
|
-
return _jsx(CellBox, {
|
|
27
|
-
"$height": "59px",
|
|
28
|
-
"$isActive": year === activeDayYear,
|
|
29
|
-
onClick: () => onSelect(format(setPeriod(value, 'year', year), 'year')),
|
|
30
|
-
children: year
|
|
31
|
-
}, year);
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
});
|
|
35
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './DecadeView';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './DecadeView';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { InputStyled } from './styles';
|
|
3
|
-
export function Input(props) {
|
|
4
|
-
const {
|
|
5
|
-
width,
|
|
6
|
-
isDisabled,
|
|
7
|
-
...rest
|
|
8
|
-
} = props;
|
|
9
|
-
return _jsx(InputStyled, {
|
|
10
|
-
type: "text",
|
|
11
|
-
disabled: isDisabled,
|
|
12
|
-
style: {
|
|
13
|
-
width: width || '100%'
|
|
14
|
-
},
|
|
15
|
-
...rest
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Input';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Input';
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const InputStyled: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "style"> & {
|
|
2
|
-
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
3
|
-
}> & string;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
-
export const InputStyled = styled.input.withConfig({
|
|
4
|
-
displayName: "InputStyled",
|
|
5
|
-
componentId: "sc-17gtn04-0"
|
|
6
|
-
})(["color:", ";-webkit-text-fill-color:", ";background-color:transparent;&::placeholder{color:", ";-webkit-text-fill-color:", ";}&:disabled{background-color:", ";-webkit-text-fill-color:", ";}"], Color.MAIN, Color.MAIN, Color.PHANTOM, Color.PHANTOM, Color.FROZEN, Color.LOCKED);
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import { Columns } from '@pushwoosh/kit-helpers';
|
|
4
|
-
import { format, firstDayOfWeek, parseStringToDate, differenceInDays, isSamePeriod, isInRange } from '../../helpers';
|
|
5
|
-
import { Lang } from '../../polyglot';
|
|
6
|
-
import { CellBox, DayHeader } from '../../styles';
|
|
7
|
-
export function Month(props) {
|
|
8
|
-
const {
|
|
9
|
-
month,
|
|
10
|
-
activeDay,
|
|
11
|
-
userInputDay,
|
|
12
|
-
minDate,
|
|
13
|
-
maxDate,
|
|
14
|
-
onDaySelect
|
|
15
|
-
} = props;
|
|
16
|
-
const [firstDayDate, days] = useMemo(() => {
|
|
17
|
-
const monthDate = parseStringToDate(month);
|
|
18
|
-
const firstDayOfMonth = new Date(monthDate);
|
|
19
|
-
firstDayOfMonth.setUTCDate(1);
|
|
20
|
-
const lastDayOfMonth = new Date(month);
|
|
21
|
-
lastDayOfMonth.setUTCMonth(lastDayOfMonth.getUTCMonth() + 1);
|
|
22
|
-
lastDayOfMonth.setUTCDate(0);
|
|
23
|
-
const firstDayOfFirstWeek = firstDayOfWeek(firstDayOfMonth);
|
|
24
|
-
const firstDayOfLastWeek = firstDayOfWeek(lastDayOfMonth);
|
|
25
|
-
const daysInCalendar = differenceInDays(firstDayOfLastWeek, firstDayOfFirstWeek) + 7;
|
|
26
|
-
return [firstDayOfFirstWeek, daysInCalendar];
|
|
27
|
-
}, [month]);
|
|
28
|
-
return _jsxs(Columns, {
|
|
29
|
-
"$sizes": 7,
|
|
30
|
-
"$gap": 4,
|
|
31
|
-
children: [_jsx(DayHeader, {
|
|
32
|
-
children: _jsx(Lang, {
|
|
33
|
-
message: "DUMB.DATE_TIME_PICKER.WEEKDAY_SUN"
|
|
34
|
-
})
|
|
35
|
-
}), _jsx(DayHeader, {
|
|
36
|
-
children: _jsx(Lang, {
|
|
37
|
-
message: "DUMB.DATE_TIME_PICKER.WEEKDAY_MON"
|
|
38
|
-
})
|
|
39
|
-
}), _jsx(DayHeader, {
|
|
40
|
-
children: _jsx(Lang, {
|
|
41
|
-
message: "DUMB.DATE_TIME_PICKER.WEEKDAY_TUE"
|
|
42
|
-
})
|
|
43
|
-
}), _jsx(DayHeader, {
|
|
44
|
-
children: _jsx(Lang, {
|
|
45
|
-
message: "DUMB.DATE_TIME_PICKER.WEEKDAY_WED"
|
|
46
|
-
})
|
|
47
|
-
}), _jsx(DayHeader, {
|
|
48
|
-
children: _jsx(Lang, {
|
|
49
|
-
message: "DUMB.DATE_TIME_PICKER.WEEKDAY_THU"
|
|
50
|
-
})
|
|
51
|
-
}), _jsx(DayHeader, {
|
|
52
|
-
children: _jsx(Lang, {
|
|
53
|
-
message: "DUMB.DATE_TIME_PICKER.WEEKDAY_FRI"
|
|
54
|
-
})
|
|
55
|
-
}), _jsx(DayHeader, {
|
|
56
|
-
children: _jsx(Lang, {
|
|
57
|
-
message: "DUMB.DATE_TIME_PICKER.WEEKDAY_SAT"
|
|
58
|
-
})
|
|
59
|
-
}), Array.from({
|
|
60
|
-
length: days
|
|
61
|
-
}).map((_, i) => {
|
|
62
|
-
const curDay = new Date(Date.UTC(firstDayDate.getUTCFullYear(), firstDayDate.getUTCMonth(), firstDayDate.getUTCDate() + i));
|
|
63
|
-
const isDisabled = isInRange({
|
|
64
|
-
value: curDay,
|
|
65
|
-
minDate: minDate,
|
|
66
|
-
maxDate: maxDate
|
|
67
|
-
});
|
|
68
|
-
return _jsx(CellBox, {
|
|
69
|
-
"$isActive": !!activeDay && isSamePeriod(curDay, activeDay, 'day'),
|
|
70
|
-
"$isDisabled": isDisabled,
|
|
71
|
-
"$secondary": !isSamePeriod(month, curDay, 'month'),
|
|
72
|
-
"$secondActive": !!userInputDay && isSamePeriod(curDay, userInputDay, 'day'),
|
|
73
|
-
onClick: () => onDaySelect(format(curDay, 'year-month-day')),
|
|
74
|
-
children: curDay.getUTCDate()
|
|
75
|
-
}, `${curDay}`);
|
|
76
|
-
})]
|
|
77
|
-
});
|
|
78
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Month';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Month';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
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 _jsx(PickerPlate, {
|
|
20
|
-
onPrev: () => onChange(format(addPeriod(month, 'month', -1), 'year-month')),
|
|
21
|
-
onNext: () => onChange(format(addPeriod(month, 'month', 1), 'year-month')),
|
|
22
|
-
slot: _jsxs(Horizontal, {
|
|
23
|
-
"$gap": 4,
|
|
24
|
-
children: [_jsx(DateInfo, {
|
|
25
|
-
onClick: onShowYear,
|
|
26
|
-
children: monthName(+format(month, 'month'))
|
|
27
|
-
}), _jsx(DateInfo, {
|
|
28
|
-
onClick: onShowDecade,
|
|
29
|
-
children: format(month, 'year')
|
|
30
|
-
})]
|
|
31
|
-
}),
|
|
32
|
-
children: _jsx(Month, {
|
|
33
|
-
month: month,
|
|
34
|
-
activeDay: activeDay,
|
|
35
|
-
userInputDay: userInputDay,
|
|
36
|
-
minDate: minDate,
|
|
37
|
-
maxDate: maxDate,
|
|
38
|
-
onDaySelect: onDaySelect
|
|
39
|
-
})
|
|
40
|
-
});
|
|
41
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './MonthView';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './MonthView';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface MonthViewProps {
|
|
2
|
-
month: string;
|
|
3
|
-
activeDay?: string;
|
|
4
|
-
userInputDay?: string;
|
|
5
|
-
minDate?: Date | string;
|
|
6
|
-
maxDate?: Date | string;
|
|
7
|
-
onDaySelect: (day: string) => void;
|
|
8
|
-
onShowYear: () => void;
|
|
9
|
-
onShowDecade: () => void;
|
|
10
|
-
onChange: (day: string) => void;
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
2
|
-
import type { NumberPickerProps } from './types';
|
|
3
|
-
export declare function NumberPicker({ value, hint, step, placeholder, focusOnMount, minValue, maxValue, autoSize, isDisabled, onChange, onSubmit, }: NumberPickerProps): ReactElement;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useState, useEffect } from 'react';
|
|
3
|
-
import { Vertical, useMount, usePersistentFunction } from '@pushwoosh/kit-helpers';
|
|
4
|
-
import { ChevronIcon } from '@pushwoosh/kit-icons';
|
|
5
|
-
import { intVal, isStringInteger } from './helpers';
|
|
6
|
-
import { SingleInputFrame } from '../../styles';
|
|
7
|
-
import { AutosizeInput } from '../AutosizeInput';
|
|
8
|
-
import { Input } from '../Input';
|
|
9
|
-
import { Hint } from './styles';
|
|
10
|
-
export function NumberPicker({
|
|
11
|
-
value,
|
|
12
|
-
hint,
|
|
13
|
-
step = 1,
|
|
14
|
-
placeholder,
|
|
15
|
-
focusOnMount,
|
|
16
|
-
minValue,
|
|
17
|
-
maxValue,
|
|
18
|
-
autoSize,
|
|
19
|
-
isDisabled,
|
|
20
|
-
onChange,
|
|
21
|
-
onSubmit
|
|
22
|
-
}) {
|
|
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 _jsxs(SingleInputFrame, {
|
|
84
|
-
ref: ref,
|
|
85
|
-
"$hasHint": !!hint,
|
|
86
|
-
"$isDisabled": isDisabled,
|
|
87
|
-
children: [_jsx(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 && _jsx(Hint, {
|
|
107
|
-
children: hint
|
|
108
|
-
}), _jsxs(Vertical, {
|
|
109
|
-
"$gap": 1,
|
|
110
|
-
children: [_jsx("div", {
|
|
111
|
-
children: _jsx(ChevronIcon, {
|
|
112
|
-
direction: "up",
|
|
113
|
-
size: "small",
|
|
114
|
-
"aria-disabled": "true",
|
|
115
|
-
onClick: () => onChangeDiff(step),
|
|
116
|
-
onMouseDown: () => setAutoDiff(step),
|
|
117
|
-
onMouseUp: resetAutoDiff,
|
|
118
|
-
onMouseLeave: resetAutoDiff
|
|
119
|
-
})
|
|
120
|
-
}), _jsx("div", {
|
|
121
|
-
children: _jsx(ChevronIcon, {
|
|
122
|
-
size: "small",
|
|
123
|
-
direction: "down",
|
|
124
|
-
"aria-disabled": isDisabled,
|
|
125
|
-
onClick: () => onChangeDiff(-1 * step),
|
|
126
|
-
onMouseDown: () => setAutoDiff(-1 * step),
|
|
127
|
-
onMouseUp: resetAutoDiff,
|
|
128
|
-
onMouseLeave: resetAutoDiff
|
|
129
|
-
})
|
|
130
|
-
})]
|
|
131
|
-
})]
|
|
132
|
-
});
|
|
133
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './NumberPicker';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './NumberPicker';
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const Hint: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
|
|
2
|
-
style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
|
|
3
|
-
}> & string;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { Color } 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:8px;color:", ";pointer-events:none;"], Color.PHANTOM);
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Vertical, Horizontal } from '@pushwoosh/kit-helpers';
|
|
3
|
-
import { Arrow } from './styles';
|
|
4
|
-
export function PickerPlate(props) {
|
|
5
|
-
const {
|
|
6
|
-
slot,
|
|
7
|
-
children,
|
|
8
|
-
onPrev,
|
|
9
|
-
onNext
|
|
10
|
-
} = props;
|
|
11
|
-
return _jsxs(Vertical, {
|
|
12
|
-
"$gap": 16,
|
|
13
|
-
children: [_jsxs(Horizontal, {
|
|
14
|
-
"$justifyContent": "space-between",
|
|
15
|
-
children: [slot, _jsxs(Horizontal, {
|
|
16
|
-
"$gap": 4,
|
|
17
|
-
children: [_jsx(Arrow, {
|
|
18
|
-
direction: "left",
|
|
19
|
-
onClick: onPrev
|
|
20
|
-
}), _jsx(Arrow, {
|
|
21
|
-
direction: "right",
|
|
22
|
-
onClick: onNext
|
|
23
|
-
})]
|
|
24
|
-
})]
|
|
25
|
-
}), children]
|
|
26
|
-
});
|
|
27
|
-
}
|