@descope/web-components-ui 1.0.135 → 1.0.148

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. package/package.json +77 -56
  2. package/src/baseClasses/createBaseClass.js +18 -16
  3. package/src/baseClasses/createBaseInputClass.js +14 -8
  4. package/src/baseClasses/createCssVarImageClass.js +27 -23
  5. package/src/components/boolean-fields/booleanFieldMixin.js +18 -29
  6. package/src/components/boolean-fields/commonStyles.js +1 -1
  7. package/src/components/boolean-fields/descope-boolean-field-internal/BooleanFieldInternal.js +46 -51
  8. package/src/components/boolean-fields/descope-boolean-field-internal/index.js +1 -1
  9. package/src/components/boolean-fields/descope-checkbox/CheckboxClass.js +80 -85
  10. package/src/components/boolean-fields/descope-checkbox/index.js +2 -2
  11. package/src/components/boolean-fields/descope-switch-toggle/SwitchToggleClass.js +88 -95
  12. package/src/components/boolean-fields/descope-switch-toggle/index.js +2 -2
  13. package/src/components/descope-button/ButtonClass.js +57 -47
  14. package/src/components/descope-button/clickableMixin.js +10 -0
  15. package/src/components/descope-combo-box/ComboBoxClass.js +156 -160
  16. package/src/components/descope-container/ContainerClass.js +32 -42
  17. package/src/components/descope-date-picker/index.js +9 -14
  18. package/src/components/descope-divider/DividerClass.js +52 -62
  19. package/src/components/descope-email-field/EmailFieldClass.js +25 -20
  20. package/src/components/descope-image/ImageClass.js +21 -24
  21. package/src/components/descope-link/LinkClass.js +31 -35
  22. package/src/components/descope-loader-linear/LoaderLinearClass.js +31 -36
  23. package/src/components/descope-loader-radial/LoaderRadialClass.js +23 -30
  24. package/src/components/descope-logo/LogoClass.js +5 -1
  25. package/src/components/descope-new-password/NewPasswordClass.js +63 -81
  26. package/src/components/descope-new-password/descope-new-password-internal/NewPasswordInternal.js +157 -162
  27. package/src/components/descope-new-password/descope-new-password-internal/componentName.js +1 -1
  28. package/src/components/descope-new-password/descope-new-password-internal/index.js +3 -3
  29. package/src/components/descope-new-password/index.js +3 -3
  30. package/src/components/descope-number-field/NumberFieldClass.js +25 -20
  31. package/src/components/descope-passcode/PasscodeClass.js +95 -95
  32. package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +151 -157
  33. package/src/components/descope-passcode/descope-passcode-internal/helpers.js +7 -8
  34. package/src/components/descope-passcode/descope-passcode-internal/index.js +2 -2
  35. package/src/components/descope-passcode/index.js +2 -2
  36. package/src/components/descope-password/PasswordClass.js +75 -83
  37. package/src/components/descope-password/passwordDraggableMixin.js +28 -27
  38. package/src/components/descope-phone-field/CountryCodes.js +1210 -1210
  39. package/src/components/descope-phone-field/PhoneFieldClass.js +139 -141
  40. package/src/components/descope-phone-field/descope-phone-field-internal/PhoneFieldInternal.js +157 -173
  41. package/src/components/descope-phone-field/helpers.js +3 -3
  42. package/src/components/descope-text/TextClass.js +25 -29
  43. package/src/components/descope-text-area/TextAreaClass.js +68 -67
  44. package/src/components/descope-text-field/TextFieldClass.js +42 -37
  45. package/src/components/descope-text-field/textFieldMappings.js +40 -55
  46. package/src/components/descope-totp-image/TotpImageClass.js +5 -1
  47. package/src/components/descope-upload-file/UploadFileClass.js +202 -0
  48. package/src/components/descope-upload-file/helpers.js +11 -0
  49. package/src/components/descope-upload-file/index.js +6 -0
  50. package/src/constants.js +3 -3
  51. package/src/helpers/componentHelpers.js +68 -74
  52. package/src/helpers/index.js +17 -16
  53. package/src/helpers/mixinsHelpers.js +21 -10
  54. package/src/helpers/themeHelpers/colorsHelpers.js +18 -18
  55. package/src/helpers/themeHelpers/componentsThemeManager.js +7 -6
  56. package/src/helpers/themeHelpers/index.js +114 -124
  57. package/src/helpers/themeHelpers/resetHelpers.js +16 -16
  58. package/src/index.cjs.js +3 -3
  59. package/src/index.d.ts +22 -21
  60. package/src/index.js +5 -4
  61. package/src/index.umd.js +14 -13
  62. package/src/mixins/changeMixin.js +18 -17
  63. package/src/mixins/componentNameValidationMixin.js +19 -19
  64. package/src/mixins/createProxy.js +33 -33
  65. package/src/mixins/createStyleMixin/helpers.js +54 -64
  66. package/src/mixins/createStyleMixin/index.js +155 -141
  67. package/src/mixins/draggableMixin.js +61 -61
  68. package/src/mixins/hoverableMixin.js +11 -13
  69. package/src/mixins/index.js +6 -6
  70. package/src/mixins/inputEventsDispatchingMixin.js +61 -60
  71. package/src/mixins/inputValidationMixin.js +153 -148
  72. package/src/mixins/lifecycleEventsMixin.js +17 -15
  73. package/src/mixins/normalizeBooleanAttributesMixin.js +31 -23
  74. package/src/mixins/portalMixin.js +58 -52
  75. package/src/mixins/proxyInputMixin.js +138 -132
  76. package/src/theme/components/button.js +86 -81
  77. package/src/theme/components/checkbox.js +26 -28
  78. package/src/theme/components/comboBox.js +32 -31
  79. package/src/theme/components/container.js +99 -89
  80. package/src/theme/components/divider.js +30 -31
  81. package/src/theme/components/emailField.js +20 -19
  82. package/src/theme/components/image.js +3 -3
  83. package/src/theme/components/index.js +33 -25
  84. package/src/theme/components/inputWrapper.js +28 -25
  85. package/src/theme/components/link.js +29 -36
  86. package/src/theme/components/loader/index.js +3 -3
  87. package/src/theme/components/loader/loaderLinear.js +34 -34
  88. package/src/theme/components/loader/loaderRadial.js +40 -34
  89. package/src/theme/components/logo.js +4 -4
  90. package/src/theme/components/newPassword.js +14 -13
  91. package/src/theme/components/numberField.js +20 -19
  92. package/src/theme/components/passcode.js +20 -22
  93. package/src/theme/components/password.js +22 -21
  94. package/src/theme/components/phoneField.js +23 -23
  95. package/src/theme/components/switchToggle.js +47 -46
  96. package/src/theme/components/text.js +72 -72
  97. package/src/theme/components/textArea.js +27 -25
  98. package/src/theme/components/textField.js +23 -22
  99. package/src/theme/components/totpImage.js +4 -4
  100. package/src/theme/components/uploadFile.js +60 -0
  101. package/src/theme/globals.js +123 -124
  102. package/src/theme/index.js +1 -1
  103. package/dist/cjs/index.cjs.js +0 -5924
  104. package/dist/cjs/index.cjs.js.map +0 -1
  105. package/dist/cjs/package.json +0 -1
  106. package/dist/index.d.ts +0 -51
  107. package/dist/index.esm.js +0 -6606
  108. package/dist/index.esm.js.map +0 -1
  109. package/dist/umd/1018.js +0 -577
  110. package/dist/umd/1018.js.LICENSE.txt +0 -23
  111. package/dist/umd/2481.js +0 -1
  112. package/dist/umd/3208.js +0 -2
  113. package/dist/umd/3208.js.LICENSE.txt +0 -5
  114. package/dist/umd/3585.js +0 -1
  115. package/dist/umd/3878.js +0 -1
  116. package/dist/umd/4201.js +0 -1
  117. package/dist/umd/422.js +0 -2
  118. package/dist/umd/422.js.LICENSE.txt +0 -5
  119. package/dist/umd/4447.js +0 -1
  120. package/dist/umd/4513.js +0 -1
  121. package/dist/umd/4803.js +0 -1
  122. package/dist/umd/541.js +0 -744
  123. package/dist/umd/541.js.LICENSE.txt +0 -21
  124. package/dist/umd/5767.js +0 -2
  125. package/dist/umd/5767.js.LICENSE.txt +0 -15
  126. package/dist/umd/5806.js +0 -109
  127. package/dist/umd/5806.js.LICENSE.txt +0 -5
  128. package/dist/umd/7056.js +0 -48
  129. package/dist/umd/7056.js.LICENSE.txt +0 -5
  130. package/dist/umd/7101.js +0 -148
  131. package/dist/umd/7101.js.LICENSE.txt +0 -11
  132. package/dist/umd/729.js +0 -1
  133. package/dist/umd/7824.js +0 -229
  134. package/dist/umd/7824.js.LICENSE.txt +0 -27
  135. package/dist/umd/7840.js +0 -356
  136. package/dist/umd/7840.js.LICENSE.txt +0 -61
  137. package/dist/umd/8725.js +0 -37
  138. package/dist/umd/8725.js.LICENSE.txt +0 -11
  139. package/dist/umd/9211.js +0 -312
  140. package/dist/umd/9211.js.LICENSE.txt +0 -5
  141. package/dist/umd/9241.js +0 -1
  142. package/dist/umd/9314.js +0 -283
  143. package/dist/umd/9314.js.LICENSE.txt +0 -27
  144. package/dist/umd/9437.js +0 -19
  145. package/dist/umd/9437.js.LICENSE.txt +0 -5
  146. package/dist/umd/9515.js +0 -202
  147. package/dist/umd/9515.js.LICENSE.txt +0 -11
  148. package/dist/umd/9789.js +0 -1
  149. package/dist/umd/boolean-fields-descope-boolean-field-internal-index-js.js +0 -1
  150. package/dist/umd/boolean-fields-descope-checkbox-index-js.js +0 -1
  151. package/dist/umd/boolean-fields-descope-switch-toggle-index-js.js +0 -1
  152. package/dist/umd/descope-button-index-js.js +0 -1
  153. package/dist/umd/descope-combo-box-index-js.js +0 -1
  154. package/dist/umd/descope-container-index-js.js +0 -1
  155. package/dist/umd/descope-date-picker-index-js.js +0 -1
  156. package/dist/umd/descope-divider-index-js.js +0 -1
  157. package/dist/umd/descope-email-field-index-js.js +0 -1
  158. package/dist/umd/descope-image-index-js.js +0 -1
  159. package/dist/umd/descope-link-index-js.js +0 -1
  160. package/dist/umd/descope-loader-linear-index-js.js +0 -1
  161. package/dist/umd/descope-loader-radial-index-js.js +0 -1
  162. package/dist/umd/descope-logo-index-js.js +0 -1
  163. package/dist/umd/descope-new-password-descope-new-password-internal-index-js.js +0 -1
  164. package/dist/umd/descope-new-password-index-js.js +0 -1
  165. package/dist/umd/descope-number-field-index-js.js +0 -1
  166. package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js +0 -1
  167. package/dist/umd/descope-passcode-index-js.js +0 -1
  168. package/dist/umd/descope-password-index-js.js +0 -1
  169. package/dist/umd/descope-phone-field-descope-phone-field-internal-index-js.js +0 -1
  170. package/dist/umd/descope-phone-field-index-js.js +0 -1
  171. package/dist/umd/descope-text-area-index-js.js +0 -1
  172. package/dist/umd/descope-text-field-index-js.js +0 -1
  173. package/dist/umd/descope-text-index-js.js +0 -1
  174. package/dist/umd/descope-totp-image-index-js.js +0 -1
  175. package/dist/umd/index.js +0 -1
