@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 CHANGED
@@ -1,160 +1,180 @@
1
- import * as react from 'react';
2
- import { ReactElement, FC, PropsWithChildren, ReactNode, SyntheticEvent, DependencyList, Dispatch, useState } from 'react';
3
- import * as react_jsx_runtime from 'react/jsx-runtime';
4
- import * as _storybook_react_native_theming from '@storybook/react-native-theming';
5
- import { useTheme, Theme } from '@storybook/react-native-theming';
6
- import * as react_native from 'react-native';
7
- import { TouchableOpacityProps, PressableProps, ViewStyle, TextStyle, ImageStyle, StyleProp } from 'react-native';
8
- import { StoryContext, Args } from 'storybook/internal/csf';
9
- import { ReactRenderer } from '@storybook/react';
10
- import { State, StoriesHash, API, IndexHash } from 'storybook/manager-api';
11
- import { StatusesByStoryIdAndTypeId, StatusValue, API_IndexHash, API_PreparedStoryIndex, StoryIndexV2, StoryIndexV3, API_Provider, DocsOptions } from 'storybook/internal/types';
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
- asChild?: boolean;
15
- size?: 'small' | 'medium';
16
- padding?: 'small' | 'medium';
17
- variant?: 'outline' | 'solid' | 'ghost';
18
- disabled?: boolean;
19
- active?: boolean;
20
- animation?: 'none' | 'rotate360' | 'glow' | 'jiggle';
21
- text?: string;
22
- Icon?: (props: {
23
- color: string;
24
- }) => ReactElement;
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: _storybook_react_native_theming.StyledComponent<react_native.TextProps & {
28
- theme?: useTheme;
29
- as?: React.ElementType;
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
- variant: ButtonProps["variant"];
32
- active: ButtonProps["active"];
32
+ variant: ButtonProps["variant"];
33
+ active: ButtonProps["active"];
33
34
  }, {}, {
34
- ref?: react.Ref<react_native.Text>;
35
+ ref?: _$react.Ref<_$react_native0.Text>;
35
36
  }>;
36
- declare const ButtonIcon: ({ Icon, active, variant, }: {
37
- Icon: (props: {
38
- color: string;
39
- }) => ReactElement;
40
- variant: ButtonProps["variant"];
41
- active: ButtonProps["active"];
42
- }) => react_jsx_runtime.JSX.Element;
43
-
44
- declare const IconButton: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<unknown>>;
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
- isDesktop: boolean;
48
- isMobile: boolean;
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
- getItem: (key: string) => Promise<string | null>;
55
- setItem: (key: string, value: string) => Promise<void>;
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
- storage: Storage;
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
- allStatuses?: StatusesByStoryIdAndTypeId;
75
+ allStatuses?: StatusesByStoryIdAndTypeId;
67
76
  };
68
77
  type Item = StoriesHash[keyof StoriesHash];
69
78
  type Dataset = Record<string, Item>;
70
79
  interface CombinedDataset {
71
- hash: Refs;
72
- entries: [string, RefType][];
80
+ hash: Refs;
81
+ entries: [string, RefType][];
73
82
  }
74
83
  interface ItemRef {
75
- itemId: string;
76
- refId: string;
84
+ itemId: string;
85
+ refId: string;
77
86
  }
78
87
  interface StoryRef {
79
- storyId: string;
80
- refId: string;
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
- showAll: () => void;
87
- totalCount: number;
88
- moreCount: number;
95
+ showAll: () => void;
96
+ totalCount: number;
97
+ moreCount: number;
89
98
  }
90
99
  type SearchItem = Item & {
91
- refId: string;
92
- path: string[];
93
- status?: StatusValue;
94
- showAll?: () => void;
100
+ refId: string;
101
+ path: string[];
102
+ status?: StatusValue;
103
+ showAll?: () => void;
95
104
  };
96
105
  interface SearchResult {
97
- item: SearchItem;
98
- score: number | null;
99
- matches: HighlightRanges[];
106
+ item: SearchItem;
107
+ score: number | null;
108
+ matches: HighlightRanges[];
100
109
  }
101
110
  type SearchResultProps = SearchResult & {
102
- icon: string;
103
- isHighlighted: boolean;
104
- onPress: PressableProps['onPress'];
111
+ icon: string;
112
+ isHighlighted: boolean;
113
+ onPress: PressableProps['onPress'];
105
114
  };
106
115
  type GetSearchItemProps = (args: {
107
- item: SearchResult;
108
- index: number;
109
- key: string;
116
+ item: SearchResult;
117
+ index: number;
118
+ key: string;
110
119
  }) => SearchResultProps;
111
120
  type SearchChildrenFn = (args: {
112
- query: string;
113
- results: SearchResult[];
114
- isBrowsing: boolean;
115
- closeMenu: (cb?: () => void) => void;
116
- getItemProps: GetSearchItemProps;
117
- highlightedIndex: number | null;
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
- story?: StoryContext<ReactRenderer, Args>;
121
- storyHash: API_IndexHash;
122
- setStory: (storyId: string) => void;
123
- storage: Storage;
124
- theme: Theme;
125
- storyBackgroundColor?: string;
126
- children: ReactElement;
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
- provider: API_Provider<API>;
131
- docsOptions: DocsOptions;
132
- filters: State['filters'];
133
- allStatuses: StatusesByStoryIdAndTypeId;
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, { provider, docsOptions, filters, allStatuses }: ToStoriesHashOptions) => API_IndexHash | any;
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
- declare const isAncestor: (element?: Element, maybeAncestor?: Element) => boolean;
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
- ids: string[];
181
- value: boolean;
202
+ ids: string[];
203
+ value: boolean;
182
204
  }
183
205
  interface ExpandedProps {
184
- refId: string;
185
- data: StoriesHash;
186
- initialExpanded?: ExpandedState;
187
- rootIds: string[];
188
- selectedStoryId: string | null;
189
- onSelectStoryId: (storyId: string) => void;
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: ({ refId, data, initialExpanded, rootIds, selectedStoryId, }: ExpandedProps) => [ExpandedState, Dispatch<ExpandAction>];
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
- getLastViewed: () => any[];
195
- clearLastViewed: () => void;
223
+ getLastViewed: () => StoryRef[];
224
+ clearLastViewed: () => void;
196
225
  };
197
-
198
- declare const useStoreBooleanState: (key: string, defaultValue: boolean) => ReturnType<typeof useState<boolean>>;
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, type ButtonProps, ButtonText, type CombinedDataset, type Dataset, type ExpandAction, type ExpandType, type ExpandedProps, type ExpandedState, type GetSearchItemProps, type Highlight, type HighlightRange, type HighlightRanges, IconButton, type Item, type ItemRef, LayoutProvider, type RefType, type Refs, type SBUI, type SearchChildrenFn, type SearchItem, type SearchResult, type SearchResultProps, type Selection, type Storage, StorageProvider, type 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 };
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 };