baaz-custom-components 5.0.18 → 5.0.20

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 CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as react from 'react';
2
+ import { IApi } from '@svar-ui/react-grid';
2
3
 
3
4
  type NavbarData = NavbarEntry[];
4
5
  interface hubDetail {
@@ -58,6 +59,7 @@ type BreadcrumbProps = {
58
59
  declare const CustomBreadcrumb: ({ layoutName, includeFrom, pathname, }: BreadcrumbProps) => react.JSX.Element;
59
60
 
60
61
  type SortOrder = "asc" | "desc";
62
+
61
63
  type GridColumn = {
62
64
  id: string;
63
65
  header: string;
@@ -94,11 +96,15 @@ type GridProps = {
94
96
  search: boolean;
95
97
  searchkey: string;
96
98
  searchValue: string;
99
+ autoResize?: boolean;
100
+ autoResizeMode?: boolean | "data" | "header" | undefined;
101
+ defaultMinWidth?: number;
97
102
  onExportPdf?: () => void;
98
103
  onExportExcel?: () => void;
99
104
  onSearch: (e: React.ChangeEvent<HTMLInputElement>) => void;
100
105
  filterList: Filters[];
101
106
  onFilterChange: (filter: ActiveFilter) => void;
107
+ onApiReady?: (api: IApi) => void;
102
108
  };
103
109
  type ActiveFilter = {
104
110
  column?: string | null;
@@ -108,7 +114,7 @@ type ActiveFilter = {
108
114
  endDate?: string | null;
109
115
  };
110
116
 
111
- declare function Grid({ data, columns, sortKey, sortOrder, onSortChange, onExportPdf, onExportExcel, downloadable, fileNmae, fonts, onFilterChange, ...rest }: GridProps): react.JSX.Element;
117
+ declare function Grid({ data, columns, sortKey, sortOrder, onSortChange, onExportPdf, onExportExcel, downloadable, autoResize, autoResizeMode, defaultMinWidth, fileNmae, fonts, onFilterChange, ...rest }: GridProps): react.JSX.Element;
112
118
 
113
119
  type Pagination$1 = {
114
120
  totalCount: number;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as react from 'react';
2
+ import { IApi } from '@svar-ui/react-grid';
2
3
 
3
4
  type NavbarData = NavbarEntry[];
4
5
  interface hubDetail {
@@ -58,6 +59,7 @@ type BreadcrumbProps = {
58
59
  declare const CustomBreadcrumb: ({ layoutName, includeFrom, pathname, }: BreadcrumbProps) => react.JSX.Element;
59
60
 
60
61
  type SortOrder = "asc" | "desc";
62
+
61
63
  type GridColumn = {
62
64
  id: string;
63
65
  header: string;
@@ -94,11 +96,15 @@ type GridProps = {
94
96
  search: boolean;
95
97
  searchkey: string;
96
98
  searchValue: string;
99
+ autoResize?: boolean;
100
+ autoResizeMode?: boolean | "data" | "header" | undefined;
101
+ defaultMinWidth?: number;
97
102
  onExportPdf?: () => void;
98
103
  onExportExcel?: () => void;
99
104
  onSearch: (e: React.ChangeEvent<HTMLInputElement>) => void;
100
105
  filterList: Filters[];
101
106
  onFilterChange: (filter: ActiveFilter) => void;
107
+ onApiReady?: (api: IApi) => void;
102
108
  };
103
109
  type ActiveFilter = {
104
110
  column?: string | null;
@@ -108,7 +114,7 @@ type ActiveFilter = {
108
114
  endDate?: string | null;
109
115
  };
110
116
 
111
- declare function Grid({ data, columns, sortKey, sortOrder, onSortChange, onExportPdf, onExportExcel, downloadable, fileNmae, fonts, onFilterChange, ...rest }: GridProps): react.JSX.Element;
117
+ declare function Grid({ data, columns, sortKey, sortOrder, onSortChange, onExportPdf, onExportExcel, downloadable, autoResize, autoResizeMode, defaultMinWidth, fileNmae, fonts, onFilterChange, ...rest }: GridProps): react.JSX.Element;
112
118
 
113
119
  type Pagination$1 = {
114
120
  totalCount: number;
package/dist/index.js CHANGED
@@ -2201,6 +2201,9 @@ function Grid(_a) {
2201
2201
  onExportPdf,
2202
2202
  onExportExcel,
2203
2203
  downloadable = true,
2204
+ autoResize = true,
2205
+ autoResizeMode = true,
2206
+ defaultMinWidth = 120,
2204
2207
  fileNmae,
2205
2208
  fonts,
2206
2209
  onFilterChange
@@ -2213,6 +2216,9 @@ function Grid(_a) {
2213
2216
  "onExportPdf",
2214
2217
  "onExportExcel",
2215
2218
  "downloadable",
2219
+ "autoResize",
2220
+ "autoResizeMode",
2221
+ "defaultMinWidth",
2216
2222
  "fileNmae",
2217
2223
  "fonts",
2218
2224
  "onFilterChange"
@@ -2239,22 +2245,41 @@ function Grid(_a) {
2239
2245
  }
2240
2246
  });
2241
2247
  });
2242
- const handleInit = (0, import_react6.useCallback)(
2243
- (api) => {
2244
- apiRef.current = api;
2245
- setTimeout(() => {
2246
- requestAnimationFrame(() => {
2247
- columns.forEach((col) => {
2248
- api.exec("resize-column", {
2249
- id: col.id,
2250
- auto: "header"
2251
- });
2248
+ const init = (api) => {
2249
+ var _a2;
2250
+ apiRef.current = api;
2251
+ (_a2 = rest.onApiReady) == null ? void 0 : _a2.call(rest, api);
2252
+ };
2253
+ (0, import_react6.useEffect)(() => {
2254
+ if (!apiRef.current || !columns.length || !autoResize) return;
2255
+ const resize = () => {
2256
+ columns.forEach((col) => {
2257
+ var _a2, _b2;
2258
+ if (!(col == null ? void 0 : col.width)) {
2259
+ (_a2 = apiRef.current) == null ? void 0 : _a2.exec("resize-column", {
2260
+ id: col.id,
2261
+ auto: autoResizeMode
2252
2262
  });
2253
- });
2254
- }, 0);
2255
- },
2256
- [columns, data]
2257
- );
2263
+ }
2264
+ if (defaultMinWidth) {
2265
+ (_b2 = apiRef.current) == null ? void 0 : _b2.exec("update-column", {
2266
+ id: col.id,
2267
+ minWidth: defaultMinWidth
2268
+ });
2269
+ }
2270
+ });
2271
+ };
2272
+ const run = async () => {
2273
+ var _a2;
2274
+ if ((_a2 = document == null ? void 0 : document.fonts) == null ? void 0 : _a2.ready) {
2275
+ await document.fonts.ready;
2276
+ }
2277
+ requestAnimationFrame(() => {
2278
+ requestAnimationFrame(resize);
2279
+ });
2280
+ };
2281
+ run();
2282
+ }, [columns, data, autoResize, autoResizeMode, defaultMinWidth]);
2258
2283
  const getSelectedData = () => {
2259
2284
  var _a2, _b2;
2260
2285
  const selected = (_b2 = (_a2 = apiRef.current) == null ? void 0 : _a2.getState().selectedRows) != null ? _b2 : [];
@@ -2294,14 +2319,7 @@ function Grid(_a) {
2294
2319
  onFilterChange
2295
2320
  }
2296
2321
  ),
2297
- /* @__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)(
2298
- import_react_grid.Grid,
2299
- __spreadProps(__spreadValues({}, rest), {
2300
- data,
2301
- columns: svarColumns,
2302
- init: handleInit
2303
- })
2304
- ) }) }) })
2322
+ /* @__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 })) }) }) })
2305
2323
  ] });
2306
2324
  }
2307
2325
  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 { useCallback as useCallback2, useRef as useRef2 } from "react";
1912
+ import { useEffect as useEffect6, 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
@@ -2172,6 +2172,9 @@ function Grid(_a) {
2172
2172
  onExportPdf,
2173
2173
  onExportExcel,
2174
2174
  downloadable = true,
2175
+ autoResize = true,
2176
+ autoResizeMode = true,
2177
+ defaultMinWidth = 120,
2175
2178
  fileNmae,
2176
2179
  fonts,
2177
2180
  onFilterChange
@@ -2184,6 +2187,9 @@ function Grid(_a) {
2184
2187
  "onExportPdf",
2185
2188
  "onExportExcel",
2186
2189
  "downloadable",
2190
+ "autoResize",
2191
+ "autoResizeMode",
2192
+ "defaultMinWidth",
2187
2193
  "fileNmae",
2188
2194
  "fonts",
2189
2195
  "onFilterChange"
@@ -2210,22 +2216,41 @@ function Grid(_a) {
2210
2216
  }
2211
2217
  });
2212
2218
  });
2213
- const handleInit = useCallback2(
2214
- (api) => {
2215
- apiRef.current = api;
2216
- setTimeout(() => {
2217
- requestAnimationFrame(() => {
2218
- columns.forEach((col) => {
2219
- api.exec("resize-column", {
2220
- id: col.id,
2221
- auto: "header"
2222
- });
2219
+ const init = (api) => {
2220
+ var _a2;
2221
+ apiRef.current = api;
2222
+ (_a2 = rest.onApiReady) == null ? void 0 : _a2.call(rest, api);
2223
+ };
2224
+ useEffect6(() => {
2225
+ if (!apiRef.current || !columns.length || !autoResize) return;
2226
+ const resize = () => {
2227
+ columns.forEach((col) => {
2228
+ var _a2, _b2;
2229
+ if (!(col == null ? void 0 : col.width)) {
2230
+ (_a2 = apiRef.current) == null ? void 0 : _a2.exec("resize-column", {
2231
+ id: col.id,
2232
+ auto: autoResizeMode
2223
2233
  });
2224
- });
2225
- }, 0);
2226
- },
2227
- [columns, data]
2228
- );
2234
+ }
2235
+ if (defaultMinWidth) {
2236
+ (_b2 = apiRef.current) == null ? void 0 : _b2.exec("update-column", {
2237
+ id: col.id,
2238
+ minWidth: defaultMinWidth
2239
+ });
2240
+ }
2241
+ });
2242
+ };
2243
+ const run = async () => {
2244
+ var _a2;
2245
+ if ((_a2 = document == null ? void 0 : document.fonts) == null ? void 0 : _a2.ready) {
2246
+ await document.fonts.ready;
2247
+ }
2248
+ requestAnimationFrame(() => {
2249
+ requestAnimationFrame(resize);
2250
+ });
2251
+ };
2252
+ run();
2253
+ }, [columns, data, autoResize, autoResizeMode, defaultMinWidth]);
2229
2254
  const getSelectedData = () => {
2230
2255
  var _a2, _b2;
2231
2256
  const selected = (_b2 = (_a2 = apiRef.current) == null ? void 0 : _a2.getState().selectedRows) != null ? _b2 : [];
@@ -2265,14 +2290,7 @@ function Grid(_a) {
2265
2290
  onFilterChange
2266
2291
  }
2267
2292
  ),
2268
- /* @__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(
2269
- SvarGrid,
2270
- __spreadProps(__spreadValues({}, rest), {
2271
- data,
2272
- columns: svarColumns,
2273
- init: handleInit
2274
- })
2275
- ) }) }) })
2293
+ /* @__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 })) }) }) })
2276
2294
  ] });
2277
2295
  }
2278
2296
  var grid_default = Grid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baaz-custom-components",
3
- "version": "5.0.18",
3
+ "version": "5.0.20",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "main": "dist/index.js",