@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,4 +1,4 @@
1
- import { observeAttributes } from "../helpers/componentHelpers";
1
+ import { observeAttributes } from '../helpers/componentHelpers';
2
2
 
3
3
  const booleanAttributesList = [
4
4
  'readonly',
@@ -16,31 +16,39 @@ const booleanAttributesList = [
16
16
  'focus-ring',
17
17
  'opened',
18
18
  'active',
19
- 'password-visible'
20
- ]
19
+ 'password-visible',
20
+ ];
21
21
 
22
22
  const isBooleanAttribute = (attr) => {
23
- return booleanAttributesList.includes(attr)
24
- }
23
+ return booleanAttributesList.includes(attr);
24
+ };
25
25
  // we want all the valueless attributes to have "true" value
26
26
  // and all the falsy attribute to be removed
27
- export const normalizeBooleanAttributesMixin = (superclass) => class NormalizeBooleanAttributesMixinClass extends superclass {
28
- init() {
29
- super.init?.();
27
+ export const normalizeBooleanAttributesMixin = (superclass) =>
28
+ class NormalizeBooleanAttributesMixinClass extends superclass {
29
+ init() {
30
+ super.init?.();
30
31
 
31
- observeAttributes(this, (attrs) =>
32
- attrs.forEach(attr => {
33
- const attrVal = this.getAttribute(attr)
32
+ observeAttributes(
33
+ this,
34
+ (attrs) =>
35
+ attrs.forEach((attr) => {
36
+ const attrVal = this.getAttribute(attr);
34
37
 
35
- if (isBooleanAttribute(attr)) {
36
- if (attrVal === '') {
37
- this.setAttribute(attr, 'true')
38
- } else if (attrVal === 'false') {
39
- this.removeAttribute(attr)
40
- }
41
- } else if (!attrVal) {
42
- console.warn(`attribute "${attr}" has no value, should it be added to the boolean attributes list?`)
43
- }
44
- }), {})
45
- }
46
- }
38
+ if (isBooleanAttribute(attr)) {
39
+ if (attrVal === '') {
40
+ this.setAttribute(attr, 'true');
41
+ } else if (attrVal === 'false') {
42
+ this.removeAttribute(attr);
43
+ }
44
+ } else if (!attrVal) {
45
+ // eslint-disable-next-line no-console
46
+ console.warn(
47
+ `attribute "${attr}" has no value, should it be added to the boolean attributes list?`
48
+ );
49
+ }
50
+ }),
51
+ {}
52
+ );
53
+ }
54
+ };
@@ -1,71 +1,77 @@
1
- import { PORTAL_THEME_PREFIX } from "../constants";
2
- import { kebabCaseJoin, upperFirst } from "../helpers";
3
- import { forwardAttrs } from "../helpers/componentHelpers";
4
- import { createStyleMixin } from "./createStyleMixin";
5
- import { createCssVarsList } from "./createStyleMixin/helpers";
1
+ import { PORTAL_THEME_PREFIX } from '../constants';
2
+ import { kebabCaseJoin } from '../helpers';
3
+ import { forwardAttrs } from '../helpers/componentHelpers';
4
+ import { createStyleMixin } from './createStyleMixin';
5
+ import { createCssVarsList } from './createStyleMixin/helpers';
6
6
 
7
7
  // this is needed because we might generate the same css vars names
8
- // e.g. "overlayColor" attribute in style mixin's mapping,
9
- // will generate the same var as "color" attribute in portals's mapping
8
+ // e.g. "overlayColor" attribute in style mixin's mapping,
9
+ // will generate the same var as "color" attribute in portals's mapping
10
10
  // when the portal name is "overlay".
11
11
  // because of that, we are adding this separator that is also used as a differentiator
12
- const DISPLAY_NAME_SEPARATOR = '_'
12
+ const DISPLAY_NAME_SEPARATOR = '_';
13
13
 
14
14
  const sanitizeSelector = (selector) => selector.replace(/[^\w\s]/gi, '');
15
15
 
16
16
  const getDomNode = (maybeDomNode) => maybeDomNode.host || maybeDomNode;
17
17
 
