@schukai/monster 3.85.0 → 3.85.2
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/CHANGELOG.md +19 -0
- package/package.json +1 -1
- package/source/components/content/copy.mjs +381 -317
- package/source/components/datatable/columnbar.mjs +15 -36
- package/source/components/datatable/datasource/dom.mjs +1 -0
- package/source/components/datatable/datatable.mjs +757 -765
- package/source/components/datatable/stylesheet/datatable.mjs +7 -14
- package/source/components/datatable/util.mjs +1 -0
- package/source/dom/ready.mjs +1 -1
- package/source/util/deadmansswitch.mjs +13 -1
|
@@ -8,30 +8,32 @@
|
|
|
8
8
|
* For those who do not wish to adhere to the AGPLv3, a commercial license is available.
|
|
9
9
|
* Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
|
|
10
10
|
* For more information about purchasing a commercial license, please contact schukai GmbH.
|
|
11
|
+
*
|
|
12
|
+
* SPDX-License-Identifier: AGPL-3.0
|
|
11
13
|
*/
|
|
12
14
|
|
|
13
|
-
import {
|
|
15
|
+
import {instanceSymbol} from "../../constants.mjs";
|
|
14
16
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
addAttributeToken,
|
|
18
|
+
removeAttributeToken,
|
|
17
19
|
} from "../../dom/attributes.mjs";
|
|
18
20
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
ATTRIBUTE_ERRORMESSAGE,
|
|
22
|
+
ATTRIBUTE_ROLE,
|
|
21
23
|
} from "../../dom/constants.mjs";
|
|
22
|
-
import {
|
|
24
|
+
import {CustomElement} from "../../dom/customelement.mjs";
|
|
23
25
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
assembleMethodSymbol,
|
|
27
|
+
registerCustomElement,
|
|
26
28
|
} from "../../dom/customelement.mjs";
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
29
|
+
import {getDocument} from "../../dom/util.mjs";
|
|
30
|
+
import {STYLE_DISPLAY_MODE_BLOCK} from "../form/constants.mjs";
|
|
31
|
+
import {CopyStyleSheet} from "./stylesheet/copy.mjs";
|
|
32
|
+
import {fireCustomEvent} from "../../dom/events.mjs";
|
|
33
|
+
import {positionPopper} from "../form/util/floating-ui.mjs";
|
|
34
|
+
import {DeadMansSwitch} from "../../util/deadmansswitch.mjs";
|
|
33
35
|
|
|
34
|
-
export {
|
|
36
|
+
export {Copy};
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
* @private
|
|
@@ -39,6 +41,12 @@ export { Copy };
|
|
|
39
41
|
*/
|
|
40
42
|
const timerCallbackSymbol = Symbol("timerCallback");
|
|
41
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
* @type {symbol}
|
|
47
|
+
*/
|
|
48
|
+
const timerDelaySymbol = Symbol("timerDelay");
|
|
49
|
+
|
|
42
50
|
/**
|
|
43
51
|
* @private
|
|
44
52
|
* @type {symbol}
|
|
@@ -83,248 +91,265 @@ const resizeObserverSymbol = Symbol("resizeObserver");
|
|
|
83
91
|
* @summary A beautiful Copy that can make your life easier and also looks good.
|
|
84
92
|
*/
|
|
85
93
|
class Copy extends CustomElement {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
94
|
+
/**
|
|
95
|
+
* This method is called by the `instanceof` operator.
|
|
96
|
+
* @return {symbol}
|
|
97
|
+
*/
|
|
98
|
+
static get [instanceSymbol]() {
|
|
99
|
+
return Symbol.for("@schukai/monster/components/content/copy@@instance");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @return {Components.Content.Copy
|
|
105
|
+
* @fires monster-copy-clicked This event is fired when the copy button is clicked.
|
|
106
|
+
* @fires monster-copy-success This event is fired when the copy action is successful.
|
|
107
|
+
* @fires monster-copy-error This event is fired when the copy action fails.
|
|
108
|
+
*/
|
|
109
|
+
[assembleMethodSymbol]() {
|
|
110
|
+
super[assembleMethodSymbol]();
|
|
111
|
+
initControlReferences.call(this);
|
|
112
|
+
initEventHandler.call(this);
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* This method is called when the element is connected to the dom.
|
|
118
|
+
*
|
|
119
|
+
* @return {void}
|
|
120
|
+
*/
|
|
121
|
+
connectedCallback() {
|
|
122
|
+
super.connectedCallback();
|
|
123
|
+
|
|
124
|
+
const document = getDocument();
|
|
125
|
+
|
|
126
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
|
127
|
+
// close on outside ui-events
|
|
128
|
+
document.addEventListener(type, this[closeEventHandler]);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
updatePopper.call(this);
|
|
132
|
+
attachResizeObserver.call(this);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* This method is called when the element is disconnected from the dom.
|
|
137
|
+
*
|
|
138
|
+
* @return {void}
|
|
139
|
+
*/
|
|
140
|
+
disconnectedCallback() {
|
|
141
|
+
super.disconnectedCallback();
|
|
142
|
+
|
|
143
|
+
// close on outside ui-events
|
|
144
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
|
145
|
+
document.removeEventListener(type, this[closeEventHandler]);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
disconnectResizeObserver.call(this);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* To set the options via the HTML Tag, the attribute `data-monster-options` must be used.
|
|
153
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
|
154
|
+
*
|
|
155
|
+
* The individual configuration values can be found in the table.
|
|
156
|
+
*
|
|
157
|
+
* @property {Object} templates Template definitions
|
|
158
|
+
* @property {string} templates.main Main template
|
|
159
|
+
* @property {Object} actions Callbacks
|
|
160
|
+
* @property {string} actions.click="throw Error" Callback when clicked
|
|
161
|
+
* @property {Object} features Features
|
|
162
|
+
* @property {boolean} features.stripTags=true Strip tags from the copied text
|
|
163
|
+
* @property {boolean} features.preventOpenEventSent=false Prevent open event from being sent
|
|
164
|
+
* @property {Object} popper Popper configuration
|
|
165
|
+
* @property {string} popper.placement="top" Popper placement
|
|
166
|
+
* @property {string[]} popper.middleware=["autoPlacement", "shift", "offset:15", "arrow"] Popper middleware
|
|
167
|
+
* @property {boolean} disabled=false Disabled state
|
|
168
|
+
*/
|
|
169
|
+
get defaults() {
|
|
170
|
+
return Object.assign({}, super.defaults, {
|
|
171
|
+
templates: {
|
|
172
|
+
main: getTemplate(),
|
|
173
|
+
},
|
|
174
|
+
disabled: false,
|
|
175
|
+
features: {
|
|
176
|
+
stripTags: true,
|
|
177
|
+
preventOpenEventSent: false,
|
|
178
|
+
},
|
|
179
|
+
popper: {
|
|
180
|
+
placement: "top",
|
|
181
|
+
middleware: ["autoPlacement", "offset:-1", "arrow"],
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @return {string}
|
|
188
|
+
*/
|
|
189
|
+
static getTag() {
|
|
190
|
+
return "monster-copy";
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @return {CSSStyleSheet[]}
|
|
195
|
+
*/
|
|
196
|
+
static getCSSStyleSheet() {
|
|
197
|
+
return [CopyStyleSheet];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* With this method, you can show the popper.
|
|
202
|
+
*
|
|
203
|
+
* @return {Copy}
|
|
204
|
+
*/
|
|
205
|
+
showDialog() {
|
|
206
|
+
if (this[timerDelaySymbol] instanceof DeadMansSwitch) {
|
|
207
|
+
try {
|
|
208
|
+
this[timerDelaySymbol].defuse();
|
|
209
|
+
} catch (e) {
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
this[timerDelaySymbol] = new DeadMansSwitch(500, () => {
|
|
214
|
+
show.call(this);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* With this method, you can hide the popper.
|
|
222
|
+
*
|
|
223
|
+
* @return {Copy}
|
|
224
|
+
*/
|
|
225
|
+
hideDialog() {
|
|
226
|
+
if (this[timerDelaySymbol] instanceof DeadMansSwitch) {
|
|
227
|
+
try {
|
|
228
|
+
this[timerDelaySymbol].defuse();
|
|
229
|
+
} catch (e) {
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
hide.call(this);
|
|
234
|
+
return this;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* With this method, you can toggle the popper.
|
|
239
|
+
*
|
|
240
|
+
* @return {Copy}
|
|
241
|
+
*/
|
|
242
|
+
toggleDialog() {
|
|
243
|
+
if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
|
244
|
+
this.hideDialog();
|
|
245
|
+
} else {
|
|
246
|
+
this.showDialog();
|
|
247
|
+
}
|
|
248
|
+
return this;
|
|
249
|
+
}
|
|
225
250
|
}
|
|
226
251
|
|
|
227
252
|
/**
|
|
228
253
|
* @private
|
|
229
254
|
*/
|
|
230
255
|
function attachResizeObserver() {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
256
|
+
// against flickering
|
|
257
|
+
this[resizeObserverSymbol] = new ResizeObserver((entries) => {
|
|
258
|
+
if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
|
|
259
|
+
try {
|
|
260
|
+
this[timerCallbackSymbol].touch();
|
|
261
|
+
return;
|
|
262
|
+
} catch (e) {
|
|
263
|
+
delete this[timerCallbackSymbol];
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
|
|
268
|
+
updatePopper.call(this);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
this[resizeObserverSymbol].observe(this.parentElement);
|
|
248
273
|
}
|
|
249
274
|
|
|
250
275
|
/**
|
|
251
276
|
* @private
|
|
252
277
|
*/
|
|
253
278
|
function disconnectResizeObserver() {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
279
|
+
if (this[resizeObserverSymbol] instanceof ResizeObserver) {
|
|
280
|
+
this[resizeObserverSymbol].disconnect();
|
|
281
|
+
}
|
|
257
282
|
}
|
|
258
283
|
|
|
259
284
|
/**
|
|
260
285
|
* @private
|
|
261
286
|
*/
|
|
262
287
|
function hide() {
|
|
263
|
-
|
|
288
|
+
const self = this;
|
|
264
289
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
290
|
+
fireCustomEvent(self, "monster-popper-hide", {
|
|
291
|
+
self,
|
|
292
|
+
});
|
|
268
293
|
|
|
269
|
-
|
|
270
|
-
|
|
294
|
+
self[popperElementSymbol].style.display = "none";
|
|
295
|
+
removeAttributeToken(self[controlElementSymbol], "class", "open");
|
|
271
296
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
297
|
+
setTimeout(() => {
|
|
298
|
+
fireCustomEvent(self, "monster-popper-hidden", {
|
|
299
|
+
self,
|
|
300
|
+
});
|
|
301
|
+
}, 0);
|
|
277
302
|
}
|
|
278
303
|
|
|
279
304
|
/**
|
|
280
305
|
* @private
|
|
281
306
|
*/
|
|
282
307
|
function show() {
|
|
283
|
-
|
|
308
|
+
const self = this;
|
|
284
309
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
310
|
+
if (self.getOption("disabled", false) === true) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
288
313
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
314
|
+
if (self[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
292
317
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
318
|
+
fireCustomEvent(self, "monster-popper-open", {
|
|
319
|
+
self,
|
|
320
|
+
});
|
|
296
321
|
|
|
297
|
-
|
|
298
|
-
|
|
322
|
+
self[popperElementSymbol].style.visibility = "hidden";
|
|
323
|
+
self[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
|
|
299
324
|
|
|
300
|
-
|
|
301
|
-
|
|
325
|
+
addAttributeToken(self[controlElementSymbol], "class", "open");
|
|
326
|
+
updatePopper.call(self);
|
|
302
327
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
328
|
+
setTimeout(() => {
|
|
329
|
+
fireCustomEvent(self, "monster-popper-opened", {
|
|
330
|
+
self,
|
|
331
|
+
});
|
|
332
|
+
}, 0);
|
|
308
333
|
}
|
|
309
334
|
|
|
310
335
|
/**
|
|
311
336
|
* @private
|
|
312
337
|
*/
|
|
313
338
|
function updatePopper() {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
339
|
+
if (this[popperElementSymbol].style.display !== STYLE_DISPLAY_MODE_BLOCK) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (this.getOption("disabled", false) === true) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
positionPopper.call(
|
|
348
|
+
this,
|
|
349
|
+
this[controlElementSymbol],
|
|
350
|
+
this[popperElementSymbol],
|
|
351
|
+
this.getOption("popper", {}),
|
|
352
|
+
);
|
|
328
353
|
}
|
|
329
354
|
|
|
330
355
|
/**
|
|
@@ -332,92 +357,126 @@ function updatePopper() {
|
|
|
332
357
|
* @return {initEventHandler}
|
|
333
358
|
*/
|
|
334
359
|
function initEventHandler() {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
360
|
+
const self = this;
|
|
361
|
+
|
|
362
|
+
this[closeEventHandler] = (event) => {
|
|
363
|
+
const path = event.composedPath();
|
|
364
|
+
|
|
365
|
+
for (const [, element] of Object.entries(path)) {
|
|
366
|
+
if (element === this) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
hide.call(this);
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
const type = "click";
|
|
374
|
+
|
|
375
|
+
this[controlElementSymbol].addEventListener("mouseenter", (event) => {
|
|
376
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
377
|
+
event.preventDefault();
|
|
378
|
+
}
|
|
379
|
+
this.showDialog();
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
this[controlElementSymbol].addEventListener("mouseleave", (event) => {
|
|
383
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
384
|
+
event.preventDefault();
|
|
385
|
+
}
|
|
386
|
+
this.hideDialog();
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
this[controlElementSymbol].addEventListener("focus", (event) => {
|
|
390
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
391
|
+
event.preventDefault();
|
|
392
|
+
}
|
|
393
|
+
this.showDialog();
|
|
394
|
+
});
|
|
395
|
+
this[controlElementSymbol].addEventListener("blur", (event) => {
|
|
396
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
397
|
+
event.preventDefault();
|
|
398
|
+
}
|
|
399
|
+
this.hideDialog();
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
this[copyButtonElementSymbol].addEventListener(type, function (event) {
|
|
403
|
+
fireCustomEvent(self, "monster-copy-clicked", {
|
|
404
|
+
element: self,
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
const text = getSlottedCopyContent.call(self);
|
|
408
|
+
|
|
409
|
+
navigator.clipboard
|
|
410
|
+
.writeText(text)
|
|
411
|
+
.then(function () {
|
|
412
|
+
self[copyButtonElementSymbol]
|
|
413
|
+
.querySelector("use")
|
|
414
|
+
.setAttribute("href", "#copy-success");
|
|
415
|
+
setTimeout(() => {
|
|
416
|
+
self[copyButtonElementSymbol]
|
|
417
|
+
.querySelector("use")
|
|
418
|
+
.setAttribute("href", "#copy");
|
|
419
|
+
}, 2000);
|
|
420
|
+
|
|
421
|
+
fireCustomEvent(self, "monster-copy-success", {
|
|
422
|
+
element: self,
|
|
423
|
+
});
|
|
424
|
+
})
|
|
425
|
+
.catch(function (e) {
|
|
426
|
+
self[copyButtonElementSymbol]
|
|
427
|
+
.querySelector("use")
|
|
428
|
+
.setAttribute("href", "#copy-error");
|
|
429
|
+
setTimeout(() => {
|
|
430
|
+
self[copyButtonElementSymbol]
|
|
431
|
+
.querySelector("use")
|
|
432
|
+
.setAttribute("href", "#copy");
|
|
433
|
+
}, 2000);
|
|
434
|
+
|
|
435
|
+
fireCustomEvent(self, "monster-copy-error", {
|
|
436
|
+
element: self,
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, "" + e);
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
return this;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* @private
|
|
448
|
+
* @returns {Set<any>|string}
|
|
449
|
+
*/
|
|
450
|
+
function getSlottedCopyContent() {
|
|
451
|
+
const self = this;
|
|
452
|
+
const result = new Set();
|
|
453
|
+
|
|
454
|
+
if (!(this.shadowRoot instanceof ShadowRoot)) {
|
|
455
|
+
return result;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
const slots = this.shadowRoot.querySelectorAll("slot");
|
|
459
|
+
|
|
460
|
+
let text = "";
|
|
461
|
+
for (const [, slot] of Object.entries(slots)) {
|
|
462
|
+
slot.assignedNodes().forEach(function (node) {
|
|
463
|
+
if (
|
|
464
|
+
node instanceof HTMLElement ||
|
|
465
|
+
node instanceof SVGElement ||
|
|
466
|
+
node instanceof MathMLElement
|
|
467
|
+
) {
|
|
468
|
+
if (self.getOption("features.stripTags")) {
|
|
469
|
+
text += node.textContent.trim();
|
|
470
|
+
} else {
|
|
471
|
+
text += node.outerHTML.trim();
|
|
472
|
+
}
|
|
473
|
+
} else {
|
|
474
|
+
text += node.textContent.trim();
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return text;
|
|
421
480
|
}
|
|
422
481
|
|
|
423
482
|
/**
|
|
@@ -425,17 +484,17 @@ function initEventHandler() {
|
|
|
425
484
|
* @return {void}
|
|
426
485
|
*/
|
|
427
486
|
function initControlReferences() {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
487
|
+
this[controlElementSymbol] = this.shadowRoot.querySelector(
|
|
488
|
+
`[${ATTRIBUTE_ROLE}="control"]`,
|
|
489
|
+
);
|
|
431
490
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
491
|
+
this[copyButtonElementSymbol] = this.shadowRoot.querySelector(
|
|
492
|
+
`[${ATTRIBUTE_ROLE}="button"]`,
|
|
493
|
+
);
|
|
435
494
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
495
|
+
this[popperElementSymbol] = this.shadowRoot.querySelector(
|
|
496
|
+
`[${ATTRIBUTE_ROLE}="popper"]`,
|
|
497
|
+
);
|
|
439
498
|
}
|
|
440
499
|
|
|
441
500
|
/**
|
|
@@ -443,14 +502,15 @@ function initControlReferences() {
|
|
|
443
502
|
* @return {string}
|
|
444
503
|
*/
|
|
445
504
|
function getTemplate() {
|
|
446
|
-
|
|
447
|
-
|
|
505
|
+
// language=HTML
|
|
506
|
+
return `
|
|
448
507
|
<div data-monster-role="control" part="control">
|
|
449
508
|
<slot></slot>
|
|
450
509
|
<div data-monster-role="popper" part="popper" tabindex="-1" class="monster-color-primary-1">
|
|
451
510
|
<div data-monster-role="arrow"></div>
|
|
452
511
|
<button data-monster-role="button" part="button">
|
|
453
|
-
<svg data-monster-role="icon-map"
|
|
512
|
+
<svg data-monster-role="icon-map">
|
|
513
|
+
<defs>
|
|
454
514
|
<g id="copy">
|
|
455
515
|
<path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1z"/>
|
|
456
516
|
<path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0z"/>
|
|
@@ -471,7 +531,11 @@ function getTemplate() {
|
|
|
471
531
|
</g>
|
|
472
532
|
|
|
473
533
|
</defs>
|
|
474
|
-
</svg
|
|
534
|
+
</svg>
|
|
535
|
+
<svg data-monster-role="icon" xmlns="http://www.w3.org/2000/svg" width="25" height="25"
|
|
536
|
+
viewBox="0 0 16 16">
|
|
537
|
+
<use href="#copy"></use>
|
|
538
|
+
</svg>
|
|
475
539
|
</button>
|
|
476
540
|
</div>
|
|
477
541
|
</div>`;
|