@daasboard/ui 0.0.0-stage → 0.1.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.
- package/LICENSE +5 -0
- package/README.md +6 -2
- package/dist/LICENSE-lucide.txt +43 -0
- package/dist/color/color.d.ts +34 -0
- package/dist/color/color.js +106 -0
- package/dist/color/edit.d.ts +34 -0
- package/dist/color/edit.js +40 -0
- package/dist/color/gradient.d.ts +39 -0
- package/dist/color/gradient.js +129 -0
- package/dist/color/index.d.ts +3 -0
- package/dist/color/index.js +3 -0
- package/dist/controls/buttons.d.ts +54 -0
- package/dist/controls/buttons.js +95 -0
- package/dist/controls/font-picker.d.ts +35 -0
- package/dist/controls/font-picker.js +178 -0
- package/dist/controls/index.d.ts +43 -0
- package/dist/controls/index.js +32 -0
- package/dist/controls/number-field.d.ts +60 -0
- package/dist/controls/number-field.js +190 -0
- package/dist/controls/place.d.ts +10 -0
- package/dist/controls/place.js +77 -0
- package/dist/controls/popover.d.ts +84 -0
- package/dist/controls/popover.js +366 -0
- package/dist/controls/shared.d.ts +30 -0
- package/dist/controls/shared.js +134 -0
- package/dist/controls/slider.d.ts +82 -0
- package/dist/controls/slider.js +241 -0
- package/dist/controls/swatch.d.ts +25 -0
- package/dist/controls/swatch.js +38 -0
- package/dist/controls/tooltip.d.ts +19 -0
- package/dist/controls/tooltip.js +84 -0
- package/dist/controls/typed.d.ts +28 -0
- package/dist/controls/typed.js +126 -0
- package/dist/element.d.ts +40 -0
- package/dist/element.js +78 -0
- package/dist/host.d.ts +99 -0
- package/dist/host.js +1 -0
- package/dist/icons/index.d.ts +7 -0
- package/dist/icons/index.js +31 -0
- package/dist/icons/lucide.d.ts +851 -0
- package/dist/icons/lucide.js +90 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +16 -0
- package/dist/keys.d.ts +30 -0
- package/dist/keys.js +122 -0
- package/dist/mount.d.ts +11 -0
- package/dist/mount.js +96 -0
- package/dist/options.d.ts +152 -0
- package/dist/options.js +78 -0
- package/dist/palette.d.ts +6 -0
- package/dist/palette.js +9 -0
- package/dist/picker/handles.d.ts +7 -0
- package/dist/picker/handles.js +8 -0
- package/dist/picker/index.d.ts +21 -0
- package/dist/picker/index.js +20 -0
- package/dist/picker/palette.d.ts +8 -0
- package/dist/picker/palette.js +14 -0
- package/dist/picker/picker.d.ts +63 -0
- package/dist/picker/picker.js +561 -0
- package/dist/picker/solid-editor.d.ts +60 -0
- package/dist/picker/solid-editor.js +330 -0
- package/dist/picker/stop-bar.d.ts +27 -0
- package/dist/picker/stop-bar.js +140 -0
- package/dist/prefs.d.ts +6 -0
- package/dist/prefs.js +34 -0
- package/dist/recents.d.ts +9 -0
- package/dist/recents.js +140 -0
- package/dist/root.d.ts +31 -0
- package/dist/root.js +526 -0
- package/dist/scheduler.d.ts +21 -0
- package/dist/scheduler.js +132 -0
- package/dist/strings.d.ts +284 -0
- package/dist/strings.js +287 -0
- package/dist/surface.d.ts +27 -0
- package/dist/surface.js +8 -0
- package/dist/surfaces/context-menu/index.d.ts +2 -0
- package/dist/surfaces/context-menu/index.js +2 -0
- package/dist/surfaces/context-menu/items.d.ts +14 -0
- package/dist/surfaces/context-menu/items.js +38 -0
- package/dist/surfaces/context-menu/menu.d.ts +16 -0
- package/dist/surfaces/context-menu/menu.js +135 -0
- package/dist/surfaces/pane/index.d.ts +16 -0
- package/dist/surfaces/pane/index.js +19 -0
- package/dist/surfaces/pane/model.d.ts +41 -0
- package/dist/surfaces/pane/model.js +139 -0
- package/dist/surfaces/pane/outlet.d.ts +16 -0
- package/dist/surfaces/pane/outlet.js +20 -0
- package/dist/surfaces/pane/pane.d.ts +40 -0
- package/dist/surfaces/pane/pane.js +1429 -0
- package/dist/surfaces/pane/placement.d.ts +11 -0
- package/dist/surfaces/pane/placement.js +62 -0
- package/dist/surfaces/pane/text-field.d.ts +16 -0
- package/dist/surfaces/pane/text-field.js +20 -0
- package/dist/surfaces/selection-toolbar/index.d.ts +2 -0
- package/dist/surfaces/selection-toolbar/index.js +2 -0
- package/dist/surfaces/selection-toolbar/items.d.ts +37 -0
- package/dist/surfaces/selection-toolbar/items.js +183 -0
- package/dist/surfaces/selection-toolbar/toolbar.d.ts +27 -0
- package/dist/surfaces/selection-toolbar/toolbar.js +956 -0
- package/dist/surfaces/tools/index.d.ts +2 -0
- package/dist/surfaces/tools/index.js +2 -0
- package/dist/surfaces/tools/keys.d.ts +11 -0
- package/dist/surfaces/tools/keys.js +21 -0
- package/dist/surfaces/tools/model.d.ts +48 -0
- package/dist/surfaces/tools/model.js +155 -0
- package/dist/surfaces/tools/toolbar.d.ts +27 -0
- package/dist/surfaces/tools/toolbar.js +502 -0
- package/dist/theme.d.ts +26 -0
- package/dist/theme.js +47 -0
- package/package.json +31 -3
package/dist/strings.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
export const DEFAULT_STRINGS = {
|
|
2
|
+
"surface.tools": "Tools",
|
|
3
|
+
"surface.selection": "Selection",
|
|
4
|
+
"surface.textFormatting": "Text formatting",
|
|
5
|
+
"surface.properties": "Properties",
|
|
6
|
+
"pane.show": "Show properties",
|
|
7
|
+
"pane.hide": "Hide properties",
|
|
8
|
+
"pane.layout": "Layout",
|
|
9
|
+
"pane.appearance": "Appearance",
|
|
10
|
+
"pane.text": "Text",
|
|
11
|
+
"pane.fill": "Fill",
|
|
12
|
+
"pane.stroke": "Stroke",
|
|
13
|
+
"pane.connector": "Connector",
|
|
14
|
+
"pane.effects": "Effects",
|
|
15
|
+
"pane.link": "Link",
|
|
16
|
+
"pane.other": "Other",
|
|
17
|
+
"pane.layoutMore": "More layout options",
|
|
18
|
+
"pane.lockRatio": "Keep aspect ratio",
|
|
19
|
+
"pane.corners": "Individual corners",
|
|
20
|
+
"pane.textMore": "More text options",
|
|
21
|
+
"pane.paddingX": "Horizontal padding",
|
|
22
|
+
"pane.paddingY": "Vertical padding",
|
|
23
|
+
"pane.paddingSides": "Padding per side",
|
|
24
|
+
"pane.layer": "Layer",
|
|
25
|
+
"pane.addFill": "Add fill",
|
|
26
|
+
"pane.removeFill": "Remove fill",
|
|
27
|
+
"pane.addStroke": "Add stroke",
|
|
28
|
+
"pane.removeStroke": "Remove stroke",
|
|
29
|
+
"pane.strokeMore": "More stroke options",
|
|
30
|
+
"pane.strokeSides": "Visible sides",
|
|
31
|
+
"pane.swapEnds": "Swap arrowheads",
|
|
32
|
+
"pane.addEffect": "Add effect",
|
|
33
|
+
"pane.removeEffect": "Remove effect",
|
|
34
|
+
"pane.dropShadow": "Drop shadow",
|
|
35
|
+
"pane.url": "Paste a link",
|
|
36
|
+
"short.x": "X",
|
|
37
|
+
"short.y": "Y",
|
|
38
|
+
"short.w": "W",
|
|
39
|
+
"short.h": "H",
|
|
40
|
+
"short.blur": "B",
|
|
41
|
+
"short.spread": "S",
|
|
42
|
+
"short.paddingX": "H",
|
|
43
|
+
"short.paddingY": "V",
|
|
44
|
+
"short.left": "L",
|
|
45
|
+
"short.right": "R",
|
|
46
|
+
"short.top": "T",
|
|
47
|
+
"short.bottom": "B",
|
|
48
|
+
"short.topLeft": "TL",
|
|
49
|
+
"short.topRight": "TR",
|
|
50
|
+
"short.bottomLeft": "BL",
|
|
51
|
+
"short.bottomRight": "BR",
|
|
52
|
+
"command.alignLeft": "Align left",
|
|
53
|
+
"command.alignCenter": "Align horizontal centers",
|
|
54
|
+
"command.alignRight": "Align right",
|
|
55
|
+
"command.alignTop": "Align top",
|
|
56
|
+
"command.alignMiddle": "Align vertical centers",
|
|
57
|
+
"command.alignBottom": "Align bottom",
|
|
58
|
+
"command.distributeHorizontal": "Distribute horizontally",
|
|
59
|
+
"command.distributeVertical": "Distribute vertically",
|
|
60
|
+
"option.none": "None",
|
|
61
|
+
"option.left": "Left",
|
|
62
|
+
"option.center": "Center",
|
|
63
|
+
"option.right": "Right",
|
|
64
|
+
"option.justify": "Justify",
|
|
65
|
+
"option.top": "Top",
|
|
66
|
+
"option.middle": "Middle",
|
|
67
|
+
"option.bottom": "Bottom",
|
|
68
|
+
"option.inside": "Inside",
|
|
69
|
+
"option.outside": "Outside",
|
|
70
|
+
"option.upper": "Uppercase",
|
|
71
|
+
"option.lower": "Lowercase",
|
|
72
|
+
"option.bullet": "Bullets",
|
|
73
|
+
"option.number": "Numbers",
|
|
74
|
+
"option.task": "Tasks",
|
|
75
|
+
"option.straight": "Straight",
|
|
76
|
+
"option.ortho": "Elbow",
|
|
77
|
+
"option.curve": "Curved",
|
|
78
|
+
"option.solid": "Solid",
|
|
79
|
+
"option.dash": "Dash",
|
|
80
|
+
"option.longDash": "Long dash",
|
|
81
|
+
"option.shortDash": "Short dash",
|
|
82
|
+
"option.dot": "Dot",
|
|
83
|
+
"option.dashDot": "Dash dot",
|
|
84
|
+
"option.dashDotDot": "Dash dot dot",
|
|
85
|
+
"option.butt": "Butt",
|
|
86
|
+
"option.round": "Round",
|
|
87
|
+
"option.square": "Square",
|
|
88
|
+
"option.miter": "Miter",
|
|
89
|
+
"option.bevel": "Bevel",
|
|
90
|
+
"option.arrow": "Arrow",
|
|
91
|
+
"option.triangle": "Triangle",
|
|
92
|
+
"option.triangle-open": "Open triangle",
|
|
93
|
+
"option.triangle-skinny": "Narrow triangle",
|
|
94
|
+
"option.circle": "Circle",
|
|
95
|
+
"option.circle-open": "Open circle",
|
|
96
|
+
"option.diamond": "Diamond",
|
|
97
|
+
"option.diamond-open": "Open diamond",
|
|
98
|
+
"option.square-open": "Open square",
|
|
99
|
+
"option.bar": "Bar",
|
|
100
|
+
"option.crow": "Crow's foot",
|
|
101
|
+
"tools.more": "More tools",
|
|
102
|
+
"tools.options": "Tool options",
|
|
103
|
+
"tools.colors": "Sticky colors",
|
|
104
|
+
"tools.quickActions": "Quick actions",
|
|
105
|
+
"sticky.yellow": "Yellow",
|
|
106
|
+
"sticky.red": "Red",
|
|
107
|
+
"sticky.orange": "Orange",
|
|
108
|
+
"sticky.green": "Green",
|
|
109
|
+
"sticky.blue": "Blue",
|
|
110
|
+
"sticky.violet": "Violet",
|
|
111
|
+
"tool.select": "Select",
|
|
112
|
+
"tool.hand": "Hand",
|
|
113
|
+
"tool.rect": "Rectangle",
|
|
114
|
+
"tool.ellipse": "Ellipse",
|
|
115
|
+
"tool.diamond": "Diamond",
|
|
116
|
+
"tool.star": "Star",
|
|
117
|
+
"tool.arrow-left": "Left arrow",
|
|
118
|
+
"tool.arrow-right": "Right arrow",
|
|
119
|
+
"tool.arrow-double": "Double arrow",
|
|
120
|
+
"tool.speech-bubble": "Speech bubble",
|
|
121
|
+
"tool.database": "Database",
|
|
122
|
+
"tool.triangle": "Triangle",
|
|
123
|
+
"tool.text": "Text",
|
|
124
|
+
"tool.image": "Insert image",
|
|
125
|
+
"tool.sticky": "Sticky note",
|
|
126
|
+
"tool.connector": "Connector",
|
|
127
|
+
"tool.frame": "Frame",
|
|
128
|
+
"tool.section": "Section",
|
|
129
|
+
"zoom.menu": "Zoom options",
|
|
130
|
+
"zoom.percent": "{value} %",
|
|
131
|
+
"zoom.in": "Zoom in",
|
|
132
|
+
"zoom.out": "Zoom out",
|
|
133
|
+
"zoom.fit": "Zoom to fit",
|
|
134
|
+
"zoom.selection": "Zoom to selection",
|
|
135
|
+
"command.undo": "Undo",
|
|
136
|
+
"command.redo": "Redo",
|
|
137
|
+
"command.delete": "Delete",
|
|
138
|
+
"command.duplicate": "Duplicate",
|
|
139
|
+
"command.selectAll": "Select all",
|
|
140
|
+
"command.bringToFront": "Bring to front",
|
|
141
|
+
"command.bringForward": "Bring forward",
|
|
142
|
+
"command.sendBackward": "Send backward",
|
|
143
|
+
"command.sendToBack": "Send to back",
|
|
144
|
+
"command.lock": "Lock",
|
|
145
|
+
"command.unlock": "Unlock",
|
|
146
|
+
"surface.contextMenu": "Actions",
|
|
147
|
+
"command.cut": "Cut",
|
|
148
|
+
"command.copy": "Copy",
|
|
149
|
+
"command.paste": "Paste",
|
|
150
|
+
"command.pasteHere": "Paste here",
|
|
151
|
+
"value.mixed": "Mixed",
|
|
152
|
+
"value.none": "None",
|
|
153
|
+
"color.area": "Saturation and brightness",
|
|
154
|
+
"color.saturation": "Saturation",
|
|
155
|
+
"color.brightness": "Brightness",
|
|
156
|
+
"font.search": "Search fonts",
|
|
157
|
+
"font.families": "Font families",
|
|
158
|
+
"font.weight": "Weight",
|
|
159
|
+
"weight.100": "Thin",
|
|
160
|
+
"weight.200": "Extra light",
|
|
161
|
+
"weight.300": "Light",
|
|
162
|
+
"weight.400": "Regular",
|
|
163
|
+
"weight.500": "Medium",
|
|
164
|
+
"weight.600": "Semibold",
|
|
165
|
+
"weight.700": "Bold",
|
|
166
|
+
"weight.800": "Extra bold",
|
|
167
|
+
"weight.900": "Black",
|
|
168
|
+
"color.palette": "Palette",
|
|
169
|
+
"color.space": "Color space",
|
|
170
|
+
"color.hue": "Hue",
|
|
171
|
+
"color.alpha": "Opacity",
|
|
172
|
+
"color.none": "No color",
|
|
173
|
+
"color.transparent": "Transparent",
|
|
174
|
+
"color.format": "Format",
|
|
175
|
+
"color.hex": "Hex",
|
|
176
|
+
"color.rgb": "RGB",
|
|
177
|
+
"color.hsl": "HSL",
|
|
178
|
+
"color.red": "Red",
|
|
179
|
+
"color.green": "Green",
|
|
180
|
+
"color.blue": "Blue",
|
|
181
|
+
"color.lightness": "Lightness",
|
|
182
|
+
"color.eyedropper": "Pick a color from the screen",
|
|
183
|
+
"color.recents": "Recent colors",
|
|
184
|
+
"paint.type": "Paint type",
|
|
185
|
+
"paint.solid": "Solid",
|
|
186
|
+
"paint.gradient": "Gradient",
|
|
187
|
+
"paint.linear": "Linear",
|
|
188
|
+
"paint.radial": "Radial",
|
|
189
|
+
"paint.angle": "Angle",
|
|
190
|
+
"paint.rotate": "Rotate 90°",
|
|
191
|
+
"paint.flip": "Flip",
|
|
192
|
+
"paint.centerX": "Center X",
|
|
193
|
+
"paint.centerY": "Center Y",
|
|
194
|
+
"paint.radius": "Radius",
|
|
195
|
+
"paint.centerX.short": "X",
|
|
196
|
+
"paint.centerY.short": "Y",
|
|
197
|
+
"paint.radius.short": "R",
|
|
198
|
+
"paint.stops": "Stops",
|
|
199
|
+
"paint.stop": "Stop",
|
|
200
|
+
"paint.addStop": "Add stop",
|
|
201
|
+
"paint.removeStop": "Remove stop",
|
|
202
|
+
"paint.position": "Position",
|
|
203
|
+
"paint.stopColor": "Stop color",
|
|
204
|
+
"paint.back": "Back to the gradient",
|
|
205
|
+
"selection.stickyColor": "Sticky color",
|
|
206
|
+
"selection.borderStyle": "Border style",
|
|
207
|
+
"selection.lineEnds": "Line ends",
|
|
208
|
+
"selection.connectorType": "Connector type",
|
|
209
|
+
"selection.moreStyles": "More text styles",
|
|
210
|
+
"selection.textOptions": "Text options",
|
|
211
|
+
"selection.more": "More",
|
|
212
|
+
"selection.locationAndSize": "Location and size",
|
|
213
|
+
"selection.multipleFills": "Multiple fills",
|
|
214
|
+
"selection.swap": "Swap the ends",
|
|
215
|
+
"selection.sizeDown": "Decrease font size",
|
|
216
|
+
"selection.sizeUp": "Increase font size",
|
|
217
|
+
"selection.corners": "Individual corners",
|
|
218
|
+
"selection.sides": "Visible sides",
|
|
219
|
+
"selection.padding": "Padding",
|
|
220
|
+
"selection.presets": "Presets",
|
|
221
|
+
"side.top": "Top",
|
|
222
|
+
"side.right": "Right",
|
|
223
|
+
"side.bottom": "Bottom",
|
|
224
|
+
"side.left": "Left",
|
|
225
|
+
"side.top.short": "T",
|
|
226
|
+
"side.right.short": "R",
|
|
227
|
+
"side.bottom.short": "B",
|
|
228
|
+
"side.left.short": "L",
|
|
229
|
+
"shadow.x.short": "X",
|
|
230
|
+
"shadow.y.short": "Y",
|
|
231
|
+
"shadow.blur.short": "B",
|
|
232
|
+
"shadow.spread.short": "S",
|
|
233
|
+
"connector.rounded": "Rounded",
|
|
234
|
+
"connector.sharp": "Sharp",
|
|
235
|
+
"connector.line": "Line",
|
|
236
|
+
"connector.curved": "Curved",
|
|
237
|
+
"list.none": "No list",
|
|
238
|
+
"list.bullet": "Bulleted list",
|
|
239
|
+
"list.number": "Numbered list",
|
|
240
|
+
"list.task": "Task list",
|
|
241
|
+
"align.left": "Align left",
|
|
242
|
+
"align.center": "Align center",
|
|
243
|
+
"align.right": "Align right",
|
|
244
|
+
"align.justify": "Justify",
|
|
245
|
+
"valign.top": "Align top",
|
|
246
|
+
"valign.middle": "Align middle",
|
|
247
|
+
"valign.bottom": "Align bottom",
|
|
248
|
+
"case.none": "As typed",
|
|
249
|
+
"case.upper": "Uppercase",
|
|
250
|
+
"case.lower": "Lowercase",
|
|
251
|
+
"dash.solid": "Solid",
|
|
252
|
+
"dash.dash": "Dashed",
|
|
253
|
+
"dash.longDash": "Long dashes",
|
|
254
|
+
"dash.shortDash": "Short dashes",
|
|
255
|
+
"dash.dot": "Dotted",
|
|
256
|
+
"dash.dashDot": "Dash dot",
|
|
257
|
+
"dash.dashDotDot": "Dash dot dot",
|
|
258
|
+
"arrow.none": "None",
|
|
259
|
+
"arrow.arrow": "Arrow",
|
|
260
|
+
"arrow.triangle": "Triangle",
|
|
261
|
+
"arrow.triangle-open": "Open triangle",
|
|
262
|
+
"arrow.triangle-skinny": "Narrow triangle",
|
|
263
|
+
"arrow.circle": "Circle",
|
|
264
|
+
"arrow.circle-open": "Open circle",
|
|
265
|
+
"arrow.diamond": "Diamond",
|
|
266
|
+
"arrow.diamond-open": "Open diamond",
|
|
267
|
+
"arrow.square": "Square",
|
|
268
|
+
"arrow.square-open": "Open square",
|
|
269
|
+
"arrow.bar": "Bar",
|
|
270
|
+
"arrow.crow": "Crow's foot",
|
|
271
|
+
};
|
|
272
|
+
export class Strings {
|
|
273
|
+
overrides;
|
|
274
|
+
constructor(overrides = {}) {
|
|
275
|
+
this.overrides = overrides;
|
|
276
|
+
}
|
|
277
|
+
t(key) {
|
|
278
|
+
return this.overrides[key] ?? DEFAULT_STRINGS[key];
|
|
279
|
+
}
|
|
280
|
+
label(descriptorKey, registryLabel) {
|
|
281
|
+
return this.overrides[`key:${descriptorKey}`] ?? registryLabel;
|
|
282
|
+
}
|
|
283
|
+
option(descriptorKey, value) {
|
|
284
|
+
const k = `option.${value}`;
|
|
285
|
+
return this.overrides[`key:${descriptorKey}.${value}`] ?? (k in DEFAULT_STRINGS ? this.t(k) : value);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PropertyValue, SceneObject, ToolName } from "@daasboard/editor";
|
|
2
|
+
import { UiElement } from "./element.js";
|
|
3
|
+
import type { UiHost } from "./host.js";
|
|
4
|
+
import type { ResolvedOptions } from "./options.js";
|
|
5
|
+
export interface UiState {
|
|
6
|
+
readonly host: UiHost;
|
|
7
|
+
readonly options: ResolvedOptions;
|
|
8
|
+
readonly values: Readonly<Record<string, PropertyValue>>;
|
|
9
|
+
readonly targets: readonly SceneObject[];
|
|
10
|
+
readonly tool: ToolName;
|
|
11
|
+
readonly readOnly: boolean;
|
|
12
|
+
readonly textSession: boolean;
|
|
13
|
+
readonly gesture: boolean;
|
|
14
|
+
readonly revision: number;
|
|
15
|
+
readonly zoom: number;
|
|
16
|
+
}
|
|
17
|
+
export type Dock = "top" | "bottom" | "left" | "right" | "float" | "container";
|
|
18
|
+
export declare const ALL_KEYS: readonly string[];
|
|
19
|
+
export declare class UiSurface extends UiElement {
|
|
20
|
+
static properties: {
|
|
21
|
+
state: {
|
|
22
|
+
attribute: boolean;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
state: UiState | undefined;
|
|
26
|
+
keys(): readonly string[];
|
|
27
|
+
}
|
package/dist/surface.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { UiClipboard } from "../../host.js";
|
|
2
|
+
import type { ResolvedOptions } from "../../options.js";
|
|
3
|
+
export type ContextItem = "cut" | "copy" | "paste" | "duplicate" | "delete";
|
|
4
|
+
export interface ContextState {
|
|
5
|
+
readonly selected: boolean;
|
|
6
|
+
readonly readOnly: boolean;
|
|
7
|
+
readonly text: boolean;
|
|
8
|
+
readonly allows?: ((operation: string) => boolean) | undefined;
|
|
9
|
+
readonly clipboard?: Pick<UiClipboard, "canCopy" | "canPaste"> | undefined;
|
|
10
|
+
canRun(command: "duplicate" | "delete"): boolean | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function contextItems(s: ContextState): (ContextItem | "|")[];
|
|
13
|
+
export declare function itemEnabled(s: ContextState, item: ContextItem): boolean;
|
|
14
|
+
export declare function itemShortcut(options: ResolvedOptions, item: ContextItem): string | undefined;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { itemList, shortcutOf } from "../selection-toolbar/items.js";
|
|
2
|
+
const CLIPBOARD = ["cut", "copy", "paste"];
|
|
3
|
+
const COMMANDS = ["duplicate", "delete"];
|
|
4
|
+
function offered(s, item) {
|
|
5
|
+
if (s.readOnly && item !== "copy")
|
|
6
|
+
return false;
|
|
7
|
+
if (item === "duplicate" || item === "delete")
|
|
8
|
+
return s.selected && !s.text && s.allows?.(`command:${item}`) !== false && s.canRun(item) !== null;
|
|
9
|
+
if (!s.clipboard || s.allows?.(item) === false)
|
|
10
|
+
return false;
|
|
11
|
+
return item === "paste" ? s.clipboard.canPaste() : s.selected || s.text;
|
|
12
|
+
}
|
|
13
|
+
export function contextItems(s) {
|
|
14
|
+
const clipboard = CLIPBOARD.filter((item) => offered(s, item));
|
|
15
|
+
const commands = COMMANDS.filter((item) => offered(s, item));
|
|
16
|
+
return clipboard.length > 0 && commands.length > 0 ? [...clipboard, "|", ...commands] : [...clipboard, ...commands];
|
|
17
|
+
}
|
|
18
|
+
export function itemEnabled(s, item) {
|
|
19
|
+
if (item === "cut" || item === "copy")
|
|
20
|
+
return s.clipboard?.canCopy() ?? false;
|
|
21
|
+
if (item === "duplicate" || item === "delete")
|
|
22
|
+
return s.canRun(item) === true;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
export function itemShortcut(options, item) {
|
|
26
|
+
switch (item) {
|
|
27
|
+
case "cut":
|
|
28
|
+
return "Mod+X";
|
|
29
|
+
case "copy":
|
|
30
|
+
return "Mod+C";
|
|
31
|
+
case "paste":
|
|
32
|
+
return "Mod+V";
|
|
33
|
+
case "duplicate":
|
|
34
|
+
return options.selectionToolbar !== false && itemList(options.selectionToolbar.items).includes("more") ? shortcutOf("duplicate", options.shortcuts) : undefined;
|
|
35
|
+
case "delete":
|
|
36
|
+
return "Delete";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { UiElement } from "../../element.js";
|
|
2
|
+
import type { UiHost, UiPoint } from "../../host.js";
|
|
3
|
+
export declare const CONTEXT_MENU_TAG = "daas-context-menu";
|
|
4
|
+
export declare class ContextMenu extends UiElement {
|
|
5
|
+
#private;
|
|
6
|
+
static styles: import("lit").CSSResult[];
|
|
7
|
+
host: UiHost | null;
|
|
8
|
+
gesturing: () => boolean;
|
|
9
|
+
get open(): boolean;
|
|
10
|
+
show(at: UiPoint | null): boolean;
|
|
11
|
+
hide(): void;
|
|
12
|
+
scopeChanged(): void;
|
|
13
|
+
disconnectedCallback(): void;
|
|
14
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
15
|
+
}
|
|
16
|
+
export declare function defineContextMenu(): void;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { baseStyles } from "../../controls/shared.js";
|
|
3
|
+
import { UiElement } from "../../element.js";
|
|
4
|
+
import { contextItems, itemEnabled, itemShortcut } from "./items.js";
|
|
5
|
+
export const CONTEXT_MENU_TAG = "daas-context-menu";
|
|
6
|
+
const LABELS = { cut: "command.cut", copy: "command.copy", paste: "command.paste", duplicate: "command.duplicate", delete: "command.delete" };
|
|
7
|
+
const styles = css `:host{position:absolute;left:0;top:0;width:0;height:0;pointer-events:none;}.anchor{position:absolute;width:0;height:0;}daas-menu{pointer-events:auto;}`;
|
|
8
|
+
export class ContextMenu extends UiElement {
|
|
9
|
+
static styles = [baseStyles, styles];
|
|
10
|
+
host = null;
|
|
11
|
+
gesturing = () => false;
|
|
12
|
+
#at = null;
|
|
13
|
+
#anchor = { x: 0, y: 0 };
|
|
14
|
+
#entries = [];
|
|
15
|
+
#turn = 0;
|
|
16
|
+
#stops = [];
|
|
17
|
+
get open() {
|
|
18
|
+
return this.#menu()?.open ?? false;
|
|
19
|
+
}
|
|
20
|
+
show(at) {
|
|
21
|
+
const host = this.host;
|
|
22
|
+
const s = host && this.#state(host);
|
|
23
|
+
const items = s ? contextItems(s) : [];
|
|
24
|
+
if (!host || !s || !items.some((item) => item !== "|" && itemEnabled(s, item))) {
|
|
25
|
+
this.hide();
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const pasteLabel = at && !s.text ? "command.pasteHere" : "command.paste";
|
|
29
|
+
const options = this.ui?.options;
|
|
30
|
+
this.#entries = items.map((item) => {
|
|
31
|
+
if (item === "|")
|
|
32
|
+
return "separator";
|
|
33
|
+
const shortcut = options && itemShortcut(options, item);
|
|
34
|
+
return { value: item, label: this.t(item === "paste" ? pasteLabel : LABELS[item]), disabled: !itemEnabled(s, item), ...(shortcut ? { shortcut } : {}) };
|
|
35
|
+
});
|
|
36
|
+
this.#at = at;
|
|
37
|
+
this.#anchor = at ?? this.#belowSelection(host);
|
|
38
|
+
const turn = ++this.#turn;
|
|
39
|
+
this.requestUpdate();
|
|
40
|
+
void this.updateComplete.then(async () => {
|
|
41
|
+
const menu = this.#menu();
|
|
42
|
+
if (turn !== this.#turn || !menu)
|
|
43
|
+
return;
|
|
44
|
+
if (menu.open)
|
|
45
|
+
menu.hide();
|
|
46
|
+
const zoom = host.camera.zoom();
|
|
47
|
+
this.#stops.push(host.camera.onChange(() => (this.gesturing() || host.camera.zoom() !== zoom) && this.hide()));
|
|
48
|
+
await menu.show(this.renderRoot.querySelector(".anchor"), "first");
|
|
49
|
+
if (turn === this.#turn && !menu.open)
|
|
50
|
+
this.#unwatch();
|
|
51
|
+
});
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
hide() {
|
|
55
|
+
this.#turn++;
|
|
56
|
+
this.#unwatch();
|
|
57
|
+
const menu = this.#menu();
|
|
58
|
+
if (menu?.open)
|
|
59
|
+
menu.hide();
|
|
60
|
+
}
|
|
61
|
+
scopeChanged() {
|
|
62
|
+
this.hide();
|
|
63
|
+
}
|
|
64
|
+
disconnectedCallback() {
|
|
65
|
+
this.hide();
|
|
66
|
+
super.disconnectedCallback();
|
|
67
|
+
}
|
|
68
|
+
#state(host) {
|
|
69
|
+
const commands = host.controller.commands;
|
|
70
|
+
return {
|
|
71
|
+
selected: host.controller.targets().length > 0,
|
|
72
|
+
readOnly: host.readOnly(),
|
|
73
|
+
text: host.controller.textTarget() !== null,
|
|
74
|
+
allows: host.allows,
|
|
75
|
+
clipboard: host.clipboard,
|
|
76
|
+
canRun: (name) => {
|
|
77
|
+
const command = commands[name];
|
|
78
|
+
return command ? command.canRun() : null;
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
#belowSelection(host) {
|
|
83
|
+
const board = this.getRootNode().host;
|
|
84
|
+
const w = board?.clientWidth ?? 0;
|
|
85
|
+
const h = board?.clientHeight ?? 0;
|
|
86
|
+
const r = host.selectionRect();
|
|
87
|
+
if (!r)
|
|
88
|
+
return { x: w / 2, y: h / 2 };
|
|
89
|
+
const clamp = (v, max) => Math.max(0, Math.min(max, v));
|
|
90
|
+
return { x: clamp(r.x, w), y: clamp(r.y + r.h, h) };
|
|
91
|
+
}
|
|
92
|
+
#menu() {
|
|
93
|
+
return this.renderRoot?.querySelector("daas-menu") ?? null;
|
|
94
|
+
}
|
|
95
|
+
#unwatch() {
|
|
96
|
+
for (const stop of this.#stops.splice(0))
|
|
97
|
+
stop();
|
|
98
|
+
}
|
|
99
|
+
#pick(value) {
|
|
100
|
+
const host = this.host;
|
|
101
|
+
if (!host)
|
|
102
|
+
return;
|
|
103
|
+
const item = value;
|
|
104
|
+
const at = this.#at;
|
|
105
|
+
this.hide();
|
|
106
|
+
if (host.readOnly() && item !== "copy")
|
|
107
|
+
return;
|
|
108
|
+
if (item === "duplicate" || item === "delete") {
|
|
109
|
+
const command = host.controller.commands[item];
|
|
110
|
+
if (host.allows?.(`command:${item}`) !== false && command?.canRun())
|
|
111
|
+
command.run();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const clipboard = host.clipboard;
|
|
115
|
+
if (!clipboard || host.allows?.(item) === false)
|
|
116
|
+
return;
|
|
117
|
+
if (item === "paste")
|
|
118
|
+
clipboard.paste(at);
|
|
119
|
+
else if (clipboard.canCopy())
|
|
120
|
+
clipboard[item]();
|
|
121
|
+
}
|
|
122
|
+
#contextMenuEvent(e) {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
if (e.button !== 2 && !(e.button === 0 && e.ctrlKey && this.ui?.mac))
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
}
|
|
127
|
+
render() {
|
|
128
|
+
const { x, y } = this.#anchor;
|
|
129
|
+
return html `<span class="anchor" style="left:${x}px;top:${y}px"></span><daas-menu part="menu" label=${this.t("surface.contextMenu")} .items=${this.#entries} @daas-commit=${(e) => this.#pick(e.detail)} @daas-close=${() => this.#unwatch()} @contextmenu=${(e) => this.#contextMenuEvent(e)}></daas-menu>`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export function defineContextMenu() {
|
|
133
|
+
if (!customElements.get(CONTEXT_MENU_TAG))
|
|
134
|
+
customElements.define(CONTEXT_MENU_TAG, ContextMenu);
|
|
135
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PaneRoot } from "./outlet.js";
|
|
2
|
+
import { PaneSurface } from "./pane.js";
|
|
3
|
+
import { TextField } from "./text-field.js";
|
|
4
|
+
export { PaneSurface, NARROW_PX, type PaneMode } from "./pane.js";
|
|
5
|
+
export { PaneRoot, PANE_ROOT_TAG } from "./outlet.js";
|
|
6
|
+
export { PanePlacement, PANE_TAG } from "./placement.js";
|
|
7
|
+
export { TextField } from "./text-field.js";
|
|
8
|
+
export { paneModel, SECTION_IDS, SECTION_KEYS, NOT_IN_PANE, type PaneSection, type PaneView, type PaneInput } from "./model.js";
|
|
9
|
+
export declare function definePane(): void;
|
|
10
|
+
declare global {
|
|
11
|
+
interface HTMLElementTagNameMap {
|
|
12
|
+
"daas-text-field": TextField;
|
|
13
|
+
"daas-pane": PaneSurface;
|
|
14
|
+
"daas-ui-pane": PaneRoot;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PaneRoot, PANE_ROOT_TAG } from "./outlet.js";
|
|
2
|
+
import { PaneSurface } from "./pane.js";
|
|
3
|
+
import { PANE_TAG } from "./placement.js";
|
|
4
|
+
import { TextField } from "./text-field.js";
|
|
5
|
+
export { PaneSurface, NARROW_PX } from "./pane.js";
|
|
6
|
+
export { PaneRoot, PANE_ROOT_TAG } from "./outlet.js";
|
|
7
|
+
export { PanePlacement, PANE_TAG } from "./placement.js";
|
|
8
|
+
export { TextField } from "./text-field.js";
|
|
9
|
+
export { paneModel, SECTION_IDS, SECTION_KEYS, NOT_IN_PANE } from "./model.js";
|
|
10
|
+
export function definePane() {
|
|
11
|
+
const tags = [
|
|
12
|
+
["daas-text-field", TextField],
|
|
13
|
+
[PANE_TAG, PaneSurface],
|
|
14
|
+
[PANE_ROOT_TAG, PaneRoot],
|
|
15
|
+
];
|
|
16
|
+
for (const [tag, cls] of tags)
|
|
17
|
+
if (!customElements.get(tag))
|
|
18
|
+
customElements.define(tag, cls);
|
|
19
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PropertyValue } from "@daasboard/editor";
|
|
2
|
+
import type { CustomSection, PaneOptions, SectionId } from "../../options.js";
|
|
3
|
+
export declare const SECTION_IDS: readonly SectionId[];
|
|
4
|
+
type BuiltIn = Exclude<SectionId, "other">;
|
|
5
|
+
export declare const CORNER_KEYS: readonly ["radiusTopLeft", "radiusTopRight", "radiusBottomLeft", "radiusBottomRight"];
|
|
6
|
+
export declare const TEXT_MORE_KEYS: readonly ["bold", "italic", "underline", "strike", "textCase", "list"];
|
|
7
|
+
export declare const SIDE_KEYS: readonly ["strokeTop", "strokeRight", "strokeBottom", "strokeLeft"];
|
|
8
|
+
export declare const STROKE_MORE_KEYS: readonly ["dash", "strokeCapStart", "strokeCapEnd", "strokeJoin"];
|
|
9
|
+
export declare const SHADOW_KEYS: readonly ["shadowX", "shadowBlur", "shadowY", "shadowSpread", "shadowColor"];
|
|
10
|
+
export declare const SECTION_KEYS: Readonly<Record<BuiltIn, readonly string[]>>;
|
|
11
|
+
export declare const NOT_IN_PANE: readonly string[];
|
|
12
|
+
export interface PaneView {
|
|
13
|
+
collapsed: ReadonlySet<string>;
|
|
14
|
+
corners: boolean;
|
|
15
|
+
paddingSides: boolean;
|
|
16
|
+
fillsHeld?: PropertyValue | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface PaneSection {
|
|
19
|
+
id: string;
|
|
20
|
+
custom?: CustomSection;
|
|
21
|
+
rows: readonly string[];
|
|
22
|
+
own: boolean;
|
|
23
|
+
empty: boolean;
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
collapsed: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface PaneInput {
|
|
28
|
+
values: Readonly<Record<string, PropertyValue>>;
|
|
29
|
+
targets: number;
|
|
30
|
+
readOnly: boolean;
|
|
31
|
+
options: PaneOptions;
|
|
32
|
+
view: PaneView;
|
|
33
|
+
replaced?: readonly string[];
|
|
34
|
+
}
|
|
35
|
+
export declare function hiddenKeys(hide: readonly string[] | undefined): Set<string>;
|
|
36
|
+
export declare function shownValues(values: Readonly<Record<string, PropertyValue>>, hide: readonly string[] | undefined): Readonly<Record<string, PropertyValue>>;
|
|
37
|
+
export declare function absent(v: PropertyValue | undefined): boolean;
|
|
38
|
+
export declare function paneModel({ values: all, targets, readOnly, options, view, replaced }: PaneInput): PaneSection[];
|
|
39
|
+
export declare const PADDING_KEYS: string[];
|
|
40
|
+
export declare const ROWS: Readonly<Record<string, Readonly<Record<string, readonly string[]>>>>;
|
|
41
|
+
export {};
|