@@ -1,10 +1,9 @@
1
-
2
1
  // create a dispatch event function that also calls to the onevent function in case it's set
3
2
  // usage example:
4
3
  // #dispatchSomething = createDispatchEvent.bind(this, 'something' { ...options })
5
4
  // this will dispatch a new event when called, but also call to "onsomething"
6
5
  export function createDispatchEvent(eventName, options = {}) {
7
- const event = new Event(eventName, options)
6
+ const event = new Event(eventName, options);
8
7
 
9
8
  this[`on${eventName}`]?.(event); // in case we got an event callback as property
10
9
  this.dispatchEvent(event);
@@ -14,22 +13,34 @@ export function createDispatchEvent(eventName, options = {}) {
14
13
  // usage example:
15
14
  // createEventListener.call(this,'change', this.onChange, { element? , ...options })
16
15
  export function createEventListener(event, callback, { element, ...options } = {}) {
17
- const timerId = setTimeout(() => console.warn(this.localName, 'is not using "lifecycleEventsMixin", events will not be removed automatically on disconnect'), 2000)
18
-
19
- this.addEventListener('connected', () => {
20
- clearTimeout(timerId);
21
- }, { once: true })
16
+ const timerId = setTimeout(
17
+ () =>
18
+ // eslint-disable-next-line no-console
19
+ console.warn(
20
+ this.localName,
21
+ 'is not using "lifecycleEventsMixin", events will not be removed automatically on disconnect'
22
+ ),
23
+ 2000
24
+ );
25
+
26
+ this.addEventListener(
27
+ 'connected',
28
+ () => {
29
+ clearTimeout(timerId);
30
+ },
31
+ { once: true }
32
+ );
22
33
 
23
34
  const targetEle = element || this;
24
35
  const boundCallback = callback.bind(this);
25
36
 
26
37
  const onDisconnect = () => {
27
38
  targetEle.removeEventListener(event, boundCallback);
28
- }
39
+ };
29
40
 
30
- this.addEventListener('disconnected', onDisconnect, { once: true })
41
+ this.addEventListener('disconnected', onDisconnect, { once: true });
31
42
 
32
43
  targetEle.addEventListener(event, boundCallback, options);
33
44
 
34
- return onDisconnect
45
+ return onDisconnect;
35
46
  }
@@ -3,30 +3,30 @@ import Color from 'color';
3
3
  const genDark = (c, percentage = 0.5) => c.darken(percentage).hex();
4
4
  const genLight = (c, percentage = 0.5) => c.lighten(percentage).hex();
5
5
  const genContrast = (c, percentage = 0.9) => {
6
- const isDark = c.isDark();
7
- return c
8
- .mix(Color(isDark ? 'white' : 'black'), percentage)
9
- .saturate(1)
10
- .hex();
6
+ const isDark = c.isDark();
7
+ return c
8
+ .mix(Color(isDark ? 'white' : 'black'), percentage)
9
+ .saturate(1)
10
+ .hex();
11
11
  };
12
12
 
13
13
  export const genColor = (color) => {
14
- const mainColor = new Color(color.main || color);
14
+ const mainColor = new Color(color.main || color);
15
15
 
16
- return {
17
- main: mainColor.hex(),
18
- dark: color.dark || genDark(mainColor),
19
- light: color.light || genLight(mainColor),
20
- contrast: color.contrast || genContrast(mainColor)
21
- };
16
+ return {
17
+ main: mainColor.hex(),
18
+ dark: color.dark || genDark(mainColor),
19
+ light: color.light || genLight(mainColor),
20
+ contrast: color.contrast || genContrast(mainColor),
21
+ };
22
22
  };
23
23
 
24
24
  export const genColors = (colors) => {
25
- return Object.keys(colors).reduce((acc, colorName) => {
26
- const currentColor = colors[colorName];
25
+ return Object.keys(colors).reduce((acc, colorName) => {
26
+ const currentColor = colors[colorName];
27
27
 
28
- return Object.assign(acc, {
29
- [colorName]: genColor(currentColor)
30
- });
31
- }, {});
28
+ return Object.assign(acc, {
29
+ [colorName]: genColor(currentColor),
30
+ });
31
+ }, {});
32
32
  };
@@ -1,4 +1,3 @@
1
-
2
1
  class ComponentsThemeManager {
3
2
  static mountOnPropName = 'DescopeThemeManager';
4
3
 
@@ -9,8 +8,8 @@ class ComponentsThemeManager {
9
8
  #callbacks = new Set();
10
9
 
11
10
  #notify() {
12
- this.#callbacks.forEach(cb => cb?.());
13
- };
11
+ this.#callbacks.forEach((cb) => cb?.());
12
+ }
14
13
 
15
14
  get currentThemeName() {
16
15
  return this.#currentThemeName;
@@ -28,8 +27,10 @@ class ComponentsThemeManager {
28
27
  onCurrentThemeChange(cb) {
29
28
  this.#callbacks.add(cb);
30
29
 
31
- return () => { this.#callbacks.delete(cb); };
32
- };
30
+ return () => {
31
+ this.#callbacks.delete(cb);
32
+ };
33
+ }
33
34
 
34
35
  set themes(themes) {
35
36
  this.#themes = themes;
@@ -37,4 +38,4 @@ class ComponentsThemeManager {
37
38
  }
38
39
  }
39
40
 
40
- export const componentsThemeManager = new ComponentsThemeManager()
41
+ export const componentsThemeManager = new ComponentsThemeManager();
@@ -7,160 +7,150 @@ import { getComponentName, getCssVarName } from '../componentHelpers';
7
7
  const getVarName = (path) => getCssVarName(DESCOPE_PREFIX, ...path);
8
8
 
9
9
  const transformTheme = (theme, path, getTransformation) => {
10
- return Object.entries(theme).reduce((acc, [key, val]) => {
11
- if (val?.constructor !== Object) {
12
- return merge(acc, getTransformation(path.concat(key), val));
13
- } else {
14
- return merge(acc, transformTheme(val, [...path, key], getTransformation));
15
- }
16
- }, {});
10
+ return Object.entries(theme).reduce((acc, [key, val]) => {
11
+ if (val?.constructor !== Object) {
12
+ return merge(acc, getTransformation(path.concat(key), val));
13
+ }
14
+ return merge(acc, transformTheme(val, [...path, key], getTransformation));
15
+ }, {});
17
16
  };
18
17
 
19
18
  const stringifyArray = (strArr) =>
20
- strArr.map((str) => (str.includes(' ') ? `"${str}"` : str)).join(', ');
19
+ strArr.map((str) => (str.includes(' ') ? `"${str}"` : str)).join(', ');
21
20
 
22
21
  const getCssVarValue = (val) => {
23
- switch (true) {
24
- case Array.isArray(val):
25
- return stringifyArray(val)
26
- case isUrl(val):
27
- return `url(${val})`
28
- default:
29
- return val
30
- }
31
- }
22
+ switch (true) {
23
+ case Array.isArray(val):
24
+ return stringifyArray(val);
25
+ case isUrl(val):
26
+ return `url(${val})`;
27
+ default:
28
+ return val;
29
+ }
30
+ };
32
31
 
33
32
  export const themeToCSSVarsObj = (theme) =>
34
- transformTheme(theme, [], (path, val) => ({
35
- [getVarName(path)]: getCssVarValue(val)
36
- }));
33
+ transformTheme(theme, [], (path, val) => ({
34
+ [getVarName(path)]: getCssVarValue(val),
35
+ }));
37
36
 
38
37
  export const getThemeRefs = (theme, prefix) =>
39
- transformTheme(theme, [], (path) =>
40
- set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`)
41
- );
38
+ transformTheme(theme, [], (path) =>
39
+ set({}, path, `var(${getVarName(prefix ? [prefix, ...path] : path)})`)
40
+ );
42
41
 
43
42
  export const getThemeVars = (theme, prefix) =>
44
- transformTheme(theme, [], (path) =>
45
- set({}, path, getVarName(prefix ? [prefix, ...path] : path))
46
- );
43
+ transformTheme(theme, [], (path) => set({}, path, getVarName(prefix ? [prefix, ...path] : path)));
47
44
 
48
45
  export const globalsThemeToStyle = (theme, themeName = '') => {
49
- const style = Object.entries(themeToCSSVarsObj(theme)).reduce(
50
- (acc, entry) => (acc += `${entry.join(':')};\n`),
51
- ''
52
- );
46
+ const style = Object.entries(themeToCSSVarsObj(theme)).reduce(
47
+ (acc, entry) => `${acc}${entry.join(':')};\n`,
48
+ ''
49
+ );
53
50
 
54
- if (!themeName) return style
51
+ if (!themeName) return style;
55
52
 
56
- return `*[data-theme="${themeName}"] {${style}}`
53
+ return `*[data-theme="${themeName}"] {${style}}`;
57
54
  };
58
55
 
59
56
  const componentsThemeToStyleObj = (componentsTheme) =>
60
- transformTheme(componentsTheme, [], (path, val) => {
61
- const [component, ...restPath] = path;
62
- const property = restPath.pop();
63
- const componentName = getComponentName(component);
64
-
65
- if (property === 'undefined') {
66
- console.warn(componentName, `theme value: "${val}" is mapped to an invalid property`)
67
- }
68
-
69
- // we need a support for portal components theme (e.g. overlay)
70
- // this allows us to generate those themes under different sections
71
- // if the theme has root level attribute that starts with #
72
- // we are generating a new theme
73
- let themeName = BASE_THEME_SECTION
74
-
75
- if (restPath[0] && restPath[0].startsWith(PORTAL_THEME_PREFIX)) {
76
- themeName = restPath.shift();
77
- }
78
-
79
- // do not start with underscore -> key:value, must have 2 no underscore attrs in a row
80
- // starts with underscore -> attribute selector
81
- const attrsSelector = restPath.reduce((acc, section, idx) => {
82
- if (section.startsWith('_'))
83
- return (acc += `[${kebabCase(section.replace(/^_/, ''))}="true"]`);
84
-
85
- const nextSection = restPath[idx + 1];
86
-
87
- if (typeof nextSection !== 'string' || nextSection.startsWith('_')) {
88
- console.error(
89
- 'theme generator',
90
- `your theme structure is invalid, attribute "${section}" is followed by "${nextSection}" which is not allowed`
91
- );
92
- return acc;
93
- }
94
-
95
- return (acc += `[${kebabCase(section)}="${restPath
96
- .splice(idx + 1, 1)
97
- .join('')}"]`);
98
- }, '');
99
-
100
- let selector = `:host${attrsSelector ? `(${attrsSelector})` : ''}`;
101
-
102
- return {
103
- [componentName]: {
104
- [themeName]: {
105
- [selector]: {
106
- [property]: getCssVarValue(val)
107
- }
108
- }
109
- }
110
- };
111
- });
57
+ transformTheme(componentsTheme, [], (path, val) => {
58
+ const [component, ...restPath] = path;
59
+ const property = restPath.pop();
60
+ const componentName = getComponentName(component);
61
+
62
+ if (property === 'undefined') {
63
+ // eslint-disable-next-line no-console
64
+ console.warn(componentName, `theme value: "${val}" is mapped to an invalid property`);
65
+ }
66
+
67
+ // we need a support for portal components theme (e.g. overlay)
68
+ // this allows us to generate those themes under different sections
69
+ // if the theme has root level attribute that starts with #
70
+ // we are generating a new theme
71
+ let themeName = BASE_THEME_SECTION;
72
+
73
+ if (restPath[0] && restPath[0].startsWith(PORTAL_THEME_PREFIX)) {
74
+ themeName = restPath.shift();
75
+ }
76
+
77
+ // do not start with underscore -> key:value, must have 2 no underscore attrs in a row
78
+ // starts with underscore -> attribute selector
79
+ const attrsSelector = restPath.reduce((acc, section, idx) => {
80
+ if (section.startsWith('_')) return `${acc}[${kebabCase(section.replace(/^_/, ''))}="true"]`;
81
+
82
+ const nextSection = restPath[idx + 1];
83
+
84
+ if (typeof nextSection !== 'string' || nextSection.startsWith('_')) {
85
+ // eslint-disable-next-line no-console
86
+ console.error(
87
+ 'theme generator',
88
+ `your theme structure is invalid, attribute "${section}" is followed by "${nextSection}" which is not allowed`
89
+ );
90
+ return acc;
91
+ }
92
+
93
+ return `${acc}[${kebabCase(section)}="${restPath.splice(idx + 1, 1).join('')}"]`;
94
+ }, '');
95
+
96
+ const selector = `:host${attrsSelector ? `(${attrsSelector})` : ''}`;
97
+
98
+ return {
99
+ [componentName]: {
100
+ [themeName]: {
101
+ [selector]: {
102
+ [property]: getCssVarValue(val),
103
+ },
104
+ },
105
+ },
106
+ };
107
+ });
112
108
 
