@descope/web-components-ui 1.0.40 → 1.0.41

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.
Files changed (35) hide show
  1. package/dist/cjs/index.cjs.js +35 -18
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +382 -327
  4. package/dist/index.esm.js.map +1 -1
  5. package/package.json +1 -1
  6. package/src/components/descope-button/index.js +3 -3
  7. package/src/components/descope-checkbox/index.js +2 -2
  8. package/src/components/descope-combo/index.js +12 -12
  9. package/src/components/descope-container/Container.js +57 -51
  10. package/src/components/descope-container/index.js +1 -1
  11. package/src/components/descope-date-picker/index.js +13 -7
  12. package/src/components/descope-email-field/index.js +2 -2
  13. package/src/components/descope-number-field/index.js +2 -2
  14. package/src/components/descope-password-field/index.js +2 -2
  15. package/src/components/descope-switch-toggle/index.js +2 -2
  16. package/src/components/descope-text-area/index.js +2 -2
  17. package/src/components/descope-text-field/index.js +3 -3
  18. package/src/componentsHelpers/componentNameValidationMixin.js +21 -17
  19. package/src/componentsHelpers/createProxy/helpers.js +31 -27
  20. package/src/componentsHelpers/createStyleMixin/helpers.js +65 -47
  21. package/src/componentsHelpers/createStyleMixin/index.js +64 -55
  22. package/src/componentsHelpers/draggableMixin.js +25 -26
  23. package/src/constants.js +1 -1
  24. package/src/dev/index.js +4 -3
  25. package/src/helpers.js +8 -6
  26. package/src/index.cjs.js +1 -1
  27. package/src/index.js +13 -13
  28. package/src/index.umd.js +11 -5
  29. package/src/theme/components/button.js +37 -37
  30. package/src/theme/components/textArea.js +3 -3
  31. package/src/theme/components/textField.js +1 -1
  32. package/src/theme/globals.js +32 -32
  33. package/src/theme/index.js +2 -2
  34. package/src/themeHelpers/index.js +45 -30
  35. package/src/themeHelpers/processColors.js +10 -7
package/dist/index.esm.js CHANGED
@@ -11,202 +11,235 @@ import Color from 'color';
11
11
 
12
12
  const DESCOPE_PREFIX = 'descope';
13
13
 
14
- const kebabCase = str => str
15
- .replace(/([a-z])([A-Z])/g, "$1-$2")
16
- .replace(/[\s_.]+/g, '-')
17
- .toLowerCase();
14
+ const kebabCase = (str) =>
15
+ str
16
+ .replace(/([a-z])([A-Z])/g, '$1-$2')
17
+ .replace(/[\s_.]+/g, '-')
18
+ .toLowerCase();
18
19
 
19
20
  const kebabCaseJoin = (...args) => kebabCase(args.join('-'));
20
21
 
21
- const getCssVarName = (...args) => `--${kebabCaseJoin(...args.filter(arg => !!arg))}`;
22
+ const getCssVarName = (...args) =>
23
+ `--${kebabCaseJoin(...args.filter((arg) => !!arg))}`;
22
24
 
23
- const createCssVarFallback = (first, ...rest) => `var(${first}${rest.length ? ` , ${createCssVarFallback(...rest)}` : ''})`;
25
+ const createCssVarFallback = (first, ...rest) =>
26
+ `var(${first}${rest.length ? ` , ${createCssVarFallback(...rest)}` : ''})`;
24
27
 
25
- const createCssSelector = (baseSelector = '', relativeSelectorOrSelectorFn = '') =>
26
- typeof relativeSelectorOrSelectorFn === 'function' ?
27
- relativeSelectorOrSelectorFn(baseSelector) :
28
- `${baseSelector}${relativeSelectorOrSelectorFn}`;
28
+ const createCssSelector = (
29
+ baseSelector = '',
30
+ relativeSelectorOrSelectorFn = ''
31
+ ) =>
32
+ typeof relativeSelectorOrSelectorFn === 'function'
33
+ ? relativeSelectorOrSelectorFn(baseSelector)
34
+ : `${baseSelector}${relativeSelectorOrSelectorFn}`;
29
35
 
30
36
  class StyleBuilder {
31
- constructor() {
32
- this.styleMap = new Map();
33
- }
34
-
35
- add(selector, property, value) {
36
- if (!this.styleMap.has(selector)) {
37
- this.styleMap.set(selector, []);
38
- }
39
-
40
- this.styleMap.set(selector, [...this.styleMap.get(selector), { property, value }]);
41
- }
42
-
43
- toString() {
44
- return Array.from(this.styleMap.entries()).reduce((style, [selector, propValArr]) =>
45
- style += `${selector} { \n${propValArr.map(({ property, value }) => `${property}: ${value}`).join(';\n')} \n}\n\n`
46
- , '')
47
- }
37
+ constructor() {
38
+ this.styleMap = new Map();
39
+ }
40
+
41
+ add(selector, property, value) {
42
+ if (!this.styleMap.has(selector)) {
43
+ this.styleMap.set(selector, []);
44
+ }
45
+
46
+ this.styleMap.set(selector, [
47
+ ...this.styleMap.get(selector),
48
+ { property, value }
49
+ ]);
50
+ }
51
+
52
+ toString() {
53
+ return Array.from(this.styleMap.entries()).reduce(
54
+ (style, [selector, propValArr]) =>
55
+ (style += `${selector} { \n${propValArr
56
+ .map(({ property, value }) => `${property}: ${value}`)
57
+ .join(';\n')} \n}\n\n`),
58
+ ''
59
+ );
60
+ }
48
61
  }
