@descope/flow-components 3.2.2 → 3.3.1

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.2.2",
8
+ "buildVersion": "3.3.1",
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.2.2",
8
+ "buildVersion": "3.3.1",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
package/dist/index.cjs.js CHANGED
@@ -95199,6 +95199,7 @@ descope-enriched-text {
95199
95199
  'allow-alphanumeric-input',
95200
95200
  'format-value',
95201
95201
  'strict-validation',
95202
+ 'phone-input-type',
95202
95203
  ],
95203
95204
  });
95204
95205
  }
@@ -95545,6 +95546,7 @@ descope-enriched-text {
95545
95546
  'format-value',
95546
95547
  'strict-validation',
95547
95548
  'data-errormessage-type-mismatch',
95549
+ 'phone-input-type',
95548
95550
  ],
95549
95551
  });
95550
95552
  }
@@ -103808,6 +103810,7 @@ descope-enriched-text {
103808
103810
  'phone-minlength',
103809
103811
  'phone-format-value',
103810
103812
  'phone-strict-validation',
103813
+ 'phone-input-type',
103811
103814
  'data-errormessage-value-missing-phone',
103812
103815
  ],
103813
103816
  inputBox: [
@@ -103816,6 +103819,7 @@ descope-enriched-text {
103816
103819
  'phone-minlength',
103817
103820
  'phone-format-value',
103818
103821
  'phone-strict-validation',
103822
+ 'phone-input-type',
103819
103823
  'data-errormessage-value-missing-phone',
103820
103824
  ],
103821
103825
  },