109
+ const componentsThemeToStyle = (componentsTheme) =>
110
+ Object.entries(componentsTheme).reduce(
111
+ (acc, [selector, vars]) =>
112
+ `${acc}${selector} { \n${Object.entries(vars)
113
+ .map(([key, val]) => `${key}: ${val}`)
114
+ .join(';\n')} \n}\n\n`,
115
+ ''
116
+ );
113
117
 
114
118
  export const createComponentsTheme = (componentsTheme) => {
115
- const styleObj = componentsThemeToStyleObj(componentsTheme);
116
-
117
- return Object.keys(styleObj).reduce(
118
- (acc, componentName) => {
119
- const componentThemes = styleObj[componentName];
120
-
121
- return Object.assign(acc, {
122
- [componentName]: Object.keys(componentThemes)
123
- .reduce((acc, theme) =>
124
- Object.assign(acc, { [theme]: componentsThemeToStyle(componentThemes[theme]) }),
125
- {})
126
- })
127
- },
128
- {}
129
- );
130
- }
131
-
132
- const componentsThemeToStyle = (componentsTheme) =>
133
- Object.entries(componentsTheme).reduce(
134
- (acc, [selector, vars]) =>
135
- (acc += `${selector} { \n${Object.entries(
136
- vars
137
- )
138
- .map(([key, val]) => `${key}: ${val}`)
139
- .join(';\n')} \n}\n\n`),
140
- ''
141
- );
119
+ const styleObj = componentsThemeToStyleObj(componentsTheme);
120
+
121
+ return Object.keys(styleObj).reduce((acc, componentName) => {
122
+ const componentThemes = styleObj[componentName];
123
+
124
+ return Object.assign(acc, {
125
+ [componentName]: Object.keys(componentThemes).reduce(
126
+ (res, theme) =>
127
+ Object.assign(res, { [theme]: componentsThemeToStyle(componentThemes[theme]) }),
128
+ {}
129
+ ),
130
+ });
131
+ }, {});
132
+ };
142
133
 
