@ory/elements-react 1.2.0-rc.0 → 1.2.0-rc.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.
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
- import { UiNodeGroupEnum, isUiNodeInputAttributes, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeScriptAttributes, FlowType, getNodeId, Configuration, FrontendApi, isUiNodeTextAttributes, UiNodeInputAttributesTypeEnum, handleContinueWith, isResponseError as isResponseError$1, loginUrl, settingsUrl, registrationUrl, FetchError, ResponseError, recoveryUrl, instanceOfContinueWithRecoveryUi, verificationUrl as verificationUrl$1 } from '@ory/client-fetch';
2
- import { createContext, useContext, useRef, useEffect, useState, useMemo, useReducer } from 'react';
1
+ import { UiNodeGroupEnum, getNodeLabel, UiNodeInputAttributesTypeEnum, isUiNodeInputAttributes, isUiNodeAnchorAttributes, isUiNodeImageAttributes, isUiNodeScriptAttributes, FlowType, getNodeId, Configuration, FrontendApi, handleContinueWith, isResponseError as isResponseError$1, loginUrl, settingsUrl, registrationUrl, FetchError, ResponseError, recoveryUrl, instanceOfContinueWithRecoveryUi, verificationUrl as verificationUrl$1 } from '@ory/client-fetch';
2
+ import { createContext, useMemo, useEffect, useCallback, useContext, useRef, useState, useReducer } from 'react';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { useIntl, IntlContext, createIntlCache, createIntl, RawIntlProvider } from 'react-intl';
5
- import { useFormContext, useForm, FormProvider } from 'react-hook-form';
5
+ import { useController, useFormState, useFormContext, useForm, FormProvider } from 'react-hook-form';
6
+ import { useDebounceValue } from 'usehooks-ts';
6
7
  import { Toaster, toast } from 'sonner';
7
8
 
8
9
  // src/context/component.tsx
@@ -577,12 +578,13 @@ function OryCardHeader() {
577
578
  }