18
- export const portalMixin = ({
19
- name,
20
- selector,
21
- mappings = {},
22
- forward: { attributes = [], include = true } = {}
23
- }) => (superclass) => {
24
- const eleDisplayName = name || sanitizeSelector(selector)
18
+ export const portalMixin =
19
+ ({ name, selector, mappings = {}, forward: { attributes = [], include = true } = {} }) =>
20
+ (superclass) => {
21
+ const eleDisplayName = name || sanitizeSelector(selector);
25
22
 
26
- const BaseClass = createStyleMixin({
27
- mappings
28
- })(superclass)
23
+ const BaseClass = createStyleMixin({
24
+ mappings,
25
+ })(superclass);
29
26
 
30
- return class PortalMixinClass extends BaseClass {
31
- static get cssVarList() {
32
- return {
33
- ...BaseClass.cssVarList,
34
- [eleDisplayName]: createCssVarsList(kebabCaseJoin(superclass.componentName, DISPLAY_NAME_SEPARATOR + eleDisplayName), mappings)
35
- };
36
- }
27
+ return class PortalMixinClass extends BaseClass {
28
+ static get cssVarList() {
29
+ return {
30
+ ...BaseClass.cssVarList,
31
+ [eleDisplayName]: createCssVarsList(
32
+ kebabCaseJoin(superclass.componentName, DISPLAY_NAME_SEPARATOR + eleDisplayName),
33
+ mappings
34
+ ),
35
+ };
36
+ }
37
37
 
38
- #portalEle
38
+ #portalEle;
39
39
 
40
- constructor() {
41
- // we cannot use "this" before calling "super"
42
- const getRootElement = (that) => {
43
- const baseEle = that.shadowRoot.querySelector(that.baseSelector)
44
- const portal = selector ? baseEle.shadowRoot.querySelector(selector) : baseEle
40
+ constructor() {
41
+ // we cannot use "this" before calling "super"
42
+ const getRootElement = (that) => {
43
+ const baseEle = that.shadowRoot.querySelector(that.baseSelector);
44
+ const portal = selector ? baseEle.shadowRoot.querySelector(selector) : baseEle;
45
45
 
46
- return portal.shadowRoot || portal
47
- };
46
+ return portal.shadowRoot || portal;
47
+ };
48
48
 
49
- super({
50
- getRootElement,
51
- componentNameSuffix: DISPLAY_NAME_SEPARATOR + eleDisplayName,
52
- themeSection: PORTAL_THEME_PREFIX + eleDisplayName,
53
- baseSelector: ':host'
54
- })
49
+ super({
50
+ getRootElement,
51
+ componentNameSuffix: DISPLAY_NAME_SEPARATOR + eleDisplayName,
52
+ themeSection: PORTAL_THEME_PREFIX + eleDisplayName,
53
+ baseSelector: ':host',
54
+ });
55
55
 
56
- this.#portalEle = getDomNode(getRootElement(this))
57
- }
56
+ this.#portalEle = getDomNode(getRootElement(this));
57
+ }
58
58
 
59
- #handleHoverAttribute() {
60
- this.#portalEle.onmouseenter = (e) => { e.target.setAttribute('hover', 'true') }
61
- this.#portalEle.onmouseleave = (e) => { e.target.removeAttribute('hover') }
62
- }
59
+ #handleHoverAttribute() {
60
+ this.#portalEle.onmouseenter = (e) => {
61
+ e.target.setAttribute('hover', 'true');
62
+ };
63
+ this.#portalEle.onmouseleave = (e) => {
64
+ e.target.removeAttribute('hover');
65
+ };
66
+ }
63
67
 
64
- init() {
65
- super.init?.();
66
- forwardAttrs(this, this.#portalEle, { [include ? 'includeAttrs' : 'excludeAttrs']: attributes })
68
+ init() {
69
+ super.init?.();
70
+ forwardAttrs(this, this.#portalEle, {
71
+ [include ? 'includeAttrs' : 'excludeAttrs']: attributes,
72
+ });
67
73
 
68
- this.#handleHoverAttribute();
69
- }
70
- }
71
- }
74
+ this.#handleHoverAttribute();
75
+ }
76
+ };
77
+ };
@@ -1,148 +1,154 @@
1
- import { compose } from "../helpers";
2
- import { forwardAttrs, getComponentName } from "../helpers/componentHelpers";
3
- import { createDispatchEvent } from "../helpers/mixinsHelpers";
4
- import { createStyleMixin } from "./createStyleMixin";
5
- import { inputValidationMixin } from "./inputValidationMixin";
1
+ /* eslint-disable no-param-reassign */
2
+ import { compose } from '../helpers';
3
+ import { forwardAttrs, getComponentName } from '../helpers/componentHelpers';
4
+ import { createDispatchEvent } from '../helpers/mixinsHelpers';
5
+ import { createStyleMixin } from './createStyleMixin';
6
+ import { inputValidationMixin } from './inputValidationMixin';
6
7
 
