@descope/web-components-ui 1.0.51 → 1.0.52
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.esm.js +297 -133
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/433.js +1 -1
- package/dist/umd/descope-combo-index-js.js +1 -1
- package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js +1 -0
- package/dist/umd/descope-passcode-index-js.js +1 -0
- package/dist/umd/descope-text-field-index-js.js +1 -1
- package/dist/umd/index.js +1 -1
- package/package.json +1 -1
- package/src/components/descope-container/Container.js +1 -1
- package/src/components/descope-passcode/Passcode.js +141 -0
- package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +213 -0
- package/src/components/descope-passcode/descope-passcode-internal/helpers.js +14 -0
- package/src/components/descope-passcode/descope-passcode-internal/index.js +3 -0
- package/src/components/descope-passcode/index.js +5 -0
- package/src/componentsHelpers/createProxy/index.js +3 -4
- package/src/componentsHelpers/createStyleMixin/index.js +103 -72
- package/src/componentsHelpers/inputMixin.js +13 -13
- package/src/theme/components/index.js +3 -1
- package/src/theme/components/passcode.js +8 -0
@@ -2,77 +2,108 @@ import { getCssVarName, kebabCaseJoin } from '../../helpers';
|
|
2
2
|
import { createStyle, createCssVarsList } from './helpers';
|
3
3
|
|
4
4
|
export const createStyleMixin =
|
5
|
-
({ mappings = {} }) =>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
|
16
|
-
static get cssVarList() {
|
17
|
-
return createCssVarsList(superclass.componentName, mappings);
|
18
|
-
}
|
19
|
-
|
20
|
-
#styleEle = null;
|
21
|
-
|
22
|
-
constructor() {
|
23
|
-
super();
|
24
|
-
|
25
|
-
this.#createComponentStyle();
|
26
|
-
this.#createAttrOverrideStyle();
|
27
|
-
}
|
28
|
-
|
29
|
-
#createAttrOverrideStyle() {
|
30
|
-
this.#styleEle = document.createElement('style');
|
31
|
-
this.#styleEle.id = 'style-mixin-overrides';
|
32
|
-
|
33
|
-
this.#styleEle.innerText = '* {}';
|
34
|
-
this.shadowRoot.prepend(this.#styleEle);
|
35
|
-
}
|
36
|
-
|
37
|
-
#updateAttrOverrideStyle(attrName, value) {
|
38
|
-
const style = this.#styleEle.sheet.cssRules[0].style;
|
39
|
-
const varName = getCssVarName(
|
40
|
-
superclass.componentName,
|
41
|
-
attrName.replace(/^st-/, '')
|
42
|
-
);
|
43
|
-
|
44
|
-
if (value) style.setProperty(varName, value);
|
45
|
-
else style.removeProperty(varName);
|
46
|
-
}
|
47
|
-
|
48
|
-
#createComponentStyle() {
|
49
|
-
const themeStyle = document.createElement('style');
|
50
|
-
themeStyle.id = 'style-mixin-component';
|
51
|
-
themeStyle.innerHTML = createStyle(
|
52
|
-
superclass.componentName,
|
53
|
-
this.baseSelector,
|
54
|
-
mappings
|
55
|
-
);
|
56
|
-
this.shadowRoot.prepend(themeStyle);
|
57
|
-
}
|
58
|
-
|
59
|
-
attributeChangedCallback(attrName, oldValue, newValue) {
|
60
|
-
super.attributeChangedCallback?.(attrName, oldValue, newValue);
|
61
|
-
|
62
|
-
if (styleAttributes.includes(attrName)) {
|
63
|
-
this.#updateAttrOverrideStyle(attrName, newValue);
|
5
|
+
({ mappings = {}, nestedMappings = {} }) =>
|
6
|
+
(superclass) => {
|
7
|
+
const styleAttributes = Object.keys(mappings).map((key) =>
|
8
|
+
kebabCaseJoin('st', key)
|
9
|
+
);
|
10
|
+
return class CustomStyleMixinClass extends superclass {
|
11
|
+
static get observedAttributes() {
|
12
|
+
const superAttrs = superclass.observedAttributes || [];
|
13
|
+
return [...superAttrs, ...styleAttributes];
|
64
14
|
}
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
15
|
+
|
16
|
+
static get cssVarList() {
|
17
|
+
return createCssVarsList(superclass.componentName, mappings);
|
18
|
+
}
|
19
|
+
|
20
|
+
#styleEle = null;
|
21
|
+
|
22
|
+
constructor() {
|
23
|
+
super();
|
24
|
+
|
25
|
+
this.#createComponentStyle();
|
26
|
+
this.#createAttrOverrideStyle();
|
27
|
+
}
|
28
|
+
|
29
|
+
#createAttrOverrideStyle() {
|
30
|
+
this.#styleEle = document.createElement('style');
|
31
|
+
this.#styleEle.id = 'style-mixin-overrides';
|
32
|
+
|
33
|
+
this.#styleEle.innerText = '* {}';
|
34
|
+
this.shadowRoot.prepend(this.#styleEle);
|
35
|
+
}
|
36
|
+
|
37
|
+
#updateAttrOverrideStyle(attrName, value) {
|
38
|
+
const style = this.#styleEle.sheet?.cssRules[0].style;
|
39
|
+
const varName = getCssVarName(
|
40
|
+
superclass.componentName,
|
41
|
+
attrName.replace(/^st-/, '')
|
42
|
+
);
|
43
|
+
|
44
|
+
if (value) style?.setProperty(varName, value);
|
45
|
+
else style?.removeProperty(varName);
|
46
|
+
}
|
47
|
+
|
48
|
+
#createComponentStyle() {
|
49
|
+
const themeStyle = document.createElement('style');
|
50
|
+
themeStyle.id = 'style-mixin-component';
|
51
|
+
themeStyle.innerHTML = createStyle(
|
52
|
+
superclass.componentName,
|
53
|
+
this.baseSelector,
|
54
|
+
mappings
|
55
|
+
);
|
56
|
+
this.shadowRoot.prepend(themeStyle);
|
57
|
+
}
|
58
|
+
|
59
|
+
#createComponentNestingStyle() {
|
60
|
+
// we need these selectors to be more specific from the theme selectors
|
61
|
+
// in order to do it, we are repeating the class name for specificity
|
62
|
+
const numOfClassNameSpecifier = 3
|
63
|
+
|
64
|
+
const rootNode = this.shadowRoot.host.getRootNode()
|
65
|
+
const styleId = `${superclass.componentName}-style-mixin-component`
|
66
|
+
|
67
|
+
const className = superclass.componentName
|
68
|
+
this.shadowRoot.host.classList.add(className)
|
69
|
+
|
70
|
+
if(rootNode.querySelector(`style#${styleId}`)) return;
|
71
|
+
|
72
|
+
const themeStyle = document.createElement('style');
|
73
|
+
themeStyle.id = styleId;
|
74
|
+
themeStyle.innerHTML = createStyle(
|
75
|
+
superclass.componentName,
|
76
|
+
`${superclass.componentName}${Array(numOfClassNameSpecifier).fill(`.${className}`).join('')}`,
|
77
|
+
nestedMappings
|
78
|
+
);
|
79
|
+
|
80
|
+
// rootNode can be either a shadow DOM or a light DOM
|
81
|
+
if (rootNode.nodeName === '#document') {
|
82
|
+
rootNode.head.append(themeStyle)
|
83
|
+
} else {
|
84
|
+
rootNode.append(themeStyle)
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
attributeChangedCallback(attrName, oldValue, newValue) {
|
89
|
+
super.attributeChangedCallback?.(attrName, oldValue, newValue);
|
90
|
+
|
91
|
+
if (styleAttributes.includes(attrName)) {
|
92
|
+
this.#updateAttrOverrideStyle(attrName, newValue);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
connectedCallback() {
|
97
|
+
super.connectedCallback?.();
|
98
|
+
if (this.shadowRoot.isConnected) {
|
99
|
+
this.#createComponentNestingStyle();
|
100
|
+
|
101
|
+
Array.from(this.attributes).forEach(attr => {
|
102
|
+
if (styleAttributes.includes(attr.nodeName)) {
|
103
|
+
this.#updateAttrOverrideStyle(attr.nodeName, attr.value)
|
104
|
+
}
|
105
|
+
});
|
106
|
+
}
|
107
|
+
}
|
108
|
+
};
|
77
109
|
};
|
78
|
-
};
|
@@ -54,40 +54,40 @@ export const inputMixin = (superclass) =>
|
|
54
54
|
}
|
55
55
|
|
56
56
|
connectedCallback() {
|
57
|
-
this.baseEle = this.shadowRoot.querySelector(this.baseSelector);
|
58
57
|
super.connectedCallback?.();
|
59
58
|
|
59
|
+
this.baseEle = this.shadowRoot.querySelector(this.baseSelector);
|
60
|
+
|
60
61
|
// this is needed in order to make sure the form input validation is working
|
61
62
|
if (!this.hasAttribute('tabindex')) {
|
62
63
|
this.setAttribute('tabindex', 0);
|
63
64
|
}
|
64
65
|
|
65
|
-
|
66
|
-
this.baseEle.querySelector('
|
67
|
-
|
68
|
-
if (!input) throw Error('no input was found');
|
66
|
+
this.inputElement ??= this.baseEle.shadowRoot.querySelector('slot[name="input"]')?.assignedElements()[0] ||
|
67
|
+
this.baseEle.shadowRoot.querySelector('slot[name="textarea"]')?.assignedElements()[0]
|
68
|
+
if (!this.inputElement) throw Error('no input was found');
|
69
69
|
|
70
70
|
// sync properties
|
71
|
-
propertyObserver(this,
|
72
|
-
this.setSelectionRange =
|
71
|
+
propertyObserver(this, this.inputElement, 'value');
|
72
|
+
this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
|
73
73
|
|
74
|
-
this.validity =
|
74
|
+
this.validity = this.inputElement.validity;
|
75
75
|
|
76
76
|
this.setValidity = () => {
|
77
|
-
this.#internals.setValidity(
|
77
|
+
this.#internals.setValidity(this.inputElement.validity, this.inputElement.validationMessage);
|
78
78
|
};
|
79
79
|
|
80
|
-
|
81
|
-
this.value =
|
80
|
+
this.inputElement.oninput = () => {
|
81
|
+
this.value = this.inputElement.value;
|
82
82
|
this.setValidity();
|
83
83
|
};
|
84
84
|
|
85
85
|
this.onfocus = () => {
|
86
|
-
setTimeout(() =>
|
86
|
+
setTimeout(() => this.inputElement.reportValidity(), 0);
|
87
87
|
this.validate();
|
88
88
|
};
|
89
89
|
|
90
|
-
|
90
|
+
this.inputElement.oninvalid = () => {
|
91
91
|
this.validate();
|
92
92
|
};
|
93
93
|
}
|
@@ -9,6 +9,7 @@ import switchToggle from './switchToggle';
|
|
9
9
|
import container from './container';
|
10
10
|
import logo from './logo';
|
11
11
|
import text from './text';
|
12
|
+
import passcode from './passcode';
|
12
13
|
|
13
14
|
export default {
|
14
15
|
button,
|
@@ -21,5 +22,6 @@ export default {
|
|
21
22
|
switchToggle,
|
22
23
|
container,
|
23
24
|
logo,
|
24
|
-
text
|
25
|
+
text,
|
26
|
+
passcode
|
25
27
|
};
|