@povio/ui 2.2.9-rc.1 → 2.2.9-rc.3

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.
Files changed (35) hide show
  1. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +3 -2
  2. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +17 -5
  3. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +3 -2
  4. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +11 -2
  5. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +3 -2
  6. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +10 -2
  7. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +3 -2
  8. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +13 -3
  9. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +6 -0
  10. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +4 -1
  11. package/dist/components/inputs/Input/TextInput/TextInput.js +2 -0
  12. package/dist/components/inputs/Inputs/InputItem.d.ts +8 -10
  13. package/dist/components/inputs/Inputs/InputItem.js +4 -0
  14. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +3 -18
  15. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +23 -7
  16. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +30 -0
  17. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +15 -0
  18. package/dist/components/inputs/Selection/Select/QuerySelect.js +56 -0
  19. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +3 -1
  20. package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
  21. package/dist/components/inputs/Selection/shared/SelectDesktop.js +3 -1
  22. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  23. package/dist/components/inputs/Selection/shared/SelectInput.js +3 -1
  24. package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
  25. package/dist/components/inputs/Selection/shared/SelectMobile.js +3 -1
  26. package/dist/components/inputs/Selection/shared/querySelect.utils.d.ts +6 -0
  27. package/dist/components/inputs/Selection/shared/querySelect.utils.js +13 -0
  28. package/dist/components/inputs/Selection/shared/select.context.js +1 -1
  29. package/dist/config/uiConfig.context.d.ts +6 -0
  30. package/dist/config/uiConfig.context.js +2 -0
  31. package/dist/helpers/dynamicInputs.d.ts +5 -5
  32. package/dist/hooks/useQueryAutocomplete.d.ts +25 -0
  33. package/dist/hooks/useQueryAutocomplete.js +41 -0
  34. package/dist/index.js +2 -2
  35. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
1
  import { CalendarDate, DateValue } from '@internationalized/date';
2
- import { Ref } from 'react';
2
+ import { Ref, FocusEvent } 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
6
  import { FormFieldProps } from '../../FormField/FormField';
7
7
  import { ControlProps } from '../../shared/form.types';
8
8
  import { InputVariantProps } from '../../shared/input.cva';
9
- interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
9
+ interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
10
10
  ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
11
11
  disableDropdown?: boolean;
12
12
  isClearable?: boolean;
@@ -16,6 +16,7 @@ interface DatePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Da
16
16
  disableManualEntry?: boolean;
17
17
  placeholder?: string;
18
18
  inputClassName?: string;
19
+ onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
19
20
  }
20
21
  export interface DatePickerProps extends Omit<DatePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
21
22
  value?: string | null;
@@ -5,6 +5,7 @@ import { DateTimeDialog } from "../shared/DateTimeDialog.js";
5
5
  import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
6
6
  import { FormField } from "../../FormField/FormField.js";
7
7
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
8
+ import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
8
9
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
11
  import { clsx } from "clsx";
@@ -12,13 +13,14 @@ import { useImperativeHandle, useMemo, useRef } from "react";
12
13
  import { useDatePicker, useLocale } from "react-aria";
13
14
  import { mergeRefs } from "@react-aria/utils";
14
15
  import { Controller } from "react-hook-form";
