@gustavo-valsechi/client 1.4.154 → 1.4.156

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.
Files changed (28) hide show
  1. package/dist/components/types/form/index.js +1 -1
  2. package/dist/components/types/form/index.mjs +1 -1
  3. package/dist/components/types/form/types/custom/index.js +1 -4
  4. package/dist/components/types/form/types/custom/index.mjs +1 -4
  5. package/dist/components/types/form/types/datetime/index.js +2 -5
  6. package/dist/components/types/form/types/datetime/index.mjs +2 -5
  7. package/dist/components/types/form/types/file/index.js +1 -4
  8. package/dist/components/types/form/types/file/index.mjs +1 -4
  9. package/dist/components/types/form/types/label/index.js +4 -1
  10. package/dist/components/types/form/types/label/index.mjs +5 -2
  11. package/dist/components/types/form/types/label/styles.js +8 -0
  12. package/dist/components/types/form/types/label/styles.mjs +8 -0
  13. package/dist/components/types/form/types/select/index.js +2 -8
  14. package/dist/components/types/form/types/select/index.mjs +2 -8
  15. package/dist/components/types/form/types/select/styles.js +6 -0
  16. package/dist/components/types/form/types/select/styles.mjs +6 -0
  17. package/dist/components/types/form/types/text/index.js +1 -4
  18. package/dist/components/types/form/types/text/index.mjs +1 -4
  19. package/dist/components/types/form/types/textarea/index.js +2 -5
  20. package/dist/components/types/form/types/textarea/index.mjs +2 -5
  21. package/dist/interfaces/components/form/custom/index.d.ts +1 -1
  22. package/dist/interfaces/components/form/datetime/index.d.ts +1 -1
  23. package/dist/interfaces/components/form/file/index.d.ts +1 -1
  24. package/dist/interfaces/components/form/label/index.d.ts +1 -0
  25. package/dist/interfaces/components/form/select/index.d.ts +1 -1
  26. package/dist/interfaces/components/form/text/index.d.ts +1 -1
  27. package/dist/interfaces/components/form/textarea/index.d.ts +1 -1
  28. package/package.json +1 -1
