taffy-js 0.2.9 → 0.2.11

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.
@@ -405,6 +405,68 @@ export interface DetailedGridItemsInfo {
405
405
  column_end: number;
406
406
  }
407
407
 
408
+ /**
409
+ * Grid placement type for positioning grid items.
410
+ *
411
+ * Specifies how an item is placed on a grid track (row or column).
412
+ * Follows CSS `grid-row-start` / `grid-column-start` specification.
413
+ *
414
+ * @remarks
415
+ * - `"auto"`: Auto-placement using the grid's flow algorithm
416
+ * - `number`: Place at a specific line index (1-indexed, can be negative)
417
+ * - `{ span: number }`: Span a specified number of tracks
418
+ *
419
+ * @example
420
+ * ```typescript
421
+ * import type { GridPlacement, Line } from 'taffy-js';
422
+ *
423
+ * // Line index (CSS: grid-row-start: 2)
424
+ * const lineIndex: GridPlacement = 2;
425
+ *
426
+ * // Auto placement (CSS: grid-row-start: auto)
427
+ * const auto: GridPlacement = "auto";
428
+ *
429
+ * // Span (CSS: grid-row-start: span 3)
430
+ * const span: GridPlacement = { span: 3 };
431
+ * ```
432
+ */
433
+ export type GridPlacement = "auto" | number | { span: number };
434
+
435
+ /**
436
+ * Line type representing start and end positions.
437
+ *
438
+ * A container for start and end values, used for CSS grid-row and grid-column
439
+ * shorthand properties.
440
+ *
441
+ * @typeParam T - The type of start and end values
442
+ *
443
+ * @property start - The starting line/position
444
+ * @property end - The ending line/position
445
+ *
446
+ * @example
447
+ * ```typescript
448
+ * import { Style, Display, type Line, type GridPlacement } from 'taffy-js';
449
+ *
450
+ * const style = new Style();
451
+ * style.display = Display.Grid;
452
+ *
453
+ * // CSS: grid-row: 1 / 3
454
+ * style.gridRow = { start: 1, end: 3 };
455
+ *
456
+ * // CSS: grid-column: 1 / span 2
457
+ * style.gridColumn = { start: 1, end: { span: 2 } };
458
+ *
459
+ * // CSS: grid-row: auto / auto
460
+ * style.gridRow = { start: "auto", end: "auto" };
461
+ * ```
462
+ */
463
+ export interface Line<T> {
464
+ /** The starting position (CSS: *-start) */
465
+ start: T;
466
+ /** The ending position (CSS: *-end) */
467
+ end: T;
468
+ }
469
+
408
470
 
409
471
 
410
472
  /**
@@ -677,6 +739,40 @@ export enum FlexWrap {
677
739
  WrapReverse = 2,
678
740
  }
679
741
 
742
+ /**
743
+ * Grid auto flow enumeration
744
+ *
745
+ * Controls whether grid items are placed row-wise or column-wise, and whether
746
+ * the sparse or dense packing algorithm is used.
747
+ *
748
+ * @example
749
+ * ```typescript
750
+ * import { GridAutoFlow } from 'taffy-js';
751
+ *
752
+ * style.gridAutoFlow = GridAutoFlow.Row; // Fill rows first
753
+ * style.gridAutoFlow = GridAutoFlow.Column; // Fill columns first
754
+ * style.gridAutoFlow = GridAutoFlow.RowDense; // Fill rows, pack densely
755
+ * ```
756
+ */
757
+ export enum GridAutoFlow {
758
+ /**
759
+ * Items are placed by filling each row in turn, adding new rows as necessary
760
+ */
761
+ Row = 0,
762
+ /**
763
+ * Items are placed by filling each column in turn, adding new columns as necessary
764
+ */
765
+ Column = 1,
766
+ /**
767
+ * Combines `Row` with the dense packing algorithm
768
+ */
769
+ RowDense = 2,
770
+ /**
771
+ * Combines `Column` with the dense packing algorithm
772
+ */
773
+ ColumnDense = 3,
774
+ }
775
+
680
776
  /**
681
777
  * Main axis alignment enumeration
682
778
  *
@@ -928,17 +1024,17 @@ export enum Overflow {
928
1024
  */
929
1025
  Visible = 0,
930
1026
  /**
931
- * Content is clipped at the container boundary
1027
+ * Content is clipped at the container boundary, but unlike Hidden, this forbids all scrolling
932
1028
  */
933
- Hidden = 1,
1029
+ Clip = 1,
934
1030
  /**
935
- * Always display scrollbars for scrollable content
1031
+ * Content is clipped at the container boundary
936
1032
  */
