@economic/taco 2.70.3-day-picker-v9.0 → 2.70.3-day-picker-v9.1

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/taco.cjs CHANGED
@@ -23864,7 +23864,7 @@ const YearsDropdown = (props) => {
23864
23864
  return /* @__PURE__ */ React__namespace.createElement("select", { className: "h-8 px-2", name: "year", onChange, value }, years.map((year) => /* @__PURE__ */ React__namespace.createElement("option", { key: year, value: year }, String(year))));
23865
23865
  };
23866
23866
  const Calendar = (props) => {
23867
- const { onChange: handleChange, value, disabledDays, autoFocus = false, ...otherProps } = props;
23867
+ const { onChange: handleChange, value, disabledDays, ...otherProps } = props;
23868
23868
  const [visibleMonth, setVisibleMonth] = React__namespace.useState(value ?? /* @__PURE__ */ new Date());
23869
23869
  const { texts } = useLocalization();
23870
23870
  React__namespace.useEffect(() => {
@@ -23882,7 +23882,6 @@ const Calendar = (props) => {
23882
23882
  return /* @__PURE__ */ React__namespace.createElement("div", { "data-taco": "calendar" }, /* @__PURE__ */ React__namespace.createElement(
23883
23883
  DayPicker,
23884
23884
  {
23885
- autoFocus,
23886
23885
  captionLayout: "dropdown",
23887
23886
  className,
23888
23887
  components: {
@@ -25859,6 +25858,7 @@ const Datepicker = React__namespace.forwardRef(function Datepicker2(props, ref)
25859
25858
  const { calendar: calendar2, input } = useDatepicker(otherProps, ref);
25860
25859
  const { texts } = useLocalization();
25861
25860
  const className = clsx("inline-flex w-full text-black font-normal", externalClassName);
25861
+ const popoverContentRef = React__namespace.useRef(null);
25862
25862
  const handlePopoverClick = React__namespace.useCallback((event) => {
25863
25863
  event.stopPropagation();
25864
25864
  }, []);
@@ -25870,6 +25870,12 @@ const Datepicker = React__namespace.forwardRef(function Datepicker2(props, ref)
25870
25870
  },
25871
25871
  [input.ref]
25872
25872
  );
25873
+ const handleOpenAutoFocus = (event) => {
25874
+ var _a;
25875
+ event.preventDefault();
25876
+ const currentDay = ((_a = popoverContentRef == null ? void 0 : popoverContentRef.current) == null ? void 0 : _a.querySelector("td.rdp-selected button")) ?? null;
25877
+ currentDay == null ? void 0 : currentDay.focus();
25878
+ };
25873
25879
  const handleInputKeyDown = (event) => {
25874
25880
  var _a, _b;
25875
25881
  (_a = props.onKeyDown) == null ? void 0 : _a.call(props, event);
@@ -25889,43 +25895,49 @@ const Datepicker = React__namespace.forwardRef(function Datepicker2(props, ref)
25889
25895
  disabled: input.disabled || input.readOnly,
25890
25896
  icon: "calendar",
25891
25897
  tabIndex: -1,
25892
- popover: (props2) => /* @__PURE__ */ React__namespace.createElement(Popover, { ...props2 }, /* @__PURE__ */ React__namespace.createElement(Popover.Content, { onCloseAutoFocus: handleCloseAutoFocus }, ({ close }) => /* @__PURE__ */ React__namespace.createElement("div", { className: "-m-3 flex", onClick: handlePopoverClick }, /* @__PURE__ */ React__namespace.createElement(
25893
- Calendar,
25894
- {
25895
- ...calendar2,
25896
- autoFocus: true,
25897
- onChange: (date2, event) => {
25898
- calendar2.onChange(date2, event);
25899
- close();
25900
- }
25901
- }
25902
- ), shortcuts && /* @__PURE__ */ React__namespace.createElement("div", { className: "border-grey-300 flex flex-col border-l" }, /* @__PURE__ */ React__namespace.createElement("span", { className: "m-4 mb-3 flex h-8 w-32 items-center text-xs font-semibold" }, shortcutsText ?? texts.datepicker.shortcuts), /* @__PURE__ */ React__namespace.createElement("ul", null, shortcuts.map((shortcut2) => /* @__PURE__ */ React__namespace.createElement("li", { key: shortcut2.text }, /* @__PURE__ */ React__namespace.createElement(
25903
- "button",
25898
+ popover: (props2) => /* @__PURE__ */ React__namespace.createElement(Popover, { ...props2 }, /* @__PURE__ */ React__namespace.createElement(
25899
+ Popover.Content,
25904
25900
  {
25905
- type: "button",
25906
- className: "hover:wcag-grey-200 flex w-full items-start px-4 py-1 text-xs",
25907
- "data-taco": "datepicker-shortcut",
25908
- onClick: (event) => {
25909
- event.persist();
25910
- shortcut2.onClick(event);
25911
- close();
25912
- }
25901
+ onOpenAutoFocus: handleOpenAutoFocus,
25902
+ onCloseAutoFocus: handleCloseAutoFocus
25913
25903
  },
25914
- shortcut2.text
25915
- )))), handleReset && /* @__PURE__ */ React__namespace.createElement(
25916
- "button",
25917
- {
25918
- type: "button",
25919
- className: "mx-auto my-4 mt-auto inline-flex cursor-pointer border-none bg-transparent text-xs text-blue-500 hover:text-blue-300",
25920
- "data-taco": "datepicker-clear-button",
25921
- onClick: (event) => {
25922
- event.persist();
25923
- handleReset(event);
25924
- close();
25904
+ ({ close }) => /* @__PURE__ */ React__namespace.createElement("div", { ref: popoverContentRef, className: "-m-3 flex", onClick: handlePopoverClick }, /* @__PURE__ */ React__namespace.createElement(
25905
+ Calendar,
25906
+ {
25907
+ ...calendar2,
25908
+ onChange: (date2, event) => {
25909
+ calendar2.onChange(date2, event);
25910
+ close();
25911
+ }
25925
25912
  }
25926
- },
25927
- texts.datepicker.clear
25928
- ))))),
25913
+ ), shortcuts && /* @__PURE__ */ React__namespace.createElement("div", { className: "border-grey-300 flex flex-col border-l" }, /* @__PURE__ */ React__namespace.createElement("span", { className: "m-4 mb-3 flex h-8 w-32 items-center text-xs font-semibold" }, shortcutsText ?? texts.datepicker.shortcuts), /* @__PURE__ */ React__namespace.createElement("ul", null, shortcuts.map((shortcut2) => /* @__PURE__ */ React__namespace.createElement("li", { key: shortcut2.text }, /* @__PURE__ */ React__namespace.createElement(
25914
+ "button",
25915
+ {
25916
+ type: "button",
25917
+ className: "hover:wcag-grey-200 flex w-full items-start px-4 py-1 text-xs",
25918
+ "data-taco": "datepicker-shortcut",
25919
+ onClick: (event) => {
25920
+ event.persist();
25921
+ shortcut2.onClick(event);
25922
+ close();
25923
+ }
25924
+ },
25925
+ shortcut2.text
25926
+ )))), handleReset && /* @__PURE__ */ React__namespace.createElement(
25927
+ "button",
25928
+ {
25929
+ type: "button",
25930
+ className: "mx-auto my-4 mt-auto inline-flex cursor-pointer border-none bg-transparent text-xs text-blue-500 hover:text-blue-300",
25931
+ "data-taco": "datepicker-clear-button",
25932
+ onClick: (event) => {
25933
+ event.persist();
25934
+ handleReset(event);
25935
+ close();
25936
+ }
25937
+ },
25938
+ texts.datepicker.clear
25939
+ )))
25940
+ )),
25929
25941
  tooltip: texts.datepicker.calendar,
25930
25942
  "data-taco": "toggle-calendar-button"
25931
25943
  }