Skip to content

Commit d5cc36a

Browse files
authored
Merge branch 'next' into norbert/share-channel-events
2 parents 26be096 + 01fc452 commit d5cc36a

File tree

8 files changed

+332
-9
lines changed

8 files changed

+332
-9
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 10.2.6
2+
3+
- Addon-Vitest: Skip postinstall setup when configured - [#33712](https://github.com/storybookjs/storybook/pull/33712), thanks @valentinpalkovic!
4+
- Addon-Vitest: Support vite/vitest config with deferred export - [#33755](https://github.com/storybookjs/storybook/pull/33755), thanks @valentinpalkovic!
5+
- CLI: Support addon-vitest setup when --skip-install is passed - [#33718](https://github.com/storybookjs/storybook/pull/33718), thanks @valentinpalkovic!
6+
- Manager: Update logic to use base path instead of full pathname - [#33686](https://github.com/storybookjs/storybook/pull/33686), thanks @JSMike!
7+
18
## 10.2.5
29

310
- Angular: fix --loglevel options in docs and descriptions - [#33726](https://github.com/storybookjs/storybook/pull/33726), thanks @theRuslan!

code/addons/vitest/src/updateVitestFile.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ describe('updateConfigFile', () => {
293293

294294
it('updates config which is not exported immediately', async () => {
295295
const source = babel.babelParse(
296-
await loadTemplate('vitest.config.3.2.template.ts', {
296+
await loadTemplate('vitest.config.3.2.template', {
297297
CONFIG_DIR: '.storybook',
298298
BROWSER_CONFIG: "{ provider: 'playwright' }",
299299
SETUP_FILE: '../.storybook/vitest.setup.ts',

code/core/src/components/components/Select/Select.stories.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,3 +1479,61 @@ export const ResetWithUndefinedOption = meta.story({
14791479
});
14801480
},
14811481
});
1482+
1483+
export const ShowSelectedOptionTitleTrue = meta.story({
1484+
name: 'Show Selected Option Title (prop=true)',
1485+
args: {
1486+
showSelectedOptionTitle: true,
1487+
defaultOptions: 'frog',
1488+
},
1489+
play: async ({ canvas, step }) => {
1490+
await step('Verify selected option title is shown', async () => {
1491+
const selectButton = await canvas.findByRole('button');
1492+
expect(selectButton).toHaveTextContent('Frog');
1493+
});
1494+
},
1495+
});
1496+
1497+
export const ShowSelectedOptionTitleFalse = meta.story({
1498+
name: 'Show Selected Option Title (prop=false)',
1499+
args: {
1500+
showSelectedOptionTitle: false,
1501+
defaultOptions: 'frog',
1502+
},
1503+
play: async ({ canvas, step }) => {
1504+
await step('Verify default title is shown instead of selected option', async () => {
1505+
const selectButton = await canvas.findByRole('button');
1506+
expect(selectButton).toHaveTextContent('Animal');
1507+
});
1508+
},
1509+
});
1510+
1511+
export const ShowSelectedOptionTitleFalseMulti = meta.story({
1512+
name: 'Show Selected Option Title (prop=false, multi)',
1513+
args: {
1514+
showSelectedOptionTitle: false,
1515+
multiSelect: true,
1516+
defaultOptions: ['frog', 'tadpole'],
1517+
},
1518+
play: async ({ canvas, step }) => {
1519+
await step('Verify default title is shown for multi-select', async () => {
1520+
const selectButton = await canvas.findByRole('button');
1521+
expect(selectButton).toHaveTextContent('Animal');
1522+
});
1523+
},
1524+
});
1525+
1526+
export const ShowSelectedOptionTitleTrueMulti = meta.story({
1527+
name: 'Show Selected Option Title (prop=true, multi)',
1528+
args: {
1529+
showSelectedOptionTitle: true,
1530+
multiSelect: true,
1531+
defaultOptions: ['frog'],
1532+
},
1533+
play: async ({ canvas, step }) => {
1534+
await step('Verify option count is shown for multi-select', async () => {
1535+
const selectButton = await canvas.findByRole('button');
1536+
expect(selectButton).toHaveTextContent('1');
1537+
});
1538+
},
1539+
});

code/core/src/components/components/Select/Select.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ export interface SelectProps extends Omit<
7878
onSelect?: (option: Value) => void;
7979
onDeselect?: (option: Value) => void;
8080
onChange?: (selected: Value[]) => void;
81+
/**
82+
* Legacy option for ToolbarMenuSelect. Do not use in new code. Controls whether to show the
83+
* selected option's title.
84+
*
85+
* @default true
86+
*/
87+
showSelectedOptionTitle?: boolean;
8188
}
8289

8390
function valueToId(parentId: string, { value }: InternalOption | ResetOption): string {
@@ -208,6 +215,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(
208215
onChange,
209216
tooltip,
210217
ariaLabel,
218+
showSelectedOptionTitle = true,
211219
...props
212220
},
213221
ref
@@ -522,7 +530,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(
522530
{!multiSelect && (
523531
<>
524532
{icon}
525-
{selectedOptions[0]?.title ?? children}
533+
{(showSelectedOptionTitle && selectedOptions[0]?.title) || children}
526534
</>
527535
)}
528536

code/core/src/toolbar/components/ToolbarMenuSelect.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ export const ToolbarMenuSelect: FC<ToolbarMenuProps> = ({
2929
id,
3030
name,
3131
description,
32-
toolbar: { icon: _icon, items, title: _title, preventDynamicIcon, dynamicTitle, shortcuts },
32+
toolbar: {
33+
icon: _icon,
34+
items,
35+
title: _title,
36+
preventDynamicIcon,
37+
dynamicTitle = true,
38+
shortcuts,
39+
},
3340
}) => {
3441
const api = useStorybookApi();
3542
const [globals, updateGlobals, storyGlobals] = useGlobals();
@@ -132,6 +139,7 @@ export const ToolbarMenuSelect: FC<ToolbarMenuProps> = ({
132139
onReset={resetItem ? () => updateGlobals({ [id]: resetItem?.value }) : undefined}
133140
onSelect={(selected) => updateGlobals({ [id]: selected })}
134141
icon={icon && <Icons icon={icon} __suppressDeprecationWarning={true} />}
142+
showSelectedOptionTitle={dynamicTitle}
135143
>
136144
{title}
137145
</Select>

code/lib/cli-storybook/src/codemod/helpers/story-to-csf-factory.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,62 @@ describe('stories codemod', () => {
297297
`);
298298
});
299299

300+
it('migrate cross-file story imports from `ImportedStories.Story.xyz` to `ImportedStories.Story.input.xyz`', async () => {
301+
await expect(
302+
transform(dedent`
303+
import * as BaseStories from './Button.stories';
304+
import { Primary as ImportedPrimary } from './Card.stories';
305+
306+
export default { title: 'Component' };
307+
308+
export const A = {
309+
args: BaseStories.Primary.args,
310+
};
311+
312+
export const B = {
313+
...BaseStories.Secondary,
314+
args: {
315+
...BaseStories.Secondary.args,
316+
label: 'Custom',
317+
},
318+
};
319+
320+
export const C = {
321+
args: {
322+
...ImportedPrimary.args,
323+
},
324+
};
325+
`)
326+
).resolves.toMatchInlineSnapshot(`
327+
import preview from '#.storybook/preview';
328+
329+
import * as BaseStories from './Button.stories';
330+
import { Primary as ImportedPrimary } from './Card.stories';
331+
332+
const meta = preview.meta({
333+
title: 'Component',
334+
});
335+
336+
export const A = meta.story({
337+
args: BaseStories.Primary.input.args,
338+
});
339+
340+
export const B = meta.story({
341+
...BaseStories.Secondary.input,
342+
args: {
343+
...BaseStories.Secondary.input.args,
344+
label: 'Custom',
345+
},
346+
});
347+
348+
export const C = meta.story({
349+
args: {
350+
...ImportedPrimary.input.args,
351+
},
352+
});
353+
`);
354+
});
355+
300356
it('does not migrate reused properties from disallowed list', async () => {
301357
await expect(
302358
transform(dedent`

0 commit comments

Comments
 (0)