@vaadin/dialog 25.1.0-alpha2 → 25.1.0-alpha4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/dialog",
3
- "version": "25.1.0-alpha2",
3
+ "version": "25.1.0-alpha4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,24 +36,24 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@open-wc/dedupe-mixin": "^1.3.0",
39
- "@vaadin/component-base": "25.1.0-alpha2",
40
- "@vaadin/lit-renderer": "25.1.0-alpha2",
41
- "@vaadin/overlay": "25.1.0-alpha2",
42
- "@vaadin/vaadin-themable-mixin": "25.1.0-alpha2",
39
+ "@vaadin/component-base": "25.1.0-alpha4",
40
+ "@vaadin/lit-renderer": "25.1.0-alpha4",
41
+ "@vaadin/overlay": "25.1.0-alpha4",
42
+ "@vaadin/vaadin-themable-mixin": "25.1.0-alpha4",
43
43
  "lit": "^3.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@vaadin/a11y-base": "25.1.0-alpha2",
47
- "@vaadin/aura": "25.1.0-alpha2",
48
- "@vaadin/chai-plugins": "25.1.0-alpha2",
49
- "@vaadin/test-runner-commands": "25.1.0-alpha2",
46
+ "@vaadin/a11y-base": "25.1.0-alpha4",
47
+ "@vaadin/aura": "25.1.0-alpha4",
48
+ "@vaadin/chai-plugins": "25.1.0-alpha4",
49
+ "@vaadin/test-runner-commands": "25.1.0-alpha4",
50
50
  "@vaadin/testing-helpers": "^2.0.0",
51
- "@vaadin/vaadin-lumo-styles": "25.1.0-alpha2",
51
+ "@vaadin/vaadin-lumo-styles": "25.1.0-alpha4",
52
52
  "sinon": "^21.0.0"
53
53
  },
54
54
  "web-types": [
55
55
  "web-types.json",
56
56
  "web-types.lit.json"
57
57
  ],
58
- "gitHead": "dfeb6e14643ec923e5505ca645f7354c6dc170ec"
58
+ "gitHead": "4fb917150617231c1acf27faabf386560dcd3bc5"
59
59
  }
@@ -32,6 +32,12 @@ export declare class DialogBaseMixinClass {
32
32
  */
33
33
  modeless: boolean;
34
34
 
35
+ /**
36
+ * Set to true to disable focus trapping.
37
+ * @attr {boolean} no-focus-trap
38
+ */
39
+ noFocusTrap: boolean;
40
+
35
41
  /**
36
42
  * The `role` attribute value to be set on the dialog. Defaults to "dialog".
37
43
  *
@@ -52,6 +52,16 @@ export const DialogBaseMixin = (superClass) =>
52
52
  value: false,
53
53
  },
54
54
 
55
+ /**
56
+ * Set to true to disable focus trapping.
57
+ * @attr {boolean} no-focus-trap
58
+ * @type {boolean}
59
+ */
60
+ noFocusTrap: {
61
+ type: Boolean,
62
+ value: false,
63
+ },
64
+
55
65
  /**
56
66
  * Set the distance of the dialog from the top of the viewport.
57
67
  * If a unitless number is provided, pixels are assumed.
@@ -21,4 +21,12 @@ export declare class DialogDraggableMixinClass {
21
21
  * "`draggable-leaf-only`" class name.
22
22
  */
23
23
  draggable: boolean;
24
+
25
+ /**
26
+ * Set to true to prevent dragging the dialog outside the viewport bounds.
27
+ * When enabled, all four edges of the dialog will remain visible during dragging.
28
+ * The dialog may still become partially hidden when the viewport is resized.
29
+ * @attr {boolean} keep-in-viewport
30
+ */
31
+ keepInViewport: boolean;
24
32
  }
@@ -31,6 +31,19 @@ export const DialogDraggableMixin = (superClass) =>
31
31
  reflectToAttribute: true,
32
32
  },
33
33
 
34
+ /**
35
+ * Set to true to prevent dragging the dialog outside the viewport bounds.
36
+ * When enabled, all four edges of the dialog will remain visible during dragging.
37
+ * The dialog may still become partially hidden when the viewport is resized.
38
+ * @attr {boolean} keep-in-viewport
39
+ * @type {boolean}
40
+ */
41
+ keepInViewport: {
42
+ type: Boolean,
43
+ value: false,
44
+ reflectToAttribute: true,
45
+ },
46
+
34
47
  /** @private */
