@takumi-rs/helpers 0.26.2 → 0.27.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ContainerNode, P as PartialStyle, T as TextNode, I as ImageNode, S as Style, a as Color } from './types-kk-nArin.cjs';
2
- export { A as AnyNode, J as JsonValue, N as Node } from './types-kk-nArin.cjs';
1
+ import { C as ContainerNode, P as PartialStyle, T as TextNode, I as ImageNode, S as Style, a as Color } from './types-CHKaewqR.cjs';
2
+ export { A as AnyNode, J as JsonValue, N as Node } from './types-CHKaewqR.cjs';
3
3
 
4
4
  declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
5
5
  declare function text(text: string, style?: PartialStyle): TextNode;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ContainerNode, P as PartialStyle, T as TextNode, I as ImageNode, S as Style, a as Color } from './types-kk-nArin.js';
2
- export { A as AnyNode, J as JsonValue, N as Node } from './types-kk-nArin.js';
1
+ import { C as ContainerNode, P as PartialStyle, T as TextNode, I as ImageNode, S as Style, a as Color } from './types-CHKaewqR.js';
2
+ export { A as AnyNode, J as JsonValue, N as Node } from './types-CHKaewqR.js';
3
3
 
4
4
  declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
5
5
  declare function text(text: string, style?: PartialStyle): TextNode;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { N as Node } from '../types-kk-nArin.cjs';
2
+ import { N as Node } from '../types-CHKaewqR.cjs';
3
3
 
4
4
  declare function fromJsx(element: ReactNode): Promise<Node>;
5
5
 
package/dist/jsx/jsx.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { N as Node } from '../types-kk-nArin.js';
2
+ import { N as Node } from '../types-CHKaewqR.js';
3
3
 
4
4
  declare function fromJsx(element: ReactNode): Promise<Node>;
5
5
 
@@ -6,6 +6,11 @@
6
6
  */
7
7
  type AlignItems = "start" | "end" | "flex-start" | "flex-end" | "center" | "baseline" | "stretch";
8
8
 
9
+ /**
10
+ * Represents an angle value in degrees.
11
+ */
12
+ type Angle = number;
13
+
9
14
  /**
10
15
  * Represents a color with 8-bit RGBA components.
11
16
  */
@@ -29,6 +34,167 @@ type LengthUnit = "auto" | {
29
34
  "vw": number;
30
35
  } | number | string;
31
36
 
