@gramps-connect/story 0.6.0 → 0.6.1

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/editor.js CHANGED
@@ -3802,6 +3802,7 @@ var COLOR_SWATCHES = [
3802
3802
  "#e0678a",
3803
3803
  "#555555"
3804
3804
  ];
3805
+ var UNSET_OPACITY = 0.25;
3805
3806
  var EMPTY_LABEL_PREVIEW = { type: "FeatureCollection", features: [] };
3806
3807
  var OVERLAY_ANCHOR_LAYER = "image-overlay-anchor";
3807
3808
  var TERRA_DRAW_LAYERS = ["td-polygon", "td-polygon-outline", "td-linestring", "td-point", "td-point-marker"];
@@ -3905,9 +3906,11 @@ var MapEditor = forwardRef(function MapEditor2({
3905
3906
  const [color, setColor] = useState7(() => defaultColor ?? defaultColors(dark).mark);
3906
3907
  const colorRef = useRef8(color);
3907
3908
  colorRef.current = color;
3908
- const [opacity, setOpacity] = useState7(0.25);
3909
+ const [opacity, setOpacity] = useState7(UNSET_OPACITY);
3909
3910
  const opacityRef = useRef8(opacity);
3910
3911
  opacityRef.current = opacity;
3912
+ const unsetColorRef = useRef8(defaultColor ?? defaultColors(dark).mark);
3913
+ unsetColorRef.current = defaultColor ?? defaultColors(dark).mark;
3911
3914
  const [labelText, setLabelText] = useState7("");
3912
3915
  const refreshLabelPreviewRef = useRef8(null);
3913
3916
  const [selectedId, setSelectedId] = useState7(null);
@@ -3970,8 +3973,8 @@ var MapEditor = forwardRef(function MapEditor2({
3970
3973
  map.dragRotate.disable();
3971
3974
  map.touchZoomRotate.disableRotation();
3972
3975
  map.keyboard.disableRotation();
3973
- const readColor = (feature) => feature.properties.color ?? colorRef.current;
3974
- const readOpacity = (feature) => feature.properties.opacity ?? opacityRef.current;
3976
+ const readColor = (feature) => feature.properties.color ?? unsetColorRef.current;
3977
+ const readOpacity = (feature) => feature.properties.opacity ?? UNSET_OPACITY;
3975
3978
  const draw = new TerraDraw({
3976
3979
  adapter: new TerraDrawMapLibreGLAdapter({ map }),
3977
3980
  modes: [
@@ -4060,8 +4063,8 @@ var MapEditor = forwardRef(function MapEditor2({
4060
4063
  const feature = id ? draw.getSnapshot().find((f) => String(f.id) === id) : void 0;
4061
4064
  setLabelText(feature?.properties?.name ?? "");
4062
4065
  if (feature) {
4063
- setColor(feature.properties?.color ?? colorRef.current);
4064
- setOpacity(feature.properties?.opacity ?? 0.25);
4066
+ setColor(feature.properties?.color ?? unsetColorRef.current);
4067
+ setOpacity(feature.properties?.opacity ?? UNSET_OPACITY);
4065
4068
  setSelectedOverlayId(null);
4066
4069
  }
4067
4070
  }
@@ -4471,12 +4474,13 @@ var MapEditor = forwardRef(function MapEditor2({
4471
4474
  getResult() {
4472
4475
  const savedParts = (drawRef.current?.getSnapshot() ?? []).filter((f) => f.geometry != null && !f.properties?.selectionPoint && !f.properties?.midPoint).map((f) => {
4473
4476
  const name = f.properties?.name?.trim();
4474
- const regionOpacity = f.geometry.type === "Polygon" ? f.properties?.opacity ?? opacityRef.current : void 0;
4477
+ const regionOpacity = f.geometry.type === "Polygon" ? f.properties?.opacity : void 0;
4478
+ const color2 = f.properties?.color;
4475
4479
  const sourceKey = f.properties?.sourceKey;
4476
4480
  return {
4477
4481
  ...typeof sourceKey === "string" ? { sourceKey } : {},
4478
4482
  geometry: f.geometry,
4479
- color: f.properties?.color ?? colorRef.current,
4483
+ ...color2 !== void 0 ? { color: color2 } : {},
4480
4484
  ...name ? { name } : {},
4481
4485
  ...regionOpacity !== void 0 ? { opacity: regionOpacity } : {}
4482
4486
  };