Skip to content

Commit

Permalink
Merge pull request #1014 from storybookjs/next
Browse files Browse the repository at this point in the history
Create a new pull request by comparing changes across two branches
  • Loading branch information
GulajavaMinistudio authored Aug 20, 2024
2 parents 7213c2d + 61b1a7b commit 84c68ea
Show file tree
Hide file tree
Showing 703 changed files with 6,668 additions and 4,530 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ jobs:
parallelism:
type: integer
executor:
class: large
class: xlarge
name: sb_playwright
parallelism: << parameters.parallelism >>
steps:
Expand Down Expand Up @@ -723,7 +723,7 @@ workflows:
requires:
- build-sandboxes
- vitest-integration:
parallelism: 4
parallelism: 5
requires:
- create-sandboxes
- bench:
Expand Down Expand Up @@ -789,7 +789,7 @@ workflows:
requires:
- build-sandboxes
- vitest-integration:
parallelism: 4
parallelism: 5
requires:
- create-sandboxes
- test-portable-stories:
Expand Down Expand Up @@ -856,7 +856,7 @@ workflows:
requires:
- build-sandboxes
- vitest-integration:
parallelism: 8
parallelism: 11
requires:
- create-sandboxes
- test-portable-stories:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ jobs:
run: |
git checkout next
git pull
git push --force origin latest-release
git push --force origin main
git push origin --force next:latest-release
git push origin --force next:main
- name: Sync CHANGELOG.md from `main` to `next`
if: steps.target.outputs.target == 'main'
Expand All @@ -174,6 +174,7 @@ jobs:
git commit -m "Update CHANGELOG.md for v${{ steps.version.outputs.current-version }} [skip ci]" || true
git push origin next
# TODO: remove this step - @JReinhold
- name: Sync version JSONs from `next-release` to `main`
if: github.ref_name == 'next-release'
working-directory: .
Expand Down
18 changes: 11 additions & 7 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 8.3.0-alpha.7