937
- Scroll = 2,
1033
+ Hidden = 2,
938
1034
  /**
939
- * Display scrollbars only when content overflows (internally maps to Scroll)
1035
+ * Always display scrollbars for scrollable content
940
1036
  */
941
- Auto = 3,
1037
+ Scroll = 3,
942
1038
  }
943
1039
 
944
1040
  /**
@@ -1042,6 +1138,16 @@ export class Style {
1042
1138
  * @returns - A `Rect<LengthPercentageAuto>` with left, right, top, bottom margins
1043
1139
  */
1044
1140
  margin: Rect<LengthPercentageAuto>;
1141
+ /**
1142
+ * Gets the text-align property
1143
+ *
1144
+ * Used by block layout to implement legacy text alignment behavior.
1145
+ *
1146
+ * @returns - The current [`TextAlign`](JsTextAlign) value
1147
+ *
1148
+ * @defaultValue - `TextAlign.Auto`
1149
+ */
1150
+ textAlign: TextAlign;
1045
1151
  /**
1046
1152
  * Gets the align-items property
1047
1153
  *
@@ -1059,6 +1165,15 @@ export class Style {
1059
1165
  * @returns - The flex shrink factor (default: 1)
1060
1166
  */
1061
1167
  flexShrink: number;
1168
+ /**
1169
+ * Gets the grid-column property
1170
+ *
1171
+ * Defines which column in the grid the item should start and end at.
1172
+ * Corresponds to CSS `grid-column` shorthand.
1173
+ *
1174
+ * @returns - A `Line<GridPlacement>` with start and end placements
1175
+ */
1176
+ gridColumn: Line<GridPlacement>;
1062
1177
  /**
1063
1178
  * Gets the display mode
1064
1179
  *
@@ -1085,6 +1200,23 @@ export class Style {
1085
1200
  * @returns - The aspect ratio value, or `undefined` if not set
1086
1201
  */
1087
1202
  aspectRatio: number | undefined;
1203
+ /**
1204
+ * Gets the justify-self property
1205
+ *
1206
+ * Overrides the parent's justify-items for this specific element in the inline axis.
1207
+ *
1208
+ * @returns - The current [`AlignSelf`](JsAlignSelf) value (returns `Auto` if not set)
1209
+ */
1210
+ justifySelf: AlignSelf | undefined;
1211
+ /**
1212
+ * Gets the grid-row property
1213
+ *
1214
+ * Defines which row in the grid the item should start and end at.
1215
+ * Corresponds to CSS `grid-row` shorthand.
1216
+ *
1217
+ * @returns - A `Line<GridPlacement>` with start and end placements
1218
+ */
1219
+ gridRow: Line<GridPlacement>;
1088
1220
  /**
1089
1221
  * Gets the maximum size constraints
1090
1222
  *
@@ -1123,6 +1255,25 @@ export class Style {
1123
1255
  * @returns - The current [`AlignContent`](JsAlignContent) value, or `undefined` if not set
1124
1256
  */
1125
1257
  alignContent: AlignContent | undefined;
1258
+ /**
1259
+ * Gets whether this item is a table
1260
+ *
1261
+ * Table children are handled specially in block layout.
1262
+ *
1263
+ * @returns - Whether the item is treated as a table
1264
+ *
1265
+ * @defaultValue - `false`
1266
+ */
1267
+ itemIsTable: boolean;
1268
+ /**
1269
+ * Gets the justify-items property
1270
+ *
1271
+ * Defines the default justify-self for all children in the inline axis.
1272
+ * This is primarily used for CSS Grid layout.
1273
+ *
1274
+ * @returns - The current [`AlignItems`](JsAlignItems) value, or `undefined` if not set
1275
+ */
1276
+ justifyItems: AlignItems | undefined;
1126
1277
  /**
1127
1278
  * Gets the flex grow factor
1128
1279
  *
@@ -1152,6 +1303,24 @@ export class Style {
1152
1303
  * @defaultValue - `FlexDirection.Row`
1153
1304
  */
1154
1305
  flexDirection: FlexDirection;
1306
+ /**
1307
+ * Gets the grid-auto-flow property
1308
+ *
1309
+ * Controls how auto-placed items are inserted into the grid.
1310
+ *
1311
+ * @returns - The current [`GridAutoFlow`](JsGridAutoFlow) value
1312
+ *
1313
+ * @defaultValue - `GridAutoFlow.Row`
1314
+ */
1315
+ gridAutoFlow: GridAutoFlow;
1316
+ /**
1317
+ * Gets the grid-auto-rows property
1318
+ *
1319
+ * Defines the size of implicitly created rows.
1320
+ *
1321
+ * @returns - An array of track sizing functions
1322
+ */
1323
+ gridAutoRows: any;
1155
1324
  /**
1156
1325
  * Gets the justify-content property
1157
1326
  *
@@ -1160,6 +1329,75 @@ export class Style {
1160
1329
  * @returns - The current [`JustifyContent`](JsJustifyContent) value, or `undefined` if not set
1161
1330
  */
