@descope/flow-components 3.2.2 → 3.3.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.
@@ -5,7 +5,7 @@
5
5
  "name": "flowComponents",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "3.2.2",
8
+ "buildVersion": "3.3.0",
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.0",
9
9
  "buildName": "@descope/flow-components"
10
10
  },
11
11
  "remoteEntry": {
package/dist/index.cjs.js CHANGED
@@ -104694,7 +104694,7 @@ descope-enriched-text {
104694
104694
 
104695
104695
  const componentName$2 = getComponentName$1('recaptcha');
104696
104696
 
104697
- const observedAttributes = ['enabled', 'site-key', 'action', 'enterprise'];
104697
+ const observedAttributes = ['enabled', 'site-key', 'action', 'enterprise', 'variant'];
104698
104698
 
104699
104699
  const BaseClass$1 = createBaseClass({
104700
104700
  componentName: componentName$2,
@@ -104711,6 +104711,10 @@ descope-enriched-text {
104711
104711
  if (attrName === 'enabled') {
104712
104712
  this.#toggleRecaptcha(newValue === 'true');
104713
104713
  }
104714
+
104715
+ if (attrName === 'variant') {
104716
+ this.updatePreview();
104717
+ }
104714
104718
  }
104715
104719
  }
104716
104720
 
@@ -104723,13 +104727,37 @@ descope-enriched-text {
104723
104727
  this.toggleRecaptchaEles(enabled);
104724
104728
  }
104725
104729
 
104730
+ displayRecaptcha() {
104731
+ if (this.isWidget) {
104732
+ this.displayWidget();
104733
+ } else {
104734
+ this.displayDeprecated();
104735
+ }
104736
+ }
104737
+
104738
+ displayWidget() {
104739
+ this.mockRecaptchaEle.style.display = 'none';
104740
+ this.recaptchaWidgetEle.style.display = '';
104741
+ this.depercatedRecaptchaEle.style.display = 'none';
104742
+ }
104743
+
104744
+ hideRecaptcha() {
104745
+ this.recaptchaWidgetEle.style.display = 'none';
104746
+ this.depercatedRecaptchaEle.style.display = 'none';
104747
+ this.mockRecaptchaEle.style.display = '';
104748
+ }
104749
+
104750
+ displayDeprecated() {
104751
+ this.mockRecaptchaEle.style.display = 'none';
104752
+ this.recaptchaWidgetEle.style.display = 'none';
104753
+ this.depercatedRecaptchaEle.style.display = '';
104754
+ }
104755
+
104726
104756
  toggleRecaptchaEles(enabled) {
104727
104757
  if (enabled) {
104728
- this.recaptchaEle.style.display = '';
104729
- this.mockRecaptchaEle.style.display = 'none';
104758
+ this.displayRecaptcha();
104730
104759
  } else {
104731
- this.recaptchaEle.style.display = 'none';
104732
- this.mockRecaptchaEle.style.display = '';
104760
+ this.hideRecaptcha();
104733
104761
  }
104734
104762
  }
104735
104763
 
@@ -104739,6 +104767,8 @@ descope-enriched-text {
104739
104767
  this.attachShadow({ mode: 'open' }).innerHTML = `
104740
104768
  <div class="badge">
104741
104769
  <span id="recaptcha"></span>
104770
+ <span id="recaptcha-widget"></span>
104771
+ <input id="recaptcha-widget-input" type="hidden" name="recaptcha-widget" required />
104742
104772
  <img src="https://imgs.descope.com/connectors/templates/recaptcha/recaptcha-big.png" alt="recaptcha"/>
104743
104773
  </div>
104744
104774
  <slot></slot>
@@ -104762,6 +104792,13 @@ descope-enriched-text {
104762
104792
  width: 100%;
104763
104793
  height: 100%;
104764
104794
  }
104795
+ :host #recaptcha-widget {
104796
+ width: 100%;
104797
+ height: 100%;
104798
+ }
104799
+ :host #recaptcha-widget-input {
104800
+ display: none;
104801
+ }
104765
104802
  :host img {
104766
104803
  width: 256px;
104767
104804
  }
@@ -104775,7 +104812,9 @@ descope-enriched-text {
104775
104812
  this
104776
104813
  );
104777
104814
 
104778
- this.recaptchaEle = this.baseElement.querySelector('#recaptcha');
104815
+ this.depercatedRecaptchaEle = this.baseElement.querySelector('#recaptcha');
104816
+ this.recaptchaWidgetEle = this.baseElement.querySelector('#recaptcha-widget');
104817
+ this.recaptchaWidgetInputEle = this.baseElement.querySelector('#recaptcha-widget-input');
104779
104818
  this.mockRecaptchaEle = this.baseElement.querySelector('img');
104780
104819
  this.badge = this.shadowRoot.querySelector('.badge');
104781
104820
  }
@@ -104788,7 +104827,8 @@ descope-enriched-text {
104788
104827
 
104789
104828
  updatePreview() {
104790
104829
  if (this.children.length) {
104791
- this.recaptchaEle.style.display = 'none';
104830
+ this.depercatedRecaptchaEle.style.display = 'none';
104831
+ this.recaptchaWidgetEle.style.display = 'none';
104792
104832
  this.mockRecaptchaEle.style.display = 'none';
104793
104833
  this.badge.classList.add('hidden');
104794
104834
  } else {
@@ -104797,6 +104837,26 @@ descope-enriched-text {
104797
104837
  }
104798
104838
  }
104799
104839
 
104840
+ getValidity() {
104841
+ if (!this.isWidget) {
104842
+ return {};
104843
+ }
104844
+
104845
+ if (!this.recaptchaWidgetInputEle.value) {
104846
+ return { valueMissing: true };
104847
+ }
104848
+
104849
+ return {};
104850
+ }
104851
+
104852
+ checkValidity() {
104853
+ if (!this.isWidget) {
104854
+ return true;
104855
+ }
104856
+
104857
+ return !!this.recaptchaWidgetInputEle.value;
104858
+ }
104859
+
104800
104860
  get enterprise() {
104801
104861
  return this.getAttribute('enterprise') === 'true';
104802
104862
  }
@@ -104813,6 +104873,14 @@ descope-enriched-text {
104813
104873
  return this.getAttribute('enabled') === 'true';
104814
104874
  }
104815
104875
 
104876
+ get variant() {
104877
+ return this.getAttribute('variant') || 'text';
104878
+ }
104879
+
104880
+ get isWidget() {
104881
+ return this.variant === 'widget';
104882
+ }
104883
+
104816
104884
  get scriptURL() {
104817
104885
  const url = new URL('https://www.google.com/recaptcha/');
104818
104886
  url.pathname += `${this.enterprise ? 'enterprise' : 'api'}.js`;
@@ -104823,6 +104891,11 @@ descope-enriched-text {
104823
104891
 
104824
104892
  #toggleRecaptcha(enabled) {
104825
104893
  this.renderRecaptcha(enabled);
104894
+ if (this.isWidget) {
104895
+ // For the v2 checkbox flow, scripts are loaded/executed by the runtime (grecaptcha-v2).
104896
+ // This legacy v3/invisible path must be fully skipped.
104897
+ return;
104898
+ }
104826
104899
  if (enabled) {
104827
104900
  this.#createOnLoadScript();
104828
104901
  if (!document.getElementById('recaptcha-script')) {
@@ -104895,7 +104968,7 @@ descope-enriched-text {
104895
104968
 
104896
104969
  #createOnLoadScript() {
104897
104970
  window.onRecaptchaLoadCallback = () => {
104898
- const currentNode = this.recaptchaEle;
104971
+ const currentNode = this.depercatedRecaptchaEle;
104899
104972
 
104900
104973
  // if there are child nodes, it means that the recaptcha was already rendered
104901
104974
  if (currentNode.hasChildNodes()) {
@@ -105629,7 +105702,12 @@ const NOTPLink = React__default.default.forwardRef(({ ...props }, ref) => {
105629
105702
  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
105703
 
105631
105704
  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)));
105705
+ const Recaptcha = React__default.default.forwardRef(({ variant = 'text', textLabel = defaultText$2, textVariant = 'body1', textMode = 'primary', textAlign = 'left', 'full-width': fullWidth, readOnly, ...props }, ref) => {
105706
+ if (variant === 'hide') {
105707
+ return null;
105708
+ }
105709
+ 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));
105710
+ });
105633
105711
 
105634
105712
  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
105713
  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.0",
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.0"
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"