@postxl/ui-components 1.5.1 → 1.5.3
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.ts +147 -140
- package/dist/index.js +40 -14
- package/dist/index.js.map +1 -1
- package/package.json +38 -38
package/dist/index.js
CHANGED
|
@@ -2488,6 +2488,12 @@ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFoc
|
|
|
2488
2488
|
return typeof v === "function" ? v : () => v;
|
|
2489
2489
|
}, [colCellMeta?.className]);
|
|
2490
2490
|
const colCellClassName = classNameResolver(rowOriginal);
|
|
2491
|
+
const rowClassNameMeta = meta?.rowClassName;
|
|
2492
|
+
const rowCellClassName = React$44.useMemo(() => {
|
|
2493
|
+
if (!rowClassNameMeta) return void 0;
|
|
2494
|
+
if (typeof rowClassNameMeta === "function") return rowClassNameMeta(cell.row);
|
|
2495
|
+
return rowClassNameMeta;
|
|
2496
|
+
}, [rowClassNameMeta, cell.row]);
|
|
2491
2497
|
const isSearchMatch = meta?.getIsSearchMatch?.(rowIndex, columnId) ?? false;
|
|
2492
2498
|
const isActiveSearchMatch = meta?.getIsActiveSearchMatch?.(rowIndex, columnId) ?? false;
|
|
2493
2499
|
const onClick = React$44.useCallback((event) => {
|
|
@@ -2588,7 +2594,7 @@ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFoc
|
|
|
2588
2594
|
"text-left": align === "left",
|
|
2589
2595
|
"text-right": align === "right",
|
|
2590
2596
|
"text-center": align === "center"
|
|
2591
|
-
}, {
|
|
2597
|
+
}, rowCellClassName, colCellClassName, {
|
|
2592
2598
|
"ring-1 ring-foreground ring-inset dark:ring-secondary-foreground": isFocused,
|
|
2593
2599
|
"bg-yellow-100 dark:bg-yellow-900/30": isSearchMatch && !isActiveSearchMatch,
|
|
2594
2600
|
"bg-orange-200 dark:bg-orange-900/50": isActiveSearchMatch,
|
|
@@ -2599,7 +2605,7 @@ function DataGridCellWrapper({ cell, table, rowIndex, columnId, isEditing, isFoc
|
|
|
2599
2605
|
"**:data-[slot=grid-cell-content]:line-clamp-3": !isEditing && rowHeight === "tall",
|
|
2600
2606
|
"**:data-[slot=grid-cell-content]:line-clamp-4": !isEditing && rowHeight === "extra-tall",
|
|
2601
2607
|
"relative overflow-visible": !!overlayContent
|
|
2602
|
-
},
|
|
2608
|
+
}, className),
|
|
2603
2609
|
onClick,
|
|
2604
2610
|
onContextMenu,
|
|
2605
2611
|
onDoubleClick,
|
|
@@ -6285,7 +6291,7 @@ function useStore$1(store, selector) {
|
|
|
6285
6291
|
const getSnapshot = React$22.useCallback(() => selector(store.getState()), [store, selector]);
|
|
6286
6292
|
return React$22.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
6287
6293
|
}
|
|
6288
|
-
function useDataGrid({ columns, data, onDataChange, onRowAdd: onRowAddProp, onRowsDelete: onRowsDeleteProp, onCellFocus: onCellFocusProp, onRowClick: onRowClickProp, highlightedRowIndex, rowHeight: rowHeightProp = DEFAULT_ROW_HEIGHT, overscan = OVERSCAN, initialState, autoFocus = false, enableColumnSelection = false, enableSearch = false, manualSorting, sorting: externalSorting, onSortingChange: externalOnSortingChange, onLoadMore, loadMoreThreshold = 25, totalRowCount, persistColumnState = false,...dataGridProps }) {
|
|
6294
|
+
function useDataGrid({ columns, data, onDataChange, onRowAdd: onRowAddProp, onRowsDelete: onRowsDeleteProp, onCellFocus: onCellFocusProp, onRowClick: onRowClickProp, highlightedRowIndex, rowClassName, rowHeight: rowHeightProp = DEFAULT_ROW_HEIGHT, overscan = OVERSCAN, initialState, autoFocus = false, enableColumnSelection = false, enableSearch = false, manualSorting, sorting: externalSorting, onSortingChange: externalOnSortingChange, onLoadMore, loadMoreThreshold = 25, totalRowCount, persistColumnState = false,...dataGridProps }) {
|
|
6289
6295
|
const dataGridRef = React$22.useRef(null);
|
|
6290
6296
|
const tableRef = React$22.useRef(null);
|
|
6291
6297
|
const rowVirtualizerRef = React$22.useRef(null);
|
|
@@ -6421,7 +6427,11 @@ function useDataGrid({ columns, data, onDataChange, onRowAdd: onRowAddProp, onRo
|
|
|
6421
6427
|
}, [initialState, persistedState]);
|
|
6422
6428
|
const getNavigableColumnIds = React$22.useCallback(() => {
|
|
6423
6429
|
const t = tableRef.current;
|
|
6424
|
-
if (t) return
|
|
6430
|
+
if (t) return [
|
|
6431
|
+
...t.getLeftVisibleLeafColumns(),
|
|
6432
|
+
...t.getCenterVisibleLeafColumns(),
|
|
6433
|
+
...t.getRightVisibleLeafColumns()
|
|
6434
|
+
].map((c) => c.id).filter((c) => !NON_NAVIGABLE_COLUMN_IDS.includes(c));
|
|
6425
6435
|
return columnIds.filter((c) => !NON_NAVIGABLE_COLUMN_IDS.includes(c));
|
|
6426
6436
|
}, [columnIds]);
|
|
6427
6437
|
const onDataUpdate = React$22.useCallback((updates) => {
|
|
@@ -7300,6 +7310,7 @@ function useDataGrid({ columns, data, onDataChange, onRowAdd: onRowAddProp, onRo
|
|
|
7300
7310
|
rowHeight,
|
|
7301
7311
|
isScrolling,
|
|
7302
7312
|
highlightedRowIndex,
|
|
7313
|
+
rowClassName,
|
|
7303
7314
|
columnDefsVersion,
|
|
7304
7315
|
onRowClick: onRowClickProp,
|
|
7305
7316
|
getIsCellSelected,
|
|
@@ -7338,6 +7349,7 @@ function useDataGrid({ columns, data, onDataChange, onRowAdd: onRowAddProp, onRo
|
|
|
7338
7349
|
searchOpen,
|
|
7339
7350
|
isScrolling,
|
|
7340
7351
|
highlightedRowIndex,
|
|
7352
|
+
rowClassName,
|
|
7341
7353
|
columnDefsVersion,
|
|
7342
7354
|
onRowClickProp,
|
|
7343
7355
|
getIsCellSelected,
|
|
@@ -9821,7 +9833,7 @@ function useSidebarTabs(side) {
|
|
|
9821
9833
|
|
|
9822
9834
|
//#endregion
|
|
9823
9835
|
//#region src/sidebar/sidebar-tab.tsx
|
|
9824
|
-
function SidebarTab({ side, id, icon, label, render, order }) {
|
|
9836
|
+
function SidebarTab({ side, id, icon, label, render, order, badge }) {
|
|
9825
9837
|
const ctx = React$10.useContext(SidebarTabsContext);
|
|
9826
9838
|
if (!ctx) throw new Error("SidebarTab must be used within a SidebarTabsProvider.");
|
|
9827
9839
|
const { register, unregister } = ctx;
|
|
@@ -9836,7 +9848,8 @@ function SidebarTab({ side, id, icon, label, render, order }) {
|
|
|
9836
9848
|
icon: iconRef.current,
|
|
9837
9849
|
label,
|
|
9838
9850
|
render: stableRender,
|
|
9839
|
-
order
|
|
9851
|
+
order,
|
|
9852
|
+
badge
|
|
9840
9853
|
});
|
|
9841
9854
|
return () => unregister(side, id);
|
|
9842
9855
|
}, [
|
|
@@ -9844,6 +9857,7 @@ function SidebarTab({ side, id, icon, label, render, order }) {
|
|
|
9844
9857
|
id,
|
|
9845
9858
|
label,
|
|
9846
9859
|
order,
|
|
9860
|
+
badge,
|
|
9847
9861
|
register,
|
|
9848
9862
|
unregister,
|
|
9849
9863
|
stableRender
|
|
@@ -9939,14 +9953,20 @@ function HorizontalTabBar({ side, tabs, activeTabId }) {
|
|
|
9939
9953
|
children: tabs.map((tab) => {
|
|
9940
9954
|
const Icon = tab.icon;
|
|
9941
9955
|
const isActive = tab.id === activeTabId;
|
|
9956
|
+
const badge = tab.badge;
|
|
9942
9957
|
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
9943
9958
|
asChild: true,
|
|
9944
|
-
children: /* @__PURE__ */
|
|
9959
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
9945
9960
|
role: "tab",
|
|
9946
9961
|
"aria-selected": isActive,
|
|
9947
|
-
className: cn("flex flex-1 items-center justify-center rounded-sm p-1.5 transition-colors", isActive ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"),
|
|
9962
|
+
className: cn("flex flex-1 items-center justify-center rounded-sm p-1.5 transition-colors cursor-pointer group/button", isActive ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground", badge && "pt-1"),
|
|
9948
9963
|
onClick: () => handleTabClick(tab.id),
|
|
9949
|
-
children: /* @__PURE__ */ jsx(Icon, { className: "size-4" })
|
|
9964
|
+
children: [/* @__PURE__ */ jsx(Icon, { className: "size-4" }), badge && /* @__PURE__ */ jsx(Badge, {
|
|
9965
|
+
size: "xs",
|
|
9966
|
+
variant: badge.variant,
|
|
9967
|
+
className: cn("ml-0.5 h-3.25 mb-1.25 px-1.5 group-hover/button:opacity-100 opacity-70 transition-opacity", isActive && "opacity-100", badge.className),
|
|
9968
|
+
children: badge.label
|
|
9969
|
+
})]
|
|
9950
9970
|
})
|
|
9951
9971
|
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
9952
9972
|
side: "bottom",
|
|
@@ -9973,14 +9993,20 @@ function VerticalTabBar({ side, tabs, activeTabId }) {
|
|
|
9973
9993
|
children: tabs.map((tab) => {
|
|
9974
9994
|
const Icon = tab.icon;
|
|
9975
9995
|
const isActive = tab.id === activeTabId;
|
|
9996
|
+
const badge = tab.badge;
|
|
9976
9997
|
return /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
9977
9998
|
asChild: true,
|
|
9978
|
-
children: /* @__PURE__ */
|
|
9999
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
9979
10000
|
role: "tab",
|
|
9980
10001
|
"aria-selected": isActive,
|
|
9981
|
-
className: cn("size-9 flex items-center justify-center rounded-md transition-colors", isActive ? "bg-sidebar-accent text-sidebar-accent-foreground" : "text-muted-foreground hover:text-foreground hover:bg-sidebar-accent/50"),
|
|
10002
|
+
className: cn("size-9 flex items-center justify-center rounded-md transition-colors cursor-pointer group/button", isActive ? "bg-sidebar-accent text-sidebar-accent-foreground" : "text-muted-foreground hover:text-foreground hover:bg-sidebar-accent/50"),
|
|
9982
10003
|
onClick: () => handleTabClick(tab.id),
|
|
9983
|
-
children: /* @__PURE__ */ jsx(Icon, { className: "size-4" })
|
|
10004
|
+
children: [/* @__PURE__ */ jsx(Icon, { className: "size-4" }), badge && /* @__PURE__ */ jsx(Badge, {
|
|
10005
|
+
size: "xs",
|
|
10006
|
+
variant: badge.variant,
|
|
10007
|
+
className: cn("ml-0.5 h-3.25 mb-1.25 px-1.5 group-hover/button:opacity-100 opacity-70 transition-opacity", isActive && "opacity-100", badge.className),
|
|
10008
|
+
children: badge.label
|
|
10009
|
+
})]
|
|
9984
10010
|
})
|
|
9985
10011
|
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
9986
10012
|
side: side === "left" ? "right" : "left",
|
|
@@ -11265,7 +11291,7 @@ const TreeBranch = ({ node, level, onNodeSelect, onGroupSelect, onToggleGroup, i
|
|
|
11265
11291
|
const hasChildren = node.children && node.children.length > 0;
|
|
11266
11292
|
if (!isGroup) return /* @__PURE__ */ jsxs("div", {
|
|
11267
11293
|
"data-test-id": `tree-node-${node.id}`,
|
|
11268
|
-
className: cn("relative flex items-center gap-2 py-1.5 px-2 rounded-md cursor-pointer hover:bg-accent hover:text-accent-foreground transition-colors border border-transparent hover:border hover:border-(--discreet-border)", { "bg-primary text-primary-foreground hover:border hover:border-(--discreet-border)": selectedId === node.id }),
|
|
11294
|
+
className: cn("relative flex items-center gap-2 py-1.5 px-2 rounded-md cursor-pointer hover:bg-accent hover:text-accent-foreground transition-colors border border-transparent hover:border hover:border-(--discreet-border)", node.className, { "bg-primary text-primary-foreground hover:border hover:border-(--discreet-border)": selectedId === node.id }),
|
|
11269
11295
|
style: { marginLeft: `${level * 24}px` },
|
|
11270
11296
|
onClick: () => onNodeSelect?.(node),
|
|
11271
11297
|
children: [
|
|
@@ -11283,7 +11309,7 @@ const TreeBranch = ({ node, level, onNodeSelect, onGroupSelect, onToggleGroup, i
|
|
|
11283
11309
|
"data-test-id": `tree-group-${node.id}`,
|
|
11284
11310
|
children: [/* @__PURE__ */ jsxs(AccordionTrigger, {
|
|
11285
11311
|
style: { "--margin-left": `calc(${level * 24 + 16}px - 16px)` },
|
|
11286
|
-
className: cn("flex flex-1 overflow-hidden items-center gap-2 py-1.5 px-2 rounded-md ml-(--margin-left) hover:bg-accent hover:text-accent-foreground hover:no-underline transition-colors border border-transparent hover:border hover:border-(--discreet-border)", "[&>svg:last-child]:hidden", { "bg-primary text-primary-foreground": selectedId === node.id }),
|
|
11312
|
+
className: cn("flex flex-1 overflow-hidden items-center gap-2 py-1.5 px-2 rounded-md ml-(--margin-left) hover:bg-accent hover:text-accent-foreground hover:no-underline transition-colors border border-transparent hover:border hover:border-(--discreet-border)", "[&>svg:last-child]:hidden", node.className, { "bg-primary text-primary-foreground": selectedId === node.id }),
|
|
11287
11313
|
children: [
|
|
11288
11314
|
/* @__PURE__ */ jsx(PlusIcon, {
|
|
11289
11315
|
"data-test-id": `tree-expand-${node.id}`,
|