shelving 1.231.0 → 1.232.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shelving",
3
- "version": "1.231.0",
3
+ "version": "1.232.0",
4
4
  "author": "Dave Houlbrooke <dave@shax.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  .scrollable,
19
19
  .prose [role="region"][tabindex="0"] {
20
20
  overflow-x: auto;
21
- overscroll-behavior-x: contain;
21
+ overscroll-behavior: contain;
22
22
 
23
23
  &:focus-visible {
24
24
  outline: var(--focus-stroke, var(--stroke-thick)) solid var(--focus-color, var(--color-focus));
@@ -20,7 +20,7 @@
20
20
  z-index: 1000;
21
21
  max-height: var(--popover-max-height, 30vh);
22
22
  overflow-y: auto;
23
- overscroll-behavior: none;
23
+ overscroll-behavior: contain;
24
24
  border-radius: var(--popover-radius, var(--radius-xsmall));
25
25
  border: var(--popover-border, var(--stroke-normal)) solid var(--popover-color-border, var(--color-vivid));
26
26
  padding: var(--popover-padding, var(--space-small));
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { requireMetaURL } from "../misc/MetaContext.js";
2
3
  import { getClass } from "../util/css.js";
3
4
  import CENTERED_LAYOUT_CSS from "./CenteredLayout.module.css";
4
5
  import { LAYOUT_CLASS } from "./Layout.js";
@@ -7,5 +8,6 @@ import { LAYOUT_CLASS } from "./Layout.js";
7
8
  * - Used for e.g. login/register/error/form pages where the content is the only focus.
8
9
  */
9
10
  export function CenteredLayout({ children, fullWidth = false }) {
10
- return (_jsx("main", { className: getClass(CENTERED_LAYOUT_CSS.main, LAYOUT_CLASS), children: _jsx("div", { className: CENTERED_LAYOUT_CSS.mainInner, style: fullWidth ? { maxWidth: "none" } : undefined, children: children }) }));
11
+ const { path } = requireMetaURL();
12
+ return (_jsx("main", { className: getClass(CENTERED_LAYOUT_CSS.main, LAYOUT_CLASS), children: _jsx("div", { className: CENTERED_LAYOUT_CSS.mainInner, style: fullWidth ? { maxWidth: "none" } : undefined, children: children }) }, path));
11
13
  }
@@ -1,4 +1,5 @@
1
1
  import type { ReactElement } from "react";
2
+ import { requireMetaURL } from "../misc/MetaContext.js";
2
3
  import { getClass } from "../util/css.js";
3
4
  import type { OptionalChildProps } from "../util/props.js";
4
5
  import CENTERED_LAYOUT_CSS from "./CenteredLayout.module.css";
@@ -13,8 +14,9 @@ export interface CenteredLayoutProps extends OptionalChildProps {
13
14
  * - Used for e.g. login/register/error/form pages where the content is the only focus.
14
15
  */
15
16
  export function CenteredLayout({ children, fullWidth = false }: CenteredLayoutProps): ReactElement {
17
+ const { path } = requireMetaURL();
16
18
  return (
17
- <main className={getClass(CENTERED_LAYOUT_CSS.main, LAYOUT_CLASS)}>
19
+ <main key={path} className={getClass(CENTERED_LAYOUT_CSS.main, LAYOUT_CLASS)}>
18
20
  <div className={CENTERED_LAYOUT_CSS.mainInner} style={fullWidth ? { maxWidth: "none" } : undefined}>
19
21
  {children}
20
22
  </div>
@@ -40,7 +40,6 @@
40
40
  width: 100dvw;
41
41
  overflow: hidden;
42
42
  overflow-wrap: break-word; /* Break overlong words only as a last resort; `anywhere` would also break mid-word to fit narrow table/flex columns. */
43
- overscroll-behavior: none;
44
43
  }
45
44
 
46
45
  body:has(.layout) {
@@ -61,6 +60,7 @@
61
60
  /* Own the page's vertical scroll. */
62
61
  overflow: hidden auto;
63
62
  scroll-behavior: smooth;
64
- overscroll-behavior: none;
63
+ /* `contain` keeps the elastic bounce on the layout itself but stops the scroll chain leaking up to the locked body. */
64
+ overscroll-behavior: contain;
65
65
  }
66
66
  }
@@ -1,9 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/solid";
3
- import { use, useEffect, useState } from "react";
4
- import { useStore } from "../../react/useStore.js";
3
+ import { useEffect, useState } from "react";
5
4
  import { Button } from "../form/Button.js";
6
- import { NavigationContext } from "../router/NavigationContext.js";
5
+ import { requireMetaURL } from "../misc/MetaContext.js";
7
6
  import { getClass } from "../util/css.js";
8
7
  import { LAYOUT_CLASS } from "./Layout.js";
9
8
  import SIDEBAR_LAYOUT_CSS from "./SidebarLayout.module.css";
@@ -16,15 +15,15 @@ import SIDEBAR_LAYOUT_CSS from "./SidebarLayout.module.css";
16
15
  * - Use the `--sidebar-layout-width`, `--sidebar-layout-bg`, `--sidebar-layout-border`, and `--sidebar-layout-color-border` custom properties to override defaults.
17
16
  */
18
17
  export function SidebarLayout({ sidebar, children, right = false }) {
18
+ const { path } = requireMetaURL();
19
19
  const [open, setOpen] = useState(false);
20
20
  // Close the drawer whenever navigation changes the URL — covers tapping a link inside the sidebar.
21
- const href = useStore(use(NavigationContext))?.href;
22
21
  useEffect(() => {
23
- if (href)
22
+ if (path)
24
23
  setOpen(false);
25
- }, [href]);
24
+ }, [path]);
26
25
  const sidebarEl = (_jsx("nav", { className: getClass(SIDEBAR_LAYOUT_CSS.sidebar, open && SIDEBAR_LAYOUT_CSS.open), children: sidebar }, "sidebar"));
27
- const contentEl = (_jsxs("div", { className: getClass(LAYOUT_CLASS, SIDEBAR_LAYOUT_CSS.content), children: [_jsx("div", { className: SIDEBAR_LAYOUT_CSS.toggle, children: _jsx(Button, { fit: true, title: open ? "Close menu" : "Show menu", onClick: () => setOpen(o => !o), children: open ? _jsx(XMarkIcon, {}) : _jsx(Bars3Icon, {}) }) }), _jsx("div", { className: SIDEBAR_LAYOUT_CSS.contentInner, children: children })] }, "content"));
26
+ const contentEl = (_jsxs("div", { className: getClass(LAYOUT_CLASS, SIDEBAR_LAYOUT_CSS.content), children: [_jsx("div", { className: SIDEBAR_LAYOUT_CSS.toggle, children: _jsx(Button, { fit: true, title: open ? "Close menu" : "Show menu", onClick: () => setOpen(o => !o), children: open ? _jsx(XMarkIcon, {}) : _jsx(Bars3Icon, {}) }) }), _jsx("div", { className: SIDEBAR_LAYOUT_CSS.contentInner, children: children })] }, path));
28
27
  const overlayEl = open && (_jsx("button", { type: "button", className: SIDEBAR_LAYOUT_CSS.overlay, "aria-label": "Close menu", onClick: () => setOpen(false) }, "overlay"));
29
28
  return (_jsx("main", { className: getClass(SIDEBAR_LAYOUT_CSS.main, LAYOUT_CLASS), children: right ? [contentEl, sidebarEl, overlayEl] : [sidebarEl, contentEl, overlayEl] }));
30
29
  }
@@ -1,8 +1,7 @@
1
1
  import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/solid";
2
- import { type ReactElement, type ReactNode, use, useEffect, useState } from "react";
3
- import { useStore } from "../../react/useStore.js";
2
+ import { type ReactElement, type ReactNode, useEffect, useState } from "react";
4
3
  import { Button } from "../form/Button.js";
5
- import { NavigationContext } from "../router/NavigationContext.js";
4
+ import { requireMetaURL } from "../misc/MetaContext.js";
6
5
  import { getClass } from "../util/css.js";
7
6
  import type { OptionalChildProps } from "../util/props.js";
8
7
  import { LAYOUT_CLASS } from "./Layout.js";
@@ -24,13 +23,13 @@ export interface SidebarLayoutProps extends OptionalChildProps {
24
23
  * - Use the `--sidebar-layout-width`, `--sidebar-layout-bg`, `--sidebar-layout-border`, and `--sidebar-layout-color-border` custom properties to override defaults.
25
24
  */
26
25
  export function SidebarLayout({ sidebar, children, right = false }: SidebarLayoutProps): ReactElement {
26
+ const { path } = requireMetaURL();
27
27
  const [open, setOpen] = useState(false);
28
28
 
29
29
  // Close the drawer whenever navigation changes the URL — covers tapping a link inside the sidebar.
30
- const href = useStore(use(NavigationContext))?.href;
31
30
  useEffect(() => {
32
- if (href) setOpen(false);
33
- }, [href]);
31
+ if (path) setOpen(false);
32
+ }, [path]);
34
33
 
35
34
  const sidebarEl = (
36
35
  <nav key="sidebar" className={getClass(SIDEBAR_LAYOUT_CSS.sidebar, open && SIDEBAR_LAYOUT_CSS.open)}>
@@ -38,7 +37,7 @@ export function SidebarLayout({ sidebar, children, right = false }: SidebarLayou
38
37
  </nav>
39
38
  );
40
39
  const contentEl = (
41
- <div key="content" className={getClass(LAYOUT_CLASS, SIDEBAR_LAYOUT_CSS.content)}>
40
+ <div key={path} className={getClass(LAYOUT_CLASS, SIDEBAR_LAYOUT_CSS.content)}>
42
41
  <div className={SIDEBAR_LAYOUT_CSS.toggle}>
43
42
  <Button fit title={open ? "Close menu" : "Show menu"} onClick={() => setOpen(o => !o)}>
44
43
  {open ? <XMarkIcon /> : <Bars3Icon />}
@@ -1,6 +1,6 @@
1
1
  import { type ReactElement } from "react";
2
2
  import type { PossibleMeta } from "../util/index.js";
3
- import type { ChildProps, OptionalChildProps } from "../util/props.js";
3
+ import type { OptionalChildProps } from "../util/props.js";
4
4
  export interface NavigationProps extends PossibleMeta, OptionalChildProps {
5
5
  }
6
6
  /**
@@ -15,10 +15,3 @@ export interface NavigationProps extends PossibleMeta, OptionalChildProps {
15
15
  * TODO: switch click/popstate handling to the browser Navigation API when broadly supported.
16
16
  */
17
17
  export declare function Navigation({ children, ...meta }: NavigationProps): ReactElement;
18
- export interface NavigationIsolateProps extends ChildProps {
19
- }
20
- /**
21
- * Force a full remount of children whenever the navigation URL changes.
22
- * - Use to reset stateful sub-trees on navigation.
23
- */
24
- export declare function NavigationIsolate({ children }: NavigationIsolateProps): ReactElement;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Fragment, useEffect } from "react";
2
+ import { useEffect } from "react";
3
3
  import { useInstance } from "../../react/useInstance.js";
4
4
  import { useStore } from "../../react/useStore.js";
5
5
  import { MetaContext, requireMeta } from "../misc/MetaContext.js";
6
- import { NavigationContext, requireNavigation } from "./NavigationContext.js";
6
+ import { NavigationContext } from "./NavigationContext.js";
7
7
  import { NavigationStore } from "./NavigationStore.js";
8
8
  /**
9
9
  * Top-level navigation provider.
@@ -46,11 +46,3 @@ export function Navigation({ children, ...meta }) {
46
46
  }, [nav]);
47
47
  return (_jsx(NavigationContext, { value: nav, children: _jsx(MetaContext, { value: { url: nav.value, root, ...merged }, children: children }) }));
48
48
  }
49
- /**
50
- * Force a full remount of children whenever the navigation URL changes.
51
- * - Use to reset stateful sub-trees on navigation.
52
- */
53
- export function NavigationIsolate({ children }) {
54
- const nav = useStore(requireNavigation());
55
- return _jsx(Fragment, { children: children }, nav.href);
56
- }
@@ -1,10 +1,10 @@
1
- import { Fragment, type ReactElement, useEffect } from "react";
1
+ import { type ReactElement, useEffect } from "react";
2
2
  import { useInstance } from "../../react/useInstance.js";
3
3
  import { useStore } from "../../react/useStore.js";
4
4
  import { MetaContext, requireMeta } from "../misc/MetaContext.js";
5
5
  import type { PossibleMeta } from "../util/index.js";
6
- import type { ChildProps, OptionalChildProps } from "../util/props.js";
7
- import { NavigationContext, requireNavigation } from "./NavigationContext.js";
6
+ import type { OptionalChildProps } from "../util/props.js";
7
+ import { NavigationContext } from "./NavigationContext.js";
8
8
  import { NavigationStore } from "./NavigationStore.js";
9
9
 
10
10
  export interface NavigationProps extends PossibleMeta, OptionalChildProps {}
@@ -59,14 +59,3 @@ export function Navigation({ children, ...meta }: NavigationProps): ReactElement
59
59
  </NavigationContext>
60
60
  );
61
61
  }
