mytek-components 2.1.4 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.es.js CHANGED
@@ -518,40 +518,44 @@ const Button = ({
518
518
  children,
519
519
  onClick,
520
520
  fontSize = "16px",
521
- color: color2 = "#ffffff",
522
- backgroundColor: backgroundColor2 = "#3369BB",
521
+ color: color2 = "#fff",
522
+ backgroundColor: backgroundColor2 = "#3B5AA1",
523
+ hoverBackgroundColor = "#2F4B8A",
524
+ disabledBackgroundColor = "#9CA3AF",
525
+ // gray-400
526
+ disabledTextColor = "#E5E7EB",
527
+ // gray-200
523
528
  height: height2 = "40px",
524
- width: width2 = "100px",
529
+ width: width2 = "auto",
525
530
  border: border2 = "none",
526
- borderRadius: borderRadius2 = "4px",
527
- padding: padding2 = "10px 20px",
528
- fontWeight = "normal",
529
- style: style2 = {},
531
+ borderRadius: borderRadius2 = "6px",
532
+ padding: padding2 = "10px 16px",
533
+ fontWeight = "500",
530
534
  loader = false,
531
535
  disabled = false,
536
+ style: style2 = {},
532
537
  ...rest
533
538
  }) => {
534
539
  const isDisabled = loader || disabled;
535
540
  const className = clsx(
536
- "flex items-center justify-center transition-opacity",
541
+ "flex items-center justify-center transition-all duration-200 overflow-hidden",
537
542
  {
538
543
  "cursor-not-allowed opacity-60": isDisabled,
539
- "cursor-pointer": !isDisabled
544
+ "cursor-pointer hover:brightness-110 active:scale-[0.98]": !isDisabled
540
545
  },
541
546
  rest.className
542
- // ✅ allow external Tailwind className overrides
543
547
  );
544
548
  const buttonStyle = {
545
549
  fontSize,
546
- color: color2,
547
- backgroundColor: backgroundColor2,
550
+ color: isDisabled ? disabledTextColor : color2,
551
+ backgroundColor: isDisabled ? disabledBackgroundColor : backgroundColor2,
548
552
  height: height2,
549
- // ✅ Only apply width if w-full is NOT passed via className
550
553
  width: rest.className?.includes("w-full") ? void 0 : width2,
551
554
  border: border2,
552
555
  borderRadius: borderRadius2,
553
556
  padding: padding2,
554
557
  fontWeight,
558
+ cursor: isDisabled ? "not-allowed" : "pointer",
555
559
  ...style2
556
560
  };
557
561
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -561,8 +565,14 @@ const Button = ({
561
565
  disabled: isDisabled,
562
566
  className,
563
567
  style: buttonStyle,
568
+ onMouseEnter: (e) => {
569
+ if (!isDisabled) e.currentTarget.style.backgroundColor = hoverBackgroundColor;
570
+ },
571
+ onMouseLeave: (e) => {
572
+ if (!isDisabled) e.currentTarget.style.backgroundColor = backgroundColor2;
573
+ },
564
574
  ...rest,
565
- children: loader ? /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { inline: true }) : label || children
575
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate w-full", children: loader ? /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { inline: true }) : label || children })
566
576
  }
567
577
  );
568
578
  };
