@sikka/hawa 0.0.202 → 0.0.204
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 +656 -648
- package/es/hooks/useTable.d.ts +5 -0
- package/es/index.es.js +1 -1
- package/lib/hooks/useTable.d.ts +5 -0
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/elements/DragDropImages.tsx +5 -21
- package/src/elements/HawaAccordion.tsx +33 -36
- package/src/elements/HawaSelect.tsx +17 -3
- package/src/elements/HawaTable.tsx +190 -8
- package/src/elements/HawaTooltip.tsx +1 -1
- package/src/hooks/useTable.ts +32 -0
- package/src/styles.css +656 -648
- package/es/stories/ElementsStories/Tooltip.stories.d.ts +0 -4
- package/lib/stories/ElementsStories/Tooltip.stories.d.ts +0 -4
package/package.json
CHANGED
|
@@ -3,12 +3,6 @@ import { useDropzone } from "react-dropzone"
|
|
|
3
3
|
import { HawaAlert } from "./HawaAlert"
|
|
4
4
|
import { HawaButton } from "./HawaButton"
|
|
5
5
|
|
|
6
|
-
const thumbsContainer = {
|
|
7
|
-
display: "flex",
|
|
8
|
-
flexDirection: "row",
|
|
9
|
-
flexWrap: "wrap",
|
|
10
|
-
marginTop: 10,
|
|
11
|
-
}
|
|
12
6
|
type DragDropImagesTypes = {
|
|
13
7
|
label?: string
|
|
14
8
|
files: [File]
|
|
@@ -79,17 +73,14 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
79
73
|
},
|
|
80
74
|
[files]
|
|
81
75
|
)
|
|
82
|
-
|
|
83
76
|
useEffect(() => {
|
|
84
77
|
setFiles(acceptedFiles)
|
|
85
78
|
}, [acceptedFiles, cmp])
|
|
86
|
-
|
|
87
79
|
onClearFiles = () => {
|
|
88
80
|
acceptedFiles.length = 0
|
|
89
81
|
acceptedFiles.splice(0, acceptedFiles.length)
|
|
90
82
|
setFiles([])
|
|
91
83
|
}
|
|
92
|
-
|
|
93
84
|
useEffect(() => {
|
|
94
85
|
if (maxSize > 0) {
|
|
95
86
|
const k = 1024
|
|
@@ -111,7 +102,7 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
111
102
|
)
|
|
112
103
|
})
|
|
113
104
|
const thumbs = files?.map((file: any, index: any) => (
|
|
114
|
-
<div className="relative m-3 rounded">
|
|
105
|
+
<div className="relative m-3 rounded ">
|
|
115
106
|
<button
|
|
116
107
|
onClick={(e) => {
|
|
117
108
|
e.stopPropagation()
|
|
@@ -158,8 +149,6 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
158
149
|
</div>
|
|
159
150
|
))
|
|
160
151
|
|
|
161
|
-
console.log("error", fileRejections)
|
|
162
|
-
|
|
163
152
|
return (
|
|
164
153
|
<div>
|
|
165
154
|
{label && (
|
|
@@ -168,22 +157,17 @@ export const DragDropImages: React.FunctionComponent<DragDropImagesTypes> = ({
|
|
|
168
157
|
</div>
|
|
169
158
|
)}
|
|
170
159
|
<div
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
style: { backgroundColor: isDragActive ? "white" : "inherit" },
|
|
174
|
-
})}
|
|
175
|
-
// style={{ backgroundColor: isDragActive ? "white" : "inherit" }}
|
|
176
|
-
className="mb-2 flex flex-col justify-center rounded border border-dashed border-black"
|
|
160
|
+
{...getRootProps({})}
|
|
161
|
+
className="flex flex-col justify-center rounded border border-dashed border-black bg-white transition-all hover:bg-gray-100 "
|
|
177
162
|
>
|
|
178
163
|
<input {...getInputProps()} />
|
|
179
|
-
<div className="
|
|
180
|
-
<div className="
|
|
164
|
+
<div className="pt-4 text-center">{texts.clickHereToUpload}</div>
|
|
165
|
+
<div className="pb-4 text-center text-xs">
|
|
181
166
|
{texts.maxFileSize} {max}
|
|
182
167
|
</div>
|
|
183
168
|
<div className="flex justify-center ">
|
|
184
169
|
{acceptedFiles.length > 0 && (
|
|
185
170
|
<HawaButton
|
|
186
|
-
// style={{ color: "black" }}
|
|
187
171
|
onClick={(e) => {
|
|
188
172
|
e.stopPropagation()
|
|
189
173
|
onClearFiles(acceptedFiles)
|
|
@@ -21,49 +21,46 @@ const AccordionItem: React.FunctionComponent<AccordionItemTypes> = (props) => {
|
|
|
21
21
|
"p-5 font-light border border-b-xl rounded-b-xl border-gray-200 dark:border-gray-700 dark:bg-gray-900"
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
|
-
<div
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
<div>
|
|
25
|
+
<button
|
|
26
|
+
id={"accordion-collapse-heading-" + props.count}
|
|
27
|
+
type="button"
|
|
28
|
+
className={clsx(
|
|
29
|
+
// props.count === 0 ? roundedTop : noRounding,
|
|
30
|
+
collapse ? "rounded" : "rounded-t",
|
|
31
|
+
"flex w-full items-center justify-between border border-gray-200 bg-gray-100 p-5 text-left font-medium text-gray-900 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-800 dark:text-white dark:hover:bg-gray-800 dark:focus:ring-gray-800"
|
|
32
|
+
)}
|
|
33
|
+
onClick={() => setCollapse(!collapse)}
|
|
34
|
+
data-accordion-target={"#accordion-collapse-body-" + props.count}
|
|
35
|
+
aria-expanded="true"
|
|
36
|
+
aria-controls={"accordion-collapse-body-" + props.count}
|
|
37
|
+
>
|
|
38
|
+
<span>{props.title}</span>
|
|
39
|
+
<svg
|
|
40
|
+
data-accordion-icon=""
|
|
41
|
+
className={`h-6 w-6 ${
|
|
42
|
+
collapse ? "" : "rotate-180"
|
|
43
|
+
} shrink-0 transition-all`}
|
|
44
|
+
fill="currentColor"
|
|
45
|
+
viewBox="0 0 20 20"
|
|
46
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
37
47
|
>
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
viewBox="0 0 20 20"
|
|
46
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
47
|
-
>
|
|
48
|
-
<path
|
|
49
|
-
fillRule="evenodd"
|
|
50
|
-
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
|
|
51
|
-
clipRule="evenodd"
|
|
52
|
-
></path>
|
|
53
|
-
</svg>
|
|
54
|
-
</button>
|
|
55
|
-
</h2>
|
|
48
|
+
<path
|
|
49
|
+
fillRule="evenodd"
|
|
50
|
+
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
|
|
51
|
+
clipRule="evenodd"
|
|
52
|
+
></path>
|
|
53
|
+
</svg>
|
|
54
|
+
</button>
|
|
56
55
|
<div
|
|
57
56
|
id={"accordion-collapse-body-" + props.count}
|
|
57
|
+
aria-labelledby={"accordion-collapse-heading-" + props.count}
|
|
58
58
|
className={clsx(
|
|
59
|
-
collapse ? "invisible hidden" : "visible",
|
|
60
|
-
"
|
|
59
|
+
collapse ? "invisible hidden h-0 p-0" : " visible h-full",
|
|
60
|
+
"rounded-b border border-t-0 border-gray-200 p-5 font-light dark:border-gray-700 dark:bg-gray-900"
|
|
61
61
|
)}
|
|
62
|
-
aria-labelledby={"accordion-collapse-heading-" + props.count}
|
|
63
62
|
>
|
|
64
|
-
{/* <div className={props.count === -1 ? accPaperRounded : accPaper}> */}
|
|
65
63
|
<p className="mb-2 text-gray-500 dark:text-gray-400">{props.content}</p>
|
|
66
|
-
{/* </div> */}
|
|
67
64
|
</div>
|
|
68
65
|
</div>
|
|
69
66
|
)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import clsx from "clsx"
|
|
1
2
|
import React from "react"
|
|
2
3
|
import Select from "react-select"
|
|
3
4
|
import CreatableSelect from "react-select/creatable"
|
|
@@ -7,6 +8,7 @@ type OptionTypes = {
|
|
|
7
8
|
getStyles: any
|
|
8
9
|
innerProps: any
|
|
9
10
|
innerRef: any
|
|
11
|
+
size?: "small" | "normal" | "large"
|
|
10
12
|
}
|
|
11
13
|
const Option: React.FunctionComponent<OptionTypes> = ({
|
|
12
14
|
cx,
|
|
@@ -14,11 +16,12 @@ const Option: React.FunctionComponent<OptionTypes> = ({
|
|
|
14
16
|
getStyles,
|
|
15
17
|
innerProps,
|
|
16
18
|
innerRef,
|
|
19
|
+
size = "normal",
|
|
17
20
|
...props
|
|
18
21
|
}) => (
|
|
19
22
|
<div
|
|
20
23
|
ref={innerRef}
|
|
21
|
-
className="m-2 flex flex-row items-center justify-between rounded
|
|
24
|
+
className="m-2 flex flex-row items-center justify-between rounded p-1 px-3 hover:bg-buttonPrimary-500 hover:text-white"
|
|
22
25
|
{...innerProps}
|
|
23
26
|
>
|
|
24
27
|
{children}
|
|
@@ -31,6 +34,7 @@ type ControlTypes = {
|
|
|
31
34
|
getStyles: any
|
|
32
35
|
innerProps: any
|
|
33
36
|
innerRef: any
|
|
37
|
+
size?: "small" | "normal" | "large"
|
|
34
38
|
}
|
|
35
39
|
const Control: React.FunctionComponent<ControlTypes> = ({
|
|
36
40
|
cx,
|
|
@@ -38,12 +42,21 @@ const Control: React.FunctionComponent<ControlTypes> = ({
|
|
|
38
42
|
getStyles,
|
|
39
43
|
innerProps,
|
|
40
44
|
innerRef,
|
|
45
|
+
size = "normal",
|
|
41
46
|
...props
|
|
42
47
|
}) => {
|
|
48
|
+
let sizeStyles = {
|
|
49
|
+
small: "h-7 text-xs",
|
|
50
|
+
normal: "h-10 text-sm",
|
|
51
|
+
large: "",
|
|
52
|
+
}
|
|
43
53
|
return (
|
|
44
54
|
<div
|
|
45
55
|
ref={innerRef}
|
|
46
|
-
className=
|
|
56
|
+
className={clsx(
|
|
57
|
+
sizeStyles[size],
|
|
58
|
+
"flex w-full rounded border border-gray-300 bg-gray-50 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-blue-500 dark:focus:ring-blue-500"
|
|
59
|
+
)}
|
|
47
60
|
{...innerProps}
|
|
48
61
|
// {...props}
|
|
49
62
|
>
|
|
@@ -93,10 +106,11 @@ type SelectTypes = {
|
|
|
93
106
|
value?: any
|
|
94
107
|
children?: any
|
|
95
108
|
getOptionLabel?: any
|
|
109
|
+
// size?
|
|
96
110
|
}
|
|
97
111
|
export const HawaSelect: React.FunctionComponent<SelectTypes> = (props) => {
|
|
98
112
|
return (
|
|
99
|
-
<div className="
|
|
113
|
+
<div className="">
|
|
100
114
|
{props.label && (
|
|
101
115
|
<label className="mb-2 block text-sm font-medium text-gray-900 dark:text-gray-300">
|
|
102
116
|
{props.label}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { BsThreeDotsVertical } from "react-icons/bs"
|
|
1
|
+
import React, { useEffect, useState } from "react"
|
|
2
|
+
import { BsChevronRight, BsThreeDotsVertical } from "react-icons/bs"
|
|
3
3
|
import clsx from "clsx"
|
|
4
4
|
import { HawaMenu } from "./HawaMenu"
|
|
5
|
+
import useTable from "../hooks/useTable"
|
|
5
6
|
|
|
6
7
|
type TableTypes = {
|
|
7
8
|
columns: any[string]
|
|
@@ -37,6 +38,20 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
|
|
|
37
38
|
bordersWidth = "1",
|
|
38
39
|
...props
|
|
39
40
|
}) => {
|
|
41
|
+
const [perPage, setPerPage] = useState(10)
|
|
42
|
+
const [enteredPage, setEnteredPage] = useState(null)
|
|
43
|
+
const [page, setPage] = useState(1)
|
|
44
|
+
|
|
45
|
+
const { slice, range } = useTable(props.rows ?? [], page, perPage)
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (slice?.length < 1 && page !== 1) {
|
|
48
|
+
setPage(page - 1)
|
|
49
|
+
}
|
|
50
|
+
if (enteredPage) {
|
|
51
|
+
setPage(enteredPage)
|
|
52
|
+
}
|
|
53
|
+
}, [slice, page])
|
|
54
|
+
|
|
40
55
|
let isRTL = direction === "rtl"
|
|
41
56
|
|
|
42
57
|
let sizeStyles = {
|
|
@@ -91,9 +106,8 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
|
|
|
91
106
|
>
|
|
92
107
|
{/* Table Rows */}
|
|
93
108
|
{props.rows ? (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
let lastRow = rowIndex == props.rows.length - 1
|
|
109
|
+
slice?.map((singleRow: any, rowIndex: any) => {
|
|
110
|
+
let lastRow = rowIndex == slice?.length - 1
|
|
97
111
|
|
|
98
112
|
return (
|
|
99
113
|
<tr
|
|
@@ -109,9 +123,9 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
|
|
|
109
123
|
: ""
|
|
110
124
|
)}
|
|
111
125
|
>
|
|
112
|
-
{singleRow
|
|
126
|
+
{singleRow?.map((r: any, i: any) => {
|
|
113
127
|
let firstCell = i === 0
|
|
114
|
-
let lastCell = i === singleRow
|
|
128
|
+
let lastCell = i === singleRow?.length - 1
|
|
115
129
|
let isRTLLastCell =
|
|
116
130
|
isRTL && lastRow && lastCell && !props.actions
|
|
117
131
|
let isRTLFirstCell = isRTL && lastRow && firstCell
|
|
@@ -192,7 +206,6 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
|
|
|
192
206
|
})
|
|
193
207
|
) : (
|
|
194
208
|
<tr className="bg-transparent">
|
|
195
|
-
{/* {console.log('props', props.columns.length)} */}
|
|
196
209
|
<td colSpan={20}>
|
|
197
210
|
<div
|
|
198
211
|
className={clsx(
|
|
@@ -206,7 +219,176 @@ export const HawaTable: React.FunctionComponent<TableTypes> = ({
|
|
|
206
219
|
</tr>
|
|
207
220
|
)}
|
|
208
221
|
</tbody>
|
|
222
|
+
<div></div>
|
|
209
223
|
</table>
|
|
224
|
+
<div className="mt-2 flex flex-row items-center justify-between ">
|
|
225
|
+
{/* Pagination Pages */}
|
|
226
|
+
{range.length > 1 ? (
|
|
227
|
+
<div className="flex w-fit flex-row items-stretch justify-center gap-2 overflow-clip rounded ">
|
|
228
|
+
{/* Previous Page Button */}
|
|
229
|
+
<div
|
|
230
|
+
className={clsx(
|
|
231
|
+
"flex h-6 w-6 rotate-180 items-center justify-center rounded bg-gray-100 p-1 text-xs hover:bg-layoutPrimary-700 "
|
|
232
|
+
)}
|
|
233
|
+
onClick={() =>
|
|
234
|
+
page <= 1 ? setPage(range.length) : setPage(page - 1)
|
|
235
|
+
}
|
|
236
|
+
>
|
|
237
|
+
<BsChevronRight />
|
|
238
|
+
</div>
|
|
239
|
+
{/* Numbered Pagination */}
|
|
240
|
+
<div className="flex flex-row items-center overflow-clip rounded transition-all">
|
|
241
|
+
{/* The first page */}
|
|
242
|
+
{range.length > 6 &&
|
|
243
|
+
range.map((el, index) => {
|
|
244
|
+
if (index <= 0) {
|
|
245
|
+
return (
|
|
246
|
+
<button
|
|
247
|
+
key={index}
|
|
248
|
+
className={clsx(
|
|
249
|
+
"w-10 p-1 text-xs hover:bg-gray-200",
|
|
250
|
+
page === el
|
|
251
|
+
? "bg-buttonPrimary-500 text-white hover:bg-buttonPrimary-500"
|
|
252
|
+
: "bg-gray-100"
|
|
253
|
+
)}
|
|
254
|
+
onClick={() => setPage(el)}
|
|
255
|
+
>
|
|
256
|
+
{el}
|
|
257
|
+
</button>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
})}
|
|
261
|
+
{/* The Current Page / Input */}
|
|
262
|
+
{range?.length > 6 && (
|
|
263
|
+
<input
|
|
264
|
+
type={"text"}
|
|
265
|
+
className=" w-10 bg-gray-100 p-1 text-center text-xs"
|
|
266
|
+
defaultValue={
|
|
267
|
+
page !== 0 || page !== range.length - 1 ? page : "..."
|
|
268
|
+
}
|
|
269
|
+
value={
|
|
270
|
+
page == 1 || page == range.length
|
|
271
|
+
? "..."
|
|
272
|
+
: enteredPage
|
|
273
|
+
? enteredPage
|
|
274
|
+
: page
|
|
275
|
+
}
|
|
276
|
+
onChange={(e) => setEnteredPage(parseInt(e.target.value))}
|
|
277
|
+
onKeyDown={(e) => {
|
|
278
|
+
if (e.key === "Enter") {
|
|
279
|
+
setPage(enteredPage)
|
|
280
|
+
setEnteredPage(null)
|
|
281
|
+
}
|
|
282
|
+
}}
|
|
283
|
+
/>
|
|
284
|
+
)}
|
|
285
|
+
{/* The last page */}
|
|
286
|
+
{range?.length > 6 &&
|
|
287
|
+
range.map((el, index) => {
|
|
288
|
+
if (index >= range.length - 1) {
|
|
289
|
+
return (
|
|
290
|
+
<button
|
|
291
|
+
key={index}
|
|
292
|
+
className={clsx(
|
|
293
|
+
"w-10 p-1 text-xs hover:bg-gray-200",
|
|
294
|
+
page === el
|
|
295
|
+
? "bg-buttonPrimary-500 text-white hover:bg-buttonPrimary-500"
|
|
296
|
+
: "bg-gray-100"
|
|
297
|
+
)}
|
|
298
|
+
onClick={() => setPage(el)}
|
|
299
|
+
>
|
|
300
|
+
{el}
|
|
301
|
+
</button>
|
|
302
|
+
)
|
|
303
|
+
}
|
|
304
|
+
})}
|
|
305
|
+
|
|
306
|
+
{/* All Pages if less than 6 pages */}
|
|
307
|
+
{range?.length <= 6 &&
|
|
308
|
+
range.map((el, index) => {
|
|
309
|
+
return (
|
|
310
|
+
<button
|
|
311
|
+
key={index}
|
|
312
|
+
className={clsx(
|
|
313
|
+
"w-10 p-1 text-xs hover:bg-gray-200",
|
|
314
|
+
page === el
|
|
315
|
+
? "bg-buttonPrimary-500 text-white hover:bg-buttonPrimary-500"
|
|
316
|
+
: "bg-gray-100"
|
|
317
|
+
)}
|
|
318
|
+
onClick={() => setPage(el)}
|
|
319
|
+
>
|
|
320
|
+
{el}
|
|
321
|
+
</button>
|
|
322
|
+
)
|
|
323
|
+
})}
|
|
324
|
+
</div>
|
|
325
|
+
{/* Next Page Button */}
|
|
326
|
+
<div
|
|
327
|
+
onClick={() =>
|
|
328
|
+
page >= range.length ? setPage(1) : setPage(page + 1)
|
|
329
|
+
}
|
|
330
|
+
className={clsx(
|
|
331
|
+
"flex h-6 w-6 items-center justify-center rounded bg-gray-100 p-1 text-xs hover:bg-layoutPrimary-700 "
|
|
332
|
+
)}
|
|
333
|
+
>
|
|
334
|
+
<BsChevronRight />
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
) : (
|
|
338
|
+
<div></div>
|
|
339
|
+
)}
|
|
340
|
+
{/* Pagination Settings */}
|
|
341
|
+
<div className="w-fit ">
|
|
342
|
+
<select
|
|
343
|
+
value={perPage}
|
|
344
|
+
className="h-6 rounded text-xs"
|
|
345
|
+
onChange={(e) => {
|
|
346
|
+
setPerPage(parseInt(e.target.value))
|
|
347
|
+
}}
|
|
348
|
+
>
|
|
349
|
+
<option value={10} style={{ fontSize: 10 }}>
|
|
350
|
+
10 Items
|
|
351
|
+
</option>
|
|
352
|
+
<option value={20} style={{ fontSize: 10 }}>
|
|
353
|
+
20 Items
|
|
354
|
+
</option>
|
|
355
|
+
<option value={30} style={{ fontSize: 10 }}>
|
|
356
|
+
30 Items
|
|
357
|
+
</option>
|
|
358
|
+
<option value={50} style={{ fontSize: 10 }}>
|
|
359
|
+
50 Items
|
|
360
|
+
</option>
|
|
361
|
+
<option value={100} style={{ fontSize: 10 }}>
|
|
362
|
+
100 Items
|
|
363
|
+
</option>
|
|
364
|
+
</select>
|
|
365
|
+
{/* <HawaSelect
|
|
366
|
+
// label="Per Page"
|
|
367
|
+
isCreatable={false}
|
|
368
|
+
isMulti={false}
|
|
369
|
+
isSearchable={false}
|
|
370
|
+
isClearable={false}
|
|
371
|
+
options={[
|
|
372
|
+
{ value: 2, label: "2" },
|
|
373
|
+
{ value: 7, label: "7" },
|
|
374
|
+
{ value: 10, label: "10" },
|
|
375
|
+
{ value: 20, label: "20" },
|
|
376
|
+
]}
|
|
377
|
+
onChange={(e: any) => {
|
|
378
|
+
// field.onChange(e.value)
|
|
379
|
+
console.log("changing to ", e.value)
|
|
380
|
+
setPage(1)
|
|
381
|
+
setPerPage(e.value)
|
|
382
|
+
}}
|
|
383
|
+
onInputChange={(e: any) => {
|
|
384
|
+
// field.onChange(e.value)
|
|
385
|
+
console.log("changing to ", e.value)
|
|
386
|
+
setPage(1)
|
|
387
|
+
setPerPage(e.value)
|
|
388
|
+
}}
|
|
389
|
+
/> */}
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
210
392
|
</div>
|
|
211
393
|
)
|
|
212
394
|
}
|
|
@@ -76,7 +76,7 @@ export const HawaTooltip: React.FunctionComponent<THawaToolTip> = ({
|
|
|
76
76
|
tooltipCoordinates =
|
|
77
77
|
direction === "rtl"
|
|
78
78
|
? `${tooltipWidth - childrenWidth}px, ${spacing}px`
|
|
79
|
-
: `-${
|
|
79
|
+
: `-${0}px, ${spacing}px`
|
|
80
80
|
break
|
|
81
81
|
case "bottom-left":
|
|
82
82
|
tooltipCoordinates =
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useState, useEffect } from "react"
|
|
2
|
+
|
|
3
|
+
const calculateRange = (data, rowsPerPage) => {
|
|
4
|
+
const range = []
|
|
5
|
+
const num = Math.ceil(data?.length / rowsPerPage)
|
|
6
|
+
let i = 1
|
|
7
|
+
for (let i = 1; i <= num; i++) {
|
|
8
|
+
range.push(i)
|
|
9
|
+
}
|
|
10
|
+
return range
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const sliceData = (data, page, rowsPerPage) => {
|
|
14
|
+
return data?.slice((page - 1) * rowsPerPage, page * rowsPerPage)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const useTable = (data, page, rowsPerPage) => {
|
|
18
|
+
const [tableRange, setTableRange] = useState([])
|
|
19
|
+
const [slice, setSlice] = useState([])
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const range = calculateRange(data, rowsPerPage)
|
|
23
|
+
setTableRange([...range])
|
|
24
|
+
|
|
25
|
+
const slice = sliceData(data, page, rowsPerPage)
|
|
26
|
+
setSlice([...slice])
|
|
27
|
+
}, [data, setTableRange, page, setSlice, rowsPerPage])
|
|
28
|
+
|
|
29
|
+
return { slice, range: tableRange }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default useTable
|