@uxf/form 11.80.4 → 11.85.0

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.
@@ -1,19 +1,12 @@
1
- import { CheckboxInputProps as UICheckboxInputProps } from "@uxf/ui/checkbox-input";
2
- import { FormControlProps } from "@uxf/ui/types";
3
- import React, { ReactNode } from "react";
1
+ import { CheckboxListOption, CheckboxListValueId, CheckboxListProps as UICheckboxListProps } from "@uxf/ui/checkbox-list";
2
+ import React from "react";
4
3
  import { FieldValues } from "react-hook-form";
5
4
  import { ControlProps } from "../types";
6
- type ValueType = string | number;
7
- export type CheckboxListOption = {
8
- id: ValueType;
9
- label: ReactNode;
10
- isDisabled?: boolean;
11
- };
12
- export type CheckboxListValue<T> = T[] | null;
13
- type CheckboxListProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UICheckboxInputProps, "isInvalid" | "name" | "onChange" | "value"> & {
14
- onChange?: FormControlProps<CheckboxListValue<string | number>>["onChange"];
5
+ export type CheckboxListProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UICheckboxListProps, "isInvalid" | "name" | "onChange" | "value"> & {
6
+ onChange?: UICheckboxListProps["onChange"];
15
7
  options: CheckboxListOption[];
16
8
  requiredMessage?: string;
9
+ onChangeConfirm?: (value: UICheckboxListProps["value"]) => Promise<boolean>;
17
10
  };
11
+ export type CheckboxListValue<T extends CheckboxListValueId> = T[] | null;
18
12
  export declare function CheckboxList<FormData extends FieldValues>(props: CheckboxListProps<FormData>): React.JSX.Element;
19
- export {};
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ "use client";
2
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
5
  };
@@ -31,10 +32,18 @@ function CheckboxList(props) {
31
32
  field.onBlur();
32
33
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
33
34
  };
34
- const onChange = (value, event) => {
35
- var _a;
36
- field.onChange(value);
37
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
35
+ const onChange = async (value, event) => {
36
+ var _a, _b;
37
+ if ((0, is_not_nil_1.isNotNil)(props.onChangeConfirm)) {
38
+ if (await props.onChangeConfirm(value)) {
39
+ field.onChange(value);
40
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
41
+ }
42
+ }
43
+ else {
44
+ field.onChange(value);
45
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, value, event);
46
+ }
38
47
  };
39
- return (react_1.default.createElement(checkbox_list_1.CheckboxList, { className: props.className, hasHiddenLabel: props.hiddenLabel, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, id: id, isDisabled: formContext.isFormDisabled || props.isDisabled, isFocused: props.isFocused, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, label: props.label, name: props.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, value: field.value }));
48
+ return (react_1.default.createElement(checkbox_list_1.CheckboxList, { className: props.className, hasHiddenLabel: props.hasHiddenLabel, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, id: id, isDisabled: formContext.isFormDisabled || props.isDisabled, isFocused: props.isFocused, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, label: props.label, name: props.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, value: field.value }));
40
49
  }
@@ -17,6 +17,6 @@ function Default() {
17
17
  return (react_1.default.createElement(storybook_form_1.StorybookForm, null, ({ control }) => (react_1.default.createElement("div", { className: "space-y-2 p-20" },
18
18
  react_1.default.createElement(checkbox_list_1.CheckboxList, { control: control, label: "CheckboxList default", name: "checkboxList1", options: CHECKBOX_LIST_OPTIONS }),
19
19
  react_1.default.createElement(checkbox_list_1.CheckboxList, { control: control, isRequired: true, label: "CheckboxList required", name: "checkboxList2", options: CHECKBOX_LIST_OPTIONS }),
20
- react_1.default.createElement(checkbox_list_1.CheckboxList, { control: control, hiddenLabel: true, label: "CheckboxList with hidden label", name: "checkboxList3", options: CHECKBOX_LIST_OPTIONS }),
20
+ react_1.default.createElement(checkbox_list_1.CheckboxList, { control: control, hasHiddenLabel: true, label: "CheckboxList with hidden label", name: "checkboxList3", options: CHECKBOX_LIST_OPTIONS }),
21
21
  react_1.default.createElement(button_1.Button, { type: "submit" }, "Submit")))));
22
22
  }
