@asymmetric-effort/specifyjs 1.2.3 → 1.3.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.
@@ -14,6 +14,7 @@ import {
14
14
  useContext,
15
15
  useEffect,
16
16
  useId,
17
+ useMediaQuery,
17
18
  useMemo,
18
19
  useReducer,
19
20
  useRef,
@@ -5737,35 +5738,85 @@ function VideoPlayer(props) {
5737
5738
  }
5738
5739
 
5739
5740
  // ../components/nav/wrapper/src/NavWrapper.ts
5741
+ var HAMBURGER_STYLE = {
5742
+ display: "flex",
5743
+ alignItems: "center",
5744
+ justifyContent: "center",
5745
+ width: "44px",
5746
+ height: "44px",
5747
+ border: "none",
5748
+ background: "transparent",
5749
+ cursor: "pointer",
5750
+ fontSize: "24px",
5751
+ color: "inherit",
5752
+ flexShrink: "0",
5753
+ borderRadius: "4px",
5754
+ WebkitTapHighlightColor: "transparent",
5755
+ padding: "0",
5756
+ marginLeft: "auto"
5757
+ };
5740
5758
  function NavWrapper(props) {
5741
5759
  const orientation = props.orientation ?? "vertical";
5742
5760
  const role = props.role ?? "navigation";
5743
5761
  const keyboardNav = props.keyboardNav ?? true;
5744
5762
  const s = props.styling ?? {};
5745
5763
  const containerRef = useRef(null);
5746
- const style = {
5764
+ const [mobileOpen, setMobileOpen] = useState(false);
5765
+ const isMobile = useMediaQuery("(max-width: 767px)");
5766
+ const needsHamburger = orientation === "horizontal" && isMobile;
5767
+ useEffect(() => {
5768
+ if (!isMobile && mobileOpen) {
5769
+ setMobileOpen(false);
5770
+ }
5771
+ }, [isMobile, mobileOpen]);
5772
+ const toggleMenu = useCallback(
5773
+ ((..._args) => setMobileOpen((prev) => !prev)),
5774
+ []
5775
+ );
5776
+ const handleMenuKeyDown = useCallback(
5777
+ (e) => {
5778
+ const ke = e;
5779
+ if (ke.key === "Escape" && mobileOpen) {
5780
+ ke.preventDefault();
5781
+ setMobileOpen(false);
5782
+ }
5783
+ },
5784
+ [mobileOpen]
5785
+ );
5786
+ const bgColor = s.backgroundColor ?? "var(--color-bg, #ffffff)";
5787
+ const textColor = s.color ?? "var(--color-text, #1f2937)";
5788
+ const borderColor = s.border ?? "1px solid var(--color-border, #e5e7eb)";
5789
+ const baseStyle = {
5747
5790
  display: "flex",
5748
- flexDirection: orientation === "horizontal" ? "row" : "column",
5749
- backgroundColor: s.backgroundColor ?? "#ffffff",
5750
- color: s.color ?? "#1f2937",
5791
+ flexDirection: needsHamburger ? "row" : orientation === "horizontal" ? "row" : "column",
5792
+ flexWrap: needsHamburger ? "wrap" : "nowrap",
5793
+ alignItems: needsHamburger ? "center" : "stretch",
5794
+ position: "relative",
5795
+ backgroundColor: bgColor,
5796
+ color: textColor,
5751
5797
  fontFamily: s.fontFamily ?? "inherit",
5752
5798
  fontSize: s.fontSize ?? "14px",
5753
- border: s.border ?? "1px solid #e5e7eb",
5799
+ border: borderColor,
5754
5800
  borderRadius: s.borderRadius ?? "8px",
5755
5801
  padding: s.padding ?? "0",
5756
5802
  width: typeof s.width === "number" ? `${s.width}px` : s.width ?? "auto",
5757
- overflow: "auto",
5803
+ overflow: needsHamburger ? "visible" : "auto",
5758
5804
  boxSizing: "border-box",
5759
5805
  listStyle: "none",
5760
5806
  margin: "0",
5761
5807
  ...s.boxShadow ? { boxShadow: s.boxShadow } : {},
5762
- ...s.maxHeight ? { maxHeight: typeof s.maxHeight === "number" ? `${s.maxHeight}px` : s.maxHeight } : {},
5808
+ ...s.maxHeight && !needsHamburger ? { maxHeight: typeof s.maxHeight === "number" ? `${s.maxHeight}px` : String(s.maxHeight) } : {},
5763
5809
  ...s.custom ?? {}
5764
5810
  };
5765
5811
  const handleKeyDown = useCallback(
5766
5812
  (e) => {
5767
5813
  if (!keyboardNav) return;
5768
5814
  const ke = e;
5815
+ if (ke.key === "Escape" && mobileOpen) {
5816
+ ke.preventDefault();
5817
+ setMobileOpen(false);
5818
+ return;
5819
+ }
5769
5820
  const container = containerRef.current;
5770
5821
  if (!container) return;
5771
5822
  const focusable = Array.from(
@@ -5775,7 +5826,8 @@ function NavWrapper(props) {
5775
5826
  );
5776
5827
  const idx = focusable.indexOf(document.activeElement);
5777
5828
  if (idx < 0) return;
5778
- const isVert = orientation === "vertical";
5829
+ const effectiveOrientation = needsHamburger ? "vertical" : orientation;
5830
+ const isVert = effectiveOrientation === "vertical";
5779
5831
  const nextKey = isVert ? "ArrowDown" : "ArrowRight";
5780
5832
  const prevKey = isVert ? "ArrowUp" : "ArrowLeft";
5781
5833
  if (ke.key === nextKey) {
@@ -5794,8 +5846,63 @@ function NavWrapper(props) {
5794
5846
  focusable[focusable.length - 1]?.focus();
5795
5847
  }
5796
5848
  },
5797
- [keyboardNav, orientation]
5849
+ [keyboardNav, orientation, needsHamburger, mobileOpen]
5798
5850
  );
5851
+ const dropdownStyle2 = {
5852
+ display: mobileOpen ? "flex" : "none",
5853
+ flexDirection: "column",
5854
+ position: "absolute",
5855
+ top: "100%",
5856
+ left: "0",
5857
+ right: "0",
5858
+ backgroundColor: bgColor,
5859
+ borderBottom: borderColor,
5860
+ borderLeft: borderColor,
5861
+ borderRight: borderColor,
5862
+ borderRadius: "0 0 8px 8px",
5863
+ padding: "8px 0",
5864
+ zIndex: "99",
5865
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.1)",
5866
+ transition: "opacity 0.2s ease, transform 0.2s ease",
5867
+ opacity: mobileOpen ? "1" : "0",
5868
+ transform: mobileOpen ? "translateY(0)" : "translateY(-8px)"
5869
+ };
5870
+ if (needsHamburger) {
5871
+ return createElement(
5872
+ "nav",
5873
+ {
5874
+ ref: containerRef,
5875
+ role,
5876
+ "aria-label": props.ariaLabel ?? void 0,
5877
+ className: `nav-wrapper ${props.className ?? ""}`.trim(),
5878
+ style: baseStyle,
5879
+ onKeyDown: handleKeyDown
5880
+ },
5881
+ // Hamburger toggle button
5882
+ createElement(
5883
+ "button",
5884
+ {
5885
+ type: "button",
5886
+ style: HAMBURGER_STYLE,
5887
+ onClick: toggleMenu,
5888
+ "aria-label": mobileOpen ? "Close menu" : "Open menu",
5889
+ "aria-expanded": String(mobileOpen),
5890
+ "aria-controls": "nav-wrapper-dropdown"
5891
+ },
5892
+ mobileOpen ? "\u2715" : "\u2630"
5893
+ ),
5894
+ // Dropdown panel (children rendered vertically)
5895
+ createElement(
5896
+ "div",
5897
+ {
5898
+ id: "nav-wrapper-dropdown",
5899
+ role: "menu",
5900
+ style: dropdownStyle2
5901
+ },
5902
+ props.children
5903
+ )
5904
+ );
5905
+ }
5799
5906
  return createElement(
5800
5907
  "nav",
5801
5908
  {
@@ -5804,7 +5911,7 @@ function NavWrapper(props) {
5804
5911
  "aria-label": props.ariaLabel ?? void 0,
5805
5912
  "aria-orientation": orientation,
5806
5913
  className: `nav-wrapper ${props.className ?? ""}`.trim(),
5807
- style,
5914
+ style: baseStyle,
5808
5915
  onKeyDown: handleKeyDown
5809
5916
  },
5810
5917
  props.children
@@ -5817,8 +5924,8 @@ function buildNavItemStyle(s, state) {
5817
5924
  padding: s.padding ?? "10px 16px",
5818
5925
  cursor: s.cursor ?? "pointer",
5819
5926
  transition: s.transition ?? "background-color 0.15s",
5820
- backgroundColor: state.active ? s.activeBackground ?? "#eff6ff" : state.hover ? s.hoverBackground ?? "#f3f4f6" : "transparent",
5821
- color: state.active ? s.activeColor ?? "#2563eb" : "inherit",
5927
+ backgroundColor: state.active ? s.activeBackground ?? "var(--color-active, #eff6ff)" : state.hover ? s.hoverBackground ?? "var(--color-hover, #f3f4f6)" : "transparent",
5928
+ color: state.active ? s.activeColor ?? "var(--color-primary, #2563eb)" : "inherit",
5822
5929
  border: "none",
5823
5930
  outline: "none",
5824
5931
  width: "100%",