goodteditor-ui 1.0.14 → 1.0.15
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 +3 -2
- package/src/components/ui/Popover.vue +42 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goodteditor-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"homepage": "https://goodt-ui.netlify.app/",
|
|
6
6
|
"scripts": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"dev": "vue-styleguidist server",
|
|
11
11
|
"docs:build": "set NODE_ENV=development && vue-styleguidist build",
|
|
12
12
|
"docs:deploy": "npx netlify deploy --dir=docs --prod",
|
|
13
|
-
"notify": "node ./ci/teams-notify.js"
|
|
13
|
+
"notify": "node ./ci/teams-notify.js",
|
|
14
|
+
"publish": "npm run docs:build && npm run docs:deploy && npm run notify"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
@@ -23,6 +23,19 @@ import { Position, generateGetBoundingClientRect } from './utils/Helpers';
|
|
|
23
23
|
|
|
24
24
|
const isElem = el => el instanceof HTMLElement;
|
|
25
25
|
|
|
26
|
+
const isCoordinates = (target) => {
|
|
27
|
+
if (Array.isArray(target) === false) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (target.length !== 2) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (target.some((item) => Number.isNaN(Number(item)))) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
26
39
|
const Strategy = Object.freeze({
|
|
27
40
|
ABSOLUTE: 'absolute',
|
|
28
41
|
FIXED: 'fixed'
|
|
@@ -51,7 +64,7 @@ export default {
|
|
|
51
64
|
},
|
|
52
65
|
props: {
|
|
53
66
|
/**
|
|
54
|
-
* Target HTMLElement
|
|
67
|
+
* Target HTMLElement|selector|array of coordinates used for positioning
|
|
55
68
|
*/
|
|
56
69
|
target: { default: null },
|
|
57
70
|
/**
|
|
@@ -107,25 +120,11 @@ export default {
|
|
|
107
120
|
default: false,
|
|
108
121
|
},
|
|
109
122
|
/**
|
|
110
|
-
* Should
|
|
111
|
-
*/
|
|
112
|
-
shouldFollowCursor: {
|
|
113
|
-
type: Boolean,
|
|
114
|
-
default: false
|
|
115
|
-
},
|
|
116
|
-
/**
|
|
117
|
-
* Cursor coordinates [ x, y ]
|
|
118
|
-
*/
|
|
119
|
-
cursorCoordinates: {
|
|
120
|
-
type: Array,
|
|
121
|
-
default: () => [0, 0]
|
|
122
|
-
},
|
|
123
|
-
/**
|
|
124
|
-
* Whether handle events to control visibility
|
|
123
|
+
* Should respond to pointer events
|
|
125
124
|
*/
|
|
126
|
-
|
|
125
|
+
shouldRespondToPointerEvents: {
|
|
127
126
|
type: Boolean,
|
|
128
|
-
default:
|
|
127
|
+
default: true
|
|
129
128
|
}
|
|
130
129
|
},
|
|
131
130
|
data() {
|
|
@@ -172,7 +171,7 @@ export default {
|
|
|
172
171
|
return;
|
|
173
172
|
}
|
|
174
173
|
|
|
175
|
-
if (this.
|
|
174
|
+
if (isCoordinates(this.target) === false) {
|
|
176
175
|
this.addEventListeners();
|
|
177
176
|
}
|
|
178
177
|
|
|
@@ -198,46 +197,51 @@ export default {
|
|
|
198
197
|
document.removeEventListener('mousedown', this.onDocMouseDown);
|
|
199
198
|
},
|
|
200
199
|
calcStyle() {
|
|
201
|
-
const { zIndex, autoWidth } = this;
|
|
200
|
+
const { zIndex, autoWidth, shouldRespondToPointerEvents } = this;
|
|
202
201
|
const target = this.getTarget();
|
|
203
202
|
const style = { zIndex };
|
|
204
203
|
if (autoWidth && target) {
|
|
205
204
|
const b = target.getBoundingClientRect();
|
|
206
205
|
style.width = `${b.width}px`;
|
|
207
206
|
}
|
|
207
|
+
if (shouldRespondToPointerEvents === false) {
|
|
208
|
+
style.pointerEvents = 'none';
|
|
209
|
+
}
|
|
208
210
|
this.cssStyle = style;
|
|
209
211
|
},
|
|
210
212
|
getTarget() {
|
|
211
|
-
|
|
212
|
-
return isElem(target) ? target : document.querySelector(target);
|
|
213
|
+
const { target } = this;
|
|
214
|
+
return isCoordinates(target) ? null : isElem(target) ? target : document.querySelector(target);
|
|
213
215
|
},
|
|
214
216
|
setShow(val) {
|
|
215
217
|
this.$nextTick(() => this.$emit('update:show', val));
|
|
216
218
|
},
|
|
217
219
|
createPopper() {
|
|
218
|
-
const {
|
|
220
|
+
const { options, $el: popper } = this;
|
|
219
221
|
const target = this.getTarget();
|
|
220
222
|
|
|
221
|
-
if (
|
|
222
|
-
|
|
223
|
+
if (target != null) {
|
|
224
|
+
this.popper = createPopper(target, popper, options);
|
|
225
|
+
this.$nextTick(this.updatePopper);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (isCoordinates(this.target)) {
|
|
230
|
+
const [x, y] = this.target;
|
|
223
231
|
const virtualElem = {
|
|
224
232
|
getBoundingClientRect: generateGetBoundingClientRect(x, y),
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
233
|
+
};
|
|
228
234
|
this.popper = createPopper(virtualElem, popper, options);
|
|
229
|
-
this
|
|
235
|
+
this.$nextTick(this.updatePopper);
|
|
236
|
+
this.unwatchCursorCoordinates = this.$watch('target', ([x, y]) => {
|
|
230
237
|
virtualElem.getBoundingClientRect = generateGetBoundingClientRect(x, y);
|
|
231
238
|
this.popper?.update();
|
|
232
|
-
})
|
|
233
|
-
} else {
|
|
234
|
-
this.popper = createPopper(target, popper, options);
|
|
239
|
+
});
|
|
235
240
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
});
|
|
241
|
+
},
|
|
242
|
+
updatePopper() {
|
|
243
|
+
this.calcStyle();
|
|
244
|
+
this.popper.update();
|
|
241
245
|
},
|
|
242
246
|
destroyPopper() {
|
|
243
247
|
this.popper?.destroy();
|
|
@@ -245,7 +249,7 @@ export default {
|
|
|
245
249
|
},
|
|
246
250
|
handleReset() {
|
|
247
251
|
this.unwatchCursorCoordinates?.();
|
|
248
|
-
if (this.
|
|
252
|
+
if (isCoordinates(this.target) === false) {
|
|
249
253
|
this.removeEventListeners();
|
|
250
254
|
}
|
|
251
255
|
this.destroyPopper();
|