@macrostrat/column-views 3.6.1 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/dist/animated-age-window.cjs +51 -0
  3. package/dist/animated-age-window.cjs.map +1 -0
  4. package/dist/animated-age-window.d.ts +51 -0
  5. package/dist/animated-age-window.js +51 -0
  6. package/dist/animated-age-window.js.map +1 -0
  7. package/dist/column-views.css +118 -89
  8. package/dist/column.cjs +12 -3
  9. package/dist/column.cjs.map +1 -1
  10. package/dist/column.d.ts +11 -0
  11. package/dist/column.js +12 -3
  12. package/dist/column.js.map +1 -1
  13. package/dist/column.module.sass.cjs +15 -15
  14. package/dist/column.module.sass.js +15 -15
  15. package/dist/correlation-chart/main.cjs +156 -42
  16. package/dist/correlation-chart/main.cjs.map +1 -1
  17. package/dist/correlation-chart/main.d.ts +40 -2
  18. package/dist/correlation-chart/main.js +138 -23
  19. package/dist/correlation-chart/main.js.map +1 -1
  20. package/dist/correlation-chart/main.module.sass.cjs +23 -20
  21. package/dist/correlation-chart/main.module.sass.cjs.map +1 -1
  22. package/dist/correlation-chart/main.module.sass.js +23 -20
  23. package/dist/correlation-chart/main.module.sass.js.map +1 -1
  24. package/dist/correlation-chart/prepare-data.cjs +0 -1
  25. package/dist/correlation-chart/prepare-data.cjs.map +1 -1
  26. package/dist/correlation-chart/prepare-data.js +0 -1
  27. package/dist/correlation-chart/prepare-data.js.map +1 -1
  28. package/dist/data-provider/store.cjs +17 -4
  29. package/dist/data-provider/store.cjs.map +1 -1
  30. package/dist/data-provider/store.d.ts +6 -1
  31. package/dist/data-provider/store.js +17 -4
  32. package/dist/data-provider/store.js.map +1 -1
  33. package/dist/data-provider/unit-selection.cjs +4 -1
  34. package/dist/data-provider/unit-selection.cjs.map +1 -1
  35. package/dist/data-provider/unit-selection.d.ts +1 -1
  36. package/dist/data-provider/unit-selection.js +4 -1
  37. package/dist/data-provider/unit-selection.js.map +1 -1
  38. package/dist/index.cjs +16 -4
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.ts +1 -0
  41. package/dist/index.js +5 -2
  42. package/dist/index.js.map +1 -1
  43. package/dist/maps/column-correlation/core.cjs +127 -6
  44. package/dist/maps/column-correlation/core.cjs.map +1 -1
  45. package/dist/maps/column-correlation/core.js +128 -7
  46. package/dist/maps/column-correlation/core.js.map +1 -1
  47. package/dist/maps/column-correlation/state.cjs +63 -2
  48. package/dist/maps/column-correlation/state.cjs.map +1 -1
  49. package/dist/maps/column-correlation/state.d.ts +31 -1
  50. package/dist/maps/column-correlation/state.js +63 -2
  51. package/dist/maps/column-correlation/state.js.map +1 -1
  52. package/dist/maps/layers/columns.cjs +5 -1
  53. package/dist/maps/layers/columns.cjs.map +1 -1
  54. package/dist/maps/layers/columns.js +5 -1
  55. package/dist/maps/layers/columns.js.map +1 -1
  56. package/dist/prepare-units/composite-scale.cjs +94 -8
  57. package/dist/prepare-units/composite-scale.cjs.map +1 -1
  58. package/dist/prepare-units/composite-scale.d.ts +39 -0
  59. package/dist/prepare-units/composite-scale.js +96 -10
  60. package/dist/prepare-units/composite-scale.js.map +1 -1
  61. package/dist/prepare-units/helpers.cjs +0 -1
  62. package/dist/prepare-units/helpers.cjs.map +1 -1
  63. package/dist/prepare-units/helpers.js +0 -1
  64. package/dist/prepare-units/helpers.js.map +1 -1
  65. package/dist/prepare-units/index.cjs +33 -12
  66. package/dist/prepare-units/index.cjs.map +1 -1
  67. package/dist/prepare-units/index.js +34 -13
  68. package/dist/prepare-units/index.js.map +1 -1
  69. package/dist/prepare-units/types.cjs.map +1 -1
  70. package/dist/prepare-units/types.d.ts +13 -0
  71. package/dist/prepare-units/types.js.map +1 -1
  72. package/dist/section.cjs +10 -2
  73. package/dist/section.cjs.map +1 -1
  74. package/dist/section.d.ts +5 -0
  75. package/dist/section.js +10 -2
  76. package/dist/section.js.map +1 -1
  77. package/dist/unit-details/age-range.cjs +2 -1
  78. package/dist/unit-details/age-range.cjs.map +1 -1
  79. package/dist/unit-details/age-range.js +2 -1
  80. package/dist/unit-details/age-range.js.map +1 -1
  81. package/dist/unit-details/index.d.ts +1 -1
  82. package/dist/unit-details/panel.cjs +2 -3
  83. package/dist/unit-details/panel.cjs.map +1 -1
  84. package/dist/unit-details/panel.js +1 -2
  85. package/dist/unit-details/panel.js.map +1 -1
  86. package/dist/unit-details/panel.module.sass.cjs +18 -22
  87. package/dist/unit-details/panel.module.sass.cjs.map +1 -1
  88. package/dist/unit-details/panel.module.sass.js +18 -22
  89. package/dist/unit-details/panel.module.sass.js.map +1 -1
  90. package/dist/unit-details/strat-names.cjs +1 -2
  91. package/dist/unit-details/strat-names.cjs.map +1 -1
  92. package/dist/unit-details/strat-names.js +1 -2
  93. package/dist/unit-details/strat-names.js.map +1 -1
  94. package/dist/units/boxes.cjs +20 -36
  95. package/dist/units/boxes.cjs.map +1 -1
  96. package/dist/units/boxes.js +22 -38
  97. package/dist/units/boxes.js.map +1 -1
  98. package/dist/units/composite.cjs +12 -12
  99. package/dist/units/composite.cjs.map +1 -1
  100. package/dist/units/composite.js +12 -12
  101. package/dist/units/composite.js.map +1 -1
  102. package/package.json +9 -9
  103. package/src/animated-age-window.ts +120 -0
  104. package/src/column.module.sass +6 -0
  105. package/src/column.ts +24 -0
  106. package/src/correlation-chart/main.module.sass +46 -2
  107. package/src/correlation-chart/main.ts +210 -17
  108. package/src/correlation-chart/prepare-data.ts +0 -1
  109. package/src/data-provider/store.ts +21 -2
  110. package/src/data-provider/unit-selection.ts +13 -2
  111. package/src/index.ts +1 -0
  112. package/src/maps/column-correlation/column-correlation-map.stories.ts +12 -0
  113. package/src/maps/column-correlation/core.ts +155 -9
  114. package/src/maps/column-correlation/state.ts +110 -2
  115. package/src/maps/layers/columns.ts +7 -1
  116. package/src/prepare-units/composite-scale.ts +210 -10
  117. package/src/prepare-units/helpers.ts +0 -2
  118. package/src/prepare-units/index.ts +68 -14
  119. package/src/prepare-units/types.ts +13 -0
  120. package/src/section.ts +15 -1
  121. package/src/unit-details/age-range.ts +3 -1
  122. package/src/unit-details/index.ts +7 -1
  123. package/src/unit-details/panel.module.sass +0 -8
  124. package/src/unit-details/panel.ts +6 -6
  125. package/src/unit-details/strat-names.ts +1 -1
  126. package/src/units/boxes.ts +33 -53
  127. package/src/units/composite.ts +21 -12
  128. package/dist/correlation-chart/stories/utils.d.ts +0 -6
  129. package/dist/unit-details/identifiers.cjs +0 -56
  130. package/dist/unit-details/identifiers.cjs.map +0 -1
  131. package/dist/unit-details/identifiers.d.ts +0 -31
  132. package/dist/unit-details/identifiers.js +0 -54
  133. package/dist/unit-details/identifiers.js.map +0 -1
  134. package/src/correlation-chart/stories/correlation-chart.stories.ts +0 -228
  135. package/src/correlation-chart/stories/namibia-correlation.stories.ts +0 -151
  136. package/src/correlation-chart/stories/stories.module.sass +0 -18
  137. package/src/correlation-chart/stories/utils.ts +0 -24
  138. package/src/unit-details/identifiers.ts +0 -67
@@ -4,7 +4,6 @@ const dataComponents = require("@macrostrat/data-components");
4
4
  const panel_module = require("./panel.module.sass.cjs");
5
5
  const classNames = require("classnames");
6
6
  const dataProvider = require("@macrostrat/data-provider");
7
- const identifiers = require("./identifiers.cjs");
8
7
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
9
8
  const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
