@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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vrobots/storybook",
3
3
  "private": false,
4
- "version": "0.2.3",
4
+ "version": "0.2.5",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -0,0 +1,4 @@
1
+ declare const FormBody: ({ children }: {
2
+ children: React.ReactNode;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default FormBody;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Stack } from "@chakra-ui/react";
3
+ const FormBody = ({ children }) => {
4
+ return (_jsx(Stack, { gap: "4", mt: 4, children: children }));
5
+ };
6
+ export default FormBody;
@@ -0,0 +1,4 @@
1
+ declare const FormDescription: ({ description }: {
2
+ description: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default FormDescription;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Card } from "@chakra-ui/react";
3
+ const FormDescription = ({ description }) => {
4
+ return _jsx(Card.Description, { children: description });
5
+ };
6
+ export default FormDescription;
@@ -0,0 +1,3 @@
1
+ import { BoxProps } from "@chakra-ui/react";
2
+ export declare const FormRoot: (props: BoxProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default FormRoot;
@@ -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;
@@ -0,0 +1,4 @@
1
+ declare const FormTitle: ({ title }: {
2
+ title: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default FormTitle;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Card } from "@chakra-ui/react";
3
+ const FormTitle = ({ title }) => {
4
+ return _jsx(Card.Title, { children: title || "Second Factor Auth" });
5
+ };
6
+ export default FormTitle;
@@ -1,17 +1,21 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Box, Button, Card, Field, Input, Stack } from "@chakra-ui/react";
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 (_jsx(Card.Root, { ...props, children: _jsxs(Card.Body, { children: [_jsx(Card.Title, { children: title || "Login" }), !!description && _jsx(Card.Description, { children: description }), _jsxs(Box, { as: "form", onSubmit: handleSubmit((data) => onLogin(data)), mt: 4, 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", {
8
- required: "Please enter your email address",
9
- pattern: {
10
- 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,}))$/,
11
- message: "Invalid email address"
12
- }
13
- }), 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", {
14
- required: "Please enter your password",
15
- }) }), _jsx(Field.ErrorText, { children: errors.password?.message })] })] }), children, _jsx(Button, { type: "submit", width: "full", mt: 6, children: "Login" })] })] }) }));
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 { Box, Button, Card, Checkbox, Field, Input, InputGroup, Stack } from "@chakra-ui/react";
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 (_jsx(Card.Root, { ...props, children: _jsxs(Card.Body, { children: [_jsx(Card.Title, { children: title || "Second Factor Auth" }), !!description && _jsx(Card.Description, { children: description }), _jsxs(Box, { as: "form", onSubmit: handleSubmit((data) => onSecondFactorAuth(data)), mt: 4, children: [_jsxs(Stack, { gap: "4", 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", {
7
- required: "Please enter your authorization code",
8
- }), 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" })] })] }) }));
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 colorMode = forcedTheme || resolvedTheme;
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: colorMode,
20
+ colorMode,
20
21
  setColorMode: setTheme,
21
22
  toggleColorMode,
22
23
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vrobots/storybook",
3
3
  "private": false,
4
- "version": "0.2.3",
4
+ "version": "0.2.5",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",