@storybook/react-native-theming 9.0.0-beta.7 → 9.0.0-rc.4

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +122 -235
  2. package/dist/index.js +825 -434
  3. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -1,233 +1,9 @@
1
1
  import * as RN from 'react-native';
2
2
  import { ImageSourcePropType, ImageProps, TextStyle } from 'react-native';
3
- import * as React$1 from 'react';
3
+ import { Theme as Theme$1 } from './theming.js';
4
+ export { ThemeProvider, useTheme, withTheme } from './theming.js';
4
5
  import { ReactElement } from 'react';
5
6
 
6
- declare const color: {
7
- primary: string;
8
- secondary: string;
9
- secondaryLighter: string;
10
- tertiary: string;
11
- ancillary: string;
12
- orange: string;
13
- gold: string;
14
- green: string;
15
- seafoam: string;
16
- purple: string;
17
- ultraviolet: string;
18
- lightest: string;
19
- lighter: string;
20
- light: string;
21
- mediumlight: string;
22
- medium: string;
23
- mediumdark: string;
24
- dark: string;
25
- darker: string;
26
- darkest: string;
27
- border: string;
28
- positive: string;
29
- negative: string;
30
- warning: string;
31
- critical: string;
32
- defaultText: string;
33
- inverseText: string;
34
- positiveText: string;
35
- negativeText: string;
36
- warningText: string;
37
- };
38
- declare const background: {
39
- app: string;
40
- bar: string;
41
- content: string;
42
- preview: string;
43
- gridCellSize: number;
44
- hoverable: string;
45
- positive: string;
46
- negative: string;
47
- warning: string;
48
- critical: string;
49
- };
50
- declare const typography: {
51
- weight: {
52
- regular: TextStyle["fontWeight"];
53
- bold: TextStyle["fontWeight"];
54
- };
55
- size: {
56
- s1: number;
57
- s2: number;
58
- s3: number;
59
- m1: number;
60
- m2: number;
61
- m3: number;
62
- l1: number;
63
- l2: number;
64
- l3: number;
65
- code: number;
66
- };
67
- };
68
- type Color = typeof color;
69
- type Background = typeof background;
70
- type Typography = typeof typography;
71
- interface Brand {
72
- title?: string | undefined;
73
- url?: string | null | undefined;
74
- image?: ImageSourcePropType | ReactElement | null | undefined;
75
- resizeMode?: ImageProps['resizeMode'] | null | undefined;
76
- target?: string | null | undefined;
77
- }
78
- interface StorybookThemeWeb {
79
- base: 'light' | 'dark';
80
- color: Color;
81
- background: Background;
82
- typography: Typography;
83
- textMutedColor: string;
84
- input: {
85
- border: string;
86
- background: string;
87
- color: string;
88
- borderRadius: number;
89
- paddingHorizontal: number;
90
- paddingVertical: number;
91
- };
92
- button: {
93
- background: string;
94
- border: string;
95
- };
96
- boolean: {
97
- background: string;
98
- selectedBackground: string;
99
- };
100
- layoutMargin: number;
101
- appBorderColor: string;
102
- appBorderRadius: number;
103
- barTextColor: string;
104
- barHoverColor: string;
105
- barSelectedColor: string;
106
- barBg: string;
107
- brand?: Brand;
108
- }
109
-
110
- type StorybookTheme = StorybookThemeWeb;
111
- declare const theme: StorybookThemeWeb;
112
- declare const darkTheme: StorybookThemeWeb;
113
-
114
- type IsPreReact19 = 2 extends Parameters<React.FunctionComponent<any>>['length']
115
- ? true
116
- : false
117
-
118
- // unpack all here to avoid infinite self-referencing when defining our own JSX namespace for the pre-React 19 case
119
- type ReactJSXElement = true extends IsPreReact19
120
- ? /** @ts-ignore */
121
- JSX.Element
122
- : /** @ts-ignore */
123
- React.JSX.Element
124
- type ReactJSXElementClass = true extends IsPreReact19
125
- ? /** @ts-ignore */
126
- JSX.ElementClass
127
- : /** @ts-ignore */
128
- React.JSX.ElementClass
129
- type ReactJSXElementAttributesProperty = true extends IsPreReact19
130
- ? /** @ts-ignore */
131
- JSX.ElementAttributesProperty
132
- : /** @ts-ignore */
133
- React.JSX.ElementAttributesProperty
134
- type ReactJSXElementChildrenAttribute = true extends IsPreReact19
135
- ? /** @ts-ignore */
136
- JSX.ElementChildrenAttribute
137
- : /** @ts-ignore */
138
- React.JSX.ElementChildrenAttribute
139
- type ReactJSXLibraryManagedAttributes<C, P> = true extends IsPreReact19
140
- ? /** @ts-ignore */
141
- JSX.LibraryManagedAttributes<C, P>
142
- : /** @ts-ignore */
143
- React.JSX.LibraryManagedAttributes<C, P>
144
- type ReactJSXIntrinsicAttributes = true extends IsPreReact19
145
- ? /** @ts-ignore */
146
- JSX.IntrinsicAttributes
147
- : /** @ts-ignore */
148
- React.JSX.IntrinsicAttributes
149
- type ReactJSXIntrinsicClassAttributes<T> = true extends IsPreReact19
150
- ? /** @ts-ignore */
151
- JSX.IntrinsicClassAttributes<T>
152
- : /** @ts-ignore */
153
- React.JSX.IntrinsicClassAttributes<T>
154
- type ReactJSXIntrinsicElements = true extends IsPreReact19
155
- ? /** @ts-ignore */
156
- JSX.IntrinsicElements
157
- : /** @ts-ignore */
158
- React.JSX.IntrinsicElements
159
-
160
- type ReactJSXElementType = true extends IsPreReact19
161
- ? // based on the code from @types/react@18.2.8
162
- // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3197efc097d522c4bf02b94e1a0766d007d6cdeb/types/react/index.d.ts#LL3204C13-L3204C13
163
- string | React.JSXElementConstructor<any>
164
- : /** @ts-ignore */
165
- React.JSX.ElementType
166
-
167
- declare namespace ReactJSX {
168
- type ElementType = ReactJSXElementType
169
- interface Element extends ReactJSXElement {}
170
- interface ElementClass extends ReactJSXElementClass {}
171
- interface ElementAttributesProperty
172
- extends ReactJSXElementAttributesProperty {}
173
- interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}
174
-
175
- type LibraryManagedAttributes<C, P> = ReactJSXLibraryManagedAttributes<C, P>
176
-
177
- interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
178
- interface IntrinsicClassAttributes<T>
179
- extends ReactJSXIntrinsicClassAttributes<T> {}
180
-
181
- type IntrinsicElements = ReactJSXIntrinsicElements
182
- }
183
-
184
- /**
185
- * @desc Utility type for getting props type of React component.
186
- * It takes `defaultProps` into an account - making props with defaults optional.
187
- */
188
- type PropsOf<
189
- C extends keyof ReactJSX.IntrinsicElements | React.JSXElementConstructor<any>
190
- > = ReactJSX.LibraryManagedAttributes<C, React.ComponentProps<C>>
191
-
192
- // We need to use this version of Omit as it's distributive (Will preserve unions)
193
- type DistributiveOmit<T, U> = T extends any
194
- ? Pick<T, Exclude<keyof T, U>>
195
- : never
196
-
197
- // Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
198
- // TypeScript Version: 3.1
199
-
200
-
201
-
202
- interface ThemeProviderProps {
203
- theme: Partial<Theme> | ((outerTheme: Theme) => Theme)
204
- children: React$1.ReactNode
205
- }
206
-
207
- declare function useTheme(): Theme
208
-
209
- interface ThemeProvider {
210
- (props: ThemeProviderProps): React$1.ReactElement
211
- }
212
-
213
- declare const ThemeProvider: ThemeProvider
214
-
215
- type withTheme = <
216
- C extends React$1.ComponentType<React$1.ComponentProps<C>>
217
- >(
218
- component: C
219
- ) => React$1.FC<DistributiveOmit<PropsOf<C>, 'theme'> & { theme?: Theme }>
220
-
221
- declare const withTheme: withTheme
222
-
223
- // Definitions by: Junyoung Clare Jang <https://github.com/Ailrun>
224
- // TypeScript Version: 3.4
225
-
226
-
227
-
228
- // tslint:disable-next-line: no-empty-interface
229
- export interface Theme extends StorybookTheme {}
230
-
231
7
  // Definitions by: Pat Sissons <https://github.com/patsissons>
