cr-ui-lib 1.1.33 → 1.1.35

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/index.d.mts CHANGED
@@ -115,10 +115,11 @@ interface MultiBarGraphProps {
115
115
  datasets: DataSet[];
116
116
  xAxisLabels: string[];
117
117
  className?: string;
118
- /** Determines the default position of the tooltip. Defaults to 'top'. */
119
118
  tooltipPosition?: "top" | "bottom";
119
+ /** The maximum value for the Y-axis. Defaults to undefined, allowing Chart.js to auto-calculate. */
120
+ yAxisMax?: number;
120
121
  }
121
- declare const MultiBarGraph: ({ datasets, xAxisLabels, className, tooltipPosition, }: MultiBarGraphProps) => JSX.Element;
122
+ declare const MultiBarGraph: ({ datasets, xAxisLabels, className, tooltipPosition, yAxisMax, }: MultiBarGraphProps) => JSX.Element;
122
123
 
123
124
  interface CommonInputProps extends React$1.HTMLAttributes<HTMLInputElement | HTMLTextAreaElement> {
124
125
  label?: string;
@@ -157,6 +158,7 @@ interface DateRangePickerProps {
157
158
  setIsExporting?: (value: boolean) => void;
158
159
  isExporting?: boolean;
159
160
  className?: string;
161
+ hasLimit?: boolean;
160
162
  }
161
163
  declare const DateRangePicker: React$1.FC<DateRangePickerProps>;
162
164
 
@@ -228,8 +230,9 @@ declare type SingleSelectDropdownProps = {
228
230
  hasSearchIcon?: boolean;
229
231
  searchInputClass?: string;
230
232
  placeholderSearchClass?: string;
233
+ usePortal?: boolean;
231
234
  };
232
- declare function SingleSelectDropdown({ label, value, onChange, options, placeholder, onScrollToEnd, onSearch, hasMore, isLoading, searchable, searchDebounceMs, requiresSearch, minSearchLength, emptyMessage, loadingMessage, searchPlaceholder, disabled, hasIcon, buttonClass, labelClass, displayItemClass, displayMainClass, hasSearchIcon, searchInputClass, placeholderSearchClass, }: SingleSelectDropdownProps): JSX.Element;
235
+ declare function SingleSelectDropdown({ label, value, onChange, options, placeholder, onScrollToEnd, onSearch, hasMore, isLoading, searchable, searchDebounceMs, requiresSearch, minSearchLength, emptyMessage, loadingMessage, searchPlaceholder, disabled, hasIcon, buttonClass, labelClass, displayItemClass, displayMainClass, hasSearchIcon, searchInputClass, placeholderSearchClass, usePortal, }: SingleSelectDropdownProps): JSX.Element;
233
236
 
234
237
  interface SelectionButton {
235
238
  data: string[];
@@ -496,12 +499,7 @@ interface BoxBodyProps extends React$1.HTMLAttributes<HTMLDivElement> {
496
499
  }
497
500
  declare const BoxBody: React$1.FC<BoxBodyProps>;
498
501
 
499
- interface DateValidationOptions {
500
- enableYearRange?: boolean;
501
- yearsBack?: number;
502
- allowFutureDates?: boolean;
503
- }
504
- declare const validateAndFormatInput: (rawInput: string, options?: DateValidationOptions) => string;
502
+ declare const validateAndFormatInput: (rawInput: string, options?: any) => string;
505
503
  declare const validateDate: (dateString: string, allowFutureDates?: boolean) => boolean;
506
504
  declare const validateDateRange: (dateString: string, options?: {
507
505
  allowFutureDates?: boolean;
package/dist/index.d.ts CHANGED
@@ -115,10 +115,11 @@ interface MultiBarGraphProps {
115
115
  datasets: DataSet[];
116
116
  xAxisLabels: string[];
117
117
  className?: string;
118
- /** Determines the default position of the tooltip. Defaults to 'top'. */
119
118
  tooltipPosition?: "top" | "bottom";
119
+ /** The maximum value for the Y-axis. Defaults to undefined, allowing Chart.js to auto-calculate. */
120
+ yAxisMax?: number;
120
121
  }
121
- declare const MultiBarGraph: ({ datasets, xAxisLabels, className, tooltipPosition, }: MultiBarGraphProps) => JSX.Element;
122
+ declare const MultiBarGraph: ({ datasets, xAxisLabels, className, tooltipPosition, yAxisMax, }: MultiBarGraphProps) => JSX.Element;
122
123
 
123
124
  interface CommonInputProps extends React$1.HTMLAttributes<HTMLInputElement | HTMLTextAreaElement> {
124
125
  label?: string;
@@ -157,6 +158,7 @@ interface DateRangePickerProps {
157
158
  setIsExporting?: (value: boolean) => void;
158
159
  isExporting?: boolean;
159
160
  className?: string;
161
+ hasLimit?: boolean;
160
162
  }
161
163
  declare const DateRangePicker: React$1.FC<DateRangePickerProps>;
162
164
 
@@ -228,8 +230,9 @@ declare type SingleSelectDropdownProps = {
228
230
  hasSearchIcon?: boolean;
229
231
  searchInputClass?: string;
230
232
  placeholderSearchClass?: string;
233
+ usePortal?: boolean;
231
234
  };
232
- declare function SingleSelectDropdown({ label, value, onChange, options, placeholder, onScrollToEnd, onSearch, hasMore, isLoading, searchable, searchDebounceMs, requiresSearch, minSearchLength, emptyMessage, loadingMessage, searchPlaceholder, disabled, hasIcon, buttonClass, labelClass, displayItemClass, displayMainClass, hasSearchIcon, searchInputClass, placeholderSearchClass, }: SingleSelectDropdownProps): JSX.Element;
235
+ declare function SingleSelectDropdown({ label, value, onChange, options, placeholder, onScrollToEnd, onSearch, hasMore, isLoading, searchable, searchDebounceMs, requiresSearch, minSearchLength, emptyMessage, loadingMessage, searchPlaceholder, disabled, hasIcon, buttonClass, labelClass, displayItemClass, displayMainClass, hasSearchIcon, searchInputClass, placeholderSearchClass, usePortal, }: SingleSelectDropdownProps): JSX.Element;
233
236
 
234
237
  interface SelectionButton {
235
238
  data: string[];
@@ -496,12 +499,7 @@ interface BoxBodyProps extends React$1.HTMLAttributes<HTMLDivElement> {
496
499
  }
497
500
  declare const BoxBody: React$1.FC<BoxBodyProps>;
498
501
 
499
- interface DateValidationOptions {
500
- enableYearRange?: boolean;
501
- yearsBack?: number;
502
- allowFutureDates?: boolean;
503
- }
504
- declare const validateAndFormatInput: (rawInput: string, options?: DateValidationOptions) => string;
502
+ declare const validateAndFormatInput: (rawInput: string, options?: any) => string;
505
503
  declare const validateDate: (dateString: string, allowFutureDates?: boolean) => boolean;
506
504
  declare const validateDateRange: (dateString: string, options?: {
507
505
  allowFutureDates?: boolean;
package/dist/index.js CHANGED
@@ -986,6 +986,11 @@ var MultiLineGraph = ({
986
986
  return;
987
987
  }
988
988
  const label = (_a = dataPoints[0]) == null ? void 0 : _a.label;
989
+ const date = new Date(label);
990
+ const formattedLabel = date.toLocaleString("en-US", {
991
+ month: "long",
992
+ year: "numeric"
993
+ });
989
994
  const dataPointsHtml = dataPoints.map(
990
995
  (point, index) => `
991
996
  <div style="display: flex; align-items: center; gap: 8px; margin: ${index > 0 ? "4px" : "0"} 0;">
@@ -1000,7 +1005,7 @@ var MultiLineGraph = ({
1000
1005
  <div id="tooltip-arrow-border"></div>
1001
1006
  <div id="tooltip-arrow"></div>
1002
1007
  <div>
1003
- <p style="color:#757575; margin: 0 0 8px 0;"><strong>${label}</strong></p>
1008
+ <p style="color:#757575; margin: 0 0 8px 0;"><strong>${formattedLabel}</strong></p>
1004
1009
  ${dataPointsHtml}
1005
1010
  </div>
1006
1011
  </div>`;
@@ -1090,7 +1095,7 @@ var MultiLineGraph = ({
1090
1095
  }
1091
1096
  }
1092
1097
  }),
1093
- [tooltipPosition]
1098
+ [tooltipPosition, svg]
1094
1099
  // Add dependency here
1095
1100
  );
1096
1101
  const verticalHoverLine = React.useMemo(
@@ -1270,6 +1275,11 @@ var SingleLineGraph = ({
1270
1275
  if (!dataPoint) return;
1271
1276
  const value = dataPoint.parsed.y;
1272
1277
  const label2 = dataPoint.label;
1278
+ const date = new Date(label2);
1279
+ const formattedLabel = date.toLocaleString("en-US", {
1280
+ month: "long",
1281
+ year: "numeric"
1282
+ });
1273
1283
  const arrowSize = 6;
1274
1284
  const innerArrowSize = 5;
1275
1285
  const isAbove = tooltipPosition === "top";
@@ -1280,7 +1290,7 @@ var SingleLineGraph = ({
1280
1290
  <div id="tooltip-arrow-border" style="position: absolute; transform: translateX(-50%); width: 0; height: 0; border-left: ${arrowSize}px solid transparent; border-right: ${arrowSize}px solid transparent; ${arrowBorderStyles}"></div>
1281
1291
  <div id="tooltip-arrow-inner" style="position: absolute; width: 0; height: 0; border-left: ${innerArrowSize}px solid transparent; border-right: ${innerArrowSize}px solid transparent; ${arrowInnerStyles}"></div>
1282
1292
  <div>
1283
- <p style="color:#757575; margin: 0 0 4px 0;"><strong>${label2}</strong></p>
1293
+ <p style="color:#757575; margin: 0 0 4px 0;"><strong>${formattedLabel}</strong></p>
1284
1294
  <span style="display: inline-flex; align-items: center; font-weight: bold; color: #757575;">
1285
1295
  ${svg}
1286
1296
  ${labelPopupTitle}: <span style="color:#131414;">&nbsp;${value}</span>
@@ -1495,11 +1505,11 @@ var MultiBarGraph = ({
1495
1505
  datasets,
1496
1506
  xAxisLabels,
1497
1507
  className = "",
1498
- tooltipPosition = "top"
1499
- // Default position is 'top'
1508
+ tooltipPosition = "top",
1509
+ yAxisMax
1510
+ // CHANGED: Added yAxisMax prop
1500
1511
  }) => {
1501
1512
  const chartRef = React.useRef(null);
1502
- const [chartKey, setChartKey] = React.useState(`chart-${Date.now()}`);
1503
1513
  const defaultColors = [
1504
1514
  "#58508d",
1505
1515
  "#bc5090",
@@ -1510,36 +1520,30 @@ var MultiBarGraph = ({
1510
1520
  ];
1511
1521
  const getDefaultSvgIcon = () => `
1512
1522
  <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
1513
- <g clip-path="url(#clip0_5485_36311)">
1514
- <path d="M7.00033 1.16602C3.78033 1.16602 1.16699 3.77935 1.16699 6.99935C1.16699 10.2193 3.78033 12.8327 7.00033 12.8327C10.2203 12.8327 12.8337 10.2193 12.8337 6.99935C12.8337 3.77935 10.2203 1.16602 7.00033 1.16602ZM7.00033 11.666C4.42783 11.666 2.33366 9.57185 2.33366 6.99935C2.33366 4.42685 4.42783 2.33268 7.00033 2.33268C9.57283 2.33268 11.667 4.42685 11.667 6.99935C11.667 9.57185 9.57283 11.666 7.00033 11.666ZM9.67782 4.42102L5.83366 8.26518L4.32283 6.76018L3.50033 7.58268L5.83366 9.91602L10.5003 5.24935L9.67782 4.42102Z" fill="#003f5c"/>
1515
- </g>
1516
- <defs>
1517
- <clipPath id="clip0_5485_36311"><rect width="14" height="14" fill="white"/></clipPath>
1518
- </defs>
1523
+ <g clip-path="url(#clip0_5485_36311)"><path d="M7.00033 1.16602C3.78033 1.16602 1.16699 3.77935 1.16699 6.99935C1.16699 10.2193 3.78033 12.8327 7.00033 12.8327C10.2203 12.8327 12.8337 10.2193 12.8337 6.99935C12.8337 3.77935 10.2203 1.16602 7.00033 1.16602ZM7.00033 11.666C4.42783 11.666 2.33366 9.57185 2.33366 6.99935C2.33366 4.42685 4.42783 2.33268 7.00033 2.33268C9.57283 2.33268 11.667 4.42685 11.667 6.99935C11.667 9.57185 9.57283 11.666 7.00033 11.666ZM9.67782 4.42102L5.83366 8.26518L4.32283 6.76018L3.50033 7.58268L5.83366 9.91602L10.5003 5.24935L9.67782 4.42102Z" fill="#003f5c"/></g>
1524
+ <defs><clipPath id="clip0_5485_36311"><rect width="14" height="14" fill="white"/></clipPath></defs>
1519
1525
  </svg>
1520
1526
  `;
1521
1527
  React.useEffect(() => {
1522
- const handleResize = () => setChartKey(`chart-${Date.now()}`);
1523
- window.addEventListener("resize", handleResize);
1524
- return () => window.removeEventListener("resize", handleResize);
1528
+ return () => {
1529
+ const tooltipEl = document.getElementById("chartjs-tooltip");
1530
+ if (tooltipEl) {
1531
+ tooltipEl.remove();
1532
+ }
1533
+ };
1525
1534
  }, []);
1526
1535
  const options = React.useMemo(
1527
1536
  () => ({
1528
1537
  responsive: true,
1529
1538
  maintainAspectRatio: false,
1530
- animation: {
1531
- duration: 100,
1532
- easing: "easeOutQuad"
1533
- },
1539
+ animation: { duration: 100, easing: "easeOutQuad" },
1534
1540
  scales: {
1535
- x: {
1536
- stacked: true,
1537
- grid: { drawOnChartArea: false }
1538
- },
1541
+ x: { stacked: true, grid: { drawOnChartArea: false } },
1539
1542
  y: {
1540
1543
  stacked: true,
1541
1544
  min: 0,
1542
- max: 100,
1545
+ max: yAxisMax,
1546
+ // CHANGED: Use the dynamic yAxisMax prop
1543
1547
  border: { display: false },
1544
1548
  grid: { drawOnChartArea: false }
1545
1549
  }
@@ -1570,69 +1574,62 @@ var MultiBarGraph = ({
1570
1574
  (sum, dataset) => sum + (dataset.data[hoveredPoint.dataIndex] || 0),
1571
1575
  0
1572
1576
  );
1577
+ const date = new Date(label);
1578
+ const formattedLabel = date.toLocaleString("en-US", {
1579
+ month: "long",
1580
+ year: "numeric"
1581
+ });
1573
1582
  const percentage = totalBarValue > 0 ? (segmentValue / totalBarValue * 100).toFixed(2) : 0;
1574
1583
  const iconHtml = customSvgIcon || getDefaultSvgIcon();
1575
- const dataPointHtml = `
1576
- <div style="display: flex; align-items: center; gap: 8px;">
1577
- ${iconHtml}
1578
- <span style="font-weight: bold; color: #757575;">
1579
- ${segmentLabel}: <span style="color:#131414;">${segmentValue} (${percentage}%)</span>
1580
- </span>
1581
- </div>`;
1582
1584
  tooltipEl.innerHTML = `
1583
1585
  <div style="position: relative; background: white; border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); padding: 10px; font-size: 12px; z-index: 999;">
1584
1586
  <div id="tooltip-arrow" style="position: absolute; width: 0; height: 0;"></div>
1585
- <p style="color:#757575; margin: 0 0 8px 0;"><strong>${label}</strong></p>
1586
- ${dataPointHtml}
1587
+ <p style="color:#757575; margin: 0 0 8px 0;"><strong>${formattedLabel}</strong></p>
1588
+ <div style="display: flex; align-items: center; gap: 8px;">
1589
+ ${iconHtml}
1590
+ <span style="font-weight: bold; color: #757575;">
1591
+ ${segmentLabel}: <span style="color:#131414;">${segmentValue} (${percentage}%)</span>
1592
+ </span>
1593
+ </div>
1587
1594
  </div>`;
1588
1595
  const position = context.chart.canvas.getBoundingClientRect();
1589
1596
  const tooltipWidth = tooltipEl.offsetWidth;
1590
1597
  const tooltipHeight = tooltipEl.offsetHeight;
1591
1598
  const arrowSize = 6;
1592
1599
  let isAbove = tooltipPosition === "top";
1593
- let yPosition;
1594
1600
  const yTop = position.top + window.scrollY + hoveredPoint.element.y - tooltipHeight - arrowSize - 5;
1595
1601
  const yBottom = position.top + window.scrollY + hoveredPoint.element.y + arrowSize + 5;
1602
+ let yPosition;
1596
1603
  if (isAbove) {
1597
- yPosition = yTop;
1598
- if (yPosition < window.scrollY + 10) {
1599
- yPosition = yBottom;
1600
- isAbove = false;
1601
- }
1604
+ yPosition = yTop < window.scrollY + 10 ? yBottom : yTop;
1602
1605
  } else {
1603
- yPosition = yBottom;
1604
- if (yPosition + tooltipHeight > window.innerHeight + window.scrollY - 10) {
1605
- yPosition = yTop;
1606
- isAbove = true;
1607
- }
1606
+ yPosition = yBottom + tooltipHeight > window.innerHeight + window.scrollY - 10 ? yTop : yBottom;
1608
1607
  }
1608
+ isAbove = yPosition === yTop;
1609
1609
  let xPosition = position.left + window.scrollX + hoveredPoint.element.x - tooltipWidth / 2;
1610
- if (xPosition < 10) xPosition = 10;
1611
- if (xPosition + tooltipWidth > window.innerWidth - 10)
1612
- xPosition = window.innerWidth - 10 - tooltipWidth;
1610
+ xPosition = Math.max(
1611
+ 10,
1612
+ Math.min(xPosition, window.innerWidth - 10 - tooltipWidth)
1613
+ );
1613
1614
  const arrowEl = tooltipEl.querySelector("#tooltip-arrow");
1614
1615
  if (arrowEl) {
1615
- if (isAbove) {
1616
- arrowEl.style.top = "100%";
1617
- arrowEl.style.bottom = "auto";
1618
- arrowEl.style.borderTop = `${arrowSize}px solid white`;
1619
- arrowEl.style.borderBottom = "none";
1620
- } else {
1621
- arrowEl.style.bottom = "100%";
1622
- arrowEl.style.top = "auto";
1623
- arrowEl.style.borderBottom = `${arrowSize}px solid white`;
1624
- arrowEl.style.borderTop = "none";
1625
- }
1626
- arrowEl.style.borderLeft = `${arrowSize}px solid transparent`;
1627
- arrowEl.style.borderRight = `${arrowSize}px solid transparent`;
1628
- const arrowX = position.left + window.scrollX + hoveredPoint.element.x - xPosition - arrowSize;
1629
- arrowEl.style.left = `${arrowX}px`;
1616
+ Object.assign(arrowEl.style, {
1617
+ top: isAbove ? "100%" : "auto",
1618
+ bottom: isAbove ? "auto" : "100%",
1619
+ borderTop: isAbove ? `${arrowSize}px solid white` : "none",
1620
+ borderBottom: isAbove ? "none" : `${arrowSize}px solid white`,
1621
+ borderLeft: `${arrowSize}px solid transparent`,
1622
+ borderRight: `${arrowSize}px solid transparent`,
1623
+ left: `${position.left + window.scrollX + hoveredPoint.element.x - xPosition - arrowSize}px`
1624
+ });
1630
1625
  }
1631
- tooltipEl.style.opacity = "1";
1632
- tooltipEl.style.position = "absolute";
1633
- tooltipEl.style.left = `${xPosition}px`;
1634
- tooltipEl.style.top = `${yPosition}px`;
1635
- tooltipEl.style.pointerEvents = "none";
1626
+ Object.assign(tooltipEl.style, {
1627
+ opacity: "1",
1628
+ position: "absolute",
1629
+ left: `${xPosition}px`,
1630
+ top: `${yPosition}px`,
1631
+ pointerEvents: "none"
1632
+ });
1636
1633
  }
1637
1634
  }
1638
1635
  },
@@ -1641,17 +1638,19 @@ var MultiBarGraph = ({
1641
1638
  mode: "nearest"
1642
1639
  }
1643
1640
  }),
1644
- [tooltipPosition]
1645
- // Add dependency here
1641
+ [tooltipPosition, yAxisMax, datasets]
1642
+ // CHANGED: Added datasets and yAxisMax for safety
1646
1643
  );
1647
1644
  const dashedGridPlugin = React.useMemo(
1648
1645
  () => ({
1649
1646
  id: "customDashedGrid",
1650
1647
  beforeDatasetsDraw(chart) {
1651
- const ctx = chart.ctx;
1652
- const yAxis = chart.scales.y;
1648
+ const {
1649
+ ctx,
1650
+ chartArea: { left, right },
1651
+ scales: { y: yAxis }
1652
+ } = chart;
1653
1653
  if (!yAxis) return;
1654
- const { left, right } = chart.chartArea;
1655
1654
  ctx.save();
1656
1655
  ctx.setLineDash([4, 4]);
1657
1656
  ctx.strokeStyle = "rgba(0, 0, 0, 0.1)";
@@ -1673,14 +1672,8 @@ var MultiBarGraph = ({
1673
1672
  () => ({
1674
1673
  labels: xAxisLabels,
1675
1674
  datasets: datasets.map((dataset, index) => ({
1676
- label: dataset.label,
1677
- data: dataset.data,
1678
- backgroundColor: `${dataset.backgroundColor || defaultColors[index % defaultColors.length]}`,
1679
- pointBackgroundColor: dataset.backgroundColor || defaultColors[index % defaultColors.length],
1680
- svgIcon: dataset.svgIcon,
1681
- fill: true,
1682
- tension: 0.4,
1683
- pointRadius: 1
1675
+ ...dataset,
1676
+ backgroundColor: dataset.backgroundColor || defaultColors[index % defaultColors.length]
1684
1677
  }))
1685
1678
  }),
1686
1679
  [datasets, xAxisLabels]
@@ -1692,8 +1685,7 @@ var MultiBarGraph = ({
1692
1685
  options,
1693
1686
  data: barData,
1694
1687
  plugins: [dashedGridPlugin]
1695
- },
1696
- chartKey
1688
+ }
1697
1689
  ) });
1698
1690
  };
1699
1691
  var MultiBarGraph_default = MultiBarGraph;
@@ -1774,18 +1766,22 @@ var validateAndFormatInput = (rawInput, options = {}) => {
1774
1766
  const {
1775
1767
  enableYearRange = true,
1776
1768
  yearsBack = 1,
1777
- allowFutureDates = false
1769
+ allowFutureDates = false,
1770
+ hasLimit = false,
1771
+ // New: To check if date range limit should be applied
1772
+ startDate = null
1773
+ // New: The selected start date for range comparison
1778
1774
  } = options;
1779
1775
  let digits = rawInput.replace(/\D/g, "");
1780
1776
  if (digits.length >= 2) {
1781
- const month = parseInt(digits.slice(0, 2));
1777
+ const month = parseInt(digits.slice(0, 2), 10);
1782
1778
  if (month < 1 || month > 12) {
1783
1779
  digits = digits.slice(0, 1);
1784
1780
  }
1785
1781
  }
1786
1782
  if (digits.length >= 4) {
1787
- const month = parseInt(digits.slice(0, 2));
1788
- const day = parseInt(digits.slice(2, 4));
1783
+ const month = parseInt(digits.slice(0, 2), 10);
1784
+ const day = parseInt(digits.slice(2, 4), 10);
1789
1785
  const daysInMonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
1790
1786
  const maxDays = daysInMonth[month - 1] || 31;
1791
1787
  if (day < 1 || day > maxDays) {
@@ -1795,15 +1791,15 @@ var validateAndFormatInput = (rawInput, options = {}) => {
1795
1791
  if (enableYearRange && digits.length >= 8) {
1796
1792
  const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
1797
1793
  const minYear = currentYear - yearsBack;
1798
- const inputYear = parseInt(digits.slice(4, 8));
1794
+ const inputYear = parseInt(digits.slice(4, 8), 10);
1799
1795
  if (inputYear < minYear || inputYear > currentYear) {
1800
1796
  digits = digits.slice(0, 4);
1801
1797
  }
1802
1798
  }
1803
1799
  if (!allowFutureDates && digits.length === 8) {
1804
- const month = parseInt(digits.slice(0, 2));
1805
- const day = parseInt(digits.slice(2, 4));
1806
- const year = parseInt(digits.slice(4, 8));
1800
+ const month = parseInt(digits.slice(0, 2), 10);
1801
+ const day = parseInt(digits.slice(2, 4), 10);
1802
+ const year = parseInt(digits.slice(4, 8), 10);
1807
1803
  const inputDate = new Date(year, month - 1, day);
1808
1804
  const today = /* @__PURE__ */ new Date();
1809
1805
  today.setHours(23, 59, 59, 999);
@@ -1811,6 +1807,17 @@ var validateAndFormatInput = (rawInput, options = {}) => {
1811
1807
  digits = digits.slice(0, 4);
1812
1808
  }
1813
1809
  }
1810
+ if (!hasLimit && startDate && digits.length === 8) {
1811
+ const month = parseInt(digits.slice(0, 2), 10);
1812
+ const day = parseInt(digits.slice(2, 4), 10);
1813
+ const year = parseInt(digits.slice(4, 8), 10);
1814
+ const inputDate = new Date(year, month - 1, day);
1815
+ const maxRangeDate = new Date(startDate);
1816
+ maxRangeDate.setFullYear(maxRangeDate.getFullYear() + yearsBack);
1817
+ if (inputDate > maxRangeDate) {
1818
+ digits = digits.slice(0, 7);
1819
+ }
1820
+ }
1814
1821
  digits = digits.slice(0, 8);
1815
1822
  let formatted = "";
1816
1823
  if (digits.length > 0) formatted += digits.slice(0, 2);
@@ -1888,7 +1895,9 @@ var DateRangePicker = ({
1888
1895
  handleExport,
1889
1896
  setIsExporting,
1890
1897
  isExporting = false,
1891
- className = ""
1898
+ className = "",
1899
+ hasLimit = false
1900
+ // Default to false to maintain the 1-year limit
1892
1901
  }) => {
1893
1902
  const [isOpen, setIsOpen] = React.useState(autoOpen);
1894
1903
  const [isApply, setIsApply] = React.useState(false);
@@ -1960,9 +1969,13 @@ var DateRangePicker = ({
1960
1969
  {
1961
1970
  label: "Last Week",
1962
1971
  getValue: () => {
1963
- const end = /* @__PURE__ */ new Date();
1964
- const start = new Date(end.getTime() - 7 * 24 * 60 * 60 * 1e3);
1965
- return { start, end };
1972
+ const now = /* @__PURE__ */ new Date();
1973
+ now.setHours(0, 0, 0, 0);
1974
+ const endOfLastWeek = new Date(now);
1975
+ endOfLastWeek.setDate(now.getDate() - (now.getDay() + 1));
1976
+ const startOfLastWeek = new Date(endOfLastWeek);
1977
+ startOfLastWeek.setDate(endOfLastWeek.getDate() - 6);
1978
+ return { start: startOfLastWeek, end: endOfLastWeek };
1966
1979
  }
1967
1980
  },
1968
1981
  {
@@ -2094,10 +2107,12 @@ var DateRangePicker = ({
2094
2107
  const baseDate = new Date(startDate);
2095
2108
  baseDate.setHours(23, 59, 59, 999);
2096
2109
  if (date < baseDate) return true;
2097
- const earliestDate2 = new Date(startDate);
2098
- earliestDate2.setFullYear(earliestDate2.getFullYear() + yearsBack);
2099
- earliestDate2.setHours(0, 0, 0, 0);
2100
- if (date > earliestDate2) return true;
2110
+ if (!hasLimit) {
2111
+ const maxDate = new Date(startDate);
2112
+ maxDate.setFullYear(maxDate.getFullYear() + yearsBack);
2113
+ maxDate.setHours(0, 0, 0, 0);
2114
+ if (date > maxDate) return true;
2115
+ }
2101
2116
  return false;
2102
2117
  }
2103
2118
  if (startDate === null) return false;
@@ -2105,10 +2120,12 @@ var DateRangePicker = ({
2105
2120
  const baseDate = new Date(startDate);
2106
2121
  baseDate.setHours(23, 59, 59, 999);
2107
2122
  if (date < baseDate) return true;
2108
- const earliestDate2 = new Date(startDate);
2109
- earliestDate2.setFullYear(earliestDate2.getFullYear() + yearsBack);
2110
- earliestDate2.setHours(0, 0, 0, 0);
2111
- if (date > earliestDate2) return true;
2123
+ if (!hasLimit) {
2124
+ const maxDate = new Date(startDate);
2125
+ maxDate.setFullYear(maxDate.getFullYear() + yearsBack);
2126
+ maxDate.setHours(0, 0, 0, 0);
2127
+ if (date > maxDate) return true;
2128
+ }
2112
2129
  return false;
2113
2130
  }
2114
2131
  const today = /* @__PURE__ */ new Date();
@@ -2676,7 +2693,7 @@ var DateRangePicker = ({
2676
2693
  setLeftCalendarView("day");
2677
2694
  setRightCalendarView("day");
2678
2695
  },
2679
- children: "Custom Range (max 1 year)"
2696
+ children: hasLimit ? "Custom Range" : "Custom Range (max 1 year)"
2680
2697
  }
2681
2698
  ),
2682
2699
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-[8px]", children: [
@@ -2693,7 +2710,8 @@ var DateRangePicker = ({
2693
2710
  rawValue,
2694
2711
  {
2695
2712
  enableYearRange: false,
2696
- yearsBack
2713
+ yearsBack,
2714
+ hasLimit
2697
2715
  }
2698
2716
  );
2699
2717
  setStartInput(formattedValue);
@@ -2743,7 +2761,8 @@ var DateRangePicker = ({
2743
2761
  rawValue,
2744
2762
  {
2745
2763
  enableYearRange: false,
2746
- yearsBack
2764
+ yearsBack,
2765
+ hasLimit
2747
2766
  }
2748
2767
  );
2749
2768
  setEndInput(formattedValue);
@@ -3259,7 +3278,9 @@ function SingleSelectDropdown({
3259
3278
  displayMainClass = "",
3260
3279
  hasSearchIcon = true,
3261
3280
  searchInputClass = "",
3262
- placeholderSearchClass = ""
3281
+ placeholderSearchClass = "",
3282
+ usePortal = true
3283
+ // ✅ default true
3263
3284
  }) {
3264
3285
  const [isOpen, setIsOpen] = React.useState(false);
3265
3286
  const [searchTerm, setSearchTerm] = React.useState("");
@@ -3358,7 +3379,7 @@ function SingleSelectDropdown({
3358
3379
  }
3359
3380
  }, [isOpen]);
3360
3381
  React.useLayoutEffect(() => {
3361
- if (isOpen && dropdownRef.current) {
3382
+ if (isOpen && dropdownRef.current && usePortal) {
3362
3383
  const rect = dropdownRef.current.getBoundingClientRect();
3363
3384
  setDropdownPosition({
3364
3385
  top: rect.bottom + window.scrollY,
@@ -3366,7 +3387,7 @@ function SingleSelectDropdown({
3366
3387
  width: rect.width
3367
3388
  });
3368
3389
  }
3369
- }, [isOpen]);
3390
+ }, [isOpen, usePortal]);
3370
3391
  const handleToggle = () => {
3371
3392
  if (!disabled) {
3372
3393
  setIsOpen(!isOpen);
@@ -3376,12 +3397,12 @@ function SingleSelectDropdown({
3376
3397
  "div",
3377
3398
  {
3378
3399
  ref: portalRef,
3379
- style: {
3400
+ style: usePortal ? {
3380
3401
  position: "absolute",
3381
3402
  top: `${dropdownPosition.top + 4}px`,
3382
3403
  left: `${dropdownPosition.left}px`,
3383
3404
  width: `${dropdownPosition.width}px`
3384
- },
3405
+ } : { position: "absolute", top: "100%", left: 0, marginTop: "4px", width: "100%" },
3385
3406
  className: "rounded-md bg-white shadow-lg z-50",
3386
3407
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-2 shadow-md border rounded-md max-h-[410px] flex flex-col", children: [
3387
3408
  searchable && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
@@ -3538,7 +3559,7 @@ function SingleSelectDropdown({
3538
3559
  ]
3539
3560
  }
3540
3561
  ),
3541
- isOpen && !disabled && reactDom.createPortal(DropdownMenu, document.body)
3562
+ isOpen && !disabled && (usePortal ? reactDom.createPortal(DropdownMenu, document.body) : DropdownMenu)
3542
3563
  ] })
3543
3564
  ] });
3544
3565
  }