@arkyn/components 1.3.89 → 1.3.91
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +4502 -2698
- package/dist/bundle.umd.cjs +57 -38
- package/dist/components/Switch/index.js +2 -2
- package/dist/hooks/useAutomation.d.ts.map +1 -1
- package/dist/hooks/useAutomation.js +7 -0
- package/package.json +2 -1
- package/src/components/Switch/index.tsx +4 -4
- package/src/hooks/useAutomation.ts +9 -1
@@ -6,11 +6,11 @@ function Switch(props) {
|
|
6
6
|
const { size = "lg", defaultChecked = false, checked: baseChecked = null, value, name, className: baseClassName = "", onCheck, ...rest } = props;
|
7
7
|
const [isChecked, setIsChecked] = useState(defaultChecked);
|
8
8
|
const { id, inputRef } = useFormController();
|
9
|
+
const currentChecked = typeof baseChecked === "boolean" ? baseChecked : isChecked;
|
9
10
|
function handleCheck() {
|
10
11
|
setIsChecked(!isChecked);
|
11
|
-
onCheck && onCheck(!
|
12
|
+
onCheck && onCheck(!currentChecked ? value || "checked" : "");
|
12
13
|
}
|
13
|
-
const currentChecked = typeof baseChecked === "boolean" ? baseChecked : isChecked;
|
14
14
|
const checkedClass = currentChecked ? "checkedTrue" : "checkedFalse";
|
15
15
|
const className = `arkynSwitch ${checkedClass} ${size} ${baseClassName}`;
|
16
16
|
return (_jsx("button", { id: id, type: "button", onClick: handleCheck, className: className, ...rest, children: _jsx("input", { type: "hidden", name: name, ref: inputRef, value: currentChecked ? value || "checked" : "" }) }));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAutomation.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutomation.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useAutomation.d.ts","sourceRoot":"","sources":["../../src/hooks/useAutomation.ts"],"names":[],"mappings":"AAqBA,iBAAS,aAAa,SA8BrB;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { useActionData } from "@remix-run/react";
|
2
2
|
import { useContext, useEffect } from "react";
|
3
|
+
import { animateScroll } from "react-scroll";
|
3
4
|
import { ModalContext } from "../context/ModalContext";
|
4
5
|
import { useToast } from "./useToast";
|
5
6
|
function isToastProps(obj) {
|
@@ -34,5 +35,11 @@ function useAutomation() {
|
|
34
35
|
});
|
35
36
|
}
|
36
37
|
}, [actionData]);
|
38
|
+
useEffect(() => {
|
39
|
+
if (typeof actionData?.data?.scrollTo === "string") {
|
40
|
+
const element = document.getElementById(actionData?.data?.scrollTo);
|
41
|
+
element && animateScroll.scrollTo(element.offsetTop - 200);
|
42
|
+
}
|
43
|
+
}, [actionData]);
|
37
44
|
}
|
38
45
|
export { useAutomation };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arkyn/components",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.91",
|
4
4
|
"main": "./dist/bundle.js",
|
5
5
|
"types": "./dist/index.d.ts",
|
6
6
|
"author": "Lucas Gonçalves",
|
@@ -15,6 +15,7 @@
|
|
15
15
|
"@react-input/mask": "^1.2.5",
|
16
16
|
"framer-motion": "^11.3.21",
|
17
17
|
"lucide-react": "^0.424.0",
|
18
|
+
"react-scroll": "^1.9.0",
|
18
19
|
"sonner": "^1.5.0"
|
19
20
|
},
|
20
21
|
"peerDependencies": {
|
@@ -19,14 +19,14 @@ function Switch(props: SwitchProps) {
|
|
19
19
|
const [isChecked, setIsChecked] = useState(defaultChecked);
|
20
20
|
const { id, inputRef } = useFormController();
|
21
21
|
|
22
|
+
const currentChecked =
|
23
|
+
typeof baseChecked === "boolean" ? baseChecked : isChecked;
|
24
|
+
|
22
25
|
function handleCheck() {
|
23
26
|
setIsChecked(!isChecked);
|
24
|
-
onCheck && onCheck(!
|
27
|
+
onCheck && onCheck(!currentChecked ? value || "checked" : "");
|
25
28
|
}
|
26
29
|
|
27
|
-
const currentChecked =
|
28
|
-
typeof baseChecked === "boolean" ? baseChecked : isChecked;
|
29
|
-
|
30
30
|
const checkedClass = currentChecked ? "checkedTrue" : "checkedFalse";
|
31
31
|
const className = `arkynSwitch ${checkedClass} ${size} ${baseClassName}`;
|
32
32
|
|
@@ -1,6 +1,7 @@
|
|
1
|
+
import { ToastProps } from "@arkyn/types";
|
1
2
|
import { useActionData } from "@remix-run/react";
|
2
3
|
import { useContext, useEffect } from "react";
|
3
|
-
import {
|
4
|
+
import { animateScroll } from "react-scroll";
|
4
5
|
|
5
6
|
import { ModalContext } from "../context/ModalContext";
|
6
7
|
import { useToast } from "./useToast";
|
@@ -41,6 +42,13 @@ function useAutomation() {
|
|
41
42
|
});
|
42
43
|
}
|
43
44
|
}, [actionData]);
|
45
|
+
|
46
|
+
useEffect(() => {
|
47
|
+
if (typeof actionData?.data?.scrollTo === "string") {
|
48
|
+
const element = document.getElementById(actionData?.data?.scrollTo);
|
49
|
+
element && animateScroll.scrollTo(element.offsetTop - 200);
|
50
|
+
}
|
51
|
+
}, [actionData]);
|
44
52
|
}
|
45
53
|
|
46
54
|
export { useAutomation };
|