49
62
 
50
63
  const normalizeConfig = (attr, config) => {
51
- const defaultMapping = { selector: '', property: kebabCase(attr) };
64
+ const defaultMapping = { selector: '', property: kebabCase(attr) };
52
65
 
53
- if (!config || !Object.keys(config).length) return [defaultMapping];
66
+ if (!config || !Object.keys(config).length) return [defaultMapping];
54
67
 
55
- if (Array.isArray(config)) return config.map(entry => Object.assign({}, defaultMapping, entry));
68
+ if (Array.isArray(config))
69
+ return config.map((entry) => Object.assign({}, defaultMapping, entry));
56
70
 
57
- return [Object.assign({}, defaultMapping, config)];
71
+ return [Object.assign({}, defaultMapping, config)];
58
72
  };
59
73
 
60
74
  const createStyle = (componentName, baseSelector, mappings) => {
61
- const style = new StyleBuilder();
75
+ const style = new StyleBuilder();
62
76
 
63
- Object.keys(mappings).forEach((attr) => {
64
- const attrConfig = normalizeConfig(attr, mappings[attr]);
77
+ Object.keys(mappings).forEach((attr) => {
78
+ const attrConfig = normalizeConfig(attr, mappings[attr]);
65
79
 
66
- const cssVarName = getCssVarName(componentName, attr);
80
+ const cssVarName = getCssVarName(componentName, attr);
67
81
 
68
- attrConfig.forEach(({ selector: relativeSelectorOrSelectorFn, property }) => {
69
- style.add(
70
- createCssSelector(baseSelector, relativeSelectorOrSelectorFn),
71
- property,
72
- createCssVarFallback(cssVarName)
73
- );
74
- });
75
- });
82
+ attrConfig.forEach(
83
+ ({ selector: relativeSelectorOrSelectorFn, property }) => {
84
+ style.add(
85
+ createCssSelector(baseSelector, relativeSelectorOrSelectorFn),
86
+ property,
87
+ createCssVarFallback(cssVarName)
88
+ );
89
+ }
90
+ );
91
+ });
76
92
 
77
- return style.toString();
93
+ return style.toString();
78
94
  };
79
95
 
80
96
  const createCssVarsList = (componentName, mappings) =>
81
- Object.keys(mappings).reduce(
82
- (acc, attr) => Object.assign(acc, { [attr]: getCssVarName(componentName, attr) }),
83
- {}
84
- );
97
+ Object.keys(mappings).reduce(
98
+ (acc, attr) =>
99
+ Object.assign(acc, { [attr]: getCssVarName(componentName, attr) }),
100
+ {}
101
+ );
85
102
 
86
103
  // match the host selector with the inner element selector
87
104
  // e.g. when we want to set the same size for the host & the inner element this can be useful
