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

Release: Prerelease 8.4.0-alpha.8 #29350

Merged
merged 75 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
216f3d6
UI WIP
shilman Feb 16, 2024
b2d4754
Merge branch 'next' into shilman/tags-filter
shilman May 19, 2024
4cff5e1
Merge branch 'next' into shilman/tags-filter
shilman Jun 13, 2024
a5f8eb1
Tag UI: state management
shilman Jun 14, 2024
be48b2b
TagsFilter: Initial implementation and stories
shilman Jun 16, 2024
eb4715e
Merge branch 'next' into shilman/tags-filter
shilman Jun 16, 2024
7b69bae
Only show filter after index has bene created
shilman Jun 16, 2024
b8af895
Add count of selected filters
shilman Jun 17, 2024
22a699b
Fix re-rendering bug
shilman Jun 17, 2024
141aeeb
TagsFilter: Don't use filtered index to generate tags
shilman Jun 17, 2024
8065a82
ignore cache & logs
shilman Oct 3, 2024
6017849
Merge branch 'next' into shilman/tags-filter
shilman Oct 5, 2024
7cdd111
remove util dependency from instrumenter and test
JReinhold Oct 9, 2024
a6b2f30
remove unused chai from core
JReinhold Oct 9, 2024
b96bcb7
Simplified design WIP
shilman Oct 11, 2024
e319c52
Fix search bar structure and styling
ghengeveld Oct 11, 2024
5529530
Tweaks
shilman Oct 11, 2024
e8a505c
Tags filter: Use built in menu components
shilman Oct 12, 2024
2b53b6e
Cleanup
shilman Oct 12, 2024
25d98e5
resolve export from import
vctqs1 Oct 12, 2024
6a517f4
add step to check decl
vctqs1 Oct 12, 2024
9faa98c
add step to check decl
vctqs1 Oct 12, 2024
1e69f85
add step to check decl
vctqs1 Oct 12, 2024
1bbb801
add step to check decl
vctqs1 Oct 12, 2024
04bcaaa
Merge branch 'next' into shilman/simple-tag-filter
shilman Oct 12, 2024
8d1fe91
Fix check
shilman Oct 12, 2024
ff6d217
Merge branch 'next' into shilman/simple-tag-filter
shilman Oct 13, 2024
763e95e
Add navigation options to applyQueryParams API
shilman Oct 13, 2024
c7603f3
Tags filter: Use built-in queryParams API
shilman Oct 13, 2024
b91e073
Merge branch 'next' into add-step-to-check-decl
vctqs1 Oct 13, 2024
812f9d9
Fix TagsFilter stories
shilman Oct 14, 2024
a088fc0
docs: drop /react slug from addons reference
flexbox Oct 14, 2024
edd29d0
Merge pull request #29345 from flexbox/docs/storybook-addons-link
jonniebigodes Oct 14, 2024
f0af3e0
Merge pull request #29310 from storybookjs/jeppe/cleanup-util-dep
JReinhold Oct 14, 2024
4b3fc7b
Fix linting
shilman Oct 15, 2024
cfbb433
Merge branch 'next' into add-step-to-check-decl
shilman Oct 15, 2024
b769cd7
Fix lint
shilman Oct 15, 2024
ceb32c2
simplify cleaning outDir on static build
JReinhold Oct 16, 2024
921c971
Merge pull request #29371 from storybookjs/fix-29358
JReinhold Oct 16, 2024
c48fd2f
Add custom tag filtering docs
shilman Oct 16, 2024
6af414a
TagsFilter: Exclude more built-in tags
shilman Oct 16, 2024
537a07d
TagsFilter: Updated filter UI WIP
shilman Oct 16, 2024
3eb65af
add svelte 5 story templates to Svelte renderer
JReinhold Oct 16, 2024
c764db1
upgrade Svelte to latest prerelease
JReinhold Oct 16, 2024
cc837c4
Remove border for now
shilman Oct 17, 2024
b0adc64
Merge branch 'next' into svelte-5-stories
shilman Oct 17, 2024
0861679
CLI: Use Svelte 5 CSF template files
shilman Oct 17, 2024
8b5972f
Fix linting
shilman Oct 17, 2024
f608e22
Clean up helper and add tests
shilman Oct 17, 2024
f1b65b0
Fix Svelte type issues
JReinhold Oct 17, 2024
47541e8
fix Svelte vitests that broke when upgrading to most recent Svelte 5 …
JReinhold Oct 17, 2024
d22b8e9
fix types in vitest config
JReinhold Oct 17, 2024
b370f6a
Merge pull request #29382 from storybookjs/svelte-5-stories
JReinhold Oct 17, 2024
ac09301
Update CHANGELOG.md for v8.3.6 [skip ci]
storybook-bot Oct 18, 2024
bb07fe6
UI: Fix refIndicator to use ReactNode for check icon
JSMike Sep 24, 2024
ec6c5e0
Review feedback
shilman Oct 19, 2024
484f930
chore: update vitest packages to 2.1.3
strozw Oct 19, 2024
9abcdf6
fix: Fix `vitest-plugin/viewports.ts` so that it is not affected by e…
strozw Oct 19, 2024
c17c443
Merge branch 'next' into shilman/simple-tag-filter
shilman Oct 19, 2024
7a90232
Fix typo
shilman Oct 19, 2024
84671f8
thanks typescript
shilman Oct 19, 2024
993d250
Merge branch 'next' into add-step-to-check-decl
shilman Oct 19, 2024
9ea2132
Merge pull request #29209 from JSMike/fix-refIndicator-icon
shilman Oct 19, 2024
97f93b7
Revert "chore: update vitest packages to 2.1.3"
strozw Oct 20, 2024
4e3bab3
refactor: Change dynamic import of `@vitest/browser/context` to be cl…
strozw Oct 20, 2024
5215f96
Merge branch 'next' into fix-vitest-plugin-for-vitest-browser-2.1.2-l…
strozw Oct 20, 2024
0284687
refactor: Revert unncessary changes
strozw Oct 20, 2024
3b4318f
Merge pull request #29344 from vctqs1/add-step-to-check-decl
shilman Oct 20, 2024
816e595
TagsFilter: Fix sidebar stories
shilman Oct 20, 2024
ec16750
Merge branch 'next' into fix-vitest-plugin-for-vitest-browser-2.1.2-l…
valentinpalkovic Oct 21, 2024
453d243
Escape xml
kasperpeulen Oct 21, 2024
61f7746
Merge pull request #29407 from strozw/fix-vitest-plugin-for-vitest-br…
valentinpalkovic Oct 21, 2024
387ca48
Merge pull request #29414 from storybookjs/kasper/escape-xml
valentinpalkovic Oct 21, 2024
f75cf71
Merge pull request #29333 from storybookjs/shilman/simple-tag-filter
shilman Oct 21, 2024
eaaeea4
Write changelog for 8.4.0-alpha.8 [skip ci]
storybook-bot Oct 21, 2024
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 8.3.6

