@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.d.mts +8 -10
- package/dist/index.d.ts +8 -10
- package/dist/index.js +40 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -352,6 +352,8 @@ interface DataTableSearchProps {
|
|
|
352
352
|
column?: string;
|
|
353
353
|
/** Debounce delay em ms */
|
|
354
354
|
debounce?: number;
|
|
355
|
+
/** Callback para server-side search (recebe valor com debounce aplicado) */
|
|
356
|
+
onSearch?: (value: string) => void;
|
|
355
357
|
/** Custom className */
|
|
356
358
|
className?: string;
|
|
357
359
|
}
|
|
@@ -385,6 +387,8 @@ interface DataTableContentProps {
|
|
|
385
387
|
stripedRows?: boolean;
|
|
386
388
|
/** Highlight no hover */
|
|
387
389
|
highlightOnHover?: boolean;
|
|
390
|
+
/** Callback quando uma row é clicada */
|
|
391
|
+
onRowClick?: (row: unknown) => void;
|
|
388
392
|
/** Custom className */
|
|
389
393
|
className?: string;
|
|
390
394
|
}
|
|
@@ -530,13 +534,7 @@ declare namespace DataTableRoot {
|
|
|
530
534
|
var displayName: string;
|
|
531
535
|
}
|
|
532
536
|
|
|
533
|
-
|
|
534
|
-
* DataTable.Loading - Componente de loading state
|
|
535
|
-
*
|
|
536
|
-
* Renderiza um skeleton ou overlay quando visible=true.
|
|
537
|
-
* Não renderiza nada quando visible=false.
|
|
538
|
-
*/
|
|
539
|
-
declare function DataTableLoading({ visible, skeleton, skeletonRows, className, }: DataTableLoadingProps): react_jsx_runtime.JSX.Element | null;
|
|
537
|
+
declare function DataTableLoading({ visible, skeletonRows, }: DataTableLoadingProps): null;
|
|
540
538
|
declare namespace DataTableLoading {
|
|
541
539
|
var displayName: string;
|
|
542
540
|
}
|
|
@@ -801,7 +799,7 @@ declare const toast: ((message: string) => string | number) & {
|
|
|
801
799
|
};
|
|
802
800
|
|
|
803
801
|
declare const checkboxVariants: (props?: ({
|
|
804
|
-
variant?: "default" | "outline" | "secondary" | null | undefined;
|
|
802
|
+
variant?: "default" | "outline" | "secondary" | "muted" | null | undefined;
|
|
805
803
|
size?: "sm" | "lg" | "md" | null | undefined;
|
|
806
804
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
807
805
|
interface CheckboxProps extends React$1.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, VariantProps<typeof checkboxVariants> {
|
|
@@ -2010,7 +2008,7 @@ interface ItemCardHeaderProps extends React$1.HTMLAttributes<HTMLDivElement> {
|
|
|
2010
2008
|
declare const ItemCardHeader: React$1.ForwardRefExoticComponent<ItemCardHeaderProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
2011
2009
|
declare const itemCardIconVariants: (props?: ({
|
|
2012
2010
|
size?: "sm" | "lg" | "md" | null | undefined;
|
|
2013
|
-
variant?: "destructive" | "outline" | "secondary" | "success" | "warning" | "info" | "
|
|
2011
|
+
variant?: "destructive" | "outline" | "secondary" | "success" | "warning" | "info" | "muted" | "primary" | null | undefined;
|
|
2014
2012
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
2015
2013
|
interface ItemCardIconProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof itemCardIconVariants> {
|
|
2016
2014
|
/** Whether to show ripple effect */
|
|
@@ -2030,7 +2028,7 @@ interface ItemCardSubtitleProps extends React$1.HTMLAttributes<HTMLParagraphElem
|
|
|
2030
2028
|
declare const ItemCardSubtitle: React$1.ForwardRefExoticComponent<ItemCardSubtitleProps & React$1.RefAttributes<HTMLParagraphElement>>;
|
|
2031
2029
|
|
|
2032
2030
|
declare const itemCardBadgeVariants: (props?: ({
|
|
2033
|
-
variant?: "default" | "destructive" | "success" | "warning" | "info" | "
|
|
2031
|
+
variant?: "default" | "destructive" | "success" | "warning" | "info" | "muted" | "primary" | null | undefined;
|
|
2034
2032
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
2035
2033
|
interface ItemCardBadgeProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof itemCardBadgeVariants> {
|
|
2036
2034
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -352,6 +352,8 @@ interface DataTableSearchProps {
|
|
|
352
352
|
column?: string;
|
|
353
353
|
/** Debounce delay em ms */
|
|
354
354
|
debounce?: number;
|
|
355
|
+
/** Callback para server-side search (recebe valor com debounce aplicado) */
|
|
356
|
+
onSearch?: (value: string) => void;
|
|
355
357
|
/** Custom className */
|
|
356
358
|
className?: string;
|
|
357
359
|
}
|
|
@@ -385,6 +387,8 @@ interface DataTableContentProps {
|
|
|
385
387
|
stripedRows?: boolean;
|
|
386
388
|
/** Highlight no hover */
|
|
387
389
|
highlightOnHover?: boolean;
|
|
390
|
+
/** Callback quando uma row é clicada */
|
|
391
|
+
onRowClick?: (row: unknown) => void;
|
|
388
392
|
/** Custom className */
|
|
389
393
|
className?: string;
|
|
390
394
|
}
|
|
@@ -530,13 +534,7 @@ declare namespace DataTableRoot {
|
|
|
530
534
|
var displayName: string;
|
|
531
535
|
}
|
|
532
536
|
|
|
533
|
-
|
|
534
|
-
* DataTable.Loading - Componente de loading state
|
|
535
|
-
*
|
|
536
|
-
* Renderiza um skeleton ou overlay quando visible=true.
|
|
537
|
-
* Não renderiza nada quando visible=false.
|
|
538
|
-
*/
|
|
539
|
-
declare function DataTableLoading({ visible, skeleton, skeletonRows, className, }: DataTableLoadingProps): react_jsx_runtime.JSX.Element | null;
|
|
537
|
+
declare function DataTableLoading({ visible, skeletonRows, }: DataTableLoadingProps): null;
|
|
540
538
|
declare namespace DataTableLoading {
|
|
541
539
|
var displayName: string;
|
|
542
540
|
}
|
|
@@ -801,7 +799,7 @@ declare const toast: ((message: string) => string | number) & {
|
|
|
801
799
|
};
|
|
802
800
|
|
|
803
801
|
declare const checkboxVariants: (props?: ({
|
|
804
|
-
variant?: "default" | "outline" | "secondary" | null | undefined;
|
|
802
|
+
variant?: "default" | "outline" | "secondary" | "muted" | null | undefined;
|
|
805
803
|
size?: "sm" | "lg" | "md" | null | undefined;
|
|
806
804
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
807
805
|
interface CheckboxProps extends React$1.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, VariantProps<typeof checkboxVariants> {
|
|
@@ -2010,7 +2008,7 @@ interface ItemCardHeaderProps extends React$1.HTMLAttributes<HTMLDivElement> {
|
|
|
2010
2008
|
declare const ItemCardHeader: React$1.ForwardRefExoticComponent<ItemCardHeaderProps & React$1.RefAttributes<HTMLDivElement>>;
|
|
2011
2009
|
declare const itemCardIconVariants: (props?: ({
|
|
2012
2010
|
size?: "sm" | "lg" | "md" | null | undefined;
|
|
2013
|
-
variant?: "destructive" | "outline" | "secondary" | "success" | "warning" | "info" | "
|
|
2011
|
+
variant?: "destructive" | "outline" | "secondary" | "success" | "warning" | "info" | "muted" | "primary" | null | undefined;
|
|
2014
2012
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
2015
2013
|
interface ItemCardIconProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof itemCardIconVariants> {
|
|
2016
2014
|
/** Whether to show ripple effect */
|
|
@@ -2030,7 +2028,7 @@ interface ItemCardSubtitleProps extends React$1.HTMLAttributes<HTMLParagraphElem
|
|
|
2030
2028
|
declare const ItemCardSubtitle: React$1.ForwardRefExoticComponent<ItemCardSubtitleProps & React$1.RefAttributes<HTMLParagraphElement>>;
|
|
2031
2029
|
|
|
2032
2030
|
declare const itemCardBadgeVariants: (props?: ({
|
|
2033
|
-
variant?: "default" | "destructive" | "success" | "warning" | "info" | "
|
|
2031
|
+
variant?: "default" | "destructive" | "success" | "warning" | "info" | "muted" | "primary" | null | undefined;
|
|
2034
2032
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
2035
2033
|
interface ItemCardBadgeProps extends React$1.HTMLAttributes<HTMLDivElement>, VariantProps<typeof itemCardBadgeVariants> {
|
|
2036
2034
|
}
|
package/dist/index.js
CHANGED
|
@@ -222,6 +222,7 @@ var Input = React10__namespace.forwardRef(
|
|
|
222
222
|
variant: error ? "error" : variant,
|
|
223
223
|
inputSize
|
|
224
224
|
}),
|
|
225
|
+
!label && "h-9 pt-0 pb-0 py-2",
|
|
225
226
|
Icon2 && "pl-10",
|
|
226
227
|
type === "password" && "pr-11",
|
|
227
228
|
className
|
|
@@ -614,6 +615,7 @@ var Select = React10__namespace.forwardRef(
|
|
|
614
615
|
variant: error ? "error" : variant,
|
|
615
616
|
selectSize
|
|
616
617
|
}),
|
|
618
|
+
!label && "h-9 pt-0 pb-0 py-2",
|
|
617
619
|
Icon2 && "pl-10",
|
|
618
620
|
"flex items-center justify-between",
|
|
619
621
|
className
|
|
@@ -1151,7 +1153,6 @@ function useDataTableInternal({
|
|
|
1151
1153
|
pageIndex: 0,
|
|
1152
1154
|
pageSize: 10
|
|
1153
1155
|
});
|
|
1154
|
-
console.log("[useDataTableInternal] pagination state", pagination);
|
|
1155
1156
|
const table = reactTable.useReactTable({
|
|
1156
1157
|
data,
|
|
1157
1158
|
columns,
|
|
@@ -1205,6 +1206,7 @@ function useDataTableInternal({
|
|
|
1205
1206
|
pageSize: pagination.pageSize
|
|
1206
1207
|
};
|
|
1207
1208
|
}
|
|
1209
|
+
var DataTableLoadingContext = React10__namespace.createContext(null);
|
|
1208
1210
|
var DataTableEmptyStateConfigContext = React10__namespace.createContext(null);
|
|
1209
1211
|
var DataTableInstanceContext = React10__namespace.createContext(null);
|
|
1210
1212
|
DataTableInstanceContext.displayName = "DataTableInstanceContext";
|
|
@@ -1223,6 +1225,12 @@ function DataTableProvider({
|
|
|
1223
1225
|
pageIndex,
|
|
1224
1226
|
pageSize
|
|
1225
1227
|
}) {
|
|
1228
|
+
const [isLoading, setIsLoading] = React10__namespace.useState(false);
|
|
1229
|
+
const [skeletonRows, setSkeletonRows] = React10__namespace.useState(5);
|
|
1230
|
+
const loadingValue = React10__namespace.useMemo(
|
|
1231
|
+
() => ({ isLoading, setIsLoading, skeletonRows, setSkeletonRows }),
|
|
1232
|
+
[isLoading, skeletonRows]
|
|
1233
|
+
);
|
|
1226
1234
|
const [emptyStateConfig, setEmptyStateConfig] = React10__namespace.useState({});
|
|
1227
1235
|
const emptyStateValue = React10__namespace.useMemo(
|
|
1228
1236
|
() => ({ config: emptyStateConfig, setConfig: setEmptyStateConfig }),
|
|
@@ -1241,7 +1249,7 @@ function DataTableProvider({
|
|
|
1241
1249
|
[pageIndex, pageSize]
|
|
1242
1250
|
);
|
|
1243
1251
|
const tableValue = table;
|
|
1244
|
-
return /* @__PURE__ */ jsxRuntime.jsx(DataTableEmptyStateConfigContext.Provider, { value: emptyStateValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableInstanceContext.Provider, { value: tableValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableMetaContext.Provider, { value: metaValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableDensityContext.Provider, { value: densityValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTablePaginationContext.Provider, { value: paginationValue, children }) }) }) }) });
|
|
1252
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DataTableLoadingContext.Provider, { value: loadingValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableEmptyStateConfigContext.Provider, { value: emptyStateValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableInstanceContext.Provider, { value: tableValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableMetaContext.Provider, { value: metaValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTableDensityContext.Provider, { value: densityValue, children: /* @__PURE__ */ jsxRuntime.jsx(DataTablePaginationContext.Provider, { value: paginationValue, children }) }) }) }) }) });
|
|
1245
1253
|
}
|
|
1246
1254
|
function useDataTable() {
|
|
1247
1255
|
const context = React10__namespace.useContext(DataTableInstanceContext);
|
|
@@ -1339,6 +1347,15 @@ function useDataTableColumnVisibility() {
|
|
|
1339
1347
|
getAllColumns: () => table.getAllColumns().filter((col) => col.getCanHide())
|
|
1340
1348
|
}), [table, columnVisibility]);
|
|
1341
1349
|
}
|
|
1350
|
+
function useDataTableLoadingState() {
|
|
1351
|
+
const context = React10__namespace.useContext(DataTableLoadingContext);
|
|
1352
|
+
if (!context) {
|
|
1353
|
+
throw new Error(
|
|
1354
|
+
"useDataTableLoadingState must be used within <DataTable>."
|
|
1355
|
+
);
|
|
1356
|
+
}
|
|
1357
|
+
return context;
|
|
1358
|
+
}
|
|
1342
1359
|
function useDataTableEmptyStateConfig() {
|
|
1343
1360
|
const context = React10__namespace.useContext(DataTableEmptyStateConfigContext);
|
|
1344
1361
|
if (!context) {
|
|
@@ -1488,16 +1505,19 @@ var DataTableContent = React10__namespace.memo(function DataTableContent2({
|
|
|
1488
1505
|
stickyHeader = false,
|
|
1489
1506
|
stripedRows = false,
|
|
1490
1507
|
highlightOnHover = true,
|
|
1508
|
+
onRowClick,
|
|
1491
1509
|
className
|
|
1492
1510
|
}) {
|
|
1493
1511
|
const table = useDataTable();
|
|
1494
1512
|
const { isEmpty } = useDataTableMeta();
|
|
1495
1513
|
const { density } = useDataTableDensity();
|
|
1496
1514
|
const { config: emptyStateConfig } = useDataTableEmptyStateConfig();
|
|
1515
|
+
const { isLoading, skeletonRows } = useDataTableLoadingState();
|
|
1497
1516
|
const densityStyles = DENSITY_CONFIG[density];
|
|
1498
1517
|
const cellClasses = cn(densityStyles.padding, densityStyles.fontSize);
|
|
1518
|
+
const columnCount = table.getVisibleLeafColumns().length;
|
|
1499
1519
|
const hasRows = table.getRowModel().rows?.length > 0;
|
|
1500
|
-
if (!hasRows && isEmpty) {
|
|
1520
|
+
if (!hasRows && isEmpty && !isLoading) {
|
|
1501
1521
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1502
1522
|
EmptyState,
|
|
1503
1523
|
{
|
|
@@ -1521,14 +1541,16 @@ var DataTableContent = React10__namespace.memo(function DataTableContent2({
|
|
|
1521
1541
|
},
|
|
1522
1542
|
header.id
|
|
1523
1543
|
)) }, headerGroup.id)) }),
|
|
1524
|
-
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: table.getRowModel().rows.map((row, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1544
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: isLoading ? Array.from({ length: skeletonRows }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(TableRow, { className: "animate-pulse", children: Array.from({ length: columnCount || 4 }).map((_2, colIndex) => /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: cellClasses, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 bg-muted rounded w-3/4" }) }, colIndex)) }, `skeleton-${index}`)) : table.getRowModel().rows.map((row, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1525
1545
|
TableRow,
|
|
1526
1546
|
{
|
|
1527
1547
|
"data-state": row.getIsSelected() && "selected",
|
|
1528
1548
|
className: cn(
|
|
1529
1549
|
highlightOnHover && "hover:bg-muted/50",
|
|
1530
|
-
stripedRows && index % 2 === 1 && "bg-muted/30"
|
|
1550
|
+
stripedRows && index % 2 === 1 && "bg-muted/30",
|
|
1551
|
+
onRowClick && "cursor-pointer"
|
|
1531
1552
|
),
|
|
1553
|
+
onClick: onRowClick ? () => onRowClick(row) : void 0,
|
|
1532
1554
|
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: cellClasses, children: reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
|
|
1533
1555
|
},
|
|
1534
1556
|
row.id
|
|
@@ -1540,7 +1562,7 @@ var DataTableToolbar = React10__namespace.memo(function DataTableToolbar2({
|
|
|
1540
1562
|
className,
|
|
1541
1563
|
children
|
|
1542
1564
|
}) {
|
|
1543
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex items-center justify-between gap-2", className), children });
|
|
1565
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("flex items-center justify-between gap-2 bg-accent/50 p-4 rounded-t-lg", className), children });
|
|
1544
1566
|
});
|
|
1545
1567
|
function useDebounce(value, delay = 300) {
|
|
1546
1568
|
const [debouncedValue, setDebouncedValue] = React10__namespace.useState(value);
|
|
@@ -1804,24 +1826,19 @@ var DataTableEmptyState = React10__namespace.memo(function DataTableEmptyState2(
|
|
|
1804
1826
|
return null;
|
|
1805
1827
|
});
|
|
1806
1828
|
DataTableEmptyState.displayName = "DataTable.EmptyState";
|
|
1807
|
-
function SkeletonRow({ columns }) {
|
|
1808
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TableRow, { className: "animate-pulse", children: Array.from({ length: columns }).map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "py-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 bg-muted rounded w-3/4" }) }, index)) });
|
|
1809
|
-
}
|
|
1810
1829
|
function DataTableLoading({
|
|
1811
1830
|
visible,
|
|
1812
|
-
|
|
1813
|
-
skeletonRows = 5,
|
|
1814
|
-
className
|
|
1831
|
+
skeletonRows = 5
|
|
1815
1832
|
}) {
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
return
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
}
|
|
1824
|
-
return
|
|
1833
|
+
const { setIsLoading, setSkeletonRows } = useDataTableLoadingState();
|
|
1834
|
+
React10__namespace.useLayoutEffect(() => {
|
|
1835
|
+
setIsLoading(visible);
|
|
1836
|
+
return () => setIsLoading(false);
|
|
1837
|
+
}, [visible, setIsLoading]);
|
|
1838
|
+
React10__namespace.useLayoutEffect(() => {
|
|
1839
|
+
setSkeletonRows(skeletonRows);
|
|
1840
|
+
}, [skeletonRows, setSkeletonRows]);
|
|
1841
|
+
return null;
|
|
1825
1842
|
}
|
|
1826
1843
|
DataTableLoading.displayName = "DataTable.Loading";
|
|
1827
1844
|
function DataTableColumnHeader({
|
|
@@ -1867,6 +1884,7 @@ var checkboxVariants = classVarianceAuthority.cva(
|
|
|
1867
1884
|
variants: {
|
|
1868
1885
|
variant: {
|
|
1869
1886
|
default: "border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
1887
|
+
muted: "border-muted-foreground/40 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
|
|
1870
1888
|
secondary: "border-secondary data-[state=checked]:bg-secondary data-[state=checked]:text-secondary-foreground",
|
|
1871
1889
|
outline: "border-border data-[state=checked]:bg-background data-[state=checked]:text-primary data-[state=checked]:border-primary"
|
|
1872
1890
|
},
|
|
@@ -2301,7 +2319,7 @@ function DataTableTabs({
|
|
|
2301
2319
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2302
2320
|
"div",
|
|
2303
2321
|
{
|
|
2304
|
-
className: cn("flex items-center gap-1
|
|
2322
|
+
className: cn("flex items-center gap-1", className),
|
|
2305
2323
|
role: "tablist",
|
|
2306
2324
|
"aria-label": "Filtros",
|
|
2307
2325
|
children: tabs.map((tab) => {
|