7
8
  const errorAttrs = ['invalid', 'required'];
8
9
 
9
10
  const propertyObserver = (src, target, property) => {
10
- Object.defineProperty(src, property, {
11
- set: function (v) {
12
- return (target[property] = v);
13
- },
14
- get: function () {
15
- return target[property];
16
- },
17
- configurable: true
18
- });
11
+ Object.defineProperty(src, property, {
12
+ set(v) {
13
+ target[property] = v;
14
+ },
15
+ get() {
16
+ return target[property];
17
+ },
18
+ configurable: true,
19
+ });
19
20
  };
20
21
 
21
22
  // recursively take the first slot child until it finds an element which is not a slot
22
23
  // stops after "nestingLevel" times
23
24
  const getNestedInput = (ele) => {
24
- if (!ele) return;
25
+ if (!ele) return undefined;
25
26
 
26
- const nestingLevel = 10
27
+ const nestingLevel = 10;
27
28
 
28
- let nonSlotEle = ele
29
- for (let i = 0; i < nestingLevel; i++) {
30
- nonSlotEle = nonSlotEle.assignedElements()[0]
31
- if (nonSlotEle.localName !== 'slot') return nonSlotEle
32
- }
33
- }
29
+ let nonSlotEle = ele;
30
+ for (let i = 0; i < nestingLevel; i++) {
31
+ [nonSlotEle] = nonSlotEle.assignedElements();
32
+ if (nonSlotEle.localName !== 'slot') return nonSlotEle;
33
+ }
34
+ return undefined;
35
+ };
34
36
 
35
37
  const proxyInputMixin = (superclass) =>