143
134
  export const themeToStyle = ({ globals, components }, themeName) => ({
144
- globals: globalsThemeToStyle(globals, themeName),
145
- components: createComponentsTheme(components)
135
+ globals: globalsThemeToStyle(globals, themeName),
136
+ components: createComponentsTheme(components),
146
137
  });
147
138
 
148
139
  const useVar = (varName) => `var(${varName})`;
149
140
 
150
141
  export const createHelperVars = (theme, prefix) => {
151
- const res = transformTheme(theme, [], (path, value) => {
152
- const modifiedPath = [...path];
153
- const property = modifiedPath.splice(-1);
154
- const varName = getCssVarName(prefix, property);
142
+ const res = transformTheme(theme, [], (path, value) => {
143
+ const modifiedPath = [...path];
144
+ const property = modifiedPath.splice(-1);
145
+ const varName = getCssVarName(prefix, property);
155
146
 
156
- const vars = { [property]: varName };
157
- const theme = set({}, [...modifiedPath, varName], value);
158
- const useVars = { [property]: useVar(varName) };
147
+ const vars = { [property]: varName };
148
+ const useVars = { [property]: useVar(varName) };
159
149
 
160
- return { theme, useVars, vars };
161
- });
150
+ return { theme: set({}, [...modifiedPath, varName], value), useVars, vars };
151
+ });
162
152
 
163
- return [res.theme, res.useVars, res.vars];
153
+ return [res.theme, res.useVars, res.vars];
164
154
  };
