@rpcbase/client 0.193.0 → 0.194.0-mongoosetsindex.0
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/package.json +1 -1
- package/types.ts +6 -0
- package/ui/Modal/HashStateModal.js +0 -2
- package/ui/SubmitButton/index.js +38 -21
package/package.json
CHANGED
package/types.ts
ADDED
package/ui/SubmitButton/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import {useFormContext} from "react-hook-form"
|
|
2
2
|
import ActivityIndicator from "../ActivityIndicator"
|
|
3
3
|
|
|
4
4
|
|
|
@@ -10,23 +10,40 @@ type Props = {
|
|
|
10
10
|
onClick: Function,
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const SubmitButton = ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
export const SubmitButton = ({
|
|
14
|
+
className = "",
|
|
15
|
+
id = "btn-submit",
|
|
16
|
+
title,
|
|
17
|
+
submittingTitle,
|
|
18
|
+
children,
|
|
19
|
+
...props
|
|
20
|
+
}: Props) => {
|
|
21
|
+
|
|
22
|
+
const {formState} = useFormContext()
|
|
23
|
+
|
|
24
|
+
const {isSubmitting} = formState
|
|
25
|
+
|
|
26
|
+
const isDisabled = props.disabled || props.isLoading || isSubmitting
|
|
27
|
+
const isLoading = props.isLoading || isSubmitting
|
|
28
|
+
|
|
29
|
+
if (title && children) {
|
|
30
|
+
throw new Error("button cannot have both title and children props")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<button
|
|
35
|
+
id={id}
|
|
36
|
+
type="submit"
|
|
37
|
+
className={cx("btn btn-primary d-flex flex-row align-items-center align-self-start", className)}
|
|
38
|
+
disabled={isDisabled}
|
|
39
|
+
onClick={props.onClick}
|
|
40
|
+
>
|
|
41
|
+
{isLoading && (
|
|
42
|
+
<ActivityIndicator style={{marginRight: 7}} color="#FFF" size={15} />
|
|
43
|
+
)}
|
|
44
|
+
{title && !isSubmitting && title}
|
|
45
|
+
{submittingTitle && isSubmitting && submittingTitle}
|
|
46
|
+
{children}
|
|
47
|
+
</button>
|
|
48
|
+
)
|
|
49
|
+
}
|