@ory/elements-react 0.0.0-pr.96c07cce → 0.0.0-pr.c7aa6707

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.
@@ -2889,25 +2889,6 @@ function LoginCardFooter() {
2889
2889
  );
2890
2890
  }
2891
2891
  if (flow.refresh || flow.requested_aal === "aal2") {
2892
- if (authMethods.length > 1 && formState.current === "method_active") {
2893
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("span", { className: "font-normal leading-normal antialiased text-interface-foreground-default-primary", children: [
2894
- intl.formatMessage({
2895
- id: "login.2fa.go-back"
2896
- }),
2897
- " ",
2898
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
2899
- "a",
2900
- {
2901
- className: "text-button-link-brand-brand transition-colors hover:text-button-link-brand-brand-hover underline",
2902
- href: "",
2903
- "data-testid": "ory/screen/login/mfa/action/selectMethod",
2904
- children: intl.formatMessage({
2905
- id: "login.2fa.go-back.link"
2906
- })
2907
- }
2908
- )
2909
- ] });
2910
- }
2911
2892
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("span", { className: "font-normal leading-normal antialiased text-interface-foreground-default-primary", children: [
2912
2893
  intl.formatMessage({
2913
2894
  id: "login.2fa.go-back"
@@ -3323,6 +3304,9 @@ var SvgArrowLeft = (props) => {
3323
3304
  };
3324
3305
  var arrow_left_default = SvgArrowLeft;
3325
3306
 
3307
+ // src/theme/default/components/card/current-identifier-button.tsx
3308
+ var import_react_hook_form13 = require("react-hook-form");
3309
+
3326
3310
  // src/theme/default/utils/attributes.ts
3327
3311
  function omit(obj, keys) {
3328
3312
  const ret = { ...obj };
@@ -3332,13 +3316,37 @@ function omit(obj, keys) {
3332
3316
  return ret;
3333
3317
  }
3334
3318
 
3319
+ // src/util/omitAttributes.ts
3320
+ function omitInputAttributes({
3321
+ ...attrs
3322
+ }) {
3323
+ return omit(attrs, [
3324
+ "autocomplete",
3325
+ "label",
3326
+ "node_type",
3327
+ "maxlength",
3328
+ "onclick",
3329
+ "onclickTrigger",
3330
+ "onload",
3331
+ "onloadTrigger"
3332
+ ]);
3333
+ }
3334
+
3335
3335
  // src/theme/default/components/card/current-identifier-button.tsx
3336
- var import_react_hook_form13 = require("react-hook-form");
3336
+ var import_react7 = require("react");
3337
3337
  var import_jsx_runtime36 = require("react/jsx-runtime");
3338
3338
  function DefaultCurrentIdentifierButton() {
3339
+ var _a;
3339
3340
  const { flow, flowType, config, formState } = (0, import_elements_react4.useOryFlow)();
3340
- const { setValue } = (0, import_react_hook_form13.useFormContext)();
3341
+ const { setValue, getValues, watch } = (0, import_react_hook_form13.useFormContext)();
3342
+ const [turnstileResponse, setTurnstileResponse] = (0, import_react7.useState)();
3341
3343
  const ui = flow.ui;
3344
+ const captchaVerificationValue = (_a = watch("transient_payload")) == null ? void 0 : _a.captcha_turnstile_response;
3345
+ (0, import_react7.useEffect)(() => {
3346
+ if (captchaVerificationValue) {
3347
+ setTurnstileResponse(captchaVerificationValue);
3348
+ }
3349
+ }, [captchaVerificationValue]);
3342
3350
  if (formState.current === "provide_identifier") {
3343
3351
  return null;
3344
3352
  }
@@ -3353,11 +3361,6 @@ function DefaultCurrentIdentifierButton() {
3353
3361
  flow,
3354
3362
  `${config.sdk.url}/self-service/${flowType}/browser`
3355
3363
  );
3356
- const attributes = omit(nodeBackButton, [
3357
- "autocomplete",
3358
- "node_type",
3359
- "maxlength"
3360
- ]);
3361
3364
  const screenSelectionNode = findScreenSelectionButton(flow.ui.nodes);
3362
3365
  if (screenSelectionNode) {
3363
3366
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("form", { action: flow.ui.action, method: flow.ui.method, children: [
@@ -3368,12 +3371,16 @@ function DefaultCurrentIdentifierButton() {
3368
3371
  return false;
3369
3372
  }).map((n) => {
3370
3373
  const attrs = n.attributes;
3374
+ let value = getValues(attrs.name) || attrs.value;
3375
+ if (attrs.name === "transient_payload.captcha_turnstile_response" && turnstileResponse) {
3376
+ value = turnstileResponse;
3377
+ }
3371
3378
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3372
3379
  "input",
3373
3380
  {
3374
3381
  type: "hidden",
3375
3382
  name: attrs.name,
3376
- value: attrs.value
3383
+ value
3377
3384
  },
3378
3385
  attrs.name
3379
3386
  );
@@ -3382,7 +3389,7 @@ function DefaultCurrentIdentifierButton() {
3382
3389
  "button",
3383
3390
  {
3384
3391
  className: "group inline-flex max-w-full cursor-pointer items-center gap-1 self-start rounded-identifier border px-[11px] py-[5px] transition-colors border-button-identifier-border-border-default bg-button-identifier-background-default hover:border-button-identifier-border-border-hover hover:bg-button-identifier-background-hover",
3385
- ...attributes,
3392
+ ...omitInputAttributes(nodeBackButton),
3386
3393
  type: "submit",
3387
3394
  onClick: () => {
3388
3395
  setValue(
@@ -3414,7 +3421,7 @@ function DefaultCurrentIdentifierButton() {
3414
3421
  "a",
3415
3422
  {
3416
3423
  className: "group inline-flex max-w-full cursor-pointer items-center gap-1 self-start rounded-identifier border px-[11px] py-[5px] transition-colors border-button-identifier-border-border-default bg-button-identifier-background-default hover:border-button-identifier-border-border-hover hover:bg-button-identifier-background-hover",
3417
- ...attributes,
3424
+ ...omitInputAttributes(nodeBackButton),
3418
3425
  href: initFlowUrl2,
3419
3426
  title: `Adjust ${nodeBackButton == null ? void 0 : nodeBackButton.value}`,
3420
3427
  "data-testid": `ory/screen/${flowType}/action/restart`,
@@ -3553,7 +3560,7 @@ var import_client_fetch31 = require("@ory/client-fetch");
3553
3560
 
3554
3561
  // src/theme/default/components/form/social.tsx
3555
3562
  var import_elements_react7 = require("@ory/elements-react");
3556
- var import_react7 = require("react");
3563
+ var import_react8 = require("react");
3557
3564
  var import_react_hook_form14 = require("react-hook-form");
3558
3565
  var import_react_intl12 = require("react-intl");
3559
3566
  var import_usehooks_ts = require("usehooks-ts");
@@ -3773,24 +3780,6 @@ function Spinner({ className }) {
3773
3780
 
3774
3781
  // src/theme/default/components/form/social.tsx
3775
3782
  var import_client_fetch30 = require("@ory/client-fetch");
3776
-
3777
- // src/util/omitAttributes.ts
3778
- function omitInputAttributes({
3779
- ...attrs
3780
- }) {
3781
- return omit(attrs, [
3782
- "autocomplete",
3783
- "label",
3784
- "node_type",
3785
- "maxlength",
3786
- "onclick",
3787
- "onclickTrigger",
3788
- "onload",
3789
- "onloadTrigger"
3790
- ]);
3791
- }
3792
-
3793
- // src/theme/default/components/form/social.tsx
3794
3783
  var import_jsx_runtime55 = require("react/jsx-runtime");
3795
3784
  function extractProvider(context) {
3796
3785
  if (context && typeof context === "object" && "provider" in context && typeof context.provider === "string") {
@@ -3826,7 +3815,7 @@ function DefaultButtonSocial({
3826
3815
  onClick == null ? void 0 : onClick();
3827
3816
  setClicked(true);
3828
3817
  };
3829
- (0, import_react7.useEffect)(() => {
3818
+ (0, import_react8.useEffect)(() => {
3830
3819
  if (!isSubmitting) {
3831
3820
  setClicked(false);
3832
3821
  }
@@ -4065,7 +4054,7 @@ var import_elements_react9 = require("@ory/elements-react");
4065
4054
  var import_class_variance_authority = require("class-variance-authority");
4066
4055
  var import_react_hook_form15 = require("react-hook-form");
4067
4056
  var import_react_intl15 = require("react-intl");
4068
- var import_react8 = require("react");
4057
+ var import_react9 = require("react");
4069
4058
  var import_jsx_runtime65 = require("react/jsx-runtime");
4070
4059
  var buttonStyles = (0, import_class_variance_authority.cva)(
4071
4060
  [
@@ -4106,14 +4095,14 @@ var DefaultButton = ({
4106
4095
  }) => {
4107
4096
  var _a;
4108
4097
  const { type, name, value, ...rest } = attributes;
4109
- const [clicked, setClicked] = (0, import_react8.useState)(false);
4098
+ const [clicked, setClicked] = (0, import_react9.useState)(false);
4110
4099
  const intl = (0, import_react_intl15.useIntl)();
4111
4100
  const label = (0, import_client_fetch32.getNodeLabel)(node);
4112
4101
  const {
4113
4102
  formState: { isSubmitting },
4114
4103
  setValue
4115
4104
  } = (0, import_react_hook_form15.useFormContext)();
4116
- (0, import_react8.useEffect)(() => {
4105
+ (0, import_react9.useEffect)(() => {
4117
4106
  if (!isSubmitting) {
4118
4107
  setClicked(false);
4119
4108
  }
@@ -4271,10 +4260,10 @@ var import_elements_react11 = require("@ory/elements-react");
4271
4260
  var import_client_fetch34 = require("@ory/client-fetch");
4272
4261
 
4273
4262
  // src/util/childCounter.ts
4274
- var import_react9 = require("react");
4263
+ var import_react10 = require("react");
4275
4264
  function countRenderableChildren(children) {
4276
- return import_react9.Children.toArray(children).filter((c) => {
4277
- if ((0, import_react9.isValidElement)(c)) {
4265
+ return import_react10.Children.toArray(children).filter((c) => {
4266
+ if ((0, import_react10.isValidElement)(c)) {
4278
4267
  return true;
4279
4268
  }
4280
4269
  return false;
@@ -4323,7 +4312,7 @@ function DefaultImage({ attributes, node }) {
4323
4312
  // src/theme/default/components/form/input.tsx
4324
4313
  var import_client_fetch35 = require("@ory/client-fetch");
4325
4314
  var import_elements_react12 = require("@ory/elements-react");
4326
- var import_react10 = require("react");
4315
+ var import_react11 = require("react");
4327
4316
  var import_react_hook_form17 = require("react-hook-form");
4328
4317
  var import_react_intl18 = require("react-intl");
4329
4318
 
@@ -4368,7 +4357,7 @@ var DefaultInput = ({
4368
4357
  const { value, autocomplete, name, maxlength, ...rest } = attributes;
4369
4358
  const intl = (0, import_react_intl18.useIntl)();
4370
4359
  const { flowType } = (0, import_elements_react12.useOryFlow)();
4371
- const inputRef = (0, import_react10.useRef)(null);
4360
+ const inputRef = (0, import_react11.useRef)(null);
4372
4361
  const formattedLabel = label ? intl.formatMessage(
4373
4362
  {
4374
4363
  id: "input.placeholder",
@@ -4382,7 +4371,7 @@ var DefaultInput = ({
4382
4371
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
4383
4372
  "input",
4384
4373
  {
4385
- ...rest,
4374
+ ...omitInputAttributes(rest),
4386
4375
  onClick,
4387
4376
  maxLength: maxlength,
4388
4377
  autoComplete: autocomplete,
@@ -4427,7 +4416,7 @@ var DefaultInput = ({
4427
4416
  function PasswordToggle({
4428
4417
  inputRef
4429
4418
  }) {
4430
- const [shown, setShown] = (0, import_react10.useState)(false);
4419
+ const [shown, setShown] = (0, import_react11.useState)(false);
4431
4420
  const handleClick = () => {
4432
4421
  setShown(!shown);
4433
4422
  if (inputRef.current) {
@@ -4522,10 +4511,10 @@ function DefaultLabel({
4522
4511
  // src/theme/default/components/form/link-button.tsx
4523
4512
  var import_client_fetch37 = require("@ory/client-fetch");
4524
4513
  var import_elements_react14 = require("@ory/elements-react");
4525
- var import_react11 = require("react");
4514
+ var import_react12 = require("react");
4526
4515
  var import_react_intl20 = require("react-intl");
4527
4516
  var import_jsx_runtime75 = require("react/jsx-runtime");
4528
- var DefaultLinkButton = (0, import_react11.forwardRef)(({ attributes, node }, ref) => {
4517
+ var DefaultLinkButton = (0, import_react12.forwardRef)(({ attributes, node }, ref) => {
4529
4518
  const intl = (0, import_react_intl20.useIntl)();
4530
4519
  const label = (0, import_client_fetch37.getNodeLabel)(node);
4531
4520
  return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
@@ -4773,12 +4762,12 @@ var getUserInitials = (session) => {
4773
4762
  };
4774
4763
 
4775
4764
  // src/theme/default/components/ui/dropdown-menu.tsx
4776
- var import_react12 = require("react");
4765
+ var import_react13 = require("react");
4777
4766
  var DropdownMenuPrimitive = __toESM(require("@radix-ui/react-dropdown-menu"));
4778
4767
  var import_jsx_runtime82 = require("react/jsx-runtime");
4779
4768
  var DropdownMenu = DropdownMenuPrimitive.Root;
4780
4769
  var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
4781
- var DropdownMenuContent = (0, import_react12.forwardRef)(({ className, sideOffset = 16, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
4770
+ var DropdownMenuContent = (0, import_react13.forwardRef)(({ className, sideOffset = 16, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
4782
4771
  DropdownMenuPrimitive.Content,
4783
4772
  {
4784
4773
  ref,
@@ -4793,7 +4782,7 @@ var DropdownMenuContent = (0, import_react12.forwardRef)(({ className, sideOffse
4793
4782
  }
4794
4783
  ) }));
4795
4784
  DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
4796
- var DropdownMenuItem = (0, import_react12.forwardRef)(({ className, inset, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
4785
+ var DropdownMenuItem = (0, import_react13.forwardRef)(({ className, inset, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
4797
4786
  DropdownMenuPrimitive.Item,
4798
4787
  {
4799
4788
  ref,
@@ -4811,7 +4800,7 @@ var DropdownMenuItem = (0, import_react12.forwardRef)(({ className, inset, ...pr
4811
4800
  }
4812
4801
  ));
4813
4802
  DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
4814
- var DropdownMenuLabel = (0, import_react12.forwardRef)(({ className, inset, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
4803
+ var DropdownMenuLabel = (0, import_react13.forwardRef)(({ className, inset, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
4815
4804
  DropdownMenuPrimitive.Label,
4816
4805
  {
4817
4806
  ref,
@@ -4826,7 +4815,7 @@ var DropdownMenuLabel = (0, import_react12.forwardRef)(({ className, inset, ...p
4826
4815
  DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
4827
4816
 
4828
4817
  // src/theme/default/components/ui/user-avater.tsx
4829
- var import_react13 = require("react");
4818
+ var import_react14 = require("react");
4830
4819
 
4831
4820
  // src/theme/default/assets/icons/user.svg
4832
4821
  var React28 = __toESM(require("react"));
@@ -4839,7 +4828,7 @@ var user_default = SvgUser;
4839
4828
 
4840
4829
  // src/theme/default/components/ui/user-avater.tsx
4841
4830
  var import_jsx_runtime84 = require("react/jsx-runtime");
4842
- var UserAvatar = (0, import_react13.forwardRef)(
4831
+ var UserAvatar = (0, import_react14.forwardRef)(
4843
4832
  ({ initials, ...rest }, ref) => {
4844
4833
  return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
4845
4834
  "button",
@@ -4931,7 +4920,7 @@ var DefaultPageHeader = (_props) => {
4931
4920
  };
4932
4921
 
4933
4922
  // src/theme/default/components/settings/settings-oidc.tsx
4934
- var import_react14 = require("react");
4923
+ var import_react15 = require("react");
4935
4924
  var import_react_hook_form20 = require("react-hook-form");
4936
4925
  var import_usehooks_ts2 = require("usehooks-ts");
4937
4926
 
@@ -4988,7 +4977,7 @@ function UnlinkRow({ button }) {
4988
4977
  button.onClick();
4989
4978
  setClicked(true);
4990
4979
  };
4991
- (0, import_react14.useEffect)(() => {
4980
+ (0, import_react15.useEffect)(() => {
4992
4981
  if (!isSubmitting) {
4993
4982
  setClicked(false);
4994
4983
  }
@@ -5437,48 +5426,53 @@ function DefaultAuthMethodListContainer({
5437
5426
  // src/theme/default/components/form/captcha.tsx
5438
5427
  var import_client_fetch39 = require("@ory/client-fetch");
5439
5428
  var import_react_turnstile = require("@marsidev/react-turnstile");
5440
- var import_react15 = require("react");
5429
+ var import_react16 = require("react");
5441
5430
  var import_react_hook_form25 = require("react-hook-form");
5442
5431
  var import_jsx_runtime98 = require("react/jsx-runtime");
5443
5432
  var DefaultCaptcha = ({ node }) => {
5444
- const { setValue } = (0, import_react_hook_form25.useFormContext)();
5445
- const ref = (0, import_react15.useRef)();
5446
- const nodes = [];
5447
- if ((0, import_client_fetch39.isUiNodeInputAttributes)(node.attributes)) {
5448
- if (node.attributes.name === "transient_payload.captcha_turnstile_response") {
5449
- nodes.push(
5450
- /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(DefaultInput, { node, attributes: node.attributes }, 1)
5451
- );
5433
+ const { setValue, formState } = (0, import_react_hook_form25.useFormContext)();
5434
+ const ref = (0, import_react16.useRef)();
5435
+ const prevSubmitCount = (0, import_react16.useRef)(formState.submitCount);
5436
+ (0, import_react16.useEffect)(() => {
5437
+ if (formState.submitCount > prevSubmitCount.current && formState.isSubmitSuccessful) {
5438
+ prevSubmitCount.current = formState.submitCount;
5439
+ setTimeout(() => {
5440
+ if (ref.current) {
5441
+ ref.current.reset();
5442
+ }
5443
+ }, 100);
5452
5444
  }
5445
+ }, [formState.submitCount, formState.isSubmitSuccessful]);
5446
+ if (!(0, import_client_fetch39.isUiNodeInputAttributes)(node.attributes)) {
5447
+ return null;
5453
5448
  }
5454
- if ((0, import_client_fetch39.isUiNodeInputAttributes)(node.attributes) && node.attributes.name === "captcha_turnstile_options") {
5449
+ if (node.attributes.name === "transient_payload.captcha_turnstile_response") {
5450
+ return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(DefaultInput, { node, attributes: node.attributes }, 1);
5451
+ } else if (node.attributes.name === "captcha_turnstile_options") {
5455
5452
  const options = JSON.parse(node.attributes.value);
5456
- nodes.push(
5457
- /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
5458
- import_react_turnstile.Turnstile,
5459
- {
5460
- ref,
5461
- siteKey: options.sitekey,
5462
- options: {
5463
- action: options.action,
5464
- size: "flexible",
5465
- theme: options.theme,
5466
- responseField: false,
5467
- responseFieldName: options.response_field_name
5468
- },
5469
- onExpire: () => {
5470
- var _a;
5471
- return (_a = ref.current) == null ? void 0 : _a.reset();
5472
- },
5473
- onSuccess: (token) => {
5474
- setValue(options.response_field_name, token);
5475
- }
5453
+ return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
5454
+ import_react_turnstile.Turnstile,
5455
+ {
5456
+ ref,
5457
+ siteKey: options.sitekey,
5458
+ options: {
5459
+ action: options.action,
5460
+ size: "flexible",
5461
+ theme: options.theme,
5462
+ responseField: false,
5463
+ responseFieldName: options.response_field_name
5476
5464
  },
5477
- 2
5478
- )
5465
+ onExpire: () => {
5466
+ var _a;
5467
+ return (_a = ref.current) == null ? void 0 : _a.reset();
5468
+ },
5469
+ onSuccess: (token) => {
5470
+ setValue(options.response_field_name, token);
5471
+ }
5472
+ }
5479
5473
  );
5480
5474
  }
5481
- return nodes;
5475
+ return null;
5482
5476
  };
5483
5477
 
5484
5478
  // src/theme/default/assets/icons/personal.svg
@@ -5608,7 +5602,7 @@ function getOryComponents(overrides) {
5608
5602
 
5609
5603
  // src/theme/default/flows/error.tsx
5610
5604
  var import_client_fetch40 = require("@ory/client-fetch");
5611
- var import_react16 = require("react");
5605
+ var import_react17 = require("react");
5612
5606
  var import_react_intl24 = require("react-intl");
5613
5607
  var import_jsx_runtime103 = require("react/jsx-runtime");
5614
5608
  function isOAuth2Error(error) {
@@ -5619,7 +5613,7 @@ var errorDescriptions = {
5619
5613
  5: "The server encountered an error and could not complete your request"
5620
5614
  };
5621
5615
  function useStandardize(error) {
5622
- return (0, import_react16.useMemo)(() => {
5616
+ return (0, import_react17.useMemo)(() => {
5623
5617
  var _a;
5624
5618
  if (isOAuth2Error(error)) {
5625
5619
  return {