165
155
 
166
- export { componentsThemeManager } from './componentsThemeManager'
156
+ export { componentsThemeManager } from './componentsThemeManager';
@@ -1,22 +1,10 @@
1
- export const resetInputOverrides = (name, cssVarList) => `
2
- ${resetInputContainer(name)}
3
- ${resetInputCursor(name)}
4
- ${resetInputPlaceholder(name)}
5
- ${resetInputField(name)}
6
- ${resetInputAutoFill(name, cssVarList)}
7
- ${resetInputFieldInvalidBackgroundColor(name)}
8
- ${resetInitialHeight(name)}
9
- ${resetInputElement(name)}
10
- ${resetInputFieldunderlayingBorder(name)}
11
- `;
12
-
13
1
  export const useHostExternalPadding = (cssVarList) => `
14
2
  :host {
15
- padding: calc(var(${cssVarList.inputOutlineWidth}) + var(${cssVarList.inputOutlineOffset}))
3
+ padding: calc(var(${cssVarList.inputOutlineWidth}) + var(${cssVarList.inputOutlineOffset}))
16
4
  }
17
5
  `;
18
6
 
19
- export const resetInputFieldunderlayingBorder = (name) => `
7
+ export const resetInputFieldUnderlayingBorder = (name) => `
20
8
  ${name}::part(input-field)::after {
21
9
  border: none;
22
10
  }