@@ -5,6 +5,7 @@ import { ControlProps } from "../types";
5
5
  export type ColorRadioGroupProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIColorRadioGroupProps, "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
6
6
  onChange?: UIColorRadioGroupProps["onChange"];
7
7
  requiredMessage?: string;
8
+ onChangeConfirm?: (value: UIColorRadioGroupProps["value"]) => Promise<boolean>;
8
9
  };
9
10
  export type ColorRadioGroupValue = `#${string}` | null;
10
11
  export declare function ColorRadioGroup<FormData extends Record<string, any>>(props: ColorRadioGroupProps<FormData>): React.JSX.Element;
@@ -32,10 +32,18 @@ function ColorRadioGroup(props) {
32
32
  field.onBlur();
33
33
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
34
34
  };
35
- const onChange = (value, event) => {
36
- var _a;
37
- field.onChange(value);
38
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
35
+ const onChange = async (value, event) => {
36
+ var _a, _b;
37
+ if ((0, is_not_nil_1.isNotNil)(props.onChangeConfirm)) {
38
+ if (await props.onChangeConfirm(value)) {
39
+ field.onChange(value);
40
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
41
+ }
42
+ }
43
+ else {
44
+ field.onChange(value);
45
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, value, event);
46
+ }
39
47
  };
40
48
  return (react_1.default.createElement(color_radio_group_1.ColorRadioGroup, { className: props.className, helperText: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isDisabled: props.options.length === 0 || formContext.isFormDisabled || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, ref: field.ref, style: props.style, value: (_d = field.value) !== null && _d !== void 0 ? _d : null }));
41
49
  }
@@ -2,12 +2,13 @@ import { ComboboxValueId, ComboboxProps as UIComboboxProps, ComboboxValue as UIC
2
2
  import React from "react";
3
3
  import { FieldValues } from "react-hook-form";
4
4
  import { ControlProps } from "../types";
5
- export type ComboProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIComboboxProps, "inputGroupRef" | "inputRef" | "inputWrapperRef" | "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
5
+ export type ComboboxProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIComboboxProps, "inputGroupRef" | "inputRef" | "inputWrapperRef" | "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
6
6
  onChange?: UIComboboxProps["onChange"];
7
7
  requiredMessage?: string;
8
+ onChangeConfirm?: (value: UIComboboxProps["value"]) => Promise<boolean>;
8
9
  };
9
10
  export type ComboboxValue<Id extends ComboboxValueId> = UIComboboxValue<Id> | null;
10
- export declare function Combobox<FormData extends Record<string, any>>(props: ComboProps<FormData>): React.JSX.Element;
11
+ export declare function Combobox<FormData extends Record<string, any>>(props: ComboboxProps<FormData>): React.JSX.Element;
11
12
  export declare namespace Combobox {
12
13
  var displayName: string;
13
14
  }
@@ -35,10 +35,18 @@ function Combobox(props) {
35
35
  field.onBlur();
36
36
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
37
37
  };
38
- const onChange = (value, event) => {
39
- var _a;
40
- field.onChange(value);
41
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
38
+ const onChange = async (value, event) => {
39
+ var _a, _b;
40
+ if ((0, is_not_nil_1.isNotNil)(props.onChangeConfirm)) {
41
+ if (await props.onChangeConfirm(value)) {
42
+ field.onChange(value);
43
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
44
+ }
45
+ }
46
+ else {
47
+ field.onChange(value);
48
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, value, event);
49
+ }
42
50
  };
