@descope/flow-components 3.27.4 → 3.27.5

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.5",
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.5",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
package/dist/index.cjs.js CHANGED
@@ -89311,7 +89311,7 @@ function requireIndex_cjs () {
89311
89311
  baseSelector: 'slot',
89312
89312
  }) {
89313
89313
  static get observedAttributes() {
89314
- return ['collapsed', 'collapsible', 'text'];
89314
+ return ['collapsed', 'collapsible', 'text', 'aria-label'];
89315
89315
  }
89316
89316
 
89317
89317
  constructor() {
@@ -89422,7 +89422,31 @@ function requireIndex_cjs () {
89422
89422
  this.setAttribute('collapsed', this.isCollapsed ? 'false' : 'true');
89423
89423
  }
89424
89424
 
89425
+ // header acts as a disclosure button only when the container is collapsible
89426
+ updateHeaderA11y() {
89427
+ if (!this.isCollapsible) {
89428
+ ['role', 'tabindex', 'aria-expanded', 'aria-label'].forEach((attr) =>
89429
+ this.header.removeAttribute(attr),
89430
+ );
89431
+ return;
89432
+ }
89433
+ this.header.setAttribute('role', 'button');
89434
+ this.header.setAttribute('tabindex', '0');
89435
+ this.header.setAttribute('aria-expanded', String(!this.isCollapsed));
89436
+ // without header text the button has no name, so fall back to a label
89437
+ if (this.getAttribute('text')) {
89438
+ this.header.removeAttribute('aria-label');
89439
+ } else {
89440
+ this.header.setAttribute(
89441
+ 'aria-label',
89442
+ this.getAttribute('aria-label') || 'Toggle section',
89443
+ );
89444
+ }
89445
+ }
89446
+
89425
89447
  collapse(animated = false) {
89448
+ // keep collapsed content out of the tab order and the a11y tree
89449
+ this.content.inert = true;
89426
89450
  const final = () => {
89427
89451
  this.content.style.maxHeight = '0px';
89428
89452
  };
@@ -89434,6 +89458,7 @@ function requireIndex_cjs () {
89434
89458
  }
89435
89459
 
89436
89460
  expand(animated = false) {
89461
+ this.content.inert = false;
89437
89462
  const final = () => {
89438
89463
  this.content.style.maxHeight = '';
89439
89464
  };
@@ -89456,6 +89481,13 @@ function requireIndex_cjs () {
89456
89481
  if (!this.isCollapsible) return;
89457
89482
  this.toggle();
89458
89483
  });
89484
+ this.header.addEventListener('keydown', (e) => {
89485
+ if (!this.isCollapsible || (e.key !== 'Enter' && e.key !== ' ')) return;
89486
+ e.preventDefault();
89487
+ // the SDK submits the flow on any Enter that reaches the flow root
89488
+ e.stopPropagation();
89489
+ this.toggle();
89490
+ });
89459
89491
  forwardAttrs(this, this.textComponent, {
89460
89492
  includeAttrs: ['text-align', 'text-variant', 'text-mode'],
89461
89493
  mapAttrs: { 'text-mode': 'mode', 'text-variant': 'variant' },
@@ -89470,8 +89502,14 @@ function requireIndex_cjs () {
89470
89502
  attributeChangedCallback(name, oldValue, newValue) {
89471
89503
  if (name === 'text') {
89472
89504
  this.updateHeaderText();
89505
+ this.updateHeaderA11y();
89473
89506
  return;
89474
89507
  }
89508
+ if (name === 'aria-label') {
89509
+ this.updateHeaderA11y();
89510
+ return;
89511
+ }
89512
+ this.updateHeaderA11y();
89475
89513
  const collapsed = this.isCollapsed && this.isCollapsible;
89476
89514
  if (collapsed) {
89477
89515
  this.collapse(this.#isComponentMounted);
@@ -94639,6 +94677,7 @@ function requireIndex_cjs () {
94639
94677
  renderCopyToClipboard(shouldRender) {
94640
94678
  if (!shouldRender) {
94641
94679
  this.icon?.remove();
94680
+ this.copyLiveRegion?.remove();
94642
94681
  return;
94643
94682
  }
94644
94683
 
@@ -94654,20 +94693,53 @@ function requireIndex_cjs () {
94654
94693
  style: 'cursor: initial',
94655
94694
  };
94656
94695
 
94696
+ const setIconState = (config) => {
94697
+ Object.assign(this.icon, config);
94698
+ this.icon.setAttribute('aria-label', config.title);
94699
+ };
94700
+
94657
94701
  this.icon = Object.assign(document.createElement('vaadin-icon'), {
94658
94702
  slot: 'suffix',
94659
- ...iconInitConfig,
94703
+ tabIndex: 0,
94660
94704
  });
94705
+ this.icon.setAttribute('role', 'button');
94706
+ setIconState(iconInitConfig);
94707
+
94708
+ // visually hidden live region, so screen readers announce the copy
94709
+ this.copyLiveRegion = document.createElement('span');
94710
+ this.copyLiveRegion.setAttribute('aria-live', 'polite');
94711
+ this.copyLiveRegion.style.cssText =
94712
+ 'position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;';
94661
94713
 
94662
94714
  this.baseElement.appendChild(this.icon);
94663
- this.icon.addEventListener('click', () => {
94664
- navigator.clipboard.writeText(this.value);
94665
- Object.assign(this.icon, iconCopiedConfig);
94715
+ this.shadowRoot.appendChild(this.copyLiveRegion);
94666
94716
 
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);
94717
+ let resetTimer;
94718
+ const copy = async () => {
94719
+ try {
94720
+ await navigator.clipboard.writeText(this.value);
94721
+ } catch {
94722
+ return;
94723
+ }
94724
+ setIconState(iconCopiedConfig);
94725
+ this.copyLiveRegion.textContent = 'Copied';
94726
+
94727
+ // we want the icon to go back to the initial state after 3 seconds
94728
+ // a repeated copy restarts the countdown
94729
+ clearTimeout(resetTimer);
94730
+ resetTimer = setTimeout(() => {
94731
+ setIconState(iconInitConfig);
94732
+ this.copyLiveRegion.textContent = '';
94733
+ }, 3000);
94734
+ };
94735
+
94736
+ this.icon.addEventListener('click', copy);
94737
+ this.icon.addEventListener('keydown', (e) => {
94738
+ if (e.key !== 'Enter' && e.key !== ' ') return;
94739
+ e.preventDefault();
94740
+ // the SDK submits the flow on any Enter that reaches the flow root
94741
+ e.stopPropagation();
94742
+ copy();
94671
94743
  });
94672
94744
  }
94673
94745
 
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.5",
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.5"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "react": ">= 18"