@hachej/boring-feedback 0.4.29 → 0.4.31
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.
|
@@ -36,7 +36,13 @@ export interface OverlayOptions {
|
|
|
36
36
|
readonly styles?: string;
|
|
37
37
|
/** Where the host is appended; defaults to `document.body`. Never inside the application root. */
|
|
38
38
|
readonly mount?: Element;
|
|
39
|
+
/** `above` (default): the label sits over the box's top-left corner. `corner`: centred on the box's top-right corner, like a numbered pin. */
|
|
40
|
+
readonly labels?: 'above' | 'corner';
|
|
41
|
+
/** `element`: each box takes its element's own border radius (default: the overlay's square box). */
|
|
42
|
+
readonly shape?: 'box' | 'element';
|
|
43
|
+
/** Nothing is drawn outside this element's rectangle (a scroll container whose bottom part is taken by another surface). */
|
|
44
|
+
readonly clip?: Element;
|
|
39
45
|
}
|
|
40
46
|
/** Creates the overlay host and its shadow root. Nothing is drawn until `draw` or `highlight`. */
|
|
41
|
-
export declare function createOverlay({ document, styles, mount }: OverlayOptions): PickerOverlay;
|
|
47
|
+
export declare function createOverlay({ document, styles, mount, labels, shape, clip }: OverlayOptions): PickerOverlay;
|
|
42
48
|
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -23,7 +23,7 @@ const BASE_STYLES = `
|
|
|
23
23
|
`;
|
|
24
24
|
const LABEL_HEIGHT = 22;
|
|
25
25
|
/** Creates the overlay host and its shadow root. Nothing is drawn until `draw` or `highlight`. */
|
|
26
|
-
export function createOverlay({ document, styles, mount }) {
|
|
26
|
+
export function createOverlay({ document, styles, mount, labels = 'above', shape = 'box', clip }) {
|
|
27
27
|
const host = document.createElement('div');
|
|
28
28
|
host.setAttribute(FEEDBACK_OVERLAY_ATTRIBUTE, '');
|
|
29
29
|
host.setAttribute('data-boring', 'feedback');
|
|
@@ -50,6 +50,10 @@ export function createOverlay({ document, styles, mount }) {
|
|
|
50
50
|
frame = undefined;
|
|
51
51
|
layer.replaceChildren();
|
|
52
52
|
const height = view?.innerHeight ?? 0;
|
|
53
|
+
if (clip) {
|
|
54
|
+
const area = clip.getBoundingClientRect();
|
|
55
|
+
layer.style.clipPath = `inset(${area.top}px ${(view?.innerWidth ?? 0) - area.right}px ${height - area.bottom}px ${area.left}px)`;
|
|
56
|
+
}
|
|
53
57
|
for (const item of boxes) {
|
|
54
58
|
if (!item.element.isConnected)
|
|
55
59
|
continue;
|
|
@@ -59,14 +63,20 @@ export function createOverlay({ document, styles, mount }) {
|
|
|
59
63
|
box.dataset['tone'] = item.tone;
|
|
60
64
|
box.setAttribute('part', `box box-${item.tone}`);
|
|
61
65
|
box.style.cssText = `top:${rect.top}px;left:${rect.left}px;width:${rect.width}px;height:${rect.height}px`;
|
|
66
|
+
if (shape === 'element' && view)
|
|
67
|
+
box.style.borderRadius = view.getComputedStyle(item.element).borderRadius;
|
|
62
68
|
const label = document.createElement('div');
|
|
63
69
|
label.className = 'label';
|
|
64
70
|
label.dataset['tone'] = item.tone;
|
|
65
71
|
label.setAttribute('part', `label label-${item.tone}`);
|
|
66
72
|
label.textContent = item.label;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
if (labels === 'corner')
|
|
74
|
+
label.style.cssText = `top:${rect.top}px;left:${rect.right}px`;
|
|
75
|
+
else {
|
|
76
|
+
const above = rect.top - LABEL_HEIGHT - 2;
|
|
77
|
+
const top = above >= 0 ? above : Math.min(rect.bottom + 2, Math.max(0, height - LABEL_HEIGHT));
|
|
78
|
+
label.style.cssText = `top:${top}px;left:${Math.max(0, rect.left)}px`;
|
|
79
|
+
}
|
|
70
80
|
layer.append(box, label);
|
|
71
81
|
}
|
|
72
82
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hachej/boring-feedback",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.31",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@hachej/boring-ui-kit": "^0.4.
|
|
56
|
-
"@hachej/boring-files": "^0.4.
|
|
57
|
-
"@hachej/boring-agent": "^0.4.
|
|
55
|
+
"@hachej/boring-ui-kit": "^0.4.31",
|
|
56
|
+
"@hachej/boring-files": "^0.4.31",
|
|
57
|
+
"@hachej/boring-agent": "^0.4.31",
|
|
58
58
|
"@earendil-works/pi-durable": "~1.4.0",
|
|
59
59
|
"@earendil-works/pi-ai": "~1.4.0",
|
|
60
60
|
"@earendil-works/chord": "~1.4.0",
|