@@ -66,7 +54,7 @@ export const resetInputPlaceholder = (name, ele = 'input') => `
66
54
  ${name}[disabled] > ${ele}:placeholder-shown,
67
55
  ${name}[readonly] > ${ele}:placeholder-shown {
68
56
  opacity: 1;
69
- }
57
+ }
70
58
  `;
71
59
 
72
60
  export const resetInputAutoFill = (name, cssVarList) => `
@@ -77,7 +65,7 @@ export const resetInputAutoFill = (name, cssVarList) => `
77
65
  ${name} input:-webkit-autofill:focus {
78
66
  -webkit-text-fill-color: var(${cssVarList.inputValueTextColor});
79
67
  box-shadow: 0 0 0 var(${cssVarList.inputHeight}) var(${cssVarList.inputBackgroundColor}) inset;
80
- }
68
+ }
81
69
  `;
82
70
 
83
71
  export const resetInputFieldDefaultWidth = () => `
@@ -98,3 +86,15 @@ export const resetInputFieldInvalidBackgroundColor = (name) => `
98
86
  background: none;
99
87
  }
100
88
  `;
89
+
90
+ export const resetInputOverrides = (name, cssVarList) => `
91
+ ${resetInputContainer(name)}
92
+ ${resetInputCursor(name)}
93
+ ${resetInputPlaceholder(name)}
94
+ ${resetInputField(name)}
95
+ ${resetInputAutoFill(name, cssVarList)}
96
+ ${resetInputFieldInvalidBackgroundColor(name)}
97
+ ${resetInitialHeight(name)}
98
+ ${resetInputElement(name)}
99
+ ${resetInputFieldUnderlayingBorder(name)}
100
+ `;
package/src/index.cjs.js CHANGED
@@ -4,8 +4,8 @@ export * from './helpers/themeHelpers';
4
4
  export * from './helpers/themeHelpers/colorsHelpers';
