@storybook/react-native 7.0.0-alpha.2 → 7.0.0-alpha.4
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.js +802 -118
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -4,6 +4,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
7
10
|
var __export = (target, all) => {
|
|
8
11
|
for (var name in all)
|
|
9
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -26,6 +29,32 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
29
|
));
|
|
27
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
31
|
|
|
32
|
+
// ../../node_modules/@storybook/types/dist/index.js
|
|
33
|
+
var require_dist = __commonJS({
|
|
34
|
+
"../../node_modules/@storybook/types/dist/index.js"(exports, module2) {
|
|
35
|
+
"use strict";
|
|
36
|
+
var __defProp2 = Object.defineProperty;
|
|
37
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
38
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
39
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
40
|
+
var __export2 = (target, all) => {
|
|
41
|
+
for (var name in all)
|
|
42
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
43
|
+
};
|
|
44
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
45
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
46
|
+
for (let key of __getOwnPropNames2(from))
|
|
47
|
+
!__hasOwnProp2.call(to, key) && key !== except && __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
48
|
+
return to;
|
|
49
|
+
};
|
|
50
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
51
|
+
var src_exports2 = {};
|
|
52
|
+
__export2(src_exports2, { Addon_TypesEnum: () => Addon_TypesEnum2 });
|
|
53
|
+
module2.exports = __toCommonJS2(src_exports2);
|
|
54
|
+
var Addon_TypesEnum2 = ((Addon_TypesEnum22) => (Addon_TypesEnum22.TAB = "tab", Addon_TypesEnum22.PANEL = "panel", Addon_TypesEnum22.TOOL = "tool", Addon_TypesEnum22.TOOLEXTRA = "toolextra", Addon_TypesEnum22.PREVIEW = "preview", Addon_TypesEnum22.experimental_PAGE = "page", Addon_TypesEnum22.NOTES_ELEMENT = "notes-element", Addon_TypesEnum22))(Addon_TypesEnum2 || {});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
29
58
|
// src/index.ts
|
|
30
59
|
var src_exports = {};
|
|
31
60
|
__export(src_exports, {
|
|
@@ -34,53 +63,712 @@ __export(src_exports, {
|
|
|
34
63
|
addDecorator: () => addDecorator,
|
|
35
64
|
addParameters: () => addParameters,
|
|
36
65
|
configure: () => configure,
|
|
37
|
-
darkTheme: () =>
|
|
66
|
+
darkTheme: () => import_react_native_theming13.darkTheme,
|
|
38
67
|
getStorybookUI: () => getStorybookUI,
|
|
39
68
|
raw: () => raw,
|
|
40
69
|
storiesOf: () => storiesOf,
|
|
41
|
-
theme: () =>
|
|
70
|
+
theme: () => import_react_native_theming13.theme
|
|
42
71
|
});
|
|
43
72
|
module.exports = __toCommonJS(src_exports);
|
|
44
73
|
|
|
45
74
|
// src/preview/start.tsx
|
|
46
|
-
var
|
|
47
|
-
var import_channels2 = __toESM(require("@storybook/channels"));
|
|
75
|
+
var import_channels2 = require("@storybook/channels");
|
|
48
76
|
var import_core_events3 = __toESM(require("@storybook/core-events"));
|
|
49
|
-
var
|
|
77
|
+
var import_global2 = require("@storybook/global");
|
|
78
|
+
var import_manager_api4 = require("@storybook/manager-api");
|
|
50
79
|
var import_preview_api = require("@storybook/preview-api");
|
|
51
80
|
var import_preview_web = require("@storybook/preview-web");
|
|
52
81
|
|
|
53
82
|
// src/preview/View.tsx
|
|
54
|
-
var import_react14 = require("react");
|
|
55
83
|
var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
|
|
56
84
|
var import_csf = require("@storybook/csf");
|
|
57
|
-
var
|
|
85
|
+
var import_manager_api3 = require("@storybook/manager-api");
|
|
58
86
|
var import_react_native_theming12 = require("@storybook/react-native-theming");
|
|
87
|
+
var import_react15 = require("react");
|
|
59
88
|
var import_react_native_safe_area_context3 = require("react-native-safe-area-context");
|
|
60
89
|
|
|
61
90
|
// src/hooks.tsx
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
91
|
+
var import_react2 = __toESM(require("react"));
|
|
92
|
+
|
|
93
|
+
// ../../node_modules/jotai/esm/vanilla.mjs
|
|
94
|
+
var import_meta = {};
|
|
95
|
+
var keyCount = 0;
|
|
96
|
+
function atom(read, write) {
|
|
97
|
+
const key = `atom${++keyCount}`;
|
|
98
|
+
const config = {
|
|
99
|
+
toString: () => key
|
|
100
|
+
};
|
|
101
|
+
if (typeof read === "function") {
|
|
102
|
+
config.read = read;
|
|
103
|
+
} else {
|
|
104
|
+
config.init = read;
|
|
105
|
+
config.read = (get) => get(config);
|
|
106
|
+
config.write = (get, set, arg) => set(
|
|
107
|
+
config,
|
|
108
|
+
typeof arg === "function" ? arg(get(config)) : arg
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
if (write) {
|
|
112
|
+
config.write = write;
|
|
113
|
+
}
|
|
114
|
+
return config;
|
|
115
|
+
}
|
|
116
|
+
var hasInitialValue = (atom2) => "init" in atom2;
|
|
117
|
+
var isActuallyWritableAtom = (atom2) => !!atom2.write;
|
|
118
|
+
var cancelPromiseMap = /* @__PURE__ */ new WeakMap();
|
|
119
|
+
var registerCancelPromise = (promise, cancel) => {
|
|
120
|
+
cancelPromiseMap.set(promise, cancel);
|
|
121
|
+
promise.catch(() => {
|
|
122
|
+
}).finally(() => cancelPromiseMap.delete(promise));
|
|
123
|
+
};
|
|
124
|
+
var cancelPromise = (promise, next) => {
|
|
125
|
+
const cancel = cancelPromiseMap.get(promise);
|
|
126
|
+
if (cancel) {
|
|
127
|
+
cancelPromiseMap.delete(promise);
|
|
128
|
+
cancel(next);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
var resolvePromise = (promise, value) => {
|
|
132
|
+
promise.status = "fulfilled";
|
|
133
|
+
promise.value = value;
|
|
134
|
+
};
|
|
135
|
+
var rejectPromise = (promise, e) => {
|
|
136
|
+
promise.status = "rejected";
|
|
137
|
+
promise.reason = e;
|
|
138
|
+
};
|
|
139
|
+
var isPromiseLike = (x) => typeof (x == null ? void 0 : x.then) === "function";
|
|
140
|
+
var isEqualAtomValue = (a, b) => "v" in a && "v" in b && Object.is(a.v, b.v);
|
|
141
|
+
var isEqualAtomError = (a, b) => "e" in a && "e" in b && Object.is(a.e, b.e);
|
|
142
|
+
var hasPromiseAtomValue = (a) => "v" in a && a.v instanceof Promise;
|
|
143
|
+
var isEqualPromiseAtomValue = (a, b) => "v" in a && "v" in b && a.v.orig && a.v.orig === b.v.orig;
|
|
144
|
+
var returnAtomValue = (atomState) => {
|
|
145
|
+
if ("e" in atomState) {
|
|
146
|
+
throw atomState.e;
|
|
147
|
+
}
|
|
148
|
+
return atomState.v;
|
|
149
|
+
};
|
|
150
|
+
var createStore = () => {
|
|
151
|
+
const atomStateMap = /* @__PURE__ */ new WeakMap();
|
|
152
|
+
const mountedMap = /* @__PURE__ */ new WeakMap();
|
|
153
|
+
const pendingMap = /* @__PURE__ */ new Map();
|
|
154
|
+
let storeListenersRev1;
|
|
155
|
+
let storeListenersRev2;
|
|
156
|
+
let mountedAtoms;
|
|
157
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
158
|
+
storeListenersRev1 = /* @__PURE__ */ new Set();
|
|
159
|
+
storeListenersRev2 = /* @__PURE__ */ new Set();
|
|
160
|
+
mountedAtoms = /* @__PURE__ */ new Set();
|
|
161
|
+
}
|
|
162
|
+
const getAtomState = (atom2) => atomStateMap.get(atom2);
|
|
163
|
+
const setAtomState = (atom2, atomState) => {
|
|
164
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
165
|
+
Object.freeze(atomState);
|
|
166
|
+
}
|
|
167
|
+
const prevAtomState = atomStateMap.get(atom2);
|
|
168
|
+
atomStateMap.set(atom2, atomState);
|
|
169
|
+
if (!pendingMap.has(atom2)) {
|
|
170
|
+
pendingMap.set(atom2, prevAtomState);
|
|
171
|
+
}
|
|
172
|
+
if (prevAtomState && hasPromiseAtomValue(prevAtomState)) {
|
|
173
|
+
const next = "v" in atomState ? atomState.v instanceof Promise ? atomState.v : Promise.resolve(atomState.v) : Promise.reject(atomState.e);
|
|
174
|
+
cancelPromise(prevAtomState.v, next);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const updateDependencies = (atom2, nextAtomState, nextDependencies) => {
|
|
178
|
+
const dependencies = /* @__PURE__ */ new Map();
|
|
179
|
+
let changed = false;
|
|
180
|
+
nextDependencies.forEach((aState, a) => {
|
|
181
|
+
if (!aState && a === atom2) {
|
|
182
|
+
aState = nextAtomState;
|
|
183
|
+
}
|
|
184
|
+
if (aState) {
|
|
185
|
+
dependencies.set(a, aState);
|
|
186
|
+
if (nextAtomState.d.get(a) !== aState) {
|
|
187
|
+
changed = true;
|
|
188
|
+
}
|
|
189
|
+
} else if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
190
|
+
console.warn("[Bug] atom state not found");
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
if (changed || nextAtomState.d.size !== dependencies.size) {
|
|
194
|
+
nextAtomState.d = dependencies;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const setAtomValue = (atom2, value, nextDependencies) => {
|
|
198
|
+
const prevAtomState = getAtomState(atom2);
|
|
199
|
+
const nextAtomState = {
|
|
200
|
+
d: (prevAtomState == null ? void 0 : prevAtomState.d) || /* @__PURE__ */ new Map(),
|
|
201
|
+
v: value
|
|
202
|
+
};
|
|
203
|
+
if (nextDependencies) {
|
|
204
|
+
updateDependencies(atom2, nextAtomState, nextDependencies);
|
|
205
|
+
}
|
|
206
|
+
if (prevAtomState && isEqualAtomValue(prevAtomState, nextAtomState) && prevAtomState.d === nextAtomState.d) {
|
|
207
|
+
return prevAtomState;
|
|
208
|
+
}
|
|
209
|
+
if (prevAtomState && hasPromiseAtomValue(prevAtomState) && hasPromiseAtomValue(nextAtomState) && isEqualPromiseAtomValue(prevAtomState, nextAtomState)) {
|
|
210
|
+
if (prevAtomState.d === nextAtomState.d) {
|
|
211
|
+
return prevAtomState;
|
|
212
|
+
} else {
|
|
213
|
+
nextAtomState.v = prevAtomState.v;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
setAtomState(atom2, nextAtomState);
|
|
217
|
+
return nextAtomState;
|
|
218
|
+
};
|
|
219
|
+
const setAtomValueOrPromise = (atom2, valueOrPromise, nextDependencies, abortPromise) => {
|
|
220
|
+
if (isPromiseLike(valueOrPromise)) {
|
|
221
|
+
let continuePromise;
|
|
222
|
+
const promise = new Promise((resolve, reject) => {
|
|
223
|
+
let settled = false;
|
|
224
|
+
valueOrPromise.then(
|
|
225
|
+
(v) => {
|
|
226
|
+
if (!settled) {
|
|
227
|
+
settled = true;
|
|
228
|
+
const prevAtomState = getAtomState(atom2);
|
|
229
|
+
const nextAtomState = setAtomValue(
|
|
230
|
+
atom2,
|
|
231
|
+
promise,
|
|
232
|
+
nextDependencies
|
|
233
|
+
);
|
|
234
|
+
resolvePromise(promise, v);
|
|
235
|
+
resolve(v);
|
|
236
|
+
if ((prevAtomState == null ? void 0 : prevAtomState.d) !== nextAtomState.d) {
|
|
237
|
+
mountDependencies(atom2, nextAtomState, prevAtomState == null ? void 0 : prevAtomState.d);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
(e) => {
|
|
242
|
+
if (!settled) {
|
|
243
|
+
settled = true;
|
|
244
|
+
const prevAtomState = getAtomState(atom2);
|
|
245
|
+
const nextAtomState = setAtomValue(
|
|
246
|
+
atom2,
|
|
247
|
+
promise,
|
|
248
|
+
nextDependencies
|
|
249
|
+
);
|
|
250
|
+
rejectPromise(promise, e);
|
|
251
|
+
reject(e);
|
|
252
|
+
if ((prevAtomState == null ? void 0 : prevAtomState.d) !== nextAtomState.d) {
|
|
253
|
+
mountDependencies(atom2, nextAtomState, prevAtomState == null ? void 0 : prevAtomState.d);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
);
|
|
258
|
+
continuePromise = (next) => {
|
|
259
|
+
if (!settled) {
|
|
260
|
+
settled = true;
|
|
261
|
+
next.then(
|
|
262
|
+
(v) => resolvePromise(promise, v),
|
|
263
|
+
(e) => rejectPromise(promise, e)
|
|
264
|
+
);
|
|
265
|
+
resolve(next);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
promise.orig = valueOrPromise;
|
|
270
|
+
promise.status = "pending";
|
|
271
|
+
registerCancelPromise(promise, (next) => {
|
|
272
|
+
if (next) {
|
|
273
|
+
continuePromise(next);
|
|
274
|
+
}
|
|
275
|
+
abortPromise == null ? void 0 : abortPromise();
|
|
276
|
+
});
|
|
277
|
+
return setAtomValue(atom2, promise, nextDependencies);
|
|
278
|
+
}
|
|
279
|
+
return setAtomValue(atom2, valueOrPromise, nextDependencies);
|
|
280
|
+
};
|
|
281
|
+
const setAtomError = (atom2, error, nextDependencies) => {
|
|
282
|
+
const prevAtomState = getAtomState(atom2);
|
|
283
|
+
const nextAtomState = {
|
|
284
|
+
d: (prevAtomState == null ? void 0 : prevAtomState.d) || /* @__PURE__ */ new Map(),
|
|
285
|
+
e: error
|
|
286
|
+
};
|
|
287
|
+
if (nextDependencies) {
|
|
288
|
+
updateDependencies(atom2, nextAtomState, nextDependencies);
|
|
289
|
+
}
|
|
290
|
+
if (prevAtomState && isEqualAtomError(prevAtomState, nextAtomState) && prevAtomState.d === nextAtomState.d) {
|
|
291
|
+
return prevAtomState;
|
|
292
|
+
}
|
|
293
|
+
setAtomState(atom2, nextAtomState);
|
|
294
|
+
return nextAtomState;
|
|
295
|
+
};
|
|
296
|
+
const readAtomState = (atom2) => {
|
|
297
|
+
const atomState = getAtomState(atom2);
|
|
298
|
+
if (atomState) {
|
|
299
|
+
atomState.d.forEach((_, a) => {
|
|
300
|
+
if (a !== atom2 && !mountedMap.has(a)) {
|
|
301
|
+
readAtomState(a);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
if (Array.from(atomState.d).every(([a, s]) => {
|
|
305
|
+
const aState = getAtomState(a);
|
|
306
|
+
return a === atom2 || aState === s || // TODO This is a hack, we should find a better solution.
|
|
307
|
+
aState && !hasPromiseAtomValue(aState) && isEqualAtomValue(aState, s);
|
|
308
|
+
})) {
|
|
309
|
+
return atomState;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
const nextDependencies = /* @__PURE__ */ new Map();
|
|
313
|
+
let isSync = true;
|
|
314
|
+
const getter = (a) => {
|
|
315
|
+
if (a === atom2) {
|
|
316
|
+
const aState2 = getAtomState(a);
|
|
317
|
+
if (aState2) {
|
|
318
|
+
nextDependencies.set(a, aState2);
|
|
319
|
+
return returnAtomValue(aState2);
|
|
320
|
+
}
|
|
321
|
+
if (hasInitialValue(a)) {
|
|
322
|
+
nextDependencies.set(a, void 0);
|
|
323
|
+
return a.init;
|
|
324
|
+
}
|
|
325
|
+
throw new Error("no atom init");
|
|
326
|
+
}
|
|
327
|
+
const aState = readAtomState(a);
|
|
328
|
+
nextDependencies.set(a, aState);
|
|
329
|
+
return returnAtomValue(aState);
|
|
330
|
+
};
|
|
331
|
+
let controller;
|
|
332
|
+
let setSelf;
|
|
333
|
+
const options = {
|
|
334
|
+
get signal() {
|
|
335
|
+
if (!controller) {
|
|
336
|
+
controller = new AbortController();
|
|
337
|
+
}
|
|
338
|
+
return controller.signal;
|
|
339
|
+
},
|
|
340
|
+
get setSelf() {
|
|
341
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && !isActuallyWritableAtom(atom2)) {
|
|
342
|
+
console.warn("setSelf function cannot be used with read-only atom");
|
|
343
|
+
}
|
|
344
|
+
if (!setSelf && isActuallyWritableAtom(atom2)) {
|
|
345
|
+
setSelf = (...args) => {
|
|
346
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && isSync) {
|
|
347
|
+
console.warn("setSelf function cannot be called in sync");
|
|
348
|
+
}
|
|
349
|
+
if (!isSync) {
|
|
350
|
+
return writeAtom(atom2, ...args);
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
return setSelf;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
try {
|
|
358
|
+
const valueOrPromise = atom2.read(getter, options);
|
|
359
|
+
return setAtomValueOrPromise(
|
|
360
|
+
atom2,
|
|
361
|
+
valueOrPromise,
|
|
362
|
+
nextDependencies,
|
|
363
|
+
() => controller == null ? void 0 : controller.abort()
|
|
364
|
+
);
|
|
365
|
+
} catch (error) {
|
|
366
|
+
return setAtomError(atom2, error, nextDependencies);
|
|
367
|
+
} finally {
|
|
368
|
+
isSync = false;
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const readAtom = (atom2) => returnAtomValue(readAtomState(atom2));
|
|
372
|
+
const addAtom = (atom2) => {
|
|
373
|
+
let mounted = mountedMap.get(atom2);
|
|
374
|
+
if (!mounted) {
|
|
375
|
+
mounted = mountAtom(atom2);
|
|
376
|
+
}
|
|
377
|
+
return mounted;
|
|
378
|
+
};
|
|
379
|
+
const canUnmountAtom = (atom2, mounted) => !mounted.l.size && (!mounted.t.size || mounted.t.size === 1 && mounted.t.has(atom2));
|
|
380
|
+
const delAtom = (atom2) => {
|
|
381
|
+
const mounted = mountedMap.get(atom2);
|
|
382
|
+
if (mounted && canUnmountAtom(atom2, mounted)) {
|
|
383
|
+
unmountAtom(atom2);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
const recomputeDependents = (atom2) => {
|
|
387
|
+
const dependencyMap = /* @__PURE__ */ new Map();
|
|
388
|
+
const dirtyMap = /* @__PURE__ */ new WeakMap();
|
|
389
|
+
const loop1 = (a) => {
|
|
390
|
+
const mounted = mountedMap.get(a);
|
|
391
|
+
mounted == null ? void 0 : mounted.t.forEach((dependent) => {
|
|
392
|
+
if (dependent !== a) {
|
|
393
|
+
dependencyMap.set(
|
|
394
|
+
dependent,
|
|
395
|
+
(dependencyMap.get(dependent) || /* @__PURE__ */ new Set()).add(a)
|
|
396
|
+
);
|
|
397
|
+
dirtyMap.set(dependent, (dirtyMap.get(dependent) || 0) + 1);
|
|
398
|
+
loop1(dependent);
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
loop1(atom2);
|
|
403
|
+
const loop2 = (a) => {
|
|
404
|
+
const mounted = mountedMap.get(a);
|
|
405
|
+
mounted == null ? void 0 : mounted.t.forEach((dependent) => {
|
|
406
|
+
var _a;
|
|
407
|
+
if (dependent !== a) {
|
|
408
|
+
let dirtyCount = dirtyMap.get(dependent);
|
|
409
|
+
if (dirtyCount) {
|
|
410
|
+
dirtyMap.set(dependent, --dirtyCount);
|
|
411
|
+
}
|
|
412
|
+
if (!dirtyCount) {
|
|
413
|
+
let isChanged = !!((_a = dependencyMap.get(dependent)) == null ? void 0 : _a.size);
|
|
414
|
+
if (isChanged) {
|
|
415
|
+
const prevAtomState = getAtomState(dependent);
|
|
416
|
+
const nextAtomState = readAtomState(dependent);
|
|
417
|
+
isChanged = !prevAtomState || !isEqualAtomValue(prevAtomState, nextAtomState);
|
|
418
|
+
}
|
|
419
|
+
if (!isChanged) {
|
|
420
|
+
dependencyMap.forEach((s) => s.delete(dependent));
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
loop2(dependent);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
};
|
|
427
|
+
loop2(atom2);
|
|
428
|
+
};
|
|
429
|
+
const writeAtomState = (atom2, ...args) => {
|
|
430
|
+
let isSync = true;
|
|
431
|
+
const getter = (a) => returnAtomValue(readAtomState(a));
|
|
432
|
+
const setter = (a, ...args2) => {
|
|
433
|
+
let r;
|
|
434
|
+
if (a === atom2) {
|
|
435
|
+
if (!hasInitialValue(a)) {
|
|
436
|
+
throw new Error("atom not writable");
|
|
437
|
+
}
|
|
438
|
+
const prevAtomState = getAtomState(a);
|
|
439
|
+
const nextAtomState = setAtomValueOrPromise(a, args2[0]);
|
|
440
|
+
if (!prevAtomState || !isEqualAtomValue(prevAtomState, nextAtomState)) {
|
|
441
|
+
recomputeDependents(a);
|
|
442
|
+
}
|
|
443
|
+
} else {
|
|
444
|
+
r = writeAtomState(a, ...args2);
|
|
445
|
+
}
|
|
446
|
+
if (!isSync) {
|
|
447
|
+
const flushed = flushPending();
|
|
448
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
449
|
+
storeListenersRev2.forEach(
|
|
450
|
+
(l) => l({ type: "async-write", flushed })
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return r;
|
|
455
|
+
};
|
|
456
|
+
const result = atom2.write(getter, setter, ...args);
|
|
457
|
+
isSync = false;
|
|
458
|
+
return result;
|
|
459
|
+
};
|
|
460
|
+
const writeAtom = (atom2, ...args) => {
|
|
461
|
+
const result = writeAtomState(atom2, ...args);
|
|
462
|
+
const flushed = flushPending();
|
|
463
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
464
|
+
storeListenersRev2.forEach(
|
|
465
|
+
(l) => l({ type: "write", flushed })
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
return result;
|
|
469
|
+
};
|
|
470
|
+
const mountAtom = (atom2, initialDependent) => {
|
|
471
|
+
const mounted = {
|
|
472
|
+
t: new Set(initialDependent && [initialDependent]),
|
|
473
|
+
l: /* @__PURE__ */ new Set()
|
|
474
|
+
};
|
|
475
|
+
mountedMap.set(atom2, mounted);
|
|
476
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
477
|
+
mountedAtoms.add(atom2);
|
|
478
|
+
}
|
|
479
|
+
readAtomState(atom2).d.forEach((_, a) => {
|
|
480
|
+
const aMounted = mountedMap.get(a);
|
|
481
|
+
if (aMounted) {
|
|
482
|
+
aMounted.t.add(atom2);
|
|
483
|
+
} else {
|
|
484
|
+
if (a !== atom2) {
|
|
485
|
+
mountAtom(a, atom2);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
readAtomState(atom2);
|
|
490
|
+
if (isActuallyWritableAtom(atom2) && atom2.onMount) {
|
|
491
|
+
const onUnmount = atom2.onMount((...args) => writeAtom(atom2, ...args));
|
|
492
|
+
if (onUnmount) {
|
|
493
|
+
mounted.u = onUnmount;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return mounted;
|
|
497
|
+
};
|
|
498
|
+
const unmountAtom = (atom2) => {
|
|
499
|
+
var _a;
|
|
500
|
+
const onUnmount = (_a = mountedMap.get(atom2)) == null ? void 0 : _a.u;
|
|
501
|
+
if (onUnmount) {
|
|
502
|
+
onUnmount();
|
|
503
|
+
}
|
|
504
|
+
mountedMap.delete(atom2);
|
|
505
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
506
|
+
mountedAtoms.delete(atom2);
|
|
507
|
+
}
|
|
508
|
+
const atomState = getAtomState(atom2);
|
|
509
|
+
if (atomState) {
|
|
510
|
+
if (hasPromiseAtomValue(atomState)) {
|
|
511
|
+
cancelPromise(atomState.v);
|
|
512
|
+
}
|
|
513
|
+
atomState.d.forEach((_, a) => {
|
|
514
|
+
if (a !== atom2) {
|
|
515
|
+
const mounted = mountedMap.get(a);
|
|
516
|
+
if (mounted) {
|
|
517
|
+
mounted.t.delete(atom2);
|
|
518
|
+
if (canUnmountAtom(a, mounted)) {
|
|
519
|
+
unmountAtom(a);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
} else if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
525
|
+
console.warn("[Bug] could not find atom state to unmount", atom2);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
const mountDependencies = (atom2, atomState, prevDependencies) => {
|
|
529
|
+
const depSet = new Set(atomState.d.keys());
|
|
530
|
+
prevDependencies == null ? void 0 : prevDependencies.forEach((_, a) => {
|
|
531
|
+
if (depSet.has(a)) {
|
|
532
|
+
depSet.delete(a);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
const mounted = mountedMap.get(a);
|
|
536
|
+
if (mounted) {
|
|
537
|
+
mounted.t.delete(atom2);
|
|
538
|
+
if (canUnmountAtom(a, mounted)) {
|
|
539
|
+
unmountAtom(a);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
depSet.forEach((a) => {
|
|
544
|
+
const mounted = mountedMap.get(a);
|
|
545
|
+
if (mounted) {
|
|
546
|
+
mounted.t.add(atom2);
|
|
547
|
+
} else if (mountedMap.has(atom2)) {
|
|
548
|
+
mountAtom(a, atom2);
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
};
|
|
552
|
+
const flushPending = () => {
|
|
553
|
+
let flushed;
|
|
554
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
555
|
+
flushed = /* @__PURE__ */ new Set();
|
|
556
|
+
}
|
|
557
|
+
while (pendingMap.size) {
|
|
558
|
+
const pending = Array.from(pendingMap);
|
|
559
|
+
pendingMap.clear();
|
|
560
|
+
pending.forEach(([atom2, prevAtomState]) => {
|
|
561
|
+
const atomState = getAtomState(atom2);
|
|
562
|
+
if (atomState) {
|
|
563
|
+
if (atomState.d !== (prevAtomState == null ? void 0 : prevAtomState.d)) {
|
|
564
|
+
mountDependencies(atom2, atomState, prevAtomState == null ? void 0 : prevAtomState.d);
|
|
565
|
+
}
|
|
566
|
+
const mounted = mountedMap.get(atom2);
|
|
567
|
+
if (mounted && !// TODO This seems pretty hacky. Hope to fix it.
|
|
568
|
+
// Maybe we could `mountDependencies` in `setAtomState`?
|
|
569
|
+
(prevAtomState && !hasPromiseAtomValue(prevAtomState) && (isEqualAtomValue(prevAtomState, atomState) || isEqualAtomError(prevAtomState, atomState)))) {
|
|
570
|
+
mounted.l.forEach((listener) => listener());
|
|
571
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
572
|
+
flushed.add(atom2);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
} else if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
576
|
+
console.warn("[Bug] no atom state to flush");
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
581
|
+
storeListenersRev1.forEach((l) => l("state"));
|
|
582
|
+
return flushed;
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
const subscribeAtom = (atom2, listener) => {
|
|
586
|
+
const mounted = addAtom(atom2);
|
|
587
|
+
const flushed = flushPending();
|
|
588
|
+
const listeners = mounted.l;
|
|
589
|
+
listeners.add(listener);
|
|
590
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
591
|
+
storeListenersRev1.forEach((l) => l("sub"));
|
|
592
|
+
storeListenersRev2.forEach(
|
|
593
|
+
(l) => l({ type: "sub", flushed })
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
return () => {
|
|
597
|
+
listeners.delete(listener);
|
|
598
|
+
delAtom(atom2);
|
|
599
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
600
|
+
storeListenersRev1.forEach((l) => l("unsub"));
|
|
601
|
+
storeListenersRev2.forEach((l) => l({ type: "unsub" }));
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
};
|
|
605
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
606
|
+
return {
|
|
607
|
+
get: readAtom,
|
|
608
|
+
set: writeAtom,
|
|
609
|
+
sub: subscribeAtom,
|
|
610
|
+
// store dev methods (these are tentative and subject to change without notice)
|
|
611
|
+
dev_subscribe_store: (l, rev) => {
|
|
612
|
+
if (rev !== 2) {
|
|
613
|
+
console.warn(
|
|
614
|
+
"The current StoreListener revision is 2. The older ones are deprecated."
|
|
615
|
+
);
|
|
616
|
+
storeListenersRev1.add(l);
|
|
617
|
+
return () => {
|
|
618
|
+
storeListenersRev1.delete(l);
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
storeListenersRev2.add(l);
|
|
622
|
+
return () => {
|
|
623
|
+
storeListenersRev2.delete(l);
|
|
624
|
+
};
|
|
625
|
+
},
|
|
626
|
+
dev_get_mounted_atoms: () => mountedAtoms.values(),
|
|
627
|
+
dev_get_atom_state: (a) => atomStateMap.get(a),
|
|
628
|
+
dev_get_mounted: (a) => mountedMap.get(a),
|
|
629
|
+
dev_restore_atoms: (values) => {
|
|
630
|
+
for (const [atom2, valueOrPromise] of values) {
|
|
631
|
+
if (hasInitialValue(atom2)) {
|
|
632
|
+
setAtomValueOrPromise(atom2, valueOrPromise);
|
|
633
|
+
recomputeDependents(atom2);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
const flushed = flushPending();
|
|
637
|
+
storeListenersRev2.forEach(
|
|
638
|
+
(l) => l({ type: "restore", flushed })
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
return {
|
|
644
|
+
get: readAtom,
|
|
645
|
+
set: writeAtom,
|
|
646
|
+
sub: subscribeAtom
|
|
647
|
+
};
|
|
648
|
+
};
|
|
649
|
+
var defaultStore;
|
|
650
|
+
var getDefaultStore = () => {
|
|
651
|
+
if (!defaultStore) {
|
|
652
|
+
defaultStore = createStore();
|
|
653
|
+
}
|
|
654
|
+
return defaultStore;
|
|
655
|
+
};
|
|
656
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
657
|
+
if (globalThis.__JOTAI_PACKAGE_IS_LOADED__) {
|
|
658
|
+
console.warn(
|
|
659
|
+
"Detected multiple Jotai instances. It may cause unexpected behavior. https://github.com/pmndrs/jotai/discussions/2044"
|
|
660
|
+
);
|
|
661
|
+
} else {
|
|
662
|
+
globalThis.__JOTAI_PACKAGE_IS_LOADED__ = true;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// ../../node_modules/jotai/esm/react.mjs
|
|
667
|
+
var import_react = __toESM(require("react"), 1);
|
|
668
|
+
var import_meta2 = {};
|
|
669
|
+
var StoreContext = (0, import_react.createContext)(void 0);
|
|
670
|
+
var useStore = (options) => {
|
|
671
|
+
const store = (0, import_react.useContext)(StoreContext);
|
|
672
|
+
return (options == null ? void 0 : options.store) || store || getDefaultStore();
|
|
673
|
+
};
|
|
674
|
+
var isPromiseLike2 = (x) => typeof (x == null ? void 0 : x.then) === "function";
|
|
675
|
+
var use = import_react.default.use || ((promise) => {
|
|
676
|
+
if (promise.status === "pending") {
|
|
677
|
+
throw promise;
|
|
678
|
+
} else if (promise.status === "fulfilled") {
|
|
679
|
+
return promise.value;
|
|
680
|
+
} else if (promise.status === "rejected") {
|
|
681
|
+
throw promise.reason;
|
|
682
|
+
} else {
|
|
683
|
+
promise.status = "pending";
|
|
684
|
+
promise.then(
|
|
685
|
+
(v) => {
|
|
686
|
+
promise.status = "fulfilled";
|
|
687
|
+
promise.value = v;
|
|
688
|
+
},
|
|
689
|
+
(e) => {
|
|
690
|
+
promise.status = "rejected";
|
|
691
|
+
promise.reason = e;
|
|
692
|
+
}
|
|
693
|
+
);
|
|
694
|
+
throw promise;
|
|
695
|
+
}
|
|
696
|
+
});
|
|
697
|
+
function useAtomValue(atom2, options) {
|
|
698
|
+
const store = useStore(options);
|
|
699
|
+
const [[valueFromReducer, storeFromReducer, atomFromReducer], rerender] = (0, import_react.useReducer)(
|
|
700
|
+
(prev) => {
|
|
701
|
+
const nextValue = store.get(atom2);
|
|
702
|
+
if (Object.is(prev[0], nextValue) && prev[1] === store && prev[2] === atom2) {
|
|
703
|
+
return prev;
|
|
704
|
+
}
|
|
705
|
+
return [nextValue, store, atom2];
|
|
706
|
+
},
|
|
707
|
+
void 0,
|
|
708
|
+
() => [store.get(atom2), store, atom2]
|
|
709
|
+
);
|
|
710
|
+
let value = valueFromReducer;
|
|
711
|
+
if (storeFromReducer !== store || atomFromReducer !== atom2) {
|
|
712
|
+
rerender();
|
|
713
|
+
value = store.get(atom2);
|
|
714
|
+
}
|
|
715
|
+
const delay = options == null ? void 0 : options.delay;
|
|
716
|
+
(0, import_react.useEffect)(() => {
|
|
717
|
+
const unsub = store.sub(atom2, () => {
|
|
718
|
+
if (typeof delay === "number") {
|
|
719
|
+
setTimeout(rerender, delay);
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
rerender();
|
|
723
|
+
});
|
|
724
|
+
rerender();
|
|
725
|
+
return unsub;
|
|
726
|
+
}, [store, atom2, delay]);
|
|
727
|
+
(0, import_react.useDebugValue)(value);
|
|
728
|
+
return isPromiseLike2(value) ? use(value) : value;
|
|
729
|
+
}
|
|
730
|
+
function useSetAtom(atom2, options) {
|
|
731
|
+
const store = useStore(options);
|
|
732
|
+
const setAtom = (0, import_react.useCallback)(
|
|
733
|
+
(...args) => {
|
|
734
|
+
if ((import_meta2.env ? import_meta2.env.MODE : void 0) !== "production" && !("write" in atom2)) {
|
|
735
|
+
throw new Error("not writable atom");
|
|
736
|
+
}
|
|
737
|
+
return store.set(atom2, ...args);
|
|
738
|
+
},
|
|
739
|
+
[store, atom2]
|
|
740
|
+
);
|
|
741
|
+
return setAtom;
|
|
742
|
+
}
|
|
743
|
+
function useAtom(atom2, options) {
|
|
744
|
+
return [
|
|
745
|
+
useAtomValue(atom2, options),
|
|
746
|
+
// We do wrong type assertion here, which results in throwing an error.
|
|
747
|
+
useSetAtom(atom2, options)
|
|
748
|
+
];
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// src/hooks.tsx
|
|
752
|
+
var storyContextAtom = atom(null);
|
|
65
753
|
function useSetStoryContext() {
|
|
66
|
-
return
|
|
754
|
+
return useSetAtom(storyContextAtom);
|
|
67
755
|
}
|
|
68
756
|
function useStoryContext() {
|
|
69
|
-
return
|
|
757
|
+
return useAtomValue(storyContextAtom);
|
|
70
758
|
}
|
|
71
759
|
function useStoryContextParam(name, defaultValue) {
|
|
72
|
-
const paramAtom = (0,
|
|
73
|
-
return
|
|
760
|
+
const paramAtom = (0, import_react2.useMemo)(() => atom((get) => get(storyContextAtom)?.parameters?.[name]), [name]);
|
|
761
|
+
return useAtomValue(paramAtom) ?? defaultValue;
|
|
74
762
|
}
|
|
75
763
|
function useIsStorySelected(storyId) {
|
|
76
|
-
return
|
|
77
|
-
(0,
|
|
764
|
+
return useAtomValue(
|
|
765
|
+
(0, import_react2.useMemo)(() => atom((get) => get(storyContextAtom)?.id === storyId), [storyId])
|
|
78
766
|
);
|
|
79
767
|
}
|
|
80
768
|
function useIsStorySectionSelected(title) {
|
|
81
|
-
return
|
|
82
|
-
(0,
|
|
83
|
-
() =>
|
|
769
|
+
return useAtomValue(
|
|
770
|
+
(0, import_react2.useMemo)(
|
|
771
|
+
() => atom((get) => {
|
|
84
772
|
const contextTitle = get(storyContextAtom)?.title;
|
|
85
773
|
return contextTitle === title || contextTitle?.startsWith(`${title}/`);
|
|
86
774
|
}),
|
|
@@ -89,9 +777,9 @@ function useIsStorySectionSelected(title) {
|
|
|
89
777
|
);
|
|
90
778
|
}
|
|
91
779
|
function useIsChildSelected(entries) {
|
|
92
|
-
return
|
|
93
|
-
(0,
|
|
94
|
-
() =>
|
|
780
|
+
return useAtomValue(
|
|
781
|
+
(0, import_react2.useMemo)(
|
|
782
|
+
() => atom((get) => {
|
|
95
783
|
const contextId = get(storyContextAtom)?.id;
|
|
96
784
|
return !!entries.find(({ id }) => id === contextId);
|
|
97
785
|
}),
|
|
@@ -100,10 +788,10 @@ function useIsChildSelected(entries) {
|
|
|
100
788
|
);
|
|
101
789
|
}
|
|
102
790
|
function useUpdateOnStoryChanged() {
|
|
103
|
-
|
|
791
|
+
useAtomValue((0, import_react2.useMemo)(() => atom((get) => get(storyContextAtom)?.id), []));
|
|
104
792
|
}
|
|
105
793
|
function atomWithToggle(initialValue) {
|
|
106
|
-
const anAtom =
|
|
794
|
+
const anAtom = atom(initialValue, (get, set, nextValue) => {
|
|
107
795
|
const update = nextValue ?? !get(anAtom);
|
|
108
796
|
set(anAtom, update);
|
|
109
797
|
});
|
|
@@ -111,14 +799,14 @@ function atomWithToggle(initialValue) {
|
|
|
111
799
|
}
|
|
112
800
|
var isUIVisibleAtom = atomWithToggle(true);
|
|
113
801
|
function useIsUIVisible() {
|
|
114
|
-
return
|
|
802
|
+
return useAtom(isUIVisibleAtom);
|
|
115
803
|
}
|
|
116
804
|
var isSplitPanelVisibleAtom = atomWithToggle(false);
|
|
117
805
|
function useIsSplitPanelVisible() {
|
|
118
|
-
return
|
|
806
|
+
return useAtom(isSplitPanelVisibleAtom);
|
|
119
807
|
}
|
|
120
808
|
function syncExternalUI({ isUIVisible, isSplitPanelVisible }) {
|
|
121
|
-
const jotaiStore =
|
|
809
|
+
const jotaiStore = getDefaultStore();
|
|
122
810
|
if (isUIVisible !== void 0) {
|
|
123
811
|
jotaiStore.set(isUIVisibleAtom, isUIVisible);
|
|
124
812
|
}
|
|
@@ -126,12 +814,12 @@ function syncExternalUI({ isUIVisible, isSplitPanelVisible }) {
|
|
|
126
814
|
jotaiStore.set(isSplitPanelVisibleAtom, isSplitPanelVisible);
|
|
127
815
|
}
|
|
128
816
|
}
|
|
129
|
-
var selectedAddonAtom =
|
|
817
|
+
var selectedAddonAtom = atom(void 0);
|
|
130
818
|
function useSelectedAddon(initialValue) {
|
|
131
|
-
const result =
|
|
819
|
+
const result = useAtom(selectedAddonAtom);
|
|
132
820
|
const set = result[1];
|
|
133
|
-
|
|
134
|
-
const jotaiStore =
|
|
821
|
+
import_react2.default.useEffect(() => {
|
|
822
|
+
const jotaiStore = getDefaultStore();
|
|
135
823
|
if (jotaiStore.get(selectedAddonAtom) === void 0) {
|
|
136
824
|
set(initialValue);
|
|
137
825
|
}
|
|
@@ -141,17 +829,17 @@ function useSelectedAddon(initialValue) {
|
|
|
141
829
|
|
|
142
830
|
// src/preview/components/OnDeviceUI/OnDeviceUI.tsx
|
|
143
831
|
var import_react_native_theming10 = require("@storybook/react-native-theming");
|
|
144
|
-
var
|
|
832
|
+
var import_react14 = __toESM(require("react"));
|
|
145
833
|
var import_react_native13 = require("react-native");
|
|
146
834
|
|
|
147
835
|
// src/constants.ts
|
|
148
836
|
var ANIMATION_DURATION_TRANSITION = 400;
|
|
149
837
|
|
|
150
838
|
// src/preview/components/StoryListView/StoryListView.tsx
|
|
151
|
-
var import_addons = require("@storybook/addons");
|
|
152
839
|
var import_core_events = __toESM(require("@storybook/core-events"));
|
|
840
|
+
var import_manager_api = require("@storybook/manager-api");
|
|
153
841
|
var import_react_native_theming = require("@storybook/react-native-theming");
|
|
154
|
-
var
|
|
842
|
+
var import_react3 = __toESM(require("react"));
|
|
155
843
|
var import_react_native2 = require("react-native");
|
|
156
844
|
|
|
157
845
|
// src/preview/components/Shared/icons.tsx
|
|
@@ -359,7 +1047,7 @@ var HeaderContainer = import_react_native_theming.styled.TouchableOpacity(
|
|
|
359
1047
|
borderBottomRightRadius: selected && !childSelected ? theme3.storyList.sectionBorderRadius : void 0
|
|
360
1048
|
})
|
|
361
1049
|
);
|
|
362
|
-
var SectionHeader =
|
|
1050
|
+
var SectionHeader = import_react3.default.memo(
|
|
363
1051
|
({ name, onPress, isChildSelected, icon = "grid", expanded }) => {
|
|
364
1052
|
const selected = useIsStorySectionSelected(name) || isChildSelected;
|
|
365
1053
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
@@ -453,7 +1141,7 @@ var RenderItem = ({
|
|
|
453
1141
|
const isChildSelected = useIsChildSelected(item.stories);
|
|
454
1142
|
const firstChild = findFirstChildStory(item);
|
|
455
1143
|
const firstChildSelected = useIsStorySelected(firstChild?.id);
|
|
456
|
-
const [showChildren, setShowChildren] = (0,
|
|
1144
|
+
const [showChildren, setShowChildren] = (0, import_react3.useState)(false);
|
|
457
1145
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
458
1146
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
459
1147
|
SectionHeader,
|
|
@@ -490,8 +1178,8 @@ var RenderItem = ({
|
|
|
490
1178
|
] });
|
|
491
1179
|
};
|
|
492
1180
|
var StoryListView = ({ storyIndex }) => {
|
|
493
|
-
const originalData = (0,
|
|
494
|
-
const [data, setData] = (0,
|
|
1181
|
+
const originalData = (0, import_react3.useMemo)(() => getNestedStories(storyIndex), [storyIndex]);
|
|
1182
|
+
const [data, setData] = (0, import_react3.useState)(originalData);
|
|
495
1183
|
const theme3 = (0, import_react_native_theming.useTheme)();
|
|
496
1184
|
const handleChangeSearchText = (text) => {
|
|
497
1185
|
const query = text.trim();
|
|
@@ -502,10 +1190,10 @@ var StoryListView = ({ storyIndex }) => {
|
|
|
502
1190
|
setData(filterNestedStories(originalData, query));
|
|
503
1191
|
};
|
|
504
1192
|
const changeStory = (storyId) => {
|
|
505
|
-
const channel =
|
|
1193
|
+
const channel = import_manager_api.addons.getChannel();
|
|
506
1194
|
channel.emit(import_core_events.default.SET_CURRENT_STORY, { storyId });
|
|
507
1195
|
};
|
|
508
|
-
const renderItem =
|
|
1196
|
+
const renderItem = import_react3.default.useCallback(({ item }) => {
|
|
509
1197
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RenderItem, { item, changeStory });
|
|
510
1198
|
}, []);
|
|
511
1199
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.View, { style: { flex: 1 }, children: [
|
|
@@ -536,10 +1224,10 @@ var StoryListView = ({ storyIndex }) => {
|
|
|
536
1224
|
)
|
|
537
1225
|
] });
|
|
538
1226
|
};
|
|
539
|
-
var StoryListView_default =
|
|
1227
|
+
var StoryListView_default = import_react3.default.memo(StoryListView);
|
|
540
1228
|
|
|
541
1229
|
// src/preview/components/StoryView/StoryView.tsx
|
|
542
|
-
var
|
|
1230
|
+
var import_react4 = __toESM(require("react"));
|
|
543
1231
|
var import_react_native_theming2 = require("@storybook/react-native-theming");
|
|
544
1232
|
var import_react_native3 = require("react-native");
|
|
545
1233
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -566,10 +1254,10 @@ var StoryView = () => {
|
|
|
566
1254
|
}
|
|
567
1255
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.View, { style: { flex: 1, padding: 16, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { children: "Please open the sidebar and select a story to preview." }) });
|
|
568
1256
|
};
|
|
569
|
-
var StoryView_default =
|
|
1257
|
+
var StoryView_default = import_react4.default.memo(StoryView);
|
|
570
1258
|
|
|
571
1259
|
// src/preview/components/OnDeviceUI/absolute-positioned-keyboard-aware-view.tsx
|
|
572
|
-
var
|
|
1260
|
+
var import_react5 = __toESM(require("react"));
|
|
573
1261
|
var import_react_native4 = require("react-native");
|
|
574
1262
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
575
1263
|
var AbsolutePositionedKeyboardAwareView = ({
|
|
@@ -598,7 +1286,7 @@ var styles2 = import_react_native4.StyleSheet.create({
|
|
|
598
1286
|
absolute: { position: "absolute" },
|
|
599
1287
|
container: { flex: 1 }
|
|
600
1288
|
});
|
|
601
|
-
var absolute_positioned_keyboard_aware_view_default =
|
|
1289
|
+
var absolute_positioned_keyboard_aware_view_default = import_react5.default.memo(AbsolutePositionedKeyboardAwareView);
|
|
602
1290
|
|
|
603
1291
|
// src/preview/components/OnDeviceUI/OnDeviceUI.tsx
|
|
604
1292
|
var import_react_native_theming11 = require("@storybook/react-native-theming");
|
|
@@ -606,7 +1294,7 @@ var import_react_native14 = require("react-native");
|
|
|
606
1294
|
var import_react_native_safe_area_context2 = require("react-native-safe-area-context");
|
|
607
1295
|
|
|
608
1296
|
// src/preview/components/OnDeviceUI/Panel.tsx
|
|
609
|
-
var
|
|
1297
|
+
var import_react6 = __toESM(require("react"));
|
|
610
1298
|
var import_react_native5 = require("react-native");
|
|
611
1299
|
var import_react_native_theming3 = require("@storybook/react-native-theming");
|
|
612
1300
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
@@ -624,19 +1312,20 @@ var Panel = ({ edge, children, style }) => {
|
|
|
624
1312
|
]);
|
|
625
1313
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Container, { edge, style: containerStyle, children });
|
|
626
1314
|
};
|
|
627
|
-
var Panel_default =
|
|
1315
|
+
var Panel_default = import_react6.default.memo(Panel);
|
|
628
1316
|
|
|
629
1317
|
// src/preview/components/OnDeviceUI/addons/Addons.tsx
|
|
630
|
-
var
|
|
1318
|
+
var import_manager_api2 = require("@storybook/manager-api");
|
|
631
1319
|
var import_react_native_theming7 = require("@storybook/react-native-theming");
|
|
632
|
-
var
|
|
1320
|
+
var import_types = __toESM(require_dist());
|
|
1321
|
+
var import_react10 = __toESM(require("react"));
|
|
633
1322
|
var import_react_native8 = require("react-native");
|
|
634
1323
|
|
|
635
1324
|
// src/preview/components/OnDeviceUI/addons/List.tsx
|
|
636
|
-
var
|
|
1325
|
+
var import_react8 = __toESM(require("react"));
|
|
637
1326
|
|
|
638
1327
|
// src/preview/components/Shared/tabs.tsx
|
|
639
|
-
var
|
|
1328
|
+
var import_react7 = __toESM(require("react"));
|
|
640
1329
|
var import_react_native6 = require("react-native");
|
|
641
1330
|
var import_react_native_theming4 = require("@storybook/react-native-theming");
|
|
642
1331
|
var import_react_native_theming5 = require("@storybook/react-native-theming");
|
|
@@ -655,7 +1344,7 @@ var TabButtonTouchable = import_react_native_theming4.styled.TouchableOpacity(({
|
|
|
655
1344
|
borderRadius: theme3.tabs.borderRadius,
|
|
656
1345
|
backgroundColor: active ? theme3.tabs.activeBackgroundColor : theme3.tabs.inactiveBackgroundColor
|
|
657
1346
|
}));
|
|
658
|
-
var TabButton =
|
|
1347
|
+
var TabButton = import_react7.default.memo(({ onPress, id, active, children, testID }) => {
|
|
659
1348
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
660
1349
|
TabButtonTouchable,
|
|
661
1350
|
{
|
|
@@ -668,7 +1357,7 @@ var TabButton = import_react6.default.memo(({ onPress, id, active, children, tes
|
|
|
668
1357
|
}
|
|
669
1358
|
);
|
|
670
1359
|
});
|
|
671
|
-
var TabBar =
|
|
1360
|
+
var TabBar = import_react7.default.memo(({ scrollable = false, style, children }) => {
|
|
672
1361
|
const theme3 = (0, import_react_native_theming5.useTheme)();
|
|
673
1362
|
if (scrollable) {
|
|
674
1363
|
children = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -692,10 +1381,8 @@ var TabBarContainer = import_react_native_theming4.styled.View(() => ({
|
|
|
692
1381
|
// src/preview/components/OnDeviceUI/addons/List.tsx
|
|
693
1382
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
694
1383
|
var AddonList = ({ panels, addonSelected, onPressAddon }) => {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
const { title } = panels[id];
|
|
698
|
-
let resolvedTitle = typeof title === "function" ? title() : title;
|
|
1384
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TabBar, { scrollable: true, children: Object.values(panels).map(({ id, title }) => {
|
|
1385
|
+
let resolvedTitle = typeof title === "function" ? title({}) : title;
|
|
699
1386
|
if (typeof resolvedTitle === "string") {
|
|
700
1387
|
resolvedTitle = resolvedTitle.toUpperCase();
|
|
701
1388
|
}
|
|
@@ -711,11 +1398,11 @@ var AddonList = ({ panels, addonSelected, onPressAddon }) => {
|
|
|
711
1398
|
);
|
|
712
1399
|
}) });
|
|
713
1400
|
};
|
|
714
|
-
var List_default =
|
|
1401
|
+
var List_default = import_react8.default.memo(AddonList);
|
|
715
1402
|
|
|
716
1403
|
// src/preview/components/OnDeviceUI/addons/Wrapper.tsx
|
|
717
1404
|
var import_react_native_theming6 = require("@storybook/react-native-theming");
|
|
718
|
-
var
|
|
1405
|
+
var import_react9 = __toESM(require("react"));
|
|
719
1406
|
var import_react_native7 = require("react-native");
|
|
720
1407
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
721
1408
|
var Container2 = import_react_native_theming6.styled.View(({ selected }) => ({
|
|
@@ -732,7 +1419,7 @@ var Wrapper = ({ panels, addonSelected }) => {
|
|
|
732
1419
|
});
|
|
733
1420
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: content });
|
|
734
1421
|
};
|
|
735
|
-
var Wrapper_default =
|
|
1422
|
+
var Wrapper_default = import_react9.default.memo(Wrapper);
|
|
736
1423
|
|
|
737
1424
|
// src/preview/components/OnDeviceUI/addons/Addons.tsx
|
|
738
1425
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
@@ -740,7 +1427,7 @@ var Text3 = import_react_native_theming7.styled.Text(({ theme: theme3 }) => ({
|
|
|
740
1427
|
marginTop: theme3.tokens.spacing4
|
|
741
1428
|
}));
|
|
742
1429
|
var Addons = ({ active }) => {
|
|
743
|
-
const panels =
|
|
1430
|
+
const panels = import_manager_api2.addons.getElements(import_types.Addon_TypesEnum.PANEL);
|
|
744
1431
|
const [addonSelected, setAddonSelected] = useSelectedAddon(Object.keys(panels)[0]);
|
|
745
1432
|
const context = useStoryContext();
|
|
746
1433
|
const id = context?.id;
|
|
@@ -762,16 +1449,16 @@ var Addons = ({ active }) => {
|
|
|
762
1449
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Wrapper_default, { addonSelected: active ? addonSelected : null, panels })
|
|
763
1450
|
] });
|
|
764
1451
|
};
|
|
765
|
-
var Addons_default =
|
|
1452
|
+
var Addons_default = import_react10.default.memo(Addons);
|
|
766
1453
|
|
|
767
1454
|
// src/preview/components/OnDeviceUI/addons/AddonsSkeleton.tsx
|
|
768
|
-
var
|
|
1455
|
+
var import_react11 = __toESM(require("react"));
|
|
769
1456
|
var import_react_native_theming8 = require("@storybook/react-native-theming");
|
|
770
1457
|
var import_react_native9 = require("react-native");
|
|
771
1458
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
772
|
-
var AddonsSkeleton =
|
|
773
|
-
const progress =
|
|
774
|
-
|
|
1459
|
+
var AddonsSkeleton = import_react11.default.memo(function AddonsSkeleton2({ visible }) {
|
|
1460
|
+
const progress = import_react11.default.useRef(new import_react_native9.Animated.Value(visible ? 1 : 0));
|
|
1461
|
+
import_react11.default.useEffect(() => {
|
|
775
1462
|
import_react_native9.Animated.timing(progress.current, {
|
|
776
1463
|
toValue: visible ? 1 : 0,
|
|
777
1464
|
duration: ANIMATION_DURATION_TRANSITION,
|
|
@@ -938,13 +1625,13 @@ var getPreviewShadowStyle = (animatedValue) => ({
|
|
|
938
1625
|
});
|
|
939
1626
|
|
|
940
1627
|
// src/preview/components/OnDeviceUI/navigation/Navigation.tsx
|
|
941
|
-
var
|
|
1628
|
+
var import_react13 = __toESM(require("react"));
|
|
942
1629
|
var import_react_native12 = require("react-native");
|
|
943
1630
|
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
944
1631
|
var import_react_native_swipe_gestures = __toESM(require("react-native-swipe-gestures"));
|
|
945
1632
|
|
|
946
1633
|
// src/preview/components/OnDeviceUI/navigation/NavigationBar.tsx
|
|
947
|
-
var
|
|
1634
|
+
var import_react12 = __toESM(require("react"));
|
|
948
1635
|
var import_react_native_theming9 = require("@storybook/react-native-theming");
|
|
949
1636
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
950
1637
|
var NavigationTabBar = (0, import_react_native_theming9.styled)(TabBar)(({ theme: theme3 }) => ({
|
|
@@ -953,7 +1640,7 @@ var NavigationTabBar = (0, import_react_native_theming9.styled)(TabBar)(({ theme
|
|
|
953
1640
|
borderColor: theme3.navigation.borderColor,
|
|
954
1641
|
borderTopWidth: theme3.navigation.borderWidth
|
|
955
1642
|
}));
|
|
956
|
-
var NavigationBar =
|
|
1643
|
+
var NavigationBar = import_react12.default.memo(({ index, onPress, style }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(NavigationTabBar, { style, children: [
|
|
957
1644
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
958
1645
|
TabButton,
|
|
959
1646
|
{
|
|
@@ -1048,7 +1735,7 @@ var Navigation = ({ tabOpen, onChangeTab, onLayout }) => {
|
|
|
1048
1735
|
] })
|
|
1049
1736
|
] });
|
|
1050
1737
|
};
|
|
1051
|
-
var Navigation_default =
|
|
1738
|
+
var Navigation_default = import_react13.default.memo(Navigation);
|
|
1052
1739
|
function NavigationShortcuts({ children }) {
|
|
1053
1740
|
const insets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
|
|
1054
1741
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
@@ -1100,16 +1787,16 @@ var OnDeviceUI = ({
|
|
|
1100
1787
|
keyboardAvoidingViewVerticalOffset,
|
|
1101
1788
|
tabOpen: initialTabOpen
|
|
1102
1789
|
}) => {
|
|
1103
|
-
const [tabOpen, setTabOpen] = (0,
|
|
1104
|
-
const lastTabOpen =
|
|
1105
|
-
const [previewDimensions, setPreviewDimensions] = (0,
|
|
1790
|
+
const [tabOpen, setTabOpen] = (0, import_react14.useState)(initialTabOpen || CANVAS);
|
|
1791
|
+
const lastTabOpen = import_react14.default.useRef(tabOpen);
|
|
1792
|
+
const [previewDimensions, setPreviewDimensions] = (0, import_react14.useState)(() => ({
|
|
1106
1793
|
width: import_react_native13.Dimensions.get("window").width,
|
|
1107
1794
|
height: import_react_native13.Dimensions.get("window").height
|
|
1108
1795
|
}));
|
|
1109
|
-
const animatedValue = (0,
|
|
1796
|
+
const animatedValue = (0, import_react14.useRef)(new import_react_native13.Animated.Value(tabOpen));
|
|
1110
1797
|
const wide = (0, import_react_native14.useWindowDimensions)().width >= BREAKPOINT;
|
|
1111
1798
|
const insets = (0, import_react_native_safe_area_context2.useSafeAreaInsets)();
|
|
1112
|
-
const handleToggleTab =
|
|
1799
|
+
const handleToggleTab = import_react14.default.useCallback(
|
|
1113
1800
|
(newTabOpen) => {
|
|
1114
1801
|
if (newTabOpen === tabOpen) {
|
|
1115
1802
|
return;
|
|
@@ -1141,8 +1828,8 @@ var OnDeviceUI = ({
|
|
|
1141
1828
|
})
|
|
1142
1829
|
];
|
|
1143
1830
|
const [isUIVisible] = useIsUIVisible();
|
|
1144
|
-
const [navBarHeight, setNavBarHeight] =
|
|
1145
|
-
const measureNavigation =
|
|
1831
|
+
const [navBarHeight, setNavBarHeight] = import_react14.default.useState(insets.bottom + 40);
|
|
1832
|
+
const measureNavigation = import_react14.default.useCallback(
|
|
1146
1833
|
({ nativeEvent }) => {
|
|
1147
1834
|
const inset = insets.bottom;
|
|
1148
1835
|
setNavBarHeight(isUIVisible ? nativeEvent.layout.height - inset : 0);
|
|
@@ -1221,11 +1908,14 @@ var OnDeviceUI = ({
|
|
|
1221
1908
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Navigation_default, { onLayout: measureNavigation, tabOpen, onChangeTab: handleToggleTab })
|
|
1222
1909
|
] }) });
|
|
1223
1910
|
};
|
|
1224
|
-
var OnDeviceUI_default =
|
|
1911
|
+
var OnDeviceUI_default = import_react14.default.memo(OnDeviceUI);
|
|
1225
1912
|
|
|
1226
1913
|
// src/preview/View.tsx
|
|
1227
|
-
var import_react_native_theming13 = require("@storybook/react-native-theming");
|
|
1228
1914
|
var import_channels = require("@storybook/channels");
|
|
1915
|
+
var import_core_events2 = __toESM(require("@storybook/core-events"));
|
|
1916
|
+
var import_global = require("@storybook/global");
|
|
1917
|
+
var import_deepmerge = __toESM(require("deepmerge"));
|
|
1918
|
+
var import_react_native15 = require("react-native");
|
|
1229
1919
|
|
|
1230
1920
|
// src/preview/rn-host-detect.js
|
|
1231
1921
|
function getByRemoteConfig(hostname) {
|
|
@@ -1273,9 +1963,6 @@ function getHost(hostname) {
|
|
|
1273
1963
|
}
|
|
1274
1964
|
|
|
1275
1965
|
// src/preview/View.tsx
|
|
1276
|
-
var import_core_events2 = __toESM(require("@storybook/core-events"));
|
|
1277
|
-
var import_react_native15 = require("react-native");
|
|
1278
|
-
var import_deepmerge = __toESM(require("deepmerge"));
|
|
1279
1966
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1280
1967
|
var STORAGE_KEY = "lastOpenedStory";
|
|
1281
1968
|
var View10 = class {
|
|
@@ -1336,13 +2023,13 @@ var View10 = class {
|
|
|
1336
2023
|
const initialStory = this._getInitialStory(params);
|
|
1337
2024
|
if (enableWebsockets) {
|
|
1338
2025
|
const channel = this._getServerChannel(params);
|
|
1339
|
-
|
|
2026
|
+
import_manager_api3.addons.setChannel(channel);
|
|
1340
2027
|
this._preview.channel = channel;
|
|
1341
2028
|
this._preview.setupListeners();
|
|
1342
2029
|
channel.emit(import_core_events2.default.CHANNEL_CREATED);
|
|
1343
2030
|
this._preview.initializeWithStoryIndex(this._storyIndex);
|
|
1344
2031
|
}
|
|
1345
|
-
|
|
2032
|
+
import_manager_api3.addons.loadAddons({
|
|
1346
2033
|
store: () => ({
|
|
1347
2034
|
fromId: (id) => this._preview.storyStore.getStoryContext(this._preview.storyStore.fromId(id)),
|
|
1348
2035
|
getSelection: () => {
|
|
@@ -1360,12 +2047,12 @@ var View10 = class {
|
|
|
1360
2047
|
return () => {
|
|
1361
2048
|
const setContext = useSetStoryContext();
|
|
1362
2049
|
const colorScheme = (0, import_react_native15.useColorScheme)();
|
|
1363
|
-
const [, forceUpdate] = (0,
|
|
1364
|
-
const appliedTheme = (0,
|
|
1365
|
-
() => (0, import_deepmerge.default)(colorScheme === "dark" ?
|
|
2050
|
+
const [, forceUpdate] = (0, import_react15.useReducer)((x) => x + 1, 0);
|
|
2051
|
+
const appliedTheme = (0, import_react15.useMemo)(
|
|
2052
|
+
() => (0, import_deepmerge.default)(colorScheme === "dark" ? import_react_native_theming12.darkTheme : import_react_native_theming12.theme, params.theme ?? {}),
|
|
1366
2053
|
[colorScheme]
|
|
1367
2054
|
);
|
|
1368
|
-
(0,
|
|
2055
|
+
(0, import_react15.useEffect)(() => {
|
|
1369
2056
|
self._setStory = (newStory) => {
|
|
1370
2057
|
setContext(newStory);
|
|
1371
2058
|
if (shouldPersistSelection) {
|
|
@@ -1379,6 +2066,13 @@ var View10 = class {
|
|
|
1379
2066
|
self._preview.selectionStore.selectionSpecifier = story;
|
|
1380
2067
|
self._preview.selectSpecifiedStory();
|
|
1381
2068
|
});
|
|
2069
|
+
import_global.global.__STORYBOOK_ADDONS_CHANNEL__.on(import_core_events2.default.SET_CURRENT_STORY, ({ storyId }) => {
|
|
2070
|
+
self._preview.selectSpecifiedStory();
|
|
2071
|
+
const newStoryContext = this._preview.storyStore.getStoryContext(
|
|
2072
|
+
this._preview.storyStore.fromId(storyId)
|
|
2073
|
+
);
|
|
2074
|
+
setContext(newStoryContext);
|
|
2075
|
+
});
|
|
1382
2076
|
}, []);
|
|
1383
2077
|
if (onDeviceUI) {
|
|
1384
2078
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native_safe_area_context3.SafeAreaProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native_theming12.ThemeProvider, { theme: appliedTheme, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
@@ -1455,7 +2149,7 @@ function executeLoadableForChanges(loadable, m) {
|
|
|
1455
2149
|
|
|
1456
2150
|
// src/preview/start.tsx
|
|
1457
2151
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1458
|
-
|
|
2152
|
+
import_global2.global.FEATURES = {
|
|
1459
2153
|
storyStoreV7: false
|
|
1460
2154
|
};
|
|
1461
2155
|
var render = (args, context) => {
|
|
@@ -1468,42 +2162,32 @@ var render = (args, context) => {
|
|
|
1468
2162
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Component, { ...args });
|
|
1469
2163
|
};
|
|
1470
2164
|
function start() {
|
|
1471
|
-
const channel = new import_channels2.
|
|
1472
|
-
|
|
2165
|
+
const channel = new import_channels2.Channel({ async: true });
|
|
2166
|
+
import_manager_api4.addons.setChannel(channel);
|
|
2167
|
+
channel.emit(import_core_events3.default.CHANNEL_CREATED);
|
|
1473
2168
|
const clientApi2 = new import_preview_api.ClientApi();
|
|
1474
2169
|
const previewView = {
|
|
1475
2170
|
prepareForStory: () => {
|
|
1476
|
-
return {};
|
|
2171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, {});
|
|
1477
2172
|
},
|
|
1478
|
-
|
|
1479
|
-
},
|
|
1480
|
-
showPreparingStory: () => {
|
|
2173
|
+
prepareForDocs: () => {
|
|
1481
2174
|
},
|
|
1482
|
-
|
|
2175
|
+
showErrorDisplay: () => {
|
|
1483
2176
|
},
|
|
1484
|
-
|
|
1485
|
-
console.log(e);
|
|
1486
|
-
},
|
|
1487
|
-
showStoryDuringRender: () => {
|
|
2177
|
+
showDocs: () => {
|
|
1488
2178
|
},
|
|
1489
2179
|
showMain: () => {
|
|
1490
2180
|
},
|
|
1491
|
-
|
|
1492
|
-
},
|
|
1493
|
-
showStory: () => {
|
|
2181
|
+
showNoPreview: () => {
|
|
1494
2182
|
},
|
|
1495
|
-
|
|
1496
|
-
prepareForDocs: () => null,
|
|
1497
|
-
showDocs: () => {
|
|
2183
|
+
showPreparingDocs: () => {
|
|
1498
2184
|
},
|
|
1499
|
-
|
|
1500
|
-
}, 0),
|
|
1501
|
-
showMode: () => {
|
|
2185
|
+
showPreparingStory: () => {
|
|
1502
2186
|
},
|
|
1503
|
-
|
|
2187
|
+
showStory: () => {
|
|
1504
2188
|
},
|
|
1505
|
-
|
|
1506
|
-
|
|
2189
|
+
showStoryDuringRender: () => {
|
|
2190
|
+
}
|
|
1507
2191
|
};
|
|
1508
2192
|
const urlStore = {
|
|
1509
2193
|
selection: null,
|
|
@@ -1516,11 +2200,11 @@ function start() {
|
|
|
1516
2200
|
};
|
|
1517
2201
|
const preview = new import_preview_web.PreviewWithSelection(urlStore, previewView);
|
|
1518
2202
|
clientApi2.storyStore = preview.storyStore;
|
|
1519
|
-
if (
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
2203
|
+
if (import_global2.global) {
|
|
2204
|
+
import_global2.global.__STORYBOOK_CLIENT_API__ = clientApi2;
|
|
2205
|
+
import_global2.global.__STORYBOOK_ADDONS_CHANNEL__ = channel;
|
|
2206
|
+
import_global2.global.__STORYBOOK_PREVIEW__ = preview;
|
|
2207
|
+
import_global2.global.__STORYBOOK_STORY_STORE__ = preview.storyStore;
|
|
1524
2208
|
}
|
|
1525
2209
|
(0, import_preview_api.setGlobalRender)(render);
|
|
1526
2210
|
let initialized = false;
|
|
@@ -1576,7 +2260,7 @@ function start() {
|
|
|
1576
2260
|
}
|
|
1577
2261
|
|
|
1578
2262
|
// src/index.ts
|
|
1579
|
-
var
|
|
2263
|
+
var import_react_native_theming13 = require("@storybook/react-native-theming");
|
|
1580
2264
|
var { clientApi, configure, view } = start();
|
|
1581
2265
|
var rawStoriesOf = clientApi.storiesOf.bind(clientApi);
|
|
1582
2266
|
var addDecorator = clientApi.addDecorator.bind(clientApi);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.4",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
35
|
"dev": "ts-node ./buildscripts/gentsdev.ts && tsup --watch",
|
|
36
|
-
"prepare": "tsup",
|
|
36
|
+
"prepare": "rm -rf dist/ && tsup",
|
|
37
37
|
"test": "jest"
|
|
38
38
|
},
|
|
39
39
|
"jest": {
|
|
@@ -51,22 +51,22 @@
|
|
|
51
51
|
"preset": "react-native"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@storybook/addons": "^7",
|
|
55
54
|
"@storybook/channel-websocket": "^7",
|
|
56
55
|
"@storybook/channels": "^7",
|
|
57
56
|
"@storybook/client-logger": "^7",
|
|
58
57
|
"@storybook/core-client": "^7",
|
|
58
|
+
"@storybook/core-common": "^7",
|
|
59
59
|
"@storybook/core-events": "^7",
|
|
60
60
|
"@storybook/csf": "^0.1.1",
|
|
61
61
|
"@storybook/global": "^5.0.0",
|
|
62
|
+
"@storybook/manager-api": "^7",
|
|
62
63
|
"@storybook/preview-api": "^7",
|
|
63
64
|
"@storybook/preview-web": "^7",
|
|
64
|
-
"@storybook/react-native-theming": "^7.0.0-alpha.
|
|
65
|
+
"@storybook/react-native-theming": "^7.0.0-alpha.4",
|
|
65
66
|
"chokidar": "^3.5.1",
|
|
66
67
|
"commander": "^8.2.0",
|
|
67
68
|
"deepmerge": "^4.3.0",
|
|
68
69
|
"glob": "^7.1.7",
|
|
69
|
-
"jotai": "^2.0.2",
|
|
70
70
|
"prettier": "^2.4.1",
|
|
71
71
|
"react-native-swipe-gestures": "^1.0.5",
|
|
72
72
|
"util": "^0.12.4"
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"@types/react": "~18.2.14",
|
|
78
78
|
"babel-jest": "^29.4.3",
|
|
79
79
|
"jest": "^29.4.3",
|
|
80
|
+
"jotai": "^2.0.2",
|
|
80
81
|
"react-test-renderer": "18.2.0",
|
|
81
82
|
"ts-node": "^10.9.1",
|
|
82
83
|
"tsup": "^7.2.0",
|
|
@@ -94,5 +95,5 @@
|
|
|
94
95
|
"publishConfig": {
|
|
95
96
|
"access": "public"
|
|
96
97
|
},
|
|
97
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "eb7e4f2ad33a74b8c898c95cbdbbd5bec3c051db"
|
|
98
99
|
}
|