@gustavo-valsechi/client 1.4.357 → 1.4.358

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.
@@ -41,6 +41,8 @@ var import_error = require("../error");
41
41
  var import_contexts = require("../../../../../contexts");
42
42
  var import_lodash = __toESM(require("lodash"));
43
43
  var import_options = __toESM(require("./options"));
44
+ var import_option = __toESM(require("./options/option"));
45
+ var import_utils = __toESM(require("@gustavo-valsechi/utils"));
44
46
  function InputSelect(props) {
45
47
  var _a, _b;
46
48
  const containerRef = (0, import_react.useRef)(null);
@@ -50,7 +52,7 @@ function InputSelect(props) {
50
52
  const [filter, setFilter] = (0, import_react.useState)("");
51
53
  const register = (props.register || ((name) => ({})))(props.name || "");
52
54
  const inputValue = ((_a = props.watch) == null ? void 0 : _a.call(props, props.name)) || "";
53
- const value = ((_b = props.options) == null ? void 0 : _b[inputValue]) || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "input-label-value-placeholder", children: "selecione" });
55
+ const inputLabel = (0, import_option.default)({ content: (_b = props.options) == null ? void 0 : _b[inputValue] }) || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "input-label-value-placeholder", children: "selecione" });
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;
@@ -81,13 +83,13 @@ function InputSelect(props) {
81
83
  if (register.onFocus) register.onFocus(event);
82
84
  };
83
85
  const onChange = (event) => {
84
- const value2 = event.target.value || "";
85
- setFilter(value2);
86
- if (props.onFilter) props.onFilter(value2);
86
+ const value = event.target.value || "";
87
+ setFilter(value);
88
+ if (props.onFilter) props.onFilter(value);
87
89
  if (register.onChange) register.onChange(event);
88
90
  const optionsElement = document.getElementById(`input[${props.name}-options]`);
89
91
  if (!optionsElement) return;
90
- optionsElement.setAttribute("value", value2);
92
+ optionsElement.setAttribute("value", value);
91
93
  };
