@rovula/ui 0.0.11 → 0.0.13
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/cjs/bundle.css +55 -5
- package/dist/cjs/bundle.js +23 -1
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/DataTable/DataTable.d.ts +6 -11
- package/dist/cjs/types/components/DataTable/DataTable.stories.d.ts +3 -0
- package/dist/cjs/types/components/Table/Table.d.ts +3 -1
- package/dist/cjs/types/components/Table/Table.stories.d.ts +4 -1
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/components/DataTable/DataTable.js +62 -23
- package/dist/components/DataTable/DataTable.stories.js +16 -25
- package/dist/components/Dropdown/Dropdown.js +39 -2
- package/dist/components/Dropdown/Dropdown.stories.js +29 -4
- package/dist/components/Table/Table.js +6 -6
- package/dist/esm/bundle.css +55 -5
- package/dist/esm/bundle.js +23 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/DataTable/DataTable.d.ts +6 -11
- package/dist/esm/types/components/DataTable/DataTable.stories.d.ts +3 -0
- package/dist/esm/types/components/Table/Table.d.ts +3 -1
- package/dist/esm/types/components/Table/Table.stories.d.ts +4 -1
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/index.d.ts +14 -2
- package/dist/index.js +1 -0
- package/dist/src/theme/global.css +71 -6
- package/package.json +2 -1
- package/src/components/DataTable/DataTable.stories.tsx +26 -30
- package/src/components/DataTable/DataTable.tsx +111 -45
- package/src/components/Dropdown/Dropdown.stories.tsx +25 -3
- package/src/components/Dropdown/Dropdown.tsx +61 -2
- package/src/components/Table/Table.tsx +17 -8
- package/src/index.ts +2 -1
- package/dist/cjs/types/components/ui/table.d.ts +0 -10
- package/dist/components/ui/table.js +0 -66
- package/dist/esm/types/components/ui/table.d.ts +0 -10
- package/src/components/ui/table.tsx +0 -117
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
-
export
|
|
3
|
-
id: string;
|
|
4
|
-
amount: number;
|
|
5
|
-
status: "pending" | "processing" | "success" | "failed";
|
|
6
|
-
email: string;
|
|
7
|
-
};
|
|
8
|
-
export declare const columns: ColumnDef<Payment>[];
|
|
9
|
-
interface DataTableProps<TData, TValue> {
|
|
1
|
+
import { ColumnDef, SortingState } from "@tanstack/react-table";
|
|
2
|
+
export interface DataTableProps<TData, TValue> {
|
|
10
3
|
columns: ColumnDef<TData, TValue>[];
|
|
11
4
|
data: TData[];
|
|
5
|
+
manualSorting?: boolean;
|
|
6
|
+
onSorting?: (sorting: SortingState) => void;
|
|
7
|
+
fetchMoreData?: () => void;
|
|
12
8
|
}
|
|
13
|
-
export declare function DataTable<TData, TValue>({ columns,
|
|
14
|
-
export {};
|
|
9
|
+
export declare function DataTable<TData, TValue>({ data, columns, manualSorting, onSorting, fetchMoreData, }: DataTableProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,6 +10,9 @@ declare const meta: {
|
|
|
10
10
|
decorators: ((Story: import("@storybook/types").PartialStoryFn<import("@storybook/react").ReactRenderer, {
|
|
11
11
|
columns: ColumnDef<unknown, unknown>[];
|
|
12
12
|
data: unknown[];
|
|
13
|
+
manualSorting?: boolean | undefined;
|
|
14
|
+
onSorting?: ((sorting: import("@tanstack/react-table").SortingState) => void) | undefined;
|
|
15
|
+
fetchMoreData?: (() => void) | undefined;
|
|
13
16
|
}>) => import("react/jsx-runtime").JSX.Element)[];
|
|
14
17
|
};
|
|
15
18
|
export default meta;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare const Table: React.ForwardRefExoticComponent<
|
|
2
|
+
declare const Table: React.ForwardRefExoticComponent<{
|
|
3
|
+
rootRef?: React.LegacyRef<HTMLDivElement> | undefined;
|
|
4
|
+
} & React.HTMLAttributes<HTMLTableElement> & React.RefAttributes<HTMLTableElement>>;
|
|
3
5
|
declare const TableHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
4
6
|
declare const TableBody: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
5
7
|
declare const TableFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLTableSectionElement> & React.RefAttributes<HTMLTableSectionElement>>;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: React.ForwardRefExoticComponent<
|
|
4
|
+
component: React.ForwardRefExoticComponent<{
|
|
5
|
+
rootRef?: React.LegacyRef<HTMLDivElement> | undefined;
|
|
6
|
+
} & React.HTMLAttributes<HTMLTableElement> & React.RefAttributes<HTMLTableElement>>;
|
|
5
7
|
tags: string[];
|
|
6
8
|
parameters: {
|
|
7
9
|
layout: string;
|
|
8
10
|
};
|
|
9
11
|
decorators: ((Story: import("@storybook/types").PartialStoryFn<import("@storybook/react").ReactRenderer, {
|
|
12
|
+
rootRef?: React.LegacyRef<HTMLDivElement> | undefined;
|
|
10
13
|
defaultChecked?: boolean | undefined;
|
|
11
14
|
defaultValue?: string | number | readonly string[] | undefined;
|
|
12
15
|
suppressContentEditableWarning?: boolean | undefined;
|
|
@@ -8,10 +8,11 @@ export { Checkbox } from "./components/Checkbox/Checkbox";
|
|
|
8
8
|
export { Label } from "./components/Label/Label";
|
|
9
9
|
export { Input } from "./components/Input/Input";
|
|
10
10
|
export * from "./components/Table/Table";
|
|
11
|
+
export * from "./components/DataTable/DataTable";
|
|
11
12
|
export * from "./components/Dialog/Dialog";
|
|
12
13
|
export * from "./components/AlertDialog/AlertDialog";
|
|
13
14
|
export type { ButtonProps } from "./components/Button/Button";
|
|
14
15
|
export type { InputProps } from "./components/TextInput/TextInput";
|
|
15
|
-
export type { DropdownProps } from "./components/Dropdown/Dropdown";
|
|
16
|
+
export type { DropdownProps, Options } from "./components/Dropdown/Dropdown";
|
|
16
17
|
export { resloveTimestamp, getStartDateOfDay, getEndDateOfDay, getStartEndTimestampOfDay, getTimestampUTC, } from "./utils/datetime";
|
|
17
18
|
export { cn } from "./utils/cn";
|
|
@@ -1,32 +1,71 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { flexRender, getCoreRowModel,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
accessorKey: "email",
|
|
11
|
-
header: "Email",
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
accessorKey: "amount",
|
|
15
|
-
header: "Amount",
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table";
|
|
2
|
+
import { flexRender, getCoreRowModel, getFilteredRowModel,
|
|
3
|
+
// getPaginationRowModel,
|
|
4
|
+
getSortedRowModel, useReactTable, } from "@tanstack/react-table";
|
|
5
|
+
import { useEffect, useRef, useState } from "react";
|
|
6
|
+
import { ArrowDownIcon, ArrowUpIcon, ArrowsUpDownIcon, ClipboardDocumentListIcon, } from "@heroicons/react/16/solid";
|
|
7
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "../Table/Table";
|
|
19
8
|
export function DataTable(_a) {
|
|
20
9
|
var _b;
|
|
21
|
-
var columns = _a.columns,
|
|
10
|
+
var data = _a.data, columns = _a.columns, _c = _a.manualSorting, manualSorting = _c === void 0 ? false : _c, onSorting = _a.onSorting, fetchMoreData = _a.fetchMoreData;
|
|
11
|
+
var tableBodyRef = useRef(null);
|
|
12
|
+
var _d = useState([]), sorting = _d[0], setSorting = _d[1];
|
|
13
|
+
var _e = useState([]), columnFilters = _e[0], setColumnFilters = _e[1];
|
|
14
|
+
var _f = useState({}), columnVisibility = _f[0], setColumnVisibility = _f[1];
|
|
15
|
+
var _g = useState({}), rowSelection = _g[0], setRowSelection = _g[1];
|
|
22
16
|
var table = useReactTable({
|
|
23
17
|
data: data,
|
|
24
18
|
columns: columns,
|
|
19
|
+
manualSorting: manualSorting,
|
|
20
|
+
onSortingChange: setSorting,
|
|
21
|
+
onColumnFiltersChange: setColumnFilters,
|
|
25
22
|
getCoreRowModel: getCoreRowModel(),
|
|
23
|
+
// getPaginationRowModel: getPaginationRowModel(),
|
|
24
|
+
getSortedRowModel: getSortedRowModel(),
|
|
25
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
26
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
27
|
+
onRowSelectionChange: setRowSelection,
|
|
28
|
+
state: {
|
|
29
|
+
sorting: sorting,
|
|
30
|
+
columnFilters: columnFilters,
|
|
31
|
+
columnVisibility: columnVisibility,
|
|
32
|
+
rowSelection: rowSelection,
|
|
33
|
+
// pagination: {
|
|
34
|
+
// pageSize: 100,
|
|
35
|
+
// pageIndex: 0,
|
|
36
|
+
// },
|
|
37
|
+
},
|
|
26
38
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
onSorting === null || onSorting === void 0 ? void 0 : onSorting(sorting);
|
|
41
|
+
}, [sorting, onSorting]);
|
|
42
|
+
useEffect(function () {
|
|
43
|
+
var handleScroll = function () {
|
|
44
|
+
if (tableBodyRef.current) {
|
|
45
|
+
var _a = tableBodyRef.current, scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
|
46
|
+
if (scrollTop + clientHeight >= scrollHeight - 10) {
|
|
47
|
+
fetchMoreData === null || fetchMoreData === void 0 ? void 0 : fetchMoreData();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var tableBodyElement = tableBodyRef.current;
|
|
52
|
+
if (tableBodyElement) {
|
|
53
|
+
tableBodyElement.addEventListener("scroll", handleScroll);
|
|
54
|
+
}
|
|
55
|
+
return function () {
|
|
56
|
+
if (tableBodyElement) {
|
|
57
|
+
tableBodyElement.removeEventListener("scroll", handleScroll);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}, [fetchMoreData]);
|
|
61
|
+
var isEmpty = ((_b = table.getRowModel().rows) === null || _b === void 0 ? void 0 : _b.length) === 0;
|
|
62
|
+
return (_jsx("div", { className: "flex w-full h-full rounded-xl overflow-hidden border border-primary-10", children: _jsxs(Table, { className: isEmpty ? "h-full" : "", rootRef: tableBodyRef, children: [_jsx(TableHeader, { className: "sticky top-0", children: table.getHeaderGroups().map(function (headerGroup) { return (_jsx(TableRow, { className: "", children: headerGroup.headers.map(function (header, i) {
|
|
63
|
+
var _a;
|
|
64
|
+
return (_jsx(TableHead, { children: _jsxs("div", { className: "flex flex-row items-center cursor-pointer", onClick: header.column.getToggleSortingHandler(), children: [header.isPlaceholder
|
|
65
|
+
? null
|
|
66
|
+
: flexRender(header.column.columnDef.header, header.getContext()), (_a = {
|
|
67
|
+
asc: _jsx(ArrowUpIcon, { className: "ml-3 h-4 w-4" }),
|
|
68
|
+
desc: _jsx(ArrowDownIcon, { className: "ml-3 h-4 w-4" }),
|
|
69
|
+
}[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : (header.column.getCanSort() ? (_jsx(ArrowsUpDownIcon, { className: "ml-3 h-4 w-4 text-textcolor-grey-light" })) : null)] }) }, header.id));
|
|
70
|
+
}) }, headerGroup.id)); }) }), _jsx(TableBody, { className: "overflow-y-scroll", children: !isEmpty ? (table.getRowModel().rows.map(function (row) { return (_jsx(TableRow, { "data-state": row.getIsSelected() && "selected", className: "", children: row.getVisibleCells().map(function (cell) { return (_jsx(TableCell, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)); }) }, row.id)); })) : (_jsx(TableRow, { className: "h-full self-stretch", children: _jsx(TableCell, { colSpan: columns.length, className: "typography-body1 text-textcolor-grey-medium text-center h-full", children: _jsxs("div", { className: "flex flex-1 h-full flex-col items-center justify-center gap-3", children: [_jsx(ClipboardDocumentListIcon, { className: "w-8 text-secondary-120" }), "There is no information yet."] }) }) })) })] }) }));
|
|
32
71
|
}
|
|
@@ -19,23 +19,13 @@ var meta = {
|
|
|
19
19
|
layout: "fullscreen",
|
|
20
20
|
},
|
|
21
21
|
decorators: [
|
|
22
|
-
function (Story) { return (_jsx("div", { className: "p-5 flex w-full", children: _jsx(Story, {}) })); },
|
|
22
|
+
function (Story) { return (_jsx("div", { className: "p-5 flex flex-1 h-full w-full ", style: { height: "100vh" }, children: _jsx(Story, {}) })); },
|
|
23
23
|
],
|
|
24
24
|
};
|
|
25
25
|
export default meta;
|
|
26
26
|
var columns = [
|
|
27
27
|
{
|
|
28
28
|
accessorKey: "amount",
|
|
29
|
-
header: function () { return _jsx("div", { className: "text-right", children: "Amount" }); },
|
|
30
|
-
cell: function (_a) {
|
|
31
|
-
var row = _a.row;
|
|
32
|
-
var amount = parseFloat(row.getValue("amount"));
|
|
33
|
-
var formatted = new Intl.NumberFormat("en-US", {
|
|
34
|
-
style: "currency",
|
|
35
|
-
currency: "USD",
|
|
36
|
-
}).format(amount);
|
|
37
|
-
return _jsx("div", { className: "text-right font-medium", children: formatted });
|
|
38
|
-
},
|
|
39
29
|
},
|
|
40
30
|
{
|
|
41
31
|
accessorKey: "status",
|
|
@@ -45,22 +35,23 @@ var columns = [
|
|
|
45
35
|
},
|
|
46
36
|
];
|
|
47
37
|
export var Default = {
|
|
48
|
-
args: {
|
|
49
|
-
// label: "Lorem Ipsum",
|
|
50
|
-
// value: "Lorem Ipsum",
|
|
51
|
-
// fullwidth: true,
|
|
52
|
-
},
|
|
38
|
+
args: {},
|
|
53
39
|
render: function (args) {
|
|
54
40
|
console.log("args ", args);
|
|
55
41
|
var props = __assign({}, args);
|
|
56
|
-
var data =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
var data = new Array(20).fill(0).map(function (__, i) { return ({
|
|
43
|
+
id: "m5gr84i9",
|
|
44
|
+
amount: i + 1,
|
|
45
|
+
status: "success",
|
|
46
|
+
email: "ken99@yahoo.com",
|
|
47
|
+
email1: "ken99@yahoo.com",
|
|
48
|
+
email2: "ken99@yahoo.com",
|
|
49
|
+
email3: "ken99@yahoo.com",
|
|
50
|
+
}); });
|
|
51
|
+
return (_jsx("div", { className: "flex flex-1 h-full flex-row gap-4 w-full", children: _jsx(DataTable, { columns: columns, data: data, onSorting: function (sorting) {
|
|
52
|
+
console.log("sorting ", sorting);
|
|
53
|
+
}, fetchMoreData: function () {
|
|
54
|
+
console.log("fetchMoreData");
|
|
55
|
+
} }) }));
|
|
65
56
|
},
|
|
66
57
|
};
|
|
@@ -21,7 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
import { Fragment, forwardRef, useCallback, useEffect, useMemo, useState, } from "react";
|
|
24
|
+
import { Fragment, forwardRef, useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
25
25
|
import TextInput from "../TextInput/TextInput";
|
|
26
26
|
import { customInputVariant, dropdownIconVariant, iconWrapperVariant, } from "./Dropdown.styles";
|
|
27
27
|
import { ChevronDownIcon } from "@heroicons/react/16/solid";
|
|
@@ -31,6 +31,7 @@ var Dropdown = forwardRef(function (_a, ref) {
|
|
|
31
31
|
var _k = useState(false), isFocused = _k[0], setIsFocused = _k[1];
|
|
32
32
|
var _l = useState(null), selectedOption = _l[0], setSelectedOption = _l[1];
|
|
33
33
|
var _m = useState(""), textValue = _m[0], setTextValue = _m[1];
|
|
34
|
+
var keyCode = useRef("");
|
|
34
35
|
useEffect(function () {
|
|
35
36
|
if (value && !selectedOption) {
|
|
36
37
|
setSelectedOption(value);
|
|
@@ -63,6 +64,42 @@ var Dropdown = forwardRef(function (_a, ref) {
|
|
|
63
64
|
}
|
|
64
65
|
return (_jsx("li", { onMouseDown: function () { return handleOptionClick(option); }, className: "px-4 py-2 hover:bg-gray-100 cursor-pointer ".concat((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) === option.value ? " bg-gray-200" : ""), children: option.label }, option.value));
|
|
65
66
|
}), optionsFiltered.length === 0 && (_jsx("li", { className: "px-4 py-14 text-center text-input-text", children: "Not found" }))] })); };
|
|
66
|
-
|
|
67
|
+
var handleOnFocus = useCallback(function (e) {
|
|
68
|
+
var _a;
|
|
69
|
+
setIsFocused(true);
|
|
70
|
+
(_a = props === null || props === void 0 ? void 0 : props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
71
|
+
}, [props === null || props === void 0 ? void 0 : props.onFocus]);
|
|
72
|
+
var clearMismatchValue = useCallback(function (e) {
|
|
73
|
+
var matchSelectedValue = optionsFiltered.find(function (opt) { var _a, _b; return opt.value === ((_a = e.target) === null || _a === void 0 ? void 0 : _a.value) || opt.label === ((_b = e.target) === null || _b === void 0 ? void 0 : _b.value); });
|
|
74
|
+
var isMatchSelectedValue = !!matchSelectedValue;
|
|
75
|
+
var option = matchSelectedValue || {
|
|
76
|
+
value: "",
|
|
77
|
+
label: "",
|
|
78
|
+
};
|
|
79
|
+
if (!isMatchSelectedValue && textValue) {
|
|
80
|
+
option = {
|
|
81
|
+
value: "",
|
|
82
|
+
label: "",
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (keyCode.current === "Enter") {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
setSelectedOption(option);
|
|
89
|
+
setTextValue(option.label);
|
|
90
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect(option);
|
|
91
|
+
}, [optionsFiltered, textValue]);
|
|
92
|
+
var handleOnBlur = useCallback(function (e) {
|
|
93
|
+
var _a;
|
|
94
|
+
setIsFocused(false);
|
|
95
|
+
clearMismatchValue(e);
|
|
96
|
+
(_a = props === null || props === void 0 ? void 0 : props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
97
|
+
}, [props === null || props === void 0 ? void 0 : props.onBlur]);
|
|
98
|
+
var handleOnKeyDown = useCallback(function (e) {
|
|
99
|
+
var _a;
|
|
100
|
+
keyCode.current = e.code;
|
|
101
|
+
(_a = props === null || props === void 0 ? void 0 : props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
102
|
+
}, [props === null || props === void 0 ? void 0 : props.onKeyDown]);
|
|
103
|
+
return (_jsxs("div", { className: "relative ".concat(fullwidth ? "w-full" : ""), children: [_jsx(TextInput, __assign({}, props, { ref: ref, readOnly: !filterMode, value: textValue, onChange: handleOnChangeText, label: label, placeholder: " ", type: "text", rounded: rounded, variant: variant, helperText: helperText, errorMessage: errorMessage, fullwidth: fullwidth, error: error, required: required, id: _id, disabled: disabled, hasClearIcon: false, size: size, className: customInputVariant({ size: size }), onFocus: handleOnFocus, onBlur: handleOnBlur, onKeyDown: handleOnKeyDown, endIcon: _jsx("div", { className: iconWrapperVariant({ size: size }), children: _jsx(ChevronDownIcon, { className: dropdownIconVariant({ size: size, isFocus: isFocused }) }) }) })), isFocused && renderOptions()] }));
|
|
67
104
|
});
|
|
68
105
|
export default Dropdown;
|
|
@@ -9,8 +9,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
12
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { useRef } from "react";
|
|
22
|
+
import { useRef, useState } from "react";
|
|
14
23
|
import Dropdown from "./Dropdown";
|
|
15
24
|
import Button from "../Button/Button";
|
|
16
25
|
import { cn } from "@/utils/cn";
|
|
@@ -46,9 +55,25 @@ export var Default = {
|
|
|
46
55
|
};
|
|
47
56
|
var DropdownWithRef = function (props) {
|
|
48
57
|
var inputRef = useRef(null);
|
|
49
|
-
|
|
58
|
+
var _a = useState(customOptions), options = _a[0], setOptions = _a[1];
|
|
59
|
+
var _b = useState({
|
|
60
|
+
label: "",
|
|
61
|
+
value: "",
|
|
62
|
+
}), value = _b[0], setValue = _b[1];
|
|
63
|
+
var _c = useState(""), text = _c[0], setText = _c[1];
|
|
64
|
+
return (_jsx(Dropdown, __assign({ id: "1", size: "lg" }, props, { value: value, options: options, ref: inputRef, labelClassName: "peer-focus:bg-red-500", onSelect: setValue, onChangeText: function (e) { return setText(e.target.value); }, onKeyDown: function (e) {
|
|
50
65
|
var _a, _b;
|
|
51
66
|
if (e.code === "Enter") {
|
|
67
|
+
setOptions(function (options) { return __spreadArray(__spreadArray([], options, true), [
|
|
68
|
+
{
|
|
69
|
+
label: text,
|
|
70
|
+
value: text,
|
|
71
|
+
},
|
|
72
|
+
], false); });
|
|
73
|
+
setValue({
|
|
74
|
+
label: text,
|
|
75
|
+
value: text,
|
|
76
|
+
});
|
|
52
77
|
(_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
53
78
|
}
|
|
54
79
|
} })));
|
|
@@ -63,7 +88,7 @@ export var WithRef = {
|
|
|
63
88
|
render: function (args) {
|
|
64
89
|
console.log("args ", args);
|
|
65
90
|
var props = __assign({}, args);
|
|
66
|
-
return (
|
|
91
|
+
return (_jsx("div", { className: "flex flex-row gap-4 w-full", children: _jsx(DropdownWithRef, __assign({ id: "1", size: "lg", options: options }, args)) }));
|
|
67
92
|
},
|
|
68
93
|
};
|
|
69
94
|
var customOptions = new Array(100).fill("").map(function (__, index) { return ({
|
|
@@ -86,6 +111,6 @@ export var CustomOption = {
|
|
|
86
111
|
render: function (args) {
|
|
87
112
|
console.log("args ", args);
|
|
88
113
|
var props = __assign({}, args);
|
|
89
|
-
return (
|
|
114
|
+
return (_jsx("div", { className: "flex flex-row gap-4 w-full", children: _jsx(DropdownWithRef, __assign({ id: "1", size: "lg", options: options }, args)) }));
|
|
90
115
|
},
|
|
91
116
|
};
|
|
@@ -24,13 +24,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
24
|
import * as React from "react";
|
|
25
25
|
import { cn } from "@/utils/cn";
|
|
26
26
|
var Table = React.forwardRef(function (_a, ref) {
|
|
27
|
-
var className = _a.className, props = __rest(_a, ["className"]);
|
|
28
|
-
return (_jsx("div", { className: "relative w-full overflow-auto", children: _jsx("table", __assign({ ref: ref, className: cn("w-full caption-bottom text-sm", className) }, props)) }));
|
|
27
|
+
var className = _a.className, rootRef = _a.rootRef, props = __rest(_a, ["className", "rootRef"]);
|
|
28
|
+
return (_jsx("div", { className: "relative h-full w-full overflow-auto", ref: rootRef, children: _jsx("table", __assign({ ref: ref, className: cn("w-full caption-bottom text-sm border-collapse", className) }, props)) }));
|
|
29
29
|
});
|
|
30
30
|
Table.displayName = "Table";
|
|
31
31
|
var TableHeader = React.forwardRef(function (_a, ref) {
|
|
32
32
|
var className = _a.className, props = __rest(_a, ["className"]);
|
|
33
|
-
return (_jsx("thead", __assign({ ref: ref, className: cn("[&_tr]:border-b", className) }, props)));
|
|
33
|
+
return (_jsx("thead", __assign({ ref: ref, className: cn("[&_tr]:border-b bg-secondary-80", className) }, props)));
|
|
34
34
|
});
|
|
35
35
|
TableHeader.displayName = "TableHeader";
|
|
36
36
|
var TableBody = React.forwardRef(function (_a, ref) {
|
|
@@ -45,17 +45,17 @@ var TableFooter = React.forwardRef(function (_a, ref) {
|
|
|
45
45
|
TableFooter.displayName = "TableFooter";
|
|
46
46
|
var TableRow = React.forwardRef(function (_a, ref) {
|
|
47
47
|
var className = _a.className, props = __rest(_a, ["className"]);
|
|
48
|
-
return (_jsx("tr", __assign({ ref: ref, className: cn("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-
|
|
48
|
+
return (_jsx("tr", __assign({ ref: ref, className: cn("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-grey-20", className) }, props)));
|
|
49
49
|
});
|
|
50
50
|
TableRow.displayName = "TableRow";
|
|
51
51
|
var TableHead = React.forwardRef(function (_a, ref) {
|
|
52
52
|
var className = _a.className, props = __rest(_a, ["className"]);
|
|
53
|
-
return (_jsx("th", __assign({ ref: ref, className: cn("h-12 px-
|
|
53
|
+
return (_jsx("th", __assign({ ref: ref, className: cn(" h-12 py-3 px-6 text-left align-middle typography-body2 text-textcolor-grey-dark [&:has([role=checkbox])]:pr-4 [&:has([role=checkbox])]:w-4", className) }, props)));
|
|
54
54
|
});
|
|
55
55
|
TableHead.displayName = "TableHead";
|
|
56
56
|
var TableCell = React.forwardRef(function (_a, ref) {
|
|
57
57
|
var className = _a.className, props = __rest(_a, ["className"]);
|
|
58
|
-
return (_jsx("td", __assign({ ref: ref, className: cn("
|
|
58
|
+
return (_jsx("td", __assign({ ref: ref, className: cn(" py-3 px-6 text-left align-middle typography-body3 text-textcolor-grey-dark [&:has([role=checkbox])]:pr-4 [&:has([role=checkbox])]:w-4", className) }, props)));
|
|
59
59
|
});
|
|
60
60
|
TableCell.displayName = "TableCell";
|
|
61
61
|
var TableCaption = React.forwardRef(function (_a, ref) {
|
package/dist/esm/bundle.css
CHANGED
|
@@ -734,6 +734,9 @@ video {
|
|
|
734
734
|
.relative {
|
|
735
735
|
position: relative;
|
|
736
736
|
}
|
|
737
|
+
.sticky {
|
|
738
|
+
position: sticky;
|
|
739
|
+
}
|
|
737
740
|
.inset-0 {
|
|
738
741
|
inset: 0px;
|
|
739
742
|
}
|
|
@@ -762,6 +765,9 @@ video {
|
|
|
762
765
|
.right-4 {
|
|
763
766
|
right: 1rem;
|
|
764
767
|
}
|
|
768
|
+
.top-0 {
|
|
769
|
+
top: 0px;
|
|
770
|
+
}
|
|
765
771
|
.top-4 {
|
|
766
772
|
top: 1rem;
|
|
767
773
|
}
|
|
@@ -785,6 +791,9 @@ video {
|
|
|
785
791
|
margin-top: auto;
|
|
786
792
|
margin-bottom: auto;
|
|
787
793
|
}
|
|
794
|
+
.ml-3 {
|
|
795
|
+
margin-left: 0.75rem;
|
|
796
|
+
}
|
|
788
797
|
.mr-2 {
|
|
789
798
|
margin-right: 0.5rem;
|
|
790
799
|
}
|
|
@@ -864,21 +873,24 @@ video {
|
|
|
864
873
|
.h-12 {
|
|
865
874
|
height: 3rem;
|
|
866
875
|
}
|
|
867
|
-
.h-24 {
|
|
868
|
-
height: 6rem;
|
|
869
|
-
}
|
|
870
876
|
.h-4 {
|
|
871
877
|
height: 1rem;
|
|
872
878
|
}
|
|
873
879
|
.h-\[54px\] {
|
|
874
880
|
height: 54px;
|
|
875
881
|
}
|
|
882
|
+
.h-full {
|
|
883
|
+
height: 100%;
|
|
884
|
+
}
|
|
876
885
|
.max-h-60 {
|
|
877
886
|
max-height: 15rem;
|
|
878
887
|
}
|
|
879
888
|
.w-4 {
|
|
880
889
|
width: 1rem;
|
|
881
890
|
}
|
|
891
|
+
.w-8 {
|
|
892
|
+
width: 2rem;
|
|
893
|
+
}
|
|
882
894
|
.w-\[100px\] {
|
|
883
895
|
width: 100px;
|
|
884
896
|
}
|
|
@@ -900,12 +912,18 @@ video {
|
|
|
900
912
|
.max-w-lg {
|
|
901
913
|
max-width: 32rem;
|
|
902
914
|
}
|
|
915
|
+
.flex-1 {
|
|
916
|
+
flex: 1 1 0%;
|
|
917
|
+
}
|
|
903
918
|
.shrink-0 {
|
|
904
919
|
flex-shrink: 0;
|
|
905
920
|
}
|
|
906
921
|
.caption-bottom {
|
|
907
922
|
caption-side: bottom;
|
|
908
923
|
}
|
|
924
|
+
.border-collapse {
|
|
925
|
+
border-collapse: collapse;
|
|
926
|
+
}
|
|
909
927
|
.translate-x-\[-50\%\] {
|
|
910
928
|
--tw-translate-x: -50%;
|
|
911
929
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
@@ -998,15 +1016,24 @@ video {
|
|
|
998
1016
|
margin-top: calc(1rem * calc(1 - var(--tw-space-y-reverse)));
|
|
999
1017
|
margin-bottom: calc(1rem * var(--tw-space-y-reverse));
|
|
1000
1018
|
}
|
|
1019
|
+
.self-stretch {
|
|
1020
|
+
align-self: stretch;
|
|
1021
|
+
}
|
|
1001
1022
|
.overflow-auto {
|
|
1002
1023
|
overflow: auto;
|
|
1003
1024
|
}
|
|
1025
|
+
.overflow-hidden {
|
|
1026
|
+
overflow: hidden;
|
|
1027
|
+
}
|
|
1004
1028
|
.overflow-x-auto {
|
|
1005
1029
|
overflow-x: auto;
|
|
1006
1030
|
}
|
|
1007
1031
|
.overflow-y-auto {
|
|
1008
1032
|
overflow-y: auto;
|
|
1009
1033
|
}
|
|
1034
|
+
.overflow-y-scroll {
|
|
1035
|
+
overflow-y: scroll;
|
|
1036
|
+
}
|
|
1010
1037
|
.whitespace-nowrap {
|
|
1011
1038
|
white-space: nowrap;
|
|
1012
1039
|
}
|
|
@@ -1155,6 +1182,10 @@ video {
|
|
|
1155
1182
|
--tw-bg-opacity: 1;
|
|
1156
1183
|
background-color: rgb(var(--secondary-110) / var(--tw-bg-opacity));
|
|
1157
1184
|
}
|
|
1185
|
+
.bg-secondary-80 {
|
|
1186
|
+
--tw-bg-opacity: 1;
|
|
1187
|
+
background-color: rgb(var(--secondary-80) / var(--tw-bg-opacity));
|
|
1188
|
+
}
|
|
1158
1189
|
.bg-success {
|
|
1159
1190
|
--tw-bg-opacity: 1;
|
|
1160
1191
|
background-color: rgb(var(--success-default) / var(--tw-bg-opacity));
|
|
@@ -1245,6 +1276,10 @@ video {
|
|
|
1245
1276
|
padding-top: 0.5rem;
|
|
1246
1277
|
padding-bottom: 0.5rem;
|
|
1247
1278
|
}
|
|
1279
|
+
.py-3 {
|
|
1280
|
+
padding-top: 0.75rem;
|
|
1281
|
+
padding-bottom: 0.75rem;
|
|
1282
|
+
}
|
|
1248
1283
|
.py-4 {
|
|
1249
1284
|
padding-top: 1rem;
|
|
1250
1285
|
padding-bottom: 1rem;
|
|
@@ -1451,6 +1486,10 @@ video {
|
|
|
1451
1486
|
--tw-text-opacity: 1;
|
|
1452
1487
|
color: rgb(var(--secondary-110) / var(--tw-text-opacity));
|
|
1453
1488
|
}
|
|
1489
|
+
.text-secondary-120 {
|
|
1490
|
+
--tw-text-opacity: 1;
|
|
1491
|
+
color: rgb(var(--secondary-120) / var(--tw-text-opacity));
|
|
1492
|
+
}
|
|
1454
1493
|
.text-secondary-130 {
|
|
1455
1494
|
--tw-text-opacity: 1;
|
|
1456
1495
|
color: rgb(var(--secondary-130) / var(--tw-text-opacity));
|
|
@@ -1487,6 +1526,10 @@ video {
|
|
|
1487
1526
|
--tw-text-opacity: 1;
|
|
1488
1527
|
color: rgb(var(--text-grey-light) / var(--tw-text-opacity));
|
|
1489
1528
|
}
|
|
1529
|
+
.text-textcolor-grey-medium {
|
|
1530
|
+
--tw-text-opacity: 1;
|
|
1531
|
+
color: rgb(var(--text-grey-medium) / var(--tw-text-opacity));
|
|
1532
|
+
}
|
|
1490
1533
|
.text-warning {
|
|
1491
1534
|
--tw-text-opacity: 1;
|
|
1492
1535
|
color: rgb(var(--warning-default) / var(--tw-text-opacity));
|
|
@@ -1970,6 +2013,10 @@ video {
|
|
|
1970
2013
|
--tw-bg-opacity: 1;
|
|
1971
2014
|
background-color: rgb(var(--primary-default) / var(--tw-bg-opacity));
|
|
1972
2015
|
}
|
|
2016
|
+
.data-\[state\=selected\]\:bg-grey-20[data-state=selected] {
|
|
2017
|
+
--tw-bg-opacity: 1;
|
|
2018
|
+
background-color: rgb(var(--grey-20) / var(--tw-bg-opacity));
|
|
2019
|
+
}
|
|
1973
2020
|
.data-\[state\=checked\]\:text-primary-foreground[data-state=checked] {
|
|
1974
2021
|
--tw-text-opacity: 1;
|
|
1975
2022
|
color: rgb(var(--primary-foreground) / var(--tw-text-opacity));
|
|
@@ -2006,8 +2053,11 @@ video {
|
|
|
2006
2053
|
text-align: left;
|
|
2007
2054
|
}
|
|
2008
2055
|
}
|
|
2009
|
-
.\[\&\:has\(\[role\=checkbox\]\)\]\:
|
|
2010
|
-
|
|
2056
|
+
.\[\&\:has\(\[role\=checkbox\]\)\]\:w-4:has([role=checkbox]) {
|
|
2057
|
+
width: 1rem;
|
|
2058
|
+
}
|
|
2059
|
+
.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-4:has([role=checkbox]) {
|
|
2060
|
+
padding-right: 1rem;
|
|
2011
2061
|
}
|
|
2012
2062
|
.\[\&\>tr\]\:last\:border-b-0:last-child>tr {
|
|
2013
2063
|
border-bottom-width: 0px;
|