@sikka/hawa 0.0.101 → 0.0.103
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 +26 -30
- 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 -13
- package/es/elements/HawaModal.d.ts +6 -7
- package/es/elements/HawaRadio.d.ts +3 -1
- 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 -13
- package/lib/elements/HawaModal.d.ts +6 -7
- package/lib/elements/HawaRadio.d.ts +3 -1
- 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/DraggableCard.tsx +2 -2
- package/src/elements/HawaCheckbox.tsx +16 -9
- 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 +24 -17
- package/src/elements/HawaModal.tsx +20 -21
- package/src/elements/HawaRadio.tsx +27 -24
- package/src/elements/HawaRange.tsx +2 -0
- package/src/elements/HawaSettingsRow.tsx +29 -41
- package/src/elements/HawaTabs.tsx +16 -7
- package/src/styles.css +26 -30
- package/storybook-static/209.70afd616.iframe.bundle.js +2 -0
- package/storybook-static/{733.8d2de9f8.iframe.bundle.js.LICENSE.txt → 209.70afd616.iframe.bundle.js.LICENSE.txt} +15 -11
- package/storybook-static/745.4b81597c.iframe.bundle.js +1 -0
- package/storybook-static/{767.2f9c96fa3338c8d16078.manager.bundle.js → 767.888009dba401078f3f72.manager.bundle.js} +2 -2
- package/storybook-static/{767.2f9c96fa3338c8d16078.manager.bundle.js.LICENSE.txt → 767.888009dba401078f3f72.manager.bundle.js.LICENSE.txt} +22 -19
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/index.html +1 -1
- package/storybook-static/main.ff0dd517.iframe.bundle.js +1 -0
- package/storybook-static/project.json +1 -1
- package/storybook-static/runtime~main.968bd8b6.iframe.bundle.js +1 -0
- package/storybook-static/733.8d2de9f8.iframe.bundle.js +0 -2
- package/storybook-static/main.71507dcb.iframe.bundle.js +0 -1
- package/storybook-static/runtime~main.4d0bf318.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.103",
|
|
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/**",
|
|
@@ -1,27 +1,34 @@
|
|
|
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> = (
|
|
11
|
+
props
|
|
12
|
+
) => {
|
|
11
13
|
return (
|
|
12
14
|
<div
|
|
13
|
-
className={
|
|
15
|
+
className={
|
|
16
|
+
props.centered
|
|
17
|
+
? "flex h-full items-center justify-center"
|
|
18
|
+
: "flex h-full items-start"
|
|
19
|
+
}
|
|
14
20
|
>
|
|
15
21
|
<input
|
|
16
22
|
type="checkbox"
|
|
17
23
|
value=""
|
|
18
|
-
|
|
24
|
+
onChange={(e) => props.onChange(e)}
|
|
25
|
+
className="mt-0.5 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
26
|
{...props}
|
|
20
27
|
/>
|
|
21
28
|
{(props.label || props.helperText) && (
|
|
22
|
-
<div className="
|
|
29
|
+
<div className=" flex flex-col">
|
|
23
30
|
{props.label && (
|
|
24
|
-
<label className="
|
|
31
|
+
<label className="mx-2 text-sm font-medium text-gray-900 dark:text-gray-300">
|
|
25
32
|
{props.label}
|
|
26
33
|
</label>
|
|
27
34
|
)}
|
|
@@ -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,26 +1,33 @@
|
|
|
1
1
|
import clsx from "clsx"
|
|
2
|
-
import React from "react"
|
|
2
|
+
import React, { ReactNode } from "react"
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface TMenuTypes {
|
|
5
5
|
popMenuID: any
|
|
6
|
-
menuItems:
|
|
6
|
+
menuItems: MenuItems[][]
|
|
7
7
|
//
|
|
8
8
|
// icon: PropTypes.element,
|
|
9
9
|
// label: PropTypes.string,
|
|
10
10
|
// action: PropTypes.func,
|
|
11
11
|
//
|
|
12
|
-
withHeader
|
|
13
|
-
withIcons
|
|
14
|
-
headerTitle
|
|
15
|
-
headerSubtitle
|
|
16
|
-
open:
|
|
17
|
-
handleClose:
|
|
18
|
-
anchor
|
|
19
|
-
children
|
|
20
|
-
buttonPosition
|
|
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"
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
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> = ({
|
|
24
31
|
menuItems,
|
|
25
32
|
withHeader,
|
|
26
33
|
withIcons,
|
|
@@ -61,15 +68,15 @@ export const HawaMenu: React.FunctionComponent<MenuTypes> = ({
|
|
|
61
68
|
<div className="truncate font-medium">{headerSubtitle}</div>
|
|
62
69
|
</div>
|
|
63
70
|
)}
|
|
64
|
-
{menuItems.map((group
|
|
71
|
+
{menuItems.map((group) => {
|
|
65
72
|
return (
|
|
66
73
|
<ul className="py-1 text-sm text-gray-700 dark:text-gray-200">
|
|
67
|
-
{group.map((item
|
|
74
|
+
{group.map((item) => {
|
|
68
75
|
return (
|
|
69
76
|
<li
|
|
70
|
-
onClick={item.action}
|
|
77
|
+
onClick={(e) => item.action(e, item.label)}
|
|
71
78
|
className={
|
|
72
|
-
item.
|
|
79
|
+
item.isButton
|
|
73
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"
|
|
74
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"
|
|
75
82
|
}
|
|
@@ -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
|
>
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import React from "react"
|
|
1
|
+
import React, { useState } from "react"
|
|
2
2
|
|
|
3
3
|
type RadioTypes = {
|
|
4
|
-
options
|
|
4
|
+
options?: any
|
|
5
|
+
onChangeTab?: any
|
|
6
|
+
defaultValue?: any
|
|
5
7
|
}
|
|
6
8
|
export const HawaRadio: React.FunctionComponent<RadioTypes> = (props) => {
|
|
9
|
+
const [selectedOption, setSelectedOption] = useState(props.defaultValue)
|
|
10
|
+
let activeTabStyle =
|
|
11
|
+
"inline-block py-2 px-4 text-white bg-blue-600 rounded-lg active"
|
|
12
|
+
let inactiveTabStyle =
|
|
13
|
+
"inline-block py-2 px-4 rounded-lg hover:text-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 dark:hover:text-white"
|
|
14
|
+
|
|
7
15
|
return (
|
|
8
16
|
<div>
|
|
9
|
-
<ul className="w-
|
|
10
|
-
{props.options
|
|
11
|
-
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
</label>
|
|
27
|
-
</div>
|
|
28
|
-
</li>
|
|
29
|
-
)
|
|
30
|
-
})}
|
|
17
|
+
<ul className="flex w-fit flex-wrap rounded-lg bg-gray-100 text-center text-sm font-medium text-gray-500 dark:text-gray-400">
|
|
18
|
+
{props.options?.map((opt: any) => (
|
|
19
|
+
<li>
|
|
20
|
+
<button
|
|
21
|
+
aria-current="page"
|
|
22
|
+
onClick={() => {
|
|
23
|
+
setSelectedOption(opt.value)
|
|
24
|
+
props.onChangeTab(opt.value)
|
|
25
|
+
}}
|
|
26
|
+
className={
|
|
27
|
+
selectedOption === opt.value ? activeTabStyle : inactiveTabStyle
|
|
28
|
+
}
|
|
29
|
+
>
|
|
30
|
+
{opt.label}
|
|
31
|
+
</button>
|
|
32
|
+
</li>
|
|
33
|
+
))}
|
|
31
34
|
</ul>
|
|
32
35
|
</div>
|
|
33
36
|
)
|
|
@@ -4,53 +4,41 @@ import { HawaTextField } from "./HawaTextField"
|
|
|
4
4
|
import { HawaSwitch } from "./HawaSwitch"
|
|
5
5
|
import { HawaColorPicker } from "./HawaColorPicker"
|
|
6
6
|
import { HawaRange } from "./HawaRange"
|
|
7
|
-
import {
|
|
8
|
-
import { HawaTabs } from "./HawaTabs"
|
|
7
|
+
import { HawaRadio } from "./HawaRadio"
|
|
9
8
|
|
|
10
9
|
type SettingsRowTypes = {
|
|
11
10
|
settingsLabel: any
|
|
12
|
-
settingsType:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
settingsType: "text" | "radio" | "boolean" | "color" | "range"
|
|
12
|
+
radioProps: {
|
|
13
|
+
defaultValue: any
|
|
14
|
+
onChangeTab: any
|
|
15
|
+
options: any
|
|
16
|
+
}
|
|
17
|
+
colorProps: {
|
|
18
|
+
color?: any
|
|
19
|
+
handleChange?: any
|
|
20
|
+
}
|
|
21
|
+
rangeProps: {
|
|
22
|
+
min?: any
|
|
23
|
+
max?: any
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
export const HawaSettingsRow: React.FunctionComponent<SettingsRowTypes> = (
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
export const HawaSettingsRow: React.FunctionComponent<SettingsRowTypes> = ({
|
|
28
|
+
settingsLabel,
|
|
29
|
+
settingsType,
|
|
30
|
+
colorProps,
|
|
31
|
+
rangeProps,
|
|
32
|
+
radioProps,
|
|
33
|
+
}) => {
|
|
25
34
|
return (
|
|
26
|
-
<div className="my-
|
|
27
|
-
<HawaTypography>{
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
)}
|
|
34
|
-
{props.settingsType === "boolean" && (
|
|
35
|
-
<HawaSwitch
|
|
36
|
-
// {...props}
|
|
37
|
-
/>
|
|
38
|
-
)}
|
|
39
|
-
{props.settingsType === "range" && (
|
|
40
|
-
<HawaRange
|
|
41
|
-
// {...props}
|
|
42
|
-
/>
|
|
43
|
-
)}
|
|
44
|
-
{props.settingsType === "color" && (
|
|
45
|
-
<HawaColorPicker
|
|
46
|
-
// {...props}
|
|
47
|
-
/>
|
|
48
|
-
)}
|
|
49
|
-
{props.settingsType === "radio" && (
|
|
50
|
-
<HawaTabs
|
|
51
|
-
// {...props}
|
|
52
|
-
/>
|
|
53
|
-
)}
|
|
35
|
+
<div className="my-0.5 flex max-h-fit flex-row items-center justify-between rounded-xl bg-white px-4 py-2 pr-2 align-middle">
|
|
36
|
+
<HawaTypography>{settingsLabel}</HawaTypography>
|
|
37
|
+
{settingsType === "text" && <HawaTextField margin="none" width="small" />}
|
|
38
|
+
{settingsType === "boolean" && <HawaSwitch />}
|
|
39
|
+
{settingsType === "range" && <HawaRange {...rangeProps} />}
|
|
40
|
+
{settingsType === "color" && <HawaColorPicker {...colorProps} />}
|
|
41
|
+
{settingsType === "radio" && <HawaRadio {...radioProps} />}
|
|
54
42
|
</div>
|
|
55
43
|
)
|
|
56
44
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import clsx from "clsx"
|
|
1
2
|
import React, { useState } from "react"
|
|
2
3
|
|
|
3
4
|
type TabsTypes = {
|
|
@@ -8,14 +9,19 @@ type TabsTypes = {
|
|
|
8
9
|
export const HawaTabs: React.FunctionComponent<TabsTypes> = (props) => {
|
|
9
10
|
const [selectedOption, setSelectedOption] = useState(props.defaultValue)
|
|
10
11
|
let activeTabStyle =
|
|
11
|
-
"inline-block py-2 px-4 text-white bg-
|
|
12
|
+
"inline-block py-2 px-4 text-white bg-primary-500 rounded-lg rounded-br-none rounded-bl-none active"
|
|
12
13
|
let inactiveTabStyle =
|
|
13
|
-
"inline-block py-2 px-4 rounded-lg hover:text-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 dark:hover:text-white"
|
|
14
|
+
"inline-block py-2 px-4 rounded-lg rounded-br-none rounded-bl-none hover:text-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 dark:hover:text-white"
|
|
14
15
|
|
|
15
16
|
return (
|
|
16
17
|
<div>
|
|
17
|
-
<ul
|
|
18
|
-
{
|
|
18
|
+
<ul
|
|
19
|
+
className={clsx(
|
|
20
|
+
"flex w-fit flex-wrap rounded-lg rounded-br-none rounded-bl-none border-b-primary-500 bg-gray-100 text-center text-sm font-medium text-gray-500 dark:text-gray-400",
|
|
21
|
+
selectedOption ? "border-b-2" : "border-b-0"
|
|
22
|
+
)}
|
|
23
|
+
>
|
|
24
|
+
{props.options?.map((opt: any) => (
|
|
19
25
|
<li>
|
|
20
26
|
<button
|
|
21
27
|
aria-current="page"
|
|
@@ -23,9 +29,12 @@ export const HawaTabs: React.FunctionComponent<TabsTypes> = (props) => {
|
|
|
23
29
|
setSelectedOption(opt.value)
|
|
24
30
|
props.onChangeTab(opt.value)
|
|
25
31
|
}}
|
|
26
|
-
className={
|
|
27
|
-
selectedOption === opt.value
|
|
28
|
-
|
|
32
|
+
className={clsx(
|
|
33
|
+
selectedOption === opt.value
|
|
34
|
+
? activeTabStyle
|
|
35
|
+
: inactiveTabStyle,
|
|
36
|
+
"transition-all"
|
|
37
|
+
)}
|
|
29
38
|
>
|
|
30
39
|
{opt.label}
|
|
31
40
|
</button>
|