- CLI: Install Svelte CSF v5 in Svelte5 projects - [#29323](https://github.com/storybookjs/storybook/pull/29323), thanks @shilman!
- Svelte: Add v5 stories to CLI templates - [#29382](https://github.com/storybookjs/storybook/pull/29382), thanks @JReinhold!

## 8.3.5

- CLI: Update the React Native init to include v8 dependencies - [#29273](https://github.com/storybookjs/storybook/pull/29273), thanks @dannyhw!
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 8.4.0-alpha.8

- Addon-Test: Support for `@vitest/browser` v2.1.2 - [#29407](https://github.com/storybookjs/storybook/pull/29407), thanks @strozw!
- ConfigFile: Fix `export { X }` parsing - [#29344](https://github.com/storybookjs/storybook/pull/29344), thanks @vctqs1!
- Core: Fix building Storybook deleting project root files - [#29371](https://github.com/storybookjs/storybook/pull/29371), thanks @JReinhold!
- Interactions: Escape xml of interactions errors - [#29414](https://github.com/storybookjs/storybook/pull/29414), thanks @kasperpeulen!
- Svelte: Add v5 stories to CLI templates - [#29382](https://github.com/storybookjs/storybook/pull/29382), thanks @JReinhold!
- Test: Remove unused `util` dependency - [#29310](https://github.com/storybookjs/storybook/pull/29310), thanks @JReinhold!
- UI: Fix RefIndicator to use CheckIcon instead of string - [#29209](https://github.com/storybookjs/storybook/pull/29209), thanks @JSMike!
- UI: Simple tag filtering - [#29333](https://github.com/storybookjs/storybook/pull/29333), thanks @shilman!

## 8.4.0-alpha.7

- CLI: Install Svelte CSF v5 in Svelte5 projects - [#29323](https://github.com/storybookjs/storybook/pull/29323), thanks @shilman!
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion code/addons/actions/ADVANCED.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Advanced/Legacy Actions usage

For basic usage, see the [documentation](https://storybook.js.org/docs/react/essentials/actions).
For basic usage, see the [documentation](https://storybook.js.org/docs/essentials/actions).

This document describes the pre-6.0 usage of the addon, and as such is no longer recommended (although it will be supported until at least 7.0).

Expand Down
2 changes: 1 addition & 1 deletion code/addons/actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ export default {

## Usage

The basic usage is documented in the [documentation](https://storybook.js.org/docs/react/essentials/actions). For legacy usage, see the [advanced README](./ADVANCED.md).
The basic usage is documented in the [documentation](https://storybook.js.org/docs/essentials/actions). For legacy usage, see the [advanced README](./ADVANCED.md).
2 changes: 1 addition & 1 deletion code/addons/backgrounds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export default {

## Usage

The usage is documented in the [documentation](https://storybook.js.org/docs/react/essentials/backgrounds).
The usage is documented in the [documentation](https://storybook.js.org/docs/essentials/backgrounds).
6 changes: 3 additions & 3 deletions code/addons/controls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default {

## Usage

The usage is documented in the [documentation](https://storybook.js.org/docs/react/essentials/controls).
The usage is documented in the [documentation](https://storybook.js.org/docs/essentials/controls).

## FAQs

Expand Down Expand Up @@ -92,7 +92,7 @@ export const Reflow = () => {
};
```

And again, as above, this can be rewritten using [fully custom args](https://storybook.js.org/docs/react/essentials/controls#fully-custom-args):
And again, as above, this can be rewritten using [fully custom args](https://storybook.js.org/docs/essentials/controls#fully-custom-args):

```jsx
export const Reflow = ({ count, label, ...args }) => (
Expand Down Expand Up @@ -147,7 +147,7 @@ Basic.args = {
};
```

The `argTypes` annotation (which can also be applied to individual stories if needed), gives Storybook the hints it needs to generate controls in these unsupported cases. See [control annotations](https://storybook.js.org/docs/react/essentials/controls#annotation) for a full list of control types.
The `argTypes` annotation (which can also be applied to individual stories if needed), gives Storybook the hints it needs to generate controls in these unsupported cases. See [control annotations](https://storybook.js.org/docs/essentials/controls#annotation) for a full list of control types.

It's also possible that your Storybook is misconfigured. If you think this might be the case, please search through Storybook's [Github issues](https://github.com/storybookjs/storybook/issues), and file a new issue if you don't find one that matches your use case.

Expand Down
6 changes: 3 additions & 3 deletions code/addons/docs/docs/props-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const WithControls = (args) => <MyComponent {...args} />;
<ArgsTable story="Controls" />
```

For a very detailed walkthrough of how to write stories that use controls, read the [documentation](https://storybook.js.org/docs/react/essentials/controls).
For a very detailed walkthrough of how to write stories that use controls, read the [documentation](https://storybook.js.org/docs/essentials/controls).

## Customization

Expand Down Expand Up @@ -187,7 +187,7 @@ This would render a row with a modified description, a type display with a dropd
> - `type: 'number'` is shorthand for `type: { name: 'number' }`
> - `control: 'radio'` is shorthand for `control: { type: 'radio' }`

Controls customization has an entire section in the [documentation](https://storybook.js.org/docs/react/essentials/controls#configuration).
Controls customization has an entire section in the [documentation](https://storybook.js.org/docs/essentials/controls#configuration).

Here are the possible customizations for the rest of the prop table:

Expand All @@ -200,7 +200,7 @@ Here are the possible customizations for the rest of the prop table:
| `table.type.detail` | A longer version of the type (if it's a complex type) |
| `table.defaultValue.summary` | A short version of the default value |
| `table.defaultValue.detail` | A longer version of the default value (if it's a complex value) |
| `control` | See [`addon-controls` README](https://storybook.js.org/docs/react/essentials/controls#configuration) |
| `control` | See [`addon-controls` README](https://storybook.js.org/docs/essentials/controls#configuration) |

## Reporting a bug

Expand Down
1 change: 1 addition & 0 deletions code/addons/interactions/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function createAnsiToHtmlFilter(theme: StorybookTheme) {
return new Filter({
fg: theme.color.defaultText,
bg: theme.background.content,
escapeXML: true,
});
}

Expand Down
6 changes: 4 additions & 2 deletions code/addons/test/src/vitest-plugin/viewports.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable no-underscore-dangle */
import { UnsupportedViewportDimensionError } from 'storybook/internal/preview-errors';

import { page } from '@vitest/browser/context';

import { MINIMAL_VIEWPORTS } from '../../../viewport/src/defaults';
import type { ViewportMap, ViewportStyles } from '../../../viewport/src/types';

Expand Down Expand Up @@ -50,6 +48,10 @@ const parseDimension = (value: string, dimension: 'width' | 'height') => {
export const setViewport = async (viewportsParam: ViewportsParam = {} as ViewportsParam) => {
const defaultViewport = viewportsParam.defaultViewport;

const { page } = await import('@vitest/browser/context').catch(() => ({
page: null,
}));

if (!page || !globalThis.__vitest_browser__) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions code/addons/toolbars/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {

## Usage

The usage is documented in the [documentation](https://storybook.js.org/docs/react/essentials/toolbars-and-globals).
The usage is documented in the [documentation](https://storybook.js.org/docs/essentials/toolbars-and-globals).

## FAQs

Expand All @@ -40,6 +40,6 @@ The primary difference between the two packages is that `addon-toolbars` makes u

- **Standardization**. Args are built into Storybook in 6.x. Since `addon-toolbars` is based on args, you don't need to learn any addon-specific APIs to use it.

- **Ergonomics**. Global args are easy to consume [in stories](https://storybook.js.org/docs/react/essentials/toolbars-and-globals#consuming-globals-from-within-a-story), in [Storybook Docs](https://github.com/storybookjs/storybook/tree/next/code/addons/docs), or even in other addons.
- **Ergonomics**. Global args are easy to consume [in stories](https://storybook.js.org/docs/essentials/toolbars-and-globals#consuming-globals-from-within-a-story), in [Storybook Docs](https://github.com/storybookjs/storybook/tree/next/code/addons/docs), or even in other addons.

* **Framework compatibility**. Args are completely framework-independent, so `addon-toolbars` is compatible with React, Vue 3, Angular, etc. out of the box with no framework logic needed in the addon.
2 changes: 1 addition & 1 deletion code/addons/viewport/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ You should now be able to see the viewport addon icon in the toolbar at the top

## Usage

The usage is documented in the [documentation](https://storybook.js.org/docs/react/essentials/viewport).
The usage is documented in the [documentation](https://storybook.js.org/docs/essentials/viewport).
1 change: 0 additions & 1 deletion code/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@
"boxen": "^7.1.1",
"browser-dtector": "^3.4.0",
"camelcase": "^8.0.0",
"chai": "^4.4.1",
"cli-table3": "^0.6.1",
"commander": "^12.1.0",
"comment-parser": "^1.4.1",
Expand Down
41 changes: 41 additions & 0 deletions code/core/src/cli/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,47 @@ describe('Helpers', () => {
vi.clearAllMocks();
});

describe('getVersionSafe', () => {
describe('installed', () => {
it.each([
['3.0.0', '3.0.0'],
['5.0.0-next.0', '5.0.0-next.0'],
[
'4.2.19::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fsvelte%2F-%2Fsvelte-4.2.19.tgz',
'4.2.19',
],
])('svelte %s => %s', async (svelteVersion, expectedAddonSpecifier) => {
const packageManager = {
getInstalledVersion: async (pkg: string) =>
pkg === 'svelte' ? svelteVersion : undefined,
getAllDependencies: async () => ({ svelte: `^${svelteVersion}` }),
} as any as JsPackageManager;
await expect(helpers.getVersionSafe(packageManager, 'svelte')).resolves.toBe(
expectedAddonSpecifier
);
});
});

describe('uninstalled', () => {
it.each([
['^3', '3.0.0'],
['^5.0.0-next.0', '5.0.0-next.0'],
[
'4.2.19::__archiveUrl=https%3A%2F%2Fregistry.npmjs.org%2Fsvelte%2F-%2Fsvelte-4.2.19.tgz',
'4.2.19',
],
])('svelte %s => %s', async (svelteSpecifier, expectedAddonSpecifier) => {
const packageManager = {
getInstalledVersion: async (pkg: string) => undefined,
getAllDependencies: async () => ({ svelte: svelteSpecifier }),
} as any as JsPackageManager;
await expect(helpers.getVersionSafe(packageManager, 'svelte')).resolves.toBe(
expectedAddonSpecifier
);
});
});
});

describe('copyTemplate', () => {
it(`should copy template files when directory is present`, () => {
const csfDirectory = /template-csf\/$/;
Expand Down
37 changes: 35 additions & 2 deletions code/core/src/cli/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { SupportedFrameworks, SupportedRenderers } from '@storybook/core/ty

import { findUpSync } from 'find-up';
import picocolors from 'picocolors';
import { coerce, satisfies } from 'semver';
import { coerce, major, satisfies } from 'semver';
import stripJsonComments from 'strip-json-comments';
import invariant from 'tiny-invariant';

Expand Down Expand Up @@ -173,20 +173,53 @@ export const frameworkToDefaultBuilder: Record<
'vue3-rsbuild': CommunityBuilder.Rsbuild,
};

/**
* Return the installed version of a package, or the coerced version specifier from package.json if
* it's a dependency but not installed (e.g. in a fresh project)
*/
export async function getVersionSafe(packageManager: JsPackageManager, packageName: string) {
try {
let version = await packageManager.getInstalledVersion(packageName);
if (!version) {
const deps = await packageManager.getAllDependencies();
const versionSpecifier = deps[packageName];
version = versionSpecifier ?? '';
}
const coerced = coerce(version, { includePrerelease: true });
return coerced?.toString();
} catch (err) {
// fall back to no version
}
return undefined;
}

export async function copyTemplateFiles({
packageManager,
renderer,
language,
destination,
commonAssetsDir,
}: CopyTemplateFilesOptions) {
const languageFolderMapping: Record<SupportedLanguage | 'typescript', string> = {
let languageFolderMapping: Record<SupportedLanguage | 'typescript', string> = {
// keeping this for backwards compatibility in case community packages are using it
typescript: 'ts',
[SupportedLanguage.JAVASCRIPT]: 'js',
[SupportedLanguage.TYPESCRIPT_3_8]: 'ts-3-8',
[SupportedLanguage.TYPESCRIPT_4_9]: 'ts-4-9',
};
// FIXME: remove after 9.0
if (renderer === 'svelte') {
const svelteVersion = await getVersionSafe(packageManager, 'svelte');
if (svelteVersion && major(svelteVersion) >= 5) {
languageFolderMapping = {
// keeping this for backwards compatibility in case community packages are using it
typescript: 'ts',
[SupportedLanguage.JAVASCRIPT]: 'svelte-5-js',
[SupportedLanguage.TYPESCRIPT_3_8]: 'svelte-5-ts-3-8',
[SupportedLanguage.TYPESCRIPT_4_9]: 'svelte-5-ts-4-9',
};
}
}
const templatePath = async () => {
const baseDir = await getRendererDir(packageManager, renderer);
const assetsDir = join(baseDir, 'template', 'cli');
Expand Down
18 changes: 2 additions & 16 deletions code/core/src/core-server/build-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,8 @@ export async function buildStaticStandalone(options: BuildStaticStandaloneOption
if (options.outputDir === '/') {
throw new Error("Won't remove directory '/'. Check your outputDir!");
}

try {
const outputDirFiles = await readdir(options.outputDir);
for (const file of outputDirFiles) {
await rm(file, { recursive: true, force: true });
}
} catch {
await mkdir(options.outputDir, { recursive: true });
}

if (!existsSync(options.outputDir)) {
await mkdir(options.outputDir, { recursive: true });
} else if ((await readdir(options.outputDir)).length > 0) {
await rm(options.outputDir, { recursive: true, force: true });
await mkdir(options.outputDir, { recursive: true });
}
await rm(options.outputDir, { recursive: true, force: true }).catch(() => {});
await mkdir(options.outputDir, { recursive: true });

const config = await loadMainConfig(options);
const { framework } = config;
Expand Down
Loading