apply more changes to code

This commit is contained in:
Norbert de Langen 2024-08-08 14:18:47 +02:00
parent d8554e319f
commit c064c112b7
63 changed files with 107 additions and 16 deletions

View File

@ -1,12 +1,15 @@
import type { PropsWithChildren } from 'react'; import type { PropsWithChildren } from 'react';
import React, { Component } from 'react'; import React, { Component } from 'react';
import type { import type {
DocsContextProps, DocsContextProps,
DocsRenderFunction, DocsRenderFunction,
Parameters, Parameters,
Renderer, Renderer,
} from 'storybook/internal/types'; } from 'storybook/internal/types';
import { AnchorMdx, CodeOrSourceMdx, Docs, HeadersMdx } from '@storybook/blocks'; import { AnchorMdx, CodeOrSourceMdx, Docs, HeadersMdx } from '@storybook/blocks';
import { renderElement, unmountElement } from '@storybook/react-dom-shim'; import { renderElement, unmountElement } from '@storybook/react-dom-shim';
// TS doesn't like that we export a component with types that it doesn't know about (TS4203) // TS doesn't like that we export a component with types that it doesn't know about (TS4203)

View File

@ -1,5 +1,7 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { dedent } from 'ts-dedent'; import { dedent } from 'ts-dedent';
import { compile, compileSync } from './index'; import { compile, compileSync } from './index';
expect.addSnapshotSerializer({ expect.addSnapshotSerializer({

View File

@ -1,5 +1,6 @@
import type { transformAsync } from '@babel/core'; import type { transformAsync } from '@babel/core';
import type { compile as mdxCompile } from '@mdx-js/mdx'; import type { compile as mdxCompile } from '@mdx-js/mdx';
import { compile } from './compiler'; import { compile } from './compiler';
export type MdxCompileOptions = Parameters<typeof mdxCompile>[1]; export type MdxCompileOptions = Parameters<typeof mdxCompile>[1];

View File

@ -1,9 +1,11 @@
import type { Options } from 'storybook/internal/types'; import type { Options } from 'storybook/internal/types';
import { createFilter } from '@rollup/pluginutils'; import { createFilter } from '@rollup/pluginutils';
import { dirname, join } from 'path'; import { dirname, join } from 'path';
import rehypeExternalLinks from 'rehype-external-links'; import rehypeExternalLinks from 'rehype-external-links';
import rehypeSlug from 'rehype-slug'; import rehypeSlug from 'rehype-slug';
import type { Plugin } from 'vite'; import type { Plugin } from 'vite';
import type { CompileOptions } from '../compiler'; import type { CompileOptions } from '../compiler';
import { compile } from '../compiler'; import { compile } from '../compiler';

View File

@ -1,9 +1,12 @@
import { logger } from 'storybook/internal/node-logger'; import { logger } from 'storybook/internal/node-logger';
import type { DocsOptions, Options, PresetProperty } from 'storybook/internal/types'; import type { DocsOptions, Options, PresetProperty } from 'storybook/internal/types';
import type { CsfPluginOptions } from '@storybook/csf-plugin'; import type { CsfPluginOptions } from '@storybook/csf-plugin';
import { dirname, isAbsolute, join } from 'path'; import { dirname, isAbsolute, join } from 'path';
import rehypeExternalLinks from 'rehype-external-links'; import rehypeExternalLinks from 'rehype-external-links';
import rehypeSlug from 'rehype-slug'; import rehypeSlug from 'rehype-slug';
import type { CompileOptions } from './compiler'; import type { CompileOptions } from './compiler';
/** /**

View File

@ -1,4 +1,5 @@
import type { PreparedStory } from 'storybook/internal/types'; import type { PreparedStory } from 'storybook/internal/types';
import { global } from '@storybook/global'; import { global } from '@storybook/global';
const excludeTags = Object.entries(global.TAGS_OPTIONS ?? {}).reduce( const excludeTags = Object.entries(global.TAGS_OPTIONS ?? {}).reduce(

View File

@ -1,8 +1,9 @@
import * as ReactExport from 'react'; import * as ReactExport from 'react';
import { expect, within } from '@storybook/test';
import * as ReactDom from 'react-dom'; import * as ReactDom from 'react-dom';
import * as ReactDomServer from 'react-dom/server'; import * as ReactDomServer from 'react-dom/server';
import { expect, within } from '@storybook/test';
/** /**
* This component is used to display the resolved version of React and its related packages. * This component is used to display the resolved version of React and its related packages.
* As long as `@storybook/addon-docs` is installed, `react` and `react-dom` should be available to import from and should resolve to the same version. * As long as `@storybook/addon-docs` is installed, `react` and `react-dom` should be available to import from and should resolve to the same version.

View File

@ -1,5 +1,7 @@
import type { StoryContext } from 'storybook/internal/types'; import type { StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global'; import { global as globalThis } from '@storybook/global';
import { dedent } from 'ts-dedent'; import { dedent } from 'ts-dedent';
export default { export default {

View File

@ -1,4 +1,5 @@
import { defineConfig, mergeConfig } from 'vitest/config'; import { defineConfig, mergeConfig } from 'vitest/config';
import { vitestCommonConfig } from '../../vitest.workspace'; import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig( export default mergeConfig(

View File

@ -1,10 +1,10 @@
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
import { useState } from 'react'; import { useState } from 'react';
import { createPortal } from 'react-dom';
import { styled } from 'storybook/internal/theming'; import { styled } from 'storybook/internal/theming';
import ReactConfetti from 'react-confetti'; import ReactConfetti from 'react-confetti';
import { createPortal } from 'react-dom';
interface ConfettiProps extends Omit<React.ComponentProps<typeof ReactConfetti>, 'drawShape'> { interface ConfettiProps extends Omit<React.ComponentProps<typeof ReactConfetti>, 'drawShape'> {
top?: number; top?: number;

View File

@ -1,10 +1,9 @@
import React, { Suspense, lazy } from 'react'; import React, { Suspense, lazy } from 'react';
import ReactDOM from 'react-dom';
import { STORY_SPECIFIED } from 'storybook/internal/core-events'; import { STORY_SPECIFIED } from 'storybook/internal/core-events';
import { addons } from 'storybook/internal/manager-api'; import { addons } from 'storybook/internal/manager-api';
import ReactDOM from 'react-dom';
const Onboarding = lazy(() => import('./Onboarding')); const Onboarding = lazy(() => import('./Onboarding'));
// The addon is enabled only when: // The addon is enabled only when:

View File

@ -1,10 +1,11 @@
import { logger } from '@storybook/core/node-logger';
import type { import type {
CoreCommon_AddonEntry, CoreCommon_AddonEntry,
CoreCommon_AddonInfo, CoreCommon_AddonInfo,
CoreCommon_OptionsEntry, CoreCommon_OptionsEntry,
} from '@storybook/core/types'; } from '@storybook/core/types';
import { logger } from '@storybook/core/node-logger';
interface Options { interface Options {
before: CoreCommon_AddonInfo; before: CoreCommon_AddonInfo;
after: CoreCommon_AddonInfo; after: CoreCommon_AddonInfo;

View File

@ -1,10 +1,10 @@
import type { ComponentProps, ReactNode } from 'react'; import type { ComponentProps, ReactNode } from 'react';
import React, { useCallback, useEffect, useState } from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import ReactDOM from 'react-dom';
import { styled } from '@storybook/core/theming'; import { styled } from '@storybook/core/theming';
import { global } from '@storybook/global'; import { global } from '@storybook/global';
import ReactDOM from 'react-dom';
import type { PopperOptions, Config as ReactPopperTooltipConfig } from 'react-popper-tooltip'; import type { PopperOptions, Config as ReactPopperTooltipConfig } from 'react-popper-tooltip';
import { usePopperTooltip } from 'react-popper-tooltip'; import { usePopperTooltip } from 'react-popper-tooltip';

View File

@ -1,6 +1,7 @@
import { addons } from '@storybook/core/manager-api';
import { global } from '@storybook/global'; import { global } from '@storybook/global';
import { addons } from '@storybook/core/manager-api';
const STATIC_FILTER = 'static-filter'; const STATIC_FILTER = 'static-filter';
addons.register(STATIC_FILTER, (api) => { addons.register(STATIC_FILTER, (api) => {

View File

@ -1,4 +1,5 @@
import type { Channel } from '@storybook/core/channels'; import type { Channel } from '@storybook/core/channels';
import type { RequestData, ResponseData } from '@storybook/core/core-events'; import type { RequestData, ResponseData } from '@storybook/core/core-events';
export class RequestResponseError<Payload extends Record<string, any> | void> extends Error { export class RequestResponseError<Payload extends Record<string, any> | void> extends Error {

View File

@ -1,7 +1,8 @@
import type { Virtualizer } from '@tanstack/react-virtual';
import { useEffect } from 'react'; import { useEffect } from 'react';
import { flushSync } from 'react-dom'; import { flushSync } from 'react-dom';
import type { Virtualizer } from '@tanstack/react-virtual';
interface UseArrowKeyNavigationProps { interface UseArrowKeyNavigationProps {
rowVirtualizer: Virtualizer<HTMLDivElement, Element>; rowVirtualizer: Virtualizer<HTMLDivElement, Element>;
parentRef: React.MutableRefObject<HTMLDivElement>; parentRef: React.MutableRefObject<HTMLDivElement>;

View File

@ -1,4 +1,6 @@
import * as REACT from 'react'; import * as REACT from 'react';
import * as REACT_DOM from 'react-dom';
import * as REACT_DOM_CLIENT from 'react-dom/client';
import * as CHANNELS from '@storybook/core/channels'; import * as CHANNELS from '@storybook/core/channels';
import * as COMPONENTS from '@storybook/core/components'; import * as COMPONENTS from '@storybook/core/components';
@ -13,9 +15,6 @@ import * as EVENTS from '@storybook/core/core-events';
import * as MANAGER_API from '@storybook/core/manager-api'; import * as MANAGER_API from '@storybook/core/manager-api';
import * as EVENTS_MANAGER_ERRORS from '@storybook/core/manager-errors'; import * as EVENTS_MANAGER_ERRORS from '@storybook/core/manager-errors';
import * as REACT_DOM from 'react-dom';
import * as REACT_DOM_CLIENT from 'react-dom/client';
import type { globalsNameReferenceMap } from './globals'; import type { globalsNameReferenceMap } from './globals';
// Here we map the name of a module to their VALUE in the global scope. // Here we map the name of a module to their VALUE in the global scope.

View File

@ -1,5 +1,6 @@
import type { ComponentProps, FC } from 'react'; import type { ComponentProps, FC } from 'react';
import React, { useCallback, useMemo } from 'react'; import React, { useCallback, useMemo } from 'react';
import { createRoot } from 'react-dom/client';
import { Location, LocationProvider, useNavigate } from '@storybook/core/router'; import { Location, LocationProvider, useNavigate } from '@storybook/core/router';
import { ThemeProvider, ensure as ensureTheme } from '@storybook/core/theming'; import { ThemeProvider, ensure as ensureTheme } from '@storybook/core/theming';
@ -10,7 +11,6 @@ import { Provider as ManagerProvider, types } from '@storybook/core/manager-api'
import type { Combo } from '@storybook/core/manager-api'; import type { Combo } from '@storybook/core/manager-api';
import { ProviderDoesNotExtendBaseProviderError } from '@storybook/core/manager-errors'; import { ProviderDoesNotExtendBaseProviderError } from '@storybook/core/manager-errors';
import { createRoot } from 'react-dom/client';
import { HelmetProvider } from 'react-helmet-async'; import { HelmetProvider } from 'react-helmet-async';
import { App } from './App'; import { App } from './App';

View File

@ -1,5 +1,6 @@
import { enhanceArgTypes } from 'storybook/internal/docs-tools'; import { enhanceArgTypes } from 'storybook/internal/docs-tools';
import type { ArgTypesEnhancer } from 'storybook/internal/types'; import type { ArgTypesEnhancer } from 'storybook/internal/types';
import { extractArgTypes, extractComponentDescription } from './jsondoc'; import { extractArgTypes, extractComponentDescription } from './jsondoc';
export const parameters: {} = { export const parameters: {} = {

View File

@ -1,4 +1,5 @@
import * as React from 'react'; import * as React from 'react';
import { StyleRegistry } from 'styled-jsx'; import { StyleRegistry } from 'styled-jsx';
export const StyledJsxDecorator = (Story: React.FC): React.ReactNode => ( export const StyledJsxDecorator = (Story: React.FC): React.ReactNode => (

View File

@ -1,6 +1,7 @@
import dynamic from 'next/dynamic';
import React, { Suspense } from 'react'; import React, { Suspense } from 'react';
import dynamic from 'next/dynamic';
const DynamicComponent = dynamic(() => import('./dynamic-component'), { const DynamicComponent = dynamic(() => import('./dynamic-component'), {
ssr: false, ssr: false,
}); });

View File

@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import 'server-only'; import 'server-only';
export const RSC = async ({ label }) => <>RSC {label}</>; export const RSC = async ({ label }) => <>RSC {label}</>;

View File

@ -1,6 +1,7 @@
import { getImageProps } from 'next/image';
import React from 'react'; import React from 'react';
import { getImageProps } from 'next/image';
import Accessibility from '../../assets/accessibility.svg'; import Accessibility from '../../assets/accessibility.svg';
import Testing from '../../assets/testing.png'; import Testing from '../../assets/testing.png';

View File

@ -1,7 +1,9 @@
import type { Mock } from 'vitest'; import type { Mock } from 'vitest';
import { beforeEach, describe, expect, it, vi } from 'vitest'; import { beforeEach, describe, expect, it, vi } from 'vitest';
import { SNIPPET_RENDERED } from 'storybook/internal/docs-tools'; import { SNIPPET_RENDERED } from 'storybook/internal/docs-tools';
import { addons, useEffect } from 'storybook/internal/preview-api'; import { addons, useEffect } from 'storybook/internal/preview-api';
import type { StoryContext } from '../types'; import type { StoryContext } from '../types';
import { sourceDecorator } from './sourceDecorator'; import { sourceDecorator } from './sourceDecorator';

View File

@ -2,6 +2,7 @@
import { SNIPPET_RENDERED, SourceType } from 'storybook/internal/docs-tools'; import { SNIPPET_RENDERED, SourceType } from 'storybook/internal/docs-tools';
import { addons, useEffect } from 'storybook/internal/preview-api'; import { addons, useEffect } from 'storybook/internal/preview-api';
import type { DecoratorFunction } from 'storybook/internal/types'; import type { DecoratorFunction } from 'storybook/internal/types';
import type { StoryFn } from '../public-types'; import type { StoryFn } from '../public-types';
import type { HtmlRenderer } from '../types'; import type { HtmlRenderer } from '../types';

View File

@ -1,5 +1,6 @@
import { defaultDecorateStory } from 'storybook/internal/preview-api'; import { defaultDecorateStory } from 'storybook/internal/preview-api';
import type { DecoratorFunction, LegacyStoryFn } from 'storybook/internal/types'; import type { DecoratorFunction, LegacyStoryFn } from 'storybook/internal/types';
import type { ReactRenderer } from '../types'; import type { ReactRenderer } from '../types';
import { jsxDecorator } from './jsxDecorator'; import { jsxDecorator } from './jsxDecorator';

View File

@ -1,12 +1,15 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { normalizeNewlines } from 'storybook/internal/docs-tools'; import { normalizeNewlines } from 'storybook/internal/docs-tools';
import { inferControls } from 'storybook/internal/preview-api'; import { inferControls } from 'storybook/internal/preview-api';
import type { Renderer } from 'storybook/internal/types'; import type { Renderer } from 'storybook/internal/types';
import { transformFileSync, transformSync } from '@babel/core'; import { transformFileSync, transformSync } from '@babel/core';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
// @ts-expect-error (seems broken/missing) // @ts-expect-error (seems broken/missing)
import requireFromString from 'require-from-string'; import requireFromString from 'require-from-string';
import type { StoryContext } from '../types'; import type { StoryContext } from '../types';
import { extractArgTypes } from './extractArgTypes'; import { extractArgTypes } from './extractArgTypes';
import { extractProps } from './extractProps'; import { extractProps } from './extractProps';

View File

@ -1,5 +1,6 @@
import type { ArgTypesExtractor, PropDef } from 'storybook/internal/docs-tools'; import type { ArgTypesExtractor, PropDef } from 'storybook/internal/docs-tools';
import type { StrictArgTypes } from 'storybook/internal/types'; import type { StrictArgTypes } from 'storybook/internal/types';
import { extractProps } from './extractProps'; import { extractProps } from './extractProps';
export const extractArgTypes: ArgTypesExtractor = (component): StrictArgTypes | null => { export const extractArgTypes: ArgTypesExtractor = (component): StrictArgTypes | null => {

View File

@ -4,7 +4,9 @@ import {
extractComponentProps, extractComponentProps,
hasDocgen, hasDocgen,
} from 'storybook/internal/docs-tools'; } from 'storybook/internal/docs-tools';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { isMemo } from './lib'; import { isMemo } from './lib';
import { enhancePropTypesProps } from './propTypes/handleProp'; import { enhancePropTypesProps } from './propTypes/handleProp';
import { enhanceTypeScriptProps } from './typeScript/handleProp'; import { enhanceTypeScriptProps } from './typeScript/handleProp';

View File

@ -1,11 +1,15 @@
/* eslint-disable no-underscore-dangle */ /* eslint-disable no-underscore-dangle */
import type { Mock } from 'vitest'; import type { Mock } from 'vitest';
import { beforeEach, describe, expect, it, vi } from 'vitest'; import { beforeEach, describe, expect, it, vi } from 'vitest';
import type { FC, PropsWithChildren } from 'react'; import type { FC, PropsWithChildren } from 'react';
import React, { Profiler, StrictMode, createElement } from 'react'; import React, { Profiler, StrictMode, createElement } from 'react';
import { SNIPPET_RENDERED } from 'storybook/internal/docs-tools'; import { SNIPPET_RENDERED } from 'storybook/internal/docs-tools';
import { addons, useEffect } from 'storybook/internal/preview-api'; import { addons, useEffect } from 'storybook/internal/preview-api';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { getReactSymbolName, jsxDecorator, renderJsx } from './jsxDecorator'; import { getReactSymbolName, jsxDecorator, renderJsx } from './jsxDecorator';
vi.mock('storybook/internal/preview-api'); vi.mock('storybook/internal/preview-api');

View File

@ -1,12 +1,15 @@
/* eslint-disable no-underscore-dangle */ /* eslint-disable no-underscore-dangle */
import type { ReactElement, ReactNode } from 'react'; import type { ReactElement, ReactNode } from 'react';
import React, { createElement, isValidElement } from 'react'; import React, { createElement, isValidElement } from 'react';
import { logger } from 'storybook/internal/client-logger'; import { logger } from 'storybook/internal/client-logger';
import { SNIPPET_RENDERED, SourceType, getDocgenSection } from 'storybook/internal/docs-tools'; import { SNIPPET_RENDERED, SourceType, getDocgenSection } from 'storybook/internal/docs-tools';
import { addons, useEffect } from 'storybook/internal/preview-api'; import { addons, useEffect } from 'storybook/internal/preview-api';
import type { ArgsStoryFn, PartialStoryFn, StoryContext } from 'storybook/internal/types'; import type { ArgsStoryFn, PartialStoryFn, StoryContext } from 'storybook/internal/types';
import type { Options } from 'react-element-to-jsx-string'; import type { Options } from 'react-element-to-jsx-string';
import reactElementToJSXString from 'react-element-to-jsx-string'; import reactElementToJSXString from 'react-element-to-jsx-string';
import type { ReactRenderer } from '../types'; import type { ReactRenderer } from '../types';
import { isForwardRef, isMemo } from './lib'; import { isForwardRef, isMemo } from './lib';

View File

@ -3,6 +3,7 @@ import {
createSummaryValue, createSummaryValue,
isTooLongForDefaultValueSummary, isTooLongForDefaultValueSummary,
} from 'storybook/internal/docs-tools'; } from 'storybook/internal/docs-tools';
import { ELEMENT_CAPTION, FUNCTION_CAPTION } from '../captions'; import { ELEMENT_CAPTION, FUNCTION_CAPTION } from '../captions';
import { generateCode } from '../generateCode'; import { generateCode } from '../generateCode';
import type { import type {

View File

@ -5,10 +5,12 @@ import {
createSummaryValue, createSummaryValue,
isTooLongForDefaultValueSummary, isTooLongForDefaultValueSummary,
} from 'storybook/internal/docs-tools'; } from 'storybook/internal/docs-tools';
import isFunction from 'lodash/isFunction.js'; import isFunction from 'lodash/isFunction.js';
import isPlainObject from 'lodash/isPlainObject.js'; import isPlainObject from 'lodash/isPlainObject.js';
import isString from 'lodash/isString.js'; import isString from 'lodash/isString.js';
import reactElementToJSXString from 'react-element-to-jsx-string'; import reactElementToJSXString from 'react-element-to-jsx-string';
import { ELEMENT_CAPTION, FUNCTION_CAPTION, OBJECT_CAPTION } from '../captions'; import { ELEMENT_CAPTION, FUNCTION_CAPTION, OBJECT_CAPTION } from '../captions';
import type { InspectionFunction } from '../inspection'; import type { InspectionFunction } from '../inspection';
import { inspectValue } from '../inspection'; import { inspectValue } from '../inspection';

View File

@ -3,6 +3,7 @@ import {
createSummaryValue, createSummaryValue,
isTooLongForDefaultValueSummary, isTooLongForDefaultValueSummary,
} from 'storybook/internal/docs-tools'; } from 'storybook/internal/docs-tools';
import { ARRAY_CAPTION } from '../captions'; import { ARRAY_CAPTION } from '../captions';
import { generateArrayCode } from '../generateCode'; import { generateArrayCode } from '../generateCode';
import type { InspectionArray, InspectionResult } from '../inspection'; import type { InspectionArray, InspectionResult } from '../inspection';

View File

@ -3,6 +3,7 @@ import {
createSummaryValue, createSummaryValue,
isTooLongForDefaultValueSummary, isTooLongForDefaultValueSummary,
} from 'storybook/internal/docs-tools'; } from 'storybook/internal/docs-tools';
import { OBJECT_CAPTION } from '../captions'; import { OBJECT_CAPTION } from '../captions';
import { generateObjectCode } from '../generateCode'; import { generateObjectCode } from '../generateCode';
import type { InspectionArray, InspectionResult } from '../inspection'; import type { InspectionArray, InspectionResult } from '../inspection';

View File

@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { parse } from './acornParser'; import { parse } from './acornParser';
import type { import type {
InspectionArray, InspectionArray,

View File

@ -2,6 +2,7 @@ import { Parser } from 'acorn';
import jsx from 'acorn-jsx'; import jsx from 'acorn-jsx';
import * as acornWalk from 'acorn-walk'; import * as acornWalk from 'acorn-walk';
import type estree from 'estree'; import type estree from 'estree';
import type { import type {
InspectionArray, InspectionArray,
InspectionClass, InspectionClass,

View File

@ -1,5 +1,6 @@
import type { DocgenPropType, ExtractedProp, PropType } from 'storybook/internal/docs-tools'; import type { DocgenPropType, ExtractedProp, PropType } from 'storybook/internal/docs-tools';
import { createSummaryValue, isTooLongForTypeSummary } from 'storybook/internal/docs-tools'; import { createSummaryValue, isTooLongForTypeSummary } from 'storybook/internal/docs-tools';
import { import {
ARRAY_CAPTION, ARRAY_CAPTION,
CLASS_CAPTION, CLASS_CAPTION,

View File

@ -1,5 +1,7 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { parseJsDoc } from 'storybook/internal/docs-tools'; import { parseJsDoc } from 'storybook/internal/docs-tools';
import { generateFuncSignature, generateShortFuncSignature } from './generateFuncSignature'; import { generateFuncSignature, generateShortFuncSignature } from './generateFuncSignature';
describe('generateFuncSignature', () => { describe('generateFuncSignature', () => {

View File

@ -1,13 +1,17 @@
/* eslint-disable no-underscore-dangle */ /* eslint-disable no-underscore-dangle */
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import React from 'react'; import React from 'react';
import { import {
type DocgenInfo, type DocgenInfo,
type DocgenPropDefaultValue, type DocgenPropDefaultValue,
type PropDef, type PropDef,
extractComponentProps, extractComponentProps,
} from 'storybook/internal/docs-tools'; } from 'storybook/internal/docs-tools';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { enhancePropTypesProp, enhancePropTypesProps } from './handleProp'; import { enhancePropTypesProp, enhancePropTypesProps } from './handleProp';
type Component = any; type Component = any;

View File

@ -1,4 +1,5 @@
import type { ExtractedProp, PropDef } from 'storybook/internal/docs-tools'; import type { ExtractedProp, PropDef } from 'storybook/internal/docs-tools';
import { createDefaultValue, createDefaultValueFromRawDefaultProp } from '../lib/defaultValues'; import { createDefaultValue, createDefaultValueFromRawDefaultProp } from '../lib/defaultValues';
import { createType } from './createType'; import { createType } from './createType';
import { rawDefaultPropTypeResolvers } from './rawDefaultPropResolvers'; import { rawDefaultPropTypeResolvers } from './rawDefaultPropResolvers';

View File

@ -1,4 +1,5 @@
import { createSummaryValue } from 'storybook/internal/docs-tools'; import { createSummaryValue } from 'storybook/internal/docs-tools';
import { ELEMENT_CAPTION, FUNCTION_CAPTION } from '../lib'; import { ELEMENT_CAPTION, FUNCTION_CAPTION } from '../lib';
import type { TypeResolver } from '../lib/defaultValues'; import type { TypeResolver } from '../lib/defaultValues';
import { createTypeResolvers, extractFunctionName } from '../lib/defaultValues'; import { createTypeResolvers, extractFunctionName } from '../lib/defaultValues';

View File

@ -1,12 +1,15 @@
/* eslint-disable no-underscore-dangle */ /* eslint-disable no-underscore-dangle */
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import React from 'react'; import React from 'react';
import { import {
type DocgenInfo, type DocgenInfo,
type DocgenPropDefaultValue, type DocgenPropDefaultValue,
type PropDef, type PropDef,
extractComponentProps, extractComponentProps,
} from 'storybook/internal/docs-tools'; } from 'storybook/internal/docs-tools';
import { enhanceTypeScriptProp } from './handleProp'; import { enhanceTypeScriptProp } from './handleProp';
type Component = any; type Component = any;

View File

@ -1,4 +1,5 @@
import type { ExtractedProp, PropDef } from 'storybook/internal/docs-tools'; import type { ExtractedProp, PropDef } from 'storybook/internal/docs-tools';
import { createDefaultValue, createDefaultValueFromRawDefaultProp } from '../lib/defaultValues'; import { createDefaultValue, createDefaultValueFromRawDefaultProp } from '../lib/defaultValues';
export function enhanceTypeScriptProp(extractedProp: ExtractedProp, rawDefaultProp?: any): PropDef { export function enhanceTypeScriptProp(extractedProp: ExtractedProp, rawDefaultProp?: any): PropDef {

View File

@ -1,7 +1,8 @@
import PropTypes from 'prop-types';
import type { FC } from 'react'; import type { FC } from 'react';
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types';
export interface IProps { export interface IProps {
/** /**
* button color * button color

View File

@ -1,6 +1,8 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import * as fs from 'fs'; import * as fs from 'fs';
import svelteDoc from 'sveltedoc-parser'; import svelteDoc from 'sveltedoc-parser';
import { createArgTypes } from './extractArgTypes'; import { createArgTypes } from './extractArgTypes';
const content = fs.readFileSync(`${__dirname}/sample/MockButton.svelte`, 'utf-8'); const content = fs.readFileSync(`${__dirname}/sample/MockButton.svelte`, 'utf-8');

View File

@ -1,6 +1,7 @@
import { logger } from 'storybook/internal/client-logger'; import { logger } from 'storybook/internal/client-logger';
import type { ArgTypesExtractor } from 'storybook/internal/docs-tools'; import type { ArgTypesExtractor } from 'storybook/internal/docs-tools';
import type { SBScalarType, StrictArgTypes } from 'storybook/internal/types'; import type { SBScalarType, StrictArgTypes } from 'storybook/internal/types';
import type { import type {
JSDocKeyword, JSDocKeyword,
JSDocType, JSDocType,

View File

@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import { extractComponentDescription } from './extractComponentDescription'; import { extractComponentDescription } from './extractComponentDescription';
describe('extractComponentDescription', () => { describe('extractComponentDescription', () => {

View File

@ -1,5 +1,7 @@
import { describe, expect, it } from 'vitest'; import { describe, expect, it } from 'vitest';
import type { Args } from 'storybook/internal/types'; import type { Args } from 'storybook/internal/types';
import { generateSvelteSource } from './sourceDecorator'; import { generateSvelteSource } from './sourceDecorator';
expect.addSnapshotSerializer({ expect.addSnapshotSerializer({

View File

@ -9,7 +9,9 @@ import type {
DecoratorFunction, DecoratorFunction,
StoryContext, StoryContext,
} from 'storybook/internal/types'; } from 'storybook/internal/types';
import type { SvelteComponentDoc } from 'sveltedoc-parser'; import type { SvelteComponentDoc } from 'sveltedoc-parser';
import type { SvelteRenderer, SvelteStoryResult } from '../types'; import type { SvelteRenderer, SvelteStoryResult } from '../types';
/** /**

View File

@ -1,6 +1,8 @@
import type { Mock } from 'vitest'; import type { Mock } from 'vitest';
import { beforeEach, describe, expect, it, vi, vitest } from 'vitest'; import { beforeEach, describe, expect, it, vi, vitest } from 'vitest';
import { extractComponentProps, hasDocgen } from 'storybook/internal/docs-tools'; import { extractComponentProps, hasDocgen } from 'storybook/internal/docs-tools';
import { extractArgTypes } from './extractArgTypes'; import { extractArgTypes } from './extractArgTypes';
import { import {
mockExtractComponentEventsReturn, mockExtractComponentEventsReturn,

View File

@ -6,6 +6,7 @@ import {
hasDocgen, hasDocgen,
} from 'storybook/internal/docs-tools'; } from 'storybook/internal/docs-tools';
import type { SBType, StrictArgTypes, StrictInputType } from 'storybook/internal/types'; import type { SBType, StrictArgTypes, StrictInputType } from 'storybook/internal/types';
import type { VueDocgenInfo, VueDocgenInfoEntry, VueDocgenPlugin } from '@storybook/vue3-vite'; import type { VueDocgenInfo, VueDocgenInfoEntry, VueDocgenPlugin } from '@storybook/vue3-vite';
type PropertyMetaSchema = VueDocgenInfoEntry<'vue-component-meta', 'props'>['schema']; type PropertyMetaSchema = VueDocgenInfoEntry<'vue-component-meta', 'props'>['schema'];

View File

@ -1,5 +1,7 @@
import { expect, test } from 'vitest'; import { expect, test } from 'vitest';
import { h } from 'vue'; import { h } from 'vue';
import type { SourceCodeGeneratorContext } from './sourceDecorator'; import type { SourceCodeGeneratorContext } from './sourceDecorator';
import { import {
generatePropsSourceCode, generatePropsSourceCode,

View File

@ -1,8 +1,10 @@
/* eslint-disable no-underscore-dangle */ /* eslint-disable no-underscore-dangle */
import { SNIPPET_RENDERED, SourceType } from 'storybook/internal/docs-tools'; import { SNIPPET_RENDERED, SourceType } from 'storybook/internal/docs-tools';
import { addons } from 'storybook/internal/preview-api'; import { addons } from 'storybook/internal/preview-api';
import type { VNode } from 'vue'; import type { VNode } from 'vue';
import { isVNode, watch } from 'vue'; import { isVNode, watch } from 'vue';
import type { Args, Decorator, StoryContext } from '../public-types'; import type { Args, Decorator, StoryContext } from '../public-types';
/** /**

View File

@ -1,4 +1,5 @@
import { TypeSystem } from 'storybook/internal/docs-tools'; import { TypeSystem } from 'storybook/internal/docs-tools';
import type { VueDocgenInfo } from '../../../../../frameworks/vue3-vite/src'; import type { VueDocgenInfo } from '../../../../../frameworks/vue3-vite/src';
type TestComponent = { __docgenInfo: VueDocgenInfo<'vue-component-meta'> }; type TestComponent = { __docgenInfo: VueDocgenInfo<'vue-component-meta'> };

View File

@ -1,4 +1,5 @@
import type { Args } from 'storybook/internal/types'; import type { Args } from 'storybook/internal/types';
import type { FunctionalComponent } from 'vue'; import type { FunctionalComponent } from 'vue';
/** /**

View File

@ -1,4 +1,5 @@
import { global } from '@storybook/global'; import { global } from '@storybook/global';
import { LitElement, css, html } from 'lit-element'; import { LitElement, css, html } from 'lit-element';
const { CustomEvent } = global; const { CustomEvent } = global;

View File

@ -2,7 +2,9 @@
/* eslint-disable no-underscore-dangle */ /* eslint-disable no-underscore-dangle */
import { afterEach, beforeEach, describe, expect, it } from 'vitest'; import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { global } from '@storybook/global'; import { global } from '@storybook/global';
import customElementsManifest from './__testfixtures__/custom-elements.json'; import customElementsManifest from './__testfixtures__/custom-elements.json';
import { extractArgTypes } from './custom-elements'; import { extractArgTypes } from './custom-elements';

View File

@ -1,6 +1,8 @@
import { logger } from 'storybook/internal/client-logger'; import { logger } from 'storybook/internal/client-logger';
import type { ArgTypes, InputType } from 'storybook/internal/types'; import type { ArgTypes, InputType } from 'storybook/internal/types';
import invariant from 'tiny-invariant'; import invariant from 'tiny-invariant';
import { getCustomElements, isValidComponent, isValidMetaData } from '..'; import { getCustomElements, isValidComponent, isValidMetaData } from '..';
interface TagItem { interface TagItem {

View File

@ -1,10 +1,13 @@
// @vitest-environment happy-dom // @vitest-environment happy-dom
import type { Mock } from 'vitest'; import type { Mock } from 'vitest';
import { beforeEach, describe, expect, it, vi } from 'vitest'; import { beforeEach, describe, expect, it, vi } from 'vitest';
import { SNIPPET_RENDERED } from 'storybook/internal/docs-tools'; import { SNIPPET_RENDERED } from 'storybook/internal/docs-tools';
import { addons, useEffect } from 'storybook/internal/preview-api'; import { addons, useEffect } from 'storybook/internal/preview-api';
import { html, render } from 'lit'; import { html, render } from 'lit';
import { styleMap } from 'lit/directives/style-map.js'; import { styleMap } from 'lit/directives/style-map.js';
import type { StoryContext } from '../types'; import type { StoryContext } from '../types';
import { sourceDecorator } from './sourceDecorator'; import { sourceDecorator } from './sourceDecorator';

View File

@ -2,7 +2,9 @@
import { SNIPPET_RENDERED, SourceType } from 'storybook/internal/docs-tools'; import { SNIPPET_RENDERED, SourceType } from 'storybook/internal/docs-tools';
import { addons, useEffect } from 'storybook/internal/preview-api'; import { addons, useEffect } from 'storybook/internal/preview-api';
import type { ArgsStoryFn, PartialStoryFn, StoryContext } from 'storybook/internal/types'; import type { ArgsStoryFn, PartialStoryFn, StoryContext } from 'storybook/internal/types';
import { render } from 'lit'; import { render } from 'lit';
import type { WebComponentsRenderer } from '../types'; import type { WebComponentsRenderer } from '../types';
// Taken from https://github.com/lit/lit/blob/main/packages/lit-html/src/test/test-utils/strip-markers.ts // Taken from https://github.com/lit/lit/blob/main/packages/lit-html/src/test/test-utils/strip-markers.ts

View File

@ -1,9 +1,11 @@
// @vitest-environment happy-dom // @vitest-environment happy-dom
import { describe, expect, it, vi } from 'vitest'; import { describe, expect, it, vi } from 'vitest';
import { sync as spawnSync } from 'cross-spawn'; import { sync as spawnSync } from 'cross-spawn';
import fs from 'fs'; import fs from 'fs';
import path from 'path'; import path from 'path';
import tmp from 'tmp'; import tmp from 'tmp';
import { extractArgTypesFromElements } from './custom-elements'; import { extractArgTypesFromElements } from './custom-elements';
// File hierarchy: // File hierarchy:

View File

@ -1,4 +1,5 @@
import { resolve } from 'path'; import { resolve } from 'node:path';
import { defineConfig, defineWorkspace } from 'vitest/config'; import { defineConfig, defineWorkspace } from 'vitest/config';
export default defineWorkspace([ export default defineWorkspace([