mytek-components 2.0.4 → 2.0.5

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