@websublime/line-components 0.2.2 → 0.2.4
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 +28 -0
- package/custom-elements.json +445 -0
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/index.js +2 -0
- package/dist/button/index.js.map +1 -1
- package/dist/separator/index.d.ts +3 -0
- package/dist/separator/index.d.ts.map +1 -0
- package/dist/separator/index.js +62 -0
- package/dist/separator/index.js.map +1 -0
- package/dist/separator/separator.d.ts +32 -0
- package/dist/separator/separator.d.ts.map +1 -0
- package/dist/separator/separator.types.d.ts +3 -0
- package/dist/separator/separator.types.d.ts.map +1 -0
- package/package.json +5 -1
- package/src/button/button.ts +3 -2
- package/src/separator/index.ts +3 -0
- package/src/separator/separator.ts +93 -0
- package/src/separator/separator.types.ts +2 -0
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ 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/separator` | `<line-separator>` |
|
|
9
10
|
| `@websublime/line-components/stack` | `<line-stack>` |
|
|
10
11
|
|
|
11
12
|
```js
|
|
@@ -37,3 +38,30 @@ container, it adds no role, and it exposes no `::part()`; style it directly with
|
|
|
37
38
|
The gap reads `--line-stack-gap`, so load `@websublime/line-tokens/sizing` and `@websublime/line-tokens/layouts`
|
|
38
39
|
or set `--line-stack-gap` yourself; without them the gap is `0`. For a list, put `role="list"` on the host and
|
|
39
40
|
`role="listitem"` on each child.
|
|
41
|
+
|
|
42
|
+
## Separator
|
|
43
|
+
|
|
44
|
+
`<line-separator>` draws a thin line between sections of content. The host is the line, it renders nothing
|
|
45
|
+
inside, and it exposes no `::part()`; style it directly with `line-separator { … }`. It adds no margin, so the
|
|
46
|
+
surrounding layout, such as a `<line-stack>` `gap`, spaces it.
|
|
47
|
+
|
|
48
|
+
| Attribute | Values | Default |
|
|
49
|
+
|-----------|--------|---------|
|
|
50
|
+
| `orientation` | `horizontal`, `vertical` | `horizontal` |
|
|
51
|
+
| `decorative` | boolean | off |
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<line-separator></line-separator>
|
|
55
|
+
<line-stack orientation="horizontal" align="center">
|
|
56
|
+
<a href="/docs">Docs</a>
|
|
57
|
+
<line-separator orientation="vertical"></line-separator>
|
|
58
|
+
<a href="/blog">Blog</a>
|
|
59
|
+
</line-stack>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Assistive technology announces it as a separator, with the host `aria-label` as its name when one is set. The
|
|
63
|
+
role and orientation are `ElementInternals` defaults, so an author `role` or `aria-*` attribute wins. Set
|
|
64
|
+
`decorative` when the line only adds visual rhythm, so assistive technology skips it, and give a decorative
|
|
65
|
+
separator no `aria-label`. The line is a border side coloured by `--line-separator-color` (default
|
|
66
|
+
`var(--line-gray-6, currentColor)`) and as thick as `--line-separator-thickness` (default
|
|
67
|
+
`var(--line-border-1, 1px)`), so it stays visible without `line-themes`, `line-tokens` and in forced-colors mode.
|
package/custom-elements.json
CHANGED
|
@@ -1177,6 +1177,451 @@
|
|
|
1177
1177
|
}
|
|
1178
1178
|
]
|
|
1179
1179
|
},
|
|
1180
|
+
{
|
|
1181
|
+
"kind": "javascript-module",
|
|
1182
|
+
"path": "src/separator/index.ts",
|
|
1183
|
+
"declarations": [],
|
|
1184
|
+
"exports": [
|
|
1185
|
+
{
|
|
1186
|
+
"kind": "js",
|
|
1187
|
+
"name": "LineSeparator",
|
|
1188
|
+
"declaration": {
|
|
1189
|
+
"name": "LineSeparator",
|
|
1190
|
+
"module": "./separator.js"
|
|
1191
|
+
}
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
"kind": "js",
|
|
1195
|
+
"name": "SeparatorOrientation",
|
|
1196
|
+
"declaration": {
|
|
1197
|
+
"name": "SeparatorOrientation",
|
|
1198
|
+
"module": "./separator.types.js"
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
]
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
"kind": "javascript-module",
|
|
1205
|
+
"path": "src/separator/separator.ts",
|
|
1206
|
+
"declarations": [
|
|
1207
|
+
{
|
|
1208
|
+
"kind": "class",
|
|
1209
|
+
"description": "`<line-separator>` draws a thin line between sections of content. The host\nis the line and the shadow root renders nothing. The host carries the\n`separator` role and its orientation as `ElementInternals` defaults, so an\nauthor `role` or `aria-*` attribute wins, and a host `aria-label` names it.\n`decorative` sets the role to `none`, so assistive technology skips the\nline; give a decorative separator no `aria-label`. It adds no spacing.",
|
|
1210
|
+
"name": "LineSeparator",
|
|
1211
|
+
"cssProperties": [
|
|
1212
|
+
{
|
|
1213
|
+
"description": "Colour of the line.",
|
|
1214
|
+
"name": "--line-separator-color",
|
|
1215
|
+
"default": "var(--line-gray-6, currentColor)"
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
"description": "Thickness of the line.",
|
|
1219
|
+
"name": "--line-separator-thickness",
|
|
1220
|
+
"default": "var(--line-border-1, 1px)"
|
|
1221
|
+
}
|
|
1222
|
+
],
|
|
1223
|
+
"members": [
|
|
1224
|
+
{
|
|
1225
|
+
"kind": "field",
|
|
1226
|
+
"name": "orientation",
|
|
1227
|
+
"privacy": "public",
|
|
1228
|
+
"type": {
|
|
1229
|
+
"text": "SeparatorOrientation"
|
|
1230
|
+
},
|
|
1231
|
+
"description": "Direction of the line; an unknown value behaves as `horizontal`.",
|
|
1232
|
+
"default": "'horizontal'",
|
|
1233
|
+
"attribute": "orientation",
|
|
1234
|
+
"reflects": true
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
"kind": "field",
|
|
1238
|
+
"name": "decorative",
|
|
1239
|
+
"privacy": "public",
|
|
1240
|
+
"type": {
|
|
1241
|
+
"text": "boolean"
|
|
1242
|
+
},
|
|
1243
|
+
"description": "Removes the separator from the accessibility tree (role `none`); the line still draws.",
|
|
1244
|
+
"default": "false",
|
|
1245
|
+
"attribute": "decorative",
|
|
1246
|
+
"reflects": true
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
"kind": "field",
|
|
1250
|
+
"name": "properties",
|
|
1251
|
+
"type": {
|
|
1252
|
+
"text": "PropertyDeclarations"
|
|
1253
|
+
},
|
|
1254
|
+
"static": true,
|
|
1255
|
+
"default": "{ direction: { attribute: false, noAccessor: true }, }",
|
|
1256
|
+
"description": "`direction` is reactive but owns its accessor and has no attribute.",
|
|
1257
|
+
"inheritedFrom": {
|
|
1258
|
+
"name": "DirectionMixin",
|
|
1259
|
+
"module": "../line-core/src/mixins/direction.ts"
|
|
1260
|
+
}
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
"kind": "field",
|
|
1264
|
+
"name": "#direction",
|
|
1265
|
+
"privacy": "private",
|
|
1266
|
+
"type": {
|
|
1267
|
+
"text": "Direction"
|
|
1268
|
+
},
|
|
1269
|
+
"default": "'ltr'",
|
|
1270
|
+
"inheritedFrom": {
|
|
1271
|
+
"name": "DirectionMixin",
|
|
1272
|
+
"module": "../line-core/src/mixins/direction.ts"
|
|
1273
|
+
}
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
"kind": "field",
|
|
1277
|
+
"name": "#recomputeDirection",
|
|
1278
|
+
"privacy": "private",
|
|
1279
|
+
"readonly": true,
|
|
1280
|
+
"inheritedFrom": {
|
|
1281
|
+
"name": "DirectionMixin",
|
|
1282
|
+
"module": "../line-core/src/mixins/direction.ts"
|
|
1283
|
+
}
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
"kind": "field",
|
|
1287
|
+
"name": "direction",
|
|
1288
|
+
"privacy": "public",
|
|
1289
|
+
"type": {
|
|
1290
|
+
"text": "Direction"
|
|
1291
|
+
},
|
|
1292
|
+
"description": "Resolved text direction of the host.",
|
|
1293
|
+
"readonly": true,
|
|
1294
|
+
"inheritedFrom": {
|
|
1295
|
+
"name": "DirectionMixin",
|
|
1296
|
+
"module": "../line-core/src/mixins/direction.ts"
|
|
1297
|
+
}
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
"kind": "field",
|
|
1301
|
+
"name": "version",
|
|
1302
|
+
"type": {
|
|
1303
|
+
"text": "string"
|
|
1304
|
+
},
|
|
1305
|
+
"static": true,
|
|
1306
|
+
"default": "'0.0.0'",
|
|
1307
|
+
"description": "Component semver string. Surfaced by the Inspector as `data-line-version`.",
|
|
1308
|
+
"inheritedFrom": {
|
|
1309
|
+
"name": "LineElement",
|
|
1310
|
+
"module": "../line-core/src/line-element.ts"
|
|
1311
|
+
}
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
"kind": "field",
|
|
1315
|
+
"name": "docs",
|
|
1316
|
+
"type": {
|
|
1317
|
+
"text": "string"
|
|
1318
|
+
},
|
|
1319
|
+
"static": true,
|
|
1320
|
+
"default": "''",
|
|
1321
|
+
"description": "Documentation URL. Surfaced by the Inspector as `data-line-docs` when set.",
|
|
1322
|
+
"inheritedFrom": {
|
|
1323
|
+
"name": "MetadataMixin",
|
|
1324
|
+
"module": "../line-core/src/mixins/metadata.ts"
|
|
1325
|
+
}
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
"kind": "field",
|
|
1329
|
+
"name": "qa",
|
|
1330
|
+
"type": {
|
|
1331
|
+
"text": "string[]"
|
|
1332
|
+
},
|
|
1333
|
+
"static": true,
|
|
1334
|
+
"default": "[]",
|
|
1335
|
+
"description": "QA tags for the component.",
|
|
1336
|
+
"inheritedFrom": {
|
|
1337
|
+
"name": "MetadataMixin",
|
|
1338
|
+
"module": "../line-core/src/mixins/metadata.ts"
|
|
1339
|
+
}
|
|
1340
|
+
},
|
|
1341
|
+
{
|
|
1342
|
+
"kind": "field",
|
|
1343
|
+
"name": "scope",
|
|
1344
|
+
"type": {
|
|
1345
|
+
"text": "string"
|
|
1346
|
+
},
|
|
1347
|
+
"static": true,
|
|
1348
|
+
"default": "''",
|
|
1349
|
+
"description": "Component scope identifier.",
|
|
1350
|
+
"inheritedFrom": {
|
|
1351
|
+
"name": "MetadataMixin",
|
|
1352
|
+
"module": "../line-core/src/mixins/metadata.ts"
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
"kind": "field",
|
|
1357
|
+
"name": "#inspectorDialog",
|
|
1358
|
+
"privacy": "private",
|
|
1359
|
+
"type": {
|
|
1360
|
+
"text": "HTMLDialogElement | null"
|
|
1361
|
+
},
|
|
1362
|
+
"default": "null",
|
|
1363
|
+
"description": "Active dialog panel while the inspector is enabled, else `null`.",
|
|
1364
|
+
"inheritedFrom": {
|
|
1365
|
+
"name": "InspectorMixin",
|
|
1366
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
"kind": "field",
|
|
1371
|
+
"name": "#onInspectorKeydown",
|
|
1372
|
+
"privacy": "private",
|
|
1373
|
+
"readonly": true,
|
|
1374
|
+
"description": "Bound keydown handler, retained so it can be removed on disconnect.",
|
|
1375
|
+
"inheritedFrom": {
|
|
1376
|
+
"name": "InspectorMixin",
|
|
1377
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1378
|
+
}
|
|
1379
|
+
},
|
|
1380
|
+
{
|
|
1381
|
+
"kind": "method",
|
|
1382
|
+
"name": "#activateInspector",
|
|
1383
|
+
"privacy": "private",
|
|
1384
|
+
"return": {
|
|
1385
|
+
"type": {
|
|
1386
|
+
"text": "void"
|
|
1387
|
+
}
|
|
1388
|
+
},
|
|
1389
|
+
"description": "Wire activation marker, host metadata attributes, the hotkey, and the\ndev-only hover-outline stylesheet.",
|
|
1390
|
+
"inheritedFrom": {
|
|
1391
|
+
"name": "InspectorMixin",
|
|
1392
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1393
|
+
}
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
"kind": "method",
|
|
1397
|
+
"name": "#deactivateInspector",
|
|
1398
|
+
"privacy": "private",
|
|
1399
|
+
"return": {
|
|
1400
|
+
"type": {
|
|
1401
|
+
"text": "void"
|
|
1402
|
+
}
|
|
1403
|
+
},
|
|
1404
|
+
"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.",
|
|
1405
|
+
"inheritedFrom": {
|
|
1406
|
+
"name": "InspectorMixin",
|
|
1407
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1408
|
+
}
|
|
1409
|
+
},
|
|
1410
|
+
{
|
|
1411
|
+
"kind": "method",
|
|
1412
|
+
"name": "#inspectorRoot",
|
|
1413
|
+
"privacy": "private",
|
|
1414
|
+
"return": {
|
|
1415
|
+
"type": {
|
|
1416
|
+
"text": "ShadowRoot | null"
|
|
1417
|
+
}
|
|
1418
|
+
},
|
|
1419
|
+
"description": "The shadow root that carries `adoptedStyleSheets`, or `null`.",
|
|
1420
|
+
"inheritedFrom": {
|
|
1421
|
+
"name": "InspectorMixin",
|
|
1422
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1423
|
+
}
|
|
1424
|
+
},
|
|
1425
|
+
{
|
|
1426
|
+
"kind": "method",
|
|
1427
|
+
"name": "#adoptInspectorOutline",
|
|
1428
|
+
"privacy": "private",
|
|
1429
|
+
"return": {
|
|
1430
|
+
"type": {
|
|
1431
|
+
"text": "void"
|
|
1432
|
+
}
|
|
1433
|
+
},
|
|
1434
|
+
"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.",
|
|
1435
|
+
"inheritedFrom": {
|
|
1436
|
+
"name": "InspectorMixin",
|
|
1437
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1438
|
+
}
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
"kind": "method",
|
|
1442
|
+
"name": "#releaseInspectorOutline",
|
|
1443
|
+
"privacy": "private",
|
|
1444
|
+
"return": {
|
|
1445
|
+
"type": {
|
|
1446
|
+
"text": "void"
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
"description": "Remove the singleton hover-outline sheet from the shadow root's\n`adoptedStyleSheets`, preserving every other adopted sheet.",
|
|
1450
|
+
"inheritedFrom": {
|
|
1451
|
+
"name": "InspectorMixin",
|
|
1452
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1453
|
+
}
|
|
1454
|
+
},
|
|
1455
|
+
{
|
|
1456
|
+
"kind": "method",
|
|
1457
|
+
"name": "#inspectorVersion",
|
|
1458
|
+
"privacy": "private",
|
|
1459
|
+
"return": {
|
|
1460
|
+
"type": {
|
|
1461
|
+
"text": "string"
|
|
1462
|
+
}
|
|
1463
|
+
},
|
|
1464
|
+
"description": "Read the host's static `version`, defaulting to `''` when absent.",
|
|
1465
|
+
"inheritedFrom": {
|
|
1466
|
+
"name": "InspectorMixin",
|
|
1467
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1468
|
+
}
|
|
1469
|
+
},
|
|
1470
|
+
{
|
|
1471
|
+
"kind": "method",
|
|
1472
|
+
"name": "#inspectorDocs",
|
|
1473
|
+
"privacy": "private",
|
|
1474
|
+
"return": {
|
|
1475
|
+
"type": {
|
|
1476
|
+
"text": "string"
|
|
1477
|
+
}
|
|
1478
|
+
},
|
|
1479
|
+
"description": "Read the host's static `docs` URL defensively (D3 may not provide one).",
|
|
1480
|
+
"inheritedFrom": {
|
|
1481
|
+
"name": "InspectorMixin",
|
|
1482
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1483
|
+
}
|
|
1484
|
+
},
|
|
1485
|
+
{
|
|
1486
|
+
"kind": "method",
|
|
1487
|
+
"name": "#toggleInspectorPanel",
|
|
1488
|
+
"privacy": "private",
|
|
1489
|
+
"return": {
|
|
1490
|
+
"type": {
|
|
1491
|
+
"text": "void"
|
|
1492
|
+
}
|
|
1493
|
+
},
|
|
1494
|
+
"description": "Open the panel if closed, close it if already open.",
|
|
1495
|
+
"inheritedFrom": {
|
|
1496
|
+
"name": "InspectorMixin",
|
|
1497
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1498
|
+
}
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
"kind": "method",
|
|
1502
|
+
"name": "#openInspectorPanel",
|
|
1503
|
+
"privacy": "private",
|
|
1504
|
+
"return": {
|
|
1505
|
+
"type": {
|
|
1506
|
+
"text": "void"
|
|
1507
|
+
}
|
|
1508
|
+
},
|
|
1509
|
+
"description": "Build (once) and open the `<dialog>` metadata panel in the shadow root.",
|
|
1510
|
+
"inheritedFrom": {
|
|
1511
|
+
"name": "InspectorMixin",
|
|
1512
|
+
"module": "../line-core/src/mixins/inspector.ts"
|
|
1513
|
+
}
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
"kind": "field",
|
|
1517
|
+
"name": "#internals",
|
|
1518
|
+
"privacy": "private",
|
|
1519
|
+
"type": {
|
|
1520
|
+
"text": "ElementInternals"
|
|
1521
|
+
},
|
|
1522
|
+
"inheritedFrom": {
|
|
1523
|
+
"name": "LineElement",
|
|
1524
|
+
"module": "../line-core/src/line-element.ts"
|
|
1525
|
+
}
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
"kind": "field",
|
|
1529
|
+
"name": "[INTERNALS]",
|
|
1530
|
+
"type": {
|
|
1531
|
+
"text": "ElementInternals"
|
|
1532
|
+
},
|
|
1533
|
+
"privacy": "protected",
|
|
1534
|
+
"description": "The element's `ElementInternals`, attached once in the constructor (spec §6.C.2, SD19).",
|
|
1535
|
+
"readonly": true,
|
|
1536
|
+
"inheritedFrom": {
|
|
1537
|
+
"name": "LineElement",
|
|
1538
|
+
"module": "../line-core/src/line-element.ts"
|
|
1539
|
+
}
|
|
1540
|
+
},
|
|
1541
|
+
{
|
|
1542
|
+
"kind": "method",
|
|
1543
|
+
"name": "reflectState",
|
|
1544
|
+
"privacy": "protected",
|
|
1545
|
+
"return": {
|
|
1546
|
+
"type": {
|
|
1547
|
+
"text": "void"
|
|
1548
|
+
}
|
|
1549
|
+
},
|
|
1550
|
+
"parameters": [
|
|
1551
|
+
{
|
|
1552
|
+
"name": "name",
|
|
1553
|
+
"type": {
|
|
1554
|
+
"text": "string"
|
|
1555
|
+
}
|
|
1556
|
+
},
|
|
1557
|
+
{
|
|
1558
|
+
"name": "active",
|
|
1559
|
+
"type": {
|
|
1560
|
+
"text": "boolean"
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
],
|
|
1564
|
+
"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`.",
|
|
1565
|
+
"inheritedFrom": {
|
|
1566
|
+
"name": "LineElement",
|
|
1567
|
+
"module": "../line-core/src/line-element.ts"
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
],
|
|
1571
|
+
"attributes": [
|
|
1572
|
+
{
|
|
1573
|
+
"name": "orientation",
|
|
1574
|
+
"type": {
|
|
1575
|
+
"text": "SeparatorOrientation"
|
|
1576
|
+
},
|
|
1577
|
+
"description": "Direction of the line; an unknown value behaves as `horizontal`.",
|
|
1578
|
+
"default": "'horizontal'",
|
|
1579
|
+
"fieldName": "orientation"
|
|
1580
|
+
},
|
|
1581
|
+
{
|
|
1582
|
+
"name": "decorative",
|
|
1583
|
+
"type": {
|
|
1584
|
+
"text": "boolean"
|
|
1585
|
+
},
|
|
1586
|
+
"description": "Removes the separator from the accessibility tree (role `none`); the line still draws.",
|
|
1587
|
+
"default": "false",
|
|
1588
|
+
"fieldName": "decorative"
|
|
1589
|
+
}
|
|
1590
|
+
],
|
|
1591
|
+
"superclass": {
|
|
1592
|
+
"name": "LineElement",
|
|
1593
|
+
"package": "@websublime/line-core"
|
|
1594
|
+
},
|
|
1595
|
+
"summary": "A thin horizontal or vertical line that separates sections of content.",
|
|
1596
|
+
"tagName": "line-separator",
|
|
1597
|
+
"customElement": true
|
|
1598
|
+
}
|
|
1599
|
+
],
|
|
1600
|
+
"exports": [
|
|
1601
|
+
{
|
|
1602
|
+
"kind": "js",
|
|
1603
|
+
"name": "LineSeparator",
|
|
1604
|
+
"declaration": {
|
|
1605
|
+
"name": "LineSeparator",
|
|
1606
|
+
"module": "src/separator/separator.ts"
|
|
1607
|
+
}
|
|
1608
|
+
},
|
|
1609
|
+
{
|
|
1610
|
+
"kind": "custom-element-definition",
|
|
1611
|
+
"name": "line-separator",
|
|
1612
|
+
"declaration": {
|
|
1613
|
+
"name": "LineSeparator",
|
|
1614
|
+
"module": "src/separator/separator.ts"
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
]
|
|
1618
|
+
},
|
|
1619
|
+
{
|
|
1620
|
+
"kind": "javascript-module",
|
|
1621
|
+
"path": "src/separator/separator.types.ts",
|
|
1622
|
+
"declarations": [],
|
|
1623
|
+
"exports": []
|
|
1624
|
+
},
|
|
1180
1625
|
{
|
|
1181
1626
|
"kind": "javascript-module",
|
|
1182
1627
|
"path": "src/shared/button-machine.ts",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../src/button/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpE,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAUb,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,aAAa,EAEd,MAAM,mBAAmB,CAAC;;;;AA8B3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,UAAW,SAAQ,eAA2B;;IACzD,OAAgB,iBAAiB,EAAE,cAAc,CAA6D;I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|
-
{"version":3,"file":"index.js","names":["buttonMachine","createMachine","bindable","prop","guard","send","pressed","event","api","disabled","props","loading","connect","service","connectStatic","VARIANTS","TYPES","FORM_ATTRIBUTES","variantConverter","variant","value","typeConverter","type","pressedConverter","emptyRemovesConverter","LineButton","FormAssociated","LineElement","LitElement","commonReset","buttonReset","next","#formDisabled","#onPressedChange","LineMachineController","#machineProps","#onClick","#ctrl","#api","#activate","form","#submit","submitter","name","attribute","release","end","ended","visible","changed","message","root","buttonAttrs","ifDefined","#onPointerDown","#onKeyDown","#onKeyUp","#onFocus","#onBlur","nothing"],"sources":["../../src/shared/button-machine.ts","../../src/button/button.ts"],"sourcesContent":["/**\n * The Button press machine, shared by `<line-button>` and `<line-icon-button>`\n * (spec `0002-button.md` States; Phase 1 spec §6.C.5; ARCH §13.1).\n *\n * The press is the only finite state: `idle → active`. `disabled`, `loading`\n * and `pressed` are props that the `isInteractive` guard and the actions read\n * at event time. `ACTIVATE` flips a toggle through `onPressedChange`. A `watch`\n * cancels a running press when `disabled` or `loading` turns true. The module\n * knows nothing about forms or DOM events and imports no component\n * (MANIFESTO Law 4).\n *\n * @module shared/button-machine\n */\n\nimport { createMachine, type Service } from '@zag-js/core';\n\n/** Machine props. A component passes them as a live function of its own properties. */\nexport interface ButtonMachineProps {\n disabled?: boolean | undefined;\n loading?: boolean | undefined;\n /** `undefined` means the button is not a toggle. */\n pressed?: boolean | undefined;\n /** Called with the next pressed state when an activation flips a toggle. */\n onPressedChange?: ((next: boolean) => void) | undefined;\n}\n\nexport type ButtonMachineEvent =\n | { type: 'PRESS_START' }\n | { type: 'PRESS_END' }\n | { type: 'PRESS_CANCEL' }\n | { type: 'ACTIVATE' }\n | { type: 'FOCUS'; visible: boolean }\n | { type: 'BLUR' };\n\nexport interface ButtonMachineSchema {\n props: ButtonMachineProps;\n context: { focusVisible: boolean };\n state: 'idle' | 'active';\n guard: 'isInteractive';\n action: 'togglePressed' | 'setFocusVisible' | 'clearFocusVisible';\n event: ButtonMachineEvent;\n}\n\nexport type ButtonService = Service<ButtonMachineSchema>;\n\nexport const buttonMachine = createMachine<ButtonMachineSchema>({\n initialState: () => 'idle',\n context: ({ bindable }) => ({\n focusVisible: bindable<boolean>(() => ({ defaultValue: false })),\n }),\n watch({ track, prop, guard, send }) {\n track([() => prop('disabled'), () => prop('loading')], () => {\n if (!guard('isInteractive')) send({ type: 'PRESS_CANCEL' });\n });\n },\n on: {\n ACTIVATE: { guard: 'isInteractive', actions: ['togglePressed'] },\n FOCUS: { actions: ['setFocusVisible'] },\n BLUR: { actions: ['clearFocusVisible'] },\n },\n states: {\n idle: {\n on: { PRESS_START: { target: 'active', guard: 'isInteractive' } },\n },\n active: {\n on: {\n PRESS_END: { target: 'idle' },\n PRESS_CANCEL: { target: 'idle' },\n },\n },\n },\n implementations: {\n guards: {\n isInteractive: ({ prop }) => !(prop('disabled') || prop('loading')),\n },\n actions: {\n togglePressed({ prop }) {\n const pressed = prop('pressed');\n if (pressed !== undefined) prop('onPressedChange')?.(!pressed);\n },\n setFocusVisible({ context, event }) {\n context.set('focusVisible', event.type === 'FOCUS' && event.visible === true);\n },\n clearFocusVisible({ context }) {\n context.set('focusVisible', false);\n },\n },\n },\n});\n\n/** What the inner native `<button>` and the host reflection read. */\nexport interface ButtonApi {\n active: boolean;\n /** `true` only on a pressed toggle. */\n pressed: boolean;\n loading: boolean;\n disabled: boolean;\n focusVisible: boolean;\n /** `!disabled && !loading`: whether an activation runs now. */\n interactive: boolean;\n /** ARIA and `disabled` for the inner `<button>`; an `undefined` attribute is left off. */\n buttonAttrs: {\n 'aria-pressed': 'true' | 'false' | undefined;\n 'aria-disabled': 'true' | undefined;\n disabled: boolean;\n };\n}\n\nfunction api(props: ButtonMachineProps, active: boolean, focusVisible: boolean): ButtonApi {\n const disabled = props.disabled === true;\n const loading = props.loading === true;\n return {\n active,\n pressed: props.pressed === true,\n loading,\n disabled,\n focusVisible,\n interactive: !(disabled || loading),\n buttonAttrs: {\n 'aria-pressed': props.pressed === undefined ? undefined : (String(props.pressed) as 'true' | 'false'),\n 'aria-disabled': loading && !disabled ? 'true' : undefined,\n disabled,\n },\n };\n}\n\n/** Reads the running machine at call time. */\nexport function connect(service: ButtonService): ButtonApi {\n const { prop } = service;\n return api(\n { disabled: prop('disabled'), loading: prop('loading'), pressed: prop('pressed') },\n service.state.matches('active'),\n service.context.get('focusVisible'),\n );\n}\n\n/** The same view without a machine, for the controller's static fallback (MANIFESTO Law 9). */\nexport function connectStatic(props: ButtonMachineProps): ButtonApi {\n return api(props, false, false);\n}\n","import { FormAssociated, LineElement } from '@websublime/line-core';\nimport { LineMachineController } from '@websublime/line-core/machine';\nimport { buttonReset, commonReset } from '@websublime/line-core/styles';\nimport {\n type ComplexAttributeConverter,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport {\n type ButtonApi,\n type ButtonMachineProps,\n type ButtonMachineSchema,\n buttonMachine,\n connect,\n connectStatic,\n} from '../shared/button-machine.js';\nimport type {\n ButtonFormEnctype,\n ButtonFormMethod,\n ButtonType,\n ButtonVariant,\n LineButtonChangeDetail,\n} from './button.types.js';\n\nconst VARIANTS: readonly ButtonVariant[] = ['default', 'primary', 'borderless'];\nconst TYPES: readonly ButtonType[] = ['submit', 'reset', 'button'];\n\n/** The host attributes the temporary submitter copies, besides `name` and `value`. */\nconst FORM_ATTRIBUTES = ['formaction', 'formmethod', 'formenctype', 'formtarget', 'formnovalidate'] as const;\n\n/** An unknown `variant` behaves as `default`; the attribute keeps what the author wrote. */\nconst variantConverter: ComplexAttributeConverter<ButtonVariant> = {\n fromAttribute: (value) => VARIANTS.find((variant) => variant === value) ?? 'default',\n};\n\n/** An unknown or missing `type` behaves as `submit`, as on a native button; the match ignores case. */\nconst typeConverter: ComplexAttributeConverter<ButtonType> = {\n fromAttribute: (value) => TYPES.find((type) => type === value?.toLowerCase()) ?? 'submit',\n};\n\n/** Absent means not a toggle; `\"false\"` parses to `false` and any other value to `true`. */\nconst pressedConverter: ComplexAttributeConverter<boolean | undefined> = {\n fromAttribute: (value) => (value === null ? undefined : value !== 'false'),\n toAttribute: (value) => (value === undefined ? null : String(value)),\n};\n\n/** Reflects a string and removes the attribute when the string is empty. */\nconst emptyRemovesConverter: ComplexAttributeConverter<string> = {\n fromAttribute: (value) => value ?? '',\n toAttribute: (value) => value || null,\n};\n\n/**\n * `<line-button>` runs an action when the user activates it. It renders a\n * native `<button>` in its shadow root, and the host is a form-associated\n * custom element, so `type=\"submit\"` and `type=\"reset\"` act on its form as a\n * native button does. `pressed` makes it a toggle; `loading` keeps it\n * focusable while it ignores presses.\n *\n * @summary A form-associated button that runs an action, submits or resets its form, or toggles with `pressed`.\n *\n * @slot - The label: text or inline content.\n * @slot prefix - A leading icon.\n * @slot suffix - A trailing icon.\n * @slot loading - A spinner, loading text or both; rendered only while `loading` is on.\n *\n * @csspart root - The inner native `<button>`: box, background, border and focus ring.\n * @csspart label - Wraps the default slot.\n * @csspart loading - Wraps the `loading` slot; present only while `loading` is on.\n *\n * @cssprop [--line-button-radius=var(--line-radius-2)] - Corner radius of `root`.\n * @cssprop [--line-button-bg=var(--line-gray-bg)] - Background of `root`; `primary` uses `var(--line-accent-solid)` and `borderless` uses `transparent`.\n * @cssprop [--line-button-color=var(--line-gray-text)] - Text colour of `root`; `primary` uses `var(--line-accent-contrast)` and `borderless` uses `var(--line-accent-text)`.\n * @cssprop [--line-button-height=var(--line-size-7)] - Minimum block size of `root`.\n * @cssprop [--line-button-padding-inline=var(--line-size-3)] - Inline padding of `root`.\n * @cssprop [--line-button-gap=var(--line-size-2)] - Gap between the prefix, label, suffix and loading zones.\n * @cssprop [--line-button-font-size=var(--line-font-size-1)] - Font size of `root`.\n * @cssprop [--line-button-font-weight=var(--line-font-weight-5)] - Font weight of `root`.\n * @cssprop [--line-button-focus-ring=var(--line-focus-ring, 2px solid currentColor)] - `outline` of `root` while the host has `data-focus-visible`.\n *\n * @fires {CustomEvent<LineButtonChangeDetail>} line-change - A user activation flipped `pressed` on a toggle button; `detail.value` is the new state. Bubbles, not composed.\n *\n * @attr {string} name - The key the submitter value goes under; read through the inherited `name` getter.\n */\nexport class LineButton extends FormAssociated(LineElement) {\n static override shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n static override properties: PropertyDeclarations = {\n variant: { reflect: true, converter: variantConverter },\n type: { reflect: true, converter: typeConverter },\n disabled: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n pressed: { reflect: true, converter: pressedConverter },\n value: { reflect: true, converter: emptyRemovesConverter },\n formAction: { attribute: 'formaction', reflect: true, converter: emptyRemovesConverter },\n formMethod: { attribute: 'formmethod', reflect: true },\n formEnctype: { attribute: 'formenctype', reflect: true },\n formTarget: { attribute: 'formtarget', reflect: true },\n formNoValidate: { attribute: 'formnovalidate', type: Boolean, reflect: true },\n customValidity: { attribute: 'custom-validity' },\n ariaLabel: { attribute: 'aria-label', reflect: true },\n ariaDescription: { attribute: 'aria-description', reflect: true },\n };\n\n static override styles = [\n commonReset,\n buttonReset,\n css`\n :host {\n --line-button-radius: var(--line-radius-2);\n --line-button-bg: var(--line-gray-bg);\n --line-button-color: var(--line-gray-text);\n --line-button-height: var(--line-size-7);\n --line-button-padding-inline: var(--line-size-3);\n --line-button-gap: var(--line-size-2);\n --line-button-font-size: var(--line-font-size-1);\n --line-button-font-weight: var(--line-font-weight-5);\n --line-button-focus-ring: var(--line-focus-ring, 2px solid currentColor);\n\n display: inline-block;\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host([variant='primary']) {\n --line-button-bg: var(--line-accent-solid);\n --line-button-color: var(--line-accent-contrast);\n }\n\n :host([variant='borderless']) {\n --line-button-bg: transparent;\n --line-button-color: var(--line-accent-text);\n }\n\n [part='root'] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--line-button-gap);\n min-block-size: var(--line-button-height);\n padding-inline: var(--line-button-padding-inline);\n border-radius: var(--line-button-radius);\n background: var(--line-button-bg);\n color: var(--line-button-color);\n font-size: var(--line-button-font-size);\n font-weight: var(--line-button-font-weight);\n }\n\n :host([data-focus-visible]) [part='root'] {\n outline: var(--line-button-focus-ring);\n }\n `,\n ];\n\n /** Semantic emphasis; an unknown value behaves as `default`. */\n declare variant: ButtonVariant;\n /** What activation does to the form owner; an unknown value behaves as `submit`. */\n declare type: ButtonType;\n /** Removes the button from the tab order and blocks activation. */\n declare disabled: boolean;\n /** Keeps focus, sets `aria-disabled=\"true\"`, blocks activation and renders the `loading` part. */\n declare loading: boolean;\n /** `undefined` means not a toggle; a toggle flips it on each activation and fires `line-change`. */\n declare pressed: boolean | undefined;\n /** The submitter value; it enters the form data only when this button submits. */\n declare value: string;\n /** Overrides the form's `action` when this button submits. */\n declare formAction: string;\n /** Overrides the form's `method` when this button submits. */\n declare formMethod: ButtonFormMethod | undefined;\n /** Overrides the form's `enctype` when this button submits. */\n declare formEnctype: ButtonFormEnctype | undefined;\n /** Overrides the form's `target` when this button submits. */\n declare formTarget: string | undefined;\n /** Skips constraint validation when this button submits. */\n declare formNoValidate: boolean;\n /** External validity: a non-empty message marks the button invalid while `type` is `submit`. */\n declare customValidity: string;\n /** Copied to the inner button, where it names the role. */\n declare ariaLabel: string | null;\n /** Copied to the inner button. */\n declare ariaDescription: string | null;\n\n /** A disabled `fieldset` ancestor or the host's own `disabled`, from `formDisabledCallback`. */\n #formDisabled = false;\n\n readonly #onPressedChange = (next: boolean): void => {\n this.pressed = next;\n this.dispatchEvent(\n new CustomEvent<LineButtonChangeDetail>('line-change', {\n detail: { value: next },\n bubbles: true,\n composed: false,\n }),\n );\n };\n\n readonly #machineProps = (): ButtonMachineProps => ({\n disabled: this.disabled || this.#formDisabled,\n loading: this.loading,\n pressed: this.pressed,\n onPressedChange: this.#onPressedChange,\n });\n\n readonly #ctrl = new LineMachineController<ButtonMachineSchema>(this, {\n machine: buttonMachine,\n props: this.#machineProps,\n });\n\n constructor() {\n super();\n this.variant = 'default';\n this.type = 'submit';\n this.disabled = false;\n this.loading = false;\n this.value = '';\n this.formAction = '';\n this.formNoValidate = false;\n this.customValidity = '';\n this.addEventListener('click', this.#onClick, { capture: true });\n }\n\n override formDisabledCallback(disabled: boolean): void {\n this.#formDisabled = disabled;\n this.requestUpdate();\n }\n\n /** The machine view, or the static view from the host props when the machine failed to start. */\n #api(): ButtonApi {\n const service = this.#ctrl.service;\n return service && !this.#ctrl.fallback ? connect(service) : connectStatic(this.#machineProps());\n }\n\n /**\n * Stops a click while the button is not interactive. It listens in the\n * capture phase, so it runs before every bubble listener on the host,\n * including an inline `onclick` or a listener added before the upgrade.\n * Otherwise it activates in a later task, once the click dispatch has\n * ended, unless a listener called `preventDefault()`.\n */\n readonly #onClick = (event: MouseEvent): void => {\n if (!this.#api().interactive) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n setTimeout(() => {\n if (!event.defaultPrevented) this.#activate();\n });\n };\n\n #activate(): void {\n this.#ctrl.send({ type: 'ACTIVATE' });\n const form = this.form;\n if (!form) return;\n if (this.type === 'reset') {\n // A control with id or name \"reset\" shadows the method on the form.\n HTMLFormElement.prototype.reset.call(form);\n } else if (this.type === 'submit') {\n this.#submit(form);\n }\n }\n\n /** Submits through a temporary native submitter, so the submission gets the native submitter semantics. */\n #submit(form: HTMLFormElement): void {\n const submitter = form.ownerDocument.createElement('button');\n submitter.type = 'submit';\n submitter.hidden = true;\n submitter.setAttribute('data-line-button-submitter', '');\n const name = this.getAttribute('name');\n if (name !== null) submitter.name = name;\n submitter.value = this.value;\n for (const attribute of FORM_ATTRIBUTES) {\n const value = this.getAttribute(attribute);\n if (value !== null) submitter.setAttribute(attribute, value);\n }\n form.append(submitter);\n try {\n submitter.click();\n } finally {\n submitter.remove();\n }\n }\n\n readonly #onPointerDown = (event: PointerEvent): void => {\n if (event.button !== 0) return;\n this.#ctrl.send({ type: 'PRESS_START' });\n const release = new AbortController();\n const end = (ended: Event): void => {\n release.abort();\n this.#ctrl.send({ type: ended.type === 'pointerup' ? 'PRESS_END' : 'PRESS_CANCEL' });\n };\n window.addEventListener('pointerup', end, { capture: true, signal: release.signal });\n window.addEventListener('pointercancel', end, { capture: true, signal: release.signal });\n };\n\n readonly #onKeyDown = (event: KeyboardEvent): void => {\n if (!event.repeat && (event.key === 'Enter' || event.key === ' ')) this.#ctrl.send({ type: 'PRESS_START' });\n };\n\n readonly #onKeyUp = (event: KeyboardEvent): void => {\n if (event.key === 'Enter' || event.key === ' ') this.#ctrl.send({ type: 'PRESS_END' });\n };\n\n readonly #onFocus = (event: FocusEvent): void => {\n const visible = (event.currentTarget as HTMLButtonElement).matches(':focus-visible');\n this.#ctrl.send({ type: 'FOCUS', visible });\n };\n\n readonly #onBlur = (): void => {\n this.#ctrl.send({ type: 'PRESS_CANCEL' });\n this.#ctrl.send({ type: 'BLUR' });\n };\n\n protected override update(changed: PropertyValues<this>): void {\n const api = this.#api();\n this.reflectState('active', api.active);\n this.reflectState('pressed', api.pressed);\n this.reflectState('loading', api.loading);\n this.reflectState('disabled', api.disabled);\n this.reflectState('focus-visible', api.focusVisible);\n super.update(changed);\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n if (!(changed.has('customValidity') || changed.has('type'))) return;\n const message = this.type === 'submit' ? this.customValidity : '';\n const root = this.renderRoot.querySelector<HTMLButtonElement>('[part=\"root\"]') ?? undefined;\n if (message) {\n this.setValidity({ customError: true }, message, root);\n } else {\n this.setValidity({});\n }\n this.reflectState('invalid', message !== '');\n }\n\n override render(): TemplateResult {\n const { loading, buttonAttrs } = this.#api();\n return html`<button\n part=\"root\"\n type=\"button\"\n ?disabled=${buttonAttrs.disabled}\n aria-pressed=${ifDefined(buttonAttrs['aria-pressed'])}\n aria-disabled=${ifDefined(buttonAttrs['aria-disabled'])}\n aria-label=${ifDefined(this.ariaLabel ?? undefined)}\n aria-description=${ifDefined(this.ariaDescription ?? undefined)}\n @pointerdown=${this.#onPointerDown}\n @keydown=${this.#onKeyDown}\n @keyup=${this.#onKeyUp}\n @focus=${this.#onFocus}\n @blur=${this.#onBlur}\n ><slot name=\"prefix\"></slot><span part=\"label\"><slot></slot></span><slot name=\"suffix\"></slot>${\n loading ? html`<span part=\"loading\"><slot name=\"loading\"></slot></span>` : nothing\n }</button>`;\n }\n}\n\ncustomElements.define('line-button', LineButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'line-button': LineButton;\n }\n}\n"],"mappings":";;;;;;;AA6CA,IAAaA,IAAgBC,EAAmC;CAC9D,oBAAoB;CACpB,UAAU,EAAE,mBAAgB,EAC1B,cAAcC,SAAyB,EAAE,cAAc,GAAM,EAAE,EACjE;CACA,MAAM,EAAE,UAAO,SAAM,UAAO,WAAQ;EAClC,EAAM,OAAOC,EAAK,UAAU,SAASA,EAAK,SAAS,CAAC,SAAS;GAC3D,AAAKC,EAAM,eAAe,KAAGC,EAAK,EAAE,MAAM,eAAe,CAAC;EAC5D,CAAC;CACH;CACA,IAAI;EACF,UAAU;GAAE,OAAO;GAAiB,SAAS,CAAC,eAAe;EAAE;EAC/D,OAAO,EAAE,SAAS,CAAC,iBAAiB,EAAE;EACtC,MAAM,EAAE,SAAS,CAAC,mBAAmB,EAAE;CACzC;CACA,QAAQ;EACN,MAAM,EACJ,IAAI,EAAE,aAAa;GAAE,QAAQ;GAAU,OAAO;EAAgB,EAAE,EAClE;EACA,QAAQ,EACN,IAAI;GACF,WAAW,EAAE,QAAQ,OAAO;GAC5B,cAAc,EAAE,QAAQ,OAAO;EACjC,EACF;CACF;CACA,iBAAiB;EACf,QAAQ,EACN,gBAAgB,EAAE,cAAW,EAAEF,EAAK,UAAU,KAAKA,EAAK,SAAS,GACnE;EACA,SAAS;GACP,cAAc,EAAE,WAAQ;IACtB,IAAMG,IAAUH,EAAK,SAAS;IAC9B,AAAIG,MAAY,KAAA,KAAWH,EAAK,iBAAiB,CAAC,GAAG,CAACG,CAAO;GAC/D;GACA,gBAAgB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K,aAAa,UAAU9B,EAAI,MAAM,GACtC,KAAK,aAAa,WAAWA,EAAI,OAAO,GACxC,KAAK,aAAa,WAAWA,EAAI,OAAO,GACxC,KAAK,aAAa,YAAYA,EAAI,QAAQ,GAC1C,KAAK,aAAa,iBAAiBA,EAAI,YAAY,GACnD,MAAM,OAAOyC,CAAO;CACtB;CAEA,QAA2B,GAAqC;EAC9D,IAAI,EAAEA,EAAQ,IAAI,gBAAgB,KAAKA,EAAQ,IAAI,MAAM,IAAI;EAC7D,IAAMC,IAAU,KAAK,SAAS,WAAW,KAAK,iBAAiB,IACzDC,IAAO,KAAK,WAAW,cAAiC,iBAAe,KAAK,KAAA;EAMlF,AALID,IACF,KAAK,YAAY,EAAE,aAAa,GAAK,GAAGA,GAASC,CAAI,IAErD,KAAK,YAAY,CAAC,CAAC,GAErB,KAAK,aAAa,WAAWD,MAAY,EAAE;CAC7C;CAEA,SAAkC;EAChC,IAAM,EAAE,YAAS,mBAAgB,KAAKZ,GAAK;EAC3C,OAAO,CAAI;;;kBAGGc,EAAY,SAAS;qBAClBC,EAAUD,EAAY,eAAe,EAAE;sBACtCC,EAAUD,EAAY,gBAAgB,EAAE;mBAC3CC,EAAU,KAAK,aAAa,KAAA,CAAS,EAAE;yBACjCA,EAAU,KAAK,mBAAmB,KAAA,CAAS,EAAE;qBACjD,KAAKC,GAAe;iBACxB,KAAKC,GAAW;eAClB,KAAKC,GAAS;eACd,KAAKC,GAAS;cACf,KAAKC,GAAQ;oGAErB/C,IAAU,CAAI,6DAA6DgD,EAC5E;CACH;AACF;AAEA,eAAe,OAAO,eAAelC,CAAU"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["buttonMachine","createMachine","bindable","prop","guard","send","pressed","event","api","disabled","props","loading","connect","service","connectStatic","VARIANTS","TYPES","FORM_ATTRIBUTES","variantConverter","variant","value","typeConverter","type","pressedConverter","emptyRemovesConverter","LineButton","FormAssociated","LineElement","LitElement","commonReset","buttonReset","next","#formDisabled","#onPressedChange","LineMachineController","#machineProps","#onClick","#ctrl","#api","#activate","form","#submit","submitter","name","attribute","release","end","ended","visible","changed","message","root","buttonAttrs","ifDefined","#onPointerDown","#onKeyDown","#onKeyUp","#onFocus","#onBlur","nothing"],"sources":["../../src/shared/button-machine.ts","../../src/button/button.ts"],"sourcesContent":["/**\n * The Button press machine, shared by `<line-button>` and `<line-icon-button>`\n * (spec `0002-button.md` States; Phase 1 spec §6.C.5; ARCH §13.1).\n *\n * The press is the only finite state: `idle → active`. `disabled`, `loading`\n * and `pressed` are props that the `isInteractive` guard and the actions read\n * at event time. `ACTIVATE` flips a toggle through `onPressedChange`. A `watch`\n * cancels a running press when `disabled` or `loading` turns true. The module\n * knows nothing about forms or DOM events and imports no component\n * (MANIFESTO Law 4).\n *\n * @module shared/button-machine\n */\n\nimport { createMachine, type Service } from '@zag-js/core';\n\n/** Machine props. A component passes them as a live function of its own properties. */\nexport interface ButtonMachineProps {\n disabled?: boolean | undefined;\n loading?: boolean | undefined;\n /** `undefined` means the button is not a toggle. */\n pressed?: boolean | undefined;\n /** Called with the next pressed state when an activation flips a toggle. */\n onPressedChange?: ((next: boolean) => void) | undefined;\n}\n\nexport type ButtonMachineEvent =\n | { type: 'PRESS_START' }\n | { type: 'PRESS_END' }\n | { type: 'PRESS_CANCEL' }\n | { type: 'ACTIVATE' }\n | { type: 'FOCUS'; visible: boolean }\n | { type: 'BLUR' };\n\nexport interface ButtonMachineSchema {\n props: ButtonMachineProps;\n context: { focusVisible: boolean };\n state: 'idle' | 'active';\n guard: 'isInteractive';\n action: 'togglePressed' | 'setFocusVisible' | 'clearFocusVisible';\n event: ButtonMachineEvent;\n}\n\nexport type ButtonService = Service<ButtonMachineSchema>;\n\nexport const buttonMachine = createMachine<ButtonMachineSchema>({\n initialState: () => 'idle',\n context: ({ bindable }) => ({\n focusVisible: bindable<boolean>(() => ({ defaultValue: false })),\n }),\n watch({ track, prop, guard, send }) {\n track([() => prop('disabled'), () => prop('loading')], () => {\n if (!guard('isInteractive')) send({ type: 'PRESS_CANCEL' });\n });\n },\n on: {\n ACTIVATE: { guard: 'isInteractive', actions: ['togglePressed'] },\n FOCUS: { actions: ['setFocusVisible'] },\n BLUR: { actions: ['clearFocusVisible'] },\n },\n states: {\n idle: {\n on: { PRESS_START: { target: 'active', guard: 'isInteractive' } },\n },\n active: {\n on: {\n PRESS_END: { target: 'idle' },\n PRESS_CANCEL: { target: 'idle' },\n },\n },\n },\n implementations: {\n guards: {\n isInteractive: ({ prop }) => !(prop('disabled') || prop('loading')),\n },\n actions: {\n togglePressed({ prop }) {\n const pressed = prop('pressed');\n if (pressed !== undefined) prop('onPressedChange')?.(!pressed);\n },\n setFocusVisible({ context, event }) {\n context.set('focusVisible', event.type === 'FOCUS' && event.visible === true);\n },\n clearFocusVisible({ context }) {\n context.set('focusVisible', false);\n },\n },\n },\n});\n\n/** What the inner native `<button>` and the host reflection read. */\nexport interface ButtonApi {\n active: boolean;\n /** `true` only on a pressed toggle. */\n pressed: boolean;\n loading: boolean;\n disabled: boolean;\n focusVisible: boolean;\n /** `!disabled && !loading`: whether an activation runs now. */\n interactive: boolean;\n /** ARIA and `disabled` for the inner `<button>`; an `undefined` attribute is left off. */\n buttonAttrs: {\n 'aria-pressed': 'true' | 'false' | undefined;\n 'aria-disabled': 'true' | undefined;\n disabled: boolean;\n };\n}\n\nfunction api(props: ButtonMachineProps, active: boolean, focusVisible: boolean): ButtonApi {\n const disabled = props.disabled === true;\n const loading = props.loading === true;\n return {\n active,\n pressed: props.pressed === true,\n loading,\n disabled,\n focusVisible,\n interactive: !(disabled || loading),\n buttonAttrs: {\n 'aria-pressed': props.pressed === undefined ? undefined : (String(props.pressed) as 'true' | 'false'),\n 'aria-disabled': loading && !disabled ? 'true' : undefined,\n disabled,\n },\n };\n}\n\n/** Reads the running machine at call time. */\nexport function connect(service: ButtonService): ButtonApi {\n const { prop } = service;\n return api(\n { disabled: prop('disabled'), loading: prop('loading'), pressed: prop('pressed') },\n service.state.matches('active'),\n service.context.get('focusVisible'),\n );\n}\n\n/** The same view without a machine, for the controller's static fallback (MANIFESTO Law 9). */\nexport function connectStatic(props: ButtonMachineProps): ButtonApi {\n return api(props, false, false);\n}\n","import { FormAssociated, LineElement } from '@websublime/line-core';\nimport { LineMachineController } from '@websublime/line-core/machine';\nimport { buttonReset, commonReset } from '@websublime/line-core/styles';\nimport {\n type ComplexAttributeConverter,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport {\n type ButtonApi,\n type ButtonMachineProps,\n type ButtonMachineSchema,\n buttonMachine,\n connect,\n connectStatic,\n} from '../shared/button-machine.js';\nimport type {\n ButtonFormEnctype,\n ButtonFormMethod,\n ButtonType,\n ButtonVariant,\n LineButtonChangeDetail,\n} from './button.types.js';\n\nconst VARIANTS: readonly ButtonVariant[] = ['default', 'primary', 'borderless'];\nconst TYPES: readonly ButtonType[] = ['submit', 'reset', 'button'];\n\n/** The host attributes the temporary submitter copies, besides `name` and `value`. */\nconst FORM_ATTRIBUTES = ['formaction', 'formmethod', 'formenctype', 'formtarget', 'formnovalidate'] as const;\n\n/** An unknown `variant` behaves as `default`; the attribute keeps what the author wrote. */\nconst variantConverter: ComplexAttributeConverter<ButtonVariant> = {\n fromAttribute: (value) => VARIANTS.find((variant) => variant === value) ?? 'default',\n};\n\n/** An unknown or missing `type` behaves as `submit`, as on a native button; the match ignores case. */\nconst typeConverter: ComplexAttributeConverter<ButtonType> = {\n fromAttribute: (value) => TYPES.find((type) => type === value?.toLowerCase()) ?? 'submit',\n};\n\n/** Absent means not a toggle; `\"false\"` parses to `false` and any other value to `true`. */\nconst pressedConverter: ComplexAttributeConverter<boolean | undefined> = {\n fromAttribute: (value) => (value === null ? undefined : value !== 'false'),\n toAttribute: (value) => (value === undefined ? null : String(value)),\n};\n\n/** Reflects a string and removes the attribute when the string is empty. */\nconst emptyRemovesConverter: ComplexAttributeConverter<string> = {\n fromAttribute: (value) => value ?? '',\n toAttribute: (value) => value || null,\n};\n\n/**\n * `<line-button>` runs an action when the user activates it. It renders a\n * native `<button>` in its shadow root, and the host is a form-associated\n * custom element, so `type=\"submit\"` and `type=\"reset\"` act on its form as a\n * native button does. `pressed` makes it a toggle; `loading` keeps it\n * focusable while it ignores presses.\n *\n * @summary A form-associated button that runs an action, submits or resets its form, or toggles with `pressed`.\n *\n * @slot - The label: text or inline content.\n * @slot prefix - A leading icon.\n * @slot suffix - A trailing icon.\n * @slot loading - A spinner, loading text or both; rendered only while `loading` is on.\n *\n * @csspart root - The inner native `<button>`: box, background, border and focus ring.\n * @csspart label - Wraps the default slot.\n * @csspart loading - Wraps the `loading` slot; present only while `loading` is on.\n *\n * @cssprop [--line-button-radius=var(--line-radius-2)] - Corner radius of `root`.\n * @cssprop [--line-button-bg=var(--line-gray-bg)] - Background of `root`; `primary` uses `var(--line-accent-solid)` and `borderless` uses `transparent`.\n * @cssprop [--line-button-color=var(--line-gray-text)] - Text colour of `root`; `primary` uses `var(--line-accent-contrast)` and `borderless` uses `var(--line-accent-text)`.\n * @cssprop [--line-button-height=var(--line-size-7)] - Minimum block size of `root`.\n * @cssprop [--line-button-padding-inline=var(--line-size-3)] - Inline padding of `root`.\n * @cssprop [--line-button-gap=var(--line-size-2)] - Gap between the prefix, label, suffix and loading zones.\n * @cssprop [--line-button-font-size=var(--line-font-size-1)] - Font size of `root`.\n * @cssprop [--line-button-font-weight=var(--line-font-weight-5)] - Font weight of `root`.\n * @cssprop [--line-button-focus-ring=var(--line-focus-ring, 2px solid currentColor)] - `outline` of `root` while the host has `data-focus-visible`.\n *\n * @fires {CustomEvent<LineButtonChangeDetail>} line-change - A user activation flipped `pressed` on a toggle button; `detail.value` is the new state. Bubbles, not composed.\n *\n * @attr {string} name - The key the submitter value goes under; read through the inherited `name` getter.\n */\nexport class LineButton extends FormAssociated(LineElement) {\n static override shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n static override properties: PropertyDeclarations = {\n variant: { reflect: true, useDefault: true, converter: variantConverter },\n type: { reflect: true, useDefault: true, converter: typeConverter },\n disabled: { type: Boolean, reflect: true },\n loading: { type: Boolean, reflect: true },\n pressed: { reflect: true, converter: pressedConverter },\n value: { reflect: true, converter: emptyRemovesConverter },\n formAction: { attribute: 'formaction', reflect: true, converter: emptyRemovesConverter },\n formMethod: { attribute: 'formmethod', reflect: true },\n formEnctype: { attribute: 'formenctype', reflect: true },\n formTarget: { attribute: 'formtarget', reflect: true },\n formNoValidate: { attribute: 'formnovalidate', type: Boolean, reflect: true },\n customValidity: { attribute: 'custom-validity' },\n ariaLabel: { attribute: 'aria-label', reflect: true },\n ariaDescription: { attribute: 'aria-description', reflect: true },\n };\n\n static override styles = [\n commonReset,\n buttonReset,\n css`\n :host {\n --line-button-radius: var(--line-radius-2);\n --line-button-bg: var(--line-gray-bg);\n --line-button-color: var(--line-gray-text);\n --line-button-height: var(--line-size-7);\n --line-button-padding-inline: var(--line-size-3);\n --line-button-gap: var(--line-size-2);\n --line-button-font-size: var(--line-font-size-1);\n --line-button-font-weight: var(--line-font-weight-5);\n --line-button-focus-ring: var(--line-focus-ring, 2px solid currentColor);\n\n display: inline-block;\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host([variant='primary']) {\n --line-button-bg: var(--line-accent-solid);\n --line-button-color: var(--line-accent-contrast);\n }\n\n :host([variant='borderless']) {\n --line-button-bg: transparent;\n --line-button-color: var(--line-accent-text);\n }\n\n [part='root'] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: var(--line-button-gap);\n min-block-size: var(--line-button-height);\n padding-inline: var(--line-button-padding-inline);\n border-radius: var(--line-button-radius);\n background: var(--line-button-bg);\n color: var(--line-button-color);\n font-size: var(--line-button-font-size);\n font-weight: var(--line-button-font-weight);\n }\n\n :host([data-focus-visible]) [part='root'] {\n outline: var(--line-button-focus-ring);\n }\n `,\n ];\n\n /** Semantic emphasis; an unknown value behaves as `default`. */\n declare variant: ButtonVariant;\n /** What activation does to the form owner; an unknown value behaves as `submit`. */\n declare type: ButtonType;\n /** Removes the button from the tab order and blocks activation. */\n declare disabled: boolean;\n /** Keeps focus, sets `aria-disabled=\"true\"`, blocks activation and renders the `loading` part. */\n declare loading: boolean;\n /** `undefined` means not a toggle; a toggle flips it on each activation and fires `line-change`. */\n declare pressed: boolean | undefined;\n /** The submitter value; it enters the form data only when this button submits. */\n declare value: string;\n /** Overrides the form's `action` when this button submits. */\n declare formAction: string;\n /** Overrides the form's `method` when this button submits. */\n declare formMethod: ButtonFormMethod | undefined;\n /** Overrides the form's `enctype` when this button submits. */\n declare formEnctype: ButtonFormEnctype | undefined;\n /** Overrides the form's `target` when this button submits. */\n declare formTarget: string | undefined;\n /** Skips constraint validation when this button submits. */\n declare formNoValidate: boolean;\n /** External validity: a non-empty message marks the button invalid while `type` is `submit`. */\n declare customValidity: string;\n /** Copied to the inner button, where it names the role. */\n declare ariaLabel: string | null;\n /** Copied to the inner button. */\n declare ariaDescription: string | null;\n\n /** A disabled `fieldset` ancestor or the host's own `disabled`, from `formDisabledCallback`. */\n #formDisabled = false;\n\n readonly #onPressedChange = (next: boolean): void => {\n this.pressed = next;\n this.dispatchEvent(\n new CustomEvent<LineButtonChangeDetail>('line-change', {\n detail: { value: next },\n bubbles: true,\n composed: false,\n }),\n );\n };\n\n readonly #machineProps = (): ButtonMachineProps => ({\n disabled: this.disabled || this.#formDisabled,\n loading: this.loading,\n pressed: this.pressed,\n onPressedChange: this.#onPressedChange,\n });\n\n readonly #ctrl = new LineMachineController<ButtonMachineSchema>(this, {\n machine: buttonMachine,\n props: this.#machineProps,\n });\n\n constructor() {\n super();\n // `useDefault` keeps these initial values out of the attributes, so an unknown author value stays (C8).\n this.variant = 'default';\n this.type = 'submit';\n this.disabled = false;\n this.loading = false;\n this.value = '';\n this.formAction = '';\n this.formNoValidate = false;\n this.customValidity = '';\n this.addEventListener('click', this.#onClick, { capture: true });\n }\n\n override formDisabledCallback(disabled: boolean): void {\n this.#formDisabled = disabled;\n this.requestUpdate();\n }\n\n /** The machine view, or the static view from the host props when the machine failed to start. */\n #api(): ButtonApi {\n const service = this.#ctrl.service;\n return service && !this.#ctrl.fallback ? connect(service) : connectStatic(this.#machineProps());\n }\n\n /**\n * Stops a click while the button is not interactive. It listens in the\n * capture phase, so it runs before every bubble listener on the host,\n * including an inline `onclick` or a listener added before the upgrade.\n * Otherwise it activates in a later task, once the click dispatch has\n * ended, unless a listener called `preventDefault()`.\n */\n readonly #onClick = (event: MouseEvent): void => {\n if (!this.#api().interactive) {\n event.preventDefault();\n event.stopImmediatePropagation();\n return;\n }\n setTimeout(() => {\n if (!event.defaultPrevented) this.#activate();\n });\n };\n\n #activate(): void {\n this.#ctrl.send({ type: 'ACTIVATE' });\n const form = this.form;\n if (!form) return;\n if (this.type === 'reset') {\n // A control with id or name \"reset\" shadows the method on the form.\n HTMLFormElement.prototype.reset.call(form);\n } else if (this.type === 'submit') {\n this.#submit(form);\n }\n }\n\n /** Submits through a temporary native submitter, so the submission gets the native submitter semantics. */\n #submit(form: HTMLFormElement): void {\n const submitter = form.ownerDocument.createElement('button');\n submitter.type = 'submit';\n submitter.hidden = true;\n submitter.setAttribute('data-line-button-submitter', '');\n const name = this.getAttribute('name');\n if (name !== null) submitter.name = name;\n submitter.value = this.value;\n for (const attribute of FORM_ATTRIBUTES) {\n const value = this.getAttribute(attribute);\n if (value !== null) submitter.setAttribute(attribute, value);\n }\n form.append(submitter);\n try {\n submitter.click();\n } finally {\n submitter.remove();\n }\n }\n\n readonly #onPointerDown = (event: PointerEvent): void => {\n if (event.button !== 0) return;\n this.#ctrl.send({ type: 'PRESS_START' });\n const release = new AbortController();\n const end = (ended: Event): void => {\n release.abort();\n this.#ctrl.send({ type: ended.type === 'pointerup' ? 'PRESS_END' : 'PRESS_CANCEL' });\n };\n window.addEventListener('pointerup', end, { capture: true, signal: release.signal });\n window.addEventListener('pointercancel', end, { capture: true, signal: release.signal });\n };\n\n readonly #onKeyDown = (event: KeyboardEvent): void => {\n if (!event.repeat && (event.key === 'Enter' || event.key === ' ')) this.#ctrl.send({ type: 'PRESS_START' });\n };\n\n readonly #onKeyUp = (event: KeyboardEvent): void => {\n if (event.key === 'Enter' || event.key === ' ') this.#ctrl.send({ type: 'PRESS_END' });\n };\n\n readonly #onFocus = (event: FocusEvent): void => {\n const visible = (event.currentTarget as HTMLButtonElement).matches(':focus-visible');\n this.#ctrl.send({ type: 'FOCUS', visible });\n };\n\n readonly #onBlur = (): void => {\n this.#ctrl.send({ type: 'PRESS_CANCEL' });\n this.#ctrl.send({ type: 'BLUR' });\n };\n\n protected override update(changed: PropertyValues<this>): void {\n const api = this.#api();\n this.reflectState('active', api.active);\n this.reflectState('pressed', api.pressed);\n this.reflectState('loading', api.loading);\n this.reflectState('disabled', api.disabled);\n this.reflectState('focus-visible', api.focusVisible);\n super.update(changed);\n }\n\n protected override updated(changed: PropertyValues<this>): void {\n if (!(changed.has('customValidity') || changed.has('type'))) return;\n const message = this.type === 'submit' ? this.customValidity : '';\n const root = this.renderRoot.querySelector<HTMLButtonElement>('[part=\"root\"]') ?? undefined;\n if (message) {\n this.setValidity({ customError: true }, message, root);\n } else {\n this.setValidity({});\n }\n this.reflectState('invalid', message !== '');\n }\n\n override render(): TemplateResult {\n const { loading, buttonAttrs } = this.#api();\n return html`<button\n part=\"root\"\n type=\"button\"\n ?disabled=${buttonAttrs.disabled}\n aria-pressed=${ifDefined(buttonAttrs['aria-pressed'])}\n aria-disabled=${ifDefined(buttonAttrs['aria-disabled'])}\n aria-label=${ifDefined(this.ariaLabel ?? undefined)}\n aria-description=${ifDefined(this.ariaDescription ?? undefined)}\n @pointerdown=${this.#onPointerDown}\n @keydown=${this.#onKeyDown}\n @keyup=${this.#onKeyUp}\n @focus=${this.#onFocus}\n @blur=${this.#onBlur}\n ><slot name=\"prefix\"></slot><span part=\"label\"><slot></slot></span><slot name=\"suffix\"></slot>${\n loading ? html`<span part=\"loading\"><slot name=\"loading\"></slot></span>` : nothing\n }</button>`;\n }\n}\n\ncustomElements.define('line-button', LineButton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'line-button': LineButton;\n }\n}\n"],"mappings":";;;;;;;AA6CA,IAAaA,IAAgBC,EAAmC;CAC9D,oBAAoB;CACpB,UAAU,EAAE,mBAAgB,EAC1B,cAAcC,SAAyB,EAAE,cAAc,GAAM,EAAE,EACjE;CACA,MAAM,EAAE,UAAO,SAAM,UAAO,WAAQ;EAClC,EAAM,OAAOC,EAAK,UAAU,SAASA,EAAK,SAAS,CAAC,SAAS;GAC3D,AAAKC,EAAM,eAAe,KAAGC,EAAK,EAAE,MAAM,eAAe,CAAC;EAC5D,CAAC;CACH;CACA,IAAI;EACF,UAAU;GAAE,OAAO;GAAiB,SAAS,CAAC,eAAe;EAAE;EAC/D,OAAO,EAAE,SAAS,CAAC,iBAAiB,EAAE;EACtC,MAAM,EAAE,SAAS,CAAC,mBAAmB,EAAE;CACzC;CACA,QAAQ;EACN,MAAM,EACJ,IAAI,EAAE,aAAa;GAAE,QAAQ;GAAU,OAAO;EAAgB,EAAE,EAClE;EACA,QAAQ,EACN,IAAI;GACF,WAAW,EAAE,QAAQ,OAAO;GAC5B,cAAc,EAAE,QAAQ,OAAO;EACjC,EACF;CACF;CACA,iBAAiB;EACf,QAAQ,EACN,gBAAgB,EAAE,cAAW,EAAEF,EAAK,UAAU,KAAKA,EAAK,SAAS,GACnE;EACA,SAAS;GACP,cAAc,EAAE,WAAQ;IACtB,IAAMG,IAAUH,EAAK,SAAS;IAC9B,AAAIG,MAAY,KAAA,KAAWH,EAAK,iBAAiB,CAAC,GAAG,CAACG,CAAO;GAC/D;GACA,gBAAgB,EAAE,YAAS,YAAS;IAClC,EAAQ,IAAI,gBAAgBC,EAAM,SAAS,WAAWA,EAAM,YAAY,EAAI;GAC9E;GACA,kBAAkB,EAAE,cAAW;IAC7B,EAAQ,IAAI,gBAAgB,EAAK;GACnC;EACF;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AQ,GAC1C,KAAK,aAAa,iBAAiBA,EAAI,YAAY,GACnD,MAAM,OAAOyC,CAAO;CACtB;CAEA,QAA2B,GAAqC;EAC9D,IAAI,EAAEA,EAAQ,IAAI,gBAAgB,KAAKA,EAAQ,IAAI,MAAM,IAAI;EAC7D,IAAMC,IAAU,KAAK,SAAS,WAAW,KAAK,iBAAiB,IACzDC,IAAO,KAAK,WAAW,cAAiC,iBAAe,KAAK,KAAA;EAMlF,AALID,IACF,KAAK,YAAY,EAAE,aAAa,GAAK,GAAGA,GAASC,CAAI,IAErD,KAAK,YAAY,CAAC,CAAC,GAErB,KAAK,aAAa,WAAWD,MAAY,EAAE;CAC7C;CAEA,SAAkC;EAChC,IAAM,EAAE,YAAS,mBAAgB,KAAKZ,GAAK;EAC3C,OAAO,CAAI;;;kBAGGc,EAAY,SAAS;qBAClBC,EAAUD,EAAY,eAAe,EAAE;sBACtCC,EAAUD,EAAY,gBAAgB,EAAE;mBAC3CC,EAAU,KAAK,aAAa,KAAA,CAAS,EAAE;yBACjCA,EAAU,KAAK,mBAAmB,KAAA,CAAS,EAAE;qBACjD,KAAKC,GAAe;iBACxB,KAAKC,GAAW;eAClB,KAAKC,GAAS;eACd,KAAKC,GAAS;cACf,KAAKC,GAAQ;oGAErB/C,IAAU,CAAI,6DAA6DgD,EAC5E;CACH;AACF;AAEA,eAAe,OAAO,eAAelC,CAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/separator/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { INTERNALS as e, LineElement as t } from "@websublime/line-core";
|
|
2
|
+
import { commonReset as n } from "@websublime/line-core/styles";
|
|
3
|
+
import { css as r } from "lit";
|
|
4
|
+
//#region src/separator/separator.ts
|
|
5
|
+
var i = { fromAttribute: (e) => e === "vertical" ? "vertical" : "horizontal" }, a = class extends t {
|
|
6
|
+
static {
|
|
7
|
+
this.properties = {
|
|
8
|
+
orientation: {
|
|
9
|
+
reflect: !0,
|
|
10
|
+
useDefault: !0,
|
|
11
|
+
converter: i
|
|
12
|
+
},
|
|
13
|
+
decorative: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
reflect: !0,
|
|
16
|
+
useDefault: !0
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
static {
|
|
21
|
+
this.styles = [n, r`
|
|
22
|
+
:host {
|
|
23
|
+
--line-separator-color: var(--line-gray-6, currentColor);
|
|
24
|
+
--line-separator-thickness: var(--line-border-1, 1px);
|
|
25
|
+
|
|
26
|
+
display: block;
|
|
27
|
+
align-self: stretch;
|
|
28
|
+
flex-shrink: 0;
|
|
29
|
+
border-block-start-style: solid;
|
|
30
|
+
border-block-start-width: var(--line-separator-thickness);
|
|
31
|
+
border-block-start-color: var(--line-separator-color);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([hidden]) {
|
|
35
|
+
display: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:host([orientation='vertical']) {
|
|
39
|
+
inline-size: 0;
|
|
40
|
+
min-block-size: 1em;
|
|
41
|
+
border-block-start-style: none;
|
|
42
|
+
border-block-start-width: 0;
|
|
43
|
+
border-inline-start-style: solid;
|
|
44
|
+
border-inline-start-width: var(--line-separator-thickness);
|
|
45
|
+
border-inline-start-color: var(--line-separator-color);
|
|
46
|
+
}
|
|
47
|
+
`];
|
|
48
|
+
}
|
|
49
|
+
constructor() {
|
|
50
|
+
super(), this.orientation = "horizontal", this.decorative = !1;
|
|
51
|
+
}
|
|
52
|
+
willUpdate(t) {
|
|
53
|
+
if (super.willUpdate(t), this.hasUpdated && !t.has("orientation") && !t.has("decorative")) return;
|
|
54
|
+
let n = this[e];
|
|
55
|
+
n.role = this.decorative ? "none" : "separator", n.ariaOrientation = !this.decorative && this.orientation === "vertical" ? "vertical" : null;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
customElements.define("line-separator", a);
|
|
59
|
+
//#endregion
|
|
60
|
+
export { a as LineSeparator };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["orientationConverter","value","LineSeparator","LineElement","commonReset","changed","internals","INTERNALS"],"sources":["../../src/separator/separator.ts"],"sourcesContent":["import { INTERNALS, LineElement } from '@websublime/line-core';\nimport { commonReset } from '@websublime/line-core/styles';\nimport { type ComplexAttributeConverter, css, type PropertyDeclarations } from 'lit';\nimport type { SeparatorOrientation } from './separator.types.js';\n\n/** An unknown `orientation` behaves as `horizontal`; the attribute keeps what the author wrote (C8). */\nconst orientationConverter: ComplexAttributeConverter<SeparatorOrientation> = {\n fromAttribute: (value) => (value === 'vertical' ? 'vertical' : 'horizontal'),\n};\n\n/**\n * `<line-separator>` draws a thin line between sections of content. The host\n * is the line and the shadow root renders nothing. The host carries the\n * `separator` role and its orientation as `ElementInternals` defaults, so an\n * author `role` or `aria-*` attribute wins, and a host `aria-label` names it.\n * `decorative` sets the role to `none`, so assistive technology skips the\n * line; give a decorative separator no `aria-label`. It adds no spacing.\n *\n * @summary A thin horizontal or vertical line that separates sections of content.\n *\n * @cssprop [--line-separator-color=var(--line-gray-6, currentColor)] - Colour of the line.\n * @cssprop [--line-separator-thickness=var(--line-border-1, 1px)] - Thickness of the line.\n */\nexport class LineSeparator extends LineElement {\n static override properties: PropertyDeclarations = {\n orientation: { reflect: true, useDefault: true, converter: orientationConverter },\n decorative: { type: Boolean, reflect: true, useDefault: true },\n };\n\n // The line is one border side set through longhands: forced-colors mode keeps a border colour visible,\n // and an invalid var() in a shorthand would reset border-style to none (spec 0011-separator.md Drawing).\n static override styles = [\n commonReset,\n css`\n :host {\n --line-separator-color: var(--line-gray-6, currentColor);\n --line-separator-thickness: var(--line-border-1, 1px);\n\n display: block;\n align-self: stretch;\n flex-shrink: 0;\n border-block-start-style: solid;\n border-block-start-width: var(--line-separator-thickness);\n border-block-start-color: var(--line-separator-color);\n }\n\n :host([hidden]) {\n display: none;\n }\n\n :host([orientation='vertical']) {\n inline-size: 0;\n min-block-size: 1em;\n border-block-start-style: none;\n border-block-start-width: 0;\n border-inline-start-style: solid;\n border-inline-start-width: var(--line-separator-thickness);\n border-inline-start-color: var(--line-separator-color);\n }\n `,\n ];\n\n /** Direction of the line; an unknown value behaves as `horizontal`. */\n declare orientation: SeparatorOrientation;\n /** Removes the separator from the accessibility tree (role `none`); the line still draws. */\n declare decorative: 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 = 'horizontal';\n this.decorative = false;\n }\n\n protected override willUpdate(changed: Map<PropertyKey, unknown>): void {\n super.willUpdate(changed);\n // Lit leaves `useDefault` initial values out of the first `changed` map, so the first update always writes.\n if (this.hasUpdated && !changed.has('orientation') && !changed.has('decorative')) {\n return;\n }\n const internals = this[INTERNALS];\n internals.role = this.decorative ? 'none' : 'separator';\n internals.ariaOrientation = !this.decorative && this.orientation === 'vertical' ? 'vertical' : null;\n }\n}\n\ncustomElements.define('line-separator', LineSeparator);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'line-separator': LineSeparator;\n }\n}\n"],"mappings":";;;;AAMA,IAAMA,IAAwE,EAC5E,gBAAgB,MAAWC,MAAU,aAAa,aAAa,aACjE,GAeaC,IAAb,cAAmCC,EAAY;;EACM,KAAA,aAAA;GACjD,aAAa;IAAE,SAAS;IAAM,YAAY;IAAM,WAAWH;GAAqB;GAChF,YAAY;IAAE,MAAM;IAAS,SAAS;IAAM,YAAY;GAAK;EAC/D;;;EAIyB,KAAA,SAAA,CACvBI,GACA,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BL;;CAOA,cAAc;EAIZ,AAHA,MAAM,GAEN,KAAK,cAAc,cACnB,KAAK,aAAa;CACpB;CAEA,WAA8B,GAA0C;EAGtE,IAFA,MAAM,WAAWC,CAAO,GAEpB,KAAK,cAAc,CAACA,EAAQ,IAAI,aAAa,KAAK,CAACA,EAAQ,IAAI,YAAY,GAC7E;EAEF,IAAMC,IAAY,KAAKC;EAEvB,AADA,EAAU,OAAO,KAAK,aAAa,SAAS,aAC5C,EAAU,kBAAkB,CAAC,KAAK,cAAc,KAAK,gBAAgB,aAAa,aAAa;CACjG;AACF;AAEA,eAAe,OAAO,kBAAkBL,CAAa"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LineElement } from '@websublime/line-core';
|
|
2
|
+
import { type PropertyDeclarations } from 'lit';
|
|
3
|
+
import type { SeparatorOrientation } from './separator.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* `<line-separator>` draws a thin line between sections of content. The host
|
|
6
|
+
* is the line and the shadow root renders nothing. The host carries the
|
|
7
|
+
* `separator` role and its orientation as `ElementInternals` defaults, so an
|
|
8
|
+
* author `role` or `aria-*` attribute wins, and a host `aria-label` names it.
|
|
9
|
+
* `decorative` sets the role to `none`, so assistive technology skips the
|
|
10
|
+
* line; give a decorative separator no `aria-label`. It adds no spacing.
|
|
11
|
+
*
|
|
12
|
+
* @summary A thin horizontal or vertical line that separates sections of content.
|
|
13
|
+
*
|
|
14
|
+
* @cssprop [--line-separator-color=var(--line-gray-6, currentColor)] - Colour of the line.
|
|
15
|
+
* @cssprop [--line-separator-thickness=var(--line-border-1, 1px)] - Thickness of the line.
|
|
16
|
+
*/
|
|
17
|
+
export declare class LineSeparator extends LineElement {
|
|
18
|
+
static properties: PropertyDeclarations;
|
|
19
|
+
static styles: (import("lit").CSSResult | CSSStyleSheet)[];
|
|
20
|
+
/** Direction of the line; an unknown value behaves as `horizontal`. */
|
|
21
|
+
orientation: SeparatorOrientation;
|
|
22
|
+
/** Removes the separator from the accessibility tree (role `none`); the line still draws. */
|
|
23
|
+
decorative: boolean;
|
|
24
|
+
constructor();
|
|
25
|
+
protected willUpdate(changed: Map<PropertyKey, unknown>): void;
|
|
26
|
+
}
|
|
27
|
+
declare global {
|
|
28
|
+
interface HTMLElementTagNameMap {
|
|
29
|
+
'line-separator': LineSeparator;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=separator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"separator.d.ts","sourceRoot":"","sources":["../../src/separator/separator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAuC,KAAK,oBAAoB,EAAE,MAAM,KAAK,CAAC;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAOjE;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,OAAgB,UAAU,EAAE,oBAAoB,CAG9C;IAIF,OAAgB,MAAM,8CA6BpB;IAEF,uEAAuE;IAC/D,WAAW,EAAE,oBAAoB,CAAC;IAC1C,6FAA6F;IACrF,UAAU,EAAE,OAAO,CAAC;IAE5B,cAKC;IAED,UAAmB,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI,CAStE;CACF;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"separator.types.d.ts","sourceRoot":"","sources":["../../src/separator/separator.types.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,UAAU,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.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"types": "./dist/button/index.d.ts",
|
|
28
28
|
"import": "./dist/button/index.js"
|
|
29
29
|
},
|
|
30
|
+
"./separator": {
|
|
31
|
+
"types": "./dist/separator/index.d.ts",
|
|
32
|
+
"import": "./dist/separator/index.js"
|
|
33
|
+
},
|
|
30
34
|
"./stack": {
|
|
31
35
|
"types": "./dist/stack/index.d.ts",
|
|
32
36
|
"import": "./dist/stack/index.js"
|
package/src/button/button.ts
CHANGED
|
@@ -92,8 +92,8 @@ export class LineButton extends FormAssociated(LineElement) {
|
|
|
92
92
|
static override shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
93
93
|
|
|
94
94
|
static override properties: PropertyDeclarations = {
|
|
95
|
-
variant: { reflect: true, converter: variantConverter },
|
|
96
|
-
type: { reflect: true, converter: typeConverter },
|
|
95
|
+
variant: { reflect: true, useDefault: true, converter: variantConverter },
|
|
96
|
+
type: { reflect: true, useDefault: true, converter: typeConverter },
|
|
97
97
|
disabled: { type: Boolean, reflect: true },
|
|
98
98
|
loading: { type: Boolean, reflect: true },
|
|
99
99
|
pressed: { reflect: true, converter: pressedConverter },
|
|
@@ -217,6 +217,7 @@ export class LineButton extends FormAssociated(LineElement) {
|
|
|
217
217
|
|
|
218
218
|
constructor() {
|
|
219
219
|
super();
|
|
220
|
+
// `useDefault` keeps these initial values out of the attributes, so an unknown author value stays (C8).
|
|
220
221
|
this.variant = 'default';
|
|
221
222
|
this.type = 'submit';
|
|
222
223
|
this.disabled = false;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// biome-ignore lint/performance/noBarrelFile: the `./separator` subpath entry registers `line-separator` and exposes its class and types (spec 0011-separator.md Bundle).
|
|
2
|
+
export { LineSeparator } from './separator.js';
|
|
3
|
+
export type { SeparatorOrientation } from './separator.types.js';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { INTERNALS, LineElement } from '@websublime/line-core';
|
|
2
|
+
import { commonReset } from '@websublime/line-core/styles';
|
|
3
|
+
import { type ComplexAttributeConverter, css, type PropertyDeclarations } from 'lit';
|
|
4
|
+
import type { SeparatorOrientation } from './separator.types.js';
|
|
5
|
+
|
|
6
|
+
/** An unknown `orientation` behaves as `horizontal`; the attribute keeps what the author wrote (C8). */
|
|
7
|
+
const orientationConverter: ComplexAttributeConverter<SeparatorOrientation> = {
|
|
8
|
+
fromAttribute: (value) => (value === 'vertical' ? 'vertical' : 'horizontal'),
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* `<line-separator>` draws a thin line between sections of content. The host
|
|
13
|
+
* is the line and the shadow root renders nothing. The host carries the
|
|
14
|
+
* `separator` role and its orientation as `ElementInternals` defaults, so an
|
|
15
|
+
* author `role` or `aria-*` attribute wins, and a host `aria-label` names it.
|
|
16
|
+
* `decorative` sets the role to `none`, so assistive technology skips the
|
|
17
|
+
* line; give a decorative separator no `aria-label`. It adds no spacing.
|
|
18
|
+
*
|
|
19
|
+
* @summary A thin horizontal or vertical line that separates sections of content.
|
|
20
|
+
*
|
|
21
|
+
* @cssprop [--line-separator-color=var(--line-gray-6, currentColor)] - Colour of the line.
|
|
22
|
+
* @cssprop [--line-separator-thickness=var(--line-border-1, 1px)] - Thickness of the line.
|
|
23
|
+
*/
|
|
24
|
+
export class LineSeparator extends LineElement {
|
|
25
|
+
static override properties: PropertyDeclarations = {
|
|
26
|
+
orientation: { reflect: true, useDefault: true, converter: orientationConverter },
|
|
27
|
+
decorative: { type: Boolean, reflect: true, useDefault: true },
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// The line is one border side set through longhands: forced-colors mode keeps a border colour visible,
|
|
31
|
+
// and an invalid var() in a shorthand would reset border-style to none (spec 0011-separator.md Drawing).
|
|
32
|
+
static override styles = [
|
|
33
|
+
commonReset,
|
|
34
|
+
css`
|
|
35
|
+
:host {
|
|
36
|
+
--line-separator-color: var(--line-gray-6, currentColor);
|
|
37
|
+
--line-separator-thickness: var(--line-border-1, 1px);
|
|
38
|
+
|
|
39
|
+
display: block;
|
|
40
|
+
align-self: stretch;
|
|
41
|
+
flex-shrink: 0;
|
|
42
|
+
border-block-start-style: solid;
|
|
43
|
+
border-block-start-width: var(--line-separator-thickness);
|
|
44
|
+
border-block-start-color: var(--line-separator-color);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:host([hidden]) {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host([orientation='vertical']) {
|
|
52
|
+
inline-size: 0;
|
|
53
|
+
min-block-size: 1em;
|
|
54
|
+
border-block-start-style: none;
|
|
55
|
+
border-block-start-width: 0;
|
|
56
|
+
border-inline-start-style: solid;
|
|
57
|
+
border-inline-start-width: var(--line-separator-thickness);
|
|
58
|
+
border-inline-start-color: var(--line-separator-color);
|
|
59
|
+
}
|
|
60
|
+
`,
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
/** Direction of the line; an unknown value behaves as `horizontal`. */
|
|
64
|
+
declare orientation: SeparatorOrientation;
|
|
65
|
+
/** Removes the separator from the accessibility tree (role `none`); the line still draws. */
|
|
66
|
+
declare decorative: boolean;
|
|
67
|
+
|
|
68
|
+
constructor() {
|
|
69
|
+
super();
|
|
70
|
+
// `useDefault` keeps these initial values out of the attributes, so an unknown author value stays (C8).
|
|
71
|
+
this.orientation = 'horizontal';
|
|
72
|
+
this.decorative = false;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
protected override willUpdate(changed: Map<PropertyKey, unknown>): void {
|
|
76
|
+
super.willUpdate(changed);
|
|
77
|
+
// Lit leaves `useDefault` initial values out of the first `changed` map, so the first update always writes.
|
|
78
|
+
if (this.hasUpdated && !changed.has('orientation') && !changed.has('decorative')) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const internals = this[INTERNALS];
|
|
82
|
+
internals.role = this.decorative ? 'none' : 'separator';
|
|
83
|
+
internals.ariaOrientation = !this.decorative && this.orientation === 'vertical' ? 'vertical' : null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
customElements.define('line-separator', LineSeparator);
|
|
88
|
+
|
|
89
|
+
declare global {
|
|
90
|
+
interface HTMLElementTagNameMap {
|
|
91
|
+
'line-separator': LineSeparator;
|
|
92
|
+
}
|
|
93
|
+
}
|