karsten-design-system 1.0.63 → 1.0.64

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/index.js CHANGED
@@ -32,4 +32,5 @@ export { ExpandablePanel } from './stories/components/expandablePanel.js';
32
32
  export { EmptyContent } from './stories/components/emptyContent.js';
33
33
  export { Select } from './stories/components/select.js';
34
34
  export { CalendarInput } from './stories/components/calendarInput.js';
35
+ export { CustomTable } from './stories/components/customTable.js';
35
36
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,27 @@
1
+ import { j as jsxRuntimeExports } from '../../_virtual/jsx-runtime.js';
2
+ import { useState, useEffect } from 'react';
3
+ import clsx from 'clsx';
4
+ import { sortData } from '../../utils/sortData.js';
5
+ import { Paginator } from './paginator.js';
6
+ import { Spinner } from './spinner.js';
7
+
8
+ function CustomTable({ columns, data, totalRecords, actions = [], isOrdered = true, actionsHeaderClassName = '', actionsColumnsClassName = '', rowsPerPage = 10, onPageChange, isPaginated = true, isLoading = false }) {
9
+ const [sortDirection, setSortDirection] = useState('ASC');
10
+ const [sortedData, setSortedData] = useState(data);
11
+ const [currentPage, setCurrentPage] = useState(1);
12
+ const handleSort = (dataIndex) => {
13
+ const newDirection = sortDirection === 'ASC' ? 'DESC' : 'ASC';
14
+ setSortDirection(newDirection);
15
+ setSortedData(sortData(sortedData, dataIndex, newDirection));
16
+ };
17
+ useEffect(() => {
18
+ setSortedData(data);
19
+ }, [data]);
20
+ return (jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsxs("table", { className: "w-100", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsxs("tr", { className: "bg-gray-100", children: [columns.map((column, idx) => (jsxRuntimeExports.jsxs("th", { className: "bg-primary first:rounded-ss-lg font-bold text-background text-sm uppercase p-3 text-left", onClick: isOrdered ? () => handleSort(column.dataIndex) : undefined, children: [column.label, isOrdered && (jsxRuntimeExports.jsx("i", { className: "pi pi-sort-alt pl-2 text-xs cursor-pointer", onClick: () => handleSort(column.dataIndex) }))] }, idx))), actions.length > 0 && (jsxRuntimeExports.jsx("th", { className: clsx('bg-primary rounded-se-lg font-bold text-background text-sm uppercase p-3 text-right pr-4', actionsHeaderClassName), children: "A\u00C7\u00D5ES" }))] }) }), jsxRuntimeExports.jsx("tbody", { children: isLoading ? (jsxRuntimeExports.jsx("tr", { children: jsxRuntimeExports.jsx("td", { colSpan: columns.length + (actions.length > 0 ? 1 : 0), className: "p-6 text-center bg-gray-50", children: jsxRuntimeExports.jsx("div", { className: "py-2 px-4 flex justify-center items-center gap-2", children: jsxRuntimeExports.jsx(Spinner, { size: "lg" }) }) }) })) : sortedData.length > 0 ? (sortedData.map((item, index) => (jsxRuntimeExports.jsxs("tr", { className: clsx(index % 2 === 0 ? 'bg-stoneBackground' : 'bg-background', 'text-primary text-base'), children: [columns.map((column) => (jsxRuntimeExports.jsx("td", { className: clsx('p-3 text-sm text-left', typeof column.style === 'function' ? column.style(item[column.dataIndex]) : column.style), children: item[column.dataIndex] }, `${column.dataIndex}-${index}`))), actions.length > 0 && (jsxRuntimeExports.jsx("td", { className: clsx('text-sm text-right flex flex-row justify-end p-3 gap-2', actionsColumnsClassName), children: actions.map((action, idx) => (jsxRuntimeExports.jsx("span", { className: "cursor-pointer", onClick: () => action.onClick(item), title: action.label, children: action.icon }, idx))) }))] }, index)))) : (jsxRuntimeExports.jsx("tr", { children: jsxRuntimeExports.jsxs("td", { colSpan: columns.length + (actions.length > 0 ? 1 : 0), className: "p-6 text-center text-primary bg-stoneBackground", children: [jsxRuntimeExports.jsx("i", { className: "pi pi-database mr-2" }), " N\u00E3o h\u00E1 dados dispon\u00EDveis."] }) })) })] }), sortedData.length > 0 && isPaginated && (jsxRuntimeExports.jsx(Paginator, { first: (currentPage - 1) * rowsPerPage, rows: rowsPerPage, totalRecords: totalRecords, onPageChange: (event) => {
21
+ setCurrentPage(event.page + 1);
22
+ onPageChange(event.page + 1);
23
+ } }))] }));
24
+ }
25
+
26
+ export { CustomTable };
27
+ //# sourceMappingURL=customTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customTable.js","sources":["../../../../src/stories/components/customTable.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;;;SAkCgB,WAAW,CAAC,EAC1B,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,OAAO,GAAG,EAAE,EACZ,SAAS,GAAG,IAAI,EAChB,sBAAsB,GAAG,EAAE,EAC3B,uBAAuB,GAAG,EAAE,EAC5B,WAAW,GAAG,EAAE,EAChB,YAAY,EACZ,WAAW,GAAG,IAAI,EAClB,SAAS,GAAG,KAAK,EACA,EAAA;IACjB,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAgB,KAAK,CAAC;IACxE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;IAClD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;AAEjD,IAAA,MAAM,UAAU,GAAG,CAAC,SAAiB,KAAI;AACvC,QAAA,MAAM,YAAY,GAAG,aAAa,KAAK,KAAK,GAAG,MAAM,GAAG,KAAK;QAC7D,gBAAgB,CAAC,YAAY,CAAC;QAC9B,aAAa,CAAC,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AAC9D,KAAC;IAED,SAAS,CAAC,MAAK;QACb,aAAa,CAAC,IAAI,CAAC;AACrB,KAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IAEV,QACEA,2CACEA,sB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,EAAA,EAAA,SAAS,EAAC,qBAAqB,EAAA,CAAK,EACpC,2CAAA,CAAA,EAAA,CAAA,EAAA,CACF,CACN,EAAA,CACK,IACF,EAEP,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,WAAW,KACnCA,qBAAC,CAAA,SAAS,IACR,KAAK,EAAE,CAAC,WAAW,GAAG,CAAC,IAAI,WAAW,EACtC,IAAI,EAAE,WAAW,EACjB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,CAAC,KAAK,KAAI;AACtB,oBAAA,cAAc,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;AAC9B,oBAAA,YAAY,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;AAC9B,iBAAC,EACD,CAAA,CACH,CACG,EAAA,CAAA;AAEV;;;;"}
@@ -32,3 +32,4 @@ export * from './stories/components/expandablePanel';
32
32
  export * from './stories/components/emptyContent';
33
33
  export * from './stories/components/select';
34
34
  export * from './stories/components/calendarInput';
35
+ export * from './stories/components/customTable';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "karsten-design-system",
3
3
  "description": "Karsten Design System Components",
4
- "version": "1.0.63",
4
+ "version": "1.0.64",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",