@storybook/react-native 7.0.0-alpha.5 → 7.0.0-alpha.6
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/V6.js +1 -0
- package/dist/V6.d.ts +28 -0
- package/dist/V6.js +2247 -0
- package/dist/View-8eae84cb.d.ts +128 -0
- package/dist/index.d-680e82dc.d.ts +201 -0
- package/dist/index.d.ts +18 -286
- package/dist/index.js +375 -486
- package/dist/preview.d.ts +12 -0
- package/dist/preview.js +34 -0
- package/package.json +15 -13
- package/scripts/__snapshots__/generate.test.js.snap +121 -0
- package/scripts/__snapshots__/loader.test.js.snap +0 -27
- package/scripts/common.js +68 -0
- package/scripts/generate.js +104 -0
- package/scripts/generate.test.js +95 -0
- package/scripts/get-stories.js +7 -2
- package/scripts/handle-args.js +4 -2
- package/scripts/loader.js +10 -56
- package/scripts/loader.test.js +2 -6
package/dist/index.js
CHANGED
|
@@ -51,40 +51,33 @@ var require_dist = __commonJS({
|
|
|
51
51
|
var src_exports2 = {};
|
|
52
52
|
__export2(src_exports2, { Addon_TypesEnum: () => Addon_TypesEnum2 });
|
|
53
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 || {});
|
|
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.experimental_SIDEBAR_BOTTOM = "sidebar-bottom", Addon_TypesEnum22.experimental_SIDEBAR_TOP = "sidebar-top", Addon_TypesEnum22.NOTES_ELEMENT = "notes-element", Addon_TypesEnum22))(Addon_TypesEnum2 || {});
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
// src/index.ts
|
|
59
59
|
var src_exports = {};
|
|
60
60
|
__export(src_exports, {
|
|
61
|
-
addArgTypesEnhancer: () => addArgTypesEnhancer,
|
|
62
|
-
addArgsEnhancer: () => addArgsEnhancer,
|
|
63
|
-
addDecorator: () => addDecorator,
|
|
64
|
-
addParameters: () => addParameters,
|
|
65
|
-
configure: () => configure,
|
|
66
61
|
darkTheme: () => import_react_native_theming13.darkTheme,
|
|
67
|
-
|
|
68
|
-
raw: () => raw,
|
|
69
|
-
storiesOf: () => storiesOf,
|
|
62
|
+
start: () => start,
|
|
70
63
|
theme: () => import_react_native_theming13.theme
|
|
71
64
|
});
|
|
72
65
|
module.exports = __toCommonJS(src_exports);
|
|
66
|
+
var import_react_native_theming13 = require("@storybook/react-native-theming");
|
|
73
67
|
|
|
74
|
-
// src/
|
|
75
|
-
var
|
|
76
|
-
var import_core_events3 = __toESM(require("@storybook/core-events"));
|
|
77
|
-
var import_global2 = require("@storybook/global");
|
|
78
|
-
var import_manager_api4 = require("@storybook/manager-api");
|
|
68
|
+
// src/Start.tsx
|
|
69
|
+
var import_csf2 = require("@storybook/csf");
|
|
79
70
|
var import_preview_api = require("@storybook/preview-api");
|
|
80
|
-
var
|
|
71
|
+
var import_manager_api3 = require("@storybook/manager-api");
|
|
72
|
+
var import_preview_web = require("@storybook/preview-api/dist/preview-web");
|
|
73
|
+
var import_channels = require("@storybook/channels");
|
|
81
74
|
|
|
82
|
-
// src/
|
|
75
|
+
// src/View.tsx
|
|
83
76
|
var import_async_storage = __toESM(require("@react-native-async-storage/async-storage"));
|
|
84
77
|
var import_csf = require("@storybook/csf");
|
|
85
|
-
var
|
|
78
|
+
var import_manager_api2 = require("@storybook/manager-api");
|
|
86
79
|
var import_react_native_theming12 = require("@storybook/react-native-theming");
|
|
87
|
-
var
|
|
80
|
+
var import_react16 = require("react");
|
|
88
81
|
var import_react_native_safe_area_context3 = require("react-native-safe-area-context");
|
|
89
82
|
|
|
90
83
|
// src/hooks.tsx
|
|
@@ -151,11 +144,9 @@ var createStore = () => {
|
|
|
151
144
|
const atomStateMap = /* @__PURE__ */ new WeakMap();
|
|
152
145
|
const mountedMap = /* @__PURE__ */ new WeakMap();
|
|
153
146
|
const pendingMap = /* @__PURE__ */ new Map();
|
|
154
|
-
let storeListenersRev1;
|
|
155
147
|
let storeListenersRev2;
|
|
156
148
|
let mountedAtoms;
|
|
157
149
|
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
158
|
-
storeListenersRev1 = /* @__PURE__ */ new Set();
|
|
159
150
|
storeListenersRev2 = /* @__PURE__ */ new Set();
|
|
160
151
|
mountedAtoms = /* @__PURE__ */ new Set();
|
|
161
152
|
}
|
|
@@ -293,19 +284,15 @@ var createStore = () => {
|
|
|
293
284
|
setAtomState(atom2, nextAtomState);
|
|
294
285
|
return nextAtomState;
|
|
295
286
|
};
|
|
296
|
-
const readAtomState = (atom2) => {
|
|
287
|
+
const readAtomState = (atom2, force) => {
|
|
297
288
|
const atomState = getAtomState(atom2);
|
|
298
|
-
if (atomState) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
})) {
|
|
289
|
+
if (!force && atomState) {
|
|
290
|
+
if (mountedMap.has(atom2)) {
|
|
291
|
+
return atomState;
|
|
292
|
+
}
|
|
293
|
+
if (Array.from(atomState.d).every(
|
|
294
|
+
([a, s]) => a === atom2 || readAtomState(a) === s
|
|
295
|
+
)) {
|
|
309
296
|
return atomState;
|
|
310
297
|
}
|
|
311
298
|
}
|
|
@@ -413,7 +400,7 @@ var createStore = () => {
|
|
|
413
400
|
let isChanged = !!((_a = dependencyMap.get(dependent)) == null ? void 0 : _a.size);
|
|
414
401
|
if (isChanged) {
|
|
415
402
|
const prevAtomState = getAtomState(dependent);
|
|
416
|
-
const nextAtomState = readAtomState(dependent);
|
|
403
|
+
const nextAtomState = readAtomState(dependent, true);
|
|
417
404
|
isChanged = !prevAtomState || !isEqualAtomValue(prevAtomState, nextAtomState);
|
|
418
405
|
}
|
|
419
406
|
if (!isChanged) {
|
|
@@ -468,15 +455,8 @@ var createStore = () => {
|
|
|
468
455
|
return result;
|
|
469
456
|
};
|
|
470
457
|
const mountAtom = (atom2, initialDependent) => {
|
|
471
|
-
|
|
472
|
-
|
|
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) => {
|
|
458
|
+
var _a;
|
|
459
|
+
(_a = getAtomState(atom2)) == null ? void 0 : _a.d.forEach((_, a) => {
|
|
480
460
|
const aMounted = mountedMap.get(a);
|
|
481
461
|
if (aMounted) {
|
|
482
462
|
aMounted.t.add(atom2);
|
|
@@ -487,6 +467,14 @@ var createStore = () => {
|
|
|
487
467
|
}
|
|
488
468
|
});
|
|
489
469
|
readAtomState(atom2);
|
|
470
|
+
const mounted = {
|
|
471
|
+
t: new Set(initialDependent && [initialDependent]),
|
|
472
|
+
l: /* @__PURE__ */ new Set()
|
|
473
|
+
};
|
|
474
|
+
mountedMap.set(atom2, mounted);
|
|
475
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
476
|
+
mountedAtoms.add(atom2);
|
|
477
|
+
}
|
|
490
478
|
if (isActuallyWritableAtom(atom2) && atom2.onMount) {
|
|
491
479
|
const onUnmount = atom2.onMount((...args) => writeAtom(atom2, ...args));
|
|
492
480
|
if (onUnmount) {
|
|
@@ -578,7 +566,6 @@ var createStore = () => {
|
|
|
578
566
|
});
|
|
579
567
|
}
|
|
580
568
|
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
581
|
-
storeListenersRev1.forEach((l) => l("state"));
|
|
582
569
|
return flushed;
|
|
583
570
|
}
|
|
584
571
|
};
|
|
@@ -588,7 +575,6 @@ var createStore = () => {
|
|
|
588
575
|
const listeners = mounted.l;
|
|
589
576
|
listeners.add(listener);
|
|
590
577
|
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
591
|
-
storeListenersRev1.forEach((l) => l("sub"));
|
|
592
578
|
storeListenersRev2.forEach(
|
|
593
579
|
(l) => l({ type: "sub", flushed })
|
|
594
580
|
);
|
|
@@ -597,7 +583,6 @@ var createStore = () => {
|
|
|
597
583
|
listeners.delete(listener);
|
|
598
584
|
delAtom(atom2);
|
|
599
585
|
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
600
|
-
storeListenersRev1.forEach((l) => l("unsub"));
|
|
601
586
|
storeListenersRev2.forEach((l) => l({ type: "unsub" }));
|
|
602
587
|
}
|
|
603
588
|
};
|
|
@@ -610,13 +595,7 @@ var createStore = () => {
|
|
|
610
595
|
// store dev methods (these are tentative and subject to change without notice)
|
|
611
596
|
dev_subscribe_store: (l, rev) => {
|
|
612
597
|
if (rev !== 2) {
|
|
613
|
-
|
|
614
|
-
"The current StoreListener revision is 2. The older ones are deprecated."
|
|
615
|
-
);
|
|
616
|
-
storeListenersRev1.add(l);
|
|
617
|
-
return () => {
|
|
618
|
-
storeListenersRev1.delete(l);
|
|
619
|
-
};
|
|
598
|
+
throw new Error("The current StoreListener revision is 2.");
|
|
620
599
|
}
|
|
621
600
|
storeListenersRev2.add(l);
|
|
622
601
|
return () => {
|
|
@@ -647,21 +626,24 @@ var createStore = () => {
|
|
|
647
626
|
};
|
|
648
627
|
};
|
|
649
628
|
var defaultStore;
|
|
629
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
|
|
630
|
+
if (typeof globalThis.__NUMBER_OF_JOTAI_INSTANCES__ === "number") {
|
|
631
|
+
++globalThis.__NUMBER_OF_JOTAI_INSTANCES__;
|
|
632
|
+
} else {
|
|
633
|
+
globalThis.__NUMBER_OF_JOTAI_INSTANCES__ = 1;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
650
636
|
var getDefaultStore = () => {
|
|
651
637
|
if (!defaultStore) {
|
|
638
|
+
if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production" && globalThis.__NUMBER_OF_JOTAI_INSTANCES__ !== 1) {
|
|
639
|
+
console.warn(
|
|
640
|
+
"Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
|
|
641
|
+
);
|
|
642
|
+
}
|
|
652
643
|
defaultStore = createStore();
|
|
653
644
|
}
|
|
654
645
|
return defaultStore;
|
|
655
646
|
};
|
|
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
647
|
|
|
666
648
|
// ../../node_modules/jotai/esm/react.mjs
|
|
667
649
|
var import_react = __toESM(require("react"), 1);
|
|
@@ -827,22 +809,21 @@ function useSelectedAddon(initialValue) {
|
|
|
827
809
|
return result;
|
|
828
810
|
}
|
|
829
811
|
|
|
830
|
-
// src/
|
|
812
|
+
// src/components/OnDeviceUI/OnDeviceUI.tsx
|
|
831
813
|
var import_react_native_theming10 = require("@storybook/react-native-theming");
|
|
832
|
-
var
|
|
833
|
-
var
|
|
814
|
+
var import_react15 = __toESM(require("react"));
|
|
815
|
+
var import_react_native14 = require("react-native");
|
|
834
816
|
|
|
835
817
|
// src/constants.ts
|
|
836
818
|
var ANIMATION_DURATION_TRANSITION = 400;
|
|
837
819
|
|
|
838
|
-
// src/
|
|
820
|
+
// src/components/StoryListView/StoryListView.tsx
|
|
839
821
|
var import_core_events = __toESM(require("@storybook/core-events"));
|
|
840
|
-
var import_manager_api = require("@storybook/manager-api");
|
|
841
822
|
var import_react_native_theming = require("@storybook/react-native-theming");
|
|
842
823
|
var import_react3 = __toESM(require("react"));
|
|
843
824
|
var import_react_native2 = require("react-native");
|
|
844
825
|
|
|
845
|
-
// src/
|
|
826
|
+
// src/components/Shared/icons.tsx
|
|
846
827
|
var import_react_native = require("react-native");
|
|
847
828
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
848
829
|
var iconSources = {
|
|
@@ -901,7 +882,7 @@ function BackgroundIcon({ name, ...props }) {
|
|
|
901
882
|
);
|
|
902
883
|
}
|
|
903
884
|
|
|
904
|
-
// src/
|
|
885
|
+
// src/components/StoryListView/getNestedStories.ts
|
|
905
886
|
function getNestedStories(storyIndex) {
|
|
906
887
|
const stories = Object.values(storyIndex?.entries ?? {});
|
|
907
888
|
const group = [];
|
|
@@ -975,7 +956,7 @@ var findFirstChildStory = (story) => {
|
|
|
975
956
|
}
|
|
976
957
|
};
|
|
977
958
|
|
|
978
|
-
// src/
|
|
959
|
+
// src/components/StoryListView/StoryListView.tsx
|
|
979
960
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
980
961
|
var SectionHeaderText = import_react_native_theming.styled.Text(({ theme: theme3 }) => ({
|
|
981
962
|
fontSize: theme3.storyList.fontSize,
|
|
@@ -1190,8 +1171,7 @@ var StoryListView = ({ storyIndex }) => {
|
|
|
1190
1171
|
setData(filterNestedStories(originalData, query));
|
|
1191
1172
|
};
|
|
1192
1173
|
const changeStory = (storyId) => {
|
|
1193
|
-
|
|
1194
|
-
channel.emit(import_core_events.default.SET_CURRENT_STORY, { storyId });
|
|
1174
|
+
global.__STORYBOOK_ADDONS_CHANNEL__.emit(import_core_events.default.SET_CURRENT_STORY, { storyId });
|
|
1195
1175
|
};
|
|
1196
1176
|
const renderItem = import_react3.default.useCallback(({ item }) => {
|
|
1197
1177
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RenderItem, { item, changeStory });
|
|
@@ -1226,13 +1206,38 @@ var StoryListView = ({ storyIndex }) => {
|
|
|
1226
1206
|
};
|
|
1227
1207
|
var StoryListView_default = import_react3.default.memo(StoryListView);
|
|
1228
1208
|
|
|
1229
|
-
// src/
|
|
1230
|
-
var
|
|
1209
|
+
// src/components/StoryView/StoryView.tsx
|
|
1210
|
+
var import_react5 = __toESM(require("react"));
|
|
1231
1211
|
var import_react_native_theming2 = require("@storybook/react-native-theming");
|
|
1212
|
+
var import_react_native4 = require("react-native");
|
|
1213
|
+
|
|
1214
|
+
// src/components/StoryView/ErrorBoundary.tsx
|
|
1215
|
+
var import_react4 = __toESM(require("react"));
|
|
1232
1216
|
var import_react_native3 = require("react-native");
|
|
1233
1217
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1218
|
+
var ErrorBoundary = class extends import_react4.default.Component {
|
|
1219
|
+
constructor(props) {
|
|
1220
|
+
super(props);
|
|
1221
|
+
this.state = { hasError: false };
|
|
1222
|
+
}
|
|
1223
|
+
static getDerivedStateFromError(_error) {
|
|
1224
|
+
return { hasError: true };
|
|
1225
|
+
}
|
|
1226
|
+
componentDidCatch(error, errorInfo) {
|
|
1227
|
+
console.warn(error, errorInfo);
|
|
1228
|
+
}
|
|
1229
|
+
render() {
|
|
1230
|
+
if (this.state.hasError) {
|
|
1231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native3.Text, { children: "Something went wrong rendering your story" });
|
|
1232
|
+
}
|
|
1233
|
+
return this.props.children;
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
|
|
1237
|
+
// src/components/StoryView/StoryView.tsx
|
|
1238
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1234
1239
|
function dismissOnStartResponder() {
|
|
1235
|
-
|
|
1240
|
+
import_react_native4.Keyboard.dismiss();
|
|
1236
1241
|
return false;
|
|
1237
1242
|
}
|
|
1238
1243
|
var StoryView = () => {
|
|
@@ -1241,25 +1246,25 @@ var StoryView = () => {
|
|
|
1241
1246
|
const { backgroundColor } = (0, import_react_native_theming2.useTheme)();
|
|
1242
1247
|
if (context && context.unboundStoryFn) {
|
|
1243
1248
|
const { unboundStoryFn: StoryComponent } = context;
|
|
1244
|
-
return /* @__PURE__ */ (0,
|
|
1245
|
-
|
|
1249
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1250
|
+
import_react_native4.View,
|
|
1246
1251
|
{
|
|
1247
1252
|
style: { flex: 1, backgroundColor },
|
|
1248
1253
|
testID: id,
|
|
1249
1254
|
onStartShouldSetResponder: dismissOnStartResponder,
|
|
1250
|
-
children: StoryComponent && /* @__PURE__ */ (0,
|
|
1255
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorBoundary, { children: StoryComponent && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(StoryComponent, { ...context }) })
|
|
1251
1256
|
},
|
|
1252
1257
|
id
|
|
1253
1258
|
);
|
|
1254
1259
|
}
|
|
1255
|
-
return /* @__PURE__ */ (0,
|
|
1260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.View, { style: { flex: 1, padding: 16, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native4.Text, { children: "Please open the sidebar and select a story to preview." }) });
|
|
1256
1261
|
};
|
|
1257
|
-
var StoryView_default =
|
|
1262
|
+
var StoryView_default = import_react5.default.memo(StoryView);
|
|
1258
1263
|
|
|
1259
|
-
// src/
|
|
1260
|
-
var
|
|
1261
|
-
var
|
|
1262
|
-
var
|
|
1264
|
+
// src/components/OnDeviceUI/absolute-positioned-keyboard-aware-view.tsx
|
|
1265
|
+
var import_react6 = __toESM(require("react"));
|
|
1266
|
+
var import_react_native5 = require("react-native");
|
|
1267
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1263
1268
|
var AbsolutePositionedKeyboardAwareView = ({
|
|
1264
1269
|
onLayout,
|
|
1265
1270
|
previewDimensions: { width, height },
|
|
@@ -1274,31 +1279,31 @@ var AbsolutePositionedKeyboardAwareView = ({
|
|
|
1274
1279
|
});
|
|
1275
1280
|
}
|
|
1276
1281
|
};
|
|
1277
|
-
return /* @__PURE__ */ (0,
|
|
1278
|
-
|
|
1282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_native5.View, { style: styles2.container, onLayout: onLayoutHandler, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1283
|
+
import_react_native5.View,
|
|
1279
1284
|
{
|
|
1280
1285
|
style: width === 0 ? styles2.container : [styles2.absolute, { position: "absolute", width, height }],
|
|
1281
1286
|
children
|
|
1282
1287
|
}
|
|
1283
1288
|
) });
|
|
1284
1289
|
};
|
|
1285
|
-
var styles2 =
|
|
1290
|
+
var styles2 = import_react_native5.StyleSheet.create({
|
|
1286
1291
|
absolute: { position: "absolute" },
|
|
1287
1292
|
container: { flex: 1 }
|
|
1288
1293
|
});
|
|
1289
|
-
var absolute_positioned_keyboard_aware_view_default =
|
|
1294
|
+
var absolute_positioned_keyboard_aware_view_default = import_react6.default.memo(AbsolutePositionedKeyboardAwareView);
|
|
1290
1295
|
|
|
1291
|
-
// src/
|
|
1296
|
+
// src/components/OnDeviceUI/OnDeviceUI.tsx
|
|
1292
1297
|
var import_react_native_theming11 = require("@storybook/react-native-theming");
|
|
1293
|
-
var
|
|
1298
|
+
var import_react_native15 = require("react-native");
|
|
1294
1299
|
var import_react_native_safe_area_context2 = require("react-native-safe-area-context");
|
|
1295
1300
|
|
|
1296
|
-
// src/
|
|
1297
|
-
var
|
|
1298
|
-
var
|
|
1301
|
+
// src/components/OnDeviceUI/Panel.tsx
|
|
1302
|
+
var import_react7 = __toESM(require("react"));
|
|
1303
|
+
var import_react_native6 = require("react-native");
|
|
1299
1304
|
var import_react_native_theming3 = require("@storybook/react-native-theming");
|
|
1300
|
-
var
|
|
1301
|
-
var Container = (0, import_react_native_theming3.styled)(
|
|
1305
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1306
|
+
var Container = (0, import_react_native_theming3.styled)(import_react_native6.Animated.View)(({ theme: theme3, edge }) => ({
|
|
1302
1307
|
backgroundColor: theme3.panel.backgroundColor,
|
|
1303
1308
|
borderTopWidth: edge === "top" ? theme3.panel.borderWidth : void 0,
|
|
1304
1309
|
borderStartWidth: edge === "left" ? theme3.panel.borderWidth : void 0,
|
|
@@ -1306,30 +1311,30 @@ var Container = (0, import_react_native_theming3.styled)(import_react_native5.An
|
|
|
1306
1311
|
borderColor: theme3.panel.borderColor
|
|
1307
1312
|
}));
|
|
1308
1313
|
var Panel = ({ edge, children, style }) => {
|
|
1309
|
-
const containerStyle =
|
|
1310
|
-
edge === "top" ? void 0 :
|
|
1314
|
+
const containerStyle = import_react_native6.StyleSheet.flatten([
|
|
1315
|
+
edge === "top" ? void 0 : import_react_native6.StyleSheet.absoluteFillObject,
|
|
1311
1316
|
style
|
|
1312
1317
|
]);
|
|
1313
|
-
return /* @__PURE__ */ (0,
|
|
1318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Container, { edge, style: containerStyle, children });
|
|
1314
1319
|
};
|
|
1315
|
-
var Panel_default =
|
|
1320
|
+
var Panel_default = import_react7.default.memo(Panel);
|
|
1316
1321
|
|
|
1317
|
-
// src/
|
|
1318
|
-
var
|
|
1322
|
+
// src/components/OnDeviceUI/addons/Addons.tsx
|
|
1323
|
+
var import_manager_api = require("@storybook/manager-api");
|
|
1319
1324
|
var import_react_native_theming7 = require("@storybook/react-native-theming");
|
|
1320
1325
|
var import_types = __toESM(require_dist());
|
|
1321
|
-
var
|
|
1322
|
-
var
|
|
1326
|
+
var import_react11 = __toESM(require("react"));
|
|
1327
|
+
var import_react_native9 = require("react-native");
|
|
1323
1328
|
|
|
1324
|
-
// src/
|
|
1325
|
-
var
|
|
1329
|
+
// src/components/OnDeviceUI/addons/List.tsx
|
|
1330
|
+
var import_react9 = __toESM(require("react"));
|
|
1326
1331
|
|
|
1327
|
-
// src/
|
|
1328
|
-
var
|
|
1329
|
-
var
|
|
1332
|
+
// src/components/Shared/tabs.tsx
|
|
1333
|
+
var import_react8 = __toESM(require("react"));
|
|
1334
|
+
var import_react_native7 = require("react-native");
|
|
1330
1335
|
var import_react_native_theming4 = require("@storybook/react-native-theming");
|
|
1331
1336
|
var import_react_native_theming5 = require("@storybook/react-native-theming");
|
|
1332
|
-
var
|
|
1337
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1333
1338
|
var TabButtonText = import_react_native_theming4.styled.Text(({ theme: theme3, active }) => ({
|
|
1334
1339
|
color: active ? theme3.tabs.activeTextColor : theme3.tabs.inactiveTextColor,
|
|
1335
1340
|
paddingVertical: theme3.tabs.paddingVertical,
|
|
@@ -1344,8 +1349,8 @@ var TabButtonTouchable = import_react_native_theming4.styled.TouchableOpacity(({
|
|
|
1344
1349
|
borderRadius: theme3.tabs.borderRadius,
|
|
1345
1350
|
backgroundColor: active ? theme3.tabs.activeBackgroundColor : theme3.tabs.inactiveBackgroundColor
|
|
1346
1351
|
}));
|
|
1347
|
-
var TabButton =
|
|
1348
|
-
return /* @__PURE__ */ (0,
|
|
1352
|
+
var TabButton = import_react8.default.memo(({ onPress, id, active, children, testID }) => {
|
|
1353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1349
1354
|
TabButtonTouchable,
|
|
1350
1355
|
{
|
|
1351
1356
|
active,
|
|
@@ -1353,15 +1358,15 @@ var TabButton = import_react7.default.memo(({ onPress, id, active, children, tes
|
|
|
1353
1358
|
onPress: () => onPress(id),
|
|
1354
1359
|
activeOpacity: 0.8,
|
|
1355
1360
|
hitSlop,
|
|
1356
|
-
children: /* @__PURE__ */ (0,
|
|
1361
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TabButtonText, { active, children })
|
|
1357
1362
|
}
|
|
1358
1363
|
);
|
|
1359
1364
|
});
|
|
1360
|
-
var TabBar =
|
|
1365
|
+
var TabBar = import_react8.default.memo(({ scrollable = false, style, children }) => {
|
|
1361
1366
|
const theme3 = (0, import_react_native_theming5.useTheme)();
|
|
1362
1367
|
if (scrollable) {
|
|
1363
|
-
children = /* @__PURE__ */ (0,
|
|
1364
|
-
|
|
1368
|
+
children = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1369
|
+
import_react_native7.ScrollView,
|
|
1365
1370
|
{
|
|
1366
1371
|
showsHorizontalScrollIndicator: false,
|
|
1367
1372
|
horizontal: true,
|
|
@@ -1370,7 +1375,7 @@ var TabBar = import_react7.default.memo(({ scrollable = false, style, children }
|
|
|
1370
1375
|
}
|
|
1371
1376
|
);
|
|
1372
1377
|
}
|
|
1373
|
-
return /* @__PURE__ */ (0,
|
|
1378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_native7.View, { style, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TabBarContainer, { children }) });
|
|
1374
1379
|
});
|
|
1375
1380
|
var TabBarContainer = import_react_native_theming4.styled.View(() => ({
|
|
1376
1381
|
flexDirection: "row",
|
|
@@ -1378,15 +1383,15 @@ var TabBarContainer = import_react_native_theming4.styled.View(() => ({
|
|
|
1378
1383
|
justifyItems: "center"
|
|
1379
1384
|
}));
|
|
1380
1385
|
|
|
1381
|
-
// src/
|
|
1382
|
-
var
|
|
1386
|
+
// src/components/OnDeviceUI/addons/List.tsx
|
|
1387
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1383
1388
|
var AddonList = ({ panels, addonSelected, onPressAddon }) => {
|
|
1384
|
-
return /* @__PURE__ */ (0,
|
|
1389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TabBar, { scrollable: true, children: Object.values(panels).map(({ id, title }) => {
|
|
1385
1390
|
let resolvedTitle = typeof title === "function" ? title({}) : title;
|
|
1386
1391
|
if (typeof resolvedTitle === "string") {
|
|
1387
1392
|
resolvedTitle = resolvedTitle.toUpperCase();
|
|
1388
1393
|
}
|
|
1389
|
-
return /* @__PURE__ */ (0,
|
|
1394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1390
1395
|
TabButton,
|
|
1391
1396
|
{
|
|
1392
1397
|
active: id === addonSelected,
|
|
@@ -1398,13 +1403,13 @@ var AddonList = ({ panels, addonSelected, onPressAddon }) => {
|
|
|
1398
1403
|
);
|
|
1399
1404
|
}) });
|
|
1400
1405
|
};
|
|
1401
|
-
var List_default =
|
|
1406
|
+
var List_default = import_react9.default.memo(AddonList);
|
|
1402
1407
|
|
|
1403
|
-
// src/
|
|
1408
|
+
// src/components/OnDeviceUI/addons/Wrapper.tsx
|
|
1404
1409
|
var import_react_native_theming6 = require("@storybook/react-native-theming");
|
|
1405
|
-
var
|
|
1406
|
-
var
|
|
1407
|
-
var
|
|
1410
|
+
var import_react10 = __toESM(require("react"));
|
|
1411
|
+
var import_react_native8 = require("react-native");
|
|
1412
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1408
1413
|
var Container2 = import_react_native_theming6.styled.View(({ selected }) => ({
|
|
1409
1414
|
display: selected ? "flex" : "none",
|
|
1410
1415
|
flex: 1
|
|
@@ -1415,30 +1420,30 @@ var Wrapper = ({ panels, addonSelected }) => {
|
|
|
1415
1420
|
const addonKeys = Object.keys(panels);
|
|
1416
1421
|
const content = addonKeys.map((id) => {
|
|
1417
1422
|
const selected = addonSelected === id;
|
|
1418
|
-
return /* @__PURE__ */ (0,
|
|
1423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Container2, { selected, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_native8.ScrollView, { contentContainerStyle: { padding: theme3.panel.paddingHorizontal }, children: panels[id].render({ active: selected, key: id }) }) }, id);
|
|
1419
1424
|
});
|
|
1420
|
-
return /* @__PURE__ */ (0,
|
|
1425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: content });
|
|
1421
1426
|
};
|
|
1422
|
-
var Wrapper_default =
|
|
1427
|
+
var Wrapper_default = import_react10.default.memo(Wrapper);
|
|
1423
1428
|
|
|
1424
|
-
// src/
|
|
1425
|
-
var
|
|
1426
|
-
var
|
|
1429
|
+
// src/components/OnDeviceUI/addons/Addons.tsx
|
|
1430
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1431
|
+
var Text4 = import_react_native_theming7.styled.Text(({ theme: theme3 }) => ({
|
|
1427
1432
|
marginTop: theme3.tokens.spacing4
|
|
1428
1433
|
}));
|
|
1429
1434
|
var Addons = ({ active }) => {
|
|
1430
|
-
const panels =
|
|
1435
|
+
const panels = import_manager_api.addons.getElements(import_types.Addon_TypesEnum.PANEL);
|
|
1431
1436
|
const [addonSelected, setAddonSelected] = useSelectedAddon(Object.keys(panels)[0]);
|
|
1432
1437
|
const context = useStoryContext();
|
|
1433
1438
|
const id = context?.id;
|
|
1434
1439
|
if (!id) {
|
|
1435
|
-
return /* @__PURE__ */ (0,
|
|
1440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native9.View, { style: { alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text4, { children: "No Story Selected" }) });
|
|
1436
1441
|
}
|
|
1437
1442
|
if (Object.keys(panels).length === 0) {
|
|
1438
|
-
return /* @__PURE__ */ (0,
|
|
1443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native9.View, { style: { alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Text4, { children: "No addons loaded." }) });
|
|
1439
1444
|
}
|
|
1440
|
-
return /* @__PURE__ */ (0,
|
|
1441
|
-
/* @__PURE__ */ (0,
|
|
1445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native9.View, { style: { flex: 1 }, children: [
|
|
1446
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1442
1447
|
List_default,
|
|
1443
1448
|
{
|
|
1444
1449
|
onPressAddon: setAddonSelected,
|
|
@@ -1446,29 +1451,29 @@ var Addons = ({ active }) => {
|
|
|
1446
1451
|
addonSelected: active ? addonSelected : null
|
|
1447
1452
|
}
|
|
1448
1453
|
),
|
|
1449
|
-
/* @__PURE__ */ (0,
|
|
1454
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Wrapper_default, { addonSelected: active ? addonSelected : null, panels })
|
|
1450
1455
|
] });
|
|
1451
1456
|
};
|
|
1452
|
-
var Addons_default =
|
|
1457
|
+
var Addons_default = import_react11.default.memo(Addons);
|
|
1453
1458
|
|
|
1454
|
-
// src/
|
|
1455
|
-
var
|
|
1459
|
+
// src/components/OnDeviceUI/addons/AddonsSkeleton.tsx
|
|
1460
|
+
var import_react12 = __toESM(require("react"));
|
|
1456
1461
|
var import_react_native_theming8 = require("@storybook/react-native-theming");
|
|
1457
|
-
var
|
|
1458
|
-
var
|
|
1459
|
-
var AddonsSkeleton =
|
|
1460
|
-
const progress =
|
|
1461
|
-
|
|
1462
|
-
|
|
1462
|
+
var import_react_native10 = require("react-native");
|
|
1463
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1464
|
+
var AddonsSkeleton = import_react12.default.memo(function AddonsSkeleton2({ visible }) {
|
|
1465
|
+
const progress = import_react12.default.useRef(new import_react_native10.Animated.Value(visible ? 1 : 0));
|
|
1466
|
+
import_react12.default.useEffect(() => {
|
|
1467
|
+
import_react_native10.Animated.timing(progress.current, {
|
|
1463
1468
|
toValue: visible ? 1 : 0,
|
|
1464
1469
|
duration: ANIMATION_DURATION_TRANSITION,
|
|
1465
1470
|
useNativeDriver: true,
|
|
1466
|
-
easing:
|
|
1471
|
+
easing: import_react_native10.Easing.inOut(import_react_native10.Easing.cubic)
|
|
1467
1472
|
}).start();
|
|
1468
1473
|
}, [visible]);
|
|
1469
|
-
return /* @__PURE__ */ (0,
|
|
1470
|
-
/* @__PURE__ */ (0,
|
|
1471
|
-
/* @__PURE__ */ (0,
|
|
1474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(AddonsSkeletonContainer, { pointerEvents: "none", style: { opacity: progress.current }, children: [
|
|
1475
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TabsSkeleton, {}),
|
|
1476
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AddonsContentSkeleton, {})
|
|
1472
1477
|
] });
|
|
1473
1478
|
});
|
|
1474
1479
|
var TabSkeleton = import_react_native_theming8.styled.View(({ theme: theme3, active }) => ({
|
|
@@ -1489,29 +1494,29 @@ var BoxSkeleton = import_react_native_theming8.styled.View(
|
|
|
1489
1494
|
})
|
|
1490
1495
|
);
|
|
1491
1496
|
function AddonsFieldSkeleton({ long = false }) {
|
|
1492
|
-
return /* @__PURE__ */ (0,
|
|
1493
|
-
/* @__PURE__ */ (0,
|
|
1494
|
-
/* @__PURE__ */ (0,
|
|
1497
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native10.View, { style: { marginBottom: 32 }, children: [
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(BoxSkeleton, { width: 75, height: 10, marginBottom: 12 }),
|
|
1499
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(BoxSkeleton, { width: long ? 200 : 120, height: 15 })
|
|
1495
1500
|
] });
|
|
1496
1501
|
}
|
|
1497
1502
|
function AddonsContentSkeleton() {
|
|
1498
|
-
return /* @__PURE__ */ (0,
|
|
1499
|
-
/* @__PURE__ */ (0,
|
|
1500
|
-
/* @__PURE__ */ (0,
|
|
1501
|
-
/* @__PURE__ */ (0,
|
|
1502
|
-
/* @__PURE__ */ (0,
|
|
1503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
1504
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AddonsFieldSkeleton, { long: true }),
|
|
1505
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AddonsFieldSkeleton, { long: true }),
|
|
1506
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AddonsFieldSkeleton, {}),
|
|
1507
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AddonsFieldSkeleton, {})
|
|
1503
1508
|
] });
|
|
1504
1509
|
}
|
|
1505
1510
|
function TabsSkeleton() {
|
|
1506
|
-
return /* @__PURE__ */ (0,
|
|
1507
|
-
/* @__PURE__ */ (0,
|
|
1508
|
-
/* @__PURE__ */ (0,
|
|
1509
|
-
/* @__PURE__ */ (0,
|
|
1511
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react_native10.View, { style: { flexDirection: "row", marginBottom: 16 }, children: [
|
|
1512
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TabSkeleton, {}),
|
|
1513
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TabSkeleton, { active: true }),
|
|
1514
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TabSkeleton, {})
|
|
1510
1515
|
] });
|
|
1511
1516
|
}
|
|
1512
|
-
var AddonsSkeletonContainer = (0, import_react_native_theming8.styled)(
|
|
1517
|
+
var AddonsSkeletonContainer = (0, import_react_native_theming8.styled)(import_react_native10.Animated.View)(
|
|
1513
1518
|
({ theme: theme3 }) => ({
|
|
1514
|
-
...
|
|
1519
|
+
...import_react_native10.StyleSheet.absoluteFillObject,
|
|
1515
1520
|
flex: 1,
|
|
1516
1521
|
backgroundColor: theme3.panel.backgroundColor,
|
|
1517
1522
|
borderTopWidth: theme3.panel.borderWidth,
|
|
@@ -1521,16 +1526,16 @@ var AddonsSkeletonContainer = (0, import_react_native_theming8.styled)(import_re
|
|
|
1521
1526
|
})
|
|
1522
1527
|
);
|
|
1523
1528
|
|
|
1524
|
-
// src/
|
|
1525
|
-
var
|
|
1529
|
+
// src/components/OnDeviceUI/animation.ts
|
|
1530
|
+
var import_react_native11 = require("react-native");
|
|
1526
1531
|
|
|
1527
|
-
// src/
|
|
1532
|
+
// src/components/OnDeviceUI/navigation/constants.ts
|
|
1528
1533
|
var SIDEBAR = -1;
|
|
1529
1534
|
var CANVAS = 0;
|
|
1530
1535
|
var ADDONS = 1;
|
|
1531
1536
|
|
|
1532
|
-
// src/
|
|
1533
|
-
var RTL_SCALE =
|
|
1537
|
+
// src/components/OnDeviceUI/animation.ts
|
|
1538
|
+
var RTL_SCALE = import_react_native11.I18nManager.isRTL ? -1 : 1;
|
|
1534
1539
|
var PREVIEW_SCALE = 0.3;
|
|
1535
1540
|
var PREVIEW_SCALE_WIDE = 0.7;
|
|
1536
1541
|
var PREVIEW_SCALE_SHRINK = 0.9;
|
|
@@ -1624,24 +1629,24 @@ var getPreviewShadowStyle = (animatedValue) => ({
|
|
|
1624
1629
|
overflow: "visible"
|
|
1625
1630
|
});
|
|
1626
1631
|
|
|
1627
|
-
// src/
|
|
1628
|
-
var
|
|
1629
|
-
var
|
|
1632
|
+
// src/components/OnDeviceUI/navigation/Navigation.tsx
|
|
1633
|
+
var import_react14 = __toESM(require("react"));
|
|
1634
|
+
var import_react_native13 = require("react-native");
|
|
1630
1635
|
var import_react_native_safe_area_context = require("react-native-safe-area-context");
|
|
1631
1636
|
var import_react_native_swipe_gestures = __toESM(require("react-native-swipe-gestures"));
|
|
1632
1637
|
|
|
1633
|
-
// src/
|
|
1634
|
-
var
|
|
1638
|
+
// src/components/OnDeviceUI/navigation/NavigationBar.tsx
|
|
1639
|
+
var import_react13 = __toESM(require("react"));
|
|
1635
1640
|
var import_react_native_theming9 = require("@storybook/react-native-theming");
|
|
1636
|
-
var
|
|
1641
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1637
1642
|
var NavigationTabBar = (0, import_react_native_theming9.styled)(TabBar)(({ theme: theme3 }) => ({
|
|
1638
1643
|
paddingHorizontal: theme3.tokens.spacing2,
|
|
1639
1644
|
backgroundColor: theme3.navigation.backgroundColor,
|
|
1640
1645
|
borderColor: theme3.navigation.borderColor,
|
|
1641
1646
|
borderTopWidth: theme3.navigation.borderWidth
|
|
1642
1647
|
}));
|
|
1643
|
-
var NavigationBar =
|
|
1644
|
-
/* @__PURE__ */ (0,
|
|
1648
|
+
var NavigationBar = import_react13.default.memo(({ index, onPress, style }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(NavigationTabBar, { style, children: [
|
|
1649
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1645
1650
|
TabButton,
|
|
1646
1651
|
{
|
|
1647
1652
|
onPress,
|
|
@@ -1651,20 +1656,20 @@ var NavigationBar = import_react12.default.memo(({ index, onPress, style }) => /
|
|
|
1651
1656
|
children: "SIDEBAR"
|
|
1652
1657
|
}
|
|
1653
1658
|
),
|
|
1654
|
-
/* @__PURE__ */ (0,
|
|
1655
|
-
/* @__PURE__ */ (0,
|
|
1659
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TabButton, { onPress, testID: "BottomMenu.Canvas", id: CANVAS, active: index === CANVAS, children: "CANVAS" }),
|
|
1660
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TabButton, { onPress, testID: "BottomMenu.Addons", id: ADDONS, active: index === ADDONS, children: "ADDONS" })
|
|
1656
1661
|
] }));
|
|
1657
1662
|
|
|
1658
|
-
// src/
|
|
1659
|
-
var
|
|
1660
|
-
var
|
|
1663
|
+
// src/components/OnDeviceUI/navigation/NavigationButton.tsx
|
|
1664
|
+
var import_react_native12 = require("react-native");
|
|
1665
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1661
1666
|
var hitSlop2 = { top: 5, left: 5, right: 5, bottom: 5 };
|
|
1662
1667
|
function NavigationButton({ iconName, inverseIconName, active, toggle }) {
|
|
1663
|
-
return /* @__PURE__ */ (0,
|
|
1668
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native12.TouchableWithoutFeedback, { onPress: toggle, hitSlop: hitSlop2, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_native12.View, { style: { marginHorizontal: 8 }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(BackgroundIcon, { style: { flex: 1, opacity: 0.8 }, name: inverseIconName, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: iconName, style: { opacity: active ? 0.6 : 0.25 } }) }) }) });
|
|
1664
1669
|
}
|
|
1665
1670
|
function VisibilityButton() {
|
|
1666
1671
|
const [active, toggle] = useIsUIVisible();
|
|
1667
|
-
return /* @__PURE__ */ (0,
|
|
1672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1668
1673
|
NavigationButton,
|
|
1669
1674
|
{
|
|
1670
1675
|
iconName: "layout-bottom",
|
|
@@ -1676,7 +1681,7 @@ function VisibilityButton() {
|
|
|
1676
1681
|
}
|
|
1677
1682
|
function AddonsSplitButton() {
|
|
1678
1683
|
const [active, toggle] = useIsSplitPanelVisible();
|
|
1679
|
-
return /* @__PURE__ */ (0,
|
|
1684
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1680
1685
|
NavigationButton,
|
|
1681
1686
|
{
|
|
1682
1687
|
iconName: "layout-split",
|
|
@@ -1687,8 +1692,8 @@ function AddonsSplitButton() {
|
|
|
1687
1692
|
);
|
|
1688
1693
|
}
|
|
1689
1694
|
|
|
1690
|
-
// src/
|
|
1691
|
-
var
|
|
1695
|
+
// src/components/OnDeviceUI/navigation/Navigation.tsx
|
|
1696
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1692
1697
|
var SWIPE_CONFIG = {
|
|
1693
1698
|
velocityThreshold: 0.2,
|
|
1694
1699
|
directionalOffsetThreshold: 80
|
|
@@ -1712,14 +1717,14 @@ var Navigation = ({ tabOpen, onChangeTab, onLayout }) => {
|
|
|
1712
1717
|
}
|
|
1713
1718
|
};
|
|
1714
1719
|
const [isUIVisible] = useIsUIVisible();
|
|
1715
|
-
return /* @__PURE__ */ (0,
|
|
1716
|
-
/* @__PURE__ */ (0,
|
|
1720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_react_native13.View, { style: navStyle, onLayout, children: [
|
|
1721
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_native13.View, { children: isUIVisible && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1717
1722
|
import_react_native_swipe_gestures.default,
|
|
1718
1723
|
{
|
|
1719
1724
|
onSwipeLeft: handleSwipeLeft,
|
|
1720
1725
|
onSwipeRight: handleSwipeRight,
|
|
1721
1726
|
config: SWIPE_CONFIG,
|
|
1722
|
-
children: /* @__PURE__ */ (0,
|
|
1727
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1723
1728
|
NavigationBar,
|
|
1724
1729
|
{
|
|
1725
1730
|
index: tabOpen,
|
|
@@ -1729,17 +1734,17 @@ var Navigation = ({ tabOpen, onChangeTab, onLayout }) => {
|
|
|
1729
1734
|
)
|
|
1730
1735
|
}
|
|
1731
1736
|
) }),
|
|
1732
|
-
/* @__PURE__ */ (0,
|
|
1733
|
-
/* @__PURE__ */ (0,
|
|
1734
|
-
/* @__PURE__ */ (0,
|
|
1737
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(NavigationShortcuts, { children: [
|
|
1738
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(VisibilityButton, {}),
|
|
1739
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(AddonsSplitButton, {})
|
|
1735
1740
|
] })
|
|
1736
1741
|
] });
|
|
1737
1742
|
};
|
|
1738
|
-
var Navigation_default =
|
|
1743
|
+
var Navigation_default = import_react14.default.memo(Navigation);
|
|
1739
1744
|
function NavigationShortcuts({ children }) {
|
|
1740
1745
|
const insets = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
|
|
1741
|
-
return /* @__PURE__ */ (0,
|
|
1742
|
-
|
|
1746
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1747
|
+
import_react_native13.View,
|
|
1743
1748
|
{
|
|
1744
1749
|
style: {
|
|
1745
1750
|
zIndex: 100,
|
|
@@ -1756,12 +1761,12 @@ function NavigationShortcuts({ children }) {
|
|
|
1756
1761
|
);
|
|
1757
1762
|
}
|
|
1758
1763
|
|
|
1759
|
-
// src/
|
|
1760
|
-
var
|
|
1761
|
-
var IS_IOS =
|
|
1764
|
+
// src/components/OnDeviceUI/OnDeviceUI.tsx
|
|
1765
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1766
|
+
var IS_IOS = import_react_native14.Platform.OS === "ios";
|
|
1762
1767
|
var getExpoRoot = () => global.Expo || global.__expo || global.__exponent;
|
|
1763
1768
|
var IS_EXPO = getExpoRoot() !== void 0;
|
|
1764
|
-
var IS_ANDROID =
|
|
1769
|
+
var IS_ANDROID = import_react_native14.Platform.OS === "android";
|
|
1765
1770
|
var BREAKPOINT = 1024;
|
|
1766
1771
|
var flex = { flex: 1 };
|
|
1767
1772
|
function Preview({ animatedValue, style, children }) {
|
|
@@ -1770,16 +1775,16 @@ function Preview({ animatedValue, style, children }) {
|
|
|
1770
1775
|
backgroundColor: theme3.preview.backgroundColor,
|
|
1771
1776
|
...getPreviewShadowStyle(animatedValue)
|
|
1772
1777
|
};
|
|
1773
|
-
return /* @__PURE__ */ (0,
|
|
1778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native14.Animated.View, { style: [flex, containerStyle], children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react_native14.View, { style: [flex, style], children }) });
|
|
1774
1779
|
}
|
|
1775
|
-
var styles3 =
|
|
1776
|
-
expoAndroidContainer: { paddingTop:
|
|
1780
|
+
var styles3 = import_react_native14.StyleSheet.create({
|
|
1781
|
+
expoAndroidContainer: { paddingTop: import_react_native14.StatusBar.currentHeight }
|
|
1777
1782
|
});
|
|
1778
1783
|
var Container3 = import_react_native_theming10.styled.View(({ theme: theme3 }) => ({
|
|
1779
1784
|
flex: 1,
|
|
1780
1785
|
backgroundColor: theme3.preview.containerBackgroundColor,
|
|
1781
1786
|
...IS_ANDROID && IS_EXPO ? styles3.expoAndroidContainer : void 0,
|
|
1782
|
-
...
|
|
1787
|
+
...import_react_native14.Platform.select({ web: { overflow: "hidden" } })
|
|
1783
1788
|
}));
|
|
1784
1789
|
var OnDeviceUI = ({
|
|
1785
1790
|
storyIndex,
|
|
@@ -1787,30 +1792,30 @@ var OnDeviceUI = ({
|
|
|
1787
1792
|
keyboardAvoidingViewVerticalOffset,
|
|
1788
1793
|
tabOpen: initialTabOpen
|
|
1789
1794
|
}) => {
|
|
1790
|
-
const [tabOpen, setTabOpen] = (0,
|
|
1791
|
-
const lastTabOpen =
|
|
1792
|
-
const [previewDimensions, setPreviewDimensions] = (0,
|
|
1793
|
-
width:
|
|
1794
|
-
height:
|
|
1795
|
+
const [tabOpen, setTabOpen] = (0, import_react15.useState)(initialTabOpen || CANVAS);
|
|
1796
|
+
const lastTabOpen = import_react15.default.useRef(tabOpen);
|
|
1797
|
+
const [previewDimensions, setPreviewDimensions] = (0, import_react15.useState)(() => ({
|
|
1798
|
+
width: import_react_native14.Dimensions.get("window").width,
|
|
1799
|
+
height: import_react_native14.Dimensions.get("window").height
|
|
1795
1800
|
}));
|
|
1796
|
-
const animatedValue = (0,
|
|
1797
|
-
const wide = (0,
|
|
1801
|
+
const animatedValue = (0, import_react15.useRef)(new import_react_native14.Animated.Value(tabOpen));
|
|
1802
|
+
const wide = (0, import_react_native15.useWindowDimensions)().width >= BREAKPOINT;
|
|
1798
1803
|
const insets = (0, import_react_native_safe_area_context2.useSafeAreaInsets)();
|
|
1799
|
-
const handleToggleTab =
|
|
1804
|
+
const handleToggleTab = import_react15.default.useCallback(
|
|
1800
1805
|
(newTabOpen) => {
|
|
1801
1806
|
if (newTabOpen === tabOpen) {
|
|
1802
1807
|
return;
|
|
1803
1808
|
}
|
|
1804
1809
|
lastTabOpen.current = tabOpen;
|
|
1805
|
-
|
|
1810
|
+
import_react_native14.Animated.timing(animatedValue.current, {
|
|
1806
1811
|
toValue: newTabOpen,
|
|
1807
1812
|
duration: ANIMATION_DURATION_TRANSITION,
|
|
1808
|
-
easing:
|
|
1813
|
+
easing: import_react_native14.Easing.inOut(import_react_native14.Easing.cubic),
|
|
1809
1814
|
useNativeDriver: true
|
|
1810
1815
|
}).start();
|
|
1811
1816
|
setTabOpen(newTabOpen);
|
|
1812
1817
|
if (newTabOpen === CANVAS) {
|
|
1813
|
-
|
|
1818
|
+
import_react_native14.Keyboard.dismiss();
|
|
1814
1819
|
}
|
|
1815
1820
|
},
|
|
1816
1821
|
[tabOpen]
|
|
@@ -1828,8 +1833,8 @@ var OnDeviceUI = ({
|
|
|
1828
1833
|
})
|
|
1829
1834
|
];
|
|
1830
1835
|
const [isUIVisible] = useIsUIVisible();
|
|
1831
|
-
const [navBarHeight, setNavBarHeight] =
|
|
1832
|
-
const measureNavigation =
|
|
1836
|
+
const [navBarHeight, setNavBarHeight] = import_react15.default.useState(insets.bottom + 40);
|
|
1837
|
+
const measureNavigation = import_react15.default.useCallback(
|
|
1833
1838
|
({ nativeEvent }) => {
|
|
1834
1839
|
const inset = insets.bottom;
|
|
1835
1840
|
setNavBarHeight(isUIVisible ? nativeEvent.layout.height - inset : 0);
|
|
@@ -1848,37 +1853,37 @@ var OnDeviceUI = ({
|
|
|
1848
1853
|
const keyboardVerticalOffset = -panelSafeAreaMargins.paddingBottom + (keyboardAvoidingViewVerticalOffset ?? 0);
|
|
1849
1854
|
const [isSplitPanelVisible] = useIsSplitPanelVisible();
|
|
1850
1855
|
const isPreviewInactive = tabOpen !== CANVAS;
|
|
1851
|
-
return /* @__PURE__ */ (0,
|
|
1852
|
-
/* @__PURE__ */ (0,
|
|
1853
|
-
|
|
1856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Container3, { children: [
|
|
1857
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1858
|
+
import_react_native14.KeyboardAvoidingView,
|
|
1854
1859
|
{
|
|
1855
1860
|
enabled: !shouldDisableKeyboardAvoidingView || isPreviewInactive,
|
|
1856
1861
|
behavior: IS_IOS ? "padding" : null,
|
|
1857
1862
|
keyboardVerticalOffset,
|
|
1858
1863
|
style: flex,
|
|
1859
|
-
children: /* @__PURE__ */ (0,
|
|
1864
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1860
1865
|
absolute_positioned_keyboard_aware_view_default,
|
|
1861
1866
|
{
|
|
1862
1867
|
onLayout: setPreviewDimensions,
|
|
1863
1868
|
previewDimensions,
|
|
1864
1869
|
children: [
|
|
1865
|
-
/* @__PURE__ */ (0,
|
|
1866
|
-
/* @__PURE__ */ (0,
|
|
1867
|
-
/* @__PURE__ */ (0,
|
|
1868
|
-
isSplitPanelVisible ? /* @__PURE__ */ (0,
|
|
1869
|
-
/* @__PURE__ */ (0,
|
|
1870
|
-
/* @__PURE__ */ (0,
|
|
1870
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react_native14.Animated.View, { style: previewWrapperStyles, children: [
|
|
1871
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Preview, { style: safeAreaMargins, animatedValue: animatedValue.current, children: [
|
|
1872
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StoryView_default, {}),
|
|
1873
|
+
isSplitPanelVisible ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(Panel_default, { edge: "top", style: { flex: 1 }, children: [
|
|
1874
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Addons_default, { active: true }),
|
|
1875
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(AddonsSkeleton, { visible: isPreviewInactive })
|
|
1871
1876
|
] }) : null
|
|
1872
1877
|
] }),
|
|
1873
|
-
isPreviewInactive ? /* @__PURE__ */ (0,
|
|
1874
|
-
|
|
1878
|
+
isPreviewInactive ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1879
|
+
import_react_native14.TouchableOpacity,
|
|
1875
1880
|
{
|
|
1876
|
-
style:
|
|
1881
|
+
style: import_react_native14.StyleSheet.absoluteFillObject,
|
|
1877
1882
|
onPress: () => handleToggleTab(CANVAS)
|
|
1878
1883
|
}
|
|
1879
1884
|
) : null
|
|
1880
1885
|
] }),
|
|
1881
|
-
/* @__PURE__ */ (0,
|
|
1886
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1882
1887
|
Panel_default,
|
|
1883
1888
|
{
|
|
1884
1889
|
edge: "right",
|
|
@@ -1886,10 +1891,10 @@ var OnDeviceUI = ({
|
|
|
1886
1891
|
getSidebarPanelPosition(animatedValue.current, previewDimensions.width, wide),
|
|
1887
1892
|
panelSafeAreaMargins
|
|
1888
1893
|
],
|
|
1889
|
-
children: /* @__PURE__ */ (0,
|
|
1894
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StoryListView_default, { storyIndex })
|
|
1890
1895
|
}
|
|
1891
1896
|
),
|
|
1892
|
-
/* @__PURE__ */ (0,
|
|
1897
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1893
1898
|
Panel_default,
|
|
1894
1899
|
{
|
|
1895
1900
|
edge: "left",
|
|
@@ -1897,7 +1902,7 @@ var OnDeviceUI = ({
|
|
|
1897
1902
|
getAddonPanelPosition(animatedValue.current, previewDimensions.width, wide),
|
|
1898
1903
|
panelSafeAreaMargins
|
|
1899
1904
|
],
|
|
1900
|
-
children: /* @__PURE__ */ (0,
|
|
1905
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Addons_default, { active: tabOpen === ADDONS })
|
|
1901
1906
|
}
|
|
1902
1907
|
)
|
|
1903
1908
|
]
|
|
@@ -1905,65 +1910,15 @@ var OnDeviceUI = ({
|
|
|
1905
1910
|
)
|
|
1906
1911
|
}
|
|
1907
1912
|
),
|
|
1908
|
-
/* @__PURE__ */ (0,
|
|
1913
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Navigation_default, { onLayout: measureNavigation, tabOpen, onChangeTab: handleToggleTab })
|
|
1909
1914
|
] }) });
|
|
1910
1915
|
};
|
|
1911
|
-
var OnDeviceUI_default =
|
|
1916
|
+
var OnDeviceUI_default = import_react15.default.memo(OnDeviceUI);
|
|
1912
1917
|
|
|
1913
|
-
// src/
|
|
1914
|
-
var import_channels = require("@storybook/channels");
|
|
1915
|
-
var import_core_events2 = __toESM(require("@storybook/core-events"));
|
|
1916
|
-
var import_global = require("@storybook/global");
|
|
1918
|
+
// src/View.tsx
|
|
1917
1919
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
1918
|
-
var
|
|
1919
|
-
|
|
1920
|
-
// src/preview/rn-host-detect.js
|
|
1921
|
-
function getByRemoteConfig(hostname) {
|
|
1922
|
-
var remoteModuleConfig = window?.__fbBatchedBridgeConfig?.remoteModuleConfig;
|
|
1923
|
-
if (!Array.isArray(remoteModuleConfig) || hostname !== "localhost" && hostname !== "127.0.0.1") {
|
|
1924
|
-
return { hostname, passed: false };
|
|
1925
|
-
}
|
|
1926
|
-
var constants = (remoteModuleConfig.find(getConstants) || [])[1];
|
|
1927
|
-
if (constants) {
|
|
1928
|
-
var serverHost = constants.ServerHost || hostname;
|
|
1929
|
-
return { hostname: serverHost.split(":")[0], passed: true };
|
|
1930
|
-
}
|
|
1931
|
-
return { hostname, passed: false };
|
|
1932
|
-
}
|
|
1933
|
-
function getConstants(config) {
|
|
1934
|
-
return config && (config[0] === "AndroidConstants" || config[0] === "PlatformConstants");
|
|
1935
|
-
}
|
|
1936
|
-
function getByRNRequirePolyfill(hostname) {
|
|
1937
|
-
var NativeModules;
|
|
1938
|
-
var PlatformConstants;
|
|
1939
|
-
var AndroidConstants;
|
|
1940
|
-
if (typeof window === "undefined" || !window.__DEV__ || typeof window.require !== "function" || // RN >= 0.56
|
|
1941
|
-
// TODO: Get NativeModules for RN >= 0.56
|
|
1942
|
-
window.require.name === "metroRequire") {
|
|
1943
|
-
return hostname;
|
|
1944
|
-
}
|
|
1945
|
-
NativeModules = window.require("NativeModules");
|
|
1946
|
-
if (!NativeModules || !NativeModules.PlatformConstants && !NativeModules.AndroidConstants) {
|
|
1947
|
-
return hostname;
|
|
1948
|
-
}
|
|
1949
|
-
PlatformConstants = NativeModules.PlatformConstants;
|
|
1950
|
-
AndroidConstants = NativeModules.AndroidConstants;
|
|
1951
|
-
var serverHost = (PlatformConstants ? PlatformConstants.ServerHost : AndroidConstants.ServerHost) || hostname;
|
|
1952
|
-
return serverHost.split(":")[0];
|
|
1953
|
-
}
|
|
1954
|
-
function getHost(hostname) {
|
|
1955
|
-
if (typeof __fbBatchedBridge !== "object" || hostname !== "localhost" && hostname !== "127.0.0.1") {
|
|
1956
|
-
return hostname;
|
|
1957
|
-
}
|
|
1958
|
-
var result = getByRemoteConfig(hostname);
|
|
1959
|
-
if (result.passed) {
|
|
1960
|
-
return result.hostname;
|
|
1961
|
-
}
|
|
1962
|
-
return getByRNRequirePolyfill(hostname);
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
// src/preview/View.tsx
|
|
1966
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1920
|
+
var import_react_native16 = require("react-native");
|
|
1921
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1967
1922
|
var STORAGE_KEY = "lastOpenedStory";
|
|
1968
1923
|
var View10 = class {
|
|
1969
1924
|
_storyIndex;
|
|
@@ -1974,8 +1929,10 @@ var View10 = class {
|
|
|
1974
1929
|
_preview;
|
|
1975
1930
|
_asyncStorageStoryId;
|
|
1976
1931
|
_webUrl;
|
|
1977
|
-
|
|
1932
|
+
_channel;
|
|
1933
|
+
constructor(preview, channel) {
|
|
1978
1934
|
this._preview = preview;
|
|
1935
|
+
this._channel = channel;
|
|
1979
1936
|
}
|
|
1980
1937
|
_getInitialStory = async ({
|
|
1981
1938
|
initialSelection,
|
|
@@ -2005,38 +1962,35 @@ var View10 = class {
|
|
|
2005
1962
|
}
|
|
2006
1963
|
return { storySpecifier: "*", viewMode: "story" };
|
|
2007
1964
|
};
|
|
2008
|
-
_getServerChannel = (params = {}) => {
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
};
|
|
1965
|
+
// _getServerChannel = (params: Partial<Params> = {}) => {
|
|
1966
|
+
// const host = getHost(params.host || 'localhost');
|
|
1967
|
+
// const port = `:${params.port || 7007}`;
|
|
1968
|
+
// const query = params.query || '';
|
|
1969
|
+
// const websocketType = params.secured ? 'wss' : 'ws';
|
|
1970
|
+
// const url = `${websocketType}://${host}${port}/${query}`;
|
|
1971
|
+
// return createWebSocketChannel({
|
|
1972
|
+
// url,
|
|
1973
|
+
// async: true,
|
|
1974
|
+
// onError: async () => {},
|
|
1975
|
+
// });
|
|
1976
|
+
// };
|
|
2021
1977
|
getStorybookUI = (params = {}) => {
|
|
2022
|
-
const {
|
|
1978
|
+
const {
|
|
1979
|
+
shouldPersistSelection = true,
|
|
1980
|
+
onDeviceUI = true
|
|
1981
|
+
/* enableWebsockets = false */
|
|
1982
|
+
} = params;
|
|
2023
1983
|
const initialStory = this._getInitialStory(params);
|
|
2024
|
-
|
|
2025
|
-
const channel = this._getServerChannel(params);
|
|
2026
|
-
import_manager_api3.addons.setChannel(channel);
|
|
2027
|
-
this._preview.channel = channel;
|
|
2028
|
-
this._preview.setupListeners();
|
|
2029
|
-
channel.emit(import_core_events2.default.CHANNEL_CREATED);
|
|
2030
|
-
this._preview.initializeWithStoryIndex(this._storyIndex);
|
|
2031
|
-
}
|
|
2032
|
-
import_manager_api3.addons.loadAddons({
|
|
1984
|
+
import_manager_api2.addons.loadAddons({
|
|
2033
1985
|
store: () => ({
|
|
2034
1986
|
fromId: (id) => this._preview.storyStore.getStoryContext(this._preview.storyStore.fromId(id)),
|
|
2035
1987
|
getSelection: () => {
|
|
2036
1988
|
return this._preview.currentSelection;
|
|
2037
1989
|
},
|
|
2038
1990
|
// @ts-ignore :) FIXME
|
|
2039
|
-
_channel: this._preview.channel
|
|
1991
|
+
// _channel: this._preview.channel,
|
|
1992
|
+
// global.__STORYBOOK_ADDONS_CHANNEL__,
|
|
1993
|
+
_channel: this._channel
|
|
2040
1994
|
})
|
|
2041
1995
|
});
|
|
2042
1996
|
const self = this;
|
|
@@ -2046,13 +2000,13 @@ var View10 = class {
|
|
|
2046
2000
|
});
|
|
2047
2001
|
return () => {
|
|
2048
2002
|
const setContext = useSetStoryContext();
|
|
2049
|
-
const colorScheme = (0,
|
|
2050
|
-
const [, forceUpdate] = (0,
|
|
2051
|
-
const appliedTheme = (0,
|
|
2003
|
+
const colorScheme = (0, import_react_native16.useColorScheme)();
|
|
2004
|
+
const [, forceUpdate] = (0, import_react16.useReducer)((x) => x + 1, 0);
|
|
2005
|
+
const appliedTheme = (0, import_react16.useMemo)(
|
|
2052
2006
|
() => (0, import_deepmerge.default)(colorScheme === "dark" ? import_react_native_theming12.darkTheme : import_react_native_theming12.theme, params.theme ?? {}),
|
|
2053
2007
|
[colorScheme]
|
|
2054
2008
|
);
|
|
2055
|
-
(0,
|
|
2009
|
+
(0, import_react16.useEffect)(() => {
|
|
2056
2010
|
self._setStory = (newStory) => {
|
|
2057
2011
|
setContext(newStory);
|
|
2058
2012
|
if (shouldPersistSelection) {
|
|
@@ -2066,20 +2020,9 @@ var View10 = class {
|
|
|
2066
2020
|
self._preview.selectionStore.selectionSpecifier = story;
|
|
2067
2021
|
self._preview.selectSpecifiedStory();
|
|
2068
2022
|
});
|
|
2069
|
-
import_global.global.__STORYBOOK_ADDONS_CHANNEL__.on(import_core_events2.default.SET_CURRENT_STORY, async ({ storyId }) => {
|
|
2070
|
-
self._preview.selectionStore.selectionSpecifier = {
|
|
2071
|
-
storySpecifier: storyId,
|
|
2072
|
-
viewMode: "story"
|
|
2073
|
-
};
|
|
2074
|
-
this._preview.selectionStore.selection = {
|
|
2075
|
-
storyId,
|
|
2076
|
-
viewMode: "story"
|
|
2077
|
-
};
|
|
2078
|
-
await self._preview.selectSpecifiedStory();
|
|
2079
|
-
});
|
|
2080
2023
|
}, []);
|
|
2081
2024
|
if (onDeviceUI) {
|
|
2082
|
-
return /* @__PURE__ */ (0,
|
|
2025
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native_safe_area_context3.SafeAreaProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_native_theming12.ThemeProvider, { theme: appliedTheme, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2083
2026
|
OnDeviceUI_default,
|
|
2084
2027
|
{
|
|
2085
2028
|
storyIndex: self._storyIndex,
|
|
@@ -2089,94 +2032,94 @@ var View10 = class {
|
|
|
2089
2032
|
}
|
|
2090
2033
|
) }) });
|
|
2091
2034
|
} else {
|
|
2092
|
-
return /* @__PURE__ */ (0,
|
|
2035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(StoryView_default, {});
|
|
2093
2036
|
}
|
|
2094
2037
|
};
|
|
2095
2038
|
};
|
|
2096
2039
|
};
|
|
2097
2040
|
|
|
2098
|
-
// src/
|
|
2099
|
-
var
|
|
2100
|
-
function
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
}
|
|
2107
|
-
let
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2041
|
+
// src/Start.tsx
|
|
2042
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2043
|
+
function prepareStories({
|
|
2044
|
+
storyEntries
|
|
2045
|
+
}) {
|
|
2046
|
+
let index = {
|
|
2047
|
+
v: 4,
|
|
2048
|
+
entries: {}
|
|
2049
|
+
};
|
|
2050
|
+
let importMap = {};
|
|
2051
|
+
const makeTitle = (fileName, userTitle) => {
|
|
2052
|
+
const title = (0, import_preview_api.userOrAutoTitle)(fileName, storyEntries, userTitle);
|
|
2053
|
+
if (title) {
|
|
2054
|
+
return title.replace("./", "");
|
|
2055
|
+
} else {
|
|
2056
|
+
console.log({
|
|
2057
|
+
fileName,
|
|
2058
|
+
userTitle,
|
|
2059
|
+
storyEntries: storyEntries.map((entry) => {
|
|
2060
|
+
return { ...entry, importPathMatcher: entry.importPathMatcher.source };
|
|
2061
|
+
}),
|
|
2062
|
+
title: title ?? ""
|
|
2063
|
+
});
|
|
2064
|
+
throw new Error("Could not generate title");
|
|
2065
|
+
}
|
|
2066
|
+
};
|
|
2067
|
+
storyEntries.forEach(({ req, directory: root }) => {
|
|
2068
|
+
req.keys().forEach((filename) => {
|
|
2069
|
+
try {
|
|
2070
|
+
const fileExports = req(filename);
|
|
2071
|
+
if (!fileExports.default)
|
|
2072
|
+
return;
|
|
2073
|
+
const meta = fileExports.default;
|
|
2074
|
+
Object.keys(fileExports).forEach((key) => {
|
|
2075
|
+
if (key === "default")
|
|
2076
|
+
return;
|
|
2077
|
+
const exportValue = fileExports[key];
|
|
2078
|
+
if (!exportValue)
|
|
2079
|
+
return;
|
|
2080
|
+
const name = (0, import_csf2.storyNameFromExport)(key);
|
|
2081
|
+
const title = makeTitle(filename, meta.title);
|
|
2082
|
+
if (title) {
|
|
2083
|
+
const id = (0, import_csf2.toId)(title, name);
|
|
2084
|
+
index.entries[id] = {
|
|
2085
|
+
type: "story",
|
|
2086
|
+
id,
|
|
2087
|
+
name,
|
|
2088
|
+
title,
|
|
2089
|
+
importPath: `${root}/${filename.substring(2)}`,
|
|
2090
|
+
// FIXME: use normalize function here
|
|
2091
|
+
tags: ["story"]
|
|
2092
|
+
};
|
|
2093
|
+
importMap[`${root}/${filename.substring(2)}`] = req(filename);
|
|
2094
|
+
} else {
|
|
2095
|
+
console.log(`Unexpected error while loading ${filename}: could not find title`);
|
|
2120
2096
|
}
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2097
|
+
});
|
|
2098
|
+
} catch (error) {
|
|
2099
|
+
const errorString = error.message && error.stack ? `${error.message}
|
|
2123
2100
|
${error.stack}` : error.toString();
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
});
|
|
2101
|
+
console.error(`Unexpected error while loading ${filename}: ${errorString}`);
|
|
2102
|
+
}
|
|
2127
2103
|
});
|
|
2128
|
-
}
|
|
2129
|
-
|
|
2130
|
-
if (typeof exported === "object") {
|
|
2131
|
-
const csfExports = Object.entries(exported).filter(
|
|
2132
|
-
([_key, value]) => value.default != null
|
|
2133
|
-
);
|
|
2134
|
-
exportsMap = new Map(csfExports.map(([filePath, fileExports]) => [filePath, fileExports]));
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
return exportsMap;
|
|
2138
|
-
}
|
|
2139
|
-
global.lastExportsMap = /* @__PURE__ */ new Map();
|
|
2140
|
-
function executeLoadableForChanges(loadable, m) {
|
|
2141
|
-
if (m?.hot?.accept) {
|
|
2142
|
-
m.hot.accept();
|
|
2143
|
-
}
|
|
2144
|
-
const lastExportsMap = global.lastExportsMap;
|
|
2145
|
-
const exportsMap = executeLoadable(loadable);
|
|
2146
|
-
const added = /* @__PURE__ */ new Map();
|
|
2147
|
-
Array.from(exportsMap.entries()).filter(([, fileExports]) => !!fileExports.default).filter(([fileName, fileExports]) => lastExportsMap.get(fileName) !== fileExports).forEach(([fileName, fileExports]) => added.set(fileName, fileExports));
|
|
2148
|
-
const removed = /* @__PURE__ */ new Map();
|
|
2149
|
-
Array.from(lastExportsMap.keys()).filter((fileName) => !exportsMap.has(fileName)).forEach((fileName) => removed.set(fileName, lastExportsMap.get(fileName)));
|
|
2150
|
-
global.lastExportsMap = exportsMap;
|
|
2151
|
-
return { added, removed };
|
|
2104
|
+
});
|
|
2105
|
+
return { index, importMap };
|
|
2152
2106
|
}
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
};
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
if (!Component) {
|
|
2162
|
-
throw new Error(
|
|
2163
|
-
`Unable to render story ${id} as the component annotation is missing from the default export`
|
|
2164
|
-
);
|
|
2165
|
-
}
|
|
2166
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Component, { ...args });
|
|
2167
|
-
};
|
|
2168
|
-
function start() {
|
|
2169
|
-
const channel = new import_channels2.Channel({ async: true });
|
|
2170
|
-
import_manager_api4.addons.setChannel(channel);
|
|
2171
|
-
channel.emit(import_core_events3.default.CHANNEL_CREATED);
|
|
2172
|
-
const clientApi2 = new import_preview_api.ClientApi();
|
|
2107
|
+
function start({
|
|
2108
|
+
annotations,
|
|
2109
|
+
storyEntries
|
|
2110
|
+
}) {
|
|
2111
|
+
const { index, importMap } = prepareStories({ storyEntries });
|
|
2112
|
+
const channel = (0, import_channels.createBrowserChannel)({ page: "preview" });
|
|
2113
|
+
import_manager_api3.addons.setChannel(channel);
|
|
2114
|
+
import_preview_api.addons.setChannel(channel);
|
|
2173
2115
|
const previewView = {
|
|
2174
2116
|
prepareForStory: () => {
|
|
2175
|
-
return /* @__PURE__ */ (0,
|
|
2117
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, {});
|
|
2176
2118
|
},
|
|
2177
2119
|
prepareForDocs: () => {
|
|
2178
2120
|
},
|
|
2179
|
-
showErrorDisplay: () => {
|
|
2121
|
+
showErrorDisplay: (e) => {
|
|
2122
|
+
console.log(e);
|
|
2180
2123
|
},
|
|
2181
2124
|
showDocs: () => {
|
|
2182
2125
|
},
|
|
@@ -2203,94 +2146,40 @@ function start() {
|
|
|
2203
2146
|
}
|
|
2204
2147
|
};
|
|
2205
2148
|
const preview = new import_preview_web.PreviewWithSelection(urlStore, previewView);
|
|
2206
|
-
|
|
2207
|
-
if (
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
import_global2.global.__STORYBOOK_STORY_STORE__ = preview.storyStore;
|
|
2212
|
-
}
|
|
2213
|
-
(0, import_preview_api.setGlobalRender)(render);
|
|
2214
|
-
let initialized = false;
|
|
2215
|
-
function onStoriesChanged() {
|
|
2216
|
-
const storyIndex = clientApi2.getStoryIndex();
|
|
2217
|
-
preview.onStoriesChanged({ storyIndex });
|
|
2218
|
-
view2._storyIndex = storyIndex;
|
|
2149
|
+
const view = new View10(preview, channel);
|
|
2150
|
+
if (global) {
|
|
2151
|
+
global.__STORYBOOK_ADDONS_CHANNEL__ = channel;
|
|
2152
|
+
global.__STORYBOOK_PREVIEW__ = preview;
|
|
2153
|
+
global.__STORYBOOK_STORY_STORE__ = preview.storyStore;
|
|
2219
2154
|
}
|
|
2220
|
-
const
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
Array.from(added.entries()).forEach(
|
|
2234
|
-
([fileName, fileExports]) => clientApi2.facade.addStoriesFromExports(fileName, fileExports)
|
|
2235
|
-
);
|
|
2236
|
-
Array.from(removed.entries()).forEach(
|
|
2237
|
-
([fileName]) => clientApi2.facade.clearFilenameExports(fileName)
|
|
2238
|
-
);
|
|
2239
|
-
return {
|
|
2240
|
-
...clientApi2.facade.projectAnnotations,
|
|
2241
|
-
renderToCanvas: (context) => {
|
|
2242
|
-
view2._setStory(context.storyContext);
|
|
2243
|
-
}
|
|
2244
|
-
};
|
|
2245
|
-
};
|
|
2246
|
-
const importFn = (path) => clientApi2.importFn(path);
|
|
2247
|
-
if (!initialized) {
|
|
2248
|
-
preview.initialize({
|
|
2249
|
-
getStoryIndex: () => {
|
|
2250
|
-
const index = clientApi2.getStoryIndex();
|
|
2251
|
-
view2._storyIndex = index;
|
|
2252
|
-
return index;
|
|
2253
|
-
},
|
|
2254
|
-
importFn,
|
|
2255
|
-
getProjectAnnotations
|
|
2256
|
-
});
|
|
2257
|
-
initialized = true;
|
|
2258
|
-
} else {
|
|
2259
|
-
getProjectAnnotations();
|
|
2260
|
-
onStoriesChanged();
|
|
2155
|
+
const getProjectAnnotations = async () => (0, import_preview_api.composeConfigs)([
|
|
2156
|
+
{
|
|
2157
|
+
renderToCanvas: (context) => {
|
|
2158
|
+
view._setStory(context.storyContext);
|
|
2159
|
+
},
|
|
2160
|
+
render: (args, context) => {
|
|
2161
|
+
const { id, component: Component } = context;
|
|
2162
|
+
if (!Component) {
|
|
2163
|
+
throw new Error(
|
|
2164
|
+
`Unable to render story ${id} as the component annotation is missing from the default export`
|
|
2165
|
+
);
|
|
2166
|
+
}
|
|
2167
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Component, { ...args });
|
|
2261
2168
|
}
|
|
2262
|
-
}
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
var rawStoriesOf = clientApi.storiesOf.bind(clientApi);
|
|
2270
|
-
var addDecorator = clientApi.addDecorator.bind(clientApi);
|
|
2271
|
-
var addParameters = clientApi.addParameters.bind(clientApi);
|
|
2272
|
-
var addArgsEnhancer = clientApi.addArgsEnhancer.bind(clientApi);
|
|
2273
|
-
var addArgTypesEnhancer = clientApi.addArgTypesEnhancer.bind(clientApi);
|
|
2274
|
-
var raw = clientApi.raw.bind(clientApi);
|
|
2275
|
-
var storiesOf = (kind, m) => {
|
|
2276
|
-
return rawStoriesOf(kind, m).addParameters({
|
|
2277
|
-
renderer: "react-native"
|
|
2169
|
+
},
|
|
2170
|
+
...annotations
|
|
2171
|
+
]);
|
|
2172
|
+
preview.initialize({
|
|
2173
|
+
importFn: async (importPath) => importMap[importPath],
|
|
2174
|
+
getProjectAnnotations,
|
|
2175
|
+
getStoryIndex: () => index
|
|
2278
2176
|
});
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
initializationPromise: clientApi.storyStore?.initializationPromise
|
|
2283
|
-
};
|
|
2177
|
+
view._storyIndex = index;
|
|
2178
|
+
return view;
|
|
2179
|
+
}
|
|
2284
2180
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2285
2181
|
0 && (module.exports = {
|
|
2286
|
-
addArgTypesEnhancer,
|
|
2287
|
-
addArgsEnhancer,
|
|
2288
|
-
addDecorator,
|
|
2289
|
-
addParameters,
|
|
2290
|
-
configure,
|
|
2291
2182
|
darkTheme,
|
|
2292
|
-
|
|
2293
|
-
raw,
|
|
2294
|
-
storiesOf,
|
|
2183
|
+
start,
|
|
2295
2184
|
theme
|
|
2296
2185
|
});
|