@pushwoosh/dumb-components 1.1.46 → 1.1.48

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 (53) hide show
  1. package/Calendar/CalendarDropdown/CalendarDropdown.d.ts +3 -0
  2. package/Calendar/CalendarDropdown/CalendarDropdown.js +158 -0
  3. package/Calendar/CalendarDropdown/helpers.d.ts +3 -0
  4. package/Calendar/CalendarDropdown/helpers.js +29 -0
  5. package/Calendar/CalendarDropdown/index.d.ts +2 -0
  6. package/Calendar/CalendarDropdown/index.js +1 -0
  7. package/Calendar/CalendarDropdown/styles.d.ts +61 -0
  8. package/Calendar/CalendarDropdown/styles.js +16 -0
  9. package/Calendar/CalendarDropdown/types.d.ts +40 -0
  10. package/Calendar/CalendarDropdown/types.js +1 -0
  11. package/Calendar/CalendarMonth/CalendarMonth.d.ts +3 -0
  12. package/Calendar/CalendarMonth/CalendarMonth.js +109 -0
  13. package/Calendar/CalendarMonth/styles.d.ts +7 -0
  14. package/Calendar/CalendarMonth/styles.js +48 -0
  15. package/Calendar/CalendarMonth/types.d.ts +17 -0
  16. package/Calendar/CalendarMonth/types.js +1 -0
  17. package/Calendar/CalendarMonthSlider/CalendarMonthSlider.d.ts +11 -0
  18. package/Calendar/CalendarMonthSlider/CalendarMonthSlider.js +141 -0
  19. package/Calendar/CalendarMonthSlider/styles.d.ts +67 -0
  20. package/Calendar/CalendarMonthSlider/styles.js +40 -0
  21. package/Calendar/CalendarSuperForm/CalendarSuperForm.d.ts +3 -0
  22. package/Calendar/CalendarSuperForm/CalendarSuperForm.js +101 -0
  23. package/Calendar/CalendarSuperForm/components/CalendarRangePicker/CalendarRangePicker.d.ts +19 -0
  24. package/Calendar/CalendarSuperForm/components/CalendarRangePicker/CalendarRangePicker.js +57 -0
  25. package/Calendar/CalendarSuperForm/components/CalendarRangePicker/getDisabledRanges.d.ts +14 -0
  26. package/Calendar/CalendarSuperForm/components/CalendarRangePicker/getDisabledRanges.js +62 -0
  27. package/Calendar/CalendarSuperForm/components/CalendarTimeAndTimezoneSection/CalendarTimeAndTimezoneSection.d.ts +3 -0
  28. package/Calendar/CalendarSuperForm/components/CalendarTimeAndTimezoneSection/CalendarTimeAndTimezoneSection.js +135 -0
  29. package/Calendar/CalendarSuperForm/components/CalendarTimeAndTimezoneSection/types.d.ts +18 -0
  30. package/Calendar/CalendarSuperForm/components/CalendarTimeAndTimezoneSection/types.js +1 -0
  31. package/Calendar/CalendarSuperForm/components/CalendarTimeInput.d.ts +19 -0
  32. package/Calendar/CalendarSuperForm/components/CalendarTimeInput.js +25 -0
  33. package/Calendar/CalendarSuperForm/components/CalendarTimezoneSelect.d.ts +9 -0
  34. package/Calendar/CalendarSuperForm/components/CalendarTimezoneSelect.js +26 -0
  35. package/Calendar/CalendarSuperForm/index.d.ts +2 -0
  36. package/Calendar/CalendarSuperForm/index.js +1 -0
  37. package/Calendar/CalendarSuperForm/types.d.ts +56 -0
  38. package/Calendar/CalendarSuperForm/types.js +1 -0
  39. package/Calendar/constants.d.ts +5 -0
  40. package/Calendar/constants.js +10 -0
  41. package/Calendar/helpers-tz.d.ts +7 -0
  42. package/Calendar/helpers-tz.js +100 -0
  43. package/Calendar/helpers.d.ts +22 -0
  44. package/Calendar/helpers.js +134 -0
  45. package/Calendar/index.d.ts +2 -0
  46. package/Calendar/index.js +2 -0
  47. package/Calendar/types.d.ts +19 -0
  48. package/Calendar/types.js +1 -0
  49. package/Popover/styles.js +3 -3
  50. package/index.d.ts +1 -0
  51. package/index.js +1 -0
  52. package/native/NativeTimeInput.js +2 -2
  53. package/package.json +3 -2
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ export type CalendarTimeInputProps<T extends {
3
+ hour: number;
4
+ minute: number;
5
+ }> = {
6
+ value?: T;
7
+ onChange: (newValue: {
8
+ hour: number;
9
+ minute: number;
10
+ second: number;
11
+ millisecond: number;
12
+ }) => void;
13
+ disabled?: boolean;
14
+ endPeriod?: boolean;
15
+ };
16
+ export declare const CalendarTimeInput: <T extends {
17
+ hour: number;
18
+ minute: number;
19
+ }>({ value, onChange, disabled, endPeriod, }: CalendarTimeInputProps<T>) => React.JSX.Element;
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { NativeTimeInput } from '../../../native';
3
+ import { formatTwoDigitNumber } from '../../helpers';
4
+ export const CalendarTimeInput = ({
5
+ value,
6
+ onChange,
7
+ disabled,
8
+ endPeriod
9
+ }) => {
10
+ const defaultHour = endPeriod ? 23 : 0;
11
+ const defaultMinute = endPeriod ? 59 : 0;
12
+ return React.createElement(NativeTimeInput, {
13
+ value: `${formatTwoDigitNumber((value === null || value === void 0 ? void 0 : value.hour) ?? defaultHour)}:${formatTwoDigitNumber((value === null || value === void 0 ? void 0 : value.minute) ?? defaultMinute)}`,
14
+ onChange: e => {
15
+ const [hour, minute] = e.target.value.split(':').map(Number);
16
+ onChange({
17
+ hour,
18
+ minute,
19
+ second: endPeriod ? 59 : 0,
20
+ millisecond: endPeriod ? 999 : 0
21
+ });
22
+ },
23
+ disabled: disabled
24
+ });
25
+ };
@@ -0,0 +1,9 @@
1
+ import { type FC } from 'react';
2
+ import { type TzValue } from '../../types';
3
+ type CalendarTimezoneSelectProps = {
4
+ timezone: TzValue;
5
+ onChange: (timezone: TzValue) => void;
6
+ isDisabled?: boolean;
7
+ };
8
+ export declare const CalendarTimezoneSelect: FC<CalendarTimezoneSelectProps>;
9
+ export {};
@@ -0,0 +1,26 @@
1
+ import React, { useMemo } from 'react';
2
+ import { Select } from '../../../Select';
3
+ import { getSortedTimezones } from '../../helpers-tz';
4
+ export const CalendarTimezoneSelect = ({
5
+ timezone,
6
+ onChange,
7
+ isDisabled
8
+ }) => {
9
+ const timezonesOptions = useMemo(() => {
10
+ return getSortedTimezones();
11
+ }, []);
12
+ return React.createElement(Select, {
13
+ value: timezonesOptions.find(op => op.value === timezone),
14
+ onChange: value => onChange(value.value),
15
+ options: timezonesOptions,
16
+ isDisabled: isDisabled,
17
+ menuPortalTarget: document.body,
18
+ menuPosition: "fixed",
19
+ styles: {
20
+ menu: provided => ({
21
+ ...provided,
22
+ width: '300px'
23
+ })
24
+ }
25
+ });
26
+ };
@@ -0,0 +1,2 @@
1
+ export { CalendarSuperForm } from './CalendarSuperForm';
2
+ export { type CalendarSuperFormProps } from './types';
@@ -0,0 +1 @@
1
+ export { CalendarSuperForm } from './CalendarSuperForm';
@@ -0,0 +1,56 @@
1
+ import { type DateStruct, type DateTimeStruct, type RangeValue, type SingleValue, type TzValue } from '../types';
2
+ interface BaseProps {
3
+ /** Количество видимых месяцев. */
4
+ visibleCount?: number;
5
+ /** Ширина одного месяца. */
6
+ monthWidth?: number;
7
+ /** Промежуток между месяцами. */
8
+ gap?: number;
9
+ /** Отключить даты до этой (включительно). */
10
+ disableOnAndBefore?: DateStruct;
11
+ /** Отключить даты после этой (включительно). */
12
+ disableOnAndAfter?: DateStruct;
13
+ /** Первый день недели: 0 - воскресенье, 1 - понедельник. По умолчанию 0. */
14
+ firstDayOfWeek?: 0 | 1;
15
+ }
16
+ export type CalendarMode = 'single-date' | 'single-datetime' | 'range-date' | 'range-datetime';
17
+ export interface CalendarSingleDateProps extends BaseProps {
18
+ mode: 'single-date';
19
+ /** Временная зона не нужна и запрещена */
20
+ timezone?: never;
21
+ onChangeTimezone?: never;
22
+ minDays?: never;
23
+ maxDays?: never;
24
+ value?: SingleValue<DateStruct>;
25
+ onChange: (value: SingleValue<DateStruct>) => void;
26
+ }
27
+ export interface CalendarSingleDateTimeProps extends BaseProps {
28
+ mode: 'single-datetime';
29
+ /** Требуется, IANA-название таймзоны (напр., 'America/New_York') */
30
+ timezone: TzValue;
31
+ onChangeTimezone: (timezone: TzValue) => void;
32
+ minDays?: never;
33
+ maxDays?: never;
34
+ value?: SingleValue<DateTimeStruct>;
35
+ onChange: (payload: SingleValue<DateTimeStruct>) => void;
36
+ }
37
+ export interface CalendarRangeDateProps extends BaseProps {
38
+ mode: 'range-date';
39
+ timezone?: never;
40
+ onChangeTimezone?: never;
41
+ minDays?: number;
42
+ maxDays?: number;
43
+ value: RangeValue<DateStruct>;
44
+ onChange: (value: RangeValue<DateStruct>) => void;
45
+ }
46
+ export interface CalendarRangeDateTimeProps extends BaseProps {
47
+ mode: 'range-datetime';
48
+ timezone: TzValue;
49
+ onChangeTimezone: (timezone: TzValue) => void;
50
+ minDays?: number;
51
+ maxDays?: number;
52
+ value: RangeValue<DateTimeStruct>;
53
+ onChange: (payload: RangeValue<DateTimeStruct>) => void;
54
+ }
55
+ export type CalendarSuperFormProps = CalendarSingleDateProps | CalendarSingleDateTimeProps | CalendarRangeDateProps | CalendarRangeDateTimeProps;
56
+ export {};
@@ -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,10 @@
1
+ export const allPeriods = ['year', 'month', 'day', 'hour', 'minute', 'second', 'millisecond'];
2
+ export const periodMethodMap = {
3
+ millisecond: 'Milliseconds',
4
+ second: 'Seconds',
5
+ minute: 'Minutes',
6
+ hour: 'Hours',
7
+ day: 'Date',
8
+ month: 'Month',
9
+ year: 'FullYear'
10
+ };
@@ -0,0 +1,7 @@
1
+ export type TimezoneOption = {
2
+ value: string;
3
+ label: string;
4
+ };
5
+ export declare function getSortedTimezones(): TimezoneOption[];
6
+ export declare function groupTimezonesByOffset(at?: Date): [number, string[]][];
7
+ export declare function formatTimezoneShort(timezone: string): string;
@@ -0,0 +1,100 @@
1
+ import { formatTwoDigitNumber } from './helpers';
2
+ function getAllTimeZones() {
3
+ return Intl.supportedValuesOf('timeZone');
4
+ }
5
+ function formatTimezoneOffset(minutes) {
6
+ const minutesAbs = Math.abs(minutes);
7
+ const hours = Math.floor(minutesAbs / 60);
8
+ const mins = minutesAbs % 60;
9
+ const sign = minutes < 0 ? '-' : '+';
10
+ if (mins === 0) {
11
+ return `UTC${sign}${hours}`;
12
+ } else {
13
+ return `UTC${sign}${hours}:${formatTwoDigitNumber(mins)}`;
14
+ }
15
+ }
16
+ function getTimezoneDifferenceInMinutes(timezoneName, at = new Date()) {
17
+ var _parts$find, _parts$find2, _parts$find3, _parts$find4, _parts$find5, _parts$find6;
18
+ const dtf = new Intl.DateTimeFormat('en-US', {
19
+ timeZone: timezoneName,
20
+ hour12: false,
21
+ year: 'numeric',
22
+ month: '2-digit',
23
+ day: '2-digit',
24
+ hour: '2-digit',
25
+ minute: '2-digit',
26
+ second: '2-digit'
27
+ });
28
+ const parts = dtf.formatToParts(at);
29
+ const y = Number((_parts$find = parts.find(p => p.type === 'year')) === null || _parts$find === void 0 ? void 0 : _parts$find.value);
30
+ const mo = Number((_parts$find2 = parts.find(p => p.type === 'month')) === null || _parts$find2 === void 0 ? void 0 : _parts$find2.value) - 1;
31
+ const d = Number((_parts$find3 = parts.find(p => p.type === 'day')) === null || _parts$find3 === void 0 ? void 0 : _parts$find3.value);
32
+ const h = Number((_parts$find4 = parts.find(p => p.type === 'hour')) === null || _parts$find4 === void 0 ? void 0 : _parts$find4.value);
33
+ const mi = Number((_parts$find5 = parts.find(p => p.type === 'minute')) === null || _parts$find5 === void 0 ? void 0 : _parts$find5.value);
34
+ const s = Number((_parts$find6 = parts.find(p => p.type === 'second')) === null || _parts$find6 === void 0 ? void 0 : _parts$find6.value);
35
+ const asUTC = Date.UTC(y, mo, d, h, mi, s);
36
+ return Math.round((asUTC - at.getTime()) / 60000);
37
+ }
38
+ export function getSortedTimezones() {
39
+ const timezones = getAllTimeZones();
40
+ const now = new Date();
41
+ return [...timezones, 'UTC'].map(tz => {
42
+ const offset = getTimezoneDifferenceInMinutes(tz, now);
43
+ const offsetFormatted = formatTimezoneOffset(offset);
44
+ let displayName;
45
+ if (tz === 'UTC') {
46
+ displayName = 'Coordinated Universal Time';
47
+ } else if (tz.includes('/')) {
48
+ const parts = tz.split('/');
49
+ if (parts.length >= 2) {
50
+ const country = parts[0].replace(/_/g, ' ');
51
+ const city = parts[parts.length - 1].replace(/_/g, ' ');
52
+ displayName = `${city} / ${country}`;
53
+ } else {
54
+ displayName = tz.replace(/_/g, ' ');
55
+ }
56
+ } else {
57
+ displayName = tz.replace(/_/g, ' ');
58
+ }
59
+ return {
60
+ value: tz,
61
+ label: `${offsetFormatted} – ${displayName}`
62
+ };
63
+ }).sort((a, b) => {
64
+ if (a.value === 'UTC') return -1;
65
+ if (b.value === 'UTC') return 1;
66
+ return a.label.localeCompare(b.label);
67
+ });
68
+ }
69
+ export function groupTimezonesByOffset(at = new Date()) {
70
+ const zones = getAllTimeZones();
71
+ const groups = new Map();
72
+ for (const tz of zones) {
73
+ try {
74
+ const diff = getTimezoneDifferenceInMinutes(tz, at);
75
+ const arr = groups.get(diff);
76
+ if (arr) {
77
+ arr.push(tz);
78
+ } else {
79
+ groups.set(diff, [tz]);
80
+ }
81
+ } catch (e) {
82
+ console.warn(`Cannot get timezone info for "${tz}"`, e);
83
+ }
84
+ }
85
+ const result = [];
86
+ for (const [diff, list] of groups) {
87
+ list.sort((a, b) => a.localeCompare(b));
88
+ result.push([diff, list]);
89
+ }
90
+ result.sort((a, b) => a[0] - b[0]);
91
+ return result;
92
+ }
93
+ export function formatTimezoneShort(timezone) {
94
+ const offsetMinutes = getTimezoneDifferenceInMinutes(timezone, new Date());
95
+ const formattedOffset = formatTimezoneOffset(offsetMinutes);
96
+ if (formattedOffset === 'UTC+0' || formattedOffset === 'UTC-0') {
97
+ return 'UTC';
98
+ }
99
+ return formattedOffset;
100
+ }
@@ -0,0 +1,22 @@
1
+ import type { DateStruct, DateTimeStruct, Period } from './types';
2
+ export declare const utcDateToStruct: (date: Date) => DateTimeStruct;
3
+ export declare const parseStringToArray: <T extends string>(datetime: T) => number[];
4
+ export declare const createStruct: (year: number, month?: number, day?: number, hour?: number, minute?: number, second?: number, millisecond?: number) => DateTimeStruct;
5
+ export declare const createUTCDate: (year: number, month?: number, day?: number, hour?: number, minute?: number, second?: number, millisecond?: number) => Date;
6
+ export declare const parseStringToDate: (date: string) => Date;
7
+ export declare const formatTwoDigitNumber: (value: number) => string;
8
+ export declare const formatStruct: (ds: DateStruct, template: string) => string;
9
+ export declare const addPeriod: <T extends DateTimeStruct | DateStruct>(ds: T, period: Period, value: number) => T;
10
+ export declare const pickDateStruct: (date: DateTimeStruct) => DateStruct;
11
+ export declare const setPeriodStruct: <T extends DateTimeStruct | DateStruct>(ds: T, period: Period, value: number) => T;
12
+ export declare const extendPeriodStruct: (struct: DateTimeStruct, extend: Partial<DateTimeStruct>) => DateTimeStruct;
13
+ export declare const differenceInDays: (ds1: DateStruct, ds2: DateStruct) => number;
14
+ export declare const monthName: (month: number, monthFormat?: "short" | "long") => string;
15
+ export declare const isSamePeriod: <T extends DateTimeStruct | DateStruct>(ds1: T, ds2: T, period: Period) => boolean;
16
+ export declare const compareStructs: <T extends DateTimeStruct | DateStruct>(ds1: T, ds2: T) => 1 | 0 | -1;
17
+ export declare const getFirstDayOfWeek: (date: DateStruct, firstDayOfWeek?: number) => DateStruct;
18
+ export declare const getLastDayOfMonth: (date: DateStruct) => DateStruct;
19
+ export declare const getPeriodStart: (date: DateTimeStruct | DateStruct, period: Period) => DateTimeStruct;
20
+ export declare const getPeriodEnd: (date: DateTimeStruct | DateStruct, period: Period) => DateTimeStruct;
21
+ export declare const dateToStruct: (date: Date, tzOffsetMinutes: number) => DateTimeStruct;
22
+ export declare const structToDate: (ds: DateTimeStruct, tzOffsetMinutes: number) => Date;
@@ -0,0 +1,134 @@
1
+ import { allPeriods, periodMethodMap } from './constants';
2
+ export const utcDateToStruct = date => ({
3
+ year: date.getUTCFullYear(),
4
+ month: date.getUTCMonth() + 1,
5
+ day: date.getUTCDate(),
6
+ hour: date.getUTCHours(),
7
+ minute: date.getUTCMinutes(),
8
+ second: date.getUTCSeconds(),
9
+ millisecond: date.getUTCMilliseconds()
10
+ });
11
+ export const parseStringToArray = datetime => datetime.split(/[.\s-T:]/).map(Number);
12
+ export const createStruct = (year, month = 1, day = 1, hour = 0, minute = 0, second = 0, millisecond = 0) => {
13
+ return {
14
+ year,
15
+ month,
16
+ day,
17
+ hour,
18
+ minute,
19
+ second,
20
+ millisecond
21
+ };
22
+ };
23
+ export const createUTCDate = (year, month = 1, day = 1, hour = 0, minute = 0, second = 0, millisecond = 0) => new Date(Date.UTC(year, month - 1, day, hour, minute, second, millisecond));
24
+ export const parseStringToDate = date => {
25
+ const args = parseStringToArray(date);
26
+ return createUTCDate(...args);
27
+ };
28
+ export const formatTwoDigitNumber = value => `${value}`.padStart(2, '0');
29
+ export const formatStruct = (ds, template) => {
30
+ return template.replace(/[a-z]+/g, match => {
31
+ const value = ds[match];
32
+ return value !== undefined ? formatTwoDigitNumber(value) : match;
33
+ });
34
+ };
35
+ export const addPeriod = (ds, period, value) => {
36
+ const date = createUTCDate(ds.year, ds.month, ds.day, ds.hour, ds.minute, ds.second);
37
+ const method = periodMethodMap[period];
38
+ date[`setUTC${method}`](date[`getUTC${method}`]() + value);
39
+ return utcDateToStruct(date);
40
+ };
41
+ export const pickDateStruct = date => {
42
+ return {
43
+ year: date.year,
44
+ month: date.month,
45
+ day: date.day
46
+ };
47
+ };
48
+ export const setPeriodStruct = (ds, period, value) => {
49
+ const date = createUTCDate(ds.year, ds.month, ds.day, ds.hour, ds.minute, ds.second);
50
+ const method = periodMethodMap[period];
51
+ date[`setUTC${method}`](period === 'month' ? value - 1 : value);
52
+ return utcDateToStruct(date);
53
+ };
54
+ export const extendPeriodStruct = (struct, extend) => {
55
+ return {
56
+ ...struct,
57
+ ...extend
58
+ };
59
+ };
60
+ export const differenceInDays = (ds1, ds2) => {
61
+ const date1 = createUTCDate(ds1.year, ds1.month, ds1.day);
62
+ const date2 = createUTCDate(ds2.year, ds2.month, ds2.day);
63
+ const diff = Math.abs(date1.getTime() - date2.getTime());
64
+ return Math.floor(diff / (1000 * 3600 * 24));
65
+ };
66
+ export const monthName = (month, monthFormat = 'long') => {
67
+ const date = new Date(2023, month - 1, 1);
68
+ return date.toLocaleString('default', {
69
+ month: monthFormat
70
+ });
71
+ };
72
+ export const isSamePeriod = (ds1, ds2, period) => {
73
+ const periodIdx = allPeriods.indexOf(period);
74
+ for (let i = 0; i <= periodIdx; i += 1) {
75
+ const value1 = ds1[allPeriods[i]];
76
+ const value2 = ds2[allPeriods[i]];
77
+ if (value1 !== value2) {
78
+ return false;
79
+ }
80
+ }
81
+ return true;
82
+ };
83
+ export const compareStructs = (ds1, ds2) => {
84
+ const date1 = createUTCDate(ds1.year, ds1.month, ds1.day, ds1.hour, ds1.minute, ds1.second);
85
+ const date2 = createUTCDate(ds2.year, ds2.month, ds2.day, ds2.hour, ds2.minute, ds2.second);
86
+ if (date1.getTime() === date2.getTime()) {
87
+ return 0;
88
+ }
89
+ return date1 > date2 ? 1 : -1;
90
+ };
91
+ export const getFirstDayOfWeek = (date, firstDayOfWeek = 0) => {
92
+ const utcDate = createUTCDate(date.year, date.month, date.day);
93
+ const day = utcDate.getUTCDay();
94
+ let diff;
95
+ if (firstDayOfWeek === 0) {
96
+ diff = day;
97
+ } else {
98
+ diff = day === 0 ? 6 : day - 1;
99
+ }
100
+ if (diff > 0) {
101
+ utcDate.setUTCDate(utcDate.getUTCDate() - diff);
102
+ }
103
+ return utcDateToStruct(utcDate);
104
+ };
105
+ export const getLastDayOfMonth = date => {
106
+ const d = createUTCDate(date.year, date.month, 1);
107
+ d.setUTCMonth(d.getUTCMonth() + 1);
108
+ d.setUTCDate(0);
109
+ return utcDateToStruct(d);
110
+ };
111
+ export const getPeriodStart = (date, period) => {
112
+ const idx = allPeriods.indexOf(period);
113
+ const values = allPeriods.slice(0, idx + 1).map(period => date[period] || 0);
114
+ const dateObj = createUTCDate(...values);
115
+ return utcDateToStruct(dateObj);
116
+ };
117
+ export const getPeriodEnd = (date, period) => {
118
+ const idx = allPeriods.indexOf(period);
119
+ const values = allPeriods.slice(0, idx + 1).map(period => date[period] || 0);
120
+ const dateObj = createUTCDate(...values);
121
+ const method = periodMethodMap[period];
122
+ dateObj[`setUTC${method}`](dateObj[`getUTC${method}`]() + 1);
123
+ dateObj.setMilliseconds(-1);
124
+ return utcDateToStruct(dateObj);
125
+ };
126
+ export const dateToStruct = (date, tzOffsetMinutes) => {
127
+ const utcTime = date.getTime() + date.getTimezoneOffset() * 60_000;
128
+ const localTime = new Date(utcTime + tzOffsetMinutes * 60_000);
129
+ return utcDateToStruct(localTime);
130
+ };
131
+ export const structToDate = (ds, tzOffsetMinutes) => {
132
+ const utcTime = Date.UTC(ds.year, ds.month - 1, ds.day, ds.hour, ds.minute, ds.second, ds.millisecond);
133
+ return new Date(utcTime - tzOffsetMinutes * 60_000);
134
+ };
@@ -0,0 +1,2 @@
1
+ export { CalendarSuperForm, type CalendarSuperFormProps } from './CalendarSuperForm';
2
+ export { CalendarDropdown, type CalendarDropdownProps } from './CalendarDropdown';
@@ -0,0 +1,2 @@
1
+ export { CalendarSuperForm } from './CalendarSuperForm';
2
+ export { CalendarDropdown } from './CalendarDropdown';
@@ -0,0 +1,19 @@
1
+ export type Period = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
2
+ export type DateStruct = {
3
+ year: number;
4
+ month: number;
5
+ day: number;
6
+ };
7
+ export type DateTimeStruct = {
8
+ year: number;
9
+ month: number;
10
+ day: number;
11
+ hour: number;
12
+ minute: number;
13
+ second: number;
14
+ millisecond: number;
15
+ };
16
+ export type SingleValue<T> = T;
17
+ export type RangeValue<T> = [from: T, to: T] | [from: T] | [];
18
+ /** Тип для значения часового пояса (IANA-название). */
19
+ export type TzValue = string;
@@ -0,0 +1 @@
1
+ export {};
package/Popover/styles.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import Tippy from '@tippyjs/react';
2
2
  import styled from 'styled-components';
