@vaadin/dialog 24.9.9 → 24.10.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/dialog",
3
- "version": "24.9.9",
3
+ "version": "24.10.0-alpha1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,18 +39,18 @@
39
39
  "dependencies": {
40
40
  "@open-wc/dedupe-mixin": "^1.3.0",
41
41
  "@polymer/polymer": "^3.0.0",
42
- "@vaadin/component-base": "~24.9.9",
43
- "@vaadin/lit-renderer": "~24.9.9",
44
- "@vaadin/overlay": "~24.9.9",
45
- "@vaadin/vaadin-lumo-styles": "~24.9.9",
46
- "@vaadin/vaadin-material-styles": "~24.9.9",
47
- "@vaadin/vaadin-themable-mixin": "~24.9.9",
42
+ "@vaadin/component-base": "24.10.0-alpha1",
43
+ "@vaadin/lit-renderer": "24.10.0-alpha1",
44
+ "@vaadin/overlay": "24.10.0-alpha1",
45
+ "@vaadin/vaadin-lumo-styles": "24.10.0-alpha1",
46
+ "@vaadin/vaadin-material-styles": "24.10.0-alpha1",
47
+ "@vaadin/vaadin-themable-mixin": "24.10.0-alpha1",
48
48
  "lit": "^3.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@vaadin/a11y-base": "~24.9.9",
52
- "@vaadin/chai-plugins": "~24.9.9",
53
- "@vaadin/test-runner-commands": "~24.9.9",
51
+ "@vaadin/a11y-base": "24.10.0-alpha1",
52
+ "@vaadin/chai-plugins": "24.10.0-alpha1",
53
+ "@vaadin/test-runner-commands": "24.10.0-alpha1",
54
54
  "@vaadin/testing-helpers": "^1.1.0",
55
55
  "sinon": "^18.0.0"
56
56
  },
@@ -58,5 +58,5 @@
58
58
  "web-types.json",
59
59
  "web-types.lit.json"
60
60
  ],
61
- "gitHead": "80089d4e448905887593abb1eecac3c09eb2730e"
61
+ "gitHead": "e2b8cbe144c13ed63b21c5deba3659a4e6058874"
62
62
  }
@@ -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,
@@ -106,8 +119,22 @@ export const DialogDraggableMixin = (superClass) =>
106
119
  _drag(e) {
107
120
  const event = getMouseOrFirstTouchEvent(e);
108
121
  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);
122
+ let top = this._originalBounds.top + (event.pageY - this._originalMouseCoords.top);
123
+ let left = this._originalBounds.left + (event.pageX - this._originalMouseCoords.left);
124
+
125
+ if (this.keepInViewport) {
126
+ const { width, height } = this._originalBounds;
127
+ // Get the overlay container's position to account for its offset from the viewport
128
+ const containerBounds = this.$.overlay.getBoundingClientRect();
129
+ // Calculate bounds so the dialog's visual edges stay within the viewport
130
+ const minLeft = -containerBounds.left;
131
+ const maxLeft = window.innerWidth - containerBounds.left - width;
132
+ const minTop = -containerBounds.top;
133
+ const maxTop = window.innerHeight - containerBounds.top - height;
134
+ left = Math.max(minLeft, Math.min(left, maxLeft));
135
+ top = Math.max(minTop, Math.min(top, maxTop));
136
+ }
137
+
111
138
  this.top = top;
112
139
  this.left = left;
113
140
  }
package/web-types.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/dialog",
4
- "version": "24.9.9",
4
+ "version": "24.10.0-alpha1",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "elements": [
9
9
  {
10
10
  "name": "vaadin-dialog",
11
- "description": "`<vaadin-dialog>` is a Web Component for creating customized modal dialogs.\n\n### Rendering\n\nThe content of the dialog can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `dialog` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `dialog`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-dialog id=\"dialog\"></vaadin-dialog>\n```\n```js\nconst dialog = document.querySelector('#dialog');\ndialog.renderer = function(root, dialog) {\n root.textContent = \"Sample dialog\";\n};\n```\n\nRenderer is called on the opening of the dialog.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### Styling\n\n`<vaadin-dialog>` uses `<vaadin-dialog-overlay>` internal\nthemable component as the actual visible dialog overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.9.9/#/elements/vaadin-overlay) documentation.\nfor `<vaadin-dialog-overlay>` parts.\n\nIn addition to `<vaadin-overlay>` parts, the following parts are available for styling:\n\nPart name | Description\n-----------------|-------------------------------------------\n`header` | Element wrapping title and header content\n`header-content` | Element wrapping the header content slot\n`title` | Element wrapping the title slot\n`footer` | Element wrapping the footer slot\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-----------------|--------------------------------------------\n`has-title` | Set when the element has a title\n`has-header` | Set when the element has header renderer\n`has-footer` | Set when the element has footer renderer\n`overflow` | Set to `top`, `bottom`, none or both\n\nNote: the `theme` attribute value set on `<vaadin-dialog>` is\npropagated to the internal `<vaadin-dialog-overlay>` component.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
11
+ "description": "`<vaadin-dialog>` is a Web Component for creating customized modal dialogs.\n\n### Rendering\n\nThe content of the dialog can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `dialog` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `dialog`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-dialog id=\"dialog\"></vaadin-dialog>\n```\n```js\nconst dialog = document.querySelector('#dialog');\ndialog.renderer = function(root, dialog) {\n root.textContent = \"Sample dialog\";\n};\n```\n\nRenderer is called on the opening of the dialog.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### Styling\n\n`<vaadin-dialog>` uses `<vaadin-dialog-overlay>` internal\nthemable component as the actual visible dialog overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.10.0-alpha1/#/elements/vaadin-overlay) documentation.\nfor `<vaadin-dialog-overlay>` parts.\n\nIn addition to `<vaadin-overlay>` parts, the following parts are available for styling:\n\nPart name | Description\n-----------------|-------------------------------------------\n`header` | Element wrapping title and header content\n`header-content` | Element wrapping the header content slot\n`title` | Element wrapping the title slot\n`footer` | Element wrapping the footer slot\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-----------------|--------------------------------------------\n`has-title` | Set when the element has a title\n`has-header` | Set when the element has header renderer\n`has-footer` | Set when the element has footer renderer\n`overflow` | Set to `top`, `bottom`, none or both\n\nNote: the `theme` attribute value set on `<vaadin-dialog>` is\npropagated to the internal `<vaadin-dialog-overlay>` component.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "opened",
@@ -110,6 +110,15 @@
110
110
  ]
111
111
  }
