@macrostrat/column-views 3.6.1 → 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 (96) hide show
  1. package/CHANGELOG.md +44 -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/unit-selection.cjs +4 -1
  23. package/dist/data-provider/unit-selection.cjs.map +1 -1
  24. package/dist/data-provider/unit-selection.d.ts +1 -1
  25. package/dist/data-provider/unit-selection.js +4 -1
  26. package/dist/data-provider/unit-selection.js.map +1 -1
  27. package/dist/index.cjs +14 -4
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.js +3 -2
  30. package/dist/maps/column-correlation/core.cjs +127 -6
  31. package/dist/maps/column-correlation/core.cjs.map +1 -1
  32. package/dist/maps/column-correlation/core.js +128 -7
  33. package/dist/maps/column-correlation/core.js.map +1 -1
  34. package/dist/maps/column-correlation/state.cjs +63 -2
  35. package/dist/maps/column-correlation/state.cjs.map +1 -1
  36. package/dist/maps/column-correlation/state.d.ts +31 -1
  37. package/dist/maps/column-correlation/state.js +63 -2
  38. package/dist/maps/column-correlation/state.js.map +1 -1
  39. package/dist/maps/layers/columns.cjs +5 -1
  40. package/dist/maps/layers/columns.cjs.map +1 -1
  41. package/dist/maps/layers/columns.js +5 -1
  42. package/dist/maps/layers/columns.js.map +1 -1
  43. package/dist/section.cjs +8 -2
  44. package/dist/section.cjs.map +1 -1
  45. package/dist/section.d.ts +2 -0
  46. package/dist/section.js +8 -2
  47. package/dist/section.js.map +1 -1
  48. package/dist/unit-details/age-range.cjs +2 -1
  49. package/dist/unit-details/age-range.cjs.map +1 -1
  50. package/dist/unit-details/age-range.js +2 -1
  51. package/dist/unit-details/age-range.js.map +1 -1
  52. package/dist/unit-details/index.d.ts +1 -1
  53. package/dist/unit-details/panel.cjs +2 -3
  54. package/dist/unit-details/panel.cjs.map +1 -1
  55. package/dist/unit-details/panel.js +1 -2
  56. package/dist/unit-details/panel.js.map +1 -1
  57. package/dist/unit-details/panel.module.sass.cjs +18 -22
  58. package/dist/unit-details/panel.module.sass.cjs.map +1 -1
  59. package/dist/unit-details/panel.module.sass.js +18 -22
  60. package/dist/unit-details/panel.module.sass.js.map +1 -1
  61. package/dist/unit-details/strat-names.cjs +1 -2
  62. package/dist/unit-details/strat-names.cjs.map +1 -1
  63. package/dist/unit-details/strat-names.js +1 -2
  64. package/dist/unit-details/strat-names.js.map +1 -1
  65. package/dist/units/boxes.cjs +2 -1
  66. package/dist/units/boxes.cjs.map +1 -1
  67. package/dist/units/boxes.js +2 -1
  68. package/dist/units/boxes.js.map +1 -1
  69. package/package.json +7 -7
  70. package/src/column.module.sass +6 -0
  71. package/src/correlation-chart/main.module.sass +46 -2
  72. package/src/correlation-chart/main.ts +180 -9
  73. package/src/correlation-chart/prepare-data.ts +0 -1
  74. package/src/data-provider/unit-selection.ts +13 -2
  75. package/src/maps/column-correlation/column-correlation-map.stories.ts +12 -0
  76. package/src/maps/column-correlation/core.ts +155 -9
  77. package/src/maps/column-correlation/state.ts +110 -2
  78. package/src/maps/layers/columns.ts +7 -1
  79. package/src/section.ts +9 -1
  80. package/src/unit-details/age-range.ts +3 -1
  81. package/src/unit-details/index.ts +7 -1
  82. package/src/unit-details/panel.module.sass +0 -8
  83. package/src/unit-details/panel.ts +6 -6
  84. package/src/unit-details/strat-names.ts +1 -1
  85. package/src/units/boxes.ts +4 -2
  86. package/dist/correlation-chart/stories/utils.d.ts +0 -6
  87. package/dist/unit-details/identifiers.cjs +0 -56
  88. package/dist/unit-details/identifiers.cjs.map +0 -1
  89. package/dist/unit-details/identifiers.d.ts +0 -31
  90. package/dist/unit-details/identifiers.js +0 -54
  91. package/dist/unit-details/identifiers.js.map +0 -1
  92. package/src/correlation-chart/stories/correlation-chart.stories.ts +0 -228
  93. package/src/correlation-chart/stories/namibia-correlation.stories.ts +0 -151
  94. package/src/correlation-chart/stories/stories.module.sass +0 -18
  95. package/src/correlation-chart/stories/utils.ts +0 -24
  96. package/src/unit-details/identifiers.ts +0 -67
