@sikka/hawa 0.0.203 → 0.0.205
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/styles.css +12 -4
- package/es/blocks/AuthForms/CodeConfirmation.d.ts +15 -8
- package/es/blocks/AuthForms/SignInForm.d.ts +2 -2
- package/es/blocks/AuthForms/SignUpForm.d.ts +1 -1
- package/es/elements/HawaPinInput.d.ts +4 -2
- package/es/index.es.js +1 -1
- package/lib/blocks/AuthForms/CodeConfirmation.d.ts +15 -8
- package/lib/blocks/AuthForms/SignInForm.d.ts +2 -2
- package/lib/blocks/AuthForms/SignUpForm.d.ts +1 -1
- package/lib/elements/HawaPinInput.d.ts +4 -2
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/blocks/AuthForms/CodeConfirmation.tsx +57 -46
- package/src/blocks/AuthForms/SignInForm.tsx +81 -76
- package/src/blocks/AuthForms/SignUpForm.tsx +2 -2
- package/src/elements/DragDropImages.tsx +5 -21
- package/src/elements/HawaAccordion.tsx +33 -36
- package/src/elements/HawaButton.tsx +1 -1
- package/src/elements/HawaPinInput.tsx +61 -38
- package/src/elements/HawaTable.tsx +1 -0
- package/src/elements/HawaTooltip.tsx +1 -1
- package/src/styles.css +12 -4
- package/es/stories/ElementsStories/Tooltip.stories.d.ts +0 -4
- package/lib/stories/ElementsStories/Tooltip.stories.d.ts +0 -4
package/package.json
CHANGED
|
@@ -1,33 +1,39 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import {
|
|
1
|
+
import React, { useState } from "react"
|
|
2
|
+
import {
|
|
3
|
+
HawaTextField,
|
|
4
|
+
HawaAlert,
|
|
5
|
+
HawaButton,
|
|
6
|
+
HawaPinInput,
|
|
7
|
+
} from "../../elements"
|
|
3
8
|
import { Controller, useForm } from "react-hook-form"
|
|
4
9
|
import { HawaContainer } from "../../layout"
|
|
5
10
|
|
|
6
|
-
type
|
|
7
|
-
showError
|
|
8
|
-
errorTitle
|
|
9
|
-
errorText
|
|
10
|
-
texts
|
|
11
|
+
type TConfirmation = {
|
|
12
|
+
showError?: any
|
|
13
|
+
errorTitle?: any
|
|
14
|
+
errorText?: any
|
|
15
|
+
texts?: {
|
|
16
|
+
checkYourPhone: string
|
|
17
|
+
weSentCode: string
|
|
18
|
+
didntGetCode: string
|
|
19
|
+
resendCode: string
|
|
11
20
|
codeLabel: string
|
|
12
21
|
codePlaceholder: string
|
|
13
22
|
codeRequiredText: string
|
|
14
|
-
|
|
23
|
+
confirm: string
|
|
24
|
+
cancel
|
|
15
25
|
}
|
|
16
|
-
|
|
26
|
+
phoneNumber?: string
|
|
27
|
+
submitConfirmation?: any
|
|
28
|
+
handleSignIn?: any
|
|
17
29
|
}
|
|
18
|
-
export const CodeConfirmation: React.FunctionComponent<
|
|
19
|
-
CodeConfirmationTypes
|
|
20
|
-
> = (props) => {
|
|
21
|
-
const methods = useForm()
|
|
22
|
-
const {
|
|
23
|
-
formState: { errors },
|
|
24
|
-
handleSubmit,
|
|
25
|
-
control,
|
|
26
|
-
} = methods
|
|
27
30
|
|
|
31
|
+
export const CodeConfirmation: React.FunctionComponent<TConfirmation> = (
|
|
32
|
+
props
|
|
33
|
+
) => {
|
|
34
|
+
const [pins, setPins] = useState(null)
|
|
28
35
|
return (
|
|
29
36
|
<HawaContainer>
|
|
30
|
-
{" "}
|
|
31
37
|
{props.showError && (
|
|
32
38
|
<HawaAlert
|
|
33
39
|
title={props.errorTitle}
|
|
@@ -35,33 +41,38 @@ export const CodeConfirmation: React.FunctionComponent<
|
|
|
35
41
|
severity="error"
|
|
36
42
|
/>
|
|
37
43
|
)}
|
|
38
|
-
<
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
>
|
|
63
|
-
{
|
|
64
|
-
|
|
44
|
+
<div className="mb-4">
|
|
45
|
+
<div className="text-lg font-bold">
|
|
46
|
+
{props.texts.checkYourPhone ?? "Please check your phone"}
|
|
47
|
+
</div>
|
|
48
|
+
<div className="text-gray-500">
|
|
49
|
+
<span>{props.texts.weSentCode ?? "We've sent a code to "}</span>
|
|
50
|
+
<span>{props.phoneNumber}</span>
|
|
51
|
+
</div>{" "}
|
|
52
|
+
</div>
|
|
53
|
+
<form
|
|
54
|
+
onSubmit={(e) => {
|
|
55
|
+
e.preventDefault()
|
|
56
|
+
if (pins) {
|
|
57
|
+
props.submitConfirmation(pins)
|
|
58
|
+
}
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<HawaPinInput width="full" digits={6} getPins={(e) => setPins(e)} />
|
|
62
|
+
<div className=" py-2 text-center text-xs">
|
|
63
|
+
<span>{props.texts.didntGetCode ?? "Didn't get the code?"}</span>{" "}
|
|
64
|
+
<span className="cursor-pointer text-buttonPrimary-500">
|
|
65
|
+
{props.texts.resendCode ?? "Click to resend"}
|
|
66
|
+
</span>
|
|
67
|
+
</div>
|
|
68
|
+
<div className="mt-4 grid grid-cols-2 gap-2">
|
|
69
|
+
<HawaButton margins={"none"} variant="outlined" width="full">
|
|
70
|
+
{props.texts.cancel ?? "Cancel"}
|
|
71
|
+
</HawaButton>
|
|
72
|
+
<HawaButton margins={"none"} color="primary" width="full">
|
|
73
|
+
{props.texts.confirm ?? "Confirm"}
|
|
74
|
+
</HawaButton>
|
|
75
|
+
</div>
|
|
65
76
|
</form>
|
|
66
77
|
</HawaContainer>
|
|
67
78
|
)
|
|
@@ -9,55 +9,6 @@ import {
|
|
|
9
9
|
import { Controller, useForm } from "react-hook-form"
|
|
10
10
|
import { HawaContainer } from "../../layout"
|
|
11
11
|
|
|
12
|
-
type SignInFormTypes = {
|
|
13
|
-
language?: string
|
|
14
|
-
showError?: any
|
|
15
|
-
errorTitle?: string
|
|
16
|
-
errorText?: string
|
|
17
|
-
signInType?: "email" | "username" | "phone"
|
|
18
|
-
texts?: {
|
|
19
|
-
emailLabel?: string
|
|
20
|
-
emailPlaceholder?: string
|
|
21
|
-
emailRequiredText?: string
|
|
22
|
-
emailInvalidText?: string
|
|
23
|
-
usernameLabel?: string
|
|
24
|
-
usernamePlaceholder?: string
|
|
25
|
-
usernameRequired?: string
|
|
26
|
-
phoneRequiredText?: string
|
|
27
|
-
passwordLabel?: string
|
|
28
|
-
passwordPlaceholder?: string
|
|
29
|
-
passwordRequiredText?: string
|
|
30
|
-
forgotPasswordText?: string
|
|
31
|
-
newUserText?: string
|
|
32
|
-
signUpText?: string
|
|
33
|
-
signInText?: string
|
|
34
|
-
googleButtonLabel?: string
|
|
35
|
-
githubButtonLabel?: string
|
|
36
|
-
twitterButtonLabel?: string
|
|
37
|
-
}
|
|
38
|
-
withoutResetPassword?: boolean
|
|
39
|
-
withoutSignUp?: boolean
|
|
40
|
-
/**
|
|
41
|
-
*show spinner if true
|
|
42
|
-
*/
|
|
43
|
-
isLoading?: any
|
|
44
|
-
viaGoogle?: boolean
|
|
45
|
-
viaGithub?: boolean
|
|
46
|
-
viaTwitter?: boolean
|
|
47
|
-
/**
|
|
48
|
-
* Handle the sign in .
|
|
49
|
-
*/
|
|
50
|
-
handleSignIn?: (e: any) => void
|
|
51
|
-
/**
|
|
52
|
-
* Handle routing to sign up page
|
|
53
|
-
*/
|
|
54
|
-
handleRouteToSignUp?: () => void
|
|
55
|
-
handleForgotPassword?: () => void
|
|
56
|
-
handleGoogleSignIn?: () => void
|
|
57
|
-
handleGithubSignIn?: () => void
|
|
58
|
-
handleTwitterSignIn?: () => void
|
|
59
|
-
}
|
|
60
|
-
|
|
61
12
|
export const SignInForm: React.FunctionComponent<SignInFormTypes> = (props) => {
|
|
62
13
|
const {
|
|
63
14
|
formState: { errors },
|
|
@@ -66,7 +17,7 @@ export const SignInForm: React.FunctionComponent<SignInFormTypes> = (props) => {
|
|
|
66
17
|
} = useForm()
|
|
67
18
|
|
|
68
19
|
return (
|
|
69
|
-
<HawaContainer direction={props.
|
|
20
|
+
<HawaContainer direction={props.direction}>
|
|
70
21
|
<form onSubmit={handleSubmit((e) => props.handleSignIn(e))}>
|
|
71
22
|
{props.showError && (
|
|
72
23
|
<HawaAlert
|
|
@@ -128,29 +79,36 @@ export const SignInForm: React.FunctionComponent<SignInFormTypes> = (props) => {
|
|
|
128
79
|
rules={{ required: props.texts.phoneRequiredText }}
|
|
129
80
|
/>
|
|
130
81
|
)}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
82
|
+
{props.signInType !== "phone" && (
|
|
83
|
+
<>
|
|
84
|
+
<Controller
|
|
85
|
+
control={control}
|
|
86
|
+
name="password"
|
|
87
|
+
render={({ field }) => (
|
|
88
|
+
<HawaTextField
|
|
89
|
+
width="full"
|
|
90
|
+
type="password"
|
|
91
|
+
label={props.texts.passwordLabel}
|
|
92
|
+
placeholder={props.texts.passwordPlaceholder}
|
|
93
|
+
helperText={errors.password?.message}
|
|
94
|
+
onChange={field.onChange}
|
|
95
|
+
value={field.value ?? ""}
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
rules={{
|
|
99
|
+
required: props.texts.passwordRequiredText,
|
|
100
|
+
minLength: 5,
|
|
101
|
+
}}
|
|
143
102
|
/>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
</div>
|
|
103
|
+
{!props.withoutResetPassword && (
|
|
104
|
+
<div
|
|
105
|
+
onClick={props.handleForgotPassword}
|
|
106
|
+
className="mb-3 w-fit cursor-pointer text-xs dark:text-gray-300"
|
|
107
|
+
>
|
|
108
|
+
{props.texts.forgotPasswordText}
|
|
109
|
+
</div>
|
|
110
|
+
)}
|
|
111
|
+
</>
|
|
154
112
|
)}
|
|
155
113
|
|
|
156
114
|
<HawaButton
|
|
@@ -159,8 +117,6 @@ export const SignInForm: React.FunctionComponent<SignInFormTypes> = (props) => {
|
|
|
159
117
|
color="primary"
|
|
160
118
|
size="medium"
|
|
161
119
|
width="full"
|
|
162
|
-
// type="submit"
|
|
163
|
-
// onClick={(e) => console.log("clicking")}
|
|
164
120
|
>
|
|
165
121
|
{props.texts.signInText}
|
|
166
122
|
</HawaButton>
|
|
@@ -176,8 +132,8 @@ export const SignInForm: React.FunctionComponent<SignInFormTypes> = (props) => {
|
|
|
176
132
|
</div>
|
|
177
133
|
)}
|
|
178
134
|
</form>
|
|
179
|
-
|
|
180
|
-
{/*
|
|
135
|
+
|
|
136
|
+
{/* 3rd Party Sign Auth Buttons */}
|
|
181
137
|
{props.viaGithub || props.viaGoogle || props.viaTwitter ? (
|
|
182
138
|
<div className="flex flex-col ">
|
|
183
139
|
{props.viaGoogle && (
|
|
@@ -206,3 +162,52 @@ export const SignInForm: React.FunctionComponent<SignInFormTypes> = (props) => {
|
|
|
206
162
|
</HawaContainer>
|
|
207
163
|
)
|
|
208
164
|
}
|
|
165
|
+
|
|
166
|
+
type SignInFormTypes = {
|
|
167
|
+
direction?: "rtl" | "ltr"
|
|
168
|
+
showError?: any
|
|
169
|
+
errorTitle?: string
|
|
170
|
+
errorText?: string
|
|
171
|
+
signInType?: "email" | "username" | "phone"
|
|
172
|
+
texts?: {
|
|
173
|
+
emailLabel?: string
|
|
174
|
+
emailPlaceholder?: string
|
|
175
|
+
emailRequiredText?: string
|
|
176
|
+
emailInvalidText?: string
|
|
177
|
+
usernameLabel?: string
|
|
178
|
+
usernamePlaceholder?: string
|
|
179
|
+
usernameRequired?: string
|
|
180
|
+
phoneRequiredText?: string
|
|
181
|
+
passwordLabel?: string
|
|
182
|
+
passwordPlaceholder?: string
|
|
183
|
+
passwordRequiredText?: string
|
|
184
|
+
forgotPasswordText?: string
|
|
185
|
+
newUserText?: string
|
|
186
|
+
signUpText?: string
|
|
187
|
+
signInText?: string
|
|
188
|
+
googleButtonLabel?: string
|
|
189
|
+
githubButtonLabel?: string
|
|
190
|
+
twitterButtonLabel?: string
|
|
191
|
+
}
|
|
192
|
+
withoutResetPassword?: boolean
|
|
193
|
+
withoutSignUp?: boolean
|
|
194
|
+
/**
|
|
195
|
+
*show spinner if true
|
|
196
|
+
*/
|
|
197
|
+
isLoading?: any
|
|
198
|
+
viaGoogle?: boolean
|
|
199
|
+
viaGithub?: boolean
|
|
200
|
+
viaTwitter?: boolean
|
|
201
|
+
/**
|
|
202
|
+
* Handle the sign in .
|
|
203
|
+
*/
|
|
204
|
+
handleSignIn?: (e: any) => void
|
|
205
|
+
/**
|
|
206
|
+
* Handle routing to sign up page
|
|
207
|
+
*/
|
|
208
|
+
handleRouteToSignUp?: () => void
|
|
209
|
+
handleForgotPassword?: () => void
|
|
210
|
+
handleGoogleSignIn?: () => void
|
|
211
|
+
handleGithubSignIn?: () => void
|
|
212
|
+
handleTwitterSignIn?: () => void
|
|
213
|
+
}
|
|
@@ -11,7 +11,7 @@ import { Controller, FormProvider, useForm } from "react-hook-form"
|
|
|
11
11
|
import { HawaContainer } from "../../layout/HawaContainer"
|
|
12
12
|
|
|
13
13
|
type SignUpFormTypes = {
|
|
14
|
-
|
|
14
|
+
direction?: "rtl" | "ltr"
|
|
15
15
|
texts: {
|
|
16
16
|
fullNameLabel: string
|
|
17
17
|
fullNamePlaceholder: string
|
|
@@ -72,7 +72,7 @@ export const SignUpForm: React.FunctionComponent<SignUpFormTypes> = (props) => {
|
|
|
72
72
|
} = methods
|
|
73
73
|
|
|
74
74
|
return (
|
|
75
|
-
<HawaContainer direction={props.
|
|
75
|
+
<HawaContainer direction={props.direction}>
|
|
76
76
|
<div>
|
|
77
77
|
{props.showError && (
|
|
78
78
|
<HawaAlert
|
|
@@ -3,12 +3,6 @@ import { useDropzone } from "react-dropzone"
|
|
|
3
3
|
import { HawaAlert } from "./HawaAlert"
|
|
4
4
|
import { HawaButton } from "./HawaButton"
|
|
5
5
|
|
|
6
|
-
const thumbsContainer = {
|
|
7
|
-
display: "flex",
|
|
8
|
-
flexDirection: "row",
|
|
9
|
-
flexWrap: "wrap",
|
|
10
|
-
marginTop: 10,
|
|
11
|
-
}
|
|
12
6
|
type DragDropImagesTypes = {
|
|
13
7
|
label?: string
|
|
14
8
|
files: [File]
|
|
@@ -79,17 +73,14 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
79
73
|
},
|
|
80
74
|
[files]
|
|
81
75
|
)
|
|
82
|
-
|
|
83
76
|
useEffect(() => {
|
|
84
77
|
setFiles(acceptedFiles)
|
|
85
78
|
}, [acceptedFiles, cmp])
|
|
86
|
-
|
|
87
79
|
onClearFiles = () => {
|
|
88
80
|
acceptedFiles.length = 0
|
|
89
81
|
acceptedFiles.splice(0, acceptedFiles.length)
|
|
90
82
|
setFiles([])
|
|
91
83
|
}
|
|
92
|
-
|
|
93
84
|
useEffect(() => {
|
|
94
85
|
if (maxSize > 0) {
|
|
95
86
|
const k = 1024
|
|
@@ -111,7 +102,7 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
111
102
|
)
|
|
112
103
|
})
|
|
113
104
|
const thumbs = files?.map((file: any, index: any) => (
|
|
114
|
-
<div className="relative m-3 rounded">
|
|
105
|
+
<div className="relative m-3 rounded ">
|
|
115
106
|
<button
|
|
116
107
|
onClick={(e) => {
|
|
117
108
|
e.stopPropagation()
|
|
@@ -158,8 +149,6 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
158
149
|
</div>
|
|
159
150
|
))
|
|
160
151
|
|
|
161
|
-
console.log("error", fileRejections)
|
|
162
|
-
|
|
163
152
|
return (
|
|
164
153
|
<div>
|
|
165
154
|
{label && (
|
|
@@ -168,22 +157,17 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
168
157
|
</div>
|
|
169
158
|
)}
|
|
170
159
|
<div
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
style: { backgroundColor: isDragActive ? "white" : "inherit" },
|
|
174
|
-
})}
|
|
175
|
-
// style={{ backgroundColor: isDragActive ? "white" : "inherit" }}
|
|
176
|
-
className="mb-2 flex flex-col justify-center rounded border border-dashed border-black"
|
|
160
|
+
{...getRootProps({})}
|
|
161
|
+
className="flex flex-col justify-center rounded border border-dashed border-black bg-white transition-all hover:bg-gray-100 "
|
|
177
162
|
>
|
|
178
163
|
<input {...getInputProps()} />
|
|
179
|
-
<div className="
|
|
180
|
-
<div className="
|
|
164
|
+
<div className="pt-4 text-center">{texts.clickHereToUpload}</div>
|
|
165
|
+
<div className="pb-4 text-center text-xs">
|
|
181
166
|
{texts.maxFileSize} {max}
|
|
182
167
|
</div>
|
|
183
168
|
<div className="flex justify-center ">
|
|
184
169
|
{acceptedFiles.length > 0 && (
|
|
185
170
|
<HawaButton
|
|
186
|
-
// style={{ color: "black" }}
|
|
187
171
|
onClick={(e) => {
|
|
188
172
|
e.stopPropagation()
|
|
189
173
|
onClearFiles(acceptedFiles)
|
|
@@ -21,49 +21,46 @@ const AccordionItem: React.FunctionComponent<AccordionItemTypes> = (props) => {
|
|
|
21
21
|
"p-5 font-light border border-b-xl rounded-b-xl border-gray-200 dark:border-gray-700 dark:bg-gray-900"
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
|
-
<div
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
<div>
|
|
25
|
+
<button
|
|
26
|
+
id={"accordion-collapse-heading-" + props.count}
|
|
27
|
+
type="button"
|
|
28
|
+
className={clsx(
|
|
29
|
+
// props.count === 0 ? roundedTop : noRounding,
|
|
30
|
+
collapse ? "rounded" : "rounded-t",
|
|
31
|
+
"flex w-full items-center justify-between border border-gray-200 bg-gray-100 p-5 text-left font-medium text-gray-900 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:text-white dark:hover:bg-gray-800 dark:focus:ring-gray-800"
|
|
32
|
+
)}
|
|
33
|
+
onClick={() => setCollapse(!collapse)}
|
|
34
|
+
data-accordion-target={"#accordion-collapse-body-" + props.count}
|
|
35
|
+
aria-expanded="true"
|
|
36
|
+
aria-controls={"accordion-collapse-body-" + props.count}
|
|
37
|
+
>
|
|
38
|
+
<span>{props.title}</span>
|
|
39
|
+
<svg
|
|
40
|
+
data-accordion-icon=""
|
|
41
|
+
className={`h-6 w-6 ${
|
|
42
|
+
collapse ? "" : "rotate-180"
|
|
43
|
+
} shrink-0 transition-all`}
|
|
44
|
+
fill="currentColor"
|
|
45
|
+
viewBox="0 0 20 20"
|
|
46
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
37
47
|
>
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
viewBox="0 0 20 20"
|
|
46
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
47
|
-
>
|
|
48
|
-
<path
|
|
49
|
-
fillRule="evenodd"
|
|
50
|
-
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
|
|
51
|
-
clipRule="evenodd"
|
|
52
|
-
></path>
|
|
53
|
-
</svg>
|
|
54
|
-
</button>
|
|
55
|
-
</h2>
|
|
48
|
+
<path
|
|
49
|
+
fillRule="evenodd"
|
|
50
|
+
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
|
|
51
|
+
clipRule="evenodd"
|
|
52
|
+
></path>
|
|
53
|
+
</svg>
|
|
54
|
+
</button>
|
|
56
55
|
<div
|
|
57
56
|
id={"accordion-collapse-body-" + props.count}
|
|
57
|
+
aria-labelledby={"accordion-collapse-heading-" + props.count}
|
|
58
58
|
className={clsx(
|
|
59
|
-
collapse ? "invisible hidden" : "visible",
|
|
60
|
-
"
|
|
59
|
+
collapse ? "invisible hidden h-0 p-0" : " visible h-full",
|
|
60
|
+
"rounded-b border border-t-0 border-gray-200 p-5 font-light dark:border-gray-700 dark:bg-gray-900"
|
|
61
61
|
)}
|
|
62
|
-
aria-labelledby={"accordion-collapse-heading-" + props.count}
|
|
63
62
|
>
|
|
64
|
-
{/* <div className={props.count === -1 ? accPaperRounded : accPaper}> */}
|
|
65
63
|
<p className="mb-2 text-gray-500 dark:text-gray-400">{props.content}</p>
|
|
66
|
-
{/* </div> */}
|
|
67
64
|
</div>
|
|
68
65
|
</div>
|
|
69
66
|
)
|
|
@@ -26,7 +26,7 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
26
26
|
isLoading?: boolean
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const baseStyles = "cursor-pointer font-medium rounded transition-all"
|
|
29
|
+
const baseStyles = "cursor-pointer font-medium rounded h-full transition-all"
|
|
30
30
|
|
|
31
31
|
const sizeStyles = {
|
|
32
32
|
xs: "px-1 py-1",
|
|
@@ -1,55 +1,78 @@
|
|
|
1
1
|
import clsx from "clsx"
|
|
2
|
-
import React from "react"
|
|
2
|
+
import React, { useEffect, useState } from "react"
|
|
3
3
|
|
|
4
4
|
type PinInputTypes = {
|
|
5
|
-
label
|
|
5
|
+
label?: string
|
|
6
6
|
icon?: JSX.Element
|
|
7
|
-
digits
|
|
7
|
+
digits: number
|
|
8
|
+
width?: "normal" | "full"
|
|
9
|
+
getPins?: any
|
|
8
10
|
}
|
|
9
11
|
export const HawaPinInput: React.FunctionComponent<PinInputTypes> = ({
|
|
10
12
|
label,
|
|
11
13
|
icon,
|
|
14
|
+
digits,
|
|
15
|
+
width = "normal",
|
|
16
|
+
getPins,
|
|
17
|
+
...props
|
|
12
18
|
}) => {
|
|
13
|
-
const
|
|
14
|
-
var theEvent = evt || window.event
|
|
19
|
+
const [pin, setPin] = useState(Array.from(Array(digits)))
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
key = String.fromCharCode(key)
|
|
21
|
+
const handleKeyDown = (e, index) => {
|
|
22
|
+
let backTo = 0
|
|
23
|
+
if (e.key === "Backspace") {
|
|
24
|
+
e.target.value.length === 0 ? (backTo = index - 1) : (backTo = index)
|
|
25
|
+
const previousInput = document.getElementById(`input-${backTo}`)
|
|
26
|
+
previousInput?.focus()
|
|
23
27
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
}
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
let unfilled = pin.includes(undefined)
|
|
31
|
+
if (!unfilled) {
|
|
32
|
+
getPins(pin)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
const handleChange = (e, index) => {
|
|
36
|
+
if (!/^\d*$/.test(e.target.value)) {
|
|
37
|
+
const newPin = [...pin]
|
|
38
|
+
newPin[index] = ""
|
|
39
|
+
setPin(newPin)
|
|
40
|
+
return
|
|
41
|
+
} else {
|
|
42
|
+
const newPin = [...pin]
|
|
43
|
+
newPin[index] = e.target.value
|
|
44
|
+
setPin(newPin)
|
|
45
|
+
|
|
46
|
+
if (e.target.value.length === 1) {
|
|
47
|
+
const nextInput = document.getElementById(`input-${index + 1}`)
|
|
48
|
+
nextInput?.focus()
|
|
49
|
+
} else if (e.target.value.length === 0) {
|
|
50
|
+
const previousInput = document.getElementById(`input-${index - 1}`)
|
|
51
|
+
previousInput?.focus()
|
|
52
|
+
}
|
|
28
53
|
}
|
|
29
54
|
}
|
|
55
|
+
|
|
30
56
|
return (
|
|
31
|
-
<div className="flex flex-row gap-2">
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
<div className="flex w-full flex-row justify-center gap-2">
|
|
58
|
+
{pin.map((value, index) => (
|
|
59
|
+
<input
|
|
60
|
+
key={index}
|
|
61
|
+
type="text"
|
|
62
|
+
maxLength={1}
|
|
63
|
+
value={value}
|
|
64
|
+
id={`input-${index}`}
|
|
65
|
+
pattern="[0-9]*"
|
|
66
|
+
className={clsx(
|
|
67
|
+
"h-10 rounded bg-white text-center",
|
|
68
|
+
width === "full" ? "w-full" : "w-10"
|
|
69
|
+
)}
|
|
70
|
+
onChange={(e) => handleChange(e, index)}
|
|
71
|
+
onKeyDown={(e) => handleKeyDown(e, index)}
|
|
72
|
+
onFocus={(e) => e.target.select()}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
))}
|
|
44
76
|
</div>
|
|
45
77
|
)
|
|
46
78
|
}
|
|
47
|
-
|
|
48
|
-
const SinglePinInput = (props) => (
|
|
49
|
-
<input
|
|
50
|
-
type="text"
|
|
51
|
-
maxLength={1}
|
|
52
|
-
className="h-10 w-10 bg-gray-200 text-center"
|
|
53
|
-
{...props}
|
|
54
|
-
/>
|
|
55
|
-
)
|
|
@@ -339,6 +339,7 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
|
|
|
339
339
|
)}
|
|
340
340
|
{/* Pagination Settings */}
|
|
341
341
|
<div className="w-fit ">
|
|
342
|
+
{/* TODO: Hide it when props.pagination is true */}
|
|
342
343
|
<select
|
|
343
344
|
value={perPage}
|
|
344
345
|
className="h-6 rounded text-xs"
|
|
@@ -76,7 +76,7 @@ export const HawaTooltip: React.FunctionComponent<THawaToolTip> = ({
|
|
|
76
76
|
tooltipCoordinates =
|
|
77
77
|
direction === "rtl"
|
|
78
78
|
? `${tooltipWidth - childrenWidth}px, ${spacing}px`
|
|
79
|
-
: `-${
|
|
79
|
+
: `-${0}px, ${spacing}px`
|
|
80
80
|
break
|
|
81
81
|
case "bottom-left":
|
|
82
82
|
tooltipCoordinates =
|