diff --git a/code/lib/manager-api/src/lib/stories.ts b/code/lib/manager-api/src/lib/stories.ts index dffc3dd45a86..d70907bc2297 100644 --- a/code/lib/manager-api/src/lib/stories.ts +++ b/code/lib/manager-api/src/lib/stories.ts @@ -215,11 +215,6 @@ export const transformStoryIndexToStoriesHash = ( startCollapsed: collapsedRoots.includes(id), // Note that this will later get appended to the previous list of children (see below) children: [childId], - - // deprecated fields - isRoot: true, - isComponent: false, - isLeaf: false, }); // Usually the last path/name pair will be displayed as a component, // *unless* there are other stories that are more deeply nested under it @@ -240,10 +235,6 @@ export const transformStoryIndexToStoriesHash = ( ...(childId && { children: [childId], }), - // deprecated fields - isRoot: false, - isComponent: true, - isLeaf: false, }); } else { acc[id] = merge((acc[id] || {}) as API_GroupEntry, { @@ -256,10 +247,6 @@ export const transformStoryIndexToStoriesHash = ( ...(childId && { children: [childId], }), - // deprecated fields - isRoot: false, - isComponent: false, - isLeaf: false, }); } }); @@ -272,12 +259,6 @@ export const transformStoryIndexToStoriesHash = ( parent: paths[paths.length - 1], renderLabel, prepared: !!item.parameters, - - // deprecated fields - kind: item.title, - isRoot: false, - isComponent: false, - isLeaf: true, } as API_DocsEntry | API_StoryEntry; return acc; diff --git a/code/lib/manager-api/src/tests/stories.test.ts b/code/lib/manager-api/src/tests/stories.test.ts index 9e1789f7188f..ba45fb688c31 100644 --- a/code/lib/manager-api/src/tests/stories.test.ts +++ b/code/lib/manager-api/src/tests/stories.test.ts @@ -1448,9 +1448,6 @@ describe('stories API', () => { ], "depth": 0, "id": "a", - "isComponent": true, - "isLeaf": false, - "isRoot": false, "name": "a", "parent": undefined, "renderLabel": undefined, @@ -1460,10 +1457,6 @@ describe('stories API', () => { "depth": 1, "id": "a--1", "importPath": "./a.ts", - "isComponent": false, - "isLeaf": true, - "isRoot": false, - "kind": "a", "name": "1", "parent": "a", "prepared": false, @@ -1475,10 +1468,6 @@ describe('stories API', () => { "depth": 1, "id": "a--2", "importPath": "./a.ts", - "isComponent": false, - "isLeaf": true, - "isRoot": false, - "kind": "a", "name": "2", "parent": "a", "prepared": false, @@ -1524,9 +1513,6 @@ describe('stories API', () => { ], "depth": 0, "id": "a", - "isComponent": true, - "isLeaf": false, - "isRoot": false, "name": "a", "parent": undefined, "renderLabel": undefined, @@ -1536,10 +1522,6 @@ describe('stories API', () => { "depth": 1, "id": "a--1", "importPath": "./a.ts", - "isComponent": false, - "isLeaf": true, - "isRoot": false, - "kind": "a", "name": "1", "parent": "a", "prepared": false, @@ -1572,9 +1554,6 @@ describe('stories API', () => { ], "depth": 0, "id": "a", - "isComponent": true, - "isLeaf": false, - "isRoot": false, "name": "a", "parent": undefined, "renderLabel": undefined, @@ -1584,10 +1563,6 @@ describe('stories API', () => { "depth": 1, "id": "a--1", "importPath": "./a.ts", - "isComponent": false, - "isLeaf": true, - "isRoot": false, - "kind": "a", "name": "1", "parent": "a", "prepared": false, @@ -1599,10 +1574,6 @@ describe('stories API', () => { "depth": 1, "id": "a--2", "importPath": "./a.ts", - "isComponent": false, - "isLeaf": true, - "isRoot": false, - "kind": "a", "name": "2", "parent": "a", "prepared": false, diff --git a/code/lib/manager-api/src/tests/url.test.js b/code/lib/manager-api/src/tests/url.test.js index a71167e7fb11..02048e903c37 100644 --- a/code/lib/manager-api/src/tests/url.test.js +++ b/code/lib/manager-api/src/tests/url.test.js @@ -157,7 +157,6 @@ describe('initModule', () => { type: 'story', args: { a: 1, b: 2 }, initialArgs: { a: 1, b: 1 }, - isLeaf: true, }), }), }); @@ -194,7 +193,7 @@ describe('initModule', () => { state: { location: {} }, navigate, fullAPI: Object.assign(fullAPI, { - getCurrentStoryData: () => ({ type: 'story', args: { a: 1 }, isLeaf: true }), + getCurrentStoryData: () => ({ type: 'story', args: { a: 1 } }), }), }); diff --git a/code/lib/types/src/modules/api-stories.ts b/code/lib/types/src/modules/api-stories.ts index b6c150242a2a..90d45a77d9ac 100644 --- a/code/lib/types/src/modules/api-stories.ts +++ b/code/lib/types/src/modules/api-stories.ts @@ -9,81 +9,42 @@ export interface API_BaseEntry { name: string; refId?: string; renderLabel?: (item: API_BaseEntry) => any; - - /** @deprecated */ - isRoot: boolean; - /** @deprecated */ - isComponent: boolean; - /** @deprecated */ - isLeaf: boolean; } export interface API_RootEntry extends API_BaseEntry { type: 'root'; startCollapsed?: boolean; children: StoryId[]; - - /** @deprecated */ - isRoot: true; - /** @deprecated */ - isComponent: false; - /** @deprecated */ - isLeaf: false; } export interface API_GroupEntry extends API_BaseEntry { type: 'group'; parent?: StoryId; children: StoryId[]; - - /** @deprecated */ - isRoot: false; - /** @deprecated */ - isComponent: false; - /** @deprecated */ - isLeaf: false; } export interface API_ComponentEntry extends API_BaseEntry { type: 'component'; parent?: StoryId; children: StoryId[]; - - /** @deprecated */ - isRoot: false; - /** @deprecated */ - isComponent: true; - /** @deprecated */ - isLeaf: false; } export interface API_DocsEntry extends API_BaseEntry { type: 'docs'; parent: StoryId; title: ComponentTitle; - /** @deprecated */ - kind: ComponentTitle; importPath: Path; tags: Tag[]; prepared: boolean; parameters?: { [parameterName: string]: any; }; - - /** @deprecated */ - isRoot: false; - /** @deprecated */ - isComponent: false; - /** @deprecated */ - isLeaf: true; } export interface API_StoryEntry extends API_BaseEntry { type: 'story'; parent: StoryId; title: ComponentTitle; - /** @deprecated */ - kind: ComponentTitle; importPath: Path; tags: Tag[]; prepared: boolean; @@ -93,13 +54,6 @@ export interface API_StoryEntry extends API_BaseEntry { args?: Args; argTypes?: ArgTypes; initialArgs?: Args; - - /** @deprecated */ - isRoot: false; - /** @deprecated */ - isComponent: false; - /** @deprecated */ - isLeaf: true; } export type API_LeafEntry = API_DocsEntry | API_StoryEntry; @@ -110,15 +64,6 @@ export type API_HashEntry = | API_DocsEntry | API_StoryEntry; -/** @deprecated */ -export type API_Root = API_RootEntry; - -/** @deprecated */ -export type API_Group = API_GroupEntry | API_ComponentEntry; - -/** @deprecated */ -export type API_Story = API_LeafEntry; - /** * The `IndexHash` is our manager-side representation of the `StoryIndex`. * We create entries in the hash not only for each story or docs entry, but diff --git a/code/ui/manager/src/components/mobile/navigation/MobileNavigation.stories.tsx b/code/ui/manager/src/components/mobile/navigation/MobileNavigation.stories.tsx index 63e48dc366da..7617574cdd4e 100644 --- a/code/ui/manager/src/components/mobile/navigation/MobileNavigation.stories.tsx +++ b/code/ui/manager/src/components/mobile/navigation/MobileNavigation.stories.tsx @@ -27,9 +27,6 @@ const mockManagerStore: any = { type: 'root', id: 'someRootId', name: 'root', - isRoot: true, - isComponent: false, - isLeaf: false, renderLabel, }, someComponentId: { @@ -37,9 +34,6 @@ const mockManagerStore: any = { id: 'someComponentId', name: 'component', parent: 'someRootId', - isRoot: false, - isComponent: true, - isLeaf: false, renderLabel, }, someStoryId: { @@ -47,9 +41,6 @@ const mockManagerStore: any = { id: 'someStoryId', name: 'story', parent: 'someComponentId', - isRoot: false, - isComponent: false, - isLeaf: true, renderLabel, }, }, @@ -110,9 +101,6 @@ export const LongStoryName: Story = { type: 'root', id: 'someRootId', name: 'someLongRootName', - isRoot: true, - isComponent: false, - isLeaf: false, renderLabel, }, someComponentId: { @@ -120,9 +108,6 @@ export const LongStoryName: Story = { id: 'someComponentId', name: 'someComponentName', parent: 'someRootId', - isRoot: false, - isComponent: true, - isLeaf: false, renderLabel, }, someStoryId: { @@ -130,9 +115,6 @@ export const LongStoryName: Story = { id: 'someStoryId', name: 'someLongStoryName', parent: 'someComponentId', - isRoot: false, - isComponent: false, - isLeaf: true, renderLabel, }, }, diff --git a/code/ui/manager/src/components/preview/Preview.mockdata.tsx b/code/ui/manager/src/components/preview/Preview.mockdata.tsx index 4bb1c7380d60..29d72ec355a2 100644 --- a/code/ui/manager/src/components/preview/Preview.mockdata.tsx +++ b/code/ui/manager/src/components/preview/Preview.mockdata.tsx @@ -39,10 +39,6 @@ export const previewProps: PreviewProps = { options: {}, }, args: {}, - kind: 'kind', - isRoot: false, - isComponent: false, - isLeaf: true, }, path: 'string', viewMode: 'story', diff --git a/code/ui/manager/src/components/sidebar/SearchResults.tsx b/code/ui/manager/src/components/sidebar/SearchResults.tsx index 3f5eb8c494d1..6a8708656d59 100644 --- a/code/ui/manager/src/components/sidebar/SearchResults.tsx +++ b/code/ui/manager/src/components/sidebar/SearchResults.tsx @@ -177,13 +177,8 @@ const Result: FC< const api = useStorybookApi(); useEffect(() => { - if (api && props.isHighlighted && item.isComponent) { - api.emit( - PRELOAD_ENTRIES, - // @ts-expect-error (TODO) - { ids: [item.isLeaf ? item.id : item.children[0]] }, - { options: { target: item.refId } } - ); + if (api && props.isHighlighted && item.type === 'component') { + api.emit(PRELOAD_ENTRIES, { ids: [item.children[0]] }, { options: { target: item.refId } }); } }, [props.isHighlighted, item]); @@ -275,9 +270,9 @@ export const SearchResults: FC<{ const currentTarget = event.currentTarget as HTMLElement; const storyId = currentTarget.getAttribute('data-id'); const refId = currentTarget.getAttribute('data-refid'); - const item = api.getData(storyId, refId === 'storybook_internal' ? undefined : refId); + const item = api.resolveStory(storyId, refId === 'storybook_internal' ? undefined : refId); - if (item?.isComponent) { + if (item?.type === 'component') { api.emit(PRELOAD_ENTRIES, { // @ts-expect-error (TODO) ids: [item.isLeaf ? item.id : item.children[0]], diff --git a/code/ui/manager/src/components/sidebar/Tree.stories.tsx b/code/ui/manager/src/components/sidebar/Tree.stories.tsx index 383468de2e40..d391d49ef053 100644 --- a/code/ui/manager/src/components/sidebar/Tree.stories.tsx +++ b/code/ui/manager/src/components/sidebar/Tree.stories.tsx @@ -87,9 +87,6 @@ export const SingleStoryComponents: Story = { type: 'component', name: 'Single', id: 'single', - isRoot: false, - isLeaf: false, - isComponent: true, parent: null, depth: 0, children: ['single--single'], @@ -100,11 +97,7 @@ export const SingleStoryComponents: Story = { id: 'single--single', title: 'Single', name: 'Single', - kind: 'single', tags: [], - isRoot: false, - isLeaf: true, - isComponent: false, prepared: true, args: {}, argTypes: {}, @@ -159,9 +152,6 @@ export const DocsOnlySingleStoryComponents = { single: { type: 'component', name: 'Single', - isRoot: false, - isLeaf: false, - isComponent: true, id: 'single', parent: null, depth: 0, @@ -172,11 +162,7 @@ export const DocsOnlySingleStoryComponents = { id: 'single--docs', title: 'Single', name: 'Single', - kind: 'single', tags: [], - isRoot: false, - isLeaf: true, - isComponent: false, prepared: true, depth: 1, parent: 'single', diff --git a/code/ui/manager/src/components/sidebar/Tree.tsx b/code/ui/manager/src/components/sidebar/Tree.tsx index db64571047bf..04c46a5b101d 100644 --- a/code/ui/manager/src/components/sidebar/Tree.tsx +++ b/code/ui/manager/src/components/sidebar/Tree.tsx @@ -317,7 +317,7 @@ const Node = React.memo(function Node({ if (item.type === 'component' && !isExpanded && isDesktop) onSelectStoryId(item.id); }} onMouseEnter={() => { - if (item.isComponent) { + if (item.type === 'component') { api.emit(PRELOAD_ENTRIES, { ids: [item.children[0]], options: { target: refId }, diff --git a/code/ui/manager/src/components/sidebar/__tests__/Sidebar.test.tsx b/code/ui/manager/src/components/sidebar/__tests__/Sidebar.test.tsx index abb84a24c980..8a0dbf309bc4 100644 --- a/code/ui/manager/src/components/sidebar/__tests__/Sidebar.test.tsx +++ b/code/ui/manager/src/components/sidebar/__tests__/Sidebar.test.tsx @@ -38,7 +38,6 @@ const generateStories = ({ title, refId }: { title: string; refId?: string }): A const docsId = `${rootId}-${hypenatedComponentName}--docs`; const storyBase: HashEntry[] = [ - // @ts-expect-error the missing fields are deprecated and replaced by the type prop { type: 'root', id: rootId, @@ -48,7 +47,6 @@ const generateStories = ({ title, refId }: { title: string; refId?: string }): A children: [componentId], startCollapsed: false, }, - // @ts-expect-error the missing fields are deprecated and replaced by the type prop { type: 'component', id: componentId, diff --git a/code/ui/manager/src/components/sidebar/useHighlighted.ts b/code/ui/manager/src/components/sidebar/useHighlighted.ts index c259969cfe30..db16ce619953 100644 --- a/code/ui/manager/src/components/sidebar/useHighlighted.ts +++ b/code/ui/manager/src/components/sidebar/useHighlighted.ts @@ -109,11 +109,10 @@ export const useHighlighted = ({ if (highlightable[nextIndex].getAttribute('data-nodetype') === 'component') { const { itemId, refId } = highlightedRef.current; - const item = api.getData(itemId, refId === 'storybook_internal' ? undefined : refId); - if (item.isComponent) { + const item = api.resolveStory(itemId, refId === 'storybook_internal' ? undefined : refId); + if (item.type === 'component') { api.emit(PRELOAD_ENTRIES, { - // @ts-expect-error (TODO) - ids: [item.isLeaf ? item.id : item.children[0]], + ids: [item.children[0]], options: { target: refId }, }); }