88
- const matchHostStyle = (mappingObj) => [mappingObj, {...mappingObj, selector: () => `:host${mappingObj.selector || ''}`}];
89
-
90
- const createStyleMixin = ({ mappings = {} }) => (superclass) => {
91
- const styleAttributes = Object.keys(mappings).map(key => kebabCaseJoin('st', key));
92
- return class CustomStyleMixinClass extends superclass {
93
- static get observedAttributes() {
94
- const superAttrs = superclass.observedAttributes || [];
95
- return [...superAttrs, ...styleAttributes]
96
- }
97
-
98
- static get cssVarList() {
99
- return createCssVarsList(superclass.componentName, mappings)
100
- }
101
-
102
- #styleEle = null;
103
-
104
- constructor() {
105
- super();
106
-
107
- this.#createComponentStyle();
108
- this.#createAttrOverrideStyle();
109
- }
110
-
111
- #createAttrOverrideStyle() {
112
- this.#styleEle = document.createElement('style');
113
- this.#styleEle.id = 'style-mixin-overrides';
114
-
115
- this.#styleEle.innerText = '* {}';
116
- this.shadowRoot.prepend(this.#styleEle);
117
- }
118
-
119
- #updateAttrOverrideStyle(attrName, value) {
120
- const style = this.#styleEle.sheet.cssRules[0].style;
121
- const varName = getCssVarName(superclass.componentName, attrName.replace(/^st-/, ''));
122
-
123
- if (value)
124
- style.setProperty(varName, value);
125
- else
126
- style.removeProperty(varName);
127
- }
128
-
129
- #createComponentStyle() {
130
- const themeStyle = document.createElement('style');
131
- themeStyle.id = 'style-mixin-component';
132
- themeStyle.innerHTML = createStyle(superclass.componentName, this.baseSelector, mappings);
133
- this.shadowRoot.prepend(themeStyle);
134
- }
135
-
136
- attributeChangedCallback(attrName, oldValue, newValue) {
137
- super.attributeChangedCallback?.(attrName, oldValue, newValue);
138
-
139
- if (styleAttributes.includes(attrName)) {
140
- this.#updateAttrOverrideStyle(attrName, newValue);
141
- }
142
- }
143
- }
144
- };
105
+ const matchHostStyle = (mappingObj) => [
106
+ mappingObj,
107
+ { ...mappingObj, selector: () => `:host${mappingObj.selector || ''}` }
108
+ ];
109
+
110
+ const createStyleMixin =
111
+ ({ mappings = {} }) =>
112
+ (superclass) => {
113
+ const styleAttributes = Object.keys(mappings).map((key) =>
114
+ kebabCaseJoin('st', key)
115
+ );
116
+ return class CustomStyleMixinClass extends superclass {
117
+ static get observedAttributes() {
118
+ const superAttrs = superclass.observedAttributes || [];
119
+ return [...superAttrs, ...styleAttributes];
120
+ }
121
+
122
+ static get cssVarList() {
123
+ return createCssVarsList(superclass.componentName, mappings);
124
+ }
125
+
126
+ #styleEle = null;
127
+
128
+ constructor() {
129
+ super();
130
+
131
+ this.#createComponentStyle();
132
+ this.#createAttrOverrideStyle();
133
+ }
134
+
135
+ #createAttrOverrideStyle() {
136
+ this.#styleEle = document.createElement('style');
137
+ this.#styleEle.id = 'style-mixin-overrides';
138
+
139
+ this.#styleEle.innerText = '* {}';
140
+ this.shadowRoot.prepend(this.#styleEle);
141
+ }
142
+
143
+ #updateAttrOverrideStyle(attrName, value) {
144
+ const style = this.#styleEle.sheet.cssRules[0].style;
145
+ const varName = getCssVarName(
146
+ superclass.componentName,
147
+ attrName.replace(/^st-/, '')
148
+ );
149
+
150
+ if (value) style.setProperty(varName, value);
151
+ else style.removeProperty(varName);
152
+ }
153
+
154
+ #createComponentStyle() {
155
+ const themeStyle = document.createElement('style');
156
+ themeStyle.id = 'style-mixin-component';
157
+ themeStyle.innerHTML = createStyle(
158
+ superclass.componentName,
159
+ this.baseSelector,
160
+ mappings
161
+ );
162
+ this.shadowRoot.prepend(themeStyle);
163
+ }
164
+
165
+ attributeChangedCallback(attrName, oldValue, newValue) {
166
+ super.attributeChangedCallback?.(attrName, oldValue, newValue);
167
+
168
+ if (styleAttributes.includes(attrName)) {
169
+ this.#updateAttrOverrideStyle(attrName, newValue);
170
+ }
171
+ }
172
+ };
173
+ };
145
174
 
146
175
  const draggableMixin = (superclass) =>
147
- class DraggableMixinClass extends superclass {
148
-
149
- #styleEle = null;
150
-
151
- static get observedAttributes() {
152
- const superAttrs = superclass.observedAttributes || [];
153
- return [...superAttrs, 'draggable']
154
- }
155
-
156
- constructor() {
157
- super();
158
-
159
- this.#styleEle = document.createElement('style');
160
- this.#styleEle.innerText = `${this.baseSelector} { cursor: inherit }`;
161
- }
162
-
163
- #handleDraggableStyle(isDraggable) {
164
- if (isDraggable) {
165
- this.shadowRoot.appendChild(this.#styleEle);
166
- } else {
167
- this.#styleEle.remove();
168
- }
169
- }
170
-
171
- attributeChangedCallback(attrName, oldValue, newValue) {
172
- super.attributeChangedCallback?.(attrName, oldValue, newValue);
173
- if (attrName === 'draggable') {
174
- this.#handleDraggableStyle(newValue === 'true');
175
- }
176
- }
177
- };
176
+ class DraggableMixinClass extends superclass {
177
+ #styleEle = null;
178
+
179
+ static get observedAttributes() {
180
+ const superAttrs = superclass.observedAttributes || [];
181
+ return [...superAttrs, 'draggable'];
182
+ }
183
+
184
+ constructor() {
185
+ super();
186
+
187
+ this.#styleEle = document.createElement('style');
188
+ this.#styleEle.innerText = `${this.baseSelector} { cursor: inherit }`;
189
+ }
190
+
191
+ #handleDraggableStyle(isDraggable) {
192
+ if (isDraggable) {
193
+ this.shadowRoot.appendChild(this.#styleEle);
194
+ } else {
195
+ this.#styleEle.remove();
196
+ }
197
+ }
198
+
199
+ attributeChangedCallback(attrName, oldValue, newValue) {
200
+ super.attributeChangedCallback?.(attrName, oldValue, newValue);
201
+ if (attrName === 'draggable') {
202
+ this.#handleDraggableStyle(newValue === 'true');
203
+ }
204
+ }
205
+ };
178
206
 
