@povio/ui 2.2.9-rc.11 → 2.2.9-rc.13

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.
@@ -17,6 +17,7 @@ interface DateTimePickerBaseProps extends FormFieldProps, InputVariantProps, Omi
17
17
  isDirty?: boolean;
18
18
  disableManualEntry?: boolean;
19
19
  autoFixYear?: boolean;
20
+ setDateValueOnDateSelection?: boolean;
20
21
  placeholder?: string;
21
22
  inputClassName?: string;
22
23
  onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
@@ -17,7 +17,7 @@ import { useCalendarState, useDatePickerState } from "react-stately";
17
17
  //#region src/components/inputs/DateTime/DateTimePicker/DateTimePicker.tsx
18
18
  var DateTimePickerBase = (props) => {
19
19
  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, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, ...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, todayIconButtonSize = ui.dateInput.todayIconButtonSize, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, autoFixYear = ui.dateInput.autoFixYear, setDateValueOnDateSelection = ui.dateInput.setDateValueOnDateSelection, ...rest } = props;
21
21
  const formFieldProps = {
22
22
  error,
23
23
  label,
@@ -177,7 +177,8 @@ var DateTimePickerBase = (props) => {
177
177
  calendarProps,
178
178
  includesTime: true,
179
179
  datePickerState: dialogState,
180
- onApply
180
+ onApply,
181
+ setDateValueOnDateSelection
181
182
  })
182
183
  })]
183
184
  })
@@ -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 handleDateChange = () => {
15
- if (includesTime && !datePickerState.value) setToggleState("time");
16
- else onApply();
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
+ 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,7 +17,7 @@ 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 (isSelected && shouldCloseOnSelect) onApply?.();
20
+ if (isSelected && shouldCloseOnSelect) onApply?.(props.date);
21
21
  }, [
22
22
  buttonProps,
23
23
  onDateSelection,
@@ -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,4 @@
1
- import { PropsWithChildren, Ref } from 'react';
1
+ import { FocusEventHandler, MouseEventHandler, PropsWithChildren, Ref } from 'react';
2
2
  import { FormFieldErrorProps } from './FormFieldError';
3
3
  import { FormFieldHeaderProps } from './FormFieldHeader';
4
4
  import { TextInputProps } from '../Input/TextInput/TextInput';
@@ -13,8 +13,8 @@ interface FormFieldComponentProps extends PropsWithChildren<FormFieldProps> {
13
13
  labelProps?: FormFieldHeaderProps["labelProps"];
14
14
  as?: TextInputProps["as"];
15
15
  tabIndex?: number;
16
- onMouseEnter?: () => void;
17
- onFocusCapture?: () => void;
16
+ onMouseEnter?: MouseEventHandler<HTMLDivElement>;
17
+ onFocusCapture?: FocusEventHandler<HTMLDivElement>;
18
18
  }
19
19
  export declare const FormField: ({ ref, as, label, tooltipText, helperText, isRequired, rightContent, isDisabled, error, hideLabel, headerClassName, errorClassName, children, className, labelProps, isHeaderHidden, tabIndex, onMouseEnter, onFocusCapture, }: FormFieldComponentProps) => import("react/jsx-runtime").JSX.Element;
20
20
  export {};
@@ -84,6 +84,8 @@ var TextInputBase = (props) => {
84
84
  ...rest
85
85
  }), inputClassName),
86
86
  onClick: () => inputRef.current?.focus(),
87
+ "data-is-empty": value === "" || value === null || value === void 0 || void 0,
88
+ "data-is-required": isRequired || void 0,
87
89
  children: /* @__PURE__ */ jsx(InputContent, {
88
90
  ...inputContentProps,
89
91
  headerProps,
@@ -5,7 +5,7 @@ import { Controller } from "react-hook-form";
5
5
  //#region src/components/inputs/Selection/Autocomplete/Autocomplete.tsx
6
6
  function Autocomplete(props) {
7
7
  if ("formControl" in props && props.formControl) {
8
- const { formControl, ref, ...innerProps } = props;
8
+ const { ignoreInputValueFiltering = true, formControl, ref, ...innerProps } = props;
9
9
  return /* @__PURE__ */ jsx(Controller, {
10
10
  control: formControl.control,
11
11
  name: formControl.name,
@@ -18,7 +18,8 @@ function Autocomplete(props) {
18
18
  isDirty,
19
19
  isDisabled: field.disabled || props.isDisabled,
20
20
  error: props.error ?? error?.message,
21
- isSearchable: true
21
+ isSearchable: true,
22
+ ignoreInputValueFiltering
22
23
  })
23
24
  });
24
25
  }
@@ -30,7 +30,7 @@ var QueryAutocomplete = ({ query, queryParams, queryOptions, queryMap, ...props
30
30
  onMouseEnter: handleEnableQuery,
31
31
  onFocusCapture: handleEnableQuery,
32
32
  hasLoadMore: hasNextPage,
33
- onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0
33
+ onLoadMore: fetchNextPage
34
34
  });
35
35
  };
36
36
  //#endregion
@@ -27,7 +27,7 @@ var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) =>
27
27
  isLoading,
