@react-pdf/stylesheet 5.2.2 → 6.0.0

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/lib/index.d.ts +284 -0
  2. package/lib/index.js +673 -678
  3. package/package.json +4 -4
package/lib/index.d.ts ADDED
@@ -0,0 +1,284 @@
1
+ type Container = {
2
+ width: number;
3
+ height: number;
4
+ dpi?: number;
5
+ remBase?: number;
6
+ orientation?: 'landscape' | 'portrait';
7
+ };
8
+ type BorderStyleValue = 'dashed' | 'dotted' | 'solid';
9
+ type BorderShorthandStyle = {
10
+ border?: number | string;
11
+ borderTop?: number | string;
12
+ borderRight?: number | string;
13
+ borderBottom?: number | string;
14
+ borderLeft?: number | string;
15
+ borderColor?: string;
16
+ borderRadius?: number | string;
17
+ borderStyle?: BorderStyleValue;
18
+ borderWidth?: number | string;
19
+ };
20
+ type BorderExpandedStyle = {
21
+ borderTopColor?: string;
22
+ borderTopStyle?: BorderStyleValue;
23
+ borderTopWidth?: number | string;
24
+ borderRightColor?: string;
25
+ borderRightStyle?: BorderStyleValue;
26
+ borderRightWidth?: number | string;
27
+ borderBottomColor?: string;
28
+ borderBottomStyle?: BorderStyleValue;
29
+ borderBottomWidth?: number | string;
30
+ borderLeftColor?: string;
31
+ borderLeftStyle?: BorderStyleValue;
32
+ borderLeftWidth?: number | string;
33
+ borderTopLeftRadius?: number | string;
34
+ borderTopRightRadius?: number | string;
35
+ borderBottomRightRadius?: number | string;
36
+ borderBottomLeftRadius?: number | string;
37
+ };
38
+ type BorderSafeStyle = BorderExpandedStyle & {
39
+ borderTopWidth?: number;
40
+ borderRightWidth?: number;
41
+ borderBottomWidth?: number;
42
+ borderLeftWidth?: number;
43
+ borderTopLeftRadius?: number;
44
+ borderTopRightRadius?: number;
45
+ borderBottomRightRadius?: number;
46
+ borderBottomLeftRadius?: number;
47
+ };
48
+ type BorderStyle = BorderShorthandStyle & BorderExpandedStyle;
49
+ type FlexboxShorthandStyle = {
50
+ flex?: number | string;
51
+ };
52
+ type AlignContent = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'space-between' | 'space-around' | 'space-evenly';
53
+ type AlignItems = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
54
+ type AlignSelf = 'auto' | 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch';
55
+ type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
56
+ type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
57
+ type JustifyContent = 'flex-start' | 'flex-end' | 'center' | 'space-around' | 'space-between' | 'space-evenly';
58
+ type JustifySelf = string;
59
+ type FlexboxExpandedStyle = {
60
+ alignContent?: AlignContent;
61
+ alignItems?: AlignItems;
62
+ alignSelf?: AlignSelf;
63
+ flexDirection?: FlexDirection;
64
+ flexWrap?: FlexWrap;
65
+ flexFlow?: number | string;
66
+ flexGrow?: number | string;
67
+ flexShrink?: number | string;
68
+ flexBasis?: number | string;
69
+ justifySelf?: JustifySelf;
70
+ justifyContent?: JustifyContent;
71
+ };
72
+ type FlexboxSafeStyle = FlexboxExpandedStyle & {
73
+ flexGrow?: number;
74
+ flexShrink?: number;
75
+ };
76
+ type FlexboxStyle = FlexboxShorthandStyle & FlexboxExpandedStyle;
77
+ type GapShorthandStyle = {
78
+ gap?: number | string;
79
+ };
80
+ type GapExpandedStyle = {
81
+ rowGap?: number | string;
82
+ columnGap?: number | string;
83
+ };
84
+ type GapSafeStyle = {
85
+ rowGap?: number;
86
+ columnGap?: number;
87
+ };
88
+ type GapStyle = GapShorthandStyle & GapExpandedStyle;
89
+ type PositionShorthandStyle = {
90
+ objectPosition?: number | string;
91
+ };
92
+ type PositionExpandedStyle = {
93
+ objectPositionX?: number | string;
94
+ objectPositionY?: number | string;
95
+ objectFit?: string;
96
+ };
97
+ type PositionSafeStyle = PositionExpandedStyle & {
98
+ objectPositionX?: number;
99
+ objectPositionY?: number;
100
+ };
101
+ type PositioningStyle = PositionShorthandStyle & PositionExpandedStyle;
102
+ type TransformShorthandStyle = {
103
+ transformOrigin?: number | string;
104
+ };
105
+ type TransformExpandedStyle = {
106
+ transformOriginX?: number | string;
107
+ transformOriginY?: number | string;
108
+ transform?: string;
109
+ };
110
+ type TransformSafeStyle = TransformExpandedStyle & {
111
+ transformOriginX?: number;
112
+ transformOriginY?: number;
113
+ };
114
+ type TransformStyle = TransformShorthandStyle & TransformExpandedStyle;
115
+ type Display = 'flex' | 'none';
116
+ type Position = 'absolute' | 'relative' | 'static';
117
+ type LayoutStyle = {
118
+ aspectRatio?: number | string;
119
+ bottom?: number | string;
120
+ display?: Display;
121
+ left?: number | string;
122
+ position?: Position;
123
+ right?: number | string;
124
+ top?: number | string;
125
+ overflow?: 'hidden';
126
+ zIndex?: number | string;
127
+ };
128
+ type LayoutExpandedStyle = LayoutStyle;
129
+ type LayoutSafeStyle = LayoutExpandedStyle & {
130
+ aspectRatio?: number;
131
+ bottom?: number;
132
+ left?: number;
133
+ right?: number;
134
+ top?: number;
135
+ zIndex?: number;
136
+ };
137
+ type DimensionStyle = {
138
+ height?: number | string;
139
+ maxHeight?: number | string;
140
+ maxWidth?: number | string;
141
+ minHeight?: number | string;
142
+ minWidth?: number | string;
143
+ width?: number | string;
144
+ };
145
+ type DimensionExpandedStyle = DimensionStyle;
146
+ type DimensionSafeStyle = DimensionExpandedStyle & {
147
+ height?: number;
148
+ maxHeight?: number;
149
+ maxWidth?: number;
150
+ minHeight?: number;
151
+ minWidth?: number;
152
+ width?: number;
153
+ };
154
+ type ColorStyle = {
155
+ backgroundColor?: string;
156
+ color?: string;
157
+ opacity?: number | string;
158
+ };
159
+ type ColorSafeStyle = {
160
+ backgroundColor?: string;
161
+ color?: string;
162
+ opacity?: number;
163
+ };
164
+ type FontStyle = 'normal' | 'italic' | 'oblique';
165
+ type FontWeight = string | number | 'thin' | 'hairline' | 'ultralight' | 'extralight' | 'light' | 'normal' | 'medium' | 'semibold' | 'demibold' | 'bold' | 'ultrabold' | 'extrabold' | 'heavy' | 'black';
166
+ type TextAlign = 'left' | 'right' | 'center' | 'justify';
167
+ type TextDecoration = 'line-through' | 'underline' | 'none' | 'line-through underline' | 'underline line-through';
168
+ type TextDecorationStyle = 'dashed' | 'dotted' | 'solid' | string;
169
+ type TextTransform = 'capitalize' | 'lowercase' | 'uppercase' | 'none';
170
+ type VerticalAlign = 'sub' | 'super';
171
+ type TextStyle = {
172
+ fontSize?: number | string;
173
+ fontFamily?: string | string[];
174
+ fontStyle?: FontStyle;
175
+ fontWeight?: FontWeight;
176
+ letterSpacing?: number | string;
177
+ lineHeight?: number | string;
178
+ maxLines?: number;
179
+ textAlign?: TextAlign;
180
+ textDecoration?: TextDecoration;
181
+ textDecorationColor?: string;
182
+ textDecorationStyle?: TextDecorationStyle;
183
+ textIndent?: any;
184
+ textOverflow?: 'ellipsis';
185
+ textTransform?: TextTransform;
186
+ verticalAlign?: VerticalAlign;
187
+ };
188
+ type TextExpandedStyle = TextStyle;
189
+ type TextSafeStyle = TextExpandedStyle & {
190
+ fontSize?: number;
191
+ fontWeight?: number;
192
+ letterSpacing?: number;
193
+ lineHeight?: number;
194
+ };
195
+ type MarginShorthandStyle = {
196
+ margin?: number | string;
197
+ marginHorizontal?: number | string;
198
+ marginVertical?: number | string;
199
+ };
200
+ type MarginExpandedStyle = {
201
+ marginTop?: number | string;
202
+ marginRight?: number | string;
203
+ marginBottom?: number | string;
204
+ marginLeft?: number | string;
205
+ };
206
+ type MarginSafeStyle = MarginExpandedStyle & {
207
+ marginTop?: number;
208
+ marginRight?: number;
209
+ marginBottom?: number;
210
+ marginLeft?: number;
211
+ };
212
+ type MarginStyle = MarginShorthandStyle & MarginExpandedStyle;
213
+ type PaddingShorthandStyle = {
214
+ padding?: number | string;
215
+ paddingHorizontal?: number | string;
216
+ paddingVertical?: number | string;
217
+ };
218
+ type PaddingExpandedStyle = {
219
+ paddingTop?: number | string;
220
+ paddingRight?: number | string;
221
+ paddingBottom?: number | string;
222
+ paddingLeft?: number | string;
223
+ };
224
+ type PaddingSafeStyle = PaddingExpandedStyle & {
225
+ paddingTop?: number;
226
+ paddingRight?: number;
227
+ paddingBottom?: number;
228
+ paddingLeft?: number;
229
+ };
230
+ type PaddingStyle = PaddingShorthandStyle & PaddingExpandedStyle;
231
+ interface SvgStyle {
232
+ fill?: string;
233
+ stroke?: string;
234
+ strokeDasharray?: string;
235
+ strokeWidth?: string | number;
236
+ fillOpacity?: string | number;
237
+ fillRule?: 'nonzero' | 'evenodd';
238
+ strokeOpacity?: string | number;
239
+ textAnchor?: 'start' | 'middle' | 'end';
240
+ strokeLinecap?: 'butt' | 'round' | 'square';
241
+ strokeLinejoin?: 'butt' | 'round' | 'square';
242
+ visibility?: 'visible' | 'hidden' | 'collapse';
243
+ clipPath?: string;
244
+ dominantBaseline?: 'auto' | 'middle' | 'central' | 'hanging' | 'mathematical' | 'text-after-edge' | 'text-before-edge';
245
+ }
246
+ type SvgSafeStyle = SvgStyle & {
247
+ strokeWidth?: number;
248
+ fillOpacity?: number;
249
+ strokeOpacity?: number;
250
+ };
251
+ type BaseStyle = BorderStyle & ColorStyle & DimensionStyle & FlexboxStyle & GapStyle & LayoutStyle & MarginStyle & PaddingStyle & PositioningStyle & TextStyle & TransformStyle & SvgStyle;
252
+ type MediaQueryStyle = {
253
+ [key in `@media${string}`]: BaseStyle;
254
+ };
255
+ type Style = BaseStyle & MediaQueryStyle;
256
+ type SafeStyle = BorderSafeStyle & ColorSafeStyle & DimensionSafeStyle & FlexboxSafeStyle & GapSafeStyle & LayoutSafeStyle & MarginSafeStyle & PaddingSafeStyle & PositionSafeStyle & TextSafeStyle & TransformSafeStyle & SvgSafeStyle;
257
+
258
+ /**
259
+ * Transform given color to hexa
260
+ *
261
+ * @param value - Styles value
262
+ * @returns Transformed value
263
+ */
264
+ declare const transformColor: (value: string) => string;
265
+
266
+ /**
267
+ * Flattens an array of style objects, into one aggregated style object.
268
+ *
269
+ * @param styles - Style or style array
270
+ * @returns Flattened style object
271
+ */
272
+ declare const flatten: (value: Style | Style[], ...args: any[]) => Style;
273
+
274
+ type StyleParam = Style | null | undefined;
275
+ /**
276
+ * Resolves styles
277
+ *
278
+ * @param container
279
+ * @param style - Style
280
+ * @returns Resolved style
281
+ */
282
+ declare const resolveStyles: (container: Container, style: StyleParam | StyleParam[]) => SafeStyle;
283
+
284
+ export { type SafeStyle, type Style, resolveStyles as default, flatten, transformColor };