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