@descope/web-components-ui 1.0.288 → 1.0.290

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. package/dist/cjs/index.cjs.js +1148 -880
  2. package/dist/cjs/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.esm.js +1147 -878
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/umd/2106.js +1 -1
  7. package/dist/umd/7911.js +73 -0
  8. package/dist/umd/7911.js.LICENSE.txt +17 -0
  9. package/dist/umd/button-selection-group-fields-descope-button-selection-group-item-index-js.js +1 -1
  10. package/dist/umd/descope-avatar-index-js.js +1 -1
  11. package/dist/umd/descope-badge-index-js.js +1 -1
  12. package/dist/umd/descope-text-index-js.js +1 -1
  13. package/dist/umd/descope-user-attribute-index-js.js +1 -0
  14. package/dist/umd/index.js +1 -1
  15. package/dist/umd/mapping-fields-descope-mappings-field-index-js.js +1 -1
  16. package/package.json +4 -2
  17. package/src/components/button-selection-group-fields/descope-button-selection-group-item/ButtonSelectionGroupItemClass.js +4 -0
  18. package/src/components/descope-avatar/AvatarClass.js +7 -5
  19. package/src/components/descope-badge/BadgeClass.js +3 -0
  20. package/src/components/descope-text/TextClass.js +1 -1
  21. package/src/components/descope-user-attribute/UserAttributeClass.js +228 -0
  22. package/src/components/descope-user-attribute/delete.svg +3 -0
  23. package/src/components/descope-user-attribute/edit.svg +3 -0
  24. package/src/components/descope-user-attribute/index.js +9 -0
  25. package/src/helpers/themeHelpers/componentsThemeManager.js +4 -0
  26. package/src/index.cjs.js +1 -0
  27. package/src/index.d.ts +3 -0
  28. package/src/index.js +1 -0
  29. package/src/theme/components/avatar.js +4 -0
  30. package/src/theme/components/buttonSelectionGroup/buttonSelectionGroupItem.js +1 -0
  31. package/src/theme/components/index.js +2 -0
  32. package/src/theme/components/userAttribute.js +20 -0
