noreflow 0.1.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.
@@ -0,0 +1,161 @@
1
+ /**
2
+ * Size value: a pixel number, a percentage string like "50%", or "auto".
3
+ */
4
+ type SizeValue = number | `${number}%` | 'auto';
5
+ /**
6
+ * Size value that excludes "auto" (for min/max constraints).
7
+ */
8
+ type DimensionValue = number | `${number}%`;
9
+ /**
10
+ * Margin value: pixels, percentage, or "auto" for auto margins.
11
+ */
12
+ type MarginValue = number | `${number}%` | 'auto';
13
+ type FlexDirection = 'row' | 'column' | 'row-reverse' | 'column-reverse';
14
+ type FlexWrap = 'nowrap' | 'wrap' | 'wrap-reverse';
15
+ type JustifyContent = 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
16
+ type AlignItems = 'flex-start' | 'flex-end' | 'center' | 'stretch';
17
+ type AlignSelf = 'auto' | AlignItems;
18
+ type AlignContent = 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'space-between' | 'space-around';
19
+ type Display = 'flex' | 'grid' | 'none';
20
+ type Position = 'static' | 'relative' | 'absolute';
21
+ type BoxSizing = 'content-box' | 'border-box';
22
+ /**
23
+ * Inset value for top/right/bottom/left: pixels, percentage, or "auto".
24
+ */
25
+ type InsetValue = number | `${number}%` | 'auto';
26
+ /**
27
+ * A single track size definition.
28
+ * - number: fixed pixels
29
+ * - `${number}%`: percentage of the container's content size
30
+ * - `${number}fr`: flexible fraction of remaining space
31
+ * - 'auto': sized to content (min-content to max-content)
32
+ */
33
+ type TrackSize = number | `${number}%` | `${number}fr` | 'auto';
34
+ type GridAutoFlow = 'row' | 'column';
35
+ /**
36
+ * Grid item placement value: a 1-based line number or 'auto'.
37
+ */
38
+ type GridLine = number | 'auto';
39
+ type JustifyItems = 'start' | 'end' | 'center' | 'stretch';
40
+ type JustifySelf = 'auto' | JustifyItems;
41
+ /**
42
+ * Style properties for a layout node (flex or grid container, or child item).
43
+ * All properties are optional and default to CSS spec initial values.
44
+ */
45
+ interface FlexStyle {
46
+ display?: Display;
47
+ position?: Position;
48
+ flexDirection?: FlexDirection;
49
+ flexWrap?: FlexWrap;
50
+ justifyContent?: JustifyContent;
51
+ alignItems?: AlignItems;
52
+ alignSelf?: AlignSelf;
53
+ alignContent?: AlignContent;
54
+ justifyItems?: JustifyItems;
55
+ justifySelf?: JustifySelf;
56
+ gridTemplateColumns?: TrackSize[];
57
+ gridTemplateRows?: TrackSize[];
58
+ gridAutoColumns?: TrackSize;
59
+ gridAutoRows?: TrackSize;
60
+ gridAutoFlow?: GridAutoFlow;
61
+ gridColumnStart?: GridLine;
62
+ gridColumnEnd?: GridLine;
63
+ gridRowStart?: GridLine;
64
+ gridRowEnd?: GridLine;
65
+ flexGrow?: number;
66
+ flexShrink?: number;
67
+ flexBasis?: number | 'auto';
68
+ width?: SizeValue;
69
+ height?: SizeValue;
70
+ minWidth?: DimensionValue;
71
+ minHeight?: DimensionValue;
72
+ maxWidth?: DimensionValue;
73
+ maxHeight?: DimensionValue;
74
+ top?: InsetValue;
75
+ right?: InsetValue;
76
+ bottom?: InsetValue;
77
+ left?: InsetValue;
78
+ zIndex?: number;
79
+ aspectRatio?: number;
80
+ padding?: number;
81
+ paddingTop?: number;
82
+ paddingRight?: number;
83
+ paddingBottom?: number;
84
+ paddingLeft?: number;
85
+ margin?: MarginValue;
86
+ marginTop?: MarginValue;
87
+ marginRight?: MarginValue;
88
+ marginBottom?: MarginValue;
89
+ marginLeft?: MarginValue;
90
+ border?: number;
91
+ borderTop?: number;
92
+ borderRight?: number;
93
+ borderBottom?: number;
94
+ borderLeft?: number;
95
+ gap?: number;
96
+ rowGap?: number;
97
+ columnGap?: number;
98
+ boxSizing?: BoxSizing;
99
+ }
100
+ /**
101
+ * Callback to measure leaf node content (e.g. text, images).
102
+ * Called by the layout engine when it needs to know the intrinsic
103
+ * size of a node that has no children.
104
+ *
105
+ * @param availableWidth - The width available for the content (may be Infinity)
106
+ * @param availableHeight - The height available for the content (may be Infinity)
107
+ * @returns The measured size of the content
108
+ */
109
+ type MeasureFunction = (availableWidth: number, availableHeight: number) => {
110
+ width: number;
111
+ height: number;
112
+ };
113
+ /**
114
+ * A node in the layout tree. This is the input to computeLayout().
115
+ */
116
+ interface FlexNode {
117
+ style?: FlexStyle;
118
+ children?: FlexNode[];
119
+ measure?: MeasureFunction;
120
+ }
121
+ /**
122
+ * The computed layout for a single node. This is the output of computeLayout().
123
+ * Coordinates are relative to the node's parent.
124
+ */
125
+ interface LayoutResult {
126
+ x: number;
127
+ y: number;
128
+ width: number;
129
+ height: number;
130
+ children: LayoutResult[];
131
+ }
132
+
133
+ declare function computeLayout(node: FlexNode, availableWidth?: number, availableHeight?: number): LayoutResult;
134
+
135
+ /**
136
+ * Create a layout node with style applied directly — no `{ style: { ... } }` wrapping.
137
+ *
138
+ * h({ width: 100, height: 50 })
139
+ * h({ flexGrow: 1 }, child1, child2)
140
+ */
141
+ declare function h(style: FlexStyle, ...children: FlexNode[]): FlexNode;
142
+ /**
143
+ * Create a row (flex-direction: row) node.
144
+ *
145
+ * row({ gap: 12, padding: 8 }, child1, child2)
146
+ */
147
+ declare function row(style: FlexStyle, ...children: FlexNode[]): FlexNode;
148
+ /**
149
+ * Create a column (flex-direction: column) node.
150
+ *
151
+ * col({ width: 375, height: 667 }, header, content, footer)
152
+ */
153
+ declare function col(style: FlexStyle, ...children: FlexNode[]): FlexNode;
154
+ /**
155
+ * Create a grid container node.
156
+ *
157
+ * grid({ gridTemplateColumns: ['1fr', '1fr'], gap: 8 }, ...items)
158
+ */
159
+ declare function grid(style: FlexStyle, ...children: FlexNode[]): FlexNode;
160
+
161
+ export { type AlignContent, type AlignItems, type AlignSelf, type BoxSizing, type DimensionValue, type Display, type FlexDirection, type FlexNode, type FlexStyle, type FlexWrap, type GridAutoFlow, type GridLine, type InsetValue, type JustifyContent, type JustifyItems, type JustifySelf, type LayoutResult, type MarginValue, type MeasureFunction, type Position, type SizeValue, type TrackSize, col, computeLayout, grid, h, row };