@macrostrat/column-views 3.6.0 → 3.8.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 (107) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/column-views.css +118 -89
  3. package/dist/column.cjs +1 -2
  4. package/dist/column.cjs.map +1 -1
  5. package/dist/column.js +1 -2
  6. package/dist/column.js.map +1 -1
  7. package/dist/column.module.sass.cjs +15 -15
  8. package/dist/column.module.sass.js +15 -15
  9. package/dist/correlation-chart/main.cjs +136 -34
  10. package/dist/correlation-chart/main.cjs.map +1 -1
  11. package/dist/correlation-chart/main.d.ts +33 -2
  12. package/dist/correlation-chart/main.js +118 -15
  13. package/dist/correlation-chart/main.js.map +1 -1
  14. package/dist/correlation-chart/main.module.sass.cjs +23 -20
  15. package/dist/correlation-chart/main.module.sass.cjs.map +1 -1
  16. package/dist/correlation-chart/main.module.sass.js +23 -20
  17. package/dist/correlation-chart/main.module.sass.js.map +1 -1
  18. package/dist/correlation-chart/prepare-data.cjs +0 -1
  19. package/dist/correlation-chart/prepare-data.cjs.map +1 -1
  20. package/dist/correlation-chart/prepare-data.js +0 -1
  21. package/dist/correlation-chart/prepare-data.js.map +1 -1
  22. package/dist/data-provider/store.cjs +10 -2
  23. package/dist/data-provider/store.cjs.map +1 -1
  24. package/dist/data-provider/store.d.ts +2 -2
  25. package/dist/data-provider/store.js +10 -2
  26. package/dist/data-provider/store.js.map +1 -1
  27. package/dist/data-provider/unit-selection.cjs +4 -1
  28. package/dist/data-provider/unit-selection.cjs.map +1 -1
  29. package/dist/data-provider/unit-selection.d.ts +1 -1
  30. package/dist/data-provider/unit-selection.js +4 -1
  31. package/dist/data-provider/unit-selection.js.map +1 -1
  32. package/dist/index.cjs +14 -4
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.js +3 -2
  35. package/dist/maps/column-correlation/core.cjs +127 -6
  36. package/dist/maps/column-correlation/core.cjs.map +1 -1
  37. package/dist/maps/column-correlation/core.js +128 -7
  38. package/dist/maps/column-correlation/core.js.map +1 -1
  39. package/dist/maps/column-correlation/state.cjs +63 -2
  40. package/dist/maps/column-correlation/state.cjs.map +1 -1
  41. package/dist/maps/column-correlation/state.d.ts +31 -1
  42. package/dist/maps/column-correlation/state.js +63 -2
  43. package/dist/maps/column-correlation/state.js.map +1 -1
  44. package/dist/maps/layers/columns.cjs +5 -1
  45. package/dist/maps/layers/columns.cjs.map +1 -1
  46. package/dist/maps/layers/columns.js +5 -1
  47. package/dist/maps/layers/columns.js.map +1 -1
  48. package/dist/prepare-units/helpers.cjs +4 -2
  49. package/dist/prepare-units/helpers.cjs.map +1 -1
  50. package/dist/prepare-units/helpers.js +4 -2
  51. package/dist/prepare-units/helpers.js.map +1 -1
  52. package/dist/section.cjs +8 -2
  53. package/dist/section.cjs.map +1 -1
  54. package/dist/section.d.ts +2 -0
  55. package/dist/section.js +8 -2
  56. package/dist/section.js.map +1 -1
  57. package/dist/unit-details/age-range.cjs +2 -1
  58. package/dist/unit-details/age-range.cjs.map +1 -1
  59. package/dist/unit-details/age-range.js +2 -1
  60. package/dist/unit-details/age-range.js.map +1 -1
  61. package/dist/unit-details/index.d.ts +1 -1
  62. package/dist/unit-details/panel.cjs +2 -3
  63. package/dist/unit-details/panel.cjs.map +1 -1
  64. package/dist/unit-details/panel.js +1 -2
  65. package/dist/unit-details/panel.js.map +1 -1
  66. package/dist/unit-details/panel.module.sass.cjs +18 -22
  67. package/dist/unit-details/panel.module.sass.cjs.map +1 -1
  68. package/dist/unit-details/panel.module.sass.js +18 -22
  69. package/dist/unit-details/panel.module.sass.js.map +1 -1
  70. package/dist/unit-details/strat-names.cjs +1 -2
  71. package/dist/unit-details/strat-names.cjs.map +1 -1
  72. package/dist/unit-details/strat-names.js +1 -2
  73. package/dist/unit-details/strat-names.js.map +1 -1
  74. package/dist/units/boxes.cjs +2 -1
  75. package/dist/units/boxes.cjs.map +1 -1
  76. package/dist/units/boxes.js +2 -1
  77. package/dist/units/boxes.js.map +1 -1
  78. package/package.json +7 -7
  79. package/src/column.module.sass +6 -0
  80. package/src/correlation-chart/main.module.sass +46 -2
  81. package/src/correlation-chart/main.ts +180 -9
  82. package/src/correlation-chart/prepare-data.ts +0 -1
  83. package/src/data-provider/store.ts +11 -1
  84. package/src/data-provider/unit-selection.ts +13 -2
  85. package/src/maps/column-correlation/column-correlation-map.stories.ts +12 -0
  86. package/src/maps/column-correlation/core.ts +155 -9
  87. package/src/maps/column-correlation/state.ts +110 -2
  88. package/src/maps/layers/columns.ts +7 -1
  89. package/src/prepare-units/helpers.ts +4 -3
  90. package/src/section.ts +9 -1
  91. package/src/unit-details/age-range.ts +3 -1
  92. package/src/unit-details/index.ts +7 -1
  93. package/src/unit-details/panel.module.sass +0 -8
  94. package/src/unit-details/panel.ts +6 -6
  95. package/src/unit-details/strat-names.ts +1 -1
  96. package/src/units/boxes.ts +4 -2
  97. package/dist/correlation-chart/stories/utils.d.ts +0 -6
  98. package/dist/unit-details/identifiers.cjs +0 -56
  99. package/dist/unit-details/identifiers.cjs.map +0 -1
  100. package/dist/unit-details/identifiers.d.ts +0 -31
  101. package/dist/unit-details/identifiers.js +0 -54
  102. package/dist/unit-details/identifiers.js.map +0 -1
  103. package/src/correlation-chart/stories/correlation-chart.stories.ts +0 -228
  104. package/src/correlation-chart/stories/namibia-correlation.stories.ts +0 -151
  105. package/src/correlation-chart/stories/stories.module.sass +0 -18
  106. package/src/correlation-chart/stories/utils.ts +0 -24
  107. package/src/unit-details/identifiers.ts +0 -67
