@getflip/swirl-components 0.116.0 → 0.117.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.
Files changed (107) hide show
  1. package/components.json +371 -69
  2. package/dist/cjs/focus-trap.esm-21561e09.js +1145 -0
  3. package/dist/cjs/index-506fe4ea.js +14 -26
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/swirl-app-bar.cjs.entry.js +2 -1
  6. package/dist/cjs/swirl-app-icon.cjs.entry.js +1 -3
  7. package/dist/cjs/swirl-app-layout_6.cjs.entry.js +1 -1
  8. package/dist/cjs/swirl-badge.cjs.entry.js +1 -1
  9. package/dist/cjs/swirl-components.cjs.js +1 -1
  10. package/dist/cjs/swirl-icon-arrow-back_5.cjs.entry.js +87 -0
  11. package/dist/cjs/swirl-icon-dock-left.cjs.entry.js +23 -0
  12. package/dist/cjs/swirl-modal.cjs.entry.js +2 -1143
  13. package/dist/cjs/swirl-shell-layout.cjs.entry.js +87 -75
  14. package/dist/cjs/swirl-shell-navigation-item.cjs.entry.js +1 -1
  15. package/dist/cjs/swirl-visually-hidden.cjs.entry.js +1 -1
  16. package/dist/collection/assets/pdfjs/pdf.worker.min.js +1 -1
  17. package/dist/collection/collection-manifest.json +1 -0
  18. package/dist/collection/components/swirl-app-bar/swirl-app-bar.js +20 -1
  19. package/dist/collection/components/swirl-app-icon/swirl-app-icon.css +3 -22
  20. package/dist/collection/components/swirl-app-icon/swirl-app-icon.js +0 -20
  21. package/dist/collection/components/swirl-app-layout/swirl-app-layout.css +38 -4
  22. package/dist/collection/components/swirl-badge/swirl-badge.css +18 -1
  23. package/dist/collection/components/swirl-badge/swirl-badge.js +1 -1
  24. package/dist/collection/components/swirl-icon/icons/swirl-icon-dock-left.js +52 -0
  25. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.css +353 -132
  26. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.js +322 -95
  27. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.spec.js +8 -58
  28. package/dist/collection/components/swirl-shell-layout/swirl-shell-layout.stories.js +81 -102
  29. package/dist/collection/components/swirl-shell-navigation-item/swirl-shell-navigation-item.css +46 -35
  30. package/dist/collection/components/swirl-visually-hidden/swirl-visually-hidden.js +1 -1
  31. package/dist/collection/components/swirl-visually-hidden/swirl-visually-hidden.spec.js +0 -3
  32. package/dist/components/assets/images/flip-logo.png +0 -0
  33. package/dist/components/assets/pdfjs/pdf.worker.min.js +1 -1
  34. package/dist/components/focus-trap.esm.js +1143 -0
  35. package/dist/components/swirl-app-bar.js +3 -1
  36. package/dist/components/swirl-app-icon.js +1 -4
  37. package/dist/components/swirl-app-layout2.js +1 -1
  38. package/dist/components/swirl-badge2.js +1 -1
  39. package/dist/components/swirl-icon-arrow-back.js +1 -35
  40. package/dist/{esm/swirl-icon-arrow-back.entry.js → components/swirl-icon-arrow-back2.js} +26 -8
  41. package/dist/components/swirl-icon-arrow-forward.js +1 -35
  42. package/dist/{esm/swirl-icon-arrow-forward.entry.js → components/swirl-icon-arrow-forward2.js} +26 -8
  43. package/dist/components/swirl-icon-dock-left.d.ts +11 -0
  44. package/dist/components/swirl-icon-dock-left.js +40 -0
  45. package/dist/components/swirl-icon-double-arrow-left.js +1 -35
  46. package/dist/{esm/swirl-icon-double-arrow-left.entry.js → components/swirl-icon-double-arrow-left2.js} +26 -8
  47. package/dist/components/swirl-icon-double-arrow-right.js +1 -35
  48. package/dist/{esm/swirl-icon-double-arrow-right.entry.js → components/swirl-icon-double-arrow-right2.js} +26 -8
  49. package/dist/components/swirl-icon-menu.js +1 -35
  50. package/dist/{esm/swirl-icon-menu.entry.js → components/swirl-icon-menu2.js} +26 -8
  51. package/dist/components/swirl-modal.js +1 -1142
  52. package/dist/components/swirl-shell-layout.js +150 -89
  53. package/dist/components/swirl-shell-navigation-item.js +1 -1
  54. package/dist/components/swirl-visually-hidden2.js +2 -3
  55. package/dist/esm/focus-trap.esm-37cd2d2b.js +1143 -0
  56. package/dist/esm/index-99d0060d.js +14 -26
  57. package/dist/esm/loader.js +1 -1
  58. package/dist/esm/swirl-app-bar.entry.js +2 -1
  59. package/dist/esm/swirl-app-icon.entry.js +1 -3
  60. package/dist/esm/swirl-app-layout_6.entry.js +1 -1
  61. package/dist/esm/swirl-badge.entry.js +1 -1
  62. package/dist/esm/swirl-components.js +1 -1
  63. package/dist/esm/swirl-icon-arrow-back_5.entry.js +79 -0
  64. package/dist/esm/swirl-icon-dock-left.entry.js +19 -0
  65. package/dist/esm/swirl-modal.entry.js +1 -1142
  66. package/dist/esm/swirl-shell-layout.entry.js +88 -76
  67. package/dist/esm/swirl-shell-navigation-item.entry.js +1 -1
  68. package/dist/esm/swirl-visually-hidden.entry.js +1 -1
  69. package/dist/swirl-components/p-08fd60a5.entry.js +1 -0
  70. package/dist/swirl-components/p-0ac2eb84.entry.js +1 -0
  71. package/dist/swirl-components/p-11c6c9ba.entry.js +1 -0
  72. package/dist/swirl-components/p-25b4973d.entry.js +1 -0
  73. package/dist/swirl-components/p-262771e5.entry.js +1 -0
  74. package/dist/swirl-components/p-3795fbb4.entry.js +1 -0
  75. package/dist/swirl-components/p-40ee5f22.entry.js +1 -0
  76. package/dist/swirl-components/p-4a69e7f3.entry.js +1 -0
  77. package/dist/swirl-components/p-76c36ee9.entry.js +1 -0
  78. package/dist/swirl-components/p-7c4a4b66.entry.js +1 -0
  79. package/dist/swirl-components/p-c2e1dfdb.js +10 -0
  80. package/dist/swirl-components/swirl-components.esm.js +1 -1
  81. package/dist/types/components/swirl-app-bar/swirl-app-bar.d.ts +1 -0
  82. package/dist/types/components/swirl-app-icon/swirl-app-icon.d.ts +0 -1
  83. package/dist/types/components/swirl-badge/swirl-badge.d.ts +1 -1
  84. package/dist/types/components/swirl-icon/icons/swirl-icon-dock-left.d.ts +5 -0
  85. package/dist/types/components/swirl-shell-layout/swirl-shell-layout.d.ts +42 -25
  86. package/dist/types/components.d.ts +50 -11
  87. package/icons.json +1 -1
  88. package/package.json +2 -2
  89. package/vscode-data.json +58 -6
  90. package/dist/cjs/swirl-icon-arrow-back.cjs.entry.js +0 -23
  91. package/dist/cjs/swirl-icon-arrow-forward.cjs.entry.js +0 -23
  92. package/dist/cjs/swirl-icon-double-arrow-left.cjs.entry.js +0 -23
  93. package/dist/cjs/swirl-icon-double-arrow-right.cjs.entry.js +0 -23
  94. package/dist/cjs/swirl-icon-menu.cjs.entry.js +0 -23
  95. package/dist/swirl-components/p-3a2abee9.entry.js +0 -1
  96. package/dist/swirl-components/p-441c8210.entry.js +0 -1
  97. package/dist/swirl-components/p-4a84e63d.entry.js +0 -1
  98. package/dist/swirl-components/p-54e4ff0b.entry.js +0 -1
  99. package/dist/swirl-components/p-5da3a9a8.entry.js +0 -1
  100. package/dist/swirl-components/p-645a878c.entry.js +0 -1
  101. package/dist/swirl-components/p-79be22ea.entry.js +0 -10
  102. package/dist/swirl-components/p-97668c59.entry.js +0 -1
  103. package/dist/swirl-components/p-be2cf7ee.entry.js +0 -1
  104. package/dist/swirl-components/p-c4d4a99d.entry.js +0 -1
  105. package/dist/swirl-components/p-ca78767e.entry.js +0 -1
  106. package/dist/swirl-components/p-d2fc7935.entry.js +0 -1
  107. package/dist/swirl-components/p-f83a0b0f.entry.js +0 -1
