@gustavo-valsechi/client 1.4.149 → 1.4.151

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,8 +48,8 @@ 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
54
  console.log(import_lodash.default.find(props.options, (option) => Object.keys(option)[0] === inputValue));
55
55
  console.log(value);
@@ -106,7 +106,6 @@ function InputSelect(props) {
106
106
  "input",
107
107
  {
108
108
  ...import_lodash.default.omit(props, ["className", "register", "mask", "setValue", "watch"]),
109
- ...register,
110
109
  ref: inputRef,
111
110
  type: "text",
112
111
  maxLength: props.maxLength || 255,
@@ -114,8 +113,9 @@ function InputSelect(props) {
114
113
  onFocus,
115
114
  onBlur,
116
115
  onClick: () => inputRef.current.focus(),
117
- value: focus ? filter : "",
118
- placeholder: import_lodash.default.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
116
+ value: focus ? filter : inputValue,
117
+ placeholder: import_lodash.default.isString(value) ? value : (value == null ? void 0 : value.textContent) || "",
118
+ ...register
119
119
  }
120
120
  ),
121
121
  !focus && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -15,8 +15,8 @@ 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
21
  console.log(_.find(props.options, (option) => Object.keys(option)[0] === inputValue));
22
22
  console.log(value);
@@ -73,7 +73,6 @@ function InputSelect(props) {
73
73
  "input",
74
74
  {
75
75
  ..._.omit(props, ["className", "register", "mask", "setValue", "watch"]),
76
- ...register,
77
76
  ref: inputRef,
78
77
  type: "text",
79
78
  maxLength: props.maxLength || 255,
@@ -81,8 +80,9 @@ function InputSelect(props) {
81
80
  onFocus,
82
81
  onBlur,
83
82
  onClick: () => inputRef.current.focus(),
84
- value: focus ? filter : "",
85
- placeholder: _.isString(value) ? value : (value == null ? void 0 : value.textContent) || ""
83
+ value: focus ? filter : inputValue,
84
+ placeholder: _.isString(value) ? value : (value == null ? void 0 : value.textContent) || "",
85
+ ...register
86
86
  }
87
87
  ),
88
88
  !focus && /* @__PURE__ */ jsx(
@@ -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.149",
3
+ "version": "1.4.151",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",