@@ -1,39 +1,35 @@
1
1
  import h$1 from "@macrostrat/hyper";
2
- const spacer = "_spacer_ue390_43";
3
- const item = "_item_ue390_61";
4
- const proportion = "_proportion_ue390_68";
5
- const sep = "_sep_ue390_68";
6
- const identifier = "_identifier_ue390_73";
7
- const refs = "_refs_ue390_91";
8
- const clickable = "_clickable_ue390_97";
2
+ const spacer = "_spacer_arfxf_43";
3
+ const item = "_item_arfxf_61";
4
+ const proportion = "_proportion_arfxf_68";
5
+ const sep = "_sep_arfxf_68";
6
+ const refs = "_refs_arfxf_82";
7
+ const clickable = "_clickable_arfxf_88";
9
8
  const styles = {
10
- "legend-panel-header": "_legend-panel-header_ue390_1",
11
- "title-container": "_title-container_ue390_15",
12
- "hidden-actions-container": "_hidden-actions-container_ue390_22",
13
- "unit-id": "_unit-id_ue390_39",
9
+ "legend-panel-header": "_legend-panel-header_arfxf_1",
10
+ "title-container": "_title-container_arfxf_15",
11
+ "hidden-actions-container": "_hidden-actions-container_arfxf_22",
12
+ "unit-id": "_unit-id_arfxf_39",
14
13
  spacer,
15
- "unit-details-panel": "_unit-details-panel_ue390_47",
16
- "unit-details-content-holder": "_unit-details-content-holder_ue390_51",
17
- "unit-details-content": "_unit-details-content_ue390_51",
18
- "units-list": "_units-list_ue390_61",
14
+ "unit-details-panel": "_unit-details-panel_arfxf_47",
15
+ "unit-details-content-holder": "_unit-details-content-holder_arfxf_51",
16
+ "unit-details-content": "_unit-details-content_arfxf_51",
17
+ "units-list": "_units-list_arfxf_61",
19
18
  item,
20
19
  proportion,
21
20
  sep,
22
- "no-units": "_no-units_ue390_68",
23
- "strat-name-text": "_strat-name-text_ue390_68",
24
- "strat-name-id": "_strat-name-id_ue390_73",
25
- identifier,
26
- "color-swatch": "_color-swatch_ue390_82",
21
+ "no-units": "_no-units_arfxf_68",
22
+ "strat-name-text": "_strat-name-text_arfxf_68",
23
+ "color-swatch": "_color-swatch_arfxf_73",
27
24
  refs,
28
25
  clickable,
29
- "hidden-actions": "_hidden-actions_ue390_22"
26
+ "hidden-actions": "_hidden-actions_arfxf_22"
30
27
  };
