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 +2210 -10
- package/dist/main.es.js.map +1 -1
- package/dist/main.umd.js +2207 -10
- package/dist/main.umd.js.map +1 -1
- package/package.json +1 -1
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
|
|
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" ?
|
|
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,2196 @@ 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 }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18200
|
+
SmartGridTopToolbar,
|
|
18201
|
+
{
|
|
18202
|
+
table: table2,
|
|
18203
|
+
theme: mergedTheme,
|
|
18204
|
+
topToolbar,
|
|
18205
|
+
isGridDisabled,
|
|
18206
|
+
isLoading,
|
|
18207
|
+
safeColumns,
|
|
18208
|
+
safeData
|
|
18209
|
+
}
|
|
18210
|
+
),
|
|
18211
|
+
/* ===============================
|
|
18212
|
+
INITIAL STATE
|
|
18213
|
+
================================ */
|
|
18214
|
+
initialState: {
|
|
18215
|
+
pagination: {
|
|
18216
|
+
pageIndex: 0,
|
|
18217
|
+
pageSize: 50
|
|
18218
|
+
},
|
|
18219
|
+
density: "comfortable",
|
|
18220
|
+
columnPinning: (controls == null ? void 0 : controls.colPinning) ? columnPinning : { left: [], right: [] },
|
|
18221
|
+
columnVisibility
|
|
18222
|
+
},
|
|
18223
|
+
paginationDisplayMode: paginationStyle,
|
|
18224
|
+
/* ===============================
|
|
18225
|
+
ROW SELECTION STATE
|
|
18226
|
+
================================ */
|
|
18227
|
+
state: {
|
|
18228
|
+
rowSelection,
|
|
18229
|
+
isLoading,
|
|
18230
|
+
showProgressBars: isLoading
|
|
18231
|
+
},
|
|
18232
|
+
onRowSelectionChange: (updater) => {
|
|
18233
|
+
const next = typeof updater === "function" ? updater(rowSelection) : updater;
|
|
18234
|
+
setRowSelection(next);
|
|
18235
|
+
if (onRowSelectionChange) {
|
|
18236
|
+
const selectedRows = Object.keys(next).map((rowId) => {
|
|
18237
|
+
var _a;
|
|
18238
|
+
return (_a = table.getRow(rowId)) == null ? void 0 : _a.original;
|
|
18239
|
+
}).filter(Boolean);
|
|
18240
|
+
onRowSelectionChange(selectedRows);
|
|
18241
|
+
}
|
|
18242
|
+
},
|
|
18243
|
+
muiTableBodyProps: {
|
|
18244
|
+
sx: {
|
|
18245
|
+
"&.MuiTableBody-root": {
|
|
18246
|
+
transform: "translateY(0px) !important"
|
|
18247
|
+
}
|
|
18248
|
+
}
|
|
18249
|
+
},
|
|
18250
|
+
/* ===============================
|
|
18251
|
+
ROOT (TABLE WRAPPER)
|
|
18252
|
+
================================ */
|
|
18253
|
+
muiTablePaperProps: React.useCallback(
|
|
18254
|
+
({ table: table2 }) => {
|
|
18255
|
+
const isFullScreen = table2.getState().isFullScreen;
|
|
18256
|
+
return {
|
|
18257
|
+
elevation: 0,
|
|
18258
|
+
sx: {
|
|
18259
|
+
height: height2,
|
|
18260
|
+
width: width2,
|
|
18261
|
+
display: "flex",
|
|
18262
|
+
flexDirection: "column",
|
|
18263
|
+
border: `1px solid ${mergedTheme.border}`,
|
|
18264
|
+
backgroundColor: mergedTheme.bodyBg,
|
|
18265
|
+
...isFullScreen && {
|
|
18266
|
+
position: "fixed",
|
|
18267
|
+
inset: 0,
|
|
18268
|
+
borderRadius: 0,
|
|
18269
|
+
zIndex: "9999999 !important"
|
|
18270
|
+
}
|
|
18271
|
+
}
|
|
18272
|
+
};
|
|
18273
|
+
},
|
|
18274
|
+
[height2, width2, mergedTheme]
|
|
18275
|
+
),
|
|
18276
|
+
/* ===============================
|
|
18277
|
+
TOP TOOLBAR (STICKY)
|
|
18278
|
+
================================ */
|
|
18279
|
+
muiTopToolbarProps: {
|
|
18280
|
+
sx: {
|
|
18281
|
+
position: "sticky",
|
|
18282
|
+
top: 0,
|
|
18283
|
+
zIndex: 4,
|
|
18284
|
+
backgroundColor: mergedTheme.bodyBg,
|
|
18285
|
+
borderBottom: `1px solid ${mergedTheme.border}`
|
|
18286
|
+
}
|
|
18287
|
+
},
|
|
18288
|
+
/* ===============================
|
|
18289
|
+
HEADER (PIN SAFE)
|
|
18290
|
+
================================ */
|
|
18291
|
+
muiTableHeadCellProps: {
|
|
18292
|
+
sx: {
|
|
18293
|
+
backgroundColor: mergedTheme.headerBg,
|
|
18294
|
+
color: mergedTheme.headerText,
|
|
18295
|
+
fontWeight: 600,
|
|
18296
|
+
borderRight: `1px solid ${mergedTheme.border}`,
|
|
18297
|
+
/* =============================== FILTER INPUT (WHEN OPEN) ================================ */
|
|
18298
|
+
"& .MuiInputBase-root": { color: mergedTheme.headerText },
|
|
18299
|
+
"& .MuiInputBase-input": { color: mergedTheme.headerText },
|
|
18300
|
+
"& .MuiInputBase-input::placeholder": { color: mergedTheme.headerText, opacity: 1 },
|
|
18301
|
+
"& .MuiInput-underline:before": { borderBottomColor: mergedTheme.headerText },
|
|
18302
|
+
"& .MuiInput-underline:hover:not(.Mui-disabled):before": { borderBottomColor: mergedTheme.headerText },
|
|
18303
|
+
"& .MuiInput-underline:after": { borderBottomColor: mergedTheme.headerText },
|
|
18304
|
+
'&[data-pinned="true"]': {
|
|
18305
|
+
backgroundColor: mergedTheme.headerBg
|
|
18306
|
+
},
|
|
18307
|
+
"& .MuiTableSortLabel-root": {
|
|
18308
|
+
color: `${mergedTheme.headerText} !important`
|
|
18309
|
+
},
|
|
18310
|
+
"& .MuiTableSortLabel-icon": {
|
|
18311
|
+
color: `${mergedTheme.headerText} !important`,
|
|
18312
|
+
opacity: "1 !important"
|
|
18313
|
+
},
|
|
18314
|
+
"& .MuiIconButton-root": {
|
|
18315
|
+
color: `${mergedTheme.headerText} !important`
|
|
18316
|
+
},
|
|
18317
|
+
"& .MuiSvgIcon-root": {
|
|
18318
|
+
color: `${mergedTheme.headerText} !important`,
|
|
18319
|
+
fill: `${mergedTheme.headerText} !important`
|
|
18320
|
+
},
|
|
18321
|
+
/* =============================== DATE PICKER FILTER (MUI X) ================================ */
|
|
18322
|
+
"& .MuiPickersInputBase-root": { color: mergedTheme.headerText },
|
|
18323
|
+
"& .MuiPickersInputBase-input": { color: mergedTheme.headerText },
|
|
18324
|
+
"& .MuiPickersSectionList-sectionContent": { color: mergedTheme.headerText },
|
|
18325
|
+
"& .MuiPickersSectionList-sectionSeparator": { color: mergedTheme.headerText },
|
|
18326
|
+
"& .MuiPickersInputAdornment-root .MuiIconButton-root": { color: mergedTheme.headerText },
|
|
18327
|
+
"& .MuiPickersInputAdornment-root .MuiSvgIcon-root": { color: mergedTheme.headerText, fill: mergedTheme.headerText },
|
|
18328
|
+
/* underline for filled/outlined pickers */
|
|
18329
|
+
"& .MuiFilledInput-underline:before": { borderBottomColor: "rgba(255,255,255,0.6)" },
|
|
18330
|
+
"& .MuiFilledInput-underline:hover:not(.Mui-disabled):before": { borderBottomColor: mergedTheme.headerText },
|
|
18331
|
+
"& .MuiFilledInput-underline:after": { borderBottomColor: mergedTheme.headerText }
|
|
18332
|
+
}
|
|
18333
|
+
},
|
|
18334
|
+
/* ===============================
|
|
18335
|
+
BODY CONTAINER
|
|
18336
|
+
================================ */
|
|
18337
|
+
muiTableContainerProps: {
|
|
18338
|
+
sx: {
|
|
18339
|
+
overflow: "auto"
|
|
18340
|
+
}
|
|
18341
|
+
},
|
|
18342
|
+
/* ===============================
|
|
18343
|
+
BODY CELLS (PIN SAFE)
|
|
18344
|
+
================================ */
|
|
18345
|
+
muiTableBodyCellProps: ({ cell }) => {
|
|
18346
|
+
var _a;
|
|
18347
|
+
return {
|
|
18348
|
+
title: (_a = cell.renderValue) == null ? void 0 : _a.call(cell),
|
|
18349
|
+
sx: {
|
|
18350
|
+
borderRight: `1px solid ${mergedTheme.border}`,
|
|
18351
|
+
backgroundColor: mergedTheme.bodyBg,
|
|
18352
|
+
"&.mrt-table-body-cell-pinned": {
|
|
18353
|
+
backgroundColor: mergedTheme.bodyBg,
|
|
18354
|
+
zIndex: 1
|
|
18355
|
+
}
|
|
18356
|
+
}
|
|
18357
|
+
};
|
|
18358
|
+
},
|
|
18359
|
+
/* ===============================
|
|
18360
|
+
ROW HOVER
|
|
18361
|
+
================================ */
|
|
18362
|
+
muiTableBodyRowProps: {
|
|
18363
|
+
sx: {
|
|
18364
|
+
"&:hover .MuiTableCell-root::after": {
|
|
18365
|
+
content: '""',
|
|
18366
|
+
position: "absolute",
|
|
18367
|
+
inset: 0,
|
|
18368
|
+
backgroundColor: "rgba(0,0,0,0.03)",
|
|
18369
|
+
pointerEvents: "none"
|
|
18370
|
+
}
|
|
18371
|
+
}
|
|
18372
|
+
},
|
|
18373
|
+
/* ===============================
|
|
18374
|
+
FOOTER / PAGINATION (STICKY)
|
|
18375
|
+
================================ */
|
|
18376
|
+
muiTableFooterRowProps: {
|
|
18377
|
+
sx: {
|
|
18378
|
+
backgroundColor: mergedTheme.bodyBg,
|
|
18379
|
+
color: mergedTheme.headerText
|
|
18380
|
+
}
|
|
18381
|
+
},
|
|
18382
|
+
muiBottomToolbarProps: {
|
|
18383
|
+
sx: {
|
|
18384
|
+
backgroundColor: mergedTheme.bodyBg,
|
|
18385
|
+
borderTop: `1px solid ${mergedTheme.border}`
|
|
18386
|
+
}
|
|
18387
|
+
},
|
|
18388
|
+
muiTablePaginationProps: {
|
|
18389
|
+
rowsPerPageOptions: [25, 50, 100],
|
|
18390
|
+
showFirstButton: true,
|
|
18391
|
+
showLastButton: true
|
|
18392
|
+
}
|
|
18393
|
+
});
|
|
18394
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MaterialReactTable, { table });
|
|
18395
|
+
}
|
|
18396
|
+
function SmartGridTopToolbar({
|
|
18397
|
+
table,
|
|
18398
|
+
theme,
|
|
18399
|
+
topToolbar,
|
|
18400
|
+
isGridDisabled,
|
|
18401
|
+
isLoading,
|
|
18402
|
+
safeColumns,
|
|
18403
|
+
safeData
|
|
18404
|
+
}) {
|
|
18405
|
+
const [searchValue, setSearchValue] = React.useState(
|
|
18406
|
+
table.getState().globalFilter ?? ""
|
|
18407
|
+
);
|
|
18408
|
+
const disable = isGridDisabled;
|
|
18409
|
+
React.useEffect(() => {
|
|
18410
|
+
if (disable) return;
|
|
18411
|
+
const t = setTimeout(() => {
|
|
18412
|
+
table.setGlobalFilter(searchValue || void 0);
|
|
18413
|
+
}, 300);
|
|
18414
|
+
return () => clearTimeout(t);
|
|
18415
|
+
}, [searchValue, table, disable]);
|
|
18416
|
+
const exportData = table.getFilteredRowModel().rows.map((row) => row.original);
|
|
18417
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(material.Box, { sx: { px: 2, py: 2 }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
18418
|
+
material.Box,
|
|
18419
|
+
{
|
|
18420
|
+
sx: {
|
|
18421
|
+
display: "grid",
|
|
18422
|
+
gridTemplateColumns: {
|
|
18423
|
+
xs: "1fr",
|
|
18424
|
+
sm: "1fr auto"
|
|
18425
|
+
},
|
|
18426
|
+
gap: 2,
|
|
18427
|
+
alignItems: "center",
|
|
18428
|
+
width: "100%"
|
|
18429
|
+
},
|
|
18430
|
+
children: [
|
|
18431
|
+
(topToolbar == null ? void 0 : topToolbar.globalSearch) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18432
|
+
material.TextField,
|
|
18433
|
+
{
|
|
18434
|
+
size: "small",
|
|
18435
|
+
fullWidth: true,
|
|
18436
|
+
disabled: disable,
|
|
18437
|
+
placeholder: isLoading ? "Loading..." : safeColumns.length === 0 ? "No columns configured" : safeData.length === 0 ? "No data available" : "Search...",
|
|
18438
|
+
value: searchValue,
|
|
18439
|
+
onChange: (e) => setSearchValue(e.target.value),
|
|
18440
|
+
InputProps: {
|
|
18441
|
+
startAdornment: /* @__PURE__ */ jsxRuntimeExports.jsx(material.InputAdornment, { position: "start", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchCheck, {}) })
|
|
18442
|
+
},
|
|
18443
|
+
sx: {
|
|
18444
|
+
"& .MuiOutlinedInput-root": {
|
|
18445
|
+
borderRadius: 1.5,
|
|
18446
|
+
"& fieldset": { borderColor: theme == null ? void 0 : theme.headerBg },
|
|
18447
|
+
"&:hover fieldset": { borderColor: theme == null ? void 0 : theme.headerBg },
|
|
18448
|
+
"&.Mui-focused fieldset": {
|
|
18449
|
+
borderColor: theme == null ? void 0 : theme.headerBg,
|
|
18450
|
+
borderWidth: 2
|
|
18451
|
+
}
|
|
18452
|
+
},
|
|
18453
|
+
"& .MuiOutlinedInput-input::placeholder": {
|
|
18454
|
+
opacity: 0.7
|
|
18455
|
+
},
|
|
18456
|
+
"& .MuiInputAdornment-root svg": {
|
|
18457
|
+
color: theme == null ? void 0 : theme.headerBg
|
|
18458
|
+
}
|
|
18459
|
+
}
|
|
18460
|
+
}
|
|
18461
|
+
),
|
|
18462
|
+
((topToolbar == null ? void 0 : topToolbar.exportBtn) || (topToolbar == null ? void 0 : topToolbar.columnFilters) || (topToolbar == null ? void 0 : topToolbar.densityToggle) || (topToolbar == null ? void 0 : topToolbar.showHideColumnsBtn) || (topToolbar == null ? void 0 : topToolbar.fullscreenToggle)) && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
18463
|
+
material.Paper,
|
|
18464
|
+
{
|
|
18465
|
+
elevation: 3,
|
|
18466
|
+
sx: {
|
|
18467
|
+
justifySelf: "end",
|
|
18468
|
+
// ✅ THIS IS THE KEY
|
|
18469
|
+
display: "inline-flex",
|
|
18470
|
+
alignItems: "center",
|
|
18471
|
+
width: "fit-content",
|
|
18472
|
+
px: 1,
|
|
18473
|
+
py: 0.2,
|
|
18474
|
+
borderRadius: 2,
|
|
18475
|
+
bgcolor: "background.paper",
|
|
18476
|
+
border: `1px solid ${theme == null ? void 0 : theme.headerBg}`,
|
|
18477
|
+
whiteSpace: "nowrap",
|
|
18478
|
+
opacity: disable ? 0.6 : 1,
|
|
18479
|
+
pointerEvents: disable ? "none" : "auto"
|
|
18480
|
+
},
|
|
18481
|
+
children: [
|
|
18482
|
+
(topToolbar == null ? void 0 : topToolbar.exportBtn) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18483
|
+
ExportButton,
|
|
18484
|
+
{
|
|
18485
|
+
data: exportData,
|
|
18486
|
+
color: theme == null ? void 0 : theme.headerBg,
|
|
18487
|
+
filename: "table-data",
|
|
18488
|
+
disabled: disable
|
|
18489
|
+
}
|
|
18490
|
+
),
|
|
18491
|
+
(topToolbar == null ? void 0 : topToolbar.columnFilters) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ToggleFiltersButton, { table, disabled: disable }),
|
|
18492
|
+
(topToolbar == null ? void 0 : topToolbar.densityToggle) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ToggleDensePaddingButton, { table, disabled: disable }),
|
|
18493
|
+
(topToolbar == null ? void 0 : topToolbar.showHideColumnsBtn) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ShowHideColumnsButton, { table, disabled: disable }),
|
|
18494
|
+
(topToolbar == null ? void 0 : topToolbar.fullscreenToggle) && /* @__PURE__ */ jsxRuntimeExports.jsx(materialReactTable.MRT_ToggleFullScreenButton, { table, disabled: disable })
|
|
18495
|
+
]
|
|
18496
|
+
}
|
|
18497
|
+
)
|
|
18498
|
+
]
|
|
18499
|
+
}
|
|
18500
|
+
) });
|
|
18501
|
+
}
|
|
18502
|
+
const ExportButton = ({
|
|
18503
|
+
data,
|
|
18504
|
+
filename = "data",
|
|
18505
|
+
disabled = false
|
|
18506
|
+
}) => {
|
|
18507
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
18508
|
+
const [loading, setLoading] = React.useState(false);
|
|
18509
|
+
const open = Boolean(anchorEl);
|
|
18510
|
+
const handleOpen = (event) => {
|
|
18511
|
+
if (!disabled && !loading) {
|
|
18512
|
+
setAnchorEl(event.currentTarget);
|
|
18513
|
+
}
|
|
18514
|
+
};
|
|
18515
|
+
const handleClose = () => {
|
|
18516
|
+
setAnchorEl(null);
|
|
18517
|
+
};
|
|
18518
|
+
const downloadCSV = () => {
|
|
18519
|
+
if (!data || data.length === 0) {
|
|
18520
|
+
return;
|
|
18521
|
+
}
|
|
18522
|
+
const csvContent = [
|
|
18523
|
+
Object.keys(data[0]).join(","),
|
|
18524
|
+
...data.map(
|
|
18525
|
+
(row) => Object.values(row).map((v) => `"${v}"`).join(",")
|
|
18526
|
+
)
|
|
18527
|
+
].join("\n");
|
|
18528
|
+
const blob = new Blob([csvContent], {
|
|
18529
|
+
type: "text/csv;charset=utf-8;"
|
|
18530
|
+
});
|
|
18531
|
+
const url = window.URL.createObjectURL(blob);
|
|
18532
|
+
const a = document.createElement("a");
|
|
18533
|
+
a.href = url;
|
|
18534
|
+
a.download = `${filename}.csv`;
|
|
18535
|
+
a.click();
|
|
18536
|
+
window.URL.revokeObjectURL(url);
|
|
18537
|
+
};
|
|
18538
|
+
const downloadXLSX = () => {
|
|
18539
|
+
if (!data || data.length === 0) {
|
|
18540
|
+
return;
|
|
18541
|
+
}
|
|
18542
|
+
const worksheet = XLSX__namespace.utils.json_to_sheet(data);
|
|
18543
|
+
const workbook = XLSX__namespace.utils.book_new();
|
|
18544
|
+
XLSX__namespace.utils.book_append_sheet(workbook, worksheet, "Data");
|
|
18545
|
+
XLSX__namespace.writeFile(workbook, `${filename}.xlsx`);
|
|
18546
|
+
};
|
|
18547
|
+
const handleExport = async (type) => {
|
|
18548
|
+
handleClose();
|
|
18549
|
+
setLoading(true);
|
|
18550
|
+
setTimeout(() => {
|
|
18551
|
+
try {
|
|
18552
|
+
type === "csv" ? downloadCSV() : downloadXLSX();
|
|
18553
|
+
} catch (err) {
|
|
18554
|
+
console.error(err);
|
|
18555
|
+
} finally {
|
|
18556
|
+
setLoading(false);
|
|
18557
|
+
}
|
|
18558
|
+
}, 200);
|
|
18559
|
+
};
|
|
18560
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
18561
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(material.Tooltip, { title: loading ? "Exporting…" : "Export", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18562
|
+
material.IconButton,
|
|
18563
|
+
{
|
|
18564
|
+
onClick: handleOpen,
|
|
18565
|
+
disabled: disabled || loading,
|
|
18566
|
+
sx: {
|
|
18567
|
+
width: 40,
|
|
18568
|
+
height: 40
|
|
18569
|
+
},
|
|
18570
|
+
children: loading ? /* @__PURE__ */ jsxRuntimeExports.jsx(material.CircularProgress, { size: 20, color: "inherit" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Download, {})
|
|
18571
|
+
}
|
|
18572
|
+
) }) }),
|
|
18573
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
18574
|
+
material.Menu,
|
|
18575
|
+
{
|
|
18576
|
+
anchorEl,
|
|
18577
|
+
open,
|
|
18578
|
+
onClose: handleClose,
|
|
18579
|
+
anchorOrigin: { vertical: "bottom", horizontal: "right" },
|
|
18580
|
+
transformOrigin: { vertical: "top", horizontal: "right" },
|
|
18581
|
+
children: [
|
|
18582
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(material.MenuItem, { onClick: () => handleExport("csv"), children: [
|
|
18583
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(material.ListItemIcon, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Table, { color: "#3b74eeb2" }) }),
|
|
18584
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18585
|
+
material.ListItemText,
|
|
18586
|
+
{
|
|
18587
|
+
primary: "Export as CSV",
|
|
18588
|
+
secondary: "Comma-separated values"
|
|
18589
|
+
}
|
|
18590
|
+
)
|
|
18591
|
+
] }),
|
|
18592
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(material.MenuItem, { onClick: () => handleExport("xlsx"), children: [
|
|
18593
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(material.ListItemIcon, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Sheet, { color: "#3bee86b2" }) }),
|
|
18594
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
18595
|
+
material.ListItemText,
|
|
18596
|
+
{
|
|
18597
|
+
primary: "Export as XLSX",
|
|
18598
|
+
secondary: "Excel spreadsheet"
|
|
18599
|
+
}
|
|
18600
|
+
)
|
|
18601
|
+
] })
|
|
18602
|
+
]
|
|
18603
|
+
}
|
|
18604
|
+
)
|
|
18605
|
+
] });
|
|
18606
|
+
};
|
|
18607
|
+
const SmartTable = ({
|
|
18608
|
+
controls = {
|
|
18609
|
+
columnActions: true,
|
|
18610
|
+
dragging: true,
|
|
18611
|
+
colPinning: true,
|
|
18612
|
+
pagination: true,
|
|
18613
|
+
rowSelection: false,
|
|
18614
|
+
rowPinning: false,
|
|
18615
|
+
grouping: false,
|
|
18616
|
+
sorting: true,
|
|
18617
|
+
editing: false,
|
|
18618
|
+
resizing: true
|
|
18619
|
+
},
|
|
18620
|
+
topToolbar = {
|
|
18621
|
+
enabled: true,
|
|
18622
|
+
globalSearch: true,
|
|
18623
|
+
columnFilters: true,
|
|
18624
|
+
densityToggle: true,
|
|
18625
|
+
fullscreenToggle: true,
|
|
18626
|
+
exportBtn: true,
|
|
18627
|
+
showHideColumnsBtn: true
|
|
18628
|
+
},
|
|
18629
|
+
height: height2 = "100%",
|
|
18630
|
+
width: width2 = "100%",
|
|
18631
|
+
columns = [],
|
|
18632
|
+
data = [],
|
|
18633
|
+
isLoading = false,
|
|
18634
|
+
onRowSelectionChange = () => {
|
|
18635
|
+
}
|
|
18636
|
+
}) => {
|
|
18637
|
+
const props = { controls, topToolbar, height: height2, width: width2, isLoading, columns, data, onRowSelectionChange };
|
|
18638
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(xDatePickers.LocalizationProvider, { dateAdapter: AdapterDayjs, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SmartGridTable, { ...props }) });
|
|
18639
|
+
};
|
|
16444
18640
|
exports2.MytekComboDropdown = ComboDropdown;
|
|
16445
18641
|
exports2.MytekInputField = CustomInput;
|
|
16446
18642
|
exports2.MytekLoader = Loader;
|
|
16447
18643
|
exports2.MytekMessageBox = Mt_MessageBox;
|
|
16448
18644
|
exports2.MytekPowerCombo = PowerDropdown;
|
|
16449
18645
|
exports2.MytekRadioButton = RadioButton;
|
|
18646
|
+
exports2.MytekSmartTable = SmartTable;
|
|
16450
18647
|
exports2.MytekTab = DynamicTabs;
|
|
16451
18648
|
exports2.MytekTable = MasterTable;
|
|
16452
18649
|
exports2.MytekTooltip = Tooltip;
|