@arkyn/components 1.3.9 → 1.3.11
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.
- package/dist/bundle.js +801 -797
- package/dist/bundle.umd.cjs +12 -12
- package/dist/components/Input/CpfCpnjInput/getConfig.d.ts +1 -1
- package/dist/components/Input/index.js +1 -1
- package/dist/components/Select/getConfig.d.ts +1 -0
- package/dist/components/Select/getConfig.d.ts.map +1 -1
- package/dist/components/Select/getConfig.js +2 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +2 -1
- package/dist/hooks/useAutomation.d.ts.map +1 -1
- package/dist/hooks/useAutomation.js +12 -0
- package/package.json +1 -1
- package/src/components/Input/index.tsx +1 -1
- package/src/components/Select/getConfig.tsx +2 -0
- package/src/components/Select/index.tsx +2 -0
- package/src/hooks/useAutomation.ts +13 -0
@@ -1,13 +1,25 @@
|
|
1
1
|
import { useActionData } from "@remix-run/react";
|
2
2
|
import { useContext, useEffect } from "react";
|
3
3
|
import { ModalContext } from "../context/ModalContext";
|
4
|
+
import { useToast } from "./useToast";
|
4
5
|
function useAutomation() {
|
5
6
|
const actionData = useActionData();
|
6
7
|
const { closeModal } = useContext(ModalContext);
|
8
|
+
const { successToast, errorToast } = useToast();
|
7
9
|
useEffect(() => {
|
8
10
|
const closeModalKey = actionData?.closeModalKey;
|
9
11
|
if (closeModalKey)
|
10
12
|
closeModal(closeModalKey);
|
11
13
|
}, [actionData]);
|
14
|
+
useEffect(() => {
|
15
|
+
const showToast = typeof actionData?.message === "string" &&
|
16
|
+
typeof actionData?.success === "boolean";
|
17
|
+
if (showToast) {
|
18
|
+
if (actionData?.success)
|
19
|
+
successToast(actionData?.message);
|
20
|
+
else
|
21
|
+
errorToast(actionData?.message);
|
22
|
+
}
|
23
|
+
}, [actionData]);
|
12
24
|
}
|
13
25
|
export { useAutomation };
|
package/package.json
CHANGED
@@ -10,7 +10,7 @@ import "./styles.css";
|
|
10
10
|
function Input(props: InputProps) {
|
11
11
|
if (props.type === "currency") return <CurrencyInput {...props} />;
|
12
12
|
if (props.type === "masked") return <MaskedInput {...props} />;
|
13
|
-
if (props.type === "cpf-
|
13
|
+
if (props.type === "cpf-cnpj") return <CpfCnpjInput {...props} />;
|
14
14
|
return <SimpleInput {...props} />;
|
15
15
|
}
|
16
16
|
|
@@ -19,6 +19,7 @@ function getConfig(props: SelectProps, isFocused: boolean) {
|
|
19
19
|
title,
|
20
20
|
style,
|
21
21
|
isSearchable = false,
|
22
|
+
closeOnSelect = true,
|
22
23
|
...rest
|
23
24
|
} = props;
|
24
25
|
|
@@ -41,6 +42,7 @@ function getConfig(props: SelectProps, isFocused: boolean) {
|
|
41
42
|
onFocus,
|
42
43
|
onBlur,
|
43
44
|
title,
|
45
|
+
closeOnSelect,
|
44
46
|
style,
|
45
47
|
isSearchable,
|
46
48
|
iconSize: iconSize,
|
@@ -39,6 +39,7 @@ function Select(props: SelectProps) {
|
|
39
39
|
onSelect,
|
40
40
|
options,
|
41
41
|
optionMaxHeight,
|
42
|
+
closeOnSelect,
|
42
43
|
...rest
|
43
44
|
} = getConfig({ ...props, id, isError }, isFocused);
|
44
45
|
|
@@ -136,6 +137,7 @@ function Select(props: SelectProps) {
|
|
136
137
|
if (selectedValue !== value) setSelectedValue(value);
|
137
138
|
else setSelectedValue("");
|
138
139
|
onSelect && onSelect({ label, value });
|
140
|
+
closeOnSelect && setTimeout(() => handleBlur(), 100);
|
139
141
|
}}
|
140
142
|
>
|
141
143
|
{label} <Check />
|
@@ -2,15 +2,28 @@ import { useActionData } from "@remix-run/react";
|
|
2
2
|
import { useContext, useEffect } from "react";
|
3
3
|
|
4
4
|
import { ModalContext } from "../context/ModalContext";
|
5
|
+
import { useToast } from "./useToast";
|
5
6
|
|
6
7
|
function useAutomation() {
|
7
8
|
const actionData = useActionData<any>();
|
8
9
|
const { closeModal } = useContext(ModalContext);
|
10
|
+
const { successToast, errorToast } = useToast();
|
9
11
|
|
10
12
|
useEffect(() => {
|
11
13
|
const closeModalKey = actionData?.closeModalKey;
|
12
14
|
if (closeModalKey) closeModal(closeModalKey);
|
13
15
|
}, [actionData]);
|
16
|
+
|
17
|
+
useEffect(() => {
|
18
|
+
const showToast =
|
19
|
+
typeof actionData?.message === "string" &&
|
20
|
+
typeof actionData?.success === "boolean";
|
21
|
+
|
22
|
+
if (showToast) {
|
23
|
+
if (actionData?.success) successToast(actionData?.message);
|
24
|
+
else errorToast(actionData?.message);
|
25
|
+
}
|
26
|
+
}, [actionData]);
|
14
27
|
}
|
15
28
|
|
16
29
|
export { useAutomation };
|