@deck.gl-community/editable-layers 9.2.0-beta.2 → 9.2.0-beta.4
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/index.cjs +255 -553
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/layers/segments-layer.d.ts +1 -1
- package/dist/lib/layers/segments-layer.d.ts.map +1 -1
- package/dist/lib/layers/segments-layer.js +1 -1
- package/dist/lib/layers/segments-layer.js.map +1 -1
- package/dist/widgets/edit-mode-tray-widget.d.ts +71 -0
- package/dist/widgets/edit-mode-tray-widget.d.ts.map +1 -0
- package/dist/widgets/edit-mode-tray-widget.js +217 -0
- package/dist/widgets/edit-mode-tray-widget.js.map +1 -0
- package/package.json +3 -2
- package/src/index.ts +8 -0
- package/src/lib/layers/segments-layer.ts +1 -1
- package/src/widgets/edit-mode-tray-widget.tsx +342 -0
package/dist/index.cjs
CHANGED
|
@@ -52,6 +52,7 @@ __export(dist_exports, {
|
|
|
52
52
|
DrawSquareFromCenterMode: () => DrawSquareFromCenterMode,
|
|
53
53
|
DrawSquareMode: () => DrawSquareMode,
|
|
54
54
|
DuplicateMode: () => DuplicateMode,
|
|
55
|
+
EditModeTrayWidget: () => EditModeTrayWidget,
|
|
55
56
|
EditableGeoJsonLayer: () => EditableGeoJsonLayer,
|
|
56
57
|
EditableH3ClusterLayer: () => EditableH3ClusterLayer,
|
|
57
58
|
ElevatedEditHandleLayer: () => ElevatedEditHandleLayer,
|
|
@@ -660,525 +661,8 @@ var TextsLayer = class extends NebulaLayer {
|
|
|
660
661
|
}
|
|
661
662
|
};
|
|
662
663
|
|
|
663
|
-
// ../layers/src/path-marker-layer/path-marker-layer.ts
|
|
664
|
-
var import_core4 = require("@deck.gl/core");
|
|
665
|
-
var import_layers5 = require("@deck.gl/layers");
|
|
666
|
-
var import_mesh_layers = require("@deck.gl/mesh-layers");
|
|
667
|
-
|
|
668
|
-
// ../layers/src/path-outline-layer/path-outline-layer.ts
|
|
669
|
-
var import_layers4 = require("@deck.gl/layers");
|
|
670
|
-
var import_constants2 = require("@luma.gl/constants");
|
|
671
|
-
|
|
672
|
-
// ../layers/src/path-outline-layer/outline.ts
|
|
673
|
-
var INITIAL_STATE = {
|
|
674
|
-
outlineEnabled: false,
|
|
675
|
-
outlineRenderShadowmap: false,
|
|
676
|
-
outlineShadowmap: null
|
|
677
|
-
};
|
|
678
|
-
function getUniforms({ outlineEnabled, outlineRenderShadowmap, outlineShadowmap } = INITIAL_STATE) {
|
|
679
|
-
const uniforms = {};
|
|
680
|
-
if (outlineEnabled !== void 0) {
|
|
681
|
-
uniforms.outline_uEnabled = outlineEnabled;
|
|
682
|
-
}
|
|
683
|
-
if (outlineRenderShadowmap !== void 0) {
|
|
684
|
-
uniforms.outline_uRenderOutlines = outlineRenderShadowmap;
|
|
685
|
-
}
|
|
686
|
-
if (outlineShadowmap !== void 0) {
|
|
687
|
-
uniforms.outline_uShadowmap = outlineShadowmap;
|
|
688
|
-
}
|
|
689
|
-
return uniforms;
|
|
690
|
-
}
|
|
691
|
-
var vs = `#version 300 es
|
|
692
|
-
in float instanceZLevel;
|
|
693
|
-
out float outline_vzLevel;
|
|
694
|
-
out vec4 outline_vPosition;
|
|
695
|
-
|
|
696
|
-
// Set the z level for the outline shadowmap rendering
|
|
697
|
-
void outline_setZLevel(float zLevel) {
|
|
698
|
-
outline_vzLevel = zLevel;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
// Store an adjusted position for texture2DProj
|
|
702
|
-
void outline_setUV(vec4 position) {
|
|
703
|
-
// mat4(
|
|
704
|
-
// 0.5, 0.0, 0.0, 0.0,
|
|
705
|
-
// 0.0, 0.5, 0.0, 0.0,
|
|
706
|
-
// 0.0, 0.0, 0.5, 0.0,
|
|
707
|
-
// 0.5, 0.5, 0.5, 1.0
|
|
708
|
-
// ) * position;
|
|
709
|
-
outline_vPosition = vec4(position.xyz * 0.5 + position.w * 0.5, position.w);
|
|
710
|
-
}
|
|
711
|
-
`;
|
|
712
|
-
var fs = `uniform bool outline_uEnabled;
|
|
713
|
-
uniform bool outline_uRenderOutlines;
|
|
714
|
-
uniform sampler2D outline_uShadowmap;
|
|
715
|
-
|
|
716
|
-
in float outline_vzLevel;
|
|
717
|
-
// in vec2 outline_vUV;
|
|
718
|
-
in vec4 outline_vPosition;
|
|
719
|
-
|
|
720
|
-
out vec4 fragColor;
|
|
721
|
-
|
|
722
|
-
const float OUTLINE_Z_LEVEL_ERROR = 0.01;
|
|
723
|
-
|
|
724
|
-
// Return a darker color in shadowmap
|
|
725
|
-
vec4 outline_filterShadowColor(vec4 color) {
|
|
726
|
-
return vec4(outline_vzLevel / 255., outline_vzLevel / 255., outline_vzLevel / 255., 1.);
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
// Return a darker color if in shadowmap
|
|
730
|
-
vec4 outline_filterDarkenColor(vec4 color) {
|
|
731
|
-
if (outline_uEnabled) {
|
|
732
|
-
float maxZLevel;
|
|
733
|
-
if (outline_vPosition.q > 0.0) {
|
|
734
|
-
maxZLevel = texture2DProj(outline_uShadowmap, outline_vPosition).r * 255.;
|
|
735
|
-
} else {
|
|
736
|
-
discard;
|
|
737
|
-
}
|
|
738
|
-
if (maxZLevel < outline_vzLevel + OUTLINE_Z_LEVEL_ERROR) {
|
|
739
|
-
vec4(color.rgb * 0.5, color.a);
|
|
740
|
-
} else {
|
|
741
|
-
discard;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
return color;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
// if enabled and rendering outlines - Render depth to shadowmap
|
|
748
|
-
// if enabled and rendering colors - Return a darker color if in shadowmap
|
|
749
|
-
// if disabled, just return color
|
|
750
|
-
vec4 outline_filterColor(vec4 color) {
|
|
751
|
-
if (outline_uEnabled) {
|
|
752
|
-
return outline_uRenderOutlines ?
|
|
753
|
-
outline_filterShadowColor(color) :
|
|
754
|
-
outline_filterDarkenColor(color);
|
|
755
|
-
}
|
|
756
|
-
return color;
|
|
757
|
-
}
|
|
758
|
-
`;
|
|
759
|
-
var outline = {
|
|
760
|
-
name: "outline",
|
|
761
|
-
vs,
|
|
762
|
-
fs,
|
|
763
|
-
getUniforms
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
// ../layers/src/path-outline-layer/path-outline-layer.ts
|
|
767
|
-
var UNIT = {
|
|
768
|
-
common: 0,
|
|
769
|
-
meters: 1,
|
|
770
|
-
pixels: 2
|
|
771
|
-
};
|
|
772
|
-
function injectShaderCode({ source, code = "" }) {
|
|
773
|
-
const INJECT_CODE = /}[^{}]*$/;
|
|
774
|
-
return source.replace(INJECT_CODE, code.concat("\n}\n"));
|
|
775
|
-
}
|
|
776
|
-
var VS_CODE = ` outline_setUV(gl_Position);
|
|
777
|
-
outline_setZLevel(instanceZLevel);
|
|
778
|
-
`;
|
|
779
|
-
var FS_CODE = ` fragColor = outline_filterColor(fragColor);
|
|
780
|
-
`;
|
|
781
|
-
var defaultProps = {
|
|
782
|
-
getZLevel: () => 0
|
|
783
|
-
};
|
|
784
|
-
var PathOutlineLayer = class extends import_layers4.PathLayer {
|
|
785
|
-
state = void 0;
|
|
786
|
-
// Override getShaders to inject the outline module
|
|
787
|
-
getShaders() {
|
|
788
|
-
const shaders = super.getShaders();
|
|
789
|
-
return Object.assign({}, shaders, {
|
|
790
|
-
modules: shaders.modules.concat([outline]),
|
|
791
|
-
vs: injectShaderCode({ source: shaders.vs, code: VS_CODE }),
|
|
792
|
-
fs: injectShaderCode({ source: shaders.fs, code: FS_CODE })
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
// @ts-expect-error PathLayer is missing LayerContext arg
|
|
796
|
-
initializeState(context) {
|
|
797
|
-
super.initializeState();
|
|
798
|
-
this.setState({
|
|
799
|
-
outlineFramebuffer: context.device.createFramebuffer({}),
|
|
800
|
-
dummyTexture: context.device.createTexture({ width: 1, height: 1 })
|
|
801
|
-
});
|
|
802
|
-
this.state.attributeManager.addInstanced({
|
|
803
|
-
instanceZLevel: {
|
|
804
|
-
size: 1,
|
|
805
|
-
type: import_constants2.GL.UNSIGNED_BYTE,
|
|
806
|
-
accessor: "getZLevel"
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
// Override draw to add render module
|
|
811
|
-
draw({ moduleParameters = {}, parameters, uniforms, context }) {
|
|
812
|
-
const {
|
|
813
|
-
jointRounded,
|
|
814
|
-
capRounded,
|
|
815
|
-
billboard,
|
|
816
|
-
miterLimit,
|
|
817
|
-
widthUnits,
|
|
818
|
-
widthScale,
|
|
819
|
-
widthMinPixels,
|
|
820
|
-
widthMaxPixels
|
|
821
|
-
} = this.props;
|
|
822
|
-
uniforms = Object.assign({}, uniforms, {
|
|
823
|
-
jointType: Number(jointRounded),
|
|
824
|
-
capType: Number(capRounded),
|
|
825
|
-
billboard,
|
|
826
|
-
widthUnits: UNIT[widthUnits],
|
|
827
|
-
widthScale,
|
|
828
|
-
miterLimit,
|
|
829
|
-
widthMinPixels,
|
|
830
|
-
widthMaxPixels
|
|
831
|
-
});
|
|
832
|
-
const { outlineFramebuffer, dummyTexture } = this.state;
|
|
833
|
-
this.state.model.updateModuleSettings({
|
|
834
|
-
outlineEnabled: true,
|
|
835
|
-
outlineRenderShadowmap: true,
|
|
836
|
-
outlineShadowmap: dummyTexture
|
|
837
|
-
});
|
|
838
|
-
this.state.model.draw({
|
|
839
|
-
uniforms: Object.assign({}, uniforms, {
|
|
840
|
-
jointType: 0,
|
|
841
|
-
widthScale: this.props.widthScale * 1.3
|
|
842
|
-
}),
|
|
843
|
-
parameters: {
|
|
844
|
-
depthTest: false,
|
|
845
|
-
// Biggest value needs to go into buffer
|
|
846
|
-
blendEquation: import_constants2.GL.MAX
|
|
847
|
-
},
|
|
848
|
-
framebuffer: outlineFramebuffer
|
|
849
|
-
});
|
|
850
|
-
this.state.model.updateModuleSettings({
|
|
851
|
-
outlineEnabled: true,
|
|
852
|
-
outlineRenderShadowmap: false,
|
|
853
|
-
outlineShadowmap: outlineFramebuffer
|
|
854
|
-
});
|
|
855
|
-
this.state.model.draw({
|
|
856
|
-
uniforms: Object.assign({}, uniforms, {
|
|
857
|
-
jointType: Number(jointRounded),
|
|
858
|
-
capType: Number(capRounded),
|
|
859
|
-
widthScale: this.props.widthScale
|
|
860
|
-
}),
|
|
861
|
-
parameters: {
|
|
862
|
-
depthTest: false
|
|
863
|
-
}
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
};
|
|
867
|
-
__publicField(PathOutlineLayer, "layerName", "PathOutlineLayer");
|
|
868
|
-
__publicField(PathOutlineLayer, "defaultProps", defaultProps);
|
|
869
|
-
|
|
870
|
-
// ../layers/src/path-marker-layer/arrow-2d-geometry.ts
|
|
871
|
-
var import_engine = require("@luma.gl/engine");
|
|
872
|
-
var Arrow2DGeometry = class extends import_engine.Geometry {
|
|
873
|
-
constructor(opts = {}) {
|
|
874
|
-
super(
|
|
875
|
-
Object.assign({}, opts, {
|
|
876
|
-
attributes: getArrowAttributes(opts),
|
|
877
|
-
topology: "triangle-list"
|
|
878
|
-
})
|
|
879
|
-
);
|
|
880
|
-
}
|
|
881
|
-
};
|
|
882
|
-
function getArrowAttributes({ length = 1, headSize = 0.2, tailWidth = 0.05, tailStart = 0.05 }) {
|
|
883
|
-
const texCoords = [
|
|
884
|
-
// HEAD
|
|
885
|
-
0.5,
|
|
886
|
-
1,
|
|
887
|
-
0,
|
|
888
|
-
0.5 - headSize / 2,
|
|
889
|
-
1 - headSize,
|
|
890
|
-
0,
|
|
891
|
-
0.5 + headSize / 2,
|
|
892
|
-
1 - headSize,
|
|
893
|
-
0,
|
|
894
|
-
0.5 - tailWidth / 2,
|
|
895
|
-
tailStart,
|
|
896
|
-
0,
|
|
897
|
-
0.5 + tailWidth / 2,
|
|
898
|
-
1 - headSize,
|
|
899
|
-
0,
|
|
900
|
-
0.5 + tailWidth / 2,
|
|
901
|
-
tailStart,
|
|
902
|
-
0,
|
|
903
|
-
0.5 - tailWidth / 2,
|
|
904
|
-
tailStart,
|
|
905
|
-
0,
|
|
906
|
-
0.5 - tailWidth / 2,
|
|
907
|
-
1 - headSize,
|
|
908
|
-
0,
|
|
909
|
-
0.5 + tailWidth / 2,
|
|
910
|
-
1 - headSize,
|
|
911
|
-
0
|
|
912
|
-
];
|
|
913
|
-
const normals = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1];
|
|
914
|
-
const positions = new Array(texCoords.length);
|
|
915
|
-
for (let i = 0; i < texCoords.length / 3; i++) {
|
|
916
|
-
const i3 = i * 3;
|
|
917
|
-
positions[i3 + 0] = (texCoords[i3 + 0] - 0.5) * length;
|
|
918
|
-
positions[i3 + 1] = (texCoords[i3 + 1] - 0.5) * length;
|
|
919
|
-
positions[i3 + 2] = 0;
|
|
920
|
-
}
|
|
921
|
-
return {
|
|
922
|
-
positions: { size: 3, value: new Float32Array(positions) },
|
|
923
|
-
normals: { size: 3, value: new Float32Array(normals) },
|
|
924
|
-
texCoords: { size: 2, value: new Float32Array(texCoords) }
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
// ../layers/src/path-marker-layer/create-path-markers.ts
|
|
929
|
-
var import_core2 = require("@math.gl/core");
|
|
930
|
-
function getLineLength(vPoints) {
|
|
931
|
-
let lineLength = 0;
|
|
932
|
-
for (let i = 0; i < vPoints.length - 1; i++) {
|
|
933
|
-
lineLength += vPoints[i].distance(vPoints[i + 1]);
|
|
934
|
-
}
|
|
935
|
-
return lineLength;
|
|
936
|
-
}
|
|
937
|
-
var DEFAULT_COLOR = [0, 0, 0, 255];
|
|
938
|
-
var DEFAULT_DIRECTION = { forward: true, backward: false };
|
|
939
|
-
function createPathMarkers({
|
|
940
|
-
data,
|
|
941
|
-
getPath = (x, context) => x.path,
|
|
942
|
-
getDirection = (x) => x.direction,
|
|
943
|
-
getColor = (x) => DEFAULT_COLOR,
|
|
944
|
-
getMarkerPercentages = (x, info) => [0.5],
|
|
945
|
-
projectFlat
|
|
946
|
-
}) {
|
|
947
|
-
const markers = [];
|
|
948
|
-
for (const object of data) {
|
|
949
|
-
const path = getPath(object, null);
|
|
950
|
-
const direction = getDirection(object) || DEFAULT_DIRECTION;
|
|
951
|
-
const color = getColor(object);
|
|
952
|
-
const vPoints = path.map((p) => new import_core2.Vector2(p));
|
|
953
|
-
const vPointsReverse = vPoints.slice(0).reverse();
|
|
954
|
-
const lineLength = getLineLength(vPoints);
|
|
955
|
-
const percentages = getMarkerPercentages(object, { lineLength });
|
|
956
|
-
for (const percentage of percentages) {
|
|
957
|
-
if (direction.forward) {
|
|
958
|
-
const marker = createMarkerAlongPath({
|
|
959
|
-
path: vPoints,
|
|
960
|
-
percentage,
|
|
961
|
-
lineLength,
|
|
962
|
-
color,
|
|
963
|
-
object,
|
|
964
|
-
projectFlat
|
|
965
|
-
});
|
|
966
|
-
markers.push(marker);
|
|
967
|
-
}
|
|
968
|
-
if (direction.backward) {
|
|
969
|
-
const marker = createMarkerAlongPath({
|
|
970
|
-
path: vPointsReverse,
|
|
971
|
-
percentage,
|
|
972
|
-
lineLength,
|
|
973
|
-
color,
|
|
974
|
-
object,
|
|
975
|
-
projectFlat
|
|
976
|
-
});
|
|
977
|
-
markers.push(marker);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
return markers;
|
|
982
|
-
}
|
|
983
|
-
function createMarkerAlongPath({
|
|
984
|
-
path,
|
|
985
|
-
percentage,
|
|
986
|
-
lineLength,
|
|
987
|
-
color,
|
|
988
|
-
object,
|
|
989
|
-
projectFlat
|
|
990
|
-
}) {
|
|
991
|
-
const distanceAlong = lineLength * percentage;
|
|
992
|
-
let currentDistance = 0;
|
|
993
|
-
let previousDistance = 0;
|
|
994
|
-
let i = 0;
|
|
995
|
-
for (i = 0; i < path.length - 1; i++) {
|
|
996
|
-
currentDistance += path[i].distance(path[i + 1]);
|
|
997
|
-
if (currentDistance > distanceAlong) {
|
|
998
|
-
break;
|
|
999
|
-
}
|
|
1000
|
-
previousDistance = currentDistance;
|
|
1001
|
-
}
|
|
1002
|
-
if (i === path.length - 1) {
|
|
1003
|
-
i -= 1;
|
|
1004
|
-
}
|
|
1005
|
-
const vDirection = path[i + 1].clone().subtract(path[i]).normalize();
|
|
1006
|
-
const along = distanceAlong - previousDistance;
|
|
1007
|
-
const vCenter = vDirection.clone().multiply(new import_core2.Vector2(along, along)).add(path[i]);
|
|
1008
|
-
const vDirection2 = new import_core2.Vector2(projectFlat(path[i + 1])).subtract(projectFlat(path[i]));
|
|
1009
|
-
const angle = vDirection2.verticalAngle() * 180 / Math.PI;
|
|
1010
|
-
return { position: [vCenter.x, vCenter.y, 0], angle, color, object };
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
// ../layers/src/path-marker-layer/polyline.ts
|
|
1014
|
-
var import_core3 = require("@math.gl/core");
|
|
1015
|
-
function getClosestPointOnLine({ p, p1, p2, clampToLine = true }) {
|
|
1016
|
-
const lineVector = new import_core3.Vector3(p2).subtract(p1);
|
|
1017
|
-
const pointVector = new import_core3.Vector3(p).subtract(p1);
|
|
1018
|
-
let dotProduct = lineVector.dot(pointVector);
|
|
1019
|
-
if (clampToLine) {
|
|
1020
|
-
dotProduct = (0, import_core3.clamp)(dotProduct, 0, 1);
|
|
1021
|
-
}
|
|
1022
|
-
return lineVector.lerp(p1, p2, dotProduct);
|
|
1023
|
-
}
|
|
1024
|
-
function getClosestPointOnPolyline({ p, points }) {
|
|
1025
|
-
p = new import_core3.Vector3(p);
|
|
1026
|
-
let pClosest = null;
|
|
1027
|
-
let distanceSquared = Infinity;
|
|
1028
|
-
let index = -1;
|
|
1029
|
-
for (let i = 0; i < points.length - 1; ++i) {
|
|
1030
|
-
const p1 = points[i];
|
|
1031
|
-
const p2 = points[i + 1];
|
|
1032
|
-
const pClosestOnLine = getClosestPointOnLine({ p, p1, p2 });
|
|
1033
|
-
const distanceToLineSquared = p.distanceSquared(pClosestOnLine);
|
|
1034
|
-
if (distanceToLineSquared < distanceSquared) {
|
|
1035
|
-
distanceSquared = distanceToLineSquared;
|
|
1036
|
-
pClosest = pClosestOnLine;
|
|
1037
|
-
index = i;
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
return {
|
|
1041
|
-
point: pClosest,
|
|
1042
|
-
index,
|
|
1043
|
-
p1: points[index],
|
|
1044
|
-
p2: points[index + 1],
|
|
1045
|
-
distanceSquared,
|
|
1046
|
-
distance: Math.sqrt(distanceSquared)
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
// ../layers/src/path-marker-layer/path-marker-layer.ts
|
|
1051
|
-
var DISTANCE_FOR_MULTI_ARROWS = 0.1;
|
|
1052
|
-
var ARROW_HEAD_SIZE = 0.2;
|
|
1053
|
-
var ARROW_TAIL_WIDTH = 0.05;
|
|
1054
|
-
var DEFAULT_MARKER_LAYER = import_mesh_layers.SimpleMeshLayer;
|
|
1055
|
-
var DEFAULT_MARKER_LAYER_PROPS = {
|
|
1056
|
-
mesh: new Arrow2DGeometry({ headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH })
|
|
1057
|
-
};
|
|
1058
|
-
var defaultProps2 = Object.assign(
|
|
1059
|
-
{},
|
|
1060
|
-
PathOutlineLayer.defaultProps,
|
|
1061
|
-
{
|
|
1062
|
-
MarkerLayer: DEFAULT_MARKER_LAYER,
|
|
1063
|
-
markerLayerProps: DEFAULT_MARKER_LAYER_PROPS,
|
|
1064
|
-
sizeScale: 100,
|
|
1065
|
-
fp64: false,
|
|
1066
|
-
highlightIndex: -1,
|
|
1067
|
-
highlightPoint: null,
|
|
1068
|
-
getPath: (x) => x.path,
|
|
1069
|
-
getColor: (x) => x.color,
|
|
1070
|
-
getMarkerColor: (x) => [0, 0, 0, 255],
|
|
1071
|
-
getDirection: (x) => x.direction,
|
|
1072
|
-
getMarkerPercentages: (object, { lineLength }) => lineLength > DISTANCE_FOR_MULTI_ARROWS ? [0.25, 0.5, 0.75] : [0.5]
|
|
1073
|
-
}
|
|
1074
|
-
);
|
|
1075
|
-
var PathMarkerLayer = class extends import_core4.CompositeLayer {
|
|
1076
|
-
state = void 0;
|
|
1077
|
-
initializeState() {
|
|
1078
|
-
this.state = {
|
|
1079
|
-
markers: [],
|
|
1080
|
-
mesh: new Arrow2DGeometry({ headSize: ARROW_HEAD_SIZE, tailWidth: ARROW_TAIL_WIDTH }),
|
|
1081
|
-
closestPoint: null,
|
|
1082
|
-
closestPoints: []
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
projectFlat(xyz, viewport, coordinateSystem, coordinateOrigin) {
|
|
1086
|
-
if (coordinateSystem === import_core4.COORDINATE_SYSTEM.METER_OFFSETS) {
|
|
1087
|
-
const [dx, dy] = viewport.metersToLngLatDelta(xyz);
|
|
1088
|
-
const [x, y] = coordinateOrigin;
|
|
1089
|
-
return viewport.projectFlat([x + dx, dy + y]);
|
|
1090
|
-
} else if (coordinateSystem === import_core4.COORDINATE_SYSTEM.LNGLAT_OFFSETS) {
|
|
1091
|
-
const [dx, dy] = xyz;
|
|
1092
|
-
const [x, y] = coordinateOrigin;
|
|
1093
|
-
return viewport.projectFlat([x + dx, dy + y]);
|
|
1094
|
-
}
|
|
1095
|
-
return viewport.projectFlat(xyz);
|
|
1096
|
-
}
|
|
1097
|
-
updateState({ props, oldProps, changeFlags }) {
|
|
1098
|
-
if (changeFlags.dataChanged || changeFlags.updateTriggersChanged) {
|
|
1099
|
-
const {
|
|
1100
|
-
data,
|
|
1101
|
-
getPath,
|
|
1102
|
-
getDirection,
|
|
1103
|
-
getMarkerColor,
|
|
1104
|
-
getMarkerPercentages,
|
|
1105
|
-
coordinateSystem,
|
|
1106
|
-
coordinateOrigin
|
|
1107
|
-
} = this.props;
|
|
1108
|
-
const { viewport } = this.context;
|
|
1109
|
-
const projectFlat = (o) => this.projectFlat(o, viewport, coordinateSystem, coordinateOrigin);
|
|
1110
|
-
this.state.markers = createPathMarkers({
|
|
1111
|
-
data,
|
|
1112
|
-
getPath,
|
|
1113
|
-
getDirection,
|
|
1114
|
-
getColor: getMarkerColor,
|
|
1115
|
-
getMarkerPercentages,
|
|
1116
|
-
projectFlat
|
|
1117
|
-
});
|
|
1118
|
-
this._recalculateClosestPoint();
|
|
1119
|
-
}
|
|
1120
|
-
if (changeFlags.propsChanged) {
|
|
1121
|
-
if (props.point !== oldProps.point) {
|
|
1122
|
-
this._recalculateClosestPoint();
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
_recalculateClosestPoint() {
|
|
1127
|
-
const { highlightPoint, highlightIndex } = this.props;
|
|
1128
|
-
if (highlightPoint && highlightIndex >= 0) {
|
|
1129
|
-
const object = this.props.data[highlightIndex];
|
|
1130
|
-
const points = this.props.getPath(object, null);
|
|
1131
|
-
const { point: point14 } = getClosestPointOnPolyline({ points, p: highlightPoint });
|
|
1132
|
-
this.state.closestPoints = [{ position: point14 }];
|
|
1133
|
-
} else {
|
|
1134
|
-
this.state.closestPoints = [];
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
getPickingInfo({ info }) {
|
|
1138
|
-
return Object.assign(info, {
|
|
1139
|
-
// override object with picked feature
|
|
1140
|
-
object: info.object && info.object.path || info.object
|
|
1141
|
-
});
|
|
1142
|
-
}
|
|
1143
|
-
renderLayers() {
|
|
1144
|
-
return [
|
|
1145
|
-
new PathOutlineLayer(
|
|
1146
|
-
this.props,
|
|
1147
|
-
this.getSubLayerProps({
|
|
1148
|
-
id: "paths",
|
|
1149
|
-
// Note: data has to be passed explicitly like this to avoid being empty
|
|
1150
|
-
data: this.props.data
|
|
1151
|
-
})
|
|
1152
|
-
),
|
|
1153
|
-
new this.props.MarkerLayer(
|
|
1154
|
-
this.getSubLayerProps(
|
|
1155
|
-
Object.assign({}, this.props.markerLayerProps, {
|
|
1156
|
-
id: "markers",
|
|
1157
|
-
data: this.state.markers,
|
|
1158
|
-
getOrientation: (x) => [0, -x.angle, 0],
|
|
1159
|
-
getColor: (x) => x.color,
|
|
1160
|
-
sizeScale: this.props.sizeScale,
|
|
1161
|
-
fp64: this.props.fp64,
|
|
1162
|
-
pickable: false,
|
|
1163
|
-
parameters: {
|
|
1164
|
-
blend: false,
|
|
1165
|
-
depthTest: false
|
|
1166
|
-
}
|
|
1167
|
-
})
|
|
1168
|
-
)
|
|
1169
|
-
),
|
|
1170
|
-
this.state.closestPoints && new import_layers5.ScatterplotLayer({
|
|
1171
|
-
id: `${this.props.id}-highlight`,
|
|
1172
|
-
data: this.state.closestPoints,
|
|
1173
|
-
fp64: this.props.fp64
|
|
1174
|
-
})
|
|
1175
|
-
];
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
__publicField(PathMarkerLayer, "layerName", "PathMarkerLayer");
|
|
1179
|
-
__publicField(PathMarkerLayer, "defaultProps", defaultProps2);
|
|
1180
|
-
|
|
1181
664
|
// dist/lib/layers/segments-layer.js
|
|
665
|
+
var import_layers4 = require("@deck.gl-community/layers");
|
|
1182
666
|
var NEBULA_TO_DECK_DIRECTIONS = {
|
|
1183
667
|
[ArrowStyles.NONE]: { forward: false, backward: false },
|
|
1184
668
|
[ArrowStyles.FORWARD]: { forward: true, backward: false },
|
|
@@ -1234,7 +718,7 @@ var SegmentsLayer = class extends NebulaLayer {
|
|
|
1234
718
|
render({ nebula }) {
|
|
1235
719
|
const defaultColor = [0, 0, 0, 255];
|
|
1236
720
|
const { objects, updateTrigger } = this.deckCache;
|
|
1237
|
-
return new PathMarkerLayer({
|
|
721
|
+
return new import_layers4.PathMarkerLayer({
|
|
1238
722
|
id: `segments-${this.id}`,
|
|
1239
723
|
data: objects,
|
|
1240
724
|
opacity: 1,
|
|
@@ -1260,7 +744,7 @@ var SegmentsLayer = class extends NebulaLayer {
|
|
|
1260
744
|
highlightColor: toDeckColor(this.highlightColor),
|
|
1261
745
|
dashJustified: this.dashed,
|
|
1262
746
|
getDashArray: this.dashed ? (nf) => nf.style.dashArray : void 0,
|
|
1263
|
-
markerLayerProps: this.markerLayerProps || PathMarkerLayer.defaultProps.markerLayerProps,
|
|
747
|
+
markerLayerProps: this.markerLayerProps || import_layers4.PathMarkerLayer.defaultProps.markerLayerProps,
|
|
1264
748
|
nebulaLayer: this
|
|
1265
749
|
});
|
|
1266
750
|
}
|
|
@@ -1268,12 +752,12 @@ var SegmentsLayer = class extends NebulaLayer {
|
|
|
1268
752
|
|
|
1269
753
|
// dist/lib/nebula-core.js
|
|
1270
754
|
var import_eventemitter32 = require("eventemitter3");
|
|
1271
|
-
var
|
|
755
|
+
var import_core2 = require("@deck.gl/core");
|
|
1272
756
|
var LOGGER_PREFIX = "Nebula: ";
|
|
1273
757
|
var NebulaCore = class {
|
|
1274
758
|
init(props) {
|
|
1275
759
|
this.props = props;
|
|
1276
|
-
this.wmViewport = new
|
|
760
|
+
this.wmViewport = new import_core2.WebMercatorViewport(this.props.viewport);
|
|
1277
761
|
["click", "mousemove", "mouseup", "mousedown"].forEach((name) => document.addEventListener(name, this._onMouseEvent, true));
|
|
1278
762
|
}
|
|
1279
763
|
detach() {
|
|
@@ -1282,7 +766,7 @@ var NebulaCore = class {
|
|
|
1282
766
|
updateProps(newProps) {
|
|
1283
767
|
this.props = newProps;
|
|
1284
768
|
const { viewport } = this.props;
|
|
1285
|
-
this.wmViewport = new
|
|
769
|
+
this.wmViewport = new import_core2.WebMercatorViewport(viewport);
|
|
1286
770
|
}
|
|
1287
771
|
props = null;
|
|
1288
772
|
deckgl = null;
|
|
@@ -1483,7 +967,7 @@ var NebulaCore = class {
|
|
|
1483
967
|
};
|
|
1484
968
|
|
|
1485
969
|
// dist/editable-layers/editable-geojson-layer.js
|
|
1486
|
-
var
|
|
970
|
+
var import_layers6 = require("@deck.gl/layers");
|
|
1487
971
|
|
|
1488
972
|
// dist/edit-modes/geojson-edit-mode.js
|
|
1489
973
|
var import_union = __toESM(require("@turf/union"), 1);
|
|
@@ -4502,9 +3986,9 @@ var DeleteMode = class extends GeoJsonEditMode {
|
|
|
4502
3986
|
var PROJECTED_PIXEL_SIZE_MULTIPLIER2 = 2 / 3;
|
|
4503
3987
|
|
|
4504
3988
|
// dist/editable-layers/editable-layer.js
|
|
4505
|
-
var
|
|
3989
|
+
var import_core3 = require("@deck.gl/core");
|
|
4506
3990
|
var EVENT_TYPES = ["click", "pointermove", "panstart", "panmove", "panend", "keyup", "dblclick"];
|
|
4507
|
-
var EditableLayer = class extends
|
|
3991
|
+
var EditableLayer = class extends import_core3.CompositeLayer {
|
|
4508
3992
|
state = void 0;
|
|
4509
3993
|
// Overridable interaction event handlers
|
|
4510
3994
|
onLayerClick(event) {
|
|
@@ -4697,7 +4181,7 @@ var EditableLayer = class extends import_core6.CompositeLayer {
|
|
|
4697
4181
|
__publicField(EditableLayer, "layerName", "EditableLayer");
|
|
4698
4182
|
|
|
4699
4183
|
// dist/editable-layers/editable-path-layer.js
|
|
4700
|
-
var
|
|
4184
|
+
var import_layers5 = require("@deck.gl/layers");
|
|
4701
4185
|
var uniformBlock = `uniform pickingLineWidthUniforms {
|
|
4702
4186
|
float extraPixels;
|
|
4703
4187
|
} pickingLineWidth;
|
|
@@ -4710,11 +4194,11 @@ var pickingUniforms = {
|
|
|
4710
4194
|
extraPixels: "f32"
|
|
4711
4195
|
}
|
|
4712
4196
|
};
|
|
4713
|
-
var
|
|
4714
|
-
...
|
|
4197
|
+
var defaultProps = {
|
|
4198
|
+
...import_layers5.PathLayer.defaultProps,
|
|
4715
4199
|
pickingLineWidthExtraPixels: { type: "number", min: 0, value: Number.MAX_SAFE_INTEGER }
|
|
4716
4200
|
};
|
|
4717
|
-
var EditablePathLayer = class extends
|
|
4201
|
+
var EditablePathLayer = class extends import_layers5.PathLayer {
|
|
4718
4202
|
getShaders() {
|
|
4719
4203
|
const shaders = super.getShaders();
|
|
4720
4204
|
shaders.vs = insertBefore(shaders.vs, "vec3 width;", `
|
|
@@ -4735,7 +4219,7 @@ var EditablePathLayer = class extends import_layers6.PathLayer {
|
|
|
4735
4219
|
super.draw(props);
|
|
4736
4220
|
}
|
|
4737
4221
|
};
|
|
4738
|
-
EditablePathLayer.defaultProps =
|
|
4222
|
+
EditablePathLayer.defaultProps = defaultProps;
|
|
4739
4223
|
EditablePathLayer.layerName = "EditablePathLayer";
|
|
4740
4224
|
|
|
4741
4225
|
// dist/editable-layers/editable-geojson-layer.js
|
|
@@ -4793,7 +4277,7 @@ function getEditHandleRadius(handle) {
|
|
|
4793
4277
|
return DEFAULT_EDITING_INTERMEDIATE_POINT_RADIUS;
|
|
4794
4278
|
}
|
|
4795
4279
|
}
|
|
4796
|
-
var
|
|
4280
|
+
var defaultProps2 = {
|
|
4797
4281
|
mode: DEFAULT_EDIT_MODE,
|
|
4798
4282
|
// Edit and interaction events
|
|
4799
4283
|
onEdit: () => {
|
|
@@ -4925,7 +4409,7 @@ var EditableGeoJsonLayer = class extends EditableLayer {
|
|
|
4925
4409
|
getLineWidth: [this.props.selectedFeatureIndexes, this.props.mode]
|
|
4926
4410
|
}
|
|
4927
4411
|
});
|
|
4928
|
-
let layers = [new
|
|
4412
|
+
let layers = [new import_layers6.GeoJsonLayer(subLayerProps)];
|
|
4929
4413
|
layers = layers.concat(this.createGuidesLayers(), this.createTooltipsLayers());
|
|
4930
4414
|
return layers;
|
|
4931
4415
|
}
|
|
@@ -5039,7 +4523,7 @@ var EditableGeoJsonLayer = class extends EditableLayer {
|
|
|
5039
4523
|
};
|
|
5040
4524
|
if (this.props.editHandleType === "icon") {
|
|
5041
4525
|
subLayerProps["points-icon"] = {
|
|
5042
|
-
type:
|
|
4526
|
+
type: import_layers6.IconLayer,
|
|
5043
4527
|
iconAtlas: this.props.editHandleIconAtlas,
|
|
5044
4528
|
iconMapping: this.props.editHandleIconMapping,
|
|
5045
4529
|
sizeUnits: this.props.editHandleIconSizeUnits,
|
|
@@ -5052,7 +4536,7 @@ var EditableGeoJsonLayer = class extends EditableLayer {
|
|
|
5052
4536
|
};
|
|
5053
4537
|
} else {
|
|
5054
4538
|
subLayerProps["points-circle"] = {
|
|
5055
|
-
type:
|
|
4539
|
+
type: import_layers6.ScatterplotLayer,
|
|
5056
4540
|
radiusScale: this.props.editHandlePointRadiusScale,
|
|
5057
4541
|
stroked: this.props.editHandlePointOutline,
|
|
5058
4542
|
getLineWidth: this.props.editHandlePointStrokeWidth,
|
|
@@ -5065,7 +4549,7 @@ var EditableGeoJsonLayer = class extends EditableLayer {
|
|
|
5065
4549
|
billboard: this.props.billboard
|
|
5066
4550
|
};
|
|
5067
4551
|
}
|
|
5068
|
-
const layer = new
|
|
4552
|
+
const layer = new import_layers6.GeoJsonLayer(this.getSubLayerProps({
|
|
5069
4553
|
id: "guides",
|
|
5070
4554
|
data: guides,
|
|
5071
4555
|
fp64: this.props.fp64,
|
|
@@ -5088,7 +4572,7 @@ var EditableGeoJsonLayer = class extends EditableLayer {
|
|
|
5088
4572
|
createTooltipsLayers() {
|
|
5089
4573
|
const mode = this.getActiveMode();
|
|
5090
4574
|
const tooltips = mode.getTooltips(this.getModeProps(this.props));
|
|
5091
|
-
const layer = new
|
|
4575
|
+
const layer = new import_layers6.TextLayer({
|
|
5092
4576
|
getSize: DEFAULT_TOOLTIP_FONT_SIZE,
|
|
5093
4577
|
...this.getSubLayerProps({
|
|
5094
4578
|
id: "tooltips",
|
|
@@ -5136,7 +4620,7 @@ var EditableGeoJsonLayer = class extends EditableLayer {
|
|
|
5136
4620
|
}
|
|
5137
4621
|
};
|
|
5138
4622
|
__publicField(EditableGeoJsonLayer, "layerName", "EditableGeoJsonLayer");
|
|
5139
|
-
__publicField(EditableGeoJsonLayer, "defaultProps",
|
|
4623
|
+
__publicField(EditableGeoJsonLayer, "defaultProps", defaultProps2);
|
|
5140
4624
|
|
|
5141
4625
|
// dist/editable-layers/editable-h3-cluster-layer.js
|
|
5142
4626
|
var import_geo_layers = require("@deck.gl/geo-layers");
|
|
@@ -5146,7 +4630,7 @@ var EMPTY_FEATURE_COLLECTION = {
|
|
|
5146
4630
|
type: "FeatureCollection",
|
|
5147
4631
|
features: []
|
|
5148
4632
|
};
|
|
5149
|
-
var
|
|
4633
|
+
var defaultProps3 = {
|
|
5150
4634
|
mode: DEFAULT_EDIT_MODE2,
|
|
5151
4635
|
...EditableGeoJsonLayer.defaultProps,
|
|
5152
4636
|
// h3 layer
|
|
@@ -5285,11 +4769,11 @@ var EditableH3ClusterLayer = class extends EditableLayer {
|
|
|
5285
4769
|
}
|
|
5286
4770
|
};
|
|
5287
4771
|
__publicField(EditableH3ClusterLayer, "layerName", "EditableH3ClusterLayer");
|
|
5288
|
-
__publicField(EditableH3ClusterLayer, "defaultProps",
|
|
4772
|
+
__publicField(EditableH3ClusterLayer, "defaultProps", defaultProps3);
|
|
5289
4773
|
|
|
5290
4774
|
// dist/editable-layers/selection-layer.js
|
|
5291
|
-
var
|
|
5292
|
-
var
|
|
4775
|
+
var import_core4 = require("@deck.gl/core");
|
|
4776
|
+
var import_layers7 = require("@deck.gl/layers");
|
|
5293
4777
|
var import_helpers16 = require("@turf/helpers");
|
|
5294
4778
|
var import_buffer3 = __toESM(require("@turf/buffer"), 1);
|
|
5295
4779
|
var import_difference4 = __toESM(require("@turf/difference"), 1);
|
|
@@ -5305,7 +4789,7 @@ var MODE_MAP = {
|
|
|
5305
4789
|
var MODE_CONFIG_MAP = {
|
|
5306
4790
|
[SELECTION_TYPE2.RECTANGLE]: { dragToDraw: true }
|
|
5307
4791
|
};
|
|
5308
|
-
var
|
|
4792
|
+
var defaultProps4 = {
|
|
5309
4793
|
selectionType: SELECTION_TYPE2.RECTANGLE,
|
|
5310
4794
|
layerIds: [],
|
|
5311
4795
|
onSelect: () => {
|
|
@@ -5340,7 +4824,7 @@ var PASS_THROUGH_PROPS = [
|
|
|
5340
4824
|
"getTentativeFillColor",
|
|
5341
4825
|
"getTentativeLineWidth"
|
|
5342
4826
|
];
|
|
5343
|
-
var SelectionLayer = class extends
|
|
4827
|
+
var SelectionLayer = class extends import_core4.CompositeLayer {
|
|
5344
4828
|
state = void 0;
|
|
5345
4829
|
_selectRectangleObjects(coordinates) {
|
|
5346
4830
|
const { layerIds, onSelect } = this.props;
|
|
@@ -5424,7 +4908,7 @@ var SelectionLayer = class extends import_core7.CompositeLayer {
|
|
|
5424
4908
|
];
|
|
5425
4909
|
if (pendingPolygonSelection) {
|
|
5426
4910
|
const { bigPolygon } = pendingPolygonSelection;
|
|
5427
|
-
layers.push(new
|
|
4911
|
+
layers.push(new import_layers7.PolygonLayer(this.getSubLayerProps({
|
|
5428
4912
|
id: LAYER_ID_BLOCKER,
|
|
5429
4913
|
pickable: true,
|
|
5430
4914
|
stroked: false,
|
|
@@ -5442,19 +4926,19 @@ var SelectionLayer = class extends import_core7.CompositeLayer {
|
|
|
5442
4926
|
}
|
|
5443
4927
|
};
|
|
5444
4928
|
__publicField(SelectionLayer, "layerName", "SelectionLayer");
|
|
5445
|
-
__publicField(SelectionLayer, "defaultProps",
|
|
4929
|
+
__publicField(SelectionLayer, "defaultProps", defaultProps4);
|
|
5446
4930
|
|
|
5447
4931
|
// dist/editable-layers/elevated-edit-handle-layer.js
|
|
5448
|
-
var
|
|
5449
|
-
var
|
|
5450
|
-
var
|
|
5451
|
-
var ElevatedEditHandleLayer = class extends
|
|
4932
|
+
var import_core5 = require("@deck.gl/core");
|
|
4933
|
+
var import_layers8 = require("@deck.gl/layers");
|
|
4934
|
+
var defaultProps5 = {};
|
|
4935
|
+
var ElevatedEditHandleLayer = class extends import_core5.CompositeLayer {
|
|
5452
4936
|
renderLayers() {
|
|
5453
|
-
const handles = new
|
|
4937
|
+
const handles = new import_layers8.ScatterplotLayer(Object.assign({}, this.props, {
|
|
5454
4938
|
id: `${this.props.id}-ScatterplotLayer`,
|
|
5455
4939
|
data: this.props.data
|
|
5456
4940
|
}));
|
|
5457
|
-
const lines = new
|
|
4941
|
+
const lines = new import_layers8.LineLayer(Object.assign({}, this.props, {
|
|
5458
4942
|
id: `${this.props.id}-LineLayer`,
|
|
5459
4943
|
data: this.props.data,
|
|
5460
4944
|
pickable: false,
|
|
@@ -5467,7 +4951,225 @@ var ElevatedEditHandleLayer = class extends import_core8.CompositeLayer {
|
|
|
5467
4951
|
}
|
|
5468
4952
|
};
|
|
5469
4953
|
__publicField(ElevatedEditHandleLayer, "layerName", "ElevatedEditHandleLayer");
|
|
5470
|
-
__publicField(ElevatedEditHandleLayer, "defaultProps",
|
|
4954
|
+
__publicField(ElevatedEditHandleLayer, "defaultProps", defaultProps5);
|
|
4955
|
+
|
|
4956
|
+
// dist/widgets/edit-mode-tray-widget.js
|
|
4957
|
+
var import_jsx_runtime = require("preact/jsx-runtime");
|
|
4958
|
+
var import_preact = require("preact");
|
|
4959
|
+
var import_core6 = require("@deck.gl/core");
|
|
4960
|
+
var ROOT_STYLE = {
|
|
4961
|
+
position: "absolute",
|
|
4962
|
+
display: "flex",
|
|
4963
|
+
pointerEvents: "auto",
|
|
4964
|
+
userSelect: "none",
|
|
4965
|
+
zIndex: "99"
|
|
4966
|
+
};
|
|
4967
|
+
var TRAY_BASE_STYLE = {
|
|
4968
|
+
display: "flex",
|
|
4969
|
+
gap: "6px",
|
|
4970
|
+
background: "rgba(36, 40, 41, 0.88)",
|
|
4971
|
+
borderRadius: "999px",
|
|
4972
|
+
padding: "6px",
|
|
4973
|
+
alignItems: "center",
|
|
4974
|
+
justifyContent: "center",
|
|
4975
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.25)"
|
|
4976
|
+
};
|
|
4977
|
+
var BUTTON_BASE_STYLE = {
|
|
4978
|
+
appearance: "none",
|
|
4979
|
+
background: "transparent",
|
|
4980
|
+
border: "none",
|
|
4981
|
+
color: "#f0f0f0",
|
|
4982
|
+
width: "34px",
|
|
4983
|
+
height: "34px",
|
|
4984
|
+
display: "flex",
|
|
4985
|
+
flexDirection: "column",
|
|
4986
|
+
alignItems: "center",
|
|
4987
|
+
justifyContent: "center",
|
|
4988
|
+
borderRadius: "50%",
|
|
4989
|
+
cursor: "pointer",
|
|
4990
|
+
padding: "0",
|
|
4991
|
+
transition: "background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease"
|
|
4992
|
+
};
|
|
4993
|
+
var BUTTON_ACTIVE_STYLE = {
|
|
4994
|
+
background: "#0071e3",
|
|
4995
|
+
color: "#ffffff",
|
|
4996
|
+
boxShadow: "0 0 0 2px rgba(255, 255, 255, 0.35)"
|
|
4997
|
+
};
|
|
4998
|
+
var BUTTON_LABEL_STYLE = {
|
|
4999
|
+
fontSize: "10px",
|
|
5000
|
+
marginTop: "2px",
|
|
5001
|
+
lineHeight: "12px"
|
|
5002
|
+
};
|
|
5003
|
+
var _EditModeTrayWidget = class extends import_core6.Widget {
|
|
5004
|
+
placement = "top-left";
|
|
5005
|
+
className = "deck-widget-edit-mode-tray";
|
|
5006
|
+
layout = "vertical";
|
|
5007
|
+
selectedModeId = null;
|
|
5008
|
+
deck = null;
|
|
5009
|
+
appliedCustomClassName = null;
|
|
5010
|
+
constructor(props = {}) {
|
|
5011
|
+
super({ ..._EditModeTrayWidget.defaultProps, ...props });
|
|
5012
|
+
this.placement = props.placement ?? _EditModeTrayWidget.defaultProps.placement;
|
|
5013
|
+
this.layout = props.layout ?? _EditModeTrayWidget.defaultProps.layout;
|
|
5014
|
+
this.selectedModeId = this.resolveSelectedModeId(props.modes ?? [], props);
|
|
5015
|
+
}
|
|
5016
|
+
setProps(props) {
|
|
5017
|
+
if (props.placement !== void 0) {
|
|
5018
|
+
this.placement = props.placement;
|
|
5019
|
+
}
|
|
5020
|
+
if (props.layout !== void 0) {
|
|
5021
|
+
this.layout = props.layout;
|
|
5022
|
+
}
|
|
5023
|
+
const modes = props.modes ?? this.props.modes ?? [];
|
|
5024
|
+
this.selectedModeId = this.resolveSelectedModeId(modes, props);
|
|
5025
|
+
super.setProps(props);
|
|
5026
|
+
this.renderTray();
|
|
5027
|
+
}
|
|
5028
|
+
onAdd({ deck }) {
|
|
5029
|
+
this.deck = deck;
|
|
5030
|
+
}
|
|
5031
|
+
onRemove() {
|
|
5032
|
+
this.deck = null;
|
|
5033
|
+
const root = this.rootElement;
|
|
5034
|
+
if (root) {
|
|
5035
|
+
(0, import_preact.render)(null, root);
|
|
5036
|
+
}
|
|
5037
|
+
this.rootElement = null;
|
|
5038
|
+
}
|
|
5039
|
+
onRenderHTML(rootElement) {
|
|
5040
|
+
const style = { ...ROOT_STYLE, ...this.props.style };
|
|
5041
|
+
Object.assign(rootElement.style, style);
|
|
5042
|
+
if (this.appliedCustomClassName && this.appliedCustomClassName !== this.props.className) {
|
|
5043
|
+
rootElement.classList.remove(this.appliedCustomClassName);
|
|
5044
|
+
this.appliedCustomClassName = null;
|
|
5045
|
+
}
|
|
5046
|
+
if (this.props.className) {
|
|
5047
|
+
rootElement.classList.add(this.props.className);
|
|
5048
|
+
this.appliedCustomClassName = this.props.className;
|
|
5049
|
+
}
|
|
5050
|
+
rootElement.classList.add(this.className);
|
|
5051
|
+
this.renderTray();
|
|
5052
|
+
}
|
|
5053
|
+
renderTray() {
|
|
5054
|
+
const root = this.rootElement;
|
|
5055
|
+
if (!root) {
|
|
5056
|
+
return;
|
|
5057
|
+
}
|
|
5058
|
+
const modes = this.props.modes ?? [];
|
|
5059
|
+
const selectedId = this.selectedModeId;
|
|
5060
|
+
const direction = this.layout === "horizontal" ? "row" : "column";
|
|
5061
|
+
const trayStyle = {
|
|
5062
|
+
...TRAY_BASE_STYLE,
|
|
5063
|
+
flexDirection: direction
|
|
5064
|
+
};
|
|
5065
|
+
const stopEvent = (event) => {
|
|
5066
|
+
event.stopPropagation();
|
|
5067
|
+
if (typeof event.stopImmediatePropagation === "function") {
|
|
5068
|
+
event.stopImmediatePropagation();
|
|
5069
|
+
}
|
|
5070
|
+
};
|
|
5071
|
+
const ui = (0, import_jsx_runtime.jsx)("div", { style: trayStyle, onPointerDown: stopEvent, onPointerMove: stopEvent, onPointerUp: stopEvent, onMouseDown: stopEvent, onMouseMove: stopEvent, onMouseUp: stopEvent, onTouchStart: stopEvent, onTouchMove: stopEvent, onTouchEnd: stopEvent, children: modes.map((option, index) => {
|
|
5072
|
+
const id = this.getModeId(option, index);
|
|
5073
|
+
const active = id === selectedId;
|
|
5074
|
+
const label = option.label ?? "";
|
|
5075
|
+
const title = option.title ?? label;
|
|
5076
|
+
const buttonStyle = {
|
|
5077
|
+
...BUTTON_BASE_STYLE,
|
|
5078
|
+
...active ? BUTTON_ACTIVE_STYLE : {}
|
|
5079
|
+
};
|
|
5080
|
+
return (0, import_jsx_runtime.jsxs)("button", { type: "button", title: title || void 0, "aria-pressed": active, style: buttonStyle, onClick: (event) => {
|
|
5081
|
+
stopEvent(event);
|
|
5082
|
+
this.handleSelect(option, id);
|
|
5083
|
+
}, children: [option.icon, label ? (0, import_jsx_runtime.jsx)("span", { style: BUTTON_LABEL_STYLE, children: label }) : null] }, id);
|
|
5084
|
+
}) });
|
|
5085
|
+
(0, import_preact.render)(ui, root);
|
|
5086
|
+
}
|
|
5087
|
+
handleSelect(option, id) {
|
|
5088
|
+
var _a, _b;
|
|
5089
|
+
if (this.selectedModeId !== id) {
|
|
5090
|
+
this.selectedModeId = id;
|
|
5091
|
+
this.renderTray();
|
|
5092
|
+
}
|
|
5093
|
+
(_b = (_a = this.props).onSelectMode) == null ? void 0 : _b.call(_a, {
|
|
5094
|
+
id,
|
|
5095
|
+
mode: option.mode,
|
|
5096
|
+
option
|
|
5097
|
+
});
|
|
5098
|
+
}
|
|
5099
|
+
resolveSelectedModeId(modes, props) {
|
|
5100
|
+
var _a;
|
|
5101
|
+
if (props.selectedModeId !== void 0) {
|
|
5102
|
+
return props.selectedModeId;
|
|
5103
|
+
}
|
|
5104
|
+
const activeMode = props.activeMode ?? ((_a = this.props) == null ? void 0 : _a.activeMode) ?? null;
|
|
5105
|
+
if (activeMode) {
|
|
5106
|
+
const match = this.findOptionByMode(modes, activeMode);
|
|
5107
|
+
if (match) {
|
|
5108
|
+
return this.getModeId(match.option, match.index);
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5111
|
+
if (this.selectedModeId) {
|
|
5112
|
+
const existing = this.findOptionById(modes, this.selectedModeId);
|
|
5113
|
+
if (existing) {
|
|
5114
|
+
return this.selectedModeId;
|
|
5115
|
+
}
|
|
5116
|
+
}
|
|
5117
|
+
const first = modes[0];
|
|
5118
|
+
return first ? this.getModeId(first, 0) : null;
|
|
5119
|
+
}
|
|
5120
|
+
findOptionByMode(modes, activeMode) {
|
|
5121
|
+
for (let index = 0; index < modes.length; index++) {
|
|
5122
|
+
const option = modes[index];
|
|
5123
|
+
if (option.mode === activeMode) {
|
|
5124
|
+
return { option, index };
|
|
5125
|
+
}
|
|
5126
|
+
if (this.isSameMode(option.mode, activeMode)) {
|
|
5127
|
+
return { option, index };
|
|
5128
|
+
}
|
|
5129
|
+
}
|
|
5130
|
+
return null;
|
|
5131
|
+
}
|
|
5132
|
+
findOptionById(modes, id) {
|
|
5133
|
+
for (let index = 0; index < modes.length; index++) {
|
|
5134
|
+
if (this.getModeId(modes[index], index) === id) {
|
|
5135
|
+
return { option: modes[index], index };
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5138
|
+
return null;
|
|
5139
|
+
}
|
|
5140
|
+
getModeId(option, index) {
|
|
5141
|
+
if (option.id) {
|
|
5142
|
+
return option.id;
|
|
5143
|
+
}
|
|
5144
|
+
const mode = option.mode;
|
|
5145
|
+
if (mode) {
|
|
5146
|
+
if (typeof mode === "function" && mode.name) {
|
|
5147
|
+
return mode.name;
|
|
5148
|
+
}
|
|
5149
|
+
if (mode && mode.constructor && mode.constructor.name) {
|
|
5150
|
+
return mode.constructor.name;
|
|
5151
|
+
}
|
|
5152
|
+
}
|
|
5153
|
+
return `mode-${index}`;
|
|
5154
|
+
}
|
|
5155
|
+
isSameMode(modeA, modeB) {
|
|
5156
|
+
if (modeA === modeB) {
|
|
5157
|
+
return true;
|
|
5158
|
+
}
|
|
5159
|
+
const constructorA = modeA == null ? void 0 : modeA.constructor;
|
|
5160
|
+
const constructorB = modeB == null ? void 0 : modeB.constructor;
|
|
5161
|
+
return Boolean(constructorA && constructorB && constructorA === constructorB);
|
|
5162
|
+
}
|
|
5163
|
+
};
|
|
5164
|
+
var EditModeTrayWidget = _EditModeTrayWidget;
|
|
5165
|
+
__publicField(EditModeTrayWidget, "defaultProps", {
|
|
5166
|
+
id: "edit-mode-tray",
|
|
5167
|
+
placement: "top-left",
|
|
5168
|
+
layout: "vertical",
|
|
5169
|
+
modes: [],
|
|
5170
|
+
style: {},
|
|
5171
|
+
className: ""
|
|
5172
|
+
});
|
|
5471
5173
|
|
|
5472
5174
|
// dist/edit-modes/resize-circle-mode.js
|
|
5473
5175
|
var import_nearest_point_on_line2 = __toESM(require("@turf/nearest-point-on-line"), 1);
|