@@ -0,0 +1,228 @@
1
+ import { createStyleMixin, draggableMixin, componentNameValidationMixin } from '../../mixins';
2
+ import { createBaseClass } from '../../baseClasses/createBaseClass';
3
+ import { compose } from '../../helpers';
4
+ import { getComponentName } from '../../helpers/componentHelpers';
5
+ import deleteIcon from './delete.svg';
6
+ import editIcon from './edit.svg';
7
+ import { TextClass } from '../descope-text/TextClass';
8
+ import { ButtonClass } from '../descope-button/ButtonClass';
9
+ import { BadgeClass } from '../descope-badge/BadgeClass';
10
+
11
+ export const componentName = getComponentName('user-attribute');
12
+ class RawUserAttribute extends createBaseClass({
13
+ componentName,
14
+ baseSelector: ':host > .root',
15
+ }) {
16
+ constructor() {
17
+ super();
18
+
19
+ this.attachShadow({ mode: 'open' }).innerHTML = `
20
+ <style>
21
+ :host {
22
+ display: inline-flex;
23
+ }
24
+
25
+ vaadin-icon {
26
+ color: currentcolor;
27
+ }
28
+
29
+ .root {
30
+ display: flex;
31
+ width: 100%;
32
+ height: 100%;
33
+ align-items: center;
34
+ }
35
+
36
+ .btn-wrapper {
37
+ display: flex;
38
+ justify-content: space-between;
39
+ align-items: center;
40
+ flex-grow: 0;
41
+ }
42
+
43
+ .text-wrapper {
44
+ display: flex;
45
+ align-items: center;
46
+ flex-grow: 1;
47
+ }
48
+
49
+ descope-text::part(text-wrapper) {
50
+ text-overflow: ellipsis;
51
+ overflow: hidden;
52
+ white-space: nowrap;
53
+ width: initial;
54
+ }
55
+
56
+ descope-text {
57
+ display: inline-flex;
58
+ }
59
+
60
+ descope-badge {
61
+ margin-inline-end: 10px;
62
+ }
63
+
64
+ descope-text[data-id="label-text"].required:after {
65
+ content: '*';
66
+ color: var(${TextClass.cssVarList.textColor});
67
+ }
68
+ </style>
69
+
70
+
71
+ <div class="root">
72
+ <div class="text-wrapper">
73
+ <descope-text st-text-align="auto" data-id="label-text" variant="body1" mode="secondary"></descope-text>
74
+ <descope-text st-text-align="auto" data-id="value-text" variant="body1" mode="primary"></descope-text>
75
+ </div>
76
+
77
+ <div class="btn-wrapper">
78
+ <descope-badge mode="default" bordered="true" size="xs"></descope-badge>
79
+ <descope-button size="xs" data-id="edit-btn" square="true" variant="link" mode="primary">
80
+ <vaadin-icon src=${editIcon}></vaadin-icon>
81
+ </descope-button>
82
+ <descope-button size="xs" data-id="delete-btn" square="true" variant="link" mode="primary">
83
+ <vaadin-icon src=${deleteIcon}></vaadin-icon>
84
+ </descope-button>
85
+ </div
86
+ </div>
87
+ `;
88
+
89
+ this.deleteButton = this.shadowRoot.querySelector('descope-button[data-id="delete-btn"]');
90
+ this.editButton = this.shadowRoot.querySelector('descope-button[data-id="edit-btn"]');
91
+ this.badge = this.shadowRoot.querySelector('descope-badge');
92
+ this.labelText = this.shadowRoot.querySelector('descope-text[data-id="label-text"]');
93
+ this.valueText = this.shadowRoot.querySelector('descope-text[data-id="value-text"]');
94
+ }
95
+
96
+ onLabelChange() {
97
+ this.labelText.innerText = this.label;
98
+ this.labelText.setAttribute('title', this.label);
99
+ }
100
+
101
+ onValueOrPlaceholderChange() {
102
+ const text = this.value || this.placeholder;
103
+ const mode = this.value ? 'primary' : 'secondary';
104
+
105
+ this.valueText.innerText = text;
106
+ this.valueText.setAttribute('title', text);
107
+ this.valueText.setAttribute('mode', mode);
108
+ }
109
+
110
+ onBadgeLabelChange() {
111
+ if (!this.badgeLabel) {
112
+ this.badge.style.display = 'none';
113
+ } else {
114
+ this.badge.innerText = this.badgeLabel;
115
+ this.badge.style.display = '';
116
+ }
117
+ }
118
+
119
+ onBadgeTooltipTextChange() {
120
+ this.badge.setAttribute('title', this.badgeTooltipText || this.badgeLabel);
121
+ }
122
+
123
+ onIsRequiredChange() {
124
+ this.labelText.classList.toggle('required', this.isRequired);
125
+ }
126
+
127
+ get label() {
128
+ return this.getAttribute('label') || '';
129
+ }
130
+
131
+ get value() {
132
+ return this.getAttribute('value') || '';
133
+ }
134
+
135
+ get placeholder() {
136
+ return this.getAttribute('placeholder') || '';
137
+ }
138
+
139
+ get isRequired() {
140
+ return this.getAttribute('required') === 'true';
141
+ }
142
+
143
+ get badgeLabel() {
144
+ return this.getAttribute('badge-label') || '';
145
+ }
146
+
147
+ get badgeTooltipText() {
148
+ return this.getAttribute('badge-tooltip-text') || '';
149
+ }
150
+
151
+ init() {
152
+ this.onLabelChange();
153
+ this.onValueOrPlaceholderChange();
154
+ this.onIsRequiredChange();
155
+ this.onBadgeLabelChange();
156
+ this.onBadgeTooltipTextChange();
157
+
158
+ this.deleteButton.addEventListener('click', () =>
159
+ this.dispatchEvent(new CustomEvent('delete-clicked', { bubbles: true, composed: true }))
160
+ );
161
+
162
+ this.editButton.addEventListener('click', () =>
163
+ this.dispatchEvent(new CustomEvent('edit-clicked', { bubbles: true, composed: true }))
164
+ );
165
+ }
166
+
167
+ static get observedAttributes() {
168
+ return [
169
+ 'label',
170
+ 'value',
171
+ 'placeholder',
172
+ 'required',
173
+ 'badge-label',
174
+ 'badge-tooltip-text',
175
+ ].concat(super.observedAttributes);
176
+ }
177
+
178
+ attributeChangedCallback(name, oldValue, newValue) {
179
+ super.attributeChangedCallback?.(name, oldValue, newValue);
180
+
181
+ if (oldValue === newValue) {
182
+ return;
183
+ }
184
+
185
+ if (name === 'label') {
186
+ this.onLabelChange();
187
+ } else if (name === 'value' || name === 'placeholder') {
188
+ this.onValueOrPlaceholderChange();
189
+ } else if (name === 'required') {
190
+ this.onIsRequiredChange();
191
+ } else if (name === 'badge-label') {
192
+ this.onBadgeLabelChange();
193
+ } else if (name === 'badge-tooltip-text') {
194
+ this.onBadgeTooltipTextChange();
195
+ }
196
+ }
197
+ }
198
+
199
+ const { host, textFields, buttons, badge, labelText, valueText, textWrapper } = {
200
+ host: { selector: () => ':host' },
201
+ textFields: { selector: 'descope-text' },
202
+ valueText: { selector: 'descope-text[data-id="value-text"]' },
203
+ labelText: { selector: 'descope-text[data-id="label-text"]' },
204
+ buttons: { selector: 'descope-button' },
205
+ badge: { selector: 'descope-badge' },
206
+ textWrapper: { selector: ' .text-wrapper' },
207
+ };
208
+
209
+ export const UserAttributeClass = compose(
210
+ createStyleMixin({
211
+ mappings: {
212
+ hostWidth: { ...host, property: 'width' },
213
+ hostMinWidth: { ...host, property: 'min-width' },
214
+ hostDirection: [
215
+ { ...host, property: 'direction' },
216
+ { ...textFields, property: TextClass.cssVarList.hostDirection },
217
+ { ...buttons, property: ButtonClass.cssVarList.hostDirection },
218
+ { ...badge, property: BadgeClass.cssVarList.hostDirection },
219
+ ],
220
+ labelTextWidth: { ...labelText, property: 'width' },
221
+ valueTextWidth: { ...valueText, property: 'width' },
222
+ badgeMaxWidth: { ...badge, property: 'max-width' },
223
+ itemsGap: [{ property: 'gap' }, { ...textWrapper, property: 'gap' }],
224
+ },
225
+ }),
226
+ draggableMixin,
227
+ componentNameValidationMixin
228
+ )(RawUserAttribute);
@@ -0,0 +1,3 @@
1
+ <svg width="14" height="18" viewBox="0 0 14 18" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M1 16C1 17.1 1.9 18 3 18H11C12.1 18 13 17.1 13 16V4H1V16ZM3 6H11V16H3V6ZM10.5 1L9.5 0H4.5L3.5 1H0V3H14V1H10.5Z" fill="currentcolor"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M10.0002 0.992149C10.0002 1.01615 10.0002 1.01615 10.0002 1.01615L8.22419 3.00815H2.99219C2.46419 3.00815 2.00819 3.44015 2.00819 3.99215V12.0082C2.00819 12.5362 2.44019 12.9922 2.99219 12.9922H5.53619C5.84819 13.0402 6.16019 13.0402 6.47219 12.9922H11.0082C11.5362 12.9922 11.9922 12.5602 11.9922 12.0082V7.78416L13.9362 5.62415L14.0082 5.67215V11.9842C14.0082 13.6642 12.6642 15.0082 11.0082 15.0082H3.01619C1.33619 15.0082 -0.0078125 13.6642 -0.0078125 11.9842V3.99215C-0.0078125 2.33615 1.33619 0.992149 3.01619 0.992149H10.0002ZM11.2722 2.62415L12.6162 4.11215L7.72019 9.68016C7.50419 9.92016 6.83219 10.2322 5.68019 10.6162C5.65619 10.6402 5.60819 10.6402 5.56019 10.6162C5.46419 10.5922 5.39219 10.4722 5.44019 10.3762C5.75219 9.24816 6.04019 8.55216 6.25619 8.31216L11.2722 2.62415ZM11.9202 1.85615L13.2882 0.320149C13.6482 -0.0878516 14.2722 -0.111852 14.6802 0.272149C15.0882 0.632149 15.1122 1.28015 14.7522 1.68815L13.2642 3.36815L11.9202 1.85615Z" fill="currentcolor"/>
3
+ </svg>
@@ -0,0 +1,9 @@
1
+ import { componentName, UserAttributeClass } from './UserAttributeClass';
2
+ import '../descope-text';
3
+ import '../descope-button';
4
+ import '../descope-badge';
5
+ import '@vaadin/icon';
6
+
7
+ customElements.define(componentName, UserAttributeClass);
8
+
9
+ export { UserAttributeClass };
@@ -36,6 +36,10 @@ class ComponentsThemeManager {
36
36
  this.#themes = themes;
37
37
  this.#notify();
38
38
  }