31
28
  let h = h$1.styled(styles);
32
29
  Object.assign(h, styles);
33
30
  export {
34
31
  clickable,
35
32
  h as default,
36
- identifier,
37
33
  item,
38
34
  proportion,
39
35
  refs,
@@ -1 +1 @@
1
- {"version":3,"file":"panel.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"panel.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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;"}
@@ -60,7 +60,7 @@ function Unit(props) {
60
60
  let _fill = fill ?? columnComponents.useGeologicPattern(_patternID, defaultFill);
61
61
  const hasBackgroundColor = backgroundColor != null;
62
62
  const _className = classNames__default.default(className, { colored: hasBackgroundColor });
63
- const [ref, selected, onClick] = unitSelection.useUnitSelectionTarget(d);
63
+ const [ref, selected, onClick, linked] = unitSelection.useUnitSelectionTarget(d);
64
64
  return h(
65
65
  "g.unit",
66
66
  {
@@ -84,6 +84,7 @@ function Unit(props) {
84
84
  onClick,
85
85
  className: "unit"
86
86
  }),
87
+ h.if(linked)(UnitRect, { ...bounds, className: "linked-overlay" }),
87
88
  h.if(selected)(UnitRect, { ...bounds, className: "selection-overlay" }),
88
89
  //defs,
89
90
  children
@@ -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,IA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OAAA;AAAA,UAChB;AAAA,UACA,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,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 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, 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(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(linked)(UnitRect, { ...bounds, className: \"linked-overlay\" }),\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;AAgDA,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,IAAaC,2BAAA;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,aAAaC,UAAAA,UAAU,CAAC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G;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;;;;"}
@@ -55,7 +55,7 @@ function Unit(props) {
55
55
  let _fill = fill ?? useGeologicPattern(_patternID, defaultFill);
56
56
  const hasBackgroundColor = backgroundColor != null;
57
57
  const _className = classNames(className, { colored: hasBackgroundColor });
58
- const [ref, selected, onClick] = useUnitSelectionTarget(d);
58
+ const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);
59
59
  return h(
60
60
  "g.unit",
61
61
  {
@@ -79,6 +79,7 @@ function Unit(props) {
79
79
  onClick,
80
80
  className: "unit"
81
81
  }),
82
+ h.if(linked)(UnitRect, { ...bounds, className: "linked-overlay" }),
82
83
  h.if(selected)(UnitRect, { ...bounds, className: "selection-overlay" }),
83
84
  //defs,
84
85
  children
@@ -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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MACA,GAAG;AAAA,IAAA;AAAA,IAEL;AAAA,MACE,EAAE,GAAG,SAAS;AAAA,QACZ;AAAA,QACA,EAAE,GAAG,QAAQ,WAAW,uBAAA;AAAA,QACxB,EAAE,gBAAgB;AAAA,UAChB,WAAW;AAAA,UACX,gBAAgB;AAAA,UAChB,OAAO,EAAE,OAAO,OAAA;AAAA,UAChB;AAAA,UACA,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,IAAc,WAAW,aAAa;AAE9C,MAAI,UAAU,UAAU,GAAG;AACzB,YAAQ,KAAK,sCAAsC;AACnD,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,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,IACL;AAAA,IACA,EAAE,WAAW,aAAA;AAAA,IACb,EAAE,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 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, 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(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(linked)(UnitRect, { ...bounds, className: \"linked-overlay\" }),\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 { resolve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,IACb,EAAE,eAAe,QAAQ;AAAA,EAAA;AAE7B;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macrostrat/column-views",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "description": "Data views for Macrostrat stratigraphic columns",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,18 +48,18 @@
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.0.10",
52
+ "@macrostrat/data-components": "^1.5.0",
53
+ "@macrostrat/data-provider": "^1.2.0",
54
54
  "@macrostrat/hyper": "^3.1.1",
55
- "@macrostrat/map-interface": "^2.3.0",
55
+ "@macrostrat/map-interface": "^2.3.1",
56
56
  "@macrostrat/map-styles": "^2.2.6",
57
- "@macrostrat/mapbox-react": "^3.3.0",
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",
62
+ "@macrostrat/timescale": "^3.1.6",
63
63
  "@macrostrat/ui-components": "^5.1.0",
64
64
  "@turf/boolean-point-in-polygon": "^7.3.2",
65
65
  "@turf/buffer": "^7.3.2",
@@ -57,6 +57,12 @@ body:global(.dark-mode) .column-container
57
57
  fill: var(--selection-overlay-color, red)
58
58
  fill-opacity: var(--selection-overlay-opacity, 0.5)
59
59
 
60
+ // Units sharing a stratigraphic name with the selection: a subtler highlight
61
+ .linked-overlay
62
+ fill: var(--linked-overlay-color, var(--selection-overlay-color, red))
63
+ fill-opacity: var(--linked-overlay-opacity, 0.18)
64
+ pointer-events: none
65
+
60
66
  g.lithology-column use.frame
61
67
  stroke: var(--column-stroke-color)
62
68
  stroke-width: 1.5px !important
@@ -105,11 +105,16 @@ $map-size-inset: 12em
105
105
 
106
106
  .main-chart
107
107
  position: relative
108
+ grid-column: 2
109
+ grid-row: 2
108
110
 
109
111
  .correlation-chart-inner
110
- display: flex
111
- flex-direction: row
112
+ display: grid
113
+ // [age axis] [columns], with an optional header row above
114
+ grid-template-columns: auto auto
115
+ grid-template-rows: auto auto
112
116
  position: relative
117
+ width: fit-content
113
118
 
114
119
  .age-axis-container
115
120
  display: flex
@@ -117,6 +122,45 @@ $map-size-inset: 12em
117
122
  position: sticky
118
123
  left: 0
119
124
  z-index: 100
125
+ grid-column: 1
126
+ grid-row: 2
120
127
  padding-left: 1em
121
128
  padding-right: 2px
122
129
  background-color: var(--panel-secondary-background-color)
130
+
131
+ // Arbitrary content rendered above each column, aligned with the columns below.
132
+ .column-header-spacer
133
+ grid-column: 1
134
+ grid-row: 1
135
+ // Anchor for absolutely-positioned content (e.g. a zoom pill) so it can sit
136
+ // above the timescale without widening the axis column / shifting the chart
137
+ position: relative
138
+
139
+ .column-header-row
140
+ grid-column: 2
141
+ grid-row: 1
142
+ display: flex
143
+ flex-direction: row
144
+ // Bottom-anchor cells so all labels share the neatline
145
+ align-items: flex-end
146
+ // Pin to the top while scrolling. It stays in flow (grid row 1) so it
147
+ // reserves space above the columns, keeping them aligned with the age axis.
148
+ position: sticky
149
+ top: 0
150
+ // `position: sticky` forms a stacking context; leaving z-index at auto keeps
151
+ // the row below later-painted floating UI (maps, popovers).
152
+ // Neatline separating the headers from the columns below
153
+ border-bottom: 1px solid var(--column-stroke-color, var(--text-color))
154
+ background-color: var(--panel-secondary-background-color)
155
+
156
+ .column-header-cell
157
+ box-sizing: border-box
158
+ display: flex
159
+ flex-direction: column
160
+ // Bottom-anchor content (nearest the columns), stretched to the column
161
+ // width so text wraps within it
162
+ justify-content: flex-end
163
+ align-items: stretch
164
+ // Cap very long content; excess is clipped
165
+ max-height: var(--column-header-max-height, 300px)
166
+ overflow: hidden