@trackunit/react-form-components 2.6.18-alpha-95d9a652800.0 → 2.6.18-alpha-62031fc7c43.0
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 +3 -8
- package/index.esm.js +4 -9
- package/package.json +8 -8
package/index.cjs.js
CHANGED
|
@@ -4860,6 +4860,7 @@ Search.displayName = "Search";
|
|
|
4860
4860
|
*
|
|
4861
4861
|
*/
|
|
4862
4862
|
const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = false, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, style, ref, required = false, ...rest }) => {
|
|
4863
|
+
const isFirstRender = reactComponents.useIsFirstRender();
|
|
4863
4864
|
const [innerValue, setInnerValue] = react.useState(value ?? defaultValue);
|
|
4864
4865
|
const onChangeRef = react.useRef(onChange);
|
|
4865
4866
|
react.useEffect(() => {
|
|
@@ -4879,23 +4880,17 @@ const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText
|
|
|
4879
4880
|
const innerRef = react.useRef(null);
|
|
4880
4881
|
// eslint-disable-next-line @trackunit/no-typescript-assertion, @typescript-eslint/no-non-null-assertion
|
|
4881
4882
|
react.useImperativeHandle(ref, () => innerRef.current, []);
|
|
4882
|
-
// Bridges a react-select pick back to the hidden native <select> so `register`/native form
|
|
4883
|
-
// consumers see a real change event. It must fire only when the value actually changes: seeding
|
|
4884
|
-
// the ref with the initial value means mounting with a value is not reported as a change, which
|
|
4885
|
-
// would otherwise write to the consumer's form and mark it dirty with no user interaction.
|
|
4886
|
-
const lastNotifiedValueRef = react.useRef(innerValue);
|
|
4887
4883
|
react.useEffect(() => {
|
|
4888
|
-
if (
|
|
4884
|
+
if (isFirstRender || innerValue === undefined) {
|
|
4889
4885
|
return;
|
|
4890
4886
|
}
|
|
4891
|
-
lastNotifiedValueRef.current = innerValue;
|
|
4892
4887
|
const event = new Event("change");
|
|
4893
4888
|
if (innerValue === "" && innerRef.current) {
|
|
4894
4889
|
innerRef.current.value = ""; // Set the desired option value
|
|
4895
4890
|
}
|
|
4896
4891
|
innerRef.current?.dispatchEvent(event);
|
|
4897
4892
|
onChangeRef.current?.(event);
|
|
4898
|
-
}, [innerValue]);
|
|
4893
|
+
}, [innerValue, isFirstRender]);
|
|
4899
4894
|
const optionsWithCurrentSelectionBackupOption = [
|
|
4900
4895
|
// Add the current selection in case there's no options loaded yet (in CreatableSelect)
|
|
4901
4896
|
// Also _don't_ add it if it's a duplicate
|
package/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { registerTranslations, useNamespaceTranslation, NamespaceTrans } from '@trackunit/i18n-library-translation';
|
|
3
|
-
import { IconButton, Icon, Tooltip, Button, Popover, PopoverTrigger, PopoverContent, cvaMenu, cvaMenuList, Tag, useIsTextTruncated, ZStack, MenuItem, useMeasure, useDebounce, useMergeRefs, Spinner, useScrollBlock, Text, Heading } from '@trackunit/react-components';
|
|
3
|
+
import { IconButton, Icon, Tooltip, Button, Popover, PopoverTrigger, PopoverContent, cvaMenu, cvaMenuList, Tag, useIsTextTruncated, ZStack, MenuItem, useMeasure, useDebounce, useMergeRefs, Spinner, useScrollBlock, Text, Heading, useIsFirstRender } from '@trackunit/react-components';
|
|
4
4
|
import { useMemo, useRef, useEffect, useImperativeHandle, useState, useCallback, useLayoutEffect, isValidElement, cloneElement, useReducer, createContext, useContext, useId } from 'react';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
@@ -4859,6 +4859,7 @@ Search.displayName = "Search";
|
|
|
4859
4859
|
*
|
|
4860
4860
|
*/
|
|
4861
4861
|
const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = false, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, style, ref, required = false, ...rest }) => {
|
|
4862
|
+
const isFirstRender = useIsFirstRender();
|
|
4862
4863
|
const [innerValue, setInnerValue] = useState(value ?? defaultValue);
|
|
4863
4864
|
const onChangeRef = useRef(onChange);
|
|
4864
4865
|
useEffect(() => {
|
|
@@ -4878,23 +4879,17 @@ const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText
|
|
|
4878
4879
|
const innerRef = useRef(null);
|
|
4879
4880
|
// eslint-disable-next-line @trackunit/no-typescript-assertion, @typescript-eslint/no-non-null-assertion
|
|
4880
4881
|
useImperativeHandle(ref, () => innerRef.current, []);
|
|
4881
|
-
// Bridges a react-select pick back to the hidden native <select> so `register`/native form
|
|
4882
|
-
// consumers see a real change event. It must fire only when the value actually changes: seeding
|
|
4883
|
-
// the ref with the initial value means mounting with a value is not reported as a change, which
|
|
4884
|
-
// would otherwise write to the consumer's form and mark it dirty with no user interaction.
|
|
4885
|
-
const lastNotifiedValueRef = useRef(innerValue);
|
|
4886
4882
|
useEffect(() => {
|
|
4887
|
-
if (
|
|
4883
|
+
if (isFirstRender || innerValue === undefined) {
|
|
4888
4884
|
return;
|
|
4889
4885
|
}
|
|
4890
|
-
lastNotifiedValueRef.current = innerValue;
|
|
4891
4886
|
const event = new Event("change");
|
|
4892
4887
|
if (innerValue === "" && innerRef.current) {
|
|
4893
4888
|
innerRef.current.value = ""; // Set the desired option value
|
|
4894
4889
|
}
|
|
4895
4890
|
innerRef.current?.dispatchEvent(event);
|
|
4896
4891
|
onChangeRef.current?.(event);
|
|
4897
|
-
}, [innerValue]);
|
|
4892
|
+
}, [innerValue, isFirstRender]);
|
|
4898
4893
|
const optionsWithCurrentSelectionBackupOption = [
|
|
4899
4894
|
// Add the current selection in case there's no options loaded yet (in CreatableSelect)
|
|
4900
4895
|
// Also _don't_ add it if it's a duplicate
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "2.6.18-alpha-
|
|
3
|
+
"version": "2.6.18-alpha-62031fc7c43.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"migrations": "./migrations.json",
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"react-calendar": "^6.0.0",
|
|
12
12
|
"react-select": "^5.10.2",
|
|
13
|
-
"@trackunit/date-and-time-utils": "1.14.20-alpha-
|
|
13
|
+
"@trackunit/date-and-time-utils": "1.14.20-alpha-62031fc7c43.0",
|
|
14
14
|
"usehooks-ts": "^3.1.0",
|
|
15
15
|
"libphonenumber-js": "^1.13.6",
|
|
16
16
|
"zod": "^3.25.76",
|
|
17
17
|
"tailwind-merge": "^2.0.0",
|
|
18
|
-
"@trackunit/css-class-variance-utilities": "1.14.19-alpha-
|
|
19
|
-
"@trackunit/react-components": "2.10.12-alpha-
|
|
20
|
-
"@trackunit/ui-icons": "1.14.18-alpha-
|
|
21
|
-
"@trackunit/shared-utils": "1.16.22-alpha-
|
|
22
|
-
"@trackunit/ui-design-tokens": "1.15.9-alpha-
|
|
23
|
-
"@trackunit/i18n-library-translation": "2.4.18-alpha-
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "1.14.19-alpha-62031fc7c43.0",
|
|
19
|
+
"@trackunit/react-components": "2.10.12-alpha-62031fc7c43.0",
|
|
20
|
+
"@trackunit/ui-icons": "1.14.18-alpha-62031fc7c43.0",
|
|
21
|
+
"@trackunit/shared-utils": "1.16.22-alpha-62031fc7c43.0",
|
|
22
|
+
"@trackunit/ui-design-tokens": "1.15.9-alpha-62031fc7c43.0",
|
|
23
|
+
"@trackunit/i18n-library-translation": "2.4.18-alpha-62031fc7c43.0",
|
|
24
24
|
"string-ts": "^2.0.0",
|
|
25
25
|
"es-toolkit": "^1.39.10"
|
|
26
26
|
},
|