@@ -6150,7 +6160,8 @@ const ComboDropdown = ({
6150
6160
  mode = "both",
6151
6161
  isRequired = false,
6152
6162
  optionLabelKey = "label",
6153
- optionValueKey = "value"
6163
+ optionValueKey = "value",
6164
+ wrapperClass = ""
6154
6165
  }) => {
6155
6166
  const [inputValue, setInputValue] = useState("");
6156
6167
  const [filteredOptions, setFilteredOptions] = useState([]);
@@ -6272,7 +6283,10 @@ const ComboDropdown = ({
6272
6283
  ref: inputRef,
6273
6284
  type: isPassword ? "password" : "text",
6274
6285
  placeholder: getPlaceholder(),
6275
- className: `w-full border rounded-sm px-3 pr-8 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-green-200 ${error ? "border-red-500" : "border-green-500"} ${disabled ? "bg-gray-100 cursor-not-allowed" : ""}`,
6286
+ className: `w-full border rounded-sm px-3 pr-8 py-2 text-sm focus:outline-none focus:ring-1
6287
+ focus:ring-[#3B5AA1]
6288
+ ${disabled ? "border-gray-300 bg-gray-100 cursor-not-allowed" : error ? "border-red-500" : "border-[#3B5AA1]"}
6289
+ ${wrapperClass}`,
6276
6290
  name,
6277
6291
  value: inputValue,
6278
6292
  onChange: handleInputChange,
@@ -12585,7 +12599,7 @@ function requireLib() {
12585
12599
  }
12586
12600
  var E, T, I, A = Array.prototype, D = Function.prototype, P = Object.prototype, F = b["__core-js_shared__"], M = (E = /[^.]+$/.exec(F && F.keys && F.keys.IE_PROTO || "")) ? "Symbol(src)_1." + E : "", R = D.toString, L = P.hasOwnProperty, z = P.toString, B = RegExp("^" + R.call(L).replace(/[\\^$.*+?()[\]{}|]/g, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"), G = b.Symbol, $ = b.Uint8Array, V = P.propertyIsEnumerable, K = A.splice, U = (T = Object.keys, I = Object, function(e3) {
12587
12601
  return T(I(e3));
12588
- }), q = Ne(b, "DataView"), H = Ne(b, "Map"), W = Ne(b, "Promise"), J = Ne(b, "Set"), Z = Ne(b, "WeakMap"), Q = Ne(Object, "create"), Y = Pe(q), X = Pe(H), ee = Pe(W), te = Pe(J), re = Pe(Z), ne = G ? G.prototype : void 0, ae = ne ? ne.valueOf : void 0, oe = ne ? ne.toString : void 0;
12602
+ }), q = Ne(b, "DataView"), H = Ne(b, "Map"), W = Ne(b, "Promise"), J = Ne(b, "Set"), Z = Ne(b, "WeakMap"), Q = Ne(Object, "create"), Y = Pe(q), X2 = Pe(H), ee = Pe(W), te = Pe(J), re = Pe(Z), ne = G ? G.prototype : void 0, ae = ne ? ne.valueOf : void 0, oe = ne ? ne.toString : void 0;
12589
12603
  function ie(e3) {
12590
12604
  var t2 = -1, r4 = e3 ? e3.length : 0;
12591
12605
  for (this.clear(); ++t2 < r4; ) {
@@ -12923,7 +12937,7 @@ function requireLib() {
12923
12937
  if (n2) switch (n2) {
12924
12938
  case Y:
12925
12939
  return "[object DataView]";
12926
- case X:
12940
+ case X2:
12927
12941
  return a;
12928
12942
  case ee:
12929
12943
  return "[object Promise]";
@@ -13978,7 +13992,11 @@ const CustomInput = ({
13978
13992
  onValidationChange,
13979
13993
  // color,
13980
13994
  showTimer,
13981
- timer
13995
+ timer,
13996
+ minValue,
13997
+ maxValue,
13998
+ stepValue,
13999
+ wrapperClassName
13982
14000
  }) => {
13983
14001
  const [countryCode, setCountryCode] = useState("IN");
13984
14002
  const [nationalNumber, setNationalNumber] = useState("");
@@ -13991,7 +14009,6 @@ const CustomInput = ({
13991
14009
  validate(value);
13992
14010
  }
13993
14011
  }, [value]);
13994
- console.log(enable);
13995
14012
  const validate = (val) => {
13996
14013
  const raw = category === "amount" ? removeCommas(val) : val;
13997
14014
  if (!isRequired && !val) {
@@ -14214,7 +14231,6 @@ const CustomInput = ({
14214
14231
  const handleChange = (e) => {
14215
14232
  let val;
14216
14233
  if (category == "mobile") {
14217
- console.log(e);
14218
14234
  val = e;
14219
14235
  validate(val);
14220
14236
  } else {
@@ -14305,20 +14321,9 @@ const CustomInput = ({
14305
14321
  }
14306
14322
  const nationalNumber1 = parsed.nationalNumber || "";
14307
14323
  setNationalNumber(nationalNumber1);
14308
- console.log(nationalNumber);
14309
14324
  const { length, startsWith } = rules;
14310
14325
  const callingCodeLength = country.dialCode.length;
14311
14326
  const maxTotalLength = callingCodeLength + length;
14312
- console.log(
14313
- value2,
14314
- value2.length,
14315
- maxTotalLength,
14316
- length,
14317
- nationalNumber.length,
14318
- startsWith,
14319
- startsWith.test(nationalNumber),
14320
- "len"
14321
- );
14322
14327
  if (value2.length > maxTotalLength) {
14323
14328
  setError("Invalid phone number for selected country");
14324
14329
  setEnable(true);
@@ -14365,7 +14370,7 @@ const CustomInput = ({
14365
14370
  prefix && /* @__PURE__ */ jsxRuntimeExports.jsx(
14366
14371
  InputGroup$1.Text,
14367
14372
  {
14368
- style: { backgroundColor: "#fff", borderColor: "#12AB5B" },
14373
+ style: { backgroundColor: "#fff", borderColor: "#3B5AA1" },
14369
14374
  children: prefix
14370
14375
  }
14371
14376
  ),
@@ -14374,107 +14379,138 @@ const CustomInput = ({
14374
14379
  {
14375
14380
  placement: "top",
14376
14381
  overlay: isAmount && amountInWords && (currency === "₹" || currency === "$") ? /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip$2, { id: `${name}-tooltip`, children: amountInWords }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", {}),
14377
- children: category === "mobile" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center border border-[#12AB5B] rounded-md w-full", children: [
14378
- /* @__PURE__ */ jsxRuntimeExports.jsx(
14379
- PhoneInput,
14380
- {
14381
- value,
14382
- onChange: (value2, country) => handlePhoneChange(value2, country),
14383
- country: countryCode.toLowerCase(),
14384
- enableLongNumbers: true,
14385
- disableDropdown: false,
14386
- countryCodeEditable: false,
14387
- inputProps: { autoComplete: "off" },
14388
- containerStyle: { width: "100%" },
14389
- disabled,
14390
- inputStyle: {
14391
- width: "100%",
14392
- height: "40px",
14393
- fontSize: "14px",
14394
- paddingLeft: "48px",
14395
- // leave space for flag
14396
- border: "none",
14397
- backgroundColor: disabled ? "#f1f1f1" : "#fff",
14398
- // gray when disabled
14399
- color: disabled ? "#6c757d" : "#000",
14400
- // ✅ muted text when disabled
14401
- cursor: disabled ? "not-allowed" : "text"
14402
- // ✅ show disabled cursor
14403
- },
14404
- buttonStyle: {
14405
- borderRight: "1px solid #12AB5B",
14406
- backgroundColor: disabled ? "#f1f1f1" : "#fff",
14407
- // ✅ gray when disabled
14408
- borderRadius: "0.375rem 0 0 0.375rem",
14409
- cursor: disabled ? "not-allowed" : "pointer"
14410
- },
14411
- dropdownClass: "z-50 mt-1 bg-white border border-gray-300 rounded-md text-sm max-h-60 overflow-y-auto shadow-lg"
14412
- }
14413
- ),
14414
- button?.label && /* @__PURE__ */ jsxRuntimeExports.jsx(
14415
- "button",
14416
- {
14417
- type: "button",
14418
- onClick: button.onClick,
14419
- disabled: button.disabled || enable,
14420
- className: `px-4 py-2 text-white ${backgroundColor2 || "bg-[#3B5AA1]"} border-l border-[#12AB5B] rounded-r-md ${button.disabled || enable ? "opacity-50 cursor-not-allowed" : ""}`,
14421
- style: { height: height2 },
14422
- children: button.loader ? /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { inline: true }) : button.label
14423
- }
14424
- )
14425
- ] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center border border-[#12AB5B] overflow-hidden rounded-md", children: [
14426
- prefix && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "px-2 bg-white text-gray-700 border-r border-[#12AB5B]", children: prefix }),
14427
- /* @__PURE__ */ jsxRuntimeExports.jsx(
14428
- "input",
14429
- {
14430
- type: isPassword ? showPassword ? "text" : "password" : type,
14431
- name,
14432
- value,
14433
- onChange: handleChange,
14434
- disabled,
14435
- placeholder,
14436
- className: `flex-1 px-2 py-2 focus:outline-none ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-500" : ""}`,
14437
- style: {
14438
- height: height2,
14439
- backgroundColor: disabled ? "#f1f1f1" : void 0,
14440
- color: disabled ? "#6c757d" : void 0
14441
- }
14442
- }
14443
- ),
14444
- suffix && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "px-2 bg-white text-gray-700 border-l border-[#12AB5B]", children: suffix }),
14445
- !error && showTimer && /* @__PURE__ */ jsxRuntimeExports.jsxs(
14446
- "span",
14447
- {
14448
- className: `flex items-center gap-1 justify-center h-[40px] min-w-[60px] px-2 ml-1 rounded text-sm
14449
- ${validationStatus === "valid" ? "text-green-600 bg-gray-100" : validationStatus === "invalid" ? "text-red-600" : "text-gray-600 bg-gray-100"}`,
14450
- title: validationStatus === "valid" ? "Correct OTP" : validationStatus === "invalid" ? "Incorrect OTP" : "OTP Timer",
14451
- children: [
14452
- validationStatus === "valid" && /* @__PURE__ */ jsxRuntimeExports.jsx(FaCheck, { size: 18 }),
14453
- validationStatus === "invalid" && /* @__PURE__ */ jsxRuntimeExports.jsx(IoMdClose, { size: 18 }),
14454
- typeof timer === "number" && validationStatus !== "valid" && `${timer}s`
14455
- ]
14456
- }
14457
- ),
14458
- isPassword && /* @__PURE__ */ jsxRuntimeExports.jsx(
14459
- "button",
14460
- {
14461
- type: "button",
14462
- onClick: () => setShowPassword(!showPassword),
14463
- className: "px-2 bg-white text-gray-500 border-l border-[#12AB5B]",
14464
- children: showPassword ? /* @__PURE__ */ jsxRuntimeExports.jsx(FiEye, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(FiEyeOff, {})
14465
- }
14466
- ),
14467
- button?.label && /* @__PURE__ */ jsxRuntimeExports.jsx(
14468
- "button",
14469
- {
14470
- onClick: button?.onClick,
14471
- disabled: disabled || enable,
14472
- className: `px-2 py-2 text-white ${backgroundColor2 || "bg-[#3B5AA1]"} border-l border-[#12AB5B] rounded-r-md ${disabled || enable ? "opacity-50 cursor-not-allowed" : ""}`,
14473
- style: { height: height2 },
14474
- children: button.loader ? /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { inline: true }) : button.label
14475
- }
14476
- )
14477
- ] })
14382
+ children: category === "mobile" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
14383
+ "div",
14384
+ {
14385
+ className: `
14386
+ flex items-center w-full
14387
+ rounded-md
14388
+ transition-all duration-200
14389
+ border border-[1px]
14390
+ ${disabled ? "border-gray-300 bg-gray-100 cursor-not-allowed" : "border-[#3B5AA1] focus-within:ring-1 focus-within:ring-[#3B5AA1] focus-within:border-[#3B5AA1]"}
14391
+ ${wrapperClassName || ""}
14392
+ `,
14393
+ children: [
14394
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14395
+ PhoneInput,
14396
+ {
14397
+ value,
14398
+ onChange: (value2, country) => handlePhoneChange(value2, country),
14399
+ country: countryCode.toLowerCase(),
14400
+ enableLongNumbers: false,
14401
+ disableDropdown: false,
14402
+ countryCodeEditable: false,
14403
+ inputProps: { autoComplete: "off" },
14404
+ containerStyle: { width: "100%" },
14405
+ disabled,
14406
+ inputStyle: {
14407
+ width: "100%",
14408
+ height: "40px",
14409
+ fontSize: "14px",
14410
+ paddingLeft: "48px",
14411
+ // leave space for flag
14412
+ border: "none",
14413
+ backgroundColor: disabled ? "#f1f1f1" : "#fff",
14414
+ // gray when disabled
14415
+ color: disabled ? "#6c757d" : "#000",
14416
+ // muted text when disabled
14417
+ cursor: disabled ? "not-allowed" : "text"
14418
+ // ✅ show disabled cursor
14419
+ },
14420
+ buttonStyle: {
14421
+ borderRight: "1px solid #3B5AA1",
14422
+ backgroundColor: disabled ? "#f1f1f1" : "#fff",
14423
+ // ✅ gray when disabled
14424
+ borderRadius: "0.375rem 0 0 0.375rem",
14425
+ cursor: disabled ? "not-allowed" : "pointer"
14426
+ },
14427
+ dropdownClass: "z-50 mt-1 bg-white border border-gray-300 rounded-md text-sm max-h-60 overflow-y-auto shadow-lg"
14428
+ }
14429
+ ),
14430
+ button?.label && /* @__PURE__ */ jsxRuntimeExports.jsx(
14431
+ "button",
14432
+ {
14433
+ type: "button",
14434
+ onClick: button.onClick,
14435
+ disabled: button.disabled || enable,
14436
+ className: `px-4 py-2 text-white ${backgroundColor2 || "bg-[#3B5AA1]"} border-l border-[#3B5AA1] rounded-r-md ${button.disabled || enable ? "opacity-50 cursor-not-allowed" : ""}`,
14437
+ style: { height: height2 },
14438
+ children: button.loader ? /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { inline: true }) : button.label
14439
+ }
14440
+ )
14441
+ ]
14442
+ }
14443
+ ) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
14444
+ "div",
14445
+ {
14446
+ className: `
14447
+ flex items-center
14448
+ overflow-hidden
14449
+ rounded-md
14450
+ transition-all duration-200
14451
+
14452
+ ${disabled ? "border border-gray-300 bg-gray-100 cursor-not-allowed" : "border border-[#3B5AA1] focus-within:border-[#3B5AA1] focus-within:ring-1 focus-within:ring-[#3B5AA1]"}
14453
+
14454
+ ${wrapperClassName || ""}
14455
+ `,
14456
+ children: [
14457
+ prefix && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "px-2 bg-white text-gray-700 border-r border-[#3B5AA1]", children: prefix }),
14458
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
14459
+ "input",
14460
+ {
14461
+ type: isPassword ? showPassword ? "text" : "password" : type,
14462
+ name,
14463
+ value,
14464
+ onChange: handleChange,
14465
+ disabled,
14466
+ placeholder,
14467
+ className: `flex-1 px-2 py-2 focus:outline-none ${disabled ? "bg-gray-100 cursor-not-allowed text-gray-500" : ""}`,
14468
+ style: {
14469
+ height: height2,
14470
+ backgroundColor: disabled ? "#f1f1f1" : void 0,
14471
+ color: disabled ? "#6c757d" : void 0
14472
+ },
14473
+ min: minValue,
14474
+ max: maxValue,
14475
+ step: stepValue
14476
+ }
14477
+ ),
14478
+ suffix && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "px-2 bg-white text-gray-700 border-l border-[#3B5AA1]", children: suffix }),
14479
+ !error && showTimer && /* @__PURE__ */ jsxRuntimeExports.jsxs(
14480
+ "span",
14481
+ {
14482
+ className: `flex items-center gap-1 justify-center h-[40px] min-w-[60px] px-2 ml-1 rounded text-sm
14483
+ ${validationStatus === "valid" ? "text-[#3B5AA1] bg-gray-100" : validationStatus === "invalid" ? "text-red-600" : "text-gray-600 bg-gray-100"}`,
14484
+ title: validationStatus === "valid" ? "Correct OTP" : validationStatus === "invalid" ? "Incorrect OTP" : "OTP Timer",
14485
+ children: [
14486
+ validationStatus === "valid" && /* @__PURE__ */ jsxRuntimeExports.jsx(FaCheck, { size: 18 }),
14487
+ validationStatus === "invalid" && /* @__PURE__ */ jsxRuntimeExports.jsx(IoMdClose, { size: 18 }),
14488
+ typeof timer === "number" && validationStatus !== "valid" && `${timer}s`
14489
+ ]
14490
+ }
14491
+ ),
14492
+ isPassword && /* @__PURE__ */ jsxRuntimeExports.jsx(
14493
+ "button",
14494
+ {
14495
+ type: "button",
14496
+ onClick: () => setShowPassword(!showPassword),
14497
+ className: "px-2 bg-white text-gray-500 border-l border-[#3B5AA1]",
14498
+ children: showPassword ? /* @__PURE__ */ jsxRuntimeExports.jsx(FiEye, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(FiEyeOff, {})
14499
+ }
14500
+ ),
14501
+ button?.label && /* @__PURE__ */ jsxRuntimeExports.jsx(
14502
+ "button",
14503
+ {
14504
+ onClick: button?.onClick,
14505
+ disabled: disabled || enable,
14506
+ className: `px-2 py-2 text-white ${backgroundColor2 || "bg-[#3B5AA1]"} border-l border-[#3B5AA1] rounded-r-md ${disabled || enable ? "opacity-50 cursor-not-allowed" : ""}`,
14507
+ style: { height: height2 },
14508
+ children: button.loader ? /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { inline: true }) : button.label
14509
+ }
14510
+ )
14511
+ ]
14512
+ }
14513
+ )
14478
14514
  }
14479
14515
  )
