@descope/flow-components 3.27.3 → 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.3",
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.3",
8
+ "buildVersion": "3.27.5",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
package/dist/index.cjs.js CHANGED
@@ -83604,7 +83604,7 @@ function requireIndex_cjs () {
83604
83604
  padding: 0;
83605
83605
  }
83606
83606
  `,
83607
- excludeAttrsSync: ['tabindex', 'class', 'style'],
83607
+ excludeAttrsSync: ['tabindex', 'class', 'style', 'role'],
83608
83608
  componentName: componentName$1u,
83609
83609
  }),
83610
83610
  );
@@ -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();
89506
+ return;
89507
+ }
89508
+ if (name === 'aria-label') {
89509
+ this.updateHeaderA11y();
89473
89510
  return;
89474
89511
  }
89512
+ this.updateHeaderA11y();
89475
89513
  const collapsed = this.isCollapsed && this.isCollapsible;
89476
89514
  if (collapsed) {
89477
89515
  this.collapse(this.#isComponentMounted);
@@ -92153,6 +92191,10 @@ function requireIndex_cjs () {
92153
92191
  this,
92154
92192
  );
92155
92193
 
92194
+ // vaadin links the target via aria-describedby to its sr-label, which lives in our shadow root,
92195
+ // so a slotted target would reference an ID from another DOM tree.
92196
+ this.tooltip.ariaTarget = this.anchored;
92197
+
92156
92198
  this.defaultSlot.addEventListener('slotchange', () =>
92157
92199
  this.#setTooltipTarget(),
92158
92200
  );
@@ -94635,6 +94677,7 @@ function requireIndex_cjs () {
94635
94677
  renderCopyToClipboard(shouldRender) {
94636
94678
  if (!shouldRender) {
94637
94679
  this.icon?.remove();
94680
+ this.copyLiveRegion?.remove();
94638
94681
  return;
94639
94682
  }
94640
94683
 
@@ -94650,20 +94693,53 @@ function requireIndex_cjs () {
94650
94693
  style: 'cursor: initial',
94651
94694
  };
94652
94695
 
94696
+ const setIconState = (config) => {
94697
+ Object.assign(this.icon, config);
94698
+ this.icon.setAttribute('aria-label', config.title);
94699
+ };
94700
+
94653
94701
  this.icon = Object.assign(document.createElement('vaadin-icon'), {
94654
94702
  slot: 'suffix',
94655
- ...iconInitConfig,
94703
+ tabIndex: 0,
94656
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;';
94657
94713
 
94658
94714
  this.baseElement.appendChild(this.icon);
94659
- this.icon.addEventListener('click', () => {
94660
- navigator.clipboard.writeText(this.value);
94661
- Object.assign(this.icon, iconCopiedConfig);
94715
+ this.shadowRoot.appendChild(this.copyLiveRegion);
94662
94716
 
94663
- // we want the icon to go back to the initial state after 5 seconds
94664
- setTimeout(() => {
94665
- Object.assign(this.icon, iconInitConfig);
94666
- }, 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();
94667
94743
  });
94668
94744
  }
94669
94745
 
@@ -102269,6 +102345,7 @@ descope-enriched-text {
102269
102345
  tabindex="-1"
102270
102346
  slot="input"
102271
102347
  role="textbox"
102348
+ aria-label="passcode"
102272
102349
  ><slot></slot></${componentName$F}>
102273
102350
  `;
102274
102351
 
