@trackunit/react-form-components 1.13.7 → 1.13.8

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
@@ -3602,13 +3602,15 @@ const cvaSearch = cssClassVarianceUtilities.cvaMerge([
3602
3602
  *
3603
3603
  * @param {SearchProps} props - The props for the Search component
3604
3604
  */
3605
- const Search = ({ className, placeholder, value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled = false, onKeyUp, onChange, onFocus, onBlur, name, onClear, "data-testid": dataTestId, autoComplete = "on", loading = false, inputClassName, iconName = "MagnifyingGlass", style, xMarkRef, ref, ...rest }) => {
3605
+ const Search = ({ className, placeholder, value, widenInputOnFocus = false, hideBorderWhenNotInFocus = false, disabled = false, onKeyUp, onChange, onFocus, onBlur, name, onClear, "data-testid": dataTestId, autoComplete = "on", loading = false, inputClassName, iconName = "MagnifyingGlass", style, ref, fieldSize = "medium", id, ...rest }) => {
3606
3606
  const { t } = useTranslation();
3607
- return (jsxRuntime.jsx(TextBaseInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), "data-testid": dataTestId, disabled: disabled, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder ?? t("search.placeholder"), prefix: loading ? (jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", size: rest.fieldSize ?? undefined })) : (jsxRuntime.jsx(reactComponents.Icon, { name: iconName, size: rest.fieldSize ?? undefined })), ref: ref, suffix:
3607
+ const generatedId = react.useId();
3608
+ const inputId = id ?? `search-${generatedId}`;
3609
+ return (jsxRuntime.jsx(TextBaseInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), "data-testid": dataTestId, disabled: disabled, fieldSize: fieldSize, id: inputId, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder ?? t("search.placeholder"), prefix: loading ? (jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", containerClassName: "!p-0", size: fieldSize })) : (jsxRuntime.jsx(reactComponents.Icon, { name: iconName, size: fieldSize })), ref: ref, suffix:
3608
3610
  //only show the clear button if there is a value and the onClear function is provided
3609
3611
  onClear && value ? (jsxRuntime.jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
3610
3612
  onClear();
3611
- }, ref: xMarkRef, type: "button", children: jsxRuntime.jsx(reactComponents.Icon, { name: "XMark", size: "small" }) })) : undefined, value: value }));
3613
+ }, type: "button", children: jsxRuntime.jsx(reactComponents.Icon, { name: "XMark", size: "small" }) })) : undefined, value: value }));
3612
3614
  };
3613
3615
  Search.displayName = "Search";
3614
3616
 
package/index.esm.js CHANGED
@@ -3,7 +3,7 @@ import { useNamespaceTranslation, registerTranslations, NamespaceTrans } from '@
3
3
  import { Temporal } from '@js-temporal/polyfill';
4
4
  import { IconButton, Icon, Tooltip, cvaMenu, cvaMenuList, Tag, useIsTextTruncated, ZStack, MenuItem, useMeasure, useDebounce, useMergeRefs, Spinner, useScrollBlock, Text, Heading, useIsFirstRender } from '@trackunit/react-components';
5
5
  import { themeSpacing } from '@trackunit/ui-design-tokens';
6
- import { forwardRef, useRef, useEffect, useImperativeHandle, useCallback, useState, cloneElement, isValidElement, useLayoutEffect, useReducer, useMemo, createContext, useContext } from 'react';
6
+ import { forwardRef, useRef, useEffect, useImperativeHandle, useCallback, useState, cloneElement, isValidElement, useLayoutEffect, useReducer, useMemo, createContext, useContext, useId } from 'react';
7
7
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
8
8
  import { titleCase } from 'string-ts';
9
9
  import { useCopyToClipboard } from 'usehooks-ts';
