@descope/web-components-ui 1.0.293 → 1.0.295

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.
@@ -0,0 +1,201 @@
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 greenVIcon from './green-v.svg';
6
+ import { TextClass } from '../descope-text/TextClass';
7
+ import { ButtonClass } from '../descope-button/ButtonClass';
8
+ import { BadgeClass } from '../descope-badge/BadgeClass';
9
+
10
+ export const componentName = getComponentName('user-auth-method');
11
+ class RawUserAuthMethod extends createBaseClass({
12
+ componentName,
13
+ baseSelector: ':host > .root',
14
+ }) {
15
+ constructor() {
16
+ super();
17
+
18
+ this.attachShadow({ mode: 'open' }).innerHTML = `
19
+ <style>
20
+ :host {
21
+ display: inline-flex;
22
+ }
23
+
24
+ vaadin-icon {
25
+ color: currentcolor;
26
+ }
27
+
28
+ .root {
29
+ display: flex;
30
+ width: 100%;
31
+ height: 100%;
32
+ align-items: center;
33
+ }
34
+
35
+ .btn-wrapper {
36
+ display: flex;
37
+ justify-content: space-between;
38
+ align-items: center;
39
+ flex-grow: 0;
40
+ }
41
+
42
+ .text-wrapper {
43
+ display: flex;
44
+ align-items: center;
45
+ flex-grow: 1;
46
+ }
47
+
48
+ descope-text::part(text-wrapper) {
49
+ text-overflow: ellipsis;
50
+ overflow: hidden;
51
+ white-space: nowrap;
52
+ width: initial;
53
+ }
54
+
55
+ descope-text {
56
+ display: inline-flex;
57
+ }
58
+
59
+ .fulfilled-indicator {
60
+ width: 1em;
61
+ height: 1em;
62
+ display: flex;
63
+ align-items: center;
64
+ padding-inline-end: 1em;
65
+ }
66
+
67
+ .hidden {
68
+ display: none;
69
+ }
70
+
71
+ .hidden-btn {
72
+ width: 0;
73
+ }
74
+
75
+ slot[name="method-icon"]{
76
+ display: inline-flex;
77
+ align-items: center;
78
+ }
79
+ </style>
80
+
81
+
82
+ <div class="root">
83
+ <div class="text-wrapper">
84
+ <slot name="method-icon"></slot>
85
+ <descope-text st-text-align="auto" data-id="label-text" variant="body1" mode="primary"></descope-text>
86
+ </div>
87
+
88
+ <div class="btn-wrapper">
89
+ <descope-button size="sm" variant="link" mode="primary">
90
+ <slot name="button-icon"></slot>
91
+ </descope-button>
92
+ <div class="fulfilled-indicator">
93
+ <vaadin-icon src=${greenVIcon}></vaadin-icon>
94
+ </div>
95
+ <descope-button class="hidden-btn"size="sm" variant="link" mode="primary"></descope-button>
96
+ </div>
97
+ </div>
98
+ `;
99
+
100
+ this.button = this.shadowRoot.querySelector('descope-button');
101
+ this.fulfilledIndicator = this.shadowRoot.querySelector('.fulfilled-indicator');
102
+ this.labelText = this.shadowRoot.querySelector('descope-text[data-id="label-text"]');
103
+ }
104
+
105
+ onLabelChange() {
106
+ this.labelText.innerText = this.label;
107
+ this.labelText.setAttribute('title', this.label);
108
+ }
109
+
110
+ onButtonLabelChange() {
111
+ let textSpanEle = this.button.querySelector('span');
112
+
113
+ if (this.buttonLabel) {
114
+ if (!textSpanEle) {
115
+ textSpanEle = document.createElement('span');
116
+ this.button.appendChild(textSpanEle);
117
+ }
118
+ textSpanEle.innerText = this.buttonLabel;
119
+ } else if (textSpanEle) {
120
+ this.button.removeChild(textSpanEle);
121
+ }
122
+ }
123
+
124
+ onFulfilledChange() {
125
+ this.button.classList.toggle('hidden', this.isFulfilled);
126
+ this.fulfilledIndicator.classList.toggle('hidden', !this.isFulfilled);
127
+ }
128
+
129
+ get label() {
130
+ return this.getAttribute('label') || '';
131
+ }
132
+
133
+ get buttonLabel() {
134
+ return this.getAttribute('button-label') || '';
135
+ }
136
+
137
+ get isFulfilled() {
138
+ return this.getAttribute('fulfilled') === 'true';
139
+ }
140
+
141
+ init() {
142
+ this.onLabelChange();
143
+ this.onButtonLabelChange();
144
+ this.onFulfilledChange();
145
+
146
+ this.button.addEventListener('click', () =>
147
+ this.dispatchEvent(new CustomEvent('button-clicked', { bubbles: true, composed: true }))
148
+ );
149
+ }
150
+
151
+ static get observedAttributes() {
152
+ return ['label', 'fulfilled'].concat(super.observedAttributes);
153
+ }
154
+
155
+ attributeChangedCallback(name, oldValue, newValue) {
156
+ super.attributeChangedCallback?.(name, oldValue, newValue);
157
+ if (oldValue === newValue) {
158
+ return;
159
+ }
160
+
161
+ if (name === 'label') {
162
+ this.onLabelChange();
163
+ } else if (name === 'fulfilled') {
164
+ this.onFulfilledChange();
165
+ } else if (name === 'button-label') {
166
+ this.onButtonLabelChange();
167
+ }
168
+ }
169
+ }
170
+
171
+ const { host, textField, buttons, badge, textWrapper, methodIconSlot } = {
172
+ host: { selector: () => ':host' },
173
+ textField: { selector: 'descope-text' },
174
+ buttons: { selector: 'descope-button' },
175
+ badge: { selector: 'descope-badge' },
176
+ textWrapper: { selector: ' .text-wrapper' },
177
+ methodIconSlot: { selector: 'slot[name="method-icon"]' },
178
+ };
179
+
180
+ export const UserAuthMethodClass = compose(
181
+ createStyleMixin({
182
+ mappings: {
183
+ hostWidth: { ...host, property: 'width' },
184
+ hostMinWidth: { ...host, property: 'min-width' },
185
+ hostDirection: [
186
+ { ...host, property: 'direction' },
187
+ { ...textField, property: TextClass.cssVarList.hostDirection },
188
+ { ...buttons, property: ButtonClass.cssVarList.hostDirection },
189
+ { ...badge, property: BadgeClass.cssVarList.hostDirection },
190
+ ],
191
+ labelTextWidth: { ...textField, property: 'width' },
192
+ itemsGap: [{ property: 'gap' }, { ...textWrapper, property: 'gap' }],
193
+ iconSize: [
194
+ { ...methodIconSlot, property: 'width' },
195
+ { ...methodIconSlot, property: 'height' },
196
+ ],
197
+ },
198
+ }),
199
+ draggableMixin,
200
+ componentNameValidationMixin
201
+ )(RawUserAuthMethod);
@@ -0,0 +1,3 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0ZM7.1 11.7L2.9 7.6L4.3 6.2L7 8.9L12 4L13.4 5.4L7.1 11.7Z" fill="#4CAF50"/>
3
+ </svg>
@@ -0,0 +1,9 @@
1
+ import { componentName, UserAuthMethodClass } from './UserAuthMethodClass';
2
+ import '../descope-text';
3
+ import '../descope-button';
4
+ import '../descope-badge';
5
+ import '@vaadin/icon';
6
+
7
+ customElements.define(componentName, UserAuthMethodClass);
8
+
9
+ export { UserAuthMethodClass };
package/src/index.cjs.js CHANGED
@@ -39,6 +39,7 @@ 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
41
  export { UserAttributeClass } from './components/descope-user-attribute/UserAttributeClass';
