@gustavo-valsechi/client 1.4.126 → 1.4.128
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/dist/components/types/form/types/select/options/index.js +12 -13
- package/dist/components/types/form/types/select/options/index.mjs +12 -13
- package/dist/components/types/form/types/select/options/styles.js +1 -1
- package/dist/components/types/form/types/select/options/styles.mjs +1 -1
- package/dist/contexts/target/index.js +1 -0
- package/dist/contexts/target/index.mjs +1 -0
- package/package.json +1 -1
|
@@ -39,13 +39,7 @@ var import_contexts = require("../../../../../../contexts");
|
|
|
39
39
|
var import_lodash = __toESM(require("lodash"));
|
|
40
40
|
function InputSelectOption(props) {
|
|
41
41
|
const target = (0, import_contexts.useTarget)();
|
|
42
|
-
const [value, set] = (0, import_react.useState)("");
|
|
43
42
|
const [options, setOptions] = (0, import_react.useState)(props.options);
|
|
44
|
-
(0, import_react.useEffect)(() => {
|
|
45
|
-
var _a;
|
|
46
|
-
(_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
|
|
47
|
-
target.close(props.inputRef);
|
|
48
|
-
}, [value, props.inputRef]);
|
|
49
43
|
(0, import_react.useEffect)(() => {
|
|
50
44
|
const optionsElement = document.getElementById("input-options");
|
|
51
45
|
if (!optionsElement) return;
|
|
@@ -56,13 +50,13 @@ function InputSelectOption(props) {
|
|
|
56
50
|
if (!filter) return setOptions(props.options);
|
|
57
51
|
const filtredOptions = import_lodash.default.filter(props.options, (data) => {
|
|
58
52
|
var _a;
|
|
59
|
-
const
|
|
53
|
+
const value = ((_a = Object.values(data || {})) == null ? void 0 : _a[0]) || "";
|
|
60
54
|
const normalize = (text) => import_lodash.default.deburr(text == null ? void 0 : text.toLowerCase());
|
|
61
|
-
if (import_lodash.default.isString(
|
|
62
|
-
console.log(typeof
|
|
63
|
-
console.log(
|
|
64
|
-
console.log(
|
|
65
|
-
return import_lodash.default.includes(normalize(
|
|
55
|
+
if (import_lodash.default.isString(value)) return import_lodash.default.includes(normalize(value), normalize(filter));
|
|
56
|
+
console.log(typeof value);
|
|
57
|
+
console.log(value);
|
|
58
|
+
console.log(value == null ? void 0 : value.textContent);
|
|
59
|
+
return import_lodash.default.includes(normalize(value == null ? void 0 : value.textContent), normalize(filter));
|
|
66
60
|
});
|
|
67
61
|
setOptions(filtredOptions);
|
|
68
62
|
}
|
|
@@ -71,13 +65,18 @@ function InputSelectOption(props) {
|
|
|
71
65
|
observer.observe(optionsElement, { attributes: true });
|
|
72
66
|
return () => observer.disconnect();
|
|
73
67
|
}, [props.options]);
|
|
68
|
+
const onSelect = (value) => {
|
|
69
|
+
var _a;
|
|
70
|
+
(_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
|
|
71
|
+
target.close(props.inputRef);
|
|
72
|
+
};
|
|
74
73
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Container, { id: "input-options", width: props.width, children: import_lodash.default.map(
|
|
75
74
|
options,
|
|
76
75
|
(data, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
77
76
|
"div",
|
|
78
77
|
{
|
|
79
78
|
className: "input-option",
|
|
80
|
-
onClick: () =>
|
|
79
|
+
onClick: () => onSelect(Object.keys(data)[index]),
|
|
81
80
|
children: Object.values(data)[index] || ""
|
|
82
81
|
},
|
|
83
82
|
index
|
|
@@ -6,13 +6,7 @@ import { useTarget } from "../../../../../../contexts";
|
|
|
6
6
|
import _ from "lodash";
|
|
7
7
|
function InputSelectOption(props) {
|
|
8
8
|
const target = useTarget();
|
|
9
|
-
const [value, set] = useState("");
|
|
10
9
|
const [options, setOptions] = useState(props.options);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
var _a;
|
|
13
|
-
(_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
|
|
14
|
-
target.close(props.inputRef);
|
|
15
|
-
}, [value, props.inputRef]);
|
|
16
10
|
useEffect(() => {
|
|
17
11
|
const optionsElement = document.getElementById("input-options");
|
|
18
12
|
if (!optionsElement) return;
|
|
@@ -23,13 +17,13 @@ function InputSelectOption(props) {
|
|
|
23
17
|
if (!filter) return setOptions(props.options);
|
|
24
18
|
const filtredOptions = _.filter(props.options, (data) => {
|
|
25
19
|
var _a;
|
|
26
|
-
const
|
|
20
|
+
const value = ((_a = Object.values(data || {})) == null ? void 0 : _a[0]) || "";
|
|
27
21
|
const normalize = (text) => _.deburr(text == null ? void 0 : text.toLowerCase());
|
|
28
|
-
if (_.isString(
|
|
29
|
-
console.log(typeof
|
|
30
|
-
console.log(
|
|
31
|
-
console.log(
|
|
32
|
-
return _.includes(normalize(
|
|
22
|
+
if (_.isString(value)) return _.includes(normalize(value), normalize(filter));
|
|
23
|
+
console.log(typeof value);
|
|
24
|
+
console.log(value);
|
|
25
|
+
console.log(value == null ? void 0 : value.textContent);
|
|
26
|
+
return _.includes(normalize(value == null ? void 0 : value.textContent), normalize(filter));
|
|
33
27
|
});
|
|
34
28
|
setOptions(filtredOptions);
|
|
35
29
|
}
|
|
@@ -38,13 +32,18 @@ function InputSelectOption(props) {
|
|
|
38
32
|
observer.observe(optionsElement, { attributes: true });
|
|
39
33
|
return () => observer.disconnect();
|
|
40
34
|
}, [props.options]);
|
|
35
|
+
const onSelect = (value) => {
|
|
36
|
+
var _a;
|
|
37
|
+
(_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
|
|
38
|
+
target.close(props.inputRef);
|
|
39
|
+
};
|
|
41
40
|
return /* @__PURE__ */ jsx(Container, { id: "input-options", width: props.width, children: _.map(
|
|
42
41
|
options,
|
|
43
42
|
(data, index) => /* @__PURE__ */ jsx(
|
|
44
43
|
"div",
|
|
45
44
|
{
|
|
46
45
|
className: "input-option",
|
|
47
|
-
onClick: () =>
|
|
46
|
+
onClick: () => onSelect(Object.keys(data)[index]),
|
|
48
47
|
children: Object.values(data)[index] || ""
|
|
49
48
|
},
|
|
50
49
|
index
|
|
@@ -38,7 +38,7 @@ const Container = import_styled_components.default.div`
|
|
|
38
38
|
background-color: ${({ theme }) => theme.primary};
|
|
39
39
|
border: 1px solid ${({ error, theme }) => error ? theme.negative : theme.t2};
|
|
40
40
|
border-radius: 5px;
|
|
41
|
-
max-height:
|
|
41
|
+
max-height: 180px;
|
|
42
42
|
position: relative;
|
|
43
43
|
overflow-x: hidden;
|
|
44
44
|
overflow-y: scroll;
|
|
@@ -5,7 +5,7 @@ const Container = styled.div`
|
|
|
5
5
|
background-color: ${({ theme }) => theme.primary};
|
|
6
6
|
border: 1px solid ${({ error, theme }) => error ? theme.negative : theme.t2};
|
|
7
7
|
border-radius: 5px;
|
|
8
|
-
max-height:
|
|
8
|
+
max-height: 180px;
|
|
9
9
|
position: relative;
|
|
10
10
|
overflow-x: hidden;
|
|
11
11
|
overflow-y: scroll;
|
|
@@ -54,6 +54,7 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
54
54
|
const blur = (index) => {
|
|
55
55
|
insideMemory.splice(import_lodash.default.findIndex(insideMemory, (i) => i === index), 1);
|
|
56
56
|
console.log("insideMemory in blur function", insideMemory);
|
|
57
|
+
elementFocusable(targets[index], index).focus();
|
|
57
58
|
elementFocusable(targets[index], index).blur();
|
|
58
59
|
};
|
|
59
60
|
const close = (index) => {
|
|
@@ -20,6 +20,7 @@ const TargetProviderContainer = ({ children }) => {
|
|
|
20
20
|
const blur = (index) => {
|
|
21
21
|
insideMemory.splice(_.findIndex(insideMemory, (i) => i === index), 1);
|
|
22
22
|
console.log("insideMemory in blur function", insideMemory);
|
|
23
|
+
elementFocusable(targets[index], index).focus();
|
|
23
24
|
elementFocusable(targets[index], index).blur();
|
|
24
25
|
};
|
|
25
26
|
const close = (index) => {
|