next-helios-fe 1.0.2 → 1.1.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "next-helios-fe",
3
- "version": "1.0.2",
4
- "description": "fix export data bug in table component",
3
+ "version": "1.1.0",
4
+ "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
@@ -37,23 +37,25 @@
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@iconify/react": "^5.0.1",
40
+ "dayjs": "^1.11.11",
40
41
  "flowbite-react": "^0.10.1",
41
42
  "next": "14.2.4",
42
43
  "postcss": "^8",
43
44
  "react": "^18.2.0",
44
45
  "react-dom": "^18.2.0",
45
46
  "tailwindcss": "^3.4.1",
46
- "typescript": "^5",
47
- "dayjs": "^1.11.11"
47
+ "typescript": "^5"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@iconify/react": "^5.0.1",
51
51
  "@types/leaflet": "^1.9.12",
52
+ "@types/qrcode": "^1.5.5",
52
53
  "@types/react": "^18",
53
54
  "@types/react-big-calendar": "^1.8.9",
54
55
  "@types/react-dom": "^18",
55
56
  "@types/react-syntax-highlighter": "^15.5.13",
56
57
  "css-loader": "^7.1.2",
58
+ "dayjs": "^1.11.11",
57
59
  "flowbite-react": "^0.10.1",
58
60
  "next": "^14.2.4",
59
61
  "postcss": "^8",
@@ -66,7 +68,6 @@
66
68
  "ts-loader": "^9.5.1",
67
69
  "typescript": "^5",
68
70
  "webpack": "^5.93.0",
69
- "webpack-cli": "^5.1.4",
70
- "dayjs": "^1.11.11"
71
+ "webpack-cli": "^5.1.4"
71
72
  }
72
73
  }
@@ -27,3 +27,4 @@ export { BigCalendar } from "./calendar/big-calendar";
27
27
  export { Timeline } from "./timeline";
28
28
  export { DataTree } from "./data-tree";
29
29
  export { SyntaxHighlighter } from "./syntax-highlighter";
30
+ export { QR } from "./qr";
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import React, { useState, useEffect } from "react";
3
+ import Image from "next/image";
4
+ import QRCode from "qrcode";
5
+
6
+ interface QRProps {
7
+ value: string;
8
+ }
9
+
10
+ export const QR: React.FC<QRProps> = ({ value }) => {
11
+ const [qr, setQr] = useState<string>("");
12
+ const options = {
13
+ scale: 10,
14
+ quality: 0.1,
15
+ margin: 1,
16
+ };
17
+
18
+ useEffect(() => {
19
+ QRCode.toDataURL(value || "", options, (err: any, data: any) => {
20
+ if (err) {
21
+ console.log(err);
22
+ }
23
+ setQr(data);
24
+ });
25
+ }, [value]);
26
+
27
+ return <Image src={qr} alt="QR Code" width={200} height={200} />;
28
+ };
@@ -8,6 +8,7 @@ import { Action, type ActionProps } from "./action";
8
8
 