36
- class ProxyInputMixinClass extends inputValidationMixin(superclass) {
37
- static get observedAttributes() {
38
- return [...superclass.observedAttributes || [], ...errorAttrs];
39
- }
40
-
41
- #inputElement
42
-
43
- #dispatchChange = createDispatchEvent.bind(this, 'change')
44
-
45
- constructor() {
46
- super();
47
-
48
- this.#inputElement = super.inputElement
49
- }
50
-
51
- // the web-component does not loaded immediately, so we want to defer the warning
52
- // and show it only if the input element was not found after the component is loaded
53
- warnIfInputElementIsMissing() {
54
- clearTimeout(this.inputElementTimerId)
55
-
56
- this.inputElementTimerId = setTimeout(() => {
57
- !this.#inputElement && console.warn(this.localName, 'no input was found');
58
- }, 0)
59
- }
60
-
61
- get name () {
62
- return this.getAttribute('name');
63
- }
64
-
65
- get inputElement() {
66
- this.warnIfInputElementIsMissing()
67
-
68
- const inputSlot = this.baseElement.shadowRoot?.querySelector('slot[name="input"]')
69
- const textAreaSlot = this.baseElement.shadowRoot?.querySelector('slot[name="textarea"]')
70
-
71
- this.#inputElement ??= getNestedInput(inputSlot) || getNestedInput(textAreaSlot)
72
-
73
- return this.#inputElement
74
- }
75
-
76
- set inputElement(ele) {
77
- this.#inputElement = ele
78
- }
79
-
80
- getValidity() {
81
- return this.inputElement?.validity || {}
82
- }
38
+ class ProxyInputMixinClass extends inputValidationMixin(superclass) {
39
+ static get observedAttributes() {
40
+ return [...(superclass.observedAttributes || []), ...errorAttrs];
41
+ }
42
+
43
+ #inputElement;
44
+
45
+ #dispatchChange = createDispatchEvent.bind(this, 'change');
46
+
47
+ constructor() {
48
+ super();
49
+
50
+ this.#inputElement = super.inputElement;
51
+ }
52
+
53
+ // the web-component does not loaded immediately, so we want to defer the warning
54
+ // and show it only if the input element was not found after the component is loaded
55
+ warnIfInputElementIsMissing() {
56
+ clearTimeout(this.inputElementTimerId);
57
+
58
+ this.inputElementTimerId = setTimeout(() => {
59
+ // eslint-disable-next-line no-console
60
+ !this.#inputElement && console.warn(this.localName, 'no input was found');
61
+ }, 0);
62
+ }
63
+
64
+ get name() {
65
+ return this.getAttribute('name');
66
+ }
67
+
68
+ get inputElement() {
69
+ this.warnIfInputElementIsMissing();
70
+
71
+ const inputSlot = this.baseElement.shadowRoot?.querySelector('slot[name="input"]');
72
+ const textAreaSlot = this.baseElement.shadowRoot?.querySelector('slot[name="textarea"]');
73
+
74
+ this.#inputElement ??= getNestedInput(inputSlot) || getNestedInput(textAreaSlot);
75
+
76
+ return this.#inputElement;
77
+ }
78
+
79
+ set inputElement(ele) {
80
+ this.#inputElement = ele;
81
+ }
82
+
83
+ getValidity() {
84
+ return this.inputElement?.validity || {};
85
+ }
86
+
87
+ handleInternalInputErrorMessage() {
88
+ if (!this.inputElement.checkValidity()) {
89
+ this.inputElement.setCustomValidity(this.validationMessage);
90
+ }
91
+ }
92
+
93
+ #handleErrorMessage() {
94
+ this.handleInternalInputErrorMessage();
95
+ this.setAttribute('error-message', this.validationMessage);
96
+ }
97
+
98
+ init() {
99
+ super.init?.();
100
+
101
+ this.inputElement.addEventListener('input', (e) => {
102
+ if (!this.inputElement.checkValidity()) {
103
+ this.inputElement.setCustomValidity('');
104
+ // after updating the input validity we want to trigger set validity on the wrapping element
105
+ // so we will get the updated validity
106
+ this.setCustomValidity('');
107
+
108
+ // Vaadin is getting the input event before us,
109
+ // so in order to make sure they use the updated validity
110
+ // we calling their fn after updating the input validity
111
+ this.baseElement.__onInput(e);
112
+
113
+ this.#handleErrorMessage();
114
+ }
115
+ });
116
+
117
+ this.baseElement.addEventListener('change', () => {
118
+ this.#dispatchChange();
119
+ });
120
+
121
+ this.#inputElement.addEventListener('blur', () => {
122
+ if (!this.checkValidity()) {
123
+ this.setAttribute('invalid', 'true');
124
+ this.#handleErrorMessage();
125
+ }
126
+ });
127
+
128
+ this.addEventListener('invalid', () => {
129
+ if (!this.checkValidity()) {
130
+ this.setAttribute('invalid', 'true');
131
+ }
132
+ this.#handleErrorMessage();
133
+ });
134
+
135
+ this.handleInternalInputErrorMessage();
136
+
137
+ // sync properties
138
+ propertyObserver(this, this.inputElement, 'value');
139
+ propertyObserver(this, this.inputElement, 'selectionStart');
140
+ this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
83
141
 
84
- handleInternalInputErrorMessage() {
85
- if (!this.inputElement.checkValidity()) {
86
- this.inputElement.setCustomValidity(this.validationMessage)
87
- }
88
- }
89
-
90
- #handleErrorMessage() {
91
- this.handleInternalInputErrorMessage()
92
- this.setAttribute('error-message', this.validationMessage)
93
- }
94
-
95
- init() {
96
- super.init?.();
97
-
98
- this.inputElement.addEventListener('input', (e) => {
99
- if (!this.inputElement.checkValidity()) {
100
- this.inputElement.setCustomValidity('')
101
- // after updating the input validity we want to trigger set validity on the wrapping element
102
- // so we will get the updated validity
103
- this.setCustomValidity('')
104
-
105
- // Vaadin is getting the input event before us,
106
- // so in order to make sure they use the updated validity
107
- // we calling their fn after updating the input validity
108
- this.baseElement.__onInput(e)
109
-
110
- this.#handleErrorMessage()
111
- }
112
- })
113
-
114
- this.baseElement.addEventListener('change', () => {
115
- this.#dispatchChange()
116
- })
117
-
118
- this.#inputElement.addEventListener('blur', () => {
119
- if (!this.checkValidity()) {
120
- this.setAttribute('invalid', 'true')
121
- this.#handleErrorMessage()
122
- }
123
- })
124
-
125
-
126
- this.addEventListener('invalid', () => {
127
- if (!this.checkValidity()) {
128
- this.setAttribute('invalid', 'true');
129
- }
130
- this.#handleErrorMessage()
131
- })
132
-
133
- this.handleInternalInputErrorMessage();
134
-
135
- // sync properties
136
- propertyObserver(this, this.inputElement, 'value');
137
- propertyObserver(this, this.inputElement, 'selectionStart');
138
- this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
139
-
140
- forwardAttrs(this, this.inputElement, { includeAttrs: ['inputmode'] })
141
- }
142
- };
142
+ forwardAttrs(this, this.inputElement, { includeAttrs: ['inputmode'] });
143
+ }
144
+ };
143
145
 
