@descope/web-components-ui 1.0.55 → 1.0.57

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.
@@ -3,107 +3,112 @@ import { createStyle, createCssVarsList } from './helpers';
3
3
 
4
4
  export const createStyleMixin =
5
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];
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];
14
+ }
15
+
16
+ static get cssVarList() {
17
+ return createCssVarsList(superclass.componentName, {
18
+ ...mappings,
19
+ ...nestedMappings
20
+ });
21
+ }
22
+
23
+ #styleEle = null;
24
+
25
+ constructor() {
26
+ super();
27
+
28
+ this.#createComponentStyle();
29
+ this.#createAttrOverrideStyle();
30
+ }
31
+
32
+ #createAttrOverrideStyle() {
33
+ this.#styleEle = document.createElement('style');
34
+ this.#styleEle.id = 'style-mixin-overrides';
35
+
36
+ this.#styleEle.innerText = '* {}';
37
+ this.shadowRoot.prepend(this.#styleEle);
38
+ }
39
+
40
+ #updateAttrOverrideStyle(attrName, value) {
41
+ const style = this.#styleEle.sheet?.cssRules[0].style;
42
+ const varName = getCssVarName(
43
+ superclass.componentName,
44
+ attrName.replace(/^st-/, '')
45
+ );
46
+
47
+ if (value) style?.setProperty(varName, value);
48
+ else style?.removeProperty(varName);
49
+ }
50
+
51
+ #createComponentStyle() {
52
+ const themeStyle = document.createElement('style');
53
+ themeStyle.id = 'style-mixin-component';
54
+ themeStyle.innerHTML = createStyle(
55
+ superclass.componentName,
56
+ this.baseSelector,
57
+ mappings
58
+ );
59
+ this.shadowRoot.prepend(themeStyle);
60
+ }
61
+
62
+ #createComponentNestingStyle() {
63
+ // we need these selectors to be more specific from the theme selectors
64
+ // in order to do it, we are repeating the class name for specificity
65
+ const numOfClassNameSpecifier = 3;
66
+
67
+ const rootNode = this.shadowRoot.host.getRootNode();
68
+ const styleId = `${superclass.componentName}-style-mixin-component`;
69
+
70
+ const className = superclass.componentName;
71
+ this.shadowRoot.host.classList.add(className);
72
+
73
+ if (rootNode.querySelector(`style#${styleId}`)) return;
74
+
75
+ const themeStyle = document.createElement('style');
76
+ themeStyle.id = styleId;
77
+ themeStyle.innerHTML = createStyle(
78
+ superclass.componentName,
79
+ `${superclass.componentName}${Array(numOfClassNameSpecifier)
80
+ .fill(`.${className}`)
81
+ .join('')}`,
82
+ nestedMappings
83
+ );
84
+
85
+ // rootNode can be either a shadow DOM or a light DOM
86
+ if (rootNode.nodeName === '#document') {
87
+ rootNode.head.append(themeStyle);
88
+ } else {
89
+ rootNode.append(themeStyle);
14
90
  }
91
+ }
15
92
 
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
- );
93
+ attributeChangedCallback(attrName, oldValue, newValue) {
94
+ super.attributeChangedCallback?.(attrName, oldValue, newValue);
43
95
 
44
- if (value) style?.setProperty(varName, value);
45
- else style?.removeProperty(varName);
96
+ if (styleAttributes.includes(attrName)) {
97
+ this.#updateAttrOverrideStyle(attrName, newValue);
46
98
  }
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
- }
99
+ }
100
+
101
+ connectedCallback() {
102
+ super.connectedCallback?.();
103
+ if (this.shadowRoot.isConnected) {
104
+ this.#createComponentNestingStyle();
105
+
106
+ Array.from(this.attributes).forEach((attr) => {
107
+ if (styleAttributes.includes(attr.nodeName)) {
108
+ this.#updateAttrOverrideStyle(attr.nodeName, attr.value);
109
+ }
110
+ });
107
111
  }
108
- };
112
+ }
109
113
  };
114
+ };
package/src/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import './components/descope-button';
2
2
  import './components/descope-checkbox';
3
+ import './components/descope-loader-linear';
4
+ import './components/descope-loader-radial';
3
5
  import './components/descope-combo';
4
6
  import './components/descope-container';
5
7
  import './components/descope-date-picker';
@@ -18,6 +18,9 @@ const divider = {
18
18
  [vars.flexDirection]: 'column',
19
19
  [vars.minHeight]: '200px',
20
20
  [vars.textWidth]: 'max-content'
21
+ },
22
+ _italic: {
23
+ [vars.fontStyle]: 'italic'
21
24
  }
22
25
  };
23
26
 
@@ -12,6 +12,7 @@ import text from './text';
12
12
  import link from './link';
13
13
  import divider from './divider';
14
14
  import passcode from './passcode';
15
+ import { loaderRadial, loaderLinear } from './loader';
15
16
 
