@trackunit/react-form-components 0.1.62 → 0.1.63

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
@@ -147,7 +147,7 @@ const ActionButton = ({ type, value, dataTestId, iconSize, disabled, className }
147
147
  return "ClipboardDocument";
148
148
  }
149
149
  };
150
- const ButtonAction = () => {
150
+ const buttonAction = () => {
151
151
  var _a, _b;
152
152
  switch (type) {
153
153
  case "EMAIL":
@@ -168,7 +168,7 @@ const ActionButton = ({ type, value, dataTestId, iconSize, disabled, className }
168
168
  return null;
169
169
  }
170
170
  };
171
- return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className }), children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton({ size: iconSize }), dataTestId: dataTestId || "testIconButtonId", disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: getIconName(), size: "small" }), onClick: ButtonAction, size: "small", variant: "secondary" }) }));
171
+ return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className }), children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton({ size: iconSize }), dataTestId: dataTestId || "testIconButtonId", disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: getIconName(), size: "small" }), onClick: buttonAction, size: "small", variant: "secondary" }) }));
172
172
  };
173
173
 
174
174
  /**
@@ -237,7 +237,16 @@ const cvaInput = cssClassVarianceUtilities.cvaMerge(["relative", "flex", "h-10",
237
237
  },
238
238
  },
239
239
  });
240
- const cvaInputField = cssClassVarianceUtilities.cvaMerge(["w-full", "px-3", "border-0", "bg-transparent", "text-base", "text-slate-900", "placeholder-slate-400", "component-baseInput-border"], {
240
+ const cvaInputField = cssClassVarianceUtilities.cvaMerge([
241
+ "w-full",
242
+ "px-3",
243
+ "border-0",
244
+ "bg-transparent",
245
+ "text-base",
246
+ "text-slate-900",
247
+ "placeholder-slate-400",
248
+ "component-baseInput-border",
249
+ ], {
241
250
  variants: {
242
251
  size: {
243
252
  small: ["py-1"],
@@ -1712,7 +1721,9 @@ const cvaSearch = cssClassVarianceUtilities.cvaMerge([
1712
1721
  * @returns {JSX.Element} Search component
1713
1722
  */
1714
1723
  const Search = React.forwardRef(({ className, placeholder = "Search", value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", ...rest }, ref) => {
1715
- return (jsxRuntime.jsx(TextInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), dataTestId: dataTestId, disabled: disabled, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "MagnifyingGlass", size: "medium" }), ref: ref, suffix: onClear ? (jsxRuntime.jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
1724
+ return (jsxRuntime.jsx(TextInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), dataTestId: dataTestId, disabled: disabled, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "MagnifyingGlass", size: "medium" }), ref: ref, suffix:
1725
+ //only show the clear button if there is a value and the onClear function is provided
1726
+ onClear && value ? (jsxRuntime.jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
1716
1727
  onClear();
1717
1728
  }, type: "button", children: jsxRuntime.jsx(reactComponents.Icon, { name: "XMark", size: "small" }) })) : undefined, value: value }));
1718
1729
  });
package/index.esm.js CHANGED
@@ -128,7 +128,7 @@ const ActionButton = ({ type, value, dataTestId, iconSize, disabled, className }
128
128
  return "ClipboardDocument";
129
129
  }
130
130
  };
