@descope/web-components-ui 1.0.39 → 1.0.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) 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 +1128 -481
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/umd/101.js +148 -0
  6. package/dist/umd/208.js +2 -0
  7. package/dist/umd/208.js.LICENSE.txt +5 -0
  8. package/dist/umd/211.js +312 -0
  9. package/dist/umd/211.js.LICENSE.txt +5 -0
  10. package/dist/umd/233.js +573 -0
  11. package/dist/umd/{511.js.LICENSE.txt → 233.js.LICENSE.txt} +0 -6
  12. package/dist/umd/422.js +2 -0
  13. package/dist/umd/422.js.LICENSE.txt +5 -0
  14. package/dist/umd/437.js +19 -0
  15. package/dist/umd/437.js.LICENSE.txt +5 -0
  16. package/dist/umd/513.js +1 -0
  17. package/dist/umd/515.js +202 -0
  18. package/dist/umd/515.js.LICENSE.txt +11 -0
  19. package/dist/umd/54.js +4 -4
  20. package/dist/umd/56.js +48 -0
  21. package/dist/umd/56.js.LICENSE.txt +5 -0
  22. package/dist/umd/599.js +1 -1
  23. package/dist/umd/63.js +1 -0
  24. package/dist/umd/725.js +37 -0
  25. package/dist/umd/725.js.LICENSE.txt +11 -0
  26. package/dist/umd/729.js +1 -1
  27. package/dist/umd/767.js +2 -0
  28. package/dist/umd/{9.js.LICENSE.txt → 767.js.LICENSE.txt} +0 -6
  29. package/dist/umd/786.js +2 -0
  30. package/dist/umd/786.js.LICENSE.txt +17 -0
  31. package/dist/umd/789.js +1 -0
  32. package/dist/umd/806.js +109 -0
  33. package/dist/umd/806.js.LICENSE.txt +5 -0
  34. package/dist/umd/938.js +1 -0
  35. package/dist/umd/97.js +1 -1
  36. package/dist/umd/descope-button-index-js.js +1 -1
  37. package/dist/umd/descope-checkbox-index-js.js +1 -0
  38. package/dist/umd/descope-combo-index-js.js +1 -1
  39. package/dist/umd/descope-container-index-js.js +1 -1
  40. package/dist/umd/descope-email-field-index-js.js +1 -0
  41. package/dist/umd/descope-number-field-index-js.js +1 -0
  42. package/dist/umd/descope-password-field-index-js.js +1 -0
  43. package/dist/umd/descope-switch-toggle-index-js.js +1 -0
  44. package/dist/umd/descope-text-area-index-js.js +1 -0
  45. package/dist/umd/descope-text-field-index-js.js +1 -1
  46. package/dist/umd/index.js +1 -1
  47. package/package.json +9 -2
  48. package/src/components/descope-button/Button.js +90 -30
  49. package/src/components/descope-button/index.js +3 -3
  50. package/src/components/descope-checkbox/Checkbox.js +33 -0
  51. package/src/components/descope-checkbox/index.js +6 -0
  52. package/src/components/descope-combo/index.js +12 -12
  53. package/src/components/descope-container/Container.js +57 -51
  54. package/src/components/descope-container/index.js +1 -1
  55. package/src/components/descope-date-picker/index.js +13 -7
  56. package/src/components/descope-email-field/EmailField.js +72 -0
  57. package/src/components/descope-email-field/index.js +6 -0
  58. package/src/components/descope-number-field/NumberField.js +72 -0
  59. package/src/components/descope-number-field/index.js +6 -0
  60. package/src/components/descope-password-field/PasswordField.js +79 -0
  61. package/src/components/descope-password-field/index.js +6 -0
  62. package/src/components/descope-switch-toggle/SwitchToggle.js +81 -0
  63. package/src/components/descope-switch-toggle/index.js +6 -0
  64. package/src/components/descope-text-area/TextArea.js +66 -0
  65. package/src/components/descope-text-area/index.js +6 -0
  66. package/src/components/descope-text-field/TextField.js +98 -28
  67. package/src/components/descope-text-field/index.js +3 -3
  68. package/src/componentsHelpers/componentNameValidationMixin.js +21 -17
  69. package/src/componentsHelpers/createProxy/helpers.js +31 -27
  70. package/src/componentsHelpers/createProxy/index.js +27 -17
  71. package/src/componentsHelpers/createStyleMixin/helpers.js +65 -47
  72. package/src/componentsHelpers/createStyleMixin/index.js +64 -55
  73. package/src/componentsHelpers/draggableMixin.js +25 -26
  74. package/src/componentsHelpers/index.js +12 -9
  75. package/src/componentsHelpers/inputMixin.js +38 -37
  76. package/src/constants.js +1 -1
  77. package/src/dev/index.js +4 -3
  78. package/src/helpers.js +8 -6
  79. package/src/index.cjs.js +1 -1
  80. package/src/index.js +16 -8
  81. package/src/index.umd.js +11 -5
  82. package/src/theme/components/button.js +32 -21
  83. package/src/theme/components/checkbox.js +9 -0
  84. package/src/theme/components/container.js +32 -27
  85. package/src/theme/components/emailField.js +8 -0
  86. package/src/theme/components/index.js +19 -7
  87. package/src/theme/components/input.js +106 -0
  88. package/src/theme/components/numberField.js +8 -0
  89. package/src/theme/components/passwordField.js +11 -0
  90. package/src/theme/components/switchToggle.js +10 -0
  91. package/src/theme/components/textArea.js +44 -0
  92. package/src/theme/components/textField.js +69 -45
  93. package/src/theme/globals.js +27 -26
  94. package/src/theme/index.js +2 -2
  95. package/src/themeHelpers/index.js +45 -30
  96. package/src/themeHelpers/processColors.js +10 -7
  97. package/dist/umd/221.js +0 -37
  98. package/dist/umd/511.js +0 -573
  99. package/dist/umd/9.js +0 -312
  100. /package/dist/umd/{221.js.LICENSE.txt → 101.js.LICENSE.txt} +0 -0
