@storybook/react-native 6.5.5 → 6.5.6-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +125 -18
- package/dist/index.js +1591 -41
- package/package.json +7 -8
- package/dist/constants.d.ts +0 -5
- package/dist/constants.js +0 -8
- package/dist/hooks.d.ts +0 -67
- package/dist/hooks.js +0 -168
- package/dist/preview/View.d.ts +0 -50
- package/dist/preview/View.js +0 -183
- package/dist/preview/components/OnDeviceUI/OnDeviceUI.d.ts +0 -12
- package/dist/preview/components/OnDeviceUI/OnDeviceUI.js +0 -163
- package/dist/preview/components/OnDeviceUI/Panel.d.ts +0 -9
- package/dist/preview/components/OnDeviceUI/Panel.js +0 -28
- package/dist/preview/components/OnDeviceUI/absolute-positioned-keyboard-aware-view.d.ts +0 -12
- package/dist/preview/components/OnDeviceUI/absolute-positioned-keyboard-aware-view.js +0 -31
- package/dist/preview/components/OnDeviceUI/addons/Addons.d.ts +0 -6
- package/dist/preview/components/OnDeviceUI/addons/Addons.js +0 -34
- package/dist/preview/components/OnDeviceUI/addons/AddonsSkeleton.d.ts +0 -14
- package/dist/preview/components/OnDeviceUI/addons/AddonsSkeleton.js +0 -78
- package/dist/preview/components/OnDeviceUI/addons/List.d.ts +0 -9
- package/dist/preview/components/OnDeviceUI/addons/List.js +0 -18
- package/dist/preview/components/OnDeviceUI/addons/Wrapper.d.ts +0 -8
- package/dist/preview/components/OnDeviceUI/addons/Wrapper.js +0 -31
- package/dist/preview/components/OnDeviceUI/addons/index.d.ts +0 -1
- package/dist/preview/components/OnDeviceUI/addons/index.js +0 -8
- package/dist/preview/components/OnDeviceUI/animation.d.ts +0 -61
- package/dist/preview/components/OnDeviceUI/animation.js +0 -116
- package/dist/preview/components/OnDeviceUI/index.d.ts +0 -1
- package/dist/preview/components/OnDeviceUI/index.js +0 -8
- package/dist/preview/components/OnDeviceUI/navigation/Navigation.d.ts +0 -9
- package/dist/preview/components/OnDeviceUI/navigation/Navigation.js +0 -54
- package/dist/preview/components/OnDeviceUI/navigation/NavigationBar.d.ts +0 -8
- package/dist/preview/components/OnDeviceUI/navigation/NavigationBar.js +0 -24
- package/dist/preview/components/OnDeviceUI/navigation/NavigationButton.d.ts +0 -2
- package/dist/preview/components/OnDeviceUI/navigation/NavigationButton.js +0 -23
- package/dist/preview/components/OnDeviceUI/navigation/constants.d.ts +0 -3
- package/dist/preview/components/OnDeviceUI/navigation/constants.js +0 -6
- package/dist/preview/components/OnDeviceUI/navigation/index.d.ts +0 -1
- package/dist/preview/components/OnDeviceUI/navigation/index.js +0 -8
- package/dist/preview/components/Shared/icons.d.ts +0 -53
- package/dist/preview/components/Shared/icons.js +0 -72
- package/dist/preview/components/Shared/layout.d.ts +0 -26
- package/dist/preview/components/Shared/layout.js +0 -24
- package/dist/preview/components/Shared/tabs.d.ts +0 -20
- package/dist/preview/components/Shared/tabs.js +0 -48
- package/dist/preview/components/StoryListView/StoryListView.d.ts +0 -7
- package/dist/preview/components/StoryListView/StoryListView.js +0 -201
- package/dist/preview/components/StoryListView/getNestedStories.d.ts +0 -10
- package/dist/preview/components/StoryListView/getNestedStories.js +0 -95
- package/dist/preview/components/StoryListView/getNestedStories.test.d.ts +0 -1
- package/dist/preview/components/StoryListView/getNestedStories.test.js +0 -237
- package/dist/preview/components/StoryListView/index.d.ts +0 -1
- package/dist/preview/components/StoryListView/index.js +0 -8
- package/dist/preview/components/StoryView/StoryView.d.ts +0 -3
- package/dist/preview/components/StoryView/StoryView.js +0 -47
- package/dist/preview/components/StoryView/index.d.ts +0 -1
- package/dist/preview/components/StoryView/index.js +0 -8
- package/dist/preview/executeLoadable.d.ts +0 -27
- package/dist/preview/executeLoadable.js +0 -95
- package/dist/preview/rn-host-detect.d.ts +0 -1
- package/dist/preview/rn-host-detect.js +0 -63
- package/dist/preview/start.d.ts +0 -16
- package/dist/preview/start.js +0 -124
- package/dist/types/types-6.0.d.ts +0 -72
- package/dist/types/types-6.0.js +0 -2
- package/dist/types/types.d.ts +0 -14
- package/dist/types/types.js +0 -2
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
-
var native_1 = __importDefault(require("@emotion/native"));
|
|
42
|
-
var addons_1 = require("@storybook/addons");
|
|
43
|
-
var core_events_1 = __importDefault(require("@storybook/core-events"));
|
|
44
|
-
var react_1 = __importStar(require("react"));
|
|
45
|
-
var react_native_1 = require("react-native");
|
|
46
|
-
var hooks_1 = require("../../../hooks");
|
|
47
|
-
var icons_1 = require("../Shared/icons");
|
|
48
|
-
var layout_1 = require("../Shared/layout");
|
|
49
|
-
var getNestedStories_1 = require("./getNestedStories");
|
|
50
|
-
var SectionHeaderText = native_1.default.Text(function (_a) {
|
|
51
|
-
var theme = _a.theme;
|
|
52
|
-
return ({
|
|
53
|
-
fontSize: theme.storyList.fontSize,
|
|
54
|
-
color: theme.storyList.headerTextColor,
|
|
55
|
-
fontWeight: theme.storyList.headerFontWeight,
|
|
56
|
-
flexShrink: 1,
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
var StoryNameText = native_1.default.Text(function (_a) {
|
|
60
|
-
var selected = _a.selected, theme = _a.theme;
|
|
61
|
-
return ({
|
|
62
|
-
fontSize: theme.storyList.fontSize,
|
|
63
|
-
fontWeight: selected ? theme.storyList.storySelectedFontWeight : theme.storyList.storyFontWeight,
|
|
64
|
-
color: selected ? theme.storyList.storySelectedTextColor : theme.storyList.storyTextColor,
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
var SEARCH_ICON_SIZE = 24;
|
|
68
|
-
var SearchInput = native_1.default.TextInput(__assign({ padding: 0 }, react_native_1.StyleSheet.absoluteFillObject), function (_a) {
|
|
69
|
-
var theme = _a.theme;
|
|
70
|
-
return ({
|
|
71
|
-
fontSize: theme.storyList.search.fontSize,
|
|
72
|
-
paddingStart: theme.storyList.search.paddingHorizontal + SEARCH_ICON_SIZE,
|
|
73
|
-
color: theme.storyList.search.textColor,
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
var SearchContainer = native_1.default.View(function (_a) {
|
|
77
|
-
var theme = _a.theme;
|
|
78
|
-
return ({
|
|
79
|
-
flexDirection: 'row',
|
|
80
|
-
alignItems: 'center',
|
|
81
|
-
margin: theme.panel.paddingHorizontal,
|
|
82
|
-
paddingVertical: theme.storyList.search.paddingVertical,
|
|
83
|
-
paddingStart: theme.storyList.search.paddingHorizontal,
|
|
84
|
-
borderColor: theme.storyList.search.borderColor,
|
|
85
|
-
borderWidth: theme.storyList.search.borderWidth,
|
|
86
|
-
borderRadius: theme.storyList.search.borderRadius,
|
|
87
|
-
backgroundColor: theme.storyList.search.backgroundColor,
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
var SearchBar = function (props) {
|
|
91
|
-
var theme = (0, hooks_1.useTheme)();
|
|
92
|
-
return ((0, jsx_runtime_1.jsxs)(SearchContainer, { children: [(0, jsx_runtime_1.jsx)(icons_1.Icon, { name: "search", opacity: 0.5 }), (0, jsx_runtime_1.jsx)(SearchInput, __assign({}, props, { autoCapitalize: "none", autoComplete: "off", autoCorrect: false, spellCheck: false, clearButtonMode: "while-editing", disableFullscreenUI: true, placeholderTextColor: theme.storyList.search.placeholderTextColor, returnKeyType: "search" }))] }));
|
|
93
|
-
};
|
|
94
|
-
var HeaderContainer = native_1.default.TouchableOpacity({
|
|
95
|
-
flexDirection: 'row',
|
|
96
|
-
alignItems: 'center',
|
|
97
|
-
}, function (_a) {
|
|
98
|
-
var selected = _a.selected, theme = _a.theme, childSelected = _a.childSelected;
|
|
99
|
-
return ({
|
|
100
|
-
marginTop: theme.storyList.sectionSpacing,
|
|
101
|
-
paddingHorizontal: theme.storyList.headerPaddingHorizontal,
|
|
102
|
-
paddingVertical: theme.storyList.headerPaddingVertical,
|
|
103
|
-
backgroundColor: selected ? theme.storyList.sectionActiveBackgroundColor : undefined,
|
|
104
|
-
borderTopLeftRadius: theme.storyList.sectionBorderRadius,
|
|
105
|
-
borderTopRightRadius: theme.storyList.sectionBorderRadius,
|
|
106
|
-
borderBottomLeftRadius: selected && !childSelected ? theme.storyList.sectionBorderRadius : undefined,
|
|
107
|
-
borderBottomRightRadius: selected && !childSelected ? theme.storyList.sectionBorderRadius : undefined,
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
var SectionHeader = react_1.default.memo(function (_a) {
|
|
111
|
-
var name = _a.name, onPress = _a.onPress, isChildSelected = _a.isChildSelected, _b = _a.icon, icon = _b === void 0 ? 'grid' : _b, expanded = _a.expanded;
|
|
112
|
-
var selected = (0, hooks_1.useIsStorySectionSelected)(name) || isChildSelected;
|
|
113
|
-
return ((0, jsx_runtime_1.jsxs)(HeaderContainer, { selected: selected, childSelected: isChildSelected, onPress: onPress, activeOpacity: 0.8, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: {
|
|
114
|
-
transform: [{ rotate: expanded ? '90deg' : '0deg' }],
|
|
115
|
-
marginRight: 6,
|
|
116
|
-
alignItems: 'center',
|
|
117
|
-
justifyContent: 'center',
|
|
118
|
-
}, children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: { fontSize: 8, color: 'grey', lineHeight: 8 }, children: '➤' }) }), (0, jsx_runtime_1.jsx)(icons_1.Icon, { name: icon, width: 12, height: 12, marginRight: 6 }), (0, jsx_runtime_1.jsx)(SectionHeaderText, { numberOfLines: 2, selected: selected, children: name })] }, name));
|
|
119
|
-
});
|
|
120
|
-
var ItemTouchable = native_1.default.TouchableOpacity({
|
|
121
|
-
flexDirection: 'row',
|
|
122
|
-
alignItems: 'center',
|
|
123
|
-
}, function (_a) {
|
|
124
|
-
var selected = _a.selected, sectionSelected = _a.sectionSelected, isLastItem = _a.isLastItem, theme = _a.theme;
|
|
125
|
-
return ({
|
|
126
|
-
padding: theme.storyList.storyPaddingHorizontal,
|
|
127
|
-
paddingStart: theme.storyList.storyIndent,
|
|
128
|
-
backgroundColor: selected
|
|
129
|
-
? theme.storyList.storySelectedBackgroundColor
|
|
130
|
-
: sectionSelected
|
|
131
|
-
? theme.storyList.sectionActiveBackgroundColor
|
|
132
|
-
: undefined,
|
|
133
|
-
borderBottomLeftRadius: isLastItem ? theme.storyList.sectionBorderRadius : undefined,
|
|
134
|
-
borderBottomRightRadius: isLastItem ? theme.storyList.sectionBorderRadius : undefined,
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
var ListItem = function (_a) {
|
|
138
|
-
var storyId = _a.storyId, kind = _a.kind, title = _a.title, isLastItem = _a.isLastItem, onPress = _a.onPress, isSiblingSelected = _a.isSiblingSelected;
|
|
139
|
-
var selected = (0, hooks_1.useIsStorySelected)(storyId);
|
|
140
|
-
var sectionSelected = (0, hooks_1.useIsStorySectionSelected)(kind) || isSiblingSelected;
|
|
141
|
-
return ((0, jsx_runtime_1.jsxs)(ItemTouchable, { onPress: onPress, activeOpacity: 0.8, testID: "Storybook.ListItem.".concat(kind, ".").concat(title), accessibilityLabel: "Storybook.ListItem.".concat(title), selected: selected, sectionSelected: sectionSelected, isLastItem: isLastItem, children: [(0, jsx_runtime_1.jsx)(icons_1.Icon, { width: 14, height: 14, name: selected ? 'story-white' : 'story-blue', marginRight: 6 }), (0, jsx_runtime_1.jsx)(StoryNameText, { selected: selected, children: title })] }, title));
|
|
142
|
-
};
|
|
143
|
-
var styles = react_native_1.StyleSheet.create({
|
|
144
|
-
sectionList: { flex: 1 },
|
|
145
|
-
sectionListContentContainer: { paddingBottom: 6 },
|
|
146
|
-
});
|
|
147
|
-
function keyExtractor(item, index) {
|
|
148
|
-
return item.name + index;
|
|
149
|
-
}
|
|
150
|
-
var RenderItem = function (_a) {
|
|
151
|
-
var _b, _c;
|
|
152
|
-
var item = _a.item, changeStory = _a.changeStory;
|
|
153
|
-
var isChildSelected = (0, hooks_1.useIsChildSelected)(item.stories);
|
|
154
|
-
var firstChild = (0, getNestedStories_1.findFirstChildStory)(item);
|
|
155
|
-
var firstChildSelected = (0, hooks_1.useIsStorySelected)(firstChild === null || firstChild === void 0 ? void 0 : firstChild.id);
|
|
156
|
-
var _d = (0, react_1.useState)(false), showChildren = _d[0], setShowChildren = _d[1];
|
|
157
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(SectionHeader, { name: item.name, isChildSelected: isChildSelected, onPress: function () {
|
|
158
|
-
if (firstChildSelected && showChildren) {
|
|
159
|
-
setShowChildren(false);
|
|
160
|
-
}
|
|
161
|
-
else if (!showChildren && firstChild) {
|
|
162
|
-
setShowChildren(true);
|
|
163
|
-
changeStory(firstChild.id);
|
|
164
|
-
}
|
|
165
|
-
else if (showChildren && !firstChildSelected && firstChild) {
|
|
166
|
-
changeStory(firstChild.id);
|
|
167
|
-
}
|
|
168
|
-
}, icon: item.children.length ? 'folder' : 'grid', expanded: showChildren }), showChildren &&
|
|
169
|
-
((_b = item.stories) === null || _b === void 0 ? void 0 : _b.map(function (story, idx) { return ((0, jsx_runtime_1.jsx)(ListItem, { storyId: story.id, title: story.name, kind: item.name, isSiblingSelected: isChildSelected, isLastItem: idx === item.stories.length - 1, onPress: function () { return changeStory(story.id); } }, story.id)); })), showChildren &&
|
|
170
|
-
((_c = item.children) === null || _c === void 0 ? void 0 : _c.map(function (child, idx) { return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: { marginLeft: 16 }, children: (0, jsx_runtime_1.jsx)(RenderItem, { item: child, changeStory: changeStory }) }, "".concat(child.title, "-").concat(idx))); }))] }));
|
|
171
|
-
};
|
|
172
|
-
var StoryListView = function (_a) {
|
|
173
|
-
var storyIndex = _a.storyIndex;
|
|
174
|
-
var originalData = (0, react_1.useMemo)(function () { return (0, getNestedStories_1.getNestedStories)(storyIndex); }, [storyIndex]);
|
|
175
|
-
var _b = (0, react_1.useState)(originalData), data = _b[0], setData = _b[1];
|
|
176
|
-
var theme = (0, hooks_1.useTheme)();
|
|
177
|
-
var handleChangeSearchText = function (text) {
|
|
178
|
-
var query = text.trim();
|
|
179
|
-
if (!query) {
|
|
180
|
-
setData(originalData);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
setData((0, getNestedStories_1.filterNestedStories)(originalData, query));
|
|
184
|
-
};
|
|
185
|
-
var changeStory = function (storyId) {
|
|
186
|
-
var channel = addons_1.addons.getChannel();
|
|
187
|
-
channel.emit(core_events_1.default.SET_CURRENT_STORY, { storyId: storyId });
|
|
188
|
-
};
|
|
189
|
-
var renderItem = react_1.default.useCallback(function (_a) {
|
|
190
|
-
var item = _a.item;
|
|
191
|
-
return (0, jsx_runtime_1.jsx)(RenderItem, { item: item, changeStory: changeStory });
|
|
192
|
-
}, []);
|
|
193
|
-
return ((0, jsx_runtime_1.jsxs)(layout_1.Box, { flex: true, children: [(0, jsx_runtime_1.jsx)(SearchBar, { testID: "Storybook.ListView.SearchBar", onChangeText: handleChangeSearchText, placeholder: "Find by name" }), (0, jsx_runtime_1.jsx)(react_native_1.FlatList, { style: styles.sectionList, contentContainerStyle: [
|
|
194
|
-
styles.sectionListContentContainer,
|
|
195
|
-
{
|
|
196
|
-
paddingVertical: theme.panel.paddingVertical,
|
|
197
|
-
paddingHorizontal: theme.panel.paddingHorizontal,
|
|
198
|
-
},
|
|
199
|
-
], testID: "Storybook.ListView", renderItem: renderItem, keyExtractor: keyExtractor, data: data })] }));
|
|
200
|
-
};
|
|
201
|
-
exports.default = react_1.default.memo(StoryListView);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { StoryIndex, StoryIndexEntry } from '@storybook/client-api';
|
|
2
|
-
export interface StoryGroup {
|
|
3
|
-
name: string;
|
|
4
|
-
title: string;
|
|
5
|
-
children: StoryGroup[];
|
|
6
|
-
stories: StoryIndexEntry[];
|
|
7
|
-
}
|
|
8
|
-
export declare function getNestedStories(storyIndex: StoryIndex): StoryGroup[];
|
|
9
|
-
export declare const filterNestedStories: (stories: StoryGroup[], filter: string) => StoryGroup[];
|
|
10
|
-
export declare const findFirstChildStory: (story: StoryGroup) => StoryIndexEntry | undefined;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.findFirstChildStory = exports.filterNestedStories = exports.getNestedStories = void 0;
|
|
15
|
-
// recursive funciton that transforms storyIndex to be StoryGroup[]
|
|
16
|
-
function getNestedStories(storyIndex) {
|
|
17
|
-
var stories = Object.values(storyIndex.stories);
|
|
18
|
-
var group = [];
|
|
19
|
-
stories.forEach(function (story) {
|
|
20
|
-
var nameParts = story.title.split('/');
|
|
21
|
-
formGroup(nameParts, story, group);
|
|
22
|
-
});
|
|
23
|
-
return group;
|
|
24
|
-
}
|
|
25
|
-
exports.getNestedStories = getNestedStories;
|
|
26
|
-
function formGroup(nameParts, story, group) {
|
|
27
|
-
if (nameParts.length === 1) {
|
|
28
|
-
var current = group.find(function (_a) {
|
|
29
|
-
var name = _a.name;
|
|
30
|
-
return name === nameParts[0];
|
|
31
|
-
});
|
|
32
|
-
if (current) {
|
|
33
|
-
current.stories.push(story);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
group.push({
|
|
37
|
-
title: story.title,
|
|
38
|
-
name: nameParts[0],
|
|
39
|
-
children: [],
|
|
40
|
-
stories: [story],
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
var newParts = nameParts.slice(1);
|
|
46
|
-
var currentListPart = group.find(function (_a) {
|
|
47
|
-
var name = _a.name;
|
|
48
|
-
return name === nameParts[0];
|
|
49
|
-
});
|
|
50
|
-
if (!currentListPart) {
|
|
51
|
-
var toPush = {
|
|
52
|
-
name: nameParts[0],
|
|
53
|
-
title: story.title,
|
|
54
|
-
children: [],
|
|
55
|
-
stories: [],
|
|
56
|
-
};
|
|
57
|
-
group.push(toPush);
|
|
58
|
-
return formGroup(newParts, story, toPush.children);
|
|
59
|
-
}
|
|
60
|
-
else if (!currentListPart.children) {
|
|
61
|
-
currentListPart.children = [];
|
|
62
|
-
}
|
|
63
|
-
var newGroup = currentListPart.children;
|
|
64
|
-
return formGroup(newParts, story, newGroup);
|
|
65
|
-
}
|
|
66
|
-
var filterNestedStories = function (stories, filter) {
|
|
67
|
-
var filteredStories = [];
|
|
68
|
-
stories.forEach(function (story) {
|
|
69
|
-
var filtered = filterStoryGroup(story, filter);
|
|
70
|
-
if (filtered) {
|
|
71
|
-
filteredStories.push(filtered);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
return filteredStories;
|
|
75
|
-
};
|
|
76
|
-
exports.filterNestedStories = filterNestedStories;
|
|
77
|
-
var filterStoryGroup = function (story, filter) {
|
|
78
|
-
var filteredStories = story.stories.filter(function (item) {
|
|
79
|
-
return item.title.toLowerCase().includes(filter.toLowerCase()) ||
|
|
80
|
-
item.name.toLowerCase().includes(filter.toLowerCase());
|
|
81
|
-
});
|
|
82
|
-
var filteredChildren = (0, exports.filterNestedStories)(story.children, filter);
|
|
83
|
-
if (filteredStories.length || filteredChildren.length) {
|
|
84
|
-
return __assign(__assign({}, story), { children: filteredChildren, stories: filteredStories });
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
var findFirstChildStory = function (story) {
|
|
88
|
-
if (story.stories.length) {
|
|
89
|
-
return story.stories[0];
|
|
90
|
-
}
|
|
91
|
-
if (story.children.length) {
|
|
92
|
-
return (0, exports.findFirstChildStory)(story.children[0]);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
exports.findFirstChildStory = findFirstChildStory;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var getNestedStories_1 = require("./getNestedStories");
|
|
4
|
-
var storyIndex = {
|
|
5
|
-
stories: {
|
|
6
|
-
'chat-message--message-first': {
|
|
7
|
-
id: 'chat-message--message-first',
|
|
8
|
-
importPath: './components/NestingExample/ChatMessage.stories.tsx',
|
|
9
|
-
name: 'Message First',
|
|
10
|
-
title: 'Chat/Message',
|
|
11
|
-
},
|
|
12
|
-
'chat-message--message-second': {
|
|
13
|
-
id: 'chat-message--message-second',
|
|
14
|
-
importPath: './components/NestingExample/ChatMessage.stories.tsx',
|
|
15
|
-
name: 'Message Second',
|
|
16
|
-
title: 'Chat/Message',
|
|
17
|
-
},
|
|
18
|
-
'chat-message-bubble--first': {
|
|
19
|
-
id: 'chat-message-bubble--first',
|
|
20
|
-
importPath: './components/NestingExample/ChatMessageBubble.stories.tsx',
|
|
21
|
-
name: 'First',
|
|
22
|
-
title: 'Chat/Message/bubble',
|
|
23
|
-
},
|
|
24
|
-
'chat-message-bubble--second': {
|
|
25
|
-
id: 'chat-message-bubble--second',
|
|
26
|
-
importPath: './components/NestingExample/ChatMessageBubble.stories.tsx',
|
|
27
|
-
name: 'Second Story',
|
|
28
|
-
title: 'Chat/Message/bubble',
|
|
29
|
-
},
|
|
30
|
-
'chat-message-reactions--message-one': {
|
|
31
|
-
id: 'chat-message-reactions--message-one',
|
|
32
|
-
importPath: './components/NestingExample/ChatMessageReactions.stories.tsx',
|
|
33
|
-
name: 'Message One',
|
|
34
|
-
title: 'Chat/Message/Reactions',
|
|
35
|
-
},
|
|
36
|
-
'chat-message-reactions--message-two': {
|
|
37
|
-
id: 'chat-message-reactions--message-two',
|
|
38
|
-
importPath: './components/NestingExample/ChatMessageReactions.stories.tsx',
|
|
39
|
-
name: 'Message Two',
|
|
40
|
-
title: 'Chat/Message/Reactions',
|
|
41
|
-
},
|
|
42
|
-
'chat-messageinput--basic': {
|
|
43
|
-
id: 'chat-messageinput--basic',
|
|
44
|
-
importPath: './components/NestingExample/ChatMessageMessageInput.stories.tsx',
|
|
45
|
-
name: 'Basic',
|
|
46
|
-
title: 'Chat/MessageInput',
|
|
47
|
-
},
|
|
48
|
-
'storylistview--basic': {
|
|
49
|
-
id: 'storylistview--basic',
|
|
50
|
-
importPath: './components/NestingExample/StoryList.stories.tsx',
|
|
51
|
-
name: 'Basic',
|
|
52
|
-
title: 'StoryListView',
|
|
53
|
-
},
|
|
54
|
-
'text-control--basic': {
|
|
55
|
-
id: 'text-control--basic',
|
|
56
|
-
importPath: './components/ControlExamples/Text/Text.stories.tsx',
|
|
57
|
-
name: 'Basic',
|
|
58
|
-
title: 'Text control',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
v: 3,
|
|
62
|
-
};
|
|
63
|
-
var output = [
|
|
64
|
-
{
|
|
65
|
-
name: 'Chat',
|
|
66
|
-
title: 'Chat/Message',
|
|
67
|
-
stories: [],
|
|
68
|
-
children: [
|
|
69
|
-
{
|
|
70
|
-
name: 'Message',
|
|
71
|
-
title: 'Chat/Message',
|
|
72
|
-
stories: [
|
|
73
|
-
{
|
|
74
|
-
name: 'Message First',
|
|
75
|
-
title: 'Chat/Message',
|
|
76
|
-
id: 'chat-message--message-first',
|
|
77
|
-
importPath: './components/NestingExample/ChatMessage.stories.tsx',
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: 'Message Second',
|
|
81
|
-
title: 'Chat/Message',
|
|
82
|
-
id: 'chat-message--message-second',
|
|
83
|
-
importPath: './components/NestingExample/ChatMessage.stories.tsx',
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
children: [
|
|
87
|
-
{
|
|
88
|
-
name: 'bubble',
|
|
89
|
-
children: [],
|
|
90
|
-
title: 'Chat/Message/bubble',
|
|
91
|
-
stories: [
|
|
92
|
-
{
|
|
93
|
-
name: 'First',
|
|
94
|
-
title: 'Chat/Message/bubble',
|
|
95
|
-
id: 'chat-message-bubble--first',
|
|
96
|
-
importPath: './components/NestingExample/ChatMessageBubble.stories.tsx',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: 'Second Story',
|
|
100
|
-
title: 'Chat/Message/bubble',
|
|
101
|
-
id: 'chat-message-bubble--second',
|
|
102
|
-
importPath: './components/NestingExample/ChatMessageBubble.stories.tsx',
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
name: 'Reactions',
|
|
108
|
-
title: 'Chat/Message/Reactions',
|
|
109
|
-
children: [],
|
|
110
|
-
stories: [
|
|
111
|
-
{
|
|
112
|
-
name: 'Message One',
|
|
113
|
-
title: 'Chat/Message/Reactions',
|
|
114
|
-
id: 'chat-message-reactions--message-one',
|
|
115
|
-
importPath: './components/NestingExample/ChatMessageReactions.stories.tsx',
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
name: 'Message Two',
|
|
119
|
-
title: 'Chat/Message/Reactions',
|
|
120
|
-
id: 'chat-message-reactions--message-two',
|
|
121
|
-
importPath: './components/NestingExample/ChatMessageReactions.stories.tsx',
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: 'MessageInput',
|
|
129
|
-
title: 'Chat/MessageInput',
|
|
130
|
-
children: [],
|
|
131
|
-
stories: [
|
|
132
|
-
{
|
|
133
|
-
name: 'Basic',
|
|
134
|
-
title: 'Chat/MessageInput',
|
|
135
|
-
id: 'chat-messageinput--basic',
|
|
136
|
-
importPath: './components/NestingExample/ChatMessageMessageInput.stories.tsx',
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
name: 'StoryListView',
|
|
144
|
-
title: 'StoryListView',
|
|
145
|
-
stories: [
|
|
146
|
-
{
|
|
147
|
-
name: 'Basic',
|
|
148
|
-
title: 'StoryListView',
|
|
149
|
-
id: 'storylistview--basic',
|
|
150
|
-
importPath: './components/NestingExample/StoryList.stories.tsx',
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
children: [],
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
title: 'Text control',
|
|
157
|
-
name: 'Text control',
|
|
158
|
-
stories: [
|
|
159
|
-
{
|
|
160
|
-
name: 'Basic',
|
|
161
|
-
title: 'Text control',
|
|
162
|
-
id: 'text-control--basic',
|
|
163
|
-
importPath: './components/ControlExamples/Text/Text.stories.tsx',
|
|
164
|
-
},
|
|
165
|
-
],
|
|
166
|
-
children: [],
|
|
167
|
-
},
|
|
168
|
-
];
|
|
169
|
-
test('story index to grouped list', function () {
|
|
170
|
-
expect((0, getNestedStories_1.getNestedStories)(storyIndex)).toEqual(output);
|
|
171
|
-
});
|
|
172
|
-
test('filter nested stories', function () {
|
|
173
|
-
expect((0, getNestedStories_1.filterNestedStories)(output, 'bubble')).toEqual([
|
|
174
|
-
{
|
|
175
|
-
title: 'Chat/Message',
|
|
176
|
-
name: 'Chat',
|
|
177
|
-
stories: [],
|
|
178
|
-
children: [
|
|
179
|
-
{
|
|
180
|
-
title: 'Chat/Message',
|
|
181
|
-
name: 'Message',
|
|
182
|
-
stories: [],
|
|
183
|
-
children: [
|
|
184
|
-
{
|
|
185
|
-
title: 'Chat/Message/bubble',
|
|
186
|
-
name: 'bubble',
|
|
187
|
-
children: [],
|
|
188
|
-
stories: [
|
|
189
|
-
{
|
|
190
|
-
name: 'First',
|
|
191
|
-
title: 'Chat/Message/bubble',
|
|
192
|
-
id: 'chat-message-bubble--first',
|
|
193
|
-
importPath: './components/NestingExample/ChatMessageBubble.stories.tsx',
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
name: 'Second Story',
|
|
197
|
-
title: 'Chat/Message/bubble',
|
|
198
|
-
id: 'chat-message-bubble--second',
|
|
199
|
-
importPath: './components/NestingExample/ChatMessageBubble.stories.tsx',
|
|
200
|
-
},
|
|
201
|
-
],
|
|
202
|
-
},
|
|
203
|
-
],
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
},
|
|
207
|
-
]);
|
|
208
|
-
expect((0, getNestedStories_1.filterNestedStories)(output, 'one')).toEqual([
|
|
209
|
-
{
|
|
210
|
-
name: 'Chat',
|
|
211
|
-
title: 'Chat/Message',
|
|
212
|
-
stories: [],
|
|
213
|
-
children: [
|
|
214
|
-
{
|
|
215
|
-
title: 'Chat/Message',
|
|
216
|
-
name: 'Message',
|
|
217
|
-
stories: [],
|
|
218
|
-
children: [
|
|
219
|
-
{
|
|
220
|
-
name: 'Reactions',
|
|
221
|
-
title: 'Chat/Message/Reactions',
|
|
222
|
-
children: [],
|
|
223
|
-
stories: [
|
|
224
|
-
{
|
|
225
|
-
name: 'Message One',
|
|
226
|
-
title: 'Chat/Message/Reactions',
|
|
227
|
-
id: 'chat-message-reactions--message-one',
|
|
228
|
-
importPath: './components/NestingExample/ChatMessageReactions.stories.tsx',
|
|
229
|
-
},
|
|
230
|
-
],
|
|
231
|
-
},
|
|
232
|
-
],
|
|
233
|
-
},
|
|
234
|
-
],
|
|
235
|
-
},
|
|
236
|
-
]);
|
|
237
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './StoryListView';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var StoryListView_1 = require("./StoryListView");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StoryListView_1).default; } });
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
18
|
-
var react_1 = __importDefault(require("react"));
|
|
19
|
-
var react_native_1 = require("react-native");
|
|
20
|
-
var hooks_1 = require("../../../hooks");
|
|
21
|
-
var layout_1 = require("../Shared/layout");
|
|
22
|
-
/**
|
|
23
|
-
* This is a handler for `onStartShouldSetResponder`, which dismisses the
|
|
24
|
-
* keyboard as a side effect but then responds with `false` to the responder
|
|
25
|
-
* system, so as not to start actually handling the touch.
|
|
26
|
-
*
|
|
27
|
-
* The objective here is to dismiss the keyboard when the story view is tapped,
|
|
28
|
-
* but in a way that won't interfere with presses or swipes. Using a
|
|
29
|
-
* `Touchable...` component as a wrapper will start to handle the touch, which
|
|
30
|
-
* will swallow swipe gestures that should have gone on to a child view, such
|
|
31
|
-
* as `ScrollView`.
|
|
32
|
-
*/
|
|
33
|
-
function dismissOnStartResponder() {
|
|
34
|
-
react_native_1.Keyboard.dismiss();
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
var StoryView = function () {
|
|
38
|
-
var context = (0, hooks_1.useStoryContext)();
|
|
39
|
-
var id = context === null || context === void 0 ? void 0 : context.id;
|
|
40
|
-
var backgroundColor = (0, hooks_1.useTheme)().backgroundColor;
|
|
41
|
-
if (context && context.unboundStoryFn) {
|
|
42
|
-
var StoryComponent = context.unboundStoryFn;
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(layout_1.Box, { flex: true, testID: id, onStartShouldSetResponder: dismissOnStartResponder, backgroundColor: backgroundColor, children: StoryComponent && (0, jsx_runtime_1.jsx)(StoryComponent, __assign({}, context)) }, id));
|
|
44
|
-
}
|
|
45
|
-
return ((0, jsx_runtime_1.jsx)(layout_1.Box, { flex: true, padding: 16, alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { children: "Please open the sidebar and select a story to preview." }) }));
|
|
46
|
-
};
|
|
47
|
-
exports.default = react_1.default.memo(StoryView);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './StoryView';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var StoryView_1 = require("./StoryView");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(StoryView_1).default; } });
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/// <reference types="webpack-env" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { Path, ModuleExports } from '@storybook/store';
|
|
4
|
-
import { Loadable } from '../types/types';
|
|
5
|
-
declare global {
|
|
6
|
-
var lastExportsMap: Map<Path, ModuleExports>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Executes a Loadable (function that returns exports or require context(s))
|
|
10
|
-
* and returns a map of filename => module exports
|
|
11
|
-
*
|
|
12
|
-
* @param loadable Loadable
|
|
13
|
-
* @returns Map<Path, ModuleExports>
|
|
14
|
-
*/
|
|
15
|
-
export declare function executeLoadable(loadable: Loadable): Map<string, ModuleExports>;
|
|
16
|
-
/**
|
|
17
|
-
* Executes a Loadable (function that returns exports or require context(s))
|
|
18
|
-
* and compares it's output to the last time it was run (as stored on a node module)
|
|
19
|
-
*
|
|
20
|
-
* @param loadable Loadable
|
|
21
|
-
* @param m NodeModule
|
|
22
|
-
* @returns { added: Map<Path, ModuleExports>, removed: Map<Path, ModuleExports> }
|
|
23
|
-
*/
|
|
24
|
-
export declare function executeLoadableForChanges(loadable: Loadable, m?: NodeModule): {
|
|
25
|
-
added: Map<string, ModuleExports>;
|
|
26
|
-
removed: Map<string, ModuleExports>;
|
|
27
|
-
};
|