4.0.3 • Published 2 years ago

@component-controls/core v4.0.3

Weekly downloads
145
License
MIT
Repository
github
Last release
2 years ago

Table of contents

Overview

Type definitions of the component-controls specification and accompanying utility functions. Includes definitions for:

Installation

This package is usually installed as part of the @component-controls package, but you can also install it standalone:

$ npm install @component-controls/core --save-dev

API

SourceIdentifier

interface

an identifier/variable.argument in the source code

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeDescription
name*string
locCodeLocationlocation in the source code of a story or part of it ie. arguments, usage of arguments

ArgUsageLocation

interface

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeDescription
loc*SourceLocationstart*line*: numbercolumn*: numberend*line*: numbercolumn*: numberwhere in the story source code is the argument used code location is relative to the start of the story
nameSourceIdentifieran identifier/variable.argument in the source code
shorthandbooleantrue if the property is a 'shorthand'. { prop: value } - not a shorthand. { prop } - a shorthand.

StoryArgument

interface

arguments passed to the 'story' function, extracted by an AST loader

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeDescription
value*string | StoryArgumentseither the name used (or a variable alias), or an array of sub-arguments ({ name: alias })
namestringthe original name of the argument
locCodeLocationlocation in the source code of a story or part of it ie. arguments, usage of arguments
usageArgUsageLocation[]list of locations where the argument is used in the body of the story

StoryArguments

array

list of story arguments. Each argument can be a deconstructed argument of itself the first argument are the control 'values'

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeDescription
anonymous*StoryArgumentarguments passed to the 'story' function, extracted by an AST loader

Story

type

Story interface - usually extracted by the AST instrumenting loader

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeParentDescription
name*stringname of the Story.
storyNamestringalternative name prop
idstringid of the story
rawIdstringraw id for the story as declared in ESM format
docstringtitle of the file/group of stories
storyFnStoryRenderFnstory render function
descriptionstringstory extended description. can use markdown.
argumentsStoryArgumentslist of story arguments. Each argument can be a deconstructed argument of itself the first argument are the control 'values'
locCodeLocationlocation in the source code of a story or part of it ie. arguments, usage of arguments
sourcestringthe source code of the story, extracted by the AST instrumenting loaders
subtitlestringoptional story subtitle property
dynamicbooleanif set to true, the function is dynamically creating stories, returns a list of Story objects
dynamicIdstringif the story was created by a dynamic story (factory), this is the original story id. it is set internally and will be used to create a story URL
componenttypeat*: function (index*: number) => T | undefinedStoryPropsid for component associated with the story
subcomponentsRecord<string, (string, Record<string, unknown>, ElementType<Props>)>StoryPropsmultiple components option
controlsComponentControlsStoryPropsComponentControls are defined in key value pairs the name of the property is the key and the value is the ComponentControl
smartControlsSmartControlssmart: booleaninclude: string[] | IncludeFnexclude: string[] | IncludeFnStoryProps"smart" controls options
decoratorsStoryRenderFn[]StoryPropsarray of wrapper functions (decorators) to be called when rendering each individual story.
pluginsanyStoryPropsplugins configuration settings
categorystringStoryPropscategory string - can be used for cleanly separating stories/components

DynamicExamples

array

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeDescription
anonymous*StoryStory interface - usually extracted by the AST instrumenting loader

ExampleControl

union

defined in @component-controls/core/core/core/src/document.ts

values

ComponentControl | any

ExampleControls

type

defined in @component-controls/core/core/core/src/document.ts

properties

NameType
name*[string]: ExampleControl

Example

type

es named export function, excapsulates a contained example code.

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeParentDescription
bind*function (props: Story) => Example
sourcestringStorythe source code of the story, extracted by the AST instrumenting loaders
storyNamestringStoryalternative name prop
idstringStoryid of the story
rawIdstringStoryraw id for the story as declared in ESM format
docstringStorytitle of the file/group of stories
storyFnStoryRenderFnStorystory render function
descriptionstringStorystory extended description. can use markdown.
locCodeLocationStorylocation in the source code of a story or part of it ie. arguments, usage of arguments
subtitlestringStoryoptional story subtitle property
dynamicbooleanStoryif set to true, the function is dynamically creating stories, returns a list of Story objects
dynamicIdstringStoryif the story was created by a dynamic story (factory), this is the original story id. it is set internally and will be used to create a story URL
componenttypeat*: function (index*: number) => T | undefinedStoryPropsid for component associated with the story
subcomponentsRecord<string, (string, Record<string, unknown>, ElementType<Props>)>StoryPropsmultiple components option
smartControlsSmartControlssmart: booleaninclude: string[] | IncludeFnexclude: string[] | IncludeFnStoryProps"smart" controls options
decoratorsStoryRenderFn[]StoryPropsarray of wrapper functions (decorators) to be called when rendering each individual story.
pluginsanyStoryPropsplugins configuration settings
categorystringStoryPropscategory string - can be used for cleanly separating stories/components
controlsExampleControls

DocumentData

type