1162
1331
  justifyContent: JustifyContent | undefined;
1332
+ /**
1333
+ * Gets the scrollbar width
1334
+ *
1335
+ * The width of the scrollbar gutter when `overflow` is set to `Scroll`.
1336
+ *
1337
+ * @returns - The scrollbar width in pixels
1338
+ *
1339
+ * @defaultValue - `0`
1340
+ */
1341
+ scrollbarWidth: number;
1342
+ /**
1343
+ * Gets whether this item is a replaced element
1344
+ *
1345
+ * Replaced elements have special sizing behavior (e.g., `<img>`, `<video>`).
1346
+ *
1347
+ * @returns - Whether the item is a replaced element
1348
+ *
1349
+ * @defaultValue - `false`
1350
+ */
1351
+ itemIsReplaced: boolean;
1352
+ /**
1353
+ * Gets the grid-auto-columns property
1354
+ *
1355
+ * Defines the size of implicitly created columns.
1356
+ *
1357
+ * @returns - An array of track sizing functions
1358
+ */
1359
+ gridAutoColumns: any;
1360
+ /**
1361
+ * Gets the grid-template-rows property
1362
+ *
1363
+ * Defines the track sizing functions (heights) of the grid rows.
1364
+ * Returns Taffy's native serialization format.
1365
+ *
1366
+ * @returns - An array of `GridTrack` values
1367
+ */
1368
+ gridTemplateRows: GridTrack[];
1369
+ /**
1370
+ * Gets the grid-template-areas property
1371
+ *
1372
+ * Defines named grid areas that can be referenced by grid items.
1373
+ *
1374
+ * @returns - An array of `GridArea` values
1375
+ */
1376
+ gridTemplateAreas: GridArea[];
1377
+ /**
1378
+ * Gets the grid-template-columns property
1379
+ *
1380
+ * Defines the track sizing functions (widths) of the grid columns.
1381
+ *
1382
+ * @returns - An array of `GridTrack` values
1383
+ */
1384
+ gridTemplateColumns: GridTrack[];
1385
+ /**
1386
+ * Gets the grid-template-row-names property
1387
+ *
1388
+ * Defines the named lines between the rows.
1389
+ *
1390
+ * @returns - An array of arrays of line names
1391
+ */
1392
+ gridTemplateRowNames: string[][];
1393
+ /**
1394
+ * Gets the grid-template-column-names property
1395
+ *
1396
+ * Defines the named lines between the columns.
1397
+ *
1398
+ * @returns - An array of arrays of line names
1399
+ */
1400
+ gridTemplateColumnNames: string[][];
1163
1401
  /**
1164
1402
  * Gets the gap
1165
1403
  *
@@ -1824,6 +2062,38 @@ export class TaffyTree {
1824
2062
  setStyle(node: bigint, style: Style): void;
1825
2063
  }
1826
2064
 
2065
+ /**
2066
+ * Text alignment enumeration (for block layout)
2067
+ *
2068
+ * Used by block layout to implement the legacy behaviour of `<center>` and
2069
+ * `<div align="left | right | center">`.
2070
+ *
2071
+ * @example
2072
+ * ```typescript
2073
+ * import { TextAlign } from 'taffy-js';
2074
+ *
2075
+ * style.textAlign = TextAlign.LegacyCenter; // Center block children
2076
+ * ```
2077
+ */
2078
+ export enum TextAlign {
2079
+ /**
2080
+ * No special legacy text align behaviour
2081
+ */
2082
+ Auto = 0,
2083
+ /**
2084
+ * Corresponds to `-webkit-left` or `-moz-left` in browsers
2085
+ */
2086
+ LegacyLeft = 1,
2087
+ /**
2088
+ * Corresponds to `-webkit-right` or `-moz-right` in browsers
2089
+ */
2090
+ LegacyRight = 2,
2091
+ /**
2092
+ * Corresponds to `-webkit-center` or `-moz-center` in browsers
2093
+ */
2094
+ LegacyCenter = 3,
2095
+ }
2096
+
1827
2097
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
1828
2098
 
