@gustavo-valsechi/client 1.4.356 → 1.4.357

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.
@@ -49,8 +49,6 @@ function InputDateTimePicker(props) {
49
49
  const theme = (0, import_contexts.useTheme)();
50
50
  const [dateTime, setDateTime] = (0, import_react.useState)(import_utils.default.moment().startOf("minutes"));
51
51
  (0, import_react.useEffect)(() => {
52
- const valueMoment = import_utils.default.moment(props.value || void 0).format("YYYY-MM-DD HH:mm");
53
- if (valueMoment === memory.format("YYYY-MM-DD HH:mm")) return;
54
52
  setDateTime(import_utils.default.moment(props.value || void 0).startOf("minutes"));
55
53
  }, [props.value]);
56
54
  const onChange = (value) => {
@@ -16,8 +16,6 @@ function InputDateTimePicker(props) {
16
16
  const theme = useTheme();
17
17
  const [dateTime, setDateTime] = useState(Utils.moment().startOf("minutes"));
18
18
  useEffect(() => {
19
- const valueMoment = Utils.moment(props.value || void 0).format("YYYY-MM-DD HH:mm");
20
- if (valueMoment === memory.format("YYYY-MM-DD HH:mm")) return;
21
19
  setDateTime(Utils.moment(props.value || void 0).startOf("minutes"));
22
20
  }, [props.value]);
23
21
  const onChange = (value) => {
@@ -62,20 +62,16 @@ function InputSelect(props) {
62
62
  ...props,
63
63
  inputRef,
64
64
  register,
65
- width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) - 1 || 0
65
+ width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) - 1 || 0,
66
+ value: inputValue
66
67
  }
67
68
  )
68
69
  });
69
- }, [containerRef, inputRef, props.options]);
70
- (0, import_react.useEffect)(() => {
71
- if (!inputRef.current || !inputValue) return;
72
- target.close(inputRef);
73
- }, [inputValue, inputRef]);
70
+ }, [containerRef, inputRef, props.options, inputValue]);
74
71
  const onBlur = (event) => {
75
72
  setFocus(false);
76
73
  setFilter("");
77
74
  if (props.onBlur) props.onBlur(event);
78
- if (register.onBlur) register.onBlur(event);
79
75
  const optionsElement = document.getElementById(`input[${props.name}-options]`);
80
76
  if (!optionsElement) return;
81
77
  optionsElement.setAttribute("value", "");
@@ -29,20 +29,16 @@ function InputSelect(props) {
29
29
  ...props,
30
30
  inputRef,
31
31
  register,
32
- width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) - 1 || 0
32
+ width: ((_a2 = containerRef == null ? void 0 : containerRef.current) == null ? void 0 : _a2.offsetWidth) - 1 || 0,
33
+ value: inputValue
33
34
  }
34
35
  )
35
36
  });
36
- }, [containerRef, inputRef, props.options]);
37
- useEffect(() => {
38
- if (!inputRef.current || !inputValue) return;
39
- target.close(inputRef);
40
- }, [inputValue, inputRef]);
37
+ }, [containerRef, inputRef, props.options, inputValue]);
41
38
  const onBlur = (event) => {
42
39
  setFocus(false);
43
40
  setFilter("");
44
41
  if (props.onBlur) props.onBlur(event);
45
- if (register.onBlur) register.onBlur(event);
46
42
  const optionsElement = document.getElementById(`input[${props.name}-options]`);
47
43
  if (!optionsElement) return;
48
44
  optionsElement.setAttribute("value", "");
@@ -41,6 +41,7 @@ var import_utils = __toESM(require("@gustavo-valsechi/utils"));
41
41
  var import_lodash = __toESM(require("lodash"));
42
42
  function InputSelectOption(props) {
43
43
  const theme = (0, import_contexts.useTheme)();
44
+ const target = (0, import_contexts.useTarget)();
44
45
  const [options, setOptions] = (0, import_react.useState)(props.options);
45
46
  (0, import_react.useEffect)(() => {
46
47
  const optionsElement = document.getElementById(`input[${props.name}-options]`);
@@ -89,6 +90,7 @@ function InputSelectOption(props) {
89
90
  }, [props.name]);
90
91
  const onSelect = (value) => {
91
92
  var _a;
93
+ setTimeout(() => target.close(props.inputRef), 10);
92
94
  (_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
93
95
  if (props.onChange) props.onChange(value);
94
96
  const optionsElement = document.getElementById(`input[${props.name}-options]`);
@@ -123,6 +125,7 @@ function InputSelectOption(props) {
123
125
  className: "input-option",
124
126
  onClick: () => onSelect(key),
125
127
  "data-string": import_lodash.default.isString(value),
128
+ "data-selected": key === props.value,
126
129
  children: value || ""
127
130
  },
128
131
  key
@@ -3,11 +3,12 @@
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  import { useEffect, useState } from "react";
5
5
  import { Container } from "./styles";
6
- import { useTheme } from "../../../../../../contexts";
6
+ import { useTarget, useTheme } from "../../../../../../contexts";
7
7
  import Utils from "@gustavo-valsechi/utils";
8
8
  import _ from "lodash";
9
9
  function InputSelectOption(props) {
10
10
  const theme = useTheme();
11
+ const target = useTarget();
11
12
  const [options, setOptions] = useState(props.options);
12
13
  useEffect(() => {
13
14
  const optionsElement = document.getElementById(`input[${props.name}-options]`);
@@ -56,6 +57,7 @@ function InputSelectOption(props) {
56
57
  }, [props.name]);
57
58
  const onSelect = (value) => {
58
59
  var _a;
60
+ setTimeout(() => target.close(props.inputRef), 10);
59
61
  (_a = props.setValue) == null ? void 0 : _a.call(props, props.name, value);
60
62
  if (props.onChange) props.onChange(value);
61
63
  const optionsElement = document.getElementById(`input[${props.name}-options]`);
@@ -90,6 +92,7 @@ function InputSelectOption(props) {
90
92
  className: "input-option",
91
93
  onClick: () => onSelect(key),
92
94
  "data-string": _.isString(value),
95
+ "data-selected": key === props.value,
93
96
  children: value || ""
94
97
  },
95
98
  key
@@ -72,6 +72,10 @@ const Container = import_styled_components.default.div`
72
72
  cursor: pointer;
73
73
  max-height: 36px;
74
74
 
75
+ &[data-selected="true"] {
76
+ background-color: ${({ theme }) => theme.t03};
77
+ }
78
+
75
79
  &[data-string="true"] {
76
80
  font-size: .8rem;
77
81
  color: ${({ theme }) => theme.t6};
@@ -39,6 +39,10 @@ const Container = styled.div`
39
39
  cursor: pointer;
40
40
  max-height: 36px;
41
41
 
42
+ &[data-selected="true"] {
43
+ background-color: ${({ theme }) => theme.t03};
44
+ }
45
+
42
46
  &[data-string="true"] {
43
47
  font-size: .8rem;
44
48
  color: ${({ theme }) => theme.t6};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gustavo-valsechi/client",
3
- "version": "1.4.356",
3
+ "version": "1.4.357",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",