144
146
  const composedProxyInputMixin = compose(
145
- proxyInputMixin,
146
- createStyleMixin({ componentNameOverride: getComponentName('input-wrapper') }))
147
-
148
- export { composedProxyInputMixin as proxyInputMixin }
147
+ proxyInputMixin,
148
+ // in order to use input-wrapper across all our input components, we need to inject its theme
149
+ // to every proxy input mixin, to allow its css vars to be scoped properly and accessible
150
+ // in the proxy input component
151
+ createStyleMixin({ componentNameOverride: getComponentName('input-wrapper') })
152
+ );
153
+
154
+ export { composedProxyInputMixin as proxyInputMixin };
@@ -6,11 +6,11 @@ const globalRefs = getThemeRefs(globals);
6
6
  const compVars = ButtonClass.cssVarList;
7
7
 
8
8
  const mode = {
9
- primary: globalRefs.colors.primary,
10
- secondary: globalRefs.colors.secondary,
11
- success: globalRefs.colors.success,
12
- error: globalRefs.colors.error,
13
- surface: globalRefs.colors.surface
9
+ primary: globalRefs.colors.primary,
10
+ secondary: globalRefs.colors.secondary,
11
+ success: globalRefs.colors.success,
12
+ error: globalRefs.colors.error,
13
+ surface: globalRefs.colors.surface,
14
14
  };
15
15
 
16
16
  const [helperTheme, helperRefs, helperVars] = createHelperVars({ mode }, componentName);
@@ -19,85 +19,90 @@ const verticalPaddingRatio = 3;
19
19
  const horizontalPaddingRatio = 2;
20
20
 
