@websublime/line-components 0.2.1 → 0.2.2
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 +25 -0
- package/custom-elements.json +531 -0
- package/dist/stack/index.d.ts +3 -0
- package/dist/stack/index.d.ts.map +1 -0
- package/dist/stack/index.js +155 -0
- package/dist/stack/index.js.map +1 -0
- package/dist/stack/stack.d.ts +37 -0
- package/dist/stack/stack.d.ts.map +1 -0
- package/dist/stack/stack.types.d.ts +9 -0
- package/dist/stack/stack.types.d.ts.map +1 -0
- package/package.json +5 -1
- package/src/stack/index.ts +3 -0
- package/src/stack/stack.ts +169 -0
- package/src/stack/stack.types.ts +11 -0
package/README.md
CHANGED
|
@@ -6,9 +6,34 @@ that registers one tag, and the root entry registers nothing.
|
|
|
6
6
|
| Subpath | Registers |
|
|
7
7
|
|---------|-----------|
|
|
8
8
|
| `@websublime/line-components/button` | `<line-button>` |
|
|
9
|
+
| `@websublime/line-components/stack` | `<line-stack>` |
|
|
9
10
|
|
|
10
11
|
```js
|
|
11
12
|
import '@websublime/line-components/button';
|
|
12
13
|
```
|
|
13
14
|
|
|
14
15
|
The package ships `custom-elements.json`, the Custom Elements Manifest of every component.
|
|
16
|
+
|
|
17
|
+
## Stack
|
|
18
|
+
|
|
19
|
+
`<line-stack>` lays out its children in one row or one column with a gap between them. The host is the flex
|
|
20
|
+
container, it adds no role, and it exposes no `::part()`; style it directly with `line-stack { … }`.
|
|
21
|
+
|
|
22
|
+
| Attribute | Values | Default |
|
|
23
|
+
|-----------|--------|---------|
|
|
24
|
+
| `orientation` | `vertical`, `horizontal` | `vertical` |
|
|
25
|
+
| `justify` | `start`, `center`, `end`, `spaceBetween`, `spaceAround`, `spaceEvenly`, `stretch` (every item grows) | `start` |
|
|
26
|
+
| `align` | `start`, `center`, `end`, `stretch` | `stretch` |
|
|
27
|
+
| `gap` | `0`–`5` on the `--line-layout-gap-*` scale | step `2` |
|
|
28
|
+
| `wrap` | boolean | off |
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<line-stack orientation="horizontal" justify="spaceBetween" align="center" gap="3">
|
|
32
|
+
<span>Title</span>
|
|
33
|
+
<line-button>Edit</line-button>
|
|
34
|
+
</line-stack>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The gap reads `--line-stack-gap`, so load `@websublime/line-tokens/sizing` and `@websublime/line-tokens/layouts`
|
|
38
|
+
or set `--line-stack-gap` yourself; without them the gap is `0`. For a list, put `role="list"` on the host and
|
|
39
|
+
`role="listitem"` on each child.
|
package/custom-elements.json
CHANGED
|
@@ -1249,6 +1249,537 @@
|
|
|
1249
1249
|
}
|
|
1250
1250
|
]
|
|
1251
1251
|
},
|
|
1252
|
+
{
|
|
1253
|
+
"kind": "javascript-module",
|
|
1254
|
+
"path": "src/stack/index.ts",
|
|
1255
|
+
"declarations": [],
|
|
1256
|
+
"exports": [
|
|
1257
|
+
{
|
|
1258
|
+
"kind": "js",
|
|
1259
|
+
"name": "LineStack",
|
|
1260
|
+
"declaration": {
|
|
1261
|
+
"name": "LineStack",
|
|
1262
|
+
"module": "./stack.js"
|
|
1263
|
+
}
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
"kind": "js",
|
|
1267
|
+
"name": "StackAlign",
|
|
1268
|
+
"declaration": {
|
|
1269
|
+
"name": "StackAlign",
|
|
1270
|
+
"module": "./stack.types.js"
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
"kind": "js",
|
|
1275
|
+
"name": "StackGap",
|
|
1276
|
+
"declaration": {
|
|
1277
|
+
"name": "StackGap",
|
|
1278
|
+
"module": "./stack.types.js"
|
|
1279
|
+
}
|
|
1280
|
+
},
|
|
1281
|
+
{
|
|
1282
|
+
"kind": "js",
|
|
1283
|
+
"name": "StackJustify",
|
|
1284
|
+
"declaration": {
|
|
1285
|
+
"name": "StackJustify",
|
|
1286
|
+
"module": "./stack.types.js"
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
{
|
|
1290
|
+
"kind": "js",
|
|
1291
|
+
"name": "StackOrientation",
|
|
1292
|
+
"declaration": {
|
|
1293
|
+
"name": "StackOrientation",
|
|
1294
|
+
"module": "./stack.types.js"
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
]
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
"kind": "javascript-module",
|
|
1301
|
+
"path": "src/stack/stack.ts",
|
|
1302
|
+
"declarations": [
|
|
1303
|
+
{
|
|
1304
|
+
"kind": "class",
|
|
1305
|
+
"description": "`<line-stack>` lays out its children in one row or one column with a gap\nbetween them. The host is the flex container and the slotted children are\nits flex items. It adds no role, so it stays `generic`; put `role=\"list\"`\non the host and `role=\"listitem\"` on the children to build a list.",
|
|
1306
|
+
"name": "LineStack",
|
|
1307
|
+
"cssProperties": [
|
|
1308
|
+
{
|
|
1309
|
+
"description": "Space between items; `gap=\"0\"` uses `0` and `gap=\"N\"` uses `var(--line-layout-gap-N)`.",
|
|
1310
|
+
"name": "--line-stack-gap",
|
|
1311
|
+
"default": "var(--line-layout-gap-2)"
|
|
1312
|
+
}
|
|
1313
|
+
],
|
|
1314
|
+
"slots": [
|
|
1315
|
+
{
|
|
1316
|
+
"description": "The children; each element becomes a flex item.",
|
|
1317
|
+
"name": ""
|
|
1318
|
+
}
|
|
1319
|
+
],
|
|
1320
|
+
"members": [
|
|
1321
|
+
{
|
|
1322
|
+
"kind": "field",
|
|
1323
|
+
"name": "orientation",
|
|
1324
|
+
"privacy": "public",
|
|
1325
|
+
"type": {
|
|
1326
|
+
"text": "StackOrientation"
|
|
1327
|
+
},
|
|
1328
|
+
"description": "Main axis; an unknown value behaves as `vertical`. A horizontal stack follows the writing direction.",
|
|
1329
|
+
"default": "'vertical'",
|
|
1330
|
+
"attribute": "orientation",
|
|
1331
|
+
"reflects": true
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
"kind": "field",
|
|
1335
|
+
"name": "justify",
|
|
1336
|
+
"privacy": "public",
|
|
1337
|
+
"type": {
|
|
1338
|
+
"text": "StackJustify"
|
|
1339
|
+
},
|
|
1340
|
+
"description": "Distribution on the main axis; `stretch` grows every item. An unknown value behaves as `start`.",
|
|
1341
|
+
"default": "'start'",
|
|
1342
|
+
"attribute": "justify",
|
|
1343
|
+
"reflects": true
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
"kind": "field",
|
|
1347
|
+
"name": "align",
|
|
1348
|
+
"privacy": "public",
|
|
1349
|
+
"type": {
|
|
1350
|
+
"text": "StackAlign"
|
|
1351
|
+
},
|
|
1352
|
+
"description": "Alignment on the cross axis; an unknown value behaves as `stretch`.",
|
|
1353
|
+
"default": "'stretch'",
|
|
1354
|
+
"attribute": "align",
|
|
1355
|
+
"reflects": true
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
"kind": "field",
|
|
1359
|
+
"name": "gap",
|
|
1360
|
+
"privacy": "public",
|
|
1361
|
+
"type": {
|
|
1362
|
+
"text": "StackGap | undefined"
|
|
1363
|
+
},
|
|
1364
|
+
"description": "Gap step from `0` to `5`; `undefined` or an unknown value gives step `2`.",
|
|
1365
|
+
"attribute": "gap",
|
|
1366
|
+
"reflects": true
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
"kind": "field",
|
|
1370
|
+
"name": "wrap",
|
|
1371
|
+
"privacy": "public",
|
|
1372
|
+
"type": {
|
|
1373
|
+
"text": "boolean"
|
|
1374
|
+
},
|
|
1375
|
+
"description": "Lets the items flow onto more lines when they run out of space.",
|
|
1376
|
+
"default": "false",
|
|
1377
|
+
"attribute": "wrap",
|
|
1378
|
+
"reflects": true
|
|
1379
|
+
},
|
|
1380
|
+
{
|
|
1381
|
+
"kind": "field",
|
|
1382
|
+
"name": "properties",
|
|
1383
|
+
"type": {
|
|
1384
|
+
"text": "PropertyDeclarations"
|
|
1385
|
+
},
|
|
1386
|
+
"static": true,
|
|
1387
|
+
"default": "{ direction: { attribute: false, noAccessor: true }, }",
|
|
1388
|
+
"description": "`direction` is reactive but owns its accessor and has no attribute.",
|
|
1389
|
+
"inheritedFrom": {
|
|
1390
|
+
"name": "DirectionMixin",
|
|
1391
|
+
"module": "../line-core/src/mixins/direction.ts"
|
|
1392
|
+
}
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
"kind": "field",
|
|
1396
|
+
"name": "#direction",
|
|
1397
|
+
"privacy": "private",
|
|
1398
|
+
"type": {
|
|
1399
|
+
"text": "Direction"
|
|
1400
|
+
},
|
|
1401
|
+
"default": "'ltr'",
|
|
1402
|
+
"inheritedFrom": {
|
|
1403
|
+
"name": "DirectionMixin",
|
|
1404
|
+
"module": "../line-core/src/mixins/direction.ts"
|
|
1405
|
+
}
|
|
1406
|
+
},
|
|
1407
|
+
{
|
|
1408
|
+
"kind": "field",
|
|
1409
|
+
"name": "#recomputeDirection",
|
|
1410
|
+
"privacy": "private",
|
|
1411
|
+
"readonly": true,
|
|
1412
|
+
"inheritedFrom": {
|
|
1413
|
+
"name": "DirectionMixin",
|
|
1414
|
+
"module": "../line-core/src/mixins/direction.ts"
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
"kind": "field",
|
|
1419
|
+
"name": "direction",
|
|
1420
|
+
"privacy": "public",
|
|
1421
|
+
"type": {
|
|
1422
|
+
"text": "Direction"
|
|
1423
|
+
},
|
|
1424
|
+
"description": "Resolved text direction of the host.",
|
|
1425
|
+
"readonly": true,
|
|
1426
|
+
"inheritedFrom": {
|
|
1427
|
+
"name": "DirectionMixin",
|
|
1428
|
+
"module": "../line-core/src/mixins/direction.ts"
|
|
1429
|
+
}
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
"kind": "field",
|
|
1433
|
+
"name": "version",
|
|
1434
|
+
"type": {
|
|
1435
|
+
"text": "string"
|
|
1436
|
+
},
|
|
1437
|
+
"static": true,
|
|
1438
|
+
"default": "'0.0.0'",
|
|
1439
|
+
"description": "Component semver string. Surfaced by the Inspector as `data-line-version`.",
|
|
1440
|
+
"inheritedFrom": {
|
|
1441
|
+
"name": "LineElement",
|
|
1442
|
+
"module": "../line-core/src/line-element.ts"
|
|
1443
|
+
}
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
"kind": "field",
|
|
1447
|
+
"name": "docs",
|
|
1448
|
+
"type": {
|
|
1449
|
+
"text": "string"
|
|
1450
|
+
},
|
|
1451
|
+
"static": true,
|
|
1452
|
+
"default": "''",
|
|
1453
|
+
"description": "Documentation URL. Surfaced by the Inspector as `data-line-docs` when set.",
|
|
1454
|
+
"inheritedFrom": {
|
|
1455
|
+
"name": "MetadataMixin",
|
|
1456
|
+
"module": "../line-core/src/mixins/metadata.ts"
|
|
1457
|
+
}
|
|
1458
|
+
},
|
|
1459
|
+
{
|
|
1460
|
+
"kind": "field",
|
|
1461
|
+
"name": "qa",
|
|
1462
|
+
"type": {
|
|
1463
|
+
"text": "string[]"
|
|
1464
|
+
},
|
|
1465
|
+
"static": true,
|
|
1466
|
+
"default": "[]",
|
|
1467
|
+
"description": "QA tags for the component.",
|
|
1468
|
+
"inheritedFrom": {
|
|
1469
|
+
"name": "MetadataMixin",
|
|
1470
|
+
"module": "../line-core/src/mixins/metadata.ts"
|
|
1471
|
+
}
|
|
1472
|
+
},
|
|
1473
|
+
{
|
|
1474
|
+
"kind": "field",
|
|
1475
|
+
"name": "scope",
|
|
1476
|
+
"type": {
|
|
1477
|
+
"text": "string"
|
|
1478
|
+
},
|
|
1479
|
+
"static": true,
|
|
1480
|
+
"default": "''",
|
|
1481
|
+
"description": "Component scope identifier.",
|
|
1482
|
+
"inheritedFrom": {
|
|
1483
|
+
"name": "MetadataMixin",
|
|
1484
|
+
"module": "../line-core/src/mixins/metadata.ts"
|
|
1485
|
+
}
|
|
1486
|
+
},
|
|
1487
|
+
{
|
|
1488
|
+
"kind": "field",
|
|
1489
|
+
"name": "#inspectorDialog",
|
|
1490
|
+
"privacy": "private",
|
|
1491
|
+
"type": {
|
|
1492
|
+
"text": "HTMLDialogElement | null"
|
|
1493
|
+
},
|
|
1494
|
+
"default": "null",
|
|
1495
|
+
"description": "Active dialog panel while the inspector is enabled, else `null`.",
|
|
1496
|
+
"inheritedFrom": {
|
|
1497
|
+
"name": "InspectorMixin",
|
|
1498
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1499
|
+
}
|
|
1500
|
+
},
|
|
1501
|
+
{
|
|
1502
|
+
"kind": "field",
|
|
1503
|
+
"name": "#onInspectorKeydown",
|
|
1504
|
+
"privacy": "private",
|
|
1505
|
+
"readonly": true,
|
|
1506
|
+
"description": "Bound keydown handler, retained so it can be removed on disconnect.",
|
|
1507
|
+
"inheritedFrom": {
|
|
1508
|
+
"name": "InspectorMixin",
|
|
1509
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1510
|
+
}
|
|
1511
|
+
},
|
|
1512
|
+
{
|
|
1513
|
+
"kind": "method",
|
|
1514
|
+
"name": "#activateInspector",
|
|
1515
|
+
"privacy": "private",
|
|
1516
|
+
"return": {
|
|
1517
|
+
"type": {
|
|
1518
|
+
"text": "void"
|
|
1519
|
+
}
|
|
1520
|
+
},
|
|
1521
|
+
"description": "Wire activation marker, host metadata attributes, the hotkey, and the\ndev-only hover-outline stylesheet.",
|
|
1522
|
+
"inheritedFrom": {
|
|
1523
|
+
"name": "InspectorMixin",
|
|
1524
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1525
|
+
}
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
"kind": "method",
|
|
1529
|
+
"name": "#deactivateInspector",
|
|
1530
|
+
"privacy": "private",
|
|
1531
|
+
"return": {
|
|
1532
|
+
"type": {
|
|
1533
|
+
"text": "void"
|
|
1534
|
+
}
|
|
1535
|
+
},
|
|
1536
|
+
"description": "Remove the hotkey, tear down the dialog, drop host attributes, and remove\nthe dev-only hover-outline sheet so the active path leaks nothing.",
|
|
1537
|
+
"inheritedFrom": {
|
|
1538
|
+
"name": "InspectorMixin",
|
|
1539
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1540
|
+
}
|
|
1541
|
+
},
|
|
1542
|
+
{
|
|
1543
|
+
"kind": "method",
|
|
1544
|
+
"name": "#inspectorRoot",
|
|
1545
|
+
"privacy": "private",
|
|
1546
|
+
"return": {
|
|
1547
|
+
"type": {
|
|
1548
|
+
"text": "ShadowRoot | null"
|
|
1549
|
+
}
|
|
1550
|
+
},
|
|
1551
|
+
"description": "The shadow root that carries `adoptedStyleSheets`, or `null`.",
|
|
1552
|
+
"inheritedFrom": {
|
|
1553
|
+
"name": "InspectorMixin",
|
|
1554
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1555
|
+
}
|
|
1556
|
+
},
|
|
1557
|
+
{
|
|
1558
|
+
"kind": "method",
|
|
1559
|
+
"name": "#adoptInspectorOutline",
|
|
1560
|
+
"privacy": "private",
|
|
1561
|
+
"return": {
|
|
1562
|
+
"type": {
|
|
1563
|
+
"text": "void"
|
|
1564
|
+
}
|
|
1565
|
+
},
|
|
1566
|
+
"description": "Append the singleton hover-outline sheet to the shadow root's\n`adoptedStyleSheets` (idempotent — never duplicated, never replaces the\narray). No-op when the sheet or root is unavailable.",
|
|
1567
|
+
"inheritedFrom": {
|
|
1568
|
+
"name": "InspectorMixin",
|
|
1569
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1570
|
+
}
|
|
1571
|
+
},
|
|
1572
|
+
{
|
|
1573
|
+
"kind": "method",
|
|
1574
|
+
"name": "#releaseInspectorOutline",
|
|
1575
|
+
"privacy": "private",
|
|
1576
|
+
"return": {
|
|
1577
|
+
"type": {
|
|
1578
|
+
"text": "void"
|
|
1579
|
+
}
|
|
1580
|
+
},
|
|
1581
|
+
"description": "Remove the singleton hover-outline sheet from the shadow root's\n`adoptedStyleSheets`, preserving every other adopted sheet.",
|
|
1582
|
+
"inheritedFrom": {
|
|
1583
|
+
"name": "InspectorMixin",
|
|
1584
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1585
|
+
}
|
|
1586
|
+
},
|
|
1587
|
+
{
|
|
1588
|
+
"kind": "method",
|
|
1589
|
+
"name": "#inspectorVersion",
|
|
1590
|
+
"privacy": "private",
|
|
1591
|
+
"return": {
|
|
1592
|
+
"type": {
|
|
1593
|
+
"text": "string"
|
|
1594
|
+
}
|
|
1595
|
+
},
|
|
1596
|
+
"description": "Read the host's static `version`, defaulting to `''` when absent.",
|
|
1597
|
+
"inheritedFrom": {
|
|
1598
|
+
"name": "InspectorMixin",
|
|
1599
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1600
|
+
}
|
|
1601
|
+
},
|
|
1602
|
+
{
|
|
1603
|
+
"kind": "method",
|
|
1604
|
+
"name": "#inspectorDocs",
|
|
1605
|
+
"privacy": "private",
|
|
1606
|
+
"return": {
|
|
1607
|
+
"type": {
|
|
1608
|
+
"text": "string"
|
|
1609
|
+
}
|
|
1610
|
+
},
|
|
1611
|
+
"description": "Read the host's static `docs` URL defensively (D3 may not provide one).",
|
|
1612
|
+
"inheritedFrom": {
|
|
1613
|
+
"name": "InspectorMixin",
|
|
1614
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1615
|
+
}
|
|
1616
|
+
},
|
|
1617
|
+
{
|
|
1618
|
+
"kind": "method",
|
|
1619
|
+
"name": "#toggleInspectorPanel",
|
|
1620
|
+
"privacy": "private",
|
|
1621
|
+
"return": {
|
|
1622
|
+
"type": {
|
|
1623
|
+
"text": "void"
|
|
1624
|
+
}
|
|
1625
|
+
},
|
|
1626
|
+
"description": "Open the panel if closed, close it if already open.",
|
|
1627
|
+
"inheritedFrom": {
|
|
1628
|
+
"name": "InspectorMixin",
|
|
1629
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1630
|
+
}
|
|
1631
|
+
},
|
|
1632
|
+
{
|
|
1633
|
+
"kind": "method",
|
|
1634
|
+
"name": "#openInspectorPanel",
|
|
1635
|
+
"privacy": "private",
|
|
1636
|
+
"return": {
|
|
1637
|
+
"type": {
|
|
1638
|
+
"text": "void"
|
|
1639
|
+
}
|
|
1640
|
+
},
|
|
1641
|
+
"description": "Build (once) and open the `<dialog>` metadata panel in the shadow root.",
|
|
1642
|
+
"inheritedFrom": {
|
|
1643
|
+
"name": "InspectorMixin",
|
|
1644
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1645
|
+
}
|
|
1646
|
+
},
|
|
1647
|
+
{
|
|
1648
|
+
"kind": "field",
|
|
1649
|
+
"name": "#internals",
|
|
1650
|
+
"privacy": "private",
|
|
1651
|
+
"type": {
|
|
1652
|
+
"text": "ElementInternals"
|
|
1653
|
+
},
|
|
1654
|
+
"inheritedFrom": {
|
|
1655
|
+
"name": "LineElement",
|
|
1656
|
+
"module": "../line-core/src/line-element.ts"
|
|
1657
|
+
}
|
|
1658
|
+
},
|
|
1659
|
+
{
|
|
1660
|
+
"kind": "field",
|
|
1661
|
+
"name": "[INTERNALS]",
|
|
1662
|
+
"type": {
|
|
1663
|
+
"text": "ElementInternals"
|
|
1664
|
+
},
|
|
1665
|
+
"privacy": "protected",
|
|
1666
|
+
"description": "The element's `ElementInternals`, attached once in the constructor (spec §6.C.2, SD19).",
|
|
1667
|
+
"readonly": true,
|
|
1668
|
+
"inheritedFrom": {
|
|
1669
|
+
"name": "LineElement",
|
|
1670
|
+
"module": "../line-core/src/line-element.ts"
|
|
1671
|
+
}
|
|
1672
|
+
},
|
|
1673
|
+
{
|
|
1674
|
+
"kind": "method",
|
|
1675
|
+
"name": "reflectState",
|
|
1676
|
+
"privacy": "protected",
|
|
1677
|
+
"return": {
|
|
1678
|
+
"type": {
|
|
1679
|
+
"text": "void"
|
|
1680
|
+
}
|
|
1681
|
+
},
|
|
1682
|
+
"parameters": [
|
|
1683
|
+
{
|
|
1684
|
+
"name": "name",
|
|
1685
|
+
"type": {
|
|
1686
|
+
"text": "string"
|
|
1687
|
+
}
|
|
1688
|
+
},
|
|
1689
|
+
{
|
|
1690
|
+
"name": "active",
|
|
1691
|
+
"type": {
|
|
1692
|
+
"text": "boolean"
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
],
|
|
1696
|
+
"description": "Reflects machine state `name` on the host as the attribute `data-<name>`\nand the custom state `:state(<name>)`, both verbatim, so a kebab-case name\nsuch as `focus-visible` keeps its spelling. The custom state is skipped\nwhere the internals have no `states`.",
|
|
1697
|
+
"inheritedFrom": {
|
|
1698
|
+
"name": "LineElement",
|
|
1699
|
+
"module": "../line-core/src/line-element.ts"
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
],
|
|
1703
|
+
"attributes": [
|
|
1704
|
+
{
|
|
1705
|
+
"name": "orientation",
|
|
1706
|
+
"type": {
|
|
1707
|
+
"text": "StackOrientation"
|
|
1708
|
+
},
|
|
1709
|
+
"description": "Main axis; an unknown value behaves as `vertical`. A horizontal stack follows the writing direction.",
|
|
1710
|
+
"default": "'vertical'",
|
|
1711
|
+
"fieldName": "orientation"
|
|
1712
|
+
},
|
|
1713
|
+
{
|
|
1714
|
+
"name": "justify",
|
|
1715
|
+
"type": {
|
|
1716
|
+
"text": "StackJustify"
|
|
1717
|
+
},
|
|
1718
|
+
"description": "Distribution on the main axis; `stretch` grows every item. An unknown value behaves as `start`.",
|
|
1719
|
+
"default": "'start'",
|
|
1720
|
+
"fieldName": "justify"
|
|
1721
|
+
},
|
|
1722
|
+
{
|
|
1723
|
+
"name": "align",
|
|
1724
|
+
"type": {
|
|
1725
|
+
"text": "StackAlign"
|
|
1726
|
+
},
|
|
1727
|
+
"description": "Alignment on the cross axis; an unknown value behaves as `stretch`.",
|
|
1728
|
+
"default": "'stretch'",
|
|
1729
|
+
"fieldName": "align"
|
|
1730
|
+
},
|
|
1731
|
+
{
|
|
1732
|
+
"name": "gap",
|
|
1733
|
+
"type": {
|
|
1734
|
+
"text": "StackGap | undefined"
|
|
1735
|
+
},
|
|
1736
|
+
"description": "Gap step from `0` to `5`; `undefined` or an unknown value gives step `2`.",
|
|
1737
|
+
"fieldName": "gap"
|
|
1738
|
+
},
|
|
1739
|
+
{
|
|
1740
|
+
"name": "wrap",
|
|
1741
|
+
"type": {
|
|
1742
|
+
"text": "boolean"
|
|
1743
|
+
},
|
|
1744
|
+
"description": "Lets the items flow onto more lines when they run out of space.",
|
|
1745
|
+
"default": "false",
|
|
1746
|
+
"fieldName": "wrap"
|
|
1747
|
+
}
|
|
1748
|
+
],
|
|
1749
|
+
"superclass": {
|
|
1750
|
+
"name": "LineElement",
|
|
1751
|
+
"package": "@websublime/line-core"
|
|
1752
|
+
},
|
|
1753
|
+
"summary": "A layout container that places its children in one row or column with even spacing.",
|
|
1754
|
+
"tagName": "line-stack",
|
|
1755
|
+
"customElement": true
|
|
1756
|
+
}
|
|
1757
|
+
],
|
|
1758
|
+
"exports": [
|
|
1759
|
+
{
|
|
1760
|
+
"kind": "js",
|
|
1761
|
+
"name": "LineStack",
|
|
1762
|
+
"declaration": {
|
|
1763
|
+
"name": "LineStack",
|
|
1764
|
+
"module": "src/stack/stack.ts"
|
|
1765
|
+
}
|
|
1766
|
+
},
|
|
1767
|
+
{
|
|
1768
|
+
"kind": "custom-element-definition",
|
|
1769
|
+
"name": "line-stack",
|
|
1770
|
+
"declaration": {
|
|
1771
|
+
"name": "LineStack",
|
|
1772
|
+
"module": "src/stack/stack.ts"
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
]
|
|
1776
|
+
},
|
|
1777
|
+
{
|
|
1778
|
+
"kind": "javascript-module",
|
|
1779
|
+
"path": "src/stack/stack.types.ts",
|
|
1780
|
+
"declarations": [],
|
|
1781
|
+
"exports": []
|
|
1782
|
+
},
|
|
1252
1783
|
{
|
|
1253
1784
|
"kind": "javascript-module",
|
|
1254
1785
|
"path": "../line-core/src/form-associated.ts",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stack/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { LineElement as e } from "@websublime/line-core";
|
|
2
|
+
import { commonReset as t } from "@websublime/line-core/styles";
|
|
3
|
+
import { css as n, html as r } from "lit";
|
|
4
|
+
//#region src/stack/stack.ts
|
|
5
|
+
var i = ["horizontal", "vertical"], a = [
|
|
6
|
+
"start",
|
|
7
|
+
"center",
|
|
8
|
+
"end",
|
|
9
|
+
"spaceBetween",
|
|
10
|
+
"spaceAround",
|
|
11
|
+
"spaceEvenly",
|
|
12
|
+
"stretch"
|
|
13
|
+
], o = [
|
|
14
|
+
"start",
|
|
15
|
+
"center",
|
|
16
|
+
"end",
|
|
17
|
+
"stretch"
|
|
18
|
+
], s = [
|
|
19
|
+
"0",
|
|
20
|
+
"1",
|
|
21
|
+
"2",
|
|
22
|
+
"3",
|
|
23
|
+
"4",
|
|
24
|
+
"5"
|
|
25
|
+
];
|
|
26
|
+
function c(e, t) {
|
|
27
|
+
return { fromAttribute: (n) => e.find((e) => e === n) ?? t };
|
|
28
|
+
}
|
|
29
|
+
var l = { fromAttribute: (e) => s.find((t) => t === e) }, u = class extends e {
|
|
30
|
+
static {
|
|
31
|
+
this.properties = {
|
|
32
|
+
orientation: {
|
|
33
|
+
reflect: !0,
|
|
34
|
+
useDefault: !0,
|
|
35
|
+
converter: c(i, "vertical")
|
|
36
|
+
},
|
|
37
|
+
justify: {
|
|
38
|
+
reflect: !0,
|
|
39
|
+
useDefault: !0,
|
|
40
|
+
converter: c(a, "start")
|
|
41
|
+
},
|
|
42
|
+
align: {
|
|
43
|
+
reflect: !0,
|
|
44
|
+
useDefault: !0,
|
|
45
|
+
converter: c(o, "stretch")
|
|
46
|
+
},
|
|
47
|
+
gap: {
|
|
48
|
+
reflect: !0,
|
|
49
|
+
converter: l
|
|
50
|
+
},
|
|
51
|
+
wrap: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
reflect: !0,
|
|
54
|
+
useDefault: !0
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
static {
|
|
59
|
+
this.styles = [t, n`
|
|
60
|
+
:host {
|
|
61
|
+
--line-stack-gap: var(--line-layout-gap-2);
|
|
62
|
+
|
|
63
|
+
display: flex;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
justify-content: flex-start;
|
|
66
|
+
align-items: stretch;
|
|
67
|
+
flex-wrap: nowrap;
|
|
68
|
+
gap: var(--line-stack-gap);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([hidden]) {
|
|
72
|
+
display: none;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:host([orientation='horizontal']) {
|
|
76
|
+
flex-direction: row;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
:host([justify='center']) {
|
|
80
|
+
justify-content: center;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host([justify='end']) {
|
|
84
|
+
justify-content: flex-end;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:host([justify='spaceBetween']) {
|
|
88
|
+
justify-content: space-between;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:host([justify='spaceAround']) {
|
|
92
|
+
justify-content: space-around;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:host([justify='spaceEvenly']) {
|
|
96
|
+
justify-content: space-evenly;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host([justify='stretch']) ::slotted(*) {
|
|
100
|
+
flex-grow: 1;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:host([align='start']) {
|
|
104
|
+
align-items: flex-start;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host([align='center']) {
|
|
108
|
+
align-items: center;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:host([align='end']) {
|
|
112
|
+
align-items: flex-end;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:host([wrap]) {
|
|
116
|
+
flex-wrap: wrap;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
:host([gap='0']) {
|
|
120
|
+
--line-stack-gap: 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
:host([gap='1']) {
|
|
124
|
+
--line-stack-gap: var(--line-layout-gap-1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:host([gap='2']) {
|
|
128
|
+
--line-stack-gap: var(--line-layout-gap-2);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:host([gap='3']) {
|
|
132
|
+
--line-stack-gap: var(--line-layout-gap-3);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
:host([gap='4']) {
|
|
136
|
+
--line-stack-gap: var(--line-layout-gap-4);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
:host([gap='5']) {
|
|
140
|
+
--line-stack-gap: var(--line-layout-gap-5);
|
|
141
|
+
}
|
|
142
|
+
`];
|
|
143
|
+
}
|
|
144
|
+
constructor() {
|
|
145
|
+
super(), this.orientation = "vertical", this.justify = "start", this.align = "stretch", this.wrap = !1;
|
|
146
|
+
}
|
|
147
|
+
render() {
|
|
148
|
+
return r`<slot></slot>`;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
customElements.define("line-stack", u);
|
|
152
|
+
//#endregion
|
|
153
|
+
export { u as LineStack };
|
|
154
|
+
|
|
155
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ORIENTATIONS","JUSTIFIES","ALIGNS","GAPS","enumConverter","values","entry","value","fallback","gapConverter","gap","LineStack","LineElement","commonReset"],"sources":["../../src/stack/stack.ts"],"sourcesContent":["import { LineElement } from '@websublime/line-core';\nimport { commonReset } from '@websublime/line-core/styles';\nimport { type ComplexAttributeConverter, css, html, type PropertyDeclarations, type TemplateResult } from 'lit';\nimport type { StackAlign, StackGap, StackJustify, StackOrientation } from './stack.types.js';\n\nconst ORIENTATIONS: readonly StackOrientation[] = ['horizontal', 'vertical'];\nconst JUSTIFIES: readonly StackJustify[] = [\n 'start',\n 'center',\n 'end',\n 'spaceBetween',\n 'spaceAround',\n 'spaceEvenly',\n 'stretch',\n];\nconst ALIGNS: readonly StackAlign[] = ['start', 'center', 'end', 'stretch'];\nconst GAPS: readonly StackGap[] = ['0', '1', '2', '3', '4', '5'];\n\n/** An unknown value behaves as `fallback`; the attribute keeps what the author wrote. */\nfunction enumConverter<T extends string>(values: readonly T[], fallback: T): ComplexAttributeConverter<T> {\n return { fromAttribute: (value) => values.find((entry) => entry === value) ?? fallback };\n}\n\n/** An unknown `gap` behaves as no attribute, so the default step applies. */\nconst gapConverter: ComplexAttributeConverter<StackGap | undefined> = {\n fromAttribute: (value) => GAPS.find((gap) => gap === value),\n};\n\n/**\n * `<line-stack>` lays out its children in one row or one column with a gap\n * between them. The host is the flex container and the slotted children are\n * its flex items. It adds no role, so it stays `generic`; put `role=\"list\"`\n * on the host and `role=\"listitem\"` on the children to build a list.\n *\n * @summary A layout container that places its children in one row or column with even spacing.\n *\n * @slot - The children; each element becomes a flex item.\n *\n * @cssprop [--line-stack-gap=var(--line-layout-gap-2)] - Space between items; `gap=\"0\"` uses `0` and `gap=\"N\"` uses `var(--line-layout-gap-N)`.\n */\nexport class LineStack extends LineElement {\n static override properties: PropertyDeclarations = {\n orientation: { reflect: true, useDefault: true, converter: enumConverter(ORIENTATIONS, 'vertical') },\n justify: { reflect: true, useDefault: true, converter: enumConverter(JUSTIFIES, 'start') },\n align: { reflect: true, useDefault: true, converter: enumConverter(ALIGNS, 'stretch') },\n gap: { reflect: true, converter: gapConverter },\n wrap: { type: Boolean, reflect: true, useDefault: true },\n };\n\n static override styles = [\n commonReset,\n css`\n :host {\n --line-stack-gap: var(--line-layout-gap-2);\n\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: stretch;\n flex-wrap: nowrap;\n gap: var(--line-stack-gap);\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host([orientation='horizontal']) {\n flex-direction: row;\n }\n\n :host([justify='center']) {\n justify-content: center;\n }\n\n :host([justify='end']) {\n justify-content: flex-end;\n }\n\n :host([justify='spaceBetween']) {\n justify-content: space-between;\n }\n\n :host([justify='spaceAround']) {\n justify-content: space-around;\n }\n\n :host([justify='spaceEvenly']) {\n justify-content: space-evenly;\n }\n\n :host([justify='stretch']) ::slotted(*) {\n flex-grow: 1;\n }\n\n :host([align='start']) {\n align-items: flex-start;\n }\n\n :host([align='center']) {\n align-items: center;\n }\n\n :host([align='end']) {\n align-items: flex-end;\n }\n\n :host([wrap]) {\n flex-wrap: wrap;\n }\n\n :host([gap='0']) {\n --line-stack-gap: 0;\n }\n\n :host([gap='1']) {\n --line-stack-gap: var(--line-layout-gap-1);\n }\n\n :host([gap='2']) {\n --line-stack-gap: var(--line-layout-gap-2);\n }\n\n :host([gap='3']) {\n --line-stack-gap: var(--line-layout-gap-3);\n }\n\n :host([gap='4']) {\n --line-stack-gap: var(--line-layout-gap-4);\n }\n\n :host([gap='5']) {\n --line-stack-gap: var(--line-layout-gap-5);\n }\n `,\n ];\n\n /** Main axis; an unknown value behaves as `vertical`. A horizontal stack follows the writing direction. */\n declare orientation: StackOrientation;\n /** Distribution on the main axis; `stretch` grows every item. An unknown value behaves as `start`. */\n declare justify: StackJustify;\n /** Alignment on the cross axis; an unknown value behaves as `stretch`. */\n declare align: StackAlign;\n /** Gap step from `0` to `5`; `undefined` or an unknown value gives step `2`. */\n declare gap: StackGap | undefined;\n /** Lets the items flow onto more lines when they run out of space. */\n declare wrap: boolean;\n\n constructor() {\n super();\n // `useDefault` keeps these initial values out of the attributes, so an unknown author value stays (C8).\n this.orientation = 'vertical';\n this.justify = 'start';\n this.align = 'stretch';\n this.wrap = false;\n }\n\n override render(): TemplateResult {\n return html`<slot></slot>`;\n }\n}\n\ncustomElements.define('line-stack', LineStack);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'line-stack': LineStack;\n }\n}\n"],"mappings":";;;;AAKA,IAAMA,IAA4C,CAAC,cAAc,UAAU,GACrEC,IAAqC;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GACMC,IAAgC;CAAC;CAAS;CAAU;CAAO;AAAS,GACpEC,IAA4B;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG;AAG/D,SAASC,EAAgC,GAAsB,GAA2C;CACxG,OAAO,EAAE,gBAAgB,MAAUC,EAAO,MAAM,MAAUC,MAAUC,CAAK,KAAKC,EAAS;AACzF;AAGA,IAAMC,IAAgE,EACpE,gBAAgB,MAAUN,EAAK,MAAM,MAAQO,MAAQH,CAAK,EAC5D,GAcaI,IAAb,cAA+BC,EAAY;;EACU,KAAA,aAAA;GACjD,aAAa;IAAE,SAAS;IAAM,YAAY;IAAM,WAAWR,EAAcJ,GAAc,UAAU;GAAE;GACnG,SAAS;IAAE,SAAS;IAAM,YAAY;IAAM,WAAWI,EAAcH,GAAW,OAAO;GAAE;GACzF,OAAO;IAAE,SAAS;IAAM,YAAY;IAAM,WAAWG,EAAcF,GAAQ,SAAS;GAAE;GACtF,KAAK;IAAE,SAAS;IAAM,WAAWO;GAAa;GAC9C,MAAM;IAAE,MAAM;IAAS,SAAS;IAAM,YAAY;GAAK;EACzD;;;EAEyB,KAAA,SAAA,CACvBI,GACA,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoFL;;CAaA,cAAc;EAMZ,AALA,MAAM,GAEN,KAAK,cAAc,YACnB,KAAK,UAAU,SACf,KAAK,QAAQ,WACb,KAAK,OAAO;CACd;CAEA,SAAkC;EAChC,OAAO,CAAI;CACb;AACF;AAEA,eAAe,OAAO,cAAcF,CAAS"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LineElement } from '@websublime/line-core';
|
|
2
|
+
import { type PropertyDeclarations, type TemplateResult } from 'lit';
|
|
3
|
+
import type { StackAlign, StackGap, StackJustify, StackOrientation } from './stack.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* `<line-stack>` lays out its children in one row or one column with a gap
|
|
6
|
+
* between them. The host is the flex container and the slotted children are
|
|
7
|
+
* its flex items. It adds no role, so it stays `generic`; put `role="list"`
|
|
8
|
+
* on the host and `role="listitem"` on the children to build a list.
|
|
9
|
+
*
|
|
10
|
+
* @summary A layout container that places its children in one row or column with even spacing.
|
|
11
|
+
*
|
|
12
|
+
* @slot - The children; each element becomes a flex item.
|
|
13
|
+
*
|
|
14
|
+
* @cssprop [--line-stack-gap=var(--line-layout-gap-2)] - Space between items; `gap="0"` uses `0` and `gap="N"` uses `var(--line-layout-gap-N)`.
|
|
15
|
+
*/
|
|
16
|
+
export declare class LineStack extends LineElement {
|
|
17
|
+
static properties: PropertyDeclarations;
|
|
18
|
+
static styles: (import("lit").CSSResult | CSSStyleSheet)[];
|
|
19
|
+
/** Main axis; an unknown value behaves as `vertical`. A horizontal stack follows the writing direction. */
|
|
20
|
+
orientation: StackOrientation;
|
|
21
|
+
/** Distribution on the main axis; `stretch` grows every item. An unknown value behaves as `start`. */
|
|
22
|
+
justify: StackJustify;
|
|
23
|
+
/** Alignment on the cross axis; an unknown value behaves as `stretch`. */
|
|
24
|
+
align: StackAlign;
|
|
25
|
+
/** Gap step from `0` to `5`; `undefined` or an unknown value gives step `2`. */
|
|
26
|
+
gap: StackGap | undefined;
|
|
27
|
+
/** Lets the items flow onto more lines when they run out of space. */
|
|
28
|
+
wrap: boolean;
|
|
29
|
+
constructor();
|
|
30
|
+
render(): TemplateResult;
|
|
31
|
+
}
|
|
32
|
+
declare global {
|
|
33
|
+
interface HTMLElementTagNameMap {
|
|
34
|
+
'line-stack': LineStack;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=stack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../src/stack/stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAA6C,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAChH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAyB7F;;;;;;;;;;;GAWG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC,OAAgB,UAAU,EAAE,oBAAoB,CAM9C;IAEF,OAAgB,MAAM,8CAsFpB;IAEF,2GAA2G;IACnG,WAAW,EAAE,gBAAgB,CAAC;IACtC,sGAAsG;IAC9F,OAAO,EAAE,YAAY,CAAC;IAC9B,0EAA0E;IAClE,KAAK,EAAE,UAAU,CAAC;IAC1B,gFAAgF;IACxE,GAAG,EAAE,QAAQ,GAAG,SAAS,CAAC;IAClC,sEAAsE;IAC9D,IAAI,EAAE,OAAO,CAAC;IAEtB,cAOC;IAEQ,MAAM,IAAI,cAAc,CAEhC;CACF;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,YAAY,EAAE,SAAS,CAAC;KACzB;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Main axis of `<line-stack>`; the A2UI basic v0.9 `List.direction` values. */
|
|
2
|
+
export type StackOrientation = 'horizontal' | 'vertical';
|
|
3
|
+
/** Main-axis distribution of `<line-stack>`; the A2UI basic v0.9 `justify` values. */
|
|
4
|
+
export type StackJustify = 'start' | 'center' | 'end' | 'spaceBetween' | 'spaceAround' | 'spaceEvenly' | 'stretch';
|
|
5
|
+
/** Cross-axis alignment of `<line-stack>`; the A2UI basic v0.9 `align` values without `baseline`. */
|
|
6
|
+
export type StackAlign = 'start' | 'center' | 'end' | 'stretch';
|
|
7
|
+
/** Gap step of `<line-stack>` on the `--line-layout-gap-*` scale (ARCH §17.2 C6). */
|
|
8
|
+
export type StackGap = '0' | '1' | '2' | '3' | '4' | '5';
|
|
9
|
+
//# sourceMappingURL=stack.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack.types.d.ts","sourceRoot":"","sources":["../../src/stack/stack.types.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,UAAU,CAAC;AAEzD,sFAAsF;AACtF,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,cAAc,GAAG,aAAa,GAAG,aAAa,GAAG,SAAS,CAAC;AAEnH,qGAAqG;AACrG,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AAEhE,qFAAqF;AACrF,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websublime/line-components",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
"./button": {
|
|
27
27
|
"types": "./dist/button/index.d.ts",
|
|
28
28
|
"import": "./dist/button/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./stack": {
|
|
31
|
+
"types": "./dist/stack/index.d.ts",
|
|
32
|
+
"import": "./dist/stack/index.js"
|
|
29
33
|
}
|
|
30
34
|
},
|
|
31
35
|
"dependencies": {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// biome-ignore lint/performance/noBarrelFile: the `./stack` subpath entry registers `line-stack` and exposes its class and types (spec 0018-stack.md Bundle).
|
|
2
|
+
export { LineStack } from './stack.js';
|
|
3
|
+
export type { StackAlign, StackGap, StackJustify, StackOrientation } from './stack.types.js';
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { LineElement } from '@websublime/line-core';
|
|
2
|
+
import { commonReset } from '@websublime/line-core/styles';
|
|
3
|
+
import { type ComplexAttributeConverter, css, html, type PropertyDeclarations, type TemplateResult } from 'lit';
|
|
4
|
+
import type { StackAlign, StackGap, StackJustify, StackOrientation } from './stack.types.js';
|
|
5
|
+
|
|
6
|
+
const ORIENTATIONS: readonly StackOrientation[] = ['horizontal', 'vertical'];
|
|
7
|
+
const JUSTIFIES: readonly StackJustify[] = [
|
|
8
|
+
'start',
|
|
9
|
+
'center',
|
|
10
|
+
'end',
|
|
11
|
+
'spaceBetween',
|
|
12
|
+
'spaceAround',
|
|
13
|
+
'spaceEvenly',
|
|
14
|
+
'stretch',
|
|
15
|
+
];
|
|
16
|
+
const ALIGNS: readonly StackAlign[] = ['start', 'center', 'end', 'stretch'];
|
|
17
|
+
const GAPS: readonly StackGap[] = ['0', '1', '2', '3', '4', '5'];
|
|
18
|
+
|
|
19
|
+
/** An unknown value behaves as `fallback`; the attribute keeps what the author wrote. */
|
|
20
|
+
function enumConverter<T extends string>(values: readonly T[], fallback: T): ComplexAttributeConverter<T> {
|
|
21
|
+
return { fromAttribute: (value) => values.find((entry) => entry === value) ?? fallback };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** An unknown `gap` behaves as no attribute, so the default step applies. */
|
|
25
|
+
const gapConverter: ComplexAttributeConverter<StackGap | undefined> = {
|
|
26
|
+
fromAttribute: (value) => GAPS.find((gap) => gap === value),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* `<line-stack>` lays out its children in one row or one column with a gap
|
|
31
|
+
* between them. The host is the flex container and the slotted children are
|
|
32
|
+
* its flex items. It adds no role, so it stays `generic`; put `role="list"`
|
|
33
|
+
* on the host and `role="listitem"` on the children to build a list.
|
|
34
|
+
*
|
|
35
|
+
* @summary A layout container that places its children in one row or column with even spacing.
|
|
36
|
+
*
|
|
37
|
+
* @slot - The children; each element becomes a flex item.
|
|
38
|
+
*
|
|
39
|
+
* @cssprop [--line-stack-gap=var(--line-layout-gap-2)] - Space between items; `gap="0"` uses `0` and `gap="N"` uses `var(--line-layout-gap-N)`.
|
|
40
|
+
*/
|
|
41
|
+
export class LineStack extends LineElement {
|
|
42
|
+
static override properties: PropertyDeclarations = {
|
|
43
|
+
orientation: { reflect: true, useDefault: true, converter: enumConverter(ORIENTATIONS, 'vertical') },
|
|
44
|
+
justify: { reflect: true, useDefault: true, converter: enumConverter(JUSTIFIES, 'start') },
|
|
45
|
+
align: { reflect: true, useDefault: true, converter: enumConverter(ALIGNS, 'stretch') },
|
|
46
|
+
gap: { reflect: true, converter: gapConverter },
|
|
47
|
+
wrap: { type: Boolean, reflect: true, useDefault: true },
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
static override styles = [
|
|
51
|
+
commonReset,
|
|
52
|
+
css`
|
|
53
|
+
:host {
|
|
54
|
+
--line-stack-gap: var(--line-layout-gap-2);
|
|
55
|
+
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
justify-content: flex-start;
|
|
59
|
+
align-items: stretch;
|
|
60
|
+
flex-wrap: nowrap;
|
|
61
|
+
gap: var(--line-stack-gap);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
:host([hidden]) {
|
|
65
|
+
display: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:host([orientation='horizontal']) {
|
|
69
|
+
flex-direction: row;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
:host([justify='center']) {
|
|
73
|
+
justify-content: center;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host([justify='end']) {
|
|
77
|
+
justify-content: flex-end;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:host([justify='spaceBetween']) {
|
|
81
|
+
justify-content: space-between;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
:host([justify='spaceAround']) {
|
|
85
|
+
justify-content: space-around;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:host([justify='spaceEvenly']) {
|
|
89
|
+
justify-content: space-evenly;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
:host([justify='stretch']) ::slotted(*) {
|
|
93
|
+
flex-grow: 1;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:host([align='start']) {
|
|
97
|
+
align-items: flex-start;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
:host([align='center']) {
|
|
101
|
+
align-items: center;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
:host([align='end']) {
|
|
105
|
+
align-items: flex-end;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
:host([wrap]) {
|
|
109
|
+
flex-wrap: wrap;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
:host([gap='0']) {
|
|
113
|
+
--line-stack-gap: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:host([gap='1']) {
|
|
117
|
+
--line-stack-gap: var(--line-layout-gap-1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
:host([gap='2']) {
|
|
121
|
+
--line-stack-gap: var(--line-layout-gap-2);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
:host([gap='3']) {
|
|
125
|
+
--line-stack-gap: var(--line-layout-gap-3);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
:host([gap='4']) {
|
|
129
|
+
--line-stack-gap: var(--line-layout-gap-4);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:host([gap='5']) {
|
|
133
|
+
--line-stack-gap: var(--line-layout-gap-5);
|
|
134
|
+
}
|
|
135
|
+
`,
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
/** Main axis; an unknown value behaves as `vertical`. A horizontal stack follows the writing direction. */
|
|
139
|
+
declare orientation: StackOrientation;
|
|
140
|
+
/** Distribution on the main axis; `stretch` grows every item. An unknown value behaves as `start`. */
|
|
141
|
+
declare justify: StackJustify;
|
|
142
|
+
/** Alignment on the cross axis; an unknown value behaves as `stretch`. */
|
|
143
|
+
declare align: StackAlign;
|
|
144
|
+
/** Gap step from `0` to `5`; `undefined` or an unknown value gives step `2`. */
|
|
145
|
+
declare gap: StackGap | undefined;
|
|
146
|
+
/** Lets the items flow onto more lines when they run out of space. */
|
|
147
|
+
declare wrap: boolean;
|
|
148
|
+
|
|
149
|
+
constructor() {
|
|
150
|
+
super();
|
|
151
|
+
// `useDefault` keeps these initial values out of the attributes, so an unknown author value stays (C8).
|
|
152
|
+
this.orientation = 'vertical';
|
|
153
|
+
this.justify = 'start';
|
|
154
|
+
this.align = 'stretch';
|
|
155
|
+
this.wrap = false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
override render(): TemplateResult {
|
|
159
|
+
return html`<slot></slot>`;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
customElements.define('line-stack', LineStack);
|
|
164
|
+
|
|
165
|
+
declare global {
|
|
166
|
+
interface HTMLElementTagNameMap {
|
|
167
|
+
'line-stack': LineStack;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Main axis of `<line-stack>`; the A2UI basic v0.9 `List.direction` values. */
|
|
2
|
+
export type StackOrientation = 'horizontal' | 'vertical';
|
|
3
|
+
|
|
4
|
+
/** Main-axis distribution of `<line-stack>`; the A2UI basic v0.9 `justify` values. */
|
|
5
|
+
export type StackJustify = 'start' | 'center' | 'end' | 'spaceBetween' | 'spaceAround' | 'spaceEvenly' | 'stretch';
|
|
6
|
+
|
|
7
|
+
/** Cross-axis alignment of `<line-stack>`; the A2UI basic v0.9 `align` values without `baseline`. */
|
|
8
|
+
export type StackAlign = 'start' | 'center' | 'end' | 'stretch';
|
|
9
|
+
|
|
10
|
+
/** Gap step of `<line-stack>` on the `--line-layout-gap-*` scale (ARCH §17.2 C6). */
|
|
11
|
+
export type StackGap = '0' | '1' | '2' | '3' | '4' | '5';
|