@storybook/addon-links 11.0.0-alpha.5 → 11.0.0-alpha.7
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 +8 -9
- package/dist/_browser-chunks/{chunk-72HWH2ZD.js → chunk-3XKCRXNN.js} +3 -3
- package/dist/_browser-chunks/{chunk-2NZOTHER.js → chunk-5ZT4RZBZ.js} +1 -1
- package/dist/index.d.ts +2 -11
- package/dist/index.js +2 -2
- package/dist/preview.js +2 -2
- package/dist/react/index.d.ts +1 -3
- package/dist/react/index.js +6 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -70,9 +70,9 @@ export const index = () => (
|
|
|
70
70
|
<option>third</option>
|
|
71
71
|
</select>
|
|
72
72
|
);
|
|
73
|
-
export const first = () => <LinkTo
|
|
74
|
-
export const second = () => <LinkTo
|
|
75
|
-
export const third = () => <LinkTo
|
|
73
|
+
export const first = () => <LinkTo name="index">Go back</LinkTo>;
|
|
74
|
+
export const second = () => <LinkTo name="index">Go back</LinkTo>;
|
|
75
|
+
export const third = () => <LinkTo name="index">Go back</LinkTo>;
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
## hrefTo function
|
|
@@ -141,18 +141,17 @@ export default {
|
|
|
141
141
|
title: 'Link',
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
export const first = () => <LinkTo
|
|
145
|
-
export const second = () => <LinkTo
|
|
144
|
+
export const first = () => <LinkTo name="second">Go to Second</LinkTo>;
|
|
145
|
+
export const second = () => <LinkTo name="first">Go to First</LinkTo>;
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
It accepts all the props the `a` element does, plus `
|
|
148
|
+
It accepts all the props the `a` element does, plus `title` and `name`. If the `title` prop is omitted, the current component's title will be used.
|
|
149
149
|
|
|
150
150
|
```mdx
|
|
151
151
|
<LinkTo
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
title="Toggle"
|
|
153
|
+
name="off"
|
|
154
154
|
target="_blank"
|
|
155
|
-
title="link to second story"
|
|
156
155
|
style={{ color: '#1474f3' }}
|
|
157
156
|
>
|
|
158
157
|
Go to Second
|
|
@@ -23,13 +23,13 @@ var navigate = (params) => addons.getChannel().emit(SELECT_STORY, params), gener
|
|
|
23
23
|
resolve(generateStoryUrl(title, name));
|
|
24
24
|
}), hrefToSync = (title, name) => generateStoryUrl(title, name), valueOrCall = (args) => (value) => typeof value == "function" ? value(...args) : value, linkTo = (idOrTitle, nameInput) => (...args) => {
|
|
25
25
|
let resolver = valueOrCall(args), title = resolver(idOrTitle), name = nameInput ? resolver(nameInput) : !1;
|
|
26
|
-
title?.match(/--/) && !name ? navigate({ storyId: title }) : name && title ? navigate({
|
|
26
|
+
title?.match(/--/) && !name ? navigate({ storyId: title }) : name && title ? navigate({ title, name }) : title ? navigate({ title }) : name && navigate({ name });
|
|
27
27
|
}, linksListener = (e) => {
|
|
28
28
|
let { target } = e;
|
|
29
29
|
if (!(target instanceof HTMLElement))
|
|
30
30
|
return;
|
|
31
|
-
let element = target, { sbKind
|
|
32
|
-
(
|
|
31
|
+
let element = target, { sbKind, sbStory } = element.dataset;
|
|
32
|
+
(sbKind || sbStory) && (e.preventDefault(), navigate({ title: sbKind, name: sbStory }));
|
|
33
33
|
}, hasListener = !1, on = () => {
|
|
34
34
|
hasListener || (hasListener = !0, document.addEventListener("click", linksListener));
|
|
35
35
|
}, off = () => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import { ComponentTitle,
|
|
1
|
+
import { ComponentTitle, SelectStoryPayload, StoryName } from "storybook/internal/types";
|
|
2
2
|
|
|
3
3
|
//#region code/addons/links/.dts-emit/code/addons/links/src/utils.d.ts
|
|
4
|
-
|
|
5
|
-
storyId: StoryId;
|
|
6
|
-
}
|
|
7
|
-
interface ParamsCombo {
|
|
8
|
-
kind?: StoryKind;
|
|
9
|
-
title?: ComponentTitle;
|
|
10
|
-
story?: StoryName;
|
|
11
|
-
name?: StoryName;
|
|
12
|
-
}
|
|
13
|
-
declare const navigate: (params: ParamsId | ParamsCombo) => void;
|
|
4
|
+
declare const navigate: (params: SelectStoryPayload) => void;
|
|
14
5
|
declare const hrefTo: (title: ComponentTitle | undefined, name: StoryName) => Promise<string>;
|
|
15
6
|
declare const hrefToSync: (title: ComponentTitle | undefined, name: StoryName) => string;
|
|
16
7
|
declare const linkTo: (idOrTitle: string | ((...args: any[]) => string), nameInput?: string | ((...args: any[]) => string)) => (...args: any[]) => void;
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
index_default
|
|
3
|
-
} from "./_browser-chunks/chunk-
|
|
3
|
+
} from "./_browser-chunks/chunk-5ZT4RZBZ.js";
|
|
4
4
|
import {
|
|
5
5
|
hrefTo,
|
|
6
6
|
hrefToSync,
|
|
7
7
|
linkTo,
|
|
8
8
|
navigate,
|
|
9
9
|
withLinks
|
|
10
|
-
} from "./_browser-chunks/chunk-
|
|
10
|
+
} from "./_browser-chunks/chunk-3XKCRXNN.js";
|
|
11
11
|
import "./_browser-chunks/chunk-FX5LXYO2.js";
|
|
12
12
|
export {
|
|
13
13
|
index_default as default,
|
package/dist/preview.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decorators
|
|
3
|
-
} from "./_browser-chunks/chunk-
|
|
4
|
-
import "./_browser-chunks/chunk-
|
|
3
|
+
} from "./_browser-chunks/chunk-5ZT4RZBZ.js";
|
|
4
|
+
import "./_browser-chunks/chunk-3XKCRXNN.js";
|
|
5
5
|
import "./_browser-chunks/chunk-FX5LXYO2.js";
|
|
6
6
|
export {
|
|
7
7
|
decorators
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { ComponentTitle,
|
|
1
|
+
import { ComponentTitle, StoryName } from "storybook/internal/types";
|
|
2
2
|
import React, { PureComponent, ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
//#region code/addons/links/.dts-emit/code/addons/links/src/react/components/link.d.ts
|
|
5
5
|
interface Props {
|
|
6
|
-
kind?: StoryKind;
|
|
7
6
|
title?: ComponentTitle;
|
|
8
|
-
story?: StoryName;
|
|
9
7
|
name?: StoryName;
|
|
10
8
|
children: ReactNode;
|
|
11
9
|
}
|
package/dist/react/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hrefTo,
|
|
3
3
|
navigate
|
|
4
|
-
} from "../_browser-chunks/chunk-
|
|
4
|
+
} from "../_browser-chunks/chunk-3XKCRXNN.js";
|
|
5
5
|
import "../_browser-chunks/chunk-FX5LXYO2.js";
|
|
6
6
|
|
|
7
7
|
// src/react/components/link.tsx
|
|
@@ -16,14 +16,14 @@ var LEFT_BUTTON = 0, isPlainLeftClick = (e) => e.button === LEFT_BUTTON && !e.al
|
|
|
16
16
|
href: "/"
|
|
17
17
|
};
|
|
18
18
|
this.updateHref = async () => {
|
|
19
|
-
let {
|
|
19
|
+
let { title, name } = this.props;
|
|
20
20
|
if (title && name) {
|
|
21
21
|
let href = await hrefTo(title, name);
|
|
22
22
|
this.setState({ href });
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
this.handleClick = () => {
|
|
26
|
-
let {
|
|
26
|
+
let { title, name } = this.props;
|
|
27
27
|
title && name && navigate({ title, name });
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -31,11 +31,11 @@ var LEFT_BUTTON = 0, isPlainLeftClick = (e) => e.button === LEFT_BUTTON && !e.al
|
|
|
31
31
|
this.updateHref();
|
|
32
32
|
}
|
|
33
33
|
componentDidUpdate(prevProps) {
|
|
34
|
-
let {
|
|
35
|
-
(prevProps.
|
|
34
|
+
let { title, name } = this.props;
|
|
35
|
+
(prevProps.title !== title || prevProps.name !== name) && this.updateHref();
|
|
36
36
|
}
|
|
37
37
|
render() {
|
|
38
|
-
let {
|
|
38
|
+
let { title, name, children, ...rest } = this.props, { href } = this.state;
|
|
39
39
|
return React.createElement("a", { href, onClick: (e) => cancelled(e, this.handleClick), ...rest }, children);
|
|
40
40
|
}
|
|
41
41
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-links",
|
|
3
|
-
"version": "11.0.0-alpha.
|
|
3
|
+
"version": "11.0.0-alpha.7",
|
|
4
4
|
"description": "Storybook Links: Link stories together to build demos and prototypes with your UI components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@types/react": "^18.0.0 || ^19.0.0",
|
|
63
63
|
"react": "^18.0.0 || ^19.0.0",
|
|
64
|
-
"storybook": "^11.0.0-alpha.
|
|
64
|
+
"storybook": "^11.0.0-alpha.7"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@types/react": {
|