@descope/flow-components 3.27.4 → 3.27.6

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.
@@ -5,7 +5,7 @@
5
5
  "name": "flowComponents",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "3.27.4",
8
+ "buildVersion": "3.27.6",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
@@ -5,7 +5,7 @@
5
5
  "name": "flowComponents",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "3.27.4",
8
+ "buildVersion": "3.27.6",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
package/dist/index.cjs.js CHANGED
@@ -83983,6 +83983,16 @@ function requireIndex_cjs () {
83983
83983
 
83984
83984
  const componentName$1s = getComponentName('enriched-text');
83985
83985
 
83986
+ const sanitizeConfig = {
83987
+ ADD_ATTR: ['target'],
83988
+ // Same scheme rule as markdown-it's link check, so custom-scheme links
83989
+ // (myapp://, slack://) keep working; DOMPurify's default list strips them.
83990
+ // `i` because markdown-it lowercases the URL before testing and DOMPurify does not.
83991
+ ALLOWED_URI_REGEXP:
83992
+ /^(?!(?:vbscript|javascript|file|data):)|^data:image\/(?:gif|png|jpeg|webp);/i,
83993
+ FORBID_TAGS: ['form', 'input', 'button', 'textarea', 'select', 'style'],
83994
+ };
83995
+
83986
83996
  class EnrichedText extends createBaseClass$1({
83987
83997
  componentName: componentName$1s,
83988
83998
  baseSelector: ':host > div',
@@ -84178,8 +84188,10 @@ function requireIndex_cjs () {
84178
84188
  console.warn('Not parsing invalid markdown token');
84179
84189
  }
84180
84190
 
84191
+ html = DOMPurify.sanitize(html, sanitizeConfig);
84192
+
84181
84193
  this.contentNode.innerHTML = html;
84182
- this.contentNode.firstChild?.setAttribute('part', 'content');
84194
+ this.contentNode.firstElementChild?.setAttribute('part', 'content');
84183
84195
  }
84184
84196
 
84185
84197
  onReadOnlyChange(isReadOnly) {
@@ -89311,7 +89323,7 @@ function requireIndex_cjs () {
89311
89323
  baseSelector: 'slot',
89312
89324
  }) {
89313
89325
  static get observedAttributes() {
89314
- return ['collapsed', 'collapsible', 'text'];
89326
+ return ['collapsed', 'collapsible', 'text', 'aria-label'];
89315
89327
  }
89316
89328
 
89317
89329
  constructor() {
@@ -89422,7 +89434,31 @@ function requireIndex_cjs () {
89422
89434
  this.setAttribute('collapsed', this.isCollapsed ? 'false' : 'true');
89423
89435
  }
89424
89436
 
89437
+ // header acts as a disclosure button only when the container is collapsible
89438
+ updateHeaderA11y() {
89439
+ if (!this.isCollapsible) {
89440
+ ['role', 'tabindex', 'aria-expanded', 'aria-label'].forEach((attr) =>
89441
+ this.header.removeAttribute(attr),
89442
+ );
89443
+ return;
89444
+ }
89445
+ this.header.setAttribute('role', 'button');
89446
+ this.header.setAttribute('tabindex', '0');
89447
+ this.header.setAttribute('aria-expanded', String(!this.isCollapsed));
89448
+ // without header text the button has no name, so fall back to a label
89449
+ if (this.getAttribute('text')) {
89450
+ this.header.removeAttribute('aria-label');
89451
+ } else {
89452
+ this.header.setAttribute(
89453
+ 'aria-label',
89454
+ this.getAttribute('aria-label') || 'Toggle section',
89455
+ );
89456
+ }
89457
+ }
89458
+
89425
89459
  collapse(animated = false) {
89460
+ // keep collapsed content out of the tab order and the a11y tree
89461
+ this.content.inert = true;
89426
89462
  const final = () => {
89427
89463
  this.content.style.maxHeight = '0px';
89428
89464
  };
@@ -89434,6 +89470,7 @@ function requireIndex_cjs () {
89434
89470
  }
89435
89471
 
89436
89472
  expand(animated = false) {
89473
+ this.content.inert = false;
89437
89474
  const final = () => {
89438
89475
  this.content.style.maxHeight = '';
89439
89476
  };
@@ -89456,6 +89493,13 @@ function requireIndex_cjs () {
89456
89493
  if (!this.isCollapsible) return;
89457
89494
  this.toggle();
89458
89495
  });
89496
+ this.header.addEventListener('keydown', (e) => {
89497
+ if (!this.isCollapsible || (e.key !== 'Enter' && e.key !== ' ')) return;
89498
+ e.preventDefault();
89499
+ // the SDK submits the flow on any Enter that reaches the flow root
89500
+ e.stopPropagation();
89501
+ this.toggle();
89502
+ });
89459
89503
  forwardAttrs(this, this.textComponent, {
89460
89504
  includeAttrs: ['text-align', 'text-variant', 'text-mode'],
89461
89505
  mapAttrs: { 'text-mode': 'mode', 'text-variant': 'variant' },
@@ -89470,8 +89514,14 @@ function requireIndex_cjs () {
89470
89514
  attributeChangedCallback(name, oldValue, newValue) {
89471
89515
  if (name === 'text') {
89472
89516
  this.updateHeaderText();
89517
+ this.updateHeaderA11y();
89518
+ return;
89519
+ }
89520
+ if (name === 'aria-label') {
89521
+ this.updateHeaderA11y();
89473
89522
  return;
89474
89523
  }
89524
+ this.updateHeaderA11y();
89475
89525
  const collapsed = this.isCollapsed && this.isCollapsible;
89476
89526
  if (collapsed) {
89477
89527
  this.collapse(this.#isComponentMounted);
@@ -94639,6 +94689,7 @@ function requireIndex_cjs () {
94639
94689
  renderCopyToClipboard(shouldRender) {
94640
94690
  if (!shouldRender) {
94641
94691
  this.icon?.remove();
94692
+ this.copyLiveRegion?.remove();
94642
94693
  return;
94643
94694
  }
94644
94695
 
@@ -94654,20 +94705,53 @@ function requireIndex_cjs () {
94654
94705
  style: 'cursor: initial',
94655
94706
  };
94656
94707
 
94708
+ const setIconState = (config) => {
94709
+ Object.assign(this.icon, config);
94710
+ this.icon.setAttribute('aria-label', config.title);
94711
+ };
94712
+
94657
94713
  this.icon = Object.assign(document.createElement('vaadin-icon'), {
94658
94714
  slot: 'suffix',
94659
- ...iconInitConfig,
94715
+ tabIndex: 0,
94660
94716
  });
94717
+ this.icon.setAttribute('role', 'button');
94718
+ setIconState(iconInitConfig);
94719
+
94720
+ // visually hidden live region, so screen readers announce the copy
94721
+ this.copyLiveRegion = document.createElement('span');
94722
+ this.copyLiveRegion.setAttribute('aria-live', 'polite');
94723
+ this.copyLiveRegion.style.cssText =
94724
+ 'position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;';
94661
94725
 
94662
94726
  this.baseElement.appendChild(this.icon);
94663
- this.icon.addEventListener('click', () => {
94664
- navigator.clipboard.writeText(this.value);
94665
- Object.assign(this.icon, iconCopiedConfig);
94727
+ this.shadowRoot.appendChild(this.copyLiveRegion);
94666
94728
 
94667
- // we want the icon to go back to the initial state after 5 seconds
94668
- setTimeout(() => {
94669
- Object.assign(this.icon, iconInitConfig);
94670
- }, 5000);
94729
+ let resetTimer;
94730
+ const copy = async () => {
94731
+ try {
94732
+ await navigator.clipboard.writeText(this.value);
94733
+ } catch {
94734
+ return;
94735
+ }
94736
+ setIconState(iconCopiedConfig);
94737
+ this.copyLiveRegion.textContent = 'Copied';
94738
+
94739
+ // we want the icon to go back to the initial state after 3 seconds
94740
+ // a repeated copy restarts the countdown
94741
+ clearTimeout(resetTimer);
94742
+ resetTimer = setTimeout(() => {
94743
+ setIconState(iconInitConfig);
94744
+ this.copyLiveRegion.textContent = '';
94745
+ }, 3000);
94746
+ };
94747
+
94748
+ this.icon.addEventListener('click', copy);
94749
+ this.icon.addEventListener('keydown', (e) => {
94750
+ if (e.key !== 'Enter' && e.key !== ' ') return;
94751
+ e.preventDefault();
94752
+ // the SDK submits the flow on any Enter that reaches the flow root
94753
+ e.stopPropagation();
94754
+ copy();
94671
94755
  });
94672
94756
  }
94673
94757
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/flow-components",
3
- "version": "3.27.4",
3
+ "version": "3.27.6",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -98,7 +98,7 @@
98
98
  "webpack-subresource-integrity": "5.2.0-rc.1"
99
99
  },
100
100
  "dependencies": {
101
- "@descope/web-components-ui": "3.27.4"
101
+ "@descope/web-components-ui": "3.27.6"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "react": ">= 18"