@storybook/blocks 7.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/dist/Color-Y7QPKMAJ.mjs +1 -0
- package/dist/chunk-EJDOMQ7I.mjs +1 -0
- package/dist/index.d.ts +498 -0
- package/dist/index.js +70 -0
- package/dist/index.mjs +70 -0
- package/package.json +81 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Kadira Inc. <hello@kadira.io>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Storybook Doc Blocks
|
|
2
|
+
|
|
3
|
+
Portable documentation components for building design systems in Storybook.
|
|
4
|
+
|
|
5
|
+
## Blocks development
|
|
6
|
+
|
|
7
|
+
To bootstrap, in the monorepo root:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
yarn && yarn bootstrap --core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
To develop this package, in the monorepo root:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
yarn build blocks --watch
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
To run storybook, in this directory:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
yarn storybook
|
|
23
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as R,b as C,c as m,d as X,e as L}from"./chunk-EJDOMQ7I.mjs";import u,{useCallback as v,useEffect as _,useMemo as O,useState as k}from"react";import{HexColorPicker as W,HslaStringColorPicker as F,RgbaStringColorPicker as j}from"react-colorful";import h from"color-convert";import M from"lodash/throttle";import{styled as x}from"@storybook/theming";import{TooltipNote as N,WithTooltip as I,Form as A,Icons as q}from"@storybook/components";function S(){return S=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},S.apply(this,arguments)}m(S,"_extends");var D=x.div({position:"relative",maxWidth:250}),J=x(I)({position:"absolute",zIndex:1,top:4,left:4}),K=x.div({width:200,margin:5,".react-colorful__saturation":{borderRadius:"4px 4px 0 0"},".react-colorful__hue":{boxShadow:"inset 0 0 0 1px rgb(0 0 0 / 5%)"},".react-colorful__last-control":{borderRadius:"0 0 4px 4px"}}),Q=x(N)(({theme:t})=>({fontFamily:t.typography.fonts.base})),U=x.div({display:"grid",gridTemplateColumns:"repeat(9, 16px)",gap:6,padding:3,marginTop:5,width:200}),Y=x.div(({theme:t,active:e})=>({width:16,height:16,boxShadow:e?`${t.appBorderColor} 0 0 0 1px inset, ${t.color.mediumdark}50 0 0 0 4px`:`${t.appBorderColor} 0 0 0 1px inset`,borderRadius:t.appBorderRadius})),Z=`url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')`,B=m(l=>{var s=l,{value:t,active:e,onClick:r,style:o}=s,n=X(s,["value","active","onClick","style"]);let a=`linear-gradient(${t}, ${t}), ${Z}, linear-gradient(#fff, #fff)`;return u.createElement(Y,S({},n,{active:e,onClick:r},{style:C(R({},o),{backgroundImage:a})}))},"Swatch"),tt=x(A.Input)(({theme:t})=>({width:"100%",paddingLeft:30,paddingRight:30,boxSizing:"border-box",fontFamily:t.typography.fonts.base})),et=x(q)(({theme:t})=>({position:"absolute",zIndex:1,top:6,right:7,width:20,height:20,padding:4,boxSizing:"border-box",cursor:"pointer",color:t.input.color})),c;(function(t){t.RGB="rgb",t.HSL="hsl",t.HEX="hex"})(c||(c={}));var w=Object.values(c),rt=/\(([0-9]+),\s*([0-9]+)%?,\s*([0-9]+)%?,?\s*([0-9.]+)?\)/,nt=/^\s*rgba?\(([0-9]+),\s*([0-9]+),\s*([0-9]+),?\s*([0-9.]+)?\)\s*$/i,ot=/^\s*hsla?\(([0-9]+),\s*([0-9]+)%,\s*([0-9]+)%,?\s*([0-9.]+)?\)\s*$/i,P=/^\s*#?([0-9a-f]{3}|[0-9a-f]{6})\s*$/i,st=/^\s*#?([0-9a-f]{3})\s*$/i,at={[c.HEX]:W,[c.RGB]:j,[c.HSL]:F},y={[c.HEX]:"transparent",[c.RGB]:"rgba(0, 0, 0, 0)",[c.HSL]:"hsla(0, 0%, 0%, 0)"},G=m(t=>{let e=t==null?void 0:t.match(rt);if(!e)return[0,0,0,1];let[,r,o,n,l=1]=e;return[r,o,n,l].map(Number)},"stringToArgs"),$=m(t=>{if(!t)return;let e=!0;if(nt.test(t)){let[s,a,i,b]=G(t),[f,d,p]=h.rgb.hsl([s,a,i])||[0,0,0];return{valid:e,value:t,keyword:h.rgb.keyword([s,a,i]),colorSpace:c.RGB,[c.RGB]:t,[c.HSL]:`hsla(${f}, ${d}%, ${p}%, ${b})`,[c.HEX]:`#${h.rgb.hex([s,a,i]).toLowerCase()}`}}if(ot.test(t)){let[s,a,i,b]=G(t),[f,d,p]=h.hsl.rgb([s,a,i])||[0,0,0];return{valid:e,value:t,keyword:h.hsl.keyword([s,a,i]),colorSpace:c.HSL,[c.RGB]:`rgba(${f}, ${d}, ${p}, ${b})`,[c.HSL]:t,[c.HEX]:`#${h.hsl.hex([s,a,i]).toLowerCase()}`}}let r=t.replace("#",""),o=h.keyword.rgb(r)||h.hex.rgb(r),n=h.rgb.hsl(o),l=t;if(/[^#a-f0-9]/i.test(t)?l=r:P.test(t)&&(l=`#${r}`),l.startsWith("#"))e=P.test(l);else try{h.keyword.hex(l)}catch{e=!1}return{valid:e,value:l,keyword:h.rgb.keyword(o),colorSpace:c.HEX,[c.RGB]:`rgba(${o[0]}, ${o[1]}, ${o[2]}, 1)`,[c.HSL]:`hsla(${n[0]}, ${n[1]}%, ${n[2]}%, 1)`,[c.HEX]:l}},"parseValue"),it=m((t,e,r)=>{if(!t||!(e!=null&&e.valid))return y[r];if(r!==c.HEX)return(e==null?void 0:e[r])||y[r];if(!e.hex.startsWith("#"))try{return`#${h.keyword.hex(e.hex)}`}catch{return y.hex}let o=e.hex.match(st);if(!o)return P.test(e.hex)?e.hex:y.hex;let[n,l,s]=o[1].split("");return`#${n}${n}${l}${l}${s}${s}`},"getRealValue"),ct=m((t,e)=>{let[r,o]=k(t||""),[n,l]=k(()=>$(r)),[s,a]=k((n==null?void 0:n.colorSpace)||c.HEX);_(()=>{t===void 0&&(o(""),l(void 0),a(c.HEX))},[t]);let i=O(()=>it(r,n,s).toLowerCase(),[r,n,s]),b=v(d=>{let p=$(d),E=(p==null?void 0:p.value)||d||"";o(E),E===""&&(l(void 0),e(void 0)),p&&(l(p),a(p.colorSpace),e(p.value))},[e]),f=v(()=>{let d=w.indexOf(s)+1;d>=w.length&&(d=0),a(w[d]);let p=(n==null?void 0:n[w[d]])||"";o(p),e(p)},[n,s,e]);return{value:r,realValue:i,updateValue:b,color:n,colorSpace:s,cycleColorSpace:f}},"useColorInput"),H=m(t=>t.replace(/\s*/,"").toLowerCase(),"id"),lt=m((t,e,r)=>{let[o,n]=k(e!=null&&e.valid?[e]:[]);_(()=>{e===void 0&&n([])},[e]);let l=O(()=>(t||[]).map(i=>typeof i=="string"?$(i):i.title?C(R({},$(i.color)),{keyword:i.title}):$(i.color)).concat(o).filter(Boolean).slice(-27),[t,o]),s=v(a=>{!(a!=null&&a.valid)||l.some(i=>H(i[r])===H(a[r]))||n(i=>i.concat(a))},[r,l]);return{presets:l,addPreset:s}},"usePresets"),dt=m(({name:t,value:e,onChange:r,onFocus:o,onBlur:n,presetColors:l,startOpen:s})=>{let{value:a,realValue:i,updateValue:b,color:f,colorSpace:d,cycleColorSpace:p}=ct(e,M(r,200)),{presets:E,addPreset:T}=lt(l,f,d),z=at[d];return u.createElement(D,null,u.createElement(J,{trigger:"click",startOpen:s,closeOnClick:!0,onVisibilityChange:()=>T(f),tooltip:u.createElement(K,null,u.createElement(z,S({color:i==="transparent"?"#000000":i},{onChange:b,onFocus:o,onBlur:n})),E.length>0&&u.createElement(U,null,E.map((g,V)=>u.createElement(I,{key:`${g.value}-${V}`,hasChrome:!1,tooltip:u.createElement(Q,{note:g.keyword||g.value})},u.createElement(B,{value:g[d],active:f&&H(g[d])===H(f[d]),onClick:()=>b(g.value)})))))},u.createElement(B,{value:i,style:{margin:4}})),u.createElement(tt,{id:L(t),value:a,onChange:g=>b(g.target.value),onFocus:g=>g.target.select(),placeholder:"Choose color..."}),a?u.createElement(et,{icon:"markup",onClick:p}):null)},"ColorControl"),$t=dt;export{dt as ColorControl,$t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=Object.defineProperty,a=Object.defineProperties;var d=Object.getOwnPropertyDescriptors;var n=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable;var l=(t,e,o)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,x=(t,e)=>{for(var o in e||(e={}))g.call(e,o)&&l(t,o,e[o]);if(n)for(var o of n(e))p.call(e,o)&&l(t,o,e[o]);return t},C=(t,e)=>a(t,d(e)),c=(t,e)=>s(t,"name",{value:e,configurable:!0});var I=(t,e)=>{var o={};for(var r in t)g.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(t!=null&&n)for(var r of n(t))e.indexOf(r)<0&&p.call(t,r)&&(o[r]=t[r]);return o};var S=c(t=>`control-${t.replace(/\s+/g,"-")}`,"getControlId"),b=c(t=>`set-${t.replace(/\s+/g,"-")}`,"getControlSetterButtonId");export{x as a,C as b,c,I as d,S as e,b as f};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import React, { FunctionComponent, ComponentProps, FC, ElementType, Context, ReactNode } from 'react';
|
|
2
|
+
import { Conditional, Parameters, AnyFramework, StrictArgTypes, ProjectAnnotations, StoryId as StoryId$1, BaseAnnotations, StoryAnnotations } from '@storybook/csf';
|
|
3
|
+
import * as _storybook_store from '@storybook/store';
|
|
4
|
+
import { PropDescriptor, ModuleExport, ModuleExports, Story as Story$2 } from '@storybook/store';
|
|
5
|
+
import { DocsContextProps, DocsRenderFunction, Preview as Preview$1 } from '@storybook/preview-web';
|
|
6
|
+
export { DocsContextProps } from '@storybook/preview-web';
|
|
7
|
+
import { SyntaxHighlighter, ActionItem, SyntaxHighlighterFormatTypes } from '@storybook/components';
|
|
8
|
+
import { StoryId } from '@storybook/api';
|
|
9
|
+
|
|
10
|
+
declare enum SourceError {
|
|
11
|
+
NO_STORY = "There\u2019s no story here.",
|
|
12
|
+
SOURCE_UNAVAILABLE = "Oh no! The source is not available."
|
|
13
|
+
}
|
|
14
|
+
interface SourceErrorProps {
|
|
15
|
+
isLoading?: boolean;
|
|
16
|
+
error?: SourceError;
|
|
17
|
+
}
|
|
18
|
+
interface SourceCodeProps {
|
|
19
|
+
language?: string;
|
|
20
|
+
code?: string;
|
|
21
|
+
format?: ComponentProps<typeof SyntaxHighlighter>['format'];
|
|
22
|
+
dark?: boolean;
|
|
23
|
+
}
|
|
24
|
+
declare type SourceProps$1 = SourceErrorProps & SourceCodeProps;
|
|
25
|
+
/**
|
|
26
|
+
* Syntax-highlighted source code for a component (or anything!)
|
|
27
|
+
*/
|
|
28
|
+
declare const Source$1: FunctionComponent<SourceProps$1>;
|
|
29
|
+
|
|
30
|
+
interface DescriptionProps$1 {
|
|
31
|
+
markdown: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface PreviewProps {
|
|
35
|
+
isLoading?: true;
|
|
36
|
+
isColumn?: boolean;
|
|
37
|
+
columns?: number;
|
|
38
|
+
withSource?: SourceProps$1;
|
|
39
|
+
isExpanded?: boolean;
|
|
40
|
+
withToolbar?: boolean;
|
|
41
|
+
className?: string;
|
|
42
|
+
additionalActions?: ActionItem[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface ArgType {
|
|
46
|
+
name?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
defaultValue?: any;
|
|
49
|
+
if?: Conditional;
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
}
|
|
52
|
+
interface ArgTypes {
|
|
53
|
+
[key: string]: ArgType;
|
|
54
|
+
}
|
|
55
|
+
interface Args {
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
}
|
|
58
|
+
declare type Globals = {
|
|
59
|
+
[name: string]: any;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
declare enum ArgsTableError {
|
|
63
|
+
NO_COMPONENT = "No component found.",
|
|
64
|
+
ARGS_UNSUPPORTED = "Args unsupported. See Args documentation for your framework."
|
|
65
|
+
}
|
|
66
|
+
declare type SortType = 'alpha' | 'requiredFirst' | 'none';
|
|
67
|
+
interface ArgsTableOptionProps {
|
|
68
|
+
updateArgs?: (args: Args) => void;
|
|
69
|
+
resetArgs?: (argNames?: string[]) => void;
|
|
70
|
+
compact?: boolean;
|
|
71
|
+
inAddonPanel?: boolean;
|
|
72
|
+
initialExpandedArgs?: boolean;
|
|
73
|
+
isLoading?: boolean;
|
|
74
|
+
sort?: SortType;
|
|
75
|
+
}
|
|
76
|
+
interface ArgsTableDataProps {
|
|
77
|
+
rows: ArgTypes;
|
|
78
|
+
args?: Args;
|
|
79
|
+
globals?: Globals;
|
|
80
|
+
}
|
|
81
|
+
interface ArgsTableErrorProps {
|
|
82
|
+
error: ArgsTableError;
|
|
83
|
+
}
|
|
84
|
+
interface ArgsTableLoadingProps {
|
|
85
|
+
isLoading: true;
|
|
86
|
+
}
|
|
87
|
+
declare type ArgsTableProps$1 = ArgsTableOptionProps & (ArgsTableDataProps | ArgsTableErrorProps | ArgsTableLoadingProps);
|
|
88
|
+
/**
|
|
89
|
+
* Display the props for a component as a props table. Each row is a collection of
|
|
90
|
+
* ArgDefs, usually derived from docgen info for the component.
|
|
91
|
+
*/
|
|
92
|
+
declare const ArgsTable$1: FC<ArgsTableProps$1>;
|
|
93
|
+
|
|
94
|
+
declare const NoControlsWarning: () => JSX.Element;
|
|
95
|
+
|
|
96
|
+
declare enum StoryError {
|
|
97
|
+
NO_STORY = "No component or story to display"
|
|
98
|
+
}
|
|
99
|
+
interface CommonProps$2 {
|
|
100
|
+
title?: string;
|
|
101
|
+
height?: string;
|
|
102
|
+
id: string;
|
|
103
|
+
}
|
|
104
|
+
interface InlineStoryProps extends CommonProps$2 {
|
|
105
|
+
parameters: Parameters;
|
|
106
|
+
storyFn: ElementType;
|
|
107
|
+
}
|
|
108
|
+
declare type IFrameStoryProps = CommonProps$2;
|
|
109
|
+
declare type StoryProps$2 = InlineStoryProps | IFrameStoryProps;
|
|
110
|
+
/**
|
|
111
|
+
* A story element, either rendered inline or in an iframe,
|
|
112
|
+
* with configurable height.
|
|
113
|
+
*/
|
|
114
|
+
declare const Story$1: FunctionComponent<StoryProps$2 & {
|
|
115
|
+
inline?: boolean;
|
|
116
|
+
error?: StoryError;
|
|
117
|
+
}>;
|
|
118
|
+
|
|
119
|
+
interface TypesetProps {
|
|
120
|
+
fontFamily?: string;
|
|
121
|
+
fontSizes: string[];
|
|
122
|
+
fontWeight?: number;
|
|
123
|
+
sampleText?: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Convenient styleguide documentation showing examples of type
|
|
127
|
+
* with different sizes and weights and configurable sample text.
|
|
128
|
+
*/
|
|
129
|
+
declare const Typeset: FunctionComponent<TypesetProps>;
|
|
130
|
+
|
|
131
|
+
declare type Colors = string[] | {
|
|
132
|
+
[key: string]: string;
|
|
133
|
+
};
|
|
134
|
+
interface ColorItemProps {
|
|
135
|
+
title: string;
|
|
136
|
+
subtitle: string;
|
|
137
|
+
colors: Colors;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A single color row your styleguide showing title, subtitle and one or more colors, used
|
|
141
|
+
* as a child of `ColorPalette`.
|
|
142
|
+
*/
|
|
143
|
+
declare const ColorItem: FunctionComponent<ColorItemProps>;
|
|
144
|
+
/**
|
|
145
|
+
* Styleguide documentation for colors, including names, captions, and color swatches,
|
|
146
|
+
* all specified as `ColorItem` children of this wrapper component.
|
|
147
|
+
*/
|
|
148
|
+
declare const ColorPalette: FunctionComponent;
|
|
149
|
+
|
|
150
|
+
interface IconItemProps {
|
|
151
|
+
name: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* An individual icon with a caption and an example (passed as `children`).
|
|
155
|
+
*/
|
|
156
|
+
declare const IconItem: FunctionComponent<IconItemProps>;
|
|
157
|
+
/**
|
|
158
|
+
* Show a grid of icons, as specified by `IconItem`.
|
|
159
|
+
*/
|
|
160
|
+
declare const IconGallery: FunctionComponent;
|
|
161
|
+
|
|
162
|
+
declare const anchorBlockIdFromId: (storyId: string) => string;
|
|
163
|
+
interface AnchorProps {
|
|
164
|
+
storyId: string;
|
|
165
|
+
}
|
|
166
|
+
declare const Anchor: FC<AnchorProps>;
|
|
167
|
+
|
|
168
|
+
declare const DocsContext: Context<DocsContextProps<AnyFramework>>;
|
|
169
|
+
|
|
170
|
+
declare const CURRENT_SELECTION = ".";
|
|
171
|
+
declare const PRIMARY_STORY = "^";
|
|
172
|
+
declare type Component = any;
|
|
173
|
+
interface StoryData {
|
|
174
|
+
id?: string;
|
|
175
|
+
kind?: string;
|
|
176
|
+
name?: string;
|
|
177
|
+
parameters?: any;
|
|
178
|
+
}
|
|
179
|
+
declare type DocsStoryProps = StoryData & {
|
|
180
|
+
expanded?: boolean;
|
|
181
|
+
withToolbar?: boolean;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
interface BaseProps {
|
|
185
|
+
include?: PropDescriptor;
|
|
186
|
+
exclude?: PropDescriptor;
|
|
187
|
+
sort?: SortType;
|
|
188
|
+
}
|
|
189
|
+
declare type OfProps = BaseProps & {
|
|
190
|
+
of: '.' | '^' | Component;
|
|
191
|
+
};
|
|
192
|
+
declare type ComponentsProps = BaseProps & {
|
|
193
|
+
components: {
|
|
194
|
+
[label: string]: Component;
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
declare type StoryProps$1 = BaseProps & {
|
|
198
|
+
story: '.' | '^' | string;
|
|
199
|
+
showComponent?: boolean;
|
|
200
|
+
};
|
|
201
|
+
declare type ArgsTableProps = BaseProps | OfProps | ComponentsProps | StoryProps$1;
|
|
202
|
+
declare const extractComponentArgTypes: (component: Component, { id, storyById }: DocsContextProps, include?: PropDescriptor, exclude?: PropDescriptor) => StrictArgTypes;
|
|
203
|
+
declare const getComponent: (props: ArgsTableProps, { id, storyById }: DocsContextProps) => Component;
|
|
204
|
+
declare const StoryTable: FC<StoryProps$1 & {
|
|
205
|
+
component: Component;
|
|
206
|
+
subcomponents: Record<string, Component>;
|
|
207
|
+
}>;
|
|
208
|
+
declare const ComponentsTable: FC<ComponentsProps>;
|
|
209
|
+
declare const ArgsTable: FC<ArgsTableProps>;
|
|
210
|
+
|
|
211
|
+
interface SourceItem {
|
|
212
|
+
code: string;
|
|
213
|
+
format: SyntaxHighlighterFormatTypes;
|
|
214
|
+
}
|
|
215
|
+
declare type StorySources = Record<StoryId, SourceItem>;
|
|
216
|
+
interface SourceContextProps {
|
|
217
|
+
sources: StorySources;
|
|
218
|
+
setSource?: (id: StoryId, item: SourceItem) => void;
|
|
219
|
+
}
|
|
220
|
+
declare const SourceContext: Context<SourceContextProps>;
|
|
221
|
+
declare const SourceContainer: FC<{}>;
|
|
222
|
+
|
|
223
|
+
declare enum SourceState {
|
|
224
|
+
OPEN = "open",
|
|
225
|
+
CLOSED = "closed",
|
|
226
|
+
NONE = "none"
|
|
227
|
+
}
|
|
228
|
+
interface CommonProps$1 {
|
|
229
|
+
language?: string;
|
|
230
|
+
dark?: boolean;
|
|
231
|
+
format?: PureSourceProps['format'];
|
|
232
|
+
code?: string;
|
|
233
|
+
}
|
|
234
|
+
declare type SingleSourceProps = {
|
|
235
|
+
id: string;
|
|
236
|
+
} & CommonProps$1;
|
|
237
|
+
declare type MultiSourceProps = {
|
|
238
|
+
ids: string[];
|
|
239
|
+
} & CommonProps$1;
|
|
240
|
+
declare type CodeProps = {
|
|
241
|
+
code: string;
|
|
242
|
+
} & CommonProps$1;
|
|
243
|
+
declare type NoneProps = CommonProps$1;
|
|
244
|
+
declare type SourceProps = SingleSourceProps | MultiSourceProps | CodeProps | NoneProps;
|
|
245
|
+
declare type SourceStateProps = {
|
|
246
|
+
state: SourceState;
|
|
247
|
+
};
|
|
248
|
+
declare type PureSourceProps = ComponentProps<typeof Source$1>;
|
|
249
|
+
declare const getSourceProps: (props: SourceProps, docsContext: DocsContextProps<any>, sourceContext: SourceContextProps) => PureSourceProps & SourceStateProps;
|
|
250
|
+
/**
|
|
251
|
+
* Story source doc block renders source code if provided,
|
|
252
|
+
* or the source for a story if `storyId` is provided, or
|
|
253
|
+
* the source for the current story if nothing is provided.
|
|
254
|
+
*/
|
|
255
|
+
declare const Source: FC<PureSourceProps>;
|
|
256
|
+
|
|
257
|
+
declare type CanvasProps = PreviewProps & {
|
|
258
|
+
withSource?: SourceState;
|
|
259
|
+
mdxSource?: string;
|
|
260
|
+
};
|
|
261
|
+
declare const Canvas: FC<CanvasProps>;
|
|
262
|
+
|
|
263
|
+
declare enum DescriptionType {
|
|
264
|
+
INFO = "info",
|
|
265
|
+
NOTES = "notes",
|
|
266
|
+
DOCGEN = "docgen",
|
|
267
|
+
LEGACY_5_2 = "legacy-5.2",
|
|
268
|
+
AUTO = "auto"
|
|
269
|
+
}
|
|
270
|
+
interface DescriptionProps {
|
|
271
|
+
of?: '.' | Component;
|
|
272
|
+
type?: DescriptionType;
|
|
273
|
+
markdown?: string;
|
|
274
|
+
children?: string;
|
|
275
|
+
}
|
|
276
|
+
declare const getDescriptionProps: ({ of, type, markdown, children }: DescriptionProps, { id, storyById }: DocsContextProps<any>) => DescriptionProps$1;
|
|
277
|
+
declare const DescriptionContainer: FunctionComponent<DescriptionProps>;
|
|
278
|
+
|
|
279
|
+
declare class DocsRenderer<TFramework extends AnyFramework> {
|
|
280
|
+
render: DocsRenderFunction<TFramework>;
|
|
281
|
+
unmount: (element: HTMLElement) => void;
|
|
282
|
+
constructor();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
declare const DocsPage: FC;
|
|
286
|
+
|
|
287
|
+
interface DocsContainerProps<TFramework extends AnyFramework = AnyFramework> {
|
|
288
|
+
context: DocsContextProps<TFramework>;
|
|
289
|
+
}
|
|
290
|
+
declare const DocsContainer: FunctionComponent<DocsContainerProps>;
|
|
291
|
+
|
|
292
|
+
declare const DocsStory: FunctionComponent<DocsStoryProps>;
|
|
293
|
+
|
|
294
|
+
declare const ExternalDocsContainer: React.FC<{
|
|
295
|
+
projectAnnotations: any;
|
|
296
|
+
}>;
|
|
297
|
+
|
|
298
|
+
declare type StoryExport = ModuleExport;
|
|
299
|
+
declare type MetaExport = ModuleExports;
|
|
300
|
+
declare class ExternalPreview<TFramework extends AnyFramework> extends Preview$1<TFramework> {
|
|
301
|
+
projectAnnotations: ProjectAnnotations;
|
|
302
|
+
private initialized;
|
|
303
|
+
private importPaths;
|
|
304
|
+
private titles;
|
|
305
|
+
storyIds: Map<any, string>;
|
|
306
|
+
private storyIndex;
|
|
307
|
+
private moduleExportsByImportPath;
|
|
308
|
+
constructor(projectAnnotations: ProjectAnnotations);
|
|
309
|
+
storyIdByModuleExport(storyExport: StoryExport, meta: MetaExport): string;
|
|
310
|
+
addStoryFromExports(storyExport: StoryExport, meta: MetaExport): Promise<void>;
|
|
311
|
+
storyById(storyId: StoryId$1): _storybook_store.Story<TFramework>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
interface HeadingProps {
|
|
315
|
+
children: JSX.Element | string;
|
|
316
|
+
disableAnchor?: boolean;
|
|
317
|
+
}
|
|
318
|
+
declare const Heading: FunctionComponent<HeadingProps>;
|
|
319
|
+
|
|
320
|
+
declare type MetaProps = BaseAnnotations & {
|
|
321
|
+
of?: ModuleExports;
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* This component is used to declare component metadata in docs
|
|
325
|
+
* and gets transformed into a default export underneath the hood.
|
|
326
|
+
*/
|
|
327
|
+
declare const Meta: FC<MetaProps>;
|
|
328
|
+
|
|
329
|
+
declare const Preview: (props: ComponentProps<typeof Canvas>) => JSX.Element;
|
|
330
|
+
|
|
331
|
+
interface PrimaryProps {
|
|
332
|
+
name?: string;
|
|
333
|
+
}
|
|
334
|
+
declare const Primary: FC<PrimaryProps>;
|
|
335
|
+
|
|
336
|
+
declare const Props: (props: ComponentProps<typeof ArgsTable>) => JSX.Element;
|
|
337
|
+
|
|
338
|
+
interface StoriesProps {
|
|
339
|
+
title?: JSX.Element | string;
|
|
340
|
+
includePrimary?: boolean;
|
|
341
|
+
}
|
|
342
|
+
declare const Stories: FunctionComponent<StoriesProps>;
|
|
343
|
+
|
|
344
|
+
declare const storyBlockIdFromId: (storyId: string) => string;
|
|
345
|
+
declare type PureStoryProps = ComponentProps<typeof Story$1>;
|
|
346
|
+
declare type CommonProps = StoryAnnotations & {
|
|
347
|
+
height?: string;
|
|
348
|
+
inline?: boolean;
|
|
349
|
+
};
|
|
350
|
+
declare type StoryDefProps = {
|
|
351
|
+
name: string;
|
|
352
|
+
children: ReactNode;
|
|
353
|
+
};
|
|
354
|
+
declare type StoryRefProps = {
|
|
355
|
+
id?: string;
|
|
356
|
+
of?: ModuleExport;
|
|
357
|
+
meta?: ModuleExports;
|
|
358
|
+
};
|
|
359
|
+
declare type StoryImportProps = {
|
|
360
|
+
name: string;
|
|
361
|
+
story: ElementType;
|
|
362
|
+
};
|
|
363
|
+
declare type StoryProps = (StoryDefProps | StoryRefProps | StoryImportProps) & CommonProps;
|
|
364
|
+
declare const lookupStoryId: (storyName: string, { mdxStoryNameToKey, mdxComponentAnnotations }: DocsContextProps) => string;
|
|
365
|
+
declare const getStoryId: (props: StoryProps, context: DocsContextProps) => StoryId$1;
|
|
366
|
+
declare const getStoryProps: <TFramework extends AnyFramework>({ height, inline }: StoryProps, story: Story$2<TFramework>) => PureStoryProps;
|
|
367
|
+
declare const Story: FunctionComponent<StoryProps>;
|
|
368
|
+
|
|
369
|
+
declare const Subheading: FunctionComponent<HeadingProps>;
|
|
370
|
+
|
|
371
|
+
interface SubtitleProps {
|
|
372
|
+
children?: JSX.Element | string;
|
|
373
|
+
}
|
|
374
|
+
declare const Subtitle: FunctionComponent<SubtitleProps>;
|
|
375
|
+
|
|
376
|
+
interface TitleProps {
|
|
377
|
+
children?: JSX.Element | string;
|
|
378
|
+
}
|
|
379
|
+
declare const extractTitle: ({ title }: DocsContextProps) => string;
|
|
380
|
+
declare const Title: FunctionComponent<TitleProps>;
|
|
381
|
+
|
|
382
|
+
declare const Wrapper: FunctionComponent;
|
|
383
|
+
|
|
384
|
+
declare const assertIsFn: (val: any) => any;
|
|
385
|
+
declare const AddContext: FC<DocsContextProps>;
|
|
386
|
+
interface CodeOrSourceMdxProps {
|
|
387
|
+
className?: string;
|
|
388
|
+
}
|
|
389
|
+
declare const CodeOrSourceMdx: FC<CodeOrSourceMdxProps>;
|
|
390
|
+
interface AnchorMdxProps {
|
|
391
|
+
href: string;
|
|
392
|
+
target: string;
|
|
393
|
+
}
|
|
394
|
+
declare const AnchorMdx: FC<AnchorMdxProps>;
|
|
395
|
+
interface HeaderMdxProps {
|
|
396
|
+
as: string;
|
|
397
|
+
id: string;
|
|
398
|
+
}
|
|
399
|
+
declare const HeaderMdx: FC<HeaderMdxProps>;
|
|
400
|
+
declare const HeadersMdx: {};
|
|
401
|
+
|
|
402
|
+
interface ControlProps<T> {
|
|
403
|
+
name: string;
|
|
404
|
+
value?: T;
|
|
405
|
+
defaultValue?: T;
|
|
406
|
+
argType?: ArgType;
|
|
407
|
+
onChange: (value: T) => T | void;
|
|
408
|
+
onFocus?: (evt: any) => void;
|
|
409
|
+
onBlur?: (evt: any) => void;
|
|
410
|
+
}
|
|
411
|
+
declare type BooleanValue = boolean;
|
|
412
|
+
interface BooleanConfig {
|
|
413
|
+
}
|
|
414
|
+
declare type ColorValue = string;
|
|
415
|
+
declare type PresetColor = ColorValue | {
|
|
416
|
+
color: ColorValue;
|
|
417
|
+
title?: string;
|
|
418
|
+
};
|
|
419
|
+
interface ColorConfig {
|
|
420
|
+
presetColors?: PresetColor[];
|
|
421
|
+
startOpen?: boolean;
|
|
422
|
+
}
|
|
423
|
+
declare type DateValue = Date | number;
|
|
424
|
+
interface DateConfig {
|
|
425
|
+
}
|
|
426
|
+
declare type NumberValue = number;
|
|
427
|
+
interface NumberConfig {
|
|
428
|
+
min?: number;
|
|
429
|
+
max?: number;
|
|
430
|
+
step?: number;
|
|
431
|
+
}
|
|
432
|
+
declare type RangeConfig = NumberConfig;
|
|
433
|
+
declare type ObjectValue = any;
|
|
434
|
+
interface ObjectConfig {
|
|
435
|
+
}
|
|
436
|
+
declare type OptionsSingleSelection = any;
|
|
437
|
+
declare type OptionsMultiSelection = any[];
|
|
438
|
+
declare type OptionsSelection = OptionsSingleSelection | OptionsMultiSelection;
|
|
439
|
+
declare type OptionsArray = any[];
|
|
440
|
+
declare type OptionsObject = Record<string, any>;
|
|
441
|
+
declare type Options = OptionsArray | OptionsObject;
|
|
442
|
+
declare type OptionsControlType = 'radio' | 'inline-radio' | 'check' | 'inline-check' | 'select' | 'multi-select';
|
|
443
|
+
interface OptionsConfig {
|
|
444
|
+
labels: Record<any, string>;
|
|
445
|
+
options: Options;
|
|
446
|
+
type: OptionsControlType;
|
|
447
|
+
}
|
|
448
|
+
interface NormalizedOptionsConfig {
|
|
449
|
+
options: OptionsObject;
|
|
450
|
+
}
|
|
451
|
+
declare type TextValue = string;
|
|
452
|
+
interface TextConfig {
|
|
453
|
+
}
|
|
454
|
+
declare type ControlType = 'array' | 'boolean' | 'color' | 'date' | 'number' | 'range' | 'object' | OptionsControlType | 'text';
|
|
455
|
+
declare type Control = BooleanConfig | ColorConfig | DateConfig | NumberConfig | ObjectConfig | OptionsConfig | RangeConfig | TextConfig;
|
|
456
|
+
declare type Controls = Record<string, Control>;
|
|
457
|
+
|
|
458
|
+
declare type ColorControlProps = ControlProps<ColorValue> & ColorConfig;
|
|
459
|
+
|
|
460
|
+
declare type BooleanProps = ControlProps<BooleanValue> & BooleanConfig;
|
|
461
|
+
declare const BooleanControl: FC<BooleanProps>;
|
|
462
|
+
|
|
463
|
+
declare const parseDate: (value: string) => Date;
|
|
464
|
+
declare const parseTime: (value: string) => Date;
|
|
465
|
+
declare const formatDate: (value: Date | number) => string;
|
|
466
|
+
declare const formatTime: (value: Date | number) => string;
|
|
467
|
+
declare type DateProps = ControlProps<DateValue> & DateConfig;
|
|
468
|
+
declare const DateControl: FC<DateProps>;
|
|
469
|
+
|
|
470
|
+
declare type NumberProps = ControlProps<NumberValue | null> & NumberConfig;
|
|
471
|
+
declare const parse: (value: string) => number;
|
|
472
|
+
declare const format: (value: NumberValue) => string;
|
|
473
|
+
declare const NumberControl: FC<NumberProps>;
|
|
474
|
+
|
|
475
|
+
declare type OptionsProps = ControlProps<OptionsSelection> & OptionsConfig;
|
|
476
|
+
declare const OptionsControl: FC<OptionsProps>;
|
|
477
|
+
|
|
478
|
+
declare type ObjectProps = ControlProps<ObjectValue> & ObjectConfig & {
|
|
479
|
+
theme: any;
|
|
480
|
+
};
|
|
481
|
+
declare const ObjectControl: FC<ObjectProps>;
|
|
482
|
+
|
|
483
|
+
declare type RangeProps = ControlProps<NumberValue | null> & RangeConfig;
|
|
484
|
+
declare const RangeControl: FC<RangeProps>;
|
|
485
|
+
|
|
486
|
+
declare type TextProps = ControlProps<TextValue | undefined> & TextConfig;
|
|
487
|
+
declare const TextControl: FC<TextProps>;
|
|
488
|
+
|
|
489
|
+
interface FilesControlProps extends ControlProps<string[]> {
|
|
490
|
+
accept?: string;
|
|
491
|
+
}
|
|
492
|
+
declare const FilesControl: FunctionComponent<FilesControlProps>;
|
|
493
|
+
|
|
494
|
+
declare type ColorProps = ColorControlProps;
|
|
495
|
+
declare const LazyColorControl: React.LazyExoticComponent<React.FC<ColorControlProps>>;
|
|
496
|
+
declare const ColorControl: (props: ComponentProps<typeof LazyColorControl>) => JSX.Element;
|
|
497
|
+
|
|
498
|
+
export { AddContext, Anchor, AnchorMdx, AnchorProps, ArgsTable, BooleanConfig, BooleanControl, BooleanProps, BooleanValue, CURRENT_SELECTION, Canvas, CodeOrSourceMdx, ColorConfig, ColorControl, ColorItem, ColorPalette, ColorProps, ColorValue, Component, ComponentsTable, Control, ControlProps, ControlType, Controls, DateConfig, DateControl, DateProps, DateValue, DescriptionContainer as Description, DescriptionType, DocsContainer, DocsContainerProps, DocsContext, DocsPage, DocsRenderer, DocsStory, DocsStoryProps, ExternalDocsContainer, ExternalPreview, FilesControl, FilesControlProps, HeaderMdx, HeadersMdx, Heading, HeadingProps, IconGallery, IconItem, Meta, NoControlsWarning, NormalizedOptionsConfig, NumberConfig, NumberControl, NumberValue, ObjectConfig, ObjectControl, ObjectProps, ObjectValue, Options, OptionsArray, OptionsConfig, OptionsControl, OptionsControlType, OptionsMultiSelection, OptionsObject, OptionsProps, OptionsSelection, OptionsSingleSelection, PRIMARY_STORY, PresetColor, Preview, Primary, Props, ArgsTable$1 as PureArgsTable, RangeConfig, RangeControl, SortType, Source, SourceContainer, SourceContext, SourceContextProps, SourceItem, SourceState, Stories, Story, StoryData, StoryProps, StorySources, StoryTable, Subheading, Subtitle, TextConfig, TextControl, TextProps, TextValue, Title, Typeset, Wrapper, anchorBlockIdFromId, assertIsFn, extractComponentArgTypes, extractTitle, format, formatDate, formatTime, getComponent, getDescriptionProps, getSourceProps, getStoryId, getStoryProps, lookupStoryId, parse, parseDate, parseTime, storyBlockIdFromId };
|