@clerk/ui 0.1.9 → 0.1.10

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.
@@ -1,18 +1,18 @@
1
- import { useLocalizations, Root2, Label, Input, Animated, Message, useDevModeWarning, useCard, Root as Root$1, LOCALIZATION_NEEDED, Content, Header, Title, Description, Body, Footer, FooterAction, Logo, GlobalError, Button as Button$1, LinkButton, FooterActionText, FooterActionButton, Connections, Actions, CaretRightLegacySm, PasswordField, useEnabledConnections, useEnvironment, useAttributes, useDisplayConfig, EmailField, UsernameField, PhoneNumberField, EmailOrPhoneNumberField, FooterActionLink, PenSm, OTPField, useOptions, Checkbox, useFocusInput, link, stringToFormattedPhoneString } from '../chunk-GJNJVJGS.mjs';
2
- import { AppearanceProvider, Separator, useAppearance, Icon } from '../chunk-RVVUA25B.mjs';
1
+ import { Root, Label, Input, Animated, Message, useDevModeWarning, useCard, LOCALIZATION_NEEDED, GlobalError, LinkButton, CaretRightLegacySm, PasswordField, useEnvironment, useAttributes, useDisplayConfig, EmailField, UsernameField, PhoneNumberField, EmailOrPhoneNumberField, RouterLink, PenSm, OTPField, Checkbox, useFocusInput, link, stringToFormattedPhoneString } from '../chunk-TVTJKSVH.mjs';
2
+ import { useLocalizations, AppearanceProvider, Root as Root$2, Content, Header, Title, Description, Body, Footer, FooterAction, Logo, Button as Button$1, FooterActionText, FooterActionButton, Separator, Connections, Actions, useEnabledConnections, useAppearance, useOptions, FooterActionLink, Icon } from '../chunk-LLOUIL3Z.mjs';
3
3
  import * as SignIn6 from '@clerk/elements/sign-in';
4
- import { Root } from '@clerk/elements/sign-in';
5
- import * as React from 'react';
6
- import React__default from 'react';
4
+ import { Root as Root$1 } from '@clerk/elements/sign-in';
5
+ import * as React6 from 'react';
6
+ import React6__default from 'react';
7
7
  import { useClerk } from '@clerk/shared/react';
8
- import { cva } from 'cva';
8
+ import { cva, cx } from 'cva';
9
9
  import { Button, ToggleButton } from 'react-aria-components';
10
10
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
11
  import * as Common8 from '@clerk/elements/common';
12
12
 
