@storybook/react-native-theming 6.5.5 → 6.5.6-alpha.1

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 +1,488 @@
1
- export { theme, darkTheme, Theme } from './theme';
1
+ import * as RN from 'react-native';
2
+ import { TextStyle, ShadowStyleIOS, ViewStyle } from 'react-native';
3
+ import * as React$1 from 'react';
4
+
5
+ type ShadowStyle = ShadowStyleIOS | Pick<ViewStyle, 'elevation'>;
6
+ type FontWeight = TextStyle['fontWeight'];
7
+ /**
8
+ * Primitive tokens used to build the theme.
9
+ *
10
+ * Ideally components should not use these values directly, and should prefer
11
+ * to use more semantic values from the theme.
12
+ */
13
+ interface ThemeTokens {
14
+ spacing1: number;
15
+ spacing2: number;
16
+ spacing3: number;
17
+ spacing4: number;
18
+ spacing5: number;
19
+ spacing6: number;
20
+ fontSize: {
21
+ small: number;
22
+ smaller: number;
23
+ normal: number;
24
+ };
25
+ color: {
26
+ navy: string;
27
+ offBlack: string;
28
+ black: string;
29
+ white: string;
30
+ grey200: string;
31
+ grey700: string;
32
+ grey800: string;
33
+ red500: string;
34
+ blue100: string;
35
+ blue200: string;
36
+ blue250: string;
37
+ blue300: string;
38
+ blue400: string;
39
+ blue600: string;
40
+ green500: string;
41
+ };
42
+ borderRadius: {
43
+ small: number;
44
+ medium: number;
45
+ large: number;
46
+ round: number;
47
+ };
48
+ borderWidthNormal: number;
49
+ /** Elevation shadows */
50
+ elevation: {
51
+ floating: ShadowStyle;
52
+ };
53
+ }
54
+ interface ThemeButton {
55
+ textColor: string;
56
+ backgroundColor: string;
57
+ borderColor: string;
58
+ borderWidth: number;
59
+ borderRadius: number;
60
+ }
61
+ interface StorybookTheme {
62
+ tokens: ThemeTokens;
63
+ backgroundColor: string;
64
+ text: {
65
+ primaryColor: string;
66
+ secondaryColor: string;
67
+ linkColor: string;
68
+ };
69
+ preview: {
70
+ containerBackgroundColor: string;
71
+ backgroundColor: string;
72
+ };
73
+ /** Navigation bar and related area */
74
+ navigation: {
75
+ backgroundColor: string;
76
+ borderColor: string;
77
+ borderWidth: number;
78
+ visibilityBorderRadius: number;
79
+ visibilityInnerBorderColor: string;
80
+ visibilityOuterBorderColor: string;
81
+ };
82
+ /** Side panels (Story list, addons) */
83
+ panel: {
84
+ backgroundColor: string;
85
+ borderWidth: number;
86
+ borderColor: string;
87
+ paddingVertical: number;
88
+ paddingHorizontal: number;
89
+ };
90
+ /** Story list and list items */
91
+ storyList: {
92
+ fontSize: number;
93
+ headerPaddingHorizontal: number;
94
+ headerPaddingVertical: number;
95
+ headerTextColor: string;
96
+ headerFontWeight: FontWeight;
97
+ storyPaddingHorizontal: number;
98
+ storyPaddingVertical: number;
99
+ storyIndent: number;
100
+ storyTextColor: string;
101
+ storyFontWeight: FontWeight;
102
+ storySelectedBackgroundColor: string;
103
+ storySelectedTextColor: string;
104
+ storySelectedFontWeight: FontWeight;
105
+ sectionSpacing: number;
106
+ sectionActiveBackgroundColor: string;
107
+ sectionBorderRadius: number;
108
+ search: {
109
+ fontSize: number;
110
+ textColor: string;
111
+ placeholderTextColor: string;
112
+ borderRadius: number;
113
+ borderColor: string;
114
+ borderWidth: number;
115
+ backgroundColor: string;
116
+ paddingVertical: number;
117
+ paddingHorizontal: number;
118
+ };
119
+ };
120
+ /** Buttons */
121
+ button: {
122
+ fontSize: number;
123
+ fontWeight: FontWeight;
124
+ paddingVertical: number;
125
+ paddingHorizontal: number;
126
+ primary: ThemeButton;
127
+ secondary: ThemeButton;
128
+ };
129
+ /** Tabs (navigation and addons) */
130
+ tabs: {
131
+ fontSize: number;
132
+ fontWeight: FontWeight;
133
+ paddingVertical: number;
134
+ paddingHorizontal: number;
135
+ borderWidth: number;
136
+ borderRadius: number;
137
+ activeBorderColor: string;
138
+ activeBackgroundColor: string;
139
+ activeTextColor: string;
140
+ inactiveBorderColor: string;
141
+ inactiveBackgroundColor: string;
142
+ inactiveTextColor: string;
143
+ };
144
+ /** Inputs (text, radio, slider, etc.) */
145
+ inputs: {
146
+ errorTextColor: string;
147
+ labelFontSize: number;
148
+ labelTextColor: string;
149
+ text: {
150
+ fontSize: number;
151
+ textColor: string;
152
+ borderWidth: number;
153
+ borderColor: string;
154
+ backgroundColor: string;
155
+ borderRadius: number;
156
+ paddingVertical: number;
157
+ paddingHorizontal: number;
158
+ };
159
+ radio: {
160
+ fontSize: number;
161
+ height: number;
162
+ borderWidth: number;
163
+ borderColor: string;
164
+ backgroundColor: string;
165
+ paddingVertical: number;
166
+ paddingHorizontal: number;
167
+ activeBackgroundColor: string;
168
+ itemSpacing: number;
169
+ labelSpacing: number;
170
+ };
171
+ swatch: {
172
+ fontSize: number;
173
+ height: number;
174
+ borderWidth: number;
175
+ borderColor: string;
176
+ backgroundColor: string;
177
+ outerBorderRadius: number;
178
+ innerBorderRadius: number;
179
+ paddingVertical: number;
180
+ paddingHorizontal: number;
181
+ nameTextWeight: FontWeight;
182
+ };
183
+ slider: {
184
+ fontSize: number;
185
+ labelTextColor: string;
186
+ valueTextColor: string;
187
+ };
188
+ };
189
+ }
190
+ declare const theme: StorybookTheme;
191
+ declare const darkTheme: StorybookTheme;
192
+
193
+ // Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
194
+ // TypeScript Version: 3.1
195
+
196
+
197
+
198
+ interface ThemeProviderProps {
199
+ theme: Partial<Theme> | ((outerTheme: Theme) => Theme)
200
+ children: React$1.ReactNode
201
+ }
202
+
203
+ declare function useTheme(): Theme
204
+
205
+ interface ThemeProvider {
206
+ (props: ThemeProviderProps): React$1.ReactElement
207
+ }
208
+
209
+ declare const ThemeProvider: ThemeProvider
210
+
211
+ // Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
212
+ // TypeScript Version: 3.4
213
+
214
+
215
+
216
+ // tslint:disable-next-line: no-empty-interface
217
+ interface Theme {}
218
+
219
+ // Definitions by: Pat Sissons <https://github.com/patsissons>
220
+ // TypeScript Version: 3.4
221
+
222
+
223
+
224
+ type ReactNativeStyle = RN.ViewStyle | RN.TextStyle | RN.ImageStyle
225
+
226
+ type ReactNativeStyleType<Props> = Props extends {
227
+ style?: RN.StyleProp<infer StyleType>
228
+ }
229
+ ? StyleType extends ReactNativeStyle
230
+ ? StyleType
231
+ : ReactNativeStyle
232
+ : ReactNativeStyle
233
+
234
+ type InterpolationPrimitive<
235
+ StyleType extends ReactNativeStyle = ReactNativeStyle
236
+ > =
237
+ | null
238
+ | undefined
239
+ | boolean
240
+ | number
241
+ | string
242
+ | ObjectInterpolation<StyleType>
243
+
244
+ type ObjectInterpolation<
245
+ StyleType extends ReactNativeStyle = ReactNativeStyle
246
+ > = StyleType
247
+
248
+ interface ArrayInterpolation<
249
+ MergedProps,
250
+ StyleType extends ReactNativeStyle = ReactNativeStyle
251
+ > extends Array<Interpolation<MergedProps, StyleType>> {}
252
+
253
+ interface FunctionInterpolation<
254
+ MergedProps,
255
+ StyleType extends ReactNativeStyle = ReactNativeStyle
256
+ > {
257
+ (mergedProps: MergedProps): Interpolation<MergedProps, StyleType>
258
+ }
259
+
260
+ type Interpolation<
261
+ MergedProps = unknown,
262
+ StyleType extends ReactNativeStyle = ReactNativeStyle
263
+ > =
264
+ | InterpolationPrimitive<StyleType>
265
+ | ArrayInterpolation<MergedProps, StyleType>
266
+ | FunctionInterpolation<MergedProps, StyleType>
267
+
268
+ /** Same as StyledOptions but shouldForwardProp must be a type guard */
269
+ interface FilteringStyledOptions<
270
+ Props = Record<string, any>,
271
+ ForwardedProps extends keyof Props & string = keyof Props & string
272
+ > {
273
+ shouldForwardProp?: (propName: string) => propName is ForwardedProps
274
+ }
275
+
276
+ interface StyledOptions<Props = Record<string, any>> {
277
+ shouldForwardProp?: (propName: string) => boolean
278
+ }
279
+
280
+ /**
281
+ * @typeparam ComponentProps Props which will be included when withComponent is called
282
+ * @typeparam SpecificComponentProps Props which will *not* be included when withComponent is called
283
+ */
284
+ interface StyledComponent<
285
+ ComponentProps extends {},
286
+ SpecificComponentProps extends {} = {},
287
+ JSXProps extends {} = {}
288
+ > extends React.FC<ComponentProps & SpecificComponentProps & JSXProps> {
289
+ withComponent<C extends React.ComponentClass<React.ComponentProps<C>>>(
290
+ component: C
291
+ ): StyledComponent<
292
+ ComponentProps & React.ComponentProps<C>,
293
+ {},
294
+ { ref?: React.Ref<InstanceType<C>> }
295
+ >
296
+ withComponent<C extends React.ComponentType<React.ComponentProps<C>>>(
297
+ component: C
298
+ ): StyledComponent<ComponentProps & React.ComponentProps<C>>
299
+ }
300
+
301
+ /**
302
+ * @typeparam ComponentProps Props which will be included when withComponent is called
303
+ * @typeparam SpecificComponentProps Props which will *not* be included when withComponent is called
304
+ */
305
+ interface CreateStyledComponent<
306
+ ComponentProps extends {},
307
+ SpecificComponentProps extends {} = {},
308
+ JSXProps extends {} = {},
309
+ StyleType extends ReactNativeStyle = ReactNativeStyle
310
+ > {
311
+ /**
312
+ * @typeparam AdditionalProps Additional props to add to your styled component
313
+ */
314
+ <AdditionalProps extends {} = {}>(
315
+ ...styles: ArrayInterpolation<
316
+ ComponentProps &
317
+ SpecificComponentProps &
318
+ AdditionalProps & { theme: Theme },
319
+ StyleType
320
+ >
321
+ ): StyledComponent<
322
+ ComponentProps & AdditionalProps,
323
+ SpecificComponentProps,
324
+ JSXProps
325
+ >
326
+ /**
327
+ * @typeparam AdditionalProps Additional props to add to your styled component
328
+ */
329
+ <AdditionalProps extends {} = {}>(
330
+ template: TemplateStringsArray,
331
+ ...styles: ArrayInterpolation<
332
+ ComponentProps &
333
+ SpecificComponentProps &
334
+ AdditionalProps & { theme: Theme },
335
+ StyleType
336
+ >
337
+ ): StyledComponent<
338
+ ComponentProps & AdditionalProps,
339
+ SpecificComponentProps,
340
+ JSXProps
341
+ >
342
+ }
343
+
344
+ /**
345
+ * @desc
346
+ * This function accepts a React component.
347
+ *
348
+ * @example styled(MyComponent)({ width: 100 })
349
+ * @example styled(MyComponent)(myComponentProps => ({ width: myComponentProps.width })
350
+ * @example styled(View)({ width: 100 })
351
+ * @example styled(View)<Props>(props => ({ width: props.width })
352
+ */
353
+ interface CreateStyled$1 {
354
+ <
355
+ C extends React.ComponentClass<React.ComponentProps<C>>,
356
+ ForwardedProps extends keyof React.ComponentProps<C> &
357
+ string = keyof React.ComponentProps<C> & string
358
+ >(
359
+ component: C,
360
+ options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
361
+ ): CreateStyledComponent<
362
+ Pick<React.ComponentProps<C>, ForwardedProps> & {
363
+ theme?: Theme
364
+ as?: React.ElementType
365
+ },
366
+ {},
367
+ { ref?: React.Ref<InstanceType<C>> },
368
+ ReactNativeStyleType<React.ComponentProps<C>>
369
+ >
370
+
371
+ <C extends React.ComponentClass<React.ComponentProps<C>>>(
372
+ component: C,
373
+ options?: StyledOptions<React.ComponentProps<C>>
374
+ ): CreateStyledComponent<
375
+ React.ComponentProps<C> & {
376
+ theme?: Theme
377
+ as?: React.ElementType
378
+ },
379
+ {},
380
+ { ref?: React.Ref<InstanceType<C>> },
381
+ ReactNativeStyleType<React.ComponentProps<C>>
382
+ >
383
+
384
+ <
385
+ C extends React.ComponentType<React.ComponentProps<C>>,
386
+ ForwardedProps extends keyof React.ComponentProps<C> &
387
+ string = keyof React.ComponentProps<C> & string
388
+ >(
389
+ component: C,
390
+ options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
391
+ ): CreateStyledComponent<
392
+ Pick<React.ComponentProps<C>, ForwardedProps> & {
393
+ theme?: Theme
394
+ as?: React.ElementType
395
+ },
396
+ {},
397
+ {},
398
+ ReactNativeStyleType<React.ComponentProps<C>>
399
+ >
400
+
401
+ <C extends React.ComponentType<React.ComponentProps<C>>>(
402
+ component: C,
403
+ options?: StyledOptions<React.ComponentProps<C>>
404
+ ): CreateStyledComponent<
405
+ React.ComponentProps<C> & { theme?: Theme; as?: React.ElementType },
406
+ {},
407
+ {},
408
+ ReactNativeStyleType<React.ComponentProps<C>>
409
+ >
410
+ }
411
+
412
+ // Definitions by: Pat Sissons <https://github.com/patsissons>
413
+ // TypeScript Version: 3.4
414
+
415
+
416
+
417
+ type ReactNative = typeof RN
418
+
419
+ // those 2 are just copies of the `BaseCreateStyled` with supplied `C` type argument
420
+ type HostClassComponent<C extends React.ComponentClass<any>> =
421
+ CreateStyledComponent<
422
+ React.ComponentProps<C> & { theme?: Theme; as?: React.ElementType },
423
+ {},
424
+ { ref?: React.Ref<InstanceType<C>> },
425
+ ReactNativeStyleType<React.ComponentProps<C>>
426
+ >
427
+ type HostFunctionComponent<C extends React.FunctionComponent<any>> =
428
+ CreateStyledComponent<
429
+ React.ComponentProps<C> & { theme?: Theme; as?: React.ElementType },
430
+ {},
431
+ {},
432
+ ReactNativeStyleType<React.ComponentProps<C>>
433
+ >
434
+
435
+ interface StyledComponents {
436
+ ActivityIndicator: HostClassComponent<ReactNative['ActivityIndicator']>
437
+ Button: HostClassComponent<ReactNative['Button']>
438
+ DatePickerIOS: HostClassComponent<ReactNative['DatePickerIOS']>
439
+ DrawerLayoutAndroid: HostClassComponent<ReactNative['DrawerLayoutAndroid']>
440
+ FlatList: HostClassComponent<ReactNative['FlatList']>
441
+ Image: HostClassComponent<ReactNative['Image']>
442
+ ImageBackground: HostClassComponent<ReactNative['ImageBackground']>
443
+ KeyboardAvoidingView: HostClassComponent<ReactNative['KeyboardAvoidingView']>
444
+ ListView: HostClassComponent<ReactNative['ListView']>
445
+ Modal: HostClassComponent<ReactNative['Modal']>
446
+ NavigatorIOS: HostClassComponent<ReactNative['NavigatorIOS']>
447
+ Picker: HostClassComponent<ReactNative['Picker']>
448
+ PickerIOS: HostClassComponent<ReactNative['PickerIOS']>
449
+ Pressable: HostFunctionComponent<ReactNative['Pressable']>
450
+ ProgressBarAndroid: HostClassComponent<ReactNative['ProgressBarAndroid']>
451
+ ProgressViewIOS: HostClassComponent<ReactNative['ProgressViewIOS']>
452
+ RecyclerViewBackedScrollView: HostClassComponent<
453
+ ReactNative['RecyclerViewBackedScrollView']
454
+ >
455
+ RefreshControl: HostClassComponent<ReactNative['RefreshControl']>
456
+ SafeAreaView: HostClassComponent<ReactNative['SafeAreaView']>
457
+ ScrollView: HostClassComponent<ReactNative['ScrollView']>
458
+ SectionList: HostClassComponent<ReactNative['SectionList']>
459
+ SegmentedControlIOS: HostClassComponent<ReactNative['SegmentedControlIOS']>
460
+ Slider: HostClassComponent<ReactNative['Slider']>
461
+ SnapshotViewIOS: HostClassComponent<ReactNative['SnapshotViewIOS']>
462
+ StatusBar: HostClassComponent<ReactNative['StatusBar']>
463
+ SwipeableListView: HostClassComponent<ReactNative['SwipeableListView']>
464
+ Switch: HostClassComponent<ReactNative['Switch']>
465
+ SwitchIOS: HostClassComponent<ReactNative['SwitchIOS']>
466
+ TabBarIOS: HostClassComponent<ReactNative['TabBarIOS']>
467
+ Text: HostClassComponent<ReactNative['Text']>
468
+ TextInput: HostClassComponent<ReactNative['TextInput']>
469
+ ToolbarAndroid: HostClassComponent<ReactNative['ToolbarAndroid']>
470
+ TouchableHighlight: HostClassComponent<ReactNative['TouchableHighlight']>
471
+ TouchableNativeFeedback: HostClassComponent<
472
+ ReactNative['TouchableNativeFeedback']
473
+ >
474
+ TouchableOpacity: HostClassComponent<ReactNative['TouchableOpacity']>
475
+ TouchableWithoutFeedback: HostClassComponent<
476
+ ReactNative['TouchableWithoutFeedback']
477
+ >
478
+ View: HostClassComponent<ReactNative['View']>
479
+ ViewPagerAndroid: HostClassComponent<ReactNative['ViewPagerAndroid']>
480
+ }
481
+
482
+ interface CreateStyled extends CreateStyled$1, StyledComponents {}
483
+
484
+ declare const styled: CreateStyled
485
+
486
+ export { StorybookTheme, StyledComponent, ThemeProvider, darkTheme, styled, theme, useTheme };
487
+
488
+ export interface Theme extends StorybookTheme {}