43
51
  const isDisabled = ((0, is_nil_1.isNil)(props.loadOptions) && (0, is_empty_1.isEmpty)((_b = props.options) !== null && _b !== void 0 ? _b : empty_array_1.EMPTY_ARRAY)) ||
44
52
  formContext.isFormDisabled ||
@@ -1,3 +1,4 @@
1
+ import { DateRangePickerValueType } from "@uxf/ui/date-range-picker";
1
2
  import { DateRangePickerInputProps as UIDateRangePickerInputProps } from "@uxf/ui/date-range-picker-input";
2
3
  import React from "react";
3
4
  import { FieldValues } from "react-hook-form";
@@ -6,6 +7,7 @@ export type DateRangePickerInputProps<FormData extends FieldValues> = ControlPro
6
7
  onChange?: UIDateRangePickerInputProps["onChange"];
7
8
  requiredMessage?: string;
8
9
  };
10
+ export type DateRangePickerInputValueType = DateRangePickerValueType;
9
11
  export declare function DateRangePickerInput<FormData extends FieldValues>(props: DateRangePickerInputProps<FormData>): React.JSX.Element;
10
12
  export declare namespace DateRangePickerInput {
11
13
  var displayName: string;
@@ -40,7 +40,7 @@ const form_context_1 = require("../form-id-context/form-context");
40
40
  (0, dayjs_1.extend)(customParseFormat_1.default);
41
41
  const OUTPUT_DATE_FORMAT = "YYYY-MM-DD";
42
42
  function DateRangePickerInput(props) {
43
- var _a, _b, _c, _d;
43
+ var _a, _b, _c, _d, _e, _f;
44
44
  const formContext = (0, form_context_1.useFormContext)();
45
45
  const t = (0, translations_1.useUxfTranslation)();
46
46
  const { field, fieldState } = (0, react_hook_form_1.useController)({
@@ -56,10 +56,10 @@ function DateRangePickerInput(props) {
56
56
  if (!value) {
57
57
  return;
58
58
  }
59
- const { from, to } = (0, date_range_picker_input_2.splitValueToRange)(value);
60
- const fromIsValid = (0, dayjs_1.default)(from, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
61
- const toIsValid = (0, dayjs_1.default)(to, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
62
- if (!fromIsValid || !toIsValid) {
59
+ const { from, to } = value;
60
+ const isFromValid = (0, dayjs_1.default)(from, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
61
+ const isToValid = (0, dayjs_1.default)(to, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
62
+ if (!isFromValid || !isToValid) {
63
63
  return t("uxf-form-date-range-picker-input:validation.invalid-date-range-format", {
64
64
  format: "D. M. YYYY. - D. M. YYYY.",
65
65
  value: value,
@@ -86,30 +86,32 @@ function DateRangePickerInput(props) {
86
86
  const onChange = (value, event) => {
87
87
  var _a;
88
88
  if (value) {
89
- const { from, to } = (0, date_range_picker_input_2.splitValueToRange)(value);
90
- const fromIsValid = (0, dayjs_1.default)(from, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
91
- const toIsValid = (0, dayjs_1.default)(to, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
92
- if (fromIsValid || toIsValid) {
93
- field.onChange((fromIsValid ? (0, dayjs_1.default)(from, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).format(OUTPUT_DATE_FORMAT) : from) +
94
- date_range_picker_input_2.SEPARATOR +
95
- (toIsValid ? (0, dayjs_1.default)(to, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).format(OUTPUT_DATE_FORMAT) : to));
96
- }
89
+ const { from, to } = (0, date_range_picker_input_2.splitValueToRange)(value.replace(/(?<=\d)-(?=\d)/g, date_range_picker_input_2.SEPARATOR));
90
+ const isFromValid = (0, dayjs_1.default)(from, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
91
+ const isToValid = (0, dayjs_1.default)(to, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).isValid();
92
+ field.onChange({
93
+ from: isFromValid ? (0, dayjs_1.default)(from, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).format(OUTPUT_DATE_FORMAT) : (from !== null && from !== void 0 ? from : ""),
94
+ to: isToValid ? (0, dayjs_1.default)(to, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true).format(OUTPUT_DATE_FORMAT) : (to !== null && to !== void 0 ? to : ""),
95
+ });
97
96
  }
98
97
  else {
99
98
  field.onChange(value);
100
99
  }
101
100
  (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
102
101
  };
103
- const { from: fieldFrom, to: fieldTo } = (0, date_range_picker_input_2.splitValueToRange)(field.value);
104
- const parsedFrom = (0, dayjs_1.default)(fieldFrom, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true);
105
- const parsedTo = (0, dayjs_1.default)(fieldTo, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true);
102
+ const fieldFrom = (_c = field.value) === null || _c === void 0 ? void 0 : _c.from;
103
+ const fieldTo = (_d = field.value) === null || _d === void 0 ? void 0 : _d.to;
104
+ const dayjsFrom = (0, dayjs_1.default)(fieldFrom, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true);
105
+ const dayjsTo = (0, dayjs_1.default)(fieldTo, date_range_picker_input_2.ALLOWED_DATE_FORMAT, true);
106
+ const isFromValid = dayjsFrom.isValid();
107
+ const isToValid = dayjsTo.isValid();
106
108
  const value = field.value
107
- ? parsedFrom.isValid() || parsedTo.isValid()
108
- ? (parsedFrom.isValid() ? parsedFrom.format(date_range_picker_input_2.DISPLAY_DATE_FORMAT) : fieldFrom) +
109
- date_range_picker_input_2.SEPARATOR +
110
- (parsedTo.isValid() ? parsedTo.format(date_range_picker_input_2.DISPLAY_DATE_FORMAT) : fieldTo)
111
- : field.value
109
+ ? isFromValid || isToValid
110
+ ? `${isFromValid ? dayjsFrom.format(date_range_picker_input_2.DISPLAY_DATE_FORMAT) : fieldFrom}${date_range_picker_input_2.SEPARATOR}${isToValid ? dayjsTo.format(date_range_picker_input_2.DISPLAY_DATE_FORMAT) : fieldTo}`
111
+ : field.value.from && field.value.to
112
+ ? `${field.value.from}${date_range_picker_input_2.SEPARATOR}${field.value.to}`
113
+ : field.value.from
112
114
  : null;
113
- return (react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { autoFocus: props.autoFocus, bottomContent: props.bottomContent, className: props.className, datesConfig: props.datesConfig, form: props.form, helperText: (_d = (_c = fieldState.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : props.helperText, hiddenLabel: props.hiddenLabel, id: props.id, isClearable: props.isClearable, isDisabled: formContext.isFormDisabled || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: field.name, numberOfMonths: props.numberOfMonths, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, placeholder: props.placeholder, popoverPlacement: props.popoverPlacement, popoverStrategy: props.popoverStrategy, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, style: props.style, triggerElement: props.triggerElement, unavailableDates: props.unavailableDates, value: value, variant: props.variant }));
115
+ return (react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { autoFocus: props.autoFocus, bottomContent: props.bottomContent, className: props.className, datesConfig: props.datesConfig, form: props.form, helperText: (_f = (_e = fieldState.error) === null || _e === void 0 ? void 0 : _e.message) !== null && _f !== void 0 ? _f : props.helperText, hiddenLabel: props.hiddenLabel, id: props.id, isClearable: props.isClearable, isDisabled: formContext.isFormDisabled || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: field.name, numberOfMonths: props.numberOfMonths, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, placeholder: props.placeholder, popoverPlacement: props.popoverPlacement, popoverStrategy: props.popoverStrategy, ref: field.ref, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, style: props.style, triggerElement: props.triggerElement, unavailableDates: props.unavailableDates, value: value, variant: props.variant }));
114
116
  }
115
117
  DateRangePickerInput.displayName = "UxfFormDateRangePickerInput";
@@ -2,12 +2,13 @@ import { MultiComboboxOption, MultiComboboxProps as UIMultiComboboxProps } from
2
2
  import React from "react";
3
3
  import { FieldValues } from "react-hook-form";
4
4
  import { ControlProps } from "../types";
5
- export type ComboProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIMultiComboboxProps, "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
5
+ export type MultiComboboxProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIMultiComboboxProps, "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
6
6
  onChange?: UIMultiComboboxProps["onChange"];
7
7
  requiredMessage?: string;
8
+ onChangeConfirm?: (value: UIMultiComboboxProps["value"]) => Promise<boolean>;
8
9
  };
9
10
  export type MultiComboboxValue<Id> = MultiComboboxOption<Id>[] | null;
10
- export declare function MultiCombobox<FormData extends Record<string, any>>(props: ComboProps<FormData>): React.JSX.Element;
11
+ export declare function MultiCombobox<FormData extends Record<string, any>>(props: MultiComboboxProps<FormData>): React.JSX.Element;
11
12
  export declare namespace MultiCombobox {
12
13
  var displayName: string;
13
14
  }
@@ -35,10 +35,18 @@ function MultiCombobox(props) {
35
35
  field.onBlur();
36
36
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
37
37
  };
38
- const onChange = (value, event) => {
39
- var _a;
40
- field.onChange(value);
41
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
38
+ const onChange = async (value, event) => {
39
+ var _a, _b;
40
+ if ((0, is_not_nil_1.isNotNil)(props.onChangeConfirm)) {
41
+ if (await props.onChangeConfirm(value)) {
42
+ field.onChange(value);
43
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
44
+ }
45
+ }
46
+ else {
47
+ field.onChange(value);
48
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, value, event);
49
+ }
42
50
  };
43
51
  const isDisabled = ((0, is_nil_1.isNil)(props.loadOptions) && (0, is_empty_1.isEmpty)((_b = props.options) !== null && _b !== void 0 ? _b : empty_array_1.EMPTY_ARRAY)) ||
44
52
  formContext.isFormDisabled ||
@@ -32,6 +32,7 @@ function Default() {
32
32
  react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, helperText: "Za\u010Dn\u011Bte ps\u00E1t pro vyhled\u00E1v\u00E1n\u00ED...", id: "form-combobox", label: "Combobox with checkboxes", name: "combobox-with-checkboxes", options: options, placeholder: "Vyberte...", withCheckboxes: true }),
33
33
  react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, helperText: "Za\u010Dn\u011Bte ps\u00E1t pro vyhled\u00E1v\u00E1n\u00ED...", id: "form-combobox", isRequired: true, label: "Combobox form required", name: "combobox-required", options: options, placeholder: "Vyberte..." }),
34
34
  react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, id: "form-combobox", isDisabled: true, label: "Combobox form disabled", name: "combobox-disabled", options: options, placeholder: "Vyberte..." }),
35
+ react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, dropdownMaxHeight: 350, helperText: "Za\u010Dn\u011Bte ps\u00E1t pro vyhled\u00E1v\u00E1n\u00ED...", id: "form-combobox", label: "Combobox form with onChangeConfirm", name: "combobox-with-onchangeconfirm", onChangeConfirm: () => Promise.resolve(confirm("Really want to change?")), options: options, placeholder: "Vyberte..." }),
35
36
  react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, dropdownPlacement: "top", id: "form-combobox", label: "Combobox form with dropdown top", name: "select-dropdown-top", options: options, placeholder: "Vyberte..." }),
36
37
  react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, dropdownPlacement: "top", id: "form-combobox", label: "Combobox async", loadOptions: (query) => Promise.resolve(options.filter((option) => !query || option.label.toLowerCase().includes(query.toLowerCase()))), name: "select-dropdown-async", placeholder: "Vyberte..." }),
37
38
  react_1.default.createElement(multi_combobox_1.MultiCombobox, { control: control, dropdownPlacement: "top", id: "form-combobox", label: "Combobox async with default values", loadOptions: (query) => Promise.resolve(options.filter((option) => !query || option.label.toLowerCase().includes(query.toLowerCase()))), name: "select-dropdown-async-default", placeholder: "Vyberte..." }),
@@ -6,6 +6,7 @@ import { ControlProps } from "../types";
6
6
  export type MultiSelectProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIMultiSelectProps, "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
7
7
  onChange?: UIMultiSelectProps["onChange"];
8
8
  requiredMessage?: string;
9
+ onChangeConfirm?: (value: UIMultiSelectProps["value"]) => Promise<boolean>;
9
10
  };
10
11
  export type MultiSelectValue<T extends SelectableId> = T[] | null;
11
12
  export declare function MultiSelect<FormData extends Record<string, any>>(props: MultiSelectProps<FormData>): React.JSX.Element;
@@ -33,10 +33,18 @@ function MultiSelect(props) {
33
33
  field.onBlur();
34
34
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
35
35
  };
36
- const onChange = (value, event) => {
37
- var _a;
38
- field.onChange(value);
39
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
36
+ const onChange = async (value, event) => {
37
+ var _a, _b;
38
+ if ((0, is_not_nil_1.isNotNil)(props.onChangeConfirm)) {
39
+ if (await props.onChangeConfirm(value)) {
40
+ field.onChange(value);
41
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
42
+ }
43
+ }
44
+ else {
45
+ field.onChange(value);
46
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, value, event);
47
+ }
40
48
  };
41
49
  return (react_1.default.createElement(multi_select_1.MultiSelect, { allOptionsSelectedMessage: props.allOptionsSelectedMessage, className: props.className, dropdownClassName: props.dropdownClassName, dropdownMatchesInputWidth: props.dropdownMatchesInputWidth, dropdownMaxHeight: props.dropdownMaxHeight, dropdownPlacement: props.dropdownPlacement, dropdownStrategy: props.dropdownStrategy, form: props.form, helperText: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : props.helperText, hiddenLabel: props.hiddenLabel, iconName: props.iconName, id: id, inputArrow: props.inputArrow, isDisabled: (0, is_empty_1.isEmpty)(props.options) || formContext.isFormDisabled || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: field.name, noOptionsMessage: props.noOptionsMessage, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, placeholder: props.placeholder, ref: field.ref, renderOption: props.renderOption, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, style: props.style, value: field.value, variant: props.variant, withCheckboxes: props.withCheckboxes }));
42
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/form",
3
- "version": "11.80.4",
3
+ "version": "11.85.0",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,9 +16,9 @@
16
16
  },
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@uxf/core": "11.80.4",
20
- "@uxf/core-react": "11.80.4",
21
- "@uxf/ui": "11.80.4",
19
+ "@uxf/core": "11.85.0",
20
+ "@uxf/core-react": "11.85.0",
21
+ "@uxf/ui": "11.85.0",
22
22
  "coordinate-parser": "1.0.7",
23
23
  "dayjs": "1.11.13",
24
24
  "react-hook-form": "7.53.0"
@@ -5,6 +5,7 @@ import { ControlProps } from "../types";
5
5
  export type RadioGroupProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UIRadioGroupProps, "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
6
6
  onChange?: UIRadioGroupProps["onChange"];
7
7
  requiredMessage?: string;
8
+ onChangeConfirm?: (value: UIRadioGroupProps["value"]) => Promise<boolean>;
8
9
  };
9
10
  export type RadioGroupValue<T extends RadioGroupOptionValueId> = T | null;
10
11
  export declare function RadioGroup<FormData extends Record<string, any>>(props: RadioGroupProps<FormData>): React.JSX.Element;
@@ -32,10 +32,18 @@ function RadioGroup(props) {
32
32
  field.onBlur();
33
33
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
34
34
  };
35
- const onChange = (value, event) => {
36
- var _a;
37
- field.onChange(value);
38
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
35
+ const onChange = async (value, event) => {
36
+ var _a, _b;
37
+ if ((0, is_not_nil_1.isNotNil)(props.onChangeConfirm)) {
38
+ if (await props.onChangeConfirm(value)) {
39
+ field.onChange(value);
40
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
41
+ }
42
+ }
43
+ else {
44
+ field.onChange(value);
45
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, value, event);
46
+ }
39
47
  };
40
48
  return (react_1.default.createElement(radio_group_1.RadioGroup, { className: props.className, forceColumn: props.forceColumn, helperText: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : props.helperText, hiddenLabel: props.hiddenLabel, id: id, isDisabled: props.options.length === 0 || formContext.isFormDisabled || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, label: props.label, name: field.name, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, radioSize: props.radioSize, ref: field.ref, style: props.style, value: (_d = field.value) !== null && _d !== void 0 ? _d : null, variant: props.variant }));
41
49
  }
@@ -5,6 +5,7 @@ import { ControlProps } from "../types";
5
5
  export type SelectProps<FormData extends FieldValues> = ControlProps<FormData> & Omit<UISelectProps, "inputGroupRef" | "inputRef" | "inputWrapperRef" | "isFocused" | "isInvalid" | "name" | "onChange" | "value"> & {
6
6
  onChange?: UISelectProps["onChange"];
7
7
  requiredMessage?: string;
8
+ onChangeConfirm?: (value: UISelectProps["value"]) => Promise<boolean>;
8
9
  };
9
10
  export type SelectValue<T extends UISelectValue> = T | null;
10
11
  export declare function Select<FormData extends Record<string, any>>(props: SelectProps<FormData>): React.JSX.Element;
package/select/select.js CHANGED
@@ -31,10 +31,18 @@ function Select(props) {
31
31
  field.onBlur();
32
32
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
33
33
  };
34
- const onChange = (value, event) => {
35
- var _a;
36
- field.onChange(value);
37
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
34
+ const onChange = async (value, event) => {
35
+ var _a, _b;
36
+ if ((0, is_not_nil_1.isNotNil)(props.onChangeConfirm)) {
37
+ if (await props.onChangeConfirm(value)) {
38
+ field.onChange(value);
39
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, event);
40
+ }
41
+ }
42
+ else {
43
+ field.onChange(value);
44
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, value, event);
45
+ }
38
46
  };
39
47
  return (react_1.default.createElement(select_1.Select, { className: props.className, dropdownClassName: props.dropdownClassName, dropdownMatchesInputWidth: props.dropdownMatchesInputWidth, dropdownMaxHeight: props.dropdownMaxHeight, dropdownPlacement: props.dropdownPlacement, dropdownStrategy: props.dropdownStrategy, form: props.form, helperText: (_c = (_b = fieldState.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : props.helperText, hiddenLabel: props.hiddenLabel, iconName: props.iconName, id: id, inputArrow: props.inputArrow, inputRef: field.ref, isClearable: props.isClearable, isDisabled: (0, is_empty_1.isEmpty)(props.options) || formContext.isFormDisabled || props.isDisabled, isInvalid: (0, is_not_nil_1.isNotNil)(fieldState.error), isReadOnly: formContext.isFormReadOnly || props.isReadOnly, isRequired: props.isRequired, keyExtractor: props.keyExtractor, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: field.name, noOptionsMessage: props.noOptionsMessage, onBlur: onBlur, onChange: onChange, onFocus: props.onFocus, options: props.options, placeholder: props.placeholder, renderOption: props.renderOption, renderSelectedOption: props.renderSelectedOption, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, style: props.style, value: field.value, variant: props.variant }));
40
48
  }