@bigpixelrocket/uiok 0.1.3 → 0.2.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.
Files changed (146) hide show
  1. package/CHANGELOG.md +95 -1
  2. package/README.md +1 -1
  3. package/dist/activity/ActivityBar.d.ts +21 -8
  4. package/dist/activity/ActivityBar.js +15 -5
  5. package/dist/activity/activity.css +53 -6
  6. package/dist/button/Button.d.ts +10 -6
  7. package/dist/button/Button.js +6 -1
  8. package/dist/button/button.css +201 -33
  9. package/dist/charts/Line.logic.d.ts +6 -0
  10. package/dist/charts/Line.logic.js +9 -0
  11. package/dist/charts/LineChart.js +11 -4
  12. package/dist/charts/Pie.logic.d.ts +89 -1
  13. package/dist/charts/Pie.logic.js +272 -2
  14. package/dist/charts/PieChart.d.ts +2 -1
  15. package/dist/charts/PieChart.js +12 -5
  16. package/dist/charts/PieFill.d.ts +15 -0
  17. package/dist/charts/PieFill.js +33 -0
  18. package/dist/charts/ResultChart.d.ts +2 -2
  19. package/dist/charts/ResultChart.js +173 -47
  20. package/dist/charts/ResultChart.logic.d.ts +60 -4
  21. package/dist/charts/ResultChart.logic.js +105 -6
  22. package/dist/charts/Scatter.logic.d.ts +18 -4
  23. package/dist/charts/Scatter.logic.js +98 -22
  24. package/dist/charts/ScatterChart.js +19 -5
  25. package/dist/charts/charts.css +233 -116
  26. package/dist/charts/seriesColour.d.ts +2 -0
  27. package/dist/charts/seriesColour.js +1 -1
  28. package/dist/datetime/DateTimePicker.d.ts +12 -2
  29. package/dist/datetime/DateTimePicker.js +61 -16
  30. package/dist/datetime/DateTimePicker.logic.d.ts +29 -0
  31. package/dist/datetime/DateTimePicker.logic.js +25 -0
  32. package/dist/datetime/datetime.css +89 -49
  33. package/dist/dialog/ConfirmDialog.d.ts +69 -20
  34. package/dist/dialog/ConfirmDialog.js +39 -12
  35. package/dist/dialog/DialogLayer.d.ts +25 -0
  36. package/dist/dialog/DialogLayer.js +24 -0
  37. package/dist/dialog/DialogLegend.d.ts +2 -1
  38. package/dist/dialog/DialogLegend.js +10 -5
  39. package/dist/dialog/DialogLegend.logic.d.ts +15 -3
  40. package/dist/dialog/DialogLegend.logic.js +8 -4
  41. package/dist/dialog/DialogLists.d.ts +157 -0
  42. package/dist/dialog/DialogLists.js +137 -0
  43. package/dist/dialog/ModalDialog.d.ts +20 -15
  44. package/dist/dialog/ModalDialog.js +22 -7
  45. package/dist/dialog/dialog.css +570 -127
  46. package/dist/dialog/index.d.ts +7 -1
  47. package/dist/dialog/index.js +7 -1
  48. package/dist/field/Check.d.ts +15 -0
  49. package/dist/field/Check.js +23 -0
  50. package/dist/field/field.css +812 -0
  51. package/dist/field/index.d.ts +10 -0
  52. package/dist/field/index.js +10 -0
  53. package/dist/field/labelHelp.d.ts +33 -0
  54. package/dist/field/labelHelp.js +22 -0
  55. package/dist/filter/FilterIcon.js +2 -1
  56. package/dist/filter/filter.css +72 -20
  57. package/dist/grid/DataGrid.d.ts +8 -1
  58. package/dist/grid/DataGrid.js +115 -40
  59. package/dist/grid/DataGrid.logic.d.ts +15 -3
  60. package/dist/grid/DataGrid.logic.js +18 -5
  61. package/dist/grid/grid.css +481 -56
  62. package/dist/icon/Spinner.d.ts +16 -0
  63. package/dist/icon/Spinner.js +13 -0
  64. package/dist/icon/index.d.ts +5 -0
  65. package/dist/icon/index.js +5 -0
  66. package/dist/icon/sizes.d.ts +19 -0
  67. package/dist/icon/sizes.js +19 -0
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.js +2 -0
  70. package/dist/keychord/KeyChord.d.ts +12 -1
  71. package/dist/keychord/KeyChord.js +2 -2
  72. package/dist/keychord/index.d.ts +1 -1
  73. package/dist/keychord/keychord.css +87 -9
  74. package/dist/labels/dialog.d.ts +12 -1
  75. package/dist/labels/dialog.js +3 -1
  76. package/dist/labels/selectAll.d.ts +4 -4
  77. package/dist/labels/selectAll.js +1 -1
  78. package/dist/legend/KeyLegendStrip.js +1 -1
  79. package/dist/legend/legend.css +82 -57
  80. package/dist/listing/Listing.d.ts +17 -10
  81. package/dist/listing/Listing.js +33 -26
  82. package/dist/listing/listing.css +1665 -237
  83. package/dist/menu/menu.css +227 -67
  84. package/dist/menu/useBellBeat.js +2 -2
  85. package/dist/namecut/NameCut.d.ts +3 -1
  86. package/dist/namecut/NameCut.js +152 -5
  87. package/dist/namecut/NameCut.logic.d.ts +5 -3
  88. package/dist/namecut/NameCut.logic.js +20 -5
  89. package/dist/namecut/namecut.css +27 -7
  90. package/dist/pager/Pager.d.ts +12 -4
  91. package/dist/pager/Pager.js +21 -7
  92. package/dist/pager/pager.css +41 -30
  93. package/dist/palette/Palette.js +2 -1
  94. package/dist/palette/palette.css +121 -60
  95. package/dist/pane/PaneActions.d.ts +56 -14
  96. package/dist/pane/PaneActions.js +64 -16
  97. package/dist/pane/PaneFrame.d.ts +37 -5
  98. package/dist/pane/PaneFrame.js +246 -11
  99. package/dist/pane/index.d.ts +4 -2
  100. package/dist/pane/index.js +4 -2
  101. package/dist/pane/toolWords.d.ts +14 -0
  102. package/dist/pane/toolWords.js +26 -0
  103. package/dist/pane/useToolbarFit.d.ts +25 -0
  104. package/dist/pane/useToolbarFit.js +95 -0
  105. package/dist/run/RunHeader.d.ts +5 -3
  106. package/dist/run/RunHeader.js +11 -8
  107. package/dist/run/run.css +64 -79
  108. package/dist/segmented/SegmentedChoice.d.ts +18 -2
  109. package/dist/segmented/SegmentedChoice.js +18 -7
  110. package/dist/segmented/segmented.css +62 -22
  111. package/dist/selectall/SelectAllBar.d.ts +4 -3
  112. package/dist/selectall/SelectAllBar.js +4 -3
  113. package/dist/selectall/selectall.css +17 -12
  114. package/dist/shell/shell.css +1073 -0
  115. package/dist/styles.css +620 -22
  116. package/dist/surface/surface.css +154 -0
  117. package/dist/tabs/PageTabs.d.ts +10 -5
  118. package/dist/tabs/PageTabs.js +126 -37
  119. package/dist/tabs/tabs.css +131 -51
  120. package/dist/terminal/Terminal.js +3 -1
  121. package/dist/terminal/Terminal.logic.d.ts +5 -4
  122. package/dist/terminal/Terminal.logic.js +9 -4
  123. package/dist/terminal/TerminalMenu.d.ts +4 -1
  124. package/dist/terminal/TerminalMenu.js +12 -5
  125. package/dist/terminal/ghostty/contrast.logic.d.ts +45 -0
  126. package/dist/terminal/ghostty/contrast.logic.js +130 -0
  127. package/dist/terminal/ghostty/core.d.ts +6 -0
  128. package/dist/terminal/ghostty/renderer.d.ts +9 -2
  129. package/dist/terminal/ghostty/renderer.js +91 -14
  130. package/dist/terminal/ghostty/surface.d.ts +8 -0
  131. package/dist/terminal/ghostty/surface.js +27 -1
  132. package/dist/terminal/terminal.css +87 -61
  133. package/dist/text/text.css +16 -7
  134. package/dist/themes/catalog.js +4 -3
  135. package/dist/themes/themes.generated.css +1307 -264
  136. package/dist/themes/tokens.d.ts +69 -14
  137. package/dist/themes/tokens.js +920 -97
  138. package/dist/tokens.css +239 -0
  139. package/dist/tooltip/Tooltip.d.ts +6 -0
  140. package/dist/tooltip/Tooltip.js +48 -6
  141. package/dist/tooltip/Tooltip.logic.d.ts +89 -12
  142. package/dist/tooltip/Tooltip.logic.js +142 -20
  143. package/dist/tooltip/index.d.ts +1 -1
  144. package/dist/tooltip/index.js +1 -1
  145. package/dist/tooltip/tooltip.css +39 -9
  146. package/package.json +9 -3
