@data-c/pro 0.2.55 → 0.2.57

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.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/DataTable/index.ts
2
- import { ColumnsPanelTrigger, useGridApiRef as useGridApiRef2 } from "@mui/x-data-grid-pro";
2
+ import { useGridApiRef as useGridApiRef2 } from "@mui/x-data-grid-pro";
3
3
 
4
4
  // src/DataTable/DataTable.tsx
5
- import { useEffect, useMemo } from "react";
5
+ import React, { useEffect } from "react";
6
6
  import { Circle } from "@mui/icons-material";
7
7
  import { LinearProgress, Stack as Stack3 } from "@mui/material";
8
8
  import {
@@ -109,7 +109,9 @@ import {
109
109
  useContext,
110
110
  useState
111
111
  } from "react";
112
- import { useGridApiRef } from "@mui/x-data-grid-pro";
112
+ import {
113
+ useGridApiRef
114
+ } from "@mui/x-data-grid-pro";
113
115
  import { jsx as jsx3 } from "react/jsx-runtime";
114
116
  var TableRootContext = createContext({});
115
117
  function TableRootProvider({
@@ -152,216 +154,274 @@ function useTableRootContext() {
152
154
 
153
155
  // src/DataTable/DataTable.tsx
154
156
  import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
155
- var getFilteredRows = ({ apiRef }) => gridFilteredSortedRowIdsSelector(apiRef);
156
- function Table(props) {
157
- const {
158
- error,
159
- isLoading,
160
- isFetching,
161
- data,
162
- columns,
163
- controlledRowsSelectedId,
164
- onClearRowsSelectedId,
165
- onRowSelectionChange,
166
- onCellKeyDown,
167
- onRowDoubleClick,
168
- stackProps,
169
- slots,
170
- ...rest
171
- } = props;
172
- const {
173
- rowsSelectedId,
174
- setRowsSelectedId,
175
- clearCallback,
176
- setClearCallback,
177
- apiRef
178
- } = useTableRootContext();
179
- const parsedColumns = useMemo(() => {
180
- return (columns2) => {
181
- return columns2.map((col) => {
182
- if (col.headerName === "A\xE7\xF5es") {
183
- return {
184
- ...col,
185
- minWidth: col.minWidth || 80,
186
- maxWidth: col.maxWidth || col.width || 80,
187
- headerClassName: "sticky-header",
188
- cellClassName: "sticky-cell"
189
- };
157
+ var _DataTable = React.forwardRef(
158
+ function Table(props, ref) {
159
+ const {
160
+ error,
161
+ isLoading,
162
+ isFetching,
163
+ data,
164
+ columns,
165
+ onColumnChange,
166
+ onColumnVisibilityModelChange,
167
+ onColumnOrderChange,
168
+ onColumnWidthChange,
169
+ controlledRowsSelectedId,
170
+ onClearRowsSelectedId,
171
+ onRowSelectionChange,
172
+ onCellKeyDown,
173
+ onRowDoubleClick,
174
+ stackProps,
175
+ slots,
176
+ restoreFromState,
177
+ ...rest
178
+ } = props;
179
+ const {
180
+ rowsSelectedId,
181
+ setRowsSelectedId,
182
+ clearCallback,
183
+ setClearCallback,
184
+ apiRef
185
+ } = useTableRootContext();
186
+ React.useImperativeHandle(
187
+ ref,
188
+ () => ({
189
+ apiRef: apiRef.current,
190
+ restoreState: (state) => {
191
+ if (!apiRef?.current || !state)
192
+ return;
193
+ const cleanState = Object.entries(state).reduce(
194
+ (acc, [key, value]) => {
195
+ if (value !== null) {
196
+ acc[key] = value;
197
+ }
198
+ return acc;
199
+ },
200
+ {}
201
+ );
202
+ if (Object.keys(cleanState).length > 0) {
203
+ console.log("Restaurando estado da tabela:", cleanState);
204
+ apiRef.current.restoreState(cleanState);
205
+ }
206
+ },
207
+ exportState: () => {
208
+ return apiRef?.current?.exportState({
209
+ exportOnlyDirtyModels: true
210
+ });
211
+ }
212
+ }),
213
+ [apiRef]
214
+ );
215
+ const columnWidthDebounceRef = React.useRef(null);
216
+ const ignoreWarmupRef = React.useRef(true);
217
+ React.useEffect(() => {
218
+ const timeoutId = window.setTimeout(() => {
219
+ ignoreWarmupRef.current = false;
220
+ }, 100);
221
+ return () => {
222
+ window.clearTimeout(timeoutId);
223
+ if (columnWidthDebounceRef.current) {
224
+ window.clearTimeout(columnWidthDebounceRef.current);
190
225
  }
191
- return {
192
- ...col,
193
- flex: col.flex || 1,
194
- minWidth: col.minWidth || 100,
195
- headerClassName: col?.enableStickyColumns ? "sticky-header" : "",
196
- cellClassName: col?.enableStickyColumns ? "sticky-cell" : ""
197
- };
226
+ };
227
+ }, []);
228
+ useEffect(() => {
229
+ if (!apiRef.current)
230
+ return;
231
+ if (!restoreFromState)
232
+ return;
233
+ const cleanState = Object.entries(restoreFromState).reduce(
234
+ (acc, [key, value]) => {
235
+ if (value !== null) {
236
+ acc[key] = value;
237
+ }
238
+ return acc;
239
+ },
240
+ {}
241
+ );
242
+ if (Object.keys(cleanState).length > 0) {
243
+ apiRef.current.restoreState(cleanState);
244
+ }
245
+ }, [apiRef, restoreFromState]);
246
+ const emitColumnChange = React.useCallback(
247
+ (meta) => {
248
+ if (!apiRef.current)
249
+ return;
250
+ const state = apiRef.current.exportState({
251
+ exportOnlyDirtyModels: true
252
+ });
253
+ onColumnChange?.({ state, meta });
254
+ },
255
+ [apiRef, onColumnChange]
256
+ );
257
+ function _onColumnOrderChange(params, event, details) {
258
+ onColumnOrderChange?.(params, event, details);
259
+ emitColumnChange({
260
+ reason: "order"
198
261
  });
199
- };
200
- }, [columns]);
201
- useEffect(() => {
202
- if (controlledRowsSelectedId) {
203
- setRowsSelectedId(controlledRowsSelectedId);
204
262
  }
205
- }, [controlledRowsSelectedId]);
206
- useEffect(() => {
207
- if (clearCallback) {
208
- onClearRowsSelectedId && onClearRowsSelectedId({
209
- type: "include",
210
- ids: /* @__PURE__ */ new Set()
211
- });
212
- setClearCallback(false);
263
+ function _onColumnWidthChange(params, event, details) {
264
+ if (ignoreWarmupRef.current) {
265
+ return;
266
+ }
267
+ onColumnWidthChange?.(params, event, details);
268
+ emitColumnWidthChangeDebounced();
213
269
  }
214
- }, [clearCallback]);
215
- function handleCellKeyDown(params, event, details) {
216
- const eventCode = event.ctrlKey && event.code === "KeyE" ? "ctrl+e" : event.code;
217
- switch (eventCode) {
218
- case "Enter":
219
- event.preventDefault();
220
- if (onCellKeyDown)
221
- onCellKeyDown("edit", params.id);
222
- break;
223
- case "F3":
224
- event.preventDefault();
225
- if (onCellKeyDown)
226
- onCellKeyDown("edit", params.id);
227
- break;
228
- case "Delete":
229
- event.preventDefault();
230
- if (onCellKeyDown)
231
- onCellKeyDown("delete", params.id);
232
- break;
233
- case "ctrl+e":
234
- event.preventDefault();
235
- const handleExport = (options) => {
236
- if (apiRef?.current) {
237
- apiRef.current.exportDataAsCsv(options);
238
- }
239
- };
240
- handleExport({ getRowsToExport: getFilteredRows });
241
- break;
242
- default:
243
- break;
270
+ function _onColumnVisibilityModelChange(params, details) {
271
+ onColumnVisibilityModelChange?.(params, details);
272
+ emitColumnChange({
273
+ reason: "visibility"
274
+ });
244
275
  }
245
- }
246
- function handleRowDoubleClick(params, _, details) {
247
- if (onRowDoubleClick)
248
- onRowDoubleClick("edit", params.id);
249
- }
250
- return /* @__PURE__ */ jsxs3(Stack3, { height: "100%", minHeight: "500px", position: "relative", ...stackProps, children: [
251
- !isLoading && isFetching && /* @__PURE__ */ jsx4(
252
- LinearProgress,
253
- {
254
- sx: {
255
- position: "absolute",
256
- top: 0,
257
- right: 0,
258
- left: 0,
259
- zIndex: 999,
260
- height: "3px"
261
- }
276
+ const emitColumnWidthChangeDebounced = React.useCallback(() => {
277
+ if (columnWidthDebounceRef.current) {
278
+ window.clearTimeout(columnWidthDebounceRef.current);
262
279
  }
263
- ),
264
- /* @__PURE__ */ jsx4(
265
- DataGridPro,
280
+ columnWidthDebounceRef.current = window.setTimeout(() => {
281
+ emitColumnChange({ reason: "width" });
282
+ }, 250);
283
+ }, [emitColumnChange]);
284
+ useEffect(() => {
285
+ if (controlledRowsSelectedId) {
286
+ setRowsSelectedId(controlledRowsSelectedId);
287
+ }
288
+ }, [controlledRowsSelectedId]);
289
+ useEffect(() => {
290
+ if (clearCallback) {
291
+ onClearRowsSelectedId && onClearRowsSelectedId({
292
+ type: "include",
293
+ ids: /* @__PURE__ */ new Set()
294
+ });
295
+ setClearCallback(false);
296
+ }
297
+ }, [clearCallback]);
298
+ return /* @__PURE__ */ jsxs3(
299
+ Stack3,
266
300
  {
267
- apiRef,
268
- rows: data,
269
- columns: parsedColumns(columns),
270
- density: "compact",
271
- hideFooterPagination: true,
272
- hideFooter: true,
273
- loading: isLoading,
274
- rowHeight: 43,
275
- columnHeaderHeight: 43,
276
- disableVirtualization: true,
277
- onRowDoubleClick: handleRowDoubleClick,
278
- onCellKeyDown: handleCellKeyDown,
279
- disableRowSelectionOnClick: true,
280
- rowSelectionModel: rowsSelectedId,
281
- onRowSelectionModelChange: (rowSelectionModel, details) => {
282
- if (onRowSelectionChange) {
283
- onRowSelectionChange(rowSelectionModel, details);
284
- }
285
- if (controlledRowsSelectedId)
286
- return;
287
- setRowsSelectedId(rowSelectionModel);
288
- },
289
- slots: {
290
- booleanCellFalseIcon: () => /* @__PURE__ */ jsx4(Circle, { color: "error", sx: { fontSize: "10pt" } }),
291
- booleanCellTrueIcon: () => /* @__PURE__ */ jsx4(Circle, { color: "success", sx: { fontSize: "10pt" } }),
292
- noRowsOverlay: () => !isLoading && !!error ? /* @__PURE__ */ jsx4(DataTableError, { errorMessage: error }) : /* @__PURE__ */ jsx4(DataTableEmptyData, {}),
293
- ...slots
294
- },
295
- slotProps: {
296
- loadingOverlay: {
297
- variant: "skeleton",
298
- noRowsVariant: "skeleton"
299
- }
300
- },
301
- disableColumnFilter: true,
302
- localeText: ptBR.components.MuiDataGrid.defaultProps.localeText,
303
- sx: {
304
- border: "none",
305
- borderRadius: 0,
306
- "--DataGrid-rowBorderColor": "#edf2f9",
307
- "--DataGrid-containerBackground": "#f4f6fa",
308
- ".MuiDataGrid-overlayWrapperInner": {
309
- display: "flex",
310
- alignItems: "center",
311
- justifyContent: "center"
312
- },
313
- ".MuiDataGrid-row": {
314
- backgroundColor: "white",
315
- "&:nth-of-type(even)": {
316
- backgroundColor: "#f9fafd"
317
- },
318
- ":hover": {
319
- backgroundColor: "#e9e9e9"
320
- },
321
- "&.Mui-selected": {
322
- backgroundColor: "rgb(238, 249, 252)",
323
- "&:hover": {
324
- backgroundColor: "rgb(222, 243, 249)"
301
+ height: "100%",
302
+ minHeight: "500px",
303
+ position: "relative",
304
+ ...stackProps,
305
+ children: [
306
+ !isLoading && isFetching && /* @__PURE__ */ jsx4(
307
+ LinearProgress,
308
+ {
309
+ sx: {
310
+ position: "absolute",
311
+ top: 0,
312
+ right: 0,
313
+ left: 0,
314
+ zIndex: 999,
315
+ height: "3px"
325
316
  }
326
317
  }
327
- },
328
- ".MuiDataGrid-cell": {
329
- fontSize: "12px",
330
- color: "#0b0e14"
331
- },
332
- ".MuiDataGrid-columnHeaders": {
333
- border: "solid 1px #edf2f9",
334
- backgroundColor: "#f4f6fa"
335
- },
336
- ".MuiDataGrid-columnHeader": {
337
- backgroundColor: "#f4f6fa"
338
- },
339
- ".MuiDataGrid-columnHeaders .MuiDataGrid-filler": {
340
- backgroundColor: "#f4f6fa"
341
- },
342
- ".MuiDataGrid-columnHeaderTitle": {
343
- fontSize: "12px",
344
- color: "#0b0e14",
345
- fontWeight: "600"
346
- },
347
- "& .sticky-cell": {
348
- position: "sticky",
349
- right: 0,
350
- background: "inherit",
351
- zIndex: 1
352
- },
353
- "& .sticky-header": {
354
- position: "sticky",
355
- right: 0,
356
- backgroundColor: "#f4f6fa",
357
- zIndex: 2
358
- }
359
- },
360
- ...rest
318
+ ),
319
+ /* @__PURE__ */ jsx4(
320
+ DataGridPro,
321
+ {
322
+ apiRef,
323
+ rows: data,
324
+ columns,
325
+ onColumnOrderChange: _onColumnOrderChange,
326
+ onColumnWidthChange: _onColumnWidthChange,
327
+ onColumnVisibilityModelChange: _onColumnVisibilityModelChange,
328
+ density: "compact",
329
+ hideFooterPagination: true,
330
+ hideFooter: true,
331
+ loading: isLoading,
332
+ rowHeight: 43,
333
+ columnHeaderHeight: 43,
334
+ disableVirtualization: true,
335
+ disableRowSelectionOnClick: true,
336
+ rowSelectionModel: rowsSelectedId,
337
+ onRowSelectionModelChange: (rowSelectionModel, details) => {
338
+ if (onRowSelectionChange) {
339
+ onRowSelectionChange(rowSelectionModel, details);
340
+ }
341
+ if (controlledRowsSelectedId)
342
+ return;
343
+ setRowsSelectedId(rowSelectionModel);
344
+ },
345
+ slots: {
346
+ booleanCellFalseIcon: () => /* @__PURE__ */ jsx4(Circle, { color: "error", sx: { fontSize: "10pt" } }),
347
+ booleanCellTrueIcon: () => /* @__PURE__ */ jsx4(Circle, { color: "success", sx: { fontSize: "10pt" } }),
348
+ noRowsOverlay: () => !isLoading && !!error ? /* @__PURE__ */ jsx4(DataTableError, { errorMessage: error }) : /* @__PURE__ */ jsx4(DataTableEmptyData, {}),
349
+ ...slots
350
+ },
351
+ slotProps: {
352
+ loadingOverlay: {
353
+ variant: "skeleton",
354
+ noRowsVariant: "skeleton"
355
+ }
356
+ },
357
+ disableColumnFilter: true,
358
+ localeText: ptBR.components.MuiDataGrid.defaultProps.localeText,
359
+ sx: {
360
+ border: "none",
361
+ borderRadius: 0,
362
+ "--DataGrid-rowBorderColor": "#edf2f9",
363
+ "--DataGrid-containerBackground": "#f4f6fa",
364
+ ".MuiDataGrid-overlayWrapperInner": {
365
+ display: "flex",
366
+ alignItems: "center",
367
+ justifyContent: "center"
368
+ },
369
+ ".MuiDataGrid-row": {
370
+ backgroundColor: "white",
371
+ "&:nth-of-type(even)": {
372
+ backgroundColor: "#f9fafd"
373
+ },
374
+ ":hover": {
375
+ backgroundColor: "#e9e9e9"
376
+ },
377
+ "&.Mui-selected": {
378
+ backgroundColor: "rgb(238, 249, 252)",
379
+ "&:hover": {
380
+ backgroundColor: "rgb(222, 243, 249)"
381
+ }
382
+ }
383
+ },
384
+ ".MuiDataGrid-cell": {
385
+ fontSize: "12px",
386
+ color: "#0b0e14"
387
+ },
388
+ ".MuiDataGrid-columnHeaders": {
389
+ border: "solid 1px #edf2f9",
390
+ backgroundColor: "#f4f6fa"
391
+ },
392
+ ".MuiDataGrid-columnHeader": {
393
+ backgroundColor: "#f4f6fa"
394
+ },
395
+ ".MuiDataGrid-columnHeaders .MuiDataGrid-filler": {
396
+ backgroundColor: "#f4f6fa"
397
+ },
398
+ ".MuiDataGrid-columnHeaderTitle": {
399
+ fontSize: "12px",
400
+ color: "#0b0e14",
401
+ fontWeight: "600"
402
+ },
403
+ "& .sticky-cell": {
404
+ position: "sticky",
405
+ right: 0,
406
+ background: "inherit",
407
+ zIndex: 1
408
+ },
409
+ "& .sticky-header": {
410
+ position: "sticky",
411
+ right: 0,
412
+ backgroundColor: "#f4f6fa",
413
+ zIndex: 2
414
+ }
415
+ },
416
+ ...rest
417
+ }
418
+ )
419
+ ]
361
420
  }
362
- )
363
- ] });
364
- }
421
+ );
422
+ }
423
+ );
424
+ var DataTable_default = _DataTable;
365
425
 
366
426
  // src/DataTable/DataTableAction.tsx
367
427
  import {
@@ -383,132 +443,7 @@ function DataTableAction(props) {
383
443
  import {
384
444
  GridActionsCellItem as GridActionsCellItem2
385
445
  } from "@mui/x-data-grid-pro";
386
-
387
- // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
388
- import { forwardRef as forwardRef2, createElement as createElement2 } from "react";
389
-
390
- // ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
391
- var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
392
- var toCamelCase = (string) => string.replace(
393
- /^([A-Z])|[\s-_]+(\w)/g,
394
- (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
395
- );
396
- var toPascalCase = (string) => {
397
- const camelCase = toCamelCase(string);
398
- return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
399
- };
400
- var mergeClasses = (...classes) => classes.filter((className, index, array) => {
401
- return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
402
- }).join(" ").trim();
403
- var hasA11yProp = (props) => {
404
- for (const prop in props) {
405
- if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
406
- return true;
407
- }
408
- }
409
- };
410
-
411
- // ../../node_modules/lucide-react/dist/esm/Icon.js
412
- import { forwardRef, createElement } from "react";
413
-
414
- // ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
415
- var defaultAttributes = {
416
- xmlns: "http://www.w3.org/2000/svg",
417
- width: 24,
418
- height: 24,
419
- viewBox: "0 0 24 24",
420
- fill: "none",
421
- stroke: "currentColor",
422
- strokeWidth: 2,
423
- strokeLinecap: "round",
424
- strokeLinejoin: "round"
425
- };
426
-
427
- // ../../node_modules/lucide-react/dist/esm/Icon.js
428
- var Icon = forwardRef(
429
- ({
430
- color = "currentColor",
431
- size = 24,
432
- strokeWidth = 2,
433
- absoluteStrokeWidth,
434
- className = "",
435
- children,
436
- iconNode,
437
- ...rest
438
- }, ref) => createElement(
439
- "svg",
440
- {
441
- ref,
442
- ...defaultAttributes,
443
- width: size,
444
- height: size,
445
- stroke: color,
446
- strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
447
- className: mergeClasses("lucide", className),
448
- ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
449
- ...rest
450
- },
451
- [
452
- ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
453
- ...Array.isArray(children) ? children : [children]
454
- ]
455
- )
456
- );
457
-
458
- // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
459
- var createLucideIcon = (iconName, iconNode) => {
460
- const Component = forwardRef2(
461
- ({ className, ...props }, ref) => createElement2(Icon, {
462
- ref,
463
- iconNode,
464
- className: mergeClasses(
465
- `lucide-${toKebabCase(toPascalCase(iconName))}`,
466
- `lucide-${iconName}`,
467
- className
468
- ),
469
- ...props
470
- })
471
- );
472
- Component.displayName = toPascalCase(iconName);
473
- return Component;
474
- };
475
-
476
- // ../../node_modules/lucide-react/dist/esm/icons/arrow-big-down.js
477
- var __iconNode = [
478
- [
479
- "path",
480
- {
481
- d: "M15 11a1 1 0 0 0 1 1h2.939a1 1 0 0 1 .75 1.811l-6.835 6.836a1.207 1.207 0 0 1-1.707 0L4.31 13.81a1 1 0 0 1 .75-1.811H8a1 1 0 0 0 1-1V5a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1z",
482
- key: "1eaqc3"
483
- }
484
- ]
485
- ];
486
- var ArrowBigDown = createLucideIcon("arrow-big-down", __iconNode);
487
-
488
- // ../../node_modules/lucide-react/dist/esm/icons/pencil.js
489
- var __iconNode2 = [
490
- [
491
- "path",
492
- {
493
- d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
494
- key: "1a8usu"
495
- }
496
- ],
497
- ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
498
- ];
499
- var Pencil = createLucideIcon("pencil", __iconNode2);
500
-
501
- // ../../node_modules/lucide-react/dist/esm/icons/trash-2.js
502
- var __iconNode3 = [
503
- ["path", { d: "M10 11v6", key: "nco0om" }],
504
- ["path", { d: "M14 11v6", key: "outv1u" }],
505
- ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
506
- ["path", { d: "M3 6h18", key: "d0wm0j" }],
507
- ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
508
- ];
509
- var Trash2 = createLucideIcon("trash-2", __iconNode3);
510
-
511
- // src/DataTable/DataTableActionDelete.tsx
446
+ import { Trash2 } from "lucide-react";
512
447
  import { jsx as jsx6 } from "react/jsx-runtime";
513
448
  function DataTableActionDelete(props) {
514
449
  const { ref, ...rest } = props;
@@ -528,6 +463,7 @@ function DataTableActionDelete(props) {
528
463
  import {
529
464
  GridActionsCellItem as GridActionsCellItem3
530
465
  } from "@mui/x-data-grid-pro";
466
+ import { Pencil } from "lucide-react";
531
467
  import { jsx as jsx7 } from "react/jsx-runtime";
532
468
  function DataTableActionEdit(props) {
533
469
  const { ref, ...rest } = props;
@@ -572,6 +508,7 @@ function Actions({ children, breakpoints }) {
572
508
  import {
573
509
  GridActionsCellItem as GridActionsCellItem4
574
510
  } from "@mui/x-data-grid-pro";
511
+ import { ArrowBigDown } from "lucide-react";
575
512
  import { jsx as jsx9 } from "react/jsx-runtime";
576
513
  function DataTableActionTransport(props) {
577
514
  const { ref, ...rest } = props;
@@ -587,6 +524,18 @@ function DataTableActionTransport(props) {
587
524
  );
588
525
  }
589
526
 
527
+ // src/DataTable/DataTableAddPanelTrigger.tsx
528
+ import { useTheme as useTheme2 } from "@mui/material";
529
+ import { ToolbarButton } from "@mui/x-data-grid-pro";
530
+ import { SquarePlus } from "lucide-react";
531
+ import { jsx as jsx10 } from "react/jsx-runtime";
532
+ function DataTableAddPanelTrigger({
533
+ onClick
534
+ }) {
535
+ const theme = useTheme2();
536
+ return /* @__PURE__ */ jsx10(ToolbarButton, { onClick, children: /* @__PURE__ */ jsx10(SquarePlus, { color: theme.palette.primary.main, size: 18 }) });
537
+ }
538
+
590
539
  // src/DataTable/DataTableButton.tsx
591
540
  import {
592
541
  Button as MuiButton,
@@ -595,11 +544,11 @@ import {
595
544
  Tooltip,
596
545
  Box
597
546
  } from "@mui/material";
598
- import { Fragment, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
547
+ import { Fragment, jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
599
548
  function DataTableButton(props) {
600
549
  const { isLoading, startIcon, children, title, ...rest } = props;
601
550
  const { breakpoint } = useTableRootContext();
602
- return /* @__PURE__ */ jsx10(Fragment, { children: breakpoint ? /* @__PURE__ */ jsx10(Tooltip, { title: children, children: /* @__PURE__ */ jsxs4(
551
+ return /* @__PURE__ */ jsx11(Fragment, { children: breakpoint ? /* @__PURE__ */ jsx11(Tooltip, { title: children, children: /* @__PURE__ */ jsxs4(
603
552
  IconButton,
604
553
  {
605
554
  ...rest,
@@ -607,7 +556,7 @@ function DataTableButton(props) {
607
556
  disabled: isLoading ? true : rest.disabled,
608
557
  children: [
609
558
  startIcon,
610
- isLoading && /* @__PURE__ */ jsx10(
559
+ isLoading && /* @__PURE__ */ jsx11(
611
560
  CircularProgress,
612
561
  {
613
562
  color: "secondary",
@@ -624,7 +573,7 @@ function DataTableButton(props) {
624
573
  )
625
574
  ]
626
575
  }
627
- ) }) : /* @__PURE__ */ jsx10(
576
+ ) }) : /* @__PURE__ */ jsx11(
628
577
  MuiButton,
629
578
  {
630
579
  startIcon,
@@ -655,7 +604,7 @@ function DataTableButton(props) {
655
604
  textOverflow: "ellipsis"
656
605
  },
657
606
  children: [
658
- isLoading && /* @__PURE__ */ jsx10(
607
+ isLoading && /* @__PURE__ */ jsx11(
659
608
  CircularProgress,
660
609
  {
661
610
  color: "secondary",
@@ -678,16 +627,16 @@ function DataTableButton(props) {
678
627
 
679
628
  // src/DataTable/DataTableCellAction.tsx
680
629
  import { GridActionsCellItem as GridActionsCellItem5 } from "@mui/x-data-grid-pro";
681
- import { jsx as jsx11 } from "react/jsx-runtime";
630
+ import { jsx as jsx12 } from "react/jsx-runtime";
682
631
  function CellAction(props) {
683
632
  const { event, onClick, ...rest } = props;
684
- return /* @__PURE__ */ jsx11(
633
+ return /* @__PURE__ */ jsx12(
685
634
  GridActionsCellItem5,
686
635
  {
687
636
  label: "A\xE7\xE3o",
688
637
  onClick: () => {
689
638
  },
690
- icon: /* @__PURE__ */ jsx11("span", { children: "\u{1F527}" })
639
+ icon: /* @__PURE__ */ jsx12("span", { children: "\u{1F527}" })
691
640
  }
692
641
  );
693
642
  }
@@ -695,15 +644,15 @@ function CellAction(props) {
695
644
  // src/DataTable/DataTableCellActionDelete.tsx
696
645
  import { Delete as DeleteIcon } from "@mui/icons-material";
697
646
  import { GridActionsCellItem as GridActionsCellItem6 } from "@mui/x-data-grid-pro";
698
- import { jsx as jsx12 } from "react/jsx-runtime";
647
+ import { jsx as jsx13 } from "react/jsx-runtime";
699
648
  function CellActionDelete({
700
649
  onClick,
701
650
  ...rest
702
651
  }) {
703
- return /* @__PURE__ */ jsx12(
652
+ return /* @__PURE__ */ jsx13(
704
653
  GridActionsCellItem6,
705
654
  {
706
- icon: /* @__PURE__ */ jsx12(DeleteIcon, {}),
655
+ icon: /* @__PURE__ */ jsx13(DeleteIcon, {}),
707
656
  label: "Delete",
708
657
  color: "primary",
709
658
  onClick: () => {
@@ -718,15 +667,15 @@ function CellActionDelete({
718
667
  // src/DataTable/DataTableCellActionEdit.tsx
719
668
  import { Edit as EditIcon } from "@mui/icons-material";
720
669
  import { GridActionsCellItem as GridActionsCellItem7 } from "@mui/x-data-grid-pro";
721
- import { jsx as jsx13 } from "react/jsx-runtime";
670
+ import { jsx as jsx14 } from "react/jsx-runtime";
722
671
  function CellActionEdit({
723
672
  onClick,
724
673
  ...rest
725
674
  }) {
726
- return /* @__PURE__ */ jsx13(
675
+ return /* @__PURE__ */ jsx14(
727
676
  GridActionsCellItem7,
728
677
  {
729
- icon: /* @__PURE__ */ jsx13(EditIcon, {}),
678
+ icon: /* @__PURE__ */ jsx14(EditIcon, {}),
730
679
  label: "Edit",
731
680
  color: "primary",
732
681
  onClick: () => onClick && onClick("edit"),
@@ -737,10 +686,10 @@ function CellActionEdit({
737
686
 
738
687
  // src/DataTable/DataTableCellActions.tsx
739
688
  import { Children, cloneElement, isValidElement } from "react";
740
- import { Fragment as Fragment2, jsx as jsx14 } from "react/jsx-runtime";
689
+ import { Fragment as Fragment2, jsx as jsx15 } from "react/jsx-runtime";
741
690
  function CellActions(props) {
742
691
  const { children, onClick: onItemClick } = props;
743
- return /* @__PURE__ */ jsx14(Fragment2, { children: Children.map(children, (child) => {
692
+ return /* @__PURE__ */ jsx15(Fragment2, { children: Children.map(children, (child) => {
744
693
  if (isValidElement(child)) {
745
694
  return cloneElement(child, {
746
695
  onClick: onItemClick
@@ -752,15 +701,15 @@ function CellActions(props) {
752
701
  // src/DataTable/DataTableCellActionTransport.tsx
753
702
  import { GetApp as TransportIcon } from "@mui/icons-material";
754
703
  import { GridActionsCellItem as GridActionsCellItem8 } from "@mui/x-data-grid-pro";
755
- import { jsx as jsx15 } from "react/jsx-runtime";
704
+ import { jsx as jsx16 } from "react/jsx-runtime";
756
705
  function CellActionTransport({
757
706
  onClick,
758
707
  ...rest
759
708
  }) {
760
- return /* @__PURE__ */ jsx15(
709
+ return /* @__PURE__ */ jsx16(
761
710
  GridActionsCellItem8,
762
711
  {
763
- icon: /* @__PURE__ */ jsx15(TransportIcon, {}),
712
+ icon: /* @__PURE__ */ jsx16(TransportIcon, {}),
764
713
  label: "Transport",
765
714
  color: "primary",
766
715
  onClick: () => onClick && onClick("transport"),
@@ -769,11 +718,21 @@ function CellActionTransport({
769
718
  );
770
719
  }
771
720
 
721
+ // src/DataTable/DataTableColumnsPanelTrigger.tsx
722
+ import { useTheme as useTheme3 } from "@mui/material";
723
+ import { ColumnsPanelTrigger, ToolbarButton as ToolbarButton2 } from "@mui/x-data-grid-pro";
724
+ import { Columns3Cog } from "lucide-react";
725
+ import { jsx as jsx17 } from "react/jsx-runtime";
726
+ function DataTableColumnsPanelTrigger() {
727
+ const theme = useTheme3();
728
+ return /* @__PURE__ */ jsx17(ColumnsPanelTrigger, { render: /* @__PURE__ */ jsx17(ToolbarButton2, {}), children: /* @__PURE__ */ jsx17(Columns3Cog, { color: theme.palette.primary.main, size: 18 }) });
729
+ }
730
+
772
731
  // src/DataTable/DataTableContent.tsx
773
732
  import { Stack as Stack5 } from "@mui/material";
774
- import { jsx as jsx16 } from "react/jsx-runtime";
733
+ import { jsx as jsx18 } from "react/jsx-runtime";
775
734
  function Content(props) {
776
- return /* @__PURE__ */ jsx16(
735
+ return /* @__PURE__ */ jsx18(
777
736
  Stack5,
778
737
  {
779
738
  direction: "row",
@@ -792,8 +751,8 @@ import { FileDownload as FileDownloadIcon } from "@mui/icons-material";
792
751
  import {
793
752
  gridFilteredSortedRowIdsSelector as gridFilteredSortedRowIdsSelector2
794
753
  } from "@mui/x-data-grid-pro";
795
- import { jsx as jsx17 } from "react/jsx-runtime";
796
- var getFilteredRows2 = ({ apiRef }) => gridFilteredSortedRowIdsSelector2(apiRef);
754
+ import { jsx as jsx19 } from "react/jsx-runtime";
755
+ var getFilteredRows = ({ apiRef }) => gridFilteredSortedRowIdsSelector2(apiRef);
797
756
  function ExportCsvButton() {
798
757
  const { apiRef } = useTableRootContext();
799
758
  const handleExport = (options) => {
@@ -801,11 +760,11 @@ function ExportCsvButton() {
801
760
  apiRef.current.exportDataAsCsv(options);
802
761
  }
803
762
  };
804
- return /* @__PURE__ */ jsx17(
763
+ return /* @__PURE__ */ jsx19(
805
764
  DataTableButton,
806
765
  {
807
- startIcon: /* @__PURE__ */ jsx17(FileDownloadIcon, {}),
808
- onClick: () => handleExport({ getRowsToExport: getFilteredRows2 }),
766
+ startIcon: /* @__PURE__ */ jsx19(FileDownloadIcon, {}),
767
+ onClick: () => handleExport({ getRowsToExport: getFilteredRows }),
809
768
  children: "Exportar CSV"
810
769
  }
811
770
  );
@@ -813,9 +772,9 @@ function ExportCsvButton() {
813
772
 
814
773
  // src/DataTable/DataTableFooter.tsx
815
774
  import { TableFooter } from "@mui/material";
816
- import { jsx as jsx18 } from "react/jsx-runtime";
775
+ import { jsx as jsx20 } from "react/jsx-runtime";
817
776
  function Footer(props) {
818
- return /* @__PURE__ */ jsx18(
777
+ return /* @__PURE__ */ jsx20(
819
778
  TableFooter,
820
779
  {
821
780
  ...props,
@@ -845,8 +804,8 @@ import {
845
804
  TextField,
846
805
  Typography as Typography3
847
806
  } from "@mui/material";
848
- import { useMemo as useMemo2 } from "react";
849
- import { jsx as jsx19, jsxs as jsxs5 } from "react/jsx-runtime";
807
+ import { useMemo } from "react";
808
+ import { jsx as jsx21, jsxs as jsxs5 } from "react/jsx-runtime";
850
809
  function Pagination(props) {
851
810
  const {
852
811
  onChangePageSize,
@@ -855,14 +814,14 @@ function Pagination(props) {
855
814
  rowsPerPageOptions = [15, 50, 100, 200]
856
815
  } = props;
857
816
  const { page, pageSize = 15, totalRecords } = pagination || {};
858
- const pages = useMemo2(() => {
817
+ const pages = useMemo(() => {
859
818
  if (pagination?.lastPage)
860
819
  return pagination.lastPage;
861
820
  if ((totalRecords || 0) < pageSize)
862
821
  return 1;
863
822
  return Math.max(Math.ceil((totalRecords || 0) / pageSize));
864
823
  }, [totalRecords, pageSize]);
865
- const totalRecordsLabel = useMemo2(() => {
824
+ const totalRecordsLabel = useMemo(() => {
866
825
  if ((totalRecords || 0) < pageSize)
867
826
  return `Exibindo ${pluralizar(
868
827
  totalRecords || 0,
@@ -892,7 +851,7 @@ function Pagination(props) {
892
851
  gap: 2,
893
852
  marginLeft: "auto",
894
853
  children: [
895
- /* @__PURE__ */ jsx19(
854
+ /* @__PURE__ */ jsx21(
896
855
  Typography3,
897
856
  {
898
857
  variant: "body2",
@@ -903,7 +862,7 @@ function Pagination(props) {
903
862
  }
904
863
  ),
905
864
  showPagination && /* @__PURE__ */ jsxs5(Stack6, { direction: "row", alignItems: "center", gap: 2, marginLeft: "auto", children: [
906
- /* @__PURE__ */ jsx19(
865
+ /* @__PURE__ */ jsx21(
907
866
  TextField,
908
867
  {
909
868
  sx: {
@@ -918,10 +877,10 @@ function Pagination(props) {
918
877
  onChangePageSize(parseInt(e.target.value));
919
878
  }
920
879
  },
921
- children: rowsPerPageOptions.map((option) => /* @__PURE__ */ jsx19(MenuItem, { value: option, children: option }, option))
880
+ children: rowsPerPageOptions.map((option) => /* @__PURE__ */ jsx21(MenuItem, { value: option, children: option }, option))
922
881
  }
923
882
  ),
924
- /* @__PURE__ */ jsx19(
883
+ /* @__PURE__ */ jsx21(
925
884
  MuiPagination,
926
885
  {
927
886
  variant: "outlined",
@@ -946,7 +905,7 @@ function Pagination(props) {
946
905
  // src/DataTable/DataTableRoot.tsx
947
906
  import { useEffect as useEffect3, useRef, useState as useState2 } from "react";
948
907
  import { Stack as Stack7 } from "@mui/material";
949
- import { jsx as jsx20 } from "react/jsx-runtime";
908
+ import { jsx as jsx22 } from "react/jsx-runtime";
950
909
  function Root({ children, height, ...rest }) {
951
910
  const tableContainerRef = useRef(null);
952
911
  const [tableHeight, setTableHeight] = useState2(500);
@@ -964,7 +923,7 @@ function Root({ children, height, ...rest }) {
964
923
  window.removeEventListener("resize", calculateHeight);
965
924
  };
966
925
  }, []);
967
- return /* @__PURE__ */ jsx20(
926
+ return /* @__PURE__ */ jsx22(
968
927
  Stack7,
969
928
  {
970
929
  ref: tableContainerRef,
@@ -976,20 +935,20 @@ function Root({ children, height, ...rest }) {
976
935
  ...rest.sx
977
936
  },
978
937
  ...rest,
979
- children: /* @__PURE__ */ jsx20(TableRootProvider, { children })
938
+ children: /* @__PURE__ */ jsx22(TableRootProvider, { children })
980
939
  }
981
940
  );
982
941
  }
983
942
 
984
943
  // src/DataTable/DataTableSelectionCounter.tsx
985
944
  import { Stack as Stack8, Typography as Typography4 } from "@mui/material";
986
- import { useMemo as useMemo3 } from "react";
987
- import { jsx as jsx21, jsxs as jsxs6 } from "react/jsx-runtime";
945
+ import { useMemo as useMemo2 } from "react";
946
+ import { jsx as jsx23, jsxs as jsxs6 } from "react/jsx-runtime";
988
947
  function SelectionCounter(props) {
989
948
  const { countTitle, gender } = props;
990
949
  const { rowsSelectedId } = useTableRootContext();
991
950
  const countQuantidade = rowsSelectedId?.ids.size || 0;
992
- const flexSufixCountTitle = useMemo3(() => {
951
+ const flexSufixCountTitle = useMemo2(() => {
993
952
  if (!countTitle)
994
953
  return "";
995
954
  const selecionadoText = gender === "feminino" ? "selecionada" : "selecionado";
@@ -997,7 +956,7 @@ function SelectionCounter(props) {
997
956
  const nenhumText = gender === "feminino" ? "Nenhuma" : "Nenhum";
998
957
  return countQuantidade === 1 ? `${countTitle} ${selecionadoText}` : countQuantidade && countQuantidade > 1 ? `${countTitle.split(" ").map((item) => `${item}s`).join(" ")} ${selecionadosText}` : `${nenhumText} ${countTitle} ${selecionadoText}`;
999
958
  }, [countQuantidade]);
1000
- return /* @__PURE__ */ jsx21(Stack8, { children: /* @__PURE__ */ jsxs6(
959
+ return /* @__PURE__ */ jsx23(Stack8, { children: /* @__PURE__ */ jsxs6(
1001
960
  Typography4,
1002
961
  {
1003
962
  variant: "body2",
@@ -1014,15 +973,15 @@ function SelectionCounter(props) {
1014
973
  }
1015
974
 
1016
975
  // src/DataTable/DataTableTitle.tsx
1017
- import { Typography as Typography5, useTheme as useTheme2 } from "@mui/material";
1018
- import { jsx as jsx22 } from "react/jsx-runtime";
976
+ import { Typography as Typography5, useTheme as useTheme4 } from "@mui/material";
977
+ import { jsx as jsx24 } from "react/jsx-runtime";
1019
978
  function Title({
1020
979
  children,
1021
980
  titleDivider = false,
1022
981
  sx
1023
982
  }) {
1024
- const theme = useTheme2();
1025
- return /* @__PURE__ */ jsx22(
983
+ const theme = useTheme4();
984
+ return /* @__PURE__ */ jsx24(
1026
985
  Typography5,
1027
986
  {
1028
987
  variant: "h6",
@@ -1039,25 +998,40 @@ function Title({
1039
998
 
1040
999
  // src/DataTable/DataTableToolbar.tsx
1041
1000
  import { Paper, Stack as Stack9 } from "@mui/material";
1042
- import { jsx as jsx23 } from "react/jsx-runtime";
1001
+ import { Toolbar as MuiToolbar } from "@mui/x-data-grid-pro";
1002
+ import { jsx as jsx25 } from "react/jsx-runtime";
1043
1003
  function Toolbar({ children }) {
1044
- return /* @__PURE__ */ jsx23(
1045
- Stack9,
1004
+ return /* @__PURE__ */ jsx25(
1005
+ MuiToolbar,
1046
1006
  {
1047
- component: Paper,
1048
- elevation: 0,
1049
- gap: 1.5,
1050
- flexDirection: "row",
1051
- justifyContent: "space-between",
1052
- alignItems: "center",
1053
- p: 1,
1054
- borderRadius: "8px 8px 0 0",
1055
- sx: { width: "100%" },
1056
- children
1007
+ render: /* @__PURE__ */ jsx25(
1008
+ Stack9,
1009
+ {
1010
+ component: Paper,
1011
+ elevation: 0,
1012
+ gap: 1.5,
1013
+ flexDirection: "row",
1014
+ justifyContent: "space-between",
1015
+ alignItems: "center",
1016
+ p: 1,
1017
+ borderRadius: "8px 8px 0 0",
1018
+ sx: { width: "100%" },
1019
+ children
1020
+ }
1021
+ )
1057
1022
  }
1058
1023
  );
1059
1024
  }
1060
1025
 
1026
+ // src/DataTable/DataTableToolbarActionsContainer.tsx
1027
+ import { Stack as Stack10 } from "@mui/material";
1028
+ import { jsx as jsx26 } from "react/jsx-runtime";
1029
+ function ToolbarActionsContainer({
1030
+ children
1031
+ }) {
1032
+ return /* @__PURE__ */ jsx26(Stack10, { direction: "row", alignItems: "center", justifyContent: "flex-end", children });
1033
+ }
1034
+
1061
1035
  // src/DataTable/index.ts
1062
1036
  var DataTable = {
1063
1037
  CellActionTransport,
@@ -1070,87 +1044,23 @@ var DataTable = {
1070
1044
  Pagination,
1071
1045
  Actions,
1072
1046
  Toolbar,
1047
+ ToolbarActionsContainer,
1073
1048
  Content,
1074
1049
  Button: DataTableButton,
1075
1050
  Footer,
1076
- Table,
1051
+ Table: DataTable_default,
1077
1052
  Title,
1078
1053
  Root,
1079
1054
  Action: DataTableAction,
1080
1055
  ActionEdit: DataTableActionEdit,
1081
1056
  ActionDelete: DataTableActionDelete,
1082
1057
  ActionTransport: DataTableActionTransport,
1083
- ColumnsPanelTrigger,
1058
+ ColumnsPanelTrigger: DataTableColumnsPanelTrigger,
1059
+ AddPanelTrigger: DataTableAddPanelTrigger,
1084
1060
  useGridApiRef: useGridApiRef2
1085
1061
  };
1086
- var DataTable_default = DataTable;
1062
+ var DataTable_default2 = DataTable;
1087
1063
  export {
1088
- DataTable_default as DataTable
1064
+ DataTable_default2 as DataTable
1089
1065
  };
1090
- /*! Bundled license information:
1091
-
1092
- lucide-react/dist/esm/shared/src/utils.js:
1093
- (**
1094
- * @license lucide-react v0.536.0 - ISC
1095
- *
1096
- * This source code is licensed under the ISC license.
1097
- * See the LICENSE file in the root directory of this source tree.
1098
- *)
1099
-
1100
- lucide-react/dist/esm/defaultAttributes.js:
1101
- (**
1102
- * @license lucide-react v0.536.0 - ISC
1103
- *
1104
- * This source code is licensed under the ISC license.
1105
- * See the LICENSE file in the root directory of this source tree.
1106
- *)
1107
-
1108
- lucide-react/dist/esm/Icon.js:
1109
- (**
1110
- * @license lucide-react v0.536.0 - ISC
1111
- *
1112
- * This source code is licensed under the ISC license.
1113
- * See the LICENSE file in the root directory of this source tree.
1114
- *)
1115
-
1116
- lucide-react/dist/esm/createLucideIcon.js:
1117
- (**
1118
- * @license lucide-react v0.536.0 - ISC
1119
- *
1120
- * This source code is licensed under the ISC license.
1121
- * See the LICENSE file in the root directory of this source tree.
1122
- *)
1123
-
1124
- lucide-react/dist/esm/icons/arrow-big-down.js:
1125
- (**
1126
- * @license lucide-react v0.536.0 - ISC
1127
- *
1128
- * This source code is licensed under the ISC license.
1129
- * See the LICENSE file in the root directory of this source tree.
1130
- *)
1131
-
1132
- lucide-react/dist/esm/icons/pencil.js:
1133
- (**
1134
- * @license lucide-react v0.536.0 - ISC
1135
- *
1136
- * This source code is licensed under the ISC license.
1137
- * See the LICENSE file in the root directory of this source tree.
1138
- *)
1139
-
1140
- lucide-react/dist/esm/icons/trash-2.js:
1141
- (**
1142
- * @license lucide-react v0.536.0 - ISC
1143
- *
1144
- * This source code is licensed under the ISC license.
1145
- * See the LICENSE file in the root directory of this source tree.
1146
- *)
1147
-
1148
- lucide-react/dist/esm/lucide-react.js:
1149
- (**
1150
- * @license lucide-react v0.536.0 - ISC
1151
- *
1152
- * This source code is licensed under the ISC license.
1153
- * See the LICENSE file in the root directory of this source tree.
1154
- *)
1155
- */
1156
1066
  //# sourceMappingURL=index.mjs.map