react-cosmos-core 6.0.0-canary.fdbaa56.0 → 6.0.0
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/fixtureState/classState.d.ts +11 -10
- package/dist/fixtureState/classState.js +16 -25
- package/dist/fixtureState/classStateTypes.d.ts +7 -0
- package/dist/fixtureState/controlsTypes.d.ts +14 -0
- package/dist/fixtureState/controlsTypes.js +1 -0
- package/dist/fixtureState/fixtureState.d.ts +6 -0
- package/dist/fixtureState/fixtureState.js +21 -0
- package/dist/fixtureState/props.d.ts +15 -14
- package/dist/fixtureState/props.js +20 -25
- package/dist/fixtureState/propsTypes.d.ts +9 -0
- package/dist/fixtureState/propsTypes.js +1 -0
- package/dist/fixtureState/types.d.ts +2 -31
- package/dist/fixtureState/viewport.d.ts +5 -0
- package/dist/fixtureState/viewport.js +1 -0
- package/dist/fixtureTree/createFixtureTree/collapseNamedIndexes.js +6 -2
- package/dist/fixtureTree/createFixtureTree/createRawFixtureTree.js +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/playground/registerPlaygroundShortcuts.js +10 -6
- package/dist/plugin/cosmosPluginConfig.d.ts +2 -2
- package/dist/renderer/rendererConfig.d.ts +1 -4
- package/dist/utils/react/ClassStateMock.js +1 -2
- package/dist/utils/react/DelayRender.d.ts +1 -1
- package/dist/utils/react/DelayRender.js +1 -1
- package/dist/utils/state.js +1 -0
- package/package.json +5 -5
- package/dist/fixtureState/controls.d.ts +0 -2
- package/dist/fixtureState/controls.js +0 -4
- /package/dist/{utils/types.js → fixtureState/classStateTypes.js} +0 -0
- /package/dist/utils/{types.d.ts → state.d.ts} +0 -0
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { ClassStateFixtureState, ClassStateFixtureStateItem } from './classStateTypes.js';
|
|
2
|
+
import { FixtureDecoratorId, FixtureElementId, FixtureStateValues } from './types.js';
|
|
3
|
+
export declare function filterClassStateFixtureState(classStateFs: ClassStateFixtureState | undefined, decoratorId: FixtureDecoratorId): ClassStateFixtureState;
|
|
4
|
+
export declare function findClassStateFixtureStateItem(classStateFs: ClassStateFixtureState | undefined, elementId: FixtureElementId): void | ClassStateFixtureStateItem;
|
|
5
|
+
type CreateClassStateFixtureStateArgs = {
|
|
6
|
+
classStateFs: ClassStateFixtureState | undefined;
|
|
6
7
|
elementId: FixtureElementId;
|
|
7
8
|
values: FixtureStateValues;
|
|
8
9
|
componentName: string;
|
|
9
10
|
};
|
|
10
|
-
export declare function
|
|
11
|
+
export declare function createClassStateFixtureStateItem({ classStateFs, elementId, values, componentName, }: CreateClassStateFixtureStateArgs): {
|
|
11
12
|
elementId: FixtureElementId;
|
|
12
13
|
values: FixtureStateValues;
|
|
13
14
|
componentName: string;
|
|
14
15
|
}[];
|
|
15
|
-
type
|
|
16
|
-
|
|
16
|
+
type UpdateClassStateFixtureStateArgs = {
|
|
17
|
+
classStateFs: ClassStateFixtureState | undefined;
|
|
17
18
|
elementId: FixtureElementId;
|
|
18
19
|
values: FixtureStateValues;
|
|
19
20
|
};
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
21
|
+
export declare function updateClassStateFixtureStateItem({ classStateFs, elementId, values, }: UpdateClassStateFixtureStateArgs): ClassStateFixtureStateItem[];
|
|
22
|
+
export declare function removeClassStateFixtureStateItem(classStateFs: ClassStateFixtureState | undefined, elementId: FixtureElementId): ClassStateFixtureStateItem[];
|
|
22
23
|
export {};
|
|
@@ -1,40 +1,31 @@
|
|
|
1
1
|
import { find, isEqual } from 'lodash-es';
|
|
2
2
|
import { removeItemMatch, replaceOrAddItem, updateItem, } from '../utils/array.js';
|
|
3
|
-
export function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
? classState.filter(s => s.elementId.decoratorId === decoratorId)
|
|
3
|
+
export function filterClassStateFixtureState(classStateFs, decoratorId) {
|
|
4
|
+
return classStateFs
|
|
5
|
+
? classStateFs.filter(s => s.elementId.decoratorId === decoratorId)
|
|
7
6
|
: [];
|
|
8
7
|
}
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
return classState && find(classState, s => isEqual(s.elementId, elementId));
|
|
8
|
+
export function findClassStateFixtureStateItem(classStateFs, elementId) {
|
|
9
|
+
return (classStateFs && find(classStateFs, s => isEqual(s.elementId, elementId)));
|
|
12
10
|
}
|
|
13
|
-
export function
|
|
14
|
-
|
|
15
|
-
return replaceOrAddItem(classState, createClassStateMatcher(elementId), {
|
|
16
|
-
elementId,
|
|
17
|
-
values,
|
|
18
|
-
componentName,
|
|
19
|
-
});
|
|
11
|
+
export function createClassStateFixtureStateItem({ classStateFs, elementId, values, componentName, }) {
|
|
12
|
+
return replaceOrAddItem(classStateFs ?? [], createClassStateMatcher(elementId), { elementId, values, componentName });
|
|
20
13
|
}
|
|
21
|
-
export function
|
|
22
|
-
const
|
|
23
|
-
return updateItem(
|
|
24
|
-
values,
|
|
25
|
-
});
|
|
14
|
+
export function updateClassStateFixtureStateItem({ classStateFs, elementId, values, }) {
|
|
15
|
+
const item = expectClassStateItem(classStateFs, elementId);
|
|
16
|
+
return updateItem(classStateFs, item, { values });
|
|
26
17
|
}
|
|
27
|
-
export function
|
|
28
|
-
return removeItemMatch(
|
|
18
|
+
export function removeClassStateFixtureStateItem(classStateFs, elementId) {
|
|
19
|
+
return removeItemMatch(classStateFs ?? [], createClassStateMatcher(elementId));
|
|
29
20
|
}
|
|
30
21
|
function createClassStateMatcher(elementId) {
|
|
31
22
|
return (p) => isEqual(p.elementId, elementId);
|
|
32
23
|
}
|
|
33
|
-
function
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
24
|
+
function expectClassStateItem(classStateFs, elementId) {
|
|
25
|
+
const item = findClassStateFixtureStateItem(classStateFs, elementId);
|
|
26
|
+
if (!item) {
|
|
36
27
|
const elId = JSON.stringify(elementId);
|
|
37
28
|
throw new Error(`Fixture state class state missing for element "${elId}"`);
|
|
38
29
|
}
|
|
39
|
-
return
|
|
30
|
+
return item;
|
|
40
31
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FixtureElementId, FixtureStateValues } from './types.js';
|
|
2
|
+
export type ClassStateFixtureStateItem = {
|
|
3
|
+
elementId: FixtureElementId;
|
|
4
|
+
values: FixtureStateValues;
|
|
5
|
+
componentName: string;
|
|
6
|
+
};
|
|
7
|
+
export type ClassStateFixtureState = ClassStateFixtureStateItem[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FixtureStateValue } from './types.js';
|
|
2
|
+
export type StandardControlFixtureState = {
|
|
3
|
+
type: 'standard';
|
|
4
|
+
defaultValue: FixtureStateValue;
|
|
5
|
+
currentValue: FixtureStateValue;
|
|
6
|
+
};
|
|
7
|
+
export type SelectControlFixtureState = {
|
|
8
|
+
type: 'select';
|
|
9
|
+
options: string[];
|
|
10
|
+
defaultValue: string;
|
|
11
|
+
currentValue: string;
|
|
12
|
+
};
|
|
13
|
+
export type ControlFixtureState = StandardControlFixtureState | SelectControlFixtureState;
|
|
14
|
+
export type ControlsFixtureState = Record<string, ControlFixtureState>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FixtureState } from './types.js';
|
|
2
|
+
export type FixtureStateUpdater<T> = (prevState: T | undefined) => T;
|
|
3
|
+
export type FixtureStateChange<T> = T | FixtureStateUpdater<T>;
|
|
4
|
+
export declare function fixtureStateByName<T>(fixtureState: FixtureState, name: string): T | undefined;
|
|
5
|
+
export declare function updateFixtureState<T>(fixtureState: FixtureState, name: string, change: FixtureStateChange<T>): FixtureState;
|
|
6
|
+
export declare function applyFixtureStateChange<T>(prevState: T | undefined, change: FixtureStateChange<T>): T;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function fixtureStateByName(fixtureState, name) {
|
|
2
|
+
return fixtureState[name];
|
|
3
|
+
}
|
|
4
|
+
export function updateFixtureState(fixtureState, name, change) {
|
|
5
|
+
const prevFs = fixtureStateByName(fixtureState, name);
|
|
6
|
+
const nextFs = applyFixtureStateChange(prevFs, change);
|
|
7
|
+
// Avoid unnecessary state updates
|
|
8
|
+
if (nextFs === prevFs) {
|
|
9
|
+
return fixtureState;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
...fixtureState,
|
|
13
|
+
[name]: nextFs,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function applyFixtureStateChange(prevState, change) {
|
|
17
|
+
return isStateUpdater(change) ? change(prevState) : change;
|
|
18
|
+
}
|
|
19
|
+
function isStateUpdater(change) {
|
|
20
|
+
return typeof change === 'function';
|
|
21
|
+
}
|
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { PropsFixtureState, PropsFixtureStateItem, PropsFixtureStateRenderKey } from './propsTypes.js';
|
|
2
|
+
import { FixtureDecoratorId, FixtureElementId, FixtureStateValues } from './types.js';
|
|
3
|
+
export declare const DEFAULT_RENDER_KEY: PropsFixtureStateRenderKey;
|
|
4
|
+
export declare function filterPropsFixtureState(propsFs: PropsFixtureState | undefined, decoratorId: FixtureDecoratorId): PropsFixtureState;
|
|
5
|
+
export declare function findPropsFixtureStateItem(propsFs: PropsFixtureState | undefined, elementId: FixtureElementId): void | PropsFixtureStateItem;
|
|
6
|
+
type CreatePropsFixtureStateArgs = {
|
|
7
|
+
propsFs: PropsFixtureState | undefined;
|
|
7
8
|
elementId: FixtureElementId;
|
|
8
9
|
values: FixtureStateValues;
|
|
9
10
|
componentName: string;
|
|
10
11
|
};
|
|
11
|
-
export declare function
|
|
12
|
+
export declare function createPropsFixtureStateItem({ propsFs, elementId, values, componentName, }: CreatePropsFixtureStateArgs): {
|
|
12
13
|
elementId: FixtureElementId;
|
|
13
14
|
values: FixtureStateValues;
|
|
14
15
|
renderKey: number;
|
|
15
16
|
componentName: string;
|
|
16
17
|
}[];
|
|
17
|
-
type
|
|
18
|
-
|
|
18
|
+
type ResetPropsFixtureStateItemArgs = {
|
|
19
|
+
propsFs: PropsFixtureState | undefined;
|
|
19
20
|
elementId: FixtureElementId;
|
|
20
21
|
values: FixtureStateValues;
|
|
21
22
|
};
|
|
22
|
-
export declare function
|
|
23
|
-
type
|
|
24
|
-
|
|
23
|
+
export declare function resetPropsFixtureStateItem({ propsFs, elementId, values, }: ResetPropsFixtureStateItemArgs): PropsFixtureStateItem[];
|
|
24
|
+
type UpdatePropsFixtureStateItemArgs = {
|
|
25
|
+
propsFs: PropsFixtureState | undefined;
|
|
25
26
|
elementId: FixtureElementId;
|
|
26
27
|
values: FixtureStateValues;
|
|
27
28
|
};
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
29
|
+
export declare function updatePropsFixtureStateItem({ propsFs, elementId, values, }: UpdatePropsFixtureStateItemArgs): PropsFixtureStateItem[];
|
|
30
|
+
export declare function removePropsFixtureStateItem(propsFs: PropsFixtureState | undefined, elementId: FixtureElementId): PropsFixtureStateItem[];
|
|
30
31
|
export {};
|
|
@@ -1,49 +1,44 @@
|
|
|
1
1
|
import { find, isEqual } from 'lodash-es';
|
|
2
2
|
import { removeItemMatch, replaceOrAddItem, updateItem, } from '../utils/array.js';
|
|
3
3
|
export const DEFAULT_RENDER_KEY = 0;
|
|
4
|
-
export function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
? props.filter(p => p.elementId.decoratorId === decoratorId)
|
|
4
|
+
export function filterPropsFixtureState(propsFs, decoratorId) {
|
|
5
|
+
return propsFs
|
|
6
|
+
? propsFs.filter(p => p.elementId.decoratorId === decoratorId)
|
|
8
7
|
: [];
|
|
9
8
|
}
|
|
10
|
-
export function
|
|
11
|
-
|
|
12
|
-
return props && find(props, p => isEqual(p.elementId, elementId));
|
|
9
|
+
export function findPropsFixtureStateItem(propsFs, elementId) {
|
|
10
|
+
return propsFs && find(propsFs, p => isEqual(p.elementId, elementId));
|
|
13
11
|
}
|
|
14
|
-
export function
|
|
15
|
-
|
|
16
|
-
return replaceOrAddItem(props, createPropsMatcher(elementId), {
|
|
12
|
+
export function createPropsFixtureStateItem({ propsFs, elementId, values, componentName, }) {
|
|
13
|
+
return replaceOrAddItem(propsFs ?? [], createPropsMatcher(elementId), {
|
|
17
14
|
elementId,
|
|
18
15
|
values,
|
|
19
16
|
renderKey: DEFAULT_RENDER_KEY,
|
|
20
17
|
componentName,
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
|
-
export function
|
|
24
|
-
const
|
|
25
|
-
return updateItem(
|
|
20
|
+
export function resetPropsFixtureStateItem({ propsFs, elementId, values, }) {
|
|
21
|
+
const item = expectPropsItem(propsFs, elementId);
|
|
22
|
+
return updateItem(propsFs, item, {
|
|
26
23
|
values,
|
|
27
|
-
renderKey:
|
|
24
|
+
renderKey: item.renderKey + 1,
|
|
28
25
|
});
|
|
29
26
|
}
|
|
30
|
-
export function
|
|
31
|
-
const
|
|
32
|
-
return updateItem(
|
|
33
|
-
values,
|
|
34
|
-
});
|
|
27
|
+
export function updatePropsFixtureStateItem({ propsFs, elementId, values, }) {
|
|
28
|
+
const item = expectPropsItem(propsFs, elementId);
|
|
29
|
+
return updateItem(propsFs, item, { values });
|
|
35
30
|
}
|
|
36
|
-
export function
|
|
37
|
-
return removeItemMatch(
|
|
31
|
+
export function removePropsFixtureStateItem(propsFs, elementId) {
|
|
32
|
+
return removeItemMatch(propsFs ?? [], createPropsMatcher(elementId));
|
|
38
33
|
}
|
|
39
34
|
function createPropsMatcher(elementId) {
|
|
40
35
|
return (p) => isEqual(p.elementId, elementId);
|
|
41
36
|
}
|
|
42
|
-
function
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
37
|
+
function expectPropsItem(propsFs, elementId) {
|
|
38
|
+
const item = findPropsFixtureStateItem(propsFs, elementId);
|
|
39
|
+
if (!item) {
|
|
45
40
|
const elId = JSON.stringify(elementId);
|
|
46
41
|
throw new Error(`Fixture state props missing for element "${elId}"`);
|
|
47
42
|
}
|
|
48
|
-
return
|
|
43
|
+
return item;
|
|
49
44
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FixtureElementId, FixtureStateValues } from './types.js';
|
|
2
|
+
export type PropsFixtureStateRenderKey = number;
|
|
3
|
+
export type PropsFixtureStateItem = {
|
|
4
|
+
elementId: FixtureElementId;
|
|
5
|
+
values: FixtureStateValues;
|
|
6
|
+
renderKey: PropsFixtureStateRenderKey;
|
|
7
|
+
componentName: string;
|
|
8
|
+
};
|
|
9
|
+
export type PropsFixtureState = PropsFixtureStateItem[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StateUpdater } from '../utils/
|
|
1
|
+
import { StateUpdater } from '../utils/state.js';
|
|
2
2
|
export type FixtureDecoratorId = string;
|
|
3
3
|
export type FixtureElementId = {
|
|
4
4
|
decoratorId: string;
|
|
@@ -26,34 +26,5 @@ export type FixtureStateArrayValue = {
|
|
|
26
26
|
};
|
|
27
27
|
export type FixtureStateValue = FixtureStateUnserializableValue | FixtureStatePrimitiveValue | FixtureStateObjectValue | FixtureStateArrayValue;
|
|
28
28
|
export type FixtureStateValues = Record<string, FixtureStateValue>;
|
|
29
|
-
export type
|
|
30
|
-
export type FixtureStateProps = {
|
|
31
|
-
elementId: FixtureElementId;
|
|
32
|
-
values: FixtureStateValues;
|
|
33
|
-
renderKey: FixtureRenderKey;
|
|
34
|
-
componentName: string;
|
|
35
|
-
};
|
|
36
|
-
export type FixtureStateClassState = {
|
|
37
|
-
elementId: FixtureElementId;
|
|
38
|
-
values: FixtureStateValues;
|
|
39
|
-
componentName: string;
|
|
40
|
-
};
|
|
41
|
-
export type FixtureStateStandardControl = {
|
|
42
|
-
type: 'standard';
|
|
43
|
-
defaultValue: FixtureStateValue;
|
|
44
|
-
currentValue: FixtureStateValue;
|
|
45
|
-
};
|
|
46
|
-
export type FixtureStateSelectControl = {
|
|
47
|
-
type: 'select';
|
|
48
|
-
options: string[];
|
|
49
|
-
defaultValue: string;
|
|
50
|
-
currentValue: string;
|
|
51
|
-
};
|
|
52
|
-
export type FixtureStateControl = FixtureStateStandardControl | FixtureStateSelectControl;
|
|
53
|
-
export type FixtureStateControls = Record<string, FixtureStateControl>;
|
|
54
|
-
export type FixtureState = {
|
|
55
|
-
props?: FixtureStateProps[];
|
|
56
|
-
classState?: FixtureStateClassState[];
|
|
57
|
-
controls?: FixtureStateControls;
|
|
58
|
-
} & Record<string, unknown>;
|
|
29
|
+
export type FixtureState = Record<string, unknown>;
|
|
59
30
|
export type SetFixtureState = (update: StateUpdater<FixtureState>) => unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -18,9 +18,13 @@ export function collapseNamedIndexes(treeNode) {
|
|
|
18
18
|
return next();
|
|
19
19
|
const [firstGrandchildName] = grandchildNames;
|
|
20
20
|
const firstGrandchildNode = grandchildren[firstGrandchildName];
|
|
21
|
+
const isUnnamed = firstGrandchildName === 'fixture';
|
|
21
22
|
if (firstGrandchildNode.data.type !== 'fileDir' &&
|
|
22
|
-
noCaseEqual(childName, firstGrandchildName))
|
|
23
|
-
return {
|
|
23
|
+
(noCaseEqual(childName, firstGrandchildName) || isUnnamed))
|
|
24
|
+
return {
|
|
25
|
+
...newChildren,
|
|
26
|
+
[isUnnamed ? childName : firstGrandchildName]: firstGrandchildNode,
|
|
27
|
+
};
|
|
24
28
|
return next();
|
|
25
29
|
}, {}),
|
|
26
30
|
};
|
|
@@ -38,7 +38,7 @@ function parseFixturePath(fixturePath) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
function removeFixtureNameExtension(fixtureName) {
|
|
41
|
-
return fixtureName.replace(/\.(
|
|
41
|
+
return fixtureName.replace(/\.(js|jsx|ts|tsx|md|mdx)$/, '');
|
|
42
42
|
}
|
|
43
43
|
function injectNode(rootNode, parents, childName, childNode) {
|
|
44
44
|
if (parents.length === 0)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export * from './fixtureState/classState.js';
|
|
2
|
-
export * from './fixtureState/
|
|
2
|
+
export * from './fixtureState/classStateTypes.js';
|
|
3
|
+
export * from './fixtureState/controlsTypes.js';
|
|
3
4
|
export * from './fixtureState/createValues.js';
|
|
4
5
|
export * from './fixtureState/extendWithValues.js';
|
|
6
|
+
export * from './fixtureState/fixtureState.js';
|
|
5
7
|
export * from './fixtureState/props.js';
|
|
8
|
+
export * from './fixtureState/propsTypes.js';
|
|
6
9
|
export * from './fixtureState/types.js';
|
|
10
|
+
export * from './fixtureState/viewport.js';
|
|
7
11
|
export * from './fixtureTree/createFixtureTree/index.js';
|
|
8
12
|
export * from './fixtureTree/flattenFixtureTree.js';
|
|
9
13
|
export * from './fixtureTree/types.js';
|
|
@@ -32,8 +36,8 @@ export * from './utils/react/DelayRender.js';
|
|
|
32
36
|
export * from './utils/react/areNodesEqual.js';
|
|
33
37
|
export * from './utils/react/getComponentName.js';
|
|
34
38
|
export * from './utils/react/isReactElement.js';
|
|
39
|
+
export * from './utils/state.js';
|
|
35
40
|
export * from './utils/string.js';
|
|
36
41
|
export * from './utils/tree.js';
|
|
37
|
-
export * from './utils/types.js';
|
|
38
42
|
export * from './utils/uuid.js';
|
|
39
43
|
export * from './utils/window.js';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export * from './fixtureState/classState.js';
|
|
2
|
-
export * from './fixtureState/
|
|
2
|
+
export * from './fixtureState/classStateTypes.js';
|
|
3
|
+
export * from './fixtureState/controlsTypes.js';
|
|
3
4
|
export * from './fixtureState/createValues.js';
|
|
4
5
|
export * from './fixtureState/extendWithValues.js';
|
|
6
|
+
export * from './fixtureState/fixtureState.js';
|
|
5
7
|
export * from './fixtureState/props.js';
|
|
8
|
+
export * from './fixtureState/propsTypes.js';
|
|
6
9
|
export * from './fixtureState/types.js';
|
|
10
|
+
export * from './fixtureState/viewport.js';
|
|
7
11
|
export * from './fixtureTree/createFixtureTree/index.js';
|
|
8
12
|
export * from './fixtureTree/flattenFixtureTree.js';
|
|
9
13
|
export * from './fixtureTree/types.js';
|
|
@@ -32,8 +36,8 @@ export * from './utils/react/DelayRender.js';
|
|
|
32
36
|
export * from './utils/react/areNodesEqual.js';
|
|
33
37
|
export * from './utils/react/getComponentName.js';
|
|
34
38
|
export * from './utils/react/isReactElement.js';
|
|
39
|
+
export * from './utils/state.js';
|
|
35
40
|
export * from './utils/string.js';
|
|
36
41
|
export * from './utils/tree.js';
|
|
37
|
-
export * from './utils/types.js';
|
|
38
42
|
export * from './utils/uuid.js';
|
|
39
43
|
export * from './utils/window.js';
|
|
@@ -5,26 +5,30 @@ export function registerPlaygroundShortcuts(runCommand) {
|
|
|
5
5
|
runCommand(command);
|
|
6
6
|
}
|
|
7
7
|
function handleWindowKeyDown(e) {
|
|
8
|
-
|
|
8
|
+
// Allow meta key shortcuts to work when focused on input fields
|
|
9
|
+
if (isEditing() && !e.metaKey) {
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
11
12
|
const keyChar = String.fromCharCode(e.keyCode);
|
|
12
13
|
const metaKey = e.metaKey || e.ctrlKey;
|
|
13
|
-
if (keyChar === '
|
|
14
|
+
if (keyChar === 'K' && metaKey) {
|
|
14
15
|
run(e, 'searchFixtures');
|
|
15
16
|
}
|
|
16
|
-
else if (keyChar === 'L'
|
|
17
|
+
else if (keyChar === 'L') {
|
|
17
18
|
run(e, 'toggleFixtureList');
|
|
18
19
|
}
|
|
19
|
-
else if (keyChar === '
|
|
20
|
+
else if (keyChar === 'P') {
|
|
20
21
|
run(e, 'toggleControlPanel');
|
|
21
22
|
}
|
|
22
|
-
else if (keyChar === 'F'
|
|
23
|
+
else if (keyChar === 'F') {
|
|
23
24
|
run(e, 'goFullScreen');
|
|
24
25
|
}
|
|
25
|
-
else if (keyChar === 'E'
|
|
26
|
+
else if (keyChar === 'E') {
|
|
26
27
|
run(e, 'editFixture');
|
|
27
28
|
}
|
|
29
|
+
else if (keyChar === 'R') {
|
|
30
|
+
run(e, 'reloadRenderer');
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
33
|
return () => {
|
|
30
34
|
window.removeEventListener('keydown', handleWindowKeyDown);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export type RawCosmosPluginConfig = {
|
|
2
2
|
name: string;
|
|
3
|
-
ui?: string;
|
|
4
3
|
server?: string;
|
|
4
|
+
ui?: string;
|
|
5
5
|
};
|
|
6
6
|
export type CosmosPluginConfig = {
|
|
7
7
|
name: string;
|
|
8
8
|
rootDir: string;
|
|
9
|
-
ui?: string;
|
|
10
9
|
server?: string;
|
|
10
|
+
ui?: string;
|
|
11
11
|
};
|
|
12
12
|
export type UiCosmosPluginConfig = CosmosPluginConfig & {
|
|
13
13
|
ui: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isEqual } from 'lodash-es';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
// Compied from https://github.com/skidding/react-mock/blob/c33dfa1d6f0c9ce7b3eaba073618d61731a0e82e/packages/state/src/index.js
|
|
4
|
-
class ClassStateMock extends React.Component {
|
|
4
|
+
export class ClassStateMock extends React.Component {
|
|
5
5
|
static cosmosCapture = false;
|
|
6
6
|
childRef = null;
|
|
7
7
|
render() {
|
|
@@ -42,7 +42,6 @@ class ClassStateMock extends React.Component {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
export { ClassStateMock };
|
|
46
45
|
function replaceState(childRef, state, cb) {
|
|
47
46
|
// We need to unset existing state keys because React doesn't provide a
|
|
48
47
|
// replaceState method (anymore)
|
|
@@ -6,5 +6,5 @@ export function DelayRender({ children, delay }) {
|
|
|
6
6
|
const timeoutId = setTimeout(() => setRender(true), delay);
|
|
7
7
|
return () => clearTimeout(timeoutId);
|
|
8
8
|
}, [delay]);
|
|
9
|
-
return
|
|
9
|
+
return render && children;
|
|
10
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cosmos-core",
|
|
3
|
-
"version": "6.0.0
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "React Cosmos Core",
|
|
5
5
|
"repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos-core",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"js-base64": "
|
|
12
|
-
"lodash-es": "
|
|
13
|
-
"react-is": "
|
|
11
|
+
"js-base64": "3.7.6",
|
|
12
|
+
"lodash-es": "4.17.21",
|
|
13
|
+
"react-is": "18.2.0"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "db4fd8fd917598f1f16d4c291be76217436422ee"
|
|
16
16
|
}
|
|
File without changes
|
|
File without changes
|