179
207
  const observeAttributes = (ele, callback, excludeAttrs) => {
180
- // sync all attrs on init
181
- callback(...Array.from(ele.attributes).map(attr => attr.name));
182
-
183
- const observer = new MutationObserver((mutationsList) => {
184
- for (const mutation of mutationsList) {
185
- if (mutation.type === "attributes" && !excludeAttrs.includes(mutation.attributeName)) {
186
- callback(mutation.attributeName);
187
- }
188
- }
189
- });
190
-
191
- observer.observe(ele, { attributes: true });
192
- };
208
+ // sync all attrs on init
209
+ callback(...Array.from(ele.attributes).map((attr) => attr.name));
210
+
211
+ const observer = new MutationObserver((mutationsList) => {
212
+ for (const mutation of mutationsList) {
213
+ if (
214
+ mutation.type === 'attributes' &&
215
+ !excludeAttrs.includes(mutation.attributeName)
216
+ ) {
217
+ callback(mutation.attributeName);
218
+ }
219
+ }
220
+ });
193
221
 
194
- const createSyncAttrsCb = (srcEle, targetEle) => (...attrNames) => {
195
- attrNames.forEach(attrName => {
196
- const srcAttrVal = srcEle.getAttribute(attrName);
197
- if (srcAttrVal !== null) {
198
- if (targetEle.getAttribute(attrName) !== srcAttrVal) {
199
- targetEle.setAttribute(attrName, srcAttrVal);
200
- }
201
- } else {
202
- targetEle.removeAttribute(attrName);
203
- }
204
- });
222
+ observer.observe(ele, { attributes: true });
205
223
  };
206
224
 
225
+ const createSyncAttrsCb =
226
+ (srcEle, targetEle) =>
227
+ (...attrNames) => {
228
+ attrNames.forEach((attrName) => {
229
+ const srcAttrVal = srcEle.getAttribute(attrName);
230
+ if (srcAttrVal !== null) {
231
+ if (targetEle.getAttribute(attrName) !== srcAttrVal) {
232
+ targetEle.setAttribute(attrName, srcAttrVal);
233
+ }
234
+ } else {
235
+ targetEle.removeAttribute(attrName);
236
+ }
237
+ });
238
+ };
239
+
207
240
  const syncAttrs = (ele1, ele2, excludeAttrs) => {
208
- observeAttributes(ele1, createSyncAttrsCb(ele1, ele2), excludeAttrs);
209
- observeAttributes(ele2, createSyncAttrsCb(ele2, ele1), excludeAttrs);
241
+ observeAttributes(ele1, createSyncAttrsCb(ele1, ele2), excludeAttrs);
242
+ observeAttributes(ele2, createSyncAttrsCb(ele2, ele1), excludeAttrs);
210
243
  };
211
244
 
212
245
  const createProxy = ({
@@ -341,26 +374,30 @@ const inputMixin = (superclass) =>
341
374
  };
342
375
 
343
376
  const componentNameValidationMixin = (superclass) =>
344
- class DraggableMixinClass extends superclass {
345
- #checkComponentName() {
346
- const currentComponentName = this.shadowRoot.host.tagName.toLowerCase();
347
-
348
- if (!superclass.componentName) {
349
- throw Error(`component name is not defined on super class, make sure you have a static get for "componentName"`)
350
- }
351
-
352
- if (currentComponentName !== superclass.componentName) {
353
- throw Error(`component name mismatch, expected "${superclass.componentName}", current "${currentComponentName}"`)
354
- }
355
- }
356
-
357
- connectedCallback() {
358
- super.connectedCallback?.();
359
- if (this.shadowRoot.isConnected) {
360
- this.#checkComponentName();
361
- }
362
- }
363
- };
377
+ class DraggableMixinClass extends superclass {
378
+ #checkComponentName() {
379
+ const currentComponentName = this.shadowRoot.host.tagName.toLowerCase();
380
+
381
+ if (!superclass.componentName) {
382
+ throw Error(
383
+ `component name is not defined on super class, make sure you have a static get for "componentName"`
384
+ );
385
+ }
386
+
387
+ if (currentComponentName !== superclass.componentName) {
388
+ throw Error(
389
+ `component name mismatch, expected "${superclass.componentName}", current "${currentComponentName}"`
390
+ );
391
+ }
392
+ }
393
+
394
+ connectedCallback() {
395
+ super.connectedCallback?.();
396
+ if (this.shadowRoot.isConnected) {
397
+ this.#checkComponentName();
398
+ }
399
+ }
400
+ };
364
401
 
365
402
  const getComponentName = (name) => kebabCaseJoin(DESCOPE_PREFIX, name);
366
403
 
@@ -552,7 +589,7 @@ customElements.define(componentName$9, TextField);
552
589
 
553
590
  const template = document.createElement('template');
554
591
 
555
- const componentName$8 = getComponentName("combo");
592
+ const componentName$8 = getComponentName('combo');
556
593
 
557
594
  template.innerHTML = `
558
595
  <descope-button></descope-button>
@@ -560,13 +597,13 @@ template.innerHTML = `
560
597
  `;
561
598
 
562
599
  class Combo extends HTMLElement {
563
- constructor() {
564
- super();
600
+ constructor() {
601
+ super();
565
602
 
566
- this.attachShadow({ mode: 'open' }).appendChild(
567
- template.content.cloneNode(true)
568
- );
569
- }
603
+ this.attachShadow({ mode: 'open' }).appendChild(
604
+ template.content.cloneNode(true)
605
+ );
606
+ }
570
607
  }
571
608
 
572
609
  customElements.define(componentName$8, Combo);
@@ -822,7 +859,7 @@ overrides$1 = `
822
859
 
