Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@storybook/csf

Package Overview
Dependencies
Maintainers
29
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/csf - npm Package Compare versions

Comparing version 0.0.2--canary.6aca495.0 to 0.0.2--canary.789b78e.0

dist/properties.d.ts

4

dist/index.d.ts

@@ -0,3 +1,4 @@

import { Args, InputType } from './story';
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;

@@ -18,2 +19,3 @@ declare type StoryDescriptor = string[] | RegExp;

};
export declare const includeConditionalArg: (argType: InputType, args: Args) => boolean;
export * from './story';

@@ -11,6 +11,7 @@ "use strict";

isExportStory: true,
parseKind: true
parseKind: true,
includeConditionalArg: true
};
exports.isExportStory = isExportStory;
exports.parseKind = exports.storyNameFromExport = exports.toId = exports.sanitize = void 0;
exports.includeConditionalArg = exports.parseKind = exports.storyNameFromExport = exports.toId = exports.sanitize = void 0;

@@ -73,3 +74,3 @@ var _startCase = _interopRequireDefault(require("lodash/startCase"));

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')) : '');
};

@@ -131,2 +132,21 @@ /**

exports.parseKind = parseKind;
exports.parseKind = parseKind;
var includeHelper = function includeHelper(includeIf, args) {
return typeof includeIf === 'string' && includeIf.length > 0 ? !!args[includeIf] : !!includeIf;
};
/**
* Helper function to include/exclude an arg based on the value of other other args
* aka "conditional args"
*/
var includeConditionalArg = function includeConditionalArg(argType, args) {
var includeIf = argType.includeIf,
excludeIf = argType.excludeIf;
if (typeof includeIf !== 'undefined') return includeHelper(includeIf, args);
if (typeof excludeIf !== 'undefined') return !includeHelper(excludeIf, args);
return true;
};
exports.includeConditionalArg = includeConditionalArg;

@@ -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 @@ });

@@ -24,2 +24,4 @@ import { SBType, SBScalarType } from './SBType';

type?: SBType | SBScalarType['name'];
includeIf?: boolean | string;
excludeIf?: boolean | string;
[key: string]: any;

@@ -75,11 +77,9 @@ }

};
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'];

@@ -92,16 +92,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>;
};

@@ -120,2 +119,3 @@ declare type StoryDescriptor = string[] | RegExp;

storyName?: StoryName;
play?: PlayFunction<TFramework, TArgs>;
story?: Omit<StoryAnnotations<TFramework, TArgs>, 'story'>;

@@ -122,0 +122,0 @@ };

{
"name": "@storybook/csf",
"version": "0.0.2--canary.6aca495.0",
"version": "0.0.2--canary.789b78e.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.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc