react-better-html 1.1.62 → 1.1.64
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.
|
@@ -177,7 +177,7 @@ InputFieldComponent.password = (0, react_1.forwardRef)(function Password({ ...pr
|
|
|
177
177
|
InputFieldComponent.search = (0, react_1.forwardRef)(function Search({ ...props }, ref) {
|
|
178
178
|
return (0, jsx_runtime_1.jsx)(InputFieldComponent, { leftIcon: "magnifyingGlass", placeholder: "Search...", ref: ref, ...props });
|
|
179
179
|
});
|
|
180
|
-
InputFieldComponent.phoneNumber = (0, react_1.forwardRef)(function PhoneNumber({ label, value, onChangeValue, ...props }, ref) {
|
|
180
|
+
InputFieldComponent.phoneNumber = (0, react_1.forwardRef)(function PhoneNumber({ label, value, onChangeValue, labelColor, ...props }, ref) {
|
|
181
181
|
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
|
182
182
|
const [dropdownValue, setDropdownValue] = (0, react_1.useState)();
|
|
183
183
|
const [inputFieldValue, setInputFieldValue] = (0, react_1.useState)(value?.toString() ?? "");
|
|
@@ -211,7 +211,7 @@ InputFieldComponent.phoneNumber = (0, react_1.forwardRef)(function PhoneNumber({
|
|
|
211
211
|
setDropdownValue(country.phoneNumberExtension);
|
|
212
212
|
setInputFieldValue(newValue.slice(country?.phoneNumberExtension.length + 1));
|
|
213
213
|
}, [value]);
|
|
214
|
-
return ((0, jsx_runtime_1.jsxs)(Div_1.default, { width: "100%", children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, required: props.required, isError: !!props.errorText }), (0, jsx_runtime_1.jsxs)(Div_1.default.row, { children: [(0, jsx_runtime_1.jsx)(Dropdown_1.default, { options: options, renderOption: renderOption, width: 130, minWidth: 116, withSearch: true, placeholder: label ?? "+00", inputFieldClassName: "react-better-html-phone-number-holder", defaultValue: defaultValue, value: dropdownValue, onChange: setDropdownValue, withoutClearButton: true }), (0, jsx_runtime_1.jsx)(InputFieldComponent, { placeholder: "Phone number", className: "react-better-html-phone-number", value: inputFieldValue, onChangeValue: onChangeValueElement, ref: ref, ...props })] })] }));
|
|
214
|
+
return ((0, jsx_runtime_1.jsxs)(Div_1.default, { width: "100%", children: [label && (0, jsx_runtime_1.jsx)(Label_1.default, { text: label, color: labelColor, required: props.required, isError: !!props.errorText }), (0, jsx_runtime_1.jsxs)(Div_1.default.row, { children: [(0, jsx_runtime_1.jsx)(Dropdown_1.default, { options: options, renderOption: renderOption, width: 130, minWidth: 116, withSearch: true, placeholder: label ?? "+00", inputFieldClassName: "react-better-html-phone-number-holder", defaultValue: defaultValue, value: dropdownValue, onChange: setDropdownValue, withoutClearButton: true }), (0, jsx_runtime_1.jsx)(InputFieldComponent, { placeholder: "Phone number", className: "react-better-html-phone-number", value: inputFieldValue, onChangeValue: onChangeValueElement, ref: ref, ...props })] })] }));
|
|
215
215
|
});
|
|
216
216
|
InputFieldComponent.date = (0, react_1.forwardRef)(function Date({ className, onFocus, onBlur, ...props }, ref) {
|
|
217
217
|
const theme = (0, BetterHtmlProvider_1.useTheme)();
|
package/dist/utils/hooks.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export declare function useForm<FormFields extends Record<string | number, strin
|
|
|
76
76
|
reset: () => void;
|
|
77
77
|
requiredFields: (keyof FormFields)[] | undefined;
|
|
78
78
|
isDirty: boolean;
|
|
79
|
+
isValid: boolean;
|
|
79
80
|
};
|
|
80
81
|
export declare function useUrlQuery(): {
|
|
81
82
|
setQuery: (query: Record<string, string | number>, keepHistory?: boolean) => void;
|
package/dist/utils/hooks.js
CHANGED
|
@@ -379,6 +379,10 @@ function useForm(options) {
|
|
|
379
379
|
setErrors({});
|
|
380
380
|
}, [defaultValues]);
|
|
381
381
|
const isDirty = (0, react_1.useMemo)(() => Object.keys(defaultValues).some((key) => defaultValues[key] !== values[key]), [defaultValues, values]);
|
|
382
|
+
const isValid = (0, react_1.useMemo)(() => {
|
|
383
|
+
const validationErrors = validate?.(values) || {};
|
|
384
|
+
return Object.keys(validationErrors).length === 0;
|
|
385
|
+
}, [validate, values]);
|
|
382
386
|
return {
|
|
383
387
|
values,
|
|
384
388
|
errors,
|
|
@@ -396,6 +400,7 @@ function useForm(options) {
|
|
|
396
400
|
reset,
|
|
397
401
|
requiredFields,
|
|
398
402
|
isDirty,
|
|
403
|
+
isValid,
|
|
399
404
|
};
|
|
400
405
|
}
|
|
401
406
|
function useUrlQuery() {
|