@sikka/hawa 0.0.205 → 0.0.206

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 (35) hide show
  1. package/dist/styles.css +124 -10
  2. package/es/elements/HawaButton.d.ts +4 -1
  3. package/es/elements/HawaChip.d.ts +3 -0
  4. package/es/elements/{HawaTimeline.d.ts → HawaStepper.d.ts} +1 -1
  5. package/es/elements/HawaTable.d.ts +7 -2
  6. package/es/elements/index.d.ts +1 -1
  7. package/es/index.es.js +1 -1
  8. package/lib/elements/HawaButton.d.ts +4 -1
  9. package/lib/elements/HawaChip.d.ts +3 -0
  10. package/lib/elements/{HawaTimeline.d.ts → HawaStepper.d.ts} +1 -1
  11. package/lib/elements/HawaTable.d.ts +7 -2
  12. package/lib/elements/index.d.ts +1 -1
  13. package/lib/index.js +1 -1
  14. package/package.json +1 -1
  15. package/src/blocks/AuthForms/NewPasswordForm.tsx +0 -1
  16. package/src/blocks/AuthForms/SignInPhone.tsx +2 -14
  17. package/src/blocks/AuthForms/SignUpForm.tsx +1 -5
  18. package/src/elements/Breadcrumb.tsx +5 -1
  19. package/src/elements/HawaButton.tsx +69 -44
  20. package/src/elements/HawaChip.tsx +31 -4
  21. package/src/elements/HawaDrawer.tsx +1 -4
  22. package/src/elements/HawaItemCard.tsx +0 -1
  23. package/src/elements/HawaMenu.tsx +1 -2
  24. package/src/elements/HawaModal.tsx +0 -2
  25. package/src/elements/HawaPhoneInput.tsx +1 -4
  26. package/src/elements/HawaSelect.tsx +3 -7
  27. package/src/elements/HawaStepper.tsx +97 -0
  28. package/src/elements/HawaTable.tsx +224 -209
  29. package/src/elements/HawaTabs.tsx +0 -2
  30. package/src/elements/HawaTextField.tsx +7 -6
  31. package/src/elements/index.ts +1 -1
  32. package/src/hooks/useBreakpoint.ts +2 -3
  33. package/src/hooks/useTable.ts +6 -4
  34. package/src/styles.css +124 -10
  35. package/src/elements/HawaTimeline.tsx +0 -84
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.0.205",
3
+ "version": "0.0.206",
4
4
  "description": "SaaS Oriented UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -31,7 +31,6 @@ export const NewPasswordForm: React.FunctionComponent<NewPasswordTypes> = (
31
31
  } = methods
32
32
 
