@sikka/hawa 0.0.193 → 0.0.195
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 +20 -1
- package/es/elements/HawaTable.d.ts +1 -1
- package/es/index.es.js +1 -1
- package/lib/elements/HawaTable.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/elements/HawaMenu.tsx +8 -47
- package/src/elements/HawaTable.tsx +84 -72
- package/src/styles.css +20 -1
- package/src/tailwind.css +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import clsx from "clsx"
|
|
2
2
|
import React, { ReactNode, useEffect, useRef, useState } from "react"
|
|
3
|
-
// TODO: add size to make it smaller
|
|
4
3
|
// TODO: add width to decrease width
|
|
5
4
|
|
|
6
5
|
interface TMenuTypes {
|
|
@@ -41,7 +40,7 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
|
|
|
41
40
|
direction = "ltr",
|
|
42
41
|
headerTitle,
|
|
43
42
|
headerSubtitle,
|
|
44
|
-
size = "
|
|
43
|
+
size = "normal",
|
|
45
44
|
children,
|
|
46
45
|
onClickOutside,
|
|
47
46
|
position = "top-right",
|
|
@@ -88,8 +87,8 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
|
|
|
88
87
|
closed: "h-0 invisible opacity-0 hidden",
|
|
89
88
|
}
|
|
90
89
|
let sizeStyles = {
|
|
91
|
-
small: "text-
|
|
92
|
-
normal: "",
|
|
90
|
+
small: "text-[11px] p-1 m-0",
|
|
91
|
+
normal: "py-2 px-4",
|
|
93
92
|
large: "",
|
|
94
93
|
}
|
|
95
94
|
let menuCoordinates
|
|
@@ -156,49 +155,11 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
|
|
|
156
155
|
|
|
157
156
|
break
|
|
158
157
|
}
|
|
159
|
-
// switch (position) {
|
|
160
|
-
// case "top-right":
|
|
161
|
-
// menuCoordinates = `0px, -${menuHeight + childrenHeight + spacing}px`
|
|
162
|
-
// break
|
|
163
|
-
// case "top-left":
|
|
164
|
-
// menuCoordinates = `-${menuWidth - childrenWidth}px, -${
|
|
165
|
-
// menuHeight + childrenHeight + spacing
|
|
166
|
-
// }px`
|
|
167
|
-
// break
|
|
168
|
-
// case "bottom-right":
|
|
169
|
-
// menuCoordinates = `0px, ${spacing}px`
|
|
170
|
-
// break
|
|
171
|
-
// case "bottom-left":
|
|
172
|
-
// menuCoordinates = `-${menuWidth - childrenWidth}px,${spacing}px`
|
|
173
|
-
// break
|
|
174
|
-
// case "right-bottom":
|
|
175
|
-
// menuCoordinates = `${childrenWidth + spacing}px, -${childrenHeight}px`
|
|
176
|
-
// break
|
|
177
|
-
// case "right-top":
|
|
178
|
-
// menuCoordinates = `${childrenWidth + spacing}px, -${menuHeight}px`
|
|
179
|
-
// break
|
|
180
|
-
// case "left-bottom":
|
|
181
|
-
// menuCoordinates = `-${menuWidth + spacing}px, -${childrenHeight}px`
|
|
182
|
-
// break
|
|
183
|
-
// case "left-top":
|
|
184
|
-
// menuCoordinates = `-${menuWidth + spacing}px, -${menuHeight}px`
|
|
185
|
-
// break
|
|
186
|
-
|
|
187
|
-
// default:
|
|
188
|
-
// menuCoordinates = `-${menuWidth / 2}px, -${
|
|
189
|
-
// childrenHeight + menuHeight / 2
|
|
190
|
-
// }px`
|
|
191
|
-
|
|
192
|
-
// break
|
|
193
|
-
// }
|
|
194
158
|
return (
|
|
195
159
|
<div
|
|
196
|
-
// className="relative w-fit "
|
|
197
160
|
onClick={() => {
|
|
198
161
|
if (menuOpened) setMenuOpened(false)
|
|
199
162
|
else setMenuOpened(true)
|
|
200
|
-
// if (open) handleClose()
|
|
201
|
-
// else handleOpen()
|
|
202
163
|
}}
|
|
203
164
|
>
|
|
204
165
|
<div ref={childrenRef}>{children}</div>
|
|
@@ -213,7 +174,6 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
|
|
|
213
174
|
}}
|
|
214
175
|
className={clsx(
|
|
215
176
|
defaultStyles,
|
|
216
|
-
sizeStyles[size],
|
|
217
177
|
menuOpened ? "opacity-100" : "invisible opacity-0"
|
|
218
178
|
)}
|
|
219
179
|
>
|
|
@@ -227,7 +187,7 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
|
|
|
227
187
|
return (
|
|
228
188
|
<ul
|
|
229
189
|
key={o}
|
|
230
|
-
className="bg-layout-1200 flex flex-col gap-1
|
|
190
|
+
className="bg-layout-1200 flex flex-col gap-1 p-1 text-gray-700 dark:text-gray-200"
|
|
231
191
|
>
|
|
232
192
|
{group?.map((item) => {
|
|
233
193
|
return item.element ? (
|
|
@@ -237,11 +197,12 @@ export const HawaMenu: React.FunctionComponent<TMenuTypes> = ({
|
|
|
237
197
|
) : (
|
|
238
198
|
<li
|
|
239
199
|
onClick={(e) => item.action(e, item.label)}
|
|
240
|
-
className={
|
|
200
|
+
className={clsx(
|
|
241
201
|
item.isButton
|
|
242
202
|
? "mx-1 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"
|
|
243
|
-
: "
|
|
244
|
-
|
|
203
|
+
: " flex cursor-pointer flex-row items-center rounded hover:bg-gray-200 rtl:flex-row-reverse dark:hover:bg-gray-600 dark:hover:text-white",
|
|
204
|
+
sizeStyles[size]
|
|
205
|
+
)}
|
|
245
206
|
>
|
|
246
207
|
{item.icon && (
|
|
247
208
|
<div className="mr-2 rtl:ml-2">{item.icon}</div>
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { HawaButton } from "./HawaButton"
|
|
3
|
-
import { FaTrash, FaExclamationCircle, FaPen } from "react-icons/fa"
|
|
1
|
+
import React from "react"
|
|
4
2
|
import { BsThreeDotsVertical } from "react-icons/bs"
|
|
5
3
|
import clsx from "clsx"
|
|
6
4
|
import { HawaMenu } from "./HawaMenu"
|
|
7
5
|
// TODO: make action click return row
|
|
8
|
-
|
|
6
|
+
|
|
9
7
|
type TableTypes = {
|
|
10
8
|
lang?: any
|
|
11
9
|
columns: any[string]
|
|
@@ -21,7 +19,7 @@ type TableTypes = {
|
|
|
21
19
|
clickable?: boolean
|
|
22
20
|
actionsText?: string
|
|
23
21
|
bordersWidth?: string
|
|
24
|
-
borders?:
|
|
22
|
+
borders?: "all" | "cols" | "rows" | "outer" | "inner"
|
|
25
23
|
}
|
|
26
24
|
type ActionItems = {
|
|
27
25
|
icon?: JSX.Element
|
|
@@ -40,28 +38,30 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
|
|
|
40
38
|
borders,
|
|
41
39
|
highlightFirst = false,
|
|
42
40
|
direction = "ltr",
|
|
43
|
-
bordersWidth = "
|
|
41
|
+
bordersWidth = "1",
|
|
44
42
|
...props
|
|
45
43
|
}) => {
|
|
46
|
-
const [openActions, setOpenActions] = useState(false)
|
|
47
44
|
let isArabic = props.lang === "ar"
|
|
48
45
|
|
|
49
46
|
let sizeStyles = {
|
|
50
47
|
normal: "py-3 px-6",
|
|
51
48
|
small: "px-3 py-1",
|
|
52
49
|
}
|
|
50
|
+
|
|
53
51
|
return (
|
|
54
|
-
<div className="relative
|
|
52
|
+
<div className="relative">
|
|
55
53
|
<table
|
|
56
54
|
className={clsx(
|
|
57
|
-
"w-full text-left text-sm text-gray-500 dark:text-gray-400"
|
|
58
|
-
borders
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
"w-full rounded bg-layoutPrimary-500 text-left text-sm text-gray-500 dark:text-gray-400"
|
|
56
|
+
// borders === "all" || borders === "outer"
|
|
57
|
+
// ? `border-[${bordersWidth}px] bg-red-300 p-2`
|
|
58
|
+
// : ""
|
|
59
|
+
// `ring-[${bordersWidth}px] ring-blue-300`
|
|
60
|
+
// `ring-[${10}px] ring-blue-300`
|
|
61
|
+
// ` ring-[10px] ring-blue-300`
|
|
62
62
|
)}
|
|
63
63
|
>
|
|
64
|
-
<thead className="
|
|
64
|
+
<thead className=" text-xs uppercase text-gray-700 dark:bg-gray-700 dark:text-gray-400">
|
|
65
65
|
<tr>
|
|
66
66
|
{props.columns.map((col: any, i: any) => (
|
|
67
67
|
<th
|
|
@@ -69,8 +69,7 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
|
|
|
69
69
|
scope="col"
|
|
70
70
|
className={clsx(
|
|
71
71
|
sizeStyles[size],
|
|
72
|
-
|
|
73
|
-
borders?.find((e) => e === "all") === "all"
|
|
72
|
+
i !== 0 && (borders === "cols" || borders === "all")
|
|
74
73
|
? `border-l border-l-[${bordersWidth}px]`
|
|
75
74
|
: ""
|
|
76
75
|
)}
|
|
@@ -85,50 +84,58 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
|
|
|
85
84
|
) : null}
|
|
86
85
|
</tr>
|
|
87
86
|
</thead>
|
|
88
|
-
<tbody
|
|
87
|
+
<tbody
|
|
88
|
+
// style={{
|
|
89
|
+
// borderWidth: bordersWidth,
|
|
90
|
+
// border: "1px solid black",
|
|
91
|
+
// }}
|
|
92
|
+
// className="bg-yellow-400"
|
|
93
|
+
>
|
|
89
94
|
{/* Table Rows */}
|
|
90
95
|
{props.rows ? (
|
|
91
|
-
props.rows.map((singleRow: any, rowIndex: any) =>
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
highlightFirst ? "font-bold" : "font-normal"
|
|
116
|
-
)}
|
|
117
|
-
>
|
|
118
|
-
{r}{" "}
|
|
119
|
-
</th>
|
|
120
|
-
)
|
|
121
|
-
} else {
|
|
96
|
+
props.rows.map((singleRow: any, rowIndex: any) => {
|
|
97
|
+
let firstRow
|
|
98
|
+
let lastRow = rowIndex == props.rows.length - 1
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<tr
|
|
102
|
+
key={rowIndex}
|
|
103
|
+
className={clsx(
|
|
104
|
+
" dark:border-gray-700 dark:bg-gray-800",
|
|
105
|
+
props.clickable ? "hover:bg-gray-100" : "",
|
|
106
|
+
"bg-" + customColor,
|
|
107
|
+
!lastRow &&
|
|
108
|
+
(borders === "all" ||
|
|
109
|
+
borders === "rows" ||
|
|
110
|
+
borders === "inner")
|
|
111
|
+
? `border-b border-b-[${bordersWidth}px]`
|
|
112
|
+
: ""
|
|
113
|
+
// "bg-yellow-400"
|
|
114
|
+
)}
|
|
115
|
+
>
|
|
116
|
+
{singleRow.map((r: any, i: any) => {
|
|
117
|
+
let firstCell = i === 0
|
|
118
|
+
let lastCell = i === singleRow.length - 1
|
|
119
|
+
|
|
122
120
|
return (
|
|
123
121
|
<td
|
|
124
122
|
key={i}
|
|
125
123
|
className={clsx(
|
|
124
|
+
highlightFirst && firstCell
|
|
125
|
+
? "font-bold"
|
|
126
|
+
: "font-normal",
|
|
127
|
+
lastRow && firstCell ? "rounded-b" : "",
|
|
128
|
+
firstCell ? "rounded-br-none" : "",
|
|
129
|
+
lastCell ? "rounded-bl-none" : "",
|
|
126
130
|
sizeStyles[size],
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
borders?.find((e) => e === "all") === "all"
|
|
131
|
+
!firstCell &&
|
|
132
|
+
(borders === "cols" || borders === "inner")
|
|
130
133
|
? `border-l border-l-[${bordersWidth}px]`
|
|
131
134
|
: "",
|
|
135
|
+
|
|
136
|
+
// borders === "all"
|
|
137
|
+
// ? `border border-[${bordersWidth}px]`
|
|
138
|
+
// : "",
|
|
132
139
|
props.actions
|
|
133
140
|
? `border-r border-r-[${bordersWidth}px]`
|
|
134
141
|
: ""
|
|
@@ -137,27 +144,32 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
|
|
|
137
144
|
{r}
|
|
138
145
|
</td>
|
|
139
146
|
)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
// }
|
|
148
|
+
})}
|
|
149
|
+
{props.actions && size !== "small" ? (
|
|
150
|
+
<td
|
|
151
|
+
align={isArabic ? "right" : "left"}
|
|
152
|
+
className={lastRow ? "rounded-br" : ""}
|
|
153
|
+
>
|
|
154
|
+
<div className="flex items-center justify-center">
|
|
155
|
+
<HawaMenu
|
|
156
|
+
size="small"
|
|
157
|
+
menuItems={props.actions}
|
|
158
|
+
position={
|
|
159
|
+
direction === "rtl" ? "right-bottom" : "left-bottom"
|
|
160
|
+
}
|
|
161
|
+
direction={direction}
|
|
162
|
+
>
|
|
163
|
+
<div className="flex w-fit items-center justify-center rounded p-2 hover:bg-gray-200">
|
|
164
|
+
<BsThreeDotsVertical />
|
|
165
|
+
</div>
|
|
166
|
+
</HawaMenu>
|
|
167
|
+
</div>
|
|
168
|
+
</td>
|
|
169
|
+
) : null}
|
|
170
|
+
</tr>
|
|
171
|
+
)
|
|
172
|
+
})
|
|
161
173
|
) : (
|
|
162
174
|
<tr>
|
|
163
175
|
<td colSpan={props.columns.length}>
|
package/src/styles.css
CHANGED
|
@@ -385,7 +385,7 @@ video {
|
|
|
385
385
|
--button-secondary-500: #ffc011;
|
|
386
386
|
--button-secondary-700: #b48d24;
|
|
387
387
|
|
|
388
|
-
--border-radius:
|
|
388
|
+
--border-radius: 10px;
|
|
389
389
|
}
|
|
390
390
|
input[type="number"]::-webkit-inner-spin-button,
|
|
391
391
|
input[type="number"]::-webkit-outer-spin-button {
|
|
@@ -1238,6 +1238,10 @@ video {
|
|
|
1238
1238
|
border-top-left-radius: 0px;
|
|
1239
1239
|
border-bottom-left-radius: 0px;
|
|
1240
1240
|
}
|
|
1241
|
+
.rounded-b {
|
|
1242
|
+
border-bottom-right-radius: var(--border-radius);
|
|
1243
|
+
border-bottom-left-radius: var(--border-radius);
|
|
1244
|
+
}
|
|
1241
1245
|
.rounded-r {
|
|
1242
1246
|
border-top-right-radius: var(--border-radius);
|
|
1243
1247
|
border-bottom-right-radius: var(--border-radius);
|
|
@@ -1267,6 +1271,9 @@ video {
|
|
|
1267
1271
|
.rounded-br-none {
|
|
1268
1272
|
border-bottom-right-radius: 0px;
|
|
1269
1273
|
}
|
|
1274
|
+
.rounded-br {
|
|
1275
|
+
border-bottom-right-radius: var(--border-radius);
|
|
1276
|
+
}
|
|
1270
1277
|
.rounded-tl-none {
|
|
1271
1278
|
border-top-left-radius: 0px;
|
|
1272
1279
|
}
|
|
@@ -1650,6 +1657,9 @@ video {
|
|
|
1650
1657
|
font-size: 1.5rem;
|
|
1651
1658
|
line-height: 2rem;
|
|
1652
1659
|
}
|
|
1660
|
+
.text-\[11px\] {
|
|
1661
|
+
font-size: 11px;
|
|
1662
|
+
}
|
|
1653
1663
|
.text-xl {
|
|
1654
1664
|
font-size: 1.25rem;
|
|
1655
1665
|
line-height: 1.75rem;
|
|
@@ -1830,10 +1840,19 @@ video {
|
|
|
1830
1840
|
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
1831
1841
|
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
1832
1842
|
}
|
|
1843
|
+
.ring-\[10px\] {
|
|
1844
|
+
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
|
1845
|
+
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(10px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
|
1846
|
+
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
|
1847
|
+
}
|
|
1833
1848
|
.ring-blue-200 {
|
|
1834
1849
|
--tw-ring-opacity: 1;
|
|
1835
1850
|
--tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity));
|
|
1836
1851
|
}
|
|
1852
|
+
.ring-blue-300 {
|
|
1853
|
+
--tw-ring-opacity: 1;
|
|
1854
|
+
--tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity));
|
|
1855
|
+
}
|
|
1837
1856
|
.ring-buttonPrimary-500 {
|
|
1838
1857
|
--tw-ring-color: var(--button-primary-500);
|
|
1839
1858
|
}
|
package/src/tailwind.css
CHANGED