@deepnoid/ui 0.1.78 → 0.1.80

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.
@@ -1,353 +0,0 @@
1
- "use client";
2
- import {
3
- table_body_default
4
- } from "./chunk-5GBAUDP4.mjs";
5
- import {
6
- table_head_default
7
- } from "./chunk-TKB2JL2E.mjs";
8
- import {
9
- scrollArea_default
10
- } from "./chunk-M37VBNB3.mjs";
11
- import {
12
- pagination_default
13
- } from "./chunk-CC2F5HQX.mjs";
14
- import {
15
- clsx
16
- } from "./chunk-27Y6K5NK.mjs";
17
- import {
18
- mapPropsVariants
19
- } from "./chunk-E3G5QXSH.mjs";
20
-
21
- // src/components/table/table.tsx
22
- import {
23
- forwardRef,
24
- useEffect,
25
- useImperativeHandle,
26
- useMemo,
27
- useState
28
- } from "react";
29
- import { tv } from "tailwind-variants";
30
- import { jsx, jsxs } from "react/jsx-runtime";
31
- var Table = forwardRef((originalProps, ref) => {
32
- const [props, variantProps] = mapPropsVariants(originalProps, tableStyle.variantKeys);
33
- const {
34
- rows,
35
- columns,
36
- rowCheckbox = false,
37
- totalData = 0,
38
- pagination,
39
- onPageChange,
40
- emptyContent,
41
- isLoading = false,
42
- classNames,
43
- color,
44
- size,
45
- skeletonRow,
46
- onCheckedRowsChange
47
- } = { ...props, ...variantProps };
48
- const { page = 1, perPage = 15 } = pagination || {};
49
- const showPagination = pagination && totalData > 0 && !isLoading;
50
- const [checkedRows, setCheckedRows] = useState(/* @__PURE__ */ new Set());
51
- useEffect(() => {
52
- onCheckedRowsChange == null ? void 0 : onCheckedRowsChange(getCheckedRowData(checkedRows));
53
- }, [checkedRows]);
54
- useEffect(() => {
55
- const currentRowIds = new Set(rows.map((row) => row.id));
56
- const checkedRowIds = Array.from(checkedRows);
57
- const hasValidCheckedRows = checkedRowIds.every((id) => currentRowIds.has(id));
58
- if (!hasValidCheckedRows) {
59
- setCheckedRows(/* @__PURE__ */ new Set());
60
- }
61
- }, [rows.map((row) => row.id).join(",")]);
62
- useImperativeHandle(
63
- ref,
64
- () => ({
65
- checkedRows,
66
- setCheckedRows
67
- }),
68
- [checkedRows]
69
- );
70
- const handleAllRowCheck = (checked) => {
71
- const updated = checked ? new Set(rows.map((row) => row.id)) : /* @__PURE__ */ new Set();
72
- setCheckedRows(updated);
73
- };
74
- const handleRowCheck = (id, checked) => {
75
- setCheckedRows((prev) => {
76
- const updated = new Set(prev);
77
- checked ? updated.add(id) : updated.delete(id);
78
- return updated;
79
- });
80
- };
81
- const getCheckedRowData = (checked) => rows.filter((row) => checked.has(row.id));
82
- const slots = useMemo(() => tableStyle(variantProps), [variantProps]);
83
- return /* @__PURE__ */ jsxs("div", { "data-table": "base", className: slots.base({ class: classNames == null ? void 0 : classNames.base }), children: [
84
- /* @__PURE__ */ jsx(scrollArea_default, { direction: "x", size: size === "xl" ? "lg" : size, children: /* @__PURE__ */ jsxs("table", { className: slots.table({ class: classNames == null ? void 0 : classNames.table }), children: [
85
- /* @__PURE__ */ jsx(
86
- table_head_default,
87
- {
88
- columns,
89
- size,
90
- color,
91
- rowCheckbox,
92
- isCheckedAll: checkedRows.size === rows.length && rows.length > 0,
93
- onCheckAll: handleAllRowCheck,
94
- isLoading,
95
- classNames,
96
- slots
97
- }
98
- ),
99
- /* @__PURE__ */ jsx(
100
- table_body_default,
101
- {
102
- slots,
103
- rows,
104
- columns,
105
- size,
106
- color,
107
- rowCheckbox,
108
- checkedRows,
109
- onCheckRow: handleRowCheck,
110
- emptyContent,
111
- isLoading,
112
- skeletonRow,
113
- className: clsx(
114
- "transition-all duration-150 ease-out",
115
- isLoading ? "-translate-y-2 opacity-0" : "translate-y-0 opacity-100",
116
- classNames
117
- )
118
- }
119
- )
120
- ] }) }),
121
- showPagination && /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx(
122
- pagination_default,
123
- {
124
- color,
125
- currentPage: page,
126
- totalPage: Math.ceil(totalData / perPage),
127
- groupSize: 10,
128
- handleChangePage: (newPage) => onPageChange == null ? void 0 : onPageChange({ page: newPage, perPage })
129
- }
130
- ) })
131
- ] });
132
- });
133
- Table.displayName = "Table";
134
- var table_default = Table;
135
- var tableStyle = tv({
136
- slots: {
137
- base: ["flex", "flex-col", "relative", "select-none", "gap-[20px]"],
138
- table: ["w-full", "h-auto"],
139
- thead: ["w-full"],
140
- tbody: ["w-full"],
141
- tr: ["group/tr", "outline-none", "w-full", "h-full"],
142
- th: [
143
- "text-body-foreground",
144
- "font-bold",
145
- "whitespace-nowrap",
146
- "outline-none",
147
- "align-middle",
148
- "px-[10px]",
149
- "[&>div]:flex",
150
- "[&>div]:gap-[10px]"
151
- ],
152
- td: [
153
- "relative",
154
- "text-foreground",
155
- "whitespace-normal",
156
- "outline-none",
157
- "[&>*]:z-1",
158
- "[&>*]:relative",
159
- "px-[10px]",
160
- "gap-[10px]",
161
- "transition duration-200",
162
- "align-middle"
163
- ],
164
- empty: [
165
- "relative",
166
- "text-foreground",
167
- "whitespace-normal",
168
- "outline-none",
169
- "[&>*]:z-1",
170
- "[&>*]:relative",
171
- "align-middle"
172
- ]
173
- },
174
- variants: {
175
- variant: {
176
- solid: {
177
- tbody: ["[&>tr]:border-b"]
178
- },
179
- outline: {
180
- tbody: ["[&>td]:border"],
181
- th: ["border"],
182
- td: ["border"]
183
- },
184
- underline: {
185
- tbody: ["[&>tr]:border-b"],
186
- th: ["border-t-[2px]", "border-b"]
187
- }
188
- },
189
- size: {
190
- sm: {
191
- tr: ["text-sm"]
192
- },
193
- md: {
194
- tr: ["text-md"]
195
- },
196
- lg: {
197
- tr: ["text-lg"]
198
- },
199
- xl: {
200
- tr: ["text-xl"]
201
- }
202
- },
203
- color: {
204
- primary: {
205
- tbody: ["[&>tr]:border-primary-light"]
206
- },
207
- secondary: {
208
- tbody: ["[&>tr]:border-secondary-light"]
209
- },
210
- neutral: {
211
- tbody: ["[&>tr]:border-neutral-light"]
212
- }
213
- },
214
- height: {
215
- narrow: {},
216
- wide: {}
217
- }
218
- },
219
- compoundVariants: [
220
- {
221
- variant: "solid",
222
- color: "primary",
223
- class: {
224
- th: ["bg-primary-soft"]
225
- }
226
- },
227
- {
228
- variant: "solid",
229
- color: "secondary",
230
- class: {
231
- th: ["bg-secondary-soft"]
232
- }
233
- },
234
- {
235
- variant: "solid",
236
- color: "neutral",
237
- class: {
238
- th: ["bg-neutral-soft"]
239
- }
240
- },
241
- {
242
- variant: "outline",
243
- color: "primary",
244
- class: {
245
- th: ["bg-primary-soft", "border-primary-light"],
246
- td: ["border-primary-light"]
247
- }
248
- },
249
- {
250
- variant: "outline",
251
- color: "secondary",
252
- class: {
253
- th: ["bg-secondary-soft", "border-secondary-light"],
254
- td: ["border-secondary-light"]
255
- }
256
- },
257
- {
258
- variant: "outline",
259
- color: "neutral",
260
- class: {
261
- th: ["bg-neutral-soft", "border-neutral-light"],
262
- td: ["border-neutral-light"]
263
- }
264
- },
265
- {
266
- variant: "underline",
267
- color: "primary",
268
- class: {
269
- th: ["bg-body-background", "border-t-[2px]", "border-b", "border-primary-main"]
270
- }
271
- },
272
- {
273
- variant: "underline",
274
- color: "secondary",
275
- class: {
276
- th: ["bg-body-background", "border-t-[2px]", "border-b", "border-secondary-main"]
277
- }
278
- },
279
- {
280
- variant: "underline",
281
- color: "neutral",
282
- class: {
283
- th: ["bg-body-background", "border-t-[2px]", "border-b", "border-neutral-main"]
284
- }
285
- },
286
- {
287
- height: "narrow",
288
- size: "sm",
289
- class: {
290
- tr: ["h-[30px]"]
291
- }
292
- },
293
- {
294
- height: "narrow",
295
- size: "md",
296
- class: {
297
- tr: ["h-[40px]"]
298
- }
299
- },
300
- {
301
- height: "narrow",
302
- size: "lg",
303
- class: {
304
- tr: ["h-[50px]"]
305
- }
306
- },
307
- {
308
- height: "narrow",
309
- size: "xl",
310
- class: {
311
- tr: ["h-[60px]"]
312
- }
313
- },
314
- {
315
- height: "wide",
316
- size: "sm",
317
- class: {
318
- tr: ["h-[40px]"]
319
- }
320
- },
321
- {
322
- height: "wide",
323
- size: "md",
324
- class: {
325
- tr: ["h-[50px]"]
326
- }
327
- },
328
- {
329
- height: "wide",
330
- size: "lg",
331
- class: {
332
- tr: ["h-[60px]"]
333
- }
334
- },
335
- {
336
- height: "wide",
337
- size: "xl",
338
- class: {
339
- tr: ["h-[70px]"]
340
- }
341
- }
342
- ],
343
- defaultVariants: {
344
- variant: "solid",
345
- size: "md",
346
- color: "primary",
347
- height: "narrow"
348
- }
349
- });
350
-
351
- export {
352
- table_default
353
- };
@@ -1,72 +0,0 @@
1
- "use client";
2
- import {
3
- skeleton_default
4
- } from "./chunk-6PN3DGOE.mjs";
5
- import {
6
- checkbox_default
7
- } from "./chunk-SKOCUCE5.mjs";
8
- import {
9
- clsx
10
- } from "./chunk-27Y6K5NK.mjs";
11
-
12
- // src/components/table/table-body.tsx
13
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
- var TableBody = ({
15
- slots,
16
- rows,
17
- columns,
18
- size,
19
- color,
20
- rowCheckbox = false,
21
- checkedRows,
22
- onCheckRow,
23
- isLoading = false,
24
- emptyContent,
25
- skeletonRow,
26
- classNames,
27
- className
28
- }) => {
29
- const getCellStyle = (column) => ({
30
- width: column.width ? `${column.width}px` : void 0,
31
- minWidth: column.minWidth ? `${column.minWidth}px` : void 0,
32
- maxWidth: column.maxWidth ? `${column.maxWidth}px` : void 0,
33
- height: column.height ? `${column.height}px` : void 0,
34
- textAlign: column.align || "center"
35
- });
36
- const renderTdSkeleton = (key) => /* @__PURE__ */ jsx("td", { className: slots.td({ class: classNames == null ? void 0 : classNames.td }), children: /* @__PURE__ */ jsx(skeleton_default, { color, className: "h-full w-full", rounded: "lg", speed: "fast" }) }, key);
37
- const renderCheckboxCell = (rowId) => /* @__PURE__ */ jsx("td", { className: clsx(slots.td({ class: classNames == null ? void 0 : classNames.td }), "text-center"), children: /* @__PURE__ */ jsx(checkbox_default, { size, checked: checkedRows.has(rowId), onChange: (e) => onCheckRow(rowId, e.target.checked) }) });
38
- const renderSkeletonRow = (rowIndex) => /* @__PURE__ */ jsxs("tr", { className: slots.tr({ class: classNames == null ? void 0 : classNames.tr }), children: [
39
- columns.map((_, colIdx) => renderTdSkeleton(`skeleton-${rowIndex}-${colIdx}`)),
40
- rowCheckbox && renderTdSkeleton(`skeleton-checkbox-${rowIndex}`)
41
- ] }, `skeleton-${rowIndex}`);
42
- const renderEmptyRow = () => /* @__PURE__ */ jsx("tr", { className: slots.tr({ class: classNames == null ? void 0 : classNames.tr }), children: /* @__PURE__ */ jsx("td", { colSpan: columns.length + (rowCheckbox ? 1 : 0), className: slots.empty({ class: classNames == null ? void 0 : classNames.empty }), children: emptyContent }) });
43
- const renderDataRow = (row, rowIndex) => /* @__PURE__ */ jsxs("tr", { className: slots.tr({ class: classNames == null ? void 0 : classNames.tr }), children: [
44
- columns.map((column, colIdx) => {
45
- var _a;
46
- const value = row[column.field];
47
- const formattedValue = ((_a = column.valueFormatter) == null ? void 0 : _a.call(column, { value, field: column.field })) || value;
48
- const content = column.renderCell ? column.renderCell({ id: row.id, field: column.field, value, formattedValue, row }) : formattedValue;
49
- return /* @__PURE__ */ jsx(
50
- "td",
51
- {
52
- className: clsx(slots.td({ class: classNames == null ? void 0 : classNames.td }), column.className),
53
- style: getCellStyle(column),
54
- children: content
55
- },
56
- `${rowIndex}-${colIdx}`
57
- );
58
- }),
59
- rowCheckbox && renderCheckboxCell(row.id)
60
- ] }, rowIndex);
61
- const renderRows = () => {
62
- if (isLoading) return skeletonRow ? Array.from({ length: skeletonRow }, (_, idx) => renderSkeletonRow(idx)) : /* @__PURE__ */ jsx(Fragment, {});
63
- if (!rows.length && emptyContent) return renderEmptyRow();
64
- return rows.map((row, index) => renderDataRow(row, index));
65
- };
66
- return /* @__PURE__ */ jsx("tbody", { className: `${slots.tbody({ class: classNames == null ? void 0 : classNames.tbody })} ${className || ""}`, children: renderRows() });
67
- };
68
- var table_body_default = TableBody;
69
-
70
- export {
71
- table_body_default
72
- };
@@ -1,67 +0,0 @@
1
- "use client";
2
- import {
3
- skeleton_default
4
- } from "./chunk-6PN3DGOE.mjs";
5
- import {
6
- checkbox_default
7
- } from "./chunk-SKOCUCE5.mjs";
8
- import {
9
- clsx
10
- } from "./chunk-27Y6K5NK.mjs";
11
-
12
- // src/components/table/table-head.tsx
13
- import { jsx, jsxs } from "react/jsx-runtime";
14
- var TableHead = ({
15
- slots,
16
- columns,
17
- color,
18
- size,
19
- rowCheckbox = false,
20
- isCheckedAll,
21
- isLoading = false,
22
- classNames,
23
- onCheckAll
24
- }) => {
25
- const handleClickCheckAll = (e) => {
26
- e.preventDefault();
27
- onCheckAll(!isCheckedAll);
28
- };
29
- const renderTh = (content, key, column) => /* @__PURE__ */ jsx(
30
- "th",
31
- {
32
- className: clsx(slots.th({ class: classNames == null ? void 0 : classNames.th }), column),
33
- style: {
34
- width: (column == null ? void 0 : column.width) ? `${column.width}px` : void 0,
35
- minWidth: (column == null ? void 0 : column.minWidth) ? `${column.minWidth}px` : void 0,
36
- maxWidth: (column == null ? void 0 : column.maxWidth) ? `${column.maxWidth}px` : void 0,
37
- height: (column == null ? void 0 : column.height) ? `${column.height}px` : void 0
38
- },
39
- children: content
40
- },
41
- key
42
- );
43
- const renderSkeletonRow = () => /* @__PURE__ */ jsx("thead", { className: slots.thead({ class: classNames == null ? void 0 : classNames.thead }), children: /* @__PURE__ */ jsxs("tr", { className: clsx(slots.tr({ class: classNames == null ? void 0 : classNames.tr }), "[&>th]:border-0"), children: [
44
- columns.map((_, idx) => renderTh(/* @__PURE__ */ jsx(skeleton_default, { color, rounded: "lg", speed: "fast" }), `skeleton-${idx}`)),
45
- rowCheckbox && renderTh(/* @__PURE__ */ jsx(skeleton_default, { color, rounded: "lg", speed: "fast" }), "checkbox-skeleton")
46
- ] }) });
47
- const renderContentRow = () => /* @__PURE__ */ jsx("thead", { className: slots.thead({ class: classNames == null ? void 0 : classNames.thead }), children: /* @__PURE__ */ jsxs("tr", { className: slots.tr({ class: classNames == null ? void 0 : classNames.tr }), children: [
48
- columns.map((column, idx) => renderTh(column.headerName, `${column.field}-${idx}`, column)),
49
- rowCheckbox && renderTh(
50
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", onClick: handleClickCheckAll, children: /* @__PURE__ */ jsx(
51
- checkbox_default,
52
- {
53
- size,
54
- checked: isCheckedAll,
55
- onChange: (e) => onCheckAll(e.target.checked)
56
- }
57
- ) }),
58
- "checkbox"
59
- )
60
- ] }) });
61
- return isLoading ? renderSkeletonRow() : renderContentRow();
62
- };
63
- var table_head_default = TableHead;
64
-
65
- export {
66
- table_head_default
67
- };
@@ -1,10 +1,10 @@
1
1
  "use client";
2
- import {
3
- list_default
4
- } from "./chunk-B6XJNGQL.mjs";
5
2
  import {
6
3
  listItem_default
7
4
  } from "./chunk-QFIS6N5R.mjs";
5
+ import {
6
+ list_default
7
+ } from "./chunk-B6XJNGQL.mjs";
8
8
 
9
9
  // src/components/dateTimePicker/timePicker.tsx
10
10
  import { useState, useRef, useEffect } from "react";