infinity-forge 14.9.1 → 14.9.2
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.
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import type { MenuListProps, MultiValueProps, ValueContainerProps } from 'react-select';
|
|
1
2
|
import { CustomOptionCheckbox } from '../components/index.js';
|
|
2
3
|
import type { SelectParametersHooks } from '../types.js';
|
|
3
4
|
export declare const useSelectComponents: (props: SelectParametersHooks) => {
|
|
4
5
|
Input: () => any;
|
|
5
|
-
MenuList: (propsSelect:
|
|
6
|
-
ValueContainer: (valueContainerProps:
|
|
7
|
-
MultiValue?: (multiValueProps:
|
|
6
|
+
MenuList: (propsSelect: MenuListProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
ValueContainer: (valueContainerProps: ValueContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
MultiValue?: (multiValueProps: MultiValueProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
Option: any;
|
|
9
10
|
SingleValue: any;
|
|
10
11
|
} | {
|
|
11
12
|
Input: () => any;
|
|
12
|
-
MenuList: (propsSelect:
|
|
13
|
-
ValueContainer: (valueContainerProps:
|
|
14
|
-
MultiValue?: (multiValueProps:
|
|
13
|
+
MenuList: (propsSelect: MenuListProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
ValueContainer: (valueContainerProps: ValueContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
MultiValue?: (multiValueProps: MultiValueProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
16
|
Option?: typeof CustomOptionCheckbox;
|
|
16
17
|
};
|
|
@@ -16,39 +16,47 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
16
16
|
var react_1 = require("react");
|
|
17
17
|
var components_1 = require("../components/index.js");
|
|
18
18
|
var useSelectComponents = function (props) {
|
|
19
|
+
// Mantém sempre os dados mais recentes sem trocar a identidade das funções de componente.
|
|
20
|
+
// O react-select remonta um componente quando a identidade da função muda; ler daqui evita isso.
|
|
21
|
+
var propsRef = (0, react_1.useRef)(props);
|
|
22
|
+
propsRef.current = props;
|
|
19
23
|
(0, react_1.useEffect)(function () {
|
|
20
24
|
var handleClickOutside = function (e) {
|
|
21
25
|
var _a;
|
|
22
|
-
|
|
26
|
+
var current = propsRef.current;
|
|
27
|
+
if (!current.menuIsOpen)
|
|
23
28
|
return;
|
|
24
|
-
var
|
|
29
|
+
var target = e.target;
|
|
30
|
+
var safeId = CSS.escape(current.id);
|
|
25
31
|
var menuPortal = document.querySelector(".".concat(safeId, "__menu-portal"));
|
|
26
32
|
var menu = document.querySelector(".".concat(safeId, "__menu"));
|
|
27
|
-
if (
|
|
28
|
-
!
|
|
29
|
-
(!menuPortal || !menuPortal.contains(
|
|
30
|
-
(!menu || !menu.contains(
|
|
31
|
-
|
|
32
|
-
(_a =
|
|
33
|
+
if (current.selectRef.current &&
|
|
34
|
+
!current.selectRef.current.contains(target) &&
|
|
35
|
+
(!menuPortal || !menuPortal.contains(target)) &&
|
|
36
|
+
(!menu || !menu.contains(target))) {
|
|
37
|
+
current.setMenuIsOpen(false);
|
|
38
|
+
(_a = current === null || current === void 0 ? void 0 : current.onCloseMenu) === null || _a === void 0 ? void 0 : _a.call(current);
|
|
33
39
|
}
|
|
34
40
|
};
|
|
35
41
|
document.addEventListener('mousedown', handleClickOutside);
|
|
36
42
|
return function () { return document.removeEventListener('mousedown', handleClickOutside); };
|
|
37
43
|
}, [props.menuIsOpen, props.id]);
|
|
38
|
-
|
|
44
|
+
var customOption = props.selectPropsInfinityForge.CustomOption;
|
|
45
|
+
var isMultiple = !!(props.selectPropsInfinityForge.isMultiple || props.selectPropsInfinityForge.multiple);
|
|
46
|
+
// Identidade das funções estável: só recalcula quando muda o *tipo* de componente,
|
|
47
|
+
// nunca em cada seleção. Os dados dinâmicos vêm sempre de propsRef.current.
|
|
48
|
+
return (0, react_1.useMemo)(function () { return (__assign(__assign(__assign({}, (customOption
|
|
39
49
|
? {
|
|
40
|
-
Option:
|
|
41
|
-
SingleValue:
|
|
50
|
+
Option: customOption,
|
|
51
|
+
SingleValue: customOption,
|
|
42
52
|
}
|
|
43
|
-
: __assign({}, (
|
|
44
|
-
? { Option: components_1.CustomOptionCheckbox }
|
|
45
|
-
: {})))), (props.selectPropsInfinityForge.isMultiple || props.selectPropsInfinityForge.multiple
|
|
53
|
+
: __assign({}, (isMultiple ? { Option: components_1.CustomOptionCheckbox } : {})))), (isMultiple
|
|
46
54
|
? {
|
|
47
55
|
MultiValue: function (multiValueProps) {
|
|
48
|
-
return (0, components_1.CustomMultiValue)(__assign(__assign({}, multiValueProps),
|
|
56
|
+
return (0, components_1.CustomMultiValue)(__assign(__assign({}, multiValueProps), propsRef.current));
|
|
49
57
|
},
|
|
50
58
|
}
|
|
51
|
-
: {})), { Input: function () { return null; }, MenuList: function (propsSelect) { return (0, jsx_runtime_1.jsx)(components_1.MenuListWithSearch, __assign({}, propsSelect,
|
|
59
|
+
: {})), { Input: function () { return null; }, MenuList: function (propsSelect) { return (0, jsx_runtime_1.jsx)(components_1.MenuListWithSearch, __assign({}, propsSelect, propsRef.current)); }, ValueContainer: function (valueContainerProps) { return ((0, jsx_runtime_1.jsx)(components_1.CustomValueContainer, __assign({}, valueContainerProps, propsRef.current))); } })); }, [customOption, isMultiple]);
|
|
52
60
|
};
|
|
53
61
|
exports.useSelectComponents = useSelectComponents;
|
|
54
62
|
//# sourceMappingURL=use-select-components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-select-components.js","sourceRoot":"","sources":["../../../../../../src/ui/components/form/select/hooks/use-select-components.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"use-select-components.js","sourceRoot":"","sources":["../../../../../../src/ui/components/form/select/hooks/use-select-components.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAkD;AAIlD,4CAAgH;AAIzG,I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