Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storybook: remove React barrel imports #2905

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion storybook/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"no-console": "off",
"@comet/no-other-module-relative-import": "off"
"@comet/no-other-module-relative-import": "off",
"react/react-in-jsx-scope": "off"
},
"overrides": [
{
Expand Down
1 change: 0 additions & 1 deletion storybook/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { createTheme as createMuiTheme, GlobalStyles } from "@mui/material";
import type { Preview } from "@storybook/react";
import { Locale as DateFnsLocale } from "date-fns";
import { de as deLocale, enUS as enLocale } from "date-fns/locale";
import * as React from "react";
import { IntlProvider } from "react-intl";

import { worker } from "./mocks/browser";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DateField, DateRange, DateRangeField, DateTimeField, TimeField, TimeRange, TimeRangeField } from "@comet/admin-date-time";
import { Box, Card, CardContent } from "@mui/material";
import * as React from "react";
import { Form } from "react-final-form";

export default {
Expand Down
1 change: 0 additions & 1 deletion storybook/src/admin-date-time/DatePicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Field } from "@comet/admin";
import { FinalFormDatePicker } from "@comet/admin-date-time";
import { Card, CardContent } from "@mui/material";
import * as React from "react";
import { Form } from "react-final-form";

export default {
Expand Down
1 change: 0 additions & 1 deletion storybook/src/admin-date-time/DateRangePicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Field } from "@comet/admin";
import { DateRange, FinalFormDateRangePicker } from "@comet/admin-date-time";
import { Card, CardContent } from "@mui/material";
import * as React from "react";
import { Form } from "react-final-form";

export default {
Expand Down
1 change: 0 additions & 1 deletion storybook/src/admin-date-time/DateTimePicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Field } from "@comet/admin";
import { FinalFormDateTimePicker } from "@comet/admin-date-time";
import { Card, CardContent } from "@mui/material";
import * as React from "react";
import { Form } from "react-final-form";

export default {
Expand Down
1 change: 0 additions & 1 deletion storybook/src/admin-date-time/TimePicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Field } from "@comet/admin";
import { FinalFormTimePicker } from "@comet/admin-date-time";
import { Card, CardContent } from "@mui/material";
import * as React from "react";
import { Form } from "react-final-form";

export default {
Expand Down
1 change: 0 additions & 1 deletion storybook/src/admin-date-time/TimeRangePicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Field } from "@comet/admin";
import { FinalFormTimeRangePicker, TimeRange } from "@comet/admin-date-time";
import { Card, CardContent } from "@mui/material";
import * as React from "react";
import { Form } from "react-final-form";

export default {
Expand Down
1 change: 0 additions & 1 deletion storybook/src/admin-icons/IconUsage.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Cookie, Error, ThreeDotSaving } from "@comet/admin-icons";
import { Card, CardContent, Grid, Typography } from "@mui/material";
import * as React from "react";

export default {
title: "@comet/admin-icons",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Field, FinalFormInput, FormSection } from "@comet/admin";
import { FinalFormReactSelectStaticOptions } from "@comet/admin-react-select";
import { Card, CardContent } from "@mui/material";
import * as React from "react";
import { Form } from "react-final-form";

const options = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { CancelButton, Field, OkayButton } from "@comet/admin";
import { FinalFormReactSelectStaticOptions } from "@comet/admin-react-select";
import { Dialog, DialogActions, DialogContent, DialogTitle } from "@mui/material";
import * as React from "react";
import { Form } from "react-final-form";

const options = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Field, FormSection } from "@comet/admin";
import { FinalFormReactSelectStaticOptions } from "@comet/admin-react-select";
import { Card, CardContent } from "@mui/material";
import * as React from "react";
import { Form } from "react-final-form";

const options = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { FormSection } from "@comet/admin";
import { ReactSelect } from "@comet/admin-react-select";
import { Card, CardContent } from "@mui/material";
import * as React from "react";

