@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,10 +1,9 @@
|
|
|
1
|
-
|
|
2
1
|
// create a dispatch event function that also calls to the onevent function in case it's set
|
|
3
2
|
// usage example:
|
|
4
3
|
// #dispatchSomething = createDispatchEvent.bind(this, 'something' { ...options })
|
|
5
4
|
// this will dispatch a new event when called, but also call to "onsomething"
|
|
6
5
|
export function createDispatchEvent(eventName, options = {}) {
|
|
7
|
-
const event = new Event(eventName, options)
|
|
6
|
+
const event = new Event(eventName, options);
|
|
8
7
|
|
|
9
8
|
this[`on${eventName}`]?.(event); // in case we got an event callback as property
|
|
10
9
|
this.dispatchEvent(event);
|
|
@@ -14,22 +13,34 @@ export function createDispatchEvent(eventName, options = {}) {
|
|
|
14
13
|
// usage example:
|
|
15
14
|
// createEventListener.call(this,'change', this.onChange, { element? , ...options })
|
|
16
15
|
export function createEventListener(event, callback, { element, ...options } = {}) {
|
|
17
|
-
const timerId = setTimeout(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const timerId = setTimeout(
|
|
17
|
+
() =>
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.warn(
|
|
20
|
+
this.localName,
|
|
21
|
+
'is not using "lifecycleEventsMixin", events will not be removed automatically on disconnect'
|
|
22
|
+
),
|
|
23
|
+
2000
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
this.addEventListener(
|
|
27
|
+
'connected',
|
|
28
|
+
() => {
|
|
29
|
+
clearTimeout(timerId);
|
|
30
|
+
},
|
|
31
|
+
{ once: true }
|
|
32
|
+
);
|
|
22
33
|
|
|
23
34
|
const targetEle = element || this;
|
|
24
35
|
const boundCallback = callback.bind(this);
|
|
25
36
|
|
|
26
37
|
const onDisconnect = () => {
|
|
27
38
|
targetEle.removeEventListener(event, boundCallback);
|
|
28
|
-
}
|
|
39
|
+
};
|
|
29
40
|
|
|
30
|
-
this.addEventListener('disconnected', onDisconnect, { once: true })
|
|
41
|
+
this.addEventListener('disconnected', onDisconnect, { once: true });
|
|
31
42
|
|
|
32
43
|
targetEle.addEventListener(event, boundCallback, options);
|
|
33
44
|
|
|
34
|
-
return onDisconnect
|
|
45
|
+
return onDisconnect;
|
|
35
46
|
}
|
|
@@ -3,30 +3,30 @@ import Color from 'color';
|
|
|
3
3
|
const genDark = (c, percentage = 0.5) => c.darken(percentage).hex();
|
|
4
4
|
const genLight = (c, percentage = 0.5) => c.lighten(percentage).hex();
|
|
5
5
|
const genContrast = (c, percentage = 0.9) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const isDark = c.isDark();
|
|
7
|
+
return c
|
|
8
|
+
.mix(Color(isDark ? 'white' : 'black'), percentage)
|
|
9
|
+
.saturate(1)
|
|
10
|
+
.hex();
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const genColor = (color) => {
|
|
14
|
-
|
|
14
|
+
const mainColor = new Color(color.main || color);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
return {
|
|
17
|
+
main: mainColor.hex(),
|
|
18
|
+
dark: color.dark || genDark(mainColor),
|
|
19
|
+
light: color.light || genLight(mainColor),
|
|
20
|
+
contrast: color.contrast || genContrast(mainColor),
|
|
21
|
+
};
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export const genColors = (colors) => {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
return Object.keys(colors).reduce((acc, colorName) => {
|
|
26
|
+
const currentColor = colors[colorName];
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
return Object.assign(acc, {
|
|
29
|
+
[colorName]: genColor(currentColor),
|
|
30
|
+
});
|
|
31
|
+
}, {});
|
|
32
32
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
class ComponentsThemeManager {
|
|
3
2
|
static mountOnPropName = 'DescopeThemeManager';
|
|
4
3
|
|
|
@@ -9,8 +8,8 @@ class ComponentsThemeManager {
|
|
|
9
8
|
#callbacks = new Set();
|
|
10
9
|
|
|
11
10
|
#notify() {
|
|
12
|
-
this.#callbacks.forEach(cb => cb?.());
|
|
13
|
-
}
|
|
11
|
+
this.#callbacks.forEach((cb) => cb?.());
|
|
12
|
+
}
|
|
14
13
|
|
|
15
14
|
get currentThemeName() {
|
|
16
15
|
return this.#currentThemeName;
|
|
@@ -28,8 +27,10 @@ class ComponentsThemeManager {
|
|
|
28
27
|
onCurrentThemeChange(cb) {
|
|
29
28
|
this.#callbacks.add(cb);
|
|
30
29
|
|
|
31
|
-
return () => {
|
|
32
|
-
|
|
30
|
+
return () => {
|
|
31
|
+
this.#callbacks.delete(cb);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
33
34
|
|
|
34
35
|
set themes(themes) {
|
|
35
36
|
this.#themes = themes;
|
|
@@ -37,4 +38,4 @@ class ComponentsThemeManager {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export const componentsThemeManager = new ComponentsThemeManager()
|
|
41
|
+
export const componentsThemeManager = new ComponentsThemeManager();
|
|
@@ -7,160 +7,150 @@ import { getComponentName, getCssVarName } from '../componentHelpers';
|
|
|
7
7
|
const getVarName = (path) => getCssVarName(DESCOPE_PREFIX, ...path);
|
|
8
8
|
|
|
9
9
|
const transformTheme = (theme, path, getTransformation) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}, {});
|
|
10
|
+
return Object.entries(theme).reduce((acc, [key, val]) => {
|
|
11
|
+
if (val?.constructor !== Object) {
|
|
12
|
+
return merge(acc, getTransformation(path.concat(key), val));
|
|
13
|
+
}
|
|
14
|
+
return merge(acc, transformTheme(val, [...path, key], getTransformation));
|
|
15
|
+
}, {});
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
const stringifyArray = (strArr) =>
|
|
20
|
-
|
|
19
|
+
strArr.map((str) => (str.includes(' ') ? `"${str}"` : str)).join(', ');
|
|
21
20
|
|
|
22
21
|
const getCssVarValue = (val) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
22
|
+
switch (true) {
|
|
23
|
+
case Array.isArray(val):
|
|
24
|
+
return stringifyArray(val);
|
|
25
|
+
case isUrl(val):
|
|
26
|
+
return `url(${val})`;
|
|
27
|
+
default:
|
|
28
|
+
return val;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
32
31
|
|
|
33
32
|
export const themeToCSSVarsObj = (theme) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
transformTheme(theme, [], (path, val) => ({
|
|
34
|
+
[getVarName(path)]: getCssVarValue(val),
|
|
35
|
+
}));
|
|
37
36
|
|
|
38
37
|
export const getThemeRefs = (theme, prefix) =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
transformTheme(theme, [], (path) =>
|
|
39
|
+
set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`)
|
|
40
|
+
);
|
|
42
41
|
|
|
43
42
|
export const getThemeVars = (theme, prefix) =>
|
|
44
|
-
|
|
45
|
-
set({}, path, getVarName(prefix ? [prefix, ...path] : path))
|
|
46
|
-
);
|
|
43
|
+
transformTheme(theme, [], (path) => set({}, path, getVarName(prefix ? [prefix, ...path] : path)));
|
|
47
44
|
|
|
48
45
|
export const globalsThemeToStyle = (theme, themeName = '') => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
const style = Object.entries(themeToCSSVarsObj(theme)).reduce(
|
|
47
|
+
(acc, entry) => `${acc}${entry.join(':')};\n`,
|
|
48
|
+
''
|
|
49
|
+
);
|
|
53
50
|
|
|
54
|
-
|
|
51
|
+
if (!themeName) return style;
|
|
55
52
|
|
|
56
|
-
|
|
53
|
+
return `*[data-theme="${themeName}"] {${style}}`;
|
|
57
54
|
};
|
|
58
55
|
|
|
59
56
|
const componentsThemeToStyleObj = (componentsTheme) =>
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
57
|
+
transformTheme(componentsTheme, [], (path, val) => {
|
|
58
|
+
const [component, ...restPath] = path;
|
|
59
|
+
const property = restPath.pop();
|
|
60
|
+
const componentName = getComponentName(component);
|
|
61
|
+
|
|
62
|
+
if (property === 'undefined') {
|
|
63
|
+
// eslint-disable-next-line no-console
|
|
64
|
+
console.warn(componentName, `theme value: "${val}" is mapped to an invalid property`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// we need a support for portal components theme (e.g. overlay)
|
|
68
|
+
// this allows us to generate those themes under different sections
|
|
69
|
+
// if the theme has root level attribute that starts with #
|
|
70
|
+
// we are generating a new theme
|
|
71
|
+
let themeName = BASE_THEME_SECTION;
|
|
72
|
+
|
|
73
|
+
if (restPath[0] && restPath[0].startsWith(PORTAL_THEME_PREFIX)) {
|
|
74
|
+
themeName = restPath.shift();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// do not start with underscore -> key:value, must have 2 no underscore attrs in a row
|
|
78
|
+
// starts with underscore -> attribute selector
|
|
79
|
+
const attrsSelector = restPath.reduce((acc, section, idx) => {
|
|
80
|
+
if (section.startsWith('_')) return `${acc}[${kebabCase(section.replace(/^_/, ''))}="true"]`;
|
|
81
|
+
|
|
82
|
+
const nextSection = restPath[idx + 1];
|
|
83
|
+
|
|
84
|
+
if (typeof nextSection !== 'string' || nextSection.startsWith('_')) {
|
|
85
|
+
// eslint-disable-next-line no-console
|
|
86
|
+
console.error(
|
|
87
|
+
'theme generator',
|
|
88
|
+
`your theme structure is invalid, attribute "${section}" is followed by "${nextSection}" which is not allowed`
|
|
89
|
+
);
|
|
90
|
+
return acc;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return `${acc}[${kebabCase(section)}="${restPath.splice(idx + 1, 1).join('')}"]`;
|
|
94
|
+
}, '');
|
|
95
|
+
|
|
96
|
+
const selector = `:host${attrsSelector ? `(${attrsSelector})` : ''}`;
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
[componentName]: {
|
|
100
|
+
[themeName]: {
|
|
101
|
+
[selector]: {
|
|
102
|
+
[property]: getCssVarValue(val),
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
});
|
|
112
108
|
|
|
109
|
+
const componentsThemeToStyle = (componentsTheme) =>
|
|
110
|
+
Object.entries(componentsTheme).reduce(
|
|
111
|
+
(acc, [selector, vars]) =>
|
|
112
|
+
`${acc}${selector} { \n${Object.entries(vars)
|
|
113
|
+
.map(([key, val]) => `${key}: ${val}`)
|
|
114
|
+
.join(';\n')} \n}\n\n`,
|
|
115
|
+
''
|
|
116
|
+
);
|
|
113
117
|
|
|
114
118
|
export const createComponentsTheme = (componentsTheme) => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const componentsThemeToStyle = (componentsTheme) =>
|
|
133
|
-
Object.entries(componentsTheme).reduce(
|
|
134
|
-
(acc, [selector, vars]) =>
|
|
135
|
-
(acc += `${selector} { \n${Object.entries(
|
|
136
|
-
vars
|
|
137
|
-
)
|
|
138
|
-
.map(([key, val]) => `${key}: ${val}`)
|
|
139
|
-
.join(';\n')} \n}\n\n`),
|
|
140
|
-
''
|
|
141
|
-
);
|
|
119
|
+
const styleObj = componentsThemeToStyleObj(componentsTheme);
|
|
120
|
+
|
|
121
|
+
return Object.keys(styleObj).reduce((acc, componentName) => {
|
|
122
|
+
const componentThemes = styleObj[componentName];
|
|
123
|
+
|
|
124
|
+
return Object.assign(acc, {
|
|
125
|
+
[componentName]: Object.keys(componentThemes).reduce(
|
|
126
|
+
(res, theme) =>
|
|
127
|
+
Object.assign(res, { [theme]: componentsThemeToStyle(componentThemes[theme]) }),
|
|
128
|
+
{}
|
|
129
|
+
),
|
|
130
|
+
});
|
|
131
|
+
}, {});
|
|
132
|
+
};
|
|
142
133
|
|
|
143
134
|
export const themeToStyle = ({ globals, components }, themeName) => ({
|
|
144
|
-
|
|
145
|
-
|
|
135
|
+
globals: globalsThemeToStyle(globals, themeName),
|
|
136
|
+
components: createComponentsTheme(components),
|
|
146
137
|
});
|
|
147
138
|
|
|
148
139
|
const useVar = (varName) => `var(${varName})`;
|
|
149
140
|
|
|
150
141
|
export const createHelperVars = (theme, prefix) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
142
|
+
const res = transformTheme(theme, [], (path, value) => {
|
|
143
|
+
const modifiedPath = [...path];
|
|
144
|
+
const property = modifiedPath.splice(-1);
|
|
145
|
+
const varName = getCssVarName(prefix, property);
|
|
155
146
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const useVars = { [property]: useVar(varName) };
|
|
147
|
+
const vars = { [property]: varName };
|
|
148
|
+
const useVars = { [property]: useVar(varName) };
|
|
159
149
|
|
|
160
|
-
|
|
161
|
-
|
|
150
|
+
return { theme: set({}, [...modifiedPath, varName], value), useVars, vars };
|
|
151
|
+
});
|
|
162
152
|
|
|
163
|
-
|
|
153
|
+
return [res.theme, res.useVars, res.vars];
|
|
164
154
|
};
|
|
165
155
|
|
|
166
|
-
export { componentsThemeManager } from './componentsThemeManager'
|
|
156
|
+
export { componentsThemeManager } from './componentsThemeManager';
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
export const resetInputOverrides = (name, cssVarList) => `
|
|
2
|
-
${resetInputContainer(name)}
|
|
3
|
-
${resetInputCursor(name)}
|
|
4
|
-
${resetInputPlaceholder(name)}
|
|
5
|
-
${resetInputField(name)}
|
|
6
|
-
${resetInputAutoFill(name, cssVarList)}
|
|
7
|
-
${resetInputFieldInvalidBackgroundColor(name)}
|
|
8
|
-
${resetInitialHeight(name)}
|
|
9
|
-
${resetInputElement(name)}
|
|
10
|
-
${resetInputFieldunderlayingBorder(name)}
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
1
|
export const useHostExternalPadding = (cssVarList) => `
|
|
14
2
|
:host {
|
|
15
|
-
padding: calc(var(${cssVarList.inputOutlineWidth}) + var(${cssVarList.inputOutlineOffset}))
|
|
3
|
+
padding: calc(var(${cssVarList.inputOutlineWidth}) + var(${cssVarList.inputOutlineOffset}))
|
|
16
4
|
}
|
|
17
5
|
`;
|
|
18
6
|
|
|
19
|
-
export const
|
|
7
|
+
export const resetInputFieldUnderlayingBorder = (name) => `
|
|
20
8
|
${name}::part(input-field)::after {
|
|
21
9
|
border: none;
|
|
22
10
|
}
|
|
@@ -66,7 +54,7 @@ export const resetInputPlaceholder = (name, ele = 'input') => `
|
|
|
66
54
|
${name}[disabled] > ${ele}:placeholder-shown,
|
|
67
55
|
${name}[readonly] > ${ele}:placeholder-shown {
|
|
68
56
|
opacity: 1;
|
|
69
|
-
}
|
|
57
|
+
}
|
|
70
58
|
`;
|
|
71
59
|
|
|
72
60
|
export const resetInputAutoFill = (name, cssVarList) => `
|
|
@@ -77,7 +65,7 @@ export const resetInputAutoFill = (name, cssVarList) => `
|
|
|
77
65
|
${name} input:-webkit-autofill:focus {
|
|
78
66
|
-webkit-text-fill-color: var(${cssVarList.inputValueTextColor});
|
|
79
67
|
box-shadow: 0 0 0 var(${cssVarList.inputHeight}) var(${cssVarList.inputBackgroundColor}) inset;
|
|
80
|
-
}
|
|
68
|
+
}
|
|
81
69
|
`;
|
|
82
70
|
|
|
83
71
|
export const resetInputFieldDefaultWidth = () => `
|
|
@@ -98,3 +86,15 @@ export const resetInputFieldInvalidBackgroundColor = (name) => `
|
|
|
98
86
|
background: none;
|
|
99
87
|
}
|
|
100
88
|
`;
|
|
89
|
+
|
|
90
|
+
export const resetInputOverrides = (name, cssVarList) => `
|
|
91
|
+
${resetInputContainer(name)}
|
|
92
|
+
${resetInputCursor(name)}
|
|
93
|
+
${resetInputPlaceholder(name)}
|
|
94
|
+
${resetInputField(name)}
|
|
95
|
+
${resetInputAutoFill(name, cssVarList)}
|
|
96
|
+
${resetInputFieldInvalidBackgroundColor(name)}
|
|
97
|
+
${resetInitialHeight(name)}
|
|
98
|
+
${resetInputElement(name)}
|
|
99
|
+
${resetInputFieldUnderlayingBorder(name)}
|
|
100
|
+
`;
|
package/src/index.cjs.js
CHANGED
|
@@ -4,8 +4,8 @@ export * from './helpers/themeHelpers';
|
|
|
4
4
|
export * from './helpers/themeHelpers/colorsHelpers';
|
|
5
5
|
export { defaultTheme, themeVars } from './theme';
|
|
6
6
|
|
|
7
|
-
export { CheckboxClass } from './components/boolean-fields/descope-checkbox/CheckboxClass'
|
|
8
|
-
export { SwitchToggleClass } from './components/boolean-fields/descope-switch-toggle/SwitchToggleClass'
|
|
7
|
+
export { CheckboxClass } from './components/boolean-fields/descope-checkbox/CheckboxClass';
|
|
8
|
+
export { SwitchToggleClass } from './components/boolean-fields/descope-switch-toggle/SwitchToggleClass';
|
|
9
9
|
export { ButtonClass } from './components/descope-button/ButtonClass';
|
|
10
10
|
export { LoaderLinearClass } from './components/descope-loader-linear/LoaderLinearClass';
|
|
11
11
|
export { LoaderRadialClass } from './components/descope-loader-radial/LoaderRadialClass';
|
|
@@ -23,4 +23,4 @@ export { TextAreaClass } from './components/descope-text-area/TextAreaClass';
|
|
|
23
23
|
export { TextFieldClass } from './components/descope-text-field/TextFieldClass';
|
|
24
24
|
export { ImageClass } from './components/descope-image/ImageClass';
|
|
25
25
|
export { PhoneFieldClass } from './components/descope-phone-field/PhoneFieldClass';
|
|
26
|
-
export { NewPasswordClass } from './components/descope-new-password/NewPasswordClass';
|
|
26
|
+
export { NewPasswordClass } from './components/descope-new-password/NewPasswordClass';
|
package/src/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
declare module '@descope/web-components-ui';
|
|
2
2
|
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
globalsThemeToStyle,
|
|
5
|
+
createComponentsTheme,
|
|
6
|
+
themeToStyle,
|
|
7
|
+
componentsThemeManager,
|
|
8
8
|
} from './helpers/themeHelpers';
|
|
9
9
|
export { genColor } from './helpers/themeHelpers/colorsHelpers';
|
|
10
10
|
export { defaultTheme, themeVars } from './theme';
|
|
@@ -29,23 +29,24 @@ export { TextFieldClass } from './components/descope-text-field';
|
|
|
29
29
|
export { ImageClass } from './components/descope-image';
|
|
30
30
|
export { PhoneFieldClass } from './components/descope-phone-field';
|
|
31
31
|
export { NewPasswordClass } from './components/descope-new-password';
|
|
32
|
+
export { UploadFileClass } from './components/descope-upload-file';
|
|
32
33
|
|
|
33
34
|
export type Theme = {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
globals: {
|
|
36
|
+
colors: Record<string, string>;
|
|
37
|
+
fonts: Record<string, any>;
|
|
38
|
+
typography: Record<string, any>;
|
|
39
|
+
shadow: Record<string, string>;
|
|
40
|
+
spacing: Record<string, string>;
|
|
41
|
+
};
|
|
42
|
+
components: {
|
|
43
|
+
button: Record<string, any>;
|
|
44
|
+
textField: Record<string, any>;
|
|
45
|
+
logo: Record<string, any>;
|
|
46
|
+
container: Record<string, any>;
|
|
47
|
+
link: Record<string, any>;
|
|
48
|
+
button: Record<string, any>;
|
|
49
|
+
text: Record<string, any>;
|
|
50
|
+
inputWrapper: Record<string, any>;
|
|
51
|
+
};
|
|
51
52
|
};
|
package/src/index.js
CHANGED
|
@@ -19,12 +19,13 @@ export * from './components/descope-text-field';
|
|
|
19
19
|
export * from './components/descope-image';
|
|
20
20
|
export * from './components/descope-phone-field';
|
|
21
21
|
export * from './components/descope-new-password';
|
|
22
|
+
export * from './components/descope-upload-file';
|
|
22
23
|
|
|
23
24
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
globalsThemeToStyle,
|
|
26
|
+
createComponentsTheme,
|
|
27
|
+
themeToStyle,
|
|
28
|
+
componentsThemeManager,
|
|
28
29
|
} from './helpers/themeHelpers';
|
|
29
30
|
export { genColor } from './helpers/themeHelpers/colorsHelpers';
|
|
30
31
|
export { defaultTheme, themeVars } from './theme';
|
package/src/index.umd.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
const { componentsThemeManager } = require(
|
|
1
|
+
const { componentsThemeManager } = require('./helpers/themeHelpers/componentsThemeManager');
|
|
2
2
|
|
|
3
3
|
const components = import.meta.webpackContext('./components', {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
recursive: true,
|
|
5
|
+
regExp: /index.js$/,
|
|
6
|
+
mode: 'lazy',
|
|
7
|
+
chunkName: '[request]',
|
|
8
|
+
prefetch: true,
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
// all components must be in a folder with the component name, and have an index.js file
|
|
12
12
|
// e.g. ./descope-button/index.js
|
|
13
13
|
module.exports = components.keys().reduce((acc, key) => {
|
|
14
|
-
|
|
14
|
+
// eslint-disable-next-line no-useless-escape
|
|
15
|
+
const componentName = key.replace(/.*?([^\/]+)\/index\.js$/, '$1');
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (componentName.endsWith('-internal')) {
|
|
18
|
+
return acc;
|
|
19
|
+
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
acc[componentName] = () => components(key);
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
return acc;
|
|
23
24
|
}, {});
|
|
24
25
|
|
|
25
|
-
module.exports.componentsThemeManager = componentsThemeManager
|
|
26
|
+
module.exports.componentsThemeManager = componentsThemeManager;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { createDispatchEvent } from
|
|
1
|
+
import { createDispatchEvent } from '../helpers/mixinsHelpers';
|
|
2
2
|
|
|
3
|
-
export const changeMixin = (superclass) =>
|
|
4
|
-
|
|
3
|
+
export const changeMixin = (superclass) =>
|
|
4
|
+
class ChangeMixinClass extends superclass {
|
|
5
|
+
#dispatchChange = createDispatchEvent.bind(this, 'change');
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
init() {
|
|
8
|
+
super.init?.();
|
|
9
|
+
this.prevValue = this.value;
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
this.addEventListener('change', (e) => {
|
|
12
|
+
e.stopPropagation();
|
|
13
|
+
});
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
15
|
+
this.addEventListener('blur', () => {
|
|
16
|
+
if (this.value !== this.prevValue) {
|
|
17
|
+
this.#dispatchChange();
|
|
18
|
+
this.prevValue = this.value;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|