@storybook/addon-links
Advanced tools
Comparing version 0.0.0-pr-28800-sha-2528064a to 0.0.0-pr-28882-sha-90fe4bc9
'use strict'; | ||
var global = require('@storybook/global'); | ||
var coreEvents = require('storybook/internal/core-events'); | ||
var previewApi = require('storybook/internal/preview-api'); | ||
var coreEvents = require('storybook/internal/core-events'); | ||
var csf = require('@storybook/csf'); | ||
var global = require('@storybook/global'); | ||
@@ -8,0 +8,0 @@ var PARAM_KEY="links";var{document,HTMLElement}=global.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=>previewApi.addons.getChannel().emit(coreEvents.SELECT_STORY,params),hrefTo=(title,name)=>new Promise(resolve=>{let{location}=document,existingId=parseQuery(location.search).id,titleToLink=title||existingId.split("--",2)[0],path=`/story/${csf.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=previewApi.makeDecorator({name:"withLinks",parameterName:PARAM_KEY,wrapper:(getStory,context)=>(on(),previewApi.addons.getChannel().once(coreEvents.STORY_CHANGED,off),getStory(context))}); |
'use strict'; | ||
var global = require('@storybook/global'); | ||
var coreEvents = require('storybook/internal/core-events'); | ||
var previewApi = require('storybook/internal/preview-api'); | ||
var coreEvents = require('storybook/internal/core-events'); | ||
require('@storybook/csf'); | ||
var global = require('@storybook/global'); | ||
@@ -8,0 +8,0 @@ var PARAM_KEY="links";var{document,HTMLElement}=global.global;var navigate=params=>previewApi.addons.getChannel().emit(coreEvents.SELECT_STORY,params);var 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=previewApi.makeDecorator({name:"withLinks",parameterName:PARAM_KEY,wrapper:(getStory,context)=>(on(),previewApi.addons.getChannel().once(coreEvents.STORY_CHANGED,off),getStory(context))});var decorators=[withLinks]; |
@@ -0,3 +1,3 @@ | ||
import React, { PureComponent, ReactNode } from 'react'; | ||
import { StoryKind, ComponentTitle, StoryName } from 'storybook/internal/types'; | ||
import React, { PureComponent, ReactNode } from 'react'; | ||
@@ -4,0 +4,0 @@ interface Props { |
'use strict'; | ||
var React = require('react'); | ||
var global = require('@storybook/global'); | ||
var coreEvents = require('storybook/internal/core-events'); | ||
var previewApi = require('storybook/internal/preview-api'); | ||
var coreEvents = require('storybook/internal/core-events'); | ||
var csf = require('@storybook/csf'); | ||
var global = require('@storybook/global'); | ||
@@ -9,0 +9,0 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } |
{ | ||
"name": "@storybook/addon-links", | ||
"version": "0.0.0-pr-28800-sha-2528064a", | ||
"version": "0.0.0-pr-28882-sha-90fe4bc9", | ||
"description": "Link stories together to build demos and prototypes with your UI components", | ||
@@ -27,5 +27,5 @@ "keywords": [ | ||
"types": "./dist/index.d.ts", | ||
"node": "./dist/index.js", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
"require": "./dist/index.js", | ||
"node": "./dist/index.js" | ||
}, | ||
@@ -67,4 +67,4 @@ "./react": { | ||
"scripts": { | ||
"check": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/check.ts", | ||
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/addon-bundle.ts" | ||
"check": "jiti ../../../scripts/prepare/check.ts", | ||
"prep": "jiti ../../../scripts/prepare/addon-bundle.ts" | ||
}, | ||
@@ -82,3 +82,3 @@ "dependencies": { | ||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0-beta", | ||
"storybook": "^0.0.0-pr-28800-sha-2528064a" | ||
"storybook": "^0.0.0-pr-28882-sha-90fe4bc9" | ||
}, | ||
@@ -85,0 +85,0 @@ "peerDependenciesMeta": { |
@@ -83,4 +83,4 @@ # Story Links Addon | ||
```js | ||
import { action } from '@storybook/addon-actions'; | ||
import { hrefTo } from '@storybook/addon-links'; | ||
import { action } from '@storybook/addon-actions'; | ||
@@ -87,0 +87,0 @@ export default { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
19020