@8sheets/data-grid 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/api/theme-core.js +2 -0
- package/calc/compile.js +1 -1
- package/calc/engine.js +1 -1
- package/calc/functions/info.js +1 -1
- package/calc/functions/math.js +1 -1
- package/calc/parser.js +3 -3
- package/calc/values.js +1 -1
- package/calcx/culture/custom.js +1 -0
- package/calcx/culture/format-locale.js +1 -1
- package/calcx/culture/separators.js +1 -0
- package/calcx/lang/convert.js +1 -0
- package/cells/axis-ops.js +1 -1
- package/cells/block.js +1 -0
- package/cells/book-css.js +2 -2
- package/cells/cell-defaults.js +1 -1
- package/cells/consolidate-links.js +1 -1
- package/cells/find-engine.js +2 -2
- package/cells/format-panes.js +3 -3
- package/cells/format-tabs.js +2 -2
- package/cells/outline-column.js +1 -1
- package/cells/panes.js +1 -1
- package/cells/selection-modes.js +1 -1
- package/cells/shift-check.js +1 -0
- package/cells/table-rows.js +1 -0
- package/cells/text-layout.js +9 -8
- package/cells/ui-kit.js +15 -0
- package/cells/view-options.js +1 -1
- package/celltypes/diagonal.js +1 -1
- package/celltypes/dropdowns.js +2 -2
- package/core/autofill.js +1 -1
- package/core/axis-styles.js +1 -0
- package/core/axis.js +1 -1
- package/core/culture.js +1 -0
- package/core/formula-refs.js +1 -1
- package/core/input.js +1 -1
- package/core/merge.js +1 -0
- package/core/numfmt.js +1 -1
- package/core/region-input.js +1 -0
- package/core/row-fit.js +1 -0
- package/core/sheet.js +1 -1
- package/core/structure.js +1 -0
- package/core/styles.js +1 -1
- package/core/tables.js +2 -2
- package/core/whatif.js +1 -1
- package/core/workbook.js +1 -1
- package/datasheets/data-core.js +1 -1
- package/datasheets/gantt-paint.js +1 -1
- package/datasheets/path-binding.js +2 -2
- package/datasheets/rules.js +1 -1
- package/datasheets/view.js +2 -2
- package/i18n/dom.js +1 -1
- package/i18n/en/cells.js +1 -1
- package/i18n/en/format.js +1 -1
- package/i18n/en/shell.js +2 -2
- package/i18n/pl/cells.js +1 -1
- package/i18n/pl/format.js +1 -1
- package/i18n/pl/shell.js +2 -2
- package/io/csv.js +8 -8
- package/io/plan.js +1 -1
- package/io/text-split.js +3 -3
- package/io/xlsx-write.js +1 -1
- package/objects/chart-model.js +1 -1
- package/package.json +1 -1
- package/pivot/engine.js +1 -1
- package/print/paginate.js +1 -1
- package/print/render-page.js +3 -3
- package/table-view/api.js +1 -1
- package/table-view/cell-editor.js +2 -1
- package/table-view/chart.js +1 -0
- package/table-view/column-drag.js +1 -1
- package/table-view/context-menu.js +1 -0
- package/table-view/editors.js +1 -0
- package/table-view/events.js +1 -1
- package/table-view/files.js +1 -1
- package/table-view/fill-handle.js +1 -0
- package/table-view/filter-builder.js +1 -0
- package/table-view/find.js +1 -0
- package/table-view/grid-keys.js +2 -2
- package/table-view/labels-de.js +1 -0
- package/table-view/labels-es.js +1 -0
- package/table-view/labels-fr.js +1 -0
- package/table-view/labels-ja.js +1 -0
- package/table-view/labels.js +1 -1
- package/table-view/model.js +1 -1
- package/table-view/mount.js +1 -1
- package/table-view/panel.js +1 -1
- package/table-view/pivot-spec.js +1 -0
- package/table-view/pivot.js +1 -1
- package/table-view/public.d.ts +277 -28
- package/table-view/reader.worker.js +1 -1
- package/table-view/remote.js +1 -1
- package/table-view/row-drag.js +1 -0
- package/table-view/sparkline.js +1 -0
- package/table-view/state-check.js +1 -0
- package/table-view/table-css.js +380 -0
- package/table-view/version.js +1 -1
- package/ui/dialogs.js +3 -3
- package/ui/menu-base.js +1 -1
package/table-view/table-css.js
CHANGED
|
@@ -1204,4 +1204,384 @@ td:nth-child(3n) .tv-skeleton {
|
|
|
1204
1204
|
opacity: 0.35;
|
|
1205
1205
|
}
|
|
1206
1206
|
}
|
|
1207
|
+
|
|
1208
|
+
/* Row density: the scrolling window's rows are --tv-row-h tall. */
|
|
1209
|
+
.tv-root {
|
|
1210
|
+
--tv-row-h: 34px;
|
|
1211
|
+
--tv-chart-0: light-dark(#3b6fb6, #7aa7e6);
|
|
1212
|
+
--tv-chart-1: light-dark(#d9822b, #f0a95b);
|
|
1213
|
+
--tv-chart-2: light-dark(#3f9a5b, #74c98e);
|
|
1214
|
+
--tv-chart-3: light-dark(#b8487a, #e283ae);
|
|
1215
|
+
--tv-chart-4: light-dark(#7a5bc0, #ab92ea);
|
|
1216
|
+
--tv-chart-5: light-dark(#6b7a8a, #a3b1bf);
|
|
1217
|
+
}
|
|
1218
|
+
.tv-data .tv-virtual tbody tr:not(.tv-spacer):not(.tv-detail) {
|
|
1219
|
+
height: var(--tv-row-h);
|
|
1220
|
+
}
|
|
1221
|
+
/* A scrolling window's rows take their height from --tv-row-h; a short table's from the cells' padding. */
|
|
1222
|
+
.tv-root[data-density='compact'] .tv-data table:not(.tv-virtual) td {
|
|
1223
|
+
padding-block: 2px;
|
|
1224
|
+
}
|
|
1225
|
+
.tv-root[data-density='compact'] .tv-data th {
|
|
1226
|
+
padding-block: 1px;
|
|
1227
|
+
}
|
|
1228
|
+
.tv-root[data-density='compact'] .tv-data td.tv-row-action button {
|
|
1229
|
+
min-height: 22px;
|
|
1230
|
+
}
|
|
1231
|
+
.tv-root[data-density='comfortable'] .tv-data table:not(.tv-virtual) td {
|
|
1232
|
+
padding-block: 9px;
|
|
1233
|
+
}
|
|
1234
|
+
.tv-data td.tv-tree-cell {
|
|
1235
|
+
text-align: start;
|
|
1236
|
+
}
|
|
1237
|
+
.tv-data td.tv-editing-list {
|
|
1238
|
+
box-shadow: inset 0 0 0 2px var(--tv-accent);
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
/* Header bands: one cell over the headings of a column group. */
|
|
1242
|
+
.tv-data th.tv-band {
|
|
1243
|
+
text-align: center;
|
|
1244
|
+
color: var(--tv-ink);
|
|
1245
|
+
font-size: 12px;
|
|
1246
|
+
padding-block: 3px;
|
|
1247
|
+
border-inline-start: 1px solid var(--tv-line);
|
|
1248
|
+
}
|
|
1249
|
+
.tv-data th.tv-band-empty {
|
|
1250
|
+
border-inline-start-color: transparent;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/* Pinned records: sticky under the headings or above the totals row. */
|
|
1254
|
+
.tv-data thead td {
|
|
1255
|
+
position: sticky;
|
|
1256
|
+
z-index: 2;
|
|
1257
|
+
background: var(--tv-bg);
|
|
1258
|
+
color: var(--tv-ink);
|
|
1259
|
+
font-weight: 400;
|
|
1260
|
+
}
|
|
1261
|
+
.tv-data thead td.tv-pinned,
|
|
1262
|
+
.tv-data tfoot tr.tv-pinned-row td.tv-pinned {
|
|
1263
|
+
z-index: 3;
|
|
1264
|
+
}
|
|
1265
|
+
.tv-data thead tr.tv-pinned-row:last-child td {
|
|
1266
|
+
border-bottom: 2px solid var(--tv-line);
|
|
1267
|
+
}
|
|
1268
|
+
.tv-data tfoot tr.tv-pinned-row td {
|
|
1269
|
+
background: var(--tv-bg);
|
|
1270
|
+
font-weight: 400;
|
|
1271
|
+
padding-block: 6px;
|
|
1272
|
+
}
|
|
1273
|
+
.tv-data tfoot tr.tv-pinned-row:first-child td {
|
|
1274
|
+
border-top: 2px solid var(--tv-line);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/* Row numbers, the move grip and the tree's indent and toggles. */
|
|
1278
|
+
.tv-row-number {
|
|
1279
|
+
display: inline-block;
|
|
1280
|
+
min-width: 2.6em;
|
|
1281
|
+
margin-inline-end: 2px;
|
|
1282
|
+
color: var(--tv-muted);
|
|
1283
|
+
font-size: 12px;
|
|
1284
|
+
text-align: end;
|
|
1285
|
+
vertical-align: middle;
|
|
1286
|
+
}
|
|
1287
|
+
.tv-row-grip {
|
|
1288
|
+
display: inline-flex;
|
|
1289
|
+
vertical-align: middle;
|
|
1290
|
+
color: var(--tv-muted);
|
|
1291
|
+
cursor: grab;
|
|
1292
|
+
touch-action: none;
|
|
1293
|
+
}
|
|
1294
|
+
.tv-row-grip .tv-icon {
|
|
1295
|
+
stroke-width: 2.4;
|
|
1296
|
+
}
|
|
1297
|
+
.tv-row-ghost {
|
|
1298
|
+
position: fixed;
|
|
1299
|
+
}
|
|
1300
|
+
.tv-row-marker {
|
|
1301
|
+
position: fixed;
|
|
1302
|
+
z-index: 31;
|
|
1303
|
+
height: 2px;
|
|
1304
|
+
background: var(--tv-accent);
|
|
1305
|
+
pointer-events: none;
|
|
1306
|
+
}
|
|
1307
|
+
.tv-root.tv-drop-target {
|
|
1308
|
+
outline: 2px dashed var(--tv-accent);
|
|
1309
|
+
outline-offset: -2px;
|
|
1310
|
+
}
|
|
1311
|
+
.tv-tree-indent,
|
|
1312
|
+
.tv-tree-leaf {
|
|
1313
|
+
display: inline-block;
|
|
1314
|
+
vertical-align: middle;
|
|
1315
|
+
}
|
|
1316
|
+
.tv-tree-leaf {
|
|
1317
|
+
width: 24px;
|
|
1318
|
+
}
|
|
1319
|
+
.tv-root .tv-data button.tv-tree-toggle {
|
|
1320
|
+
width: 22px;
|
|
1321
|
+
min-height: 22px;
|
|
1322
|
+
margin-inline-end: 2px;
|
|
1323
|
+
vertical-align: middle;
|
|
1324
|
+
}
|
|
1325
|
+
.tv-root .tv-data button.tv-tree-toggle .tv-icon {
|
|
1326
|
+
width: 13px;
|
|
1327
|
+
height: 13px;
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
/* Cells drawn as controls or pictures: a boolean's box and sparklines. */
|
|
1331
|
+
.tv-data input.tv-cell-check {
|
|
1332
|
+
margin: 0;
|
|
1333
|
+
vertical-align: middle;
|
|
1334
|
+
}
|
|
1335
|
+
.tv-data td.tv-spark-cell {
|
|
1336
|
+
padding-block: 0;
|
|
1337
|
+
line-height: 0;
|
|
1338
|
+
}
|
|
1339
|
+
.tv-spark {
|
|
1340
|
+
vertical-align: middle;
|
|
1341
|
+
overflow: visible;
|
|
1342
|
+
}
|
|
1343
|
+
.tv-spark-line {
|
|
1344
|
+
fill: none;
|
|
1345
|
+
stroke: var(--tv-accent);
|
|
1346
|
+
stroke-width: 1.5;
|
|
1347
|
+
stroke-linejoin: round;
|
|
1348
|
+
}
|
|
1349
|
+
.tv-spark-dot {
|
|
1350
|
+
fill: var(--tv-accent);
|
|
1351
|
+
}
|
|
1352
|
+
.tv-spark-bar {
|
|
1353
|
+
fill: var(--tv-cf-bar);
|
|
1354
|
+
}
|
|
1355
|
+
.tv-spark-negative {
|
|
1356
|
+
fill: var(--tv-cf-bar-negative);
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/* Changed values flash once; find hits are marked, the current one outlined. */
|
|
1360
|
+
.tv-data td.tv-flash {
|
|
1361
|
+
animation: tv-flash 0.9s ease-out;
|
|
1362
|
+
}
|
|
1363
|
+
@keyframes tv-flash {
|
|
1364
|
+
from {
|
|
1365
|
+
background: color-mix(in srgb, var(--tv-accent) 32%, var(--tv-bg));
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1369
|
+
.tv-data td.tv-flash {
|
|
1370
|
+
animation: none;
|
|
1371
|
+
box-shadow: inset 0 0 0 2px var(--tv-accent);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
.tv-root {
|
|
1375
|
+
--tv-find: light-dark(#fff1b8, #5a4a10);
|
|
1376
|
+
--tv-find-current: light-dark(#d89b00, #ffcc33);
|
|
1377
|
+
}
|
|
1378
|
+
.tv-data td.tv-find-hit {
|
|
1379
|
+
background: var(--tv-find);
|
|
1380
|
+
}
|
|
1381
|
+
.tv-data td.tv-find-current {
|
|
1382
|
+
box-shadow: inset 0 0 0 2px var(--tv-find-current);
|
|
1383
|
+
}
|
|
1384
|
+
.tv-find {
|
|
1385
|
+
display: flex;
|
|
1386
|
+
align-items: center;
|
|
1387
|
+
gap: 6px;
|
|
1388
|
+
padding: 2px 8px;
|
|
1389
|
+
border-bottom: 1px solid var(--tv-line);
|
|
1390
|
+
color: var(--tv-muted);
|
|
1391
|
+
}
|
|
1392
|
+
.tv-root .tv-find input {
|
|
1393
|
+
flex: 0 1 280px;
|
|
1394
|
+
min-width: 0;
|
|
1395
|
+
}
|
|
1396
|
+
.tv-find-count {
|
|
1397
|
+
min-width: 6em;
|
|
1398
|
+
font-size: 13px;
|
|
1399
|
+
font-variant-numeric: tabular-nums;
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
/* The context menu opens at the pointer; shortcuts sit at the end of their items. */
|
|
1403
|
+
.tv-menu-point {
|
|
1404
|
+
position: absolute;
|
|
1405
|
+
width: 0;
|
|
1406
|
+
height: 0;
|
|
1407
|
+
}
|
|
1408
|
+
.tv-shortcut {
|
|
1409
|
+
margin-inline-start: auto;
|
|
1410
|
+
padding-inline-start: 18px;
|
|
1411
|
+
color: var(--tv-muted);
|
|
1412
|
+
font: inherit;
|
|
1413
|
+
font-size: 12px;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/* The fill handle at the corner of the cell range. */
|
|
1417
|
+
.tv-data td.tv-has-handle:not(.tv-pinned) {
|
|
1418
|
+
position: relative;
|
|
1419
|
+
}
|
|
1420
|
+
.tv-fill-handle {
|
|
1421
|
+
position: absolute;
|
|
1422
|
+
inset-inline-end: 0;
|
|
1423
|
+
bottom: 0;
|
|
1424
|
+
width: 7px;
|
|
1425
|
+
height: 7px;
|
|
1426
|
+
background: var(--tv-accent);
|
|
1427
|
+
border: 1px solid var(--tv-bg);
|
|
1428
|
+
cursor: crosshair;
|
|
1429
|
+
touch-action: none;
|
|
1430
|
+
}
|
|
1431
|
+
.tv-data td.tv-fill-preview {
|
|
1432
|
+
background: var(--tv-tint);
|
|
1433
|
+
box-shadow: inset 0 0 0 1px var(--tv-accent);
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
/* Typed editors. */
|
|
1437
|
+
.tv-select-editor {
|
|
1438
|
+
display: block;
|
|
1439
|
+
}
|
|
1440
|
+
.tv-select-editor input {
|
|
1441
|
+
width: 100%;
|
|
1442
|
+
}
|
|
1443
|
+
.tv-root .tv-data textarea.tv-cell-area {
|
|
1444
|
+
resize: none;
|
|
1445
|
+
font: inherit;
|
|
1446
|
+
}
|
|
1447
|
+
.tv-cell-popup {
|
|
1448
|
+
position: absolute;
|
|
1449
|
+
z-index: 20;
|
|
1450
|
+
display: grid;
|
|
1451
|
+
gap: 8px;
|
|
1452
|
+
min-width: 180px;
|
|
1453
|
+
max-height: 300px;
|
|
1454
|
+
overflow: auto;
|
|
1455
|
+
padding: 10px;
|
|
1456
|
+
border: 1px solid var(--tv-line);
|
|
1457
|
+
border-radius: 8px;
|
|
1458
|
+
background: var(--tv-bg);
|
|
1459
|
+
box-shadow: var(--tv-shadow);
|
|
1460
|
+
}
|
|
1461
|
+
.tv-choices {
|
|
1462
|
+
display: grid;
|
|
1463
|
+
gap: 2px;
|
|
1464
|
+
}
|
|
1465
|
+
.tv-choices label {
|
|
1466
|
+
display: flex;
|
|
1467
|
+
gap: 8px;
|
|
1468
|
+
align-items: center;
|
|
1469
|
+
}
|
|
1470
|
+
.tv-field-group {
|
|
1471
|
+
display: grid;
|
|
1472
|
+
gap: 4px;
|
|
1473
|
+
}
|
|
1474
|
+
.tv-field-group > span,
|
|
1475
|
+
.tv-form-heading {
|
|
1476
|
+
font-size: 13px;
|
|
1477
|
+
font-weight: 600;
|
|
1478
|
+
}
|
|
1479
|
+
.tv-rename {
|
|
1480
|
+
width: 100%;
|
|
1481
|
+
min-width: 60px;
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
/* Grouping by dropping a heading. */
|
|
1485
|
+
.tv-group-zone {
|
|
1486
|
+
padding: 3px 10px;
|
|
1487
|
+
border: 1px dashed var(--tv-muted);
|
|
1488
|
+
border-radius: 6px;
|
|
1489
|
+
color: var(--tv-muted);
|
|
1490
|
+
font-size: 13px;
|
|
1491
|
+
}
|
|
1492
|
+
.tv-group-zone.tv-over {
|
|
1493
|
+
border-color: var(--tv-accent);
|
|
1494
|
+
background: var(--tv-tint);
|
|
1495
|
+
color: var(--tv-ink);
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
/* Quick charts. */
|
|
1499
|
+
.tv-chart-figure {
|
|
1500
|
+
margin: 0;
|
|
1501
|
+
}
|
|
1502
|
+
.tv-qchart {
|
|
1503
|
+
width: 100%;
|
|
1504
|
+
max-width: 640px;
|
|
1505
|
+
height: auto;
|
|
1506
|
+
}
|
|
1507
|
+
.tv-qchart-label {
|
|
1508
|
+
font-size: 14px;
|
|
1509
|
+
fill: var(--tv-muted);
|
|
1510
|
+
}
|
|
1511
|
+
.tv-qchart-grid {
|
|
1512
|
+
stroke: var(--tv-line);
|
|
1513
|
+
}
|
|
1514
|
+
.tv-qchart-axis {
|
|
1515
|
+
stroke: var(--tv-muted);
|
|
1516
|
+
}
|
|
1517
|
+
.tv-qchart-line {
|
|
1518
|
+
fill: none !important;
|
|
1519
|
+
stroke-width: 2;
|
|
1520
|
+
}
|
|
1521
|
+
.tv-qchart-s0 { fill: var(--tv-chart-0); stroke: var(--tv-chart-0); }
|
|
1522
|
+
.tv-qchart-s1 { fill: var(--tv-chart-1); stroke: var(--tv-chart-1); }
|
|
1523
|
+
.tv-qchart-s2 { fill: var(--tv-chart-2); stroke: var(--tv-chart-2); }
|
|
1524
|
+
.tv-qchart-s3 { fill: var(--tv-chart-3); stroke: var(--tv-chart-3); }
|
|
1525
|
+
.tv-qchart-s4 { fill: var(--tv-chart-4); stroke: var(--tv-chart-4); }
|
|
1526
|
+
.tv-qchart-s5 { fill: var(--tv-chart-5); stroke: var(--tv-chart-5); }
|
|
1527
|
+
.tv-qchart-slice {
|
|
1528
|
+
stroke: var(--tv-bg);
|
|
1529
|
+
stroke-width: 1;
|
|
1530
|
+
}
|
|
1531
|
+
.tv-qchart-bar {
|
|
1532
|
+
stroke: none;
|
|
1533
|
+
}
|
|
1534
|
+
.tv-form > button.tv-chart-save {
|
|
1535
|
+
justify-self: start;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
/* The filter builder and the pivot's values. */
|
|
1539
|
+
.tv-filter-list {
|
|
1540
|
+
display: grid;
|
|
1541
|
+
gap: 6px;
|
|
1542
|
+
}
|
|
1543
|
+
.tv-filter-line {
|
|
1544
|
+
display: flex;
|
|
1545
|
+
flex-wrap: wrap;
|
|
1546
|
+
gap: 6px;
|
|
1547
|
+
align-items: center;
|
|
1548
|
+
}
|
|
1549
|
+
.tv-root .tv-filter-line select,
|
|
1550
|
+
.tv-root .tv-filter-line input {
|
|
1551
|
+
flex: 1 1 110px;
|
|
1552
|
+
min-width: 0;
|
|
1553
|
+
}
|
|
1554
|
+
.tv-filter-group {
|
|
1555
|
+
display: grid;
|
|
1556
|
+
gap: 6px;
|
|
1557
|
+
margin: 0;
|
|
1558
|
+
padding: 8px;
|
|
1559
|
+
border: 1px solid var(--tv-line);
|
|
1560
|
+
border-radius: 8px;
|
|
1561
|
+
}
|
|
1562
|
+
.tv-filter-group legend {
|
|
1563
|
+
display: flex;
|
|
1564
|
+
gap: 6px;
|
|
1565
|
+
align-items: center;
|
|
1566
|
+
padding-inline: 4px;
|
|
1567
|
+
}
|
|
1568
|
+
.tv-filter-tools {
|
|
1569
|
+
display: flex;
|
|
1570
|
+
flex-wrap: wrap;
|
|
1571
|
+
gap: 8px;
|
|
1572
|
+
}
|
|
1573
|
+
.tv-pivot-values {
|
|
1574
|
+
display: grid;
|
|
1575
|
+
gap: 6px;
|
|
1576
|
+
}
|
|
1577
|
+
.tv-root .tv-pivot-values .tv-column select {
|
|
1578
|
+
flex: 1 1 0;
|
|
1579
|
+
min-width: 0;
|
|
1580
|
+
}
|
|
1581
|
+
.tv-assistant-reply {
|
|
1582
|
+
min-height: 1.4em;
|
|
1583
|
+
margin: 0;
|
|
1584
|
+
color: var(--tv-muted);
|
|
1585
|
+
white-space: pre-wrap;
|
|
1586
|
+
}
|
|
1207
1587
|
`;export{n as default};
|
package/table-view/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="1.0
|
|
1
|
+
const o="1.1.0";export{o as VERSION};
|
package/ui/dialogs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{scaleToApp as
|
|
2
|
-
`).map(n=>s("p",{class:"dlg-message",textContent:n}))),[{label:"OK",primary:!0}],{width:o,onClose:()=>a()})})}function
|
|
3
|
-
`).map(p=>s("p",{class:"dlg-message",textContent:p}))),[{label:a,cancel:!0},{label:o,primary:!0,action:()=>{
|
|
1
|
+
import{FormulaSyntaxError as N}from"../calc/parser.js";import{scaleToApp as R}from"./ui-scale.js";import{openFillEffects as $}from"../cells/cell-options-ui.js";import{overlayRoot as j}from"../api/overlay.js";import{applyBorderEdges as D,borderTab as I,formatCodeProblem as q,numberTab as H}from"../cells/format-tabs.js";import{alignmentTab as X,fillTab as _,fontTab as G,protectionTab as U}from"../cells/format-panes.js";import{setBorderRadius as V}from"../cells/rounded.js";import{getFormatter as L}from"../core/numfmt.js";import{MAX_COLS as W,MAX_ROWS as z}from"../core/address.js";import{FORMULA as J,KIND_MASK as Q,STR as Y}from"../core/sheet.js";import{el as s}from"./dom.js";import{t as d}from"../i18n/index.js";const x=[];function k(r,m,i,o,{onClose:a,width:n,className:c}={}){const t=s("dialog",{class:c?`dlg ${c}`:"dlg"});n&&(t.style.width=`${n}px`),R(r,t);const p=typeof document<"u"?document.activeElement:null,g=x.at(-1)??null,u={dlg:t};let b=!1;const E=()=>{b=!0,t.open&&t.close(),t.remove();const e=x.indexOf(u);e>=0&&x.splice(e,1)};r.signal?.addEventListener("abort",E,{once:!0});const w=(e="close")=>{if(b)return;b=!0,r.signal?.removeEventListener("abort",E),t.open&&t.close(),t.remove();const f=x.indexOf(u);f>=0&&x.splice(f,1),a?.(e);const h=x.at(-1)??null;h===null?r.controller.focusGrid():h===g&&(p&&g.dlg.contains(p)?p:g.dlg).focus()},v=o.find(e=>e.cancel)??o.find(e=>e.label==="Cancel")??o.find(e=>e.label==="Close")??null,F=()=>{b||v?.action?.()!==!1&&w("escape")},A=e=>{try{e.action?.()!==!1&&w(e.label)}catch(f){if(!(f instanceof N))throw f;B(r,"8sheets",f.message)}},C=s("div",{class:"dlg-foot"},...o.map(e=>s("button",{class:`dlg-btn${e.primary?" primary":""}${e.left?" dlg-left":""}`,textContent:d(e.label),type:"button",on:{click:()=>A(e)}})));t.append(s("h2",{class:"dlg-title",textContent:d(m)}),s("div",{class:"dlg-body"},i),C),t.addEventListener("cancel",e=>{e.preventDefault(),F()}),t.addEventListener("keydown",e=>{if(e.stopPropagation(),e.key==="Escape"&&!e.isComposing&&!e.defaultPrevented){e.preventDefault(),F();return}const f=e.target.tagName==="BUTTON"&&!C.contains(e.target);if(e.key==="Enter"&&!e.isComposing&&e.target.tagName!=="TEXTAREA"&&!f&&!e.defaultPrevented){const h=o.find(O=>O.primary);h&&(e.preventDefault(),A(h))}}),j().append(t);for(const e of t.querySelectorAll(".dlg-tabs"))Z(e);if(x.push(u),t.showModal(),c?.includes("xl-dlg"))t.tabIndex=-1,t.focus();else if(C.contains(document.activeElement))C.querySelector(".dlg-btn.primary")?.focus();else{const e=document.activeElement;e instanceof HTMLInputElement&&t.contains(e)&&/^(text|number|search|)$/.test(e.type)&&e.value!==""&&e.select()}return{dlg:t,close:w}}function Z(r){const m=()=>[...r.querySelectorAll('[role="tab"]')].filter(o=>!o.hidden),i=()=>{const o=m(),a=o.find(n=>n.getAttribute("aria-selected")==="true")??o[0];for(const n of o)n.tabIndex=n===a?0:-1};i(),new MutationObserver(i).observe(r,{attributes:!0,subtree:!0,attributeFilter:["aria-selected","hidden"]}),r.addEventListener("keydown",o=>{if(o.key!=="ArrowLeft"&&o.key!=="ArrowRight"&&o.key!=="Home"&&o.key!=="End")return;const a=m(),n=a.indexOf(document.activeElement);if(n<0)return;o.preventDefault();const c=o.key==="Home"?0:o.key==="End"?a.length-1:(n+(o.key==="ArrowLeft"?-1:1)+a.length)%a.length;a[c].focus(),a[c].click()})}function me(r,m="Number",i={}){const{commands:o,grid:a,book:n}=r,c=i.base??o.activeStyle(),t=a.selection,p=n.sheet.kind(t.row,t.col)&Q,g=p===1?n.sheet.value(t.row,t.col):1234.5,u={},b={},E=s("div",{class:"dlg-tabs",role:"tablist"}),w=s("div",{class:"dlg-panes"}),v=(l,y)=>{const T=s("button",{type:"button",role:"tab",class:"dlg-tab",textContent:d(`fc.tab|${l}`),dataset:{tab:l},on:{click:()=>F(l)}});b[l]={btn:T,content:y},E.append(T),w.append(y)},F=l=>{for(const[y,T]of Object.entries(b))T.btn.setAttribute("aria-selected",String(y===l)),T.content.hidden=y!==l;b[l].content.onShow?.()},A=l=>{try{return p===2?L(l).text(n.strings.get(n.sheet.value(t.row,t.col))):L(l).number(g).replace(/\u0001.?\u0001/g," ")}catch{return""}},C=[...new Set(n.styles.list.map(l=>l.numFmt))];v("Number",H(c.numFmt,A,l=>{u.numFmt=l},C));const e=n.sheet.mergeAt(t.row,t.col)!==null;let f;v("Alignment",X(c,u,e,l=>{f=l})),v("Font",G(c,n.styles.get(0),u,r.objects?.theme?.majorFont,n.theme));const h=t.ranges.length===1&&t.ranges[0].r0===t.ranges[0].r1&&t.ranges[0].c0===t.ranges[0].c1;let O=null;v("Border",I(c.borders,!h,l=>{O=l},n.theme));const S=s("input",{class:"dlg-input short",value:(c.ext?.radius??[]).join(" "),"aria-label":d("Corner radius in points"),spellcheck:!1}),P=s("select",{class:"dlg-input fc-grow","aria-label":d("Corner radius applies to")},s("option",{value:"all",textContent:d("Every cell")}),s("option",{value:"outer",textContent:d("Outer corners of the selection")}));b.Border.content.append(s("div",{class:"dlg-row fc-radius"},d("Rounded corners (points, not in Excel):"),S,P)),v("Fill",_(c,u,(l,y)=>$(r,l,y),n.theme)),v("Protection",U(c,u));const K=s("div",{class:"fc-body"},E,w),M=r.controller.isEditing;if(M)for(const[l,y]of Object.entries(b))l!=="Font"&&(y.btn.hidden=!0);k(r,"dlg|Format Cells",K,[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{u.numFmt===c.numFmt&&delete u.numFmt,M&&delete u.numFmt;const l=u.numFmt?q(u.numFmt):null;if(l)return B(r,"dlg|Format Cells",d("This number format can't be used. {problem}",{problem:d(l)})),!1;if(i.onPick){i.onPick(u);return}Object.keys(u).length&&o.apply(u),f!==void 0&&f!==e&&o.toggleMerge(f?"merge":"unmerge"),O!==null&&D(r,O),S.value.trim()!==(c.ext?.radius??[]).join(" ")&&V(n,t.ranges,S.value,P.value),r.afterCommand()}}],{width:616,className:"xl-dlg fc-dlg"}),F(M?"Font":m)}function fe(r,m,i,o,a,n,c){const t=s("input",{class:"dlg-input",type:"number",min:a,max:n,step:"any",value:o,"aria-label":d(i)}),p=k(r,m,s("label",{class:"dlg-row"},`${d(i)} `,t),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{const g=Number(t.value);return!Number.isFinite(g)||g<a||g>n?(t.setCustomValidity(d("Enter a number from {min} to {max}",{min:a,max:n})),t.reportValidity(),!1):(c(g),!0)}}],{width:320});return t.select(),p}function pe(r,m,i,o,a){const n=s("input",{class:"dlg-input",value:o,"aria-label":d(i),spellcheck:!1});k(r,m,s("label",{class:"dlg-row"},`${d(i)} `,n),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{a(n.value.trim())}}],{width:420}),n.select()}import{openGoTo as he}from"../cells/goto.js";import{openFind as we}from"../cells/find.js";function B(r,m,i,{width:o=380}={}){return new Promise(a=>{k(r,m,s("div",{class:"dlg-col"},...d(String(i)).split(`
|
|
2
|
+
`).map(n=>s("p",{class:"dlg-message",textContent:n}))),[{label:"OK",primary:!0}],{width:o,onClose:()=>a()})})}function ge(r,m,i,{ok:o="OK",cancel:a="Cancel",width:n=380}={}){return new Promise(c=>{let t=!1;k(r,m,s("div",{class:"dlg-col"},...d(String(i)).split(`
|
|
3
|
+
`).map(p=>s("p",{class:"dlg-message",textContent:p}))),[{label:a,cancel:!0},{label:o,primary:!0,action:()=>{t=!0}}],{width:n,onClose:()=>c(t)})})}function be(r,m,i){return new Promise(o=>{let a=null;const n=s("input",{type:"password",class:"dlg-input",autocomplete:"off","aria-label":d("Password")});k(r,m,s("div",{class:"dlg-col"},s("p",{textContent:d(i)}),n),[{label:"Cancel"},{label:"OK",primary:!0,action:()=>{a=n.value}}],{width:340,onClose:()=>o(a)}),n.focus()})}export{J as FORMULA,W as MAX_COLS,z as MAX_ROWS,Y as STR,be as askPassword,ge as confirmModal,s as el,we as openFind,me as openFormatCells,he as openGoTo,k as openModal,fe as promptNumber,pe as promptText,B as showMessage};
|
package/ui/menu-base.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{overlayRoot as
|
|
1
|
+
import{overlayRoot as p}from"../api/overlay.js";import{decorateMenuItem as v}from"../cells/menu-extras.js";import{defaultTheme as k,makeRef as f,themeArray as w}from"../api/theme-core.js";import{t as u}from"../i18n/index.js";import{icon as A}from"./icons.js";import{placeAt as h,scaleToApp as C}from"./ui-scale.js";const M={Cut:"cut",Copy:"copy",Paste:"paste","Paste Special…":"paste","Insert…":"insertCells",Insert:"insertCells","Insert Rows":"insertCells","Insert Columns":"insertCells","Insert Sheet":"insertCells","Delete…":"deleteCells",Delete:"deleteCells","Delete Rows":"deleteCells","Delete Columns":"deleteCells","Delete Sheet":"deleteCells","Clear Contents":"eraser",Filter:"filter",Sort:"sort","Sort A to Z":"sort","Sort Z to A":"sortZA","Custom Sort…":"sortCustom","Clear Filter":"filterClear",Reapply:"filterReapply","Format Cells…":"formatCells","Column Width…":"formatCells","Row Height…":"formatCells","New Comment":"note","Reply to Comment":"note","Delete Comment":"deleteComment","New Note":"notes","Edit Note":"notes","Delete Note":"deleteComment","Define Name…":"nameDefine","Link…":"link","Cell Alt Text…":"altText","Rich Text…":"textEffects","Default Value…":"cellOptions","Bring to Front":"front","Send to Back":"back","Bring Forward":"forward","Send Backward":"backward","Merge & Center":"merge","Merge Across":"merge","Merge Cells":"merge","Unmerge Cells":"merge","Find…":"find",Rename:"nameDefine","Protect Sheet…":"protect",Hide:"hideWindow",Unhide:"unhideWindow","Unhide…":"unhideWindow"},g=w(k()),b=["#C00000","#FF0000","#FFC000","#FFFF00","#92D050","#00B050","#00B0F0","#0070C0","#002060","#7030A0"];function B(r){const t=r?.length>=10?r:g,n=[];for(const e of[0,.8,.6,.4,-.25,-.5])for(let o=0;o<10;o++){const i=o===0?-Math.abs(e)*.6:(o===1||o===3)&&e<0?-e:e;n.push(f(o,i,t))}return{theme:n.map(e=>e.hex),refs:n,standard:b}}function E(r,t){return t&&typeof t=="object"?f(t.t,t.tint,r.theme?.length>=10?r.theme:g):t}function R(r){const t=String(r).replace(/\s*\([^)]*\)\s*$/,"").split(/[^A-Za-z0-9]+/).filter(Boolean),n=(e,o)=>{const i=e===e.toUpperCase()&&e.length>1?e[0]+e.slice(1).toLowerCase():e;return o===0?i[0].toLowerCase()+i.slice(1):i[0].toUpperCase()+i.slice(1)};return t.map(n).join("")}const T=Symbol("cancelled");function y(r,t,n,e,o){return t&&r.actionGate?r.actionGate(t,n,e,o):e()}class F{constructor(t){this.app=t,this.menu=null,t.signal?.addEventListener("abort",()=>{this.menu?.remove(),this.menu=null,this.menuBar?.remove(),this.menuBar=null}),t.listen(document,"pointerdown",n=>{this.menu&&!this.menu.contains(n.target)&&!this.menuBar?.contains(n.target)&&this.closeMenu()},!0),t.listen(document,"keydown",n=>{n.key==="Escape"&&this.menu&&!document.activeElement?.closest?.(".bk-sub-menu")&&this.closeMenu()},!0)}openMenuAt(t,n,e){this.openMenu({getBoundingClientRect:()=>({left:t,bottom:n})},e);const o=this.menu.getBoundingClientRect();if(h(this.menu,null,Math.min(n,window.innerHeight-o.height-6)),e.miniBar){const i=e.miniBar(this);C(this.app,i),p().append(i);const a=this.menu.getBoundingClientRect(),s=i.getBoundingClientRect(),m=a.top-s.height-6>=4?a.top-s.height-6:a.bottom+6;h(i,Math.max(4,Math.min(a.left,window.innerWidth-s.width-6)),m),this.menuBar=i}}openMenu(t,n){this.closeMenu(),this.menuOpener=document.activeElement,this.menuAnchor=t instanceof Element?t:null,this.menuAnchor?.setAttribute("aria-expanded","true");const e=document.createElement("div");e.className="menu",e.role="menu",n.palette?this._fillPalette(e,n):n.build?n.build(e):this._fillItems(e,n),C(this.app,e),p().append(e);const o=t.getBoundingClientRect(),i=e.getBoundingClientRect();h(e,Math.min(o.left,window.innerWidth-i.width-6),o.bottom+3),this.menu=e}buildMenu(t){const n=document.createElement("div");return n.className="menu",n.role="menu",t.palette?this._fillPalette(n,t):this._fillItems(n,t),n}_fillItems(t,n){for(const e of n.items){if(e===null){t.append(document.createElement("hr"));continue}const o=e[2],i=e.id===void 0&&!o?.raw&&e[0]?`${this.menuAnchor?.dataset.command??"menu"}.${R(o?.name??e[0])}`:null,a=this.menuAnchor?.dataset.command?"ribbon":"menu";if(i&&this.hiddenIds?.has(i))continue;const s=document.createElement("button");s.textContent=o?.raw?e[0]:o?.text??u(e[0]);const m=o?.icon??(o?.raw?void 0:M[e[0]]);if(m&&(s.insertAdjacentHTML("afterbegin",`<span class="mi-ic">${A(m,16)}</span>`),t.classList.add("menu-icons")),o?.raw||(s.dataset.item=e[0]),t.append(s),!(o&&v(this,s,o))){if(i&&(s.dataset.command=i),e[1]==null){s.disabled=!0;continue}s.addEventListener("click",()=>{o?.keepOpen||this.closeMenu(),y(this.app,i,void 0,()=>e[1](),a),this.app.afterCommand(),o?.keepOpen&&o.checked!==void 0&&s.setAttribute("aria-checked",String(!!(typeof o.checked=="function"?o.checked():o.checked)))})}}if(this.hiddenIds?.size){for(const e of[...t.querySelectorAll(":scope > hr")]){const o=e.previousElementSibling;(!o||o.tagName==="HR")&&e.remove()}for(;t.lastElementChild?.tagName==="HR";)t.lastElementChild.remove()}}pickedHex(t){const n=E(this.app.book,t);return n?.hex??n}applyCellColor(t,n){const e=E(this.app.book,n),o=t==="fill"?{pattern:void 0,gradient:null}:{};o[t]=e?.hex??e,e?.hex&&(o.themeRefs={[t]:e}),this.app.commands.apply(o)}_fillPalette(t,n){const e=l=>{const c=document.createElement("div");c.className="palette-label",c.textContent=u(l),t.append(c)},o=(l,c)=>{this.closeMenu(),n.pick(l,c),this.app.afterCommand()},i=(l,c,x)=>{const d=document.createElement("button");d.style.background=c,d.title=c,d.setAttribute("aria-label",c),d.addEventListener("click",()=>o(c,x)),l.append(d)},a=document.createElement("button");a.textContent=u(n.none),a.addEventListener("click",()=>o(null)),t.append(a),e("Theme Colors");const s=document.createElement("div");s.className="palette";for(const l of B(this.app.book?.theme).refs)i(s,l.hex,l);t.append(s),e("Standard Colors");const m=document.createElement("div");m.className="palette";for(const l of b)i(m,l);if(t.append(m),n.more){const l=document.createElement("button");l.textContent=u(n.more[0]),l.addEventListener("click",()=>{this.closeMenu(),n.more[1]()}),t.append(l)}}closeMenu(){if(this.menuBar?.remove(),this.menuBar=null,this.menu){const t=this.menu.contains(document.activeElement);this.menu.remove(),this.menu=null,this.menuAnchor?.setAttribute("aria-expanded","false"),this.menuAnchor=null;const n=this.menuOpener;this.menuOpener=null,(t||document.activeElement===document.body)&&(!n?.isConnected||n===document.body||n===this.app.el?.("key-sink")?this.app.controller?.focusGrid():n.focus({preventScroll:!0}))}}}class O extends F{constructor(t){super(t),this.active="Home",this.lastFixedTab="Home",this.controls={},this.context=[]}sync(){}render(){}contextChanged(){}selectionKindChanged(){}_renderTabs(){}}export{T as CANCELLED,F as MenuHost,O as NoRibbon,R as controlName,B as paletteColors,y as runControl};
|