@descope-ui/common 0.0.6 → 0.0.8
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
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.0.8](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.7...@descope-ui/common-0.0.8) (2025-03-05)
|
|
6
|
+
|
|
7
|
+
## [0.0.7](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.6...@descope-ui/common-0.0.7) (2025-03-03)
|
|
8
|
+
|
|
5
9
|
## [0.0.6](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.5...@descope-ui/common-0.0.6) (2025-03-03)
|
|
6
10
|
|
|
7
11
|
## [0.0.5](https://github.com/descope/web-components-ui/compare/@descope-ui/common-0.0.4...@descope-ui/common-0.0.5) (2025-02-26)
|
package/package.json
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
|
+
import { injectStyle } from '../../componentsHelpers'
|
|
1
2
|
export const draggableMixin = (superclass) =>
|
|
2
3
|
class DraggableMixinClass extends superclass {
|
|
3
|
-
#styleEle = null;
|
|
4
|
-
|
|
5
|
-
static get observedAttributes() {
|
|
6
|
-
const superAttrs = superclass.observedAttributes || [];
|
|
7
|
-
return [...superAttrs, 'draggable'];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
4
|
constructor() {
|
|
11
5
|
super();
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
this.#styleEle.innerText = `* { cursor: inherit!important }`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
#handleDraggableStyle(isDraggable) {
|
|
18
|
-
if (isDraggable) {
|
|
19
|
-
this.shadowRoot.appendChild(this.#styleEle);
|
|
20
|
-
} else {
|
|
21
|
-
this.#styleEle.remove();
|
|
22
|
-
}
|
|
7
|
+
injectStyle(`:host([draggable="true"]) * { cursor: inherit!important }`, this);
|
|
23
8
|
}
|
|
24
9
|
|
|
25
10
|
get isDraggable() {
|
|
@@ -37,9 +22,8 @@ export const draggableMixin = (superclass) =>
|
|
|
37
22
|
this.baseElement.setAttribute('tabindex', '-1');
|
|
38
23
|
|
|
39
24
|
const onComplete = () => {
|
|
40
|
-
prevTabIndex
|
|
41
|
-
|
|
42
|
-
: this.baseElement.removeAttribute('tabindex');
|
|
25
|
+
if (prevTabIndex) this.baseElement.setAttribute('tabindex', prevTabIndex)
|
|
26
|
+
else this.baseElement.removeAttribute('tabindex');
|
|
43
27
|
|
|
44
28
|
e.target.removeEventListener('mouseup', onComplete);
|
|
45
29
|
e.target.removeEventListener('dragend', onComplete);
|
|
@@ -52,11 +36,4 @@ export const draggableMixin = (superclass) =>
|
|
|
52
36
|
|
|
53
37
|
super.init?.();
|
|
54
38
|
}
|
|
55
|
-
|
|
56
|
-
attributeChangedCallback(attrName, oldValue, newValue) {
|
|
57
|
-
super.attributeChangedCallback?.(attrName, oldValue, newValue);
|
|
58
|
-
if (attrName === 'draggable') {
|
|
59
|
-
this.#handleDraggableStyle(newValue === 'true');
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
39
|
};
|
package/src/sbHelpers.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
export const withForm = (
|
|
1
|
+
export const withForm = (story) => {
|
|
2
|
+
setTimeout(() => {
|
|
3
|
+
const form = document.querySelector('form');
|
|
4
|
+
form.addEventListener('submit', (e) => {
|
|
5
|
+
e.preventDefault();
|
|
6
|
+
});
|
|
7
|
+
});
|
|
2
8
|
return `
|
|
3
9
|
<style nonce="${window.DESCOPE_NONCE}">
|
|
4
|
-
.
|
|
5
|
-
margin-top: 6em
|
|
10
|
+
.action-wrapper {
|
|
11
|
+
margin-top: 6em;
|
|
6
12
|
}
|
|
7
13
|
</style>
|
|
8
|
-
<form
|
|
9
|
-
<div>${
|
|
10
|
-
<div class="
|
|
14
|
+
<form>
|
|
15
|
+
<div>${story()}</div>
|
|
16
|
+
<div class="action-wrapper">
|
|
11
17
|
<button type="submit" data-testid="submit-button">Submit</button>
|
|
12
18
|
</div>
|
|
13
19
|
</form>
|