@widgetic/canvas 0.5.41 → 0.5.43
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.
- package/README.md +1 -0
- package/dist/canvas/DomCanvas.svelte +49 -20
- package/dist/canvas/DomCanvas.svelte.d.ts +13 -7
- package/dist/canvas/autosaveScheduler.js +37 -89
- package/dist/canvas/boardFrame.js +1 -1
- package/dist/canvas/boardSurface.js +1 -1
- package/dist/canvas/canvasLogger.js +7 -19
- package/dist/canvas/chromeLayout.d.ts +14 -3
- package/dist/canvas/chromeLayout.js +30 -20
- package/dist/canvas/eventScope.js +10 -14
- package/dist/canvas/host/CanvasHost.d.ts +47 -5
- package/dist/canvas/host/CanvasHost.js +1481 -1566
- package/dist/canvas/host/CanvasHostApi.js +4 -19
- package/dist/canvas/host/browserServices.js +65 -116
- package/dist/canvas/host/conversion.js +82 -170
- package/dist/canvas/host/hostObject.js +7 -7
- package/dist/canvas/host/nearCards.d.ts +33 -0
- package/dist/canvas/host/nearCards.js +78 -0
- package/dist/canvas/host/pageEvents.d.ts +16 -4
- package/dist/canvas/host/pageEvents.js +17 -8
- package/dist/canvas/host/pictureSaves.d.ts +33 -0
- package/dist/canvas/host/pictureSaves.js +42 -0
- package/dist/canvas/host/screenRects.d.ts +5 -0
- package/dist/canvas/host/screenRects.js +28 -31
- package/dist/canvas/host/storedPictures.d.ts +88 -0
- package/dist/canvas/host/storedPictures.js +288 -0
- package/dist/canvas/host/strokeSnap.js +88 -143
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas/index.js +1 -1
- package/dist/canvas/openMarks.js +2 -2
- package/dist/canvas/outsideClickDeselect.js +6 -7
- package/dist/canvas/panZoomPosition.js +2 -2
- package/dist/canvas/preferredTextFont.js +13 -25
- package/dist/canvas/shapes/ShapeLibrary.js +138 -148
- package/dist/canvas/shapes/shapeImageStore.d.ts +45 -2
- package/dist/canvas/shapes/shapeImageStore.js +10 -3
- package/dist/canvas/shapes/strokeShapeSnap.js +188 -233
- package/dist/canvas/toolbarPosition.d.ts +2 -2
- package/dist/canvas/toolbarPosition.js +4 -4
- package/dist/canvas/ui/SelectionPanel.svelte +28 -5
- package/dist/canvas/ui/SelectionPanel.svelte.d.ts +7 -0
- package/dist/canvas/ui/SelectorIndicator.svelte +81 -0
- package/dist/canvas/ui/SelectorIndicator.svelte.d.ts +11 -0
- package/dist/canvas/ui/ToolButton.svelte +8 -2
- package/dist/canvas/ui/colorModel.js +21 -32
- package/dist/canvas/ui/colorPickerMessages.js +5 -5
- package/dist/canvas/ui/floatingCard.d.ts +2 -2
- package/dist/canvas/ui/floatingCard.js +20 -20
- package/dist/canvas/ui/floatingLayer.d.ts +13 -2
- package/dist/canvas/ui/floatingLayer.js +18 -7
- package/dist/canvas/ui/keyHints.js +9 -11
- package/dist/canvas/ui/popoverSide.js +2 -3
- package/dist/canvas/ui/selectionTraits.js +34 -40
- package/dist/canvas/view/CanvasStage.svelte +101 -67
- package/dist/canvas/view/LeftToRightScope.svelte +21 -0
- package/dist/canvas/view/LeftToRightScope.svelte.d.ts +7 -0
- package/dist/canvas/view/ObjectView.svelte +15 -10
- package/dist/canvas/view/ObjectView.svelte.d.ts +1 -1
- package/dist/canvas/view/erasingMarks.js +7 -7
- package/dist/canvas/view/geometry.js +71 -90
- package/dist/canvas/view/liftedScene.d.ts +31 -0
- package/dist/canvas/view/liftedScene.js +146 -0
- package/dist/canvas/view/mountedScene.d.ts +71 -0
- package/dist/canvas/view/mountedScene.js +363 -0
- package/dist/components/preferenceStorage.js +2 -2
- package/dist/engine/EngineCore.d.ts +15 -1
- package/dist/engine/EngineCore.js +724 -797
- package/dist/engine/codec/canvasDocument.d.ts +5 -0
- package/dist/engine/codec/canvasDocument.js +212 -149
- package/dist/engine/codec/hostReadableKeys.js +1 -1
- package/dist/engine/core/arrange.js +26 -38
- package/dist/engine/core/arrow.js +76 -89
- package/dist/engine/core/arrowBinding.js +98 -116
- package/dist/engine/core/arrowBindingRecords.js +23 -38
- package/dist/engine/core/brush.js +67 -94
- package/dist/engine/core/defaults.js +90 -51
- package/dist/engine/core/freehand.js +147 -163
- package/dist/engine/core/geometry.js +47 -54
- package/dist/engine/core/history.d.ts +6 -0
- package/dist/engine/core/history.js +49 -50
- package/dist/engine/core/hitTest.js +68 -81
- package/dist/engine/core/matrix.js +18 -20
- package/dist/engine/core/pathData.js +183 -210
- package/dist/engine/core/rotationReset.js +5 -6
- package/dist/engine/core/scene.d.ts +10 -0
- package/dist/engine/core/scene.js +153 -187
- package/dist/engine/core/scribble.js +59 -84
- package/dist/engine/core/shapePaths.js +12 -15
- package/dist/engine/core/shapeTools.js +72 -63
- package/dist/engine/core/snapping.js +65 -117
- package/dist/engine/core/style.js +31 -64
- package/dist/engine/core/transform.js +83 -94
- package/dist/engine/core/types.d.ts +8 -2
- package/dist/engine/core/types.js +4 -4
- package/dist/engine/core/viewport.js +23 -36
- package/dist/engine/input/PointerController.js +467 -474
- package/dist/engine/input/arrowHandles.js +12 -12
- package/dist/engine/input/gestures.js +265 -309
- package/dist/engine/input/hoverCursor.js +1 -1
- package/dist/engine/input/keyboard.js +27 -30
- package/dist/engine/input/selectionHandles.js +45 -50
- package/dist/engine/input/types.js +1 -1
- package/dist/engine/render/rasterize.js +86 -158
- package/dist/engine/state.d.ts +20 -0
- package/dist/engine/state.js +5 -15
- package/dist/engine/text/layoutText.js +43 -62
- package/dist/engine/text/textMetrics.js +8 -10
- package/dist/engine/widgets.js +101 -137
- package/dist/fonts/interFont.d.ts +10 -1
- package/dist/fonts/interFont.js +47 -75
- package/dist/fonts/workspaceFonts.js +32 -90
- package/dist/i18n/labels.js +4 -4
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/language.js +4 -4
- package/dist/i18n/messages.d.ts +8 -1
- package/dist/i18n/messages.js +10 -2
- package/dist/i18n/shortcuts.js +14 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/settings/workspaceToolSettings.js +32 -48
- package/dist/tools/components/catalog.js +64 -74
- package/dist/tools/components/grouping.js +6 -28
- package/dist/tools/definitions.js +5 -5
- package/dist/tools/executors.js +105 -141
- package/dist/tools/hostAdapter.js +11 -13
- package/dist/tools/sceneSummary.js +43 -57
- package/dist/tools/sketchIntent.js +13 -21
- package/dist/tools/types.js +1 -1
- package/package.json +1 -1
- package/dist/canvas/ui/SelectorBar.svelte +0 -84
- package/dist/canvas/ui/SelectorBar.svelte.d.ts +0 -12
|
@@ -1,29 +1,19 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
1
|
import { boundsOfObjects, findObject, indexScene, shapeBounds } from '../engine/core/scene.js';
|
|
11
2
|
import { isBoxedObject } from '../engine/core/types.js';
|
|
12
|
-
|
|
13
|
-
export
|
|
3
|
+
const DEFAULT_BOUNDS = { width: 1200, height: 800 };
|
|
4
|
+
export const SCENE_SUMMARY_MAX_ELEMENTS = 48;
|
|
14
5
|
/** The longest label a summary carries (the assistant request schema accepts 256, and the model needs far fewer). */
|
|
15
|
-
|
|
6
|
+
const SCENE_LABEL_MAX_CHARS = 80;
|
|
16
7
|
/** A label cut to the length a summary carries, so a long text never makes a request the gateway refuses. */
|
|
17
8
|
function shortenLabel(text) {
|
|
18
|
-
return text.length > SCENE_LABEL_MAX_CHARS ?
|
|
9
|
+
return text.length > SCENE_LABEL_MAX_CHARS ? `${text.slice(0, SCENE_LABEL_MAX_CHARS - 3)}...` : text;
|
|
19
10
|
}
|
|
20
11
|
export function labelOfObject(object) {
|
|
21
|
-
var _a, _b;
|
|
22
12
|
if (object.type === 'text') {
|
|
23
13
|
return shortenLabel(object.text.trim());
|
|
24
14
|
}
|
|
25
15
|
if (object.type === 'widget')
|
|
26
|
-
return
|
|
16
|
+
return object.widgetName ?? 'widget';
|
|
27
17
|
if (object.type === 'group')
|
|
28
18
|
return 'group';
|
|
29
19
|
if (object.type === 'path' && object.arrow)
|
|
@@ -35,12 +25,11 @@ export function labelOfObject(object) {
|
|
|
35
25
|
if (object.type === 'ellipse')
|
|
36
26
|
return 'ellipse';
|
|
37
27
|
if (object.type === 'image')
|
|
38
|
-
return
|
|
28
|
+
return object.fileName ?? 'image';
|
|
39
29
|
return object.type;
|
|
40
30
|
}
|
|
41
31
|
function groupLabelFromMembers(groupId, scene) {
|
|
42
|
-
for (
|
|
43
|
-
var object = scene_1[_i];
|
|
32
|
+
for (const object of scene) {
|
|
44
33
|
if (object.parentId === groupId && object.type === 'text') {
|
|
45
34
|
// Cut like the label of a loose text: a component's first text can be a whole paragraph.
|
|
46
35
|
return shortenLabel(object.text.trim()) || 'group';
|
|
@@ -67,31 +56,30 @@ function elementPriority(element) {
|
|
|
67
56
|
return 3;
|
|
68
57
|
}
|
|
69
58
|
function compareElements(a, b) {
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
const pa = elementPriority(a);
|
|
60
|
+
const pb = elementPriority(b);
|
|
72
61
|
if (pa !== pb)
|
|
73
62
|
return pa - pb;
|
|
74
|
-
|
|
75
|
-
|
|
63
|
+
const areaA = a.bbox.width * a.bbox.height;
|
|
64
|
+
const areaB = b.bbox.width * b.bbox.height;
|
|
76
65
|
if (areaA !== areaB)
|
|
77
66
|
return areaB - areaA;
|
|
78
67
|
return a.zIndex - b.zIndex;
|
|
79
68
|
}
|
|
80
|
-
export function summarizeScene(scene, bounds) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
scene.forEach(function (object, zIndex) {
|
|
69
|
+
export function summarizeScene(scene, bounds = DEFAULT_BOUNDS) {
|
|
70
|
+
const elements = [];
|
|
71
|
+
scene.forEach((object, zIndex) => {
|
|
84
72
|
if (object.type === 'group') {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (!
|
|
73
|
+
const memberIds = scene.filter((member) => member.parentId === object.id).map((member) => member.id);
|
|
74
|
+
const bbox = boundsOfObjects(scene, memberIds);
|
|
75
|
+
if (!bbox)
|
|
88
76
|
return;
|
|
89
77
|
elements.push({
|
|
90
78
|
id: object.id,
|
|
91
79
|
kind: 'group',
|
|
92
80
|
label: groupLabelFromMembers(object.id, scene),
|
|
93
|
-
bbox
|
|
94
|
-
zIndex
|
|
81
|
+
bbox,
|
|
82
|
+
zIndex,
|
|
95
83
|
parentId: object.parentId
|
|
96
84
|
});
|
|
97
85
|
return;
|
|
@@ -100,69 +88,67 @@ export function summarizeScene(scene, bounds) {
|
|
|
100
88
|
return;
|
|
101
89
|
if (!isBoxedObject(object))
|
|
102
90
|
return;
|
|
103
|
-
|
|
91
|
+
const bbox = shapeBounds(object);
|
|
104
92
|
elements.push({
|
|
105
93
|
id: object.id,
|
|
106
94
|
kind: kindOfObject(object),
|
|
107
95
|
label: labelOfObject(object),
|
|
108
|
-
bbox
|
|
109
|
-
zIndex
|
|
96
|
+
bbox,
|
|
97
|
+
zIndex,
|
|
110
98
|
parentId: object.parentId
|
|
111
99
|
});
|
|
112
100
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
101
|
+
const sorted = [...elements].sort(compareElements);
|
|
102
|
+
const totalCount = sorted.length;
|
|
103
|
+
const truncated = totalCount > SCENE_SUMMARY_MAX_ELEMENTS;
|
|
104
|
+
const limited = truncated ? sorted.slice(0, SCENE_SUMMARY_MAX_ELEMENTS) : sorted;
|
|
117
105
|
return {
|
|
118
|
-
bounds
|
|
106
|
+
bounds,
|
|
119
107
|
elements: limited,
|
|
120
|
-
totalCount
|
|
121
|
-
truncated
|
|
122
|
-
truncationNote: truncated ?
|
|
108
|
+
totalCount,
|
|
109
|
+
truncated,
|
|
110
|
+
truncationNote: truncated ? `Showing ${SCENE_SUMMARY_MAX_ELEMENTS} of ${totalCount} top-level elements.` : undefined
|
|
123
111
|
};
|
|
124
112
|
}
|
|
125
113
|
export function findByLabel(scene, needle) {
|
|
126
|
-
|
|
127
|
-
for (
|
|
128
|
-
var object = scene_2[_i];
|
|
114
|
+
const lower = needle.toLowerCase();
|
|
115
|
+
for (const object of scene) {
|
|
129
116
|
if (object.type === 'group') {
|
|
130
|
-
|
|
117
|
+
const label = groupLabelFromMembers(object.id, scene).toLowerCase();
|
|
131
118
|
if (label.includes(lower))
|
|
132
119
|
return object.id;
|
|
133
120
|
}
|
|
134
121
|
if (object.type === 'text') {
|
|
135
|
-
|
|
122
|
+
const label = object.text.toLowerCase();
|
|
136
123
|
if (label.includes(lower))
|
|
137
124
|
return object.id;
|
|
138
125
|
}
|
|
139
126
|
}
|
|
140
|
-
for (
|
|
141
|
-
|
|
142
|
-
var label = labelOfObject(object).toLowerCase();
|
|
127
|
+
for (const object of scene) {
|
|
128
|
+
const label = labelOfObject(object).toLowerCase();
|
|
143
129
|
if (label.includes(lower))
|
|
144
130
|
return object.id;
|
|
145
131
|
}
|
|
146
132
|
return null;
|
|
147
133
|
}
|
|
148
134
|
export function centerOf(id, scene) {
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
if (!
|
|
135
|
+
const object = findObject(scene, id);
|
|
136
|
+
if (object?.type === 'group') {
|
|
137
|
+
const bbox = boundsOfObjects(scene, [id]);
|
|
138
|
+
if (!bbox)
|
|
153
139
|
return null;
|
|
154
|
-
return { x:
|
|
140
|
+
return { x: bbox.x + bbox.width / 2, y: bbox.y + bbox.height / 2 };
|
|
155
141
|
}
|
|
156
142
|
if (!object || !isBoxedObject(object))
|
|
157
143
|
return null;
|
|
158
|
-
|
|
144
|
+
const bbox = shapeBounds(object);
|
|
159
145
|
return { x: bbox.x + bbox.width / 2, y: bbox.y + bbox.height / 2 };
|
|
160
146
|
}
|
|
161
147
|
export function sceneIndexMap(scene) {
|
|
162
148
|
return indexScene(scene);
|
|
163
149
|
}
|
|
164
150
|
export function bboxIntersects(a, b) {
|
|
165
|
-
|
|
151
|
+
const pad = 2;
|
|
166
152
|
return (a.x + a.width > b.x + pad &&
|
|
167
153
|
b.x + b.width > a.x + pad &&
|
|
168
154
|
a.y + a.height > b.y + pad &&
|
|
@@ -4,26 +4,18 @@
|
|
|
4
4
|
* every script. It is written without a lookbehind (which older Safari does not have), so it can never stop the module
|
|
5
5
|
* from loading.
|
|
6
6
|
*/
|
|
7
|
-
function standalone() {
|
|
8
|
-
|
|
9
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10
|
-
alternatives[_i] = arguments[_i];
|
|
11
|
-
}
|
|
12
|
-
return new RegExp("(?:^|[^\\p{L}\\p{N}_])(?:".concat(alternatives.join('|'), ")(?![\\p{L}\\p{N}_])"), 'iu');
|
|
7
|
+
function standalone(...alternatives) {
|
|
8
|
+
return new RegExp(`(?:^|[^\\p{L}\\p{N}_])(?:${alternatives.join('|')})(?![\\p{L}\\p{N}_])`, 'iu');
|
|
13
9
|
}
|
|
14
10
|
/** A pattern for a phrase of a writing system that puts no spaces between words (Chinese, Japanese): found anywhere. */
|
|
15
|
-
function anywhere() {
|
|
16
|
-
|
|
17
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
18
|
-
alternatives[_i] = arguments[_i];
|
|
19
|
-
}
|
|
20
|
-
return new RegExp("(?:".concat(alternatives.join('|'), ")"), 'iu');
|
|
11
|
+
function anywhere(...alternatives) {
|
|
12
|
+
return new RegExp(`(?:${alternatives.join('|')})`, 'iu');
|
|
21
13
|
}
|
|
22
14
|
/**
|
|
23
15
|
* Words that say the author wants something drawn on the canvas. Only words that mean drawing: a request to create
|
|
24
16
|
* something ("make a quiz", "I need a video player") is a widget, and goes to the code generator.
|
|
25
17
|
*/
|
|
26
|
-
|
|
18
|
+
const SKETCH_PATTERNS = [
|
|
27
19
|
/\bdraw\b/i,
|
|
28
20
|
/\bsketch\b/i,
|
|
29
21
|
/\bwireframe\b/i,
|
|
@@ -58,7 +50,7 @@ var SKETCH_PATTERNS = [
|
|
|
58
50
|
* Words that say the author wants code, a build or a publish. They win over a drawing word: "draw it, then publish it"
|
|
59
51
|
* is a request for the widget.
|
|
60
52
|
*/
|
|
61
|
-
|
|
53
|
+
const CODEGEN_PATTERNS = [
|
|
62
54
|
/\bbuild\b/i,
|
|
63
55
|
/\bgenerate\b/i,
|
|
64
56
|
/\bcode\b/i,
|
|
@@ -84,7 +76,7 @@ var CODEGEN_PATTERNS = [
|
|
|
84
76
|
standalone('zbuduj', 'wygeneruj', 'kod', 'opublikuj', 'zaimplementuj'),
|
|
85
77
|
standalone('bouw', 'genereer', 'publiceer', 'implementeer')
|
|
86
78
|
];
|
|
87
|
-
export
|
|
79
|
+
export const SKETCH_INTENT_COUNTER_EXAMPLES = [
|
|
88
80
|
'build me a countdown widget',
|
|
89
81
|
'make the button blue in the widget',
|
|
90
82
|
'generate the react code for this',
|
|
@@ -96,7 +88,7 @@ export var SKETCH_INTENT_COUNTER_EXAMPLES = [
|
|
|
96
88
|
* Free-text requests that draw, in the languages the router knows. Every one must route to the sketch assistant
|
|
97
89
|
* (the creator's tests and the gateway's mirror hold the same list).
|
|
98
90
|
*/
|
|
99
|
-
export
|
|
91
|
+
export const SKETCH_FREE_TEXT_EXAMPLES = [
|
|
100
92
|
'Sketch a pricing page with three plans and a call to action under each',
|
|
101
93
|
'wireframe a dashboard with a sidebar and four stat cards',
|
|
102
94
|
'can you draw three circles in a row and connect them with arrows',
|
|
@@ -128,7 +120,7 @@ export var SKETCH_FREE_TEXT_EXAMPLES = [
|
|
|
128
120
|
* Requests that are not for a drawing, with the verdict each gets. Creating something ("make", "create", "I need") is a
|
|
129
121
|
* widget, so most of them are `unknown` and go to the code generator by default; the ones that name code are `generate`.
|
|
130
122
|
*/
|
|
131
|
-
export
|
|
123
|
+
export const SKETCH_FREE_TEXT_COUNTER_EXAMPLES = [
|
|
132
124
|
['a video player with a playlist', 'unknown'],
|
|
133
125
|
['create a countdown timer with a start button', 'unknown'],
|
|
134
126
|
['I want a quiz about world capitals', 'unknown'],
|
|
@@ -149,16 +141,16 @@ export var SKETCH_FREE_TEXT_COUNTER_EXAMPLES = [
|
|
|
149
141
|
* Lightweight sketch-vs-codegen classifier for the creator chat (gateway mirrors this in tests).
|
|
150
142
|
*/
|
|
151
143
|
export function classifySketchIntent(message) {
|
|
152
|
-
|
|
144
|
+
const text = message.trim();
|
|
153
145
|
if (!text)
|
|
154
146
|
return 'unknown';
|
|
155
|
-
if (CODEGEN_PATTERNS.some(
|
|
147
|
+
if (CODEGEN_PATTERNS.some((pattern) => pattern.test(text)))
|
|
156
148
|
return 'generate';
|
|
157
|
-
if (SKETCH_PATTERNS.some(
|
|
149
|
+
if (SKETCH_PATTERNS.some((pattern) => pattern.test(text)))
|
|
158
150
|
return 'sketch';
|
|
159
151
|
return 'unknown';
|
|
160
152
|
}
|
|
161
|
-
export
|
|
153
|
+
export const SKETCH_ACCEPTANCE_PROMPTS = [
|
|
162
154
|
'draw a video player for me',
|
|
163
155
|
'move the navigation outside the video thumbnail',
|
|
164
156
|
'delete all sketches',
|
package/dist/tools/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
The element selector bar: what stands where the toolbar stood once the page has hidden the drawing tools (after the first
|
|
3
|
-
generation) and asks for the selector instead.
|
|
4
|
-
|
|
5
|
-
One toggle that puts the page's element selector on or off, and, whenever the page gave its words, the line that says how to
|
|
6
|
-
use it (click, the arrow keys to move between parent and child, a held key to use the widget, Escape to finish). The bar has
|
|
7
|
-
one form only, the open one: the instructions are there before the toggle is pressed, not after (it used to shrink to the
|
|
8
|
-
toggle while the selector was off and grow when it was on).
|
|
9
|
-
The words come from the page (`selectorGuide`), already in its language; the key caps are the keys themselves.
|
|
10
|
-
|
|
11
|
-
The bar stands where the toolbar stands (`toolbarPosition`). On the left or the right edge it stands upright, and the line
|
|
12
|
-
of words becomes four short lines under the toggle.
|
|
13
|
-
-->
|
|
14
|
-
<script lang="ts">
|
|
15
|
-
import { useCanvasLanguage } from '../../i18n/language.js';
|
|
16
|
-
import { isSideAnchor, popoverSideFor } from '../chromeLayout.js';
|
|
17
|
-
import type { ChromeAnchor } from '../chromeLayout.js';
|
|
18
|
-
import type { SelectorGuide } from '../host/CanvasHost.js';
|
|
19
|
-
import { FLOATING_CARD_CLASSES } from './floatingCard.js';
|
|
20
|
-
import { IconSelectElement } from './icons.js';
|
|
21
|
-
import { providePopoverSide } from './popoverSide.js';
|
|
22
|
-
import ToolButton from './ToolButton.svelte';
|
|
23
|
-
|
|
24
|
-
interface Props {
|
|
25
|
-
active: boolean;
|
|
26
|
-
guide: SelectorGuide | null;
|
|
27
|
-
/** Where the bar stands (see `chromeLayout.ts`): it stands upright on the left and the right edge. */
|
|
28
|
-
anchor: ChromeAnchor;
|
|
29
|
-
onToggle: () => void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let { active, guide, anchor, onToggle }: Props = $props();
|
|
33
|
-
|
|
34
|
-
const { t } = useCanvasLanguage();
|
|
35
|
-
|
|
36
|
-
const vertical = $derived(isSideAnchor(anchor));
|
|
37
|
-
providePopoverSide(() => popoverSideFor(anchor));
|
|
38
|
-
</script>
|
|
39
|
-
|
|
40
|
-
{#snippet keyCap(cap: string)}
|
|
41
|
-
<kbd class="rounded-md border border-border bg-muted px-1.5 py-0.5 font-sans text-xs text-muted-foreground">{cap}</kbd>
|
|
42
|
-
{/snippet}
|
|
43
|
-
|
|
44
|
-
{#snippet dot()}
|
|
45
|
-
<span class="text-border" aria-hidden="true">·</span>
|
|
46
|
-
{/snippet}
|
|
47
|
-
|
|
48
|
-
<!-- `widget-selector-bar` is the name pages' own tests have always found the bar by. -->
|
|
49
|
-
<div
|
|
50
|
-
role="group"
|
|
51
|
-
aria-label={$t('canvas.tool.selector')}
|
|
52
|
-
data-canvas-selector-bar
|
|
53
|
-
data-anchor={anchor}
|
|
54
|
-
class="widget-selector-bar pointer-events-auto flex items-center gap-1 whitespace-nowrap {vertical ? 'max-h-full flex-col overflow-y-auto' : 'max-w-full flex-nowrap'} {FLOATING_CARD_CLASSES}"
|
|
55
|
-
>
|
|
56
|
-
<ToolButton toggle label={$t('canvas.tool.selector')} active={active} onclick={onToggle}>
|
|
57
|
-
<IconSelectElement />
|
|
58
|
-
</ToolButton>
|
|
59
|
-
{#if guide}
|
|
60
|
-
{#if vertical}
|
|
61
|
-
<div class="flex flex-col items-start gap-1.5 px-1 pb-1.5 text-caption-medium text-muted-foreground">
|
|
62
|
-
<span>{guide.click}</span>
|
|
63
|
-
<span class="flex items-center gap-1.5">{@render keyCap('↑')}{@render keyCap('↓')}<span>{guide.parentChild}</span></span>
|
|
64
|
-
<span class="flex items-center gap-1.5"><span>{guide.hold}</span>{@render keyCap(guide.cmd)}<span>{guide.interact}</span></span>
|
|
65
|
-
<span class="flex items-center gap-1.5">{@render keyCap(guide.esc)}<span>{guide.done}</span></span>
|
|
66
|
-
</div>
|
|
67
|
-
{:else}
|
|
68
|
-
<div class="flex flex-nowrap items-center gap-1.5 pe-3 ps-1 text-caption-medium text-muted-foreground">
|
|
69
|
-
<span>{guide.click}</span>
|
|
70
|
-
{@render dot()}
|
|
71
|
-
{@render keyCap('↑')}
|
|
72
|
-
{@render keyCap('↓')}
|
|
73
|
-
<span>{guide.parentChild}</span>
|
|
74
|
-
{@render dot()}
|
|
75
|
-
<span>{guide.hold}</span>
|
|
76
|
-
{@render keyCap(guide.cmd)}
|
|
77
|
-
<span>{guide.interact}</span>
|
|
78
|
-
{@render dot()}
|
|
79
|
-
{@render keyCap(guide.esc)}
|
|
80
|
-
<span>{guide.done}</span>
|
|
81
|
-
</div>
|
|
82
|
-
{/if}
|
|
83
|
-
{/if}
|
|
84
|
-
</div>
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ChromeAnchor } from '../chromeLayout.js';
|
|
2
|
-
import type { SelectorGuide } from '../host/CanvasHost.js';
|
|
3
|
-
interface Props {
|
|
4
|
-
active: boolean;
|
|
5
|
-
guide: SelectorGuide | null;
|
|
6
|
-
/** Where the bar stands (see `chromeLayout.ts`): it stands upright on the left and the right edge. */
|
|
7
|
-
anchor: ChromeAnchor;
|
|
8
|
-
onToggle: () => void;
|
|
9
|
-
}
|
|
10
|
-
declare const SelectorBar: import("svelte").Component<Props, {}, "">;
|
|
11
|
-
type SelectorBar = ReturnType<typeof SelectorBar>;
|
|
12
|
-
export default SelectorBar;
|