15
- import { createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
16
+ import { CalendarDate, createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
16
17
  import { DateTime } from "luxon";
17
18
  import { useCalendarState, useDatePickerState } from "react-stately";
18
19
  //#region src/components/inputs/DateTime/DatePicker/DatePicker.tsx
20
+ var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
19
21
  var DatePickerBase = (props) => {
20
22
  const ui = UIConfig.useConfig();
21
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, 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, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
23
+ 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, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
22
24
  const formFieldProps = {
23
25
  error,
24
26
  label,
@@ -39,6 +41,10 @@ var DatePickerBase = (props) => {
39
41
  useImperativeHandle(ref, () => ({ clear: () => {
40
42
  datePickerInputRef.current?.clear();
41
43
  } }));
44
+ const handleBlur = (val) => {
45
+ onBlur?.({ target: { value: val } });
46
+ };
47
+ const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
42
48
  const dialogState = useDatePickerState({
43
49
  ...rest,
44
50
  defaultValue: value || rest.defaultValue,
@@ -57,6 +63,7 @@ var DatePickerBase = (props) => {
57
63
  onChange?.(val);
58
64
  dialogState.setValue(val);
59
65
  calendarState.setFocusedDate(val || today(getLocalTimeZone()));
66
+ debouncedBlur(val);
60
67
  },
61
68
  shouldCloseOnSelect: false
62
69
  });
@@ -88,8 +95,10 @@ var DatePickerBase = (props) => {
88
95
  labelProps
89
96
  };
90
97
  const onApply = () => {
91
- state.setValue(dialogState.value);
98
+ const newValue = dialogState.value;
99
+ state.setValue(newValue);
92
100
  state.toggle();
101
+ handleBlur(newValue);
93
102
  };
94
103
  const onTodayPress = () => {
95
104
  dialogState.setValue(today(getLocalTimeZone()));
@@ -114,7 +123,10 @@ var DatePickerBase = (props) => {
114
123
  ref: mergeRefs(ref, datePickerInputRef),
115
124
  as,
116
125
  groupProps,
117
- fieldProps,
126
+ fieldProps: {
127
+ ...fieldProps,
128
+ placeholderValue: PLACEHOLDER_VALUE
129
+ },
118
130
  buttonProps,
119
131
  isDirty,
120
132
  isDisabled,
@@ -129,7 +141,7 @@ var DatePickerBase = (props) => {
129
141
  onOpenDropdown: () => state.toggle(),
130
142
  placeholder,
131
143
  className: inputClassName
132
- }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(DateTimeDialog, {
144
+ }), (!disableDropdown || disableManualEntry) && state.isOpen && /* @__PURE__ */ jsx(DateTimeDialog, {
133
145
  footer: /* @__PURE__ */ jsx(DateTimeDialogFooter, {
134
146
  isDisabled,
135
147
  isValid: !dialogState.isInvalid && !!dialogState.value,
@@ -1,5 +1,5 @@
1
1
  import { CalendarDate } from '@internationalized/date';
2
- import { Ref } from 'react';
2
+ import { FocusEvent, Ref } from 'react';
3
3
  import { DateValue } from 'react-aria';
4
4
  import { FieldValues } from 'react-hook-form';
5
5
  import { DateRangePickerStateOptions } from 'react-stately';
@@ -7,7 +7,7 @@ import { DatePickerInputHandle } from '../shared/DatePickerInput';
7
7
  import { FormFieldProps } from '../../FormField/FormField';
8
8
  import { ControlProps } from '../../shared/form.types';
9
9
  import { InputVariantProps } from '../../shared/input.cva';
10
- interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DateRangePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label"> {
10
+ interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DateRangePickerStateOptions<CalendarDate>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
11
11
  ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
12
12
  disableDropdown?: boolean;
13
13
  isClearable?: boolean;
@@ -18,6 +18,7 @@ interface DateRangePickerBaseProps extends FormFieldProps, InputVariantProps, Om
18
18
  disableManualEntry?: boolean;
19
19
  placeholder?: string;
20
20
  inputClassName?: string;
21
+ onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
21
22
  }
22
23
  export interface DateRangePickerProps extends Omit<DateRangePickerBaseProps, "value" | "onChange" | "minValue" | "maxValue"> {
23
24
  value?: {
@@ -6,6 +6,7 @@ import { DateTimeDialog } from "../shared/DateTimeDialog.js";
6
6
  import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
7
7
  import { FormField } from "../../FormField/FormField.js";
8
8
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
9
+ import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
9
10
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
10
11
  import { RangeCalendar } from "../shared/RangeCalendar.js";
11
12
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -23,7 +24,7 @@ import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
23
24
  var DateRangePickerBase = (props) => {
24
25
  const ui = UIConfig.useConfig();
25
26
  const { t } = useTranslation();
26
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, 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, 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, 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, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
27
28
  const [validationRangeError, setValidationRangeError] = useState();
28
29
  const datePickerInputRef = useRef(null);
29
30
  const dateRangePickerRef = useMemo(() => ({ get current() {
@@ -43,6 +44,7 @@ var DateRangePickerBase = (props) => {
43
44
  if (isValidRange(newValue)) return;
44
45
  onChange?.(newValue);
45
46
  handleCalendarStatesChange(newValue);
47
+ debouncedBlur(newValue);
46
48
  },
47
49
  shouldCloseOnSelect: false
48
50
  });
@@ -60,6 +62,10 @@ var DateRangePickerBase = (props) => {
60
62
  useImperativeHandle(ref, () => ({ clear: () => {
61
63
  datePickerInputRef.current?.clear();
62
64
  } }));
65
+ const handleBlur = (newValue) => {
66
+ onBlur?.({ target: { value: newValue } });
67
+ };
68
+ const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
63
69
  const formFieldProps = {
64
70
  error: error || validationRangeError,
65
71
  label,
@@ -321,7 +327,10 @@ var DateRangePickerBase = (props) => {
321
327
  start: rangeSelection.start,
322
328
  end: rangeSelection.end
323
329
  } : dialogState.value;
324
- if (valueToApply) state.setValue(valueToApply);
330
+ if (valueToApply) {
331
+ state.setValue(valueToApply);
332
+ handleBlur(valueToApply);
333
+ }
325
334
  state.toggle();
326
335
  };
327
336
  const onTodayPress = () => {
@@ -1,4 +1,4 @@
1
- import { Ref } from 'react';
1
+ import { FocusEvent, Ref } from 'react';
2
2
  import { DateValue } from 'react-aria';
3
3
  import { FieldValues } from 'react-hook-form';
4
4
  import { DatePickerStateOptions } from 'react-stately';
@@ -6,7 +6,7 @@ import { DatePickerInputHandle } from '../shared/DatePickerInput';
6
6
  import { FormFieldProps } from '../../FormField/FormField';
7
7
  import { ControlProps } from '../../shared/form.types';
8
8
  import { InputVariantProps } from '../../shared/input.cva';
9
- interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label"> {
9
+ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<DatePickerStateOptions<DateValue>, "granularity" | "shouldCloseOnSelect" | "label" | "onBlur"> {
10
10
  ref?: Ref<DatePickerInputHandle & HTMLDivElement>;
11
11
  disableDropdown?: boolean;
12
12
  isTimeOptional?: boolean;
@@ -16,6 +16,7 @@ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omi
16
16
  disableManualEntry?: boolean;
17
17
  placeholder?: string;
18
18
  inputClassName?: string;
19
+ onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
19
20
  }
20
21
  export interface DateTimePickerProps extends Omit<DateTimePickerBaseProps, "value" | "onChange"> {
21
22
  value?: string | null;
@@ -5,6 +5,7 @@ import { DateTimeDialog } from "../shared/DateTimeDialog.js";
5
5
  import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
6
6
  import { FormField } from "../../FormField/FormField.js";
7
7
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
8
+ import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
8
9
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
11
  import { useEffect, useImperativeHandle, useMemo, useRef } from "react";
@@ -16,7 +17,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
16
17
  //#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
17
18
  var DateTimePickerBase = (props) => {
18
19
  const ui = UIConfig.useConfig();
19
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, 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;
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;
20
21
  const formFieldProps = {
21
22
  error,
22
23
  label,
@@ -37,6 +38,10 @@ var DateTimePickerBase = (props) => {
37
38
  useImperativeHandle(ref, () => ({ clear: () => {
38
39
  datePickerInputRef.current?.clear();
39
40
  } }));
41
+ const handleBlur = (val) => {
42
+ onBlur?.({ target: { value: val } });
43
+ };
44
+ const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
40
45
  const dialogState = useDatePickerState({
41
46
  ...rest,
42
47
  defaultValue: value || rest.defaultValue,
@@ -56,6 +61,7 @@ var DateTimePickerBase = (props) => {
56
61
  onChange?.(val);
57
62
  dialogState.setValue(val);
58
63
  calendarState.setFocusedDate(val || today(getLocalTimeZone()));
64
+ debouncedBlur(val);
59
65
  },
60
66
  shouldCloseOnSelect: false,
61
67
  granularity: "minute",
@@ -91,8 +97,10 @@ var DateTimePickerBase = (props) => {
91
97
  labelProps
92
98
  };
93
99
  const onApply = () => {
94
- state.setValue(dialogState.value);
100
+ const newValue = dialogState.value;
101
+ state.setValue(newValue);
95
102
  state.toggle();
103
+ handleBlur(newValue);
96
104
  };
97
105
  const onTodayPress = () => {
98
106
  dialogState.setValue(toCalendarDateTime(now(getLocalTimeZone())));
@@ -1,10 +1,10 @@
1
- import { Ref } from 'react';
1
+ import { Ref, FocusEvent } from 'react';
2
2
  import { AriaTimeFieldProps, TimeValue } from 'react-aria';
3
3
  import { FieldValues } from 'react-hook-form';
4
4
  import { FormFieldProps } from '../../FormField/FormField';
5
5
  import { ControlProps } from '../../shared/form.types';
6
6
  import { InputVariantProps } from '../../shared/input.cva';
7
- interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<AriaTimeFieldProps<TimeValue>, "label"> {
7
+ interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<AriaTimeFieldProps<TimeValue>, "label" | "onBlur"> {
8
8
  ref?: Ref<HTMLDivElement>;
9
9
  disableDropdown?: boolean;
10
10
  date?: string | null;
@@ -13,6 +13,7 @@ interface TimePickerBaseProps extends FormFieldProps, InputVariantProps, Omit<Ar
13
13
  disableManualEntry?: boolean;
14
14
  placeholder?: string;
15
15
  inputClassName?: string;
16
+ onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
16
17
  }
17
18
  export interface TimePickerProps extends Omit<TimePickerBaseProps, "value" | "onChange"> {
18
19
  value?: string | null;
@@ -4,6 +4,7 @@ import { DateTimeDialog } from "../shared/DateTimeDialog.js";
4
4
  import { DateTimeDialogFooter } from "../shared/DateTimeDialogFooter.js";
5
5
  import { FormField } from "../../FormField/FormField.js";
6
6
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
7
+ import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
7
8
  import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
8
9
  import { TimePickerInput } from "../shared/TimePickerInput.js";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -18,7 +19,7 @@ import { useTimeFieldState } from "react-stately";
18
19
  //#region src/components/inputs/DateTime/TimePicker/TimePicker.tsx
19
20
  var TimePickerBase = (props) => {
20
21
  const ui = UIConfig.useConfig();
21
- const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, placeholder, className, inputClassName, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
22
+ const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, onBlur, value, disableDropdown, placeholder, className, inputClassName, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
22
23
  const formFieldProps = {
23
24
  error,
24
25
  label,
@@ -40,11 +41,18 @@ var TimePickerBase = (props) => {
40
41
  defaultValue: value || rest.defaultValue,
41
42
  locale
42
43
  });
44
+ const handleBlur = (val) => {
45
+ onBlur?.({ target: { value: val } });
46
+ };
47
+ const { callback: debouncedBlur } = useDebounceCallback(handleBlur, { delay: 500 });
43
48
  const state = useTimeFieldState({
44
49
  ...rest,
45
50
  isDisabled,
46
51
  value,
47
- onChange,
52
+ onChange: (val) => {
53
+ onChange?.(val);
54
+ debouncedBlur(val);
55
+ },
48
56
  locale
49
57
  });
50
58
  useEffect(() => {
@@ -72,8 +80,10 @@ var TimePickerBase = (props) => {
72
80
  labelProps
73
81
  };
74
82
  const onApply = () => {
75
- state.setValue(dialogState.value);
83
+ const newValue = dialogState.value;
84
+ state.setValue(newValue);
76
85
  setIsOpen(false);
86
+ handleBlur(newValue);
77
87
  };
78
88
  const onOpenChange = (open) => {
79
89
  setIsOpen(open);
@@ -41,6 +41,7 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
41
41
  if (endFieldProps) endFieldProps.onChange?.(null);
42
42
  setCanClear(false);
43
43
  fieldProps.onBlur?.(null);
44
+ endFieldProps?.onBlur?.(null);
44
45
  },
45
46
  getContainer: () => containerRef.current
46
47
  }));
@@ -51,7 +52,10 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
51
52
  dateFieldRef.current?.clearField();
52
53
  fieldProps.onChange?.(null);
53
54
  endDateFieldRef.current?.clearField();
55
+ endFieldProps?.onChange?.(null);
54
56
  setCanClear(false);
57
+ fieldProps.onBlur?.(null);
58
+ endFieldProps?.onBlur?.(null);
55
59
  };
56
60
  const onToday = () => {
57
61
  if (isDateTime) {
@@ -62,6 +66,8 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
62
66
  fieldProps.onChange?.(today(getLocalTimeZone()));
63
67
  if (endFieldProps) endFieldProps.onChange?.(today(getLocalTimeZone()));
64
68
  }
69
+ fieldProps.onBlur?.(null);
70
+ endFieldProps?.onBlur?.(null);
65
71
  };
66
72
  const hidePlaceholder = as === "floating" && !fieldProps.value && !isFocused;
67
73
  return /* @__PURE__ */ jsxs("div", {
@@ -74,7 +74,10 @@ var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequ
74
74
  as
75
75
  }), "flex items-center gap-input-gap-trailing-elements py-0! pl-0!"),
76
76
  children: [isClearable && /* @__PURE__ */ jsx(InputClear, {
77
- onClear: () => state.setValue(null),
77
+ onClear: () => {
78
+ state.setValue(null);
79
+ fieldProps.onBlur?.(null);
80
+ },
78
81
  show: canClear
79
82
  }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(InlineIconButton, {
80
83
  label: "",
@@ -75,6 +75,8 @@ var TextInputBase = (props) => {
75
75
  labelProps,
76
76
  className: clsx("group w-full", as === "inline" && "h-full", className),
77
77
  tabIndex: as === "inline" ? -1 : void 0,
78
+ "data-is-empty": value === "" || value === null || value === void 0 || void 0,
79
+ "data-is-required": isRequired || void 0,
78
80
  children: /* @__PURE__ */ jsx("div", {
79
81
  className: clsx("relative flex cursor-text has-disabled:cursor-default", inputBaseCva({
80
82
  variant,
@@ -11,23 +11,21 @@ declare const componentRegistry: {
11
11
  readonly passwordInput: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/PasswordInput/PasswordInput').ControlledPasswordInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
12
12
  readonly textArea: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../Input/TextArea/TextArea').ControlledTextAreaProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
13
13
  readonly select: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key, TInitialSelectItem = import('../Selection/shared/select.types').DefaultInitialSelectItem<TKey>>(props: import('../Selection/Select/Select').ControlledSelectProps<TFieldValues, TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
14
- readonly autocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key, TInitialSelectItem = import('../Selection/shared/select.types').DefaultInitialSelectItem<TKey>>(props: import('../Selection/Autocomplete/Autocomplete').ControlledAutocompleteProps<TFieldValues, TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
15
- readonly queryAutocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TSelectItem extends import('../Selection/shared/select.types').SelectItem<any>, TQueryFn extends (...args: any) => import('@tanstack/react-query').UseQueryResult<TSelectItem[]>>({ query, queryParams, queryOptions, ...props }: import('../../../types/common').OmitDiscriminatedUnion<import('../Selection/Autocomplete/Autocomplete').AutocompleteProps<Exclude<ReturnType<TQueryFn>["data"], undefined>[0] extends {
16
- id: infer InferredKey extends import('react-aria').Key;
17
- } ? InferredKey : never>, "onChange" | "value" | "items" | "selectionMode" | "isLoading" | "showSelectionBar" | "showSelectAllOption" | "initialSelection" | "showSelectionContent" | "onSearchChange"> & (import('../Selection/shared/select.types').GroupedSelectControlProps<TFieldValues, Exclude<ReturnType<TQueryFn>["data"], undefined>[0] extends {
18
- id: infer InferredKey extends import('react-aria').Key;
19
- } ? InferredKey : never> & {
20
- query: Parameters<TQueryFn>[0] extends {
21
- search?: string;
22
- } ? TQueryFn : never;
23
- queryParams?: Omit<Parameters<TQueryFn>[0], "search"> | undefined;
14
+ readonly querySelect: <TFieldValues extends import('react-hook-form').FieldValues, TQueryFn extends import('../Selection/shared/querySelect.utils').QueryFn, TKey extends import('react-aria').Key = import('react-aria').Key>({ query, queryParams, queryOptions, queryMap, ...props }: import('../../../types/common').OmitDiscriminatedUnion<import('../Selection/shared/SelectBase').SelectBaseProps<TKey>, "onChange" | "value" | "items" | "selectionMode" | "isLoading" | "showSelectionBar" | "showSelectAllOption" | "initialSelection" | "showSelectionContent"> & (import('../Selection/shared/select.types').GroupedSelectControlProps<TFieldValues, TKey> & {
15
+ query: TQueryFn;
16
+ queryParams?: Parameters<TQueryFn>[0] | undefined;
24
17
  queryOptions?: Parameters<TQueryFn>[1] | undefined;
18
+ queryMap?: ((data: Exclude<ReturnType<TQueryFn>["data"], undefined>) => import('../Selection/shared/select.types').SelectItem<TKey>[]) | undefined;
19
+ isInitialQueryDisabled?: boolean;
25
20
  })) => import("react/jsx-runtime").JSX.Element;
21
+ readonly autocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key, TInitialSelectItem = import('../Selection/shared/select.types').DefaultInitialSelectItem<TKey>>(props: import('../Selection/Autocomplete/Autocomplete').ControlledAutocompleteProps<TFieldValues, TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
22
+ readonly queryAutocomplete: <TFieldValues extends import('react-hook-form').FieldValues, TSelectItem extends import('../Selection/shared/select.types').SelectItem<any>, TQueryFn extends import('../Selection/Autocomplete/queryAutocomplete.types').QueryFn<TSelectItem>>({ query, queryParams, queryOptions, queryMap, ...props }: import('../Selection/Autocomplete/queryAutocomplete.types').QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
26
23
  readonly segment: <TFieldValues extends import('react-hook-form').FieldValues, TKey extends import('react-aria').Key = import('react-aria').Key>(props: import('../../..').ControlledSegmentProps<TFieldValues, TKey>) => import("react/jsx-runtime").JSX.Element;
27
24
  readonly datePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, minValue, maxValue, ...props }: import('../DateTime/DatePicker/DatePicker').ControlledDatePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
28
25
  readonly dateTimePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, ...props }: import('../DateTime/DateTimePicker/DateTimePicker').ControlledDateTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
29
26
  readonly timePicker: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../DateTime/TimePicker/TimePicker').ControlledTimePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
30
27
  readonly dateRangePicker: <TFieldValues extends import('react-hook-form').FieldValues>({ fullIso, minValue, maxValue, ...props }: import('../DateTime/DateRangePicker/DateRangePicker').ControlledDateRangePickerProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
28
+ readonly textEditor: <TFieldValues extends import('react-hook-form').FieldValues>(props: import('../../../text-editor.js').ControlledTextEditorProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
31
29
  readonly unknown: null;
32
30
  };
33
31
  export type InputComponentRegistry = typeof componentRegistry;
@@ -13,6 +13,8 @@ import { QueryAutocomplete } from "../Selection/Autocomplete/QueryAutocomplete.j
13
13
  import { Slider } from "../Slider/Slider.js";
14
14
  import { Toggle } from "../Toggle/Toggle.js";
15
15
  import { Segment } from "../../segment/Segment.js";
16
+ import { QuerySelect } from "../Selection/Select/QuerySelect.js";
17
+ import { TextEditor } from "../TextEditor/TextEditor.js";
16
18
  import { jsx } from "react/jsx-runtime";
17
19
  //#region src/components/inputs/Inputs/InputItem.tsx
18
20
  var componentRegistry = {
@@ -24,6 +26,7 @@ var componentRegistry = {
24
26
  passwordInput: PasswordInput,
25
27
  textArea: TextArea,
26
28
  select: Select,
29
+ querySelect: QuerySelect,
27
30
  autocomplete: Autocomplete,
28
31
  queryAutocomplete: QueryAutocomplete,
29
32
  segment: Segment,
@@ -31,6 +34,7 @@ var componentRegistry = {
31
34
  dateTimePicker: DateTimePicker,
32
35
  timePicker: TimePicker,
33
36
  dateRangePicker: DateRangePicker,
37
+ textEditor: TextEditor,
34
38
  unknown: null
35
39
  };
36
40
  function InputItem({ form, inputDef }) {
@@ -1,19 +1,4 @@
1
- import { UseQueryResult } from '@tanstack/react-query';
2
- import { Key } from 'react-aria-components';
3
1
  import { FieldValues } from 'react-hook-form';
4
- import { AutocompleteProps } from './Autocomplete';
5
- import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
6
- import { OmitDiscriminatedUnion } from '../../../../types/common';
7
- type QueryFn<TSelectItem extends SelectItem = SelectItem> = (...args: any) => UseQueryResult<Array<TSelectItem>>;
8
- type TKey<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>[0] extends {
9
- id: infer InferredKey extends Key;
10
- } ? InferredKey : never;
11
- type QueryAutocompleteProps<TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>> = OmitDiscriminatedUnion<AutocompleteProps<TKey<TQueryFn>>, "items" | "onSearchChange" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey<TQueryFn>> & {
12
- query: Parameters<TQueryFn>[0] extends {
13
- search?: string;
14
- } ? TQueryFn : never;
15
- queryParams?: Omit<Parameters<TQueryFn>[0], "search">;
16
- queryOptions?: Parameters<TQueryFn>[1];
17
- };
18
- export declare const QueryAutocomplete: <TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>>({ query, queryParams, queryOptions, ...props }: QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
19
- export {};
2
+ import { QueryAutocompleteProps, QueryFn } from './queryAutocomplete.types';
3
+ import { SelectItem } from '../shared/select.types';
4
+ export declare const QueryAutocomplete: <TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>>({ query, queryParams, queryOptions, queryMap, ...props }: QueryAutocompleteProps<TFieldValues, TSelectItem, TQueryFn>) => import("react/jsx-runtime").JSX.Element;
@@ -1,19 +1,35 @@
1
+ import { UIConfig } from "../../../../config/uiConfig.context.js";
1
2
  import { Autocomplete } from "./Autocomplete.js";
3
+ import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
2
4
  import { jsx } from "react/jsx-runtime";
3
5
  import { useState } from "react";
4
6
  //#region src/components/inputs/Selection/Autocomplete/QueryAutocomplete.tsx
5
- var QueryAutocomplete = ({ query, queryParams, queryOptions, ...props }) => {
7
+ var QueryAutocomplete = ({ query, queryParams, queryOptions, queryMap, ...props }) => {
8
+ const ui = UIConfig.useConfig();
6
9
  const [search, setSearch] = useState("");
7
- const { data: items, isLoading } = query({
10
+ const mapItems = (data) => {
11
+ const extractedData = Array.isArray(data) ? data : data.pages.flatMap((page) => page.items ?? []);
12
+ return queryMap?.(extractedData) ?? extractedData;
13
+ };
14
+ const { items, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
15
+ query,
16
+ queryParams,
17
+ queryOptions,
18
+ mapItems: (data) => mapItems(data),
8
19
  search,
9
- ...queryParams
10
- }, queryOptions);
20
+ initialQueryState: props.isInitialQueryDisabled ?? ui.queryAutocomplete?.isInitialQueryDisabled
21
+ });
22
+ const { isInitialQueryDisabled: _, ...restProps } = props;
11
23
  return /* @__PURE__ */ jsx(Autocomplete, {
12
- ...props,
13
- items: items ?? [],
24
+ ...restProps,
25
+ items,
14
26
  onSearchChange: setSearch,
15
27
  isClientSearchDisabled: true,
16
- isLoading
28
+ isLoading,
29
+ onMouseEnter: handleEnableQuery,
30
+ onFocusCapture: handleEnableQuery,
31
+ hasLoadMore: hasNextPage,
32
+ onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0
17
33
  });
18
34
  };
19
35
  //#endregion
@@ -0,0 +1,30 @@
1
+ import { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
2
+ import { Key } from 'react-aria-components';
3
+ import { FieldValues } from 'react-hook-form';
4
+ import { AutocompleteProps } from './Autocomplete';
5
+ import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
6
+ import { OmitDiscriminatedUnion } from '../../../../types/common';
7
+ export interface QueryAutocompleteInfinitePage<TSelectItem extends SelectItem = SelectItem> {
8
+ items: Array<TSelectItem>;
9
+ totalItems?: number;
10
+ }
11
+ export type QueryResult<TSelectItem extends SelectItem = SelectItem> = UseQueryResult<Array<TSelectItem>> | UseInfiniteQueryResult<QueryAutocompleteInfinitePage<TSelectItem>>;
12
+ export type QueryFn<TSelectItem extends SelectItem = SelectItem> = (...args: any[]) => QueryResult<TSelectItem>;
13
+ export type QueryAutocompleteExtractedData<TSelectItem extends SelectItem = SelectItem> = Array<TSelectItem>;
14
+ export type QueryAutocompleteProps<TFieldValues extends FieldValues, TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>> = OmitDiscriminatedUnion<AutocompleteProps<TSelectItem["id"]>, "items" | "onSearchChange" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TSelectItem["id"]> & {
15
+ query: Parameters<TQueryFn>[0] extends {
16
+ search?: string;
17
+ } ? TQueryFn : never;
18
+ queryParams?: Omit<Parameters<TQueryFn>[0], "search">;
19
+ queryOptions?: Parameters<TQueryFn>[1];
20
+ queryMap?: (data: QueryAutocompleteExtractedData<TSelectItem>) => SelectItem<TSelectItem["id"]>[];
21
+ isInitialQueryDisabled?: boolean;
22
+ };
23
+ export interface UseQueryAutocompleteOptions<TSelectItem extends SelectItem<any>, TQueryFn extends QueryFn<TSelectItem>, TKey extends Key = QueryAutocompleteExtractedData<TSelectItem>[number]["id"]> {
24
+ query: TQueryFn;
25
+ queryParams?: Parameters<TQueryFn>[0];
26
+ queryOptions?: Parameters<TQueryFn>[1];
27
+ queryMap?: (data: QueryAutocompleteExtractedData<TSelectItem>) => SelectItem<TKey>[];
28
+ initialQueryState?: boolean;
29
+ search: string;
30
+ }
@@ -0,0 +1,15 @@
1
+ import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
2
+ import { SelectBaseProps } from '../shared/SelectBase';
3
+ import { QueryDataType, QueryFn } from '../shared/querySelect.utils';
4
+ import { OmitDiscriminatedUnion } from '../../../../types/common';
5
+ import { Key } from 'react-aria-components';
6
+ import { FieldValues } from 'react-hook-form';
7
+ type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key> = OmitDiscriminatedUnion<SelectBaseProps<TKey>, "items" | "isLoading" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey> & {
8
+ query: TQueryFn;
9
+ queryParams?: Parameters<TQueryFn>[0];
10
+ queryOptions?: Parameters<TQueryFn>[1];
11
+ queryMap?: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[];
12
+ isInitialQueryDisabled?: boolean;
13
+ };
14
+ export declare const QuerySelect: <TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key>({ query, queryParams, queryOptions, queryMap, ...props }: QuerySelectProps<TFieldValues, TQueryFn, TKey>) => import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,56 @@
1
+ import { UIConfig } from "../../../../config/uiConfig.context.js";
2
+ import { SelectBase } from "../shared/SelectBase.js";
3
+ import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
4
+ import { getQueryItems } from "../shared/querySelect.utils.js";
5
+ import { jsx } from "react/jsx-runtime";
6
+ import { mergeRefs } from "@react-aria/utils";
7
+ import { Controller } from "react-hook-form";
8
+ //#region src/components/inputs/Selection/Select/QuerySelect.tsx
9
+ var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) => {
10
+ const ui = UIConfig.useConfig();
11
+ const { items, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
12
+ query,
13
+ queryParams,
14
+ queryOptions,
15
+ mapItems: (data) => getQueryItems(data, queryMap),
16
+ initialQueryState: props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled
17
+ });
18
+ if ("formControl" in props && props.formControl) {
19
+ const { formControl, ref, isInitialQueryDisabled: _, ...innerProps } = props;
20
+ return /* @__PURE__ */ jsx(Controller, {
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
+ hasLoadMore: hasNextPage,
29
+ onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0,
30
+ value: field.value,
31
+ onChange: (value) => {
32
+ field.onChange(value);
33
+ field.onBlur?.();
34
+ },
35
+ onBlur: field.onBlur,
36
+ isDirty,
37
+ isDisabled: field.disabled || props.isDisabled,
38
+ error: props.error ?? error?.message,
39
+ onMouseEnter: handleEnableQuery,
40
+ onFocusCapture: handleEnableQuery
41
+ })
42
+ });
43
+ }
44
+ const { isInitialQueryDisabled: _, ...restProps } = props;
45
+ return /* @__PURE__ */ jsx(SelectBase, {
46
+ ...restProps,
47
+ items,
48
+ isLoading,
49
+ hasLoadMore: hasNextPage,
50
+ onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0,
51
+ onMouseEnter: handleEnableQuery,
52
+ onFocusCapture: handleEnableQuery
53
+ });
54
+ };
55
+ //#endregion
56
+ export { QuerySelect };
@@ -1,4 +1,4 @@
1
- import { ReactElement, Ref } from 'react';
1
+ import { FocusEventHandler, MouseEventHandler, ReactElement, Ref } from 'react';
2
2
  import { AriaButtonProps } from 'react-aria';
3
3
  import { Key } from 'react-aria-components';
4
4
  import { FormFieldProps } from '../../FormField/FormField';
@@ -25,5 +25,7 @@ export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = Default
25
25
  onInputChange?: (value: string) => void;
26
26
  onSearchChange?: (value: string) => void;
27
27
  mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
28
+ onMouseEnter?: MouseEventHandler<HTMLDivElement>;
29
+ onFocusCapture?: FocusEventHandler<HTMLDivElement>;
28
30
  };
29
31
  export declare const SelectBase: <TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>>(dProps: SelectBaseProps<TKey, TInitialSelectItem>) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { Key } from 'react-aria-components';
2
2
  import { SelectBaseProps } from './SelectBase';
3
3
  type SelectDesktopProps<TKey extends Key = Key> = SelectBaseProps<TKey>;
4
- export declare const SelectDesktop: <TKey extends Key = Key>({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }: SelectDesktopProps<TKey>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const SelectDesktop: <TKey extends Key = Key>({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectDesktopProps<TKey>) => import("react/jsx-runtime").JSX.Element;
5
5
  export {};
@@ -13,7 +13,7 @@ import { ComboBox, DialogTrigger, Popover } from "react-aria-components";
13
13
  import { useLabel, usePreventScroll } from "react-aria";
14
14
  import { mergeRefs } from "@react-aria/utils";
15
15
  //#region src/components/inputs/Selection/shared/SelectDesktop.tsx
16
- var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }) => {
16
+ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
17
17
  const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, isSearchable, isClearable, isLoading, as, size, collapseAfter, selectedTagsType } = props;
18
18
  const popoverCva = UIStyle.useCva("popover.cva", popover);
19
19
  const formFieldProps = {
@@ -119,6 +119,8 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
119
119
  children: /* @__PURE__ */ jsx("div", {
120
120
  ...fieldProps,
121
121
  ref: mergeRefs(ref, triggerRef),
122
+ onMouseEnter,
123
+ onFocusCapture,
122
124
  children: customTrigger
123
125
  })
124
126
  }) : /* @__PURE__ */ jsx(SelectInput, {
@@ -4,12 +4,12 @@ import { FormFieldHeaderProps } from '../../FormField/FormFieldHeader';
4
4
  import { SelectBaseProps } from './SelectBase';
5
5
  import { SelectItem } from './select.types';
6
6
  import { InputVariantProps } from '../../shared/input.cva';
7
- interface SelectInputProps extends InputVariantProps, Pick<SelectBaseProps, "ref" | "placeholder" | "isDisabled" | "hideDropdownIcon" | "isSearchable" | "isClearable" | "onBlur" | "showSelectionContent" | "inputClassName" | "selectedTagsType" | "collapseAfter" | "isRequired" | "isDirty" | "fireBlurOnChange"> {
7
+ interface SelectInputProps extends InputVariantProps, Pick<SelectBaseProps, "ref" | "placeholder" | "isDisabled" | "hideDropdownIcon" | "isSearchable" | "isClearable" | "onBlur" | "showSelectionContent" | "inputClassName" | "selectedTagsType" | "collapseAfter" | "isRequired" | "isDirty" | "fireBlurOnChange" | "onMouseEnter" | "onFocusCapture"> {
8
8
  isInvalid?: boolean;
9
9
  className?: string;
10
10
  fieldProps?: AriaFieldProps;
11
11
  headerProps?: FormFieldHeaderProps;
12
12
  onCloseComboBox?: (state: ComboBoxState<SelectItem> | null) => void;
13
13
  }
14
- export declare const SelectInput: ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, ...props }: SelectInputProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const SelectInput: ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, onMouseEnter, onFocusCapture, ...props }: SelectInputProps) => import("react/jsx-runtime").JSX.Element;
15
15
  export {};
@@ -14,7 +14,7 @@ import { Button, ComboBoxStateContext, Input } from "react-aria-components";
14
14
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
15
15
  import { useTranslation } from "react-i18next";
16
16
  //#region src/components/inputs/Selection/shared/SelectInput.tsx
17
- var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, ...props }) => {
17
+ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, onMouseEnter, onFocusCapture, ...props }) => {
18
18
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
19
19
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
20
20
  const { t } = useTranslation("ui");
@@ -83,6 +83,8 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
83
83
  "data-is-required": isRequired || void 0,
84
84
  "data-is-dirty": isDirty || void 0,
85
85
  "data-select-input": "",
86
+ onMouseEnter,
87
+ onFocusCapture,
86
88
  ...hoverProps,
87
89
  ...focusWithinProps,
88
90
  children: [
@@ -1,5 +1,5 @@
1
1
  import { Key } from 'react-aria-components';
2
2
  import { SelectBaseProps } from './SelectBase';
3
3
  type SelectMobileProps<TKey extends Key = Key> = SelectBaseProps<TKey>;
4
- export declare const SelectMobile: <TKey extends Key = Key>({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }: SelectMobileProps<TKey>) => import("react/jsx-runtime").JSX.Element;
4
+ export declare const SelectMobile: <TKey extends Key = Key>({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }: SelectMobileProps<TKey>) => import("react/jsx-runtime").JSX.Element;
5
5
  export {};
@@ -13,7 +13,7 @@ import { useRef } from "react";
13
13
  import { DialogTrigger } from "react-aria-components";
14
14
  import { useLabel } from "react-aria";
15
15
  //#region src/components/inputs/Selection/shared/SelectMobile.tsx
16
- var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }) => {
16
+ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
17
17
  const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, hideSearchIcon, isSearchable, isClearable, as, size, collapseAfter, selectedTagsType } = props;
18
18
  const formFieldProps = {
19
19
  error,
@@ -62,6 +62,8 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
62
62
  children: [customTrigger ? /* @__PURE__ */ jsx("div", {
63
63
  ...fieldProps,
64
64
  ref,
65
+ onMouseEnter,
66
+ onFocusCapture,
65
67
  children: customTrigger
66
68
  }) : /* @__PURE__ */ jsx(SelectInput, {
67
69
  ref,
@@ -0,0 +1,6 @@
1
+ import { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
2
+ import { Key } from 'react-aria-components';
3
+ import { SelectItem } from './select.types';
4
+ export type QueryFn<TData = any> = (...args: any[]) => UseQueryResult<TData> | UseInfiniteQueryResult<TData>;
5
+ export type QueryDataType<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>;
6
+ export declare const getQueryItems: <TQueryFn extends QueryFn, TKey extends Key = Key>(data: QueryDataType<TQueryFn> | undefined, queryMap?: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[]) => SelectItem<TKey>[];
@@ -0,0 +1,13 @@
1
+ //#region src/components/inputs/Selection/shared/querySelect.utils.ts
2
+ var getQueryItems = (data, queryMap) => {
3
+ if (!data) return [];
4
+ if (queryMap) return queryMap(data);
5
+ if (Array.isArray(data)) return data;
6
+ if (typeof data === "object" && data !== null) {
7
+ if ("items" in data && Array.isArray(data.items)) return data.items;
8
+ if ("pages" in data && Array.isArray(data.pages)) return data.pages.flatMap((page) => page && typeof page === "object" && "items" in page && Array.isArray(page.items) ? page.items : []);
9
+ }
10
+ return [];
11
+ };
12
+ //#endregion
13
+ export { getQueryItems };
@@ -1,5 +1,5 @@
1
- import { useSelectItems } from "./useSelectItems.js";
2
1
  import { useDebounceCallback } from "../../../../hooks/useDebounceCallback.js";
2
+ import { useSelectItems } from "./useSelectItems.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
5
5
  //#region src/components/inputs/Selection/shared/select.context.tsx
@@ -25,6 +25,12 @@ export declare namespace UIConfig {
25
25
  radioGroup: Pick<RadioGroupProps, "variant" | "hideLabel">;
26
26
  checkbox: Pick<CheckboxProps, "variant">;
27
27
  select: Pick<SelectBaseProps, "selectionMode" | "isSearchable" | "collapseAfter" | "selectedTagsType" | "hideSearchIcon" | "fireBlurOnChange">;
28
+ queryAutocomplete: {
29
+ isInitialQueryDisabled?: boolean;
30
+ };
31
+ querySelect: {
32
+ isInitialQueryDisabled?: boolean;
33
+ };
28
34
  toggle: Pick<ToggleProps, "variant">;
29
35
  slider: Pick<SliderProps, "minValue" | "maxValue">;
30
36
  dateInput: Pick<DatePickerProps, "todayIcon" | "shouldForceLeadingZeros" | "disableManualEntry">;
@@ -34,6 +34,8 @@ var UIConfig;
34
34
  hideSearchIcon: false,
35
35
  fireBlurOnChange: false
36
36
  },
37
+ queryAutocomplete: { isInitialQueryDisabled: false },
38
+ querySelect: { isInitialQueryDisabled: false },
37
39
  toggle: { variant: "default" },
38
40
  slider: {
39
41
  minValue: 0,
@@ -21,14 +21,14 @@ export type AllowedComponentType<TZodType extends z.ZodType> = ZodUtils.ZodTypeS
21
21
  datetime: "datePicker" | "dateTimePicker" | "timePicker";
22
22
  dateRange: "dateRangePicker";
23
23
  boolean: "toggle" | "checkbox";
24
- number: "numberInput" | "slider" | "select" | "autocomplete" | "queryAutocomplete" | "segment";
25
- enum: "select" | "autocomplete" | "segment";
26
- string: "textInput" | "passwordInput" | "textArea" | "select" | "autocomplete" | "queryAutocomplete" | "segment";
24
+ number: "numberInput" | "slider" | "select" | "querySelect" | "autocomplete" | "queryAutocomplete" | "segment";
25
+ enum: "select" | "querySelect" | "autocomplete" | "segment";
26
+ string: "textInput" | "passwordInput" | "textArea" | "select" | "querySelect" | "autocomplete" | "queryAutocomplete" | "segment";
27
27
  email: "textInput";
28
- array: "select" | "autocomplete" | "queryAutocomplete" | "segment";
28
+ array: "select" | "querySelect" | "autocomplete" | "queryAutocomplete" | "segment";
29
29
  object: InputComponentType;
30
30
  unknown: InputComponentType;
31
- uuid: "select" | "autocomplete" | "queryAutocomplete" | "segment";
31
+ uuid: "select" | "querySelect" | "autocomplete" | "queryAutocomplete" | "segment";
32
32
  }>;
33
33
  interface DynamicInputDefBase<TProps> {
34
34
  label?: string;
@@ -0,0 +1,25 @@
1
+ import { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
2
+ import { Key } from 'react-aria-components';
3
+ import { SelectItem } from '../components/inputs/Selection/shared/select.types';
4
+ type QueryResult<TData = any> = UseQueryResult<TData> | UseInfiniteQueryResult<TData>;
5
+ type QueryFn<TData = any> = (...args: any[]) => QueryResult<TData>;
6
+ type QueryDataType<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>;
7
+ interface UseQueryAutocompleteOptions<TQueryFn extends QueryFn, TKey extends Key = Key> {
8
+ query: TQueryFn;
9
+ queryParams?: Parameters<TQueryFn>[0];
10
+ queryOptions?: Parameters<TQueryFn>[1];
11
+ mapItems: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[];
12
+ initialQueryState?: boolean;
13
+ search?: string;
14
+ }
15
+ export declare const useQueryAutocomplete: <TQueryFn extends QueryFn, TKey extends Key = Key>({ query, queryParams, queryOptions, mapItems, initialQueryState, search, }: UseQueryAutocompleteOptions<TQueryFn, TKey>) => {
16
+ data: any;
17
+ isLoading: boolean;
18
+ isQueryEnabled: boolean;
19
+ handleEnableQuery: () => void;
20
+ items: SelectItem<TKey>[];
21
+ hasNextPage: boolean;
22
+ fetchNextPage: (() => Promise<unknown>) | ((options?: import('@tanstack/react-query').FetchNextPageOptions) => Promise<import('@tanstack/react-query').InfiniteQueryObserverResult<any, Error>>) | undefined;
23
+ isFetchingNextPage: boolean;
24
+ };
25
+ export {};
@@ -0,0 +1,41 @@
1
+ import { useMemo, useState } from "react";
2
+ //#region src/hooks/useQueryAutocomplete.ts
3
+ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initialQueryState, search }) => {
4
+ const [isQueryEnabled, setIsQueryEnabled] = useState(!initialQueryState);
5
+ const queryResult = query(search === void 0 ? queryParams : {
6
+ search,
7
+ ...queryParams
8
+ }, {
9
+ ...queryOptions,
10
+ enabled: isQueryEnabled && (queryOptions?.enabled ?? true)
11
+ });
12
+ const data = queryResult.data;
13
+ const isLoading = queryResult.isLoading;
14
+ const isInfiniteQueryResult = (result) => {
15
+ return "hasNextPage" in result && "fetchNextPage" in result;
16
+ };
17
+ const isInfiniteQuery = isInfiniteQueryResult(queryResult);
18
+ const handleEnableQuery = () => {
19
+ setIsQueryEnabled(true);
20
+ };
21
+ const infiniteQueryResult = isInfiniteQuery ? queryResult : void 0;
22
+ const hasNextPage = infiniteQueryResult?.hasNextPage ?? false;
23
+ const fetchNextPage = infiniteQueryResult?.fetchNextPage;
24
+ const isFetchingNextPage = infiniteQueryResult?.isFetchingNextPage ?? false;
25
+ const items = useMemo(() => {
26
+ if (!data) return [];
27
+ return mapItems(data);
28
+ }, [data, mapItems]);
29
+ return {
30
+ data,
31
+ isLoading: isLoading || isFetchingNextPage,
32
+ isQueryEnabled,
33
+ handleEnableQuery,
34
+ items,
35
+ hasNextPage,
36
+ fetchNextPage,
37
+ isFetchingNextPage
38
+ };
39
+ };
40
+ //#endregion
41
+ export { useQueryAutocomplete };
package/dist/index.js CHANGED
@@ -68,10 +68,10 @@ import { Checkbox } from "./components/inputs/Checkbox/Checkbox.js";
68
68
  import { useLongPressRepeat } from "./hooks/useLongPressRepeat.js";
69
69
  import { useScrollableListBox } from "./hooks/useScrollableListBox.js";
70
70
  import { FormField } from "./components/inputs/FormField/FormField.js";
71
+ import { useDebounceCallback } from "./hooks/useDebounceCallback.js";
71
72
  import { DateTimeUtils } from "./utils/date-time.utils.js";
72
73
  import { DatePicker } from "./components/inputs/DateTime/DatePicker/DatePicker.js";
73
74
  import { Tag } from "./components/text/Tag/Tag.js";
74
- import { useDebounceCallback } from "./hooks/useDebounceCallback.js";
75
75
  import { useIntersectionObserver } from "./hooks/useIntersectionObserver.js";
76
76
  import { TextInput } from "./components/inputs/Input/TextInput/TextInput.js";
77
77
  import { Select } from "./components/inputs/Selection/Select/Select.js";
@@ -92,6 +92,7 @@ import { QueryAutocomplete } from "./components/inputs/Selection/Autocomplete/Qu
92
92
  import { Slider } from "./components/inputs/Slider/Slider.js";
93
93
  import { Toggle } from "./components/inputs/Toggle/Toggle.js";
94
94
  import { Segment } from "./components/segment/Segment.js";
95
+ import { ResponsivePopover } from "./components/overlays/ResponsivePopover/ResponsivePopover.js";
95
96
  import { StringUtils } from "./utils/string.utils.js";
96
97
  import { dynamicInputs } from "./helpers/dynamicInputs.js";
97
98
  import { Form } from "./components/inputs/Inputs/Form.js";
@@ -102,7 +103,6 @@ import { Stepper } from "./components/navigation/Stepper/Stepper.js";
102
103
  import { Modal } from "./components/overlays/Modal/Modal.js";
103
104
  import { ActionModal } from "./components/overlays/ActionModal/ActionModal.js";
104
105
  import { Drawer } from "./components/overlays/Drawer/Drawer.js";
105
- import { ResponsivePopover } from "./components/overlays/ResponsivePopover/ResponsivePopover.js";
106
106
  import { TooltipEllipsis } from "./components/overlays/Tooltip/TooltipEllipsis.js";
107
107
  import { PaginationList } from "./components/shared/pagination/PaginationList.js";
108
108
  import { Pagination } from "./components/shared/pagination/Pagination.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.1",
3
+ "version": "2.2.9-rc.3",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",