37
+ /**
38
+ * Represents a gradient stop position.
39
+ * If a percentage or number (0.0-1.0) is provided, it is treated as a percentage.
40
+ */
41
+ type StopPosition = LengthUnit | string;
42
+
43
+ /**
44
+ * Represents a gradient stop.
45
+ */
46
+ type GradientStop = {
47
+ /**
48
+ * The color of the gradient stop.
49
+ */
50
+ color: Color;
51
+ /**
52
+ * The position of the gradient stop.
53
+ */
54
+ hint: StopPosition | null;
55
+ } | StopPosition;
56
+
57
+ /**
58
+ * Represents a linear gradient.
59
+ */
60
+ type LinearGradient = {
61
+ /**
62
+ * The angle of the gradient.
63
+ */
64
+ angle: Angle;
65
+ /**
66
+ * The steps of the gradient.
67
+ */
68
+ stops: Array<GradientStop>;
69
+ } | string;
70
+
71
+ /**
72
+ * Supported shapes for radial gradients
73
+ */
74
+ type RadialShape = "circle" | "ellipse";
75
+
76
+ /**
77
+ * Supported size keywords for radial gradients
78
+ */
79
+ type RadialSize = "closest-side" | "farthest-side" | "closest-corner" | "farthest-corner";
80
+
81
+ /**
82
+ * Represents a radial gradient.
83
+ */
84
+ type RadialGradient = {
85
+ /**
86
+ * The radial gradient shape
87
+ */
88
+ shape: RadialShape;
89
+ /**
90
+ * The sizing mode for the gradient
91
+ */
92
+ size: RadialSize;
93
+ /**
94
+ * Center position in normalized coordinates [0.0, 1.0]
95
+ */
96
+ center: [number, number];
97
+ /**
98
+ * Gradient stops
99
+ */
100
+ stops: Array<GradientStop>;
101
+ };
102
+
103
+ /**
104
+ * Background image variants supported by Takumi.
105
+ */
106
+ type BackgroundImage = LinearGradient | RadialGradient;
107
+
108
+ /**
109
+ * A collection of background images.
110
+ */
111
+ type BackgroundImages = Array<BackgroundImage> | string;
112
+
113
+ /**
114
+ * Horizontal keywords for `background-position`.
115
+ */
116
+ type PositionKeywordX = "left" | "center" | "right";
117
+
118
+ /**
119
+ * Vertical keywords for `background-position`.
120
+ */
121
+ type PositionKeywordY = "top" | "center" | "bottom";
122
+
123
+ /**
124
+ * A single `background-position` component for an axis.
125
+ */
126
+ type PositionComponent = {
127
+ "keyword-x": PositionKeywordX;
128
+ } | {
129
+ "keyword-y": PositionKeywordY;
130
+ } | {
131
+ "length": LengthUnit;
132
+ };
133
+
134
+ /**
135
+ * Parsed `background-position` value for one layer.
136
+ */
137
+ type BackgroundPosition = {
138
+ /**
139
+ * X-axis position component.
140
+ */
141
+ x: PositionComponent;
142
+ /**
143
+ * Y-axis position component.
144
+ */
145
+ y: PositionComponent;
146
+ };
147
+
148
+ /**
149
+ * A list of `background-position` values (one per layer).
150
+ */
151
+ type BackgroundPositions = Array<BackgroundPosition> | string;
152
+
153
+ /**
154
+ * Per-axis repeat style.
155
+ */
156
+ type BackgroundRepeatStyle = "repeat" | "no-repeat" | "space" | "round";
157
+
158
+ /**
159
+ * Combined repeat for X and Y axes.
160
+ */
161
+ type BackgroundRepeat = {
162
+ /**
163
+ * Repeat style along the X axis.
164
+ */
165
+ x: BackgroundRepeatStyle;
166
+ /**
167
+ * Repeat style along the Y axis.
168
+ */
169
+ y: BackgroundRepeatStyle;
170
+ };
171
+
172
+ /**
173
+ * A list of background-repeat values (layered).
174
+ */
175
+ type BackgroundRepeats = Array<BackgroundRepeat> | string;
176
+
177
+ /**
178
+ * Parsed `background-size` for one layer.
179
+ */
180
+ type BackgroundSize = "Cover" | "Contain" | {
181
+ "Explicit": {
182
+ /**
183
+ * Width value for the background image.
184
+ */
185
+ width: LengthUnit;
186
+ /**
187
+ * Height value for the background image.
188
+ */
189
+ height: LengthUnit;
190
+ };
191
+ };
192
+
193
+ /**
194
+ * A list of `background-size` values (one per layer).
195
+ */
196
+ type BackgroundSizes = Array<BackgroundSize> | string;
197
+
32
198
  /**
33
199
  * Represents a box shadow with all its properties.
34
200
  *
@@ -210,6 +376,19 @@ type GridRepetitionCount = "auto-fill" | "auto-fit" | number;
210
376
  */
211
377
  type GridTemplateComponent = Array<string> | GridTrackSize | [GridRepetitionCount, Array<GridRepeatTrack>];
212
378
 
379
+ /**
380
+ * A transparent wrapper around a list of `GridTemplateComponent`.
381
+ *
382
+ * This exists to provide a distinct type for template component lists while
383
+ * preserving JSON compatibility (serialized as a plain array) and clean TS types.
384
+ */
385
+ type GridTemplateComponents = Array<GridTemplateComponent> | string;
386
+
387
+ /**
388
+ * A wrapper around a list of `GridTrackSize` that can also be parsed from a CSS string.
389
+ */
390
+ type GridTrackSizes = Array<GridTrackSize> | string;
391
+
213
392
  /**
214
393
  * Defines how images should be scaled when rendered.
215
394
  */