39
+
40
+ get hasThemes() {
41
+ return !!Object.keys(this.#themes).length;
42
+ }
39
43
  }
40
44
 
41
45
  export const componentsThemeManager = new ComponentsThemeManager();
package/src/index.cjs.js CHANGED
@@ -38,4 +38,5 @@ 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
40
  export { AvatarClass } from './components/descope-avatar/AvatarClass';
41
+ export { UserAttributeClass } from './components/descope-user-attribute/UserAttributeClass';
41
42
  export { MappingsFieldClass } from './components/mapping-fields/descope-mappings-field/MappingsFieldClass';
package/src/index.d.ts CHANGED
@@ -51,6 +51,8 @@ export type Theme = {
51
51
  typography: Record<string, any>;
52
52
  shadow: Record<string, string>;
53
53
  spacing: Record<string, string>;
54
+ radius: Record<string, string>;
55
+ border: Record<string, string>;
54
56
  };
55
57
  components: {
56
58
  button: Record<string, any>;
@@ -60,5 +62,6 @@ export type Theme = {
60
62
  link: Record<string, any>;
61
63
  text: Record<string, any>;
62
64
  inputWrapper: Record<string, any>;
65
+ buttonSelectionGroupItem: Record<string, any>;
63
66
  };
64
67
  };
