@pushwoosh/dumb-components 1.1.70 → 1.1.72
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/Calendar/CalendarDropdown/CalendarDropdown.js +15 -4
- package/Calendar/CalendarDropdown/types.d.ts +15 -12
- package/Calendar/CalendarDropdown/types.js +4 -0
- package/DropdownMenu/components/DropdownMenu/DropdownMenu.js +2 -1
- package/DropdownMenu/components/DropdownMenu/types.d.ts +1 -0
- package/StatisticCard/StatisticCard.js +4 -1
- package/package.json +1 -1
|
@@ -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:
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
44
|
-
};
|
|
46
|
+
}
|
|
45
47
|
export type CalendarDropdownProps = CalendarDropdownSingleDateProps | CalendarDropdownSingleDateTimeProps | CalendarDropdownRangeDateProps | CalendarDropdownRangeDateTimeProps;
|
|
48
|
+
export {};
|
|
@@ -10,13 +10,14 @@ export const DropdownMenu = ({
|
|
|
10
10
|
isScrollable,
|
|
11
11
|
menuZIndex,
|
|
12
12
|
menuPlacement,
|
|
13
|
+
windowWidth = null,
|
|
13
14
|
openOnMount = false,
|
|
14
15
|
fullWidth,
|
|
15
16
|
onClose,
|
|
16
17
|
children
|
|
17
18
|
}) => {
|
|
18
19
|
const [isOpen, setIsOpen] = useState(openOnMount);
|
|
19
|
-
const [width, setWidth] = useState(
|
|
20
|
+
const [width, setWidth] = useState(windowWidth);
|
|
20
21
|
const {
|
|
21
22
|
refs,
|
|
22
23
|
floatingStyles
|
|
@@ -40,6 +40,7 @@ export function StatisticCard(props) {
|
|
|
40
40
|
return React.createElement(StatValue, null, typeof value === 'number' ? formatNumber(value, 'spaced') : value);
|
|
41
41
|
}, [isLoading, value, valueSubtext]);
|
|
42
42
|
const resolvedRightSlot = rightSlot ?? (actions ? React.createElement(DropdownMenu, {
|
|
43
|
+
windowWidth: 230,
|
|
43
44
|
renderHandler: ({
|
|
44
45
|
onClick,
|
|
45
46
|
ref,
|
|
@@ -62,7 +63,9 @@ export function StatisticCard(props) {
|
|
|
62
63
|
key: a.id,
|
|
63
64
|
onClick: a.onClick,
|
|
64
65
|
disabled: a.disabled
|
|
65
|
-
},
|
|
66
|
+
}, React.createElement(Text, {
|
|
67
|
+
"$ellipsis": true
|
|
68
|
+
}, a.label))))) : null);
|
|
66
69
|
return React.createElement(Container, {
|
|
67
70
|
"$active": active,
|
|
68
71
|
"$selectable": selectable,
|