@storybook/preact 7.0.0-alpha.3 → 7.0.0-alpha.30

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ import*as e from"preact";import{dedent as s}from"ts-dedent";var p;function i(r,t){e.Fragment?e.render(r,t):p=e.render(r,t,p)}var l=({showError:r,name:t,title:o,storyFn:a,domElement:m})=>{let n=e.h(a,null);return n||(r({title:`Expecting a Preact element from the story: "${t}" of "${o}".`,description:s`
2
+ Did you forget to return the Preact element from the story?
3
+ Use "() => (<MyComp/>)" or "() => { return <MyComp/>; }" when defining the story.
4
+ `}),null)};function d({storyFn:r,title:t,name:o,showMain:a,showError:m,forceRemount:n},c){n&&i(null,c),a(),i(e.h(l,{name:o,title:t,showError:m,storyFn:r,domElement:c}),c)}export{d as a};
@@ -0,0 +1,11 @@
1
+ import { RenderContext } from '@storybook/store';
2
+ import { P as PreactFramework } from './types-ed8e97dc.js';
3
+ import 'preact';
4
+
5
+ declare function renderToDOM({ storyFn, title, name, showMain, showError, forceRemount }: RenderContext<PreactFramework>, domElement: Element): void;
6
+
7
+ declare const parameters: {
8
+ framework: "preact";
9
+ };
10
+
11
+ export { parameters, renderToDOM };
package/dist/config.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";var d=Object.create;var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var x=(e,r)=>{for(var t in r)c(e,t,{get:r[t],enumerable:!0})},s=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of h(r))!F.call(e,n)&&n!==t&&c(e,n,{get:()=>r[n],enumerable:!(a=u(r,n))||a.enumerable});return e};var E=(e,r,t)=>(t=e!=null?d(w(e)):{},s(r||!e||!e.__esModule?c(t,"default",{value:e,enumerable:!0}):t,e)),P=e=>s(c({},"__esModule",{value:!0}),e);var C={};x(C,{parameters:()=>k,renderToDOM:()=>f});module.exports=P(C);var o=E(require("preact")),y=require("ts-dedent"),i;function l(e,r){o.Fragment?o.render(e,r):i=o.render(e,r,i)}var g=({showError:e,name:r,title:t,storyFn:a,domElement:n})=>{let p=o.h(a,null);return p||(e({title:`Expecting a Preact element from the story: "${r}" of "${t}".`,description:y.dedent`
2
+ Did you forget to return the Preact element from the story?
3
+ Use "() => (<MyComp/>)" or "() => { return <MyComp/>; }" when defining the story.
4
+ `}),null)};function f({storyFn:e,title:r,name:t,showMain:a,showError:n,forceRemount:p},m){p&&l(null,m),a(),l(o.h(g,{name:t,title:r,showError:n,storyFn:e,domElement:m}),m)}var k={framework:"preact"};0&&(module.exports={parameters,renderToDOM});
@@ -0,0 +1 @@
1
+ import{a as r}from"./chunk-5JPFR37Q.mjs";var o={framework:"preact"};export{o as parameters,r as renderToDOM};
@@ -0,0 +1,51 @@
1
+ import { ClientStoryApi, Loadable } from '@storybook/addons';
2
+ import { P as PreactFramework, I as IStorybookSection } from './types-ed8e97dc.js';
3
+ import { Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations } from '@storybook/csf';
4
+ export { ArgTypes, Args, Parameters, StoryContext } from '@storybook/csf';
5
+ import 'preact';
6
+
7
+ interface ClientApi extends ClientStoryApi<PreactFramework['storyResult']> {
8
+ setAddon(addon: any): void;
9
+ configure(loader: Loadable, module: NodeModule): void;
10
+ getStorybook(): IStorybookSection[];
11
+ clearDecorators(): void;
12
+ forceReRender(): void;
13
+ raw: () => any;
14
+ load: (...args: any[]) => void;
15
+ }
16
+ declare const storiesOf: ClientApi['storiesOf'];
17
+ declare const configure: ClientApi['configure'];
18
+ declare const addDecorator: ClientApi['addDecorator'];
19
+ declare const addParameters: ClientApi['addParameters'];
20
+ declare const clearDecorators: ClientApi['clearDecorators'];
21
+ declare const setAddon: ClientApi['setAddon'];
22
+ declare const forceReRender: ClientApi['forceReRender'];
23
+ declare const getStorybook: ClientApi['getStorybook'];
24
+ declare const raw: ClientApi['raw'];
25
+
26
+ /**
27
+ * Metadata to configure the stories for a component.
28
+ *
29
+ * @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
30
+ */
31
+ declare type Meta<TArgs = Args> = ComponentAnnotations<PreactFramework, TArgs>;
32
+ /**
33
+ * Story function that represents a CSFv2 component example.
34
+ *
35
+ * @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
36
+ */
37
+ declare type StoryFn<TArgs = Args> = AnnotatedStoryFn<PreactFramework, TArgs>;
38
+ /**
39
+ * Story function that represents a CSFv3 component example.
40
+ *
41
+ * @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
42
+ */
43
+ declare type StoryObj<TArgs = Args> = StoryAnnotations<PreactFramework, TArgs>;
44
+ /**
45
+ * Story function that represents a CSFv3 component example.
46
+ *
47
+ * @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
48
+ */
49
+ declare type Story<TArgs = Args> = StoryObj<TArgs>;
50
+
51
+ export { ClientApi, Meta, Story, StoryFn, StoryObj, addDecorator, addParameters, clearDecorators, configure, forceReRender, getStorybook, raw, setAddon, storiesOf };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";var w=Object.create;var p=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var D=(e,r)=>{for(var t in r)p(e,t,{get:r[t],enumerable:!0})},s=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of S(r))!b.call(e,n)&&n!==t&&p(e,n,{get:()=>r[n],enumerable:!(i=k(r,n))||i.enumerable});return e};var l=(e,r,t)=>(t=e!=null?w(P(e)):{},s(r||!e||!e.__esModule?p(t,"default",{value:e,enumerable:!0}):t,e)),F=e=>s(p({},"__esModule",{value:!0}),e);var W={};D(W,{addDecorator:()=>v,addParameters:()=>M,clearDecorators:()=>T,configure:()=>E,forceReRender:()=>K,getStorybook:()=>L,raw:()=>N,setAddon:()=>I,storiesOf:()=>O});module.exports=F(W);var f=l(require("global")),{window:m}=f.default;m&&(m.STORYBOOK_ENV="preact");var x=require("@storybook/core-client");var a=l(require("preact")),u=require("ts-dedent"),y;function A(e,r){a.Fragment?a.render(e,r):y=a.render(e,r,y)}var h=({showError:e,name:r,title:t,storyFn:i,domElement:n})=>{let c=a.h(i,null);return c||(e({title:`Expecting a Preact element from the story: "${r}" of "${t}".`,description:u.dedent`
2
+ Did you forget to return the Preact element from the story?
3
+ Use "() => (<MyComp/>)" or "() => { return <MyComp/>; }" when defining the story.
4
+ `}),null)};function C({storyFn:e,title:r,name:t,showMain:i,showError:n,forceRemount:c},d){c&&A(null,d),i(),A(a.h(h,{name:t,title:r,showError:n,storyFn:e,domElement:d}),d)}var R="preact",o=(0,x.start)(C),O=(e,r)=>o.clientApi.storiesOf(e,r).addParameters({framework:R}),E=(...e)=>o.configure(R,...e),v=o.clientApi.addDecorator,M=o.clientApi.addParameters,T=o.clientApi.clearDecorators,I=o.clientApi.setAddon,K=o.forceReRender,L=o.clientApi.getStorybook,N=o.clientApi.raw;var g;(g=module==null?void 0:module.hot)==null||g.decline();0&&(module.exports={addDecorator,addParameters,clearDecorators,configure,forceReRender,getStorybook,raw,setAddon,storiesOf});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-5JPFR37Q.mjs";import s from"global";var{window:n}=s;n&&(n.STORYBOOK_ENV="preact");import{start as p}from"@storybook/core-client";var a="preact",o=p(e),l=(r,i)=>o.clientApi.storiesOf(r,i).addParameters({framework:a}),m=(...r)=>o.configure(a,...r),y=o.clientApi.addDecorator,f=o.clientApi.addParameters,g=o.clientApi.clearDecorators,x=o.clientApi.setAddon,S=o.forceReRender,C=o.clientApi.getStorybook,k=o.clientApi.raw;module?.hot?.decline();export{y as addDecorator,f as addParameters,g as clearDecorators,m as configure,S as forceReRender,C as getStorybook,k as raw,x as setAddon,l as storiesOf};
@@ -0,0 +1,17 @@
1
+ import { AnyComponent } from 'preact';
2
+
3
+ declare type StoryFnPreactReturnType = string | Node | preact.JSX.Element;
4
+ interface IStorybookStory {
5
+ name: string;
6
+ render: (context: any) => any;
7
+ }
8
+ interface IStorybookSection {
9
+ kind: string;
10
+ stories: IStorybookStory[];
11
+ }
12
+ declare type PreactFramework = {
13
+ component: AnyComponent<any, any>;
14
+ storyResult: StoryFnPreactReturnType;
15
+ };
16
+
17
+ export { IStorybookSection as I, PreactFramework as P };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/preact",
3
- "version": "7.0.0-alpha.3",
3
+ "version": "7.0.0-alpha.30",
4
4
  "description": "Storybook Preact renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -19,9 +19,26 @@
19
19
  "url": "https://opencollective.com/storybook"
20
20
  },
21
21
  "license": "MIT",
22
- "main": "dist/cjs/index.js",
23
- "module": "dist/esm/index.js",
24
- "types": "dist/types/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "require": "./dist/index.js",
25
+ "import": "./dist/index.mjs",
26
+ "types": "./dist/index.d.ts"
27
+ },
28
+ "./preview": {
29
+ "require": "./dist/config.js",
30
+ "import": "./dist/config.mjs",
31
+ "types": "./dist/config.d.ts"
32
+ },
33
+ "./package.json": {
34
+ "require": "./package.json",
35
+ "import": "./package.json",
36
+ "types": "./package.json"
37
+ }
38
+ },
39
+ "main": "dist/index.js",
40
+ "module": "dist/index.mjs",
41
+ "types": "dist/index.d.ts",
25
42
  "files": [
26
43
  "dist/**/*",
27
44
  "README.md",
@@ -29,22 +46,22 @@
29
46
  "*.d.ts"
30
47
  ],
31
48
  "scripts": {
32
- "prepare": "node ../../scripts/prepare.js"
49
+ "check": "tsc --noEmit",
50
+ "prepare": "../../../scripts/prepare/bundle.ts"
33
51
  },
34
52
  "dependencies": {
35
- "@storybook/addons": "7.0.0-alpha.3",
36
- "@storybook/core-client": "7.0.0-alpha.3",
37
- "@storybook/csf": "0.0.2--canary.4566f4d.1",
38
- "@storybook/store": "7.0.0-alpha.3",
39
- "core-js": "^3.8.2",
53
+ "@storybook/addons": "7.0.0-alpha.30",
54
+ "@storybook/core-client": "7.0.0-alpha.30",
55
+ "@storybook/csf": "0.0.2--canary.0899bb7.0",
56
+ "@storybook/store": "7.0.0-alpha.30",
40
57
  "global": "^4.4.0",
41
58
  "react": "16.14.0",
42
59
  "react-dom": "16.14.0",
43
- "regenerator-runtime": "^0.13.7",
44
60
  "ts-dedent": "^2.0.0"
45
61
  },
46
62
  "devDependencies": {
47
- "preact": "^10.5.13"
63
+ "preact": "^10.5.13",
64
+ "typescript": "~4.6.3"
48
65
  },
49
66
  "peerDependencies": {
50
67
  "preact": "^8.0.0||^10.0.0"
@@ -55,5 +72,12 @@
55
72
  "publishConfig": {
56
73
  "access": "public"
57
74
  },
58
- "gitHead": "629b056190993bcee6445471b8cb27208eb401a9"
75
+ "bundler": {
76
+ "entries": [
77
+ "./src/index.ts",
78
+ "./src/config.ts"
79
+ ],
80
+ "platform": "browser"
81
+ },
82
+ "gitHead": "aabf7b595cb13d8a86dca27ad3d6039205bd55d6"
59
83
  }
package/preview.js CHANGED
@@ -1 +1 @@
1
- export * from './dist/esm/preview/config';
1
+ export * from './dist/config';
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 Kadira Inc. <hello@kadira.io>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
package/dist/cjs/index.js DELETED
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- storiesOf: true,
8
- setAddon: true,
9
- addDecorator: true,
10
- addParameters: true,
11
- configure: true,
12
- getStorybook: true,
13
- forceReRender: true,
14
- raw: true
15
- };
16
- Object.defineProperty(exports, "addDecorator", {
17
- enumerable: true,
18
- get: function () {
19
- return _preview.addDecorator;
20
- }
21
- });
22
- Object.defineProperty(exports, "addParameters", {
23
- enumerable: true,
24
- get: function () {
25
- return _preview.addParameters;
26
- }
27
- });
28
- Object.defineProperty(exports, "configure", {
29
- enumerable: true,
30
- get: function () {
31
- return _preview.configure;
32
- }
33
- });
34
- Object.defineProperty(exports, "forceReRender", {
35
- enumerable: true,
36
- get: function () {
37
- return _preview.forceReRender;
38
- }
39
- });
40
- Object.defineProperty(exports, "getStorybook", {
41
- enumerable: true,
42
- get: function () {
43
- return _preview.getStorybook;
44
- }
45
- });
46
- Object.defineProperty(exports, "raw", {
47
- enumerable: true,
48
- get: function () {
49
- return _preview.raw;
50
- }
51
- });
52
- Object.defineProperty(exports, "setAddon", {
53
- enumerable: true,
54
- get: function () {
55
- return _preview.setAddon;
56
- }
57
- });
58
- Object.defineProperty(exports, "storiesOf", {
59
- enumerable: true,
60
- get: function () {
61
- return _preview.storiesOf;
62
- }
63
- });
64
-
65
- var _preview = require("./preview");
66
-
67
- var _types = require("./preview/types-6-0");
68
-
69
- Object.keys(_types).forEach(function (key) {
70
- if (key === "default" || key === "__esModule") return;
71
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
72
- if (key in exports && exports[key] === _types[key]) return;
73
- Object.defineProperty(exports, key, {
74
- enumerable: true,
75
- get: function () {
76
- return _types[key];
77
- }
78
- });
79
- });
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.parameters = void 0;
7
- Object.defineProperty(exports, "renderToDOM", {
8
- enumerable: true,
9
- get: function () {
10
- return _render.renderToDOM;
11
- }
12
- });
13
-
14
- var _render = require("./render");
15
-
16
- const parameters = {
17
- framework: 'preact'
18
- };
19
- exports.parameters = parameters;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- var _global = _interopRequireDefault(require("global"));
4
-
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
-
7
- const {
8
- window: globalWindow
9
- } = _global.default;
10
-
11
- if (globalWindow) {
12
- globalWindow.STORYBOOK_ENV = 'preact';
13
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.storiesOf = exports.setAddon = exports.raw = exports.getStorybook = exports.forceReRender = exports.configure = exports.clearDecorators = exports.addParameters = exports.addDecorator = void 0;
7
-
8
- var _coreClient = require("@storybook/core-client");
9
-
10
- require("./globals");
11
-
12
- var _render = require("./render");
13
-
14
- /* eslint-disable prefer-destructuring */
15
- const framework = 'preact';
16
- const api = (0, _coreClient.start)(_render.renderToDOM);
17
-
18
- const storiesOf = (kind, m) => {
19
- return api.clientApi.storiesOf(kind, m).addParameters({
20
- framework
21
- });
22
- };
23
-
24
- exports.storiesOf = storiesOf;
25
-
26
- const configure = (...args) => api.configure(framework, ...args);
27
-
28
- exports.configure = configure;
29
- const addDecorator = api.clientApi.addDecorator;
30
- exports.addDecorator = addDecorator;
31
- const addParameters = api.clientApi.addParameters;
32
- exports.addParameters = addParameters;
33
- const clearDecorators = api.clientApi.clearDecorators;
34
- exports.clearDecorators = clearDecorators;
35
- const setAddon = api.clientApi.setAddon;
36
- exports.setAddon = setAddon;
37
- const forceReRender = api.forceReRender;
38
- exports.forceReRender = forceReRender;
39
- const getStorybook = api.clientApi.getStorybook;
40
- exports.getStorybook = getStorybook;
41
- const raw = api.clientApi.raw;
42
- exports.raw = raw;
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.renderToDOM = renderToDOM;
7
-
8
- var preact = _interopRequireWildcard(require("preact"));
9
-
10
- var _tsDedent = _interopRequireDefault(require("ts-dedent"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
-
16
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
-
18
- let renderedStory;
19
-
20
- function preactRender(story, domElement) {
21
- if (preact.Fragment) {
22
- // Preact 10 only:
23
- preact.render(story, domElement);
24
- } else {
25
- renderedStory = preact.render(story, domElement, renderedStory);
26
- }
27
- }
28
-
29
- const StoryHarness = ({
30
- showError,
31
- name,
32
- title,
33
- storyFn,
34
- domElement
35
- }) => {
36
- const content = preact.h(storyFn, null);
37
-
38
- if (!content) {
39
- showError({
40
- title: `Expecting a Preact element from the story: "${name}" of "${title}".`,
41
- description: (0, _tsDedent.default)`
42
- Did you forget to return the Preact element from the story?
43
- Use "() => (<MyComp/>)" or "() => { return <MyComp/>; }" when defining the story.
44
- `
45
- });
46
- return null;
47
- }
48
-
49
- return content;
50
- };
51
-
52
- function renderToDOM({
53
- storyFn,
54
- title,
55
- name,
56
- showMain,
57
- showError,
58
- forceRemount
59
- }, domElement) {
60
- if (forceRemount) {
61
- preactRender(null, domElement);
62
- }
63
-
64
- showMain();
65
- preactRender(preact.h(StoryHarness, {
66
- name,
67
- title,
68
- showError,
69
- storyFn,
70
- domElement
71
- }), domElement);
72
- }
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
@@ -1 +0,0 @@
1
- "use strict";
package/dist/esm/index.js DELETED
@@ -1,2 +0,0 @@
1
- export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw } from './preview';
2
- export * from './preview/types-6-0';
@@ -1,4 +0,0 @@
1
- export { renderToDOM } from './render';
2
- export const parameters = {
3
- framework: 'preact'
4
- };
@@ -1,8 +0,0 @@
1
- import global from 'global';
2
- const {
3
- window: globalWindow
4
- } = global;
5
-
6
- if (globalWindow) {
7
- globalWindow.STORYBOOK_ENV = 'preact';
8
- }
@@ -1,19 +0,0 @@
1
- /* eslint-disable prefer-destructuring */
2
- import { start } from '@storybook/core-client';
3
- import './globals';
4
- import { renderToDOM } from './render';
5
- const framework = 'preact';
6
- const api = start(renderToDOM);
7
- export const storiesOf = (kind, m) => {
8
- return api.clientApi.storiesOf(kind, m).addParameters({
9
- framework
10
- });
11
- };
12
- export const configure = (...args) => api.configure(framework, ...args);
13
- export const addDecorator = api.clientApi.addDecorator;
14
- export const addParameters = api.clientApi.addParameters;
15
- export const clearDecorators = api.clientApi.clearDecorators;
16
- export const setAddon = api.clientApi.setAddon;
17
- export const forceReRender = api.forceReRender;
18
- export const getStorybook = api.clientApi.getStorybook;
19
- export const raw = api.clientApi.raw;
@@ -1,57 +0,0 @@
1
- import * as preact from 'preact';
2
- import dedent from 'ts-dedent';
3
- let renderedStory;
4
-
5
- function preactRender(story, domElement) {
6
- if (preact.Fragment) {
7
- // Preact 10 only:
8
- preact.render(story, domElement);
9
- } else {
10
- renderedStory = preact.render(story, domElement, renderedStory);
11
- }
12
- }
13
-
14
- const StoryHarness = ({
15
- showError,
16
- name,
17
- title,
18
- storyFn,
19
- domElement
20
- }) => {
21
- const content = preact.h(storyFn, null);
22
-
23
- if (!content) {
24
- showError({
25
- title: `Expecting a Preact element from the story: "${name}" of "${title}".`,
26
- description: dedent`
27
- Did you forget to return the Preact element from the story?
28
- Use "() => (<MyComp/>)" or "() => { return <MyComp/>; }" when defining the story.
29
- `
30
- });
31
- return null;
32
- }
33
-
34
- return content;
35
- };
36
-
37
- export function renderToDOM({
38
- storyFn,
39
- title,
40
- name,
41
- showMain,
42
- showError,
43
- forceRemount
44
- }, domElement) {
45
- if (forceRemount) {
46
- preactRender(null, domElement);
47
- }
48
-
49
- showMain();
50
- preactRender(preact.h(StoryHarness, {
51
- name,
52
- title,
53
- showError,
54
- storyFn,
55
- domElement
56
- }), domElement);
57
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
File without changes
@@ -1,2 +0,0 @@
1
- export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw, } from './preview';
2
- export * from './preview/types-6-0';
@@ -1,4 +0,0 @@
1
- export { renderToDOM } from './render';
2
- export declare const parameters: {
3
- framework: string;
4
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- /// <reference types="webpack-env" />
2
- import type { ClientStoryApi, Loadable } from '@storybook/addons';
3
- import './globals';
4
- import type { IStorybookSection } from './types';
5
- import type { PreactFramework } from './types-6-0';
6
- export interface ClientApi extends ClientStoryApi<PreactFramework['storyResult']> {
7
- setAddon(addon: any): void;
8
- configure(loader: Loadable, module: NodeModule): void;
9
- getStorybook(): IStorybookSection[];
10
- clearDecorators(): void;
11
- forceReRender(): void;
12
- raw: () => any;
13
- load: (...args: any[]) => void;
14
- }
15
- export declare const storiesOf: ClientApi['storiesOf'];
16
- export declare const configure: ClientApi['configure'];
17
- export declare const addDecorator: ClientApi['addDecorator'];
18
- export declare const addParameters: ClientApi['addParameters'];
19
- export declare const clearDecorators: ClientApi['clearDecorators'];
20
- export declare const setAddon: ClientApi['setAddon'];
21
- export declare const forceReRender: ClientApi['forceReRender'];
22
- export declare const getStorybook: ClientApi['getStorybook'];
23
- export declare const raw: ClientApi['raw'];
@@ -1,3 +0,0 @@
1
- import { RenderContext } from '@storybook/store';
2
- import { PreactFramework } from './types-6-0';
3
- export declare function renderToDOM({ storyFn, title, name, showMain, showError, forceRemount }: RenderContext<PreactFramework>, domElement: HTMLElement): void;
@@ -1,35 +0,0 @@
1
- import type { AnyComponent } from 'preact';
2
- import type { Args, ComponentAnnotations, StoryAnnotations, AnnotatedStoryFn } from '@storybook/csf';
3
- import type { StoryFnPreactReturnType } from './types';
4
- export type { Args, ArgTypes, Parameters, StoryContext } from '@storybook/csf';
5
- export declare type PreactFramework = {
6
- component: AnyComponent<any, any>;
7
- storyResult: StoryFnPreactReturnType;
8
- };
9
- /**
10
- * Metadata to configure the stories for a component.
11
- *
12
- * @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
13
- */
14
- export declare type Meta<TArgs = Args> = ComponentAnnotations<PreactFramework, TArgs>;
15
- /**
16
- * Story function that represents a CSFv2 component example.
17
- *
18
- * @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
19
- */
20
- export declare type StoryFn<TArgs = Args> = AnnotatedStoryFn<PreactFramework, TArgs>;
21
- /**
22
- * Story function that represents a CSFv3 component example.
23
- *
24
- * @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
25
- */
26
- export declare type StoryObj<TArgs = Args> = StoryAnnotations<PreactFramework, TArgs>;
27
- /**
28
- * Story function that represents a CSFv2 component example.
29
- *
30
- * @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
31
- *
32
- * NOTE that in Storybook 7.0, this type will be renamed to `StoryFn` and replaced by the current `StoryObj` type.
33
- *
34
- */
35
- export declare type Story<TArgs = Args> = StoryFn<TArgs>;
@@ -1,9 +0,0 @@
1
- import type { Args } from '@storybook/csf';
2
- import type { StoryObj } from './types-6-0';
3
- export type { StoryFn, StoryObj, Meta } from './types-6-0';
4
- /**
5
- * Story function that represents a CSFv3 component example.
6
- *
7
- * @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
8
- */
9
- export declare type Story<TArgs = Args> = StoryObj<TArgs>;
@@ -1,14 +0,0 @@
1
- export type { RenderContext } from '@storybook/core-client';
2
- export declare type StoryFnPreactReturnType = string | Node | preact.JSX.Element;
3
- export interface ShowErrorArgs {
4
- title: string;
5
- description: string;
6
- }
7
- export interface IStorybookStory {
8
- name: string;
9
- render: (context: any) => any;
10
- }
11
- export interface IStorybookSection {
12
- kind: string;
13
- stories: IStorybookStory[];
14
- }