@facter/ds-core 1.7.7 → 1.8.1

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.mjs CHANGED
@@ -191,6 +191,7 @@ var Input = React10.forwardRef(
191
191
  variant: error ? "error" : variant,
192
192
  inputSize
193
193
  }),
194
+ !label && "h-9 pt-0 pb-0 py-2",
194
195
  Icon2 && "pl-10",
195
196
  type === "password" && "pr-11",
196
197
  className
@@ -583,6 +584,7 @@ var Select = React10.forwardRef(
583
584
  variant: error ? "error" : variant,
584
585
  selectSize
585
586
  }),
587
+ !label && "h-9 pt-0 pb-0 py-2",
586
588
  Icon2 && "pl-10",
587
589
  "flex items-center justify-between",
588
590
  className
@@ -1120,7 +1122,6 @@ function useDataTableInternal({
1120
1122
  pageIndex: 0,
1121
1123
  pageSize: 10
1122
1124
  });
1123
- console.log("[useDataTableInternal] pagination state", pagination);
1124
1125
  const table = useReactTable({
1125
1126
  data,
1126
1127
  columns,
@@ -1174,6 +1175,7 @@ function useDataTableInternal({
1174
1175
  pageSize: pagination.pageSize
1175
1176
  };
1176
1177
  }
1178
+ var DataTableLoadingContext = React10.createContext(null);
1177
1179
  var DataTableEmptyStateConfigContext = React10.createContext(null);
1178
1180
  var DataTableInstanceContext = React10.createContext(null);
1179
1181
  DataTableInstanceContext.displayName = "DataTableInstanceContext";
@@ -1192,6 +1194,12 @@ function DataTableProvider({
1192
1194
  pageIndex,
1193
1195
  pageSize
1194
1196
  }) {
1197
+ const [isLoading, setIsLoading] = React10.useState(false);
1198
+ const [skeletonRows, setSkeletonRows] = React10.useState(5);
1199
+ const loadingValue = React10.useMemo(
1200
+ () => ({ isLoading, setIsLoading, skeletonRows, setSkeletonRows }),
1201
+ [isLoading, skeletonRows]
1202
+ );
1195
1203
  const [emptyStateConfig, setEmptyStateConfig] = React10.useState({});
1196
1204
  const emptyStateValue = React10.useMemo(
1197
1205
  () => ({ config: emptyStateConfig, setConfig: setEmptyStateConfig }),
@@ -1210,7 +1218,7 @@ function DataTableProvider({
1210
1218
  [pageIndex, pageSize]
1211
1219
  );
1212
1220
  const tableValue = table;
1213
- return /* @__PURE__ */ jsx(DataTableEmptyStateConfigContext.Provider, { value: emptyStateValue, children: /* @__PURE__ */ jsx(DataTableInstanceContext.Provider, { value: tableValue, children: /* @__PURE__ */ jsx(DataTableMetaContext.Provider, { value: metaValue, children: /* @__PURE__ */ jsx(DataTableDensityContext.Provider, { value: densityValue, children: /* @__PURE__ */ jsx(DataTablePaginationContext.Provider, { value: paginationValue, children }) }) }) }) });
1221
+ return /* @__PURE__ */ jsx(DataTableLoadingContext.Provider, { value: loadingValue, children: /* @__PURE__ */ jsx(DataTableEmptyStateConfigContext.Provider, { value: emptyStateValue, children: /* @__PURE__ */ jsx(DataTableInstanceContext.Provider, { value: tableValue, children: /* @__PURE__ */ jsx(DataTableMetaContext.Provider, { value: metaValue, children: /* @__PURE__ */ jsx(DataTableDensityContext.Provider, { value: densityValue, children: /* @__PURE__ */ jsx(DataTablePaginationContext.Provider, { value: paginationValue, children }) }) }) }) }) });
1214
1222
  }
1215
1223
  function useDataTable() {
1216
1224
  const context = React10.useContext(DataTableInstanceContext);
@@ -1308,6 +1316,15 @@ function useDataTableColumnVisibility() {
1308
1316
  getAllColumns: () => table.getAllColumns().filter((col) => col.getCanHide())
1309
1317
  }), [table, columnVisibility]);
1310
1318
  }
1319
+ function useDataTableLoadingState() {
1320
+ const context = React10.useContext(DataTableLoadingContext);
1321
+ if (!context) {
1322
+ throw new Error(
1323
+ "useDataTableLoadingState must be used within <DataTable>."
1324
+ );
1325
+ }
1326
+ return context;
1327
+ }
1311
1328
  function useDataTableEmptyStateConfig() {
1312
1329
  const context = React10.useContext(DataTableEmptyStateConfigContext);
1313
1330
  if (!context) {
@@ -1457,16 +1474,19 @@ var DataTableContent = React10.memo(function DataTableContent2({
1457
1474
  stickyHeader = false,
1458
1475
  stripedRows = false,
1459
1476
  highlightOnHover = true,
1477
+ onRowClick,
1460
1478
  className
1461
1479
  }) {
1462
1480
  const table = useDataTable();
1463
1481
  const { isEmpty } = useDataTableMeta();
1464
1482
  const { density } = useDataTableDensity();
1465
1483
  const { config: emptyStateConfig } = useDataTableEmptyStateConfig();
1484
+ const { isLoading, skeletonRows } = useDataTableLoadingState();
1466
1485
  const densityStyles = DENSITY_CONFIG[density];
1467
1486
  const cellClasses = cn(densityStyles.padding, densityStyles.fontSize);
1487
+ const columnCount = table.getVisibleLeafColumns().length;
1468
1488
  const hasRows = table.getRowModel().rows?.length > 0;
1469
- if (!hasRows && isEmpty) {
1489
+ if (!hasRows && isEmpty && !isLoading) {
1470
1490
  return /* @__PURE__ */ jsx(
1471
1491
  EmptyState,
1472
1492
  {
@@ -1490,14 +1510,16 @@ var DataTableContent = React10.memo(function DataTableContent2({
1490
1510
  },
1491
1511
  header.id
1492
1512
  )) }, headerGroup.id)) }),
1493
- /* @__PURE__ */ jsx(TableBody, { children: table.getRowModel().rows.map((row, index) => /* @__PURE__ */ jsx(
1513
+ /* @__PURE__ */ jsx(TableBody, { children: isLoading ? Array.from({ length: skeletonRows }).map((_, index) => /* @__PURE__ */ jsx(TableRow, { className: "animate-pulse", children: Array.from({ length: columnCount || 4 }).map((_2, colIndex) => /* @__PURE__ */ jsx(TableCell, { className: cellClasses, children: /* @__PURE__ */ jsx("div", { className: "h-4 bg-muted rounded w-3/4" }) }, colIndex)) }, `skeleton-${index}`)) : table.getRowModel().rows.map((row, index) => /* @__PURE__ */ jsx(
1494
1514
  TableRow,
1495
1515
  {
1496
1516
  "data-state": row.getIsSelected() && "selected",
1497
1517
  className: cn(
1498
1518
  highlightOnHover && "hover:bg-muted/50",
1499
- stripedRows && index % 2 === 1 && "bg-muted/30"
1519
+ stripedRows && index % 2 === 1 && "bg-muted/30",
1520
+ onRowClick && "cursor-pointer"
1500
1521
  ),
1522
+ onClick: onRowClick ? () => onRowClick(row) : void 0,
1501
1523
  children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(TableCell, { className: cellClasses, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
1502
1524
  },
1503
1525
  row.id
@@ -1509,7 +1531,7 @@ var DataTableToolbar = React10.memo(function DataTableToolbar2({
1509
1531
  className,
1510
1532
  children
1511
1533
  }) {
1512
- return /* @__PURE__ */ jsx("div", { className: cn("flex items-center justify-between gap-2", className), children });
1534
+ return /* @__PURE__ */ jsx("div", { className: cn("flex items-center justify-between gap-2 bg-accent/50 p-4 rounded-t-lg", className), children });
1513
1535
  });
1514
1536
  function useDebounce(value, delay = 300) {
1515
1537
  const [debouncedValue, setDebouncedValue] = React10.useState(value);
@@ -1773,24 +1795,19 @@ var DataTableEmptyState = React10.memo(function DataTableEmptyState2({
1773
1795
  return null;
1774
1796
  });
1775
1797
  DataTableEmptyState.displayName = "DataTable.EmptyState";
1776
- function SkeletonRow({ columns }) {
1777
- return /* @__PURE__ */ jsx(TableRow, { className: "animate-pulse", children: Array.from({ length: columns }).map((_, index) => /* @__PURE__ */ jsx(TableCell, { className: "py-4", children: /* @__PURE__ */ jsx("div", { className: "h-4 bg-muted rounded w-3/4" }) }, index)) });
1778
- }
1779
1798
  function DataTableLoading({
1780
1799
  visible,
1781
- skeleton,
1782
- skeletonRows = 5,
1783
- className
1800
+ skeletonRows = 5
1784
1801
  }) {
1785
- const table = useDataTable();
1786
- const columnCount = table.getVisibleLeafColumns().length;
1787
- if (!visible) {
1788
- return null;
1789
- }
1790
- if (skeleton) {
1791
- return /* @__PURE__ */ jsx("div", { className: cn("w-full", className), children: skeleton });
1792
- }
1793
- return /* @__PURE__ */ jsx("div", { className: cn("w-full", className), children: /* @__PURE__ */ jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsx("table", { className: "w-full", children: /* @__PURE__ */ jsx("tbody", { children: Array.from({ length: skeletonRows }).map((_, index) => /* @__PURE__ */ jsx(SkeletonRow, { columns: columnCount || 4 }, index)) }) }) }) });
1802
+ const { setIsLoading, setSkeletonRows } = useDataTableLoadingState();
1803
+ React10.useLayoutEffect(() => {
1804
+ setIsLoading(visible);
1805
+ return () => setIsLoading(false);
1806
+ }, [visible, setIsLoading]);
1807
+ React10.useLayoutEffect(() => {
1808
+ setSkeletonRows(skeletonRows);
1809
+ }, [skeletonRows, setSkeletonRows]);
1810
+ return null;
1794
1811
  }
1795
1812
  DataTableLoading.displayName = "DataTable.Loading";
1796
1813
  function DataTableColumnHeader({
@@ -1836,6 +1853,7 @@ var checkboxVariants = cva(
1836
1853
  variants: {
1837
1854
  variant: {
1838
1855
  default: "border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
1856
+ muted: "border-muted-foreground/40 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
1839
1857
  secondary: "border-secondary data-[state=checked]:bg-secondary data-[state=checked]:text-secondary-foreground",
1840
1858
  outline: "border-border data-[state=checked]:bg-background data-[state=checked]:text-primary data-[state=checked]:border-primary"
1841
1859
  },
@@ -2270,7 +2288,7 @@ function DataTableTabs({
2270
2288
  return /* @__PURE__ */ jsx(
2271
2289
  "div",
2272
2290
  {
2273
- className: cn("flex items-center gap-1 border-b", className),
2291
+ className: cn("flex items-center gap-1", className),
2274
2292
  role: "tablist",
2275
2293
  "aria-label": "Filtros",
2276
2294
  children: tabs.map((tab) => {