@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
@@ -19,13 +19,34 @@ import { useMacrostratColumns } from "@macrostrat/data-provider";
19
19
  import { buffer } from "@turf/buffer";
20
20
  import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
21
21
 
22
+ export type CorrelationSelectionMode = "line" | "manual";
23
+
22
24
  export interface CorrelationMapInput {
23
25
  columns: ColumnGeoJSONRecord[];
24
26
  focusedLine: LineString | null;
27
+ /** When set, columns are selected manually (by clicking) in this order,
28
+ * rather than derived from a line of section. */
29
+ manualColumns?: number[] | null;
25
30
  }
26
31
 
27
32
  export interface CorrelationMapStore extends CorrelationMapInput {
28
33
  onClickMap: (event: mapboxgl.MapMouseEvent, point: Point) => void;
34
+ /** Toggle a column in/out of the manual selection (used in "manual" mode) */
35
+ toggleColumn: (colID: number) => void;
36
+ /** Remove a column from the selection. In "line" mode this converts the
37
+ * current selection to a manual one (a line can't represent an arbitrary
38
+ * subset), so removing a column switches modes. */
39
+ removeColumn: (colID: number) => void;
40
+ /** Replace the manual column selection with an explicit ordered list (used
41
+ * e.g. for drag-and-drop reordering). Switches to manual mode. */
42
+ setManualColumns: (colIDs: number[]) => void;
43
+ setHoveredColumn: (colID: number | null) => void;
44
+ hoveredColumn: number | null;
45
+ /** Request the map to frame a particular column (e.g. on header click). */
46
+ zoomToColumn: (colID: number | null) => void;
47
+ zoomColumn: number | null;
48
+ /** Incremented on each zoom request so repeat clicks re-frame the column. */
49
+ zoomNonce: number;
29
50
  projectID?: number;
30
51
  }
31
52
 
@@ -45,13 +66,19 @@ const CorrelationStoreContext =
45
66
 
46
67
  type ComputedStore = {
47
68
  focusedColumns: FocusedColumnGeoJSONRecord[];
69
+ selectionMode: CorrelationSelectionMode;
48
70
  };
49
71
 
50
72
  /** A computed store that will automatically update when the state changes */
51
73
  const computed = createComputed((state: CorrelationMapStore): ComputedStore => {
74
+ const manual = state.manualColumns != null;
52
75
  return {
53
- // We compute the focused columns based on columns and focusedLine
54
- focusedColumns: buildCorrelationColumns(state.columns, state.focusedLine),
76
+ selectionMode: manual ? "manual" : "line",
77
+ // Focused columns are derived either from an explicit manual selection or
78
+ // from the columns intersecting the line of section.
79
+ focusedColumns: manual
80
+ ? buildManualColumns(state.columns, state.manualColumns)
81
+ : buildCorrelationColumns(state.columns, state.focusedLine),
55
82
  };
56
83
  }) as any;
57
84
 
