@storybook/addon-links 11.0.0-alpha.6 → 11.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/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 story="index">Go back</LinkTo>;
74
- export const second = () => <LinkTo story="index">Go back</LinkTo>;
75
- export const third = () => <LinkTo story="index">Go back</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 story="second">Go to Second</LinkTo>;
145
- export const second = () => <LinkTo story="first">Go to First</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 `story` and `kind`. It the `kind` prop is omitted, the current kind will be preserved.
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
- kind="Toggle"
153
- story="off"
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({ kind: title, story: name }) : title ? navigate({ kind: title }) : name && navigate({ story: name });
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: kind, sbStory: story } = element.dataset;
32
- (kind || story) && (e.preventDefault(), navigate({ kind, story }));
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 = () => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withLinks
3
- } from "./chunk-72HWH2ZD.js";
3
+ } from "./chunk-3XKCRXNN.js";
4
4
  import {
5
5
  __export
6
6
  } from "./chunk-FX5LXYO2.js";
package/dist/index.d.ts CHANGED
@@ -1,16 +1,7 @@
1
- import { ComponentTitle, StoryId, StoryKind, StoryName } from "storybook/internal/types";
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
- interface ParamsId {
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-2NZOTHER.js";
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-72HWH2ZD.js";
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-2NZOTHER.js";
4
- import "./_browser-chunks/chunk-72HWH2ZD.js";
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
@@ -1,11 +1,9 @@
1
- import { ComponentTitle, StoryKind, StoryName } from "storybook/internal/types";
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
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  hrefTo,
3
3
  navigate
4
- } from "../_browser-chunks/chunk-72HWH2ZD.js";
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 { kind, title = kind, story, name = story } = this.props;
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 { kind, title = kind, story, name = story } = this.props;
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 { kind, title, story, name } = this.props;
35
- (prevProps.kind !== kind || prevProps.story !== story || prevProps.title !== title || prevProps.name !== name) && this.updateHref();
34
+ let { title, name } = this.props;
35
+ (prevProps.title !== title || prevProps.name !== name) && this.updateHref();
36
36
  }
37
37
  render() {
38
- let { kind, title = kind, story, name = story, children, ...rest } = this.props, { href } = this.state;
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.6",
3
+ "version": "11.0.0-alpha.8",
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.6"
64
+ "storybook": "^11.0.0-alpha.8"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@types/react": {