@@ -5,14 +5,16 @@ var set = require('lodash.set');
5
5
 
6
6
  const DESCOPE_PREFIX = 'descope';
7
7
 
8
- const kebabCase = str => str
9
- .replace(/([a-z])([A-Z])/g, "$1-$2")
10
- .replace(/[\s_.]+/g, '-')
11
- .toLowerCase();
8
+ const kebabCase = (str) =>
9
+ str
10
+ .replace(/([a-z])([A-Z])/g, '$1-$2')
11
+ .replace(/[\s_.]+/g, '-')
12
+ .toLowerCase();
12
13
 
13
14
  const kebabCaseJoin = (...args) => kebabCase(args.join('-'));
14
15
 
15
- const getCssVarName = (...args) => `--${kebabCaseJoin(...args.filter(arg => !!arg))}`;
16
+ const getCssVarName = (...args) =>
17
+ `--${kebabCaseJoin(...args.filter((arg) => !!arg))}`;
16
18
 
17
19
  const getComponentName = (name) => kebabCaseJoin(DESCOPE_PREFIX, name);
18
20
 
@@ -28,21 +30,25 @@ const transformTheme = (theme, path, getTransformation) => {
28
30
  }, {});
29
31
  };
30
32
 
31
- const stringifyArray = (strArr) => strArr.map((str) => (str.includes(" ") ? `"${str}"` : str)).join(", ");
33
+ const stringifyArray = (strArr) =>
34
+ strArr.map((str) => (str.includes(' ') ? `"${str}"` : str)).join(', ');
32
35
 
33
36
  const themeToCSSVarsObj = (theme) =>
34
37
  transformTheme(theme, [], (path, val) => ({
35
- [getVarName(path)]: Array.isArray(val) ? stringifyArray(val) : val,
38
+ [getVarName(path)]: Array.isArray(val) ? stringifyArray(val) : val
36
39
  }));
37
40
 
38
41
  const getThemeRefs = (theme, prefix) =>
39
- transformTheme(theme, [], (path) => set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`));
42
+ transformTheme(theme, [], (path) =>
43
+ set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`)
44
+ );
40
45
 
41
46
  const globalsThemeToStyle = (theme, themeName = '') => `
42
47
  *[data-theme="${themeName}"] {
43
48
  ${Object.entries(themeToCSSVarsObj(theme)).reduce(
44
- (acc, entry) => (acc += `${entry.join(":")};\n`), ''
45
- )}
49
+ (acc, entry) => (acc += `${entry.join(':')};\n`),
50
+ ''
51
+ )}
46
52
  }
47
53
  `;
48
54
 
@@ -55,16 +61,22 @@ const componentsThemeToStyleObj = (componentsTheme) =>
55
61
  // starts with underscore -> attribute selector
56
62
 
57
63
  const attrsSelector = restPath.reduce((acc, section, idx) => {
58
- if (section.startsWith('_')) return acc += `[${kebabCase(section.replace(/^_/, ''))}]`;
64
+ if (section.startsWith('_'))
65
+ return (acc += `[${kebabCase(section.replace(/^_/, ''))}="true"]`);
59
66
 
60
67
  const nextSection = restPath[idx + 1];
61
68
 
62
69
  if (typeof nextSection !== 'string' || nextSection.startsWith('_')) {
63
- console.error('theme generator', `your theme structure is invalid, attribute "${section}" is followed by "${nextSection}" which is not allowed`);
70
+ console.error(
71
+ 'theme generator',
72
+ `your theme structure is invalid, attribute "${section}" is followed by "${nextSection}" which is not allowed`
73
+ );
64
74
  return acc;
65
75
  }
66
76
 
67
- return acc += `[${kebabCase(section)}="${restPath.splice(idx + 1, 1).join('')}"]`;
77
+ return (acc += `[${kebabCase(section)}="${restPath
78
+ .splice(idx + 1, 1)
79
+ .join('')}"]`);
68
80
  }, '');
69
81
 
70
82
  let selector = `${getComponentName(component)}${attrsSelector}`;
@@ -73,12 +85,17 @@ const componentsThemeToStyleObj = (componentsTheme) =>
73
85
  [selector]: {
74
86
  [property]: val
75
87
  }
76
- }
88
+ };
77
89
  });
78
90
 
79
91
  const componentsThemeToStyle = (componentsTheme, themeName = '') =>
80
92
  Object.entries(componentsThemeToStyleObj(componentsTheme)).reduce(
81
- (acc, [selector, vars]) => (acc += `*[data-theme="${themeName}"] ${selector} { \n${Object.entries(vars).map(([key, val]) => `${key}: ${val}`).join(';\n')} \n}\n\n`),
93
+ (acc, [selector, vars]) =>
94
+ (acc += `*[data-theme="${themeName}"] ${selector} { \n${Object.entries(
95
+ vars
96
+ )
97
+ .map(([key, val]) => `${key}: ${val}`)
98
+ .join(';\n')} \n}\n\n`),
82
99
  ''
83
100
  );
84
101
 
@@ -87,7 +104,7 @@ ${globalsThemeToStyle(globals, themeName)}
87
104
  ${componentsThemeToStyle(components, themeName)}
88
105
  `;
89
106
 
90
- const useVar = varName => `var(${varName})`;
107
+ const useVar = (varName) => `var(${varName})`;
91
108
 
92
109
  const createHelperVars = (theme, prefix) => {
93
110
  const res = transformTheme(theme, [], (path, value) => {
@@ -99,10 +116,10 @@ const createHelperVars = (theme, prefix) => {
99
116
  const theme = set({}, [...modifiedPath, varName], value);
100
117
  const useVars = { [property]: useVar(varName) };
101
118
 
102
- return { theme, useVars, vars }
119
+ return { theme, useVars, vars };
103
120
  });
104
121
 
105
- return [res.theme, res.useVars, res.vars]
122
+ return [res.theme, res.useVars, res.vars];
106
123
  };
107
124
 
108
125
  exports.componentsThemeToStyle = componentsThemeToStyle;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../../src/constants.js","../../src/helpers.js","../../src/componentsHelpers/index.js","../../src/themeHelpers/index.js"],"sourcesContent":["export const DESCOPE_PREFIX = 'descope'","export const kebabCase = str => str\n.replace(/([a-z])([A-Z])/g, \"$1-$2\")\n.replace(/[\\s_.]+/g, '-')\n.toLowerCase();\n\nexport const kebabCaseJoin = (...args) => kebabCase(args.join('-'))\n\nexport const getCssVarName = (...args) => `--${kebabCaseJoin(...args.filter(arg => !!arg))}`\n","import { DESCOPE_PREFIX } from \"../constants\";\nimport { kebabCaseJoin } from \"../helpers\";\n\nexport const getComponentName = (name) => kebabCaseJoin(DESCOPE_PREFIX, name)\n\nexport const compose = (...fns) => (val) => fns.reduceRight((res, fn) => fn(res), val);\n\nexport { createStyleMixin } from './createStyleMixin'\nexport { draggableMixin } from './draggableMixin'\nexport { createProxy } from './createProxy'\nexport { inputMixin } from './inputMixin'\nexport { componentNameValidationMixin } from './componentNameValidationMixin'\n","import merge from \"lodash.merge\";\nimport set from \"lodash.set\";\nimport { DESCOPE_PREFIX } from \"../constants\";\nimport { getCssVarName, kebabCase } from \"../helpers\";\nimport { getComponentName } from \"../componentsHelpers\";\n\nconst getVarName = (path) => getCssVarName(DESCOPE_PREFIX, ...path)\n\nconst transformTheme = (theme, path, getTransformation) => {\n\treturn Object.entries(theme).reduce((acc, [key, val]) => {\n\t\tif (val?.constructor !== Object) {\n\t\t\treturn merge(acc, getTransformation(path.concat(key), val));\n\t\t} else {\n\t\t\treturn merge(acc, transformTheme(val, [...path, key], getTransformation));\n\t\t}\n\t}, {});\n};\n\nconst stringifyArray = (strArr) => strArr.map((str) => (str.includes(\" \") ? `\"${str}\"` : str)).join(\", \")\n\nexport const themeToCSSVarsObj = (theme) =>\n\ttransformTheme(theme, [], (path, val) => ({\n\t\t[getVarName(path)]: Array.isArray(val) ? stringifyArray(val) : val,\n\t}));\n\nexport const getThemeRefs = (theme, prefix) =>\n\ttransformTheme(theme, [], (path) => set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`));\n\nexport const globalsThemeToStyle = (theme, themeName = '') => `\n*[data-theme=\"${themeName}\"] {\n\t${Object.entries(themeToCSSVarsObj(theme)).reduce(\n\t(acc, entry) => (acc += `${entry.join(\":\")};\\n`), ''\n)}\n}\n`\n\nconst componentsThemeToStyleObj = (componentsTheme) =>\n\ttransformTheme(componentsTheme, [], (path, val) => {\n\t\tconst [component, ...restPath] = path\n\t\tconst property = restPath.pop()\n\n\t\t// do not start with underscore -> key:value, must have 2 no underscore attrs in a row\n\t\t// starts with underscore -> attribute selector\n\n\t\tconst attrsSelector = restPath.reduce((acc, section, idx) => {\n\t\t\tif (section.startsWith('_')) return acc += `[${kebabCase(section.replace(/^_/, ''))}]`;\n\n\t\t\tconst nextSection = restPath[idx + 1];\n\n\t\t\tif (typeof nextSection !== 'string' || nextSection.startsWith('_')) {\n\t\t\t\tconsole.error('theme generator', `your theme structure is invalid, attribute \"${section}\" is followed by \"${nextSection}\" which is not allowed`)\n\t\t\t\treturn acc;\n\t\t\t}\n\n\t\t\treturn acc += `[${kebabCase(section)}=\"${restPath.splice(idx + 1, 1).join('')}\"]`;\n\t\t}, '');\n\n\t\tlet selector = `${getComponentName(component)}${attrsSelector}`\n\n\t\treturn {\n\t\t\t[selector]: {\n\t\t\t\t[property]: val\n\t\t\t}\n\t\t}\n\t});\n\nexport const componentsThemeToStyle = (componentsTheme, themeName = '') =>\n\tObject.entries(componentsThemeToStyleObj(componentsTheme)).reduce(\n\t\t(acc, [selector, vars]) => (acc += `*[data-theme=\"${themeName}\"] ${selector} { \\n${Object.entries(vars).map(([key, val]) => `${key}: ${val}`).join(';\\n')} \\n}\\n\\n`),\n\t\t''\n\t);\n\nexport const themeToStyle = ({ globals, components }, themeName) => `\n${globalsThemeToStyle(globals, themeName)}\n${componentsThemeToStyle(components, themeName)}\n`\n\nconst useVar = varName => `var(${varName})`\n\nexport const createHelperVars = (theme, prefix) => {\n\tconst res = transformTheme(theme, [], (path, value) => {\n\t\tconst modifiedPath = [...path];\n\t\tconst property = modifiedPath.splice(-1)\n\t\tconst varName = getCssVarName(prefix, property)\n\n\t\tconst vars = { [property]: varName }\n\t\tconst theme = set({}, [...modifiedPath, varName], value)\n\t\tconst useVars = { [property]: useVar(varName) }\n\n\t\treturn { theme, useVars, vars }\n\t})\n\n\treturn [res.theme, res.useVars, res.vars]\n};\n"],"names":[],"mappings":";;;;;AAAO,MAAM,cAAc,GAAG;;ACAvB,MAAM,SAAS,GAAG,GAAG,IAAI,GAAG;AACnC,CAAC,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;AACpC,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;AACzB,CAAC,WAAW,EAAE,CAAC;AACf;AACO,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAC;AACnE;AACO,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE,aAAa,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;;ACJpF,MAAM,gBAAgB,GAAG,CAAC,IAAI,KAAK,aAAa,CAAC,cAAc,EAAE,IAAI;;ACG5E,MAAM,UAAU,GAAG,CAAC,IAAI,KAAK,aAAa,CAAC,cAAc,EAAE,GAAG,IAAI,EAAC;AACnE;AACA,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,iBAAiB,KAAK;AAC3D,CAAC,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK;AAC1D,EAAE,IAAI,GAAG,EAAE,WAAW,KAAK,MAAM,EAAE;AACnC,GAAG,OAAO,KAAK,CAAC,GAAG,EAAE,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;AAC/D,GAAG,MAAM;AACT,GAAG,OAAO,KAAK,CAAC,GAAG,EAAE,cAAc,C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YAAY,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AACjC,EAAE,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAC;AAC1C,EAAE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAC;AACjD;AACA,EAAE,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,GAAG,OAAO,GAAE;AACtC,EAAE,MAAM,KAAK,GAAG,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,YAAY,EAAE,OAAO,CAAC,EAAE,KAAK,EAAC;AAC1D,EAAE,MAAM,OAAO,GAAG,EAAE,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,GAAE;AACjD;AACA,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE;AACjC,EAAE,EAAC;AACH;AACA,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC;AAC1C;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../../src/constants.js","../../src/helpers.js","../../src/componentsHelpers/index.js","../../src/themeHelpers/index.js"],"sourcesContent":["export const DESCOPE_PREFIX = 'descope';\n","export const kebabCase = (str) =>\n\tstr\n\t\t.replace(/([a-z])([A-Z])/g, '$1-$2')\n\t\t.replace(/[\\s_.]+/g, '-')\n\t\t.toLowerCase();\n\nexport const kebabCaseJoin = (...args) => kebabCase(args.join('-'));\n\nexport const getCssVarName = (...args) =>\n\t`--${kebabCaseJoin(...args.filter((arg) => !!arg))}`;\n","import { DESCOPE_PREFIX } from '../constants';\nimport { kebabCaseJoin } from '../helpers';\n\nexport const getComponentName = (name) => kebabCaseJoin(DESCOPE_PREFIX, name);\n\nexport const compose =\n\t(...fns) =>\n\t(val) =>\n\t\tfns.reduceRight((res, fn) => fn(res), val);\n\nexport { createStyleMixin } from './createStyleMixin';\nexport { draggableMixin } from './draggableMixin';\nexport { createProxy } from './createProxy';\nexport { inputMixin } from './inputMixin';\nexport { componentNameValidationMixin } from './componentNameValidationMixin';\n","import merge from 'lodash.merge';\nimport set from 'lodash.set';\nimport { DESCOPE_PREFIX } from '../constants';\nimport { getCssVarName, kebabCase } from '../helpers';\nimport { getComponentName } from '../componentsHelpers';\n\nconst getVarName = (path) => getCssVarName(DESCOPE_PREFIX, ...path);\n\nconst transformTheme = (theme, path, getTransformation) => {\n\treturn Object.entries(theme).reduce((acc, [key, val]) => {\n\t\tif (val?.constructor !== Object) {\n\t\t\treturn merge(acc, getTransformation(path.concat(key), val));\n\t\t} else {\n\t\t\treturn merge(acc, transformTheme(val, [...path, key], getTransformation));\n\t\t}\n\t}, {});\n};\n\nconst stringifyArray = (strArr) =>\n\tstrArr.map((str) => (str.includes(' ') ? `\"${str}\"` : str)).join(', ');\n\nexport const themeToCSSVarsObj = (theme) =>\n\ttransformTheme(theme, [], (path, val) => ({\n\t\t[getVarName(path)]: Array.isArray(val) ? stringifyArray(val) : val\n\t}));\n\nexport const getThemeRefs = (theme, prefix) =>\n\ttransformTheme(theme, [], (path) =>\n\t\tset({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`)\n\t);\n\nexport const globalsThemeToStyle = (theme, themeName = '') => `\n*[data-theme=\"${themeName}\"] {\n\t${Object.entries(themeToCSSVarsObj(theme)).reduce(\n\t\t(acc, entry) => (acc += `${entry.join(':')};\\n`),\n\t\t''\n\t)}\n}\n`;\n\nconst componentsThemeToStyleObj = (componentsTheme) =>\n\ttransformTheme(componentsTheme, [], (path, val) => {\n\t\tconst [component, ...restPath] = path;\n\t\tconst property = restPath.pop();\n\n\t\t// do not start with underscore -> key:value, must have 2 no underscore attrs in a row\n\t\t// starts with underscore -> attribute selector\n\n\t\tconst attrsSelector = restPath.reduce((acc, section, idx) => {\n\t\t\tif (section.startsWith('_'))\n\t\t\t\treturn (acc += `[${kebabCase(section.replace(/^_/, ''))}=\"true\"]`);\n\n\t\t\tconst nextSection = restPath[idx + 1];\n\n\t\t\tif (typeof nextSection !== 'string' || nextSection.startsWith('_')) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t'theme generator',\n\t\t\t\t\t`your theme structure is invalid, attribute \"${section}\" is followed by \"${nextSection}\" which is not allowed`\n\t\t\t\t);\n\t\t\t\treturn acc;\n\t\t\t}\n\n\t\t\treturn (acc += `[${kebabCase(section)}=\"${restPath\n\t\t\t\t.splice(idx + 1, 1)\n\t\t\t\t.join('')}\"]`);\n\t\t}, '');\n\n\t\tlet selector = `${getComponentName(component)}${attrsSelector}`;\n\n\t\treturn {\n\t\t\t[selector]: {\n\t\t\t\t[property]: val\n\t\t\t}\n\t\t};\n\t});\n\nexport const componentsThemeToStyle = (componentsTheme, themeName = '') =>\n\tObject.entries(componentsThemeToStyleObj(componentsTheme)).reduce(\n\t\t(acc, [selector, vars]) =>\n\t\t\t(acc += `*[data-theme=\"${themeName}\"] ${selector} { \\n${Object.entries(\n\t\t\t\tvars\n\t\t\t)\n\t\t\t\t.map(([key, val]) => `${key}: ${val}`)\n\t\t\t\t.join(';\\n')} \\n}\\n\\n`),\n\t\t''\n\t);\n\nexport const themeToStyle = ({ globals, components }, themeName) => `\n${globalsThemeToStyle(globals, themeName)}\n${componentsThemeToStyle(components, themeName)}\n`;\n\nconst useVar = (varName) => `var(${varName})`;\n\nexport const createHelperVars = (theme, prefix) => {\n\tconst res = transformTheme(theme, [], (path, value) => {\n\t\tconst modifiedPath = [...path];\n\t\tconst property = modifiedPath.splice(-1);\n\t\tconst varName = getCssVarName(prefix, property);\n\n\t\tconst vars = { [property]: varName };\n\t\tconst theme = set({}, [...modifiedPath, varName], value);\n\t\tconst useVars = { [property]: useVar(varName) };\n\n\t\treturn { theme, useVars, vars };\n\t});\n\n\treturn [res.theme, res.useVars, res.vars];\n};\n"],"names":[],"mappings":";;;;;AAAO,MAAM,cAAc,GAAG,SAAS;;ACAhC,MAAM,SAAS,GAAG,CAAC,GAAG;AAC7B,CAAC,GA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