@lotte-innovate/ui-component-test 0.0.128 → 0.0.129
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/lib/components/Grid/Pagination.mjs +2 -0
- package/dist/lib/components/Grid/Pagination.mjs.map +1 -0
- package/dist/lib/components/Grid/index.js +2 -2
- package/dist/lib/components/Grid/index.mjs +1 -1
- package/dist/lib/components/Grid/useGrid.js +59 -32
- package/dist/lib/components/Grid/useGrid.mjs +1 -1
- package/dist/lib/tsconfig.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/lib/components/Grid/NumberingPagination.mjs +0 -2
- package/dist/lib/components/Grid/NumberingPagination.mjs.map +0 -1
@@ -0,0 +1,2 @@
|
|
1
|
+
import{jsxs as e,jsx as n}from"react/jsx-runtime";import{IconButton as t}from"../IconButton/index.mjs";import{DoubleArrowLeftIcon as a,ChevronLeftIcon as r,ChevronRightIcon as o,DoubleArrowRightIcon as i}from"@radix-ui/react-icons";import l from"../TextField/index.mjs";import c from"../Select/index.mjs";import{MAIN_COLOR as d}from"../../color/constants.mjs";function g(g){var s,u=g.table,m=null!==(s=u.options.color)&&void 0!==s?s:d;return e("div",{className:"flex items-center gap-2",children:[n(t,{className:"rounded border p-1",color:m,onClick:function(){return u.firstPage()},disabled:!u.getCanPreviousPage(),children:n(a,{})}),n(t,{className:"rounded border p-1",color:m,onClick:function(){return u.previousPage()},disabled:!u.getCanPreviousPage(),children:n(r,{})}),n(t,{className:"rounded border p-1",color:m,onClick:function(){return u.nextPage()},disabled:!u.getCanNextPage(),children:n(o,{})}),n(t,{className:"rounded border p-1",color:m,onClick:function(){return u.lastPage()},disabled:!u.getCanNextPage(),children:n(i,{})}),e("span",{className:"flex items-center gap-1",children:[n("div",{children:"Page"}),e("strong",{children:[u.getState().pagination.pageIndex+1," of ",u.getPageCount().toLocaleString()]})]}),e("span",{className:"flex items-center gap-1",children:["| Go to page:",n(l.Root,{type:"number",color:m,min:"1",max:u.getPageCount(),defaultValue:u.getState().pagination.pageIndex+1,onChange:function(e){var n=e.target.value?Number(e.target.value)-1:0;u.setPageIndex(n)},className:"w-16 rounded border p-1"})]}),e(c.Root,{color:m,value:String(u.getState().pagination.pageSize),defaultValue:String(u.getState().pagination.pageSize),onValueChange:function(e){u.setPageSize(Number(e))},children:[n(c.Trigger,{}),n(c.Content,{children:[10,20,30,40,50].map((function(e){return n(c.Item,{value:String(e),children:e},e)}))})]})]})}export{g as default};
|
2
|
+
//# sourceMappingURL=Pagination.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Pagination.mjs","sources":["../../../lib/components/Grid/Pagination.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport IconButton from '../IconButton';\nimport { ChevronLeftIcon, ChevronRightIcon, DoubleArrowLeftIcon, DoubleArrowRightIcon, } from '@radix-ui/react-icons';\nimport TextField from '../TextField';\nimport Select from '../Select';\nimport { MAIN_COLOR } from '../../../lib/color/constants';\nfunction Pagination(_a) {\n var _b;\n var table = _a.table;\n var color = (_b = table.options.color) !== null && _b !== void 0 ? _b : MAIN_COLOR;\n return (_jsxs(\"div\", { className: \"flex items-center gap-2\", children: [_jsx(IconButton, { className: \"rounded border p-1\", color: color, onClick: function () { return table.firstPage(); }, disabled: !table.getCanPreviousPage(), children: _jsx(DoubleArrowLeftIcon, {}) }), _jsx(IconButton, { className: \"rounded border p-1\", color: color, onClick: function () { return table.previousPage(); }, disabled: !table.getCanPreviousPage(), children: _jsx(ChevronLeftIcon, {}) }), _jsx(IconButton, { className: \"rounded border p-1\", color: color, onClick: function () { return table.nextPage(); }, disabled: !table.getCanNextPage(), children: _jsx(ChevronRightIcon, {}) }), _jsx(IconButton, { className: \"rounded border p-1\", color: color, onClick: function () { return table.lastPage(); }, disabled: !table.getCanNextPage(), children: _jsx(DoubleArrowRightIcon, {}) }), _jsxs(\"span\", { className: \"flex items-center gap-1\", children: [_jsx(\"div\", { children: \"Page\" }), _jsxs(\"strong\", { children: [table.getState().pagination.pageIndex + 1, \" of \", table.getPageCount().toLocaleString()] })] }), _jsxs(\"span\", { className: \"flex items-center gap-1\", children: [\"| Go to page:\", _jsx(TextField.Root, { type: \"number\", color: color, min: \"1\", max: table.getPageCount(), defaultValue: table.getState().pagination.pageIndex + 1, onChange: function (e) {\n var page = e.target.value ? Number(e.target.value) - 1 : 0;\n table.setPageIndex(page);\n }, className: \"w-16 rounded border p-1\" })] }), _jsxs(Select.Root, { color: color, value: String(table.getState().pagination.pageSize), defaultValue: String(table.getState().pagination.pageSize), onValueChange: function (e) {\n table.setPageSize(Number(e));\n }, children: [_jsx(Select.Trigger, {}), _jsx(Select.Content, { children: [10, 20, 30, 40, 50].map(function (pageSize) { return (_jsx(Select.Item, { value: String(pageSize), children: pageSize }, pageSize)); }) })] })] }));\n}\nexport default Pagination;\n"],"names":["Pagination","_a","_b","table","color","options","MAIN_COLOR","_jsxs","className","children","_jsx","IconButton","onClick","firstPage","disabled","getCanPreviousPage","DoubleArrowLeftIcon","previousPage","ChevronLeftIcon","nextPage","getCanNextPage","ChevronRightIcon","lastPage","DoubleArrowRightIcon","getState","pagination","pageIndex","getPageCount","toLocaleString","TextField","Root","type","min","max","defaultValue","onChange","e","page","target","value","Number","setPageIndex","Select","String","pageSize","onValueChange","setPageSize","Trigger","Content","map","Item"],"mappings":"wWAMA,SAASA,EAAWC,GAChB,IAAIC,EACAC,EAAQF,EAAGE,MACXC,EAAuC,QAA9BF,EAAKC,EAAME,QAAQD,aAA0B,IAAPF,EAAgBA,EAAKI,EACxE,OAAQC,EAAM,MAAO,CAAEC,UAAW,0BAA2BC,SAAU,CAACC,EAAKC,EAAY,CAAEH,UAAW,qBAAsBJ,MAAOA,EAAOQ,QAAS,WAAc,OAAOT,EAAMU,WAAc,EAAEC,UAAWX,EAAMY,qBAAsBN,SAAUC,EAAKM,EAAqB,MAAQN,EAAKC,EAAY,CAAEH,UAAW,qBAAsBJ,MAAOA,EAAOQ,QAAS,WAAc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AAIwC,KAAI,SAAUL,GAAY,OAAQlC,EAAKgC,EAAOQ,KAAM,CAAEX,MAAOI,OAAOC,GAAWnC,SAAUmC,GAAYA,EAAa,WAChO"}
|
@@ -7,7 +7,7 @@ import { ChevronDownIcon, ChevronUpIcon } from '@radix-ui/react-icons';
|
|
7
7
|
import { cn } from '../../../lib/utils/utils';
|
8
8
|
import { bgColorStyle } from '../../../lib/constants';
|
9
9
|
import { cva } from 'class-variance-authority';
|
10
|
-
import
|
10
|
+
import Pagination from './Pagination';
|
11
11
|
export var GridVariants = cva("", {
|
12
12
|
variants: {
|
13
13
|
color: bgColorStyle(),
|
@@ -54,6 +54,6 @@ function Grid(_a) {
|
|
54
54
|
.getRowModel()
|
55
55
|
.rows.map(function (row) { return (_jsx(Table.Row, { children: row.getVisibleCells().map(function (cell) { return (_jsx(Table.Cell, { style: {
|
56
56
|
width: cell.column.getSize(),
|
57
|
-
}, className: "h-[30px]", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)); }) }, row.id)); }) })] }), _jsx("div", { className: "h-2" }), ((_d = table.options) === null || _d === void 0 ? void 0 : _d.enableRowPagination) && _jsx(
|
57
|
+
}, className: "h-[30px]", children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)); }) }, row.id)); }) })] }), _jsx("div", { className: "h-2" }), ((_d = table.options) === null || _d === void 0 ? void 0 : _d.enableRowPagination) && _jsx(Pagination, { table: table })] }) }));
|
58
58
|
}
|
59
59
|
export default Grid;
|
@@ -1,3 +1,3 @@
|
|
1
1
|
"use client";
|
2
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{flexRender as t}from"@tanstack/react-table";import n from"../Table/index.mjs";import{ChevronUpIcon as i,ChevronDownIcon as r}from"@radix-ui/react-icons";import{cn as l}from"../../utils/utils.mjs";import{bgColorStyle as a}from"../../constants.mjs";import{cva as c}from"class-variance-authority";import s from"./
|
2
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{flexRender as t}from"@tanstack/react-table";import n from"../Table/index.mjs";import{ChevronUpIcon as i,ChevronDownIcon as r}from"@radix-ui/react-icons";import{cn as l}from"../../utils/utils.mjs";import{bgColorStyle as a}from"../../constants.mjs";import{cva as c}from"class-variance-authority";import s from"./Pagination.mjs";var d=c("",{variants:{color:a()},defaultVariants:{color:"red"}});function u(a){var c,u,m,p=a.table;return e("div",{style:{direction:p.options.columnResizeDirection},children:o("div",{className:"overflow-x-auto",children:[o(n.Root,{style:{},appearance:null===(c=p.options)||void 0===c?void 0:c.appearance,radius:null===(u=p.options)||void 0===u?void 0:u.radius,children:[e(n.Header,{children:p.getHeaderGroups().map((function(a){return e(n.Row,{children:a.headers.map((function(a){var c;return o(n.ColumnHeaderCell,{colSpan:a.colSpan,style:{width:a.getSize()},children:[a.isPlaceholder?null:o("div",{className:a.column.getCanSort()?"flex cursor-pointer select-none":"",onClick:a.column.getToggleSortingHandler(),title:a.column.getCanSort()?"asc"===a.column.getNextSortingOrder()?"Sort ascending":"desc"===a.column.getNextSortingOrder()?"Sort descending":"Clear sort":void 0,children:[t(a.column.columnDef.header,a.getContext()),"asc"==a.column.getIsSorted()?e(i,{}):"desc"==a.column.getIsSorted()?e(r,{}):null]}),e("div",{onDoubleClick:function(){return a.column.resetSize()},onMouseDown:a.getResizeHandler(),onTouchStart:a.getResizeHandler(),className:l("absolute top-0 h-full w-[3px] bg-slateA-3 cursor-col-resize select-none touch-none right-0 opacity-0 hover:opacity-100",p.options.columnResizeDirection,a.column.getIsResizing()?d({color:p.options.color}):""),style:{transform:a.column.getIsResizing()?"translateX(".concat(("rtl"===p.options.columnResizeDirection?-1:1)*(null!==(c=p.getState().columnSizingInfo.deltaOffset)&&void 0!==c?c:0),"px)"):""}})]},a.id)}))},a.id)}))}),e(n.Body,{children:p.getRowModel().rows.map((function(o){return e(n.Row,{children:o.getVisibleCells().map((function(o){return e(n.Cell,{style:{width:o.column.getSize()},className:"h-[30px]",children:t(o.column.columnDef.cell,o.getContext())},o.id)}))},o.id)}))})]}),e("div",{className:"h-2"}),(null===(m=p.options)||void 0===m?void 0:m.enableRowPagination)&&e(s,{table:p})]})})}export{d as GridVariants,u as default};
|
3
3
|
//# sourceMappingURL=index.mjs.map
|
@@ -21,11 +21,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
21
21
|
}
|
22
22
|
return t;
|
23
23
|
};
|
24
|
-
import { jsx as _jsx
|
24
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
25
25
|
import { createColumnHelper, getCoreRowModel, getExpandedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
|
26
|
-
import React, {
|
27
|
-
import IconButton from '../IconButton';
|
28
|
-
import { ChevronDownIcon, ChevronRightIcon } from '@radix-ui/react-icons';
|
26
|
+
import React, { useRef } from 'react';
|
29
27
|
import Checkbox from '../Checkbox';
|
30
28
|
import { useTheme } from '../../../lib/theme';
|
31
29
|
function IndeterminateCheckbox(_a) {
|
@@ -49,34 +47,63 @@ export var useGrid = function (_a) {
|
|
49
47
|
var columnsData = (_b = props === null || props === void 0 ? void 0 : props.columns) === null || _b === void 0 ? void 0 : _b.map(function (el) {
|
50
48
|
return columnHelper.accessor(el.id, __assign({}, el));
|
51
49
|
});
|
52
|
-
useEffect(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
50
|
+
// useEffect(() => {
|
51
|
+
// if (props.enableExpanding) {
|
52
|
+
// const firstcell = columnsData[0].cell;
|
53
|
+
// columnsData[0] = {
|
54
|
+
// ...columnsData[0],
|
55
|
+
// cell: (props: any) => {
|
56
|
+
// return (
|
57
|
+
// <div className="flex" style={{ paddingLeft: `${props.row.depth * 10}px` }}>
|
58
|
+
// {props.row.getCanExpand() ? (
|
59
|
+
// <IconButton
|
60
|
+
// onClick={props.row.getToggleExpandedHandler()}
|
61
|
+
// appearance="ghost"
|
62
|
+
// className={`h-3 w-3`}
|
63
|
+
// color={props.color ?? theme.themeColor}
|
64
|
+
// >
|
65
|
+
// {props.row.getIsExpanded() ? <ChevronDownIcon /> : <ChevronRightIcon />}
|
66
|
+
// </IconButton>
|
67
|
+
// ) : (
|
68
|
+
// <></>
|
69
|
+
// )}
|
70
|
+
// <div>{firstcell ? firstcell(props) : props.getValue()}</div>
|
71
|
+
// </div>
|
72
|
+
// );
|
73
|
+
// },
|
74
|
+
// };
|
75
|
+
// }
|
76
|
+
// }, [props.enableExpanding]);
|
77
|
+
// useEffect(() => {
|
78
|
+
// if (props.enableRowSelection) {
|
79
|
+
// columnsData?.unshift({
|
80
|
+
// id: 'select',
|
81
|
+
// header: ({ table }: any) => (
|
82
|
+
// <div className="header-checkbox">
|
83
|
+
// <IndeterminateCheckbox
|
84
|
+
// {...{
|
85
|
+
// checked: table.getIsAllRowsSelected() || table.getIsSomeRowsSelected(),
|
86
|
+
// indeterminate: table.getIsSomeRowsSelected(),
|
87
|
+
// onChange: table.getToggleAllRowsSelectedHandler(),
|
88
|
+
// }}
|
89
|
+
// />
|
90
|
+
// </div>
|
91
|
+
// ),
|
92
|
+
// cell: ({ row }: any) => (
|
93
|
+
// <div className="px-1" style={{ paddingLeft: `${row.depth * 10}px` }}>
|
94
|
+
// <IndeterminateCheckbox
|
95
|
+
// {...{
|
96
|
+
// checked:
|
97
|
+
// row.getIsSelected() || row.getIsSomeSelected() || row.getIsAllSubRowsSelected(),
|
98
|
+
// indeterminate: row.getIsSomeSelected() && !row.getIsAllSubRowsSelected(),
|
99
|
+
// onChange: row.getToggleSelectedHandler(),
|
100
|
+
// }}
|
101
|
+
// />
|
102
|
+
// </div>
|
103
|
+
// ),
|
104
|
+
// });
|
105
|
+
// }
|
106
|
+
// }, [props.enableRowSelection]);
|
80
107
|
var reactTableProps = __assign(__assign({ state: { sorting: sorting, rowSelection: rowSelection, expanded: expanded } }, props), { data: props.data, columns: columnsData, color: (_c = props.color) !== null && _c !== void 0 ? _c : theme.themeColor, paginateExpandedRows: true, enableExpanding: !!props.enableExpanding, getSubRows: function (row) { return row.subRows; }, onExpandedChange: setExpanded, onSortingChange: setSorting, onRowSelectionChange: setRowSelection, getSortedRowModel: getSortedRowModel(), getCoreRowModel: getCoreRowModel(), getExpandedRowModel: getExpandedRowModel() });
|
81
108
|
if (props.enableRowPagination) {
|
82
109
|
reactTableProps['getPaginationRowModel'] = getPaginationRowModel();
|
@@ -1,3 +1,3 @@
|
|
1
1
|
"use client";
|
2
|
-
import
|
2
|
+
import"react/jsx-runtime";import{createColumnHelper as e,getSortedRowModel as t,getCoreRowModel as o,getExpandedRowModel as n,getPaginationRowModel as r,useReactTable as a}from"@tanstack/react-table";import i from"react";import"../Checkbox/index.mjs";import{useTheme as l}from"../../theme/ThemeProvider.mjs";var c=function(){return c=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},c.apply(this,arguments)},p=function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o},d=function(d){var u,s,m=p(d,[]),g=l().theme,f=i.useState([]),b=f[0],w=f[1],h=i.useState({}),v=h[0],x=h[1],y=i.useState({}),O=y[0],S=y[1],j=e(),R=null===(u=null==m?void 0:m.columns)||void 0===u?void 0:u.map((function(e){return j.accessor(e.id,c({},e))})),P=c(c({state:{sorting:b,rowSelection:O,expanded:v}},m),{data:m.data,columns:R,color:null!==(s=m.color)&&void 0!==s?s:g.themeColor,paginateExpandedRows:!0,enableExpanding:!!m.enableExpanding,getSubRows:function(e){return e.subRows},onExpandedChange:x,onSortingChange:w,onRowSelectionChange:S,getSortedRowModel:t(),getCoreRowModel:o(),getExpandedRowModel:n()});return m.enableRowPagination&&(P.getPaginationRowModel=r()),a(P)};export{d as useGrid};
|
3
3
|
//# sourceMappingURL=useGrid.mjs.map
|