occulite-ui 0.0.0-stage → 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 (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +290 -2
  3. package/THIRD_PARTY_NOTICES.md +36 -0
  4. package/dist/clipboard.d.ts +26 -0
  5. package/dist/clipboard.js +70 -0
  6. package/dist/components/ContextMenu.svelte +158 -0
  7. package/dist/components/ContextMenu.svelte.d.ts +14 -0
  8. package/dist/components/DataTable.svelte +1990 -0
  9. package/dist/components/DataTable.svelte.d.ts +154 -0
  10. package/dist/components/Dialog.svelte +420 -0
  11. package/dist/components/Dialog.svelte.d.ts +55 -0
  12. package/dist/components/GithubLink.svelte +74 -0
  13. package/dist/components/GithubLink.svelte.d.ts +16 -0
  14. package/dist/components/Header.svelte +196 -0
  15. package/dist/components/Header.svelte.d.ts +42 -0
  16. package/dist/components/Icon.svelte +51 -0
  17. package/dist/components/Icon.svelte.d.ts +12 -0
  18. package/dist/components/LanguageSwitch.svelte +63 -0
  19. package/dist/components/LanguageSwitch.svelte.d.ts +17 -0
  20. package/dist/components/Loader.svelte +65 -0
  21. package/dist/components/Loader.svelte.d.ts +9 -0
  22. package/dist/components/MultiSelect.svelte +467 -0
  23. package/dist/components/MultiSelect.svelte.d.ts +28 -0
  24. package/dist/components/Notices.svelte +146 -0
  25. package/dist/components/Notices.svelte.d.ts +16 -0
  26. package/dist/components/PrimaryToolbarButton.svelte +189 -0
  27. package/dist/components/PrimaryToolbarButton.svelte.d.ts +34 -0
  28. package/dist/components/Tabs.svelte +118 -0
  29. package/dist/components/Tabs.svelte.d.ts +16 -0
  30. package/dist/components/ThemeSwitch.svelte +46 -0
  31. package/dist/components/ThemeSwitch.svelte.d.ts +11 -0
  32. package/dist/components/Toolbar.svelte +57 -0
  33. package/dist/components/Toolbar.svelte.d.ts +11 -0
  34. package/dist/components/ToolbarButton.svelte +126 -0
  35. package/dist/components/ToolbarButton.svelte.d.ts +22 -0
  36. package/dist/components/Tooltip.svelte +106 -0
  37. package/dist/components/Tooltip.svelte.d.ts +31 -0
  38. package/dist/components/TooltipBubble.svelte +65 -0
  39. package/dist/components/TooltipBubble.svelte.d.ts +18 -0
  40. package/dist/components/contextMenu.d.ts +19 -0
  41. package/dist/components/contextMenu.js +6 -0
  42. package/dist/components/dialogGeometry.d.ts +91 -0
  43. package/dist/components/dialogGeometry.js +140 -0
  44. package/dist/components/index.d.ts +22 -0
  45. package/dist/components/index.js +22 -0
  46. package/dist/components/multiSelect.d.ts +27 -0
  47. package/dist/components/multiSelect.js +26 -0
  48. package/dist/components/navigation.d.ts +34 -0
  49. package/dist/components/navigation.js +19 -0
  50. package/dist/components/tooltip.d.ts +29 -0
  51. package/dist/components/tooltip.js +27 -0
  52. package/dist/css/app.css +3 -0
  53. package/dist/css/base.css +84 -0
  54. package/dist/css/tokens.css +170 -0
  55. package/dist/dialog/index.d.ts +6 -0
  56. package/dist/dialog/index.js +6 -0
  57. package/dist/embedding/ShellEmbedding.svelte.d.ts +27 -0
  58. package/dist/embedding/ShellEmbedding.svelte.js +79 -0
  59. package/dist/embedding/constants.d.ts +23 -0
  60. package/dist/embedding/constants.js +54 -0
  61. package/dist/embedding/index.d.ts +2 -0
  62. package/dist/embedding/index.js +2 -0
  63. package/dist/externalLink.d.ts +15 -0
  64. package/dist/externalLink.js +20 -0
  65. package/dist/format.d.ts +6 -0
  66. package/dist/format.js +16 -0
  67. package/dist/i18n/i18n.svelte.d.ts +112 -0
  68. package/dist/i18n/i18n.svelte.js +211 -0
  69. package/dist/i18n/index.d.ts +3 -0
  70. package/dist/i18n/index.js +3 -0
  71. package/dist/i18n/messages.d.ts +9 -0
  72. package/dist/i18n/messages.js +58 -0
  73. package/dist/i18n/translator.d.ts +65 -0
  74. package/dist/i18n/translator.js +99 -0
  75. package/dist/icons/index.d.ts +17 -0
  76. package/dist/icons/index.js +11 -0
  77. package/dist/index.d.ts +16 -0
  78. package/dist/index.js +16 -0
  79. package/dist/notices/NoticesStore.svelte.d.ts +64 -0
  80. package/dist/notices/NoticesStore.svelte.js +127 -0
  81. package/dist/notices/index.d.ts +1 -0
  82. package/dist/notices/index.js +1 -0
  83. package/dist/storage.d.ts +11 -0
  84. package/dist/storage.js +27 -0
  85. package/dist/table/LocalColumnWidths.svelte.d.ts +32 -0
  86. package/dist/table/LocalColumnWidths.svelte.js +91 -0
  87. package/dist/table/columnMeasure.d.ts +24 -0
  88. package/dist/table/columnMeasure.js +82 -0
  89. package/dist/table/columnWidths.d.ts +60 -0
  90. package/dist/table/columnWidths.js +86 -0
  91. package/dist/table/dataTableContext.d.ts +26 -0
  92. package/dist/table/dataTableContext.js +16 -0
  93. package/dist/table/index.d.ts +6 -0
  94. package/dist/table/index.js +6 -0
  95. package/dist/table/metrics.d.ts +10 -0
  96. package/dist/table/metrics.js +10 -0
  97. package/dist/table/tableModel.d.ts +306 -0
  98. package/dist/table/tableModel.js +437 -0
  99. package/dist/theme/choices.d.ts +8 -0
  100. package/dist/theme/choices.js +6 -0
  101. package/dist/theme/index.d.ts +2 -0
  102. package/dist/theme/index.js +2 -0
  103. package/dist/theme/theme.svelte.d.ts +60 -0
  104. package/dist/theme/theme.svelte.js +108 -0
  105. package/package.json +137 -4
@@ -0,0 +1,189 @@
1
+ <script lang="ts">
2
+ import {isIconData, type IconData} from '../icons/index.js';
3
+ import Icon from './Icon.svelte';
4
+ import Tooltip from './Tooltip.svelte';
5
+
6
+ /**
7
+ * The main action of a tab, in its header band: an icon **and** a caption, larger than the
8
+ * toolbar icons and in the accent colour.
9
+ *
10
+ * "Pair device" on the Devices tab and "Add link" on the Links tab were a bare `+` among nine
11
+ * other icons, named only by their tooltip - the one action a new user comes to the tab for was
12
+ * the easiest one to miss. Both tabs use this component, so the two read as the same kind of
13
+ * thing.
14
+ *
15
+ * A narrow window takes the caption away before anything else in the band overflows, and the
16
+ * button never disappears. The slot the button sits in is a flex item whose basis is the width
17
+ * the captioned button needs (measured on a hidden copy) and whose minimum is the icon: when the
18
+ * band has less room than that, the flex layout shrinks the slot, and the button follows with
19
+ * its compact form. `contain: inline-size` keeps the button out of the slot's intrinsic size, so
20
+ * the band never has to grow to make room for a caption it cannot fit - and since the slot's
21
+ * width does not depend on which form the button is in, the two forms cannot chase each other.
22
+ */
23
+ interface Props {
24
+ /** The caption, and the accessible name in both forms. */
25
+ caption: string;
26
+ /** A single character, or icon data from `occulite-ui/icons`. */
27
+ icon?: string | IconData;
28
+ disabled?: boolean;
29
+ /** Why the button is disabled - shown in the tooltip, as `ToolbarButton` does. */
30
+ reason?: string | undefined;
31
+ /** `true` icon only, `false` always captioned; left out, the space in the band decides. */
32
+ compact?: boolean | undefined;
33
+ onclick?: (() => void) | undefined;
34
+ testId?: string | undefined;
35
+ }
36
+
37
+ let {
38
+ caption,
39
+ icon = '+',
40
+ disabled = false,
41
+ reason = undefined,
42
+ compact = undefined,
43
+ onclick = undefined,
44
+ testId = undefined,
45
+ }: Props = $props();
46
+
47
+ let slot = $state<HTMLElement | undefined>(undefined);
48
+ let measure = $state<HTMLElement | undefined>(undefined);
49
+ /** What the captioned button needs, and what the band gave its slot; 0 until measured. */
50
+ let captionedWidth = $state(0);
51
+ let slotWidth = $state(0);
52
+
53
+ $effect(() => {
54
+ const box = slot;
55
+ const copy = measure;
56
+ if (compact !== undefined || !box || !copy) {
57
+ return;
58
+ }
59
+ const update = (): void => {
60
+ captionedWidth = Math.ceil(copy.getBoundingClientRect().width);
61
+ slotWidth = box.getBoundingClientRect().width;
62
+ };
63
+ update();
64
+ const observer = new ResizeObserver(update);
65
+ observer.observe(box);
66
+ observer.observe(copy);
67
+ return () => {
68
+ observer.disconnect();
69
+ };
70
+ });
71
+
72
+ /**
73
+ * One pixel of slack, so a sub-pixel rounding never turns a fitting caption into an icon. A slot
74
+ * of no width at all has not been laid out yet (a tab that is still hidden, the first frame) -
75
+ * that is no reason to drop the caption, and dropping it there flashed the icon on every mount.
76
+ */
77
+ const isCompact = $derived(compact ?? (captionedWidth > 0 && slotWidth > 0 && slotWidth < captionedWidth - 1));
78
+ const tooltip = $derived(disabled && reason !== undefined ? `${caption} — ${reason}` : isCompact ? caption : '');
79
+ const tooltipTestId = $derived(testId === undefined ? undefined : `${testId}-tooltip`);
80
+ </script>
81
+
82
+ <span
83
+ class="hmm-primary-slot"
84
+ bind:this={slot}
85
+ style:flex-basis={captionedWidth > 0 ? `${String(captionedWidth)}px` : undefined}
86
+ >
87
+ <Tooltip text={tooltip} testId={tooltipTestId}>
88
+ <button
89
+ type="button"
90
+ class="hmm-primary-button"
91
+ class:hmm-primary-compact={isCompact}
92
+ aria-label={caption}
93
+ data-testid={testId}
94
+ data-compact={isCompact ? 'true' : 'false'}
95
+ {disabled}
96
+ onclick={() => onclick?.()}
97
+ >
98
+ <span class="hmm-primary-icon" aria-hidden="true"
99
+ >{#if isIconData(icon)}<Icon {icon} />{:else}{icon}{/if}</span
100
+ >
101
+ {#if !isCompact}
102
+ <span class="hmm-primary-caption" data-testid={testId === undefined ? undefined : `${testId}-caption`}
103
+ >{caption}</span
104
+ >
105
+ {/if}
106
+ </button>
107
+ </Tooltip>
108
+ {#if compact === undefined}
109
+ <!-- The captioned form, never seen: only its width is read. -->
110
+ <span class="hmm-primary-button hmm-primary-measure" aria-hidden="true" bind:this={measure}>
111
+ <span class="hmm-primary-icon"
112
+ >{#if isIconData(icon)}<Icon {icon} />{:else}{icon}{/if}</span
113
+ >
114
+ <span class="hmm-primary-caption">{caption}</span>
115
+ </span>
116
+ {/if}
117
+ </span>
118
+
119
+ <style>
120
+ /* 28 px tall where the toolbar icons are 26, and still the band's 33 px of the slot
121
+ reaches one pixel into the band's padding above and below instead of pushing the band open. */
122
+ .hmm-primary-slot {
123
+ position: relative;
124
+ display: flex;
125
+ align-items: center;
126
+ flex: 0 1 auto;
127
+ min-width: 30px;
128
+ margin-block: -1px;
129
+ margin-right: 6px;
130
+ contain: inline-size;
131
+ }
132
+
133
+ /* The accent colour is the app's one signal for "this is the action"; the pressed toolbar
134
+ toggle uses the same token. */
135
+ .hmm-primary-button {
136
+ box-sizing: border-box;
137
+ display: inline-flex;
138
+ align-items: center;
139
+ gap: 5px;
140
+ height: 28px;
141
+ min-width: 30px;
142
+ padding: 0 11px 0 8px;
143
+ border: 1px solid var(--hmm-accent);
144
+ border-radius: var(--hmm-radius);
145
+ background: var(--hmm-accent);
146
+ color: var(--hmm-accent-fg);
147
+ font: inherit;
148
+ font-weight: 600;
149
+ line-height: 1;
150
+ white-space: nowrap;
151
+ cursor: pointer;
152
+ }
153
+
154
+ .hmm-primary-button:hover:not(:disabled) {
155
+ filter: brightness(1.12);
156
+ }
157
+
158
+ .hmm-primary-button:focus-visible {
159
+ outline: 2px solid var(--hmm-focus);
160
+ outline-offset: 1px;
161
+ }
162
+
163
+ /* As in `ToolbarButton`: out of the hit test, so the tooltip anchor gets the pointer and the
164
+ reason can be read. */
165
+ .hmm-primary-button:disabled {
166
+ opacity: 0.45;
167
+ cursor: default;
168
+ pointer-events: none;
169
+ }
170
+
171
+ .hmm-primary-compact {
172
+ justify-content: center;
173
+ width: 30px;
174
+ padding: 0;
175
+ }
176
+
177
+ .hmm-primary-icon {
178
+ font-size: 17px;
179
+ line-height: 1;
180
+ }
181
+
182
+ .hmm-primary-measure {
183
+ position: absolute;
184
+ top: 0;
185
+ left: 0;
186
+ visibility: hidden;
187
+ pointer-events: none;
188
+ }
189
+ </style>
@@ -0,0 +1,34 @@
1
+ import { type IconData } from '../icons/index.js';
2
+ /**
3
+ * The main action of a tab, in its header band: an icon **and** a caption, larger than the
4
+ * toolbar icons and in the accent colour.
5
+ *
6
+ * "Pair device" on the Devices tab and "Add link" on the Links tab were a bare `+` among nine
7
+ * other icons, named only by their tooltip - the one action a new user comes to the tab for was
8
+ * the easiest one to miss. Both tabs use this component, so the two read as the same kind of
9
+ * thing.
10
+ *
11
+ * A narrow window takes the caption away before anything else in the band overflows, and the
12
+ * button never disappears. The slot the button sits in is a flex item whose basis is the width
13
+ * the captioned button needs (measured on a hidden copy) and whose minimum is the icon: when the
14
+ * band has less room than that, the flex layout shrinks the slot, and the button follows with
15
+ * its compact form. `contain: inline-size` keeps the button out of the slot's intrinsic size, so
16
+ * the band never has to grow to make room for a caption it cannot fit - and since the slot's
17
+ * width does not depend on which form the button is in, the two forms cannot chase each other.
18
+ */
19
+ interface Props {
20
+ /** The caption, and the accessible name in both forms. */
21
+ caption: string;
22
+ /** A single character, or icon data from `occulite-ui/icons`. */
23
+ icon?: string | IconData;
24
+ disabled?: boolean;
25
+ /** Why the button is disabled - shown in the tooltip, as `ToolbarButton` does. */
26
+ reason?: string | undefined;
27
+ /** `true` icon only, `false` always captioned; left out, the space in the band decides. */
28
+ compact?: boolean | undefined;
29
+ onclick?: (() => void) | undefined;
30
+ testId?: string | undefined;
31
+ }
32
+ declare const PrimaryToolbarButton: import("svelte").Component<Props, {}, "">;
33
+ type PrimaryToolbarButton = ReturnType<typeof PrimaryToolbarButton>;
34
+ export default PrimaryToolbarButton;
@@ -0,0 +1,118 @@
1
+ <script lang="ts">
2
+ import {t as kitT} from '../i18n/i18n.svelte.js';
3
+ interface Tab {
4
+ readonly id: string;
5
+ readonly label: string;
6
+ /** Drawn after the label in the 2.x way: "Servicemeldungen (9)". */
7
+ readonly badge?: string | number;
8
+ }
9
+
10
+ interface Props {
11
+ tabs: Tab[];
12
+ active?: string;
13
+ onselect?: ((id: string) => void) | undefined;
14
+ label?: string | undefined;
15
+ testId?: string | undefined;
16
+ }
17
+
18
+ let {
19
+ tabs,
20
+ active = $bindable(''),
21
+ onselect = undefined,
22
+ label: labelProp = undefined,
23
+ testId = undefined,
24
+ }: Props = $props();
25
+
26
+ const label = $derived(labelProp ?? kitT('Tabs'));
27
+
28
+ function select(id: string): void {
29
+ active = id;
30
+ onselect?.(id);
31
+ }
32
+
33
+ /** Left/right arrows move between tabs, which jQuery UI's tab widget also did. */
34
+ function onKeyDown(event: KeyboardEvent, index: number): void {
35
+ if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') {
36
+ return;
37
+ }
38
+ event.preventDefault();
39
+ const delta = event.key === 'ArrowRight' ? 1 : -1;
40
+ const next = tabs[(index + delta + tabs.length) % tabs.length];
41
+ if (next) {
42
+ select(next.id);
43
+ }
44
+ }
45
+ </script>
46
+
47
+ <div class="hmm-tabs" role="tablist" aria-label={label} data-testid={testId}>
48
+ {#each tabs as tab, index (tab.id)}
49
+ <button
50
+ type="button"
51
+ class="hmm-tab"
52
+ class:hmm-tab-active={tab.id === active}
53
+ role="tab"
54
+ id={`tab-${tab.id}`}
55
+ aria-selected={tab.id === active}
56
+ aria-controls={`panel-${tab.id}`}
57
+ tabindex={tab.id === active ? 0 : -1}
58
+ onclick={() => select(tab.id)}
59
+ onkeydown={(event) => onKeyDown(event, index)}
60
+ >
61
+ <span>{tab.label}</span>
62
+ {#if tab.badge !== undefined && tab.badge !== ''}<span class="hmm-tab-badge">({tab.badge})</span>{/if}
63
+ </button>
64
+ {/each}
65
+ </div>
66
+
67
+ <style>
68
+ /*
69
+ Flat tab buttons in the `she` idiom, and a tab that is
70
+ exactly as wide when it is active as when it is not, so the bar never moves when the user
71
+ switches. That rules out the bold-on-active of the 2.x look: the active tab is marked by a
72
+ background, the text colour and an inset underline, none of which changes a layout box.
73
+
74
+ The tabs span the full height of the bar and hang one pixel over its bottom border
75
+ (seen early on): the active tab's underline then lies on the border instead of
76
+ floating above it, the way a classic tab strip joins its page.
77
+ */
78
+ .hmm-tabs {
79
+ display: flex;
80
+ align-self: stretch;
81
+ align-items: stretch;
82
+ gap: 2px;
83
+ margin-bottom: -1px;
84
+ position: relative;
85
+ z-index: 1;
86
+ }
87
+
88
+ .hmm-tab {
89
+ display: flex;
90
+ align-items: center;
91
+ gap: 4px;
92
+ padding: 0 12px;
93
+ border: none;
94
+ border-radius: var(--hmm-radius) var(--hmm-radius) 0 0;
95
+ background: none;
96
+ color: var(--hmm-fg-muted);
97
+ font-weight: 500;
98
+ cursor: pointer;
99
+ white-space: nowrap;
100
+ }
101
+
102
+ .hmm-tab:hover:not(.hmm-tab-active) {
103
+ background: var(--hmm-control-bg-hover);
104
+ color: var(--hmm-fg);
105
+ }
106
+
107
+ .hmm-tab-active {
108
+ background: var(--hmm-accent-bg);
109
+ color: var(--hmm-fg);
110
+ /* An inset shadow, not a border: a border would make the active tab a pixel taller. Its
111
+ lowest pixel is the bar's border line, which the tab overlaps by design. */
112
+ box-shadow: inset 0 -2px 0 var(--hmm-accent);
113
+ }
114
+
115
+ .hmm-tab-badge {
116
+ color: var(--hmm-fg-muted);
117
+ }
118
+ </style>
@@ -0,0 +1,16 @@
1
+ interface Tab {
2
+ readonly id: string;
3
+ readonly label: string;
4
+ /** Drawn after the label in the 2.x way: "Servicemeldungen (9)". */
5
+ readonly badge?: string | number;
6
+ }
7
+ interface Props {
8
+ tabs: Tab[];
9
+ active?: string;
10
+ onselect?: ((id: string) => void) | undefined;
11
+ label?: string | undefined;
12
+ testId?: string | undefined;
13
+ }
14
+ declare const Tabs: import("svelte").Component<Props, {}, "active">;
15
+ type Tabs = ReturnType<typeof Tabs>;
16
+ export default Tabs;
@@ -0,0 +1,46 @@
1
+ <script lang="ts">
2
+ import {t as kitT} from '../i18n/i18n.svelte.js';
3
+ import type {ThemeChoice} from '../theme/choices.js';
4
+
5
+ interface Props {
6
+ theme?: ThemeChoice;
7
+ /** `t('Theme: light')` etc.; the kit's catalogue when absent. */
8
+ labelFor?: ((theme: ThemeChoice) => string) | undefined;
9
+ onclick?: (() => void) | undefined;
10
+ testId?: string | undefined;
11
+ }
12
+
13
+ let {theme = 'system', labelFor = undefined, onclick = undefined, testId = undefined}: Props = $props();
14
+
15
+ const ICONS: Record<ThemeChoice, string> = {system: '◐', light: '☀', dark: '☾'};
16
+ const label = $derived(labelFor?.(theme) ?? kitT(`Theme: ${theme}`));
17
+ </script>
18
+
19
+ <button
20
+ type="button"
21
+ class="hmm-theme-switch"
22
+ aria-label={label}
23
+ title={label}
24
+ data-testid={testId}
25
+ onclick={() => onclick?.()}
26
+ >
27
+ <span aria-hidden="true">{ICONS[theme]}</span>
28
+ </button>
29
+
30
+ <style>
31
+ .hmm-theme-switch {
32
+ width: 26px;
33
+ height: 24px;
34
+ padding: 0;
35
+ border: 1px solid var(--hmm-border);
36
+ border-radius: var(--hmm-radius);
37
+ background: var(--hmm-bg);
38
+ cursor: pointer;
39
+ line-height: 1;
40
+ }
41
+
42
+ .hmm-theme-switch:hover {
43
+ border-color: var(--hmm-border-strong);
44
+ background: var(--hmm-accent-bg);
45
+ }
46
+ </style>
@@ -0,0 +1,11 @@
1
+ import type { ThemeChoice } from '../theme/choices.js';
2
+ interface Props {
3
+ theme?: ThemeChoice;
4
+ /** `t('Theme: light')` etc.; the kit's catalogue when absent. */
5
+ labelFor?: ((theme: ThemeChoice) => string) | undefined;
6
+ onclick?: (() => void) | undefined;
7
+ testId?: string | undefined;
8
+ }
9
+ declare const ThemeSwitch: import("svelte").Component<Props, {}, "">;
10
+ type ThemeSwitch = ReturnType<typeof ThemeSwitch>;
11
+ export default ThemeSwitch;
@@ -0,0 +1,57 @@
1
+ <script lang="ts">
2
+ import {t as kitT} from '../i18n/i18n.svelte.js';
3
+ import type {Snippet} from 'svelte';
4
+
5
+ interface Props {
6
+ label?: string | undefined;
7
+ children?: Snippet | undefined;
8
+ /** Right-hand side, where the 2.x pager put its record count. */
9
+ trailing?: Snippet | undefined;
10
+ testId?: string | undefined;
11
+ }
12
+
13
+ let {
14
+ label: labelProp = undefined,
15
+ children = undefined,
16
+ trailing = undefined,
17
+ testId = undefined,
18
+ }: Props = $props();
19
+
20
+ const label = $derived(labelProp ?? kitT('Toolbar'));
21
+ </script>
22
+
23
+ <div class="hmm-toolbar" role="toolbar" aria-label={label} data-testid={testId}>
24
+ <div class="hmm-toolbar-group">
25
+ {#if children}{@render children()}{/if}
26
+ </div>
27
+ {#if trailing}
28
+ <div class="hmm-toolbar-trailing">{@render trailing()}</div>
29
+ {/if}
30
+ </div>
31
+
32
+ <style>
33
+ /* No framed grey box around the buttons any more - the toolbar is a row of controls on
34
+ the page, and the grid below it brings its own frame. */
35
+ .hmm-toolbar {
36
+ display: flex;
37
+ align-items: center;
38
+ gap: 4px;
39
+ padding: 0 0 6px;
40
+ }
41
+
42
+ .hmm-toolbar-group {
43
+ display: flex;
44
+ align-items: center;
45
+ gap: 2px;
46
+ flex: 1 1 auto;
47
+ flex-wrap: wrap;
48
+ }
49
+
50
+ .hmm-toolbar-trailing {
51
+ display: flex;
52
+ align-items: center;
53
+ gap: 6px;
54
+ color: var(--hmm-fg-muted);
55
+ white-space: nowrap;
56
+ }
57
+ </style>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ label?: string | undefined;
4
+ children?: Snippet | undefined;
5
+ /** Right-hand side, where the 2.x pager put its record count. */
6
+ trailing?: Snippet | undefined;
7
+ testId?: string | undefined;
8
+ }
9
+ declare const Toolbar: import("svelte").Component<Props, {}, "">;
10
+ type Toolbar = ReturnType<typeof Toolbar>;
11
+ export default Toolbar;
@@ -0,0 +1,126 @@
1
+ <script lang="ts">
2
+ import {isIconData, type IconData} from '../icons/index.js';
3
+ import Icon from './Icon.svelte';
4
+ import Tooltip from './Tooltip.svelte';
5
+
6
+ interface Props {
7
+ /** The tooltip and the accessible name; the buttons are icon-only. */
8
+ title: string;
9
+ /** A single character, or icon data from `occulite-ui/icons`. */
10
+ icon?: string | IconData;
11
+ disabled?: boolean;
12
+ /** Why the button is disabled - shown in the tooltip so "greyed out" is never a mystery. */
13
+ reason?: string | undefined;
14
+ pressed?: boolean | undefined;
15
+ /**
16
+ * The action this button started is still running: it turns, and it cannot be pressed
17
+ * again. A refresh that reads a remote system takes a moment, and without a sign that
18
+ * anything happened the button reads as one without a function.
19
+ */
20
+ busy?: boolean;
21
+ onclick?: (() => void) | undefined;
22
+ testId?: string | undefined;
23
+ }
24
+
25
+ let {
26
+ title,
27
+ icon = '•',
28
+ disabled = false,
29
+ reason = undefined,
30
+ pressed = undefined,
31
+ busy = false,
32
+ onclick = undefined,
33
+ testId = undefined,
34
+ }: Props = $props();
35
+
36
+ /** The anchor a test hovers: the button itself is disabled half the time and takes no pointer. */
37
+ const tooltipTestId = $derived(testId === undefined ? undefined : `${testId}-tooltip`);
38
+ </script>
39
+
40
+ <!--
41
+ The tooltip is drawn by the app, not by the browser. The `title` attribute made the
42
+ wait the browser's - four to five seconds on the reporter's macOS, a few hundred milliseconds
43
+ elsewhere - and on a disabled button it never appeared at all, which is precisely where the
44
+ text matters: `reason` is why the button is greyed out.
45
+ -->
46
+ <Tooltip text={disabled && reason !== undefined ? `${title} — ${reason}` : title} testId={tooltipTestId}>
47
+ <button
48
+ type="button"
49
+ class="hmm-toolbar-button"
50
+ class:hmm-toolbar-button-pressed={pressed === true}
51
+ aria-label={title}
52
+ aria-pressed={pressed}
53
+ aria-busy={busy ? 'true' : undefined}
54
+ data-testid={testId}
55
+ disabled={disabled || busy}
56
+ onclick={() => onclick?.()}
57
+ >
58
+ <span class="hmm-toolbar-icon" class:hmm-toolbar-icon-busy={busy} aria-hidden="true"
59
+ >{#if isIconData(icon)}<Icon {icon} />{:else}{icon}{/if}</span
60
+ >
61
+ </button>
62
+ </Tooltip>
63
+
64
+ <style>
65
+ /* The icon buttons of the she UI: no frame until the pointer is on them. */
66
+ .hmm-toolbar-button {
67
+ width: 26px;
68
+ height: 26px;
69
+ padding: 0;
70
+ border: 1px solid transparent;
71
+ border-radius: var(--hmm-radius);
72
+ background: none;
73
+ color: var(--hmm-fg-muted);
74
+ cursor: pointer;
75
+ line-height: 1;
76
+ }
77
+
78
+ .hmm-toolbar-button:hover:not(:disabled) {
79
+ background: var(--hmm-control-bg-hover);
80
+ color: var(--hmm-fg);
81
+ }
82
+
83
+ /*
84
+ * A disabled control dispatches no pointer events at all, so the anchor around it
85
+ * would never see the pointer and the tooltip that says *why* it is disabled could never
86
+ * appear. Taking it out of the hit test hands the pointer to the anchor.
87
+ */
88
+ .hmm-toolbar-button:disabled {
89
+ opacity: 0.4;
90
+ cursor: default;
91
+ pointer-events: none;
92
+ }
93
+
94
+ /* While the action runs the icon turns, so a refresh that takes a second is
95
+ visibly a refresh. `prefers-reduced-motion` gets the dimmed button without the spin. */
96
+ .hmm-toolbar-icon {
97
+ display: inline-block;
98
+ line-height: 1;
99
+ }
100
+
101
+ .hmm-toolbar-icon-busy {
102
+ animation: hmm-toolbar-spin 1s linear infinite;
103
+ }
104
+
105
+ @keyframes hmm-toolbar-spin {
106
+ from {
107
+ transform: rotate(0deg);
108
+ }
109
+
110
+ to {
111
+ transform: rotate(360deg);
112
+ }
113
+ }
114
+
115
+ @media (prefers-reduced-motion: reduce) {
116
+ .hmm-toolbar-icon-busy {
117
+ animation: none;
118
+ }
119
+ }
120
+
121
+ .hmm-toolbar-button-pressed {
122
+ background: var(--hmm-accent-bg);
123
+ border-color: var(--hmm-accent);
124
+ color: var(--hmm-fg);
125
+ }
126
+ </style>
@@ -0,0 +1,22 @@
1
+ import { type IconData } from '../icons/index.js';
2
+ interface Props {
3
+ /** The tooltip and the accessible name; the buttons are icon-only. */
4
+ title: string;
5
+ /** A single character, or icon data from `occulite-ui/icons`. */
6
+ icon?: string | IconData;
7
+ disabled?: boolean;
8
+ /** Why the button is disabled - shown in the tooltip so "greyed out" is never a mystery. */
9
+ reason?: string | undefined;
10
+ pressed?: boolean | undefined;
11
+ /**
12
+ * The action this button started is still running: it turns, and it cannot be pressed
13
+ * again. A refresh that reads a remote system takes a moment, and without a sign that
14
+ * anything happened the button reads as one without a function.
15
+ */
16
+ busy?: boolean;
17
+ onclick?: (() => void) | undefined;
18
+ testId?: string | undefined;
19
+ }
20
+ declare const ToolbarButton: import("svelte").Component<Props, {}, "">;
21
+ type ToolbarButton = ReturnType<typeof ToolbarButton>;
22
+ export default ToolbarButton;