@@ -6,10 +6,13 @@ import { type ReactElement, type Ref } from 'react';
6
6
  */
7
7
  export type LinkLook = 'icons' | 'text' | 'both';
8
8
  /**
9
- * How the `RowIconAction`s under it draw. An app whose rows follow a
10
- * preference provides it; icons alone without one. A `Listing` whose grid
11
- * is a function of the look steps it down to a plainer one when its words
12
- * would make it scroll sideways.
9
+ * How the `RowIconAction`s under it, and the `QuietAction`s in its rows,
10
+ * draw. An app whose rows follow a preference provides it; icons alone
11
+ * without one, each word kept as the control's tooltip and name. A path
12
+ * bar's tools and a `tabbable` row's actions show their words unless the
13
+ * look is `text` or `both` (which they follow); `icons` does not reach them. A
14
+ * `Listing` whose grid is a function of the look steps it down to a plainer
15
+ * one when its words would make it scroll sideways.
13
16
  */
14
17
  export declare const RowLinkLookContext: import("react").Context<LinkLook>;
15
18
  /**
@@ -24,6 +27,18 @@ export declare const InRowContext: import("react").Context<boolean>;
24
27
  * between panes and the page's other controls instead of through every row.
25
28
  */
26
29
  export declare const useInRow: () => boolean;
30
+ /**
31
+ * Set inside every listing row, a `tabbable` one included, whose
32
+ * `QuietAction`s follow `RowLinkLookContext` whether or not they keep their
33
+ * Tab stop. Internal to the library; not part of the package's surface.
34
+ */
35
+ export declare const InListingRowContext: import("react").Context<boolean>;
36
+ /**
37
+ * Set inside a path bar's tools (`PanePathBar`'s children), whose
38
+ * `QuietAction`s are toolbar items and follow `RowLinkLookContext` as a
39
+ * row's do. Internal to the pane area; not part of the package's surface.
40
+ */
41
+ export declare const InPathBarContext: import("react").Context<boolean>;
27
42
  /**
28
43
  * What the keys run a control for, read by `verbControl` off the rendered
29
44
  * pane. A row's control carries it as `data-verb`; a path bar's controls
@@ -41,12 +56,16 @@ export interface QuietActionProps {
41
56
  readonly word: string;
42
57
  /** The accessible name, which names the target ("Remove PostgreSQL 17"). */
43
58
  readonly label: string;
44
- /** Lit in the accent as its bar's lead action, as the cursor row's is. */
59
+ /** Its bar's lead action: a weight up, its glyph in the accent. */
45
60
  readonly lit?: boolean;
46
61
  readonly disabled?: boolean;
47
- /** The tooltip, also its accessible description; none without it. */
62
+ /**
63
+ * The tooltip, also its accessible description. Drawn as a glyph alone,
64
+ * the action names itself in a tooltip of its `word` when this is not
65
+ * given; drawn with its word, it has none without this.
66
+ */
48
67
  readonly tip?: string;
49
- /** The chord that runs it, which its tooltip names after `tip` ("⌥↩"). */
68
+ /** The chord that runs it, which its tooltip names after its words ("⌥↩"). */
50
69
  readonly shortcut?: string;
51
70
  readonly onClick: () => void;
52
71
  readonly ref?: Ref<HTMLButtonElement>;
