react-cosmos-ui 6.0.0-alpha.9 → 6.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Icon.d.ts +7 -3
- package/dist/components/Icon.js +2 -2
- package/dist/components/Illustration.d.ts +1 -0
- package/dist/components/KeyBox.d.ts +1 -0
- package/dist/components/SidePanel.d.ts +1 -0
- package/dist/components/SidePanel.js +1 -1
- package/dist/components/Space.d.ts +1 -0
- package/dist/components/ValueInputTree/ExpandCollapseValues.d.ts +1 -0
- package/dist/components/ValueInputTree/ValueInput/BooleanValueInput.d.ts +1 -0
- package/dist/components/ValueInputTree/ValueInput/NullValueInput.d.ts +1 -0
- package/dist/components/ValueInputTree/ValueInput/NumberValueInput.d.ts +1 -0
- package/dist/components/ValueInputTree/ValueInput/StringValueInput.d.ts +1 -0
- package/dist/components/ValueInputTree/ValueInput/UndefinedValueInput.d.ts +1 -0
- package/dist/components/ValueInputTree/ValueInput/UnserializableValueInput.d.ts +1 -0
- package/dist/components/ValueInputTree/ValueInput/ValueInput.d.ts +1 -0
- package/dist/components/ValueInputTree/ValueInput/ValueInput.js +1 -1
- package/dist/components/ValueInputTree/ValueInputDir.d.ts +1 -0
- package/dist/components/ValueInputTree/index.d.ts +3 -3
- package/dist/components/ValueInputTree/index.js +2 -2
- package/dist/components/ValueInputTree/shared.d.ts +1 -2
- package/dist/components/ValueInputTree/shared.js +0 -4
- package/dist/components/ValueInputTree/valueTreeExpansion.js +2 -1
- package/dist/components/icons/index.d.ts +4 -6
- package/dist/components/icons/index.js +1 -1
- package/dist/components/illustrations/ArtificialIntelligence.d.ts +1 -0
- package/dist/components/illustrations/Astronaut.d.ts +1 -0
- package/dist/components/illustrations/BlankCanvas.d.ts +1 -0
- package/dist/components/inputs/NumberInput.d.ts +1 -0
- package/dist/components/inputs/Select.d.ts +1 -0
- package/dist/cosmos.loadPlugins.js +14 -10
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/playground.bundle.js +602 -599
- package/dist/playground.bundle.js.map +1 -1
- package/dist/playground.js +13 -2
- package/dist/playgroundConfig.d.ts +2 -0
- package/dist/plugins/ClassStatePanel/ClassStatePanel/ComponentClassState.d.ts +1 -0
- package/dist/plugins/ClassStatePanel/ClassStatePanel/ComponentClassState.js +3 -3
- package/dist/plugins/ControlPanel/ControlPanel.d.ts +1 -0
- package/dist/plugins/ControlPanel/ControlPanel.js +1 -1
- package/dist/plugins/ControlSelect/SelectValueInput.d.ts +1 -0
- package/dist/plugins/ControlSelect/SelectValueInput.js +1 -1
- package/dist/plugins/Core/index.js +0 -5
- package/dist/plugins/Core/spec.d.ts +0 -2
- package/dist/plugins/FixtureBookmark/BookmarkFixtureButton.d.ts +1 -0
- package/dist/plugins/FixtureBookmark/FixtureBookmarks.d.ts +5 -5
- package/dist/plugins/FixtureBookmark/FixtureBookmarks.js +10 -7
- package/dist/plugins/FixtureBookmark/index.js +7 -17
- package/dist/plugins/FixtureSearch/FixtureSearchHeader.d.ts +3 -2
- package/dist/plugins/FixtureSearch/FixtureSearchHeader.js +3 -3
- package/dist/plugins/FixtureSearch/FixtureSearchOverlay.d.ts +1 -0
- package/dist/plugins/FixtureSearch/FixtureSearchOverlay.js +2 -2
- package/dist/plugins/FixtureSearch/FixtureSearchResult.d.ts +1 -0
- package/dist/plugins/FixtureSearch/FixtureSearchShortcuts.d.ts +1 -0
- package/dist/plugins/FixtureSearch/index.js +2 -1
- package/dist/plugins/FixtureTree/BlankState.d.ts +1 -0
- package/dist/plugins/FixtureTree/BlankState.js +23 -24
- package/dist/plugins/FixtureTree/FixtureTree/FixtureButton.d.ts +2 -2
- package/dist/plugins/FixtureTree/FixtureTree/FixtureButton.js +2 -2
- package/dist/plugins/FixtureTree/FixtureTree/FixtureDir.d.ts +1 -0
- package/dist/plugins/FixtureTree/FixtureTree/FixtureTree.js +6 -8
- package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureButton.d.ts +3 -2
- package/dist/plugins/FixtureTree/FixtureTree/MultiFixtureButton.js +16 -11
- package/dist/plugins/FixtureTree/FixtureTreeContainer.d.ts +2 -2
- package/dist/plugins/FixtureTree/FixtureTreeContainer.js +1 -3
- package/dist/plugins/FixtureTree/FixtureTreeHeader.d.ts +1 -0
- package/dist/plugins/FixtureTree/index.js +1 -1
- package/dist/plugins/FixtureTree/revealFixture.js +2 -2
- package/dist/plugins/FixtureTree/shared.d.ts +1 -1
- package/dist/plugins/FullScreenButton/FullScreenButton.d.ts +1 -0
- package/dist/plugins/FullScreenButton/index.js +11 -5
- package/dist/plugins/Notifications/Notifications.d.ts +1 -0
- package/dist/plugins/PluginList/PluginList.d.ts +1 -0
- package/dist/plugins/PropsPanel/BlankState.d.ts +1 -0
- package/dist/plugins/PropsPanel/BlankState.js +14 -12
- package/dist/plugins/PropsPanel/PropsPanel/ComponentProps.d.ts +1 -0
- package/dist/plugins/PropsPanel/index.js +1 -4
- package/dist/plugins/RemoteRenderer/RemoteButton/index.d.ts +3 -2
- package/dist/plugins/RemoteRenderer/RemoteButton/index.js +5 -4
- package/dist/plugins/RemoteRenderer/index.js +2 -1
- package/dist/plugins/RendererCore/index.js +23 -5
- package/dist/plugins/RendererCore/onRouterFixtureReselect.d.ts +3 -0
- package/dist/plugins/RendererCore/onRouterFixtureReselect.js +7 -0
- package/dist/plugins/RendererCore/onRouterFixtureSelect.d.ts +3 -0
- package/dist/plugins/RendererCore/onRouterFixtureSelect.js +9 -0
- package/dist/plugins/RendererCore/onRouterFixtureUnselect.d.ts +2 -0
- package/dist/plugins/RendererCore/onRouterFixtureUnselect.js +9 -0
- package/dist/plugins/RendererCore/receiveResponse/fixtureStateChange.js +4 -4
- package/dist/plugins/RendererCore/receiveResponse/rendererReady.js +15 -21
- package/dist/plugins/RendererCore/reloadRenderer.d.ts +2 -0
- package/dist/plugins/RendererCore/reloadRenderer.js +5 -0
- package/dist/plugins/RendererCore/shared/postRequest.d.ts +1 -0
- package/dist/plugins/RendererCore/shared/postRequest.js +8 -0
- package/dist/plugins/RendererCore/spec.d.ts +6 -1
- package/dist/plugins/RendererPreview/RendererOverlay/RemoteRendererConnected.d.ts +2 -0
- package/dist/plugins/RendererPreview/RendererOverlay/RemoteRendererConnected.js +19 -0
- package/dist/plugins/RendererPreview/RendererOverlay/RemoteRendererOverlay.d.ts +6 -0
- package/dist/plugins/RendererPreview/RendererOverlay/RemoteRendererOverlay.js +6 -0
- package/dist/plugins/RendererPreview/RendererOverlay/RendererOverlay.d.ts +7 -0
- package/dist/plugins/RendererPreview/RendererOverlay/RendererOverlay.js +11 -0
- package/dist/plugins/RendererPreview/RendererOverlay/WaitingForRenderer.d.ts +2 -0
- package/dist/plugins/RendererPreview/RendererOverlay/WaitingForRenderer.js +65 -0
- package/dist/plugins/RendererPreview/RendererOverlay/rendererOverlayShared.d.ts +3 -0
- package/dist/plugins/RendererPreview/RendererOverlay/rendererOverlayShared.js +27 -0
- package/dist/plugins/RendererPreview/RendererPreview.d.ts +3 -0
- package/dist/plugins/RendererPreview/RendererPreview.js +10 -3
- package/dist/plugins/RendererPreview/handleRendererRequests.js +7 -6
- package/dist/plugins/RendererPreview/handleWindowMessages.js +10 -1
- package/dist/plugins/RendererPreview/index.js +7 -13
- package/dist/plugins/RendererPreview/shared.d.ts +0 -6
- package/dist/plugins/RendererPreview/spec.d.ts +0 -3
- package/dist/plugins/ResponsivePreview/ResponsivePreview/{Header.d.ts → ResponsiveHeader.d.ts} +1 -1
- package/dist/plugins/ResponsivePreview/ResponsivePreview/{Header.js → ResponsiveHeader.js} +2 -2
- package/dist/plugins/ResponsivePreview/ResponsivePreview/ResponsivePreview.d.ts +1 -2
- package/dist/plugins/ResponsivePreview/ResponsivePreview/ResponsivePreview.js +4 -4
- package/dist/plugins/ResponsivePreview/ToggleButton/index.d.ts +1 -0
- package/dist/plugins/ResponsivePreview/index.js +5 -6
- package/dist/plugins/ResponsivePreview/shared.js +13 -10
- package/dist/plugins/Root/GlobalHeader.d.ts +2 -4
- package/dist/plugins/Root/GlobalHeader.js +2 -23
- package/dist/plugins/{ContentOverlay/shared.d.ts → Root/HomeOverlay/ContentOverlay.d.ts} +1 -4
- package/dist/plugins/{ContentOverlay/shared.js → Root/HomeOverlay/ContentOverlay.js} +3 -3
- package/dist/plugins/Root/HomeOverlay/HomeOverlay.d.ts +8 -0
- package/dist/plugins/Root/HomeOverlay/HomeOverlay.js +6 -0
- package/dist/plugins/{ContentOverlay → Root/HomeOverlay}/KeyShortcut.d.ts +1 -0
- package/dist/plugins/{ContentOverlay → Root/HomeOverlay}/KeyShortcut.js +2 -2
- package/dist/plugins/{ContentOverlay → Root/HomeOverlay}/NoFixtureSelected.d.ts +1 -0
- package/dist/plugins/{ContentOverlay → Root/HomeOverlay}/NoFixtureSelected.js +5 -5
- package/dist/plugins/{ContentOverlay → Root/HomeOverlay}/WelcomeCosmos.d.ts +1 -0
- package/dist/plugins/Root/HomeOverlay/WelcomeCosmos.js +159 -0
- package/dist/plugins/Root/HomeOverlay/welcomeDismiss.d.ts +7 -0
- package/dist/plugins/{ContentOverlay → Root/HomeOverlay}/welcomeDismiss.js +6 -4
- package/dist/plugins/Root/RendererHeader.d.ts +1 -1
- package/dist/plugins/Root/RendererHeader.js +13 -5
- package/dist/plugins/Root/Root.d.ts +7 -5
- package/dist/plugins/Root/Root.js +9 -10
- package/dist/plugins/Root/ToggleNavButton.d.ts +1 -0
- package/dist/plugins/Root/index.js +6 -5
- package/dist/plugins/Root/panelOpen.js +0 -5
- package/dist/plugins/Router/index.js +23 -11
- package/dist/plugins/Router/spec.d.ts +5 -3
- package/dist/plugins/StandardControl/storage.d.ts +1 -1
- package/dist/plugins/pluginEntry.d.ts +0 -1
- package/dist/plugins/pluginEntry.js +0 -1
- package/dist/shared/fixtureTree.d.ts +1 -2
- package/dist/shared/fixtureTree.js +5 -10
- package/dist/shared/url.d.ts +6 -5
- package/dist/shared/url.js +6 -6
- package/dist/slots/ControlActionSlot.d.ts +1 -0
- package/dist/slots/ControlSlot.d.ts +1 -0
- package/dist/slots/FixtureActionSlot.d.ts +3 -2
- package/dist/slots/NavRowSlot.d.ts +1 -0
- package/dist/slots/RendererActionSlot.d.ts +1 -0
- package/dist/slots/SidePanelRowSlot.d.ts +1 -0
- package/dist/testHelpers/pluginMocks.d.ts +8 -7
- package/dist/testHelpers/pluginMocks.js +5 -3
- package/package.json +4 -4
- package/dist/plugins/ContentOverlay/ContentOverlay.d.ts +0 -13
- package/dist/plugins/ContentOverlay/ContentOverlay.js +0 -34
- package/dist/plugins/ContentOverlay/RendererNotResponding.d.ts +0 -1
- package/dist/plugins/ContentOverlay/RendererNotResponding.js +0 -109
- package/dist/plugins/ContentOverlay/WelcomeCosmos.js +0 -158
- package/dist/plugins/ContentOverlay/cosmos.decorator.d.ts +0 -5
- package/dist/plugins/ContentOverlay/cosmos.decorator.js +0 -13
- package/dist/plugins/ContentOverlay/index.d.ts +0 -2
- package/dist/plugins/ContentOverlay/index.js +0 -19
- package/dist/plugins/ContentOverlay/spec.d.ts +0 -3
- package/dist/plugins/ContentOverlay/spec.js +0 -1
- package/dist/plugins/ContentOverlay/welcomeDismiss.d.ts +0 -7
- package/dist/plugins/RendererCore/isValidFixtureSelected.d.ts +0 -2
- package/dist/plugins/RendererCore/isValidFixtureSelected.js +0 -16
- package/dist/plugins/RendererCore/onRouterFixtureChange.d.ts +0 -3
- package/dist/plugins/RendererCore/onRouterFixtureChange.js +0 -18
- package/dist/plugins/RendererPreview/checkRendererStatus.d.ts +0 -2
- package/dist/plugins/RendererPreview/checkRendererStatus.js +0 -31
package/dist/playground.js
CHANGED
|
@@ -28,9 +28,20 @@ export default async function mount({ playgroundConfig, pluginConfigs, }) {
|
|
|
28
28
|
}
|
|
29
29
|
async function loadPluginScript(scriptPath) {
|
|
30
30
|
console.log(`[Cosmos] Loading plugin script at ${scriptPath}`);
|
|
31
|
-
//
|
|
31
|
+
// Paths are absolute with the dev server, and relative with static
|
|
32
|
+
// exports. Why aren't they always relative? Because in dev mode
|
|
33
|
+
// the plugins could be loaded from folders outside the project rootDir,
|
|
34
|
+
// for example when using a monorepo. In that case relative paths would
|
|
35
|
+
// have to contain "../" segments, which are not allowed in URLs, and
|
|
36
|
+
// for this reason we pass full paths when using the dev server.
|
|
32
37
|
const normalizedPath = scriptPath.startsWith('/')
|
|
33
38
|
? scriptPath
|
|
34
39
|
: `/${scriptPath}`;
|
|
35
|
-
|
|
40
|
+
try {
|
|
41
|
+
await import(/* webpackIgnore: true */ `./_plugin${normalizedPath}`);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
console.log(`[Cosmos] Failed to load plugin script ${scriptPath}`);
|
|
45
|
+
console.log(err);
|
|
46
|
+
}
|
|
36
47
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CosmosPluginConfig } from 'react-cosmos-core';
|
|
2
2
|
import { CoreSpec } from './plugins/Core/spec.js';
|
|
3
|
+
import { RendererCoreSpec } from './plugins/RendererCore/spec.js';
|
|
3
4
|
export type PlaygroundConfig = {
|
|
4
5
|
core: CoreSpec['config'];
|
|
6
|
+
rendererCore: RendererCoreSpec['config'];
|
|
5
7
|
[pluginName: string]: {};
|
|
6
8
|
};
|
|
7
9
|
export type PlaygroundMountArgs = {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isEqual } from 'lodash-es';
|
|
2
2
|
import React, { useCallback } from 'react';
|
|
3
3
|
import { updateFixtureStateClassState, } from 'react-cosmos-core';
|
|
4
|
-
import { IconButton32 } from '../../../components/buttons/index.js';
|
|
5
|
-
import { RotateCcwIcon } from '../../../components/icons/index.js';
|
|
6
4
|
import { SidePanelActions, SidePanelBody, SidePanelContainer, SidePanelHeader, SidePanelTitle, } from '../../../components/SidePanel.js';
|
|
7
5
|
import { ExpandCollapseValues } from '../../../components/ValueInputTree/ExpandCollapseValues.js';
|
|
8
|
-
import {
|
|
6
|
+
import { ValueInputTree, stringifyElementId, } from '../../../components/ValueInputTree/index.js';
|
|
7
|
+
import { IconButton32 } from '../../../components/buttons/index.js';
|
|
8
|
+
import { RotateCcwIcon } from '../../../components/icons/index.js';
|
|
9
9
|
import { createClassStateFsUpdater } from './shared.js';
|
|
10
10
|
export function ComponentClassState({ fsClassState, fixtureExpansion, onFixtureStateChange, onElementExpansionChange, }) {
|
|
11
11
|
const { componentName, elementId, values } = fsClassState;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isEqual } from 'lodash-es';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { SidePanelActions, SidePanelBody, SidePanelContainer, SidePanelHeader, SidePanelTitle, } from '../../components/SidePanel.js';
|
|
3
4
|
import { IconButton32 } from '../../components/buttons/index.js';
|
|
4
5
|
import { RotateCcwIcon } from '../../components/icons/index.js';
|
|
5
|
-
import { SidePanelActions, SidePanelBody, SidePanelContainer, SidePanelHeader, SidePanelTitle, } from '../../components/SidePanel.js';
|
|
6
6
|
import { ControlActionSlot } from '../../slots/ControlActionSlot.js';
|
|
7
7
|
import { ControlSlot } from '../../slots/ControlSlot.js';
|
|
8
8
|
export function ControlPanel({ fixtureState, controlActionOrder, onFixtureStateChange, }) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Select } from '../../components/inputs/Select.js';
|
|
3
2
|
import { Label, ValueDataContainer, ValueInputContainer, } from '../../components/ValueInputTree/ValueInput/shared.js';
|
|
3
|
+
import { Select } from '../../components/inputs/Select.js';
|
|
4
4
|
import { lightBlue } from '../../style/colors.js';
|
|
5
5
|
export function SelectValueInput({ name, control, onChange }) {
|
|
6
6
|
const { options, currentValue } = control;
|
|
@@ -11,7 +11,6 @@ const { onLoad, register } = createPlugin({
|
|
|
11
11
|
fixturesDir: '__fixtures__',
|
|
12
12
|
fixtureFileSuffix: 'fixture',
|
|
13
13
|
devServerOn: false,
|
|
14
|
-
webRendererUrl: null,
|
|
15
14
|
},
|
|
16
15
|
methods: {
|
|
17
16
|
registerCommands,
|
|
@@ -19,7 +18,6 @@ const { onLoad, register } = createPlugin({
|
|
|
19
18
|
getProjectId,
|
|
20
19
|
getFixtureFileVars,
|
|
21
20
|
isDevServerOn,
|
|
22
|
-
getWebRendererUrl,
|
|
23
21
|
},
|
|
24
22
|
});
|
|
25
23
|
export { register };
|
|
@@ -63,6 +61,3 @@ function getFixtureFileVars({ getConfig }) {
|
|
|
63
61
|
function isDevServerOn({ getConfig }) {
|
|
64
62
|
return getConfig().devServerOn;
|
|
65
63
|
}
|
|
66
|
-
function getWebRendererUrl({ getConfig }) {
|
|
67
|
-
return getConfig().webRendererUrl;
|
|
68
|
-
}
|
|
@@ -6,7 +6,6 @@ export type CoreSpec = {
|
|
|
6
6
|
fixturesDir: string;
|
|
7
7
|
fixtureFileSuffix: string;
|
|
8
8
|
devServerOn: boolean;
|
|
9
|
-
webRendererUrl: null | string;
|
|
10
9
|
};
|
|
11
10
|
state: {
|
|
12
11
|
commands: Commands;
|
|
@@ -20,6 +19,5 @@ export type CoreSpec = {
|
|
|
20
19
|
fixtureFileSuffix: string;
|
|
21
20
|
};
|
|
22
21
|
isDevServerOn(): boolean;
|
|
23
|
-
getWebRendererUrl(): null | string;
|
|
24
22
|
};
|
|
25
23
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FixtureId, FlatFixtureTree, FlatFixtureTreeItem } from 'react-cosmos-core';
|
|
2
3
|
type Props = {
|
|
3
|
-
|
|
4
|
-
bookmarks: FixtureId[];
|
|
4
|
+
bookmarks: FlatFixtureTree;
|
|
5
5
|
selectedFixtureId: FixtureId | null;
|
|
6
6
|
onFixtureSelect: (fixtureId: FixtureId) => void;
|
|
7
|
-
onBookmarkDelete: (
|
|
7
|
+
onBookmarkDelete: (fixtureItem: FlatFixtureTreeItem) => void;
|
|
8
8
|
};
|
|
9
|
-
export declare function FixtureBookmarks({
|
|
9
|
+
export declare function FixtureBookmarks({ bookmarks, selectedFixtureId, onFixtureSelect, onBookmarkDelete, }: Props): JSX.Element | null;
|
|
10
10
|
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { isEqual } from 'lodash-es';
|
|
1
|
+
import { isEqual, sortBy } from 'lodash-es';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { stringifyFixtureId, } from 'react-cosmos-core';
|
|
3
4
|
import styled from 'styled-components';
|
|
4
5
|
import { XIcon } from '../../components/icons/index.js';
|
|
5
|
-
import { stringifyFixtureId } from '../../components/ValueInputTree/index.js';
|
|
6
6
|
import { createRelativePlaygroundUrl } from '../../shared/url.js';
|
|
7
7
|
import { blue, grey128, grey224, grey24, grey248, grey32, grey8, selectedColors, white10, } from '../../style/colors.js';
|
|
8
8
|
import { quick } from '../../style/vars.js';
|
|
9
|
-
export function FixtureBookmarks({
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
9
|
+
export function FixtureBookmarks({ bookmarks, selectedFixtureId, onFixtureSelect, onBookmarkDelete, }) {
|
|
10
|
+
const sortedBookmarks = useSortedBookmarks(bookmarks);
|
|
11
|
+
if (!sortedBookmarks.length)
|
|
12
12
|
return null;
|
|
13
13
|
return (React.createElement(Container, null,
|
|
14
14
|
React.createElement(Header, null,
|
|
15
15
|
React.createElement(HeaderTitle, null, "Bookmarks")),
|
|
16
|
-
|
|
16
|
+
sortedBookmarks.map(fixtureItem => {
|
|
17
17
|
const { fixtureId } = fixtureItem;
|
|
18
18
|
const itemKey = stringifyFixtureId(fixtureId);
|
|
19
19
|
const selected = isEqual(fixtureId, selectedFixtureId);
|
|
@@ -28,11 +28,14 @@ export function FixtureBookmarks({ fixtureItems, bookmarks, selectedFixtureId, o
|
|
|
28
28
|
}
|
|
29
29
|
return (React.createElement(ListItem, { key: itemKey, selected: selected },
|
|
30
30
|
React.createElement(FixtureLink, { href: createRelativePlaygroundUrl({ fixtureId }), selected: selected, onClick: handleClick }, getFixtureName(fixtureItem)),
|
|
31
|
-
React.createElement(DeleteButton, { onClick: () => onBookmarkDelete(
|
|
31
|
+
React.createElement(DeleteButton, { onClick: () => onBookmarkDelete(fixtureItem) },
|
|
32
32
|
React.createElement(DeleteIconContainer, null,
|
|
33
33
|
React.createElement(XIcon, null)))));
|
|
34
34
|
})));
|
|
35
35
|
}
|
|
36
|
+
function useSortedBookmarks(bookmarks) {
|
|
37
|
+
return React.useMemo(() => sortBy(bookmarks, b => b.fixtureId.path, b => b.fixtureId.name), [bookmarks]);
|
|
38
|
+
}
|
|
36
39
|
function openAnchorInNewTab(anchorEl) {
|
|
37
40
|
// Allow users to cmd+click to open fixtures in new tab
|
|
38
41
|
window.open(anchorEl.href, '_blank');
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isEqual } from 'lodash-es';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { createFixtureTree, flattenFixtureTree, } from 'react-cosmos-core';
|
|
4
3
|
import { createPlugin } from 'react-plugin';
|
|
5
4
|
import { BookmarkFixtureButton } from './BookmarkFixtureButton.js';
|
|
6
5
|
import { FixtureBookmarks } from './FixtureBookmarks.js';
|
|
@@ -8,20 +7,19 @@ const { namedPlug, register } = createPlugin({
|
|
|
8
7
|
name: 'fixtureBookmark',
|
|
9
8
|
});
|
|
10
9
|
namedPlug('fixtureAction', 'bookmarkFixture', ({ pluginContext, slotProps }) => {
|
|
11
|
-
const {
|
|
10
|
+
const { fixtureItem } = slotProps;
|
|
12
11
|
const { getBookmarks, setBookmarks } = getStorageApi(pluginContext);
|
|
13
12
|
const bookmarks = getBookmarks();
|
|
14
|
-
const selected = bookmarks.some(b => isEqual(b,
|
|
13
|
+
const selected = bookmarks.some(b => isEqual(b, fixtureItem));
|
|
15
14
|
return (React.createElement(BookmarkFixtureButton, { selected: selected, onClick: () => setBookmarks(selected
|
|
16
|
-
? bookmarks.filter(b => !isEqual(b,
|
|
17
|
-
: [...bookmarks,
|
|
15
|
+
? bookmarks.filter(b => !isEqual(b, fixtureItem))
|
|
16
|
+
: [...bookmarks, fixtureItem]) }));
|
|
18
17
|
});
|
|
19
18
|
namedPlug('navRow', 'fixtureBookmarks', ({ pluginContext }) => {
|
|
20
19
|
const router = pluginContext.getMethodsOf('router');
|
|
21
20
|
const { getBookmarks, setBookmarks } = getStorageApi(pluginContext);
|
|
22
21
|
const bookmarks = getBookmarks();
|
|
23
|
-
|
|
24
|
-
return (React.createElement(FixtureBookmarks, { fixtureItems: fixtureItems, bookmarks: bookmarks, selectedFixtureId: router.getSelectedFixtureId(), onFixtureSelect: router.selectFixture, onBookmarkDelete: fixtureId => setBookmarks(bookmarks.filter(b => !isEqual(b, fixtureId))) }));
|
|
22
|
+
return (React.createElement(FixtureBookmarks, { bookmarks: bookmarks, selectedFixtureId: router.getSelectedFixtureId(), onFixtureSelect: router.selectFixture, onBookmarkDelete: fixtureItem => setBookmarks(bookmarks.filter(b => !isEqual(b, fixtureItem))) }));
|
|
25
23
|
});
|
|
26
24
|
export { register };
|
|
27
25
|
if (process.env.NODE_ENV !== 'test')
|
|
@@ -29,18 +27,10 @@ if (process.env.NODE_ENV !== 'test')
|
|
|
29
27
|
function getStorageApi(pluginContext) {
|
|
30
28
|
const storage = pluginContext.getMethodsOf('storage');
|
|
31
29
|
function getBookmarks() {
|
|
32
|
-
return storage.getItem('fixtureBookmarks') || [];
|
|
30
|
+
return storage.getItem('fixtureBookmarks.1') || [];
|
|
33
31
|
}
|
|
34
32
|
function setBookmarks(bookmarks) {
|
|
35
|
-
storage.setItem('fixtureBookmarks', bookmarks);
|
|
33
|
+
storage.setItem('fixtureBookmarks.1', bookmarks);
|
|
36
34
|
}
|
|
37
35
|
return { getBookmarks, setBookmarks };
|
|
38
36
|
}
|
|
39
|
-
function useFixtureItems(pluginContext) {
|
|
40
|
-
const { getMethodsOf } = pluginContext;
|
|
41
|
-
const core = getMethodsOf('core');
|
|
42
|
-
const { fixturesDir, fixtureFileSuffix } = core.getFixtureFileVars();
|
|
43
|
-
const rendererCore = getMethodsOf('rendererCore');
|
|
44
|
-
const fixtures = rendererCore.getFixtures();
|
|
45
|
-
return React.useMemo(() => flattenFixtureTree(createFixtureTree({ fixturesDir, fixtureFileSuffix, fixtures })), [fixtureFileSuffix, fixtures, fixturesDir]);
|
|
46
|
-
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
type Props = {
|
|
2
|
-
|
|
3
|
+
fixtureSelected: boolean;
|
|
3
4
|
onOpen: () => unknown;
|
|
4
5
|
onCloseNav: () => unknown;
|
|
5
6
|
};
|
|
6
|
-
export declare function FixtureSearchHeader({
|
|
7
|
+
export declare function FixtureSearchHeader({ fixtureSelected, onOpen, onCloseNav, }: Props): JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import { KeyBox } from '../../components/KeyBox.js';
|
|
3
4
|
import { IconButton32 } from '../../components/buttons/index.js';
|
|
4
5
|
import { ChevronLeftIcon, SearchIcon } from '../../components/icons/index.js';
|
|
5
|
-
import { KeyBox } from '../../components/KeyBox.js';
|
|
6
6
|
import { blue, grey160, grey32, white10 } from '../../style/colors.js';
|
|
7
|
-
export function FixtureSearchHeader({
|
|
7
|
+
export function FixtureSearchHeader({ fixtureSelected, onOpen, onCloseNav, }) {
|
|
8
8
|
return (React.createElement(Container, null,
|
|
9
9
|
React.createElement(SearchButton, { onClick: onOpen },
|
|
10
10
|
React.createElement(SearchIconContainer, null,
|
|
@@ -13,7 +13,7 @@ export function FixtureSearchHeader({ validFixtureSelected, onOpen, onCloseNav,
|
|
|
13
13
|
React.createElement(KeyBox, { value: '⌘', bgColor: white10, textColor: grey160, size: 20 }),
|
|
14
14
|
React.createElement(KeyBox, { value: 'P', bgColor: white10, textColor: grey160, size: 20 })),
|
|
15
15
|
React.createElement(NavButtonContainer, null,
|
|
16
|
-
React.createElement(IconButton32, { icon: React.createElement(ChevronLeftIcon, null), title: "Hide fixture list", disabled: !
|
|
16
|
+
React.createElement(IconButton32, { icon: React.createElement(ChevronLeftIcon, null), title: "Hide fixture list", disabled: !fixtureSelected, selected: false, onClick: onCloseNav }))));
|
|
17
17
|
}
|
|
18
18
|
const Container = styled.div `
|
|
19
19
|
display: flex;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { filter } from 'fuzzaldrin-plus';
|
|
2
2
|
import { isEqual } from 'lodash-es';
|
|
3
3
|
import React, { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { KEY_DOWN, KEY_ENTER, KEY_ESC, KEY_FWD_SLASH, KEY_TAB, KEY_UP, createFixtureTree, flattenFixtureTree, } from 'react-cosmos-core';
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import { HelpCircleIcon, SearchIcon } from '../../components/icons/index.js';
|
|
7
7
|
import { black60, grey128, grey160, grey176, grey208, grey224, grey248, grey64, } from '../../style/colors.js';
|
|
@@ -176,7 +176,7 @@ export function FixtureSearchOverlay({ searchText, fixturesDir, fixtureFileSuffi
|
|
|
176
176
|
React.createElement(FixtureSearchShortcuts, null)),
|
|
177
177
|
React.createElement(ResultsViewport, null,
|
|
178
178
|
React.createElement(ResultsContainer, null,
|
|
179
|
-
matchingFixturePaths.map(cleanFixturePath => (React.createElement(FixtureSearchResult, { key: cleanFixturePath, cleanFixturePath: cleanFixturePath, fixtureItem: fixtureItems[cleanFixturePath], active: cleanFixturePath === activeFixturePath, onSelect: onSelect }))),
|
|
179
|
+
matchingFixturePaths.map(cleanFixturePath => fixtureItems[cleanFixturePath] && (React.createElement(FixtureSearchResult, { key: cleanFixturePath, cleanFixturePath: cleanFixturePath, fixtureItem: fixtureItems[cleanFixturePath], active: cleanFixturePath === activeFixturePath, onSelect: onSelect }))),
|
|
180
180
|
matchingFixturePaths.length === 0 && (React.createElement(NoResults, null, "No results")))))));
|
|
181
181
|
}
|
|
182
182
|
function findFixturePath(fixtureItems, fixtureId) {
|
|
@@ -18,6 +18,7 @@ onLoad(pluginContext => {
|
|
|
18
18
|
});
|
|
19
19
|
namedPlug('navRow', 'fixtureSearch', ({ pluginContext, slotProps }) => {
|
|
20
20
|
const { getMethodsOf } = pluginContext;
|
|
21
|
+
const router = getMethodsOf('router');
|
|
21
22
|
const rendererCore = getMethodsOf('rendererCore');
|
|
22
23
|
const fixtures = rendererCore.getFixtures();
|
|
23
24
|
const onOpen = useOnOpen(pluginContext);
|
|
@@ -26,7 +27,7 @@ namedPlug('navRow', 'fixtureSearch', ({ pluginContext, slotProps }) => {
|
|
|
26
27
|
if (Object.keys(fixtures).length === 0) {
|
|
27
28
|
return null;
|
|
28
29
|
}
|
|
29
|
-
return (React.createElement(FixtureSearchHeader, {
|
|
30
|
+
return (React.createElement(FixtureSearchHeader, { fixtureSelected: router.getSelectedFixtureId() !== null, onOpen: onOpen, onCloseNav: onCloseNav }));
|
|
30
31
|
});
|
|
31
32
|
namedPlug('global', 'fixtureSearch', ({ pluginContext }) => {
|
|
32
33
|
const { getState, getMethodsOf } = pluginContext;
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { DelayRender } from 'react-cosmos-core';
|
|
2
3
|
import styled from 'styled-components';
|
|
3
4
|
import { FileIcon } from '../../components/icons/index.js';
|
|
4
5
|
import { grey160, grey224, grey32, grey64, grey8 } from '../../style/colors.js';
|
|
5
6
|
export function BlankState({ fixturesDir, fixtureFileSuffix }) {
|
|
6
|
-
return (React.createElement(
|
|
7
|
-
React.createElement(
|
|
8
|
-
React.createElement(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
React.createElement(
|
|
14
|
-
React.createElement("
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"will ",
|
|
29
|
-
React.createElement(NoWrap, null, "appear here"))))));
|
|
7
|
+
return (React.createElement(DelayRender, { delay: 500 },
|
|
8
|
+
React.createElement(Container, { "data-testid": "nav-blank-state" },
|
|
9
|
+
React.createElement(IconContainer, null,
|
|
10
|
+
React.createElement(FileIcon, null)),
|
|
11
|
+
React.createElement(Title, null,
|
|
12
|
+
"No component ",
|
|
13
|
+
React.createElement(NoWrap, null, "fixtures found")),
|
|
14
|
+
React.createElement(Description, null,
|
|
15
|
+
React.createElement("ol", null,
|
|
16
|
+
React.createElement("li", null,
|
|
17
|
+
"Place fixture files under ",
|
|
18
|
+
React.createElement("code", null, fixturesDir),
|
|
19
|
+
" dirs or add the ",
|
|
20
|
+
React.createElement("code", null,
|
|
21
|
+
".",
|
|
22
|
+
fixtureFileSuffix),
|
|
23
|
+
" suffix to",
|
|
24
|
+
' ',
|
|
25
|
+
React.createElement(NoWrap, null, "their name")),
|
|
26
|
+
React.createElement("li", null,
|
|
27
|
+
"Default exports from your fixtures (any React element or component) will ",
|
|
28
|
+
React.createElement(NoWrap, null, "appear here")))))));
|
|
30
29
|
}
|
|
31
30
|
const Container = styled.div `
|
|
32
31
|
padding: 16px 24px;
|
|
@@ -2,11 +2,11 @@ import { RefObject } from 'react';
|
|
|
2
2
|
import { FixtureId } from 'react-cosmos-core';
|
|
3
3
|
type Props = {
|
|
4
4
|
name: string;
|
|
5
|
-
|
|
5
|
+
fixturePath: string;
|
|
6
6
|
indentLevel: number;
|
|
7
7
|
selected: boolean;
|
|
8
8
|
selectedRef: RefObject<HTMLElement>;
|
|
9
9
|
onSelect: (fixtureId: FixtureId) => unknown;
|
|
10
10
|
};
|
|
11
|
-
export declare function FixtureButton({ name,
|
|
11
|
+
export declare function FixtureButton({ name, fixturePath, indentLevel, selected, selectedRef, onSelect, }: Props): JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -3,8 +3,8 @@ import styled from 'styled-components';
|
|
|
3
3
|
import { quick } from '../../../style/vars.js';
|
|
4
4
|
import { FixtureLink } from './FixtureLink.js';
|
|
5
5
|
import { FixtureTreeItem } from './FixtureTreeItem.js';
|
|
6
|
-
export function FixtureButton({ name,
|
|
7
|
-
return (React.createElement(FixtureLink, { fixtureId:
|
|
6
|
+
export function FixtureButton({ name, fixturePath, indentLevel, selected, selectedRef, onSelect, }) {
|
|
7
|
+
return (React.createElement(FixtureLink, { fixtureId: { path: fixturePath }, onSelect: onSelect },
|
|
8
8
|
React.createElement(FixtureTreeItem, { ref: selected ? selectedRef : undefined, indentLevel: indentLevel, selected: selected },
|
|
9
9
|
React.createElement(Name, null, name))));
|
|
10
10
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { isEqual } from 'lodash-es';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import styled from 'styled-components';
|
|
4
3
|
import { TreeView } from '../../../components/TreeView.js';
|
|
5
|
-
import {
|
|
4
|
+
import { fixtureTreeNodeContainsFixtureId } from '../../../shared/fixtureTree.js';
|
|
6
5
|
import { grey32 } from '../../../style/colors.js';
|
|
7
6
|
import { FixtureButton } from './FixtureButton.js';
|
|
8
7
|
import { FixtureDir } from './FixtureDir.js';
|
|
@@ -12,19 +11,18 @@ export const FixtureTree = React.memo(function FixtureTree({ rootNode, selectedF
|
|
|
12
11
|
React.createElement(TreeView, { node: rootNode, expansion: expansion, setExpansion: setExpansion, renderNode: ({ node, name, parents, expanded, onToggle }) => {
|
|
13
12
|
const { data, children } = node;
|
|
14
13
|
if (data.type === 'fixture') {
|
|
15
|
-
const selected =
|
|
16
|
-
return (React.createElement(FixtureButton, { name: name,
|
|
14
|
+
const selected = selectedFixtureId?.path === data.path;
|
|
15
|
+
return (React.createElement(FixtureButton, { name: name, fixturePath: data.path, indentLevel: parents.length, selected: selected, selectedRef: selectedRef, onSelect: onSelect }));
|
|
17
16
|
}
|
|
18
17
|
if (data.type === 'multiFixture') {
|
|
19
|
-
const selected = selectedFixtureId
|
|
20
|
-
|
|
21
|
-
return (React.createElement(MultiFixtureButton, { name: name, fixtureIds: data.fixtureIds, indentLevel: parents.length, selected: selected, selectedFixtureId: selectedFixtureId, selectedRef: selectedRef, onSelect: onSelect }));
|
|
18
|
+
const selected = selectedFixtureId?.path === data.path;
|
|
19
|
+
return (React.createElement(MultiFixtureButton, { name: name, fixturePath: data.path, fixtureNames: data.names, indentLevel: parents.length, selected: selected, selectedFixtureId: selectedFixtureId, selectedRef: selectedRef, onSelect: onSelect }));
|
|
22
20
|
}
|
|
23
21
|
if (!children)
|
|
24
22
|
return null;
|
|
25
23
|
const selected = !expanded &&
|
|
26
24
|
selectedFixtureId !== null &&
|
|
27
|
-
|
|
25
|
+
fixtureTreeNodeContainsFixtureId(node, selectedFixtureId);
|
|
28
26
|
return (React.createElement(FixtureDir, { name: name, indentLevel: parents.length, expanded: expanded, selected: selected, onToggle: onToggle }));
|
|
29
27
|
} })));
|
|
30
28
|
});
|
|
@@ -2,12 +2,13 @@ import { RefObject } from 'react';
|
|
|
2
2
|
import { FixtureId } from 'react-cosmos-core';
|
|
3
3
|
type Props = {
|
|
4
4
|
name: string;
|
|
5
|
-
|
|
5
|
+
fixturePath: string;
|
|
6
|
+
fixtureNames: string[];
|
|
6
7
|
indentLevel: number;
|
|
7
8
|
selected: boolean;
|
|
8
9
|
selectedFixtureId: null | FixtureId;
|
|
9
10
|
selectedRef: RefObject<HTMLElement>;
|
|
10
11
|
onSelect: (fixtureId: FixtureId) => unknown;
|
|
11
12
|
};
|
|
12
|
-
export declare function MultiFixtureButton({ name,
|
|
13
|
+
export declare function MultiFixtureButton({ name, fixturePath, fixtureNames, indentLevel, selected, selectedFixtureId, selectedRef, onSelect, }: Props): JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { isEqual } from 'lodash-es';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import styled from 'styled-components';
|
|
4
3
|
import { grey8 } from '../../../style/colors.js';
|
|
5
4
|
import { FixtureLink } from './FixtureLink.js';
|
|
6
5
|
import { FixtureTreeItem } from './FixtureTreeItem.js';
|
|
7
6
|
import { MultiFixtureChildButton } from './MultiFixtureChildButton.js';
|
|
8
|
-
export function MultiFixtureButton({ name,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return (React.createElement(FixtureLink, { fixtureId:
|
|
7
|
+
export function MultiFixtureButton({ name, fixturePath, fixtureNames, indentLevel, selected, selectedFixtureId, selectedRef, onSelect, }) {
|
|
8
|
+
if (!selected) {
|
|
9
|
+
const [firstFixtureName] = fixtureNames;
|
|
10
|
+
const fixtureId = firstFixtureName
|
|
11
|
+
? { path: fixturePath, name: firstFixtureName }
|
|
12
|
+
: { path: fixturePath };
|
|
13
|
+
return (React.createElement(FixtureLink, { fixtureId: fixtureId, onSelect: onSelect },
|
|
15
14
|
React.createElement(FixtureTreeItem, { indentLevel: indentLevel, selected: false },
|
|
16
15
|
React.createElement(Name, null, name),
|
|
17
16
|
React.createElement(Count, null, fixtureNames.length))));
|
|
17
|
+
}
|
|
18
18
|
return (React.createElement(React.Fragment, null,
|
|
19
19
|
React.createElement(FixtureTreeItem, { indentLevel: indentLevel, selected: true },
|
|
20
20
|
React.createElement(Name, null, name),
|
|
21
21
|
React.createElement(Count, null, fixtureNames.length)),
|
|
22
|
-
fixtureNames.map(fixtureName => {
|
|
23
|
-
const fixtureId =
|
|
24
|
-
|
|
22
|
+
fixtureNames.map((fixtureName, index) => {
|
|
23
|
+
const fixtureId = { path: fixturePath, name: fixtureName };
|
|
24
|
+
// Select first child when only the path of a multi fixture is selected
|
|
25
|
+
const childSelected = selectedFixtureId !== null &&
|
|
26
|
+
selectedFixtureId.path === fixturePath &&
|
|
27
|
+
(selectedFixtureId.name === undefined
|
|
28
|
+
? index === 0
|
|
29
|
+
: fixtureName === selectedFixtureId.name);
|
|
25
30
|
return (React.createElement(MultiFixtureChildButton, { key: fixtureName, name: fixtureName, fixtureId: fixtureId, indentLevel: indentLevel + 1, selected: childSelected, selectedRef: selectedRef, onSelect: onSelect }));
|
|
26
31
|
}),
|
|
27
32
|
React.createElement(FooterPadding, null)));
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { FixtureId, FixtureList } from 'react-cosmos-core';
|
|
2
3
|
import { TreeExpansion } from '../../shared/treeExpansion.js';
|
|
3
4
|
type Props = {
|
|
4
5
|
fixturesDir: string;
|
|
5
6
|
fixtureFileSuffix: string;
|
|
6
7
|
selectedFixtureId: null | FixtureId;
|
|
7
|
-
rendererConnected: boolean;
|
|
8
8
|
fixtures: FixtureList;
|
|
9
9
|
expansion: TreeExpansion;
|
|
10
10
|
selectFixture: (fixtureId: FixtureId) => void;
|
|
11
11
|
setExpansion: (expansion: TreeExpansion) => unknown;
|
|
12
12
|
};
|
|
13
|
-
export declare function FixtureTreeContainer({ fixturesDir, fixtureFileSuffix, selectedFixtureId,
|
|
13
|
+
export declare function FixtureTreeContainer({ fixturesDir, fixtureFileSuffix, selectedFixtureId, fixtures, expansion, selectFixture, setExpansion, }: Props): JSX.Element;
|
|
14
14
|
export {};
|
|
@@ -6,11 +6,9 @@ import { BlankState } from './BlankState.js';
|
|
|
6
6
|
import { FixtureTree } from './FixtureTree/FixtureTree.js';
|
|
7
7
|
import { FixtureTreeHeader } from './FixtureTreeHeader.js';
|
|
8
8
|
import { useScrollToSelected } from './useScrollToSelected.js';
|
|
9
|
-
export function FixtureTreeContainer({ fixturesDir, fixtureFileSuffix, selectedFixtureId,
|
|
9
|
+
export function FixtureTreeContainer({ fixturesDir, fixtureFileSuffix, selectedFixtureId, fixtures, expansion, selectFixture, setExpansion, }) {
|
|
10
10
|
const rootNode = useMemo(() => createFixtureTree({ fixtures, fixturesDir, fixtureFileSuffix }), [fixtures, fixturesDir, fixtureFileSuffix]);
|
|
11
11
|
const { containerRef, selectedRef } = useScrollToSelected(selectedFixtureId);
|
|
12
|
-
if (!rendererConnected)
|
|
13
|
-
return React.createElement(TreeContainer, null);
|
|
14
12
|
if (Object.keys(fixtures).length === 0) {
|
|
15
13
|
return (React.createElement(TreeContainer, null,
|
|
16
14
|
React.createElement(BlankState, { fixturesDir: fixturesDir, fixtureFileSuffix: fixtureFileSuffix })));
|
|
@@ -18,7 +18,7 @@ namedPlug('navRow', 'fixtureTree', ({ pluginContext }) => {
|
|
|
18
18
|
const rendererCore = getMethodsOf('rendererCore');
|
|
19
19
|
const expansion = getTreeExpansion(storage);
|
|
20
20
|
const setExpansionMemo = useCallback((newExpansion) => setTreeExpansion(storage, newExpansion), [storage]);
|
|
21
|
-
return (React.createElement(FixtureTreeContainer, { fixturesDir: fixturesDir, fixtureFileSuffix: fixtureFileSuffix, selectedFixtureId: router.getSelectedFixtureId(),
|
|
21
|
+
return (React.createElement(FixtureTreeContainer, { fixturesDir: fixturesDir, fixtureFileSuffix: fixtureFileSuffix, selectedFixtureId: router.getSelectedFixtureId(), fixtures: rendererCore.getFixtures(), expansion: expansion, selectFixture: router.selectFixture, setExpansion: setExpansionMemo }));
|
|
22
22
|
});
|
|
23
23
|
export { register };
|
|
24
24
|
if (process.env.NODE_ENV !== 'test')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createFixtureTree, } from 'react-cosmos-core';
|
|
2
|
-
import {
|
|
2
|
+
import { fixtureTreeNodeContainsFixtureId } from '../../shared/fixtureTree.js';
|
|
3
3
|
import { getTreeExpansion, setTreeExpansion, } from './shared.js';
|
|
4
4
|
export function revealFixture(context, fixtureId) {
|
|
5
5
|
const { getMethodsOf } = context;
|
|
@@ -32,7 +32,7 @@ function findDirPath({ data, children }, fixtureId, parents = []) {
|
|
|
32
32
|
for (let childName of childNames) {
|
|
33
33
|
const childNode = children[childName];
|
|
34
34
|
if (childNode.data.type !== 'fileDir') {
|
|
35
|
-
if (
|
|
35
|
+
if (fixtureTreeNodeContainsFixtureId(childNode, fixtureId))
|
|
36
36
|
return parents;
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
@@ -3,5 +3,5 @@ import { TreeExpansion } from '../../shared/treeExpansion.js';
|
|
|
3
3
|
import { StorageSpec } from '../Storage/spec.js';
|
|
4
4
|
import { FixtureTreeSpec } from './spec.js';
|
|
5
5
|
export type FixtureTreeContext = PluginContext<FixtureTreeSpec>;
|
|
6
|
-
export declare function getTreeExpansion({ getItem }: StorageSpec['methods']):
|
|
6
|
+
export declare function getTreeExpansion({ getItem }: StorageSpec['methods']): {};
|
|
7
7
|
export declare function setTreeExpansion({ setItem }: StorageSpec['methods'], treeExpansion: TreeExpansion): void;
|