@@ -105226,7 +105303,7 @@ descope-enriched-text {
105226
105303
  </div>
105227
105304
  <div class="description"></div>
105228
105305
  <div class="button-wrapper">
105229
- <input type="file" tabindex="-1" aria-labelledby="button"/>
105306
+ <input type="file" tabindex="-1" aria-hidden="true"/>
105230
105307
  <descope-button id="button"></descope-button>
105231
105308
  </div>
105232
105309
  </div>
@@ -114173,12 +114250,19 @@ const Tooltip = React__default.default.forwardRef(({ text, hideDelay = 0, hoverD
114173
114250
 
114174
114251
  const Button = React__default.default.forwardRef(({
114175
114252
  // Button props
114176
- children, startIcon, startIconDark, startIconColorText, color = 'primary', size = 'md', variant = 'contained', 'data-name': dataName,
114253
+ children, startIcon, startIconDark, startIconColorText, color = 'primary', size = 'md', variant = 'contained', 'data-name': dataName, ariaLabel,
114177
114254
  // Tooltip props
114178
114255
  hasTooltip, tooltipText, tooltipPosition, tooltipHoverDelay, tooltipHideDelay, tooltipOpened, tooltipReadOnly, ...props }, ref) => {
114179
114256
  const isSquare = React.useMemo(() => !!(startIcon && !children), [startIcon, children]);
114257
+ const tooltipLabel = tooltipText?.trim();
114258
+ const fallbackLabel = isSquare &&
114259
+ hasTooltip &&
114260
+ tooltipLabel &&
114261
+ !/[*_`~[\]<>#\\]/.test(tooltipLabel)
114262
+ ? tooltipLabel
114263
+ : undefined;
114180
114264
  return (React__default.default.createElement(Tooltip, { text: hasTooltip ? tooltipText : undefined, position: tooltipPosition, hoverDelay: tooltipHoverDelay, hideDelay: tooltipHideDelay, opened: tooltipOpened, readonly: tooltipReadOnly },
114181
- React__default.default.createElement("descope-button", { ...props, size: size, variant: variant, mode: color, ref: ref, square: isSquare, "data-name": dataName },
114265
+ React__default.default.createElement("descope-button", { ...props, size: size, variant: variant, mode: color, ref: ref, square: isSquare, "data-name": dataName, "aria-label": ariaLabel || props['aria-label'] || fallbackLabel },
114182
114266
  startIcon != null && (React__default.default.createElement(Icon, { "data-name": `${dataName}-icon`, icon: startIcon, "src-dark": startIconDark, noColor: startIconColorText })),
114183
114267
  children)));
114184
114268
  });
package/dist/index.d.ts CHANGED
@@ -196,6 +196,7 @@ declare const Button: React.ForwardRefExoticComponent<Omit<React.ClassAttributes
196
196
  startIconColorText?: boolean;
197
197
  'full-width'?: boolean;
198
198
  'data-name'?: string;
199
+ ariaLabel?: string;
199
200
  } & ITooltip, "ref"> & React.RefAttributes<HTMLButtonElement>>;
200
201
 
201
202
  type Props$R = {
package/dist/index.esm.js CHANGED
@@ -167,12 +167,19 @@ const Tooltip = React.forwardRef(({ text, hideDelay = 0, hoverDelay = 0, childre
167
167
 
168
168
  const Button = React.forwardRef(({
169
169
  // Button props
170
- children, startIcon, startIconDark, startIconColorText, color = 'primary', size = 'md', variant = 'contained', 'data-name': dataName,
170
+ children, startIcon, startIconDark, startIconColorText, color = 'primary', size = 'md', variant = 'contained', 'data-name': dataName, ariaLabel,
171
171
  // Tooltip props
172
172
  hasTooltip, tooltipText, tooltipPosition, tooltipHoverDelay, tooltipHideDelay, tooltipOpened, tooltipReadOnly, ...props }, ref) => {
173
173
  const isSquare = useMemo(() => !!(startIcon && !children), [startIcon, children]);
174
+ const tooltipLabel = tooltipText?.trim();
175
+ const fallbackLabel = isSquare &&
176
+ hasTooltip &&
177
+ tooltipLabel &&
178
+ !/[*_`~[\]<>#\\]/.test(tooltipLabel)
179
+ ? tooltipLabel
180
+ : undefined;
174
181
  return (React.createElement(Tooltip, { text: hasTooltip ? tooltipText : undefined, position: tooltipPosition, hoverDelay: tooltipHoverDelay, hideDelay: tooltipHideDelay, opened: tooltipOpened, readonly: tooltipReadOnly },
175
- React.createElement("descope-button", { ...props, size: size, variant: variant, mode: color, ref: ref, square: isSquare, "data-name": dataName },
182
+ React.createElement("descope-button", { ...props, size: size, variant: variant, mode: color, ref: ref, square: isSquare, "data-name": dataName, "aria-label": ariaLabel || props['aria-label'] || fallbackLabel },
176
183
  startIcon != null && (React.createElement(Icon, { "data-name": `${dataName}-icon`, icon: startIcon, "src-dark": startIconDark, noColor: startIconColorText })),
177
184
  children)));
178
185
  });
@@ -22,5 +22,6 @@ declare const Button: React.ForwardRefExoticComponent<Omit<React.ClassAttributes
22
22
  startIconColorText?: boolean;
23
23
  'full-width'?: boolean;
24
24
  'data-name'?: string;
25
+ ariaLabel?: string;
25
26
  } & ITooltip, "ref"> & React.RefAttributes<HTMLButtonElement>>;
26
27
  export default Button;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/flow-components",
3
- "version": "3.27.3",
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.3"
101
+ "@descope/web-components-ui": "3.27.5"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "react": ">= 18"