@gramlot/gramlot 0.3.36 → 0.3.37
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/dist/components/charts/__init__.py +1 -1
- package/dist/components/charts/assets/collection.js +9 -9
- package/dist/components/charts/assets/index.js +1 -1
- package/dist/components/charts/grammar.json +0 -30
- package/dist/components/drawing/__init__.py +1 -1
- package/dist/components/drawing/assets/collection.js +3 -3
- package/dist/components/drawing/assets/index.js +1 -1
- package/dist/components/grid/__init__.py +1 -1
- package/dist/components/grid/assets/collection.js +6 -6
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/grammar.json +0 -2
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/collection.js +8 -8
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/inputs/grammar.json +2 -1
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +9 -9
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +2 -2
- package/dist/components/selection_trial/__init__.py +1 -1
- package/dist/components/selection_trial/assets/collection.js +3 -3
- package/dist/components/selection_trial/assets/index.js +1 -1
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/collection.js +6 -6
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/tree/grammar.json +0 -1
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/collection.js +3 -3
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/components/uploads/grammar.json +0 -3
- package/dist/gramlot.js +1205 -627
- package/dist/gramlot.min.js +45 -45
- package/dist/standard-collections.js +1 -1
- package/package.json +2 -3
- package/src/binding/data-binder.js +11 -3
- package/src/binding/grid-struct.js +7 -4
- package/src/binding/runtime.js +203 -46
- package/src/builder/binding.json +23 -1
- package/src/builder/gramlot-builder.d.ts +1 -4
- package/src/builder/source.js +185 -29
- package/src/chat.js +26 -20
- package/src/components/attachment-manager.js +38 -34
- package/src/components/chart-data-view.js +4 -7
- package/src/components/chart-fields.js +18 -6
- package/src/components/chart-renderer.js +10 -3
- package/src/components/chart-timeline.js +7 -5
- package/src/components/charts.js +74 -67
- package/src/components/check-box-text-editor.js +3 -3
- package/src/components/check-box-text.js +7 -22
- package/src/components/check-box-tree.js +20 -16
- package/src/components/choice-editor.js +1 -1
- package/src/components/drawing.js +47 -34
- package/src/components/grid-cell-editor.js +72 -29
- package/src/components/grid-column-filters.js +47 -40
- package/src/components/grid-formulas.js +22 -17
- package/src/components/grid-header-interaction.js +9 -11
- package/src/components/grid-row-interaction.js +25 -24
- package/src/components/grid-row-layout.js +28 -29
- package/src/components/grid-search-box.js +3 -3
- package/src/components/grid-search.js +3 -8
- package/src/components/grid-selection.js +33 -29
- package/src/components/grid-structure.js +48 -10
- package/src/components/grid-tools.js +14 -14
- package/src/components/grid.js +83 -79
- package/src/components/image-crop-dialog.js +2 -2
- package/src/components/image-crop.js +16 -9
- package/src/components/image-uploader.js +21 -28
- package/src/components/inputs.js +19 -1
- package/src/components/registry.js +3 -5
- package/src/components/tray-pane.js +85 -61
- package/src/components/tree.js +332 -239
- package/src/components/upload-engine.js +10 -2
- package/src/components/uploader.js +31 -27
- package/src/editing-session.d.ts +4 -1
- package/src/editing-session.js +120 -83
- package/src/experiments/window-selection.js +4 -6
- package/src/filesystem.js +2 -2
- package/src/gramlot.js +1 -0
- package/src/handlers/device-handler.js +219 -213
- package/src/handlers/rpc-handler.d.ts +17 -0
- package/src/handlers/rpc-handler.js +22 -0
- package/src/ide-documents.js +29 -11
- package/src/ide-runtime.js +33 -31
- package/src/index-page-runtime.d.ts +2 -2
- package/src/index-page-runtime.js +67 -48
- package/src/message-port-connection.js +100 -0
- package/src/message-port-store.js +158 -0
- package/src/page-store-connection.js +6 -1
- package/src/renderer/gramlot-renderer.js +21 -2
- package/src/source-picker.d.ts +2 -2
- package/src/source-picker.js +15 -6
- package/src/stores/bag-collection-store.js +25 -7
- package/src/stores/bag-collection-view.js +23 -22
- package/src/view/controls.js +1 -1
- package/src/view/html.js +40 -20
- package/src/visual-editor-canvas.js +1 -1
- package/src/visual-editor.js +18 -19
- package/tools/gramlot-tools-inspector.js +400 -374
- package/tools/inspector-agent.js +223 -49
- package/dist/components/vizabi/__init__.py +0 -13
- package/dist/components/vizabi/assets/collection.js +0 -4
- package/dist/components/vizabi/assets/index.js +0 -3
- package/dist/components/vizabi/commands.json +0 -7
- package/dist/components/vizabi/grammar.json +0 -128
- package/src/components/vizabi-session.js +0 -66
- package/src/components/vizabi.js +0 -66
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export {default} from "./collection.js";
|
|
2
2
|
export * from "./collection.js";
|
|
3
|
-
export const buildId = "sha256:
|
|
3
|
+
export const buildId = "sha256:e28e96b1191cf00aa565caab72a137852dd5cc347b1327209fd2664425ac18ba";
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"chartArea": {
|
|
9
9
|
"_meta": {
|
|
10
10
|
"gramlot_component": {
|
|
11
|
-
"bagStore": true,
|
|
12
11
|
"command": false,
|
|
13
12
|
"dataScope": false,
|
|
14
13
|
"parameters": {
|
|
@@ -562,7 +561,6 @@
|
|
|
562
561
|
"chartBar": {
|
|
563
562
|
"_meta": {
|
|
564
563
|
"gramlot_component": {
|
|
565
|
-
"bagStore": true,
|
|
566
564
|
"command": false,
|
|
567
565
|
"dataScope": false,
|
|
568
566
|
"parameters": {
|
|
@@ -1116,7 +1114,6 @@
|
|
|
1116
1114
|
"chartBar3D": {
|
|
1117
1115
|
"_meta": {
|
|
1118
1116
|
"gramlot_component": {
|
|
1119
|
-
"bagStore": true,
|
|
1120
1117
|
"command": false,
|
|
1121
1118
|
"dataScope": false,
|
|
1122
1119
|
"parameters": {
|
|
@@ -1670,7 +1667,6 @@
|
|
|
1670
1667
|
"chartBoxplot": {
|
|
1671
1668
|
"_meta": {
|
|
1672
1669
|
"gramlot_component": {
|
|
1673
|
-
"bagStore": true,
|
|
1674
1670
|
"command": false,
|
|
1675
1671
|
"dataScope": false,
|
|
1676
1672
|
"parameters": {
|
|
@@ -2284,7 +2280,6 @@
|
|
|
2284
2280
|
"chartCandlestick": {
|
|
2285
2281
|
"_meta": {
|
|
2286
2282
|
"gramlot_component": {
|
|
2287
|
-
"bagStore": true,
|
|
2288
2283
|
"command": false,
|
|
2289
2284
|
"dataScope": false,
|
|
2290
2285
|
"parameters": {
|
|
@@ -2883,7 +2878,6 @@
|
|
|
2883
2878
|
"chartDonut": {
|
|
2884
2879
|
"_meta": {
|
|
2885
2880
|
"gramlot_component": {
|
|
2886
|
-
"bagStore": true,
|
|
2887
2881
|
"command": false,
|
|
2888
2882
|
"dataScope": false,
|
|
2889
2883
|
"parameters": {
|
|
@@ -3437,7 +3431,6 @@
|
|
|
3437
3431
|
"chartFields": {
|
|
3438
3432
|
"_meta": {
|
|
3439
3433
|
"gramlot_component": {
|
|
3440
|
-
"bagStore": true,
|
|
3441
3434
|
"command": false,
|
|
3442
3435
|
"dataScope": false,
|
|
3443
3436
|
"parameters": {
|
|
@@ -3627,7 +3620,6 @@
|
|
|
3627
3620
|
"chartFunnel": {
|
|
3628
3621
|
"_meta": {
|
|
3629
3622
|
"gramlot_component": {
|
|
3630
|
-
"bagStore": true,
|
|
3631
3623
|
"command": false,
|
|
3632
3624
|
"dataScope": false,
|
|
3633
3625
|
"parameters": {
|
|
@@ -4256,7 +4248,6 @@
|
|
|
4256
4248
|
"chartHeatmap": {
|
|
4257
4249
|
"_meta": {
|
|
4258
4250
|
"gramlot_component": {
|
|
4259
|
-
"bagStore": true,
|
|
4260
4251
|
"command": false,
|
|
4261
4252
|
"dataScope": false,
|
|
4262
4253
|
"parameters": {
|
|
@@ -4810,7 +4801,6 @@
|
|
|
4810
4801
|
"chartHorizontalBar": {
|
|
4811
4802
|
"_meta": {
|
|
4812
4803
|
"gramlot_component": {
|
|
4813
|
-
"bagStore": true,
|
|
4814
4804
|
"command": false,
|
|
4815
4805
|
"dataScope": false,
|
|
4816
4806
|
"parameters": {
|
|
@@ -5364,7 +5354,6 @@
|
|
|
5364
5354
|
"chartLine": {
|
|
5365
5355
|
"_meta": {
|
|
5366
5356
|
"gramlot_component": {
|
|
5367
|
-
"bagStore": true,
|
|
5368
5357
|
"command": false,
|
|
5369
5358
|
"dataScope": false,
|
|
5370
5359
|
"parameters": {
|
|
@@ -5918,7 +5907,6 @@
|
|
|
5918
5907
|
"chartLine3D": {
|
|
5919
5908
|
"_meta": {
|
|
5920
5909
|
"gramlot_component": {
|
|
5921
|
-
"bagStore": true,
|
|
5922
5910
|
"command": false,
|
|
5923
5911
|
"dataScope": false,
|
|
5924
5912
|
"parameters": {
|
|
@@ -6472,7 +6460,6 @@
|
|
|
6472
6460
|
"chartLines3D": {
|
|
6473
6461
|
"_meta": {
|
|
6474
6462
|
"gramlot_component": {
|
|
6475
|
-
"bagStore": true,
|
|
6476
6463
|
"command": false,
|
|
6477
6464
|
"dataScope": false,
|
|
6478
6465
|
"parameters": {
|
|
@@ -7026,7 +7013,6 @@
|
|
|
7026
7013
|
"chartMap": {
|
|
7027
7014
|
"_meta": {
|
|
7028
7015
|
"gramlot_component": {
|
|
7029
|
-
"bagStore": true,
|
|
7030
7016
|
"command": false,
|
|
7031
7017
|
"dataScope": false,
|
|
7032
7018
|
"parameters": {
|
|
@@ -7565,7 +7551,6 @@
|
|
|
7565
7551
|
"chartMap3D": {
|
|
7566
7552
|
"_meta": {
|
|
7567
7553
|
"gramlot_component": {
|
|
7568
|
-
"bagStore": true,
|
|
7569
7554
|
"command": false,
|
|
7570
7555
|
"dataScope": false,
|
|
7571
7556
|
"parameters": {
|
|
@@ -8119,7 +8104,6 @@
|
|
|
8119
8104
|
"chartMapBar3D": {
|
|
8120
8105
|
"_meta": {
|
|
8121
8106
|
"gramlot_component": {
|
|
8122
|
-
"bagStore": true,
|
|
8123
8107
|
"command": false,
|
|
8124
8108
|
"dataScope": false,
|
|
8125
8109
|
"parameters": {
|
|
@@ -8799,7 +8783,6 @@
|
|
|
8799
8783
|
"chartParallel": {
|
|
8800
8784
|
"_meta": {
|
|
8801
8785
|
"gramlot_component": {
|
|
8802
|
-
"bagStore": true,
|
|
8803
8786
|
"command": false,
|
|
8804
8787
|
"dataScope": false,
|
|
8805
8788
|
"parameters": {
|
|
@@ -9353,7 +9336,6 @@
|
|
|
9353
9336
|
"chartPie": {
|
|
9354
9337
|
"_meta": {
|
|
9355
9338
|
"gramlot_component": {
|
|
9356
|
-
"bagStore": true,
|
|
9357
9339
|
"command": false,
|
|
9358
9340
|
"dataScope": false,
|
|
9359
9341
|
"parameters": {
|
|
@@ -9907,7 +9889,6 @@
|
|
|
9907
9889
|
"chartPolygons3D": {
|
|
9908
9890
|
"_meta": {
|
|
9909
9891
|
"gramlot_component": {
|
|
9910
|
-
"bagStore": true,
|
|
9911
9892
|
"command": false,
|
|
9912
9893
|
"dataScope": false,
|
|
9913
9894
|
"parameters": {
|
|
@@ -10461,7 +10442,6 @@
|
|
|
10461
10442
|
"chartRadar": {
|
|
10462
10443
|
"_meta": {
|
|
10463
10444
|
"gramlot_component": {
|
|
10464
|
-
"bagStore": true,
|
|
10465
10445
|
"command": false,
|
|
10466
10446
|
"dataScope": false,
|
|
10467
10447
|
"parameters": {
|
|
@@ -11015,7 +10995,6 @@
|
|
|
11015
10995
|
"chartSankey": {
|
|
11016
10996
|
"_meta": {
|
|
11017
10997
|
"gramlot_component": {
|
|
11018
|
-
"bagStore": true,
|
|
11019
10998
|
"command": false,
|
|
11020
10999
|
"dataScope": false,
|
|
11021
11000
|
"parameters": {
|
|
@@ -11569,7 +11548,6 @@
|
|
|
11569
11548
|
"chartScatter": {
|
|
11570
11549
|
"_meta": {
|
|
11571
11550
|
"gramlot_component": {
|
|
11572
|
-
"bagStore": true,
|
|
11573
11551
|
"command": false,
|
|
11574
11552
|
"dataScope": false,
|
|
11575
11553
|
"parameters": {
|
|
@@ -12123,7 +12101,6 @@
|
|
|
12123
12101
|
"chartScatter3D": {
|
|
12124
12102
|
"_meta": {
|
|
12125
12103
|
"gramlot_component": {
|
|
12126
|
-
"bagStore": true,
|
|
12127
12104
|
"command": false,
|
|
12128
12105
|
"dataScope": false,
|
|
12129
12106
|
"parameters": {
|
|
@@ -12677,7 +12654,6 @@
|
|
|
12677
12654
|
"chartStackedArea": {
|
|
12678
12655
|
"_meta": {
|
|
12679
12656
|
"gramlot_component": {
|
|
12680
|
-
"bagStore": true,
|
|
12681
12657
|
"command": false,
|
|
12682
12658
|
"dataScope": false,
|
|
12683
12659
|
"parameters": {
|
|
@@ -13231,7 +13207,6 @@
|
|
|
13231
13207
|
"chartStackedBar": {
|
|
13232
13208
|
"_meta": {
|
|
13233
13209
|
"gramlot_component": {
|
|
13234
|
-
"bagStore": true,
|
|
13235
13210
|
"command": false,
|
|
13236
13211
|
"dataScope": false,
|
|
13237
13212
|
"parameters": {
|
|
@@ -13785,7 +13760,6 @@
|
|
|
13785
13760
|
"chartSunburst": {
|
|
13786
13761
|
"_meta": {
|
|
13787
13762
|
"gramlot_component": {
|
|
13788
|
-
"bagStore": true,
|
|
13789
13763
|
"command": false,
|
|
13790
13764
|
"dataScope": false,
|
|
13791
13765
|
"parameters": {
|
|
@@ -14339,7 +14313,6 @@
|
|
|
14339
14313
|
"chartSurface": {
|
|
14340
14314
|
"_meta": {
|
|
14341
14315
|
"gramlot_component": {
|
|
14342
|
-
"bagStore": true,
|
|
14343
14316
|
"command": false,
|
|
14344
14317
|
"dataScope": false,
|
|
14345
14318
|
"parameters": {
|
|
@@ -14893,7 +14866,6 @@
|
|
|
14893
14866
|
"chartTimeline": {
|
|
14894
14867
|
"_meta": {
|
|
14895
14868
|
"gramlot_component": {
|
|
14896
|
-
"bagStore": true,
|
|
14897
14869
|
"command": false,
|
|
14898
14870
|
"dataScope": false,
|
|
14899
14871
|
"parameters": {
|
|
@@ -15035,7 +15007,6 @@
|
|
|
15035
15007
|
"chartTreemap": {
|
|
15036
15008
|
"_meta": {
|
|
15037
15009
|
"gramlot_component": {
|
|
15038
|
-
"bagStore": true,
|
|
15039
15010
|
"command": false,
|
|
15040
15011
|
"dataScope": false,
|
|
15041
15012
|
"parameters": {
|
|
@@ -15589,7 +15560,6 @@
|
|
|
15589
15560
|
"chartView": {
|
|
15590
15561
|
"_meta": {
|
|
15591
15562
|
"gramlot_component": {
|
|
15592
|
-
"bagStore": true,
|
|
15593
15563
|
"command": false,
|
|
15594
15564
|
"dataScope": false,
|
|
15595
15565
|
"parameters": {
|
|
@@ -10,6 +10,6 @@ mygramlot = GramlotCollection(
|
|
|
10
10
|
module="assets/index.js",
|
|
11
11
|
css=(),
|
|
12
12
|
dependencies=(_dependency_0, _dependency_1,),
|
|
13
|
-
build_id="sha256:
|
|
13
|
+
build_id="sha256:cd7e1c52ccfcea4c70cc878ff3eda2d25c88c95fdc940e681733730e6a92aea1",
|
|
14
14
|
files=("assets/collection.js", "assets/index.js", "commands.json", "grammar.json",),
|
|
15
15
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
1
|
+
var k=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var E=(n,t)=>{for(var e in t)k(n,e,{get:t[e],enumerable:!0})},S=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of A(t))!I.call(n,s)&&s!==e&&k(n,s,{get:()=>t[s],enumerable:!(i=z(t,s))||i.enumerable});return n},m=(n,t,e)=>(S(n,t,"default"),e&&S(e,t,"default"));import{Bag as h,sourceTarget as j}from"@gramlot/gramlot";import L from"@gramlot/collections/inputs";import R from"@gramlot/collections/layout";var d={};E(d,{defineCollection:()=>g});m(d,Y);import*as Y from"@gramlot/gramlot/components";import{defineCollection as B}from"@gramlot/gramlot/components";function g(n){if(n.name!=="drawing")throw new Error("Unexpected bundled collection");let t=[],e={};n.css?.forEach((i,s)=>{i.href=t[s].href});for(let[i,s]of Object.entries(n.assets??{}))s.href=e[i].href;return B({...n,css:t,assets:e})}import{sharedModules as N}from"@gramlot/gramlot";var P=n=>N["./components/parameters.js"][n];var C=P("projectParameters");function y(n){return class extends n{constructor(){super();let t=this.attachShadow({mode:"open"}),e=this.ownerDocument.createElement("style");e.textContent=`:host{box-sizing:border-box;display:block;min-width:0;font:inherit;color:var(--gramlot-ink,CanvasText)}
|
|
2
2
|
*,*::before,*::after{box-sizing:border-box}.control-box{min-width:0}slot{display:contents}
|
|
3
|
-
::slotted(*){min-width:0;max-width:100%}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",this.control=this.controlBox,this.control.id="control",this.control.append(this.ownerDocument.createElement("slot")),t.append(e,this.controlBox)}projectAttributes(t){return
|
|
3
|
+
::slotted(*){min-width:0;max-width:100%}`,this.controlBox=this.ownerDocument.createElement("div"),this.controlBox.className="control-box",this.control=this.controlBox,this.control.id="control",this.control.append(this.ownerDocument.createElement("slot")),t.append(e,this.controlBox)}projectAttributes(t){return C(this,t)}}}y.parameters={};import{sharedModules as D}from"@gramlot/gramlot";var T=n=>D["./random-id.js"][n],M=T("randomId");import{sharedModules as V}from"@gramlot/gramlot";var _=n=>V["./renderer/attributes.js"][n],u=_("SVG_NS");var q=(0,d.defineComponent)({name:"drawingPane",tag:"gramlot-drawing-pane",base:y,sourceContext:!0,subTags:"*",parameters:{image:{dtype:"T",nullable:!0,default:null,binding:"read"},annotations:{dtype:"X",binding:"read"}},implementation:n=>class extends n{#t;#c;#i;#m;#S=null;#k=!1;#C=!1;#f;#g;#x=null;#n="select";#r=null;#e=null;#h=[1e3,1e3];#u=null;#y;constructor(){super();let t=this.ownerDocument,e=t.createElement("style");e.textContent=`:host{display:block;height:100%;min-height:0}.control-box{height:100%;display:flex;flex-direction:row;min-height:0;position:relative}
|
|
4
4
|
slot{display:contents} ::slotted(gramlot-menu){flex:0 0 56px;box-sizing:border-box;padding:6px;background:var(--gramlot-surface,Canvas);border-right:1px solid var(--gramlot-border-control,#a8b2bf);overflow:hidden}
|
|
5
5
|
.canvas{display:block;flex:1;width:0;height:100%;min-width:0;min-height:0;background:var(--gramlot-surface-subtle,#eee);touch-action:none;user-select:none}
|
|
6
6
|
.text-editor{position:absolute;z-index:2;min-width:120px;padding:2px 4px;border:1px solid #3977bc;border-radius:3px;background:white;color:#222;box-shadow:0 2px 8px #0003}
|
|
7
|
-
.text-editor[hidden]{display:none}.shape{cursor:pointer}.selected{stroke:#1683ff}.selected [data-text-hit]{stroke:#3977bc;stroke-width:1;stroke-dasharray:4 3}`,this.shadowRoot.append(e),this.control.replaceChildren(),this.#s=t.createElement("input"),this.#s.type="text",this.#s.className="text-editor",this.#s.hidden=!0,this.#s.setAttribute("aria-label","Annotation text"),this.#t=t.createElementNS(u,"svg"),this.#t.setAttribute("role","img"),this.#t.setAttribute("aria-label","Annotated image"),this.#t.setAttribute("class","canvas"),this.#t.setAttribute("viewBox","0 0 1000 1000"),this.#t.setAttribute("preserveAspectRatio","xMidYMid meet"),this.controlBox.append(t.createElement("slot"),this.#t,this.#s),this.#c=t.createElement("img")}setSourceContext(t){this.context=t}projectAttributes(t,e){let i=super.projectAttributes(t,e);return this.isConnected&&this.#C(),i}connectedCallback(){this.#g=new this.ownerDocument.defaultView.AbortController;let t={signal:this.#g.signal};this.#B(),this.isConnected&&(this.#e.subscribe(this.#k,{any:()=>this.#P()}),this.#t.addEventListener("pointerdown",e=>this.#N(e),t),this.#t.addEventListener("pointermove",e=>this.#M(e),t),this.#t.addEventListener("pointerup",e=>this.#T(e),t),this.#t.addEventListener("pointercancel",()=>{this.#i=null,this.#r()},t),this.#t.addEventListener("dblclick",e=>{let i=e.target.closest("[data-id]")?.dataset.id;i&&this.#o.getItem(i)?.getItem("type")==="text"&&(this.#i=null,this.#z(i),e.preventDefault())},t),this.#s.addEventListener("keydown",e=>{e.key==="Enter"?(e.preventDefault(),this.#p(!0)):e.key==="Escape"&&(e.preventDefault(),this.#p(!1))},t),this.#s.addEventListener("blur",()=>this.#p(!0),t),this.#C())}disconnectedCallback(){this.#p(!1),this.#g?.abort(),this.#g=null,this.#e?.unsubscribe(this.#k,{any:!0}),this.#o?.unsubscribe(this.#S,{any:!0}),this.#o=null,this.#c.onload=null,this.#c.onerror=null,this.#u=null,this.#i=null}#C(){let t=this.parameters.annotations;if(!(t instanceof h))throw new TypeError("drawingPane annotations requires a Data Bag");t!==this.#o&&(this.#o?.unsubscribe(this.#S,{any:!0}),this.#o=t,t.subscribe(this.#S,{any:()=>this.#r()}),this.#a=null);let e=this.parameters.image;e!==this.#u&&(this.#u=e,this.#i=null,e?(this.#h=null,this.#r(),this.#c.onload=()=>{this.#u===e&&(this.#h=[this.#c.naturalWidth,this.#c.naturalHeight],this.#r())},this.#c.onerror=()=>{this.#u===e&&(this.#h=null,this.context.reportError(new Error("Cannot load image"),"Drawing image"),this.#r())},this.#c.src=e):(this.#h=[1e3,1e3],this.#r())),this.#r()}#B(){if(this.#v)return;let t=this.context.sourceNode,e=t.rootBuilder,i=t.value?.getNode("bar");if(i){this.#e=t.drawingState,this.#n=t.drawingStatePath,i.drawingController=this,this.#v=!0,this.#l=this.#e.getItem("tool"),this.#m=this.#e.getItem("color"),this.#f=this.#e.getItem("size");return}this.#n=`_gramlot.drawing.${f()}`,this.#e=new h({tool:"select",color:"#dd2222",size:3}),t.setRelativeData(this.#n,this.#e),Object.defineProperty(t,"drawingState",{value:this.#e,configurable:!0}),Object.defineProperty(t,"drawingStatePath",{value:this.#n,configurable:!0}),this.#m=this.#e.getItem("color"),this.#f=this.#e.getItem("size");let s=new e.source.constructor(null,e),r=e.wrapSource(s).menu({node_label:"bar",presentation:"bar",orientation:"vertical",labelPosition:"tooltip",iconSize:20,aria_label:"Image annotations"});Object.defineProperty(_(r),"drawingController",{value:this,configurable:!0,writable:!0});let l={select:"M5 3l13 11-6 .5-3 5z",freehand:"M4 20l3.5-.7L19 7.8 16.2 5 4.7 16.5z M14.7 6.5l2.8 2.8",arrow:"M4 19L19 4 M12 4h7v7",circle:"M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0z",text:"M4 5h16 M12 5v14 M8 19h8",delete:"M4 7h16 M9 7V4h6v3 M7 7l1 13h8l1-13 M10 10v7 M14 10v7"},c=a=>"data:image/svg+xml,"+encodeURIComponent(`<svg xmlns="${u}" viewBox="0 0 24 24" fill="none" stroke="#7e93ad" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${l[a]}"/></svg>`);for(let[a,g]of[["select","Select"],["freehand","Draw"],["arrow","Arrow"],["circle","Circle"],["text","Text"]])r.menuline({caption:g,tooltip:g,iconSrc:c(a),checked:`^${this.#n}.tool:={} === '${a}'`,action:`this.parentBag.parentNode.drawingController.setTool('${a}')`});r.contentPane({height:"1px",margin:"6px 4px",background:"var(--gramlot-border-control,#a8b2bf)"});let p=a=>"data:image/svg+xml,"+encodeURIComponent(`<svg xmlns="${u}" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="${a}" stroke="#8793a3" stroke-width="1.5"/></svg>`),x=r.menuline({caption:"Color",tooltip:"Color",iconSrc:`^${this.#n}.color:='data:image/svg+xml,' + encodeURIComponent('<svg xmlns="${u}" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="' + {} + '" stroke="#8793a3" stroke-width="1.5"/></svg>')`}).menu({aria_label:"Annotation colors"});for(let[a,g]of[["#dd2222","Red"],["#e6a700","Yellow"],["#16834a","Green"],["#1677d2","Blue"],["#ffffff","White"],["#202733","Black"]])x.menuline({caption:g,iconSrc:p(a),checked:`^${this.#n}.color:={} === '${a}'`,action:`this.SET('${this.#n}.color', '${a}');`});x.contentPane({padding:"8px"}).colorpicker({value:`^${this.#n}.color`,lbl:"Custom color",aria_label:"Color",width:"140px"});let M=a=>"data:image/svg+xml,"+encodeURIComponent(`<svg xmlns="${u}" viewBox="0 0 24 24"><path d="M4 12h16" stroke="#7e93ad" stroke-width="${a}" stroke-linecap="round"/></svg>`),w=r.menuline({caption:"Pen size",tooltip:"Pen size",iconSrc:`^${this.#n}.size:='data:image/svg+xml,' + encodeURIComponent('<svg xmlns="${u}" viewBox="0 0 24 24"><path d="M4 12h16" stroke="#7e93ad" stroke-width="' + Math.min({}, 12) + '" stroke-linecap="round"/></svg>')`}).menu({aria_label:"Pen size"});for(let a of[1,3,5,7,12,20])w.menuline({caption:`${a} px`,iconSrc:M(Math.min(a,12)),checked:`^${this.#n}.size:={} === ${a}`,action:`this.SET('${this.#n}.size', ${a});`});w.contentPane({padding:"8px"}).numberTextBox({value:`^${this.#n}.size`,lbl:"Custom size",aria_label:"Pen size",dtype:"L",min:1,max:20,width:"140px"}),r.contentPane({flex:"1",min_height:"12px"}),r.menuline({caption:"Delete",tooltip:"Delete",iconSrc:c("delete"),action:"this.parentBag.parentNode.drawingController.deleteSelection()"});let v=e.binding.gramlot,S=v.src.prepareSource(s);v.src.renderer.validateCandidate(S),this.#v=!0,t.setValue(S)}setTool(t){this.#p(!0),this.#i=null,this.#e.setItem("tool",t)}deleteSelection(){this.#a&&(this.#o.popNode(this.#a),this.#a=null,this.#r())}#P(){let t=this.#e.getItem("tool");this.#l=t;let e=this.#e.getItem("color"),i=this.#e.getItem("size"),s=e!==this.#m||i!==this.#f;this.#m=e,this.#f=i,s&&!this.#w&&this.#D(),this.#r()}#I(t){let e=this.#t.getScreenCTM();if(!e)return null;let i=this.#t.createSVGPoint();i.x=t.clientX,i.y=t.clientY;let s=i.matrixTransform(e.inverse());return{x:Math.max(0,Math.min(this.#h[0],s.x)),y:Math.max(0,Math.min(this.#h[1],s.y))}}#N(t){if(t.button!==0||!this.#h)return;let e=this.#I(t);if(!e)return;let i=t.target.closest("[data-id]")?.getAttribute("data-id");if(this.#l==="select"){if(this.#a=i||null,i){let s=this.#o.getItem(i);if(!(s instanceof h))throw new TypeError("Annotation must be a Bag");let o=this.#y(s);this.#w=!0;try{this.#e.setItem("color",o.color),this.#e.setItem("size",o.width)}finally{this.#w=!1}this.#i={id:i,start:e,original:o}}}else if(this.#l==="text"){let s=i?this.#o.getItem(i):null;this.#z(s instanceof h&&s.getItem("type")==="text"?i:null,e)}else this.#a=null,this.#i={start:e,current:e,points:[e]};this.#i&&this.#t.setPointerCapture(t.pointerId),this.#r(),t.preventDefault()}#M(t){if(!this.#i||!this.#h)return;let e=this.#I(t);e&&(this.#i.current=e,this.#l==="freehand"&&this.#i.points.push(e),this.#r())}#T(t){if(!this.#i)return;this.#M(t);let e=this.#i;if(this.#i=null,e.id){let i={x:e.current.x-e.start.x,y:e.current.y-e.start.y},s=this.#A(e.original,i);this.#o.setItem(e.id,new h(s))}else{let{start:i,current:s,points:o}=e,r;this.#l==="arrow"?r={type:"arrow",x:i.x,y:i.y,x2:s.x,y2:s.y}:this.#l==="circle"?r={type:"circle",x:i.x,y:i.y,radius:Math.hypot(s.x-i.x,s.y-i.y)}:this.#l==="freehand"&&(r={type:"freehand",points:o}),r&&this.#$({...r,color:this.#e.getItem("color"),width:this.#b()})}this.#t.hasPointerCapture(t.pointerId)&&this.#t.releasePointerCapture(t.pointerId),this.#r()}#$(t){let e=`item_${f()}`;this.#o.setItem(e,new h(t)),this.#a=e}#b(){let t=this.#e.getItem("size");return Number.isFinite(t)?Math.max(1,Math.min(20,t)):3}#D(){if(!this.#a)return;let t=this.#o.getItem(this.#a);if(!(t instanceof h))return;let e=this.#y(t);e.color=this.#e.getItem("color"),e.width=this.#b(),this.#o.setItem(this.#a,new h(e))}#z(t,e){this.#p(!0);let i=t?this.#y(this.#o.getItem(t)):{type:"text",...e,text:"",color:this.#e.getItem("color"),width:this.#b()};this.#a=t,this.#x={id:t,row:i},this.#s.value=i.text,this.#s.hidden=!1;let s=this.#t.createSVGPoint();s.x=i.x,s.y=i.y;let o=this.#t.getScreenCTM();if(!o){this.#p(!1);return}let r=s.matrixTransform(o),l=this.controlBox.getBoundingClientRect(),c=Math.max(14,Math.max(14,12+i.width*2)*o.a);this.#s.style.left=`${r.x-l.left}px`,this.#s.style.top=`${r.y-l.top-c}px`,this.#s.style.fontSize=`${c}px`,this.#s.focus(),this.#s.select()}#p(t){if(!this.#x)return;let{id:e,row:i}=this.#x;this.#x=null;let s=this.#s.value.trim();this.#s.hidden=!0,t&&s&&(i.text=s,e?this.#o.setItem(e,new h(i)):this.#$(i)),t&&this.#e.setItem("tool","select"),this.#r()}#y(t){let e=Object.fromEntries(t.getNodes().map(i=>[i.label,i.getValue()]));return e.type==="freehand"&&(e.points=e.points.getNodes().map(i=>({x:i.getValue().getItem("x"),y:i.getValue().getItem("y")}))),e}#A(t,e){let i={...t};return t.type==="freehand"?i.points=t.points.map(s=>({x:s.x+e.x,y:s.y+e.y})):(i.x+=e.x,i.y+=e.y,t.type==="arrow"&&(i.x2+=e.x,i.y2+=e.y)),i}#d(t,e){let i=this.ownerDocument.createElementNS(u,t);for(let[s,o]of Object.entries(e))i.setAttribute(s,String(o));return i}#E(t,e){let i=this.#d("g",{"data-id":e,class:`shape${e===this.#a?" selected":""}`,fill:"none",stroke:t.color,"stroke-width":t.width,"stroke-linecap":"round","stroke-linejoin":"round"});if(t.type==="circle"&&i.append(this.#d("circle",{cx:t.x,cy:t.y,r:t.radius})),t.type==="arrow"){i.append(this.#d("line",{x1:t.x,y1:t.y,x2:t.x2,y2:t.y2}));let s=Math.atan2(t.y2-t.y,t.x2-t.x),o=Math.max(12,t.width*5),r=t.x2-o*Math.cos(s-.45),l=t.y2-o*Math.sin(s-.45),c=t.x2-o*Math.cos(s+.45),p=t.y2-o*Math.sin(s+.45);i.append(this.#d("polyline",{points:`${r},${l} ${t.x2},${t.y2} ${c},${p}`}))}if(t.type==="freehand"&&i.append(this.#d("polyline",{points:t.points.map(s=>`${s.x},${s.y}`).join(" ")})),t.type==="text"){let s=this.#d("rect",{"data-text-hit":"",fill:"transparent",stroke:"none","pointer-events":"all"}),o=this.#d("text",{x:t.x,y:t.y,fill:t.color,stroke:"none","font-size":Math.max(14,12+t.width*2)});o.textContent=t.text,i.append(s,o)}return i}#r(){if(!this.#t||!this.#o||(this.#t.replaceChildren(),!this.#h))return;let[t,e]=this.#h;this.#t.setAttribute("viewBox",`0 0 ${t} ${e}`),this.#u&&this.#t.append(this.#d("image",{href:this.#u,x:0,y:0,width:t,height:e,"pointer-events":"none"}));for(let s of this.#o.getNodes()){let o=s.getValue();if(!(o instanceof h))throw new TypeError("Annotation must be a Bag");let r=this.#y(o);this.#i?.id===s.label&&this.#i.current&&(r=this.#A(this.#i.original,{x:this.#i.current.x-this.#i.start.x,y:this.#i.current.y-this.#i.start.y}));let l=this.#E(r,s.label);if(this.#t.append(l),r.type==="text"){let c=l.querySelector("text").getBBox(),p=l.querySelector("[data-text-hit]");for(let x of["x","y","width","height"])p.setAttribute(x,c[x])}}let i=this.#i;if(i&&!i.id&&i.current){let s;this.#l==="arrow"&&(s={type:"arrow",x:i.start.x,y:i.start.y,x2:i.current.x,y2:i.current.y}),this.#l==="circle"&&(s={type:"circle",x:i.start.x,y:i.start.y,radius:Math.hypot(i.current.x-i.start.x,i.current.y-i.start.y)}),this.#l==="freehand"&&(s={type:"freehand",points:i.points}),s&&this.#t.append(this.#E({...s,color:this.#e.getItem("color"),width:this.#b()},""))}}}}),ct=b({name:"drawing",dependencies:[L,R],components:[q]});export{q as DrawingPane,ct as default};
|
|
7
|
+
.text-editor[hidden]{display:none}.shape{cursor:pointer}.selected{stroke:#1683ff}.selected [data-text-hit]{stroke:#3977bc;stroke-width:1;stroke-dasharray:4 3}`,this.shadowRoot.append(e),this.control.replaceChildren(),this.#i=t.createElement("input"),this.#i.type="text",this.#i.className="text-editor",this.#i.hidden=!0,this.#i.setAttribute("aria-label","Annotation text"),this.#t=t.createElementNS(u,"svg"),this.#t.setAttribute("role","img"),this.#t.setAttribute("aria-label","Annotated image"),this.#t.setAttribute("class","canvas"),this.#t.setAttribute("viewBox","0 0 1000 1000"),this.#t.setAttribute("preserveAspectRatio","xMidYMid meet"),this.controlBox.append(t.createElement("slot"),this.#t,this.#i),this.#c=t.createElement("img")}setSourceContext(t){this.context=t}get#o(){return this.context.sourceNode.workspaceDatapath}#s(t){return this.context.getStaticData(`${this.#o}.${t}`)}#b(t,e){this.context.sourceNode.data.setItem(`${this.#o}.${t}`,e)}#a(){let t=this.context.getStaticData(this.#x);if(!(t instanceof h))throw new TypeError("drawingPane annotations requires a Data Bag");return t}projectAttributes(t,e){let i=super.projectAttributes(t,e);return this.isConnected&&this.#M(),i}connectedCallback(){this.#y=new this.ownerDocument.defaultView.AbortController;let t={signal:this.#y.signal};this.#N(),this.isConnected&&(this.#S=this.context.sourceNode.rootBuilder.binding.router.register({path:this.#o,subtree:!0,recipient:{receive:()=>this.#P()}}),this.#t.addEventListener("pointerdown",e=>this.#D(e),t),this.#t.addEventListener("pointermove",e=>this.#z(e),t),this.#t.addEventListener("pointerup",e=>this.#T(e),t),this.#t.addEventListener("pointercancel",()=>{this.#e=null,this.#l()},t),this.#t.addEventListener("dblclick",e=>{let i=e.target.closest("[data-id]")?.dataset.id;i&&this.#a().getItem(i)?.getItem("type")==="text"&&(this.#e=null,this.#I(i),e.preventDefault())},t),this.#i.addEventListener("keydown",e=>{e.key==="Enter"?(e.preventDefault(),this.#p(!0)):e.key==="Escape"&&(e.preventDefault(),this.#p(!1))},t),this.#i.addEventListener("blur",()=>this.#p(!0),t),this.#M())}disconnectedCallback(){this.#p(!1),this.#y?.abort(),this.#y=null,this.#S?.close(),this.#S=null,this.#x=null,this.#c.onload=null,this.#c.onerror=null,this.#u=null,this.#e=null}#M(){let t=this.context.attrDatapath("annotations");t!==this.#x&&(this.#x=t,this.#r=null),this.#a();let e=this.parameters.image;e!==this.#u&&(this.#u=e,this.#e=null,e?(this.#h=null,this.#l(),this.#c.onload=()=>{this.#u===e&&(this.#h=[this.#c.naturalWidth,this.#c.naturalHeight],this.#l())},this.#c.onerror=()=>{this.#u===e&&(this.#h=null,this.context.reportError(new Error("Cannot load image"),"Drawing image"),this.#l())},this.#c.src=e):(this.#h=[1e3,1e3],this.#l())),this.#l()}#N(){if(this.#C)return;let t=this.context.sourceNode,e=t.rootBuilder,i=t.value?.getNode("bar");if(i){i._internal.drawingController=this,this.#C=!0,this.#n=this.#s("tool"),this.#f=this.#s("color"),this.#g=this.#s("size");return}this.#s("tool")&&this.#s("color")&&this.#s("size")||t.data.setItem(this.#o,new h({tool:"select",color:"#dd2222",size:3})),this.#n=this.#s("tool"),this.#f=this.#s("color"),this.#g=this.#s("size");let s=new e.source.constructor(null,e),r=e.wrapSource(s).menu({node_label:"bar",presentation:"bar",orientation:"vertical",labelPosition:"tooltip",iconSize:20,aria_label:"Image annotations"});j(r)._internal.drawingController=this;let l={select:"M5 3l13 11-6 .5-3 5z",freehand:"M4 20l3.5-.7L19 7.8 16.2 5 4.7 16.5z M14.7 6.5l2.8 2.8",arrow:"M4 19L19 4 M12 4h7v7",circle:"M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0z",text:"M4 5h16 M12 5v14 M8 19h8",delete:"M4 7h16 M9 7V4h6v3 M7 7l1 13h8l1-13 M10 10v7 M14 10v7"},c=a=>"data:image/svg+xml,"+encodeURIComponent(`<svg xmlns="${u}" viewBox="0 0 24 24" fill="none" stroke="#7e93ad" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${l[a]}"/></svg>`);for(let[a,f]of[["select","Select"],["freehand","Draw"],["arrow","Arrow"],["circle","Circle"],["text","Text"]])r.menuline({caption:f,tooltip:f,iconSrc:c(a),checked:`^${this.#o}.tool:={} === '${a}'`,action:`this.parentBag.parentNode._internal.drawingController.setTool('${a}')`});r.contentPane({height:"1px",margin:"6px 4px",background:"var(--gramlot-border-control,#a8b2bf)"});let p=a=>"data:image/svg+xml,"+encodeURIComponent(`<svg xmlns="${u}" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="${a}" stroke="#8793a3" stroke-width="1.5"/></svg>`),x=r.menuline({caption:"Color",tooltip:"Color",iconSrc:`^${this.#o}.color:='data:image/svg+xml,' + encodeURIComponent('<svg xmlns="${u}" viewBox="0 0 24 24"><circle cx="12" cy="12" r="8" fill="' + {} + '" stroke="#8793a3" stroke-width="1.5"/></svg>')`}).menu({aria_label:"Annotation colors"});for(let[a,f]of[["#dd2222","Red"],["#e6a700","Yellow"],["#16834a","Green"],["#1677d2","Blue"],["#ffffff","White"],["#202733","Black"]])x.menuline({caption:f,iconSrc:p(a),checked:`^${this.#o}.color:={} === '${a}'`,action:`this.SET('${this.#o}.color', '${a}');`});x.contentPane({padding:"8px"}).colorpicker({value:`^${this.#o}.color`,lbl:"Custom color",aria_label:"Color",width:"140px"});let $=a=>"data:image/svg+xml,"+encodeURIComponent(`<svg xmlns="${u}" viewBox="0 0 24 24"><path d="M4 12h16" stroke="#7e93ad" stroke-width="${a}" stroke-linecap="round"/></svg>`),b=r.menuline({caption:"Pen size",tooltip:"Pen size",iconSrc:`^${this.#o}.size:='data:image/svg+xml,' + encodeURIComponent('<svg xmlns="${u}" viewBox="0 0 24 24"><path d="M4 12h16" stroke="#7e93ad" stroke-width="' + Math.min({}, 12) + '" stroke-linecap="round"/></svg>')`}).menu({aria_label:"Pen size"});for(let a of[1,3,5,7,12,20])b.menuline({caption:`${a} px`,iconSrc:$(Math.min(a,12)),checked:`^${this.#o}.size:={} === ${a}`,action:`this.SET('${this.#o}.size', ${a});`});b.contentPane({padding:"8px"}).numberTextBox({value:`^${this.#o}.size`,lbl:"Custom size",aria_label:"Pen size",dtype:"L",min:1,max:20,width:"140px"}),r.contentPane({flex:"1",min_height:"12px"}),r.menuline({caption:"Delete",tooltip:"Delete",iconSrc:c("delete"),action:"this.parentBag.parentNode._internal.drawingController.deleteSelection()"});let w=e.binding.gramlot,v=w.src.prepareSource(s);w.src.renderer.validateCandidate(v),this.#C=!0,t.setValue(v)}setTool(t){this.#p(!0),this.#e=null,this.#b("tool",t)}deleteSelection(){this.#r&&(this.#a().popNode(this.#r),this.#r=null,this.#l())}#P(){let t=this.#s("tool");this.#n=t;let e=this.#s("color"),i=this.#s("size"),s=e!==this.#f||i!==this.#g;this.#f=e,this.#g=i,s&&!this.#k&&this.#V(),this.#l()}#$(t){let e=this.#t.getScreenCTM();if(!e)return null;let i=this.#t.createSVGPoint();i.x=t.clientX,i.y=t.clientY;let s=i.matrixTransform(e.inverse());return{x:Math.max(0,Math.min(this.#h[0],s.x)),y:Math.max(0,Math.min(this.#h[1],s.y))}}#D(t){if(t.button!==0||!this.#h)return;let e=this.#$(t);if(!e)return;let i=t.target.closest("[data-id]")?.getAttribute("data-id");if(this.#n==="select"){if(this.#r=i||null,i){let s=this.#a().getItem(i);if(!(s instanceof h))throw new TypeError("Annotation must be a Bag");let o=this.#v(s);this.#k=!0;try{this.#b("color",o.color),this.#b("size",o.width)}finally{this.#k=!1}this.#e={id:i,start:e,original:o}}}else if(this.#n==="text"){let s=i?this.#a().getItem(i):null;this.#I(s instanceof h&&s.getItem("type")==="text"?i:null,e)}else this.#r=null,this.#e={start:e,current:e,points:[e]};this.#e&&this.#t.setPointerCapture(t.pointerId),this.#l(),t.preventDefault()}#z(t){if(!this.#e||!this.#h)return;let e=this.#$(t);e&&(this.#e.current=e,this.#n==="freehand"&&this.#e.points.push(e),this.#l())}#T(t){if(!this.#e)return;this.#z(t);let e=this.#e;if(this.#e=null,e.id){let i={x:e.current.x-e.start.x,y:e.current.y-e.start.y},s=this.#E(e.original,i);this.#a().setItem(e.id,new h(s))}else{let{start:i,current:s,points:o}=e,r;this.#n==="arrow"?r={type:"arrow",x:i.x,y:i.y,x2:s.x,y2:s.y}:this.#n==="circle"?r={type:"circle",x:i.x,y:i.y,radius:Math.hypot(s.x-i.x,s.y-i.y)}:this.#n==="freehand"&&(r={type:"freehand",points:o}),r&&this.#A({...r,color:this.#s("color"),width:this.#w()})}this.#t.hasPointerCapture(t.pointerId)&&this.#t.releasePointerCapture(t.pointerId),this.#l()}#A(t){let e=`item_${M()}`;this.#a().setItem(e,new h(t)),this.#r=e}#w(){let t=this.#s("size");return Number.isFinite(t)?Math.max(1,Math.min(20,t)):3}#V(){if(!this.#r)return;let t=this.#a().getItem(this.#r);if(!(t instanceof h))return;let e=this.#v(t);e.color=this.#s("color"),e.width=this.#w(),this.#a().setItem(this.#r,new h(e))}#I(t,e){this.#p(!0);let i=t?this.#v(this.#a().getItem(t)):{type:"text",...e,text:"",color:this.#s("color"),width:this.#w()};this.#r=t,this.#m={id:t,row:i},this.#i.value=i.text,this.#i.hidden=!1;let s=this.#t.createSVGPoint();s.x=i.x,s.y=i.y;let o=this.#t.getScreenCTM();if(!o){this.#p(!1);return}let r=s.matrixTransform(o),l=this.controlBox.getBoundingClientRect(),c=Math.max(14,Math.max(14,12+i.width*2)*o.a);this.#i.style.left=`${r.x-l.left}px`,this.#i.style.top=`${r.y-l.top-c}px`,this.#i.style.fontSize=`${c}px`,this.#i.focus(),this.#i.select()}#p(t){if(!this.#m)return;let{id:e,row:i}=this.#m;this.#m=null;let s=this.#i.value.trim();this.#i.hidden=!0,t&&s&&(i.text=s,e?this.#a().setItem(e,new h(i)):this.#A(i)),t&&this.#b("tool","select"),this.#l()}#v(t){let e=Object.fromEntries(t.getNodes().map(i=>[i.label,i.getValue()]));return e.type==="freehand"&&(e.points=e.points.getNodes().map(i=>({x:i.getValue().getItem("x"),y:i.getValue().getItem("y")}))),e}#E(t,e){let i={...t};return t.type==="freehand"?i.points=t.points.map(s=>({x:s.x+e.x,y:s.y+e.y})):(i.x+=e.x,i.y+=e.y,t.type==="arrow"&&(i.x2+=e.x,i.y2+=e.y)),i}#d(t,e){let i=this.ownerDocument.createElementNS(u,t);for(let[s,o]of Object.entries(e))i.setAttribute(s,String(o));return i}#B(t,e){let i=this.#d("g",{"data-id":e,class:`shape${e===this.#r?" selected":""}`,fill:"none",stroke:t.color,"stroke-width":t.width,"stroke-linecap":"round","stroke-linejoin":"round"});if(t.type==="circle"&&i.append(this.#d("circle",{cx:t.x,cy:t.y,r:t.radius})),t.type==="arrow"){i.append(this.#d("line",{x1:t.x,y1:t.y,x2:t.x2,y2:t.y2}));let s=Math.atan2(t.y2-t.y,t.x2-t.x),o=Math.max(12,t.width*5),r=t.x2-o*Math.cos(s-.45),l=t.y2-o*Math.sin(s-.45),c=t.x2-o*Math.cos(s+.45),p=t.y2-o*Math.sin(s+.45);i.append(this.#d("polyline",{points:`${r},${l} ${t.x2},${t.y2} ${c},${p}`}))}if(t.type==="freehand"&&i.append(this.#d("polyline",{points:t.points.map(s=>`${s.x},${s.y}`).join(" ")})),t.type==="text"){let s=this.#d("rect",{"data-text-hit":"",fill:"transparent",stroke:"none","pointer-events":"all"}),o=this.#d("text",{x:t.x,y:t.y,fill:t.color,stroke:"none","font-size":Math.max(14,12+t.width*2)});o.textContent=t.text,i.append(s,o)}return i}#l(){if(!this.#t||!this.#x||(this.#t.replaceChildren(),!this.#h))return;let[t,e]=this.#h;this.#t.setAttribute("viewBox",`0 0 ${t} ${e}`),this.#u&&this.#t.append(this.#d("image",{href:this.#u,x:0,y:0,width:t,height:e,"pointer-events":"none"}));for(let s of this.#a().getNodes()){let o=s.getValue();if(!(o instanceof h))throw new TypeError("Annotation must be a Bag");let r=this.#v(o);this.#e?.id===s.label&&this.#e.current&&(r=this.#E(this.#e.original,{x:this.#e.current.x-this.#e.start.x,y:this.#e.current.y-this.#e.start.y}));let l=this.#B(r,s.label);if(this.#t.append(l),r.type==="text"){let c=l.querySelector("text").getBBox(),p=l.querySelector("[data-text-hit]");for(let x of["x","y","width","height"])p.setAttribute(x,c[x])}}let i=this.#e;if(i&&!i.id&&i.current){let s;this.#n==="arrow"&&(s={type:"arrow",x:i.start.x,y:i.start.y,x2:i.current.x,y2:i.current.y}),this.#n==="circle"&&(s={type:"circle",x:i.start.x,y:i.start.y,radius:Math.hypot(i.current.x-i.start.x,i.current.y-i.start.y)}),this.#n==="freehand"&&(s={type:"freehand",points:i.points}),s&&this.#t.append(this.#B({...s,color:this.#s("color"),width:this.#w()},""))}}}}),ct=g({name:"drawing",dependencies:[L,R],components:[q]});export{q as DrawingPane,ct as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export {default} from "./collection.js";
|
|
2
2
|
export * from "./collection.js";
|
|
3
|
-
export const buildId = "sha256:
|
|
3
|
+
export const buildId = "sha256:cd7e1c52ccfcea4c70cc878ff3eda2d25c88c95fdc940e681733730e6a92aea1";
|
|
@@ -9,6 +9,6 @@ mygramlot = GramlotCollection(
|
|
|
9
9
|
module="assets/index.js",
|
|
10
10
|
css=(),
|
|
11
11
|
dependencies=(_dependency_0,),
|
|
12
|
-
build_id="sha256:
|
|
12
|
+
build_id="sha256:92b20ec86b7a4dfe2e8430f4cafcbb06a15d95798ca180c082275302c4bb6663",
|
|
13
13
|
files=("assets/collection.js", "assets/files/0a1df3a083d0c010560aa342e87959c8c1070e6fd54545741f083f22d0c8b551-fflate.txt", "assets/files/8cf9b31947daf7adb4a7a00a037459e58241af050cd0a603bfcf1756e533f75e-write-excel-file.txt", "assets/index.js", "assets/modules/browser-Y2BRNI3P.js", "assets/modules/chunk-BLMUM44K.js", "commands.json", "grammar.json",),
|
|
14
14
|
)
|