package/src/index.js CHANGED
@@ -33,6 +33,7 @@ export * from './components/descope-modal';
33
33
  export * from './components/descope-notification';
34
34
  export * from './components/descope-avatar';
35
35
  export * from './components/mapping-fields/descope-mappings-field';
36
+ export * from './components/descope-user-attribute';
36
37
 
37
38
  export {
38
39
  globalsThemeToStyle,
@@ -13,6 +13,10 @@ const avatar = {
13
13
  [compVars.avatarTextColor]: globalRefs.colors.surface.main,
14
14
  [compVars.avatarBackgroundColor]: globalRefs.colors.surface.dark,
15
15
 
16
+ _editable: {
17
+ [compVars.cursor]: 'pointer',
18
+ },
19
+
16
20
  size: {
17
21
  xs: {
18
22
  [compVars.hostWidth]: '30px',
@@ -14,6 +14,7 @@ const buttonSelectionGroupItem = {
14
14
  [vars.borderStyle]: 'solid',
15
15
  [vars.borderRadius]: globalRefs.radius.sm,
16
16
  [vars.outlineColor]: 'transparent',
17
+ [vars.borderWidth]: globalRefs.border.xs,
17
18
 
18
19
  _hover: {
19
20
  [vars.backgroundColor]: globalRefs.colors.surface.highlight,
@@ -32,6 +32,7 @@ import * as multiSelectComboBox from './multiSelectComboBox';
32
32
  import * as badge from './badge';
33
33
  import * as avatar from './avatar';
34
34
  import * as mappingsField from './mappingsField';
35
+ import * as userAttribute from './userAttribute';
35
36
 
36
37
  const components = {
37
38
  button,
@@ -69,6 +70,7 @@ const components = {
69
70
  badge,
70
71
  avatar,
71
72
  mappingsField,
73
+ userAttribute,
72
74
  };
73
75
 
74
76
  const theme = Object.keys(components).reduce(
@@ -0,0 +1,20 @@
1
+ import globals from '../globals';
2
+ import { UserAttributeClass } from '../../components/descope-user-attribute/UserAttributeClass';
3
+ import { getThemeRefs } from '../../helpers/themeHelpers';
4
+
5
+ const globalRefs = getThemeRefs(globals);
6
+ export const vars = UserAttributeClass.cssVarList;
7
+
8
+ const userAttribute = {
9
+ [vars.hostDirection]: globalRefs.direction,
10
+ [vars.labelTextWidth]: '150px',
11
+ [vars.valueTextWidth]: '200px',
12
+ [vars.badgeMaxWidth]: '85px',
13
+ [vars.itemsGap]: '16px',
14
+ [vars.hostMinWidth]: '530px',
15
+ _fullWidth: {
16
+ [vars.hostWidth]: '100%',
17
+ },
18
+ };
19
+
20
+ export default userAttribute;