@arkyn/components 1.3.7 → 1.3.9

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.
@@ -9,7 +9,6 @@ import { currencyInputKeyDown, valueDisplay } from "./utils";
9
9
 
10
10
  function CurrencyInput(props: CurrencyInputProps) {
11
11
  const [isFocused, setIsFocused] = useState(false);
12
- const [currencyValue, setCurrencyValue] = useState(props.defaultValue || 0);
13
12
 
14
13
  const baseRef = useRef<HTMLInputElement>(null);
15
14
 
@@ -39,9 +38,12 @@ function CurrencyInput(props: CurrencyInputProps) {
39
38
  onKeyDown,
40
39
  onChange,
41
40
  showCents,
41
+ defaultValue,
42
42
  ...rest
43
43
  } = getConfig({ ...props, id, isError }, isFocused);
44
44
 
45
+ const [currencyValue, setCurrencyValue] = useState(defaultValue * 100 || 0);
46
+
45
47
  const showLeftIcon = LeftIcon && !isLoading;
46
48
  const showRightIcon = RightIcon && !isLoading;
47
49
 
@@ -56,7 +58,7 @@ function CurrencyInput(props: CurrencyInputProps) {
56
58
 
57
59
  function handleKeyDown(event: KeyboardEvent<HTMLInputElement>) {
58
60
  currencyInputKeyDown({ currencyValue, event, max, setCurrencyValue });
59
- onChange && onChange(currencyValue);
61
+ onChange && onChange(currencyValue / 100);
60
62
  onKeyDown && onKeyDown(event);
61
63
  }
62
64
 
@@ -31,6 +31,7 @@ function SimpleInput(props: SimpleInputProps) {
31
31
  onFocus,
32
32
  onBlur,
33
33
  RightIcon,
34
+ type,
34
35
  Spinner,
35
36
  ...rest
36
37
  } = getConfig({ ...props, id, isError }, isFocused);
@@ -57,6 +58,10 @@ function SimpleInput(props: SimpleInputProps) {
57
58
  if (onBlur) onBlur(e);
58
59
  }
59
60
 
61
+ if (type === "hidden") {
62
+ return <input type="hidden" ref={ref} {...rest} />;
63
+ }
64
+
60
65
  return (
61
66
  <section
62
67
  title={title}
@@ -74,6 +79,7 @@ function SimpleInput(props: SimpleInputProps) {
74
79
  ref={ref}
75
80
  onFocus={handleFocus}
76
81
  onBlur={handleBlur}
82
+ type={type}
77
83
  {...rest}
78
84
  />
79
85
 
@@ -109,14 +109,19 @@ function Select(props: SelectProps) {
109
109
  readOnly={!isSearchable}
110
110
  value={searchValue || ""}
111
111
  placeholder={currentLabel || placeholder}
112
- ref={ref}
113
112
  onFocus={handleFocus}
114
113
  onBlur={() => setSearchValue("")}
115
114
  {...rest}
116
115
  onChange={(e) => setSearchValue(e.target.value)}
117
116
  />
118
117
 
119
- <input type="hidden" name={name} value={currentValue || ""} readOnly />
118
+ <input
119
+ type="hidden"
120
+ ref={ref}
121
+ name={name}
122
+ value={currentValue || ""}
123
+ readOnly
124
+ />
120
125
 
121
126
  {isFocused && (
122
127
  <ul