@descope/web-components-ui 3.16.3 → 3.17.0
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.
- package/dist/cjs/index.cjs.js +104 -8
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +104 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/umd/DescopeDev.js +1 -1
- package/dist/umd/DescopeDev.js.map +1 -1
- package/dist/umd/descope-hybrid-field-index-js.js +1 -1
- package/dist/umd/descope-hybrid-field-index-js.js.map +1 -1
- package/dist/umd/descope-user-attribute-index-js.js +2 -2
- package/dist/umd/descope-user-attribute-index-js.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/package.json +41 -41
- package/src/components/descope-hybrid-field/HybridFieldClass.js +11 -2
- package/src/components/descope-user-attribute/UserAttributeClass.js +91 -6
- package/src/components/descope-user-attribute/check.svg +3 -0
- package/src/components/descope-user-attribute/copy.svg +3 -0
- package/stories/descope-user-attribute.stories.js +12 -0
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -24032,6 +24032,10 @@ var deleteIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTQiIGhlaWdodD0iMTgi
|
|
|
24032
24032
|
|
|
24033
24033
|
var editIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxNSAxNSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBkPSJNMTAuMDAwMiAwLjk5MjE0OUMxMC4wMDAyIDEuMDE2MTUgMTAuMDAwMiAxLjAxNjE1IDEwLjAwMDIgMS4wMTYxNUw4LjIyNDE5IDMuMDA4MTVIMi45OTIxOUMyLjQ2NDE5IDMuMDA4MTUgMi4wMDgxOSAzLjQ0MDE1IDIuMDA4MTkgMy45OTIxNVYxMi4wMDgyQzIuMDA4MTkgMTIuNTM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4MTVMMTEuOTIwMiAxLjg1NjE1WiIgZmlsbD0iY3VycmVudGNvbG9yIi8+Cjwvc3ZnPgo=";
|
|
24034
24034
|
|
|
24035
|
+
var copyIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBkPSJNMTYgMUg0Yy0xLjEgMC0yIC45LTIgMnYxNGgyVjNoMTJWMXptMyA0SDhjLTEuMSAwLTIgLjktMiAydjE0YzAgMS4xLjkgMiAyIDJoMTFjMS4xIDAgMi0uOSAyLTJWN2MwLTEuMS0uOS0yLTItMnptMCAxNkg4VjdoMTF2MTR6IiBmaWxsPSJjdXJyZW50Y29sb3IiLz4KPC9zdmc+Cg==";
|
|
24036
|
+
|
|
24037
|
+
var checkIcon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBkPSJNOSAxNi4xNyA0LjgzIDEybC0xLjQyIDEuNDFMOSAxOSAyMSA3bC0xLjQxLTEuNDF6IiBmaWxsPSJjdXJyZW50Y29sb3IiLz4KPC9zdmc+Cg==";
|
|
24038
|
+
|
|
24035
24039
|
const componentName$j = getComponentName$1('user-attribute');
|
|
24036
24040
|
class RawUserAttribute extends createBaseClass({
|
|
24037
24041
|
componentName: componentName$j,
|
|
@@ -24047,6 +24051,10 @@ class RawUserAttribute extends createBaseClass({
|
|
|
24047
24051
|
<descope-text st-text-align="auto" data-id="value-text" variant="body1" mode="primary" class="value"></descope-text>
|
|
24048
24052
|
<div class="btn-wrapper">
|
|
24049
24053
|
<descope-badge mode="default" bordered="true" size="xs"></descope-badge>
|
|
24054
|
+
<descope-button size="sm" data-id="copy-btn" variant="link" mode="primary">
|
|
24055
|
+
<slot name="copy-icon"></slot>
|
|
24056
|
+
<descope-icon class="check-icon" src="${checkIcon}" src-dark="${checkIcon}"></descope-icon>
|
|
24057
|
+
</descope-button>
|
|
24050
24058
|
<descope-button size="sm" data-id="delete-btn" variant="link" mode="primary">
|
|
24051
24059
|
<slot name="delete-icon"></slot>
|
|
24052
24060
|
</descope-button>
|
|
@@ -24093,12 +24101,29 @@ class RawUserAttribute extends createBaseClass({
|
|
|
24093
24101
|
}
|
|
24094
24102
|
|
|
24095
24103
|
slot[name="edit-icon"],
|
|
24096
|
-
slot[name="delete-icon"]
|
|
24104
|
+
slot[name="delete-icon"],
|
|
24105
|
+
slot[name="copy-icon"] {
|
|
24097
24106
|
display: inline-flex;
|
|
24098
24107
|
flex-shrink: 0;
|
|
24099
24108
|
align-items: center;
|
|
24100
24109
|
}
|
|
24101
24110
|
|
|
24111
|
+
descope-button[data-id="copy-btn"].hidden {
|
|
24112
|
+
display: none;
|
|
24113
|
+
}
|
|
24114
|
+
|
|
24115
|
+
descope-button[data-id="copy-btn"] .check-icon {
|
|
24116
|
+
display: none;
|
|
24117
|
+
}
|
|
24118
|
+
|
|
24119
|
+
descope-button[data-id="copy-btn"].copied slot[name="copy-icon"] {
|
|
24120
|
+
display: none;
|
|
24121
|
+
}
|
|
24122
|
+
|
|
24123
|
+
descope-button[data-id="copy-btn"].copied .check-icon {
|
|
24124
|
+
display: inline-flex;
|
|
24125
|
+
}
|
|
24126
|
+
|
|
24102
24127
|
.content-wrapper {
|
|
24103
24128
|
display: flex;
|
|
24104
24129
|
flex-grow: 1;
|
|
@@ -24141,7 +24166,7 @@ class RawUserAttribute extends createBaseClass({
|
|
|
24141
24166
|
color: var(${TextClass.cssVarList.textColor});
|
|
24142
24167
|
}
|
|
24143
24168
|
|
|
24144
|
-
:host([readonly="true"]) descope-button {
|
|
24169
|
+
:host([readonly="true"]) descope-button:not([data-id="copy-btn"]) {
|
|
24145
24170
|
visibility: hidden;
|
|
24146
24171
|
width: 0;
|
|
24147
24172
|
}
|
|
@@ -24149,6 +24174,7 @@ class RawUserAttribute extends createBaseClass({
|
|
|
24149
24174
|
this
|
|
24150
24175
|
);
|
|
24151
24176
|
|
|
24177
|
+
this.copyButton = this.shadowRoot.querySelector('descope-button[data-id="copy-btn"]');
|
|
24152
24178
|
this.deleteButton = this.shadowRoot.querySelector('descope-button[data-id="delete-btn"]');
|
|
24153
24179
|
this.editButton = this.shadowRoot.querySelector('descope-button[data-id="edit-btn"]');
|
|
24154
24180
|
this.badge = this.shadowRoot.querySelector('descope-badge');
|
|
@@ -24238,6 +24264,14 @@ class RawUserAttribute extends createBaseClass({
|
|
|
24238
24264
|
return this.getAttribute('hide-delete') === 'true';
|
|
24239
24265
|
}
|
|
24240
24266
|
|
|
24267
|
+
get isCopyEnabled() {
|
|
24268
|
+
return this.getAttribute('show-copy') === 'true';
|
|
24269
|
+
}
|
|
24270
|
+
|
|
24271
|
+
get copyButtonLabel() {
|
|
24272
|
+
return this.getAttribute('copy-button-label') || '';
|
|
24273
|
+
}
|
|
24274
|
+
|
|
24241
24275
|
init() {
|
|
24242
24276
|
this.onLabelChange();
|
|
24243
24277
|
this.onValueOrPlaceholderChange();
|
|
@@ -24246,7 +24280,9 @@ class RawUserAttribute extends createBaseClass({
|
|
|
24246
24280
|
this.onBadgeTooltipTextChange();
|
|
24247
24281
|
this.updateButtonLabel(this.editButton, this.editButtonLabel);
|
|
24248
24282
|
this.updateButtonLabel(this.deleteButton, this.deleteButtonLabel);
|
|
24283
|
+
this.updateButtonLabel(this.copyButton, this.copyButtonLabel);
|
|
24249
24284
|
this.handleDeleteButtonVisibility();
|
|
24285
|
+
this.handleCopyButtonState();
|
|
24250
24286
|
|
|
24251
24287
|
this.deleteButton.addEventListener('click', () =>
|
|
24252
24288
|
this.dispatchEvent(new CustomEvent('delete-clicked', { bubbles: true, composed: true }))
|
|
@@ -24256,9 +24292,35 @@ class RawUserAttribute extends createBaseClass({
|
|
|
24256
24292
|
this.dispatchEvent(new CustomEvent('edit-clicked', { bubbles: true, composed: true }))
|
|
24257
24293
|
);
|
|
24258
24294
|
|
|
24295
|
+
this.copyButton.addEventListener('click', () => this.#handleCopyClick());
|
|
24296
|
+
|
|
24259
24297
|
this.setDefaultChildren();
|
|
24260
24298
|
}
|
|
24261
24299
|
|
|
24300
|
+
#handleCopyClick() {
|
|
24301
|
+
// isDraggable is true only inside the page editor (craftjs sets draggable="true"
|
|
24302
|
+
// for drag-and-drop); there the copy action must not run.
|
|
24303
|
+
if (!this.value || this.isDraggable || !navigator.clipboard) return;
|
|
24304
|
+
|
|
24305
|
+
navigator.clipboard
|
|
24306
|
+
.writeText(this.value)
|
|
24307
|
+
.then(() => {
|
|
24308
|
+
this.copyButton.classList.add('copied');
|
|
24309
|
+
setTimeout(() => this.copyButton.classList.remove('copied'), 2000);
|
|
24310
|
+
})
|
|
24311
|
+
.catch(() => {});
|
|
24312
|
+
}
|
|
24313
|
+
|
|
24314
|
+
handleCopyButtonState() {
|
|
24315
|
+
this.copyButton.classList.toggle('hidden', !this.isCopyEnabled);
|
|
24316
|
+
|
|
24317
|
+
if (this.value) {
|
|
24318
|
+
this.copyButton.removeAttribute('disabled');
|
|
24319
|
+
} else {
|
|
24320
|
+
this.copyButton.setAttribute('disabled', 'true');
|
|
24321
|
+
}
|
|
24322
|
+
}
|
|
24323
|
+
|
|
24262
24324
|
#addIcon(src, slotName) {
|
|
24263
24325
|
const icon = document.createElement('descope-icon');
|
|
24264
24326
|
icon.setAttribute('src', src);
|
|
@@ -24268,9 +24330,19 @@ class RawUserAttribute extends createBaseClass({
|
|
|
24268
24330
|
}
|
|
24269
24331
|
|
|
24270
24332
|
setDefaultChildren() {
|
|
24271
|
-
if (this.
|
|
24272
|
-
|
|
24273
|
-
|
|
24333
|
+
if (!this.querySelector('[slot="delete-icon"]')) {
|
|
24334
|
+
this.#addIcon(deleteIcon, 'delete-icon');
|
|
24335
|
+
}
|
|
24336
|
+
if (!this.querySelector('[slot="edit-icon"]')) {
|
|
24337
|
+
this.#addIcon(editIcon, 'edit-icon');
|
|
24338
|
+
}
|
|
24339
|
+
this.setDefaultCopyIcon();
|
|
24340
|
+
}
|
|
24341
|
+
|
|
24342
|
+
setDefaultCopyIcon() {
|
|
24343
|
+
if (this.isCopyEnabled && !this.querySelector('[slot="copy-icon"]')) {
|
|
24344
|
+
this.#addIcon(copyIcon, 'copy-icon');
|
|
24345
|
+
}
|
|
24274
24346
|
}
|
|
24275
24347
|
|
|
24276
24348
|
static get observedAttributes() {
|
|
@@ -24283,7 +24355,9 @@ class RawUserAttribute extends createBaseClass({
|
|
|
24283
24355
|
'badge-tooltip-text',
|
|
24284
24356
|
'edit-button-label',
|
|
24285
24357
|
'delete-button-label',
|
|
24358
|
+
'copy-button-label',
|
|
24286
24359
|
'hide-delete',
|
|
24360
|
+
'show-copy',
|
|
24287
24361
|
].concat(super.observedAttributes);
|
|
24288
24362
|
}
|
|
24289
24363
|
|
|
@@ -24315,11 +24389,19 @@ class RawUserAttribute extends createBaseClass({
|
|
|
24315
24389
|
this.updateButtonLabel(this.editButton, this.editButtonLabel);
|
|
24316
24390
|
} else if (name === 'delete-button-label') {
|
|
24317
24391
|
this.updateButtonLabel(this.deleteButton, this.deleteButtonLabel);
|
|
24392
|
+
} else if (name === 'copy-button-label') {
|
|
24393
|
+
this.updateButtonLabel(this.copyButton, this.copyButtonLabel);
|
|
24394
|
+
} else if (name === 'show-copy') {
|
|
24395
|
+
this.setDefaultCopyIcon();
|
|
24318
24396
|
}
|
|
24319
24397
|
|
|
24320
24398
|
if (name === 'value' || name === 'required' || name === 'hide-delete') {
|
|
24321
24399
|
this.handleDeleteButtonVisibility();
|
|
24322
24400
|
}
|
|
24401
|
+
|
|
24402
|
+
if (name === 'value' || name === 'show-copy') {
|
|
24403
|
+
this.handleCopyButtonState();
|
|
24404
|
+
}
|
|
24323
24405
|
}
|
|
24324
24406
|
}
|
|
24325
24407
|
|
|
@@ -24348,7 +24430,12 @@ const UserAttributeClass = compose$1(
|
|
|
24348
24430
|
contentMinWidth: { ...contentWrapper, property: 'min-width' },
|
|
24349
24431
|
badgeMaxWidth: { ...badge$1, property: 'max-width' },
|
|
24350
24432
|
itemsGap: [{ property: 'gap' }, { ...contentWrapper, property: 'gap' }],
|
|
24351
|
-
iconColor: [
|
|
24433
|
+
iconColor: [
|
|
24434
|
+
{ selector: () => '::slotted(*)', property: IconClass.cssVarList.fill },
|
|
24435
|
+
// the copied check-icon lives in the shadow DOM (not slotted), so it
|
|
24436
|
+
// needs its own mapping to follow the same icon color
|
|
24437
|
+
{ selector: () => '.check-icon', property: IconClass.cssVarList.fill },
|
|
24438
|
+
],
|
|
24352
24439
|
},
|
|
24353
24440
|
}),
|
|
24354
24441
|
draggableMixin,
|
|
@@ -29010,8 +29097,17 @@ class RawHybridField extends BaseClass$2 {
|
|
|
29010
29097
|
|
|
29011
29098
|
setActiveInputSelectionStart() {
|
|
29012
29099
|
setTimeout(() => {
|
|
29013
|
-
this.activeInputEle
|
|
29014
|
-
|
|
29100
|
+
const ele = this.activeInputEle;
|
|
29101
|
+
ele.focus();
|
|
29102
|
+
// setSelectionRange throws InvalidStateError on input types that do not
|
|
29103
|
+
// support selection (e.g. `email`). The focus handler usually switches
|
|
29104
|
+
// type to `text` first, but that can race with the blur timer or fail
|
|
29105
|
+
// to fire (e.g. background tab). Restoring the caret is best-effort.
|
|
29106
|
+
try {
|
|
29107
|
+
ele.setSelectionRange?.(this.#selectionStart, this.#selectionStart);
|
|
29108
|
+
} catch {
|
|
29109
|
+
/* noop */
|
|
29110
|
+
}
|
|
29015
29111
|
});
|
|
29016
29112
|
}
|
|
29017
29113
|
|