baaz-custom-components 5.2.3 → 5.2.4
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -8
- package/dist/index.mjs +39 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -105,6 +105,7 @@ type GridProps = {
|
|
|
105
105
|
filterList: Filters[];
|
|
106
106
|
initialFilters?: any[];
|
|
107
107
|
children?: React.ReactNode;
|
|
108
|
+
onRowClick?: (row: AnyRow) => void;
|
|
108
109
|
onSortChange?: (key: string, order: SortOrder) => void;
|
|
109
110
|
onExportPdf?: () => void;
|
|
110
111
|
onExportExcel?: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ type GridProps = {
|
|
|
105
105
|
filterList: Filters[];
|
|
106
106
|
initialFilters?: any[];
|
|
107
107
|
children?: React.ReactNode;
|
|
108
|
+
onRowClick?: (row: AnyRow) => void;
|
|
108
109
|
onSortChange?: (key: string, order: SortOrder) => void;
|
|
109
110
|
onExportPdf?: () => void;
|
|
110
111
|
onExportExcel?: () => void;
|
package/dist/index.js
CHANGED
|
@@ -2412,7 +2412,6 @@ function GridHeader({
|
|
|
2412
2412
|
onSelectionAction,
|
|
2413
2413
|
onClearSelection
|
|
2414
2414
|
}) {
|
|
2415
|
-
console.log("GridHeader rendered");
|
|
2416
2415
|
const [downloadMenu, setDownloadMenu] = (0, import_react6.useState)(false);
|
|
2417
2416
|
const [searchOpen, setSearchOpen] = (0, import_react6.useState)(false);
|
|
2418
2417
|
const downloadRef = (0, import_react6.useRef)(null);
|
|
@@ -2573,7 +2572,6 @@ function useStore(store, name) {
|
|
|
2573
2572
|
// src/components/custom/grid/checkboxCell/checkBoxCell.tsx
|
|
2574
2573
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2575
2574
|
var CheckboxCell = ({ row, api, column }) => {
|
|
2576
|
-
console.log("CheckboxCell rendered");
|
|
2577
2575
|
const selectedRows = useStore(api, "selectedRows");
|
|
2578
2576
|
const isSelected = selectedRows.includes(row.id);
|
|
2579
2577
|
const handleChange = (e) => {
|
|
@@ -2702,6 +2700,15 @@ function buildCheckboxColumn({
|
|
|
2702
2700
|
|
|
2703
2701
|
// src/components/custom/grid/index.tsx
|
|
2704
2702
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2703
|
+
var _measureCanvas = typeof window !== "undefined" ? document.createElement("canvas") : null;
|
|
2704
|
+
function measureHeaderTextWidth(text) {
|
|
2705
|
+
if (!_measureCanvas) return 0;
|
|
2706
|
+
const ctx = _measureCanvas.getContext("2d");
|
|
2707
|
+
if (!ctx) return 0;
|
|
2708
|
+
ctx.font = "500 13px Inter, ui-sans-serif, system-ui, sans-serif";
|
|
2709
|
+
const textWidth = ctx.measureText(text).width;
|
|
2710
|
+
return Math.ceil(textWidth) + 64;
|
|
2711
|
+
}
|
|
2705
2712
|
var Grid = (0, import_react10.forwardRef)(
|
|
2706
2713
|
(_a, ref) => {
|
|
2707
2714
|
var _b = _a, {
|
|
@@ -2727,7 +2734,8 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2727
2734
|
selectedData,
|
|
2728
2735
|
selectionActions,
|
|
2729
2736
|
onSelectionAction,
|
|
2730
|
-
onClearSelection
|
|
2737
|
+
onClearSelection,
|
|
2738
|
+
onRowClick
|
|
2731
2739
|
} = _b, rest = __objRest(_b, [
|
|
2732
2740
|
"data",
|
|
2733
2741
|
"columns",
|
|
@@ -2751,10 +2759,10 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2751
2759
|
"selectedData",
|
|
2752
2760
|
"selectionActions",
|
|
2753
2761
|
"onSelectionAction",
|
|
2754
|
-
"onClearSelection"
|
|
2762
|
+
"onClearSelection",
|
|
2763
|
+
"onRowClick"
|
|
2755
2764
|
]);
|
|
2756
2765
|
var _a2;
|
|
2757
|
-
console.log("Grid rendered");
|
|
2758
2766
|
const apiRef = (0, import_react10.useRef)(null);
|
|
2759
2767
|
const containerRef = (0, import_react10.useRef)(null);
|
|
2760
2768
|
const dataRef = (0, import_react10.useRef)(data);
|
|
@@ -2769,6 +2777,10 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2769
2777
|
(0, import_react10.useEffect)(() => {
|
|
2770
2778
|
onSelectAllPageRef.current = onSelectAllPage;
|
|
2771
2779
|
}, [onSelectAllPage]);
|
|
2780
|
+
const onRowClickRef = (0, import_react10.useRef)(onRowClick);
|
|
2781
|
+
(0, import_react10.useEffect)(() => {
|
|
2782
|
+
onRowClickRef.current = onRowClick;
|
|
2783
|
+
}, [onRowClick]);
|
|
2772
2784
|
(0, import_react10.useImperativeHandle)(ref, () => apiRef.current, []);
|
|
2773
2785
|
const clearTokenRef = (0, import_react10.useRef)(0);
|
|
2774
2786
|
const prevSelectedCountRef = (0, import_react10.useRef)(selectedCount != null ? selectedCount : 0);
|
|
@@ -2819,6 +2831,17 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2819
2831
|
resizableColumns.forEach((col) => {
|
|
2820
2832
|
api.exec("resize-column", { id: col.id, auto: "data" });
|
|
2821
2833
|
});
|
|
2834
|
+
resizableColumns.forEach((col) => {
|
|
2835
|
+
var _a3, _b2, _c, _d, _e, _f, _g;
|
|
2836
|
+
const headerText = (_f = (_e = (_d = (_a3 = col == null ? void 0 : col.header) == null ? void 0 : _a3.text) != null ? _d : (_c = (_b2 = col == null ? void 0 : col.header) == null ? void 0 : _b2[0]) == null ? void 0 : _c.text) != null ? _e : col == null ? void 0 : col.text) != null ? _f : "";
|
|
2837
|
+
if (!headerText) return;
|
|
2838
|
+
const minWidth = measureHeaderTextWidth(headerText);
|
|
2839
|
+
const column = api.getColumn(col.id);
|
|
2840
|
+
const currentWidth = (_g = column == null ? void 0 : column.width) != null ? _g : 0;
|
|
2841
|
+
if (!isNaN(currentWidth) && currentWidth < minWidth) {
|
|
2842
|
+
api.exec("resize-column", { id: col.id, width: minWidth });
|
|
2843
|
+
}
|
|
2844
|
+
});
|
|
2822
2845
|
const totalAutoWidth = resizableColumns.reduce((sum, col) => {
|
|
2823
2846
|
var _a3;
|
|
2824
2847
|
const column = api.getColumn(col.id);
|
|
@@ -2842,9 +2865,12 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2842
2865
|
} else {
|
|
2843
2866
|
const equalWidth = resizableColumns.length > 0 ? availableWidth / resizableColumns.length : 0;
|
|
2844
2867
|
resizableColumns.forEach((col) => {
|
|
2868
|
+
var _a3, _b2, _c, _d, _e, _f;
|
|
2869
|
+
const headerText = (_f = (_e = (_d = (_a3 = col == null ? void 0 : col.header) == null ? void 0 : _a3.text) != null ? _d : (_c = (_b2 = col == null ? void 0 : col.header) == null ? void 0 : _b2[0]) == null ? void 0 : _c.text) != null ? _e : col == null ? void 0 : col.text) != null ? _f : "";
|
|
2870
|
+
const minWidth = headerText ? measureHeaderTextWidth(headerText) : 0;
|
|
2845
2871
|
api.exec("resize-column", {
|
|
2846
2872
|
id: col.id,
|
|
2847
|
-
width: equalWidth
|
|
2873
|
+
width: Math.max(equalWidth, minWidth)
|
|
2848
2874
|
});
|
|
2849
2875
|
});
|
|
2850
2876
|
}
|
|
@@ -2860,6 +2886,12 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2860
2886
|
apiRef.current = api;
|
|
2861
2887
|
resizeColumns();
|
|
2862
2888
|
api.intercept("focus-cell", onFocusCell);
|
|
2889
|
+
api.on("select-row", (ev) => {
|
|
2890
|
+
const handler = onRowClickRef.current;
|
|
2891
|
+
if (!handler) return;
|
|
2892
|
+
const row = api.getRow(ev.id);
|
|
2893
|
+
handler(row);
|
|
2894
|
+
});
|
|
2863
2895
|
},
|
|
2864
2896
|
[resizeColumns, onFocusCell]
|
|
2865
2897
|
);
|
|
@@ -2911,8 +2943,7 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2911
2943
|
data,
|
|
2912
2944
|
columns: resolvedColumns,
|
|
2913
2945
|
init,
|
|
2914
|
-
selectedRows: selectionEnabled ? selectedIds : void 0
|
|
2915
|
-
select: selectionEnabled ? false : rest.select
|
|
2946
|
+
selectedRows: selectionEnabled ? selectedIds : void 0
|
|
2916
2947
|
})
|
|
2917
2948
|
) }) })
|
|
2918
2949
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2381,7 +2381,6 @@ function GridHeader({
|
|
|
2381
2381
|
onSelectionAction,
|
|
2382
2382
|
onClearSelection
|
|
2383
2383
|
}) {
|
|
2384
|
-
console.log("GridHeader rendered");
|
|
2385
2384
|
const [downloadMenu, setDownloadMenu] = useState7(false);
|
|
2386
2385
|
const [searchOpen, setSearchOpen] = useState7(false);
|
|
2387
2386
|
const downloadRef = useRef2(null);
|
|
@@ -2542,7 +2541,6 @@ function useStore(store, name) {
|
|
|
2542
2541
|
// src/components/custom/grid/checkboxCell/checkBoxCell.tsx
|
|
2543
2542
|
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
2544
2543
|
var CheckboxCell = ({ row, api, column }) => {
|
|
2545
|
-
console.log("CheckboxCell rendered");
|
|
2546
2544
|
const selectedRows = useStore(api, "selectedRows");
|
|
2547
2545
|
const isSelected = selectedRows.includes(row.id);
|
|
2548
2546
|
const handleChange = (e) => {
|
|
@@ -2671,6 +2669,15 @@ function buildCheckboxColumn({
|
|
|
2671
2669
|
|
|
2672
2670
|
// src/components/custom/grid/index.tsx
|
|
2673
2671
|
import { jsx as jsx28, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2672
|
+
var _measureCanvas = typeof window !== "undefined" ? document.createElement("canvas") : null;
|
|
2673
|
+
function measureHeaderTextWidth(text) {
|
|
2674
|
+
if (!_measureCanvas) return 0;
|
|
2675
|
+
const ctx = _measureCanvas.getContext("2d");
|
|
2676
|
+
if (!ctx) return 0;
|
|
2677
|
+
ctx.font = "500 13px Inter, ui-sans-serif, system-ui, sans-serif";
|
|
2678
|
+
const textWidth = ctx.measureText(text).width;
|
|
2679
|
+
return Math.ceil(textWidth) + 64;
|
|
2680
|
+
}
|
|
2674
2681
|
var Grid = forwardRef(
|
|
2675
2682
|
(_a, ref) => {
|
|
2676
2683
|
var _b = _a, {
|
|
@@ -2696,7 +2703,8 @@ var Grid = forwardRef(
|
|
|
2696
2703
|
selectedData,
|
|
2697
2704
|
selectionActions,
|
|
2698
2705
|
onSelectionAction,
|
|
2699
|
-
onClearSelection
|
|
2706
|
+
onClearSelection,
|
|
2707
|
+
onRowClick
|
|
2700
2708
|
} = _b, rest = __objRest(_b, [
|
|
2701
2709
|
"data",
|
|
2702
2710
|
"columns",
|
|
@@ -2720,10 +2728,10 @@ var Grid = forwardRef(
|
|
|
2720
2728
|
"selectedData",
|
|
2721
2729
|
"selectionActions",
|
|
2722
2730
|
"onSelectionAction",
|
|
2723
|
-
"onClearSelection"
|
|
2731
|
+
"onClearSelection",
|
|
2732
|
+
"onRowClick"
|
|
2724
2733
|
]);
|
|
2725
2734
|
var _a2;
|
|
2726
|
-
console.log("Grid rendered");
|
|
2727
2735
|
const apiRef = useRef5(null);
|
|
2728
2736
|
const containerRef = useRef5(null);
|
|
2729
2737
|
const dataRef = useRef5(data);
|
|
@@ -2738,6 +2746,10 @@ var Grid = forwardRef(
|
|
|
2738
2746
|
useEffect9(() => {
|
|
2739
2747
|
onSelectAllPageRef.current = onSelectAllPage;
|
|
2740
2748
|
}, [onSelectAllPage]);
|
|
2749
|
+
const onRowClickRef = useRef5(onRowClick);
|
|
2750
|
+
useEffect9(() => {
|
|
2751
|
+
onRowClickRef.current = onRowClick;
|
|
2752
|
+
}, [onRowClick]);
|
|
2741
2753
|
useImperativeHandle(ref, () => apiRef.current, []);
|
|
2742
2754
|
const clearTokenRef = useRef5(0);
|
|
2743
2755
|
const prevSelectedCountRef = useRef5(selectedCount != null ? selectedCount : 0);
|
|
@@ -2788,6 +2800,17 @@ var Grid = forwardRef(
|
|
|
2788
2800
|
resizableColumns.forEach((col) => {
|
|
2789
2801
|
api.exec("resize-column", { id: col.id, auto: "data" });
|
|
2790
2802
|
});
|
|
2803
|
+
resizableColumns.forEach((col) => {
|
|
2804
|
+
var _a3, _b2, _c, _d, _e, _f, _g;
|
|
2805
|
+
const headerText = (_f = (_e = (_d = (_a3 = col == null ? void 0 : col.header) == null ? void 0 : _a3.text) != null ? _d : (_c = (_b2 = col == null ? void 0 : col.header) == null ? void 0 : _b2[0]) == null ? void 0 : _c.text) != null ? _e : col == null ? void 0 : col.text) != null ? _f : "";
|
|
2806
|
+
if (!headerText) return;
|
|
2807
|
+
const minWidth = measureHeaderTextWidth(headerText);
|
|
2808
|
+
const column = api.getColumn(col.id);
|
|
2809
|
+
const currentWidth = (_g = column == null ? void 0 : column.width) != null ? _g : 0;
|
|
2810
|
+
if (!isNaN(currentWidth) && currentWidth < minWidth) {
|
|
2811
|
+
api.exec("resize-column", { id: col.id, width: minWidth });
|
|
2812
|
+
}
|
|
2813
|
+
});
|
|
2791
2814
|
const totalAutoWidth = resizableColumns.reduce((sum, col) => {
|
|
2792
2815
|
var _a3;
|
|
2793
2816
|
const column = api.getColumn(col.id);
|
|
@@ -2811,9 +2834,12 @@ var Grid = forwardRef(
|
|
|
2811
2834
|
} else {
|
|
2812
2835
|
const equalWidth = resizableColumns.length > 0 ? availableWidth / resizableColumns.length : 0;
|
|
2813
2836
|
resizableColumns.forEach((col) => {
|
|
2837
|
+
var _a3, _b2, _c, _d, _e, _f;
|
|
2838
|
+
const headerText = (_f = (_e = (_d = (_a3 = col == null ? void 0 : col.header) == null ? void 0 : _a3.text) != null ? _d : (_c = (_b2 = col == null ? void 0 : col.header) == null ? void 0 : _b2[0]) == null ? void 0 : _c.text) != null ? _e : col == null ? void 0 : col.text) != null ? _f : "";
|
|
2839
|
+
const minWidth = headerText ? measureHeaderTextWidth(headerText) : 0;
|
|
2814
2840
|
api.exec("resize-column", {
|
|
2815
2841
|
id: col.id,
|
|
2816
|
-
width: equalWidth
|
|
2842
|
+
width: Math.max(equalWidth, minWidth)
|
|
2817
2843
|
});
|
|
2818
2844
|
});
|
|
2819
2845
|
}
|
|
@@ -2829,6 +2855,12 @@ var Grid = forwardRef(
|
|
|
2829
2855
|
apiRef.current = api;
|
|
2830
2856
|
resizeColumns();
|
|
2831
2857
|
api.intercept("focus-cell", onFocusCell);
|
|
2858
|
+
api.on("select-row", (ev) => {
|
|
2859
|
+
const handler = onRowClickRef.current;
|
|
2860
|
+
if (!handler) return;
|
|
2861
|
+
const row = api.getRow(ev.id);
|
|
2862
|
+
handler(row);
|
|
2863
|
+
});
|
|
2832
2864
|
},
|
|
2833
2865
|
[resizeColumns, onFocusCell]
|
|
2834
2866
|
);
|
|
@@ -2880,8 +2912,7 @@ var Grid = forwardRef(
|
|
|
2880
2912
|
data,
|
|
2881
2913
|
columns: resolvedColumns,
|
|
2882
2914
|
init,
|
|
2883
|
-
selectedRows: selectionEnabled ? selectedIds : void 0
|
|
2884
|
-
select: selectionEnabled ? false : rest.select
|
|
2915
|
+
selectedRows: selectionEnabled ? selectedIds : void 0
|
|
2885
2916
|
})
|
|
2886
2917
|
) }) })
|
|
2887
2918
|
}
|