@vrobots/storybook 0.2.3 → 0.2.5
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/package.json +1 -1
- package/dist/src/components/form/Form.Body.d.ts +4 -0
- package/dist/src/components/form/Form.Body.js +6 -0
- package/dist/src/components/form/Form.Description.d.ts +4 -0
- package/dist/src/components/form/Form.Description.js +6 -0
- package/dist/src/components/form/Form.Root.d.ts +3 -0
- package/dist/src/components/form/Form.Root.js +6 -0
- package/dist/src/components/form/Form.Title.d.ts +4 -0
- package/dist/src/components/form/Form.Title.js +6 -0
- package/dist/src/components/form/Login.js +14 -10
- package/dist/src/components/form/SecondFactorAuth.js +8 -4
- package/dist/src/components/form/index.d.ts +10 -0
- package/dist/src/components/form/index.js +8 -0
- package/dist/src/components/ui/color-mode.js +6 -5
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Card } from "@chakra-ui/react";
|
|
3
|
+
export const FormRoot = (props) => {
|
|
4
|
+
return (_jsx(Box, { as: "form", display: "flex", justifyContent: "center", alignItems: "center", height: `100%`, bg: "neu.bg", px: 4, children: _jsx(Box, { layerStyle: "neuRaised", p: { base: 6, md: 8 }, minW: { base: "100%", sm: "460px" }, maxW: "560px", bg: { _light: 'white', _dark: 'black' }, children: _jsx(Card.Root, { bg: 'transparent', border: 'none', ...props, children: _jsx(Card.Body, { children: props.children }) }) }) }));
|
|
5
|
+
};
|
|
6
|
+
export default FormRoot;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Button, Field, Input, Stack } from "@chakra-ui/react";
|
|
3
3
|
import { useForm } from "react-hook-form";
|
|
4
4
|
import { PasswordInput } from "../ui/password-input";
|
|
5
|
+
import FormRoot from "./Form.Root";
|
|
6
|
+
import FormDescription from "./Form.Description";
|
|
7
|
+
import FormTitle from "./Form.Title";
|
|
8
|
+
import FormBody from "./Form.Body";
|
|
5
9
|
const Login = ({ title, description, onLogin, children = null, ...props }) => {
|
|
6
10
|
const { register, handleSubmit, formState: { errors }, } = useForm();
|
|
7
|
-
return (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
return (_jsxs(FormRoot, { onSubmit: handleSubmit((data) => onLogin(data)), children: [_jsx(FormTitle, { title: title || "Login" }), !!description && _jsx(FormDescription, { description: description }), _jsxs(FormBody, { children: [_jsxs(Stack, { gap: "4", children: [_jsxs(Field.Root, { invalid: !!errors.emailAddress, required: true, children: [_jsx(Field.Label, { children: "Email Address" }), _jsx(Input, { ...register("emailAddress", {
|
|
12
|
+
required: "Please enter your email address",
|
|
13
|
+
pattern: {
|
|
14
|
+
value: /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
|
15
|
+
message: "Invalid email address"
|
|
16
|
+
}
|
|
17
|
+
}), autoFocus: true }), _jsx(Field.ErrorText, { children: errors.emailAddress?.message })] }), _jsxs(Field.Root, { invalid: !!errors.password, children: [_jsx(Field.Label, { children: "Password" }), _jsx(PasswordInput, { ...register("password", {
|
|
18
|
+
required: "Please enter your password",
|
|
19
|
+
}) }), _jsx(Field.ErrorText, { children: errors.password?.message })] })] }), children, _jsx(Button, { type: "submit", width: "full", mt: 6, children: "Login" })] })] }));
|
|
16
20
|
};
|
|
17
21
|
export default Login;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Button, Checkbox, Field, Input, InputGroup } from "@chakra-ui/react";
|
|
3
3
|
import { useForm } from "react-hook-form";
|
|
4
|
+
import FormRoot from "./Form.Root";
|
|
5
|
+
import FormTitle from "./Form.Title";
|
|
6
|
+
import FormBody from "./Form.Body";
|
|
7
|
+
import FormDescription from "./Form.Description";
|
|
4
8
|
const SecondFactorAuth = ({ title, description, onSecondFactorAuth, onResendAuthCode, ...props }) => {
|
|
5
9
|
const { register, handleSubmit, formState: { errors }, } = useForm();
|
|
6
|
-
return (
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
return (_jsxs(FormRoot, { onSubmit: handleSubmit((data) => onSecondFactorAuth(data)), children: [_jsx(FormTitle, { title: title || "Second Factor Auth" }), !!description && _jsx(FormDescription, { description: description }), _jsxs(FormBody, { children: [_jsxs(Field.Root, { invalid: !!errors.authCode, required: true, children: [_jsx(Field.Label, { children: "Authorization Code" }), _jsx(InputGroup, { endAddon: _jsx(Button, { h: '1.75rem', size: 'sm', variant: 'ghost', onClick: onResendAuthCode, children: "Resend" }), children: _jsx(Input, { type: 'text', placeholder: 'Authorization code', ...register("authCode", {
|
|
11
|
+
required: "Please enter your authorization code",
|
|
12
|
+
}), autoFocus: true }) }), _jsx(Field.ErrorText, { children: errors.authCode?.message })] }), _jsxs(Checkbox.Root, { ...register("rememberDevice"), size: 'sm', children: [_jsx(Checkbox.HiddenInput, {}), _jsx(Checkbox.Control, {}), _jsx(Checkbox.Label, { children: "Remember Device" })] })] }), _jsx(Button, { type: "submit", width: "full", mt: 6, children: "Submit" })] }));
|
|
9
13
|
};
|
|
10
14
|
export default SecondFactorAuth;
|
|
@@ -3,6 +3,16 @@ export * from "./SecondFactorAuth";
|
|
|
3
3
|
export * from "./FileUploader";
|
|
4
4
|
declare const Form: {
|
|
5
5
|
(): null;
|
|
6
|
+
Root: (props: import("@chakra-ui/react").BoxProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
Title: ({ title }: {
|
|
8
|
+
title: string;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
Description: ({ description }: {
|
|
11
|
+
description: string;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
Body: ({ children }: {
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
16
|
Login: ({ title, description, onLogin, children, ...props }: import("./Login").ILoginProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
17
|
SecondFactorAuth: ({ title, description, onSecondFactorAuth, onResendAuthCode, ...props }: import("./SecondFactorAuth").ISecondFactorAuthProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
18
|
FileUploader: ({ title, description, buttonLabel, helperText, accept, multiple, onFilesSelected, uploadPercentages, children, ...props }: import("./FileUploader").IFileUploaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import Login from "./Login";
|
|
2
2
|
import SecondFactorAuth from "./SecondFactorAuth";
|
|
3
3
|
import FileUploader from "./FileUploader";
|
|
4
|
+
import FormRoot from "./Form.Root";
|
|
5
|
+
import FormTitle from "./Form.Title";
|
|
6
|
+
import FormBody from "./Form.Body";
|
|
7
|
+
import FormDescription from "./Form.Description";
|
|
4
8
|
export * from "./Login";
|
|
5
9
|
export * from "./SecondFactorAuth";
|
|
6
10
|
export * from "./FileUploader";
|
|
7
11
|
const Form = () => null;
|
|
12
|
+
Form.Root = FormRoot;
|
|
13
|
+
Form.Title = FormTitle;
|
|
14
|
+
Form.Description = FormDescription;
|
|
15
|
+
Form.Body = FormBody;
|
|
8
16
|
Form.Login = Login;
|
|
9
17
|
Form.SecondFactorAuth = SecondFactorAuth;
|
|
10
18
|
Form.FileUploader = FileUploader;
|
|
@@ -8,15 +8,16 @@ export function ColorModeProvider(props) {
|
|
|
8
8
|
}
|
|
9
9
|
export function useColorMode() {
|
|
10
10
|
const { resolvedTheme, setTheme, forcedTheme } = useTheme();
|
|
11
|
-
const
|
|
11
|
+
const [mounted, setMounted] = React.useState(false);
|
|
12
|
+
React.useEffect(() => {
|
|
13
|
+
setMounted(true);
|
|
14
|
+
}, []);
|
|
15
|
+
const colorMode = (mounted ? (forcedTheme ?? resolvedTheme ?? "light") : "light");
|
|
12
16
|
const toggleColorMode = () => {
|
|
13
17
|
setTheme(resolvedTheme === "dark" ? "light" : "dark");
|
|
14
18
|
};
|
|
15
|
-
if (!colorMode) {
|
|
16
|
-
setTheme("light");
|
|
17
|
-
}
|
|
18
19
|
return {
|
|
19
|
-
colorMode
|
|
20
|
+
colorMode,
|
|
20
21
|
setColorMode: setTheme,
|
|
21
22
|
toggleColorMode,
|
|
22
23
|
};
|