112
112
  },
113
+ {
114
+ "name": "keep-in-viewport",
115
+ "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.",
116
+ "value": {
117
+ "type": [
118
+ "boolean"
119
+ ]
120
+ }
121
+ },
113
122
  {
114
123
  "name": "header-title",
115
124
  "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 added to the overlay element.",
@@ -266,6 +275,15 @@
266
275
  ]
267
276
  }
268
277
  },
278
+ {
279
+ "name": "keepInViewport",
280
+ "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.",
281
+ "value": {
282
+ "type": [
283
+ "boolean"
284
+ ]
285
+ }
286
+ },
269
287
  {
270
288
  "name": "renderer",
271
289
  "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.",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/dialog",
4
- "version": "24.9.9",
4
+ "version": "24.10.0-alpha1",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -16,7 +16,7 @@
16
16
  "elements": [
17
17
  {
18
18
  "name": "vaadin-dialog",
19
- "description": "`<vaadin-dialog>` is a Web Component for creating customized modal dialogs.\n\n### Rendering\n\nThe content of the dialog can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `dialog` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `dialog`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-dialog id=\"dialog\"></vaadin-dialog>\n```\n```js\nconst dialog = document.querySelector('#dialog');\ndialog.renderer = function(root, dialog) {\n root.textContent = \"Sample dialog\";\n};\n```\n\nRenderer is called on the opening of the dialog.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### Styling\n\n`<vaadin-dialog>` uses `<vaadin-dialog-overlay>` internal\nthemable component as the actual visible dialog overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.9.9/#/elements/vaadin-overlay) documentation.\nfor `<vaadin-dialog-overlay>` parts.\n\nIn addition to `<vaadin-overlay>` parts, the following parts are available for styling:\n\nPart name | Description\n-----------------|-------------------------------------------\n`header` | Element wrapping title and header content\n`header-content` | Element wrapping the header content slot\n`title` | Element wrapping the title slot\n`footer` | Element wrapping the footer slot\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-----------------|--------------------------------------------\n`has-title` | Set when the element has a title\n`has-header` | Set when the element has header renderer\n`has-footer` | Set when the element has footer renderer\n`overflow` | Set to `top`, `bottom`, none or both\n\nNote: the `theme` attribute value set on `<vaadin-dialog>` is\npropagated to the internal `<vaadin-dialog-overlay>` component.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
19
+ "description": "`<vaadin-dialog>` is a Web Component for creating customized modal dialogs.\n\n### Rendering\n\nThe content of the dialog can be populated by using the renderer callback function.\n\nThe renderer function provides `root`, `dialog` arguments.\nGenerate DOM content, append it to the `root` element and control the state\nof the host element by accessing `dialog`. Before generating new content,\nusers are able to check if there is already content in `root` for reusing it.\n\n```html\n<vaadin-dialog id=\"dialog\"></vaadin-dialog>\n```\n```js\nconst dialog = document.querySelector('#dialog');\ndialog.renderer = function(root, dialog) {\n root.textContent = \"Sample dialog\";\n};\n```\n\nRenderer is called on the opening of the dialog.\nDOM generated during the renderer call can be reused\nin the next renderer call and will be provided with the `root` argument.\nOn first call it will be empty.\n\n### Styling\n\n`<vaadin-dialog>` uses `<vaadin-dialog-overlay>` internal\nthemable component as the actual visible dialog overlay.\n\nSee [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.10.0-alpha1/#/elements/vaadin-overlay) documentation.\nfor `<vaadin-dialog-overlay>` parts.\n\nIn addition to `<vaadin-overlay>` parts, the following parts are available for styling:\n\nPart name | Description\n-----------------|-------------------------------------------\n`header` | Element wrapping title and header content\n`header-content` | Element wrapping the header content slot\n`title` | Element wrapping the title slot\n`footer` | Element wrapping the footer slot\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n-----------------|--------------------------------------------\n`has-title` | Set when the element has a title\n`has-header` | Set when the element has header renderer\n`has-footer` | Set when the element has footer renderer\n`overflow` | Set to `top`, `bottom`, none or both\n\nNote: the `theme` attribute value set on `<vaadin-dialog>` is\npropagated to the internal `<vaadin-dialog-overlay>` component.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {
@@ -54,6 +54,13 @@
54
54
  "kind": "expression"
55
55
  }
56
56
  },
57
+ {
58
+ "name": "?keepInViewport",
59
+ "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.",
60
+ "value": {
61
+ "kind": "expression"
62
+ }
63
+ },
57
64
  {
58
65
  "name": "?resizable",
59
66
  "description": "Set to true to enable resizing the dialog by dragging the corners and edges.",