@gustavo-valsechi/client 1.4.245 → 1.4.247

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.
@@ -1,2 +1,3 @@
1
1
  import { IInputDateTime } from "../../../../../interfaces";
2
+ import "react-day-picker/dist/style";
2
3
  export declare function InputDateTime(props: IInputDateTime): import("react/jsx-runtime").JSX.Element;
@@ -38,43 +38,64 @@ var import_react = require("react");
38
38
  var import_styles = require("./styles");
39
39
  var import_label = require("../label");
40
40
  var import_error = require("../error");
41
+ var import_contexts = require("../../../../../contexts");
42
+ var import_react_day_picker = require("react-day-picker");
43
+ var import_locale = require("react-day-picker/locale");
44
+ var import_style = require("react-day-picker/dist/style");
41
45
  var import_lodash = __toESM(require("lodash"));
42
46
  function InputDateTime(props) {
43
47
  const inputRef = (0, import_react.useRef)();
48
+ const target = (0, import_contexts.useTarget)();
44
49
  const register = (props.register || ((name) => ({})))(props.name || "");
50
+ const [date, setDate] = (0, import_react.useState)(/* @__PURE__ */ new Date());
51
+ (0, import_react.useEffect)(() => {
52
+ if (props.setValue) props.setValue(props.name, date);
53
+ }, [date]);
45
54
  const onChange = (event) => {
46
55
  if (register.onChange) register.onChange(event);
47
- if (props.setValue) props.setValue(event.target.value || "");
48
56
  if (props.onChange) props.onChange(event);
49
57
  };
50
58
  const showPicker = () => {
51
59
  if (!inputRef.current) return;
52
- inputRef.current.focus();
53
- inputRef.current.showPicker();
60
+ target.add({
61
+ ref: inputRef,
62
+ component: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
+ import_react_day_picker.DayPicker,
64
+ {
65
+ mode: "single",
66
+ selected: date,
67
+ onSelect: setDate,
68
+ locale: import_locale.ptBR,
69
+ required: true
70
+ }
71
+ )
72
+ });
54
73
  };
55
74
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_styles.Container, { className: props.className, error: props.error, disabled: props.disabled, children: [
56
75
  !!props.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_label.InputLabel, { optional: props.optional, children: props.label }),
57
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "input-content", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
58
- "input",
59
- {
60
- ...import_lodash.default.omit(props, ["className", "onChange", "mask", "type", "optional", "register", "setValue", "watch", "optional"]),
61
- type: "datetime-local",
62
- onFocus: () => {
63
- if (props.onFocus) props.onFocus(props.name);
64
- },
65
- ...register,
66
- ref: inputRef,
67
- onChange,
68
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
- "div",
70
- {
71
- className: "input-icon",
72
- onClick: showPicker,
73
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { "aria-hidden": true, className: "fa-solid fa-calendar" })
74
- }
75
- )
76
- }
77
- ) }),
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "input-content", children: [
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
+ "input",
79
+ {
80
+ ...import_lodash.default.omit(props, ["className", "onChange", "mask", "type", "optional", "register", "setValue", "watch", "optional"]),
81
+ type: "datetime-local",
82
+ onFocus: () => {
83
+ if (props.onFocus) props.onFocus(props.name);
84
+ },
85
+ ...register,
86
+ ref: inputRef,
87
+ onChange
88
+ }
89
+ ),
90
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
91
+ "div",
92
+ {
93
+ className: "input-icon",
94
+ onClick: showPicker,
95
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { "aria-hidden": true, className: "fa-solid fa-calendar" })
96
+ }
97
+ )
98
+ ] }),
78
99
  !!props.error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_error.InputError, { children: props.error })
79
100
  ] });
80
101
  }
@@ -1,47 +1,68 @@
1
1
  "use client";
2
2
  "use client";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
- import { useRef } from "react";
4
+ import { useRef, useState, useEffect } from "react";
5
5
  import { Container } from "./styles";
6
6
  import { InputLabel } from "../label";
7
7
  import { InputError } from "../error";
8
+ import { useTarget } from "../../../../../contexts";
9
+ import { DayPicker } from "react-day-picker";
10
+ import { ptBR } from "react-day-picker/locale";
11
+ import "react-day-picker/dist/style";
8
12
  import _ from "lodash";