records of storyid/data pairs, to be associated with documents

defined in @component-controls/core/core/core/src/document.ts

properties

NameType
anonymous[string]: ExampleControls

StoryFactoryFn

function

dynamic story creator function type. returns an array of dynamically loaded stories

defined in @component-controls/core/core/core/src/document.ts

parameters

NameTypeDescription
doc*Document
returnstypename*: stringstoryName: stringid: stringrawId: stringdoc: stringstoryFn: StoryRenderFndescription: stringarguments: StoryArgumentsloc: CodeLocationsource: stringsubtitle: stringdynamic: booleandynamicId: stringcomponentat*: function (index*: number) => T | undefinedsubcomponents: Record<string, (string, Record<string, unknown>, ElementType<Props>)>controls: ComponentControlssmartControlssmart: booleaninclude: string[] | IncludeFnexclude: string[] | IncludeFndecorators: StoryRenderFn[]plugins: anycategory: stringStory interface - usually extracted by the AST instrumenting loader

defDocType

union = "story"

defined in @component-controls/core/core/core/src/document.ts

values

"story" | "blog" | "page" | "tags" | "author" | string

Document

type

A documentation file's metadata. For MDX files, fromtmatter is used to declare the document properties. For ESM (ES Modules) documentation files, the default export is used.

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeParentDescription
key*[string]: anycustom document props
title*stringtitle of the document. If no 'route' parameter is specifified, the title is used to generate the document url. This is the only required field, to show the document in the menu structures.
typeDocTypedocument type - blogs, pages, stories and even custom ones. By default - story
routestringif provided, will be used as the route for the page. if not provided, the title in lowercase will be used as the route
datestringoptional date the document was created. If not assigned, the instrumentation process will use birthtime
dateModifiedstringoptional date the document was last modified. If not assigned, the instrumentation process will use mtime
status"draft" | "published"if set to draft, the document will be hidden in production builds.
tagsstring[]comma-separated list of document tags, used for search and for SOE keywords unless keyswords are specified.
keywordsstring[]comma-separated list of SEO keywords
descriptionstring | JSX.Elementdocumentation file description
imagestringlink to an image for the document, will be used for SEO
authorstringdocument author
ordernumberdocument order, used to sort documents within the same parent
menustringto which static menu to attach the document compatibility with docz
templateExamplees named export function, excapsulates a contained example code.
storiesstring[]list of story ids contained in the document.
sourcestringsource code of the entire file of stories
fileNamestringfile name of the file of stories
packagestringlookup into the global store of PackageInfo package.json
testFilesstring[]optional specify which test files are asociated with the document
testCoveragestring[]optional specify which files to use for test coverage
testDatastringoptional test data file
renderFnFrameworkRenderFnrender function by framework. By default 'react'
dataDocumentDatarecords of storyid/data pairs, to be associated with documents
componentsLookuptype[string]: stringlookup into the global store.components since multiple components of the same name can be used example: ['Button']: 'c:/myapp/Button.tsx'
MDXPageanyfor MDX documents, this is an MDXContent function, to be rendered inside a MDXProvider
isMDXComponentbooleancustom prop set by mdxjs
parametersanystorybook compatibility field
componenttypeat*: function (index*: number) => T | undefinedStoryPropsid for component associated with the story
subcomponentsRecord<string, (string, Record<string, unknown>, ElementType<Props>)>StoryPropsmultiple components option
controlsComponentControlsStoryPropsComponentControls are defined in key value pairs the name of the property is the key and the value is the ComponentControl
smartControlsSmartControlssmart: booleaninclude: string[] | IncludeFnexclude: string[] | IncludeFnStoryProps"smart" controls options
decoratorsStoryRenderFn[]StoryPropsarray of wrapper functions (decorators) to be called when rendering each individual story.
pluginsanyStoryPropsplugins configuration settings
categorystringStoryPropscategory string - can be used for cleanly separating stories/components
navSidebarbooleanPageLayoutPropswhether to add navigation sidebar to the page
contextSidebarbooleanPageLayoutPropswhether to add conext sidebar to navigate the sections of the current document
fullPagebooleanPageLayoutPropswhether to take a fullpage theme option

dateToLocalString

react function

defined in @component-controls/core/core/core/src/document.ts

parameters

NameType
dateDate
returnsstring

DocInfo

type

short document information. used in search results, or index page

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeParentDescription
title*stringDocumenttitle of the document. If no 'route' parameter is specifified, the title is used to generate the document url. This is the only required field, to show the document in the menu structures.
imagestringDocumentlink to an image for the document, will be used for SEO
descriptionstring | JSX.ElementDocumentdocumentation file description
tagsstring[]Documentcomma-separated list of document tags, used for search and for SOE keywords unless keyswords are specified.
authorstringDocumentdocument author
typeDocTypeDocumentdocument type - blogs, pages, stories and even custom ones. By default - story
datestringDocumentoptional date the document was created. If not assigned, the instrumentation process will use birthtime
link*stringfollowing fields are useful for highlighting search results
authorLinkstring
rawTagsstring[]
rawTypestring