@@ -3601,13 +3601,15 @@ const cvaSearch = cvaMerge([
3601
3601
  *
3602
3602
  * @param {SearchProps} props - The props for the Search component
3603
3603
  */
3604
- const Search = ({ className, placeholder, value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled = false, onKeyUp, onChange, onFocus, onBlur, name, onClear, "data-testid": dataTestId, autoComplete = "on", loading = false, inputClassName, iconName = "MagnifyingGlass", style, xMarkRef, ref, ...rest }) => {
3604
+ const Search = ({ className, placeholder, value, widenInputOnFocus = false, hideBorderWhenNotInFocus = false, disabled = false, onKeyUp, onChange, onFocus, onBlur, name, onClear, "data-testid": dataTestId, autoComplete = "on", loading = false, inputClassName, iconName = "MagnifyingGlass", style, ref, fieldSize = "medium", id, ...rest }) => {
3605
3605
  const { t } = useTranslation();
3606
- return (jsx(TextBaseInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), "data-testid": dataTestId, disabled: disabled, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder ?? t("search.placeholder"), prefix: loading ? (jsx(Spinner, { centering: "centered", size: rest.fieldSize ?? undefined })) : (jsx(Icon, { name: iconName, size: rest.fieldSize ?? undefined })), ref: ref, suffix:
3606
+ const generatedId = useId();
3607
+ const inputId = id ?? `search-${generatedId}`;
3608
+ return (jsx(TextBaseInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), "data-testid": dataTestId, disabled: disabled, fieldSize: fieldSize, id: inputId, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder ?? t("search.placeholder"), prefix: loading ? (jsx(Spinner, { centering: "centered", containerClassName: "!p-0", size: fieldSize })) : (jsx(Icon, { name: iconName, size: fieldSize })), ref: ref, suffix:
3607
3609
  //only show the clear button if there is a value and the onClear function is provided
3608
3610
  onClear && value ? (jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
3609
3611
  onClear();
3610
- }, ref: xMarkRef, type: "button", children: jsx(Icon, { name: "XMark", size: "small" }) })) : undefined, value: value }));
3612
+ }, type: "button", children: jsx(Icon, { name: "XMark", size: "small" }) })) : undefined, value: value }));
3611
3613
  };
3612
3614
  Search.displayName = "Search";
3613
3615
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-form-components",
3
- "version": "1.13.7",
3
+ "version": "1.13.8",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -15,7 +15,7 @@
15
15
  "react-hook-form": "7.62.0",
16
16
  "tailwind-merge": "^2.0.0",
17
17
  "@trackunit/css-class-variance-utilities": "1.11.26",
18
- "@trackunit/react-components": "1.16.7",
18
+ "@trackunit/react-components": "1.16.8",
19
19
  "@trackunit/ui-icons": "1.11.25",
20
20
  "@trackunit/shared-utils": "1.13.26",
21
21
  "@trackunit/ui-design-tokens": "1.11.26",
@@ -1,6 +1,6 @@
1
1
  import { CommonProps } from "@trackunit/react-components";
2
2
  import { IconName } from "@trackunit/ui-icons";
3
- import { CSSProperties, ChangeEvent, FocusEvent, KeyboardEvent, Ref } from "react";
3
+ import { CSSProperties, ChangeEvent, FocusEvent, KeyboardEvent, ReactElement, Ref } from "react";
4
4
  import { TextBaseInputProps } from "../TextField/TextBaseInput/TextBaseInput";
5
5
  export interface SearchProps extends CommonProps, TextBaseInputProps {
6
6
  /**
@@ -69,10 +69,6 @@ export interface SearchProps extends CommonProps, TextBaseInputProps {
69
69
  */
70
70
  iconName?: IconName;
71
71
  style?: CSSProperties;
72
- /**
73
- * Ref object for the "Clear" button (with the XMark icon), allowing external control of the button.
74
- */
75
- xMarkRef?: Ref<HTMLButtonElement>;
76
72
  }
77
73
  /**
78
74
  * The Search component is used to render a search input field.
@@ -80,6 +76,6 @@ export interface SearchProps extends CommonProps, TextBaseInputProps {
80
76
  * @param {SearchProps} props - The props for the Search component
81
77
  */
82
78
  export declare const Search: {
83
- ({ className, placeholder, value, widenInputOnFocus, hideBorderWhenNotInFocus, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, "data-testid": dataTestId, autoComplete, loading, inputClassName, iconName, style, xMarkRef, ref, ...rest }: SearchProps): import("react/jsx-runtime").JSX.Element;
79
+ ({ className, placeholder, value, widenInputOnFocus, hideBorderWhenNotInFocus, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, "data-testid": dataTestId, autoComplete, loading, inputClassName, iconName, style, ref, fieldSize, id, ...rest }: SearchProps): ReactElement;
84
80
  displayName: string;
85
81
  };