@storybook/addon-links 7.0.7 → 7.0.9
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/dist/chunk-DXNAW7Q2.mjs +9 -1
- package/dist/chunk-JT3VIYBO.mjs +3 -1
- package/dist/chunk-VJY7NXNQ.mjs +6 -2
- package/dist/index.mjs +3 -1
- package/dist/manager.mjs +4 -1
- package/dist/preview.d.ts +2 -2
- package/dist/preview.mjs +7 -1
- package/dist/react/index.mjs +7 -1
- package/package.json +19 -19
package/dist/chunk-DXNAW7Q2.mjs
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
import{PARAM_KEY}from
|
|
1
|
+
import { PARAM_KEY } from './chunk-JT3VIYBO.mjs';
|
|
2
|
+
import { global } from '@storybook/global';
|
|
3
|
+
import { makeDecorator, addons } from '@storybook/preview-api';
|
|
4
|
+
import { STORY_CHANGED, SELECT_STORY } from '@storybook/core-events';
|
|
5
|
+
import { toId } from '@storybook/csf';
|
|
6
|
+
|
|
7
|
+
var{document,HTMLElement}=global;function parseQuery(queryString){let query={},pairs=(queryString[0]==="?"?queryString.substring(1):queryString).split("&").filter(Boolean);for(let i=0;i<pairs.length;i++){let pair=pairs[i].split("=");query[decodeURIComponent(pair[0])]=decodeURIComponent(pair[1]||"");}return query}var navigate=params=>addons.getChannel().emit(SELECT_STORY,params),hrefTo=(title,name)=>new Promise(resolve=>{let{location}=document,query=parseQuery(location.search),existingId=[].concat(query.id)[0],titleToLink=title||existingId.split("--",2)[0],path=`/story/${toId(titleToLink,name)}`,sbPath=location.pathname.replace(/iframe\.html$/,""),url=`${location.origin+sbPath}?${Object.entries({path}).map(item=>`${item[0]}=${item[1]}`).join("&")}`;resolve(url);}),valueOrCall=args=>value=>typeof value=="function"?value(...args):value,linkTo=(idOrTitle,nameInput)=>(...args)=>{let resolver=valueOrCall(args),title=resolver(idOrTitle),name=nameInput?resolver(nameInput):!1;title?.match(/--/)&&!name?navigate({storyId:title}):name&&title?navigate({kind:title,story:name}):title?navigate({kind:title}):name&&navigate({story:name});},linksListener=e=>{let{target}=e;if(!(target instanceof HTMLElement))return;let element=target,{sbKind:kind,sbStory:story}=element.dataset;(kind||story)&&(e.preventDefault(),navigate({kind,story}));},hasListener=!1,on=()=>{hasListener||(hasListener=!0,document.addEventListener("click",linksListener));},off=()=>{hasListener&&(hasListener=!1,document.removeEventListener("click",linksListener));},withLinks=makeDecorator({name:"withLinks",parameterName:PARAM_KEY,wrapper:(getStory,context)=>(on(),addons.getChannel().once(STORY_CHANGED,off),getStory(context))});
|
|
8
|
+
|
|
9
|
+
export { hrefTo, linkTo, navigate, withLinks };
|
package/dist/chunk-JT3VIYBO.mjs
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
var ADDON_ID="storybook/links",PARAM_KEY="links",constants_default={NAVIGATE:`${ADDON_ID}/navigate`,REQUEST:`${ADDON_ID}/request`,RECEIVE:`${ADDON_ID}/receive`};
|
|
1
|
+
var ADDON_ID="storybook/links",PARAM_KEY="links",constants_default={NAVIGATE:`${ADDON_ID}/navigate`,REQUEST:`${ADDON_ID}/request`,RECEIVE:`${ADDON_ID}/receive`};
|
|
2
|
+
|
|
3
|
+
export { ADDON_ID, PARAM_KEY, constants_default };
|
package/dist/chunk-VJY7NXNQ.mjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import{dedent}from
|
|
1
|
+
import { dedent } from 'ts-dedent';
|
|
2
|
+
|
|
3
|
+
var hasWarned=!1;function LinkTo(){return hasWarned||(console.error(dedent`
|
|
2
4
|
LinkTo has moved to addon-links/react:
|
|
3
5
|
import LinkTo from '@storybook/addon-links/react';
|
|
4
|
-
`),hasWarned=!0),null}
|
|
6
|
+
`),hasWarned=!0),null}
|
|
7
|
+
|
|
8
|
+
export { LinkTo };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
export { LinkTo } from './chunk-VJY7NXNQ.mjs';
|
|
2
|
+
export { hrefTo, linkTo, navigate, withLinks } from './chunk-DXNAW7Q2.mjs';
|
|
3
|
+
import './chunk-JT3VIYBO.mjs';
|
package/dist/manager.mjs
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{ADDON_ID,constants_default}from
|
|
1
|
+
import { ADDON_ID, constants_default } from './chunk-JT3VIYBO.mjs';
|
|
2
|
+
import { addons } from '@storybook/manager-api';
|
|
3
|
+
|
|
4
|
+
addons.register(ADDON_ID,api=>{addons.getChannel().on(constants_default.REQUEST,({kind,name})=>{let id=api.storyId(kind,name);api.emit(constants_default.RECEIVE,id);});});
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Addon_DecoratorFunction } from '@storybook/types';
|
|
2
2
|
|
|
3
|
-
declare const decorators:
|
|
3
|
+
declare const decorators: Addon_DecoratorFunction[];
|
|
4
4
|
|
|
5
5
|
export { decorators };
|
package/dist/preview.mjs
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './chunk-VJY7NXNQ.mjs';
|
|
2
|
+
import { withLinks } from './chunk-DXNAW7Q2.mjs';
|
|
3
|
+
import './chunk-JT3VIYBO.mjs';
|
|
4
|
+
|
|
5
|
+
var decorators=[withLinks];
|
|
6
|
+
|
|
7
|
+
export { decorators };
|
package/dist/react/index.mjs
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
import{hrefTo,navigate}from
|
|
1
|
+
import { hrefTo, navigate } from '../chunk-DXNAW7Q2.mjs';
|
|
2
|
+
import '../chunk-JT3VIYBO.mjs';
|
|
3
|
+
import React, { PureComponent } from 'react';
|
|
4
|
+
|
|
5
|
+
var LEFT_BUTTON=0,isPlainLeftClick=e=>e.button===LEFT_BUTTON&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey,cancelled=(e,cb=_e=>{})=>{isPlainLeftClick(e)&&(e.preventDefault(),cb(e));},LinkTo=class extends PureComponent{constructor(){super(...arguments);this.state={href:"/"};this.updateHref=async()=>{let{kind,title=kind,story,name=story}=this.props;if(title&&name){let href=await hrefTo(title,name);this.setState({href});}};this.handleClick=()=>{let{kind,title=kind,story,name=story}=this.props;title&&name&&navigate({title,name});};}componentDidMount(){this.updateHref();}componentDidUpdate(prevProps){let{kind,title,story,name}=this.props;(prevProps.kind!==kind||prevProps.story!==story||prevProps.title!==title||prevProps.name!==name)&&this.updateHref();}render(){let{kind,title=kind,story,name=story,children,...rest}=this.props,{href}=this.state;return React.createElement("a",{href,onClick:e=>cancelled(e,this.handleClick),...rest},children)}};LinkTo.defaultProps={children:void 0};var react_default=LinkTo;
|
|
6
|
+
|
|
7
|
+
export { react_default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-links",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.9",
|
|
4
4
|
"description": "Link stories together to build demos and prototypes with your UI components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/storybookjs/storybook.git",
|
|
17
|
-
"directory": "addons/links"
|
|
17
|
+
"directory": "code/addons/links"
|
|
18
18
|
},
|
|
19
19
|
"funding": {
|
|
20
20
|
"type": "opencollective",
|
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
26
27
|
"node": "./dist/index.js",
|
|
27
28
|
"require": "./dist/index.js",
|
|
28
|
-
"import": "./dist/index.mjs"
|
|
29
|
-
"types": "./dist/index.d.ts"
|
|
29
|
+
"import": "./dist/index.mjs"
|
|
30
30
|
},
|
|
31
31
|
"./manager": {
|
|
32
|
+
"types": "./dist/manager.d.ts",
|
|
32
33
|
"require": "./dist/manager.js",
|
|
33
|
-
"import": "./dist/manager.mjs"
|
|
34
|
-
"types": "./dist/manager.d.ts"
|
|
34
|
+
"import": "./dist/manager.mjs"
|
|
35
35
|
},
|
|
36
36
|
"./preview": {
|
|
37
|
+
"types": "./dist/preview.d.ts",
|
|
37
38
|
"require": "./dist/preview.js",
|
|
38
|
-
"import": "./dist/preview.mjs"
|
|
39
|
-
"types": "./dist/preview.d.ts"
|
|
39
|
+
"import": "./dist/preview.mjs"
|
|
40
40
|
},
|
|
41
41
|
"./react": {
|
|
42
|
+
"types": "./dist/react/index.d.ts",
|
|
42
43
|
"require": "./dist/react/index.js",
|
|
43
|
-
"import": "./dist/react/index.mjs"
|
|
44
|
-
"types": "./dist/react/index.d.ts"
|
|
44
|
+
"import": "./dist/react/index.mjs"
|
|
45
45
|
},
|
|
46
46
|
"./register": {
|
|
47
|
+
"types": "./dist/manager.d.ts",
|
|
47
48
|
"require": "./dist/manager.js",
|
|
48
|
-
"import": "./dist/manager.mjs"
|
|
49
|
-
"types": "./dist/manager.d.ts"
|
|
49
|
+
"import": "./dist/manager.mjs"
|
|
50
50
|
},
|
|
51
51
|
"./package.json": "./package.json"
|
|
52
52
|
},
|
|
@@ -80,14 +80,14 @@
|
|
|
80
80
|
"prep": "../../../scripts/prepare/bundle.ts"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@storybook/client-logger": "7.0.
|
|
84
|
-
"@storybook/core-events": "7.0.
|
|
83
|
+
"@storybook/client-logger": "7.0.9",
|
|
84
|
+
"@storybook/core-events": "7.0.9",
|
|
85
85
|
"@storybook/csf": "^0.1.0",
|
|
86
86
|
"@storybook/global": "^5.0.0",
|
|
87
|
-
"@storybook/manager-api": "7.0.
|
|
88
|
-
"@storybook/preview-api": "7.0.
|
|
89
|
-
"@storybook/router": "7.0.
|
|
90
|
-
"@storybook/types": "7.0.
|
|
87
|
+
"@storybook/manager-api": "7.0.9",
|
|
88
|
+
"@storybook/preview-api": "7.0.9",
|
|
89
|
+
"@storybook/router": "7.0.9",
|
|
90
|
+
"@storybook/types": "7.0.9",
|
|
91
91
|
"prop-types": "^15.7.2",
|
|
92
92
|
"ts-dedent": "^2.0.0"
|
|
93
93
|
},
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
],
|
|
120
120
|
"post": "./scripts/fix-preview-api-reference.ts"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "797cfd6f12f94a65617c65f25b2d6546a689bf1b",
|
|
123
123
|
"storybook": {
|
|
124
124
|
"displayName": "Links",
|
|
125
125
|
"icon": "https://user-images.githubusercontent.com/263385/101991673-48355c80-3c7c-11eb-9b6e-b627c96a75f6.png",
|