42
+ export { UserAuthMethodClass } from './components/descope-user-auth-method/UserAuthMethodClass';
42
43
  export { MappingsFieldClass } from './components/mapping-fields/descope-mappings-field/MappingsFieldClass';
43
44
  export { SamlGroupMappingsClass } from './components/mapping-fields/descope-saml-group-mappings/SamlGroupMappingsClass';
44
45
  export { PolicyValidationClass } from './components/descope-policy-validation/PolicyValidationClass';
package/src/index.js CHANGED
@@ -34,6 +34,7 @@ export * from './components/descope-notification';
34
34
  export * from './components/descope-avatar';
35
35
  export * from './components/mapping-fields/descope-mappings-field';
36
36
  export * from './components/descope-user-attribute';
37
+ export * from './components/descope-user-auth-method';
37
38
  export * from './components/mapping-fields/descope-saml-group-mappings';
38
39
  export * from './components/descope-policy-validation';
39
40
 
@@ -33,6 +33,7 @@ import * as badge from './badge';
33
33
  import * as avatar from './avatar';
34
34
  import * as mappingsField from './mappingsField';
35
35
  import * as userAttribute from './userAttribute';
36
+ import * as userAuthMethod from './userAuthMethod';
36
37
  import * as samlGroupMappings from './samlGroupMappings';
37
38
  import * as policyValidation from './policyValidation';
38
39
 
@@ -73,6 +74,7 @@ const components = {
73
74
  avatar,
74
75
  mappingsField,
75
76
  userAttribute,
77
+ userAuthMethod,
76
78
  samlGroupMappings,
77
79
  policyValidation,
78
80
  };
@@ -0,0 +1,19 @@
1
+ import globals from '../globals';
2
+ import { UserAuthMethodClass } from '../../components/descope-user-auth-method/UserAuthMethodClass';
3
+ import { getThemeRefs } from '../../helpers/themeHelpers';
4
+
5
+ const globalRefs = getThemeRefs(globals);
6
+ export const vars = UserAuthMethodClass.cssVarList;
7
+
8
+ const userAuthMethod = {
9
+ [vars.hostDirection]: globalRefs.direction,
10
+ [vars.labelTextWidth]: '200px',
11
+ [vars.itemsGap]: '16px',
12
+ [vars.hostMinWidth]: '530px',
13
+ [vars.iconSize]: '24px',
14
+ _fullWidth: {
15
+ [vars.hostWidth]: '100%',
16
+ },
17
+ };
18
+
19
+ export default userAuthMethod;