5
5
  export { defaultTheme, themeVars } from './theme';
6
6
 
7
- export { CheckboxClass } from './components/boolean-fields/descope-checkbox/CheckboxClass'
8
- export { SwitchToggleClass } from './components/boolean-fields/descope-switch-toggle/SwitchToggleClass'
7
+ export { CheckboxClass } from './components/boolean-fields/descope-checkbox/CheckboxClass';
8
+ export { SwitchToggleClass } from './components/boolean-fields/descope-switch-toggle/SwitchToggleClass';
9
9
  export { ButtonClass } from './components/descope-button/ButtonClass';
10
10
  export { LoaderLinearClass } from './components/descope-loader-linear/LoaderLinearClass';
11
11
  export { LoaderRadialClass } from './components/descope-loader-radial/LoaderRadialClass';
@@ -23,4 +23,4 @@ export { TextAreaClass } from './components/descope-text-area/TextAreaClass';
23
23
  export { TextFieldClass } from './components/descope-text-field/TextFieldClass';
24
24
  export { ImageClass } from './components/descope-image/ImageClass';
25
25
  export { PhoneFieldClass } from './components/descope-phone-field/PhoneFieldClass';
26
- export { NewPasswordClass } from './components/descope-new-password/NewPasswordClass';
26
+ export { NewPasswordClass } from './components/descope-new-password/NewPasswordClass';
package/src/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  declare module '@descope/web-components-ui';
2
2
 
3
3
  export {
4
- globalsThemeToStyle,
5
- createComponentsTheme,
6
- themeToStyle,
7
- componentsThemeManager
4
+ globalsThemeToStyle,
5
+ createComponentsTheme,
6
+ themeToStyle,
7
+ componentsThemeManager,
8
8
  } from './helpers/themeHelpers';
9
9
  export { genColor } from './helpers/themeHelpers/colorsHelpers';
10
10
  export { defaultTheme, themeVars } from './theme';
@@ -29,23 +29,24 @@ export { TextFieldClass } from './components/descope-text-field';
29
29
  export { ImageClass } from './components/descope-image';
30
30
  export { PhoneFieldClass } from './components/descope-phone-field';
31
31
  export { NewPasswordClass } from './components/descope-new-password';
32
+ export { UploadFileClass } from './components/descope-upload-file';
32
33
 