14480
14516
  ] }),
@@ -15776,11 +15812,18 @@ function DynamicTabs({
15776
15812
  centered = false,
15777
15813
  scrollButtons = "auto",
15778
15814
  indicatorColor = "primary",
15779
- textColor = "primary"
15815
+ textColor = "primary",
15816
+ handleTabChange,
15817
+ tabIndex
15780
15818
  }) {
15781
- const [value, setValue] = useState(defaultValue);
15819
+ const [value, setValue] = useState(tabIndex || defaultValue);
15820
+ useEffect(() => {
15821
+ const setUpVal = tabs.length - 1 >= tabIndex ? tabIndex : tabs.length - 1;
15822
+ setValue(setUpVal);
15823
+ }, [tabIndex]);
15782
15824
  const handleChange = (event, newValue) => {
15783
15825
  setValue(newValue);
15826
+ handleTabChange(newValue);
15784
15827
  };
15785
15828
  const getTabsStyles = () => {
15786
15829
  const baseStyles = "w-full";
@@ -16403,13 +16446,20 @@ const createLucideIcon = (iconName, iconNode) => {
16403
16446
  Component.displayName = toPascalCase(iconName);
16404
16447
  return Component;
16405
16448
  };
16406
- const __iconNode$4 = [
16449
+ const __iconNode$6 = [
16450
+ ["path", { d: "M8 2v4", key: "1cmpym" }],
16451
+ ["path", { d: "M16 2v4", key: "4m81vk" }],
16452
+ ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
16453
+ ["path", { d: "M3 10h18", key: "8toen8" }]
16454
+ ];
16455
+ const Calendar = createLucideIcon("calendar", __iconNode$6);
16456
+ const __iconNode$5 = [
16407
16457
  ["path", { d: "M12 15V3", key: "m9g1x1" }],
16408
16458
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
16409
16459
  ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
16410
16460
  ];
16411
- const Download = createLucideIcon("download", __iconNode$4);
16412
- const __iconNode$3 = [
16461
+ const Download = createLucideIcon("download", __iconNode$5);
16462
+ const __iconNode$4 = [
16413
16463
  [
16414
16464
  "path",
16415
16465
  {
@@ -16418,28 +16468,33 @@ const __iconNode$3 = [
16418
16468
  }
16419
16469
  ]
16420
16470
  ];
16421
- const Funnel = createLucideIcon("funnel", __iconNode$3);
16422
- const __iconNode$2 = [
16471
+ const Funnel = createLucideIcon("funnel", __iconNode$4);
16472
+ const __iconNode$3 = [
16423
16473
  ["path", { d: "m8 11 2 2 4-4", key: "1sed1v" }],
16424
16474
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
16425
16475
  ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
16426
16476
  ];
16427
- const SearchCheck = createLucideIcon("search-check", __iconNode$2);
16428
- const __iconNode$1 = [
16477
+ const SearchCheck = createLucideIcon("search-check", __iconNode$3);
16478
+ const __iconNode$2 = [
16429
16479
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
16430
16480
  ["line", { x1: "3", x2: "21", y1: "9", y2: "9", key: "1vqk6q" }],
16431
16481
  ["line", { x1: "3", x2: "21", y1: "15", y2: "15", key: "o2sbyz" }],
16432
16482
  ["line", { x1: "9", x2: "9", y1: "9", y2: "21", key: "1ib60c" }],
16433
16483
  ["line", { x1: "15", x2: "15", y1: "9", y2: "21", key: "1n26ft" }]
16434
16484
  ];
16435
- const Sheet = createLucideIcon("sheet", __iconNode$1);
16436
- const __iconNode = [
16485
+ const Sheet = createLucideIcon("sheet", __iconNode$2);
16486
+ const __iconNode$1 = [
16437
16487
  ["path", { d: "M12 3v18", key: "108xh3" }],
16438
16488
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
16439
16489
  ["path", { d: "M3 9h18", key: "1pudct" }],
16440
16490
  ["path", { d: "M3 15h18", key: "5xshup" }]
16441
16491
  ];
16442
- const Table = createLucideIcon("table", __iconNode);
16492
+ const Table = createLucideIcon("table", __iconNode$1);
16493
+ const __iconNode = [
16494
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
16495
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
16496
+ ];
16497
+ const X = createLucideIcon("x", __iconNode);
16443
16498
  var weekOfYear$1 = { exports: {} };
16444
16499
  var weekOfYear = weekOfYear$1.exports;
16445
16500
  var hasRequiredWeekOfYear;
@@ -17782,9 +17837,41 @@ const buildColumn = (col, fyOptions, detectedColumnTypes, aggregates) => {
17782
17837
  };
17783
17838
  }
17784
17839
  if (col.TotTyp) {
17785
- column.Footer = () => {
17786
- const value = aggregates[col.ColFields];
17787
- if (value === void 0 || value === null) return "";
17840
+ column.Footer = ({ table }) => {
17841
+ const rows = table.getFilteredRowModel().rows;
17842
+ if (!rows.length) return "";
17843
+ let count = 0;
17844
+ let sum = 0;
17845
+ let min2 = Infinity;
17846
+ let max2 = -Infinity;
17847
+ for (const row of rows) {
17848
+ const val = Number(row.original[col.ColFields]);
17849
+ if (isNaN(val)) continue;
17850
+ count++;
17851
+ sum += val;
17852
+ min2 = Math.min(min2, val);
17853
+ max2 = Math.max(max2, val);
17854
+ }
17855
+ let value;
17856
+ switch (col.TotTyp) {
17857
+ case "SUM":
17858
+ value = sum;
17859
+ break;
17860
+ case "AVG":
17861
+ value = count ? sum / count : 0;
17862
+ break;
17863
+ case "MIN":
17864
+ value = count ? min2 : "";
17865
+ break;
17866
+ case "MAX":
17867
+ value = count ? max2 : "";
17868
+ break;
17869
+ case "COUNT":
17870
+ value = count;
17871
+ break;
17872
+ default:
17873
+ return "";
17874
+ }
17788
17875
  if (isNumericColumn && col.IsPercentage) {
17789
17876
  return formatPercentage({
17790
17877
  value,
@@ -17825,6 +17912,7 @@ const defaultControlOpt = {
17825
17912
  colPinning: true,
17826
17913
  pagination: true,
17827
17914
  rowSelection: false,
17915
+ enableSelectAllRows: true,
17828
17916
  rowPinning: false,
17829
17917
  grouping: false,
17830
17918
  sorting: true,
@@ -17841,7 +17929,8 @@ function SmartGridTable({
17841
17929
  topToolbar = defaultToolBarOpt,
17842
17930
  controls = defaultControlOpt,
17843
17931
  onRowSelectionChange,
17844
- isLoading = false
17932
+ isLoading = false,
17933
+ resetRowSelection
17845
17934
  }) {
17846
17935
  const safeColumns = useMemo(
17847
17936
  () => sanitizeColumns(columns),
@@ -17853,6 +17942,9 @@ function SmartGridTable({
17853
17942
  );
17854
17943
  const [rowSelection, setRowSelection] = useState({});
17855
17944
  const isMobile = useMediaQuery("(max-width:600px)");
17945
+ useEffect(() => {
17946
+ setRowSelection({});
17947
+ }, [resetRowSelection]);
17856
17948
  const mergedTheme = { ...DEFAULT_THEME, ...theme };
17857
17949
  topToolbar = { ...defaultToolBarOpt, ...topToolbar };
17858
17950
  controls = { ...defaultControlOpt, ...controls };
@@ -17930,7 +18022,7 @@ function SmartGridTable({
17930
18022
  const finalColumns = useMemo(() => {
17931
18023
  if (safeColumns.length === 0) return [];
17932
18024
  return safeColumns.sort((a, b) => a.ColOrder - b.ColOrder).map(
17933
- (col) => buildColumn(col, fyOptions, detectedColumnTypes, aggregates)
18025
+ (col) => buildColumn(col, fyOptions, detectedColumnTypes)
17934
18026
  );
17935
18027
  }, [safeColumns, fyOptions, detectedColumnTypes, aggregates]);
17936
18028
  const columnPinning = useMemo(() => {
@@ -17979,6 +18071,7 @@ function SmartGridTable({
17979
18071
  enablePagination: !isGridDisabled && controls.pagination,
17980
18072
  enableColumnActions: !isGridDisabled && controls.columnActions,
17981
18073
  enableRowSelection: !isGridDisabled && controls.rowSelection,
18074
+ enableSelectAll: !isGridDisabled && controls.rowSelection && controls?.enableSelectAllRows,
17982
18075
  enableGrouping: !isGridDisabled && controls.grouping,
17983
18076
  enableSorting: !isGridDisabled && controls.sorting,
17984
18077
  enableEditing: !isGridDisabled && controls.editing,
@@ -18423,48 +18516,561 @@ const ExportButton = ({
18423
18516
  )
18424
18517
  ] });
18425
18518
  };
18426
- const SmartTable = ({
18427
- controls = {
18428
- columnActions: true,
18429
- dragging: false,
18430
- colPinning: true,
18431
- pagination: true,
18432
- rowSelection: false,
18433
- rowPinning: false,
18434
- grouping: false,
18435
- sorting: true,
18436
- editing: false,
18437
- resizing: true
18438
- },
18439
- topToolbar = {
18440
- enabled: true,
18441
- globalSearch: true,
18442
- columnFilters: true,
18443
- densityToggle: true,
18444
- fullscreenToggle: false,
18445
- exportBtn: true,
18446
- showHideColumnsBtn: true
18447
- },
18448
- theme = {
18449
- headerBg: "#3f5fa3",
18450
- headerText: "#ffffff",
18451
- bodyBg: "#ffffff",
18452
- border: "#cfd6e4"
18519
+ const SmartTable = (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SmartGridTable, { ...props }) });
18520
+ const FinancialDateRangePicker = ({
18521
+ value = null,
18522
+ onChange = () => {
18453
18523
  },
18454
- height: height2 = "100%",
18455
- width: width2 = "100%",
18456
- columns = [],
18457
- data = [],
18458
- paginationStyle = "default",
18459
- isLoading = false,
18460
- onRowSelectionChange = () => {
18461
- }
18524
+ placeholder = "Select date range",
18525
+ className = "",
18526
+ disabled = false,
18527
+ error = "",
18528
+ label = "",
18529
+ required = false,
18530
+ defaultMode = "yearly",
18531
+ showFinancialYear = true,
18532
+ showYearly = true,
18533
+ showMonthly = true,
18534
+ showCustom = true,
18535
+ isSticky = false,
18536
+ stickyTop = 0,
18537
+ stickyRight = 0
18462
18538
  }) => {
18463
- const props = { controls, topToolbar, height: height2, width: width2, isLoading, columns, data, onRowSelectionChange, paginationStyle, theme };
18464
- return /* @__PURE__ */ jsxRuntimeExports.jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SmartGridTable, { ...props }) });
18539
+ const [isOpen, setIsOpen] = useState(false);
18540
+ const [selectionMode, setSelectionMode] = useState(defaultMode);
18541
+ const [financialYear, setFinancialYear] = useState("");
18542
+ const [yearlySubMode, setYearlySubMode] = useState("half-yearly");
18543
+ const [selectedHalfYear, setSelectedHalfYear] = useState(null);
18544
+ const [selectedQuarter, setSelectedQuarter] = useState(null);
18545
+ const [selectedMonthStart, setSelectedMonthStart] = useState(null);
18546
+ const [selectedMonthEnd, setSelectedMonthEnd] = useState(null);
18547
+ const [monthRangeSelecting, setMonthRangeSelecting] = useState(false);
18548
+ const [customStart, setCustomStart] = useState("");
18549
+ const [customEnd, setCustomEnd] = useState("");
18550
+ const [tempDateRange, setTempDateRange] = useState({ start: "", end: "" });
18551
+ const [dropdownPosition, setDropdownPosition] = useState({
18552
+ top: true,
18553
+ left: 0,
18554
+ right: "auto",
18555
+ arrowLeft: 24
18556
+ });
18557
+ const containerRef = useRef(null);
18558
+ const dropdownRef = useRef(null);
18559
+ const inputRef = useRef(null);
18560
+ const [parentWidth, setParentWidth] = useState("100%");
18561
+ useEffect(() => {
18562
+ if (containerRef.current) {
18563
+ const parent = containerRef.current.parentElement;
18564
+ const updateWidth = () => {
18565
+ setParentWidth(parent.offsetWidth);
18566
+ };
18567
+ updateWidth();
18568
+ window.addEventListener("resize", updateWidth);
18569
+ return () => window.removeEventListener("resize", updateWidth);
18570
+ }
18571
+ }, []);
18572
+ const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
18573
+ const financialYears = Array.from({ length: 5 }, (_, i) => {
18574
+ const year = currentYear - 5 + i + 1;
18575
+ return `${year}-${String(year + 1).slice(2)}`;
18576
+ });
18577
+ const halfYears = [
18578
+ { id: "H1", label: "H1 (Apr-Sep)", startMonth: 3, endMonth: 8 },
18579
+ { id: "H2", label: "H2 (Oct-Mar)", startMonth: 9, endMonth: 2 }
18580
+ ];
18581
+ const quarters = [
18582
+ { id: "Q1", label: "Q1 (Apr-Jun)", startMonth: 3, endMonth: 5 },
18583
+ { id: "Q2", label: "Q2 (Jul-Sep)", startMonth: 6, endMonth: 8 },
18584
+ { id: "Q3", label: "Q3 (Oct-Dec)", startMonth: 9, endMonth: 11 },
18585
+ { id: "Q4", label: "Q4 (Jan-Mar)", startMonth: 0, endMonth: 2 }
18586
+ ];
18587
+ const months = [
18588
+ { id: 4, label: "April", short: "Apr", index: 3 },
18589
+ { id: 5, label: "May", short: "May", index: 4 },
18590
+ { id: 6, label: "June", short: "Jun", index: 5 },
18591
+ { id: 7, label: "July", short: "Jul", index: 6 },
18592
+ { id: 8, label: "August", short: "Aug", index: 7 },
18593
+ { id: 9, label: "September", short: "Sep", index: 8 },
18594
+ { id: 10, label: "October", short: "Oct", index: 9 },
18595
+ { id: 11, label: "November", short: "Nov", index: 10 },
18596
+ { id: 12, label: "December", short: "Dec", index: 11 },
18597
+ { id: 1, label: "January", short: "Jan", index: 0 },
18598
+ { id: 2, label: "February", short: "Feb", index: 1 },
18599
+ { id: 3, label: "March", short: "Mar", index: 2 }
18600
+ ];
18601
+ useEffect(() => {
18602
+ if (isOpen && value) {
18603
+ setTempDateRange(value);
18604
+ setSelectionMode(value?.mode);
18605
+ setFinancialYear(value?.financialYear);
18606
+ if (value?.mode === "monthly") {
18607
+ setSelectedMonthStart(value?.monthStart);
18608
+ setSelectedMonthEnd(value?.monthEnd);
18609
+ }
18610
+ if (value?.mode === "yearly") {
18611
+ setYearlySubMode(value?.yearlySubMode);
18612
+ setSelectedHalfYear(value?.halfYear);
18613
+ setSelectedQuarter(value?.quarter);
18614
+ }
18615
+ if (value?.mode === "custom") {
18616
+ setCustomStart(value?.start);
18617
+ setCustomEnd(value?.end);
18618
+ }
18619
+ }
18620
+ }, [value, isOpen]);
18621
+ useEffect(() => {
18622
+ if (isOpen && containerRef.current && dropdownRef.current && inputRef.current) {
18623
+ const calculatePosition = () => {
18624
+ const container = containerRef.current.getBoundingClientRect();
18625
+ const input = inputRef.current.getBoundingClientRect();
18626
+ const dropdown = dropdownRef.current;
18627
+ const dropdownWidth = 400;
18628
+ const dropdownHeight = dropdown.scrollHeight;
18629
+ const viewportHeight = window.innerHeight;
18630
+ const viewportWidth = window.innerWidth;
18631
+ const spaceBelow = viewportHeight - container.bottom;
18632
+ const spaceAbove = container.top;
18633
+ const showBelow = spaceBelow >= dropdownHeight + 10 || spaceBelow > spaceAbove;
18634
+ let leftPos = 0;
18635
+ let rightPos = "auto";
18636
+ let arrowLeftPos = 24;
18637
+ const containerLeft = container.left;
18638
+ const containerWidth = container.width;
18639
+ const containerRight = containerLeft + containerWidth;
18640
+ const fitsOnRight = containerLeft + dropdownWidth <= viewportWidth - 16;
18641
+ const fitsOnLeft = containerRight - dropdownWidth >= 16;
18642
+ if (fitsOnRight) {
18643
+ leftPos = 0;
18644
+ rightPos = "auto";
18645
+ arrowLeftPos = 24;
18646
+ } else if (fitsOnLeft) {
18647
+ leftPos = "auto";
18648
+ rightPos = 0;
18649
+ arrowLeftPos = dropdownWidth - 40;
18650
+ } else {
18651
+ const maxLeft = viewportWidth - dropdownWidth - 16;
18652
+ const desiredLeft = Math.max(16 - containerLeft, Math.min(0, maxLeft - containerLeft));
18653
+ leftPos = desiredLeft;
18654
+ rightPos = "auto";
18655
+ const inputCenter = input.left + input.width / 2 - container.left;
18656
+ arrowLeftPos = Math.max(16, Math.min(dropdownWidth - 32, inputCenter - desiredLeft - 8));
18657
+ }
18658
+ setDropdownPosition({
18659
+ top: showBelow,
18660
+ left: leftPos,
18661
+ right: rightPos,
18662
+ arrowLeft: arrowLeftPos
18663
+ });
18664
+ };
18665
+ setTimeout(calculatePosition, 10);
18666
+ window.addEventListener("resize", calculatePosition);
18667
+ window.addEventListener("scroll", calculatePosition, true);
18668
+ return () => {
18669
+ window.removeEventListener("resize", calculatePosition);
18670
+ window.removeEventListener("scroll", calculatePosition, true);
18671
+ };
18672
+ }
18673
+ }, [isOpen]);
18674
+ useEffect(() => {
18675
+ const handleClickOutside = (e) => {
18676
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
18677
+ setIsOpen(false);
18678
+ }
18679
+ };
18680
+ if (isOpen) {
18681
+ document.addEventListener("mousedown", handleClickOutside);
18682
+ }
18683
+ return () => document.removeEventListener("mousedown", handleClickOutside);
18684
+ }, [isOpen]);
18685
+ const getHalfYearDates = (fy, halfYear) => {
18686
+ const [startYear] = fy.split("-");
18687
+ const year = parseInt(startYear);
18688
+ const hy = halfYears.find((h) => h.id === halfYear);
18689
+ const startDate = new Date(
18690
+ hy.startMonth >= 3 ? year : year + 1,
18691
+ hy.startMonth,
18692
+ 1
18693
+ );
18694
+ const endDate = new Date(
18695
+ hy.endMonth >= 3 ? year : year + 1,
18696
+ hy.endMonth + 1,
18697
+ 0
18698
+ );
18699
+ return {
18700
+ start: startDate.toLocaleDateString("en-CA"),
18701
+ end: endDate.toLocaleDateString("en-CA")
18702
+ };
18703
+ };
18704
+ const getQuarterDates = (fy, quarter) => {
18705
+ const [startYear] = fy.split("-");
18706
+ const year = parseInt(startYear);
18707
+ const q = quarters.find((q2) => q2.id === quarter);
18708
+ const startDate = new Date(
18709
+ q.startMonth >= 3 ? year : year + 1,
18710
+ q.startMonth,
18711
+ 1
18712
+ );
18713
+ const endDate = new Date(
18714
+ q.endMonth >= 3 ? year : year + 1,
18715
+ q.endMonth + 1,
18716
+ 0
18717
+ );
18718
+ return {
18719
+ start: startDate.toLocaleDateString("en-CA"),
18720
+ end: endDate.toLocaleDateString("en-CA")
18721
+ };
18722
+ };
18723
+ const getMonthRangeDates = (fy, startMonthId, endMonthId) => {
18724
+ const [startYear] = fy.split("-");
18725
+ const year = parseInt(startYear);
18726
+ const startMonth = months.find((m) => m.id === startMonthId);
18727
+ const endMonth = months.find((m) => m.id === endMonthId);
18728
+ const startDate = new Date(
18729
+ startMonth.index >= 3 ? year : year + 1,
18730
+ startMonth.index,
18731
+ 1
18732
+ );
18733
+ const endDate = new Date(
18734
+ endMonth.index >= 3 ? year : year + 1,
18735
+ endMonth.index + 1,
18736
+ 0
18737
+ );
18738
+ return {
18739
+ start: startDate.toLocaleDateString("en-CA"),
18740
+ end: endDate.toLocaleDateString("en-CA")
18741
+ };
18742
+ };
18743
+ useEffect(() => {
18744
+ if (selectionMode === "yearly") {
18745
+ if (selectedHalfYear) {
18746
+ const dates = getHalfYearDates(financialYear, selectedHalfYear);
18747
+ setTempDateRange(dates);
18748
+ } else if (selectedQuarter) {
18749
+ const dates = getQuarterDates(financialYear, selectedQuarter);
18750
+ setTempDateRange(dates);
18751
+ }
18752
+ } else if (selectionMode === "monthly" && selectedMonthStart && selectedMonthEnd) {
18753
+ const dates = getMonthRangeDates(financialYear, selectedMonthStart, selectedMonthEnd);
18754
+ setTempDateRange(dates);
18755
+ } else if (selectionMode === "custom" && customStart && customEnd) {
18756
+ setTempDateRange({ start: customStart, end: customEnd });
18757
+ }
18758
+ }, [selectionMode, yearlySubMode, financialYear, selectedHalfYear, selectedQuarter, selectedMonthStart, selectedMonthEnd, customStart, customEnd]);
18759
+ const handleHalfYearSelect = (halfYearId) => {
18760
+ setSelectedHalfYear(halfYearId);
18761
+ setSelectedQuarter(null);
18762
+ };
18763
+ const handleQuarterSelect = (quarterId) => {
18764
+ setSelectedQuarter(quarterId);
18765
+ setSelectedHalfYear(null);
18766
+ };
18767
+ const handleMonthClick = (monthId) => {
18768
+ if (!monthRangeSelecting) {
18769
+ setSelectedMonthStart(monthId);
18770
+ setSelectedMonthEnd(null);
18771
+ setMonthRangeSelecting(true);
18772
+ } else {
18773
+ const startId = selectedMonthStart;
18774
+ const endId = monthId;
18775
+ const startIndex = months.findIndex((m) => m.id === startId);
18776
+ const endIndex = months.findIndex((m) => m.id === endId);
18777
+ if (startIndex <= endIndex) {
18778
+ setSelectedMonthStart(startId);
18779
+ setSelectedMonthEnd(endId);
18780
+ } else {
18781
+ setSelectedMonthStart(endId);
18782
+ setSelectedMonthEnd(startId);
18783
+ }
18784
+ setMonthRangeSelecting(false);
18785
+ }
18786
+ };
18787
+ const isMonthInRange = (monthId) => {
18788
+ if (!selectedMonthStart) return false;
18789
+ if (!selectedMonthEnd) return monthId === selectedMonthStart;
18790
+ const startIndex = months.findIndex((m) => m.id === selectedMonthStart);
18791
+ const endIndex = months.findIndex((m) => m.id === selectedMonthEnd);
18792
+ const currentIndex = months.findIndex((m) => m.id === monthId);
18793
+ const minIndex = Math.min(startIndex, endIndex);
18794
+ const maxIndex = Math.max(startIndex, endIndex);
18795
+ return currentIndex >= minIndex && currentIndex <= maxIndex;
18796
+ };
18797
+ const isMonthRangeEdge = (monthId) => {
18798
+ return monthId === selectedMonthStart || monthId === selectedMonthEnd;
18799
+ };
18800
+ const resetAllSelections = () => {
18801
+ setSelectedHalfYear(null);
18802
+ setSelectedQuarter(null);
18803
+ setSelectedMonthStart(null);
18804
+ setSelectedMonthEnd(null);
18805
+ setMonthRangeSelecting(false);
18806
+ setCustomStart("");
18807
+ setCustomEnd("");
18808
+ setTempDateRange({ start: "", end: "" });
18809
+ };
18810
+ const handleCancel = () => {
18811
+ resetAllSelections();
18812
+ setIsOpen(false);
18813
+ };
18814
+ const handleApply = () => {
18815
+ if (tempDateRange.start && tempDateRange.end) {
18816
+ onChange({
18817
+ start: tempDateRange.start,
18818
+ end: tempDateRange.end,
18819
+ financialYear,
18820
+ mode: selectionMode,
18821
+ yearlySubMode: selectionMode === "yearly" ? yearlySubMode : null,
18822
+ halfYear: selectedHalfYear,
18823
+ quarter: selectedQuarter,
18824
+ monthStart: selectedMonthStart,
18825
+ monthEnd: selectedMonthEnd
18826
+ });
18827
+ setIsOpen(false);
18828
+ }
18829
+ };
18830
+ const handleClear = () => {
18831
+ resetAllSelections();
18832
+ onChange(null);
18833
+ setFinancialYear((/* @__PURE__ */ new Date()).getFullYear() + "-" + String((/* @__PURE__ */ new Date()).getFullYear() + 1).slice(2));
18834
+ };
18835
+ const formatDate2 = (dateStr) => {
18836
+ if (!dateStr) return "";
18837
+ const date = new Date(dateStr);
18838
+ return date.toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
18839
+ };
18840
+ const getDisplayValue = () => {
18841
+ if (!value) return "";
18842
+ return `${formatDate2(value.start)} - ${formatDate2(value.end)}`;
18843
+ };
18844
+ const availableModes = [];
18845
+ if (showYearly) availableModes.push("yearly");
18846
+ if (showMonthly) availableModes.push("monthly");
18847
+ if (showCustom) availableModes.push("custom");
18848
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
18849
+ "div",
18850
+ {
18851
+ ref: containerRef,
18852
+ className: `${isSticky ? "fixed z-40 bg-white" : "relative"} ${className}`,
18853
+ style: isSticky ? {
18854
+ top: stickyTop,
18855
+ right: stickyRight || "auto",
18856
+ width: parentWidth
18857
+ // dynamic width applied here
18858
+ } : {},
18859
+ children: [
18860
+ label && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium text-gray-700 mb-2", children: [
18861
+ label,
18862
+ required && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500 ml-1", children: "*" })
18863
+ ] }),
18864
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
18865
+ "div",
18866
+ {
18867
+ ref: inputRef,
18868
+ onClick: () => !disabled && setIsOpen(!isOpen),
18869
+ className: `
18870
+ flex items-center justify-between px-3 sm:px-4 py-2 sm:py-3 border-2 rounded-lg cursor-pointer transition
18871
+ ${disabled ? "bg-gray-100 cursor-not-allowed" : "bg-white hover:border-[#3B5AA1]/70"}
18872
+ ${error ? "border-red-500" : "border-gray-300"}
18873
+ ${isOpen ? "border-[#3B5AA1]/70 ring-2 ring-[#3B5AA1]/70" : ""}
18874
+ `,
18875
+ children: [
18876
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
18877
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Calendar, { className: `w-4 h-4 sm:w-5 sm:h-5 flex-shrink-0 ${disabled ? "text-gray-400" : "text-[#3B5AA1]"}` }),
18878
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-xs sm:text-sm truncate ${value ? "text-gray-900" : "text-gray-400"}`, children: getDisplayValue() || placeholder })
18879
+ ] }),
18880
+ value && !disabled && /* @__PURE__ */ jsxRuntimeExports.jsx(
18881
+ "button",
18882
+ {
18883
+ onClick: (e) => {
18884
+ e.stopPropagation();
18885
+ handleClear();
18886
+ },
18887
+ className: "p-1 hover:bg-gray-100 rounded flex-shrink-0 ml-2",
18888
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "w-3 h-3 sm:w-4 sm:h-4 text-gray-500" })
18889
+ }
18890
+ )
18891
+ ]
18892
+ }
18893
+ ),
18894
+ error && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-xs text-red-500", children: error }),
18895
+ isOpen && /* @__PURE__ */ jsxRuntimeExports.jsxs(
18896
+ "div",
18897
+ {
18898
+ ref: dropdownRef,
18899
+ style: {
18900
+ left: dropdownPosition.left !== "auto" ? `${dropdownPosition.left}px` : "auto",
18901
+ right: dropdownPosition.right !== "auto" ? `${dropdownPosition.right}px` : "auto"
18902
+ },
18903
+ className: `
18904
+ absolute z-50 w-full sm:w-[400px] bg-white rounded-xl shadow-2xl border-2 border-gray-200
18905
+ ${dropdownPosition.top ? "mt-2" : "mb-2 bottom-full"}
18906
+ `,
18907
+ children: [
18908
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
18909
+ "div",
18910
+ {
18911
+ style: { left: `${dropdownPosition.arrowLeft}px` },
18912
+ className: `
18913
+ absolute w-4 h-4 bg-white border-gray-200 transform rotate-45
18914
+ ${dropdownPosition.top ? "-top-2 border-t-2 border-l-2" : "-bottom-2 border-b-2 border-r-2"}
18915
+ `
18916
+ }
18917
+ ),
18918
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative bg-white rounded-xl p-4 sm:p-5 max-h-[70vh] overflow-y-auto", children: [
18919
+ showFinancialYear && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [
18920
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "block text-xs sm:text-sm font-semibold text-gray-700 mb-2", children: "Financial Year" }),
18921
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
18922
+ "select",
18923
+ {
18924
+ value: financialYear,
18925
+ onChange: (e) => {
18926
+ setFinancialYear(e.target.value);
18927
+ resetAllSelections();
18928
+ },
18929
+ className: "w-full px-3 py-2 text-sm border-2 border-gray-300 rounded-lg focus:border-[#3B5AA1]/70 focus:ring-2 focus:ring-[#3B5AA1]/70 transition",
18930
+ children: financialYears.map((fy) => /* @__PURE__ */ jsxRuntimeExports.jsxs("option", { value: fy, children: [
18931
+ "FY ",
18932
+ fy
18933
+ ] }, fy))
18934
+ }
18935
+ )
18936
+ ] }),
18937
+ availableModes.length > 1 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex gap-2 mb-4 bg-gray-100 p-1 rounded-lg", children: availableModes.map((mode) => /* @__PURE__ */ jsxRuntimeExports.jsx(
18938
+ "button",
18939
+ {
18940
+ onClick: () => {
18941
+ setSelectionMode(mode);
18942
+ resetAllSelections();
18943
+ },
18944
+ className: `flex-1 px-3 py-2 font-medium capitalize rounded-md transition text-sm ${selectionMode === mode ? "bg-[#3B5AA1] text-white shadow-md" : "bg-transparent text-gray-600 hover:bg-gray-200"}`,
18945
+ children: mode
18946
+ },
18947
+ mode
18948
+ )) }),
18949
+ selectionMode === "yearly" && showYearly && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [
18950
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
18951
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-700 mb-3", children: "Select Half Year" }),
18952
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 gap-2", children: halfYears.map((halfYear) => /* @__PURE__ */ jsxRuntimeExports.jsx(
18953
+ "button",
18954
+ {
18955
+ onClick: () => handleHalfYearSelect(halfYear.id),
18956
+ className: `p-3 rounded-lg border-2 font-medium text-sm transition ${selectedHalfYear === halfYear.id ? "bg-[#3B5AA1] text-white border-[#3B5AA1]/70 shadow-md" : "bg-white text-gray-700 border-gray-300 hover:border-[#3B5AA1]/70 hover:bg-[#3B5AA1]/10"}`,
18957
+ children: halfYear.label
18958
+ },
18959
+ halfYear.id
18960
+ )) })
18961
+ ] }),
18962
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3", children: [
18963
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-700 mb-3", children: "Select Quarter" }),
18964
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-2 gap-2", children: quarters.map((quarter) => /* @__PURE__ */ jsxRuntimeExports.jsx(
18965
+ "button",
18966
+ {
18967
+ onClick: () => handleQuarterSelect(quarter.id),
18968
+ className: `p-3 rounded-lg border-2 font-medium text-sm transition ${selectedQuarter === quarter.id ? "bg-[#3B5AA1] text-white border-[#3B5AA1]/70 shadow-md" : "bg-white text-gray-700 border-gray-300 hover:border-[#3B5AA1]/70 hover:bg-[#3B5AA1]/10"}`,
18969
+ children: quarter.label
18970
+ },
18971
+ quarter.id
18972
+ )) })
18973
+ ] })
18974
+ ] }),
18975
+ selectionMode === "monthly" && showMonthly && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [
18976
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
18977
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-700", children: "Select Month Range" }),
18978
+ monthRangeSelecting && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-[#3B5AA1] font-medium", children: "Select end →" })
18979
+ ] }),
18980
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-3 gap-2", children: months.map((month) => {
18981
+ const inRange = isMonthInRange(month.id);
18982
+ const isEdge = isMonthRangeEdge(month.id);
18983
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
18984
+ "button",
18985
+ {
18986
+ onClick: () => handleMonthClick(month.id),
18987
+ className: `p-2 rounded-lg border-2 font-medium text-xs transition ${inRange ? isEdge ? "bg-[#3B5AA1] text-white border-[#3B5AA1]/70 shadow-md" : "bg-[#3B5AA1]/10 text-[#3B5AA1] border-[#3B5AA1]/70" : "bg-white text-gray-700 border-gray-300 hover:border-[#3B5AA1]/70 hover:bg-[#3B5AA1]/10"}`,
18988
+ children: month.short
18989
+ },
18990
+ month.id
18991
+ );
18992
+ }) }),
18993
+ selectedMonthStart && selectedMonthEnd && /* @__PURE__ */ jsxRuntimeExports.jsx(
18994
+ "button",
18995
+ {
18996
+ onClick: () => {
18997
+ setSelectedMonthStart(null);
18998
+ setSelectedMonthEnd(null);
18999
+ setMonthRangeSelecting(false);
19000
+ },
19001
+ className: "mt-2 text-xs text-[#3B5AA1] hover:underline font-medium",
19002
+ children: "Clear Selection"
19003
+ }
19004
+ )
19005
+ ] }),
19006
+ selectionMode === "custom" && showCustom && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [
19007
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-semibold text-gray-700 mb-3", children: "Custom Date Range" }),
19008
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
19009
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
19010
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "block text-xs font-medium text-gray-600 mb-1", children: "Start Date" }),
19011
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
19012
+ "input",
19013
+ {
19014
+ type: "date",
19015
+ value: customStart,
19016
+ onChange: (e) => setCustomStart(e.target.value),
19017
+ className: "w-full px-2.5 py-2 border-2 border-gray-300 rounded-lg text-xs focus:border-[#3B5AA1]/70 focus:ring-2 focus:ring-[#3B5AA1]/70 transition"
19018
+ }
19019
+ )
19020
+ ] }),
19021
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
19022
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "block text-xs font-medium text-gray-600 mb-1", children: "End Date" }),
19023
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
19024
+ "input",
19025
+ {
19026
+ type: "date",
19027
+ value: customEnd,
19028
+ onChange: (e) => setCustomEnd(e.target.value),
19029
+ min: customStart,
19030
+ className: "w-full px-2.5 py-2 border-2 border-gray-300 rounded-lg text-xs focus:border-[#3B5AA1]/70 focus:ring-2 focus:ring-[#3B5AA1]/70 transition"
19031
+ }
19032
+ )
19033
+ ] })
19034
+ ] })
19035
+ ] }),
19036
+ tempDateRange.start && tempDateRange.end && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "bg-[#3B5AA1]/10 rounded-lg p-3 mb-4 border border-[#3B5AA1]/70", children: [
19037
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs font-medium text-gray-600 mb-1", children: "Selected Range" }),
19038
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs font-semibold text-[#3B5AA1] break-words", children: [
19039
+ formatDate2(tempDateRange.start),
19040
+ " - ",
19041
+ formatDate2(tempDateRange.end)
19042
+ ] })
19043
+ ] }),
19044
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
19045
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
19046
+ "button",
19047
+ {
19048
+ onClick: handleCancel,
19049
+ className: "flex-1 px-4 py-2 border-2 border-gray-300 rounded-lg font-medium text-gray-700 hover:bg-gray-50 transition text-sm",
19050
+ children: "Cancel"
19051
+ }
19052
+ ),
19053
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
19054
+ "button",
19055
+ {
19056
+ onClick: handleApply,
19057
+ disabled: !tempDateRange.start || !tempDateRange.end,
19058
+ className: `flex-1 px-4 py-2 rounded-lg font-medium transition text-sm ${tempDateRange.start && tempDateRange.end ? "bg-[#3B5AA1] text-white hover:bg-[#2d4680] shadow-md" : "bg-gray-200 text-gray-400 cursor-not-allowed"}`,
19059
+ children: "Apply"
19060
+ }
19061
+ )
19062
+ ] })
19063
+ ] })
19064
+ ]
19065
+ }
19066
+ )
19067
+ ]
19068
+ }
19069
+ );
18465
19070
  };
18466
19071
  export {
18467
19072
  ComboDropdown as MytekComboDropdown,
19073
+ FinancialDateRangePicker as MytekFinancialDateRangePicker,
18468
19074
  CustomInput as MytekInputField,
18469
19075
  Loader as MytekLoader,
18470
19076
  Mt_MessageBox as MytekMessageBox,