@pushwoosh/dumb-components 1.1.57 → 1.1.59
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.
|
@@ -11,7 +11,8 @@ import { CalendarSuperForm } from '../CalendarSuperForm';
|
|
|
11
11
|
export const CalendarDropdown = props => {
|
|
12
12
|
const {
|
|
13
13
|
mode,
|
|
14
|
-
calendarProps
|
|
14
|
+
calendarProps,
|
|
15
|
+
buttonColor = 'secondary'
|
|
15
16
|
} = props;
|
|
16
17
|
const isRangePicker = mode === 'range-date' || mode === 'range-datetime';
|
|
17
18
|
const withTime = mode === 'single-datetime' || mode === 'range-datetime';
|
|
@@ -55,7 +56,7 @@ export const CalendarDropdown = props => {
|
|
|
55
56
|
}, React.createElement(Button, {
|
|
56
57
|
boxRef: buttonRef,
|
|
57
58
|
type: "button",
|
|
58
|
-
color:
|
|
59
|
+
color: buttonColor,
|
|
59
60
|
icon: React.createElement(CalendarIcon, {
|
|
60
61
|
size: "medium",
|
|
61
62
|
view: "lined"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import { type RequiredButtonProps } from '../../Button';
|
|
2
3
|
import type { CalendarRangeDateProps, CalendarRangeDateTimeProps, CalendarSingleDateProps, CalendarSingleDateTimeProps } from '../CalendarSuperForm/types';
|
|
3
4
|
import type { DateStruct, DateTimeStruct, RangeValue, TzValue } from '../types';
|
|
4
5
|
export type CalendarDropdownSingleDateProps = {
|
|
@@ -7,6 +8,7 @@ export type CalendarDropdownSingleDateProps = {
|
|
|
7
8
|
value?: DateStruct;
|
|
8
9
|
onChange?: (value: DateStruct) => void;
|
|
9
10
|
onSubmit: (value: DateStruct, tz: TzValue) => void;
|
|
11
|
+
buttonColor: RequiredButtonProps['color'];
|
|
10
12
|
};
|
|
11
13
|
export type CalendarDropdownSingleDateTimeProps = {
|
|
12
14
|
mode: 'single-datetime';
|
|
@@ -14,6 +16,7 @@ export type CalendarDropdownSingleDateTimeProps = {
|
|
|
14
16
|
value?: DateTimeStruct;
|
|
15
17
|
onChange?: (value: DateTimeStruct) => void;
|
|
16
18
|
onSubmit: (value: DateTimeStruct, tz: TzValue) => void;
|
|
19
|
+
buttonColor: RequiredButtonProps['color'];
|
|
17
20
|
};
|
|
18
21
|
export type CalendarDropdownRangeDateProps = {
|
|
19
22
|
mode: 'range-date';
|
|
@@ -25,6 +28,7 @@ export type CalendarDropdownRangeDateProps = {
|
|
|
25
28
|
label: ReactNode | string;
|
|
26
29
|
value: [DateStruct, DateStruct];
|
|
27
30
|
}>;
|
|
31
|
+
buttonColor: RequiredButtonProps['color'];
|
|
28
32
|
};
|
|
29
33
|
export type CalendarDropdownRangeDateTimeProps = {
|
|
30
34
|
mode: 'range-datetime';
|
|
@@ -36,5 +40,6 @@ export type CalendarDropdownRangeDateTimeProps = {
|
|
|
36
40
|
label: ReactNode | string;
|
|
37
41
|
value: [DateTimeStruct, DateTimeStruct];
|
|
38
42
|
}>;
|
|
43
|
+
buttonColor: RequiredButtonProps['color'];
|
|
39
44
|
};
|
|
40
45
|
export type CalendarDropdownProps = CalendarDropdownSingleDateProps | CalendarDropdownSingleDateTimeProps | CalendarDropdownRangeDateProps | CalendarDropdownRangeDateTimeProps;
|
|
@@ -45,6 +45,16 @@ export const DropdownMenu = ({
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
}, [isOpen, refs.floating, refs.reference]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (isOpen && isScrollable && refs.floating.current) {
|
|
50
|
+
const activeElement = refs.floating.current.querySelector('[data-active="true"]');
|
|
51
|
+
if (activeElement) {
|
|
52
|
+
activeElement.scrollIntoView({
|
|
53
|
+
block: 'nearest'
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, [isOpen, isScrollable, refs.floating]);
|
|
48
58
|
return React.createElement(DropdownContext.Provider, {
|
|
49
59
|
value: setIsOpen
|
|
50
60
|
}, renderHandler({
|