@vaadin/app-layout 24.7.0-alpha1 → 24.7.0-alpha2

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.
@@ -0,0 +1,166 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2018 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
7
+
8
+ export const appLayoutStyles = css`
9
+ :host {
10
+ display: block;
11
+ box-sizing: border-box;
12
+ height: 100%;
13
+ --vaadin-app-layout-transition: 200ms;
14
+ transition: padding var(--vaadin-app-layout-transition);
15
+ --_vaadin-app-layout-drawer-width: var(--vaadin-app-layout-drawer-width, 16em);
16
+ --vaadin-app-layout-touch-optimized: false;
17
+ --vaadin-app-layout-navbar-offset-top: var(--_vaadin-app-layout-navbar-offset-size);
18
+ --vaadin-app-layout-navbar-offset-bottom: var(--_vaadin-app-layout-navbar-offset-size-bottom);
19
+ padding-block: var(--vaadin-app-layout-navbar-offset-top) var(--vaadin-app-layout-navbar-offset-bottom);
20
+ padding-inline-start: var(--vaadin-app-layout-navbar-offset-left);
21
+ }
22
+
23
+ :host([hidden]),
24
+ [hidden] {
25
+ display: none !important;
26
+ }
27
+
28
+ :host([no-anim]) {
29
+ --vaadin-app-layout-transition: none !important;
30
+ }
31
+
32
+ :host([drawer-opened]) {
33
+ --vaadin-app-layout-drawer-offset-left: var(--_vaadin-app-layout-drawer-offset-size);
34
+ }
35
+
36
+ :host([overlay]) {
37
+ --vaadin-app-layout-drawer-offset-left: 0;
38
+ --vaadin-app-layout-navbar-offset-left: 0;
39
+ }
40
+
41
+ :host(:not([no-scroll])) [content] {
42
+ overflow: auto;
43
+ }
44
+
45
+ [content] {
46
+ height: 100%;
47
+ }
48
+
49
+ @media (pointer: coarse) and (max-width: 800px) and (min-height: 500px) {
50
+ :host {
51
+ --vaadin-app-layout-touch-optimized: true;
52
+ }
53
+ }
54
+
55
+ [part='navbar'] {
56
+ position: fixed;
57
+ display: flex;
58
+ align-items: center;
59
+ top: 0;
60
+ inset-inline: 0;
61
+ transition: inset-inline-start var(--vaadin-app-layout-transition);
62
+ padding-top: var(--safe-area-inset-top);
63
+ padding-left: var(--safe-area-inset-left);
64
+ padding-right: var(--safe-area-inset-right);
65
+ z-index: 1;
66
+ }
67
+
68
+ :host([primary-section='drawer'][drawer-opened]:not([overlay])) [part='navbar'] {
69
+ inset-inline-start: var(--vaadin-app-layout-drawer-offset-left, 0);
70
+ }
71
+
72
+ :host([primary-section='drawer']) [part='drawer'] {
73
+ top: 0;
74
+ }
75
+
76
+ [part='navbar'][bottom] {
77
+ top: auto;
78
+ bottom: 0;
79
+ padding-bottom: var(--safe-area-inset-bottom);
80
+ }
81
+
82
+ [part='drawer'] {
83
+ overflow: auto;
84
+ position: fixed;
85
+ top: var(--vaadin-app-layout-navbar-offset-top, 0);
86
+ bottom: var(--vaadin-app-layout-navbar-offset-bottom, var(--vaadin-viewport-offset-bottom, 0));
87
+ inset-inline: var(--vaadin-app-layout-navbar-offset-left, 0) auto;
88
+ transition:
89
+ transform var(--vaadin-app-layout-transition),
90
+ visibility var(--vaadin-app-layout-transition);
91
+ transform: translateX(-100%);
92
+ max-width: 90%;
93
+ width: var(--_vaadin-app-layout-drawer-width);
94
+ box-sizing: border-box;
95
+ padding: var(--safe-area-inset-top) 0 var(--safe-area-inset-bottom) var(--safe-area-inset-left);
96
+ outline: none;
97
+ /* The drawer should be inaccessible by the tabbing navigation when it is closed. */
98
+ visibility: hidden;
99
+ display: flex;
100
+ flex-direction: column;
101
+ }
102
+
103
+ :host([drawer-opened]) [part='drawer'] {
104
+ /* The drawer should be accessible by the tabbing navigation when it is opened. */
105
+ visibility: visible;
106
+ transform: translateX(0%);
107
+ touch-action: manipulation;
108
+ }
109
+
110
+ [part='backdrop'] {
111
+ background-color: #000;
112
+ opacity: 0.3;
113
+ }
114
+
115
+ :host(:not([drawer-opened])) [part='backdrop'] {
116
+ opacity: 0;
117
+ }
118
+
119
+ :host([overlay]) [part='backdrop'] {
120
+ position: fixed;
121
+ inset: 0;
122
+ pointer-events: none;
123
+ transition: opacity var(--vaadin-app-layout-transition);
124
+ -webkit-tap-highlight-color: transparent;
125
+ }
126
+
127
+ :host([overlay]) [part='drawer'] {
128
+ top: 0;
129
+ bottom: 0;
130
+ }
131
+
132
+ :host([overlay]) [part='drawer'],
133
+ :host([overlay]) [part='backdrop'] {
134
+ z-index: 2;
135
+ }
136
+
137
+ :host([drawer-opened][overlay]) [part='backdrop'] {
138
+ pointer-events: auto;
139
+ touch-action: manipulation;
140
+ }
141
+
142
+ :host([dir='rtl']) [part='drawer'] {
143
+ transform: translateX(100%);
144
+ }
145
+
146
+ :host([dir='rtl'][drawer-opened]) [part='drawer'] {
147
+ transform: translateX(0%);
148
+ }
149
+
150
+ :host([drawer-opened]:not([overlay])) {
151
+ padding-inline-start: var(--vaadin-app-layout-drawer-offset-left);
152
+ }
153
+
154
+ @media (max-width: 800px), (max-height: 600px) {
155
+ :host {
156
+ --vaadin-app-layout-drawer-overlay: true;
157
+ --_vaadin-app-layout-drawer-width: var(--vaadin-app-layout-drawer-width, 20em);
158
+ }
159
+ }
160
+
161
+ /* If a vaadin-scroller is used in the drawer, allow it to take all remaining space and contain scrolling */
162
+ [part='drawer'] ::slotted(vaadin-scroller) {
163
+ flex: 1;
164
+ overscroll-behavior: contain;
165
+ }
166
+ `;
@@ -6,10 +6,9 @@
6
6
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
7
7
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
8
8
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
+ import { AppLayoutMixin } from './vaadin-app-layout-mixin.js';
9
10
 
