@storybook/csf
Advanced tools
Comparing version 0.0.2--canary.6aca495.0 to 0.0.2--canary.835a408.0
export declare const sanitize: (string: string) => string; | ||
export declare const toId: (kind: string, name: string) => string; | ||
export declare const toId: (kind: string, name?: string | undefined) => string; | ||
export declare const storyNameFromExport: (key: string) => string; | ||
@@ -4,0 +4,0 @@ declare type StoryDescriptor = string[] | RegExp; |
@@ -72,3 +72,3 @@ "use strict"; | ||
var toId = function toId(kind, name) { | ||
return "".concat(sanitizeSafe(kind, 'kind'), "--").concat(sanitizeSafe(name, 'name')); | ||
return "".concat(sanitizeSafe(kind, 'kind')).concat(name ? "--".concat(sanitizeSafe(name, 'name')) : ''); | ||
}; | ||
@@ -75,0 +75,0 @@ /** |
@@ -18,4 +18,5 @@ "use strict"; | ||
describe('toId', function () { | ||
[// name, kind, story, output | ||
['handles simple cases', 'kind', 'story', 'kind--story'], ['handles basic substitution', 'a b$c?d😀e', '1-2:3', 'a-b-c-d😀e--1-2-3'], ['handles runs of non-url chars', 'a?&*b', 'story', 'a-b--story'], ['removes non-url chars from start and end', '?ab-', 'story', 'ab--story'], ['downcases', 'KIND', 'STORY', 'kind--story'], ['non-latin', 'Кнопки', 'нормальный', 'кнопки--нормальный'], ['korean', 'kind', '바보 (babo)', 'kind--바보-babo'], ['all punctuation', 'kind', 'unicorns,’–—―′¿`"<>()!.!!!{}[]%^&$*#&', 'kind--unicorns']].forEach(function (_ref) { | ||
var testCases = [// name, kind, story, output | ||
['handles simple cases', 'kind', 'story', 'kind--story'], ['handles kind without story', 'kind', undefined, 'kind'], ['handles basic substitution', 'a b$c?d😀e', '1-2:3', 'a-b-c-d😀e--1-2-3'], ['handles runs of non-url chars', 'a?&*b', 'story', 'a-b--story'], ['removes non-url chars from start and end', '?ab-', 'story', 'ab--story'], ['downcases', 'KIND', 'STORY', 'kind--story'], ['non-latin', 'Кнопки', 'нормальный', 'кнопки--нормальный'], ['korean', 'kind', '바보 (babo)', 'kind--바보-babo'], ['all punctuation', 'kind', 'unicorns,’–—―′¿`"<>()!.!!!{}[]%^&$*#&', 'kind--unicorns']]; | ||
testCases.forEach(function (_ref) { | ||
var _ref2 = _slicedToArray(_ref, 4), | ||
@@ -46,6 +47,6 @@ name = _ref2[0], | ||
}); | ||
it('does not allow empty story', function () { | ||
it('allows empty story', function () { | ||
expect(function () { | ||
return (0, _.toId)('kind', ''); | ||
}).toThrow("Invalid name '', must include alphanumeric characters"); | ||
}).not.toThrow(); | ||
}); | ||
@@ -52,0 +53,0 @@ }); |
@@ -74,11 +74,9 @@ import { SBType, SBScalarType } from './SBType'; | ||
}; | ||
export declare type LoaderFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (c: StoryContextForLoaders<TFramework, TArgs>) => Promise<Record<string, any>>; | ||
export declare type LoaderFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContextForLoaders<TFramework, TArgs>) => Promise<Record<string, any>>; | ||
export declare type StoryContext<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContextForLoaders<TFramework, TArgs> & { | ||
loaded: Record<string, any>; | ||
}; | ||
export declare type StoryContextForPlayFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContext<TFramework, TArgs> & { | ||
abortSignal: AbortSignal; | ||
canvas?: HTMLElement; | ||
canvasElement: HTMLElement; | ||
}; | ||
export declare type PlayFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = () => Promise<void> | void; | ||
export declare type PlayFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContext<TFramework, TArgs>) => Promise<void> | void; | ||
export declare type PartialStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (update?: StoryContextUpdate<TArgs>) => TFramework['storyResult']; | ||
@@ -91,16 +89,15 @@ export declare type LegacyStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContext<TFramework, TArgs>) => TFramework['storyResult']; | ||
export declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = { | ||
decorators?: DecoratorFunction<TFramework, TArgs>[]; | ||
decorators?: DecoratorFunction<TFramework, Args>[]; | ||
parameters?: Parameters; | ||
args?: Partial<TArgs>; | ||
argTypes?: Partial<ArgTypes<TArgs>>; | ||
loaders?: LoaderFunction<TFramework, TArgs>[]; | ||
render?: ArgsStoryFn<TFramework, TArgs>; | ||
play?: PlayFunction<TFramework, TArgs>; | ||
loaders?: LoaderFunction<TFramework, Args>[]; | ||
render?: ArgsStoryFn<TFramework, Args>; | ||
}; | ||
export declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = BaseAnnotations<TFramework, TArgs> & { | ||
argsEnhancers?: ArgsEnhancer<TFramework, TArgs>[]; | ||
argTypesEnhancers?: ArgTypesEnhancer<TFramework, TArgs>[]; | ||
argsEnhancers?: ArgsEnhancer<TFramework, Args>[]; | ||
argTypesEnhancers?: ArgTypesEnhancer<TFramework, Args>[]; | ||
globals?: Globals; | ||
globalTypes?: GlobalTypes; | ||
applyDecorators?: DecoratorApplicator<TFramework, TArgs>; | ||
applyDecorators?: DecoratorApplicator<TFramework, Args>; | ||
}; | ||
@@ -119,2 +116,3 @@ declare type StoryDescriptor = string[] | RegExp; | ||
storyName?: StoryName; | ||
play?: PlayFunction<TFramework, TArgs>; | ||
story?: Omit<StoryAnnotations<TFramework, TArgs>, 'story'>; | ||
@@ -121,0 +119,0 @@ }; |
{ | ||
"name": "@storybook/csf", | ||
"version": "0.0.2--canary.6aca495.0", | ||
"version": "0.0.2--canary.835a408.0", | ||
"description": "Component Story Format (CSF) utilities", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -33,3 +33,3 @@ <img src="https://user-images.githubusercontent.com/42671/89649515-eceafc00-d88e-11ea-9728-5ef80cdf8462.png" width="321px" height="236px" /> | ||
**Tools:** [Storybook](https://storybook.js.org), [WebComponents.dev](https://webcomponents.dev), [RedwoodJS](https://redwoodjs.com/), [UXPin](https://www.uxpin.com/) | ||
**Tools:** [Storybook](https://storybook.js.org), [WebComponents.dev](https://webcomponents.dev), [Components.studio](https://components.studio), [RedwoodJS](https://redwoodjs.com/), [UXPin](https://www.uxpin.com/) | ||
@@ -36,0 +36,0 @@ **Compatible with:** [Jest](https://jestjs.io/), [Enzyme](https://enzymejs.github.io/enzyme), [Testing Library](https://testing-library.com), [Cypress](https://www.cypress.io/), [Playwright](https://playwright.dev/), [Mocha](https://mochajs.org), etc. |
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
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
30963
17
693