232
8
  // TypeScript Version: 3.4
233
9
 
@@ -327,7 +103,7 @@ interface CreateStyledComponent<
327
103
  ...styles: ArrayInterpolation<
328
104
  ComponentProps &
329
105
  SpecificComponentProps &
330
- AdditionalProps & { theme: Theme },
106
+ AdditionalProps & { theme: Theme$1 },
331
107
  StyleType
332
108
  >
333
109
  ): StyledComponent<
@@ -343,7 +119,7 @@ interface CreateStyledComponent<
343
119
  ...styles: ArrayInterpolation<
344
120
  ComponentProps &
345
121
  SpecificComponentProps &
346
- AdditionalProps & { theme: Theme },
122
+ AdditionalProps & { theme: Theme$1 },
347
123
  StyleType
348
124
  >
349
125
  ): StyledComponent<
@@ -372,7 +148,7 @@ interface CreateStyled$1 {
372
148
  options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
373
149
  ): CreateStyledComponent<
374
150
  Pick<React.ComponentProps<C>, ForwardedProps> & {
375
- theme?: Theme
151
+ theme?: Theme$1
376
152
  as?: React.ElementType
377
153
  },
378
154
  {},
@@ -385,7 +161,7 @@ interface CreateStyled$1 {
385
161
  options?: StyledOptions<React.ComponentProps<C>>
386
162
  ): CreateStyledComponent<
