-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
27,546 additions
and
12,239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
{ | ||
"presets": [["@babel/preset-env", {}, "@babel/preset-react"]], | ||
"plugins": [ | ||
"presets": [ | ||
"@babel/preset-env", | ||
[ | ||
"@babel/plugin-transform-react-jsx", | ||
"@babel/preset-typescript", | ||
{ | ||
"pragmaFrag": "React.Fragment" | ||
"onlyRemoveTypeImports": true, | ||
"allExtensions": true, | ||
"isTSX": true | ||
} | ||
] | ||
], | ||
["@babel/preset-react", { "runtime": "automatic" }] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { StorybookConfig } from "@storybook/react-webpack5"; | ||
// import '@storybook/addon-console'; | ||
|
||
const config: StorybookConfig = { | ||
stories: ["../stories/**/*.mdx", "../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)"], | ||
addons: [ | ||
"@storybook/addon-essentials", | ||
"@storybook/addon-actions", | ||
"@storybook/addon-links", | ||
"@storybook/addon-interactions", | ||
// "@storybook/addon-actions/register", | ||
], | ||
framework: { | ||
name: "@storybook/react-webpack5", | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: false, | ||
}, | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { Preview } from "@storybook/react"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
actions: { argTypesRegex: "^(w+.)*on[A-Z].*" }, | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
boolean: /(is|show|loaded)/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default preview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import Page from "../lib/ts/recipe/multifactorauth/components/themes/factorChooser"; | ||
import React from "react"; | ||
import { defaultTranslationsMultiFactorAuth } from "../lib/ts/recipe/multifactorauth/components/themes/translations"; | ||
import { WindowHandlerReference } from "supertokens-web-js/utils/windowHandler"; | ||
import { TranslationContextProvider } from "../lib/ts/translation/translationContext"; | ||
import { ComponentOverrideContext } from "../lib/ts/components/componentOverride/componentOverrideContext"; | ||
import { resetAndInitST } from "./utils"; | ||
import { SessionContext } from "../lib/ts/recipe/session"; | ||
import { otpEmailFactor, otpPhoneFactor } from "../lib/ts/recipe/passwordless/recipe"; | ||
import { totpFactor } from "../lib/ts/recipe/totp/recipe"; | ||
|
||
function noop() {} | ||
WindowHandlerReference.init((oI) => ({ ...oI })); | ||
|
||
const factors = [otpEmailFactor, otpPhoneFactor, totpFactor]; | ||
|
||
const defaultSessionContext = { | ||
loading: false, | ||
doesSessionExist: true, | ||
invalidClaims: [], | ||
accessTokenPayload: {}, | ||
userId: "test-user", | ||
}; | ||
const meta: Meta<typeof Page> = { | ||
title: "MFA/chooser", | ||
decorators: [ | ||
(Story, context) => { | ||
return ( | ||
<SessionContext.Provider value={context.loaded.session ?? defaultSessionContext}> | ||
<ComponentOverrideContext.Provider value={{}}> | ||
<TranslationContextProvider | ||
translationControlEventSource={{ on: noop, off: noop }} | ||
defaultLanguage="en" | ||
defaultStore={defaultTranslationsMultiFactorAuth}> | ||
<Story /> | ||
</TranslationContextProvider> | ||
</ComponentOverrideContext.Provider> | ||
</SessionContext.Provider> | ||
); | ||
}, | ||
], | ||
component: Page, | ||
render: (args) => { | ||
resetAndInitST(); | ||
return ( | ||
<Page | ||
{...args} | ||
availableFactors={(args.availableFactors as any).map((id) => | ||
factors.find((factor) => factor.id === id) | ||
)} | ||
/> | ||
); | ||
}, | ||
argTypes: { | ||
availableFactors: { control: "check", options: ["otp-email", "otp-phone", "totp"] }, | ||
navigateToFactor: { action: "navigateToFactor" }, | ||
userContext: { | ||
table: { | ||
disable: true, | ||
}, | ||
}, | ||
}, | ||
args: { | ||
availableFactors: [], | ||
showBackButton: false, | ||
config: { | ||
factorChooserScreen: { | ||
style: "", | ||
}, | ||
firstFactors: [], | ||
rootStyle: "", | ||
useShadowDom: false, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Page>; | ||
|
||
export const NoFactors: Story = { | ||
args: { | ||
availableFactors: [], | ||
}, | ||
}; | ||
|
||
export const SingleFactor: Story = { | ||
args: { | ||
availableFactors: ["otp-email"], | ||
}, | ||
}; | ||
|
||
export const MultipleFactors: Story = { | ||
args: { | ||
availableFactors: ["otp-email", "otp-phone", "totp"], | ||
}, | ||
}; |
Oops, something went wrong.