@povio/ui 2.2.9-rc.24 → 2.2.9-rc.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/components/inputs/DateTime/DatePicker/DatePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +2 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +20 -16
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +2 -1
- package/dist/components/inputs/DateTime/shared/DateField.js +3 -10
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +3 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +51 -45
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.js +9 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
- package/dist/components/inputs/Input/shared/InputContent.js +3 -2
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -3
- package/dist/components/inputs/Selection/Select/QuerySelect.js +5 -34
- package/dist/components/inputs/shared/input.cva.d.ts +5 -0
- package/dist/components/inputs/shared/input.cva.js +10 -1
- package/dist/config/uiConfig.context.d.ts +1 -1
- package/dist/config/uiConfig.context.js +1 -0
- package/dist/config/uiStyle.context.d.ts +2 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import { FocusEvent, Ref } from 'react';
|
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { DatePickerStateOptions } from 'react-stately';
|
|
5
5
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
6
|
-
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
6
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
|
|
7
7
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
8
8
|
import { ControlProps } from '../../shared/form.types';
|
|
9
9
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
@@ -14,6 +14,7 @@ interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Da
|
|
|
14
14
|
className?: string;
|
|
15
15
|
todayIcon?: DatePickerTodayIcon;
|
|
16
16
|
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
17
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
17
18
|
isDirty?: boolean;
|
|
18
19
|
disableManualEntry?: boolean;
|
|
19
20
|
autoFixYear?: boolean;
|
|
@@ -24,7 +24,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
|
|
|
24
24
|
var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
|
|
25
25
|
var DatePickerBase = (props) => {
|
|
26
26
|
const ui = UIConfig.useConfig();
|
|
27
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, placeholder, inputClassName, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
27
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, placeholder, inputClassName, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, todayIconPlacement = ui.dateInput.todayIconPlacement, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
28
28
|
const formFieldProps = {
|
|
29
29
|
error,
|
|
30
30
|
label,
|
|
@@ -144,6 +144,7 @@ var DatePickerBase = (props) => {
|
|
|
144
144
|
headerProps,
|
|
145
145
|
todayIcon,
|
|
146
146
|
todayIconButtonSize,
|
|
147
|
+
todayIconPlacement,
|
|
147
148
|
onOpenDropdown: () => state.toggle(),
|
|
148
149
|
placeholder,
|
|
149
150
|
className: inputClassName
|
|
@@ -4,7 +4,7 @@ import { DateValue } from 'react-aria';
|
|
|
4
4
|
import { FieldValues } from 'react-hook-form';
|
|
5
5
|
import { DateRangePickerStateOptions } from 'react-stately';
|
|
6
6
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
7
|
-
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
7
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
|
|
8
8
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
9
9
|
import { ControlProps } from '../../shared/form.types';
|
|
10
10
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
@@ -16,6 +16,7 @@ interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Om
|
|
|
16
16
|
className?: string;
|
|
17
17
|
todayIcon?: DatePickerTodayIcon;
|
|
18
18
|
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
19
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
19
20
|
isDirty?: boolean;
|
|
20
21
|
disableManualEntry?: boolean;
|
|
21
22
|
autoFixYear?: boolean;
|
|
@@ -13,7 +13,7 @@ import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
|
13
13
|
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
14
14
|
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
15
15
|
import { RangeCalendar } from "../shared/RangeCalendar.js";
|
|
16
|
-
import {
|
|
16
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
17
|
import { clsx } from "clsx";
|
|
18
18
|
import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
19
19
|
import { Button } from "react-aria-components";
|
|
@@ -28,7 +28,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
|
|
|
28
28
|
var DateRangePickerBase = (props) => {
|
|
29
29
|
const ui = UIConfig.useConfig();
|
|
30
30
|
const { t } = useTranslation();
|
|
31
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
31
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, className, hideSidebar, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, todayIconPlacement = ui.dateInput.todayIconPlacement, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...rest } = props;
|
|
32
32
|
const [validationRangeError, setValidationRangeError] = useState();
|
|
33
33
|
const datePickerInputRef = useRef(null);
|
|
34
34
|
const dateRangePickerRef = useMemo(() => ({ get current() {
|
|
@@ -489,6 +489,7 @@ var DateRangePickerBase = (props) => {
|
|
|
489
489
|
headerProps,
|
|
490
490
|
todayIcon,
|
|
491
491
|
todayIconButtonSize,
|
|
492
|
+
todayIconPlacement,
|
|
492
493
|
isDirty,
|
|
493
494
|
disableManualEntry,
|
|
494
495
|
autoFixYear,
|
|
@@ -626,20 +627,23 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
|
|
|
626
627
|
};
|
|
627
628
|
const start = formatStaticDate(rawValue?.start ?? null);
|
|
628
629
|
const end = formatStaticDate(rawValue?.end ?? null);
|
|
629
|
-
const displayValue = /* @__PURE__ */ jsxs(
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
630
|
+
const displayValue = /* @__PURE__ */ jsxs("div", {
|
|
631
|
+
className: datePickerInputContentRowCva({ size }),
|
|
632
|
+
children: [
|
|
633
|
+
/* @__PURE__ */ jsx("span", {
|
|
634
|
+
className: rawValue?.start ? "" : "text-text-default-3",
|
|
635
|
+
children: rawValue?.start ? start : defaultDatePlaceholder
|
|
636
|
+
}),
|
|
637
|
+
/* @__PURE__ */ jsx("span", {
|
|
638
|
+
className: "pointer-events-none select-none",
|
|
639
|
+
children: "–"
|
|
640
|
+
}),
|
|
641
|
+
/* @__PURE__ */ jsx("span", {
|
|
642
|
+
className: rawValue?.end ? "" : "text-text-default-3",
|
|
643
|
+
children: rawValue?.end ? end : defaultDatePlaceholder
|
|
644
|
+
})
|
|
645
|
+
]
|
|
646
|
+
});
|
|
643
647
|
return /* @__PURE__ */ jsx(StaticInput, {
|
|
644
648
|
...props,
|
|
645
649
|
onInteract: (focus) => {
|
|
@@ -3,7 +3,7 @@ import { DateValue } from 'react-aria';
|
|
|
3
3
|
import { FieldValues } from 'react-hook-form';
|
|
4
4
|
import { DatePickerStateOptions } from 'react-stately';
|
|
5
5
|
import { DatePickerInputHandle } from '../shared/DatePickerInput';
|
|
6
|
-
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from '../shared/datePicker.types';
|
|
6
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from '../shared/datePicker.types';
|
|
7
7
|
import { FormFieldProps } from '../../FormField/FormField';
|
|
8
8
|
import { ControlProps } from '../../shared/form.types';
|
|
9
9
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
@@ -14,6 +14,7 @@ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omi
|
|
|
14
14
|
isClearable?: boolean;
|
|
15
15
|
todayIcon?: DatePickerTodayIcon;
|
|
16
16
|
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
17
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
17
18
|
isDirty?: boolean;
|
|
18
19
|
disableManualEntry?: boolean;
|
|
19
20
|
autoFixYear?: boolean;
|
|
@@ -21,7 +21,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
|
|
|
21
21
|
//#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
|
|
22
22
|
var DateTimePickerBase = (props) => {
|
|
23
23
|
const ui = UIConfig.useConfig();
|
|
24
|
-
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, isTimeOptional, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, setDateValueOnDateSelection = ui.dateInput.setDateValueOnDateSelection, ...rest } = props;
|
|
24
|
+
const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, isTimeOptional, placeholder, inputClassName, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, todayIconButtonSize = ui.dateInput.todayIconButtonSize, todayIconPlacement = ui.dateInput.todayIconPlacement, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, setDateValueOnDateSelection = ui.dateInput.setDateValueOnDateSelection, ...rest } = props;
|
|
25
25
|
const formFieldProps = {
|
|
26
26
|
error,
|
|
27
27
|
label,
|
|
@@ -158,6 +158,7 @@ var DateTimePickerBase = (props) => {
|
|
|
158
158
|
headerProps,
|
|
159
159
|
todayIcon,
|
|
160
160
|
todayIconButtonSize,
|
|
161
|
+
todayIconPlacement,
|
|
161
162
|
isRequired,
|
|
162
163
|
disableManualEntry,
|
|
163
164
|
autoFixYear,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DateSegmentItem } from "./DateSegmentItem.js";
|
|
2
|
+
import { getTimeSegmentValue } from "./dateSegment.utils.js";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
import { clsx } from "clsx";
|
|
4
5
|
import { useEffect, useImperativeHandle, useRef } from "react";
|
|
@@ -31,16 +32,8 @@ var DateField = ({ ref, onClearChange, hidePlaceholder, isDisabled, disableManua
|
|
|
31
32
|
const isDayFilled = daySegment && !daySegment.isPlaceholder;
|
|
32
33
|
const isYearEmpty = yearSegment && !(parseInt(yearSegment.text) && yearSegment.text?.length === 4);
|
|
33
34
|
const isHourEmpty = hourSegment && !parseInt(hourSegment.text);
|
|
34
|
-
if (minuteSegment && !parseInt(minuteSegment.text))
|
|
35
|
-
|
|
36
|
-
if (minuteSegment?.text?.length && minuteSegment?.text?.length > 0) minute = parseInt(minuteSegment?.text ?? "00");
|
|
37
|
-
state.setSegment("minute", minute);
|
|
38
|
-
}
|
|
39
|
-
if (isHourEmpty) {
|
|
40
|
-
let hour = hourSegment?.value || 0;
|
|
41
|
-
if (hourSegment?.text?.length && hourSegment?.text?.length > 0) hour = parseInt(hourSegment?.text ?? "00");
|
|
42
|
-
state.setSegment("hour", hour);
|
|
43
|
-
}
|
|
35
|
+
if (minuteSegment && !parseInt(minuteSegment.text)) state.setSegment("minute", getTimeSegmentValue(minuteSegment));
|
|
36
|
+
if (isHourEmpty) state.setSegment("hour", getTimeSegmentValue(hourSegment));
|
|
44
37
|
if (isMonthFilled && isDayFilled && isYearEmpty) {
|
|
45
38
|
let year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
46
39
|
if (yearSegment?.text?.length && yearSegment?.text?.length === 2) year = parseInt(`20${yearSegment?.text}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
2
|
import { DatePickerAria } from 'react-aria';
|
|
3
|
-
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from './datePicker.types';
|
|
3
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from './datePicker.types';
|
|
4
4
|
import { FormFieldHeaderProps } from '../../FormField/FormFieldHeader';
|
|
5
5
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
6
6
|
export interface DatePickerInputHandle {
|
|
@@ -21,6 +21,7 @@ interface DatePickerInputProps extends InputVariantProps {
|
|
|
21
21
|
headerProps?: FormFieldHeaderProps;
|
|
22
22
|
todayIcon?: DatePickerTodayIcon;
|
|
23
23
|
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
24
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
24
25
|
isDirty?: boolean;
|
|
25
26
|
isRequired?: boolean;
|
|
26
27
|
disableManualEntry?: boolean;
|
|
@@ -29,5 +30,5 @@ interface DatePickerInputProps extends InputVariantProps {
|
|
|
29
30
|
className?: string;
|
|
30
31
|
onOpenDropdown?: () => void;
|
|
31
32
|
}
|
|
32
|
-
export declare const DatePickerInput: ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize, isDirty, isRequired, disableManualEntry, autoFixYear, placeholder, className, onOpenDropdown, ...props }: DatePickerInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare const DatePickerInput: ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize, todayIconPlacement, isDirty, isRequired, disableManualEntry, autoFixYear, placeholder, className, onOpenDropdown, ...props }: DatePickerInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
34
|
export {};
|
|
@@ -15,7 +15,7 @@ import { Button } from "react-aria-components";
|
|
|
15
15
|
import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
|
|
16
16
|
import { getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
|
|
17
17
|
//#region src/components/inputs/DateTime/shared/DatePickerInput.tsx
|
|
18
|
-
var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize = "none", isDirty, isRequired, disableManualEntry, autoFixYear = false, placeholder, className, onOpenDropdown, ...props }) => {
|
|
18
|
+
var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize = "none", todayIconPlacement = "content", isDirty, isRequired, disableManualEntry, autoFixYear = false, placeholder, className, onOpenDropdown, ...props }) => {
|
|
19
19
|
const uiConfig = UIConfig.useConfig();
|
|
20
20
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
21
21
|
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
@@ -72,6 +72,14 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
|
|
|
72
72
|
};
|
|
73
73
|
const hidePlaceholder = as === "floating" && !fieldProps.value && !isFocused;
|
|
74
74
|
const todayIconComponent = getDatePickerTodayIcon(todayIcon);
|
|
75
|
+
const todayIconButton = todayIconComponent ? /* @__PURE__ */ jsx(InlineIconButton, {
|
|
76
|
+
label: "",
|
|
77
|
+
icon: todayIconComponent,
|
|
78
|
+
size: todayIconButtonSize,
|
|
79
|
+
onPress: onToday,
|
|
80
|
+
className: "relative z-1 !border-none"
|
|
81
|
+
}) : null;
|
|
82
|
+
const shouldRenderTodayIconWithFieldLabel = todayIconPlacement === "fieldLabel";
|
|
75
83
|
const pickerIcon = isDateTime ? uiConfig.dateInput.dateTimeIcon : uiConfig.dateInput.calendarIcon;
|
|
76
84
|
return /* @__PURE__ */ jsxs("div", {
|
|
77
85
|
ref: containerRef,
|
|
@@ -101,50 +109,48 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
|
|
|
101
109
|
size,
|
|
102
110
|
as
|
|
103
111
|
})),
|
|
104
|
-
children: [
|
|
105
|
-
as,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
]
|
|
147
|
-
})]
|
|
112
|
+
children: [
|
|
113
|
+
as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
|
|
114
|
+
as,
|
|
115
|
+
...headerProps
|
|
116
|
+
}),
|
|
117
|
+
shouldRenderTodayIconWithFieldLabel && todayIconButton,
|
|
118
|
+
/* @__PURE__ */ jsxs("div", {
|
|
119
|
+
className: datePickerInputContentRowCva({ size }),
|
|
120
|
+
children: [
|
|
121
|
+
disableManualEntry && /* @__PURE__ */ jsx(Button, {
|
|
122
|
+
onPress: onOpenDropdown,
|
|
123
|
+
className: "absolute inset-0 z-0",
|
|
124
|
+
isDisabled
|
|
125
|
+
}),
|
|
126
|
+
!shouldRenderTodayIconWithFieldLabel && todayIconButton,
|
|
127
|
+
disableManualEntry && placeholder && !fieldProps.value ? /* @__PURE__ */ jsx(Typography, {
|
|
128
|
+
size: "label-1",
|
|
129
|
+
className: "text-text-default-3",
|
|
130
|
+
children: placeholder
|
|
131
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(DateField, {
|
|
132
|
+
ref: dateFieldRef,
|
|
133
|
+
...fieldProps,
|
|
134
|
+
isDisabled,
|
|
135
|
+
isInvalid,
|
|
136
|
+
onClearChange,
|
|
137
|
+
hidePlaceholder,
|
|
138
|
+
disableManualEntry
|
|
139
|
+
}), endFieldProps && /* @__PURE__ */ jsxs(Fragment, { children: [!((as === "floating" || as === "filter") && hidePlaceholder) && /* @__PURE__ */ jsx("span", {
|
|
140
|
+
className: clsx("pointer-events-none select-none", isDisabled && "text-interactive-text-secondary-disabled"),
|
|
141
|
+
children: "–"
|
|
142
|
+
}), /* @__PURE__ */ jsx(DateField, {
|
|
143
|
+
ref: endDateFieldRef,
|
|
144
|
+
...endFieldProps,
|
|
145
|
+
isDisabled,
|
|
146
|
+
isInvalid,
|
|
147
|
+
onClearChange,
|
|
148
|
+
hidePlaceholder,
|
|
149
|
+
disableManualEntry
|
|
150
|
+
})] })] })
|
|
151
|
+
]
|
|
152
|
+
})
|
|
153
|
+
]
|
|
148
154
|
}), /* @__PURE__ */ jsxs("div", {
|
|
149
155
|
className: clsx(inputSizeCva({
|
|
150
156
|
size,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IconButtonProps } from '../../../buttons/IconButton/IconButton';
|
|
2
2
|
export type DatePickerTodayIcon = boolean | IconButtonProps["icon"];
|
|
3
3
|
export type DatePickerTodayIconButtonSize = IconButtonProps["size"];
|
|
4
|
+
export type DatePickerTodayIconPlacement = "content" | "fieldLabel";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/components/inputs/DateTime/shared/dateSegment.utils.ts
|
|
2
|
+
var getTimeSegmentValue = (segment, fallbackValue = 0) => {
|
|
3
|
+
if (!segment) return fallbackValue;
|
|
4
|
+
const parsedValue = Number.parseInt(segment.text, 10);
|
|
5
|
+
if (Number.isFinite(parsedValue)) return parsedValue;
|
|
6
|
+
return Number.isFinite(segment.value) ? segment.value ?? fallbackValue : fallbackValue;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getTimeSegmentValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import { Loader } from "../../../status/Loader/Loader.js";
|
|
|
4
4
|
import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
|
|
5
5
|
import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
|
|
6
6
|
import { InputClear } from "../../shared/InputClear.js";
|
|
7
|
-
import { inputSize } from "../../shared/input.cva.js";
|
|
7
|
+
import { inputContentWrapper, inputSize } from "../../shared/input.cva.js";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { clsx } from "clsx";
|
|
10
10
|
import { isValidElement } from "react";
|
|
@@ -12,6 +12,7 @@ import { isValidElement } from "react";
|
|
|
12
12
|
var InputContent = ({ leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, unit, isLoading, isDisabled, action, isClearable, value, onChange, onBlur, children, headerProps, as, size }) => {
|
|
13
13
|
const typographyCva = UIStyle.useCva("typography.cva", typography);
|
|
14
14
|
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
15
|
+
const inputContentWrapperCva = UIStyle.useCva("input.contentWrapperCva", inputContentWrapper);
|
|
15
16
|
const isLeadingIconElement = LeadingIcon && isValidElement(LeadingIcon);
|
|
16
17
|
const isTrailingIconElement = TrailingIcon && isValidElement(TrailingIcon);
|
|
17
18
|
const showClear = value != null && value !== "" && !isDisabled;
|
|
@@ -26,7 +27,7 @@ var InputContent = ({ leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, unit
|
|
|
26
27
|
className: clsx(!isLeadingIconElement && "pointer-events-none"),
|
|
27
28
|
children: isLeadingIconElement ? LeadingIcon : /* @__PURE__ */ jsx(LeadingIcon, { className: "size-6 text-interactive-text-secondary-idle" })
|
|
28
29
|
}), /* @__PURE__ */ jsxs("div", {
|
|
29
|
-
className:
|
|
30
|
+
className: inputContentWrapperCva({ as }),
|
|
30
31
|
children: [as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
|
|
31
32
|
as,
|
|
32
33
|
size,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
|
|
2
|
-
import {
|
|
1
|
+
import { DefaultInitialSelectItem, GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
|
|
2
|
+
import { SelectProps } from './Select';
|
|
3
3
|
import { QueryDataType, QueryFn } from '../shared/querySelect.utils';
|
|
4
4
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
5
5
|
import { Key } from 'react-aria-components';
|
|
6
6
|
import { FieldValues } from 'react-hook-form';
|
|
7
|
-
export type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key
|
|
7
|
+
export type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectProps<TKey, TInitialSelectItem>, "items" | "totalItems" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey, TInitialSelectItem> & {
|
|
8
8
|
query: TQueryFn;
|
|
9
9
|
queryParams?: Parameters<TQueryFn>[0];
|
|
10
10
|
queryOptions?: Parameters<TQueryFn>[1];
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Select } from "./Select.js";
|
|
3
3
|
import { getQueryItems } from "../shared/querySelect.utils.js";
|
|
4
4
|
import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { mergeRefs } from "@react-aria/utils";
|
|
7
|
-
import { Controller } from "react-hook-form";
|
|
8
6
|
//#region src/components/inputs/Selection/Select/QuerySelect.tsx
|
|
9
7
|
var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) => {
|
|
10
8
|
const ui = UIConfig.useConfig();
|
|
@@ -15,41 +13,14 @@ var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) =>
|
|
|
15
13
|
mapItems: (data) => getQueryItems(data, queryMap),
|
|
16
14
|
initialQueryState: props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled
|
|
17
15
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
control: formControl.control,
|
|
22
|
-
name: formControl.name,
|
|
23
|
-
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
24
|
-
...innerProps,
|
|
25
|
-
ref: mergeRefs(ref, field.ref),
|
|
26
|
-
items,
|
|
27
|
-
isLoading,
|
|
28
|
-
totalItems,
|
|
29
|
-
hasLoadMore: hasNextPage,
|
|
30
|
-
onLoadMore: fetchNextPage,
|
|
31
|
-
value: field.value,
|
|
32
|
-
onChange: (value) => {
|
|
33
|
-
field.onChange(value);
|
|
34
|
-
field.onBlur?.();
|
|
35
|
-
},
|
|
36
|
-
onBlur: field.onBlur,
|
|
37
|
-
isDirty,
|
|
38
|
-
isDisabled: field.disabled || props.isDisabled,
|
|
39
|
-
error: props.error ?? error?.message,
|
|
40
|
-
onMouseEnter: handleEnableQuery,
|
|
41
|
-
onFocusCapture: handleEnableQuery
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const { isInitialQueryDisabled: _, ...restProps } = props;
|
|
46
|
-
return /* @__PURE__ */ jsx(SelectBase, {
|
|
47
|
-
...restProps,
|
|
16
|
+
const { isInitialQueryDisabled: _, ...selectProps } = props;
|
|
17
|
+
return /* @__PURE__ */ jsx(Select, {
|
|
18
|
+
...selectProps,
|
|
48
19
|
items,
|
|
49
20
|
isLoading,
|
|
50
21
|
totalItems,
|
|
51
22
|
hasLoadMore: hasNextPage,
|
|
52
|
-
onLoadMore: fetchNextPage
|
|
23
|
+
onLoadMore: fetchNextPage,
|
|
53
24
|
onMouseEnter: handleEnableQuery,
|
|
54
25
|
onFocusCapture: handleEnableQuery
|
|
55
26
|
});
|
|
@@ -12,6 +12,11 @@ export declare const inputSize: (props?: ({
|
|
|
12
12
|
} & ClassProp) | undefined) => string;
|
|
13
13
|
export interface InputSizeProps extends VariantProps<typeof inputSize> {
|
|
14
14
|
}
|
|
15
|
+
export declare const inputContentWrapper: (props?: ({
|
|
16
|
+
as?: "filter" | "default" | "floating" | "inline" | null | undefined;
|
|
17
|
+
} & ClassProp) | undefined) => string;
|
|
18
|
+
export interface InputContentWrapperProps extends VariantProps<typeof inputContentWrapper> {
|
|
19
|
+
}
|
|
15
20
|
export declare const inputClearClass: (props?: ({
|
|
16
21
|
as?: "filter" | "default" | "floating" | "inline" | null | undefined;
|
|
17
22
|
} & ClassProp) | undefined) => string;
|
|
@@ -191,6 +191,15 @@ var inputSize = cva("", {
|
|
|
191
191
|
as: "default"
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
|
+
var inputContentWrapper = cva("flex w-full", {
|
|
195
|
+
variants: { as: {
|
|
196
|
+
default: "",
|
|
197
|
+
floating: "flex-col",
|
|
198
|
+
filter: "gap-input-gap-input-text-to-elements",
|
|
199
|
+
inline: ""
|
|
200
|
+
} },
|
|
201
|
+
defaultVariants: { as: "default" }
|
|
202
|
+
});
|
|
194
203
|
var inputClearClass = cva("", {
|
|
195
204
|
variants: { as: {
|
|
196
205
|
default: "",
|
|
@@ -286,4 +295,4 @@ var useInputCva = () => {
|
|
|
286
295
|
};
|
|
287
296
|
};
|
|
288
297
|
//#endregion
|
|
289
|
-
export { inputBase, inputClearClass, inputSide, inputSize, useInputCva };
|
|
298
|
+
export { inputBase, inputClearClass, inputContentWrapper, inputSide, inputSize, useInputCva };
|
|
@@ -34,7 +34,7 @@ export declare namespace UIConfig {
|
|
|
34
34
|
};
|
|
35
35
|
toggle: Pick<ToggleProps, "variant">;
|
|
36
36
|
slider: Pick<SliderProps, "minValue" | "maxValue">;
|
|
37
|
-
dateInput: Pick<DatePickerProps, "todayIcon" | "todayIconButtonSize" | "shouldForceLeadingZeros" | "disableManualEntry" | "autoFixYear"> & {
|
|
37
|
+
dateInput: Pick<DatePickerProps, "todayIcon" | "todayIconButtonSize" | "todayIconPlacement" | "shouldForceLeadingZeros" | "disableManualEntry" | "autoFixYear"> & {
|
|
38
38
|
calendarIcon?: ReactElement;
|
|
39
39
|
dateTimeIcon?: ReactElement;
|
|
40
40
|
timeIcon?: ReactElement;
|
|
@@ -11,7 +11,7 @@ import { FormFieldHelperVariantProps } from '../components/inputs/FormField/form
|
|
|
11
11
|
import { RadioVariantProps } from '../components/inputs/RadioGroup/radio.cva';
|
|
12
12
|
import { SelectPopoverCva } from '../components/inputs/Selection/shared/selectDesktop.cva';
|
|
13
13
|
import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
|
|
14
|
-
import { InputBaseProps, InputClearClassProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
|
|
14
|
+
import { InputBaseProps, InputClearClassProps, InputContentWrapperProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
|
|
15
15
|
import { LabelBaseProps } from '../components/inputs/shared/label.cva';
|
|
16
16
|
import { TooltipWrapperTriggerVariantProps } from '../components/inputs/shared/tooltipWrapper.cva';
|
|
17
17
|
import { ToggleVariantProps } from '../components/inputs/Toggle/toggle.cva';
|
|
@@ -71,6 +71,7 @@ export declare namespace UIStyle {
|
|
|
71
71
|
input: {
|
|
72
72
|
baseCva?: Cva<InputBaseProps>;
|
|
73
73
|
clearClassCva?: Cva<InputClearClassProps>;
|
|
74
|
+
contentWrapperCva?: Cva<InputContentWrapperProps>;
|
|
74
75
|
sizeCva?: Cva<InputSizeProps>;
|
|
75
76
|
sideCva?: Cva<InputSideProps>;
|
|
76
77
|
};
|