387
163
  React.ComponentProps<C> & {
388
- theme?: Theme
164
+ theme?: Theme$1
389
165
  as?: React.ElementType
390
166
  },
391
167
  {},
@@ -402,7 +178,7 @@ interface CreateStyled$1 {
402
178
  options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
403
179
  ): CreateStyledComponent<
404
180
  Pick<React.ComponentProps<C>, ForwardedProps> & {
405
- theme?: Theme
181
+ theme?: Theme$1
406
182
  as?: React.ElementType
407
183
  },
408
184
  {},
@@ -414,7 +190,7 @@ interface CreateStyled$1 {
414
190
  component: C,
415
191
  options?: StyledOptions<React.ComponentProps<C>>
416
192
  ): CreateStyledComponent<
417
- React.ComponentProps<C> & { theme?: Theme; as?: React.ElementType },
193
+ React.ComponentProps<C> & { theme?: Theme$1; as?: React.ElementType },
418
194
  {},
419
195
  {},
420
196
  ReactNativeStyleType<React.ComponentProps<C>>
@@ -431,14 +207,14 @@ type ReactNative = typeof RN
431
207
  // those 2 are just copies of the `BaseCreateStyled` with supplied `C` type argument
432
208
  type HostClassComponent<C extends React.ComponentClass<any>> =
433
209
  CreateStyledComponent<
434
- React.ComponentProps<C> & { theme?: Theme; as?: React.ElementType },
210
+ React.ComponentProps<C> & { theme?: Theme$1; as?: React.ElementType },
435
211
  {},
436
212
  { ref?: React.Ref<InstanceType<C>> },
437
213
  ReactNativeStyleType<React.ComponentProps<C>>
438
214
  >
439
215
  type HostFunctionComponent<C extends React.FunctionComponent<any>> =
440
216
  CreateStyledComponent<
