mytek-components 2.0.5 → 2.0.6
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/main.es.js +176 -113
- package/dist/main.es.js.map +1 -1
- package/dist/main.umd.js +174 -111
- package/dist/main.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/main.es.js
CHANGED
|
@@ -5,9 +5,9 @@ import * as React from "react";
|
|
|
5
5
|
import React__default, { useState, useRef, useEffect, useCallback, useContext, useMemo, useLayoutEffect, createContext, cloneElement, forwardRef, createElement } from "react";
|
|
6
6
|
import emStyled from "@emotion/styled";
|
|
7
7
|
import "@emotion/react";
|
|
8
|
-
import { FormControlLabel, Radio, IconButton, Menu, MenuItem, Divider, Box, TextField, FormControl as FormControl$2, Select, Button as Button$1, Typography, Checkbox, Tabs, Tab, TableContainer, Paper, Table as Table$1, TableHead, TableRow, TableCell, TableBody, useMediaQuery, InputAdornment, Tooltip as Tooltip$3, CircularProgress, ListItemIcon, ListItemText
|
|
8
|
+
import { FormControlLabel, Radio, IconButton, Menu, MenuItem, Divider, Box, TextField, FormControl as FormControl$2, Select, Button as Button$1, Typography, Checkbox, Tabs, Tab, TableContainer, Paper, Table as Table$1, TableHead, TableRow, TableCell, TableBody, useMediaQuery, InputAdornment, Popover as Popover$2, Tooltip as Tooltip$3, CircularProgress, ListItemIcon, ListItemText } from "@mui/material";
|
|
9
9
|
import ReactDOM from "react-dom";
|
|
10
|
-
import { useMaterialReactTable, MRT_ToggleFiltersButton, MRT_ToggleDensePaddingButton, MRT_ShowHideColumnsButton, MRT_ToggleFullScreenButton
|
|
10
|
+
import { useMaterialReactTable, MaterialReactTable, MRT_ToggleFiltersButton, MRT_ToggleDensePaddingButton, MRT_ShowHideColumnsButton, MRT_ToggleFullScreenButton } from "material-react-table";
|
|
11
11
|
import { LocalizationProvider, DatePicker } from "@mui/x-date-pickers";
|
|
12
12
|
import dayjs from "dayjs";
|
|
13
13
|
import * as XLSX from "xlsx";
|
|
@@ -18184,104 +18184,18 @@ function SmartGridTable({
|
|
|
18184
18184
|
}
|
|
18185
18185
|
},
|
|
18186
18186
|
//render top menu
|
|
18187
|
-
renderTopToolbar: ({ table: table2 }) =>
|
|
18188
|
-
|
|
18189
|
-
|
|
18190
|
-
|
|
18191
|
-
|
|
18192
|
-
|
|
18193
|
-
|
|
18194
|
-
|
|
18195
|
-
|
|
18196
|
-
|
|
18197
|
-
|
|
18198
|
-
|
|
18199
|
-
const exportData = table2.getFilteredRowModel().rows.map((row) => row.original);
|
|
18200
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { sx: { px: 2, py: 2 }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
18201
|
-
Box,
|
|
18202
|
-
{
|
|
18203
|
-
sx: {
|
|
18204
|
-
display: "grid",
|
|
18205
|
-
gridTemplateColumns: {
|
|
18206
|
-
xs: "1fr",
|
|
18207
|
-
sm: "1fr auto"
|
|
18208
|
-
},
|
|
18209
|
-
gap: 2,
|
|
18210
|
-
alignItems: "center",
|
|
18211
|
-
width: "100%"
|
|
18212
|
-
},
|
|
18213
|
-
children: [
|
|
18214
|
-
(topToolbar == null ? void 0 : topToolbar.globalSearch) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18215
|
-
TextField,
|
|
18216
|
-
{
|
|
18217
|
-
size: "small",
|
|
18218
|
-
fullWidth: true,
|
|
18219
|
-
disabled: disable,
|
|
18220
|
-
placeholder: isLoading ? "Loading..." : safeColumns.length === 0 ? "No columns configured" : safeData.length === 0 ? "No data available" : "Search...",
|
|
18221
|
-
value: searchValue,
|
|
18222
|
-
onChange: (e) => setSearchValue(e.target.value),
|
|
18223
|
-
InputProps: {
|
|
18224
|
-
startAdornment: /* @__PURE__ */ jsxRuntimeExports.jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchCheck, {}) })
|
|
18225
|
-
},
|
|
18226
|
-
sx: {
|
|
18227
|
-
"& .MuiOutlinedInput-root": {
|
|
18228
|
-
borderRadius: 1.5,
|
|
18229
|
-
"& fieldset": { borderColor: mergedTheme == null ? void 0 : mergedTheme.headerBg },
|
|
18230
|
-
"&:hover fieldset": { borderColor: mergedTheme == null ? void 0 : mergedTheme.headerBg },
|
|
18231
|
-
"&.Mui-focused fieldset": {
|
|
18232
|
-
borderColor: mergedTheme == null ? void 0 : mergedTheme.headerBg,
|
|
18233
|
-
borderWidth: 2
|
|
18234
|
-
}
|
|
18235
|
-
},
|
|
18236
|
-
"& .MuiOutlinedInput-input::placeholder": {
|
|
18237
|
-
opacity: 0.7
|
|
18238
|
-
},
|
|
18239
|
-
"& .MuiInputAdornment-root svg": {
|
|
18240
|
-
color: mergedTheme == null ? void 0 : mergedTheme.headerBg
|
|
18241
|
-
}
|
|
18242
|
-
}
|
|
18243
|
-
}
|
|
18244
|
-
),
|
|
18245
|
-
((topToolbar == null ? void 0 : topToolbar.exportBtn) || (topToolbar == null ? void 0 : topToolbar.columnFilters) || (topToolbar == null ? void 0 : topToolbar.densityToggle) || (topToolbar == null ? void 0 : topToolbar.showHideColumnsBtn) || (topToolbar == null ? void 0 : topToolbar.fullscreenToggle)) && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
18246
|
-
Paper,
|
|
18247
|
-
{
|
|
18248
|
-
elevation: 3,
|
|
18249
|
-
sx: {
|
|
18250
|
-
justifySelf: "end",
|
|
18251
|
-
// ✅ THIS IS THE KEY
|
|
18252
|
-
display: "inline-flex",
|
|
18253
|
-
alignItems: "center",
|
|
18254
|
-
width: "fit-content",
|
|
18255
|
-
px: 1,
|
|
18256
|
-
py: 0.2,
|
|
18257
|
-
borderRadius: 2,
|
|
18258
|
-
bgcolor: "background.paper",
|
|
18259
|
-
border: `1px solid ${mergedTheme == null ? void 0 : mergedTheme.headerBg}`,
|
|
18260
|
-
whiteSpace: "nowrap",
|
|
18261
|
-
opacity: disable ? 0.6 : 1,
|
|
18262
|
-
pointerEvents: disable ? "none" : "auto"
|
|
18263
|
-
},
|
|
18264
|
-
children: [
|
|
18265
|
-
(topToolbar == null ? void 0 : topToolbar.exportBtn) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18266
|
-
ExportButton,
|
|
18267
|
-
{
|
|
18268
|
-
data: exportData,
|
|
18269
|
-
color: mergedTheme == null ? void 0 : mergedTheme.headerBg,
|
|
18270
|
-
filename: "table-data",
|
|
18271
|
-
disabled: disable
|
|
18272
|
-
}
|
|
18273
|
-
),
|
|
18274
|
-
(topToolbar == null ? void 0 : topToolbar.columnFilters) && /* @__PURE__ */ jsxRuntimeExports.jsx(MRT_ToggleFiltersButton, { table: table2, disabled: disable }),
|
|
18275
|
-
(topToolbar == null ? void 0 : topToolbar.densityToggle) && /* @__PURE__ */ jsxRuntimeExports.jsx(MRT_ToggleDensePaddingButton, { table: table2, disabled: disable }),
|
|
18276
|
-
(topToolbar == null ? void 0 : topToolbar.showHideColumnsBtn) && /* @__PURE__ */ jsxRuntimeExports.jsx(MRT_ShowHideColumnsButton, { table: table2, disabled: disable }),
|
|
18277
|
-
(topToolbar == null ? void 0 : topToolbar.fullscreenToggle) && /* @__PURE__ */ jsxRuntimeExports.jsx(MRT_ToggleFullScreenButton, { table: table2, disabled: disable })
|
|
18278
|
-
]
|
|
18279
|
-
}
|
|
18280
|
-
)
|
|
18281
|
-
]
|
|
18282
|
-
}
|
|
18283
|
-
) }) });
|
|
18284
|
-
},
|
|
18187
|
+
renderTopToolbar: ({ table: table2 }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18188
|
+
SmartGridTopToolbar,
|
|
18189
|
+
{
|
|
18190
|
+
table: table2,
|
|
18191
|
+
theme: mergedTheme,
|
|
18192
|
+
topToolbar,
|
|
18193
|
+
isGridDisabled,
|
|
18194
|
+
isLoading,
|
|
18195
|
+
safeColumns,
|
|
18196
|
+
safeData
|
|
18197
|
+
}
|
|
18198
|
+
),
|
|
18285
18199
|
/* ===============================
|
|
18286
18200
|
INITIAL STATE
|
|
18287
18201
|
================================ */
|
|
@@ -18324,18 +18238,29 @@ function SmartGridTable({
|
|
|
18324
18238
|
/* ===============================
|
|
18325
18239
|
ROOT (TABLE WRAPPER)
|
|
18326
18240
|
================================ */
|
|
18327
|
-
muiTablePaperProps:
|
|
18328
|
-
|
|
18329
|
-
|
|
18330
|
-
|
|
18331
|
-
|
|
18332
|
-
|
|
18333
|
-
|
|
18334
|
-
|
|
18335
|
-
|
|
18336
|
-
|
|
18337
|
-
|
|
18338
|
-
|
|
18241
|
+
muiTablePaperProps: useCallback(
|
|
18242
|
+
({ table: table2 }) => {
|
|
18243
|
+
const isFullScreen = table2.getState().isFullScreen;
|
|
18244
|
+
return {
|
|
18245
|
+
elevation: 0,
|
|
18246
|
+
sx: {
|
|
18247
|
+
height: height2,
|
|
18248
|
+
width: width2,
|
|
18249
|
+
display: "flex",
|
|
18250
|
+
flexDirection: "column",
|
|
18251
|
+
border: `1px solid ${mergedTheme.border}`,
|
|
18252
|
+
backgroundColor: mergedTheme.bodyBg,
|
|
18253
|
+
...isFullScreen && {
|
|
18254
|
+
position: "fixed",
|
|
18255
|
+
inset: 0,
|
|
18256
|
+
borderRadius: 0,
|
|
18257
|
+
zIndex: "9999999 !important"
|
|
18258
|
+
}
|
|
18259
|
+
}
|
|
18260
|
+
};
|
|
18261
|
+
},
|
|
18262
|
+
[height2, width2, mergedTheme]
|
|
18263
|
+
),
|
|
18339
18264
|
/* ===============================
|
|
18340
18265
|
TOP TOOLBAR (STICKY)
|
|
18341
18266
|
================================ */
|
|
@@ -18456,6 +18381,112 @@ function SmartGridTable({
|
|
|
18456
18381
|
});
|
|
18457
18382
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(MaterialReactTable, { table });
|
|
18458
18383
|
}
|
|
18384
|
+
function SmartGridTopToolbar({
|
|
18385
|
+
table,
|
|
18386
|
+
theme,
|
|
18387
|
+
topToolbar,
|
|
18388
|
+
isGridDisabled,
|
|
18389
|
+
isLoading,
|
|
18390
|
+
safeColumns,
|
|
18391
|
+
safeData
|
|
18392
|
+
}) {
|
|
18393
|
+
const [searchValue, setSearchValue] = useState(
|
|
18394
|
+
table.getState().globalFilter ?? ""
|
|
18395
|
+
);
|
|
18396
|
+
const disable = isGridDisabled;
|
|
18397
|
+
useEffect(() => {
|
|
18398
|
+
if (disable) return;
|
|
18399
|
+
const t = setTimeout(() => {
|
|
18400
|
+
table.setGlobalFilter(searchValue || void 0);
|
|
18401
|
+
}, 300);
|
|
18402
|
+
return () => clearTimeout(t);
|
|
18403
|
+
}, [searchValue, table, disable]);
|
|
18404
|
+
const exportData = table.getFilteredRowModel().rows.map((row) => row.original);
|
|
18405
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { sx: { px: 2, py: 2 }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
18406
|
+
Box,
|
|
18407
|
+
{
|
|
18408
|
+
sx: {
|
|
18409
|
+
display: "grid",
|
|
18410
|
+
gridTemplateColumns: {
|
|
18411
|
+
xs: "1fr",
|
|
18412
|
+
sm: "1fr auto"
|
|
18413
|
+
},
|
|
18414
|
+
gap: 2,
|
|
18415
|
+
alignItems: "center",
|
|
18416
|
+
width: "100%"
|
|
18417
|
+
},
|
|
18418
|
+
children: [
|
|
18419
|
+
(topToolbar == null ? void 0 : topToolbar.globalSearch) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18420
|
+
TextField,
|
|
18421
|
+
{
|
|
18422
|
+
size: "small",
|
|
18423
|
+
fullWidth: true,
|
|
18424
|
+
disabled: disable,
|
|
18425
|
+
placeholder: isLoading ? "Loading..." : safeColumns.length === 0 ? "No columns configured" : safeData.length === 0 ? "No data available" : "Search...",
|
|
18426
|
+
value: searchValue,
|
|
18427
|
+
onChange: (e) => setSearchValue(e.target.value),
|
|
18428
|
+
InputProps: {
|
|
18429
|
+
startAdornment: /* @__PURE__ */ jsxRuntimeExports.jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchCheck, {}) })
|
|
18430
|
+
},
|
|
18431
|
+
sx: {
|
|
18432
|
+
"& .MuiOutlinedInput-root": {
|
|
18433
|
+
borderRadius: 1.5,
|
|
18434
|
+
"& fieldset": { borderColor: theme == null ? void 0 : theme.headerBg },
|
|
18435
|
+
"&:hover fieldset": { borderColor: theme == null ? void 0 : theme.headerBg },
|
|
18436
|
+
"&.Mui-focused fieldset": {
|
|
18437
|
+
borderColor: theme == null ? void 0 : theme.headerBg,
|
|
18438
|
+
borderWidth: 2
|
|
18439
|
+
}
|
|
18440
|
+
},
|
|
18441
|
+
"& .MuiOutlinedInput-input::placeholder": {
|
|
18442
|
+
opacity: 0.7
|
|
18443
|
+
},
|
|
18444
|
+
"& .MuiInputAdornment-root svg": {
|
|
18445
|
+
color: theme == null ? void 0 : theme.headerBg
|
|
18446
|
+
}
|
|
18447
|
+
}
|
|
18448
|
+
}
|
|
18449
|
+
),
|
|
18450
|
+
((topToolbar == null ? void 0 : topToolbar.exportBtn) || (topToolbar == null ? void 0 : topToolbar.columnFilters) || (topToolbar == null ? void 0 : topToolbar.densityToggle) || (topToolbar == null ? void 0 : topToolbar.showHideColumnsBtn) || (topToolbar == null ? void 0 : topToolbar.fullscreenToggle)) && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
18451
|
+
Paper,
|
|
18452
|
+
{
|
|
18453
|
+
elevation: 3,
|
|
18454
|
+
sx: {
|
|
18455
|
+
justifySelf: "end",
|
|
18456
|
+
// ✅ THIS IS THE KEY
|
|
18457
|
+
display: "inline-flex",
|
|
18458
|
+
alignItems: "center",
|
|
18459
|
+
width: "fit-content",
|
|
18460
|
+
px: 1,
|
|
18461
|
+
py: 0.2,
|
|
18462
|
+
borderRadius: 2,
|
|
18463
|
+
bgcolor: "background.paper",
|
|
18464
|
+
border: `1px solid ${theme == null ? void 0 : theme.headerBg}`,
|
|
18465
|
+
whiteSpace: "nowrap",
|
|
18466
|
+
opacity: disable ? 0.6 : 1,
|
|
18467
|
+
pointerEvents: disable ? "none" : "auto"
|
|
18468
|
+
},
|
|
18469
|
+
children: [
|
|
18470
|
+
(topToolbar == null ? void 0 : topToolbar.exportBtn) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18471
|
+
ExportButton,
|
|
18472
|
+
{
|
|
18473
|
+
data: exportData,
|
|
18474
|
+
color: theme == null ? void 0 : theme.headerBg,
|
|
18475
|
+
filename: "table-data",
|
|
18476
|
+
disabled: disable
|
|
18477
|
+
}
|
|
18478
|
+
),
|
|
18479
|
+
(topToolbar == null ? void 0 : topToolbar.columnFilters) && /* @__PURE__ */ jsxRuntimeExports.jsx(MRT_ToggleFiltersButton, { table, disabled: disable }),
|
|
18480
|
+
(topToolbar == null ? void 0 : topToolbar.densityToggle) && /* @__PURE__ */ jsxRuntimeExports.jsx(MRT_ToggleDensePaddingButton, { table, disabled: disable }),
|
|
18481
|
+
(topToolbar == null ? void 0 : topToolbar.showHideColumnsBtn) && /* @__PURE__ */ jsxRuntimeExports.jsx(MRT_ShowHideColumnsButton, { table, disabled: disable }),
|
|
18482
|
+
(topToolbar == null ? void 0 : topToolbar.fullscreenToggle) && /* @__PURE__ */ jsxRuntimeExports.jsx(MRT_ToggleFullScreenButton, { table, disabled: disable })
|
|
18483
|
+
]
|
|
18484
|
+
}
|
|
18485
|
+
)
|
|
18486
|
+
]
|
|
18487
|
+
}
|
|
18488
|
+
) });
|
|
18489
|
+
}
|
|
18459
18490
|
const ExportButton = ({
|
|
18460
18491
|
data,
|
|
18461
18492
|
filename = "data",
|
|
@@ -18561,7 +18592,39 @@ const ExportButton = ({
|
|
|
18561
18592
|
)
|
|
18562
18593
|
] });
|
|
18563
18594
|
};
|
|
18564
|
-
const SmartTable = (
|
|
18595
|
+
const SmartTable = ({
|
|
18596
|
+
controls = {
|
|
18597
|
+
columnActions: true,
|
|
18598
|
+
dragging: true,
|
|
18599
|
+
colPinning: true,
|
|
18600
|
+
pagination: true,
|
|
18601
|
+
rowSelection: false,
|
|
18602
|
+
rowPinning: false,
|
|
18603
|
+
grouping: false,
|
|
18604
|
+
sorting: true,
|
|
18605
|
+
editing: false,
|
|
18606
|
+
resizing: true
|
|
18607
|
+
},
|
|
18608
|
+
topToolbar = {
|
|
18609
|
+
enabled: true,
|
|
18610
|
+
globalSearch: true,
|
|
18611
|
+
columnFilters: true,
|
|
18612
|
+
densityToggle: true,
|
|
18613
|
+
fullscreenToggle: true,
|
|
18614
|
+
exportBtn: true,
|
|
18615
|
+
showHideColumnsBtn: true
|
|
18616
|
+
},
|
|
18617
|
+
height: height2 = "100%",
|
|
18618
|
+
width: width2 = "100%",
|
|
18619
|
+
columns = [],
|
|
18620
|
+
data = [],
|
|
18621
|
+
isLoading = false,
|
|
18622
|
+
onRowSelectionChange = () => {
|
|
18623
|
+
}
|
|
18624
|
+
}) => {
|
|
18625
|
+
const props = { controls, topToolbar, height: height2, width: width2, isLoading, columns, data, onRowSelectionChange };
|
|
18626
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SmartGridTable, { ...props }) });
|
|
18627
|
+
};
|
|
18565
18628
|
export {
|
|
18566
18629
|
ComboDropdown as MytekComboDropdown,
|
|
18567
18630
|
CustomInput as MytekInputField,
|