@descope/web-components-ui 1.0.62 → 1.0.63
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/index.cjs.js +95 -21
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +669 -696
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/447.js +1 -1
- package/dist/umd/666.js +37 -0
- package/dist/umd/725.js +1 -37
- package/dist/umd/descope-button-index-js.js +1 -1
- package/dist/umd/descope-checkbox-index-js.js +1 -1
- package/dist/umd/descope-container-index-js.js +1 -1
- package/dist/umd/descope-date-picker-index-js.js +1 -1
- package/dist/umd/descope-divider-index-js.js +1 -1
- package/dist/umd/descope-email-field-index-js.js +1 -1
- package/dist/umd/descope-link-index-js.js +1 -1
- package/dist/umd/descope-loader-linear-index-js.js +1 -1
- package/dist/umd/descope-loader-radial-index-js.js +1 -1
- package/dist/umd/descope-logo-index-js.js +1 -1
- package/dist/umd/descope-number-field-index-js.js +1 -1
- package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js +1 -1
- package/dist/umd/descope-passcode-index-js.js +1 -1
- package/dist/umd/descope-password-field-index-js.js +1 -1
- package/dist/umd/descope-switch-toggle-index-js.js +1 -1
- package/dist/umd/descope-text-area-index-js.js +1 -1
- package/dist/umd/descope-text-field-index-js.js +1 -1
- package/dist/umd/descope-text-index-js.js +1 -1
- package/dist/umd/index.js +1 -1
- package/package.json +1 -1
- package/src/baseClasses/BaseInputClass.js +1 -1
- package/src/components/descope-button/Button.js +14 -10
- package/src/components/descope-checkbox/Checkbox.js +8 -5
- package/src/components/descope-container/Container.js +12 -7
- package/src/components/descope-date-picker/index.js +3 -3
- package/src/components/descope-divider/Divider.js +35 -30
- package/src/components/descope-email-field/EmailField.js +3 -3
- package/src/components/descope-link/Link.js +19 -27
- package/src/components/descope-loader-linear/LoaderLinear.js +12 -7
- package/src/components/descope-loader-radial/LoaderRadial.js +5 -5
- package/src/components/descope-logo/Logo.js +4 -4
- package/src/components/descope-number-field/NumberField.js +3 -3
- package/src/components/descope-passcode/Passcode.js +50 -69
- package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +1 -1
- package/src/components/descope-password-field/PasswordField.js +3 -3
- package/src/components/descope-switch-toggle/SwitchToggle.js +8 -5
- package/src/components/descope-text/Text.js +18 -9
- package/src/components/descope-text-area/TextArea.js +7 -6
- package/src/components/descope-text-field/TextField.js +3 -3
- package/src/components/descope-text-field/textFieldMappings.js +3 -5
- package/src/constants.js +1 -0
- package/src/dev/index.js +2 -2
- package/src/{componentsHelpers/createProxy/helpers.js → helpers/componentHelpers.js} +13 -5
- package/src/{helpers.js → helpers/index.js} +5 -2
- package/src/helpers/themeHelpers/componentsThemeManager.js +40 -0
- package/src/{themeHelpers → helpers/themeHelpers}/index.js +56 -21
- package/src/index.cjs.js +1 -1
- package/src/index.js +5 -5
- package/src/index.umd.js +4 -0
- package/src/{componentsHelpers/createProxy/index.js → mixins/createProxy.js} +4 -4
- package/src/{componentsHelpers → mixins}/createStyleMixin/helpers.js +14 -15
- package/src/mixins/createStyleMixin/index.js +109 -0
- package/src/{componentsHelpers → mixins}/index.js +2 -6
- package/src/theme/components/button.js +2 -2
- package/src/theme/components/checkbox.js +2 -1
- package/src/theme/components/container.js +2 -2
- package/src/theme/components/divider.js +17 -9
- package/src/theme/components/link.js +1 -1
- package/src/theme/components/loader/loaderLinear.js +1 -1
- package/src/theme/components/loader/loaderRadial.js +1 -1
- package/src/theme/components/text.js +1 -1
- package/src/theme/components/textArea.js +2 -1
- package/src/theme/components/textField.js +1 -1
- package/src/theme/globals.js +3 -3
- package/dist/umd/442.js +0 -1
- package/dist/umd/942.js +0 -1
- package/dist/umd/descope-combo-index-js.js +0 -1
- package/src/components/descope-combo/index.js +0 -27
- package/src/componentsHelpers/compose.js +0 -3
- package/src/componentsHelpers/createStyleMixin/index.js +0 -114
- package/src/componentsHelpers/enforceNestingElementsStylesMixin.js +0 -103
- /package/dist/umd/{725.js.LICENSE.txt → 666.js.LICENSE.txt} +0 -0
- /package/src/{themeHelpers/processColors.js → helpers/themeHelpers/colorsHelpers.js} +0 -0
- /package/src/{componentsHelpers → mixins}/componentNameValidationMixin.js +0 -0
- /package/src/{componentsHelpers → mixins}/draggableMixin.js +0 -0
- /package/src/{componentsHelpers → mixins}/hoverableMixin.js +0 -0
- /package/src/{componentsHelpers → mixins}/inputMixin.js +0 -0
- /package/src/{componentsHelpers → mixins}/proxyInputMixin.js +0 -0
@@ -1,20 +1,20 @@
|
|
1
1
|
import {
|
2
|
-
getComponentName,
|
3
2
|
createStyleMixin,
|
4
3
|
draggableMixin,
|
5
4
|
createProxy,
|
6
5
|
proxyInputMixin,
|
7
|
-
compose,
|
8
6
|
componentNameValidationMixin
|
9
|
-
} from '../../
|
10
|
-
import {
|
7
|
+
} from '../../mixins';
|
8
|
+
import { compose } from '../../helpers';
|
9
|
+
import { getComponentName } from '../../helpers/componentHelpers';
|
11
10
|
|
12
11
|
export const componentName = getComponentName('text-area');
|
13
12
|
|
14
13
|
const selectors = {
|
15
14
|
label: '::part(label)',
|
16
15
|
input: '::part(input-field)',
|
17
|
-
required: '::part(required-indicator)::after'
|
16
|
+
required: '::part(required-indicator)::after',
|
17
|
+
host: () => ':host'
|
18
18
|
};
|
19
19
|
|
20
20
|
let overrides = ``;
|
@@ -25,7 +25,7 @@ const TextArea = compose(
|
|
25
25
|
resize: { selector: '> textarea' },
|
26
26
|
color: { selector: selectors.label },
|
27
27
|
cursor: {},
|
28
|
-
width:
|
28
|
+
width: { selector: selectors.host },
|
29
29
|
backgroundColor: { selector: selectors.input },
|
30
30
|
borderWidth: { selector: selectors.input },
|
31
31
|
borderStyle: { selector: selectors.input },
|
@@ -55,6 +55,7 @@ overrides = `
|
|
55
55
|
|
56
56
|
vaadin-text-area {
|
57
57
|
margin: 0;
|
58
|
+
width: 100%;
|
58
59
|
}
|
59
60
|
vaadin-text-area > label,
|
60
61
|
vaadin-text-area::part(input-field) {
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import {
|
2
|
-
getComponentName,
|
3
2
|
createStyleMixin,
|
4
3
|
draggableMixin,
|
5
4
|
createProxy,
|
6
5
|
proxyInputMixin,
|
7
|
-
compose,
|
8
6
|
componentNameValidationMixin
|
9
|
-
} from '../../
|
7
|
+
} from '../../mixins';
|
10
8
|
import textFieldMappings from '../descope-text-field/textFieldMappings';
|
9
|
+
import { compose } from '../../helpers';
|
10
|
+
import { getComponentName } from '../../helpers/componentHelpers';
|
11
11
|
|
12
12
|
export const componentName = getComponentName('text-field');
|
13
13
|
|
@@ -1,17 +1,15 @@
|
|
1
|
-
import { matchHostStyle } from '../../componentsHelpers/createStyleMixin/helpers';
|
2
|
-
|
3
1
|
const selectors = {
|
4
2
|
label: '::part(label)',
|
5
3
|
input: '::part(input-field)',
|
6
4
|
readOnlyInput: '[readonly]::part(input-field)::after',
|
7
|
-
placeholder: '> input:placeholder-shown'
|
5
|
+
placeholder: '> input:placeholder-shown',
|
6
|
+
host: () => ':host'
|
8
7
|
};
|
9
8
|
|
10
9
|
export default {
|
11
|
-
color: { selector: selectors.input },
|
12
10
|
backgroundColor: { selector: selectors.input },
|
13
11
|
color: { selector: selectors.input },
|
14
|
-
width:
|
12
|
+
width: { selector: selectors.host },
|
15
13
|
borderColor: [
|
16
14
|
{ selector: selectors.input },
|
17
15
|
{ selector: selectors.readOnlyInput }
|
package/src/constants.js
CHANGED
package/src/dev/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export {default as defaultTheme} from '../theme';
|
2
|
-
export { themeToStyle } from '../themeHelpers';
|
1
|
+
export { default as defaultTheme } from '../theme';
|
2
|
+
export { themeToStyle } from '../helpers/themeHelpers';
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import { kebabCaseJoin } from '.';
|
2
|
+
import { DESCOPE_PREFIX } from '../constants';
|
3
|
+
|
1
4
|
const observeAttributes = (
|
2
5
|
ele,
|
3
6
|
callback,
|
@@ -50,12 +53,17 @@ export const syncAttrs = (ele1, ele2, options) => {
|
|
50
53
|
observeAttributes(ele2, createSyncAttrsCb(ele2, ele1), options);
|
51
54
|
};
|
52
55
|
|
56
|
+
export const getComponentName = (name) => kebabCaseJoin(DESCOPE_PREFIX, name);
|
57
|
+
|
58
|
+
export const getCssVarName = (...args) =>
|
59
|
+
`--${kebabCaseJoin(...args.filter((arg) => !!arg))}`;
|
60
|
+
|
53
61
|
export const forwardAttrs = (source, dest, options = {}) => {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
62
|
+
observeAttributes(
|
63
|
+
source,
|
64
|
+
createSyncAttrsCb(source, dest, options.mapAttrs),
|
65
|
+
options
|
66
|
+
);
|
59
67
|
};
|
60
68
|
|
61
69
|
export const forwardProps = (src, target, props = []) => {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
export const kebabCase = (str) =>
|
2
3
|
str
|
3
4
|
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
@@ -6,5 +7,7 @@ export const kebabCase = (str) =>
|
|
6
7
|
|
7
8
|
export const kebabCaseJoin = (...args) => kebabCase(args.join('-'));
|
8
9
|
|
9
|
-
export const
|
10
|
-
|
10
|
+
export const compose = (...fns) =>
|
11
|
+
(val) =>
|
12
|
+
fns.reduceRight((res, fn) => fn(res), val);
|
13
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
class ComponentsThemeManager {
|
3
|
+
static mountOnPropName = 'DescopeThemeManager';
|
4
|
+
|
5
|
+
#themes = {};
|
6
|
+
|
7
|
+
#currentThemeName = 'light';
|
8
|
+
|
9
|
+
#callbacks = new Set();
|
10
|
+
|
11
|
+
#notify() {
|
12
|
+
this.#callbacks.forEach(cb => cb?.());
|
13
|
+
};
|
14
|
+
|
15
|
+
get currentThemeName() {
|
16
|
+
return this.#currentThemeName;
|
17
|
+
}
|
18
|
+
|
19
|
+
set currentThemeName(themeName) {
|
20
|
+
this.#currentThemeName = themeName;
|
21
|
+
this.#notify();
|
22
|
+
}
|
23
|
+
|
24
|
+
get currentTheme() {
|
25
|
+
return this.#themes[this.currentThemeName];
|
26
|
+
}
|
27
|
+
|
28
|
+
onCurrentThemeChange(cb) {
|
29
|
+
this.#callbacks.add(cb);
|
30
|
+
|
31
|
+
return () => { this.#callbacks.delete(cb); };
|
32
|
+
};
|
33
|
+
|
34
|
+
set themes(themes) {
|
35
|
+
this.#themes = themes;
|
36
|
+
this.#notify();
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
export const componentsThemeManager = new ComponentsThemeManager()
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import merge from 'lodash.merge';
|
2
2
|
import set from 'lodash.set';
|
3
|
-
import { DESCOPE_PREFIX } from '
|
4
|
-
import {
|
5
|
-
import { getComponentName } from '../
|
3
|
+
import { DESCOPE_PREFIX } from '../../constants';
|
4
|
+
import { kebabCase } from '..';
|
5
|
+
import { getComponentName, getCssVarName } from '../componentHelpers';
|
6
6
|
|
7
7
|
const getVarName = (path) => getCssVarName(DESCOPE_PREFIX, ...path);
|
8
8
|
|
@@ -32,9 +32,9 @@ export const getThemeRefs = (theme, prefix) =>
|
|
32
32
|
export const globalsThemeToStyle = (theme, themeName = '') => `
|
33
33
|
*[data-theme="${themeName}"] {
|
34
34
|
${Object.entries(themeToCSSVarsObj(theme)).reduce(
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
(acc, entry) => (acc += `${entry.join(':')};\n`),
|
36
|
+
''
|
37
|
+
)}
|
38
38
|
}
|
39
39
|
`;
|
40
40
|
|
@@ -42,10 +42,20 @@ const componentsThemeToStyleObj = (componentsTheme) =>
|
|
42
42
|
transformTheme(componentsTheme, [], (path, val) => {
|
43
43
|
const [component, ...restPath] = path;
|
44
44
|
const property = restPath.pop();
|
45
|
+
const componentName = getComponentName(component);
|
46
|
+
|
47
|
+
// we need a support for portal components theme (e.g. overlay)
|
48
|
+
// this allows us to generate those themes under different sections
|
49
|
+
// if the theme has root level attribute that starts with #
|
50
|
+
// we are generating a new theme
|
51
|
+
let themeName = 'theme'
|
52
|
+
|
53
|
+
if (restPath[0] && restPath[0].startsWith('#')) {
|
54
|
+
themeName = restPath.shift();
|
55
|
+
}
|
45
56
|
|
46
57
|
// do not start with underscore -> key:value, must have 2 no underscore attrs in a row
|
47
58
|
// starts with underscore -> attribute selector
|
48
|
-
|
49
59
|
const attrsSelector = restPath.reduce((acc, section, idx) => {
|
50
60
|
if (section.startsWith('_'))
|
51
61
|
return (acc += `[${kebabCase(section.replace(/^_/, ''))}="true"]`);
|
@@ -65,30 +75,53 @@ const componentsThemeToStyleObj = (componentsTheme) =>
|
|
65
75
|
.join('')}"]`);
|
66
76
|
}, '');
|
67
77
|
|
68
|
-
let selector =
|
78
|
+
let selector = `:host${attrsSelector ? `(${attrsSelector})` : ''}`;
|
69
79
|
|
70
80
|
return {
|
71
|
-
[
|
72
|
-
[
|
81
|
+
[componentName]: {
|
82
|
+
[themeName]: {
|
83
|
+
[selector]: {
|
84
|
+
[property]: val
|
85
|
+
}
|
86
|
+
}
|
73
87
|
}
|
74
88
|
};
|
75
89
|
});
|
76
90
|
|
77
|
-
|
78
|
-
|
91
|
+
|
92
|
+
export const createComponentsTheme = (componentsTheme) => {
|
93
|
+
const styleObj = componentsThemeToStyleObj(componentsTheme);
|
94
|
+
|
95
|
+
return Object.keys(styleObj).reduce(
|
96
|
+
(acc, componentName) => {
|
97
|
+
const componentThemes = styleObj[componentName];
|
98
|
+
|
99
|
+
return Object.assign(acc, {
|
100
|
+
[componentName]: Object.keys(componentThemes)
|
101
|
+
.reduce((acc, theme) =>
|
102
|
+
Object.assign(acc, { [theme]: componentsThemeToStyle(componentThemes[theme]) }),
|
103
|
+
{})
|
104
|
+
})
|
105
|
+
},
|
106
|
+
{}
|
107
|
+
);
|
108
|
+
}
|
109
|
+
|
110
|
+
const componentsThemeToStyle = (componentsTheme) =>
|
111
|
+
Object.entries(componentsTheme).reduce(
|
79
112
|
(acc, [selector, vars]) =>
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
113
|
+
(acc += `${selector} { \n${Object.entries(
|
114
|
+
vars
|
115
|
+
)
|
116
|
+
.map(([key, val]) => `${key}: ${val}`)
|
117
|
+
.join(';\n')} \n}\n\n`),
|
85
118
|
''
|
86
119
|
);
|
87
120
|
|
88
|
-
export const themeToStyle = ({ globals, components }, themeName) =>
|
89
|
-
|
90
|
-
|
91
|
-
|
121
|
+
export const themeToStyle = ({ globals, components }, themeName) => ({
|
122
|
+
globals: globalsThemeToStyle(globals, themeName),
|
123
|
+
components: createComponentsTheme(components)
|
124
|
+
});
|
92
125
|
|
93
126
|
const useVar = (varName) => `var(${varName})`;
|
94
127
|
|
@@ -107,3 +140,5 @@ export const createHelperVars = (theme, prefix) => {
|
|
107
140
|
|
108
141
|
return [res.theme, res.useVars, res.vars];
|
109
142
|
};
|
143
|
+
|
144
|
+
export { componentsThemeManager } from './componentsThemeManager'
|
package/src/index.cjs.js
CHANGED
package/src/index.js
CHANGED
@@ -2,7 +2,6 @@ import './components/descope-button';
|
|
2
2
|
import './components/descope-checkbox';
|
3
3
|
import './components/descope-loader-linear';
|
4
4
|
import './components/descope-loader-radial';
|
5
|
-
import './components/descope-combo';
|
6
5
|
import './components/descope-container';
|
7
6
|
import './components/descope-date-picker';
|
8
7
|
import './components/descope-divider';
|
@@ -19,8 +18,9 @@ import './components/descope-text-field';
|
|
19
18
|
|
20
19
|
export {
|
21
20
|
globalsThemeToStyle,
|
22
|
-
|
23
|
-
themeToStyle
|
24
|
-
|
25
|
-
|
21
|
+
createComponentsTheme,
|
22
|
+
themeToStyle,
|
23
|
+
componentsThemeManager
|
24
|
+
} from './helpers/themeHelpers';
|
25
|
+
export { genColor } from './helpers/themeHelpers/colorsHelpers';
|
26
26
|
export { default as defaultTheme } from './theme';
|
package/src/index.umd.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
const { componentsThemeManager } = require("./helpers/themeHelpers/componentsThemeManager");
|
2
|
+
|
1
3
|
const components = import.meta.webpackContext('./components', {
|
2
4
|
recursive: true,
|
3
5
|
regExp: /index.js$/,
|
@@ -14,3 +16,5 @@ module.exports = components.keys().reduce((acc, key) => {
|
|
14
16
|
|
15
17
|
return acc;
|
16
18
|
}, {});
|
19
|
+
|
20
|
+
module.exports.componentsThemeManager = componentsThemeManager
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
1
|
+
import { DescopeBaseClass } from '../baseClasses/DescopeBaseClass';
|
2
|
+
import { compose } from '../helpers';
|
3
|
+
import { forwardProps, syncAttrs } from '../helpers/componentHelpers';
|
4
|
+
import { hoverableMixin } from './hoverableMixin';
|
5
5
|
|
6
6
|
export const createProxy = ({
|
7
7
|
componentName,
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { kebabCase } from '../../helpers';
|
2
|
+
import { getCssVarName } from '../../helpers/componentHelpers';
|
2
3
|
|
3
4
|
const createCssVarFallback = (first, ...rest) =>
|
4
5
|
`var(${first}${rest.length ? ` , ${createCssVarFallback(...rest)}` : ''})`;
|
@@ -9,11 +10,10 @@ const createCssSelector = (
|
|
9
10
|
) =>
|
10
11
|
typeof relativeSelectorOrSelectorFn === 'function'
|
11
12
|
? relativeSelectorOrSelectorFn(baseSelector)
|
12
|
-
: `${baseSelector}${
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}`;
|
13
|
+
: `${baseSelector}${/^[A-Za-z]/.test(relativeSelectorOrSelectorFn)
|
14
|
+
? ` ${relativeSelectorOrSelectorFn}`
|
15
|
+
: relativeSelectorOrSelectorFn
|
16
|
+
}`;
|
17
17
|
|
18
18
|
class StyleBuilder {
|
19
19
|
constructor() {
|
@@ -34,9 +34,9 @@ class StyleBuilder {
|
|
34
34
|
toString() {
|
35
35
|
return Array.from(this.styleMap.entries()).reduce(
|
36
36
|
(style, [selector, propValArr]) =>
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
(style += `${selector} { \n${propValArr
|
38
|
+
.map(({ property, value }) => `${property}: ${value}`)
|
39
|
+
.join(';\n')} \n}\n\n`),
|
40
40
|
''
|
41
41
|
);
|
42
42
|
}
|
@@ -82,9 +82,8 @@ export const createCssVarsList = (componentName, mappings) =>
|
|
82
82
|
{}
|
83
83
|
);
|
84
84
|
|
85
|
-
//
|
86
|
-
//
|
87
|
-
export const
|
88
|
-
|
89
|
-
|
90
|
-
];
|
85
|
+
// on some cases we need a selector to be more specific than another
|
86
|
+
// for this we have this fn that generate a class selector multiple times
|
87
|
+
export const createClassSelectorSpecifier = (className, numOfRepeats) => Array(numOfRepeats)
|
88
|
+
.fill(`.${className}`)
|
89
|
+
.join('')
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import { CSS_SELECTOR_SPECIFIER_MULTIPLY } from '../../constants';
|
2
|
+
import { kebabCaseJoin } from '../../helpers';
|
3
|
+
import { getCssVarName } from '../../helpers/componentHelpers';
|
4
|
+
import { componentsThemeManager } from '../../helpers/themeHelpers/componentsThemeManager';
|
5
|
+
import { createStyle, createCssVarsList, createClassSelectorSpecifier } from './helpers';
|
6
|
+
|
7
|
+
export const createStyleMixin =
|
8
|
+
({ mappings = {} }) =>
|
9
|
+
(superclass) => {
|
10
|
+
const styleAttributes = Object.keys(mappings).map((key) =>
|
11
|
+
kebabCaseJoin('st', key)
|
12
|
+
);
|
13
|
+
return class CustomStyleMixinClass extends superclass {
|
14
|
+
static get observedAttributes() {
|
15
|
+
const superAttrs = superclass.observedAttributes || [];
|
16
|
+
return [...superAttrs, ...styleAttributes];
|
17
|
+
}
|
18
|
+
|
19
|
+
static get cssVarList() {
|
20
|
+
return createCssVarsList(superclass.componentName, {
|
21
|
+
...mappings,
|
22
|
+
});
|
23
|
+
}
|
24
|
+
|
25
|
+
#overrideStyleEle = null;
|
26
|
+
#themeStyleEle = null;
|
27
|
+
#disconnectThemeManager
|
28
|
+
|
29
|
+
constructor() {
|
30
|
+
super();
|
31
|
+
|
32
|
+
this.classList.add(superclass.componentName)
|
33
|
+
|
34
|
+
this.#createComponentStyle();
|
35
|
+
this.#createComponentTheme();
|
36
|
+
this.#createAttrOverrideStyle();
|
37
|
+
}
|
38
|
+
|
39
|
+
get componentTheme() {
|
40
|
+
return componentsThemeManager.currentTheme?.[superclass.componentName] || ''
|
41
|
+
}
|
42
|
+
|
43
|
+
onComponentThemeChange() {
|
44
|
+
this.#themeStyleEle.innerHTML = this.componentTheme.theme
|
45
|
+
}
|
46
|
+
|
47
|
+
#createComponentTheme() {
|
48
|
+
this.#themeStyleEle = document.createElement('style');
|
49
|
+
this.#themeStyleEle.id = 'style-mixin-component-theme';
|
50
|
+
this.shadowRoot.prepend(this.#themeStyleEle);
|
51
|
+
this.#disconnectThemeManager = componentsThemeManager.onCurrentThemeChange(this.onComponentThemeChange.bind(this))
|
52
|
+
this.onComponentThemeChange()
|
53
|
+
}
|
54
|
+
|
55
|
+
#createAttrOverrideStyle() {
|
56
|
+
this.#overrideStyleEle = document.createElement('style');
|
57
|
+
this.#overrideStyleEle.id = 'style-mixin-overrides';
|
58
|
+
|
59
|
+
const classSpecifier = createClassSelectorSpecifier(superclass.componentName, CSS_SELECTOR_SPECIFIER_MULTIPLY);
|
60
|
+
this.#overrideStyleEle.innerText = `:host(${classSpecifier}) {}`;
|
61
|
+
this.shadowRoot.append(this.#overrideStyleEle);
|
62
|
+
}
|
63
|
+
|
64
|
+
#updateAttrOverrideStyle(attrName, value) {
|
65
|
+
const style = this.#overrideStyleEle.sheet?.cssRules[0].style;
|
66
|
+
const varName = getCssVarName(
|
67
|
+
superclass.componentName,
|
68
|
+
attrName.replace(/^st-/, '')
|
69
|
+
);
|
70
|
+
|
71
|
+
if (value) style?.setProperty(varName, value);
|
72
|
+
else style?.removeProperty(varName);
|
73
|
+
}
|
74
|
+
|
75
|
+
#createComponentStyle() {
|
76
|
+
const themeStyle = document.createElement('style');
|
77
|
+
themeStyle.id = 'style-mixin-component';
|
78
|
+
themeStyle.innerHTML = createStyle(
|
79
|
+
superclass.componentName,
|
80
|
+
this.baseSelector,
|
81
|
+
mappings
|
82
|
+
);
|
83
|
+
this.shadowRoot.prepend(themeStyle);
|
84
|
+
}
|
85
|
+
|
86
|
+
attributeChangedCallback(attrName, oldValue, newValue) {
|
87
|
+
super.attributeChangedCallback?.(attrName, oldValue, newValue);
|
88
|
+
|
89
|
+
if (styleAttributes.includes(attrName)) {
|
90
|
+
this.#updateAttrOverrideStyle(attrName, newValue);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
connectedCallback() {
|
95
|
+
super.connectedCallback?.();
|
96
|
+
if (this.shadowRoot.isConnected) {
|
97
|
+
Array.from(this.attributes).forEach((attr) => {
|
98
|
+
if (styleAttributes.includes(attr.nodeName)) {
|
99
|
+
this.#updateAttrOverrideStyle(attr.nodeName, attr.value);
|
100
|
+
}
|
101
|
+
});
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
disconnectedCallback() {
|
106
|
+
this.#disconnectThemeManager?.();
|
107
|
+
}
|
108
|
+
};
|
109
|
+
};
|
@@ -1,11 +1,7 @@
|
|
1
|
-
import { DESCOPE_PREFIX } from '../constants';
|
2
|
-
import { kebabCaseJoin } from '../helpers';
|
3
|
-
|
4
|
-
export const getComponentName = (name) => kebabCaseJoin(DESCOPE_PREFIX, name);
|
5
|
-
|
6
1
|
export { createStyleMixin } from './createStyleMixin';
|
7
2
|
export { draggableMixin } from './draggableMixin';
|
8
3
|
export { createProxy } from './createProxy';
|
9
4
|
export { proxyInputMixin } from './proxyInputMixin';
|
10
5
|
export { componentNameValidationMixin } from './componentNameValidationMixin';
|
11
|
-
export {
|
6
|
+
export { hoverableMixin } from './hoverableMixin';
|
7
|
+
export { inputMixin } from './inputMixin'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import globals from '../globals';
|
2
|
-
import { getThemeRefs, createHelperVars } from '../../themeHelpers';
|
2
|
+
import { getThemeRefs, createHelperVars } from '../../helpers/themeHelpers';
|
3
3
|
import Button, { componentName } from '../../components/descope-button/Button';
|
4
4
|
|
5
5
|
const globalRefs = getThemeRefs(globals);
|
@@ -17,7 +17,7 @@ const [helperTheme, helperRefs] = createHelperVars({ mode }, componentName);
|
|
17
17
|
|
18
18
|
const button = {
|
19
19
|
...helperTheme,
|
20
|
-
|
20
|
+
[vars.width]: 'fit-content',
|
21
21
|
size: {
|
22
22
|
xs: {
|
23
23
|
[vars.height]: '10px',
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import globals from "../globals";
|
2
|
-
import { getThemeRefs, createHelperVars } from "../../themeHelpers";
|
2
|
+
import { getThemeRefs, createHelperVars } from "../../helpers/themeHelpers";
|
3
3
|
import Container from "../../components/descope-container/Container";
|
4
4
|
|
5
5
|
const globalRefs = getThemeRefs(globals);
|
@@ -27,7 +27,7 @@ const [helperTheme, helperRefs, helperVars] =
|
|
27
27
|
|
28
28
|
const container = {
|
29
29
|
...helperTheme,
|
30
|
-
[vars.
|
30
|
+
[vars.width]: '100%',
|
31
31
|
verticalPadding: {
|
32
32
|
sm: { [vars.verticalPadding]: '5px' },
|
33
33
|
md: { [vars.verticalPadding]: '10px' },
|
@@ -1,26 +1,34 @@
|
|
1
|
-
import Divider from '../../components/descope-divider/Divider';
|
1
|
+
import Divider, { componentName } from '../../components/descope-divider/Divider';
|
2
|
+
import { createHelperVars } from '../../helpers/themeHelpers';
|
2
3
|
|
3
4
|
const vars = Divider.cssVarList;
|
4
5
|
|
6
|
+
const thickness = '2px'
|
7
|
+
const textPaddingSize = '10px'
|
8
|
+
const [helperTheme, helperRefs] = createHelperVars({ thickness, textPaddingSize }, componentName);
|
9
|
+
|
10
|
+
|
5
11
|
const divider = {
|
12
|
+
...helperTheme,
|
6
13
|
[vars.alignItems]: 'center',
|
7
|
-
[vars.
|
14
|
+
[vars.dividerHeight]: helperRefs.thickness,
|
8
15
|
[vars.backgroundColor]: 'currentColor',
|
9
16
|
[vars.opacity]: '0.2',
|
10
|
-
[vars.
|
17
|
+
[vars.textPadding]: `0 ${helperRefs.textPaddingSize}`,
|
11
18
|
[vars.width]: '100%',
|
12
19
|
[vars.flexDirection]: 'row',
|
13
20
|
[vars.alignSelf]: 'strech',
|
14
21
|
[vars.textWidth]: 'fit-content',
|
22
|
+
[vars.maxTextWidth]: 'calc(100% - 100px)',
|
15
23
|
_vertical: {
|
16
|
-
[vars.
|
17
|
-
[vars.
|
24
|
+
[vars.padding]: `0 calc(${thickness} * 3)`,
|
25
|
+
[vars.width]: 'fit-content',
|
26
|
+
[vars.textPadding]: `${helperRefs.textPaddingSize} 0`,
|
18
27
|
[vars.flexDirection]: 'column',
|
19
28
|
[vars.minHeight]: '200px',
|
20
|
-
[vars.textWidth]: '
|
21
|
-
|
22
|
-
|
23
|
-
[vars.fontStyle]: 'italic'
|
29
|
+
[vars.textWidth]: 'fit-content',
|
30
|
+
[vars.dividerWidth]: helperRefs.thickness,
|
31
|
+
[vars.maxTextWidth]: '100%',
|
24
32
|
}
|
25
33
|
};
|
26
34
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import LoaderLinear from '../../../components/descope-loader-linear/LoaderLinear';
|
2
|
-
import { getThemeRefs } from '../../../themeHelpers';
|
2
|
+
import { getThemeRefs } from '../../../helpers/themeHelpers';
|
3
3
|
import globals from '../../globals';
|
4
4
|
|
5
5
|
const globalRefs = getThemeRefs(globals);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import LoaderRadial from '../../../components/descope-loader-radial/LoaderRadial';
|
2
|
-
import { getThemeRefs } from '../../../themeHelpers';
|
2
|
+
import { getThemeRefs } from '../../../helpers/themeHelpers';
|
3
3
|
import globals from '../../globals';
|
4
4
|
|
5
5
|
const globalRefs = getThemeRefs(globals);
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import globals from '../globals';
|
2
|
-
import { getThemeRefs } from '../../themeHelpers';
|
2
|
+
import { getThemeRefs } from '../../helpers/themeHelpers';
|
3
3
|
import TextArea from '../../components/descope-text-area/TextArea';
|
4
4
|
|
5
5
|
const globalRefs = getThemeRefs(globals);
|
6
6
|
const vars = TextArea.cssVarList;
|
7
7
|
|
8
8
|
const textArea = {
|
9
|
+
[vars.width]: '100%',
|
9
10
|
[vars.color]: globalRefs.colors.primary.main,
|
10
11
|
[vars.backgroundColor]: globalRefs.colors.surface.light,
|
11
12
|
[vars.resize]: 'vertical',
|