@xaui/native 0.2.5 → 0.2.7

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.
@@ -1,55 +1,163 @@
1
1
  import React, { ReactNode, ReactElement, ComponentType } from 'react';
2
- import { StyleProp, ViewStyle, ColorValue, ScrollViewProps } from 'react-native';
2
+ import { AccessibilityRole, AccessibilityState, StyleProp, ViewStyle, ColorValue, ScrollViewProps } from 'react-native';
3
+ import { EdgeInsets, Alignment, Border, BorderRadius, ShadowConfig, TransformConfig } from '@xaui/core';
3
4
  import { ThemeColor, Radius } from '@xaui/core/types';
4
5
 
5
- type MainAxisAlignment = 'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly';
6
- type CrossAxisAlignment = 'start' | 'center' | 'end' | 'stretch' | 'baseline';
7
- type RowProps = {
8
- /**
9
- * The content to render inside the row.
10
- */
11
- children: ReactNode;
12
- /**
13
- * Main axis alignment for row items.
14
- * @default 'start'
15
- */
6
+ type ContainerProps = {
7
+ /** Content to render inside the container. */
8
+ children?: ReactNode;
9
+ /** Width in logical pixels or percentage string (e.g. `'50%'`). */
10
+ width?: number | `${number}%`;
11
+ /** Height in logical pixels or percentage string (e.g. `'50%'`). */
12
+ height?: number | `${number}%`;
13
+ /** Minimum width constraint in logical pixels. */
14
+ minWidth?: number;
15
+ /** Maximum width constraint in logical pixels. */
16
+ maxWidth?: number;
17
+ /** Minimum height constraint in logical pixels. */
18
+ minHeight?: number;
19
+ /** Maximum height constraint in logical pixels. */
20
+ maxHeight?: number;
21
+ /** Width-to-height aspect ratio (e.g. `16 / 9`). */
22
+ aspectRatio?: number;
23
+ /** Flex grow/shrink factor. */
24
+ flex?: number;
25
+ /** Inner spacing — number for all sides or `{ top, bottom, left, right, horizontal, vertical }`. */
26
+ padding?: EdgeInsets;
27
+ /** Outer spacing — same shape as `padding`. */
28
+ margin?: EdgeInsets;
29
+ /** Alignment of children — named (`'center'`, `'topLeft'`, …) or coordinate `{ x, y }`. */
30
+ alignment?: Alignment;
31
+ /** Background color. */
32
+ color?: string;
33
+ /** Border — uniform `{ width, color, style }` or per-side `{ top, left, … }`. */
34
+ border?: Border;
35
+ /** Corner radius — number for all corners or `{ topLeft, topRight, bottomLeft, bottomRight }`. */
36
+ borderRadius?: BorderRadius;
37
+ /** Drop shadow config — `{ color, offset: { x, y }, blur, opacity, elevation }`. */
38
+ shadow?: ShadowConfig;
39
+ /** Clip children to the container bounds (`overflow: hidden`). */
40
+ clip?: boolean;
41
+ /** CSS / RN transforms — `{ rotate, scale, translateX, translateY, … }`. */
42
+ transform?: TransformConfig;
43
+ /** Opacity from `0` (transparent) to `1` (opaque). */
44
+ opacity?: number;
45
+ /** Tap handler — renders the container as `Pressable` when provided. */
46
+ onPress?: () => void;
47
+ /** Long-press handler (fires after 500 ms). */
48
+ onLongPress?: () => void;
49
+ /** Fired on touch/pointer down. */
50
+ onPressIn?: () => void;
51
+ /** Fired on touch/pointer up. */
52
+ onPressOut?: () => void;
53
+ /** Disables all press handlers when `true`. */
54
+ disabled?: boolean;
55
+ /** Screen reader label. */
56
+ accessibilityLabel?: string;
57
+ /** Accessibility role for assistive technologies. */
58
+ accessibilityRole?: AccessibilityRole;
59
+ /** Accessibility state (disabled, selected, …). */
60
+ accessibilityState?: AccessibilityState;
61
+ /** Whether the element is accessible to assistive technologies. */
62
+ accessible?: boolean;
63
+ /** Test identifier for e2e tests. */
64
+ testID?: string;
65
+ /** Raw style override applied to the underlying View / Pressable. */
66
+ style?: StyleProp<ViewStyle>;
67
+ };
68
+
69
+ declare const Container: React.FC<ContainerProps>;
70
+
71
+ type MainAxisAlignment = 'start' | 'end' | 'center' | 'spaceBetween' | 'spaceAround' | 'spaceEvenly';
72
+ type CrossAxisAlignment = 'start' | 'end' | 'center' | 'stretch';
73
+ /** Controls how much space the flex widget occupies in its main axis. */
74
+ type MainAxisSize = 'min' | 'max';
75
+ type Direction = 'horizontal' | 'vertical';
76
+ type FlexProps = {
77
+ /** Content to render inside the flex container. */
78
+ children?: ReactNode;
79
+ /** Axis direction — `'horizontal'` for row, `'vertical'` for column. */
80
+ direction: Direction;
81
+ /** How to place children along the main axis. @default 'start' */
16
82
  mainAxisAlignment?: MainAxisAlignment;
17
- /**
18
- * Cross axis alignment for row items.
19
- * @default 'center'
20
- */
83
+ /** How to place children along the cross axis. @default 'center' */
21
84
  crossAxisAlignment?: CrossAxisAlignment;
22
- /**
23
- * Spacing between children.
24
- */
25
- spacing?: number;
26
- /**
27
- * Reverse the row direction.
28
- * @default false
29
- */
30
- reverse?: boolean;
31
- /**
32
- * Force the container to take the full width.
33
- * @default false
34
- */
35
- fullWidth?: boolean;
36
- /**
37
- * Custom style for the row container.
38
- */
85
+ /** Whether the flex takes max or min space in the main axis. @default 'max' */
86
+ mainAxisSize?: MainAxisSize;
87
+ /** Wrap children onto multiple lines when they overflow. @default false */
88
+ wrap?: boolean;
89
+ /** Gap in logical pixels between children. */
90
+ gap?: number;
91
+ /** Reverse the layout direction. @default false */
92
+ reversed?: boolean;
93
+ /** Flex factor applied to the container itself. */
94
+ flex?: number;
95
+ /** Raw style override applied to the underlying View. */
39
96
  style?: StyleProp<ViewStyle>;
97
+ /** Test identifier for e2e tests. */
98
+ testID?: string;
40
99
  };
41
- type ColumnProps = RowProps & {
100
+ type RowProps = Omit<FlexProps, 'direction'>;
101
+ type ColumnProps = Omit<FlexProps, 'direction'>;
102
+ /** Controls how a `Flexible` child sizes itself within available space. */
103
+ type FlexFit = 'tight' | 'loose';
104
+ type FlexibleProps = {
105
+ /** Content to render inside the flexible container. */
106
+ children?: ReactNode;
107
+ /** Flex factor — how much space to claim relative to siblings. @default 1 */
108
+ flex?: number;
42
109
  /**
43
- * If true, the container will grow to fill available space.
44
- * @default false
110
+ * Sizing behaviour:
111
+ * - `'tight'` — force the child to fill all allotted space (like `Expanded`).
112
+ * - `'loose'` — allow the child to be at most the allotted size but no larger.
113
+ * @default 'loose'
45
114
  */
46
- noGrowth?: boolean;
115
+ fit?: FlexFit;
116
+ /** Raw style override applied to the underlying View. */
117
+ style?: StyleProp<ViewStyle>;
118
+ /** Test identifier for e2e tests. */
119
+ testID?: string;
47
120
  };
121
+ type WrapProps = {
122
+ /** Content to render inside the wrap container. */
123
+ children?: ReactNode;
124
+ /** Primary axis direction. @default 'horizontal' */
125
+ direction?: Direction;
126
+ /** Alignment of children along the main axis within each run. @default 'start' */
127
+ alignment?: MainAxisAlignment;
128
+ /** Alignment of runs along the cross axis. @default 'start' */
129
+ runAlignment?: MainAxisAlignment;
130
+ /** Space between children along the main axis. @default 0 */
131
+ spacing?: number;
132
+ /** Space between runs along the cross axis. @default 0 */
133
+ runSpacing?: number;
134
+ /** Raw style override applied to the underlying View. */
135
+ style?: StyleProp<ViewStyle>;
136
+ /** Test identifier for e2e tests. */
137
+ testID?: string;
138
+ };
139
+
140
+ declare const Flex: React.FC<FlexProps>;
48
141
 
49
142
  declare const Column: React.FC<ColumnProps>;
50
143
 
51
144
  declare const Row: React.FC<RowProps>;
52
145
 
146
+ type ExpandedProps = {
147
+ /** Content to render inside the expanded container. */
148
+ children?: ReactNode;
149
+ /** Flex factor — how much of the available space to take relative to siblings. @default 1 */
150
+ flex?: number;
151
+ /** Raw style override applied to the underlying View. */
152
+ style?: StyleProp<ViewStyle>;
153
+ /** Test identifier for e2e tests. */
154
+ testID?: string;
155
+ };
156
+
157
+ declare const Expanded: React.FC<ExpandedProps>;
158
+
159
+ declare const Flexible: React.FC<FlexibleProps>;
160
+
53
161
  type SpacerProps = {
54
162
  /**
55
163
  * Flex factor for the spacer.
@@ -64,133 +172,133 @@ type SpacerProps = {
64
172
 
65
173
  declare const Spacer: React.FC<SpacerProps>;
66
174
 
175
+ declare const Wrap: React.FC<WrapProps>;
176
+
67
177
  type PaddingProps = {
178
+ /** Content to render inside the padding container. */
179
+ children?: ReactNode;
180
+ /** Padding applied to all sides — number for uniform, or `{ top, bottom, left, right, horizontal, vertical }`. */
181
+ padding: EdgeInsets;
182
+ /** Raw style override applied to the underlying View. */
183
+ style?: StyleProp<ViewStyle>;
184
+ };
185
+
186
+ declare const Padding: React.FC<PaddingProps>;
187
+
188
+ type MarginProps = {
189
+ /** Content to render inside the margin container. */
190
+ children?: ReactNode;
191
+ /** Margin applied to all sides — number for uniform, or `{ top, bottom, left, right, horizontal, vertical }`. */
192
+ margin: EdgeInsets;
193
+ /** Raw style override applied to the underlying View. */
194
+ style?: StyleProp<ViewStyle>;
195
+ };
196
+
197
+ declare const Margin: React.FC<MarginProps>;
198
+
199
+ type SizedBoxProps = {
68
200
  /**
69
- * Content to render inside the padding container.
70
- */
71
- children: ReactNode;
72
- /**
73
- * Padding on all sides.
74
- */
75
- all?: number;
76
- /**
77
- * Horizontal padding.
78
- */
79
- horizontal?: number;
80
- /**
81
- * Vertical padding.
82
- */
83
- vertical?: number;
84
- /**
85
- * Top padding.
86
- */
87
- top?: number;
88
- /**
89
- * Right padding.
201
+ * Width in logical pixels.
90
202
  */
91
- right?: number;
203
+ width?: number;
92
204
  /**
93
- * Bottom padding.
205
+ * Height in logical pixels.
94
206
  */
95
- bottom?: number;
207
+ height?: number;
96
208
  /**
97
- * Left padding.
209
+ * Fills all available space — equivalent to Flutter's Expanded (flex: 1, alignSelf: 'stretch').
210
+ * @default false
98
211
  */
99
- left?: number;
212
+ expand?: boolean;
100
213
  /**
101
- * Whether the padding container should take the full width of its parent.
214
+ * Collapses to zero size equivalent to Flutter's SizedBox.shrink().
102
215
  * @default false
103
216
  */
104
- fullWidth?: boolean;
217
+ shrink?: boolean;
105
218
  /**
106
- * If true, the padding container will grow to fill available space.
107
- * @default false
219
+ * Content to render inside the box.
108
220
  */
109
- noGrowth?: boolean;
221
+ children?: ReactNode;
110
222
  /**
111
- * Custom style for the padding container.
223
+ * Style override applied to the underlying View.
112
224
  */
113
225
  style?: StyleProp<ViewStyle>;
226
+ /**
227
+ * Test identifier for e2e tests.
228
+ */
229
+ testID?: string;
114
230
  };
115
231
 
116
- declare const Padding: React.FC<PaddingProps>;
232
+ declare const SizedBox: React.FC<SizedBoxProps>;
117
233
 
118
- type MarginProps = {
234
+ type BoxConstraints = {
119
235
  /**
120
- * Content to render inside the margin container.
236
+ * Minimum width in logical pixels.
121
237
  */
122
- children: ReactNode;
238
+ minWidth?: number;
123
239
  /**
124
- * Margin on all sides.
240
+ * Maximum width in logical pixels.
125
241
  */
126
- all?: number;
242
+ maxWidth?: number;
127
243
  /**
128
- * Horizontal margin.
244
+ * Minimum height in logical pixels.
129
245
  */
130
- horizontal?: number;
131
- /**
132
- * Vertical margin.
133
- */
134
- vertical?: number;
135
- /**
136
- * Top margin.
137
- */
138
- top?: number;
246
+ minHeight?: number;
139
247
  /**
140
- * Right margin.
248
+ * Maximum height in logical pixels.
141
249
  */
142
- right?: number;
250
+ maxHeight?: number;
251
+ };
252
+ type ConstrainedBoxProps = {
143
253
  /**
144
- * Bottom margin.
254
+ * Size constraints to impose on the child — Flutter BoxConstraints equivalent.
145
255
  */
146
- bottom?: number;
256
+ constraints: BoxConstraints;
147
257
  /**
148
- * Left margin.
149
- */
150
- left?: number;
151
- /**
152
- * Whether the margin container should take the full width of its parent.
153
- * @default false
258
+ * Content to render inside the box.
154
259
  */
155
- fullWidth?: boolean;
260
+ children?: ReactNode;
156
261
  /**
157
- * If true, the margin container will grow to fill available space.
158
- * @default false
262
+ * Style override applied to the underlying View.
159
263
  */
160
- noGrowth?: boolean;
264
+ style?: StyleProp<ViewStyle>;
161
265
  /**
162
- * Custom style for the margin container.
266
+ * Test identifier for e2e tests.
163
267
  */
164
- style?: StyleProp<ViewStyle>;
268
+ testID?: string;
165
269
  };
166
270
 
167
- declare const Margin: React.FC<MarginProps>;
271
+ declare const ConstrainedBox: React.FC<ConstrainedBoxProps>;
168
272
 
169
- type SizedBoxProps = {
273
+ type FractionallySizedBoxProps = {
170
274
  /**
171
- * Content to render inside the box.
275
+ * Fraction of the parent's width (0–1). When undefined, the child chooses its own width.
172
276
  */
173
- children?: ReactNode;
277
+ widthFactor?: number;
174
278
  /**
175
- * Width of the box.
279
+ * Fraction of the parent's height (0–1). When undefined, the child chooses its own height.
176
280
  */
177
- width?: ViewStyle['width'];
281
+ heightFactor?: number;
178
282
  /**
179
- * Height of the box.
283
+ * How to align the child within the remaining space.
284
+ * @default 'topLeft'
180
285
  */
181
- height?: ViewStyle['height'];
286
+ alignment?: Alignment;
182
287
  /**
183
- * Whether the box should take the full width of its parent.
184
- * @default false
288
+ * Content to render inside the box.
185
289
  */
186
- fullWidth?: boolean;
290
+ children?: ReactNode;
187
291
  /**
188
- * Custom style for the box.
292
+ * Style override applied to the underlying View.
189
293
  */
190
294
  style?: StyleProp<ViewStyle>;
295
+ /**
296
+ * Test identifier for e2e tests.
297
+ */
298
+ testID?: string;
191
299
  };
192
300
 
193
- declare const SizedBox: React.FC<SizedBoxProps>;
301
+ declare const FractionallySizedBox: React.FC<FractionallySizedBoxProps>;
194
302
 
195
303
  type PositionedViewProps = {
196
304
  /**
@@ -300,18 +408,31 @@ declare const RoundedView: React.FC<RoundedViewProps>;
300
408
 
301
409
  type AspectRatioProps = {
302
410
  /**
303
- * Content to be displayed inside the aspect ratio container
411
+ * Content to be displayed inside the aspect ratio container.
304
412
  */
305
- children: ReactNode;
413
+ children?: ReactNode;
306
414
  /**
307
- * Aspect ratio as a number (width / height)
415
+ * Aspect ratio as a number (width / height).
308
416
  * Examples: 16/9, 4/3, 1, 2/1
309
417
  */
310
418
  ratio: number;
311
419
  /**
312
- * Custom style for the container
420
+ * How to align the child within the container.
313
421
  */
314
- style?: ViewStyle;
422
+ alignment?: Alignment;
423
+ /**
424
+ * Whether to clip content that overflows the container.
425
+ * @default false
426
+ */
427
+ clip?: boolean;
428
+ /**
429
+ * Style override applied to the underlying View.
430
+ */
431
+ style?: StyleProp<ViewStyle>;
432
+ /**
433
+ * Test identifier for e2e tests.
434
+ */
435
+ testID?: string;
315
436
  };
316
437
 
317
438
  declare const AspectRatio: React.FC<AspectRatioProps>;
@@ -378,24 +499,21 @@ type ScreenProps = {
378
499
 
379
500
  declare const Screen: React.FC<ScreenProps>;
380
501
 
502
+ type AlignProps = {
503
+ /** Content to align inside the container. */
504
+ children?: ReactNode;
505
+ /** Alignment of children — named (`'center'`, `'topLeft'`, …) or coordinate `{ x, y }`. */
506
+ alignment: Alignment;
507
+ /** Raw style override applied to the underlying View. */
508
+ style?: StyleProp<ViewStyle>;
509
+ };
510
+
511
+ declare const Align: React.FC<AlignProps>;
512
+
381
513
  type CenterProps = {
382
- /**
383
- * Content to render inside the centered container.
384
- */
385
- children: ReactNode;
386
- /**
387
- * Whether the centered container should take the full width of its parent.
388
- * @default false
389
- */
390
- fullWidth?: boolean;
391
- /**
392
- * If true, disables automatic growth (e.g. prevents using flex: 1 to fill available space).
393
- * @default false
394
- */
395
- noGrowth?: boolean;
396
- /**
397
- * Additional style for the container.
398
- */
514
+ /** Content to center. */
515
+ children?: ReactNode;
516
+ /** Raw style override applied to the underlying View. */
399
517
  style?: StyleProp<ViewStyle>;
400
518
  };
401
519
 
@@ -712,4 +830,4 @@ declare const MasonryGridBuilder: {
712
830
  displayName: string;
713
831
  };
714
832
 
715
- export { AspectRatio, type AspectRatioProps, BlurView, type BlurViewProps, Center, type CenterProps, Column, type ColumnProps, ConditionalView, type ConditionalViewAnimation, type ConditionalViewProps, type CrossAxisAlignment, Grid, GridBuilder, type GridBuilderProps, GridItem, type GridItemProps, type GridProps, type MainAxisAlignment, Margin, type MarginProps, MasonryGrid, MasonryGridBuilder, type MasonryGridBuilderProps, MasonryGridItem, type MasonryGridItemProps, type MasonryGridProps, Padding, type PaddingProps, PositionedView, type PositionedViewProps, RoundedView, type RoundedViewProps, Row, type RowProps, Screen, type ScreenProps, SizedBox, type SizedBoxProps, Spacer, type SpacerProps, Surface, type SurfaceProps, type SurfaceThemeColor };
833
+ export { Align, type AlignProps, AspectRatio, type AspectRatioProps, BlurView, type BlurViewProps, type BoxConstraints, Center, type CenterProps, Column, type ColumnProps, ConditionalView, type ConditionalViewAnimation, type ConditionalViewProps, ConstrainedBox, type ConstrainedBoxProps, Container, type ContainerProps, type CrossAxisAlignment, type Direction, Expanded, type ExpandedProps, Flex, type FlexFit, type FlexProps, Flexible, type FlexibleProps, FractionallySizedBox, type FractionallySizedBoxProps, Grid, GridBuilder, type GridBuilderProps, GridItem, type GridItemProps, type GridProps, type MainAxisAlignment, type MainAxisSize, Margin, type MarginProps, MasonryGrid, MasonryGridBuilder, type MasonryGridBuilderProps, MasonryGridItem, type MasonryGridItemProps, type MasonryGridProps, Padding, type PaddingProps, PositionedView, type PositionedViewProps, RoundedView, type RoundedViewProps, Row, type RowProps, Screen, type ScreenProps, SizedBox, type SizedBoxProps, Spacer, type SpacerProps, Surface, type SurfaceProps, type SurfaceThemeColor, Wrap, type WrapProps };