@trackunit/react-form-components 1.8.126 → 1.8.131
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 +14 -35
- package/index.esm.js +14 -35
- package/package.json +7 -7
- package/src/components/BaseSelect/useSelect.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -1577,10 +1577,10 @@ autoComplete, // see https://github.com/JedWatson/react-select/issues/758
|
|
|
1577
1577
|
return (jsxRuntime.jsx(ReactSelect.components.ClearIndicator, { ...selectClearIndicator, className: cvaSelectClearIndicator({ className: selectClearIndicator.className }), getStyles: getNoStyles, children: jsxRuntime.jsx(reactComponents.Icon, { ariaLabel: t("clearIndicator.icon.tooltip.clearAll"), "data-testid": `${dataTestId}-XMarkIcon`, name: "XCircle", size: "medium" }) }));
|
|
1578
1578
|
},
|
|
1579
1579
|
LoadingMessage: selectLoadingMessage => {
|
|
1580
|
-
return (jsxRuntime.jsx(ReactSelect.components.LoadingMessage, { ...selectLoadingMessage, className: cvaSelectLoadingMessage({ className: selectLoadingMessage.className }), getStyles: getNoStyles, children: t("select.loadingMessage") }));
|
|
1580
|
+
return (jsxRuntime.jsx(ReactSelect.components.LoadingMessage, { ...selectLoadingMessage, className: cvaSelectLoadingMessage({ className: selectLoadingMessage.className }), getStyles: getNoStyles, children: selectLoadingMessage.children ?? t("select.loadingMessage") }));
|
|
1581
1581
|
},
|
|
1582
1582
|
NoOptionsMessage: selectNoOptionsMessage => {
|
|
1583
|
-
return (jsxRuntime.jsx(ReactSelect.components.NoOptionsMessage, { ...selectNoOptionsMessage, className: cvaSelectNoOptionsMessage({ className: selectNoOptionsMessage.className }), getStyles: getNoStyles, children: t("select.noOptionsMessage") }));
|
|
1583
|
+
return (jsxRuntime.jsx(ReactSelect.components.NoOptionsMessage, { ...selectNoOptionsMessage, className: cvaSelectNoOptionsMessage({ className: selectNoOptionsMessage.className }), getStyles: getNoStyles, children: selectNoOptionsMessage.children ?? t("select.noOptionsMessage") }));
|
|
1584
1584
|
},
|
|
1585
1585
|
SingleValue: selectSingleValue => {
|
|
1586
1586
|
const optionPrefix = getOptionPrefix ? getOptionPrefix(selectSingleValue.data) : null;
|
|
@@ -1699,10 +1699,7 @@ const getPlaceholderElement = (children) => {
|
|
|
1699
1699
|
const useSelect = ({ disabled = false, //renaming to isDisabled, so not directly passed to react-select
|
|
1700
1700
|
"data-testid": dataTestId,
|
|
1701
1701
|
// Extract critical props that must trigger recalculation when they change
|
|
1702
|
-
onMenuOpen, onMenuClose, options, value,
|
|
1703
|
-
// restProps are pur in a ref to keep dependencies stable while always having the latest values
|
|
1704
|
-
// See explanation on restPropsRef below for more details 👇
|
|
1705
|
-
...restProps }) => {
|
|
1702
|
+
onMenuOpen, onMenuClose, options, value, ...restProps }) => {
|
|
1706
1703
|
const customComponents = useCustomComponents({
|
|
1707
1704
|
disabled, // intentionally not evaluated as boolean, since it can be object too!
|
|
1708
1705
|
readOnly: restProps.readOnly ?? false, // intentionally not evaluated as boolean, since it can be object too!
|
|
@@ -1745,28 +1742,14 @@ onMenuOpen, onMenuClose, options, value, onChange, defaultValue,
|
|
|
1745
1742
|
restoreScroll();
|
|
1746
1743
|
onMenuCloseRef.current?.();
|
|
1747
1744
|
}, [restoreScroll]);
|
|
1748
|
-
// Store restProps in a ref to keep dependencies stable while always having the latest values
|
|
1749
|
-
// This allows us to access restProps in useMemo without including them in the dependency array
|
|
1750
|
-
// Criteria for props in restProps:
|
|
1751
|
-
// - Props used in computations are already tracked via derived values (interactable, portalTarget, etc.)
|
|
1752
|
-
// - Other props are accessed via ref - they'll always be latest but won't trigger recalculation
|
|
1753
|
-
// This is a trade-off: we prioritize stability over perfect reactivity for less critical props
|
|
1754
|
-
const restPropsRef = react.useRef(restProps);
|
|
1755
|
-
react.useEffect(() => {
|
|
1756
|
-
restPropsRef.current = restProps;
|
|
1757
|
-
}, [restProps]);
|
|
1758
|
-
// eslint-disable-next-line react-hooks/refs
|
|
1759
1745
|
return react.useMemo(() => {
|
|
1760
|
-
const currentRestProps = restPropsRef.current;
|
|
1761
1746
|
return {
|
|
1762
|
-
...
|
|
1747
|
+
...restProps,
|
|
1763
1748
|
options,
|
|
1764
1749
|
value,
|
|
1765
|
-
onChange,
|
|
1766
|
-
defaultValue,
|
|
1767
1750
|
components: customComponents,
|
|
1768
1751
|
unstyled: true,
|
|
1769
|
-
"aria-label":
|
|
1752
|
+
"aria-label": restProps.label,
|
|
1770
1753
|
"data-testid": dataTestId ?? "select",
|
|
1771
1754
|
tabSelectsValue: false,
|
|
1772
1755
|
blurInputOnSelect: false,
|
|
@@ -1774,20 +1757,20 @@ onMenuOpen, onMenuClose, options, value, onChange, defaultValue,
|
|
|
1774
1757
|
// Setting menuPortalTarget to 'null' specifies that the dropdown should be rendered within
|
|
1775
1758
|
// the parent element instead of 'document.body'.
|
|
1776
1759
|
menuPortalTarget: portalTarget,
|
|
1777
|
-
isSearchable: interactable ? (
|
|
1760
|
+
isSearchable: interactable ? (restProps.isSearchable ?? true) : false,
|
|
1778
1761
|
// Disable react-select's built-in scroll blocking as we handle it ourselves in onMenuOpen/onMenuClose
|
|
1779
1762
|
// to prevent layout shifts caused by not accounting for existing body padding in the react-select implementation.
|
|
1780
1763
|
// See: https://github.com/JedWatson/react-select/issues/5342 AND https://github.com/JedWatson/react-select/issues/5020
|
|
1781
1764
|
menuShouldBlockScroll: false,
|
|
1782
1765
|
menuShouldScrollIntoView: true,
|
|
1783
|
-
openMenuOnClick: interactable ? (
|
|
1784
|
-
openMenuOnFocus: Boolean(
|
|
1785
|
-
closeMenuOnSelect: !Boolean(
|
|
1766
|
+
openMenuOnClick: interactable ? (restProps.openMenuOnClick ?? true) : false,
|
|
1767
|
+
openMenuOnFocus: Boolean(restProps.openMenuOnFocus),
|
|
1768
|
+
closeMenuOnSelect: !Boolean(restProps.isMulti),
|
|
1786
1769
|
isDisabled: Boolean(disabled),
|
|
1787
|
-
isClearable: Boolean(
|
|
1788
|
-
menuPlacement:
|
|
1789
|
-
placeholder: interactable ?
|
|
1790
|
-
hideSelectedOptions: Boolean(
|
|
1770
|
+
isClearable: Boolean(restProps.isClearable),
|
|
1771
|
+
menuPlacement: restProps.menuPlacement ?? "auto",
|
|
1772
|
+
placeholder: interactable ? restProps.placeholder : undefined,
|
|
1773
|
+
hideSelectedOptions: Boolean(restProps.hideSelectedOptions),
|
|
1791
1774
|
menuIsOpen: interactable ? undefined : false, // close it if not interactable, otherwise leave state to react-select
|
|
1792
1775
|
// Wire up our custom menu open/close handlers
|
|
1793
1776
|
onMenuOpen: handleMenuOpen,
|
|
@@ -1807,13 +1790,9 @@ onMenuOpen, onMenuClose, options, value, onChange, defaultValue,
|
|
|
1807
1790
|
handleMenuClose,
|
|
1808
1791
|
dataTestId,
|
|
1809
1792
|
portalTarget,
|
|
1810
|
-
// Critical props that must trigger recalculation when they change
|
|
1811
1793
|
options,
|
|
1812
1794
|
value,
|
|
1813
|
-
|
|
1814
|
-
defaultValue,
|
|
1815
|
-
// restPropsRef is intentionally not included - we access restPropsRef.current inside useMemo
|
|
1816
|
-
// to always get the latest restProps without causing recalculation when the object reference changes
|
|
1795
|
+
restProps,
|
|
1817
1796
|
]);
|
|
1818
1797
|
};
|
|
1819
1798
|
|
package/index.esm.js
CHANGED
|
@@ -1576,10 +1576,10 @@ autoComplete, // see https://github.com/JedWatson/react-select/issues/758
|
|
|
1576
1576
|
return (jsx(components.ClearIndicator, { ...selectClearIndicator, className: cvaSelectClearIndicator({ className: selectClearIndicator.className }), getStyles: getNoStyles, children: jsx(Icon, { ariaLabel: t("clearIndicator.icon.tooltip.clearAll"), "data-testid": `${dataTestId}-XMarkIcon`, name: "XCircle", size: "medium" }) }));
|
|
1577
1577
|
},
|
|
1578
1578
|
LoadingMessage: selectLoadingMessage => {
|
|
1579
|
-
return (jsx(components.LoadingMessage, { ...selectLoadingMessage, className: cvaSelectLoadingMessage({ className: selectLoadingMessage.className }), getStyles: getNoStyles, children: t("select.loadingMessage") }));
|
|
1579
|
+
return (jsx(components.LoadingMessage, { ...selectLoadingMessage, className: cvaSelectLoadingMessage({ className: selectLoadingMessage.className }), getStyles: getNoStyles, children: selectLoadingMessage.children ?? t("select.loadingMessage") }));
|
|
1580
1580
|
},
|
|
1581
1581
|
NoOptionsMessage: selectNoOptionsMessage => {
|
|
1582
|
-
return (jsx(components.NoOptionsMessage, { ...selectNoOptionsMessage, className: cvaSelectNoOptionsMessage({ className: selectNoOptionsMessage.className }), getStyles: getNoStyles, children: t("select.noOptionsMessage") }));
|
|
1582
|
+
return (jsx(components.NoOptionsMessage, { ...selectNoOptionsMessage, className: cvaSelectNoOptionsMessage({ className: selectNoOptionsMessage.className }), getStyles: getNoStyles, children: selectNoOptionsMessage.children ?? t("select.noOptionsMessage") }));
|
|
1583
1583
|
},
|
|
1584
1584
|
SingleValue: selectSingleValue => {
|
|
1585
1585
|
const optionPrefix = getOptionPrefix ? getOptionPrefix(selectSingleValue.data) : null;
|
|
@@ -1698,10 +1698,7 @@ const getPlaceholderElement = (children) => {
|
|
|
1698
1698
|
const useSelect = ({ disabled = false, //renaming to isDisabled, so not directly passed to react-select
|
|
1699
1699
|
"data-testid": dataTestId,
|
|
1700
1700
|
// Extract critical props that must trigger recalculation when they change
|
|
1701
|
-
onMenuOpen, onMenuClose, options, value,
|
|
1702
|
-
// restProps are pur in a ref to keep dependencies stable while always having the latest values
|
|
1703
|
-
// See explanation on restPropsRef below for more details 👇
|
|
1704
|
-
...restProps }) => {
|
|
1701
|
+
onMenuOpen, onMenuClose, options, value, ...restProps }) => {
|
|
1705
1702
|
const customComponents = useCustomComponents({
|
|
1706
1703
|
disabled, // intentionally not evaluated as boolean, since it can be object too!
|
|
1707
1704
|
readOnly: restProps.readOnly ?? false, // intentionally not evaluated as boolean, since it can be object too!
|
|
@@ -1744,28 +1741,14 @@ onMenuOpen, onMenuClose, options, value, onChange, defaultValue,
|
|
|
1744
1741
|
restoreScroll();
|
|
1745
1742
|
onMenuCloseRef.current?.();
|
|
1746
1743
|
}, [restoreScroll]);
|
|
1747
|
-
// Store restProps in a ref to keep dependencies stable while always having the latest values
|
|
1748
|
-
// This allows us to access restProps in useMemo without including them in the dependency array
|
|
1749
|
-
// Criteria for props in restProps:
|
|
1750
|
-
// - Props used in computations are already tracked via derived values (interactable, portalTarget, etc.)
|
|
1751
|
-
// - Other props are accessed via ref - they'll always be latest but won't trigger recalculation
|
|
1752
|
-
// This is a trade-off: we prioritize stability over perfect reactivity for less critical props
|
|
1753
|
-
const restPropsRef = useRef(restProps);
|
|
1754
|
-
useEffect(() => {
|
|
1755
|
-
restPropsRef.current = restProps;
|
|
1756
|
-
}, [restProps]);
|
|
1757
|
-
// eslint-disable-next-line react-hooks/refs
|
|
1758
1744
|
return useMemo(() => {
|
|
1759
|
-
const currentRestProps = restPropsRef.current;
|
|
1760
1745
|
return {
|
|
1761
|
-
...
|
|
1746
|
+
...restProps,
|
|
1762
1747
|
options,
|
|
1763
1748
|
value,
|
|
1764
|
-
onChange,
|
|
1765
|
-
defaultValue,
|
|
1766
1749
|
components: customComponents,
|
|
1767
1750
|
unstyled: true,
|
|
1768
|
-
"aria-label":
|
|
1751
|
+
"aria-label": restProps.label,
|
|
1769
1752
|
"data-testid": dataTestId ?? "select",
|
|
1770
1753
|
tabSelectsValue: false,
|
|
1771
1754
|
blurInputOnSelect: false,
|
|
@@ -1773,20 +1756,20 @@ onMenuOpen, onMenuClose, options, value, onChange, defaultValue,
|
|
|
1773
1756
|
// Setting menuPortalTarget to 'null' specifies that the dropdown should be rendered within
|
|
1774
1757
|
// the parent element instead of 'document.body'.
|
|
1775
1758
|
menuPortalTarget: portalTarget,
|
|
1776
|
-
isSearchable: interactable ? (
|
|
1759
|
+
isSearchable: interactable ? (restProps.isSearchable ?? true) : false,
|
|
1777
1760
|
// Disable react-select's built-in scroll blocking as we handle it ourselves in onMenuOpen/onMenuClose
|
|
1778
1761
|
// to prevent layout shifts caused by not accounting for existing body padding in the react-select implementation.
|
|
1779
1762
|
// See: https://github.com/JedWatson/react-select/issues/5342 AND https://github.com/JedWatson/react-select/issues/5020
|
|
1780
1763
|
menuShouldBlockScroll: false,
|
|
1781
1764
|
menuShouldScrollIntoView: true,
|
|
1782
|
-
openMenuOnClick: interactable ? (
|
|
1783
|
-
openMenuOnFocus: Boolean(
|
|
1784
|
-
closeMenuOnSelect: !Boolean(
|
|
1765
|
+
openMenuOnClick: interactable ? (restProps.openMenuOnClick ?? true) : false,
|
|
1766
|
+
openMenuOnFocus: Boolean(restProps.openMenuOnFocus),
|
|
1767
|
+
closeMenuOnSelect: !Boolean(restProps.isMulti),
|
|
1785
1768
|
isDisabled: Boolean(disabled),
|
|
1786
|
-
isClearable: Boolean(
|
|
1787
|
-
menuPlacement:
|
|
1788
|
-
placeholder: interactable ?
|
|
1789
|
-
hideSelectedOptions: Boolean(
|
|
1769
|
+
isClearable: Boolean(restProps.isClearable),
|
|
1770
|
+
menuPlacement: restProps.menuPlacement ?? "auto",
|
|
1771
|
+
placeholder: interactable ? restProps.placeholder : undefined,
|
|
1772
|
+
hideSelectedOptions: Boolean(restProps.hideSelectedOptions),
|
|
1790
1773
|
menuIsOpen: interactable ? undefined : false, // close it if not interactable, otherwise leave state to react-select
|
|
1791
1774
|
// Wire up our custom menu open/close handlers
|
|
1792
1775
|
onMenuOpen: handleMenuOpen,
|
|
@@ -1806,13 +1789,9 @@ onMenuOpen, onMenuClose, options, value, onChange, defaultValue,
|
|
|
1806
1789
|
handleMenuClose,
|
|
1807
1790
|
dataTestId,
|
|
1808
1791
|
portalTarget,
|
|
1809
|
-
// Critical props that must trigger recalculation when they change
|
|
1810
1792
|
options,
|
|
1811
1793
|
value,
|
|
1812
|
-
|
|
1813
|
-
defaultValue,
|
|
1814
|
-
// restPropsRef is intentionally not included - we access restPropsRef.current inside useMemo
|
|
1815
|
-
// to always get the latest restProps without causing recalculation when the object reference changes
|
|
1794
|
+
restProps,
|
|
1816
1795
|
]);
|
|
1817
1796
|
};
|
|
1818
1797
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.131",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"zod": "^3.23.8",
|
|
15
15
|
"react-hook-form": "7.62.0",
|
|
16
16
|
"tailwind-merge": "^2.0.0",
|
|
17
|
-
"@trackunit/css-class-variance-utilities": "1.7.
|
|
18
|
-
"@trackunit/react-components": "1.10.
|
|
19
|
-
"@trackunit/ui-icons": "1.7.
|
|
20
|
-
"@trackunit/shared-utils": "1.9.
|
|
21
|
-
"@trackunit/ui-design-tokens": "1.7.
|
|
22
|
-
"@trackunit/i18n-library-translation": "1.7.
|
|
17
|
+
"@trackunit/css-class-variance-utilities": "1.7.86",
|
|
18
|
+
"@trackunit/react-components": "1.10.61",
|
|
19
|
+
"@trackunit/ui-icons": "1.7.87",
|
|
20
|
+
"@trackunit/shared-utils": "1.9.86",
|
|
21
|
+
"@trackunit/ui-design-tokens": "1.7.86",
|
|
22
|
+
"@trackunit/i18n-library-translation": "1.7.104",
|
|
23
23
|
"string-ts": "^2.0.0",
|
|
24
24
|
"@js-temporal/polyfill": "^0.5.1",
|
|
25
25
|
"es-toolkit": "^1.39.10",
|
|
@@ -134,4 +134,4 @@ export type SelectProps<TOption, TIsAsync extends boolean = false, TIsMulti exte
|
|
|
134
134
|
* @param {SelectProps} props - The props for the Select component
|
|
135
135
|
* @returns {ReactSelectProps} Props for react-select component
|
|
136
136
|
*/
|
|
137
|
-
export declare const useSelect: <TOption, TIsAsync extends boolean = false, TIsMulti extends boolean = false, TGroup extends GroupBase<TOption> = GroupBase<TOption>>({ disabled, "data-testid": dataTestId, onMenuOpen, onMenuClose, options, value,
|
|
137
|
+
export declare const useSelect: <TOption, TIsAsync extends boolean = false, TIsMulti extends boolean = false, TGroup extends GroupBase<TOption> = GroupBase<TOption>>({ disabled, "data-testid": dataTestId, onMenuOpen, onMenuClose, options, value, ...restProps }: SelectProps<TOption, TIsAsync, TIsMulti, TGroup>) => ReactSelectProps<TOption, TIsMulti, TGroup>;
|