3
- import { Color, ShapeRadius, Spacing } from '@pushwoosh/kit-constants';
3
+ import { Color, ShapeRadius } from '@pushwoosh/kit-constants';
4
4
  export const PopoverContainer = styled.div.withConfig({
5
5
  displayName: "PopoverContainer",
6
6
  componentId: "sc-qsqk3z-0"
@@ -8,9 +8,9 @@ export const PopoverContainer = styled.div.withConfig({
8
8
  export const PopoverContainerWindow = styled.div.withConfig({
9
9
  displayName: "PopoverContainerWindow",
10
10
  componentId: "sc-qsqk3z-1"
11
- })(["min-width:", ";padding:", ";border:1px solid ", ";border-radius:", ";background:", ";transition:visibility 50ms linear;> *{opacity:", ";}"], ({
11
+ })(["min-width:", ";border:1px solid ", ";border-radius:", ";background:", ";transition:visibility 50ms linear;> *{opacity:", ";}"], ({
12
12
  $minWidth
13
- }) => $minWidth ? `${$minWidth}px` : 'auto', Spacing.S5, Color.FORM, ShapeRadius.DIALOG, Color.CLEAR, ({
13
+ }) => $minWidth ? `${$minWidth}px` : 'auto', Color.FORM, ShapeRadius.DIALOG, Color.CLEAR, ({
14
14
  $isLoading
15
15
  }) => $isLoading ? '0.5' : '1');
16
16
  export const PopoverContainerPortal = styled(Tippy).withConfig({
package/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { Button, GhostButton } from './Button';
5
5
  export { CardMetric } from './CardMetric';
6
6
  export { Checkbox } from './Checkbox';
7
7
  export { Drawer, DrawerHeader, DrawerTitle, DrawerBody, DrawerDocs, useDocs, } from './Drawer';
8
+ export { CalendarSuperForm, type CalendarSuperFormProps, CalendarDropdown, type CalendarDropdownProps, } from './Calendar';
8
9
  export { DatePicker, DatePickerField, DateTimePicker, DateTimePickerField, } from './DateTimePicker';
9
10
  export { DropdownMenu, DropdownMenuButton, DropdownMenuSection, DropdownMenuItem, } from './DropdownMenu';
10
11
  export { GetStartedPage } from './GetStartedPage';
package/index.js CHANGED
@@ -5,6 +5,7 @@ export { Button, GhostButton } from './Button';
5
5
  export { CardMetric } from './CardMetric';
6
6
  export { Checkbox } from './Checkbox';
7
7
  export { Drawer, DrawerHeader, DrawerTitle, DrawerBody, DrawerDocs, useDocs } from './Drawer';
8
+ export { CalendarSuperForm, CalendarDropdown } from './Calendar';
8
9
  export { DatePicker, DatePickerField, DateTimePicker, DateTimePickerField } from './DateTimePicker';
9
10
  export { DropdownMenu, DropdownMenuButton, DropdownMenuSection, DropdownMenuItem } from './DropdownMenu';
10
11
  export { GetStartedPage } from './GetStartedPage';
@@ -1,8 +1,8 @@
1
1
  import styled from 'styled-components';
2
- import { Color } from '@pushwoosh/kit-constants';
2
+ import { Color, FontSize, LineHeight, ShapeRadius, UnitSize } from '@pushwoosh/kit-constants';
3
3
  export const NativeTimeInput = styled.input.attrs({
4
4
  type: 'time'
5
5
  }).withConfig({
6
6
  displayName: "NativeTimeInput",
7
7
  componentId: "sc-r1vjhd-0"
8
- })(["border:1px solid ", ";border-radius:4px;color:", ";font-size:14px;line-height:1.4;padding:8px 12px;height:36px;box-sizing:border-box;appearance:none;&:focus{border-color:", ";outline:none;}&::-webkit-calendar-picker-indicator{display:none;-webkit-appearance:none;}"], Color.FORM, Color.MAIN, Color.BRIGHT);
8
+ })(["border:1px solid ", ";border-radius:", ";color:", ";font-size:", ";line-height:", ";padding:8px 12px;height:", ";box-sizing:border-box;appearance:none;&:focus{border-color:", ";outline:none;}&::-webkit-calendar-picker-indicator{display:none;-webkit-appearance:none;}"], Color.FORM, ShapeRadius.CONTROL, Color.MAIN, FontSize.REGULAR, LineHeight.REGULAR, UnitSize.FIELD_HEIGHT, Color.BRIGHT);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.46",
3
+ "version": "1.1.48",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -12,6 +12,7 @@
12
12
  "copy-docs": "node scripts/copy-docs.js",
13
13
  "check": "npm run check:lint && npm run check:types",
14
14
  "check:lint": "echo \"Run check:lint\" && eslint src",
15
+ "check:lint-fix": "echo \"Run check:lint\" && eslint src --fix",
15
16
  "check:types": "echo \"Run check:types\" && pushwoosh-engine lib:check-types"
16
17
  },
17
18
  "pre-commit": "check",
@@ -20,7 +21,7 @@
20
21
  "npm": ">= 7"
21
22
  },
22
23
  "devDependencies": {
23
- "@pushwoosh/frontend-builder-engine": "^1.0.16",
24
+ "@pushwoosh/frontend-builder-engine": "^1.0.21",
24
25
  "@svgr/webpack": "^8.1.0",
25
26
  "@types/lodash": "^4.17.13",
26
27
  "@types/react": "^18.2.69",