@agilant/toga-blox 1.0.46 → 1.0.47
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,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { UseFormRegister } from "react-hook-form";
|
|
2
3
|
interface InputFieldProps {
|
|
3
4
|
label?: string;
|
|
4
5
|
value?: string | number;
|
|
@@ -25,6 +26,7 @@ interface InputFieldProps {
|
|
|
25
26
|
labelClasses?: string;
|
|
26
27
|
disabled?: boolean;
|
|
27
28
|
hasAutoFocus?: boolean;
|
|
29
|
+
register?: UseFormRegister<any>;
|
|
28
30
|
focusRingColor?: string;
|
|
29
31
|
}
|
|
30
32
|
declare const InputField: React.ForwardRefExoticComponent<InputFieldProps & React.RefAttributes<unknown>>;
|
|
@@ -2,9 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { faCircleInfo } from "@fortawesome/free-solid-svg-icons";
|
|
3
3
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import { useState, forwardRef } from "react";
|
|
5
|
-
const InputField = forwardRef(({ label, placeholder, required = false, checked, id, name, type = "text", firstIcon, secondIcon, iconPosition = "before", iconColor = "primary", isValid = true, isReadOnly = false, onChange, value, readOnlyInfo = "", toolTipText = "", hasToolTip = false, additionalClasses = "", labelClasses = "", hasAutoFocus, onIconClick, onKeyDown, disabled,
|
|
6
|
-
// register,
|
|
7
|
-
focusRingColor = "focus:ring-transparent", }) => {
|
|
5
|
+
const InputField = forwardRef(({ label, placeholder, required = false, checked, id, name, type = "text", firstIcon, secondIcon, iconPosition = "before", iconColor = "primary", isValid = true, isReadOnly = false, onChange, value, readOnlyInfo = "", toolTipText = "", hasToolTip = false, additionalClasses = "", labelClasses = "", hasAutoFocus, onIconClick, onKeyDown, disabled, register, focusRingColor = "focus:ring-transparent", }) => {
|
|
8
6
|
const [isFocused, setIsFocused] = useState(false);
|
|
9
7
|
const hasValue = value != null && !!value.toString().trim(); // Check if input value has at least one non-space character
|
|
10
8
|
const isNumberInput = type === "number";
|
|
@@ -47,17 +45,15 @@ focusRingColor = "focus:ring-transparent", }) => {
|
|
|
47
45
|
return null;
|
|
48
46
|
}
|
|
49
47
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
const registerProps = register
|
|
49
|
+
? register(name || "", { required })
|
|
50
|
+
: {};
|
|
53
51
|
return isReadOnly ? (_jsxs("div", { className: "input-wrapper relative", children: [renderIcons(), _jsxs("label", { htmlFor: id, className: `block font-light text-left mb-1 ${labelClasses} `, children: [label, hasToolTip && (_jsxs("span", { className: "pl-4 group", children: [_jsx(FontAwesomeIcon, { icon: faCircleInfo, className: "text-primary group-hover:text-blue-600" }), _jsx("span", { className: "opacity-0 group-hover:opacity-100 bg-gray-800 text-white text-sm rounded-md px-2 py-1 absolute top-[-14px]", children: toolTipText })] }))] }), _jsx("div", { className: `
|
|
54
52
|
text-left focus:outline-none focus:ring-2 block w-full py-2 px-2 rounded-lg shadow-input outline outline-0 outline-barelyPrimary focus:outline-4 md:w-full lg:w-full xl:w-full
|
|
55
53
|
${firstIcon ? "pl-10" : ""}
|
|
56
54
|
${secondIcon ? "pr-10" : ""}
|
|
57
55
|
${additionalClasses}
|
|
58
|
-
`, children: readOnlyInfo }), iconPosition === "after" && renderSecondIcon()] })) : (_jsxs(_Fragment, { children: [label && (_jsxs("label", { htmlFor: id, className: ` block font-light text-left mb-1 ${labelClasses}`, children: [label, hasToolTip && (_jsxs("span", { className: "pl-4 group", children: [_jsx(FontAwesomeIcon, { icon: faCircleInfo, className: "text-primary group-hover:text-blue-600" }), _jsx("span", { className: "opacity-0 group-hover:opacity-100 bg-gray-800 text-white text-sm rounded-md px-2 py-1 absolute top-[-14px]", children: toolTipText })] }))] })), _jsxs("div", { className: " input-wrapper relative", children: [renderIcons(), _jsx("input", { autoComplete: "",
|
|
59
|
-
// {...registerProps}
|
|
60
|
-
className: `rounded-md focused:ring-0 ${focusRingColor} focus:ring-1
|
|
56
|
+
`, children: readOnlyInfo }), iconPosition === "after" && renderSecondIcon()] })) : (_jsxs(_Fragment, { children: [label && (_jsxs("label", { htmlFor: id, className: ` block font-light text-left mb-1 ${labelClasses}`, children: [label, hasToolTip && (_jsxs("span", { className: "pl-4 group", children: [_jsx(FontAwesomeIcon, { icon: faCircleInfo, className: "text-primary group-hover:text-blue-600" }), _jsx("span", { className: "opacity-0 group-hover:opacity-100 bg-gray-800 text-white text-sm rounded-md px-2 py-1 absolute top-[-14px]", children: toolTipText })] }))] })), _jsxs("div", { className: " input-wrapper relative", children: [renderIcons(), _jsx("input", { autoComplete: "", ...registerProps, className: `rounded-md focused:ring-0 ${focusRingColor} focus:ring-1
|
|
61
57
|
focus:outline-none
|
|
62
58
|
${disabled
|
|
63
59
|
? "border-gray-500 focus:ring-gray-500"
|