62
-
63
- export interface NavigationIsolateProps extends ChildProps {}
64
-
65
- /**
66
- * Force a full remount of children whenever the navigation URL changes.
67
- * - Use to reset stateful sub-trees on navigation.
68
- */
69
- export function NavigationIsolate({ children }: NavigationIsolateProps): ReactElement {
70
- const nav = useStore(requireNavigation());
71
- return <Fragment key={nav.href}>{children}</Fragment>;
72
- }
@@ -41,7 +41,7 @@ function _matchRoute(routes, fallback, meta, path = meta.path, depth = 0) {
41
41
  if (typeof Route !== "function")
42
42
  return Route;
43
43
  // Component — render with merged URL query params and route placeholders as props (placeholders win on conflict).
44
- _jsx(Route, { ...meta.params, ...placeholders }, path);
44
+ return _jsx(Route, { ...meta.params, ...placeholders }, path);
45
45
  }
46
46
  // No match, try the fallback.
47
47
  if (fallback !== undefined)
@@ -61,7 +61,7 @@ function _matchRoute(
61
61
  if (typeof Route !== "function") return Route;
62
62
 
63
63
  // Component — render with merged URL query params and route placeholders as props (placeholders win on conflict).
64
- <Route key={path} {...meta.params} {...placeholders} />;
64
+ return <Route key={path} {...meta.params} {...placeholders} />;
65
65
  }
66
66
 
67
67
  // No match, try the fallback.