28
28
  totalItems,
29
29
  hasLoadMore: hasNextPage,
30
- onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0,
30
+ onLoadMore: fetchNextPage,
31
31
  value: field.value,
32
32
  onChange: (value) => {
33
33
  field.onChange(value);
@@ -115,14 +115,14 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
115
115
  className: clsx("w-full", containerClassName)
116
116
  },
117
117
  as,
118
+ onMouseEnter,
119
+ onFocusCapture,
118
120
  ref: wrapperRef,
119
121
  children: [customTrigger ? /* @__PURE__ */ jsx(DialogTrigger, {
120
122
  ...dialogTriggerProps,
121
123
  children: /* @__PURE__ */ jsx("div", {
122
124
  ...fieldProps,
123
125
  ref: mergeRefs(ref, triggerRef),
124
- onMouseEnter,
125
- onFocusCapture,
126
126
  children: customTrigger
127
127
  })
128
128
  }) : /* @__PURE__ */ jsx(SelectInput, {
@@ -6,4 +6,4 @@ export interface SelectListBoxProps extends Pick<SelectBaseProps, "label" | "new
6
6
  isScrollable?: boolean;
7
7
  onClose?: () => void;
8
8
  }
9
- export declare const SelectListBox: ({ label, selectionMode, isSearchable, isScrollable, virtualizerOptions, totalItems, hasLoadMore, newItemRender, onLoadMore, className, onClose, ...props }: SelectListBoxProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const SelectListBox: ({ label, selectionMode, isSearchable, isScrollable, virtualizerOptions, totalItems, newItemRender, onLoadMore, className, onClose, ...props }: SelectListBoxProps) => import("react/jsx-runtime").JSX.Element;
@@ -7,8 +7,8 @@ import { jsx } from "react/jsx-runtime";
7
7
  import { clsx } from "clsx";
8
8
  import { ListBox, ListLayout, Virtualizer } from "react-aria-components";
9
9
  //#region src/components/inputs/Selection/shared/SelectListBox.tsx
10
- var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true, virtualizerOptions, totalItems, hasLoadMore, newItemRender, onLoadMore, className, onClose, ...props }) => {
11
- const { fieldState, onChange, listItems, selectableListItems, selectedIds, isMultiple, onClear, onSelectAll } = SelectContext.useSelect();
10
+ var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true, virtualizerOptions, totalItems, newItemRender, onLoadMore, className, onClose, ...props }) => {
11
+ const { fieldState, onChange, listItems, selectableListItems, selectedIds, isMultiple, onClear, onSelectAll, hasLoadMore } = SelectContext.useSelect();
12
12
  const onSelectionChange = (value) => {
13
13
  const ids = Array.from(value);
14
14
  if (!isMultiple && ids.length === 0) {
@@ -57,13 +57,13 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
57
57
  as,
58
58
  labelProps,
59
59
  className: clsx("w-full", containerClassName),
60
+ onMouseEnter,
61
+ onFocusCapture,
60
62
  children: /* @__PURE__ */ jsxs(DialogTrigger, {
61
63
  ...dialogTriggerProps,
62
64
  children: [customTrigger ? /* @__PURE__ */ jsx("div", {
63
65
  ...fieldProps,
64
66
  ref,
65
- onMouseEnter,
66
- onFocusCapture,
67
67
  children: customTrigger
68
68
  }) : /* @__PURE__ */ jsx(SelectInput, {
69
69
  ref,
@@ -33,7 +33,9 @@ export declare namespace UIConfig {
33
33
  };
34
34
  toggle: Pick<ToggleProps, "variant">;
35
35
  slider: Pick<SliderProps, "minValue" | "maxValue">;
36
- dateInput: Pick<DatePickerProps, "todayIcon" | "todayIconButtonSize" | "shouldForceLeadingZeros" | "disableManualEntry" | "autoFixYear">;
36
+ dateInput: Pick<DatePickerProps, "todayIcon" | "todayIconButtonSize" | "shouldForceLeadingZeros" | "disableManualEntry" | "autoFixYear"> & {
37
+ setDateValueOnDateSelection?: boolean;
38
+ };
37
39
  actionModal: Pick<ActionModalProps, "titleTypography" | "descriptionTypography">;
38
40
  bottomSheet: Pick<BottomSheetProps, "closeDragThreshold" | "closeVelocityThreshold" | "hideThumb" | "headerTypography">;
39
41
  tableHeaderText: Pick<HeaderTextProps, "variant" | "size">;
@@ -46,7 +46,8 @@ var UIConfig;
46
46
  todayIconButtonSize: "none",
47
47
  shouldForceLeadingZeros: false,
48
48
  disableManualEntry: false,
49
- autoFixYear: false
49
+ autoFixYear: false,
50
+ setDateValueOnDateSelection: false
50
51
  },
51
52
  actionModal: {
52
53
  titleTypography: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.11",
3
+ "version": "2.2.9-rc.13",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",