@storybook/react-native 6.0.1-beta.8 → 6.0.1-canary.0
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/dist/document-polyfill/DOM/Document.d.ts +14 -0
- package/dist/document-polyfill/DOM/Document.js +37 -0
- package/dist/document-polyfill/DOM/Element.d.ts +37 -0
- package/dist/document-polyfill/DOM/Element.js +58 -0
- package/dist/document-polyfill/DOM/HTMLCanvasElement.d.ts +4 -0
- package/dist/document-polyfill/DOM/HTMLCanvasElement.js +4 -0
- package/dist/document-polyfill/DOM/HTMLImageElement.d.ts +4 -0
- package/dist/document-polyfill/DOM/HTMLImageElement.js +4 -0
- package/dist/document-polyfill/DOM/HTMLVideoElement.d.ts +4 -0
- package/dist/document-polyfill/DOM/HTMLVideoElement.js +4 -0
- package/dist/document-polyfill/DOM/Node.d.ts +26 -0
- package/dist/document-polyfill/DOM/Node.js +33 -0
- package/dist/{preview/global.js → document-polyfill/index.d.ts} +0 -0
- package/dist/document-polyfill/index.js +3 -0
- package/dist/document-polyfill/module.d.ts +0 -0
- package/dist/document-polyfill/module.js +1 -0
- package/dist/{types-6.0.js → document-polyfill/module.native.d.ts} +0 -0
- package/dist/document-polyfill/module.native.js +2 -0
- package/dist/index.d.ts +13 -12
- package/dist/index.js +13 -17
- package/dist/preview/View.d.ts +40 -0
- package/dist/preview/View.js +90 -0
- package/dist/preview/components/OnDeviceUI/OnDeviceUI.d.ts +6 -3
- package/dist/preview/components/OnDeviceUI/OnDeviceUI.js +6 -26
- package/dist/preview/components/OnDeviceUI/Panel.js +1 -0
- package/dist/preview/components/OnDeviceUI/animation.d.ts +5 -5
- package/dist/preview/components/Shared/icons.d.ts +1 -0
- package/dist/preview/components/Shared/text.d.ts +3 -44
- package/dist/preview/components/StoryListView/StoryListView.d.ts +7 -4
- package/dist/preview/components/StoryListView/StoryListView.js +12 -12
- package/dist/preview/components/StoryView/StoryView.d.ts +5 -3
- package/dist/preview/components/StoryView/StoryView.js +5 -24
- package/dist/preview/executeLoadable.d.ts +24 -0
- package/dist/preview/executeLoadable.js +82 -0
- package/dist/preview/rn-host-detect.d.ts +1 -0
- package/dist/preview/rn-host-detect.js +62 -0
- package/dist/preview/start.d.ts +13 -0
- package/dist/preview/start.js +75 -0
- package/dist/{types-6.0.d.ts → types/types-6.0.d.ts} +4 -0
- package/dist/types/types-6.0.js +1 -0
- package/dist/types/types.d.ts +14 -0
- package/dist/types/types.js +1 -0
- package/package.json +14 -12
- package/dist/preview/Preview.d.ts +0 -57
- package/dist/preview/Preview.js +0 -121
- package/dist/preview/global.d.ts +0 -8
- package/dist/preview/index.d.ts +0 -1
- package/dist/preview/index.js +0 -1
- package/dist/preview/loadCsf.d.ts +0 -16
- package/dist/preview/loadCsf.js +0 -180
package/dist/preview/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Preview';
|
package/dist/preview/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Preview';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="webpack-env" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { ClientApi, ConfigApi, StoryStore } from '@storybook/client-api';
|
|
4
|
-
import './global';
|
|
5
|
-
export interface RequireContext {
|
|
6
|
-
keys: () => string[];
|
|
7
|
-
(id: string): any;
|
|
8
|
-
resolve(id: string): string;
|
|
9
|
-
}
|
|
10
|
-
export declare type LoadableFunction = () => void | any[];
|
|
11
|
-
export declare type Loadable = RequireContext | RequireContext[] | LoadableFunction;
|
|
12
|
-
export declare const loadCsf: ({ clientApi, storyStore, configApi, }: {
|
|
13
|
-
clientApi: ClientApi;
|
|
14
|
-
storyStore: StoryStore;
|
|
15
|
-
configApi: ConfigApi;
|
|
16
|
-
}) => (framework: string, loadable: Loadable, m: NodeModule, showDeprecationWarning?: boolean) => void;
|
package/dist/preview/loadCsf.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { logger } from '@storybook/client-logger';
|
|
13
|
-
import { isExportStory, storyNameFromExport, toId } from '@storybook/csf';
|
|
14
|
-
import './global';
|
|
15
|
-
const deprecatedStoryAnnotationWarning = () => logger.log(`
|
|
16
|
-
CSF .story annotations deprecated; annotate story functions directly:
|
|
17
|
-
- StoryFn.story.name => StoryFn.storyName
|
|
18
|
-
- StoryFn.story.(parameters|decorators) => StoryFn.(parameters|decorators)
|
|
19
|
-
See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#hoisted-csf-annotations for details and codemod.
|
|
20
|
-
`);
|
|
21
|
-
const duplicateKindWarning = (kindName) => {
|
|
22
|
-
logger.warn(`Duplicate title: '${kindName}'
|
|
23
|
-
Duplicate title used in multiple files; use unique titles or a primary file for a component with re-exported stories.
|
|
24
|
-
|
|
25
|
-
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-support-for-duplicate-kinds
|
|
26
|
-
`);
|
|
27
|
-
};
|
|
28
|
-
global.previousExports = new Map();
|
|
29
|
-
const loadStories = (loadable, framework, { clientApi, storyStore }) => () => {
|
|
30
|
-
// Make sure we don't try to define a kind more than once within the same load
|
|
31
|
-
const loadedKinds = new Set();
|
|
32
|
-
let reqs = null;
|
|
33
|
-
// todo discuss / improve type check
|
|
34
|
-
if (Array.isArray(loadable)) {
|
|
35
|
-
reqs = loadable;
|
|
36
|
-
}
|
|
37
|
-
else if (loadable.keys) {
|
|
38
|
-
reqs = [loadable];
|
|
39
|
-
}
|
|
40
|
-
let currentExports = new Map();
|
|
41
|
-
// reqs is not null when require context is used,
|
|
42
|
-
// this comes from storybook core client and will never be true in RN
|
|
43
|
-
// keeping this here only to get an idea how the core version could be re-used
|
|
44
|
-
if (reqs) {
|
|
45
|
-
reqs.forEach((req) => {
|
|
46
|
-
req.keys().forEach((filename) => {
|
|
47
|
-
try {
|
|
48
|
-
const fileExports = req(filename);
|
|
49
|
-
currentExports.set(fileExports,
|
|
50
|
-
// todo discuss: types infer that this is RequireContext; no checks needed?
|
|
51
|
-
// NOTE: turns out `babel-plugin-require-context-hook` doesn't implement this (yet)
|
|
52
|
-
typeof req.resolve === 'function' ? req.resolve(filename) : filename);
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
logger.warn(`Unexpected error while loading ${filename}: ${error}`);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
try {
|
|
62
|
-
const exported = loadable();
|
|
63
|
-
if (Array.isArray(exported)) {
|
|
64
|
-
const csfExports = exported.filter((obj) => obj.default != null);
|
|
65
|
-
currentExports = new Map(csfExports.map((fileExports) => [fileExports, null]));
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
logger.warn(`Loader function passed to 'configure' should return void or an array of module exports that all contain a 'default' export. Received: ${JSON.stringify(exported)}`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
logger.warn(`Unexpected error while loading stories: ${error}`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const removed = Array.from(global.previousExports.keys()).filter((exp) => !currentExports.has(exp));
|
|
76
|
-
removed.forEach((exp) => {
|
|
77
|
-
if (exp.default) {
|
|
78
|
-
storyStore.removeStoryKind(exp.default.title);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
const added = Array.from(currentExports.keys()).filter((exp) => !global.previousExports.has(exp));
|
|
82
|
-
added.forEach((fileExports) => {
|
|
83
|
-
// An old-style story file
|
|
84
|
-
if (!fileExports.default) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (!fileExports.default.title) {
|
|
88
|
-
throw new Error(`Unexpected default export without title: ${JSON.stringify(fileExports.default)}`);
|
|
89
|
-
}
|
|
90
|
-
const { default: meta, __namedExportsOrder } = fileExports, namedExports = __rest(fileExports, ["default", "__namedExportsOrder"]);
|
|
91
|
-
let exports = namedExports;
|
|
92
|
-
// prefer a user/loader provided `__namedExportsOrder` array if supplied
|
|
93
|
-
// we do this as es module exports are always ordered alphabetically
|
|
94
|
-
// see https://github.com/storybookjs/storybook/issues/9136
|
|
95
|
-
if (Array.isArray(__namedExportsOrder)) {
|
|
96
|
-
exports = {};
|
|
97
|
-
__namedExportsOrder.forEach((name) => {
|
|
98
|
-
if (namedExports[name]) {
|
|
99
|
-
exports[name] = namedExports[name];
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
const { title: kindName, id: componentId, parameters: kindParameters, decorators: kindDecorators, loaders: kindLoaders = [], component, subcomponents, args: kindArgs, argTypes: kindArgTypes, } = meta;
|
|
104
|
-
if (loadedKinds.has(kindName)) {
|
|
105
|
-
duplicateKindWarning(kindName);
|
|
106
|
-
}
|
|
107
|
-
loadedKinds.add(kindName);
|
|
108
|
-
// We pass true here to avoid the warning about HMR. It's cool clientApi, we got this
|
|
109
|
-
// todo discuss: TS now wants a NodeModule; should we fix this differently?
|
|
110
|
-
const kind = clientApi.storiesOf(kindName, true);
|
|
111
|
-
// we should always have a framework, rest optional
|
|
112
|
-
kind.addParameters(Object.assign(Object.assign({ framework,
|
|
113
|
-
component,
|
|
114
|
-
subcomponents, fileName: currentExports.get(fileExports) }, kindParameters), { args: kindArgs, argTypes: kindArgTypes }));
|
|
115
|
-
// todo add type
|
|
116
|
-
(kindDecorators || []).forEach((decorator) => {
|
|
117
|
-
kind.addDecorator(decorator);
|
|
118
|
-
});
|
|
119
|
-
kindLoaders.forEach((loader) => {
|
|
120
|
-
kind.addLoader(loader);
|
|
121
|
-
});
|
|
122
|
-
const storyExports = Object.keys(exports);
|
|
123
|
-
if (storyExports.length === 0) {
|
|
124
|
-
logger.warn(`
|
|
125
|
-
Found a story file for "${kindName}" but no exported stories.
|
|
126
|
-
Check the docs for reference: https://storybook.js.org/docs/formats/component-story-format/
|
|
127
|
-
`);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
storyExports.forEach((key) => {
|
|
131
|
-
if (isExportStory(key, meta)) {
|
|
132
|
-
const storyFn = exports[key];
|
|
133
|
-
const { story } = storyFn;
|
|
134
|
-
const name = story === null || story === void 0 ? void 0 : story.name;
|
|
135
|
-
const { storyName = name } = storyFn;
|
|
136
|
-
// storyFn.x and storyFn.story.x get merged with
|
|
137
|
-
// storyFn.x taking precedence in the merge
|
|
138
|
-
const parameters = Object.assign(Object.assign({}, story === null || story === void 0 ? void 0 : story.parameters), storyFn.parameters);
|
|
139
|
-
const decorators = [...(storyFn.decorators || []), ...((story === null || story === void 0 ? void 0 : story.decorators) || [])];
|
|
140
|
-
const loaders = [...(storyFn.loaders || []), ...((story === null || story === void 0 ? void 0 : story.loaders) || [])];
|
|
141
|
-
const args = Object.assign(Object.assign({}, story === null || story === void 0 ? void 0 : story.args), storyFn.args);
|
|
142
|
-
const argTypes = Object.assign(Object.assign({}, story === null || story === void 0 ? void 0 : story.argTypes), storyFn.argTypes);
|
|
143
|
-
if (story) {
|
|
144
|
-
logger.debug('deprecated story', story);
|
|
145
|
-
deprecatedStoryAnnotationWarning();
|
|
146
|
-
}
|
|
147
|
-
const exportName = storyNameFromExport(key);
|
|
148
|
-
const storyParams = Object.assign(Object.assign({}, parameters), { __id: toId(componentId || kindName, exportName), decorators,
|
|
149
|
-
loaders,
|
|
150
|
-
args,
|
|
151
|
-
argTypes });
|
|
152
|
-
kind.add(storyName || exportName, storyFn, storyParams);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
global.previousExports = currentExports;
|
|
157
|
-
};
|
|
158
|
-
const configureDeprecationWarning = () => logger.log(`\`configure()\` is deprecated and will be removed in Storybook 7.0.
|
|
159
|
-
Please use the \`stories\` field of \`main.js\` to load stories.
|
|
160
|
-
Read more at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-configure`);
|
|
161
|
-
export const loadCsf = ({ clientApi, storyStore, configApi, }) =>
|
|
162
|
-
/**
|
|
163
|
-
* Load a collection of stories. If it has a default export, assume that it is a module-style
|
|
164
|
-
* file and process its named exports as stories. If not, assume it's an old-style
|
|
165
|
-
* storiesof file and require it.
|
|
166
|
-
*
|
|
167
|
-
* @param {*} framework - name of framework in use, e.g. "react"
|
|
168
|
-
* @param {*} loadable a require.context `req`, an array of `req`s, or a loader function that returns void or an array of exports
|
|
169
|
-
* @param {*} m - ES module object for hot-module-reloading (HMR)
|
|
170
|
-
* @param {boolean} showDeprecationWarning - show the deprecation warning (default true)
|
|
171
|
-
*/
|
|
172
|
-
(framework, loadable, m, showDeprecationWarning = true) => {
|
|
173
|
-
if (showDeprecationWarning) {
|
|
174
|
-
configureDeprecationWarning();
|
|
175
|
-
}
|
|
176
|
-
if (typeof m === 'string') {
|
|
177
|
-
throw new Error(`Invalid module '${m}'. Did you forget to pass \`module\` as the second argument to \`configure\`"?`);
|
|
178
|
-
}
|
|
179
|
-
configApi.configure(loadStories(loadable, framework, { clientApi, storyStore }), m);
|
|
180
|
-
};
|