mytek-components 2.0.4 → 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 CHANGED
@@ -1,9 +1,16 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
1
4
  import * as React from "react";
2
- import React__default, { useState, useRef, useEffect, useCallback, useContext, useMemo, useLayoutEffect, createContext, cloneElement } from "react";
5
+ import React__default, { useState, useRef, useEffect, useCallback, useContext, useMemo, useLayoutEffect, createContext, cloneElement, forwardRef, createElement } from "react";
3
6
  import emStyled from "@emotion/styled";
4
7
  import "@emotion/react";
5
- 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, TableHead, TableRow, TableCell, TableBody } from "@mui/material";
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";
6
9
  import ReactDOM from "react-dom";
10
+ import { useMaterialReactTable, MaterialReactTable, MRT_ToggleFiltersButton, MRT_ToggleDensePaddingButton, MRT_ShowHideColumnsButton, MRT_ToggleFullScreenButton } from "material-react-table";
11
+ import { LocalizationProvider, DatePicker } from "@mui/x-date-pickers";
12
+ import dayjs from "dayjs";
13
+ import * as XLSX from "xlsx";
7
14
  function getDefaultExportFromCjs(x) {
8
15
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
9
16
  }
@@ -616,8 +623,8 @@ function _objectWithoutPropertiesLoose$4(source, excluded) {
616
623
  }
617
624
  return target;
618
625
  }
