@povio/ui 2.2.9-rc.4 → 2.2.9-rc.41
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/buttons/Button/Button.d.ts +2 -1
- package/dist/components/buttons/Button/Button.js +41 -32
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +2 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
- package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
- package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
- package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +8 -3
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +81 -6
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -2
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +83 -5
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -2
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +84 -7
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +60 -4
- package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
- package/dist/components/inputs/DateTime/shared/Calendar.js +23 -6
- package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
- package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
- package/dist/components/inputs/DateTime/shared/DateField.js +3 -10
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +6 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +65 -55
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +19 -6
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +4 -2
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +4 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
- package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +21 -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/DateTime/shared/staticDateTimeSegments.d.ts +35 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +80 -0
- package/dist/components/inputs/File/FileUpload.js +1 -0
- package/dist/components/inputs/File/shared/InputUploadContent.js +1 -0
- package/dist/components/inputs/FormField/FormField.d.ts +3 -3
- package/dist/components/inputs/FormField/FormFieldHeader.d.ts +2 -2
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -2
- package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
- package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +78 -7
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.d.ts +45 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeField.js +146 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +35 -0
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +233 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.d.ts +4 -0
- package/dist/components/inputs/Input/TextArea/TextArea.cva.js +5 -0
- package/dist/components/inputs/Input/TextArea/TextArea.js +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +77 -7
- package/dist/components/inputs/Input/shared/InputContent.js +7 -6
- package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
- package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
- package/dist/components/inputs/Inputs/InputItem.d.ts +12 -9
- package/dist/components/inputs/Inputs/InputItem.js +2 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.d.ts +2 -1
- package/dist/components/inputs/RadioGroup/RadioGroup.js +106 -25
- package/dist/components/inputs/RadioGroup/radio.cva.d.ts +17 -0
- package/dist/components/inputs/RadioGroup/radio.cva.js +42 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +95 -6
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +20 -11
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -3
- package/dist/components/inputs/Selection/Select/QuerySelect.js +22 -36
- package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
- package/dist/components/inputs/Selection/Select/Select.js +108 -4
- package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
- package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
- package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
- package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +13 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
- package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
- package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
- package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -3
- package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/select.context.js +27 -4
- package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
- package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
- package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +77 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +200 -0
- package/dist/components/inputs/TextEditor/TextEditor.js +1 -0
- package/dist/components/inputs/Toggle/Toggle.js +6 -1
- package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
- package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
- package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
- package/dist/components/inputs/shared/CheckContent.js +3 -4
- package/dist/components/inputs/shared/InputClear.d.ts +2 -1
- package/dist/components/inputs/shared/InputClear.js +13 -1
- package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
- package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
- package/dist/components/inputs/shared/input.cva.d.ts +10 -0
- package/dist/components/inputs/shared/input.cva.js +19 -1
- package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.d.ts +13 -0
- package/dist/components/inputs/shared/useStaticInputHandoff.js +47 -0
- package/dist/config/uiConfig.context.d.ts +8 -2
- package/dist/config/uiConfig.context.js +12 -1
- package/dist/config/uiStyle.context.d.ts +27 -4
- package/dist/hooks/useIntersectionObserver.d.ts +1 -1
- package/dist/hooks/useIntersectionObserver.js +29 -10
- package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
- package/dist/hooks/useQueryAutocomplete.js +20 -5
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -2
- package/dist/tw-ui-plugin.js +2 -0
- package/dist/utils/date-time.utils.d.ts +30 -9
- package/dist/utils/date-time.utils.js +113 -1
- package/dist/utils/query.utils.d.ts +4 -0
- package/dist/utils/query.utils.js +8 -0
- package/package.json +1 -1
|
@@ -1,23 +1,30 @@
|
|
|
1
|
+
import { UIStyle } from "../../../../config/uiStyle.context.js";
|
|
1
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
2
3
|
import { Calendar } from "../shared/Calendar.js";
|
|
4
|
+
import { datePickerInputContentRow } from "../shared/datePickerInput.cva.js";
|
|
5
|
+
import { renderDatePickerTodayIcon } from "../shared/datePickerTodayIcon.js";
|
|
3
6
|
import { DatePickerInput } from "../shared/DatePickerInput.js";
|
|
4
7
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
5
8
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
9
|
+
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
10
|
+
import { getStaticCalendarDateTimeSegments } from "../shared/staticDateTimeSegments.js";
|
|
6
11
|
import { FormField } from "../../FormField/FormField.js";
|
|
7
12
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
13
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
14
|
+
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
8
15
|
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
9
|
-
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
10
16
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import {
|
|
17
|
+
import { clsx } from "clsx";
|
|
18
|
+
import { useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
12
19
|
import { useDatePicker, useLocale } from "react-aria";
|
|
13
20
|
import { mergeRefs } from "@react-aria/utils";
|
|
14
|
-
import { Controller } from "react-hook-form";
|
|
21
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
15
22
|
import { Time, createCalendar, getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
|
|
16
23
|
import { useCalendarState, useDatePickerState } from "react-stately";
|
|
17
24
|
//#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
|
|
18
25
|
var DateTimePickerBase = (props) => {
|
|
19
26
|
const ui = UIConfig.useConfig();
|
|
20
|
-
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, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
|
|
27
|
+
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;
|
|
21
28
|
const formFieldProps = {
|
|
22
29
|
error,
|
|
23
30
|
label,
|
|
@@ -153,8 +160,11 @@ var DateTimePickerBase = (props) => {
|
|
|
153
160
|
isClearable,
|
|
154
161
|
headerProps,
|
|
155
162
|
todayIcon,
|
|
163
|
+
todayIconButtonSize,
|
|
164
|
+
todayIconPlacement,
|
|
156
165
|
isRequired,
|
|
157
166
|
disableManualEntry,
|
|
167
|
+
autoFixYear,
|
|
158
168
|
placeholder,
|
|
159
169
|
onOpenDropdown: () => state.toggle(),
|
|
160
170
|
className: inputClassName
|
|
@@ -175,13 +185,35 @@ var DateTimePickerBase = (props) => {
|
|
|
175
185
|
calendarProps,
|
|
176
186
|
includesTime: true,
|
|
177
187
|
datePickerState: dialogState,
|
|
178
|
-
onApply
|
|
188
|
+
onApply,
|
|
189
|
+
setDateValueOnDateSelection
|
|
179
190
|
})
|
|
180
191
|
})]
|
|
181
192
|
})
|
|
182
193
|
});
|
|
183
194
|
};
|
|
184
|
-
var DateTimePicker = ({ fullIso = true, ...props }) => {
|
|
195
|
+
var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
|
|
196
|
+
const ui = UIConfig.useConfig();
|
|
197
|
+
const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
|
|
198
|
+
const { locale } = useLocale();
|
|
199
|
+
const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? ui.dateInput.shouldForceLeadingZeros;
|
|
200
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
201
|
+
const inputRef = useRef(null);
|
|
202
|
+
const { renderRealInput } = useStaticInputHandoff({
|
|
203
|
+
inputRef,
|
|
204
|
+
renderInput,
|
|
205
|
+
setRenderInput,
|
|
206
|
+
getFocusTarget: (input) => {
|
|
207
|
+
return (input.getContainer?.() ?? input).querySelector("input, button, [tabindex]:not([tabindex='-1'])");
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
211
|
+
control: props.formControl.control,
|
|
212
|
+
name: props.formControl.name
|
|
213
|
+
}) : props.value;
|
|
214
|
+
let isFormControlDisabled = false;
|
|
215
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
216
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
185
217
|
const formatDateValue = (dateValue) => {
|
|
186
218
|
if (dateValue === null) return null;
|
|
187
219
|
if (fullIso) return DateTimeUtils.fromCalendarDateTimeToUTCISO(dateValue);
|
|
@@ -191,6 +223,50 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
|
|
|
191
223
|
if (isoString == null) return isoString;
|
|
192
224
|
return DateTimeUtils.fromUTCISOToCalendarDateTime(isoString);
|
|
193
225
|
};
|
|
226
|
+
if (!renderInput) {
|
|
227
|
+
const dateTimeValue = rawValue ? parseDateValue(rawValue) : null;
|
|
228
|
+
const as = props.as ?? ui.input.as;
|
|
229
|
+
const size = props.size ?? ui.input.size;
|
|
230
|
+
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
231
|
+
const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
|
|
232
|
+
const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
|
|
233
|
+
const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
|
|
234
|
+
const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
|
|
235
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
236
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
237
|
+
const staticSegments = getStaticCalendarDateTimeSegments({
|
|
238
|
+
value: dateTimeValue,
|
|
239
|
+
locale,
|
|
240
|
+
placeholder: props.placeholder,
|
|
241
|
+
shouldForceLeadingZeros,
|
|
242
|
+
isDisabled,
|
|
243
|
+
hidePlaceholder: as === "floating" && !dateTimeValue
|
|
244
|
+
});
|
|
245
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
246
|
+
...props,
|
|
247
|
+
isDisabled,
|
|
248
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
249
|
+
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
250
|
+
contentWrapperClassName: datePickerInputContentRowCva({ size }),
|
|
251
|
+
labelPlacement: "content-row",
|
|
252
|
+
dataAttributes: {
|
|
253
|
+
dataIsEmpty: dateTimeValue === null,
|
|
254
|
+
dataIsFilled: dateTimeValue !== null,
|
|
255
|
+
dataIsDirty: props.isDirty,
|
|
256
|
+
dataIsRequired: props.isRequired,
|
|
257
|
+
dataIsDisabled: isDisabled,
|
|
258
|
+
dataDisabled: isDisabled,
|
|
259
|
+
dataInvalid: !!props.error,
|
|
260
|
+
dataHasSelection: dateTimeValue !== null
|
|
261
|
+
},
|
|
262
|
+
renderStatic: true,
|
|
263
|
+
onStaticInteract: renderRealInput,
|
|
264
|
+
actionContent: staticTodayIcon,
|
|
265
|
+
actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
|
|
266
|
+
trailingContent: showDropdown ? ui.dateInput.dateTimeIcon : void 0,
|
|
267
|
+
children: staticSegments
|
|
268
|
+
});
|
|
269
|
+
}
|
|
194
270
|
if ("formControl" in props && props.formControl) {
|
|
195
271
|
const { formControl, ref, ...innerProps } = props;
|
|
196
272
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -198,7 +274,7 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
|
|
|
198
274
|
name: formControl.name,
|
|
199
275
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(DateTimePickerBase, {
|
|
200
276
|
...innerProps,
|
|
201
|
-
ref: mergeRefs(ref, field.ref),
|
|
277
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
202
278
|
value: parseDateValue(field.value),
|
|
203
279
|
onChange: (value) => field.onChange(formatDateValue(value)),
|
|
204
280
|
onBlur: field.onBlur,
|
|
@@ -210,6 +286,7 @@ var DateTimePicker = ({ fullIso = true, ...props }) => {
|
|
|
210
286
|
}
|
|
211
287
|
return /* @__PURE__ */ jsx(DateTimePickerBase, {
|
|
212
288
|
...props,
|
|
289
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
213
290
|
value: parseDateValue(props.value),
|
|
214
291
|
onChange: (value) => props.onChange?.(formatDateValue(value))
|
|
215
292
|
});
|
|
@@ -19,7 +19,8 @@ export interface TimePickerProps extends Omit<TimePickerBaseProps, "value" | "on
|
|
|
19
19
|
value?: string | null;
|
|
20
20
|
onChange?: (value: string | null) => void;
|
|
21
21
|
fullIso?: boolean;
|
|
22
|
+
renderStaticInput?: boolean;
|
|
22
23
|
}
|
|
23
24
|
export type ControlledTimePickerProps<TFieldValues extends FieldValues> = ControlProps<TimePickerProps, TFieldValues>;
|
|
24
|
-
export declare const TimePicker: <TFieldValues extends FieldValues>(props: ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const TimePicker: <TFieldValues extends FieldValues>({ renderStaticInput, ...props }: ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
|
|
25
26
|
export {};
|
|
@@ -2,17 +2,20 @@ import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
|
2
2
|
import { TimePickerForm } from "../shared/TimePickerForm.js";
|
|
3
3
|
import { DateTimeDialog } from "../shared/DateTimeDialog.js";
|
|
4
4
|
import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
|
|
5
|
+
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
6
|
+
import { getStaticTimeSegments } from "../shared/staticDateTimeSegments.js";
|
|
5
7
|
import { FormField } from "../../FormField/FormField.js";
|
|
6
8
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
9
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
10
|
+
import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
|
|
7
11
|
import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
|
|
8
|
-
import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
|
|
9
12
|
import { TimePickerInput } from "../shared/TimePickerInput.js";
|
|
10
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
14
|
import { clsx } from "clsx";
|
|
12
15
|
import { useEffect, useRef, useState } from "react";
|
|
13
16
|
import { useLocale, useTimeField } from "react-aria";
|
|
14
17
|
import { mergeRefs } from "@react-aria/utils";
|
|
15
|
-
import { Controller } from "react-hook-form";
|
|
18
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
16
19
|
import { getLocalTimeZone, now, toTime } from "@internationalized/date";
|
|
17
20
|
import { DateTime } from "luxon";
|
|
18
21
|
import { useTimeFieldState } from "react-stately";
|
|
@@ -136,7 +139,24 @@ var TimePickerBase = (props) => {
|
|
|
136
139
|
})
|
|
137
140
|
});
|
|
138
141
|
};
|
|
139
|
-
var TimePicker = (props) => {
|
|
142
|
+
var TimePicker = ({ renderStaticInput, ...props }) => {
|
|
143
|
+
const ui = UIConfig.useConfig();
|
|
144
|
+
const { locale } = useLocale();
|
|
145
|
+
const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
|
|
146
|
+
const inputRef = useRef(null);
|
|
147
|
+
const { renderRealInput } = useStaticInputHandoff({
|
|
148
|
+
inputRef,
|
|
149
|
+
renderInput,
|
|
150
|
+
setRenderInput,
|
|
151
|
+
getFocusTarget: (input) => input.querySelector("input, button, [tabindex]:not([tabindex='-1'])")
|
|
152
|
+
});
|
|
153
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
154
|
+
control: props.formControl.control,
|
|
155
|
+
name: props.formControl.name
|
|
156
|
+
}) : props.value;
|
|
157
|
+
let isFormControlDisabled = false;
|
|
158
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
159
|
+
const rawValue = watchedValue ?? props.value ?? null;
|
|
140
160
|
const formatTimeValue = (timeValue) => {
|
|
141
161
|
if (timeValue === null) return null;
|
|
142
162
|
const parsedDate = props.date ? DateTime.fromISO(props.date).toJSDate() : void 0;
|
|
@@ -147,6 +167,41 @@ var TimePicker = (props) => {
|
|
|
147
167
|
if (isoString == null) return isoString;
|
|
148
168
|
return toTime(DateTimeUtils.fromISOtoZonedDateTime(isoString));
|
|
149
169
|
};
|
|
170
|
+
if (!renderInput) {
|
|
171
|
+
const timeValue = rawValue ? parseTimeValue(rawValue) : null;
|
|
172
|
+
const as = props.as ?? ui.input.as;
|
|
173
|
+
const isDisabled = isFormControlDisabled || !!props.isDisabled;
|
|
174
|
+
const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
|
|
175
|
+
const showDropdown = !props.disableDropdown || disableManualEntry;
|
|
176
|
+
const staticSegments = getStaticTimeSegments({
|
|
177
|
+
value: timeValue,
|
|
178
|
+
locale,
|
|
179
|
+
placeholder: props.placeholder,
|
|
180
|
+
isDisabled,
|
|
181
|
+
hidePlaceholder: as === "floating" && !timeValue
|
|
182
|
+
});
|
|
183
|
+
return /* @__PURE__ */ jsx(InputFrame, {
|
|
184
|
+
...props,
|
|
185
|
+
isDisabled,
|
|
186
|
+
className: clsx("relative inline-flex w-full flex-col text-left", props.className),
|
|
187
|
+
inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
|
|
188
|
+
labelPlacement: "content-row",
|
|
189
|
+
dataAttributes: {
|
|
190
|
+
dataIsEmpty: timeValue === null,
|
|
191
|
+
dataIsFilled: timeValue !== null,
|
|
192
|
+
dataIsDirty: props.isDirty,
|
|
193
|
+
dataIsRequired: props.isRequired,
|
|
194
|
+
dataIsDisabled: isDisabled,
|
|
195
|
+
dataDisabled: isDisabled,
|
|
196
|
+
dataInvalid: !!props.error,
|
|
197
|
+
dataHasSelection: timeValue !== null
|
|
198
|
+
},
|
|
199
|
+
renderStatic: true,
|
|
200
|
+
onStaticInteract: renderRealInput,
|
|
201
|
+
trailingContent: showDropdown ? ui.dateInput.timeIcon : void 0,
|
|
202
|
+
children: staticSegments
|
|
203
|
+
});
|
|
204
|
+
}
|
|
150
205
|
if ("formControl" in props && props.formControl) {
|
|
151
206
|
const { formControl, ref, ...innerProps } = props;
|
|
152
207
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -154,7 +209,7 @@ var TimePicker = (props) => {
|
|
|
154
209
|
name: formControl.name,
|
|
155
210
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(TimePickerBase, {
|
|
156
211
|
...innerProps,
|
|
157
|
-
ref: mergeRefs(ref, field.ref),
|
|
212
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
158
213
|
value: parseTimeValue(field.value),
|
|
159
214
|
onChange: (value) => field.onChange(formatTimeValue(value)),
|
|
160
215
|
onBlur: field.onBlur,
|
|
@@ -166,6 +221,7 @@ var TimePicker = (props) => {
|
|
|
166
221
|
}
|
|
167
222
|
return /* @__PURE__ */ jsx(TimePickerBase, {
|
|
168
223
|
...props,
|
|
224
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
169
225
|
value: parseTimeValue(props.value),
|
|
170
226
|
onChange: (value) => props.onChange?.(formatTimeValue(value))
|
|
171
227
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CalendarState, CalendarStateOptions } from '@react-stately/calendar';
|
|
2
|
+
import { DateValue } from 'react-aria';
|
|
2
3
|
import { DatePickerState } from 'react-stately';
|
|
3
4
|
type DateTimeCalendarProps = {
|
|
4
5
|
includesTime?: false;
|
|
@@ -13,8 +14,10 @@ type CalendarProps = DateTimeCalendarProps & {
|
|
|
13
14
|
className?: string;
|
|
14
15
|
state: CalendarState;
|
|
15
16
|
calendarProps: Omit<CalendarStateOptions, "locale" | "createCalendar">;
|
|
16
|
-
onApply: () => void;
|
|
17
|
+
onApply: (selectedDate?: DateValue) => void;
|
|
18
|
+
onDateSelectionChange?: (selectedDate: DateValue) => void;
|
|
19
|
+
setDateValueOnDateSelection?: boolean;
|
|
17
20
|
};
|
|
18
21
|
export type ToggleState = "month" | "year" | "time";
|
|
19
|
-
export declare const Calendar: ({ className, includesTime, datePickerState, hourCycle, onApply, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const Calendar: ({ className, includesTime, datePickerState, hourCycle, onApply, onDateSelectionChange, setDateValueOnDateSelection, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
23
|
export {};
|
|
@@ -5,20 +5,37 @@ import { TimePickerForm } from "./TimePickerForm.js";
|
|
|
5
5
|
import { YearPicker } from "./YearPicker.js";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { clsx } from "clsx";
|
|
8
|
-
import { useState } from "react";
|
|
8
|
+
import { useCallback, useState } from "react";
|
|
9
9
|
import { useCalendar } from "@react-aria/calendar";
|
|
10
10
|
//#region src/components/inputs/DateTime/shared/Calendar.tsx
|
|
11
|
-
var Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply, ...props }) => {
|
|
11
|
+
var Calendar = ({ className, includesTime, datePickerState, hourCycle, onApply, onDateSelectionChange, setDateValueOnDateSelection = false, ...props }) => {
|
|
12
12
|
const [toggleState, setToggleState] = useState(null);
|
|
13
13
|
const { calendarProps, prevButtonProps, nextButtonProps } = useCalendar(props.calendarProps, props.state);
|
|
14
|
-
const
|
|
15
|
-
if (includesTime
|
|
16
|
-
|
|
14
|
+
const onDateSelection = useCallback((date) => {
|
|
15
|
+
if (!includesTime || !setDateValueOnDateSelection) return;
|
|
16
|
+
datePickerState.setDateValue(date);
|
|
17
|
+
}, [
|
|
18
|
+
includesTime,
|
|
19
|
+
datePickerState,
|
|
20
|
+
setDateValueOnDateSelection
|
|
21
|
+
]);
|
|
22
|
+
const handleDateChange = (selectedDate) => {
|
|
23
|
+
const resolvedDate = selectedDate ?? props.state.focusedDate;
|
|
24
|
+
if (includesTime && resolvedDate && setDateValueOnDateSelection) {
|
|
25
|
+
datePickerState.setDateValue(resolvedDate);
|
|
26
|
+
onDateSelectionChange?.(resolvedDate);
|
|
27
|
+
}
|
|
28
|
+
if (includesTime && toggleState !== "time") {
|
|
29
|
+
setToggleState("time");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (datePickerState?.value && !setDateValueOnDateSelection) onApply(resolvedDate);
|
|
17
33
|
};
|
|
18
34
|
const getContent = () => {
|
|
19
35
|
if (!toggleState) return /* @__PURE__ */ jsx(CalendarGrid, {
|
|
20
36
|
state: props.state,
|
|
21
|
-
onApply: handleDateChange
|
|
37
|
+
onApply: handleDateChange,
|
|
38
|
+
onDateSelection
|
|
22
39
|
});
|
|
23
40
|
if (toggleState === "month") return /* @__PURE__ */ jsx(MonthPicker, {
|
|
24
41
|
state: props.state,
|
|
@@ -4,7 +4,7 @@ import { KeyboardEvent } from 'react';
|
|
|
4
4
|
import { DateValue } from 'react-aria';
|
|
5
5
|
interface CalendarCellProps extends AriaCalendarCellProps {
|
|
6
6
|
state: CalendarState | RangeCalendarState;
|
|
7
|
-
onApply?: () => void;
|
|
7
|
+
onApply?: (selectedDate?: DateValue) => void;
|
|
8
8
|
shouldCloseOnSelect?: boolean;
|
|
9
9
|
onDateSelection?: (date: DateValue) => void;
|
|
10
10
|
onDateHover?: (date: DateValue | null) => void;
|
|
@@ -17,12 +17,12 @@ var CalendarCell = ({ state, onApply, shouldCloseOnSelect = true, onDateSelectio
|
|
|
17
17
|
const onClick = useCallback((event) => {
|
|
18
18
|
buttonProps.onClick?.(event);
|
|
19
19
|
if (onDateSelection) onDateSelection(props.date);
|
|
20
|
-
if (
|
|
20
|
+
if (shouldCloseOnSelect && !isDisabled) onApply?.(props.date);
|
|
21
21
|
}, [
|
|
22
22
|
buttonProps,
|
|
23
23
|
onDateSelection,
|
|
24
24
|
props.date,
|
|
25
|
-
|
|
25
|
+
isDisabled,
|
|
26
26
|
shouldCloseOnSelect,
|
|
27
27
|
onApply
|
|
28
28
|
]);
|
|
@@ -87,7 +87,7 @@ var CalendarCell = ({ state, onApply, shouldCloseOnSelect = true, onDateSelectio
|
|
|
87
87
|
state.setFocusedDate(props.date);
|
|
88
88
|
}
|
|
89
89
|
eventHandler?.(event);
|
|
90
|
-
if (isSelected && shouldCloseOnSelect) onApply?.();
|
|
90
|
+
if (isSelected && shouldCloseOnSelect) onApply?.(props.date);
|
|
91
91
|
};
|
|
92
92
|
const onMouseEnter = useCallback(() => {
|
|
93
93
|
if (onDateHover && selectionState.isSelectingMode) onDateHover(props.date);
|
|
@@ -4,7 +4,7 @@ import { KeyboardEvent } from 'react';
|
|
|
4
4
|
import { DateValue } from 'react-aria';
|
|
5
5
|
interface CalendarGridProps extends AriaCalendarGridProps {
|
|
6
6
|
state: CalendarState | RangeCalendarState;
|
|
7
|
-
onApply?: () => void;
|
|
7
|
+
onApply?: (selectedDate?: DateValue) => void;
|
|
8
8
|
offset?: {
|
|
9
9
|
months?: number;
|
|
10
10
|
};
|
|
@@ -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,5 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'react';
|
|
2
2
|
import { DatePickerAria } from 'react-aria';
|
|
3
|
+
import { DatePickerTodayIcon, DatePickerTodayIconButtonSize, DatePickerTodayIconPlacement } from './datePicker.types';
|
|
3
4
|
import { FormFieldHeaderProps } from '../../FormField/FormFieldHeader';
|
|
4
5
|
import { InputVariantProps } from '../../shared/input.cva';
|
|
5
6
|
export interface DatePickerInputHandle {
|
|
@@ -18,13 +19,16 @@ interface DatePickerInputProps extends InputVariantProps {
|
|
|
18
19
|
isDateTime?: boolean;
|
|
19
20
|
isClearable?: boolean;
|
|
20
21
|
headerProps?: FormFieldHeaderProps;
|
|
21
|
-
todayIcon?:
|
|
22
|
+
todayIcon?: DatePickerTodayIcon;
|
|
23
|
+
todayIconButtonSize?: DatePickerTodayIconButtonSize;
|
|
24
|
+
todayIconPlacement?: DatePickerTodayIconPlacement;
|
|
22
25
|
isDirty?: boolean;
|
|
23
26
|
isRequired?: boolean;
|
|
24
27
|
disableManualEntry?: boolean;
|
|
28
|
+
autoFixYear?: boolean;
|
|
25
29
|
placeholder?: string;
|
|
26
30
|
className?: string;
|
|
27
31
|
onOpenDropdown?: () => void;
|
|
28
32
|
}
|
|
29
|
-
export declare const DatePickerInput: ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, isDirty, isRequired, disableManualEntry, 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;
|
|
30
34
|
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { CalendarIcon } from "../../../../assets/icons/Calendar.js";
|
|
2
|
-
import { DateTimeIcon } from "../../../../assets/icons/DateTime.js";
|
|
3
1
|
import { UIStyle } from "../../../../config/uiStyle.context.js";
|
|
4
2
|
import { Typography } from "../../../text/Typography/Typography.js";
|
|
5
|
-
import {
|
|
3
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
6
4
|
import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
|
|
7
|
-
import { TodayIcon } from "../../../../assets/icons/Today.js";
|
|
8
5
|
import { DateField } from "./DateField.js";
|
|
6
|
+
import { datePickerInputContentRow } from "./datePickerInput.cva.js";
|
|
7
|
+
import { getDatePickerTodayIcon } from "./datePickerTodayIcon.js";
|
|
9
8
|
import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
|
|
10
9
|
import { InputClear } from "../../shared/InputClear.js";
|
|
11
10
|
import { inputBase, inputSize } from "../../shared/input.cva.js";
|
|
@@ -16,15 +15,17 @@ import { Button } from "react-aria-components";
|
|
|
16
15
|
import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
|
|
17
16
|
import { getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
|
|
18
17
|
//#region src/components/inputs/DateTime/shared/DatePickerInput.tsx
|
|
19
|
-
var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, isDirty, isRequired, disableManualEntry, 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
|
+
const uiConfig = UIConfig.useConfig();
|
|
20
20
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
21
21
|
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
22
|
+
const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
|
|
22
23
|
const [canClear, setCanClear] = useState(false);
|
|
23
24
|
const { hoverProps, isHovered } = useHover({ isDisabled });
|
|
24
25
|
const [isFocused, setIsFocused] = useState(false);
|
|
25
26
|
const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: (isFocusWithin) => {
|
|
26
27
|
setIsFocused(isFocusWithin);
|
|
27
|
-
if (!isFocusWithin) {
|
|
28
|
+
if (!isFocusWithin && autoFixYear) {
|
|
28
29
|
dateFieldRef.current?.autoFixYear();
|
|
29
30
|
endDateFieldRef.current?.autoFixYear();
|
|
30
31
|
}
|
|
@@ -70,17 +71,28 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
|
|
|
70
71
|
endFieldProps?.onBlur?.(null);
|
|
71
72
|
};
|
|
72
73
|
const hidePlaceholder = as === "floating" && !fieldProps.value && !isFocused;
|
|
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";
|
|
83
|
+
const pickerIcon = isDateTime ? uiConfig.dateInput.dateTimeIcon : uiConfig.dateInput.calendarIcon;
|
|
73
84
|
return /* @__PURE__ */ jsxs("div", {
|
|
74
85
|
ref: containerRef,
|
|
75
|
-
className: clsx(inputBaseCva({
|
|
86
|
+
className: clsx("group/date-picker-content relative flex min-w-input-width-min-width items-center justify-between gap-2", inputBaseCva({
|
|
76
87
|
variant,
|
|
77
88
|
as,
|
|
78
89
|
...props
|
|
79
|
-
}),
|
|
90
|
+
}), className),
|
|
80
91
|
"data-rac": "",
|
|
81
92
|
"data-datetime-input": "",
|
|
82
93
|
"data-hovered": isHovered || void 0,
|
|
83
94
|
"data-disabled": isDisabled || void 0,
|
|
95
|
+
"data-is-disabled": isDisabled || void 0,
|
|
84
96
|
"data-invalid": isInvalid || void 0,
|
|
85
97
|
"data-is-empty": fieldProps.value === null || void 0,
|
|
86
98
|
"data-focus-within": isFocused || void 0,
|
|
@@ -93,54 +105,52 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
|
|
|
93
105
|
...focusWithinProps,
|
|
94
106
|
...hoverProps,
|
|
95
107
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
96
|
-
className: clsx(inputSizeCva({
|
|
108
|
+
className: clsx("flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", inputSizeCva({
|
|
97
109
|
size,
|
|
98
110
|
as
|
|
99
|
-
})
|
|
100
|
-
children: [
|
|
101
|
-
as,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
})]
|
|
111
|
+
})),
|
|
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
|
+
]
|
|
144
154
|
}), /* @__PURE__ */ jsxs("div", {
|
|
145
155
|
className: clsx(inputSizeCva({
|
|
146
156
|
size,
|
|
@@ -153,7 +163,7 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
|
|
|
153
163
|
label: "",
|
|
154
164
|
color: "secondary",
|
|
155
165
|
...buttonProps,
|
|
156
|
-
icon:
|
|
166
|
+
icon: pickerIcon,
|
|
157
167
|
isDisabled,
|
|
158
168
|
className: "border-0!"
|
|
159
169
|
})]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DateFieldState, DateSegment } from '@react-stately/datepicker';
|
|
2
|
+
import { HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
3
|
interface DateSegmentProps {
|
|
3
4
|
state: DateFieldState;
|
|
4
5
|
segment: DateSegment;
|
|
@@ -8,4 +9,17 @@ interface DateSegmentProps {
|
|
|
8
9
|
}
|
|
9
10
|
export declare const getPlaceholder: (segment: DateSegment) => string | null;
|
|
10
11
|
export declare const DateSegmentItem: ({ segment, state, isDisabled, timePickerOnly, hidePlaceholder }: DateSegmentProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
interface DateSegmentItemViewProps {
|
|
13
|
+
ref?: Ref<HTMLDivElement>;
|
|
14
|
+
segmentProps?: HTMLAttributes<HTMLDivElement>;
|
|
15
|
+
type?: DateSegment["type"];
|
|
16
|
+
text: ReactNode;
|
|
17
|
+
placeholder?: ReactNode;
|
|
18
|
+
isPlaceholder?: boolean;
|
|
19
|
+
isInputEmpty?: boolean;
|
|
20
|
+
isDisabled?: boolean;
|
|
21
|
+
timePickerOnly?: boolean;
|
|
22
|
+
hidePlaceholder?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const DateSegmentItemView: ({ ref, segmentProps, type, text, placeholder, isPlaceholder, isInputEmpty, isDisabled, timePickerOnly, hidePlaceholder, }: DateSegmentItemViewProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
25
|
export {};
|