@povio/ui 2.2.8 → 2.2.9-rc.1

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.
@@ -101,6 +101,7 @@ var TimePickerBase = (props) => {
101
101
  onPress: onOpen,
102
102
  isDisabled,
103
103
  isDirty,
104
+ isRequired,
104
105
  isInvalid: !!error,
105
106
  disableDropdown,
106
107
  variant,
@@ -141,12 +142,13 @@ var TimePicker = (props) => {
141
142
  return /* @__PURE__ */ jsx(Controller, {
142
143
  control: formControl.control,
143
144
  name: formControl.name,
144
- render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx(TimePickerBase, {
145
+ render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(TimePickerBase, {
145
146
  ...innerProps,
146
147
  ref: mergeRefs(ref, field.ref),
147
148
  value: parseTimeValue(field.value),
148
149
  onChange: (value) => field.onChange(formatTimeValue(value)),
149
150
  onBlur: field.onBlur,
151
+ isDirty,
150
152
  isDisabled: field.disabled || props.isDisabled,
151
153
  error: props.error ?? error?.message
152
154
  })
@@ -82,6 +82,7 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
82
82
  "data-has-selection": fieldProps.value !== null || void 0,
83
83
  "data-is-dirty": isDirty || void 0,
84
84
  "data-is-required": isRequired || void 0,
85
+ "data-is-filled": fieldProps.value !== null || void 0,
85
86
  ...groupProps,
86
87
  ...focusWithinProps,
87
88
  ...hoverProps,
@@ -9,6 +9,7 @@ interface DatePickerInputProps extends InputVariantProps {
9
9
  state: TimeFieldState;
10
10
  isDisabled?: boolean;
11
11
  isDirty?: boolean;
12
+ isRequired?: boolean;
12
13
  isInvalid?: boolean;
13
14
  disableDropdown?: boolean;
14
15
  headerProps?: FormFieldHeaderProps;
@@ -18,5 +19,5 @@ interface DatePickerInputProps extends InputVariantProps {
18
19
  className?: string;
19
20
  onPress: () => void;
20
21
  }
21
- export declare const TimePickerInput: ({ ref, as, fieldProps, state, isDisabled, isDirty, isInvalid, disableDropdown, variant, size, isClearable, headerProps, disableManualEntry, placeholder, className, onPress, ...props }: DatePickerInputProps) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const TimePickerInput: ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequired, isInvalid, disableDropdown, variant, size, isClearable, headerProps, disableManualEntry, placeholder, className, onPress, ...props }: DatePickerInputProps) => import("react/jsx-runtime").JSX.Element;
22
23
  export {};
@@ -12,7 +12,7 @@ import { useState } from "react";
12
12
  import { Button } from "react-aria-components";
13
13
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
14
14
  //#region src/components/inputs/DateTime/shared/TimePickerInput.tsx
15
- var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isInvalid, disableDropdown, variant, size, isClearable, headerProps, disableManualEntry, placeholder, className, onPress, ...props }) => {
15
+ var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequired, isInvalid, disableDropdown, variant, size, isClearable, headerProps, disableManualEntry, placeholder, className, onPress, ...props }) => {
16
16
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
17
17
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
18
18
  const { hoverProps, isHovered } = useHover({ isDisabled });
@@ -38,6 +38,8 @@ var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isInva
38
38
  "data-focus-visible": isFocused && isFocusVisible || void 0,
39
39
  "data-has-selection": state.value !== null || void 0,
40
40
  "data-is-dirty": isDirty || void 0,
41
+ "data-is-required": isRequired || void 0,
42
+ "data-is-filled": state.value !== null || void 0,
41
43
  ...fieldProps,
42
44
  ...focusWithinProps,
43
45
  ...hoverProps,
@@ -101,6 +101,7 @@ var NumberInputBase = (props) => {
101
101
  "data-is-dirty": isDirty || void 0,
102
102
  "data-is-required": isRequired || void 0,
103
103
  "data-is-empty": value === null || value === void 0 || void 0,
104
+ "data-is-filled": !("" + value === "" || value === null || value === void 0) || void 0,
104
105
  placeholder: as === "floating" ? "\xA0" : inputProps.placeholder,
105
106
  className: "w-full outline-none",
106
107
  onFocus: (e) => {
@@ -91,6 +91,7 @@ var TextInputBase = (props) => {
91
91
  ...inputProps,
92
92
  ref: mergeRefs(ref, inputRef),
93
93
  "data-is-empty": value === "" || value === null || value === void 0 || void 0,
94
+ "data-is-filled": !(value === "" || value === null || value === void 0) || void 0,
94
95
  "data-is-dirty": isDirty || void 0,
95
96
  "data-is-required": isRequired || void 0,
96
97
  "data-is-disabled": isDisabled || void 0,
@@ -9,12 +9,13 @@ var Autocomplete = (props) => {
9
9
  return /* @__PURE__ */ jsx(Controller, {
10
10
  control: formControl.control,
11
11
  name: formControl.name,
12
- render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx(SelectBase, {
12
+ render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(SelectBase, {
13
13
  ...innerProps,
14
14
  ref: mergeRefs(ref, field.ref),
15
15
  value: field.value,
16
16
  onChange: field.onChange,
17
17
  onBlur: field.onBlur,
18
+ isDirty,
18
19
  isDisabled: field.disabled || props.isDisabled,
19
20
  error: props.error ?? error?.message,
20
21
  isSearchable: true
@@ -9,12 +9,13 @@ var Select = (props) => {
9
9
  return /* @__PURE__ */ jsx(Controller, {
10
10
  control: formControl.control,
11
11
  name: formControl.name,
12
- render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx(SelectBase, {
12
+ render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(SelectBase, {
13
13
  ...innerProps,
14
14
  ref: mergeRefs(ref, field.ref),
15
15
  value: field.value,
16
16
  onChange: field.onChange,
17
17
  onBlur: field.onBlur,
18
+ isDirty,
18
19
  isDisabled: field.disabled || props.isDisabled,
19
20
  error: props.error ?? error?.message
20
21
  })
@@ -7,6 +7,7 @@ import { InputVariantProps } from '../../shared/input.cva';
7
7
  export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = FormFieldProps & GroupedSelectProps<TKey, TInitialSelectItem> & SelectNewItemProps & SelectAsyncProps & SelectVirtualizationProps & InputVariantProps & Pick<AriaButtonProps, "onBlur"> & {
8
8
  ref?: Ref<HTMLDivElement>;
9
9
  className?: string;
10
+ isDirty?: boolean;
10
11
  placeholder?: string;
11
12
  hideDropdownIcon?: boolean;
12
13
  hideSearchIcon?: boolean;
@@ -20,6 +21,7 @@ export type SelectBaseProps<TKey extends Key = Key, TInitialSelectItem = Default
20
21
  customTrigger?: ReactElement;
21
22
  selectedTagsType?: "tags" | "list";
22
23
  collapseAfter?: number;
24
+ fireBlurOnChange?: boolean;
23
25
  onInputChange?: (value: string) => void;
24
26
  onSearchChange?: (value: string) => void;
25
27
  mapInitialToSelectItem?: (item: TInitialSelectItem) => SelectItem<TKey>;
@@ -19,7 +19,8 @@ var SelectBase = (dProps) => {
19
19
  selectedTagsType: dProps.selectedTagsType ?? ui.select.selectedTagsType,
20
20
  ignoreTriggerWidth: dProps.virtualizerOptions || dProps.items.length > 100 ? false : dProps.ignoreTriggerWidth ?? false,
21
21
  collapseAfter: dProps.collapseAfter ?? ui.select.collapseAfter,
22
- hideSearchIcon: dProps.hideSearchIcon ?? ui.select.hideSearchIcon
22
+ hideSearchIcon: dProps.hideSearchIcon ?? ui.select.hideSearchIcon,
23
+ fireBlurOnChange: dProps.fireBlurOnChange ?? ui.select.fireBlurOnChange
23
24
  };
24
25
  const isDesktop = useBreakpoint("md");
25
26
  return /* @__PURE__ */ jsx(SelectContext.Provider, {
@@ -14,7 +14,7 @@ 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
16
  var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }) => {
17
- const { label, tooltipText, helperText, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, isSearchable, isClearable, isLoading, as, size, collapseAfter, selectedTagsType } = props;
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 = {
20
20
  error,
@@ -137,6 +137,8 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
137
137
  inputClassName,
138
138
  collapseAfter,
139
139
  selectedTagsType,
140
+ isRequired,
141
+ isDirty,
140
142
  onBlur,
141
143
  onCloseComboBox: (state) => {
142
144
  if (isSearchable) closeComboBoxRef.current = state;
@@ -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"> {
7
+ interface SelectInputProps extends InputVariantProps, Pick<SelectBaseProps, "ref" | "placeholder" | "isDisabled" | "hideDropdownIcon" | "isSearchable" | "isClearable" | "onBlur" | "showSelectionContent" | "inputClassName" | "selectedTagsType" | "collapseAfter" | "isRequired" | "isDirty" | "fireBlurOnChange"> {
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, onCloseComboBox, onBlur, ...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, ...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, onCloseComboBox, onBlur, ...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, ...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");
@@ -44,9 +44,13 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
44
44
  if (e.key === "Enter" && !isMultiple && !isLoading && listItems.length === 1 && !listItems[0].isDisabled) {
45
45
  e.preventDefault();
46
46
  onChange(listItems[0].id);
47
+ if (fireBlurOnChange) onBlur?.({});
47
48
  onCloseComboBox?.(state);
48
49
  }
49
- if (e.key === "Backspace" && isMultiple && fieldState.inputValue === "" && Array.isArray(fieldState.value) && fieldState.value.length > 0) onChange(fieldState.value.slice(0, -1));
50
+ if (e.key === "Backspace" && isMultiple && fieldState.inputValue === "" && Array.isArray(fieldState.value) && fieldState.value.length > 0) {
51
+ onChange(fieldState.value.slice(0, -1));
52
+ if (fireBlurOnChange) onBlur?.({});
53
+ }
50
54
  };
51
55
  const onClick = () => {
52
56
  if (isDisabled) return;
@@ -75,6 +79,9 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
75
79
  "data-has-search": fieldState.searchValue !== "" || void 0,
76
80
  "data-invalid": isInvalid || void 0,
77
81
  "data-is-empty": isEmpty || void 0,
82
+ "data-is-filled": !isEmpty || void 0,
83
+ "data-is-required": isRequired || void 0,
84
+ "data-is-dirty": isDirty || void 0,
78
85
  "data-select-input": "",
79
86
  ...hoverProps,
80
87
  ...focusWithinProps,
@@ -125,7 +132,10 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
125
132
  ]
126
133
  }),
127
134
  isClearable && /* @__PURE__ */ jsx(InputClear, {
128
- onClear,
135
+ onClear: () => {
136
+ onClear();
137
+ if (fireBlurOnChange) onBlur?.({});
138
+ },
129
139
  show: showClearButton
130
140
  }),
131
141
  !hideDropdownIcon && /* @__PURE__ */ jsx(Button, {
@@ -14,7 +14,7 @@ import { DialogTrigger } from "react-aria-components";
14
14
  import { useLabel } from "react-aria";
15
15
  //#region src/components/inputs/Selection/shared/SelectMobile.tsx
16
16
  var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containerClassName, customTrigger, onBlur, ...props }) => {
17
- const { label, tooltipText, helperText, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, hideSearchIcon, isSearchable, isClearable, as, size, collapseAfter, selectedTagsType } = props;
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,
20
20
  label,
@@ -80,7 +80,9 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
80
80
  fieldProps,
81
81
  headerProps,
82
82
  collapseAfter,
83
- selectedTagsType
83
+ selectedTagsType,
84
+ isRequired,
85
+ isDirty
84
86
  }), /* @__PURE__ */ jsx(BottomSheet, {
85
87
  isOpen,
86
88
  onOpenChange: handleOpenChange,
@@ -15,6 +15,7 @@ export interface TextEditorBaseProps extends FormFieldProps {
15
15
  onBlur?: () => void;
16
16
  as?: "default" | "filter" | "floating" | "inline" | null;
17
17
  editorClassName?: string;
18
+ isDirty?: boolean;
18
19
  }
19
20
  export type TextEditorProps = TextEditorBaseProps;
20
21
  export type ControlledTextEditorProps<TFieldValues extends FieldValues> = ControlProps<TextEditorProps, TFieldValues>;
@@ -37,7 +37,7 @@ var extensions = [
37
37
  defaultProtocol: "https"
38
38
  })
39
39
  ];
40
- var TextEditorBase = ({ ref, as = "default", placeholder, label, hideLabel, tooltipText, helperText, isRequired, rightContent, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, value, className, editorClassName, onChange, onBlur }) => {
40
+ var TextEditorBase = ({ ref, as = "default", placeholder, label, hideLabel, tooltipText, helperText, isRequired, rightContent, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, value, className, editorClassName, isDirty, onChange, onBlur }) => {
41
41
  const contentRef = useRef(null);
42
42
  const { hoverProps, isHovered } = useHover({ isDisabled });
43
43
  const [isFocused, setIsFocused] = useState(false);
@@ -109,6 +109,8 @@ var TextEditorBase = ({ ref, as = "default", placeholder, label, hideLabel, tool
109
109
  "data-focus-within": isFocused || void 0,
110
110
  "data-focus-visible": isFocused && isFocusVisible || void 0,
111
111
  "data-is-filled": !editor?.isEmpty,
112
+ "data-is-required": isRequired || void 0,
113
+ "data-is-dirty": isDirty || void 0,
112
114
  ...hoverProps,
113
115
  ...focusWithinProps,
114
116
  ...fieldProps,
@@ -136,13 +138,15 @@ var TextEditor = (props) => {
136
138
  return /* @__PURE__ */ jsx(Controller, {
137
139
  control: formControl.control,
138
140
  name: formControl.name,
139
- render: ({ field }) => /* @__PURE__ */ jsx(TextEditorBase, {
141
+ render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(TextEditorBase, {
140
142
  ...innerProps,
141
143
  ref: mergeRefs(ref, field.ref),
142
144
  value: field.value,
143
145
  onChange: field.onChange,
144
146
  onBlur: field.onBlur,
145
- isDisabled: field.disabled || props.isDisabled
147
+ isDirty,
148
+ isDisabled: field.disabled || props.isDisabled,
149
+ error: props.error ?? error?.message
146
150
  })
147
151
  });
148
152
  }
@@ -24,7 +24,7 @@ export declare namespace UIConfig {
24
24
  numberInput: Pick<NumberInputProps, "formatOptions">;
25
25
  radioGroup: Pick<RadioGroupProps, "variant" | "hideLabel">;
26
26
  checkbox: Pick<CheckboxProps, "variant">;
27
- select: Pick<SelectBaseProps, "selectionMode" | "isSearchable" | "collapseAfter" | "selectedTagsType" | "hideSearchIcon">;
27
+ select: Pick<SelectBaseProps, "selectionMode" | "isSearchable" | "collapseAfter" | "selectedTagsType" | "hideSearchIcon" | "fireBlurOnChange">;
28
28
  toggle: Pick<ToggleProps, "variant">;
29
29
  slider: Pick<SliderProps, "minValue" | "maxValue">;
30
30
  dateInput: Pick<DatePickerProps, "todayIcon" | "shouldForceLeadingZeros" | "disableManualEntry">;
@@ -31,7 +31,8 @@ var UIConfig;
31
31
  isSearchable: false,
32
32
  selectedTagsType: "list",
33
33
  collapseAfter: 3,
34
- hideSearchIcon: false
34
+ hideSearchIcon: false,
35
+ fireBlurOnChange: false
35
36
  },
36
37
  toggle: { variant: "default" },
37
38
  slider: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.8",
3
+ "version": "2.2.9-rc.1",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",