@trackunit/react-form-components 1.0.19 → 1.0.20
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
|
@@ -1934,7 +1934,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
|
|
|
1934
1934
|
* @param {Partial<SelectComponents<Option, IsMulti, Group>> | undefined} componentsProps a custom component prop that you can to override defaults
|
|
1935
1935
|
* @param {boolean} disabled decide to override disabled variant
|
|
1936
1936
|
* @param {boolean} menuIsOpen menu is open state
|
|
1937
|
-
* @param {
|
|
1937
|
+
* @param {MutableRefObject<boolean>} refMenuIsEnabled a flag to block menu from open
|
|
1938
1938
|
* @param {string} dataTestId a test id
|
|
1939
1939
|
* @param {number} maxSelectedDisplayCount a number of max display count
|
|
1940
1940
|
* @param {JSX.Element} dropdownIcon an custom dropdown icon
|
|
@@ -1945,7 +1945,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
|
|
|
1945
1945
|
const useCustomComponents = ({ componentsProps, disabled, readOnly, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon, prefix, hasError, getOptionLabelDescription, }) => {
|
|
1946
1946
|
const [t] = useTranslation();
|
|
1947
1947
|
// perhaps it should not be wrap in memo (causing some issues with opening and closing on mobiles)
|
|
1948
|
-
const customComponents =
|
|
1948
|
+
const customComponents = React.useMemo(() => {
|
|
1949
1949
|
return {
|
|
1950
1950
|
ValueContainer: props => {
|
|
1951
1951
|
if (props.isMulti && Array.isArray(props.children) && props.children.length > 0) {
|
|
@@ -1994,7 +1994,12 @@ const useCustomComponents = ({ componentsProps, disabled, readOnly, refMenuIsEna
|
|
|
1994
1994
|
if (disabled) {
|
|
1995
1995
|
return null;
|
|
1996
1996
|
}
|
|
1997
|
-
return (jsxRuntime.jsx(ReactSelect.components.ClearIndicator, { ...props,
|
|
1997
|
+
return (jsxRuntime.jsx(ReactSelect.components.ClearIndicator, { ...props, innerProps: {
|
|
1998
|
+
...props.innerProps,
|
|
1999
|
+
onMouseDown: e => {
|
|
2000
|
+
e.preventDefault();
|
|
2001
|
+
},
|
|
2002
|
+
}, children: jsxRuntime.jsx("div", { className: cvaSelectXIcon(), "data-testid": dataTestId ? `${dataTestId}-XMarkIcon` : null, onClick: props.clearValue, children: jsxRuntime.jsx(reactComponents.Icon, { ariaLabel: t("clearIndicator.icon.tooltip.clearAll"), name: "XCircle", size: "medium" }) }) }));
|
|
1998
2003
|
},
|
|
1999
2004
|
Control: props => {
|
|
2000
2005
|
return (jsxRuntime.jsx(ReactSelect.components.Control, { ...props, className: cvaSelectControl({
|
package/index.esm.js
CHANGED
|
@@ -1915,7 +1915,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
|
|
|
1915
1915
|
* @param {Partial<SelectComponents<Option, IsMulti, Group>> | undefined} componentsProps a custom component prop that you can to override defaults
|
|
1916
1916
|
* @param {boolean} disabled decide to override disabled variant
|
|
1917
1917
|
* @param {boolean} menuIsOpen menu is open state
|
|
1918
|
-
* @param {
|
|
1918
|
+
* @param {MutableRefObject<boolean>} refMenuIsEnabled a flag to block menu from open
|
|
1919
1919
|
* @param {string} dataTestId a test id
|
|
1920
1920
|
* @param {number} maxSelectedDisplayCount a number of max display count
|
|
1921
1921
|
* @param {JSX.Element} dropdownIcon an custom dropdown icon
|
|
@@ -1926,7 +1926,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
|
|
|
1926
1926
|
const useCustomComponents = ({ componentsProps, disabled, readOnly, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon, prefix, hasError, getOptionLabelDescription, }) => {
|
|
1927
1927
|
const [t] = useTranslation();
|
|
1928
1928
|
// perhaps it should not be wrap in memo (causing some issues with opening and closing on mobiles)
|
|
1929
|
-
const customComponents =
|
|
1929
|
+
const customComponents = useMemo(() => {
|
|
1930
1930
|
return {
|
|
1931
1931
|
ValueContainer: props => {
|
|
1932
1932
|
if (props.isMulti && Array.isArray(props.children) && props.children.length > 0) {
|
|
@@ -1975,7 +1975,12 @@ const useCustomComponents = ({ componentsProps, disabled, readOnly, refMenuIsEna
|
|
|
1975
1975
|
if (disabled) {
|
|
1976
1976
|
return null;
|
|
1977
1977
|
}
|
|
1978
|
-
return (jsx(components.ClearIndicator, { ...props,
|
|
1978
|
+
return (jsx(components.ClearIndicator, { ...props, innerProps: {
|
|
1979
|
+
...props.innerProps,
|
|
1980
|
+
onMouseDown: e => {
|
|
1981
|
+
e.preventDefault();
|
|
1982
|
+
},
|
|
1983
|
+
}, children: jsx("div", { className: cvaSelectXIcon(), "data-testid": dataTestId ? `${dataTestId}-XMarkIcon` : null, onClick: props.clearValue, children: jsx(Icon, { ariaLabel: t("clearIndicator.icon.tooltip.clearAll"), name: "XCircle", size: "medium" }) }) }));
|
|
1979
1984
|
},
|
|
1980
1985
|
Control: props => {
|
|
1981
1986
|
return (jsx(components.Control, { ...props, className: cvaSelectControl({
|
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.20",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -18,7 +18,7 @@
|
|
|
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.1.
|
|
21
|
+
"@trackunit/react-components": "^1.1.2",
|
|
22
22
|
"@trackunit/ui-icons": "^1.0.4",
|
|
23
23
|
"@trackunit/shared-utils": "^1.0.3",
|
|
24
24
|
"@trackunit/i18n-library-translation": "^1.0.8"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { MutableRefObject } from "react";
|
|
2
2
|
import { GroupBase } from "react-select";
|
|
3
3
|
import { SelectComponents } from "react-select/dist/declarations/src/components";
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ import { SelectComponents } from "react-select/dist/declarations/src/components"
|
|
|
10
10
|
* @param {Partial<SelectComponents<Option, IsMulti, Group>> | undefined} componentsProps a custom component prop that you can to override defaults
|
|
11
11
|
* @param {boolean} disabled decide to override disabled variant
|
|
12
12
|
* @param {boolean} menuIsOpen menu is open state
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {MutableRefObject<boolean>} refMenuIsEnabled a flag to block menu from open
|
|
14
14
|
* @param {string} dataTestId a test id
|
|
15
15
|
* @param {number} maxSelectedDisplayCount a number of max display count
|
|
16
16
|
* @param {JSX.Element} dropdownIcon an custom dropdown icon
|
|
@@ -22,7 +22,7 @@ export declare const useCustomComponents: <Option, IsMulti extends boolean = fal
|
|
|
22
22
|
componentsProps: Partial<SelectComponents<Option, IsMulti, Group>> | undefined;
|
|
23
23
|
disabled: boolean;
|
|
24
24
|
readOnly: boolean;
|
|
25
|
-
refMenuIsEnabled:
|
|
25
|
+
refMenuIsEnabled: MutableRefObject<boolean>;
|
|
26
26
|
dataTestId: string;
|
|
27
27
|
maxSelectedDisplayCount: number | undefined;
|
|
28
28
|
dropdownIcon?: JSX.Element;
|
|
@@ -12,9 +12,9 @@ import { BaseOptionType } from "./FormFieldSelectAdapter";
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const CreatableSelectField: import("react").ForwardRefExoticComponent<import("dist/libs/react/components/src").CommonProps & {
|
|
14
14
|
label: string | React.ReactNode;
|
|
15
|
-
tip?:
|
|
16
|
-
helpText?:
|
|
17
|
-
helpAddon?:
|
|
15
|
+
tip?: import("react").ReactNode;
|
|
16
|
+
helpText?: string | null | undefined;
|
|
17
|
+
helpAddon?: import("react").ReactNode;
|
|
18
18
|
isInvalid?: boolean | undefined;
|
|
19
19
|
} & import("dist/libs/shared/utils/src").MappedOmit<import("../Select/useSelect").SelectProps<BaseOptionType, false, false, import("react-select").GroupBase<BaseOptionType>>, "label" | "onBlur" | "onChange" | "options" | "value" | "defaultValue"> & {
|
|
20
20
|
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
@@ -11,9 +11,9 @@ import { BaseOptionType } from "./FormFieldSelectAdapter";
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const SelectField: import("react").ForwardRefExoticComponent<import("dist/libs/react/components/src").CommonProps & {
|
|
13
13
|
label: string | React.ReactNode;
|
|
14
|
-
tip?:
|
|
15
|
-
helpText?:
|
|
16
|
-
helpAddon?:
|
|
14
|
+
tip?: import("react").ReactNode;
|
|
15
|
+
helpText?: string | null | undefined;
|
|
16
|
+
helpAddon?: import("react").ReactNode;
|
|
17
17
|
isInvalid?: boolean | undefined;
|
|
18
18
|
} & import("dist/libs/shared/utils/src").MappedOmit<import("../Select/useSelect").SelectProps<BaseOptionType, false, false, import("react-select").GroupBase<BaseOptionType>>, "label" | "onBlur" | "onChange" | "options" | "value" | "defaultValue"> & {
|
|
19
19
|
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|