@descope/web-components-ui 1.0.135 → 1.0.148
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/package.json +77 -56
- package/src/baseClasses/createBaseClass.js +18 -16
- package/src/baseClasses/createBaseInputClass.js +14 -8
- package/src/baseClasses/createCssVarImageClass.js +27 -23
- package/src/components/boolean-fields/booleanFieldMixin.js +18 -29
- package/src/components/boolean-fields/commonStyles.js +1 -1
- package/src/components/boolean-fields/descope-boolean-field-internal/BooleanFieldInternal.js +46 -51
- package/src/components/boolean-fields/descope-boolean-field-internal/index.js +1 -1
- package/src/components/boolean-fields/descope-checkbox/CheckboxClass.js +80 -85
- package/src/components/boolean-fields/descope-checkbox/index.js +2 -2
- package/src/components/boolean-fields/descope-switch-toggle/SwitchToggleClass.js +88 -95
- package/src/components/boolean-fields/descope-switch-toggle/index.js +2 -2
- package/src/components/descope-button/ButtonClass.js +57 -47
- package/src/components/descope-button/clickableMixin.js +10 -0
- package/src/components/descope-combo-box/ComboBoxClass.js +156 -160
- package/src/components/descope-container/ContainerClass.js +32 -42
- package/src/components/descope-date-picker/index.js +9 -14
- package/src/components/descope-divider/DividerClass.js +52 -62
- package/src/components/descope-email-field/EmailFieldClass.js +25 -20
- package/src/components/descope-image/ImageClass.js +21 -24
- package/src/components/descope-link/LinkClass.js +31 -35
- package/src/components/descope-loader-linear/LoaderLinearClass.js +31 -36
- package/src/components/descope-loader-radial/LoaderRadialClass.js +23 -30
- package/src/components/descope-logo/LogoClass.js +5 -1
- package/src/components/descope-new-password/NewPasswordClass.js +63 -81
- package/src/components/descope-new-password/descope-new-password-internal/NewPasswordInternal.js +157 -162
- package/src/components/descope-new-password/descope-new-password-internal/componentName.js +1 -1
- package/src/components/descope-new-password/descope-new-password-internal/index.js +3 -3
- package/src/components/descope-new-password/index.js +3 -3
- package/src/components/descope-number-field/NumberFieldClass.js +25 -20
- package/src/components/descope-passcode/PasscodeClass.js +95 -95
- package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +151 -157
- package/src/components/descope-passcode/descope-passcode-internal/helpers.js +7 -8
- package/src/components/descope-passcode/descope-passcode-internal/index.js +2 -2
- package/src/components/descope-passcode/index.js +2 -2
- package/src/components/descope-password/PasswordClass.js +75 -83
- package/src/components/descope-password/passwordDraggableMixin.js +28 -27
- package/src/components/descope-phone-field/CountryCodes.js +1210 -1210
- package/src/components/descope-phone-field/PhoneFieldClass.js +139 -141
- package/src/components/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js +157 -173
- package/src/components/descope-phone-field/helpers.js +3 -3
- package/src/components/descope-text/TextClass.js +25 -29
- package/src/components/descope-text-area/TextAreaClass.js +68 -67
- package/src/components/descope-text-field/TextFieldClass.js +42 -37
- package/src/components/descope-text-field/textFieldMappings.js +40 -55
- package/src/components/descope-totp-image/TotpImageClass.js +5 -1
- package/src/components/descope-upload-file/UploadFileClass.js +202 -0
- package/src/components/descope-upload-file/helpers.js +11 -0
- package/src/components/descope-upload-file/index.js +6 -0
- package/src/constants.js +3 -3
- package/src/helpers/componentHelpers.js +68 -74
- package/src/helpers/index.js +17 -16
- package/src/helpers/mixinsHelpers.js +21 -10
- package/src/helpers/themeHelpers/colorsHelpers.js +18 -18
- package/src/helpers/themeHelpers/componentsThemeManager.js +7 -6
- package/src/helpers/themeHelpers/index.js +114 -124
- package/src/helpers/themeHelpers/resetHelpers.js +16 -16
- package/src/index.cjs.js +3 -3
- package/src/index.d.ts +22 -21
- package/src/index.js +5 -4
- package/src/index.umd.js +14 -13
- package/src/mixins/changeMixin.js +18 -17
- package/src/mixins/componentNameValidationMixin.js +19 -19
- package/src/mixins/createProxy.js +33 -33
- package/src/mixins/createStyleMixin/helpers.js +54 -64
- package/src/mixins/createStyleMixin/index.js +155 -141
- package/src/mixins/draggableMixin.js +61 -61
- package/src/mixins/hoverableMixin.js +11 -13
- package/src/mixins/index.js +6 -6
- package/src/mixins/inputEventsDispatchingMixin.js +61 -60
- package/src/mixins/inputValidationMixin.js +153 -148
- package/src/mixins/lifecycleEventsMixin.js +17 -15
- package/src/mixins/normalizeBooleanAttributesMixin.js +31 -23
- package/src/mixins/portalMixin.js +58 -52
- package/src/mixins/proxyInputMixin.js +138 -132
- package/src/theme/components/button.js +86 -81
- package/src/theme/components/checkbox.js +26 -28
- package/src/theme/components/comboBox.js +32 -31
- package/src/theme/components/container.js +99 -89
- package/src/theme/components/divider.js +30 -31
- package/src/theme/components/emailField.js +20 -19
- package/src/theme/components/image.js +3 -3
- package/src/theme/components/index.js +33 -25
- package/src/theme/components/inputWrapper.js +28 -25
- package/src/theme/components/link.js +29 -36
- package/src/theme/components/loader/index.js +3 -3
- package/src/theme/components/loader/loaderLinear.js +34 -34
- package/src/theme/components/loader/loaderRadial.js +40 -34
- package/src/theme/components/logo.js +4 -4
- package/src/theme/components/newPassword.js +14 -13
- package/src/theme/components/numberField.js +20 -19
- package/src/theme/components/passcode.js +20 -22
- package/src/theme/components/password.js +22 -21
- package/src/theme/components/phoneField.js +23 -23
- package/src/theme/components/switchToggle.js +47 -46
- package/src/theme/components/text.js +72 -72
- package/src/theme/components/textArea.js +27 -25
- package/src/theme/components/textField.js +23 -22
- package/src/theme/components/totpImage.js +4 -4
- package/src/theme/components/uploadFile.js +60 -0
- package/src/theme/globals.js +123 -124
- package/src/theme/index.js +1 -1
- package/dist/cjs/index.cjs.js +0 -5924
- package/dist/cjs/index.cjs.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/index.d.ts +0 -51
- package/dist/index.esm.js +0 -6606
- package/dist/index.esm.js.map +0 -1
- package/dist/umd/1018.js +0 -577
- package/dist/umd/1018.js.LICENSE.txt +0 -23
- package/dist/umd/2481.js +0 -1
- package/dist/umd/3208.js +0 -2
- package/dist/umd/3208.js.LICENSE.txt +0 -5
- package/dist/umd/3585.js +0 -1
- package/dist/umd/3878.js +0 -1
- package/dist/umd/4201.js +0 -1
- package/dist/umd/422.js +0 -2
- package/dist/umd/422.js.LICENSE.txt +0 -5
- package/dist/umd/4447.js +0 -1
- package/dist/umd/4513.js +0 -1
- package/dist/umd/4803.js +0 -1
- package/dist/umd/541.js +0 -744
- package/dist/umd/541.js.LICENSE.txt +0 -21
- package/dist/umd/5767.js +0 -2
- package/dist/umd/5767.js.LICENSE.txt +0 -15
- package/dist/umd/5806.js +0 -109
- package/dist/umd/5806.js.LICENSE.txt +0 -5
- package/dist/umd/7056.js +0 -48
- package/dist/umd/7056.js.LICENSE.txt +0 -5
- package/dist/umd/7101.js +0 -148
- package/dist/umd/7101.js.LICENSE.txt +0 -11
- package/dist/umd/729.js +0 -1
- package/dist/umd/7824.js +0 -229
- package/dist/umd/7824.js.LICENSE.txt +0 -27
- package/dist/umd/7840.js +0 -356
- package/dist/umd/7840.js.LICENSE.txt +0 -61
- package/dist/umd/8725.js +0 -37
- package/dist/umd/8725.js.LICENSE.txt +0 -11
- package/dist/umd/9211.js +0 -312
- package/dist/umd/9211.js.LICENSE.txt +0 -5
- package/dist/umd/9241.js +0 -1
- package/dist/umd/9314.js +0 -283
- package/dist/umd/9314.js.LICENSE.txt +0 -27
- package/dist/umd/9437.js +0 -19
- package/dist/umd/9437.js.LICENSE.txt +0 -5
- package/dist/umd/9515.js +0 -202
- package/dist/umd/9515.js.LICENSE.txt +0 -11
- package/dist/umd/9789.js +0 -1
- package/dist/umd/boolean-fields-descope-boolean-field-internal-index-js.js +0 -1
- package/dist/umd/boolean-fields-descope-checkbox-index-js.js +0 -1
- package/dist/umd/boolean-fields-descope-switch-toggle-index-js.js +0 -1
- package/dist/umd/descope-button-index-js.js +0 -1
- package/dist/umd/descope-combo-box-index-js.js +0 -1
- package/dist/umd/descope-container-index-js.js +0 -1
- package/dist/umd/descope-date-picker-index-js.js +0 -1
- package/dist/umd/descope-divider-index-js.js +0 -1
- package/dist/umd/descope-email-field-index-js.js +0 -1
- package/dist/umd/descope-image-index-js.js +0 -1
- package/dist/umd/descope-link-index-js.js +0 -1
- package/dist/umd/descope-loader-linear-index-js.js +0 -1
- package/dist/umd/descope-loader-radial-index-js.js +0 -1
- package/dist/umd/descope-logo-index-js.js +0 -1
- package/dist/umd/descope-new-password-descope-new-password-internal-index-js.js +0 -1
- package/dist/umd/descope-new-password-index-js.js +0 -1
- package/dist/umd/descope-number-field-index-js.js +0 -1
- package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js +0 -1
- package/dist/umd/descope-passcode-index-js.js +0 -1
- package/dist/umd/descope-password-index-js.js +0 -1
- package/dist/umd/descope-phone-field-descope-phone-field-internal-index-js.js +0 -1
- package/dist/umd/descope-phone-field-index-js.js +0 -1
- package/dist/umd/descope-text-area-index-js.js +0 -1
- package/dist/umd/descope-text-field-index-js.js +0 -1
- package/dist/umd/descope-text-index-js.js +0 -1
- package/dist/umd/descope-totp-image-index-js.js +0 -1
- package/dist/umd/index.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { observeAttributes } from
|
|
1
|
+
import { observeAttributes } from '../helpers/componentHelpers';
|
|
2
2
|
|
|
3
3
|
const booleanAttributesList = [
|
|
4
4
|
'readonly',
|
|
@@ -16,31 +16,39 @@ const booleanAttributesList = [
|
|
|
16
16
|
'focus-ring',
|
|
17
17
|
'opened',
|
|
18
18
|
'active',
|
|
19
|
-
'password-visible'
|
|
20
|
-
]
|
|
19
|
+
'password-visible',
|
|
20
|
+
];
|
|
21
21
|
|
|
22
22
|
const isBooleanAttribute = (attr) => {
|
|
23
|
-
return booleanAttributesList.includes(attr)
|
|
24
|
-
}
|
|
23
|
+
return booleanAttributesList.includes(attr);
|
|
24
|
+
};
|
|
25
25
|
// we want all the valueless attributes to have "true" value
|
|
26
26
|
// and all the falsy attribute to be removed
|
|
27
|
-
export const normalizeBooleanAttributesMixin = (superclass) =>
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
export const normalizeBooleanAttributesMixin = (superclass) =>
|
|
28
|
+
class NormalizeBooleanAttributesMixinClass extends superclass {
|
|
29
|
+
init() {
|
|
30
|
+
super.init?.();
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
observeAttributes(
|
|
33
|
+
this,
|
|
34
|
+
(attrs) =>
|
|
35
|
+
attrs.forEach((attr) => {
|
|
36
|
+
const attrVal = this.getAttribute(attr);
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
38
|
+
if (isBooleanAttribute(attr)) {
|
|
39
|
+
if (attrVal === '') {
|
|
40
|
+
this.setAttribute(attr, 'true');
|
|
41
|
+
} else if (attrVal === 'false') {
|
|
42
|
+
this.removeAttribute(attr);
|
|
43
|
+
}
|
|
44
|
+
} else if (!attrVal) {
|
|
45
|
+
// eslint-disable-next-line no-console
|
|
46
|
+
console.warn(
|
|
47
|
+
`attribute "${attr}" has no value, should it be added to the boolean attributes list?`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}),
|
|
51
|
+
{}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -1,71 +1,77 @@
|
|
|
1
|
-
import { PORTAL_THEME_PREFIX } from
|
|
2
|
-
import { kebabCaseJoin
|
|
3
|
-
import { forwardAttrs } from
|
|
4
|
-
import { createStyleMixin } from
|
|
5
|
-
import { createCssVarsList } from
|
|
1
|
+
import { PORTAL_THEME_PREFIX } from '../constants';
|
|
2
|
+
import { kebabCaseJoin } from '../helpers';
|
|
3
|
+
import { forwardAttrs } from '../helpers/componentHelpers';
|
|
4
|
+
import { createStyleMixin } from './createStyleMixin';
|
|
5
|
+
import { createCssVarsList } from './createStyleMixin/helpers';
|
|
6
6
|
|
|
7
7
|
// this is needed because we might generate the same css vars names
|
|
8
|
-
// e.g. "overlayColor" attribute in style mixin's mapping,
|
|
9
|
-
// will generate the same var as "color" attribute in portals's mapping
|
|
8
|
+
// e.g. "overlayColor" attribute in style mixin's mapping,
|
|
9
|
+
// will generate the same var as "color" attribute in portals's mapping
|
|
10
10
|
// when the portal name is "overlay".
|
|
11
11
|
// because of that, we are adding this separator that is also used as a differentiator
|
|
12
|
-
const DISPLAY_NAME_SEPARATOR = '_'
|
|
12
|
+
const DISPLAY_NAME_SEPARATOR = '_';
|
|
13
13
|
|
|
14
14
|
const sanitizeSelector = (selector) => selector.replace(/[^\w\s]/gi, '');
|
|
15
15
|
|
|
16
16
|
const getDomNode = (maybeDomNode) => maybeDomNode.host || maybeDomNode;
|
|
17
17
|
|
|
18
|
-
export const portalMixin =
|
|
19
|
-
name,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
forward: { attributes = [], include = true } = {}
|
|
23
|
-
}) => (superclass) => {
|
|
24
|
-
const eleDisplayName = name || sanitizeSelector(selector)
|
|
18
|
+
export const portalMixin =
|
|
19
|
+
({ name, selector, mappings = {}, forward: { attributes = [], include = true } = {} }) =>
|
|
20
|
+
(superclass) => {
|
|
21
|
+
const eleDisplayName = name || sanitizeSelector(selector);
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
const BaseClass = createStyleMixin({
|
|
24
|
+
mappings,
|
|
25
|
+
})(superclass);
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
return class PortalMixinClass extends BaseClass {
|
|
28
|
+
static get cssVarList() {
|
|
29
|
+
return {
|
|
30
|
+
...BaseClass.cssVarList,
|
|
31
|
+
[eleDisplayName]: createCssVarsList(
|
|
32
|
+
kebabCaseJoin(superclass.componentName, DISPLAY_NAME_SEPARATOR + eleDisplayName),
|
|
33
|
+
mappings
|
|
34
|
+
),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
#portalEle;
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
constructor() {
|
|
41
|
+
// we cannot use "this" before calling "super"
|
|
42
|
+
const getRootElement = (that) => {
|
|
43
|
+
const baseEle = that.shadowRoot.querySelector(that.baseSelector);
|
|
44
|
+
const portal = selector ? baseEle.shadowRoot.querySelector(selector) : baseEle;
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
return portal.shadowRoot || portal;
|
|
47
|
+
};
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
super({
|
|
50
|
+
getRootElement,
|
|
51
|
+
componentNameSuffix: DISPLAY_NAME_SEPARATOR + eleDisplayName,
|
|
52
|
+
themeSection: PORTAL_THEME_PREFIX + eleDisplayName,
|
|
53
|
+
baseSelector: ':host',
|
|
54
|
+
});
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
this.#portalEle = getDomNode(getRootElement(this));
|
|
57
|
+
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
#handleHoverAttribute() {
|
|
60
|
+
this.#portalEle.onmouseenter = (e) => {
|
|
61
|
+
e.target.setAttribute('hover', 'true');
|
|
62
|
+
};
|
|
63
|
+
this.#portalEle.onmouseleave = (e) => {
|
|
64
|
+
e.target.removeAttribute('hover');
|
|
65
|
+
};
|
|
66
|
+
}
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
init() {
|
|
69
|
+
super.init?.();
|
|
70
|
+
forwardAttrs(this, this.#portalEle, {
|
|
71
|
+
[include ? 'includeAttrs' : 'excludeAttrs']: attributes,
|
|
72
|
+
});
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
74
|
+
this.#handleHoverAttribute();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
@@ -1,148 +1,154 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
import { compose } from '../helpers';
|
|
3
|
+
import { forwardAttrs, getComponentName } from '../helpers/componentHelpers';
|
|
4
|
+
import { createDispatchEvent } from '../helpers/mixinsHelpers';
|
|
5
|
+
import { createStyleMixin } from './createStyleMixin';
|
|
6
|
+
import { inputValidationMixin } from './inputValidationMixin';
|
|
6
7
|
|
|
7
8
|
const errorAttrs = ['invalid', 'required'];
|
|
8
9
|
|
|
9
10
|
const propertyObserver = (src, target, property) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
Object.defineProperty(src, property, {
|
|
12
|
+
set(v) {
|
|
13
|
+
target[property] = v;
|
|
14
|
+
},
|
|
15
|
+
get() {
|
|
16
|
+
return target[property];
|
|
17
|
+
},
|
|
18
|
+
configurable: true,
|
|
19
|
+
});
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
// recursively take the first slot child until it finds an element which is not a slot
|
|
22
23
|
// stops after "nestingLevel" times
|
|
23
24
|
const getNestedInput = (ele) => {
|
|
24
|
-
|
|
25
|
+
if (!ele) return undefined;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
const nestingLevel = 10;
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
let nonSlotEle = ele;
|
|
30
|
+
for (let i = 0; i < nestingLevel; i++) {
|
|
31
|
+
[nonSlotEle] = nonSlotEle.assignedElements();
|
|
32
|
+
if (nonSlotEle.localName !== 'slot') return nonSlotEle;
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
35
|
+
};
|
|
34
36
|
|
|
35
37
|
const proxyInputMixin = (superclass) =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
38
|
+
class ProxyInputMixinClass extends inputValidationMixin(superclass) {
|
|
39
|
+
static get observedAttributes() {
|
|
40
|
+
return [...(superclass.observedAttributes || []), ...errorAttrs];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#inputElement;
|
|
44
|
+
|
|
45
|
+
#dispatchChange = createDispatchEvent.bind(this, 'change');
|
|
46
|
+
|
|
47
|
+
constructor() {
|
|
48
|
+
super();
|
|
49
|
+
|
|
50
|
+
this.#inputElement = super.inputElement;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// the web-component does not loaded immediately, so we want to defer the warning
|
|
54
|
+
// and show it only if the input element was not found after the component is loaded
|
|
55
|
+
warnIfInputElementIsMissing() {
|
|
56
|
+
clearTimeout(this.inputElementTimerId);
|
|
57
|
+
|
|
58
|
+
this.inputElementTimerId = setTimeout(() => {
|
|
59
|
+
// eslint-disable-next-line no-console
|
|
60
|
+
!this.#inputElement && console.warn(this.localName, 'no input was found');
|
|
61
|
+
}, 0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get name() {
|
|
65
|
+
return this.getAttribute('name');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get inputElement() {
|
|
69
|
+
this.warnIfInputElementIsMissing();
|
|
70
|
+
|
|
71
|
+
const inputSlot = this.baseElement.shadowRoot?.querySelector('slot[name="input"]');
|
|
72
|
+
const textAreaSlot = this.baseElement.shadowRoot?.querySelector('slot[name="textarea"]');
|
|
73
|
+
|
|
74
|
+
this.#inputElement ??= getNestedInput(inputSlot) || getNestedInput(textAreaSlot);
|
|
75
|
+
|
|
76
|
+
return this.#inputElement;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
set inputElement(ele) {
|
|
80
|
+
this.#inputElement = ele;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getValidity() {
|
|
84
|
+
return this.inputElement?.validity || {};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
handleInternalInputErrorMessage() {
|
|
88
|
+
if (!this.inputElement.checkValidity()) {
|
|
89
|
+
this.inputElement.setCustomValidity(this.validationMessage);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#handleErrorMessage() {
|
|
94
|
+
this.handleInternalInputErrorMessage();
|
|
95
|
+
this.setAttribute('error-message', this.validationMessage);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
init() {
|
|
99
|
+
super.init?.();
|
|
100
|
+
|
|
101
|
+
this.inputElement.addEventListener('input', (e) => {
|
|
102
|
+
if (!this.inputElement.checkValidity()) {
|
|
103
|
+
this.inputElement.setCustomValidity('');
|
|
104
|
+
// after updating the input validity we want to trigger set validity on the wrapping element
|
|
105
|
+
// so we will get the updated validity
|
|
106
|
+
this.setCustomValidity('');
|
|
107
|
+
|
|
108
|
+
// Vaadin is getting the input event before us,
|
|
109
|
+
// so in order to make sure they use the updated validity
|
|
110
|
+
// we calling their fn after updating the input validity
|
|
111
|
+
this.baseElement.__onInput(e);
|
|
112
|
+
|
|
113
|
+
this.#handleErrorMessage();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
this.baseElement.addEventListener('change', () => {
|
|
118
|
+
this.#dispatchChange();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
this.#inputElement.addEventListener('blur', () => {
|
|
122
|
+
if (!this.checkValidity()) {
|
|
123
|
+
this.setAttribute('invalid', 'true');
|
|
124
|
+
this.#handleErrorMessage();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
this.addEventListener('invalid', () => {
|
|
129
|
+
if (!this.checkValidity()) {
|
|
130
|
+
this.setAttribute('invalid', 'true');
|
|
131
|
+
}
|
|
132
|
+
this.#handleErrorMessage();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
this.handleInternalInputErrorMessage();
|
|
136
|
+
|
|
137
|
+
// sync properties
|
|
138
|
+
propertyObserver(this, this.inputElement, 'value');
|
|
139
|
+
propertyObserver(this, this.inputElement, 'selectionStart');
|
|
140
|
+
this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
|
|
83
141
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
#handleErrorMessage() {
|
|
91
|
-
this.handleInternalInputErrorMessage()
|
|
92
|
-
this.setAttribute('error-message', this.validationMessage)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
init() {
|
|
96
|
-
super.init?.();
|
|
97
|
-
|
|
98
|
-
this.inputElement.addEventListener('input', (e) => {
|
|
99
|
-
if (!this.inputElement.checkValidity()) {
|
|
100
|
-
this.inputElement.setCustomValidity('')
|
|
101
|
-
// after updating the input validity we want to trigger set validity on the wrapping element
|
|
102
|
-
// so we will get the updated validity
|
|
103
|
-
this.setCustomValidity('')
|
|
104
|
-
|
|
105
|
-
// Vaadin is getting the input event before us,
|
|
106
|
-
// so in order to make sure they use the updated validity
|
|
107
|
-
// we calling their fn after updating the input validity
|
|
108
|
-
this.baseElement.__onInput(e)
|
|
109
|
-
|
|
110
|
-
this.#handleErrorMessage()
|
|
111
|
-
}
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
this.baseElement.addEventListener('change', () => {
|
|
115
|
-
this.#dispatchChange()
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
this.#inputElement.addEventListener('blur', () => {
|
|
119
|
-
if (!this.checkValidity()) {
|
|
120
|
-
this.setAttribute('invalid', 'true')
|
|
121
|
-
this.#handleErrorMessage()
|
|
122
|
-
}
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
this.addEventListener('invalid', () => {
|
|
127
|
-
if (!this.checkValidity()) {
|
|
128
|
-
this.setAttribute('invalid', 'true');
|
|
129
|
-
}
|
|
130
|
-
this.#handleErrorMessage()
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
this.handleInternalInputErrorMessage();
|
|
134
|
-
|
|
135
|
-
// sync properties
|
|
136
|
-
propertyObserver(this, this.inputElement, 'value');
|
|
137
|
-
propertyObserver(this, this.inputElement, 'selectionStart');
|
|
138
|
-
this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
|
|
139
|
-
|
|
140
|
-
forwardAttrs(this, this.inputElement, { includeAttrs: ['inputmode'] })
|
|
141
|
-
}
|
|
142
|
-
};
|
|
142
|
+
forwardAttrs(this, this.inputElement, { includeAttrs: ['inputmode'] });
|
|
143
|
+
}
|
|
144
|
+
};
|
|
143
145
|
|
|
144
146
|
const composedProxyInputMixin = compose(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
proxyInputMixin,
|
|
148
|
+
// in order to use input-wrapper across all our input components, we need to inject its theme
|
|
149
|
+
// to every proxy input mixin, to allow its css vars to be scoped properly and accessible
|
|
150
|
+
// in the proxy input component
|
|
151
|
+
createStyleMixin({ componentNameOverride: getComponentName('input-wrapper') })
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
export { composedProxyInputMixin as proxyInputMixin };
|
|
@@ -6,11 +6,11 @@ const globalRefs = getThemeRefs(globals);
|
|
|
6
6
|
const compVars = ButtonClass.cssVarList;
|
|
7
7
|
|
|
8
8
|
const mode = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
primary: globalRefs.colors.primary,
|
|
10
|
+
secondary: globalRefs.colors.secondary,
|
|
11
|
+
success: globalRefs.colors.success,
|
|
12
|
+
error: globalRefs.colors.error,
|
|
13
|
+
surface: globalRefs.colors.surface,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const [helperTheme, helperRefs, helperVars] = createHelperVars({ mode }, componentName);
|
|
@@ -19,85 +19,90 @@ const verticalPaddingRatio = 3;
|
|
|
19
19
|
const horizontalPaddingRatio = 2;
|
|
20
20
|
|
|
21
21
|
const button = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
22
|
+
...helperTheme,
|
|
23
|
+
|
|
24
|
+
[compVars.fontFamily]: globalRefs.fonts.font1.family,
|
|
25
|
+
|
|
26
|
+
[compVars.cursor]: 'pointer',
|
|
27
|
+
[compVars.hostHeight]: '3em',
|
|
28
|
+
|
|
29
|
+
[compVars.borderRadius]: globalRefs.radius.sm,
|
|
30
|
+
[compVars.borderWidth]: globalRefs.border.xs,
|
|
31
|
+
[compVars.borderStyle]: 'solid',
|
|
32
|
+
[compVars.borderColor]: 'transparent',
|
|
33
|
+
|
|
34
|
+
[compVars.labelSpacing]: '0.25em',
|
|
35
|
+
|
|
36
|
+
[compVars.verticalPadding]: `calc(var(${compVars.fontSize}) / ${verticalPaddingRatio})`,
|
|
37
|
+
[compVars.horizontalPadding]: `calc(var(${compVars.fontSize}) / ${horizontalPaddingRatio})`,
|
|
38
|
+
|
|
39
|
+
[compVars.outlineWidth]: globals.border.sm,
|
|
40
|
+
[compVars.outlineOffset]: '0px', // keep `px` unit for external calc
|
|
41
|
+
[compVars.outlineStyle]: 'solid',
|
|
42
|
+
[compVars.outlineColor]: 'transparent',
|
|
43
|
+
|
|
44
|
+
size: {
|
|
45
|
+
xs: { [compVars.fontSize]: '12px' },
|
|
46
|
+
sm: { [compVars.fontSize]: '14px' },
|
|
47
|
+
md: { [compVars.fontSize]: '16px' },
|
|
48
|
+
lg: { [compVars.fontSize]: '18px' },
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
_fullWidth: {
|
|
52
|
+
[compVars.hostWidth]: '100%',
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
_loading: {
|
|
56
|
+
[compVars.cursor]: 'wait',
|
|
57
|
+
[compVars.labelTextColor]: helperRefs.main,
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
variant: {
|
|
61
|
+
contained: {
|
|
62
|
+
[compVars.labelTextColor]: helperRefs.contrast,
|
|
63
|
+
[compVars.backgroundColor]: helperRefs.main,
|
|
64
|
+
_hover: {
|
|
65
|
+
[compVars.backgroundColor]: helperRefs.dark,
|
|
66
|
+
_loading: {
|
|
67
|
+
[compVars.backgroundColor]: helperRefs.main,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
_active: {
|
|
71
|
+
[compVars.backgroundColor]: helperRefs.main,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
outline: {
|
|
76
|
+
[compVars.labelTextColor]: helperRefs.main,
|
|
77
|
+
[compVars.borderColor]: 'currentColor',
|
|
78
|
+
_hover: {
|
|
79
|
+
[compVars.labelTextColor]: helperRefs.dark,
|
|
80
|
+
},
|
|
81
|
+
_active: {
|
|
82
|
+
[compVars.labelTextColor]: helperRefs.main,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
link: {
|
|
87
|
+
[compVars.labelTextColor]: helperRefs.main,
|
|
88
|
+
_hover: {
|
|
89
|
+
[compVars.labelTextColor]: helperRefs.dark,
|
|
90
|
+
[compVars.labelTextDecoration]: 'underline',
|
|
91
|
+
},
|
|
92
|
+
_active: {
|
|
93
|
+
[compVars.labelTextColor]: helperRefs.dark,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
_focused: {
|
|
99
|
+
[compVars.outlineColor]: globalRefs.colors.surface.main,
|
|
100
|
+
},
|
|
96
101
|
};
|
|
97
102
|
|
|
98
103
|
export default button;
|
|
99
104
|
|
|
100
105
|
export const vars = {
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
...compVars,
|
|
107
|
+
...helperVars,
|
|
103
108
|
};
|