@pushwoosh/dumb-components 1.0.13 → 1.0.14

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.
Files changed (104) hide show
  1. package/DateTimePicker/components/AutosizeInput/AutosizeInput.d.ts +3 -0
  2. package/DateTimePicker/components/AutosizeInput/AutosizeInput.js +35 -0
  3. package/DateTimePicker/components/AutosizeInput/index.d.ts +1 -0
  4. package/DateTimePicker/components/AutosizeInput/index.js +1 -0
  5. package/DateTimePicker/components/AutosizeInput/styles.d.ts +1 -0
  6. package/DateTimePicker/components/AutosizeInput/styles.js +5 -0
  7. package/DateTimePicker/components/AutosizeInput/types.d.ts +10 -0
  8. package/DateTimePicker/components/AutosizeInput/types.js +1 -0
  9. package/DateTimePicker/components/DatePicker/DatePicker.d.ts +3 -0
  10. package/DateTimePicker/components/DatePicker/DatePicker.js +54 -0
  11. package/DateTimePicker/components/DatePicker/index.d.ts +1 -0
  12. package/DateTimePicker/components/DatePicker/index.js +1 -0
  13. package/DateTimePicker/components/DatePicker/types.d.ts +10 -0
  14. package/DateTimePicker/components/DatePicker/types.js +1 -0
  15. package/DateTimePicker/components/DatePickerField/DatePickerField.d.ts +3 -0
  16. package/DateTimePicker/components/DatePickerField/DatePickerField.js +59 -0
  17. package/DateTimePicker/components/DatePickerField/index.d.ts +1 -0
  18. package/DateTimePicker/components/DatePickerField/index.js +1 -0
  19. package/DateTimePicker/components/DatePickerField/types.d.ts +8 -0
  20. package/DateTimePicker/components/DatePickerField/types.js +1 -0
  21. package/DateTimePicker/components/DateTimePicker/DateTimePicker.d.ts +3 -0
  22. package/DateTimePicker/components/DateTimePicker/DateTimePicker.js +54 -0
  23. package/DateTimePicker/components/DateTimePicker/index.d.ts +1 -0
  24. package/DateTimePicker/components/DateTimePicker/index.js +1 -0
  25. package/DateTimePicker/components/DateTimePicker/types.d.ts +5 -0
  26. package/DateTimePicker/components/DateTimePicker/types.js +1 -0
  27. package/DateTimePicker/components/DateTimePickerField/DateTimePickerField.d.ts +3 -0
  28. package/DateTimePicker/components/DateTimePickerField/DateTimePickerField.js +67 -0
  29. package/DateTimePicker/components/DateTimePickerField/helpers.d.ts +8 -0
  30. package/DateTimePicker/components/DateTimePickerField/helpers.js +13 -0
  31. package/DateTimePicker/components/DateTimePickerField/index.d.ts +1 -0
  32. package/DateTimePicker/components/DateTimePickerField/index.js +1 -0
  33. package/DateTimePicker/components/DateTimePickerField/types.d.ts +8 -0
  34. package/DateTimePicker/components/DateTimePickerField/types.js +1 -0
  35. package/DateTimePicker/components/DecadeView/DecadeView.d.ts +3 -0
  36. package/DateTimePicker/components/DecadeView/DecadeView.js +34 -0
  37. package/DateTimePicker/components/DecadeView/index.d.ts +1 -0
  38. package/DateTimePicker/components/DecadeView/index.js +1 -0
  39. package/DateTimePicker/components/DecadeView/types.d.ts +6 -0
  40. package/DateTimePicker/components/DecadeView/types.js +1 -0
  41. package/DateTimePicker/components/Input/Input.d.ts +3 -0
  42. package/DateTimePicker/components/Input/Input.js +17 -0
  43. package/DateTimePicker/components/Input/index.d.ts +1 -0
  44. package/DateTimePicker/components/Input/index.js +1 -0
  45. package/DateTimePicker/components/Input/styles.d.ts +1 -0
  46. package/DateTimePicker/components/Input/styles.js +6 -0
  47. package/DateTimePicker/components/Input/types.d.ts +11 -0
  48. package/DateTimePicker/components/Input/types.js +1 -0
  49. package/DateTimePicker/components/Month/Month.d.ts +3 -0
  50. package/DateTimePicker/components/Month/Month.js +48 -0
  51. package/DateTimePicker/components/Month/index.d.ts +1 -0
  52. package/DateTimePicker/components/Month/index.js +1 -0
  53. package/DateTimePicker/components/Month/types.d.ts +8 -0
  54. package/DateTimePicker/components/Month/types.js +1 -0
  55. package/DateTimePicker/components/MonthView/MonthView.d.ts +3 -0
  56. package/DateTimePicker/components/MonthView/MonthView.js +37 -0
  57. package/DateTimePicker/components/MonthView/index.d.ts +1 -0
  58. package/DateTimePicker/components/MonthView/index.js +1 -0
  59. package/DateTimePicker/components/MonthView/types.d.ts +11 -0
  60. package/DateTimePicker/components/MonthView/types.js +1 -0
  61. package/DateTimePicker/components/NumberPicker/NumberPicker.d.ts +3 -0
  62. package/DateTimePicker/components/NumberPicker/NumberPicker.js +125 -0
  63. package/DateTimePicker/components/NumberPicker/helpers.d.ts +2 -0
  64. package/DateTimePicker/components/NumberPicker/helpers.js +5 -0
  65. package/DateTimePicker/components/NumberPicker/index.d.ts +1 -0
  66. package/DateTimePicker/components/NumberPicker/index.js +1 -0
  67. package/DateTimePicker/components/NumberPicker/styles.d.ts +1 -0
  68. package/DateTimePicker/components/NumberPicker/styles.js +6 -0
  69. package/DateTimePicker/components/NumberPicker/types.d.ts +13 -0
  70. package/DateTimePicker/components/NumberPicker/types.js +1 -0
  71. package/DateTimePicker/components/PickerPlate/PickerPlate.d.ts +3 -0
  72. package/DateTimePicker/components/PickerPlate/PickerPlate.js +25 -0
  73. package/DateTimePicker/components/PickerPlate/index.d.ts +1 -0
  74. package/DateTimePicker/components/PickerPlate/index.js +1 -0
  75. package/DateTimePicker/components/PickerPlate/styles.d.ts +3 -0
  76. package/DateTimePicker/components/PickerPlate/styles.js +9 -0
  77. package/DateTimePicker/components/PickerPlate/types.d.ts +7 -0
  78. package/DateTimePicker/components/PickerPlate/types.js +1 -0
  79. package/DateTimePicker/components/YearView/YearView.d.ts +3 -0
  80. package/DateTimePicker/components/YearView/YearView.js +33 -0
  81. package/DateTimePicker/components/YearView/index.d.ts +1 -0
  82. package/DateTimePicker/components/YearView/index.js +1 -0
  83. package/DateTimePicker/components/YearView/types.d.ts +6 -0
  84. package/DateTimePicker/components/YearView/types.js +1 -0
  85. package/DateTimePicker/constants.d.ts +5 -0
  86. package/DateTimePicker/constants.js +9 -0
  87. package/DateTimePicker/helpers.d.ts +15 -0
  88. package/DateTimePicker/helpers.js +79 -0
  89. package/DateTimePicker/index.d.ts +4 -0
  90. package/DateTimePicker/index.js +4 -0
  91. package/DateTimePicker/styles.d.ts +67 -0
  92. package/DateTimePicker/styles.js +64 -0
  93. package/DateTimePicker/types.d.ts +6 -0
  94. package/DateTimePicker/types.js +1 -0
  95. package/Modal/components/ModalContent/index.d.ts +1 -1
  96. package/Modal/components/ModalContent/index.js +1 -1
  97. package/Modal/components/ModalContent/{styled.js → styles.js} +5 -5
  98. package/Radio/Radio.js +1 -1
  99. package/Radio/{styled.js → styles.js} +2 -2
  100. package/index.d.ts +2 -1
  101. package/index.js +2 -1
  102. package/package.json +1 -1
  103. /package/Modal/components/ModalContent/{styled.d.ts → styles.d.ts} +0 -0
  104. /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,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { NumberPickerProps } from './types';
