@alulore/kumiko 0.15.1 → 0.17.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 (91) hide show
  1. package/dist/media-viewer/icons.d.ts +4 -0
  2. package/dist/media-viewer/icons.js +18 -0
  3. package/dist/media-viewer/index.d.ts +4 -0
  4. package/dist/media-viewer/index.js +3 -0
  5. package/dist/media-viewer/media-slide.d.ts +14 -0
  6. package/dist/media-viewer/media-slide.js +67 -0
  7. package/dist/media-viewer/media-viewer.css +611 -0
  8. package/dist/media-viewer/media-viewer.d.ts +17 -0
  9. package/dist/media-viewer/media-viewer.js +241 -0
  10. package/dist/media-viewer/pager-drag.d.ts +10 -0
  11. package/dist/media-viewer/pager-drag.js +53 -0
  12. package/dist/media-viewer/types.d.ts +58 -0
  13. package/dist/media-viewer/types.js +17 -0
  14. package/dist/media-viewer/video-controls.d.ts +3 -0
  15. package/dist/media-viewer/video-controls.js +62 -0
  16. package/dist/media-viewer/view-gesture.d.ts +74 -0
  17. package/dist/media-viewer/view-gesture.js +465 -0
  18. package/dist/media-viewer/viewer-chrome.d.ts +13 -0
  19. package/dist/media-viewer/viewer-chrome.js +35 -0
  20. package/dist/media-viewer/viewer-motion.d.ts +9 -0
  21. package/dist/media-viewer/viewer-motion.js +126 -0
  22. package/dist/media-viewer/zoom-pan.d.ts +35 -0
  23. package/dist/media-viewer/zoom-pan.js +102 -0
  24. package/dist/shortcuts/bindings.d.ts +44 -0
  25. package/dist/shortcuts/bindings.js +71 -0
  26. package/dist/shortcuts/capture.d.ts +7 -0
  27. package/dist/shortcuts/capture.js +92 -0
  28. package/dist/shortcuts/guard.d.ts +9 -0
  29. package/dist/shortcuts/guard.js +48 -0
  30. package/dist/shortcuts/help.d.ts +25 -0
  31. package/dist/shortcuts/help.js +26 -0
  32. package/dist/shortcuts/hints.d.ts +19 -0
  33. package/dist/shortcuts/hints.js +33 -0
  34. package/dist/shortcuts/index.d.ts +11 -0
  35. package/dist/shortcuts/index.js +11 -0
  36. package/dist/shortcuts/judge.d.ts +42 -0
  37. package/dist/shortcuts/judge.js +34 -0
  38. package/dist/shortcuts/keys.d.ts +11 -0
  39. package/dist/shortcuts/keys.js +89 -0
  40. package/dist/shortcuts/list.d.ts +16 -0
  41. package/dist/shortcuts/list.js +43 -0
  42. package/dist/shortcuts/notes.d.ts +28 -0
  43. package/dist/shortcuts/notes.js +27 -0
  44. package/dist/shortcuts/provider.d.ts +98 -0
  45. package/dist/shortcuts/provider.js +116 -0
  46. package/dist/shortcuts/rebinder.d.ts +23 -0
  47. package/dist/shortcuts/rebinder.js +84 -0
  48. package/dist/shortcuts/registration.d.ts +19 -0
  49. package/dist/shortcuts/registration.js +84 -0
  50. package/dist/shortcuts/shortcuts.css +171 -0
  51. package/dist/stored/index.d.ts +4 -0
  52. package/dist/stored/index.js +4 -0
  53. package/dist/stored/storage.d.ts +22 -0
  54. package/dist/stored/storage.js +10 -0
  55. package/dist/stored/stored.d.ts +93 -0
  56. package/dist/stored/stored.js +209 -0
  57. package/dist/stored/use-stored.d.ts +6 -0
  58. package/dist/stored/use-stored.js +12 -0
  59. package/dist/stored/validators.d.ts +6 -0
  60. package/dist/stored/validators.js +13 -0
  61. package/dist/titlebar/index.d.ts +2 -0
  62. package/dist/titlebar/index.js +2 -0
  63. package/dist/titlebar/titlebar-looks.d.ts +53 -0
  64. package/dist/titlebar/titlebar-looks.js +26 -0
  65. package/dist/titlebar/titlebar.css +561 -0
  66. package/dist/titlebar/titlebar.d.ts +54 -0
  67. package/dist/titlebar/titlebar.js +68 -0
  68. package/dist/undo/history.d.ts +62 -0
  69. package/dist/undo/history.js +151 -0
  70. package/dist/undo/index.d.ts +10 -0
  71. package/dist/undo/index.js +10 -0
  72. package/dist/undo/undo-adapter.d.ts +35 -0
  73. package/dist/undo/undo-adapter.js +35 -0
  74. package/dist/undo/undo-feedback.d.ts +28 -0
  75. package/dist/undo/undo-feedback.js +69 -0
  76. package/dist/undo/undo-keys.d.ts +32 -0
  77. package/dist/undo/undo-keys.js +76 -0
  78. package/dist/undo/undo-options.d.ts +51 -0
  79. package/dist/undo/undo-options.js +6 -0
  80. package/dist/undo/undo-panel.d.ts +23 -0
  81. package/dist/undo/undo-panel.js +56 -0
  82. package/dist/undo/undo-provider.d.ts +88 -0
  83. package/dist/undo/undo-provider.js +104 -0
  84. package/dist/undo/undo-reveal.d.ts +9 -0
  85. package/dist/undo/undo-reveal.js +45 -0
  86. package/dist/undo/undo-store.d.ts +89 -0
  87. package/dist/undo/undo-store.js +243 -0
  88. package/dist/undo/undo.css +135 -0
  89. package/dist/undo/use-undo-value.d.ts +43 -0
  90. package/dist/undo/use-undo-value.js +85 -0
  91. package/package.json +42 -1
