@sikka/hawa 0.0.199 → 0.0.201

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.
@@ -23,7 +23,7 @@ type HawaAppLayoutTypes = {
23
23
  type MenuItems = {
24
24
  icon?: JSX.Element;
25
25
  label: string;
26
- action?: (e: React.MouseEvent<HTMLLIElement, MouseEvent>, item: string) => void;
26
+ action?: (e: any) => void;
27
27
  isButton?: boolean;
28
28
  };
29
29
  export declare const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sikka/hawa",
3
- "version": "0.0.199",
3
+ "version": "0.0.201",
4
4
  "description": "SaaS Oriented UI Kit",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.es.js",
@@ -18,10 +18,7 @@ interface ItemCardTypes {
18
18
  type THeaderActions = {
19
19
  icon?: JSX.Element
20
20
  label: string
21
- action?: (
22
- e: React.MouseEvent<HTMLLIElement, MouseEvent>,
23
- item: string
24
- ) => void
21
+ action?: (e: any) => void
25
22
  isButton?: boolean
26
23
  }
27
24
  export const HawaItemCard: React.FunctionComponent<ItemCardTypes> = ({
@@ -1,5 +1,6 @@
1
1
  import clsx from "clsx"
2
2
  import React, { ReactNode, useEffect, useRef, useState } from "react"
3
+
3
4
  // TODO: add width to decrease width
4
5
 
5
6
  interface TMenuTypes {
@@ -20,16 +21,15 @@ interface TMenuTypes {
20
21
  | "bottom-right"
21
22
  | "bottom-left"
22
23
  onClickOutside?: any
24
+ actionedItem?: any
23
25
  size?: "small" | "normal" | "large"
24
26
  }
25
27
 
26
28
  type MenuItems = {
27
29
  icon?: JSX.Element
28
30
  label: string
29
- action?: (
30
- e: React.MouseEvent<HTMLLIElement, MouseEvent>,
31
- item: string
32
- ) => void
31
+ // action?: (item: any) => void
32
+ action?: (e: any) => void
33
33
  isButton?: boolean
34
34
  element?: any
35
35
  }
@@ -43,6 +43,7 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
43
43
  size = "normal",
44
44
  children,
45
45
  onClickOutside,
46
+ actionedItem,
46
47
  position = "top-right",
47
48
  }) => {
48
49
  const [menuOpened, setMenuOpened] = useState(false)
@@ -196,7 +197,7 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
196
197
  </li>
197
198
  ) : (
198
199
  <li
199
- onClick={(e) => item.action(e, item.label)}
200
+ onClick={() => item?.action(actionedItem)}
200
201
  className={clsx(
201
202
  item.isButton
202
203
  ? "flex cursor-pointer flex-row items-center rounded bg-buttonPrimary-500 py-2 px-4 text-white hover:bg-buttonPrimary-700 rtl:flex-row-reverse dark:hover:bg-buttonPrimary-700 dark:hover:text-white"
@@ -205,7 +206,13 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
205
206
  )}
206
207
  >
207
208
  {item.icon && (
208
- <div className="mr-2 rtl:ml-2">{item.icon}</div>
209
+ <div
210
+ className={
211
+ size === "small" ? "mr-1 rtl:ml-1" : "mr-2 rtl:ml-2"
212
+ }
213
+ >
214
+ {item.icon}
215
+ </div>
209
216
  )}
210
217
  {item.label}
211
218
  </li>
@@ -2,8 +2,7 @@ import React from "react"
2
2
  import { BsThreeDotsVertical } from "react-icons/bs"
3
3
  import clsx from "clsx"
4
4
  import { HawaMenu } from "./HawaMenu"
5
- // TODO: make action click return row
6
- // TODO: make action column width max fit
5
+
7
6
  type TableTypes = {
8
7
  columns: any[string]
9
8
  actions?: ActionItems[][]
@@ -18,15 +17,13 @@ type TableTypes = {
18
17
  clickable?: boolean
19
18
  actionsText?: string
20
19
  bordersWidth?: string
20
+ onActionClicked?: any
21
21
  borders?: "all" | "cols" | "rows" | "outer" | "inner"
22
22
  }
23
23
  type ActionItems = {
24
24
  icon?: JSX.Element
25
25
  label: string
26
- action?: (
27
- e: React.MouseEvent<HTMLLIElement, MouseEvent>,
28
- item: string
29
- ) => void
26
+ action?: (e: any) => void
30
27
  isButton?: boolean
31
28
  element?: any
32
29
  }
@@ -56,22 +53,32 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
56
53
  >
57
54
  <thead className=" text-xs uppercase text-gray-700 dark:bg-gray-700 dark:text-gray-400">
58
55
  <tr>
59
- {props.columns.map((col: any, i: any) => (
56
+ {props.columns.map((col: any, i: any) => {
57
+ if (col.hidden) {
58
+ return
59
+ } else {
60
+ return (
61
+ <th
62
+ key={i}
63
+ scope="col"
64
+ colSpan={2}
65
+ className={clsx(
66
+ sizeStyles[size],
67
+ i !== 0 && (borders === "cols" || borders === "all")
68
+ ? `border-l border-l-[${bordersWidth}px]`
69
+ : ""
70
+ )}
71
+ >
72
+ {col.value}
73
+ </th>
74
+ )
75
+ }
76
+ })}
77
+ {props.actions && size !== "small" ? (
60
78
  <th
61
- key={i}
62
79
  scope="col"
63
- className={clsx(
64
- sizeStyles[size],
65
- i !== 0 && (borders === "cols" || borders === "all")
66
- ? `border-l border-l-[${bordersWidth}px]`
67
- : ""
68
- )}
80
+ className={clsx(sizeStyles[size], "w-[calc(1%)] text-center")}
69
81
  >
70
- {col}
71
- </th>
72
- ))}
73
- {props.actions && size !== "small" ? (
74
- <th scope="col" className={clsx(sizeStyles[size], "text-center")}>
75
82
  {props.actionsText}
76
83
  </th>
77
84
  ) : null}
@@ -85,7 +92,9 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
85
92
  {/* Table Rows */}
86
93
  {props.rows ? (
87
94
  props.rows.map((singleRow: any, rowIndex: any) => {
95
+ console.log("single row is ", singleRow)
88
96
  let lastRow = rowIndex == props.rows.length - 1
97
+
89
98
  return (
90
99
  <tr
91
100
  key={rowIndex}
@@ -110,40 +119,45 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
110
119
  let isLTRLastCell =
111
120
  !isRTL && lastRow && lastCell && !props.actions
112
121
 
113
- return (
114
- <td
115
- key={i}
116
- className={clsx(
117
- sizeStyles[size],
118
- highlightFirst && firstCell
119
- ? "font-bold"
120
- : "font-normal",
121
- isRTLFirstCell
122
- ? "rounded-bl-none rounded-br"
123
- : isRTLLastCell
124
- ? "rounded-br-none rounded-bl"
125
- : isLTRFirstCell
126
- ? "rounded-br-none rounded-bl"
127
- : isLTRLastCell
128
- ? "rounded-bl-none rounded-br"
129
- : "",
122
+ if (r.hidden) {
123
+ return
124
+ } else {
125
+ return (
126
+ <td
127
+ colSpan={2}
128
+ key={i}
129
+ className={clsx(
130
+ sizeStyles[size],
131
+ highlightFirst && firstCell
132
+ ? "font-bold"
133
+ : "font-normal",
134
+ isRTLFirstCell
135
+ ? "rounded-bl-none rounded-br"
136
+ : isRTLLastCell
137
+ ? "rounded-br-none rounded-bl"
138
+ : isLTRFirstCell
139
+ ? "rounded-br-none rounded-bl"
140
+ : isLTRLastCell
141
+ ? "rounded-bl-none rounded-br"
142
+ : "",
130
143
 
131
- !firstCell &&
132
- !lastCell &&
133
- (borders === "cols" || borders === "inner")
134
- ? `border-l border-l-[${bordersWidth}px] border-r border-r-[${bordersWidth}px]`
135
- : !firstCell &&
136
- props.actions &&
144
+ !firstCell &&
145
+ !lastCell &&
137
146
  (borders === "cols" || borders === "inner")
138
- ? `border-l border-l-[${bordersWidth}px] border-r border-r-[${bordersWidth}px]`
139
- : ""
147
+ ? `border-l border-l-[${bordersWidth}px] border-r border-r-[${bordersWidth}px]`
148
+ : !firstCell &&
149
+ props.actions &&
150
+ (borders === "cols" || borders === "inner")
151
+ ? `border-l border-l-[${bordersWidth}px] border-r border-r-[${bordersWidth}px]`
152
+ : ""
140
153
 
141
- // customColor ? `bg-${customColor}` : "bg-white"
142
- )}
143
- >
144
- {r}
145
- </td>
146
- )
154
+ // customColor ? `bg-${customColor}` : "bg-white"
155
+ )}
156
+ >
157
+ {r.value}
158
+ </td>
159
+ )
160
+ }
147
161
  // }
148
162
  })}
149
163
  {props.actions && size !== "small" ? (
@@ -152,11 +166,14 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
152
166
  className={clsx(
153
167
  isRTL && lastRow ? "rounded-br-none rounded-bl" : "",
154
168
  !isRTL && lastRow ? "rounded-bl-none rounded-br" : ""
169
+ // "w-fit bg-red-400"
155
170
  )}
171
+ colSpan={1}
156
172
  >
157
173
  <div className="flex items-center justify-center">
158
174
  <HawaMenu
159
175
  size="small"
176
+ actionedItem={[rowIndex, singleRow]}
160
177
  menuItems={props.actions}
161
178
  position={
162
179
  direction === "rtl" ? "right-bottom" : "left-bottom"
@@ -192,28 +209,3 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
192
209
  </div>
193
210
  )
194
211
  }
195
-
196
- // const TableActionButton = (props) => {
197
- // let smallAct = props.action?.toLowerCase()
198
- // return (
199
- // <HawaButton
200
- // tooltipSize="small"
201
- // buttonID={props.action + props.row}
202
- // tooltipPosition="top-right"
203
- // size="xs"
204
- // variant="contained"
205
- // tooltip={props.action}
206
- // onClick={() => props.handleActionClick(smallAct)}
207
- // >
208
- // {smallAct === "delete" ? (
209
- // <FaTrash />
210
- // ) : smallAct === "view" ? (
211
- // <FaExclamationCircle />
212
- // ) : smallAct === "edit" ? (
213
- // <FaPen />
214
- // ) : (
215
- // props.action
216
- // )}
217
- // </HawaButton>
218
- // )
219
- // }
@@ -26,8 +26,7 @@ type InvoiceAccordionTypes = {
26
26
  icon?: JSX.Element
27
27
  label: string
28
28
  action?: (
29
- e: React.MouseEvent<HTMLLIElement, MouseEvent>,
30
- item: string
29
+ e: any
31
30
  ) => void
32
31
  isButton?: boolean
33
32
  element?: any
@@ -33,10 +33,7 @@ type HawaAppLayoutTypes = {
33
33
  type MenuItems = {
34
34
  icon?: JSX.Element
35
35
  label: string
36
- action?: (
37
- e: React.MouseEvent<HTMLLIElement, MouseEvent>,
38
- item: string
39
- ) => void
36
+ action?: (e: any) => void
40
37
  isButton?: boolean
41
38
  }
42
39
  export const HawaAppLayout: React.FunctionComponent<HawaAppLayoutTypes> = ({
package/src/styles.css CHANGED
@@ -715,6 +715,9 @@ video {
715
715
  .mt-1 {
716
716
  margin-top: 0.25rem;
717
717
  }
718
+ .mr-1 {
719
+ margin-right: 0.25rem;
720
+ }
718
721
  .mr-2 {
719
722
  margin-right: 0.5rem;
720
723
  }
@@ -772,9 +775,6 @@ video {
772
775
  .mr-1\.5 {
773
776
  margin-right: 0.375rem;
774
777
  }
775
- .mr-1 {
776
- margin-right: 0.25rem;
777
- }
778
778
  .mt-6 {
779
779
  margin-top: 1.5rem;
780
780
  }
@@ -938,6 +938,9 @@ video {
938
938
  .w-11 {
939
939
  width: 2.75rem;
940
940
  }
941
+ .w-\[calc\(1\%\)\] {
942
+ width: calc(1%);
943
+ }
941
944
  .w-1 {
942
945
  width: 0.25rem;
943
946
  }
@@ -2136,6 +2139,10 @@ body {
2136
2139
  --tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity));
2137
2140
  }
2138
2141
 
2142
+ [dir="rtl"] .rtl\:ml-1 {
2143
+ margin-left: 0.25rem;
2144
+ }
2145
+
2139
2146
  [dir="rtl"] .rtl\:ml-2 {
2140
2147
  margin-left: 0.5rem;
2141
2148
  }