errorbuttons 1.0.0 → 1.0.1
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/index.js +9 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -16,6 +16,8 @@ const defaultDefaultStyles = {
|
|
|
16
16
|
display: 'flex',
|
|
17
17
|
flexDirection: 'column',
|
|
18
18
|
gap: '4px',
|
|
19
|
+
maxWidth: '400px',
|
|
20
|
+
wordBreak: 'break-word'
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
const defaultHoverStyles = {
|
|
@@ -55,10 +57,7 @@ const defaultHolderStyles = {
|
|
|
55
57
|
pointerEvents: 'none'
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
const defaultSpanStyles = {
|
|
59
|
-
maxWidth: '400px',
|
|
60
|
-
wordBreak: 'break-word'
|
|
61
|
-
}
|
|
60
|
+
const defaultSpanStyles = {}
|
|
62
61
|
|
|
63
62
|
export const setupErrorButtons = (myError, options={}) => {
|
|
64
63
|
const pressedStyles=options.pressedStyles || defaultPressedStyles;
|
|
@@ -68,10 +67,10 @@ export const setupErrorButtons = (myError, options={}) => {
|
|
|
68
67
|
const idValue=options.idValue || 'statusbuttonerrholder';
|
|
69
68
|
const title=options.title || `Copy to clipboard and dismiss`;
|
|
70
69
|
const spanStyles =options.spanStyles || defaultSpanStyles;
|
|
71
|
-
let errHolder = document.
|
|
70
|
+
let errHolder = document.querySelector(`[data-errorbuttonid=${idValue}]`);
|
|
72
71
|
if (!errHolder) {
|
|
73
72
|
errHolder = document.createElement('div');
|
|
74
|
-
errHolder.
|
|
73
|
+
errHolder.dataset.errorbuttonid = idValue;
|
|
75
74
|
Object.assign(errHolder.style, holderStyles);
|
|
76
75
|
document.body.appendChild(errHolder);
|
|
77
76
|
}
|
|
@@ -105,7 +104,11 @@ export const setupErrorButtons = (myError, options={}) => {
|
|
|
105
104
|
timestamp: errTimestamp.textContent
|
|
106
105
|
}
|
|
107
106
|
navigator.clipboard.writeText(JSON.stringify(parsedError, null, 2));
|
|
107
|
+
const parent = statusButton.parentElement;
|
|
108
108
|
statusButton.remove();
|
|
109
|
+
if (parent.childElementCount === 0) {
|
|
110
|
+
parent.remove();
|
|
111
|
+
}
|
|
109
112
|
});
|
|
110
113
|
buttonizer(statusButton, pressedStyles, optionalStyles, false, false);
|
|
111
114
|
errHolder.appendChild(statusButton);
|