- Addon Vitest: Set screenshotFailures to false by default - [#28908](https://github.com/storybookjs/storybook/pull/28908), thanks @yannbf!
- Addon Vitest: Fix error message logic in set up file - [#28906](https://github.com/storybookjs/storybook/pull/28906), thanks @yannbf!
- Core: Add Rsbuild frameworks to known frameworks - [#28694](https://github.com/storybookjs/storybook/pull/28694), thanks @fi3ework!
- Test: Fix support for TS < 4.7 - [#28887](https://github.com/storybookjs/storybook/pull/28887), thanks @ndelangen!

## 8.3.0-alpha.6

- Addon Vitest: Add experimental vitest integration - [#28768](https://github.com/storybookjs/storybook/pull/28768), thanks @kasperpeulen!
Expand All @@ -21,7 +28,7 @@

- CSF: Allow overridding globals at the story level - [#26654](https://github.com/storybookjs/storybook/pull/26654), thanks @tmeasday!
- Core: Introduce run over play in portable stories, and revert back play changes of 8.2 - [#28764](https://github.com/storybookjs/storybook/pull/28764), thanks @kasperpeulen!
- Core: Split Storybook CLI - [#28519](https://github.com/storybookjs/storybook/pull/28519), thanks @kasperpeulen!
- Core: Split Storybook CLI - [#28519](https://github.com/storybookjs/storybook/pull/28519), thanks @kasperpeulen!
- Fix: Invariant failed: Expected package.json#version to be defined in the "undefined" package - [#28752](https://github.com/storybookjs/storybook/pull/28752), thanks @abcdmku!
- Next.js: Make RSC portable-stories compatible - [#28756](https://github.com/storybookjs/storybook/pull/28756), thanks @valentinpalkovic!
- UI: Fix collapse/expand all functionality - [#28582](https://github.com/storybookjs/storybook/pull/28582), thanks @filipemelo2002!
Expand Down Expand Up @@ -71,7 +78,6 @@

## 8.3.0-alpha.0


## 8.2.0-beta.3

- Addon Controls: Fix saving on Windows - [#28485](https://github.com/storybookjs/storybook/pull/28485), thanks @ghengeveld!
Expand Down Expand Up @@ -213,7 +219,6 @@

## 8.2.0-alpha.0


## 8.1.0-beta.1

- API: Add API access to sidebar renderLabel - [#27099](https://github.com/storybookjs/storybook/pull/27099), thanks @shilman!
Expand Down Expand Up @@ -259,7 +264,7 @@
- Portable Stories: Warn when rendering stories without cleaning up first - [#27008](https://github.com/storybookjs/storybook/pull/27008), thanks @JReinhold!
- React: Support v19 in `react-dom-shim` - [#26898](https://github.com/storybookjs/storybook/pull/26898), thanks @Tobbe!
- Test: Remove chai as dependency of @storybook/test - [#26852](https://github.com/storybookjs/storybook/pull/26852), thanks @kasperpeulen!
- Test: Support module mocking with conditional subpath imports in `package.json` - [#26688](https://github.com/storybookjs/storybook/pull/26688), thanks @kasperpeulen!
- Test: Support module mocking with conditional subpath imports in `package.json` - [#26688](https://github.com/storybookjs/storybook/pull/26688), thanks @kasperpeulen!
- UI: Fix not re-rendering tabs on state change - [#26899](https://github.com/storybookjs/storybook/pull/26899), thanks @lifeiscontent!
- UI: Fix sidebar search hanging when selecting a story in touch mode - [#26807](https://github.com/storybookjs/storybook/pull/26807), thanks @JReinhold!
- Vite: Merge assetsInclude property with Storybook default values - [#26860](https://github.com/storybookjs/storybook/pull/26860), thanks @yuemori!
Expand Down Expand Up @@ -333,11 +338,10 @@

## 8.1.0-alpha.1

- Maintenance: Fix performance regressions - [#26411](https://github.com/storybookjs/storybook/pull/26411), thanks @kasperpeulen!
- Maintenance: Fix performance regressions - [#26411](https://github.com/storybookjs/storybook/pull/26411), thanks @kasperpeulen!

## 8.1.0-alpha.0


## 8.0.0-rc.5

- CLI: Automigration fix version detection of upgrading related packages - [#26410](https://github.com/storybookjs/storybook/pull/26410), thanks @ndelangen!
Expand All @@ -348,7 +352,7 @@
- CLI: Add explicit actions to header story - [#26352](https://github.com/storybookjs/storybook/pull/26352), thanks @kasperpeulen!
- CLI: Automigration for upgrading storybook related dependencies - [#26377](https://github.com/storybookjs/storybook/pull/26377), thanks @ndelangen!
- CLI: Fix doctor compatibility check - [#26363](https://github.com/storybookjs/storybook/pull/26363), thanks @yannbf!
- CLI: Fix fn reference in preact templates - [#26384](https://github.com/storybookjs/storybook/pull/26384), thanks @kasperpeulen!
- CLI: Fix fn reference in preact templates - [#26384](https://github.com/storybookjs/storybook/pull/26384), thanks @kasperpeulen!
- CLI: Remove duplicated dependency warning - [#26385](https://github.com/storybookjs/storybook/pull/26385), thanks @yannbf!
- CLI: Vite migration link (shorter) - [#26379](https://github.com/storybookjs/storybook/pull/26379), thanks @ndelangen!
- Composition: Fix refs not loading when there's multiple - [#26356](https://github.com/storybookjs/storybook/pull/26356), thanks @ndelangen!
Expand Down
26 changes: 16 additions & 10 deletions code/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {

import { DocsContext } from '@storybook/blocks';
import { global } from '@storybook/global';
import type { Decorator, ReactRenderer } from '@storybook/react';
import type { Decorator, Loader, ReactRenderer } from '@storybook/react';

import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport';

Expand Down Expand Up @@ -95,7 +95,6 @@ const StackContainer = ({ children, layout }) => (
height: '100%',
display: 'flex',
flexDirection: 'column',
// margin: layout === 'fullscreen' ? 0 : '-1rem',
}}
>
<style dangerouslySetInnerHTML={{ __html: 'html, body, #storybook-root { height: 100%; }' }} />
Expand Down Expand Up @@ -124,15 +123,21 @@ const preview = (window as any).__STORYBOOK_PREVIEW__ as PreviewWeb<ReactRendere
const channel = (window as any).__STORYBOOK_ADDONS_CHANNEL__ as Channel;
export const loaders = [
/**
* This loader adds a DocsContext to the story, which is required for the most Blocks to work.
* A story will specify which stories they need in the index with:
* This loader adds a DocsContext to the story, which is required for the most Blocks to work. A
* story will specify which stories they need in the index with:
*
* ```ts
* parameters: {
* relativeCsfPaths: ['../stories/MyStory.stories.tsx'], // relative to the story
* relativeCsfPaths: ['../stories/MyStory.stories.tsx'], // relative to the story
* }
* ```
*
* The DocsContext will then be added via the decorator below.
*/
async ({ parameters: { relativeCsfPaths, attached = true } }) => {
if (!relativeCsfPaths) return {};
if (!relativeCsfPaths) {
return {};
}
const csfFiles = await Promise.all(
(relativeCsfPaths as string[]).map(async (blocksRelativePath) => {
const projectRelativePath = `./lib/blocks/src/${blocksRelativePath.replace(
Expand Down Expand Up @@ -185,7 +190,8 @@ export const decorators = [
<Story />
),
/**
* This decorator renders the stories side-by-side, stacked or default based on the theme switcher in the toolbar
* This decorator renders the stories side-by-side, stacked or default based on the theme switcher
* in the toolbar
*/
(StoryFn, { globals, playFunction, args, storyGlobals, parameters }) => {
let theme = globals.sb_theme;
Expand Down Expand Up @@ -267,9 +273,9 @@ export const decorators = [
}
},
/**
* This decorator shows the current state of the arg named in the
* parameters.withRawArg property, by updating the arg in the onChange function
* this also means that the arg will sync with the control panel
* This decorator shows the current state of the arg named in the parameters.withRawArg property,
* by updating the arg in the onChange function this also means that the arg will sync with the
* control panel
*
* If parameters.withRawArg is not set, this decorator will do nothing
*/
Expand Down
2 changes: 1 addition & 1 deletion code/.storybook/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default mergeConfig(
include: [
// TODO: test all core and addon stories later
// './core/**/components/**/*.{story,stories}.?(c|m)[jt]s?(x)',
'../addons/interactions/src/**/*.{story,stories}.?(c|m)[jt]s?(x)',
'../addons/**/src/**/*.{story,stories}.?(c|m)[jt]s?(x)',
],
exclude: [
...defaultExclude,
Expand Down
2 changes: 1 addition & 1 deletion code/addons/a11y/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-a11y",
"version": "8.3.0-alpha.6",
"version": "8.3.0-alpha.7",
"description": "Test component compliance with web accessibility standards",
"keywords": [
"a11y",
Expand Down
5 changes: 1 addition & 4 deletions code/addons/a11y/src/a11yRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ let activeStoryId: string | undefined;

const defaultParameters = { config: {}, options: {} };

/**
* Handle A11yContext events.
* Because the event are sent without manual check, we split calls
*/
/** Handle A11yContext events. Because the event are sent without manual check, we split calls */
const handleRequest = async (storyId: string, input: A11yParameters | null) => {
if (!input?.manual) {
await run(storyId, input ?? defaultParameters);
Expand Down
4 changes: 3 additions & 1 deletion code/addons/a11y/src/components/A11yContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export const A11yContextProvider: React.FC<React.PropsWithChildren<A11yContextPr
}
}, [active, handleClearHighlights, emit, storyEntry]);

if (!active) return null;
if (!active) {
return null;
}

return (
<A11yContext.Provider
Expand Down
2 changes: 1 addition & 1 deletion code/addons/actions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-actions",
"version": "8.3.0-alpha.6",
"version": "8.3.0-alpha.7",
"description": "Get UI feedback when an action is performed on an interactive element",
"keywords": [
"storybook",
Expand Down
8 changes: 3 additions & 5 deletions code/addons/actions/src/addArgsHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const isInInitialArgs = (name: string, initialArgs: Args) =>
typeof initialArgs[name] === 'undefined' && !(name in initialArgs);

/**
* Automatically add action args for argTypes whose name
* matches a regex, such as `^on.*` for react-style `onClick` etc.
* Automatically add action args for argTypes whose name matches a regex, such as `^on.*` for
* react-style `onClick` etc.
*/

export const inferActionsFromArgTypesRegex: ArgsEnhancer<Renderer> = (context) => {
Expand All @@ -39,9 +39,7 @@ export const inferActionsFromArgTypesRegex: ArgsEnhancer<Renderer> = (context) =
}, {} as Args);
};

/**
* Add action args for list of strings.
*/
/** Add action args for list of strings. */
export const addActionsFromArgTypes: ArgsEnhancer<Renderer> = (context) => {
const {
initialArgs,
Expand Down
6 changes: 5 additions & 1 deletion code/addons/actions/src/components/ActionLogger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export const ActionLogger = ({ actions, onClear }: ActionLoggerProps) => {

useEffect(() => {
// Scroll to bottom, when the action panel was already scrolled down
if (wasAtBottom) wrapperRef.current.scrollTop = wrapperRef.current.scrollHeight;

// Scroll to bottom, when the action panel was already scrolled down
if (wasAtBottom) {
wrapperRef.current.scrollTop = wrapperRef.current.scrollHeight;
}
}, [wasAtBottom, actions.length]);

return (
Expand Down
10 changes: 8 additions & 2 deletions code/addons/actions/src/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const logActionsWhenMockCalled: LoaderFunction = (context) => {
const {
parameters: { actions },
} = context;
if (actions?.disable) return;

if (actions?.disable) {
return;
}

if (
!subscribed &&
Expand All @@ -22,7 +25,10 @@ const logActionsWhenMockCalled: LoaderFunction = (context) => {
const onMockCall = global.__STORYBOOK_TEST_ON_MOCK_CALL__ as typeof onMockCallType;
onMockCall((mock, args) => {
const name = mock.getMockName();
if (name === 'spy') return;

if (name === 'spy') {
return;
}

// TODO: Make this a configurable API in 8.2
if (
Expand Down
5 changes: 4 additions & 1 deletion code/addons/actions/src/runtime/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import { config } from './configureActions';
type SyntheticEvent = any; // import('react').SyntheticEvent;
const findProto = (obj: unknown, callback: (proto: any) => boolean): Function | null => {
const proto = Object.getPrototypeOf(obj);
if (!proto || callback(proto)) return proto;

if (!proto || callback(proto)) {
return proto;
}
return findProto(proto, callback);
};
const isReactSyntheticEvent = (e: unknown): e is SyntheticEvent =>
Expand Down
2 changes: 1 addition & 1 deletion code/addons/backgrounds/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-backgrounds",
"version": "8.3.0-alpha.6",
"version": "8.3.0-alpha.7",
"description": "Switch backgrounds to view components in different settings",
"keywords": [
"addon",
Expand Down
2 changes: 1 addition & 1 deletion code/addons/controls/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@storybook/addon-controls",
"version": "8.3.0-alpha.6",
"version": "8.3.0-alpha.7",
"description": "Interact with component inputs dynamically in the Storybook UI",
"keywords": [
"addon",
Expand Down
11 changes: 8 additions & 3 deletions code/addons/controls/src/ControlsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,21 @@ export const ControlsPanel = ({ saveStory, createStory }: ControlsPanelProps) =>
// If the story is prepared, then show the args table
// and reset the loading states
useEffect(() => {
if (previewInitialized) setIsLoading(false);
if (previewInitialized) {
setIsLoading(false);
}
}, [previewInitialized]);

const hasControls = Object.values(rows).some((arg) => arg?.control);

const withPresetColors = Object.entries(rows).reduce((acc, [key, arg]) => {
const control = arg?.control;
if (typeof control !== 'object' || control?.type !== 'color' || control?.presetColors)

if (typeof control !== 'object' || control?.type !== 'color' || control?.presetColors) {
acc[key] = arg;
else acc[key] = { ...arg, control: { ...control, presetColors } };
} else {
acc[key] = { ...arg, control: { ...control, presetColors } };
}
return acc;
}, {} as ArgTypes);

Expand Down
9 changes: 7 additions & 2 deletions code/addons/controls/src/SaveStory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export const SaveStory = ({ saveStory, createStory, resetArgs }: SaveStoryProps)
const [errorMessage, setErrorMessage] = React.useState(null);

const onSaveStory = async () => {
if (saving) return;
if (saving) {
return;
}
setSaving(true);
await saveStory().catch(() => {});
setSaving(false);
Expand All @@ -125,7 +127,10 @@ export const SaveStory = ({ saveStory, createStory, resetArgs }: SaveStoryProps)
};
const onSubmitForm = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
if (saving) return;

if (saving) {
return;
}
try {
setErrorMessage(null);
setSaving(true);
Expand Down
Loading

0 comments on commit 84c68ea

Please sign in to comment.