3
+ export declare function NumberPicker(props: NumberPickerProps): ReactElement;
@@ -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,2 @@
1
+ export declare const intVal: (value: any) => number;
2
+ export declare const isStringInteger: (value: string) => boolean;
@@ -0,0 +1,5 @@
1
+ export const intVal = value => {
2
+ const num = parseInt(value, 10);
3
+ return Number.isNaN(num) ? 0 : num;
4
+ };
5
+ export const isStringInteger = value => /^-?\d+$/.test(value);
@@ -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,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { PickerPlateProps } from './types';
3
+ export declare function PickerPlate(props: PickerPlateProps): ReactElement;
@@ -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,3 @@
1
+ export declare const Arrow: import("styled-components").StyledComponent<import("react").FC<import("@pushwoosh/kit-icons").ArrowIconProps>, any, {
2
+ size: "medium";
3
+ }, "size">;
@@ -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,7 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface PickerPlateProps {
3
+ slot?: ReactNode;
4
+ onPrev: () => void;
5
+ onNext: () => void;
6
+ children: ReactNode;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { YearViewProps } from './types';
3
+ export declare function YearView(props: YearViewProps): ReactElement;
@@ -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,6 @@
1
+ export interface YearViewProps {
2
+ activeDay?: string;
3
+ year: string;
4
+ onChange: (year: string) => void;
5
+ onSelect: (month: string) => void;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { Period } from './types';
2
+ export declare const allPeriods: Period[];
3
+ export declare const periodMethodMap: {
4
+ [key in Period]: string;
5
+ };
@@ -0,0 +1,9 @@
1
+ export const allPeriods = ['year', 'month', 'day', 'hour', 'minute', 'second'];
2
+ export const periodMethodMap = {
3
+ second: 'Seconds',
4
+ minute: 'Minutes',
5
+ hour: 'Hours',
6
+ day: 'Date',
7
+ month: 'Month',
8
+ year: 'FullYear'
9
+ };
@@ -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,4 @@
1
+ export { DatePicker } from './components/DatePicker';
2
+ export { DatePickerField } from './components/DatePickerField';
3
+ export { DateTimePicker } from './components/DateTimePicker';
4
+ export { DateTimePickerField } from './components/DateTimePickerField';
@@ -0,0 +1,4 @@
1
+ export { DatePicker } from './components/DatePicker';
2
+ export { DatePickerField } from './components/DatePickerField';
3
+ export { DateTimePicker } from './components/DateTimePicker';
4
+ export { DateTimePickerField } from './components/DateTimePickerField';
@@ -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,6 @@
1
+ export type Period = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second';
2
+ export type RangeOptions = {
3
+ value: Date;
4
+ minDate?: Date;
5
+ maxDate?: Date;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- export { ModalHeader, ModalBodyGroup, ModalBodyItem, ModalBody, ModalFooter, } from './styled';
1
+ export { ModalHeader, ModalBodyGroup, ModalBodyItem, ModalBody, ModalFooter, } from './styles';
@@ -1 +1 @@
1
- export { ModalHeader, ModalBodyGroup, ModalBodyItem, ModalBody, ModalFooter } from './styled';
1
+ export { ModalHeader, ModalBodyGroup, ModalBodyItem, ModalBody, ModalFooter } from './styles';