619
- function _extends() {
620
- _extends = Object.assign ? Object.assign.bind() : function(target) {
626
+ function _extends$1() {
627
+ _extends$1 = Object.assign ? Object.assign.bind() : function(target) {
621
628
  for (var i = 1; i < arguments.length; i++) {
622
629
  var source = arguments[i];
623
630
  for (var key in source) {
@@ -628,7 +635,7 @@ function _extends() {
628
635
  }
629
636
  return target;
630
637
  };
631
- return _extends.apply(this, arguments);
638
+ return _extends$1.apply(this, arguments);
632
639
  }
633
640
  function ownKeys$4(e, r2) {
634
641
  var t = Object.keys(e);
@@ -680,7 +687,7 @@ function Tree2Element(tree) {
680
687
  }, node.attr), Tree2Element(node.child)));
681
688
  }
682
689
  function GenIcon(data) {
683
- return (props) => /* @__PURE__ */ React__default.createElement(IconBase, _extends({
690
+ return (props) => /* @__PURE__ */ React__default.createElement(IconBase, _extends$1({
684
691
  attr: _objectSpread$4({}, data.attr)
685
692
  }, props), Tree2Element(data.child));
686
693
  }
@@ -695,7 +702,7 @@ function IconBase(props) {
695
702
  var className;
696
703
  if (conf.className) className = conf.className;
697
704
  if (props.className) className = (className ? className + " " : "") + props.className;
698
- return /* @__PURE__ */ React__default.createElement("svg", _extends({
705
+ return /* @__PURE__ */ React__default.createElement("svg", _extends$1({
699
706
  stroke: "currentColor",
700
707
  fill: "currentColor",
701
708
  strokeWidth: "0"
@@ -6474,6 +6481,15 @@ function requireClassnames() {
6474
6481
  }
6475
6482
  var classnamesExports = requireClassnames();
6476
6483
  const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
6484
+ function _extends() {
6485
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
6486
+ for (var e = 1; e < arguments.length; e++) {
6487
+ var t = arguments[e];
6488
+ for (var r2 in t) ({}).hasOwnProperty.call(t, r2) && (n[r2] = t[r2]);
6489
+ }
6490
+ return n;
6491
+ }, _extends.apply(null, arguments);
6492
+ }
6477
6493
  function _objectWithoutPropertiesLoose$3(r2, e) {
6478
6494
  if (null == r2) return {};
6479
6495
  var t = {};
@@ -15065,7 +15081,7 @@ const MasterTable = ({
15065
15081
  onSelectionChange(updated);
15066
15082
  };
15067
15083
  const isAllSelected = data.length > 0 && selectedRows.length === data.length;
15068
- const formatDate = (value, format = "YYYY-MM-DD") => {
15084
+ const formatDate2 = (value, format = "YYYY-MM-DD") => {
15069
15085
  if (!value) return "";
15070
15086
  const date = new Date(value);
15071
15087
  if (isNaN(date)) return value;
@@ -15258,7 +15274,7 @@ const MasterTable = ({
15258
15274
  checked: selectedRows.includes(rowIndex),
15259
15275
  onChange: () => handleRowSelect(rowIndex)
15260
15276
  }
15261
- ) : column.key === "__sr_no" ? rowIndex + 1 : column.render ? column.render(row) : column.type === "date" ? formatDate(value, column.format) : column.type === "category" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
15277
+ ) : column.key === "__sr_no" ? rowIndex + 1 : column.render ? column.render(row) : column.type === "date" ? formatDate2(value, column.format) : column.type === "category" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
15262
15278
  "span",
15263
15279
  {
15264
15280
  className: `
@@ -16272,7 +16288,7 @@ const PowerDropdown = ({
16272
16288
  component: Paper,
16273
16289
  className: "table-container overflow-x-hidden w-ful mt-0 h-full max-h-[60vh] overflow-y-auto shadow-2xl",
16274
16290
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
16275
- Table,
16291
+ Table$1,
16276
16292
  {
16277
16293
  stickyHeader: true,
16278
16294
  size: "small",
@@ -16426,6 +16442,2189 @@ const PowerDropdown = ({
16426
16442
  )
16427
16443
  ] });
16428
16444
  };
16445
+ /**
16446
+ * @license lucide-react v0.542.0 - ISC
16447
+ *
16448
+ * This source code is licensed under the ISC license.
16449
+ * See the LICENSE file in the root directory of this source tree.
16450
+ */
16451
+ const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
16452
+ const toCamelCase = (string) => string.replace(
16453
+ /^([A-Z])|[\s-_]+(\w)/g,
16454
+ (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
16455
+ );
16456
+ const toPascalCase = (string) => {
16457
+ const camelCase = toCamelCase(string);
16458
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
16459
+ };
16460
+ const mergeClasses = (...classes) => classes.filter((className, index, array) => {
16461
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
16462
+ }).join(" ").trim();
16463
+ const hasA11yProp = (props) => {
16464
+ for (const prop in props) {
16465
+ if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
16466
+ return true;
16467
+ }
16468
+ }
16469
+ };
16470
+ /**
16471
+ * @license lucide-react v0.542.0 - ISC
16472
+ *
16473
+ * This source code is licensed under the ISC license.
16474
+ * See the LICENSE file in the root directory of this source tree.
16475
+ */
16476
+ var defaultAttributes = {
16477
+ xmlns: "http://www.w3.org/2000/svg",
16478
+ width: 24,
16479
+ height: 24,
16480
+ viewBox: "0 0 24 24",
16481
+ fill: "none",
16482
+ stroke: "currentColor",
16483
+ strokeWidth: 2,
16484
+ strokeLinecap: "round",
16485
+ strokeLinejoin: "round"
16486
+ };
16487
+ /**
16488
+ * @license lucide-react v0.542.0 - ISC
16489
+ *
16490
+ * This source code is licensed under the ISC license.
16491
+ * See the LICENSE file in the root directory of this source tree.
16492
+ */
16493
+ const Icon = forwardRef(
16494
+ ({
16495
+ color: color2 = "currentColor",
16496
+ size = 24,
16497
+ strokeWidth = 2,
16498
+ absoluteStrokeWidth,
16499
+ className = "",
16500
+ children,
16501
+ iconNode,
16502
+ ...rest
16503
+ }, ref) => createElement(
16504
+ "svg",
16505
+ {
16506
+ ref,
16507
+ ...defaultAttributes,
16508
+ width: size,
16509
+ height: size,
16510
+ stroke: color2,
16511
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
16512
+ className: mergeClasses("lucide", className),
16513
+ ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
16514
+ ...rest
16515
+ },
16516
+ [
16517
+ ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
16518
+ ...Array.isArray(children) ? children : [children]
16519
+ ]
16520
+ )
16521
+ );
16522
+ /**
16523
+ * @license lucide-react v0.542.0 - ISC
16524
+ *
16525
+ * This source code is licensed under the ISC license.
16526
+ * See the LICENSE file in the root directory of this source tree.
16527
+ */
16528
+ const createLucideIcon = (iconName, iconNode) => {
16529
+ const Component = forwardRef(
16530
+ ({ className, ...props }, ref) => createElement(Icon, {
16531
+ ref,
16532
+ iconNode,
16533
+ className: mergeClasses(
16534
+ `lucide-${toKebabCase(toPascalCase(iconName))}`,
16535
+ `lucide-${iconName}`,
16536
+ className
16537
+ ),
16538
+ ...props
16539
+ })
16540
+ );
16541
+ Component.displayName = toPascalCase(iconName);
16542
+ return Component;
16543
+ };
16544
+ /**
16545
+ * @license lucide-react v0.542.0 - ISC
16546
+ *
16547
+ * This source code is licensed under the ISC license.
16548
+ * See the LICENSE file in the root directory of this source tree.
16549
+ */
16550
+ const __iconNode$4 = [
16551
+ ["path", { d: "M12 15V3", key: "m9g1x1" }],
16552
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
16553
+ ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
16554
+ ];
16555
+ const Download = createLucideIcon("download", __iconNode$4);
16556
+ /**
16557
+ * @license lucide-react v0.542.0 - ISC
16558
+ *
16559
+ * This source code is licensed under the ISC license.
16560
+ * See the LICENSE file in the root directory of this source tree.
16561
+ */
16562
+ const __iconNode$3 = [
16563
+ [
16564
+ "path",
16565
+ {
16566
+ d: "M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",
16567
+ key: "sc7q7i"
16568
+ }
16569
+ ]
16570
+ ];
16571
+ const Funnel = createLucideIcon("funnel", __iconNode$3);
16572
+ /**
16573
+ * @license lucide-react v0.542.0 - ISC
16574
+ *
16575
+ * This source code is licensed under the ISC license.
16576
+ * See the LICENSE file in the root directory of this source tree.
16577
+ */
16578
+ const __iconNode$2 = [
16579
+ ["path", { d: "m8 11 2 2 4-4", key: "1sed1v" }],
16580
+ ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
16581
+ ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
16582
+ ];
16583
+ const SearchCheck = createLucideIcon("search-check", __iconNode$2);
16584
+ /**
16585
+ * @license lucide-react v0.542.0 - ISC
16586
+ *
16587
+ * This source code is licensed under the ISC license.
16588
+ * See the LICENSE file in the root directory of this source tree.
16589
+ */
16590
+ const __iconNode$1 = [
16591
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
16592
+ ["line", { x1: "3", x2: "21", y1: "9", y2: "9", key: "1vqk6q" }],
16593
+ ["line", { x1: "3", x2: "21", y1: "15", y2: "15", key: "o2sbyz" }],
16594
+ ["line", { x1: "9", x2: "9", y1: "9", y2: "21", key: "1ib60c" }],
16595
+ ["line", { x1: "15", x2: "15", y1: "9", y2: "21", key: "1n26ft" }]
16596
+ ];
16597
+ const Sheet = createLucideIcon("sheet", __iconNode$1);
16598
+ /**
16599
+ * @license lucide-react v0.542.0 - ISC
16600
+ *
16601
+ * This source code is licensed under the ISC license.
16602
+ * See the LICENSE file in the root directory of this source tree.
16603
+ */
16604
+ const __iconNode = [
16605
+ ["path", { d: "M12 3v18", key: "108xh3" }],
16606
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
16607
+ ["path", { d: "M3 9h18", key: "1pudct" }],
16608
+ ["path", { d: "M3 15h18", key: "5xshup" }]
16609
+ ];
16610
+ const Table = createLucideIcon("table", __iconNode);
16611
+ var weekOfYear$1 = { exports: {} };
16612
+ var weekOfYear = weekOfYear$1.exports;
16613
+ var hasRequiredWeekOfYear;
16614
+ function requireWeekOfYear() {
16615
+ if (hasRequiredWeekOfYear) return weekOfYear$1.exports;
16616
+ hasRequiredWeekOfYear = 1;
16617
+ (function(module, exports$1) {
16618
+ !(function(e, t) {
16619
+ module.exports = t();
16620
+ })(weekOfYear, (function() {
16621
+ var e = "week", t = "year";
16622
+ return function(i, n, r2) {
16623
+ var f = n.prototype;
16624
+ f.week = function(i2) {
16625
+ if (void 0 === i2 && (i2 = null), null !== i2) return this.add(7 * (i2 - this.week()), "day");
16626
+ var n2 = this.$locale().yearStart || 1;
16627
+ if (11 === this.month() && this.date() > 25) {
16628
+ var f2 = r2(this).startOf(t).add(1, t).date(n2), s = r2(this).endOf(e);
16629
+ if (f2.isBefore(s)) return 1;
16630
+ }
16631
+ var a = r2(this).startOf(t).date(n2).startOf(e).subtract(1, "millisecond"), o = this.diff(a, e, true);
16632
+ return o < 0 ? r2(this).startOf("week").week() : Math.ceil(o);
16633
+ }, f.weeks = function(e2) {
16634
+ return void 0 === e2 && (e2 = null), this.week(e2);
16635
+ };
16636
+ };
16637
+ }));
16638
+ })(weekOfYear$1);
16639
+ return weekOfYear$1.exports;
16640
+ }
16641
+ var weekOfYearExports = requireWeekOfYear();
16642
+ const weekOfYearPlugin = /* @__PURE__ */ getDefaultExportFromCjs(weekOfYearExports);
16643
+ var customParseFormat$1 = { exports: {} };
16644
+ var customParseFormat = customParseFormat$1.exports;
16645
+ var hasRequiredCustomParseFormat;
16646
+ function requireCustomParseFormat() {
16647
+ if (hasRequiredCustomParseFormat) return customParseFormat$1.exports;
16648
+ hasRequiredCustomParseFormat = 1;
16649
+ (function(module, exports$1) {
16650
+ !(function(e, t) {
16651
+ module.exports = t();
16652
+ })(customParseFormat, (function() {
16653
+ var e = { LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D, YYYY", LLL: "MMMM D, YYYY h:mm A", LLLL: "dddd, MMMM D, YYYY h:mm A" }, t = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g, n = /\d/, r2 = /\d\d/, i = /\d\d?/, o = /\d*[^-_:/,()\s\d]+/, s = {}, a = function(e2) {
16654
+ return (e2 = +e2) + (e2 > 68 ? 1900 : 2e3);
16655
+ };
16656
+ var f = function(e2) {
16657
+ return function(t2) {
16658
+ this[e2] = +t2;
16659
+ };
16660
+ }, h = [/[+-]\d\d:?(\d\d)?|Z/, function(e2) {
16661
+ (this.zone || (this.zone = {})).offset = (function(e3) {
16662
+ if (!e3) return 0;
16663
+ if ("Z" === e3) return 0;
16664
+ var t2 = e3.match(/([+-]|\d\d)/g), n2 = 60 * t2[1] + (+t2[2] || 0);
16665
+ return 0 === n2 ? 0 : "+" === t2[0] ? -n2 : n2;
16666
+ })(e2);
16667
+ }], u = function(e2) {
16668
+ var t2 = s[e2];
16669
+ return t2 && (t2.indexOf ? t2 : t2.s.concat(t2.f));
16670
+ }, d = function(e2, t2) {
16671
+ var n2, r3 = s.meridiem;
16672
+ if (r3) {
16673
+ for (var i2 = 1; i2 <= 24; i2 += 1) if (e2.indexOf(r3(i2, 0, t2)) > -1) {
16674
+ n2 = i2 > 12;
16675
+ break;
16676
+ }
16677
+ } else n2 = e2 === (t2 ? "pm" : "PM");
16678
+ return n2;
16679
+ }, c = { A: [o, function(e2) {
16680
+ this.afternoon = d(e2, false);
16681
+ }], a: [o, function(e2) {
16682
+ this.afternoon = d(e2, true);
16683
+ }], Q: [n, function(e2) {
16684
+ this.month = 3 * (e2 - 1) + 1;
16685
+ }], S: [n, function(e2) {
16686
+ this.milliseconds = 100 * +e2;
16687
+ }], SS: [r2, function(e2) {
16688
+ this.milliseconds = 10 * +e2;
16689
+ }], SSS: [/\d{3}/, function(e2) {
16690
+ this.milliseconds = +e2;
16691
+ }], s: [i, f("seconds")], ss: [i, f("seconds")], m: [i, f("minutes")], mm: [i, f("minutes")], H: [i, f("hours")], h: [i, f("hours")], HH: [i, f("hours")], hh: [i, f("hours")], D: [i, f("day")], DD: [r2, f("day")], Do: [o, function(e2) {
16692
+ var t2 = s.ordinal, n2 = e2.match(/\d+/);
16693
+ if (this.day = n2[0], t2) for (var r3 = 1; r3 <= 31; r3 += 1) t2(r3).replace(/\[|\]/g, "") === e2 && (this.day = r3);
16694
+ }], w: [i, f("week")], ww: [r2, f("week")], M: [i, f("month")], MM: [r2, f("month")], MMM: [o, function(e2) {
16695
+ var t2 = u("months"), n2 = (u("monthsShort") || t2.map((function(e3) {
16696
+ return e3.slice(0, 3);
16697
+ }))).indexOf(e2) + 1;
16698
+ if (n2 < 1) throw new Error();
16699
+ this.month = n2 % 12 || n2;
16700
+ }], MMMM: [o, function(e2) {
16701
+ var t2 = u("months").indexOf(e2) + 1;
16702
+ if (t2 < 1) throw new Error();
16703
+ this.month = t2 % 12 || t2;
16704
+ }], Y: [/[+-]?\d+/, f("year")], YY: [r2, function(e2) {
16705
+ this.year = a(e2);
16706
+ }], YYYY: [/\d{4}/, f("year")], Z: h, ZZ: h };
16707
+ function l(n2) {
16708
+ var r3, i2;
16709
+ r3 = n2, i2 = s && s.formats;
16710
+ for (var o2 = (n2 = r3.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (function(t2, n3, r4) {
16711
+ var o3 = r4 && r4.toUpperCase();
16712
+ return n3 || i2[r4] || e[r4] || i2[o3].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (function(e2, t3, n4) {
16713
+ return t3 || n4.slice(1);
16714
+ }));
16715
+ }))).match(t), a2 = o2.length, f2 = 0; f2 < a2; f2 += 1) {
16716
+ var h2 = o2[f2], u2 = c[h2], d2 = u2 && u2[0], l2 = u2 && u2[1];
16717
+ o2[f2] = l2 ? { regex: d2, parser: l2 } : h2.replace(/^\[|\]$/g, "");
16718
+ }
16719
+ return function(e2) {
16720
+ for (var t2 = {}, n3 = 0, r4 = 0; n3 < a2; n3 += 1) {
16721
+ var i3 = o2[n3];
16722
+ if ("string" == typeof i3) r4 += i3.length;
16723
+ else {
16724
+ var s2 = i3.regex, f3 = i3.parser, h3 = e2.slice(r4), u3 = s2.exec(h3)[0];
16725
+ f3.call(t2, u3), e2 = e2.replace(u3, "");
16726
+ }
16727
+ }
16728
+ return (function(e3) {
16729
+ var t3 = e3.afternoon;
16730
+ if (void 0 !== t3) {
16731
+ var n4 = e3.hours;
16732
+ t3 ? n4 < 12 && (e3.hours += 12) : 12 === n4 && (e3.hours = 0), delete e3.afternoon;
16733
+ }
16734
+ })(t2), t2;
16735
+ };
16736
+ }
16737
+ return function(e2, t2, n2) {
16738
+ n2.p.customParseFormat = true, e2 && e2.parseTwoDigitYear && (a = e2.parseTwoDigitYear);
16739
+ var r3 = t2.prototype, i2 = r3.parse;
16740
+ r3.parse = function(e3) {
16741
+ var t3 = e3.date, r4 = e3.utc, o2 = e3.args;
16742
+ this.$u = r4;
16743
+ var a2 = o2[1];
16744
+ if ("string" == typeof a2) {
16745
+ var f2 = true === o2[2], h2 = true === o2[3], u2 = f2 || h2, d2 = o2[2];
16746
+ h2 && (d2 = o2[2]), s = this.$locale(), !f2 && d2 && (s = n2.Ls[d2]), this.$d = (function(e4, t4, n3, r5) {
16747
+ try {
16748
+ if (["x", "X"].indexOf(t4) > -1) return new Date(("X" === t4 ? 1e3 : 1) * e4);
16749
+ var i3 = l(t4)(e4), o3 = i3.year, s2 = i3.month, a3 = i3.day, f3 = i3.hours, h3 = i3.minutes, u3 = i3.seconds, d3 = i3.milliseconds, c3 = i3.zone, m2 = i3.week, M2 = /* @__PURE__ */ new Date(), Y = a3 || (o3 || s2 ? 1 : M2.getDate()), p = o3 || M2.getFullYear(), v = 0;
16750
+ o3 && !s2 || (v = s2 > 0 ? s2 - 1 : M2.getMonth());
16751
+ var D, w = f3 || 0, g = h3 || 0, y = u3 || 0, L = d3 || 0;
16752
+ return c3 ? new Date(Date.UTC(p, v, Y, w, g, y, L + 60 * c3.offset * 1e3)) : n3 ? new Date(Date.UTC(p, v, Y, w, g, y, L)) : (D = new Date(p, v, Y, w, g, y, L), m2 && (D = r5(D).week(m2).toDate()), D);
16753
+ } catch (e5) {
16754
+ return /* @__PURE__ */ new Date("");
16755
+ }
16756
+ })(t3, a2, r4, n2), this.init(), d2 && true !== d2 && (this.$L = this.locale(d2).$L), u2 && t3 != this.format(a2) && (this.$d = /* @__PURE__ */ new Date("")), s = {};
16757
+ } else if (a2 instanceof Array) for (var c2 = a2.length, m = 1; m <= c2; m += 1) {
16758
+ o2[1] = a2[m - 1];
16759
+ var M = n2.apply(this, o2);
16760
+ if (M.isValid()) {
16761
+ this.$d = M.$d, this.$L = M.$L, this.init();
16762
+ break;
16763
+ }
16764
+ m === c2 && (this.$d = /* @__PURE__ */ new Date(""));
16765
+ }
16766
+ else i2.call(this, e3);
16767
+ };
16768
+ };
16769
+ }));
16770
+ })(customParseFormat$1);
16771
+ return customParseFormat$1.exports;
16772
+ }
16773
+ var customParseFormatExports = requireCustomParseFormat();
16774
+ const customParseFormatPlugin = /* @__PURE__ */ getDefaultExportFromCjs(customParseFormatExports);
16775
+ var localizedFormat$1 = { exports: {} };
16776
+ var localizedFormat = localizedFormat$1.exports;
16777
+ var hasRequiredLocalizedFormat;
16778
+ function requireLocalizedFormat() {
16779
+ if (hasRequiredLocalizedFormat) return localizedFormat$1.exports;
16780
+ hasRequiredLocalizedFormat = 1;
16781
+ (function(module, exports$1) {
16782
+ !(function(e, t) {
16783
+ module.exports = t();
16784
+ })(localizedFormat, (function() {
16785
+ var e = { LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D, YYYY", LLL: "MMMM D, YYYY h:mm A", LLLL: "dddd, MMMM D, YYYY h:mm A" };
16786
+ return function(t, o, n) {
16787
+ var r2 = o.prototype, i = r2.format;
16788
+ n.en.formats = e, r2.format = function(t2) {
16789
+ void 0 === t2 && (t2 = "YYYY-MM-DDTHH:mm:ssZ");
16790
+ var o2 = this.$locale().formats, n2 = (function(t3, o3) {
16791
+ return t3.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (function(t4, n3, r3) {
16792
+ var i2 = r3 && r3.toUpperCase();
16793
+ return n3 || o3[r3] || e[r3] || o3[i2].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (function(e2, t5, o4) {
16794
+ return t5 || o4.slice(1);
16795
+ }));
16796
+ }));
16797
+ })(t2, void 0 === o2 ? {} : o2);
16798
+ return i.call(this, n2);
16799
+ };
16800
+ };
16801
+ }));
16802
+ })(localizedFormat$1);
16803
+ return localizedFormat$1.exports;
16804
+ }
16805
+ var localizedFormatExports = requireLocalizedFormat();
16806
+ const localizedFormatPlugin = /* @__PURE__ */ getDefaultExportFromCjs(localizedFormatExports);
16807
+ var isBetween$1 = { exports: {} };
16808
+ var isBetween = isBetween$1.exports;
16809
+ var hasRequiredIsBetween;
16810
+ function requireIsBetween() {
16811
+ if (hasRequiredIsBetween) return isBetween$1.exports;
16812
+ hasRequiredIsBetween = 1;
16813
+ (function(module, exports$1) {
16814
+ !(function(e, i) {
16815
+ module.exports = i();
16816
+ })(isBetween, (function() {
16817
+ return function(e, i, t) {
16818
+ i.prototype.isBetween = function(e2, i2, s, f) {
16819
+ var n = t(e2), o = t(i2), r2 = "(" === (f = f || "()")[0], u = ")" === f[1];
16820
+ return (r2 ? this.isAfter(n, s) : !this.isBefore(n, s)) && (u ? this.isBefore(o, s) : !this.isAfter(o, s)) || (r2 ? this.isBefore(n, s) : !this.isAfter(n, s)) && (u ? this.isAfter(o, s) : !this.isBefore(o, s));
16821
+ };
16822
+ };
16823
+ }));
16824
+ })(isBetween$1);
16825
+ return isBetween$1.exports;
16826
+ }
16827
+ var isBetweenExports = requireIsBetween();
16828
+ const isBetweenPlugin = /* @__PURE__ */ getDefaultExportFromCjs(isBetweenExports);
16829
+ var advancedFormat$1 = { exports: {} };
16830
+ var advancedFormat = advancedFormat$1.exports;
16831
+ var hasRequiredAdvancedFormat;
16832
+ function requireAdvancedFormat() {
16833
+ if (hasRequiredAdvancedFormat) return advancedFormat$1.exports;
16834
+ hasRequiredAdvancedFormat = 1;
16835
+ (function(module, exports$1) {
16836
+ !(function(e, t) {
16837
+ module.exports = t();
16838
+ })(advancedFormat, (function() {
16839
+ return function(e, t) {
16840
+ var r2 = t.prototype, n = r2.format;
16841
+ r2.format = function(e2) {
16842
+ var t2 = this, r3 = this.$locale();
16843
+ if (!this.isValid()) return n.bind(this)(e2);
16844
+ var s = this.$utils(), a = (e2 || "YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g, (function(e3) {
16845
+ switch (e3) {
16846
+ case "Q":
16847
+ return Math.ceil((t2.$M + 1) / 3);
16848
+ case "Do":
16849
+ return r3.ordinal(t2.$D);
16850
+ case "gggg":
16851
+ return t2.weekYear();
16852
+ case "GGGG":
16853
+ return t2.isoWeekYear();
16854
+ case "wo":
16855
+ return r3.ordinal(t2.week(), "W");
16856
+ case "w":
16857
+ case "ww":
16858
+ return s.s(t2.week(), "w" === e3 ? 1 : 2, "0");
16859
+ case "W":
16860
+ case "WW":
16861
+ return s.s(t2.isoWeek(), "W" === e3 ? 1 : 2, "0");
16862
+ case "k":
16863
+ case "kk":
16864
+ return s.s(String(0 === t2.$H ? 24 : t2.$H), "k" === e3 ? 1 : 2, "0");
16865
+ case "X":
16866
+ return Math.floor(t2.$d.getTime() / 1e3);
16867
+ case "x":
16868
+ return t2.$d.getTime();
16869
+ case "z":
16870
+ return "[" + t2.offsetName() + "]";
16871
+ case "zzz":
16872
+ return "[" + t2.offsetName("long") + "]";
16873
+ default:
16874
+ return e3;
16875
+ }
16876
+ }));
16877
+ return n.bind(this)(a);
16878
+ };
16879
+ };
16880
+ }));
16881
+ })(advancedFormat$1);
16882
+ return advancedFormat$1.exports;
16883
+ }
16884
+ var advancedFormatExports = requireAdvancedFormat();
16885
+ const advancedFormatPlugin = /* @__PURE__ */ getDefaultExportFromCjs(advancedFormatExports);
16886
+ const warnedOnceCache = /* @__PURE__ */ new Set();
16887
+ function warnOnce(message, gravity = "warning") {
16888
+ if (process.env.NODE_ENV === "production") {
16889
+ return;
16890
+ }
16891
+ const cleanMessage = Array.isArray(message) ? message.join("\n") : message;
16892
+ if (!warnedOnceCache.has(cleanMessage)) {
16893
+ warnedOnceCache.add(cleanMessage);
16894
+ if (gravity === "error") {
16895
+ console.error(cleanMessage);
16896
+ } else {
16897
+ console.warn(cleanMessage);
16898
+ }
16899
+ }
16900
+ }
16901
+ dayjs.extend(localizedFormatPlugin);
16902
+ dayjs.extend(weekOfYearPlugin);
16903
+ dayjs.extend(isBetweenPlugin);
16904
+ dayjs.extend(advancedFormatPlugin);
16905
+ const formatTokenMap = {
16906
+ // Year
16907
+ YY: "year",
16908
+ YYYY: {
16909
+ sectionType: "year",
16910
+ contentType: "digit",
16911
+ maxLength: 4
16912
+ },
16913
+ // Month
16914
+ M: {
16915
+ sectionType: "month",
16916
+ contentType: "digit",
16917
+ maxLength: 2
16918
+ },
16919
+ MM: "month",
16920
+ MMM: {
16921
+ sectionType: "month",
16922
+ contentType: "letter"
16923
+ },
16924
+ MMMM: {
16925
+ sectionType: "month",
16926
+ contentType: "letter"
16927
+ },
16928
+ // Day of the month
16929
+ D: {
16930
+ sectionType: "day",
16931
+ contentType: "digit",
16932
+ maxLength: 2
16933
+ },
16934
+ DD: "day",
16935
+ Do: {
16936
+ sectionType: "day",
16937
+ contentType: "digit-with-letter"
16938
+ },
16939
+ // Day of the week
16940
+ d: {
16941
+ sectionType: "weekDay",
16942
+ contentType: "digit",
16943
+ maxLength: 2
16944
+ },
16945
+ dd: {
16946
+ sectionType: "weekDay",
16947
+ contentType: "letter"
16948
+ },
16949
+ ddd: {
16950
+ sectionType: "weekDay",
16951
+ contentType: "letter"
16952
+ },
16953
+ dddd: {
16954
+ sectionType: "weekDay",
16955
+ contentType: "letter"
16956
+ },
16957
+ // Meridiem
16958
+ A: "meridiem",
16959
+ a: "meridiem",
16960
+ // Hours
16961
+ H: {
16962
+ sectionType: "hours",
16963
+ contentType: "digit",
16964
+ maxLength: 2
16965
+ },
16966
+ HH: "hours",
16967
+ h: {
16968
+ sectionType: "hours",
16969
+ contentType: "digit",
16970
+ maxLength: 2
16971
+ },
16972
+ hh: "hours",
16973
+ // Minutes
16974
+ m: {
16975
+ sectionType: "minutes",
16976
+ contentType: "digit",
16977
+ maxLength: 2
16978
+ },
16979
+ mm: "minutes",
16980
+ // Seconds
16981
+ s: {
16982
+ sectionType: "seconds",
16983
+ contentType: "digit",
16984
+ maxLength: 2
16985
+ },
16986
+ ss: "seconds"
16987
+ };
16988
+ const defaultFormats = {
16989
+ year: "YYYY",
16990
+ month: "MMMM",
16991
+ monthShort: "MMM",
16992
+ dayOfMonth: "D",
16993
+ dayOfMonthFull: "Do",
16994
+ weekday: "dddd",
16995
+ weekdayShort: "dd",
16996
+ hours24h: "HH",
16997
+ hours12h: "hh",
16998
+ meridiem: "A",
16999
+ minutes: "mm",
17000
+ seconds: "ss",
17001
+ fullDate: "ll",
17002
+ keyboardDate: "L",
17003
+ shortDate: "MMM D",
17004
+ normalDate: "D MMMM",
17005
+ normalDateWithWeekday: "ddd, MMM D",
17006
+ fullTime12h: "hh:mm A",
17007
+ fullTime24h: "HH:mm",
17008
+ keyboardDateTime12h: "L hh:mm A",
17009
+ keyboardDateTime24h: "L HH:mm"
17010
+ };
17011
+ const MISSING_UTC_PLUGIN = ["Missing UTC plugin", "To be able to use UTC or timezones, you have to enable the `utc` plugin", "Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-utc"].join("\n");
17012
+ const MISSING_TIMEZONE_PLUGIN = ["Missing timezone plugin", "To be able to use timezones, you have to enable both the `utc` and the `timezone` plugin", "Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-timezone"].join("\n");
17013
+ class AdapterDayjs {
17014
+ constructor({
17015
+ locale,
17016
+ formats
17017
+ } = {}) {
17018
+ __publicField(this, "isMUIAdapter", true);
17019
+ __publicField(this, "isTimezoneCompatible", true);
17020
+ __publicField(this, "lib", "dayjs");
17021
+ __publicField(this, "escapedCharacters", {
17022
+ start: "[",
17023
+ end: "]"
17024
+ });
17025
+ __publicField(this, "formatTokenMap", /* @__PURE__ */ (() => formatTokenMap)());
17026
+ __publicField(this, "setLocaleToValue", (value) => {
17027
+ const expectedLocale = this.getCurrentLocaleCode();
17028
+ if (expectedLocale === value.locale()) {
17029
+ return value;
17030
+ }
17031
+ return value.locale(expectedLocale);
17032
+ });
17033
+ __publicField(this, "hasUTCPlugin", () => typeof dayjs.utc !== "undefined");
17034
+ __publicField(this, "hasTimezonePlugin", () => typeof dayjs.tz !== "undefined");
17035
+ __publicField(this, "isSame", (value, comparing, comparisonTemplate) => {
17036
+ const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
17037
+ return value.format(comparisonTemplate) === comparingInValueTimezone.format(comparisonTemplate);
17038
+ });
17039
+ /**
17040
+ * Replaces "default" by undefined and "system" by the system timezone before passing it to `dayjs`.
17041
+ */
17042
+ __publicField(this, "cleanTimezone", (timezone) => {
17043
+ switch (timezone) {
17044
+ case "default": {
17045
+ return void 0;
17046
+ }
17047
+ case "system": {
17048
+ return dayjs.tz.guess();
17049
+ }
17050
+ default: {
17051
+ return timezone;
17052
+ }
17053
+ }
17054
+ });
17055
+ __publicField(this, "createSystemDate", (value) => {
17056
+ let date;
17057
+ if (this.hasUTCPlugin() && this.hasTimezonePlugin()) {
17058
+ const timezone = dayjs.tz.guess();
17059
+ if (timezone === "UTC") {
17060
+ date = dayjs(value);
17061
+ } else {
17062
+ date = dayjs.tz(value, timezone);
17063
+ }
17064
+ } else {
17065
+ date = dayjs(value);
17066
+ }
17067
+ return this.setLocaleToValue(date);
17068
+ });
17069
+ __publicField(this, "createUTCDate", (value) => {
17070
+ if (!this.hasUTCPlugin()) {
17071
+ throw new Error(MISSING_UTC_PLUGIN);
17072
+ }
17073
+ return this.setLocaleToValue(dayjs.utc(value));
17074
+ });
17075
+ __publicField(this, "createTZDate", (value, timezone) => {
17076
+ if (!this.hasUTCPlugin()) {
17077
+ throw new Error(MISSING_UTC_PLUGIN);
17078
+ }
17079
+ if (!this.hasTimezonePlugin()) {
17080
+ throw new Error(MISSING_TIMEZONE_PLUGIN);
17081
+ }
17082
+ const keepLocalTime = value !== void 0 && !value.endsWith("Z");
17083
+ return this.setLocaleToValue(dayjs(value).tz(this.cleanTimezone(timezone), keepLocalTime));
17084
+ });
17085
+ __publicField(this, "getLocaleFormats", () => {
17086
+ const locales = dayjs.Ls;
17087
+ const locale = this.locale || "en";
17088
+ let localeObject = locales[locale];
17089
+ if (localeObject === void 0) {
17090
+ if (process.env.NODE_ENV !== "production") {
17091
+ warnOnce(["MUI X: Your locale has not been found.", "Either the locale key is not a supported one. Locales supported by dayjs are available here: https://github.com/iamkun/dayjs/tree/dev/src/locale.", "Or you forget to import the locale from 'dayjs/locale/{localeUsed}'", "fallback on English locale."]);
17092
+ }
17093
+ localeObject = locales.en;
17094
+ }
17095
+ return localeObject.formats;
17096
+ });
17097
+ /**
17098
+ * If the new day does not have the same offset as the old one (when switching to summer day time for example),
17099
+ * Then dayjs will not automatically adjust the offset (moment does).
17100
+ * We have to parse again the value to make sure the `fixOffset` method is applied.
17101
+ * See https://github.com/iamkun/dayjs/blob/b3624de619d6e734cd0ffdbbd3502185041c1b60/src/plugin/timezone/index.js#L72
17102
+ */
17103
+ __publicField(this, "adjustOffset", (value) => {
17104
+ if (!this.hasTimezonePlugin()) {
17105
+ return value;
17106
+ }
17107
+ const timezone = this.getTimezone(value);
17108
+ if (timezone !== "UTC") {
17109
+ const fixedValue = value.tz(this.cleanTimezone(timezone), true);
17110
+ if (fixedValue.$offset === (value.$offset ?? 0)) {
17111
+ return value;
17112
+ }
17113
+ value.$offset = fixedValue.$offset;
17114
+ }
17115
+ return value;
17116
+ });
17117
+ __publicField(this, "date", (value, timezone = "default") => {
17118
+ if (value === null) {
17119
+ return null;
17120
+ }
17121
+ if (timezone === "UTC") {
17122
+ return this.createUTCDate(value);
17123
+ }
17124
+ if (timezone === "system" || timezone === "default" && !this.hasTimezonePlugin()) {
17125
+ return this.createSystemDate(value);
17126
+ }
17127
+ return this.createTZDate(value, timezone);
17128
+ });
17129
+ __publicField(this, "getInvalidDate", () => dayjs(/* @__PURE__ */ new Date("Invalid date")));
17130
+ __publicField(this, "getTimezone", (value) => {
17131
+ var _a;
17132
+ if (this.hasTimezonePlugin()) {
17133
+ const zone = (_a = value.$x) == null ? void 0 : _a.$timezone;
17134
+ if (zone) {
17135
+ return zone;
17136
+ }
17137
+ }
17138
+ if (this.hasUTCPlugin() && value.isUTC()) {
17139
+ return "UTC";
17140
+ }
17141
+ return "system";
17142
+ });
17143
+ __publicField(this, "setTimezone", (value, timezone) => {
17144
+ if (this.getTimezone(value) === timezone) {
17145
+ return value;
17146
+ }
17147
+ if (timezone === "UTC") {
17148
+ if (!this.hasUTCPlugin()) {
17149
+ throw new Error(MISSING_UTC_PLUGIN);
17150
+ }
17151
+ return value.utc();
17152
+ }
17153
+ if (timezone === "system") {
17154
+ return value.local();
17155
+ }
17156
+ if (!this.hasTimezonePlugin()) {
17157
+ if (timezone === "default") {
17158
+ return value;
17159
+ }
17160
+ throw new Error(MISSING_TIMEZONE_PLUGIN);
17161
+ }
17162
+ return this.setLocaleToValue(dayjs.tz(value, this.cleanTimezone(timezone)));
17163
+ });
17164
+ __publicField(this, "toJsDate", (value) => {
17165
+ return value.toDate();
17166
+ });
17167
+ __publicField(this, "parse", (value, format) => {
17168
+ if (value === "") {
17169
+ return null;
17170
+ }
17171
+ return dayjs(value, format, this.locale, true);
17172
+ });
17173
+ __publicField(this, "getCurrentLocaleCode", () => {
17174
+ return this.locale || "en";
17175
+ });
17176
+ __publicField(this, "is12HourCycleInCurrentLocale", () => {
17177
+ return /A|a/.test(this.getLocaleFormats().LT || "");
17178
+ });
17179
+ __publicField(this, "expandFormat", (format) => {
17180
+ const localeFormats = this.getLocaleFormats();
17181
+ const t = (formatBis) => formatBis.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (_, a, b) => a || b.slice(1));
17182
+ return format.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (_, a, b) => {
17183
+ const B = b && b.toUpperCase();
17184
+ return a || localeFormats[b] || t(localeFormats[B]);
17185
+ });
17186
+ });
17187
+ __publicField(this, "isValid", (value) => {
17188
+ if (value == null) {
17189
+ return false;
17190
+ }
17191
+ return value.isValid();
17192
+ });
17193
+ __publicField(this, "format", (value, formatKey) => {
17194
+ return this.formatByString(value, this.formats[formatKey]);
17195
+ });
17196
+ __publicField(this, "formatByString", (value, formatString) => {
17197
+ return this.setLocaleToValue(value).format(formatString);
17198
+ });
17199
+ __publicField(this, "formatNumber", (numberToFormat) => {
17200
+ return numberToFormat;
17201
+ });
17202
+ __publicField(this, "isEqual", (value, comparing) => {
17203
+ if (value === null && comparing === null) {
17204
+ return true;
17205
+ }
17206
+ if (value === null || comparing === null) {
17207
+ return false;
17208
+ }
17209
+ return value.toDate().getTime() === comparing.toDate().getTime();
17210
+ });
17211
+ __publicField(this, "isSameYear", (value, comparing) => {
17212
+ return this.isSame(value, comparing, "YYYY");
17213
+ });
17214
+ __publicField(this, "isSameMonth", (value, comparing) => {
17215
+ return this.isSame(value, comparing, "YYYY-MM");
17216
+ });
17217
+ __publicField(this, "isSameDay", (value, comparing) => {
17218
+ return this.isSame(value, comparing, "YYYY-MM-DD");
17219
+ });
17220
+ __publicField(this, "isSameHour", (value, comparing) => {
17221
+ return value.isSame(comparing, "hour");
17222
+ });
17223
+ __publicField(this, "isAfter", (value, comparing) => {
17224
+ return value > comparing;
17225
+ });
17226
+ __publicField(this, "isAfterYear", (value, comparing) => {
17227
+ if (!this.hasUTCPlugin()) {
17228
+ return value.isAfter(comparing, "year");
17229
+ }
17230
+ return !this.isSameYear(value, comparing) && value.utc() > comparing.utc();
17231
+ });
17232
+ __publicField(this, "isAfterDay", (value, comparing) => {
17233
+ if (!this.hasUTCPlugin()) {
17234
+ return value.isAfter(comparing, "day");
17235
+ }
17236
+ return !this.isSameDay(value, comparing) && value.utc() > comparing.utc();
17237
+ });
17238
+ __publicField(this, "isBefore", (value, comparing) => {
17239
+ return value < comparing;
17240
+ });
17241
+ __publicField(this, "isBeforeYear", (value, comparing) => {
17242
+ if (!this.hasUTCPlugin()) {
17243
+ return value.isBefore(comparing, "year");
17244
+ }
17245
+ return !this.isSameYear(value, comparing) && value.utc() < comparing.utc();
17246
+ });
17247
+ __publicField(this, "isBeforeDay", (value, comparing) => {
17248
+ if (!this.hasUTCPlugin()) {
17249
+ return value.isBefore(comparing, "day");
17250
+ }
17251
+ return !this.isSameDay(value, comparing) && value.utc() < comparing.utc();
17252
+ });
17253
+ __publicField(this, "isWithinRange", (value, [start2, end2]) => {
17254
+ return value >= start2 && value <= end2;
17255
+ });
17256
+ __publicField(this, "startOfYear", (value) => {
17257
+ return this.adjustOffset(value.startOf("year"));
17258
+ });
17259
+ __publicField(this, "startOfMonth", (value) => {
17260
+ return this.adjustOffset(value.startOf("month"));
17261
+ });
17262
+ __publicField(this, "startOfWeek", (value) => {
17263
+ return this.adjustOffset(this.setLocaleToValue(value).startOf("week"));
17264
+ });
17265
+ __publicField(this, "startOfDay", (value) => {
17266
+ return this.adjustOffset(value.startOf("day"));
17267
+ });
17268
+ __publicField(this, "endOfYear", (value) => {
17269
+ return this.adjustOffset(value.endOf("year"));
17270
+ });
17271
+ __publicField(this, "endOfMonth", (value) => {
17272
+ return this.adjustOffset(value.endOf("month"));
17273
+ });
17274
+ __publicField(this, "endOfWeek", (value) => {
17275
+ return this.adjustOffset(this.setLocaleToValue(value).endOf("week"));
17276
+ });
17277
+ __publicField(this, "endOfDay", (value) => {
17278
+ return this.adjustOffset(value.endOf("day"));
17279
+ });
17280
+ __publicField(this, "addYears", (value, amount) => {
17281
+ return this.adjustOffset(value.add(amount, "year"));
17282
+ });
17283
+ __publicField(this, "addMonths", (value, amount) => {
17284
+ return this.adjustOffset(value.add(amount, "month"));
17285
+ });
17286
+ __publicField(this, "addWeeks", (value, amount) => {
17287
+ return this.adjustOffset(value.add(amount, "week"));
17288
+ });
17289
+ __publicField(this, "addDays", (value, amount) => {
17290
+ return this.adjustOffset(value.add(amount, "day"));
17291
+ });
17292
+ __publicField(this, "addHours", (value, amount) => {
17293
+ return this.adjustOffset(value.add(amount, "hour"));
17294
+ });
17295
+ __publicField(this, "addMinutes", (value, amount) => {
17296
+ return this.adjustOffset(value.add(amount, "minute"));
17297
+ });
17298
+ __publicField(this, "addSeconds", (value, amount) => {
17299
+ return this.adjustOffset(value.add(amount, "second"));
17300
+ });
17301
+ __publicField(this, "getYear", (value) => {
17302
+ return value.year();
17303
+ });
17304
+ __publicField(this, "getMonth", (value) => {
17305
+ return value.month();
17306
+ });
17307
+ __publicField(this, "getDate", (value) => {
17308
+ return value.date();
17309
+ });
17310
+ __publicField(this, "getHours", (value) => {
17311
+ return value.hour();
17312
+ });
17313
+ __publicField(this, "getMinutes", (value) => {
17314
+ return value.minute();
17315
+ });
17316
+ __publicField(this, "getSeconds", (value) => {
17317
+ return value.second();
17318
+ });
17319
+ __publicField(this, "getMilliseconds", (value) => {
17320
+ return value.millisecond();
17321
+ });
17322
+ __publicField(this, "setYear", (value, year) => {
17323
+ return this.adjustOffset(value.set("year", year));
17324
+ });
17325
+ __publicField(this, "setMonth", (value, month) => {
17326
+ return this.adjustOffset(value.set("month", month));
17327
+ });
17328
+ __publicField(this, "setDate", (value, date) => {
17329
+ return this.adjustOffset(value.set("date", date));
17330
+ });
17331
+ __publicField(this, "setHours", (value, hours) => {
17332
+ return this.adjustOffset(value.set("hour", hours));
17333
+ });
17334
+ __publicField(this, "setMinutes", (value, minutes) => {
17335
+ return this.adjustOffset(value.set("minute", minutes));
17336
+ });
17337
+ __publicField(this, "setSeconds", (value, seconds) => {
17338
+ return this.adjustOffset(value.set("second", seconds));
17339
+ });
17340
+ __publicField(this, "setMilliseconds", (value, milliseconds) => {
17341
+ return this.adjustOffset(value.set("millisecond", milliseconds));
17342
+ });
17343
+ __publicField(this, "getDaysInMonth", (value) => {
17344
+ return value.daysInMonth();
17345
+ });
17346
+ __publicField(this, "getWeekArray", (value) => {
17347
+ const start2 = this.startOfWeek(this.startOfMonth(value));
17348
+ const end2 = this.endOfWeek(this.endOfMonth(value));
17349
+ let count = 0;
17350
+ let current = start2;
17351
+ const nestedWeeks = [];
17352
+ while (current < end2) {
17353
+ const weekNumber = Math.floor(count / 7);
17354
+ nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
17355
+ nestedWeeks[weekNumber].push(current);
17356
+ current = this.addDays(current, 1);
17357
+ count += 1;
17358
+ }
17359
+ return nestedWeeks;
17360
+ });
17361
+ __publicField(this, "getWeekNumber", (value) => {
17362
+ return value.week();
17363
+ });
17364
+ __publicField(this, "getYearRange", ([start2, end2]) => {
17365
+ const startDate = this.startOfYear(start2);
17366
+ const endDate = this.endOfYear(end2);
17367
+ const years = [];
17368
+ let current = startDate;
17369
+ while (this.isBefore(current, endDate)) {
17370
+ years.push(current);
17371
+ current = this.addYears(current, 1);
17372
+ }
17373
+ return years;
17374
+ });
17375
+ this.locale = locale;
17376
+ this.formats = _extends({}, defaultFormats, formats);
17377
+ dayjs.extend(customParseFormatPlugin);
17378
+ }
17379
+ getDayOfWeek(value) {
17380
+ return value.day() + 1;
17381
+ }
17382
+ }
17383
+ const DEFAULT_THEME = {
17384
+ headerBg: "#3f5fa3",
17385
+ headerText: "#ffffff",
17386
+ bodyBg: "#ffffff",
17387
+ border: "#cfd6e4"
17388
+ };
17389
+ const percentToGrow = (p) => Math.max(1, Math.round((p || 10) / 10));
17390
+ const MONTHS_SHORT = [
17391
+ "Jan",
17392
+ "Feb",
17393
+ "Mar",
17394
+ "Apr",
17395
+ "May",
17396
+ "Jun",
17397
+ "Jul",
17398
+ "Aug",
17399
+ "Sep",
17400
+ "Oct",
17401
+ "Nov",
17402
+ "Dec"
17403
+ ];
17404
+ const pad = (n) => String(n).padStart(2, "0");
17405
+ const isNumericValue = (v) => v !== null && v !== void 0 && v !== "" && !isNaN(v) && typeof v !== "boolean";
17406
+ const isDateValue = (v) => {
17407
+ if (v instanceof Date && !isNaN(v)) return true;
17408
+ if (typeof v === "string") {
17409
+ return /^\d{4}-\d{2}-\d{2}/.test(v) || /^\d{4}\/\d{2}\/\d{2}/.test(v) || /^\d{2}-\d{2}-\d{4}/.test(v);
17410
+ }
17411
+ return false;
17412
+ };
17413
+ const isBooleanValue = (v) => typeof v === "boolean" || v === "true" || v === "false";
17414
+ const formatDate = (value, format = "dd/MM/yyyy") => {
17415
+ if (!value) return "";
17416
+ const d = value instanceof Date ? value : new Date(value);
17417
+ if (isNaN(d)) return "";
17418
+ const dd = pad(d.getDate());
17419
+ const mm = pad(d.getMonth() + 1);
17420
+ const yyyy = d.getFullYear();
17421
+ const MMM = MONTHS_SHORT[d.getMonth()];
17422
+ pad(d.getHours());
17423
+ const hh12 = pad(d.getHours() % 12 || 12);
17424
+ const min2 = pad(d.getMinutes());
17425
+ const ampm = d.getHours() >= 12 ? "PM" : "AM";
17426
+ switch (format) {
17427
+ case "dd/MM/yyyy":
17428
+ return `${dd}/${mm}/${yyyy}`;
17429
+ case "dd-MM-yyyy":
17430
+ return `${dd}-${mm}-${yyyy}`;
17431
+ case "yyyy/MM/dd":
17432
+ return `${yyyy}/${mm}/${dd}`;
17433
+ case "dd-MMM-yyyy":
17434
+ return `${dd}-${MMM}-${yyyy}`;
17435
+ case "dd-MMM-yyyy hh:mm a":
17436
+ return `${dd}-${MMM}-${yyyy} ${hh12}:${min2} ${ampm}`;
17437
+ case "yyyy-MM-dd":
17438
+ return `${yyyy}-${mm}-${dd}`;
17439
+ default:
17440
+ return `${dd}/${mm}/${yyyy}`;
17441
+ }
17442
+ };
17443
+ const CURRENCY_LOCALE_MAP = {
17444
+ INR: "en-IN",
17445
+ USD: "en-US",
17446
+ EUR: "de-DE",
17447
+ GBP: "en-GB",
17448
+ JPY: "ja-JP",
17449
+ AUD: "en-AU",
17450
+ CAD: "en-CA",
17451
+ SGD: "en-SG"
17452
+ };
17453
+ const getLocaleFromCurrency = (currency) => {
17454
+ return CURRENCY_LOCALE_MAP[currency] || "en-IN";
17455
+ };
17456
+ const formatCurrency = ({
17457
+ value,
17458
+ decimal = 0,
17459
+ // 👈 NO DEFAULT
17460
+ currency,
17461
+ showSymbol = false
17462
+ }) => {
17463
+ if (value === null || value === void 0 || value === "") return "";
17464
+ const num = Number(value);
17465
+ if (isNaN(num)) return "";
17466
+ const locale = getLocaleFromCurrency(currency);
17467
+ const options = {};
17468
+ if (typeof decimal === "number") {
17469
+ options.minimumFractionDigits = decimal;
17470
+ options.maximumFractionDigits = decimal;
17471
+ }
17472
+ if (currency && showSymbol) {
17473
+ options.style = "currency";
17474
+ options.currency = currency;
17475
+ }
17476
+ return new Intl.NumberFormat(locale, options).format(num);
17477
+ };
17478
+ const formatPercentage = ({
17479
+ value,
17480
+ decimal,
17481
+ showSymbol = true
17482
+ }) => {
17483
+ if (value === null || value === void 0 || value === "") return "";
17484
+ const num = Number(value);
17485
+ if (isNaN(num)) return "";
17486
+ const options = {};
17487
+ if (typeof decimal === "number") {
17488
+ options.minimumFractionDigits = decimal;
17489
+ options.maximumFractionDigits = decimal;
17490
+ }
17491
+ const formatted = new Intl.NumberFormat("en-IN", options).format(num);
17492
+ return showSymbol ? `${formatted}%` : formatted;
17493
+ };
17494
+ const sanitizeColumns = (columns = []) => {
17495
+ if (!Array.isArray(columns)) return [];
17496
+ return columns.filter((col) => col && typeof col === "object").filter((col) => {
17497
+ if (!col.ColFields || typeof col.ColFields !== "string") return false;
17498
+ if (!col.ColHeading || typeof col.ColHeading !== "string") return false;
17499
+ return true;
17500
+ }).map((col, index) => ({
17501
+ // 🔒 enforce safe defaults
17502
+ ColOrder: typeof col.ColOrder === "number" ? col.ColOrder : index + 1,
17503
+ ...col
17504
+ }));
17505
+ };
17506
+ const getFinancialRange = (fy, quarter) => {
17507
+ const [startYear, endYear] = fy.split("-").map(Number);
17508
+ if (!quarter) {
17509
+ return {
17510
+ start: new Date(startYear, 3, 1),
17511
+ end: new Date(endYear, 2, 31)
17512
+ };
17513
+ }
17514
+ const map = {
17515
+ Q1: [3, 0, startYear],
17516
+ Q2: [6, 0, startYear],
17517
+ Q3: [9, 0, startYear],
17518
+ Q4: [0, 0, endYear]
17519
+ };
17520
+ const [month, day, year] = map[quarter];
17521
+ const start2 = new Date(year, month, 1);
17522
+ const end2 = new Date(year, month + 3, 0);
17523
+ return { start: start2, end: end2 };
17524
+ };
17525
+ function RangeDateFilter({ column, onClose }) {
17526
+ const current = column.getFilterValue() || {};
17527
+ const [from, setFrom] = useState(
17528
+ (current == null ? void 0 : current.from) ? dayjs(current.from) : null
17529
+ );
17530
+ const [to, setTo] = useState(
17531
+ (current == null ? void 0 : current.to) ? dayjs(current.to) : null
17532
+ );
17533
+ const canApply = Boolean(from && to);
17534
+ const handleApply = () => {
17535
+ column.setFilterValue({
17536
+ mode: "range",
17537
+ from: from.toDate(),
17538
+ // 🔥 convert here
17539
+ to: to.toDate()
17540
+ });
17541
+ onClose == null ? void 0 : onClose();
17542
+ };
17543
+ const handleClear = () => {
17544
+ setFrom(null);
17545
+ setTo(null);
17546
+ column.setFilterValue(void 0);
17547
+ onClose == null ? void 0 : onClose();
17548
+ };
17549
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { p: 2, width: 240, children: [
17550
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
17551
+ DatePicker,
17552
+ {
17553
+ label: "From",
17554
+ value: from,
17555
+ onChange: (v) => {
17556
+ setFrom(v);
17557
+ setTo(null);
17558
+ },
17559
+ slotProps: {
17560
+ textField: {
17561
+ size: "small",
17562
+ // Options: 'small', 'medium'
17563
+ style: { height: "40px", width: "100%" }
17564
+ // Custom height
17565
+ }
17566
+ }
17567
+ }
17568
+ ),
17569
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
17570
+ DatePicker,
17571
+ {
17572
+ label: "To",
17573
+ value: to,
17574
+ minDate: from,
17575
+ disabled: !from,
17576
+ onChange: (v) => setTo(v),
17577
+ sx: { mt: 2 },
17578
+ slotProps: {
17579
+ textField: {
17580
+ size: "small",
17581
+ // Options: 'small', 'medium'
17582
+ style: { height: "40px", width: "100%" }
17583
+ // Custom height
17584
+ }
17585
+ }
17586
+ }
17587
+ ),
17588
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
17589
+ Button$1,
17590
+ {
17591
+ fullWidth: true,
17592
+ size: "small",
17593
+ variant: "contained",
17594
+ sx: { mt: 1 },
17595
+ disabled: !canApply,
17596
+ onClick: handleApply,
17597
+ children: "Apply"
17598
+ }
17599
+ ),
17600
+ current.from && current.to && /* @__PURE__ */ jsxRuntimeExports.jsx(
17601
+ Button$1,
17602
+ {
17603
+ fullWidth: true,
17604
+ size: "small",
17605
+ sx: { mt: 0.5 },
17606
+ color: "error",
17607
+ onClick: handleClear,
17608
+ children: "Clear"
17609
+ }
17610
+ )
17611
+ ] });
17612
+ }
17613
+ const financialDateFilterFn = (row, columnId, filterValue) => {
17614
+ if (!filterValue) return true;
17615
+ const rowDate = row.getValue(columnId);
17616
+ if (!(rowDate instanceof Date)) return false;
17617
+ const { mode, from, to, fy, quarter } = filterValue;
17618
+ if (mode === "range") {
17619
+ if (from && rowDate < from) return false;
17620
+ if (to && rowDate > to) return false;
17621
+ return true;
17622
+ }
17623
+ if (mode === "financial") {
17624
+ const { start: start2, end: end2 } = getFinancialRange(fy, quarter);
17625
+ return rowDate >= start2 && rowDate <= end2;
17626
+ }
17627
+ return true;
17628
+ };
17629
+ const getFinancialYear = (date) => {
17630
+ const d = date instanceof Date ? date : new Date(date);
17631
+ if (isNaN(d)) return null;
17632
+ const year = d.getFullYear();
17633
+ return d.getMonth() >= 3 ? `${year}-${year + 1}` : `${year - 1}-${year}`;
17634
+ };
17635
+ function FinancialDateFilter({ column, fyOptions = [], closePopover }) {
17636
+ const activeFilter = column.getFilterValue();
17637
+ const [from, setFrom] = useState(
17638
+ (activeFilter == null ? void 0 : activeFilter.from) ? dayjs(activeFilter.from) : null
17639
+ );
17640
+ const [to, setTo] = useState(
17641
+ (activeFilter == null ? void 0 : activeFilter.to) ? dayjs(activeFilter.to) : null
17642
+ );
17643
+ const [fy, setFy] = useState((activeFilter == null ? void 0 : activeFilter.fy) || "");
17644
+ const [quarter, setQuarter] = useState((activeFilter == null ? void 0 : activeFilter.quarter) || "");
17645
+ const isManual = !fy;
17646
+ const isFinancial = Boolean(fy);
17647
+ const apply = () => {
17648
+ if (isFinancial) {
17649
+ const { start: start2, end: end2 } = getFinancialRange(fy, quarter || null);
17650
+ column.setFilterValue({
17651
+ mode: "financial",
17652
+ fy,
17653
+ quarter: quarter || null,
17654
+ from: start2,
17655
+ // Date
17656
+ to: end2
17657
+ // Date
17658
+ });
17659
+ closePopover();
17660
+ return;
17661
+ }
17662
+ if (from && to) {
17663
+ column.setFilterValue({
17664
+ mode: "range",
17665
+ from: from.toDate(),
17666
+ // ✅ convert HERE only
17667
+ to: to.toDate()
17668
+ });
17669
+ closePopover();
17670
+ }
17671
+ };
17672
+ const clear = () => {
17673
+ column.setFilterValue(void 0);
17674
+ setFrom(null);
17675
+ setTo(null);
17676
+ setFy("");
17677
+ setQuarter("");
17678
+ closePopover();
17679
+ };
17680
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { p: 2, width: 240, children: [
17681
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
17682
+ DatePicker,
17683
+ {
17684
+ label: "From",
17685
+ value: from,
17686
+ disabled: !isManual,
17687
+ onChange: (v) => {
17688
+ setFrom(v);
17689
+ setTo(null);
17690
+ },
17691
+ slotProps: {
17692
+ textField: {
17693
+ size: "small",
17694
+ // Options: 'small', 'medium'
17695
+ style: { height: "40px", width: "100%" }
17696
+ // Custom height
17697
+ }
17698
+ }
17699
+ }
17700
+ ),
17701
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
17702
+ DatePicker,
17703
+ {
17704
+ sx: { mt: 2 },
17705
+ label: "To",
17706
+ value: to,
17707
+ minDate: from,
17708
+ disabled: !isManual || !from,
17709
+ onChange: (v) => setTo(v),
17710
+ slotProps: {
17711
+ textField: {
17712
+ size: "small",
17713
+ // Options: 'small', 'medium'
17714
+ style: { height: "40px", width: "100%" }
17715
+ // Custom height
17716
+ }
17717
+ }
17718
+ }
17719
+ ),
17720
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
17721
+ Select,
17722
+ {
17723
+ fullWidth: true,
17724
+ value: fy,
17725
+ onChange: (e) => {
17726
+ setFy(e.target.value);
17727
+ setQuarter("");
17728
+ setFrom(null);
17729
+ setTo(null);
17730
+ },
17731
+ sx: { mt: 1 },
17732
+ displayEmpty: true,
17733
+ size: "small",
17734
+ children: [
17735
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MenuItem, { value: "", children: "Financial Year" }),
17736
+ fyOptions.map((y) => /* @__PURE__ */ jsxRuntimeExports.jsx(MenuItem, { value: y, children: y }, y))
17737
+ ]
17738
+ }
17739
+ ),
17740
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
17741
+ Select,
17742
+ {
17743
+ fullWidth: true,
17744
+ disabled: !fy,
17745
+ value: quarter,
17746
+ onChange: (e) => setQuarter(e.target.value),
17747
+ sx: { mt: 1 },
17748
+ displayEmpty: true,
17749
+ size: "small",
17750
+ children: [
17751
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MenuItem, { value: "", disabled: true, children: "Quarter" }),
17752
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MenuItem, { value: "Q1", children: "Q1 (Apr–Jun)" }),
17753
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MenuItem, { value: "Q2", children: "Q2 (Jul–Sep)" }),
17754
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MenuItem, { value: "Q3", children: "Q3 (Oct–Dec)" }),
17755
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MenuItem, { value: "Q4", children: "Q4 (Jan–Mar)" })
17756
+ ]
17757
+ }
17758
+ ),
17759
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
17760
+ Button$1,
17761
+ {
17762
+ fullWidth: true,
17763
+ variant: "contained",
17764
+ sx: { mt: 1 },
17765
+ disabled: !(isFinancial || from && to),
17766
+ onClick: apply,
17767
+ children: "APPLY"
17768
+ }
17769
+ ),
17770
+ activeFilter && /* @__PURE__ */ jsxRuntimeExports.jsx(
17771
+ Button$1,
17772
+ {
17773
+ fullWidth: true,
17774
+ color: "error",
17775
+ sx: { mt: 1 },
17776
+ onClick: clear,
17777
+ children: "CLEAR"
17778
+ }
17779
+ )
17780
+ ] });
17781
+ }
17782
+ function DateFilterHeader({ title, column, mode, fyOptions = [] }) {
17783
+ const [anchorEl, setAnchorEl] = useState(null);
17784
+ const open = Boolean(anchorEl);
17785
+ const filterValue = column.getFilterValue();
17786
+ const hasFilter = filterValue && (filterValue.mode === "range" && filterValue.from && filterValue.to || filterValue.mode === "financial" && filterValue.fy);
17787
+ const tooltipText = (() => {
17788
+ if (!hasFilter) return "";
17789
+ if (filterValue.mode === "range") {
17790
+ return `${filterValue.from.toLocaleDateString()} → ${filterValue.to.toLocaleDateString()}`;
17791
+ }
17792
+ if (filterValue.mode === "financial") {
17793
+ return filterValue.quarter ? `${filterValue.fy} - ${filterValue.quarter}` : `${filterValue.fy}`;
17794
+ }
17795
+ return "";
17796
+ })();
17797
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
17798
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: title }),
17799
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
17800
+ IconButton,
17801
+ {
17802
+ size: "small",
17803
+ onClick: (e) => setAnchorEl(e.currentTarget),
17804
+ title: tooltipText,
17805
+ color: hasFilter ? "primary" : "default",
17806
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Funnel, { size: 14 })
17807
+ }
17808
+ ),
17809
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
17810
+ Popover$2,
17811
+ {
17812
+ open,
17813
+ anchorEl,
17814
+ onClose: () => setAnchorEl(null),
17815
+ anchorOrigin: { vertical: "bottom", horizontal: "left" },
17816
+ children: mode === "financial" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
17817
+ FinancialDateFilter,
17818
+ {
17819
+ column,
17820
+ fyOptions,
17821
+ closePopover: () => setAnchorEl(null)
17822
+ }
17823
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
17824
+ RangeDateFilter,
17825
+ {
17826
+ column,
17827
+ onClose: () => setAnchorEl(null)
17828
+ }
17829
+ )
17830
+ }
17831
+ )
17832
+ ] });
17833
+ }
17834
+ const alignOpt = ["left", "center", "right"];
17835
+ const buildColumn = (col, fyOptions, detectedColumnTypes, aggregates) => {
17836
+ const grow = percentToGrow(col.ColSize);
17837
+ const resolvedType = col.ColDataType || detectedColumnTypes[col.ColFields] || "string";
17838
+ const isNumericColumn = resolvedType === "number";
17839
+ const isDateColumn = resolvedType === "date";
17840
+ const isBooleanColumn = resolvedType === "boolean";
17841
+ let align = "left";
17842
+ if (typeof col.ColAllignment === "string") {
17843
+ align = alignOpt.includes(col.ColAllignment.toLowerCase()) ? col.ColAllignment.toLowerCase() : "left";
17844
+ } else if (isNumericColumn) {
17845
+ align = "right";
17846
+ } else if (isDateColumn || isBooleanColumn) {
17847
+ align = "center";
17848
+ }
17849
+ const column = {
17850
+ header: col.ColHeading,
17851
+ accessorKey: col.ColFields,
17852
+ size: grow * 50,
17853
+ grow,
17854
+ enableSorting: !!col.ColSortable,
17855
+ enableEditing: !!col.ColEditable,
17856
+ enableHiding: true,
17857
+ enablePinning: Boolean(col.Pin),
17858
+ muiTableBodyCellProps: {
17859
+ align,
17860
+ sx: {
17861
+ fontFamily: col.FntName,
17862
+ color: col.FColor || "#1f2937",
17863
+ backgroundColor: col.BColor || "#ffffff",
17864
+ fontSize: col.FntSize || 13,
17865
+ fontWeight: col.FntBold ? 600 : 400
17866
+ }
17867
+ },
17868
+ muiTableFooterCellProps: {
17869
+ align,
17870
+ sx: {
17871
+ fontWeight: "bold",
17872
+ fontSize: col.FntSize || 14
17873
+ }
17874
+ }
17875
+ };
17876
+ if (typeof col.Render === "function") {
17877
+ column.Cell = ({ row, cell }) => col.Render({
17878
+ row,
17879
+ cell,
17880
+ value: row.original[col.ColFields]
17881
+ });
17882
+ if (col.IsUIOnly) {
17883
+ column.enableSorting = false;
17884
+ column.enableColumnFilter = false;
17885
+ column.enableGrouping = false;
17886
+ column.enableEditing = false;
17887
+ column.enableColumnOrdering = false;
17888
+ column.enableColumnActions = false;
17889
+ column.enableHiding = false;
17890
+ column.enablePinning = Boolean(col.Pin);
17891
+ }
17892
+ return column;
17893
+ }
17894
+ if (isDateColumn) {
17895
+ column.id = col.ColFields;
17896
+ column.accessorFn = (row) => {
17897
+ const v = row[col.ColFields];
17898
+ if (!v) return null;
17899
+ const d = v instanceof Date ? v : new Date(v);
17900
+ return isNaN(d) ? null : d;
17901
+ };
17902
+ column.Cell = ({ cell }) => formatDate(cell.getValue(), col.DateFormat || "dd/MM/yyyy");
17903
+ if (!col.DateMode || col.DateMode === "single") {
17904
+ column.filterVariant = "date";
17905
+ column.filterFn = (row, columnId, filterValue) => {
17906
+ if (!filterValue) return true;
17907
+ const rowDate = row.getValue(columnId);
17908
+ if (!(rowDate instanceof Date)) return false;
17909
+ const f = filterValue instanceof Date ? filterValue : filterValue.toDate();
17910
+ return rowDate.getFullYear() === f.getFullYear() && rowDate.getMonth() === f.getMonth() && rowDate.getDate() === f.getDate();
17911
+ };
17912
+ return column;
17913
+ }
17914
+ if (col.DateMode === "range" || col.DateMode === "financial") {
17915
+ delete column.filterVariant;
17916
+ column.enableColumnFilter = false;
17917
+ column.filterFn = financialDateFilterFn;
17918
+ column.Header = ({ column: column2 }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
17919
+ DateFilterHeader,
17920
+ {
17921
+ title: col.ColHeading,
17922
+ column: column2,
17923
+ mode: col.DateMode,
17924
+ fyOptions
17925
+ }
17926
+ );
17927
+ }
17928
+ return column;
17929
+ }
17930
+ if (isNumericColumn) {
17931
+ column.Cell = ({ cell }) => {
17932
+ const value = cell.getValue();
17933
+ if (col.IsPercentage) {
17934
+ return formatPercentage({
17935
+ value,
17936
+ decimal: col.Decimal
17937
+ });
17938
+ }
17939
+ if (col.Currency) {
17940
+ return formatCurrency({
17941
+ value,
17942
+ decimal: col.Decimal,
17943
+ currency: col.Currency,
17944
+ showSymbol: col.ShowCurrencySymbol
17945
+ });
17946
+ }
17947
+ return formatCurrency({
17948
+ value,
17949
+ decimal: col.Decimal
17950
+ });
17951
+ };
17952
+ }
17953
+ if (col.TotTyp) {
17954
+ column.Footer = () => {
17955
+ const value = aggregates[col.ColFields];
17956
+ if (value === void 0 || value === null) return "";
17957
+ if (isNumericColumn && col.IsPercentage) {
17958
+ return formatPercentage({
17959
+ value,
17960
+ decimal: col.Decimal
17961
+ });
17962
+ }
17963
+ if (isNumericColumn && col.Currency) {
17964
+ return formatCurrency({
17965
+ value,
17966
+ decimal: col.Decimal,
17967
+ currency: col.Currency,
17968
+ showSymbol: col.ShowCurrencySymbol
17969
+ });
17970
+ }
17971
+ if (isNumericColumn) {
17972
+ return formatCurrency({
17973
+ value,
17974
+ decimal: col.Decimal
17975
+ });
17976
+ }
17977
+ return String(value);
17978
+ };
17979
+ }
17980
+ return column;
17981
+ };
17982
+ const defaultToolBarOpt = {
17983
+ enabled: true,
17984
+ globalSearch: true,
17985
+ columnFilters: true,
17986
+ densityToggle: true,
17987
+ fullscreenToggle: true,
17988
+ exportBtn: true,
17989
+ showHideColumnsBtn: true
17990
+ };
17991
+ const defaultControlOpt = {
17992
+ columnActions: true,
17993
+ dragging: true,
17994
+ colPinning: true,
17995
+ pagination: true,
17996
+ rowSelection: false,
17997
+ rowPinning: false,
17998
+ grouping: false,
17999
+ sorting: true,
18000
+ editing: false,
18001
+ resizing: true
18002
+ };
18003
+ function SmartGridTable({
18004
+ columns = [],
18005
+ data = [],
18006
+ height: height2 = "100%",
18007
+ width: width2 = "100%",
18008
+ theme = DEFAULT_THEME,
18009
+ paginationStyle = "default",
18010
+ topToolbar = defaultToolBarOpt,
18011
+ controls = defaultControlOpt,
18012
+ onRowSelectionChange,
18013
+ isLoading = false
18014
+ }) {
18015
+ const safeColumns = useMemo(
18016
+ () => sanitizeColumns(columns),
18017
+ [columns]
18018
+ );
18019
+ const safeData = useMemo(
18020
+ () => Array.isArray(data) ? data : [],
18021
+ [data]
18022
+ );
18023
+ const [rowSelection, setRowSelection] = useState({});
18024
+ const isMobile = useMediaQuery("(max-width:600px)");
18025
+ const mergedTheme = { ...DEFAULT_THEME, ...theme };
18026
+ topToolbar = { ...defaultToolBarOpt, ...topToolbar };
18027
+ controls = { ...defaultControlOpt, ...controls };
18028
+ const isGridDisabled = isLoading || safeColumns.length === 0 || safeData.length === 0;
18029
+ const resolvedTopToolbar = {
18030
+ ...defaultToolBarOpt,
18031
+ ...topToolbar,
18032
+ enabled: !isGridDisabled && (topToolbar == null ? void 0 : topToolbar.enabled) !== false
18033
+ };
18034
+ const detectedColumnTypes = useMemo(() => {
18035
+ if (!Array.isArray(data) || !safeData.length) return {};
18036
+ const sample = safeData[0];
18037
+ const map = {};
18038
+ Object.keys(sample).forEach((key) => {
18039
+ const v = sample[key];
18040
+ if (isDateValue(v)) map[key] = "date";
18041
+ else if (isNumericValue(v)) map[key] = "number";
18042
+ else if (isBooleanValue(v)) map[key] = "boolean";
18043
+ else map[key] = "string";
18044
+ });
18045
+ return map;
18046
+ }, [safeData]);
18047
+ const aggregates = useMemo(() => {
18048
+ if (isLoading || safeData.length === 0 || safeColumns.length === 0) {
18049
+ return {};
18050
+ }
18051
+ if (!Array.isArray(data) || data.length === 0) return {};
18052
+ const result2 = {};
18053
+ columns == null ? void 0 : columns.forEach((col) => {
18054
+ if (!col.TotTyp) return;
18055
+ let count = 0;
18056
+ let sum = 0;
18057
+ let min2 = Infinity;
18058
+ let max2 = -Infinity;
18059
+ for (const row of data) {
18060
+ const val = Number(row[col.ColFields]);
18061
+ if (isNaN(val)) continue;
18062
+ count++;
18063
+ sum += val;
18064
+ if (val < min2) min2 = val;
18065
+ if (val > max2) max2 = val;
18066
+ }
18067
+ switch (col.TotTyp) {
18068
+ case "SUM":
18069
+ result2[col.ColFields] = sum;
18070
+ break;
18071
+ case "AVG":
18072
+ result2[col.ColFields] = count ? sum / count : 0;
18073
+ break;
18074
+ case "MIN":
18075
+ result2[col.ColFields] = count ? min2 : "";
18076
+ break;
18077
+ case "MAX":
18078
+ result2[col.ColFields] = count ? max2 : "";
18079
+ break;
18080
+ case "COUNT":
18081
+ result2[col.ColFields] = count;
18082
+ break;
18083
+ }
18084
+ });
18085
+ return result2;
18086
+ }, [safeData, safeColumns, isLoading]);
18087
+ const fyOptions = useMemo(() => {
18088
+ if (!Array.isArray(data)) return [];
18089
+ const fyColumn = columns == null ? void 0 : columns.find(
18090
+ (c) => c.ColDataType === "date" && c.DateMode === "financial"
18091
+ );
18092
+ if (!fyColumn) return [];
18093
+ return [
18094
+ ...new Set(
18095
+ data.map((r2) => getFinancialYear(r2[fyColumn.ColFields])).filter(Boolean)
18096
+ )
18097
+ ];
18098
+ }, [data, columns]);
18099
+ const finalColumns = useMemo(() => {
18100
+ if (safeColumns.length === 0) return [];
18101
+ return safeColumns.sort((a, b) => a.ColOrder - b.ColOrder).map(
18102
+ (col) => buildColumn(col, fyOptions, detectedColumnTypes, aggregates)
18103
+ );
18104
+ }, [safeColumns, fyOptions, detectedColumnTypes, aggregates]);
18105
+ const columnPinning = useMemo(() => {
18106
+ const left2 = [];
18107
+ const right2 = [];
18108
+ (safeColumns || []).forEach((col) => {
18109
+ if (col.Pin === "left") left2.push(col.ColFields);
18110
+ if (col.Pin === "right") right2.push(col.ColFields);
18111
+ });
18112
+ return { left: left2, right: right2 };
18113
+ }, [safeColumns]);
18114
+ const columnVisibility = useMemo(() => {
18115
+ const visibility = {};
18116
+ (safeColumns || []).forEach((col) => {
18117
+ if (col.IsHidden === true) {
18118
+ visibility[col.ColFields] = false;
18119
+ }
18120
+ });
18121
+ return visibility;
18122
+ }, [safeColumns]);
18123
+ const hasValidColumns = safeColumns.length > 0;
18124
+ const hasData = safeData.length > 0;
18125
+ const disableAllActions = isLoading || !hasValidColumns || !hasData;
18126
+ const safeFinalColumns = finalColumns.length ? finalColumns : [];
18127
+ if (!hasValidColumns) {
18128
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { p: 3, textAlign: "center", color: "text.secondary", children: "No valid columns provided" });
18129
+ }
18130
+ const table = useMaterialReactTable({
18131
+ columns: safeFinalColumns,
18132
+ data: safeData,
18133
+ /* ===============================
18134
+ CORE LAYOUT (🔥 MUST BE semantic)
18135
+ ================================ */
18136
+ layoutMode: "semantic",
18137
+ getRowId: (row, index) => {
18138
+ var _a;
18139
+ return ((_a = row.id) == null ? void 0 : _a.toString()) ?? index.toString();
18140
+ },
18141
+ /* ===============================
18142
+ FEATURES
18143
+ ================================ */
18144
+ enableTopToolbar: resolvedTopToolbar.enabled,
18145
+ enableGlobalFilter: resolvedTopToolbar.globalSearch && !isGridDisabled,
18146
+ enableColumnFilters: resolvedTopToolbar.columnFilters && !isGridDisabled,
18147
+ enableDensityToggle: resolvedTopToolbar.densityToggle && !isGridDisabled,
18148
+ enableFullScreenToggle: resolvedTopToolbar.fullscreenToggle && !isGridDisabled,
18149
+ enableColumnOrdering: !isGridDisabled && (controls == null ? void 0 : controls.dragging),
18150
+ enableColumnPinning: !isGridDisabled && controls.colPinning,
18151
+ enablePagination: !isGridDisabled && controls.pagination,
18152
+ enableColumnActions: !isGridDisabled && controls.columnActions,
18153
+ enableRowSelection: !isGridDisabled && controls.rowSelection,
18154
+ enableGrouping: !isGridDisabled && controls.grouping,
18155
+ enableSorting: !isGridDisabled && controls.sorting,
18156
+ enableEditing: !isGridDisabled && controls.editing,
18157
+ editDisplayMode: "cell",
18158
+ enableColumnResizing: !disableAllActions && (controls == null ? void 0 : controls.resizing),
18159
+ enableRowVirtualization: !controls.rowPinning && true,
18160
+ enableStickyHeader: true,
18161
+ enableStickyFooter: true,
18162
+ enableBottomToolbar: !disableAllActions && (controls == null ? void 0 : controls.pagination),
18163
+ enableRowPinning: !disableAllActions && controls.rowPinning,
18164
+ enableGlobalFilterRankedResults: false,
18165
+ enableFilterMatchHighlighting: true,
18166
+ rowVirtualizerOptions: {
18167
+ overscan: 20
18168
+ },
18169
+ muiPaginationProps: {
18170
+ showRowsPerPage: !isMobile,
18171
+ // ✅ mobile = false, desktop = true
18172
+ showFirstButton: !isMobile,
18173
+ showLastButton: !isMobile,
18174
+ sx: {
18175
+ flexDirection: {
18176
+ xs: "column",
18177
+ sm: "row"
18178
+ },
18179
+ alignItems: {
18180
+ xs: "flex-start",
18181
+ sm: "center"
18182
+ },
18183
+ gap: 1
18184
+ }
18185
+ },
18186
+ //render top menu
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
+ ),
18199
+ /* ===============================
18200
+ INITIAL STATE
18201
+ ================================ */
18202
+ initialState: {
18203
+ pagination: {
18204
+ pageIndex: 0,
18205
+ pageSize: 50
18206
+ },
18207
+ density: "comfortable",
18208
+ columnPinning: (controls == null ? void 0 : controls.colPinning) ? columnPinning : { left: [], right: [] },
18209
+ columnVisibility
18210
+ },
18211
+ paginationDisplayMode: paginationStyle,
18212
+ /* ===============================
18213
+ ROW SELECTION STATE
18214
+ ================================ */
18215
+ state: {
18216
+ rowSelection,
18217
+ isLoading,
18218
+ showProgressBars: isLoading
18219
+ },
18220
+ onRowSelectionChange: (updater) => {
18221
+ const next = typeof updater === "function" ? updater(rowSelection) : updater;
18222
+ setRowSelection(next);
18223
+ if (onRowSelectionChange) {
18224
+ const selectedRows = Object.keys(next).map((rowId) => {
18225
+ var _a;
18226
+ return (_a = table.getRow(rowId)) == null ? void 0 : _a.original;
18227
+ }).filter(Boolean);
18228
+ onRowSelectionChange(selectedRows);
18229
+ }
18230
+ },
18231
+ muiTableBodyProps: {
18232
+ sx: {
18233
+ "&.MuiTableBody-root": {
18234
+ transform: "translateY(0px) !important"
18235
+ }
18236
+ }
18237
+ },
18238
+ /* ===============================
18239
+ ROOT (TABLE WRAPPER)
18240
+ ================================ */
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
+ ),
18264
+ /* ===============================
18265
+ TOP TOOLBAR (STICKY)
18266
+ ================================ */
18267
+ muiTopToolbarProps: {
18268
+ sx: {
18269
+ position: "sticky",
18270
+ top: 0,
18271
+ zIndex: 4,
18272
+ backgroundColor: mergedTheme.bodyBg,
18273
+ borderBottom: `1px solid ${mergedTheme.border}`
18274
+ }
18275
+ },
18276
+ /* ===============================
18277
+ HEADER (PIN SAFE)
18278
+ ================================ */
18279
+ muiTableHeadCellProps: {
18280
+ sx: {
18281
+ backgroundColor: mergedTheme.headerBg,
18282
+ color: mergedTheme.headerText,
18283
+ fontWeight: 600,
18284
+ borderRight: `1px solid ${mergedTheme.border}`,
18285
+ /* =============================== FILTER INPUT (WHEN OPEN) ================================ */
18286
+ "& .MuiInputBase-root": { color: mergedTheme.headerText },
18287
+ "& .MuiInputBase-input": { color: mergedTheme.headerText },
18288
+ "& .MuiInputBase-input::placeholder": { color: mergedTheme.headerText, opacity: 1 },
18289
+ "& .MuiInput-underline:before": { borderBottomColor: mergedTheme.headerText },
18290
+ "& .MuiInput-underline:hover:not(.Mui-disabled):before": { borderBottomColor: mergedTheme.headerText },
18291
+ "& .MuiInput-underline:after": { borderBottomColor: mergedTheme.headerText },
18292
+ '&[data-pinned="true"]': {
18293
+ backgroundColor: mergedTheme.headerBg
18294
+ },
18295
+ "& .MuiTableSortLabel-root": {
18296
+ color: `${mergedTheme.headerText} !important`
18297
+ },
18298
+ "& .MuiTableSortLabel-icon": {
18299
+ color: `${mergedTheme.headerText} !important`,
18300
+ opacity: "1 !important"
18301
+ },
18302
+ "& .MuiIconButton-root": {
18303
+ color: `${mergedTheme.headerText} !important`
18304
+ },
18305
+ "& .MuiSvgIcon-root": {
18306
+ color: `${mergedTheme.headerText} !important`,
18307
+ fill: `${mergedTheme.headerText} !important`
18308
+ },
18309
+ /* =============================== DATE PICKER FILTER (MUI X) ================================ */
18310
+ "& .MuiPickersInputBase-root": { color: mergedTheme.headerText },
18311
+ "& .MuiPickersInputBase-input": { color: mergedTheme.headerText },
18312
+ "& .MuiPickersSectionList-sectionContent": { color: mergedTheme.headerText },
18313
+ "& .MuiPickersSectionList-sectionSeparator": { color: mergedTheme.headerText },
18314
+ "& .MuiPickersInputAdornment-root .MuiIconButton-root": { color: mergedTheme.headerText },
18315
+ "& .MuiPickersInputAdornment-root .MuiSvgIcon-root": { color: mergedTheme.headerText, fill: mergedTheme.headerText },
18316
+ /* underline for filled/outlined pickers */
18317
+ "& .MuiFilledInput-underline:before": { borderBottomColor: "rgba(255,255,255,0.6)" },
18318
+ "& .MuiFilledInput-underline:hover:not(.Mui-disabled):before": { borderBottomColor: mergedTheme.headerText },
18319
+ "& .MuiFilledInput-underline:after": { borderBottomColor: mergedTheme.headerText }
18320
+ }
18321
+ },
18322
+ /* ===============================
18323
+ BODY CONTAINER
18324
+ ================================ */
18325
+ muiTableContainerProps: {
18326
+ sx: {
18327
+ overflow: "auto"
18328
+ }
18329
+ },
18330
+ /* ===============================
18331
+ BODY CELLS (PIN SAFE)
18332
+ ================================ */
18333
+ muiTableBodyCellProps: ({ cell }) => {
18334
+ var _a;
18335
+ return {
18336
+ title: (_a = cell.renderValue) == null ? void 0 : _a.call(cell),
18337
+ sx: {
18338
+ borderRight: `1px solid ${mergedTheme.border}`,
18339
+ backgroundColor: mergedTheme.bodyBg,
18340
+ "&.mrt-table-body-cell-pinned": {
18341
+ backgroundColor: mergedTheme.bodyBg,
18342
+ zIndex: 1
18343
+ }
18344
+ }
18345
+ };
18346
+ },
18347
+ /* ===============================
18348
+ ROW HOVER
18349
+ ================================ */
18350
+ muiTableBodyRowProps: {
18351
+ sx: {
18352
+ "&:hover .MuiTableCell-root::after": {
18353
+ content: '""',
18354
+ position: "absolute",
18355
+ inset: 0,
18356
+ backgroundColor: "rgba(0,0,0,0.03)",
18357
+ pointerEvents: "none"
18358
+ }
18359
+ }
18360
+ },
18361
+ /* ===============================
18362
+ FOOTER / PAGINATION (STICKY)
18363
+ ================================ */
18364
+ muiTableFooterRowProps: {
18365
+ sx: {
18366
+ backgroundColor: mergedTheme.bodyBg,
18367
+ color: mergedTheme.headerText
18368
+ }
18369
+ },
18370
+ muiBottomToolbarProps: {
18371
+ sx: {
18372
+ backgroundColor: mergedTheme.bodyBg,
18373
+ borderTop: `1px solid ${mergedTheme.border}`
18374
+ }
18375
+ },
18376
+ muiTablePaginationProps: {
18377
+ rowsPerPageOptions: [25, 50, 100],
18378
+ showFirstButton: true,
18379
+ showLastButton: true
18380
+ }
18381
+ });
18382
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(MaterialReactTable, { table });
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
+ }
18490
+ const ExportButton = ({
18491
+ data,
18492
+ filename = "data",
18493
+ disabled = false
18494
+ }) => {
18495
+ const [anchorEl, setAnchorEl] = useState(null);
18496
+ const [loading, setLoading] = useState(false);
18497
+ const open = Boolean(anchorEl);
18498
+ const handleOpen = (event) => {
18499
+ if (!disabled && !loading) {
18500
+ setAnchorEl(event.currentTarget);
18501
+ }
18502
+ };
18503
+ const handleClose = () => {
18504
+ setAnchorEl(null);
18505
+ };
18506
+ const downloadCSV = () => {
18507
+ if (!data || data.length === 0) {
18508
+ return;
18509
+ }
18510
+ const csvContent = [
18511
+ Object.keys(data[0]).join(","),
18512
+ ...data.map(
18513
+ (row) => Object.values(row).map((v) => `"${v}"`).join(",")
18514
+ )
18515
+ ].join("\n");
18516
+ const blob = new Blob([csvContent], {
18517
+ type: "text/csv;charset=utf-8;"
18518
+ });
18519
+ const url = window.URL.createObjectURL(blob);
18520
+ const a = document.createElement("a");
18521
+ a.href = url;
18522
+ a.download = `${filename}.csv`;
18523
+ a.click();
18524
+ window.URL.revokeObjectURL(url);
18525
+ };
18526
+ const downloadXLSX = () => {
18527
+ if (!data || data.length === 0) {
18528
+ return;
18529
+ }
18530
+ const worksheet = XLSX.utils.json_to_sheet(data);
18531
+ const workbook = XLSX.utils.book_new();
18532
+ XLSX.utils.book_append_sheet(workbook, worksheet, "Data");
18533
+ XLSX.writeFile(workbook, `${filename}.xlsx`);
18534
+ };
18535
+ const handleExport = async (type) => {
18536
+ handleClose();
18537
+ setLoading(true);
18538
+ setTimeout(() => {
18539
+ try {
18540
+ type === "csv" ? downloadCSV() : downloadXLSX();
18541
+ } catch (err) {
18542
+ console.error(err);
18543
+ } finally {
18544
+ setLoading(false);
18545
+ }
18546
+ }, 200);
18547
+ };
18548
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
18549
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip$3, { title: loading ? "Exporting…" : "Export", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
18550
+ IconButton,
18551
+ {
18552
+ onClick: handleOpen,
18553
+ disabled: disabled || loading,
18554
+ sx: {
18555
+ width: 40,
18556
+ height: 40
18557
+ },
18558
+ children: loading ? /* @__PURE__ */ jsxRuntimeExports.jsx(CircularProgress, { size: 20, color: "inherit" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Download, {})
18559
+ }
18560
+ ) }) }),
18561
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
18562
+ Menu,
18563
+ {
18564
+ anchorEl,
18565
+ open,
18566
+ onClose: handleClose,
18567
+ anchorOrigin: { vertical: "bottom", horizontal: "right" },
18568
+ transformOrigin: { vertical: "top", horizontal: "right" },
18569
+ children: [
18570
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(MenuItem, { onClick: () => handleExport("csv"), children: [
18571
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ListItemIcon, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Table, { color: "#3b74eeb2" }) }),
18572
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
18573
+ ListItemText,
18574
+ {
18575
+ primary: "Export as CSV",
18576
+ secondary: "Comma-separated values"
18577
+ }
18578
+ )
18579
+ ] }),
18580
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(MenuItem, { onClick: () => handleExport("xlsx"), children: [
18581
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ListItemIcon, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Sheet, { color: "#3bee86b2" }) }),
18582
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
18583
+ ListItemText,
18584
+ {
18585
+ primary: "Export as XLSX",
18586
+ secondary: "Excel spreadsheet"
18587
+ }
18588
+ )
18589
+ ] })
18590
+ ]
18591
+ }
18592
+ )
18593
+ ] });
18594
+ };
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
+ };
16429
18628
  export {
16430
18629
  ComboDropdown as MytekComboDropdown,
16431
18630
  CustomInput as MytekInputField,
@@ -16433,6 +18632,7 @@ export {
16433
18632
  Mt_MessageBox as MytekMessageBox,
16434
18633
  PowerDropdown as MytekPowerCombo,
16435
18634
  RadioButton as MytekRadioButton,
18635
+ SmartTable as MytekSmartTable,
16436
18636
  DynamicTabs as MytekTab,
16437
18637
  MasterTable as MytekTable,
16438
18638
  Tooltip as MytekTooltip,