823
860
  customElements.define(componentName$4, TextArea);
824
861
 
825
- const componentName$3 = getComponentName("date-picker");
862
+ const componentName$3 = getComponentName('date-picker');
826
863
 
827
864
  const DatePicker = compose(
828
865
  draggableMixin,
@@ -830,66 +867,66 @@ const DatePicker = compose(
830
867
  )(
831
868
  createProxy({
832
869
  componentName: componentName$3,
833
- slots: ["prefix", "suffix"],
834
- wrappedEleName: "vaadin-date-picker",
835
- style: ``,
870
+ slots: ['prefix', 'suffix'],
871
+ wrappedEleName: 'vaadin-date-picker',
872
+ style: ``
836
873
  })
837
874
  );
838
875
 
839
876
  customElements.define(componentName$3, DatePicker);
840
877
 
841
- const componentName$2 = getComponentName("container");
878
+ const componentName$2 = getComponentName('container');
842
879
 
843
880
  class RawContainer extends HTMLElement {
844
- static get componentName() {
845
- return componentName$2
846
- }
847
- constructor() {
848
- super();
849
- const template = document.createElement('template');
850
- template.innerHTML = `<slot></slot>`;
851
-
852
- this.attachShadow({ mode: 'open' });
853
- this.shadowRoot.appendChild(template.content.cloneNode(true));
854
-
855
- this.baseSelector = ':host > slot';
856
- }
881
+ static get componentName() {
882
+ return componentName$2;
883
+ }
884
+ constructor() {
885
+ super();
886
+ const template = document.createElement('template');
887
+ template.innerHTML = `<slot></slot>`;
888
+
889
+ this.attachShadow({ mode: 'open' });
890
+ this.shadowRoot.appendChild(template.content.cloneNode(true));
891
+
892
+ this.baseSelector = ':host > slot';
893
+ }
857
894
  }
858
895
 
859
896
  const Container = compose(
860
- createStyleMixin({
861
- // todo: do we want to change the mapping structure to this? ['aa', 'aaa', {'color': [{ selector: '::part(label)' }]}],
862
- mappings: {
863
- 'height': {},
864
- 'width': {},
865
-
866
- 'verticalPadding': [
867
- { property: 'padding-top' },
868
- { property: 'padding-bottom' }
869
- ],
870
- 'horizontalPadding': [
871
- { property: 'padding-left' },
872
- { property: 'padding-right' }
873
- ],
874
-
875
- 'display': {},
876
- 'flexDirection': {},
877
- 'justifyContent': {},
878
- 'alignItems': {},
879
- 'gap': {},
880
-
881
- 'backgroundColor': {},
882
- 'borderRadius': {},
883
-
884
- 'borderColor': {},
885
- 'borderStyle': {},
886
- 'borderWidth': {},
887
-
888
- 'boxShadow': {},
889
- },
890
- }),
891
- draggableMixin,
892
- componentNameValidationMixin,
897
+ createStyleMixin({
898
+ // todo: do we want to change the mapping structure to this? ['aa', 'aaa', {'color': [{ selector: '::part(label)' }]}],
899
+ mappings: {
900
+ height: {},
901
+ width: {},
902
+
903
+ verticalPadding: [
904
+ { property: 'padding-top' },
905
+ { property: 'padding-bottom' }
906
+ ],
907
+ horizontalPadding: [
908
+ { property: 'padding-left' },
909
+ { property: 'padding-right' }
910
+ ],
911
+
912
+ display: {},
913
+ flexDirection: {},
914
+ justifyContent: {},
915
+ alignItems: {},
916
+ gap: {},
917
+
918
+ backgroundColor: {},
919
+ borderRadius: {},
920
+
921
+ borderColor: {},
922
+ borderStyle: {},
923
+ borderWidth: {},
924
+
925
+ boxShadow: {}
926
+ }
927
+ }),
928
+ draggableMixin,
929
+ componentNameValidationMixin
893
930
  )(RawContainer);
894
931
 
895
932
  customElements.define(componentName$2, Container);
@@ -906,21 +943,25 @@ const transformTheme = (theme, path, getTransformation) => {
906
943
  }, {});
907
944
  };
908
945
 
909
- const stringifyArray = (strArr) => strArr.map((str) => (str.includes(" ") ? `"${str}"` : str)).join(", ");
946
+ const stringifyArray = (strArr) =>
947
+ strArr.map((str) => (str.includes(' ') ? `"${str}"` : str)).join(', ');
910
948
 
911
949
  const themeToCSSVarsObj = (theme) =>
912
950
  transformTheme(theme, [], (path, val) => ({
913
- [getVarName(path)]: Array.isArray(val) ? stringifyArray(val) : val,
951
+ [getVarName(path)]: Array.isArray(val) ? stringifyArray(val) : val
914
952
  }));
915
953
 
916
954
  const getThemeRefs = (theme, prefix) =>
917
- transformTheme(theme, [], (path) => set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`));
955
+ transformTheme(theme, [], (path) =>
956
+ set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`)
957
+ );
918
958
 
