@secmia/openui-flow 4.0.1 → 4.1.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.
- package/AGENTS.md +5 -0
- package/README.md +99 -1
- package/dist/index.d.mts +58 -7
- package/dist/index.d.ts +58 -7
- package/dist/index.js +256 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +254 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,7 +40,8 @@ __export(index_exports, {
|
|
|
40
40
|
defaultRequirements: () => defaultRequirements,
|
|
41
41
|
evaluateNextStep: () => evaluateNextStep,
|
|
42
42
|
getMissingRequirements: () => getMissingRequirements,
|
|
43
|
-
initialContext: () => initialContext
|
|
43
|
+
initialContext: () => initialContext,
|
|
44
|
+
useAdaptiveFlow: () => useAdaptiveFlow
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(index_exports);
|
|
46
47
|
|
|
@@ -292,10 +293,78 @@ function clearPersistedState(persistence) {
|
|
|
292
293
|
}
|
|
293
294
|
storage.removeItem(persistence.key);
|
|
294
295
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
var FlowValidationError = class extends Error {
|
|
297
|
+
constructor(message, fieldErrors) {
|
|
298
|
+
super(message);
|
|
299
|
+
this.name = "FlowValidationError";
|
|
300
|
+
this.fieldErrors = fieldErrors;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
function toValidationError(issue, fallbackField) {
|
|
304
|
+
const field = issue.field ?? fallbackField;
|
|
305
|
+
if (field) {
|
|
306
|
+
return new FlowValidationError(issue.message, { [field]: issue.message });
|
|
307
|
+
}
|
|
308
|
+
return new FlowValidationError(issue.message, {});
|
|
309
|
+
}
|
|
310
|
+
function normalizeSchemaIssues(error, fallbackField) {
|
|
311
|
+
const fieldErrors = {};
|
|
312
|
+
const issues = error?.issues ?? [];
|
|
313
|
+
for (const issue of issues) {
|
|
314
|
+
const path = issue.path?.length ? issue.path.map(String).join(".") : fallbackField;
|
|
315
|
+
const message = issue.message?.trim() || error?.message || "Validation failed.";
|
|
316
|
+
if (path && !fieldErrors[path]) {
|
|
317
|
+
fieldErrors[path] = message;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (Object.keys(fieldErrors).length === 0 && fallbackField) {
|
|
321
|
+
fieldErrors[fallbackField] = error?.message || "Validation failed.";
|
|
322
|
+
}
|
|
323
|
+
return fieldErrors;
|
|
324
|
+
}
|
|
325
|
+
async function assertValid(result, fallbackField) {
|
|
326
|
+
const outcome = await result;
|
|
327
|
+
if (!outcome) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (typeof outcome === "string") {
|
|
331
|
+
const message = outcome.trim();
|
|
332
|
+
if (message.length > 0) {
|
|
333
|
+
throw new FlowValidationError(message, fallbackField ? { [fallbackField]: message } : {});
|
|
334
|
+
}
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (outcome.message.trim().length > 0) {
|
|
338
|
+
throw toValidationError(outcome, fallbackField);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
async function assertSchema(schema, value, fallbackField) {
|
|
342
|
+
if (!schema) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (schema.safeParse) {
|
|
346
|
+
const result = schema.safeParse(value);
|
|
347
|
+
if (!result.success) {
|
|
348
|
+
const fieldErrors = normalizeSchemaIssues(result.error, fallbackField);
|
|
349
|
+
throw new FlowValidationError(result.error?.message || "Validation failed.", fieldErrors);
|
|
350
|
+
}
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (!schema.parse) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
try {
|
|
357
|
+
schema.parse(value);
|
|
358
|
+
} catch (error) {
|
|
359
|
+
const normalized = error;
|
|
360
|
+
const fieldErrors = normalizeSchemaIssues(
|
|
361
|
+
{
|
|
362
|
+
message: normalized?.message,
|
|
363
|
+
issues: normalized?.issues
|
|
364
|
+
},
|
|
365
|
+
fallbackField
|
|
366
|
+
);
|
|
367
|
+
throw new FlowValidationError(normalized?.message || "Validation failed.", fieldErrors);
|
|
299
368
|
}
|
|
300
369
|
}
|
|
301
370
|
function resolveStyles(unstyled, styleOverrides) {
|
|
@@ -312,26 +381,20 @@ function resolveStyles(unstyled, styleOverrides) {
|
|
|
312
381
|
}
|
|
313
382
|
return resolved;
|
|
314
383
|
}
|
|
315
|
-
function
|
|
384
|
+
function useAdaptiveFlow({
|
|
316
385
|
adapter,
|
|
317
386
|
requirements,
|
|
318
387
|
requirementGraph,
|
|
319
388
|
requirementGraphConfig,
|
|
320
389
|
requirementResolvers,
|
|
321
390
|
completeStep,
|
|
322
|
-
stepTitles,
|
|
323
|
-
renderStep,
|
|
324
|
-
stepRegistry,
|
|
325
391
|
initialValue,
|
|
326
392
|
onComplete,
|
|
327
393
|
onError,
|
|
328
394
|
onStepTransition,
|
|
329
|
-
className,
|
|
330
|
-
classNames,
|
|
331
|
-
styles,
|
|
332
|
-
unstyled = false,
|
|
333
395
|
persistence,
|
|
334
|
-
validators
|
|
396
|
+
validators,
|
|
397
|
+
schemas
|
|
335
398
|
}) {
|
|
336
399
|
const normalizedRequirements = React.useMemo(
|
|
337
400
|
() => requirements ?? defaultRequirements,
|
|
@@ -365,7 +428,6 @@ function AdaptiveFlow({
|
|
|
365
428
|
requirementGraphConfig?.dependencies
|
|
366
429
|
]
|
|
367
430
|
);
|
|
368
|
-
const uiStyles = React.useMemo(() => resolveStyles(unstyled, styles), [unstyled, styles]);
|
|
369
431
|
const [context, setContext] = React.useState(() => withDefaults(initialValue));
|
|
370
432
|
const [step, setStep] = React.useState(normalizedCompleteStep);
|
|
371
433
|
const [missingRequirements, setMissingRequirements] = React.useState([]);
|
|
@@ -373,6 +435,7 @@ function AdaptiveFlow({
|
|
|
373
435
|
const [busy, setBusy] = React.useState(false);
|
|
374
436
|
const [message, setMessage] = React.useState(null);
|
|
375
437
|
const [errorMessage, setErrorMessage] = React.useState(null);
|
|
438
|
+
const [fieldErrors, setFieldErrors] = React.useState({});
|
|
376
439
|
const [oauthPendingProvider, setOauthPendingProvider] = React.useState(null);
|
|
377
440
|
const [persistenceHydrated, setPersistenceHydrated] = React.useState(!persistence);
|
|
378
441
|
const attemptByStepRef = React.useRef({});
|
|
@@ -400,14 +463,14 @@ function AdaptiveFlow({
|
|
|
400
463
|
let isCancelled = false;
|
|
401
464
|
const currentEvaluation = ++evaluationRef.current;
|
|
402
465
|
void (async () => {
|
|
403
|
-
const [
|
|
466
|
+
const [missing, next] = await Promise.all([
|
|
404
467
|
getMissingRequirements(context, graph),
|
|
405
468
|
evaluateNextStep(context, graph, normalizedCompleteStep)
|
|
406
469
|
]);
|
|
407
470
|
if (isCancelled || currentEvaluation !== evaluationRef.current) {
|
|
408
471
|
return;
|
|
409
472
|
}
|
|
410
|
-
setMissingRequirements(
|
|
473
|
+
setMissingRequirements(missing);
|
|
411
474
|
setStep(next);
|
|
412
475
|
const from = previousStepRef.current;
|
|
413
476
|
const attemptKey = String(next);
|
|
@@ -427,6 +490,7 @@ function AdaptiveFlow({
|
|
|
427
490
|
return;
|
|
428
491
|
}
|
|
429
492
|
const normalized = toError(error);
|
|
493
|
+
setFieldErrors({});
|
|
430
494
|
setErrorMessage(normalized.message);
|
|
431
495
|
onError?.(normalized);
|
|
432
496
|
});
|
|
@@ -461,12 +525,21 @@ function AdaptiveFlow({
|
|
|
461
525
|
async (job) => {
|
|
462
526
|
setBusy(true);
|
|
463
527
|
setErrorMessage(null);
|
|
528
|
+
setFieldErrors({});
|
|
464
529
|
try {
|
|
465
530
|
await job();
|
|
466
531
|
} catch (error) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
532
|
+
if (error instanceof FlowValidationError) {
|
|
533
|
+
setFieldErrors(error.fieldErrors);
|
|
534
|
+
if (Object.keys(error.fieldErrors).length === 0) {
|
|
535
|
+
setErrorMessage(error.message);
|
|
536
|
+
onError?.(error);
|
|
537
|
+
}
|
|
538
|
+
} else {
|
|
539
|
+
const normalized = toError(error);
|
|
540
|
+
setErrorMessage(normalized.message);
|
|
541
|
+
onError?.(normalized);
|
|
542
|
+
}
|
|
470
543
|
} finally {
|
|
471
544
|
setBusy(false);
|
|
472
545
|
}
|
|
@@ -502,8 +575,9 @@ function AdaptiveFlow({
|
|
|
502
575
|
return;
|
|
503
576
|
}
|
|
504
577
|
void run(async () => {
|
|
578
|
+
await assertSchema(schemas?.email, email, "email");
|
|
505
579
|
if (validators?.email) {
|
|
506
|
-
await assertValid(validators.email(email, { context }));
|
|
580
|
+
await assertValid(validators.email(email, { context }), "email");
|
|
507
581
|
}
|
|
508
582
|
const identity = await adapter?.lookupByEmail?.(email) ?? null;
|
|
509
583
|
patchBaseContext({
|
|
@@ -535,8 +609,9 @@ function AdaptiveFlow({
|
|
|
535
609
|
return;
|
|
536
610
|
}
|
|
537
611
|
void run(async () => {
|
|
612
|
+
await assertSchema(schemas?.otp, code, "otp");
|
|
538
613
|
if (validators?.otp) {
|
|
539
|
-
await assertValid(validators.otp(code, { context, email: context.email }));
|
|
614
|
+
await assertValid(validators.otp(code, { context, email: context.email }), "otp");
|
|
540
615
|
}
|
|
541
616
|
if (adapter?.verifyOtp) {
|
|
542
617
|
await adapter.verifyOtp(context.email, code);
|
|
@@ -550,8 +625,12 @@ function AdaptiveFlow({
|
|
|
550
625
|
return;
|
|
551
626
|
}
|
|
552
627
|
void run(async () => {
|
|
628
|
+
await assertSchema(schemas?.password, password, "password");
|
|
553
629
|
if (validators?.password) {
|
|
554
|
-
await assertValid(
|
|
630
|
+
await assertValid(
|
|
631
|
+
validators.password(password, { context, hasPassword: context.hasPassword }),
|
|
632
|
+
"password"
|
|
633
|
+
);
|
|
555
634
|
}
|
|
556
635
|
if (context.hasPassword) {
|
|
557
636
|
if (adapter?.signInWithPassword) {
|
|
@@ -568,8 +647,9 @@ function AdaptiveFlow({
|
|
|
568
647
|
};
|
|
569
648
|
const handleProfile = (profile) => {
|
|
570
649
|
void run(async () => {
|
|
650
|
+
await assertSchema(schemas?.profile, profile, "profile");
|
|
571
651
|
if (validators?.profile) {
|
|
572
|
-
await assertValid(validators.profile(profile, { context }));
|
|
652
|
+
await assertValid(validators.profile(profile, { context }), "profile");
|
|
573
653
|
}
|
|
574
654
|
const next = mergeContext(context, {
|
|
575
655
|
profile: {
|
|
@@ -587,8 +667,9 @@ function AdaptiveFlow({
|
|
|
587
667
|
};
|
|
588
668
|
const handleTos = () => {
|
|
589
669
|
void run(async () => {
|
|
670
|
+
await assertSchema(schemas?.tos, true, "tos");
|
|
590
671
|
if (validators?.tos) {
|
|
591
|
-
await assertValid(validators.tos(true, { context }));
|
|
672
|
+
await assertValid(validators.tos(true, { context }), "tos");
|
|
592
673
|
}
|
|
593
674
|
const next = mergeContext(context, { agreedToTos: true });
|
|
594
675
|
if (adapter?.acceptTos) {
|
|
@@ -609,7 +690,84 @@ function AdaptiveFlow({
|
|
|
609
690
|
await startOAuth(provider, context);
|
|
610
691
|
});
|
|
611
692
|
};
|
|
612
|
-
|
|
693
|
+
return {
|
|
694
|
+
context,
|
|
695
|
+
step,
|
|
696
|
+
completeStep: normalizedCompleteStep,
|
|
697
|
+
requirements: normalizedRequirements,
|
|
698
|
+
missingRequirements,
|
|
699
|
+
transitions,
|
|
700
|
+
busy,
|
|
701
|
+
message,
|
|
702
|
+
errorMessage,
|
|
703
|
+
fieldErrors,
|
|
704
|
+
setContextPatch: patchContext,
|
|
705
|
+
run,
|
|
706
|
+
handleEmail,
|
|
707
|
+
handleOtp,
|
|
708
|
+
handlePassword,
|
|
709
|
+
handleProfile,
|
|
710
|
+
handleTos,
|
|
711
|
+
handleOAuth
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
function AdaptiveFlow({
|
|
715
|
+
adapter,
|
|
716
|
+
requirements,
|
|
717
|
+
requirementGraph,
|
|
718
|
+
requirementGraphConfig,
|
|
719
|
+
requirementResolvers,
|
|
720
|
+
completeStep,
|
|
721
|
+
stepTitles,
|
|
722
|
+
renderStep,
|
|
723
|
+
stepRegistry,
|
|
724
|
+
initialValue,
|
|
725
|
+
onComplete,
|
|
726
|
+
onError,
|
|
727
|
+
onStepTransition,
|
|
728
|
+
className,
|
|
729
|
+
classNames,
|
|
730
|
+
styles,
|
|
731
|
+
unstyled = false,
|
|
732
|
+
persistence,
|
|
733
|
+
validators,
|
|
734
|
+
schemas
|
|
735
|
+
}) {
|
|
736
|
+
const uiStyles = React.useMemo(() => resolveStyles(unstyled, styles), [unstyled, styles]);
|
|
737
|
+
const {
|
|
738
|
+
context,
|
|
739
|
+
step,
|
|
740
|
+
completeStep: normalizedCompleteStep,
|
|
741
|
+
requirements: normalizedRequirements,
|
|
742
|
+
missingRequirements: missing,
|
|
743
|
+
transitions,
|
|
744
|
+
busy,
|
|
745
|
+
message,
|
|
746
|
+
errorMessage,
|
|
747
|
+
fieldErrors,
|
|
748
|
+
setContextPatch: patchContext,
|
|
749
|
+
run,
|
|
750
|
+
handleEmail,
|
|
751
|
+
handleOtp,
|
|
752
|
+
handlePassword,
|
|
753
|
+
handleProfile,
|
|
754
|
+
handleTos,
|
|
755
|
+
handleOAuth
|
|
756
|
+
} = useAdaptiveFlow({
|
|
757
|
+
adapter,
|
|
758
|
+
requirements,
|
|
759
|
+
requirementGraph,
|
|
760
|
+
requirementGraphConfig,
|
|
761
|
+
requirementResolvers,
|
|
762
|
+
completeStep,
|
|
763
|
+
initialValue,
|
|
764
|
+
onComplete,
|
|
765
|
+
onError,
|
|
766
|
+
onStepTransition,
|
|
767
|
+
persistence,
|
|
768
|
+
validators,
|
|
769
|
+
schemas
|
|
770
|
+
});
|
|
613
771
|
const needsJobTitle = normalizedRequirements.includes("has_job_title");
|
|
614
772
|
const stepLabel = stepTitles?.[step] ?? defaultStepTitle[step] ?? step;
|
|
615
773
|
const defaultView = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
@@ -618,6 +776,7 @@ function AdaptiveFlow({
|
|
|
618
776
|
{
|
|
619
777
|
onSubmit: handleEmail,
|
|
620
778
|
disabled: busy,
|
|
779
|
+
error: fieldErrors.email,
|
|
621
780
|
styles: uiStyles,
|
|
622
781
|
classNames
|
|
623
782
|
}
|
|
@@ -628,6 +787,7 @@ function AdaptiveFlow({
|
|
|
628
787
|
onSubmit: handleOtp,
|
|
629
788
|
email: context.email ?? "your email",
|
|
630
789
|
disabled: busy,
|
|
790
|
+
error: fieldErrors.otp,
|
|
631
791
|
styles: uiStyles,
|
|
632
792
|
classNames
|
|
633
793
|
}
|
|
@@ -638,6 +798,7 @@ function AdaptiveFlow({
|
|
|
638
798
|
onSubmit: handlePassword,
|
|
639
799
|
disabled: busy,
|
|
640
800
|
hasPassword: context.hasPassword,
|
|
801
|
+
error: fieldErrors.password,
|
|
641
802
|
styles: uiStyles,
|
|
642
803
|
classNames
|
|
643
804
|
}
|
|
@@ -649,6 +810,7 @@ function AdaptiveFlow({
|
|
|
649
810
|
requireJobTitle: needsJobTitle,
|
|
650
811
|
onSubmit: handleProfile,
|
|
651
812
|
disabled: busy,
|
|
813
|
+
errors: fieldErrors,
|
|
652
814
|
styles: uiStyles,
|
|
653
815
|
classNames
|
|
654
816
|
}
|
|
@@ -658,6 +820,7 @@ function AdaptiveFlow({
|
|
|
658
820
|
{
|
|
659
821
|
onSubmit: handleTos,
|
|
660
822
|
disabled: busy,
|
|
823
|
+
error: fieldErrors.tos,
|
|
661
824
|
styles: uiStyles,
|
|
662
825
|
classNames
|
|
663
826
|
}
|
|
@@ -675,6 +838,7 @@ function AdaptiveFlow({
|
|
|
675
838
|
busy,
|
|
676
839
|
message,
|
|
677
840
|
errorMessage,
|
|
841
|
+
fieldErrors,
|
|
678
842
|
missingRequirements: missing,
|
|
679
843
|
requirements: normalizedRequirements,
|
|
680
844
|
defaultView,
|
|
@@ -689,6 +853,7 @@ function AdaptiveFlow({
|
|
|
689
853
|
busy,
|
|
690
854
|
message,
|
|
691
855
|
errorMessage,
|
|
856
|
+
fieldErrors,
|
|
692
857
|
missingRequirements: missing,
|
|
693
858
|
requirements: normalizedRequirements,
|
|
694
859
|
setContextPatch: patchContext,
|
|
@@ -741,8 +906,15 @@ function AdaptiveFlow({
|
|
|
741
906
|
] })
|
|
742
907
|
] });
|
|
743
908
|
}
|
|
744
|
-
function EmailBlock({
|
|
909
|
+
function EmailBlock({
|
|
910
|
+
onSubmit,
|
|
911
|
+
disabled,
|
|
912
|
+
error,
|
|
913
|
+
styles,
|
|
914
|
+
classNames
|
|
915
|
+
}) {
|
|
745
916
|
const [email, setEmail] = React.useState("");
|
|
917
|
+
const errorId = "adaptive-flow-email-error";
|
|
746
918
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
747
919
|
"form",
|
|
748
920
|
{
|
|
@@ -763,10 +935,13 @@ function EmailBlock({ onSubmit, disabled, styles, classNames }) {
|
|
|
763
935
|
placeholder: "Enter your email",
|
|
764
936
|
value: email,
|
|
765
937
|
onChange: (event) => setEmail(event.target.value),
|
|
938
|
+
"aria-invalid": Boolean(error),
|
|
939
|
+
"aria-describedby": error ? errorId : void 0,
|
|
766
940
|
required: true
|
|
767
941
|
}
|
|
768
942
|
),
|
|
769
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: classNames?.button, style: styles.button, disabled, type: "submit", children: "Continue" })
|
|
943
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: classNames?.button, style: styles.button, disabled, type: "submit", children: "Continue" }),
|
|
944
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: errorId, className: classNames?.error, style: styles.error, children: error }) : null
|
|
770
945
|
]
|
|
771
946
|
}
|
|
772
947
|
);
|
|
@@ -775,10 +950,12 @@ function OtpBlock({
|
|
|
775
950
|
onSubmit,
|
|
776
951
|
disabled,
|
|
777
952
|
email,
|
|
953
|
+
error,
|
|
778
954
|
styles,
|
|
779
955
|
classNames
|
|
780
956
|
}) {
|
|
781
957
|
const [code, setCode] = React.useState("");
|
|
958
|
+
const errorId = "adaptive-flow-otp-error";
|
|
782
959
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
783
960
|
"form",
|
|
784
961
|
{
|
|
@@ -804,6 +981,8 @@ function OtpBlock({
|
|
|
804
981
|
placeholder: "Enter 6-digit code",
|
|
805
982
|
value: code,
|
|
806
983
|
onChange: (event) => setCode(event.target.value.replace(/\D/g, "").slice(0, 6)),
|
|
984
|
+
"aria-invalid": Boolean(error),
|
|
985
|
+
"aria-describedby": error ? errorId : void 0,
|
|
807
986
|
required: true,
|
|
808
987
|
maxLength: 6,
|
|
809
988
|
pattern: "[0-9]{6}"
|
|
@@ -818,7 +997,8 @@ function OtpBlock({
|
|
|
818
997
|
type: "submit",
|
|
819
998
|
children: "Verify"
|
|
820
999
|
}
|
|
821
|
-
)
|
|
1000
|
+
),
|
|
1001
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: errorId, className: classNames?.error, style: styles.error, children: error }) : null
|
|
822
1002
|
] })
|
|
823
1003
|
]
|
|
824
1004
|
}
|
|
@@ -828,10 +1008,12 @@ function PasswordBlock({
|
|
|
828
1008
|
onSubmit,
|
|
829
1009
|
disabled,
|
|
830
1010
|
hasPassword,
|
|
1011
|
+
error,
|
|
831
1012
|
styles,
|
|
832
1013
|
classNames
|
|
833
1014
|
}) {
|
|
834
1015
|
const [password, setPassword] = React.useState("");
|
|
1016
|
+
const errorId = "adaptive-flow-password-error";
|
|
835
1017
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
836
1018
|
"form",
|
|
837
1019
|
{
|
|
@@ -852,11 +1034,14 @@ function PasswordBlock({
|
|
|
852
1034
|
placeholder: hasPassword ? "Enter your password" : "Create a password",
|
|
853
1035
|
value: password,
|
|
854
1036
|
onChange: (event) => setPassword(event.target.value),
|
|
1037
|
+
"aria-invalid": Boolean(error),
|
|
1038
|
+
"aria-describedby": error ? errorId : void 0,
|
|
855
1039
|
required: true,
|
|
856
1040
|
minLength: 8
|
|
857
1041
|
}
|
|
858
1042
|
),
|
|
859
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: classNames?.button, style: styles.button, disabled, type: "submit", children: "Continue" })
|
|
1043
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: classNames?.button, style: styles.button, disabled, type: "submit", children: "Continue" }),
|
|
1044
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { id: errorId, className: classNames?.error, style: styles.error, children: error }) : null
|
|
860
1045
|
]
|
|
861
1046
|
}
|
|
862
1047
|
);
|
|
@@ -866,12 +1051,17 @@ function ProfileBlock({
|
|
|
866
1051
|
disabled,
|
|
867
1052
|
defaultValue,
|
|
868
1053
|
requireJobTitle,
|
|
1054
|
+
errors,
|
|
869
1055
|
styles,
|
|
870
1056
|
classNames
|
|
871
1057
|
}) {
|
|
872
1058
|
const [firstName, setFirstName] = React.useState(defaultValue.firstName ?? "");
|
|
873
1059
|
const [lastName, setLastName] = React.useState(defaultValue.lastName ?? "");
|
|
874
1060
|
const [jobTitle, setJobTitle] = React.useState(defaultValue.jobTitle ?? "");
|
|
1061
|
+
const firstNameError = errors?.firstName ?? errors?.["profile.firstName"];
|
|
1062
|
+
const lastNameError = errors?.lastName ?? errors?.["profile.lastName"];
|
|
1063
|
+
const jobTitleError = errors?.jobTitle ?? errors?.["profile.jobTitle"];
|
|
1064
|
+
const profileError = errors?.profile;
|
|
875
1065
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
876
1066
|
"form",
|
|
877
1067
|
{
|
|
@@ -897,6 +1087,7 @@ function ProfileBlock({
|
|
|
897
1087
|
placeholder: "First name",
|
|
898
1088
|
value: firstName,
|
|
899
1089
|
onChange: (event) => setFirstName(event.target.value),
|
|
1090
|
+
"aria-invalid": Boolean(firstNameError),
|
|
900
1091
|
required: true
|
|
901
1092
|
}
|
|
902
1093
|
),
|
|
@@ -910,23 +1101,31 @@ function ProfileBlock({
|
|
|
910
1101
|
placeholder: "Last name",
|
|
911
1102
|
value: lastName,
|
|
912
1103
|
onChange: (event) => setLastName(event.target.value),
|
|
1104
|
+
"aria-invalid": Boolean(lastNameError),
|
|
913
1105
|
required: true
|
|
914
1106
|
}
|
|
915
1107
|
)
|
|
916
1108
|
] }),
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1109
|
+
firstNameError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: classNames?.error, style: styles.error, children: firstNameError }) : null,
|
|
1110
|
+
lastNameError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: classNames?.error, style: styles.error, children: lastNameError }) : null,
|
|
1111
|
+
requireJobTitle ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1112
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1113
|
+
"input",
|
|
1114
|
+
{
|
|
1115
|
+
className: classNames?.input,
|
|
1116
|
+
style: styles.input,
|
|
1117
|
+
type: "text",
|
|
1118
|
+
autoComplete: "organization-title",
|
|
1119
|
+
placeholder: "Job title",
|
|
1120
|
+
value: jobTitle,
|
|
1121
|
+
onChange: (event) => setJobTitle(event.target.value),
|
|
1122
|
+
"aria-invalid": Boolean(jobTitleError),
|
|
1123
|
+
required: true
|
|
1124
|
+
}
|
|
1125
|
+
),
|
|
1126
|
+
jobTitleError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: classNames?.error, style: styles.error, children: jobTitleError }) : null
|
|
1127
|
+
] }) : null,
|
|
1128
|
+
profileError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: classNames?.error, style: styles.error, children: profileError }) : null,
|
|
930
1129
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: classNames?.button, style: styles.button, disabled, type: "submit", children: "Continue" })
|
|
931
1130
|
]
|
|
932
1131
|
}
|
|
@@ -935,6 +1134,7 @@ function ProfileBlock({
|
|
|
935
1134
|
function TosBlock({
|
|
936
1135
|
onSubmit,
|
|
937
1136
|
disabled,
|
|
1137
|
+
error,
|
|
938
1138
|
styles,
|
|
939
1139
|
classNames
|
|
940
1140
|
}) {
|
|
@@ -952,9 +1152,18 @@ function TosBlock({
|
|
|
952
1152
|
},
|
|
953
1153
|
children: [
|
|
954
1154
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: classNames?.checkboxRow, style: styles.checkboxRow, children: [
|
|
955
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1155
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1156
|
+
"input",
|
|
1157
|
+
{
|
|
1158
|
+
type: "checkbox",
|
|
1159
|
+
checked,
|
|
1160
|
+
onChange: (event) => setChecked(event.target.checked),
|
|
1161
|
+
"aria-invalid": Boolean(error)
|
|
1162
|
+
}
|
|
1163
|
+
),
|
|
956
1164
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "I agree to the Terms of Service and Privacy Policy." })
|
|
957
1165
|
] }),
|
|
1166
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: classNames?.error, style: styles.error, children: error }) : null,
|
|
958
1167
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
959
1168
|
"button",
|
|
960
1169
|
{
|
|
@@ -974,7 +1183,7 @@ function CompleteBlock({
|
|
|
974
1183
|
classNames
|
|
975
1184
|
}) {
|
|
976
1185
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: classNames?.complete, style: styles.complete, children: [
|
|
977
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "You are
|
|
1186
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "You are all set." }),
|
|
978
1187
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: classNames?.caption, style: styles.caption, children: "All requirements are complete." })
|
|
979
1188
|
] });
|
|
980
1189
|
}
|
|
@@ -1113,6 +1322,7 @@ var defaultStyles = {
|
|
|
1113
1322
|
defaultRequirements,
|
|
1114
1323
|
evaluateNextStep,
|
|
1115
1324
|
getMissingRequirements,
|
|
1116
|
-
initialContext
|
|
1325
|
+
initialContext,
|
|
1326
|
+
useAdaptiveFlow
|
|
1117
1327
|
});
|
|
1118
1328
|
//# sourceMappingURL=index.js.map
|