@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
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export const LUCIDE_VERSION = "1.55.0";
|
|
2
|
+
export const LUCIDE_ICONS = {
|
|
3
|
+
"tool-select": [["path", { "d": "M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z" }]],
|
|
4
|
+
"tool-hand": [["path", { "d": "M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2" }], ["path", { "d": "M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2" }], ["path", { "d": "M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8" }], ["path", { "d": "M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15" }]],
|
|
5
|
+
"tool-rect": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2" }]],
|
|
6
|
+
"tool-ellipse": [["circle", { "cx": "12", "cy": "12", "r": "10" }]],
|
|
7
|
+
"tool-diamond": [["path", { "d": "M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z" }]],
|
|
8
|
+
"tool-triangle": [["path", { "d": "M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }]],
|
|
9
|
+
"tool-image": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2", "ry": "2" }], ["circle", { "cx": "9", "cy": "9", "r": "2" }], ["path", { "d": "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }]],
|
|
10
|
+
"tool-text": [["path", { "d": "M12 4v16" }], ["path", { "d": "M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" }], ["path", { "d": "M9 20h6" }]],
|
|
11
|
+
"tool-sticky": [["path", { "d": "M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z" }], ["path", { "d": "M15 3v5a1 1 0 0 0 1 1h5" }]],
|
|
12
|
+
"tool-connector": [["circle", { "cx": "19", "cy": "5", "r": "2" }], ["circle", { "cx": "5", "cy": "19", "r": "2" }], ["path", { "d": "M5 17A12 12 0 0 1 17 5" }]],
|
|
13
|
+
"tool-frame": [["line", { "x1": "22", "x2": "2", "y1": "6", "y2": "6" }], ["line", { "x1": "22", "x2": "2", "y1": "18", "y2": "18" }], ["line", { "x1": "6", "x2": "6", "y1": "2", "y2": "22" }], ["line", { "x1": "18", "x2": "18", "y1": "2", "y2": "22" }]],
|
|
14
|
+
"tool-section": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2" }], ["path", { "d": "M3 9h18" }]],
|
|
15
|
+
"chevron-down": [["path", { "d": "m6 9 6 6 6-6" }]],
|
|
16
|
+
"chevron-up": [["path", { "d": "m18 15-6-6-6 6" }]],
|
|
17
|
+
"chevron-left": [["path", { "d": "m15 18-6-6 6-6" }]],
|
|
18
|
+
"chevron-right": [["path", { "d": "m9 18 6-6-6-6" }]],
|
|
19
|
+
"more": [["circle", { "cx": "12", "cy": "12", "r": "1" }], ["circle", { "cx": "19", "cy": "12", "r": "1" }], ["circle", { "cx": "5", "cy": "12", "r": "1" }]],
|
|
20
|
+
"more-vertical": [["circle", { "cx": "12", "cy": "12", "r": "1" }], ["circle", { "cx": "12", "cy": "5", "r": "1" }], ["circle", { "cx": "12", "cy": "19", "r": "1" }]],
|
|
21
|
+
"plus": [["path", { "d": "M5 12h14" }], ["path", { "d": "M12 5v14" }]],
|
|
22
|
+
"minus": [["path", { "d": "M5 12h14" }]],
|
|
23
|
+
"close": [["path", { "d": "M18 6 6 18" }], ["path", { "d": "m6 6 12 12" }]],
|
|
24
|
+
"check": [["path", { "d": "M20 6 9 17l-5-5" }]],
|
|
25
|
+
"search": [["path", { "d": "m21 21-4.34-4.34" }], ["circle", { "cx": "11", "cy": "11", "r": "8" }]],
|
|
26
|
+
"panel": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2" }], ["path", { "d": "M15 3v18" }]],
|
|
27
|
+
"settings": [["path", { "d": "M14 17H5" }], ["path", { "d": "M19 7h-9" }], ["circle", { "cx": "17", "cy": "17", "r": "3" }], ["circle", { "cx": "7", "cy": "7", "r": "3" }]],
|
|
28
|
+
"zoom-in": [["circle", { "cx": "11", "cy": "11", "r": "8" }], ["line", { "x1": "21", "x2": "16.65", "y1": "21", "y2": "16.65" }], ["line", { "x1": "11", "x2": "11", "y1": "8", "y2": "14" }], ["line", { "x1": "8", "x2": "14", "y1": "11", "y2": "11" }]],
|
|
29
|
+
"zoom-out": [["circle", { "cx": "11", "cy": "11", "r": "8" }], ["line", { "x1": "21", "x2": "16.65", "y1": "21", "y2": "16.65" }], ["line", { "x1": "8", "x2": "14", "y1": "11", "y2": "11" }]],
|
|
30
|
+
"undo": [["path", { "d": "M9 14 4 9l5-5" }], ["path", { "d": "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" }]],
|
|
31
|
+
"redo": [["path", { "d": "m15 14 5-5-5-5" }], ["path", { "d": "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" }]],
|
|
32
|
+
"delete": [["path", { "d": "M10 11v6" }], ["path", { "d": "M14 11v6" }], ["path", { "d": "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }], ["path", { "d": "M3 6h18" }], ["path", { "d": "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }]],
|
|
33
|
+
"duplicate": [["rect", { "width": "14", "height": "14", "x": "8", "y": "8", "rx": "2", "ry": "2" }], ["path", { "d": "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" }]],
|
|
34
|
+
"lock": [["rect", { "width": "18", "height": "11", "x": "3", "y": "11", "rx": "2", "ry": "2" }], ["path", { "d": "M7 11V7a5 5 0 0 1 10 0v4" }]],
|
|
35
|
+
"unlock": [["rect", { "width": "18", "height": "11", "x": "3", "y": "11", "rx": "2", "ry": "2" }], ["path", { "d": "M7 11V7a5 5 0 0 1 9.9-1" }]],
|
|
36
|
+
"swap": [["path", { "d": "M8 3 4 7l4 4" }], ["path", { "d": "M4 7h16" }], ["path", { "d": "m16 21 4-4-4-4" }], ["path", { "d": "M20 17H4" }]],
|
|
37
|
+
"fill": [["path", { "d": "M11 7 6 2" }], ["path", { "d": "M18.992 12H2.041" }], ["path", { "d": "M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" }], ["path", { "d": "m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" }]],
|
|
38
|
+
"stroke": [["path", { "d": "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" }], ["path", { "d": "m15 5 4 4" }]],
|
|
39
|
+
"eyedropper": [["path", { "d": "m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12" }], ["path", { "d": "m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z" }], ["path", { "d": "m2 22 .414-.414" }]],
|
|
40
|
+
"palette": [["path", { "d": "M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z" }], ["circle", { "cx": "13.5", "cy": "6.5", "r": ".5", "fill": "currentColor" }], ["circle", { "cx": "17.5", "cy": "10.5", "r": ".5", "fill": "currentColor" }], ["circle", { "cx": "6.5", "cy": "12.5", "r": ".5", "fill": "currentColor" }], ["circle", { "cx": "8.5", "cy": "7.5", "r": ".5", "fill": "currentColor" }]],
|
|
41
|
+
"color-space": [["path", { "d": "M5 3a2 2 0 0 0-2 2" }], ["path", { "d": "M19 3a2 2 0 0 1 2 2" }], ["path", { "d": "M21 19a2 2 0 0 1-2 2" }], ["path", { "d": "M5 21a2 2 0 0 1-2-2" }], ["path", { "d": "M9 3h1" }], ["path", { "d": "M9 21h1" }], ["path", { "d": "M14 3h1" }], ["path", { "d": "M14 21h1" }], ["path", { "d": "M3 9v1" }], ["path", { "d": "M21 9v1" }], ["path", { "d": "M3 14v1" }], ["path", { "d": "M21 14v1" }]],
|
|
42
|
+
"gradient": [["circle", { "cx": "15", "cy": "9", "r": "7" }], ["circle", { "cx": "9", "cy": "15", "r": "7" }]],
|
|
43
|
+
"no-color": [["circle", { "cx": "12", "cy": "12", "r": "10" }], ["path", { "d": "M4.929 4.929 19.07 19.071" }]],
|
|
44
|
+
"opacity": [["path", { "d": "M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z" }]],
|
|
45
|
+
"rotate-90": [["path", { "d": "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8" }], ["path", { "d": "M21 3v5h-5" }]],
|
|
46
|
+
"flip": [["path", { "d": "m16 3 4 4-4 4" }], ["path", { "d": "M20 7H4" }], ["path", { "d": "m8 21-4-4 4-4" }], ["path", { "d": "M4 17h16" }]],
|
|
47
|
+
"bold": [["path", { "d": "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" }]],
|
|
48
|
+
"italic": [["line", { "x1": "19", "x2": "10", "y1": "4", "y2": "4" }], ["line", { "x1": "14", "x2": "5", "y1": "20", "y2": "20" }], ["line", { "x1": "15", "x2": "9", "y1": "4", "y2": "20" }]],
|
|
49
|
+
"underline": [["path", { "d": "M6 4v6a6 6 0 0 0 12 0V4" }], ["line", { "x1": "4", "x2": "20", "y1": "20", "y2": "20" }]],
|
|
50
|
+
"strike": [["path", { "d": "M16 4H9a3 3 0 0 0-2.83 4" }], ["path", { "d": "M14 12a4 4 0 0 1 0 8H6" }], ["line", { "x1": "4", "x2": "20", "y1": "12", "y2": "12" }]],
|
|
51
|
+
"text-color": [["path", { "d": "M4 20h16" }], ["path", { "d": "m6 16 6-12 6 12" }], ["path", { "d": "M8 12h8" }]],
|
|
52
|
+
"case-none": [["path", { "d": "m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16" }], ["path", { "d": "M22 9v7" }], ["path", { "d": "M3.304 13h6.392" }], ["circle", { "cx": "18.5", "cy": "12.5", "r": "3.5" }]],
|
|
53
|
+
"case-upper": [["path", { "d": "M15 11h4.5a1 1 0 0 1 0 5h-4a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h3a1 1 0 0 1 0 5" }], ["path", { "d": "m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16" }], ["path", { "d": "M3.304 13h6.392" }]],
|
|
54
|
+
"case-lower": [["path", { "d": "M10 9v7" }], ["path", { "d": "M14 6v10" }], ["circle", { "cx": "17.5", "cy": "12.5", "r": "3.5" }], ["circle", { "cx": "6.5", "cy": "12.5", "r": "3.5" }]],
|
|
55
|
+
"list-none": [["path", { "d": "M3 5h18" }], ["path", { "d": "M3 12h18" }], ["path", { "d": "M3 19h18" }]],
|
|
56
|
+
"list-bullet": [["path", { "d": "M3 5h.01" }], ["path", { "d": "M3 12h.01" }], ["path", { "d": "M3 19h.01" }], ["path", { "d": "M8 5h13" }], ["path", { "d": "M8 12h13" }], ["path", { "d": "M8 19h13" }]],
|
|
57
|
+
"list-number": [["path", { "d": "M11 5h10" }], ["path", { "d": "M11 12h10" }], ["path", { "d": "M11 19h10" }], ["path", { "d": "M4 4h1v5" }], ["path", { "d": "M4 9h2" }], ["path", { "d": "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" }]],
|
|
58
|
+
"list-task": [["path", { "d": "M13 5h8" }], ["path", { "d": "M13 12h8" }], ["path", { "d": "M13 19h8" }], ["path", { "d": "m3 17 2 2 4-4" }], ["rect", { "x": "3", "y": "4", "width": "6", "height": "6", "rx": "1" }]],
|
|
59
|
+
"align-left": [["path", { "d": "M21 5H3" }], ["path", { "d": "M15 12H3" }], ["path", { "d": "M17 19H3" }]],
|
|
60
|
+
"align-center": [["path", { "d": "M21 5H3" }], ["path", { "d": "M17 12H7" }], ["path", { "d": "M19 19H5" }]],
|
|
61
|
+
"align-right": [["path", { "d": "M21 5H3" }], ["path", { "d": "M21 12H9" }], ["path", { "d": "M21 19H7" }]],
|
|
62
|
+
"align-justify": [["path", { "d": "M3 5h18" }], ["path", { "d": "M3 12h18" }], ["path", { "d": "M3 19h18" }]],
|
|
63
|
+
"valign-top": [["rect", { "width": "14", "height": "6", "x": "5", "y": "16", "rx": "2" }], ["rect", { "width": "10", "height": "6", "x": "7", "y": "6", "rx": "2" }], ["path", { "d": "M2 2h20" }]],
|
|
64
|
+
"valign-middle": [["rect", { "width": "14", "height": "6", "x": "5", "y": "16", "rx": "2" }], ["rect", { "width": "10", "height": "6", "x": "7", "y": "2", "rx": "2" }], ["path", { "d": "M2 12h20" }]],
|
|
65
|
+
"valign-bottom": [["rect", { "width": "14", "height": "6", "x": "5", "y": "12", "rx": "2" }], ["rect", { "width": "10", "height": "6", "x": "7", "y": "2", "rx": "2" }], ["path", { "d": "M2 22h20" }]],
|
|
66
|
+
"line-height": [["rect", { "width": "13", "height": "7", "x": "8", "y": "3", "rx": "1" }], ["path", { "d": "m2 9 3 3-3 3" }], ["rect", { "width": "13", "height": "7", "x": "8", "y": "14", "rx": "1" }]],
|
|
67
|
+
"letter-spacing": [["path", { "d": "m18 8 4 4-4 4" }], ["path", { "d": "M2 12h20" }], ["path", { "d": "m6 8-4 4 4 4" }]],
|
|
68
|
+
"padding": [["path", { "d": "M3 7V5a2 2 0 0 1 2-2h2" }], ["path", { "d": "M17 3h2a2 2 0 0 1 2 2v2" }], ["path", { "d": "M21 17v2a2 2 0 0 1-2 2h-2" }], ["path", { "d": "M7 21H5a2 2 0 0 1-2-2v-2" }]],
|
|
69
|
+
"link": [["path", { "d": "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }], ["path", { "d": "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" }]],
|
|
70
|
+
"border-style": [["path", { "d": "M5 3a2 2 0 0 0-2 2" }], ["path", { "d": "M19 3a2 2 0 0 1 2 2" }], ["path", { "d": "M21 19a2 2 0 0 1-2 2" }], ["path", { "d": "M5 21a2 2 0 0 1-2-2" }], ["path", { "d": "M9 3h1" }], ["path", { "d": "M9 21h1" }], ["path", { "d": "M14 3h1" }], ["path", { "d": "M14 21h1" }], ["path", { "d": "M3 9v1" }], ["path", { "d": "M21 9v1" }], ["path", { "d": "M3 14v1" }], ["path", { "d": "M21 14v1" }]],
|
|
71
|
+
"line-style": [["path", { "d": "M11 5h2" }], ["path", { "d": "M15 12h6" }], ["path", { "d": "M19 5h2" }], ["path", { "d": "M3 12h6" }], ["path", { "d": "M3 19h18" }], ["path", { "d": "M3 5h2" }]],
|
|
72
|
+
"line-ends": [["path", { "d": "M18 8L22 12L18 16" }], ["path", { "d": "M2 12H22" }]],
|
|
73
|
+
"connector-line": [["path", { "d": "M13 5H19V11" }], ["path", { "d": "M19 5L5 19" }]],
|
|
74
|
+
"connector-sharp": [["path", { "d": "m15 10 5 5-5 5" }], ["path", { "d": "M4 4v7a4 4 0 0 0 4 4h12" }]],
|
|
75
|
+
"connector-rounded": [["circle", { "cx": "6", "cy": "19", "r": "3" }], ["path", { "d": "M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15" }], ["circle", { "cx": "18", "cy": "5", "r": "3" }]],
|
|
76
|
+
"connector-curved": [["circle", { "cx": "19", "cy": "5", "r": "2" }], ["circle", { "cx": "5", "cy": "19", "r": "2" }], ["path", { "d": "M5 17A12 12 0 0 1 17 5" }]],
|
|
77
|
+
"corner-radius": [["path", { "d": "M21 11a8 8 0 0 0-8-8" }], ["path", { "d": "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }]],
|
|
78
|
+
"corners": [["path", { "d": "M8 3H5a2 2 0 0 0-2 2v3" }], ["path", { "d": "M21 8V5a2 2 0 0 0-2-2h-3" }], ["path", { "d": "M3 16v3a2 2 0 0 0 2 2h3" }], ["path", { "d": "M16 21h3a2 2 0 0 0 2-2v-3" }]],
|
|
79
|
+
"sides": [["rect", { "width": "18", "height": "18", "x": "3", "y": "3", "rx": "2" }]],
|
|
80
|
+
"shadow": [["path", { "d": "M4 10c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2" }], ["path", { "d": "M10 16c-1.1 0-2-.9-2-2v-4c0-1.1.9-2 2-2h4c1.1 0 2 .9 2 2" }], ["rect", { "width": "8", "height": "8", "x": "14", "y": "14", "rx": "2" }]],
|
|
81
|
+
"rotation": [["path", { "d": "M12 5H6a2 2 0 0 0-2 2v3" }], ["path", { "d": "m9 8 3-3-3-3" }], ["path", { "d": "M4 14v4a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2" }]],
|
|
82
|
+
"align-objects-left": [["rect", { "width": "9", "height": "6", "x": "6", "y": "14", "rx": "2" }], ["rect", { "width": "16", "height": "6", "x": "6", "y": "4", "rx": "2" }], ["path", { "d": "M2 2v20" }]],
|
|
83
|
+
"align-objects-center": [["path", { "d": "M12 2v20" }], ["path", { "d": "M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" }], ["path", { "d": "M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" }], ["path", { "d": "M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" }], ["path", { "d": "M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" }]],
|
|
84
|
+
"align-objects-right": [["rect", { "width": "16", "height": "6", "x": "2", "y": "4", "rx": "2" }], ["rect", { "width": "9", "height": "6", "x": "9", "y": "14", "rx": "2" }], ["path", { "d": "M22 22V2" }]],
|
|
85
|
+
"align-objects-top": [["rect", { "width": "6", "height": "16", "x": "4", "y": "6", "rx": "2" }], ["rect", { "width": "6", "height": "9", "x": "14", "y": "6", "rx": "2" }], ["path", { "d": "M22 2H2" }]],
|
|
86
|
+
"align-objects-middle": [["path", { "d": "M2 12h20" }], ["path", { "d": "M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4" }], ["path", { "d": "M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4" }], ["path", { "d": "M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1" }], ["path", { "d": "M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1" }]],
|
|
87
|
+
"align-objects-bottom": [["rect", { "width": "6", "height": "16", "x": "4", "y": "2", "rx": "2" }], ["rect", { "width": "6", "height": "9", "x": "14", "y": "9", "rx": "2" }], ["path", { "d": "M22 22H2" }]],
|
|
88
|
+
"distribute-horizontal": [["rect", { "width": "6", "height": "14", "x": "4", "y": "5", "rx": "2" }], ["rect", { "width": "6", "height": "10", "x": "14", "y": "7", "rx": "2" }], ["path", { "d": "M17 22v-5" }], ["path", { "d": "M17 7V2" }], ["path", { "d": "M7 22v-3" }], ["path", { "d": "M7 5V2" }]],
|
|
89
|
+
"distribute-vertical": [["path", { "d": "M22 17h-3" }], ["path", { "d": "M22 7h-5" }], ["path", { "d": "M5 17H2" }], ["path", { "d": "M7 7H2" }], ["rect", { "x": "5", "y": "14", "width": "14", "height": "6", "rx": "2" }], ["rect", { "x": "7", "y": "4", "width": "10", "height": "6", "rx": "2" }]],
|
|
90
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { mountUi } from "./mount.js";
|
|
2
|
+
export { mergeOptions } from "./options.js";
|
|
3
|
+
export type { UiHost, UiController, UiTools, UiCamera, UiHandle, UiFrameStats, UiInsets, UiRect, UiPoint, UiClipboard, ZoomLevel, FontFamilyInfo, ColorToken, UiGradientTarget, UiGradientEdit, UiGradientHandleEvents, UiGradientHandles, } from "./host.js";
|
|
4
|
+
export type { UiOptions, ColorOptions, RecentsStore, GradientType, ColorFormat, PickerMode, CommandName, CustomTool, ToolGroup, ToolbarToolName, ItemId, ItemList, SectionId, ItemContext, SectionContext, CustomItem, CustomSection, ControlContext, ControlFactory, ToolbarOptions, SelectionToolbarOptions, PaneOptions, } from "./options.js";
|
|
5
|
+
export { DEFAULT_TOOL_SHORTCUTS } from "./keys.js";
|
|
6
|
+
export { LIGHT_TOKENS, DARK_TOKENS, type ThemeTokens, type ThemeName } from "./theme.js";
|
|
7
|
+
export { DEFAULT_STRINGS, type UiStrings, type StringKey } from "./strings.js";
|
|
8
|
+
export { ICON_NAMES, LUCIDE_VERSION, type IconName, type IconNode, type IconOverride } from "./icons/index.js";
|
|
9
|
+
export { memoryPrefs, localStoragePrefs, type PrefsStore } from "./prefs.js";
|
|
10
|
+
export { defineControls, IconButton, ToggleButton, SegmentedControl, NumberField, Slider, ColorArea, Popover, Menu, Select, Swatch, FontPicker, PREVIEW, COMMIT, CANCEL, type Segment, type MenuItem, type MenuEntry, type SelectOption, type AreaValue, type FontChoice, } from "./controls/index.js";
|
|
11
|
+
export { applyPaintEdit, angleOf, axisForAngle, axisFromPoints, pointsOfAxis, paintCss, convertPaint, parseHex, formatHex, type PaintEdit, type PaintType, type Box, type Rgba, type Hsv, } from "./color/index.js";
|
|
12
|
+
export { definePicker, PaintPicker, DEFAULT_PALETTE, canvasHandles, type CanvasHandles } from "./picker/index.js";
|
|
13
|
+
export { definePane, SECTION_IDS, NARROW_PX, type PaneMode } from "./surfaces/pane/index.js";
|
|
14
|
+
export { memoryRecents, paintKey } from "./recents.js";
|
|
15
|
+
export { SelectionToolbar, defineSelectionToolbar, SELECTION_TOOLBAR_TAG, DEFAULT_ITEMS as DEFAULT_SELECTION_ITEMS, SIZE_LADDER, SELECTION_SHORTCUTS } from "./surfaces/selection-toolbar/index.js";
|
|
16
|
+
export { ToolsToolbar, defineToolsToolbar, TOOLS_TAG } from "./surfaces/tools/index.js";
|
|
17
|
+
export { ContextMenu, defineContextMenu, CONTEXT_MENU_TAG } from "./surfaces/context-menu/index.js";
|
|
18
|
+
export { STICKY_COLORS, type StickyColor } from "./palette.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { mountUi } from "./mount.js";
|
|
2
|
+
export { mergeOptions } from "./options.js";
|
|
3
|
+
export { DEFAULT_TOOL_SHORTCUTS } from "./keys.js";
|
|
4
|
+
export { LIGHT_TOKENS, DARK_TOKENS } from "./theme.js";
|
|
5
|
+
export { DEFAULT_STRINGS } from "./strings.js";
|
|
6
|
+
export { ICON_NAMES, LUCIDE_VERSION } from "./icons/index.js";
|
|
7
|
+
export { memoryPrefs, localStoragePrefs } from "./prefs.js";
|
|
8
|
+
export { defineControls, IconButton, ToggleButton, SegmentedControl, NumberField, Slider, ColorArea, Popover, Menu, Select, Swatch, FontPicker, PREVIEW, COMMIT, CANCEL, } from "./controls/index.js";
|
|
9
|
+
export { applyPaintEdit, angleOf, axisForAngle, axisFromPoints, pointsOfAxis, paintCss, convertPaint, parseHex, formatHex, } from "./color/index.js";
|
|
10
|
+
export { definePicker, PaintPicker, DEFAULT_PALETTE, canvasHandles } from "./picker/index.js";
|
|
11
|
+
export { definePane, SECTION_IDS, NARROW_PX } from "./surfaces/pane/index.js";
|
|
12
|
+
export { memoryRecents, paintKey } from "./recents.js";
|
|
13
|
+
export { SelectionToolbar, defineSelectionToolbar, SELECTION_TOOLBAR_TAG, DEFAULT_ITEMS as DEFAULT_SELECTION_ITEMS, SIZE_LADDER, SELECTION_SHORTCUTS } from "./surfaces/selection-toolbar/index.js";
|
|
14
|
+
export { ToolsToolbar, defineToolsToolbar, TOOLS_TAG } from "./surfaces/tools/index.js";
|
|
15
|
+
export { ContextMenu, defineContextMenu, CONTEXT_MENU_TAG } from "./surfaces/context-menu/index.js";
|
|
16
|
+
export { STICKY_COLORS } from "./palette.js";
|
package/dist/keys.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ToolName } from "@daasboard/editor";
|
|
2
|
+
import type { CommandName, CustomTool, ToolbarOptions } from "./options.js";
|
|
3
|
+
export declare const DEFAULT_TOOL_SHORTCUTS: Readonly<Record<string, string>>;
|
|
4
|
+
export interface Chord {
|
|
5
|
+
key: string;
|
|
6
|
+
ctrl: boolean;
|
|
7
|
+
meta: boolean;
|
|
8
|
+
alt: boolean;
|
|
9
|
+
shift: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseChord(text: string, mac: boolean): Chord | null;
|
|
12
|
+
export declare function matchesChord(c: Chord, e: KeyboardEvent): boolean;
|
|
13
|
+
export declare function formatChord(c: Chord, mac: boolean): string;
|
|
14
|
+
export declare function ariaChord(c: Chord): string;
|
|
15
|
+
export type Binding = {
|
|
16
|
+
chord: Chord;
|
|
17
|
+
tool: ToolName;
|
|
18
|
+
} | {
|
|
19
|
+
chord: Chord;
|
|
20
|
+
custom: CustomTool;
|
|
21
|
+
} | {
|
|
22
|
+
chord: Chord;
|
|
23
|
+
command: CommandName;
|
|
24
|
+
};
|
|
25
|
+
export declare function toolBindings(toolbar: false | ToolbarOptions, overrides: Partial<Record<string, string | null>>, known: readonly ToolName[], mac: boolean): Binding[];
|
|
26
|
+
export declare function bindingAllowed(b: Binding, readOnly: boolean): boolean;
|
|
27
|
+
export declare function isMac(nav?: {
|
|
28
|
+
platform?: string;
|
|
29
|
+
userAgent?: string;
|
|
30
|
+
} | undefined): boolean;
|
package/dist/keys.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export const DEFAULT_TOOL_SHORTCUTS = {
|
|
2
|
+
select: "V",
|
|
3
|
+
hand: "H",
|
|
4
|
+
rect: "R",
|
|
5
|
+
ellipse: "O",
|
|
6
|
+
text: "T",
|
|
7
|
+
sticky: "S",
|
|
8
|
+
connector: "C",
|
|
9
|
+
frame: "F",
|
|
10
|
+
};
|
|
11
|
+
const READ_ONLY_TOOLS = new Set(["select", "hand"]);
|
|
12
|
+
const READ_ONLY_COMMANDS = new Set(["zoomIn", "zoomOut", "zoomReset", "zoomFit", "zoomSelection"]);
|
|
13
|
+
export function parseChord(text, mac) {
|
|
14
|
+
const parts = text.split("+");
|
|
15
|
+
if (parts.length > 1 && parts.at(-1) === "" && parts.at(-2) === "")
|
|
16
|
+
parts.splice(-2, 2, "+");
|
|
17
|
+
const key = parts.pop()?.trim() ?? "";
|
|
18
|
+
if (key === "")
|
|
19
|
+
return null;
|
|
20
|
+
const chord = { key: key.length === 1 ? key.toLowerCase() : key, ctrl: false, meta: false, alt: false, shift: false };
|
|
21
|
+
for (const raw of parts) {
|
|
22
|
+
switch (raw.trim().toLowerCase()) {
|
|
23
|
+
case "mod":
|
|
24
|
+
if (mac)
|
|
25
|
+
chord.meta = true;
|
|
26
|
+
else
|
|
27
|
+
chord.ctrl = true;
|
|
28
|
+
break;
|
|
29
|
+
case "ctrl":
|
|
30
|
+
case "control":
|
|
31
|
+
chord.ctrl = true;
|
|
32
|
+
break;
|
|
33
|
+
case "cmd":
|
|
34
|
+
case "meta":
|
|
35
|
+
chord.meta = true;
|
|
36
|
+
break;
|
|
37
|
+
case "alt":
|
|
38
|
+
case "option":
|
|
39
|
+
chord.alt = true;
|
|
40
|
+
break;
|
|
41
|
+
case "shift":
|
|
42
|
+
chord.shift = true;
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return chord;
|
|
49
|
+
}
|
|
50
|
+
export function matchesChord(c, e) {
|
|
51
|
+
if (e.ctrlKey !== c.ctrl || e.metaKey !== c.meta || e.altKey !== c.alt || e.shiftKey !== c.shift)
|
|
52
|
+
return false;
|
|
53
|
+
const key = e.key.length === 1 ? e.key.toLowerCase() : e.key;
|
|
54
|
+
if (key === c.key)
|
|
55
|
+
return true;
|
|
56
|
+
if (/^[a-z0-9]$/.test(key))
|
|
57
|
+
return false;
|
|
58
|
+
if (/^[a-z]$/.test(c.key))
|
|
59
|
+
return e.code === `Key${c.key.toUpperCase()}`;
|
|
60
|
+
if (/^[0-9]$/.test(c.key))
|
|
61
|
+
return e.code === `Digit${c.key}`;
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
export function formatChord(c, mac) {
|
|
65
|
+
const key = c.key.length === 1 ? c.key.toUpperCase() : c.key;
|
|
66
|
+
if (mac)
|
|
67
|
+
return `${c.ctrl ? "⌃" : ""}${c.alt ? "⌥" : ""}${c.shift ? "⇧" : ""}${c.meta ? "⌘" : ""}${key}`;
|
|
68
|
+
return [c.ctrl && "Ctrl", c.meta && "Meta", c.alt && "Alt", c.shift && "Shift", key].filter(Boolean).join("+");
|
|
69
|
+
}
|
|
70
|
+
export function ariaChord(c) {
|
|
71
|
+
const key = c.key.length === 1 ? c.key.toUpperCase() : c.key;
|
|
72
|
+
return [c.ctrl && "Control", c.alt && "Alt", c.shift && "Shift", c.meta && "Meta", key].filter(Boolean).join("+");
|
|
73
|
+
}
|
|
74
|
+
export function toolBindings(toolbar, overrides, known, mac) {
|
|
75
|
+
if (toolbar === false)
|
|
76
|
+
return [];
|
|
77
|
+
const out = [];
|
|
78
|
+
const add = (text, b) => {
|
|
79
|
+
const chord = text ? parseChord(text, mac) : null;
|
|
80
|
+
if (chord)
|
|
81
|
+
out.push({ chord, ...b });
|
|
82
|
+
};
|
|
83
|
+
const builtIn = (name) => {
|
|
84
|
+
if (!known.includes(name))
|
|
85
|
+
return;
|
|
86
|
+
add(name in overrides ? overrides[name] : DEFAULT_TOOL_SHORTCUTS[name], { tool: name });
|
|
87
|
+
};
|
|
88
|
+
const listed = toolbar.tools;
|
|
89
|
+
if (!listed) {
|
|
90
|
+
for (const name of known)
|
|
91
|
+
builtIn(name);
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
const entries = [];
|
|
95
|
+
for (const t of listed) {
|
|
96
|
+
if (typeof t === "object" && "tools" in t)
|
|
97
|
+
entries.push(...t.tools);
|
|
98
|
+
else
|
|
99
|
+
entries.push(t);
|
|
100
|
+
}
|
|
101
|
+
for (const entry of entries) {
|
|
102
|
+
if (entry === "|")
|
|
103
|
+
continue;
|
|
104
|
+
if (typeof entry === "string")
|
|
105
|
+
builtIn(entry);
|
|
106
|
+
else
|
|
107
|
+
add(entry.shortcut, { custom: entry });
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
export function bindingAllowed(b, readOnly) {
|
|
112
|
+
if (!readOnly)
|
|
113
|
+
return true;
|
|
114
|
+
if ("tool" in b)
|
|
115
|
+
return READ_ONLY_TOOLS.has(b.tool);
|
|
116
|
+
if ("command" in b)
|
|
117
|
+
return READ_ONLY_COMMANDS.has(b.command);
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
export function isMac(nav = globalThis.navigator) {
|
|
121
|
+
return /mac|iphone|ipad|ipod/i.test(nav?.platform || nav?.userAgent || "");
|
|
122
|
+
}
|
package/dist/mount.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { UiHandle, UiHost } from "./host.js";
|
|
2
|
+
import type { UiOptions } from "./options.js";
|
|
3
|
+
import { type FrameSource } from "./scheduler.js";
|
|
4
|
+
export interface MountEnv {
|
|
5
|
+
frames?: FrameSource;
|
|
6
|
+
clock?: () => number;
|
|
7
|
+
mac?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function defineElements(): void;
|
|
10
|
+
export declare function mountUi(container: HTMLElement, host: UiHost, options?: UiOptions): UiHandle;
|
|
11
|
+
export declare function mountUiWith(container: HTMLElement, host: UiHost, options: UiOptions, env: MountEnv): UiHandle;
|
package/dist/mount.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { definePicker } from "./picker/index.js";
|
|
2
|
+
import { definePane, PanePlacement } from "./surfaces/pane/index.js";
|
|
3
|
+
import { defineContextMenu } from "./surfaces/context-menu/index.js";
|
|
4
|
+
import { defineSelectionToolbar } from "./surfaces/selection-toolbar/index.js";
|
|
5
|
+
import { defineToolsToolbar } from "./surfaces/tools/index.js";
|
|
6
|
+
import { isMac } from "./keys.js";
|
|
7
|
+
import { ROOT_TAG, UiRoot } from "./root.js";
|
|
8
|
+
import { animationFrames, UiScheduler } from "./scheduler.js";
|
|
9
|
+
export function defineElements() {
|
|
10
|
+
const defined = customElements.get(ROOT_TAG);
|
|
11
|
+
if (!defined)
|
|
12
|
+
customElements.define(ROOT_TAG, UiRoot);
|
|
13
|
+
else if (defined !== UiRoot)
|
|
14
|
+
throw new Error(`<${ROOT_TAG}> is already defined by another copy of @daasboard/ui`);
|
|
15
|
+
definePicker();
|
|
16
|
+
definePane();
|
|
17
|
+
defineSelectionToolbar();
|
|
18
|
+
defineToolsToolbar();
|
|
19
|
+
defineContextMenu();
|
|
20
|
+
}
|
|
21
|
+
export function mountUi(container, host, options = {}) {
|
|
22
|
+
return mountUiWith(container, host, options, {});
|
|
23
|
+
}
|
|
24
|
+
export function mountUiWith(container, host, options, env) {
|
|
25
|
+
defineElements();
|
|
26
|
+
const win = container.ownerDocument.defaultView ?? window;
|
|
27
|
+
const scheduler = new UiScheduler(env.frames ?? animationFrames(win), env.clock ?? (() => win.performance.now()));
|
|
28
|
+
const root = container.ownerDocument.createElement(ROOT_TAG);
|
|
29
|
+
if (!(root instanceof UiRoot))
|
|
30
|
+
throw new Error("mountUi: the board's container must be in the document that loaded @daasboard/ui");
|
|
31
|
+
root.init(narrowHost(host), options, scheduler, env.mac ?? isMac(win.navigator));
|
|
32
|
+
container.append(root);
|
|
33
|
+
const pane = new PanePlacement(root);
|
|
34
|
+
pane.sync();
|
|
35
|
+
return {
|
|
36
|
+
configure: (partial) => {
|
|
37
|
+
root.configure(partial);
|
|
38
|
+
pane.sync();
|
|
39
|
+
},
|
|
40
|
+
handleKey: (e) => root.handleKey(e),
|
|
41
|
+
owns: (target) => root.owns(target),
|
|
42
|
+
openContextMenu: (at) => root.openContextMenu(at),
|
|
43
|
+
stats: () => scheduler.stats(),
|
|
44
|
+
dispose: () => {
|
|
45
|
+
pane.dispose();
|
|
46
|
+
root.dispose();
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function narrowHost(host) {
|
|
51
|
+
const c = host.controller;
|
|
52
|
+
const t = host.tools;
|
|
53
|
+
const sessions = new WeakMap();
|
|
54
|
+
const session = (s) => {
|
|
55
|
+
let view = sessions.get(s);
|
|
56
|
+
if (!view)
|
|
57
|
+
sessions.set(s, (view = Object.freeze({ objectId: s.objectId, ...forward(s, ["readMark", "writeMark"]) })));
|
|
58
|
+
return view;
|
|
59
|
+
};
|
|
60
|
+
const controller = Object.freeze({
|
|
61
|
+
...forward(c, ["read", "set", "preview", "commitPreview", "cancelPreview", "hasPreview", "previewOverlay", "subscribe", "targets", "create"]),
|
|
62
|
+
get commands() {
|
|
63
|
+
return c.commands;
|
|
64
|
+
},
|
|
65
|
+
textTarget: () => {
|
|
66
|
+
const s = c.textTarget();
|
|
67
|
+
return s && session(s);
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
const tools = Object.freeze({
|
|
71
|
+
get active() {
|
|
72
|
+
return t.active;
|
|
73
|
+
},
|
|
74
|
+
...forward(t, ["setTool", "onToolChange", "setCreationStyle", "creationStyle"]),
|
|
75
|
+
});
|
|
76
|
+
return Object.freeze({
|
|
77
|
+
...forward(host, ["readOnly", "onGesture", "selectionRect", "fonts", "returnFocus", "setInsets", "onChange"]),
|
|
78
|
+
...(host.lookupLink && forward(host, ["lookupLink"])),
|
|
79
|
+
...(host.insertImages && forward(host, ["insertImages"])),
|
|
80
|
+
...(host.tokens && forward(host, ["tokens"])),
|
|
81
|
+
...(host.gradientHandles && forward(host, ["gradientHandles"])),
|
|
82
|
+
...(host.allowsKey && forward(host, ["allowsKey"])),
|
|
83
|
+
...(host.handleClipboard && forward(host, ["handleClipboard"])),
|
|
84
|
+
...(host.allows && forward(host, ["allows"])),
|
|
85
|
+
...(host.clipboard && { clipboard: Object.freeze(forward(host.clipboard, ["canCopy", "canPaste", "copy", "cut", "paste"])) }),
|
|
86
|
+
controller,
|
|
87
|
+
tools,
|
|
88
|
+
camera: host.camera,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function forward(obj, keys) {
|
|
92
|
+
const out = {};
|
|
93
|
+
for (const k of keys)
|
|
94
|
+
out[k] = (...args) => obj[k].apply(obj, args);
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { FillPaint, PropertyDescriptor, PropertyValue, PropType, SceneObject, ToolName } from "@daasboard/editor";
|
|
2
|
+
import type { UiHost } from "./host.js";
|
|
3
|
+
import type { IconName, IconNode, IconOverride } from "./icons/index.js";
|
|
4
|
+
import { type PrefsStore } from "./prefs.js";
|
|
5
|
+
import { Strings, type UiStrings } from "./strings.js";
|
|
6
|
+
import type { ThemeName, ThemeTokens } from "./theme.js";
|
|
7
|
+
export type GradientType = "linear" | "radial";
|
|
8
|
+
export type ColorFormat = "hex" | "rgb" | "hsl";
|
|
9
|
+
export type PickerMode = "palette" | "space";
|
|
10
|
+
export declare const GRADIENT_TYPES: readonly GradientType[];
|
|
11
|
+
export declare const COLOR_FORMATS: readonly ColorFormat[];
|
|
12
|
+
export declare const PICKER_MODES: readonly PickerMode[];
|
|
13
|
+
export interface RecentsStore {
|
|
14
|
+
list(): readonly FillPaint[];
|
|
15
|
+
add(paint: FillPaint): void;
|
|
16
|
+
subscribe(l: () => void): () => void;
|
|
17
|
+
}
|
|
18
|
+
export interface ColorOptions {
|
|
19
|
+
gradients?: boolean | readonly GradientType[];
|
|
20
|
+
alpha?: boolean;
|
|
21
|
+
formats?: readonly ColorFormat[];
|
|
22
|
+
modes?: readonly PickerMode[];
|
|
23
|
+
palette?: readonly string[] | readonly {
|
|
24
|
+
name: string;
|
|
25
|
+
colors: readonly string[];
|
|
26
|
+
}[];
|
|
27
|
+
recents?: false | {
|
|
28
|
+
max?: number;
|
|
29
|
+
store?: RecentsStore;
|
|
30
|
+
};
|
|
31
|
+
eyedropper?: boolean;
|
|
32
|
+
tokens?: boolean;
|
|
33
|
+
canvasHandles?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ResolvedColorOptions {
|
|
36
|
+
gradients: readonly GradientType[];
|
|
37
|
+
alpha: boolean;
|
|
38
|
+
formats: readonly ColorFormat[];
|
|
39
|
+
modes: readonly PickerMode[];
|
|
40
|
+
palette: ColorOptions["palette"];
|
|
41
|
+
recents: false | {
|
|
42
|
+
max: number;
|
|
43
|
+
store?: RecentsStore;
|
|
44
|
+
};
|
|
45
|
+
eyedropper: boolean;
|
|
46
|
+
tokens: boolean;
|
|
47
|
+
canvasHandles: boolean;
|
|
48
|
+
}
|
|
49
|
+
export type ColorSurface = "selectionToolbar" | "pane";
|
|
50
|
+
export type CommandName = "undo" | "redo" | "delete" | "duplicate" | "selectAll" | "bringToFront" | "bringForward" | "sendBackward" | "sendToBack" | "lock" | "zoomIn" | "zoomOut" | "zoomReset" | "zoomFit" | "zoomSelection" | "locationAndSize";
|
|
51
|
+
export interface CustomTool {
|
|
52
|
+
id: string;
|
|
53
|
+
label: string;
|
|
54
|
+
icon: string | IconNode;
|
|
55
|
+
shortcut?: string;
|
|
56
|
+
activate(host: UiHost): void;
|
|
57
|
+
}
|
|
58
|
+
export type ToolbarToolName = ToolName | "image";
|
|
59
|
+
export interface ToolGroup {
|
|
60
|
+
tools: readonly (ToolbarToolName | CustomTool)[];
|
|
61
|
+
}
|
|
62
|
+
export type ItemId = "stickyColor" | "fill" | "stroke" | "borderStyle" | "lineEnds" | "connectorType" | "font" | "fontSize" | "bold" | "italic" | "moreStyles" | "textColor" | "textOptions" | "list" | "align" | "shadow" | "opacity" | "more";
|
|
63
|
+
export type SectionId = "layout" | "appearance" | "text" | "fill" | "stroke" | "connector" | "effects" | "link" | "other";
|
|
64
|
+
export interface ItemContext {
|
|
65
|
+
host: UiHost;
|
|
66
|
+
values: Readonly<Record<string, PropertyValue>>;
|
|
67
|
+
targets: readonly SceneObject[];
|
|
68
|
+
}
|
|
69
|
+
export interface CustomItem {
|
|
70
|
+
id: string;
|
|
71
|
+
requires?: readonly string[];
|
|
72
|
+
when?(targets: readonly SceneObject[]): boolean;
|
|
73
|
+
render(ctx: ItemContext): HTMLElement;
|
|
74
|
+
}
|
|
75
|
+
export type SectionContext = ItemContext;
|
|
76
|
+
export interface CustomSection {
|
|
77
|
+
id: string;
|
|
78
|
+
title: string;
|
|
79
|
+
keys?: readonly string[];
|
|
80
|
+
render?(ctx: SectionContext): HTMLElement;
|
|
81
|
+
}
|
|
82
|
+
export interface ControlContext {
|
|
83
|
+
descriptor: PropertyDescriptor;
|
|
84
|
+
value: PropertyValue;
|
|
85
|
+
preview(value: unknown): void;
|
|
86
|
+
commit(value: unknown): void;
|
|
87
|
+
cancel(): void;
|
|
88
|
+
onCancel(listener: () => void): void;
|
|
89
|
+
}
|
|
90
|
+
export type ControlFactory = (ctx: ControlContext) => HTMLElement;
|
|
91
|
+
export interface ToolbarOptions {
|
|
92
|
+
placement?: "bottom" | "top" | "left" | "right" | {
|
|
93
|
+
container: HTMLElement;
|
|
94
|
+
};
|
|
95
|
+
tools?: readonly (ToolbarToolName | ToolGroup | CustomTool | "|")[];
|
|
96
|
+
overflow?: boolean;
|
|
97
|
+
quickActions?: boolean | {
|
|
98
|
+
toolOptions?: boolean;
|
|
99
|
+
touch?: boolean;
|
|
100
|
+
};
|
|
101
|
+
zoom?: boolean;
|
|
102
|
+
rememberToolStyles?: boolean;
|
|
103
|
+
}
|
|
104
|
+
export type ItemList = readonly (ItemId | CustomItem | "|")[];
|
|
105
|
+
export interface SelectionToolbarOptions {
|
|
106
|
+
placement?: "top" | "floating" | {
|
|
107
|
+
container: HTMLElement;
|
|
108
|
+
};
|
|
109
|
+
items?: ItemList | ((defaults: readonly (ItemId | "|")[]) => ItemList);
|
|
110
|
+
color?: ColorOptions;
|
|
111
|
+
}
|
|
112
|
+
export interface PaneOptions {
|
|
113
|
+
container?: HTMLElement | null;
|
|
114
|
+
side?: "left" | "right";
|
|
115
|
+
sections?: readonly (SectionId | CustomSection)[];
|
|
116
|
+
collapsed?: readonly SectionId[];
|
|
117
|
+
hide?: readonly string[];
|
|
118
|
+
color?: ColorOptions;
|
|
119
|
+
}
|
|
120
|
+
export interface UiOptions {
|
|
121
|
+
theme?: ThemeName | Partial<ThemeTokens>;
|
|
122
|
+
density?: "comfortable" | "compact";
|
|
123
|
+
strings?: Partial<UiStrings>;
|
|
124
|
+
icons?: Partial<Record<IconName, IconOverride>>;
|
|
125
|
+
shortcuts?: Partial<Record<ToolName | CommandName, string | null>>;
|
|
126
|
+
prefs?: PrefsStore;
|
|
127
|
+
color?: ColorOptions;
|
|
128
|
+
toolbar?: false | ToolbarOptions;
|
|
129
|
+
selectionToolbar?: false | SelectionToolbarOptions;
|
|
130
|
+
pane?: boolean | PaneOptions;
|
|
131
|
+
contextMenu?: boolean;
|
|
132
|
+
controls?: Partial<Record<PropType | `key:${string}`, ControlFactory>>;
|
|
133
|
+
}
|
|
134
|
+
export interface ResolvedOptions {
|
|
135
|
+
theme: ThemeName;
|
|
136
|
+
tokens: Partial<ThemeTokens> | null;
|
|
137
|
+
density: "comfortable" | "compact";
|
|
138
|
+
strings: Strings;
|
|
139
|
+
icons: Partial<Record<IconName, IconOverride>>;
|
|
140
|
+
shortcuts: Partial<Record<ToolName | CommandName, string | null>>;
|
|
141
|
+
prefs: PrefsStore;
|
|
142
|
+
color: ColorOptions;
|
|
143
|
+
toolbar: false | ToolbarOptions;
|
|
144
|
+
selectionToolbar: false | SelectionToolbarOptions;
|
|
145
|
+
pane: false | PaneOptions;
|
|
146
|
+
contextMenu: boolean;
|
|
147
|
+
controls: Partial<Record<PropType | `key:${string}`, ControlFactory>>;
|
|
148
|
+
}
|
|
149
|
+
export declare function resolveOptions(o: UiOptions, fallbackPrefs?: PrefsStore): ResolvedOptions;
|
|
150
|
+
export declare function mergeOptions(base: UiOptions, partial: UiOptions): UiOptions;
|
|
151
|
+
export declare function colorOptionsFor(resolved: ResolvedOptions, surface: ColorSurface): ResolvedColorOptions;
|
|
152
|
+
export declare function gradientsFor(color: ResolvedColorOptions, descriptorType: string): readonly GradientType[];
|