@@ -1,110 +1,117 @@
1
- import { h, Host } from "@stencil/core";
1
+ import { h, Host, } from "@stencil/core";
2
2
  import classnames from "classnames";
3
- import { getDesktopMediaQuery, getActiveElement } from "../../utils";
3
+ import * as focusTrap from "focus-trap";
4
+ const NAVIGATION_COLLAPSE_STORAGE_KEY = "SWIRL_SHELL_NAVIGATION_COLLAPSE_STATE";
5
+ const SIDEBAR_STORAGE_KEY = "SWIRL_SHELL_SIDEBAR_STATE";
4
6
  /**
5
- * @slot logo-expanded - Logo shown inside expanded sidebar.
6
- * @slot logo-collapsed - Logo shown inside collapsed sidebar.
7
- * @slot tools - Items shown in the upper sidebar part.
8
- * @slot main-navigation - Items shown in the lower sidebar part.
9
- * @slot banner - Used to show a swirl-banner on top of the page.
10
- * @slot main - Contents of the main area.
7
+ * @slot logo - Logo shown inside header.
8
+ * @slot header-tools - Tools positioned on the header's right-hand side.
9
+ * @slot mobile-header-tools - Tools positioned in the mobile drawer header.
10
+ * @slot nav - Items shown in the lower sidebar part.
11
+ * @slot mobile-logo - Logo shown inside the mobile navigation drawer.
12
+ * @slot default - Contents of the main area.
13
+ * @slot sidebar-app-bar - Contents of the right sidebar header.
14
+ * @slot sidebar - Contents of the right sidebar.
11
15
  */