919
959
  const globalsThemeToStyle = (theme, themeName = '') => `
920
960
  *[data-theme="${themeName}"] {
921
961
  ${Object.entries(themeToCSSVarsObj(theme)).reduce(
922
- (acc, entry) => (acc += `${entry.join(":")};\n`), ''
923
- )}
962
+ (acc, entry) => (acc += `${entry.join(':')};\n`),
963
+ ''
964
+ )}
924
965
  }
925
966
  `;
926
967
 
@@ -933,16 +974,22 @@ const componentsThemeToStyleObj = (componentsTheme) =>
933
974
  // starts with underscore -> attribute selector
934
975
 
935
976
  const attrsSelector = restPath.reduce((acc, section, idx) => {
936
- if (section.startsWith('_')) return acc += `[${kebabCase(section.replace(/^_/, ''))}]`;
977
+ if (section.startsWith('_'))
978
+ return (acc += `[${kebabCase(section.replace(/^_/, ''))}="true"]`);
937
979
 
938
980
  const nextSection = restPath[idx + 1];
939
981
 
940
982
  if (typeof nextSection !== 'string' || nextSection.startsWith('_')) {
941
- console.error('theme generator', `your theme structure is invalid, attribute "${section}" is followed by "${nextSection}" which is not allowed`);
983
+ console.error(
984
+ 'theme generator',
985
+ `your theme structure is invalid, attribute "${section}" is followed by "${nextSection}" which is not allowed`
986
+ );
942
987
  return acc;
943
988
  }
944
989
 
945
- return acc += `[${kebabCase(section)}="${restPath.splice(idx + 1, 1).join('')}"]`;
990
+ return (acc += `[${kebabCase(section)}="${restPath
991
+ .splice(idx + 1, 1)
992
+ .join('')}"]`);
946
993
  }, '');
947
994
 
948
995
  let selector = `${getComponentName(component)}${attrsSelector}`;
@@ -951,12 +998,17 @@ const componentsThemeToStyleObj = (componentsTheme) =>
951
998
  [selector]: {
952
999
  [property]: val
953
1000
  }
954
- }
1001
+ };
955
1002
  });
956
1003
 
957
1004
  const componentsThemeToStyle = (componentsTheme, themeName = '') =>
958
1005
  Object.entries(componentsThemeToStyleObj(componentsTheme)).reduce(
959
- (acc, [selector, vars]) => (acc += `*[data-theme="${themeName}"] ${selector} { \n${Object.entries(vars).map(([key, val]) => `${key}: ${val}`).join(';\n')} \n}\n\n`),
1006
+ (acc, [selector, vars]) =>
1007
+ (acc += `*[data-theme="${themeName}"] ${selector} { \n${Object.entries(
1008
+ vars
1009
+ )
1010
+ .map(([key, val]) => `${key}: ${val}`)
1011
+ .join(';\n')} \n}\n\n`),
960
1012
  ''
961
1013
  );
962
1014
 
@@ -965,7 +1017,7 @@ ${globalsThemeToStyle(globals, themeName)}
965
1017
  ${componentsThemeToStyle(components, themeName)}
