@pushwoosh/dumb-components 1.1.64 → 1.1.66

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.
@@ -18,7 +18,8 @@ export const CalendarSuperForm = props => {
18
18
  visibleCount,
19
19
  monthWidth,
20
20
  gap,
21
- firstDayOfWeek
21
+ firstDayOfWeek,
22
+ footerContent
22
23
  } = props;
23
24
  const isRangePicker = mode === 'range-date' || mode === 'range-datetime';
24
25
  const withTime = mode === 'single-datetime' || mode === 'range-datetime';
@@ -78,16 +79,16 @@ export const CalendarSuperForm = props => {
78
79
  visibleCount: visibleCount !== undefined ? visibleCount : isRangePicker ? 2 : 1,
79
80
  monthWidth: monthWidth,
80
81
  gap: gap,
81
- renderAfter: withTime || maxDays && maxDays > 0 ? () => {
82
+ renderAfter: withTime || maxDays && maxDays > 0 || footerContent ? () => {
82
83
  return React.createElement(Vertical, {
83
84
  "$gap": 8,
84
85
  "$margin": {
85
86
  top: 16
86
87
  }
87
- }, maxDays && maxDays > 0 && React.createElement(Text, {
88
+ }, React.createElement(Vertical, null, maxDays && maxDays > 0 && React.createElement(Text, {
88
89
  "$variant": "footnote",
89
90
  "$color": Color.LOCKED
90
- }, `Max length: ${maxDays} days`), withTime && timezone && onChangeTimezone && React.createElement(CalendarTimeAndTimezoneSection, {
91
+ }, `Max length: ${maxDays} days`), footerContent), withTime && timezone && onChangeTimezone && React.createElement(CalendarTimeAndTimezoneSection, {
91
92
  isRangePicker: isRangePicker,
92
93
  value: value,
93
94
  onChange: onChange,
@@ -1,3 +1,4 @@
1
+ import { type ReactNode } from 'react';
1
2
  import { type DateStruct, type DateTimeStruct, type RangeValue, type SingleValue, type TzValue } from '../types';
2
3
  interface BaseProps {
3
4
  /** Количество видимых месяцев. */
@@ -12,6 +13,8 @@ interface BaseProps {
12
13
  disableOnAndAfter?: DateStruct;
13
14
  /** Первый день недели: 0 - воскресенье, 1 - понедельник. По умолчанию 0. */
14
15
  firstDayOfWeek?: 0 | 1;
16
+ /** Кастомный футер-аннотация, который рендерится после календаря и после min/max days limitation. */
17
+ footerContent?: ReactNode;
15
18
  }
16
19
  export type CalendarMode = 'single-date' | 'single-datetime' | 'range-date' | 'range-datetime';
17
20
  export interface CalendarSingleDateProps extends BaseProps {
@@ -19,7 +19,7 @@ export declare const getLastDayOfMonth: (date: DateStruct) => DateStruct;
19
19
  export declare const getPeriodStart: (date: DateTimeStruct | DateStruct, period: Period) => DateTimeStruct;
20
20
  export declare const getPeriodEnd: (date: DateTimeStruct | DateStruct, period: Period) => DateTimeStruct;
21
21
  export declare const dateToStruct: (date: Date, tzOffsetMinutes: number) => DateTimeStruct;
22
- export declare const structToDate: (ds: DateTimeStruct, tzOffsetMinutes: number) => Date;
22
+ export declare const structToDate: (ds: DateTimeStruct | DateStruct, tzOffsetMinutes: number) => Date;
23
23
  export declare function getTimezoneOffset(timezoneName: string, at?: Date): number;
24
24
  export declare const dateToStructTz: (date: Date, tzName: string) => DateTimeStruct;
25
- export declare const structToDateTz: (ds: DateTimeStruct, tzName: string) => Date;
25
+ export declare const structToDateTz: (ds: DateTimeStruct | DateStruct, tzName: string) => Date;
@@ -128,7 +128,11 @@ export const dateToStruct = (date, tzOffsetMinutes) => {
128
128
  return utcDateToStruct(localTime);
129
129
  };
130
130
  export const structToDate = (ds, tzOffsetMinutes) => {
131
- const utcTime = Date.UTC(ds.year, ds.month - 1, ds.day, ds.hour, ds.minute, ds.second, ds.millisecond);
131
+ const hour = ds.hour ?? 0;
132
+ const minute = ds.minute ?? 0;
133
+ const second = ds.second ?? 0;
134
+ const millisecond = ds.millisecond ?? 0;
135
+ const utcTime = Date.UTC(ds.year, ds.month - 1, ds.day, hour, minute, second, millisecond);
132
136
  return new Date(utcTime - tzOffsetMinutes * 60_000);
133
137
  };
134
138
  export function getTimezoneOffset(timezoneName, at = new Date()) {
@@ -158,7 +162,11 @@ export const dateToStructTz = (date, tzName) => {
158
162
  return dateToStruct(date, tzOffsetMinutes);
159
163
  };
160
164
  export const structToDateTz = (ds, tzName) => {
161
- const utcTime = Date.UTC(ds.year, ds.month - 1, ds.day, ds.hour, ds.minute, ds.second, ds.millisecond);
165
+ const hour = ds.hour ?? 0;
166
+ const minute = ds.minute ?? 0;
167
+ const second = ds.second ?? 0;
168
+ const millisecond = ds.millisecond ?? 0;
169
+ const utcTime = Date.UTC(ds.year, ds.month - 1, ds.day, hour, minute, second, millisecond);
162
170
  const tentativeDate = new Date(utcTime);
163
171
  const tzOffsetMinutes = getTimezoneOffset(tzName, tentativeDate);
164
172
  return new Date(utcTime - tzOffsetMinutes * 60_000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.64",
3
+ "version": "1.1.66",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",