@@ -64,15 +83,36 @@ export interface QuietActionProps {
64
83
  * logic that must tell them apart without reading the translated `word`.
65
84
  */
66
85
  readonly action?: string;
86
+ /**
87
+ * A destructive action (Remove, Drop, Delete): quiet at rest, in the
88
+ * danger tone under the pointer, with the focus, and on the cursor row.
89
+ */
90
+ readonly danger?: boolean;
91
+ /**
92
+ * In a toolbar fitted by `useToolbarFit`, keeps its word after the other
93
+ * tools have stepped to their glyphs, and steps only when the bar still
94
+ * does not fit (`data-keep-word`). For the one command whose glyph alone
95
+ * could be misread at a cost (Kill, Drop). A path bar ignores it.
96
+ */
97
+ readonly keepWord?: boolean;
67
98
  }
68
99
  /**
69
- * A row's one quiet action, or a compact control in a path bar: an icon and
70
- * a verb in the dim tone, lit in the accent on the cursor row (and as a
71
- * path bar's lead action, `lit`). In a row it leaves the Tab order
72
- * (`useInRow`), and a press never reaches the row's own `onOpen`. Drawn by
73
- * `.pane-act` in the listing look.
100
+ * A row's one quiet action, or a compact control in a path bar: in the dim
101
+ * tone at rest, in full words on the cursor row (and as a path bar's lead
102
+ * action, `lit`). In a row the keys reach (not `tabbable`) it draws as
103
+ * `RowLinkLookContext` says: a glyph alone by default (`icons`), with its
104
+ * word as its tooltip (and its `shortcut` after it) and kept for assistive
105
+ * technology in `.pane-act-word`, or its glyph and word under a look of
106
+ * words. A path bar's tool, a `tabbable` row's action, and a toolbar's
107
+ * command draw their glyph and word by default, whatever the row look, so
108
+ * a command reached by Tab shows what it does without a hover; a path bar
109
+ * too tight for its words hides them and keeps the glyph, its word then
110
+ * its tooltip, as a toolbar fitted by `useToolbarFit` does. In a row it leaves the Tab order (`useInRow`)
111
+ * unless the row is `tabbable`, and a press never reaches the row's own
112
+ * `onOpen`. Drawn by `.pane-act` in the listing
113
+ * look, `.pane-act.wordless` for the glyph alone.
74
114
  */
75
- export declare function QuietAction({ icon: Icon, word, label, lit, disabled, tip, shortcut, onClick, ref, softDisabled, verb, pageVerb, action }: QuietActionProps): ReactElement;
115
+ export declare function QuietAction({ icon: Icon, word, label, lit, disabled, tip, shortcut, onClick, ref, softDisabled, verb, pageVerb, action, danger, keepWord }: QuietActionProps): ReactElement;
76
116
  /** Props for {@link RowIconAction}. */
77
117
  export interface RowIconActionProps {
78
118
  readonly icon: LucideIcon;
@@ -92,6 +132,8 @@ export interface RowIconActionProps {
92
132
  * `RowLinkLookContext` of words, the word it draws.
93
133
  */
94
134
  readonly word?: string;
135
+ /** A destructive action, drawn as on `QuietAction`. */
136
+ readonly danger?: boolean;
95
137
  }
96
138
  /**
97
139
  * A compact icon control: in a row, one that shows on its row's hover, its
@@ -101,4 +143,4 @@ export interface RowIconActionProps {
101
143
  * in the listing look. Under `RowLinkLookContext` an action that names its
102
144
  * verb (`word`, a row link) draws it in place of the icon or beside it.
103
145
  */
104
- export declare function RowIconAction({ icon: Icon, label, disabled, onClick, ref, softDisabled, tip, verb, word }: RowIconActionProps): ReactElement;
146
+ export declare function RowIconAction({ icon: Icon, label, disabled, onClick, ref, softDisabled, tip, verb, word, danger }: RowIconActionProps): ReactElement;
@@ -1,11 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createContext, useContext } from 'react';
3
+ import { ICON_SM } from '../icon/index.js';
3
4
  import { describedTooltip, tooltip } from '../tooltip/Tooltip.logic.js';
4
5
  /**
5
- * How the `RowIconAction`s under it draw. An app whose rows follow a
6
- * preference provides it; icons alone without one. A `Listing` whose grid
7
- * is a function of the look steps it down to a plainer one when its words
8
- * would make it scroll sideways.
6
+ * How the `RowIconAction`s under it, and the `QuietAction`s in its rows,
7
+ * draw. An app whose rows follow a preference provides it; icons alone
8
+ * without one, each word kept as the control's tooltip and name. A path
9
+ * bar's tools and a `tabbable` row's actions show their words unless the
10
+ * look is `text` or `both` (which they follow); `icons` does not reach them. A
11
+ * `Listing` whose grid is a function of the look steps it down to a plainer
12
+ * one when its words would make it scroll sideways.
9
13
  */
10
14
  export const RowLinkLookContext = createContext('icons');
11
15
  /**
@@ -21,21 +25,63 @@ export const InRowContext = createContext(false);
21
25
  */
22
26
  export const useInRow = () => useContext(InRowContext);
23
27
  /**
24
- * A row's one quiet action, or a compact control in a path bar: an icon and
25
- * a verb in the dim tone, lit in the accent on the cursor row (and as a
26
- * path bar's lead action, `lit`). In a row it leaves the Tab order
27
- * (`useInRow`), and a press never reaches the row's own `onOpen`. Drawn by
28
- * `.pane-act` in the listing look.
28
+ * Set inside every listing row, a `tabbable` one included, whose
29
+ * `QuietAction`s follow `RowLinkLookContext` whether or not they keep their
30
+ * Tab stop. Internal to the library; not part of the package's surface.
29
31
  */
