@povio/ui 2.1.25 → 2.1.26
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/dist/Calendar2.js +5 -3
- package/dist/DatePicker.js +12 -2
- package/dist/DateTimePicker.js +18 -2
- package/dist/MonthPicker.js +4 -3
- package/dist/YearPicker.js +4 -3
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +1 -0
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +3 -1
- package/dist/components/inputs/DateTime/shared/MonthPicker.d.ts +3 -1
- package/dist/components/inputs/DateTime/shared/YearPicker.d.ts +3 -1
- package/dist/config/uiConfig.context.d.ts +1 -1
- package/dist/uiConfig.context.js +2 -1
- package/package.json +1 -1
package/dist/Calendar2.js
CHANGED
|
@@ -7,7 +7,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
8
|
import { useState } from "react";
|
|
9
9
|
import { useCalendar } from "@react-aria/calendar";
|
|
10
|
-
const Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply,...props }) => {
|
|
10
|
+
const Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply, onMonthYearChange,...props }) => {
|
|
11
11
|
const [toggleState, setToggleState] = useState(null);
|
|
12
12
|
const { calendarProps, prevButtonProps, nextButtonProps } = useCalendar(props.calendarProps, props.state);
|
|
13
13
|
const handleDateChange = () => {
|
|
@@ -21,11 +21,13 @@ const Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply
|
|
|
21
21
|
});
|
|
22
22
|
if (toggleState === "month") return /* @__PURE__ */ jsx(MonthPicker, {
|
|
23
23
|
state: props.state,
|
|
24
|
-
onSelectionChange: () => setToggleState(null)
|
|
24
|
+
onSelectionChange: () => setToggleState(null),
|
|
25
|
+
onDateChange: onMonthYearChange
|
|
25
26
|
});
|
|
26
27
|
if (toggleState === "year") return /* @__PURE__ */ jsx(YearPicker, {
|
|
27
28
|
state: props.state,
|
|
28
|
-
onSelectionChange: () => setToggleState(null)
|
|
29
|
+
onSelectionChange: () => setToggleState(null),
|
|
30
|
+
onDateChange: onMonthYearChange
|
|
29
31
|
});
|
|
30
32
|
if (toggleState === "time" && includesTime) return /* @__PURE__ */ jsx("div", {
|
|
31
33
|
className: "flex h-72 w-80 items-center justify-center",
|
package/dist/DatePicker.js
CHANGED
|
@@ -18,7 +18,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
|
|
|
18
18
|
var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
|
|
19
19
|
var DatePickerBase = (props) => {
|
|
20
20
|
const ui = UIConfig.useConfig();
|
|
21
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, placeholder, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry,...rest } = props;
|
|
21
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, placeholder, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, shouldUpdateDateOnMonthYearChange = ui.dateInput.shouldUpdateDateOnMonthYearChange,...rest } = props;
|
|
22
22
|
const formFieldProps = {
|
|
23
23
|
error,
|
|
24
24
|
label,
|
|
@@ -91,6 +91,15 @@ var DatePickerBase = (props) => {
|
|
|
91
91
|
state.setValue(dialogState.value);
|
|
92
92
|
state.toggle();
|
|
93
93
|
};
|
|
94
|
+
const onMonthYearChange = (selectedDate) => {
|
|
95
|
+
if (!shouldUpdateDateOnMonthYearChange) return;
|
|
96
|
+
const updatedDate = (dialogState.value || state.value || today(getLocalTimeZone())).set({
|
|
97
|
+
year: selectedDate.year,
|
|
98
|
+
month: selectedDate.month
|
|
99
|
+
});
|
|
100
|
+
dialogState.setValue(updatedDate);
|
|
101
|
+
calendarState.setFocusedDate(updatedDate);
|
|
102
|
+
};
|
|
94
103
|
const onTodayPress = () => {
|
|
95
104
|
dialogState.setValue(today(getLocalTimeZone()));
|
|
96
105
|
calendarState.setFocusedDate(today(getLocalTimeZone()));
|
|
@@ -146,7 +155,8 @@ var DatePickerBase = (props) => {
|
|
|
146
155
|
children: /* @__PURE__ */ jsx(Calendar, {
|
|
147
156
|
state: calendarState,
|
|
148
157
|
calendarProps,
|
|
149
|
-
onApply
|
|
158
|
+
onApply,
|
|
159
|
+
onMonthYearChange
|
|
150
160
|
})
|
|
151
161
|
})]
|
|
152
162
|
})
|
package/dist/DateTimePicker.js
CHANGED
|
@@ -16,7 +16,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
|
|
|
16
16
|
var PLACEHOLDER_VALUE = new CalendarDateTime(2024, 1, 1);
|
|
17
17
|
var DateTimePickerBase = (props) => {
|
|
18
18
|
const ui = UIConfig.useConfig();
|
|
19
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, isTimeOptional, placeholder, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry,...rest } = props;
|
|
19
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, isTimeOptional, placeholder, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, shouldUpdateDateOnMonthYearChange = ui.dateInput.shouldUpdateDateOnMonthYearChange,...rest } = props;
|
|
20
20
|
const formFieldProps = {
|
|
21
21
|
error,
|
|
22
22
|
label,
|
|
@@ -94,6 +94,21 @@ var DateTimePickerBase = (props) => {
|
|
|
94
94
|
state.setValue(dialogState.value);
|
|
95
95
|
state.toggle();
|
|
96
96
|
};
|
|
97
|
+
const onMonthYearChange = (selectedDate) => {
|
|
98
|
+
if (!shouldUpdateDateOnMonthYearChange) return;
|
|
99
|
+
const baseDate = dialogState.value || state.value;
|
|
100
|
+
if (baseDate) {
|
|
101
|
+
const updatedDate = baseDate.set({
|
|
102
|
+
year: selectedDate.year,
|
|
103
|
+
month: selectedDate.month
|
|
104
|
+
});
|
|
105
|
+
dialogState.setValue(updatedDate);
|
|
106
|
+
calendarState.setFocusedDate(updatedDate);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
dialogState.setValue(toCalendarDateTime(selectedDate));
|
|
110
|
+
calendarState.setFocusedDate(selectedDate);
|
|
111
|
+
};
|
|
97
112
|
const onTodayPress = () => {
|
|
98
113
|
dialogState.setValue(toCalendarDateTime(now(getLocalTimeZone())));
|
|
99
114
|
calendarState.setFocusedDate(today(getLocalTimeZone()));
|
|
@@ -167,7 +182,8 @@ var DateTimePickerBase = (props) => {
|
|
|
167
182
|
calendarProps,
|
|
168
183
|
includesTime: true,
|
|
169
184
|
datePickerState: dialogState,
|
|
170
|
-
onApply
|
|
185
|
+
onApply,
|
|
186
|
+
onMonthYearChange
|
|
171
187
|
})
|
|
172
188
|
})]
|
|
173
189
|
})
|
package/dist/MonthPicker.js
CHANGED
|
@@ -3,7 +3,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { clsx } from "clsx";
|
|
4
4
|
import { ListBox, ListBoxItem } from "react-aria-components";
|
|
5
5
|
import { useDateFormatter } from "@react-aria/i18n";
|
|
6
|
-
const MonthPicker = ({ state, onSelectionChange }) => {
|
|
6
|
+
const MonthPicker = ({ state, onSelectionChange, onDateChange }) => {
|
|
7
7
|
const formatter = useDateFormatter({
|
|
8
8
|
month: "long",
|
|
9
9
|
timeZone: state.timeZone
|
|
@@ -31,8 +31,9 @@ const MonthPicker = ({ state, onSelectionChange }) => {
|
|
|
31
31
|
onSelectionChange: (key) => {
|
|
32
32
|
if (key === "all") return;
|
|
33
33
|
if (typeof [...key][0] === "number") {
|
|
34
|
-
const
|
|
35
|
-
state.setFocusedDate(
|
|
34
|
+
const selectedDate = state.focusedDate.set({ month: [...key][0] });
|
|
35
|
+
state.setFocusedDate(selectedDate);
|
|
36
|
+
onDateChange?.(selectedDate);
|
|
36
37
|
}
|
|
37
38
|
onSelectionChange(key);
|
|
38
39
|
},
|
package/dist/YearPicker.js
CHANGED
|
@@ -6,7 +6,7 @@ import { ListBox, ListBoxItem } from "react-aria-components";
|
|
|
6
6
|
import { useMemo } from "react";
|
|
7
7
|
import { today } from "@internationalized/date";
|
|
8
8
|
import { useDateFormatter } from "@react-aria/i18n";
|
|
9
|
-
const YearPicker = ({ state, onSelectionChange }) => {
|
|
9
|
+
const YearPicker = ({ state, onSelectionChange, onDateChange }) => {
|
|
10
10
|
const formatter = useDateFormatter({
|
|
11
11
|
year: "numeric",
|
|
12
12
|
timeZone: state.timeZone
|
|
@@ -39,8 +39,9 @@ const YearPicker = ({ state, onSelectionChange }) => {
|
|
|
39
39
|
if (key === "all") return;
|
|
40
40
|
const index = [...key][0];
|
|
41
41
|
if (typeof index === "number") {
|
|
42
|
-
const
|
|
43
|
-
state.setFocusedDate(
|
|
42
|
+
const selectedDate = state.focusedDate.set({ year: years[index].value });
|
|
43
|
+
state.setFocusedDate(selectedDate);
|
|
44
|
+
onDateChange?.(selectedDate);
|
|
44
45
|
}
|
|
45
46
|
onSelectionChange(key);
|
|
46
47
|
},
|
|
@@ -15,6 +15,7 @@ interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Da
|
|
|
15
15
|
isDirty?: boolean;
|
|
16
16
|
disableManualEntry?: boolean;
|
|
17
17
|
placeholder?: string;
|
|
18
|
+
shouldUpdateDateOnMonthYearChange?: boolean;
|
|
18
19
|
}
|
|
19
20
|
export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
|
|
20
21
|
value?: string | null;
|
|
@@ -15,6 +15,7 @@ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omi
|
|
|
15
15
|
isDirty?: boolean;
|
|
16
16
|
disableManualEntry?: boolean;
|
|
17
17
|
placeholder?: string;
|
|
18
|
+
shouldUpdateDateOnMonthYearChange?: boolean;
|
|
18
19
|
}
|
|
19
20
|
export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
|
|
20
21
|
value?: string | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CalendarDate } from '@internationalized/date';
|
|
1
2
|
import { CalendarState, CalendarStateOptions } from '@react-stately/calendar';
|
|
2
3
|
import { DatePickerState } from 'react-stately';
|
|
3
4
|
type DateTimeCalendarProps = {
|
|
@@ -14,7 +15,8 @@ type CalendarProps = DateTimeCalendarProps & {
|
|
|
14
15
|
state: CalendarState;
|
|
15
16
|
calendarProps: Omit<CalendarStateOptions, "locale" | "createCalendar">;
|
|
16
17
|
onApply: () => void;
|
|
18
|
+
onMonthYearChange?: (selectedDate: CalendarDate) => void;
|
|
17
19
|
};
|
|
18
20
|
export type ToggleState = "month" | "year" | "time";
|
|
19
|
-
export declare const Calendar: ({ className, includesTime, datePickerState, hourCycle, onApply, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const Calendar: ({ className, includesTime, datePickerState, hourCycle, onApply, onMonthYearChange, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
22
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { CalendarDate } from '@internationalized/date';
|
|
1
2
|
import { CalendarState, RangeCalendarState } from '@react-stately/calendar';
|
|
2
3
|
import { Key } from 'react-aria-components';
|
|
3
4
|
export interface MonthPickerProps {
|
|
4
5
|
state: CalendarState | RangeCalendarState;
|
|
5
6
|
onSelectionChange: (key: Set<Key>) => void;
|
|
7
|
+
onDateChange?: (selectedDate: CalendarDate) => void;
|
|
6
8
|
}
|
|
7
|
-
export declare const MonthPicker: ({ state, onSelectionChange }: MonthPickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const MonthPicker: ({ state, onSelectionChange, onDateChange }: MonthPickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { CalendarDate } from '@internationalized/date';
|
|
1
2
|
import { CalendarState, RangeCalendarState } from '@react-stately/calendar';
|
|
2
3
|
import { Key } from 'react-aria-components';
|
|
3
4
|
interface YearPickerProps {
|
|
4
5
|
state: CalendarState | RangeCalendarState;
|
|
5
6
|
onSelectionChange: (key: Set<Key>) => void;
|
|
7
|
+
onDateChange?: (selectedDate: CalendarDate) => void;
|
|
6
8
|
}
|
|
7
|
-
export declare const YearPicker: ({ state, onSelectionChange }: YearPickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const YearPicker: ({ state, onSelectionChange, onDateChange }: YearPickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -20,7 +20,7 @@ export declare namespace UIConfig {
|
|
|
20
20
|
select: Pick<SelectBaseProps, "selectionMode" | "isSearchable" | "collapseAfter" | "selectedTagsType">;
|
|
21
21
|
toggle: Pick<ToggleProps, "variant">;
|
|
22
22
|
slider: Pick<SliderProps, "minValue" | "maxValue">;
|
|
23
|
-
dateInput: Pick<DatePickerProps, "todayIcon" | "shouldForceLeadingZeros" | "disableManualEntry">;
|
|
23
|
+
dateInput: Pick<DatePickerProps, "todayIcon" | "shouldForceLeadingZeros" | "disableManualEntry" | "shouldUpdateDateOnMonthYearChange">;
|
|
24
24
|
actionModal: Pick<ActionModalProps, "titleTypography" | "descriptionTypography">;
|
|
25
25
|
}
|
|
26
26
|
interface ProviderProps {
|
package/dist/uiConfig.context.js
CHANGED