35
48
  _touchDevice: {
36
49
  type: Boolean,
@@ -93,11 +106,15 @@ export const DialogDraggableMixin = (superClass) =>
93
106
  window.addEventListener('touchend', this._stopDrag);
94
107
  window.addEventListener('mousemove', this._drag);
95
108
  window.addEventListener('touchmove', this._drag);
109
+
110
+ const { top, left, width, height } = this._originalBounds;
96
111
  if (this.$.overlay.$.overlay.style.position !== 'absolute') {
97
- const { top, left } = this._originalBounds;
98
112
  this.top = top;
99
113
  this.left = left;
100
114
  }
115
+ this.dispatchEvent(
116
+ new CustomEvent('drag-start', { bubbles: true, composed: true, detail: { width, height, top, left } }),
117
+ );
101
118
  }
102
119
  }
103
120
  }
@@ -106,8 +123,22 @@ export const DialogDraggableMixin = (superClass) =>
106
123
  _drag(e) {
107
124
  const event = getMouseOrFirstTouchEvent(e);
108
125
  if (eventInWindow(event)) {
109
- const top = this._originalBounds.top + (event.pageY - this._originalMouseCoords.top);
110
- const left = this._originalBounds.left + (event.pageX - this._originalMouseCoords.left);
126
+ let top = this._originalBounds.top + (event.pageY - this._originalMouseCoords.top);
127
+ let left = this._originalBounds.left + (event.pageX - this._originalMouseCoords.left);
128
+
129
+ if (this.keepInViewport) {
130
+ const { width, height } = this._originalBounds;
131
+ // Get the overlay container's position to account for its offset from the viewport
132
+ const containerBounds = this.$.overlay.getBoundingClientRect();
133
+ // Calculate bounds so the dialog's visual edges stay within the viewport
134
+ const minLeft = -containerBounds.left;
135
+ const maxLeft = window.innerWidth - containerBounds.left - width;
136
+ const minTop = -containerBounds.top;
137
+ const maxTop = window.innerHeight - containerBounds.top - height;
138
+ left = Math.max(minLeft, Math.min(left, maxLeft));
139
+ top = Math.max(minTop, Math.min(top, maxTop));
140
+ }
141
+
111
142
  this.top = top;
112
143
  this.left = left;
113
144
  }
@@ -124,6 +155,12 @@ export const DialogDraggableMixin = (superClass) =>
124
155
  window.removeEventListener('touchmove', this._drag);
125
156
  }
126
157
 
158
+ /**
159
+ * Fired when the dialog drag is started.
160
+ *
161
+ * @event drag-start
162
+ */
163
+
127
164
  /**
128
165
  * Fired when the dialog drag is finished.
129
166
  *
@@ -74,6 +74,9 @@ export const DialogResizableMixin = (superClass) =>
74
74
  window.addEventListener('touchend', this._resizeListeners.stop[direction]);
75
75
  this.$.overlay.setBounds(this._originalBounds);
76
76
  this.$.overlay.setAttribute('has-bounds-set', '');
77
+
78
+ const { width, height, top, left } = this._originalBounds;
79
+ this.dispatchEvent(new CustomEvent('resize-start', { detail: { width, height, top, left } }));
77
80
  }
78
81
  }
79
82
 
@@ -148,6 +151,12 @@ export const DialogResizableMixin = (superClass) =>
148
151
  return { width, height, top, left };
149
152
  }
150
153
 
154
+ /**
155
+ * Fired when the dialog resize is started.
156
+ *
157
+ * @event resize-start
158
+ */
159
+
151
160
  /**
152
161
  * Fired when the dialog resize is finished.
153
162
  *
@@ -34,11 +34,21 @@ export type DialogPosition = {
34
34
  */
35
35
  export type DialogOpenedChangedEvent = CustomEvent<{ value: boolean }>;
36
36
 
37
+ /**
38
+ * Fired when the dialog resize is started.
39
+ */
40
+ export type DialogResizeStartEvent = CustomEvent<DialogResizeDimensions>;
41
+
37
42
  /**
38
43
  * Fired when the dialog resize is finished.
39
44
  */