const options = [
{ value: "chocolate", label: "Chocolate" },
Expand Down
6 changes: 3 additions & 3 deletions storybook/src/admin-rte/Field.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Field, FinalFormInput, FormSection } from "@comet/admin";
import { createFinalFormRte } from "@comet/admin-rte";
import { Button, Card, CardContent, Grid } from "@mui/material";
import * as React from "react";
import { useReducer, useState } from "react";
import { Form } from "react-final-form";

const { RteField, RteReadOnly } = createFinalFormRte();
Expand All @@ -11,8 +11,8 @@ export default {
};

export const _Field = () => {
const [submittedValue, setSubmittedValue] = React.useState<{ rteContent: any }>({ rteContent: undefined });
const [disabled, toggleDisabled] = React.useReducer((s) => !s, false);
const [submittedValue, setSubmittedValue] = useState<{ rteContent: any }>({ rteContent: undefined });
const [disabled, toggleDisabled] = useReducer((s) => !s, false);

return (
<Grid container spacing={4} style={{ maxWidth: 800 }}>
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/FieldAllOptions.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Field, FormSection } from "@comet/admin";
import { createFinalFormRte } from "@comet/admin-rte";
import { Button, Card, CardContent, Grid } from "@mui/material";
import * as React from "react";
import { useState } from "react";
import { Form } from "react-final-form";

import { ContentFormat, defaultContent, makeApiOptions, rteOptions } from "./RteAllOptions.stories";
Expand All @@ -17,7 +17,7 @@ export default {

export const FieldAllOptions = {
render: () => {
const [submittedValue, setSubmittedValue] = React.useState<{ rteContent: any }>({ rteContent: defaultContent });
const [submittedValue, setSubmittedValue] = useState<{ rteContent: any }>({ rteContent: defaultContent });

return (
<Grid container spacing={4} style={{ maxWidth: 800 }}>
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/MaxListLevel.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IRteRef, makeRteApi, Rte } from "@comet/admin-rte";
import { Box, Card, CardContent } from "@mui/material";
import * as React from "react";
import { useRef } from "react";

import { PrintEditorState, useAutoFocus } from "./helper";

Expand Down Expand Up @@ -128,7 +128,7 @@ export const MaxListLevel = {
});

// focus the editor to see the cursor immediately
const editorRef = React.useRef<IRteRef>();
const editorRef = useRef<IRteRef>();
useAutoFocus(editorRef);

return (
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/Rte.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IRteRef, makeRteApi, Rte } from "@comet/admin-rte";
import { Box, Card, CardContent } from "@mui/material";
import * as React from "react";
import { useRef } from "react";

import { exampleContent, PrintEditorState, useAutoFocus } from "./helper";

Expand All @@ -15,7 +15,7 @@ export const RteMinimalConfiguration = {
const { editorState, setEditorState } = useRteApi({ defaultValue: JSON.stringify(exampleContent) }); // defaultValue is optional

// focus the editor to see the cursor immediately
const editorRef = React.useRef<IRteRef>();
const editorRef = useRef<IRteRef>();
useAutoFocus(editorRef);

return (
Expand Down
8 changes: 4 additions & 4 deletions storybook/src/admin-rte/RteAllOptions.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IMakeRteApiProps, IRteApiProps, IRteOptions, IRteRef, LinkDecorator, makeRteApi, Rte } from "@comet/admin-rte";
import { Box, Card, CardContent, Typography } from "@mui/material";
import { convertFromRaw, convertToRaw } from "draft-js";
import * as React from "react";
import { ReactNode, useRef } from "react";

import { exampleContent, PrintEditorState, useAutoFocus } from "./helper";

Expand All @@ -25,12 +25,12 @@ export const apiOptions: IRteApiProps<ContentFormat> = {
debounceDelay: 400, // delay when onDebouncedContentChange after editor content changed
};

const RedCustomHeader: React.FC = ({ children }) => (
const RedCustomHeader = ({ children }: { children?: ReactNode }) => (
<Typography variant="h1" style={{ color: "red" }}>
{children}
</Typography>
);
const GreenCustomHeader: React.FC = ({ children }) => <h2 style={{ color: "green" }}>{children}</h2>;
const GreenCustomHeader = ({ children }: { children?: ReactNode }) => <h2 style={{ color: "green" }}>{children}</h2>;

export const rteOptions: IRteOptions = {
supports: [
Expand Down Expand Up @@ -112,7 +112,7 @@ export const RteAllOptions = {
const { editorState, setEditorState } = useRteApi(apiOptions);

// focus the editor to see the cursor immediately
const editorRef = React.useRef<IRteRef>();
const editorRef = useRef<IRteRef>();
useAutoFocus(editorRef);

return (
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/RteCustom.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IRteOptions, IRteRef, makeRteApi, Rte } from "@comet/admin-rte";
import { Box, Card, CardContent, Typography } from "@mui/material";
import * as React from "react";
import { useRef } from "react";

import { PrintEditorState, useAutoFocus } from "./helper";

Expand All @@ -20,7 +20,7 @@ export const RteCustomized = {
const { editorState, setEditorState } = useRteApi();

// focus the editor to see the cursor immediately
const editorRef = React.useRef<IRteRef>();
const editorRef = useRef<IRteRef>();
useAutoFocus(editorRef);

return (
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/RteCustomInlineStyles.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Favorite } from "@comet/admin-icons";
import { IRteOptions, IRteRef, makeRteApi, Rte } from "@comet/admin-rte";
import { Box, Card, CardContent } from "@mui/material";
import * as React from "react";
import { useRef } from "react";

import { PrintEditorState, useAutoFocus } from "./helper";

Expand Down Expand Up @@ -29,7 +29,7 @@ export const CustomInlineStyles = {
const { editorState, setEditorState } = useRteApi();

// focus the editor to see the cursor immediately
const editorRef = React.useRef<IRteRef>();
const editorRef = useRef<IRteRef>();
useAutoFocus(editorRef);

return (
Expand Down
6 changes: 3 additions & 3 deletions storybook/src/admin-rte/RteDisable.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Toolbar, ToolbarActions, ToolbarFillSpace } from "@comet/admin";
import { IRteRef, makeRteApi, Rte } from "@comet/admin-rte";
import { Box, Button, Card, CardContent } from "@mui/material";
import * as React from "react";
import { useReducer, useRef } from "react";

import { exampleContent, PrintEditorState, useAutoFocus } from "./helper";

Expand All @@ -14,10 +14,10 @@ export default {
export const RteDisable = {
render: () => {
const { editorState, setEditorState } = useRteApi({ defaultValue: JSON.stringify(exampleContent) }); // defaultValue is optional
const [disabled, toggleDisabled] = React.useReducer((s) => !s, false);
const [disabled, toggleDisabled] = useReducer((s) => !s, false);

// focus the editor to see the cursor immediately
const editorRef = React.useRef<IRteRef>();
const editorRef = useRef<IRteRef>();
useAutoFocus(editorRef);

return (
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/RteFilterContent.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@comet/admin-rte";
import { Box, Card, CardContent, Typography } from "@mui/material";
import { EditorState, EntityInstance } from "draft-js";
import * as React from "react";
import { useRef } from "react";

import { PrintEditorState, useAutoFocus } from "./helper";

Expand Down Expand Up @@ -41,7 +41,7 @@ export const RteFilterContent = {
const { editorState, setEditorState } = useRteApi();

// focus the editor to see the cursor immediately
const editorRef = React.useRef<IRteRef>();
const editorRef = useRef<IRteRef>();
useAutoFocus(editorRef);

return (
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/RteMaxBlocks.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IRteOptions, IRteRef, makeRteApi, Rte } from "@comet/admin-rte";
import { Box, Card, CardContent } from "@mui/material";
import * as React from "react";
import { useRef } from "react";

import { PrintEditorState, useAutoFocus } from "./helper";

Expand Down Expand Up @@ -45,7 +45,7 @@ export const RteMaxBlocksSet = {
});

// focus the editor to see the cursor immediately
const editorRef = React.useRef<IRteRef>();
const editorRef = useRef<IRteRef>();
useAutoFocus(editorRef);

return (
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/RteReadOnly.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { IRteReadOnlyOptions, makeRteApi, RteReadOnly } from "@comet/admin-rte";
import { Box, Card, CardContent } from "@mui/material";
import * as React from "react";
import { ReactNode } from "react";

import { exampleContent, PrintEditorState } from "./helper";

const [useRteApi] = makeRteApi();

const GreenCustomHeader: React.FC = ({ children }) => <span style={{ color: "green" }}>{children}</span>;
const GreenCustomHeader = ({ children }: { children?: ReactNode }) => <span style={{ color: "green" }}>{children}</span>;

const rteOptions: IRteReadOnlyOptions = {
blocktypeMap: {
Expand Down
1 change: 0 additions & 1 deletion storybook/src/admin-rte/RteSortBlockTypes.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { IRteOptions, makeRteApi, Rte } from "@comet/admin-rte";
import { Box, Card, CardContent } from "@mui/material";
import * as React from "react";

const rteOptions: IRteOptions = {
blocktypeMap: {
Expand Down
1 change: 0 additions & 1 deletion storybook/src/admin-rte/RteTheming.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { makeRteApi, Rte } from "@comet/admin-rte";
import { Box, Card, CardContent } from "@mui/material";
import * as React from "react";

const [useRteApi] = makeRteApi();

Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/SaveAsDraftObject.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IMakeRteApiProps, makeRteApi, OnDebouncedContentChangeFn, Rte } from "@comet/admin-rte";
import { Box, Card, CardContent } from "@mui/material";
import { convertFromRaw, convertToRaw, RawDraftContentState } from "draft-js";
import * as React from "react";
import { useState } from "react";

import { PrintAnything } from "./helper";

Expand Down Expand Up @@ -48,7 +48,7 @@ export default {

export const SaveAsRawDraftJsObject = {
render: () => {
const [savableContent, setSavableContent] = React.useState<RawDraftContentState>(defaultValue);
const [savableContent, setSavableContent] = useState<RawDraftContentState>(defaultValue);

const handleDebouncedContentChange: OnDebouncedContentChangeFn = (innerEditorState, convertStateToRawContent) => {
setSavableContent(convertStateToRawContent(innerEditorState));
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/SaveAsHtml.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IMakeRteApiProps, makeRteApi, OnDebouncedContentChangeFn, Rte } from "@
import { Box, Card, CardContent } from "@mui/material";
import { ContentState, convertFromHTML } from "draft-js";
import { stateToHTML } from "draft-js-export-html";
import * as React from "react";
import { useState } from "react";

import { PrintAnything } from "./helper";

Expand All @@ -28,7 +28,7 @@ export default {

export const SaveAsHtml = {
render: () => {
const [savableContent, setSavableContent] = React.useState<Html>(defaultValue);
const [savableContent, setSavableContent] = useState<Html>(defaultValue);

const handleDebouncedContentChange: OnDebouncedContentChangeFn = (innerEditorState, convertStateToRawContent) => {
setSavableContent(convertStateToRawContent(innerEditorState));
Expand Down
4 changes: 2 additions & 2 deletions storybook/src/admin-rte/SaveAsMD.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { IMakeRteApiProps, makeRteApi, OnDebouncedContentChangeFn, Rte } from "@
import { Box, Card, CardContent } from "@mui/material";
import { stateToMarkdown } from "draft-js-export-markdown";
import { stateFromMarkdown } from "draft-js-import-markdown";
import * as React from "react";
import { useState } from "react";

import { PrintAnything } from "./helper";

Expand Down Expand Up @@ -31,7 +31,7 @@ export default {

export const SaveAsMd = {
render: () => {
const [savableContent, setSavableContent] = React.useState<Markdown>(defaultValue);
const [savableContent, setSavableContent] = useState<Markdown>(defaultValue);

const handleDebouncedContentChange: OnDebouncedContentChangeFn = (innerEditorState, convertStateToRawContent) => {
setSavableContent(convertStateToRawContent(innerEditorState));
Expand Down
Loading
Loading