@@ -47,7 +47,7 @@ function Form(props) {
47
47
  const [submitting, setSubmitting] = (0, import_react.useState)(false);
48
48
  const setSchema = () => {
49
49
  const schema2 = {};
50
- const validation = (data) => (data.validation || import_zod.z.string().optional()).transform((value) => value != null ? value : void 0);
50
+ const validation = (data) => (data.validation || import_zod.z.string().optional()).transform((value) => import_lodash.default.isEmpty(value) ? void 0 : value);
51
51
  import_lodash.default.forEach(props.inputs, (data) => {
52
52
  if (import_lodash.default.isArray(data)) {
53
53
  import_lodash.default.forEach(data, (input) => schema2[input.name] = validation(input));
@@ -13,7 +13,7 @@ function Form(props) {
13
13
  const [submitting, setSubmitting] = useState(false);
14
14
  const setSchema = () => {
15
15
  const schema2 = {};
16
- const validation = (data) => (data.validation || z.string().optional()).transform((value) => value != null ? value : void 0);
16
+ const validation = (data) => (data.validation || z.string().optional()).transform((value) => _.isEmpty(value) ? void 0 : value);
17
17
  _.forEach(props.inputs, (data) => {
18
18
  if (_.isArray(data)) {
19
19
  _.forEach(data, (input) => schema2[input.name] = validation(input));
@@ -34,10 +34,7 @@ function InputCustom(props) {
34
34
  (_a = props.setValue) == null ? void 0 : _a.call(props, props.name, props.value);
35
35
  }, [props.name, props.value]);
36
36
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { className: props.className, children: [
37
- !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_label.InputLabel, { children: [
38
- props.label,
39
- props.required ? "*" : ""
40
- ] }),
37
+ !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.InputLabel, { optional: props.optional, children: props.label }),
41
38
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "input-content", children: [
42
39
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { hidden: true, ...register }),
43
40
  props.children
@@ -11,10 +11,7 @@ function InputCustom(props) {
11
11
  (_a = props.setValue) == null ? void 0 : _a.call(props, props.name, props.value);
12
12
  }, [props.name, props.value]);
13
13
  return /* @__PURE__ */ jsxs(Container, { className: props.className, children: [
14
- !!props.label && /* @__PURE__ */ jsxs(InputLabel, { children: [
15
- props.label,
16
- props.required ? "*" : ""
17
- ] }),
14
+ !!props.label && /* @__PURE__ */ jsx(InputLabel, { optional: props.optional, children: props.label }),
18
15
  /* @__PURE__ */ jsxs("div", { className: "input-content", children: [
19
16
  /* @__PURE__ */ jsx("input", { hidden: true, ...register }),
20
17
  props.children
@@ -46,14 +46,11 @@ function InputDateTime(props) {
46
46
  if (props.onChange) props.onChange(event);
47
47
  };
48
48
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { className: props.className, error: props.error, children: [
49
- !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_label.InputLabel, { children: [
50
- props.label,
51
- props.required ? "*" : ""
52
- ] }),
49
+ !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.InputLabel, { optional: props.optional, children: props.label }),
53
50
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "input-content", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
54
51
  "input",
55
52
  {
56
- ...import_lodash.default.omit(props, ["className", "onChange", "mask", "type", "required", "register", "setValue", "watch"]),
53
+ ...import_lodash.default.omit(props, ["className", "onChange", "mask", "type", "optional", "register", "setValue", "watch"]),
57
54
  type: "datetime-local",
58
55
  onFocus: () => {
59
56
  if (props.onFocus) props.onFocus(props.name);
@@ -13,14 +13,11 @@ function InputDateTime(props) {
13
13
  if (props.onChange) props.onChange(event);
14
14
  };
15
15
  return /* @__PURE__ */ jsxs(Container, { className: props.className, error: props.error, children: [
16
- !!props.label && /* @__PURE__ */ jsxs(InputLabel, { children: [
17
- props.label,
18
- props.required ? "*" : ""
19
- ] }),
16
+ !!props.label && /* @__PURE__ */ jsx(InputLabel, { optional: props.optional, children: props.label }),
20
17
  /* @__PURE__ */ jsx("div", { className: "input-content", children: /* @__PURE__ */ jsx(
21
18
  "input",
22
19
  {
23
- ..._.omit(props, ["className", "onChange", "mask", "type", "required", "register", "setValue", "watch"]),
20
+ ..._.omit(props, ["className", "onChange", "mask", "type", "optional", "register", "setValue", "watch"]),
24
21
  type: "datetime-local",
25
22
  onFocus: () => {
26
23
  if (props.onFocus) props.onFocus(props.name);
@@ -57,10 +57,7 @@ function InputFile(props) {
57
57
  }
58
58
  }
59
59
  ),
60
- !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_label.InputLabel, { children: [
61
- props.label,
62
- props.required ? "*" : ""
63
- ] }),
60
+ !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.InputLabel, { optional: props.optional, children: props.label }),
64
61
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "image-content", onClick: () => inputRef.current.click(), children: ((_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.value) || "selecione uma imagem" }),
65
62
  !!props.error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_error.InputError, { children: props.error })
66
63
  ] });
@@ -34,10 +34,7 @@ function InputFile(props) {
34
34
  }
35
35
  }
36
36
  ),
37
- !!props.label && /* @__PURE__ */ jsxs(InputLabel, { children: [
38
- props.label,
39
- props.required ? "*" : ""
40
- ] }),
37
+ !!props.label && /* @__PURE__ */ jsx(InputLabel, { optional: props.optional, children: props.label }),
41
38
  /* @__PURE__ */ jsx("div", { className: "image-content", onClick: () => inputRef.current.click(), children: ((_a = inputRef == null ? void 0 : inputRef.current) == null ? void 0 : _a.value) || "selecione uma imagem" }),
42
39
  !!props.error && /* @__PURE__ */ jsx(InputError, { children: props.error })
43
40
  ] });
@@ -25,7 +25,10 @@ module.exports = __toCommonJS(label_exports);
25
25
  var import_jsx_runtime = require("react/jsx-runtime");
26
26
  var import_styles = require("./styles");
27
27
  function InputLabel(props) {
28
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styles.Container, { className: props.className, children: props.children });
28
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { className: props.className, children: [
29
+ props.children,
30
+ !!props.optional && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: `(opcional)` })
31
+ ] });
29
32
  }
30
33
  // Annotate the CommonJS export names for ESM import in node:
31
34
  0 && (module.exports = {
@@ -1,8 +1,11 @@
1
1
  "use client";
2
- import { jsx } from "react/jsx-runtime";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { Container } from "./styles";
4
4
  function InputLabel(props) {
5
- return /* @__PURE__ */ jsx(Container, { className: props.className, children: props.children });
5
+ return /* @__PURE__ */ jsxs(Container, { className: props.className, children: [
6
+ props.children,
7
+ !!props.optional && /* @__PURE__ */ jsx("span", { children: `(opcional)` })
8
+ ] });
6
9
  }
7
10
  export {
8
11
  InputLabel
@@ -38,6 +38,14 @@ const Container = import_styled_components.default.label`
38
38
  font-weight: 500;
39
39
  color: ${({ theme }) => theme.t6};
40
40
  user-select: none;
41
+ display: flex;
42
+ align-items: center;
43
+ gap: .2rem;
44
+
45
+ span {
46
+ font-size: .6rem;
47
+ font-weight: 200;
48
+ }
41
49
  `;
42
50
  // Annotate the CommonJS export names for ESM import in node:
43
51
  0 && (module.exports = {
@@ -5,6 +5,14 @@ const Container = styled.label`
5
5
  font-weight: 500;
6
6
  color: ${({ theme }) => theme.t6};
7
7
  user-select: none;
8
+ display: flex;
9
+ align-items: center;
10
+ gap: .2rem;
11
+
12
+ span {
13
+ font-size: .6rem;
14
+ font-weight: 200;
15
+ }
8
16
  `;
9
17
  export {
10
18
  Container
@@ -49,10 +49,7 @@ function InputSelect(props) {
49
49
  const [filter, setFilter] = (0, import_react.useState)("");
50
50
  const register = (props.register || ((name) => ({})))(props.name || "");
51
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
- console.log(inputValue);
54
- console.log(import_lodash.default.find(props.options, (option) => Object.keys(option)[0] === inputValue));
55
- console.log(value);
52
+ const value = ((_b = props.options) == null ? void 0 : _b[inputValue]) || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "input-label-value-placeholder", children: "selecione" });
56
53
  (0, import_react.useEffect)(() => {
57
54
  var _a2;
58
55
  if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
@@ -97,10 +94,7 @@ function InputSelect(props) {
97
94
  if (register.onClick) register.onClick(event);
98
95
  };
99
96
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { className: props.className, error: props.error, children: [
100
- !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_label.InputLabel, { children: [
101
- props.label,
102
- props.required ? "*" : ""
103
- ] }),
97
+ !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.InputLabel, { optional: props.optional, children: props.label }),
104
98
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
105
99
  "div",
106
100
  {
@@ -16,10 +16,7 @@ function InputSelect(props) {
16
16
  const [filter, setFilter] = useState("");
17
17
  const register = (props.register || ((name) => ({})))(props.name || "");
18
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
- console.log(inputValue);
21
- console.log(_.find(props.options, (option) => Object.keys(option)[0] === inputValue));
22
- console.log(value);
19
+ const value = ((_b = props.options) == null ? void 0 : _b[inputValue]) || /* @__PURE__ */ jsx("div", { className: "input-label-value-placeholder", children: "selecione" });
23
20
  useEffect(() => {
24
21
  var _a2;
25
22
  if (!(inputRef == null ? void 0 : inputRef.current) || !(containerRef == null ? void 0 : containerRef.current)) return;
@@ -64,10 +61,7 @@ function InputSelect(props) {
64
61
  if (register.onClick) register.onClick(event);
65
62
  };
66
63
  return /* @__PURE__ */ jsxs(Container, { className: props.className, error: props.error, children: [
67
- !!props.label && /* @__PURE__ */ jsxs(InputLabel, { children: [
68
- props.label,
69
- props.required ? "*" : ""
70
- ] }),
64
+ !!props.label && /* @__PURE__ */ jsx(InputLabel, { optional: props.optional, children: props.label }),
71
65
  /* @__PURE__ */ jsxs(
72
66
  "div",
73
67
  {
@@ -87,6 +87,12 @@ const Container = import_styled_components.default.div`
87
87
  display: flex;
88
88
  align-items: center;
89
89
  user-select: none;
90
+
91
+ .input-label-value-placeholder {
92
+ font-size: .8rem;
93
+ font-weight: 300;
94
+ color: ${({ theme }) => theme.t6};
95
+ }
90
96
  }
91
97
 
92
98
  .input-icon {
@@ -54,6 +54,12 @@ const Container = styled.div`
54
54
  display: flex;
55
55
  align-items: center;
56
56
  user-select: none;
57
+
58
+ .input-label-value-placeholder {
59
+ font-size: .8rem;
60
+ font-weight: 300;
61
+ color: ${({ theme }) => theme.t6};
62
+ }
57
63
  }
58
64
 
59
65
  .input-icon {
@@ -48,10 +48,7 @@ function InputText(props) {
48
48
  if (props.onChange) props.onChange(value);
49
49
  };
50
50
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { className: props.className, error: props.error, password: props.type === "password", children: [
51
- !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_label.InputLabel, { children: [
52
- props.label,
53
- props.required ? "*" : ""
54
- ] }),
51
+ !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.InputLabel, { optional: props.optional, children: props.label }),
55
52
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "input-content", children: [
56
53
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
57
54
  "input",
@@ -15,10 +15,7 @@ function InputText(props) {
15
15
  if (props.onChange) props.onChange(value);
16
16
  };
17
17
  return /* @__PURE__ */ jsxs(Container, { className: props.className, error: props.error, password: props.type === "password", children: [
18
- !!props.label && /* @__PURE__ */ jsxs(InputLabel, { children: [
19
- props.label,
20
- props.required ? "*" : ""
21
- ] }),
18
+ !!props.label && /* @__PURE__ */ jsx(InputLabel, { optional: props.optional, children: props.label }),
22
19
  /* @__PURE__ */ jsxs("div", { className: "input-content", children: [
23
20
  /* @__PURE__ */ jsx(
24
21
  "input",
@@ -46,14 +46,11 @@ function InputTextarea(props) {
46
46
  if (props.onChange) props.onChange(value);
47
47
  };
48
48
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { className: props.className, error: props.error, children: [
49
- !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_label.InputLabel, { children: [
50
- props.label,
51
- props.required ? "*" : ""
52
- ] }),
49
+ !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.InputLabel, { optional: props.optional, children: props.label }),
53
50
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "input-content", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
54
51
  "textarea",
55
52
  {
56
- ...import_lodash.default.omit(props, ["onFocus", "maxLength", "className", "onChange", "mask", "rows", "required", "register", "setValue", "watch"]),
53
+ ...import_lodash.default.omit(props, ["onFocus", "maxLength", "className", "onChange", "mask", "rows", "optional", "register", "setValue", "watch"]),
57
54
  maxLength: props.maxLength,
58
55
  rows: props.rows || 5,
59
56
  onFocus: () => {
@@ -13,14 +13,11 @@ function InputTextarea(props) {
13
13
  if (props.onChange) props.onChange(value);
14
14
  };
15
15
  return /* @__PURE__ */ jsxs(Container, { className: props.className, error: props.error, children: [
16
- !!props.label && /* @__PURE__ */ jsxs(InputLabel, { children: [
17
- props.label,
18
- props.required ? "*" : ""
19
- ] }),
16
+ !!props.label && /* @__PURE__ */ jsx(InputLabel, { optional: props.optional, children: props.label }),
20
17
  /* @__PURE__ */ jsx("div", { className: "input-content", children: /* @__PURE__ */ jsx(
21
18
  "textarea",
22
19
  {
23
- ..._.omit(props, ["onFocus", "maxLength", "className", "onChange", "mask", "rows", "required", "register", "setValue", "watch"]),
20
+ ..._.omit(props, ["onFocus", "maxLength", "className", "onChange", "mask", "rows", "optional", "register", "setValue", "watch"]),
24
21
  maxLength: props.maxLength,
25
22
  rows: props.rows || 5,
26
23
  onFocus: () => {
@@ -11,7 +11,7 @@ export interface IInputCustom {
11
11
  value?: string;
12
12
  error?: string;
13
13
  disabled?: boolean;
14
- required?: boolean;
14
+ optional?: boolean;
15
15
  register?: UseFormRegister<any>;
16
16
  setValue?: (...args: any[]) => void;
17
17
  children: React.ReactNode;
@@ -13,7 +13,7 @@ export interface IInputDateTime {
13
13
  maxLength?: number;
14
14
  error: string;
15
15
  disabled?: boolean;
16
- required?: boolean;
16
+ optional?: boolean;
17
17
  register?: UseFormRegister<any>;
18
18
  validation?: typeof z;
19
19
  }
@@ -12,7 +12,7 @@ export interface IInputFile {
12
12
  disabled?: boolean;
13
13
  error: string;
14
14
  onFocus: (value: string) => void;
15
- required?: boolean;
15
+ optional?: boolean;
16
16
  register?: UseFormRegister<any>;
17
17
  validation?: typeof z;
18
18
  }
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  export interface IInputLabel {
3
3
  className?: string;
4
+ optional?: boolean;
4
5
  children: React.ReactNode;
5
6
  }
@@ -14,7 +14,7 @@ export interface IInputSelect {
14
14
  error?: string;
15
15
  disabled?: boolean;
16
16
  onFocus?: (value: any) => void;
17
- required?: boolean;
17
+ optional?: boolean;
18
18
  register?: UseFormRegister<any>;
19
19
  validation?: typeof z;
20
20
  mask?: (value: string) => void;
@@ -14,7 +14,7 @@ export interface IInputText {
14
14
  error?: string;
15
15
  disabled?: boolean;
16
16
  onFocus?: (value: any) => void;
17
- required?: boolean;
17
+ optional?: boolean;
18
18
  register?: UseFormRegister<any>;
19
19
  validation?: typeof z;
20
20
  }
@@ -14,7 +14,7 @@ export interface IInputTextarea {
14
14
  error: string;
15
15
  disabled?: boolean;
16
16
  onFocus: (value: string) => void;
17
- required?: boolean;
17
+ optional?: boolean;
18
18
  register?: UseFormRegister<any>;
19
19
  validation?: typeof z;
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.154",
3
+ "version": "1.4.156",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",