@schukai/monster 3.86.0 → 3.86.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 +16 -0
- package/package.json +1 -1
- package/source/components/content/copy.mjs +357 -359
- package/source/components/datatable/columnbar.mjs +5 -8
- package/source/components/datatable/datasource/dom.mjs +0 -1
- package/source/components/datatable/datatable.mjs +741 -741
- package/source/components/datatable/style/column-bar.pcss +27 -19
- package/source/components/datatable/style/datatable.pcss +6 -1
- package/source/components/datatable/stylesheet/column-bar.mjs +1 -1
- package/source/components/datatable/stylesheet/datatable.mjs +14 -7
- package/source/components/datatable/util.mjs +0 -1
- package/source/components/form/button-bar.mjs +1 -3
- package/source/components/form/style/field-set.pcss +41 -56
- package/source/components/form/stylesheet/button-bar.mjs +13 -6
- package/source/components/form/stylesheet/button.mjs +13 -6
- package/source/components/form/stylesheet/confirm-button.mjs +13 -6
- package/source/components/form/stylesheet/field-set.mjs +1 -1
- package/source/components/form/stylesheet/message-state-button.mjs +13 -6
- package/source/components/form/stylesheet/popper-button.mjs +13 -6
- package/source/components/form/stylesheet/select.mjs +13 -6
- package/source/components/form/stylesheet/state-button.mjs +13 -6
- package/source/components/layout/details.mjs +2 -2
- package/source/components/layout/stylesheet/panel.mjs +13 -6
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/test.html +2 -2
- package/test/web/tests.js +192 -270
|
@@ -12,28 +12,28 @@
|
|
|
12
12
|
* SPDX-License-Identifier: AGPL-3.0
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {instanceSymbol} from "../../constants.mjs";
|
|
15
|
+
import { instanceSymbol } from "../../constants.mjs";
|
|
16
16
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
addAttributeToken,
|
|
18
|
+
removeAttributeToken,
|
|
19
19
|
} from "../../dom/attributes.mjs";
|
|
20
20
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
ATTRIBUTE_ERRORMESSAGE,
|
|
22
|
+
ATTRIBUTE_ROLE,
|
|
23
23
|
} from "../../dom/constants.mjs";
|
|
24
|
-
import {CustomElement} from "../../dom/customelement.mjs";
|
|
24
|
+
import { CustomElement } from "../../dom/customelement.mjs";
|
|
25
25
|
import {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
assembleMethodSymbol,
|
|
27
|
+
registerCustomElement,
|
|
28
28
|
} from "../../dom/customelement.mjs";
|
|
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";
|
|
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";
|
|
35
35
|
|
|
36
|
-
export {Copy};
|
|
36
|
+
export { Copy };
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* @private
|
|
@@ -91,265 +91,263 @@ const resizeObserverSymbol = Symbol("resizeObserver");
|
|
|
91
91
|
* @summary A beautiful Copy that can make your life easier and also looks good.
|
|
92
92
|
*/
|
|
93
93
|
class Copy extends CustomElement {
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
return this;
|
|
249
|
-
}
|
|
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
|
+
this[timerDelaySymbol] = new DeadMansSwitch(500, () => {
|
|
213
|
+
show.call(this);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
return this;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* With this method, you can hide the popper.
|
|
221
|
+
*
|
|
222
|
+
* @return {Copy}
|
|
223
|
+
*/
|
|
224
|
+
hideDialog() {
|
|
225
|
+
if (this[timerDelaySymbol] instanceof DeadMansSwitch) {
|
|
226
|
+
try {
|
|
227
|
+
this[timerDelaySymbol].defuse();
|
|
228
|
+
} catch (e) {}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
hide.call(this);
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* With this method, you can toggle the popper.
|
|
237
|
+
*
|
|
238
|
+
* @return {Copy}
|
|
239
|
+
*/
|
|
240
|
+
toggleDialog() {
|
|
241
|
+
if (this[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
|
242
|
+
this.hideDialog();
|
|
243
|
+
} else {
|
|
244
|
+
this.showDialog();
|
|
245
|
+
}
|
|
246
|
+
return this;
|
|
247
|
+
}
|
|
250
248
|
}
|
|
251
249
|
|
|
252
250
|
/**
|
|
253
251
|
* @private
|
|
254
252
|
*/
|
|
255
253
|
function attachResizeObserver() {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
254
|
+
// against flickering
|
|
255
|
+
this[resizeObserverSymbol] = new ResizeObserver((entries) => {
|
|
256
|
+
if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
|
|
257
|
+
try {
|
|
258
|
+
this[timerCallbackSymbol].touch();
|
|
259
|
+
return;
|
|
260
|
+
} catch (e) {
|
|
261
|
+
delete this[timerCallbackSymbol];
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
|
|
266
|
+
updatePopper.call(this);
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
this[resizeObserverSymbol].observe(this.parentElement);
|
|
273
271
|
}
|
|
274
272
|
|
|
275
273
|
/**
|
|
276
274
|
* @private
|
|
277
275
|
*/
|
|
278
276
|
function disconnectResizeObserver() {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
277
|
+
if (this[resizeObserverSymbol] instanceof ResizeObserver) {
|
|
278
|
+
this[resizeObserverSymbol].disconnect();
|
|
279
|
+
}
|
|
282
280
|
}
|
|
283
281
|
|
|
284
282
|
/**
|
|
285
283
|
* @private
|
|
286
284
|
*/
|
|
287
285
|
function hide() {
|
|
288
|
-
|
|
286
|
+
const self = this;
|
|
289
287
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
288
|
+
fireCustomEvent(self, "monster-popper-hide", {
|
|
289
|
+
self,
|
|
290
|
+
});
|
|
293
291
|
|
|
294
|
-
|
|
295
|
-
|
|
292
|
+
self[popperElementSymbol].style.display = "none";
|
|
293
|
+
removeAttributeToken(self[controlElementSymbol], "class", "open");
|
|
296
294
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
295
|
+
setTimeout(() => {
|
|
296
|
+
fireCustomEvent(self, "monster-popper-hidden", {
|
|
297
|
+
self,
|
|
298
|
+
});
|
|
299
|
+
}, 0);
|
|
302
300
|
}
|
|
303
301
|
|
|
304
302
|
/**
|
|
305
303
|
* @private
|
|
306
304
|
*/
|
|
307
305
|
function show() {
|
|
308
|
-
|
|
306
|
+
const self = this;
|
|
309
307
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
308
|
+
if (self.getOption("disabled", false) === true) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
313
311
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
312
|
+
if (self[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
317
315
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
316
|
+
fireCustomEvent(self, "monster-popper-open", {
|
|
317
|
+
self,
|
|
318
|
+
});
|
|
321
319
|
|
|
322
|
-
|
|
323
|
-
|
|
320
|
+
self[popperElementSymbol].style.visibility = "hidden";
|
|
321
|
+
self[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
|
|
324
322
|
|
|
325
|
-
|
|
326
|
-
|
|
323
|
+
addAttributeToken(self[controlElementSymbol], "class", "open");
|
|
324
|
+
updatePopper.call(self);
|
|
327
325
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
326
|
+
setTimeout(() => {
|
|
327
|
+
fireCustomEvent(self, "monster-popper-opened", {
|
|
328
|
+
self,
|
|
329
|
+
});
|
|
330
|
+
}, 0);
|
|
333
331
|
}
|
|
334
332
|
|
|
335
333
|
/**
|
|
336
334
|
* @private
|
|
337
335
|
*/
|
|
338
336
|
function updatePopper() {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
337
|
+
if (this[popperElementSymbol].style.display !== STYLE_DISPLAY_MODE_BLOCK) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
if (this.getOption("disabled", false) === true) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
positionPopper.call(
|
|
346
|
+
this,
|
|
347
|
+
this[controlElementSymbol],
|
|
348
|
+
this[popperElementSymbol],
|
|
349
|
+
this.getOption("popper", {}),
|
|
350
|
+
);
|
|
353
351
|
}
|
|
354
352
|
|
|
355
353
|
/**
|
|
@@ -357,90 +355,90 @@ function updatePopper() {
|
|
|
357
355
|
* @return {initEventHandler}
|
|
358
356
|
*/
|
|
359
357
|
function initEventHandler() {
|
|
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
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
358
|
+
const self = this;
|
|
359
|
+
|
|
360
|
+
this[closeEventHandler] = (event) => {
|
|
361
|
+
const path = event.composedPath();
|
|
362
|
+
|
|
363
|
+
for (const [, element] of Object.entries(path)) {
|
|
364
|
+
if (element === this) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
hide.call(this);
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
const type = "click";
|
|
372
|
+
|
|
373
|
+
this[controlElementSymbol].addEventListener("mouseenter", (event) => {
|
|
374
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
375
|
+
event.preventDefault();
|
|
376
|
+
}
|
|
377
|
+
this.showDialog();
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
this[controlElementSymbol].addEventListener("mouseleave", (event) => {
|
|
381
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
382
|
+
event.preventDefault();
|
|
383
|
+
}
|
|
384
|
+
this.hideDialog();
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
this[controlElementSymbol].addEventListener("focus", (event) => {
|
|
388
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
389
|
+
event.preventDefault();
|
|
390
|
+
}
|
|
391
|
+
this.showDialog();
|
|
392
|
+
});
|
|
393
|
+
this[controlElementSymbol].addEventListener("blur", (event) => {
|
|
394
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
395
|
+
event.preventDefault();
|
|
396
|
+
}
|
|
397
|
+
this.hideDialog();
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
this[copyButtonElementSymbol].addEventListener(type, function (event) {
|
|
401
|
+
fireCustomEvent(self, "monster-copy-clicked", {
|
|
402
|
+
element: self,
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
const text = getSlottedCopyContent.call(self);
|
|
406
|
+
|
|
407
|
+
navigator.clipboard
|
|
408
|
+
.writeText(text)
|
|
409
|
+
.then(function () {
|
|
410
|
+
self[copyButtonElementSymbol]
|
|
411
|
+
.querySelector("use")
|
|
412
|
+
.setAttribute("href", "#copy-success");
|
|
413
|
+
setTimeout(() => {
|
|
414
|
+
self[copyButtonElementSymbol]
|
|
415
|
+
.querySelector("use")
|
|
416
|
+
.setAttribute("href", "#copy");
|
|
417
|
+
}, 2000);
|
|
418
|
+
|
|
419
|
+
fireCustomEvent(self, "monster-copy-success", {
|
|
420
|
+
element: self,
|
|
421
|
+
});
|
|
422
|
+
})
|
|
423
|
+
.catch(function (e) {
|
|
424
|
+
self[copyButtonElementSymbol]
|
|
425
|
+
.querySelector("use")
|
|
426
|
+
.setAttribute("href", "#copy-error");
|
|
427
|
+
setTimeout(() => {
|
|
428
|
+
self[copyButtonElementSymbol]
|
|
429
|
+
.querySelector("use")
|
|
430
|
+
.setAttribute("href", "#copy");
|
|
431
|
+
}, 2000);
|
|
432
|
+
|
|
433
|
+
fireCustomEvent(self, "monster-copy-error", {
|
|
434
|
+
element: self,
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, "" + e);
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
return this;
|
|
444
442
|
}
|
|
445
443
|
|
|
446
444
|
/**
|
|
@@ -448,35 +446,35 @@ function initEventHandler() {
|
|
|
448
446
|
* @returns {Set<any>|string}
|
|
449
447
|
*/
|
|
450
448
|
function getSlottedCopyContent() {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
449
|
+
const self = this;
|
|
450
|
+
const result = new Set();
|
|
451
|
+
|
|
452
|
+
if (!(this.shadowRoot instanceof ShadowRoot)) {
|
|
453
|
+
return result;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const slots = this.shadowRoot.querySelectorAll("slot");
|
|
457
|
+
|
|
458
|
+
let text = "";
|
|
459
|
+
for (const [, slot] of Object.entries(slots)) {
|
|
460
|
+
slot.assignedNodes().forEach(function (node) {
|
|
461
|
+
if (
|
|
462
|
+
node instanceof HTMLElement ||
|
|
463
|
+
node instanceof SVGElement ||
|
|
464
|
+
node instanceof MathMLElement
|
|
465
|
+
) {
|
|
466
|
+
if (self.getOption("features.stripTags")) {
|
|
467
|
+
text += node.textContent.trim();
|
|
468
|
+
} else {
|
|
469
|
+
text += node.outerHTML.trim();
|
|
470
|
+
}
|
|
471
|
+
} else {
|
|
472
|
+
text += node.textContent.trim();
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return text;
|
|
480
478
|
}
|
|
481
479
|
|
|
482
480
|
/**
|
|
@@ -484,17 +482,17 @@ function getSlottedCopyContent() {
|
|
|
484
482
|
* @return {void}
|
|
485
483
|
*/
|
|
486
484
|
function initControlReferences() {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
485
|
+
this[controlElementSymbol] = this.shadowRoot.querySelector(
|
|
486
|
+
`[${ATTRIBUTE_ROLE}="control"]`,
|
|
487
|
+
);
|
|
490
488
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
489
|
+
this[copyButtonElementSymbol] = this.shadowRoot.querySelector(
|
|
490
|
+
`[${ATTRIBUTE_ROLE}="button"]`,
|
|
491
|
+
);
|
|
494
492
|
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
493
|
+
this[popperElementSymbol] = this.shadowRoot.querySelector(
|
|
494
|
+
`[${ATTRIBUTE_ROLE}="popper"]`,
|
|
495
|
+
);
|
|
498
496
|
}
|
|
499
497
|
|
|
500
498
|
/**
|
|
@@ -502,8 +500,8 @@ function initControlReferences() {
|
|
|
502
500
|
* @return {string}
|
|
503
501
|
*/
|
|
504
502
|
function getTemplate() {
|
|
505
|
-
|
|
506
|
-
|
|
503
|
+
// language=HTML
|
|
504
|
+
return `
|
|
507
505
|
<div data-monster-role="control" part="control">
|
|
508
506
|
<slot></slot>
|
|
509
507
|
<div data-monster-role="popper" part="popper" tabindex="-1" class="monster-color-primary-1">
|