@descope/web-components-ui 1.0.61 → 1.0.63

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. package/dist/cjs/index.cjs.js +95 -21
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.esm.js +967 -784
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/umd/447.js +1 -1
  6. package/dist/umd/666.js +37 -0
  7. package/dist/umd/725.js +1 -37
  8. package/dist/umd/descope-button-index-js.js +1 -1
  9. package/dist/umd/descope-checkbox-index-js.js +1 -1
  10. package/dist/umd/descope-container-index-js.js +1 -1
  11. package/dist/umd/descope-date-picker-index-js.js +1 -1
  12. package/dist/umd/descope-divider-index-js.js +1 -1
  13. package/dist/umd/descope-email-field-index-js.js +1 -1
  14. package/dist/umd/descope-link-index-js.js +1 -1
  15. package/dist/umd/descope-loader-linear-index-js.js +1 -1
  16. package/dist/umd/descope-loader-radial-index-js.js +1 -1
  17. package/dist/umd/descope-logo-index-js.js +1 -1
  18. package/dist/umd/descope-number-field-index-js.js +1 -1
  19. package/dist/umd/descope-passcode-descope-passcode-internal-index-js.js +1 -1
  20. package/dist/umd/descope-passcode-index-js.js +1 -1
  21. package/dist/umd/descope-password-field-index-js.js +1 -1
  22. package/dist/umd/descope-switch-toggle-index-js.js +1 -1
  23. package/dist/umd/descope-text-area-index-js.js +1 -1
  24. package/dist/umd/descope-text-field-index-js.js +1 -1
  25. package/dist/umd/descope-text-index-js.js +1 -1
  26. package/dist/umd/index.js +1 -1
  27. package/package.json +1 -1
  28. package/src/baseClasses/BaseInputClass.js +3 -0
  29. package/src/components/descope-button/Button.js +14 -10
  30. package/src/components/descope-checkbox/Checkbox.js +10 -7
  31. package/src/components/descope-container/Container.js +12 -7
  32. package/src/components/descope-date-picker/index.js +3 -3
  33. package/src/components/descope-divider/Divider.js +35 -30
  34. package/src/components/descope-email-field/EmailField.js +5 -5
  35. package/src/components/descope-link/Link.js +19 -27
  36. package/src/components/descope-loader-linear/LoaderLinear.js +12 -7
  37. package/src/components/descope-loader-radial/LoaderRadial.js +5 -5
  38. package/src/components/descope-logo/Logo.js +4 -4
  39. package/src/components/descope-number-field/NumberField.js +5 -5
  40. package/src/components/descope-passcode/Passcode.js +52 -71
  41. package/src/components/descope-passcode/descope-passcode-internal/PasscodeInternal.js +43 -71
  42. package/src/components/descope-password-field/PasswordField.js +5 -5
  43. package/src/components/descope-switch-toggle/SwitchToggle.js +10 -7
  44. package/src/components/descope-text/Text.js +18 -9
  45. package/src/components/descope-text-area/TextArea.js +9 -8
  46. package/src/components/descope-text-field/TextField.js +5 -5
  47. package/src/components/descope-text-field/textFieldMappings.js +3 -5
  48. package/src/constants.js +1 -0
  49. package/src/dev/index.js +2 -2
  50. package/src/{componentsHelpers/createProxy/helpers.js → helpers/componentHelpers.js} +13 -5
  51. package/src/{helpers.js → helpers/index.js} +5 -2
  52. package/src/helpers/themeHelpers/componentsThemeManager.js +40 -0
  53. package/src/{themeHelpers → helpers/themeHelpers}/index.js +56 -21
  54. package/src/index.cjs.js +1 -1
  55. package/src/index.js +5 -5
  56. package/src/index.umd.js +4 -0
  57. package/src/{componentsHelpers/createProxy/index.js → mixins/createProxy.js} +4 -4
  58. package/src/{componentsHelpers → mixins}/createStyleMixin/helpers.js +14 -15
  59. package/src/mixins/createStyleMixin/index.js +109 -0
  60. package/src/mixins/index.js +7 -0
  61. package/src/mixins/inputMixin.js +173 -0
  62. package/src/mixins/proxyInputMixin.js +152 -0
  63. package/src/theme/components/button.js +2 -2
  64. package/src/theme/components/checkbox.js +2 -1
  65. package/src/theme/components/container.js +2 -2
  66. package/src/theme/components/divider.js +17 -9
  67. package/src/theme/components/link.js +1 -1
  68. package/src/theme/components/loader/loaderLinear.js +1 -1
  69. package/src/theme/components/loader/loaderRadial.js +1 -1
  70. package/src/theme/components/text.js +1 -1
  71. package/src/theme/components/textArea.js +2 -1
  72. package/src/theme/components/textField.js +2 -2
  73. package/src/theme/globals.js +3 -3
  74. package/dist/umd/832.js +0 -1
  75. package/dist/umd/942.js +0 -1
  76. package/dist/umd/descope-combo-index-js.js +0 -1
  77. package/src/components/descope-combo/index.js +0 -27
  78. package/src/componentsHelpers/createStyleMixin/index.js +0 -114
  79. package/src/componentsHelpers/enforceNestingElementsStylesMixin.js +0 -95
  80. package/src/componentsHelpers/index.js +0 -15
  81. package/src/componentsHelpers/inputMixin.js +0 -94
  82. /package/dist/umd/{725.js.LICENSE.txt → 666.js.LICENSE.txt} +0 -0
  83. /package/src/{themeHelpers/processColors.js → helpers/themeHelpers/colorsHelpers.js} +0 -0
  84. /package/src/{componentsHelpers → mixins}/componentNameValidationMixin.js +0 -0
  85. /package/src/{componentsHelpers → mixins}/draggableMixin.js +0 -0
  86. /package/src/{componentsHelpers → mixins}/hoverableMixin.js +0 -0
