@descope/web-components-ui 1.0.418 → 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 (233) hide show
  1. package/dist/cjs/index.cjs.js +1439 -1355
  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-alert/AlertClass.js +1 -1
  152. package/src/components/descope-apps-list/AppsListClass.js +1 -1
  153. package/src/components/descope-apps-list/index.js +2 -2
  154. package/src/components/descope-divider/DividerClass.js +1 -1
  155. package/src/components/descope-divider/index.js +1 -1
  156. package/src/components/descope-link/LinkClass.js +1 -1
  157. package/src/components/descope-link/index.js +1 -1
  158. package/src/components/descope-security-questions-verify/SecurityQuestionsVerifyClass.js +1 -1
  159. package/src/components/descope-security-questions-verify/index.js +1 -1
  160. package/src/components/descope-user-attribute/UserAttributeClass.js +1 -1
  161. package/src/components/descope-user-attribute/index.js +1 -1
  162. package/src/components/descope-user-auth-method/UserAuthMethodClass.js +1 -1
  163. package/src/components/descope-user-auth-method/index.js +1 -1
  164. package/src/components/mapping-fields/descope-mappings-field/MappingsFieldClass.js +1 -1
  165. package/src/components/mapping-fields/descope-mappings-field/index.js +1 -1
  166. package/src/helpers/themeHelpers/index.js +1 -1
  167. package/src/index.cjs.js +2 -2
  168. package/src/index.d.ts +0 -2
  169. package/src/index.js +2 -2
  170. package/src/index.umd.js +3 -1
  171. package/src/mixins/createStyleMixin/index.js +1 -1
  172. package/src/theme/components/alert.js +1 -1
  173. package/src/theme/components/comboBox.js +2 -2
  174. package/src/theme/components/enrichedText.js +1 -1
  175. package/src/theme/components/index.js +2 -2
  176. package/dist/umd/1033.js +0 -2
  177. package/dist/umd/1414.js +0 -352
  178. package/dist/umd/1437.js +0 -422
  179. package/dist/umd/1672.js +0 -1
  180. package/dist/umd/2566.js +0 -2
  181. package/dist/umd/2838.js +0 -2
  182. package/dist/umd/2838.js.LICENSE.txt +0 -1
  183. package/dist/umd/286.js +0 -148
  184. package/dist/umd/2919.js +0 -832
  185. package/dist/umd/3222.js +0 -282
  186. package/dist/umd/3607.js +0 -2
  187. package/dist/umd/3711.js +0 -123
  188. package/dist/umd/5412.js +0 -109
  189. package/dist/umd/650.js +0 -1
  190. package/dist/umd/6726.js +0 -148
  191. package/dist/umd/7407.js +0 -450
  192. package/dist/umd/8980.js +0 -143
  193. package/dist/umd/8980.js.LICENSE.txt +0 -29
  194. package/dist/umd/9632.js +0 -275
  195. package/dist/umd/9878.js +0 -1
  196. package/dist/umd/9895.js +0 -17
  197. package/dist/umd/DescopeDev.js.LICENSE.txt +0 -1
  198. package/dist/umd/bcdfe87ae253c2cf789c9a737f8d8c22.woff +0 -0
  199. package/dist/umd/descope-avatar-index-js.js +0 -1
  200. package/dist/umd/descope-text-index-js.js +0 -1
  201. /package/dist/umd/{1414.js.LICENSE.txt → 1172.js.LICENSE.txt} +0 -0
  202. /package/dist/umd/{1437.js.LICENSE.txt → 1396.js.LICENSE.txt} +0 -0
  203. /package/dist/umd/{6726.js.LICENSE.txt → 1484.js.LICENSE.txt} +0 -0
  204. /package/dist/umd/{286.js.LICENSE.txt → 189.js.LICENSE.txt} +0 -0
  205. /package/dist/umd/{6637.js.LICENSE.txt → 201.js.LICENSE.txt} +0 -0
  206. /package/dist/umd/{1053.js.LICENSE.txt → 2159.js.LICENSE.txt} +0 -0
  207. /package/dist/umd/{351.js.LICENSE.txt → 2570.js.LICENSE.txt} +0 -0
  208. /package/dist/umd/{5026.js.LICENSE.txt → 2666.js.LICENSE.txt} +0 -0
  209. /package/dist/umd/{9632.js.LICENSE.txt → 3110.js.LICENSE.txt} +0 -0
  210. /package/dist/umd/{9167.js.LICENSE.txt → 3191.js.LICENSE.txt} +0 -0
  211. /package/dist/umd/{1033.js.LICENSE.txt → 3437.js.LICENSE.txt} +0 -0
  212. /package/dist/umd/{6418.js.LICENSE.txt → 3638.js.LICENSE.txt} +0 -0
  213. /package/dist/umd/{7212.js.LICENSE.txt → 404.js.LICENSE.txt} +0 -0
  214. /package/dist/umd/{3711.js.LICENSE.txt → 4114.js.LICENSE.txt} +0 -0
  215. /package/dist/umd/{7607.js.LICENSE.txt → 4127.js.LICENSE.txt} +0 -0
  216. /package/dist/umd/{3607.js.LICENSE.txt → 4187.js.LICENSE.txt} +0 -0
  217. /package/dist/umd/{3222.js.LICENSE.txt → 4218.js.LICENSE.txt} +0 -0
  218. /package/dist/umd/{5086.js.LICENSE.txt → 4455.js.LICENSE.txt} +0 -0
  219. /package/dist/umd/{5273.js.LICENSE.txt → 4554.js.LICENSE.txt} +0 -0
  220. /package/dist/umd/{4834.js.LICENSE.txt → 4574.js.LICENSE.txt} +0 -0
  221. /package/dist/umd/{9895.js.LICENSE.txt → 4902.js.LICENSE.txt} +0 -0
  222. /package/dist/umd/{5443.js.LICENSE.txt → 507.js.LICENSE.txt} +0 -0
  223. /package/dist/umd/{5412.js.LICENSE.txt → 5096.js.LICENSE.txt} +0 -0
  224. /package/dist/umd/{8164.js.LICENSE.txt → 5563.js.LICENSE.txt} +0 -0
  225. /package/dist/umd/{7407.js.LICENSE.txt → 7097.js.LICENSE.txt} +0 -0
  226. /package/dist/umd/{2919.js.LICENSE.txt → 731.js.LICENSE.txt} +0 -0
  227. /package/dist/umd/{2566.js.LICENSE.txt → 742.js.LICENSE.txt} +0 -0
  228. /package/dist/umd/{7824.js.LICENSE.txt → 7979.js.LICENSE.txt} +0 -0
  229. /package/dist/umd/{6474.js.LICENSE.txt → 9030.js.LICENSE.txt} +0 -0
  230. /package/dist/umd/{8162.js.LICENSE.txt → 9478.js.LICENSE.txt} +0 -0
  231. /package/{src/helpers → node_modules/common/src}/themeHelpers/componentsThemeManager.js +0 -0
  232. /package/{src/components/descope-avatar → node_modules/descope-avatar/src/component}/index.js +0 -0
  233. /package/{src/components/descope-text → node_modules/descope-text/src/component}/index.js +0 -0
