baaz-custom-components 5.0.14 → 5.0.16

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
@@ -2239,17 +2239,23 @@ function Grid(_a) {
2239
2239
  }
2240
2240
  });
2241
2241
  });
2242
- const init = (api) => {
2243
- apiRef.current = api;
2242
+ const autoResizeColumns = () => {
2243
+ if (!apiRef.current) return;
2244
2244
  columns.forEach((col) => {
2245
- if (!(col == null ? void 0 : col.width)) {
2246
- api.exec("resize-column", {
2247
- id: col.id,
2248
- auto: "data"
2249
- });
2250
- }
2245
+ var _a2;
2246
+ (_a2 = apiRef == null ? void 0 : apiRef.current) == null ? void 0 : _a2.exec("resize-column", {
2247
+ id: col.id,
2248
+ auto: "header"
2249
+ });
2251
2250
  });
2252
2251
  };
2252
+ const handleInit = (0, import_react6.useCallback)(
2253
+ (api) => {
2254
+ apiRef.current = api;
2255
+ requestAnimationFrame(autoResizeColumns);
2256
+ },
2257
+ [columns]
2258
+ );
2253
2259
  const getSelectedData = () => {
2254
2260
  var _a2, _b2;
2255
2261
  const selected = (_b2 = (_a2 = apiRef.current) == null ? void 0 : _a2.getState().selectedRows) != null ? _b2 : [];
@@ -2289,7 +2295,14 @@ function Grid(_a) {
2289
2295
  onFilterChange
2290
2296
  }
2291
2297
  ),
2292
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "w-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_grid.WillowDark, { fonts, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "w-grid h-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_grid.Grid, __spreadProps(__spreadValues({}, rest), { data, columns: svarColumns, init })) }) }) })
2298
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "w-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_react_grid.WillowDark, { fonts, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "w-grid h-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2299
+ import_react_grid.Grid,
2300
+ __spreadProps(__spreadValues({}, rest), {
2301
+ data,
2302
+ columns: svarColumns,
2303
+ init: handleInit
2304
+ })
2305
+ ) }) }) })
2293
2306
  ] });
2294
2307
  }
2295
2308
  var grid_default = Grid;
package/dist/index.mjs CHANGED
@@ -1909,7 +1909,7 @@ var CustomBreadcrumb = ({
1909
1909
  var breadcrumb_default = CustomBreadcrumb;
1910
1910
 
1911
1911
  // src/components/custom/grid/index.tsx
1912
- import { useRef as useRef2 } from "react";
1912
+ import { useCallback as useCallback2, useRef as useRef2 } from "react";
1913
1913
  import { Grid as SvarGrid, WillowDark } from "@svar-ui/react-grid";
1914
1914
 
1915
1915
  // src/components/custom/grid/sortableHeaderCell.tsx
@@ -2210,17 +2210,23 @@ function Grid(_a) {
2210
2210
  }
2211
2211
  });
2212
2212
  });
2213
- const init = (api) => {
2214
- apiRef.current = api;
2213
+ const autoResizeColumns = () => {
2214
+ if (!apiRef.current) return;
2215
2215
  columns.forEach((col) => {
2216
- if (!(col == null ? void 0 : col.width)) {
2217
- api.exec("resize-column", {
2218
- id: col.id,
2219
- auto: "data"
2220
- });
2221
- }
2216
+ var _a2;
2217
+ (_a2 = apiRef == null ? void 0 : apiRef.current) == null ? void 0 : _a2.exec("resize-column", {
2218
+ id: col.id,
2219
+ auto: "header"
2220
+ });
2222
2221
  });
2223
2222
  };
2223
+ const handleInit = useCallback2(
2224
+ (api) => {
2225
+ apiRef.current = api;
2226
+ requestAnimationFrame(autoResizeColumns);
2227
+ },
2228
+ [columns]
2229
+ );
2224
2230
  const getSelectedData = () => {
2225
2231
  var _a2, _b2;
2226
2232
  const selected = (_b2 = (_a2 = apiRef.current) == null ? void 0 : _a2.getState().selectedRows) != null ? _b2 : [];
@@ -2260,7 +2266,14 @@ function Grid(_a) {
2260
2266
  onFilterChange
2261
2267
  }
2262
2268
  ),
2263
- /* @__PURE__ */ jsx25("div", { className: "w-full overflow-hidden", children: /* @__PURE__ */ jsx25(WillowDark, { fonts, children: /* @__PURE__ */ jsx25("div", { className: "w-grid h-full overflow-hidden", children: /* @__PURE__ */ jsx25(SvarGrid, __spreadProps(__spreadValues({}, rest), { data, columns: svarColumns, init })) }) }) })
2269
+ /* @__PURE__ */ jsx25("div", { className: "w-full overflow-hidden", children: /* @__PURE__ */ jsx25(WillowDark, { fonts, children: /* @__PURE__ */ jsx25("div", { className: "w-grid h-full overflow-hidden", children: /* @__PURE__ */ jsx25(
2270
+ SvarGrid,
2271
+ __spreadProps(__spreadValues({}, rest), {
2272
+ data,
2273
+ columns: svarColumns,
2274
+ init: handleInit
2275
+ })
2276
+ ) }) }) })
2264
2277
  ] });
2265
2278
  }
2266
2279
  var grid_default = Grid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baaz-custom-components",
3
- "version": "5.0.14",
3
+ "version": "5.0.16",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "main": "dist/index.js",