92
94
  const onClick = (event) => {
93
95
  inputRef.current.focus();
@@ -115,7 +117,7 @@ function InputSelect(props) {
115
117
  type: "text",
116
118
  maxLength: props.maxLength || 255,
117
119
  value: focus ? filter : inputValue,
118
- placeholder: import_lodash.default.isString(value) ? value : (value == null ? void 0 : value.textContent) || "",
120
+ placeholder: import_lodash.default.isString(inputLabel) ? inputLabel : import_utils.default.format.textIntoElement(inputLabel) || "",
119
121
  ...register,
120
122
  ref: inputRef,
121
123
  onBlur,
@@ -128,9 +130,9 @@ function InputSelect(props) {
128
130
  "div",
129
131
  {
130
132
  className: "input-label-value",
131
- "data-string": import_lodash.default.isString(value),
133
+ "data-string": import_lodash.default.isString(inputLabel),
132
134
  onClick: () => inputRef.current.click(),
133
- children: value
135
+ children: inputLabel
134
136
  }
135
137
  ),
136
138
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
@@ -7,7 +7,9 @@ import { InputLabel } from "../label";
7
7
  import { InputError } from "../error";
8
8
  import { useTarget } from "../../../../../contexts";
9
9
  import _ from "lodash";
10
- import InputSelectOption from "./options";
10
+ import InputSelectOptions from "./options";
11
+ import InputSelectOption from "./options/option";
12
+ import Utils from "@gustavo-valsechi/utils";
11
13
  function InputSelect(props) {
12
14
  var _a, _b;
13
15
  const containerRef = useRef(null);
@@ -17,14 +19,14 @@ function InputSelect(props) {
17
19
  const [filter, setFilter] = useState("");
18
20
  const register = (props.register || ((name) => ({})))(props.name || "");
19
21
  const inputValue = ((_a = props.watch) == null ? void 0 : _a.call(props, props.name)) || "";
20
- const value = ((_b = props.options) == null ? void 0 : _b[inputValue]) || /* @__PURE__ */ jsx("div", { className: "input-label-value-placeholder", children: "selecione" });
22
+ const inputLabel = InputSelectOption({ content: (_b = props.options) == null ? void 0 : _b[inputValue] }) || /* @__PURE__ */ jsx("div", { className: "input-label-value-placeholder", children: "selecione" });
21
23
  useEffect(() => {
22
24
  var _a2;
23
25
  if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
24
26
  target.save({
25
27
  ref: inputRef,
26
28
  component: /* @__PURE__ */ jsx(
27
- InputSelectOption,
29
+ InputSelectOptions,
28
30
  {
29
31
  ...props,
30
32
  inputRef,
@@ -48,13 +50,13 @@ function InputSelect(props) {
48
50
  if (register.onFocus) register.onFocus(event);
49
51
  };
50
52
  const onChange = (event) => {
51
- const value2 = event.target.value || "";
52
- setFilter(value2);
53
- if (props.onFilter) props.onFilter(value2);
53
+ const value = event.target.value || "";
54
+ setFilter(value);
55
+ if (props.onFilter) props.onFilter(value);
54
56
  if (register.onChange) register.onChange(event);
55
57
  const optionsElement = document.getElementById(`input[${props.name}-options]`);
56
58
  if (!optionsElement) return;
57
- optionsElement.setAttribute("value", value2);
59
+ optionsElement.setAttribute("value", value);
58
60
  };
59
61
  const onClick = (event) => {
60
62
  inputRef.current.focus();
@@ -82,7 +84,7 @@ function InputSelect(props) {
82
84
  type: "text",
83
85
  maxLength: props.maxLength || 255,
84
86
  value: focus ? filter : inputValue,
85
- placeholder: _.isString(value) ? value : (value == null ? void 0 : value.textContent) || "",
87
+ placeholder: _.isString(inputLabel) ? inputLabel : Utils.format.textIntoElement(inputLabel) || "",
86
88
  ...register,
87
89
  ref: inputRef,
88
90
  onBlur,
@@ -95,9 +97,9 @@ function InputSelect(props) {
95
97
  "div",
96
98
  {
97
99
  className: "input-label-value",
98
- "data-string": _.isString(value),
100
+ "data-string": _.isString(inputLabel),
99
101
  onClick: () => inputRef.current.click(),
100
- children: value
102
+ children: inputLabel
101
103
  }
102
104
  ),
103
105
  /* @__PURE__ */ jsxs(
@@ -1,5 +1,5 @@
1
1
  import { IInputSelect } from "../../../../../../interfaces";
2
- export default function InputSelectOption(props: IInputSelect & {
2
+ export default function InputSelectOptions(props: IInputSelect & {
3
3
  inputRef: any;
4
4
  width: number;
5
5
  }): import("react/jsx-runtime").JSX.Element;
@@ -30,7 +30,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
31
  var options_exports = {};
32
32
  __export(options_exports, {
33
- default: () => InputSelectOption
33
+ default: () => InputSelectOptions
34
34
  });
35
35
  module.exports = __toCommonJS(options_exports);
36
36
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -39,7 +39,8 @@ var import_styles = require("./styles");
39
39
  var import_contexts = require("../../../../../../contexts");
40
40
  var import_utils = __toESM(require("@gustavo-valsechi/utils"));
41
41
  var import_lodash = __toESM(require("lodash"));
42
- function InputSelectOption(props) {
42
+ var import_option = __toESM(require("./option"));
43
+ function InputSelectOptions(props) {
43
44
  const theme = (0, import_contexts.useTheme)();
44
45
  const target = (0, import_contexts.useTarget)();
45
46
  const [options, setOptions] = (0, import_react.useState)(props.options);
@@ -54,7 +55,8 @@ function InputSelectOption(props) {
54
55
  const filtredValues = import_lodash.default.filter(props.options, (value) => {
55
56
  const normalize = (text2) => import_lodash.default.deburr(text2 == null ? void 0 : text2.toLowerCase());
56
57
  if (import_lodash.default.isString(value)) return import_lodash.default.includes(normalize(value), normalize(filter));
57
- const text = import_utils.default.format.textIntoElement(value);
58
+ const text = import_utils.default.format.textIntoElement((0, import_option.default)({ content: value }));
59
+ console.log(text);
58
60
  return import_lodash.default.includes(normalize(text), normalize(filter));
59
61
  });
60
62
  const filtredOptions = {};
@@ -119,16 +121,16 @@ function InputSelectOption(props) {
119
121
  className: "input-option-content-mask",
120
122
  children: !Object.keys(options || {}).length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "input-option empty", children: "Nenhuma op\xE7\xE3o encontrada" }) : import_lodash.default.map(
121
123
  options,
122
- (value, key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
124
+ (data, value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
123
125
  "div",
124
126
  {
125
127
  className: "input-option",
126
- onClick: () => onSelect(key),
127
- "data-string": import_lodash.default.isString(value),
128
- "data-selected": key === props.value,
129
- children: value || ""
128
+ onClick: () => onSelect(value),
129
+ "data-string": import_lodash.default.isString(data),
130
+ "data-selected": value === props.value,
131
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_option.default, { content: data })
130
132
  },
131
- key
133
+ value
132
134
  )
133
135
  )
134
136
  }
@@ -6,7 +6,8 @@ import { Container } from "./styles";
6
6
  import { useTarget, useTheme } from "../../../../../../contexts";
7
7
  import Utils from "@gustavo-valsechi/utils";
8
8
  import _ from "lodash";
9
- function InputSelectOption(props) {
9
+ import InputSelectOption from "./option";
10
+ function InputSelectOptions(props) {
10
11
  const theme = useTheme();
11
12
  const target = useTarget();
12
13
  const [options, setOptions] = useState(props.options);
@@ -21,7 +22,8 @@ function InputSelectOption(props) {
21
22
  const filtredValues = _.filter(props.options, (value) => {
22
23
  const normalize = (text2) => _.deburr(text2 == null ? void 0 : text2.toLowerCase());
23
24
  if (_.isString(value)) return _.includes(normalize(value), normalize(filter));
24
- const text = Utils.format.textIntoElement(value);
25
+ const text = Utils.format.textIntoElement(InputSelectOption({ content: value }));
26
+ console.log(text);
25
27
  return _.includes(normalize(text), normalize(filter));
26
28
  });
27
29
  const filtredOptions = {};
@@ -86,16 +88,16 @@ function InputSelectOption(props) {
86
88
  className: "input-option-content-mask",
87
89
  children: !Object.keys(options || {}).length ? /* @__PURE__ */ jsx("div", { className: "input-option empty", children: "Nenhuma op\xE7\xE3o encontrada" }) : _.map(
88
90
  options,
89
- (value, key) => /* @__PURE__ */ jsx(
91
+ (data, value) => /* @__PURE__ */ jsx(
90
92
  "div",
91
93
  {
92
94
  className: "input-option",
93
- onClick: () => onSelect(key),
94
- "data-string": _.isString(value),
95
- "data-selected": key === props.value,
96
- children: value || ""
95
+ onClick: () => onSelect(value),
96
+ "data-string": _.isString(data),
97
+ "data-selected": value === props.value,
98
+ children: /* @__PURE__ */ jsx(InputSelectOption, { content: data })
97
99
  },
98
- key
100
+ value
99
101
  )
100
102
  )
101
103
  }
@@ -107,5 +109,5 @@ function InputSelectOption(props) {
107
109
  );
108
110
  }
109
111
  export {
110
- InputSelectOption as default
112
+ InputSelectOptions as default
111
113
  };
@@ -0,0 +1,3 @@
1
+ export default function InputSelectOption(props: {
2
+ content: any;
3
+ }): import("react/jsx-runtime").JSX.Element | "";
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ "use strict";
3
+ "use client";
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+ var option_exports = {};
32
+ __export(option_exports, {
33
+ default: () => InputSelectOption
34
+ });
35
+ module.exports = __toCommonJS(option_exports);
36
+ var import_jsx_runtime = require("react/jsx-runtime");
37
+ var import_styles = require("./styles");
38
+ var import_lodash = __toESM(require("lodash"));
39
+ function InputSelectOption(props) {
40
+ var _a, _b, _c, _d, _e, _f, _g, _h;
41
+ if (import_lodash.default.isArray(props.content)) return "";
42
+ if (!!((_a = props.content) == null ? void 0 : _a.icon) || !!((_b = props.content) == null ? void 0 : _b.flag)) {
43
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { color: (_c = props.content) == null ? void 0 : _c.color, flag: (_d = props.content) == null ? void 0 : _d.flag, children: [
44
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "select-option-identifier", children: [
45
+ !!((_e = props.content) == null ? void 0 : _e.icon) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { "aria-hidden": true, className: (_f = props.content) == null ? void 0 : _f.icon }),
46
+ !!((_g = props.content) == null ? void 0 : _g.flag) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "select-option-flag" })
47
+ ] }),
48
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: (_h = props.content) == null ? void 0 : _h.label })
49
+ ] });
50
+ }
51
+ return props.content || "";
52
+ }
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ "use client";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { Container } from "./styles";
5
+ import _ from "lodash";
6
+ function InputSelectOption(props) {
7
+ var _a, _b, _c, _d, _e, _f, _g, _h;
8
+ if (_.isArray(props.content)) return "";
9
+ if (!!((_a = props.content) == null ? void 0 : _a.icon) || !!((_b = props.content) == null ? void 0 : _b.flag)) {
10
+ return /* @__PURE__ */ jsxs(Container, { color: (_c = props.content) == null ? void 0 : _c.color, flag: (_d = props.content) == null ? void 0 : _d.flag, children: [
11
+ /* @__PURE__ */ jsxs("div", { className: "select-option-identifier", children: [
12
+ !!((_e = props.content) == null ? void 0 : _e.icon) && /* @__PURE__ */ jsx("i", { "aria-hidden": true, className: (_f = props.content) == null ? void 0 : _f.icon }),
13
+ !!((_g = props.content) == null ? void 0 : _g.flag) && /* @__PURE__ */ jsx("div", { className: "select-option-flag" })
14
+ ] }),
15
+ /* @__PURE__ */ jsx("span", { children: (_h = props.content) == null ? void 0 : _h.label })
16
+ ] });
17
+ }
18
+ return props.content || "";
19
+ }
20
+ export {
21
+ InputSelectOption as default
22
+ };
@@ -0,0 +1 @@
1
+ export declare const Container: any;
@@ -0,0 +1,76 @@
1
+ "use client";
2
+ "use strict";
3
+ "use client";
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+ var styles_exports = {};
32
+ __export(styles_exports, {
33
+ Container: () => Container
34
+ });
35
+ module.exports = __toCommonJS(styles_exports);
36
+ var import_styled_components = __toESM(require("styled-components"));
37
+ const Container = import_styled_components.default.div`
38
+ display: flex;
39
+ align-items: center;
40
+ gap: .5rem;
41
+ margin-left: -0.5rem;
42
+
43
+ .select-option-identifier {
44
+ width: 1.3rem;
45
+ height: 1.3rem;
46
+ border-radius: 5px;
47
+ background: ${(props) => props.theme.t05};
48
+ display: flex;
49
+ align-items: center;
50
+ justify-content: center;
51
+
52
+ i {
53
+ font-size: .7rem;
54
+ color: ${(props) => props.theme[props.color || ""] || props.theme.t6};
55
+ }
56
+
57
+ .select-option-flag {
58
+ width: .8rem;
59
+ height: .8rem;
60
+ background-image: url(${(props) => props.flag});
61
+ background-size: contain;
62
+ background-repeat: no-repeat;
63
+ background-position: center;
64
+ }
65
+ }
66
+
67
+ span {
68
+ font-size: .75rem;
69
+ font-weight: 500;
70
+ color: ${(props) => props.theme[props.color || ""] || props.theme.t6};
71
+ }
72
+ `;
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ Container
76
+ });
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ "use client";
3
+ import styled from "styled-components";
4
+ const Container = styled.div`
5
+ display: flex;
6
+ align-items: center;
7
+ gap: .5rem;
8
+ margin-left: -0.5rem;
9
+
10
+ .select-option-identifier {
11
+ width: 1.3rem;
12
+ height: 1.3rem;
13
+ border-radius: 5px;
14
+ background: ${(props) => props.theme.t05};
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+
19
+ i {
20
+ font-size: .7rem;
21
+ color: ${(props) => props.theme[props.color || ""] || props.theme.t6};
22
+ }
23
+
24
+ .select-option-flag {
25
+ width: .8rem;
26
+ height: .8rem;
27
+ background-image: url(${(props) => props.flag});
28
+ background-size: contain;
29
+ background-repeat: no-repeat;
30
+ background-position: center;
31
+ }
32
+ }
33
+
34
+ span {
35
+ font-size: .75rem;
36
+ font-weight: 500;
37
+ color: ${(props) => props.theme[props.color || ""] || props.theme.t6};
38
+ }
39
+ `;
40
+ export {
41
+ Container
42
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.357",
3
+ "version": "1.4.358",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@emotion/react": "11.14.0",
29
29
  "@emotion/styled": "11.14.1",
30
30
  "@gustavo-valsechi/server": "1.0.13",
31
- "@gustavo-valsechi/utils": "1.0.17",
31
+ "@gustavo-valsechi/utils": "1.0.19",
32
32
  "@hookform/resolvers": "5.2.2",
33
33
  "@mui/material": "7.3.7",
34
34
  "@mui/x-date-pickers": "8.24.0",