@gustavo-valsechi/client 1.4.148 → 1.4.150

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.
@@ -48,9 +48,11 @@ function InputSelect(props) {
48
48
  const [focus, setFocus] = (0, import_react.useState)(false);
49
49
  const [filter, setFilter] = (0, import_react.useState)("");
50
50
  const register = (props.register || ((name) => ({})))(props.name || "");
51
- const inputValue = (_a = props.watch) == null ? void 0 : _a.call(props, props.name);
52
- const value = ((_b = import_lodash.default.find(props.options, (option) => Object.keys(option)[0] === inputValue)) == null ? void 0 : _b[inputValue || ""]) || "";
51
+ const inputValue = ((_a = props.watch) == null ? void 0 : _a.call(props, props.name)) || "";
52
+ const value = ((_b = props.options) == null ? void 0 : _b[inputValue]) || "";
53
53
  console.log(inputValue);
54
+ console.log(import_lodash.default.find(props.options, (option) => Object.keys(option)[0] === inputValue));
55
+ console.log(value);
54
56
  (0, import_react.useEffect)(() => {
55
57
  var _a2;
56
58
  if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
@@ -112,7 +114,7 @@ function InputSelect(props) {
112
114
  onFocus,
113
115
  onBlur,
114
116
  onClick: () => inputRef.current.focus(),
115
- value: focus ? filter : "",
117
+ value: focus ? filter : inputValue,
116
118
  placeholder: import_lodash.default.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
117
119
  }
118
120
  ),
@@ -15,9 +15,11 @@ function InputSelect(props) {
15
15
  const [focus, setFocus] = useState(false);
16
16
  const [filter, setFilter] = useState("");
17
17
  const register = (props.register || ((name) => ({})))(props.name || "");
18
- const inputValue = (_a = props.watch) == null ? void 0 : _a.call(props, props.name);
19
- const value = ((_b = _.find(props.options, (option) => Object.keys(option)[0] === inputValue)) == null ? void 0 : _b[inputValue || ""]) || "";
18
+ const inputValue = ((_a = props.watch) == null ? void 0 : _a.call(props, props.name)) || "";
19
+ const value = ((_b = props.options) == null ? void 0 : _b[inputValue]) || "";
20
20
  console.log(inputValue);
21
+ console.log(_.find(props.options, (option) => Object.keys(option)[0] === inputValue));
22
+ console.log(value);
21
23
  useEffect(() => {
22
24
  var _a2;
23
25
  if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
@@ -79,7 +81,7 @@ function InputSelect(props) {
79
81
  onFocus,
80
82
  onBlur,
81
83
  onClick: () => inputRef.current.focus(),
82
- value: focus ? filter : "",
84
+ value: focus ? filter : inputValue,
83
85
  placeholder: _.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
84
86
  }
85
87
  ),
@@ -49,9 +49,7 @@ function InputSelectOption(props) {
49
49
  if (mutation.type === "attributes" && mutation.attributeName === "value") {
50
50
  const filter = optionsElement.getAttribute("value") || "";
51
51
  if (!filter) return setOptions(props.options);
52
- const filtredOptions = import_lodash.default.filter(props.options, (data) => {
53
- var _a;
54
- const value = ((_a = Object.values(data || {})) == null ? void 0 : _a[0]) || "";
52
+ const filtredOptions = import_lodash.default.filter(props.options, (value) => {
55
53
  const normalize = (text2) => import_lodash.default.deburr(text2 == null ? void 0 : text2.toLowerCase());
56
54
  if (import_lodash.default.isString(value)) return import_lodash.default.includes(normalize(value), normalize(filter));
57
55
  const text = import_utils.default.format.textIntoElement(value);
@@ -74,14 +72,14 @@ function InputSelectOption(props) {
74
72
  };
75
73
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Container, { id: `input-${props.name}-options`, width: props.width, children: import_lodash.default.map(
76
74
  options,
77
- (data, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
75
+ (value, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
76
  "div",
79
77
  {
80
78
  className: "input-option",
81
- onClick: () => onSelect(Object.keys(data)[index]),
82
- children: Object.values(data)[index] || ""
79
+ onClick: () => onSelect(key),
80
+ children: value || ""
83
81
  },
84
- index
82
+ key
85
83
  )
86
84
  ) });
87
85
  }
@@ -16,9 +16,7 @@ function InputSelectOption(props) {
16
16
  if (mutation.type === "attributes" && mutation.attributeName === "value") {
17
17
  const filter = optionsElement.getAttribute("value") || "";
18
18
  if (!filter) return setOptions(props.options);
19
- const filtredOptions = _.filter(props.options, (data) => {
20
- var _a;
21
- const value = ((_a = Object.values(data || {})) == null ? void 0 : _a[0]) || "";
19
+ const filtredOptions = _.filter(props.options, (value) => {
22
20
  const normalize = (text2) => _.deburr(text2 == null ? void 0 : text2.toLowerCase());
23
21
  if (_.isString(value)) return _.includes(normalize(value), normalize(filter));
24
22
  const text = Utils.format.textIntoElement(value);
@@ -41,14 +39,14 @@ function InputSelectOption(props) {
41
39
  };
42
40
  return /* @__PURE__ */ jsx(Container, { id: `input-${props.name}-options`, width: props.width, children: _.map(
43
41
  options,
44
- (data, index) => /* @__PURE__ */ jsx(
42
+ (value, key) => /* @__PURE__ */ jsx(
45
43
  "div",
46
44
  {
47
45
  className: "input-option",
48
- onClick: () => onSelect(Object.keys(data)[index]),
49
- children: Object.values(data)[index] || ""
46
+ onClick: () => onSelect(key),
47
+ children: value || ""
50
48
  },
51
- index
49
+ key
52
50
  )
53
51
  ) });
54
52
  }
@@ -8,7 +8,9 @@ export interface IInputSelect {
8
8
  name: string;
9
9
  value?: string;
10
10
  onFilter?: (event: any) => void;
11
- options: Array<any>;
11
+ options: {
12
+ [value: string]: any;
13
+ };
12
14
  error?: string;
13
15
  disabled?: boolean;
14
16
  onFocus?: (value: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.148",
3
+ "version": "1.4.150",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",