@pictogrammers/components 0.5.14 → 0.5.17
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/package.json +1 -1
- package/pg/autocompleteItem/__examples__/basic/basic.html +3 -0
- package/pg/autocompleteItem/autocompleteItem.css +55 -0
- package/pg/autocompleteItem/autocompleteItem.html +1 -0
- package/pg/autocompleteItem/autocompleteItem.ts +65 -0
- package/pg/button/button.css +5 -0
- package/pg/buttonMenu/buttonMenu.ts +1 -1
- package/pg/inputCombobox/__examples__/basic/basic.ts +33 -0
- package/pg/inputCombobox/inputCombobox.ts +158 -0
- package/pg/inputCombobox/inputCombobox.ts.tmp.44252.751480cb81cc +158 -0
- package/pg/inputCombobox/inputCombobox.ts.tmp.44252.dcea847c40a8 +156 -0
- package/pg/inputNumber/inputNumber.ts +31 -13
- package/pg/inputPill/inputPill.html +6 -0
- package/pg/inputPill/inputPill.html.tmp.26852.84ac63f4c46f +6 -0
- package/pg/inputPill/inputPill.ts +41 -0
- package/pg/inputPills/__examples__/basic/basic.html +9 -0
- package/pg/inputPills/__examples__/basic/basic.html.tmp.26852.4771e4cad5b7 +9 -0
- package/pg/inputPills/__examples__/basic/basic.ts.tmp.26852.d8fe41df18bd +0 -0
- package/pg/inputPixelEditor/README.md +104 -69
- package/pg/inputPixelEditor/README.md.tmp.42596.658de5f0a6f5 +0 -0
- package/pg/inputPixelEditor/__examples__/basic/basic.ts +6 -5
- package/pg/inputPixelEditor/inputPixelEditor.ts +95 -23
- package/pg/inputPixelEditor/inputPixelEditor.ts.tmp.38516.96529dd82670 +1703 -0
- package/pg/inputPixelEditor/inputPixelEditor.ts.tmp.42596.48ecc3ad9c72 +1724 -0
- package/pg/inputPixelEditor/utils/bitmapToMask.ts +113 -79
- package/pg/inputPixelEditor/utils/getLassoPixels.ts +51 -0
- package/pg/inputRange/inputRange.css +7 -0
- package/pg/inputSelect/__examples__/basic/basic.ts +2 -2
- package/pg/inputSelect/inputSelect.css +1 -1
- package/pg/inputSelect/inputSelect.ts +62 -5
- package/pg/inputText/README.md +6 -6
- package/pg/inputText/__examples__/basic/basic.ts +1 -1
- package/pg/inputText/inputText.css +2 -2
- package/pg/inputText copy/README.md +38 -0
- package/pg/inputText copy/inputText.css +41 -0
- package/pg/inputText copy/inputText.html +1 -0
- package/pg/inputText copy/inputText.spec.ts +59 -0
- package/pg/inputText copy/inputText.ts +67 -0
- package/pg/inputTextarea/README.md +39 -0
- package/pg/inputTextarea/__examples__/basic/basic.html +9 -0
- package/pg/inputTextarea/__examples__/basic/basic.ts +30 -0
- package/pg/inputTextarea/inputTextarea.ts +121 -0
- package/pg/inputTextarea copy/README.md +39 -0
- package/pg/inputTextarea copy/inputTextarea.css +41 -0
- package/pg/inputTextarea copy/inputTextarea.html +1 -0
- package/pg/inputTextarea copy/inputTextarea.spec.ts +59 -0
- package/pg/inputTextarea copy/inputTextarea.ts +79 -0
- package/pg/inputTextareaAutocomplete/README.md +70 -0
- package/pg/inputTextareaAutocomplete/__examples__/basic/basic.ts +67 -0
- package/pg/inputTextareaAutocomplete/inputTextareaAutocomplete.ts +267 -0
- package/pg/node/README.md +35 -0
- package/pg/node/__examples__/basic/basic.ts +34 -0
- package/pg/node/index.ts +3 -0
- package/pg/node/node.css +53 -0
- package/pg/node/node.html +5 -0
- package/pg/node/node.ts +270 -0
- package/pg/nodeEditorLink/nodeEditorLink.css +69 -0
- package/pg/nodeEditorLink/nodeEditorLink.css.tmp.1408.09e961fd0dcc +69 -0
- package/pg/nodeEditorLink/nodeEditorLink.html +9 -0
- package/pg/nodeEditorNumber/nodeEditorNumber.css +59 -0
- package/pg/nodeEditorNumber/nodeEditorNumber.ts +57 -0
- package/pg/nodeEditorRange/nodeEditorRange.css +23 -0
- package/pg/nodeEditorRange/nodeEditorRange.ts +69 -0
- package/pg/nodeEditorText/__examples__/basic/basic.html +9 -0
- package/pg/nodeEditorText/__examples__/basic/basic.ts +30 -0
- package/pg/nodeEditorText/nodeEditorText.css +17 -0
- package/pg/nodeEditorText/nodeEditorText.html +4 -0
- package/pg/nodeEditorText/nodeEditorText.ts +57 -0
- package/pg/nodeEditorText copy/README.md +35 -0
- package/pg/nodeEditorText copy/nodeEditorText.css +49 -0
- package/pg/nodeEditorText copy/nodeEditorText.html +4 -0
- package/pg/nodeEditorText copy/nodeEditorText.ts +50 -0
- package/pg/nodeEditorTextArray/nodeEditorTextArray.css +68 -0
- package/pg/nodeEditorTextArray/nodeEditorTextArray.html +9 -0
- package/pg/nodeEditorTextArray/nodeEditorTextArray.ts +162 -0
- package/pg/nodeEntry/nodeEntry.css +61 -0
- package/pg/nodeEntry/nodeEntry.ts +164 -0
- package/pg/nodeEntry/nodeEntry.ts.tmp.28724.dda67762bca5 +164 -0
- package/pg/nodeInputText/nodeInputText.css +75 -0
- package/pg/nodeInputText/nodeInputText.html +4 -0
- package/pg/nodeInputText/nodeInputText.ts +105 -0
- package/pg/nodeOutput/nodeOutput.css +32 -0
- package/pg/nodeResize/README.md +3 -0
- package/pg/nodeResize/THINKING.md +81 -0
- package/pg/nodeResize/THINKING.md.tmp.24812.99a70ba81062 +81 -0
- package/pg/nodeResize/basic/basic.ts +17 -0
- package/pg/nodeResize/dragUtil.ts +105 -0
- package/pg/nodeResize/dragUtil.ts.tmp.34372.787464c73309 +75 -0
- package/pg/nodeResize/nodeResize.css +187 -0
- package/pg/nodeResize/nodeResize.html +9 -0
- package/pg/nodeResize/nodeResize.ts +156 -0
- package/pg/nodes/README.md +177 -0
- package/pg/nodes/__examples__/basic/basic.html +33 -0
- package/pg/nodes/__examples__/basic/basic.ts +716 -0
- package/pg/nodes/__examples__/basic/exampleNodes.ts +129 -0
- package/pg/nodes/__examples__/basic/exampleScripts.ts +129 -0
- package/pg/nodes/__examples__/basic/keystore.ts +38 -0
- package/pg/nodes/executeInSandbox.ts +32 -0
- package/pg/nodes/index.ts +3 -0
- package/pg/nodes/nodes.css +69 -0
- package/pg/nodes/nodes.html +6 -0
- package/pg/nodes/nodes.ts +1240 -0
- package/pg/nodes copy/nodes.css +41 -0
- package/pg/nodes copy/nodes.html +1 -0
- package/pg/overlayContextMenu/__examples__/filter/filter.ts +87 -0
- package/pg/overlayContextMenu/overlayContextMenu.css +14 -0
- package/pg/overlayContextMenu/overlayContextMenu.html +4 -3
- package/pg/overlayContextMenu/overlayContextMenu.ts +6 -2
- package/pg/overlayContextMenu/overlayContextMenu.ts.tmp.37088.530ff1c0a321 +0 -0
- package/pg/overlayMenu/overlayMenu.css +3 -1
- package/pg/overlayMenu/overlayMenu.ts +11 -2
- package/pg/overlayMenu/overlayMenu.ts.tmp.44252.9bb22fd59ede +80 -0
- package/pg/overlaySelectMenu/overlaySelectMenu.css +2 -0
- package/pg/overlaySubMenu/overlaySubMenu.css +8 -6
- package/pg/poco/README.md +22 -0
- package/pg/poco/__examples__/basic/basic.html +11 -0
- package/pg/poco/__examples__/basic/basic.ts +95 -0
- package/pg/poco/__examples__/basic/examples.ts +258 -0
- package/pg/poco/__examples__/basic/myFont.ts +1300 -0
- package/pg/poco/index.ts +3 -0
- package/pg/poco/mockPoco.ts +640 -0
- package/pg/poco/poco.css +7 -0
- package/pg/poco/poco.html +1 -0
- package/pg/poco/poco.ts +75 -0
- package/pg/popover/README.md +47 -0
- package/pg/popover/__examples__/basic/basic.html +3 -0
- package/pg/popover/popover.html +3 -0
- package/pg/popover/popover.ts +44 -0
- package/pg/popoverAutocomplete/__examples__/basic/basic.html +4 -0
- package/pg/popoverAutocomplete/__examples__/basic/basic.ts +46 -0
- package/pg/popoverAutocomplete/popoverAutocomplete.css +25 -0
- package/pg/popoverAutocomplete/popoverAutocomplete.html +1 -0
- package/pg/popoverAutocomplete/popoverAutocomplete.ts +134 -0
- package/pg/popoverAutocompleteItem/popoverAutocompleteItem.css +69 -0
- package/pg/popoverAutocompleteItem/popoverAutocompleteItem.ts +90 -0
- package/pg/table/__examples__/basic/basic.ts +1 -0
- package/pg/tableCellFileLocal/tableCellFileLocal.html +3 -0
- package/pg/tableCellFileLocal/tableCellFileLocal.html.tmp.20484.68ee2e30710e +3 -0
- package/pg/tableCellFileLocal/tableCellFileLocal.ts +44 -0
- package/pg/tableCellSelect/tableCellSelect.html +3 -0
- package/pg/tableCellSelect/tableCellSelect.html.tmp.41808.99c1a6f14340 +3 -0
- package/pg/tableCellSelect/tableCellSelect.ts +51 -0
- package/pg/tree/__examples__/basic/basic.ts +12 -5
- package/pg/tree/tree.html +1 -1
- package/pg/tree/tree.ts +385 -227
- package/pg/tree/tree.ts.tmp.38376.07d376a04f41 +343 -0
- package/pg/tree/tree.ts.tmp.38376.2a04599ade9f +361 -0
- package/pg/tree/tree.ts.tmp.38376.6cb2c663d476 +0 -0
- package/pg/tree/tree.ts.tmp.38376.ac5af1aff2b0 +393 -0
- package/pg/tree/tree.ts.tmp.38376.ac9acfc4f95f +324 -0
- package/pg/treeItem/treeItem.ts +536 -558
- package/pg/treeItem/treeItem.ts.tmp.38376.145d3121d648 +530 -0
- package/pg/treeItem/treeItem.ts.tmp.38376.b5224d48e5c0 +0 -0
package/pg/treeItem/treeItem.ts
CHANGED
|
@@ -1,558 +1,536 @@
|
|
|
1
|
-
import { Component, Prop, Part, forEach } from '@pictogrammers/element';
|
|
2
|
-
|
|
3
|
-
import PgIcon from '../icon/icon';
|
|
4
|
-
import PgTreeButtonIcon from '../treeButtonIcon/treeButtonIcon';
|
|
5
|
-
|
|
6
|
-
import template from './treeItem.html';
|
|
7
|
-
import style from './treeItem.css';
|
|
8
|
-
|
|
9
|
-
const noIcon = 'M0 0h24v24H0V0zm2 2v20h20V2H2z';
|
|
10
|
-
|
|
11
|
-
@Component({
|
|
12
|
-
selector: 'pg-tree-item',
|
|
13
|
-
style,
|
|
14
|
-
template
|
|
15
|
-
})
|
|
16
|
-
export default class PgTreeItem extends HTMLElement {
|
|
17
|
-
|
|
18
|
-
@Prop() index: number;
|
|
19
|
-
@Prop() label: string = '';
|
|
20
|
-
@Prop() selected: boolean = false;
|
|
21
|
-
@Prop() expanded: boolean = false;
|
|
22
|
-
@Prop()
|
|
23
|
-
@Prop()
|
|
24
|
-
@Prop()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@Part() $
|
|
28
|
-
@Part() $
|
|
29
|
-
@Part() $
|
|
30
|
-
@Part() $
|
|
31
|
-
@Part() $
|
|
32
|
-
@Part() $
|
|
33
|
-
@Part() $
|
|
34
|
-
@Part() $
|
|
35
|
-
@Part() $
|
|
36
|
-
@Part() $
|
|
37
|
-
@Part() $
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.$
|
|
42
|
-
this.$item.addEventListener('
|
|
43
|
-
this.$item.addEventListener('
|
|
44
|
-
this.$item.addEventListener('
|
|
45
|
-
this.$item.addEventListener('
|
|
46
|
-
this.$
|
|
47
|
-
this.$labelButton.addEventListener('
|
|
48
|
-
this.$labelButton.addEventListener('
|
|
49
|
-
this.$
|
|
50
|
-
this.$iconButton.addEventListener('
|
|
51
|
-
this.$iconButton.addEventListener('
|
|
52
|
-
this.$
|
|
53
|
-
this.$
|
|
54
|
-
this.$input.addEventListener('
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.$items.addEventListener('
|
|
58
|
-
this.$items.addEventListener('
|
|
59
|
-
this.$items.addEventListener('
|
|
60
|
-
this.$items.addEventListener('
|
|
61
|
-
this.$items.addEventListener('
|
|
62
|
-
this.$items.addEventListener('
|
|
63
|
-
this.$items.addEventListener('
|
|
64
|
-
this.$items.addEventListener('
|
|
65
|
-
this.$items.addEventListener('
|
|
66
|
-
|
|
67
|
-
this.$
|
|
68
|
-
this.$
|
|
69
|
-
|
|
70
|
-
this.$dropabove.addEventListener('
|
|
71
|
-
this.$
|
|
72
|
-
this.$
|
|
73
|
-
this.$
|
|
74
|
-
this.$dropon.addEventListener('
|
|
75
|
-
this.$
|
|
76
|
-
this.$
|
|
77
|
-
this.$
|
|
78
|
-
this.$dropbelow.addEventListener('
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.$
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
#
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
#
|
|
235
|
-
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
#
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
this.$
|
|
333
|
-
this.$
|
|
334
|
-
this.$input.
|
|
335
|
-
|
|
336
|
-
break;
|
|
337
|
-
case '
|
|
338
|
-
this.dispatchEvent(new CustomEvent('
|
|
339
|
-
bubbles: true,
|
|
340
|
-
composed: true,
|
|
341
|
-
detail: { indexes: [this.index] }
|
|
342
|
-
}));
|
|
343
|
-
this.$labelButton.classList.remove('hide');
|
|
344
|
-
this.$actions.classList.remove('hide');
|
|
345
|
-
this.$input.classList.add('hide');
|
|
346
|
-
e.preventDefault();
|
|
347
|
-
break;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
ctx.
|
|
398
|
-
ctx.
|
|
399
|
-
ctx.
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
(
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
ctx.
|
|
408
|
-
ctx.
|
|
409
|
-
ctx.
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
(
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
this
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
this
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
this
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
e.
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
bubbles: true,
|
|
538
|
-
composed: true,
|
|
539
|
-
detail: {
|
|
540
|
-
indexes: [this.index],
|
|
541
|
-
position: 'on'
|
|
542
|
-
}
|
|
543
|
-
}));
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
#handleDropBelow(e: any) {
|
|
547
|
-
e.target.classList.toggle('drop', false);
|
|
548
|
-
this.dispatchEvent(new CustomEvent('move', {
|
|
549
|
-
bubbles: true,
|
|
550
|
-
composed: true,
|
|
551
|
-
detail: {
|
|
552
|
-
indexes: [this.index],
|
|
553
|
-
position: 'after'
|
|
554
|
-
}
|
|
555
|
-
}));
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
}
|
|
1
|
+
import { Component, Prop, Part, forEach } from '@pictogrammers/element';
|
|
2
|
+
|
|
3
|
+
import PgIcon from '../icon/icon';
|
|
4
|
+
import PgTreeButtonIcon from '../treeButtonIcon/treeButtonIcon';
|
|
5
|
+
|
|
6
|
+
import template from './treeItem.html';
|
|
7
|
+
import style from './treeItem.css';
|
|
8
|
+
|
|
9
|
+
const noIcon = 'M0 0h24v24H0V0zm2 2v20h20V2H2z';
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'pg-tree-item',
|
|
13
|
+
style,
|
|
14
|
+
template
|
|
15
|
+
})
|
|
16
|
+
export default class PgTreeItem extends HTMLElement {
|
|
17
|
+
|
|
18
|
+
@Prop() index: number;
|
|
19
|
+
@Prop() label: string = '';
|
|
20
|
+
@Prop() selected: boolean = false;
|
|
21
|
+
@Prop() expanded: boolean = false;
|
|
22
|
+
@Prop() isFolder: boolean = false;
|
|
23
|
+
@Prop() icon: { path: string } = { path: noIcon };
|
|
24
|
+
@Prop() actions: any[] = [];
|
|
25
|
+
@Prop() items: any[] = [];
|
|
26
|
+
|
|
27
|
+
@Part() $toggle: HTMLButtonElement;
|
|
28
|
+
@Part() $item: HTMLDivElement;
|
|
29
|
+
@Part() $input: HTMLInputElement;
|
|
30
|
+
@Part() $iconButton: HTMLButtonElement;
|
|
31
|
+
@Part() $icon: PgIcon;
|
|
32
|
+
@Part() $label: HTMLDivElement;
|
|
33
|
+
@Part() $labelButton: HTMLButtonElement;
|
|
34
|
+
@Part() $actions: HTMLDivElement;
|
|
35
|
+
@Part() $items: HTMLDivElement;
|
|
36
|
+
@Part() $dropabove: HTMLDivElement;
|
|
37
|
+
@Part() $dropon: HTMLDivElement;
|
|
38
|
+
@Part() $dropbelow: HTMLDivElement;
|
|
39
|
+
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
this.$toggle.addEventListener('click', this.#handleToggleClick.bind(this));
|
|
42
|
+
this.$item.addEventListener('action', this.#handleItemAction.bind(this));
|
|
43
|
+
this.$item.addEventListener('pointerenter', this.#handlePointerEnter.bind(this));
|
|
44
|
+
this.$item.addEventListener('pointerleave', this.#handlePointerLeave.bind(this));
|
|
45
|
+
this.$item.addEventListener('dragstart', this.#handleDragStart.bind(this));
|
|
46
|
+
this.$item.addEventListener('dragend', this.#handleDragEnd.bind(this));
|
|
47
|
+
this.$labelButton.addEventListener('dblclick', this.#handleDoubleClick.bind(this));
|
|
48
|
+
this.$labelButton.addEventListener('click', this.#handleClick.bind(this));
|
|
49
|
+
this.$labelButton.addEventListener('keydown', this.#handleKeyDownLabel.bind(this));
|
|
50
|
+
this.$iconButton.addEventListener('dblclick', this.#handleIconDoubleClick.bind(this));
|
|
51
|
+
this.$iconButton.addEventListener('click', this.#handleIconClick.bind(this));
|
|
52
|
+
this.$iconButton.addEventListener('keydown', this.#handleIconKeyDown.bind(this));
|
|
53
|
+
this.$item.addEventListener('contextmenu', this.#handleContextMenu.bind(this));
|
|
54
|
+
this.$input.addEventListener('blur', this.#handleBlur.bind(this));
|
|
55
|
+
this.$input.addEventListener('keydown', this.#handleInputKeyDown.bind(this));
|
|
56
|
+
// Bubble indexes up through nested items containers
|
|
57
|
+
this.$items.addEventListener('action', this.#handleAction.bind(this));
|
|
58
|
+
this.$items.addEventListener('move', this.#handleMove.bind(this));
|
|
59
|
+
this.$items.addEventListener('toggle', this.#handleToggle.bind(this));
|
|
60
|
+
this.$items.addEventListener('select', this.#handleSelect.bind(this));
|
|
61
|
+
this.$items.addEventListener('rename', this.#handleRename.bind(this));
|
|
62
|
+
this.$items.addEventListener('menu', this.#handleMenu.bind(this));
|
|
63
|
+
this.$items.addEventListener('up', this.#handleUp.bind(this));
|
|
64
|
+
this.$items.addEventListener('down', this.#handleDown.bind(this));
|
|
65
|
+
this.$items.addEventListener('itemdragstart', this.#handleItemDragStart.bind(this));
|
|
66
|
+
this.$items.addEventListener('itemdragend', this.#handleItemDragEnd.bind(this));
|
|
67
|
+
this.$items.addEventListener('itemdropenter', this.#handleItemDropEnter.bind(this));
|
|
68
|
+
this.$items.addEventListener('expand', this.#handleItemExpand.bind(this));
|
|
69
|
+
// Drop zones
|
|
70
|
+
this.$dropabove.addEventListener('dragenter', this.#handleDragAboveEnter.bind(this));
|
|
71
|
+
this.$dropabove.addEventListener('dragleave', this.#handleDragAboveLeave.bind(this));
|
|
72
|
+
this.$dropabove.addEventListener('dragover', this.#handleDragOver.bind(this));
|
|
73
|
+
this.$dropabove.addEventListener('drop', this.#handleDragAbove.bind(this));
|
|
74
|
+
this.$dropon.addEventListener('dragenter', this.#handleDragOnEnter.bind(this));
|
|
75
|
+
this.$dropon.addEventListener('dragleave', this.#handleDragOnLeave.bind(this));
|
|
76
|
+
this.$dropon.addEventListener('dragover', this.#handleDragOver.bind(this));
|
|
77
|
+
this.$dropon.addEventListener('drop', this.#handleDropOn.bind(this));
|
|
78
|
+
this.$dropbelow.addEventListener('dragenter', this.#handleDragBelowEnter.bind(this));
|
|
79
|
+
this.$dropbelow.addEventListener('dragleave', this.#handleDragBelowLeave.bind(this));
|
|
80
|
+
this.$dropbelow.addEventListener('dragover', this.#handleDragOver.bind(this));
|
|
81
|
+
this.$dropbelow.addEventListener('drop', this.#handleDropBelow.bind(this));
|
|
82
|
+
|
|
83
|
+
forEach({
|
|
84
|
+
container: this.$actions,
|
|
85
|
+
items: this.actions,
|
|
86
|
+
type: (item) => item.type || PgTreeButtonIcon
|
|
87
|
+
});
|
|
88
|
+
if (this.expanded) {
|
|
89
|
+
this.#initItems();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
disconnectedCallback() {
|
|
94
|
+
window.clearTimeout(this.#dragOnTimer);
|
|
95
|
+
this.#canvas?.remove();
|
|
96
|
+
this.#canvas = null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
#initItemsOnce = true;
|
|
100
|
+
#initItems() {
|
|
101
|
+
if (this.#initItemsOnce) {
|
|
102
|
+
forEach({
|
|
103
|
+
container: this.$items,
|
|
104
|
+
items: this.items,
|
|
105
|
+
type: () => PgTreeItem
|
|
106
|
+
});
|
|
107
|
+
this.#initItemsOnce = false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
render(changes: Record<string, boolean>) {
|
|
112
|
+
if (changes.label) {
|
|
113
|
+
this.$label.textContent = this.label;
|
|
114
|
+
}
|
|
115
|
+
if (changes.icon && this.icon) {
|
|
116
|
+
this.$icon.path = this.icon.path;
|
|
117
|
+
}
|
|
118
|
+
if (changes.selected) {
|
|
119
|
+
this.$item.classList.toggle('selected', this.selected);
|
|
120
|
+
}
|
|
121
|
+
if (changes.items || changes.isFolder) {
|
|
122
|
+
this.$item.classList.toggle('items', this.isFolder || this.items.length !== 0);
|
|
123
|
+
}
|
|
124
|
+
if (changes.expanded) {
|
|
125
|
+
if (this.expanded) {
|
|
126
|
+
this.#initItems();
|
|
127
|
+
}
|
|
128
|
+
this.$item.classList.toggle('expanded', this.expanded);
|
|
129
|
+
this.$items.classList.toggle('expanded', this.expanded);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
#handleToggleClick() {
|
|
134
|
+
this.dispatchEvent(new CustomEvent('toggle', {
|
|
135
|
+
bubbles: true,
|
|
136
|
+
composed: true,
|
|
137
|
+
detail: { indexes: [this.index] }
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#handleIconDoubleClick(e: MouseEvent) {
|
|
142
|
+
if (e.ctrlKey || e.shiftKey) return;
|
|
143
|
+
this.dispatchEvent(new CustomEvent('select', {
|
|
144
|
+
bubbles: true,
|
|
145
|
+
composed: true,
|
|
146
|
+
detail: {
|
|
147
|
+
type: 'icondoubleclick',
|
|
148
|
+
indexes: [this.index]
|
|
149
|
+
}
|
|
150
|
+
}));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
#handleIconClick() {
|
|
154
|
+
this.dispatchEvent(new CustomEvent('select', {
|
|
155
|
+
bubbles: true,
|
|
156
|
+
composed: true,
|
|
157
|
+
detail: {
|
|
158
|
+
type: 'icon',
|
|
159
|
+
indexes: [this.index]
|
|
160
|
+
}
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#handleClick(e: MouseEvent) {
|
|
165
|
+
if (this.#ignoreNextClick) {
|
|
166
|
+
this.#ignoreNextClick = false;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.dispatchEvent(new CustomEvent('select', {
|
|
170
|
+
bubbles: true,
|
|
171
|
+
composed: true,
|
|
172
|
+
detail: {
|
|
173
|
+
type: 'label',
|
|
174
|
+
indexes: [this.index],
|
|
175
|
+
ctrlKey: e.ctrlKey,
|
|
176
|
+
shiftKey: e.shiftKey
|
|
177
|
+
}
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
#handleKeyDownLabel(e: KeyboardEvent) {
|
|
182
|
+
if (e.key === 'Enter') {
|
|
183
|
+
this.#enableRename();
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
} else if (e.key === 'ArrowUp') {
|
|
186
|
+
this.dispatchEvent(new CustomEvent('up', {
|
|
187
|
+
bubbles: true,
|
|
188
|
+
composed: true,
|
|
189
|
+
detail: { indexes: [this.index] }
|
|
190
|
+
}));
|
|
191
|
+
e.preventDefault();
|
|
192
|
+
} else if (e.key === 'ArrowDown') {
|
|
193
|
+
this.dispatchEvent(new CustomEvent('down', {
|
|
194
|
+
bubbles: true,
|
|
195
|
+
composed: true,
|
|
196
|
+
detail: { indexes: [this.index] }
|
|
197
|
+
}));
|
|
198
|
+
e.preventDefault();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
#handlePointerEnter() {
|
|
203
|
+
this.dispatchEvent(new CustomEvent('enter', {
|
|
204
|
+
bubbles: true,
|
|
205
|
+
composed: true,
|
|
206
|
+
detail: { indexes: [this.index] }
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
#handlePointerLeave() {
|
|
211
|
+
this.dispatchEvent(new CustomEvent('leave', {
|
|
212
|
+
bubbles: true,
|
|
213
|
+
composed: true,
|
|
214
|
+
detail: { indexes: [this.index] }
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
#handleItemAction(e: any) {
|
|
219
|
+
e.stopPropagation();
|
|
220
|
+
this.dispatchEvent(new CustomEvent('action', {
|
|
221
|
+
bubbles: true,
|
|
222
|
+
composed: true,
|
|
223
|
+
detail: {
|
|
224
|
+
indexes: [this.index],
|
|
225
|
+
actionIndex: e.detail.index
|
|
226
|
+
}
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
#handleAction(e: any) { e.detail.indexes.unshift(this.index); }
|
|
231
|
+
#handleMove(e: any) { e.detail.indexes.unshift(this.index); }
|
|
232
|
+
#handleToggle(e: any) { e.detail.indexes.unshift(this.index); }
|
|
233
|
+
#handleRename(e: any) { e.detail.indexes.unshift(this.index); }
|
|
234
|
+
#handleMenu(e: any) { e.detail.indexes.unshift(this.index); }
|
|
235
|
+
#handleUp(e: any) { e.detail.indexes.unshift(this.index); }
|
|
236
|
+
#handleDown(e: any) { e.detail.indexes.unshift(this.index); }
|
|
237
|
+
#handleSelect(e: any) { e.detail.indexes.unshift(this.index); }
|
|
238
|
+
#handleItemDropEnter(e: any) { e.detail.indexes.unshift(this.index); }
|
|
239
|
+
|
|
240
|
+
#handleContextMenu(e: MouseEvent) {
|
|
241
|
+
e.preventDefault();
|
|
242
|
+
this.dispatchEvent(new CustomEvent('menu', {
|
|
243
|
+
bubbles: true,
|
|
244
|
+
composed: true,
|
|
245
|
+
detail: {
|
|
246
|
+
indexes: [this.index],
|
|
247
|
+
x: e.clientX,
|
|
248
|
+
y: e.clientY
|
|
249
|
+
}
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
#enableRename() {
|
|
254
|
+
this.$labelButton.classList.add('hide');
|
|
255
|
+
this.$actions.classList.add('hide');
|
|
256
|
+
this.$input.classList.remove('hide');
|
|
257
|
+
this.$input.value = this.label;
|
|
258
|
+
this.$input.select();
|
|
259
|
+
this.#ignoreNextClick = true;
|
|
260
|
+
this.dispatchEvent(new CustomEvent('select', {
|
|
261
|
+
bubbles: true,
|
|
262
|
+
composed: true,
|
|
263
|
+
detail: {
|
|
264
|
+
type: 'rename',
|
|
265
|
+
indexes: [this.index]
|
|
266
|
+
}
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
#ignoreNextClick = false;
|
|
271
|
+
#handleDoubleClick(e: MouseEvent) {
|
|
272
|
+
if (e.ctrlKey || e.shiftKey) return;
|
|
273
|
+
this.#enableRename();
|
|
274
|
+
e.preventDefault();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
#handleBlur() {
|
|
278
|
+
this.$labelButton.classList.remove('hide');
|
|
279
|
+
this.$actions.classList.remove('hide');
|
|
280
|
+
this.$input.classList.add('hide');
|
|
281
|
+
this.$labelButton.click();
|
|
282
|
+
this.dispatchEvent(new CustomEvent('rename', {
|
|
283
|
+
bubbles: true,
|
|
284
|
+
composed: true,
|
|
285
|
+
detail: {
|
|
286
|
+
indexes: [this.index],
|
|
287
|
+
label: this.$input.value
|
|
288
|
+
}
|
|
289
|
+
}));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
#handleIconKeyDown(e: KeyboardEvent) {
|
|
293
|
+
switch (e.key) {
|
|
294
|
+
case 'ArrowUp':
|
|
295
|
+
this.dispatchEvent(new CustomEvent('up', {
|
|
296
|
+
bubbles: true,
|
|
297
|
+
composed: true,
|
|
298
|
+
detail: { indexes: [this.index] }
|
|
299
|
+
}));
|
|
300
|
+
e.preventDefault();
|
|
301
|
+
break;
|
|
302
|
+
case 'ArrowDown':
|
|
303
|
+
this.dispatchEvent(new CustomEvent('down', {
|
|
304
|
+
bubbles: true,
|
|
305
|
+
composed: true,
|
|
306
|
+
detail: { indexes: [this.index] }
|
|
307
|
+
}));
|
|
308
|
+
e.preventDefault();
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
#handleInputKeyDown(e: KeyboardEvent) {
|
|
314
|
+
switch (e.key) {
|
|
315
|
+
case 'Enter':
|
|
316
|
+
this.#handleBlur();
|
|
317
|
+
break;
|
|
318
|
+
case 'Escape':
|
|
319
|
+
e.stopPropagation();
|
|
320
|
+
this.$labelButton.classList.remove('hide');
|
|
321
|
+
this.$actions.classList.remove('hide');
|
|
322
|
+
this.$input.classList.add('hide');
|
|
323
|
+
this.$input.value = this.label;
|
|
324
|
+
this.$labelButton.click();
|
|
325
|
+
break;
|
|
326
|
+
case 'ArrowUp':
|
|
327
|
+
this.dispatchEvent(new CustomEvent('up', {
|
|
328
|
+
bubbles: true,
|
|
329
|
+
composed: true,
|
|
330
|
+
detail: { indexes: [this.index] }
|
|
331
|
+
}));
|
|
332
|
+
this.$labelButton.classList.remove('hide');
|
|
333
|
+
this.$actions.classList.remove('hide');
|
|
334
|
+
this.$input.classList.add('hide');
|
|
335
|
+
e.preventDefault();
|
|
336
|
+
break;
|
|
337
|
+
case 'ArrowDown':
|
|
338
|
+
this.dispatchEvent(new CustomEvent('down', {
|
|
339
|
+
bubbles: true,
|
|
340
|
+
composed: true,
|
|
341
|
+
detail: { indexes: [this.index] }
|
|
342
|
+
}));
|
|
343
|
+
this.$labelButton.classList.remove('hide');
|
|
344
|
+
this.$actions.classList.remove('hide');
|
|
345
|
+
this.$input.classList.add('hide');
|
|
346
|
+
e.preventDefault();
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
#canvas: HTMLCanvasElement | null = null;
|
|
352
|
+
#handleDragStart(event: DragEvent) {
|
|
353
|
+
let dragCount = 0;
|
|
354
|
+
this.dispatchEvent(new CustomEvent('itemdragstart', {
|
|
355
|
+
bubbles: true,
|
|
356
|
+
composed: true,
|
|
357
|
+
detail: {
|
|
358
|
+
ctrlKey: event.ctrlKey,
|
|
359
|
+
shiftKey: event.shiftKey,
|
|
360
|
+
indexes: [this.index],
|
|
361
|
+
callback: (count: number) => {
|
|
362
|
+
dragCount = count;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}));
|
|
366
|
+
this.$item.classList.toggle('dragging', true);
|
|
367
|
+
this.$items.classList.toggle('dragging', true);
|
|
368
|
+
// Generate drag image showing selected item count
|
|
369
|
+
const dpr = window.devicePixelRatio;
|
|
370
|
+
const canvas = document.createElement('canvas');
|
|
371
|
+
// Position off-screen so it doesn't flash before becoming the drag image
|
|
372
|
+
canvas.style.position = 'absolute';
|
|
373
|
+
canvas.style.top = '-200px';
|
|
374
|
+
canvas.style.left = '-200px';
|
|
375
|
+
document.body.append(canvas);
|
|
376
|
+
const offsetInline = 20;
|
|
377
|
+
const fontSize = 16;
|
|
378
|
+
const paddingBlock = 6;
|
|
379
|
+
const paddingInline = 6;
|
|
380
|
+
canvas.width = 100 * dpr;
|
|
381
|
+
canvas.height = 40 * dpr;
|
|
382
|
+
canvas.style.width = `${canvas.width / dpr}px`;
|
|
383
|
+
const ctx = canvas.getContext('2d');
|
|
384
|
+
if (ctx) {
|
|
385
|
+
const text = `${dragCount}`;
|
|
386
|
+
ctx.font = `bold ${fontSize * dpr}px Segoe UI`;
|
|
387
|
+
const textSize = ctx.measureText(text);
|
|
388
|
+
ctx.fillStyle = '#453C4F';
|
|
389
|
+
ctx.beginPath();
|
|
390
|
+
ctx.roundRect(
|
|
391
|
+
offsetInline * dpr,
|
|
392
|
+
0,
|
|
393
|
+
(textSize.width + paddingInline * 2) * dpr,
|
|
394
|
+
(fontSize + paddingBlock * 2) * dpr,
|
|
395
|
+
8 + dpr * 2
|
|
396
|
+
);
|
|
397
|
+
ctx.fill();
|
|
398
|
+
ctx.fillStyle = '#FFF';
|
|
399
|
+
ctx.beginPath();
|
|
400
|
+
ctx.roundRect(
|
|
401
|
+
(offsetInline + 2) * dpr,
|
|
402
|
+
2 * dpr,
|
|
403
|
+
(textSize.width + paddingInline * 2 - 4) * dpr,
|
|
404
|
+
(fontSize + paddingBlock * 2 - 4) * dpr,
|
|
405
|
+
8
|
|
406
|
+
);
|
|
407
|
+
ctx.fill();
|
|
408
|
+
ctx.fillStyle = '#453C4F';
|
|
409
|
+
ctx.fillText(
|
|
410
|
+
text,
|
|
411
|
+
(offsetInline + paddingInline + 4) * dpr,
|
|
412
|
+
(fontSize + paddingBlock - 2) * dpr
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
event.dataTransfer!.setDragImage(canvas, 0, 0);
|
|
416
|
+
this.#canvas = canvas;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
#handleDragEnd(_event: DragEvent) {
|
|
420
|
+
this.dispatchEvent(new CustomEvent('itemdragend', {
|
|
421
|
+
bubbles: true,
|
|
422
|
+
composed: true,
|
|
423
|
+
detail: { indexes: [this.index] }
|
|
424
|
+
}));
|
|
425
|
+
this.$item.classList.toggle('dragging', false);
|
|
426
|
+
this.$items.classList.toggle('dragging', false);
|
|
427
|
+
this.#canvas?.remove();
|
|
428
|
+
this.#canvas = null;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
#handleItemDragStart(e: any) { e.detail.indexes.unshift(this.index); }
|
|
432
|
+
#handleItemDragEnd(e: any) { e.detail.indexes.unshift(this.index); }
|
|
433
|
+
#handleItemExpand(e: any) { e.detail.indexes.unshift(this.index); }
|
|
434
|
+
|
|
435
|
+
#handleDragAboveEnter(e: DragEvent) {
|
|
436
|
+
this.dispatchEvent(new CustomEvent('itemdropenter', {
|
|
437
|
+
bubbles: true,
|
|
438
|
+
composed: true,
|
|
439
|
+
detail: {
|
|
440
|
+
indexes: [this.index],
|
|
441
|
+
callback: (isValid: boolean) => {
|
|
442
|
+
if (isValid) {
|
|
443
|
+
e.dataTransfer!.dropEffect = 'move';
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}));
|
|
448
|
+
(e.target as HTMLElement).classList.toggle('drop', true);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
#handleDragAboveLeave(e: DragEvent) {
|
|
452
|
+
(e.target as HTMLElement).classList.toggle('drop', false);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
#dragOnTimer: number | undefined;
|
|
456
|
+
#handleDragOnEnter(e: DragEvent) {
|
|
457
|
+
this.dispatchEvent(new CustomEvent('itemdropenter', {
|
|
458
|
+
bubbles: true,
|
|
459
|
+
composed: true,
|
|
460
|
+
detail: {
|
|
461
|
+
indexes: [this.index],
|
|
462
|
+
callback: (isValid: boolean) => {
|
|
463
|
+
if (isValid) {
|
|
464
|
+
e.dataTransfer!.dropEffect = 'move';
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}));
|
|
469
|
+
(e.target as HTMLElement).classList.toggle('drop', true);
|
|
470
|
+
this.#dragOnTimer = window.setTimeout(() => {
|
|
471
|
+
this.dispatchEvent(new CustomEvent('expand', {
|
|
472
|
+
bubbles: true,
|
|
473
|
+
composed: true,
|
|
474
|
+
detail: { indexes: [this.index] }
|
|
475
|
+
}));
|
|
476
|
+
}, 1500);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
#handleDragOnLeave(e: DragEvent) {
|
|
480
|
+
window.clearTimeout(this.#dragOnTimer);
|
|
481
|
+
(e.target as HTMLElement).classList.toggle('drop', false);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
#handleDragBelowEnter(e: DragEvent) {
|
|
485
|
+
this.dispatchEvent(new CustomEvent('itemdropenter', {
|
|
486
|
+
bubbles: true,
|
|
487
|
+
composed: true,
|
|
488
|
+
detail: {
|
|
489
|
+
indexes: [this.index],
|
|
490
|
+
callback: (isValid: boolean) => {
|
|
491
|
+
if (isValid) {
|
|
492
|
+
e.dataTransfer!.dropEffect = 'move';
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}));
|
|
497
|
+
(e.target as HTMLElement).classList.toggle('drop', true);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
#handleDragBelowLeave(e: DragEvent) {
|
|
501
|
+
(e.target as HTMLElement).classList.toggle('drop', false);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
#handleDragOver(e: DragEvent) {
|
|
505
|
+
e.preventDefault();
|
|
506
|
+
e.dataTransfer!.dropEffect = 'move';
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
#handleDragAbove(e: DragEvent) {
|
|
510
|
+
(e.target as HTMLElement).classList.toggle('drop', false);
|
|
511
|
+
this.dispatchEvent(new CustomEvent('move', {
|
|
512
|
+
bubbles: true,
|
|
513
|
+
composed: true,
|
|
514
|
+
detail: { indexes: [this.index], position: 'before' }
|
|
515
|
+
}));
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
#handleDropOn(e: DragEvent) {
|
|
519
|
+
(e.target as HTMLElement).classList.toggle('drop', false);
|
|
520
|
+
this.dispatchEvent(new CustomEvent('move', {
|
|
521
|
+
bubbles: true,
|
|
522
|
+
composed: true,
|
|
523
|
+
detail: { indexes: [this.index], position: 'on' }
|
|
524
|
+
}));
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
#handleDropBelow(e: DragEvent) {
|
|
528
|
+
(e.target as HTMLElement).classList.toggle('drop', false);
|
|
529
|
+
this.dispatchEvent(new CustomEvent('move', {
|
|
530
|
+
bubbles: true,
|
|
531
|
+
composed: true,
|
|
532
|
+
detail: { indexes: [this.index], position: 'after' }
|
|
533
|
+
}));
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
}
|