@vaadin/login 24.2.0-dev.f254716fe → 24.3.0-alpha1

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,35 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2018 - 2023 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css } from 'lit';
7
+
8
+ export const loginOverlayWrapperStyles = css`
9
+ [part='overlay'] {
10
+ outline: none;
11
+ }
12
+
13
+ [part='card'] {
14
+ max-width: 100%;
15
+ box-sizing: border-box;
16
+ overflow: hidden;
17
+ display: flex;
18
+ flex-direction: column;
19
+ }
20
+
21
+ [part='brand'] {
22
+ box-sizing: border-box;
23
+ overflow: hidden;
24
+ flex-grow: 1;
25
+ flex-shrink: 0;
26
+ display: flex;
27
+ flex-direction: column;
28
+ justify-content: flex-end;
29
+ }
30
+
31
+ [part='brand'] h1 {
32
+ color: inherit;
33
+ margin: 0;
34
+ }
35
+ `;
@@ -3,58 +3,17 @@
3
3
  * Copyright (c) 2018 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { html } from '@polymer/polymer/lib/utils/html-tag.js';
7
- import { Overlay } from '@vaadin/overlay/src/vaadin-overlay.js';
8
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
6
+ import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
7
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
+ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
+ import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
10
+ import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
11
+ import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12
+ import { loginOverlayWrapperStyles } from './vaadin-login-overlay-wrapper-styles.js';
9
13
 
10
- registerStyles(
11
- 'vaadin-login-overlay-wrapper',
12
- css`
13
- [part='overlay'] {
14
- outline: none;
15
- }
16
-
17
- [part='card'] {
18
- max-width: 100%;
19
- box-sizing: border-box;
20
- overflow: hidden;
21
- display: flex;
22
- flex-direction: column;
23
- }
24
-
25
- [part='brand'] {
26
- box-sizing: border-box;
27
- overflow: hidden;
28
- flex-grow: 1;
29
- flex-shrink: 0;
30
- display: flex;
31
- flex-direction: column;
32
- justify-content: flex-end;
33
- }
34
-
35
- [part='brand'] h1 {
36
- color: inherit;
37
- margin: 0;
38
- }
39
- `,
40
- { moduleId: 'vaadin-login-overlay-wrapper-styles' },
41
- );
42
-
43
- const template = html`
44
- <section part="card">
45
- <div part="brand">
46
- <slot name="title">
47
- <h1 part="title">[[title]]</h1>
48
- </slot>
49
- <p part="description">[[description]]</p>
50
- </div>
51
- <div part="form">
52
- <slot></slot>
53
- </div>
54
- </section>
55
- `;
56
-
57
- let memoizedTemplate;
14
+ registerStyles('vaadin-login-overlay-wrapper', [overlayStyles, loginOverlayWrapperStyles], {
15
+ moduleId: 'vaadin-login-overlay-wrapper-styles',
16
+ });
58
17
 
59
18
  /**
60
19
  * An element used internally by `<vaadin-login-overlay>`. Not intended to be used separately.
@@ -62,7 +21,7 @@ let memoizedTemplate;
62
21
  * @extends Overlay
63
22
  * @private
64
23
  */
