@iyulab/desktop-patterns 0.10.1 → 0.11.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/README.md CHANGED
@@ -87,6 +87,11 @@ collapsed rail (`dp-sidebar` `collapsed`). Give the toggle `expanded` so assisti
87
87
  which state it is in. The consumer owns both states — start the drawer closed, close it when the
88
88
  shell asks (backdrop click, Escape) and when a place is picked, or a narrow window stays covered.
89
89
 
90
+ The shell holds the window's height, so the document never scrolls — the main content box does.
91
+ Anything that saves and restores where the user was reading reaches that box through
92
+ `shell.mainElement`; with `@iyulab/router`, hand it to the router's scroll restoration:
93
+ `scrollRestoration: { container: () => document.querySelector('dp-shell')?.mainElement }`.
94
+
90
95
  ### A list beside the item picked from it
91
96
 
92
97
  ```html
@@ -35,6 +35,13 @@ export declare class DpShell extends LitElement {
35
35
  * place is picked in the drawer.
36
36
  */
37
37
  sidebarOpen: boolean;
38
+ /**
39
+ * The box that scrolls the main content. The shell holds the window's height, so the document
40
+ * never scrolls — this box does. Code that saves and restores where the user was reading (a
41
+ * router's scroll restoration, for one) reads and writes its `scrollTop`. It sits in the shadow
42
+ * root, so this is the supported way to reach it. `null` until the first render.
43
+ */
44
+ get mainElement(): HTMLElement | null;
38
45
  private readonly onKeydown;
39
46
  connectedCallback(): void;
40
47
  disconnectedCallback(): void;
package/dist/shell.js CHANGED
@@ -103,6 +103,9 @@ var c = class extends Event {
103
103
  }
104
104
  `;
105
105
  }
106
+ get mainElement() {
107
+ return this.shadowRoot?.querySelector("main") ?? null;
108
+ }
106
109
  connectedCallback() {
107
110
  super.connectedCallback(), document.addEventListener("keydown", this.onKeydown);
108
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iyulab/desktop-patterns",
3
- "version": "0.10.1",
3
+ "version": "0.11.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -82,10 +82,10 @@
82
82
  "lit": "^3.3.3"
83
83
  },
84
84
  "peerDependencies": {
85
- "@iyulab/desktop-compact": "^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0"
85
+ "@iyulab/desktop-compact": "^0.2.0 || ^0.3.0 || ^0.4.0 || ^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0"
86
86
  },
87
87
  "devDependencies": {
88
- "@iyulab/desktop-compact": "^0.12.0",
88
+ "@iyulab/desktop-compact": "^0.13.0",
89
89
  "@open-wc/testing": "^5.0.0",
90
90
  "@storybook/web-components": "^10.6.0",
91
91
  "@storybook/web-components-vite": "^10.6.0",