@alulore/kumiko 0.21.0 → 0.21.1
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { disposeMirror, findField, measureCaret } from "./caret-geometry";
|
|
2
2
|
import { createGlider, prefersReducedMotion } from "./caret-glide";
|
|
3
|
-
import { canJoinTopLayer, isRaised, raiseToTop, topLayerAncestor } from "./top-layer";
|
|
3
|
+
import { canJoinTopLayer, isRaised, lowerFromTop, raiseToTop, topLayerAncestor } from "./top-layer";
|
|
4
4
|
const GLIDE_LIMIT = 400;
|
|
5
5
|
const IDLE_MS = 500;
|
|
6
6
|
const STILL_FRAMES = 12;
|
|
@@ -107,6 +107,7 @@ class CaretController {
|
|
|
107
107
|
this.glider.stop();
|
|
108
108
|
this.resizeObserver.disconnect();
|
|
109
109
|
delete this.tracked?.dataset.smoothCaret;
|
|
110
|
+
this.hide();
|
|
110
111
|
disposeMirror();
|
|
111
112
|
}
|
|
112
113
|
setTracked(field) {
|
|
@@ -174,13 +175,26 @@ class CaretController {
|
|
|
174
175
|
hide() {
|
|
175
176
|
this.visible = false;
|
|
176
177
|
delete this.caret.dataset.visible;
|
|
178
|
+
this.lower();
|
|
177
179
|
}
|
|
178
|
-
|
|
180
|
+
lower() {
|
|
181
|
+
lowerFromTop(this.caret);
|
|
182
|
+
this.raisedField = null;
|
|
183
|
+
this.raisedLayer = null;
|
|
184
|
+
}
|
|
185
|
+
/*
|
|
186
|
+
* Paints the caret above the top-layer element that holds the field, once per field and per holder. A
|
|
187
|
+
* field in the page leaves the caret a page element, under any popover like the native caret: Electron
|
|
188
|
+
* drops every window drag region while any popover is open, so a caret left in the top layer would stop
|
|
189
|
+
* the titlebar moving the window.
|
|
190
|
+
*/
|
|
179
191
|
raise(field) {
|
|
180
192
|
const layer = topLayerAncestor(field);
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
193
|
+
if (layer === null) {
|
|
194
|
+
this.lower();
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const settled = isRaised(this.caret) && layer === this.raisedLayer && field === this.raisedField;
|
|
184
198
|
if (!settled) {
|
|
185
199
|
raiseToTop(this.caret);
|
|
186
200
|
this.raisedField = field;
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
/*
|
|
18
18
|
* Both are manual popovers, so they sit in the top layer and paint above dialogs and popovers. The
|
|
19
|
-
* resets undo the browser's popover look (centred, bordered, padded, filled).
|
|
19
|
+
* resets undo the browser's popover look (centred, bordered, padded, filled). The caret leaves the top
|
|
20
|
+
* layer when its field is in the page, so it is shown as a plain element too.
|
|
20
21
|
*/
|
|
21
22
|
[data-slot="smooth-caret"] {
|
|
23
|
+
display: block;
|
|
22
24
|
position: fixed;
|
|
23
25
|
inset-block-start: 0;
|
|
24
26
|
inset-inline-start: 0;
|
|
@@ -4,6 +4,8 @@ export declare function canJoinTopLayer(element: HTMLElement): boolean;
|
|
|
4
4
|
export declare function makeTopLayerPopover(element: HTMLElement): void;
|
|
5
5
|
/** Puts the element on top of the top layer: showing it again moves it above everything opened so far. */
|
|
6
6
|
export declare function raiseToTop(element: HTMLElement): void;
|
|
7
|
+
/** Takes the element out of the top layer, if it is there. */
|
|
8
|
+
export declare function lowerFromTop(element: HTMLElement): void;
|
|
7
9
|
/** Whether the element is shown in the top layer right now. */
|
|
8
10
|
export declare function isRaised(element: HTMLElement): boolean;
|
|
9
11
|
/** The modal dialog or open popover that holds this element, or `null` when it sits in the page. */
|
|
@@ -29,6 +29,12 @@ export function raiseToTop(element) {
|
|
|
29
29
|
}
|
|
30
30
|
element.showPopover();
|
|
31
31
|
}
|
|
32
|
+
/** Takes the element out of the top layer, if it is there. */
|
|
33
|
+
export function lowerFromTop(element) {
|
|
34
|
+
if (canJoinTopLayer(element) && isShown(element)) {
|
|
35
|
+
element.hidePopover();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
32
38
|
/** Whether the element is shown in the top layer right now. */
|
|
33
39
|
export function isRaised(element) {
|
|
34
40
|
return isShown(element);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alulore/kumiko",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "Polished, cozy React components with gentle motion, built on ui-sdk. Every look and behaviour can be switched with props and CSS tokens.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|