@webtides/element-library 0.3.0 → 0.4.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/CHANGELOG.md +208 -0
- package/README.md +72 -56
- package/all.js +16 -0
- package/catalog.js +17 -1
- package/custom-elements.json +14731 -10193
- package/package.json +1 -1
- package/src/components/accordion/accordion.changelog.md +11 -0
- package/src/components/accordion/accordion.js +15 -3
- package/src/components/accordion/accordion.readme.md +27 -1
- package/src/components/accordion/accordion.style.js +19 -0
- package/src/components/app-bar/app-bar.changelog.md +24 -0
- package/src/components/app-bar/app-bar.define.js +3 -0
- package/src/components/app-bar/app-bar.js +91 -0
- package/src/components/app-bar/app-bar.readme.md +130 -0
- package/src/components/app-bar/app-bar.style.js +103 -0
- package/src/components/app-frame/app-frame.changelog.md +45 -0
- package/src/components/app-frame/app-frame.define.js +3 -0
- package/src/components/app-frame/app-frame.events.js +6 -0
- package/src/components/app-frame/app-frame.js +1073 -0
- package/src/components/app-frame/app-frame.readme.md +416 -0
- package/src/components/app-frame/app-frame.style.js +527 -0
- package/src/components/button/button.changelog.md +25 -0
- package/src/components/button/button.events.js +3 -0
- package/src/components/button/button.js +209 -14
- package/src/components/button/button.readme.md +82 -6
- package/src/components/button/button.style.js +161 -7
- package/src/components/checkbox-field/checkbox-field.changelog.md +6 -0
- package/src/components/checkbox-field/checkbox-field.js +7 -1
- package/src/components/description-list/description-list.changelog.md +25 -0
- package/src/components/description-list/description-list.define.js +3 -0
- package/src/components/description-list/description-list.js +44 -0
- package/src/components/description-list/description-list.readme.md +135 -0
- package/src/components/description-list/description-list.style.js +140 -0
- package/src/components/dialog/dialog.changelog.md +7 -0
- package/src/components/dialog/dialog.readme.md +5 -0
- package/src/components/dialog/dialog.style.js +17 -2
- package/src/components/drawer/drawer.changelog.md +7 -0
- package/src/components/drawer/drawer.readme.md +7 -6
- package/src/components/drawer/drawer.style.js +35 -2
- package/src/components/dropdown/dropdown.readme.md +6 -1
- package/src/components/list/list.changelog.md +24 -0
- package/src/components/list/list.define.js +3 -0
- package/src/components/list/list.js +66 -0
- package/src/components/list/list.readme.md +122 -0
- package/src/components/list/list.style.js +56 -0
- package/src/components/list-item/list-item.changelog.md +24 -0
- package/src/components/list-item/list-item.define.js +3 -0
- package/src/components/list-item/list-item.js +128 -0
- package/src/components/list-item/list-item.readme.md +126 -0
- package/src/components/list-item/list-item.style.js +234 -0
- package/src/components/menu/menu.changelog.md +27 -0
- package/src/components/menu/menu.define.js +3 -0
- package/src/components/menu/menu.events.js +5 -0
- package/src/components/menu/menu.js +570 -0
- package/src/components/menu/menu.readme.md +272 -0
- package/src/components/menu/menu.style.js +55 -0
- package/src/components/menu-group/menu-group.changelog.md +20 -0
- package/src/components/menu-group/menu-group.define.js +3 -0
- package/src/components/menu-group/menu-group.js +44 -0
- package/src/components/menu-group/menu-group.readme.md +74 -0
- package/src/components/menu-group/menu-group.style.js +38 -0
- package/src/components/menu-item/menu-item.changelog.md +24 -0
- package/src/components/menu-item/menu-item.define.js +3 -0
- package/src/components/menu-item/menu-item.js +130 -0
- package/src/components/menu-item/menu-item.readme.md +94 -0
- package/src/components/menu-item/menu-item.style.js +87 -0
- package/src/components/nav/nav.changelog.md +35 -0
- package/src/components/nav/nav.define.js +3 -0
- package/src/components/nav/nav.js +212 -0
- package/src/components/nav/nav.readme.md +248 -0
- package/src/components/nav/nav.style.js +269 -0
- package/src/components/nav-item/nav-item.changelog.md +25 -0
- package/src/components/nav-item/nav-item.define.js +3 -0
- package/src/components/nav-item/nav-item.js +75 -0
- package/src/components/nav-item/nav-item.readme.md +111 -0
- package/src/components/nav-item/nav-item.style.js +159 -0
- package/src/components/pagination/pagination.changelog.md +8 -0
- package/src/components/pagination/pagination.js +123 -49
- package/src/components/pagination/pagination.readme.md +24 -6
- package/src/components/pagination/pagination.style.js +11 -1
- package/src/components/scroll-to-top/scroll-to-top.changelog.md +7 -5
- package/src/components/scroll-to-top/scroll-to-top.js +16 -12
- package/src/components/scroll-to-top/scroll-to-top.readme.md +2 -0
- package/src/components/segmented-field/segmented-field.changelog.md +27 -0
- package/src/components/segmented-field/segmented-field.define.js +3 -0
- package/src/components/segmented-field/segmented-field.js +175 -0
- package/src/components/segmented-field/segmented-field.readme.md +140 -0
- package/src/components/segmented-field/segmented-field.style.js +193 -0
- package/src/components/splitter/splitter.changelog.md +24 -0
- package/src/components/splitter/splitter.define.js +3 -0
- package/src/components/splitter/splitter.events.js +4 -0
- package/src/components/splitter/splitter.js +237 -0
- package/src/components/splitter/splitter.readme.md +164 -0
- package/src/components/splitter/splitter.style.js +100 -0
- package/src/components/status-bar/status-bar.changelog.md +25 -0
- package/src/components/status-bar/status-bar.define.js +3 -0
- package/src/components/status-bar/status-bar.js +74 -0
- package/src/components/status-bar/status-bar.readme.md +139 -0
- package/src/components/status-bar/status-bar.style.js +122 -0
- package/src/components/switch-field/switch-field.changelog.md +6 -0
- package/src/components/switch-field/switch-field.js +7 -1
- package/src/components/tab-group/tab-group.changelog.md +7 -0
- package/src/components/tab-group/tab-group.js +30 -9
- package/src/components/tab-group/tab-group.readme.md +14 -0
- package/src/components/toast/toast.changelog.md +6 -0
- package/src/components/toast/toast.readme.md +5 -3
- package/src/components/toast/toast.style.js +22 -6
- package/src/components/toolbar/toolbar.changelog.md +24 -0
- package/src/components/toolbar/toolbar.define.js +3 -0
- package/src/components/toolbar/toolbar.js +233 -0
- package/src/components/toolbar/toolbar.readme.md +156 -0
- package/src/components/toolbar/toolbar.style.js +49 -0
- package/src/components/tooltip/tooltip.changelog.md +11 -0
- package/src/components/tooltip/tooltip.js +51 -4
- package/src/components/tooltip/tooltip.readme.md +26 -1
- package/src/components/tree/tree.changelog.md +23 -0
- package/src/components/tree/tree.define.js +3 -0
- package/src/components/tree/tree.js +138 -0
- package/src/components/tree/tree.readme.md +119 -0
- package/src/components/tree/tree.style.js +16 -0
- package/src/components/tree-item/tree-item.changelog.md +23 -0
- package/src/components/tree-item/tree-item.define.js +3 -0
- package/src/components/tree-item/tree-item.events.js +3 -0
- package/src/components/tree-item/tree-item.js +246 -0
- package/src/components/tree-item/tree-item.readme.md +128 -0
- package/src/components/tree-item/tree-item.style.js +226 -0
- package/src/styles/appearance.style.js +47 -0
- package/src/styles/choice-group.style.js +1 -1
- package/src/styles/modal.style.js +14 -1
- package/src/styles/size.style.js +41 -0
- package/src/utils/focus.js +69 -0
- package/src/utils/scroll.js +24 -0
- package/types/all.d.ts +16 -0
- package/types/src/components/accordion/accordion.d.ts +3 -1
- package/types/src/components/app-bar/app-bar.d.ts +43 -0
- package/types/src/components/app-bar/app-bar.define.d.ts +1 -0
- package/types/src/components/app-bar/app-bar.style.d.ts +2 -0
- package/types/src/components/app-frame/app-frame.d.ts +491 -0
- package/types/src/components/app-frame/app-frame.define.d.ts +1 -0
- package/types/src/components/app-frame/app-frame.events.d.ts +7 -0
- package/types/src/components/app-frame/app-frame.style.d.ts +8 -0
- package/types/src/components/button/button.d.ts +97 -7
- package/types/src/components/button/button.events.d.ts +4 -0
- package/types/src/components/description-list/description-list.d.ts +29 -0
- package/types/src/components/description-list/description-list.define.d.ts +1 -0
- package/types/src/components/description-list/description-list.style.d.ts +2 -0
- package/types/src/components/list/list.d.ts +39 -0
- package/types/src/components/list/list.define.d.ts +1 -0
- package/types/src/components/list/list.style.d.ts +2 -0
- package/types/src/components/list-item/list-item.d.ts +62 -0
- package/types/src/components/list-item/list-item.define.d.ts +1 -0
- package/types/src/components/list-item/list-item.style.d.ts +2 -0
- package/types/src/components/menu/menu.d.ts +266 -0
- package/types/src/components/menu/menu.define.d.ts +1 -0
- package/types/src/components/menu/menu.events.d.ts +6 -0
- package/types/src/components/menu/menu.style.d.ts +2 -0
- package/types/src/components/menu-group/menu-group.d.ts +24 -0
- package/types/src/components/menu-group/menu-group.define.d.ts +1 -0
- package/types/src/components/menu-group/menu-group.style.d.ts +2 -0
- package/types/src/components/menu-item/menu-item.d.ts +59 -0
- package/types/src/components/menu-item/menu-item.define.d.ts +1 -0
- package/types/src/components/menu-item/menu-item.style.d.ts +2 -0
- package/types/src/components/nav/nav.d.ts +103 -0
- package/types/src/components/nav/nav.define.d.ts +1 -0
- package/types/src/components/nav/nav.style.d.ts +2 -0
- package/types/src/components/nav-item/nav-item.d.ts +39 -0
- package/types/src/components/nav-item/nav-item.define.d.ts +1 -0
- package/types/src/components/nav-item/nav-item.style.d.ts +2 -0
- package/types/src/components/pagination/pagination.d.ts +31 -2
- package/types/src/components/scroll-to-top/scroll-to-top.d.ts +6 -5
- package/types/src/components/segmented-field/segmented-field.d.ts +85 -0
- package/types/src/components/segmented-field/segmented-field.define.d.ts +1 -0
- package/types/src/components/segmented-field/segmented-field.style.d.ts +2 -0
- package/types/src/components/splitter/splitter.d.ts +127 -0
- package/types/src/components/splitter/splitter.define.d.ts +1 -0
- package/types/src/components/splitter/splitter.events.d.ts +5 -0
- package/types/src/components/splitter/splitter.style.d.ts +2 -0
- package/types/src/components/status-bar/status-bar.d.ts +44 -0
- package/types/src/components/status-bar/status-bar.define.d.ts +1 -0
- package/types/src/components/status-bar/status-bar.style.d.ts +2 -0
- package/types/src/components/tab-group/tab-group.d.ts +17 -0
- package/types/src/components/toolbar/toolbar.d.ts +96 -0
- package/types/src/components/toolbar/toolbar.define.d.ts +1 -0
- package/types/src/components/toolbar/toolbar.style.d.ts +2 -0
- package/types/src/components/tooltip/tooltip.d.ts +26 -0
- package/types/src/components/tree/tree.d.ts +62 -0
- package/types/src/components/tree/tree.define.d.ts +1 -0
- package/types/src/components/tree/tree.style.d.ts +2 -0
- package/types/src/components/tree-item/tree-item.d.ts +106 -0
- package/types/src/components/tree-item/tree-item.define.d.ts +1 -0
- package/types/src/components/tree-item/tree-item.events.d.ts +4 -0
- package/types/src/components/tree-item/tree-item.style.d.ts +2 -0
- package/types/src/styles/appearance.style.d.ts +31 -0
- package/types/src/styles/choice-group.style.d.ts +1 -1
- package/types/src/styles/modal.style.d.ts +5 -0
- package/types/src/styles/size.style.d.ts +24 -0
- package/types/src/utils/focus.d.ts +25 -0
- package/types/src/utils/scroll.d.ts +11 -0
- package/web-types.json +2530 -393
|
@@ -0,0 +1,1073 @@
|
|
|
1
|
+
import { TemplateElement, defineElement, html } from '@webtides/element-js';
|
|
2
|
+
import { define as defineDrawer } from '../drawer/drawer.js';
|
|
3
|
+
import { define as defineSplitter } from '../splitter/splitter.js';
|
|
4
|
+
import { activeElement, containsFocusable } from '../../utils/focus.js';
|
|
5
|
+
import { hasSlotted } from '../../utils/slots.js';
|
|
6
|
+
import style, { DEFAULT_STEP, STEPS } from './app-frame.style.js';
|
|
7
|
+
import Events from './app-frame.events.js';
|
|
8
|
+
|
|
9
|
+
/** The regions the page can leave out by the width of the frame. */
|
|
10
|
+
const REGIONS = ['header', 'navigation', 'aside', 'footer'];
|
|
11
|
+
|
|
12
|
+
/** The regions whose width the user can set by dragging their edge. */
|
|
13
|
+
const RESIZABLE = ['navigation', 'aside'];
|
|
14
|
+
|
|
15
|
+
/** What opens and closes the navigation where it is a drawer: any element with this attribute. */
|
|
16
|
+
const TOGGLE = '[data-navigation-toggle]';
|
|
17
|
+
|
|
18
|
+
/** What the user types into: the controls an on-screen keyboard opens for. */
|
|
19
|
+
const TYPED_INTO =
|
|
20
|
+
'input, textarea, select, [contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"]';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The least a part of the viewport is covered by, in pixels, for it to be taken as covered by an
|
|
24
|
+
* on-screen keyboard. Less is a scrollbar, or a height that is rounded.
|
|
25
|
+
*/
|
|
26
|
+
const KEYBOARD = 80;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* How long, in milliseconds, a scroll of the document is taken for the doing of something else
|
|
30
|
+
* than a tap on the status bar: after a finger that dragged the page has left the screen, after a
|
|
31
|
+
* wheel or a key, after a keyboard has come or gone, and after the viewport has changed its size.
|
|
32
|
+
* A page that was dragged swings back for that long.
|
|
33
|
+
*/
|
|
34
|
+
const SETTLE = 700;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* How long, in milliseconds, a scroll of the document is taken to go on after it was last heard
|
|
38
|
+
* of, where the browser does not say when it is over (`scrollend`). iOS is on its way to the
|
|
39
|
+
* top for a second and a half after a tap on the status bar, and takes the document back there
|
|
40
|
+
* for as long.
|
|
41
|
+
*/
|
|
42
|
+
const LONGEST = 2000;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* How long, in milliseconds, after the frame has put the document on its pixel a scroll back to
|
|
46
|
+
* zero is the browser that takes the pixel away again, and no tap.
|
|
47
|
+
*/
|
|
48
|
+
const ECHO = 200;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The frame of an application: it fills what the browser shows and lays out five regions, a
|
|
52
|
+
* header, a footer, a navigation at the start side, an aside at the end side, and the content.
|
|
53
|
+
* The header and the footer stay in view, and the content scrolls between them.
|
|
54
|
+
*
|
|
55
|
+
* The frame knows regions, not what they mean. The page writes the elements that say so, the
|
|
56
|
+
* landmarks, and slots them: `<header slot="header">`, `<nav slot="navigation" aria-label="…">`,
|
|
57
|
+
* `<main id="…">`, `<aside slot="aside">`, `<footer slot="footer">`. The frame adds the layout,
|
|
58
|
+
* the room for the notch and the home indicator of a phone, and a link that skips to the content
|
|
59
|
+
* as the first stop of the Tab key.
|
|
60
|
+
*
|
|
61
|
+
* From the width `wide-from` names, the navigation and the aside are columns beside the content,
|
|
62
|
+
* and each scrolls on its own. Where the frame is narrow, the content and the aside are one
|
|
63
|
+
* column that scrolls, and the navigation does not show: it opens as a drawer from the start
|
|
64
|
+
* edge, from any element with `data-navigation-toggle`. The page writes the navigation once.
|
|
65
|
+
*
|
|
66
|
+
* The width is the one of the frame, and the stylesheet alone decides: a server-rendered frame
|
|
67
|
+
* has its layout before the script has run.
|
|
68
|
+
*
|
|
69
|
+
* `resizable` names the columns whose width the user sets by dragging their edge, an
|
|
70
|
+
* `el-splitter` of the frame. `navigation-size` and `aside-size` are those widths: the frame tells
|
|
71
|
+
* of them, and the page keeps them and gives them back.
|
|
72
|
+
*
|
|
73
|
+
* Where a browser lays its on-screen keyboard over the page, the frame is as high as what shows
|
|
74
|
+
* above the keyboard, and where that part is: the header stays in view, and the field the user
|
|
75
|
+
* types into does. That needs the script.
|
|
76
|
+
*
|
|
77
|
+
* With `status-bar-tap` a tap on the status bar of an iPhone brings the content to its top, as it
|
|
78
|
+
* does in an application. iOS scrolls the document for that tap and never a region, so the frame
|
|
79
|
+
* keeps the document scrolled by one pixel there, and hears it go back. The document snaps to
|
|
80
|
+
* that pixel: a script of the page that scrolls the window does not move it, and is no tap.
|
|
81
|
+
*
|
|
82
|
+
* @element el-app-frame
|
|
83
|
+
*
|
|
84
|
+
* @fires {CustomEvent<{ open: boolean }>} app-frame-navigation-toggle - Fired when the drawer of
|
|
85
|
+
* the navigation opens or closes, with the new state in `detail.open`.
|
|
86
|
+
* @fires {CustomEvent<{ region: 'navigation'|'aside', size: number }>} app-frame-resize - Fired
|
|
87
|
+
* with every change the user makes to the width of a column: while its edge is dragged, and
|
|
88
|
+
* with every key. The new width in pixels is in `detail.size`.
|
|
89
|
+
* @fires {CustomEvent<{ region: 'navigation'|'aside', size: number }>} app-frame-resize-end -
|
|
90
|
+
* Fired once the user has set a width: when the pointer lets go of the edge, and with every
|
|
91
|
+
* key. The width to keep is in `detail.size`.
|
|
92
|
+
* @fires {CustomEvent} app-frame-status-bar-tap - Fired when the user has tapped the status bar of
|
|
93
|
+
* an iPhone, with `status-bar-tap`. The frame scrolls its content to the top after it, unless a
|
|
94
|
+
* listener calls `preventDefault()`: a view whose columns scroll brings those to their tops.
|
|
95
|
+
*
|
|
96
|
+
* @slot - The content of the view: the `main` of the page, with an id for the skip link.
|
|
97
|
+
* @slot header - The region at the top, an app bar as a rule. Left out while it is empty.
|
|
98
|
+
* @slot navigation - The region at the start side, and the content of the drawer where the frame
|
|
99
|
+
* is narrow. Left out while it is empty.
|
|
100
|
+
* @slot aside - The region at the end side. Left out while it is empty.
|
|
101
|
+
* @slot footer - The region at the lower edge. Left out while it is empty.
|
|
102
|
+
*
|
|
103
|
+
* @csspart base - The frame: the grid of the regions.
|
|
104
|
+
* @csspart skip-link - The link that skips to the content. It shows while it has the focus.
|
|
105
|
+
* @csspart header - The region at the top. Its surface reaches under the status bar of a phone.
|
|
106
|
+
* @csspart navigation - The region at the start side, where the frame is wide.
|
|
107
|
+
* @csspart body - The content and the aside. Where the frame is narrow, it is what scrolls.
|
|
108
|
+
* @csspart content - The region of the content. Where the frame is wide, it is what scrolls.
|
|
109
|
+
* @csspart aside - The region at the end side.
|
|
110
|
+
* @csspart footer - The region at the lower edge. Its surface reaches under the home indicator.
|
|
111
|
+
* @csspart drawer - The surface of the drawer the navigation is in where the frame is narrow.
|
|
112
|
+
* @csspart drawer-header - The header of that drawer, with its title and its close button.
|
|
113
|
+
* @csspart drawer-title - The title of that drawer.
|
|
114
|
+
* @csspart drawer-close-button - The close button of that drawer.
|
|
115
|
+
* @csspart drawer-body - The body of that drawer: the navigation of the page is in it.
|
|
116
|
+
* @csspart navigation-splitter - The edge of the navigation the user drags, an `el-splitter`.
|
|
117
|
+
* @csspart aside-splitter - The edge of the aside the user drags, an `el-splitter`.
|
|
118
|
+
*
|
|
119
|
+
* @cssproperty --el-app-frame-navigation-size - The width of the navigation where the frame is
|
|
120
|
+
* wide, and of its drawer where it is narrow. Default `16rem`. `auto` is the width of what is
|
|
121
|
+
* in it.
|
|
122
|
+
* @cssproperty --el-app-frame-aside-size - The width of the aside where the frame is wide.
|
|
123
|
+
* Default `20rem`.
|
|
124
|
+
* @cssproperty --el-app-frame-navigation-min-size - The least width of a navigation that is
|
|
125
|
+
* resizable. Default `10rem`.
|
|
126
|
+
* @cssproperty --el-app-frame-navigation-max-size - The greatest width of a navigation that is
|
|
127
|
+
* resizable. Default `min(30rem, 40cqi)`: two fifths of the width of the frame at most.
|
|
128
|
+
* @cssproperty --el-app-frame-aside-min-size - The least width of an aside that is resizable.
|
|
129
|
+
* Default `10rem`.
|
|
130
|
+
* @cssproperty --el-app-frame-aside-max-size - The greatest width of an aside that is resizable.
|
|
131
|
+
* Default `min(30rem, 40cqi)`.
|
|
132
|
+
*
|
|
133
|
+
* @cssstate navigation-open - Set while the drawer of the navigation is open.
|
|
134
|
+
* @cssstate keyboard - Set while an on-screen keyboard covers a part of the viewport, and the
|
|
135
|
+
* frame is as high as what shows above it.
|
|
136
|
+
*
|
|
137
|
+
* @property {string} skipLabel - The text of the link that skips to the content. Default
|
|
138
|
+
* `'Skip to content'`.
|
|
139
|
+
* @property {'30rem'|'40rem'|'48rem'|'64rem'|'80rem'} wideFrom - The width of the frame from
|
|
140
|
+
* which the navigation and the aside are columns beside the content. One of the steps the
|
|
141
|
+
* stylesheet knows, another value is the default. Default `'48rem'`.
|
|
142
|
+
* @property {string} narrowOnly - The regions that are there only where the frame is narrow, as
|
|
143
|
+
* their names with a space between them: `header`, `navigation`, `aside`, `footer`. A bar of
|
|
144
|
+
* destinations in the footer of a phone, for example (`narrow-only="footer"`). Default `''`.
|
|
145
|
+
* @property {string} wideOnly - The regions that are there only where the frame is wide, named
|
|
146
|
+
* the same way. Default `''`.
|
|
147
|
+
* @property {'drawer'|'bar'} narrowNavigation - What the navigation is where the frame is narrow.
|
|
148
|
+
* `drawer`: it does not show, and opens as a drawer. `bar`: its region lies at the lower edge,
|
|
149
|
+
* for an `el-nav` whose destinations are a bar there and a rail in the column of the wide
|
|
150
|
+
* frame. Default `'drawer'`.
|
|
151
|
+
* @property {boolean} navigationOpen - Whether the drawer of the navigation is open. It is one
|
|
152
|
+
* only where the frame is narrow: elsewhere the property is `false`. Reflected to the
|
|
153
|
+
* `navigation-open` attribute.
|
|
154
|
+
* @property {string} navigationLabel - The title of the drawer of the navigation, and its name
|
|
155
|
+
* for assistive technology. Default `'Navigation'`.
|
|
156
|
+
* @property {string} closeLabel - The name of the close button of that drawer. Default
|
|
157
|
+
* `'Close'`.
|
|
158
|
+
* @property {string} resizable - The columns whose width the user sets by dragging their edge,
|
|
159
|
+
* as their names with a space between them: `navigation`, `aside`. Default `''`.
|
|
160
|
+
* @property {number} navigationSize - The width of the navigation where the frame is wide, in
|
|
161
|
+
* pixels: the one the user has set, or the one the page has kept. `0` is the width of the
|
|
162
|
+
* stylesheet (`--el-app-frame-navigation-size`). Default `0`.
|
|
163
|
+
* @property {number} asideSize - The width of the aside where the frame is wide, in pixels. `0`
|
|
164
|
+
* is the width of the stylesheet (`--el-app-frame-aside-size`). Default `0`.
|
|
165
|
+
* @property {string} asideLabel - The name of the aside for assistive technology, on the edge
|
|
166
|
+
* that sizes it. The edge of the navigation has `navigation-label`. Default `'Aside'`.
|
|
167
|
+
* @property {boolean} statusBarTap - Whether a tap on the status bar of an iPhone brings the
|
|
168
|
+
* content to its top. The document of the page is one pixel higher than the viewport then, and
|
|
169
|
+
* snaps to that pixel. Default `false`.
|
|
170
|
+
*/
|
|
171
|
+
export default class AppFrame extends TemplateElement {
|
|
172
|
+
/**
|
|
173
|
+
* Tells of every change of a size: of the frame, which can make it wide or narrow, and of a
|
|
174
|
+
* region, which can make it scroll or stop it from scrolling.
|
|
175
|
+
* @private
|
|
176
|
+
* @type {ResizeObserver | undefined}
|
|
177
|
+
*/
|
|
178
|
+
_resizeObserver = undefined;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Whether the navigation is in a drawer: the frame is narrow, and has a navigation there.
|
|
182
|
+
* Only the script knows, so a server and the first render in the browser have the region.
|
|
183
|
+
* @private
|
|
184
|
+
*/
|
|
185
|
+
_inDrawer = false;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* What the frame has said of its drawer last, so it says a change once.
|
|
189
|
+
* @private
|
|
190
|
+
*/
|
|
191
|
+
_saidOpen = false;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Whether the script has started. The edges to drag are there from then on: they do nothing
|
|
195
|
+
* before, and a server leaves them out.
|
|
196
|
+
* @private
|
|
197
|
+
*/
|
|
198
|
+
_started = false;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The height of what scrolls the content, as it was last: a field the user types into is
|
|
202
|
+
* brought back into view when that height gets less.
|
|
203
|
+
* @private
|
|
204
|
+
*/
|
|
205
|
+
_scrollerSize = 0;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Whether an on-screen keyboard covers a part of the viewport, as the frame has said last
|
|
209
|
+
* (`:state(keyboard)`). Kept here, and not read back from the states of the element: WebKit
|
|
210
|
+
* forgets what was added to them a moment later (`states.has()` is `false`), while the state
|
|
211
|
+
* still matches.
|
|
212
|
+
* @private
|
|
213
|
+
*/
|
|
214
|
+
_keyboard = false;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Tells of a visual viewport that changes: an on-screen keyboard that comes or goes, or the
|
|
218
|
+
* page that the browser moves behind it.
|
|
219
|
+
* @private
|
|
220
|
+
* @param {Event} event
|
|
221
|
+
*/
|
|
222
|
+
_onViewport = (event) => {
|
|
223
|
+
// A viewport that changes its size is not the doing of a tap on the status bar, whatever
|
|
224
|
+
// the document does next. One that moves says nothing: it does so for that tap as well.
|
|
225
|
+
if (event.type === 'resize') this._quiet();
|
|
226
|
+
this._syncViewport();
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* What the frame keeps while it listens for a tap on the status bar: the element that makes
|
|
231
|
+
* the document one pixel higher than the viewport, whether the document snaps to that pixel
|
|
232
|
+
* and what the page had in the place of that rule, whether a script can move the document all
|
|
233
|
+
* the same, how many fingers are on the screen, until when a scroll of the document is
|
|
234
|
+
* somebody else's, whether the document is scrolling and when it was last heard of, when the
|
|
235
|
+
* frame has put it on its pixel last, and the timer that does so.
|
|
236
|
+
* @private
|
|
237
|
+
* @type {{ sentinel: HTMLElement, snaps: boolean, snapBefore: string, held: boolean, touches: number, dragged: boolean, quietUntil: number, scrolling: boolean, scrolledAt: number, armedAt: number, timer: number } | undefined}
|
|
238
|
+
*/
|
|
239
|
+
_statusBar = undefined;
|
|
240
|
+
|
|
241
|
+
/** @private */
|
|
242
|
+
_onDocumentScroll = () => this._onStatusBarScroll();
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The scroll of the document is over: it can have its pixel back.
|
|
246
|
+
* @private
|
|
247
|
+
*/
|
|
248
|
+
_onDocumentScrollEnd = () => {
|
|
249
|
+
const state = this._statusBar;
|
|
250
|
+
if (!state) return;
|
|
251
|
+
state.scrolling = false;
|
|
252
|
+
if (window.scrollY < 1) this._arm();
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* A finger has come or gone. One that has dragged the document, from the header or the
|
|
257
|
+
* footer, leaves a page that swings back: for that moment a scroll is not a tap. One that has
|
|
258
|
+
* scrolled the content has moved no document, and a tap right after it counts.
|
|
259
|
+
* @private
|
|
260
|
+
* @param {TouchEvent} event
|
|
261
|
+
*/
|
|
262
|
+
_onTouch = (event) => {
|
|
263
|
+
const state = this._statusBar;
|
|
264
|
+
if (!state) return;
|
|
265
|
+
state.touches = event.touches.length;
|
|
266
|
+
if (state.touches > 0 || !state.dragged) return;
|
|
267
|
+
state.dragged = false;
|
|
268
|
+
this._quiet();
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* A wheel or a key: over the header they scroll the document, as the tap does.
|
|
273
|
+
* @private
|
|
274
|
+
*/
|
|
275
|
+
_onInput = () => this._quiet();
|
|
276
|
+
|
|
277
|
+
constructor() {
|
|
278
|
+
super({
|
|
279
|
+
styles: [style],
|
|
280
|
+
shadowRender: true,
|
|
281
|
+
propertyOptions: { navigationOpen: { reflect: true } },
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
properties() {
|
|
286
|
+
return {
|
|
287
|
+
skipLabel: 'Skip to content',
|
|
288
|
+
wideFrom: DEFAULT_STEP,
|
|
289
|
+
narrowOnly: '',
|
|
290
|
+
wideOnly: '',
|
|
291
|
+
narrowNavigation: 'drawer',
|
|
292
|
+
navigationOpen: false,
|
|
293
|
+
navigationLabel: 'Navigation',
|
|
294
|
+
closeLabel: 'Close',
|
|
295
|
+
resizable: '',
|
|
296
|
+
navigationSize: 0,
|
|
297
|
+
asideSize: 0,
|
|
298
|
+
asideLabel: 'Aside',
|
|
299
|
+
statusBarTap: false,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
connected() {
|
|
304
|
+
this._resizeObserver = new ResizeObserver(() => {
|
|
305
|
+
this._syncView();
|
|
306
|
+
this._syncTabStops();
|
|
307
|
+
this._syncEdges();
|
|
308
|
+
this._syncFocus();
|
|
309
|
+
});
|
|
310
|
+
this._observeSizes();
|
|
311
|
+
this._syncView();
|
|
312
|
+
this._started = true;
|
|
313
|
+
if (this._resizable().length > 0) this.requestUpdate();
|
|
314
|
+
|
|
315
|
+
window.visualViewport?.addEventListener('resize', this._onViewport);
|
|
316
|
+
window.visualViewport?.addEventListener('scroll', this._onViewport);
|
|
317
|
+
this._syncViewport();
|
|
318
|
+
this._syncStatusBar();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
disconnected() {
|
|
322
|
+
this._resizeObserver?.disconnect();
|
|
323
|
+
window.visualViewport?.removeEventListener('resize', this._onViewport);
|
|
324
|
+
window.visualViewport?.removeEventListener('scroll', this._onViewport);
|
|
325
|
+
this._syncStatusBar();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
afterUpdate() {
|
|
329
|
+
// A render can have brought or taken the drawer, and with it a region to watch.
|
|
330
|
+
this._observeSizes();
|
|
331
|
+
this._syncToggles();
|
|
332
|
+
this._syncEdges();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
watch() {
|
|
336
|
+
return {
|
|
337
|
+
narrowNavigation: () => this._syncView(),
|
|
338
|
+
wideOnly: () => this._syncView(),
|
|
339
|
+
statusBarTap: () => this._syncStatusBar(),
|
|
340
|
+
navigationOpen: () => {
|
|
341
|
+
// There is a drawer to open only where the frame is narrow.
|
|
342
|
+
if (this.navigationOpen && !this._inDrawer) {
|
|
343
|
+
this.navigationOpen = false;
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
if (this.navigationOpen) this._internals.states.add('navigation-open');
|
|
347
|
+
else this._internals.states.delete('navigation-open');
|
|
348
|
+
this._syncToggles();
|
|
349
|
+
if (this.navigationOpen === this._saidOpen) return;
|
|
350
|
+
this._saidOpen = this.navigationOpen;
|
|
351
|
+
this.dispatch(Events.NAVIGATION_TOGGLE, { open: this.navigationOpen });
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
events() {
|
|
357
|
+
return {
|
|
358
|
+
this: {
|
|
359
|
+
click: (event) => this._onClick(event),
|
|
360
|
+
},
|
|
361
|
+
// A template element does not render again when a child comes, goes or changes its
|
|
362
|
+
// `slot` attribute. The slot tells of all three, and the event bubbles to the base.
|
|
363
|
+
"[part~='base']": {
|
|
364
|
+
slotchange: () => {
|
|
365
|
+
this.requestUpdate();
|
|
366
|
+
this._observeSizes();
|
|
367
|
+
this._syncView();
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
"[part~='skip-link']": {
|
|
371
|
+
click: (event) => this._onSkip(event),
|
|
372
|
+
},
|
|
373
|
+
// The drawer is a part of the frame. What it says of itself stays in the frame, and
|
|
374
|
+
// the frame says it in its own words.
|
|
375
|
+
'el-drawer': {
|
|
376
|
+
'drawer-show': (event) => event.stopPropagation(),
|
|
377
|
+
'drawer-after-show': (event) => event.stopPropagation(),
|
|
378
|
+
'drawer-initial-focus': (event) => event.stopPropagation(),
|
|
379
|
+
'drawer-request-close': (event) => event.stopPropagation(),
|
|
380
|
+
'drawer-hide': (event) => {
|
|
381
|
+
event.stopPropagation();
|
|
382
|
+
// Closed by its own button, by Escape or by a click beside it.
|
|
383
|
+
this.navigationOpen = false;
|
|
384
|
+
},
|
|
385
|
+
'drawer-after-hide': (event) => event.stopPropagation(),
|
|
386
|
+
},
|
|
387
|
+
// And so are the edges of the columns.
|
|
388
|
+
'el-splitter': {
|
|
389
|
+
'splitter-resize': (event) => this._onResize(event, Events.RESIZE),
|
|
390
|
+
'splitter-resize-end': (event) => this._onResize(event, Events.RESIZE_END),
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Whether the frame is wide: the navigation, the content and the aside are beside each other.
|
|
397
|
+
* The stylesheet decides, by the width of the frame and its `wide-from`; this reads what it
|
|
398
|
+
* has decided, so the width is written in one place.
|
|
399
|
+
* @returns {boolean}
|
|
400
|
+
*/
|
|
401
|
+
get wide() {
|
|
402
|
+
const base = this.$refs.base;
|
|
403
|
+
if (!base) return false;
|
|
404
|
+
return getComputedStyle(base).getPropertyValue('--_el-app-frame-view').trim() === 'wide';
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* The element that scrolls the content: the region of the content where the frame is wide,
|
|
409
|
+
* the column of the content and the aside where it is narrow. For a page that sets the scroll
|
|
410
|
+
* back after a change of the view, or brings a position back. The window does not scroll in a
|
|
411
|
+
* frame.
|
|
412
|
+
* @returns {HTMLElement | undefined}
|
|
413
|
+
*/
|
|
414
|
+
get scroller() {
|
|
415
|
+
return this.wide ? this.$refs.content : this.$refs.body;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* The element of the page the skip link leads to: its `main`, or the first element that is in
|
|
420
|
+
* no named slot.
|
|
421
|
+
* @private
|
|
422
|
+
* @returns {Element | undefined}
|
|
423
|
+
*/
|
|
424
|
+
_content() {
|
|
425
|
+
const inDefaultSlot = [...this.children].filter((child) => !child.getAttribute('slot'));
|
|
426
|
+
return inDefaultSlot.find((child) => child.localName === 'main') ?? inDefaultSlot[0];
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* The names of regions in an attribute of the page, and nothing else.
|
|
431
|
+
* @private
|
|
432
|
+
* @param {string} names
|
|
433
|
+
* @returns {string[]}
|
|
434
|
+
*/
|
|
435
|
+
_regionsOf(names) {
|
|
436
|
+
return String(names ?? '')
|
|
437
|
+
.split(/\s+/)
|
|
438
|
+
.filter((name) => REGIONS.includes(name));
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* The columns the page lets the user size.
|
|
443
|
+
* @private
|
|
444
|
+
* @returns {string[]}
|
|
445
|
+
*/
|
|
446
|
+
_resizable() {
|
|
447
|
+
return this._regionsOf(this.resizable).filter((name) => RESIZABLE.includes(name));
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* An edge says the width of its column, and the least and the greatest one. The stylesheet
|
|
452
|
+
* has them, in any unit, and the edge needs pixels: they are read from the column as it is
|
|
453
|
+
* laid out. A limit that is no length there, a percentage, is none for the edge. The
|
|
454
|
+
* stylesheet keeps it all the same, and the width is read again after every change.
|
|
455
|
+
* @private
|
|
456
|
+
*/
|
|
457
|
+
_syncEdges() {
|
|
458
|
+
for (const edge of this.shadowRoot?.querySelectorAll('el-splitter') ?? []) {
|
|
459
|
+
const region = this.shadowRoot.querySelector(`[part~='${edge.dataset.region}']`);
|
|
460
|
+
// A column that is not laid out, where the frame is narrow, has no width to say.
|
|
461
|
+
if (!region || !this.wide || getComputedStyle(region).display === 'none') continue;
|
|
462
|
+
|
|
463
|
+
const { inlineSize, minInlineSize, maxInlineSize } = getComputedStyle(region);
|
|
464
|
+
const pixels = (length, otherwise) => (length.endsWith('px') ? Math.round(parseFloat(length)) : otherwise);
|
|
465
|
+
const value = pixels(inlineSize, 0);
|
|
466
|
+
const min = pixels(minInlineSize, 0);
|
|
467
|
+
const max = pixels(maxInlineSize, Math.round(this.$refs.base.getBoundingClientRect().width));
|
|
468
|
+
if (edge.value !== value) edge.value = value;
|
|
469
|
+
if (edge.min !== min) edge.min = min;
|
|
470
|
+
if (edge.max !== max) edge.max = max;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* The user has moved an edge: the column takes the width, and the frame tells of it in its
|
|
476
|
+
* own words.
|
|
477
|
+
* @private
|
|
478
|
+
* @param {CustomEvent<{ value: number }>} event
|
|
479
|
+
* @param {string} name - The event of the frame.
|
|
480
|
+
*/
|
|
481
|
+
_onResize(event, name) {
|
|
482
|
+
event.stopPropagation();
|
|
483
|
+
|
|
484
|
+
const region = event.currentTarget.dataset.region;
|
|
485
|
+
const size = event.detail.value;
|
|
486
|
+
if (region === 'aside') this.asideSize = size;
|
|
487
|
+
else this.navigationSize = size;
|
|
488
|
+
this.dispatch(name, { region, size });
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* A browser that lays its on-screen keyboard over the page leaves the layout as it is: the
|
|
493
|
+
* frame is as high as the viewport, and its lower part is under the keyboard. To show the
|
|
494
|
+
* field the user types into, the browser moves the page up behind the keyboard, and the
|
|
495
|
+
* header leaves the screen with it.
|
|
496
|
+
*
|
|
497
|
+
* The visual viewport is what shows. While it is less high than the layout by more than a
|
|
498
|
+
* scrollbar, and the user types into something, the frame takes its place and its height:
|
|
499
|
+
* the header is at the top of what shows, the footer above the keyboard, and the content
|
|
500
|
+
* scrolls between them. The browser tells of the viewport once it has moved it, so for the
|
|
501
|
+
* moment the keyboard comes in the regions are on their way.
|
|
502
|
+
*
|
|
503
|
+
* A viewport that shows less is no keyboard by itself. Safari on iOS makes the visual
|
|
504
|
+
* viewport less high while a finger pulls the page past its top, by the length of the pull
|
|
505
|
+
* and with the numbers of a keyboard. A keyboard is there for a field, so the frame takes
|
|
506
|
+
* one that has the focus for the sign.
|
|
507
|
+
*
|
|
508
|
+
* Only a frame that fills the viewport follows, and not while the user has zoomed in: what
|
|
509
|
+
* shows is a part of the page then, by the will of the user.
|
|
510
|
+
* @private
|
|
511
|
+
*/
|
|
512
|
+
_syncViewport() {
|
|
513
|
+
const viewport = window.visualViewport;
|
|
514
|
+
if (!viewport) return;
|
|
515
|
+
|
|
516
|
+
const covered =
|
|
517
|
+
getComputedStyle(this).position === 'fixed' &&
|
|
518
|
+
Math.abs(viewport.scale - 1) < 0.01 &&
|
|
519
|
+
document.documentElement.clientHeight - viewport.height > KEYBOARD &&
|
|
520
|
+
this._isTyping();
|
|
521
|
+
|
|
522
|
+
if (!covered) {
|
|
523
|
+
if (!this._keyboard) return;
|
|
524
|
+
this._keyboard = false;
|
|
525
|
+
this._internals.states.delete('keyboard');
|
|
526
|
+
this.style.removeProperty('--_el-app-frame-visible-start');
|
|
527
|
+
this.style.removeProperty('--_el-app-frame-visible-size');
|
|
528
|
+
// The document is where the keyboard has left it: back by its pixel, for a tap on
|
|
529
|
+
// the status bar.
|
|
530
|
+
this._quiet();
|
|
531
|
+
this._arm();
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// The browser moves the page behind the keyboard, to show the field: it is free to.
|
|
536
|
+
this._snap(false);
|
|
537
|
+
this.style.setProperty('--_el-app-frame-visible-start', `${viewport.offsetTop}px`);
|
|
538
|
+
this.style.setProperty('--_el-app-frame-visible-size', `${viewport.height}px`);
|
|
539
|
+
this._keyboard = true;
|
|
540
|
+
this._internals.states.add('keyboard');
|
|
541
|
+
this._showFocus();
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Whether the user types into something: a field or a text they edit has the focus, in the
|
|
546
|
+
* page or in a shadow root that is open, or a frame with another page has it, which keeps
|
|
547
|
+
* to itself what has the focus in it. An on-screen keyboard is there for one of these.
|
|
548
|
+
* @private
|
|
549
|
+
* @returns {boolean}
|
|
550
|
+
*/
|
|
551
|
+
_isTyping() {
|
|
552
|
+
return activeElement()?.matches?.(`${TYPED_INTO}, iframe`) === true;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Whether the frame listens for a tap on the status bar: the page asks for it, the frame
|
|
557
|
+
* fills the viewport, and the browser is one of iOS, which has that tap and nothing that
|
|
558
|
+
* tells of it. `-webkit-touch-callout` is a property only its WebKit knows.
|
|
559
|
+
* @private
|
|
560
|
+
* @returns {boolean}
|
|
561
|
+
*/
|
|
562
|
+
_wantsStatusBarTap() {
|
|
563
|
+
const asked = this.statusBarTap === true || this.statusBarTap === 'true' || this.statusBarTap === '';
|
|
564
|
+
return (
|
|
565
|
+
asked &&
|
|
566
|
+
this.isConnected &&
|
|
567
|
+
getComputedStyle(this).position === 'fixed' &&
|
|
568
|
+
CSS.supports('-webkit-touch-callout', 'none') &&
|
|
569
|
+
CSS.supports('block-size', '100dvh')
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Starts or stops listening for a tap on the status bar.
|
|
575
|
+
*
|
|
576
|
+
* iOS scrolls the document to its top for that tap, and a frame leaves the document nothing
|
|
577
|
+
* to scroll. So an element makes the document one pixel higher than what the browser shows,
|
|
578
|
+
* and the document rests scrolled down by that pixel: it snaps there. The frame is fixed to
|
|
579
|
+
* the viewport and does not move with it. A tap takes the document back to zero, past the
|
|
580
|
+
* snap, which the frame hears.
|
|
581
|
+
* @private
|
|
582
|
+
*/
|
|
583
|
+
_syncStatusBar() {
|
|
584
|
+
const wanted = this._wantsStatusBarTap();
|
|
585
|
+
if (wanted === !!this._statusBar) return;
|
|
586
|
+
|
|
587
|
+
if (!wanted) {
|
|
588
|
+
const { sentinel, timer } = this._statusBar;
|
|
589
|
+
this._snap(false);
|
|
590
|
+
this._statusBar = undefined;
|
|
591
|
+
clearTimeout(timer);
|
|
592
|
+
sentinel.remove();
|
|
593
|
+
window.removeEventListener('scroll', this._onDocumentScroll);
|
|
594
|
+
window.removeEventListener('scrollend', this._onDocumentScrollEnd);
|
|
595
|
+
for (const type of ['touchstart', 'touchend', 'touchcancel']) {
|
|
596
|
+
window.removeEventListener(type, this._onTouch, true);
|
|
597
|
+
}
|
|
598
|
+
for (const type of ['wheel', 'keydown']) window.removeEventListener(type, this._onInput, true);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// An element of its own tree, so its rules need no stylesheet of the page. On paper there
|
|
603
|
+
// is no viewport, and it would add a sheet. The element in it is where the document
|
|
604
|
+
// snaps to: one pixel down.
|
|
605
|
+
const sentinel = document.createElement('div');
|
|
606
|
+
sentinel.setAttribute('data-el-app-frame-sentinel', '');
|
|
607
|
+
sentinel.setAttribute('aria-hidden', 'true');
|
|
608
|
+
sentinel.attachShadow({ mode: 'open' }).innerHTML = `<style>
|
|
609
|
+
:host {
|
|
610
|
+
position: absolute;
|
|
611
|
+
inset-block-start: 0;
|
|
612
|
+
inset-inline-start: 0;
|
|
613
|
+
inline-size: 1px;
|
|
614
|
+
block-size: calc(100dvh + 1px);
|
|
615
|
+
visibility: hidden;
|
|
616
|
+
pointer-events: none;
|
|
617
|
+
}
|
|
618
|
+
div {
|
|
619
|
+
position: absolute;
|
|
620
|
+
inset-block-start: 1px;
|
|
621
|
+
inset-inline-start: 0;
|
|
622
|
+
inline-size: 1px;
|
|
623
|
+
block-size: 1px;
|
|
624
|
+
scroll-snap-align: start;
|
|
625
|
+
}
|
|
626
|
+
@media print {
|
|
627
|
+
:host {
|
|
628
|
+
display: none;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
</style><div></div>`;
|
|
632
|
+
document.body.append(sentinel);
|
|
633
|
+
|
|
634
|
+
this._statusBar = {
|
|
635
|
+
sentinel,
|
|
636
|
+
snaps: false,
|
|
637
|
+
snapBefore: '',
|
|
638
|
+
held: false,
|
|
639
|
+
touches: 0,
|
|
640
|
+
dragged: false,
|
|
641
|
+
quietUntil: 0,
|
|
642
|
+
scrolling: false,
|
|
643
|
+
scrolledAt: 0,
|
|
644
|
+
armedAt: 0,
|
|
645
|
+
timer: 0,
|
|
646
|
+
};
|
|
647
|
+
window.addEventListener('scroll', this._onDocumentScroll, { passive: true });
|
|
648
|
+
window.addEventListener('scrollend', this._onDocumentScrollEnd);
|
|
649
|
+
for (const type of ['touchstart', 'touchend', 'touchcancel']) {
|
|
650
|
+
window.addEventListener(type, this._onTouch, { capture: true, passive: true });
|
|
651
|
+
}
|
|
652
|
+
for (const type of ['wheel', 'keydown']) {
|
|
653
|
+
window.addEventListener(type, this._onInput, { capture: true, passive: true });
|
|
654
|
+
}
|
|
655
|
+
this._snap(true);
|
|
656
|
+
// The browser may put the scroll of a page back while it loads: not a tap either.
|
|
657
|
+
this._quiet();
|
|
658
|
+
this._arm();
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Makes the document snap to its one pixel, or lets it go.
|
|
663
|
+
*
|
|
664
|
+
* What snaps is where a scroll ends, also the one of a script: `window.scrollTo(0, 0)` of a
|
|
665
|
+
* router leaves the document on its pixel. And a finger that has dragged the page lets it go
|
|
666
|
+
* back there. The tap on the status bar is the one scroll iOS does not snap.
|
|
667
|
+
*
|
|
668
|
+
* The rule is one for the element of the document, the only place the browser reads it for
|
|
669
|
+
* the viewport: the frame writes it there, and puts back what the page had.
|
|
670
|
+
* @private
|
|
671
|
+
* @param {boolean} on
|
|
672
|
+
*/
|
|
673
|
+
_snap(on) {
|
|
674
|
+
const state = this._statusBar;
|
|
675
|
+
if (!state || state.snaps === on) return;
|
|
676
|
+
state.snaps = on;
|
|
677
|
+
|
|
678
|
+
const root = document.documentElement;
|
|
679
|
+
if (on) {
|
|
680
|
+
state.snapBefore = root.style.scrollSnapType;
|
|
681
|
+
root.style.scrollSnapType = 'y mandatory';
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
root.style.scrollSnapType = state.snapBefore;
|
|
685
|
+
if (root.getAttribute('style') === '') root.removeAttribute('style');
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* From now on, for a moment, a scroll of the document is not the doing of a tap on the status
|
|
690
|
+
* bar: a finger drags the page, a keyboard moves it, the phone is turned.
|
|
691
|
+
* @private
|
|
692
|
+
*/
|
|
693
|
+
_quiet() {
|
|
694
|
+
if (this._statusBar) this._statusBar.quietUntil = performance.now() + SETTLE;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Whether something else than a tap on the status bar is moving the document.
|
|
699
|
+
* @private
|
|
700
|
+
* @returns {boolean}
|
|
701
|
+
*/
|
|
702
|
+
_isMoved() {
|
|
703
|
+
const { touches, quietUntil } = this._statusBar;
|
|
704
|
+
return touches > 0 || performance.now() < quietUntil || this._keyboard;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Whether the document is scrolling: it has scrolled, and the browser has not said that this
|
|
709
|
+
* is over. A browser that never says so is given the time the longest scroll takes.
|
|
710
|
+
* @private
|
|
711
|
+
* @returns {boolean}
|
|
712
|
+
*/
|
|
713
|
+
_isScrolling() {
|
|
714
|
+
const { scrolling, scrolledAt } = this._statusBar;
|
|
715
|
+
return scrolling && performance.now() - scrolledAt < LONGEST;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Scrolls the document down by its one pixel, once nothing else moves it and its scroll is
|
|
720
|
+
* over: iOS takes the document back to the top for as long as it is on its way there. Until
|
|
721
|
+
* then it looks again: a finger can stay on the screen for long.
|
|
722
|
+
*
|
|
723
|
+
* And it asks what tells the tap from a script: whether a script can scroll the document to
|
|
724
|
+
* zero. Where the browser snaps the scroll of a script, it cannot. Where it can, the two look
|
|
725
|
+
* the same, and the frame takes no scroll for the tap.
|
|
726
|
+
* @private
|
|
727
|
+
*/
|
|
728
|
+
_arm() {
|
|
729
|
+
const state = this._statusBar;
|
|
730
|
+
if (!state) return;
|
|
731
|
+
clearTimeout(state.timer);
|
|
732
|
+
|
|
733
|
+
const now = performance.now();
|
|
734
|
+
if (this._isMoved() || this._isScrolling()) {
|
|
735
|
+
const scrolls = this._isScrolling() ? state.scrolledAt + LONGEST - now : 0;
|
|
736
|
+
const wait = Math.max(state.quietUntil - now, scrolls, 150) + 50;
|
|
737
|
+
state.timer = setTimeout(() => this._arm(), wait);
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
this._snap(true);
|
|
741
|
+
state.armedAt = now;
|
|
742
|
+
// At once, also where the page asks for a scroll that takes its time.
|
|
743
|
+
if (window.scrollY < 1) window.scrollTo({ top: 1, behavior: 'instant' });
|
|
744
|
+
window.scrollTo({ top: 0, behavior: 'instant' });
|
|
745
|
+
state.held = window.scrollY >= 1;
|
|
746
|
+
if (!state.held) window.scrollTo({ top: 1, behavior: 'instant' });
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* The document has scrolled. At zero, with nothing else that moves it, the user has tapped
|
|
751
|
+
* the status bar: the content goes to its top, as the document of a page would.
|
|
752
|
+
*
|
|
753
|
+
* A script of the page does not get the document there, a router that sets the scroll of the
|
|
754
|
+
* window back after a change of the view for one: the document snaps to its pixel.
|
|
755
|
+
* @private
|
|
756
|
+
*/
|
|
757
|
+
_onStatusBarScroll() {
|
|
758
|
+
const state = this._statusBar;
|
|
759
|
+
if (!state) return;
|
|
760
|
+
const now = performance.now();
|
|
761
|
+
// The document moves under a finger: a drag, and no tap when the finger has gone.
|
|
762
|
+
if (state.touches > 0) state.dragged = true;
|
|
763
|
+
// The tap is the first thing a document at rest does. What follows it is iOS on its way
|
|
764
|
+
// to the top, which takes the document back there until it has arrived.
|
|
765
|
+
const first = !this._isScrolling();
|
|
766
|
+
state.scrolling = true;
|
|
767
|
+
state.scrolledAt = now;
|
|
768
|
+
if (window.scrollY >= 1) return;
|
|
769
|
+
|
|
770
|
+
const taken = now - state.armedAt < ECHO;
|
|
771
|
+
if (first && !taken && state.held && !this._isMoved()) {
|
|
772
|
+
// Built by hand: dispatch() of element-js does not say whether a listener has
|
|
773
|
+
// prevented the default.
|
|
774
|
+
const event = new CustomEvent(Events.STATUS_BAR_TAP, { bubbles: true, composed: true, cancelable: true });
|
|
775
|
+
this.dispatchEvent(event);
|
|
776
|
+
if (!event.defaultPrevented) {
|
|
777
|
+
const calm = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
778
|
+
this.scroller?.scrollTo({ top: 0, behavior: calm ? 'auto' : 'smooth' });
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
// Back by the pixel, for the next tap, once this scroll is over.
|
|
782
|
+
clearTimeout(state.timer);
|
|
783
|
+
state.timer = setTimeout(() => this._arm(), 50);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* The regions have changed their sizes. Where what scrolls the content got less high, a
|
|
788
|
+
* keyboard has come in or the window got smaller, and the field the user types into may be
|
|
789
|
+
* out of view now.
|
|
790
|
+
* @private
|
|
791
|
+
*/
|
|
792
|
+
_syncFocus() {
|
|
793
|
+
const size = this.scroller?.clientHeight ?? 0;
|
|
794
|
+
const less = size < this._scrollerSize;
|
|
795
|
+
this._scrollerSize = size;
|
|
796
|
+
if (less) this._showFocus();
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Brings the field the user types into back into view, in the region that scrolls it. A
|
|
801
|
+
* field in a dialog or a popover is in the top layer and in no region: the browser shows it.
|
|
802
|
+
* @private
|
|
803
|
+
*/
|
|
804
|
+
_showFocus() {
|
|
805
|
+
const active = activeElement();
|
|
806
|
+
if (!active?.matches?.(TYPED_INTO)) return;
|
|
807
|
+
|
|
808
|
+
for (let node = active; node && node !== this; node = node.assignedSlot ?? node.parentNode ?? node.host) {
|
|
809
|
+
if (node === document) return;
|
|
810
|
+
if (node instanceof Element && node.matches(':modal, :popover-open')) return;
|
|
811
|
+
}
|
|
812
|
+
active.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Takes what the stylesheet has decided: where the frame is narrow and has a navigation
|
|
817
|
+
* there, the navigation is in a drawer. Where it is wide again, the drawer goes, open or
|
|
818
|
+
* not: the platform takes a dialog that leaves the page out of the top layer, and the drawer
|
|
819
|
+
* gives the scroll of the page back.
|
|
820
|
+
* @private
|
|
821
|
+
*/
|
|
822
|
+
_syncView() {
|
|
823
|
+
if (!this.$refs.base) return;
|
|
824
|
+
|
|
825
|
+
const inDrawer =
|
|
826
|
+
!this.wide &&
|
|
827
|
+
this.narrowNavigation !== 'bar' &&
|
|
828
|
+
hasSlotted(this, 'navigation') &&
|
|
829
|
+
!this._regionsOf(this.wideOnly).includes('navigation');
|
|
830
|
+
if (inDrawer === this._inDrawer) return;
|
|
831
|
+
|
|
832
|
+
this._inDrawer = inDrawer;
|
|
833
|
+
if (!inDrawer) this.navigationOpen = false;
|
|
834
|
+
this.requestUpdate();
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* The elements of the page that open and close the navigation.
|
|
839
|
+
* @private
|
|
840
|
+
* @returns {HTMLElement[]}
|
|
841
|
+
*/
|
|
842
|
+
_toggles() {
|
|
843
|
+
return [...this.querySelectorAll(TOGGLE)];
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* A toggle says whether the navigation is open, and is not there where there is no drawer to
|
|
848
|
+
* open. An `el-button` reads that from the stylesheet of the frame, before the script has
|
|
849
|
+
* run; any other element is hidden here.
|
|
850
|
+
* @private
|
|
851
|
+
*/
|
|
852
|
+
_syncToggles() {
|
|
853
|
+
for (const toggle of this._toggles()) {
|
|
854
|
+
toggle.setAttribute('aria-expanded', this.navigationOpen ? 'true' : 'false');
|
|
855
|
+
if (toggle.localName !== 'el-button') toggle.hidden = !this._inDrawer;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* A click on a toggle opens or closes the drawer. A click on a link in the open drawer closes
|
|
861
|
+
* it: the user has chosen where to go, also where the page changes the view without loading.
|
|
862
|
+
* @private
|
|
863
|
+
* @param {MouseEvent} event
|
|
864
|
+
*/
|
|
865
|
+
_onClick(event) {
|
|
866
|
+
const path = event.composedPath().filter((node) => node instanceof Element);
|
|
867
|
+
|
|
868
|
+
if (path.some((node) => node.matches(TOGGLE))) {
|
|
869
|
+
if (this._inDrawer) this.navigationOpen = !this.navigationOpen;
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
if (!this.navigationOpen) return;
|
|
874
|
+
const inNavigation = path.some(
|
|
875
|
+
(node) => node.parentNode === this && node.getAttribute('slot') === 'navigation',
|
|
876
|
+
);
|
|
877
|
+
if (inNavigation && path.some((node) => node.matches('a[href]'))) this.navigationOpen = false;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
/**
|
|
881
|
+
* The regions that can scroll, each with the elements of the page that are in it.
|
|
882
|
+
* @private
|
|
883
|
+
* @returns {Array<[HTMLElement, Element[]]>}
|
|
884
|
+
*/
|
|
885
|
+
_regions() {
|
|
886
|
+
return ['body', 'navigation', 'content', 'aside']
|
|
887
|
+
.map((name) => this.shadowRoot.querySelector(`[part~='${name}']`))
|
|
888
|
+
.filter(Boolean)
|
|
889
|
+
.map((region) => [
|
|
890
|
+
region,
|
|
891
|
+
[...region.querySelectorAll('slot')].flatMap((slot) => slot.assignedElements({ flatten: true })),
|
|
892
|
+
]);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Watches the sizes of the frame, of the regions and of what the page has put into them.
|
|
897
|
+
* @private
|
|
898
|
+
*/
|
|
899
|
+
_observeSizes() {
|
|
900
|
+
if (!this._resizeObserver) return;
|
|
901
|
+
this._resizeObserver.disconnect();
|
|
902
|
+
this._resizeObserver.observe(this);
|
|
903
|
+
for (const [region, elements] of this._regions()) {
|
|
904
|
+
this._resizeObserver.observe(region);
|
|
905
|
+
for (const element of elements) this._resizeObserver.observe(element);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* A region that scrolls and has nothing in it that takes the focus is a stop of the Tab key
|
|
911
|
+
* itself: without one the keyboard cannot scroll it. Some browsers do that by themselves, and
|
|
912
|
+
* this does it for the others.
|
|
913
|
+
* @private
|
|
914
|
+
*/
|
|
915
|
+
_syncTabStops() {
|
|
916
|
+
for (const [region, elements] of this._regions()) {
|
|
917
|
+
const { overflowY } = getComputedStyle(region);
|
|
918
|
+
const scrolls =
|
|
919
|
+
(overflowY === 'auto' || overflowY === 'scroll') && region.scrollHeight > region.clientHeight;
|
|
920
|
+
|
|
921
|
+
if (scrolls && !elements.some(containsFocusable)) {
|
|
922
|
+
region.setAttribute('tabindex', '0');
|
|
923
|
+
} else if (region.getAttribute('tabindex') === '0') {
|
|
924
|
+
region.removeAttribute('tabindex');
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
* After the skip link the content is in view from its start, the keys scroll it, and the Tab
|
|
931
|
+
* key goes on inside of it: the region of the content has the focus.
|
|
932
|
+
*
|
|
933
|
+
* The link is a link to the id of the content, which a browser follows before the script has
|
|
934
|
+
* run. From then on the script does the same and leaves the address alone: a page that keeps
|
|
935
|
+
* its route in the fragment would lose it.
|
|
936
|
+
* @private
|
|
937
|
+
* @param {MouseEvent} event
|
|
938
|
+
*/
|
|
939
|
+
_onSkip(event) {
|
|
940
|
+
event.preventDefault();
|
|
941
|
+
|
|
942
|
+
const region = this.$refs.content;
|
|
943
|
+
const scroller = this.scroller;
|
|
944
|
+
// The region scrolls itself where the frame is wide, and is a part of what scrolls where
|
|
945
|
+
// it is narrow.
|
|
946
|
+
scroller.scrollTop =
|
|
947
|
+
scroller === region
|
|
948
|
+
? 0
|
|
949
|
+
: scroller.scrollTop + region.getBoundingClientRect().top - scroller.getBoundingClientRect().top;
|
|
950
|
+
|
|
951
|
+
// Where the region is no stop of the Tab key, it takes the focus for this moment only.
|
|
952
|
+
if (!region.hasAttribute('tabindex')) {
|
|
953
|
+
region.setAttribute('tabindex', '-1');
|
|
954
|
+
region.addEventListener(
|
|
955
|
+
'blur',
|
|
956
|
+
() => {
|
|
957
|
+
if (region.getAttribute('tabindex') === '-1') region.removeAttribute('tabindex');
|
|
958
|
+
},
|
|
959
|
+
{ once: true },
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
region.focus({ preventScroll: true });
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* The navigation: a region of the frame, or the content of a drawer where the frame is
|
|
967
|
+
* narrow. One slot either way, so the page writes the navigation once and no node is moved.
|
|
968
|
+
* @private
|
|
969
|
+
*/
|
|
970
|
+
navigationTemplate() {
|
|
971
|
+
if (this._inDrawer) {
|
|
972
|
+
return html`
|
|
973
|
+
<el-drawer
|
|
974
|
+
class="drawer"
|
|
975
|
+
placement="start"
|
|
976
|
+
exportparts="base:drawer, header:drawer-header, title:drawer-title, close-button:drawer-close-button, body:drawer-body"
|
|
977
|
+
label="${this.navigationLabel}"
|
|
978
|
+
close-label="${this.closeLabel}"
|
|
979
|
+
open="${this.navigationOpen ? 'true' : 'false'}"
|
|
980
|
+
>
|
|
981
|
+
<slot name="navigation"></slot>
|
|
982
|
+
</el-drawer>
|
|
983
|
+
`;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
return html`
|
|
987
|
+
<div part="navigation" class="navigation" ?hidden="${!hasSlotted(this, 'navigation')}">
|
|
988
|
+
<slot name="navigation"></slot>
|
|
989
|
+
</div>
|
|
990
|
+
`;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* The edge of a column the user drags: an `el-splitter` at the side that faces the content.
|
|
995
|
+
* Only where the page asks for it, the column is there, and the script runs. Where the
|
|
996
|
+
* navigation is a drawer, it has no edge.
|
|
997
|
+
* @private
|
|
998
|
+
* @param {'navigation'|'aside'} region
|
|
999
|
+
*/
|
|
1000
|
+
edgeTemplate(region) {
|
|
1001
|
+
if (!this._started || !this._resizable().includes(region) || !hasSlotted(this, region)) return '';
|
|
1002
|
+
if (region === 'navigation' && this._inDrawer) return '';
|
|
1003
|
+
|
|
1004
|
+
return html`
|
|
1005
|
+
<el-splitter
|
|
1006
|
+
part="${region}-splitter"
|
|
1007
|
+
class="edge edge--${region}"
|
|
1008
|
+
data-region="${region}"
|
|
1009
|
+
placement="${region === 'aside' ? 'start' : 'end'}"
|
|
1010
|
+
label="${region === 'aside' ? this.asideLabel : this.navigationLabel}"
|
|
1011
|
+
></el-splitter>
|
|
1012
|
+
`;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
template() {
|
|
1016
|
+
const id = this._content()?.id;
|
|
1017
|
+
// The stylesheet reads the step from the frame, not from the host: a value it does not
|
|
1018
|
+
// know is the default here, and a server writes it as the browser does.
|
|
1019
|
+
const step = STEPS.includes(this.wideFrom) ? this.wideFrom : DEFAULT_STEP;
|
|
1020
|
+
// The widths the user has set, or the page has kept: the stylesheet reads them from the
|
|
1021
|
+
// frame, so a server-rendered frame has them before the script has run.
|
|
1022
|
+
const sizes = [
|
|
1023
|
+
['navigation', this.navigationSize],
|
|
1024
|
+
['aside', this.asideSize],
|
|
1025
|
+
]
|
|
1026
|
+
.filter(([, size]) => Number(size) > 0)
|
|
1027
|
+
.map(([region, size]) => `--_el-app-frame-${region}-size: ${Math.round(Number(size))}px;`)
|
|
1028
|
+
.join(' ');
|
|
1029
|
+
|
|
1030
|
+
return html`
|
|
1031
|
+
<a part="skip-link" class="skip" href="#${id || ''}">${this.skipLabel}</a>
|
|
1032
|
+
<div
|
|
1033
|
+
part="base"
|
|
1034
|
+
ref="base"
|
|
1035
|
+
class="frame ${hasSlotted(this, 'header') ? 'frame--header' : ''} ${
|
|
1036
|
+
hasSlotted(this, 'footer') ? 'frame--footer' : ''
|
|
1037
|
+
} ${hasSlotted(this, 'navigation') ? 'frame--navigation' : ''} ${
|
|
1038
|
+
hasSlotted(this, 'aside') ? 'frame--aside' : ''
|
|
1039
|
+
}"
|
|
1040
|
+
data-wide-from="${step}"
|
|
1041
|
+
data-narrow-only="${this._regionsOf(this.narrowOnly).join(' ')}"
|
|
1042
|
+
data-wide-only="${this._regionsOf(this.wideOnly).join(' ')}"
|
|
1043
|
+
data-narrow-navigation="${this.narrowNavigation === 'bar' ? 'bar' : 'drawer'}"
|
|
1044
|
+
data-resizable="${this._resizable().join(' ')}"
|
|
1045
|
+
style="${sizes || null}"
|
|
1046
|
+
>
|
|
1047
|
+
<div part="header" class="header" ?hidden="${!hasSlotted(this, 'header')}">
|
|
1048
|
+
<slot name="header"></slot>
|
|
1049
|
+
</div>
|
|
1050
|
+
${this.navigationTemplate()} ${this.edgeTemplate('navigation')}
|
|
1051
|
+
<div part="body" ref="body" class="body">
|
|
1052
|
+
<div part="content" ref="content" class="content"><slot></slot></div>
|
|
1053
|
+
${this.edgeTemplate('aside')}
|
|
1054
|
+
<div part="aside" class="aside" ?hidden="${!hasSlotted(this, 'aside')}">
|
|
1055
|
+
<slot name="aside"></slot>
|
|
1056
|
+
</div>
|
|
1057
|
+
</div>
|
|
1058
|
+
<div part="footer" class="footer" ?hidden="${!hasSlotted(this, 'footer')}">
|
|
1059
|
+
<slot name="footer"></slot>
|
|
1060
|
+
</div>
|
|
1061
|
+
</div>
|
|
1062
|
+
`;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
export function define() {
|
|
1067
|
+
// The drawer the navigation is in where the frame is narrow, and the edges of its columns.
|
|
1068
|
+
defineDrawer();
|
|
1069
|
+
defineSplitter();
|
|
1070
|
+
defineElement('el-app-frame', AppFrame);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
export { Events };
|