33
34
  export type Theme = {
34
- globals: {
35
- colors: Record<string, string>;
36
- fonts: Record<string, any>;
37
- typography: Record<string, any>;
38
- shadow: Record<string, string>;
39
- spacing: Record<string, string>;
40
- };
41
- components: {
42
- button: Record<string, any>;
43
- textField: Record<string, any>;
44
- logo: Record<string, any>;
45
- container: Record<string, any>;
46
- link: Record<string, any>;
47
- button: Record<string, any>;
48
- text: Record<string, any>;
49
- inputWrapper: Record<string, any>;
50
- };
35
+ globals: {
36
+ colors: Record<string, string>;
37
+ fonts: Record<string, any>;
38
+ typography: Record<string, any>;
39
+ shadow: Record<string, string>;
40
+ spacing: Record<string, string>;
41
+ };
42
+ components: {
43
+ button: Record<string, any>;
44
+ textField: Record<string, any>;
45
+ logo: Record<string, any>;
46
+ container: Record<string, any>;
47
+ link: Record<string, any>;
48
+ button: Record<string, any>;
49
+ text: Record<string, any>;
50
+ inputWrapper: Record<string, any>;
51
+ };
51
52
  };
package/src/index.js CHANGED
@@ -19,12 +19,13 @@ export * from './components/descope-text-field';
19
19
  export * from './components/descope-image';
20
20
  export * from './components/descope-phone-field';
21
21
  export * from './components/descope-new-password';
22
+ export * from './components/descope-upload-file';
22
23
 
23
24
  export {
24
- globalsThemeToStyle,
25
- createComponentsTheme,
26
- themeToStyle,
27
- componentsThemeManager
25
+ globalsThemeToStyle,
26
+ createComponentsTheme,
27
+ themeToStyle,
28
+ componentsThemeManager,
28
29
  } from './helpers/themeHelpers';
29
30
  export { genColor } from './helpers/themeHelpers/colorsHelpers';
30
31
  export { defaultTheme, themeVars } from './theme';
package/src/index.umd.js CHANGED
@@ -1,25 +1,26 @@
1
- const { componentsThemeManager } = require("./helpers/themeHelpers/componentsThemeManager");
1
+ const { componentsThemeManager } = require('./helpers/themeHelpers/componentsThemeManager');
2
2
 
3
3
  const components = import.meta.webpackContext('./components', {
4
- recursive: true,
5
- regExp: /index.js$/,
6
- mode: 'lazy',
7
- chunkName: '[request]',
8
- prefetch: true
4
+ recursive: true,
5
+ regExp: /index.js$/,
6
+ mode: 'lazy',
7
+ chunkName: '[request]',
8
+ prefetch: true,
9
9
  });
10
10
 
11
11
  // all components must be in a folder with the component name, and have an index.js file
12
12
  // e.g. ./descope-button/index.js
13
13
  module.exports = components.keys().reduce((acc, key) => {
14
- const componentName = key.replace(/.*?([^\/]+)\/index\.js$/, '$1');
14
+ // eslint-disable-next-line no-useless-escape
15
+ const componentName = key.replace(/.*?([^\/]+)\/index\.js$/, '$1');
15
16
 
16
- if (componentName.endsWith('-internal')) {
17
- return acc;
18
- }
17
+ if (componentName.endsWith('-internal')) {
18
+ return acc;
19
+ }
19
20
 
20
- acc[componentName] = () => components(key);
21
+ acc[componentName] = () => components(key);
21
22
 
22
- return acc;
23
+ return acc;
23
24
  }, {});
24
25
 
25
- module.exports.componentsThemeManager = componentsThemeManager
26
+ module.exports.componentsThemeManager = componentsThemeManager;
@@ -1,21 +1,22 @@
1
- import { createDispatchEvent } from "../helpers/mixinsHelpers";
1
+ import { createDispatchEvent } from '../helpers/mixinsHelpers';
2
2
 
3
- export const changeMixin = (superclass) => class ChangeMixinClass extends superclass {
4
- #dispatchChange = createDispatchEvent.bind(this, 'change')
3
+ export const changeMixin = (superclass) =>
4
+ class ChangeMixinClass extends superclass {
5
+ #dispatchChange = createDispatchEvent.bind(this, 'change');
5
6
 
6
- init() {
7
- super.init?.();
8
- this.prevValue = this.value
7
+ init() {
8
+ super.init?.();
9
+ this.prevValue = this.value;
9
10
 
10
- this.addEventListener('change', (e) => {
11
- e.stopPropagation();
12
- })
11
+ this.addEventListener('change', (e) => {
12
+ e.stopPropagation();
13
+ });
13
14
 
14
- this.addEventListener('blur', () => {
15
- if (this.value !== this.prevValue) {
16
- this.#dispatchChange()
17
- this.prevValue = this.value
18
- }
19
- })
20
- }
21
- }
15
+ this.addEventListener('blur', () => {
16
+ if (this.value !== this.prevValue) {
17
+ this.#dispatchChange();
18
+ this.prevValue = this.value;
19
+ }
20
+ });
21
+ }
22
+ };