Skip to content

Commit 38dc379

Browse files
committed
refactor(ui): Rename preferredSignInIdentifier to preferredIdentifier
1 parent 495ce18 commit 38dc379

5 files changed

Lines changed: 12 additions & 13 deletions

File tree

.changeset/phone-country-preferred-identifier.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
'@clerk/ui': minor
44
---
55

6-
Add `phoneNumberCountryCode` to `SignIn` component's `initialValues` prop for preselecting the phone dropdown country via ISO 3166 alpha-2 code. Add `preferredSignInIdentifier` to `appearance.options` for selecting which identifier type (email, phone, username) shows first without pre-filling a value.
6+
Add `phoneNumberCountryCode` to `SignIn` component's `initialValues` prop for preselecting the phone dropdown country via ISO 3166 alpha-2 code. Add `preferredIdentifier` to `appearance.options` for selecting which identifier type (email, phone, username) shows first without pre-filling a value.

packages/ui/src/components/SignIn/SignInStart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ function SignInStartInternal(): JSX.Element {
136136
if (mapped) return mapped;
137137
}
138138

139-
if (parsedOptions.preferredSignInIdentifier) {
140-
const mapped = mapToIdentifierAttribute(parsedOptions.preferredSignInIdentifier);
139+
if (parsedOptions.preferredIdentifier) {
140+
const mapped = mapToIdentifierAttribute(parsedOptions.preferredIdentifier);
141141
if (mapped) return mapped;
142142
}
143143

packages/ui/src/components/SignIn/__tests__/SignInStart.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,13 +479,13 @@ describe('SignInStart', () => {
479479
});
480480
});
481481

482-
describe('preferredSignInIdentifier (appearance option)', () => {
482+
describe('preferredIdentifier (appearance option)', () => {
483483
it('selects phone_number tab when set to phoneNumber', async () => {
484484
const { wrapper, props } = await createFixtures(f => {
485485
f.withEmailAddress();
486486
f.withPhoneNumber();
487487
});
488-
props.setProps({ appearance: { options: { preferredSignInIdentifier: 'phoneNumber' } } });
488+
props.setProps({ appearance: { options: { preferredIdentifier: 'phoneNumber' } } });
489489

490490
render(<SignInStart />, { wrapper });
491491
screen.getByText(/phone number/i);
@@ -496,7 +496,7 @@ describe('SignInStart', () => {
496496
f.withEmailAddress();
497497
f.withPhoneNumber();
498498
});
499-
props.setProps({ appearance: { options: { preferredSignInIdentifier: 'emailAddress' } } });
499+
props.setProps({ appearance: { options: { preferredIdentifier: 'emailAddress' } } });
500500

501501
render(<SignInStart />, { wrapper });
502502
screen.getByText(/email address/i);
@@ -506,7 +506,7 @@ describe('SignInStart', () => {
506506
const { wrapper, props } = await createFixtures(f => {
507507
f.withEmailAddress();
508508
});
509-
props.setProps({ appearance: { options: { preferredSignInIdentifier: 'phoneNumber' } } });
509+
props.setProps({ appearance: { options: { preferredIdentifier: 'phoneNumber' } } });
510510

511511
render(<SignInStart />, { wrapper });
512512
screen.getByText(/email address/i);
@@ -519,7 +519,7 @@ describe('SignInStart', () => {
519519
});
520520
props.setProps({
521521
initialValues: { phoneNumber: '+306911111111' },
522-
appearance: { options: { preferredSignInIdentifier: 'emailAddress' } },
522+
appearance: { options: { preferredIdentifier: 'emailAddress' } },
523523
});
524524

525525
render(<SignInStart />, { wrapper });
@@ -531,7 +531,7 @@ describe('SignInStart', () => {
531531
f.withEmailAddress();
532532
f.withUsername();
533533
});
534-
props.setProps({ appearance: { options: { preferredSignInIdentifier: 'username' } } });
534+
props.setProps({ appearance: { options: { preferredIdentifier: 'username' } } });
535535

536536
render(<SignInStart />, { wrapper });
537537
screen.getByText(/email address or username/i);

packages/ui/src/customizables/parseAppearance.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import {
1717

1818
export type ParsedElements = Elements[];
1919
export type ParsedInternalTheme = InternalTheme;
20-
export type ParsedOptions = Required<Omit<Options, 'preferredSignInIdentifier'>> &
21-
Pick<Options, 'preferredSignInIdentifier'>;
20+
export type ParsedOptions = Required<Omit<Options, 'preferredIdentifier'>> & Pick<Options, 'preferredIdentifier'>;
2221
export type ParsedCaptcha = Required<CaptchaAppearanceOptions>;
2322

2423
type PublicAppearanceTopLevelKey = Exclude<
@@ -52,7 +51,7 @@ const defaultOptions: ParsedOptions = {
5251
shimmer: true,
5352
animations: true,
5453
unsafe_disableDevelopmentModeWarnings: false,
55-
preferredSignInIdentifier: undefined,
54+
preferredIdentifier: undefined,
5655
};
5756

5857
const defaultCaptchaOptions: ParsedCaptcha = {

packages/ui/src/internal/appearance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ export type Options = {
970970
*
971971
* @default undefined
972972
*/
973-
preferredSignInIdentifier?: 'emailAddress' | 'phoneNumber' | 'username';
973+
preferredIdentifier?: 'emailAddress' | 'phoneNumber' | 'username';
974974
};
975975

976976
export type CaptchaAppearanceOptions = {

0 commit comments

Comments
 (0)