@storybook/addon-links 9.2.0-alpha.3 → 10.0.0-beta.1
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/README.md +4 -2
- package/dist/_browser-chunks/chunk-5NYAPMFO.js +91 -0
- package/dist/_browser-chunks/chunk-76WYWG2V.js +25 -0
- package/dist/_browser-chunks/chunk-D24LJQWS.js +23 -0
- package/dist/index.js +17 -16
- package/dist/manager.js +12 -2
- package/dist/preview.js +8 -10
- package/dist/react/index.js +63 -13
- package/package.json +22 -49
- package/dist/chunk-DAF6YNFB.mjs +0 -8
- package/dist/index.mjs +0 -7
- package/dist/preview.mjs +0 -8
- package/dist/react/index.mjs +0 -6
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Story Links Addon
|
|
2
2
|
|
|
3
|
-
The Storybook Links addon can be used to create links that navigate between stories in [Storybook](https://storybook.js.org).
|
|
3
|
+
The Storybook Links addon can be used to create links that navigate between stories in [Storybook](https://storybook.js.org?ref=readme).
|
|
4
4
|
|
|
5
|
-
[Framework Support](https://storybook.js.org/docs/configure/integration/frameworks-feature-support)
|
|
5
|
+
[Framework Support](https://storybook.js.org/docs/configure/integration/frameworks-feature-support?ref=readme)
|
|
6
6
|
|
|
7
7
|
## Getting Started
|
|
8
8
|
|
|
@@ -145,3 +145,5 @@ It accepts all the props the `a` element does, plus `story` and `kind`. It the `
|
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
To implement such a component for another framework, you need to add special handling for `click` event on native `a` element. See [`RoutedLink` sources](https://github.com/storybookjs/storybook/blob/next/code/addons/links/src/react/components/RoutedLink.tsx) for reference.
|
|
148
|
+
|
|
149
|
+
Learn more about Storybook at [storybook.js.org](https://storybook.js.org/?ref=readme).
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PARAM_KEY,
|
|
3
|
+
__name
|
|
4
|
+
} from "./chunk-D24LJQWS.js";
|
|
5
|
+
|
|
6
|
+
// src/utils.ts
|
|
7
|
+
import { SELECT_STORY, STORY_CHANGED } from "storybook/internal/core-events";
|
|
8
|
+
import { toId } from "storybook/internal/csf";
|
|
9
|
+
import { global } from "@storybook/global";
|
|
10
|
+
import { addons, makeDecorator } from "storybook/preview-api";
|
|
11
|
+
var { document, HTMLElement } = global;
|
|
12
|
+
function parseQuery(queryString) {
|
|
13
|
+
const query = {};
|
|
14
|
+
const pairs = (queryString[0] === "?" ? queryString.substring(1) : queryString).split("&").filter(Boolean);
|
|
15
|
+
for (let i = 0; i < pairs.length; i++) {
|
|
16
|
+
const pair = pairs[i].split("=");
|
|
17
|
+
query[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1] || "");
|
|
18
|
+
}
|
|
19
|
+
return query;
|
|
20
|
+
}
|
|
21
|
+
__name(parseQuery, "parseQuery");
|
|
22
|
+
var navigate = /* @__PURE__ */ __name((params) => addons.getChannel().emit(SELECT_STORY, params), "navigate");
|
|
23
|
+
var hrefTo = /* @__PURE__ */ __name((title, name) => {
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
const { location } = document;
|
|
26
|
+
const query = parseQuery(location.search);
|
|
27
|
+
const existingId = query.id;
|
|
28
|
+
const titleToLink = title || existingId.split("--", 2)[0];
|
|
29
|
+
const id = toId(titleToLink, name);
|
|
30
|
+
const path = `/story/${id}`;
|
|
31
|
+
const sbPath = location.pathname.replace(/iframe\.html$/, "");
|
|
32
|
+
const url = `${location.origin + sbPath}?${Object.entries({ path }).map((item) => `${item[0]}=${item[1]}`).join("&")}`;
|
|
33
|
+
resolve(url);
|
|
34
|
+
});
|
|
35
|
+
}, "hrefTo");
|
|
36
|
+
var valueOrCall = /* @__PURE__ */ __name((args) => (value) => typeof value === "function" ? value(...args) : value, "valueOrCall");
|
|
37
|
+
var linkTo = /* @__PURE__ */ __name((idOrTitle, nameInput) => (...args) => {
|
|
38
|
+
const resolver = valueOrCall(args);
|
|
39
|
+
const title = resolver(idOrTitle);
|
|
40
|
+
const name = nameInput ? resolver(nameInput) : false;
|
|
41
|
+
if (title?.match(/--/) && !name) {
|
|
42
|
+
navigate({ storyId: title });
|
|
43
|
+
} else if (name && title) {
|
|
44
|
+
navigate({ kind: title, story: name });
|
|
45
|
+
} else if (title) {
|
|
46
|
+
navigate({ kind: title });
|
|
47
|
+
} else if (name) {
|
|
48
|
+
navigate({ story: name });
|
|
49
|
+
}
|
|
50
|
+
}, "linkTo");
|
|
51
|
+
var linksListener = /* @__PURE__ */ __name((e) => {
|
|
52
|
+
const { target } = e;
|
|
53
|
+
if (!(target instanceof HTMLElement)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const element = target;
|
|
57
|
+
const { sbKind: kind, sbStory: story } = element.dataset;
|
|
58
|
+
if (kind || story) {
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
navigate({ kind, story });
|
|
61
|
+
}
|
|
62
|
+
}, "linksListener");
|
|
63
|
+
var hasListener = false;
|
|
64
|
+
var on = /* @__PURE__ */ __name(() => {
|
|
65
|
+
if (!hasListener) {
|
|
66
|
+
hasListener = true;
|
|
67
|
+
document.addEventListener("click", linksListener);
|
|
68
|
+
}
|
|
69
|
+
}, "on");
|
|
70
|
+
var off = /* @__PURE__ */ __name(() => {
|
|
71
|
+
if (hasListener) {
|
|
72
|
+
hasListener = false;
|
|
73
|
+
document.removeEventListener("click", linksListener);
|
|
74
|
+
}
|
|
75
|
+
}, "off");
|
|
76
|
+
var withLinks = makeDecorator({
|
|
77
|
+
name: "withLinks",
|
|
78
|
+
parameterName: PARAM_KEY,
|
|
79
|
+
wrapper: /* @__PURE__ */ __name((getStory, context) => {
|
|
80
|
+
on();
|
|
81
|
+
addons.getChannel().once(STORY_CHANGED, off);
|
|
82
|
+
return getStory(context);
|
|
83
|
+
}, "wrapper")
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
navigate,
|
|
88
|
+
hrefTo,
|
|
89
|
+
linkTo,
|
|
90
|
+
withLinks
|
|
91
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withLinks
|
|
3
|
+
} from "./chunk-5NYAPMFO.js";
|
|
4
|
+
import {
|
|
5
|
+
__export,
|
|
6
|
+
__name
|
|
7
|
+
} from "./chunk-D24LJQWS.js";
|
|
8
|
+
|
|
9
|
+
// src/preview.ts
|
|
10
|
+
var preview_exports = {};
|
|
11
|
+
__export(preview_exports, {
|
|
12
|
+
decorators: () => decorators
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// src/index.ts
|
|
16
|
+
import { definePreviewAddon } from "storybook/internal/csf";
|
|
17
|
+
var index_default = /* @__PURE__ */ __name(() => definePreviewAddon(preview_exports), "default");
|
|
18
|
+
|
|
19
|
+
// src/preview.ts
|
|
20
|
+
var decorators = [withLinks];
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
decorators,
|
|
24
|
+
index_default
|
|
25
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// src/constants.ts
|
|
9
|
+
var ADDON_ID = "storybook/links";
|
|
10
|
+
var PARAM_KEY = `links`;
|
|
11
|
+
var constants_default = {
|
|
12
|
+
NAVIGATE: `${ADDON_ID}/navigate`,
|
|
13
|
+
REQUEST: `${ADDON_ID}/request`,
|
|
14
|
+
RECEIVE: `${ADDON_ID}/receive`
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
__name,
|
|
19
|
+
__export,
|
|
20
|
+
ADDON_ID,
|
|
21
|
+
PARAM_KEY,
|
|
22
|
+
constants_default
|
|
23
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import {
|
|
2
|
+
index_default
|
|
3
|
+
} from "./_browser-chunks/chunk-76WYWG2V.js";
|
|
4
|
+
import {
|
|
5
|
+
hrefTo,
|
|
6
|
+
linkTo,
|
|
7
|
+
navigate,
|
|
8
|
+
withLinks
|
|
9
|
+
} from "./_browser-chunks/chunk-5NYAPMFO.js";
|
|
10
|
+
import "./_browser-chunks/chunk-D24LJQWS.js";
|
|
11
|
+
export {
|
|
12
|
+
index_default as default,
|
|
13
|
+
hrefTo,
|
|
14
|
+
linkTo,
|
|
15
|
+
navigate,
|
|
16
|
+
withLinks
|
|
17
|
+
};
|
package/dist/manager.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ADDON_ID,
|
|
3
|
+
constants_default
|
|
4
|
+
} from "./_browser-chunks/chunk-D24LJQWS.js";
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
// src/manager.ts
|
|
7
|
+
import { addons } from "storybook/manager-api";
|
|
8
|
+
addons.register(ADDON_ID, (api) => {
|
|
9
|
+
api.on(constants_default.REQUEST, ({ kind, name }) => {
|
|
10
|
+
const id = api.storyId(kind, name);
|
|
11
|
+
api.emit(constants_default.RECEIVE, id);
|
|
12
|
+
});
|
|
13
|
+
});
|
package/dist/preview.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.decorators = decorators;
|
|
1
|
+
import {
|
|
2
|
+
decorators
|
|
3
|
+
} from "./_browser-chunks/chunk-76WYWG2V.js";
|
|
4
|
+
import "./_browser-chunks/chunk-5NYAPMFO.js";
|
|
5
|
+
import "./_browser-chunks/chunk-D24LJQWS.js";
|
|
6
|
+
export {
|
|
7
|
+
decorators
|
|
8
|
+
};
|
package/dist/react/index.js
CHANGED
|
@@ -1,15 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
hrefTo,
|
|
3
|
+
navigate
|
|
4
|
+
} from "../_browser-chunks/chunk-5NYAPMFO.js";
|
|
5
|
+
import {
|
|
6
|
+
__name
|
|
7
|
+
} from "../_browser-chunks/chunk-D24LJQWS.js";
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
9
|
+
// src/react/components/link.tsx
|
|
10
|
+
import React, { PureComponent } from "react";
|
|
11
|
+
var LEFT_BUTTON = 0;
|
|
12
|
+
var isPlainLeftClick = /* @__PURE__ */ __name((e) => e.button === LEFT_BUTTON && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey, "isPlainLeftClick");
|
|
13
|
+
var cancelled = /* @__PURE__ */ __name((e, cb = (_e) => {
|
|
14
|
+
}) => {
|
|
15
|
+
if (isPlainLeftClick(e)) {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
cb(e);
|
|
18
|
+
}
|
|
19
|
+
}, "cancelled");
|
|
20
|
+
var _LinkTo = class _LinkTo extends PureComponent {
|
|
21
|
+
constructor() {
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.state = {
|
|
24
|
+
href: "/"
|
|
25
|
+
};
|
|
26
|
+
this.updateHref = /* @__PURE__ */ __name(async () => {
|
|
27
|
+
const { kind, title = kind, story, name = story } = this.props;
|
|
28
|
+
if (title && name) {
|
|
29
|
+
const href = await hrefTo(title, name);
|
|
30
|
+
this.setState({ href });
|
|
31
|
+
}
|
|
32
|
+
}, "updateHref");
|
|
33
|
+
this.handleClick = /* @__PURE__ */ __name(() => {
|
|
34
|
+
const { kind, title = kind, story, name = story } = this.props;
|
|
35
|
+
if (title && name) {
|
|
36
|
+
navigate({ title, name });
|
|
37
|
+
}
|
|
38
|
+
}, "handleClick");
|
|
39
|
+
}
|
|
40
|
+
componentDidMount() {
|
|
41
|
+
this.updateHref();
|
|
42
|
+
}
|
|
43
|
+
componentDidUpdate(prevProps) {
|
|
44
|
+
const { kind, title, story, name } = this.props;
|
|
45
|
+
if (prevProps.kind !== kind || prevProps.story !== story || prevProps.title !== title || prevProps.name !== name) {
|
|
46
|
+
this.updateHref();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
render() {
|
|
50
|
+
const { kind, title = kind, story, name = story, children, ...rest } = this.props;
|
|
51
|
+
const { href } = this.state;
|
|
52
|
+
return React.createElement("a", { href, onClick: (e) => cancelled(e, this.handleClick), ...rest }, children);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
__name(_LinkTo, "LinkTo");
|
|
56
|
+
_LinkTo.defaultProps = {
|
|
57
|
+
children: void 0
|
|
58
|
+
};
|
|
59
|
+
var LinkTo = _LinkTo;
|
|
8
60
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
module.exports = react_default;
|
|
61
|
+
// src/react/index.ts
|
|
62
|
+
var react_default = LinkTo;
|
|
63
|
+
export {
|
|
64
|
+
react_default as default
|
|
65
|
+
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-links",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Link stories together to build demos and prototypes with your UI components",
|
|
3
|
+
"version": "10.0.0-beta.1",
|
|
4
|
+
"description": "Storybook Links: Link stories together to build demos and prototypes with your UI components",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"storybook
|
|
7
|
-
"
|
|
6
|
+
"storybook",
|
|
7
|
+
"storybook-addon",
|
|
8
|
+
"organize",
|
|
9
|
+
"links",
|
|
10
|
+
"navigation",
|
|
11
|
+
"component",
|
|
12
|
+
"components"
|
|
8
13
|
],
|
|
9
14
|
"homepage": "https://github.com/storybookjs/storybook/tree/next/code/addons/links",
|
|
10
15
|
"bugs": {
|
|
@@ -20,40 +25,21 @@
|
|
|
20
25
|
"url": "https://opencollective.com/storybook"
|
|
21
26
|
},
|
|
22
27
|
"license": "MIT",
|
|
28
|
+
"type": "module",
|
|
23
29
|
"exports": {
|
|
24
30
|
".": {
|
|
25
31
|
"types": "./dist/index.d.ts",
|
|
26
|
-
"
|
|
27
|
-
"require": "./dist/index.js"
|
|
28
|
-
},
|
|
29
|
-
"./react": {
|
|
30
|
-
"types": "./dist/react/index.d.ts",
|
|
31
|
-
"import": "./dist/react/index.mjs",
|
|
32
|
-
"require": "./dist/react/index.js"
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
33
|
},
|
|
34
|
+
"./manager": "./dist/manager.js",
|
|
35
|
+
"./package.json": "./package.json",
|
|
34
36
|
"./preview": {
|
|
35
37
|
"types": "./dist/preview.d.ts",
|
|
36
|
-
"
|
|
37
|
-
"require": "./dist/preview.js"
|
|
38
|
+
"default": "./dist/preview.js"
|
|
38
39
|
},
|
|
39
|
-
"./
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
"main": "dist/index.js",
|
|
44
|
-
"module": "dist/index.mjs",
|
|
45
|
-
"types": "dist/index.d.ts",
|
|
46
|
-
"typesVersions": {
|
|
47
|
-
"*": {
|
|
48
|
-
"*": [
|
|
49
|
-
"dist/index.d.ts"
|
|
50
|
-
],
|
|
51
|
-
"preview": [
|
|
52
|
-
"dist/preview.d.ts"
|
|
53
|
-
],
|
|
54
|
-
"react": [
|
|
55
|
-
"dist/react/index.d.ts"
|
|
56
|
-
]
|
|
40
|
+
"./react": {
|
|
41
|
+
"types": "./dist/react/index.d.ts",
|
|
42
|
+
"default": "./dist/react/index.js"
|
|
57
43
|
}
|
|
58
44
|
},
|
|
59
45
|
"files": [
|
|
@@ -64,8 +50,8 @@
|
|
|
64
50
|
"!src/**/*"
|
|
65
51
|
],
|
|
66
52
|
"scripts": {
|
|
67
|
-
"check": "jiti ../../../scripts/
|
|
68
|
-
"prep": "jiti ../../../scripts/
|
|
53
|
+
"check": "jiti ../../../scripts/check/check-package.ts",
|
|
54
|
+
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
69
55
|
},
|
|
70
56
|
"dependencies": {
|
|
71
57
|
"@storybook/global": "^5.0.0"
|
|
@@ -74,8 +60,8 @@
|
|
|
74
60
|
"typescript": "^5.8.3"
|
|
75
61
|
},
|
|
76
62
|
"peerDependencies": {
|
|
77
|
-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
|
78
|
-
"storybook": "^
|
|
63
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
64
|
+
"storybook": "^10.0.0-beta.1"
|
|
79
65
|
},
|
|
80
66
|
"peerDependenciesMeta": {
|
|
81
67
|
"react": {
|
|
@@ -85,20 +71,7 @@
|
|
|
85
71
|
"publishConfig": {
|
|
86
72
|
"access": "public"
|
|
87
73
|
},
|
|
88
|
-
"
|
|
89
|
-
"exportEntries": [
|
|
90
|
-
"./src/react/index.ts",
|
|
91
|
-
"./src/index.ts"
|
|
92
|
-
],
|
|
93
|
-
"managerEntries": [
|
|
94
|
-
"./src/manager.ts"
|
|
95
|
-
],
|
|
96
|
-
"previewEntries": [
|
|
97
|
-
"./src/preview.ts"
|
|
98
|
-
],
|
|
99
|
-
"post": "./scripts/fix-preview-api-reference.ts"
|
|
100
|
-
},
|
|
101
|
-
"gitHead": "ce6a1e4a8d5ad69c699021a0b183df89cfc7b684",
|
|
74
|
+
"gitHead": "a8e7fd8a655c69780bc20b9749d2699e45beae16",
|
|
102
75
|
"storybook": {
|
|
103
76
|
"displayName": "Links",
|
|
104
77
|
"icon": "https://user-images.githubusercontent.com/263385/101991673-48355c80-3c7c-11eb-9b6e-b627c96a75f6.png",
|
package/dist/chunk-DAF6YNFB.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { STORY_CHANGED, SELECT_STORY } from 'storybook/internal/core-events';
|
|
2
|
-
import { toId } from 'storybook/internal/csf';
|
|
3
|
-
import { global } from '@storybook/global';
|
|
4
|
-
import { makeDecorator, addons } from 'storybook/preview-api';
|
|
5
|
-
|
|
6
|
-
var __defProp=Object.defineProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0});};var PARAM_KEY="links";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,existingId=parseQuery(location.search).id,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))});
|
|
7
|
-
|
|
8
|
-
export { __export, hrefTo, linkTo, navigate, withLinks };
|
package/dist/index.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { __export, withLinks } from './chunk-DAF6YNFB.mjs';
|
|
2
|
-
export { hrefTo, linkTo, navigate, withLinks } from './chunk-DAF6YNFB.mjs';
|
|
3
|
-
import { definePreviewAddon } from 'storybook/internal/csf';
|
|
4
|
-
|
|
5
|
-
var preview_exports={};__export(preview_exports,{decorators:()=>decorators});var decorators=[withLinks];var index_default=()=>definePreviewAddon(preview_exports);
|
|
6
|
-
|
|
7
|
-
export { index_default as default };
|
package/dist/preview.mjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import 'storybook/internal/csf';
|
|
2
|
-
import { STORY_CHANGED, SELECT_STORY } from 'storybook/internal/core-events';
|
|
3
|
-
import { global } from '@storybook/global';
|
|
4
|
-
import { makeDecorator, addons } from 'storybook/preview-api';
|
|
5
|
-
|
|
6
|
-
var PARAM_KEY="links";var{document,HTMLElement}=global;var navigate=params=>addons.getChannel().emit(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=makeDecorator({name:"withLinks",parameterName:PARAM_KEY,wrapper:(getStory,context)=>(on(),addons.getChannel().once(STORY_CHANGED,off),getStory(context))});var decorators=[withLinks];
|
|
7
|
-
|
|
8
|
-
export { decorators };
|
package/dist/react/index.mjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { hrefTo, navigate } from '../chunk-DAF6YNFB.mjs';
|
|
2
|
-
import React, { PureComponent } from 'react';
|
|
3
|
-
|
|
4
|
-
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;
|
|
5
|
-
|
|
6
|
-
export { react_default as default };
|