16
17
  export default {
17
18
  button,
@@ -27,5 +28,7 @@ export default {
27
28
  text,
28
29
  link,
29
30
  divider,
30
- passcode
31
+ passcode,
32
+ loaderRadial,
33
+ loaderLinear
31
34
  };
@@ -0,0 +1,2 @@
1
+ export { default as loaderLinear } from './loaderLinear';
2
+ export { default as loaderRadial } from './loaderRadial';
@@ -0,0 +1,49 @@
1
+ import LoaderLinear from '../../../components/descope-loader-linear/LoaderLinear';
2
+ import { getThemeRefs } from '../../../themeHelpers';
3
+ import globals from '../../globals';
4
+
5
+ const globalRefs = getThemeRefs(globals);
6
+
7
+ const vars = LoaderLinear.cssVarList;
8
+
9
+ const loaderLinear = {
10
+ [vars.display]: 'inline-block',
11
+ [vars.barColor]: globalRefs.colors.surface.contrast,
12
+ [vars.barWidth]: '20%',
13
+ [vars.surfaceColor]: globalRefs.colors.surface.main,
14
+ [vars.borderRadius]: '4px',
15
+ [vars.animationDuration]: '2s',
16
+ [vars.animationTimingFunction]: 'linear',
17
+ [vars.animationIterationCount]: 'infinite',
18
+ [vars.width]: '100%',
19
+ size: {
20
+ xs: {
21
+ [vars.height]: '6px'
22
+ },
23
+ sm: {
24
+ [vars.height]: '8px'
25
+ },
26
+ md: {
27
+ [vars.height]: '10px'
28
+ },
29
+ lg: {
30
+ [vars.height]: '12px'
31
+ },
32
+ xl: {
33
+ [vars.height]: '14px'
34
+ }
35
+ },
36
+ mode: {
37
+ primary: {
38
+ [vars.barColor]: globalRefs.colors.primary.main
39
+ },
40
+ secondary: {
41
+ [vars.barColor]: globalRefs.colors.secondary.main
42
+ }
43
+ },
44
+ _hidden: {
45
+ [vars.display]: 'none'
46
+ }
47
+ };
48
+
49
+ export default loaderLinear;
@@ -0,0 +1,62 @@
1
+ import LoaderRadial from '../../../components/descope-loader-radial/LoaderRadial';
2
+ import { getThemeRefs } from '../../../themeHelpers';
3
+ import globals from '../../globals';
4
+
5
+ const globalRefs = getThemeRefs(globals);
6
+
7
+ const vars = LoaderRadial.cssVarList;
8
+
9
+ const loaderRadial = {
10
+ [vars.display]: 'inline-block',
11
+ [vars.color]: globalRefs.colors.surface.contrast,
12
+ [vars.animationDuration]: '2s',
13
+ [vars.animationTimingFunction]: 'linear',
14
+ [vars.animationIterationCount]: 'infinite',
15
+ [vars.spinnerStyle]: 'solid',
16
+ [vars.spinnerWidth]: '4px',
17
+ [vars.spinnerRadius]: '50%',
18
+ [vars.spinnerTopColor]: 'currentColor',
19
+ [vars.spinnerBottomColor]: 'transparent',
20
+ [vars.spinnerRightColor]: 'currentColor',
21
+ [vars.spinnerLeftColor]: 'transparent',
22
+ size: {
23
+ xs: {
24
+ [vars.width]: '20px',
25
+ [vars.height]: '20px',
26
+ [vars.spinnerWidth]: '2px'
27
+ },
28
+ sm: {
29
+ [vars.width]: '30px',
30
+ [vars.height]: '30px',
31
+ [vars.spinnerWidth]: '3px'
32
+ },
33
+ md: {
34
+ [vars.width]: '40px',
35
+ [vars.height]: '40px',
36
+ [vars.spinnerWidth]: '4px'
37
+ },
38
+ lg: {
39
+ [vars.width]: '60px',
40
+ [vars.height]: '60px',
41
+ [vars.spinnerWidth]: '5px'
42
+ },
43
+ xl: {
44
+ [vars.width]: '80px',
45
+ [vars.height]: '80px',
46
+ [vars.spinnerWidth]: '6px'
47
+ }
48
+ },
49
+ mode: {
50
+ primary: {
51
+ [vars.color]: globalRefs.colors.primary.main
52
+ },
53
+ secondary: {
54
+ [vars.color]: globalRefs.colors.secondary.main
55
+ }
56
+ },
57
+ _hidden: {
58
+ [vars.display]: 'none'
59
+ }
60
+ };
61
+
62
+ export default loaderRadial;
@@ -15,10 +15,6 @@ const textArea = {
15
15
  [vars.borderStyle]: 'solid',
16
16
  [vars.borderColor]: 'transparent',
17
17
 
18
- _borderOffset: {
19
- [vars.outlineOffset]: '2px'
20
- },
21
-
22
18
  _bordered: {
23
19
  [vars.borderColor]: globalRefs.colors.surface.main
24
20
  },
@@ -45,10 +45,6 @@ export const textField = (vars) => ({
45
45
  [vars.borderColor]: 'transparent',
46
46
  [vars.borderRadius]: globalRefs.radius.sm,
47
47
 
48
- _borderOffset: {
49
- [vars.outlineOffset]: '2px'
50
- },
51
-
52
48
  _disabled: {
53
49
  [vars.color]: globalRefs.colors.surface.dark,
54
50
  [vars.placeholderColor]: globalRefs.colors.surface.light,
@@ -1,5 +1,6 @@
1
1
  import { getThemeRefs } from '../themeHelpers';
2
2
  import { genColors } from '../themeHelpers/processColors';
3
+ import button from './components/button';
3
4
 
4
5
  export const colors = genColors({
5
6
  surface: {