@storybook/react-native 6.5.5-alpha.1 → 6.5.6-alpha.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/index.d.ts +125 -18
- package/dist/index.js +1591 -41
- package/package.json +9 -9
- package/scripts/__snapshots__/loader.test.js.snap +24 -6
- package/scripts/handle-args.js +5 -1
- package/scripts/loader.js +71 -36
- package/template/cli/storybook.requires.js +54 -0
- package/dist/constants.d.ts +0 -5
- package/dist/constants.js +0 -8
- package/dist/hooks.d.ts +0 -67
- package/dist/hooks.js +0 -168
- package/dist/preview/View.d.ts +0 -50
- package/dist/preview/View.js +0 -183
- package/dist/preview/components/OnDeviceUI/OnDeviceUI.d.ts +0 -12
- package/dist/preview/components/OnDeviceUI/OnDeviceUI.js +0 -163
- package/dist/preview/components/OnDeviceUI/Panel.d.ts +0 -9
- package/dist/preview/components/OnDeviceUI/Panel.js +0 -28
- package/dist/preview/components/OnDeviceUI/absolute-positioned-keyboard-aware-view.d.ts +0 -12
- package/dist/preview/components/OnDeviceUI/absolute-positioned-keyboard-aware-view.js +0 -31
- package/dist/preview/components/OnDeviceUI/addons/Addons.d.ts +0 -6
- package/dist/preview/components/OnDeviceUI/addons/Addons.js +0 -34
- package/dist/preview/components/OnDeviceUI/addons/AddonsSkeleton.d.ts +0 -14
- package/dist/preview/components/OnDeviceUI/addons/AddonsSkeleton.js +0 -78
- package/dist/preview/components/OnDeviceUI/addons/List.d.ts +0 -9
- package/dist/preview/components/OnDeviceUI/addons/List.js +0 -18
- package/dist/preview/components/OnDeviceUI/addons/Wrapper.d.ts +0 -8
- package/dist/preview/components/OnDeviceUI/addons/Wrapper.js +0 -31
- package/dist/preview/components/OnDeviceUI/addons/index.d.ts +0 -1
- package/dist/preview/components/OnDeviceUI/addons/index.js +0 -8
- package/dist/preview/components/OnDeviceUI/animation.d.ts +0 -61
- package/dist/preview/components/OnDeviceUI/animation.js +0 -116
- package/dist/preview/components/OnDeviceUI/index.d.ts +0 -1
- package/dist/preview/components/OnDeviceUI/index.js +0 -8
- package/dist/preview/components/OnDeviceUI/navigation/Navigation.d.ts +0 -9
- package/dist/preview/components/OnDeviceUI/navigation/Navigation.js +0 -54
- package/dist/preview/components/OnDeviceUI/navigation/NavigationBar.d.ts +0 -8
- package/dist/preview/components/OnDeviceUI/navigation/NavigationBar.js +0 -24
- package/dist/preview/components/OnDeviceUI/navigation/NavigationButton.d.ts +0 -2
- package/dist/preview/components/OnDeviceUI/navigation/NavigationButton.js +0 -23
- package/dist/preview/components/OnDeviceUI/navigation/constants.d.ts +0 -3
- package/dist/preview/components/OnDeviceUI/navigation/constants.js +0 -6
- package/dist/preview/components/OnDeviceUI/navigation/index.d.ts +0 -1
- package/dist/preview/components/OnDeviceUI/navigation/index.js +0 -8
- package/dist/preview/components/Shared/icons.d.ts +0 -53
- package/dist/preview/components/Shared/icons.js +0 -72
- package/dist/preview/components/Shared/layout.d.ts +0 -26
- package/dist/preview/components/Shared/layout.js +0 -24
- package/dist/preview/components/Shared/tabs.d.ts +0 -20
- package/dist/preview/components/Shared/tabs.js +0 -48
- package/dist/preview/components/StoryListView/StoryListView.d.ts +0 -7
- package/dist/preview/components/StoryListView/StoryListView.js +0 -201
- package/dist/preview/components/StoryListView/getNestedStories.d.ts +0 -10
- package/dist/preview/components/StoryListView/getNestedStories.js +0 -95
- package/dist/preview/components/StoryListView/getNestedStories.test.d.ts +0 -1
- package/dist/preview/components/StoryListView/getNestedStories.test.js +0 -237
- package/dist/preview/components/StoryListView/index.d.ts +0 -1
- package/dist/preview/components/StoryListView/index.js +0 -8
- package/dist/preview/components/StoryView/StoryView.d.ts +0 -3
- package/dist/preview/components/StoryView/StoryView.js +0 -47
- package/dist/preview/components/StoryView/index.d.ts +0 -1
- package/dist/preview/components/StoryView/index.js +0 -8
- package/dist/preview/executeLoadable.d.ts +0 -27
- package/dist/preview/executeLoadable.js +0 -92
- package/dist/preview/rn-host-detect.d.ts +0 -1
- package/dist/preview/rn-host-detect.js +0 -63
- package/dist/preview/start.d.ts +0 -16
- package/dist/preview/start.js +0 -124
- package/dist/types/types-6.0.d.ts +0 -72
- package/dist/types/types-6.0.js +0 -2
- package/dist/types/types.d.ts +0 -14
- package/dist/types/types.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.6-alpha.0",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -32,9 +32,8 @@
|
|
|
32
32
|
"template/**/*"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"dev": "
|
|
36
|
-
"
|
|
37
|
-
"prepare": "tsc",
|
|
35
|
+
"dev": "ts-node ./buildscripts/gentsdev.ts && tsup --watch",
|
|
36
|
+
"prepare": "tsup",
|
|
38
37
|
"test": "jest"
|
|
39
38
|
},
|
|
40
39
|
"jest": {
|
|
@@ -52,8 +51,6 @@
|
|
|
52
51
|
"preset": "react-native"
|
|
53
52
|
},
|
|
54
53
|
"dependencies": {
|
|
55
|
-
"@emotion/native": "^11.11.0",
|
|
56
|
-
"@emotion/react": "^11.11.1",
|
|
57
54
|
"@storybook/addons": "^6.5.14",
|
|
58
55
|
"@storybook/channel-websocket": "^6.5.14",
|
|
59
56
|
"@storybook/channels": "^6.5.14",
|
|
@@ -63,7 +60,7 @@
|
|
|
63
60
|
"@storybook/core-events": "^6.5.14",
|
|
64
61
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
65
62
|
"@storybook/preview-web": "^6.5.14",
|
|
66
|
-
"@storybook/react-native-theming": "^6.5.
|
|
63
|
+
"@storybook/react-native-theming": "^6.5.6-alpha.0",
|
|
67
64
|
"chokidar": "^3.5.1",
|
|
68
65
|
"commander": "^8.2.0",
|
|
69
66
|
"deepmerge": "^4.3.0",
|
|
@@ -78,7 +75,10 @@
|
|
|
78
75
|
"@types/react": "~18.2.14",
|
|
79
76
|
"babel-jest": "^29.4.3",
|
|
80
77
|
"jest": "^29.4.3",
|
|
81
|
-
"react-test-renderer": "18.2.0"
|
|
78
|
+
"react-test-renderer": "18.2.0",
|
|
79
|
+
"ts-node": "^10.9.1",
|
|
80
|
+
"tsup": "^7.2.0",
|
|
81
|
+
"typescript": "^5.1.3"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"@react-native-async-storage/async-storage": ">=1",
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "f2ff9ddebf4e2a8a008cc484bf054c4a5cd641c5"
|
|
96
96
|
}
|
|
@@ -41,11 +41,14 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
41
41
|
} catch{}
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
|
|
44
45
|
const getStories=() => {
|
|
45
|
-
|
|
46
|
+
return {"./scripts/mocks/file-extensions/FakeStory.stories.tsx": require("./FakeStory.stories.tsx")};
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
configure(getStories, module, false)
|
|
50
|
+
|
|
51
|
+
|
|
49
52
|
"
|
|
50
53
|
`;
|
|
51
54
|
|
|
@@ -90,11 +93,14 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
90
93
|
} catch{}
|
|
91
94
|
|
|
92
95
|
|
|
96
|
+
|
|
93
97
|
const getStories=() => {
|
|
94
|
-
|
|
98
|
+
return {"./scripts/mocks/configuration-objects/components/FakeStory.stories.tsx": require("./components/FakeStory.stories.tsx")};
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
configure(getStories, module, false)
|
|
102
|
+
|
|
103
|
+
|
|
98
104
|
"
|
|
99
105
|
`;
|
|
100
106
|
|
|
@@ -139,11 +145,14 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
139
145
|
} catch{}
|
|
140
146
|
|
|
141
147
|
|
|
148
|
+
|
|
142
149
|
const getStories=() => {
|
|
143
|
-
|
|
150
|
+
return {"./scripts/mocks/exclude-config-files/include-components/FakeStory.stories.tsx": require("./include-components/FakeStory.stories.tsx")};
|
|
144
151
|
}
|
|
145
152
|
|
|
146
153
|
configure(getStories, module, false)
|
|
154
|
+
|
|
155
|
+
|
|
147
156
|
"
|
|
148
157
|
`;
|
|
149
158
|
|
|
@@ -188,11 +197,14 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
188
197
|
} catch{}
|
|
189
198
|
|
|
190
199
|
|
|
200
|
+
|
|
191
201
|
const getStories=() => {
|
|
192
|
-
|
|
202
|
+
return {"./scripts/mocks/all-config-files/FakeStory.stories.tsx": require("./FakeStory.stories.tsx")};
|
|
193
203
|
}
|
|
194
204
|
|
|
195
205
|
configure(getStories, module, false)
|
|
206
|
+
|
|
207
|
+
|
|
196
208
|
"
|
|
197
209
|
`;
|
|
198
210
|
|
|
@@ -219,11 +231,14 @@ import "@storybook/addon-ondevice-actions/register";
|
|
|
219
231
|
} catch{}
|
|
220
232
|
|
|
221
233
|
|
|
234
|
+
|
|
222
235
|
const getStories=() => {
|
|
223
|
-
|
|
236
|
+
return {"./scripts/mocks/no-preview/FakeStory.stories.tsx": require("./FakeStory.stories.tsx")};
|
|
224
237
|
}
|
|
225
238
|
|
|
226
239
|
configure(getStories, module, false)
|
|
240
|
+
|
|
241
|
+
|
|
227
242
|
"
|
|
228
243
|
`;
|
|
229
244
|
|
|
@@ -243,10 +258,13 @@ exports[`loader writeRequires when there is no story glob or addons writes no st
|
|
|
243
258
|
|
|
244
259
|
|
|
245
260
|
|
|
261
|
+
|
|
246
262
|
const getStories=() => {
|
|
247
|
-
|
|
263
|
+
return {};
|
|
248
264
|
}
|
|
249
265
|
|
|
250
266
|
configure(getStories, module, false)
|
|
267
|
+
|
|
268
|
+
|
|
251
269
|
"
|
|
252
270
|
`;
|
package/scripts/handle-args.js
CHANGED
|
@@ -8,7 +8,11 @@ function getArguments() {
|
|
|
8
8
|
'The path to your config folder relative to your project-dir',
|
|
9
9
|
'./.storybook'
|
|
10
10
|
)
|
|
11
|
-
.option('-a, --absolute', 'Use absolute paths for story imports')
|
|
11
|
+
.option('-a, --absolute', 'Use absolute paths for story imports')
|
|
12
|
+
.option(
|
|
13
|
+
'-unstable_useRequireContext, --unstable_useRequireContext',
|
|
14
|
+
'Use experimental require.context to load stories'
|
|
15
|
+
);
|
|
12
16
|
|
|
13
17
|
program.parse();
|
|
14
18
|
|
package/scripts/loader.js
CHANGED
|
@@ -2,7 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const glob = require('glob');
|
|
4
4
|
const prettier = require('prettier');
|
|
5
|
-
const normalizeStories = require('@storybook/core-common')
|
|
5
|
+
const { normalizeStories, toRequireContext } = require('@storybook/core-common');
|
|
6
6
|
|
|
7
7
|
const cwd = process.cwd();
|
|
8
8
|
const supportedExtensions = ['js', 'jsx', 'ts', 'tsx', 'cjs', 'mjs'];
|
|
@@ -45,14 +45,17 @@ function normalizeExcludePaths(paths) {
|
|
|
45
45
|
|
|
46
46
|
function requireUncached(module) {
|
|
47
47
|
delete require.cache[require.resolve(module)];
|
|
48
|
+
|
|
48
49
|
return require(module);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
function getMain({ configPath }) {
|
|
52
53
|
const fileExtension = getFilePathExtension({ configPath }, 'main');
|
|
54
|
+
|
|
53
55
|
if (fileExtension === null) {
|
|
54
56
|
throw new Error('main config file not found');
|
|
55
57
|
}
|
|
58
|
+
|
|
56
59
|
const mainPath = path.resolve(cwd, configPath, `main.${fileExtension}`);
|
|
57
60
|
|
|
58
61
|
return requireUncached(mainPath);
|
|
@@ -61,10 +64,12 @@ function getMain({ configPath }) {
|
|
|
61
64
|
function getFilePathExtension({ configPath }, fileName) {
|
|
62
65
|
for (const ext of supportedExtensions) {
|
|
63
66
|
const filePath = path.resolve(cwd, configPath, `${fileName}.${ext}`);
|
|
67
|
+
|
|
64
68
|
if (fs.existsSync(filePath)) {
|
|
65
69
|
return ext;
|
|
66
70
|
}
|
|
67
71
|
}
|
|
72
|
+
|
|
68
73
|
return null;
|
|
69
74
|
}
|
|
70
75
|
|
|
@@ -76,13 +81,17 @@ function ensureRelativePathHasDot(relativePath) {
|
|
|
76
81
|
return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
|
|
77
82
|
}
|
|
78
83
|
|
|
79
|
-
function writeRequires({ configPath, absolute = false }) {
|
|
84
|
+
function writeRequires({ configPath, absolute = false, unstable_useRequireContext = false }) {
|
|
80
85
|
const storybookRequiresLocation = path.resolve(cwd, configPath, 'storybook.requires.js');
|
|
81
86
|
|
|
82
87
|
const mainImport = getMain({ configPath });
|
|
88
|
+
|
|
83
89
|
const main = mainImport.default ?? mainImport;
|
|
90
|
+
|
|
84
91
|
const reactNativeOptions = main.reactNativeOptions;
|
|
92
|
+
|
|
85
93
|
const excludePaths = reactNativeOptions && reactNativeOptions.excludePaths;
|
|
94
|
+
|
|
86
95
|
const normalizedExcludePaths = normalizeExcludePaths(excludePaths);
|
|
87
96
|
|
|
88
97
|
const storiesSpecifiers = normalizeStories(main.stories, {
|
|
@@ -90,32 +99,61 @@ function writeRequires({ configPath, absolute = false }) {
|
|
|
90
99
|
workingDir: cwd,
|
|
91
100
|
});
|
|
92
101
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
path.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
102
|
+
let configure = '';
|
|
103
|
+
|
|
104
|
+
if (unstable_useRequireContext) {
|
|
105
|
+
const contexts = storiesSpecifiers.map((specifier) => {
|
|
106
|
+
const { path: p, recursive: r, match: m } = toRequireContext(specifier);
|
|
107
|
+
// TODO remove this dot 👇 and find actual solution
|
|
108
|
+
return `require.context('.${p}', ${r}, ${m})`;
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
configure = `
|
|
112
|
+
const stories = [${contexts.join(',')}];
|
|
113
|
+
|
|
114
|
+
configure(stories, module, false)
|
|
115
|
+
`;
|
|
116
|
+
} else {
|
|
117
|
+
const storyRequires = storiesSpecifiers.reduce((acc, specifier) => {
|
|
118
|
+
const paths = glob
|
|
119
|
+
.sync(specifier.files, {
|
|
120
|
+
cwd: path.resolve(cwd, specifier.directory),
|
|
121
|
+
absolute,
|
|
122
|
+
// default to always ignore (exclude) anything in node_modules
|
|
123
|
+
ignore:
|
|
124
|
+
normalizedExcludePaths !== undefined ? normalizedExcludePaths : ['**/node_modules'],
|
|
125
|
+
})
|
|
126
|
+
.map((storyPath) => {
|
|
127
|
+
const pathWithDirectory = path.join(specifier.directory, storyPath);
|
|
128
|
+
|
|
129
|
+
const requirePath = absolute
|
|
130
|
+
? storyPath
|
|
131
|
+
: ensureRelativePathHasDot(path.relative(configPath, pathWithDirectory));
|
|
132
|
+
|
|
133
|
+
const absolutePath = absolute ? requirePath : path.resolve(configPath, requirePath);
|
|
134
|
+
|
|
135
|
+
const pathRelativeToCwd = path.relative(cwd, absolutePath);
|
|
136
|
+
|
|
137
|
+
const normalizePathForWindows = (str) =>
|
|
138
|
+
path.sep === '\\' ? str.replace(/\\/g, '/') : str;
|
|
139
|
+
|
|
140
|
+
return `"./${normalizePathForWindows(
|
|
141
|
+
pathRelativeToCwd
|
|
142
|
+
)}": require("${normalizePathForWindows(requirePath)}")`;
|
|
143
|
+
});
|
|
144
|
+
return [...acc, ...paths];
|
|
145
|
+
}, []);
|
|
146
|
+
|
|
147
|
+
const path_obj_str = `{${storyRequires.join(',')}}`;
|
|
148
|
+
|
|
149
|
+
configure = `
|
|
150
|
+
const getStories=() => {
|
|
151
|
+
return ${path_obj_str};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
configure(getStories, module, false)
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
119
157
|
|
|
120
158
|
fs.writeFileSync(storybookRequiresLocation, '');
|
|
121
159
|
|
|
@@ -123,14 +161,14 @@ function writeRequires({ configPath, absolute = false }) {
|
|
|
123
161
|
|
|
124
162
|
let previewJs = previewExists ? previewImports : '';
|
|
125
163
|
|
|
126
|
-
const path_obj_str = `{${storyRequires.join(',')}}`;
|
|
127
|
-
|
|
128
164
|
const registerAddons = main.addons?.map((addon) => `import "${addon}/register";`).join('\n');
|
|
165
|
+
|
|
129
166
|
let enhancersImport = '';
|
|
167
|
+
|
|
130
168
|
let enhancers = '';
|
|
131
169
|
|
|
132
170
|
// TODO: implement presets or something similar
|
|
133
|
-
if (main.addons
|
|
171
|
+
if (main.addons?.includes('@storybook/addon-ondevice-actions')) {
|
|
134
172
|
enhancersImport =
|
|
135
173
|
'import { argsEnhancers } from "@storybook/addon-actions/dist/modern/preset/addArgs"';
|
|
136
174
|
|
|
@@ -167,11 +205,8 @@ function writeRequires({ configPath, absolute = false }) {
|
|
|
167
205
|
|
|
168
206
|
${enhancers}
|
|
169
207
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
configure(getStories, module, false)
|
|
208
|
+
${configure}
|
|
209
|
+
|
|
175
210
|
`;
|
|
176
211
|
|
|
177
212
|
const formattedFileContent = prettier.format(fileContent, { parser: 'babel' });
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* do not change this file, it is auto generated by storybook. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
configure,
|
|
5
|
+
addDecorator,
|
|
6
|
+
addParameters,
|
|
7
|
+
addArgsEnhancer,
|
|
8
|
+
clearDecorators,
|
|
9
|
+
} from '@storybook/react-native';
|
|
10
|
+
|
|
11
|
+
global.STORIES = [
|
|
12
|
+
{
|
|
13
|
+
titlePrefix: '',
|
|
14
|
+
directory: './.storybook/stories',
|
|
15
|
+
files: '**/*.stories.?(ts|tsx|js|jsx)',
|
|
16
|
+
importPathMatcher:
|
|
17
|
+
'^\\.[\\\\/](?:\\.storybook\\/stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(?:ts|tsx|js|jsx)?)$',
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
import '@storybook/addon-ondevice-controls/register';
|
|
22
|
+
import '@storybook/addon-ondevice-actions/register';
|
|
23
|
+
|
|
24
|
+
import { argsEnhancers } from '@storybook/addon-actions/dist/modern/preset/addArgs';
|
|
25
|
+
|
|
26
|
+
import { decorators, parameters } from './preview';
|
|
27
|
+
|
|
28
|
+
if (decorators) {
|
|
29
|
+
if (__DEV__) {
|
|
30
|
+
// stops the warning from showing on every HMR
|
|
31
|
+
require('react-native').LogBox.ignoreLogs([
|
|
32
|
+
'`clearDecorators` is deprecated and will be removed in Storybook 7.0',
|
|
33
|
+
]);
|
|
34
|
+
}
|
|
35
|
+
// workaround for global decorators getting infinitely applied on HMR, see https://github.com/storybookjs/react-native/issues/185
|
|
36
|
+
clearDecorators();
|
|
37
|
+
decorators.forEach((decorator) => addDecorator(decorator));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (parameters) {
|
|
41
|
+
addParameters(parameters);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
argsEnhancers.forEach((enhancer) => addArgsEnhancer(enhancer));
|
|
46
|
+
} catch {}
|
|
47
|
+
|
|
48
|
+
const getStories = () => {
|
|
49
|
+
return {
|
|
50
|
+
'./.storybook/stories/Button/Button.stories.js': require('./stories/Button/Button.stories.js'),
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
configure(getStories, module, false);
|
package/dist/constants.d.ts
DELETED
package/dist/constants.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ANIMATION_DURATION_TRANSITION = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Duration for a typical transition animation, such as rescaling the canvas
|
|
6
|
-
* UI.
|
|
7
|
-
*/
|
|
8
|
-
exports.ANIMATION_DURATION_TRANSITION = 400;
|
package/dist/hooks.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { StoryContext } from '@storybook/csf';
|
|
2
|
-
import type { ReactNativeFramework } from './types/types-6.0';
|
|
3
|
-
import { StoryIndexEntry } from '@storybook/client-api';
|
|
4
|
-
/**
|
|
5
|
-
* Hook that returns a function to set the current story context.
|
|
6
|
-
*/
|
|
7
|
-
export declare function useSetStoryContext(): (args_0: StoryContext<ReactNativeFramework> | ((prev: StoryContext<ReactNativeFramework>) => StoryContext<ReactNativeFramework>)) => void;
|
|
8
|
-
/**
|
|
9
|
-
* Hook to read the current story context.
|
|
10
|
-
*/
|
|
11
|
-
export declare function useStoryContext(): StoryContext<ReactNativeFramework>;
|
|
12
|
-
/**
|
|
13
|
-
* Hook that reads the value of a specific story context parameter.
|
|
14
|
-
*/
|
|
15
|
-
export declare function useStoryContextParam<T = any>(name: string, defaultValue?: T): T;
|
|
16
|
-
/**
|
|
17
|
-
* Hook that indicates if `storyId` is the currently selected story.
|
|
18
|
-
*/
|
|
19
|
-
export declare function useIsStorySelected(storyId: string): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Hook that indicates if story kind (title) is the currently selected story section.
|
|
22
|
-
*/
|
|
23
|
-
export declare function useIsStorySectionSelected(title: string): boolean;
|
|
24
|
-
export declare function useIsChildSelected(entries: StoryIndexEntry[]): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Hook that causes a re-render when the currently selected story is changed.
|
|
27
|
-
*/
|
|
28
|
-
export declare function useUpdateOnStoryChanged(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Hook that gets the current theme values.
|
|
31
|
-
*/
|
|
32
|
-
export declare function useTheme(): import("@emotion/react").Theme;
|
|
33
|
-
/**
|
|
34
|
-
* A boolean atom creator for an atom that can only be toggled between
|
|
35
|
-
* true/false.
|
|
36
|
-
*
|
|
37
|
-
* @see {@link https://jotai.org/docs/recipes/atom-creators#atomwithtoggle}
|
|
38
|
-
*/
|
|
39
|
-
export declare function atomWithToggle(initialValue?: boolean): import("jotai").WritableAtom<boolean, [nextValue?: boolean], void> & {
|
|
40
|
-
init: boolean;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Hook that retrieves the current state, and a setter, for the `isUIVisible`
|
|
44
|
-
* atom.
|
|
45
|
-
*/
|
|
46
|
-
export declare function useIsUIVisible(): [boolean, (nextValue?: boolean) => void];
|
|
47
|
-
/**
|
|
48
|
-
* Hook that retrieves the current state, and a setter, for the
|
|
49
|
-
* `isSplitPanelVisibleAtom` atom.
|
|
50
|
-
*/
|
|
51
|
-
export declare function useIsSplitPanelVisible(): [boolean, (nextValue?: boolean) => void];
|
|
52
|
-
interface SyncExternalUIParams {
|
|
53
|
-
isUIVisible?: boolean;
|
|
54
|
-
isSplitPanelVisible?: boolean;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Sync the UI atom states with external values, such as from Story parameters.
|
|
58
|
-
*/
|
|
59
|
-
export declare function syncExternalUI({ isUIVisible, isSplitPanelVisible }: SyncExternalUIParams): void;
|
|
60
|
-
/**
|
|
61
|
-
* Hook that manages the state for the currently selected addon.
|
|
62
|
-
*
|
|
63
|
-
* This value persists across stories, so that the same addon will be selected
|
|
64
|
-
* when switching stories.
|
|
65
|
-
*/
|
|
66
|
-
export declare function useSelectedAddon(initialValue?: string): [string, (args_0: string | ((prev: string) => string)) => void];
|
|
67
|
-
export {};
|
package/dist/hooks.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.useSelectedAddon = exports.syncExternalUI = exports.useIsSplitPanelVisible = exports.useIsUIVisible = exports.atomWithToggle = exports.useTheme = exports.useUpdateOnStoryChanged = exports.useIsChildSelected = exports.useIsStorySectionSelected = exports.useIsStorySelected = exports.useStoryContextParam = exports.useStoryContext = exports.useSetStoryContext = void 0;
|
|
27
|
-
var react_1 = __importStar(require("react"));
|
|
28
|
-
var jotai_1 = require("jotai");
|
|
29
|
-
var react_2 = require("@emotion/react");
|
|
30
|
-
var storyContextAtom = (0, jotai_1.atom)(null);
|
|
31
|
-
/**
|
|
32
|
-
* Hook that returns a function to set the current story context.
|
|
33
|
-
*/
|
|
34
|
-
function useSetStoryContext() {
|
|
35
|
-
return (0, jotai_1.useSetAtom)(storyContextAtom);
|
|
36
|
-
}
|
|
37
|
-
exports.useSetStoryContext = useSetStoryContext;
|
|
38
|
-
/**
|
|
39
|
-
* Hook to read the current story context.
|
|
40
|
-
*/
|
|
41
|
-
function useStoryContext() {
|
|
42
|
-
return (0, jotai_1.useAtomValue)(storyContextAtom);
|
|
43
|
-
}
|
|
44
|
-
exports.useStoryContext = useStoryContext;
|
|
45
|
-
/**
|
|
46
|
-
* Hook that reads the value of a specific story context parameter.
|
|
47
|
-
*/
|
|
48
|
-
function useStoryContextParam(name, defaultValue) {
|
|
49
|
-
var _a;
|
|
50
|
-
var paramAtom = (0, react_1.useMemo)(function () { return (0, jotai_1.atom)(function (get) { var _a, _b; return (_b = (_a = get(storyContextAtom)) === null || _a === void 0 ? void 0 : _a.parameters) === null || _b === void 0 ? void 0 : _b[name]; }); }, [name]);
|
|
51
|
-
return (_a = (0, jotai_1.useAtomValue)(paramAtom)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
52
|
-
}
|
|
53
|
-
exports.useStoryContextParam = useStoryContextParam;
|
|
54
|
-
/**
|
|
55
|
-
* Hook that indicates if `storyId` is the currently selected story.
|
|
56
|
-
*/
|
|
57
|
-
function useIsStorySelected(storyId) {
|
|
58
|
-
return (0, jotai_1.useAtomValue)((0, react_1.useMemo)(function () { return (0, jotai_1.atom)(function (get) { var _a; return ((_a = get(storyContextAtom)) === null || _a === void 0 ? void 0 : _a.id) === storyId; }); }, [storyId]));
|
|
59
|
-
}
|
|
60
|
-
exports.useIsStorySelected = useIsStorySelected;
|
|
61
|
-
/**
|
|
62
|
-
* Hook that indicates if story kind (title) is the currently selected story section.
|
|
63
|
-
*/
|
|
64
|
-
function useIsStorySectionSelected(title) {
|
|
65
|
-
return (0, jotai_1.useAtomValue)((0, react_1.useMemo)(function () {
|
|
66
|
-
return (0, jotai_1.atom)(function (get) {
|
|
67
|
-
var _a;
|
|
68
|
-
var contextTitle = (_a = get(storyContextAtom)) === null || _a === void 0 ? void 0 : _a.title;
|
|
69
|
-
return contextTitle === title || (contextTitle === null || contextTitle === void 0 ? void 0 : contextTitle.startsWith("".concat(title, "/")));
|
|
70
|
-
});
|
|
71
|
-
}, [title]));
|
|
72
|
-
}
|
|
73
|
-
exports.useIsStorySectionSelected = useIsStorySectionSelected;
|
|
74
|
-
function useIsChildSelected(entries) {
|
|
75
|
-
return (0, jotai_1.useAtomValue)((0, react_1.useMemo)(function () {
|
|
76
|
-
return (0, jotai_1.atom)(function (get) {
|
|
77
|
-
var _a;
|
|
78
|
-
var contextId = (_a = get(storyContextAtom)) === null || _a === void 0 ? void 0 : _a.id;
|
|
79
|
-
return !!entries.find(function (_a) {
|
|
80
|
-
var id = _a.id;
|
|
81
|
-
return id === contextId;
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
}, [entries]));
|
|
85
|
-
}
|
|
86
|
-
exports.useIsChildSelected = useIsChildSelected;
|
|
87
|
-
/**
|
|
88
|
-
* Hook that causes a re-render when the currently selected story is changed.
|
|
89
|
-
*/
|
|
90
|
-
function useUpdateOnStoryChanged() {
|
|
91
|
-
(0, jotai_1.useAtomValue)((0, react_1.useMemo)(function () { return (0, jotai_1.atom)(function (get) { var _a; return (_a = get(storyContextAtom)) === null || _a === void 0 ? void 0 : _a.id; }); }, []));
|
|
92
|
-
}
|
|
93
|
-
exports.useUpdateOnStoryChanged = useUpdateOnStoryChanged;
|
|
94
|
-
/**
|
|
95
|
-
* Hook that gets the current theme values.
|
|
96
|
-
*/
|
|
97
|
-
function useTheme() {
|
|
98
|
-
return (0, react_2.useTheme)();
|
|
99
|
-
}
|
|
100
|
-
exports.useTheme = useTheme;
|
|
101
|
-
/**
|
|
102
|
-
* A boolean atom creator for an atom that can only be toggled between
|
|
103
|
-
* true/false.
|
|
104
|
-
*
|
|
105
|
-
* @see {@link https://jotai.org/docs/recipes/atom-creators#atomwithtoggle}
|
|
106
|
-
*/
|
|
107
|
-
function atomWithToggle(initialValue) {
|
|
108
|
-
var anAtom = (0, jotai_1.atom)(initialValue, function (get, set, nextValue) {
|
|
109
|
-
var update = nextValue !== null && nextValue !== void 0 ? nextValue : !get(anAtom);
|
|
110
|
-
set(anAtom, update);
|
|
111
|
-
});
|
|
112
|
-
return anAtom;
|
|
113
|
-
}
|
|
114
|
-
exports.atomWithToggle = atomWithToggle;
|
|
115
|
-
var isUIVisibleAtom = atomWithToggle(true);
|
|
116
|
-
/**
|
|
117
|
-
* Hook that retrieves the current state, and a setter, for the `isUIVisible`
|
|
118
|
-
* atom.
|
|
119
|
-
*/
|
|
120
|
-
function useIsUIVisible() {
|
|
121
|
-
return (0, jotai_1.useAtom)(isUIVisibleAtom);
|
|
122
|
-
}
|
|
123
|
-
exports.useIsUIVisible = useIsUIVisible;
|
|
124
|
-
var isSplitPanelVisibleAtom = atomWithToggle(false);
|
|
125
|
-
/**
|
|
126
|
-
* Hook that retrieves the current state, and a setter, for the
|
|
127
|
-
* `isSplitPanelVisibleAtom` atom.
|
|
128
|
-
*/
|
|
129
|
-
function useIsSplitPanelVisible() {
|
|
130
|
-
return (0, jotai_1.useAtom)(isSplitPanelVisibleAtom);
|
|
131
|
-
}
|
|
132
|
-
exports.useIsSplitPanelVisible = useIsSplitPanelVisible;
|
|
133
|
-
/**
|
|
134
|
-
* Sync the UI atom states with external values, such as from Story parameters.
|
|
135
|
-
*/
|
|
136
|
-
function syncExternalUI(_a) {
|
|
137
|
-
var isUIVisible = _a.isUIVisible, isSplitPanelVisible = _a.isSplitPanelVisible;
|
|
138
|
-
var jotaiStore = (0, jotai_1.getDefaultStore)();
|
|
139
|
-
if (isUIVisible !== undefined) {
|
|
140
|
-
jotaiStore.set(isUIVisibleAtom, isUIVisible);
|
|
141
|
-
}
|
|
142
|
-
if (isSplitPanelVisible !== undefined) {
|
|
143
|
-
jotaiStore.set(isSplitPanelVisibleAtom, isSplitPanelVisible);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
exports.syncExternalUI = syncExternalUI;
|
|
147
|
-
var selectedAddonAtom = (0, jotai_1.atom)(undefined);
|
|
148
|
-
/**
|
|
149
|
-
* Hook that manages the state for the currently selected addon.
|
|
150
|
-
*
|
|
151
|
-
* This value persists across stories, so that the same addon will be selected
|
|
152
|
-
* when switching stories.
|
|
153
|
-
*/
|
|
154
|
-
function useSelectedAddon(initialValue) {
|
|
155
|
-
var result = (0, jotai_1.useAtom)(selectedAddonAtom);
|
|
156
|
-
var set = result[1];
|
|
157
|
-
react_1.default.useEffect(function () {
|
|
158
|
-
var jotaiStore = (0, jotai_1.getDefaultStore)();
|
|
159
|
-
// Only apply the initial value once, and only if the atom doesn't have a
|
|
160
|
-
// value yet.
|
|
161
|
-
if (jotaiStore.get(selectedAddonAtom) === undefined) {
|
|
162
|
-
set(initialValue);
|
|
163
|
-
}
|
|
164
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
165
|
-
}, []);
|
|
166
|
-
return result;
|
|
167
|
-
}
|
|
168
|
-
exports.useSelectedAddon = useSelectedAddon;
|