@schukai/monster 3.78.0 → 3.80.0
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 +32 -0
- package/package.json +1 -1
- package/source/components/content/copy.mjs +313 -311
- package/source/components/content/stylesheet/copy.mjs +13 -6
- package/source/components/form/field-set.mjs +1 -2
- package/source/components/form/select.mjs +116 -24
- package/source/components/form/style/field-set.pcss +5 -5
- package/source/components/form/stylesheet/field-set.mjs +14 -7
- package/source/components/form/toggle-switch.mjs +319 -319
- package/source/components/layout/collapse.mjs +351 -351
- package/source/components/layout/details.mjs +1 -1
- package/source/components/layout/iframe.mjs +1 -1
- package/source/components/layout/width-toggle.mjs +2 -3
- package/source/components/state/log.mjs +151 -152
- package/source/components/state/state.mjs +1 -1
- package/source/components/stylesheet/form.mjs +13 -6
- package/source/components/tree-menu/tree-menu.mjs +2 -3
- package/source/dom/customelement.mjs +18 -1
- package/source/i18n/translations.mjs +2 -3
- package/source/monster.mjs +2 -1
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/util/jsdom.mjs +1 -2
- package/test/web/test.html +2 -2
- package/test/web/tests.js +7455 -8361
|
@@ -10,25 +10,28 @@
|
|
|
10
10
|
* For more information about purchasing a commercial license, please contact schukai GmbH.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {instanceSymbol} from "../../constants.mjs";
|
|
14
|
-
import {addAttributeToken, removeAttributeToken} from "../../dom/attributes.mjs";
|
|
13
|
+
import { instanceSymbol } from "../../constants.mjs";
|
|
15
14
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
addAttributeToken,
|
|
16
|
+
removeAttributeToken,
|
|
17
|
+
} from "../../dom/attributes.mjs";
|
|
18
|
+
import {
|
|
19
|
+
ATTRIBUTE_ERRORMESSAGE,
|
|
20
|
+
ATTRIBUTE_ROLE,
|
|
18
21
|
} from "../../dom/constants.mjs";
|
|
19
|
-
import {CustomElement, getSlottedElements} from "../../dom/customelement.mjs";
|
|
22
|
+
import { CustomElement, getSlottedElements } from "../../dom/customelement.mjs";
|
|
20
23
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
assembleMethodSymbol,
|
|
25
|
+
registerCustomElement,
|
|
23
26
|
} from "../../dom/customelement.mjs";
|
|
24
|
-
import {getDocument} from "../../dom/util.mjs";
|
|
25
|
-
import {STYLE_DISPLAY_MODE_BLOCK} from "../form/constants.mjs";
|
|
26
|
-
import {CopyStyleSheet} from "./stylesheet/copy.mjs";
|
|
27
|
-
import {fireCustomEvent} from "../../dom/events.mjs";
|
|
27
|
+
import { getDocument } from "../../dom/util.mjs";
|
|
28
|
+
import { STYLE_DISPLAY_MODE_BLOCK } from "../form/constants.mjs";
|
|
29
|
+
import { CopyStyleSheet } from "./stylesheet/copy.mjs";
|
|
30
|
+
import { fireCustomEvent } from "../../dom/events.mjs";
|
|
28
31
|
import { positionPopper } from "../form/util/floating-ui.mjs";
|
|
29
32
|
import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
|
|
30
33
|
|
|
31
|
-
export {Copy};
|
|
34
|
+
export { Copy };
|
|
32
35
|
|
|
33
36
|
/**
|
|
34
37
|
* @private
|
|
@@ -36,7 +39,6 @@ export {Copy};
|
|
|
36
39
|
*/
|
|
37
40
|
const timerCallbackSymbol = Symbol("timerCallback");
|
|
38
41
|
|
|
39
|
-
|
|
40
42
|
/**
|
|
41
43
|
* @private
|
|
42
44
|
* @type {symbol}
|
|
@@ -81,246 +83,242 @@ const resizeObserverSymbol = Symbol("resizeObserver");
|
|
|
81
83
|
* @summary A beautiful Copy that can make your life easier and also looks good.
|
|
82
84
|
*/
|
|
83
85
|
class Copy extends CustomElement {
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
return this;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
86
|
+
/**
|
|
87
|
+
* This method is called by the `instanceof` operator.
|
|
88
|
+
* @returns {symbol}
|
|
89
|
+
*/
|
|
90
|
+
static get [instanceSymbol]() {
|
|
91
|
+
return Symbol.for("@schukai/monster/components/content/copy@@instance");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @return {Components.Content.Copy
|
|
97
|
+
*/
|
|
98
|
+
[assembleMethodSymbol]() {
|
|
99
|
+
super[assembleMethodSymbol]();
|
|
100
|
+
initControlReferences.call(this);
|
|
101
|
+
initEventHandler.call(this);
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* This method is called when the element is connected to the dom.
|
|
107
|
+
*
|
|
108
|
+
* @return {void}
|
|
109
|
+
*/
|
|
110
|
+
connectedCallback() {
|
|
111
|
+
super.connectedCallback();
|
|
112
|
+
|
|
113
|
+
const document = getDocument();
|
|
114
|
+
|
|
115
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
|
116
|
+
// close on outside ui-events
|
|
117
|
+
document.addEventListener(type, this[closeEventHandler]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
updatePopper.call(this);
|
|
121
|
+
attachResizeObserver.call(this);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* This method is called when the element is disconnected from the dom.
|
|
126
|
+
*
|
|
127
|
+
* @return {void}
|
|
128
|
+
*/
|
|
129
|
+
disconnectedCallback() {
|
|
130
|
+
super.disconnectedCallback();
|
|
131
|
+
|
|
132
|
+
// close on outside ui-events
|
|
133
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
|
134
|
+
document.removeEventListener(type, this[closeEventHandler]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
disconnectResizeObserver.call(this);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* To set the options via the HTML Tag, the attribute `data-monster-options` must be used.
|
|
142
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
|
143
|
+
*
|
|
144
|
+
* The individual configuration values can be found in the table.
|
|
145
|
+
*
|
|
146
|
+
* @property {Object} templates Template definitions
|
|
147
|
+
* @property {string} templates.main Main template
|
|
148
|
+
* @property {Object} actions Callbacks
|
|
149
|
+
* @property {string} actions.click="throw Error" Callback when clicked
|
|
150
|
+
* @property {Object} features Features
|
|
151
|
+
* @property {boolean} features.stripTags=true Strip tags from the copied text
|
|
152
|
+
* @property {boolean} features.preventOpenEventSent=false Prevent open event from being sent
|
|
153
|
+
* @property {Object} popper Popper configuration
|
|
154
|
+
* @property {string} popper.placement="top" Popper placement
|
|
155
|
+
* @property {string[]} popper.middleware=["autoPlacement", "shift", "offset:15", "arrow"] Popper middleware
|
|
156
|
+
* @property {boolean} disabled=false Disabled state
|
|
157
|
+
*/
|
|
158
|
+
get defaults() {
|
|
159
|
+
return Object.assign({}, super.defaults, {
|
|
160
|
+
templates: {
|
|
161
|
+
main: getTemplate(),
|
|
162
|
+
},
|
|
163
|
+
disabled: false,
|
|
164
|
+
features: {
|
|
165
|
+
stripTags: true,
|
|
166
|
+
preventOpenEventSent: false,
|
|
167
|
+
},
|
|
168
|
+
popper: {
|
|
169
|
+
placement: "top",
|
|
170
|
+
middleware: ["autoPlacement", "shift", "offset:15", "arrow"],
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @return {string}
|
|
177
|
+
*/
|
|
178
|
+
static getTag() {
|
|
179
|
+
return "monster-copy";
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @return {CSSStyleSheet[]}
|
|
184
|
+
*/
|
|
185
|
+
static getCSSStyleSheet() {
|
|
186
|
+
return [CopyStyleSheet];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* With this method, you can show the popper.
|
|
191
|
+
*
|
|
192
|
+
* @return {Copy}
|
|
193
|
+
*/
|
|
194
|
+
showDialog() {
|
|
195
|
+
show.call(this);
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* With this method, you can hide the popper.
|
|
201
|
+
*
|
|
202
|
+
* @return {Copy}
|
|
203
|
+
*/
|
|
204
|
+
hideDialog() {
|
|
205
|
+
hide.call(this);
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* With this method, you can toggle the popper.
|
|
211
|
+
*
|
|
212
|
+
* @return {Copy}
|
|
213
|
+
*/
|
|
214
|
+
toggleDialog() {
|
|
215
|
+
if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
|
216
|
+
this.hideDialog();
|
|
217
|
+
} else {
|
|
218
|
+
this.showDialog();
|
|
219
|
+
}
|
|
220
|
+
return this;
|
|
221
|
+
}
|
|
224
222
|
}
|
|
225
223
|
|
|
226
224
|
/**
|
|
227
225
|
* @private
|
|
228
226
|
*/
|
|
229
227
|
function attachResizeObserver() {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
228
|
+
// against flickering
|
|
229
|
+
this[resizeObserverSymbol] = new ResizeObserver((entries) => {
|
|
230
|
+
if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
|
|
231
|
+
try {
|
|
232
|
+
this[timerCallbackSymbol].touch();
|
|
233
|
+
return;
|
|
234
|
+
} catch (e) {
|
|
235
|
+
delete this[timerCallbackSymbol];
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
|
|
240
|
+
updatePopper.call(this);
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
this[resizeObserverSymbol].observe(this.parentElement);
|
|
247
245
|
}
|
|
248
246
|
|
|
249
247
|
function disconnectResizeObserver() {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
248
|
+
if (this[resizeObserverSymbol] instanceof ResizeObserver) {
|
|
249
|
+
this[resizeObserverSymbol].disconnect();
|
|
250
|
+
}
|
|
253
251
|
}
|
|
254
252
|
|
|
255
253
|
/**
|
|
256
254
|
* @private
|
|
257
255
|
*/
|
|
258
256
|
function hide() {
|
|
259
|
-
|
|
257
|
+
const self = this;
|
|
260
258
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
259
|
+
fireCustomEvent(self, "monster-popper-hide", {
|
|
260
|
+
self,
|
|
261
|
+
});
|
|
264
262
|
|
|
265
|
-
|
|
266
|
-
|
|
263
|
+
self[popperElementSymbol].style.display = "none";
|
|
264
|
+
removeAttributeToken(self[controlElementSymbol], "class", "open");
|
|
267
265
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
266
|
+
setTimeout(() => {
|
|
267
|
+
fireCustomEvent(self, "monster-popper-hidden", {
|
|
268
|
+
self,
|
|
269
|
+
});
|
|
270
|
+
}, 0);
|
|
273
271
|
}
|
|
274
272
|
|
|
275
273
|
/**
|
|
276
274
|
* @private
|
|
277
275
|
*/
|
|
278
276
|
function show() {
|
|
279
|
-
|
|
277
|
+
const self = this;
|
|
280
278
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
279
|
+
if (self.getOption("disabled", false) === true) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
284
282
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
283
|
+
if (self[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
288
286
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
287
|
+
fireCustomEvent(self, "monster-popper-open", {
|
|
288
|
+
self,
|
|
289
|
+
});
|
|
292
290
|
|
|
293
|
-
|
|
294
|
-
|
|
291
|
+
self[popperElementSymbol].style.visibility = "hidden";
|
|
292
|
+
self[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
|
|
295
293
|
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
addAttributeToken(self[controlElementSymbol], "class", "open");
|
|
295
|
+
updatePopper.call(self);
|
|
298
296
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
297
|
+
setTimeout(() => {
|
|
298
|
+
fireCustomEvent(self, "monster-popper-opened", {
|
|
299
|
+
self,
|
|
300
|
+
});
|
|
301
|
+
}, 0);
|
|
304
302
|
}
|
|
305
303
|
|
|
306
304
|
/**
|
|
307
305
|
* @private
|
|
308
306
|
*/
|
|
309
307
|
function updatePopper() {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
308
|
+
if (this[popperElementSymbol].style.display !== STYLE_DISPLAY_MODE_BLOCK) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (this.getOption("disabled", false) === true) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
positionPopper.call(
|
|
317
|
+
this,
|
|
318
|
+
this[controlElementSymbol],
|
|
319
|
+
this[popperElementSymbol],
|
|
320
|
+
this.getOption("popper", {}),
|
|
321
|
+
);
|
|
324
322
|
}
|
|
325
323
|
|
|
326
324
|
/**
|
|
@@ -331,105 +329,110 @@ function updatePopper() {
|
|
|
331
329
|
* @fires monster-copy-error
|
|
332
330
|
*/
|
|
333
331
|
function initEventHandler() {
|
|
334
|
-
|
|
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
|
-
|
|
332
|
+
const self = this;
|
|
333
|
+
|
|
334
|
+
this[closeEventHandler] = (event) => {
|
|
335
|
+
const path = event.composedPath();
|
|
336
|
+
|
|
337
|
+
for (const [, element] of Object.entries(path)) {
|
|
338
|
+
if (element === this) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
hide.call(this);
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
const type = "click";
|
|
346
|
+
|
|
347
|
+
this[controlElementSymbol].addEventListener("mouseenter", (event) => {
|
|
348
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
349
|
+
event.preventDefault();
|
|
350
|
+
}
|
|
351
|
+
this.showDialog();
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
this[controlElementSymbol].addEventListener("focus", (event) => {
|
|
355
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
356
|
+
event.preventDefault();
|
|
357
|
+
}
|
|
358
|
+
this.showDialog();
|
|
359
|
+
});
|
|
360
|
+
this[controlElementSymbol].addEventListener("blur", (event) => {
|
|
361
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
362
|
+
event.preventDefault();
|
|
363
|
+
}
|
|
364
|
+
this.hideDialog();
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
this[copyButtonElementSymbol].addEventListener(type, function (event) {
|
|
368
|
+
fireCustomEvent(self, "monster-copy-clicked", {
|
|
369
|
+
element: self,
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
const nodes = getSlottedElements.call(self, ":scope");
|
|
373
|
+
|
|
374
|
+
let text = "";
|
|
375
|
+
for (const node of nodes) {
|
|
376
|
+
if (self.getOption("features.stripTags")) {
|
|
377
|
+
text += node.textContent;
|
|
378
|
+
} else {
|
|
379
|
+
text += node.outerHTML;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
navigator.clipboard
|
|
384
|
+
.writeText(text)
|
|
385
|
+
.then(function () {
|
|
386
|
+
self[copyButtonElementSymbol]
|
|
387
|
+
.querySelector("use")
|
|
388
|
+
.setAttribute("href", "#copy-success");
|
|
389
|
+
setTimeout(() => {
|
|
390
|
+
self[copyButtonElementSymbol]
|
|
391
|
+
.querySelector("use")
|
|
392
|
+
.setAttribute("href", "#copy");
|
|
393
|
+
}, 2000);
|
|
394
|
+
|
|
395
|
+
fireCustomEvent(self, "monster-copy-success", {
|
|
396
|
+
element: self,
|
|
397
|
+
});
|
|
398
|
+
})
|
|
399
|
+
.catch(function (e) {
|
|
400
|
+
self[copyButtonElementSymbol]
|
|
401
|
+
.querySelector("use")
|
|
402
|
+
.setAttribute("href", "#copy-error");
|
|
403
|
+
setTimeout(() => {
|
|
404
|
+
self[copyButtonElementSymbol]
|
|
405
|
+
.querySelector("use")
|
|
406
|
+
.setAttribute("href", "#copy");
|
|
407
|
+
}, 2000);
|
|
408
|
+
|
|
409
|
+
fireCustomEvent(self, "monster-copy-error", {
|
|
410
|
+
element: self,
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, "" + e);
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
return this;
|
|
413
418
|
}
|
|
414
419
|
|
|
415
|
-
|
|
416
420
|
/**
|
|
417
421
|
* @private
|
|
418
422
|
* @return {void}
|
|
419
423
|
*/
|
|
420
424
|
function initControlReferences() {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
this[popperElementSymbol] = this.shadowRoot.querySelector(
|
|
430
|
-
`[${ATTRIBUTE_ROLE}="popper"]`,
|
|
431
|
-
);
|
|
425
|
+
this[controlElementSymbol] = this.shadowRoot.querySelector(
|
|
426
|
+
`[${ATTRIBUTE_ROLE}="control"]`,
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
this[copyButtonElementSymbol] = this.shadowRoot.querySelector(
|
|
430
|
+
`[${ATTRIBUTE_ROLE}="button"]`,
|
|
431
|
+
);
|
|
432
432
|
|
|
433
|
+
this[popperElementSymbol] = this.shadowRoot.querySelector(
|
|
434
|
+
`[${ATTRIBUTE_ROLE}="popper"]`,
|
|
435
|
+
);
|
|
433
436
|
}
|
|
434
437
|
|
|
435
438
|
/**
|
|
@@ -437,8 +440,8 @@ function initControlReferences() {
|
|
|
437
440
|
* @return {string}
|
|
438
441
|
*/
|
|
439
442
|
function getTemplate() {
|
|
440
|
-
|
|
441
|
-
|
|
443
|
+
// language=HTML
|
|
444
|
+
return `
|
|
442
445
|
<div data-monster-role="control" part="control">
|
|
443
446
|
<slot></slot>
|
|
444
447
|
<div data-monster-role="popper" part="popper" tabindex="-1" class="monster-color-primary-1">
|
|
@@ -471,5 +474,4 @@ function getTemplate() {
|
|
|
471
474
|
</div>`;
|
|
472
475
|
}
|
|
473
476
|
|
|
474
|
-
|
|
475
477
|
registerCustomElement(Copy);
|