40
45
  export type DialogResizeEvent = CustomEvent<DialogResizeDimensions>;
41
46
 
47
+ /**
48
+ * Fired when the dialog drag is started.
49
+ */
50
+ export type DialogDragStartEvent = CustomEvent<DialogResizeDimensions>;
51
+
42
52
  /**
43
53
  * Fired when the dialog drag is finished.
44
54
  */
@@ -54,8 +64,12 @@ export interface DialogCustomEventMap {
54
64
 
55
65
  closed: DialogClosedEvent;
56
66
 
67
+ 'resize-start': DialogResizeStartEvent;
68
+
57
69
  resize: DialogResizeEvent;
58
70
 
71
+ 'drag-start': DialogDragStartEvent;
72
+
59
73
  dragged: DialogDraggedEvent;
60
74
  }
61
75
 
@@ -131,7 +145,9 @@ export type DialogEventMap = DialogCustomEventMap & HTMLElementEventMap;
131
145
  *
132
146
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
133
147
  *
148
+ * @fires {CustomEvent} resize-start - Fired when the dialog resize is started.
134
149
  * @fires {CustomEvent} resize - Fired when the dialog resize is finished.
150
+ * @fires {CustomEvent} drag-start - Fired when the dialog drag is started.
135
151
  * @fires {CustomEvent} dragged - Fired when the dialog drag is finished.
136
152
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
137
153
  * @fires {CustomEvent} closed - Fired when the dialog is closed.
@@ -88,7 +88,9 @@ export { DialogOverlay } from './vaadin-dialog-overlay.js';
88
88
  *
89
89
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
90
90
  *
91
+ * @fires {CustomEvent} resize-start - Fired when the dialog resize is started.
91
92
  * @fires {CustomEvent} resize - Fired when the dialog resize is finished.
93
+ * @fires {CustomEvent} drag-start - Fired when the dialog drag is started.
92
94
  * @fires {CustomEvent} dragged - Fired when the dialog drag is finished.
93
95
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
94
96
  * @fires {CustomEvent} closed - Fired when the dialog is closed.
@@ -154,7 +156,7 @@ class Dialog extends DialogSizeMixin(
154
156
  .withBackdrop="${!this.modeless}"
155
157
  ?resizable="${this.resizable}"
156
158
  restore-focus-on-close
157
- focus-trap
159
+ ?focus-trap="${!this.noFocusTrap}"
158
160
  exportparts="backdrop, overlay, header, title, header-content, content, footer"
159
161
  >
160
162
  <slot name="title" slot="title"></slot>
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/dialog",
4
- "version": "25.1.0-alpha2",
4
+ "version": "25.1.0-alpha4",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -46,6 +46,15 @@
46
46
  ]
47
47
  }
48
48
  },
49
+ {
50
+ "name": "no-focus-trap",
51
+ "description": "Set to true to disable focus trapping.",
52
+ "value": {
53
+ "type": [
54
+ "boolean"
55
+ ]
56
+ }
57
+ },
49
58
  {
50
59
  "name": "top",
51
60
  "description": "Set the distance of the dialog from the top of the viewport.\nIf a unitless number is provided, pixels are assumed.\n\nNote that the dialog uses an internal container that has some\nadditional spacing, which can be overridden by the theme.",
@@ -88,6 +97,15 @@
88
97
  ]
89
98
  }
90
99
  },
100
+ {
101
+ "name": "keep-in-viewport",
102
+ "description": "Set to true to prevent dragging the dialog outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible during dragging.\nThe dialog may still become partially hidden when the viewport is resized.",
103
+ "value": {
104
+ "type": [
105
+ "boolean"
106
+ ]
107
+ }
108
+ },
91
109
  {
92
110
  "name": "header-title",
93
111
  "description": "String used for rendering a dialog title.\n\nIf both `headerTitle` and `headerRenderer` are defined, the title\nand the elements created by the renderer will be placed next to\neach other, with the title coming first.\n\nWhen `headerTitle` is set, the attribute `has-title` is set on the dialog.",
@@ -180,6 +198,15 @@
180
198
  ]
181
199
  }
182
200
  },