966
1018
  `;
967
1019
 
968
- const useVar = varName => `var(${varName})`;
1020
+ const useVar = (varName) => `var(${varName})`;
969
1021
 
970
1022
  const createHelperVars = (theme, prefix) => {
971
1023
  const res = transformTheme(theme, [], (path, value) => {
@@ -977,17 +1029,20 @@ const createHelperVars = (theme, prefix) => {
977
1029
  const theme = set({}, [...modifiedPath, varName], value);
978
1030
  const useVars = { [property]: useVar(varName) };
979
1031
 
980
- return { theme, useVars, vars }
1032
+ return { theme, useVars, vars };
981
1033
  });
982
1034
 
983
- return [res.theme, res.useVars, res.vars]
1035
+ return [res.theme, res.useVars, res.vars];
984
1036
  };
985
1037
 
986
1038
  const genDark = (c, percentage = 0.5) => c.darken(percentage).hex();
987
1039
  const genLight = (c, percentage = 0.5) => c.lighten(percentage).hex();
988
1040
  const genContrast = (c, percentage = 0.9) => {
989
1041
  const isDark = c.isDark();
990
- return c.mix(Color(isDark ? 'white' : 'black'), percentage).saturate(1).hex();
1042
+ return c
1043
+ .mix(Color(isDark ? 'white' : 'black'), percentage)
1044
+ .saturate(1)
1045
+ .hex();
991
1046
  };
992
1047
 
993
1048
  const genColor = (color) => {
@@ -997,8 +1052,8 @@ const genColor = (color) => {
997
1052
  main: mainColor.hex(),
998
1053
  dark: color.dark || genDark(mainColor),
999
1054
  light: color.light || genLight(mainColor),
1000
- contrast: color.contrast || genContrast(mainColor),
1001
- }
1055
+ contrast: color.contrast || genContrast(mainColor)
1056
+ };
1002
1057
  };
1003
1058
 
1004
1059
  const genColors = (colors) => {
@@ -1006,59 +1061,59 @@ const genColors = (colors) => {
1006
1061
  const currentColor = colors[colorName];
1007
1062
 
1008
1063
  return Object.assign(acc, {
1009
- [colorName]: genColor(currentColor),
1010
- })
1064
+ [colorName]: genColor(currentColor)
1065
+ });
1011
1066
  }, {});
1012
1067
  };
1013
1068
 
1014
1069
  const colors = genColors({
1015
1070
  surface: {
1016
- main: "lightgray",
1017
- light: "#fff",
1018
- dark: "#000",
1071
+ main: 'lightgray',
1072
+ light: '#fff',
1073
+ dark: '#000'
1019
1074
  },
1020
- primary: "#0082B5",
1021
- secondary: "#7D14EB",
1022
- success: "green",
1023
- error: "red",
1075
+ primary: '#0082B5',
1076
+ secondary: '#7D14EB',
1077
+ success: 'green',
1078
+ error: 'red'
1024
1079
  });
1025
1080
 
1026
1081
  const typography = {
1027
1082
  h1: {
1028
- font: ["Courier New", "Arial", "sans-serif"],
1029
- weight: "700",
1030
- size: "48px",
1083
+ font: ['Courier New', 'Arial', 'sans-serif'],
1084
+ weight: '700',
1085
+ size: '48px'
1031
1086
  },
1032
1087
  h2: {
1033
- font: ["Courier New", "sans-serif"],
1034
- weight: "500",
1035
- size: "38px",
1088
+ font: ['Courier New', 'sans-serif'],
1089
+ weight: '500',
1090
+ size: '38px'
1036
1091
  },
1037
1092
  h3: {
1038
- font: ["Courier New", "sans-serif"],
1039
- weight: "300",
1040
- size: "28px",
1041
- },
1093
+ font: ['Courier New', 'sans-serif'],
1094
+ weight: '300',
1095
+ size: '28px'
1096
+ }
1042
1097
  };
1043
1098
 
1044
1099
  const spacing = {
1045
- xs: "2px",
1046
- sm: "4px",
1047
- md: "8px",
1048
- lg: "16px",
1049
- xl: "32px",
1100
+ xs: '2px',
1101
+ sm: '4px',
1102
+ md: '8px',
1103
+ lg: '16px',
1104
+ xl: '32px'
1050
1105
  };
1051
1106
 
1052
1107
  const border = {
1053
- sm: "1px",
1054
- md: "2px",
1055
- lg: "3px",
1108
+ sm: '1px',
1109
+ md: '2px',
1110
+ lg: '3px'
1056
1111
  };
1057
1112
 
1058
1113
  const radius = {
1059
- sm: "5px",
1060
- md: "25px",
1061
- lg: "50px",
1114
+ sm: '5px',
1115
+ md: '25px',
1116
+ lg: '50px'
1062
1117
  };
1063
1118
 
1064
1119
  const shadow = {
@@ -1066,8 +1121,8 @@ const shadow = {
1066
1121
  size: {
1067
1122
  sm: `0 0 10px`,
1068
1123
  md: `0 0 20px`,
1069
- lg: `0 0 30px`,
1070
- },
1124
+ lg: `0 0 30px`
1125
+ }
1071
1126
  };
1072
1127
 
1073
1128
  var globals = {
@@ -1076,7 +1131,7 @@ var globals = {
1076
1131
  spacing,
1077
1132
  border,
1078
1133
  radius,
1079
- shadow,
1134
+ shadow
1080
1135
  };
1081
1136
 
1082
1137
  const globalRefs$3 = getThemeRefs(globals);
@@ -1087,7 +1142,7 @@ const mode = {
1087
1142
  secondary: globalRefs$3.colors.secondary,
1088
1143
  success: globalRefs$3.colors.success,
1089
1144
  error: globalRefs$3.colors.error,
1090
- surface: globalRefs$3.colors.surface,
1145
+ surface: globalRefs$3.colors.surface
1091
1146
  };
1092
1147
 
1093
1148
  const [helperTheme$1, helperRefs$1] = createHelperVars({ mode }, componentName$a);
@@ -1097,43 +1152,43 @@ const button = {
1097
1152
 
1098
1153
  size: {
1099
1154
  xs: {
1100
- [vars$6.height]: "10px",
1101
- [vars$6.fontSize]: "10px",
1102
- [vars$6.padding]: `0 ${globalRefs$3.spacing.xs}`,
1155
+ [vars$6.height]: '10px',
1156
+ [vars$6.fontSize]: '10px',
1157
+ [vars$6.padding]: `0 ${globalRefs$3.spacing.xs}`
1103
1158
  },
1104
1159
  sm: {
1105
- [vars$6.height]: "20px",
1106
- [vars$6.fontSize]: "10px",
1107
- [vars$6.padding]: `0 ${globalRefs$3.spacing.sm}`,
1160
+ [vars$6.height]: '20px',
1161
+ [vars$6.fontSize]: '10px',
1162
+ [vars$6.padding]: `0 ${globalRefs$3.spacing.sm}`
1108
1163
  },
1109
1164
  md: {
1110
- [vars$6.height]: "30px",
1111
- [vars$6.fontSize]: "14px",
1112
- [vars$6.padding]: `0 ${globalRefs$3.spacing.md}`,
1165
+ [vars$6.height]: '30px',
1166
+ [vars$6.fontSize]: '14px',
1167
+ [vars$6.padding]: `0 ${globalRefs$3.spacing.md}`
1113
1168
  },
1114
1169
  lg: {
1115
- [vars$6.height]: "40px",
1116
- [vars$6.fontSize]: "20px",
1117
- [vars$6.padding]: `0 ${globalRefs$3.spacing.lg}`,
1170
+ [vars$6.height]: '40px',
1171
+ [vars$6.fontSize]: '20px',
1172
+ [vars$6.padding]: `0 ${globalRefs$3.spacing.lg}`
1118
1173
  },
1119
1174
  xl: {
1120
- [vars$6.height]: "50px",
1121
- [vars$6.fontSize]: "25px",
1122
- [vars$6.padding]: `0 ${globalRefs$3.spacing.xl}`,
1123
- },
1175
+ [vars$6.height]: '50px',
1176
+ [vars$6.fontSize]: '25px',
1177
+ [vars$6.padding]: `0 ${globalRefs$3.spacing.xl}`
1178
+ }
1124
1179
  },
1125
1180
 
1126
1181
  [vars$6.borderRadius]: globalRefs$3.radius.lg,
1127
- [vars$6.cursor]: "pointer",
1128
- [vars$6.borderWidth]: "2px",
1129
- [vars$6.borderStyle]: "solid",
1130
- [vars$6.borderColor]: "transparent",
1182
+ [vars$6.cursor]: 'pointer',
1183
+ [vars$6.borderWidth]: '2px',
1184
+ [vars$6.borderStyle]: 'solid',
1185
+ [vars$6.borderColor]: 'transparent',
1131
1186
 
1132
- _fullwidth: {
1133
- [vars$6.width]: "100%",
1187
+ _fullWidth: {
1188
+ [vars$6.width]: '100%'
1134
1189
  },
1135
1190
  _loading: {
1136
- [vars$6.cursor]: "wait",
1191
+ [vars$6.cursor]: 'wait'
1137
1192
  },
1138
1193
 
1139
1194
  variant: {
@@ -1141,11 +1196,11 @@ const button = {
1141
1196
  [vars$6.color]: helperRefs$1.contrast,
1142
1197
  [vars$6.backgroundColor]: helperRefs$1.main,
1143
1198
  _hover: {
1144
- [vars$6.backgroundColor]: helperRefs$1.dark,
1199
+ [vars$6.backgroundColor]: helperRefs$1.dark
1145
1200
  },
1146
1201
  _loading: {
1147
- [vars$6.backgroundColor]: helperRefs$1.main,
1148
- },
1202
+ [vars$6.backgroundColor]: helperRefs$1.main
1203
+ }
1149
1204
  },
1150
1205
  outline: {
1151
1206
  [vars$6.color]: helperRefs$1.main,
@@ -1154,9 +1209,9 @@ const button = {
1154
1209
  [vars$6.color]: helperRefs$1.dark,
1155
1210
  [vars$6.borderColor]: helperRefs$1.dark,
1156
1211
  _error: {
1157
- [vars$6.color]: helperRefs$1.error,
1158
- },
1159
- },
1212
+ [vars$6.color]: helperRefs$1.error
1213
+ }
1214
+ }
1160
1215
  },
1161
1216
  link: {
1162
1217
  [vars$6.color]: helperRefs$1.main,
@@ -1166,10 +1221,10 @@ const button = {
1166
1221
  [vars$6.borderRadius]: 0,
1167
1222
  _hover: {
1168
1223
  [vars$6.color]: helperRefs$1.main,
1169
- [vars$6.textDecoration]: "underline",
1170
- },
1171
- },
1172
- },
1224
+ [vars$6.textDecoration]: 'underline'
1225
+ }
1226
+ }
1227
+ }
1173
1228
  };
1174
1229
 
1175
1230
  const globalRefs$2 = getThemeRefs(globals);
@@ -1231,7 +1286,7 @@ const textField = (vars) => ({
1231
1286
  [vars.backgroundColor]: globalRefs$2.colors.surface.main
1232
1287
  },
1233
1288
 
1234
- _fullwidth: {
1289
+ _fullWidth: {
1235
1290
  [vars.width]: '100%'
1236
1291
  },
1237
1292
 
@@ -1274,12 +1329,12 @@ const textArea = {
1274
1329
  [vars$3.borderStyle]: 'solid',
1275
1330
  [vars$3.borderColor]: 'transparent',
1276
1331
 
1277
- _borderoffset: {
1332
+ _borderOffset: {
1278
1333
  [vars$3.outlineOffset]: '2px'
1279
1334
  },
1280
1335
 
1281
1336
  _bordered: {
1282
- [vars$3.inputBorderColor]: globalRefs$1.colors.surface.main
1337
+ [vars$3.borderColor]: globalRefs$1.colors.surface.main
1283
1338
  },
1284
1339
 
1285
1340
  _focused: {
@@ -1287,7 +1342,7 @@ const textArea = {
1287
1342
  [vars$3.outline]: `2px solid ${globalRefs$1.colors.surface.main}`
1288
1343
  },
1289
1344
 
1290
- _fullwidth: {
1345
+ _fullWidth: {
1291
1346
  [vars$3.width]: '100%'
1292
1347
  },
1293
1348