@descope/web-components-ui 1.0.279 → 1.0.281

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. package/dist/cjs/index.cjs.js +2344 -2099
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.esm.js +3075 -2446
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/umd/1000.js +1 -1
  7. package/dist/umd/1438.js +2 -2
  8. package/dist/umd/{9558.js → 1621.js} +117 -117
  9. package/dist/umd/2066.js +1 -1
  10. package/dist/umd/3280.js +197 -0
  11. package/dist/umd/3280.js.LICENSE.txt +29 -0
  12. package/dist/umd/{6542.js → 3951.js} +6 -6
  13. package/dist/umd/{6542.js.LICENSE.txt → 3951.js.LICENSE.txt} +0 -6
  14. package/dist/umd/422.js +1 -1
  15. package/dist/umd/4447.js +1 -1
  16. package/dist/umd/5806.js +1 -1
  17. package/dist/umd/6770.js +1 -1
  18. package/dist/umd/6977.js +2 -0
  19. package/dist/umd/6977.js.LICENSE.txt +5 -0
  20. package/dist/umd/7056.js +1 -1
  21. package/dist/umd/7262.js +1 -1
  22. package/dist/umd/7531.js +2 -2
  23. package/dist/umd/7583.js +2 -2
  24. package/dist/umd/8725.js +1 -1
  25. package/dist/umd/9092.js +2 -2
  26. package/dist/umd/9437.js +1 -1
  27. package/dist/umd/descope-combo-box-index-js.js +1 -1
  28. package/dist/umd/descope-notification-descope-notification-card-index-js.js +1 -1
  29. package/dist/umd/descope-notification-index-js.js +1 -1
  30. package/dist/umd/index.js +1 -1
  31. package/dist/umd/mapping-fields-descope-mappings-field-descope-mapping-item-index-js.js +1 -0
  32. package/dist/umd/mapping-fields-descope-mappings-field-descope-mappings-field-internal-index-js.js +1 -0
  33. package/dist/umd/mapping-fields-descope-mappings-field-index-js.js +1 -0
  34. package/package.json +4 -1
  35. package/src/components/descope-combo-box/ComboBoxClass.js +4 -0
  36. package/src/components/descope-text-field/textFieldMappings.js +7 -1
  37. package/src/components/mapping-fields/descope-mappings-field/MappingsFieldClass.js +159 -0
  38. package/src/components/mapping-fields/descope-mappings-field/descope-mapping-item/MappingItem.js +158 -0
  39. package/src/components/mapping-fields/descope-mappings-field/descope-mapping-item/index.js +3 -0
  40. package/src/components/mapping-fields/descope-mappings-field/descope-mappings-field-internal/MappingsFieldInternal.js +232 -0
  41. package/src/components/mapping-fields/descope-mappings-field/descope-mappings-field-internal/index.js +3 -0
  42. package/src/components/mapping-fields/descope-mappings-field/index.js +14 -0
  43. package/src/components/phone-fields/CountryCodes.js +1209 -1206
  44. package/src/index.cjs.js +1 -0
  45. package/src/index.d.ts +1 -0
  46. package/src/index.js +1 -0
  47. package/src/mixins/inputValidationMixin.js +8 -0
  48. package/src/mixins/proxyInputMixin.js +48 -6
  49. package/src/theme/components/index.js +2 -0
  50. package/src/theme/components/inputWrapper.js +2 -0
  51. package/src/theme/components/mappingsField.js +25 -0
  52. package/src/theme/components/textField.js +1 -0
  53. /package/dist/umd/{9558.js.LICENSE.txt → 1621.js.LICENSE.txt} +0 -0
package/src/index.cjs.js CHANGED
@@ -37,3 +37,4 @@ export { NotificationClass } from './components/descope-notification/Notificatio
37
37
  export { GridClass } from './components/descope-grid/GridClass';
38
38
  export { BadgeClass } from './components/descope-badge/BadgeClass';
39
39
  export { MultiSelectComboBoxClass } from './components/descope-multi-select-combo-box/MultiSelectComboBoxClass';
