formanitor 0.0.29 → 0.0.30

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.cjs CHANGED
@@ -1715,29 +1715,66 @@ var RepeatableWidget = ({
1715
1715
  showError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
1716
1716
  ] });
1717
1717
  };
1718
+ function CalendarDropdown(props) {
1719
+ const { options, value, onChange } = props;
1720
+ const handleValueChange = (newValue) => {
1721
+ if (!onChange) return;
1722
+ const syntheticEvent = {
1723
+ target: { value: newValue }
1724
+ };
1725
+ onChange(syntheticEvent);
1726
+ };
1727
+ return /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: value?.toString(), onValueChange: handleValueChange, children: [
1728
+ /* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "h-7 px-2 text-sm", "aria-label": props["aria-label"], children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, {}) }),
1729
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { children: options?.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
1730
+ SelectItem,
1731
+ {
1732
+ value: option.value.toString(),
1733
+ disabled: option.disabled,
1734
+ children: option.label
1735
+ },
1736
+ option.value.toString()
1737
+ )) })
1738
+ ] });
1739
+ }
1718
1740
  function Calendar({
1719
1741
  className,
1720
1742
  classNames,
1721
1743
  showOutsideDays = true,
1722
1744
  ...props
1723
1745
  }) {
1746
+ const captionLayout = props.captionLayout ?? "dropdown";
1747
+ const isDropdownCaption = captionLayout === "dropdown" || captionLayout === "dropdown-months" || captionLayout === "dropdown-years";
1748
+ const startMonth = props.startMonth ?? (isDropdownCaption ? new Date(1900, 0) : void 0);
1749
+ const endMonth = props.endMonth ?? (isDropdownCaption ? new Date(2100, 11) : void 0);
1724
1750
  return /* @__PURE__ */ jsxRuntime.jsx(
1725
1751
  reactDayPicker.DayPicker,
1726
1752
  {
1727
1753
  showOutsideDays,
1754
+ captionLayout,
1755
+ hideNavigation: props.hideNavigation ?? isDropdownCaption,
1756
+ navLayout: props.navLayout ?? (isDropdownCaption ? "around" : void 0),
1757
+ startMonth,
1758
+ endMonth,
1728
1759
  className: cn("p-3 relative", className),
1729
1760
  classNames: {
1730
1761
  months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
1731
1762
  month: "space-y-4",
1732
1763
  caption: "flex justify-center pt-1 relative items-center",
1733
- caption_label: "text-sm font-medium",
1764
+ caption_label: cn(
1765
+ "text-sm font-medium",
1766
+ isDropdownCaption && "sr-only"
1767
+ ),
1768
+ dropdowns: "flex items-center gap-2",
1769
+ months_dropdown: "h-7 rounded-md border border-input bg-background px-2 text-sm",
1770
+ years_dropdown: "h-7 rounded-md border border-input bg-background px-2 text-sm",
1734
1771
  nav: "space-x-1 flex items-center",
1735
1772
  nav_button: cn(
1736
1773
  buttonVariants({ variant: "outline" }),
1737
1774
  "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
1738
1775
  ),
1739
- nav_button_previous: "absolute left-1",
1740
- nav_button_next: "absolute right-1",
1776
+ nav_button_previous: isDropdownCaption ? "" : "absolute left-1",
1777
+ nav_button_next: isDropdownCaption ? "" : "absolute right-1",
1741
1778
  table: "w-full border-collapse space-y-1",
1742
1779
  head_row: "flex",
1743
1780
  head_cell: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
@@ -1758,12 +1795,12 @@ function Calendar({
1758
1795
  button_previous: cn(
1759
1796
  buttonVariants({ variant: "outline" }),
1760
1797
  "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
1761
- "absolute left-1 top-3"
1798
+ isDropdownCaption ? "" : "absolute left-1 top-3"
1762
1799
  ),
1763
1800
  button_next: cn(
1764
1801
  buttonVariants({ variant: "outline" }),
1765
1802
  "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
1766
- "absolute right-1 top-3"
1803
+ isDropdownCaption ? "" : "absolute right-1 top-3"
1767
1804
  ),
1768
1805
  month_grid: "w-full border-collapse space-y-1",
1769
1806
  weekdays: "flex",
@@ -1783,9 +1820,11 @@ function Calendar({
1783
1820
  ...classNames
1784
1821
  },
1785
1822
  components: {
1786
- IconLeft: ({ ...props2 }) => /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" }),
1787
- IconRight: ({ ...props2 }) => /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4" }),
1788
- // @ts-ignore
1823
+ IconLeft: () => /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "h-4 w-4" }),
1824
+ IconRight: () => /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4" }),
1825
+ // @ts-expect-error react-day-picker v9 component typing differences
1826
+ Dropdown: CalendarDropdown,
1827
+ // @ts-expect-error react-day-picker v9 component typing differences
1789
1828
  Chevron: ({ orientation }) => {
1790
1829
  const Icon2 = orientation === "left" ? lucideReact.ChevronLeft : lucideReact.ChevronRight;
1791
1830
  return /* @__PURE__ */ jsxRuntime.jsx(Icon2, { className: "h-4 w-4" });