Documents

type

list of story files, or groups

defined in @component-controls/core/core/core/src/document.ts

properties

NameType
anonymous[string]: Document

Pages

array

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeDescription
anonymous*DocumentA documentation file's metadata. For MDX files, fromtmatter is used to declare the document properties. For ESM (ES Modules) documentation files, the default export is used.

Stories

type

list of stories

defined in @component-controls/core/core/core/src/document.ts

properties

NameType
anonymous[string]: Story

Packages

type

list of repositories

defined in @component-controls/core/core/core/src/document.ts

properties

NameType
anonymous[string]: PackageInfo

StoreObserver

function

defined in @component-controls/core/core/core/src/document.ts

parameters

NameTypeDescription
storyStoryStory interface - usually extracted by the AST instrumenting loader

CURRENT_STORY

string = "."

Shorthand id to denote the current story

defined in @component-controls/core/core/core/src/document.ts

Store

interface

Store of stories information in memory after the loader is applied

defined in @component-controls/core/core/core/src/document.ts

properties

NameTypeDescription
errorstringbuild-time error string
config*RunConfigurationglobal configuration for config file
docs*Documentslist of documents (pages)
stories*Storieslist of stories
components*Componentslist of components used in stories and documents
packages*Packageslist of package.json files and their data used by the components and the stories of the project
addObserver*function (observer*: StoreObserver) => voidstorybook integration notifiers
removeObserver*function (observer*: StoreObserver) => void
updateStory*function (story*: Story) => voidupdate store, for example controls or state
searchfunction (store*: Store) => SearchResultitems*: SearchItem[]searchFn*: function (search*: string) => voidproviderlogo*: ReactNodeurl*: stringname*: string

getDefaultStore

function

defined in @component-controls/core/core/core/src/document.ts

parameters

NameTypeDescription
returnsStoreStore of stories information in memory after the loader is applied

assignProps

react function

_defined in @component-controls/core/core/core/src/document.ts(https://github.com/ccontrols/component-controls/tree/master/core/core/src/doc

4.0.3

2 years ago

3.12.0

3 years ago

3.14.0

3 years ago

3.14.2

3 years ago

3.14.5

3 years ago

3.14.6

3 years ago

3.13.0

3 years ago

3.11.4

3 years ago

3.9.0

3 years ago

3.8.0

3 years ago

3.10.0

3 years ago

3.10.3

3 years ago

3.10.2

3 years ago

3.8.2

3 years ago

3.11.0

3 years ago

3.7.0

3 years ago

3.6.3

3 years ago

3.6.2

3 years ago

3.6.0

3 years ago

3.5.0

3 years ago

3.4.2

3 years ago

3.4.1

3 years ago

3.4.0

3 years ago

3.2.0

3 years ago

3.1.5

3 years ago

3.3.0

3 years ago

3.1.0

3 years ago

2.13.0

3 years ago

2.10.4

3 years ago

2.9.0

3 years ago

2.8.0

3 years ago

2.7.0

3 years ago

2.6.3

3 years ago

2.6.2

3 years ago

2.6.0

3 years ago

2.5.0

3 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.0.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.44.0

3 years ago

1.43.0

3 years ago

1.42.12

3 years ago

1.42.9

3 years ago

1.42.0

3 years ago

1.41.0

3 years ago

1.40.2

3 years ago

1.39.4

3 years ago

1.39.3

3 years ago

1.38.0

3 years ago

1.37.0

4 years ago

1.36.14

4 years ago

1.36.8

4 years ago

1.36.6

4 years ago

1.36.5

4 years ago

1.36.0

4 years ago

1.35.1

4 years ago

1.35.0

4 years ago

1.34.0

4 years ago

1.32.1

4 years ago

1.32.5

4 years ago

1.32.2

4 years ago

1.32.3

4 years ago

1.31.3

4 years ago

1.31.2

4 years ago

1.30.0

4 years ago

1.29.0

4 years ago

1.28.0

4 years ago

1.27.3

4 years ago

1.26.0

4 years ago

1.25.0

4 years ago

1.24.6

4 years ago

1.22.0

4 years ago

1.21.0

4 years ago

1.20.0

4 years ago

1.19.5

4 years ago

1.19.3

4 years ago

1.19.2

4 years ago

1.19.1

4 years ago

1.19.0

4 years ago

1.18.1

4 years ago

1.18.0

4 years ago

1.18.3

4 years ago

1.18.2

4 years ago

1.17.0

4 years ago

1.16.3

4 years ago

1.16.2

4 years ago

1.16.1

4 years ago

1.16.0

4 years ago

1.15.0

4 years ago

1.14.1

4 years ago

1.14.0

4 years ago

1.13.4

4 years ago

1.13.3

4 years ago

1.11.0

4 years ago

1.10.3

4 years ago

1.10.0

4 years ago

1.9.0

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.7

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago

0.8.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.3.5

4 years ago

0.4.0

4 years ago

0.3.3

4 years ago

0.3.1

4 years ago

0.1.11

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago