@descope/web-components-ui 1.0.419 → 1.0.420

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 (232) hide show
  1. package/dist/cjs/index.cjs.js +1439 -1353
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +0 -2
  4. package/dist/index.esm.js +1983 -1091
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/umd/1172.js +240 -0
  7. package/dist/umd/{8162.js → 1396.js} +3 -3
  8. package/dist/umd/1402.js +1 -0
  9. package/dist/umd/1484.js +148 -0
  10. package/dist/umd/{5026.js → 189.js} +5 -117
  11. package/dist/umd/{6637.js → 201.js} +5 -5
  12. package/dist/umd/{1053.js → 2159.js} +13 -13
  13. package/dist/umd/2540.js +1 -0
  14. package/dist/umd/2570.js +338 -0
  15. package/dist/umd/2666.js +148 -0
  16. package/dist/umd/3110.js +275 -0
  17. package/dist/umd/{9167.js → 3191.js} +66 -12
  18. package/dist/umd/3437.js +2 -0
  19. package/dist/umd/{6418.js → 3638.js} +2 -2
  20. package/dist/umd/{7212.js → 404.js} +8 -8
  21. package/dist/umd/4114.js +124 -0
  22. package/dist/umd/{7607.js → 4127.js} +9 -9
  23. package/dist/umd/4187.js +2 -0
  24. package/dist/umd/4218.js +129 -0
  25. package/dist/umd/4455.js +422 -0
  26. package/dist/umd/4480.js +1 -1
  27. package/dist/umd/{5086.js → 4554.js} +5 -5
  28. package/dist/umd/{4834.js → 4574.js} +5 -5
  29. package/dist/umd/4619.js +1 -1
  30. package/dist/umd/4902.js +170 -0
  31. package/dist/umd/{5273.js → 507.js} +5 -5
  32. package/dist/umd/5096.js +109 -0
  33. package/dist/umd/5318.js +1 -0
  34. package/dist/umd/5414.js +2 -0
  35. package/dist/umd/5414.js.LICENSE.txt +1 -0
  36. package/dist/umd/{8164.js → 5563.js} +5 -5
  37. package/dist/umd/{7824.js → 7097.js} +5 -117
  38. package/dist/umd/7150.js +2 -0
  39. package/dist/umd/7150.js.LICENSE.txt +485 -0
  40. package/dist/umd/731.js +832 -0
  41. package/dist/umd/742.js +2 -0
  42. package/dist/umd/{351.js → 7979.js} +10 -10
  43. package/dist/umd/8823.js +1 -0
  44. package/dist/umd/{6474.js → 9030.js} +12 -12
  45. package/dist/umd/9243.js +202 -0
  46. package/dist/umd/9243.js.LICENSE.txt +51 -0
  47. package/dist/umd/{5443.js → 9478.js} +5 -117
  48. package/dist/umd/DescopeDev.js +1 -2
  49. package/dist/umd/boolean-fields-descope-checkbox-index-js.js +1 -1
  50. package/dist/umd/boolean-fields-descope-switch-toggle-index-js.js +1 -1
  51. package/dist/umd/button-selection-group-fields-descope-button-multi-selection-group-index-js.js +1 -1
  52. package/dist/umd/button-selection-group-fields-descope-button-selection-group-index-js.js +1 -1
  53. package/dist/umd/button-selection-group-fields-descope-button-selection-group-item-index-js.js +1 -1
  54. package/dist/umd/descope-alert-index-js.js +1 -1
  55. package/dist/umd/descope-apps-list-index-js.js +1 -1
  56. package/dist/umd/descope-avatar.js +1 -0
  57. package/dist/umd/descope-button-index-js.js +4 -116
  58. package/dist/umd/descope-code-snippet-index-js.js +1 -1
  59. package/dist/umd/descope-combo-box-index-js.js +5 -5
  60. package/dist/umd/descope-date-field-descope-calendar-index-js.js +1 -1
  61. package/dist/umd/descope-date-field-index-js.js +1 -1
  62. package/dist/umd/descope-divider-index-js.js +1 -1
  63. package/dist/umd/descope-email-field-index-js.js +4 -4
  64. package/dist/umd/descope-enriched-text-index-js.js +1 -1
  65. package/dist/umd/descope-grid-descope-grid-custom-column-index-js.js +4 -4
  66. package/dist/umd/descope-grid-descope-grid-item-details-column-index-js.js +19 -4
  67. package/dist/umd/descope-grid-descope-grid-item-details-column-index-js.js.LICENSE.txt +12 -0
  68. package/dist/umd/descope-grid-descope-grid-selection-column-index-js.js +1 -1
  69. package/dist/umd/descope-grid-descope-grid-text-column-index-js.js +4 -4
  70. package/dist/umd/descope-grid-index-js.js +1 -1
  71. package/dist/umd/descope-hybrid-field-index-js.js +3 -3
  72. package/dist/umd/descope-icon-index-js.js +1 -1
  73. package/dist/umd/descope-link-index-js.js +1 -1
  74. package/dist/umd/descope-modal-index-js.js +1 -1
  75. package/dist/umd/descope-multi-select-combo-box-index-js.js +1 -1
  76. package/dist/umd/descope-new-password-index-js.js +1 -1
  77. package/dist/umd/descope-notification-descope-notification-card-index-js.js +1 -1
  78. package/dist/umd/descope-notification-index-js.js +1 -1
  79. package/dist/umd/descope-number-field-index-js.js +1 -1
  80. package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js +1 -1
  81. package/dist/umd/descope-passcode-index-js.js +1 -1
  82. package/dist/umd/descope-password-index-js.js +1 -1
  83. package/dist/umd/descope-radio-group-index-js.js +1 -1
  84. package/dist/umd/descope-scopes-list-index-js.js +1 -1
  85. package/dist/umd/descope-security-questions-setup-index-js.js +1 -1
  86. package/dist/umd/descope-security-questions-verify-index-js.js +2 -2
  87. package/dist/umd/descope-text-area-index-js.js +1 -1
  88. package/dist/umd/descope-text-field-index-js.js +2 -2
  89. package/dist/umd/descope-text.js +1 -0
  90. package/dist/umd/descope-third-party-app-logo-index-js.js +1 -1
  91. package/dist/umd/descope-upload-file-index-js.js +1 -1
  92. package/dist/umd/descope-user-attribute-index-js.js +1 -1
  93. package/dist/umd/descope-user-auth-method-index-js.js +1 -1
  94. package/dist/umd/index.js +1 -1
  95. package/dist/umd/mapping-fields-descope-mappings-field-index-js.js +1 -1
  96. package/dist/umd/mapping-fields-descope-saml-group-mappings-index-js.js +1 -1
  97. package/dist/umd/phone-fields-descope-phone-field-descope-phone-field-internal-index-js.js +1 -1
  98. package/dist/umd/phone-fields-descope-phone-field-index-js.js +1 -1
  99. package/dist/umd/phone-fields-descope-phone-input-box-field-descope-phone-input-box-internal-index-js.js +2 -2
  100. package/dist/umd/phone-fields-descope-phone-input-box-field-index-js.js +7 -7
  101. package/node_modules/common/.eslintrc.json +18 -0
  102. package/node_modules/common/README.md +7 -0
  103. package/node_modules/common/package.json +34 -0
  104. package/node_modules/common/project.json +7 -0
  105. package/node_modules/common/src/baseClasses/baseClasses/createBaseClass.js +66 -0
  106. package/node_modules/common/src/baseClasses/baseClasses/createBaseInputClass.js +14 -0
  107. package/node_modules/common/src/baseClasses/baseClasses/createCssVarImageClass.js +55 -0
  108. package/node_modules/common/src/baseClasses/index.js +3 -0
  109. package/node_modules/common/src/componentsHelpers/index.js +95 -0
  110. package/node_modules/common/src/componentsMixins/helpers/mixinsHelpers.js +10 -0
  111. package/node_modules/common/src/componentsMixins/index.js +1 -0
  112. package/node_modules/common/src/componentsMixins/mixins/activableMixin.js +14 -0
  113. package/node_modules/common/src/componentsMixins/mixins/changeMixin.js +22 -0
  114. package/node_modules/common/src/componentsMixins/mixins/componentNameValidationMixin.js +23 -0
  115. package/node_modules/common/src/componentsMixins/mixins/componentsContextMixin.js +12 -0
  116. package/node_modules/common/src/componentsMixins/mixins/createDynamicDataMixin.js +100 -0
  117. package/node_modules/common/src/componentsMixins/mixins/createProxy.js +58 -0
  118. package/node_modules/common/src/componentsMixins/mixins/createStyleMixin/helpers.js +106 -0
  119. package/node_modules/common/src/componentsMixins/mixins/createStyleMixin/index.js +167 -0
  120. package/node_modules/common/src/componentsMixins/mixins/draggableMixin.js +62 -0
  121. package/node_modules/common/src/componentsMixins/mixins/externalInputHelpers.js +93 -0
  122. package/node_modules/common/src/componentsMixins/mixins/externalInputMixin.js +170 -0
  123. package/node_modules/common/src/componentsMixins/mixins/hoverableMixin.js +13 -0
  124. package/node_modules/common/src/componentsMixins/mixins/index.js +14 -0
  125. package/node_modules/common/src/componentsMixins/mixins/inputEventsDispatchingMixin.js +76 -0
  126. package/node_modules/common/src/componentsMixins/mixins/inputValidationMixin.js +210 -0
  127. package/node_modules/common/src/componentsMixins/mixins/lifecycleEventsMixin.js +23 -0
  128. package/node_modules/common/src/componentsMixins/mixins/normalizeBooleanAttributesMixin.js +57 -0
  129. package/node_modules/common/src/componentsMixins/mixins/portalMixin.js +112 -0
  130. package/node_modules/common/src/componentsMixins/mixins/proxyInputMixin.js +242 -0
  131. package/node_modules/common/src/constants.js +4 -0
  132. package/node_modules/common/src/icons/errorMessageIconBase64.js +1 -0
  133. package/node_modules/common/src/sbControls.js +302 -0
  134. package/node_modules/common/src/themeHelpers/colorsHelpers.js +94 -0
  135. package/node_modules/common/src/themeHelpers/index.js +176 -0
  136. package/node_modules/common/src/utils/index.js +68 -0
  137. package/node_modules/descope-avatar/e2e/descope-avatar.spec.ts +54 -0
  138. package/node_modules/descope-avatar/package.json +34 -0
  139. package/node_modules/descope-avatar/project.json +7 -0
  140. package/{src/components/descope-avatar → node_modules/descope-avatar/src/component}/AvatarClass.js +4 -4
  141. package/{src/theme/components/avatar.js → node_modules/descope-avatar/src/theme.js} +3 -3
  142. package/node_modules/descope-avatar/stories/avatar.jpeg +0 -0
  143. package/node_modules/descope-avatar/stories/descope-avatar.stories.js +32 -0
  144. package/node_modules/descope-text/e2e/descope-text.spec.ts +35 -0
  145. package/node_modules/descope-text/package.json +31 -0
  146. package/node_modules/descope-text/project.json +7 -0
  147. package/{src/components/descope-text → node_modules/descope-text/src/component}/TextClass.js +4 -4
  148. package/{src/theme/components/text.js → node_modules/descope-text/src/theme.js} +3 -3
  149. package/node_modules/descope-text/stories/descope-text.stories.js +55 -0
  150. package/package.json +52 -43
  151. package/src/components/descope-apps-list/AppsListClass.js +1 -1
  152. package/src/components/descope-apps-list/index.js +2 -2
  153. package/src/components/descope-divider/DividerClass.js +1 -1
  154. package/src/components/descope-divider/index.js +1 -1
  155. package/src/components/descope-link/LinkClass.js +1 -1
  156. package/src/components/descope-link/index.js +1 -1
  157. package/src/components/descope-security-questions-verify/SecurityQuestionsVerifyClass.js +1 -1
  158. package/src/components/descope-security-questions-verify/index.js +1 -1
  159. package/src/components/descope-user-attribute/UserAttributeClass.js +1 -1
  160. package/src/components/descope-user-attribute/index.js +1 -1
  161. package/src/components/descope-user-auth-method/UserAuthMethodClass.js +1 -1
  162. package/src/components/descope-user-auth-method/index.js +1 -1
  163. package/src/components/mapping-fields/descope-mappings-field/MappingsFieldClass.js +1 -1
  164. package/src/components/mapping-fields/descope-mappings-field/index.js +1 -1
  165. package/src/helpers/themeHelpers/index.js +1 -1
  166. package/src/index.cjs.js +2 -2
  167. package/src/index.d.ts +0 -2
  168. package/src/index.js +2 -2
  169. package/src/index.umd.js +3 -1
  170. package/src/mixins/createStyleMixin/index.js +1 -1
  171. package/src/theme/components/alert.js +1 -1
  172. package/src/theme/components/comboBox.js +2 -2
  173. package/src/theme/components/enrichedText.js +1 -1
  174. package/src/theme/components/index.js +2 -2
  175. package/dist/umd/1033.js +0 -2
  176. package/dist/umd/1414.js +0 -352
  177. package/dist/umd/1437.js +0 -422
  178. package/dist/umd/1672.js +0 -1
  179. package/dist/umd/2566.js +0 -2
  180. package/dist/umd/2838.js +0 -2
  181. package/dist/umd/2838.js.LICENSE.txt +0 -1
  182. package/dist/umd/286.js +0 -148
  183. package/dist/umd/2919.js +0 -832
  184. package/dist/umd/3222.js +0 -282
  185. package/dist/umd/3607.js +0 -2
  186. package/dist/umd/3711.js +0 -123
  187. package/dist/umd/5412.js +0 -109
  188. package/dist/umd/650.js +0 -1
  189. package/dist/umd/6726.js +0 -148
  190. package/dist/umd/7407.js +0 -450
  191. package/dist/umd/8980.js +0 -143
  192. package/dist/umd/8980.js.LICENSE.txt +0 -29
  193. package/dist/umd/9632.js +0 -275
  194. package/dist/umd/9878.js +0 -1
  195. package/dist/umd/9895.js +0 -17
  196. package/dist/umd/DescopeDev.js.LICENSE.txt +0 -1
  197. package/dist/umd/bcdfe87ae253c2cf789c9a737f8d8c22.woff +0 -0
  198. package/dist/umd/descope-avatar-index-js.js +0 -1
  199. package/dist/umd/descope-text-index-js.js +0 -1
  200. /package/dist/umd/{1414.js.LICENSE.txt → 1172.js.LICENSE.txt} +0 -0
  201. /package/dist/umd/{1437.js.LICENSE.txt → 1396.js.LICENSE.txt} +0 -0
  202. /package/dist/umd/{6726.js.LICENSE.txt → 1484.js.LICENSE.txt} +0 -0
  203. /package/dist/umd/{286.js.LICENSE.txt → 189.js.LICENSE.txt} +0 -0
  204. /package/dist/umd/{6637.js.LICENSE.txt → 201.js.LICENSE.txt} +0 -0
  205. /package/dist/umd/{1053.js.LICENSE.txt → 2159.js.LICENSE.txt} +0 -0
  206. /package/dist/umd/{351.js.LICENSE.txt → 2570.js.LICENSE.txt} +0 -0
  207. /package/dist/umd/{5026.js.LICENSE.txt → 2666.js.LICENSE.txt} +0 -0
  208. /package/dist/umd/{9632.js.LICENSE.txt → 3110.js.LICENSE.txt} +0 -0
  209. /package/dist/umd/{9167.js.LICENSE.txt → 3191.js.LICENSE.txt} +0 -0
  210. /package/dist/umd/{1033.js.LICENSE.txt → 3437.js.LICENSE.txt} +0 -0
  211. /package/dist/umd/{6418.js.LICENSE.txt → 3638.js.LICENSE.txt} +0 -0
  212. /package/dist/umd/{7212.js.LICENSE.txt → 404.js.LICENSE.txt} +0 -0
  213. /package/dist/umd/{3711.js.LICENSE.txt → 4114.js.LICENSE.txt} +0 -0
  214. /package/dist/umd/{7607.js.LICENSE.txt → 4127.js.LICENSE.txt} +0 -0
  215. /package/dist/umd/{3607.js.LICENSE.txt → 4187.js.LICENSE.txt} +0 -0
  216. /package/dist/umd/{3222.js.LICENSE.txt → 4218.js.LICENSE.txt} +0 -0
  217. /package/dist/umd/{5086.js.LICENSE.txt → 4455.js.LICENSE.txt} +0 -0
  218. /package/dist/umd/{5273.js.LICENSE.txt → 4554.js.LICENSE.txt} +0 -0
  219. /package/dist/umd/{4834.js.LICENSE.txt → 4574.js.LICENSE.txt} +0 -0
  220. /package/dist/umd/{9895.js.LICENSE.txt → 4902.js.LICENSE.txt} +0 -0
  221. /package/dist/umd/{5443.js.LICENSE.txt → 507.js.LICENSE.txt} +0 -0
  222. /package/dist/umd/{5412.js.LICENSE.txt → 5096.js.LICENSE.txt} +0 -0
  223. /package/dist/umd/{8164.js.LICENSE.txt → 5563.js.LICENSE.txt} +0 -0
  224. /package/dist/umd/{7407.js.LICENSE.txt → 7097.js.LICENSE.txt} +0 -0
  225. /package/dist/umd/{2919.js.LICENSE.txt → 731.js.LICENSE.txt} +0 -0
  226. /package/dist/umd/{2566.js.LICENSE.txt → 742.js.LICENSE.txt} +0 -0
  227. /package/dist/umd/{7824.js.LICENSE.txt → 7979.js.LICENSE.txt} +0 -0
  228. /package/dist/umd/{6474.js.LICENSE.txt → 9030.js.LICENSE.txt} +0 -0
  229. /package/dist/umd/{8162.js.LICENSE.txt → 9478.js.LICENSE.txt} +0 -0
  230. /package/{src/helpers → node_modules/common/src}/themeHelpers/componentsThemeManager.js +0 -0
  231. /package/{src/components/descope-avatar → node_modules/descope-avatar/src/component}/index.js +0 -0
  232. /package/{src/components/descope-text → node_modules/descope-text/src/component}/index.js +0 -0
@@ -0,0 +1,176 @@
1
+ import merge from 'lodash.merge';
2
+ import { BASE_THEME_SECTION, DESCOPE_PREFIX, PORTAL_THEME_PREFIX } from '../constants';
3
+ import { isUrl, kebabCase } from '../utils';
4
+ import { getComponentName, getCssVarName } from '../componentsHelpers';
5
+
6
+ const getVarName = (path) => getCssVarName(DESCOPE_PREFIX, ...path);
7
+
8
+ // lodash.set alternative
9
+ const set = (obj, path, value) => {
10
+ const pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g);
11
+
12
+ pathArray.reduce((acc, key, i) => {
13
+ if (acc[key] === undefined) acc[key] = {};
14
+ if (i === pathArray.length - 1) acc[key] = value;
15
+ return acc[key];
16
+ }, obj);
17
+
18
+ return obj;
19
+ };
20
+
21
+ const transformTheme = (theme, path, getTransformation) => {
22
+ return Object.entries(theme).reduce((acc, [key, val]) => {
23
+ if (val?.constructor !== Object) {
24
+ return merge(acc, getTransformation(path.concat(key), val));
25
+ }
26
+ return merge(acc, transformTheme(val, [...path, key], getTransformation));
27
+ }, {});
28
+ };
29
+
30
+ const stringifyArray = (strArr) =>
31
+ strArr.map((str) => (str.includes(' ') ? `"${str}"` : str)).join(', ');
32
+
33
+ const getCssVarValue = (val) => {
34
+ switch (true) {
35
+ case Array.isArray(val):
36
+ return stringifyArray(val);
37
+ case isUrl(val):
38
+ return `url(${val})`;
39
+ default:
40
+ return val;
41
+ }
42
+ };
43
+
44
+ export const themeToCSSVarsObj = (theme) =>
45
+ transformTheme(theme, [], (path, val) => ({
46
+ [getVarName(path)]: getCssVarValue(val),
47
+ }));
48
+
49
+ export const getThemeRefs = (theme, prefix) =>
50
+ transformTheme(theme, [], (path) =>
51
+ set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`)
52
+ );
53
+
54
+ export const getThemeVars = (theme, prefix) =>
55
+ transformTheme(theme, [], (path) => set({}, path, getVarName(prefix ? [prefix, ...path] : path)));
56
+
57
+ export const globalsThemeToStyle = (theme, themeName = '') => {
58
+ const style = Object.entries(themeToCSSVarsObj(theme)).reduce(
59
+ (acc, entry) => `${acc}${entry.join(':')};\n`,
60
+ ''
61
+ );
62
+
63
+ if (!themeName) return style;
64
+
65
+ return `*[data-theme="${themeName}"] {${style}}`;
66
+ };
67
+
68
+ const componentsThemeToStyleObj = (componentsTheme) =>
69
+ transformTheme(componentsTheme, [], (path, val) => {
70
+ const [component, ...restPath] = path;
71
+ const property = restPath.pop();
72
+ const componentName = getComponentName(component);
73
+
74
+ if (property === 'undefined') {
75
+ // eslint-disable-next-line no-console
76
+ console.warn(componentName, `theme value: "${val}" is mapped to an invalid property`);
77
+ }
78
+
79
+ // we need a support for portal components theme (e.g. overlay)
80
+ // this allows us to generate those themes under different sections
81
+ // if the theme has root level attribute that starts with #
82
+ // we are generating a new theme
83
+ let themeName = BASE_THEME_SECTION;
84
+
85
+ if (restPath[0] && restPath[0].startsWith(PORTAL_THEME_PREFIX)) {
86
+ themeName = restPath.shift();
87
+ }
88
+
89
+ // do not start with underscore -> key:value, must have 2 no underscore attrs in a row
90
+ // starts with underscore -> attribute selector
91
+ const attrsSelector = restPath.reduce((acc, section, idx) => {
92
+ if (section.startsWith('_')) return `${acc}[${kebabCase(section.replace(/^_/, ''))}="true"]`;
93
+
94
+ const nextSection = restPath[idx + 1];
95
+
96
+ if (typeof nextSection !== 'string' || nextSection.startsWith('_')) {
97
+ // eslint-disable-next-line no-console
98
+ console.error(
99
+ 'theme generator',
100
+ `your theme structure is invalid, attribute "${section}" is followed by "${nextSection}" which is not allowed`
101
+ );
102
+ return acc;
103
+ }
104
+
105
+ return `${acc}[${kebabCase(section)}="${restPath.splice(idx + 1, 1).join('')}"]`;
106
+ }, '');
107
+
108
+ const selector = `:host${attrsSelector ? `(${attrsSelector})` : ''}`;
109
+
110
+ return {
111
+ [componentName]: {
112
+ [themeName]: {
113
+ [selector]: {
114
+ [property]: getCssVarValue(val),
115
+ },
116
+ },
117
+ },
118
+ };
119
+ });
120
+
121
+ const componentsThemeToStyle = (componentsTheme) =>
122
+ Object.entries(componentsTheme).reduce(
123
+ (acc, [selector, vars]) =>
124
+ `${acc}${selector} { \n${Object.entries(vars)
125
+ .map(([key, val]) => `${key}: ${val}`)
126
+ .join(';\n')} \n}\n\n`,
127
+ ''
128
+ );
129
+
130
+ export const createComponentsTheme = (componentsTheme) => {
131
+ const styleObj = componentsThemeToStyleObj(componentsTheme);
132
+
133
+ return Object.keys(styleObj).reduce((acc, componentName) => {
134
+ const componentThemes = styleObj[componentName];
135
+
136
+ return Object.assign(acc, {
137
+ [componentName]: Object.keys(componentThemes).reduce(
138
+ (res, theme) =>
139
+ Object.assign(res, { [theme]: componentsThemeToStyle(componentThemes[theme]) }),
140
+ {}
141
+ ),
142
+ });
143
+ }, {});
144
+ };
145
+
146
+ export const themeToStyle = ({ globals, components }, themeName) => ({
147
+ globals: globalsThemeToStyle(globals, themeName),
148
+ components: createComponentsTheme(components),
149
+ });
150
+
151
+ // allows to generate css variables with nested fallbacks
152
+ export const useVar = (...varNames) => {
153
+ return varNames.reduceRight((acc, value) => {
154
+ if (value.startsWith('--')) return `var(${value}${acc ? `, ${acc}` : acc})`;
155
+
156
+ return `${value}${acc ? `, ${acc}` : acc}`;
157
+ }, '');
158
+ };
159
+
160
+ export const createHelperVars = (theme, prefix) => {
161
+ const res = transformTheme(theme, [], (path, value) => {
162
+ const modifiedPath = [...path];
163
+ const property = modifiedPath.splice(-1);
164
+ const varName = getCssVarName(prefix, property);
165
+
166
+ const vars = { [property]: varName };
167
+ const useVars = { [property]: useVar(varName) };
168
+
169
+ return { theme: set({}, [...modifiedPath, varName], value), useVars, vars };
170
+ });
171
+
172
+ return [res.theme, res.useVars, res.vars];
173
+ };
174
+
175
+ export { componentsThemeManager } from './componentsThemeManager';
176
+ export * from './colorsHelpers';
@@ -0,0 +1,68 @@
1
+ export const kebabCase = (str) =>
2
+ str
3
+ .replace(/([a-z])([A-Z])/g, '$1-$2')
4
+ .replace(/[\s_.]+/g, '-')
5
+ .toLowerCase();
6
+
7
+ export const kebabCaseJoin = (...args) => kebabCase(args.filter((arg) => !!arg).join('-'));
8
+
9
+ export const upperFirst = (str) => str.charAt(0).toUpperCase() + str.slice(1);
10
+
11
+ export const camelCaseJoin = (...args) =>
12
+ args
13
+ .filter(Boolean)
14
+ .map((arg, index) => (index === 0 ? arg : upperFirst(arg)))
15
+ .join('');
16
+
17
+ export const compose =
18
+ (...fns) =>
19
+ (val) =>
20
+ fns.reduceRight((res, fn) => fn(res), val);
21
+
22
+ export const isFunction = (maybeFunc) => typeof maybeFunc === 'function';
23
+
24
+ export const isUrl = (maybeUrl) => {
25
+ try {
26
+ // eslint-disable-next-line no-new
27
+ new URL(maybeUrl);
28
+
29
+ return true;
30
+ } catch (e) {
31
+ return false;
32
+ }
33
+ };
34
+
35
+ /**
36
+ * Compares two arrays unorderedly.
37
+ * @param {Array} arr1 - The first array to compare.
38
+ * @param {Array} arr2 - The second array to compare.
39
+ * @returns {boolean} - Returns true if the arrays are equal unorderedly, false otherwise.
40
+ */
41
+ export const compareArraysUnordered = (arr1, arr2) => {
42
+ if (!Array.isArray(arr1) || !Array.isArray(arr2)) {
43
+ return false;
44
+ }
45
+
46
+ if (arr1.length !== arr2.length) {
47
+ return false;
48
+ }
49
+
50
+ const sortedArr1 = arr1.slice().sort();
51
+ const sortedArr2 = arr2.slice().sort();
52
+
53
+ for (let i = 0; i < sortedArr1.length; i++) {
54
+ if (sortedArr1[i] !== sortedArr2[i]) {
55
+ return false;
56
+ }
57
+ }
58
+
59
+ return true;
60
+ };
61
+
62
+ export const toTitle = (str) =>
63
+ str
64
+ .replace(/([A-Z])/g, ' $1')
65
+ .trim()
66
+ .split(' ')
67
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
68
+ .join(' ');
@@ -0,0 +1,54 @@
1
+ import { test, expect } from '@playwright/test';
2
+ import { getStoryUrl, loopConfig, loopPresets } from 'e2e-utils';
3
+
4
+ const img =
5
+ 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSzmudcbKkbOue75DaM9HDDrt0W39SJLBH-3HPK3s-K1w&s';
6
+
7
+ const componentAttributes = {
8
+ size: ['xs', 'sm', 'md', 'lg'],
9
+ editable: ['true', 'false'],
10
+ img: [img],
11
+ };
12
+
13
+ const presets = {
14
+ 'direction rtl': {
15
+ direction: 'rtl',
16
+ editable: 'true',
17
+ },
18
+ 'no image': {
19
+ img: '',
20
+ 'display-name': 'John Doe',
21
+ },
22
+ 'no image and name': {
23
+ img: '',
24
+ 'display-name': '',
25
+ },
26
+ };
27
+
28
+ const storyName = 'descope-avatar';
29
+ const componentName = 'descope-avatar';
30
+
31
+ test.describe('theme', () => {
32
+ loopConfig(componentAttributes, (attr, value) => {
33
+ test.describe(`${attr}: ${value}`, () => {
34
+ test.beforeEach(async ({ page }) => {
35
+ await page.goto(getStoryUrl(storyName, { text: 'Text 123', [attr]: value }), { waitUntil: 'load' });
36
+ });
37
+ test('style', async ({ page }) => {
38
+ const componentParent = page.locator(componentName);
39
+
40
+ expect(await componentParent.screenshot()).toMatchSnapshot();
41
+ });
42
+ });
43
+ });
44
+
45
+ loopPresets(presets, (preset, name) => {
46
+ test(name, async ({ page }) => {
47
+ await page.goto(getStoryUrl(storyName, preset));
48
+ await page.waitForSelector(componentName);
49
+ const component = page.locator(componentName);
50
+ expect(
51
+ await component.screenshot({ animations: 'disabled', timeout: 3000, caret: 'hide' })
52
+ ).toMatchSnapshot();
53
+ });
54
+ });});
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "descope-avatar",
3
+ "version": "0.0.1",
4
+ "exports": {
5
+ ".": {
6
+ "import": "./src/component/index.js"
7
+ },
8
+ "./theme": {
9
+ "import": "./src/theme.js"
10
+ },
11
+ "./class": {
12
+ "import": "./src/component/AvatarClass.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "test": "echo 'No tests defined' && exit 0",
17
+ "test:e2e": "echo 'No e2e tests defined' && exit 0"
18
+ },
19
+ "devDependencies": {
20
+ "e2e-utils": "workspace:*",
21
+ "@playwright/test": "1.38.1"
22
+ },
23
+ "dependencies": {
24
+ "common": "0.0.1",
25
+ "theme-globals": "0.0.1",
26
+ "@vaadin/avatar": "24.3.4",
27
+ "@vaadin/icon": "24.3.4",
28
+ "@vaadin/icons": "24.3.4"
29
+ },
30
+ "private": true,
31
+ "publishConfig": {
32
+ "link-workspace-packages": false
33
+ }
34
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "descope-avatar",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/web-components/components/descope-avatar/src",
5
+ "projectType": "library",
6
+ "tags": []
7
+ }
@@ -1,7 +1,7 @@
1
- import { createStyleMixin, draggableMixin, componentNameValidationMixin } from '../../mixins';
2
- import { createBaseClass } from '../../baseClasses/createBaseClass';
3
- import { compose } from '../../helpers';
4
- import { forwardAttrs, getComponentName, observeAttributes } from '../../helpers/componentHelpers';
1
+ import { createStyleMixin, draggableMixin, componentNameValidationMixin } from 'common/components-mixins';
2
+ import { createBaseClass } from 'common/base-classes';
3
+ import { compose } from 'common/utils';
4
+ import { forwardAttrs, getComponentName, observeAttributes } from 'common/components-helpers';
5
5
 
6
6
  export const componentName = getComponentName('avatar');
7
7
  class RawAvatar extends createBaseClass({ componentName, baseSelector: ':host > .wrapper' }) {
@@ -1,6 +1,6 @@
1
- import globals from '../globals';
2
- import { AvatarClass } from '../../components/descope-avatar/AvatarClass';
3
- import { getThemeRefs } from '../../helpers/themeHelpers';
1
+ import globals from 'theme-globals';
2
+ import { AvatarClass } from './component/AvatarClass';
3
+ import { getThemeRefs } from 'common/theme-helpers';
4
4
 
5
5
  const globalRefs = getThemeRefs(globals);
6
6
  const compVars = AvatarClass.cssVarList;
@@ -0,0 +1,32 @@
1
+ import { componentName } from '../src/component/AvatarClass';
2
+ import { directionControl, sizeControl } from 'common/sb-controls';
3
+ import img from './avatar.jpeg'
4
+
5
+ const Template = ({ 'display-name': displayName, img, size, editable, direction }) => `
6
+ <descope-avatar
7
+ display-name="${displayName || ''}"
8
+ img="${img}"
9
+ size="${size}"
10
+ editable="${editable || ''}"
11
+ st-host-direction="${direction ?? ''}">
12
+ ></descope-avatar
13
+ `;
14
+
15
+ export default {
16
+ component: componentName,
17
+ title: 'descope-avatar',
18
+ argTypes: {
19
+ ...sizeControl,
20
+ ...directionControl,
21
+ },
22
+ };
23
+
24
+ export const Default = Template.bind({});
25
+
26
+ Default.args = {
27
+ img: img,
28
+ 'display-name': 'John Doe',
29
+ size: 'sm',
30
+ editable: false,
31
+ direction: ''
32
+ };
@@ -0,0 +1,35 @@
1
+ import { test, expect } from '@playwright/test';
2
+ import { getStoryUrl, loopConfig } from 'e2e-utils';
3
+
4
+ const componentAttributes = {
5
+ text: 'Test Text',
6
+ variant: ['h1', 'h2', 'h3', 'subtitle1', 'subtitle2', 'body1', 'body2'],
7
+ mode: ['primary', 'secondary', 'success', 'error'],
8
+ 'text-align': ['left', 'center', 'right'],
9
+ 'hide-when-empty': ['true'],
10
+ };
11
+
12
+ const storyName = 'descope-text';
13
+ const componentName = 'descope-text';
14
+
15
+ test.describe('theme', () => {
16
+ loopConfig(componentAttributes, (attr, value) => {
17
+ test(`${attr}: ${value}`, async ({ page }) => {
18
+ await page.goto(getStoryUrl(storyName, { [attr]: value }));
19
+ const component = page.locator(componentName);
20
+ expect(await component.screenshot()).toMatchSnapshot();
21
+ });
22
+ });
23
+
24
+ test(`full-width: false`, async ({ page }) => {
25
+ await page.goto(getStoryUrl(storyName, { 'full-width': false }));
26
+ const component = page.locator(componentName);
27
+ expect(await component.screenshot()).toMatchSnapshot();
28
+ });
29
+
30
+ test(`direction: rtl`, async ({ page }) => {
31
+ await page.goto(getStoryUrl(storyName, { direction: 'rtl', text: '-Hello World' }));
32
+ const component = page.locator(componentName);
33
+ expect(await component.screenshot()).toMatchSnapshot();
34
+ });
35
+ });
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "descope-text",
3
+ "version": "0.0.1",
4
+ "exports": {
5
+ ".": {
6
+ "import": "./src/component/index.js"
7
+ },
8
+ "./theme": {
9
+ "import": "./src/theme.js"
10
+ },
11
+ "./class": {
12
+ "import": "./src/component/TextClass.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "test": "echo 'No tests defined' && exit 0",
17
+ "test:e2e": "echo 'No e2e tests defined' && exit 0"
18
+ },
19
+ "devDependencies": {
20
+ "e2e-utils": "workspace:*",
21
+ "@playwright/test": "1.38.1"
22
+ },
23
+ "dependencies": {
24
+ "common": "0.0.1",
25
+ "theme-globals": "0.0.1"
26
+ },
27
+ "private": true,
28
+ "publishConfig": {
29
+ "link-workspace-packages": false
30
+ }
31
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "descope-text",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/web-components/components/descope-text/src",
5
+ "projectType": "library",
6
+ "tags": []
7
+ }
@@ -1,7 +1,7 @@
1
- import { createStyleMixin, draggableMixin, componentNameValidationMixin } from '../../mixins';
2
- import { compose } from '../../helpers';
3
- import { getComponentName, observeChildren } from '../../helpers/componentHelpers';
4
- import { createBaseClass } from '../../baseClasses/createBaseClass';
1
+ import { createStyleMixin, draggableMixin, componentNameValidationMixin } from 'common/components-mixins';
2
+ import { compose } from 'common/utils';
3
+ import { getComponentName, observeChildren } from 'common/components-helpers';
4
+ import { createBaseClass } from 'common/base-classes';
5
5
 
6
6
  export const componentName = getComponentName('text');
7
7
 
@@ -1,6 +1,6 @@
1
- import globals from '../globals';
2
- import { getThemeRefs } from '../../helpers/themeHelpers';
3
- import { TextClass } from '../../components/descope-text/TextClass';
1
+ import globals from 'theme-globals';
2
+ import { getThemeRefs } from 'common/theme-helpers';
3
+ import { TextClass } from './component/TextClass';
4
4
 
5
5
  const globalRefs = getThemeRefs(globals);
6
6
  const vars = TextClass.cssVarList;
@@ -0,0 +1,55 @@
1
+ import { componentName } from '../src/component/TextClass';
2
+ import {
3
+ textContentControl,
4
+ textAlignControl,
5
+ modeControl,
6
+ fullWidthControl,
7
+ typographyVariantControl,
8
+ directionControl,
9
+ } from 'common/sb-controls';
10
+
11
+ const Template = ({
12
+ variant,
13
+ mode,
14
+ 'text-align': textAlign,
15
+ 'full-width': fullWidth,
16
+ text,
17
+ 'hide-when-empty': hideWhenEmpty,
18
+ direction,
19
+ }) => `
20
+ <descope-text
21
+ mode="${mode || ''}"
22
+ variant="${variant || ''}"
23
+ full-width="${fullWidth || false}"
24
+ text-align="${textAlign}"
25
+ hide-when-empty="${hideWhenEmpty}"
26
+ st-host-direction="${direction ?? ''}"
27
+ >${text}</descope-text>
28
+ `;
29
+
30
+ export default {
31
+ component: componentName,
32
+ title: 'descope-text',
33
+ parameters: {
34
+ panelPosition: 'right',
35
+ controls: { expanded: true },
36
+ },
37
+ argTypes: {
38
+ ...textContentControl,
39
+ ...modeControl,
40
+ ...textAlignControl,
41
+ ...fullWidthControl,
42
+ ...typographyVariantControl,
43
+ ...directionControl,
44
+ },
45
+ };
46
+
47
+ export const Default = Template.bind({});
48
+
49
+ Default.args = {
50
+ text: 'Lorem Ipsum',
51
+ variant: 'h1',
52
+ mode: 'primary',
53
+ 'hide-when-empty': false,
54
+ fullWidth: true, // full-width is true by default for test purposes, which expect this as default and test the FALSE override only
55
+ };