@trackunit/react-form-components 1.0.12 → 1.0.14
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.
package/index.cjs.js
CHANGED
|
@@ -378,7 +378,7 @@ const DisabledForReasonsTip = ({ reasons, kind }) => {
|
|
|
378
378
|
* For specific input types make sure to use the corresponding input component.
|
|
379
379
|
* This is a base used by our other input components such as TextInput, NumberInput, PasswordInput, etc.
|
|
380
380
|
*/
|
|
381
|
-
const BaseInput = React__namespace.forwardRef(({ className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, showDefaultActions = false, inputClassName, placeholder, addonBeforeClassName, ...rest }, ref) => {
|
|
381
|
+
const BaseInput = React__namespace.forwardRef(({ className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, showDefaultActions = false, inputClassName, placeholder, addonBeforeClassName, style, ...rest }, ref) => {
|
|
382
382
|
var _a;
|
|
383
383
|
const renderAsDisabled = Boolean(rest.disabled) || rest.readOnly;
|
|
384
384
|
const innerRef = React__namespace.useRef(null);
|
|
@@ -389,7 +389,7 @@ const BaseInput = React__namespace.forwardRef(({ className, isInvalid, dataTestI
|
|
|
389
389
|
invalid: isInvalid,
|
|
390
390
|
size: fieldSize,
|
|
391
391
|
className,
|
|
392
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : null, children: [addonBefore ? (jsxRuntime.jsx("div", { className: cvaInputAddonBefore({ className: addonBeforeClassName }), "data-testid": dataTestId ? `${dataTestId}-addonBefore` : null, children: addonBefore })) : null, prefix && !compareReactNodes(addonBefore, prefix) ? (jsxRuntime.jsx("div", { className: cvaInputPrefix({
|
|
392
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : null, style: style, children: [addonBefore ? (jsxRuntime.jsx("div", { className: cvaInputAddonBefore({ className: addonBeforeClassName }), "data-testid": dataTestId ? `${dataTestId}-addonBefore` : null, children: addonBefore })) : null, prefix && !compareReactNodes(addonBefore, prefix) ? (jsxRuntime.jsx("div", { className: cvaInputPrefix({
|
|
393
393
|
disabled: renderAsDisabled,
|
|
394
394
|
addonBefore: addonBefore !== undefined,
|
|
395
395
|
}), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, children: prefix })) : null, jsxRuntime.jsx("input", { "aria-required": rest.required, className: cvaInputField({
|
|
@@ -1716,7 +1716,13 @@ const cvaSearch = cssClassVarianceUtilities.cvaMerge([
|
|
|
1716
1716
|
variants: {
|
|
1717
1717
|
border: { true: ["!component-search-borderless"], false: "" },
|
|
1718
1718
|
widenOnFocus: {
|
|
1719
|
-
true: [
|
|
1719
|
+
true: [
|
|
1720
|
+
"component-search-width",
|
|
1721
|
+
"component-search-widen",
|
|
1722
|
+
"hover:component-search-widen",
|
|
1723
|
+
"focus-within:w-full",
|
|
1724
|
+
"max-w-sm",
|
|
1725
|
+
],
|
|
1720
1726
|
false: "w-full",
|
|
1721
1727
|
},
|
|
1722
1728
|
},
|
|
@@ -1728,8 +1734,9 @@ const cvaSearch = cssClassVarianceUtilities.cvaMerge([
|
|
|
1728
1734
|
* @param {SearchProps} props - The props for the Search component
|
|
1729
1735
|
* @returns {JSX.Element} Search component
|
|
1730
1736
|
*/
|
|
1731
|
-
const Search = React.forwardRef(({ className, placeholder = "Search", value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", loading, inputClassName, ...rest }, ref) => {
|
|
1732
|
-
|
|
1737
|
+
const Search = React.forwardRef(({ className, placeholder = "Search", value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", loading, inputClassName, iconName = "MagnifyingGlass", ...rest }, ref) => {
|
|
1738
|
+
var _a, _b;
|
|
1739
|
+
return (jsxRuntime.jsx(TextInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), dataTestId: dataTestId, disabled: disabled, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder, prefix: loading ? (jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", size: (_a = rest.fieldSize) !== null && _a !== void 0 ? _a : undefined })) : (jsxRuntime.jsx(reactComponents.Icon, { name: iconName, size: (_b = rest.fieldSize) !== null && _b !== void 0 ? _b : undefined })), ref: ref, suffix:
|
|
1733
1740
|
//only show the clear button if there is a value and the onClear function is provided
|
|
1734
1741
|
onClear && value ? (jsxRuntime.jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
|
|
1735
1742
|
onClear();
|
package/index.esm.js
CHANGED
|
@@ -359,7 +359,7 @@ const DisabledForReasonsTip = ({ reasons, kind }) => {
|
|
|
359
359
|
* For specific input types make sure to use the corresponding input component.
|
|
360
360
|
* This is a base used by our other input components such as TextInput, NumberInput, PasswordInput, etc.
|
|
361
361
|
*/
|
|
362
|
-
const BaseInput = React.forwardRef(({ className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, showDefaultActions = false, inputClassName, placeholder, addonBeforeClassName, ...rest }, ref) => {
|
|
362
|
+
const BaseInput = React.forwardRef(({ className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, showDefaultActions = false, inputClassName, placeholder, addonBeforeClassName, style, ...rest }, ref) => {
|
|
363
363
|
var _a;
|
|
364
364
|
const renderAsDisabled = Boolean(rest.disabled) || rest.readOnly;
|
|
365
365
|
const innerRef = React.useRef(null);
|
|
@@ -370,7 +370,7 @@ const BaseInput = React.forwardRef(({ className, isInvalid, dataTestId, prefix,
|
|
|
370
370
|
invalid: isInvalid,
|
|
371
371
|
size: fieldSize,
|
|
372
372
|
className,
|
|
373
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : null, children: [addonBefore ? (jsx("div", { className: cvaInputAddonBefore({ className: addonBeforeClassName }), "data-testid": dataTestId ? `${dataTestId}-addonBefore` : null, children: addonBefore })) : null, prefix && !compareReactNodes(addonBefore, prefix) ? (jsx("div", { className: cvaInputPrefix({
|
|
373
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : null, style: style, children: [addonBefore ? (jsx("div", { className: cvaInputAddonBefore({ className: addonBeforeClassName }), "data-testid": dataTestId ? `${dataTestId}-addonBefore` : null, children: addonBefore })) : null, prefix && !compareReactNodes(addonBefore, prefix) ? (jsx("div", { className: cvaInputPrefix({
|
|
374
374
|
disabled: renderAsDisabled,
|
|
375
375
|
addonBefore: addonBefore !== undefined,
|
|
376
376
|
}), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, children: prefix })) : null, jsx("input", { "aria-required": rest.required, className: cvaInputField({
|
|
@@ -1697,7 +1697,13 @@ const cvaSearch = cvaMerge([
|
|
|
1697
1697
|
variants: {
|
|
1698
1698
|
border: { true: ["!component-search-borderless"], false: "" },
|
|
1699
1699
|
widenOnFocus: {
|
|
1700
|
-
true: [
|
|
1700
|
+
true: [
|
|
1701
|
+
"component-search-width",
|
|
1702
|
+
"component-search-widen",
|
|
1703
|
+
"hover:component-search-widen",
|
|
1704
|
+
"focus-within:w-full",
|
|
1705
|
+
"max-w-sm",
|
|
1706
|
+
],
|
|
1701
1707
|
false: "w-full",
|
|
1702
1708
|
},
|
|
1703
1709
|
},
|
|
@@ -1709,8 +1715,9 @@ const cvaSearch = cvaMerge([
|
|
|
1709
1715
|
* @param {SearchProps} props - The props for the Search component
|
|
1710
1716
|
* @returns {JSX.Element} Search component
|
|
1711
1717
|
*/
|
|
1712
|
-
const Search = forwardRef(({ className, placeholder = "Search", value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", loading, inputClassName, ...rest }, ref) => {
|
|
1713
|
-
|
|
1718
|
+
const Search = forwardRef(({ className, placeholder = "Search", value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", loading, inputClassName, iconName = "MagnifyingGlass", ...rest }, ref) => {
|
|
1719
|
+
var _a, _b;
|
|
1720
|
+
return (jsx(TextInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), dataTestId: dataTestId, disabled: disabled, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder, prefix: loading ? (jsx(Spinner, { centering: "centered", size: (_a = rest.fieldSize) !== null && _a !== void 0 ? _a : undefined })) : (jsx(Icon, { name: iconName, size: (_b = rest.fieldSize) !== null && _b !== void 0 ? _b : undefined })), ref: ref, suffix:
|
|
1714
1721
|
//only show the clear button if there is a value and the onClear function is provided
|
|
1715
1722
|
onClear && value ? (jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
|
|
1716
1723
|
onClear();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"react-hook-form": "7.53.1",
|
|
19
19
|
"tailwind-merge": "^2.0.0",
|
|
20
20
|
"@trackunit/css-class-variance-utilities": "^1.0.1",
|
|
21
|
-
"@trackunit/react-components": "^1.0.
|
|
22
|
-
"@trackunit/ui-icons": "^1.0.
|
|
21
|
+
"@trackunit/react-components": "^1.0.13",
|
|
22
|
+
"@trackunit/ui-icons": "^1.0.3",
|
|
23
23
|
"@trackunit/shared-utils": "^1.0.3",
|
|
24
|
-
"@trackunit/i18n-library-translation": "^1.0.
|
|
24
|
+
"@trackunit/i18n-library-translation": "^1.0.5"
|
|
25
25
|
},
|
|
26
26
|
"module": "./index.esm.js",
|
|
27
27
|
"main": "./index.cjs.js",
|
|
@@ -69,6 +69,7 @@ export interface BaseInputProps extends FilteredInputProps, CommonProps {
|
|
|
69
69
|
*/
|
|
70
70
|
readonly?: boolean;
|
|
71
71
|
disabled?: boolean | DisabledForReasons;
|
|
72
|
+
style?: React.CSSProperties;
|
|
72
73
|
}
|
|
73
74
|
/**
|
|
74
75
|
* A base input component that can be used for text inputs, password inputs, etc.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
+
import { IconName } from "@trackunit/ui-icons";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { TextInputProps } from "../TextInput/TextInput";
|
|
4
5
|
export interface SearchProps extends CommonProps, TextInputProps {
|
|
@@ -59,6 +60,11 @@ export interface SearchProps extends CommonProps, TextInputProps {
|
|
|
59
60
|
* Indicates whether a loading spinner should be displayed in the search box.
|
|
60
61
|
*/
|
|
61
62
|
loading?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* A custom icon to be displayed in the search box.
|
|
65
|
+
*/
|
|
66
|
+
iconName?: IconName;
|
|
67
|
+
style?: React.CSSProperties;
|
|
62
68
|
}
|
|
63
69
|
/**
|
|
64
70
|
* The Search component is used to render a search input field.
|