21
21
  const button = {
22
- ...helperTheme,
23
-
24
- [compVars.fontFamily]: globalRefs.fonts.font1.family,
25
-
26
- [compVars.cursor]: 'pointer',
27
-
28
- [compVars.borderRadius]: globalRefs.radius.sm,
29
- [compVars.borderWidth]: '2px',
30
- [compVars.borderStyle]: 'solid',
31
- [compVars.borderColor]: 'transparent',
32
-
33
- [compVars.labelSpacing]: '0.25em',
34
-
35
- [compVars.verticalPadding]: `calc(var(${compVars.fontSize}) / ${verticalPaddingRatio})`,
36
- [compVars.horizontalPadding]: `calc(var(${compVars.fontSize}) / ${horizontalPaddingRatio})`,
37
-
38
- [compVars.outlineWidth]: globals.border.sm,
39
- [compVars.outlineOffset]: '1px',
40
- [compVars.outlineStyle]: 'solid',
41
- [compVars.outlineColor]: 'transparent',
42
-
43
- size: {
44
- xs: { [compVars.fontSize]: '12px' },
45
- sm: { [compVars.fontSize]: '14px' },
46
- md: { [compVars.fontSize]: '16px' },
47
- lg: { [compVars.fontSize]: '18px' }
48
- },
49
-
50
- _fullWidth: {
51
- [compVars.hostWidth]: '100%'
52
- },
53
-
54
- _loading: {
55
- [compVars.cursor]: 'wait'
56
- },
57
-
58
- variant: {
59
- contained: {
60
- [compVars.labelTextColor]: helperRefs.contrast,
61
- [compVars.backgroundColor]: helperRefs.main,
62
- _hover: {
63
- [compVars.backgroundColor]: helperRefs.dark
64
- },
65
- _active: {
66
- [compVars.backgroundColor]: helperRefs.dark
67
- }
68
- },
69
-
70
- outline: {
71
- [compVars.labelTextColor]: helperRefs.main,
72
- [compVars.borderColor]: 'currentColor',
73
- _hover: {
74
- [compVars.labelTextColor]: helperRefs.dark,
75
- },
76
- _active: {
77
- [compVars.labelTextColor]: helperRefs.light,
78
- }
79
- },
80
-
81
- link: {
82
- [compVars.labelTextColor]: helperRefs.main,
83
- _hover: {
84
- [compVars.labelTextColor]: helperRefs.main,
85
- [compVars.labelTextDecoration]: 'underline'
86
- },
87
- _active: {
88
- [compVars.labelTextColor]: helperRefs.dark
89
- }
90
- }
91
- },
92
-
93
- _focused: {
94
- [compVars.outlineColor]: globals.colors.surface.main,
95
- }
22
+ ...helperTheme,
23
+
24
+ [compVars.fontFamily]: globalRefs.fonts.font1.family,
25
+
26
+ [compVars.cursor]: 'pointer',
27
+ [compVars.hostHeight]: '3em',
28
+
29
+ [compVars.borderRadius]: globalRefs.radius.sm,
30
+ [compVars.borderWidth]: globalRefs.border.xs,
31
+ [compVars.borderStyle]: 'solid',
32
+ [compVars.borderColor]: 'transparent',
33
+
34
+ [compVars.labelSpacing]: '0.25em',
35
+
36
+ [compVars.verticalPadding]: `calc(var(${compVars.fontSize}) / ${verticalPaddingRatio})`,
37
+ [compVars.horizontalPadding]: `calc(var(${compVars.fontSize}) / ${horizontalPaddingRatio})`,
38
+
39
+ [compVars.outlineWidth]: globals.border.sm,
40
+ [compVars.outlineOffset]: '0px', // keep `px` unit for external calc
41
+ [compVars.outlineStyle]: 'solid',
42
+ [compVars.outlineColor]: 'transparent',
43
+
44
+ size: {
45
+ xs: { [compVars.fontSize]: '12px' },
46
+ sm: { [compVars.fontSize]: '14px' },
47
+ md: { [compVars.fontSize]: '16px' },
48
+ lg: { [compVars.fontSize]: '18px' },
49
+ },
50
+
51
+ _fullWidth: {
52
+ [compVars.hostWidth]: '100%',
53
+ },
54
+
55
+ _loading: {
56
+ [compVars.cursor]: 'wait',
57
+ [compVars.labelTextColor]: helperRefs.main,
58
+ },
59
+
60
+ variant: {
61
+ contained: {
62
+ [compVars.labelTextColor]: helperRefs.contrast,
63
+ [compVars.backgroundColor]: helperRefs.main,
64
+ _hover: {
65
+ [compVars.backgroundColor]: helperRefs.dark,
66
+ _loading: {
67
+ [compVars.backgroundColor]: helperRefs.main,
68
+ },
69
+ },
70
+ _active: {
71
+ [compVars.backgroundColor]: helperRefs.main,
72
+ },
73
+ },
74
+
75
+ outline: {
76
+ [compVars.labelTextColor]: helperRefs.main,
77
+ [compVars.borderColor]: 'currentColor',
78
+ _hover: {
79
+ [compVars.labelTextColor]: helperRefs.dark,
80
+ },
81
+ _active: {
82
+ [compVars.labelTextColor]: helperRefs.main,
83
+ },
84
+ },
85
+
86
+ link: {
87
+ [compVars.labelTextColor]: helperRefs.main,
88
+ _hover: {
89
+ [compVars.labelTextColor]: helperRefs.dark,
90
+ [compVars.labelTextDecoration]: 'underline',
91
+ },
92
+ _active: {
93
+ [compVars.labelTextColor]: helperRefs.dark,
94
+ },
95
+ },
96
+ },
97
+
98
+ _focused: {
99
+ [compVars.outlineColor]: globalRefs.colors.surface.main,
100
+ },
96
101
  };
97
102
 
98
103
  export default button;
99
104
 
100
105
  export const vars = {
101
- ...compVars,
102
- ...helperVars
106
+ ...compVars,
107
+ ...helperVars,
103
108
  };