@nectary/components 3.0.0 → 3.0.1

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.
@@ -100,12 +100,16 @@ template.innerHTML = templateHTML;
100
100
  return (0, _utils.getRect)(this.#$closeButton);
101
101
  }
102
102
  #onCancel = e => {
103
- e.preventDefault();
103
+ if (e.cancelable) {
104
+ e.preventDefault();
105
+ } else {
106
+ this.#onCollapse();
107
+ }
104
108
  e.stopPropagation();
105
- this.#dispatchCloseEvent('escape');
109
+ this.#dispatchCloseEvent('escape', e.cancelable);
106
110
  };
107
111
  #onCloseClick = () => {
108
- this.#dispatchCloseEvent('close');
112
+ this.#dispatchCloseEvent('close', true);
109
113
  };
110
114
  #onBackdropMouseDown = e => {
111
115
  if ((0, _utils.isTargetEqual)(e, this.#$dialog)) {
@@ -113,16 +117,17 @@ template.innerHTML = templateHTML;
113
117
  const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
114
118
  if (!isInside) {
115
119
  e.stopPropagation();
116
- this.#dispatchCloseEvent('backdrop');
120
+ this.#dispatchCloseEvent('backdrop', e.cancelable);
117
121
  }
118
122
  }
119
123
  };
120
124
  #onCloseReactHandler = e => {
121
125
  (0, _utils.getReactEventHandler)(this, 'on-close')?.(e);
122
126
  };
123
- #dispatchCloseEvent(detail) {
127
+ #dispatchCloseEvent(detail, cancelable) {
124
128
  this.dispatchEvent(new CustomEvent('-close', {
125
- detail
129
+ detail,
130
+ cancelable
126
131
  }));
127
132
  }
128
133
  #onExpand() {
@@ -98,12 +98,16 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
98
98
  return getRect(this.#$closeButton);
99
99
  }
100
100
  #onCancel = e => {
101
- e.preventDefault();
101
+ if (e.cancelable) {
102
+ e.preventDefault();
103
+ } else {
104
+ this.#onCollapse();
105
+ }
102
106
  e.stopPropagation();
103
- this.#dispatchCloseEvent('escape');
107
+ this.#dispatchCloseEvent('escape', e.cancelable);
104
108
  };
105
109
  #onCloseClick = () => {
106
- this.#dispatchCloseEvent('close');
110
+ this.#dispatchCloseEvent('close', true);
107
111
  };
108
112
  #onBackdropMouseDown = e => {
109
113
  if (isTargetEqual(e, this.#$dialog)) {
@@ -111,16 +115,17 @@ defineCustomElement('sinch-dialog', class extends NectaryElement {
111
115
  const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
112
116
  if (!isInside) {
113
117
  e.stopPropagation();
114
- this.#dispatchCloseEvent('backdrop');
118
+ this.#dispatchCloseEvent('backdrop', e.cancelable);
115
119
  }
116
120
  }
117
121
  };
118
122
  #onCloseReactHandler = e => {
119
123
  getReactEventHandler(this, 'on-close')?.(e);
120
124
  };
121
- #dispatchCloseEvent(detail) {
125
+ #dispatchCloseEvent(detail, cancelable) {
122
126
  this.dispatchEvent(new CustomEvent('-close', {
123
- detail
127
+ detail,
128
+ cancelable
124
129
  }));
125
130
  }
126
131
  #onExpand() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "files": [
5
5
  "lib"
6
6
  ],