@@ -228,49 +407,11 @@ type JustifyContent = "start" | "end" | "flex-start" | "flex-end" | "center" | "
228
407
  */
229
408
  type LineHeight = number | string | LengthUnit;
230
409
 
231
- /**
232
- * Represents an angle value in degrees.
233
- */
234
- type Angle = number;
235
-
236
- /**
237
- * Represents a gradient stop.
238
- */
239
- type GradientStop = {
240
- /**
241
- * The color of the gradient stop.
242
- */
243
- color: Color;
244
- /**
245
- * The position of the gradient stop (0% to 100%).
246
- */
247
- hint: number | null;
248
- } | number;
249
-
250
- /**
251
- * Represents a linear gradient.
252
- */
253
- type LinearGradient = {
254
- /**
255
- * The angle of the gradient.
256
- */
257
- angle: Angle;
258
- /**
259
- * The steps of the gradient.
260
- */
261
- stops: Array<GradientStop>;
262
- } | string;
263
-
264
410
  /**
265
411
  * Represents either a linear gradient or a solid color.
266
412
  */
267
413
  type LinearGradientOrColor = LinearGradient | Color;
268
414
 
269
- /**
270
- * A collection of linear gradients.
271
- */
272
- type LinearGradients = Array<LinearGradient> | string;
273
-
274
415
  /**
275
416
  * Defines how an image should be resized to fit its container.
276
417
  *
@@ -469,27 +610,39 @@ type Style = {
469
610
  /**
470
611
  * Longhand: top border width. Overrides `border_width` top value.
471
612
  */
472
- borderWidthTop?: LengthUnit;
613
+ borderTopWidth?: LengthUnit;
473
614
  /**
474
615
  * Longhand: right border width. Overrides `border_width` right value.
475
616
  */
476
- borderWidthRight?: LengthUnit;
617
+ borderRightWidth?: LengthUnit;
477
618
  /**
478
619
  * Longhand: bottom border width. Overrides `border_width` bottom value.
479
620
  */
480
- borderWidthBottom?: LengthUnit;
621
+ borderBottomWidth?: LengthUnit;
481
622
  /**
482
623
  * Longhand: left border width. Overrides `border_width` left value.
483
624
  */
484
- borderWidthLeft?: LengthUnit;
625
+ borderLeftWidth?: LengthUnit;
485
626
  /**
486
627
  * How images should be fitted within their container.
487
628
  */
488
629
  objectFit: ObjectFit;
489
630
  /**
490
- * Background gradient(s).
631
+ * Background image(s): linear or radial gradients.
632
+ */
633
+ backgroundImage?: BackgroundImages;
634
+ /**
635
+ * Background positions per layer.
636
+ */
637
+ backgroundPosition?: BackgroundPositions;
638
+ /**
639
+ * Background sizes per layer.
640
+ */
641
+ backgroundSize?: BackgroundSizes;
642
+ /**
643
+ * Background repeat per layer.
491
644
  */
492
- backgroundImage?: LinearGradients;
645
+ backgroundRepeat?: BackgroundRepeats;
493
646
  /**
494
647
  * Background color for the element.
495
648
  */