12
16
  export class SwirlShellLayout {
13
17
  constructor() {
14
- this.desktopMediaQuery = getDesktopMediaQuery();
15
- this.desktopMediaQueryHandler = (event) => {
16
- if (event.matches) {
17
- this.expandLeftSidebar();
18
- }
19
- else {
20
- this.collapseLeftSidebar();
21
- }
22
- };
23
- this.collapseLeftSidebar = () => {
24
- this.collapsedSidebar = true;
25
- this.collapsing = true;
26
- setTimeout(() => {
27
- this.collapsing = false;
28
- // Some browsers don't update the hovered state of an element correctly,
29
- // if the element was moved and is no longer underneath the cursor.
30
- // https://bugs.chromium.org/p/chromium/issues/detail?id=276329
31
- this.sidebarHovered = false;
32
- }, 200);
33
- };
34
- this.expandLeftSidebar = () => {
35
- if (this.hideSidebar) {
36
- return;
37
- }
38
- this.collapsedSidebar = false;
39
- };
40
- this.toggleSidebar = () => {
41
- if (this.collapsedSidebar) {
42
- this.expandLeftSidebar();
43
- }
44
- else {
45
- this.collapseLeftSidebar();
46
- }
47
- };
48
- this.onBackdropClick = () => {
49
- if (!this.collapsedSidebar) {
50
- this.collapseLeftSidebar();
51
- }
18
+ this.onBrowserBackClick = () => {
19
+ history.back();
52
20
  };
53
- this.onSidebarClick = () => {
54
- if (this.collapsedSidebar) {
55
- document.activeElement?.blur();
56
- getActiveElement()?.blur();
57
- }
21
+ this.onBrowserForwardClick = () => {
22
+ history.forward();
58
23
  };
59
- this.onSidebarMouseEnter = () => {
60
- this.sidebarHovered = true;
24
+ this.onNavigationToggleClick = () => {
25
+ this.navigationCollapsed = !this.navigationCollapsed;
61
26
  };
62
- this.onSidebarMouseLeave = () => {
63
- this.sidebarHovered = false;
27
+ this.onNavigationClick = () => {
28
+ this.hideMobileNavigation();
64
29
  };
65
- this.hideSidebar = undefined;
66
- this.mainNavigationLabel = "Main";
30
+ this.brandedHeader = undefined;
31
+ this.browserBackButtonLabel = "Navigate back";
32
+ this.browserForwardButtonLabel = "Navigate forward";
33
+ this.hideMobileNavigationButtonLabel = "Close navigation";
34
+ this.navigationLabel = "Main";
35
+ this.navigationToggleLabel = "Toggle navigation";
36
+ this.sidebarActive = undefined;
37
+ this.sidebarToggleBadge = undefined;
38
+ this.sidebarToggleBadgeAriaLabel = undefined;
39
+ this.sidebarToggleIcon = "notifications";
67
40
  this.sidebarToggleLabel = "Toggle sidebar";
68
- this.collapsedSidebar = undefined;
69
- this.collapsing = undefined;
70
- this.sidebarHovered = undefined;
41
+ this.skipLinkLabel = "Skip to main content";
42
+ this.mobileNavigationActive = undefined;
43
+ this.navigationCollapsed = undefined;
71
44
  }
72
45
  componentWillLoad() {
73
- if (!this.desktopMediaQuery.matches) {
74
- this.collapseLeftSidebar();
46
+ const restoredSidebarState = localStorage.getItem(SIDEBAR_STORAGE_KEY) === "true";
47
+ this.sidebarActive =
48
+ this.sidebarActive === undefined
49
+ ? restoredSidebarState
50
+ : this.sidebarActive;
51
+ const restoredNavigationCollapseState = localStorage.getItem(NAVIGATION_COLLAPSE_STORAGE_KEY) === "true";
52
+ this.navigationCollapsed = restoredNavigationCollapseState;
53
+ }
54
+ componentDidLoad() {
55
+ this.focusTrap = focusTrap.createFocusTrap(this.navElement, {
56
+ allowOutsideClick: true,
57
+ tabbableOptions: {
58
+ getShadowRoot: (node) => {
59
+ return node.shadowRoot;
60
+ },
61
+ },
62
+ });
63
+ }
64
+ componentDidRender() {
65
+ this.focusTrap?.updateContainerElements(this.navElement);
66
+ }
67
+ disconnectedCallback() {
68
+ this.focusTrap?.deactivate();
69
+ }
70
+ onWindowKeyDown(event) {
71
+ if (event.key === "Escape" && this.mobileNavigationActive) {
72
+ this.hideMobileNavigation();
75
73
  }
76
- this.desktopMediaQuery.onchange = this.desktopMediaQueryHandler;
74
+ }
75
+ watchMobileNavigationState() {
76
+ if (this.mobileNavigationActive) {
77
+ // wait for animation
78
+ setTimeout(() => {
79
+ this.focusTrap.activate();
80
+ }, 200);
81
+ }
82
+ else {
83
+ this.focusTrap.deactivate();
84
+ }
85
+ }
86
+ watchNavigationCollapsed() {
87
+ localStorage.setItem(NAVIGATION_COLLAPSE_STORAGE_KEY, String(this.navigationCollapsed));
88
+ }
89
+ watchSidebarActive() {
90
+ localStorage.setItem(SIDEBAR_STORAGE_KEY, String(this.sidebarActive));
77
91
  }
78
92
  /**
79
- * Collapse the left sidebar.
93
+ * Opens the mobile navigation.
80
94
  */
81
- async collapseSidebar() {
82
- this.collapseLeftSidebar();
95
+ async showMobileNavigation() {
96
+ this.mobileNavigationActive = true;
83
97
  }
84
98
  /**
85
- * Extend the left sidebar.
99
+ * Hides the mobile navigation.
86
100
  */
87
- async extendSidebar() {
88
- this.expandLeftSidebar();
101
+ async hideMobileNavigation() {
102
+ this.mobileNavigationActive = false;
89
103
  }
90
104
  render() {
91
105
  const className = classnames("shell-layout", {
92
- "shell-layout--collapsed-sidebar": this.collapsedSidebar,
93
- "shell-layout--collapsing": this.collapsing,
94
- "shell-layout--hide-sidebar": this.hideSidebar,
106
+ "shell-layout--branded-header": this.brandedHeader,
107
+ "shell-layout--mobile-navigation-active": this.mobileNavigationActive,
108
+ "shell-layout--navigation-collapsed": this.navigationCollapsed,
109
+ "shell-layout--sidebar-active": this.sidebarActive,
95
110
  });
96
- const sidebarWrapperClassName = classnames("shell-layout__sidebar-wrapper", {
97
- "shell-layout__sidebar-wrapper--hovered": this.sidebarHovered,
98
- });
99
- const backdropClassName = classnames("shell-layout__backdrop", {
100
- "shell-layout__backdrop--fading": this.collapsing,
101
- });
102
- return (h(Host, null, h("div", { class: className }, h("div", { class: "shell-layout__banner" }, h("slot", { name: "banner" })), h("div", { class: sidebarWrapperClassName, onClick: this.onSidebarClick, onMouseEnter: this.onSidebarMouseEnter, onMouseLeave: this.onSidebarMouseLeave }, !this.hideSidebar && (h("div", { class: "shell-layout__sidebar" }, h("header", { class: "shell-layout__header" }, h("div", { class: "shell-layout__logo-bar" }, h("div", { class: "shell-layout__expanded-logo" }, h("slot", { name: "logo-expanded" })), h("div", { class: "shell-layout__collapsed-logo" }, h("slot", { name: "logo-collapsed" })), h("div", { class: "shell-layout__toggle" }, h("swirl-button", { swirlAriaExpanded: String(!this.collapsedSidebar), hideLabel: true, icon: this.collapsedSidebar
103
- ? "<swirl-icon-double-arrow-right></swirl-icon-double-arrow-right>"
104
- : "<swirl-icon-double-arrow-left></swirl-icon-double-arrow-left>", label: this.sidebarToggleLabel, onClick: this.toggleSidebar }))), h("div", { class: "shell-layout__tools" }, h("slot", { name: "tools" }))), h("nav", { "aria-label": this.mainNavigationLabel, class: "shell-layout__main-navigation" }, h("slot", { name: "main-navigation" }))))), h("main", { class: "shell-layout__main" }, h("slot", { name: "main" })), (!this.collapsedSidebar || this.collapsing) && (h("div", { class: backdropClassName, onClick: this.onBackdropClick })))));
111
+ return (h(Host, null, h("div", { class: className }, h("header", { class: "shell-layout__header", "data-tauri-drag-region": "true" }, h("button", { class: "shell-layout__skip-link", onClick: this.skipLinkClick.emit, type: "button" }, this.skipLinkLabel), h("div", { class: "shell-layout__header-left" }, h("button", { class: "shell-layout__header-tool shell-layout__navigation-toggle", onClick: this.onNavigationToggleClick, type: "button" }, h("swirl-icon-menu", { size: 20 }), h("swirl-icon-double-arrow-left", { size: 20 }), h("swirl-icon-double-arrow-right", { size: 20 }), h("swirl-visually-hidden", null, this.navigationToggleLabel)), h("button", { class: "shell-layout__header-tool", onClick: this.onBrowserBackClick, type: "button" }, h("swirl-icon-arrow-back", { size: 20 }), h("swirl-visually-hidden", null, this.browserBackButtonLabel)), h("button", { class: "shell-layout__header-tool", onClick: this.onBrowserForwardClick, type: "button" }, h("swirl-icon-arrow-forward", { size: 20 }), h("swirl-visually-hidden", null, this.browserForwardButtonLabel))), h("div", { class: "shell-layout__logo" }, h("slot", { name: "logo" })), h("div", { class: "shell-layout__header-right" }, h("button", { class: "shell-layout__header-tool shell-layout__sidebar-toggle", onClick: this.sidebarToggleClick.emit, type: "button" }, h("swirl-icon", { glyph: this.sidebarToggleIcon, size: 20 }), h("swirl-visually-hidden", null, this.sidebarToggleLabel), this.sidebarToggleBadge && (h("swirl-badge", { "aria-label": this.sidebarToggleBadgeAriaLabel, label: this.sidebarToggleBadge, size: "xs" }))), h("slot", { name: "header-tools" }))), h("div", { class: "shell-layout__mobile-nav-backdrop", onClick: this.onNavigationClick }), h("nav", { "aria-labelledby": "main-navigation-label", class: "shell-layout__nav", onClick: this.onNavigationClick, ref: (el) => (this.navElement = el) }, h("div", { class: "shell-layout__mobile-header" }, h("slot", { name: "mobile-logo" }), h("div", { class: "shell-layout__mobile-header-tools" }, h("slot", { name: "mobile-header-tools" }), h("button", { class: "shell-layout__header-tool", type: "button" }, h("swirl-icon-double-arrow-left", { size: 20 }), h("swirl-visually-hidden", null, this.hideMobileNavigationButtonLabel)))), h("div", { class: "shell-layout__nav-body" }, h("swirl-visually-hidden", null, h("span", { id: "main-navigation-label" }, this.navigationLabel)), h("slot", { name: "nav" }))), h("main", { class: "shell-layout__main", id: "main-content" }, h("slot", null)), h("aside", { class: "shell-layout__sidebar" }, h("div", { class: "shell-layout__sidebar-body" }, h("div", { class: "shell-layout__sidebar-app-bar" }, h("slot", { name: "sidebar-app-bar" })), h("div", { class: "shell-layout__sidebar-content" }, h("slot", { name: "sidebar" })))))));
105
112
  }
106
113
  static get is() { return "swirl-shell-layout"; }
107
- static get encapsulation() { return "shadow"; }
114
+ static get encapsulation() { return "scoped"; }
108
115
  static get originalStyleUrls() {
109
116
  return {
110
117
  "$": ["swirl-shell-layout.css"]
@@ -117,7 +124,7 @@ export class SwirlShellLayout {
117
124
  }
118
125
  static get properties() {
119
126
  return {
120
- "hideSidebar": {
127
+ "brandedHeader": {
121
128
  "type": "boolean",
122
129
  "mutable": false,
123
130
  "complexType": {
@@ -131,10 +138,10 @@ export class SwirlShellLayout {
131
138
  "tags": [],
132
139
  "text": ""
133
140
  },
134
- "attribute": "hide-sidebar",
141
+ "attribute": "branded-header",
135
142
  "reflect": false
136
143
  },
137
- "mainNavigationLabel": {
144
+ "browserBackButtonLabel": {
138
145
  "type": "string",
139
146
  "mutable": false,
140
147
  "complexType": {
@@ -143,15 +150,156 @@ export class SwirlShellLayout {
143
150
  "references": {}
144
151
  },
145
152
  "required": false,
146
- "optional": false,
153
+ "optional": true,
147
154
  "docs": {
148
155
  "tags": [],
149
156
  "text": ""
150
157
  },
151
- "attribute": "main-navigation-label",
158
+ "attribute": "browser-back-button-label",
159
+ "reflect": false,
160
+ "defaultValue": "\"Navigate back\""
161
+ },
162
+ "browserForwardButtonLabel": {
163
+ "type": "string",
164
+ "mutable": false,
165
+ "complexType": {
166
+ "original": "string",
167
+ "resolved": "string",
168
+ "references": {}
169
+ },
170
+ "required": false,
171
+ "optional": true,
172
+ "docs": {
173
+ "tags": [],
174
+ "text": ""
175
+ },
176
+ "attribute": "browser-forward-button-label",
177
+ "reflect": false,
178
+ "defaultValue": "\"Navigate forward\""
179
+ },
180
+ "hideMobileNavigationButtonLabel": {
181
+ "type": "string",
182
+ "mutable": false,
183
+ "complexType": {
184
+ "original": "string",
185
+ "resolved": "string",
186
+ "references": {}
187
+ },
188
+ "required": false,
189
+ "optional": true,
190
+ "docs": {
191
+ "tags": [],
192
+ "text": ""
193
+ },
194
+ "attribute": "hide-mobile-navigation-button-label",
195
+ "reflect": false,
196
+ "defaultValue": "\"Close navigation\""
197
+ },
198
+ "navigationLabel": {
199
+ "type": "string",
200
+ "mutable": false,
201
+ "complexType": {
202
+ "original": "string",
203
+ "resolved": "string",
204
+ "references": {}
205
+ },
206
+ "required": false,
207
+ "optional": true,
208
+ "docs": {
209
+ "tags": [],
210
+ "text": ""
211
+ },
212
+ "attribute": "navigation-label",
152
213
  "reflect": false,
153
214
  "defaultValue": "\"Main\""
154
215
  },
216
+ "navigationToggleLabel": {
217
+ "type": "string",
218
+ "mutable": false,
219
+ "complexType": {
220
+ "original": "string",
221
+ "resolved": "string",
222
+ "references": {}
223
+ },
224
+ "required": false,
225
+ "optional": true,
226
+ "docs": {
227
+ "tags": [],
228
+ "text": ""
229
+ },
230
+ "attribute": "navigation-toggle-label",
231
+ "reflect": false,
232
+ "defaultValue": "\"Toggle navigation\""
233
+ },
234
+ "sidebarActive": {
235
+ "type": "boolean",
236
+ "mutable": true,
237
+ "complexType": {
238
+ "original": "boolean",
239
+ "resolved": "boolean",
240
+ "references": {}
241
+ },
242
+ "required": false,
243
+ "optional": true,
244
+ "docs": {
245
+ "tags": [],
246
+ "text": ""
247
+ },
248
+ "attribute": "sidebar-active",
249
+ "reflect": false
250
+ },
251
+ "sidebarToggleBadge": {
252
+ "type": "string",
253
+ "mutable": false,
254
+ "complexType": {
255
+ "original": "string",
256
+ "resolved": "string",
257
+ "references": {}
258
+ },
259
+ "required": false,
260
+ "optional": true,
261
+ "docs": {
262
+ "tags": [],
263
+ "text": ""
264
+ },
265
+ "attribute": "sidebar-toggle-badge",
266
+ "reflect": false
267
+ },
268
+ "sidebarToggleBadgeAriaLabel": {
269
+ "type": "string",
270
+ "mutable": false,
271
+ "complexType": {
272
+ "original": "string",
273
+ "resolved": "string",
274
+ "references": {}
275
+ },
276
+ "required": false,
277
+ "optional": true,
278
+ "docs": {
279
+ "tags": [],
280
+ "text": ""
281
+ },
282
+ "attribute": "sidebar-toggle-badge-aria-label",
283
+ "reflect": false
284
+ },
285
+ "sidebarToggleIcon": {
286
+ "type": "string",
287
+ "mutable": false,
288
+ "complexType": {
289
+ "original": "string",
290
+ "resolved": "string",
291
+ "references": {}
292
+ },
293
+ "required": false,
294
+ "optional": true,
295
+ "docs": {
296
+ "tags": [],
297
+ "text": ""
298
+ },
299
+ "attribute": "sidebar-toggle-icon",
300
+ "reflect": false,
301
+ "defaultValue": "\"notifications\""
302
+ },
155
303
  "sidebarToggleLabel": {
156
304
  "type": "string",
157
305
  "mutable": false,
@@ -161,7 +309,7 @@ export class SwirlShellLayout {
161
309
  "references": {}
162
310
  },
163
311
  "required": false,
164
- "optional": false,
312
+ "optional": true,
165
313
  "docs": {
166
314
  "tags": [],
167
315
  "text": ""
@@ -169,19 +317,77 @@ export class SwirlShellLayout {
169
317
  "attribute": "sidebar-toggle-label",
170
318
  "reflect": false,
171
319
  "defaultValue": "\"Toggle sidebar\""
320
+ },
321
+ "skipLinkLabel": {
322
+ "type": "string",
323
+ "mutable": false,
324
+ "complexType": {
325
+ "original": "string",
326
+ "resolved": "string",
327
+ "references": {}
328
+ },
329
+ "required": false,
330
+ "optional": true,
331
+ "docs": {
332
+ "tags": [],
333
+ "text": ""
334
+ },
335
+ "attribute": "skip-link-label",
336
+ "reflect": false,
337
+ "defaultValue": "\"Skip to main content\""
172
338
  }
173
339
  };
174
340
  }
175
341
  static get states() {
176
342
  return {
177
- "collapsedSidebar": {},
178
- "collapsing": {},
179
- "sidebarHovered": {}
343
+ "mobileNavigationActive": {},
344
+ "navigationCollapsed": {}
180
345
  };
181
346
  }
347
+ static get events() {
348
+ return [{
349
+ "method": "sidebarToggleClick",
350
+ "name": "sidebarToggleClick",
351
+ "bubbles": true,
352
+ "cancelable": true,
353
+ "composed": true,
354
+ "docs": {
355
+ "tags": [],
356
+ "text": ""
357
+ },
358
+ "complexType": {
359
+ "original": "MouseEvent",
360
+ "resolved": "MouseEvent",
361
+ "references": {
362
+ "MouseEvent": {
363
+ "location": "global"
364
+ }
365
+ }
366
+ }
367
+ }, {
368
+ "method": "skipLinkClick",
369
+ "name": "skipLinkClick",
370
+ "bubbles": true,
371
+ "cancelable": true,
372
+ "composed": true,
373
+ "docs": {
374
+ "tags": [],
375
+ "text": ""
376
+ },
377
+ "complexType": {
378
+ "original": "MouseEvent",
379
+ "resolved": "MouseEvent",
380
+ "references": {
381
+ "MouseEvent": {
382
+ "location": "global"
383
+ }
384
+ }
385
+ }
386
+ }];
387
+ }
182
388
  static get methods() {
183
389
  return {
184
- "collapseSidebar": {
390
+ "showMobileNavigation": {
185
391
  "complexType": {
186
392
  "signature": "() => Promise<void>",
187
393
  "parameters": [],
@@ -193,11 +399,11 @@ export class SwirlShellLayout {
193
399
  "return": "Promise<void>"
194
400
  },
195
401
  "docs": {
196
- "text": "Collapse the left sidebar.",
402
+ "text": "Opens the mobile navigation.",
197
403
  "tags": []
198
404
  }
199
405
  },
200
- "extendSidebar": {
406
+ "hideMobileNavigation": {
201
407
  "complexType": {
202
408
  "signature": "() => Promise<void>",
203
409
  "parameters": [],
@@ -209,10 +415,31 @@ export class SwirlShellLayout {
209
415
  "return": "Promise<void>"
210
416
  },
211
417
  "docs": {
212
- "text": "Extend the left sidebar.",
418
+ "text": "Hides the mobile navigation.",
213
419
  "tags": []
214
420
  }
215
421
  }
216
422
  };
217
423
  }
424
+ static get watchers() {
425
+ return [{
426
+ "propName": "mobileNavigationActive",
427
+ "methodName": "watchMobileNavigationState"
428
+ }, {
429
+ "propName": "navigationCollapsed",
430
+ "methodName": "watchNavigationCollapsed"
431
+ }, {
432
+ "propName": "sidebarActive",
433
+ "methodName": "watchSidebarActive"
434
+ }];
435
+ }
436
+ static get listeners() {
437
+ return [{
438
+ "name": "keydown",
439
+ "method": "onWindowKeyDown",
440
+ "target": "window",
441
+ "capture": false,
442
+ "passive": false
443
+ }];
444
+ }
218
445
  }
@@ -5,65 +5,15 @@ describe("swirl-shell-layout", () => {
5
5
  const page = await newSpecPage({
6
6
  components: [SwirlShellLayout],
7
7
  html: `<swirl-shell-layout main-navigation-label="Test">
8
- <div slot="logo-expanded">Expanded logo</div>
9
- <div slot="logo-collapsed">Collapsed logo</div>
10
- <div slot="tools">Tools</div>
11
- <div slot="main-navigation">Main navigation</div>
12
- <div slot="main">Main</div>
8
+ <div slot="logo">Logo</div>
9
+ <div slot="mobile-logo">Mobile logo</div>
10
+ <div slot="header-tools">Tools</div>
11
+ <div slot="nav">nav</div>
12
+ <div>Main</div>
13
+ <div slot="sidebar-header">Sidebar header</div>
14
+ <div slot="sidebar">Sidebar</div>
13
15
  </swirl-shell-layout>`,
14
16
  });
15
- expect(page.root).toEqualHtml(`
16
- <swirl-shell-layout main-navigation-label="Test">
17
- <mock:shadow-root>
18
- <div class="shell-layout shell-layout--collapsed-sidebar shell-layout--collapsing">
19
- <div class="shell-layout__banner">
20
- <slot name="banner"></slot>
21
- </div>
22
- <div class="shell-layout__sidebar-wrapper">
23
- <div class="shell-layout__sidebar">
24
- <header class="shell-layout__header">
25
- <div class="shell-layout__logo-bar">
26
- <div class="shell-layout__expanded-logo">
27
- <slot name="logo-expanded"></slot>
28
- </div>
29
- <div class="shell-layout__collapsed-logo">
30
- <slot name="logo-collapsed"></slot>
31
- </div>
32
- <div class="shell-layout__toggle">
33
- <swirl-button hidelabel="" icon="<swirl-icon-double-arrow-right></swirl-icon-double-arrow-right>" label="Toggle sidebar" swirlariaexpanded="false"></swirl-button>
34
- </div>
35
- </div>
36
- <div class="shell-layout__tools">
37
- <slot name="tools"></slot>
38
- </div>
39
- </header>
40
- <nav aria-label="Test" class="shell-layout__main-navigation">
41
- <slot name="main-navigation"></slot>
42
- </nav>
43
- </div>
44
- </div>
45
- <main class="shell-layout__main">
46
- <slot name="main"></slot>
47
- </main>
48
- <div class="shell-layout__backdrop shell-layout__backdrop--fading"></div>
49
- </div>
50
- </mock:shadow-root>
51
- <div slot="logo-expanded">
52
- Expanded logo
53
- </div>
54
- <div slot="logo-collapsed">
55
- Collapsed logo
56
- </div>
57
- <div slot="tools">
58
- Tools
59
- </div>
60
- <div slot="main-navigation">
61
- Main navigation
62
- </div>
63
- <div slot="main">
64
- Main
65
- </div>
66
- </swirl-shell-layout>
67
- `);
17
+ expect(page.root.innerHTML).toMatchInlineSnapshot(`"<!----> <div slot=\\"sidebar-header\\" hidden=\\"\\">Sidebar header</div> <div class=\\"shell-layout\\"><header class=\\"shell-layout__header\\" data-tauri-drag-region=\\"true\\"><button class=\\"shell-layout__skip-link\\" type=\\"button\\">Skip to main content</button><div class=\\"shell-layout__header-left\\"><button class=\\"shell-layout__header-tool shell-layout__navigation-toggle\\" type=\\"button\\"><swirl-icon-menu size=\\"20\\"></swirl-icon-menu><swirl-icon-double-arrow-left size=\\"20\\"></swirl-icon-double-arrow-left><swirl-icon-double-arrow-right size=\\"20\\"></swirl-icon-double-arrow-right><swirl-visually-hidden>Toggle navigation</swirl-visually-hidden></button><button class=\\"shell-layout__header-tool\\" type=\\"button\\"><swirl-icon-arrow-back size=\\"20\\"></swirl-icon-arrow-back><swirl-visually-hidden>Navigate back</swirl-visually-hidden></button><button class=\\"shell-layout__header-tool\\" type=\\"button\\"><swirl-icon-arrow-forward size=\\"20\\"></swirl-icon-arrow-forward><swirl-visually-hidden>Navigate forward</swirl-visually-hidden></button></div><div class=\\"shell-layout__logo\\"> <div slot=\\"logo\\">Logo</div></div><div class=\\"shell-layout__header-right\\"><button class=\\"shell-layout__header-tool shell-layout__sidebar-toggle\\" type=\\"button\\"><swirl-icon glyph=\\"notifications\\" size=\\"20\\"></swirl-icon><swirl-visually-hidden>Toggle sidebar</swirl-visually-hidden></button> <div slot=\\"header-tools\\">Tools</div></div></header><div class=\\"shell-layout__mobile-nav-backdrop\\"></div><nav aria-labelledby=\\"main-navigation-label\\" class=\\"shell-layout__nav\\"><div class=\\"shell-layout__mobile-header\\"> <div slot=\\"mobile-logo\\">Mobile logo</div><div class=\\"shell-layout__mobile-header-tools\\"> <button class=\\"shell-layout__header-tool\\" type=\\"button\\"><swirl-icon-double-arrow-left size=\\"20\\"></swirl-icon-double-arrow-left><swirl-visually-hidden>Close navigation</swirl-visually-hidden></button></div></div><div class=\\"shell-layout__nav-body\\"><swirl-visually-hidden><span id=\\"main-navigation-label\\">Main</span></swirl-visually-hidden> <div slot=\\"nav\\">nav</div></div></nav><main class=\\"shell-layout__main\\" id=\\"main-content\\"> <div>Main</div> </main><aside class=\\"shell-layout__sidebar\\"><div class=\\"shell-layout__sidebar-body\\"><div class=\\"shell-layout__sidebar-app-bar\\"></div><div class=\\"shell-layout__sidebar-content\\"> <div slot=\\"sidebar\\">Sidebar</div></div></div></aside></div>"`);
68
18
  });
69
19
  });