578
579
  function computeDefaultValues(flow) {
579
580
  const defaults = flow.ui.nodes.reduce((acc, node) => {
581
+ var _a;
580
582
  const attrs = node.attributes;
581
583
  if (isUiNodeInputAttributes(attrs)) {
582
584
  if (attrs.type === "checkbox" && typeof attrs.value === "undefined") {
583
585
  attrs.value = false;
584
586
  }
585
- if (attrs.name === "method" || attrs.type === "submit" || typeof attrs.value === "undefined") {
587
+ if (attrs.name === "method" || attrs.type === "submit") {
586
588
  return acc;
587
589
  }
588
590
  if (attrs.name.startsWith("grant_scope")) {
@@ -604,7 +606,7 @@ function computeDefaultValues(flow) {
604
606
  return unrollTrait(
605
607
  {
606
608
  name: attrs.name,
607
- value: attrs.value
609
+ value: (_a = attrs.value) != null ? _a : ""
608
610
  },
609
611
  acc
610
612
  );
@@ -1054,6 +1056,35 @@ async function onSubmitVerification({ flow }, config, {
1054
1056
  );
1055
1057
  }
1056
1058
 
1059
+ // src/util/removeFalsyValues.ts
1060
+ function removeEmptyStrings(input) {
1061
+ if (Array.isArray(input)) {
1062
+ return input.map((item) => removeEmptyStrings(item)).filter(
1063
+ (v) => v || typeof v === "boolean" || typeof v === "number"
1064
+ );
1065
+ }
1066
+ if (input === null || typeof input !== "object") {
1067
+ return input;
1068
+ }
1069
+ const obj = input;
1070
+ const out = {};
1071
+ for (const [key, value] of Object.entries(obj)) {
1072
+ if (value && typeof value === "object") {
1073
+ const cleaned = removeEmptyStrings(value);
1074
+ if (Array.isArray(cleaned)) {
1075
+ if (cleaned.length) {
1076
+ out[key] = cleaned;
1077
+ }
1078
+ } else if (cleaned && Object.keys(cleaned).length > 0) {
1079
+ out[key] = cleaned;
1080
+ }
1081
+ } else if (value || typeof value === "boolean" || typeof value === "number") {
1082
+ out[key] = value;
1083
+ }
1084
+ }
1085
+ return out;
1086
+ }
1087
+
1057
1088
  // src/components/form/useOryFormSubmit.ts
1058
1089
  var supportsSelectAccountPrompt = ["google", "github"];
1059
1090
  function useOryFormSubmit(onAfterSubmit) {
@@ -1062,12 +1093,17 @@ function useOryFormSubmit(onAfterSubmit) {
1062
1093
  const config = useOryConfiguration();
1063
1094
  const handleSuccess = (flow) => {
1064
1095
  flowContainer.setFlowContainer(flow);
1065
- methods.reset(computeDefaultValues(flow.flow));
1096
+ const newValues = computeDefaultValues(flow.flow);
1097
+ methods.reset(newValues, {
1098
+ keepSubmitCount: true
1099
+ });
1066
1100
  };
1067
1101
  const onRedirect = (url, _external) => {
1068
1102
  window.location.assign(url);
1069
1103
  };
1070
- const onSubmit = async (data) => {
1104
+ const onSubmit = async (initialData) => {
1105
+ const data = removeEmptyStrings(initialData);
1106
+ console.log("Submitting form data:", data);
1071
1107
  switch (flowContainer.flowType) {
1072
1108
  case FlowType.Login: {
1073
1109
  const submitData = {
@@ -1214,7 +1250,7 @@ function OryForm({ children, onAfterSubmit }) {
1214
1250
  {
1215
1251
  action: flowContainer.flow.ui.action,
1216
1252
  method: flowContainer.flow.ui.method,
1217
- onSubmit: (e) => void methods.handleSubmit(onSubmit)(e),
1253
+ onSubmit: (e) => void methods.handleSubmit(onSubmit, console.error)(e),
1218
1254
  children
1219
1255
  }
1220
1256
  );
@@ -1245,16 +1281,376 @@ function OryCardValidationMessages({
1245
1281
  }
1246
1282
  return /* @__PURE__ */ jsx(Message.Root, { children: messages == null ? void 0 : messages.map((message) => /* @__PURE__ */ jsx(Message.Content, { message }, message.id)) });
1247
1283
  }
1284
+
1285
+ // src/util/utilFixSDKTypesHelper.ts
1286
+ function isUiNodeInput(node) {
1287
+ return node.type === "input";
1288
+ }
1289
+ function isUiNodeImage(node) {
1290
+ return node.type === "img";
1291
+ }
1292
+ function isUiNodeAnchor(node) {
1293
+ return node.type === "a";
1294
+ }
1295
+ function isUiNodeText(node) {
1296
+ return node.type === "text";
1297
+ }
1298
+ function isUiNodeScript(node) {
1299
+ return node.type === "script";
1300
+ }
1301
+ function isUiNodeDiv(node) {
1302
+ return node.type === "div";
1303
+ }
1304
+ function ConsentCheckboxRenderer({ node }) {
1305
+ const attributes = node.attributes;
1306
+ const { Node: Node2 } = useComponents();
1307
+ const { setValue, watch, formState } = useFormContext();
1308
+ const scopes = watch("grant_scope");
1309
+ const checked = useMemo(() => {
1310
+ if (Array.isArray(scopes)) {
1311
+ return scopes.includes(attributes.value);
1312
+ }
1313
+ return false;
1314
+ }, [scopes, attributes.value]);
1315
+ const handleScopeChange = (checked2) => {
1316
+ const scopes2 = watch("grant_scope");
1317
+ if (Array.isArray(scopes2)) {
1318
+ if (checked2) {
1319
+ setValue(
1320
+ "grant_scope",
1321
+ Array.from(/* @__PURE__ */ new Set([...scopes2, attributes.value]))
1322
+ );
1323
+ } else {
1324
+ setValue(
1325
+ "grant_scope",
1326
+ scopes2.filter((scope) => scope !== attributes.value)
1327
+ );
1328
+ }
1329
+ }
1330
+ };
1331
+ const inputProps = {
1332
+ value: attributes.value,
1333
+ checked: checked === true,
1334
+ disabled: attributes.disabled || !formState.isReady,
1335
+ name: attributes.name
1336
+ };
1337
+ return /* @__PURE__ */ jsx(
1338
+ Node2.ConsentScopeCheckbox,
1339
+ {
1340
+ attributes,
1341
+ node,
1342
+ inputProps,
1343
+ onCheckedChange: handleScopeChange
1344
+ }
1345
+ );
1346
+ }
1347
+ function ButtonRenderer({ node }) {
1348
+ const { Node: Node2 } = useComponents();
1349
+ const { formState, setValue } = useFormContext();
1350
+ const [clicked, setClicked] = useDebounceValue(false, 100);
1351
+ const handleClick = useCallback(() => {
1352
+ setValue(node.attributes.name, node.attributes.value);
1353
+ setClicked(true);
1354
+ if (node.attributes.onclickTrigger) {
1355
+ triggerToWindowCall(node.attributes.onclickTrigger);
1356
+ }
1357
+ }, [node.attributes, setValue, setClicked]);
1358
+ const buttonProps = {
1359
+ type: node.attributes.type === "submit" ? "submit" : "button",
1360
+ name: node.attributes.name,
1361
+ value: node.attributes.value,
1362
+ onClick: handleClick,
1363
+ disabled: node.attributes.disabled || !formState.isReady || formState.isSubmitting
1364
+ };
1365
+ useEffect(() => {
1366
+ if (!formState.isSubmitting) {
1367
+ setClicked(false);
1368
+ }
1369
+ }, [formState.isSubmitting, setClicked]);
1370
+ return /* @__PURE__ */ jsx(
1371
+ Node2.Button,
1372
+ {
1373
+ attributes: node.attributes,
1374
+ node,
1375
+ buttonProps,
1376
+ isSubmitting: clicked
1377
+ }
1378
+ );
1379
+ }
1380
+ function CheckboxRenderer({ node }) {
1381
+ const attributes = node.attributes;
1382
+ const { Node: Node2 } = useComponents();
1383
+ const controller = useController({
1384
+ name: attributes.name,
1385
+ defaultValue: attributes.value,
1386
+ disabled: attributes.disabled
1387
+ });
1388
+ const inputProps = {
1389
+ ...controller.field,
1390
+ type: "checkbox",
1391
+ value: controller.field.value === true ? "true" : "false",
1392
+ checked: controller.field.value === true,
1393
+ disabled: attributes.disabled || !controller.formState.isReady
1394
+ };
1395
+ return /* @__PURE__ */ jsx(
1396
+ Node2.Label,
1397
+ {
1398
+ attributes: { ...attributes, label: void 0 },
1399
+ node: { ...node, meta: { ...node.meta, label: void 0 } },
1400
+ fieldError: controller.fieldState.error,
1401
+ children: /* @__PURE__ */ jsx(
1402
+ Node2.Checkbox,
1403
+ {
1404
+ attributes,
1405
+ node,
1406
+ inputProps,
1407
+ onClick: () => {
1408
+ }
1409
+ }
1410
+ )
1411
+ }
1412
+ );
1413
+ }
1414
+ function ImageRenderer({ node }) {
1415
+ const { Node: Node2 } = useComponents();
1416
+ return /* @__PURE__ */ jsx(Node2.Image, { node, attributes: node.attributes });
1417
+ }
1418
+
1419
+ // src/util/nodes.ts
1420
+ function isDynamicText(text) {
1421
+ return text.id === 1070002 && !!text.context && "name" in text.context && typeof text.context["name"] === "string";
1422
+ }
1423
+
1424
+ // src/util/i18n/index.ts
1425
+ var uiTextToFormattedMessage = ({ id, context = {}, text }, intl) => {
1426
+ const contextInjectedMessage = Object.entries(context).reduce(
1427
+ (accumulator, [key, value]) => {
1428
+ if (Array.isArray(value)) {
1429
+ return {
1430
+ ...accumulator,
1431
+ [key]: value,
1432
+ [key + "_list"]: intl.formatList(value)
1433
+ };
1434
+ } else if (key.endsWith("_unix")) {
1435
+ if (typeof value === "number") {
1436
+ return {
1437
+ ...accumulator,
1438
+ [key]: intl.formatDate(new Date(value * 1e3)),
1439
+ [key + "_since"]: intl.formatDateTimeRange(
1440
+ new Date(value),
1441
+ /* @__PURE__ */ new Date()
1442
+ ),
1443
+ [key + "_since_minutes"]: Math.ceil(
1444
+ (value - (/* @__PURE__ */ new Date()).getTime() / 1e3) / 60
1445
+ ).toFixed(0),
1446
+ [key + "_until"]: intl.formatDateTimeRange(
1447
+ /* @__PURE__ */ new Date(),
1448
+ new Date(value)
1449
+ ),
1450
+ [key + "_until_minutes"]: Math.ceil(
1451
+ ((/* @__PURE__ */ new Date()).getTime() / 1e3 - value) / 60
1452
+ ).toFixed(0)
1453
+ };
1454
+ }
1455
+ } else if (key === "property") {
1456
+ return {
1457
+ ...accumulator,
1458
+ [key]: intl.formatMessage({
1459
+ id: `property.${value}`,
1460
+ defaultMessage: value
1461
+ })
1462
+ };
1463
+ }
1464
+ return {
1465
+ ...accumulator,
1466
+ [key]: value
1467
+ };
1468
+ },
1469
+ {}
1470
+ );
1471
+ return intl.formatMessage(
1472
+ {
1473
+ id: `identities.messages.${id}`,
1474
+ defaultMessage: text
1475
+ },
1476
+ contextInjectedMessage
1477
+ );
1478
+ };
1479
+ function resolvePlaceholder(text, intl) {
1480
+ const fallback = intl.formatMessage(
1481
+ {
1482
+ id: "input.placeholder",
1483
+ defaultMessage: "Enter your {placeholder}"
1484
+ },
1485
+ {
1486
+ placeholder: uiTextToFormattedMessage(text, intl)
1487
+ }
1488
+ );
1489
+ if (isDynamicText(text)) {
1490
+ const field = text.context.name;
1491
+ return intl.formatMessage({
1492
+ id: `forms.input.placeholder.${field}`,
1493
+ defaultMessage: fallback
1494
+ });
1495
+ }
1496
+ return fallback;
1497
+ }
1498
+
1499
+ // src/util/test-id.ts
1500
+ function messageTestId(message) {
1501
+ return {
1502
+ "data-testid": `ory/message/${message.id}`
1503
+ };
1504
+ }
1505
+ function useInputProps(attributes, placeholder) {
1506
+ const controller = useController({
1507
+ name: attributes.name,
1508
+ control: void 0,
1509
+ disabled: attributes.disabled,
1510
+ shouldUnregister: true
1511
+ // TODO: consider adding rules based on attributes.required, attributes.pattern, etc.
1512
+ });
1513
+ const handleClick = () => {
1514
+ if (attributes.onclickTrigger) {
1515
+ triggerToWindowCall(attributes.onclickTrigger);
1516
+ }
1517
+ };
1518
+ return {
1519
+ ...controller.field,
1520
+ type: attributes.type,
1521
+ onClick: handleClick,
1522
+ maxLength: attributes.maxlength,
1523
+ autoComplete: attributes.autocomplete,
1524
+ placeholder: placeholder || "",
1525
+ disabled: attributes.disabled || !controller.formState.isReady
1526
+ };
1527
+ }
1528
+ function InputRenderer({ node }) {
1529
+ const { Node: Node2 } = useComponents();
1530
+ const label = getNodeLabel(node);
1531
+ const intl = useIntl();
1532
+ const formState = useFormState();
1533
+ const attributes = node.attributes;
1534
+ const placeholder = label ? resolvePlaceholder(label, intl) : "";
1535
+ const inputProps = useInputProps(attributes, placeholder);
1536
+ const isPinCodeInput = attributes.name === "code" && node.group === "code" || attributes.name === "totp_code" && node.group === "totp";
1537
+ const InputComponent = isPinCodeInput ? Node2.CodeInput : Node2.Input;
1538
+ return /* @__PURE__ */ jsx(
1539
+ Node2.Label,
1540
+ {
1541
+ attributes,
1542
+ node,
1543
+ fieldError: formState.errors[attributes.name],
1544
+ children: /* @__PURE__ */ jsx(
1545
+ InputComponent,
1546
+ {
1547
+ attributes,
1548
+ node,
1549
+ onClick: inputProps.onClick,
1550
+ inputProps
1551
+ }
1552
+ )
1553
+ }
1554
+ );
1555
+ }
1556
+ function extractProvider(context) {
1557
+ if (context && typeof context === "object" && "provider" in context && typeof context.provider === "string") {
1558
+ return context.provider;
1559
+ }
1560
+ return void 0;
1561
+ }
1562
+ function SSOButtonRenderer({ node }) {
1563
+ var _a, _b;
1564
+ const { Node: Node2 } = useComponents();
1565
+ const attributes = node.attributes;
1566
+ const {
1567
+ setValue,
1568
+ formState: { isSubmitting, isReady }
1569
+ } = useFormContext();
1570
+ const [clicked, setClicked] = useDebounceValue(false, 100);
1571
+ useEffect(() => {
1572
+ if (!isSubmitting) {
1573
+ setClicked(false);
1574
+ }
1575
+ }, [isSubmitting, setClicked]);
1576
+ const clickHandler = useCallback(() => {
1577
+ setValue("provider", attributes.value);
1578
+ setValue("method", node.group);
1579
+ setClicked(true);
1580
+ }, [setValue, attributes.value, node.group, setClicked]);
1581
+ const buttonProps = {
1582
+ type: "submit",
1583
+ name: attributes.name,
1584
+ value: attributes.value,
1585
+ onClick: clickHandler,
1586
+ disabled: attributes.disabled || !isReady || isSubmitting
1587
+ };
1588
+ const provider = (_b = extractProvider((_a = node.meta.label) == null ? void 0 : _a.context)) != null ? _b : "";
1589
+ return /* @__PURE__ */ jsx(
1590
+ Node2.SsoButton,
1591
+ {
1592
+ node,
1593
+ attributes,
1594
+ buttonProps,
1595
+ provider,
1596
+ isSubmitting: clicked
1597
+ }
1598
+ );
1599
+ }
1600
+ function TextRenderer({ node }) {
1601
+ const { Node: Node2 } = useComponents();
1602
+ return /* @__PURE__ */ jsx(Node2.Text, { node, attributes: node.attributes });
1603
+ }
1604
+
1605
+ // src/components/form/nodes/renderer/index.ts
1606
+ var NodeRenderer = {
1607
+ Button: ButtonRenderer,
1608
+ SsoButton: SSOButtonRenderer,
1609
+ ConsentCheckbox: ConsentCheckboxRenderer,
1610
+ Input: InputRenderer,
1611
+ Checkbox: CheckboxRenderer,
1612
+ Image: ImageRenderer,
1613
+ Text: TextRenderer
1614
+ };
1615
+ function NodeButton({ node }) {
1616
+ var _a;
1617
+ const isResendNode = ((_a = node.meta.label) == null ? void 0 : _a.id) === 1070008;
1618
+ const isScreenSelectionNode2 = "name" in node.attributes && node.attributes.name === "screen";
1619
+ if (isResendNode || isScreenSelectionNode2) {
1620
+ return null;
1621
+ }
1622
+ if (node.group === "oauth2_consent") {
1623
+ return null;
1624
+ }
1625
+ const isSocial = (node.attributes.name === "provider" || node.attributes.name === "link") && (node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml);
1626
+ if (isSocial) {
1627
+ return /* @__PURE__ */ jsx(NodeRenderer.SsoButton, { node });
1628
+ }
1629
+ return /* @__PURE__ */ jsx(NodeRenderer.Button, { node });
1630
+ }
1631
+ function HiddenInputRenderer({ node }) {
1632
+ const { Node: Node2 } = useComponents();
1633
+ const attributes = node.attributes;
1634
+ const inputProps = useInputProps(attributes);
1635
+ return /* @__PURE__ */ jsx(
1636
+ Node2.Input,
1637
+ {
1638
+ inputProps,
1639
+ attributes,
1640
+ node,
1641
+ onClick: () => {
1642
+ }
1643
+ }
1644
+ );
1645
+ }
1248
1646
  var NodeInput = ({
1249
1647
  node,
1250
1648
  attributes
1251
1649
  }) => {
1252
1650
  var _a;
1253
- const { Node: Node2 } = useComponents();
1254
- const { setValue, watch } = useFormContext();
1651
+ const { setValue } = useFormContext();
1255
1652
  const {
1256
1653
  onloadTrigger,
1257
- onclickTrigger,
1258
1654
  // These properties do not exist on input fields so we remove them (as we already have handled them).
1259
1655
  onclick: _ignoredOnclick,
1260
1656
  onload: _ignoredOnload,
@@ -1281,117 +1677,44 @@ var NodeInput = ({
1281
1677
  // eslint-disable-next-line react-hooks/exhaustive-deps -- ignore onloadTrigger for now, until we make sure this is stable
1282
1678
  []
1283
1679
  );
1284
- const handleClick = () => {
1285
- setFormValue();
1286
- if (onclickTrigger) {
1287
- triggerToWindowCall(onclickTrigger);
1288
- }
1289
- };
1290
- const isSocial = (attrs.name === "provider" || attrs.name === "link") && (node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml);
1291
- const isPinCodeInput = attrs.name === "code" && node.group === "code" || attrs.name === "totp_code" && node.group === "totp";
1292
- const handleScopeChange = (checked) => {
1293
- const scopes = watch("grant_scope");
1294
- if (Array.isArray(scopes)) {
1295
- if (checked) {
1296
- setValue("grant_scope", Array.from(/* @__PURE__ */ new Set([...scopes, attrs.value])));
1297
- } else {
1298
- setValue(
1299
- "grant_scope",
1300
- scopes.filter((scope) => scope !== attrs.value)
1301
- );
1302
- }
1303
- }
1304
- };
1305
1680
  switch (attributes.type) {
1306
1681
  case UiNodeInputAttributesTypeEnum.Submit:
1307
- case UiNodeInputAttributesTypeEnum.Button:
1308
- if (isSocial) {
1309
- return /* @__PURE__ */ jsx(
1310
- Node2.SsoButton,
1311
- {
1312
- node,
1313
- attributes: attrs,
1314
- onClick: () => {
1315
- setValue(
1316
- "provider",
1317
- node.attributes.value
1318
- );
1319
- setValue("method", node.group);
1320
- }
1321
- }
1322
- );
1323
- }
1324
- if (isResendNode || isScreenSelectionNode2) {
1325
- return null;
1326
- }
1327
- if (node.group === "oauth2_consent") {
1328
- return null;
1329
- }
1330
- return /* @__PURE__ */ jsx(
1331
- Node2.Label,
1332
- {
1333
- attributes: { ...attrs, label: void 0 },
1334
- node: { ...node, meta: { ...node.meta, label: void 0 } },
1335
- children: /* @__PURE__ */ jsx(Node2.Button, { attributes: attrs, node, onClick: handleClick })
1336
- }
1337
- );
1682
+ case UiNodeInputAttributesTypeEnum.Button: {
1683
+ return /* @__PURE__ */ jsx(NodeButton, { node });
1684
+ }
1338
1685
  case UiNodeInputAttributesTypeEnum.DatetimeLocal:
1339
1686
  throw new Error("Not implemented");
1340
1687
  case UiNodeInputAttributesTypeEnum.Checkbox:
1341
1688
  if (node.group === "oauth2_consent" && node.attributes.node_type === "input") {
1342
1689
  switch (node.attributes.name) {
1343
1690
  case "grant_scope":
1344
- return /* @__PURE__ */ jsx(
1345
- Node2.ConsentScopeCheckbox,
1346
- {
1347
- attributes: attrs,
1348
- node,
1349
- onCheckedChange: handleScopeChange
1350
- }
1351
- );
1691
+ return /* @__PURE__ */ jsx(ConsentCheckboxRenderer, { node });
1352
1692
  default:
1353
1693
  return null;
1354
1694
  }
1355
1695
  }
1356
- return /* @__PURE__ */ jsx(
1357
- Node2.Label,
1358
- {
1359
- attributes: { ...attrs, label: void 0 },
1360
- node: { ...node, meta: { ...node.meta, label: void 0 } },
1361
- children: /* @__PURE__ */ jsx(Node2.Checkbox, { attributes: attrs, node, onClick: handleClick })
1362
- }
1363
- );
1696
+ return /* @__PURE__ */ jsx(CheckboxRenderer, { node });
1364
1697
  case UiNodeInputAttributesTypeEnum.Hidden:
1365
- return /* @__PURE__ */ jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick });
1698
+ return /* @__PURE__ */ jsx(HiddenInputRenderer, { node });
1366
1699
  default:
1367
- if (isPinCodeInput) {
1368
- return /* @__PURE__ */ jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsx(
1369
- Node2.CodeInput,
1370
- {
1371
- attributes: attrs,
1372
- node,
1373
- onClick: handleClick
1374
- }
1375
- ) });
1376
- }
1377
- return /* @__PURE__ */ jsx(Node2.Label, { attributes: attrs, node, children: /* @__PURE__ */ jsx(Node2.Input, { attributes: attrs, node, onClick: handleClick }) });
1700
+ return /* @__PURE__ */ jsx(InputRenderer, { node });
1378
1701
  }
1379
1702
  };
1380
- var Node = ({ node, onClick }) => {
1703
+ var ignoredScriptGroups = ["captcha"];
1704
+ var NodeBase = ({ node }) => {
1381
1705
  const { Node: Node2 } = useComponents();
1382
1706
  if (node.group === UiNodeGroupEnum.Captcha) {
1383
1707
  return /* @__PURE__ */ jsx(Node2.Captcha, { node });
1384
1708
  }
1385
- if (isUiNodeImageAttributes(node.attributes)) {
1386
- return /* @__PURE__ */ jsx(Node2.Image, { node, attributes: node.attributes });
1387
- } else if (isUiNodeTextAttributes(node.attributes)) {
1388
- const attrs = node.attributes;
1389
- return /* @__PURE__ */ jsx(Node2.Text, { attributes: attrs, node });
1390
- } else if (isUiNodeInputAttributes(node.attributes)) {
1391
- return /* @__PURE__ */ jsx(NodeInput, { node, attributes: node.attributes, onClick });
1392
- } else if (isUiNodeAnchorAttributes(node.attributes)) {
1709
+ if (isUiNodeImage(node)) {
1710
+ return /* @__PURE__ */ jsx(NodeRenderer.Image, { node });
1711
+ } else if (isUiNodeText(node)) {
1712
+ return /* @__PURE__ */ jsx(NodeRenderer.Text, { node });
1713
+ } else if (isUiNodeInput(node)) {
1714
+ return /* @__PURE__ */ jsx(NodeInput, { node, attributes: node.attributes });
1715
+ } else if (isUiNodeAnchor(node)) {
1393
1716
  return /* @__PURE__ */ jsx(Node2.Anchor, { attributes: node.attributes, node });
1394
- } else if (isUiNodeScriptAttributes(node.attributes)) {
1717
+ } else if (isUiNodeScript(node) && !ignoredScriptGroups.includes(node.group)) {
1395
1718
  const {
1396
1719
  crossorigin,
1397
1720
  referrerpolicy,
@@ -1409,6 +1732,7 @@ var Node = ({ node, onClick }) => {
1409
1732
  }
1410
1733
  return null;
1411
1734
  };
1735
+ var Node = Object.assign(NodeBase, NodeRenderer);
1412
1736
  function MethodActiveForm({
1413
1737
  formState
1414
1738
  }) {
@@ -1437,29 +1761,14 @@ function OryFormSsoButtons() {
1437
1761
  const {
1438
1762
  flow: { ui }
1439
1763
  } = useOryFlow();
1440
- const { setValue } = useFormContext();
1441
1764
  const filteredNodes = ui.nodes.filter(
1442
1765
  (node) => node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml
1443
1766
  );
1444
- const { Form, Node: Node2 } = useComponents();
1767
+ const { Form } = useComponents();
1445
1768
  if (filteredNodes.length === 0) {
1446
1769
  return null;
1447
1770
  }
1448
- return /* @__PURE__ */ jsx(Form.SsoRoot, { nodes: filteredNodes, children: filteredNodes.map((node) => /* @__PURE__ */ jsx(
1449
- Node2.SsoButton,
1450
- {
1451
- node,
1452
- attributes: node.attributes,
1453
- onClick: () => {
1454
- setValue(
1455
- "provider",
1456
- node.attributes.value
1457
- );
1458
- setValue("method", node.group);
1459
- }
1460
- },
1461
- getNodeId(node)
1462
- )) });
1771
+ return /* @__PURE__ */ jsx(Form.SsoRoot, { nodes: filteredNodes, children: filteredNodes.map((node) => /* @__PURE__ */ jsx(Node, { node }, getNodeId(node))) });
1463
1772
  }
1464
1773
  function OryFormSsoForm() {
1465
1774
  const {
@@ -1501,7 +1810,7 @@ function AuthMethodList({
1501
1810
  setSelectedGroup
1502
1811
  }) {
1503
1812
  const { Card } = useComponents();
1504
- const { setValue, getValues } = useFormContext();
1813
+ const { setValue, getValues, formState } = useFormContext();
1505
1814
  if (Object.entries(options).length === 0) {
1506
1815
  return null;
1507
1816
  }
@@ -1521,7 +1830,8 @@ function AuthMethodList({
1521
1830
  {
1522
1831
  group,
1523
1832
  title: options2.title,
1524
- onClick: () => handleClick(group, options2)
1833
+ onClick: () => handleClick(group, options2),
1834
+ disabled: !formState.isReady || formState.isSubmitting
1525
1835
  },
1526
1836
  group
1527
1837
  )) });
@@ -1659,6 +1969,42 @@ function OrySettingsFormSectionInner({
1659
1969
  }
1660
1970
  );
1661
1971
  }
1972
+ function findResendNode(nodes) {
1973
+ return nodes.find(
1974
+ (n) => "name" in n.attributes && (["email", "recovery_confirm_address"].includes(n.attributes.name) && n.attributes.type === "submit" || n.attributes.name === "resend")
1975
+ );
1976
+ }
1977
+ function useResendCode() {
1978
+ const flowContainer = useOryFlow();
1979
+ const resendCodeNode = findResendNode(flowContainer.flow.ui.nodes);
1980
+ const formSubmit = useOryFormSubmit();
1981
+ const handleResend = useCallback(() => {
1982
+ const hiddenFields = flowContainer.flow.ui.nodes.filter(
1983
+ (n) => n.attributes.node_type === "input" && (n.attributes.type === "hidden" || n.group === "default")
1984
+ );
1985
+ const hiddenData = computeDefaultValues({
1986
+ active: flowContainer.flow.active,
1987
+ ui: { nodes: hiddenFields }
1988
+ });
1989
+ if ((resendCodeNode == null ? void 0 : resendCodeNode.attributes) && "name" in resendCodeNode.attributes) {
1990
+ const data = {
1991
+ code: void 0,
1992
+ [resendCodeNode.attributes.name]: resendCodeNode.attributes.value,
1993
+ method: "code"
1994
+ };
1995
+ formSubmit({ ...hiddenData, ...data });
1996
+ }
1997
+ }, [
1998
+ flowContainer.flow.active,
1999
+ flowContainer.flow.ui.nodes,
2000
+ formSubmit,
2001
+ resendCodeNode
2002
+ ]);
2003
+ return {
2004
+ resendCode: handleResend,
2005
+ resendCodeNode
2006
+ };
2007
+ }
1662
2008
  function OryConsentCard() {
1663
2009
  const { Form, Card } = useComponents();
1664
2010
  const flow = useOryFlow();
@@ -1697,32 +2043,54 @@ function showToast(toast$1, ToastComponent) {
1697
2043
  }
1698
2044
  var getLinkButtons = (nodes) => nodes.filter(
1699
2045
  (node) => "name" in node.attributes && node.attributes.name === "link"
1700
- );
2046
+ ).filter(isUiNodeInput);
1701
2047
  var getUnlinkButtons = (nodes) => nodes.filter(
1702
2048
  (node) => "name" in node.attributes && node.attributes.name === "unlink"
1703
- );
2049
+ ).filter(isUiNodeInput);
1704
2050
  function OrySettingsOidc({ nodes }) {
1705
2051
  const { Card, Form } = useComponents();
1706
2052
  const intl = useIntl();
1707
- const { setValue } = useFormContext();
1708
- const linkButtons = getLinkButtons(nodes).map((node) => ({
1709
- ...node,
1710
- onClick: () => {
1711
- if (node.attributes.node_type === "input") {
1712
- setValue("link", node.attributes.value);
1713
- setValue("method", node.group);
1714
- }
2053
+ const { setValue, formState } = useFormContext();
2054
+ const linkButtons = getLinkButtons(nodes).map(
2055
+ (node) => {
2056
+ const clickHandler = function() {
2057
+ if (node.attributes.node_type === "input") {
2058
+ setValue("link", node.attributes.value);
2059
+ setValue("method", node.group);
2060
+ }
2061
+ };
2062
+ return {
2063
+ ...node,
2064
+ onClick: clickHandler,
2065
+ buttonProps: {
2066
+ name: node.attributes.name,
2067
+ value: node.attributes.value,
2068
+ onClick: clickHandler,
2069
+ type: "submit"
2070
+ }
2071
+ };
1715
2072
  }
1716
- }));
1717
- const unlinkButtons = getUnlinkButtons(nodes).map((node) => ({
1718
- ...node,
1719
- onClick: () => {
1720
- if (node.attributes.node_type === "input") {
1721
- setValue("unlink", node.attributes.value);
1722
- setValue("method", node.group);
1723
- }
2073
+ );
2074
+ const unlinkButtons = getUnlinkButtons(nodes).map(
2075
+ (node) => {
2076
+ const clickHandler = function() {
2077
+ if (node.attributes.node_type === "input") {
2078
+ setValue("unlink", node.attributes.value);
2079
+ setValue("method", node.group);
2080
+ }
2081
+ };
2082
+ return {
2083
+ ...node,
2084
+ onClick: clickHandler,
2085
+ buttonProps: {
2086
+ name: node.attributes.name,
2087
+ value: node.attributes.value,
2088
+ onClick: clickHandler,
2089
+ type: "submit"
2090
+ }
2091
+ };
1724
2092
  }
1725
- }));
2093
+ );
1726
2094
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1727
2095
  /* @__PURE__ */ jsx(
1728
2096
  Card.SettingsSectionContent,
@@ -1733,7 +2101,8 @@ function OrySettingsOidc({ nodes }) {
1733
2101
  Form.SsoSettings,
1734
2102
  {
1735
2103
  linkButtons,
1736
- unlinkButtons
2104
+ unlinkButtons,
2105
+ isSubmitting: formState.isSubmitting
1737
2106
  }
1738
2107
  )
1739
2108
  }
@@ -1746,7 +2115,7 @@ function OrySettingsOidc({ nodes }) {
1746
2115
  )
1747
2116
  ] });
1748
2117
  }
1749
- var getTriggerNode = (nodes) => nodes.find(
2118
+ var getTriggerNode = (nodes) => nodes.filter(isUiNodeInput).find(
1750
2119
  (node) => "name" in node.attributes && node.attributes.name === "passkey_register_trigger"
1751
2120
  );
1752
2121
  var getSettingsNodes = (nodes) => nodes.filter(
@@ -1754,11 +2123,11 @@ var getSettingsNodes = (nodes) => nodes.filter(
1754
2123
  );
1755
2124
  var getRemoveNodes = (nodes) => nodes.filter(
1756
2125
  (node) => "name" in node.attributes && node.attributes.name === "passkey_remove"
1757
- );
2126
+ ).filter(isUiNodeInput);
1758
2127
  function OrySettingsPasskey({ nodes }) {
1759
2128
  const { Card, Form } = useComponents();
1760
2129
  const intl = useIntl();
1761
- const { setValue } = useFormContext();
2130
+ const { setValue, formState } = useFormContext();
1762
2131
  const triggerButton = getTriggerNode(nodes);
1763
2132
  const settingsNodes = getSettingsNodes(nodes);
1764
2133
  const removeNodes = getRemoveNodes(nodes);
@@ -1792,14 +2161,27 @@ function OrySettingsPasskey({ nodes }) {
1792
2161
  /* @__PURE__ */ jsx(
1793
2162
  Form.PasskeySettings,
1794
2163
  {
2164
+ isSubmitting: formState.isSubmitting,
1795
2165
  triggerButton: {
1796
2166
  ...triggerButton,
1797
- attributes: triggerAttributes,
1798
- onClick: onTriggerClick
2167
+ onClick: onTriggerClick,
2168
+ buttonProps: {
2169
+ name: triggerAttributes.name,
2170
+ value: triggerAttributes.value,
2171
+ onClick: onTriggerClick,
2172
+ type: "button"
2173
+ }
1799
2174
  },
1800
2175
  removeButtons: removeNodes.map((node) => ({
1801
2176
  ...node,
1802
2177
  onClick: node.attributes.node_type === "input" ? removePasskeyHandler(node.attributes.value) : () => {
2178
+ },
2179
+ buttonProps: {
2180
+ name: node.attributes.name,
2181
+ value: node.attributes.value,
2182
+ onClick: node.attributes.node_type === "input" ? removePasskeyHandler(node.attributes.value) : () => {
2183
+ },
2184
+ type: "button"
1803
2185
  }
1804
2186
  }))
1805
2187
  }
@@ -1816,32 +2198,32 @@ function OrySettingsPasskey({ nodes }) {
1816
2198
  ] });
1817
2199
  }
1818
2200
  var getRegenerateNode = (nodes) => nodes.find(
1819
- (node) => "name" in node.attributes && node.attributes.name === "lookup_secret_regenerate"
2201
+ (node) => "name" in node.attributes && node.attributes.name === "lookup_secret_regenerate" && isUiNodeInput(node)
1820
2202
  );
1821
2203
  var getRevealNode = (nodes) => nodes.find(
1822
- (node) => "name" in node.attributes && node.attributes.name === "lookup_secret_reveal"
2204
+ (node) => "name" in node.attributes && node.attributes.name === "lookup_secret_reveal" && isUiNodeInput(node)
1823
2205
  );
1824
2206
  var getRecoveryCodes = (nodes) => nodes.find(
1825
- (node) => "id" in node.attributes && node.attributes.id === "lookup_secret_codes"
2207
+ (node) => "id" in node.attributes && node.attributes.id === "lookup_secret_codes" && isUiNodeText(node)
1826
2208
  );
1827
2209
  var getDisableNode = (nodes) => nodes.find(
1828
- (node) => "name" in node.attributes && node.attributes.name === "lookup_secret_disable"
2210
+ (node) => "name" in node.attributes && node.attributes.name === "lookup_secret_disable" && isUiNodeInput(node)
1829
2211
  );
1830
2212
  var getConfirmNode = (nodes) => nodes.find(
1831
- (node) => "name" in node.attributes && node.attributes.name === "lookup_secret_confirm"
2213
+ (node) => "name" in node.attributes && node.attributes.name === "lookup_secret_confirm" && isUiNodeInput(node)
1832
2214
  );
1833
2215
  function OrySettingsRecoveryCodes({
1834
2216
  nodes
1835
2217
  }) {
1836
2218
  var _a, _b, _c;
1837
- const { Card, Form, Node: Node2 } = useComponents();
2219
+ const { Card, Form } = useComponents();
1838
2220
  const intl = useIntl();
1839
2221
  const codesNode = getRecoveryCodes(nodes);
1840
2222
  const revealNode = getRevealNode(nodes);
1841
2223
  const regenerateNode = getRegenerateNode(nodes);
1842
2224
  const disableNode = getDisableNode(nodes);
1843
2225
  const confirmNode = getConfirmNode(nodes);
1844
- const { setValue } = useFormContext();
2226
+ const { setValue, formState } = useFormContext();
1845
2227
  const codesContext = (_b = (_a = codesNode == null ? void 0 : codesNode.attributes) == null ? void 0 : _a.text.context) != null ? _b : {};
1846
2228
  const secrets = codesContext.secrets ? codesContext.secrets.map((i) => i.text) : [];
1847
2229
  const onRegenerate = () => {
@@ -1870,41 +2252,36 @@ function OrySettingsRecoveryCodes({
1870
2252
  {
1871
2253
  codes: secrets,
1872
2254
  revealButton: revealNode,
1873
- regnerateButton: regenerateNode,
2255
+ regenerateButton: regenerateNode,
1874
2256
  onRegenerate,
1875
- onReveal
2257
+ onReveal,
2258
+ isSubmitting: formState.isSubmitting
1876
2259
  }
1877
2260
  )
1878
2261
  }
1879
2262
  ),
1880
- /* @__PURE__ */ jsx(Card.SettingsSectionFooter, { children: footerNode && /* @__PURE__ */ jsx(
1881
- Node2.Button,
1882
- {
1883
- node: footerNode,
1884
- attributes: footerNode.attributes
1885
- }
1886
- ) })
2263
+ /* @__PURE__ */ jsx(Card.SettingsSectionFooter, { children: footerNode && /* @__PURE__ */ jsx(Node, { node: footerNode }) })
1887
2264
  ] });
1888
2265
  }
1889
2266
  var getQrCodeNode = (nodes) => nodes.find(
1890
- (node) => "id" in node.attributes && node.attributes.id === "totp_qr"
2267
+ (node) => "id" in node.attributes && node.attributes.id === "totp_qr" && isUiNodeImage(node)
1891
2268
  );
1892
2269
  var getTotpSecretNode = (nodes) => nodes.find(
1893
- (node) => "id" in node.attributes && node.attributes.id === "totp_secret_key"
2270
+ (node) => "id" in node.attributes && node.attributes.id === "totp_secret_key" && isUiNodeText(node)
1894
2271
  );
1895
2272
  var getTotpInputNode = (nodes) => nodes.find(
1896
- (node) => "name" in node.attributes && node.attributes.name === "totp_code"
2273
+ (node) => "name" in node.attributes && node.attributes.name === "totp_code" && isUiNodeInput(node)
1897
2274
  );
1898
2275
  var getTotpUnlinkInput = (nodes) => nodes.find(
1899
- (node) => "name" in node.attributes && node.attributes.name === "totp_unlink"
2276
+ (node) => "name" in node.attributes && node.attributes.name === "totp_unlink" && isUiNodeInput(node)
1900
2277
  );
1901
2278
  var getTotpLinkButton = (nodes) => nodes.find(
1902
- (node) => "name" in node.attributes && node.attributes.name === "method"
2279
+ (node) => "name" in node.attributes && node.attributes.name === "method" && isUiNodeInput(node)
1903
2280
  );
1904
2281
  function OrySettingsTotp({ nodes }) {
1905
- const { Card, Form, Node: Node2 } = useComponents();
2282
+ const { Card, Form } = useComponents();
1906
2283
  const intl = useIntl();
1907
- const { setValue } = useFormContext();
2284
+ const { setValue, formState } = useFormContext();
1908
2285
  const totpUnlink = getTotpUnlinkInput(nodes);
1909
2286
  const qrNode = getQrCodeNode(nodes);
1910
2287
  const secretNode = getTotpSecretNode(nodes);
@@ -1922,14 +2299,22 @@ function OrySettingsTotp({ nodes }) {
1922
2299
  {
1923
2300
  title: intl.formatMessage({ id: "settings.totp.title" }),
1924
2301
  description: intl.formatMessage({ id: "settings.totp.description" }),
1925
- children: /* @__PURE__ */ jsx(
2302
+ children: qrNode && secretNode && totpCodeNode && !totpUnlink ? /* @__PURE__ */ jsx(
2303
+ TotpSettingsLink,
2304
+ {
2305
+ totpImage: qrNode,
2306
+ totpSecret: secretNode,
2307
+ totpInput: totpCodeNode
2308
+ }
2309
+ ) : /* @__PURE__ */ jsx(
1926
2310
  Form.TotpSettings,
1927
2311
  {
1928
2312
  totpImage: qrNode,
1929
2313
  totpSecret: secretNode,
1930
- totpInput: totpCodeNode,
2314
+ totpInput: void 0,
1931
2315
  totpUnlink,
1932
- onUnlink: handleUnlink
2316
+ onUnlink: handleUnlink,
2317
+ isSubmitting: formState.isSubmitting
1933
2318
  }
1934
2319
  )
1935
2320
  }
@@ -1938,17 +2323,31 @@ function OrySettingsTotp({ nodes }) {
1938
2323
  Card.SettingsSectionFooter,
1939
2324
  {
1940
2325
  text: totpUnlink ? intl.formatMessage({ id: "settings.totp.info.linked" }) : intl.formatMessage({ id: "settings.totp.info.not-linked" }),
1941
- children: totpLinkButton && /* @__PURE__ */ jsx(
1942
- Node2.Button,
1943
- {
1944
- node: totpLinkButton,
1945
- attributes: totpLinkButton.attributes
1946
- }
1947
- )
2326
+ children: totpLinkButton && /* @__PURE__ */ jsx(Node, { node: totpLinkButton })
1948
2327
  }
1949
2328
  )
1950
2329
  ] });
1951
2330
  }
2331
+ function TotpSettingsLink({
2332
+ totpImage,
2333
+ totpSecret,
2334
+ totpInput
2335
+ }) {
2336
+ const { formState } = useFormContext();
2337
+ const { Form } = useComponents();
2338
+ return /* @__PURE__ */ jsx(
2339
+ Form.TotpSettings,
2340
+ {
2341
+ totpImage,
2342
+ totpSecret,
2343
+ totpInput,
2344
+ totpUnlink: void 0,
2345
+ onUnlink: () => {
2346
+ },
2347
+ isSubmitting: formState.isSubmitting
2348
+ }
2349
+ );
2350
+ }
1952
2351
  var getInputNode = (nodes) => nodes.find(
1953
2352
  (node) => "name" in node.attributes && node.attributes.name === "webauthn_register_displayname"
1954
2353
  );
@@ -1962,30 +2361,14 @@ var getRegisterNode = (nodes) => nodes.find(
1962
2361
  (node) => "name" in node.attributes && node.attributes.name === "webauthn_register"
1963
2362
  );
1964
2363
  function OrySettingsWebauthn({ nodes }) {
1965
- const { Card, Form } = useComponents();
2364
+ const { Card } = useComponents();
1966
2365
  const intl = useIntl();
1967
- const { setValue } = useFormContext();
1968
2366
  const triggerButton = getTriggerNode2(nodes);
1969
2367
  const inputNode = getInputNode(nodes);
1970
- const removeButtons = getRemoveButtons(nodes);
1971
2368
  const registerNode = getRegisterNode(nodes);
1972
- if (!inputNode || !triggerButton) {
2369
+ if (!inputNode || !triggerButton || inputNode.attributes.node_type !== "input") {
1973
2370
  return null;
1974
2371
  }
1975
- const {
1976
- onclick: _onClick,
1977
- onclickTrigger,
1978
- ...triggerAttributes
1979
- } = triggerButton.attributes;
1980
- const onTriggerClick = () => {
1981
- triggerToWindowCall(onclickTrigger);
1982
- };
1983
- const removeWebauthnKeyHandler = (value) => {
1984
- return () => {
1985
- setValue("webauthn_remove", value);
1986
- setValue("method", "webauthn");
1987
- };
1988
- };
1989
2372
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1990
2373
  /* @__PURE__ */ jsxs(
1991
2374
  Card.SettingsSectionContent,
@@ -1996,19 +2379,11 @@ function OrySettingsWebauthn({ nodes }) {
1996
2379
  }),
1997
2380
  children: [
1998
2381
  /* @__PURE__ */ jsx(
1999
- Form.WebauthnSettings,
2382
+ WebauthnForm,
2000
2383
  {
2001
- nameInput: inputNode,
2002
- triggerButton: {
2003
- ...triggerButton,
2004
- attributes: triggerAttributes,
2005
- onClick: onTriggerClick
2006
- },
2007
- removeButtons: removeButtons.map((node) => ({
2008
- ...node,
2009
- onClick: node.attributes.node_type === "input" ? removeWebauthnKeyHandler(node.attributes.value) : () => {
2010
- }
2011
- }))
2384
+ inputNode,
2385
+ nodes,
2386
+ triggerButton
2012
2387
  }
2013
2388
  ),
2014
2389
  registerNode && /* @__PURE__ */ jsx(Node, { node: registerNode })
@@ -2023,6 +2398,54 @@ function OrySettingsWebauthn({ nodes }) {
2023
2398
  )
2024
2399
  ] });
2025
2400
  }
2401
+ function WebauthnForm({ inputNode, triggerButton, nodes }) {
2402
+ const { Form } = useComponents();
2403
+ const { setValue, formState } = useFormContext();
2404
+ const removeButtons = getRemoveButtons(nodes);
2405
+ const {
2406
+ onclick: _onClick,
2407
+ onclickTrigger,
2408
+ ...triggerAttributes
2409
+ } = triggerButton.attributes;
2410
+ const onTriggerClick = () => {
2411
+ triggerToWindowCall(onclickTrigger);
2412
+ };
2413
+ const removeWebauthnKeyHandler = (value) => {
2414
+ return () => {
2415
+ setValue("webauthn_remove", value);
2416
+ setValue("method", "webauthn");
2417
+ };
2418
+ };
2419
+ return /* @__PURE__ */ jsx(
2420
+ Form.WebauthnSettings,
2421
+ {
2422
+ isSubmitting: formState.isSubmitting,
2423
+ nameInput: inputNode,
2424
+ triggerButton: {
2425
+ ...triggerButton,
2426
+ onClick: onTriggerClick,
2427
+ buttonProps: {
2428
+ name: triggerAttributes.name,
2429
+ value: triggerAttributes.value,
2430
+ onClick: onTriggerClick,
2431
+ type: "button"
2432
+ }
2433
+ },
2434
+ removeButtons: removeButtons.map((node) => ({
2435
+ ...node,
2436
+ onClick: node.attributes.node_type === "input" ? removeWebauthnKeyHandler(node.attributes.value) : () => {
2437
+ },
2438
+ buttonProps: {
2439
+ name: node.attributes.name,
2440
+ value: node.attributes.value,
2441
+ onClick: node.attributes.node_type === "input" ? removeWebauthnKeyHandler(node.attributes.value) : () => {
2442
+ },
2443
+ type: "submit"
2444
+ }
2445
+ }))
2446
+ }
2447
+ );
2448
+ }
2026
2449
  function SettingsSectionContent({ group, nodes }) {
2027
2450
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2028
2451
  const { Card } = useComponents();
@@ -2169,69 +2592,6 @@ function SettingsMessageToaster() {
2169
2592
  return /* @__PURE__ */ jsx(Toaster, {});
2170
2593
  }
2171
2594
 
2172
- // src/util/i18n/index.ts
2173
- var uiTextToFormattedMessage = ({ id, context = {}, text }, intl) => {
2174
- const contextInjectedMessage = Object.entries(context).reduce(
2175
- (accumulator, [key, value]) => {
2176
- if (Array.isArray(value)) {
2177
- return {
2178
- ...accumulator,
2179
- [key]: value,
2180
- [key + "_list"]: intl.formatList(value)
2181
- };
2182
- } else if (key.endsWith("_unix")) {
2183
- if (typeof value === "number") {
2184
- return {
2185
- ...accumulator,
2186
- [key]: intl.formatDate(new Date(value * 1e3)),
2187
- [key + "_since"]: intl.formatDateTimeRange(
2188
- new Date(value),
2189
- /* @__PURE__ */ new Date()
2190
- ),
2191
- [key + "_since_minutes"]: Math.ceil(
2192
- (value - (/* @__PURE__ */ new Date()).getTime() / 1e3) / 60
2193
- ).toFixed(0),
2194
- [key + "_until"]: intl.formatDateTimeRange(
2195
- /* @__PURE__ */ new Date(),
2196
- new Date(value)
2197
- ),
2198
- [key + "_until_minutes"]: Math.ceil(
2199
- ((/* @__PURE__ */ new Date()).getTime() / 1e3 - value) / 60
2200
- ).toFixed(0)
2201
- };
2202
- }
2203
- } else if (key === "property") {
2204
- return {
2205
- ...accumulator,
2206
- [key]: intl.formatMessage({
2207
- id: `property.${value}`,
2208
- defaultMessage: value
2209
- })
2210
- };
2211
- }
2212
- return {
2213
- ...accumulator,
2214
- [key]: value
2215
- };
2216
- },
2217
- {}
2218
- );
2219
- return intl.formatMessage(
2220
- {
2221
- id: `identities.messages.${id}`,
2222
- defaultMessage: text
2223
- },
2224
- contextInjectedMessage
2225
- );
2226
- };
2227
-
2228
- // src/util/test-id.ts
2229
- function messageTestId(message) {
2230
- return {
2231
- "data-testid": `ory/message/${message.id}`
2232
- };
2233
- }
2234
-
2235
2595
  // src/locales/af.json
2236
2596
  var af_default = {
2237
2597
  "consent.action-accept": "Toelaat",
@@ -27053,6 +27413,6 @@ var OryLocales = Object.freeze({
27053
27413
  zu: zu_default
27054
27414
  });
27055
27415
 
27056
- export { OryCard, OryCardContent, OryCardFooter, OryCardHeader, OryCardValidationMessages, OryConfigurationProvider, OryConsentCard, OryForm, OryFormGroupDivider, OryFormSsoButtons, OryFormSsoForm, OryLocales, OryPageHeader, OryProvider, OrySelfServiceFlowCard, OrySettingsCard, OrySettingsFormSection, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryConfiguration, useOryFlow };
27416
+ export { Node, OryCard, OryCardContent, OryCardFooter, OryCardHeader, OryCardValidationMessages, OryConfigurationProvider, OryConsentCard, OryForm, OryFormGroupDivider, OryFormSsoButtons, OryFormSsoForm, OryLocales, OryPageHeader, OryProvider, OrySelfServiceFlowCard, OrySettingsCard, OrySettingsFormSection, isUiNodeAnchor, isUiNodeDiv, isUiNodeImage, isUiNodeInput, isUiNodeScript, isUiNodeText, messageTestId, resolvePlaceholder, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryConfiguration, useOryFlow, useResendCode };
27057
27417
  //# sourceMappingURL=index.mjs.map
27058
27418
  //# sourceMappingURL=index.mjs.map