@alulore/kumiko 0.0.0-stage → 0.14.2

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 (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -2
  3. package/dist/badge/badge.css +287 -0
  4. package/dist/badge/badge.d.ts +40 -0
  5. package/dist/badge/badge.js +51 -0
  6. package/dist/badge/index.d.ts +1 -0
  7. package/dist/badge/index.js +1 -0
  8. package/dist/board/board-api.d.ts +147 -0
  9. package/dist/board/board-api.js +139 -0
  10. package/dist/board/board-card-menu.d.ts +17 -0
  11. package/dist/board/board-card-menu.js +53 -0
  12. package/dist/board/board-drag-events.d.ts +12 -0
  13. package/dist/board/board-drag-events.js +86 -0
  14. package/dist/board/board-fold.d.ts +10 -0
  15. package/dist/board/board-fold.js +30 -0
  16. package/dist/board/board-group.d.ts +10 -0
  17. package/dist/board/board-group.js +28 -0
  18. package/dist/board/board-keys.d.ts +16 -0
  19. package/dist/board/board-keys.js +65 -0
  20. package/dist/board/board-locked-rows.d.ts +23 -0
  21. package/dist/board/board-locked-rows.js +77 -0
  22. package/dist/board/board-motion.d.ts +7 -0
  23. package/dist/board/board-motion.js +102 -0
  24. package/dist/board/board-primitive.d.ts +53 -0
  25. package/dist/board/board-primitive.js +66 -0
  26. package/dist/board/board-pull.d.ts +6 -0
  27. package/dist/board/board-pull.js +94 -0
  28. package/dist/board/board-selection.d.ts +42 -0
  29. package/dist/board/board-selection.js +130 -0
  30. package/dist/board/board-slots.d.ts +1003 -0
  31. package/dist/board/board-slots.js +250 -0
  32. package/dist/board/board-types.d.ts +99 -0
  33. package/dist/board/board-types.js +1 -0
  34. package/dist/board/board.css +343 -0
  35. package/dist/board/board.d.ts +290 -0
  36. package/dist/board/board.js +23 -0
  37. package/dist/board/card-menu.d.ts +21 -0
  38. package/dist/board/card-menu.js +79 -0
  39. package/dist/board/cell-key.d.ts +6 -0
  40. package/dist/board/cell-key.js +16 -0
  41. package/dist/board/index.d.ts +6 -0
  42. package/dist/board/index.js +5 -0
  43. package/dist/board/interactive.d.ts +18 -0
  44. package/dist/board/interactive.js +51 -0
  45. package/dist/board/keep-capture.d.ts +16 -0
  46. package/dist/board/keep-capture.js +57 -0
  47. package/dist/board/landing.d.ts +5 -0
  48. package/dist/board/landing.js +10 -0
  49. package/dist/board/press-to-drop.d.ts +9 -0
  50. package/dist/board/press-to-drop.js +28 -0
  51. package/dist/board/refused-home.d.ts +16 -0
  52. package/dist/board/refused-home.js +50 -0
  53. package/dist/board/repeat-gate.d.ts +4 -0
  54. package/dist/board/repeat-gate.js +12 -0
  55. package/dist/board/scrollbar-gutter.d.ts +1 -0
  56. package/dist/board/scrollbar-gutter.js +27 -0
  57. package/dist/board/touch-hold.d.ts +19 -0
  58. package/dist/board/touch-hold.js +103 -0
  59. package/dist/button/button.css +576 -0
  60. package/dist/button/button.d.ts +50 -0
  61. package/dist/button/button.js +70 -0
  62. package/dist/button/index.d.ts +2 -0
  63. package/dist/button/index.js +1 -0
  64. package/dist/checkbox/checkbox-mark.d.ts +8 -0
  65. package/dist/checkbox/checkbox-mark.js +17 -0
  66. package/dist/checkbox/checkbox-marks.d.ts +33 -0
  67. package/dist/checkbox/checkbox-marks.js +30 -0
  68. package/dist/checkbox/checkbox.css +201 -0
  69. package/dist/checkbox/checkbox.d.ts +26 -0
  70. package/dist/checkbox/checkbox.js +11 -0
  71. package/dist/checkbox/index.d.ts +3 -0
  72. package/dist/checkbox/index.js +3 -0
  73. package/dist/chip/chip.css +251 -0
  74. package/dist/chip/chip.d.ts +39 -0
  75. package/dist/chip/chip.js +25 -0
  76. package/dist/chip/index.d.ts +1 -0
  77. package/dist/chip/index.js +1 -0
  78. package/dist/dialog/dialog.css +247 -0
  79. package/dist/dialog/index.d.ts +3 -0
  80. package/dist/dialog/index.js +3 -0
  81. package/dist/hover-card/hover-card.css +149 -0
  82. package/dist/hover-card/hover-card.d.ts +3 -0
  83. package/dist/hover-card/hover-card.js +8 -0
  84. package/dist/hover-card/index.d.ts +2 -0
  85. package/dist/hover-card/index.js +2 -0
  86. package/dist/input/index.d.ts +5 -0
  87. package/dist/input/index.js +5 -0
  88. package/dist/input/input-attributes.d.ts +12 -0
  89. package/dist/input/input-attributes.js +9 -0
  90. package/dist/input/input.css +752 -0
  91. package/dist/input/input.d.ts +28 -0
  92. package/dist/input/input.js +9 -0
  93. package/dist/input/search-input.d.ts +41 -0
  94. package/dist/input/search-input.js +47 -0
  95. package/dist/kbd/index.d.ts +1 -0
  96. package/dist/kbd/index.js +1 -0
  97. package/dist/kbd/kbd.css +77 -0
  98. package/dist/kbd/kbd.d.ts +21 -0
  99. package/dist/kbd/kbd.js +37 -0
  100. package/dist/label/index.d.ts +1 -0
  101. package/dist/label/index.js +1 -0
  102. package/dist/label/label.css +37 -0
  103. package/dist/label/label.d.ts +13 -0
  104. package/dist/label/label.js +10 -0
  105. package/dist/menu/index.d.ts +3 -0
  106. package/dist/menu/index.js +3 -0
  107. package/dist/menu/menu.css +349 -0
  108. package/dist/menu/menu.d.ts +11 -0
  109. package/dist/menu/menu.js +86 -0
  110. package/dist/menu/point-menu.d.ts +26 -0
  111. package/dist/menu/point-menu.js +51 -0
  112. package/dist/motion/flip-math.d.ts +19 -0
  113. package/dist/motion/flip-math.js +33 -0
  114. package/dist/motion/flip.d.ts +40 -0
  115. package/dist/motion/flip.js +203 -0
  116. package/dist/motion/index.d.ts +2 -0
  117. package/dist/motion/index.js +2 -0
  118. package/dist/motion/motion.css +169 -0
  119. package/dist/popover/index.d.ts +1 -0
  120. package/dist/popover/index.js +1 -0
  121. package/dist/popover/popover.css +208 -0
  122. package/dist/progress/index.d.ts +2 -0
  123. package/dist/progress/index.js +2 -0
  124. package/dist/progress/progress.css +390 -0
  125. package/dist/progress/progress.d.ts +36 -0
  126. package/dist/progress/progress.js +107 -0
  127. package/dist/select/index.d.ts +3 -0
  128. package/dist/select/index.js +2 -0
  129. package/dist/select/select-labels.d.ts +6 -0
  130. package/dist/select/select-labels.js +64 -0
  131. package/dist/select/select-search.d.ts +18 -0
  132. package/dist/select/select-search.js +10 -0
  133. package/dist/select/select.css +470 -0
  134. package/dist/select/select.d.ts +44 -0
  135. package/dist/select/select.js +92 -0
  136. package/dist/separator/index.d.ts +2 -0
  137. package/dist/separator/index.js +1 -0
  138. package/dist/separator/separator.css +32 -0
  139. package/dist/separator/separator.d.ts +17 -0
  140. package/dist/separator/separator.js +10 -0
  141. package/dist/slider/index.d.ts +2 -0
  142. package/dist/slider/index.js +2 -0
  143. package/dist/slider/slider-bubble.css +203 -0
  144. package/dist/slider/slider-feel.d.ts +33 -0
  145. package/dist/slider/slider-feel.js +153 -0
  146. package/dist/slider/slider-format.d.ts +13 -0
  147. package/dist/slider/slider-format.js +15 -0
  148. package/dist/slider/slider-marks.d.ts +16 -0
  149. package/dist/slider/slider-marks.js +32 -0
  150. package/dist/slider/slider.css +335 -0
  151. package/dist/slider/slider.d.ts +34 -0
  152. package/dist/slider/slider.js +94 -0
  153. package/dist/smooth-caret/caret-box.d.ts +7 -0
  154. package/dist/smooth-caret/caret-box.js +8 -0
  155. package/dist/smooth-caret/caret-controller.d.ts +7 -0
  156. package/dist/smooth-caret/caret-controller.js +222 -0
  157. package/dist/smooth-caret/caret-geometry.d.ts +11 -0
  158. package/dist/smooth-caret/caret-geometry.js +230 -0
  159. package/dist/smooth-caret/caret-glide.d.ts +13 -0
  160. package/dist/smooth-caret/caret-glide.js +76 -0
  161. package/dist/smooth-caret/caret-host.d.ts +5 -0
  162. package/dist/smooth-caret/caret-host.js +40 -0
  163. package/dist/smooth-caret/index.d.ts +7 -0
  164. package/dist/smooth-caret/index.js +7 -0
  165. package/dist/smooth-caret/remote-carets.d.ts +40 -0
  166. package/dist/smooth-caret/remote-carets.js +130 -0
  167. package/dist/smooth-caret/smooth-caret.css +157 -0
  168. package/dist/smooth-caret/smooth-caret.d.ts +5 -0
  169. package/dist/smooth-caret/smooth-caret.js +9 -0
  170. package/dist/smooth-caret/use-smooth-caret.d.ts +5 -0
  171. package/dist/smooth-caret/use-smooth-caret.js +9 -0
  172. package/dist/switch/index.d.ts +2 -0
  173. package/dist/switch/index.js +2 -0
  174. package/dist/switch/switch-drag.d.ts +21 -0
  175. package/dist/switch/switch-drag.js +23 -0
  176. package/dist/switch/switch-gesture.d.ts +28 -0
  177. package/dist/switch/switch-gesture.js +131 -0
  178. package/dist/switch/switch.css +189 -0
  179. package/dist/switch/switch.d.ts +15 -0
  180. package/dist/switch/switch.js +24 -0
  181. package/dist/textarea/index.d.ts +2 -0
  182. package/dist/textarea/index.js +2 -0
  183. package/dist/textarea/textarea.css +37 -0
  184. package/dist/textarea/textarea.d.ts +35 -0
  185. package/dist/textarea/textarea.js +11 -0
  186. package/dist/toast/index.d.ts +2 -0
  187. package/dist/toast/index.js +2 -0
  188. package/dist/toast/toast.css +293 -0
  189. package/dist/tooltip/index.d.ts +2 -0
  190. package/dist/tooltip/index.js +2 -0
  191. package/dist/tooltip/tooltip.css +143 -0
  192. package/dist/tooltip/tooltip.d.ts +14 -0
  193. package/dist/tooltip/tooltip.js +13 -0
  194. package/package.json +243 -5
@@ -0,0 +1,349 @@
1
+ @import "../motion/motion.css";
2
+
3
+ @layer kumiko {
4
+ :where(:root) {
5
+ --kumiko-menu-bg: Canvas;
6
+ --kumiko-menu-fg: CanvasText;
7
+ --kumiko-menu-border-width: 1px;
8
+ --kumiko-menu-radius: 0.625rem;
9
+ --kumiko-menu-shadow: 0 10px 28px -8px color-mix(in oklab, CanvasText 30%, transparent);
10
+ --kumiko-menu-padding: 0.25rem;
11
+ --kumiko-menu-min-width: 11rem;
12
+ --kumiko-menu-font-size: 0.875rem;
13
+ --kumiko-menu-item-padding: 0.4rem 0.625rem;
14
+ --kumiko-menu-item-gap: 0.5rem;
15
+ --kumiko-menu-icon-size: 1rem;
16
+ --kumiko-menu-focus-ring: Highlight;
17
+ --kumiko-menu-destructive-fg: light-dark(#b42318, #ff8f85);
18
+ --kumiko-menu-disabled-opacity: 0.45;
19
+ }
20
+
21
+ /* Derived colours resolve on the menu, so they follow a fg and bg set on any container. */
22
+ :where([data-slot="menu-content"]) {
23
+ --_menu-muted-fg: var(
24
+ --kumiko-menu-muted-fg,
25
+ color-mix(in oklab, var(--kumiko-menu-fg) 64%, var(--kumiko-menu-bg))
26
+ );
27
+
28
+ box-sizing: border-box;
29
+ min-inline-size: var(--kumiko-menu-min-width);
30
+ max-block-size: var(--available-height, 100dvh);
31
+ margin: 0;
32
+ padding: var(--kumiko-menu-padding);
33
+ overflow-y: auto;
34
+ overscroll-behavior: contain;
35
+ border: var(--kumiko-menu-border-width) solid
36
+ var(--kumiko-menu-border, color-mix(in oklab, var(--kumiko-menu-fg) 14%, transparent));
37
+ border-radius: var(--kumiko-menu-radius);
38
+ background: var(--kumiko-menu-bg);
39
+ box-shadow: var(--kumiko-menu-shadow);
40
+ color: var(--kumiko-menu-fg);
41
+ font-size: var(--kumiko-menu-font-size);
42
+ line-height: 1.3;
43
+ outline: none;
44
+ }
45
+
46
+ /* ui-sdk sets overscroll-behavior: contain inline on a sheet, which keeps a swipe the panel can't scroll from closing it. Only !important beats that. */
47
+ :where([data-slot="menu-content"][data-presentation="sheet"]) {
48
+ overscroll-behavior: auto !important;
49
+ }
50
+
51
+ /* A sheet's slide belongs to ui-sdk, so only popovers grow from their trigger. */
52
+ :where([data-slot="menu-content"][data-presentation="popover"]) {
53
+ --_menu-from: 0 0;
54
+ /* No scale or translate at rest: any other value than none would clip fixed-position descendants. */
55
+
56
+ transform-origin: var(--transform-origin);
57
+ transition-property: opacity, scale, translate;
58
+ /* Opening is quicker than closing, so a menu opened again and again never feels slow. */
59
+ transition-duration:
60
+ calc(var(--kumiko-fade-duration) * 0.6), var(--kumiko-pop-duration),
61
+ var(--kumiko-pop-duration);
62
+ transition-timing-function:
63
+ var(--kumiko-enter-ease), var(--kumiko-pop-ease), var(--kumiko-pop-ease);
64
+ }
65
+
66
+ :where([data-slot="menu-content"][data-presentation="popover"][data-side="bottom"]) {
67
+ --_menu-from: 0 calc(var(--kumiko-pop-distance) * -1);
68
+ }
69
+
70
+ :where([data-slot="menu-content"][data-presentation="popover"][data-side="top"]) {
71
+ --_menu-from: 0 var(--kumiko-pop-distance);
72
+ }
73
+
74
+ :where([data-slot="menu-content"][data-presentation="popover"][data-side="right"]) {
75
+ --_menu-from: calc(var(--kumiko-pop-distance) * -1) 0;
76
+ }
77
+
78
+ :where([data-slot="menu-content"][data-presentation="popover"][data-side="left"]) {
79
+ --_menu-from: var(--kumiko-pop-distance) 0;
80
+ }
81
+
82
+ :where([data-slot="menu-content"][data-presentation="popover"]):where(
83
+ [data-starting-style],
84
+ [data-ending-style]
85
+ ) {
86
+ opacity: 0;
87
+ scale: var(--kumiko-pop-scale);
88
+ translate: var(--_menu-from);
89
+ }
90
+
91
+ :where([data-slot="menu-content"][data-presentation="popover"][data-ending-style]) {
92
+ /* Closing, the shrink and slide last as long as the fade and on its curve, so they never stop mid-fade. */
93
+ transition-duration: var(--kumiko-fade-duration);
94
+ transition-timing-function: var(--kumiko-exit-ease);
95
+ }
96
+
97
+ /* A menu replacing another, like a right-click elsewhere, appears at once and the old one goes at once. */
98
+ :where(
99
+ [data-slot="menu-content"][data-presentation="popover"][data-kumiko-switch][data-starting-style]
100
+ ) {
101
+ opacity: 1;
102
+ scale: none;
103
+ translate: none;
104
+ }
105
+
106
+ /* With reduced or still motion the menu only fades, so scale and translate have nothing to animate. */
107
+ @media (prefers-reduced-motion: reduce) {
108
+ :where([data-slot="menu-content"][data-presentation="popover"]) {
109
+ transition-property: opacity;
110
+ }
111
+ }
112
+
113
+ :where([data-kumiko-motion="still"] [data-slot="menu-content"][data-presentation="popover"]) {
114
+ transition-property: opacity;
115
+ }
116
+
117
+ :where(
118
+ [data-slot="menu-content"][data-presentation="popover"][data-kumiko-switch][data-ending-style]
119
+ ) {
120
+ transition-property: none;
121
+ }
122
+
123
+ :where(
124
+ [data-slot="menu-content"] [role="menuitem"],
125
+ [data-slot="menu-content"] [role="menuitemcheckbox"],
126
+ [data-slot="menu-content"] [role="menuitemradio"]
127
+ ) {
128
+ display: flex;
129
+ gap: var(--kumiko-menu-item-gap);
130
+ align-items: center;
131
+ padding: var(--kumiko-menu-item-padding);
132
+ border-radius: var(
133
+ --kumiko-menu-item-radius,
134
+ calc(var(--kumiko-menu-radius) - var(--kumiko-menu-padding))
135
+ );
136
+ outline: none;
137
+ cursor: default;
138
+ user-select: none;
139
+ transition-property: background-color, color;
140
+ transition-duration: calc(var(--kumiko-fade-duration) * 0.5);
141
+ transition-timing-function: var(--kumiko-fade-ease);
142
+ }
143
+
144
+ /* The highlight arrives at once and lets go quickly, so it barely trails a sweep. */
145
+ :where(
146
+ [data-slot="menu-content"] [role="menuitem"],
147
+ [data-slot="menu-content"] [role="menuitemcheckbox"],
148
+ [data-slot="menu-content"] [role="menuitemradio"]
149
+ ):where([data-highlighted], [data-open]) {
150
+ transition-property: none;
151
+ background: var(
152
+ --kumiko-menu-highlight-bg,
153
+ color-mix(in oklab, var(--kumiko-menu-fg) 9%, transparent)
154
+ );
155
+ color: var(--kumiko-menu-highlight-fg, var(--kumiko-menu-fg));
156
+ }
157
+
158
+ /* The highlight fill is too faint to mark focus alone, so the keyboard also gets a ring. */
159
+ :where(
160
+ [data-slot="menu-content"] [role="menuitem"],
161
+ [data-slot="menu-content"] [role="menuitemcheckbox"],
162
+ [data-slot="menu-content"] [role="menuitemradio"]
163
+ ):focus-visible {
164
+ outline: 2px solid var(--kumiko-menu-focus-ring);
165
+ outline-offset: -2px;
166
+ }
167
+
168
+ :where([data-slot="menu-content"] [data-destructive]) {
169
+ color: var(--kumiko-menu-destructive-fg);
170
+ }
171
+
172
+ :where([data-slot="menu-content"] [data-destructive]):where([data-highlighted]) {
173
+ background: var(
174
+ --kumiko-menu-destructive-highlight-bg,
175
+ color-mix(in oklab, var(--kumiko-menu-destructive-fg) 13%, transparent)
176
+ );
177
+ color: var(--kumiko-menu-destructive-fg);
178
+ }
179
+
180
+ :where([data-slot="menu-content"] [data-disabled]) {
181
+ opacity: var(--kumiko-menu-disabled-opacity);
182
+ }
183
+
184
+ :where([data-slot="menu-content"] [data-pending]) {
185
+ --_menu-spinner: calc(var(--kumiko-menu-icon-size) * 0.875);
186
+
187
+ cursor: progress;
188
+ }
189
+
190
+ /* The spinner sits where the shortcut hint was, so the row keeps its width. */
191
+ :where([data-slot="menu-content"] [data-pending]) > :where([data-slot="menu-shortcut"]) {
192
+ visibility: hidden;
193
+ }
194
+
195
+ /* It fades in a moment late, so a quick action never flashes it. */
196
+ :where([data-slot="menu-content"] [data-pending])::after {
197
+ box-sizing: border-box;
198
+ flex: none;
199
+ inline-size: var(--_menu-spinner);
200
+ block-size: var(--_menu-spinner);
201
+ margin-inline-start: auto;
202
+ border: max(2px, 0.15em) solid color-mix(in oklab, currentColor 18%, transparent);
203
+ border-block-start-color: currentColor;
204
+ border-radius: 50%;
205
+ content: "";
206
+ animation:
207
+ kumiko-menu-spin var(--kumiko-spin-duration) var(--kumiko-spin-ease) infinite,
208
+ kumiko-menu-appear var(--kumiko-fade-duration) var(--kumiko-enter-ease)
209
+ var(--kumiko-fade-duration) both;
210
+ }
211
+
212
+ :where([data-slot="menu-content"] [data-pending]:has(> [data-slot="menu-shortcut"]))::after {
213
+ margin-inline-start: calc((var(--_menu-spinner) + var(--kumiko-menu-item-gap)) * -1);
214
+ }
215
+
216
+ /* Forced colours would paint both arcs one colour and hide the turn. */
217
+ @media (forced-colors: active) {
218
+ :where([data-slot="menu-content"] [data-pending])::after {
219
+ border-color: GrayText;
220
+ border-block-start-color: CanvasText;
221
+ forced-color-adjust: none;
222
+ }
223
+ }
224
+
225
+ @keyframes kumiko-menu-spin {
226
+ to {
227
+ rotate: 1turn;
228
+ }
229
+ }
230
+
231
+ @keyframes kumiko-menu-appear {
232
+ from {
233
+ opacity: 0;
234
+ }
235
+ }
236
+
237
+ :where([data-slot="menu-item-icon"], [data-slot="menu-item-indicator"]) {
238
+ display: inline-grid;
239
+ flex: none;
240
+ inline-size: var(--kumiko-menu-icon-size);
241
+ block-size: var(--kumiko-menu-icon-size);
242
+ place-items: center;
243
+ }
244
+
245
+ :where([data-slot="menu-item-indicator"]) {
246
+ transition-property: opacity, scale;
247
+ transition-duration: var(--kumiko-fade-duration), var(--kumiko-pop-duration);
248
+ transition-timing-function: var(--kumiko-enter-ease), var(--kumiko-pop-ease);
249
+ }
250
+
251
+ /* Only the item being chosen is highlighted, so ticks already on don't pop as the menu opens. */
252
+ @starting-style {
253
+ :where([data-highlighted] > [data-slot="menu-item-indicator"]) {
254
+ opacity: 0;
255
+ scale: 0.4;
256
+ }
257
+ }
258
+
259
+ :where([data-slot="menu-item-icon"] > svg) {
260
+ inline-size: 100%;
261
+ block-size: 100%;
262
+ }
263
+
264
+ :where([data-slot="menu-item-icon"][data-mirror]):dir(rtl) {
265
+ scale: -1 1;
266
+ }
267
+
268
+ /* When some items have an icon or a check, the rest keep that space so labels line up. */
269
+ :where(
270
+ [data-slot="menu-content"]:is(
271
+ [data-has-icons],
272
+ :has(> [aria-checked], > [role="group"] > [aria-checked])
273
+ )
274
+ )
275
+ > :where([role^="menuitem"]),
276
+ :where(
277
+ [data-slot="menu-content"]:is(
278
+ [data-has-icons],
279
+ :has(> [aria-checked], > [role="group"] > [aria-checked])
280
+ )
281
+ )
282
+ > [role="group"]
283
+ > :where([role^="menuitem"]) {
284
+ &:not(:has(> [data-slot="menu-item-icon"], > [data-slot="menu-item-indicator"]))::before {
285
+ flex: none;
286
+ inline-size: var(--kumiko-menu-icon-size);
287
+ content: "";
288
+ }
289
+ }
290
+
291
+ :where([data-slot="menu-checkbox-item"] > [data-slot="menu-item-indicator"])::before {
292
+ box-sizing: border-box;
293
+ inline-size: 0.35em;
294
+ block-size: 0.7em;
295
+ margin-block-start: -0.15em;
296
+ border: solid currentColor;
297
+ border-width: 0 max(2px, 0.14em) max(2px, 0.14em) 0;
298
+ rotate: 45deg;
299
+ content: "";
300
+ }
301
+
302
+ :where([data-slot="menu-radio-item"] > [data-slot="menu-item-indicator"])::before {
303
+ inline-size: 0.4em;
304
+ block-size: 0.4em;
305
+ border-radius: 50%;
306
+ background: currentColor;
307
+ content: "";
308
+ }
309
+
310
+ :where([data-slot="menu-shortcut"]) {
311
+ margin-inline-start: auto;
312
+ padding-inline-start: 1.5rem;
313
+ color: var(--_menu-muted-fg);
314
+ font-size: 0.9em;
315
+ font-variant-numeric: tabular-nums;
316
+ }
317
+
318
+ :where([data-slot="menu-content"] [data-slot="menu-trigger"])::after {
319
+ box-sizing: border-box;
320
+ inline-size: 0.4em;
321
+ block-size: 0.4em;
322
+ margin-inline: auto 0.15em;
323
+ border: solid currentColor;
324
+ border-width: 0 0.12em 0.12em 0;
325
+ rotate: -45deg;
326
+ opacity: 0.7;
327
+ content: "";
328
+ }
329
+
330
+ :where([data-slot="menu-content"] [data-slot="menu-trigger"]):dir(rtl)::after {
331
+ rotate: 135deg;
332
+ }
333
+
334
+ :where([data-slot="menu-group-label"]) {
335
+ padding: var(--kumiko-menu-item-padding);
336
+ color: var(--_menu-muted-fg);
337
+ font-size: 0.8em;
338
+ font-weight: 600;
339
+ }
340
+
341
+ :where([data-slot="menu-separator"]) {
342
+ block-size: 1px;
343
+ margin: var(--kumiko-menu-padding) calc(var(--kumiko-menu-padding) * -1);
344
+ background: var(
345
+ --kumiko-menu-separator,
346
+ color-mix(in oklab, var(--kumiko-menu-fg) 12%, transparent)
347
+ );
348
+ }
349
+ }
@@ -0,0 +1,11 @@
1
+ import { MenuContent as SdkMenuContent, type MenuProps } from "@ui-sdk/react/menu";
2
+ import { type ComponentProps } from "react";
3
+ /**
4
+ * The ui-sdk menu. A menu that opens while another (or itself) is open or still closing, as a
5
+ * right-click elsewhere does, replaces it at once: the new one appears whole, the old one goes
6
+ * without fading. Its content carries `data-kumiko-switch` from the moment it opens or closes
7
+ * until ui-sdk says the change is complete, set directly on a mounted element (ui-sdk restarts a
8
+ * reused one's entrance before React renders) and through React for one that mounts fresh.
9
+ */
10
+ export declare function Menu({ onOpenChange, onOpenChangeComplete, ...props }: MenuProps): React.JSX.Element;
11
+ export declare function MenuContent<Payload = unknown>({ ref, ...props }: ComponentProps<typeof SdkMenuContent<Payload>>): React.JSX.Element | null;
@@ -0,0 +1,86 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Menu as SdkMenu, MenuContent as SdkMenuContent } from "@ui-sdk/react/menu";
3
+ import { createContext, use, useEffect, useId, useState } from "react";
4
+ const open = new Set();
5
+ /** Menus still fading out, each with a way to cut its fade short. */
6
+ const closing = new Map();
7
+ const SwitchContext = createContext(null);
8
+ function mark(el, on) {
9
+ if (!el) {
10
+ return;
11
+ }
12
+ if (on) {
13
+ el.dataset.kumikoSwitch = "";
14
+ }
15
+ else {
16
+ delete el.dataset.kumikoSwitch;
17
+ }
18
+ }
19
+ /** Notes a menu opening or closing, and marks it (and any it replaces) as switching or not. */
20
+ function changed(id, next, set) {
21
+ if (next) {
22
+ const replacing = closing.size > 0 || [...open].some((other) => other !== id);
23
+ for (const [other, cut] of closing) {
24
+ if (other !== id) {
25
+ cut();
26
+ }
27
+ }
28
+ closing.delete(id);
29
+ open.add(id);
30
+ set(replacing);
31
+ return;
32
+ }
33
+ open.delete(id);
34
+ closing.set(id, () => {
35
+ set(true);
36
+ });
37
+ set(open.size > 0);
38
+ }
39
+ /**
40
+ * The ui-sdk menu. A menu that opens while another (or itself) is open or still closing, as a
41
+ * right-click elsewhere does, replaces it at once: the new one appears whole, the old one goes
42
+ * without fading. Its content carries `data-kumiko-switch` from the moment it opens or closes
43
+ * until ui-sdk says the change is complete, set directly on a mounted element (ui-sdk restarts a
44
+ * reused one's entrance before React renders) and through React for one that mounts fresh.
45
+ */
46
+ export function Menu({ onOpenChange, onOpenChangeComplete, ...props }) {
47
+ const id = useId();
48
+ const [on, setOn] = useState(false);
49
+ const [el] = useState(() => ({ current: null }));
50
+ const set = (next) => {
51
+ mark(el.current, next);
52
+ setOn(next);
53
+ };
54
+ useEffect(() => () => {
55
+ open.delete(id);
56
+ // The close may never be reported complete when a closing menu is removed.
57
+ closing.delete(id);
58
+ }, [id]);
59
+ return (_jsx(SwitchContext, { value: { on, el }, children: _jsx(SdkMenu, { ...props, onOpenChange: (next, details) => {
60
+ changed(id, next, set);
61
+ onOpenChange?.(next, details);
62
+ }, onOpenChangeComplete: (next) => {
63
+ if (!next) {
64
+ closing.delete(id);
65
+ }
66
+ set(false);
67
+ onOpenChangeComplete?.(next);
68
+ } }) }));
69
+ }
70
+ function joinRefs(holder, theirs) {
71
+ return (node) => {
72
+ if (holder) {
73
+ holder.current = node;
74
+ }
75
+ if (typeof theirs === "function") {
76
+ theirs(node);
77
+ }
78
+ else if (theirs) {
79
+ theirs.current = node;
80
+ }
81
+ };
82
+ }
83
+ export function MenuContent({ ref, ...props }) {
84
+ const state = use(SwitchContext);
85
+ return (_jsx(SdkMenuContent, { ...props, ref: joinRefs(state?.el, ref), "data-kumiko-switch": state?.on ? "" : undefined }));
86
+ }
@@ -0,0 +1,26 @@
1
+ import { type MenuController } from "@ui-sdk/react/menu";
2
+ export interface Point {
3
+ x: number;
4
+ y: number;
5
+ }
6
+ export interface PointMenuOptions {
7
+ /** A key opened it (Shift+F10, the menu key): focus lands on the first item, not the menu. */
8
+ keyboard?: boolean;
9
+ }
10
+ export interface PointMenu<Payload> {
11
+ /** Pass to the `Menu` that holds the items. */
12
+ controller: MenuController<Payload>;
13
+ /**
14
+ * Opens the menu with its corner at `at`, for a request from outside the page, like Electron's
15
+ * context-menu event. Focus moves into the menu and comes back to the element that had it.
16
+ */
17
+ open: (at: Point, payload: Payload, options?: PointMenuOptions) => void;
18
+ /**
19
+ * Runs `action` once the menu has closed and focus is back where it was, so an edit command or
20
+ * a spelling replacement acts on the text field rather than on the menu.
21
+ */
22
+ afterClose: (action: () => void) => void;
23
+ }
24
+ export declare function createPointMenu<Payload = unknown>(): PointMenu<Payload>;
25
+ /** One menu opened at a point from code: open it from a request, and run actions with `afterClose`. */
26
+ export declare function usePointMenu<Payload = unknown>(): PointMenu<Payload>;
@@ -0,0 +1,51 @@
1
+ import { createMenuController } from "@ui-sdk/react/menu";
2
+ import { useState } from "react";
3
+ const inMenu = (el) => el?.closest('[data-slot="menu-content"]') !== null && el !== null;
4
+ export function createPointMenu() {
5
+ const controller = createMenuController();
6
+ let queued = null;
7
+ const run = () => {
8
+ const action = queued;
9
+ queued = null;
10
+ action?.();
11
+ };
12
+ // Focus comes back just after ui-sdk says the menu closed, so a queued action waits for that.
13
+ const whenFocusLeaves = () => {
14
+ if (!queued) {
15
+ return;
16
+ }
17
+ if (!inMenu(document.activeElement)) {
18
+ run();
19
+ return;
20
+ }
21
+ const moved = (event) => {
22
+ if (event.target instanceof Element && !inMenu(event.target)) {
23
+ document.removeEventListener("focusin", moved, true);
24
+ run();
25
+ }
26
+ };
27
+ document.addEventListener("focusin", moved, true);
28
+ };
29
+ return {
30
+ controller,
31
+ open(at, payload, options = {}) {
32
+ if (controller.isOpen()) {
33
+ controller.close();
34
+ }
35
+ const anchor = { x: at.x, y: at.y };
36
+ void controller
37
+ .open(options.keyboard
38
+ ? { anchor, payload, focus: "first" }
39
+ : { anchor, payload, focus: "popup" })
40
+ .then(whenFocusLeaves);
41
+ },
42
+ afterClose(action) {
43
+ queued = action;
44
+ }
45
+ };
46
+ }
47
+ /** One menu opened at a point from code: open it from a request, and run actions with `afterClose`. */
48
+ export function usePointMenu() {
49
+ const [menu] = useState(() => createPointMenu());
50
+ return menu;
51
+ }
@@ -0,0 +1,19 @@
1
+ export interface Box {
2
+ left: number;
3
+ top: number;
4
+ }
5
+ export interface Offset {
6
+ x: number;
7
+ y: number;
8
+ }
9
+ export interface Place {
10
+ parent: unknown;
11
+ left: number;
12
+ top: number;
13
+ }
14
+ export declare function offsetBetween(from: Box, to: Box): Offset;
15
+ export declare function withoutParent(offset: Offset, parent: Offset | undefined): Offset;
16
+ export declare function isStill(offset: Offset): boolean;
17
+ export declare function parseDuration(value: string): number;
18
+ export declare function firstWins<Key, Value>(earlier: ReadonlyMap<Key, Value> | null, later: ReadonlyMap<Key, Value>): Map<Key, Value>;
19
+ export declare function offsetFromRest(was: Place | undefined, now: Place): Offset | undefined;
@@ -0,0 +1,33 @@
1
+ const STILL = 0.5;
2
+ export function offsetBetween(from, to) {
3
+ return { x: from.left - to.left, y: from.top - to.top };
4
+ }
5
+ export function withoutParent(offset, parent) {
6
+ return parent ? { x: offset.x - parent.x, y: offset.y - parent.y } : offset;
7
+ }
8
+ export function isStill(offset) {
9
+ return Math.abs(offset.x) < STILL && Math.abs(offset.y) < STILL;
10
+ }
11
+ export function parseDuration(value) {
12
+ const text = value.trim();
13
+ const milliseconds = text.endsWith("ms");
14
+ const unit = milliseconds ? 2 : 1;
15
+ if (!text.endsWith("s")) {
16
+ return 0;
17
+ }
18
+ const amount = Number(text.slice(0, -unit)) * (milliseconds ? 1 : 1000);
19
+ return Number.isFinite(amount) && amount > 0 ? amount : 0;
20
+ }
21
+ export function firstWins(earlier, later) {
22
+ const merged = new Map(later);
23
+ for (const [key, value] of earlier ?? []) {
24
+ merged.set(key, value);
25
+ }
26
+ return merged;
27
+ }
28
+ export function offsetFromRest(was, now) {
29
+ if (!was || was.parent !== now.parent) {
30
+ return undefined;
31
+ }
32
+ return { x: was.left - now.left, y: was.top - now.top };
33
+ }
@@ -0,0 +1,40 @@
1
+ import { type Box } from "./flip-math";
2
+ export type MotionKind = "move" | "settle";
3
+ export interface FlipOptions {
4
+ items: () => Iterable<HTMLElement>;
5
+ keyOf?: (el: HTMLElement) => string | undefined;
6
+ from?: (key: string) => DOMRect | undefined;
7
+ /**
8
+ * Where positions are measured from. When the frame moves (page content
9
+ * above it grows, the page scrolls), its items didn't move within it, so
10
+ * they don't animate. Defaults to the viewport.
11
+ */
12
+ origin?: () => Box;
13
+ skip?: (el: HTMLElement) => boolean;
14
+ prepare?: () => void;
15
+ enter?: (items: HTMLElement[]) => void;
16
+ }
17
+ export interface Flip {
18
+ measure: () => void;
19
+ /**
20
+ * Animates from the measured starts. `structural` says elements were added,
21
+ * removed or moved; without it only released items settle. Only a
22
+ * structural play can fall back to where an item last rested (changes that
23
+ * reach the page before the store does).
24
+ */
25
+ play: (structural?: boolean) => void;
26
+ /**
27
+ * Notes where everything rests now, and drops measurements that never
28
+ * played (a page in the background gets no frames), so a later change
29
+ * can't animate from a layout that has since changed.
30
+ */
31
+ rest: () => void;
32
+ }
33
+ export declare function readMotion(el: Element, kind: MotionKind): {
34
+ duration: number;
35
+ easing: string;
36
+ };
37
+ export declare function createFlip(options: FlipOptions): Flip;
38
+ export declare function bindFlip(root: HTMLElement, options: FlipOptions & {
39
+ subscribe: (listener: () => void) => () => void;
40
+ }): () => void;