30
- export function QuietAction({ icon: Icon, word, label, lit = false, disabled = false, tip, shortcut, onClick, ref, softDisabled = false, verb, pageVerb, action }) {
32
+ export const InListingRowContext = createContext(false);
33
+ /**
34
+ * Set inside a path bar's tools (`PanePathBar`'s children), whose
35
+ * `QuietAction`s are toolbar items and follow `RowLinkLookContext` as a
36
+ * row's do. Internal to the pane area; not part of the package's surface.
37
+ */
38
+ export const InPathBarContext = createContext(false);
39
+ /**
40
+ * A row's one quiet action, or a compact control in a path bar: in the dim
41
+ * tone at rest, in full words on the cursor row (and as a path bar's lead
42
+ * action, `lit`). In a row the keys reach (not `tabbable`) it draws as
43
+ * `RowLinkLookContext` says: a glyph alone by default (`icons`), with its
44
+ * word as its tooltip (and its `shortcut` after it) and kept for assistive
45
+ * technology in `.pane-act-word`, or its glyph and word under a look of
46
+ * words. A path bar's tool, a `tabbable` row's action, and a toolbar's
47
+ * command draw their glyph and word by default, whatever the row look, so
48
+ * a command reached by Tab shows what it does without a hover; a path bar
49
+ * too tight for its words hides them and keeps the glyph, its word then
50
+ * its tooltip, as a toolbar fitted by `useToolbarFit` does. In a row it leaves the Tab order (`useInRow`)
51
+ * unless the row is `tabbable`, and a press never reaches the row's own
52
+ * `onOpen`. Drawn by `.pane-act` in the listing
53
+ * look, `.pane-act.wordless` for the glyph alone.
54
+ */
55
+ export function QuietAction({ icon: Icon, word, label, lit = false, disabled = false, tip, shortcut, onClick, ref, softDisabled = false, verb, pageVerb, action, danger = false, keepWord = false }) {
31
56
  const inRow = useInRow();
32
- return (_jsxs("button", { "aria-disabled": softDisabled || undefined, "aria-label": label, className: lit ? 'pane-act lit' : 'pane-act', "data-action": action, "data-page-verb": pageVerb, "data-verb": verb, "data-word": word, disabled: disabled, onClick: (event) => {
57
+ const inListingRow = useContext(InListingRowContext);
58
+ const inBar = useContext(InPathBarContext);
59
+ const chosen = useContext(RowLinkLookContext);
60
+ // Only an untabbable row's actions follow the icons look: the row's keys and
61
+ // menu name them. A path bar's tools and a tabbable row's actions are
62
+ // commands reached by Tab, so they say their word wherever it fits (the
63
+ // bar hides it, glyph kept, when it does not).
64
+ const look = inRow
65
+ ? chosen
66
+ : (inListingRow || inBar) && chosen !== 'icons'
67
+ ? chosen
68
+ : 'both';
69
+ // A glyph alone names itself in a tooltip of its word.
70
+ const shownTip = tip ?? (look === 'icons' ? word : undefined);
71
+ return (_jsxs("button", { "aria-disabled": softDisabled || undefined, "aria-label": label, className: [
72
+ 'pane-act',
73
+ look === 'icons' ? 'wordless' : '',
74
+ lit ? 'lit' : '',
75
+ danger ? 'danger' : ''
76
+ ]
77
+ .filter(Boolean)
78
+ .join(' '), "data-action": action, "data-keep-word": keepWord ? '' : undefined, "data-page-verb": pageVerb, "data-verb": verb, "data-word": word, disabled: disabled, onClick: (event) => {
33
79
  event.stopPropagation();
34
80
  if (!softDisabled)
35
81
  onClick();
36
- }, ref: ref, tabIndex: inRow ? -1 : undefined, type: "button", ...(tip === undefined ? {} : describedTooltip(tip)), ...(tip === undefined || shortcut === undefined
82
+ }, ref: ref, tabIndex: inRow ? -1 : undefined, type: "button", ...(shownTip === undefined ? {} : describedTooltip(shownTip)), ...(shownTip === undefined || shortcut === undefined
37
83
  ? {}
38
- : { 'data-tooltip-shortcut': shortcut }), children: [_jsx(Icon, { "aria-hidden": true, size: 12 }), word] }));
84
+ : { 'data-tooltip-shortcut': shortcut }), children: [_jsx(Icon, { "aria-hidden": true, size: ICON_SM }), _jsx("span", { className: "pane-act-word", children: word })] }));
39
85
  }
40
86
  /**
41
87
  * A compact icon control: in a row, one that shows on its row's hover, its
@@ -45,12 +91,14 @@ export function QuietAction({ icon: Icon, word, label, lit = false, disabled = f
45
91
  * in the listing look. Under `RowLinkLookContext` an action that names its
46
92
  * verb (`word`, a row link) draws it in place of the icon or beside it.
47
93
  */
48
- export function RowIconAction({ icon: Icon, label, disabled = false, onClick, ref, softDisabled = false, tip = label, verb, word }) {
94
+ export function RowIconAction({ icon: Icon, label, disabled = false, onClick, ref, softDisabled = false, tip = label, verb, word, danger = false }) {
49
95
  const inRow = useInRow();
50
96
  const chosen = useContext(RowLinkLookContext);
51
97
  // Only an action that names its verb draws it in words.
52
98
  const look = word === undefined ? 'icons' : chosen;
53
- return (_jsxs("button", { "aria-disabled": softDisabled || undefined, "aria-label": label, className: look === 'icons' ? 'pane-icon-act' : 'pane-icon-act worded', "data-verb": verb, "data-word": word, disabled: disabled, onClick: (event) => {
99
+ return (_jsxs("button", { "aria-disabled": softDisabled || undefined, "aria-label": label, className: ['pane-icon-act', look === 'icons' ? '' : 'worded', danger ? 'danger' : '']
100
+ .filter(Boolean)
101
+ .join(' '), "data-verb": verb, "data-word": word, disabled: disabled, onClick: (event) => {
54
102
  event.stopPropagation();
55
103
  if (!softDisabled)
56
104
  onClick();
@@ -58,5 +106,5 @@ export function RowIconAction({ icon: Icon, label, disabled = false, onClick, re
58
106
  ? {}
59
107
  : tip === label
60
108
  ? tooltip(label)
61
- : describedTooltip(tip)), children: [look !== 'text' && _jsx(Icon, { "aria-hidden": true, size: 13 }), look !== 'icons' && _jsx("span", { children: word })] }));
109
+ : describedTooltip(tip)), children: [look !== 'text' && _jsx(Icon, { "aria-hidden": true, size: ICON_SM }), look !== 'icons' && _jsx("span", { children: word })] }));
62
110
  }
@@ -30,12 +30,43 @@ export interface PanePathBarProps {
30
30
  * The row a pane opens with: a path bar, in the listing look (under
31
31
  * `.listing-root`). Its crumbs say where the pane is; one handed as a
32
32
  * `PaneCrumb` is a control that goes there. A narrow pane, or a longer
33
- * language, cuts a label crumb with an ellipsis, its whole text in its
34
- * tooltip. Facts and controls sit at the bar's end (`.path-tools`): a state
35
- * as `.path-facts`, compact verbs as `QuietAction` and `.path-star` icon
36
- * buttons.
33
+ * language, cuts a crumb with an ellipsis: the crumbs before the last give
34
+ * way first, the last one only once they have. A cut crumb opens its whole
35
+ * text as a tooltip, and a crumb in full view opens none (a control's
36
+ * `tip`, when it has one, says what a press does instead, cut or not).
37
+ * Facts and controls sit at the bar's end (`.path-tools`): a state
38
+ * as `PathFact`, compact verbs as `QuietAction` and `.path-star` icon
39
+ * buttons. In a bar too narrow for everything, things give way in one
40
+ * order (`pane.md`, "How a narrow bar gives way"): the crumbs before the
41
+ * last, then the last down to a stem, then a fact's words, then the crumbs
42
+ * before the last scroll out at the trail's start, then the quiet actions'
43
+ * words step down to icons, then the last crumb cuts to one character.
44
+ * Nothing is drawn over anything, and no control leaves the row. The bar
45
+ * fits itself after every render and whenever any box in it resizes.
37
46
  */
38
47
  export declare function PanePathBar({ trail, mark, heading, here, children }: PanePathBarProps): ReactElement;
48
+ /** Props for {@link PathFact}. */
49
+ export interface PathFactProps {
50
+ /**
51
+ * A failure (`danger`) or a change waiting for the user (`warning`): its
52
+ * mark, a `StateMark` of the same tone, carries the colour, and its words
53
+ * stand a step up from a plain fact's dim ones, in the text colour, never
54
+ * red or amber. Set as a class (`.path-facts.danger`) a host may read.
55
+ */
56
+ readonly tone?: 'danger' | 'warning';
57
+ /** Drawn before the words: the fact's `StateMark` (with `word=""`). */
58
+ readonly mark?: ReactNode;
59
+ /** The fact's words. */
60
+ readonly children: string;
61
+ }
62
+ /**
63
+ * A page's state at its path bar's end (`.path-facts`): an optional mark
64
+ * and the fact's words, the mark one gap from them. In a bar too narrow for
65
+ * everything, once the trail has given its floor, the words cut with an
66
+ * ellipsis down to one character, and the whole fact opens as a tooltip
67
+ * only while it is cut.
68
+ */
69
+ export declare function PathFact({ tone, mark, children }: PathFactProps): ReactElement;
39
70
  /** Props for {@link PaneStatus}. */
40
71
  export interface PaneStatusProps {
41
72
  /** The summary of what the pane lists or shows ("12 items"). */
@@ -46,6 +77,7 @@ export interface PaneStatusProps {
46
77
  /**
47
78
  * The line a pane closes with: one summary of what the pane lists or
48
79
  * shows, and compact icon controls at its end (`tools`, `RowIconAction`s),
49
- * which the summary gives way to.
80
+ * which the summary gives way to. A summary in words that a narrow pane
81
+ * cuts with an ellipsis carries itself whole as its tooltip.
50
82
  */
51
83
  export declare function PaneStatus({ children, tools }: PaneStatusProps): ReactElement;
@@ -1,28 +1,263 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment } from 'react';
3
- import { describedTooltip, tooltip } from '../tooltip/Tooltip.logic.js';
2
+ import { Fragment, useLayoutEffect, useRef } from 'react';
3
+ import { cutTooltip, describedTooltip } from '../tooltip/Tooltip.logic.js';
4
+ import { InPathBarContext } from './PaneActions.js';
5
+ import { clearWordTips, giveWordTips } from './toolWords.js';
6
+ /** A fact of words alone, or of words after marks: the bar cuts its words. */
7
+ const WORDS_FACT = '.path-facts:not(:has(> :not(.pane-state, svg, :empty)))';
8
+ /**
9
+ * Rests a trail its row cannot hold whole on its end, a slash first. The
10
+ * layout itself is the stylesheet's (the trail gives way, then the tools,
11
+ * then the trail below its floor); a trail that still runs past its box
12
+ * scrolls, and only a script can say where it rests: on its end, so the
13
+ * last crumb (where the pane is) shows, at the first slash that lets the
14
+ * crumbs after it show whole. `--pane-crumb-fit` is the room after the
15
+ * last crumb that lets the trail scroll that far, and `data-cramped` marks
16
+ * the trail. While a crumb has the focus the trail stays where the focus
17
+ * scrolled it. It also gives a fact of bare words, which the bar cuts, its
18
+ * whole words as a tooltip while they are cut, as `PathFact` has.
19
+ */
20
+ function fitTrail(row) {
21
+ for (const fact of row.querySelectorAll(`:scope > .path-tools > ${WORDS_FACT}`)) {
22
+ const words = fact.textContent ?? '';
23
+ if (fact.dataset.pathFactTip === undefined && fact.hasAttribute('data-tooltip'))
24
+ continue;
25
+ if (words === '')
26
+ continue;
27
+ fact.dataset.pathFactTip = '';
28
+ fact.dataset.tooltip = words;
29
+ fact.dataset.tooltipCut = '';
30
+ }
31
+ // A row a host lets wrap holds its tools on a line of their own, where
32
+ // they owe the trail no room (`data-wraps` lifts that cap).
33
+ const wraps = getComputedStyle(row).flexWrap !== 'nowrap';
34
+ if (wraps !== row.hasAttribute('data-wraps'))
35
+ row.toggleAttribute('data-wraps', wraps);
36
+ const trail = row.querySelector(':scope > .pane-crumbs');
37
+ // Right to left keeps the browser's own scroll origin (decision recorded
38
+ // in pane.md): the trail scrolls, and rests where the browser puts it.
39
+ if (trail === null || getComputedStyle(trail).direction === 'rtl')
40
+ return;
41
+ // Measure the bar as the stylesheet lays it out, unpinned.
42
+ const focused = trail.contains(document.activeElement);
43
+ const first = trail.firstElementChild;
44
+ delete trail.dataset.cramped;
45
+ trail.style.removeProperty('--pane-crumb-fit');
46
+ first?.style.removeProperty('margin-inline-start');
47
+ stepActionWords(row, trail);
48
+ // While a crumb's menu is open the trail clips nothing, so it does not
49
+ // scroll: its crumbs are shifted to where it would rest instead.
50
+ const open = trail.querySelector('[aria-expanded="true"]') !== null;
51
+ const max = trail.scrollWidth - trail.clientWidth;
52
+ if (max < 1) {
53
+ if (!focused)
54
+ trail.scrollLeft = 0;
55
+ return;
56
+ }
57
+ // Where each slash starts in the trail's scrolled content, less the
58
+ // trail's start padding, which the slash keeps before it at rest, less
59
+ // half the padding after the crumb before it: rounding either way then
60
+ // shows only that padding, never a sliver of the crumb. The trail rests on
61
+ // the first such point that lets every crumb after it show, pinned that
62
+ // much narrower (`--pane-crumb-fit`, its width while
63
+ // `data-cramped="pinned"`), and the room it leaves goes to the tools.
64
+ const style = getComputedStyle(trail);
65
+ const box = trail.getBoundingClientRect();
66
+ const origin = box.left + trail.clientLeft - trail.scrollLeft;
67
+ const inset = parseFloat(style.paddingLeft) / 2 || 0;
68
+ const end = trail.lastElementChild?.getBoundingClientRect().right ?? box.right;
69
+ // Fractional, as the boxes are: `clientWidth` rounds.
70
+ const exact = end - origin + (parseFloat(style.paddingRight) || 0) - box.width;
71
+ const rest = [...trail.querySelectorAll(':scope > .crumb-separator')]
72
+ .map((slash) => slash.getBoundingClientRect().left - origin - inset)
73
+ .find((at) => at >= exact - 0.5) ?? exact;
74
+ const pinned = rest - exact >= 1;
75
+ if (pinned)
76
+ trail.style.setProperty('--pane-crumb-fit', `${box.width - (rest - exact)}px`);
77
+ trail.dataset.cramped = pinned ? 'pinned' : '';
78
+ if (open)
79
+ first?.style.setProperty('margin-inline-start', `${-Math.ceil(rest)}px`);
80
+ else if (!focused)
81
+ trail.scrollLeft = trail.scrollWidth - trail.clientWidth;
82
+ }
83
+ /**
84
+ * The bar's last step before the last crumb falls below its stem: its
85
+ * quiet actions say their verbs with their icons alone (`data-tight` on
86
+ * the row), as a row's actions do where values need the room. Each keeps
87
+ * its accessible name, and one without a tooltip of its own takes its
88
+ * word as one while the word is hidden.
89
+ */
90
+ function stepActionWords(row, trail) {
91
+ delete row.dataset.tight;
92
+ clearWordTips(row);
93
+ const acts = row.querySelectorAll(':scope > .path-tools > .pane-act');
94
+ const text = trail.lastElementChild?.querySelector('.crumb-text');
95
+ if (acts.length === 0 || text == null)
96
+ return;
97
+ // The stem shows the shorter of the name and eight characters, and an
98
+ // ellipsis after eight. Exact widths: a name a fraction of a pixel short
99
+ // of its box already shows its ellipsis.
100
+ const name = text.textContent ?? '';
101
+ if (name.length === 0)
102
+ return;
103
+ const words = document.createRange();
104
+ words.selectNodeContents(text);
105
+ // A document without range geometry reads the whole pixels it has.
106
+ const whole = typeof words.getBoundingClientRect === 'function'
107
+ ? words.getBoundingClientRect().width
108
+ : text.scrollWidth;
109
+ const stem = name.length > 8 ? (whole / name.length) * 9 : whole;
110
+ if (text.getBoundingClientRect().width >= stem - 0.01)
111
+ return;
112
+ row.dataset.tight = '';
113
+ giveWordTips(acts);
114
+ }
115
+ /**
116
+ * Brings a crumb the keyboard focuses wholly into view, its ring clear of
117
+ * the fade at a side that hides more crumbs: the browser's own scroll on
118
+ * focus stops at the trail's edge, under the fade.
119
+ */
120
+ function showFocusedCrumb(trail, crumb) {
121
+ const style = getComputedStyle(trail);
122
+ // The fade's depth, which the trail's scroll padding repeats as a length.
123
+ const fade = parseFloat(style.scrollPaddingLeft) || 0;
124
+ const ring = parseFloat(getComputedStyle(crumb).outlineWidth) || 0;
125
+ const box = trail.getBoundingClientRect();
126
+ const at = crumb.getBoundingClientRect();
127
+ const max = trail.scrollWidth - trail.clientWidth;
128
+ if (at.left - ring < box.left + fade && trail.scrollLeft > 0) {
129
+ trail.scrollLeft = Math.max(0, Math.floor(trail.scrollLeft - (box.left + fade - (at.left - ring))));
130
+ }
131
+ else if (at.right + ring > box.right - fade && trail.scrollLeft < max) {
132
+ trail.scrollLeft = Math.min(max, Math.ceil(trail.scrollLeft + (at.right + ring - (box.right - fade))));
133
+ }
134
+ }
4
135
  /**
5
136
  * The row a pane opens with: a path bar, in the listing look (under
6
137
  * `.listing-root`). Its crumbs say where the pane is; one handed as a
7
138
  * `PaneCrumb` is a control that goes there. A narrow pane, or a longer
8
- * language, cuts a label crumb with an ellipsis, its whole text in its
9
- * tooltip. Facts and controls sit at the bar's end (`.path-tools`): a state
10
- * as `.path-facts`, compact verbs as `QuietAction` and `.path-star` icon
11
- * buttons.
139
+ * language, cuts a crumb with an ellipsis: the crumbs before the last give
140
+ * way first, the last one only once they have. A cut crumb opens its whole
141
+ * text as a tooltip, and a crumb in full view opens none (a control's
142
+ * `tip`, when it has one, says what a press does instead, cut or not).
143
+ * Facts and controls sit at the bar's end (`.path-tools`): a state
144
+ * as `PathFact`, compact verbs as `QuietAction` and `.path-star` icon
145
+ * buttons. In a bar too narrow for everything, things give way in one
146
+ * order (`pane.md`, "How a narrow bar gives way"): the crumbs before the
147
+ * last, then the last down to a stem, then a fact's words, then the crumbs
148
+ * before the last scroll out at the trail's start, then the quiet actions'
149
+ * words step down to icons, then the last crumb cuts to one character.
150
+ * Nothing is drawn over anything, and no control leaves the row. The bar
151
+ * fits itself after every render and whenever any box in it resizes.
12
152
  */
13
153
  export function PanePathBar({ trail, mark, heading = false, here, children }) {
14
- return (_jsxs("div", { className: "pane-path-row", children: [_jsxs("div", { className: "pane-crumbs", children: [mark !== undefined && (_jsx("span", { className: "crumb root", children: _jsx("span", { className: "crumb-label crumb-mark", children: mark }) })), trail.map((crumb, index) => {
154
+ const rowRef = useRef(null);
155
+ const sizes = useRef(null);
156
+ const last = trail.at(-1);
157
+ const lastLabel = typeof last === 'string' ? last : (last?.label ?? '');
158
+ // The trail's resting place follows every size in the bar: the row's,
159
+ // the trail's, each crumb's, and each tool's (a word that changes on its
160
+ // own, a font that loads late). So it is
161
+ // fitted after every render, whenever one of those boxes resizes, once
162
+ // the document's fonts are in, and when the focus leaves the trail.
163
+ useLayoutEffect(() => {
164
+ const row = rowRef.current;
165
+ if (row === null)
166
+ return;
167
+ let live = true;
168
+ const fit = () => {
169
+ if (live)
170
+ fitTrail(row);
171
+ };
172
+ if (typeof ResizeObserver !== 'undefined')
173
+ sizes.current = new ResizeObserver(fit);
174
+ const left = (event) => {
175
+ const to = event.relatedTarget;
176
+ if (!(to instanceof Node) || !event.currentTarget.contains(to))
177
+ fit();
178
+ };
179
+ // The browser scrolls a focused crumb into view after the focus
180
+ // event, so the fade's room is added on the next frame.
181
+ const shown = (event) => {
182
+ const trail = event.currentTarget;
183
+ const crumb = event.target;
184
+ if (!(crumb instanceof Element) || crumb === trail)
185
+ return;
186
+ requestAnimationFrame(() => {
187
+ if (live && document.activeElement === crumb)
188
+ showFocusedCrumb(trail, crumb);
189
+ });
190
+ };
191
+ const crumbs = row.querySelector(':scope > .pane-crumbs');
192
+ // A crumb's menu opening or closing changes how the trail clips.
193
+ const menus = typeof MutationObserver === 'undefined' ? null : new MutationObserver(fit);
194
+ if (crumbs !== null) {
195
+ menus?.observe(crumbs, { subtree: true, attributeFilter: ['aria-expanded'] });
196
+ }
197
+ crumbs?.addEventListener('focusout', left);
198
+ crumbs?.addEventListener('focusin', shown);
199
+ void document.fonts?.ready.then(fit);
200
+ return () => {
201
+ live = false;
202
+ sizes.current?.disconnect();
203
+ sizes.current = null;
204
+ menus?.disconnect();
205
+ crumbs?.removeEventListener('focusout', left);
206
+ crumbs?.removeEventListener('focusin', shown);
207
+ };
208
+ }, []);
209
+ useLayoutEffect(() => {
210
+ const row = rowRef.current;
211
+ if (row === null)
212
+ return;
213
+ const observer = sizes.current;
214
+ if (observer !== null) {
215
+ observer.disconnect();
216
+ // Border boxes: the room the fit adds after the last crumb is
217
+ // padding, which must not count as a resize of the trail.
218
+ const border = { box: 'border-box' };
219
+ observer.observe(row, border);
220
+ const crumbs = row.querySelector(':scope > .pane-crumbs');
221
+ if (crumbs !== null) {
222
+ observer.observe(crumbs, border);
223
+ for (const crumb of crumbs.children)
224
+ observer.observe(crumb, border);
225
+ }
226
+ // A tool that grows while the trail is pinned changes no box above.
227
+ for (const tool of row.querySelectorAll(':scope > .path-tools > *')) {
228
+ observer.observe(tool, border);
229
+ }
230
+ }
231
+ fitTrail(row);
232
+ });
233
+ return (_jsxs("div", { className: "pane-path-row", ref: rowRef, style: {
234
+ // The trail's floor (listing.css): its crumbs, and the last one's
235
+ // stem, eight characters and an ellipsis or its whole name.
236
+ '--pane-crumb-count': trail.length,
237
+ '--pane-crumb-here-room': `${lastLabel.length > 8 ? 9 : lastLabel.length}ch`
238
+ }, children: [_jsxs("div", { className: "pane-crumbs", children: [mark !== undefined && (_jsx("span", { className: "crumb root", children: _jsx("span", { className: "crumb-label crumb-mark", children: mark }) })), trail.map((crumb, index) => {
15
239
  const last = index === trail.length - 1;
16
240
  const label = typeof crumb === 'string' ? crumb : crumb.label;
17
241
  const Label = last && heading ? 'h2' : 'span';
18
- return (_jsxs(Fragment, { children: [index > 0 && (_jsx("span", { "aria-hidden": true, className: "crumb-separator", children: "/" })), _jsxs("span", { className: last ? 'crumb here' : 'crumb', children: [typeof crumb === 'string' ? (_jsx(Label, { className: "crumb-label", ...tooltip(label), children: label })) : (_jsx("button", { className: "crumb-label", onClick: crumb.onOpen, type: "button", ...describedTooltip(crumb.tip), children: label })), last && here] })] }, `${index}:${label}`));
19
- })] }), children !== undefined && children !== null && children !== false && (_jsx("div", { className: "path-tools", children: children }))] }));
242
+ return (_jsxs(Fragment, { children: [index > 0 && (_jsx("span", { "aria-hidden": true, className: "crumb-separator", children: "/" })), _jsxs("span", { className: last ? 'crumb here' : 'crumb', children: [typeof crumb === 'string' ? (_jsx(Label, { className: "crumb-label", children: _jsx("span", { className: "crumb-text", ...cutTooltip(label), children: label }) })) : (_jsx("button", { className: "crumb-label", onClick: crumb.onOpen, type: "button", ...describedTooltip(crumb.tip), children: _jsx("span", { className: "crumb-text", ...(crumb.tip === undefined ? cutTooltip(label) : {}), children: label }) })), last && here] })] }, `${index}:${label}`));
243
+ })] }), children !== undefined && children !== null && children !== false && (_jsx("div", { className: "path-tools", children: _jsx(InPathBarContext.Provider, { value: true, children: children }) }))] }));
244
+ }
245
+ /**
246
+ * A page's state at its path bar's end (`.path-facts`): an optional mark
247
+ * and the fact's words, the mark one gap from them. In a bar too narrow for
248
+ * everything, once the trail has given its floor, the words cut with an
249
+ * ellipsis down to one character, and the whole fact opens as a tooltip
250
+ * only while it is cut.
251
+ */
252
+ export function PathFact({ tone, mark, children }) {
253
+ return (_jsxs("span", { className: tone === undefined ? 'path-facts' : `path-facts ${tone}`, children: [mark, _jsx("span", { className: "path-fact-text", ...cutTooltip(children), children: children })] }));
20
254
  }
21
255
  /**
22
256
  * The line a pane closes with: one summary of what the pane lists or
23
257
  * shows, and compact icon controls at its end (`tools`, `RowIconAction`s),
24
- * which the summary gives way to.
258
+ * which the summary gives way to. A summary in words that a narrow pane
259
+ * cuts with an ellipsis carries itself whole as its tooltip.
25
260
  */
26
261
  export function PaneStatus({ children, tools }) {
27
- return (_jsxs("footer", { className: "pane-status", children: [_jsx("span", { className: "pane-summary", children: children }), tools !== undefined && tools !== null && tools !== false && (_jsx("span", { className: "pane-status-tools", children: tools }))] }));
262
+ return (_jsxs("footer", { className: "pane-status", children: [_jsx("span", { className: "pane-summary", ...(typeof children === 'string' ? cutTooltip(children) : {}), children: children }), tools !== undefined && tools !== null && tools !== false && (_jsx("span", { className: "pane-status-tools", children: tools }))] }));
28
263
  }
@@ -1,11 +1,13 @@
1
1
  /**
2
2
  * Panes: the path bar and status line a pane opens and closes with, the
3
- * compact controls inside them and in listing rows, and the keyboard of a
3
+ * compact controls inside them, in listing rows, and in a toolbar that
4
+ * fits its tools to one line (`useToolbarFit`), and the keyboard of a
4
5
  * sidebar beside a page (`usePaneKeys`) with the pure key mapping and DOM
5
6
  * readers it is built on. Styled by the listing look under `.listing-root`.
6
7
  */
7
8
  export { InRowContext, QuietAction, RowIconAction, RowLinkLookContext, useInRow, type ControlVerb, type LinkLook, type QuietActionProps, type RowIconActionProps } from './PaneActions.js';
8
- export { PanePathBar, PaneStatus, type PaneCrumb, type PanePathBarProps, type PaneStatusProps } from './PaneFrame.js';
9
+ export { PanePathBar, PaneStatus, PathFact, type PaneCrumb, type PanePathBarProps, type PaneStatusProps, type PathFactProps } from './PaneFrame.js';
9
10
  export { isTabStop, nextTabStop, pageRows, paneRow, paneRows, showRow, tabStops, verbControl, type SidebarTabStops, type TabStop } from './PaneKeys.js';
10
11
  export { movedIndex, NO_MAIN_VERBS, paneKeyAction, sameVerbs, type MainVerbs, type PaneKeyAction, type PaneKeyOptions, type PaneKeyStroke, type PaneMove } from './PaneKeys.logic.js';
12
+ export { useToolbarFit } from './useToolbarFit.js';
11
13
  export { usePaneKeys, type Pane, type PaneKeys, type PaneKeysOptions } from './usePaneKeys.js';
@@ -1,11 +1,13 @@
1
1
  /**
2
2
  * Panes: the path bar and status line a pane opens and closes with, the
3
- * compact controls inside them and in listing rows, and the keyboard of a
3
+ * compact controls inside them, in listing rows, and in a toolbar that
4
+ * fits its tools to one line (`useToolbarFit`), and the keyboard of a
4
5
  * sidebar beside a page (`usePaneKeys`) with the pure key mapping and DOM
5
6
  * readers it is built on. Styled by the listing look under `.listing-root`.
6
7
  */
7
8
  export { InRowContext, QuietAction, RowIconAction, RowLinkLookContext, useInRow } from './PaneActions.js';
8
- export { PanePathBar, PaneStatus } from './PaneFrame.js';
9
+ export { PanePathBar, PaneStatus, PathFact } from './PaneFrame.js';
9
10
  export { isTabStop, nextTabStop, pageRows, paneRow, paneRows, showRow, tabStops, verbControl } from './PaneKeys.js';
10
11
  export { movedIndex, NO_MAIN_VERBS, paneKeyAction, sameVerbs } from './PaneKeys.logic.js';
12
+ export { useToolbarFit } from './useToolbarFit.js';
11
13
  export { usePaneKeys } from './usePaneKeys.js';
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The word step a path bar and a fitted toolbar share: when their quiet
3
+ * actions say their verbs with their glyphs alone, each one without a
4
+ * tooltip of its own takes its word (`data-word`) as one, marked
5
+ * `data-word-tip` so the next fit can take back exactly what it gave.
6
+ * Internal to the pane area; not part of the package's surface.
7
+ */
8
+ /** Takes back every word tooltip a fit gave under `root`. */
9
+ export declare function clearWordTips(root: HTMLElement): void;
10
+ /**
11
+ * Gives each action whose word the fit hides that word as its tooltip,
12
+ * leaving an action that has a tooltip of its own (a `tip`) as it is.
13
+ */
14
+ export declare function giveWordTips(acts: Iterable<HTMLElement>): void;