@bigpixelrocket/uiok 0.2.1 → 0.2.3
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/CHANGELOG.md +51 -1
- package/dist/button/TextLink.d.ts +27 -0
- package/dist/button/TextLink.js +15 -0
- package/dist/button/button.css +48 -0
- package/dist/button/index.d.ts +2 -1
- package/dist/button/index.js +2 -1
- package/dist/charts/Line.logic.d.ts +15 -1
- package/dist/charts/Line.logic.js +37 -4
- package/dist/charts/LineChart.d.ts +42 -2
- package/dist/charts/LineChart.js +41 -9
- package/dist/charts/Scatter.logic.js +7 -2
- package/dist/charts/charts.css +35 -5
- package/dist/charts/index.d.ts +1 -1
- package/dist/dialog/ConfirmDialog.d.ts +7 -1
- package/dist/dialog/ConfirmDialog.js +9 -4
- package/dist/dialog/DialogLists.d.ts +8 -1
- package/dist/dialog/DialogLists.js +3 -2
- package/dist/field/field.css +110 -2
- package/dist/filter/filter.css +16 -0
- package/dist/grid/DataGrid.d.ts +10 -2
- package/dist/grid/DataGrid.js +47 -13
- package/dist/grid/DataGrid.logic.d.ts +16 -0
- package/dist/grid/DataGrid.logic.js +28 -0
- package/dist/grid/grid.css +128 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/labels/UiokLabels.d.ts +3 -0
- package/dist/labels/UiokLabels.js +3 -1
- package/dist/labels/index.d.ts +1 -0
- package/dist/labels/index.js +1 -0
- package/dist/labels/keys.js +2 -0
- package/dist/labels/paneTabs.d.ts +27 -0
- package/dist/labels/paneTabs.js +10 -0
- package/dist/labels/selectAll.d.ts +4 -1
- package/dist/labels/selectAll.js +1 -1
- package/dist/legend/KeyLegendStrip.d.ts +9 -1
- package/dist/legend/KeyLegendStrip.js +119 -5
- package/dist/legend/legend.css +52 -0
- package/dist/listing/Listing.d.ts +23 -5
- package/dist/listing/Listing.js +11 -8
- package/dist/listing/listing.css +106 -3
- package/dist/pane/PaneActions.d.ts +3 -1
- package/dist/pane/PaneActions.js +6 -5
- package/dist/pane/PaneTabs.d.ts +92 -0
- package/dist/pane/PaneTabs.js +326 -0
- package/dist/pane/PaneTabs.logic.d.ts +97 -0
- package/dist/pane/PaneTabs.logic.js +158 -0
- package/dist/pane/index.d.ts +5 -1
- package/dist/pane/index.js +5 -1
- package/dist/pane/panetabs.css +408 -0
- package/dist/pane/useTabDrag.d.ts +49 -0
- package/dist/pane/useTabDrag.js +306 -0
- package/dist/segmented/SegmentedChoice.d.ts +8 -1
- package/dist/segmented/SegmentedChoice.js +7 -4
- package/dist/styles.css +8 -0
- package/dist/surface/GroupSwatch.d.ts +22 -0
- package/dist/surface/GroupSwatch.js +15 -0
- package/dist/surface/Tag.d.ts +26 -0
- package/dist/surface/Tag.js +12 -0
- package/dist/surface/index.d.ts +7 -0
- package/dist/surface/index.js +7 -0
- package/dist/surface/surface.css +116 -1
- package/dist/themes/tokens.js +13 -1
- package/package.json +1 -1
package/dist/listing/listing.css
CHANGED
|
@@ -1148,7 +1148,7 @@ button.crumb-label > .crumb-text {
|
|
|
1148
1148
|
|
|
1149
1149
|
/* The bar: the state's tone, the width of the old inset bar. A row in no
|
|
1150
1150
|
state draws none. */
|
|
1151
|
-
:where(.listing-root) .row:is(.cursor, .marked)::after {
|
|
1151
|
+
:where(.listing-root) .row:is(.cursor, .marked, .row-changed)::after {
|
|
1152
1152
|
content: '';
|
|
1153
1153
|
width: var(--line-strong);
|
|
1154
1154
|
background: var(--row-bar, transparent);
|
|
@@ -1236,6 +1236,42 @@ button.crumb-label > .crumb-text {
|
|
|
1236
1236
|
background: var(--row-fill);
|
|
1237
1237
|
}
|
|
1238
1238
|
|
|
1239
|
+
/* Rows a save will change, the listing form of the grid's cell states
|
|
1240
|
+
(host classes through Row's className): a changed row (.row-changed)
|
|
1241
|
+
on the warning wash with a warning bar on its leading edge, and a row a
|
|
1242
|
+
save will delete (.row-removed) struck out in --danger on the danger
|
|
1243
|
+
wash, its quiet words in the on-surface tone floored on a state ground.
|
|
1244
|
+
The cursor, a mark, and a selection paint their own fill and bar over
|
|
1245
|
+
either; a removed row keeps its strike. */
|
|
1246
|
+
:where(.listing-root) .row.row-changed:where(:not(.cursor, .marked, .selected)) {
|
|
1247
|
+
--row-fill: var(--warning-wash);
|
|
1248
|
+
--row-bar: var(--warning);
|
|
1249
|
+
|
|
1250
|
+
background: var(--row-fill);
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
:where(.listing-root) .row.row-removed:where(:not(.cursor, .marked, .selected)) {
|
|
1254
|
+
--row-fill: var(--danger-wash);
|
|
1255
|
+
|
|
1256
|
+
background: var(--row-fill);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
:where(.listing-root) .row.row-removed > :is(.row-name, .row-meta) {
|
|
1260
|
+
text-decoration: line-through;
|
|
1261
|
+
text-decoration-color: var(--danger);
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
:where(.listing-root) .row:is(.row-changed, .row-removed):where(:not(.selected)) > .row-meta {
|
|
1265
|
+
color: var(--text-on-surface);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/* A row something is dragged over that will take the drop (.drop-target):
|
|
1269
|
+
an accent outline inside its edges, over whatever state it is in. */
|
|
1270
|
+
:where(.listing-root) .row.drop-target,
|
|
1271
|
+
:where(.listing-root) .row.drop-target:is(.cursor, .marked, .selected) {
|
|
1272
|
+
box-shadow: inset 0 0 0 var(--line-strong) var(--accent);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1239
1275
|
/* A focusable row (`Row` `focusable`) rings inside its edges: the list
|
|
1240
1276
|
around it scrolls, and would clip a ring drawn outside. */
|
|
1241
1277
|
:where(.listing-root) .row:focus-visible {
|
|
@@ -1315,6 +1351,13 @@ button.crumb-label > .crumb-text {
|
|
|
1315
1351
|
white-space: nowrap;
|
|
1316
1352
|
}
|
|
1317
1353
|
|
|
1354
|
+
/* A row in a tree or a plan (Row's level, as --row-level) indents its
|
|
1355
|
+
name one icon column a level, so a child's name starts under its
|
|
1356
|
+
parent's. At zero weight, so a host's own rule on the name wins. */
|
|
1357
|
+
:where(.listing-root .row > .row-name) {
|
|
1358
|
+
padding-inline-start: calc(var(--row-level, 0) * var(--icon-column));
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1318
1361
|
/* A listing selects rows, not text, as a file manager does: a drag, a
|
|
1319
1362
|
Shift-click, or a double-click on a row never starts a text selection,
|
|
1320
1363
|
in its name and values included, and a row copies through the host's
|
|
@@ -1358,6 +1401,13 @@ button.crumb-label > .crumb-text {
|
|
|
1358
1401
|
text-align: right;
|
|
1359
1402
|
}
|
|
1360
1403
|
|
|
1404
|
+
/* A missing value (SQL NULL) in a cell: italic in the row-meta tone, as
|
|
1405
|
+
the grid's cell-null; a state row's quiet-word rule takes it to the
|
|
1406
|
+
on-surface tone. */
|
|
1407
|
+
:where(.listing-root) .row-meta.value-null {
|
|
1408
|
+
font-style: italic;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1361
1411
|
/* The status line closes the pane: a summary of what the pane lists. Its
|
|
1362
1412
|
words start, and its last control's glyph ends, on the row inset, the
|
|
1363
1413
|
edges the path bar and the rows keep. */
|
|
@@ -1384,6 +1434,19 @@ button.crumb-label > .crumb-text {
|
|
|
1384
1434
|
white-space: nowrap;
|
|
1385
1435
|
}
|
|
1386
1436
|
|
|
1437
|
+
/* A notice as the status line's message keeps to its one line: centred on
|
|
1438
|
+
the bar, its words cut with an ellipsis rather than wrapped (give its
|
|
1439
|
+
notice-text cutTooltip with the whole text). */
|
|
1440
|
+
:where(.listing-root) .pane-summary > .notice {
|
|
1441
|
+
align-items: center;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
:where(.listing-root) .pane-summary > .notice .notice-text {
|
|
1445
|
+
overflow: hidden;
|
|
1446
|
+
text-overflow: ellipsis;
|
|
1447
|
+
white-space: nowrap;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1387
1450
|
/* Compact controls at the status line's end (PaneStatus's tools: Reveal,
|
|
1388
1451
|
Copy); the summary before them gives way to them. */
|
|
1389
1452
|
:where(.listing-root) .pane-status-tools {
|
|
@@ -1584,6 +1647,28 @@ button.crumb-label > .crumb-text {
|
|
|
1584
1647
|
color: var(--text);
|
|
1585
1648
|
}
|
|
1586
1649
|
|
|
1650
|
+
/* A warning (.warning): the warning tone's TriangleAlert, drawn as a mask
|
|
1651
|
+
in --warning as the danger line's glyph is, then the words in --text. A
|
|
1652
|
+
host that draws its own glyph first (an svg) gets no second one. */
|
|
1653
|
+
:where(.listing-root) .pane-message.warning {
|
|
1654
|
+
color: var(--text);
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
:where(.listing-root) .pane-message.warning:not(:has(> svg:first-child))::before {
|
|
1658
|
+
content: '';
|
|
1659
|
+
flex: none;
|
|
1660
|
+
width: var(--icon-md);
|
|
1661
|
+
height: var(--icon-md);
|
|
1662
|
+
background: var(--warning);
|
|
1663
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3'/%3E%3Cpath d='M12 9v4'/%3E%3Cpath d='M12 17h.01'/%3E%3C/svg%3E")
|
|
1664
|
+
center / contain no-repeat;
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
:where(.listing-root) .pane-message.warning > svg:first-child {
|
|
1668
|
+
flex: none;
|
|
1669
|
+
color: var(--warning);
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1587
1672
|
/* A line that says a listing has no rows (`.empty`, Listing's `empty`)
|
|
1588
1673
|
reads as a quiet row in the rows' place: it starts where a row's icon
|
|
1589
1674
|
starts, in the rows' own typeface and size (the host's, as the rows'
|
|
@@ -1630,6 +1715,12 @@ button.crumb-label > .crumb-text {
|
|
|
1630
1715
|
color: var(--text-faint);
|
|
1631
1716
|
}
|
|
1632
1717
|
|
|
1718
|
+
/* A pane that could not load (role="alert") leads with its glyph in the
|
|
1719
|
+
danger tone, as every failure's glyph is. */
|
|
1720
|
+
:where(.listing-root) .pane-empty[role='alert'] > svg {
|
|
1721
|
+
color: var(--danger);
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1633
1724
|
:where(.listing-root) .pane-empty :is(strong, h2) {
|
|
1634
1725
|
margin: 0;
|
|
1635
1726
|
color: var(--text);
|
|
@@ -1744,6 +1835,14 @@ button.crumb-label > .crumb-text {
|
|
|
1744
1835
|
box-shadow: inset 0 0 0 var(--line-strong) var(--accent);
|
|
1745
1836
|
}
|
|
1746
1837
|
|
|
1838
|
+
/* A note (info): an upright accent bar, the stem of an "i", as tall as the
|
|
1839
|
+
dot, so it reads apart from the busy ring in the same hue. */
|
|
1840
|
+
:where(.listing-root) .pane-tone-info > .pane-state-dot {
|
|
1841
|
+
width: var(--line-strong);
|
|
1842
|
+
background: var(--accent);
|
|
1843
|
+
box-shadow: none;
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1747
1846
|
/* The busy spinner is the shared Spinner (it turns and stands still under
|
|
1748
1847
|
reduced motion on its own); the state only colours it. */
|
|
1749
1848
|
:where(.listing-root) .pane-state > svg.pane-state-busy {
|
|
@@ -1781,7 +1880,7 @@ button.crumb-label > .crumb-text {
|
|
|
1781
1880
|
on the accent tint whatever its hue. */
|
|
1782
1881
|
:where(.listing-root)
|
|
1783
1882
|
.row.marked:where(:not(.selected))
|
|
1784
|
-
:is(.pane-tone-ready, .pane-tone-warning, .pane-tone-danger)
|
|
1883
|
+
:is(.pane-tone-ready, .pane-tone-warning, .pane-tone-danger, .pane-tone-info)
|
|
1785
1884
|
> .pane-state-dot {
|
|
1786
1885
|
box-shadow: 0 0 0 var(--line) var(--text-on-surface);
|
|
1787
1886
|
}
|
|
@@ -1798,6 +1897,10 @@ button.crumb-label > .crumb-text {
|
|
|
1798
1897
|
color: var(--warning-text);
|
|
1799
1898
|
}
|
|
1800
1899
|
|
|
1900
|
+
:where(.listing-root) .row .pane-state.pane-tone-info {
|
|
1901
|
+
color: var(--accent-text);
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1801
1904
|
:where(.listing-root) .row .pane-state:is(.pane-tone-muted, .pane-tone-busy) {
|
|
1802
1905
|
color: var(--row-meta-text);
|
|
1803
1906
|
}
|
|
@@ -2207,7 +2310,7 @@ button.crumb-label > .crumb-text {
|
|
|
2207
2310
|
.listing-root:has(.pane.active) .pane:not(.active, .active .pane) *
|
|
2208
2311
|
)
|
|
2209
2312
|
)
|
|
2210
|
-
:is(.pane-tone-ready, .pane-tone-warning, .pane-tone-danger)
|
|
2313
|
+
:is(.pane-tone-ready, .pane-tone-warning, .pane-tone-danger, .pane-tone-info)
|
|
2211
2314
|
> .pane-state-dot {
|
|
2212
2315
|
box-shadow: 0 0 0 var(--line) var(--on-selected);
|
|
2213
2316
|
}
|
|
@@ -134,6 +134,8 @@ export interface RowIconActionProps {
|
|
|
134
134
|
readonly word?: string;
|
|
135
135
|
/** A destructive action, drawn as on `QuietAction`. */
|
|
136
136
|
readonly danger?: boolean;
|
|
137
|
+
/** The chord that runs it, as text ("⌘⌫"), written after the words in its tooltip as on `QuietAction`. */
|
|
138
|
+
readonly shortcut?: string;
|
|
137
139
|
}
|
|
138
140
|
/**
|
|
139
141
|
* A compact icon control: in a row, one that shows on its row's hover, its
|
|
@@ -143,4 +145,4 @@ export interface RowIconActionProps {
|
|
|
143
145
|
* in the listing look. Under `RowLinkLookContext` an action that names its
|
|
144
146
|
* verb (`word`, a row link) draws it in place of the icon or beside it.
|
|
145
147
|
*/
|
|
146
|
-
export declare function RowIconAction({ icon: Icon, label, disabled, onClick, ref, softDisabled, tip, verb, word, danger }: RowIconActionProps): ReactElement;
|
|
148
|
+
export declare function RowIconAction({ icon: Icon, label, disabled, onClick, ref, softDisabled, tip, verb, word, danger, shortcut }: RowIconActionProps): ReactElement;
|
package/dist/pane/PaneActions.js
CHANGED
|
@@ -91,7 +91,7 @@ export function QuietAction({ icon: Icon, word, label, lit = false, disabled = f
|
|
|
91
91
|
* in the listing look. Under `RowLinkLookContext` an action that names its
|
|
92
92
|
* verb (`word`, a row link) draws it in place of the icon or beside it.
|
|
93
93
|
*/
|
|
94
|
-
export function RowIconAction({ icon: Icon, label, disabled = false, onClick, ref, softDisabled = false, tip = label, verb, word, danger = false }) {
|
|
94
|
+
export function RowIconAction({ icon: Icon, label, disabled = false, onClick, ref, softDisabled = false, tip = label, verb, word, danger = false, shortcut }) {
|
|
95
95
|
const inRow = useInRow();
|
|
96
96
|
const chosen = useContext(RowLinkLookContext);
|
|
97
97
|
// Only an action that names its verb draws it in words.
|
|
@@ -102,9 +102,10 @@ export function RowIconAction({ icon: Icon, label, disabled = false, onClick, re
|
|
|
102
102
|
event.stopPropagation();
|
|
103
103
|
if (!softDisabled)
|
|
104
104
|
onClick();
|
|
105
|
-
}, ref: ref, tabIndex: inRow ? -1 : undefined, type: "button", ...(look !== 'icons' && tip === word
|
|
105
|
+
}, ref: ref, tabIndex: inRow ? -1 : undefined, type: "button", ...(look !== 'icons' && tip === word && shortcut === undefined
|
|
106
106
|
? {}
|
|
107
|
-
:
|
|
108
|
-
? tooltip(label)
|
|
109
|
-
|
|
107
|
+
: {
|
|
108
|
+
...(tip === label ? tooltip(label) : describedTooltip(tip)),
|
|
109
|
+
...(shortcut === undefined ? {} : { 'data-tooltip-shortcut': shortcut })
|
|
110
|
+
}), children: [look !== 'text' && _jsx(Icon, { "aria-hidden": true, size: ICON_SM }), look !== 'icons' && _jsx("span", { children: word })] }));
|
|
110
111
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type MouseEvent, type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import type { Chord } from '../keyboard/Keyboard.logic.js';
|
|
3
|
+
/** One tab of a pane's strip. */
|
|
4
|
+
export interface PaneTabItem {
|
|
5
|
+
/** Names the tab to every callback; also its `data-pane-tab` attribute. */
|
|
6
|
+
readonly id: string;
|
|
7
|
+
/** What the tab shows. */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/**
|
|
10
|
+
* Dim words before the name and a slash, to tell two tabs of one name
|
|
11
|
+
* apart (`shop` / `orders`). They give way to an ellipsis before the
|
|
12
|
+
* name loses a character.
|
|
13
|
+
*/
|
|
14
|
+
readonly context?: string;
|
|
15
|
+
/** A node ahead of the name: a group's swatch or a lucide icon at `ICON_SM`. Decorative. */
|
|
16
|
+
readonly mark?: ReactNode;
|
|
17
|
+
/** The tooltip, at every width: the tab's whole path. Also its accessible description. */
|
|
18
|
+
readonly tip?: string;
|
|
19
|
+
/** The next place opened takes this tab over: its name is set in italic. */
|
|
20
|
+
readonly following?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The tab holds changes not saved: the warning mark stands where its close
|
|
23
|
+
* control is, and the control comes back under the pointer.
|
|
24
|
+
*/
|
|
25
|
+
readonly dirty?: boolean;
|
|
26
|
+
/** Stands before the pin rule, keeps its width, and carries a pin in place of a close control. */
|
|
27
|
+
readonly pinned?: boolean;
|
|
28
|
+
/** `'danger'` outlines the tab in the danger colour at every width (a place that needs care). */
|
|
29
|
+
readonly tone?: 'danger';
|
|
30
|
+
/** False draws no close control, and a middle click closes nothing. True by default. */
|
|
31
|
+
readonly closable?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Props for {@link PaneTabs}. */
|
|
34
|
+
export interface PaneTabsProps {
|
|
35
|
+
/** The tablist's accessible name. */
|
|
36
|
+
readonly label: string;
|
|
37
|
+
/** The tabs in strip order; pinned tabs must come first. */
|
|
38
|
+
readonly tabs: readonly PaneTabItem[];
|
|
39
|
+
/** The id of the tab in front: exactly one, among `tabs`. */
|
|
40
|
+
readonly front: string;
|
|
41
|
+
/**
|
|
42
|
+
* The ids picked beside the tab in front, which the host keeps
|
|
43
|
+
* (`togglePick`, `pickRun`, `pickedTabs`). A picked tab wears the marked
|
|
44
|
+
* look and a drag of it carries every pick.
|
|
45
|
+
*/
|
|
46
|
+
readonly picked?: readonly string[];
|
|
47
|
+
/** A press on a tab, or a choice in the folded tabs' menu: bring that tab to the front. */
|
|
48
|
+
readonly onSelect: (id: string) => void;
|
|
49
|
+
/** A tab's close control, or a middle click on a tab that has one. */
|
|
50
|
+
readonly onClose: (id: string) => void;
|
|
51
|
+
/** ⌘-click picks or drops a tab (`'toggle'`); ⇧-click picks the run from the front tab (`'run'`). */
|
|
52
|
+
readonly onPick?: (id: string, how: 'toggle' | 'run') => void;
|
|
53
|
+
/** A double-click on a tab: keeps a following tab. */
|
|
54
|
+
readonly onKeep?: (id: string) => void;
|
|
55
|
+
/** After a drag drops, the full order, folded tabs included. Omit to turn dragging off. */
|
|
56
|
+
readonly onReorder?: (order: readonly string[]) => void;
|
|
57
|
+
/** The New Tab button, and a double-click on the strip's empty end. Omit to draw no button. */
|
|
58
|
+
readonly onNew?: () => void;
|
|
59
|
+
/** The chord New Tab's tooltip shows; ⌘T by default. */
|
|
60
|
+
readonly newChord?: Chord;
|
|
61
|
+
/** A secondary click on a tab; the host decides whether to prevent the browser's menu. */
|
|
62
|
+
readonly onTabContextMenu?: (id: string, event: MouseEvent) => void;
|
|
63
|
+
/** Drawn after the folded tabs' count, at the strip's end (an update pill). */
|
|
64
|
+
readonly trailing?: ReactNode;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The tabs a pane hangs from: the first child of a `.pane` under
|
|
68
|
+
* `.listing-root`, whose frame hangs from the tab in front. A tab wears its
|
|
69
|
+
* place's name, with dim context before it when two tabs share a name; the
|
|
70
|
+
* one in front joins the frame, the others stand behind it, shorter and
|
|
71
|
+
* fainter. A following tab's name is italic, a dirty tab carries the
|
|
72
|
+
* warning mark in its close control's place, a pinned tab stands before the
|
|
73
|
+
* pin rule with a pin, and a danger-toned tab keeps its danger outline.
|
|
74
|
+
*
|
|
75
|
+
* The strip never wraps or scrolls. Tabs behind the front one shrink
|
|
76
|
+
* together to a floor (eight characters of the name, three of the
|
|
77
|
+
* context), then fold into a count after New Tab, farthest from the front
|
|
78
|
+
* tab first; pinned, front, and following tabs never fold, and pinned and
|
|
79
|
+
* front never shrink. The count's menu names the folded tabs.
|
|
80
|
+
*
|
|
81
|
+
* A press brings a tab to the front at once and, with `onReorder`, may
|
|
82
|
+
* start a drag (past a 4px slop): the held tab follows the pointer, its
|
|
83
|
+
* neighbours step aside at half cover, it stays its side of the pin rule,
|
|
84
|
+
* picked tabs ride with it, Escape puts every tab back, and release hands
|
|
85
|
+
* the full order to `onReorder`. ⌘-click and ⇧-click pick (`onPick`), a
|
|
86
|
+
* middle click closes, a double-click keeps (`onKeep`), and a double-click
|
|
87
|
+
* on the strip's empty end opens a new tab (`onNew`).
|
|
88
|
+
*
|
|
89
|
+
* Tabs take no focus: the host's verbs are the keyboard's way in. Words
|
|
90
|
+
* come from `useLabels().paneTabs`.
|
|
91
|
+
*/
|
|
92
|
+
export declare function PaneTabs({ label, tabs, front, picked, onSelect, onClose, onPick, onKeep, onReorder, onNew, newChord, onTabContextMenu, trailing }: PaneTabsProps): ReactElement;
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDown, Pin, Plus, X } from 'lucide-react';
|
|
3
|
+
import { Fragment, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
5
|
+
import { ICON_MD, ICON_SM } from '../icon/index.js';
|
|
6
|
+
import { useLabels } from '../labels/UiokProvider.js';
|
|
7
|
+
import { StateMark } from '../listing/Listing.js';
|
|
8
|
+
import { movedPickableCursor, pickableCursor } from '../menu/MenuQuery.logic.js';
|
|
9
|
+
import { describedTooltip, tooltip } from '../tooltip/Tooltip.logic.js';
|
|
10
|
+
import { foldOrder, foldsNeeded, tabLabelFloor } from './PaneTabs.logic.js';
|
|
11
|
+
import { useTabDrag } from './useTabDrag.js';
|
|
12
|
+
/** New Tab's chord when the host names none. */
|
|
13
|
+
const NEW_TAB_CHORD = { key: 't', meta: true };
|
|
14
|
+
/** No picks. */
|
|
15
|
+
const NO_PICKS = [];
|
|
16
|
+
/** Keeps the focus where it was on a press, so a press on the strip leaves the keys where they were. */
|
|
17
|
+
const keepFocus = (event) => event.preventDefault();
|
|
18
|
+
/** The words a tab is called by: its context and name, as the strip shows them. */
|
|
19
|
+
const spokenTab = (tab) => tab.context === undefined ? tab.name : `${tab.context}/${tab.name}`;
|
|
20
|
+
/** Whether the tab draws a close control. */
|
|
21
|
+
const closes = (tab) => tab.pinned !== true && tab.closable !== false;
|
|
22
|
+
/** A tab's label: the context giving way to its floor before the name gives a character. */
|
|
23
|
+
function TabLabel({ tab }) {
|
|
24
|
+
const floor = tabLabelFloor(tab);
|
|
25
|
+
return (_jsxs("span", { className: "pane-tab-label", children: [tab.context === undefined ? null : (_jsxs(_Fragment, { children: [_jsx("span", { className: "pane-tab-context", style: { minWidth: `${floor.context}ch` }, children: tab.context }), _jsx("span", { className: "pane-tab-context pane-tab-slash", children: "/" })] })), _jsx("span", { className: "pane-tab-name", children: tab.name })] }));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The folded tabs' count at the strip's end: "+N" and a chevron, the
|
|
29
|
+
* warning mark before it while a folded tab is dirty. It opens the menu of
|
|
30
|
+
* the folded tabs, in strip order; the menu holds the keys (↑ ↓, Return,
|
|
31
|
+
* Escape) and hands the focus back to where it was when it opened.
|
|
32
|
+
*/
|
|
33
|
+
function FoldedTabs({ folded, labels, onSelect }) {
|
|
34
|
+
const buttonRef = useRef(null);
|
|
35
|
+
const menuRef = useRef(null);
|
|
36
|
+
const returnRef = useRef(null);
|
|
37
|
+
const menuId = useId();
|
|
38
|
+
const [host, setHost] = useState(null);
|
|
39
|
+
const [pointed, setPointed] = useState(null);
|
|
40
|
+
const dirty = folded.filter((tab) => tab.dirty === true).length;
|
|
41
|
+
const words = labels.folded(folded.length, dirty);
|
|
42
|
+
const rows = folded.map((tab) => ({ key: tab.id, taken: false }));
|
|
43
|
+
const cursor = host === null ? null : pickableCursor(rows, pointed);
|
|
44
|
+
const close = (by) => {
|
|
45
|
+
setHost(null);
|
|
46
|
+
setPointed(null);
|
|
47
|
+
const back = returnRef.current;
|
|
48
|
+
returnRef.current = null;
|
|
49
|
+
if (by === 'keyboard' && back instanceof HTMLElement && back.isConnected) {
|
|
50
|
+
back.focus({ preventScroll: true });
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const closeRef = useRef(close);
|
|
54
|
+
useLayoutEffect(() => {
|
|
55
|
+
closeRef.current = close;
|
|
56
|
+
});
|
|
57
|
+
// Placed under the count, its trailing edge on the count's, and given the
|
|
58
|
+
// keys; over the count instead when the window has no room for it below
|
|
59
|
+
// and has room above, so no row the keys reach falls out of the window.
|
|
60
|
+
useLayoutEffect(() => {
|
|
61
|
+
const menu = menuRef.current;
|
|
62
|
+
const button = buttonRef.current;
|
|
63
|
+
if (host === null || menu === null || button === null) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const box = button.getBoundingClientRect();
|
|
67
|
+
const gap = parseFloat(getComputedStyle(menu).getPropertyValue('--space-2')) || 0;
|
|
68
|
+
const width = menu.offsetWidth;
|
|
69
|
+
const height = menu.offsetHeight;
|
|
70
|
+
const above = box.top - gap - height;
|
|
71
|
+
const below = box.bottom + gap;
|
|
72
|
+
menu.style.top = `${below + height > window.innerHeight - gap && above >= gap ? above : below}px`;
|
|
73
|
+
menu.style.left = `${Math.max(gap, Math.min(box.right - width, window.innerWidth - width - gap))}px`;
|
|
74
|
+
menu.focus({ preventScroll: true });
|
|
75
|
+
}, [host]);
|
|
76
|
+
// The row the keys move to scrolls into the list's view, so Return never
|
|
77
|
+
// chooses a row out of sight. Optional call: jsdom has no scrollIntoView.
|
|
78
|
+
useLayoutEffect(() => {
|
|
79
|
+
if (host === null || cursor === null) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
menuRef.current
|
|
83
|
+
?.querySelector('.pane-tabs-folded-option.cursor')
|
|
84
|
+
?.scrollIntoView?.({ block: 'nearest' });
|
|
85
|
+
}, [host, cursor]);
|
|
86
|
+
// A press outside closes it; the press goes on to whatever it landed on.
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (host === null) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const listener = (event) => {
|
|
92
|
+
if (!(event.target instanceof Node) ||
|
|
93
|
+
!(menuRef.current?.contains(event.target) || buttonRef.current?.contains(event.target))) {
|
|
94
|
+
closeRef.current('pointer');
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
// A window that changes size moves the count out from under the menu:
|
|
98
|
+
// the menu closes, and the keys go back to where they were.
|
|
99
|
+
const resized = () => closeRef.current('keyboard');
|
|
100
|
+
document.addEventListener('mousedown', listener, true);
|
|
101
|
+
window.addEventListener('resize', resized);
|
|
102
|
+
return () => {
|
|
103
|
+
document.removeEventListener('mousedown', listener, true);
|
|
104
|
+
window.removeEventListener('resize', resized);
|
|
105
|
+
};
|
|
106
|
+
}, [host]);
|
|
107
|
+
const choose = (tab) => {
|
|
108
|
+
if (tab !== undefined) {
|
|
109
|
+
close('keyboard');
|
|
110
|
+
onSelect(tab.id);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { "aria-expanded": host !== null, "aria-haspopup": "menu", "aria-label": labels.foldedHeading, className: "pane-tabs-folded hit-target quiet-control", onClick: () => {
|
|
114
|
+
if (host !== null) {
|
|
115
|
+
close('pointer');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
returnRef.current = document.activeElement;
|
|
119
|
+
setHost(buttonRef.current?.closest('.listing-root') ?? document.body);
|
|
120
|
+
}, onMouseDown: keepFocus, ref: buttonRef, type: "button", ...describedTooltip(words), children: [dirty > 0 ? (_jsx("span", { "aria-hidden": true, className: "pane-tab-dirty", children: _jsx(StateMark, { tone: "warning", word: "" }) })) : null, _jsx("span", { className: "pane-tabs-folded-count", children: `+${folded.length.toLocaleString('en-US')}` }), _jsx(ChevronDown, { "aria-hidden": true, size: ICON_SM })] }), host === null
|
|
121
|
+
? null
|
|
122
|
+
: createPortal(_jsxs("div", { "aria-activedescendant": cursor === null ? undefined : `${menuId}-${cursor}`, "aria-label": labels.foldedHeading, className: "folder-menu folder-menu-compact pane-tabs-folded-menu", "data-native-keyboard": true, "data-overlay": true, onBlur: (event) => {
|
|
123
|
+
if (!(event.relatedTarget instanceof Node &&
|
|
124
|
+
event.currentTarget.contains(event.relatedTarget))) {
|
|
125
|
+
close('pointer');
|
|
126
|
+
}
|
|
127
|
+
}, onKeyDown: (event) => {
|
|
128
|
+
if (event.metaKey || event.ctrlKey || event.altKey) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
132
|
+
const next = movedPickableCursor(rows, cursor, event.key === 'ArrowDown' ? 1 : -1);
|
|
133
|
+
setPointed(next === null ? null : (folded[next]?.id ?? null));
|
|
134
|
+
}
|
|
135
|
+
else if (event.key === 'Enter' || event.key === ' ') {
|
|
136
|
+
choose(cursor === null ? undefined : folded[cursor]);
|
|
137
|
+
}
|
|
138
|
+
else if (event.key === 'Escape') {
|
|
139
|
+
close('keyboard');
|
|
140
|
+
}
|
|
141
|
+
else if (event.key === 'Tab') {
|
|
142
|
+
close('pointer');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
event.stopPropagation();
|
|
150
|
+
},
|
|
151
|
+
// A press on a row must not take the focus from the menu, which holds the keys.
|
|
152
|
+
onMouseDown: keepFocus, ref: menuRef, role: "menu", tabIndex: -1, children: [_jsx("div", { "aria-hidden": true, className: "entry-menu-heading overline", children: labels.foldedHeading }), _jsx("div", { className: "folder-menu-options", role: "none", children: folded.map((tab, index) => (_jsxs("div", { "aria-description": [tab.tip, tab.dirty === true ? labels.notSaved : undefined]
|
|
153
|
+
.filter((part) => part !== undefined && part !== '')
|
|
154
|
+
.join(', ') || undefined, "aria-label": spokenTab(tab), className: index === cursor
|
|
155
|
+
? 'folder-menu-option pane-tabs-folded-option cursor'
|
|
156
|
+
: 'folder-menu-option pane-tabs-folded-option', "data-tone": tab.tone, id: `${menuId}-${index}`, onClick: () => choose(tab), onMouseMove: () => setPointed(tab.id), role: "menuitem", ...tooltip(tab.tip, null, { value: true }), children: [_jsx("span", { "aria-hidden": true, className: "pane-tabs-folded-mark", children: tab.mark }), _jsxs("span", { className: "pane-tabs-folded-label", children: [tab.context === undefined ? null : (_jsxs(_Fragment, { children: [_jsx("span", { className: "pane-tab-context", children: tab.context }), _jsx("span", { className: "pane-tab-context pane-tab-slash", children: "/" })] })), _jsx("span", { className: "pane-tab-name", children: tab.name })] }), _jsxs("span", { "aria-hidden": true, className: "pane-tabs-folded-marks", children: [tab.dirty === true ? _jsx(StateMark, { tone: "warning", word: "" }) : null, tab.tone === 'danger' ? _jsx(StateMark, { tone: "danger", word: "" }) : null] })] }, tab.id))) })] }), host)] }));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The tabs a pane hangs from: the first child of a `.pane` under
|
|
160
|
+
* `.listing-root`, whose frame hangs from the tab in front. A tab wears its
|
|
161
|
+
* place's name, with dim context before it when two tabs share a name; the
|
|
162
|
+
* one in front joins the frame, the others stand behind it, shorter and
|
|
163
|
+
* fainter. A following tab's name is italic, a dirty tab carries the
|
|
164
|
+
* warning mark in its close control's place, a pinned tab stands before the
|
|
165
|
+
* pin rule with a pin, and a danger-toned tab keeps its danger outline.
|
|
166
|
+
*
|
|
167
|
+
* The strip never wraps or scrolls. Tabs behind the front one shrink
|
|
168
|
+
* together to a floor (eight characters of the name, three of the
|
|
169
|
+
* context), then fold into a count after New Tab, farthest from the front
|
|
170
|
+
* tab first; pinned, front, and following tabs never fold, and pinned and
|
|
171
|
+
* front never shrink. The count's menu names the folded tabs.
|
|
172
|
+
*
|
|
173
|
+
* A press brings a tab to the front at once and, with `onReorder`, may
|
|
174
|
+
* start a drag (past a 4px slop): the held tab follows the pointer, its
|
|
175
|
+
* neighbours step aside at half cover, it stays its side of the pin rule,
|
|
176
|
+
* picked tabs ride with it, Escape puts every tab back, and release hands
|
|
177
|
+
* the full order to `onReorder`. ⌘-click and ⇧-click pick (`onPick`), a
|
|
178
|
+
* middle click closes, a double-click keeps (`onKeep`), and a double-click
|
|
179
|
+
* on the strip's empty end opens a new tab (`onNew`).
|
|
180
|
+
*
|
|
181
|
+
* Tabs take no focus: the host's verbs are the keyboard's way in. Words
|
|
182
|
+
* come from `useLabels().paneTabs`.
|
|
183
|
+
*/
|
|
184
|
+
export function PaneTabs({ label, tabs, front, picked = NO_PICKS, onSelect, onClose, onPick, onKeep, onReorder, onNew, newChord = NEW_TAB_CHORD, onTabContextMenu, trailing }) {
|
|
185
|
+
const labels = useLabels().paneTabs;
|
|
186
|
+
const headerRef = useRef(null);
|
|
187
|
+
const stripRef = useRef(null);
|
|
188
|
+
const trailingRef = useRef(null);
|
|
189
|
+
const [room, setRoom] = useState('');
|
|
190
|
+
const drag = useTabDrag();
|
|
191
|
+
const liveOrder = drag.liveOrder;
|
|
192
|
+
const hasTrailing = trailing !== undefined;
|
|
193
|
+
const byId = new Map(tabs.map((tab) => [tab.id, tab]));
|
|
194
|
+
const order = tabs.map((tab) => tab.id);
|
|
195
|
+
// While a drag runs the strip draws the hand's order; the host's comes back on release.
|
|
196
|
+
const drawn = liveOrder !== null && liveOrder.length === order.length && liveOrder.every((id) => byId.has(id))
|
|
197
|
+
? liveOrder
|
|
198
|
+
: order;
|
|
199
|
+
// Whatever changes the strip's natural width starts the folding over.
|
|
200
|
+
const shape = `${room}|${front}|${onNew === undefined ? '' : 'new'}|${tabs
|
|
201
|
+
.map((tab) => `${tab.id}:${tab.pinned === true ? 'p' : ''}${tab.following === true ? 'f' : ''}${tab.mark === undefined ? '' : 'm'}${closes(tab) ? 'x' : ''}${tab.dirty === true ? 'd' : ''}:${tab.context ?? ''}/${tab.name}`)
|
|
202
|
+
.join('|')}`;
|
|
203
|
+
const [folding, setFolding] = useState({ shape, count: 0 });
|
|
204
|
+
const count = folding.shape === shape ? folding.count : 0;
|
|
205
|
+
if (folding.shape !== shape) {
|
|
206
|
+
setFolding({ shape, count: 0 });
|
|
207
|
+
}
|
|
208
|
+
const folds = foldOrder(tabs, front);
|
|
209
|
+
const folded = new Set(folds.slice(0, count));
|
|
210
|
+
const foldRank = new Map(folds.map((id, rank) => [id, rank]));
|
|
211
|
+
const foldedTabs = tabs.filter((tab) => folded.has(tab.id));
|
|
212
|
+
const pinnedIds = new Set(tabs.filter((tab) => tab.pinned === true).map((tab) => tab.id));
|
|
213
|
+
const shown = drawn.filter((id) => !folded.has(id));
|
|
214
|
+
const lastPinned = shown.reduce((last, id, index) => (pinnedIds.has(id) ? index : last), -1);
|
|
215
|
+
const carried = drawn.filter((id) => id === front || picked.includes(id));
|
|
216
|
+
const hasPicks = carried.length > 1;
|
|
217
|
+
// While the tabs on show, each at its floor, run past the strip's room,
|
|
218
|
+
// fold as many as cover the overrun in one step; the count taking its own
|
|
219
|
+
// room costs a pass or two more. Box widths, not offsets: each offset
|
|
220
|
+
// rounds on its own, and a tab in the hand is drawn away from its place.
|
|
221
|
+
useLayoutEffect(() => {
|
|
222
|
+
const strip = stripRef.current;
|
|
223
|
+
if (!strip || count >= folds.length) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const boxes = [...strip.children].map((element) => ({
|
|
227
|
+
rank: element instanceof HTMLElement ? element.dataset.foldRank : undefined,
|
|
228
|
+
width: element.getBoundingClientRect().width
|
|
229
|
+
}));
|
|
230
|
+
const gap = parseFloat(getComputedStyle(strip).columnGap) || 0;
|
|
231
|
+
const run = boxes.reduce((sum, box) => sum + box.width, 0) + gap * Math.max(0, boxes.length - 1);
|
|
232
|
+
const deficit = run - strip.getBoundingClientRect().width;
|
|
233
|
+
if (deficit <= 0.5) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const widths = boxes
|
|
237
|
+
.flatMap((box) => box.rank === undefined ? [] : [{ rank: Number(box.rank), width: box.width }])
|
|
238
|
+
.sort((a, b) => a.rank - b.rank)
|
|
239
|
+
.map((box) => box.width);
|
|
240
|
+
setFolding({ shape, count: count + foldsNeeded(deficit, widths, gap) });
|
|
241
|
+
}, [count, folds.length, shape]);
|
|
242
|
+
// The header's width and the trailing slot's, which the folding starts over on.
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
const header = headerRef.current;
|
|
245
|
+
// Optional: jsdom has no ResizeObserver.
|
|
246
|
+
if (!header || typeof ResizeObserver === 'undefined') {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const observer = new ResizeObserver(() => setRoom(`${header.clientWidth}:${trailingRef.current?.offsetWidth ?? 0}`));
|
|
250
|
+
observer.observe(header);
|
|
251
|
+
if (trailingRef.current) {
|
|
252
|
+
observer.observe(trailingRef.current);
|
|
253
|
+
}
|
|
254
|
+
return () => observer.disconnect();
|
|
255
|
+
}, [hasTrailing]);
|
|
256
|
+
// After every layout, since any of them may have moved a tab.
|
|
257
|
+
useLayoutEffect(() => {
|
|
258
|
+
drag.afterLayout({
|
|
259
|
+
order: drawn,
|
|
260
|
+
pinned: pinnedIds,
|
|
261
|
+
strip: stripRef.current,
|
|
262
|
+
commit: (next) => onReorder?.(next)
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
const tabElement = (tab) => {
|
|
266
|
+
const isFront = tab.id === front;
|
|
267
|
+
const isPicked = hasPicks && !isFront && picked.includes(tab.id);
|
|
268
|
+
const spoken = spokenTab(tab);
|
|
269
|
+
const floor = tabLabelFloor(tab);
|
|
270
|
+
const description = [
|
|
271
|
+
tab.tip,
|
|
272
|
+
tab.pinned === true ? labels.pinned : undefined,
|
|
273
|
+
tab.dirty === true ? labels.notSaved : undefined
|
|
274
|
+
]
|
|
275
|
+
.filter((part) => part !== undefined && part !== '')
|
|
276
|
+
.join(', ');
|
|
277
|
+
return (_jsxs("div", { ...tooltip(tab.tip, null, { value: true }), "aria-description": description === '' ? undefined : description, "aria-label": isPicked ? labels.picked(spoken) : spoken, "aria-selected": isFront, className: [
|
|
278
|
+
'pane-tab',
|
|
279
|
+
isFront ? 'active' : '',
|
|
280
|
+
tab.following === true ? 'following' : '',
|
|
281
|
+
tab.dirty === true ? 'dirty' : '',
|
|
282
|
+
tab.pinned === true ? 'pinned' : '',
|
|
283
|
+
isPicked ? 'picked' : '',
|
|
284
|
+
drag.draggingIds.includes(tab.id) ? 'dragging' : ''
|
|
285
|
+
]
|
|
286
|
+
.filter(Boolean)
|
|
287
|
+
.join(' '), "data-fold-rank": foldRank.get(tab.id), "data-pane-tab": tab.id, "data-tone": tab.tone, onAuxClick: (event) => {
|
|
288
|
+
if (event.button === 1 && closes(tab)) {
|
|
289
|
+
onClose(tab.id);
|
|
290
|
+
}
|
|
291
|
+
}, onContextMenu: (event) => onTabContextMenu?.(tab.id, event), onDoubleClick: () => onKeep?.(tab.id), onMouseDown: keepFocus, onPointerDown: (event) => {
|
|
292
|
+
if (event.button !== 0 || event.ctrlKey) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (onPick !== undefined && (event.metaKey || event.shiftKey)) {
|
|
296
|
+
onPick(tab.id, event.metaKey ? 'toggle' : 'run');
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
// A press on a picked tab waits for its release: it may start a drag of every pick.
|
|
300
|
+
if (onReorder !== undefined && hasPicks && carried.includes(tab.id)) {
|
|
301
|
+
drag.begin(tab.id, event.currentTarget, event.clientX, {
|
|
302
|
+
ids: carried,
|
|
303
|
+
onClick: () => onSelect(tab.id)
|
|
304
|
+
});
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (!isFront || hasPicks) {
|
|
308
|
+
onSelect(tab.id);
|
|
309
|
+
}
|
|
310
|
+
if (onReorder !== undefined) {
|
|
311
|
+
drag.begin(tab.id, event.currentTarget, event.clientX);
|
|
312
|
+
}
|
|
313
|
+
}, ref: drag.tabRef(tab.id), role: "tab", style: {
|
|
314
|
+
'--pane-tab-floor': `${floor.context + (tab.context === undefined ? 0 : 1) + floor.name}ch`
|
|
315
|
+
}, children: [tab.mark === undefined ? null : (_jsx("span", { "aria-hidden": true, className: "pane-tab-mark", children: tab.mark })), _jsx(TabLabel, { tab: tab }), tab.dirty === true ? (_jsx("span", { "aria-hidden": true, className: "pane-tab-dirty", ...tooltip(labels.notSaved), children: _jsx(StateMark, { tone: "warning", word: "" }) })) : null, tab.pinned === true ? (_jsx("span", { "aria-hidden": true, className: "pane-tab-pin", ...tooltip(labels.pinned), children: _jsx(Pin, { size: ICON_SM }) })) : closes(tab) ? (_jsx("button", { "aria-label": labels.close(spoken), className: "pane-tab-close hit-target quiet-control", onClick: (event) => {
|
|
316
|
+
event.stopPropagation();
|
|
317
|
+
onClose(tab.id);
|
|
318
|
+
}, onDoubleClick: (event) => event.stopPropagation(), onMouseDown: keepFocus,
|
|
319
|
+
// A press on the control is not the start of a drag of its tab.
|
|
320
|
+
onPointerDown: (event) => event.stopPropagation(), tabIndex: -1, type: "button", ...tooltip(labels.close(spoken)), children: _jsx(X, { "aria-hidden": true, size: ICON_SM }) })) : null] }));
|
|
321
|
+
};
|
|
322
|
+
return (_jsxs("div", { className: "pane-header", ref: headerRef, children: [_jsx("div", { "aria-label": label, className: "pane-tabs", ref: stripRef, role: "tablist", children: shown.map((id, index) => {
|
|
323
|
+
const tab = byId.get(id);
|
|
324
|
+
return tab === undefined ? null : (_jsxs(Fragment, { children: [tabElement(tab), index === lastPinned && index < shown.length - 1 ? (_jsx("span", { "aria-hidden": true, className: "pane-pin-rule" })) : null] }, id));
|
|
325
|
+
}) }), onNew === undefined ? null : (_jsx("button", { "aria-label": labels.newTab, className: "pane-tab-new hit-target quiet-control", onClick: onNew, onMouseDown: keepFocus, tabIndex: -1, type: "button", ...tooltip(labels.newTab, newChord), children: _jsx(Plus, { "aria-hidden": true, size: ICON_MD }) })), _jsx("span", { "aria-hidden": true, className: "pane-tabs-rest", onDoubleClick: onNew }), foldedTabs.length === 0 ? null : (_jsx(FoldedTabs, { folded: foldedTabs, labels: labels, onSelect: onSelect })), !hasTrailing ? null : (_jsx("span", { className: "pane-tabs-trailing", ref: trailingRef, children: trailing }))] }));
|
|
326
|
+
}
|