@storybook/react-native-ui-common 10.4.0 → 10.4.1-canary-20260510001247
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 +140 -110
- package/dist/index.js +574 -702
- package/package.json +5 -5
- package/src/Button.tsx +1 -1
- package/src/StorageProvider.tsx +2 -2
- package/src/hooks/useExpanded.ts +4 -2
- package/src/hooks/useLastViewed.ts +1 -1
- package/src/hooks/useStoreState.ts +4 -4
- package/src/util/tree.ts +12 -7
- package/src/util/useStyle.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,160 +1,180 @@
|
|
|
1
|
-
import * as react from
|
|
2
|
-
import {
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { ReactRenderer } from
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import * as _$react from "react";
|
|
2
|
+
import { DependencyList, Dispatch, FC, PropsWithChildren, ReactElement, ReactNode, SetStateAction, SyntheticEvent } from "react";
|
|
3
|
+
import * as _$react_native0 from "react-native";
|
|
4
|
+
import { ImageStyle, PressableProps, StyleProp, TextStyle, TouchableOpacityProps, ViewStyle } from "react-native";
|
|
5
|
+
import * as _$_storybook_react_native_theming0 from "@storybook/react-native-theming";
|
|
6
|
+
import { Theme } from "@storybook/react-native-theming";
|
|
7
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
8
|
+
import { Args, StoryContext } from "storybook/internal/csf";
|
|
9
|
+
import { ReactRenderer } from "@storybook/react";
|
|
10
|
+
import { API, IndexHash, State, StoriesHash } from "storybook/manager-api";
|
|
11
|
+
import { API_IndexHash, API_PreparedStoryIndex, API_Provider, DocsOptions, StatusValue, StatusesByStoryIdAndTypeId, StoryIndexV2, StoryIndexV3 } from "storybook/internal/types";
|
|
12
12
|
|
|
13
|
+
//#region src/Button.d.ts
|
|
13
14
|
interface ButtonProps extends TouchableOpacityProps {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
asChild?: boolean;
|
|
16
|
+
size?: 'small' | 'medium';
|
|
17
|
+
padding?: 'small' | 'medium';
|
|
18
|
+
variant?: 'outline' | 'solid' | 'ghost';
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
active?: boolean;
|
|
21
|
+
animation?: 'none' | 'rotate360' | 'glow' | 'jiggle';
|
|
22
|
+
text?: string;
|
|
23
|
+
Icon?: (props: {
|
|
24
|
+
color: string;
|
|
25
|
+
}) => ReactElement;
|
|
25
26
|
}
|
|
26
|
-
declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<any>>;
|
|
27
|
-
declare const ButtonText:
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
declare const Button: _$react.ForwardRefExoticComponent<ButtonProps & _$react.RefAttributes<any>>;
|
|
28
|
+
declare const ButtonText: _$_storybook_react_native_theming0.StyledComponent<_$react_native0.TextProps & {
|
|
29
|
+
theme?: _$_storybook_react_native_theming0.Theme;
|
|
30
|
+
as?: React.ElementType;
|
|
30
31
|
} & {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
variant: ButtonProps["variant"];
|
|
33
|
+
active: ButtonProps["active"];
|
|
33
34
|
}, {}, {
|
|
34
|
-
|
|
35
|
+
ref?: _$react.Ref<_$react_native0.Text>;
|
|
35
36
|
}>;
|
|
36
|
-
declare const ButtonIcon: ({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
declare const ButtonIcon: ({
|
|
38
|
+
Icon,
|
|
39
|
+
active,
|
|
40
|
+
variant
|
|
41
|
+
}: {
|
|
42
|
+
Icon: (props: {
|
|
43
|
+
color: string;
|
|
44
|
+
}) => ReactElement;
|
|
45
|
+
variant: ButtonProps["variant"];
|
|
46
|
+
active: ButtonProps["active"];
|
|
47
|
+
}) => _$react_jsx_runtime0.JSX.Element;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/IconButton.d.ts
|
|
50
|
+
declare const IconButton: _$react.ForwardRefExoticComponent<ButtonProps & _$react.RefAttributes<unknown>>;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/LayoutProvider.d.ts
|
|
46
53
|
type LayoutContextType = {
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
isDesktop: boolean;
|
|
55
|
+
isMobile: boolean;
|
|
49
56
|
};
|
|
50
57
|
declare const LayoutProvider: FC<PropsWithChildren>;
|
|
51
58
|
declare const useLayout: () => LayoutContextType;
|
|
52
|
-
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/StorageProvider.d.ts
|
|
53
61
|
interface Storage {
|
|
54
|
-
|
|
55
|
-
|
|
62
|
+
getItem: (key: string) => Promise<string | null> | string | null;
|
|
63
|
+
setItem: (key: string, value: string) => Promise<void> | void;
|
|
56
64
|
}
|
|
57
65
|
declare const StorageProvider: FC<PropsWithChildren<{
|
|
58
|
-
|
|
66
|
+
storage: Storage;
|
|
59
67
|
}>>;
|
|
60
68
|
declare const useStorage: () => Storage;
|
|
61
|
-
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/types.d.ts
|
|
62
71
|
type HighlightRange = [number, number];
|
|
63
72
|
type HighlightRanges = HighlightRange[];
|
|
64
73
|
type Refs = State['refs'];
|
|
65
74
|
type RefType = Refs[keyof Refs] & {
|
|
66
|
-
|
|
75
|
+
allStatuses?: StatusesByStoryIdAndTypeId;
|
|
67
76
|
};
|
|
68
77
|
type Item = StoriesHash[keyof StoriesHash];
|
|
69
78
|
type Dataset = Record<string, Item>;
|
|
70
79
|
interface CombinedDataset {
|
|
71
|
-
|
|
72
|
-
|
|
80
|
+
hash: Refs;
|
|
81
|
+
entries: [string, RefType][];
|
|
73
82
|
}
|
|
74
83
|
interface ItemRef {
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
itemId: string;
|
|
85
|
+
refId: string;
|
|
77
86
|
}
|
|
78
87
|
interface StoryRef {
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
storyId: string;
|
|
89
|
+
refId: string;
|
|
81
90
|
}
|
|
82
91
|
type Highlight = ItemRef | null;
|
|
83
92
|
type Selection = StoryRef | null;
|
|
84
93
|
declare function isExpandType(x: any): x is ExpandType;
|
|
85
94
|
interface ExpandType {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
showAll: () => void;
|
|
96
|
+
totalCount: number;
|
|
97
|
+
moreCount: number;
|
|
89
98
|
}
|
|
90
99
|
type SearchItem = Item & {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
refId: string;
|
|
101
|
+
path: string[];
|
|
102
|
+
status?: StatusValue;
|
|
103
|
+
showAll?: () => void;
|
|
95
104
|
};
|
|
96
105
|
interface SearchResult {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
item: SearchItem;
|
|
107
|
+
score: number | null;
|
|
108
|
+
matches: HighlightRanges[];
|
|
100
109
|
}
|
|
101
110
|
type SearchResultProps = SearchResult & {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
icon: string;
|
|
112
|
+
isHighlighted: boolean;
|
|
113
|
+
onPress: PressableProps['onPress'];
|
|
105
114
|
};
|
|
106
115
|
type GetSearchItemProps = (args: {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
item: SearchResult;
|
|
117
|
+
index: number;
|
|
118
|
+
key: string;
|
|
110
119
|
}) => SearchResultProps;
|
|
111
120
|
type SearchChildrenFn = (args: {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
query: string;
|
|
122
|
+
results: SearchResult[];
|
|
123
|
+
isBrowsing: boolean;
|
|
124
|
+
closeMenu: (cb?: () => void) => void;
|
|
125
|
+
getItemProps: GetSearchItemProps;
|
|
126
|
+
highlightedIndex: number | null;
|
|
118
127
|
}) => ReactNode;
|
|
119
128
|
type SBUI = (props: {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
story?: StoryContext<ReactRenderer, Args>;
|
|
130
|
+
storyHash: API_IndexHash;
|
|
131
|
+
setStory: (storyId: string) => void;
|
|
132
|
+
storage: Storage;
|
|
133
|
+
theme: Theme;
|
|
134
|
+
storyBackgroundColor?: string;
|
|
135
|
+
children: ReactElement;
|
|
127
136
|
}) => ReactElement;
|
|
128
|
-
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/util/StoryHash.d.ts
|
|
129
139
|
type ToStoriesHashOptions = {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
140
|
+
provider: API_Provider<API>;
|
|
141
|
+
docsOptions: DocsOptions;
|
|
142
|
+
filters: State['filters'];
|
|
143
|
+
allStatuses: StatusesByStoryIdAndTypeId;
|
|
134
144
|
};
|
|
135
145
|
declare const intersect: <T>(a: T[], b: T[]) => T[];
|
|
136
146
|
declare const merge: <TObj = any>(a: TObj, ...b: Partial<TObj>[]) => TObj;
|
|
137
147
|
declare const noArrayMerge: <TObj = any>(a: TObj, ...b: Partial<TObj>[]) => TObj;
|
|
138
|
-
declare const transformStoryIndexToStoriesHash: (input: API_PreparedStoryIndex | StoryIndexV2 | StoryIndexV3, {
|
|
148
|
+
declare const transformStoryIndexToStoriesHash: (input: API_PreparedStoryIndex | StoryIndexV2 | StoryIndexV3, {
|
|
149
|
+
provider,
|
|
150
|
+
docsOptions,
|
|
151
|
+
filters,
|
|
152
|
+
allStatuses
|
|
153
|
+
}: ToStoriesHashOptions) => API_IndexHash | any;
|
|
139
154
|
declare const transformStoryIndexV2toV3: (index: StoryIndexV2) => StoryIndexV3;
|
|
140
155
|
declare const transformStoryIndexV3toV4: (index: StoryIndexV3) => API_PreparedStoryIndex;
|
|
141
156
|
declare const transformStoryIndexV4toV5: (index: API_PreparedStoryIndex) => API_PreparedStoryIndex;
|
|
142
|
-
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/util/tree.d.ts
|
|
143
159
|
declare const createId: (itemId: string, refId?: string) => string;
|
|
144
160
|
declare const prevent: (e: SyntheticEvent) => boolean;
|
|
145
161
|
declare const get: (id: string, dataset: Dataset) => Item;
|
|
146
162
|
declare const getParent: (id: string, dataset: Dataset) => Item;
|
|
147
163
|
declare const getParents: (id: string, dataset: Dataset) => Item[];
|
|
148
|
-
declare const getAncestorIds: (data: IndexHash, id: string) => string[];
|
|
164
|
+
declare const getAncestorIds: (data: IndexHash, id: string | null) => string[];
|
|
149
165
|
declare const getDescendantIds: (data: IndexHash, id: string, skipLeafs: boolean) => string[];
|
|
150
166
|
declare function getPath(item: Item, ref: RefType): string[];
|
|
151
167
|
declare const searchItem: (item: Item, ref: RefType) => SearchItem;
|
|
152
168
|
declare function cycle<T>(array: T[], index: number, delta: number): number;
|
|
153
169
|
declare const getStateType: (isLoading: boolean, isAuthRequired: boolean, isError: boolean, isEmpty: boolean) => "auth" | "error" | "loading" | "empty" | "ready";
|
|
154
|
-
|
|
170
|
+
type ElementLike = {
|
|
171
|
+
parentElement?: ElementLike | null;
|
|
172
|
+
};
|
|
173
|
+
declare const isAncestor: (element?: ElementLike | null, maybeAncestor?: ElementLike | null) => boolean;
|
|
155
174
|
declare const removeNoiseFromName: (storyName: string) => string;
|
|
156
175
|
declare const isStoryHoistable: (storyName: string, componentName: string) => boolean;
|
|
157
|
-
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/util/useStyle.d.ts
|
|
158
178
|
/**
|
|
159
179
|
* A hook to memoize a style. Uses `ViewStyle` per default, but can be used with other styles deriving from `FlexStyle` as well, such as `TextStyle`.
|
|
160
180
|
* @param styleFactory The function that returns a style
|
|
@@ -172,30 +192,40 @@ declare const isStoryHoistable: (storyName: string, componentName: string) => bo
|
|
|
172
192
|
* );
|
|
173
193
|
*/
|
|
174
194
|
declare const useStyle: <TStyle extends ViewStyle | TextStyle | ImageStyle, TOutput extends StyleProp<TStyle>>(styleFactory: () => TOutput, deps?: DependencyList) => TOutput;
|
|
175
|
-
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/util/string.d.ts
|
|
176
197
|
declare function startCase(str: string): string;
|
|
177
|
-
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/hooks/useExpanded.d.ts
|
|
178
200
|
type ExpandedState = Record<string, boolean>;
|
|
179
201
|
interface ExpandAction {
|
|
180
|
-
|
|
181
|
-
|
|
202
|
+
ids: string[];
|
|
203
|
+
value: boolean;
|
|
182
204
|
}
|
|
183
205
|
interface ExpandedProps {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
206
|
+
refId: string;
|
|
207
|
+
data: StoriesHash;
|
|
208
|
+
initialExpanded?: ExpandedState;
|
|
209
|
+
rootIds: string[];
|
|
210
|
+
selectedStoryId: string | null;
|
|
211
|
+
onSelectStoryId: (storyId: string) => void;
|
|
190
212
|
}
|
|
191
|
-
declare const useExpanded: ({
|
|
192
|
-
|
|
213
|
+
declare const useExpanded: ({
|
|
214
|
+
refId,
|
|
215
|
+
data,
|
|
216
|
+
initialExpanded,
|
|
217
|
+
rootIds,
|
|
218
|
+
selectedStoryId
|
|
219
|
+
}: ExpandedProps) => [ExpandedState, Dispatch<ExpandAction>];
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/hooks/useLastViewed.d.ts
|
|
193
222
|
declare const useLastViewed: (selection: Selection) => {
|
|
194
|
-
|
|
195
|
-
|
|
223
|
+
getLastViewed: () => StoryRef[];
|
|
224
|
+
clearLastViewed: () => void;
|
|
196
225
|
};
|
|
197
|
-
|
|
198
|
-
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region src/hooks/useStoreState.d.ts
|
|
228
|
+
declare const useStoreBooleanState: (key: string, defaultValue: boolean) => [boolean, Dispatch<SetStateAction<boolean>>];
|
|
199
229
|
declare const useStoreNumberState: (key: string, defaultValue: number) => [number, (value: number | ((prev: number) => number)) => void];
|
|
200
|
-
|
|
201
|
-
export { Button, ButtonIcon,
|
|
230
|
+
//#endregion
|
|
231
|
+
export { Button, ButtonIcon, ButtonProps, ButtonText, CombinedDataset, Dataset, ExpandAction, ExpandType, ExpandedProps, ExpandedState, GetSearchItemProps, Highlight, HighlightRange, HighlightRanges, IconButton, Item, ItemRef, LayoutProvider, RefType, Refs, SBUI, SearchChildrenFn, SearchItem, SearchResult, SearchResultProps, Selection, Storage, StorageProvider, StoryRef, createId, cycle, get, getAncestorIds, getDescendantIds, getParent, getParents, getPath, getStateType, intersect, isAncestor, isExpandType, isStoryHoistable, merge, noArrayMerge, prevent, removeNoiseFromName, searchItem, startCase, transformStoryIndexToStoriesHash, transformStoryIndexV2toV3, transformStoryIndexV3toV4, transformStoryIndexV4toV5, useExpanded, useLastViewed, useLayout, useStorage, useStoreBooleanState, useStoreNumberState, useStyle };
|