react-cosmos-renderer
Advanced tools
Comparing version 6.0.4-canary.2314a55.0 to 6.0.4-canary.2806ea7.0
@@ -1,7 +0,6 @@ | ||
import { FixtureStateData } from 'react-cosmos-core'; | ||
import { SetValue } from './shared.js'; | ||
type Opts<T extends FixtureStateData> = { | ||
/// <reference types="react" /> | ||
type Opts<T> = { | ||
defaultValue: T; | ||
}; | ||
export declare function useValue<T extends FixtureStateData>(inputName: string, { defaultValue }: Opts<T>): [T, SetValue<T>]; | ||
export declare function useValue<T>(inputName: string, { defaultValue }: Opts<T>): [T, React.Dispatch<React.SetStateAction<T>>]; | ||
export {}; |
@@ -1,2 +0,1 @@ | ||
import { FixtureStateData } from 'react-cosmos-core'; | ||
export declare function useCreateFixtureState(inputName: string, defaultValue: FixtureStateData): void; | ||
export declare function useCreateFixtureState(inputName: string, defaultValue: unknown): void; |
@@ -1,2 +0,1 @@ | ||
import { FixtureStateData } from 'react-cosmos-core'; | ||
export declare function useCurrentValue<T extends FixtureStateData>(inputName: string, defaultValue: T): T; | ||
export declare function useCurrentValue<T>(inputName: string, defaultValue: T): T; |
@@ -1,2 +0,2 @@ | ||
import { extendWithValue, } from 'react-cosmos-core'; | ||
import { extendWithValue } from 'react-cosmos-core'; | ||
import { useFixtureState } from '../useFixtureState.js'; | ||
@@ -7,3 +7,3 @@ export function useCurrentValue(inputName, defaultValue) { | ||
return controlFs && controlFs.type === 'standard' | ||
? // Types of fixture state values cannot be guaranteed at read time, which | ||
? // Types of fixture state values cannot be guaranteed at run time, which | ||
// means that tampering with the fixture state can cause runtime errors | ||
@@ -10,0 +10,0 @@ extendWithValue(defaultValue, controlFs.currentValue) |
@@ -1,3 +0,2 @@ | ||
import { FixtureStateData } from 'react-cosmos-core'; | ||
import { SetValue } from './shared.js'; | ||
export declare function useSetValue<T extends FixtureStateData>(inputName: string, defaultValue: T): SetValue<T>; | ||
import React from 'react'; | ||
export declare function useSetValue<T>(inputName: string, defaultValue: T): React.Dispatch<React.SetStateAction<T>>; |
@@ -8,9 +8,11 @@ import React from 'react'; | ||
setFixtureState(prevFs => { | ||
const currentValue = typeof stateChange === 'function' | ||
? stateChange( | ||
// Types of fixture state values cannot be guaranteed at read | ||
// time, which means that tampering with the fixture state can | ||
// cause runtime errors | ||
getCurrentValueFromFixtureState(prevFs, inputName, defaultValue)) | ||
: stateChange; | ||
// Types of fixture state values cannot be guaranteed at run | ||
// time, which means that tampering with the fixture state can | ||
// cause runtime errors | ||
function getNewState() { | ||
if (typeof stateChange !== 'function') | ||
return stateChange; | ||
const stateUpdater = stateChange; | ||
return stateUpdater(getCurrentValueFromFixtureState(prevFs, inputName, defaultValue)); | ||
} | ||
return { | ||
@@ -21,3 +23,3 @@ ...prevFs, | ||
defaultValue: createValue(defaultValue), | ||
currentValue: createValue(currentValue), | ||
currentValue: createValue(getNewState()), | ||
}, | ||
@@ -24,0 +26,0 @@ }; |
{ | ||
"name": "react-cosmos-renderer", | ||
"version": "6.0.4-canary.2314a55.0+2314a55", | ||
"version": "6.0.4-canary.2806ea7.0+2806ea7", | ||
"description": "React Cosmos Renderer", | ||
@@ -15,6 +15,6 @@ "repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos-renderer", | ||
"lodash-es": "4.17.21", | ||
"react-cosmos-core": "6.0.4-canary.2314a55.0+2314a55", | ||
"react-cosmos-core": "6.0.4-canary.2806ea7.0+2806ea7", | ||
"react-is": "18.2.0" | ||
}, | ||
"gitHead": "2314a552ecb325a7601415058f5dac67df41fe41" | ||
"gitHead": "2806ea711b679d1f47726cdc1dc48065e7a3c1ee" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
70684
106
1499