10
9
  function useStratNameData(strat_name_id) {
@@ -19,7 +18,7 @@ function StratNameField(props) {
19
18
  ...baseInteractionProps,
20
19
  ...rest
21
20
  };
22
- let inner = panel_module.default(identifiers.Identifier, { id: strat_name_id });
21
+ let inner = panel_module.default(dataComponents.Identifier, { id: strat_name_id });
23
22
  const name = data?.strat_name_long;
24
23
  if (name != null) {
25
24
  inner = panel_module.default("span.strat-name", name);
@@ -1 +1 @@
1
- {"version":3,"file":"strat-names.cjs","sources":["../../src/unit-details/strat-names.ts"],"sourcesContent":["import {\n DataField,\n isClickable,\n ItemInteractionProps,\n useInteractionProps,\n} from \"@macrostrat/data-components\";\nimport h from \"./panel.module.sass\";\nimport classNames from \"classnames\";\nimport { useStratNames } from \"@macrostrat/data-provider\";\nimport { Identifier } from \"./identifiers.ts\";\n\nfunction useStratNameData(strat_name_id: number) {\n const stratNames = useStratNames([strat_name_id]);\n return stratNames?.[0];\n}\n\nexport function StratNameField(\n props: {\n strat_name_id: number;\n className?: string;\n } & ItemInteractionProps,\n) {\n /** Handling for stratigraphic name field */\n const { strat_name_id, className, ...rest } = props;\n\n const data = useStratNameData(strat_name_id);\n\n const baseInteractionProps = useInteractionProps({ strat_name_id });\n\n const coreProps = {\n ...baseInteractionProps,\n ...rest,\n };\n\n let inner: any = h(Identifier, { id: strat_name_id });\n const name = data?.strat_name_long;\n if (name != null) {\n inner = h(\"span.strat-name\", name);\n }\n\n const clickable = isClickable(coreProps);\n\n return h(\n DataField,\n {\n label: \"Stratigraphic name\",\n },\n h(\n clickable ? \"a\" : \"span\",\n {\n className: classNames({ clickable }, className),\n ...coreProps,\n },\n inner,\n ),\n );\n}\n"],"names":["useStratNames","useInteractionProps","h","Identifier","isClickable","DataField","classNames"],"mappings":";;;;;;;;;AAWA,SAAS,iBAAiB,eAAuB;AAC/C,QAAM,aAAaA,aAAAA,cAAc,CAAC,aAAa,CAAC;AAChD,SAAO,aAAa,CAAC;AACvB;AAEO,SAAS,eACd,OAIA;AAEA,QAAM,EAAE,eAAe,WAAW,GAAG,SAAS;AAE9C,QAAM,OAAO,iBAAiB,aAAa;AAE3C,QAAM,uBAAuBC,eAAAA,oBAAoB,EAAE,eAAe;AAElE,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAGL,MAAI,QAAaC,aAAAA,QAAEC,YAAAA,YAAY,EAAE,IAAI,eAAe;AACpD,QAAM,OAAO,MAAM;AACnB,MAAI,QAAQ,MAAM;AAChB,YAAQD,aAAAA,QAAE,mBAAmB,IAAI;AAAA,EACnC;AAEA,QAAM,YAAYE,eAAAA,YAAY,SAAS;AAEvC,SAAOF,aAAAA;AAAAA,IACLG,eAAAA;AAAAA,IACA;AAAA,MACE,OAAO;AAAA,IAAA;AAAA,IAETH,aAAAA;AAAAA,MACE,YAAY,MAAM;AAAA,MAClB;AAAA,QACE,WAAWI,oBAAAA,QAAW,EAAE,UAAA,GAAa,SAAS;AAAA,QAC9C,GAAG;AAAA,MAAA;AAAA,MAEL;AAAA,IAAA;AAAA,EACF;AAEJ;;"}
1
+ {"version":3,"file":"strat-names.cjs","sources":["../../src/unit-details/strat-names.ts"],"sourcesContent":["import {\n DataField,\n isClickable,\n ItemInteractionProps,\n useInteractionProps,\n Identifier,\n} from \"@macrostrat/data-components\";\nimport h from \"./panel.module.sass\";\nimport classNames from \"classnames\";\nimport { useStratNames } from \"@macrostrat/data-provider\";\n\nfunction useStratNameData(strat_name_id: number) {\n const stratNames = useStratNames([strat_name_id]);\n return stratNames?.[0];\n}\n\nexport function StratNameField(\n props: {\n strat_name_id: number;\n className?: string;\n } & ItemInteractionProps,\n) {\n /** Handling for stratigraphic name field */\n const { strat_name_id, className, ...rest } = props;\n\n const data = useStratNameData(strat_name_id);\n\n const baseInteractionProps = useInteractionProps({ strat_name_id });\n\n const coreProps = {\n ...baseInteractionProps,\n ...rest,\n };\n\n let inner: any = h(Identifier, { id: strat_name_id });\n const name = data?.strat_name_long;\n if (name != null) {\n inner = h(\"span.strat-name\", name);\n }\n\n const clickable = isClickable(coreProps);\n\n return h(\n DataField,\n {\n label: \"Stratigraphic name\",\n },\n h(\n clickable ? \"a\" : \"span\",\n {\n className: classNames({ clickable }, className),\n ...coreProps,\n },\n inner,\n ),\n );\n}\n"],"names":["useStratNames","useInteractionProps","h","Identifier","isClickable","DataField","classNames"],"mappings":";;;;;;;;AAWA,SAAS,iBAAiB,eAAuB;AAC/C,QAAM,aAAaA,aAAAA,cAAc,CAAC,aAAa,CAAC;AAChD,SAAO,aAAa,CAAC;AACvB;AAEO,SAAS,eACd,OAIA;AAEA,QAAM,EAAE,eAAe,WAAW,GAAG,SAAS;AAE9C,QAAM,OAAO,iBAAiB,aAAa;AAE3C,QAAM,uBAAuBC,eAAAA,oBAAoB,EAAE,eAAe;AAElE,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAGL,MAAI,QAAaC,aAAAA,QAAEC,eAAAA,YAAY,EAAE,IAAI,eAAe;AACpD,QAAM,OAAO,MAAM;AACnB,MAAI,QAAQ,MAAM;AAChB,YAAQD,aAAAA,QAAE,mBAAmB,IAAI;AAAA,EACnC;AAEA,QAAM,YAAYE,eAAAA,YAAY,SAAS;AAEvC,SAAOF,aAAAA;AAAAA,IACLG,eAAAA;AAAAA,IACA;AAAA,MACE,OAAO;AAAA,IAAA;AAAA,IAETH,aAAAA;AAAAA,MACE,YAAY,MAAM;AAAA,MAClB;AAAA,QACE,WAAWI,oBAAAA,QAAW,EAAE,UAAA,GAAa,SAAS;AAAA,QAC9C,GAAG;AAAA,MAAA;AAAA,MAEL;AAAA,IAAA;AAAA,EACF;AAEJ;;"}
@@ -1,8 +1,7 @@
1
- import { useInteractionProps, isClickable, DataField } from "@macrostrat/data-components";
1
+ import { useInteractionProps, Identifier, isClickable, DataField } from "@macrostrat/data-components";
2
2
  import h from "./panel.module.sass.js";
3
3
  import classNames from "classnames";
4
4
  import { useStratNames } from "@macrostrat/data-provider";
5
- import { Identifier } from "./identifiers.js";
6
5
  function useStratNameData(strat_name_id) {
7
6
  const stratNames = useStratNames([strat_name_id]);
8
7
  return stratNames?.[0];
@@ -1 +1 @@
1
- {"version":3,"file":"strat-names.js","sources":["../../src/unit-details/strat-names.ts"],"sourcesContent":["import {\n DataField,\n isClickable,\n ItemInteractionProps,\n useInteractionProps,\n} from \"@macrostrat/data-components\";\nimport h from \"./panel.module.sass\";\nimport classNames from \"classnames\";\nimport { useStratNames } from \"@macrostrat/data-provider\";\nimport { Identifier } from \"./identifiers.ts\";\n\nfunction useStratNameData(strat_name_id: number) {\n const stratNames = useStratNames([strat_name_id]);\n return stratNames?.[0];\n}\n\nexport function StratNameField(\n props: {\n strat_name_id: number;\n className?: string;\n } & ItemInteractionProps,\n) {\n /** Handling for stratigraphic name field */\n const { strat_name_id, className, ...rest } = props;\n\n const data = useStratNameData(strat_name_id);\n\n const baseInteractionProps = useInteractionProps({ strat_name_id });\n\n const coreProps = {\n ...baseInteractionProps,\n ...rest,\n };\n\n let inner: any = h(Identifier, { id: strat_name_id });\n const name = data?.strat_name_long;\n if (name != null) {\n inner = h(\"span.strat-name\", name);\n }\n\n const clickable = isClickable(coreProps);\n\n return h(\n DataField,\n {\n label: \"Stratigraphic name\",\n },\n h(\n clickable ? \"a\" : \"span\",\n {\n className: classNames({ clickable }, className),\n ...coreProps,\n },\n inner,\n ),\n );\n}\n"],"names":[],"mappings":";;;;;AAWA,SAAS,iBAAiB,eAAuB;AAC/C,QAAM,aAAa,cAAc,CAAC,aAAa,CAAC;AAChD,SAAO,aAAa,CAAC;AACvB;AAEO,SAAS,eACd,OAIA;AAEA,QAAM,EAAE,eAAe,WAAW,GAAG,SAAS;AAE9C,QAAM,OAAO,iBAAiB,aAAa;AAE3C,QAAM,uBAAuB,oBAAoB,EAAE,eAAe;AAElE,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAGL,MAAI,QAAa,EAAE,YAAY,EAAE,IAAI,eAAe;AACpD,QAAM,OAAO,MAAM;AACnB,MAAI,QAAQ,MAAM;AAChB,YAAQ,EAAE,mBAAmB,IAAI;AAAA,EACnC;AAEA,QAAM,YAAY,YAAY,SAAS;AAEvC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,OAAO;AAAA,IAAA;AAAA,IAET;AAAA,MACE,YAAY,MAAM;AAAA,MAClB;AAAA,QACE,WAAW,WAAW,EAAE,UAAA,GAAa,SAAS;AAAA,QAC9C,GAAG;AAAA,MAAA;AAAA,MAEL;AAAA,IAAA;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"strat-names.js","sources":["../../src/unit-details/strat-names.ts"],"sourcesContent":["import {\n DataField,\n isClickable,\n ItemInteractionProps,\n useInteractionProps,\n Identifier,\n} from \"@macrostrat/data-components\";\nimport h from \"./panel.module.sass\";\nimport classNames from \"classnames\";\nimport { useStratNames } from \"@macrostrat/data-provider\";\n\nfunction useStratNameData(strat_name_id: number) {\n const stratNames = useStratNames([strat_name_id]);\n return stratNames?.[0];\n}\n\nexport function StratNameField(\n props: {\n strat_name_id: number;\n className?: string;\n } & ItemInteractionProps,\n) {\n /** Handling for stratigraphic name field */\n const { strat_name_id, className, ...rest } = props;\n\n const data = useStratNameData(strat_name_id);\n\n const baseInteractionProps = useInteractionProps({ strat_name_id });\n\n const coreProps = {\n ...baseInteractionProps,\n ...rest,\n };\n\n let inner: any = h(Identifier, { id: strat_name_id });\n const name = data?.strat_name_long;\n if (name != null) {\n inner = h(\"span.strat-name\", name);\n }\n\n const clickable = isClickable(coreProps);\n\n return h(\n DataField,\n {\n label: \"Stratigraphic name\",\n },\n h(\n clickable ? \"a\" : \"span\",\n {\n className: classNames({ clickable }, className),\n ...coreProps,\n },\n inner,\n ),\n );\n}\n"],"names":[],"mappings":";;;;AAWA,SAAS,iBAAiB,eAAuB;AAC/C,QAAM,aAAa,cAAc,CAAC,aAAa,CAAC;AAChD,SAAO,aAAa,CAAC;AACvB;AAEO,SAAS,eACd,OAIA;AAEA,QAAM,EAAE,eAAe,WAAW,GAAG,SAAS;AAE9C,QAAM,OAAO,iBAAiB,aAAa;AAE3C,QAAM,uBAAuB,oBAAoB,EAAE,eAAe;AAElE,QAAM,YAAY;AAAA,IAChB,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAGL,MAAI,QAAa,EAAE,YAAY,EAAE,IAAI,eAAe;AACpD,QAAM,OAAO,MAAM;AACnB,MAAI,QAAQ,MAAM;AAChB,YAAQ,EAAE,mBAAmB,IAAI;AAAA,EACnC;AAEA,QAAM,YAAY,YAAY,SAAS;AAEvC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,OAAO;AAAA,IAAA;AAAA,IAET;AAAA,MACE,YAAY,MAAM;AAAA,MAClB;AAAA,QACE,WAAW,WAAW,EAAE,UAAA,GAAa,SAAS;AAAA,QAC9C,GAAG;AAAA,MAAA;AAAA,MAEL;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -14,6 +14,7 @@ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
14
  const h__default = /* @__PURE__ */ _interopDefault(h$1);
15
15
  const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
16
16
  const h = h__default.default.styled(boxes_module.default);
17
+ const cls = (name) => boxes_module.default[name] ?? name;
17
18
  function useUnitRect(division, options = {}) {
18
19
  const {
19
20
  widthFraction = 1,
@@ -60,7 +61,7 @@ function Unit(props) {
60
61
  let _fill = fill ?? columnComponents.useGeologicPattern(_patternID, defaultFill);
61
62
  const hasBackgroundColor = backgroundColor != null;
62
63
  const _className = classNames__default.default(className, { colored: hasBackgroundColor });
63
- const [ref, selected, onClick] = unitSelection.useUnitSelectionTarget(d);
64
+ const [ref, selected, onClick, linked] = unitSelection.useUnitSelectionTarget(d);
64
65
  return h(
65
66
  "g.unit",
66
67
  {
@@ -70,54 +71,33 @@ function Unit(props) {
70
71
  }
71
72
  },
72
73
  [
73
- h(UnitRect, {
74
+ h(columnComponents.ClippableRect, {
74
75
  ...bounds,
75
76
  fill: backgroundColor,
76
77
  onClick,
77
- className: "background"
78
+ className: cls("background")
78
79
  }),
79
- h(UnitRect, {
80
+ h(columnComponents.ClippableRect, {
80
81
  ref,
81
82
  ...bounds,
82
83
  fill: _fill,
83
84
  //mask,
84
85
  onClick,
85
- className: "unit"
86
+ className: cls("unit")
87
+ }),
88
+ h.if(linked)(columnComponents.ClippableRect, {
89
+ ...bounds,
90
+ className: cls("linked-overlay")
91
+ }),
92
+ h.if(selected)(columnComponents.ClippableRect, {
93
+ ...bounds,
94
+ className: cls("selection-overlay")
86
95
  }),
87
- h.if(selected)(UnitRect, { ...bounds, className: "selection-overlay" }),
88
96
  //defs,
89
97
  children
90
98
  ]
91
99
  );
92
100
  }
93
- const UnitRect = React.forwardRef((props, ref) => {
94
- const {
95
- x,
96
- y,
97
- width,
98
- height,
99
- overflowTop = false,
100
- overflowBottom = false,
101
- ...rest
102
- } = props;
103
- if (!overflowTop && !overflowBottom) {
104
- return h("rect", {
105
- x,
106
- y,
107
- width,
108
- height,
109
- ref,
110
- ...rest
111
- });
112
- } else {
113
- const d = columnComponents.zigZagBoxPath(x, y, width, height, overflowTop, overflowBottom);
114
- return h("path", {
115
- d,
116
- ref,
117
- ...rest
118
- });
119
- }
120
- });
121
101
  function LabeledUnit(props) {
122
102
  const {
123
103
  division,
@@ -131,12 +111,13 @@ function LabeledUnit(props) {
131
111
  // not sure why this is brought in...
132
112
  ...baseBounds
133
113
  } = props;
134
- const { axisType } = columnComponents.useColumn();
114
+ const { axisType, isTransitioning, hideLabelsWhileTransitioning } = columnComponents.useColumn();
135
115
  const bounds = {
136
116
  ...useUnitRect(division, { widthFraction, axisType }),
137
117
  ...baseBounds
138
118
  };
139
119
  const { width, height } = bounds;
120
+ const skipLabel = isTransitioning && hideLabelsWhileTransitioning;
140
121
  return h(
141
122
  Unit,
142
123
  {
@@ -147,7 +128,7 @@ function LabeledUnit(props) {
147
128
  ...bounds
148
129
  },
149
130
  [
150
- h.if(showLabel)(
131
+ h.if(showLabel && !skipLabel)(
151
132
  columnComponents.ForeignObject,
152
133
  { ...bounds, className: "unit-label-container" },
153
134
  h(uiComponents.SizeAwareLabel, {
@@ -155,6 +136,9 @@ function LabeledUnit(props) {
155
136
  labelClassName: "unit-label",
156
137
  style: { width, height },
157
138
  label,
139
+ // Re-fit the label when a transition settles (isTransitioning flips),
140
+ // not on every intermediate frame.
141
+ remeasureKey: isTransitioning,
158
142
  onVisibilityChanged(viz) {
159
143
  onLabelUpdated(label, viz);
160
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"boxes.cjs","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n zigZagBoxPath,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { forwardRef, ReactNode, useContext, useMemo } from \"react\";\nimport { resolveID, scalePattern } from \"./resolvers\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport { getMixedUnitColor } from \"./colors\";\nimport type { RectBounds } from \"./types\";\n\nconst h = hyper.styled(styles);\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? resolveID(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(UnitRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: \"background\",\n }),\n h(UnitRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: \"unit\",\n }),\n h.if(selected)(UnitRect, { ...bounds, className: \"selection-overlay\" }),\n //defs,\n children,\n ],\n );\n}\n\ninterface UnitRectProps {\n x: number;\n y: number;\n width: number;\n height: number;\n className: string;\n // Used to determine if the rect should have a zig-zag edge on the top or bottom\n overflowTop?: boolean;\n overflowBottom?: boolean;\n [key: string]: any;\n}\n\nconst UnitRect = forwardRef((props: UnitRectProps, ref) => {\n const {\n x,\n y,\n width,\n height,\n overflowTop = false,\n overflowBottom = false,\n ...rest\n } = props;\n\n if (!overflowTop && !overflowBottom) {\n return h(\"rect\", {\n x,\n y,\n width,\n height,\n ref,\n ...rest,\n });\n } else {\n const d = zigZagBoxPath(x, y, width, height, overflowTop, overflowBottom);\n return h(\"path\", {\n d,\n ref,\n ...rest,\n });\n }\n});\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles","ColumnAxisType","useContext","ColumnContext","ColumnLayoutContext","getUnitHeightRange","useColumn","resolveID","useGeologicPattern","classNames","useUnitSelectionTarget","forwardRef","zigZagBoxPath","ForeignObject","SizeAwareLabel","useMemo","PatternDefsProvider","scalePattern"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,oBAAM;AAkC7B,SAAS,YACP,UACA,UAA2B,IACf;AACZ,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB,WAAWC,iBAAAA,eAAe;AAAA,IAC1B,UAAU;AAAA,EAAA,IACR;AACJ,QAAM,EAAE,MAAA,IAAUC,MAAAA,WAAWC,8BAAa;AAC1C,QAAM,EAAE,MAAA,IAAUD,MAAAA,WAAWE,oCAAmB;AAEhD,QAAM,CAAC,cAAc,SAAS,IAAIC,MAAAA,mBAAmB,UAAU,QAAQ;AAEvE,QAAM,IAAI,MAAM,SAAS;AACzB,QAAM,SAAS,KAAK,IAAI,MAAM,YAAY,IAAI,CAAC;AAE/C,SAAO;AAAA,IACL,GAAG,SAAS,IAAI,iBAAiB;AAAA,IACjC,GAAG,IAAI;AAAA,IACP,QAAQ,SAAS,UAAU;AAAA,IAC3B,OAAO,gBAAgB,QAAQ,UAAU;AAAA,EAAA;AAE7C;AA+CA,SAAS,KAAK,OAAkB;AAC9B,QAAM;AAAA,IACJ,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA,gBAAgB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1D,QAAM,EAAE,UAAA,IAAcZ,MAAAA,WAAWC,8BAAa;AAE9C,MAAI,UAAU,UAAU,GAAG;AACzB,YAAQ,KAAK,sCAAsC;AACnD,WAAO;AAAA,EACT;AAEA,QAAM,WAAWY,MAAAA,QAAQ,MAAM;AAC7B,WAAO,UAAU,IAAI,CAAC,UAAe,MAAM;AAEzC,aAAO,EAAE,eAAe;AAAA,QACtB;AAAA,QACA,KAAK,SAAS;AAAA,QACd,GAAG;AAAA,MAAA,CACJ;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,eAAe,kBAAkB,CAAC;AAEjD,SAAO;AAAA,IACLC,iBAAAA;AAAAA,IACA,EAAA,WAAET,UAAAA,yBAAWU,UAAAA,aAAA;AAAA,IACb,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;;;;"}
1
+ {"version":3,"file":"boxes.cjs","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ClippableRect,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { ReactNode, useContext, useMemo } from \"react\";\nimport { resolveID, scalePattern } from \"./resolvers\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport { getMixedUnitColor } from \"./colors\";\nimport type { RectBounds } from \"./types\";\n\nconst h = hyper.styled(styles);\n\n/** Resolve a class name through this file's CSS module exactly as the styled\n * `h` would (module-scoped classes are hashed; unknown/global classes pass\n * through). Needed because `ClippableRect` renders the element in\n * `@macrostrat/column-components`, so class resolution must happen here. */\nconst cls = (name: string): string => (styles as any)[name] ?? name;\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(linked)(\"rect.linked-overlay\", bounds),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? resolveID(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(ClippableRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: cls(\"background\"),\n }),\n h(ClippableRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: cls(\"unit\"),\n }),\n h.if(linked)(ClippableRect, {\n ...bounds,\n className: cls(\"linked-overlay\"),\n }),\n h.if(selected)(ClippableRect, {\n ...bounds,\n className: cls(\"selection-overlay\"),\n }),\n //defs,\n children,\n ],\n );\n}\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType, isTransitioning, hideLabelsWhileTransitioning } =\n useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n // Labels stay visible through the animation by default. `hideLabelsWhileTransitioning`\n // is a perf escape hatch: when set, the `foreignObject` label (whose HTML\n // reflows on every size change) is skipped mid-transition and restored on settle.\n const skipLabel = isTransitioning && hideLabelsWhileTransitioning;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel && !skipLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n // Re-fit the label when a transition settles (isTransitioning flips),\n // not on every intermediate frame.\n remeasureKey: isTransitioning,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles","ColumnAxisType","useContext","ColumnContext","ColumnLayoutContext","getUnitHeightRange","useColumn","resolveID","useGeologicPattern","classNames","useUnitSelectionTarget","ClippableRect","ForeignObject","SizeAwareLabel","useMemo","PatternDefsProvider","scalePattern"],"mappings":";;;;;;;;;;;;;;;AAuBA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,oBAAM;AAM7B,MAAM,MAAM,CAAC,SAA0BA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AAA;AAAA,IAEL;AAAA,MACE,EAAE,GAAG,aAAa,CAAC,SAAS;AAAA,QAC1BM,iBAAAA;AAAAA,QACA,EAAE,GAAG,QAAQ,WAAW,uBAAA;AAAA,QACxB,EAAEC,aAAAA,gBAAgB;AAAA,UAChB,WAAW;AAAA,UACX,gBAAgB;AAAA,UAChB,OAAO,EAAE,OAAO,OAAA;AAAA,UAChB;AAAA;AAAA;AAAA,UAGA,cAAc;AAAA,UACd,oBAAoB,KAAK;AACvB,2BAAe,OAAO,GAAG;AAAA,UAC3B;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ;AAEA,SAAS,UAAa,OASnB;AACD,QAAM,EAAE,gBAAgB,MAAM,qBAAqB,CAAA,MAAO;AAC1D,QAAM,EAAE,UAAA,IAAcX,MAAAA,WAAWC,8BAAa;AAE9C,MAAI,UAAU,UAAU,GAAG;AACzB,YAAQ,KAAK,sCAAsC;AACnD,WAAO;AAAA,EACT;AAEA,QAAM,WAAWW,MAAAA,QAAQ,MAAM;AAC7B,WAAO,UAAU,IAAI,CAAC,UAAe,MAAM;AAEzC,aAAO,EAAE,eAAe;AAAA,QACtB;AAAA,QACA,KAAK,SAAS;AAAA,QACd,GAAG;AAAA,MAAA,CACJ;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,eAAe,kBAAkB,CAAC;AAEjD,SAAO;AAAA,IACLC,iBAAAA;AAAAA,IACA,EAAA,WAAER,UAAAA,yBAAWS,UAAAA,aAAA;AAAA,IACb,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;;;;"}
@@ -1,7 +1,7 @@
1
- import { useColumn, ForeignObject, ColumnContext, PatternDefsProvider, ColumnAxisType, ColumnLayoutContext, useGeologicPattern, zigZagBoxPath } from "@macrostrat/column-components";
1
+ import { useColumn, ForeignObject, ColumnContext, PatternDefsProvider, ColumnAxisType, ColumnLayoutContext, useGeologicPattern, ClippableRect } from "@macrostrat/column-components";
2
2
  import { SizeAwareLabel } from "@macrostrat/ui-components";
3
3
  import h$1 from "@macrostrat/hyper";
4
- import { useContext, useMemo, forwardRef } from "react";
4
+ import { useContext, useMemo } from "react";
5
5
  import { scalePattern, resolveID } from "./resolvers.js";
6
6
  import "@macrostrat/data-provider";
7
7
  import h$2 from "./boxes.module.sass.js";
@@ -9,6 +9,7 @@ import classNames from "classnames";
9
9
  import { getUnitHeightRange } from "../prepare-units/utils.js";
10
10
  import { useUnitSelectionTarget } from "../data-provider/unit-selection.js";
11
11
  const h = h$1.styled(h$2);
12
+ const cls = (name) => h$2[name] ?? name;
12
13
  function useUnitRect(division, options = {}) {
13
14
  const {
14
15
  widthFraction = 1,
@@ -55,7 +56,7 @@ function Unit(props) {
55
56
  let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);
56
57
  const hasBackgroundColor = backgroundColor != null;
57
58
  const _className = classNames(className, { colored: hasBackgroundColor });
58
- const [ref, selected, onClick] = useUnitSelectionTarget(d);
59
+ const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);
59
60
  return h(
60
61
  "g.unit",
61
62
  {
@@ -65,54 +66,33 @@ function Unit(props) {
65
66
  }
66
67
  },
67
68
  [
68
- h(UnitRect, {
69
+ h(ClippableRect, {
69
70
  ...bounds,
70
71
  fill: backgroundColor,
71
72
  onClick,
72
- className: "background"
73
+ className: cls("background")
73
74
  }),
74
- h(UnitRect, {
75
+ h(ClippableRect, {
75
76
  ref,
76
77
  ...bounds,
77
78
  fill: _fill,
78
79
  //mask,
79
80
  onClick,
80
- className: "unit"
81
+ className: cls("unit")
82
+ }),
83
+ h.if(linked)(ClippableRect, {
84
+ ...bounds,
85
+ className: cls("linked-overlay")
86
+ }),
87
+ h.if(selected)(ClippableRect, {
88
+ ...bounds,
89
+ className: cls("selection-overlay")
81
90
  }),
82
- h.if(selected)(UnitRect, { ...bounds, className: "selection-overlay" }),
83
91
  //defs,
84
92
  children
85
93
  ]
86
94
  );
87
95
  }
88
- const UnitRect = forwardRef((props, ref) => {
89
- const {
90
- x,
91
- y,
92
- width,
93
- height,
94
- overflowTop = false,
95
- overflowBottom = false,
96
- ...rest
97
- } = props;
98
- if (!overflowTop && !overflowBottom) {
99
- return h("rect", {
100
- x,
101
- y,
102
- width,
103
- height,
104
- ref,
105
- ...rest
106
- });
107
- } else {
108
- const d = zigZagBoxPath(x, y, width, height, overflowTop, overflowBottom);
109
- return h("path", {
110
- d,
111
- ref,
112
- ...rest
113
- });
114
- }
115
- });
116
96
  function LabeledUnit(props) {
117
97
  const {
118
98
  division,
@@ -126,12 +106,13 @@ function LabeledUnit(props) {
126
106
  // not sure why this is brought in...
127
107
  ...baseBounds
128
108
  } = props;
129
- const { axisType } = useColumn();
109
+ const { axisType, isTransitioning, hideLabelsWhileTransitioning } = useColumn();
130
110
  const bounds = {
131
111
  ...useUnitRect(division, { widthFraction, axisType }),
132
112
  ...baseBounds
133
113
  };
134
114
  const { width, height } = bounds;
115
+ const skipLabel = isTransitioning && hideLabelsWhileTransitioning;
135
116
  return h(
136
117
  Unit,
137
118
  {
@@ -142,7 +123,7 @@ function LabeledUnit(props) {
142
123
  ...bounds
143
124
  },
144
125
  [
145
- h.if(showLabel)(
126
+ h.if(showLabel && !skipLabel)(
146
127
  ForeignObject,
147
128
  { ...bounds, className: "unit-label-container" },
148
129
  h(SizeAwareLabel, {
@@ -150,6 +131,9 @@ function LabeledUnit(props) {
150
131
  labelClassName: "unit-label",
151
132
  style: { width, height },
152
133
  label,
134
+ // Re-fit the label when a transition settles (isTransitioning flips),
135
+ // not on every intermediate frame.
136
+ remeasureKey: isTransitioning,
153
137
  onVisibilityChanged(viz) {
154
138
  onLabelUpdated(label, viz);
155
139
  }
@@ -1 +1 @@
1
- {"version":3,"file":"boxes.js","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n zigZagBoxPath,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { forwardRef, ReactNode, useContext, useMemo } from \"react\";\nimport { resolveID, scalePattern } from \"./resolvers\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport { getMixedUnitColor } from \"./colors\";\nimport type { RectBounds } from \"./types\";\n\nconst h = hyper.styled(styles);\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? resolveID(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(UnitRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: \"background\",\n }),\n h(UnitRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: \"unit\",\n }),\n h.if(selected)(UnitRect, { ...bounds, className: \"selection-overlay\" }),\n //defs,\n children,\n ],\n );\n}\n\ninterface UnitRectProps {\n x: number;\n y: number;\n width: number;\n height: number;\n className: string;\n // Used to determine if the rect should have a zig-zag edge on the top or bottom\n overflowTop?: boolean;\n overflowBottom?: boolean;\n [key: string]: any;\n}\n\nconst UnitRect = forwardRef((props: UnitRectProps, ref) => {\n const {\n x,\n y,\n width,\n height,\n overflowTop = false,\n overflowBottom = false,\n ...rest\n } = props;\n\n if (!overflowTop && !overflowBottom) {\n return h(\"rect\", {\n x,\n y,\n width,\n height,\n ref,\n ...rest,\n });\n } else {\n const d = zigZagBoxPath(x, y, width, height, overflowTop, overflowBottom);\n return h(\"path\", {\n d,\n ref,\n ...rest,\n });\n }\n});\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles"],"mappings":";;;;;;;;;;AAuBA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAkC7B,SAAS,YACP,UACA,UAA2B,IACf;AACZ,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB,WAAW,eAAe;AAAA,IAC1B,UAAU;AAAA,EAAA,IACR;AACJ,QAAM,EAAE,MAAA,IAAU,WAAW,aAAa;AAC1C,QAAM,EAAE,MAAA,IAAU,WAAW,mBAAmB;AAEhD,QAAM,CAAC,cAAc,SAAS,IAAI,mBAAmB,UAAU,QAAQ;AAEvE,QAAM,IAAI,MAAM,SAAS;AACzB,QAAM,SAAS,KAAK,IAAI,MAAM,YAAY,IAAI,CAAC;AAE/C,SAAO;AAAA,IACL,GAAG,SAAS,IAAI,iBAAiB;AAAA,IACjC,GAAG,IAAI;AAAA,IACP,QAAQ,SAAS,UAAU;AAAA,IAC3B,OAAO,gBAAgB,QAAQ,UAAU;AAAA,EAAA;AAE7C;AA+CA,SAAS,KAAK,OAAkB;AAC9B,QAAM;AAAA,IACJ,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA;AAAA,IACV,GAAG;AAAA,EAAA,IACD;AAEJ,QAAM,EAAE,SAAA,IAAa,UAAA;AAErB,QAAM,iBAAiB,EAAE,cAAc;AACvC,QAAM,oBAAoB,EAAE,cAAc;AAE1C,QAAM,SAAS;AAAA,IACb,GAAG,YAAY,GAAG,EAAE,eAAe,UAAU;AAAA,IAC7C,GAAG;AAAA,IACH,aAAa;AAAA,IACb,gBAAgB;AAAA,EAAA;AAElB,QAAM,aAAa,aAAa,UAAU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AE,eAAe,QAAQ;AAAA,EAAA;AAE7B;"}
1
+ {"version":3,"file":"boxes.js","sources":["../../src/units/boxes.ts"],"sourcesContent":["import {\n ColumnAxisType,\n ColumnContext,\n ColumnLayoutContext,\n ClippableRect,\n ForeignObject,\n PatternDefsProvider,\n useColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { SizeAwareLabel, Clickable } from \"@macrostrat/ui-components\";\nimport hyper from \"@macrostrat/hyper\";\nimport { ReactNode, useContext, useMemo } from \"react\";\nimport { resolveID, scalePattern } from \"./resolvers\";\nimport { useUnitSelectionTarget } from \"../data-provider\";\nimport { useLithologies } from \"@macrostrat/data-provider\";\nimport { IUnit } from \"./types\";\nimport styles from \"./boxes.module.sass\";\nimport classNames from \"classnames\";\nimport { getUnitHeightRange } from \"../prepare-units/utils\";\nimport { getMixedUnitColor } from \"./colors\";\nimport type { RectBounds } from \"./types\";\n\nconst h = hyper.styled(styles);\n\n/** Resolve a class name through this file's CSS module exactly as the styled\n * `h` would (module-scoped classes are hashed; unknown/global classes pass\n * through). Needed because `ClippableRect` renders the element in\n * `@macrostrat/column-components`, so class resolution must happen here. */\nconst cls = (name: string): string => (styles as any)[name] ?? name;\n\ninterface UnitRectOptions {\n widthFraction?: number;\n axisType?: ColumnAxisType;\n // Padding to create overflow for zig-zags or other ornamented edges\n padding?: number;\n}\n\ninterface UnitProps extends Clickable, Partial<RectBounds>, UnitRectOptions {\n division: IUnit;\n resolveID?(IUnit): string;\n UUID?: string;\n defaultFill?: string;\n widthFraction?: number;\n children?: ReactNode;\n className?: string;\n fill?: string;\n backgroundColor?: string;\n patternColor?: string;\n patternID?: string | number;\n}\n\nexport interface LabeledUnitProps\n extends UnitRectOptions, Clickable, Partial<RectBounds> {\n division: IUnit;\n patternID?: string | number;\n label: string;\n onLabelUpdated?(label: string, shown: boolean);\n halfWidth?: boolean;\n showLabel?: boolean;\n backgroundColor?: string;\n}\n\nfunction useUnitRect(\n division: IUnit,\n options: UnitRectOptions = {},\n): RectBounds {\n const {\n widthFraction = 1,\n axisType = ColumnAxisType.AGE,\n padding = 0,\n } = options;\n const { scale } = useContext(ColumnContext);\n const { width } = useContext(ColumnLayoutContext);\n\n const [bottomHeight, topHeight] = getUnitHeightRange(division, axisType);\n\n const y = scale(topHeight);\n const height = Math.abs(scale(bottomHeight) - y);\n\n return {\n x: width * (1 - widthFraction) - padding,\n y: y - padding,\n height: height + padding * 2,\n width: widthFraction * width + padding * 2,\n };\n}\n\nexport function MinimalUnit(props) {\n const {\n division: d,\n children,\n className,\n widthFraction = 1,\n axisType: _, // not sure why this is brought in...\n nColumns: __,\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n const lithMap = useLithologies();\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n };\n\n const backgroundColor = getMixedUnitColor(d, lithMap, null, false);\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n \"--column-stroke-color\": backgroundColor,\n },\n },\n [\n h(\"rect.unit.background\", {\n ref,\n ...bounds,\n fill: backgroundColor,\n fillOpacity: 0.8,\n stroke: backgroundColor,\n onClick,\n }),\n h.if(linked)(\"rect.linked-overlay\", bounds),\n h.if(selected)(\"rect.selection-overlay\", bounds),\n ],\n );\n}\n\nfunction Unit(props: UnitProps) {\n const {\n division: d,\n children,\n fill,\n defaultFill = \"transparent\",\n className,\n widthFraction = 1,\n backgroundColor,\n patternColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType } = useColumn();\n\n const hasOverflowTop = d.t_clip_pos != null;\n const hasOverflowBottom = d.b_clip_pos != null;\n\n const bounds = {\n ...useUnitRect(d, { widthFraction, axisType }),\n ...baseBounds,\n overflowTop: hasOverflowTop,\n overflowBottom: hasOverflowBottom,\n };\n const _patternID = patternID ?? resolveID(d);\n let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);\n\n const hasBackgroundColor = backgroundColor != null;\n\n const _className = classNames(className, { colored: hasBackgroundColor });\n\n const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);\n\n return h(\n \"g.unit\",\n {\n className: _className,\n style: {\n \"--column-unit-background-color\": backgroundColor,\n },\n },\n [\n h(ClippableRect, {\n ...bounds,\n fill: backgroundColor,\n onClick,\n className: cls(\"background\"),\n }),\n h(ClippableRect, {\n ref,\n ...bounds,\n fill: _fill,\n //mask,\n onClick,\n className: cls(\"unit\"),\n }),\n h.if(linked)(ClippableRect, {\n ...bounds,\n className: cls(\"linked-overlay\"),\n }),\n h.if(selected)(ClippableRect, {\n ...bounds,\n className: cls(\"selection-overlay\"),\n }),\n //defs,\n children,\n ],\n );\n}\n\nfunction LabeledUnit(props: LabeledUnitProps) {\n const {\n division,\n label,\n onLabelUpdated,\n widthFraction,\n showLabel = true,\n backgroundColor,\n patternID,\n axisType: _, // not sure why this is brought in...\n ...baseBounds\n } = props;\n\n const { axisType, isTransitioning, hideLabelsWhileTransitioning } =\n useColumn();\n const bounds = {\n ...useUnitRect(division, { widthFraction, axisType }),\n ...baseBounds,\n };\n const { width, height } = bounds;\n // Labels stay visible through the animation by default. `hideLabelsWhileTransitioning`\n // is a perf escape hatch: when set, the `foreignObject` label (whose HTML\n // reflows on every size change) is skipped mid-transition and restored on settle.\n const skipLabel = isTransitioning && hideLabelsWhileTransitioning;\n return h(\n Unit,\n {\n className: \"labeled-unit\",\n division,\n backgroundColor,\n patternID,\n ...bounds,\n },\n [\n h.if(showLabel && !skipLabel)(\n ForeignObject,\n { ...bounds, className: \"unit-label-container\" },\n h(SizeAwareLabel, {\n className: \"unit-overlay\",\n labelClassName: \"unit-label\",\n style: { width, height },\n label,\n // Re-fit the label when a transition settles (isTransitioning flips),\n // not on every intermediate frame.\n remeasureKey: isTransitioning,\n onVisibilityChanged(viz) {\n onLabelUpdated(label, viz);\n },\n }),\n ),\n ],\n );\n}\n\nfunction UnitBoxes<T>(props: {\n unitComponent: React.FunctionComponent<{ division: T }>;\n unitComponentProps?: any;\n transformDivisions?(divisions: T[]): T[];\n transformDivision?: (\n division: any,\n index: number,\n divisions: any[],\n ) => T | null;\n}) {\n const { unitComponent = Unit, unitComponentProps = {} } = props;\n const { divisions } = useContext(ColumnContext);\n\n if (divisions.length == 0) {\n console.warn(\"No divisions found in column context\");\n return null;\n }\n\n const children = useMemo(() => {\n return divisions.map((division: any, i) => {\n // @ts-ignore\n return h(unitComponent, {\n division,\n key: division.unit_id,\n ...unitComponentProps,\n });\n });\n }, [divisions, unitComponent, unitComponentProps]);\n\n return h(\n PatternDefsProvider,\n { resolveID, scalePattern },\n h(\"g.divisions\", children),\n );\n}\n\nexport { LabeledUnit, Unit, UnitBoxes, UnitProps };\n"],"names":["hyper","styles"],"mappings":";;;;;;;;;;AAuBA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAM7B,MAAM,MAAM,CAAC,SAA0BA,IAAe,IAAI,KAAK;AAkC/D,SAAS,YACP,UACA,UAA2B,IACf;AACZ,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB,WAAW,eAAe;AAAA,IAC1B,UAAU;AAAA,EAAA,IACR;AACJ,QAAM,EAAE,MAAA,IAAU,WAAW,aAAa;AAC1C,QAAM,EAAE,MAAA,IAAU,WAAW,mBAAmB;AAEhD,QAAM,CAAC,cAAc,SAAS,IAAI,mBAAmB,UAAU,QAAQ;AAEvE,QAAM,IAAI,MAAM,SAAS;AACzB,QAAM,SAAS,KAAK,IAAI,MAAM,YAAY,IAAI,CAAC;AAE/C,SAAO;AAAA,IACL,GAAG,SAAS,IAAI,iBAAiB;AAAA,IACjC,GAAG,IAAI;AAAA,IACP,QAAQ,SAAS,UAAU;AAAA,IAC3B,OAAO,gBAAgB,QAAQ,UAAU;AAAA,EAAA;AAE7C;AAgDA,SAAS,KAAK,OAAkB;AAC9B,QAAM;AAAA,IACJ,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,cAAc;AA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;AAAA,IACH,CAAC;AAAA,EACH,GAAG,CAAC,WAAW,eAAe,kBAAkB,CAAC;AAEjD,SAAO;AAAA,IACL;AAAA,IACA,EAAE,WAAW,aAAA;AAAA,IACb,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;"}
@@ -16,22 +16,22 @@ function LabelTrackerProvider(props) {
16
16
  const { children, units, findUnitID = findMacrostratUnitID } = props;
17
17
  const [unlabeledDivisions, setUnlabeledDivisions] = React.useState(null);
18
18
  const labelTrackerRef = React.useRef({});
19
+ const recompute = React.useCallback(() => {
20
+ const tracker = labelTrackerRef.current;
21
+ const allReported = units.every((d) => findUnitID(d) in tracker);
22
+ if (!allReported) return;
23
+ setUnlabeledDivisions(units.filter((d) => tracker[findUnitID(d)] === false));
24
+ }, [units, findUnitID]);
19
25
  const trackLabelVisibility = React.useCallback(
20
26
  (div, visible) => {
21
- const id = findUnitID(div);
22
- labelTrackerRef.current[id] = visible;
23
- if (Object.keys(labelTrackerRef.current).length == units.length) {
24
- setUnlabeledDivisions(
25
- // @ts-ignore
26
- units.filter((d) => {
27
- const id2 = findUnitID(d);
28
- return labelTrackerRef.current[id2] == false;
29
- })
30
- );
31
- }
27
+ labelTrackerRef.current[findUnitID(div)] = visible;
28
+ recompute();
32
29
  },
33
- [labelTrackerRef, units, findUnitID]
30
+ [recompute, findUnitID]
34
31
  );
32
+ React.useEffect(() => {
33
+ recompute();
34
+ }, [recompute]);
35
35
  const value = trackLabelVisibility;
36
36
  return h(
37
37
  LabelTrackerContext.Provider,
@@ -1 +1 @@
1
- {"version":3,"file":"composite.cjs","sources":["../../src/units/composite.ts"],"sourcesContent":["import { hyperStyled } from \"@macrostrat/hyper\";\nimport {\n ColumnContext,\n LithologyColumn,\n SVG,\n} from \"@macrostrat/column-components\";\nimport { defaultNameFunction, UnitNamesColumn } from \"./names\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { LabeledUnit, UnitBoxes } from \"./boxes\";\nimport styles from \"./composite.module.sass\";\nimport {\n useCompositeScale,\n useMacrostratColumnData,\n useUnitSelectionDispatch,\n} from \"../data-provider\";\n\nconst h = hyperStyled(styles);\n\ninterface LabelTracker {\n [key: number]: boolean;\n}\n\nconst LabelTrackerContext = createContext(null);\nconst UnlabeledDivisionsContext = createContext(null);\n\nconst findMacrostratUnitID = (u) => u.unit_id;\n\nexport function LabelTrackerProvider(props) {\n /** Tracker for units to handle state for whether their labels fit inline or not.\n * Designed to work for single or composite columns.\n */\n const { children, units, findUnitID = findMacrostratUnitID } = props;\n const [unlabeledDivisions, setUnlabeledDivisions] = useState<\n BaseUnit[] | null\n >(null);\n const labelTrackerRef = useRef<LabelTracker>({});\n const trackLabelVisibility = useCallback(\n (div, visible) => {\n const id = findUnitID(div);\n labelTrackerRef.current[id] = visible;\n if (Object.keys(labelTrackerRef.current).length == units.length) {\n setUnlabeledDivisions(\n // @ts-ignore\n units.filter((d) => {\n const id = findUnitID(d);\n return labelTrackerRef.current[id] == false;\n }),\n );\n }\n },\n [labelTrackerRef, units, findUnitID],\n );\n\n const value = trackLabelVisibility;\n return h(\n LabelTrackerContext.Provider,\n { value },\n h(\n UnlabeledDivisionsContext.Provider,\n { value: unlabeledDivisions },\n children,\n ),\n );\n}\n\nfunction TrackedLabeledUnit({\n division,\n nameForDivision = defaultNameFunction,\n ...rest\n}) {\n const trackLabelVisibility = useContext(LabelTrackerContext);\n return h(LabeledUnit, {\n division,\n label: nameForDivision(division),\n onLabelUpdated(label, visible) {\n // If there is al LabelTrackerContext, update the label visibility\n trackLabelVisibility?.(division, visible);\n },\n ...rest,\n });\n}\n\nexport const CompositeUnitComponent = TrackedLabeledUnit;\n\ntype BaseUnitProps = {\n width: number;\n showLabels?: boolean;\n columnWidth?: number;\n clipToFrame?: boolean;\n};\n\ntype ICompositeUnitProps = BaseUnitProps & {\n gutterWidth?: number;\n labelOffset?: number;\n paddingLeft?: number;\n nameForDivision?: (division: BaseUnit) => string;\n children?: React.ReactNode;\n unitComponent?: React.FC<any>;\n unitComponentProps?: any;\n noteMode?: \"labeled\" | \"unlabeled\";\n showLabelColumn?: boolean;\n noteComponent?: React.FC<any>;\n shouldRenderNote?: (d: any) => boolean;\n};\n\ninterface CompositeUnitProps {\n unitComponent: React.FC<any>;\n unitComponentProps?: any;\n width: number;\n showLabels?: boolean;\n clipToFrame?: boolean;\n}\n\nexport function CompositeUnitsColumn(props: CompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const {\n width,\n unitComponent = TrackedLabeledUnit,\n unitComponentProps,\n clipToFrame,\n ...rest\n } = props;\n\n return h(LithologyColumn, { width, clipToFrame }, [\n h(UnitBoxes, {\n unitComponent,\n unitComponentProps,\n ...rest,\n }),\n ]);\n}\n\nexport function AnnotatedUnitsColumn(props: ICompositeUnitProps) {\n useEffect(() => {\n console.warn(\n \"AnnotatedUnitsColumn is deprecated and currently renders a no-op for transition purposes\",\n );\n }, []);\n return null;\n}\n\nexport function SectionLabelsColumn(props: ICompositeUnitProps) {\n // Section with \"squishy\" time scale\n const {\n width = 300,\n noteMode = \"unlabeled\",\n labelOffset = 30,\n noteComponent,\n shouldRenderNote,\n } = props;\n\n const { totalHeight, axisType } = useMacrostratColumnData();\n const _compositeScale = useCompositeScale();\n\n const unlabeledUnits = useContext(UnlabeledDivisionsContext);\n const unitsToLabel = noteMode == \"unlabeled\" ? unlabeledUnits : undefined;\n\n const selectUnit = useUnitSelectionDispatch();\n\n return h(\"div.section-labels-column\", [\n h(\n ColumnNotesProvider,\n {\n units: [],\n scale: _compositeScale,\n totalHeight,\n axisType,\n },\n h(\n SVG,\n {\n height: totalHeight,\n innerWidth: width - 4,\n paddingH: 1,\n paddingLeft: 3,\n },\n h(UnitNamesColumn, {\n divisions: unitsToLabel,\n paddingLeft: labelOffset,\n width,\n noteComponent,\n shouldRenderNote,\n scale: _compositeScale,\n onClickNote(note) {\n selectUnit(note.data, null, null);\n },\n }),\n ),\n ),\n ]);\n}\n\nexport function ColumnNotesProvider(props) {\n // A fake column axis provider that allows scales to cross\n const { children, scale, totalHeight, pixelScale } = props;\n\n const { axisType } = useMacrostratColumnData();\n\n return h(\n ColumnContext.Provider,\n {\n value: {\n divisions: [],\n scale,\n scaleClamped: scale,\n pixelHeight: totalHeight,\n pixelsPerMeter: pixelScale,\n axisType,\n zoom: 1,\n },\n },\n children,\n );\n}\n\nexport { TrackedLabeledUnit, ICompositeUnitProps };\n"],"names":["hyperStyled","styles","createContext","useState","useRef","useCallback","id","defaultNameFunction","useContext","LabeledUnit","LithologyColumn","UnitBoxes","useEffect","useMacrostratColumnData","useCompositeScale","useUnitSelectionDispatch","SVG","UnitNamesColumn","ColumnContext"],"mappings":";;;;;;;;;;AAwBA,MAAM,IAAIA,IAAAA,YAAYC,gBAAM;AAM5B,MAAM,sBAAsBC,MAAAA,cAAc,IAAI;AAC9C,MAAM,4BAA4BA,MAAAA,cAAc,IAAI;AAEpD,MAAM,uBAAuB,CAAC,MAAM,EAAE;AAE/B,SAAS,qBAAqB,OAAO;AAI1C,QAAM,EAAE,UAAU,OAAO,aAAa,yBAAyB;AAC/D,QAAM,CAAC,oBAAoB,qBAAqB,IAAIC,MAAAA,SAElD,IAAI;AACN,QAAM,kBAAkBC,MAAAA,OAAqB,EAAE;AAC/C,QAAM,uBAAuBC,MAAAA;AAAAA,IAC3B,CAAC,KAAK,YAAY;AAChB,YAAM,KAAK,WAAW,GAAG;AACzB,sBAAgB,QAAQ,EAAE,IAAI;AAC9B,UAAI,OAAO,KAAK,gBAAgB,OAAO,EAAE,UAAU,MAAM,QAAQ;AAC/D;AAAA;AAAA,UAEE,MAAM,OAAO,CAAC,MAAM;AAClB,kBAAMC,MAAK,WAAW,CAAC;AACvB,mBAAO,gBAAgB,QAAQA,GAAE,KAAK;AAAA,UACxC,CAAC;AAAA,QAAA;AAAA,MAEL;AAAA,IACF;AAAA,IACA,CAAC,iBAAiB,OAAO,UAA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3D,QAAM,eAAe,YAAY,cAAc,iBAAiB;AAEhE,QAAM,aAAaO,cAAAA,yBAAA;AAEnB,SAAO,EAAE,6BAA6B;AAAA,IACpC;AAAA,MACE;AAAA,MACA;AAAA,QACE,OAAO,CAAA;AAAA,QACP,OAAO;AAAA,QACP;AAAA,QACA;AAAA,MAAA;AAAA,MAEF;AAAA,QACEC,iBAAAA;AAAAA,QACA;AAAA,UACE,QAAQ;AAAA,UACR,YAAY,QAAQ;AAAA,UACpB,UAAU;AAAA,UACV,aAAa;AAAA,QAAA;AAAA,QAEf,EAAEC,MAAAA,iBAAiB;AAAA,UACjB,WAAW;AAAA,UACX,aAAa;AAAA,UACb;AAAA,UACA;AAAA,UACA;AAAA,UACA,OAAO;AAAA,UACP,YAAY,MAAM;AAChB,uBAAW,KAAK,MAAM,MAAM,IAAI;AAAA,UAClC;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IACH;AAAA,EACF,CACD;AACH;AAEO,SAAS,oBAAoB,OAAO;AAEzC,QAAM,EAAE,UAAU,OAAO,aAAa,eAAe;AAErD,QAAM,EAAE,SAAA,IAAaJ,8BAAA;AAErB,SAAO;AAAA,IACLK,iBAAAA,cAAc;AAAA,IACd;AAAA,MACE,OAAO;AAAA,QACL,WAAW,CAAA;AAAA,QACX;AAAA,QACA,cAAc;AAAA,QACd,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB;AAAA,QACA,MAAM;AAAA,MAAA;AAAA,IACR;AAAA,IAEF;AAAA,EAAA;AAEJ;;;;;;;;"}
1
+ {"version":3,"file":"composite.cjs","sources":["../../src/units/composite.ts"],"sourcesContent":["import { hyperStyled } from \"@macrostrat/hyper\";\nimport {\n ColumnContext,\n LithologyColumn,\n SVG,\n} from \"@macrostrat/column-components\";\nimport { defaultNameFunction, UnitNamesColumn } from \"./names\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { LabeledUnit, UnitBoxes } from \"./boxes\";\nimport styles from \"./composite.module.sass\";\nimport {\n useCompositeScale,\n useMacrostratColumnData,\n useUnitSelectionDispatch,\n} from \"../data-provider\";\n\nconst h = hyperStyled(styles);\n\ninterface LabelTracker {\n [key: number]: boolean;\n}\n\nconst LabelTrackerContext = createContext(null);\nconst UnlabeledDivisionsContext = createContext(null);\n\nconst findMacrostratUnitID = (u) => u.unit_id;\n\nexport function LabelTrackerProvider(props) {\n /** Tracker for units to handle state for whether their labels fit inline or not.\n * Designed to work for single or composite columns.\n */\n const { children, units, findUnitID = findMacrostratUnitID } = props;\n const [unlabeledDivisions, setUnlabeledDivisions] = useState<\n BaseUnit[] | null\n >(null);\n const labelTrackerRef = useRef<LabelTracker>({});\n\n const recompute = useCallback(() => {\n // Recompute over the *current* unit set (which changes as the column zooms).\n // The tracker ref accumulates entries for units seen at any zoom level, so\n // we gate on whether every currently-visible unit has reported — not on the\n // total number of tracked units, which would go stale and freeze the notes.\n const tracker = labelTrackerRef.current;\n const allReported = units.every((d) => findUnitID(d) in tracker);\n if (!allReported) return;\n setUnlabeledDivisions(units.filter((d) => tracker[findUnitID(d)] === false));\n }, [units, findUnitID]);\n\n const trackLabelVisibility = useCallback(\n (div, visible) => {\n labelTrackerRef.current[findUnitID(div)] = visible;\n recompute();\n },\n [recompute, findUnitID],\n );\n\n // Re-sync when the visible unit set changes (e.g. on zoom), so a unit whose\n // label now fits inline stops also rendering as a note, and vice versa.\n useEffect(() => {\n recompute();\n }, [recompute]);\n\n const value = trackLabelVisibility;\n return h(\n LabelTrackerContext.Provider,\n { value },\n h(\n UnlabeledDivisionsContext.Provider,\n { value: unlabeledDivisions },\n children,\n ),\n );\n}\n\nfunction TrackedLabeledUnit({\n division,\n nameForDivision = defaultNameFunction,\n ...rest\n}) {\n const trackLabelVisibility = useContext(LabelTrackerContext);\n return h(LabeledUnit, {\n division,\n label: nameForDivision(division),\n onLabelUpdated(label, visible) {\n // If there is al LabelTrackerContext, update the label visibility\n trackLabelVisibility?.(division, visible);\n },\n ...rest,\n });\n}\n\nexport const CompositeUnitComponent = TrackedLabeledUnit;\n\ntype BaseUnitProps = {\n width: number;\n showLabels?: boolean;\n columnWidth?: number;\n clipToFrame?: boolean;\n};\n\ntype ICompositeUnitProps = BaseUnitProps & {\n gutterWidth?: number;\n labelOffset?: number;\n paddingLeft?: number;\n nameForDivision?: (division: BaseUnit) => string;\n children?: React.ReactNode;\n unitComponent?: React.FC<any>;\n unitComponentProps?: any;\n noteMode?: \"labeled\" | \"unlabeled\";\n showLabelColumn?: boolean;\n noteComponent?: React.FC<any>;\n shouldRenderNote?: (d: any) => boolean;\n};\n\ninterface CompositeUnitProps {\n unitComponent: React.FC<any>;\n unitComponentProps?: any;\n width: number;\n showLabels?: boolean;\n clipToFrame?: boolean;\n}\n\nexport function CompositeUnitsColumn(props: CompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const {\n width,\n unitComponent = TrackedLabeledUnit,\n unitComponentProps,\n clipToFrame,\n ...rest\n } = props;\n\n return h(LithologyColumn, { width, clipToFrame }, [\n h(UnitBoxes, {\n unitComponent,\n unitComponentProps,\n ...rest,\n }),\n ]);\n}\n\nexport function AnnotatedUnitsColumn(props: ICompositeUnitProps) {\n useEffect(() => {\n console.warn(\n \"AnnotatedUnitsColumn is deprecated and currently renders a no-op for transition purposes\",\n );\n }, []);\n return null;\n}\n\nexport function SectionLabelsColumn(props: ICompositeUnitProps) {\n // Section with \"squishy\" time scale\n const {\n width = 300,\n noteMode = \"unlabeled\",\n labelOffset = 30,\n noteComponent,\n shouldRenderNote,\n } = props;\n\n const { totalHeight, axisType } = useMacrostratColumnData();\n const _compositeScale = useCompositeScale();\n\n const unlabeledUnits = useContext(UnlabeledDivisionsContext);\n const unitsToLabel = noteMode == \"unlabeled\" ? unlabeledUnits : undefined;\n\n const selectUnit = useUnitSelectionDispatch();\n\n return h(\"div.section-labels-column\", [\n h(\n ColumnNotesProvider,\n {\n units: [],\n scale: _compositeScale,\n totalHeight,\n axisType,\n },\n h(\n SVG,\n {\n height: totalHeight,\n innerWidth: width - 4,\n paddingH: 1,\n paddingLeft: 3,\n },\n h(UnitNamesColumn, {\n divisions: unitsToLabel,\n paddingLeft: labelOffset,\n width,\n noteComponent,\n shouldRenderNote,\n scale: _compositeScale,\n onClickNote(note) {\n selectUnit(note.data, null, null);\n },\n }),\n ),\n ),\n ]);\n}\n\nexport function ColumnNotesProvider(props) {\n // A fake column axis provider that allows scales to cross\n const { children, scale, totalHeight, pixelScale } = props;\n\n const { axisType } = useMacrostratColumnData();\n\n return h(\n ColumnContext.Provider,\n {\n value: {\n divisions: [],\n scale,\n scaleClamped: scale,\n pixelHeight: totalHeight,\n pixelsPerMeter: pixelScale,\n axisType,\n zoom: 1,\n },\n },\n children,\n );\n}\n\nexport { TrackedLabeledUnit, ICompositeUnitProps };\n"],"names":["hyperStyled","styles","createContext","useState","useRef","useCallback","useEffect","defaultNameFunction","useContext","LabeledUnit","LithologyColumn","UnitBoxes","useMacrostratColumnData","useCompositeScale","useUnitSelectionDispatch","SVG","UnitNamesColumn","ColumnContext"],"mappings":";;;;;;;;;;AAwBA,MAAM,IAAIA,IAAAA,YAAYC,gBAAM;AAM5B,MAAM,sBAAsBC,MAAAA,cAAc,IAAI;AAC9C,MAAM,4BAA4BA,MAAAA,cAAc,IAAI;AAEpD,MAAM,uBAAuB,CAAC,MAAM,EAAE;AAE/B,SAAS,qBAAqB,OAAO;AAI1C,QAAM,EAAE,UAAU,OAAO,aAAa,yBAAyB;AAC/D,QAAM,CAAC,oBAAoB,qBAAqB,IAAIC,MAAAA,SAElD,IAAI;AACN,QAAM,kBAAkBC,MAAAA,OAAqB,EAAE;AAE/C,QAAM,YAAYC,MAAAA,YAAY,MAAM;AAKlC,UAAM,UAAU,gBAAgB;AAChC,UAAM,cAAc,MAAM,MAAM,CAAC,MAAM,WAAW,CAAC,KAAK,OAAO;AAC/D,QAAI,CAAC,YAAa;AAClB,0BAAsB,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AAA;AAAA,IACR;AAAA,IAEF;AAAA,EAAA;AAEJ;;;;;;;;"}
@@ -14,22 +14,22 @@ function LabelTrackerProvider(props) {
14
14
  const { children, units, findUnitID = findMacrostratUnitID } = props;
15
15
  const [unlabeledDivisions, setUnlabeledDivisions] = useState(null);
16
16
  const labelTrackerRef = useRef({});
17
+ const recompute = useCallback(() => {
18
+ const tracker = labelTrackerRef.current;
19
+ const allReported = units.every((d) => findUnitID(d) in tracker);
20
+ if (!allReported) return;
21
+ setUnlabeledDivisions(units.filter((d) => tracker[findUnitID(d)] === false));
22
+ }, [units, findUnitID]);
17
23
  const trackLabelVisibility = useCallback(
18
24
  (div, visible) => {
19
- const id = findUnitID(div);
20
- labelTrackerRef.current[id] = visible;
21
- if (Object.keys(labelTrackerRef.current).length == units.length) {
22
- setUnlabeledDivisions(
23
- // @ts-ignore
24
- units.filter((d) => {
25
- const id2 = findUnitID(d);
26
- return labelTrackerRef.current[id2] == false;
27
- })
28
- );
29
- }
25
+ labelTrackerRef.current[findUnitID(div)] = visible;
26
+ recompute();
30
27
  },
31
- [labelTrackerRef, units, findUnitID]
28
+ [recompute, findUnitID]
32
29
  );
30
+ useEffect(() => {
31
+ recompute();
32
+ }, [recompute]);
33
33
  const value = trackLabelVisibility;
34
34
  return h(
35
35
  LabelTrackerContext.Provider,
@@ -1 +1 @@
1
- {"version":3,"file":"composite.js","sources":["../../src/units/composite.ts"],"sourcesContent":["import { hyperStyled } from \"@macrostrat/hyper\";\nimport {\n ColumnContext,\n LithologyColumn,\n SVG,\n} from \"@macrostrat/column-components\";\nimport { defaultNameFunction, UnitNamesColumn } from \"./names\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { LabeledUnit, UnitBoxes } from \"./boxes\";\nimport styles from \"./composite.module.sass\";\nimport {\n useCompositeScale,\n useMacrostratColumnData,\n useUnitSelectionDispatch,\n} from \"../data-provider\";\n\nconst h = hyperStyled(styles);\n\ninterface LabelTracker {\n [key: number]: boolean;\n}\n\nconst LabelTrackerContext = createContext(null);\nconst UnlabeledDivisionsContext = createContext(null);\n\nconst findMacrostratUnitID = (u) => u.unit_id;\n\nexport function LabelTrackerProvider(props) {\n /** Tracker for units to handle state for whether their labels fit inline or not.\n * Designed to work for single or composite columns.\n */\n const { children, units, findUnitID = findMacrostratUnitID } = props;\n const [unlabeledDivisions, setUnlabeledDivisions] = useState<\n BaseUnit[] | null\n >(null);\n const labelTrackerRef = useRef<LabelTracker>({});\n const trackLabelVisibility = useCallback(\n (div, visible) => {\n const id = findUnitID(div);\n labelTrackerRef.current[id] = visible;\n if (Object.keys(labelTrackerRef.current).length == units.length) {\n setUnlabeledDivisions(\n // @ts-ignore\n units.filter((d) => {\n const id = findUnitID(d);\n return labelTrackerRef.current[id] == false;\n }),\n );\n }\n },\n [labelTrackerRef, units, findUnitID],\n );\n\n const value = trackLabelVisibility;\n return h(\n LabelTrackerContext.Provider,\n { value },\n h(\n UnlabeledDivisionsContext.Provider,\n { value: unlabeledDivisions },\n children,\n ),\n );\n}\n\nfunction TrackedLabeledUnit({\n division,\n nameForDivision = defaultNameFunction,\n ...rest\n}) {\n const trackLabelVisibility = useContext(LabelTrackerContext);\n return h(LabeledUnit, {\n division,\n label: nameForDivision(division),\n onLabelUpdated(label, visible) {\n // If there is al LabelTrackerContext, update the label visibility\n trackLabelVisibility?.(division, visible);\n },\n ...rest,\n });\n}\n\nexport const CompositeUnitComponent = TrackedLabeledUnit;\n\ntype BaseUnitProps = {\n width: number;\n showLabels?: boolean;\n columnWidth?: number;\n clipToFrame?: boolean;\n};\n\ntype ICompositeUnitProps = BaseUnitProps & {\n gutterWidth?: number;\n labelOffset?: number;\n paddingLeft?: number;\n nameForDivision?: (division: BaseUnit) => string;\n children?: React.ReactNode;\n unitComponent?: React.FC<any>;\n unitComponentProps?: any;\n noteMode?: \"labeled\" | \"unlabeled\";\n showLabelColumn?: boolean;\n noteComponent?: React.FC<any>;\n shouldRenderNote?: (d: any) => boolean;\n};\n\ninterface CompositeUnitProps {\n unitComponent: React.FC<any>;\n unitComponentProps?: any;\n width: number;\n showLabels?: boolean;\n clipToFrame?: boolean;\n}\n\nexport function CompositeUnitsColumn(props: CompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const {\n width,\n unitComponent = TrackedLabeledUnit,\n unitComponentProps,\n clipToFrame,\n ...rest\n } = props;\n\n return h(LithologyColumn, { width, clipToFrame }, [\n h(UnitBoxes, {\n unitComponent,\n unitComponentProps,\n ...rest,\n }),\n ]);\n}\n\nexport function AnnotatedUnitsColumn(props: ICompositeUnitProps) {\n useEffect(() => {\n console.warn(\n \"AnnotatedUnitsColumn is deprecated and currently renders a no-op for transition purposes\",\n );\n }, []);\n return null;\n}\n\nexport function SectionLabelsColumn(props: ICompositeUnitProps) {\n // Section with \"squishy\" time scale\n const {\n width = 300,\n noteMode = \"unlabeled\",\n labelOffset = 30,\n noteComponent,\n shouldRenderNote,\n } = props;\n\n const { totalHeight, axisType } = useMacrostratColumnData();\n const _compositeScale = useCompositeScale();\n\n const unlabeledUnits = useContext(UnlabeledDivisionsContext);\n const unitsToLabel = noteMode == \"unlabeled\" ? unlabeledUnits : undefined;\n\n const selectUnit = useUnitSelectionDispatch();\n\n return h(\"div.section-labels-column\", [\n h(\n ColumnNotesProvider,\n {\n units: [],\n scale: _compositeScale,\n totalHeight,\n axisType,\n },\n h(\n SVG,\n {\n height: totalHeight,\n innerWidth: width - 4,\n paddingH: 1,\n paddingLeft: 3,\n },\n h(UnitNamesColumn, {\n divisions: unitsToLabel,\n paddingLeft: labelOffset,\n width,\n noteComponent,\n shouldRenderNote,\n scale: _compositeScale,\n onClickNote(note) {\n selectUnit(note.data, null, null);\n },\n }),\n ),\n ),\n ]);\n}\n\nexport function ColumnNotesProvider(props) {\n // A fake column axis provider that allows scales to cross\n const { children, scale, totalHeight, pixelScale } = props;\n\n const { axisType } = useMacrostratColumnData();\n\n return h(\n ColumnContext.Provider,\n {\n value: {\n divisions: [],\n scale,\n scaleClamped: scale,\n pixelHeight: totalHeight,\n pixelsPerMeter: pixelScale,\n axisType,\n zoom: 1,\n },\n },\n children,\n );\n}\n\nexport { TrackedLabeledUnit, ICompositeUnitProps };\n"],"names":["styles","id"],"mappings":";;;;;;;;AAwBA,MAAM,IAAI,YAAYA,GAAM;AAM5B,MAAM,sBAAsB,cAAc,IAAI;AAC9C,MAAM,4BAA4B,cAAc,IAAI;AAEpD,MAAM,uBAAuB,CAAC,MAAM,EAAE;AAE/B,SAAS,qBAAqB,OAAO;AAI1C,QAAM,EAAE,UAAU,OAAO,aAAa,yBAAyB;AAC/D,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAElD,IAAI;AACN,QAAM,kBAAkB,OAAqB,EAAE;AAC/C,QAAM,uBAAuB;AAAA,IAC3B,CAAC,KAAK,YAAY;AAChB,YAAM,KAAK,WAAW,GAAG;AACzB,sBAAgB,QAAQ,EAAE,IAAI;AAC9B,UAAI,OAAO,KAAK,gBAAgB,OAAO,EAAE,UAAU,MAAM,QAAQ;AAC/D;AAAA;AAAA,UAEE,MAAM,OAAO,CAAC,MAAM;AAClB,kBAAMC,MAAK,WAAW,CAAC;AACvB,mBAAO,gBAAgB,QAAQA,GAAE,KAAK;AAAA,UACxC,CAAC;AAAA,QAAA;AAAA,MAEL;AAAA,IACF;AAAA,IACA,CAAC,iBAAiB,OAAO,UAAU;AAAA,EAAA;AAGrC,QAAM,QAAQ;AACd,SAAO;AAAA,IACL,oBAAoB;AAAA,IACpB,EAAE,MAAA;AAAA,IACF;AAAA,MACE,0BAA0B;AAAA,MAC1B,EAAE,OAAO,mBAAA;AAAA,MACT;AAAA,IAAA;AAAA,EACF;AAEJ;AAEA,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA,kBAAkB;AAAA,EAClB,GAAG;AACL,GAAG;AACD,QAAM,uBAAuB,WAAW,mBAAmB;AAC3D,SAAO,EAAE,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UACA;AAAA,UACA;AAAA,UACA,OAAO;AAAA,UACP,YAAY,MAAM;AAChB,uBAAW,KAAK,MAAM,MAAM,IAAI;AAAA,UAClC;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IACH;AAAA,EACF,CACD;AACH;AAEO,SAAS,oBAAoB,OAAO;AAEzC,QAAM,EAAE,UAAU,OAAO,aAAa,eAAe;AAErD,QAAM,EAAE,SAAA,IAAa,wBAAA;AAErB,SAAO;AAAA,IACL,cAAc;AAAA,IACd;AAAA,MACE,OAAO;AAAA,QACL,WAAW,CAAA;AAAA,QACX;AAAA,QACA,cAAc;AAAA,QACd,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB;AAAA,QACA,MAAM;AAAA,MAAA;AAAA,IACR;AAAA,IAEF;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"composite.js","sources":["../../src/units/composite.ts"],"sourcesContent":["import { hyperStyled } from \"@macrostrat/hyper\";\nimport {\n ColumnContext,\n LithologyColumn,\n SVG,\n} from \"@macrostrat/column-components\";\nimport { defaultNameFunction, UnitNamesColumn } from \"./names\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { LabeledUnit, UnitBoxes } from \"./boxes\";\nimport styles from \"./composite.module.sass\";\nimport {\n useCompositeScale,\n useMacrostratColumnData,\n useUnitSelectionDispatch,\n} from \"../data-provider\";\n\nconst h = hyperStyled(styles);\n\ninterface LabelTracker {\n [key: number]: boolean;\n}\n\nconst LabelTrackerContext = createContext(null);\nconst UnlabeledDivisionsContext = createContext(null);\n\nconst findMacrostratUnitID = (u) => u.unit_id;\n\nexport function LabelTrackerProvider(props) {\n /** Tracker for units to handle state for whether their labels fit inline or not.\n * Designed to work for single or composite columns.\n */\n const { children, units, findUnitID = findMacrostratUnitID } = props;\n const [unlabeledDivisions, setUnlabeledDivisions] = useState<\n BaseUnit[] | null\n >(null);\n const labelTrackerRef = useRef<LabelTracker>({});\n\n const recompute = useCallback(() => {\n // Recompute over the *current* unit set (which changes as the column zooms).\n // The tracker ref accumulates entries for units seen at any zoom level, so\n // we gate on whether every currently-visible unit has reported — not on the\n // total number of tracked units, which would go stale and freeze the notes.\n const tracker = labelTrackerRef.current;\n const allReported = units.every((d) => findUnitID(d) in tracker);\n if (!allReported) return;\n setUnlabeledDivisions(units.filter((d) => tracker[findUnitID(d)] === false));\n }, [units, findUnitID]);\n\n const trackLabelVisibility = useCallback(\n (div, visible) => {\n labelTrackerRef.current[findUnitID(div)] = visible;\n recompute();\n },\n [recompute, findUnitID],\n );\n\n // Re-sync when the visible unit set changes (e.g. on zoom), so a unit whose\n // label now fits inline stops also rendering as a note, and vice versa.\n useEffect(() => {\n recompute();\n }, [recompute]);\n\n const value = trackLabelVisibility;\n return h(\n LabelTrackerContext.Provider,\n { value },\n h(\n UnlabeledDivisionsContext.Provider,\n { value: unlabeledDivisions },\n children,\n ),\n );\n}\n\nfunction TrackedLabeledUnit({\n division,\n nameForDivision = defaultNameFunction,\n ...rest\n}) {\n const trackLabelVisibility = useContext(LabelTrackerContext);\n return h(LabeledUnit, {\n division,\n label: nameForDivision(division),\n onLabelUpdated(label, visible) {\n // If there is al LabelTrackerContext, update the label visibility\n trackLabelVisibility?.(division, visible);\n },\n ...rest,\n });\n}\n\nexport const CompositeUnitComponent = TrackedLabeledUnit;\n\ntype BaseUnitProps = {\n width: number;\n showLabels?: boolean;\n columnWidth?: number;\n clipToFrame?: boolean;\n};\n\ntype ICompositeUnitProps = BaseUnitProps & {\n gutterWidth?: number;\n labelOffset?: number;\n paddingLeft?: number;\n nameForDivision?: (division: BaseUnit) => string;\n children?: React.ReactNode;\n unitComponent?: React.FC<any>;\n unitComponentProps?: any;\n noteMode?: \"labeled\" | \"unlabeled\";\n showLabelColumn?: boolean;\n noteComponent?: React.FC<any>;\n shouldRenderNote?: (d: any) => boolean;\n};\n\ninterface CompositeUnitProps {\n unitComponent: React.FC<any>;\n unitComponentProps?: any;\n width: number;\n showLabels?: boolean;\n clipToFrame?: boolean;\n}\n\nexport function CompositeUnitsColumn(props: CompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const {\n width,\n unitComponent = TrackedLabeledUnit,\n unitComponentProps,\n clipToFrame,\n ...rest\n } = props;\n\n return h(LithologyColumn, { width, clipToFrame }, [\n h(UnitBoxes, {\n unitComponent,\n unitComponentProps,\n ...rest,\n }),\n ]);\n}\n\nexport function AnnotatedUnitsColumn(props: ICompositeUnitProps) {\n useEffect(() => {\n console.warn(\n \"AnnotatedUnitsColumn is deprecated and currently renders a no-op for transition purposes\",\n );\n }, []);\n return null;\n}\n\nexport function SectionLabelsColumn(props: ICompositeUnitProps) {\n // Section with \"squishy\" time scale\n const {\n width = 300,\n noteMode = \"unlabeled\",\n labelOffset = 30,\n noteComponent,\n shouldRenderNote,\n } = props;\n\n const { totalHeight, axisType } = useMacrostratColumnData();\n const _compositeScale = useCompositeScale();\n\n const unlabeledUnits = useContext(UnlabeledDivisionsContext);\n const unitsToLabel = noteMode == \"unlabeled\" ? unlabeledUnits : undefined;\n\n const selectUnit = useUnitSelectionDispatch();\n\n return h(\"div.section-labels-column\", [\n h(\n ColumnNotesProvider,\n {\n units: [],\n scale: _compositeScale,\n totalHeight,\n axisType,\n },\n h(\n SVG,\n {\n height: totalHeight,\n innerWidth: width - 4,\n paddingH: 1,\n paddingLeft: 3,\n },\n h(UnitNamesColumn, {\n divisions: unitsToLabel,\n paddingLeft: labelOffset,\n width,\n noteComponent,\n shouldRenderNote,\n scale: _compositeScale,\n onClickNote(note) {\n selectUnit(note.data, null, null);\n },\n }),\n ),\n ),\n ]);\n}\n\nexport function ColumnNotesProvider(props) {\n // A fake column axis provider that allows scales to cross\n const { children, scale, totalHeight, pixelScale } = props;\n\n const { axisType } = useMacrostratColumnData();\n\n return h(\n ColumnContext.Provider,\n {\n value: {\n divisions: [],\n scale,\n scaleClamped: scale,\n pixelHeight: totalHeight,\n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;AAAA,UACA;AAAA,UACA;AAAA,UACA,OAAO;AAAA,UACP,YAAY,MAAM;AAChB,uBAAW,KAAK,MAAM,MAAM,IAAI;AAAA,UAClC;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IACH;AAAA,EACF,CACD;AACH;AAEO,SAAS,oBAAoB,OAAO;AAEzC,QAAM,EAAE,UAAU,OAAO,aAAa,eAAe;AAErD,QAAM,EAAE,SAAA,IAAa,wBAAA;AAErB,SAAO;AAAA,IACL,cAAc;AAAA,IACd;AAAA,MACE,OAAO;AAAA,QACL,WAAW,CAAA;AAAA,QACX;AAAA,QACA,cAAc;AAAA,QACd,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB;AAAA,QACA,MAAM;AAAA,MAAA;AAAA,IACR;AAAA,IAEF;AAAA,EAAA;AAEJ;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macrostrat/column-views",
3
- "version": "3.6.1",
3
+ "version": "3.9.0",
4
4
  "description": "Data views for Macrostrat stratigraphic columns",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,19 +48,19 @@
48
48
  "@blueprintjs/core": "^6.14.0",
49
49
  "@macrostrat/api-types": "^1.2.0",
50
50
  "@macrostrat/color-utils": "^1.2.2",
51
- "@macrostrat/column-components": "^2.0.9",
52
- "@macrostrat/data-components": "^1.4.0",
53
- "@macrostrat/data-provider": "^1.1.0",
51
+ "@macrostrat/column-components": "^2.1.0",
52
+ "@macrostrat/data-components": "^1.5.1",
53
+ "@macrostrat/data-provider": "^1.2.0",
54
54
  "@macrostrat/hyper": "^3.1.1",
55
- "@macrostrat/map-interface": "^2.3.0",
56
- "@macrostrat/map-styles": "^2.2.6",
57
- "@macrostrat/mapbox-react": "^3.3.1",
55
+ "@macrostrat/map-interface": "^2.3.1",
56
+ "@macrostrat/map-styles": "^2.2.7",
57
+ "@macrostrat/mapbox-react": "^3.3.3",
58
58
  "@macrostrat/mapbox-utils": "^1.8.0",
59
59
  "@macrostrat/scoped-store": "^1.0.1",
60
60
  "@macrostrat/stratigraphy-utils": "^1.3.0",
61
61
  "@macrostrat/svg-map-components": "^2.0.3",
62
- "@macrostrat/timescale": "^3.1.5",
63
- "@macrostrat/ui-components": "^5.1.0",
62
+ "@macrostrat/timescale": "^3.2.0",
63
+ "@macrostrat/ui-components": "^5.2.0",
64
64
  "@turf/boolean-point-in-polygon": "^7.3.2",
65
65
  "@turf/buffer": "^7.3.2",
66
66
  "@turf/centroid": "^7.3.2",