@mirohq/design-system-calendar 2.5.9 → 2.5.11
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.js +36 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +36 -0
- package/dist/module.js.map +1 -1
- package/package.json +11 -11
package/dist/main.js
CHANGED
|
@@ -716,6 +716,37 @@ const Header = ({
|
|
|
716
716
|
}
|
|
717
717
|
return "";
|
|
718
718
|
};
|
|
719
|
+
const prevButtonRef = React.useRef(null);
|
|
720
|
+
const nextButtonRef = React.useRef(null);
|
|
721
|
+
const titleButtonRef = React.useRef(null);
|
|
722
|
+
const focusedStepRef = React.useRef(null);
|
|
723
|
+
React.useLayoutEffect(() => {
|
|
724
|
+
var _a;
|
|
725
|
+
const focusedStep = focusedStepRef.current;
|
|
726
|
+
if (focusedStep === null) return;
|
|
727
|
+
const isPrev = focusedStep === "prev";
|
|
728
|
+
const isFocusedStepDisabled = (isPrev ? isPrevDisabled : isNextDisabled) === true;
|
|
729
|
+
if (!isFocusedStepDisabled) return;
|
|
730
|
+
const disabledButton = isPrev ? prevButtonRef.current : nextButtonRef.current;
|
|
731
|
+
const otherButton = isPrev ? nextButtonRef.current : prevButtonRef.current;
|
|
732
|
+
const activeElement = disabledButton == null ? void 0 : disabledButton.ownerDocument.activeElement;
|
|
733
|
+
focusedStepRef.current = null;
|
|
734
|
+
if (activeElement != null && activeElement !== disabledButton && activeElement !== (disabledButton == null ? void 0 : disabledButton.ownerDocument.body)) {
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
const fallback = (_a = titleButtonRef.current) != null ? _a : (otherButton == null ? void 0 : otherButton.disabled) === false ? otherButton : null;
|
|
738
|
+
fallback == null ? void 0 : fallback.focus();
|
|
739
|
+
}, [isPrevDisabled, isNextDisabled]);
|
|
740
|
+
const trackStepFocus = (step) => ({
|
|
741
|
+
onFocus: () => {
|
|
742
|
+
focusedStepRef.current = step;
|
|
743
|
+
},
|
|
744
|
+
// A button that disables itself blurs with no relatedTarget; keep tracking
|
|
745
|
+
// it so the effect above can still hand focus on.
|
|
746
|
+
onBlur: (event) => {
|
|
747
|
+
if (event.relatedTarget !== null) focusedStepRef.current = null;
|
|
748
|
+
}
|
|
749
|
+
});
|
|
719
750
|
const isTopLevel = viewMode === "years";
|
|
720
751
|
const showClickableTitle = navigation === true && !isTopLevel;
|
|
721
752
|
const isDayView = viewMode === "days";
|
|
@@ -727,15 +758,18 @@ const Header = ({
|
|
|
727
758
|
isDayView ? /* @__PURE__ */ jsxRuntime.jsx(HeaderButton, { ...prevButtonProps, children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconChevronLeft, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
728
759
|
HeaderButton,
|
|
729
760
|
{
|
|
761
|
+
ref: prevButtonRef,
|
|
730
762
|
"aria-label": stepLabels.prev,
|
|
731
763
|
isDisabled: isPrevDisabled,
|
|
732
764
|
onClick: onPrevOverride,
|
|
765
|
+
...trackStepFocus("prev"),
|
|
733
766
|
children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconChevronLeft, {})
|
|
734
767
|
}
|
|
735
768
|
),
|
|
736
769
|
/* @__PURE__ */ jsxRuntime.jsx(StyledHeaderTitle, { level: 2, styledAs: "h3", children: showClickableTitle ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
737
770
|
StyledHeaderTitleButton,
|
|
738
771
|
{
|
|
772
|
+
ref: titleButtonRef,
|
|
739
773
|
onClick: onZoomOut,
|
|
740
774
|
"aria-label": (formatSwitchViewLabel != null ? formatSwitchViewLabel : strings.switchView)(
|
|
741
775
|
getTitleText(),
|
|
@@ -753,9 +787,11 @@ const Header = ({
|
|
|
753
787
|
isDayView ? /* @__PURE__ */ jsxRuntime.jsx(HeaderButton, { ...nextButtonProps, children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconChevronRight, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
754
788
|
HeaderButton,
|
|
755
789
|
{
|
|
790
|
+
ref: nextButtonRef,
|
|
756
791
|
"aria-label": stepLabels.next,
|
|
757
792
|
isDisabled: isNextDisabled,
|
|
758
793
|
onClick: onNextOverride,
|
|
794
|
+
...trackStepFocus("next"),
|
|
759
795
|
children: /* @__PURE__ */ jsxRuntime.jsx(designSystemIcons.IconChevronRight, {})
|
|
760
796
|
}
|
|
761
797
|
)
|