@@ -501,11 +654,11 @@ type Style = {
501
654
  /**
502
655
  * Controls the size of implicitly-created grid columns.
503
656
  */
504
- gridAutoColumns?: Array<GridTrackSize>;
657
+ gridAutoColumns?: GridTrackSizes;
505
658
  /**
506
659
  * Controls the size of implicitly-created grid rows.
507
660
  */
508
- gridAutoRows?: Array<GridTrackSize>;
661
+ gridAutoRows?: GridTrackSizes;
509
662
  /**
510
663
  * Controls how auto-placed items are inserted in the grid.
511
664
  */
@@ -521,11 +674,11 @@ type Style = {
521
674
  /**
522
675
  * Defines the line names and track sizing functions of the grid columns.
523
676
  */
524
- gridTemplateColumns?: Array<GridTemplateComponent>;
677
+ gridTemplateColumns?: GridTemplateComponents;
525
678
  /**
526
679
  * Defines the line names and track sizing functions of the grid rows.
527
680
  */
528
- gridTemplateRows?: Array<GridTemplateComponent>;
681
+ gridTemplateRows?: GridTemplateComponents;
529
682
  /**
530
683
  * Defines named grid areas specified via `grid-template-areas`.
531
684
  */
@@ -6,6 +6,11 @@
6
6
  */
7
7
  type AlignItems = "start" | "end" | "flex-start" | "flex-end" | "center" | "baseline" | "stretch";
8
8
 
9
+ /**
10
+ * Represents an angle value in degrees.
11
+ */
12
+ type Angle = number;
13
+
9
14
  /**
10
15
  * Represents a color with 8-bit RGBA components.
11
16
  */
@@ -29,6 +34,167 @@ type LengthUnit = "auto" | {
29
34
  "vw": number;
30
35
  } | number | string;
31
36
 
37
+ /**
38
+ * Represents a gradient stop position.
39
+ * If a percentage or number (0.0-1.0) is provided, it is treated as a percentage.
40
+ */
41
+ type StopPosition = LengthUnit | string;
42
+
43
+ /**
44
+ * Represents a gradient stop.
45
+ */
46
+ type GradientStop = {
47
+ /**
48
+ * The color of the gradient stop.
49
+ */
50
+ color: Color;
51
+ /**
52
+ * The position of the gradient stop.
53
+ */
54
+ hint: StopPosition | null;
55
+ } | StopPosition;
56
+
57
+ /**
58
+ * Represents a linear gradient.
59
+ */
60
+ type LinearGradient = {
61
+ /**
62
+ * The angle of the gradient.
63
+ */
64
+ angle: Angle;
65
+ /**
66
+ * The steps of the gradient.
67
+ */
68
+ stops: Array<GradientStop>;
69
+ } | string;
70
+
71
+ /**
72
+ * Supported shapes for radial gradients
73
+ */
74
+ type RadialShape = "circle" | "ellipse";
75
+
76
+ /**
77
+ * Supported size keywords for radial gradients
78
+ */
79
+ type RadialSize = "closest-side" | "farthest-side" | "closest-corner" | "farthest-corner";
80
+
81
+ /**
82
+ * Represents a radial gradient.
83
+ */
84
+ type RadialGradient = {
85
+ /**
86
+ * The radial gradient shape
87
+ */
88
+ shape: RadialShape;
89
+ /**
90
+ * The sizing mode for the gradient
91
+ */
92
+ size: RadialSize;
93
+ /**
94
+ * Center position in normalized coordinates [0.0, 1.0]
95
+ */
96
+ center: [number, number];
97
+ /**
98
+ * Gradient stops
99
+ */
100
+ stops: Array<GradientStop>;
101
+ };
102
+
103
+ /**
104
+ * Background image variants supported by Takumi.
105
+ */
106
+ type BackgroundImage = LinearGradient | RadialGradient;
107
+
108
+ /**
109
+ * A collection of background images.
110
+ */
111
+ type BackgroundImages = Array<BackgroundImage> | string;
112
+
113
+ /**
114
+ * Horizontal keywords for `background-position`.
115
+ */
116
+ type PositionKeywordX = "left" | "center" | "right";
117
+
118
+ /**
119
+ * Vertical keywords for `background-position`.
120
+ */
121
+ type PositionKeywordY = "top" | "center" | "bottom";
122
+
123
+ /**
124
+ * A single `background-position` component for an axis.
125
+ */
126
+ type PositionComponent = {
127
+ "keyword-x": PositionKeywordX;
128
+ } | {
129
+ "keyword-y": PositionKeywordY;
130
+ } | {
131
+ "length": LengthUnit;
132
+ };
133
+
134
+ /**
135
+ * Parsed `background-position` value for one layer.
136
+ */
137
+ type BackgroundPosition = {
138
+ /**
139
+ * X-axis position component.
140
+ */
141
+ x: PositionComponent;
142
+ /**
143
+ * Y-axis position component.
144
+ */
145
+ y: PositionComponent;
146
+ };
147
+
148
+ /**
149
+ * A list of `background-position` values (one per layer).
150
+ */
151
+ type BackgroundPositions = Array<BackgroundPosition> | string;
152
+
153
+ /**
154
+ * Per-axis repeat style.
155
+ */
156
+ type BackgroundRepeatStyle = "repeat" | "no-repeat" | "space" | "round";
157
+
158
+ /**
159
+ * Combined repeat for X and Y axes.
160
+ */
161
+ type BackgroundRepeat = {
162
+ /**
163
+ * Repeat style along the X axis.
164
+ */
165
+ x: BackgroundRepeatStyle;
166
+ /**
167
+ * Repeat style along the Y axis.
168
+ */
169
+ y: BackgroundRepeatStyle;
170
+ };
171
+
172
+ /**
173
+ * A list of background-repeat values (layered).
174
+ */
175
+ type BackgroundRepeats = Array<BackgroundRepeat> | string;
176
+
177
+ /**
178
+ * Parsed `background-size` for one layer.
179
+ */
180
+ type BackgroundSize = "Cover" | "Contain" | {
181
+ "Explicit": {
182
+ /**
183
+ * Width value for the background image.
184
+ */
185
+ width: LengthUnit;
186
+ /**
187
+ * Height value for the background image.
188
+ */
189
+ height: LengthUnit;
190
+ };
191
+ };
192
+
193
+ /**
194
+ * A list of `background-size` values (one per layer).
195
+ */
196
+ type BackgroundSizes = Array<BackgroundSize> | string;
197
+
32
198
  /**
33
199
  * Represents a box shadow with all its properties.
34
200
  *
@@ -210,6 +376,19 @@ type GridRepetitionCount = "auto-fill" | "auto-fit" | number;
210
376
  */
211
377
  type GridTemplateComponent = Array<string> | GridTrackSize | [GridRepetitionCount, Array<GridRepeatTrack>];
212
378
 
379
+ /**
380
+ * A transparent wrapper around a list of `GridTemplateComponent`.
381
+ *
382
+ * This exists to provide a distinct type for template component lists while
383
+ * preserving JSON compatibility (serialized as a plain array) and clean TS types.
384
+ */
385
+ type GridTemplateComponents = Array<GridTemplateComponent> | string;
386
+
387
+ /**
388
+ * A wrapper around a list of `GridTrackSize` that can also be parsed from a CSS string.
389
+ */
390
+ type GridTrackSizes = Array<GridTrackSize> | string;
391
+
213
392
  /**
214
393
  * Defines how images should be scaled when rendered.
215
394
  */
@@ -228,49 +407,11 @@ type JustifyContent = "start" | "end" | "flex-start" | "flex-end" | "center" | "
228
407
  */
229
408
  type LineHeight = number | string | LengthUnit;
230
409
 
231
- /**
232
- * Represents an angle value in degrees.
233
- */
234
- type Angle = number;
235
-
236
- /**
237
- * Represents a gradient stop.
238
- */
239
- type GradientStop = {
240
- /**
241
- * The color of the gradient stop.
242
- */
243
- color: Color;
244
- /**
245
- * The position of the gradient stop (0% to 100%).
246
- */
247
- hint: number | null;
248
- } | number;
249
-
250
- /**
251
- * Represents a linear gradient.
252
- */
253
- type LinearGradient = {
254
- /**
255
- * The angle of the gradient.
256
- */
257
- angle: Angle;
258
- /**
259
- * The steps of the gradient.
260
- */
261
- stops: Array<GradientStop>;
262
- } | string;
263
-
264
410
  /**
265
411
  * Represents either a linear gradient or a solid color.
266
412
  */
267
413
  type LinearGradientOrColor = LinearGradient | Color;
268
414
 
269
- /**
270
- * A collection of linear gradients.
271
- */
272
- type LinearGradients = Array<LinearGradient> | string;
273
-
274
415
  /**
275
416
  * Defines how an image should be resized to fit its container.
276
417
  *
@@ -469,27 +610,39 @@ type Style = {
469
610
  /**
470
611
  * Longhand: top border width. Overrides `border_width` top value.
471
612
  */
472
- borderWidthTop?: LengthUnit;
613
+ borderTopWidth?: LengthUnit;
473
614
  /**
474
615
  * Longhand: right border width. Overrides `border_width` right value.
475
616
  */
476
- borderWidthRight?: LengthUnit;
617
+ borderRightWidth?: LengthUnit;
477
618
  /**
478
619
  * Longhand: bottom border width. Overrides `border_width` bottom value.
479
620
  */
480
- borderWidthBottom?: LengthUnit;
621
+ borderBottomWidth?: LengthUnit;
481
622
  /**
482
623
  * Longhand: left border width. Overrides `border_width` left value.
483
624
  */
484
- borderWidthLeft?: LengthUnit;
625
+ borderLeftWidth?: LengthUnit;
485
626
  /**
486
627
  * How images should be fitted within their container.
487
628
  */
488
629
  objectFit: ObjectFit;
489
630
  /**
490
- * Background gradient(s).
631
+ * Background image(s): linear or radial gradients.
632
+ */
633
+ backgroundImage?: BackgroundImages;
634
+ /**
635
+ * Background positions per layer.
636
+ */
637
+ backgroundPosition?: BackgroundPositions;
638
+ /**
639
+ * Background sizes per layer.
640
+ */
641
+ backgroundSize?: BackgroundSizes;
642
+ /**
643
+ * Background repeat per layer.
491
644
  */
492
- backgroundImage?: LinearGradients;
645
+ backgroundRepeat?: BackgroundRepeats;
493
646
  /**
494
647
  * Background color for the element.
495
648
  */
@@ -501,11 +654,11 @@ type Style = {
501
654
  /**
502
655
  * Controls the size of implicitly-created grid columns.
503
656
  */
504
- gridAutoColumns?: Array<GridTrackSize>;
657
+ gridAutoColumns?: GridTrackSizes;
505
658
  /**
506
659
  * Controls the size of implicitly-created grid rows.
507
660
  */
508
- gridAutoRows?: Array<GridTrackSize>;
661
+ gridAutoRows?: GridTrackSizes;
509
662
  /**
510
663
  * Controls how auto-placed items are inserted in the grid.
511
664
  */
@@ -521,11 +674,11 @@ type Style = {
521
674
  /**
522
675
  * Defines the line names and track sizing functions of the grid columns.
523
676
  */
524
- gridTemplateColumns?: Array<GridTemplateComponent>;
677
+ gridTemplateColumns?: GridTemplateComponents;
525
678
  /**
526
679
  * Defines the line names and track sizing functions of the grid rows.
527
680
  */
528
- gridTemplateRows?: Array<GridTemplateComponent>;
681
+ gridTemplateRows?: GridTemplateComponents;
529
682
  /**
530
683
  * Defines named grid areas specified via `grid-template-areas`.
531
684
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takumi-rs/helpers",
3
- "version": "0.26.2",
3
+ "version": "0.27.1",
4
4
  "author": {
5
5
  "email": "me@kane.tw",
6
6
  "name": "Kane Wang",
@@ -14,7 +14,7 @@
14
14
  "@types/react": "^19.1.10",
15
15
  "@types/react-dom": "^19.1.7",
16
16
  "bun-plugin-dts": "^0.3.0",
17
- "lucide-react": "^0.540.0",
17
+ "lucide-react": "^0.541.0",
18
18
  "react": "^19.1.0",
19
19
  "tsup": "^8.5.0",
20
20
  "typescript": "catalog:"