react-native-unistyles 1.0.0-beta.5 → 1.0.0-rc.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/README.md +6 -588
- package/lib/commonjs/createUnistyles.js +0 -9
- package/lib/commonjs/createUnistyles.js.map +1 -1
- package/lib/commonjs/types/breakpoints.js +6 -0
- package/lib/commonjs/types/breakpoints.js.map +1 -0
- package/lib/commonjs/{types.js → types/core.js} +1 -1
- package/lib/commonjs/types/core.js.map +1 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/mediaQueries.js.map +1 -0
- package/lib/commonjs/utils/index.js +43 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/createUnistyles.js +0 -9
- package/lib/module/createUnistyles.js.map +1 -1
- package/lib/module/types/breakpoints.js +2 -0
- package/lib/module/types/breakpoints.js.map +1 -0
- package/lib/module/types/core.js +2 -0
- package/lib/module/types/core.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/mediaQueries.js.map +1 -0
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/src/createUnistyles.d.ts +1 -5
- package/lib/typescript/src/createUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +19 -0
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -0
- package/lib/typescript/src/types/core.d.ts +32 -0
- package/lib/typescript/src/types/core.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +3 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/mediaQueries.d.ts +2 -0
- package/lib/typescript/src/types/mediaQueries.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +2 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/package.json +13 -10
- package/src/__tests__/createUnistyles.spec.tsx +158 -0
- package/src/createUnistyles.ts +0 -10
- package/src/types/breakpoints.ts +33 -0
- package/src/types/core.ts +73 -0
- package/src/types/index.ts +9 -0
- package/src/types/mediaQueries.ts +69 -0
- package/src/utils/index.ts +9 -1
- package/lib/commonjs/mediaQueries.js.map +0 -1
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/breakpoints.spec.js +0 -154
- package/lib/commonjs/utils/breakpoints.spec.js.map +0 -1
- package/lib/commonjs/utils/mediaQueries.spec.js +0 -220
- package/lib/commonjs/utils/mediaQueries.spec.js.map +0 -1
- package/lib/commonjs/utils/styles.spec.js +0 -174
- package/lib/commonjs/utils/styles.spec.js.map +0 -1
- package/lib/module/mediaQueries.js.map +0 -1
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/breakpoints.spec.js +0 -152
- package/lib/module/utils/breakpoints.spec.js.map +0 -1
- package/lib/module/utils/mediaQueries.spec.js +0 -218
- package/lib/module/utils/mediaQueries.spec.js.map +0 -1
- package/lib/module/utils/styles.spec.js +0 -172
- package/lib/module/utils/styles.spec.js.map +0 -1
- package/lib/typescript/src/mediaQueries.d.ts +0 -2
- package/lib/typescript/src/mediaQueries.d.ts.map +0 -1
- package/lib/typescript/src/types.d.ts +0 -67
- package/lib/typescript/src/types.d.ts.map +0 -1
- package/lib/typescript/src/utils/breakpoints.spec.d.ts +0 -2
- package/lib/typescript/src/utils/breakpoints.spec.d.ts.map +0 -1
- package/lib/typescript/src/utils/mediaQueries.spec.d.ts +0 -2
- package/lib/typescript/src/utils/mediaQueries.spec.d.ts.map +0 -1
- package/lib/typescript/src/utils/styles.spec.d.ts +0 -2
- package/lib/typescript/src/utils/styles.spec.d.ts.map +0 -1
- package/src/mediaQueries.ts +0 -33
- package/src/types.ts +0 -123
- /package/lib/commonjs/{mediaQueries.js → types/mediaQueries.js} +0 -0
- /package/lib/module/{mediaQueries.js → types/mediaQueries.js} +0 -0
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"breakpoints.spec.d.ts","sourceRoot":"","sources":["../../../../src/utils/breakpoints.spec.ts"],"names":[],"mappings":""}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mediaQueries.spec.d.ts","sourceRoot":"","sources":["../../../../src/utils/mediaQueries.spec.ts"],"names":[],"mappings":""}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"styles.spec.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.spec.ts"],"names":[],"mappings":""}
|
package/src/mediaQueries.ts
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
// this is super weird, but number passes empty string and bigint does not
|
2
|
-
export type MediaQueries =
|
3
|
-
// For :w
|
4
|
-
`:w[${bigint}]` |
|
5
|
-
`:w[,${bigint}]` |
|
6
|
-
`:w[${bigint},${bigint}]` |
|
7
|
-
|
8
|
-
// For :h
|
9
|
-
`:h[${bigint}]` |
|
10
|
-
`:h[,${bigint}]` |
|
11
|
-
`:h[${bigint},${bigint}]` |
|
12
|
-
|
13
|
-
// Combinations of :w and :h
|
14
|
-
`:w[${bigint}]:h[${bigint}]` |
|
15
|
-
`:w[${bigint},${bigint}]:h[${bigint}]` |
|
16
|
-
`:w[${bigint}]:h[${bigint},${bigint}]` |
|
17
|
-
`:w[${bigint},${bigint}]:h[${bigint},${bigint}]` |
|
18
|
-
`:w[,${bigint}]:h[,${bigint}]` |
|
19
|
-
`:w[,${bigint}]:h[${bigint}]` |
|
20
|
-
`:w[${bigint}]:h[,${bigint}]` |
|
21
|
-
`:w[,${bigint}]:h[${bigint},${bigint}]` |
|
22
|
-
`:w[${bigint},${bigint}]:h[,${bigint}]` |
|
23
|
-
|
24
|
-
// Combinations of :h and :w
|
25
|
-
`:h[${bigint}]:w[${bigint}]` |
|
26
|
-
`:h[${bigint},${bigint}]:w[${bigint}]` |
|
27
|
-
`:h[${bigint}]:w[${bigint},${bigint}]` |
|
28
|
-
`:h[${bigint},${bigint}]:w[${bigint},${bigint}]` |
|
29
|
-
`:h[,${bigint}]:w[,${bigint}]` |
|
30
|
-
`:h[,${bigint}]:w[${bigint}]` |
|
31
|
-
`:h[${bigint}]:w[,${bigint}]` |
|
32
|
-
`:h[,${bigint}]:w[${bigint},${bigint}]` |
|
33
|
-
`:h[${bigint},${bigint}]:w[,${bigint}]`
|
package/src/types.ts
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'
|
2
|
-
import type {
|
3
|
-
MatrixTransform,
|
4
|
-
PerpectiveTransform,
|
5
|
-
RotateTransform,
|
6
|
-
RotateXTransform,
|
7
|
-
RotateYTransform,
|
8
|
-
RotateZTransform,
|
9
|
-
ScaleTransform,
|
10
|
-
ScaleXTransform,
|
11
|
-
ScaleYTransform,
|
12
|
-
SkewXTransform,
|
13
|
-
SkewYTransform,
|
14
|
-
TranslateXTransform,
|
15
|
-
TranslateYTransform
|
16
|
-
} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'
|
17
|
-
import type { MediaQueries } from './mediaQueries'
|
18
|
-
|
19
|
-
export type Breakpoints = Record<string, number>
|
20
|
-
|
21
|
-
export type SortedBreakpointEntries<B extends Breakpoints> = [[keyof B & string, number]]
|
22
|
-
|
23
|
-
export type ScreenSize = {
|
24
|
-
width: number,
|
25
|
-
height: number
|
26
|
-
}
|
27
|
-
|
28
|
-
export type CreateStylesFactory<ST, Theme> = (theme: Theme) => ST
|
29
|
-
|
30
|
-
type StyleProperty<T, B extends Breakpoints> = {
|
31
|
-
[K in keyof T]: {
|
32
|
-
[innerKey in keyof B]?: T[K]
|
33
|
-
} | {
|
34
|
-
[innerKey in MediaQueries]?: T[K]
|
35
|
-
} | T[K]
|
36
|
-
}
|
37
|
-
|
38
|
-
type ShadowOffsetProps<B> = {
|
39
|
-
shadowOffset: {
|
40
|
-
width: number | {
|
41
|
-
[innerKey in keyof B]?: number
|
42
|
-
} | {
|
43
|
-
[innerKey in MediaQueries]: number
|
44
|
-
},
|
45
|
-
height: number | {
|
46
|
-
[innerKey in keyof B]?: number
|
47
|
-
} | {
|
48
|
-
[innerKey in MediaQueries]: number
|
49
|
-
}
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
type TextShadowOffsetProps<B> = {
|
54
|
-
textShadowOffset: {
|
55
|
-
width: number | {
|
56
|
-
[innerKey in keyof B]?: number
|
57
|
-
} | {
|
58
|
-
[innerKey in MediaQueries]: number
|
59
|
-
},
|
60
|
-
height: number | {
|
61
|
-
[innerKey in keyof B]?: number
|
62
|
-
} | {
|
63
|
-
[innerKey in MediaQueries]: number
|
64
|
-
}
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
type TransformStyles<B extends Breakpoints> =
|
69
|
-
PerpectiveTransform | StyleProperty<PerpectiveTransform, B>
|
70
|
-
| RotateTransform | StyleProperty<RotateTransform, B>
|
71
|
-
| RotateXTransform | StyleProperty<RotateXTransform, B>
|
72
|
-
| RotateYTransform | StyleProperty<RotateYTransform, B>
|
73
|
-
| RotateZTransform | StyleProperty<RotateZTransform, B>
|
74
|
-
| ScaleTransform | StyleProperty<ScaleTransform, B>
|
75
|
-
| ScaleXTransform | StyleProperty<ScaleXTransform, B>
|
76
|
-
| ScaleYTransform | StyleProperty<ScaleYTransform, B>
|
77
|
-
| TranslateXTransform | StyleProperty<TranslateXTransform, B>
|
78
|
-
| TranslateYTransform | StyleProperty<TranslateYTransform, B>
|
79
|
-
| SkewXTransform | StyleProperty<SkewXTransform, B>
|
80
|
-
| SkewYTransform | StyleProperty<SkewYTransform, B>
|
81
|
-
| MatrixTransform | StyleProperty<MatrixTransform, B>
|
82
|
-
|
83
|
-
type TransformProps<B extends Breakpoints> = {
|
84
|
-
transform: Array<TransformStyles<B>>
|
85
|
-
}
|
86
|
-
|
87
|
-
type UnistyleView = Omit<Omit<Omit<ViewStyle, 'shadowOffset'>, 'transform'>, 'textShadowOffset'>
|
88
|
-
type UnistyleText = Omit<Omit<Omit<TextStyle, 'shadowOffset'>, 'transform'>, 'textShadowOffset'>
|
89
|
-
type UnistyleImage = Omit<Omit<Omit<ImageStyle, 'shadowOffset'>, 'transform'>, 'textShadowOffset'>
|
90
|
-
|
91
|
-
export type StaticStyles<B extends Breakpoints> =
|
92
|
-
| (UnistyleView | StyleProperty<UnistyleView, B>)
|
93
|
-
| (UnistyleText | StyleProperty<UnistyleText, B>)
|
94
|
-
| (UnistyleImage | StyleProperty<UnistyleImage, B>)
|
95
|
-
& TransformProps<B> & ShadowOffsetProps<B> & TextShadowOffsetProps<B>
|
96
|
-
|
97
|
-
export type CustomNamedStyles<T, B extends Breakpoints> = {
|
98
|
-
[K in keyof T]: T[K] extends (...args: infer A) => unknown
|
99
|
-
? (...args: A) => StaticStyles<B>
|
100
|
-
: StaticStyles<B>
|
101
|
-
}
|
102
|
-
|
103
|
-
type WithEmptyObject<V> = keyof V extends never ? {} : V
|
104
|
-
|
105
|
-
export type ExtractBreakpoints<T, B extends Breakpoints> = T extends Partial<Record<keyof B & string, infer V>>
|
106
|
-
? WithEmptyObject<V>
|
107
|
-
: T extends (...args: infer A) => infer R
|
108
|
-
? (...args: A) => ExtractBreakpoints<R, B>
|
109
|
-
: {
|
110
|
-
[K in keyof T]: T[K] extends (...args: infer A) => infer R
|
111
|
-
? (...args: A) => ExtractBreakpoints<R, B>
|
112
|
-
: T[K] extends object
|
113
|
-
? ExtractBreakpoints<T[K], B>
|
114
|
-
: T[K]
|
115
|
-
}
|
116
|
-
|
117
|
-
export type RemoveKeysWithPrefix<T, B extends Breakpoints> = T extends (...args: Array<any>) => infer R
|
118
|
-
? (...args: Parameters<T>) => RemoveKeysWithPrefix<R, B>
|
119
|
-
: T extends object
|
120
|
-
? T extends Record<string, infer _V>
|
121
|
-
? { [K in keyof T as K extends MediaQueries ? keyof B & string : K]: RemoveKeysWithPrefix<T[K], B> }
|
122
|
-
: { [K in keyof T]: RemoveKeysWithPrefix<T[K], B> }
|
123
|
-
: T
|
File without changes
|
File without changes
|