@@ -0,0 +1,561 @@
1
+ @import "../motion/motion.css";
2
+
3
+ @layer kumiko {
4
+ :where(:root) {
5
+ --kumiko-touch-target: 2.75rem;
6
+ --kumiko-titlebar-height: 44px;
7
+ --kumiko-titlebar-height-compact: 36px;
8
+ --kumiko-titlebar-height-regular: 44px;
9
+ --kumiko-titlebar-height-tall: 52px;
10
+ --kumiko-titlebar-edge: 1px;
11
+ --kumiko-titlebar-bg: Canvas;
12
+ --kumiko-titlebar-fg: CanvasText;
13
+ --kumiko-titlebar-edge-color: color-mix(in oklab, CanvasText 18%, transparent);
14
+ --kumiko-titlebar-edge-shadow: 0 2px 8px -2px
15
+ color-mix(in oklab, CanvasText 28%, transparent);
16
+ --kumiko-titlebar-padding-start: 14px;
17
+ --kumiko-titlebar-padding-end: 8px;
18
+ --kumiko-titlebar-gap: 10px;
19
+ --kumiko-titlebar-name-size: 1.125rem;
20
+ --kumiko-titlebar-name-weight: 600;
21
+ --kumiko-titlebar-mark-size: 24px;
22
+ --kumiko-titlebar-divider-color: color-mix(in oklab, CanvasText 22%, transparent);
23
+ --kumiko-titlebar-inactive-opacity: 0.5;
24
+ --kumiko-titlebar-controls-width: 138px;
25
+ --kumiko-titlebar-controls-mac-width: 78px;
26
+ --kumiko-titlebar-button-size: 32px;
27
+ --kumiko-titlebar-button-icon-size: 17px;
28
+ --kumiko-titlebar-button-fg: color-mix(in oklab, CanvasText 62%, transparent);
29
+ --kumiko-titlebar-button-hover-fg: CanvasText;
30
+ --kumiko-titlebar-button-hover-bg: color-mix(in oklab, CanvasText 10%, transparent);
31
+ --kumiko-titlebar-button-radius: 999px;
32
+ --kumiko-titlebar-button-square-radius: 9px;
33
+ --kumiko-titlebar-button-focus-ring: Highlight;
34
+ --kumiko-titlebar-button-disabled-opacity: 0.45;
35
+ --kumiko-titlebar-tilt: -8deg;
36
+ --kumiko-titlebar-spin: 30deg;
37
+ --kumiko-titlebar-win-button-width: 46px;
38
+ --kumiko-titlebar-win-hover-bg: color-mix(in oklab, CanvasText 10%, transparent);
39
+ --kumiko-titlebar-win-close-bg: #c42b1c;
40
+ --kumiko-titlebar-win-close-fg: #fff;
41
+ --kumiko-titlebar-dot-size: 12px;
42
+ --kumiko-titlebar-dot-gap: 8px;
43
+ --kumiko-titlebar-dot-close: #ff5f57;
44
+ --kumiko-titlebar-dot-min: #febc2e;
45
+ --kumiko-titlebar-dot-max: #28c840;
46
+ }
47
+
48
+ /*
49
+ * Every word sets a private custom property on the element that carries it.
50
+ * The bar and its parts read them with the default as the fallback, so the nearest word wins.
51
+ * A container's words reach every bar inside, and a word for the default value opts out of another container's word.
52
+ */
53
+ :where([data-kumiko-titlebar~="height-compact"]) {
54
+ --kumiko-titlebar-height: var(--kumiko-titlebar-height-compact);
55
+ }
56
+
57
+ :where([data-kumiko-titlebar~="height-regular"]) {
58
+ --kumiko-titlebar-height: var(--kumiko-titlebar-height-regular);
59
+ }
60
+
61
+ :where([data-kumiko-titlebar~="height-tall"]) {
62
+ --kumiko-titlebar-height: var(--kumiko-titlebar-height-tall);
63
+ }
64
+
65
+ :where([data-kumiko-titlebar~="edge-line"]) {
66
+ --_edge-color: var(--kumiko-titlebar-edge-color);
67
+ --_edge-shadow: none;
68
+ }
69
+
70
+ :where([data-kumiko-titlebar~="edge-shadow"]) {
71
+ --_edge-color: transparent;
72
+ --_edge-shadow: var(--kumiko-titlebar-edge-shadow);
73
+ }
74
+
75
+ :where([data-kumiko-titlebar~="edge-none"]) {
76
+ --_edge-color: transparent;
77
+ --_edge-shadow: none;
78
+ }
79
+
80
+ :where([data-kumiko-titlebar~="layout-start"]) {
81
+ --_name-position: static;
82
+ --_name-inline: auto;
83
+ --_name-max: none;
84
+ --_name-margin: 0;
85
+ --_name-line: normal;
86
+ --_name-events: auto;
87
+ }
88
+
89
+ :where([data-kumiko-titlebar~="layout-center"]) {
90
+ --_name-position: initial;
91
+ --_name-inline: initial;
92
+ --_name-max: initial;
93
+ --_name-margin: initial;
94
+ --_name-line: initial;
95
+ --_name-events: initial;
96
+ }
97
+
98
+ :where([data-kumiko-titlebar~="divider-diamond"]) {
99
+ --_divider-display: block;
100
+ --_divider-width: 5px;
101
+ --_divider-height: 5px;
102
+ --_divider-radius: 2px;
103
+ --_divider-transform: rotate(-9deg);
104
+ }
105
+
106
+ :where([data-kumiko-titlebar~="divider-line"]) {
107
+ --_divider-display: block;
108
+ --_divider-width: 1px;
109
+ --_divider-height: 55%;
110
+ --_divider-radius: 0;
111
+ --_divider-transform: none;
112
+ }
113
+
114
+ :where([data-kumiko-titlebar~="divider-none"]) {
115
+ --_divider-display: none;
116
+ }
117
+
118
+ :where([data-kumiko-titlebar~="dim-inactive"]) {
119
+ --_dim: var(--kumiko-titlebar-inactive-opacity);
120
+ }
121
+
122
+ :where([data-kumiko-titlebar~="no-dim-inactive"]) {
123
+ --_dim: 1;
124
+ }
125
+
126
+ :where([data-kumiko-titlebar~="look-round"], [data-kumiko-titlebar-button][data-look="round"]) {
127
+ --_radius: var(--kumiko-titlebar-button-radius);
128
+ --_hover-bg: var(--kumiko-titlebar-button-hover-bg);
129
+ }
130
+
131
+ :where(
132
+ [data-kumiko-titlebar~="look-square"],
133
+ [data-kumiko-titlebar-button][data-look="square"]
134
+ ) {
135
+ --_radius: var(--kumiko-titlebar-button-square-radius);
136
+ --_hover-bg: var(--kumiko-titlebar-button-hover-bg);
137
+ }
138
+
139
+ :where([data-kumiko-titlebar~="look-ghost"], [data-kumiko-titlebar-button][data-look="ghost"]) {
140
+ --_radius: var(--kumiko-titlebar-button-radius);
141
+ --_hover-bg: transparent;
142
+ }
143
+
144
+ /* The tilt is opt-in: its default is the shared hover-tilt token, which is none. */
145
+ :where([data-kumiko-titlebar~="tilt"], [data-kumiko-titlebar-button][data-tilt="on"]) {
146
+ --_tilt: var(--kumiko-titlebar-tilt);
147
+ --_spin: var(--kumiko-titlebar-spin);
148
+ }
149
+
150
+ :where([data-kumiko-titlebar~="no-tilt"], [data-kumiko-titlebar-button][data-tilt="off"]) {
151
+ --_tilt: var(--kumiko-hover-tilt);
152
+ --_spin: var(--kumiko-hover-tilt);
153
+ }
154
+
155
+ [data-slot="titlebar"] {
156
+ --_height: var(--kumiko-titlebar-height);
157
+
158
+ position: relative;
159
+ z-index: 20;
160
+ display: flex;
161
+ box-sizing: border-box;
162
+ flex-shrink: 0;
163
+ gap: var(--kumiko-titlebar-gap);
164
+ align-items: center;
165
+ block-size: var(--_height);
166
+ padding-inline: var(--kumiko-titlebar-padding-start) var(--kumiko-titlebar-padding-end);
167
+ background: var(--kumiko-titlebar-bg);
168
+ color: var(--kumiko-titlebar-fg);
169
+
170
+ /* The edge keeps its room whatever it looks like, so the height Electron is told never moves. */
171
+ border-block-end: var(--kumiko-titlebar-edge) solid var(--_edge-color, transparent);
172
+ box-shadow: var(--_edge-shadow, var(--kumiko-titlebar-edge-shadow));
173
+ -webkit-app-region: drag;
174
+ app-region: drag;
175
+ user-select: none;
176
+ }
177
+
178
+ /*
179
+ * No drag for anything a person can use, and for every popup.
180
+ * Kumiko draws menus, popovers, selects, tooltips, hover cards, dialogs and toasts inline, as children of their trigger.
181
+ * Inside a drag bar they would inherit the drag, and Windows would hit-test the whole window as a caption.
182
+ * The popup roots, and everything inside them, are listed by their data-slot.
183
+ * The native ones are listed by [popover] and dialog.
184
+ */
185
+ :where(
186
+ a,
187
+ button,
188
+ input,
189
+ textarea,
190
+ select,
191
+ label,
192
+ summary,
193
+ [role="button"],
194
+ [role="link"],
195
+ [role="menuitem"],
196
+ [role="option"],
197
+ [role="combobox"],
198
+ [role="switch"],
199
+ [role="checkbox"],
200
+ [role="slider"],
201
+ [tabindex],
202
+ [contenteditable],
203
+ [data-slot$="-trigger"],
204
+ [role="menu"],
205
+ [role="listbox"],
206
+ [role="dialog"],
207
+ [role="alertdialog"],
208
+ [role="tooltip"],
209
+ [popover],
210
+ dialog,
211
+ [data-slot$="-content"],
212
+ [data-slot^="toast"],
213
+ [data-kumiko-titlebar~="no-drag"]
214
+ ),
215
+ :where(
216
+ [popover],
217
+ dialog,
218
+ [data-slot$="-content"],
219
+ [data-slot^="toast"],
220
+ [data-kumiko-titlebar~="no-drag"]
221
+ )
222
+ * {
223
+ -webkit-app-region: no-drag;
224
+ app-region: no-drag;
225
+ }
226
+
227
+ /* The opt-in outranks the no-drag above, which has no specificity. */
228
+ [data-slot="titlebar"] [data-kumiko-titlebar~="drag"] {
229
+ -webkit-app-region: drag;
230
+ app-region: drag;
231
+ }
232
+
233
+ [data-slot="titlebar-brand"] {
234
+ display: flex;
235
+ min-inline-size: 0;
236
+ gap: var(--kumiko-titlebar-gap);
237
+ align-items: center;
238
+ }
239
+
240
+ [data-slot="titlebar-mark"] {
241
+ display: block;
242
+ flex-shrink: 0;
243
+ inline-size: var(--kumiko-titlebar-mark-size);
244
+ block-size: var(--kumiko-titlebar-mark-size);
245
+ }
246
+
247
+ [data-slot="titlebar-mark"] > * {
248
+ display: block;
249
+ inline-size: 100%;
250
+ block-size: 100%;
251
+ }
252
+
253
+ /* The name sits in the middle of the whole bar unless a layout-start word brings it back next to the mark. */
254
+ [data-slot="titlebar-name"] {
255
+ position: var(--_name-position, absolute);
256
+ inset-inline: 0;
257
+ inset-block: 0;
258
+ box-sizing: border-box;
259
+ overflow: hidden;
260
+ inline-size: var(--_name-inline, max-content);
261
+ max-inline-size: var(--_name-max, 50%);
262
+ margin-inline: var(--_name-margin, auto);
263
+ font-size: var(--kumiko-titlebar-name-size);
264
+ font-weight: var(--kumiko-titlebar-name-weight);
265
+ line-height: var(
266
+ --_name-line,
267
+ calc(var(--kumiko-titlebar-height) - var(--kumiko-titlebar-edge))
268
+ );
269
+ pointer-events: var(--_name-events, none);
270
+ text-overflow: ellipsis;
271
+ white-space: nowrap;
272
+ }
273
+
274
+ [data-slot="titlebar-divider"] {
275
+ display: var(--_divider-display, block);
276
+ flex-shrink: 0;
277
+ inline-size: var(--_divider-width, 5px);
278
+ block-size: var(--_divider-height, 5px);
279
+ border-radius: var(--_divider-radius, 2px);
280
+ background: var(--kumiko-titlebar-divider-color);
281
+ transform: var(--_divider-transform, rotate(-9deg));
282
+ }
283
+
284
+ [data-slot="titlebar-middle"] {
285
+ display: flex;
286
+ min-inline-size: 0;
287
+ gap: var(--kumiko-titlebar-gap);
288
+ align-items: center;
289
+ }
290
+
291
+ [data-slot="titlebar-end"] {
292
+ display: flex;
293
+ gap: 8px;
294
+ align-items: center;
295
+ margin-inline-start: auto;
296
+ }
297
+
298
+ /* A window that lost focus fades the bar's contents, not its background. */
299
+ [data-slot="titlebar"] > * {
300
+ transition: opacity var(--kumiko-fade-duration) var(--kumiko-fade-ease);
301
+ }
302
+
303
+ [data-slot="titlebar"][data-inactive] > * {
304
+ opacity: var(--_dim, var(--kumiko-titlebar-inactive-opacity));
305
+ }
306
+
307
+ /*
308
+ * Native controls: empty room for what the OS draws.
309
+ * The browser's own numbers win when it gives them (Electron's titleBarOverlay does), and the token is the fallback.
310
+ * The room on the right is what is left of the window after the area the app owns, and on the left it is where that area starts.
311
+ * The end side is the right in left-to-right text and the left in right-to-left text, and the start side is the other way round.
312
+ */
313
+ [data-slot="titlebar-controls"][data-kind="native"] {
314
+ --_right: calc(
315
+ 100vw - env(titlebar-area-x, 0px) -
316
+ env(titlebar-area-width, calc(100vw - var(--_fallback)))
317
+ );
318
+ --_left: env(titlebar-area-x, var(--_fallback));
319
+
320
+ flex-shrink: 0;
321
+ inline-size: var(--_right);
322
+ block-size: 100%;
323
+ }
324
+
325
+ [data-slot="titlebar-controls"][data-kind="native"][data-side="end"] {
326
+ --_fallback: var(--kumiko-titlebar-controls-width);
327
+ }
328
+
329
+ [data-slot="titlebar-controls"][data-kind="native"][data-side="start"] {
330
+ --_fallback: var(--kumiko-titlebar-controls-mac-width);
331
+ }
332
+
333
+ [data-slot="titlebar-controls"][data-kind="native"][data-side="end"]:dir(rtl),
334
+ [data-slot="titlebar-controls"][data-kind="native"][data-side="start"]:dir(ltr) {
335
+ inline-size: var(--_left);
336
+ }
337
+
338
+ /* The reserved room runs to the window's own edge, past the bar's padding. */
339
+ [data-slot="titlebar-controls"][data-side="end"] {
340
+ margin-inline-end: calc(var(--kumiko-titlebar-padding-end) * -1);
341
+ }
342
+
343
+ [data-slot="titlebar-controls"][data-side="start"] {
344
+ margin-inline-start: calc(var(--kumiko-titlebar-padding-start) * -1);
345
+ }
346
+
347
+ [data-slot="titlebar-controls"][data-kind="windows"] {
348
+ display: flex;
349
+ align-self: stretch;
350
+ align-items: stretch;
351
+ }
352
+
353
+ [data-slot="titlebar-controls"][data-kind="windows"] > button {
354
+ display: grid;
355
+ place-items: center;
356
+ inline-size: var(--kumiko-titlebar-win-button-width);
357
+ padding: 0;
358
+ border: 0;
359
+ background: transparent;
360
+ color: inherit;
361
+ cursor: var(--kumiko-press-cursor, pointer);
362
+ }
363
+
364
+ [data-slot="titlebar-controls"][data-kind="windows"] svg {
365
+ inline-size: 10px;
366
+ block-size: 10px;
367
+ }
368
+
369
+ [data-slot="titlebar-controls"][data-kind="windows"] > button:focus-visible {
370
+ outline: 2px solid var(--kumiko-titlebar-button-focus-ring);
371
+ outline-offset: -2px;
372
+ }
373
+
374
+ [data-slot="titlebar-controls"][data-kind="mac"] {
375
+ display: flex;
376
+ gap: var(--kumiko-titlebar-dot-gap);
377
+ align-items: center;
378
+ padding-inline: var(--kumiko-titlebar-padding-start) var(--kumiko-titlebar-dot-gap);
379
+ margin-inline-end: calc(var(--kumiko-titlebar-gap) * -0.5);
380
+ }
381
+
382
+ [data-slot="titlebar-controls"][data-kind="mac"][data-side="end"] {
383
+ padding-inline: var(--kumiko-titlebar-dot-gap) var(--kumiko-titlebar-padding-end);
384
+ margin-inline-end: calc(var(--kumiko-titlebar-padding-end) * -1);
385
+ }
386
+
387
+ [data-slot="titlebar-controls"][data-kind="mac"] > button {
388
+ position: relative;
389
+ inline-size: var(--kumiko-titlebar-dot-size);
390
+ block-size: var(--kumiko-titlebar-dot-size);
391
+ padding: 0;
392
+ border: 0;
393
+ border-radius: 50%;
394
+ cursor: var(--kumiko-press-cursor, pointer);
395
+ }
396
+
397
+ [data-dot="close"] {
398
+ background: var(--kumiko-titlebar-dot-close);
399
+ }
400
+
401
+ [data-dot="min"] {
402
+ background: var(--kumiko-titlebar-dot-min);
403
+ }
404
+
405
+ [data-dot="max"] {
406
+ background: var(--kumiko-titlebar-dot-max);
407
+ }
408
+
409
+ [data-slot="titlebar-controls"][data-kind="mac"] > button:focus-visible {
410
+ outline: 2px solid var(--kumiko-titlebar-button-focus-ring);
411
+ outline-offset: 2px;
412
+ }
413
+
414
+ @media (hover: hover) and (pointer: fine) {
415
+ [data-slot="titlebar-controls"][data-kind="windows"] > button:hover {
416
+ background: var(--kumiko-titlebar-win-hover-bg);
417
+ }
418
+
419
+ [data-slot="titlebar-controls"][data-kind="windows"] > button[data-close]:hover {
420
+ background: var(--kumiko-titlebar-win-close-bg);
421
+ color: var(--kumiko-titlebar-win-close-fg);
422
+ }
423
+
424
+ [data-slot="titlebar-controls"][data-kind="mac"] > button:hover {
425
+ filter: brightness(0.85);
426
+ }
427
+ }
428
+
429
+ /* The tool button. */
430
+ [data-kumiko-titlebar-button] {
431
+ position: relative;
432
+ display: grid;
433
+ flex-shrink: 0;
434
+ place-items: center;
435
+ inline-size: var(--kumiko-titlebar-button-size);
436
+ block-size: var(--kumiko-titlebar-button-size);
437
+ padding: 0;
438
+ border: 0;
439
+ border-radius: var(--_radius, var(--kumiko-titlebar-button-square-radius));
440
+ background: transparent;
441
+ color: var(--kumiko-titlebar-button-fg);
442
+ cursor: var(--kumiko-press-cursor, pointer);
443
+ transition-property: background-color, color, scale;
444
+ transition-duration:
445
+ var(--kumiko-fade-duration), var(--kumiko-fade-duration), var(--kumiko-move-duration);
446
+ transition-timing-function:
447
+ var(--kumiko-fade-ease), var(--kumiko-fade-ease), var(--kumiko-move-ease);
448
+ }
449
+
450
+ [data-kumiko-titlebar-button] > svg {
451
+ inline-size: var(--kumiko-titlebar-button-icon-size);
452
+ block-size: var(--kumiko-titlebar-button-icon-size);
453
+ transition: rotate var(--kumiko-move-duration) var(--kumiko-move-ease);
454
+ }
455
+
456
+ [data-kumiko-titlebar-button]:focus-visible {
457
+ outline: 2px solid var(--kumiko-titlebar-button-focus-ring);
458
+ outline-offset: 2px;
459
+ }
460
+
461
+ [data-kumiko-titlebar-button][data-state="open"],
462
+ [data-kumiko-titlebar-button][aria-expanded="true"],
463
+ [data-kumiko-titlebar-button][aria-current="page"] {
464
+ background: var(--_hover-bg, var(--kumiko-titlebar-button-hover-bg));
465
+ color: var(--kumiko-titlebar-button-hover-fg);
466
+ }
467
+
468
+ [data-kumiko-titlebar-button]:active:not(:disabled) {
469
+ scale: var(--kumiko-press-scale);
470
+ transition-duration: var(--kumiko-press-duration);
471
+ transition-timing-function: var(--kumiko-press-ease);
472
+ }
473
+
474
+ [data-kumiko-titlebar-button]:disabled {
475
+ opacity: var(--kumiko-titlebar-button-disabled-opacity);
476
+ cursor: not-allowed;
477
+ }
478
+
479
+ @media (hover: hover) and (pointer: fine) {
480
+ [data-kumiko-titlebar-button]:hover:not(:disabled) {
481
+ background: var(--_hover-bg, var(--kumiko-titlebar-button-hover-bg));
482
+ color: var(--kumiko-titlebar-button-hover-fg);
483
+ scale: var(--kumiko-hover-scale);
484
+ }
485
+
486
+ [data-kumiko-titlebar-button]:hover:not(:disabled) > svg {
487
+ rotate: var(--_tilt, var(--kumiko-hover-tilt));
488
+ }
489
+
490
+ [data-kumiko-titlebar-button]:hover:not(:disabled) > svg[data-spin] {
491
+ rotate: var(--_spin, var(--_tilt, var(--kumiko-hover-tilt)));
492
+ }
493
+ }
494
+
495
+ /* On a finger, an invisible area around the button reaches the touch target. */
496
+ @media (pointer: coarse) {
497
+ [data-kumiko-titlebar-button]::after {
498
+ content: "";
499
+ position: absolute;
500
+ inset-block-start: 50%;
501
+ inset-inline-start: 50%;
502
+ inline-size: max(100%, var(--kumiko-touch-target));
503
+ block-size: max(100%, var(--kumiko-touch-target));
504
+ translate: -50% -50%;
505
+ }
506
+
507
+ [data-kumiko-titlebar-button]:dir(rtl)::after {
508
+ translate: 50% -50%;
509
+ }
510
+ }
511
+
512
+ @media (prefers-reduced-motion: reduce) {
513
+ [data-kumiko-titlebar-button],
514
+ [data-kumiko-titlebar-button] > svg {
515
+ transition-duration: 0.01ms;
516
+ }
517
+
518
+ [data-kumiko-titlebar-button]:hover,
519
+ [data-kumiko-titlebar-button]:hover > svg,
520
+ [data-kumiko-titlebar-button]:active {
521
+ rotate: none;
522
+ scale: none;
523
+ }
524
+ }
525
+
526
+ @media (forced-colors: active) {
527
+ [data-slot="titlebar"] {
528
+ border-block-end-color: CanvasText;
529
+ background: Canvas;
530
+ color: CanvasText;
531
+ }
532
+
533
+ [data-kumiko-titlebar-button] {
534
+ border: 1px solid transparent;
535
+ color: ButtonText;
536
+ }
537
+
538
+ [data-kumiko-titlebar-button]:hover:not(:disabled),
539
+ [data-kumiko-titlebar-button][aria-expanded="true"],
540
+ [data-kumiko-titlebar-button][aria-current="page"] {
541
+ border-color: Highlight;
542
+ background: Canvas;
543
+ color: Highlight;
544
+ }
545
+
546
+ [data-kumiko-titlebar-button]:disabled {
547
+ color: GrayText;
548
+ }
549
+
550
+ [data-slot="titlebar-divider"] {
551
+ background: CanvasText;
552
+ }
553
+
554
+ [data-slot="titlebar-controls"] > button {
555
+ border: 1px solid ButtonText;
556
+ color: ButtonText;
557
+ forced-color-adjust: none;
558
+ background: ButtonFace;
559
+ }
560
+ }
561
+ }
@@ -0,0 +1,54 @@
1
+ import { type TitlebarButtonLook, type TitlebarLooks } from "./titlebar-looks";
2
+ /** Who draws the window controls: the OS over reserved space, Kumiko in Windows style, Kumiko as macOS dots, or nobody. */
3
+ export type WindowControls = "native" | "windows" | "mac" | "none";
4
+ /** Whether this window has focus. Needs no Electron: the page's own focus and blur say it. */
5
+ export declare function useWindowActive(): boolean;
6
+ export interface TitlebarButtonProps extends React.ComponentProps<"button"> {
7
+ /** Overrides the bar's `look-*` word for this button. */
8
+ look?: TitlebarButtonLook;
9
+ /** Overrides the bar's `tilt` word for this button. */
10
+ tilt?: boolean;
11
+ }
12
+ /** A round 32px tool button for the bar's end. It carries no drag: buttons never do. */
13
+ export declare function TitlebarButton({ look, tilt, type, ...props }: TitlebarButtonProps): React.JSX.Element;
14
+ export interface WindowControlsProps {
15
+ /** @defaultValue "native" */
16
+ controls?: WindowControls;
17
+ /**
18
+ * Which end the controls sit at. Native macOS traffic lights are at the start.
19
+ * @defaultValue "end", or "start" for `mac`
20
+ */
21
+ side?: "start" | "end";
22
+ /** Whether the window is maximised: swaps the maximise button's icon. */
23
+ maximized?: boolean;
24
+ onMinimize?: () => void;
25
+ onToggleMaximize?: () => void;
26
+ onClose?: () => void;
27
+ }
28
+ /**
29
+ * The window-control area. `native` is empty space the OS draws over (Electron's `titleBarOverlay`, or the
30
+ * traffic lights); `windows` and `mac` are drawn here and call your handlers, so the app must wire them to
31
+ * its window. Drawn controls lose Windows 11's snap layouts on the maximise button.
32
+ */
33
+ export declare function TitlebarWindowControls({ controls, side, ...drawn }: WindowControlsProps): React.JSX.Element | null;
34
+ export type TitlebarProps = Omit<React.ComponentProps<"header">, "title"> & TitlebarLooks & WindowControlsProps & {
35
+ /** The brand's mark, at the start. */
36
+ mark?: React.ReactNode;
37
+ /** The brand's name; centred with `layout="center"`. */
38
+ name?: React.ReactNode;
39
+ /** Tool buttons and anything else at the end, before the window controls. */
40
+ end?: React.ReactNode;
41
+ /**
42
+ * Forces the active state, for an app that knows its window's focus better than the page does. Left out,
43
+ * the page's focus and blur decide.
44
+ */
45
+ active?: boolean;
46
+ /** The middle section, after a divider. Anything interactive in it is never a drag handle. */
47
+ children?: React.ReactNode;
48
+ };
49
+ /**
50
+ * The app's title bar. Its empty space drags the window (`-webkit-app-region: drag`); everything interactive in it,
51
+ * and every popup opened from it, does not. A custom child opts out with `data-kumiko-titlebar="no-drag"`, or in
52
+ * with `data-kumiko-titlebar="drag"`.
53
+ */
54
+ export declare function Titlebar({ layout, height, edge, look, tilt, divider, dimInactive, controls, side, maximized, onMinimize, onToggleMaximize, onClose, mark, name, end, active, children, ...props }: TitlebarProps): React.JSX.Element;
@@ -0,0 +1,68 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useSyncExternalStore } from "react";
3
+ import { tiltAttribute, titlebarWords } from "./titlebar-looks";
4
+ function subscribeFocus(onChange) {
5
+ window.addEventListener("focus", onChange);
6
+ window.addEventListener("blur", onChange);
7
+ return () => {
8
+ window.removeEventListener("focus", onChange);
9
+ window.removeEventListener("blur", onChange);
10
+ };
11
+ }
12
+ /** Whether this window has focus. Needs no Electron: the page's own focus and blur say it. */
13
+ export function useWindowActive() {
14
+ return useSyncExternalStore(subscribeFocus, () => document.hasFocus(), () => true);
15
+ }
16
+ function flag(on) {
17
+ return on ? "" : undefined;
18
+ }
19
+ /** A round 32px tool button for the bar's end. It carries no drag: buttons never do. */
20
+ export function TitlebarButton({ look, tilt, type = "button", ...props }) {
21
+ return (_jsx("button", { type: type, "data-slot": "titlebar-button", "data-kumiko-titlebar-button": "", "data-look": look, "data-tilt": tiltAttribute(tilt), ...props }));
22
+ }
23
+ function WindowsGlyph({ glyph }) {
24
+ return (_jsxs("svg", { viewBox: "0 0 10 10", fill: "none", stroke: "currentColor", strokeWidth: 1, "aria-hidden": true, children: [glyph === "min" ? _jsx("path", { d: "M0 5.5h10" }) : null, glyph === "max" ? _jsx("rect", { x: "0.5", y: "0.5", width: "9", height: "9" }) : null, glyph === "restore" ? _jsx("path", { d: "M2.5 2.5V0.5h7v7h-2M0.5 2.5h7v7h-7z" }) : null, glyph === "close" ? _jsx("path", { d: "M0 0l10 10M10 0L0 10" }) : null] }));
25
+ }
26
+ function WindowsControls({ side, maximized, onMinimize, onToggleMaximize, onClose }) {
27
+ return (_jsxs("div", { role: "group", "aria-label": "Window controls", "data-slot": "titlebar-controls", "data-kind": "windows", "data-side": side, children: [_jsx("button", { type: "button", "aria-label": "Minimize", onClick: onMinimize, children: _jsx(WindowsGlyph, { glyph: "min" }) }), _jsx("button", { type: "button", "aria-label": maximized ? "Restore" : "Maximize", onClick: onToggleMaximize, children: _jsx(WindowsGlyph, { glyph: maximized ? "restore" : "max" }) }), _jsx("button", { type: "button", "aria-label": "Close", "data-close": "", onClick: onClose, children: _jsx(WindowsGlyph, { glyph: "close" }) })] }));
28
+ }
29
+ function MacControls({ side, maximized, onMinimize, onToggleMaximize, onClose }) {
30
+ return (_jsxs("div", { role: "group", "aria-label": "Window controls", "data-slot": "titlebar-controls", "data-kind": "mac", "data-side": side, children: [_jsx("button", { type: "button", "aria-label": "Close", "data-dot": "close", onClick: onClose }), _jsx("button", { type: "button", "aria-label": "Minimize", "data-dot": "min", onClick: onMinimize }), _jsx("button", { type: "button", "aria-label": maximized ? "Restore" : "Maximize", "data-dot": "max", onClick: onToggleMaximize })] }));
31
+ }
32
+ /**
33
+ * The window-control area. `native` is empty space the OS draws over (Electron's `titleBarOverlay`, or the
34
+ * traffic lights); `windows` and `mac` are drawn here and call your handlers, so the app must wire them to
35
+ * its window. Drawn controls lose Windows 11's snap layouts on the maximise button.
36
+ */
37
+ export function TitlebarWindowControls({ controls = "native", side, ...drawn }) {
38
+ const placed = side ?? (controls === "mac" ? "start" : "end");
39
+ if (controls === "windows") {
40
+ return _jsx(WindowsControls, { side: placed, ...drawn });
41
+ }
42
+ if (controls === "mac") {
43
+ return _jsx(MacControls, { side: placed, ...drawn });
44
+ }
45
+ if (controls === "none") {
46
+ return null;
47
+ }
48
+ return _jsx("div", { "aria-hidden": true, "data-slot": "titlebar-controls", "data-kind": "native", "data-side": placed });
49
+ }
50
+ function Brand({ mark, name }) {
51
+ return (_jsxs("div", { "data-slot": "titlebar-brand", children: [mark ? _jsx("span", { "data-slot": "titlebar-mark", children: mark }) : null, name ? _jsx("span", { "data-slot": "titlebar-name", children: name }) : null] }));
52
+ }
53
+ function Middle({ children }) {
54
+ return children ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, "data-slot": "titlebar-divider" }), _jsx("div", { "data-slot": "titlebar-middle", children: children })] })) : null;
55
+ }
56
+ /**
57
+ * The app's title bar. Its empty space drags the window (`-webkit-app-region: drag`); everything interactive in it,
58
+ * and every popup opened from it, does not. A custom child opts out with `data-kumiko-titlebar="no-drag"`, or in
59
+ * with `data-kumiko-titlebar="drag"`.
60
+ */
61
+ export function Titlebar({ layout, height, edge, look, tilt, divider, dimInactive, controls = "native", side, maximized, onMinimize, onToggleMaximize, onClose, mark, name, end, active, children, ...props }) {
62
+ const windowActive = useWindowActive();
63
+ const isActive = active ?? windowActive;
64
+ const placed = side ?? (controls === "mac" ? "start" : "end");
65
+ const words = titlebarWords({ layout, height, edge, look, tilt, divider, dimInactive });
66
+ const area = (_jsx(TitlebarWindowControls, { controls: controls, side: placed, maximized: maximized, onMinimize: onMinimize, onToggleMaximize: onToggleMaximize, onClose: onClose }));
67
+ return (_jsxs("header", { "data-slot": "titlebar", "data-kumiko-titlebar": words, "data-inactive": flag(!isActive), ...props, children: [placed === "start" ? area : null, _jsx(Brand, { mark: mark, name: name }), _jsx(Middle, { children: children }), _jsx("div", { "data-slot": "titlebar-end", children: end }), placed === "end" ? area : null] }));
68
+ }