10
- export interface AppLayoutI18n {
11
- drawer: string;
12
- }
11
+ export type { AppLayoutI18n } from './vaadin-app-layout-mixin.js';
13
12
 
14
13
  /**
15
14
  * Fired when the `drawerOpened` property changes.
@@ -123,65 +122,12 @@ export type AppLayoutEventMap = AppLayoutCustomEventMap & HTMLElementEventMap;
123
122
  * @fires {CustomEvent} overlay-changed - Fired when the `overlay` property changes.
124
123
  * @fires {CustomEvent} primary-section-changed - Fired when the `primarySection` property changes.
125
124
  */
126
- declare class AppLayout extends ElementMixin(ThemableMixin(ControllerMixin(HTMLElement))) {
125
+ declare class AppLayout extends AppLayoutMixin(ElementMixin(ThemableMixin(ControllerMixin(HTMLElement)))) {
127
126
  /**
128
127
  * Helper static method that dispatches a `close-overlay-drawer` event
129
128
  */
130
129
  static dispatchCloseOverlayDrawerEvent(): void;
131
130
 
132
- /**
133
- * The object used to localize this component.
134
- * To change the default localization, replace the entire
135
- * `i18n` object with a custom one.
136
- *
137
- * To update individual properties, extend the existing i18n object as follows:
138
- * ```js
139
- * appLayout.i18n = {
140
- * ...appLayout.i18n,
141
- * drawer: 'Drawer'
142
- * }
143
- * ```
144
- *
145
- * The object has the following structure and default values:
146
- * ```
147
- * {
148
- * drawer: 'Drawer'
149
- * }
150
- * ```
151
- */
152
- i18n: AppLayoutI18n;
153
-
154
- /**
155
- * Defines whether navbar or drawer will come first visually.
156
- * - By default (`primary-section="navbar"`), the navbar takes the full available width and moves the drawer down.
157
- * - If `primary-section="drawer"` is set, then the drawer will move the navbar, taking the full available height.
158
- * @attr {navbar|drawer} primary-section
159
- */
160
- primarySection: 'drawer' | 'navbar';
161
-
162
- /**
163
- * Controls whether the drawer is opened (visible) or not.
164
- * Its default value depends on the viewport:
165
- * - `true`, for desktop size views
166
- * - `false`, for mobile size views
167
- * @attr {boolean} drawer-opened
168
- */
169
- drawerOpened: boolean;
170
-
171
- /**
172
- * Drawer is an overlay on top of the content
173
- * Controlled via CSS using `--vaadin-app-layout-drawer-overlay: true|false`;
174
- */
175
- readonly overlay: boolean;
176
-
177
- /**
178
- * A global event that causes the drawer to close (be hidden) when it is in overlay mode.
179
- * - The default is `vaadin-router-location-changed` dispatched by Vaadin Router
180
- *
181
- * @attr {string} close-drawer-on
182
- */
183
- closeDrawerOn: string;
184
-
185
131
  addEventListener<K extends keyof AppLayoutEventMap>(
186
132
  type: K,
187
133
  listener: (this: AppLayout, ev: AppLayoutEventMap[K]) => void,