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.umd.js CHANGED
@@ -18196,104 +18196,18 @@ To suppress this warning, you need to explicitly provide the \`palette.${key}Cha
18196
18196
  }
18197
18197
  },
18198
18198
  //render top menu
18199
- renderTopToolbar: ({ table: table2 }) => {
18200
- const [searchValue, setSearchValue] = React.useState(
18201
- table2.getState().globalFilter ?? ""
18202
- );
18203
- const disable = isGridDisabled;
18204
- React.useEffect(() => {
18205
- if (disable) return;
18206
- const timeout = setTimeout(() => {
18207
- table2.setGlobalFilter(searchValue || void 0);
18208
- }, 300);
18209
- return () => clearTimeout(timeout);
18210
- }, [searchValue, table2, disable]);
18211
- const exportData = table2.getFilteredRowModel().rows.map((row) => row.original);
18212
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(material.Box, { sx: { px: 2, py: 2 }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
18213
- material.Box,
18214
- {
18215
- sx: {
18216
- display: "grid",
18217
- gridTemplateColumns: {
18218
- xs: "1fr",
18219
- sm: "1fr auto"
18220
- },
18221
- gap: 2,
18222
- alignItems: "center",
18223
- width: "100%"
18224
- },
18225
- children: [
18226
- (topToolbar == null ? void 0 : topToolbar.globalSearch) && /* @__PURE__ */ jsxRuntimeExports.jsx(
18227
- material.TextField,
18228
- {
18229
- size: "small",
18230
- fullWidth: true,
18231
- disabled: disable,
18232
- placeholder: isLoading ? "Loading..." : safeColumns.length === 0 ? "No columns configured" : safeData.length === 0 ? "No data available" : "Search...",
18233
- value: searchValue,
18234
- onChange: (e) => setSearchValue(e.target.value),
18235
- InputProps: {
18236
- startAdornment: /* @__PURE__ */ jsxRuntimeExports.jsx(material.InputAdornment, { position: "start", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchCheck, {}) })
18237
- },
18238
- sx: {
18239
- "& .MuiOutlinedInput-root": {
18240
- borderRadius: 1.5,
18241
- "& fieldset": { borderColor: mergedTheme == null ? void 0 : mergedTheme.headerBg },
18242
- "&:hover fieldset": { borderColor: mergedTheme == null ? void 0 : mergedTheme.headerBg },
18243
- "&.Mui-focused fieldset": {
18244
- borderColor: mergedTheme == null ? void 0 : mergedTheme.headerBg,
18245
- borderWidth: 2
18246
- }
18247
- },
18248
- "& .MuiOutlinedInput-input::placeholder": {
18249
- opacity: 0.7
18250
- },
18251
- "& .MuiInputAdornment-root svg": {
18252
- color: mergedTheme == null ? void 0 : mergedTheme.headerBg
18253
- }
18254
- }
18255
- }
18256
- ),
18257
- ((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(
18258
- material.Paper,
18259
- {
18260
- elevation: 3,
18261
- sx: {
18262
- justifySelf: "end",
18263
- // ✅ THIS IS THE KEY
18264
- display: "inline-flex",
18265
- alignItems: "center",
18266
- width: "fit-content",
18267
- px: 1,
18268
- py: 0.2,
18269
- borderRadius: 2,
18270
- bgcolor: "background.paper",
18271
- border: `1px solid ${mergedTheme == null ? void 0 : mergedTheme.headerBg}`,
18272
- whiteSpace: "nowrap",
18273
- opacity: disable ? 0.6 : 1,
18274
- pointerEvents: disable ? "none" : "auto"
18275
- },
18276
- children: [
18277
- (topToolbar == null ? void 0 : topToolbar.exportBtn) && /* @__PURE__ */ jsxRuntimeExports.jsx(
18278
- ExportButton,
18279
- {
18280
- data: exportData,
18281
- color: mergedTheme == null ? void 0 : mergedTheme.headerBg,
18282
- filename: "table-data",
18283
- disabled: disable
18284
- }
18285
- ),
18286
- (topToolbar == null ? void 0 : topToolbar.columnFilters) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ToggleFiltersButton, { table: table2, disabled: disable }),
18287
- (topToolbar == null ? void 0 : topToolbar.densityToggle) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ToggleDensePaddingButton, { table: table2, disabled: disable }),
18288
- (topToolbar == null ? void 0 : topToolbar.showHideColumnsBtn) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ShowHideColumnsButton, { table: table2, disabled: disable }),
18289
- (topToolbar == null ? void 0 : topToolbar.fullscreenToggle) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ToggleFullScreenButton, { table: table2, disabled: disable })
18290
- ]
18291
- }
18292
- )
18293
- ]
18294
- }
18295
- ) }) });
18296
- },
18199
+ renderTopToolbar: ({ table: table2 }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
18200
+ SmartGridTopToolbar,
18201
+ {
18202
+ table: table2,
18203
+ theme: mergedTheme,
18204
+ topToolbar,
18205
+ isGridDisabled,
18206
+ isLoading,
18207
+ safeColumns,
18208
+ safeData
18209
+ }
18210
+ ),
18297
18211
  /* ===============================
18298
18212
  INITIAL STATE
18299
18213
  ================================ */
@@ -18336,18 +18250,29 @@ To suppress this warning, you need to explicitly provide the \`palette.${key}Cha
18336
18250
  /* ===============================
18337
18251
  ROOT (TABLE WRAPPER)
18338
18252
  ================================ */
18339
- muiTablePaperProps: {
18340
- elevation: 0,
18341
- sx: {
18342
- height: height2,
18343
- width: width2,
18344
- display: "flex",
18345
- flexDirection: "column",
18346
- border: `1px solid ${mergedTheme.border}`,
18347
- borderRadius: "6px",
18348
- backgroundColor: mergedTheme.bodyBg
18349
- }
18350
- },
18253
+ muiTablePaperProps: React.useCallback(
18254
+ ({ table: table2 }) => {
18255
+ const isFullScreen = table2.getState().isFullScreen;
18256
+ return {
18257
+ elevation: 0,
18258
+ sx: {
18259
+ height: height2,
18260
+ width: width2,
18261
+ display: "flex",
18262
+ flexDirection: "column",
18263
+ border: `1px solid ${mergedTheme.border}`,
18264
+ backgroundColor: mergedTheme.bodyBg,
18265
+ ...isFullScreen && {
18266
+ position: "fixed",
18267
+ inset: 0,
18268
+ borderRadius: 0,
18269
+ zIndex: "9999999 !important"
18270
+ }
18271
+ }
18272
+ };
18273
+ },
18274
+ [height2, width2, mergedTheme]
18275
+ ),
18351
18276
  /* ===============================
18352
18277
  TOP TOOLBAR (STICKY)
18353
18278
  ================================ */
@@ -18468,6 +18393,112 @@ To suppress this warning, you need to explicitly provide the \`palette.${key}Cha
18468
18393
  });
18469
18394
  return /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MaterialReactTable, { table });
18470
18395
  }
18396
+ function SmartGridTopToolbar({
18397
+ table,
18398
+ theme,
18399
+ topToolbar,
18400
+ isGridDisabled,
18401
+ isLoading,
18402
+ safeColumns,
18403
+ safeData
18404
+ }) {
18405
+ const [searchValue, setSearchValue] = React.useState(
18406
+ table.getState().globalFilter ?? ""
18407
+ );
18408
+ const disable = isGridDisabled;
18409
+ React.useEffect(() => {
18410
+ if (disable) return;
18411
+ const t = setTimeout(() => {
18412
+ table.setGlobalFilter(searchValue || void 0);
18413
+ }, 300);
18414
+ return () => clearTimeout(t);
18415
+ }, [searchValue, table, disable]);
18416
+ const exportData = table.getFilteredRowModel().rows.map((row) => row.original);
18417
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(material.Box, { sx: { px: 2, py: 2 }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
18418
+ material.Box,
18419
+ {
18420
+ sx: {
18421
+ display: "grid",
18422
+ gridTemplateColumns: {
18423
+ xs: "1fr",
18424
+ sm: "1fr auto"
18425
+ },
18426
+ gap: 2,
18427
+ alignItems: "center",
18428
+ width: "100%"
18429
+ },
18430
+ children: [
18431
+ (topToolbar == null ? void 0 : topToolbar.globalSearch) && /* @__PURE__ */ jsxRuntimeExports.jsx(
18432
+ material.TextField,
18433
+ {
18434
+ size: "small",
18435
+ fullWidth: true,
18436
+ disabled: disable,
18437
+ placeholder: isLoading ? "Loading..." : safeColumns.length === 0 ? "No columns configured" : safeData.length === 0 ? "No data available" : "Search...",
18438
+ value: searchValue,
18439
+ onChange: (e) => setSearchValue(e.target.value),
18440
+ InputProps: {
18441
+ startAdornment: /* @__PURE__ */ jsxRuntimeExports.jsx(material.InputAdornment, { position: "start", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchCheck, {}) })
18442
+ },
18443
+ sx: {
18444
+ "& .MuiOutlinedInput-root": {
18445
+ borderRadius: 1.5,
18446
+ "& fieldset": { borderColor: theme == null ? void 0 : theme.headerBg },
18447
+ "&:hover fieldset": { borderColor: theme == null ? void 0 : theme.headerBg },
18448
+ "&.Mui-focused fieldset": {
18449
+ borderColor: theme == null ? void 0 : theme.headerBg,
18450
+ borderWidth: 2
18451
+ }
18452
+ },
18453
+ "& .MuiOutlinedInput-input::placeholder": {
18454
+ opacity: 0.7
18455
+ },
18456
+ "& .MuiInputAdornment-root svg": {
18457
+ color: theme == null ? void 0 : theme.headerBg
18458
+ }
18459
+ }
18460
+ }
18461
+ ),
18462
+ ((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(
18463
+ material.Paper,
18464
+ {
18465
+ elevation: 3,
18466
+ sx: {
18467
+ justifySelf: "end",
18468
+ // ✅ THIS IS THE KEY
18469
+ display: "inline-flex",
18470
+ alignItems: "center",
18471
+ width: "fit-content",
18472
+ px: 1,
18473
+ py: 0.2,
18474
+ borderRadius: 2,
18475
+ bgcolor: "background.paper",
18476
+ border: `1px solid ${theme == null ? void 0 : theme.headerBg}`,
18477
+ whiteSpace: "nowrap",
18478
+ opacity: disable ? 0.6 : 1,
18479
+ pointerEvents: disable ? "none" : "auto"
18480
+ },
18481
+ children: [
18482
+ (topToolbar == null ? void 0 : topToolbar.exportBtn) && /* @__PURE__ */ jsxRuntimeExports.jsx(
18483
+ ExportButton,
18484
+ {
18485
+ data: exportData,
18486
+ color: theme == null ? void 0 : theme.headerBg,
18487
+ filename: "table-data",
18488
+ disabled: disable
18489
+ }
18490
+ ),
18491
+ (topToolbar == null ? void 0 : topToolbar.columnFilters) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ToggleFiltersButton, { table, disabled: disable }),
18492
+ (topToolbar == null ? void 0 : topToolbar.densityToggle) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ToggleDensePaddingButton, { table, disabled: disable }),
18493
+ (topToolbar == null ? void 0 : topToolbar.showHideColumnsBtn) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ShowHideColumnsButton, { table, disabled: disable }),
18494
+ (topToolbar == null ? void 0 : topToolbar.fullscreenToggle) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ToggleFullScreenButton, { table, disabled: disable })
18495
+ ]
18496
+ }
18497
+ )
18498
+ ]
18499
+ }
18500
+ ) });
18501
+ }
18471
18502
  const ExportButton = ({
18472
18503
  data,
18473
18504
  filename = "data",
@@ -18573,7 +18604,39 @@ To suppress this warning, you need to explicitly provide the \`palette.${key}Cha
18573
18604
  )
18574
18605
  ] });
18575
18606
  };
18576
- const SmartTable = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(xDatePickers.LocalizationProvider, { dateAdapter: AdapterDayjs, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SmartGridTable, { ...props }) });
18607
+ const SmartTable = ({
18608
+ controls = {
18609
+ columnActions: true,
18610
+ dragging: true,
18611
+ colPinning: true,
18612
+ pagination: true,
18613
+ rowSelection: false,
18614
+ rowPinning: false,
18615
+ grouping: false,
18616
+ sorting: true,
18617
+ editing: false,
18618
+ resizing: true
18619
+ },
18620
+ topToolbar = {
18621
+ enabled: true,
18622
+ globalSearch: true,
18623
+ columnFilters: true,
18624
+ densityToggle: true,
18625
+ fullscreenToggle: true,
18626
+ exportBtn: true,
18627
+ showHideColumnsBtn: true
18628
+ },
18629
+ height: height2 = "100%",
18630
+ width: width2 = "100%",
18631
+ columns = [],
18632
+ data = [],
18633
+ isLoading = false,
18634
+ onRowSelectionChange = () => {
18635
+ }
18636
+ }) => {
18637
+ const props = { controls, topToolbar, height: height2, width: width2, isLoading, columns, data, onRowSelectionChange };
18638
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(xDatePickers.LocalizationProvider, { dateAdapter: AdapterDayjs, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SmartGridTable, { ...props }) });
18639
+ };
18577
18640
  exports2.MytekComboDropdown = ComboDropdown;
18578
18641
  exports2.MytekInputField = CustomInput;
18579
18642
  exports2.MytekLoader = Loader;