react-cosmos-renderer
Advanced tools
Comparing version 6.0.3 to 6.0.4-canary.2314a55.0
@@ -7,2 +7,6 @@ import { useCreateFixtureState } from './useCreateFixtureState.js'; | ||
throw new Error('No options provided to useSelect'); | ||
if (typeof args.options[0] === 'object') { | ||
if (!args.options[0].options.length) | ||
throw new Error('No options provided to useSelect'); | ||
} | ||
useCreateFixtureState(selectName, args); | ||
@@ -9,0 +13,0 @@ const currentValue = useCurrentValue(selectName, args); |
@@ -0,3 +1,7 @@ | ||
type GroupedOptions<Option extends string> = { | ||
group: string; | ||
options: Option[]; | ||
}; | ||
export type UseSelectArgs<Option extends string> = { | ||
options: Option[]; | ||
options: Option[] | GroupedOptions<Option>[]; | ||
defaultValue?: Option; | ||
@@ -7,1 +11,2 @@ }; | ||
export declare function getDefaultSelectValue<Option extends string>({ options, defaultValue, }: UseSelectArgs<Option>): Option; | ||
export {}; |
export function getDefaultSelectValue({ options, defaultValue, }) { | ||
return typeof defaultValue === 'string' ? defaultValue : options[0]; | ||
if (typeof defaultValue === 'string') { | ||
return defaultValue; | ||
} | ||
const [firstOption] = options; | ||
if (typeof firstOption === 'object') { | ||
return firstOption.options[0]; | ||
} | ||
return firstOption; | ||
} |
@@ -28,3 +28,3 @@ import { useEffect } from 'react'; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [String(args.options), defaultValue, selectName, setFixtureState]); | ||
}, [JSON.stringify(args.options), defaultValue, selectName, setFixtureState]); | ||
} |
{ | ||
"name": "react-cosmos-renderer", | ||
"version": "6.0.3", | ||
"version": "6.0.4-canary.2314a55.0+2314a55", | ||
"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.1", | ||
"react-cosmos-core": "6.0.4-canary.2314a55.0+2314a55", | ||
"react-is": "18.2.0" | ||
}, | ||
"gitHead": "a046d36222582e9750fc23fee9eaeed146f44633" | ||
"gitHead": "2314a552ecb325a7601415058f5dac67df41fe41" | ||
} |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
71084
1505
2
1
- Removedjs-base64@3.7.7(transitive)
- Removedreact-cosmos-core@6.2.0(transitive)
- Removedreact-is@18.3.1(transitive)