65
- class LoginOverlayWrapper extends Overlay {
24
+ class LoginOverlayWrapper extends OverlayMixin(DirMixin(ThemableMixin(PolymerElement))) {
66
25
  static get is() {
67
26
  return 'vaadin-login-overlay-wrapper';
68
27
  }
@@ -86,18 +45,25 @@ class LoginOverlayWrapper extends Overlay {
86
45
  }
87
46
 
88
47
  static get template() {
89
- if (!memoizedTemplate) {
90
- // Clone the superclass template
91
- memoizedTemplate = super.template.cloneNode(true);
92
-
93
- // Replace overlay slot with card
94
- const card = template.content.querySelector('[part=card]');
95
- const content = memoizedTemplate.content.querySelector('#content');
96
- content.replaceChild(card, content.children[0]);
97
- }
98
-
99
- return memoizedTemplate;
48
+ return html`
49
+ <div id="backdrop" part="backdrop" hidden$="[[!withBackdrop]]"></div>
50
+ <div part="overlay" id="overlay" tabindex="0">
51
+ <div part="content" id="content">
52
+ <section part="card">
53
+ <div part="brand">
54
+ <slot name="title">
55
+ <h1 part="title">[[title]]</h1>
56
+ </slot>
57
+ <p part="description">[[description]]</p>
58
+ </div>
59
+ <div part="form">
60
+ <slot></slot>
61
+ </div>
62
+ </section>
63
+ </div>
64
+ </div>
65
+ `;
100
66
  }
101
67
  }
102
68
 
103
- customElements.define(LoginOverlayWrapper.is, LoginOverlayWrapper);
69
+ defineCustomElement(LoginOverlayWrapper);
@@ -4,9 +4,9 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
7
- import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
8
7
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
- import { LoginMixin } from './vaadin-login-mixin.js';
8
+ import { LoginOverlayMixin } from './vaadin-login-overlay-mixin.js';
9
+
10
10
  export { LoginI18n } from './vaadin-login-mixin.js';
11
11
 
12
12
  /**
@@ -27,7 +27,11 @@ export type LoginOverlayErrorChangedEvent = CustomEvent<{ value: boolean }>;
27
27
  /**
28
28
  * Fired when a user submits the login.
29
29
  */
30
- export type LoginOverlayLoginEvent = CustomEvent<{ username: string; password: string }>;
30
+ export type LoginOverlayLoginEvent = CustomEvent<{
31
+ username: string;
32
+ password: string;
33
+ custom?: Record<string, unknown>;
34
+ }>;
31
35
 
32
36
  export interface LoginOverlayCustomEventMap {
33
37
  'description-changed': LoginOverlayDescriptionChangedEvent;
@@ -76,22 +80,7 @@ export interface LoginOverlayEventMap extends HTMLElementEventMap, LoginOverlayC
76
80
  * @fires {CustomEvent} forgot-password - Fired when user clicks on the "Forgot password" button.
77
81
  * @fires {CustomEvent} login - Fired when a user submits the login.
78
82
  */
79
- declare class LoginOverlay extends LoginMixin(OverlayClassMixin(ElementMixin(ThemableMixin(HTMLElement)))) {
80
- /**
81
- * Defines the application description
82
- */
83
- description: string;
84
-
85
- /**
86
- * True if the overlay is currently displayed.
87
- */
88
- opened: boolean;
89
-
90
- /**
91
- * Defines the application title
92
- */
93
- title: string;
94
-
83
+ declare class LoginOverlay extends LoginOverlayMixin(ElementMixin(ThemableMixin(HTMLElement))) {
95
84
  addEventListener<K extends keyof LoginOverlayEventMap>(
96
85
  type: K,
97
86
  listener: (this: LoginOverlay, ev: LoginOverlayEventMap[K]) => void,
@@ -6,10 +6,10 @@
6
6
  import './vaadin-login-form.js';
7
7
  import './vaadin-login-overlay-wrapper.js';
8
8
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
9
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
9
10
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
10
- import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
11
11
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12
- import { LoginMixin } from './vaadin-login-mixin.js';
12
+ import { LoginOverlayMixin } from './vaadin-login-overlay-mixin.js';
13
13
 
14
14
  /**
15
15
  * `<vaadin-login-overlay>` is a wrapper of the `<vaadin-login-form>` which opens a login form in an overlay and
@@ -44,13 +44,13 @@ import { LoginMixin } from './vaadin-login-mixin.js';
44
44
  * @fires {CustomEvent} forgot-password - Fired when user clicks on the "Forgot password" button.
45
45
  * @fires {CustomEvent} login - Fired when a user submits the login.
46
46
  *
47
+ * @customElement
47
48
  * @extends HTMLElement
48
49
  * @mixes ElementMixin
49
50
  * @mixes ThemableMixin
50
- * @mixes LoginMixin
51
- * @mixes OverlayClassMixin
51
+ * @mixes LoginOverlayMixin
52
52
  */
53
- class LoginOverlay extends LoginMixin(OverlayClassMixin(ElementMixin(ThemableMixin(PolymerElement)))) {
53
+ class LoginOverlay extends LoginOverlayMixin(ElementMixin(ThemableMixin(PolymerElement))) {
54
54
  static get template() {
55
55
  return html`
56
56
  <vaadin-login-overlay-wrapper
@@ -77,145 +77,19 @@ class LoginOverlay extends LoginMixin(OverlayClassMixin(ElementMixin(ThemableMix
77
77
  on-forgot-password="_retargetEvent"
78
78
  ></vaadin-login-form>
79
79
  </vaadin-login-overlay-wrapper>
80
+
81
+ <div hidden>
82
+ <slot name="custom-form-area"></slot>
83
+ <slot name="footer"></slot>
84
+ </div>
80
85
  `;
81
86
  }
82
87
 
83
88
  static get is() {
84
89
  return 'vaadin-login-overlay';
85
90
  }
86
-
87
- static get properties() {
88
- return {
89
- /**
90
- * Defines the application description
91
- * @type {string}
92
- */
93
- description: {
94
- type: String,
95
- value: 'Application description',
96
- notify: true,
97
- },
98
-
99
- /**
100
- * True if the overlay is currently displayed.
101
- * @type {boolean}
102
- */
103
- opened: {
104
- type: Boolean,
105
- value: false,
106
- observer: '_onOpenedChange',
107
- },
108
-
109
- /**
110
- * Defines the application title
111
- * @type {string}
112
- */
113
- title: {
114
- type: String,
115
- value: 'App name',
116
- },
117
- };
118
- }
119
-
120
- static get observers() {
121
- return ['__i18nChanged(i18n.header.*)'];
122
- }
123
-
124
- /** @protected */
125
- ready() {
126
- super.ready();
127
-
128
- this._overlayElement = this.$.vaadinLoginOverlayWrapper;
129
- }
130
-
131
- /** @protected */
132
- connectedCallback() {
133
- super.connectedCallback();
134
-
135
- // Restore opened state if overlay was open when disconnecting
136
- if (this.__restoreOpened) {
137
- this.opened = true;
138
- }
139
- }
140
-
141
- /** @protected */
142
- disconnectedCallback() {
143
- super.disconnectedCallback();
144
-
145
- // Close overlay and memorize opened state
146
- this.__restoreOpened = this.opened;
147
- this.opened = false;
148
- }
149
-
150
- /** @private */
151
- __i18nChanged(i18n) {
152
- const header = i18n.base;
153
- if (!header) {
154
- return;
155
- }
156
- this.title = header.title;
157
- this.description = header.description;
158
- }
159
-
160
- /** @private */
161
- _preventClosingLogin(e) {
162
- e.preventDefault();
163
- }
164
-
165
- /**
166
- * @param {!Event} e
167
- * @private
168
- */
169
- _retargetEvent(e) {
170
- e.stopPropagation();
171
- const { detail, composed, cancelable, bubbles } = e;
172
-
173
- const firedEvent = this.dispatchEvent(new CustomEvent(e.type, { bubbles, cancelable, composed, detail }));
174
- // Check if `eventTarget.preventDefault()` was called to prevent default in the original event
175
- if (!firedEvent) {
176
- e.preventDefault();
177
- }
178
- }
179
-
180
- /** @private */
181
- _onOpenedChange() {
182
- if (!this.opened) {
183
- this.$.vaadinLoginForm.$.vaadinLoginUsername.value = '';
184
- this.$.vaadinLoginForm.$.vaadinLoginPassword.value = '';
185
- this.disabled = false;
186
-
187
- if (this._undoTeleport) {
188
- this._undoTeleport();
189
- }
190
- } else {
191
- this._undoTeleport = this._teleport(this._getElementsToTeleport());
192
-
193
- // Overlay sets pointerEvents on body to `none`, which breaks LastPass popup
194
- // Reverting it back to the previous state
195
- // https://github.com/vaadin/vaadin-overlay/blob/041cde4481b6262eac68d3a699f700216d897373/src/vaadin-overlay.html#L660
196
- document.body.style.pointerEvents = this.$.vaadinLoginOverlayWrapper._previousDocumentPointerEvents;
197
- }
198
- }
199
-
200
- /** @private */
201
- _teleport(elements) {
202
- const teleported = Array.from(elements).map((e) => {
203
- return this.$.vaadinLoginOverlayWrapper.appendChild(e);
204
- });
205
- // Function to undo the teleport
206
- return () => {
207
- while (teleported.length > 0) {
208
- this.appendChild(teleported.shift());
209
- }
210
- };
211
- }
212
-
213
- /** @private */
214
- _getElementsToTeleport() {
215
- return this.querySelectorAll('[slot=title]');
216
- }
217
91
  }
218
92
 
219
- customElements.define(LoginOverlay.is, LoginOverlay);
93
+ defineCustomElement(LoginOverlay);
220
94
 
221
95
  export { LoginOverlay };
@@ -17,6 +17,11 @@ const loginFormWrapper = css`
17
17
  margin-top: calc(var(--lumo-font-size-xxxl) - var(--lumo-font-size-xxl));
18
18
  }
19
19
 
20
+ ::slotted([slot='submit']) {
21
+ margin-top: var(--lumo-space-l);
22
+ margin-bottom: var(--lumo-space-s);
23
+ }
24
+
20
25
  ::slotted([slot='forgot-password']) {
21
26
  margin: var(--lumo-space-s) auto;
22
27
  }
@@ -2,5 +2,4 @@ import '@vaadin/button/theme/lumo/vaadin-button.js';
2
2
  import '@vaadin/text-field/theme/lumo/vaadin-text-field.js';
3
3
  import '@vaadin/password-field/theme/lumo/vaadin-password-field.js';
4
4
  import './vaadin-login-form-wrapper-styles.js';
5
- import './vaadin-login-form-styles.js';
6
5
  import '../../src/vaadin-login-form.js';
@@ -1,6 +1,7 @@
1
1
  import '@vaadin/vaadin-lumo-styles/spacing.js';
2
2
  import './vaadin-login-form-wrapper-styles.js';
3
3
  import { color } from '@vaadin/vaadin-lumo-styles/color.js';
4
+ import { overlay } from '@vaadin/vaadin-lumo-styles/mixins/overlay.js';
4
5
  import { typography } from '@vaadin/vaadin-lumo-styles/typography.js';
5
6
  import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
6
7
 
@@ -169,8 +170,8 @@ const loginOverlayWrapper = css`
169
170
  }
170
171
  `;
171
172
 
172
- registerStyles('vaadin-login-overlay-wrapper', [color, typography, loginOverlayWrapper], {
173
- moduleId: 'vaadin-login-overlay-wrapper-lumo-styles',
173
+ registerStyles('vaadin-login-overlay-wrapper', [color, typography, overlay, loginOverlayWrapper], {
174
+ moduleId: 'lumo-login-overlay-wrapper',
174
175
  });
175
176
 
176
177
  const loginFormWrapper = css`
@@ -1,7 +1,6 @@
1
1
  import '@vaadin/text-field/theme/lumo/vaadin-text-field.js';
2
2
  import '@vaadin/password-field/theme/lumo/vaadin-password-field.js';
3
3
  import '@vaadin/button/theme/lumo/vaadin-button.js';
4
- import '@vaadin/overlay/theme/lumo/vaadin-overlay.js';
5
4
  import './vaadin-login-form.js';
6
5
  import './vaadin-login-overlay-styles.js';
7
6
  import '../../src/vaadin-login-overlay.js';
@@ -5,7 +5,6 @@ import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themab
5
5
  const loginFormWrapper = css`
6
6
  :host {
7
7
  background: var(--material-background-color) linear-gradient(hsla(0, 0%, 100%, 0.3), hsla(0, 0%, 100%, 0.3));
8
- min-height: 250px;
9
8
  }
10
9
 
11
10
  [part='form'] {
@@ -22,6 +21,19 @@ const loginFormWrapper = css`
22
21
  font-size: var(--material-h5-font-size);
23
22
  }
24
23
 
24
+ ::slotted([slot='submit']) {
25
+ margin-top: 3em;
26
+ margin-bottom: 2em;
27
+ flex-grow: 0;
28
+ }
29
+
30
+ @media only screen and (max-width: 1023px) {
31
+ ::slotted([slot='submit']) {
32
+ margin-top: 2.5em;
33
+ margin-bottom: 1em;
34
+ }
35
+ }
36
+
25
37
  ::slotted([slot='forgot-password']) {
26
38
  margin: 0.5rem auto;
27
39
  padding-bottom: 12px;
@@ -2,5 +2,4 @@ import '@vaadin/button/theme/material/vaadin-button.js';
2
2
  import '@vaadin/text-field/theme/material/vaadin-text-field.js';
3
3
  import '@vaadin/password-field/theme/material/vaadin-password-field.js';
4
4
  import './vaadin-login-form-wrapper-styles.js';
5
- import './vaadin-login-form-styles.js';
6
5
  import '../../src/vaadin-login-form.js';
@@ -1,5 +1,4 @@
1
1
  import '@vaadin/vaadin-material-styles/color.js';
2
- import './vaadin-login-form-styles.js';
3
2
  import { overlay } from '@vaadin/vaadin-material-styles/mixins/overlay.js';
4
3
  import { typography } from '@vaadin/vaadin-material-styles/typography.js';
5
4
  import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
@@ -338,9 +337,7 @@ const loginFormWrapper = css`
338
337
  }
339
338
 
340
339
  :host([theme~='with-overlay']) [part='form'] ::slotted(form) {
341
- justify-content: space-around;
342
- margin-top: 20px;
343
- min-height: 250px;
340
+ margin-top: 15px;
344
341
  }
345
342
  }
346
343
 
@@ -1,7 +1,6 @@
1
1
  import '@vaadin/text-field/theme/material/vaadin-text-field.js';
2
2
  import '@vaadin/password-field/theme/material/vaadin-password-field.js';
3
3
  import '@vaadin/button/theme/material/vaadin-button.js';
4
- import '@vaadin/overlay/theme/material/vaadin-overlay.js';
5
4
  import './vaadin-login-form.js';
6
5
  import './vaadin-login-overlay-styles.js';
7
6
  import '../../src/vaadin-login-overlay.js';