@@ -1,228 +0,0 @@
1
- import { Meta } from "@storybook/react-vite";
2
- import "@macrostrat/style-system";
3
- import { useCorrelationLine } from "./utils";
4
- import {
5
- ColumnCorrelationMap,
6
- ColumnCorrelationProvider,
7
- MergeSectionsMode,
8
- useCorrelationMapStore,
9
- } from "../..";
10
- import { hyperStyled } from "@macrostrat/hyper";
11
- import {
12
- MacrostratDataProvider,
13
- fetchUnits,
14
- useMacrostratFetch,
15
- } from "@macrostrat/data-provider";
16
-
17
- import styles from "./stories.module.sass";
18
- import { CorrelationChart, CorrelationChartProps } from "../main";
19
- import { ErrorBoundary, useAsyncMemo } from "@macrostrat/ui-components";
20
- import { OverlaysProvider } from "@blueprintjs/core";
21
- import { EnvironmentColoredUnitComponent } from "../../units";
22
- import { scaleLinear, scalePow } from "d3-scale";
23
- import { MacrostratInteractionProvider } from "@macrostrat/data-components";
24
-
25
- const mapboxToken = import.meta.env.VITE_MAPBOX_API_TOKEN;
26
-
27
- const h = hyperStyled(styles);
28
-
29
- function CorrelationStoryUI({
30
- focusedLine,
31
- setFocusedLine,
32
- columnID,
33
- setColumn,
34
- selectedUnit,
35
- setSelectedUnit,
36
- inProcess,
37
- projectID,
38
- ...rest
39
- }: any) {
40
- const domain = "https://dev.macrostrat.org";
41
- return h(
42
- MacrostratDataProvider,
43
- { baseURL: domain + "/api/v2" },
44
- h(
45
- MacrostratInteractionProvider,
46
- { linkDomain: domain },
47
- h(
48
- ColumnCorrelationProvider,
49
- {
50
- focusedLine,
51
- columns: null,
52
- projectID,
53
- onSelectColumns(cols, line) {
54
- setFocusedLine(line);
55
- },
56
- },
57
- h("div.correlation-ui", [
58
- h("div.correlation-container", h(CorrelationDiagramWrapper, rest)),
59
- h("div.right-column", [
60
- h(ColumnCorrelationMap, {
61
- accessToken: mapboxToken,
62
- className: "correlation-map",
63
- //showLogo: false,
64
- }),
65
- ]),
66
- ]),
67
- ),
68
- ),
69
- );
70
- }
71
-
72
- function CorrelationDiagramWrapper(props: Omit<CorrelationChartProps, "data">) {
73
- /** This state management is a bit too complicated, but it does kinda sorta work */
74
-
75
- const fetch = useMacrostratFetch();
76
-
77
- // Sync focused columns with map
78
- const focusedColumns = useCorrelationMapStore(
79
- (state) => state.focusedColumns,
80
- );
81
-
82
- const columnUnits = useAsyncMemo(async () => {
83
- const col_ids = focusedColumns.map((col) => col.properties.col_id);
84
- return await fetchUnits(col_ids, fetch);
85
- }, [focusedColumns]);
86
-
87
- return h("div.correlation-diagram", [
88
- h(
89
- ErrorBoundary,
90
- h(OverlaysProvider, [
91
- h(CorrelationChart, { data: columnUnits, ...props }),
92
- ]),
93
- ),
94
- ]);
95
- }
96
-
97
- export default {
98
- title: "Column views/Correlation chart",
99
- component: CorrelationStoryUI,
100
- parameters: {
101
- layout: "fullscreen",
102
- docs: {
103
- description: {
104
- component: "Correlation chart for Macrostrat columns",
105
- },
106
- story: {
107
- inline: false,
108
- iframeHeight: 500,
109
- },
110
- },
111
- },
112
- args: {
113
- focusedLine: "-100,45 -90,50",
114
- columnSpacing: 0,
115
- columnWidth: 100,
116
- collapseSmallUnconformities: true,
117
- targetUnitHeight: 20,
118
- },
119
- argTypes: {
120
- selectedUnit: {
121
- control: {
122
- type: "number",
123
- },
124
- },
125
- t_age: {
126
- control: {
127
- type: "number",
128
- },
129
- },
130
- b_age: {
131
- control: {
132
- type: "number",
133
- },
134
- },
135
- columnSpacing: {
136
- control: {
137
- type: "number",
138
- },
139
- },
140
- columnWidth: {
141
- control: {
142
- type: "number",
143
- },
144
- },
145
- mergeSections: {
146
- options: ["all", "overlapping", null],
147
- control: { type: "radio" },
148
- },
149
- pixelScale: {
150
- control: {
151
- type: "number",
152
- },
153
- },
154
- collapseSmallUnconformities: {
155
- control: {
156
- type: "boolean",
157
- },
158
- },
159
- minSectionHeight: {
160
- control: {
161
- type: "number",
162
- },
163
- },
164
- targetUnitHeight: {
165
- control: {
166
- type: "number",
167
- },
168
- },
169
- showLabelColumn: {
170
- control: {
171
- type: "boolean",
172
- },
173
- },
174
- maxInternalColumns: {
175
- control: {
176
- type: "number",
177
- },
178
- },
179
- projectID: {
180
- control: {
181
- type: "number",
182
- },
183
- },
184
- },
185
- } as Meta<typeof CorrelationStoryUI>;
186
-
187
- function Template(args) {
188
- return h(CorrelationStoryUI, {
189
- ...args,
190
- ...useCorrelationLine(),
191
- });
192
- }
193
-
194
- export const Primary = Template.bind({});
195
-
196
- export const ColoredByEnvironment = Template.bind({});
197
- ColoredByEnvironment.args = {
198
- unitComponent: EnvironmentColoredUnitComponent,
199
- };
200
-
201
- export const RestrictedAgeRange = Template.bind({});
202
- RestrictedAgeRange.args = {
203
- t_age: 100,
204
- b_age: 300,
205
- focusedLine: "-114.29,42.74 -104.59,39.21",
206
- };
207
-
208
- export const WithFixedScale = Template.bind({});
209
- WithFixedScale.args = {
210
- scale: scaleLinear().domain([0, 2500]).range([0, 1000]),
211
- };
212
-
213
- export const WithPowerScale = Template.bind({});
214
- WithPowerScale.args = {
215
- scale: scalePow().exponent(0.3).domain([0, 2500]).range([0, 1000]),
216
- };
217
-
218
- export const WithPowerScaleMerged = Template.bind({});
219
- WithPowerScaleMerged.args = {
220
- scale: scalePow().exponent(0.3).domain([0, 2500]).range([0, 1000]),
221
- mergeSections: MergeSectionsMode.ALL,
222
- };
223
-
224
- export const eODPCorrelationChart = Template.bind({});
225
- eODPCorrelationChart.args = {
226
- focusedLine: "-125,38 -120,32",
227
- projectID: 3,
228
- };
@@ -1,151 +0,0 @@
1
- import "@macrostrat/style-system";
2
- import { MergeSectionsMode, UnitComponent } from "../..";
3
- import { Meta } from "@storybook/react-vite";
4
-
5
- import h from "./stories.module.sass";
6
- import { CorrelationChart } from "../main";
7
- import { BaseUnit } from "@macrostrat/api-types";
8
- import { useGeologicPattern } from "@macrostrat/column-components";
9
-
10
- export default {
11
- title: "Column views/Correlation chart",
12
- component: CorrelationChart,
13
- parameters: {
14
- layout: "fullscreen",
15
- docs: {
16
- description: {
17
- component: "Correlation chart for Macrostrat columns",
18
- },
19
- story: {
20
- inline: false,
21
- iframeHeight: 500,
22
- },
23
- },
24
- },
25
- args: {},
26
- } as Meta<typeof CorrelationChart>;
27
-
28
- const nosib = {
29
- b_age: 900,
30
- t_age: 800,
31
- name: "Nosib",
32
- color: "#ffd4ba",
33
- };
34
-
35
- const namUnits: (BaseUnit | BaseUnit[])[] = [
36
- [
37
- nosib,
38
- { b_age: 746, t_age: 720, name: "Chuos", color: "#d0b4ff" },
39
- {
40
- b_age: 720,
41
- t_age: 600,
42
- name: "Otavi",
43
- color: "dodgerblue",
44
- },
45
- ],
46
- [
47
- nosib,
48
- {
49
- b_age: 740,
50
- t_age: 600,
51
- name: "Swakop",
52
- color: "#aaa",
53
- },
54
- ],
55
- [
56
- nosib,
57
- {
58
- b_age: 670,
59
- t_age: 580,
60
- name: "Witvlei",
61
- color: "#fffc4e",
62
- },
63
- ],
64
- [
65
- {
66
- b_age: 610,
67
- t_age: 575,
68
- name: "Zebra Series",
69
- color: "#fdbcf0",
70
- },
71
- {
72
- b_age: 660,
73
- t_age: 610,
74
- name: "Naukluft complex",
75
- color: "#fdbcbc",
76
- },
77
- ],
78
- {
79
- b_age: 550,
80
- t_age: 520,
81
- name: "Nama",
82
- color: "#baf1a7",
83
- },
84
- // {
85
- // unit_id: 0,
86
- // b_age: 900,
87
- // t_age: 0,
88
- // unit_name: "",
89
- // column: 8,
90
- // },
91
- ];
92
-
93
- export function NamibiaCorrelationChart() {
94
- return h(
95
- "div",
96
- {
97
- style: {
98
- "--column-unit-font-size": "14px",
99
- "--column-unit-font-style": "bold",
100
- "--column-text-color": "white",
101
- },
102
- },
103
- [
104
- h(CorrelationChart, {
105
- id: 432,
106
- data: namUnits.map((u, i) => {
107
- let units: any = null;
108
- if (Array.isArray(u)) {
109
- units = u.map((u) => buildUnit(u, i));
110
- } else {
111
- units = [buildUnit(u, i)];
112
- }
113
- return {
114
- columnID: i,
115
- units,
116
- };
117
- }),
118
- columnSpacing: 10,
119
- t_age: 450,
120
- b_age: 850,
121
- //width: 400,
122
- //columnWidth: 400,
123
- pixelScale: 2,
124
- //showLabelColumn: false,
125
- mergeSections: MergeSectionsMode.ALL,
126
- unitComponent: ProvidedColorUnitComponent,
127
- }),
128
- ],
129
- );
130
- }
131
-
132
- function buildUnit(unit, i) {
133
- return {
134
- unit_id: i,
135
- col_id: i,
136
- ...unit,
137
- unit_name: unit.name,
138
- };
139
- }
140
-
141
- function ProvidedColorUnitComponent(props) {
142
- /** A unit component that is colored by its own properties. */
143
-
144
- const fill = useGeologicPattern(props.division.patternID);
145
-
146
- return h(UnitComponent, {
147
- fill,
148
- backgroundColor: props.division.color ?? null,
149
- ...props,
150
- });
151
- }
@@ -1,18 +0,0 @@
1
- .column-ui
2
- height: 100%
3
- width: 100%
4
- overflow: scroll
5
-
6
- .correlation-container
7
- padding: 2em calc(350px + 2em) 2em 2em
8
- width: fit-content
9
-
10
- .right-column
11
- width: 350px
12
- position: fixed
13
- top: 0
14
- right: 0
15
- padding: 1em
16
-
17
- .column-selector-map, .correlation-map
18
- height: 350px
@@ -1,24 +0,0 @@
1
- import { useArgs } from "storybook/preview-api";
2
- import { useCallback } from "react";
3
- import { parseLineFromString, stringifyLine } from "../hash-string";
4
-
5
- export function useCorrelationLine() {
6
- const [{ focusedLine, selectedUnit }, updateArgs] = useArgs();
7
- const setFocusedLine = (line) => {
8
- updateArgs({ focusedLine: stringifyLine(line) });
9
- };
10
-
11
- const setSelectedUnit = useCallback(
12
- (selectedUnit) => {
13
- updateArgs({ selectedUnit });
14
- },
15
- [updateArgs],
16
- );
17
-
18
- return {
19
- focusedLine: parseLineFromString(focusedLine),
20
- setFocusedLine,
21
- selectedUnit,
22
- setSelectedUnit,
23
- };
24
- }
@@ -1,67 +0,0 @@
1
- import { isClickable, ItemInteractionProps } from "@macrostrat/data-components";
2
- import h from "./panel.module.sass";
3
- import { ReactNode } from "react";
4
- import classNames from "classnames";
5
-
6
- export function ClickableText({
7
- className,
8
- ...rest
9
- }: {
10
- className?: string;
11
- children: ReactNode;
12
- } & ItemInteractionProps) {
13
- /** An optionally clickable text element */
14
- const clickable = isClickable(rest);
15
- const tag = clickable ? "a" : "span";
16
- return h(tag, { className: classNames(className, { clickable }), ...rest });
17
- }
18
-
19
- export function Identifier({
20
- id,
21
- className,
22
- ...rest
23
- }: {
24
- id: number | string;
25
- className?: string;
26
- } & ItemInteractionProps) {
27
- /** An item that displays a numeric identifier, optionally clickable */
28
- return h(
29
- ClickableText,
30
- {
31
- className: classNames("identifier", className),
32
- ...rest,
33
- },
34
- id,
35
- );
36
- }
37
-
38
- export type UnitInfo = {
39
- unitID: number;
40
- colID?: number;
41
- name?: string;
42
- };
43
-
44
- export function UnitIdentifier({
45
- unitID,
46
- colID,
47
- name,
48
- ...interactionProps
49
- }: UnitInfo & ItemInteractionProps) {
50
- if (name != null) {
51
- return h(
52
- ClickableText,
53
- {
54
- className: "unit-name",
55
- ...interactionProps,
56
- },
57
- name,
58
- );
59
- }
60
-
61
- return h(Identifier, {
62
- className: "unit-id",
63
- key: unitID,
64
- id: unitID,
65
- ...interactionProps,
66
- });
67
- }