1829
2099
  export interface InitOutput {
@@ -1866,8 +2136,22 @@ export interface InitOutput {
1866
2136
  readonly style_flexShrink: (a: number) => number;
1867
2137
  readonly style_flexWrap: (a: number) => number;
1868
2138
  readonly style_gap: (a: number) => any;
2139
+ readonly style_gridAutoColumns: (a: number) => any;
2140
+ readonly style_gridAutoFlow: (a: number) => number;
2141
+ readonly style_gridAutoRows: (a: number) => any;
2142
+ readonly style_gridColumn: (a: number) => any;
2143
+ readonly style_gridRow: (a: number) => any;
2144
+ readonly style_gridTemplateAreas: (a: number) => any;
2145
+ readonly style_gridTemplateColumnNames: (a: number) => any;
2146
+ readonly style_gridTemplateColumns: (a: number) => any;
2147
+ readonly style_gridTemplateRowNames: (a: number) => any;
2148
+ readonly style_gridTemplateRows: (a: number) => any;
1869
2149
  readonly style_inset: (a: number) => any;
2150
+ readonly style_itemIsReplaced: (a: number) => number;
2151
+ readonly style_itemIsTable: (a: number) => number;
1870
2152
  readonly style_justifyContent: (a: number) => number;
2153
+ readonly style_justifyItems: (a: number) => number;
2154
+ readonly style_justifySelf: (a: number) => number;
1871
2155
  readonly style_margin: (a: number) => any;
1872
2156
  readonly style_maxSize: (a: number) => any;
1873
2157
  readonly style_minSize: (a: number) => any;
@@ -1875,6 +2159,7 @@ export interface InitOutput {
1875
2159
  readonly style_overflow: (a: number) => any;
1876
2160
  readonly style_padding: (a: number) => any;
1877
2161
  readonly style_position: (a: number) => number;
2162
+ readonly style_scrollbarWidth: (a: number) => number;
1878
2163
  readonly style_set_alignContent: (a: number, b: any) => void;
1879
2164
  readonly style_set_alignItems: (a: number, b: any) => void;
1880
2165
  readonly style_set_alignSelf: (a: number, b: any) => void;
@@ -1888,16 +2173,33 @@ export interface InitOutput {
1888
2173
  readonly style_set_flexShrink: (a: number, b: number) => void;
1889
2174
  readonly style_set_flexWrap: (a: number, b: number) => void;
1890
2175
  readonly style_set_gap: (a: number, b: any) => void;
2176
+ readonly style_set_gridAutoColumns: (a: number, b: any) => void;
2177
+ readonly style_set_gridAutoFlow: (a: number, b: number) => void;
2178
+ readonly style_set_gridAutoRows: (a: number, b: any) => void;
2179
+ readonly style_set_gridColumn: (a: number, b: any) => void;
2180
+ readonly style_set_gridRow: (a: number, b: any) => void;
2181
+ readonly style_set_gridTemplateAreas: (a: number, b: any) => void;
2182
+ readonly style_set_gridTemplateColumnNames: (a: number, b: any) => void;
2183
+ readonly style_set_gridTemplateColumns: (a: number, b: any) => void;
2184
+ readonly style_set_gridTemplateRowNames: (a: number, b: any) => void;
2185
+ readonly style_set_gridTemplateRows: (a: number, b: any) => void;
1891
2186
  readonly style_set_inset: (a: number, b: any) => void;
2187
+ readonly style_set_itemIsReplaced: (a: number, b: number) => void;
2188
+ readonly style_set_itemIsTable: (a: number, b: number) => void;
1892
2189
  readonly style_set_justifyContent: (a: number, b: any) => void;
2190
+ readonly style_set_justifyItems: (a: number, b: any) => void;
2191
+ readonly style_set_justifySelf: (a: number, b: any) => void;
1893
2192
  readonly style_set_margin: (a: number, b: any) => void;
1894
2193
  readonly style_set_maxSize: (a: number, b: any) => void;
1895
2194
  readonly style_set_minSize: (a: number, b: any) => void;
1896
2195
  readonly style_set_overflow: (a: number, b: any) => void;
1897
2196
  readonly style_set_padding: (a: number, b: any) => void;
1898
2197
  readonly style_set_position: (a: number, b: number) => void;
2198
+ readonly style_set_scrollbarWidth: (a: number, b: number) => void;
1899
2199
  readonly style_set_size: (a: number, b: any) => void;
2200
+ readonly style_set_textAlign: (a: number, b: number) => void;
1900
2201
  readonly style_size: (a: number) => any;
2202
+ readonly style_textAlign: (a: number) => number;
1901
2203
  readonly taffyerror_message: (a: number) => [number, number];
1902
2204
  readonly taffytree_addChild: (a: number, b: bigint, c: bigint) => [number, number];
1903
2205
  readonly taffytree_childCount: (a: number, b: bigint) => number;