@sikka/hawa 0.0.101 → 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.
Files changed (43) hide show
  1. package/dist/styles.css +3 -0
  2. package/es/elements/DraggableCard.d.ts +2 -2
  3. package/es/elements/HawaCheckbox.d.ts +4 -4
  4. package/es/elements/HawaChip.d.ts +3 -3
  5. package/es/elements/HawaColorPicker.d.ts +1 -1
  6. package/es/elements/HawaCopyrights.d.ts +4 -2
  7. package/es/elements/HawaDrawer.d.ts +18 -8
  8. package/es/elements/HawaMenu.d.ts +19 -13
  9. package/es/elements/HawaModal.d.ts +6 -7
  10. package/es/elements/HawaRange.d.ts +2 -0
  11. package/es/elements/HawaSettingsRow.d.ts +14 -1
  12. package/es/index.es.js +1 -1
  13. package/lib/elements/DraggableCard.d.ts +2 -2
  14. package/lib/elements/HawaCheckbox.d.ts +4 -4
  15. package/lib/elements/HawaChip.d.ts +3 -3
  16. package/lib/elements/HawaColorPicker.d.ts +1 -1
  17. package/lib/elements/HawaCopyrights.d.ts +4 -2
  18. package/lib/elements/HawaDrawer.d.ts +18 -8
  19. package/lib/elements/HawaMenu.d.ts +19 -13
  20. package/lib/elements/HawaModal.d.ts +6 -7
  21. package/lib/elements/HawaRange.d.ts +2 -0
  22. package/lib/elements/HawaSettingsRow.d.ts +14 -1
  23. package/lib/index.js +1 -1
  24. package/package.json +3 -2
  25. package/rollup.config.js +4 -0
  26. package/src/elements/DraggableCard.tsx +2 -2
  27. package/src/elements/HawaCheckbox.tsx +11 -6
  28. package/src/elements/HawaChip.tsx +3 -3
  29. package/src/elements/HawaColorPicker.tsx +2 -2
  30. package/src/elements/HawaCopyrights.tsx +8 -15
  31. package/src/elements/HawaDrawer.tsx +42 -23
  32. package/src/elements/HawaMenu.tsx +24 -17
  33. package/src/elements/HawaModal.tsx +20 -21
  34. package/src/elements/HawaRange.tsx +2 -0
  35. package/src/elements/HawaSettingsRow.tsx +29 -38
  36. package/src/elements/HawaTabs.tsx +1 -1
  37. package/src/styles.css +3 -0
  38. package/storybook-static/{733.8d2de9f8.iframe.bundle.js → 209.3141149a.iframe.bundle.js} +2 -2
  39. package/storybook-static/{733.8d2de9f8.iframe.bundle.js.LICENSE.txt → 209.3141149a.iframe.bundle.js.LICENSE.txt} +0 -0
  40. package/storybook-static/iframe.html +1 -1
  41. package/storybook-static/main.2fac3c3c.iframe.bundle.js +1 -0
  42. package/storybook-static/project.json +1 -1
  43. 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.101",
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/**",
@@ -1,6 +1,6 @@
1
- import React from "react"
1
+ import React, { ReactElement } from "react"
2
2
  type DraggableCardTypes = {
3
- children: any
3
+ children: ReactElement
4
4
  }
5
5
 
6
6
  export const DraggableCard: React.FunctionComponent<DraggableCardTypes> = (
@@ -1,20 +1,25 @@
1
- import React from "react"
1
+ import React, { ReactElement } from "react"
2
2
 
3
- type CheckoutTypes = {
4
- centered?: any
3
+ type TCheckBoxTypes = {
4
+ centered?: boolean
5
5
  label?: any
6
6
  helperText?: any
7
- onChange?: any
7
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
8
8
  }
9
9
 
10
- export const HawaCheckbox: React.FunctionComponent<CheckoutTypes> = (props) => {
10
+ export const HawaCheckbox: React.FunctionComponent<TCheckBoxTypes> = (props) => {
11
11
  return (
12
12
  <div
13
- className={props.centered ? "flex h-full items-center" : "flex h-full"}
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 ChipTypes = {
4
- label: any
3
+ type TChipTypes = {
4
+ label: string
5
5
  }
6
- export const HawaChip: React.FunctionComponent<ChipTypes> = (props) => {
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?: any
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.target.value)
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: any
4
+ withLogo: boolean
5
5
  lang: any
6
- version: any
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="/qawaim-logo.svg"
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 DrawerTypes = {
6
- open: any
5
+ type TDrawerTypes = {
6
+ open: boolean
7
7
  setOpen: any
8
8
  position: any
9
9
  heading: any
10
- children: any
10
+ children?: ReactNode
11
11
  }
12
12
 
13
- export const HawaDrawer: React.FunctionComponent<DrawerTypes> = ({
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
- // if (
31
- // // React.isValidElement(child) &&
32
- // // child.type.name == "DrawerHeader"
33
- // ) {
34
- // return React.cloneElement(child, {
35
- // // setOpen: setOpen,
36
- // // children: child.props.children,
37
- // })
38
- // }
39
- // if (React.isValidElement(child) && child.type.name == "DrawerBody") {
40
- // return React.cloneElement(child, { children: child.props })
41
- // }
42
- // if (React.isValidElement(child) && child.type.name == "DrawerFooter") {
43
- // return React.cloneElement(child, { children: child.props.children })
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
- export const DrawerHeader = (props: any) => {
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
- export const DrawerBody = (props: any) => {
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
- export const DrawerFooter = (props: any) => {
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
- type MenuTypes = {
4
+ interface TMenuTypes {
5
5
  popMenuID: any
6
- menuItems: any
6
+ menuItems: MenuItems[][]
7
7
  //
8
8
  // icon: PropTypes.element,
9
9
  // label: PropTypes.string,
10
10
  // action: PropTypes.func,
11
11
  //
12
- withHeader: any
13
- withIcons: any
14
- headerTitle: any
15
- headerSubtitle: any
16
- open: any
17
- handleClose: any
18
- anchor: any
19
- children: any
20
- buttonPosition: "top-right" | "top-left" | "bottom-right" | "bottom-left"
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
- export const HawaMenu: React.FunctionComponent<MenuTypes> = ({
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: any) => {
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: any) => {
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.button
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: any
5
- title: any
6
- onClose: any
7
- closeOnClickOutside: any
8
- modalID: any
9
- children: any
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
- if (closeOnClickOutside) {
21
- window.onclick = () => {
22
- console.log("open : ", open)
23
- if (open) {
24
- console.log("Im clicing")
25
- onClose()
26
- }
27
- }
28
- }
29
- return () => (window.onclick = null)
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
  >
@@ -6,6 +6,8 @@ type RangeTypes = {
6
6
  startElement?: any
7
7
  endElement?: any
8
8
  label?: any
9
+ min?: any
10
+ max?: any
9
11
  }
10
12
 
11
13
  export const HawaRange: React.FunctionComponent<RangeTypes> = ({
@@ -6,51 +6,42 @@ import { HawaColorPicker } from "./HawaColorPicker"
6
6
  import { HawaRange } from "./HawaRange"
7
7
  import { HawaCheckbox } from "./HawaCheckbox"
8
8
  import { HawaTabs } from "./HawaTabs"
9
+ import { HawaRadio } from "./HawaRadio"
9
10
 
10
11
  type SettingsRowTypes = {
11
12
  settingsLabel: any
12
- settingsType: any
13
- // settingsType: PropTypes.oneOf([
14
- // "checkbox",
15
- // "text",
16
- // "radio",
17
- // "boolean",
18
- // "color",
19
- // ]),
13
+ settingsType: "checkbox" | "text" | "radio" | "boolean" | "color" | "range"
14
+ radioProps: {
15
+ defaultValue: any
16
+ onChangeTab: any
17
+ options: any
18
+ }
19
+ colorProps: {
20
+ color?: any
21
+ handleChange?: any
22
+ }
23
+ rangeProps: {
24
+ min?: any
25
+ max?: any
26
+ }
20
27
  }
21
28
 
22
- export const HawaSettingsRow: React.FunctionComponent<SettingsRowTypes> = (
23
- props
24
- ) => {
29
+ export const HawaSettingsRow: React.FunctionComponent<SettingsRowTypes> = ({
30
+ settingsLabel,
31
+ settingsType,
32
+ colorProps,
33
+ rangeProps,
34
+ radioProps,
35
+ }) => {
25
36
  return (
26
37
  <div className="my-2 flex max-h-fit flex-row items-center justify-between rounded-xl bg-white px-4 py-2 pr-2 align-middle">
27
- <HawaTypography>{props.settingsLabel}</HawaTypography>
28
- {props.settingsType === "checkbox" && (
29
- <HawaCheckbox centered {...props} />
30
- )}
31
- {props.settingsType === "text" && (
32
- <HawaTextField margin="none" {...props} />
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
- )}
38
+ <HawaTypography>{settingsLabel}</HawaTypography>
39
+ {settingsType === "checkbox" && <HawaCheckbox centered />}
40
+ {settingsType === "text" && <HawaTextField margin="none" width="small" />}
41
+ {settingsType === "boolean" && <HawaSwitch />}
42
+ {settingsType === "range" && <HawaRange {...rangeProps} />}
43
+ {settingsType === "color" && <HawaColorPicker {...colorProps} />}
44
+ {settingsType === "radio" && <HawaTabs {...radioProps} />}
54
45
  </div>
55
46
  )
56
47
  }
@@ -15,7 +15,7 @@ export const HawaTabs: React.FunctionComponent<TabsTypes> = (props) => {
15
15
  return (
16
16
  <div>
17
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) => (
18
+ {props.options?.map((opt: any) => (
19
19
  <li>
20
20
  <button
21
21
  aria-current="page"
package/src/styles.css CHANGED
@@ -903,6 +903,9 @@ video {
903
903
  .justify-evenly {
904
904
  justify-content: space-evenly;
905
905
  }
906
+ .gap-1 {
907
+ gap: 0.25rem;
908
+ }
906
909
  .gap-x-3 {
907
910
  -moz-column-gap: 0.75rem;
908
911
  column-gap: 0.75rem;