@vinena/knobs 0.5.2 → 0.6.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/CHANGELOG.md +39 -0
- package/README.md +7 -6
- package/dist/context-amfyasb5.js +23 -0
- package/dist/context-svtr7vwt.js +22 -0
- package/dist/early.global.js +6 -6
- package/dist/edit/css.d.ts +59 -0
- package/dist/edit/html.d.ts +91 -0
- package/dist/edit/keep.d.ts +175 -0
- package/dist/edit/log.d.ts +107 -0
- package/dist/edit/replay.d.ts +28 -0
- package/dist/edit/risk.d.ts +33 -0
- package/dist/edit/rule.d.ts +31 -0
- package/dist/edit/source.d.ts +12 -0
- package/dist/edit/text.d.ts +66 -0
- package/dist/elementsview-fyc06wjt.js +3702 -0
- package/dist/elementsview-k6zvvcne.js +3701 -0
- package/dist/engine/browserdraw.d.ts +5 -0
- package/dist/engine/browserkit.d.ts +2 -0
- package/dist/engine/devices.d.ts +3 -2
- package/dist/engine/dock.d.ts +3 -4
- package/dist/engine/frame.d.ts +1 -1
- package/dist/engine/frames.d.ts +1 -0
- package/dist/engine/identity.d.ts +5 -1
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/mock.d.ts +0 -2
- package/dist/engine/mockdata.d.ts +4 -3
- package/dist/engine/mockdraw.d.ts +2 -14
- package/dist/engine/morphrun.d.ts +4 -0
- package/dist/engine/native.d.ts +31 -3
- package/dist/engine/notice.d.ts +1 -2
- package/dist/engine/style.d.ts +15 -0
- package/dist/engine/width.d.ts +3 -0
- package/dist/{framekit-w0v516w5.js → framekit-622h6w1f.js} +264 -105
- package/dist/{framekit-te90cjs0.js → framekit-yx612r28.js} +264 -105
- package/dist/index-0zp9py56.js +859 -0
- package/dist/{index-9re7sv56.js → index-1mstjadm.js} +126 -2167
- package/dist/{index-30fc6php.js → index-4a4x1bt2.js} +1 -1
- package/dist/index-58jdczmj.js +44 -0
- package/dist/index-5tv6sr74.js +23 -0
- package/dist/index-6bc2ztfd.js +688 -0
- package/dist/index-7cb4x1vj.js +1885 -0
- package/dist/index-a974q3aa.js +34 -0
- package/dist/{index-r72tz2vn.js → index-aymfvd8s.js} +1 -1
- package/dist/{index-trx7bxdk.js → index-aynkv7qk.js} +11 -8
- package/dist/{index-xjhwp5cj.js → index-dzm8ywq0.js} +504 -2362
- package/dist/{index-dan2kpsd.js → index-f60yax1j.js} +13 -8
- package/dist/index-f67wctn3.js +1858 -0
- package/dist/{index-agwr37gw.js → index-ftjdt358.js} +8 -171
- package/dist/{index-pewcdh28.js → index-gm51cthv.js} +2 -45
- package/dist/index-kfdzsyyw.js +1859 -0
- package/dist/index-t4kssacm.js +208 -0
- package/dist/index-v0ht9q0g.js +1518 -0
- package/dist/{index-sxe5079a.js → index-x59vz1xx.js} +262 -901
- package/dist/index-xh39jtkq.js +32 -0
- package/dist/index-yb7fc59g.js +718 -0
- package/dist/index-zd6adby9.js +496 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.global.js +447 -160
- package/dist/index.js +533 -485
- package/dist/react-0wepdf60.js +1519 -0
- package/dist/{react-4pvp6amm.js → react-1gqwa2yw.js} +1 -1
- package/dist/{index-hv02xka3.js → react-3mfz1x2a.js} +126 -2167
- package/dist/react-4rbjw9af.js +33 -0
- package/dist/react-5rq7bnsy.js +210 -0
- package/dist/react-6bz05qk1.js +860 -0
- package/dist/{react-05jh9jv5.js → react-6fnxxs30.js} +8 -171
- package/dist/react-6q2cw2ya.js +689 -0
- package/dist/{react-sw8d8c94.js → react-6t4dbdzn.js} +11 -8
- package/dist/react-88es9b5q.js +719 -0
- package/dist/react-97b5b8j4.js +46 -0
- package/dist/{react-16spgn0h.js → react-bxzn8vq5.js} +1 -1
- package/dist/{react-ayg1bgw3.js → react-cs62p9qh.js} +83 -722
- package/dist/react-ethftdxp.js +497 -0
- package/dist/react-fp73vhyd.js +36 -0
- package/dist/{react-exjcpxma.js → react-me102s1a.js} +2 -45
- package/dist/react-t2qnewz2.js +24 -0
- package/dist/react-ttj8f9qp.js +1886 -0
- package/dist/{react-zy1mmhgz.js → react-v8497a41.js} +13 -8
- package/dist/{react-fm9y8dbn.js → react-wqn4sx0n.js} +276 -2133
- package/dist/react.js +529 -485
- package/dist/replay-j18rw92k.js +258 -0
- package/dist/replay-vtg0vqj2.js +257 -0
- package/dist/{storageview-s7heg93p.js → storageview-6xj7zb63.js} +11 -7
- package/dist/{storageview-r595qpt9.js → storageview-pzn8yaad.js} +11 -7
- package/dist/styles/force.d.ts +66 -0
- package/dist/types.d.ts +7 -0
- package/dist/ui/bindings.d.ts +31 -5
- package/dist/ui/changes.d.ts +49 -0
- package/dist/ui/cssauto.d.ts +119 -0
- package/dist/ui/cssedit.d.ts +80 -0
- package/dist/ui/domedit.d.ts +99 -0
- package/dist/ui/domtree.d.ts +26 -1
- package/dist/ui/elementsview.d.ts +19 -2
- package/dist/ui/htmledit.d.ts +62 -0
- package/dist/ui/inspector.d.ts +6 -1
- package/dist/ui/keys.d.ts +12 -8
- package/dist/ui/pane.d.ts +0 -2
- package/dist/ui/panel.d.ts +3 -0
- package/dist/ui/prefs.d.ts +30 -10
- package/dist/ui/settings.d.ts +10 -0
- package/dist/ui/size.d.ts +14 -22
- package/dist/ui/stylesview.d.ts +30 -1
- package/package.json +1 -1
- package/skills/devknobs/SKILL.md +95 -0
- package/dist/elementsview-2z4pkrdz.js +0 -2873
- package/dist/elementsview-qn8qyksa.js +0 -2874
- package/dist/index-78r0f8pw.js +0 -27
- package/dist/react-adky72h9.js +0 -29
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
import {
|
|
2
|
+
post
|
|
3
|
+
} from "./index-dzm8ywq0.js";
|
|
4
|
+
|
|
5
|
+
// src/ui/icons.ts
|
|
6
|
+
var SVG = "http://www.w3.org/2000/svg";
|
|
7
|
+
var p = (d) => ["path", { d }];
|
|
8
|
+
var c = (cx, cy, r) => ["circle", { cx, cy, r }];
|
|
9
|
+
var ICONS = {
|
|
10
|
+
"half-sun-moon": [
|
|
11
|
+
p("M12 7a5 5 0 0 0 0 10"),
|
|
12
|
+
p("M12 3a9 9 0 0 1 0 18 12 12 0 0 0 0-18z"),
|
|
13
|
+
p("M3 12h2"),
|
|
14
|
+
p("m5.64 5.64 1.41 1.41"),
|
|
15
|
+
p("m5.64 18.36 1.41-1.41")
|
|
16
|
+
],
|
|
17
|
+
contrast: [c("12", "12", "10"), p("M12 18a6 6 0 0 0 0-12v12z")],
|
|
18
|
+
blend: [c("15", "9", "7"), c("9", "15", "7")],
|
|
19
|
+
eye: [
|
|
20
|
+
p("M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"),
|
|
21
|
+
c("12", "12", "3")
|
|
22
|
+
],
|
|
23
|
+
type: [p("M12 4v16"), p("M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"), p("M9 20h6")],
|
|
24
|
+
wind: [
|
|
25
|
+
p("M12.8 19.6A2 2 0 1 0 14 16H2"),
|
|
26
|
+
p("M17.5 8a2.5 2.5 0 1 1 2 4H2"),
|
|
27
|
+
p("M9.8 4.4A2 2 0 1 1 11 8H2")
|
|
28
|
+
],
|
|
29
|
+
languages: [
|
|
30
|
+
p("m5 8 6 6"),
|
|
31
|
+
p("m4 14 6-6 2-3"),
|
|
32
|
+
p("M2 5h12"),
|
|
33
|
+
p("M7 2h1"),
|
|
34
|
+
p("m22 22-5-10-5 10"),
|
|
35
|
+
p("M14 18h6")
|
|
36
|
+
],
|
|
37
|
+
"map-pin": [
|
|
38
|
+
p("M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0"),
|
|
39
|
+
c("12", "10", "3")
|
|
40
|
+
],
|
|
41
|
+
clock: [c("12", "12", "10"), p("M12 6v6l4 2")],
|
|
42
|
+
wifi: [
|
|
43
|
+
p("M12 20h.01"),
|
|
44
|
+
p("M2 8.82a15 15 0 0 1 20 0"),
|
|
45
|
+
p("M5 12.859a10 10 0 0 1 14 0"),
|
|
46
|
+
p("M8.5 16.429a5 5 0 0 1 7 0")
|
|
47
|
+
],
|
|
48
|
+
smartphone: [
|
|
49
|
+
["rect", { width: "14", height: "20", x: "5", y: "2", rx: "2", ry: "2" }],
|
|
50
|
+
p("M12 18h.01")
|
|
51
|
+
],
|
|
52
|
+
ruler: [
|
|
53
|
+
p("M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z"),
|
|
54
|
+
p("m14.5 12.5 2-2"),
|
|
55
|
+
p("m11.5 9.5 2-2"),
|
|
56
|
+
p("m8.5 6.5 2-2"),
|
|
57
|
+
p("m17.5 15.5 2-2")
|
|
58
|
+
],
|
|
59
|
+
bug: [
|
|
60
|
+
p("M12 20v-9"),
|
|
61
|
+
p("M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"),
|
|
62
|
+
p("M14.12 3.88 16 2"),
|
|
63
|
+
p("M21 21a4 4 0 0 0-3.81-4"),
|
|
64
|
+
p("M21 5a4 4 0 0 1-3.55 3.97"),
|
|
65
|
+
p("M22 13h-4"),
|
|
66
|
+
p("M3 21a4 4 0 0 1 3.81-4"),
|
|
67
|
+
p("M3 5a4 4 0 0 0 3.55 3.97"),
|
|
68
|
+
p("M6 13H2"),
|
|
69
|
+
p("m8 2 1.88 1.88"),
|
|
70
|
+
p("M9 7.13V6a3 3 0 1 1 6 0v1.13")
|
|
71
|
+
],
|
|
72
|
+
"square-dashed-mouse-pointer": [
|
|
73
|
+
p("M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"),
|
|
74
|
+
p("M5 3a2 2 0 0 0-2 2"),
|
|
75
|
+
p("M19 3a2 2 0 0 1 2 2"),
|
|
76
|
+
p("M5 21a2 2 0 0 1-2-2"),
|
|
77
|
+
p("M9 3h1"),
|
|
78
|
+
p("M9 21h2"),
|
|
79
|
+
p("M14 3h1"),
|
|
80
|
+
p("M3 9v1"),
|
|
81
|
+
p("M21 9v2"),
|
|
82
|
+
p("M3 14v1")
|
|
83
|
+
],
|
|
84
|
+
braces: [
|
|
85
|
+
p("M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1"),
|
|
86
|
+
p("M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1")
|
|
87
|
+
],
|
|
88
|
+
settings: [
|
|
89
|
+
p("M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915"),
|
|
90
|
+
c("12", "12", "3")
|
|
91
|
+
],
|
|
92
|
+
"panel-right": [
|
|
93
|
+
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }],
|
|
94
|
+
p("M15 3v18")
|
|
95
|
+
],
|
|
96
|
+
"panel-left": [
|
|
97
|
+
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }],
|
|
98
|
+
p("M9 3v18")
|
|
99
|
+
],
|
|
100
|
+
"panel-right-close": [
|
|
101
|
+
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }],
|
|
102
|
+
p("M15 3v18"),
|
|
103
|
+
p("m8 9 3 3-3 3")
|
|
104
|
+
],
|
|
105
|
+
"panel-right-open": [
|
|
106
|
+
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }],
|
|
107
|
+
p("M15 3v18"),
|
|
108
|
+
p("m10 15-3-3 3-3")
|
|
109
|
+
],
|
|
110
|
+
pin: [
|
|
111
|
+
p("M12 17v5"),
|
|
112
|
+
p("M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z")
|
|
113
|
+
],
|
|
114
|
+
"pin-off": [
|
|
115
|
+
p("M12 17v5"),
|
|
116
|
+
p("M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89"),
|
|
117
|
+
p("m2 2 20 20"),
|
|
118
|
+
p("M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11")
|
|
119
|
+
],
|
|
120
|
+
eraser: [
|
|
121
|
+
p("M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21"),
|
|
122
|
+
p("m5.082 11.09 8.828 8.828")
|
|
123
|
+
],
|
|
124
|
+
"rotate-ccw": [p("M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"), p("M3 3v5h5")],
|
|
125
|
+
"arrow-up-down": [p("m21 16-4 4-4-4"), p("M17 20V4"), p("m3 8 4-4 4 4"), p("M7 4v16")],
|
|
126
|
+
ban: [c("12", "12", "10"), p("M4.929 4.929 19.07 19.071")],
|
|
127
|
+
copy: [
|
|
128
|
+
["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2" }],
|
|
129
|
+
p("M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2")
|
|
130
|
+
],
|
|
131
|
+
"refresh-cw": [
|
|
132
|
+
p("M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"),
|
|
133
|
+
p("M21 3v5h-5"),
|
|
134
|
+
p("M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"),
|
|
135
|
+
p("M8 16H3v5")
|
|
136
|
+
],
|
|
137
|
+
database: [
|
|
138
|
+
["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3" }],
|
|
139
|
+
p("M3 5V19A9 3 0 0 0 21 19V5"),
|
|
140
|
+
p("M3 12A9 3 0 0 0 21 12")
|
|
141
|
+
],
|
|
142
|
+
"trash-2": [
|
|
143
|
+
p("M10 11v6"),
|
|
144
|
+
p("M14 11v6"),
|
|
145
|
+
p("M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"),
|
|
146
|
+
p("M3 6h18"),
|
|
147
|
+
p("M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2")
|
|
148
|
+
],
|
|
149
|
+
check: [p("M20 6 9 17l-5-5")],
|
|
150
|
+
"chevron-left": [p("m15 18-6-6 6-6")],
|
|
151
|
+
"chevrons-left-right": [p("m9 7-5 5 5 5"), p("m15 7 5 5-5 5")],
|
|
152
|
+
plus: [p("M5 12h14"), p("M12 5v14")],
|
|
153
|
+
x: [p("M18 6 6 18"), p("m6 6 12 12")],
|
|
154
|
+
"grip-vertical": [
|
|
155
|
+
c("9", "12", "1"),
|
|
156
|
+
c("9", "5", "1"),
|
|
157
|
+
c("9", "19", "1"),
|
|
158
|
+
c("15", "12", "1"),
|
|
159
|
+
c("15", "5", "1"),
|
|
160
|
+
c("15", "19", "1")
|
|
161
|
+
],
|
|
162
|
+
image: [
|
|
163
|
+
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2" }],
|
|
164
|
+
c("9", "9", "2"),
|
|
165
|
+
p("m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21")
|
|
166
|
+
],
|
|
167
|
+
film: [
|
|
168
|
+
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2" }],
|
|
169
|
+
p("M7 3v18"),
|
|
170
|
+
p("M3 7.5h4"),
|
|
171
|
+
p("M3 12h18"),
|
|
172
|
+
p("M3 16.5h4"),
|
|
173
|
+
p("M17 3v18"),
|
|
174
|
+
p("M17 7.5h4"),
|
|
175
|
+
p("M17 16.5h4")
|
|
176
|
+
],
|
|
177
|
+
file: [
|
|
178
|
+
p("M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"),
|
|
179
|
+
p("M14 2v5a1 1 0 0 0 1 1h5")
|
|
180
|
+
],
|
|
181
|
+
"table-2": [
|
|
182
|
+
p("M3 9h18"),
|
|
183
|
+
p("M9 3v18"),
|
|
184
|
+
["rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }]
|
|
185
|
+
],
|
|
186
|
+
cookie: [
|
|
187
|
+
p("M11 17h.01"),
|
|
188
|
+
p("M11.496 2c.324-.016.558.292.529.615a4 4 0 004.235 4.368.713.713 0 01.758.757 4 4 0 004.366 4.237c.323-.03.63.204.614.527a10 10 0 01-2.915 6.566A1 1 0 114.93 4.918 10 10 0 0111.496 2"),
|
|
189
|
+
p("M12 12h.01"),
|
|
190
|
+
p("M16 16h.01"),
|
|
191
|
+
p("M16 3h.01"),
|
|
192
|
+
p("M21 4h.01"),
|
|
193
|
+
p("M21 8h.01"),
|
|
194
|
+
p("M7 14h.01"),
|
|
195
|
+
p("M9 8h.01")
|
|
196
|
+
],
|
|
197
|
+
"hard-drive": [
|
|
198
|
+
p("M10 16h.01"),
|
|
199
|
+
p("M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"),
|
|
200
|
+
p("M21.946 12.013H2.054"),
|
|
201
|
+
p("M6 16h.01")
|
|
202
|
+
],
|
|
203
|
+
bookmark: [
|
|
204
|
+
p("M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z")
|
|
205
|
+
]
|
|
206
|
+
};
|
|
207
|
+
var BRANDS = {
|
|
208
|
+
javascript: [
|
|
209
|
+
"#F7DF1E",
|
|
210
|
+
"M0 0h24v24H0V0zm22.034 18.276c-.175-1.095-.888-2.015-3.003-2.873-.736-.345-1.554-.585-1.797-1.14-.091-.33-.105-.51-.046-.705.15-.646.915-.84 1.515-.66.39.12.75.42.976.9 1.034-.676 1.034-.676 1.755-1.125-.27-.42-.404-.601-.586-.78-.63-.705-1.469-1.065-2.834-1.034l-.705.089c-.676.165-1.32.525-1.71 1.005-1.14 1.291-.811 3.541.569 4.471 1.365 1.02 3.361 1.244 3.616 2.205.24 1.17-.87 1.545-1.966 1.41-.811-.18-1.26-.586-1.755-1.336l-1.83 1.051c.21.48.45.689.81 1.109 1.74 1.756 6.09 1.666 6.871-1.004.029-.09.24-.705.074-1.65l.046.067zm-8.983-7.245h-2.248c0 1.938-.009 3.864-.009 5.805 0 1.232.063 2.363-.138 2.711-.33.689-1.18.601-1.566.48-.396-.196-.597-.466-.83-.855-.063-.105-.11-.196-.127-.196l-1.825 1.125c.305.63.75 1.172 1.324 1.517.855.51 2.004.675 3.207.405.783-.226 1.458-.691 1.811-1.411.51-.93.402-2.07.397-3.346.012-2.054 0-4.109 0-6.179l.004-.056z",
|
|
211
|
+
["#000", "M1 1h22v22H1z"]
|
|
212
|
+
],
|
|
213
|
+
css: [
|
|
214
|
+
"#663399",
|
|
215
|
+
"M0 0v20.16A3.84 3.84 0 0 0 3.84 24h16.32A3.84 3.84 0 0 0 24 20.16V3.84A3.84 3.84 0 0 0 20.16 0Zm14.256 13.08c1.56 0 2.28 1.08 2.304 2.64h-1.608c.024-.288-.048-.6-.144-.84-.096-.192-.288-.264-.552-.264-.456 0-.696.264-.696.84-.024.576.288.888.768 1.08.72.288 1.608.744 1.92 1.296q.432.648.432 1.656c0 1.608-.912 2.592-2.496 2.592-1.656 0-2.4-1.032-2.424-2.688h1.68c0 .792.264 1.176.792 1.176.264 0 .456-.072.552-.24.192-.312.24-1.176-.048-1.512-.312-.408-.912-.6-1.32-.816q-.828-.396-1.224-.936c-.24-.36-.36-.888-.36-1.536 0-1.44.936-2.472 2.424-2.448m5.4 0c1.584 0 2.304 1.08 2.328 2.64h-1.608c0-.288-.048-.6-.168-.84-.096-.192-.264-.264-.528-.264-.48 0-.72.264-.72.84s.288.888.792 1.08c.696.288 1.608.744 1.92 1.296.264.432.408.984.408 1.656.024 1.608-.888 2.592-2.472 2.592-1.68 0-2.424-1.056-2.448-2.688h1.68c0 .744.264 1.176.792 1.176.264 0 .456-.072.552-.24.216-.312.264-1.176-.048-1.512-.288-.408-.888-.6-1.32-.816-.552-.264-.96-.576-1.2-.936s-.36-.888-.36-1.536c-.024-1.44.912-2.472 2.4-2.448m-11.031.018c.711-.006 1.419.198 1.839.63.432.432.672 1.128.648 1.992H9.336c.024-.456-.096-.792-.432-.96-.312-.144-.768-.048-.888.24-.12.264-.192.576-.168.864v3.504c0 .744.264 1.128.768 1.128a.65.65 0 0 0 .552-.264c.168-.24.192-.552.168-.84h1.776c.096 1.632-.984 2.712-2.568 2.688-1.536 0-2.496-.864-2.472-2.472v-4.032c0-.816.24-1.44.696-1.848.432-.408 1.146-.624 1.857-.63",
|
|
216
|
+
["#fff", "M4 12h18v11.3H4z"]
|
|
217
|
+
],
|
|
218
|
+
html5: [
|
|
219
|
+
"#E34F26",
|
|
220
|
+
"M1.5 0h21l-1.91 21.563L11.977 24l-8.564-2.438L1.5 0zm7.031 9.75l-.232-2.718 10.059.003.23-2.622L5.412 4.41l.698 8.01h9.126l-.326 3.426-2.91.804-2.955-.81-.188-2.11H6.248l.33 4.171L12 19.351l5.379-1.443.744-8.157H8.531z",
|
|
221
|
+
["#fff", "M5 4h14v16H5z"]
|
|
222
|
+
],
|
|
223
|
+
webassembly: [
|
|
224
|
+
"#654FF0",
|
|
225
|
+
"M14.745,0c0,0.042,0,0.085,0,0.129c0,1.52-1.232,2.752-2.752,2.752c-1.52,0-2.752-1.232-2.752-2.752 c0-0.045,0-0.087,0-0.129H0v24h24V0H14.745z M11.454,21.431l-1.169-5.783h-0.02l-1.264,5.783H7.39l-1.824-8.497h1.59l1.088,5.783 h0.02l1.311-5.783h1.487l1.177,5.854h0.02l1.242-5.854h1.561l-2.027,8.497H11.454z M20.209,21.431l-0.542-1.891h-2.861l-0.417,1.891 h-1.59l2.056-8.497h2.509l2.5,8.497H20.209z M17.812,15.028l-0.694,3.118h2.159l-0.796-3.118H17.812z",
|
|
226
|
+
["#fff", "M4 12h19v10H4z"]
|
|
227
|
+
],
|
|
228
|
+
json: [
|
|
229
|
+
"currentColor",
|
|
230
|
+
"M12.043 23.968c.479-.004.953-.029 1.426-.094a11.805 11.805 0 003.146-.863 12.404 12.404 0 003.793-2.542 11.977 11.977 0 002.44-3.427 11.794 11.794 0 001.02-3.476c.149-1.16.135-2.346-.045-3.499a11.96 11.96 0 00-.793-2.788 11.197 11.197 0 00-.854-1.617c-1.168-1.837-2.861-3.314-4.81-4.3a12.835 12.835 0 00-2.172-.87h-.005c.119.063.24.132.345.201.12.074.239.146.351.225a8.93 8.93 0 011.559 1.33c1.063 1.145 1.797 2.548 2.218 4.041.284.982.434 1.998.495 3.017.044.743.044 1.491-.047 2.229-.149 1.27-.554 2.51-1.228 3.596a7.475 7.475 0 01-1.903 2.084c-1.244.928-2.877 1.482-4.436 1.114a3.916 3.916 0 01-.748-.258 4.692 4.692 0 01-.779-.45 6.08 6.08 0 01-1.244-1.105 6.507 6.507 0 01-1.049-1.747 7.366 7.366 0 01-.494-2.54c-.03-1.273.225-2.553.854-3.67a6.43 6.43 0 011.663-1.918c.225-.178.464-.333.704-.479l.016-.007a5.121 5.121 0 00-1.441-.12 4.963 4.963 0 00-1.228.24c-.359.12-.704.27-1.019.45a6.146 6.146 0 00-.733.494c-.211.18-.42.36-.615.555-1.123 1.153-1.768 2.682-2.022 4.256-.15.973-.15 1.96-.091 2.95.105 1.395.391 2.787.945 4.062a8.518 8.518 0 001.348 2.173 8.14 8.14 0 003.132 2.23 7.934 7.934 0 002.113.54c.074.015.149.015.209.015zm-2.934-.398a4.102 4.102 0 01-.45-.228 8.5 8.5 0 01-2.038-1.534c-1.094-1.137-1.827-2.566-2.247-4.08a15.184 15.184 0 01-.495-3.172 12.14 12.14 0 01.046-2.082c.135-1.257.495-2.501 1.124-3.58a6.889 6.889 0 011.783-2.053 6.23 6.23 0 011.633-.9 5.363 5.363 0 013.522-.045c.029 0 .029 0 .045.03.015.015.045.015.06.03.045.016.104.045.165.074.239.12.479.271.704.42a6.294 6.294 0 012.097 2.502c.42.914.615 1.934.631 2.938.014 1.079-.18 2.157-.645 3.146a6.42 6.42 0 01-2.638 2.832c.09.03.18.045.271.075.225.044.449.074.688.074 1.468.045 2.892-.66 3.94-1.647.195-.18.375-.375.54-.585.225-.27.435-.54.614-.823.239-.375.435-.75.614-1.154a8.112 8.112 0 00.509-1.664c.196-1.004.211-2.022.149-3.026-.135-2.022-.673-4.045-1.842-5.724a9.054 9.054 0 00-.555-.719 9.868 9.868 0 00-1.063-1.034 8.477 8.477 0 00-1.363-.915 9.927 9.927 0 00-1.692-.598l-.3-.06c-.209-.03-.42-.044-.634-.06a8.453 8.453 0 00-1.015.016c-.704.045-1.412.16-2.112.337C5.799 1.227 2.863 3.566 1.3 6.67A11.834 11.834 0 00.238 9.801a11.81 11.81 0 00-.104 3.775c.12 1.02.374 2.023.778 2.977.227.57.511 1.124.825 1.648 1.094 1.783 2.683 3.236 4.51 4.24.688.39 1.408.69 2.157.944.226.074.45.15.689.21z"
|
|
231
|
+
]
|
|
232
|
+
};
|
|
233
|
+
var ROW_ICONS = {
|
|
234
|
+
scheme: "half-sun-moon",
|
|
235
|
+
contrast: "contrast",
|
|
236
|
+
transparency: "blend",
|
|
237
|
+
vision: "eye",
|
|
238
|
+
text: "type",
|
|
239
|
+
motion: "wind",
|
|
240
|
+
locale: "languages",
|
|
241
|
+
location: "map-pin",
|
|
242
|
+
clock: "clock",
|
|
243
|
+
network: "wifi",
|
|
244
|
+
device: "smartphone",
|
|
245
|
+
viewport: "ruler",
|
|
246
|
+
debug: "bug"
|
|
247
|
+
};
|
|
248
|
+
function rowIcon(row) {
|
|
249
|
+
return row.action ? row.action.icon : ROW_ICONS[row.id];
|
|
250
|
+
}
|
|
251
|
+
var BINDING_ICONS = {
|
|
252
|
+
panel: "panel-right-open",
|
|
253
|
+
grab: "square-dashed-mouse-pointer",
|
|
254
|
+
inspect: "braces",
|
|
255
|
+
replay: "rotate-ccw",
|
|
256
|
+
requests: "arrow-up-down",
|
|
257
|
+
storage: "database",
|
|
258
|
+
reset: "eraser",
|
|
259
|
+
elements: "chevrons-left-right",
|
|
260
|
+
settings: "settings"
|
|
261
|
+
};
|
|
262
|
+
function frame(size) {
|
|
263
|
+
const svg = document.createElementNS(SVG, "svg");
|
|
264
|
+
svg.setAttribute("class", "glyph");
|
|
265
|
+
svg.setAttribute("viewBox", "0 0 24 24");
|
|
266
|
+
svg.setAttribute("width", String(size));
|
|
267
|
+
svg.setAttribute("height", String(size));
|
|
268
|
+
svg.setAttribute("aria-hidden", "true");
|
|
269
|
+
return svg;
|
|
270
|
+
}
|
|
271
|
+
function icon(name, size = 14) {
|
|
272
|
+
const svg = frame(size);
|
|
273
|
+
svg.setAttribute("fill", "none");
|
|
274
|
+
svg.setAttribute("stroke", "currentColor");
|
|
275
|
+
svg.setAttribute("stroke-width", "1.5");
|
|
276
|
+
svg.setAttribute("stroke-linecap", "round");
|
|
277
|
+
svg.setAttribute("stroke-linejoin", "round");
|
|
278
|
+
for (const [tag, attributes] of ICONS[name]) {
|
|
279
|
+
const shape = document.createElementNS(SVG, tag);
|
|
280
|
+
for (const [key, value] of Object.entries(attributes))
|
|
281
|
+
shape.setAttribute(key, value);
|
|
282
|
+
svg.append(shape);
|
|
283
|
+
}
|
|
284
|
+
return svg;
|
|
285
|
+
}
|
|
286
|
+
function brand(name, size = 14) {
|
|
287
|
+
const svg = frame(size);
|
|
288
|
+
const [fill, d, behind] = BRANDS[name];
|
|
289
|
+
for (const [color, path] of behind ? [behind, [fill, d]] : [[fill, d]]) {
|
|
290
|
+
const shape = document.createElementNS(SVG, "path");
|
|
291
|
+
shape.setAttribute("fill", color);
|
|
292
|
+
shape.setAttribute("d", path);
|
|
293
|
+
svg.append(shape);
|
|
294
|
+
}
|
|
295
|
+
return svg;
|
|
296
|
+
}
|
|
297
|
+
function isBrand(name) {
|
|
298
|
+
return name in BRANDS;
|
|
299
|
+
}
|
|
300
|
+
function glyph(name, size = 14) {
|
|
301
|
+
return isBrand(name) ? brand(name, size) : icon(name, size);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// src/ui/keys.ts
|
|
305
|
+
function hotkeyOf(hotkey) {
|
|
306
|
+
return (hotkey ?? "k").toLowerCase();
|
|
307
|
+
}
|
|
308
|
+
var MODIFIER_NAMES = {
|
|
309
|
+
meta: "meta",
|
|
310
|
+
cmd: "meta",
|
|
311
|
+
command: "meta",
|
|
312
|
+
ctrl: "ctrl",
|
|
313
|
+
control: "ctrl",
|
|
314
|
+
shift: "shift",
|
|
315
|
+
alt: "alt",
|
|
316
|
+
option: "alt",
|
|
317
|
+
opt: "alt"
|
|
318
|
+
};
|
|
319
|
+
function parseCombo(spec) {
|
|
320
|
+
if (!spec?.trim())
|
|
321
|
+
return null;
|
|
322
|
+
const parsed = { meta: false, ctrl: false, shift: false, alt: false, key: "" };
|
|
323
|
+
for (const raw of spec.split("+")) {
|
|
324
|
+
const part = raw.trim().toLowerCase();
|
|
325
|
+
const modifier = MODIFIER_NAMES[part];
|
|
326
|
+
if (modifier)
|
|
327
|
+
parsed[modifier] = true;
|
|
328
|
+
else if (part && !parsed.key)
|
|
329
|
+
parsed.key = part;
|
|
330
|
+
else
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
return parsed.key ? parsed : null;
|
|
334
|
+
}
|
|
335
|
+
function comboText(combo) {
|
|
336
|
+
const names = [
|
|
337
|
+
combo.meta && "meta",
|
|
338
|
+
combo.ctrl && "ctrl",
|
|
339
|
+
combo.alt && "alt",
|
|
340
|
+
combo.shift && "shift"
|
|
341
|
+
];
|
|
342
|
+
return [...names.filter((name) => Boolean(name)), combo.key].join("+");
|
|
343
|
+
}
|
|
344
|
+
function withShift(key) {
|
|
345
|
+
return { meta: false, ctrl: false, shift: true, alt: false, key };
|
|
346
|
+
}
|
|
347
|
+
function isFunctionKey(key) {
|
|
348
|
+
return /^f([1-9]|1[0-2])$/.test(key);
|
|
349
|
+
}
|
|
350
|
+
function deletes(key) {
|
|
351
|
+
return key === "backspace" || key === "delete";
|
|
352
|
+
}
|
|
353
|
+
var KEY_GLYPHS = { backspace: "⌫", delete: "⌦", enter: "↩" };
|
|
354
|
+
var KEY_NAMES = { backspace: "Backspace", delete: "Delete", enter: "Enter" };
|
|
355
|
+
function comboLabel(combo, mac) {
|
|
356
|
+
const key = combo.key;
|
|
357
|
+
if (mac) {
|
|
358
|
+
const marks = `${combo.ctrl ? "⌃" : ""}${combo.alt ? "⌥" : ""}${combo.shift ? "⇧" : ""}${combo.meta ? "⌘" : ""}`;
|
|
359
|
+
return `${marks}${KEY_GLYPHS[key] ?? key.toUpperCase()}`;
|
|
360
|
+
}
|
|
361
|
+
const names = [
|
|
362
|
+
combo.ctrl && "Ctrl",
|
|
363
|
+
combo.alt && "Alt",
|
|
364
|
+
combo.shift && "Shift",
|
|
365
|
+
combo.meta && "Meta"
|
|
366
|
+
];
|
|
367
|
+
const name = KEY_NAMES[key] ?? key.toUpperCase();
|
|
368
|
+
return [...names.filter((part) => Boolean(part)), name].join(" ");
|
|
369
|
+
}
|
|
370
|
+
function comboSpoken(combo) {
|
|
371
|
+
return comboText(combo).replaceAll("+", " ");
|
|
372
|
+
}
|
|
373
|
+
var INSPECT_KEYS = ["c", "i", "y"];
|
|
374
|
+
var ELEMENTS_KEYS = ["e", "l", "d"];
|
|
375
|
+
var SETTINGS_KEYS = ["o", "u", "p"];
|
|
376
|
+
function defaultKeys(options = {}) {
|
|
377
|
+
const panel = withShift(hotkeyOf(options.hotkey));
|
|
378
|
+
const grab = parseCombo(options.grabKey) ?? withShift("g");
|
|
379
|
+
const taken = [panel, grab].map(comboText);
|
|
380
|
+
const free = (letters) => {
|
|
381
|
+
const key = withShift(letters.find((letter) => !taken.includes(comboText(withShift(letter)))) ?? letters[0]);
|
|
382
|
+
taken.push(comboText(key));
|
|
383
|
+
return key;
|
|
384
|
+
};
|
|
385
|
+
return {
|
|
386
|
+
panel,
|
|
387
|
+
grab,
|
|
388
|
+
inspect: free(INSPECT_KEYS),
|
|
389
|
+
replay: withShift(REPLAY_KEY),
|
|
390
|
+
requests: withShift(REQUESTS_KEY),
|
|
391
|
+
storage: withShift(STORAGE_KEY),
|
|
392
|
+
reset: withShift("backspace"),
|
|
393
|
+
elements: free(ELEMENTS_KEYS),
|
|
394
|
+
settings: free(SETTINGS_KEYS)
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
var KEYS_FIELD = "data-devknobs-keys";
|
|
398
|
+
function isTyping(node) {
|
|
399
|
+
const element = node;
|
|
400
|
+
const tag = element?.tagName;
|
|
401
|
+
if (tag === "INPUT" || tag === "TEXTAREA")
|
|
402
|
+
return true;
|
|
403
|
+
return element?.isContentEditable === true;
|
|
404
|
+
}
|
|
405
|
+
function focusInClosedRoot(node) {
|
|
406
|
+
if (typeof HTMLElement === "undefined" || !(node instanceof HTMLElement))
|
|
407
|
+
return false;
|
|
408
|
+
if (!node.tagName.includes("-"))
|
|
409
|
+
return false;
|
|
410
|
+
if (node.shadowRoot !== null || node.hasAttribute("tabindex") || node.tabIndex >= 0)
|
|
411
|
+
return false;
|
|
412
|
+
const root = node.getRootNode();
|
|
413
|
+
if (root instanceof Document) {
|
|
414
|
+
if (node === root.body || node === root.documentElement)
|
|
415
|
+
return false;
|
|
416
|
+
} else if (!(root instanceof ShadowRoot)) {
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
return root.activeElement === node;
|
|
420
|
+
}
|
|
421
|
+
function isEditable(node) {
|
|
422
|
+
return isTyping(node) || node?.tagName === "SELECT" || focusInClosedRoot(node);
|
|
423
|
+
}
|
|
424
|
+
function inField(event) {
|
|
425
|
+
return isEditable(event.composedPath?.()[0] ?? event.target);
|
|
426
|
+
}
|
|
427
|
+
function typesInField(event) {
|
|
428
|
+
const target = event.composedPath?.()[0] ?? event.target;
|
|
429
|
+
if (!isEditable(target))
|
|
430
|
+
return false;
|
|
431
|
+
return target?.hasAttribute?.(KEYS_FIELD) !== true;
|
|
432
|
+
}
|
|
433
|
+
function lowerKey(key) {
|
|
434
|
+
return key === "İ" ? "i" : key.toLowerCase();
|
|
435
|
+
}
|
|
436
|
+
function letterMatches(event, letter) {
|
|
437
|
+
const key = lowerKey(event.key);
|
|
438
|
+
if (key === letter)
|
|
439
|
+
return true;
|
|
440
|
+
return [...key].length === 1 && !/\p{Script=Latin}/u.test(key) && event.code === `Key${letter.toUpperCase()}`;
|
|
441
|
+
}
|
|
442
|
+
function keyIs(event, key) {
|
|
443
|
+
if (/^[a-z]$/.test(key)) {
|
|
444
|
+
return letterMatches(event, key) || event.altKey && event.code === `Key${key.toUpperCase()}`;
|
|
445
|
+
}
|
|
446
|
+
if (event.key.toLowerCase() === key)
|
|
447
|
+
return true;
|
|
448
|
+
if (/^[0-9]$/.test(key))
|
|
449
|
+
return event.code === `Digit${key}`;
|
|
450
|
+
return key === "backspace" && event.key === "Delete";
|
|
451
|
+
}
|
|
452
|
+
function comboMatches(event, combo) {
|
|
453
|
+
return event.isComposing !== true && event.metaKey === combo.meta && event.ctrlKey === combo.ctrl && event.shiftKey === combo.shift && event.altKey === combo.alt && keyIs(event, combo.key);
|
|
454
|
+
}
|
|
455
|
+
function actsHere(event, combo) {
|
|
456
|
+
if (isFunctionKey(combo.key))
|
|
457
|
+
return true;
|
|
458
|
+
if (deletes(combo.key) || !(combo.meta || combo.ctrl || combo.alt || combo.shift))
|
|
459
|
+
return !inField(event);
|
|
460
|
+
return !typesInField(event);
|
|
461
|
+
}
|
|
462
|
+
var REPLAY_KEY = "r";
|
|
463
|
+
var REQUESTS_KEY = "n";
|
|
464
|
+
var STORAGE_KEY = "s";
|
|
465
|
+
function keyAction(event, keys) {
|
|
466
|
+
if (event.key === "Escape")
|
|
467
|
+
return "close";
|
|
468
|
+
const steps = [
|
|
469
|
+
["toggle", keys.panel],
|
|
470
|
+
["replay", keys.replay],
|
|
471
|
+
["requests", keys.requests],
|
|
472
|
+
["reset", keys.reset],
|
|
473
|
+
["elements", keys.elements],
|
|
474
|
+
["settings", keys.settings],
|
|
475
|
+
["storage", keys.storage]
|
|
476
|
+
];
|
|
477
|
+
for (const [action, combo] of steps) {
|
|
478
|
+
if (combo && comboMatches(event, combo))
|
|
479
|
+
return actsHere(event, combo) ? action : null;
|
|
480
|
+
}
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
function isSearchKey(event) {
|
|
484
|
+
if (event.key !== "/" || event.altKey || event.ctrlKey || event.metaKey)
|
|
485
|
+
return false;
|
|
486
|
+
const target = event.composedPath?.()[0] ?? event.target;
|
|
487
|
+
return !isEditable(target);
|
|
488
|
+
}
|
|
489
|
+
function typeAhead(event) {
|
|
490
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.isComposing === true)
|
|
491
|
+
return null;
|
|
492
|
+
if ([...event.key].length !== 1 || event.key === " " || event.key === "/")
|
|
493
|
+
return null;
|
|
494
|
+
return isEditable(event.composedPath?.()[0] ?? event.target) ? null : event.key;
|
|
495
|
+
}
|
|
496
|
+
function zoomAction(event) {
|
|
497
|
+
if (!event.metaKey && !event.ctrlKey || event.altKey)
|
|
498
|
+
return null;
|
|
499
|
+
if (isTyping(event.composedPath?.()[0] ?? event.target))
|
|
500
|
+
return null;
|
|
501
|
+
if (event.key === "=" || event.key === "+")
|
|
502
|
+
return "zoom-in";
|
|
503
|
+
if (event.key === "-" || event.key === "_")
|
|
504
|
+
return "zoom-out";
|
|
505
|
+
return event.key === "0" ? "zoom-fit" : null;
|
|
506
|
+
}
|
|
507
|
+
function escapeStep(scene) {
|
|
508
|
+
if (scene.search)
|
|
509
|
+
return "search";
|
|
510
|
+
if (scene.filter)
|
|
511
|
+
return "filter";
|
|
512
|
+
if (scene.keys)
|
|
513
|
+
return "keys";
|
|
514
|
+
if (scene.view)
|
|
515
|
+
return "view";
|
|
516
|
+
if (scene.editor)
|
|
517
|
+
return "editor";
|
|
518
|
+
return "panel";
|
|
519
|
+
}
|
|
520
|
+
function highlightAt(cursor, count, newQuery = false) {
|
|
521
|
+
return Math.min(Math.max(newQuery ? 0 : cursor, 0), count - 1);
|
|
522
|
+
}
|
|
523
|
+
function paletteMove(key, cursor, count) {
|
|
524
|
+
if (key === "ArrowDown" || key === "ArrowUp") {
|
|
525
|
+
return { cursor: highlightAt(cursor + (key === "ArrowDown" ? 1 : -1), count), pick: false };
|
|
526
|
+
}
|
|
527
|
+
if (key === "Enter")
|
|
528
|
+
return { cursor: highlightAt(cursor, count), pick: count > 0 };
|
|
529
|
+
return null;
|
|
530
|
+
}
|
|
531
|
+
function radioMove(key, index, count) {
|
|
532
|
+
if (count === 0)
|
|
533
|
+
return null;
|
|
534
|
+
if (key === "ArrowRight" || key === "ArrowDown")
|
|
535
|
+
return (index + 1) % count;
|
|
536
|
+
if (key === "ArrowLeft" || key === "ArrowUp")
|
|
537
|
+
return (index - 1 + count) % count;
|
|
538
|
+
if (key === "Home")
|
|
539
|
+
return 0;
|
|
540
|
+
return key === "End" ? count - 1 : null;
|
|
541
|
+
}
|
|
542
|
+
function forwardKeys(keys = () => defaultKeys(), open = () => true) {
|
|
543
|
+
function onKeydown(event) {
|
|
544
|
+
const zoom = zoomAction(event);
|
|
545
|
+
const search = isSearchKey(event) && open();
|
|
546
|
+
const panelAction = keyAction(event, keys());
|
|
547
|
+
if (zoom || search || panelAction && panelAction !== "close")
|
|
548
|
+
event.preventDefault();
|
|
549
|
+
const action = panelAction ?? zoom ?? (search ? "search" : null);
|
|
550
|
+
if (action)
|
|
551
|
+
post(window.parent, { source: "devknobs", type: "key", action });
|
|
552
|
+
}
|
|
553
|
+
window.addEventListener("keydown", onKeydown, true);
|
|
554
|
+
return () => window.removeEventListener("keydown", onKeydown, true);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// src/grab/hit.ts
|
|
558
|
+
var MAX_DEPTH = 32;
|
|
559
|
+
var MAX_LAYERS = 8;
|
|
560
|
+
var REPLACED = new Set([
|
|
561
|
+
"audio",
|
|
562
|
+
"br",
|
|
563
|
+
"canvas",
|
|
564
|
+
"embed",
|
|
565
|
+
"hr",
|
|
566
|
+
"iframe",
|
|
567
|
+
"img",
|
|
568
|
+
"input",
|
|
569
|
+
"meter",
|
|
570
|
+
"object",
|
|
571
|
+
"progress",
|
|
572
|
+
"select",
|
|
573
|
+
"svg",
|
|
574
|
+
"textarea",
|
|
575
|
+
"video"
|
|
576
|
+
]);
|
|
577
|
+
var CLEAR_COLOR = /^transparent$|[,/]\s*0\)$/;
|
|
578
|
+
function composedParent(element) {
|
|
579
|
+
if (element.parentElement)
|
|
580
|
+
return element.parentElement;
|
|
581
|
+
const root = element.getRootNode?.();
|
|
582
|
+
return root && "host" in root ? root.host : null;
|
|
583
|
+
}
|
|
584
|
+
function isDevknobs(element) {
|
|
585
|
+
for (let current = element;current; current = composedParent(current)) {
|
|
586
|
+
if (current.hasAttribute("data-devknobs"))
|
|
587
|
+
return true;
|
|
588
|
+
}
|
|
589
|
+
return false;
|
|
590
|
+
}
|
|
591
|
+
function isRoot(element) {
|
|
592
|
+
const tag = element.tagName.toLowerCase();
|
|
593
|
+
return tag === "html" || tag === "body";
|
|
594
|
+
}
|
|
595
|
+
function isGrabbable(element) {
|
|
596
|
+
return element !== null && !isRoot(element) && !isDevknobs(element);
|
|
597
|
+
}
|
|
598
|
+
function styleOf(element) {
|
|
599
|
+
return element.ownerDocument.defaultView?.getComputedStyle(element) ?? null;
|
|
600
|
+
}
|
|
601
|
+
function inside(rect, x, y) {
|
|
602
|
+
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
|
|
603
|
+
}
|
|
604
|
+
function holds(element, x, y) {
|
|
605
|
+
if (!inside(element.getBoundingClientRect(), x, y))
|
|
606
|
+
return false;
|
|
607
|
+
const rects = element.getClientRects();
|
|
608
|
+
for (let index = 0;index < rects.length; index++) {
|
|
609
|
+
const rect = rects[index];
|
|
610
|
+
if (rect && rect.width > 0 && rect.height > 0 && inside(rect, x, y))
|
|
611
|
+
return true;
|
|
612
|
+
}
|
|
613
|
+
return false;
|
|
614
|
+
}
|
|
615
|
+
function area(element) {
|
|
616
|
+
const rect = element.getBoundingClientRect();
|
|
617
|
+
return rect.width * rect.height;
|
|
618
|
+
}
|
|
619
|
+
function isHidden(element) {
|
|
620
|
+
const visibility = styleOf(element)?.visibility;
|
|
621
|
+
return visibility !== undefined && visibility !== "visible";
|
|
622
|
+
}
|
|
623
|
+
function isClearLayer(element) {
|
|
624
|
+
if (element.children.length > 0 || element.shadowRoot)
|
|
625
|
+
return false;
|
|
626
|
+
if (REPLACED.has(element.tagName.toLowerCase()) || element.textContent?.trim())
|
|
627
|
+
return false;
|
|
628
|
+
const style = styleOf(element);
|
|
629
|
+
if (!style)
|
|
630
|
+
return false;
|
|
631
|
+
return style.backgroundImage === "none" && CLEAR_COLOR.test(style.backgroundColor);
|
|
632
|
+
}
|
|
633
|
+
function under(root, top, x, y) {
|
|
634
|
+
if (!root.elementsFromPoint || holds(top, x, y) && !isClearLayer(top))
|
|
635
|
+
return top;
|
|
636
|
+
for (const element of root.elementsFromPoint(x, y).slice(0, MAX_LAYERS)) {
|
|
637
|
+
if (element === top || !isGrabbable(element))
|
|
638
|
+
continue;
|
|
639
|
+
if (holds(element, x, y) && !isClearLayer(element))
|
|
640
|
+
return element;
|
|
641
|
+
}
|
|
642
|
+
return top;
|
|
643
|
+
}
|
|
644
|
+
function descend(start, x, y) {
|
|
645
|
+
let current = start;
|
|
646
|
+
for (let depth = 0;depth < MAX_DEPTH; depth += 1) {
|
|
647
|
+
let best = null;
|
|
648
|
+
let smallest = Number.POSITIVE_INFINITY;
|
|
649
|
+
for (const children of [current.children, current.shadowRoot?.children]) {
|
|
650
|
+
if (!children)
|
|
651
|
+
continue;
|
|
652
|
+
for (let index = 0;index < children.length; index++) {
|
|
653
|
+
const child = children[index];
|
|
654
|
+
if (!child || child.hasAttribute("data-devknobs") || !holds(child, x, y))
|
|
655
|
+
continue;
|
|
656
|
+
if (isHidden(child) || isClearLayer(child))
|
|
657
|
+
continue;
|
|
658
|
+
const size = area(child);
|
|
659
|
+
if (size > smallest)
|
|
660
|
+
continue;
|
|
661
|
+
best = child;
|
|
662
|
+
smallest = size;
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
if (!best)
|
|
666
|
+
break;
|
|
667
|
+
current = best;
|
|
668
|
+
}
|
|
669
|
+
return current;
|
|
670
|
+
}
|
|
671
|
+
function deepElementAt(root, x, y) {
|
|
672
|
+
let element = root.elementFromPoint(x, y);
|
|
673
|
+
while (element?.shadowRoot) {
|
|
674
|
+
const inner = element.shadowRoot.elementFromPoint(x, y);
|
|
675
|
+
if (!inner || inner === element)
|
|
676
|
+
break;
|
|
677
|
+
element = inner;
|
|
678
|
+
}
|
|
679
|
+
if (!isGrabbable(element))
|
|
680
|
+
return element;
|
|
681
|
+
return descend(under(root, element, x, y), x, y);
|
|
682
|
+
}
|
|
683
|
+
function grabTargetAt(root, x, y) {
|
|
684
|
+
const element = deepElementAt(root, x, y);
|
|
685
|
+
return isGrabbable(element) ? element : null;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
export { composedParent, isDevknobs, isGrabbable, grabTargetAt, ROW_ICONS, rowIcon, BINDING_ICONS, icon, glyph, parseCombo, comboText, withShift, isFunctionKey, comboLabel, comboSpoken, defaultKeys, KEYS_FIELD, inField, typesInField, lowerKey, letterMatches, keyIs, keyAction, isSearchKey, typeAhead, zoomAction, escapeStep, highlightAt, paletteMove, radioMove, forwardKeys };
|