@sikka/hawa 0.0.100 → 0.0.102
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 +60 -8
- package/es/elements/DraggableCard.d.ts +2 -2
- package/es/elements/HawaCheckbox.d.ts +4 -4
- package/es/elements/HawaChip.d.ts +3 -3
- package/es/elements/HawaColorPicker.d.ts +1 -1
- package/es/elements/HawaCopyrights.d.ts +4 -2
- package/es/elements/HawaDrawer.d.ts +18 -8
- package/es/elements/HawaMenu.d.ts +19 -11
- package/es/elements/HawaModal.d.ts +6 -7
- package/es/elements/HawaRange.d.ts +2 -0
- package/es/elements/HawaSettingsRow.d.ts +14 -1
- package/es/index.es.js +1 -1
- package/lib/elements/DraggableCard.d.ts +2 -2
- package/lib/elements/HawaCheckbox.d.ts +4 -4
- package/lib/elements/HawaChip.d.ts +3 -3
- package/lib/elements/HawaColorPicker.d.ts +1 -1
- package/lib/elements/HawaCopyrights.d.ts +4 -2
- package/lib/elements/HawaDrawer.d.ts +18 -8
- package/lib/elements/HawaMenu.d.ts +19 -11
- package/lib/elements/HawaModal.d.ts +6 -7
- package/lib/elements/HawaRange.d.ts +2 -0
- package/lib/elements/HawaSettingsRow.d.ts +14 -1
- package/lib/index.js +1 -1
- package/package.json +3 -2
- package/rollup.config.js +4 -0
- package/src/elements/DragDropImages.tsx +32 -26
- package/src/elements/DraggableCard.tsx +2 -2
- package/src/elements/HawaCheckbox.tsx +11 -6
- package/src/elements/HawaChip.tsx +3 -3
- package/src/elements/HawaColorPicker.tsx +2 -2
- package/src/elements/HawaCopyrights.tsx +8 -15
- package/src/elements/HawaDrawer.tsx +42 -23
- package/src/elements/HawaMenu.tsx +76 -53
- package/src/elements/HawaModal.tsx +20 -21
- package/src/elements/HawaRange.tsx +2 -0
- package/src/elements/HawaSettingsRow.tsx +29 -38
- package/src/elements/HawaTabs.tsx +1 -1
- package/src/styles.css +60 -8
- package/storybook-static/{733.8d2de9f8.iframe.bundle.js → 209.3141149a.iframe.bundle.js} +2 -2
- package/storybook-static/{733.8d2de9f8.iframe.bundle.js.LICENSE.txt → 209.3141149a.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/main.2fac3c3c.iframe.bundle.js +1 -0
- package/storybook-static/project.json +1 -1
- package/tailwind.config.js +26 -1
- package/storybook-static/main.71507dcb.iframe.bundle.js +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sikka/hawa",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.102",
|
|
4
4
|
"description": "UI Kit",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.es.js",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"react-transition-group": "^4.4.2",
|
|
59
59
|
"rollup": "^2.38.4",
|
|
60
60
|
"rollup-plugin-babel": "^4.4.0",
|
|
61
|
+
"rollup-plugin-cleaner": "^1.0.0",
|
|
61
62
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
62
63
|
"rollup-plugin-postcss": "^4.0.0",
|
|
63
64
|
"rollup-plugin-terser": "^7.0.2",
|
|
@@ -90,9 +91,9 @@
|
|
|
90
91
|
},
|
|
91
92
|
"dependencies": {
|
|
92
93
|
"react-dropzone": "^12.0.4",
|
|
94
|
+
"react-hook-form": "^7.28.0",
|
|
93
95
|
"react-icons": "^4.6.0",
|
|
94
96
|
"react-select": "^5.3.2",
|
|
95
|
-
"react-hook-form": "^7.28.0",
|
|
96
97
|
"rollup-plugin-swc": "^0.2.1",
|
|
97
98
|
"rollup-plugin-typescript2": "^0.34.1"
|
|
98
99
|
}
|
package/rollup.config.js
CHANGED
|
@@ -6,6 +6,7 @@ import { terser } from "rollup-plugin-terser";
|
|
|
6
6
|
import postcss from "rollup-plugin-postcss";
|
|
7
7
|
import typescript from "rollup-plugin-typescript2";
|
|
8
8
|
import swc from "rollup-plugin-swc";
|
|
9
|
+
import cleaner from "rollup-plugin-cleaner";
|
|
9
10
|
|
|
10
11
|
export default [
|
|
11
12
|
{
|
|
@@ -15,6 +16,9 @@ export default [
|
|
|
15
16
|
{ file: "es/index.es.js", format: "es", exports: "named" }
|
|
16
17
|
],
|
|
17
18
|
plugins: [
|
|
19
|
+
cleaner({
|
|
20
|
+
targets: ["./lib", "./es"]
|
|
21
|
+
}),
|
|
18
22
|
postcss({ plugins: [], minimize: true }),
|
|
19
23
|
babel({
|
|
20
24
|
exclude: "node_modules/**",
|
|
@@ -96,14 +96,15 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
96
96
|
}, [maxSize])
|
|
97
97
|
const errs = fileRejections.map((rej, i) => {
|
|
98
98
|
return (
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
<HawaAlert
|
|
100
|
+
text={rej.file.name}
|
|
101
|
+
title={rej.errors[0].code}
|
|
102
|
+
severity="error"
|
|
103
|
+
/>
|
|
103
104
|
)
|
|
104
105
|
})
|
|
105
106
|
const thumbs = files?.map((file: any, index: any) => (
|
|
106
|
-
<div
|
|
107
|
+
<div className="relative m-3 rounded-lg">
|
|
107
108
|
<button
|
|
108
109
|
onClick={(e) => {
|
|
109
110
|
e.stopPropagation()
|
|
@@ -112,7 +113,7 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
112
113
|
onDeleteFile(file)
|
|
113
114
|
}}
|
|
114
115
|
type="button"
|
|
115
|
-
className="absolute left-0 ml-auto inline-flex items-center rounded-lg bg-gray-900 p-1.5 text-sm text-gray-400 hover:bg-gray-200 hover:text-gray-900 dark:hover:bg-gray-600 dark:hover:text-white"
|
|
116
|
+
className="absolute left-0 ml-auto inline-flex items-center rounded-lg rounded-tr-none rounded-bl-none bg-gray-900 p-1.5 text-sm text-gray-400 hover:bg-gray-200 hover:text-gray-900 dark:hover:bg-gray-600 dark:hover:text-white"
|
|
116
117
|
data-modal-toggle="defaultModal"
|
|
117
118
|
>
|
|
118
119
|
<svg
|
|
@@ -144,6 +145,7 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
144
145
|
backgroundPosition: "center",
|
|
145
146
|
border: "1px solid black",
|
|
146
147
|
}}
|
|
148
|
+
className="rounded-lg"
|
|
147
149
|
key={file.name}
|
|
148
150
|
/>
|
|
149
151
|
</div>
|
|
@@ -165,37 +167,41 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
165
167
|
Click here or drop files here to upload
|
|
166
168
|
</div>
|
|
167
169
|
<div className="p-1 text-center">Max file size is {max}</div>
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
e
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
170
|
+
<div className="flex justify-center ">
|
|
171
|
+
{acceptedFiles.length > 0 && (
|
|
172
|
+
<HawaButton
|
|
173
|
+
// style={{ color: "black" }}
|
|
174
|
+
onClick={(e) => {
|
|
175
|
+
e.stopPropagation()
|
|
176
|
+
onClearFiles(acceptedFiles)
|
|
177
|
+
}}
|
|
178
|
+
>
|
|
179
|
+
Clear All
|
|
180
|
+
</HawaButton>
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
180
183
|
{thumbs && showPreview ? (
|
|
181
184
|
<aside
|
|
182
185
|
style={{
|
|
183
186
|
display: "flex",
|
|
184
187
|
flexDirection: "row",
|
|
185
188
|
flexWrap: "wrap",
|
|
186
|
-
marginTop: 10,
|
|
189
|
+
// marginTop: 10,
|
|
187
190
|
}}
|
|
191
|
+
className="rounded-lg border-red-500"
|
|
188
192
|
>
|
|
189
193
|
{thumbs}
|
|
190
194
|
</aside>
|
|
191
195
|
) : null}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
<div className="px-2">
|
|
197
|
+
{fileRejections[0]?.errors[0]?.code === "too-many-files" ? (
|
|
198
|
+
<HawaAlert text={texts.tooManyFiles} severity="error" />
|
|
199
|
+
) : fileRejections[0]?.errors[0]?.code === "file-too-large" ? (
|
|
200
|
+
<HawaAlert text={texts.fileTooLarge} severity="error" />
|
|
201
|
+
) : (
|
|
202
|
+
errs
|
|
203
|
+
)}
|
|
204
|
+
</div>
|
|
199
205
|
{}
|
|
200
206
|
</div>
|
|
201
207
|
)
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import React from "react"
|
|
1
|
+
import React, { ReactElement } from "react"
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
centered?:
|
|
3
|
+
type TCheckBoxTypes = {
|
|
4
|
+
centered?: boolean
|
|
5
5
|
label?: any
|
|
6
6
|
helperText?: any
|
|
7
|
-
onChange?:
|
|
7
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const HawaCheckbox: React.FunctionComponent<
|
|
10
|
+
export const HawaCheckbox: React.FunctionComponent<TCheckBoxTypes> = (props) => {
|
|
11
11
|
return (
|
|
12
12
|
<div
|
|
13
|
-
className={
|
|
13
|
+
className={
|
|
14
|
+
props.centered
|
|
15
|
+
? "flex h-full items-center justify-center"
|
|
16
|
+
: "flex h-full items-start"
|
|
17
|
+
}
|
|
14
18
|
>
|
|
15
19
|
<input
|
|
16
20
|
type="checkbox"
|
|
17
21
|
value=""
|
|
22
|
+
onChange={(e) => props.onChange(e)}
|
|
18
23
|
className="h-5 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:ring-offset-gray-800 dark:focus:ring-blue-600"
|
|
19
24
|
{...props}
|
|
20
25
|
/>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
label:
|
|
3
|
+
type TChipTypes = {
|
|
4
|
+
label: string
|
|
5
5
|
}
|
|
6
|
-
export const HawaChip: React.FunctionComponent<
|
|
6
|
+
export const HawaChip: React.FunctionComponent<TChipTypes> = (props) => {
|
|
7
7
|
return (
|
|
8
8
|
<span className="mr-2 h-fit rounded bg-blue-100 px-2.5 py-0.5 text-xs font-semibold text-blue-800 dark:bg-blue-200 dark:text-blue-800">
|
|
9
9
|
{props.label}
|
|
@@ -2,7 +2,7 @@ import React, { useState } from "react"
|
|
|
2
2
|
|
|
3
3
|
type ColorPickerTypes = {
|
|
4
4
|
color?: any
|
|
5
|
-
handleChange?:
|
|
5
|
+
handleChange?: (e : React.ChangeEvent<HTMLInputElement>) => void
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export const HawaColorPicker: React.FunctionComponent<ColorPickerTypes> = (
|
|
@@ -20,7 +20,7 @@ export const HawaColorPicker: React.FunctionComponent<ColorPickerTypes> = (
|
|
|
20
20
|
value={selectedColor}
|
|
21
21
|
onChange={(e) => {
|
|
22
22
|
setSelectedColor(e.target.value)
|
|
23
|
-
props.handleChange(e
|
|
23
|
+
props.handleChange(e)
|
|
24
24
|
}}
|
|
25
25
|
className="opacity-0"
|
|
26
26
|
/>
|
|
@@ -1,31 +1,24 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react"
|
|
2
2
|
|
|
3
3
|
type CopyRightsTypes = {
|
|
4
|
-
withLogo:
|
|
4
|
+
withLogo: boolean
|
|
5
5
|
lang: any
|
|
6
|
-
version:
|
|
6
|
+
version: string
|
|
7
|
+
credits: string
|
|
8
|
+
logoURL: string
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export const HawaCopyrights: React.FunctionComponent<CopyRightsTypes> = (
|
|
10
12
|
props
|
|
11
13
|
) => {
|
|
12
14
|
return (
|
|
13
|
-
<div
|
|
14
|
-
style={{
|
|
15
|
-
display: "flex",
|
|
16
|
-
flexDirection: "column",
|
|
17
|
-
textAlign: "center",
|
|
18
|
-
color: "grey",
|
|
19
|
-
fontSize: 14,
|
|
20
|
-
marginTop: 10,
|
|
21
|
-
marginBottom: 10,
|
|
22
|
-
}}
|
|
23
|
-
>
|
|
15
|
+
<div className="my-2 flex flex-col items-center justify-center gap-1 text-xs text-gray-400">
|
|
24
16
|
{props.withLogo ? (
|
|
25
17
|
<a href={"https://qawaim.app/" + props.lang}>
|
|
26
18
|
<div style={{ cursor: "pointer" }}>
|
|
27
19
|
<image
|
|
28
|
-
// src=
|
|
20
|
+
// src={props.logoURL}
|
|
21
|
+
href={props.logoURL}
|
|
29
22
|
// alt="Qawaim"
|
|
30
23
|
width={100}
|
|
31
24
|
height={50}
|
|
@@ -33,8 +26,8 @@ export const HawaCopyrights: React.FunctionComponent<CopyRightsTypes> = (
|
|
|
33
26
|
</div>
|
|
34
27
|
</a>
|
|
35
28
|
) : null}
|
|
36
|
-
|
|
37
29
|
<div>{props.version}</div>
|
|
30
|
+
{props.credits ? props.credits : null}
|
|
38
31
|
</div>
|
|
39
32
|
)
|
|
40
33
|
}
|
|
@@ -1,47 +1,53 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react"
|
|
1
|
+
import React, { FC, ReactElement, ReactNode, useEffect, useState } from "react"
|
|
2
2
|
import { FaDailymotion } from "react-icons/fa"
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
|
|
5
|
-
type
|
|
6
|
-
open:
|
|
5
|
+
type TDrawerTypes = {
|
|
6
|
+
open: boolean
|
|
7
7
|
setOpen: any
|
|
8
8
|
position: any
|
|
9
9
|
heading: any
|
|
10
|
-
children
|
|
10
|
+
children?: ReactNode
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const HawaDrawer: React.FunctionComponent<
|
|
13
|
+
export const HawaDrawer: React.FunctionComponent<TDrawerTypes> = ({
|
|
14
14
|
open,
|
|
15
15
|
setOpen,
|
|
16
16
|
position,
|
|
17
17
|
heading,
|
|
18
18
|
children,
|
|
19
|
+
...props
|
|
19
20
|
}) => {
|
|
20
21
|
const leftDrawer =
|
|
21
22
|
"w-60 z-50 h-full absolute overflow-x-hidden top-0 left-0 border-r bg-white"
|
|
22
23
|
const rightDrawer =
|
|
23
24
|
"w-60 z-50 h-full absolute overflow-x-hidden top-0 right-0 border-l bg-white"
|
|
24
25
|
|
|
26
|
+
const isFunction = (data: any): data is (...args: any[]) => any =>
|
|
27
|
+
typeof data === "function"
|
|
25
28
|
// useEffect(() => {
|
|
26
29
|
// setOpenDrawer(true);
|
|
27
30
|
// }, [open]);
|
|
28
31
|
|
|
29
32
|
const childrenWithProps = React.Children.map(children, (child) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
if (React.isValidElement(child) && isFunction(child.type)) {
|
|
34
|
+
switch (child.type.name) {
|
|
35
|
+
case "DrawerHeader":
|
|
36
|
+
return (
|
|
37
|
+
<DrawerHeader setOpen={setOpen} children={child.props.children} />
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
case "DrawerBody":
|
|
41
|
+
return <DrawerBody children={child.props.children} />
|
|
42
|
+
|
|
43
|
+
case "DrawerFooter":
|
|
44
|
+
return <DrawerFooter children={child.props.children} />
|
|
45
|
+
}
|
|
46
|
+
return React.cloneElement(child, {
|
|
47
|
+
// setOpen: setOpen,
|
|
48
|
+
// children: child.props.children,
|
|
49
|
+
})
|
|
50
|
+
}
|
|
45
51
|
})
|
|
46
52
|
|
|
47
53
|
const drawerClass =
|
|
@@ -54,7 +60,12 @@ export const HawaDrawer: React.FunctionComponent<DrawerTypes> = ({
|
|
|
54
60
|
return <div className={drawerClass}>{childrenWithProps}</div>
|
|
55
61
|
}
|
|
56
62
|
|
|
57
|
-
|
|
63
|
+
type TDrawerHeader = {
|
|
64
|
+
setOpen: any
|
|
65
|
+
children: ReactElement
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const DrawerHeader: FC<TDrawerHeader> = (props) => {
|
|
58
69
|
return (
|
|
59
70
|
<div className=" flex w-full flex-row items-center justify-between border-b py-4 px-1">
|
|
60
71
|
{props.children}
|
|
@@ -71,11 +82,19 @@ export const DrawerHeader = (props: any) => {
|
|
|
71
82
|
)
|
|
72
83
|
}
|
|
73
84
|
|
|
74
|
-
|
|
85
|
+
type TDrawerBody = {
|
|
86
|
+
children: ReactElement
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const DrawerBody = (props: TDrawerBody) => {
|
|
75
90
|
return <div className="p-1">{props.children}</div>
|
|
76
91
|
}
|
|
77
92
|
|
|
78
|
-
|
|
93
|
+
type TDrawerFooter = {
|
|
94
|
+
children: ReactElement
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const DrawerFooter = (props: TDrawerFooter) => {
|
|
79
98
|
return (
|
|
80
99
|
<div className="absolute bottom-0 w-full border-t py-4 px-1">
|
|
81
100
|
{props.children}
|
|
@@ -1,23 +1,33 @@
|
|
|
1
|
+
import clsx from "clsx"
|
|
2
|
+
import React, { ReactNode } from "react"
|
|
1
3
|
|
|
2
|
-
|
|
4
|
+
interface TMenuTypes {
|
|
3
5
|
popMenuID: any
|
|
4
|
-
menuItems:
|
|
6
|
+
menuItems: MenuItems[][]
|
|
5
7
|
//
|
|
6
8
|
// icon: PropTypes.element,
|
|
7
9
|
// label: PropTypes.string,
|
|
8
10
|
// action: PropTypes.func,
|
|
9
11
|
//
|
|
10
|
-
withHeader
|
|
11
|
-
withIcons
|
|
12
|
-
headerTitle
|
|
13
|
-
headerSubtitle
|
|
14
|
-
open:
|
|
15
|
-
handleClose:
|
|
16
|
-
anchor
|
|
12
|
+
withHeader?: boolean
|
|
13
|
+
withIcons?: boolean
|
|
14
|
+
headerTitle?: string
|
|
15
|
+
headerSubtitle?: string
|
|
16
|
+
open: boolean
|
|
17
|
+
handleClose: (e : boolean) => void
|
|
18
|
+
anchor?: any
|
|
19
|
+
children?: ReactNode
|
|
20
|
+
buttonPosition?: "top-right" | "top-left" | "bottom-right" | "bottom-left"
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
type MenuItems = {
|
|
24
|
+
icon ?: JSX.Element,
|
|
25
|
+
label : string,
|
|
26
|
+
action ?: (e : React.MouseEvent<HTMLLIElement, MouseEvent>,item : string) => void
|
|
27
|
+
isButton ?: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
|
|
21
31
|
menuItems,
|
|
22
32
|
withHeader,
|
|
23
33
|
withIcons,
|
|
@@ -25,50 +35,63 @@ export const HawaMenu: React.FunctionComponent<MenuTypes> = ({
|
|
|
25
35
|
headerSubtitle,
|
|
26
36
|
open,
|
|
27
37
|
handleClose,
|
|
38
|
+
buttonPosition,
|
|
39
|
+
children,
|
|
28
40
|
}) => {
|
|
41
|
+
let defaultStyles =
|
|
42
|
+
"absolute z-10 w-44 divide-y divide-gray-100 overflow-y-clip rounded-lg bg-white shadow transition-all dark:bg-gray-700"
|
|
43
|
+
let positionStyles = {
|
|
44
|
+
"top-right": "top-30 right-0",
|
|
45
|
+
"top-left": "top-30 left-0",
|
|
46
|
+
"bottom-right": "bottom-30 right-0",
|
|
47
|
+
"bottom-left": "bottom-30 left-0",
|
|
48
|
+
}
|
|
49
|
+
let animationStyles = {
|
|
50
|
+
opened: "max-h-72 animate-expandDown",
|
|
51
|
+
closed: "max-h-0 opacity-0 animate-expandUp",
|
|
52
|
+
}
|
|
29
53
|
return (
|
|
30
|
-
<div>
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
})}
|
|
54
|
+
<div className="">
|
|
55
|
+
<div className="relative w-fit" onClick={() => handleClose(!open)}>
|
|
56
|
+
{children}
|
|
57
|
+
|
|
58
|
+
<div
|
|
59
|
+
className={clsx(
|
|
60
|
+
defaultStyles,
|
|
61
|
+
positionStyles[buttonPosition],
|
|
62
|
+
open ? animationStyles.opened : animationStyles.closed
|
|
63
|
+
)}
|
|
64
|
+
>
|
|
65
|
+
{withHeader && (
|
|
66
|
+
<div className="py-3 px-4 text-sm text-gray-900 dark:text-white">
|
|
67
|
+
<div>{headerTitle}</div>
|
|
68
|
+
<div className="truncate font-medium">{headerSubtitle}</div>
|
|
69
|
+
</div>
|
|
70
|
+
)}
|
|
71
|
+
{menuItems.map((group) => {
|
|
72
|
+
return (
|
|
73
|
+
<ul className="py-1 text-sm text-gray-700 dark:text-gray-200">
|
|
74
|
+
{group.map((item) => {
|
|
75
|
+
return (
|
|
76
|
+
<li
|
|
77
|
+
onClick={(e) => item.action(e, item.label)}
|
|
78
|
+
className={
|
|
79
|
+
item.isButton
|
|
80
|
+
? "mx-1 flex cursor-pointer flex-row items-center rounded-lg bg-primary-500 py-2 px-4 text-white hover:bg-primary-600 rtl:flex-row-reverse dark:hover:bg-primary-600 dark:hover:text-white"
|
|
81
|
+
: "mx-1 flex cursor-pointer flex-row items-center rounded-lg py-2 px-4 hover:bg-gray-100 rtl:flex-row-reverse dark:hover:bg-gray-600 dark:hover:text-white"
|
|
82
|
+
}
|
|
83
|
+
>
|
|
84
|
+
{withIcons && (
|
|
85
|
+
<div className="mr-2 rtl:ml-2">{item.icon}</div>
|
|
86
|
+
)}
|
|
87
|
+
{item.label}
|
|
88
|
+
</li>
|
|
89
|
+
)
|
|
90
|
+
})}
|
|
91
|
+
</ul>
|
|
92
|
+
)
|
|
93
|
+
})}
|
|
94
|
+
</div>
|
|
72
95
|
</div>
|
|
73
96
|
</div>
|
|
74
97
|
)
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
-
import React, { useEffect } from "react"
|
|
1
|
+
import React, { ReactElement, useEffect } from "react"
|
|
2
2
|
|
|
3
3
|
type ModalTypes = {
|
|
4
|
-
open:
|
|
5
|
-
title:
|
|
6
|
-
onClose:
|
|
7
|
-
closeOnClickOutside: any
|
|
8
|
-
modalID
|
|
9
|
-
children:
|
|
4
|
+
open: boolean
|
|
5
|
+
title: string
|
|
6
|
+
onClose: () => void
|
|
7
|
+
// closeOnClickOutside: any
|
|
8
|
+
modalID?: string
|
|
9
|
+
children: ReactElement
|
|
10
10
|
actions: any
|
|
11
11
|
}
|
|
12
12
|
export const HawaModal: React.FunctionComponent<ModalTypes> = ({
|
|
13
13
|
open,
|
|
14
14
|
title,
|
|
15
15
|
onClose,
|
|
16
|
-
closeOnClickOutside,
|
|
17
16
|
...props
|
|
18
17
|
}) => {
|
|
19
|
-
useEffect((): any => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}, [open])
|
|
18
|
+
// useEffect((): any => {
|
|
19
|
+
// if (closeOnClickOutside) {
|
|
20
|
+
// window.onclick = () => {
|
|
21
|
+
// console.log("open : ", open)
|
|
22
|
+
// if (open) {
|
|
23
|
+
// console.log("Im clicing")
|
|
24
|
+
// onClose()
|
|
25
|
+
// }
|
|
26
|
+
// }
|
|
27
|
+
// }
|
|
28
|
+
// return () => (window.onclick = null)
|
|
29
|
+
// }, [open])
|
|
31
30
|
return (
|
|
32
31
|
<div
|
|
33
32
|
id={props.modalID}
|
|
@@ -47,7 +46,7 @@ export const HawaModal: React.FunctionComponent<ModalTypes> = ({
|
|
|
47
46
|
type="button"
|
|
48
47
|
className="ml-auto inline-flex items-center rounded-lg bg-transparent p-1.5 text-sm text-gray-400 hover:bg-gray-200 hover:text-gray-900 dark:hover:bg-gray-600 dark:hover:text-white"
|
|
49
48
|
data-modal-toggle="defaultModal"
|
|
50
|
-
onClick={() => {
|
|
49
|
+
onClick={(e) => {
|
|
51
50
|
onClose()
|
|
52
51
|
}}
|
|
53
52
|
>
|