@@ -103855,8 +103859,8 @@ descope-enriched-text {
103855
103859
  this.attachShadow({ mode: 'open' }).innerHTML = `
103856
103860
  <div class="wrapper">
103857
103861
  <descope-email-field external-input="${this.isExternalInput}"></descope-email-field>
103858
- <descope-phone-field allow-alphanumeric-input="true"></descope-phone-field>
103859
- <descope-phone-input-box-field allow-alphanumeric-input="true"></descope-phone-input-box-field>
103862
+ <descope-phone-field allow-alphanumeric-input="true" phone-input-type="text"></descope-phone-field>
103863
+ <descope-phone-input-box-field allow-alphanumeric-input="true" phone-input-type="text"></descope-phone-input-box-field>
103860
103864
  </div>
103861
103865
  `;
103862
103866
 
@@ -104694,7 +104698,7 @@ descope-enriched-text {
104694
104698
 
104695
104699
  const componentName$2 = getComponentName$1('recaptcha');
104696
104700
 
104697
- const observedAttributes = ['enabled', 'site-key', 'action', 'enterprise'];
104701
+ const observedAttributes = ['enabled', 'site-key', 'action', 'enterprise', 'variant'];
104698
104702
 
104699
104703
  const BaseClass$1 = createBaseClass({
104700
104704
  componentName: componentName$2,
@@ -104711,6 +104715,10 @@ descope-enriched-text {
104711
104715
  if (attrName === 'enabled') {
104712
104716
  this.#toggleRecaptcha(newValue === 'true');
104713
104717
  }
104718
+
104719
+ if (attrName === 'variant') {
104720
+ this.updatePreview();
104721
+ }
104714
104722
  }
104715
104723
  }
104716
104724
 
@@ -104723,13 +104731,37 @@ descope-enriched-text {
104723
104731
  this.toggleRecaptchaEles(enabled);
104724
104732
  }
104725
104733
 
104734
+ displayRecaptcha() {
104735
+ if (this.isWidget) {
104736
+ this.displayWidget();
104737
+ } else {
104738
+ this.displayDeprecated();
104739
+ }
104740
+ }
104741
+
104742
+ displayWidget() {
104743
+ this.mockRecaptchaEle.style.display = 'none';
104744
+ this.recaptchaWidgetEle.style.display = '';
104745
+ this.depercatedRecaptchaEle.style.display = 'none';
104746
+ }
104747
+
104748
+ hideRecaptcha() {
104749
+ this.recaptchaWidgetEle.style.display = 'none';
104750
+ this.depercatedRecaptchaEle.style.display = 'none';
104751
+ this.mockRecaptchaEle.style.display = '';
104752
+ }
104753
+
104754
+ displayDeprecated() {
104755
+ this.mockRecaptchaEle.style.display = 'none';
104756
+ this.recaptchaWidgetEle.style.display = 'none';
104757
+ this.depercatedRecaptchaEle.style.display = '';
104758
+ }
104759
+
104726
104760
  toggleRecaptchaEles(enabled) {
104727
104761
  if (enabled) {
104728
- this.recaptchaEle.style.display = '';
104729
- this.mockRecaptchaEle.style.display = 'none';
104762
+ this.displayRecaptcha();
104730
104763
  } else {
104731
- this.recaptchaEle.style.display = 'none';
104732
- this.mockRecaptchaEle.style.display = '';
104764
+ this.hideRecaptcha();
104733
104765
  }
104734
104766
  }
104735
104767
 
@@ -104739,6 +104771,8 @@ descope-enriched-text {
104739
104771
  this.attachShadow({ mode: 'open' }).innerHTML = `
104740
104772
  <div class="badge">
104741
104773
  <span id="recaptcha"></span>
104774
+ <span id="recaptcha-widget"></span>
104775
+ <input id="recaptcha-widget-input" type="hidden" name="recaptcha-widget" required />
104742
104776
  <img src="https://imgs.descope.com/connectors/templates/recaptcha/recaptcha-big.png" alt="recaptcha"/>
104743
104777
  </div>
104744
104778
  <slot></slot>
@@ -104762,6 +104796,13 @@ descope-enriched-text {
104762
104796
  width: 100%;
104763
104797
  height: 100%;
104764
104798
  }
104799
+ :host #recaptcha-widget {
104800
+ width: 100%;
104801
+ height: 100%;
104802
+ }
104803
+ :host #recaptcha-widget-input {
104804
+ display: none;
104805
+ }
104765
104806
  :host img {
104766
104807
  width: 256px;
104767
104808
  }
@@ -104775,7 +104816,9 @@ descope-enriched-text {
104775
104816
  this
104776
104817
  );
104777
104818
 
104778
- this.recaptchaEle = this.baseElement.querySelector('#recaptcha');
104819
+ this.depercatedRecaptchaEle = this.baseElement.querySelector('#recaptcha');
104820
+ this.recaptchaWidgetEle = this.baseElement.querySelector('#recaptcha-widget');
104821
+ this.recaptchaWidgetInputEle = this.baseElement.querySelector('#recaptcha-widget-input');
104779
104822
  this.mockRecaptchaEle = this.baseElement.querySelector('img');
104780
104823
  this.badge = this.shadowRoot.querySelector('.badge');
104781
104824
  }
@@ -104788,7 +104831,8 @@ descope-enriched-text {
104788
104831
 
104789
104832
  updatePreview() {
104790
104833
  if (this.children.length) {
104791
- this.recaptchaEle.style.display = 'none';
104834
+ this.depercatedRecaptchaEle.style.display = 'none';
104835
+ this.recaptchaWidgetEle.style.display = 'none';
104792
104836
  this.mockRecaptchaEle.style.display = 'none';
104793
104837
  this.badge.classList.add('hidden');
104794
104838
  } else {
@@ -104797,6 +104841,26 @@ descope-enriched-text {
104797
104841
  }
104798
104842
  }
104799
104843
 
104844
+ getValidity() {
104845
+ if (!this.isWidget) {
104846
+ return {};
104847
+ }
104848
+
104849
+ if (!this.recaptchaWidgetInputEle.value) {
104850
+ return { valueMissing: true };
104851
+ }
104852
+
104853
+ return {};
104854
+ }
104855
+
104856
+ checkValidity() {
104857
+ if (!this.isWidget) {
104858
+ return true;
104859
+ }
104860
+
104861
+ return !!this.recaptchaWidgetInputEle.value;
104862
+ }
104863
+
104800
104864
  get enterprise() {
104801
104865
  return this.getAttribute('enterprise') === 'true';
104802
104866
  }
@@ -104813,6 +104877,14 @@ descope-enriched-text {
104813
104877
  return this.getAttribute('enabled') === 'true';
104814
104878
  }
104815
104879
 
104880
+ get variant() {
104881
+ return this.getAttribute('variant') || 'text';
104882
+ }
104883
+
104884
+ get isWidget() {
104885
+ return this.variant === 'widget';
104886
+ }
104887
+
104816
104888
  get scriptURL() {
104817
104889
  const url = new URL('https://www.google.com/recaptcha/');
104818
104890
  url.pathname += `${this.enterprise ? 'enterprise' : 'api'}.js`;
@@ -104823,6 +104895,11 @@ descope-enriched-text {
104823
104895
 
104824
104896
  #toggleRecaptcha(enabled) {
104825
104897
  this.renderRecaptcha(enabled);
104898
+ if (this.isWidget) {
104899
+ // For the v2 checkbox flow, scripts are loaded/executed by the runtime (grecaptcha-v2).
104900
+ // This legacy v3/invisible path must be fully skipped.
104901
+ return;
104902
+ }
104826
104903
  if (enabled) {
104827
104904
  this.#createOnLoadScript();
104828
104905
  if (!document.getElementById('recaptcha-script')) {
@@ -104895,7 +104972,7 @@ descope-enriched-text {
104895
104972
 
104896
104973
  #createOnLoadScript() {
104897
104974
  window.onRecaptchaLoadCallback = () => {
104898
- const currentNode = this.recaptchaEle;
104975
+ const currentNode = this.depercatedRecaptchaEle;
104899
104976
 
104900
104977
  // if there are child nodes, it means that the recaptcha was already rendered
104901
104978
  if (currentNode.hasChildNodes()) {
@@ -105629,7 +105706,12 @@ const NOTPLink = React__default.default.forwardRef(({ ...props }, ref) => {
105629
105706
  const UploadFile = React__default.default.forwardRef(({ icon, ...props }, ref) => (React__default.default.createElement("descope-upload-file", { ref: ref, ...props }, icon && React__default.default.createElement(Icon, { slot: "icon", icon: icon, "src-dark": icon }))));
105630
105707
 
105631
105708
  const defaultText$2 = 'This site is protected by reCAPTCHA and the Google [Privacy Policy](https://policies.google.com/privacy) and [Terms of Service](https://policies.google.com/terms) apply.';
105632
- const Recaptcha = React__default.default.forwardRef(({ variant, textLabel = defaultText$2, textVariant = 'body1', textMode = 'primary', textAlign = 'left', 'full-width': fullWidth, readOnly, ...props }, ref) => (React__default.default.createElement("descope-recaptcha", { ref: ref, ...props, "full-width": fullWidth }, variant === 'text' ? (React__default.default.createElement("descope-enriched-text", { "full-width": fullWidth, readonly: readOnly, variant: textVariant, mode: textMode, "text-align": textAlign }, textLabel)) : null)));
105709
+ const Recaptcha = React__default.default.forwardRef(({ variant = 'text', textLabel = defaultText$2, textVariant = 'body1', textMode = 'primary', textAlign = 'left', 'full-width': fullWidth, readOnly, ...props }, ref) => {
105710
+ if (variant === 'hide') {
105711
+ return null;
105712
+ }
105713
+ return (React__default.default.createElement("descope-recaptcha", { ref: ref, ...props, variant: variant, "full-width": fullWidth }, variant === 'text' ? (React__default.default.createElement("descope-enriched-text", { "full-width": fullWidth, readonly: readOnly, variant: textVariant, mode: textMode, "text-align": textAlign }, textLabel)) : null));
105714
+ });
105633
105715
 
105634
105716
  const defaultText$1 = 'This site is protected by reCAPTCHA and the Google [Privacy Policy](https://policies.google.com/privacy) and [Terms of Service](https://policies.google.com/terms) apply.';
105635
105717
  const RecaptchaV2 = React__default.default.forwardRef(({ textLabel = defaultText$1, textVariant = 'body1', textMode = 'primary', textAlign = 'left', 'full-width': fullWidth, readOnly, connector: _connector, enterprise: _enterprise, action: _action, variant = 'text', src, width, height, ...props }, ref) => {
package/dist/index.d.ts CHANGED
@@ -535,7 +535,7 @@ type Props$x = {
535
535
  'site-key'?: string;
536
536
  enterprise?: boolean;
537
537
  action?: string;
538
- variant?: 'text';
538
+ variant?: CaptchaVariants;
539
539
  textLabel?: string;
540
540
  textVariant?: TypographyVariants;
541
541
  textMode?: Mode;
@@ -549,11 +549,11 @@ declare global {
549
549
  }
550
550
  namespace React.JSX {
551
551
  interface IntrinsicElements {
552
- 'descope-recaptcha': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & Props$x;
552
+ 'descope-recaptcha': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement, any>, HTMLElement> & Props$x;
553
553
  }
554
554
  }
555
555
  }
556
- declare const Recaptcha: React.ForwardRefExoticComponent<Props$x & React.HTMLAttributes<HTMLDivElement, unknown> & React.RefAttributes<HTMLDivElement>>;
556
+ declare const Recaptcha: React.ForwardRefExoticComponent<Props$x & React.HTMLAttributes<HTMLDivElement, any> & React.RefAttributes<HTMLDivElement>>;
557
557
 
558
558
  type Props$w = {
559
559
  connector?: string;
package/dist/index.esm.js CHANGED
@@ -388,7 +388,12 @@ const NOTPLink = React.forwardRef(({ ...props }, ref) => {
388
388
  const UploadFile = React.forwardRef(({ icon, ...props }, ref) => (React.createElement("descope-upload-file", { ref: ref, ...props }, icon && React.createElement(Icon, { slot: "icon", icon: icon, "src-dark": icon }))));
389
389
 
390
390
  const defaultText$2 = 'This site is protected by reCAPTCHA and the Google [Privacy Policy](https://policies.google.com/privacy) and [Terms of Service](https://policies.google.com/terms) apply.';
391
- const Recaptcha = React.forwardRef(({ variant, textLabel = defaultText$2, textVariant = 'body1', textMode = 'primary', textAlign = 'left', 'full-width': fullWidth, readOnly, ...props }, ref) => (React.createElement("descope-recaptcha", { ref: ref, ...props, "full-width": fullWidth }, variant === 'text' ? (React.createElement("descope-enriched-text", { "full-width": fullWidth, readonly: readOnly, variant: textVariant, mode: textMode, "text-align": textAlign }, textLabel)) : null)));
391
+ const Recaptcha = React.forwardRef(({ variant = 'text', textLabel = defaultText$2, textVariant = 'body1', textMode = 'primary', textAlign = 'left', 'full-width': fullWidth, readOnly, ...props }, ref) => {
392
+ if (variant === 'hide') {
393
+ return null;
394
+ }
395
+ return (React.createElement("descope-recaptcha", { ref: ref, ...props, variant: variant, "full-width": fullWidth }, variant === 'text' ? (React.createElement("descope-enriched-text", { "full-width": fullWidth, readonly: readOnly, variant: textVariant, mode: textMode, "text-align": textAlign }, textLabel)) : null));
396
+ });
392
397
 
393
398
  const defaultText$1 = 'This site is protected by reCAPTCHA and the Google [Privacy Policy](https://policies.google.com/privacy) and [Terms of Service](https://policies.google.com/terms) apply.';
394
399
  const RecaptchaV2 = React.forwardRef(({ textLabel = defaultText$1, textVariant = 'body1', textMode = 'primary', textAlign = 'left', 'full-width': fullWidth, readOnly, connector: _connector, enterprise: _enterprise, action: _action, variant = 'text', src, width, height, ...props }, ref) => {
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
- import { Mode, TextAlign, TypographyVariants } from '../types';
2
+ import { CaptchaVariants, Mode, TextAlign, TypographyVariants } from '../types';
3
3
  type Props = {
4
4
  enabled?: boolean;
5
5
  'site-key'?: string;
6
6
  enterprise?: boolean;
7
7
  action?: string;
8
- variant?: 'text';
8
+ variant?: CaptchaVariants;
9
9
  textLabel?: string;
10
10
  textVariant?: TypographyVariants;
11
11
  textMode?: Mode;
@@ -19,9 +19,9 @@ declare global {
19
19
  }
20
20
  namespace React.JSX {
21
21
  interface IntrinsicElements {
22
- 'descope-recaptcha': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & Props;
22
+ 'descope-recaptcha': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement, any>, HTMLElement> & Props;
23
23
  }
24
24
  }
25
25
  }
26
- declare const Recaptcha: React.ForwardRefExoticComponent<Props & React.HTMLAttributes<HTMLDivElement, unknown> & React.RefAttributes<HTMLDivElement>>;
26
+ declare const Recaptcha: React.ForwardRefExoticComponent<Props & React.HTMLAttributes<HTMLDivElement, any> & React.RefAttributes<HTMLDivElement>>;
27
27
  export default Recaptcha;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope/flow-components",
3
- "version": "3.2.2",
3
+ "version": "3.3.1",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -97,7 +97,7 @@
97
97
  "webpack-subresource-integrity": "5.2.0-rc.1"
98
98
  },
99
99
  "dependencies": {
100
- "@descope/web-components-ui": "3.2.2"
100
+ "@descope/web-components-ui": "3.3.1"
101
101
  },
102
102
  "peerDependencies": {
103
103
  "react": ">= 18"
@@ -139,7 +139,7 @@
139
139
  "build": "npx nx run flow-components:build",
140
140
  "dev": "nx dev flow-components",
141
141
  "dev-server": "FEDERATION_IP=127.0.0.1 NODE_ENV=development webpack serve --mode development --port 4444",
142
- "test": "exit 0",
142
+ "test": "jest",
143
143
  "lint": "eslint --no-warn-ignored --fix 'src/**/*.{ts,tsx,js,jsx}'",
144
144
  "format": "prettier . -w --ignore-path .gitignore",
145
145
  "format-lint": "pretty-quick --staged --ignore-path .gitignore && lint-staged"