9
13
  function InputDateTime(props) {
10
14
  const inputRef = useRef();
15
+ const target = useTarget();
11
16
  const register = (props.register || ((name) => ({})))(props.name || "");
17
+ const [date, setDate] = useState(/* @__PURE__ */ new Date());
18
+ useEffect(() => {
19
+ if (props.setValue) props.setValue(props.name, date);
20
+ }, [date]);
12
21
  const onChange = (event) => {
13
22
  if (register.onChange) register.onChange(event);
14
- if (props.setValue) props.setValue(event.target.value || "");
15
23
  if (props.onChange) props.onChange(event);
16
24
  };
17
25
  const showPicker = () => {
18
26
  if (!inputRef.current) return;
19
- inputRef.current.focus();
20
- inputRef.current.showPicker();
27
+ target.add({
28
+ ref: inputRef,
29
+ component: /* @__PURE__ */ jsx(
30
+ DayPicker,
31
+ {
32
+ mode: "single",
33
+ selected: date,
34
+ onSelect: setDate,
35
+ locale: ptBR,
36
+ required: true
37
+ }
38
+ )
39
+ });
21
40
  };
22
41
  return /* @__PURE__ */ jsxs(Container, { className: props.className, error: props.error, disabled: props.disabled, children: [
23
42
  !!props.label && /* @__PURE__ */ jsx(InputLabel, { optional: props.optional, children: props.label }),
24
- /* @__PURE__ */ jsx("div", { className: "input-content", children: /* @__PURE__ */ jsx(
25
- "input",
26
- {
27
- ..._.omit(props, ["className", "onChange", "mask", "type", "optional", "register", "setValue", "watch", "optional"]),
28
- type: "datetime-local",
29
- onFocus: () => {
30
- if (props.onFocus) props.onFocus(props.name);
31
- },
32
- ...register,
33
- ref: inputRef,
34
- onChange,
35
- children: /* @__PURE__ */ jsx(
36
- "div",
37
- {
38
- className: "input-icon",
39
- onClick: showPicker,
40
- children: /* @__PURE__ */ jsx("i", { "aria-hidden": true, className: "fa-solid fa-calendar" })
41
- }
42
- )
43
- }
44
- ) }),
43
+ /* @__PURE__ */ jsxs("div", { className: "input-content", children: [
44
+ /* @__PURE__ */ jsx(
45
+ "input",
46
+ {
47
+ ..._.omit(props, ["className", "onChange", "mask", "type", "optional", "register", "setValue", "watch", "optional"]),
48
+ type: "datetime-local",
49
+ onFocus: () => {
50
+ if (props.onFocus) props.onFocus(props.name);
51
+ },
52
+ ...register,
53
+ ref: inputRef,
54
+ onChange
55
+ }
56
+ ),
57
+ /* @__PURE__ */ jsx(
58
+ "div",
59
+ {
60
+ className: "input-icon",
61
+ onClick: showPicker,
62
+ children: /* @__PURE__ */ jsx("i", { "aria-hidden": true, className: "fa-solid fa-calendar" })
63
+ }
64
+ )
65
+ ] }),
45
66
  !!props.error && /* @__PURE__ */ jsx(InputError, { children: props.error })
46
67
  ] });
47
68
  }
@@ -58,9 +58,6 @@ const Container = import_styled_components.default.div`
58
58
  color: ${({ theme }) => theme.t6};
59
59
  color-scheme: ${(props) => props.theme || "light"};
60
60
  appearance: textfield;
61
- display: flex;
62
- align-content: center;
63
- justify-content: space-between;
64
61
 
65
62
  &:disabled {
66
63
  background-color: transparent;
@@ -79,21 +76,21 @@ const Container = import_styled_components.default.div`
79
76
  &::-webkit-inner-spin-button {
80
77
  display: none;
81
78
  }
79
+ }
82
80
 
83
- .input-icon {
84
- background: ${({ theme }) => theme.primary};
85
- color: ${({ theme }) => theme.t3};
86
- cursor: pointer;
87
- height: 100%;
88
- width: 2.5rem;
89
- display: flex;
90
- align-items: center;
91
- justify-content: center;
92
- position: relative;
81
+ .input-icon {
82
+ background: ${({ theme }) => theme.primary};
83
+ color: ${({ theme }) => theme.t3};
84
+ cursor: pointer;
85
+ height: 100%;
86
+ width: 2.5rem;
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+ position: relative;
93
91
 
94
- i {
95
- font-size: .9rem;
96
- }
92
+ i {
93
+ font-size: .9rem;
97
94
  }
98
95
  }
99
96
  }
@@ -25,9 +25,6 @@ const Container = styled.div`
25
25
  color: ${({ theme }) => theme.t6};
26
26
  color-scheme: ${(props) => props.theme || "light"};
27
27
  appearance: textfield;
28
- display: flex;
29
- align-content: center;
30
- justify-content: space-between;
31
28
 
32
29
  &:disabled {
33
30
  background-color: transparent;
@@ -46,21 +43,21 @@ const Container = styled.div`
46
43
  &::-webkit-inner-spin-button {
47
44
  display: none;
48
45
  }
46
+ }
49
47
 
50
- .input-icon {
51
- background: ${({ theme }) => theme.primary};
52
- color: ${({ theme }) => theme.t3};
53
- cursor: pointer;
54
- height: 100%;
55
- width: 2.5rem;
56
- display: flex;
57
- align-items: center;
58
- justify-content: center;
59
- position: relative;
48
+ .input-icon {
49
+ background: ${({ theme }) => theme.primary};
50
+ color: ${({ theme }) => theme.t3};
51
+ cursor: pointer;
52
+ height: 100%;
53
+ width: 2.5rem;
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ position: relative;
60
58
 
61
- i {
62
- font-size: .9rem;
63
- }
59
+ i {
60
+ font-size: .9rem;
64
61
  }
65
62
  }
66
63
  }
@@ -67,6 +67,7 @@ function InputSelectOption(props) {
67
67
  var _a;
68
68
  (_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
69
69
  target.close(props.inputRef);
70
+ if (props.onChange) props.onChange(value);
70
71
  const optionsElement = document.getElementById(`input-${props.name}-options`);
71
72
  if (!optionsElement) return;
72
73
  optionsElement.setAttribute("value", "");
@@ -34,6 +34,7 @@ function InputSelectOption(props) {
34
34
  var _a;
35
35
  (_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
36
36
  target.close(props.inputRef);
37
+ if (props.onChange) props.onChange(value);
37
38
  const optionsElement = document.getElementById(`input-${props.name}-options`);
38
39
  if (!optionsElement) return;
39
40
  optionsElement.setAttribute("value", "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.245",
3
+ "version": "1.4.247",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -35,6 +35,7 @@
35
35
  "randomcolor": "0.6.2",
36
36
  "react-apexcharts": "1.4.1",
37
37
  "react-credit-cards-2": "1.0.3",
38
+ "react-day-picker": "9.13.0",
38
39
  "react-hook-form": "7.65.0",
39
40
  "react-lottie": "1.2.4",
40
41
  "tsup": "8.5.0",