9
9
  interface TableProps {
10
10
  title?: string;
11
+
11
12
  header: {
12
13
  title: string;
13
14
  key: string;
@@ -16,13 +17,14 @@ interface TableProps {
16
17
  data: any[];
17
18
  options?: {
18
19
  hideToolbar?: boolean;
19
- hideNumber?: boolean;
20
+ hideNumberColumn?: boolean;
20
21
  checkbox?: boolean;
21
22
  height?: "full" | "fit" | "20" | "40" | "80";
22
23
  maxRow?: 10 | 20 | 50 | 100;
23
24
  border?: boolean;
24
25
  };
25
26
  actions?: (e: any) => React.ReactNode;
27
+ onAddData?: (e: React.MouseEvent<HTMLButtonElement>) => void;
26
28
  }
27
29
 
28
30
  interface TableComponentProps extends React.FC<TableProps> {
@@ -35,6 +37,7 @@ export const Table: TableComponentProps = ({
35
37
  data,
36
38
  options,
37
39
  actions,
40
+ onAddData,
38
41
  }) => {
39
42
  const [search, setSearch] = useState<string>("");
40
43
  const [filter, setFilter] = useState<any[]>([]);
@@ -70,12 +73,10 @@ export const Table: TableComponentProps = ({
70
73
  return item;
71
74
  } else if (
72
75
  header.some((headerItem) => {
73
- if (headerItem.title !== header[1].title) {
74
- return item[headerItem.key as keyof typeof item]
75
- ?.toString()
76
- .toLowerCase()
77
- .includes(search.toLowerCase());
78
- }
76
+ return item[headerItem.key as keyof typeof item]
77
+ ?.toString()
78
+ .toLowerCase()
79
+ .includes(search.toLowerCase());
79
80
  })
80
81
  ) {
81
82
  return item;
@@ -132,22 +133,30 @@ export const Table: TableComponentProps = ({
132
133
  }`}
133
134
  />
134
135
  </button>
135
- <input
136
- type="search"
137
- className="w-full px-0 pt-0 pb-0.5 border-default border-t-0 border-b border-x-0 bg-secondary-bg text-sm font-normal placeholder:duration-300 placeholder:translate-x-0 [&::-webkit-search-cancel-button]:appearance-none focus:placeholder:translate-x-1 placeholder:text-slate-300 focus:outline-none focus:ring-0 focus:border-primary-dark disabled:bg-secondary-light disabled:text-slate-400"
138
- value={
139
- filter.find((filterItem) => filterItem.key === item.key)?.value
140
- }
141
- onChange={(e) => {
142
- setFilter(
143
- filter.map((filterItem) => {
144
- return filterItem.key === item.key
145
- ? { ...filterItem, value: e.target.value }
146
- : filterItem;
147
- })
148
- );
149
- }}
150
- />
136
+ <div className="relative flex items-center">
137
+ <input
138
+ type="search"
139
+ className="w-full ps-6 pe-0 pt-0 pb-0.5 border-default border-t-0 border-b border-x-0 bg-secondary-bg text-sm font-normal placeholder:duration-300 placeholder:translate-x-0 [&::-webkit-search-cancel-button]:appearance-none focus:placeholder:translate-x-1 placeholder:text-slate-300 focus:outline-none focus:ring-0 focus:border-primary-dark disabled:bg-secondary-light disabled:text-slate-400"
140
+ placeholder="search.."
141
+ value={
142
+ filter.find((filterItem) => filterItem.key === item.key)
143
+ ?.value
144
+ }
145
+ onChange={(e) => {
146
+ setFilter(
147
+ filter.map((filterItem) => {
148
+ return filterItem.key === item.key
149
+ ? { ...filterItem, value: e.target.value }
150
+ : filterItem;
151
+ })
152
+ );
153
+ }}
154
+ />
155
+ <Icon
156
+ icon="ic:round-search"
157
+ className="absolute text-sm text-slate-400"
158
+ />
159
+ </div>
151
160
  </div>
152
161
  </th>
153
162
  );
@@ -186,7 +195,7 @@ export const Table: TableComponentProps = ({
186
195
  />
187
196
  </td>
188
197
  )}
189
- {!options?.hideNumber && (
198
+ {!options?.hideNumberColumn && (
190
199
  <td className="sticky left-0 px-4 py-1 border-b bg-secondary-bg text-center">
191
200
  {(page - 1) * maxRow + index + 1}
192
201
  </td>
@@ -229,6 +238,17 @@ export const Table: TableComponentProps = ({
229
238
  <div className="flex justify-between items-center gap-4 w-full h-fit">
230
239
  <span className="text-lg">{title}</span>
231
240
  <div className="flex items-center gap-4">
241
+ {onAddData && (
242
+ <button
243
+ type="button"
244
+ className="p-1.5 rounded-full bg-primary text-white hover:bg-primary-dark"
245
+ onClick={(e) => {
246
+ onAddData && onAddData(e);
247
+ }}
248
+ >
249
+ <Icon icon="ic:round-plus" className="text-2xl" />
250
+ </button>
251
+ )}
232
252
  <Dropdown
233
253
  trigger={
234
254
  <button
@@ -315,8 +335,8 @@ export const Table: TableComponentProps = ({
315
335
  </div>
316
336
  </th>
317
337
  )}
318
- {!options?.hideNumber && (
319
- <th className="sticky left-0 w-min px-4 py-2 bg-secondary-bg font-medium text-center whitespace-nowrap">
338
+ {!options?.hideNumberColumn && (
339
+ <th className="sticky left-0 w-min px-4 py-2 z-10 bg-secondary-bg font-medium text-center whitespace-nowrap">
320
340
  <div className="flex flex-col">
321
341
  <span>NO.</span>
322
342
  <div className="invisible w-0 overflow-hidden">