131
- const ButtonAction = () => {
131
+ const buttonAction = () => {
132
132
  var _a, _b;
133
133
  switch (type) {
134
134
  case "EMAIL":
@@ -149,7 +149,7 @@ const ActionButton = ({ type, value, dataTestId, iconSize, disabled, className }
149
149
  return null;
150
150
  }
151
151
  };
152
- return (jsx("div", { className: cvaActionContainer({ className }), children: jsx(IconButton, { className: cvaActionButton({ size: iconSize }), dataTestId: dataTestId || "testIconButtonId", disabled: disabled, icon: jsx(Icon, { name: getIconName(), size: "small" }), onClick: ButtonAction, size: "small", variant: "secondary" }) }));
152
+ return (jsx("div", { className: cvaActionContainer({ className }), children: jsx(IconButton, { className: cvaActionButton({ size: iconSize }), dataTestId: dataTestId || "testIconButtonId", disabled: disabled, icon: jsx(Icon, { name: getIconName(), size: "small" }), onClick: buttonAction, size: "small", variant: "secondary" }) }));
153
153
  };
154
154
 
155
155
  /**
@@ -218,7 +218,16 @@ const cvaInput = cvaMerge(["relative", "flex", "h-10", cvaInputBase()], {
218
218
  },
219
219
  },
220
220
  });
221
- const cvaInputField = cvaMerge(["w-full", "px-3", "border-0", "bg-transparent", "text-base", "text-slate-900", "placeholder-slate-400", "component-baseInput-border"], {
221
+ const cvaInputField = cvaMerge([
222
+ "w-full",
223
+ "px-3",
224
+ "border-0",
225
+ "bg-transparent",
226
+ "text-base",
227
+ "text-slate-900",
228
+ "placeholder-slate-400",
229
+ "component-baseInput-border",
230
+ ], {
222
231
  variants: {
223
232
  size: {
224
233
  small: ["py-1"],
@@ -1693,7 +1702,9 @@ const cvaSearch = cvaMerge([
1693
1702
  * @returns {JSX.Element} Search component
1694
1703
  */
1695
1704
  const Search = forwardRef(({ className, placeholder = "Search", value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", ...rest }, ref) => {
1696
- return (jsx(TextInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), dataTestId: dataTestId, disabled: disabled, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder, prefix: jsx(Icon, { name: "MagnifyingGlass", size: "medium" }), ref: ref, suffix: onClear ? (jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
1705
+ return (jsx(TextInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), dataTestId: dataTestId, disabled: disabled, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder, prefix: jsx(Icon, { name: "MagnifyingGlass", size: "medium" }), ref: ref, suffix:
1706
+ //only show the clear button if there is a value and the onClear function is provided
1707
+ onClear && value ? (jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
1697
1708
  onClear();
1698
1709
  }, type: "button", children: jsx(Icon, { name: "XMark", size: "small" }) })) : undefined, value: value }));
1699
1710
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-form-components",
3
- "version": "0.1.62",
3
+ "version": "0.1.63",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -1,6 +1,7 @@
1
+ import { VariantProps } from "@trackunit/css-class-variance-utilities";
1
2
  import { ButtonCommonProps, CommonProps } from "@trackunit/react-components";
3
+ import { cvaActionButton } from "./ActionButton.variants";
2
4
  type ActionType = "PHONE_NUMBER" | "WEB_ADDRESS" | "EMAIL" | "COPY";
3
- type FieldSize = "small" | "medium";
4
5
  interface AbstractActionButtonProps extends ButtonCommonProps, CommonProps {
5
6
  /**
6
7
  * The type of action performed when clicking the button.
@@ -13,7 +14,7 @@ interface AbstractActionButtonProps extends ButtonCommonProps, CommonProps {
13
14
  /**
14
15
  * The size of the icon.
15
16
  */
16
- iconSize?: FieldSize;
17
+ iconSize?: VariantProps<typeof cvaActionButton>["size"];
17
18
  }
18
19
  interface GenericActionButtonProps extends AbstractActionButtonProps {
19
20
  /**
@@ -1,9 +1,10 @@
1
+ import { VariantProps } from "@trackunit/css-class-variance-utilities";
1
2
  import { CommonProps } from "@trackunit/react-components";
2
3
  import { MappedOmit } from "@trackunit/shared-utils";
3
4
  import * as React from "react";
5
+ import { cvaInputField } from "./BaseInput.variants";
4
6
  import { DisabledForReasons } from "./DisabledForReasonsTip";
5
7
  type FilteredInputProps = MappedOmit<React.InputHTMLAttributes<HTMLInputElement>, "prefix" | "disabled">;
6
- type FieldSize = "small" | "medium";
7
8
  export interface BaseInputProps extends FilteredInputProps, CommonProps {
8
9
  /**
9
10
  * A React element to render before the text in the input.
@@ -38,7 +39,7 @@ export interface BaseInputProps extends FilteredInputProps, CommonProps {
38
39
  * The size of the input.
39
40
  * Default == 40px, Small == 32px.
40
41
  */
41
- fieldSize?: FieldSize;
42
+ fieldSize?: VariantProps<typeof cvaInputField>["size"];
42
43
  /**
43
44
  * If true the field is rendered in its invalid state.
44
45
  */