201
+ {
202
+ "name": "noFocusTrap",
203
+ "description": "Set to true to disable focus trapping.",
204
+ "value": {
205
+ "type": [
206
+ "boolean"
207
+ ]
208
+ }
209
+ },
183
210
  {
184
211
  "name": "top",
185
212
  "description": "Set the distance of the dialog from the top of the viewport.\nIf a unitless number is provided, pixels are assumed.\n\nNote that the dialog uses an internal container that has some\nadditional spacing, which can be overridden by the theme.",
@@ -222,6 +249,15 @@
222
249
  ]
223
250
  }
224
251
  },
252
+ {
253
+ "name": "keepInViewport",
254
+ "description": "Set to true to prevent dragging the dialog outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible during dragging.\nThe dialog may still become partially hidden when the viewport is resized.",
255
+ "value": {
256
+ "type": [
257
+ "boolean"
258
+ ]
259
+ }
260
+ },
225
261
  {
226
262
  "name": "renderer",
227
263
  "description": "Custom function for rendering the content of the dialog.\nReceives two arguments:\n\n- `root` The root container DOM element. Append your content to it.\n- `dialog` The reference to the `<vaadin-dialog>` element.",
@@ -300,6 +336,10 @@
300
336
  "name": "closed",
301
337
  "description": "Fired when the dialog is closed."
302
338
  },
339
+ {
340
+ "name": "drag-start",
341
+ "description": "Fired when the dialog drag is started."
342
+ },
303
343
  {
304
344
  "name": "dragged",
305
345
  "description": "Fired when the dialog drag is finished."
@@ -308,6 +348,10 @@
308
348
  "name": "resize",
309
349
  "description": "Fired when the dialog resize is finished."
310
350
  },
351
+ {
352
+ "name": "resize-start",
353
+ "description": "Fired when the dialog resize is started."
354
+ },
311
355
  {
312
356
  "name": "opened-changed",
313
357
  "description": "Fired when the `opened` property changes."
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/dialog",
4
- "version": "25.1.0-alpha2",
4
+ "version": "25.1.0-alpha4",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -47,6 +47,13 @@
47
47
  "kind": "expression"
48
48
  }
49
49
  },
50
+ {
51
+ "name": "?noFocusTrap",
52
+ "description": "Set to true to disable focus trapping.",
53
+ "value": {
54
+ "kind": "expression"
55
+ }
56
+ },
50
57
  {
51
58
  "name": "?draggable",
52
59
  "description": "Set to true to enable repositioning the dialog by clicking and dragging.\n\nBy default, only the overlay area can be used to drag the element. But,\na child element can be marked as a draggable area by adding a\n\"`draggable`\" class to it, this will by default make all of its children draggable also.\nIf you want a child element to be draggable\nbut still have its children non-draggable (by default), mark it with\n\"`draggable-leaf-only`\" class name.",
@@ -54,6 +61,13 @@
54
61
  "kind": "expression"
55
62
  }
56
63
  },
64
+ {
65
+ "name": "?keepInViewport",
66
+ "description": "Set to true to prevent dragging the dialog outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible during dragging.\nThe dialog may still become partially hidden when the viewport is resized.",
67
+ "value": {
68
+ "kind": "expression"
69
+ }
70
+ },
57
71
  {
58
72
  "name": "?resizable",
59
73
  "description": "Set to true to enable resizing the dialog by dragging the corners and edges.",
@@ -131,6 +145,13 @@
131
145
  "kind": "expression"
132
146
  }
133
147
  },
148
+ {
149
+ "name": "@drag-start",
150
+ "description": "Fired when the dialog drag is started.",
151
+ "value": {
152
+ "kind": "expression"
153
+ }
154
+ },
134
155
  {
135
156
  "name": "@dragged",
136
157
  "description": "Fired when the dialog drag is finished.",
@@ -145,6 +166,13 @@
145
166
  "kind": "expression"
146
167
  }
147
168
  },
169
+ {
170
+ "name": "@resize-start",
171
+ "description": "Fired when the dialog resize is started.",
172
+ "value": {
173
+ "kind": "expression"
174
+ }
175
+ },
148
176
  {
149
177
  "name": "@opened-changed",
150
178
  "description": "Fired when the `opened` property changes.",