@macrostrat/column-views 1.0.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.
- package/CHANGELOG.md +14 -0
- package/README.md +3 -0
- package/dist/age-axis.7ce58d66.js +41 -0
- package/dist/age-axis.7ce58d66.js.map +1 -0
- package/dist/boxes.6d3192e6.js +164 -0
- package/dist/boxes.6d3192e6.js.map +1 -0
- package/dist/boxes.module.998ff312.js +13 -0
- package/dist/boxes.module.998ff312.js.map +1 -0
- package/dist/boxes.module.dd631fe3.css +4 -0
- package/dist/boxes.module.dd631fe3.css.map +1 -0
- package/dist/carbon-isotopes.6d9bddcf.js +11 -0
- package/dist/carbon-isotopes.6d9bddcf.js.map +1 -0
- package/dist/column.e35a471f.js +149 -0
- package/dist/column.e35a471f.js.map +1 -0
- package/dist/column.e901b5d4.js +117 -0
- package/dist/column.e901b5d4.js.map +1 -0
- package/dist/column.module.2e29259c.js +22 -0
- package/dist/column.module.2e29259c.js.map +1 -0
- package/dist/column.module.35184ea7.css +157 -0
- package/dist/column.module.35184ea7.css.map +1 -0
- package/dist/column.module.35ba04e7.js +34 -0
- package/dist/column.module.35ba04e7.js.map +1 -0
- package/dist/column.module.c9df6edf.css +138 -0
- package/dist/column.module.c9df6edf.css.map +1 -0
- package/dist/composite.494beffc.js +153 -0
- package/dist/composite.494beffc.js.map +1 -0
- package/dist/composite.module.5cc0e747.css +4 -0
- package/dist/composite.module.5cc0e747.css.map +1 -0
- package/dist/composite.module.6359deba.js +13 -0
- package/dist/composite.module.6359deba.js.map +1 -0
- package/dist/core.f3824dd8.js +89 -0
- package/dist/core.f3824dd8.js.map +1 -0
- package/dist/data-area.f9bb9ad9.js +86 -0
- package/dist/data-area.f9bb9ad9.js.map +1 -0
- package/dist/data-provider.61ef7f9a.js +25 -0
- package/dist/data-provider.61ef7f9a.js.map +1 -0
- package/dist/helpers.2af05ee4.js +94 -0
- package/dist/helpers.2af05ee4.js.map +1 -0
- package/dist/index.d.ts +363 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/index.module.8fad0020.js +37 -0
- package/dist/index.module.8fad0020.js.map +1 -0
- package/dist/index.module.de76feb2.css +65 -0
- package/dist/index.module.de76feb2.css.map +1 -0
- package/dist/isotopes-column.b5442b4d.js +163 -0
- package/dist/isotopes-column.b5442b4d.js.map +1 -0
- package/dist/layers.946aaa37.js +231 -0
- package/dist/layers.946aaa37.js.map +1 -0
- package/dist/map.e782010f.js +82 -0
- package/dist/map.e782010f.js.map +1 -0
- package/dist/names.ab14789e.js +65 -0
- package/dist/names.ab14789e.js.map +1 -0
- package/dist/providers.abcb2cbe.js +25 -0
- package/dist/providers.abcb2cbe.js.map +1 -0
- package/dist/resolvers.2949c4c0.js +83 -0
- package/dist/resolvers.2949c4c0.js.map +1 -0
- package/dist/section.6f6fc929.js +118 -0
- package/dist/section.6f6fc929.js.map +1 -0
- package/dist/selection-popover.7e008544.js +60 -0
- package/dist/selection-popover.7e008544.js.map +1 -0
- package/dist/selection-popover.module.2732ebc0.css +34 -0
- package/dist/selection-popover.module.2732ebc0.css.map +1 -0
- package/dist/selection-popover.module.fdbfb40e.js +22 -0
- package/dist/selection-popover.module.fdbfb40e.js.map +1 -0
- package/dist/selection.add9f8b0.js +117 -0
- package/dist/selection.add9f8b0.js.map +1 -0
- package/dist/store.c5271371.js +18 -0
- package/dist/store.c5271371.js.map +1 -0
- package/dist/types.ff938b22.js +18 -0
- package/dist/types.ff938b22.js.map +1 -0
- package/dist/unit-details.0c1edd00.js +209 -0
- package/dist/unit-details.0c1edd00.js.map +1 -0
- package/dist/units.5ec6a44c.js +42 -0
- package/dist/units.5ec6a44c.js.map +1 -0
- package/package.json +66 -0
- package/src/age-axis.ts +42 -0
- package/src/carbon-isotopes/column.module.sass +136 -0
- package/src/carbon-isotopes/column.ts +131 -0
- package/src/carbon-isotopes/core.ts +78 -0
- package/src/carbon-isotopes/data-area.ts +96 -0
- package/src/carbon-isotopes/data-provider.ts +19 -0
- package/src/carbon-isotopes/index.ts +3 -0
- package/src/carbon-isotopes/isotopes-column.ts +214 -0
- package/src/column.module.sass +114 -0
- package/src/column.ts +185 -0
- package/src/helpers.ts +133 -0
- package/src/index.ts +7 -0
- package/src/map/animated.ts +78 -0
- package/src/map/index.ts +86 -0
- package/src/map/layers.ts +316 -0
- package/src/providers.ts +34 -0
- package/src/section.ts +129 -0
- package/src/selection-popover.module.sass +27 -0
- package/src/selection-popover.ts +71 -0
- package/src/store.ts +12 -0
- package/src/unit-details/index.module.sass +51 -0
- package/src/unit-details/index.ts +215 -0
- package/src/units/boxes.module.sass +3 -0
- package/src/units/boxes.ts +221 -0
- package/src/units/composite.module.sass +2 -0
- package/src/units/composite.ts +266 -0
- package/src/units/index.ts +36 -0
- package/src/units/names.ts +118 -0
- package/src/units/resolvers.ts +111 -0
- package/src/units/selection.ts +167 -0
- package/src/units/types.ts +26 -0
- package/src/units/units.scss +16 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import $ge7AF$macrostrathyper from "@macrostrat/hyper";
|
|
2
|
+
import {getQueryString as $ge7AF$getQueryString, setQueryString as $ge7AF$setQueryString, useKeyHandler as $ge7AF$useKeyHandler} from "@macrostrat/ui-components";
|
|
3
|
+
import {createContext as $ge7AF$createContext, useContext as $ge7AF$useContext, useState as $ge7AF$useState, useMemo as $ge7AF$useMemo, useCallback as $ge7AF$useCallback, useEffect as $ge7AF$useEffect} from "react";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const $4d5d1c15f39f6a14$var$UnitSelectionContext = (0, $ge7AF$createContext)(null);
|
|
9
|
+
const $4d5d1c15f39f6a14$var$DispatchContext = (0, $ge7AF$createContext)(null);
|
|
10
|
+
function $4d5d1c15f39f6a14$export$77a278d5ca56e309() {
|
|
11
|
+
return (0, $ge7AF$useContext)($4d5d1c15f39f6a14$var$DispatchContext);
|
|
12
|
+
}
|
|
13
|
+
function $4d5d1c15f39f6a14$export$f0dd93f90aa8e5da() {
|
|
14
|
+
return (0, $ge7AF$useContext)($4d5d1c15f39f6a14$var$UnitSelectionContext);
|
|
15
|
+
}
|
|
16
|
+
function $4d5d1c15f39f6a14$export$f19d75b1d4b676a4(props) {
|
|
17
|
+
const { unit: unit, setUnit: setUnit, onUnitSelected: onUnitSelected, children: children } = props;
|
|
18
|
+
if (unit == null && setUnit == null) return (0, $ge7AF$macrostrathyper)($4d5d1c15f39f6a14$var$StatefulUnitSelectionProvider, props);
|
|
19
|
+
return (0, $ge7AF$macrostrathyper)($4d5d1c15f39f6a14$var$BaseUnitSelectionProvider, {
|
|
20
|
+
unit: unit,
|
|
21
|
+
setUnit: setUnit,
|
|
22
|
+
onUnitSelected: onUnitSelected
|
|
23
|
+
}, children);
|
|
24
|
+
}
|
|
25
|
+
function $4d5d1c15f39f6a14$var$StatefulUnitSelectionProvider(props) {
|
|
26
|
+
const [unit, setUnit] = (0, $ge7AF$useState)(null);
|
|
27
|
+
return (0, $ge7AF$macrostrathyper)($4d5d1c15f39f6a14$var$BaseUnitSelectionProvider, {
|
|
28
|
+
...props,
|
|
29
|
+
unit: unit,
|
|
30
|
+
setUnit: setUnit
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function $4d5d1c15f39f6a14$var$BaseUnitSelectionProvider({ children: children, unit: unit, setUnit: setUnit, onUnitSelected: onUnitSelected }) {
|
|
34
|
+
const value = (0, $ge7AF$useMemo)(()=>unit, [
|
|
35
|
+
unit?.unit_id
|
|
36
|
+
]);
|
|
37
|
+
const _onUnitSelected = (0, $ge7AF$useCallback)((u, target, event)=>{
|
|
38
|
+
let newUnit = u;
|
|
39
|
+
setUnit(newUnit);
|
|
40
|
+
onUnitSelected?.(newUnit, target, event);
|
|
41
|
+
}, [
|
|
42
|
+
setUnit,
|
|
43
|
+
onUnitSelected
|
|
44
|
+
]);
|
|
45
|
+
return (0, $ge7AF$macrostrathyper)($4d5d1c15f39f6a14$var$DispatchContext.Provider, {
|
|
46
|
+
value: _onUnitSelected
|
|
47
|
+
}, (0, $ge7AF$macrostrathyper)($4d5d1c15f39f6a14$var$UnitSelectionContext.Provider, {
|
|
48
|
+
value: value
|
|
49
|
+
}, children));
|
|
50
|
+
}
|
|
51
|
+
const $4d5d1c15f39f6a14$var$ColumnNavCtx = (0, $ge7AF$createContext)(null);
|
|
52
|
+
function $4d5d1c15f39f6a14$export$91cb5ac808759b34(defaultArgs = {
|
|
53
|
+
col_id: 495,
|
|
54
|
+
unit_id: null
|
|
55
|
+
}) {
|
|
56
|
+
const ctx = (0, $ge7AF$useContext)($4d5d1c15f39f6a14$var$ColumnNavCtx);
|
|
57
|
+
if (ctx != null) return ctx;
|
|
58
|
+
const [columnArgs, setColumnArgs] = (0, $ge7AF$useState)($4d5d1c15f39f6a14$var$extractColumnArgs((0, $ge7AF$getQueryString)(window.location.search)) ?? defaultArgs);
|
|
59
|
+
(0, $ge7AF$useEffect)(()=>(0, $ge7AF$setQueryString)(columnArgs), [
|
|
60
|
+
columnArgs
|
|
61
|
+
]);
|
|
62
|
+
const { col_id: col_id, project_id: project_id, status_code: status_code } = columnArgs;
|
|
63
|
+
const setCurrentColumn = (obj)=>{
|
|
64
|
+
let args = obj;
|
|
65
|
+
if ("properties" in obj) args = {
|
|
66
|
+
col_id: obj.properties.col_id,
|
|
67
|
+
project_id: project_id,
|
|
68
|
+
status_code: status_code
|
|
69
|
+
};
|
|
70
|
+
// Set query string
|
|
71
|
+
(0, $ge7AF$setQueryString)(args);
|
|
72
|
+
setColumnArgs(args);
|
|
73
|
+
};
|
|
74
|
+
return [
|
|
75
|
+
columnArgs,
|
|
76
|
+
setCurrentColumn
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
function $4d5d1c15f39f6a14$var$extractColumnArgs(search) {
|
|
80
|
+
const { col_id: col_id, unit_id: unit_id, project_id: project_id, status_code: status_code } = search;
|
|
81
|
+
if (col_id == null) return null;
|
|
82
|
+
return {
|
|
83
|
+
col_id: col_id,
|
|
84
|
+
unit_id: unit_id,
|
|
85
|
+
project_id: project_id,
|
|
86
|
+
status_code: status_code
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function $4d5d1c15f39f6a14$export$36fed9e0f93a8fde({ children: children, ...defaultArgs }) {
|
|
90
|
+
const value = $4d5d1c15f39f6a14$export$91cb5ac808759b34(defaultArgs);
|
|
91
|
+
return (0, $ge7AF$macrostrathyper)($4d5d1c15f39f6a14$var$ColumnNavCtx.Provider, {
|
|
92
|
+
value: value
|
|
93
|
+
}, children);
|
|
94
|
+
}
|
|
95
|
+
function $4d5d1c15f39f6a14$export$70f5ee19650fc7d1({ units: units }) {
|
|
96
|
+
const selectedUnit = $4d5d1c15f39f6a14$export$f0dd93f90aa8e5da();
|
|
97
|
+
const selectUnit = $4d5d1c15f39f6a14$export$77a278d5ca56e309();
|
|
98
|
+
const ix = units.findIndex((unit)=>unit.unit_id === selectedUnit?.unit_id);
|
|
99
|
+
const keyMap = {
|
|
100
|
+
38: ix - 1,
|
|
101
|
+
40: ix + 1
|
|
102
|
+
};
|
|
103
|
+
(0, $ge7AF$useKeyHandler)((event)=>{
|
|
104
|
+
const nextIx = keyMap[event.keyCode];
|
|
105
|
+
if (nextIx == null || nextIx < 0 || nextIx >= units.length) return;
|
|
106
|
+
selectUnit(units[nextIx], null, null);
|
|
107
|
+
event.stopPropagation();
|
|
108
|
+
}, [
|
|
109
|
+
units,
|
|
110
|
+
ix
|
|
111
|
+
]);
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
export {$4d5d1c15f39f6a14$export$77a278d5ca56e309 as useUnitSelectionDispatch, $4d5d1c15f39f6a14$export$f0dd93f90aa8e5da as useSelectedUnit, $4d5d1c15f39f6a14$export$f19d75b1d4b676a4 as UnitSelectionProvider, $4d5d1c15f39f6a14$export$91cb5ac808759b34 as useColumnNav, $4d5d1c15f39f6a14$export$36fed9e0f93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,SAAS;QACb,IAAI,KAAK;QACT,IAAI,KAAK;IACX;IAEA,CAAA,GAAA,oBAAY,EACV,CAAC;QACC,MAAM,SAAS,MAAM,CAAC,MAAM,OAAO,CAAC;QACpC,IAAI,UAAU,QAAQ,SAAS,KAAK,UAAU,MAAM,MAAM,EAAE;QAC5D,WAAW,KAAK,CAAC,OAAO,EAAE,MAAM;QAChC,MAAM,eAAe;IACvB,GACA;QAAC;QAAO;KAAG;IAEb,OAAO;AACT","sources":["packages/column-views/src/units/selection.ts"],"sourcesContent":["import { BaseUnit } from \"@macrostrat/api-types\";\nimport h from \"@macrostrat/hyper\";\nimport {\n getQueryString,\n setQueryString,\n useKeyHandler,\n} from \"@macrostrat/ui-components\";\nimport {\n Dispatch,\n SetStateAction,\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n ReactNode,\n useCallback,\n} from \"react\";\n\ntype UnitSelectDispatch = (\n unit: BaseUnit | null,\n target: HTMLElement | null,\n event: Event | null\n) => void;\n\nconst UnitSelectionContext = createContext<BaseUnit | null>(null);\nconst DispatchContext = createContext<UnitSelectDispatch | null>(null);\n\nexport function useUnitSelectionDispatch() {\n return useContext(DispatchContext);\n}\n\nexport function useSelectedUnit() {\n return useContext(UnitSelectionContext);\n}\n\nexport interface UnitSelectionProps<T extends BaseUnit> {\n children: React.ReactNode;\n unit: T | null;\n setUnit: Dispatch<SetStateAction<T>>;\n onUnitSelected?: (unit: T, target: HTMLElement, event: Event) => void;\n}\n\nexport function UnitSelectionProvider<T extends BaseUnit>(\n props: Partial<UnitSelectionProps<T>>\n) {\n const { unit, setUnit, onUnitSelected, children } = props;\n\n if (unit == null && setUnit == null) {\n return h(StatefulUnitSelectionProvider, props);\n }\n\n return h(\n BaseUnitSelectionProvider,\n { unit, setUnit, onUnitSelected },\n children\n );\n}\n\nfunction StatefulUnitSelectionProvider<T extends BaseUnit>(props: {\n children: ReactNode;\n onUnitSelected?: (unit: T, target: HTMLElement, event: Event) => void;\n}) {\n const [unit, setUnit] = useState<T | null>(null);\n\n return h(BaseUnitSelectionProvider, { ...props, unit, setUnit });\n}\n\nfunction BaseUnitSelectionProvider<T extends BaseUnit>({\n children,\n unit,\n setUnit,\n onUnitSelected,\n}: UnitSelectionProps<T>) {\n const value = useMemo(() => unit, [unit?.unit_id]);\n\n const _onUnitSelected = useCallback(\n (u: T, target: HTMLElement, event: Event) => {\n let newUnit = u;\n setUnit(newUnit);\n onUnitSelected?.(newUnit, target, event);\n },\n [setUnit, onUnitSelected]\n );\n\n return h(\n DispatchContext.Provider,\n { value: _onUnitSelected },\n h(UnitSelectionContext.Provider, { value }, children)\n );\n}\n\nexport interface ColumnArgs {\n col_id?: number;\n unit_id?: number;\n project_id?: number;\n status_code?: \"in process\";\n}\n\ntype ColumnManagerData = [ColumnArgs, (c: ColumnArgs) => void];\n\nconst ColumnNavCtx = createContext<ColumnManagerData | null>(null);\n\nexport function useColumnNav(\n defaultArgs: ColumnArgs = { col_id: 495, unit_id: null }\n): ColumnManagerData {\n const ctx = useContext(ColumnNavCtx);\n if (ctx != null) return ctx;\n\n const [columnArgs, setColumnArgs] = useState<ColumnArgs>(\n extractColumnArgs(getQueryString(window.location.search)) ?? defaultArgs\n );\n\n useEffect(() => setQueryString(columnArgs), [columnArgs]);\n\n const { col_id, project_id, status_code } = columnArgs;\n\n const setCurrentColumn = (obj) => {\n let args = obj;\n if (\"properties\" in obj) {\n args = { col_id: obj.properties.col_id, project_id, status_code };\n }\n // Set query string\n setQueryString(args);\n setColumnArgs(args);\n };\n\n return [columnArgs, setCurrentColumn];\n}\n\nfunction extractColumnArgs(search: any): ColumnArgs | null {\n const { col_id, unit_id, project_id, status_code } = search;\n if (col_id == null) return null;\n return { col_id, unit_id, project_id, status_code };\n}\n\nexport function ColumnNavProvider({ children, ...defaultArgs }) {\n const value = useColumnNav(defaultArgs as any);\n return h(ColumnNavCtx.Provider, { value }, children);\n}\n\nexport function UnitKeyboardNavigation<T extends BaseUnit>({\n units,\n}: {\n units: T[];\n}) {\n const selectedUnit = useSelectedUnit();\n const selectUnit = useUnitSelectionDispatch();\n\n const ix = units.findIndex((unit) => unit.unit_id === selectedUnit?.unit_id);\n\n const keyMap = {\n 38: ix - 1,\n 40: ix + 1,\n };\n\n useKeyHandler(\n (event) => {\n const nextIx = keyMap[event.keyCode];\n if (nextIx == null || nextIx < 0 || nextIx >= units.length) return;\n selectUnit(units[nextIx], null, null);\n event.stopPropagation();\n },\n [units, ix]\n );\n return null;\n}\n"],"names":[],"version":3,"file":"selection.add9f8b0.js.map"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {createContext as $3Bwds$createContext, useContext as $3Bwds$useContext} from "react";
|
|
2
|
+
import $3Bwds$macrostrathyper from "@macrostrat/hyper";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const $1fcb9b8d7da394a3$var$MacrostratUnitsContext = (0, $3Bwds$createContext)(null);
|
|
7
|
+
function $1fcb9b8d7da394a3$export$e5fe24ae4f287040({ children: children, units: units }) {
|
|
8
|
+
return (0, $3Bwds$macrostrathyper)($1fcb9b8d7da394a3$var$MacrostratUnitsContext.Provider, {
|
|
9
|
+
value: units
|
|
10
|
+
}, children);
|
|
11
|
+
}
|
|
12
|
+
function $1fcb9b8d7da394a3$export$6fb40844db555b2() {
|
|
13
|
+
return (0, $3Bwds$useContext)($1fcb9b8d7da394a3$var$MacrostratUnitsContext);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export {$1fcb9b8d7da394a3$export$e5fe24ae4f287040 as MacrostratUnitsProvider, $1fcb9b8d7da394a3$export$6fb40844db555b2 as useMacrostratUnits};
|
|
18
|
+
//# sourceMappingURL=store.c5271371.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;AAGA,MAAM,+CAAyB,CAAA,GAAA,oBAAY,EAAE;AAEtC,SAAS,0CAAwB,YAAE,QAAQ,SAAE,KAAK,EAAE;IACzD,OAAO,CAAA,GAAA,sBAAA,EAAE,6CAAuB,QAAQ,EAAE;QAAE,OAAO;IAAM,GAAG;AAC9D;AAEO,SAAS;IACd,OAAO,CAAA,GAAA,iBAAS,EAAE;AACpB","sources":["packages/column-views/src/store.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport h from \"@macrostrat/hyper\";\n\nconst MacrostratUnitsContext = createContext(null);\n\nexport function MacrostratUnitsProvider({ children, units }) {\n return h(MacrostratUnitsContext.Provider, { value: units }, children);\n}\n\nexport function useMacrostratUnits() {\n return useContext(MacrostratUnitsContext);\n}\n"],"names":[],"version":3,"file":"store.c5271371.js.map"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var $faf1eba02aecac6a$export$6d217bb9de27dba7 = /*#__PURE__*/ function(MacrostratAxisKey) {
|
|
2
|
+
MacrostratAxisKey["AGE"] = "age";
|
|
3
|
+
MacrostratAxisKey["POS"] = "pos";
|
|
4
|
+
return MacrostratAxisKey;
|
|
5
|
+
}($faf1eba02aecac6a$export$6d217bb9de27dba7 || {});
|
|
6
|
+
function $faf1eba02aecac6a$export$ab2a19f8a72df19b(t) {
|
|
7
|
+
switch(t){
|
|
8
|
+
case "age":
|
|
9
|
+
return "age";
|
|
10
|
+
case "height":
|
|
11
|
+
case "depth":
|
|
12
|
+
return "pos";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export {$faf1eba02aecac6a$export$6d217bb9de27dba7 as MacrostratAxisKey, $faf1eba02aecac6a$export$ab2a19f8a72df19b as transformAxisType};
|
|
18
|
+
//# sourceMappingURL=types.ff938b22.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAUA,IAAA,AAAK,mEAAA;;;WAAA;EAAA;AAKL,SAAS,0CAAkB,CAAiB;IAC1C,OAAQ;QACN,KAAK;YACH;QACF,KAAK;QACL,KAAK;YACH;IACJ;AACF","sources":["packages/column-views/src/units/types.ts"],"sourcesContent":["import { ColumnAxisType } from \"@macrostrat/column-components\";\nexport interface IUnit {\n unit_id: number;\n col_id: number;\n section_id: number;\n t_age: number;\n b_age: number;\n [x: string]: any;\n}\n\nenum MacrostratAxisKey {\n AGE = \"age\",\n POS = \"pos\"\n}\n\nfunction transformAxisType(t: ColumnAxisType): MacrostratAxisKey {\n switch (t) {\n case \"age\":\n return MacrostratAxisKey.AGE;\n case \"height\":\n case \"depth\":\n return MacrostratAxisKey.POS;\n }\n}\n\nexport { MacrostratAxisKey, transformAxisType };\n"],"names":[],"version":3,"file":"types.ff938b22.js.map"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import "./index.module.de76feb2.css";
|
|
2
|
+
import $33VLW$indexmodule8fad0020js from "./index.module.8fad0020.js";
|
|
3
|
+
import {useUnitSelectionDispatch as $4d5d1c15f39f6a14$export$77a278d5ca56e309} from "./selection.add9f8b0.js";
|
|
4
|
+
import {useMacrostratUnits as $1fcb9b8d7da394a3$export$6fb40844db555b2} from "./store.c5271371.js";
|
|
5
|
+
import $33VLW$macrostrathyper from "@macrostrat/hyper";
|
|
6
|
+
import {JSONView as $33VLW$JSONView} from "@macrostrat/ui-components";
|
|
7
|
+
import {Button as $33VLW$Button} from "@blueprintjs/core";
|
|
8
|
+
import {useState as $33VLW$useState} from "react";
|
|
9
|
+
import {DataField as $33VLW$DataField, LithologyList as $33VLW$LithologyList, EnvironmentsList as $33VLW$EnvironmentsList, ItemList as $33VLW$ItemList, Interval as $33VLW$Interval} from "@macrostrat/data-components";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
function $parcel$interopDefault(a) {
|
|
13
|
+
return a && a.__esModule ? a.default : a;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const $5e9557c2513b08ab$var$h = (0, $33VLW$macrostrathyper).styled((0, ($parcel$interopDefault($33VLW$indexmodule8fad0020js))));
|
|
24
|
+
function $5e9557c2513b08ab$export$fbd245232df17557({ unit: unit, onClose: onClose }) {
|
|
25
|
+
const [showJSON, setShowJSON] = (0, $33VLW$useState)(false);
|
|
26
|
+
let content = null;
|
|
27
|
+
if (showJSON) content = $5e9557c2513b08ab$var$h((0, $33VLW$JSONView), {
|
|
28
|
+
data: unit,
|
|
29
|
+
showRoot: false
|
|
30
|
+
});
|
|
31
|
+
else content = $5e9557c2513b08ab$var$h($5e9557c2513b08ab$var$UnitDetailsContent, {
|
|
32
|
+
unit: unit
|
|
33
|
+
});
|
|
34
|
+
return $5e9557c2513b08ab$var$h("div.unit-details-panel", [
|
|
35
|
+
$5e9557c2513b08ab$var$h($5e9557c2513b08ab$export$fc503c39cc5cff43, {
|
|
36
|
+
onClose: onClose,
|
|
37
|
+
title: unit.unit_name,
|
|
38
|
+
id: unit.unit_id,
|
|
39
|
+
actions: [
|
|
40
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$Button), {
|
|
41
|
+
icon: "code",
|
|
42
|
+
small: true,
|
|
43
|
+
minimal: true,
|
|
44
|
+
className: "json-view-toggle",
|
|
45
|
+
onClick () {
|
|
46
|
+
setShowJSON(!showJSON);
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
]
|
|
50
|
+
}),
|
|
51
|
+
$5e9557c2513b08ab$var$h("div.unit-details-content", [
|
|
52
|
+
content
|
|
53
|
+
])
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
function $5e9557c2513b08ab$export$fc503c39cc5cff43({ title: title, id: id, onClose: onClose, actions: actions = null }) {
|
|
57
|
+
return $5e9557c2513b08ab$var$h("header.legend-panel-header", [
|
|
58
|
+
$5e9557c2513b08ab$var$h.if(title != null)("h3", title),
|
|
59
|
+
$5e9557c2513b08ab$var$h("div.spacer"),
|
|
60
|
+
$5e9557c2513b08ab$var$h.if(id != null)("code", id),
|
|
61
|
+
actions,
|
|
62
|
+
$5e9557c2513b08ab$var$h.if(onClose != null)((0, $33VLW$Button), {
|
|
63
|
+
icon: "cross",
|
|
64
|
+
minimal: true,
|
|
65
|
+
small: true,
|
|
66
|
+
onClick () {
|
|
67
|
+
onClose();
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
function $5e9557c2513b08ab$var$UnitDetailsContent({ unit: unit }) {
|
|
73
|
+
let outcrop = unit.outcrop;
|
|
74
|
+
if (outcrop == "both") outcrop = "surface and subsurface";
|
|
75
|
+
return $5e9557c2513b08ab$var$h("div.unit-details-content", [
|
|
76
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$DataField), {
|
|
77
|
+
label: "Thickness",
|
|
78
|
+
value: `${unit.min_thick}\u{2013}${unit.max_thick}`,
|
|
79
|
+
unit: "m"
|
|
80
|
+
}),
|
|
81
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$LithologyList), {
|
|
82
|
+
lithologies: unit.lith
|
|
83
|
+
}),
|
|
84
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$DataField), {
|
|
85
|
+
label: "Age range",
|
|
86
|
+
value: `${unit.b_age}\u{2013}${unit.t_age}`,
|
|
87
|
+
unit: "Ma"
|
|
88
|
+
}),
|
|
89
|
+
$5e9557c2513b08ab$var$h($5e9557c2513b08ab$var$IntervalField, {
|
|
90
|
+
unit: unit
|
|
91
|
+
}),
|
|
92
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$EnvironmentsList), {
|
|
93
|
+
environments: unit.environ
|
|
94
|
+
}),
|
|
95
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$DataField), {
|
|
96
|
+
label: "Outcrop",
|
|
97
|
+
value: outcrop
|
|
98
|
+
}),
|
|
99
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$DataField), {
|
|
100
|
+
label: "Stratigraphic name"
|
|
101
|
+
}, $5e9557c2513b08ab$var$h("span.strat-name-id", unit.strat_name_id)),
|
|
102
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$DataField), {
|
|
103
|
+
label: "Above"
|
|
104
|
+
}, $5e9557c2513b08ab$var$h($5e9557c2513b08ab$var$UnitIDList, {
|
|
105
|
+
units: unit.units_above
|
|
106
|
+
})),
|
|
107
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$DataField), {
|
|
108
|
+
label: "Below"
|
|
109
|
+
}, $5e9557c2513b08ab$var$h($5e9557c2513b08ab$var$UnitIDList, {
|
|
110
|
+
units: unit.units_below
|
|
111
|
+
})),
|
|
112
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$DataField), {
|
|
113
|
+
label: "Color"
|
|
114
|
+
}, $5e9557c2513b08ab$var$h("span.color-swatch", {
|
|
115
|
+
style: {
|
|
116
|
+
backgroundColor: unit.color
|
|
117
|
+
}
|
|
118
|
+
}))
|
|
119
|
+
]);
|
|
120
|
+
}
|
|
121
|
+
function $5e9557c2513b08ab$var$UnitIDList({ units: units }) {
|
|
122
|
+
const u1 = units.filter((d)=>d != 0);
|
|
123
|
+
const dispatch = (0, $4d5d1c15f39f6a14$export$77a278d5ca56e309)();
|
|
124
|
+
const allUnits = (0, $1fcb9b8d7da394a3$export$6fb40844db555b2)();
|
|
125
|
+
if (u1.length === 0) return $5e9557c2513b08ab$var$h("span.no-units", "None");
|
|
126
|
+
let onClickHandler = null;
|
|
127
|
+
let tag = "span";
|
|
128
|
+
if (dispatch != null) {
|
|
129
|
+
onClickHandler = (id)=>(evt)=>{
|
|
130
|
+
console.log(units);
|
|
131
|
+
const unit = allUnits.find((d)=>d.unit_id == id);
|
|
132
|
+
dispatch(unit, null, null);
|
|
133
|
+
evt.stopPropagation();
|
|
134
|
+
};
|
|
135
|
+
tag = "a";
|
|
136
|
+
}
|
|
137
|
+
return $5e9557c2513b08ab$var$h((0, $33VLW$ItemList), {
|
|
138
|
+
className: "unit-id-list"
|
|
139
|
+
}, [
|
|
140
|
+
u1.map((unit)=>{
|
|
141
|
+
return $5e9557c2513b08ab$var$h(tag, {
|
|
142
|
+
className: "unit-id",
|
|
143
|
+
onClick: onClickHandler?.(unit)
|
|
144
|
+
}, unit);
|
|
145
|
+
})
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
function $5e9557c2513b08ab$var$IntervalField({ unit: unit }) {
|
|
149
|
+
return $5e9557c2513b08ab$var$h([
|
|
150
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$DataField), {
|
|
151
|
+
label: "Intervals"
|
|
152
|
+
}, $5e9557c2513b08ab$var$h($5e9557c2513b08ab$var$IntervalProportions, {
|
|
153
|
+
unit: unit
|
|
154
|
+
}))
|
|
155
|
+
]);
|
|
156
|
+
}
|
|
157
|
+
function $5e9557c2513b08ab$var$IntervalProportions({ unit: unit }) {
|
|
158
|
+
const i0 = unit.b_int_id;
|
|
159
|
+
const i1 = unit.t_int_id;
|
|
160
|
+
let b_prop = unit.b_prop ?? 0;
|
|
161
|
+
let t_prop = unit.t_prop ?? 1;
|
|
162
|
+
if (i0 === i1 && b_prop === 0 && t_prop === 1) // We have a single interval with undefined proportions
|
|
163
|
+
return $5e9557c2513b08ab$var$h((0, $33VLW$Interval), {
|
|
164
|
+
interval: {
|
|
165
|
+
id: i0,
|
|
166
|
+
name: unit.b_int_name
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return $5e9557c2513b08ab$var$h((0, $33VLW$ItemList), {
|
|
170
|
+
className: "interval-proportions"
|
|
171
|
+
}, [
|
|
172
|
+
$5e9557c2513b08ab$var$h($5e9557c2513b08ab$var$Proportion, {
|
|
173
|
+
value: b_prop
|
|
174
|
+
}),
|
|
175
|
+
$5e9557c2513b08ab$var$h.if(i0 != i1)((0, $33VLW$Interval), {
|
|
176
|
+
interval: {
|
|
177
|
+
id: i0,
|
|
178
|
+
name: unit.b_int_name
|
|
179
|
+
},
|
|
180
|
+
proportion: b_prop
|
|
181
|
+
}),
|
|
182
|
+
$5e9557c2513b08ab$var$h("span.sep", "to"),
|
|
183
|
+
$5e9557c2513b08ab$var$h($5e9557c2513b08ab$var$Proportion, {
|
|
184
|
+
value: t_prop
|
|
185
|
+
}),
|
|
186
|
+
$5e9557c2513b08ab$var$h((0, $33VLW$Interval), {
|
|
187
|
+
interval: {
|
|
188
|
+
id: i1,
|
|
189
|
+
name: unit.t_int_name
|
|
190
|
+
},
|
|
191
|
+
proportion: t_prop
|
|
192
|
+
})
|
|
193
|
+
]);
|
|
194
|
+
}
|
|
195
|
+
const $5e9557c2513b08ab$var$formatProportion = (d)=>{
|
|
196
|
+
if (d == null) return null;
|
|
197
|
+
return d.toFixed(1);
|
|
198
|
+
};
|
|
199
|
+
function $5e9557c2513b08ab$var$Proportion({ value: value }) {
|
|
200
|
+
let content = null;
|
|
201
|
+
if (value == 0) content = "base";
|
|
202
|
+
else if (value == 1) content = "top";
|
|
203
|
+
else content = $5e9557c2513b08ab$var$formatProportion(value * 100) + "%";
|
|
204
|
+
return $5e9557c2513b08ab$var$h("span.proportion", content);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
export {$5e9557c2513b08ab$export$fbd245232df17557 as UnitDetailsPanel, $5e9557c2513b08ab$export$fc503c39cc5cff43 as LegendPanelHeader};
|
|
209
|
+
//# sourceMappingURL=unit-details.0c1edd00.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeA,MAAM,0BAAI,CAAA,GAAA,sBAAI,EAAE,MAAM,CAAC,CAAA,GAAA,uEAAK;AAErB,SAAS,0CAAiB,QAC/B,IAAI,WACJ,OAAO,EAIR;IACC,MAAM,CAAC,UAAU,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE;IAEzC,IAAI,UAAU;IACd,IAAI,UACF,UAAU,wBAAE,CAAA,GAAA,eAAO,GAAG;QAAE,MAAM;QAAM,UAAU;IAAM;SAEpD,UAAU,wBAAE,0CAAoB;cAAE;IAAK;IAGzC,OAAO,wBAAE,0BAA0B;QACjC,wBAAE,2CAAmB;qBACnB;YACA,OAAO,KAAK,SAAS;YACrB,IAAI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AAI,EAAE;IACnC,MAAM,KAAK,KAAK,QAAQ;IACxB,MAAM,KAAK,KAAK,QAAQ;IACxB,IAAI,SAAS,KAAK,MAAM,IAAI;IAC5B,IAAI,SAAS,KAAK,MAAM,IAAI;IAE5B,IAAI,OAAO,MAAM,WAAW,KAAK,WAAW,GAC1C,uDAAuD;IACvD,OAAO,wBAAE,CAAA,GAAA,eAAO,GAAG;QACjB,UAAU;YACR,IAAI;YACJ,MAAM,KAAK,UAAU;QACvB;IACF;IAGF,OAAO,wBAAE,CAAA,GAAA,eAAO,GAAG;QAAE,WAAW;IAAuB,GAAG;QACxD,wBAAE,kCAAY;YAAE,OAAO;QAAO;QAC9B,wBAAE,EAAE,CAAC,MAAM,IAAI,CAAA,GAAA,eAAO,GAAG;YACvB,UAAU;gBACR,IAAI;gBACJ,MAAM,KAAK,UAAU;YACvB;YACA,YAAY;QACd;QACA,wBAAE,YAAY;QACd,wBAAE,kCAAY;YAAE,OAAO;QAAO;QAC9B,wBAAE,CAAA,GAAA,eAAO,GAAG;YACV,UAAU;gBACR,IAAI;gBACJ,MAAM,KAAK,UAAU;YACvB;YACA,YAAY;QACd;KACD;AACH;AAEA,MAAM,yCAAmB,CAAC;IACxB,IAAI,KAAK,MAAM,OAAO;IACtB,OAAO,EAAE,OAAO,CAAC;AACnB;AAEA,SAAS,iCAAW,SAAE,KAAK,EAAE;IAC3B,IAAI,UAAU;IACd,IAAI,SAAS,GACX,UAAU;SACL,IAAI,SAAS,GAClB,UAAU;SAEV,UAAU,uCAAiB,QAAQ,OAAO;IAG5C,OAAO,wBAAE,mBAAmB;AAC9B","sources":["packages/column-views/src/unit-details/index.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport styles from \"./index.module.sass\";\nimport { JSONView } from \"@macrostrat/ui-components\";\nimport { Button } from \"@blueprintjs/core\";\nimport { useState } from \"react\";\nimport {\n DataField,\n EnvironmentsList,\n Interval,\n ItemList,\n LithologyList,\n} from \"@macrostrat/data-components\";\nimport { useUnitSelectionDispatch } from \"../units/selection\";\nimport { useMacrostratUnits } from \"../store\";\n\nconst h = hyper.styled(styles);\n\nexport function UnitDetailsPanel({\n unit,\n onClose,\n}: {\n unit: any;\n onClose?: any;\n}) {\n const [showJSON, setShowJSON] = useState(false);\n\n let content = null;\n if (showJSON) {\n content = h(JSONView, { data: unit, showRoot: false });\n } else {\n content = h(UnitDetailsContent, { unit });\n }\n\n return h(\"div.unit-details-panel\", [\n h(LegendPanelHeader, {\n onClose,\n title: unit.unit_name,\n id: unit.unit_id,\n actions: [\n h(Button, {\n icon: \"code\",\n small: true,\n minimal: true,\n className: \"json-view-toggle\",\n onClick() {\n setShowJSON(!showJSON);\n },\n }),\n ],\n }),\n h(\"div.unit-details-content\", [content]),\n ]);\n}\n\nexport function LegendPanelHeader({ title, id, onClose, actions = null }) {\n return h(\"header.legend-panel-header\", [\n h.if(title != null)(\"h3\", title),\n h(\"div.spacer\"),\n h.if(id != null)(\"code\", id),\n actions,\n h.if(onClose != null)(Button, {\n icon: \"cross\",\n minimal: true,\n small: true,\n onClick() {\n onClose();\n },\n }),\n ]);\n}\n\nfunction UnitDetailsContent({ unit }) {\n let outcrop = unit.outcrop;\n if (outcrop == \"both\") {\n outcrop = \"surface and subsurface\";\n }\n\n return h(\"div.unit-details-content\", [\n h(DataField, {\n label: \"Thickness\",\n value: `${unit.min_thick}–${unit.max_thick}`,\n unit: \"m\",\n }),\n h(LithologyList, { lithologies: unit.lith }),\n h(DataField, {\n label: \"Age range\",\n value: `${unit.b_age}–${unit.t_age}`,\n unit: \"Ma\",\n }),\n h(IntervalField, { unit }),\n h(EnvironmentsList, { environments: unit.environ }),\n h(DataField, { label: \"Outcrop\", value: outcrop }),\n h(\n DataField,\n {\n label: \"Stratigraphic name\",\n },\n h(\"span.strat-name-id\", unit.strat_name_id)\n ),\n h(\n DataField,\n { label: \"Above\" },\n h(UnitIDList, { units: unit.units_above })\n ),\n h(\n DataField,\n { label: \"Below\" },\n h(UnitIDList, { units: unit.units_below })\n ),\n h(\n DataField,\n { label: \"Color\" },\n h(\"span.color-swatch\", { style: { backgroundColor: unit.color } })\n ),\n ]);\n}\n\nfunction UnitIDList({ units }) {\n const u1 = units.filter((d) => d != 0);\n const dispatch = useUnitSelectionDispatch();\n const allUnits = useMacrostratUnits();\n\n if (u1.length === 0) {\n return h(\"span.no-units\", \"None\");\n }\n\n let onClickHandler = null;\n let tag = \"span\";\n if (dispatch != null) {\n onClickHandler = (id: number) => (evt) => {\n console.log(units);\n const unit = allUnits.find((d) => d.unit_id == id);\n dispatch(unit, null, null);\n evt.stopPropagation();\n };\n tag = \"a\";\n }\n\n return h(ItemList, { className: \"unit-id-list\" }, [\n u1.map((unit) => {\n return h(\n tag,\n { className: \"unit-id\", onClick: onClickHandler?.(unit) },\n unit\n );\n }),\n ]);\n}\n\nfunction IntervalField({ unit }) {\n return h([\n h(\n DataField,\n {\n label: \"Intervals\",\n },\n h(IntervalProportions, { unit })\n ),\n ]);\n}\n\nfunction IntervalProportions({ unit }) {\n const i0 = unit.b_int_id;\n const i1 = unit.t_int_id;\n let b_prop = unit.b_prop ?? 0;\n let t_prop = unit.t_prop ?? 1;\n\n if (i0 === i1 && b_prop === 0 && t_prop === 1) {\n // We have a single interval with undefined proportions\n return h(Interval, {\n interval: {\n id: i0,\n name: unit.b_int_name,\n },\n });\n }\n\n return h(ItemList, { className: \"interval-proportions\" }, [\n h(Proportion, { value: b_prop }),\n h.if(i0 != i1)(Interval, {\n interval: {\n id: i0,\n name: unit.b_int_name,\n },\n proportion: b_prop,\n }),\n h(\"span.sep\", \"to\"),\n h(Proportion, { value: t_prop }),\n h(Interval, {\n interval: {\n id: i1,\n name: unit.t_int_name,\n },\n proportion: t_prop,\n }),\n ]);\n}\n\nconst formatProportion = (d) => {\n if (d == null) return null;\n return d.toFixed(1);\n};\n\nfunction Proportion({ value }) {\n let content = null;\n if (value == 0) {\n content = \"base\";\n } else if (value == 1) {\n content = \"top\";\n } else {\n content = formatProportion(value * 100) + \"%\";\n }\n\n return h(\"span.proportion\", content);\n}\n"],"names":[],"version":3,"file":"unit-details.0c1edd00.js.map"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {UnitNamesColumn as $bc17276da4abb183$export$594d19cdd88f8c16} from "./names.ab14789e.js";
|
|
2
|
+
import {UnitBoxes as $d254716a820e9c85$export$5d1cdfabe8dc8085} from "./boxes.6d3192e6.js";
|
|
3
|
+
import {TrackedLabeledUnit as $8c8238faa5cde49c$export$f613830566442374, AnnotatedUnitsColumn as $8c8238faa5cde49c$export$d8c3f2fdd653a082, CompositeUnitsColumn as $8c8238faa5cde49c$export$a6684360fef0406e, CompositeUnitComponent as $8c8238faa5cde49c$export$1dfa200d57964eee} from "./composite.494beffc.js";
|
|
4
|
+
import {MacrostratAxisKey as $faf1eba02aecac6a$export$6d217bb9de27dba7, transformAxisType as $faf1eba02aecac6a$export$ab2a19f8a72df19b} from "./types.ff938b22.js";
|
|
5
|
+
import {useUnitSelectionDispatch as $4d5d1c15f39f6a14$export$77a278d5ca56e309, useSelectedUnit as $4d5d1c15f39f6a14$export$f0dd93f90aa8e5da, UnitSelectionProvider as $4d5d1c15f39f6a14$export$f19d75b1d4b676a4, useColumnNav as $4d5d1c15f39f6a14$export$91cb5ac808759b34, ColumnNavProvider as $4d5d1c15f39f6a14$export$36fed9e0f93a8fde, UnitKeyboardNavigation as $4d5d1c15f39f6a14$export$70f5ee19650fc7d1} from "./selection.add9f8b0.js";
|
|
6
|
+
import $1FQbq$macrostrathyper from "@macrostrat/hyper";
|
|
7
|
+
import {LithologyColumn as $1FQbq$LithologyColumn} from "@macrostrat/column-components";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const $4c8184c4a7317749$export$3750278673318c9a = ({ width: width = 100 })=>{
|
|
17
|
+
/*
|
|
18
|
+
A column showing units with USGS color fill
|
|
19
|
+
*/ return (0, $1FQbq$macrostrathyper)((0, $1FQbq$LithologyColumn), {
|
|
20
|
+
width: width
|
|
21
|
+
}, (0, $1FQbq$macrostrathyper)((0, $d254716a820e9c85$export$5d1cdfabe8dc8085)));
|
|
22
|
+
};
|
|
23
|
+
const $4c8184c4a7317749$export$2006342ddaa547c6 = (props)=>{
|
|
24
|
+
/*
|
|
25
|
+
A column with units and names either
|
|
26
|
+
overlapping or offset to the right
|
|
27
|
+
*/ const { columnWidth: columnWidth, width: width, gutterWidth: gutterWidth = 0, labelOffset: labelOffset = 30 } = props;
|
|
28
|
+
return (0, $1FQbq$macrostrathyper)([
|
|
29
|
+
(0, $1FQbq$macrostrathyper)($4c8184c4a7317749$export$3750278673318c9a, {
|
|
30
|
+
width: columnWidth
|
|
31
|
+
}),
|
|
32
|
+
(0, $1FQbq$macrostrathyper)((0, $bc17276da4abb183$export$594d19cdd88f8c16), {
|
|
33
|
+
transform: `translate(${columnWidth + gutterWidth})`,
|
|
34
|
+
paddingLeft: labelOffset,
|
|
35
|
+
width: width - columnWidth - gutterWidth
|
|
36
|
+
})
|
|
37
|
+
]);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
export {$4c8184c4a7317749$export$3750278673318c9a as UnitsColumn, $4c8184c4a7317749$export$2006342ddaa547c6 as SimpleUnitsColumn, $8c8238faa5cde49c$export$f613830566442374 as TrackedLabeledUnit, $8c8238faa5cde49c$export$d8c3f2fdd653a082 as AnnotatedUnitsColumn, $8c8238faa5cde49c$export$a6684360fef0406e as CompositeUnitsColumn, $8c8238faa5cde49c$export$1dfa200d57964eee as CompositeUnitComponent, $faf1eba02aecac6a$export$6d217bb9de27dba7 as MacrostratAxisKey, $faf1eba02aecac6a$export$ab2a19f8a72df19b as transformAxisType, $4d5d1c15f39f6a14$export$77a278d5ca56e309 as useUnitSelectionDispatch, $4d5d1c15f39f6a14$export$f0dd93f90aa8e5da as useSelectedUnit, $4d5d1c15f39f6a14$export$f19d75b1d4b676a4 as UnitSelectionProvider, $4d5d1c15f39f6a14$export$91cb5ac808759b34 as useColumnNav, $4d5d1c15f39f6a14$export$36fed9e0f93a8fde as ColumnNavProvider, $4d5d1c15f39f6a14$export$70f5ee19650fc7d1 as UnitKeyboardNavigation};
|
|
42
|
+
//# sourceMappingURL=units.5ec6a44c.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAMA,MAAM,4CAAc,CAAC,SAAE,QAAQ,KAAK;IAClC;;EAEA,GACA,OAAO,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,sBAAc,GAAG;eAAE;IAAM,GAAG,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,yCAAQ;AACjD;AAEA,MAAM,4CAAoB,CAAC;IACzB;;;EAGA,GACA,MAAM,eAAE,WAAW,SAAE,KAAK,eAAE,cAAc,gBAAG,cAAc,IAAI,GAAG;IAElE,OAAO,CAAA,GAAA,sBAAA,EAAE;QACP,CAAA,GAAA,sBAAA,EAAE,2CAAa;YACb,OAAO;QACT;QACA,CAAA,GAAA,sBAAA,EAAE,CAAA,GAAA,yCAAc,GAAG;YACjB,WAAW,CAAC,UAAU,EAAE,cAAc,YAAY,CAAC,CAAC;YACpD,aAAa;YACb,OAAO,QAAQ,cAAc;QAC/B;KACD;AACH","sources":["packages/column-views/src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport { LithologyColumn } from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes } from \"./boxes\";\n\nconst UnitsColumn = ({ width = 100 }) => {\n /*\n A column showing units with USGS color fill\n */\n return h(LithologyColumn, { width }, h(UnitBoxes));\n};\n\nconst SimpleUnitsColumn = (props: ICompositeUnitProps) => {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const { columnWidth, width, gutterWidth = 0, labelOffset = 30 } = props;\n\n return h([\n h(UnitsColumn, {\n width: columnWidth,\n }),\n h(UnitNamesColumn, {\n transform: `translate(${columnWidth + gutterWidth})`,\n paddingLeft: labelOffset,\n width: width - columnWidth - gutterWidth,\n }),\n ]);\n};\n\nexport { UnitsColumn, SimpleUnitsColumn };\nexport * from \"./composite\";\nexport * from \"./types\";\nexport * from \"./selection\";\n"],"names":[],"version":3,"file":"units.5ec6a44c.js.map"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@macrostrat/column-views",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Data views for Macrostrat stratigraphic columns",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"source": "src/index.ts",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"**/*.css"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"source": "./src/index.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "rm -rf dist && parcel build"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@macrostrat/api-types": "^1.0.0",
|
|
24
|
+
"@macrostrat/column-components": "^1.0.0",
|
|
25
|
+
"@macrostrat/data-components": "^0.0.5",
|
|
26
|
+
"@macrostrat/hyper": "^3.0.6",
|
|
27
|
+
"@macrostrat/stratigraphy-utils": "^1.0.0",
|
|
28
|
+
"@macrostrat/svg-map-components": "^1.0.0",
|
|
29
|
+
"@macrostrat/timescale": "^2.1.0",
|
|
30
|
+
"@macrostrat/ui-components": "^4.1.0",
|
|
31
|
+
"@types/chroma-js": "^3",
|
|
32
|
+
"@types/d3-format": "^3",
|
|
33
|
+
"@types/d3-geo": "^3",
|
|
34
|
+
"@types/d3-shape": "^3",
|
|
35
|
+
"@types/topojson-client": "^3.1.5",
|
|
36
|
+
"@visx/axis": "^3.12.0",
|
|
37
|
+
"chroma-js": "^3.1.2",
|
|
38
|
+
"classnames": "^2.5.1",
|
|
39
|
+
"d3-array": "^3.2.4",
|
|
40
|
+
"d3-format": "^3.1.0",
|
|
41
|
+
"d3-geo": "^3.1.1",
|
|
42
|
+
"d3-geo-voronoi": "^2.1.0",
|
|
43
|
+
"d3-shape": "^3.2.0",
|
|
44
|
+
"react-spring": "^9.7.5",
|
|
45
|
+
"topojson-client": "^3.1.0",
|
|
46
|
+
"zustand": "^5.0.3"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@blueprintjs/core": "^3.43.0 || ^4.3.0 || ^5.0.0",
|
|
50
|
+
"react": "^16.8.6||^17.0.0||^18.0.0"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/UW-Macrostrat/web-components.git",
|
|
55
|
+
"directory": "packages/column-views"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"parcel": "^2.13.3",
|
|
59
|
+
"postcss": "^8.0.0",
|
|
60
|
+
"postcss-modules": "^6.0.0"
|
|
61
|
+
},
|
|
62
|
+
"files": [
|
|
63
|
+
"dist",
|
|
64
|
+
"src"
|
|
65
|
+
]
|
|
66
|
+
}
|
package/src/age-axis.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import h from "@macrostrat/hyper";
|
|
2
|
+
import {
|
|
3
|
+
ColumnSVG,
|
|
4
|
+
ColumnAxis,
|
|
5
|
+
ColumnContext,
|
|
6
|
+
} from "@macrostrat/column-components";
|
|
7
|
+
import { useContext } from "react";
|
|
8
|
+
// import "@macrostrat/timescale/dist/timescale.css";
|
|
9
|
+
//
|
|
10
|
+
const AgeAxisCore = ({ ticks, tickSpacing = 40, showDomain = false }) => {
|
|
11
|
+
const { pixelHeight } = useContext(ColumnContext);
|
|
12
|
+
// A tick roughly every 40 pixels
|
|
13
|
+
let v = Math.max(Math.round(pixelHeight / tickSpacing), 1);
|
|
14
|
+
|
|
15
|
+
return h("g.axis", { transform: "translate(20 0)" }, [
|
|
16
|
+
h(ColumnAxis, {
|
|
17
|
+
ticks: v,
|
|
18
|
+
showDomain,
|
|
19
|
+
}),
|
|
20
|
+
]);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function AgeAxis(props) {
|
|
24
|
+
const {
|
|
25
|
+
ticks,
|
|
26
|
+
tickSpacing,
|
|
27
|
+
showLabel = true,
|
|
28
|
+
paddingV = 10,
|
|
29
|
+
showDomain,
|
|
30
|
+
...rest
|
|
31
|
+
} = props;
|
|
32
|
+
|
|
33
|
+
// Not sure where this extra 5px comes from.
|
|
34
|
+
return h("div.column.age-axis", [
|
|
35
|
+
h.if(showLabel)("div.age-axis-label", "Age (Ma)"),
|
|
36
|
+
h(
|
|
37
|
+
ColumnSVG,
|
|
38
|
+
{ paddingV, ...rest },
|
|
39
|
+
h(AgeAxisCore, { ticks, tickSpacing, showDomain })
|
|
40
|
+
),
|
|
41
|
+
]);
|
|
42
|
+
}
|