40
+ export { MappingsFieldClass } from './components/mapping-fields/descope-mappings-field/MappingsFieldClass';
package/src/index.d.ts CHANGED
@@ -42,6 +42,7 @@ export { ModalClass } from './components/descope-modal/ModalClass';
42
42
  export { NotificationClass } from './components/descope-notification/';
43
43
  export { BadgeClass } from './components/descope-badge/';
44
44
  export { MultiSelectComboBoxClass } from './components/descope-multi-select-combo-box/';
45
+ export { MappingsFieldClass } from './components/mapping-fields/descope-mappings-field/';
45
46
 
46
47
  export type Theme = {
47
48
  globals: {
package/src/index.js CHANGED
@@ -31,6 +31,7 @@ export * from './components/descope-multi-select-combo-box';
31
31
  export * from './components/descope-badge';
32
32
  export * from './components/descope-modal';
33
33
  export * from './components/descope-notification';
34
+ export * from './components/mapping-fields/descope-mappings-field';
34
35
 
35
36
  export {
36
37
  globalsThemeToStyle,
@@ -20,6 +20,14 @@ export const inputValidationMixin = (superclass) =>
20
20
 
21
21
  #internals;
22
22
 
23
+ get internals() {
24
+ return this.#internals;
25
+ }
26
+
27
+ set internals(value) {
28
+ this.#internals = value;
29
+ }
30
+
23
31
  constructor() {
24
32
  super();
25
33
 
@@ -38,7 +38,10 @@ const proxyInputMixin =
38
38
  ({
39
39
  proxyProps = [],
40
40
  // allows us to set the event that should trigger validation
41
+ // it can be either a string or an array of strings (for multiple events)
41
42
  inputEvent = 'input',
43
+ // Proxies all validations from the parent component to the input element
44
+ proxyParentValidation = false,
42
45
  }) =>
43
46
  (superclass) =>
44
47
  class ProxyInputMixinClass extends inputValidationMixin(superclass) {
@@ -128,12 +131,16 @@ const proxyInputMixin =
128
131
  // on some cases the base element is not ready so the inputElement is empty
129
132
  // we are deferring this section to make sure the base element is ready
130
133
  setTimeout(() => {
131
- this.baseElement?.addEventListener(inputEvent, () => {
132
- if (!this.baseElement.checkValidity()) {
133
- this.#handleErrorMessage();
134
- } else {
135
- this.removeAttribute('invalid');
136
- }
134
+ const validationEvents = Array.isArray(inputEvent) ? inputEvent : [inputEvent];
135
+
136
+ validationEvents.forEach((e) => {
137
+ this.baseElement?.addEventListener(e, () => {
138
+ if (!this.baseElement.checkValidity()) {
139
+ this.#handleErrorMessage();
140
+ } else {
141
+ this.removeAttribute('invalid');
142
+ }
143
+ });
137
144
  });
138
145
 
139
146
  this.baseElement.addEventListener('change', () => {
@@ -156,6 +163,41 @@ const proxyInputMixin =
156
163
 
157
164
  forwardAttrs(this, this.inputElement, { includeAttrs: ['inputmode'] });
158
165
  });
166
+
167
+ if (proxyParentValidation) {
168
+ // All functions called on the inputElement internals will be applied to the parent
169
+ // component internals as well. As a result, there's no need to add outer mechanisms
170
+ // to update the parent component's validity state based on the input elements validity.
171
+ const inputElementInternals = this.inputElement.internals;
172
+ const parentThis = this;
173
+ this.inputElement.internals = new Proxy(inputElementInternals, {
174
+ get: (target, prop) => {
175
+ if (typeof target[prop] === 'function' && prop === 'setValidity') {
176
+ return (...args) => {
177
+ // If we're calling setValidity with 3 args, then the validationTarget
178
+ // needs to be swapped to be the inputElement
179
+ if (args.length === 3) {
180
+ const newArgs = args.slice(0, args.length - 1);
181
+ newArgs.push(parentThis.inputElement);
182
+ parentThis.internals[prop](...newArgs);
183
+ } else {
184
+ parentThis.internals[prop](...args);
185
+ }
186
+ return target[prop](...args);
187
+ };
188
+ }
189
+
190
+ if (typeof target[prop] === 'function') {
191
+ return (...args) => {
192
+ parentThis.internals[prop](...args);
193
+ return target[prop](...args);
194
+ };
195
+ }
196
+
197
+ return target[prop];
198
+ },
199
+ });
200
+ }
159
201
  }
160
202
  };
161
203
 
@@ -30,6 +30,7 @@ import * as grid from './grid';
30
30
  import * as notificationCard from './notificationCard';
31
31
  import * as multiSelectComboBox from './multiSelectComboBox';
32
32
  import * as badge from './badge';
33
+ import * as mappingsField from './mappingsField';
33
34
 
34
35
  const components = {
35
36
  button,
@@ -65,6 +66,7 @@ const components = {
65
66
  notificationCard,
66
67
  multiSelectComboBox,
67
68
  badge,
69
+ mappingsField,
68
70
  };
69
71
 
70
72
  const theme = Object.keys(components).reduce(
@@ -12,6 +12,7 @@ const [theme, refs, vars] = createHelperVars(
12
12
  placeholderTextColor: globalRefs.colors.surface.dark,
13
13
  requiredIndicator: "'*'",
14
14
  errorMessageTextColor: globalRefs.colors.error.main,
15
+ helperTextColor: globalRefs.colors.surface.dark,
15
16
 
16
17
  borderWidth: globalRefs.border.xs,
17
18
  borderRadius: globalRefs.radius.xs,
@@ -68,6 +69,7 @@ const [theme, refs, vars] = createHelperVars(
68
69
  borderColor: globalRefs.colors.surface.light,
69
70
  valueTextColor: globalRefs.colors.surface.light,
70
71
  placeholderTextColor: globalRefs.colors.surface.light,
72
+ helperTextColor: globalRefs.colors.surface.light,
71
73
  backgroundColor: globalRefs.colors.surface.main,
72
74
  },
73
75
  },
@@ -0,0 +1,25 @@
1
+ import globals from '../globals';
2
+ import { MappingsFieldClass } from '../../components/mapping-fields/descope-mappings-field/MappingsFieldClass';
3
+ import { getThemeRefs } from '../../helpers/themeHelpers';
4
+ import { refs } from './inputWrapper';
5
+
6
+ const globalRefs = getThemeRefs(globals);
7
+
8
+ const vars = MappingsFieldClass.cssVarList;
9
+
10
+ export const mappingsField = {
11
+ [vars.hostWidth]: refs.width,
12
+ [vars.hostDirection]: refs.direction,
13
+ [vars.fontSize]: refs.fontSize,
14
+ [vars.fontFamily]: refs.fontFamily,
15
+ [vars.separatorFontSize]: '14px',
16
+ [vars.labelTextColor]: refs.labelTextColor,
17
+ [vars.itemMarginBottom]: '1em',
18
+ // To be positioned correctly, the min width has to match the text field min width
19
+ [vars.valueLabelMinWidth]: refs.minWidth,
20
+ // To be positioned correctly, the min width has to match the combo box field min width
21
+ [vars.attrLabelMinWidth]: `calc(12em + 2 * ${globalRefs.border.xs})`,
22
+ };
23
+
24
+ export default mappingsField;
25
+ export { vars };
@@ -25,6 +25,7 @@ export const textField = {
25
25
  [vars.inputBackgroundColor]: refs.backgroundColor,
26
26
  [vars.inputHeight]: refs.inputHeight,
27
27
  [vars.inputHorizontalPadding]: refs.horizontalPadding,
28
+ [vars.helperTextColor]: refs.helperTextColor,
28
29
  textAlign: {
29
30
  right: { [vars.inputTextAlign]: 'right' },
30
31
  left: { [vars.inputTextAlign]: 'left' },