@@ -0,0 +1,242 @@
1
+ /* eslint-disable no-param-reassign */
2
+ import { compose } from '../../utils';
3
+ import { forwardAttrs, getComponentName } from '../../componentsHelpers';
4
+ import { createDispatchEvent } from '../helpers/mixinsHelpers';
5
+ import { inputValidationMixin } from '../mixins/inputValidationMixin';
6
+ import { createStyleMixin } from '../mixins/createStyleMixin';
7
+
8
+ const errorAttrs = ['invalid', 'required'];
9
+
10
+ const forwardProps = (src, targets, property) => {
11
+ const targetArr = Array.isArray(targets) ? targets : [targets];
12
+
13
+ Object.defineProperty(src, property, {
14
+ set(v) {
15
+ targetArr.forEach((target) => {
16
+ target[property] = v;
17
+ });
18
+ },
19
+ get() {
20
+ return targets[0][property];
21
+ },
22
+ configurable: true,
23
+ });
24
+ };
25
+
26
+ // recursively take the first slot child until it finds an element which is not a slot
27
+ // stops after "nestingLevel" times
28
+ const getNestedInput = (ele) => {
29
+ if (!ele) return undefined;
30
+
31
+ const nestingLevel = 10;
32
+
33
+ let nonSlotEle = ele;
34
+ for (let i = 0; i < nestingLevel; i++) {
35
+ [nonSlotEle] = nonSlotEle.assignedElements();
36
+ if (nonSlotEle?.localName !== 'slot') return nonSlotEle;
37
+ }
38
+ return undefined;
39
+ };
40
+
41
+ const proxyInputMixin =
42
+ ({
43
+ proxyProps = [],
44
+ // useProxyTargets flag allows to forwardProps to other targets, other than
45
+ // `this.inputElement`. It's to be used within `external-input` components,
46
+ // if needed
47
+ useProxyTargets = false,
48
+ // allows us to set the event that should trigger validation
49
+ // it can be either a string or an array of strings (for multiple events)
50
+ inputEvent = 'input',
51
+ triggerValidationEvents = [],
52
+ // Proxies all validations from the parent component to the input element
53
+ proxyParentValidation = false,
54
+ }) =>
55
+ (superclass) =>
56
+ class ProxyInputMixinClass extends inputValidationMixin(superclass) {
57
+ static get observedAttributes() {
58
+ return [...(superclass.observedAttributes || []), ...errorAttrs];
59
+ }
60
+
61
+ #inputElement;
62
+
63
+ #dispatchChange = createDispatchEvent.bind(this, 'change');
64
+
65
+ constructor() {
66
+ super();
67
+
68
+ this.#inputElement = super.inputElement;
69
+ }
70
+
71
+ // the web-component does not loaded immediately, so we want to defer the warning
72
+ // and show it only if the input element was not found after the component is loaded
73
+ warnIfInputElementIsMissing() {
74
+ clearTimeout(this.inputElementTimerId);
75
+
76
+ this.inputElementTimerId = setTimeout(() => {
77
+ // eslint-disable-next-line no-console
78
+ !this.#inputElement && console.warn(this.localName, 'no input was found');
79
+ }, 0);
80
+ }
81
+
82
+ get inputElement() {
83
+ if (this.#inputElement) return this.#inputElement;
84
+
85
+ this.warnIfInputElementIsMissing();
86
+
87
+ const inputSlot = this.baseElement.shadowRoot?.querySelector('slot[name="input"]');
88
+ const textAreaSlot = this.baseElement.shadowRoot?.querySelector('slot[name="textarea"]');
89
+
90
+ this.#inputElement = getNestedInput(inputSlot) || getNestedInput(textAreaSlot);
91
+
92
+ return this.#inputElement;
93
+ }
94
+
95
+ set inputElement(ele) {
96
+ this.#inputElement = ele;
97
+ }
98
+
99
+ getValidity() {
100
+ return this.inputElement?.validity || {};
101
+ }
102
+
103
+ #handleErrorMessage() {
104
+ this.setAttribute('error-message', this.validationMessage);
105
+ }
106
+
107
+ // We do not want to show the default validity report tooltip
108
+ // So we are overriding the reportValidity fn to show the input's error message
109
+ reportValidity = () => {
110
+ // we want to update validity so in case the value was set programmatically, we won't get an error
111
+ this.inputElement.setCustomValidity('');
112
+ this.setCustomValidity('');
113
+ if (!this.checkValidity()) {
114
+ this.setAttribute('invalid', 'true');
115
+ this.#handleErrorMessage();
116
+ this.focus();
117
+ }
118
+ };
119
+
120
+ // we are keeping also the default reportValidity because there are some components that still using it
121
+ defaultReportValidity() {
122
+ return super.reportValidity();
123
+ }
124
+
125
+ init() {
126
+ super.init?.();
127
+
128
+ // vaadin sets invalid indication on blur
129
+ // we want invalid indication to appear only when calling reportValidity
130
+ // this is why we are overriding vaadin's setInvalid behavior
131
+ // to update only when the element is valid (so invalid indication will only be removed)
132
+ // and we are adding it in reportValidity
133
+ // eslint-disable-next-line func-names
134
+ this.baseElement._setInvalid = function (invalid) {
135
+ if (!invalid && this._shouldSetInvalid(invalid)) {
136
+ this.invalid = invalid;
137
+ }
138
+ };
139
+
140
+ // We want to ensure that `input` events properly cross ShadowDOM boundries
141
+ // e.g. When we autofill a component's input with 1Password, for instance,
142
+ // the event is fired without `composed: true` and doesn't our component's
143
+ // ShadowDOM.
144
+ this.baseElement.addEventListener('input', (e) => {
145
+ if (!e.composed) {
146
+ this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
147
+ }
148
+ });
149
+
150
+ triggerValidationEvents.forEach((e) => {
151
+ this.baseElement?.addEventListener(e, () => {
152
+ this.inputElement?.setCustomValidity('');
153
+ });
154
+ });
155
+
156
+ // on some cases the base element is not ready so the inputElement is empty
157
+ // we are deferring this section to make sure the base element is ready
158
+ setTimeout(() => {
159
+ const validationEvents = Array.isArray(inputEvent) ? inputEvent : [inputEvent];
160
+
161
+ validationEvents.forEach((e) => {
162
+ this.baseElement?.addEventListener(e, () => {
163
+ if (!this.baseElement.checkValidity()) {
164
+ this.#handleErrorMessage();
165
+ } else {
166
+ this.removeAttribute('invalid');
167
+ }
168
+ });
169
+ });
170
+
171
+ this.baseElement.addEventListener('change', () => {
172
+ this.#dispatchChange();
173
+ });
174
+
175
+ this.addEventListener('invalid', () => {
176
+ if (!this.checkValidity()) {
177
+ this.setAttribute('invalid', 'true');
178
+ }
179
+ this.#handleErrorMessage();
180
+ });
181
+
182
+ // sync properties
183
+ proxyProps.forEach((prop) => {
184
+ const externalInput = this.querySelector('input[slot="external-input"]') || null;
185
+ const proxyTargets = useProxyTargets
186
+ ? [this.baseElement, externalInput].filter(Boolean)
187
+ : [];
188
+ forwardProps(this, [this.inputElement, ...proxyTargets], prop);
189
+ });
190
+
191
+ this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
192
+
193
+ forwardAttrs(this, this.inputElement, { includeAttrs: ['inputmode'] });
194
+ });
195
+
196
+ if (proxyParentValidation) {
197
+ // All functions called on the inputElement internals will be applied to the parent
198
+ // component internals as well. As a result, there's no need to add outer mechanisms
199
+ // to update the parent component's validity state based on the input elements validity.
200
+ const inputElementInternals = this.inputElement.internals;
201
+ const parentThis = this;
202
+ this.inputElement.internals = new Proxy(inputElementInternals, {
203
+ get: (target, prop) => {
204
+ if (typeof target[prop] === 'function' && prop === 'setValidity') {
205
+ return (...args) => {
206
+ // If we're calling setValidity with 3 args, then the validationTarget
207
+ // needs to be swapped to be the inputElement
208
+ if (args.length === 3) {
209
+ const newArgs = args.slice(0, args.length - 1);
210
+ newArgs.push(parentThis.inputElement);
211
+ parentThis.internals[prop](...newArgs);
212
+ } else {
213
+ parentThis.internals[prop](...args);
214
+ }
215
+ return target[prop](...args);
216
+ };
217
+ }
218
+
219
+ if (typeof target[prop] === 'function') {
220
+ return (...args) => {
221
+ parentThis.internals[prop](...args);
222
+ return target[prop](...args);
223
+ };
224
+ }
225
+
226
+ return target[prop];
227
+ },
228
+ });
229
+ }
230
+ }
231
+ };
232
+
233
+ const composedProxyInputMixin = (proxyInputMixinConfig) =>
234
+ compose(
235
+ proxyInputMixin(proxyInputMixinConfig),
236
+ // in order to use input-wrapper across all our input components, we need to inject its theme
237
+ // to every proxy input mixin, to allow its css vars to be scoped properly and accessible
238
+ // in the proxy input component
239
+ createStyleMixin({ componentNameOverride: getComponentName('input-wrapper') })
240
+ );
241
+
242
+ export { composedProxyInputMixin as proxyInputMixin };
@@ -0,0 +1,4 @@
1
+ export const DESCOPE_PREFIX = 'descope';
2
+ export const CSS_SELECTOR_SPECIFIER_MULTIPLY = 3;
3
+ export const BASE_THEME_SECTION = 'host';
4
+ export const PORTAL_THEME_PREFIX = '@';
@@ -0,0 +1 @@
1
+ export default `data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjZTIxZDEyIiB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIA0KCSB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAzMC4zMzQgMzAuMzM0Ig0KCSB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxwYXRoIGQ9Ik0xNS4xNjcsMEM2LjgwNSwwLDAuMDAxLDYuODA0LDAuMDAxLDE1LjE2N2MwLDguMzYyLDYuODA0LDE1LjE2NywxNS4xNjYsMTUuMTY3YzguMzYxLDAsMTUuMTY2LTYuODA1LDE1LjE2Ni0xNS4xNjcNCgkJQzMwLjMzMyw2LjgwNCwyMy41MjgsMCwxNS4xNjcsMHogTTE3LjE2NywyNS42NjdoLTR2LTQuNWg0VjI1LjY2N3ogTTE3LjE2NywxOS41NDJoLTRWNS4xNjdoNFYxOS41NDJ6Ii8+DQo8L2c+DQo8L3N2Zz4=`;
@@ -0,0 +1,302 @@
1
+ import errorMessageIconBase64 from './icons/errorMessageIconBase64';
2
+
3
+ export const labelControl = {
4
+ label: {
5
+ name: 'Label',
6
+ control: { type: 'text' },
7
+ },
8
+ };
9
+
10
+ export const helperTextControl = {
11
+ 'helper-text': {
12
+ name: 'Helper Text',
13
+ control: { type: 'text' },
14
+ },
15
+ };
16
+
17
+ export const placeholderControl = {
18
+ placeholder: {
19
+ name: 'Placeholder',
20
+ control: { type: 'text' },
21
+ },
22
+ };
23
+
24
+ export const sizeControl = {
25
+ size: {
26
+ name: 'Size',
27
+ options: ['xs', 'sm', 'md', 'lg'],
28
+ control: { type: 'select' },
29
+ },
30
+ };
31
+
32
+ export const loadingControl = {
33
+ loading: {
34
+ name: 'Loading',
35
+ control: { type: 'boolean' },
36
+ },
37
+ };
38
+
39
+ export const fullWidthControl = {
40
+ 'full-width': {
41
+ name: 'Full Width',
42
+ control: { type: 'boolean' },
43
+ },
44
+ };
45
+
46
+ export const disabledControl = {
47
+ disabled: {
48
+ name: 'Disabled',
49
+ control: { type: 'boolean' },
50
+ },
51
+ };
52
+
53
+ export const readOnlyControl = {
54
+ readonly: {
55
+ name: 'Read Only',
56
+ control: { type: 'boolean' },
57
+ },
58
+ };
59
+
60
+ export const requiredControl = {
61
+ required: {
62
+ name: 'Required',
63
+ control: { type: 'boolean' },
64
+ },
65
+ };
66
+
67
+ export const directionControl = {
68
+ direction: {
69
+ name: 'Direction',
70
+ options: ['ltr', 'rtl'],
71
+ control: { type: 'select' },
72
+ },
73
+ };
74
+
75
+ export const borderedControl = {
76
+ bordered: {
77
+ name: 'Bordered',
78
+ control: { type: 'boolean' },
79
+ },
80
+ };
81
+
82
+ export const minLengthControl = {
83
+ minlength: {
84
+ name: 'Min. Length',
85
+ control: { type: 'text' },
86
+ },
87
+ };
88
+
89
+ export const maxLengthControl = {
90
+ maxlength: {
91
+ name: 'Max. Length',
92
+ control: { type: 'text' },
93
+ },
94
+ };
95
+
96
+ export const textContentControl = {
97
+ text: {
98
+ name: 'Content',
99
+ control: { type: 'text' },
100
+ },
101
+ };
102
+
103
+ export const modeControl = {
104
+ mode: {
105
+ name: 'Mode',
106
+ options: ['none', 'primary', 'secondary', 'success', 'error'],
107
+ control: { type: 'select' },
108
+ },
109
+ };
110
+
111
+ export const textAlignControl = {
112
+ 'text-align': {
113
+ name: 'Text Align',
114
+ options: ['left', 'center', 'right'],
115
+ control: { type: 'select' },
116
+ },
117
+ };
118
+
119
+ export const errorMissingValueControl = {
120
+ 'data-errormessage-value-missing': {
121
+ name: 'Custom Error: Mandatory',
122
+ control: { type: 'text' },
123
+ },
124
+ };
125
+
126
+ export const errorPatternMismatchControl = {
127
+ 'data-errormessage-pattern-mismatch': {
128
+ name: 'Custom Error: Pattern Mismatch',
129
+ control: { type: 'text' },
130
+ },
131
+ };
132
+
133
+ export const errorTypeMismatchControl = {
134
+ 'data-errormessage-type-mismatch': {
135
+ name: 'Custom Error: Type Mismatch',
136
+ control: { type: 'text' },
137
+ },
138
+ };
139
+
140
+ export const errorBadInputControl = {
141
+ 'data-errormessage-bad-input': {
142
+ name: 'Custom Error: Bad Input',
143
+ control: { type: 'text' },
144
+ },
145
+ };
146
+
147
+ export const errorRangeUnderflowControl = {
148
+ 'data-errormessage-range-underflow': {
149
+ name: 'Custom Error: Below minimum value',
150
+ control: { type: 'text' },
151
+ },
152
+ };
153
+
154
+ export const errorRangeOverflowControl = {
155
+ 'data-errormessage-range-overflow': {
156
+ name: 'Custom Error: Exceeds maximum value',
157
+ control: { type: 'text' },
158
+ },
159
+ };
160
+
161
+ export const fillControl = {
162
+ 'st-fill': {
163
+ name: 'Fill',
164
+ control: { type: 'color' },
165
+ },
166
+ };
167
+
168
+ export const customHeightControl = {
169
+ 'st-host-height': {
170
+ name: 'Custom Height',
171
+ control: { type: 'text' },
172
+ },
173
+ };
174
+
175
+ export const customWidthControl = {
176
+ 'st-host-width': {
177
+ name: 'Custom Width',
178
+ control: { type: 'text' },
179
+ },
180
+ };
181
+
182
+ export const checkboxValueControl = {
183
+ checked: {
184
+ name: 'Checked',
185
+ control: { type: 'boolean' },
186
+ },
187
+ };
188
+
189
+ export const buttonVariantControl = {
190
+ variant: {
191
+ name: 'Button Variant',
192
+ options: ['contained', 'outline', 'link'],
193
+ control: { type: 'select' },
194
+ },
195
+ };
196
+
197
+ export const boxShadowControl = {
198
+ shadow: {
199
+ name: 'Shadow',
200
+ options: ['sm', 'md', 'lg', 'xl', '2xl'],
201
+ control: { type: 'select' },
202
+ },
203
+ };
204
+
205
+ export const borderRadiusControl = {
206
+ 'border-radius': {
207
+ name: 'Radius',
208
+ options: ['sm', 'md', 'lg', 'xl', '2xl', '3xl'],
209
+ control: { type: 'select' },
210
+ },
211
+ };
212
+
213
+ export const imgSrcControl = {
214
+ src: {
215
+ name: 'Image Source',
216
+ control: { type: 'text' },
217
+ },
218
+ };
219
+
220
+ export const typographyVariantControl = {
221
+ variant: {
222
+ name: 'Variant',
223
+ options: ['h1', 'h2', 'h3', 'subtitle1', 'subtitle2', 'body1', 'body2'],
224
+ control: { type: 'select' },
225
+ },
226
+ };
227
+
228
+ export const overrideRenderItemControl = {
229
+ overrideRenderItem: {
230
+ name: 'Override the default item renderer function',
231
+ control: { type: 'boolean' },
232
+ },
233
+ };
234
+
235
+ export const itemsSourceControl = {
236
+ itemsSource: {
237
+ name: 'Where to take the items from',
238
+ control: {
239
+ type: 'select',
240
+ options: {
241
+ Children: 'children',
242
+ '"data" attribute': 'attr',
243
+ '"data" property': 'prop',
244
+ },
245
+ },
246
+ },
247
+ };
248
+
249
+ export const minItemsSelectionControl = {
250
+ minItemsSelection: {
251
+ name: 'Min Items Selection',
252
+ control: { type: 'number' },
253
+ },
254
+ };
255
+
256
+ export const maxItemsSelectionControl = {
257
+ maxItemsSelection: {
258
+ name: 'Max Items Selection',
259
+ control: { type: 'number' },
260
+ },
261
+ };
262
+
263
+ export const labelSpacingControl = {
264
+ 'label-spacing': {
265
+ name: 'Label Spacing',
266
+ control: { type: 'range', min: 0, max: 200, step: 1 },
267
+ },
268
+ };
269
+
270
+ export const inputLabelTypeControl = {
271
+ 'label-type': {
272
+ name: 'Label Type',
273
+ control: {
274
+ type: 'select',
275
+ options: ['static', 'floating'],
276
+ },
277
+ },
278
+ };
279
+
280
+ export const inputCopyToClipboardControl = {
281
+ 'copy-to-clipboard': {
282
+ name: 'Copy to clipboard',
283
+ control: {
284
+ type: 'boolean',
285
+ },
286
+ },
287
+ };
288
+
289
+ export const errorMessageIconControl = {
290
+ errorMsgIcon: {
291
+ name: 'Error Message Icon',
292
+ control: {
293
+ type: 'boolean',
294
+ },
295
+ },
296
+ };
297
+
298
+ export const errorMessageIconAttrs = `
299
+ st-error-message-icon="url(${errorMessageIconBase64})"
300
+ st-error-message-icon-size="14px"
301
+ st-error-message-icon-padding="1.5em"
302
+ `;
@@ -0,0 +1,94 @@
1
+ import Color from 'color';
2
+
3
+ const colorGaps = {
4
+ darkLight: 0.4,
5
+ highlight: 0.8,
6
+ contrast: 1,
7
+ edgeColor: {
8
+ darkLight: 0.25,
9
+ highlight: 0.1,
10
+ },
11
+ };
12
+
13
+ const darken = (c, percentage) => c.darken(percentage).hex();
14
+
15
+ const contrast = (c) => {
16
+ const isDark = c.isDark();
17
+ return c
18
+ .mix(Color(isDark ? 'white' : 'black'), colorGaps.contrast)
19
+ .saturate(1)
20
+ .hex();
21
+ };
22
+
23
+ const lighten = (c, percentage) => {
24
+ const isDark = c.lightness() < 0.5;
25
+
26
+ if (isDark) {
27
+ return c.lightness(percentage * 100).hex();
28
+ }
29
+
30
+ return c.lighten(percentage).hex();
31
+ };
32
+
33
+ const isNearBlack = (color) => color.luminosity() < 0.01;
34
+ const isNearWhite = (color) => color.luminosity() > 0.99;
35
+
36
+ const generateDarkColor = (color, theme) => {
37
+ if (theme === 'dark') {
38
+ return isNearWhite(color)
39
+ ? darken(color, colorGaps.edgeColor.darkLight)
40
+ : lighten(color, colorGaps.darkLight);
41
+ }
42
+
43
+ return isNearBlack(color)
44
+ ? lighten(color, colorGaps.edgeColor.darkLight)
45
+ : darken(color, colorGaps.darkLight);
46
+ };
47
+
48
+ const generateLightColor = (color, theme) => {
49
+ if (theme === 'dark') {
50
+ return isNearBlack(color)
51
+ ? lighten(color, colorGaps.edgeColor.darkLight)
52
+ : darken(color, colorGaps.darkLight);
53
+ }
54
+
55
+ return isNearWhite(color)
56
+ ? darken(color, colorGaps.edgeColor.darkLight)
57
+ : lighten(color, colorGaps.darkLight);
58
+ };
59
+
60
+ const generateHighlightColor = (color, theme) => {
61
+ if (theme === 'dark') {
62
+ return isNearBlack(color)
63
+ ? lighten(color, colorGaps.edgeColor.highlight)
64
+ : darken(color, colorGaps.highlight);
65
+ }
66
+
67
+ return isNearWhite(color)
68
+ ? darken(color, colorGaps.edgeColor.highlight)
69
+ : lighten(color, colorGaps.highlight);
70
+ };
71
+
72
+ export const genColor = (color, theme) => {
73
+ const mainColor = new Color(color.main || color);
74
+
75
+ const res = {
76
+ main: mainColor.hex(),
77
+ dark: color.dark || generateDarkColor(mainColor, theme),
78
+ light: color.light || generateLightColor(mainColor, theme),
79
+ highlight: color.highlight || generateHighlightColor(mainColor, theme),
80
+ contrast: color.contrast || contrast(mainColor),
81
+ };
82
+
83
+ return res;
84
+ };
85
+
86
+ export const genColors = (colors) => {
87
+ return Object.keys(colors).reduce((acc, colorName) => {
88
+ const currentColor = colors[colorName];
89
+
90
+ return Object.assign(acc, {
91
+ [colorName]: genColor(currentColor),
92
+ });
93
+ }, {});
94
+ };