package/src/index.js CHANGED
@@ -2,7 +2,6 @@ import './components/descope-button';
2
2
  import './components/descope-checkbox';
3
3
  import './components/descope-loader-linear';
4
4
  import './components/descope-loader-radial';
5
- import './components/descope-combo';
6
5
  import './components/descope-container';
7
6
  import './components/descope-date-picker';
8
7
  import './components/descope-divider';
@@ -19,8 +18,9 @@ import './components/descope-text-field';
19
18
 
20
19
  export {
21
20
  globalsThemeToStyle,
22
- componentsThemeToStyle,
23
- themeToStyle
24
- } from './themeHelpers';
25
- export { genColor } from './themeHelpers/processColors';
21
+ createComponentsTheme,
22
+ themeToStyle,
23
+ componentsThemeManager
24
+ } from './helpers/themeHelpers';
25
+ export { genColor } from './helpers/themeHelpers/colorsHelpers';
26
26
  export { default as defaultTheme } from './theme';
package/src/index.umd.js CHANGED
@@ -1,3 +1,5 @@
1
+ const { componentsThemeManager } = require("./helpers/themeHelpers/componentsThemeManager");
2
+
1
3
  const components = import.meta.webpackContext('./components', {
2
4
  recursive: true,
3
5
  regExp: /index.js$/,
@@ -14,3 +16,5 @@ module.exports = components.keys().reduce((acc, key) => {
14
16
 
15
17
  return acc;
16
18
  }, {});
19
+
20
+ module.exports.componentsThemeManager = componentsThemeManager
@@ -1,7 +1,7 @@
1
- import { compose } from '..';
2
- import { DescopeBaseClass } from '../../baseClasses/DescopeBaseClass';
3
- import { hoverableMixin } from '../hoverableMixin';
4
- import { syncAttrs, forwardProps } from './helpers';
1
+ import { DescopeBaseClass } from '../baseClasses/DescopeBaseClass';
2
+ import { compose } from '../helpers';
3
+ import { forwardProps, syncAttrs } from '../helpers/componentHelpers';
4
+ import { hoverableMixin } from './hoverableMixin';
5
5
 
6
6
  export const createProxy = ({
7
7
  componentName,
@@ -1,4 +1,5 @@
1
- import { getCssVarName, kebabCase } from '../../helpers';
1
+ import { kebabCase } from '../../helpers';
2
+ import { getCssVarName } from '../../helpers/componentHelpers';
2
3
 
3
4
  const createCssVarFallback = (first, ...rest) =>
4
5
  `var(${first}${rest.length ? ` , ${createCssVarFallback(...rest)}` : ''})`;
@@ -9,11 +10,10 @@ const createCssSelector = (
9
10
  ) =>
10
11
  typeof relativeSelectorOrSelectorFn === 'function'
11
12
  ? relativeSelectorOrSelectorFn(baseSelector)
12
- : `${baseSelector}${
13
- /^[A-Za-z]/.test(relativeSelectorOrSelectorFn)
14
- ? ` ${relativeSelectorOrSelectorFn}`
15
- : relativeSelectorOrSelectorFn
16
- }`;
13
+ : `${baseSelector}${/^[A-Za-z]/.test(relativeSelectorOrSelectorFn)
14
+ ? ` ${relativeSelectorOrSelectorFn}`
15
+ : relativeSelectorOrSelectorFn
16
+ }`;
17
17
 
18
18
  class StyleBuilder {
19
19
  constructor() {
@@ -34,9 +34,9 @@ class StyleBuilder {
34
34
  toString() {
35
35
  return Array.from(this.styleMap.entries()).reduce(
36
36
  (style, [selector, propValArr]) =>
37
- (style += `${selector} { \n${propValArr
38
- .map(({ property, value }) => `${property}: ${value}`)
39
- .join(';\n')} \n}\n\n`),
37
+ (style += `${selector} { \n${propValArr
38
+ .map(({ property, value }) => `${property}: ${value}`)
39
+ .join(';\n')} \n}\n\n`),
40
40
  ''
41
41
  );
42
42
  }
@@ -82,9 +82,8 @@ export const createCssVarsList = (componentName, mappings) =>
82
82
  {}
83
83
  );
84
84
 
85
- // match the host selector with the inner element selector
86
- // e.g. when we want to set the same size for the host & the inner element this can be useful
87
- export const matchHostStyle = (mappingObj = {}) => [
88
- mappingObj,
89
- { ...mappingObj, selector: () => `:host${mappingObj.selector || ''}` }
90
- ];
85
+ // on some cases we need a selector to be more specific than another
86
+ // for this we have this fn that generate a class selector multiple times
87
+ export const createClassSelectorSpecifier = (className, numOfRepeats) => Array(numOfRepeats)
88
+ .fill(`.${className}`)
89
+ .join('')
@@ -0,0 +1,109 @@
1
+ import { CSS_SELECTOR_SPECIFIER_MULTIPLY } from '../../constants';
2
+ import { kebabCaseJoin } from '../../helpers';
3
+ import { getCssVarName } from '../../helpers/componentHelpers';
4
+ import { componentsThemeManager } from '../../helpers/themeHelpers/componentsThemeManager';
5
+ import { createStyle, createCssVarsList, createClassSelectorSpecifier } from './helpers';
6
+
7
+ export const createStyleMixin =
8
+ ({ mappings = {} }) =>
9
+ (superclass) => {
10
+ const styleAttributes = Object.keys(mappings).map((key) =>
11
+ kebabCaseJoin('st', key)
12
+ );
13
+ return class CustomStyleMixinClass extends superclass {
14
+ static get observedAttributes() {
15
+ const superAttrs = superclass.observedAttributes || [];
16
+ return [...superAttrs, ...styleAttributes];
17
+ }
18
+
19
+ static get cssVarList() {
20
+ return createCssVarsList(superclass.componentName, {
21
+ ...mappings,
22
+ });
23
+ }
24
+
25
+ #overrideStyleEle = null;
26
+ #themeStyleEle = null;
27
+ #disconnectThemeManager
28
+
29
+ constructor() {
30
+ super();
31
+
32
+ this.classList.add(superclass.componentName)
33
+
34
+ this.#createComponentStyle();
35
+ this.#createComponentTheme();
36
+ this.#createAttrOverrideStyle();
37
+ }
38
+
39
+ get componentTheme() {
40
+ return componentsThemeManager.currentTheme?.[superclass.componentName] || ''
41
+ }
42
+
43
+ onComponentThemeChange() {
44
+ this.#themeStyleEle.innerHTML = this.componentTheme.theme
45
+ }
46
+
47
+ #createComponentTheme() {
48
+ this.#themeStyleEle = document.createElement('style');
49
+ this.#themeStyleEle.id = 'style-mixin-component-theme';
50
+ this.shadowRoot.prepend(this.#themeStyleEle);
51
+ this.#disconnectThemeManager = componentsThemeManager.onCurrentThemeChange(this.onComponentThemeChange.bind(this))
52
+ this.onComponentThemeChange()
53
+ }
54
+
55
+ #createAttrOverrideStyle() {
56
+ this.#overrideStyleEle = document.createElement('style');
57
+ this.#overrideStyleEle.id = 'style-mixin-overrides';
58
+
59
+ const classSpecifier = createClassSelectorSpecifier(superclass.componentName, CSS_SELECTOR_SPECIFIER_MULTIPLY);
60
+ this.#overrideStyleEle.innerText = `:host(${classSpecifier}) {}`;
61
+ this.shadowRoot.append(this.#overrideStyleEle);
62
+ }
63
+
64
+ #updateAttrOverrideStyle(attrName, value) {
65
+ const style = this.#overrideStyleEle.sheet?.cssRules[0].style;
66
+ const varName = getCssVarName(
67
+ superclass.componentName,
68
+ attrName.replace(/^st-/, '')
69
+ );
70
+
71
+ if (value) style?.setProperty(varName, value);
72
+ else style?.removeProperty(varName);
73
+ }
74
+
75
+ #createComponentStyle() {
76
+ const themeStyle = document.createElement('style');
77
+ themeStyle.id = 'style-mixin-component';
78
+ themeStyle.innerHTML = createStyle(
79
+ superclass.componentName,
80
+ this.baseSelector,
81
+ mappings
82
+ );
83
+ this.shadowRoot.prepend(themeStyle);
84
+ }
85
+
86
+ attributeChangedCallback(attrName, oldValue, newValue) {
87
+ super.attributeChangedCallback?.(attrName, oldValue, newValue);
88
+
89
+ if (styleAttributes.includes(attrName)) {
90
+ this.#updateAttrOverrideStyle(attrName, newValue);
91
+ }
92
+ }
93
+
94
+ connectedCallback() {
95
+ super.connectedCallback?.();
96
+ if (this.shadowRoot.isConnected) {
97
+ Array.from(this.attributes).forEach((attr) => {
98
+ if (styleAttributes.includes(attr.nodeName)) {
99
+ this.#updateAttrOverrideStyle(attr.nodeName, attr.value);
100
+ }
101
+ });
102
+ }
103
+ }
104
+
105
+ disconnectedCallback() {
106
+ this.#disconnectThemeManager?.();
107
+ }
108
+ };
109
+ };
@@ -0,0 +1,7 @@
1
+ export { createStyleMixin } from './createStyleMixin';
2
+ export { draggableMixin } from './draggableMixin';
3
+ export { createProxy } from './createProxy';
4
+ export { proxyInputMixin } from './proxyInputMixin';
5
+ export { componentNameValidationMixin } from './componentNameValidationMixin';
6
+ export { hoverableMixin } from './hoverableMixin';
7
+ export { inputMixin } from './inputMixin'
@@ -0,0 +1,173 @@
1
+
2
+ const upperFirst = (str) => str.charAt(0).toUpperCase() + str.slice(1)
3
+
4
+ const events = [
5
+ 'change',
6
+ 'input',
7
+ 'blur',
8
+ 'focus',
9
+ 'invalid',
10
+ 'valid',
11
+ ]
12
+
13
+ const observedAttributes = [
14
+ 'required',
15
+ 'pattern',
16
+ ]
17
+
18
+ const errorAttributes = {
19
+ valueMissing: 'data-errormessage-value-missing',
20
+ patternMismatch: 'data-errormessage-pattern-mismatch'
21
+ }
22
+ export const inputMixin = (superclass) => class InputMixinClass extends superclass {
23
+ static get observedAttributes() {
24
+ return [
25
+ ...superclass.observedAttributes || [],
26
+ ...observedAttributes
27
+ ];
28
+ }
29
+
30
+ static get formAssociated() {
31
+ return true;
32
+ }
33
+
34
+ #internals
35
+
36
+ constructor() {
37
+ super();
38
+
39
+ this.#internals = this.attachInternals();
40
+
41
+ for (const event of events) {
42
+ this[`dispatch${upperFirst(event)}`] = function () {
43
+ this.dispatchInputEvent(event)
44
+ }
45
+ }
46
+ }
47
+
48
+ get defaultErrorMsgValueMissing() {
49
+ return 'Please fill out this field.'
50
+ }
51
+
52
+ get defaultErrorMsgPatternMismatch() {
53
+ return 'Please match the requested format.'
54
+ }
55
+
56
+ getErrorMessage(flags) {
57
+ switch (true) {
58
+ case flags.valueMissing:
59
+ return this.getAttribute(errorAttributes.valueMissing) ||
60
+ this.defaultErrorMsgValueMissing
61
+ case flags.patternMismatch || flags.typeMismatch:
62
+ return this.getAttribute(errorAttributes.patternMismatch) ||
63
+ this.defaultErrorMsgPatternMismatch
64
+ case flags.customError:
65
+ return this.validationMessage
66
+ default:
67
+ return ''
68
+ }
69
+ }
70
+
71
+ setValidity() {
72
+ const validity = this.getValidity()
73
+ this.#internals.setValidity(validity, this.getErrorMessage(validity))
74
+ }
75
+
76
+ get validationMessage() {
77
+ return this.#internals.validationMessage;
78
+ }
79
+
80
+ getValidity() {
81
+ throw Error('getValidity', 'is not implemented')
82
+ }
83
+
84
+ checkValidity() {
85
+ return this.#internals.validity.valid
86
+ }
87
+
88
+ reportValidity() {
89
+ return this.#internals.reportValidity()
90
+ }
91
+
92
+ get validity() {
93
+ return this.#internals.validity
94
+ }
95
+
96
+ setCustomValidity(errorMessage) {
97
+ if(errorMessage){
98
+ this.#internals.setValidity({customError: true}, errorMessage)
99
+ } else {
100
+ this.#internals.setValidity({})
101
+ this.setValidity()
102
+ }
103
+ }
104
+
105
+ get isRequired() {
106
+ return this.hasAttribute('required') && this.getAttribute('required') !== 'false'
107
+ }
108
+
109
+ get pattern() {
110
+ return this.getAttribute('pattern')
111
+ }
112
+
113
+ get value() {
114
+ throw Error('get value', 'is not implemented')
115
+ }
116
+
117
+ set value(value) {
118
+ throw Error('set value', 'is not implemented')
119
+ }
120
+
121
+ handleFocus() {
122
+ throw Error('handleFocus', 'is not implemented')
123
+ }
124
+
125
+ handleInput() {
126
+ this.setValidity()
127
+ this.handleDispatchValidationEvents()
128
+ }
129
+
130
+ handleBlur() {
131
+ throw Error('handleBlur', 'is not implemented')
132
+ }
133
+
134
+ handleChange() {
135
+ throw Error('handleChange', 'is not implemented')
136
+ }
137
+
138
+ dispatchInputEvent(eventName) {
139
+ this[`on${eventName}`]?.(); // in case we got an event callback as property
140
+ this.dispatchEvent(new InputEvent(eventName));
141
+ }
142
+
143
+ attributeChangedCallback(attrName, oldValue, newValue) {
144
+ super.attributeChangedCallback?.(attrName, oldValue, newValue);
145
+
146
+ if (observedAttributes.includes(attrName)) {
147
+ this.setValidity();
148
+ }
149
+ }
150
+
151
+ handleDispatchValidationEvents(){
152
+ if(this.checkValidity()) {
153
+ this.dispatchValid()
154
+ } else {
155
+ this.dispatchInvalid()
156
+ }
157
+ }
158
+
159
+ connectedCallback() {
160
+ super.connectedCallback?.();
161
+
162
+ this.setValidity();
163
+ this.handleDispatchValidationEvents();
164
+
165
+ // create proxy replace the addEventListener fn
166
+ // and we want to be able to access the focus events
167
+ // of this element and not the nested element's events
168
+ this.onfocus = this.handleFocus.bind(this);
169
+ this.addEventListener('input', this.handleInput.bind(this))
170
+ this.addEventListener('blur', this.handleBlur.bind(this))
171
+ this.addEventListener('change', this.handleBlur.bind(this))
172
+ }
173
+ }
@@ -0,0 +1,152 @@
1
+ import { inputMixin } from "./inputMixin";
2
+
3
+ const errorAttrs = ['invalid', 'has-error-message'];
4
+
5
+ const propertyObserver = (src, target, property) => {
6
+ Object.defineProperty(src, property, {
7
+ set: function (v) {
8
+ return (target[property] = v);
9
+ },
10
+ get: function () {
11
+ return target[property];
12
+ },
13
+ configurable: true
14
+ });
15
+ };
16
+
17
+ // recursively take the first slot child until it finds an element which is not a slot
18
+ // stops after "nestingLevel" times
19
+ const getNestedInput = (ele) => {
20
+ if (!ele) return;
21
+
22
+ const nestingLevel = 10
23
+
24
+ let nonSlotEle = ele
25
+ for (let i = 0; i < nestingLevel; i++) {
26
+ nonSlotEle = nonSlotEle.assignedElements()[0]
27
+ if (nonSlotEle.localName !== 'slot') return nonSlotEle
28
+ }
29
+ }
30
+
31
+ export const proxyInputMixin = (superclass) =>
32
+ class proxyInputMixinClass extends inputMixin(superclass) {
33
+ static get observedAttributes() {
34
+ return [...superclass.observedAttributes || [], ...errorAttrs];
35
+ }
36
+
37
+ #inputElement
38
+
39
+ constructor() {
40
+ super();
41
+
42
+ this.#inputElement = super.inputElement
43
+
44
+ // this is our way to identify that the form was submitted
45
+ // in this case, we want the input to be in error state if it's not valid
46
+ this.addEventListener('focus', (e) => {
47
+ if (e.relatedTarget?.form) {
48
+ if (!this.checkValidity()) {
49
+ this.setAttribute('invalid', 'true');
50
+ }
51
+
52
+ if (this.hasAttribute('invalid')) {
53
+ this.reportValidityOnInternalInput()
54
+ }
55
+ }
56
+ })
57
+
58
+ this.addEventListener('invalid', () => {
59
+ this.setInternalInputErrorMessage()
60
+ this.setAttribute('error-message', this.validationMessage)
61
+ })
62
+
63
+ this.addEventListener('valid', () => {
64
+ this.removeAttribute('invalid')
65
+ })
66
+ }
67
+
68
+ get inputElement() {
69
+ const inputSlot = this.baseEle.shadowRoot.querySelector('slot[name="input"]')
70
+ const textAreaSlot = this.baseEle.shadowRoot.querySelector('slot[name="textarea"]')
71
+
72
+ this.#inputElement ??= getNestedInput(inputSlot) || getNestedInput(textAreaSlot)
73
+
74
+ if (!this.#inputElement) throw Error('no input was found');
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
+ reportValidityOnInternalInput() {
88
+ setTimeout(() => {
89
+ this.inputElement.reportValidity()
90
+ }, 0)
91
+ }
92
+
93
+ handleBlur() { }
94
+
95
+ handleFocus() {
96
+ this.inputElement.focus();
97
+ if (this.hasAttribute('invalid')) {
98
+ this.reportValidityOnInternalInput()
99
+ }
100
+ }
101
+
102
+ // we want reportValidity to behave like form submission
103
+ reportValidity() {
104
+ const isValid = super.reportValidity()
105
+ if (!isValid) {
106
+ this.setAttribute('invalid', 'true');
107
+ this.inputElement.focus()
108
+ }
109
+ this.reportValidityOnInternalInput()
110
+ }
111
+
112
+ setInternalInputErrorMessage() {
113
+ if (!this.checkValidity()) {
114
+ this.inputElement.setCustomValidity(this.validationMessage)
115
+ }
116
+ }
117
+
118
+ connectedCallback() {
119
+ this.baseEle = this.shadowRoot.querySelector(this.baseSelector);
120
+
121
+ super.connectedCallback?.();
122
+
123
+ this.inputElement.addEventListener('input', () => {
124
+ this.inputElement.setCustomValidity('')
125
+ if (!this.inputElement.checkValidity())
126
+ this.setInternalInputErrorMessage()
127
+ })
128
+
129
+ this.inputElement.addEventListener('invalid', () => {
130
+ this.setValidity()
131
+ this.setInternalInputErrorMessage()
132
+ this.setAttribute('error-message', this.validationMessage)
133
+ })
134
+
135
+ // this is needed in order to make sure the form input validation is working
136
+ if (!this.hasAttribute('tabindex')) {
137
+ this.setAttribute('tabindex', 0);
138
+ }
139
+
140
+ // sync properties
141
+ propertyObserver(this, this.inputElement, 'value');
142
+ this.setSelectionRange = this.inputElement.setSelectionRange?.bind(this.inputElement);
143
+ }
144
+
145
+ attributeChangedCallback(attrName, oldValue, newValue) {
146
+ super.attributeChangedCallback?.(attrName, oldValue, newValue);
147
+
148
+ if (attrName === 'invalid' && newValue === '') {
149
+ this.setAttribute('invalid', 'true')
150
+ }
151
+ }
152
+ };
@@ -1,5 +1,5 @@
1
1
  import globals from '../globals';
2
- import { getThemeRefs, createHelperVars } from '../../themeHelpers';
2
+ import { getThemeRefs, createHelperVars } from '../../helpers/themeHelpers';
3
3
  import Button, { componentName } from '../../components/descope-button/Button';
4
4
 
5
5
  const globalRefs = getThemeRefs(globals);
@@ -17,7 +17,7 @@ const [helperTheme, helperRefs] = createHelperVars({ mode }, componentName);
17
17
 
18
18
  const button = {
19
19
  ...helperTheme,
20
-
20
+ [vars.width]: 'fit-content',
21
21
  size: {
22
22
  xs: {
23
23
  [vars.height]: '10px',
@@ -3,7 +3,8 @@ import Checkbox from '../../components/descope-checkbox/Checkbox';
3
3
  const vars = Checkbox.cssVarList;
4
4
 
5
5
  const checkbox = {
6
- [vars.cursor]: 'pointer'
6
+ [vars.cursor]: 'pointer',
7
+ [vars.width]: 'fit-content'
7
8
  };
8
9
 
9
10
  export default checkbox;
@@ -1,5 +1,5 @@
1
1
  import globals from "../globals";
2
- import { getThemeRefs, createHelperVars } from "../../themeHelpers";
2
+ import { getThemeRefs, createHelperVars } from "../../helpers/themeHelpers";
3
3
  import Container from "../../components/descope-container/Container";
4
4
 
5
5
  const globalRefs = getThemeRefs(globals);
@@ -27,7 +27,7 @@ const [helperTheme, helperRefs, helperVars] =
27
27
 
28
28
  const container = {
29
29
  ...helperTheme,
30
- [vars.display]: 'flex',
30
+ [vars.width]: '100%',
31
31
  verticalPadding: {
32
32
  sm: { [vars.verticalPadding]: '5px' },
33
33
  md: { [vars.verticalPadding]: '10px' },
@@ -1,26 +1,34 @@
1
- import Divider from '../../components/descope-divider/Divider';
1
+ import Divider, { componentName } from '../../components/descope-divider/Divider';
2
+ import { createHelperVars } from '../../helpers/themeHelpers';
2
3
 
3
4
  const vars = Divider.cssVarList;
4
5
 
6
+ const thickness = '2px'
7
+ const textPaddingSize = '10px'
8
+ const [helperTheme, helperRefs] = createHelperVars({ thickness, textPaddingSize }, componentName);
9
+
10
+
5
11
  const divider = {
12
+ ...helperTheme,
6
13
  [vars.alignItems]: 'center',
7
- [vars.height]: '2px',
14
+ [vars.dividerHeight]: helperRefs.thickness,
8
15
  [vars.backgroundColor]: 'currentColor',
9
16
  [vars.opacity]: '0.2',
10
- [vars.padding]: '0 10px',
17
+ [vars.textPadding]: `0 ${helperRefs.textPaddingSize}`,
11
18
  [vars.width]: '100%',
12
19
  [vars.flexDirection]: 'row',
13
20
  [vars.alignSelf]: 'strech',
14
21
  [vars.textWidth]: 'fit-content',
22
+ [vars.maxTextWidth]: 'calc(100% - 100px)',
15
23
  _vertical: {
16
- [vars.width]: '2px',
17
- [vars.padding]: '10px 0',
24
+ [vars.padding]: `0 calc(${thickness} * 3)`,
25
+ [vars.width]: 'fit-content',
26
+ [vars.textPadding]: `${helperRefs.textPaddingSize} 0`,
18
27
  [vars.flexDirection]: 'column',
19
28
  [vars.minHeight]: '200px',
20
- [vars.textWidth]: 'max-content'
21
- },
22
- _italic: {
23
- [vars.fontStyle]: 'italic'
29
+ [vars.textWidth]: 'fit-content',
30
+ [vars.dividerWidth]: helperRefs.thickness,
31
+ [vars.maxTextWidth]: '100%',
24
32
  }
25
33
  };
26
34
 
@@ -1,5 +1,5 @@
1
1
  import globals from '../globals';
2
- import { getThemeRefs } from '../../themeHelpers';
2
+ import { getThemeRefs } from '../../helpers/themeHelpers';
3
3
  import Link from '../../components/descope-link/Link';
4
4
 
5
5
  const globalRefs = getThemeRefs(globals);
@@ -1,5 +1,5 @@
1
1
  import LoaderLinear from '../../../components/descope-loader-linear/LoaderLinear';
2
- import { getThemeRefs } from '../../../themeHelpers';
2
+ import { getThemeRefs } from '../../../helpers/themeHelpers';
3
3
  import globals from '../../globals';
4
4
 
5
5
  const globalRefs = getThemeRefs(globals);
@@ -1,5 +1,5 @@
1
1
  import LoaderRadial from '../../../components/descope-loader-radial/LoaderRadial';
2
- import { getThemeRefs } from '../../../themeHelpers';
2
+ import { getThemeRefs } from '../../../helpers/themeHelpers';
3
3
  import globals from '../../globals';
4
4
 
5
5
  const globalRefs = getThemeRefs(globals);
@@ -1,5 +1,5 @@
1
1
  import globals from '../globals';
2
- import { getThemeRefs } from '../../themeHelpers';
2
+ import { getThemeRefs } from '../../helpers/themeHelpers';
3
3
  import Text from '../../components/descope-text/Text';
4
4
 
5
5
  const globalRefs = getThemeRefs(globals);
@@ -1,11 +1,12 @@
1
1
  import globals from '../globals';
2
- import { getThemeRefs } from '../../themeHelpers';
2
+ import { getThemeRefs } from '../../helpers/themeHelpers';
3
3
  import TextArea from '../../components/descope-text-area/TextArea';
4
4
 
5
5
  const globalRefs = getThemeRefs(globals);
6
6
  const vars = TextArea.cssVarList;
7
7
 
8
8
  const textArea = {
9
+ [vars.width]: '100%',
9
10
  [vars.color]: globalRefs.colors.primary.main,
10
11
  [vars.backgroundColor]: globalRefs.colors.surface.light,
11
12
  [vars.resize]: 'vertical',