@schukai/monster 3.77.0 → 3.78.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
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.11","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"3.
|
|
1
|
+
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.11","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"3.78.0"}
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. All rights reserved.
|
|
3
|
+
* Node module: @schukai/monster
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
|
|
6
|
+
* The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
|
|
7
|
+
*
|
|
8
|
+
* For those who do not wish to adhere to the AGPLv3, a commercial license is available.
|
|
9
|
+
* Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
|
|
10
|
+
* For more information about purchasing a commercial license, please contact schukai GmbH.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {instanceSymbol} from "../../constants.mjs";
|
|
14
|
+
import {addAttributeToken, removeAttributeToken} from "../../dom/attributes.mjs";
|
|
15
|
+
import {
|
|
16
|
+
ATTRIBUTE_ERRORMESSAGE,
|
|
17
|
+
ATTRIBUTE_ROLE,
|
|
18
|
+
} from "../../dom/constants.mjs";
|
|
19
|
+
import {CustomElement, getSlottedElements} from "../../dom/customelement.mjs";
|
|
20
|
+
import {
|
|
21
|
+
assembleMethodSymbol,
|
|
22
|
+
registerCustomElement,
|
|
23
|
+
} 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";
|
|
28
|
+
import { positionPopper } from "../form/util/floating-ui.mjs";
|
|
29
|
+
import { DeadMansSwitch } from "../../util/deadmansswitch.mjs";
|
|
30
|
+
|
|
31
|
+
export {Copy};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @private
|
|
35
|
+
* @type {symbol}
|
|
36
|
+
*/
|
|
37
|
+
const timerCallbackSymbol = Symbol("timerCallback");
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @private
|
|
42
|
+
* @type {symbol}
|
|
43
|
+
*/
|
|
44
|
+
export const controlElementSymbol = Symbol("copyElement");
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @private
|
|
48
|
+
* @type {symbol}
|
|
49
|
+
*/
|
|
50
|
+
export const popperElementSymbol = Symbol("popperElement");
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @private
|
|
54
|
+
* @type {symbol}
|
|
55
|
+
*/
|
|
56
|
+
export const copyButtonElementSymbol = Symbol("copyButtonElement");
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* local symbol
|
|
60
|
+
* @private
|
|
61
|
+
* @type {symbol}
|
|
62
|
+
*/
|
|
63
|
+
const closeEventHandler = Symbol("closeEventHandler");
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* local symbol
|
|
67
|
+
* @private
|
|
68
|
+
* @type {symbol}
|
|
69
|
+
*/
|
|
70
|
+
const resizeObserverSymbol = Symbol("resizeObserver");
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A Copy
|
|
74
|
+
*
|
|
75
|
+
* @fragments /fragments/components/content/copy/
|
|
76
|
+
*
|
|
77
|
+
* @example /examples/components/content/copy-simple
|
|
78
|
+
*
|
|
79
|
+
* @since 3.77.0
|
|
80
|
+
* @copyright schukai GmbH
|
|
81
|
+
* @summary A beautiful Copy that can make your life easier and also looks good.
|
|
82
|
+
*/
|
|
83
|
+
class Copy extends CustomElement {
|
|
84
|
+
/**
|
|
85
|
+
* This method is called by the `instanceof` operator.
|
|
86
|
+
* @returns {symbol}
|
|
87
|
+
*/
|
|
88
|
+
static get [instanceSymbol]() {
|
|
89
|
+
return Symbol.for("@schukai/monster/components/content/copy@@instance");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @return {Components.Content.Copy
|
|
95
|
+
*/
|
|
96
|
+
[assembleMethodSymbol]() {
|
|
97
|
+
super[assembleMethodSymbol]();
|
|
98
|
+
initControlReferences.call(this);
|
|
99
|
+
initEventHandler.call(this);
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* This method is called when the element is connected to the dom.
|
|
106
|
+
*
|
|
107
|
+
* @return {void}
|
|
108
|
+
*/
|
|
109
|
+
connectedCallback() {
|
|
110
|
+
super.connectedCallback();
|
|
111
|
+
|
|
112
|
+
const document = getDocument();
|
|
113
|
+
|
|
114
|
+
for (const [, type] of Object.entries(["click", "touch"])) {
|
|
115
|
+
// close on outside ui-events
|
|
116
|
+
document.addEventListener(type, this[closeEventHandler]);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
updatePopper.call(this);
|
|
120
|
+
attachResizeObserver.call(this);
|
|
121
|
+
}
|
|
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
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @private
|
|
228
|
+
*/
|
|
229
|
+
function attachResizeObserver() {
|
|
230
|
+
// against flickering
|
|
231
|
+
this[resizeObserverSymbol] = new ResizeObserver((entries) => {
|
|
232
|
+
if (this[timerCallbackSymbol] instanceof DeadMansSwitch) {
|
|
233
|
+
try {
|
|
234
|
+
this[timerCallbackSymbol].touch();
|
|
235
|
+
return;
|
|
236
|
+
} catch (e) {
|
|
237
|
+
delete this[timerCallbackSymbol];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
|
|
242
|
+
updatePopper.call(this);
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
this[resizeObserverSymbol].observe(this.parentElement);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function disconnectResizeObserver() {
|
|
250
|
+
if (this[resizeObserverSymbol] instanceof ResizeObserver) {
|
|
251
|
+
this[resizeObserverSymbol].disconnect();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* @private
|
|
257
|
+
*/
|
|
258
|
+
function hide() {
|
|
259
|
+
const self = this;
|
|
260
|
+
|
|
261
|
+
fireCustomEvent(self, "monster-popper-hide", {
|
|
262
|
+
self,
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
self[popperElementSymbol].style.display = "none";
|
|
266
|
+
removeAttributeToken(self[controlElementSymbol], "class", "open");
|
|
267
|
+
|
|
268
|
+
setTimeout(() => {
|
|
269
|
+
fireCustomEvent(self, "monster-popper-hidden", {
|
|
270
|
+
self,
|
|
271
|
+
});
|
|
272
|
+
}, 0);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* @private
|
|
277
|
+
*/
|
|
278
|
+
function show() {
|
|
279
|
+
const self = this;
|
|
280
|
+
|
|
281
|
+
if (self.getOption("disabled", false) === true) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (self[popperElementSymbol].style.display === STYLE_DISPLAY_MODE_BLOCK) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
fireCustomEvent(self, "monster-popper-open", {
|
|
290
|
+
self,
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
self[popperElementSymbol].style.visibility = "hidden";
|
|
294
|
+
self[popperElementSymbol].style.display = STYLE_DISPLAY_MODE_BLOCK;
|
|
295
|
+
|
|
296
|
+
addAttributeToken(self[controlElementSymbol], "class", "open");
|
|
297
|
+
updatePopper.call(self);
|
|
298
|
+
|
|
299
|
+
setTimeout(() => {
|
|
300
|
+
fireCustomEvent(self, "monster-popper-opened", {
|
|
301
|
+
self,
|
|
302
|
+
});
|
|
303
|
+
}, 0);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @private
|
|
308
|
+
*/
|
|
309
|
+
function updatePopper() {
|
|
310
|
+
if (this[popperElementSymbol].style.display !== STYLE_DISPLAY_MODE_BLOCK) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (this.getOption("disabled", false) === true) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
positionPopper.call(
|
|
319
|
+
this,
|
|
320
|
+
this[controlElementSymbol],
|
|
321
|
+
this[popperElementSymbol],
|
|
322
|
+
this.getOption("popper", {}),
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* @private
|
|
328
|
+
* @return {initEventHandler}
|
|
329
|
+
* @fires monster-copy-clicked
|
|
330
|
+
* @fires monster-copy-success
|
|
331
|
+
* @fires monster-copy-error
|
|
332
|
+
*/
|
|
333
|
+
function initEventHandler() {
|
|
334
|
+
const self = this;
|
|
335
|
+
|
|
336
|
+
this[closeEventHandler] = (event) => {
|
|
337
|
+
const path = event.composedPath();
|
|
338
|
+
|
|
339
|
+
for (const [, element] of Object.entries(path)) {
|
|
340
|
+
if (element === this) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
hide.call(this);
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
const type = "click";
|
|
348
|
+
|
|
349
|
+
this[controlElementSymbol].addEventListener("mouseenter", (event) => {
|
|
350
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
351
|
+
event.preventDefault();
|
|
352
|
+
}
|
|
353
|
+
this.showDialog();
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
this[controlElementSymbol].addEventListener("focus", (event) => {
|
|
357
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
358
|
+
event.preventDefault();
|
|
359
|
+
}
|
|
360
|
+
this.showDialog();
|
|
361
|
+
});
|
|
362
|
+
this[controlElementSymbol].addEventListener("blur", (event) => {
|
|
363
|
+
if (this.getOption("features.preventOpenEventSent") === true) {
|
|
364
|
+
event.preventDefault();
|
|
365
|
+
}
|
|
366
|
+
this.hideDialog();
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
this[copyButtonElementSymbol].addEventListener(type, function (event) {
|
|
370
|
+
|
|
371
|
+
fireCustomEvent(self, "monster-copy-clicked", {
|
|
372
|
+
element: self,
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
const nodes = getSlottedElements.call(self, ":scope");
|
|
376
|
+
|
|
377
|
+
let text = "";
|
|
378
|
+
for (const node of nodes) {
|
|
379
|
+
if (self.getOption("features.stripTags")) {
|
|
380
|
+
text += node.textContent;
|
|
381
|
+
} else {
|
|
382
|
+
text += node.outerHTML;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
navigator.clipboard.writeText(text).then(function () {
|
|
387
|
+
|
|
388
|
+
self[copyButtonElementSymbol].querySelector("use").setAttribute("href", "#copy-success");
|
|
389
|
+
setTimeout(() => {
|
|
390
|
+
self[copyButtonElementSymbol].querySelector("use").setAttribute("href", "#copy");
|
|
391
|
+
}, 2000);
|
|
392
|
+
|
|
393
|
+
fireCustomEvent(self, "monster-copy-success", {
|
|
394
|
+
element: self,
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
}).catch(function (e) {
|
|
398
|
+
|
|
399
|
+
self[copyButtonElementSymbol].querySelector("use").setAttribute("href", "#copy-error");
|
|
400
|
+
setTimeout(() => {
|
|
401
|
+
self[copyButtonElementSymbol].querySelector("use").setAttribute("href", "#copy");
|
|
402
|
+
}, 2000);
|
|
403
|
+
|
|
404
|
+
fireCustomEvent(self, "monster-copy-error", {
|
|
405
|
+
element: self,
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, "" + e);
|
|
409
|
+
})
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
return this;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* @private
|
|
418
|
+
* @return {void}
|
|
419
|
+
*/
|
|
420
|
+
function initControlReferences() {
|
|
421
|
+
this[controlElementSymbol] = this.shadowRoot.querySelector(
|
|
422
|
+
`[${ATTRIBUTE_ROLE}="control"]`,
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
this[copyButtonElementSymbol] = this.shadowRoot.querySelector(
|
|
426
|
+
`[${ATTRIBUTE_ROLE}="button"]`,
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
this[popperElementSymbol] = this.shadowRoot.querySelector(
|
|
430
|
+
`[${ATTRIBUTE_ROLE}="popper"]`,
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* @private
|
|
437
|
+
* @return {string}
|
|
438
|
+
*/
|
|
439
|
+
function getTemplate() {
|
|
440
|
+
// language=HTML
|
|
441
|
+
return `
|
|
442
|
+
<div data-monster-role="control" part="control">
|
|
443
|
+
<slot></slot>
|
|
444
|
+
<div data-monster-role="popper" part="popper" tabindex="-1" class="monster-color-primary-1">
|
|
445
|
+
<div data-monster-role="arrow"></div>
|
|
446
|
+
<button data-monster-role="button" part="button">
|
|
447
|
+
<svg data-monster-role="icon-map"><defs>
|
|
448
|
+
<g id="copy">
|
|
449
|
+
<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"/>
|
|
450
|
+
<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"/>
|
|
451
|
+
</g>
|
|
452
|
+
|
|
453
|
+
<g id="copy-success">
|
|
454
|
+
<path fill-rule="evenodd"
|
|
455
|
+
d="M10.854 7.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 9.793l2.646-2.647a.5.5 0 0 1 .708 0"/>
|
|
456
|
+
<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"/>
|
|
457
|
+
<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"/>
|
|
458
|
+
</g>
|
|
459
|
+
|
|
460
|
+
<g id="copy-error">
|
|
461
|
+
<path fill-rule="evenodd"
|
|
462
|
+
d="M6.146 7.146a.5.5 0 0 1 .708 0L8 8.293l1.146-1.147a.5.5 0 1 1 .708.708L8.707 9l1.147 1.146a.5.5 0 0 1-.708.708L8 9.707l-1.146 1.147a.5.5 0 0 1-.708-.708L7.293 9 6.146 7.854a.5.5 0 0 1 0-.708"/>
|
|
463
|
+
<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"/>
|
|
464
|
+
<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"/>
|
|
465
|
+
</g>
|
|
466
|
+
|
|
467
|
+
</defs>
|
|
468
|
+
</svg><svg data-monster-role="icon" xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 16 16"><use href="#copy"></use></svg>
|
|
469
|
+
</button>
|
|
470
|
+
</div>
|
|
471
|
+
</div>`;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
registerCustomElement(Copy);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@import "../../style/control.pcss";
|
|
2
|
+
@import "../../style/property.pcss";
|
|
3
|
+
@import "../../style/floating-ui.pcss";
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: inline-block;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
[data-monster-role=control] {
|
|
10
|
+
display: inherit;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[data-monster-role="icon"] {
|
|
14
|
+
fill: var(--monster-color-primary-1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[data-monster-role="icon-map"] {
|
|
18
|
+
display: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
button {
|
|
22
|
+
border: none;
|
|
23
|
+
background: inherit;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
button:hover {
|
|
27
|
+
cursor: copy;
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
button:active {
|
|
32
|
+
transform: scale(0.95);
|
|
33
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright © schukai GmbH and all contributing authors, 2024. All rights reserved.
|
|
3
|
+
* Node module: @schukai/monster
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
|
|
6
|
+
* The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
|
|
7
|
+
*
|
|
8
|
+
* For those who do not wish to adhere to the AGPLv3, a commercial license is available.
|
|
9
|
+
* Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
|
|
10
|
+
* For more information about purchasing a commercial license, please contact schukai GmbH.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {addAttributeToken} from "../../../dom/attributes.mjs";
|
|
14
|
+
import {ATTRIBUTE_ERRORMESSAGE} from "../../../dom/constants.mjs";
|
|
15
|
+
|
|
16
|
+
export {CopyStyleSheet}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @private
|
|
20
|
+
* @type {CSSStyleSheet}
|
|
21
|
+
*/
|
|
22
|
+
const CopyStyleSheet = new CSSStyleSheet();
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
CopyStyleSheet.insertRule(`
|
|
26
|
+
@layer copy {
|
|
27
|
+
[data-monster-role=control]{box-sizing:border-box;outline:none;width:100%}[data-monster-role=control].flex{align-items:center;display:flex;flex-direction:row}:host{box-sizing:border-box;display:block}:after,:before,:root{--monster-font-family:-apple-system,BlinkMacSystemFont,\"Quicksand\",\"Segoe UI\",\"Roboto\",\"Oxygen\",\"Ubuntu\",\"Cantarell\",\"Fira Sans\",\"Droid Sans\",\"Helvetica Neue\",Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\";--monster-color-primary-1:var(--monster-color-gray-6);--monster-color-primary-2:var(--monster-color-gray-6);--monster-color-primary-3:var(--monster-color-cinnamon-1);--monster-color-primary-4:var(--monster-color-cinnamon-1);--monster-bg-color-primary-1:var(--monster-color-gray-1);--monster-bg-color-primary-2:var(--monster-color-gray-2);--monster-bg-color-primary-3:var(--monster-color-gray-6);--monster-bg-color-primary-4:var(--monster-color-gray-4)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-color-primary-1:var(--monster-color-gray-1);--monster-color-primary-2:var(--monster-color-gray-1);--monster-color-primary-3:var(--monster-color-gray-6);--monster-color-primary-4:var(--monster-color-gray-6);--monster-bg-color-primary-1:var(--monster-color-gray-6);--monster-bg-color-primary-2:var(--monster-color-gray-3);--monster-bg-color-primary-3:var(--monster-color-gray-2);--monster-bg-color-primary-4:var(--monster-color-gray-1)}}:after,:before,:root{--monster-color-secondary-1:var(--monster-color-red-4);--monster-color-secondary-2:var(--monster-color-red-4);--monster-color-secondary-3:var(--monster-color-red-1);--monster-color-secondary-4:var(--monster-color-red-1);--monster-bg-color-secondary-1:var(--monster-color-gray-1);--monster-bg-color-secondary-2:var(--monster-color-red-2);--monster-bg-color-secondary-3:var(--monster-color-red-3);--monster-bg-color-secondary-4:var(--monster-color-red-6)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-color-secondary-1:var(--monster-color-red-1);--monster-color-secondary-2:var(--monster-color-red-1);--monster-color-secondary-3:var(--monster-color-red-6);--monster-color-secondary-4:var(--monster-color-red-4);--monster-bg-color-secondary-1:var(--monster-color-gray-6);--monster-bg-color-secondary-2:var(--monster-color-red-3);--monster-bg-color-secondary-3:var(--monster-color-red-2);--monster-bg-color-secondary-4:var(--monster-color-red-1)}}:after,:before,:root{--monster-color-tertiary-1:var(--monster-color-magenta-4);--monster-color-tertiary-2:var(--monster-color-magenta-4);--monster-color-tertiary-3:var(--monster-color-magenta-6);--monster-color-tertiary-4:var(--monster-color-magenta-1);--monster-bg-color-tertiary-1:var(--monster-color-gray-1);--monster-bg-color-tertiary-2:var(--monster-color-magenta-1);--monster-bg-color-tertiary-3:var(--monster-color-magenta-2);--monster-bg-color-tertiary-4:var(--monster-color-magenta-6)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-color-tertiary-1:var(--monster-color-magenta-1);--monster-color-tertiary-2:var(--monster-color-magenta-6);--monster-color-tertiary-3:var(--monster-color-magenta-4);--monster-color-tertiary-4:var(--monster-color-magenta-4);--monster-bg-color-tertiary-1:var(--monster-color-gray-6);--monster-bg-color-tertiary-2:var(--monster-color-magenta-2);--monster-bg-color-tertiary-3:var(--monster-color-magenta-1);--monster-bg-color-tertiary-4:var(--monster-color-magenta-1)}}:after,:before,:root{--monster-color-destructive-1:var(--monster-color-red-1);--monster-color-destructive-2:var(--monster-color-red-4);--monster-color-destructive-3:var(--monster-color-red-6);--monster-color-destructive-4:var(--monster-color-red-1);--monster-bg-color-destructive-1:var(--monster-color-red-4);--monster-bg-color-destructive-2:var(--monster-color-gray-1);--monster-bg-color-destructive-3:var(--monster-color-red-2);--monster-bg-color-destructive-4:var(--monster-color-red-5)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-color-destructive-1:var(--monster-color-red-1);--monster-color-destructive-2:var(--monster-color-red-3);--monster-color-destructive-3:var(--monster-color-red-4);--monster-color-destructive-4:var(--monster-color-red-1);--monster-bg-color-destructive-1:var(--monster-color-red-5);--monster-bg-color-destructive-2:var(--monster-color-gray-6);--monster-bg-color-destructive-3:var(--monster-color-red-1);--monster-bg-color-destructive-4:var(--monster-color-red-4)}}:after,:before,:root{--monster-color-success-1:var(--monster-color-green-1);--monster-color-success-2:var(--monster-color-green-4);--monster-color-success-3:var(--monster-color-green-6);--monster-color-success-4:var(--monster-color-green-1);--monster-bg-color-success-1:var(--monster-color-green-3);--monster-bg-color-success-2:var(--monster-color-gray-1);--monster-bg-color-success-3:var(--monster-color-green-2);--monster-bg-color-success-4:var(--monster-color-green-5)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-color-success-1:var(--monster-color-green-1);--monster-color-success-2:var(--monster-color-green-2);--monster-color-success-3:var(--monster-color-green-4);--monster-color-success-4:var(--monster-color-green-1);--monster-bg-color-success-1:var(--monster-color-green-5);--monster-bg-color-success-2:var(--monster-color-gray-6);--monster-bg-color-success-3:var(--monster-color-green-1);--monster-bg-color-success-4:var(--monster-color-green-3)}}:after,:before,:root{--monster-color-warning-1:var(--monster-color-orange-1);--monster-color-warning-2:var(--monster-color-orange-4);--monster-color-warning-3:var(--monster-color-orange-6);--monster-color-warning-4:var(--monster-color-orange-1);--monster-bg-color-warning-1:var(--monster-color-orange-3);--monster-bg-color-warning-2:var(--monster-color-gray-1);--monster-bg-color-warning-3:var(--monster-color-orange-2);--monster-bg-color-warning-4:var(--monster-color-orange-5)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-color-warning-1:var(--monster-color-orange-1);--monster-color-warning-2:var(--monster-color-orange-3);--monster-color-warning-3:var(--monster-color-orange-4);--monster-color-warning-4:var(--monster-color-orange-1);--monster-bg-color-warning-1:var(--monster-color-orange-5);--monster-bg-color-warning-2:var(--monster-color-gray-6);--monster-bg-color-warning-3:var(--monster-color-orange-1);--monster-bg-color-warning-4:var(--monster-color-orange-3)}}:after,:before,:root{--monster-color-error-1:var(--monster-color-red-1);--monster-color-error-2:var(--monster-color-red-4);--monster-color-error-3:var(--monster-color-red-6);--monster-color-error-4:var(--monster-color-red-1);--monster-bg-color-error-1:var(--monster-color-red-4);--monster-bg-color-error-2:var(--monster-color-gray-1);--monster-bg-color-error-3:var(--monster-color-red-2);--monster-bg-color-error-4:var(--monster-color-red-5)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-color-error-1:var(--monster-color-red-1);--monster-color-error-2:var(--monster-color-red-3);--monster-color-error-3:var(--monster-color-red-4);--monster-color-error-4:var(--monster-color-red-1);--monster-bg-color-error-1:var(--monster-color-red-5);--monster-bg-color-error-2:var(--monster-color-gray-6);--monster-bg-color-error-3:var(--monster-color-red-1);--monster-bg-color-error-4:var(--monster-color-red-4)}}:after,:before,:root{--monster-color-selection-1:var(--monster-color-gray-6);--monster-color-selection-2:var(--monster-color-gray-6);--monster-color-selection-3:var(--monster-color-gray-6);--monster-color-selection-4:var(--monster-color-gray-1);--monster-bg-color-selection-1:var(--monster-color-yellow-2);--monster-bg-color-selection-2:var(--monster-color-yellow-1);--monster-bg-color-selection-3:var(--monster-color-yellow-2);--monster-bg-color-selection-4:var(--monster-color-yellow-6)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-color-selection-1:var(--monster-color-gray-6);--monster-color-selection-2:var(--monster-color-gray-6);--monster-color-selection-3:var(--monster-color-gray-6);--monster-color-selection-4:var(--monster-color-gray-1);--monster-bg-color-selection-1:var(--monster-color-yellow-2);--monster-bg-color-selection-2:var(--monster-color-yellow-1);--monster-bg-color-selection-3:var(--monster-color-yellow-2);--monster-bg-color-selection-4:var(--monster-color-yellow-6)}}:after,:before,:root{--monster-color-primary-disabled-1:var(--monster-color-gray-4);--monster-color-primary-disabled-2:var(--monster-color-gray-4);--monster-color-primary-disabled-3:var(--monster-color-gray-4);--monster-color-primary-disabled-4:var(--monster-color-gray-4);--monster-bg-color-primary-disabled-1:var(--monster-color-gray-1);--monster-bg-color-primary-disabled-2:var(--monster-color-gray-2);--monster-bg-color-primary-disabled-3:var(--monster-color-gray-3);--monster-bg-color-primary-disabled-4:var(--monster-color-gray-6)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-color-primary-disabled-1:var(--monster-color-gray-4);--monster-color-primary-disabled-2:var(--monster-color-gray-4);--monster-color-primary-disabled-3:var(--monster-color-gray-3);--monster-color-primary-disabled-4:var(--monster-color-gray-3);--monster-bg-color-primary-disabled-1:var(--monster-color-gray-6);--monster-bg-color-primary-disabled-2:var(--monster-color-gray-3);--monster-bg-color-primary-disabled-3:var(--monster-color-gray-2);--monster-bg-color-primary-disabled-4:var(--monster-color-gray-1)}}:after,:before,:root{--monster-color-gradient-1:#833ab4;--monster-color-gradient-2:#fd1d1d;--monster-color-gradient-3:#fcb045;--monster-box-shadow-1:none;--monster-box-shadow-2:-1px 1px 10px 1px hsla(0,0%,76%,.61);--monster-text-shadow:none;--monster-theme-control-bg-color:var(--monster-color-seashell-1);--monster-theme-control-color:var(--monster-color-seashell-6);--monster-theme-control-hover-color:var(--monster-color-seashell-6);--monster-theme-control-hover-bg-color:var(--monster-color-seashell-2);--monster-theme-control-border-width:2px;--monster-theme-control-border-style:solid;--monster-theme-control-border-radius:0;--monster-theme-control-border-color:var(--monster-color-primary-1)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-theme-control-bg-color:var(--monster-color-gray-5);--monster-theme-control-color:var(--monster-color-gray-1);--monster-theme-control-border-color:var(--monster-color-gray-3);--monster-theme-control-hover-color:var(--monster-color-gray-1);--monster-theme-control-hover-bg-color:var(--monster-color-gray-6)}}:after,:before,:root{--monster-theme-on-color:var(--monster-color-green-1);--monster-theme-on-bg-color:var(--monster-color-green-5);--monster-theme-off-color:var(--monster-color-gray-1);--monster-theme-off-bg-color:var(--monster-color-gray-4)}@media (prefers-color-scheme:dark){:after,:before,:root{--monster-theme-on-color:var(--monster-color-gray-6);--monster-theme-on-bg-color:var(--monster-color-gray-1);--monster-theme-off-color:var(--monster-color-gray-1);--monster-theme-off-bg-color:var(--monster-color-gray-5)}}:after,:before,:root{--monster-border-style:solid;--monster-border-width:3px;--monster-border-radius:0;--monster-popper-witharrrow-distance:-4px;--monster-z-index-default:0;--monster-z-index-outline:10;--monster-z-index-dropdown:200;--monster-z-index-dropdown-overlay:210;--monster-z-index-sticky:300;--monster-z-index-sticky-overlay:310;--monster-z-index-fixed:400;--monster-z-index-fixed-overlay:410;--monster-z-index-modal-backdrop:500;--monster-z-index-modal-backdrop-overlay:510;--monster-z-index-offcanvas:600;--monster-z-index-offcanvas-overlay:610;--monster-z-index-modal:700;--monster-z-index-modal-overlay:710;--monster-z-index-popover:800;--monster-z-index-popover-overlay:810;--monster-z-index-tooltip:800;--monster-z-index-tooltip-overlay:910;--monster-space-0:0;--monster-space-1:2px;--monster-space-2:4px;--monster-space-3:6px;--monster-space-4:10px;--monster-space-5:16px;--monster-space-6:26px;--monster-space-7:42px;--monster-breakpoint-0:480px;--monster-breakpoint-4:480px;--monster-breakpoint-7:768px;--monster-breakpoint-9:992px;--monster-breakpoint-12:1200px;--monster-dragger-width:2px;--monster-dragger-handle-width:4px;--monster-dragger-handle-height:50px}div[data-monster-role=popper]{align-content:center;background:var(--monster-bg-color-primary-1);border-color:var(--monster-bg-color-primary-4);border-radius:var(--monster-border-radius);border-style:var(--monster-border-style);border-width:var(--monster-border-width);box-shadow:var(--monster-box-shadow-1);box-sizing:border-box;color:var(--monster-color-primary-1);display:none;justify-content:space-between;left:0;padding:1.1em;position:absolute;top:0;width:-moz-max-content;width:max-content;z-index:var(--monster-z-index-modal)}div[data-monster-role=popper] div[data-monster-role=arrow]{background:var(--monster-bg-color-primary-1);height:calc(max(var(--monster-popper-witharrrow-distance), -1 * var(--monster-popper-witharrrow-distance))*2);pointer-events:none;position:absolute;width:calc(max(var(--monster-popper-witharrrow-distance), -1 * var(--monster-popper-witharrrow-distance))*2);z-index:-1}:host{display:inline-block}[data-monster-role=control]{display:inherit}[data-monster-role=icon]{fill:var(--monster-color-primary-1)}[data-monster-role=icon-map]{display:none}button{background:inherit;border:none}button:hover{cursor:copy}button:active{transform:scale(.95)}
|
|
28
|
+
}`, 0);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
addAttributeToken(document.getRootNode().querySelector('html'), ATTRIBUTE_ERRORMESSAGE, e + "");
|
|
31
|
+
}
|
|
@@ -20,42 +20,6 @@ import { Popper } from "./popper.mjs";
|
|
|
20
20
|
|
|
21
21
|
export { ContextHelp };
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* The ContextHelp ist an element that can be used to display a tooltip or a popover.
|
|
25
|
-
*
|
|
26
|
-
* <img src="./images/context-help.png">
|
|
27
|
-
*
|
|
28
|
-
* Dependencies: the system uses functions of the [monsterjs](https://monsterjs.org/) library
|
|
29
|
-
* as well as [pooperjs](https://popper.js.org/docs/v2/).
|
|
30
|
-
*
|
|
31
|
-
* You can create this control either by specifying the HTML tag <monster-context-help-button />` directly in the HTML or using
|
|
32
|
-
* Javascript via the `document.createElement('monster-context-help');` method.
|
|
33
|
-
*
|
|
34
|
-
* ```html
|
|
35
|
-
* <monster-context-help></monster-context-help>
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* Or you can create this CustomControl directly in Javascript:
|
|
39
|
-
*
|
|
40
|
-
* ```js
|
|
41
|
-
* import {Popper} from '@schukai/monster/components/form/context-help.mjs';
|
|
42
|
-
* document.createElement('monster-context-help');
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* @startuml context-help.png
|
|
46
|
-
* skinparam monochrome true
|
|
47
|
-
* skinparam shadowing false
|
|
48
|
-
* HTMLElement <|-- CustomElement
|
|
49
|
-
* CustomElement <|-- CustomControl
|
|
50
|
-
* CustomControl <|-- Popper
|
|
51
|
-
* Popper <|-- ContextHelp
|
|
52
|
-
* @enduml
|
|
53
|
-
*
|
|
54
|
-
* @copyright schukai GmbH
|
|
55
|
-
* @memberOf Monster.Components.Form
|
|
56
|
-
* @summary A control that can be used to display a tooltip or a popover.
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
23
|
/**
|
|
60
24
|
* A context help control.
|
|
61
25
|
*
|