441
- React.ComponentProps<C> & { theme?: Theme; as?: React.ElementType },
217
+ React.ComponentProps<C> & { theme?: Theme$1; as?: React.ElementType },
442
218
  {},
443
219
  {},
444
220
  ReactNativeStyleType<React.ComponentProps<C>>
@@ -495,4 +271,115 @@ interface CreateStyled extends CreateStyled$1, StyledComponents {}
495
271
 
496
272
  declare const styled: CreateStyled
497
273
 
498
- export { StorybookTheme, StyledComponent, ThemeProvider, darkTheme, styled, theme, useTheme, withTheme };
274
+ declare const color: {
275
+ primary: string;
276
+ secondary: string;
277
+ secondaryLighter: string;
278
+ tertiary: string;
279
+ ancillary: string;
280
+ orange: string;
281
+ gold: string;
282
+ green: string;
283
+ seafoam: string;
284
+ purple: string;
285
+ ultraviolet: string;
286
+ lightest: string;
287
+ lighter: string;
288
+ light: string;
289
+ mediumlight: string;
290
+ medium: string;
291
+ mediumdark: string;
292
+ dark: string;
293
+ darker: string;
294
+ darkest: string;
295
+ border: string;
296
+ positive: string;
297
+ negative: string;
298
+ warning: string;
299
+ critical: string;
300
+ defaultText: string;
301
+ inverseText: string;
302
+ positiveText: string;
303
+ negativeText: string;
304
+ warningText: string;
305
+ };
306
+ declare const background: {
307
+ app: string;
308
+ bar: string;
309
+ content: string;
310
+ preview: string;
311
+ gridCellSize: number;
312
+ hoverable: string;
313
+ positive: string;
314
+ negative: string;
315
+ warning: string;
316
+ critical: string;
317
+ };
318
+ declare const typography: {
319
+ weight: {
320
+ regular: TextStyle["fontWeight"];
321
+ bold: TextStyle["fontWeight"];
322
+ };
323
+ size: {
324
+ s1: number;
325
+ s2: number;
326
+ s3: number;
327
+ m1: number;
328
+ m2: number;
329
+ m3: number;
330
+ l1: number;
331
+ l2: number;
332
+ l3: number;
333
+ code: number;
334
+ };
335
+ };
336
+ type Color = typeof color;
337
+ type Background = typeof background;
338
+ type Typography = typeof typography;
339
+ interface Brand {
340
+ title?: string | undefined;
341
+ url?: string | null | undefined;
342
+ image?: ImageSourcePropType | ReactElement | null | undefined;
343
+ resizeMode?: ImageProps['resizeMode'] | null | undefined;
344
+ target?: string | null | undefined;
345
+ }
346
+ interface StorybookThemeWeb {
347
+ base: 'light' | 'dark';
348
+ color: Color;
349
+ background: Background;
350
+ typography: Typography;
351
+ textMutedColor: string;
352
+ input: {
353
+ border: string;
354
+ background: string;
355
+ color: string;
356
+ borderRadius: number;
357
+ paddingHorizontal: number;
358
+ paddingVertical: number;
359
+ };
360
+ button: {
361
+ background: string;
362
+ border: string;
363
+ };
364
+ boolean: {
365
+ background: string;
366
+ selectedBackground: string;
367
+ };
368
+ layoutMargin: number;
369
+ appBorderColor: string;
370
+ appBorderRadius: number;
371
+ barTextColor: string;
372
+ barHoverColor: string;
373
+ barSelectedColor: string;
374
+ barBg: string;
375
+ brand?: Brand;
376
+ }
377
+
378
+ type StorybookTheme = StorybookThemeWeb;
379
+ declare const theme: StorybookThemeWeb;
380
+ declare const darkTheme: StorybookThemeWeb;
381
+
382
+ interface Theme extends StorybookTheme {
383
+ }
384
+
385
+ export { StorybookTheme, StyledComponent, Theme, darkTheme, styled, theme };