@pushwoosh/dumb-components 1.1.70 → 1.1.71

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.
@@ -12,7 +12,10 @@ export const CalendarDropdown = props => {
12
12
  const {
13
13
  mode,
14
14
  calendarProps,
15
- buttonColor = 'secondary'
15
+ buttonColor = 'secondary',
16
+ buttonSize = 'field',
17
+ buttonTextCustom,
18
+ allowEmpty
16
19
  } = props;
17
20
  const isRangePicker = mode === 'range-date' || mode === 'range-datetime';
18
21
  const withTime = mode === 'single-datetime' || mode === 'range-datetime';
@@ -56,14 +59,15 @@ export const CalendarDropdown = props => {
56
59
  }, React.createElement(Button, {
57
60
  boxRef: buttonRef,
58
61
  type: "button",
62
+ size: buttonSize,
59
63
  color: buttonColor,
60
64
  icon: React.createElement(CalendarIcon, {
61
- size: "medium",
65
+ size: buttonSize === 'compact' ? 'small' : 'medium',
62
66
  view: "lined"
63
67
  }),
64
68
  onClick: () => isOpen ? closePopover() : openPopover(),
65
69
  isOpen: isOpen
66
- }, buttonText), React.createElement(Popover, {
70
+ }, buttonTextCustom ?? buttonText), React.createElement(Popover, {
67
71
  open: isOpen,
68
72
  anchorEl: buttonRef,
69
73
  internalWindowRef: popoverRef,
@@ -144,7 +148,14 @@ export const CalendarDropdown = props => {
144
148
  color: "primary",
145
149
  size: "compact",
146
150
  onClick: () => {
147
- const isInvalid = isRangePicker ? (value === null || value === void 0 ? void 0 : value.length) !== 2 : !value;
151
+ let isInvalid;
152
+ if (isRangePicker) {
153
+ const range = value;
154
+ const length = (range === null || range === void 0 ? void 0 : range.length) ?? 0;
155
+ isInvalid = allowEmpty ? length === 1 : length !== 2;
156
+ } else {
157
+ isInvalid = allowEmpty ? false : !value;
158
+ }
148
159
  if (isInvalid) {
149
160
  setIsShaking(true);
150
161
  } else {
@@ -2,23 +2,27 @@ import { type ReactNode } from 'react';
2
2
  import { type RequiredButtonProps } from '../../Button';
3
3
  import type { CalendarRangeDateProps, CalendarRangeDateTimeProps, CalendarSingleDateProps, CalendarSingleDateTimeProps } from '../CalendarSuperForm/types';
4
4
  import type { DateStruct, DateTimeStruct, RangeValue, TzValue } from '../types';
5
- export type CalendarDropdownSingleDateProps = {
5
+ interface BaseProps {
6
+ buttonSize?: RequiredButtonProps['size'];
7
+ buttonColor?: RequiredButtonProps['color'];
8
+ buttonTextCustom?: string;
9
+ allowEmpty?: boolean;
10
+ }
11
+ export interface CalendarDropdownSingleDateProps extends BaseProps {
6
12
  mode: 'single-date';
7
13
  calendarProps: Omit<CalendarSingleDateProps, 'mode' | 'value' | 'onChange'>;
8
14
  value?: DateStruct;
9
15
  onChange?: (value: DateStruct) => void;
10
16
  onSubmit: (value: DateStruct, tz: TzValue) => void;
11
- buttonColor?: RequiredButtonProps['color'];
12
- };
13
- export type CalendarDropdownSingleDateTimeProps = {
17
+ }
18
+ export interface CalendarDropdownSingleDateTimeProps extends BaseProps {
14
19
  mode: 'single-datetime';
15
20
  calendarProps: Omit<CalendarSingleDateTimeProps, 'mode' | 'value' | 'onChange'>;
16
21
  value?: DateTimeStruct;
17
22
  onChange?: (value: DateTimeStruct) => void;
18
23
  onSubmit: (value: DateTimeStruct, tz: TzValue) => void;
19
- buttonColor?: RequiredButtonProps['color'];
20
- };
21
- export type CalendarDropdownRangeDateProps = {
24
+ }
25
+ export interface CalendarDropdownRangeDateProps extends BaseProps {
22
26
  mode: 'range-date';
23
27
  calendarProps: Omit<CalendarRangeDateProps, 'mode' | 'value' | 'onChange'>;
24
28
  value?: RangeValue<DateStruct>;
@@ -28,9 +32,8 @@ export type CalendarDropdownRangeDateProps = {
28
32
  label: ReactNode | string;
29
33
  value: [DateStruct, DateStruct];
30
34
  }>;
31
- buttonColor?: RequiredButtonProps['color'];
32
- };
33
- export type CalendarDropdownRangeDateTimeProps = {
35
+ }
36
+ export interface CalendarDropdownRangeDateTimeProps extends BaseProps {
34
37
  mode: 'range-datetime';
35
38
  calendarProps: Omit<CalendarRangeDateTimeProps, 'mode' | 'value' | 'onChange'>;
36
39
  value?: RangeValue<DateTimeStruct>;
@@ -40,6 +43,6 @@ export type CalendarDropdownRangeDateTimeProps = {
40
43
  label: ReactNode | string;
41
44
  value: [DateTimeStruct, DateTimeStruct];
42
45
  }>;
43
- buttonColor?: RequiredButtonProps['color'];
44
- };
46
+ }
45
47
  export type CalendarDropdownProps = CalendarDropdownSingleDateProps | CalendarDropdownSingleDateTimeProps | CalendarDropdownRangeDateProps | CalendarDropdownRangeDateTimeProps;
48
+ export {};
@@ -1 +1,5 @@
1
+ ;
2
+ ;
3
+ ;
4
+ ;
1
5
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.70",
3
+ "version": "1.1.71",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",