@takumi-rs/helpers 0.22.1 → 0.24.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.
- package/README.md +2 -23
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +33 -0
- package/dist/index.d.ts +20 -570
- package/dist/index.js +1 -1
- package/dist/jsx/jsx.cjs +1 -0
- package/dist/jsx/jsx.d.cts +6 -0
- package/dist/jsx/jsx.d.ts +3 -470
- package/dist/jsx/jsx.js +1 -13
- package/dist/types-C93nbSJX.d.cts +586 -0
- package/dist/types-C93nbSJX.d.ts +586 -0
- package/package.json +13 -9
package/README.md
CHANGED
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
# @takumi-rs/helpers
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Helper package for constructing Takumi layout.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```ts
|
|
8
|
-
import { container, text, image, style } from "@takumi-rs/helpers";
|
|
9
|
-
|
|
10
|
-
const root = container({
|
|
11
|
-
width: 1200,
|
|
12
|
-
height: 630,
|
|
13
|
-
children: [
|
|
14
|
-
text(
|
|
15
|
-
style({
|
|
16
|
-
font_size: 24,
|
|
17
|
-
font_weight: 700,
|
|
18
|
-
color: 0xffffff,
|
|
19
|
-
}),
|
|
20
|
-
"Hello, world!"
|
|
21
|
-
),
|
|
22
|
-
],
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// Fetch takumi server or with @takumi-rs/core
|
|
26
|
-
```
|
|
5
|
+
Checkout [documentation](http://localhost:5173/docs/deep-dives/from-jsx-helper) for usage.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var u=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var a=(e,r)=>{for(var t in r)u(e,t,{get:r[t],enumerable:!0})},x=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of p(r))!m.call(e,n)&&n!==t&&u(e,n,{get:()=>r[n],enumerable:!(o=i(r,n))||o.enumerable});return e};var f=e=>x(u({},"__esModule",{value:!0}),e);var v={};a(v,{container:()=>c,em:()=>C,fr:()=>P,image:()=>y,percentage:()=>g,rem:()=>s,rgba:()=>S,style:()=>b,text:()=>l,vh:()=>N,vw:()=>d});module.exports=f(v);function c(e){return{type:"container",...e}}function l(e,r){return{...r,type:"text",text:e}}function y(e,r){return{...r,type:"image",src:e}}function b(e){return e}function g(e){return{percentage:e}}function d(e){return{vw:e}}function N(e){return{vh:e}}function C(e){return{em:e}}function s(e){return{rem:e}}function P(e){return{fr:e}}function S(e,r,t,o=1){return[e,r,t,o]}0&&(module.exports={container,em,fr,image,percentage,rem,rgba,style,text,vh,vw});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { C as ContainerNode, P as PartialStyle, T as TextNode, I as ImageNode, S as Style, a as Color } from './types-C93nbSJX.cjs';
|
|
2
|
+
export { N as Node } from './types-C93nbSJX.cjs';
|
|
3
|
+
|
|
4
|
+
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
5
|
+
declare function text(text: string, style?: PartialStyle): TextNode;
|
|
6
|
+
declare function image(src: string, style?: PartialStyle): ImageNode;
|
|
7
|
+
declare function style(style: PartialStyle): Partial<Style>;
|
|
8
|
+
/**
|
|
9
|
+
* Convert a number to a percentage struct.
|
|
10
|
+
* @param percentage - The percentage to convert (0.0 - 100.0).
|
|
11
|
+
* @returns The percentage struct.
|
|
12
|
+
*/
|
|
13
|
+
declare function percentage(percentage: number): {
|
|
14
|
+
percentage: number;
|
|
15
|
+
};
|
|
16
|
+
declare function vw(vw: number): {
|
|
17
|
+
vw: number;
|
|
18
|
+
};
|
|
19
|
+
declare function vh(vh: number): {
|
|
20
|
+
vh: number;
|
|
21
|
+
};
|
|
22
|
+
declare function em(em: number): {
|
|
23
|
+
em: number;
|
|
24
|
+
};
|
|
25
|
+
declare function rem(rem: number): {
|
|
26
|
+
rem: number;
|
|
27
|
+
};
|
|
28
|
+
declare function fr(fr: number): {
|
|
29
|
+
fr: number;
|
|
30
|
+
};
|
|
31
|
+
declare function rgba(r: number, g: number, b: number, a?: number): Color;
|
|
32
|
+
|
|
33
|
+
export { ContainerNode, ImageNode, PartialStyle, TextNode, container, em, fr, image, percentage, rem, rgba, style, text, vh, vw };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,583 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import { C as ContainerNode, P as PartialStyle, T as TextNode, I as ImageNode, S as Style, a as Color } from './types-C93nbSJX.js';
|
|
2
|
+
export { N as Node } from './types-C93nbSJX.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* along the cross axis (perpendicular to the main axis).
|
|
8
|
-
*/
|
|
9
|
-
export type AlignItems = "start" | "end" | "flex-start" | "flex-end" | "center" | "baseline" | "stretch";
|
|
10
|
-
/**
|
|
11
|
-
* Represents a color in various formats with support for RGB, RGBA, and integer RGB values.
|
|
12
|
-
*
|
|
13
|
-
* The enum supports three color formats:
|
|
14
|
-
* - `Rgb`: RGB color with 8-bit components (r, g, b)
|
|
15
|
-
* - `Rgba`: RGBA color with 8-bit RGB components and 32-bit float alpha (r, g, b, a)
|
|
16
|
-
* - `RgbInt`: Single 32-bit integer containing RGB values
|
|
17
|
-
*/
|
|
18
|
-
export type Color = [
|
|
19
|
-
number,
|
|
20
|
-
number,
|
|
21
|
-
number
|
|
22
|
-
] | [
|
|
23
|
-
number,
|
|
24
|
-
number,
|
|
25
|
-
number,
|
|
26
|
-
number
|
|
27
|
-
] | number;
|
|
28
|
-
/**
|
|
29
|
-
* Represents a single color stop in a gradient.
|
|
30
|
-
*/
|
|
31
|
-
export type GradientStop = {
|
|
32
|
-
/**
|
|
33
|
-
* The color of the gradient stop
|
|
34
|
-
*/
|
|
35
|
-
color: Color;
|
|
36
|
-
/**
|
|
37
|
-
* Position in the range [0.0, 1.0]
|
|
38
|
-
*/
|
|
39
|
-
position: number;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Represents a gradient with color steps and an angle for directional gradients.
|
|
43
|
-
*/
|
|
44
|
-
export type Gradient = {
|
|
45
|
-
/**
|
|
46
|
-
* The color stops that make up the gradient
|
|
47
|
-
*/
|
|
48
|
-
stops: Array<GradientStop>;
|
|
49
|
-
/**
|
|
50
|
-
* The angle in degrees for the gradient direction (0-360)
|
|
51
|
-
*/
|
|
52
|
-
angle: number;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Represents a color input that can be either a color or a gradient.
|
|
56
|
-
*/
|
|
57
|
-
export type ColorInput = Color | Gradient;
|
|
58
|
-
/**
|
|
59
|
-
* Represents a value that can be a specific length, percentage, or automatic.
|
|
60
|
-
*
|
|
61
|
-
* This corresponds to CSS values that can be specified as pixels, percentages,
|
|
62
|
-
* or the 'auto' keyword for automatic sizing.
|
|
63
|
-
*/
|
|
64
|
-
export type LengthUnit = "auto" | "min-content" | "max-content" | {
|
|
65
|
-
"percentage": number;
|
|
66
|
-
} | {
|
|
67
|
-
"rem": number;
|
|
68
|
-
} | {
|
|
69
|
-
"em": number;
|
|
70
|
-
} | {
|
|
71
|
-
"vh": number;
|
|
72
|
-
} | {
|
|
73
|
-
"vw": number;
|
|
74
|
-
} | number;
|
|
75
|
-
/**
|
|
76
|
-
* Defines a box shadow for an element.
|
|
77
|
-
*
|
|
78
|
-
* This struct contains the properties for a box shadow, including color,
|
|
79
|
-
* offset, blur radius, spread radius, and inset flag.
|
|
80
|
-
*/
|
|
81
|
-
export type BoxShadow = {
|
|
82
|
-
/**
|
|
83
|
-
* Color of the box shadow
|
|
84
|
-
*/
|
|
85
|
-
color: ColorInput;
|
|
86
|
-
/**
|
|
87
|
-
* Horizontal offset of the box shadow
|
|
88
|
-
*/
|
|
89
|
-
offset_x: LengthUnit;
|
|
90
|
-
/**
|
|
91
|
-
* Vertical offset of the box shadow
|
|
92
|
-
*/
|
|
93
|
-
offset_y: LengthUnit;
|
|
94
|
-
/**
|
|
95
|
-
* Blur radius of the box shadow (must be non-negative)
|
|
96
|
-
*/
|
|
97
|
-
blur_radius: LengthUnit;
|
|
98
|
-
/**
|
|
99
|
-
* Spread radius of the box shadow (can be negative)
|
|
100
|
-
*/
|
|
101
|
-
spread_radius: LengthUnit;
|
|
102
|
-
/**
|
|
103
|
-
* Whether the shadow is inset (inside the element) or outset (outside the element)
|
|
104
|
-
*/
|
|
105
|
-
inset: boolean;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Defines a box shadow for an element.
|
|
109
|
-
*
|
|
110
|
-
* This enum allows for flexible specification of box shadows, including
|
|
111
|
-
* a single shadow or multiple shadows.
|
|
112
|
-
*/
|
|
113
|
-
export type BoxShadowInput = BoxShadow | Array<BoxShadow>;
|
|
114
|
-
/**
|
|
115
|
-
* This enum determines the layout algorithm used for the children of a node.
|
|
116
|
-
*/
|
|
117
|
-
export type Display = "flex" | "grid";
|
|
118
|
-
/**
|
|
119
|
-
* Defines the direction of flex items within a flex container.
|
|
120
|
-
*
|
|
121
|
-
* This enum determines how flex items are laid out along the main axis.
|
|
122
|
-
*/
|
|
123
|
-
export type FlexDirection = "row" | "column" | "row-reverse" | "column-reverse";
|
|
124
|
-
/**
|
|
125
|
-
* Defines how flex items should wrap.
|
|
126
|
-
*
|
|
127
|
-
* This enum determines how flex items should wrap within the flex container.
|
|
128
|
-
*/
|
|
129
|
-
export type FlexWrap = "nowrap" | "wrap" | "wrap-reverse";
|
|
130
|
-
/**
|
|
131
|
-
* Represents a font family for text rendering.
|
|
132
|
-
* Use only the family name (no style suffixes like "Bold", "Italic", "Regular").
|
|
133
|
-
* Multi-word names are allowed (e.g., "Noto Sans") and should be provided as-is without quotes.
|
|
134
|
-
*/
|
|
135
|
-
export type FontFamily = "sans-serif" | "serif" | "monospace" | "cursive" | "fantasy" | string;
|
|
136
|
-
/**
|
|
137
|
-
* Represents font weight as a numeric value.
|
|
138
|
-
*
|
|
139
|
-
* This wraps a u16 value that corresponds to CSS font-weight values.
|
|
140
|
-
* Common values include 100 (thin), 200 (extra light), 300 (light),
|
|
141
|
-
* 400 (normal), 500 (medium), 600 (semi bold), 700 (bold),
|
|
142
|
-
* 800 (extra bold), 900 (black).
|
|
143
|
-
*/
|
|
144
|
-
export type FontWeight = number;
|
|
145
|
-
/**
|
|
146
|
-
* Represents spacing between flex items.
|
|
147
|
-
*
|
|
148
|
-
* Can be either a single value applied to both axes, or separate values
|
|
149
|
-
* for horizontal and vertical spacing.
|
|
150
|
-
*/
|
|
151
|
-
export type Gap = LengthUnit | [
|
|
152
|
-
LengthUnit,
|
|
153
|
-
LengthUnit
|
|
154
|
-
];
|
|
155
|
-
/**
|
|
156
|
-
* Represents the grid auto flow with serde support
|
|
157
|
-
*/
|
|
158
|
-
export type GridAutoFlow = "row" | "column" | "row-dense" | "column-dense";
|
|
159
|
-
/**
|
|
160
|
-
* Represents a grid placement with serde support
|
|
161
|
-
*/
|
|
162
|
-
export type GridPlacement = "auto" | {
|
|
163
|
-
"span": number;
|
|
164
|
-
} | number | string;
|
|
165
|
-
/**
|
|
166
|
-
* Represents a grid line placement with serde support
|
|
167
|
-
*/
|
|
168
|
-
export type GridLine = {
|
|
169
|
-
/**
|
|
170
|
-
* The start line placement
|
|
171
|
-
*/
|
|
172
|
-
start: GridPlacement | null;
|
|
173
|
-
/**
|
|
174
|
-
* The end line placement
|
|
175
|
-
*/
|
|
176
|
-
end: GridPlacement | null;
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* Represents a grid track sizing function with serde support
|
|
180
|
-
*/
|
|
181
|
-
export type GridTrackSize = {
|
|
182
|
-
"fr": number;
|
|
183
|
-
} | LengthUnit;
|
|
184
|
-
/**
|
|
185
|
-
* Defines how images should be scaled when rendered.
|
|
186
|
-
*/
|
|
187
|
-
export type ImageScalingAlgorithm = "auto" | "smooth" | "pixelated";
|
|
188
|
-
/**
|
|
189
|
-
* Defines how flex items are aligned along the main axis.
|
|
190
|
-
*
|
|
191
|
-
* This enum determines how space is distributed between and around flex items
|
|
192
|
-
* along the main axis of the flex container.
|
|
193
|
-
*/
|
|
194
|
-
export type JustifyContent = "start" | "end" | "flex-start" | "flex-end" | "center" | "stretch" | "space-between" | "space-evenly" | "space-around";
|
|
195
|
-
/**
|
|
196
|
-
* Defines how an image should be resized to fit its container.
|
|
197
|
-
*
|
|
198
|
-
* Similar to CSS object-fit property.
|
|
199
|
-
*/
|
|
200
|
-
export type ObjectFit = "fill" | "contain" | "cover" | "scale-down" | "none";
|
|
201
|
-
/**
|
|
202
|
-
* Defines the positioning method for an element.
|
|
203
|
-
*
|
|
204
|
-
* This enum determines how an element is positioned within its containing element.
|
|
205
|
-
*/
|
|
206
|
-
type Position$1 = "relative" | "absolute";
|
|
207
|
-
/**
|
|
208
|
-
* Represents values that can be applied to all sides of an element.
|
|
209
|
-
*
|
|
210
|
-
* This enum allows for flexible specification of values like padding, margin,
|
|
211
|
-
* or border sizes using either a single value for all sides, separate values
|
|
212
|
-
* for vertical/horizontal axes, or individual values for each side.
|
|
213
|
-
*/
|
|
214
|
-
export type SidesValue<T> = T | [
|
|
215
|
-
T,
|
|
216
|
-
T
|
|
217
|
-
] | [
|
|
218
|
-
T,
|
|
219
|
-
T,
|
|
220
|
-
T,
|
|
221
|
-
T
|
|
222
|
-
];
|
|
223
|
-
/**
|
|
224
|
-
* Text alignment options for text rendering.
|
|
225
|
-
*
|
|
226
|
-
* Corresponds to CSS text-align property values.
|
|
227
|
-
*/
|
|
228
|
-
export type TextAlign = "left" | "right" | "center" | "justify" | "start" | "end";
|
|
229
|
-
/**
|
|
230
|
-
* Defines how text should be overflowed.
|
|
231
|
-
*
|
|
232
|
-
* This enum determines how text should be handled when it exceeds the container width.
|
|
233
|
-
*/
|
|
234
|
-
export type TextOverflow = "ellipsis" | "clip";
|
|
235
|
-
/**
|
|
236
|
-
* Represents a grid track repetition pattern
|
|
237
|
-
*/
|
|
238
|
-
export type GridTrackRepetition = "auto-fill" | "auto-fit" | number;
|
|
239
|
-
/**
|
|
240
|
-
* Represents a track sizing function
|
|
241
|
-
*/
|
|
242
|
-
export type TrackSizingFunction = {
|
|
243
|
-
"single": GridTrackSize;
|
|
244
|
-
} | {
|
|
245
|
-
"repeat": [
|
|
246
|
-
GridTrackRepetition,
|
|
247
|
-
Array<GridTrackSize>
|
|
248
|
-
];
|
|
249
|
-
};
|
|
250
|
-
/**
|
|
251
|
-
* Main styling structure that contains all layout and visual properties.
|
|
252
|
-
*
|
|
253
|
-
* This structure combines both layout properties (like width, height, padding)
|
|
254
|
-
* and inheritable properties (like font settings, colors) that can be passed
|
|
255
|
-
* down to child elements.
|
|
256
|
-
*/
|
|
257
|
-
export type Style = {
|
|
258
|
-
/**
|
|
259
|
-
* Display algorithm to use for the element
|
|
260
|
-
*/
|
|
261
|
-
display: Display;
|
|
262
|
-
/**
|
|
263
|
-
* Width of the element
|
|
264
|
-
*/
|
|
265
|
-
width: LengthUnit;
|
|
266
|
-
/**
|
|
267
|
-
* Height of the element
|
|
268
|
-
*/
|
|
269
|
-
height: LengthUnit;
|
|
270
|
-
/**
|
|
271
|
-
* Max width of the element
|
|
272
|
-
*/
|
|
273
|
-
max_width: LengthUnit;
|
|
274
|
-
/**
|
|
275
|
-
* Max height of the element
|
|
276
|
-
*/
|
|
277
|
-
max_height: LengthUnit;
|
|
278
|
-
/**
|
|
279
|
-
* Min width of the element
|
|
280
|
-
*/
|
|
281
|
-
min_width: LengthUnit;
|
|
282
|
-
/**
|
|
283
|
-
* Min height of the element
|
|
284
|
-
*/
|
|
285
|
-
min_height: LengthUnit;
|
|
286
|
-
/**
|
|
287
|
-
* Aspect ratio of the element (width/height)
|
|
288
|
-
*/
|
|
289
|
-
aspect_ratio?: number;
|
|
290
|
-
/**
|
|
291
|
-
* Internal spacing around the element's content (top, right, bottom, left)
|
|
292
|
-
*/
|
|
293
|
-
padding: SidesValue<LengthUnit>;
|
|
294
|
-
/**
|
|
295
|
-
* External spacing around the element (top, right, bottom, left)
|
|
296
|
-
*/
|
|
297
|
-
margin: SidesValue<LengthUnit>;
|
|
298
|
-
/**
|
|
299
|
-
* Positioning offsets (top, right, bottom, left) from the element's normal position
|
|
300
|
-
*/
|
|
301
|
-
inset: SidesValue<LengthUnit>;
|
|
302
|
-
/**
|
|
303
|
-
* Direction of flex layout (row or column)
|
|
304
|
-
*/
|
|
305
|
-
flex_direction: FlexDirection;
|
|
306
|
-
/**
|
|
307
|
-
* How a single grid item is aligned along the inline (row) axis, overriding the container's justify-items value
|
|
308
|
-
*/
|
|
309
|
-
justify_self?: AlignItems;
|
|
310
|
-
/**
|
|
311
|
-
* How items are aligned along the main axis
|
|
312
|
-
*/
|
|
313
|
-
justify_content?: JustifyContent;
|
|
314
|
-
/**
|
|
315
|
-
* How lines are aligned within the flex container when there's extra space in the cross axis
|
|
316
|
-
*/
|
|
317
|
-
align_content?: JustifyContent;
|
|
318
|
-
/**
|
|
319
|
-
* How grid items are aligned along the inline (row) axis within their grid areas
|
|
320
|
-
*/
|
|
321
|
-
justify_items?: AlignItems;
|
|
322
|
-
/**
|
|
323
|
-
* How items are aligned along the cross axis
|
|
324
|
-
*/
|
|
325
|
-
align_items?: AlignItems;
|
|
326
|
-
/**
|
|
327
|
-
* How a single item is aligned along the cross axis, overriding the container's align-items value
|
|
328
|
-
*/
|
|
329
|
-
align_self?: AlignItems;
|
|
330
|
-
/**
|
|
331
|
-
* How flex items should wrap
|
|
332
|
-
*/
|
|
333
|
-
flex_wrap: FlexWrap;
|
|
334
|
-
/**
|
|
335
|
-
* The initial main size of the flex item before growing or shrinking
|
|
336
|
-
*/
|
|
337
|
-
flex_basis: LengthUnit;
|
|
338
|
-
/**
|
|
339
|
-
* Positioning method (relative, absolute, etc.)
|
|
340
|
-
*/
|
|
341
|
-
position: Position$1;
|
|
342
|
-
/**
|
|
343
|
-
* Spacing between rows and columns in flex or grid layouts
|
|
344
|
-
*/
|
|
345
|
-
gap: Gap;
|
|
346
|
-
/**
|
|
347
|
-
* How much the flex item should grow relative to other flex items when positive free space is distributed
|
|
348
|
-
*/
|
|
349
|
-
flex_grow: number;
|
|
350
|
-
/**
|
|
351
|
-
* How much the flex item should shrink relative to other flex items when negative free space is distributed
|
|
352
|
-
*/
|
|
353
|
-
flex_shrink: number;
|
|
354
|
-
/**
|
|
355
|
-
* Width of the element's border on each side (top, right, bottom, left)
|
|
356
|
-
*/
|
|
357
|
-
border_width: SidesValue<LengthUnit>;
|
|
358
|
-
/**
|
|
359
|
-
* How images should be fitted within their container
|
|
360
|
-
*/
|
|
361
|
-
object_fit: ObjectFit;
|
|
362
|
-
/**
|
|
363
|
-
* Background gradient(s)
|
|
364
|
-
*/
|
|
365
|
-
background_image?: Gradient;
|
|
366
|
-
/**
|
|
367
|
-
* Background color for the element
|
|
368
|
-
*/
|
|
369
|
-
background_color?: Color;
|
|
370
|
-
/**
|
|
371
|
-
* Box shadow effect for the element
|
|
372
|
-
*/
|
|
373
|
-
box_shadow?: BoxShadowInput;
|
|
374
|
-
/**
|
|
375
|
-
* Controls the size of implicitly-created grid columns
|
|
376
|
-
*/
|
|
377
|
-
grid_auto_columns?: Array<GridTrackSize>;
|
|
378
|
-
/**
|
|
379
|
-
* Controls the size of implicitly-created grid rows
|
|
380
|
-
*/
|
|
381
|
-
grid_auto_rows?: Array<GridTrackSize>;
|
|
382
|
-
/**
|
|
383
|
-
* Controls how auto-placed items are inserted in the grid
|
|
384
|
-
*/
|
|
385
|
-
grid_auto_flow?: GridAutoFlow;
|
|
386
|
-
/**
|
|
387
|
-
* Specifies a grid item's size and location within the grid column
|
|
388
|
-
*/
|
|
389
|
-
grid_column?: GridLine;
|
|
390
|
-
/**
|
|
391
|
-
* Specifies a grid item's size and location within the grid row
|
|
392
|
-
*/
|
|
393
|
-
grid_row?: GridLine;
|
|
394
|
-
/**
|
|
395
|
-
* Defines the line names and track sizing functions of the grid columns
|
|
396
|
-
*/
|
|
397
|
-
grid_template_columns?: Array<TrackSizingFunction>;
|
|
398
|
-
/**
|
|
399
|
-
* Defines the line names and track sizing functions of the grid rows
|
|
400
|
-
*/
|
|
401
|
-
grid_template_rows?: Array<TrackSizingFunction>;
|
|
402
|
-
/**
|
|
403
|
-
* How text should be overflowed
|
|
404
|
-
*/
|
|
405
|
-
text_overflow?: TextOverflow;
|
|
406
|
-
/**
|
|
407
|
-
* Color of the element's border
|
|
408
|
-
*/
|
|
409
|
-
border_color?: ColorInput;
|
|
410
|
-
/**
|
|
411
|
-
* Text color for child text elements
|
|
412
|
-
*/
|
|
413
|
-
color?: ColorInput;
|
|
414
|
-
/**
|
|
415
|
-
* Font size in pixels for text rendering
|
|
416
|
-
*/
|
|
417
|
-
font_size?: LengthUnit;
|
|
418
|
-
/**
|
|
419
|
-
* Font family name for text rendering
|
|
420
|
-
*/
|
|
421
|
-
font_family?: FontFamily;
|
|
422
|
-
/**
|
|
423
|
-
* Line height multiplier for text spacing
|
|
424
|
-
*/
|
|
425
|
-
line_height?: LengthUnit;
|
|
426
|
-
/**
|
|
427
|
-
* Font weight for text rendering
|
|
428
|
-
*/
|
|
429
|
-
font_weight?: FontWeight;
|
|
430
|
-
/**
|
|
431
|
-
* Maximum number of lines for text before truncation
|
|
432
|
-
*/
|
|
433
|
-
line_clamp?: number;
|
|
434
|
-
/**
|
|
435
|
-
* Corner radius for rounded borders
|
|
436
|
-
*/
|
|
437
|
-
border_radius?: SidesValue<LengthUnit>;
|
|
438
|
-
/**
|
|
439
|
-
* Text alignment within the element
|
|
440
|
-
*/
|
|
441
|
-
text_align?: TextAlign;
|
|
442
|
-
/**
|
|
443
|
-
* Additional spacing between characters in text
|
|
444
|
-
* Positive values increase spacing, negative values decrease spacing
|
|
445
|
-
*/
|
|
446
|
-
letter_spacing?: LengthUnit;
|
|
447
|
-
/**
|
|
448
|
-
* Controls how images are scaled when rendered
|
|
449
|
-
* This property determines the algorithm used for image scaling
|
|
450
|
-
*/
|
|
451
|
-
image_rendering?: ImageScalingAlgorithm;
|
|
452
|
-
};
|
|
453
|
-
/**
|
|
454
|
-
* Style properties that can be inherited by child elements.
|
|
455
|
-
*
|
|
456
|
-
* These properties are typically passed down from parent to child elements
|
|
457
|
-
* in the layout hierarchy, such as font settings and colors.
|
|
458
|
-
*/
|
|
459
|
-
export type InheritableStyle = {
|
|
460
|
-
/**
|
|
461
|
-
* How text should be overflowed
|
|
462
|
-
*/
|
|
463
|
-
text_overflow?: TextOverflow;
|
|
464
|
-
/**
|
|
465
|
-
* Color of the element's border
|
|
466
|
-
*/
|
|
467
|
-
border_color?: ColorInput;
|
|
468
|
-
/**
|
|
469
|
-
* Text color for child text elements
|
|
470
|
-
*/
|
|
471
|
-
color?: ColorInput;
|
|
472
|
-
/**
|
|
473
|
-
* Font size in pixels for text rendering
|
|
474
|
-
*/
|
|
475
|
-
font_size?: LengthUnit;
|
|
476
|
-
/**
|
|
477
|
-
* Font family name for text rendering
|
|
478
|
-
*/
|
|
479
|
-
font_family?: FontFamily;
|
|
480
|
-
/**
|
|
481
|
-
* Line height multiplier for text spacing
|
|
482
|
-
*/
|
|
483
|
-
line_height?: LengthUnit;
|
|
484
|
-
/**
|
|
485
|
-
* Font weight for text rendering
|
|
486
|
-
*/
|
|
487
|
-
font_weight?: FontWeight;
|
|
488
|
-
/**
|
|
489
|
-
* Maximum number of lines for text before truncation
|
|
490
|
-
*/
|
|
491
|
-
line_clamp?: number;
|
|
492
|
-
/**
|
|
493
|
-
* Corner radius for rounded borders
|
|
494
|
-
*/
|
|
495
|
-
border_radius?: SidesValue<LengthUnit>;
|
|
496
|
-
/**
|
|
497
|
-
* Text alignment within the element
|
|
498
|
-
*/
|
|
499
|
-
text_align?: TextAlign;
|
|
500
|
-
/**
|
|
501
|
-
* Additional spacing between characters in text
|
|
502
|
-
* Positive values increase spacing, negative values decrease spacing
|
|
503
|
-
*/
|
|
504
|
-
letter_spacing?: LengthUnit;
|
|
505
|
-
/**
|
|
506
|
-
* Controls how images are scaled when rendered
|
|
507
|
-
* This property determines the algorithm used for image scaling
|
|
508
|
-
*/
|
|
509
|
-
image_rendering?: ImageScalingAlgorithm;
|
|
510
|
-
};
|
|
511
|
-
/**
|
|
512
|
-
* Represents a value that can be a specific length, percentage, or automatic.
|
|
513
|
-
*
|
|
514
|
-
* This corresponds to CSS values that can be specified as pixels, percentages,
|
|
515
|
-
* or the 'auto' keyword for automatic sizing.
|
|
516
|
-
*/
|
|
517
|
-
export type ValuePercentageAuto = "auto" | {
|
|
518
|
-
"percentage": number;
|
|
519
|
-
} | number;
|
|
520
|
-
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
521
|
-
[key: string]: JsonValue;
|
|
522
|
-
};
|
|
523
|
-
export type AnyNode = {
|
|
524
|
-
type: string;
|
|
525
|
-
[key: string]: JsonValue;
|
|
526
|
-
};
|
|
527
|
-
export type PartialStyle = Partial<Style>;
|
|
528
|
-
export type JsxParsedStyle = {
|
|
529
|
-
[key in keyof Style]: Style[key] | undefined;
|
|
530
|
-
};
|
|
531
|
-
type Node$1 = ContainerNode | TextNode | ImageNode | AnyNode;
|
|
532
|
-
export type ContainerNode = PartialStyle & {
|
|
533
|
-
type: "container";
|
|
534
|
-
children?: Node$1[];
|
|
535
|
-
};
|
|
536
|
-
export type TextNode = PartialStyle & {
|
|
537
|
-
type: "text";
|
|
538
|
-
text: string;
|
|
539
|
-
};
|
|
540
|
-
export type ImageNode = PartialStyle & {
|
|
541
|
-
type: "image";
|
|
542
|
-
src: string;
|
|
543
|
-
};
|
|
544
|
-
export declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
545
|
-
export declare function text(text: string, style?: PartialStyle): TextNode;
|
|
546
|
-
export declare function image(src: string, style?: PartialStyle): ImageNode;
|
|
547
|
-
export declare function style(style: PartialStyle): Partial<Style>;
|
|
4
|
+
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
5
|
+
declare function text(text: string, style?: PartialStyle): TextNode;
|
|
6
|
+
declare function image(src: string, style?: PartialStyle): ImageNode;
|
|
7
|
+
declare function style(style: PartialStyle): Partial<Style>;
|
|
548
8
|
/**
|
|
549
9
|
* Convert a number to a percentage struct.
|
|
550
10
|
* @param percentage - The percentage to convert (0.0 - 100.0).
|
|
551
11
|
* @returns The percentage struct.
|
|
552
12
|
*/
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
};
|
|
556
|
-
export declare function vw(vw: number): {
|
|
557
|
-
vw: number;
|
|
13
|
+
declare function percentage(percentage: number): {
|
|
14
|
+
percentage: number;
|
|
558
15
|
};
|
|
559
|
-
|
|
560
|
-
|
|
16
|
+
declare function vw(vw: number): {
|
|
17
|
+
vw: number;
|
|
561
18
|
};
|
|
562
|
-
|
|
563
|
-
|
|
19
|
+
declare function vh(vh: number): {
|
|
20
|
+
vh: number;
|
|
564
21
|
};
|
|
565
|
-
|
|
566
|
-
|
|
22
|
+
declare function em(em: number): {
|
|
23
|
+
em: number;
|
|
567
24
|
};
|
|
568
|
-
|
|
569
|
-
|
|
25
|
+
declare function rem(rem: number): {
|
|
26
|
+
rem: number;
|
|
570
27
|
};
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
to: ColorInput;
|
|
574
|
-
angle: number;
|
|
575
|
-
};
|
|
576
|
-
export declare function rgba(r: number, g: number, b: number, a?: number): Color;
|
|
577
|
-
|
|
578
|
-
export {
|
|
579
|
-
Node$1 as Node,
|
|
580
|
-
Position$1 as Position,
|
|
28
|
+
declare function fr(fr: number): {
|
|
29
|
+
fr: number;
|
|
581
30
|
};
|
|
31
|
+
declare function rgba(r: number, g: number, b: number, a?: number): Color;
|
|
582
32
|
|
|
583
|
-
export {};
|
|
33
|
+
export { ContainerNode, ImageNode, PartialStyle, TextNode, container, em, fr, image, percentage, rem, rgba, style, text, vh, vw };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function o(e){return{type:"container",...e}}function u(e,r){return{...r,type:"text",text:e}}function i(e,r){return{...r,type:"image",src:e}}function p(e){return e}function m(e){return{percentage:e}}function a(e){return{vw:e}}function x(e){return{vh:e}}function f(e){return{em:e}}function c(e){return{rem:e}}function l(e){return{fr:e}}function y(e,r,t,n=1){return[e,r,t,n]}export{o as container,f as em,l as fr,i as image,m as percentage,c as rem,y as rgba,p as style,u as text,x as vh,a as vw};
|
package/dist/jsx/jsx.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var p=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var b=(t,r)=>{for(var e in r)p(t,e,{get:r[e],enumerable:!0})},x=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of S(r))!P.call(t,i)&&i!==e&&p(t,i,{get:()=>r[i],enumerable:!(n=h(r,i))||n.enumerable});return t};var E=t=>x(p({},"__esModule",{value:!0}),t);var W={};b(W,{fromJsx:()=>a});module.exports=E(W);var g=require("react"),d=require("react-dom/server");function c(t){return{type:"container",...t}}function f(t,r){return{...r,type:"text",text:t}}function s(t,r){return{...r,type:"image",src:t}}function o(t){return{em:t}}function u(t,r,e,n=1){return[t,r,e,n]}var m={p:{margin:[o(1),0]},blockquote:{margin:[o(1),40]},center:{textAlign:"center"},hr:{margin:[o(.5),"auto"],borderWidth:1},h1:{fontSize:o(2),margin:[o(.67),0],fontWeight:700},h2:{fontSize:o(1.5),margin:[o(.83),0],fontWeight:700},h3:{fontSize:o(1.17),margin:[o(1),0],fontWeight:700},h4:{margin:[o(1.33),0],fontWeight:700},h5:{fontSize:o(.83),margin:[o(1.67),0],fontWeight:700},h6:{fontSize:o(.67),margin:[o(2.33),0],fontWeight:700},strong:{fontWeight:700},b:{fontWeight:700},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{fontFamily:"monospace",margin:[o(1),0]},mark:{backgroundColor:u(255,255,0),color:0},big:{fontSize:o(1.2)},small:{fontSize:o(1/1.2)}};var w=Symbol.for("react.transitional.element");function N(t){return typeof t=="object"&&t!==null&&"$$typeof"in t&&t.$$typeof===w}async function a(t){if(t==null)return[];if(t instanceof Promise)return a(await t);if(typeof t=="object"&&Symbol.iterator in t)return T(t);if(N(t)){let r=await C(t);return Array.isArray(r)?r:r?[r]:[]}return[f(String(t))]}async function C(t){if(typeof t.type=="function"){let n=t.type;return a(n(t.props))}if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await l(t)||[];if(y(t,"img"))return R(t);if(y(t,"svg"))return[k(t)];let r=await l(t),e=I(t.props);return[c({children:r,...m[t.type],...e})]}function R(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let r=t.props.style?.width??t.props.width,e=t.props.style?.height??t.props.height;return[s(t.props.src,{...t.props.style,width:r,height:e})]}function k(t){return s((0,d.renderToStaticMarkup)((0,g.cloneElement)(t,{xmlns:"http://www.w3.org/2000/svg",...t.props},t.props.children)))}function I(t){return typeof t=="object"&&t&&"style"in t?t.style:void 0}function y(t,r){return t.type===r}async function l(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?[]:await a(t.props.children)}async function T(t){return(await Promise.all(Array.from(t).map(a))).flat()}0&&(module.exports={fromJsx});
|