13
- var GetHelpContext = React.createContext(null);
13
+ var GetHelpContext = React6.createContext(null);
14
14
  var useGetHelp = () => {
15
- const context = React.useContext(GetHelpContext);
15
+ const context = React6.useContext(GetHelpContext);
16
16
  if (!context) {
17
17
  throw new Error("useGetHelp must be used within GetHelpContext.Provider");
18
18
  }
@@ -72,7 +72,7 @@ function SignInChooseSession() {
72
72
  {
73
73
  asChild: true,
74
74
  name: "choose-session",
75
- children: /* @__PURE__ */ jsxs(Root$1, { banner: isDev ? LOCALIZATION_NEEDED.developmentMode : null, children: [
75
+ children: /* @__PURE__ */ jsxs(Root$2, { banner: isDev ? LOCALIZATION_NEEDED.developmentMode : null, children: [
76
76
  /* @__PURE__ */ jsxs(Content, { children: [
77
77
  /* @__PURE__ */ jsxs(Header, { children: [
78
78
  /* @__PURE__ */ jsx(Title, { children: t("signIn.accountSwitcher.title") }),
@@ -280,7 +280,7 @@ function SignInChooseStrategy() {
280
280
  {
281
281
  asChild: true,
282
282
  name: "choose-strategy",
283
- children: /* @__PURE__ */ jsxs(Root$1, { banner: isDev ? LOCALIZATION_NEEDED.developmentMode : null, children: [
283
+ children: /* @__PURE__ */ jsxs(Root$2, { banner: isDev ? LOCALIZATION_NEEDED.developmentMode : null, children: [
284
284
  /* @__PURE__ */ jsxs(Content, { children: [
285
285
  /* @__PURE__ */ jsxs(Header, { children: [
286
286
  /* @__PURE__ */ jsx(Logo, { ...logoProps }),
@@ -439,7 +439,7 @@ function SignInForgotPassword() {
439
439
  asChild: true,
440
440
  name: "forgot-password",
441
441
  children: /* @__PURE__ */ jsxs(
442
- Root$1,
442
+ Root$2,
443
443
  {
444
444
  as: "form",
445
445
  banner: isDev ? LOCALIZATION_NEEDED.developmentMode : null,
@@ -596,7 +596,7 @@ function useSupportEmail() {
596
596
  const { supportEmail: supportEmailFromOptions } = useOptions();
597
597
  const { displayConfig } = useEnvironment();
598
598
  const { supportEmail: supportEmailFromEnvironment } = displayConfig;
599
- const supportEmail = React__default.useMemo(
599
+ const supportEmail = React6__default.useMemo(
600
600
  () => supportEmailFromOptions || supportEmailFromEnvironment || ["support", "@", Clerk.frontendApi ? Clerk.frontendApi.replace("clerk.", "") : "clerk.com"].join(""),
601
601
  [Clerk.frontendApi, supportEmailFromOptions, supportEmailFromEnvironment]
602
602
  );
@@ -608,7 +608,7 @@ function SignInGetHelp() {
608
608
  const supportEmail = useSupportEmail();
609
609
  const { setShowHelp } = useGetHelp();
610
610
  const { logoProps, footerProps } = useCard();
611
- return /* @__PURE__ */ jsxs(Root$1, { banner: isDev ? LOCALIZATION_NEEDED.developmentMode : null, children: [
611
+ return /* @__PURE__ */ jsxs(Root$2, { banner: isDev ? LOCALIZATION_NEEDED.developmentMode : null, children: [
612
612
  /* @__PURE__ */ jsxs(Content, { children: [
613
613
  /* @__PURE__ */ jsxs(Header, { children: [
614
614
  /* @__PURE__ */ jsx(Logo, { ...logoProps }),
@@ -642,7 +642,7 @@ function CheckboxField({
642
642
  {
643
643
  name,
644
644
  asChild: true,
645
- children: /* @__PURE__ */ jsxs(Root2, { children: [
645
+ children: /* @__PURE__ */ jsxs(Root, { children: [
646
646
  /* @__PURE__ */ jsxs("div", { className: "cl-c354e22d", children: [
647
647
  /* @__PURE__ */ jsx(
648
648
  Common8.Input,
@@ -673,7 +673,7 @@ function SignInResetPassword() {
673
673
  asChild: true,
674
674
  name: "reset-password",
675
675
  children: /* @__PURE__ */ jsxs(
676
- Root$1,
676
+ Root$2,
677
677
  {
678
678
  as: "form",
679
679
  banner: isDev ? LOCALIZATION_NEEDED.developmentMode : null,
@@ -745,7 +745,7 @@ function SignInResetPassword() {
745
745
  );
746
746
  } });
747
747
  }
748
- var EmailOrUsernameField = React__default.forwardRef(function EmailOrUsernameField2({
748
+ var EmailOrUsernameField = React6__default.forwardRef(function EmailOrUsernameField2({
749
749
  alternativeFieldTrigger,
750
750
  ...props
751
751
  }, forwardedRef) {
@@ -755,7 +755,7 @@ var EmailOrUsernameField = React__default.forwardRef(function EmailOrUsernameFie
755
755
  {
756
756
  name: "identifier",
757
757
  asChild: true,
758
- children: /* @__PURE__ */ jsxs(Root2, { children: [
758
+ children: /* @__PURE__ */ jsxs(Root, { children: [
759
759
  /* @__PURE__ */ jsx(Common8.Label, { asChild: true, children: /* @__PURE__ */ jsxs(Label, { children: [
760
760
  t("formFieldLabel__emailAddress_username"),
761
761
  " ",
@@ -787,7 +787,7 @@ function EmailOrUsernameOrPhoneNumberField({
787
787
  toggleLabelPhoneNumber,
788
788
  ...props
789
789
  }) {
790
- const [showPhoneNumberField, setShowPhoneNumberField] = React.useState(false);
790
+ const [showPhoneNumberField, setShowPhoneNumberField] = React6.useState(false);
791
791
  const [inputRef, setInputFocus] = useFocusInput();
792
792
  const toggle = /* @__PURE__ */ jsxs(
793
793
  ToggleButton,
@@ -829,7 +829,7 @@ function PhoneNumberOrUsernameField({
829
829
  toggleLabelUsername,
830
830
  ...props
831
831
  }) {
832
- const [showUsernameField, setShowUsernameField] = React.useState(false);
832
+ const [showUsernameField, setShowUsernameField] = React6.useState(false);
833
833
  const toggle = /* @__PURE__ */ jsxs(
834
834
  ToggleButton,
835
835
  {
@@ -878,6 +878,8 @@ function SignInStart() {
878
878
  const isDev = useDevModeWarning();
879
879
  const { options } = useAppearance().parsedAppearance;
880
880
  const { logoProps, footerProps } = useCard();
881
+ const clerk = useClerk();
882
+ const { signUpUrl } = useOptions();
881
883
  return /* @__PURE__ */ jsx(Common8.Loading, { scope: "global", children: (isGlobalLoading) => {
882
884
  const connectionsWithSeperator = [
883
885
  /* @__PURE__ */ jsx(
@@ -895,7 +897,7 @@ function SignInStart() {
895
897
  asChild: true,
896
898
  name: "start",
897
899
  children: /* @__PURE__ */ jsxs(
898
- Root$1,
900
+ Root$2,
899
901
  {
900
902
  as: "form",
901
903
  banner: isDev ? LOCALIZATION_NEEDED.developmentMode : null,
@@ -971,7 +973,8 @@ function SignInStart() {
971
973
  disabled: isGlobalLoading,
972
974
  required: true
973
975
  }
974
- ) : null
976
+ ) : null,
977
+ /* @__PURE__ */ jsx(AutoFillPasswordField, {})
975
978
  ] }) : null,
976
979
  options.socialButtonsPlacement === "bottom" ? connectionsWithSeperator.reverse() : null
977
980
  ] }),
@@ -1014,10 +1017,14 @@ function SignInStart() {
1014
1017
  /* @__PURE__ */ jsx(Footer, { ...footerProps, children: userSettings.signUp.mode === SIGN_UP_MODES.PUBLIC ? /* @__PURE__ */ jsx(FooterAction, { children: /* @__PURE__ */ jsxs(FooterActionText, { children: [
1015
1018
  t("signIn.start.actionText"),
1016
1019
  " ",
1017
- /* @__PURE__ */ jsxs(FooterActionLink, { href: "/sign-up", children: [
1018
- " ",
1019
- t("signIn.start.actionLink")
1020
- ] })
1020
+ /* @__PURE__ */ jsx(
1021
+ RouterLink,
1022
+ {
1023
+ asChild: true,
1024
+ href: clerk.buildUrlWithAuth(signUpUrl || "/sign-up"),
1025
+ children: /* @__PURE__ */ jsx(FooterActionLink, { children: t("signIn.start.actionLink") })
1026
+ }
1027
+ )
1021
1028
  ] }) }) : null })
1022
1029
  ]
1023
1030
  }
@@ -1026,6 +1033,35 @@ function SignInStart() {
1026
1033
  );
1027
1034
  } });
1028
1035
  }
1036
+ function AutoFillPasswordField() {
1037
+ const { t } = useLocalizations();
1038
+ const [isAutoFilled, setIsAutoFilled] = React6.useState(false);
1039
+ const fieldRef = React6.useRef(null);
1040
+ const handleAutofill = (event) => {
1041
+ if (event.target.value && !isAutoFilled) {
1042
+ setIsAutoFilled(true);
1043
+ }
1044
+ };
1045
+ React6.useEffect(() => {
1046
+ if (fieldRef.current) {
1047
+ fieldRef.current.setAttribute("inert", "");
1048
+ }
1049
+ }, []);
1050
+ React6.useEffect(() => {
1051
+ if (fieldRef.current && isAutoFilled) {
1052
+ fieldRef.current.removeAttribute("inert");
1053
+ }
1054
+ }, [isAutoFilled]);
1055
+ return /* @__PURE__ */ jsx(
1056
+ PasswordField,
1057
+ {
1058
+ label: t("formFieldLabel__password"),
1059
+ fieldRef,
1060
+ fieldClassName: cx(!isAutoFilled && "cl-73c00d56"),
1061
+ onChange: handleAutofill
1062
+ }
1063
+ );
1064
+ }
1029
1065
  function BackupCodeField(props) {
1030
1066
  const { t } = useLocalizations();
1031
1067
  return /* @__PURE__ */ jsx(
@@ -1033,7 +1069,7 @@ function BackupCodeField(props) {
1033
1069
  {
1034
1070
  name: "backup_code",
1035
1071
  asChild: true,
1036
- children: /* @__PURE__ */ jsxs(Root2, { children: [
1072
+ children: /* @__PURE__ */ jsxs(Root, { children: [
1037
1073
  /* @__PURE__ */ jsx(Common8.Label, { asChild: true, children: /* @__PURE__ */ jsx(Label, { children: t("formFieldLabel__backupCode") }) }),
1038
1074
  /* @__PURE__ */ jsx(Common8.FieldState, { children: ({ state }) => {
1039
1075
  return /* @__PURE__ */ jsx(
@@ -1082,7 +1118,7 @@ function SignInVerifications() {
1082
1118
  asChild: true,
1083
1119
  name: "verifications",
1084
1120
  children: /* @__PURE__ */ jsxs(
1085
- Root$1,
1121
+ Root$2,
1086
1122
  {
1087
1123
  as: "form",
1088
1124
  banner: isDev ? LOCALIZATION_NEEDED.developmentMode : null,
@@ -1593,9 +1629,11 @@ function SignInVerifications() {
1593
1629
  );
1594
1630
  } });
1595
1631
  }
1596
- function SignIn7({ appearance, ...rest }) {
1597
- const [showHelp, setShowHelp] = React.useState(false);
1598
- return /* @__PURE__ */ jsx(AppearanceProvider, { appearance, children: /* @__PURE__ */ jsx(GetHelpContext.Provider, { value: { showHelp, setShowHelp }, children: /* @__PURE__ */ jsx(Root, { ...rest, children: showHelp ? /* @__PURE__ */ jsx(SignInGetHelp, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
1632
+ function SignIn7({ appearance, ...props }) {
1633
+ var _a;
1634
+ const [showHelp, setShowHelp] = React6.useState(false);
1635
+ const componentAppearance = ((_a = props.__experimental) == null ? void 0 : _a.newComponents) ? props.__experimental.appearance : appearance;
1636
+ return /* @__PURE__ */ jsx(AppearanceProvider, { appearance: componentAppearance, children: /* @__PURE__ */ jsx(GetHelpContext.Provider, { value: { showHelp, setShowHelp }, children: /* @__PURE__ */ jsx(Root$1, { ...props, children: showHelp ? /* @__PURE__ */ jsx(SignInGetHelp, {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
1599
1637
  /* @__PURE__ */ jsx(SignInStart, {}),
1600
1638
  /* @__PURE__ */ jsx(SignInVerifications, {}),
1601
1639
  /* @__PURE__ */ jsx(SignInChooseStrategy, {}),