@@ -61,6 +88,7 @@ export function ColumnCorrelationProvider({
61
88
  projectID,
62
89
  inProcess,
63
90
  focusedLine,
91
+ manualColumns = null,
64
92
  onSelectColumns,
65
93
  }: CorrelationProviderProps) {
66
94
  const [store] = useState(() => {
@@ -68,10 +96,16 @@ export function ColumnCorrelationProvider({
68
96
  computed((set, get): CorrelationMapStore => {
69
97
  return {
70
98
  focusedLine,
99
+ manualColumns,
100
+ hoveredColumn: null,
101
+ zoomColumn: null,
102
+ zoomNonce: 0,
71
103
  projectID,
72
104
  columns: null,
73
105
  onClickMap(event: mapboxgl.MapMouseEvent, point: Point) {
74
106
  const state = get();
107
+ // In manual-selection mode the map click is handled per-column
108
+ if (state.manualColumns != null) return;
75
109
  // Check if shift key is pressed
76
110
  const shiftKeyPressed = event.originalEvent.shiftKey;
77
111
  let existingCoords = state.focusedLine?.coordinates ?? [];
@@ -87,6 +121,36 @@ export function ColumnCorrelationProvider({
87
121
  },
88
122
  });
89
123
  },
124
+ toggleColumn(colID: number) {
125
+ const state = get();
126
+ const current =
127
+ state.manualColumns ??
128
+ state.focusedColumns.map((d) => d.properties.col_id);
129
+ const next = current.includes(colID)
130
+ ? current.filter((d) => d !== colID)
131
+ : [...current, colID];
132
+ set({ manualColumns: next, focusedLine: null });
133
+ },
134
+ removeColumn(colID: number) {
135
+ const state = get();
136
+ // Seed from the current selection (line-derived or manual)
137
+ const current =
138
+ state.manualColumns ??
139
+ state.focusedColumns.map((d) => d.properties.col_id);
140
+ set({
141
+ manualColumns: current.filter((d) => d !== colID),
142
+ focusedLine: null,
143
+ });
144
+ },
145
+ setManualColumns(colIDs: number[]) {
146
+ set({ manualColumns: colIDs, focusedLine: null });
147
+ },
148
+ setHoveredColumn(colID: number | null) {
149
+ set({ hoveredColumn: colID });
150
+ },
151
+ zoomToColumn(colID: number | null) {
152
+ set({ zoomColumn: colID, zoomNonce: get().zoomNonce + 1 });
153
+ },
90
154
  };
91
155
  }),
92
156
  );
@@ -122,6 +186,24 @@ export function useCorrelationMapStore(
122
186
  return useStore(storeApi, selector);
123
187
  }
124
188
 
189
+ export interface ColumnMapLink {
190
+ onColumnMouseOver: (colID: number | null) => void;
191
+ onColumnClick: (colID: number) => void;
192
+ }
193
+
194
+ /** Wire a correlation chart's column-level events to the correlation map:
195
+ * hovering a column highlights it on the map, and clicking a column header
196
+ * frames it. Spread the result into `CorrelationChart`. Must be used within a
197
+ * `ColumnCorrelationProvider`. */
198
+ export function useColumnMapLink(): ColumnMapLink {
199
+ const setHoveredColumn = useCorrelationMapStore((s) => s.setHoveredColumn);
200
+ const zoomToColumn = useCorrelationMapStore((s) => s.zoomToColumn);
201
+ return {
202
+ onColumnMouseOver: setHoveredColumn,
203
+ onColumnClick: zoomToColumn,
204
+ };
205
+ }
206
+
125
207
  function buildCorrelationColumns(
126
208
  columns: ColumnGeoJSONRecord[],
127
209
  line: LineString,
@@ -135,6 +217,32 @@ function buildCorrelationColumns(
135
217
  );
136
218
  }
137
219
 
220
+ function buildManualColumns(
221
+ columns: ColumnGeoJSONRecord[],
222
+ ids: number[],
223
+ ): FocusedColumnGeoJSONRecord[] {
224
+ /** Build focused columns from an explicit, ordered list of column IDs. The
225
+ * ordering line simply connects them in the order they were selected. */
226
+ if (columns == null || ids == null) return [];
227
+ const byID = new Map(columns.map((c) => [c.properties.col_id, c]));
228
+ const result: FocusedColumnGeoJSONRecord[] = [];
229
+ ids.forEach((id, i) => {
230
+ const col = byID.get(id);
231
+ if (col == null) return;
232
+ const c = centroid(col.geometry);
233
+ result.push({
234
+ ...col,
235
+ properties: {
236
+ ...col.properties,
237
+ centroid: c,
238
+ nearestPointOnLine: c,
239
+ distanceAlongLine: i,
240
+ },
241
+ });
242
+ });
243
+ return result;
244
+ }
245
+
138
246
  function computeIntersectingColumns(
139
247
  columns: ColumnGeoJSONRecord[],
140
248
  line: LineString,
@@ -75,7 +75,13 @@ export function buildColumnsStyle(
75
75
  opts.selectedColor ?? getCSSVariable("--selection-color", "purple");
76
76
 
77
77
  const lineColor = opts.lineColor ?? columnBaseColor;
78
- const isHovered = ["boolean", ["feature-state", "hover"], false];
78
+ // Highlight on either direct map hover or an externally-driven highlight
79
+ // (e.g. hovering the corresponding column header elsewhere in the UI).
80
+ const isHovered = [
81
+ "any",
82
+ ["boolean", ["feature-state", "hover"], false],
83
+ ["boolean", ["feature-state", "highlighted"], false],
84
+ ];
79
85
  // If color is in the feature state or geojson properties, use that as second choice
80
86
  if (typeof columnColor === "string") {
81
87
  columnColor = [
package/src/section.ts CHANGED
@@ -7,6 +7,7 @@ import { ReactNode, FunctionComponent, useMemo } from "react";
7
7
  import {
8
8
  Timescale,
9
9
  TimescaleOrientation,
10
+ TimescaleClickHandler,
10
11
  useMacrostratIntervals,
11
12
  } from "@macrostrat/timescale";
12
13
  import { ColumnAxisType, SVG } from "@macrostrat/column-components";
@@ -218,10 +219,16 @@ export function CompositeTimescale(props: CompositeTimescaleProps) {
218
219
 
219
220
  type CompositeTimescaleCoreProps = CompositeTimescaleProps & {
220
221
  packages: PackageScaleLayoutData[];
222
+ onClickInterval?: TimescaleClickHandler;
221
223
  };
222
224
 
223
225
  export function CompositeTimescaleCore(props: CompositeTimescaleCoreProps) {
224
- const { levels = 3, packages, unconformityLabels = false } = props;
226
+ const {
227
+ levels = 3,
228
+ packages,
229
+ unconformityLabels = false,
230
+ onClickInterval,
231
+ } = props;
225
232
 
226
233
  // Use intervals from Macrostrat API
227
234
  const baseURL = useMacrostratBaseURL();
@@ -254,6 +261,7 @@ export function CompositeTimescaleCore(props: CompositeTimescaleCoreProps) {
254
261
  showAgeAxis: false,
255
262
  scale,
256
263
  intervals,
264
+ onClick: onClickInterval,
257
265
  }),
258
266
  ],
259
267
  );
@@ -132,8 +132,10 @@ export function IntervalProportions({
132
132
  const i0 = unit.b_int_id;
133
133
  const i1 = unit.t_int_id;
134
134
 
135
+ const ints = new Set([i0, i1]);
136
+
135
137
  /** Get interval information */
136
- const intervalMap = useMacrostratDefs("intervals");
138
+ const intervalMap = useMacrostratDefs("intervals", Array.from(ints), null);
137
139
  const [int0, int1] = useMemo(() => {
138
140
  const int0 = intervalMap?.get(i0) ?? {};
139
141
  if (i0 === i1) {
@@ -3,4 +3,10 @@ export * from "./popover";
3
3
  export * from "./modal-panel";
4
4
  export * from "./age-range";
5
5
  export * from "./strat-names";
6
- export * from "./identifiers";
6
+
7
+ // Backwards compatibility
8
+ export {
9
+ ClickableText,
10
+ Identifier,
11
+ UnitIdentifier,
12
+ } from "@macrostrat/data-components";
@@ -61,14 +61,6 @@
61
61
  color: var(--secondary-color)
62
62
  font-style: italic
63
63
 
64
- .strat-name-id, .identifier
65
- font-family: var(--monospace-font)
66
- color: var(--secondary-color)
67
-
68
- &::before
69
- content: '#'
70
- color: var(--tertiary-color)
71
-
72
64
  .color-swatch
73
65
  width: 1em
74
66
  height: 1em
@@ -34,7 +34,11 @@ import { AgeField, Duration, IntervalProportions } from "./age-range";
34
34
  import { formatRange, formatSignificance } from "./utils.ts";
35
35
  import h from "./panel.module.sass";
36
36
  import { StratNameField } from "./strat-names.ts";
37
- import { Identifier, UnitIdentifier, UnitInfo } from "./identifiers.ts";
37
+ import {
38
+ Identifier,
39
+ UnitIdentifier,
40
+ UnitInfo,
41
+ } from "@macrostrat/data-components";
38
42
  import { LithologyIdentifier } from "@macrostrat/api-types/src/lithologies";
39
43
 
40
44
  export interface UnitDetailsPanelProps {
@@ -196,11 +200,7 @@ export enum UnitDetailsFeature {
196
200
  export type MacrostratItemClickHandler = (
197
201
  event: MouseEvent,
198
202
  item:
199
- | Lithology
200
- | Environment
201
- | UnitLong
202
- | Interval
203
- | { strat_name_id: number },
203
+ Lithology | Environment | UnitLong | Interval | { strat_name_id: number },
204
204
  ) => void;
205
205
 
206
206
  function UnitDetailsContent({
@@ -3,11 +3,11 @@ import {
3
3
  isClickable,
4
4
  ItemInteractionProps,
5
5
  useInteractionProps,
6
+ Identifier,
6
7
  } from "@macrostrat/data-components";
7
8
  import h from "./panel.module.sass";
8
9
  import classNames from "classnames";
9
10
  import { useStratNames } from "@macrostrat/data-provider";
10
- import { Identifier } from "./identifiers.ts";
11
11
 
12
12
  function useStratNameData(strat_name_id: number) {
13
13
  const stratNames = useStratNames([strat_name_id]);
@@ -100,7 +100,7 @@ export function MinimalUnit(props) {
100
100
 
101
101
  const backgroundColor = getMixedUnitColor(d, lithMap, null, false);
102
102
 
103
- const [ref, selected, onClick] = useUnitSelectionTarget(d);
103
+ const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);
104
104
 
105
105
  return h(
106
106
  "g.unit",
@@ -120,6 +120,7 @@ export function MinimalUnit(props) {
120
120
  stroke: backgroundColor,
121
121
  onClick,
122
122
  }),
123
+ h.if(linked)("rect.linked-overlay", bounds),
123
124
  h.if(selected)("rect.selection-overlay", bounds),
124
125
  ],
125
126
  );
@@ -158,7 +159,7 @@ function Unit(props: UnitProps) {
158
159
 
159
160
  const _className = classNames(className, { colored: hasBackgroundColor });
160
161
 
161
- const [ref, selected, onClick] = useUnitSelectionTarget(d);
162
+ const [ref, selected, onClick, linked] = useUnitSelectionTarget(d);
162
163
 
163
164
  return h(
164
165
  "g.unit",
@@ -183,6 +184,7 @@ function Unit(props: UnitProps) {
183
184
  onClick,
184
185
  className: "unit",
185
186
  }),
187
+ h.if(linked)(UnitRect, { ...bounds, className: "linked-overlay" }),
186
188
  h.if(selected)(UnitRect, { ...bounds, className: "selection-overlay" }),
187
189
  //defs,
188
190
  children,
@@ -1,6 +0,0 @@
1
- export declare function useCorrelationLine(): {
2
- focusedLine: import('geojson').LineString | null;
3
- setFocusedLine: (line: any) => void;
4
- selectedUnit: any;
5
- setSelectedUnit: (selectedUnit: any) => void;
6
- };
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const dataComponents = require("@macrostrat/data-components");
4
- const panel_module = require("./panel.module.sass.cjs");
5
- const classNames = require("classnames");
6
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
7
- const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
8
- function ClickableText({
9
- className,
10
- ...rest
11
- }) {
12
- const clickable = dataComponents.isClickable(rest);
13
- const tag = clickable ? "a" : "span";
14
- return panel_module.default(tag, { className: classNames__default.default(className, { clickable }), ...rest });
15
- }
16
- function Identifier({
17
- id,
18
- className,
19
- ...rest
20
- }) {
21
- return panel_module.default(
22
- ClickableText,
23
- {
24
- className: classNames__default.default("identifier", className),
25
- ...rest
26
- },
27
- id
28
- );
29
- }
30
- function UnitIdentifier({
31
- unitID,
32
- colID,
33
- name,
34
- ...interactionProps
35
- }) {
36
- if (name != null) {
37
- return panel_module.default(
38
- ClickableText,
39
- {
40
- className: "unit-name",
41
- ...interactionProps
42
- },
43
- name
44
- );
45
- }
46
- return panel_module.default(Identifier, {
47
- className: "unit-id",
48
- key: unitID,
49
- id: unitID,
50
- ...interactionProps
51
- });
52
- }
53
- exports.ClickableText = ClickableText;
54
- exports.Identifier = Identifier;
55
- exports.UnitIdentifier = UnitIdentifier;
56
- //# sourceMappingURL=identifiers.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"identifiers.cjs","sources":["../../src/unit-details/identifiers.ts"],"sourcesContent":["import { isClickable, ItemInteractionProps } from \"@macrostrat/data-components\";\nimport h from \"./panel.module.sass\";\nimport { ReactNode } from \"react\";\nimport classNames from \"classnames\";\n\nexport function ClickableText({\n className,\n ...rest\n}: {\n className?: string;\n children: ReactNode;\n} & ItemInteractionProps) {\n /** An optionally clickable text element */\n const clickable = isClickable(rest);\n const tag = clickable ? \"a\" : \"span\";\n return h(tag, { className: classNames(className, { clickable }), ...rest });\n}\n\nexport function Identifier({\n id,\n className,\n ...rest\n}: {\n id: number | string;\n className?: string;\n} & ItemInteractionProps) {\n /** An item that displays a numeric identifier, optionally clickable */\n return h(\n ClickableText,\n {\n className: classNames(\"identifier\", className),\n ...rest,\n },\n id,\n );\n}\n\nexport type UnitInfo = {\n unitID: number;\n colID?: number;\n name?: string;\n};\n\nexport function UnitIdentifier({\n unitID,\n colID,\n name,\n ...interactionProps\n}: UnitInfo & ItemInteractionProps) {\n if (name != null) {\n return h(\n ClickableText,\n {\n className: \"unit-name\",\n ...interactionProps,\n },\n name,\n );\n }\n\n return h(Identifier, {\n className: \"unit-id\",\n key: unitID,\n id: unitID,\n ...interactionProps,\n });\n}\n"],"names":["isClickable","h","classNames"],"mappings":";;;;;;;AAKO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA,GAAG;AACL,GAG0B;AAExB,QAAM,YAAYA,eAAAA,YAAY,IAAI;AAClC,QAAM,MAAM,YAAY,MAAM;AAC9B,SAAOC,qBAAE,KAAK,EAAE,WAAWC,oBAAAA,QAAW,WAAW,EAAE,UAAA,CAAW,GAAG,GAAG,MAAM;AAC5E;AAEO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAG0B;AAExB,SAAOD,aAAAA;AAAAA,IACL;AAAA,IACA;AAAA,MACE,WAAWC,oBAAAA,QAAW,cAAc,SAAS;AAAA,MAC7C,GAAG;AAAA,IAAA;AAAA,IAEL;AAAA,EAAA;AAEJ;AAQO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAoC;AAClC,MAAI,QAAQ,MAAM;AAChB,WAAOD,aAAAA;AAAAA,MACL;AAAA,MACA;AAAA,QACE,WAAW;AAAA,QACX,GAAG;AAAA,MAAA;AAAA,MAEL;AAAA,IAAA;AAAA,EAEJ;AAEA,SAAOA,aAAAA,QAAE,YAAY;AAAA,IACnB,WAAW;AAAA,IACX,KAAK;AAAA,IACL,IAAI;AAAA,IACJ,GAAG;AAAA,EAAA,CACJ;AACH;;;;"}
@@ -1,31 +0,0 @@
1
- import { ItemInteractionProps } from '@macrostrat/data-components';
2
- import { ReactNode } from 'react';
3
- export declare function ClickableText({ className, ...rest }: {
4
- className?: string;
5
- children: ReactNode;
6
- } & ItemInteractionProps): import('react').ReactElement<{
7
- children: ReactNode;
8
- href?: string | null;
9
- target?: string;
10
- onClick?: (event: MouseEvent) => void;
11
- className: string;
12
- }, string | import('react').JSXElementConstructor<any>>;
13
- export declare function Identifier({ id, className, ...rest }: {
14
- id: number | string;
15
- className?: string;
16
- } & ItemInteractionProps): import('react').FunctionComponentElement<{
17
- className?: string;
18
- children: ReactNode;
19
- } & ItemInteractionProps>;
20
- export type UnitInfo = {
21
- unitID: number;
22
- colID?: number;
23
- name?: string;
24
- };
25
- export declare function UnitIdentifier({ unitID, colID, name, ...interactionProps }: UnitInfo & ItemInteractionProps): import('react').FunctionComponentElement<{
26
- className?: string;
27
- children: ReactNode;
28
- } & ItemInteractionProps> | import('react').FunctionComponentElement<{
29
- id: number | string;
30
- className?: string;
31
- } & ItemInteractionProps>;
@@ -1,54 +0,0 @@
1
- import { isClickable } from "@macrostrat/data-components";
2
- import h from "./panel.module.sass.js";
3
- import classNames from "classnames";
4
- function ClickableText({
5
- className,
6
- ...rest
7
- }) {
8
- const clickable = isClickable(rest);
9
- const tag = clickable ? "a" : "span";
10
- return h(tag, { className: classNames(className, { clickable }), ...rest });
11
- }
12
- function Identifier({
13
- id,
14
- className,
15
- ...rest
16
- }) {
17
- return h(
18
- ClickableText,
19
- {
20
- className: classNames("identifier", className),
21
- ...rest
22
- },
23
- id
24
- );
25
- }
26
- function UnitIdentifier({
27
- unitID,
28
- colID,
29
- name,
30
- ...interactionProps
31
- }) {
32
- if (name != null) {
33
- return h(
34
- ClickableText,
35
- {
36
- className: "unit-name",
37
- ...interactionProps
38
- },
39
- name
40
- );
41
- }
42
- return h(Identifier, {
43
- className: "unit-id",
44
- key: unitID,
45
- id: unitID,
46
- ...interactionProps
47
- });
48
- }
49
- export {
50
- ClickableText,
51
- Identifier,
52
- UnitIdentifier
53
- };
54
- //# sourceMappingURL=identifiers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"identifiers.js","sources":["../../src/unit-details/identifiers.ts"],"sourcesContent":["import { isClickable, ItemInteractionProps } from \"@macrostrat/data-components\";\nimport h from \"./panel.module.sass\";\nimport { ReactNode } from \"react\";\nimport classNames from \"classnames\";\n\nexport function ClickableText({\n className,\n ...rest\n}: {\n className?: string;\n children: ReactNode;\n} & ItemInteractionProps) {\n /** An optionally clickable text element */\n const clickable = isClickable(rest);\n const tag = clickable ? \"a\" : \"span\";\n return h(tag, { className: classNames(className, { clickable }), ...rest });\n}\n\nexport function Identifier({\n id,\n className,\n ...rest\n}: {\n id: number | string;\n className?: string;\n} & ItemInteractionProps) {\n /** An item that displays a numeric identifier, optionally clickable */\n return h(\n ClickableText,\n {\n className: classNames(\"identifier\", className),\n ...rest,\n },\n id,\n );\n}\n\nexport type UnitInfo = {\n unitID: number;\n colID?: number;\n name?: string;\n};\n\nexport function UnitIdentifier({\n unitID,\n colID,\n name,\n ...interactionProps\n}: UnitInfo & ItemInteractionProps) {\n if (name != null) {\n return h(\n ClickableText,\n {\n className: \"unit-name\",\n ...interactionProps,\n },\n name,\n );\n }\n\n return h(Identifier, {\n className: \"unit-id\",\n key: unitID,\n id: unitID,\n ...interactionProps,\n });\n}\n"],"names":[],"mappings":";;;AAKO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA,GAAG;AACL,GAG0B;AAExB,QAAM,YAAY,YAAY,IAAI;AAClC,QAAM,MAAM,YAAY,MAAM;AAC9B,SAAO,EAAE,KAAK,EAAE,WAAW,WAAW,WAAW,EAAE,UAAA,CAAW,GAAG,GAAG,MAAM;AAC5E;AAEO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAG0B;AAExB,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,WAAW,WAAW,cAAc,SAAS;AAAA,MAC7C,GAAG;AAAA,IAAA;AAAA,IAEL;AAAA,EAAA;AAEJ;AAQO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAoC;AAClC,MAAI,QAAQ,MAAM;AAChB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,WAAW;AAAA,QACX,GAAG;AAAA,MAAA;AAAA,MAEL;AAAA,IAAA;AAAA,EAEJ;AAEA,SAAO,EAAE,YAAY;AAAA,IACnB,WAAW;AAAA,IACX,KAAK;AAAA,IACL,IAAI;AAAA,IACJ,GAAG;AAAA,EAAA,CACJ;AACH;"}