33
33
  const handleSubmission = (e: any) => {
34
- console.log("handling subb", e)
35
34
  if (e.password === e.confirmPassword) {
36
35
  props.handleNewPassword()
37
36
  } else {
@@ -40,16 +40,8 @@ export const SignInPhone: React.FunctionComponent<SignInPhoneTypes> = (
40
40
  <HawaPhoneInput
41
41
  country={props.country ?? ""}
42
42
  label={props.label ?? ""}
43
- handleChange={(e: any) => {
44
- console.log("test")
45
- setUserPhone(e.target.value)
46
- }}
43
+ handleChange={(e: any) => setUserPhone(e.target.value)}
47
44
  {...field}
48
- // handleChange={(e: any) => {
49
- // // props.handlePhoneChange(e.target.value)
50
- // setUserPhone(e.target.value)
51
- // }}
52
- // value={props.value ?? props.value}
53
45
  />
54
46
  )}
55
47
  rules={{
@@ -57,11 +49,7 @@ export const SignInPhone: React.FunctionComponent<SignInPhoneTypes> = (
57
49
  }}
58
50
  />
59
51
  <div className="mt-2"></div>
60
- <HawaButton
61
- color="primary"
62
- width="full"
63
- // type="submit"
64
- >
52
+ <HawaButton color="primary" width="full">
65
53
  {props.SignInButtonText}
66
54
  </HawaButton>
67
55
  </form>
@@ -243,10 +243,7 @@ export const SignUpForm: React.FunctionComponent<SignUpFormTypes> = (props) => {
243
243
  <HawaCheckbox
244
244
  id="terms_accepted"
245
245
  helperText={errors.terms_accepted?.message}
246
- onChange={(e) => {
247
- console.log("changing ", e)
248
- field.onChange(e)
249
- }}
246
+ onChange={(e) => field.onChange(e)}
250
247
  label={
251
248
  <span>
252
249
  {props.texts.iAcceptText}{" "}
@@ -280,7 +277,6 @@ export const SignUpForm: React.FunctionComponent<SignUpFormTypes> = (props) => {
280
277
  isLoading={props.isLoading}
281
278
  color="primary"
282
279
  width="full"
283
- // type="submit"
284
280
  >
285
281
  {props.texts.signUpText}
286
282
  </HawaButton>
@@ -22,7 +22,11 @@ const Breadcrumb: FC<TBreadcrumb> = ({
22
22
  <div className="flex flex-row items-center justify-center gap-2">
23
23
  <a
24
24
  href={singleBreadcrumbLink.href}
25
- className="hover:underline hover:decoration-2"
25
+ className={
26
+ index + 1 === breadcrumbLink.length
27
+ ? "pointer-events-none"
28
+ : "underline-offset-4 transition-all hover:text-buttonPrimary-500 hover:underline hover:decoration-2"
29
+ }
26
30
  >
27
31
  {singleBreadcrumbLink.label}
28
32
  </a>
@@ -23,46 +23,10 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
23
23
  | "top-left"
24
24
  | "bottom-right"
25
25
  | "bottom-left"
26
+ startIcon?: any
27
+ endIcon?: any
26
28
  isLoading?: boolean
27
- }
28
-
29
- const baseStyles = "cursor-pointer font-medium rounded h-full transition-all"
30
-
31
- const sizeStyles = {
32
- xs: "px-1 py-1",
33
- small: "text-xs px-2.5 py-1.5",
34
- medium: "text-sm leading-4 px-3 py-2",
35
- large: "text-sm px-4 py-2",
36
- noPadding: "p-0",
37
- full: "h-full max-h-full p-2",
38
- }
39
-
40
- const widthStyles = {
41
- full: "w-full flex justify-center px-5 py-2.5 text-center inline-flex items-center",
42
- normal:
43
- "w-fit dark:bg-buttonPrimary-dark dark:hover:bg-buttonPrimary-700 dark:hover:brightness-90 dark:focus:ring-buttonPrimary-500",
44
- half: "w-1/2",
45
- }
46
- const variantStyles = {
47
- contained: "border-transparent",
48
- outlined: "bg-transparent border",
49
- }
50
-
51
- const colorStyles = {
52
- contained: {
53
- default:
54
- "text-neutral-900 bg-buttonPrimary-500 hover:bg-buttonPrimary-700 bg-buttonPrimary-500 text-white",
55
- primary:
56
- "text-white bg-buttonPrimary-500 hover:bg-buttonPrimary-700 transition-all",
57
- secondary:
58
- "text-neutral-900 bg-buttonSecondary-default hover:text-white hover:bg-buttonSecondary-700",
59
- },
60
- outlined: {
61
- default: "text-gray-600 border-gray-600 hover:bg-gray-200",
62
- primary: "text-black hover:bg-gray-50",
63
- secondary:
64
- "text-secondary-800 border-secondary-800 hover:bg-buttonSecondary-700 hover:text-white",
65
- },
29
+ badge?: any
66
30
  }
67
31
 
68
32
  const disabledSyles = "cursor-default pointer-events-none"
@@ -71,7 +35,7 @@ const disabledVariantSyles = {
71
35
  outlined: "text-gray-300 border-gray-300",
72
36
  }
73
37
 
74
- export function HawaButton({
38
+ export const HawaButton: React.FunctionComponent<ButtonProps> = ({
75
39
  className,
76
40
  variant = "contained",
77
41
  color = "default",
@@ -86,11 +50,60 @@ export function HawaButton({
86
50
  margins = "2",
87
51
  children,
88
52
  buttonID,
53
+ badge,
89
54
  ...props
90
- }: ButtonProps) {
55
+ }) => {
56
+ const baseStyles = "cursor-pointer font-medium rounded h-full transition-all"
57
+
58
+ const sizeStyles = {
59
+ xs: "px-1 py-1",
60
+ small: "text-xs px-2.5 py-1.5",
61
+ medium: "text-sm leading-4 px-3 py-2",
62
+ large: "text-sm px-4 py-2",
63
+ noPadding: "p-0",
64
+ full: "h-full max-h-full p-2",
65
+ }
66
+
67
+ const widthStyles = {
68
+ full: "w-full flex justify-center px-5 py-2.5 text-center inline-flex items-center",
69
+ half: "w-full text-center flex items-center justify-center h-full",
70
+ normal:
71
+ "w-fit dark:bg-buttonPrimary-dark dark:hover:bg-buttonPrimary-700 dark:hover:brightness-90 dark:focus:ring-buttonPrimary-500",
72
+ }
73
+ const containerWidthStyles = {
74
+ full: "w-full flex justify-center text-center inline-flex items-center",
75
+ half: "w-1/2",
76
+ normal: "w-fit",
77
+ }
78
+ const variantStyles = {
79
+ contained: "border-transparent",
80
+ outlined: "bg-transparent border",
81
+ }
82
+
83
+ const colorStyles = {
84
+ contained: {
85
+ default:
86
+ "text-neutral-900 bg-buttonPrimary-500 hover:bg-buttonPrimary-700 bg-buttonPrimary-500 text-white",
87
+ primary:
88
+ "text-white bg-buttonPrimary-500 hover:bg-buttonPrimary-700 transition-all",
89
+ secondary:
90
+ "text-neutral-900 bg-buttonSecondary-default hover:text-white hover:bg-buttonSecondary-700",
91
+ },
92
+ outlined: {
93
+ default: "text-gray-600 border-gray-600 hover:bg-gray-200",
94
+ primary: "text-black hover:bg-gray-50",
95
+ secondary:
96
+ "text-secondary-800 border-secondary-800 hover:bg-buttonSecondary-700 hover:text-white",
97
+ },
98
+ }
99
+
91
100
  return (
92
101
  <div
93
- className={clsx("relative", margins !== "none" ? `my-${margins}` : "m-0")}
102
+ className={clsx(
103
+ "relative",
104
+ margins !== "none" ? `my-${margins}` : "m-0",
105
+ containerWidthStyles[width]
106
+ )}
94
107
  >
95
108
  {tooltip ? (
96
109
  <HawaTooltip
@@ -153,11 +166,23 @@ export function HawaButton({
153
166
  }
154
167
  disabled={disabled}
155
168
  onClick={props.onClick}
156
- // {...props}
157
169
  >
158
- {!isLoading ? children : <HawaSpinner size="button" />}
170
+ {!isLoading ? (
171
+ <div className="flex flex-row items-center gap-2 whitespace-nowrap">
172
+ {props.startIcon && props.startIcon}
173
+ {children}
174
+ {props.endIcon && props.endIcon}
175
+ </div>
176
+ ) : (
177
+ <HawaSpinner size="button" />
178
+ )}
159
179
  </button>
160
180
  )}
181
+ {badge && (
182
+ <div className="absolute -top-3 -right-3 inline-flex h-6 w-6 items-center justify-center rounded-full border-2 border-white bg-red-500 text-xs font-bold text-white dark:border-gray-900">
183
+ {badge}
184
+ </div>
185
+ )}
161
186
  </div>
162
187
  )
163
188
  }
@@ -5,21 +5,48 @@ type TChipTypes = {
5
5
  label: string
6
6
  size?: "small" | "normal" | "large"
7
7
  icon?: JSX.Element
8
+ color?: string
9
+ dot?: boolean
10
+ dotType?: "available" | "unavailable"
8
11
  }
9
12
  export const HawaChip: React.FunctionComponent<TChipTypes> = ({
10
13
  size = "normal",
11
14
  label,
12
15
  icon,
16
+ color,
17
+ dot,
18
+ dotType = "available",
13
19
  }) => {
14
20
  let defaultStyles =
15
- "flex flex-row w-fit gap-1 items-center rounded bg-blue-200 px-2.5 py-0.5 font-bold text-blue-800 dark:bg-blue-200 dark:text-blue-800"
21
+ "flex flex-row w-fit gap-1 items-center rounded px-2.5 py-0.5 font-bold text-blue-800 dark:bg-blue-200 dark:text-blue-800"
16
22
  let sizeStyles = {
17
- small: "h-fit text-xs",
18
- normal: "h-full leading-4 px-3 py-2 text-xs ",
23
+ small: "h-full leading-4 px-1 py-0 text-[9px] gap-0.5 ",
24
+ normal: "h-fit text-xs",
19
25
  large: "",
20
26
  }
27
+
28
+ let dotStyles = {
29
+ small: "flex h-1 w-1 rounded-full",
30
+ normal: "flex h-2 w-2 rounded-full",
31
+ large: "flex h-3 w-3 rounded-full",
32
+ }
33
+ let dotTypeStyles = {
34
+ available: "bg-green-500",
35
+ unavailable: "bg-red-500",
36
+ }
21
37
  return (
22
- <span className={clsx(defaultStyles, sizeStyles[size])}>
38
+ <span
39
+ className={clsx(
40
+ defaultStyles,
41
+ sizeStyles[size],
42
+ color ? `bg-${color}-100 text-${color}-500` : "bg-layoutPrimary-500"
43
+ // `bg-[${color}]`
44
+ // `bg-[#c92424]`
45
+ )}
46
+ >
47
+ {dot && (
48
+ <span className={clsx(dotStyles[size], dotTypeStyles[dotType])}></span>
49
+ )}
23
50
  {icon && icon}
24
51
  {label}
25
52
  </span>
@@ -68,10 +68,7 @@ const DrawerHeader: FC<TDrawerHeader> = (props) => {
68
68
  {props.children}
69
69
  <div
70
70
  className="justify-self-end rounded border p-1 hover:cursor-pointer"
71
- onClick={() => {
72
- console.log("running")
73
- props.setOpen(false)
74
- }}
71
+ onClick={() => props.setOpen(false)}
75
72
  >
76
73
  {props.direction == "left" ? (
77
74
  <FaChevronLeft size={20} strokeWidth={2} />
@@ -64,7 +64,6 @@ export const HawaItemCard: React.FunctionComponent<ItemCardTypes> = ({
64
64
 
65
65
  useEffect((): any => {
66
66
  window.onclick = () => {
67
- console.log("clicking, state = ", openActionHeader)
68
67
  if (openActionHeader) {
69
68
  setOpenActionHeader(false)
70
69
  }
@@ -69,7 +69,6 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
69
69
  setMenuOpened(false)
70
70
  }
71
71
  }
72
- console.log("ref is", menuRef.current?.getBoundingClientRect())
73
72
  document.addEventListener("click", handleClickOutside, true)
74
73
  return () => {
75
74
  document.removeEventListener("click", handleClickOutside, true)
@@ -88,7 +87,7 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
88
87
  closed: "h-0 invisible opacity-0 hidden",
89
88
  }
90
89
  let sizeStyles = {
91
- small: "text-[11px] p-1 m-0",
90
+ small: "text-[11px] p-1 px-4 m-0",
92
91
  normal: "py-2 px-4",
93
92
  large: "",
94
93
  }
@@ -23,8 +23,6 @@ export const HawaModal: React.FunctionComponent<ModalTypes> = ({
23
23
  if (closeOnClickOutside && open) {
24
24
  window.onclick = (e) => {
25
25
  e.stopPropagation()
26
- console.log("open : ", open)
27
- console.log("Im clicing")
28
26
  onClose()
29
27
  }
30
28
  }
@@ -91,10 +91,7 @@ export const HawaPhoneInput: React.FunctionComponent<HawaPhoneInputTypes> = (
91
91
  placeholder="+966"
92
92
  defaultValue={props.preferredCountry}
93
93
  value={selectedCountry}
94
- onChange={(newValue, action) => {
95
- console.log("test n", newValue)
96
- setSelectedCountry(newValue)
97
- }}
94
+ onChange={(newValue, action) => setSelectedCountry(newValue)}
98
95
  />
99
96
  <input
100
97
  onChange={props.handleChange}
@@ -175,14 +175,10 @@ export const HawaSelect: React.FunctionComponent<SelectTypes> = (props) => {
175
175
  isMulti={props.isMulti}
176
176
  isSearchable={props.isSearchable}
177
177
  onCreateOption={() => console.log("im changing")}
178
- onChange={(newValue, action) => {
179
- console.log("this is onChange", newValue)
180
- props.onChange(newValue, action)
181
- }}
182
- onInputChange={(newValue, action) => {
183
- console.log("onInputChange====", newValue)
178
+ onChange={(newValue, action) => props.onChange(newValue, action)}
179
+ onInputChange={(newValue, action) =>
184
180
  props.onInputChange(newValue, action)
185
- }}
181
+ }
186
182
  />
187
183
  )}
188
184
  {props.helperText && (
@@ -0,0 +1,97 @@
1
+ import React from "react"
2
+ import clsx from "clsx"
3
+ import { FaCheck } from "react-icons/fa"
4
+
5
+ type THawaTimeline = {
6
+ steps: any[any]
7
+ currentStep: any
8
+ orientation: "vertical" | "horizontal"
9
+ }
10
+
11
+ export const HawaStepper: React.FunctionComponent<THawaTimeline> = ({
12
+ orientation = "horizontal",
13
+ ...props
14
+ }) => {
15
+ let orientationStyles = {
16
+ vertical: "flex flex-col items-start w-fit",
17
+ horizontal: "flex flex-row",
18
+ }
19
+ let lineStyles = {
20
+ vertical: "w-1 h-32 rounded bg-red-200 ml-6 my-2",
21
+ horizontal: "h-0.5 flex w-full rounded bg-red-200",
22
+ }
23
+ return (
24
+ <div
25
+ className={clsx(
26
+ orientationStyles[orientation],
27
+ " flex-wrap justify-start gap-4"
28
+ )}
29
+ >
30
+ {props.steps.map((step: any, i: number) => {
31
+ return (
32
+ <div className="my-2 flex w-auto flex-row flex-wrap justify-start ">
33
+ <div
34
+ className={
35
+ orientation === "vertical"
36
+ ? "flex w-full flex-row items-center"
37
+ : i + 1 === props.steps.length
38
+ ? "flex w-full flex-row items-center justify-start gap-2"
39
+ : "flex flex-row items-center justify-start gap-2 after:mx-2 after:hidden after:h-1 after:w-10 after:border-b after:border-gray-200 dark:after:border-gray-700 sm:after:inline-block sm:after:content-[''] md:w-full xl:after:mx-10"
40
+ }
41
+ >
42
+ <div className="flex flex-row gap-2 ">
43
+ {/* Icon */}
44
+ <div
45
+ className={clsx(
46
+ "ring-buttonPrimary-200 flex h-6 w-6 min-w-[24px] items-center justify-center rounded ring-2 ring-offset-2",
47
+ i + 1 <= props.currentStep
48
+ ? "bg-buttonPrimary-500 text-white"
49
+ : "bg-buttonPrimary-200"
50
+ )}
51
+ >
52
+ {i + 1 <= props.currentStep ? (
53
+ <FaCheck fontSize={11} />
54
+ ) : (
55
+ i + 1
56
+ )}
57
+ </div>
58
+ {/* Text */}
59
+ <div className="whitespace-nowrap">{step}</div>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ )
64
+ })}
65
+ </div>
66
+ )
67
+ }
68
+
69
+ const TimelineStep = (props) => {
70
+ let defaultStyles = {
71
+ vertical: "",
72
+ horizontal: "",
73
+ }
74
+ return (
75
+ <div
76
+ className={
77
+ props.orientation === "vertical"
78
+ ? "flex w-full flex-row items-center"
79
+ : props.stepNumber === props.steps
80
+ ? "flex items-center"
81
+ : "after:border-1 flex items-center after:mx-6 after:hidden after:h-1 after:w-10 after:border-b after:border-gray-200 dark:after:border-gray-700 sm:after:inline-block sm:after:content-[''] md:w-full xl:after:mx-10"
82
+ }
83
+ >
84
+ <div
85
+ className={clsx(
86
+ "ring-buttonPrimary-200 m-2 mr-4 flex h-6 w-6 items-center justify-center rounded ring-2 ring-offset-2",
87
+ props.current
88
+ ? "bg-buttonPrimary-500 text-white"
89
+ : "bg-buttonPrimary-200"
90
+ )}
91
+ >
92
+ {props.current ? <FaCheck fontSize={11} /> : props.stepNumber}
93
+ </div>
94
+ <div className="whitespace-nowrap">{props.stepName}</div>
95
+ </div>
96
+ )
97
+ }