@macrostrat/column-views 3.1.0 → 3.2.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 +6 -0
- package/dist/age-axis.js +2 -2
- package/dist/age-axis.js.map +1 -1
- package/dist/age-axis.module.sass.cjs +6 -1
- package/dist/age-axis.module.sass.cjs.map +1 -1
- package/dist/age-axis.module.sass.js +4 -1
- package/dist/age-axis.module.sass.js.map +1 -1
- package/dist/age-model-overlay.js +2 -2
- package/dist/age-model-overlay.js.map +1 -1
- package/dist/age-model-overlay.module.sass.cjs +6 -1
- package/dist/age-model-overlay.module.sass.cjs.map +1 -1
- package/dist/age-model-overlay.module.sass.js +4 -1
- package/dist/age-model-overlay.module.sass.js.map +1 -1
- package/dist/column.js +2 -2
- package/dist/column.js.map +1 -1
- package/dist/column.module.sass.cjs +6 -1
- package/dist/column.module.sass.cjs.map +1 -1
- package/dist/column.module.sass.js +4 -1
- package/dist/column.module.sass.js.map +1 -1
- package/dist/correlation-chart/main.js +2 -2
- package/dist/correlation-chart/main.js.map +1 -1
- package/dist/correlation-chart/main.module.sass.cjs +6 -1
- package/dist/correlation-chart/main.module.sass.cjs.map +1 -1
- package/dist/correlation-chart/main.module.sass.js +4 -1
- package/dist/correlation-chart/main.module.sass.js.map +1 -1
- package/dist/data-provider/store.cjs +1 -1
- package/dist/data-provider/store.cjs.map +1 -1
- package/dist/data-provider/store.js +1 -1
- package/dist/data-provider/store.js.map +1 -1
- package/dist/facets/carbon-isotopes/isotopes-column.js +2 -2
- package/dist/facets/carbon-isotopes/isotopes-column.js.map +1 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.cjs +6 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.cjs.map +1 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.js +4 -1
- package/dist/facets/carbon-isotopes/isotopes-column.module.sass.js.map +1 -1
- package/dist/facets/detrital-zircon/index.js +2 -2
- package/dist/facets/detrital-zircon/index.js.map +1 -1
- package/dist/facets/detrital-zircon/index.module.sass.cjs +6 -1
- package/dist/facets/detrital-zircon/index.module.sass.cjs.map +1 -1
- package/dist/facets/detrital-zircon/index.module.sass.js +4 -1
- package/dist/facets/detrital-zircon/index.module.sass.js.map +1 -1
- package/dist/facets/fossils/index.js +2 -2
- package/dist/facets/fossils/index.js.map +1 -1
- package/dist/facets/fossils/taxon-ranges.js +2 -2
- package/dist/facets/fossils/taxon-ranges.js.map +1 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.cjs +6 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.cjs.map +1 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.js +4 -1
- package/dist/facets/fossils/taxon-ranges.module.sass.js.map +1 -1
- package/dist/facets/measurements/base.js +2 -2
- package/dist/facets/measurements/base.js.map +1 -1
- package/dist/facets/measurements/base.module.sass.cjs +6 -1
- package/dist/facets/measurements/base.module.sass.cjs.map +1 -1
- package/dist/facets/measurements/base.module.sass.js +4 -1
- package/dist/facets/measurements/base.module.sass.js.map +1 -1
- package/dist/index.cjs +10 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/maps/_shared/styles.cjs +6 -1
- package/dist/maps/_shared/styles.cjs.map +1 -1
- package/dist/maps/_shared/styles.js +6 -1
- package/dist/maps/_shared/styles.js.map +1 -1
- package/dist/maps/column-navigation/mapbox/keyboard-navigation.d.ts +1 -1
- package/dist/maps/index.d.ts +1 -0
- package/dist/maps/units-overlay/index.cjs +254 -0
- package/dist/maps/units-overlay/index.cjs.map +1 -0
- package/dist/maps/units-overlay/index.d.ts +14 -0
- package/dist/maps/units-overlay/index.js +252 -0
- package/dist/maps/units-overlay/index.js.map +1 -0
- package/dist/section.js +2 -2
- package/dist/section.js.map +1 -1
- package/dist/unit-details/panel.js +2 -2
- package/dist/unit-details/panel.js.map +1 -1
- package/dist/unit-details/panel.module.sass.cjs +6 -1
- package/dist/unit-details/panel.module.sass.cjs.map +1 -1
- package/dist/unit-details/panel.module.sass.js +4 -1
- package/dist/unit-details/panel.module.sass.js.map +1 -1
- package/dist/unit-details/popover.js +2 -2
- package/dist/unit-details/popover.js.map +1 -1
- package/dist/unit-details/popover.module.sass.cjs +6 -1
- package/dist/unit-details/popover.module.sass.cjs.map +1 -1
- package/dist/unit-details/popover.module.sass.js +4 -1
- package/dist/unit-details/popover.module.sass.js.map +1 -1
- package/dist/units/boxes.js +2 -2
- package/dist/units/boxes.js.map +1 -1
- package/dist/units/boxes.module.sass.cjs +6 -1
- package/dist/units/boxes.module.sass.cjs.map +1 -1
- package/dist/units/boxes.module.sass.js +4 -1
- package/dist/units/boxes.module.sass.js.map +1 -1
- package/dist/units/colors.cjs +79 -18
- package/dist/units/colors.cjs.map +1 -1
- package/dist/units/colors.d.ts +17 -4
- package/dist/units/colors.js +79 -18
- package/dist/units/colors.js.map +1 -1
- package/dist/units/composite.js +2 -2
- package/dist/units/composite.js.map +1 -1
- package/dist/units/composite.module.sass.cjs +6 -1
- package/dist/units/composite.module.sass.cjs.map +1 -1
- package/dist/units/composite.module.sass.js +4 -1
- package/dist/units/composite.module.sass.js.map +1 -1
- package/dist/units/index.cjs +2 -0
- package/dist/units/index.cjs.map +1 -1
- package/dist/units/index.js +3 -0
- package/dist/units/index.js.map +1 -1
- package/dist/units/resolvers.cjs +11 -0
- package/dist/units/resolvers.cjs.map +1 -1
- package/dist/units/resolvers.d.ts +5 -0
- package/dist/units/resolvers.js +11 -0
- package/dist/units/resolvers.js.map +1 -1
- package/package.json +10 -9
- package/src/data-provider/store.ts +1 -0
- package/src/maps/_shared/styles.ts +10 -3
- package/src/maps/index.ts +1 -0
- package/src/maps/unit-map.stories.ts +64 -0
- package/src/maps/units-overlay/index.ts +336 -0
- package/src/units/colors.ts +137 -25
- package/src/units/resolvers.ts +16 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.cjs","sources":["../../src/units/colors.ts"],"sourcesContent":["import chroma from \"chroma-js\";\nimport {
|
|
1
|
+
{"version":3,"file":"colors.cjs","sources":["../../src/units/colors.ts"],"sourcesContent":["import chroma from \"chroma-js\";\nimport {\n Environment,\n Lithology,\n UnitLithology,\n UnitLong,\n} from \"@macrostrat/api-types\";\n\ninterface KeyOptions {\n key?: \"lith\" | \"environ\";\n id_key?: \"lith_id\" | \"environ_id\";\n}\n\nexport function getMixedUnitColor(\n unit: UnitLong,\n lithMap: Map<number, { color: string }>,\n inDarkMode = false,\n asBackground = true,\n keyOpts: KeyOptions = null,\n): string | null {\n const { key = \"lith\", id_key = \"lith_id\" } = keyOpts ?? {};\n const liths = unit[key];\n const getColor = (data: UnitLithology): string | null => {\n return lithMap?.get(data[id_key])?.color ?? null;\n };\n\n return getMixedColorForData(liths, getColor, {\n inDarkMode,\n asBackground,\n key: id_key,\n });\n}\n\ninterface ColorBuilderOptions {\n key?: \"lith_id\" | \"environ_id\";\n inDarkMode?: boolean;\n asBackground?: boolean;\n}\n\nexport function flattenLithologies<\n T extends { prop: number | null; lith_id?: number; environ_id?: number },\n>(liths: T[][], normalize: boolean = true): T[] {\n /** Unify proportions in lithology/environment data across several units, normalizing if needed.\n * If normalize is true, proportions are scaled to sum to 1 within each unit (with remaining proportions\n * distributed equally among liths without specified proportions). This helps ensure that units with a\n * few lithologies with specified proportions don't skew the color mixing.\n *\n * Lithologies are deduplicated based on their identifying property (lith_id or environ_id) if that is present.\n */\n if (liths == null || liths.length === 0) {\n return [];\n }\n\n const unitCount = liths.length;\n\n let newLiths: T[] = [];\n for (const unitLiths of liths) {\n let l1 = unitLiths;\n if (normalize) {\n l1 = addProportionsToAllData(unitLiths);\n }\n // Divide proportions by number of units to balance influence\n for (const lith of l1) {\n if (lith.prop == null || isNaN(lith.prop) || lith.prop <= 0) {\n continue;\n }\n lith.prop = lith.prop / unitCount;\n }\n newLiths.push(...l1);\n }\n if (newLiths[0]?.lith_id != null) {\n newLiths = mergeLikeData(newLiths, \"lith_id\");\n } else if (newLiths[0]?.environ_id != null) {\n newLiths = mergeLikeData(newLiths, \"environ_id\");\n }\n // Sort by proportion descending\n newLiths.sort((a, b) => b.prop - a.prop);\n return newLiths;\n}\n\nexport function getMixedColorForData<\n T extends UnitLithology | Lithology | Environment,\n>(\n liths: T[] | null,\n getColor: (val: T) => string | null,\n options: ColorBuilderOptions = {},\n): string | null {\n const { inDarkMode = false, asBackground = true } = options;\n if (liths == null || liths.length === 0) {\n return null;\n }\n const lithData = liths\n .map((d) => {\n let prop = d.prop;\n if (prop == null || isNaN(prop) || prop <= 0) {\n prop = null;\n }\n return {\n ...d,\n prop,\n color: getColor?.(d) ?? d.color,\n };\n })\n .filter((d) => d.color != null);\n\n if (lithData.length == 0) {\n return null;\n }\n\n const lithsWithProp = addProportionsToAllData(lithData);\n\n // Mix colors proportionally\n const baseColor = chroma.average(\n lithsWithProp.map((d) => d.color),\n \"lrgb\",\n lithsWithProp.map((d) => d.prop),\n );\n\n if (!asBackground) {\n return baseColor.hex();\n }\n\n if (inDarkMode) {\n return baseColor.set(\"hsl.l\", 0.2).hex();\n } else {\n return baseColor.set(\"hsl.l\", 0.9).hex();\n }\n}\n\nfunction addProportionsToAllData<T extends { prop?: number }>(liths: T[]): T[] {\n /** Make sure that all lithologies/environments have a defined proportion,\n * and that proportions sum to 1. If some liths lack a defined proportion,\n * the remaining proportion is distributed equally among them.\n *\n * NOTE: This function does not normalize proportions if they already sum to more than 1.\n */\n const lithsWithProp = liths.filter((d) => d.prop != null);\n const lithsWithoutProp = liths.filter((d) => d.prop == null);\n\n const totalProp = lithsWithProp.reduce((sum, d) => sum + d.prop, 0);\n let overallTotal = 1;\n\n if (totalProp < overallTotal && lithsWithoutProp.length > 0) {\n const remainingProp = overallTotal - totalProp;\n // Distribute remaining proportion equally among liths without prop\n const equalProp = remainingProp / lithsWithoutProp.length;\n lithsWithoutProp.forEach((d) => {\n lithsWithProp.push({\n ...d,\n prop: equalProp,\n } as T);\n });\n }\n return lithsWithProp as T[];\n}\n\nfunction mergeLikeData<\n T extends { prop: number; lith_id?: number; environ_id?: number },\n>(liths: T[], key: \"lith_id\" | \"environ_id\"): T[] {\n /** Merge lithology/environment data with the same identifying property (lith_id or environ_id),\n * summing their proportions.\n *\n * TODO: handle attribute merging\n */\n const mergedMap: Map<number, T> = new Map();\n\n for (const lith of liths) {\n const id = lith[key];\n if (id == null) continue;\n\n if (mergedMap.has(id)) {\n const existing = mergedMap.get(id);\n mergedMap.set(id, {\n ...existing,\n prop: existing.prop + lith.prop,\n });\n } else {\n mergedMap.set(id, { ...lith });\n }\n }\n\n return Array.from(mergedMap.values());\n}\n"],"names":["chroma"],"mappings":";;;;;AAaO,SAAS,kBACd,MACA,SACA,aAAa,OACb,eAAe,MACf,UAAsB,MACP;AACf,QAAM,EAAE,MAAM,QAAQ,SAAS,UAAA,IAAc,WAAW,CAAA;AACxD,QAAM,QAAQ,KAAK,GAAG;AACtB,QAAM,WAAW,CAAC,SAAuC;AACvD,WAAO,SAAS,IAAI,KAAK,MAAM,CAAC,GAAG,SAAS;AAAA,EAC9C;AAEA,SAAO,qBAAqB,OAAO,UAAU;AAAA,IAC3C;AAAA,IACA;AAAA,EAEF,CAAC;AACH;AAQO,SAAS,mBAEd,OAAc,YAAqB,MAAW;AAQ9C,MAAI,SAAS,QAAQ,MAAM,WAAW,GAAG;AACvC,WAAO,CAAA;AAAA,EACT;AAEA,QAAM,YAAY,MAAM;AAExB,MAAI,WAAgB,CAAA;AACpB,aAAW,aAAa,OAAO;AAC7B,QAAI,KAAK;AACT,QAAI,WAAW;AACb,WAAK,wBAAwB,SAAS;AAAA,IACxC;AAEA,eAAW,QAAQ,IAAI;AACrB,UAAI,KAAK,QAAQ,QAAQ,MAAM,KAAK,IAAI,KAAK,KAAK,QAAQ,GAAG;AAC3D;AAAA,MACF;AACA,WAAK,OAAO,KAAK,OAAO;AAAA,IAC1B;AACA,aAAS,KAAK,GAAG,EAAE;AAAA,EACrB;AACA,MA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D,QAAM,mBAAmB,MAAM,OAAO,CAAC,MAAM,EAAE,QAAQ,IAAI;AAE3D,QAAM,YAAY,cAAc,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,MAAM,CAAC;AAClE,MAAI,eAAe;AAEnB,MAAI,YAAY,gBAAgB,iBAAiB,SAAS,GAAG;AAC3D,UAAM,gBAAgB,eAAe;AAErC,UAAM,YAAY,gBAAgB,iBAAiB;AACnD,qBAAiB,QAAQ,CAAC,MAAM;AAC9B,oBAAc,KAAK;AAAA,QACjB,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACF;AAAA,IACR,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,SAAS,cAEP,OAAY,KAAoC;AAMhD,QAAM,gCAAgC,IAAA;AAEtC,aAAW,QAAQ,OAAO;AACxB,UAAM,KAAK,KAAK,GAAG;AACnB,QAAI,MAAM,KAAM;AAEhB,QAAI,UAAU,IAAI,EAAE,GAAG;AACrB,YAAM,WAAW,UAAU,IAAI,EAAE;AACjC,gBAAU,IAAI,IAAI;AAAA,QAChB,GAAG;AAAA,QACH,MAAM,SAAS,OAAO,KAAK;AAAA,MAAA,CAC5B;AAAA,IACH,OAAO;AACL,gBAAU,IAAI,IAAI,EAAE,GAAG,MAAM;AAAA,IAC/B;AAAA,EACF;AAEA,SAAO,MAAM,KAAK,UAAU,OAAA,CAAQ;AACtC;;;;"}
|
package/dist/units/colors.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
import { UnitLong } from '@macrostrat/api-types';
|
|
1
|
+
import { Environment, Lithology, UnitLithology, UnitLong } from '@macrostrat/api-types';
|
|
2
2
|
interface KeyOptions {
|
|
3
|
-
key?:
|
|
4
|
-
id_key?:
|
|
3
|
+
key?: "lith" | "environ";
|
|
4
|
+
id_key?: "lith_id" | "environ_id";
|
|
5
5
|
}
|
|
6
|
-
export declare function getMixedUnitColor(unit: UnitLong, lithMap:
|
|
6
|
+
export declare function getMixedUnitColor(unit: UnitLong, lithMap: Map<number, {
|
|
7
|
+
color: string;
|
|
8
|
+
}>, inDarkMode?: boolean, asBackground?: boolean, keyOpts?: KeyOptions): string | null;
|
|
9
|
+
interface ColorBuilderOptions {
|
|
10
|
+
key?: "lith_id" | "environ_id";
|
|
11
|
+
inDarkMode?: boolean;
|
|
12
|
+
asBackground?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function flattenLithologies<T extends {
|
|
15
|
+
prop: number | null;
|
|
16
|
+
lith_id?: number;
|
|
17
|
+
environ_id?: number;
|
|
18
|
+
}>(liths: T[][], normalize?: boolean): T[];
|
|
19
|
+
export declare function getMixedColorForData<T extends UnitLithology | Lithology | Environment>(liths: T[] | null, getColor: (val: T) => string | null, options?: ColorBuilderOptions): string | null;
|
|
7
20
|
export {};
|
package/dist/units/colors.js
CHANGED
|
@@ -2,8 +2,45 @@ import chroma from "chroma-js";
|
|
|
2
2
|
function getMixedUnitColor(unit, lithMap, inDarkMode = false, asBackground = true, keyOpts = null) {
|
|
3
3
|
const { key = "lith", id_key = "lith_id" } = keyOpts ?? {};
|
|
4
4
|
const liths = unit[key];
|
|
5
|
-
|
|
6
|
-
return
|
|
5
|
+
const getColor = (data) => {
|
|
6
|
+
return lithMap?.get(data[id_key])?.color ?? null;
|
|
7
|
+
};
|
|
8
|
+
return getMixedColorForData(liths, getColor, {
|
|
9
|
+
inDarkMode,
|
|
10
|
+
asBackground
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function flattenLithologies(liths, normalize = true) {
|
|
14
|
+
if (liths == null || liths.length === 0) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
const unitCount = liths.length;
|
|
18
|
+
let newLiths = [];
|
|
19
|
+
for (const unitLiths of liths) {
|
|
20
|
+
let l1 = unitLiths;
|
|
21
|
+
if (normalize) {
|
|
22
|
+
l1 = addProportionsToAllData(unitLiths);
|
|
23
|
+
}
|
|
24
|
+
for (const lith of l1) {
|
|
25
|
+
if (lith.prop == null || isNaN(lith.prop) || lith.prop <= 0) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
lith.prop = lith.prop / unitCount;
|
|
29
|
+
}
|
|
30
|
+
newLiths.push(...l1);
|
|
31
|
+
}
|
|
32
|
+
if (newLiths[0]?.lith_id != null) {
|
|
33
|
+
newLiths = mergeLikeData(newLiths, "lith_id");
|
|
34
|
+
} else if (newLiths[0]?.environ_id != null) {
|
|
35
|
+
newLiths = mergeLikeData(newLiths, "environ_id");
|
|
36
|
+
}
|
|
37
|
+
newLiths.sort((a, b) => b.prop - a.prop);
|
|
38
|
+
return newLiths;
|
|
39
|
+
}
|
|
40
|
+
function getMixedColorForData(liths, getColor, options = {}) {
|
|
41
|
+
const { inDarkMode = false, asBackground = true } = options;
|
|
42
|
+
if (liths == null || liths.length === 0) {
|
|
43
|
+
return null;
|
|
7
44
|
}
|
|
8
45
|
const lithData = liths.map((d) => {
|
|
9
46
|
let prop = d.prop;
|
|
@@ -11,27 +48,15 @@ function getMixedUnitColor(unit, lithMap, inDarkMode = false, asBackground = tru
|
|
|
11
48
|
prop = null;
|
|
12
49
|
}
|
|
13
50
|
return {
|
|
14
|
-
|
|
51
|
+
...d,
|
|
15
52
|
prop,
|
|
16
|
-
color:
|
|
53
|
+
color: getColor?.(d) ?? d.color
|
|
17
54
|
};
|
|
18
55
|
}).filter((d) => d.color != null);
|
|
19
|
-
|
|
20
|
-
const lithsWithoutProp = lithData.filter((d) => d.prop == null);
|
|
21
|
-
const totalProp = lithsWithProp.reduce((sum, d) => sum + d.prop, 0);
|
|
22
|
-
if (totalProp < 1 && lithsWithoutProp.length > 0) {
|
|
23
|
-
const remainingProp = 1 - totalProp;
|
|
24
|
-
const equalProp = remainingProp / lithsWithoutProp.length;
|
|
25
|
-
lithsWithoutProp.forEach((d) => {
|
|
26
|
-
lithsWithProp.push({
|
|
27
|
-
...d,
|
|
28
|
-
prop: equalProp
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
if (lithsWithProp.length == 0) {
|
|
56
|
+
if (lithData.length == 0) {
|
|
33
57
|
return null;
|
|
34
58
|
}
|
|
59
|
+
const lithsWithProp = addProportionsToAllData(lithData);
|
|
35
60
|
const baseColor = chroma.average(
|
|
36
61
|
lithsWithProp.map((d) => d.color),
|
|
37
62
|
"lrgb",
|
|
@@ -46,7 +71,43 @@ function getMixedUnitColor(unit, lithMap, inDarkMode = false, asBackground = tru
|
|
|
46
71
|
return baseColor.set("hsl.l", 0.9).hex();
|
|
47
72
|
}
|
|
48
73
|
}
|
|
74
|
+
function addProportionsToAllData(liths) {
|
|
75
|
+
const lithsWithProp = liths.filter((d) => d.prop != null);
|
|
76
|
+
const lithsWithoutProp = liths.filter((d) => d.prop == null);
|
|
77
|
+
const totalProp = lithsWithProp.reduce((sum, d) => sum + d.prop, 0);
|
|
78
|
+
let overallTotal = 1;
|
|
79
|
+
if (totalProp < overallTotal && lithsWithoutProp.length > 0) {
|
|
80
|
+
const remainingProp = overallTotal - totalProp;
|
|
81
|
+
const equalProp = remainingProp / lithsWithoutProp.length;
|
|
82
|
+
lithsWithoutProp.forEach((d) => {
|
|
83
|
+
lithsWithProp.push({
|
|
84
|
+
...d,
|
|
85
|
+
prop: equalProp
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return lithsWithProp;
|
|
90
|
+
}
|
|
91
|
+
function mergeLikeData(liths, key) {
|
|
92
|
+
const mergedMap = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const lith of liths) {
|
|
94
|
+
const id = lith[key];
|
|
95
|
+
if (id == null) continue;
|
|
96
|
+
if (mergedMap.has(id)) {
|
|
97
|
+
const existing = mergedMap.get(id);
|
|
98
|
+
mergedMap.set(id, {
|
|
99
|
+
...existing,
|
|
100
|
+
prop: existing.prop + lith.prop
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
mergedMap.set(id, { ...lith });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return Array.from(mergedMap.values());
|
|
107
|
+
}
|
|
49
108
|
export {
|
|
109
|
+
flattenLithologies,
|
|
110
|
+
getMixedColorForData,
|
|
50
111
|
getMixedUnitColor
|
|
51
112
|
};
|
|
52
113
|
//# sourceMappingURL=colors.js.map
|
package/dist/units/colors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sources":["../../src/units/colors.ts"],"sourcesContent":["import chroma from \"chroma-js\";\nimport {
|
|
1
|
+
{"version":3,"file":"colors.js","sources":["../../src/units/colors.ts"],"sourcesContent":["import chroma from \"chroma-js\";\nimport {\n Environment,\n Lithology,\n UnitLithology,\n UnitLong,\n} from \"@macrostrat/api-types\";\n\ninterface KeyOptions {\n key?: \"lith\" | \"environ\";\n id_key?: \"lith_id\" | \"environ_id\";\n}\n\nexport function getMixedUnitColor(\n unit: UnitLong,\n lithMap: Map<number, { color: string }>,\n inDarkMode = false,\n asBackground = true,\n keyOpts: KeyOptions = null,\n): string | null {\n const { key = \"lith\", id_key = \"lith_id\" } = keyOpts ?? {};\n const liths = unit[key];\n const getColor = (data: UnitLithology): string | null => {\n return lithMap?.get(data[id_key])?.color ?? null;\n };\n\n return getMixedColorForData(liths, getColor, {\n inDarkMode,\n asBackground,\n key: id_key,\n });\n}\n\ninterface ColorBuilderOptions {\n key?: \"lith_id\" | \"environ_id\";\n inDarkMode?: boolean;\n asBackground?: boolean;\n}\n\nexport function flattenLithologies<\n T extends { prop: number | null; lith_id?: number; environ_id?: number },\n>(liths: T[][], normalize: boolean = true): T[] {\n /** Unify proportions in lithology/environment data across several units, normalizing if needed.\n * If normalize is true, proportions are scaled to sum to 1 within each unit (with remaining proportions\n * distributed equally among liths without specified proportions). This helps ensure that units with a\n * few lithologies with specified proportions don't skew the color mixing.\n *\n * Lithologies are deduplicated based on their identifying property (lith_id or environ_id) if that is present.\n */\n if (liths == null || liths.length === 0) {\n return [];\n }\n\n const unitCount = liths.length;\n\n let newLiths: T[] = [];\n for (const unitLiths of liths) {\n let l1 = unitLiths;\n if (normalize) {\n l1 = addProportionsToAllData(unitLiths);\n }\n // Divide proportions by number of units to balance influence\n for (const lith of l1) {\n if (lith.prop == null || isNaN(lith.prop) || lith.prop <= 0) {\n continue;\n }\n lith.prop = lith.prop / unitCount;\n }\n newLiths.push(...l1);\n }\n if (newLiths[0]?.lith_id != null) {\n newLiths = mergeLikeData(newLiths, \"lith_id\");\n } else if (newLiths[0]?.environ_id != null) {\n newLiths = mergeLikeData(newLiths, \"environ_id\");\n }\n // Sort by proportion descending\n newLiths.sort((a, b) => b.prop - a.prop);\n return newLiths;\n}\n\nexport function getMixedColorForData<\n T extends UnitLithology | Lithology | Environment,\n>(\n liths: T[] | null,\n getColor: (val: T) => string | null,\n options: ColorBuilderOptions = {},\n): string | null {\n const { inDarkMode = false, asBackground = true } = options;\n if (liths == null || liths.length === 0) {\n return null;\n }\n const lithData = liths\n .map((d) => {\n let prop = d.prop;\n if (prop == null || isNaN(prop) || prop <= 0) {\n prop = null;\n }\n return {\n ...d,\n prop,\n color: getColor?.(d) ?? d.color,\n };\n })\n .filter((d) => d.color != null);\n\n if (lithData.length == 0) {\n return null;\n }\n\n const lithsWithProp = addProportionsToAllData(lithData);\n\n // Mix colors proportionally\n const baseColor = chroma.average(\n lithsWithProp.map((d) => d.color),\n \"lrgb\",\n lithsWithProp.map((d) => d.prop),\n );\n\n if (!asBackground) {\n return baseColor.hex();\n }\n\n if (inDarkMode) {\n return baseColor.set(\"hsl.l\", 0.2).hex();\n } else {\n return baseColor.set(\"hsl.l\", 0.9).hex();\n }\n}\n\nfunction addProportionsToAllData<T extends { prop?: number }>(liths: T[]): T[] {\n /** Make sure that all lithologies/environments have a defined proportion,\n * and that proportions sum to 1. If some liths lack a defined proportion,\n * the remaining proportion is distributed equally among them.\n *\n * NOTE: This function does not normalize proportions if they already sum to more than 1.\n */\n const lithsWithProp = liths.filter((d) => d.prop != null);\n const lithsWithoutProp = liths.filter((d) => d.prop == null);\n\n const totalProp = lithsWithProp.reduce((sum, d) => sum + d.prop, 0);\n let overallTotal = 1;\n\n if (totalProp < overallTotal && lithsWithoutProp.length > 0) {\n const remainingProp = overallTotal - totalProp;\n // Distribute remaining proportion equally among liths without prop\n const equalProp = remainingProp / lithsWithoutProp.length;\n lithsWithoutProp.forEach((d) => {\n lithsWithProp.push({\n ...d,\n prop: equalProp,\n } as T);\n });\n }\n return lithsWithProp as T[];\n}\n\nfunction mergeLikeData<\n T extends { prop: number; lith_id?: number; environ_id?: number },\n>(liths: T[], key: \"lith_id\" | \"environ_id\"): T[] {\n /** Merge lithology/environment data with the same identifying property (lith_id or environ_id),\n * summing their proportions.\n *\n * TODO: handle attribute merging\n */\n const mergedMap: Map<number, T> = new Map();\n\n for (const lith of liths) {\n const id = lith[key];\n if (id == null) continue;\n\n if (mergedMap.has(id)) {\n const existing = mergedMap.get(id);\n mergedMap.set(id, {\n ...existing,\n prop: existing.prop + lith.prop,\n });\n } else {\n mergedMap.set(id, { ...lith });\n }\n }\n\n return Array.from(mergedMap.values());\n}\n"],"names":[],"mappings":";AAaO,SAAS,kBACd,MACA,SACA,aAAa,OACb,eAAe,MACf,UAAsB,MACP;AACf,QAAM,EAAE,MAAM,QAAQ,SAAS,UAAA,IAAc,WAAW,CAAA;AACxD,QAAM,QAAQ,KAAK,GAAG;AACtB,QAAM,WAAW,CAAC,SAAuC;AACvD,WAAO,SAAS,IAAI,KAAK,MAAM,CAAC,GAAG,SAAS;AAAA,EAC9C;AAEA,SAAO,qBAAqB,OAAO,UAAU;AAAA,IAC3C;AAAA,IACA;AAAA,EAEF,CAAC;AACH;AAQO,SAAS,mBAEd,OAAc,YAAqB,MAAW;AAQ9C,MAAI,SAAS,QAAQ,MAAM,WAAW,GAAG;AACvC,WAAO,CAAA;AAAA,EACT;AAEA,QAAM,YAAY,MAAM;AAExB,MAAI,WAAgB,CAAA;AACpB,aAAW,aAAa,OAAO;AAC7B,QAAI,KAAK;AACT,QAAI,WAAW;AACb,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,YAAY;AACd,WAAO,UAAU,IAAI,SAAS,GAAG,EAAE,IAAA;AAAA,EACrC,OAAO;AACL,WAAO,UAAU,IAAI,SAAS,GAAG,EAAE,IAAA;AAAA,EACrC;AACF;AAEA,SAAS,wBAAqD,OAAiB;AAO7E,QAAM,gBAAgB,MAAM,OAAO,CAAC,MAAM,EAAE,QAAQ,IAAI;AACxD,QAAM,mBAAmB,MAAM,OAAO,CAAC,MAAM,EAAE,QAAQ,IAAI;AAE3D,QAAM,YAAY,cAAc,OAAO,CAAC,KAAK,MAAM,MAAM,EAAE,MAAM,CAAC;AAClE,MAAI,eAAe;AAEnB,MAAI,YAAY,gBAAgB,iBAAiB,SAAS,GAAG;AAC3D,UAAM,gBAAgB,eAAe;AAErC,UAAM,YAAY,gBAAgB,iBAAiB;AACnD,qBAAiB,QAAQ,CAAC,MAAM;AAC9B,oBAAc,KAAK;AAAA,QACjB,GAAG;AAAA,QACH,MAAM;AAAA,MAAA,CACF;AAAA,IACR,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,SAAS,cAEP,OAAY,KAAoC;AAMhD,QAAM,gCAAgC,IAAA;AAEtC,aAAW,QAAQ,OAAO;AACxB,UAAM,KAAK,KAAK,GAAG;AACnB,QAAI,MAAM,KAAM;AAEhB,QAAI,UAAU,IAAI,EAAE,GAAG;AACrB,YAAM,WAAW,UAAU,IAAI,EAAE;AACjC,gBAAU,IAAI,IAAI;AAAA,QAChB,GAAG;AAAA,QACH,MAAM,SAAS,OAAO,KAAK;AAAA,MAAA,CAC5B;AAAA,IACH,OAAO;AACL,gBAAU,IAAI,IAAI,EAAE,GAAG,MAAM;AAAA,IAC/B;AAAA,EACF;AAEA,SAAO,MAAM,KAAK,UAAU,OAAA,CAAQ;AACtC;"}
|
package/dist/units/composite.js
CHANGED
|
@@ -3,10 +3,10 @@ import { ColumnContext, LithologyColumn, SVG } from "@macrostrat/column-componen
|
|
|
3
3
|
import { defaultNameFunction, UnitNamesColumn } from "./names.js";
|
|
4
4
|
import { useEffect, useContext, useState, useRef, useCallback, createContext } from "react";
|
|
5
5
|
import { LabeledUnit, UnitBoxes } from "./boxes.js";
|
|
6
|
-
import
|
|
6
|
+
import h$1 from "./composite.module.sass.js";
|
|
7
7
|
import { useUnitSelectionDispatch } from "../data-provider/unit-selection.js";
|
|
8
8
|
import { useMacrostratColumnData, useCompositeScale } from "../data-provider/store.js";
|
|
9
|
-
const h = hyperStyled(
|
|
9
|
+
const h = hyperStyled(h$1);
|
|
10
10
|
const LabelTrackerContext = createContext(null);
|
|
11
11
|
const UnlabeledDivisionsContext = createContext(null);
|
|
12
12
|
const findMacrostratUnitID = (u) => u.unit_id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composite.js","sources":["../../src/units/composite.ts"],"sourcesContent":["import { hyperStyled } from \"@macrostrat/hyper\";\nimport {\n ColumnContext,\n LithologyColumn,\n SVG,\n} from \"@macrostrat/column-components\";\nimport { defaultNameFunction, UnitNamesColumn } from \"./names\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { LabeledUnit, UnitBoxes } from \"./boxes\";\nimport styles from \"./composite.module.sass\";\nimport {\n useCompositeScale,\n useMacrostratColumnData,\n useUnitSelectionDispatch,\n} from \"../data-provider\";\n\nconst h = hyperStyled(styles);\n\ninterface LabelTracker {\n [key: number]: boolean;\n}\n\nconst LabelTrackerContext = createContext(null);\nconst UnlabeledDivisionsContext = createContext(null);\n\nconst findMacrostratUnitID = (u) => u.unit_id;\n\nexport function LabelTrackerProvider(props) {\n /** Tracker for units to handle state for whether their labels fit inline or not.\n * Designed to work for single or composite columns.\n */\n const { children, units, findUnitID = findMacrostratUnitID } = props;\n const [unlabeledDivisions, setUnlabeledDivisions] = useState<\n BaseUnit[] | null\n >(null);\n const labelTrackerRef = useRef<LabelTracker>({});\n const trackLabelVisibility = useCallback(\n (div, visible) => {\n const id = findUnitID(div);\n labelTrackerRef.current[id] = visible;\n if (Object.keys(labelTrackerRef.current).length == units.length) {\n setUnlabeledDivisions(\n // @ts-ignore\n units.filter((d) => {\n const id = findUnitID(d);\n return labelTrackerRef.current[id] == false;\n }),\n );\n }\n },\n [labelTrackerRef, units, findUnitID],\n );\n\n const value = trackLabelVisibility;\n return h(\n LabelTrackerContext.Provider,\n { value },\n h(\n UnlabeledDivisionsContext.Provider,\n { value: unlabeledDivisions },\n children,\n ),\n );\n}\n\nfunction TrackedLabeledUnit({\n division,\n nameForDivision = defaultNameFunction,\n ...rest\n}) {\n const trackLabelVisibility = useContext(LabelTrackerContext);\n return h(LabeledUnit, {\n division,\n label: nameForDivision(division),\n onLabelUpdated(label, visible) {\n // If there is al LabelTrackerContext, update the label visibility\n trackLabelVisibility?.(division, visible);\n },\n ...rest,\n });\n}\n\nexport const CompositeUnitComponent = TrackedLabeledUnit;\n\ntype BaseUnitProps = {\n width: number;\n showLabels?: boolean;\n columnWidth?: number;\n clipToFrame?: boolean;\n};\n\ntype ICompositeUnitProps = BaseUnitProps & {\n gutterWidth?: number;\n labelOffset?: number;\n paddingLeft?: number;\n nameForDivision?: (division: BaseUnit) => string;\n children?: React.ReactNode;\n unitComponent?: React.FC<any>;\n unitComponentProps?: any;\n noteMode?: \"labeled\" | \"unlabeled\";\n showLabelColumn?: boolean;\n noteComponent?: React.FC<any>;\n shouldRenderNote?: (d: any) => boolean;\n};\n\ninterface CompositeUnitProps {\n unitComponent: React.FC<any>;\n unitComponentProps?: any;\n width: number;\n showLabels?: boolean;\n clipToFrame?: boolean;\n}\n\nexport function CompositeUnitsColumn(props: CompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const {\n width,\n unitComponent = TrackedLabeledUnit,\n unitComponentProps,\n clipToFrame,\n ...rest\n } = props;\n\n return h(LithologyColumn, { width, clipToFrame }, [\n h(UnitBoxes, {\n unitComponent,\n unitComponentProps,\n ...rest,\n }),\n ]);\n}\n\nexport function AnnotatedUnitsColumn(props: ICompositeUnitProps) {\n useEffect(() => {\n console.warn(\n \"AnnotatedUnitsColumn is deprecated and currently renders a no-op for transition purposes\",\n );\n }, []);\n return null;\n}\n\nexport function SectionLabelsColumn(props: ICompositeUnitProps) {\n // Section with \"squishy\" time scale\n const {\n width = 300,\n noteMode = \"unlabeled\",\n labelOffset = 30,\n noteComponent,\n shouldRenderNote,\n } = props;\n\n const { totalHeight, axisType } = useMacrostratColumnData();\n const _compositeScale = useCompositeScale();\n\n const unlabeledUnits = useContext(UnlabeledDivisionsContext);\n const unitsToLabel = noteMode == \"unlabeled\" ? unlabeledUnits : undefined;\n\n const selectUnit = useUnitSelectionDispatch();\n\n return h(\"div.section-labels-column\", [\n h(\n ColumnNotesProvider,\n {\n units: [],\n scale: _compositeScale,\n totalHeight,\n axisType,\n },\n h(\n SVG,\n {\n height: totalHeight,\n innerWidth: width - 4,\n paddingH: 1,\n paddingLeft: 3,\n },\n h(UnitNamesColumn, {\n divisions: unitsToLabel,\n paddingLeft: labelOffset,\n width,\n noteComponent,\n shouldRenderNote,\n scale: _compositeScale,\n onClickNote(note) {\n selectUnit(note.data, null, null);\n },\n }),\n ),\n ),\n ]);\n}\n\nexport function ColumnNotesProvider(props) {\n // A fake column axis provider that allows scales to cross\n const { children, scale, totalHeight, pixelScale } = props;\n\n const { axisType } = useMacrostratColumnData();\n\n return h(\n ColumnContext.Provider,\n {\n value: {\n divisions: [],\n scale,\n scaleClamped: scale,\n pixelHeight: totalHeight,\n pixelsPerMeter: pixelScale,\n axisType,\n zoom: 1,\n },\n },\n children,\n );\n}\n\nexport { TrackedLabeledUnit, ICompositeUnitProps };\n"],"names":["id"],"mappings":";;;;;;;;AAwBA,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"composite.js","sources":["../../src/units/composite.ts"],"sourcesContent":["import { hyperStyled } from \"@macrostrat/hyper\";\nimport {\n ColumnContext,\n LithologyColumn,\n SVG,\n} from \"@macrostrat/column-components\";\nimport { defaultNameFunction, UnitNamesColumn } from \"./names\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { BaseUnit } from \"@macrostrat/api-types\";\nimport { LabeledUnit, UnitBoxes } from \"./boxes\";\nimport styles from \"./composite.module.sass\";\nimport {\n useCompositeScale,\n useMacrostratColumnData,\n useUnitSelectionDispatch,\n} from \"../data-provider\";\n\nconst h = hyperStyled(styles);\n\ninterface LabelTracker {\n [key: number]: boolean;\n}\n\nconst LabelTrackerContext = createContext(null);\nconst UnlabeledDivisionsContext = createContext(null);\n\nconst findMacrostratUnitID = (u) => u.unit_id;\n\nexport function LabelTrackerProvider(props) {\n /** Tracker for units to handle state for whether their labels fit inline or not.\n * Designed to work for single or composite columns.\n */\n const { children, units, findUnitID = findMacrostratUnitID } = props;\n const [unlabeledDivisions, setUnlabeledDivisions] = useState<\n BaseUnit[] | null\n >(null);\n const labelTrackerRef = useRef<LabelTracker>({});\n const trackLabelVisibility = useCallback(\n (div, visible) => {\n const id = findUnitID(div);\n labelTrackerRef.current[id] = visible;\n if (Object.keys(labelTrackerRef.current).length == units.length) {\n setUnlabeledDivisions(\n // @ts-ignore\n units.filter((d) => {\n const id = findUnitID(d);\n return labelTrackerRef.current[id] == false;\n }),\n );\n }\n },\n [labelTrackerRef, units, findUnitID],\n );\n\n const value = trackLabelVisibility;\n return h(\n LabelTrackerContext.Provider,\n { value },\n h(\n UnlabeledDivisionsContext.Provider,\n { value: unlabeledDivisions },\n children,\n ),\n );\n}\n\nfunction TrackedLabeledUnit({\n division,\n nameForDivision = defaultNameFunction,\n ...rest\n}) {\n const trackLabelVisibility = useContext(LabelTrackerContext);\n return h(LabeledUnit, {\n division,\n label: nameForDivision(division),\n onLabelUpdated(label, visible) {\n // If there is al LabelTrackerContext, update the label visibility\n trackLabelVisibility?.(division, visible);\n },\n ...rest,\n });\n}\n\nexport const CompositeUnitComponent = TrackedLabeledUnit;\n\ntype BaseUnitProps = {\n width: number;\n showLabels?: boolean;\n columnWidth?: number;\n clipToFrame?: boolean;\n};\n\ntype ICompositeUnitProps = BaseUnitProps & {\n gutterWidth?: number;\n labelOffset?: number;\n paddingLeft?: number;\n nameForDivision?: (division: BaseUnit) => string;\n children?: React.ReactNode;\n unitComponent?: React.FC<any>;\n unitComponentProps?: any;\n noteMode?: \"labeled\" | \"unlabeled\";\n showLabelColumn?: boolean;\n noteComponent?: React.FC<any>;\n shouldRenderNote?: (d: any) => boolean;\n};\n\ninterface CompositeUnitProps {\n unitComponent: React.FC<any>;\n unitComponentProps?: any;\n width: number;\n showLabels?: boolean;\n clipToFrame?: boolean;\n}\n\nexport function CompositeUnitsColumn(props: CompositeUnitProps) {\n /*\n A column with units and names either\n overlapping or offset to the right\n */\n const {\n width,\n unitComponent = TrackedLabeledUnit,\n unitComponentProps,\n clipToFrame,\n ...rest\n } = props;\n\n return h(LithologyColumn, { width, clipToFrame }, [\n h(UnitBoxes, {\n unitComponent,\n unitComponentProps,\n ...rest,\n }),\n ]);\n}\n\nexport function AnnotatedUnitsColumn(props: ICompositeUnitProps) {\n useEffect(() => {\n console.warn(\n \"AnnotatedUnitsColumn is deprecated and currently renders a no-op for transition purposes\",\n );\n }, []);\n return null;\n}\n\nexport function SectionLabelsColumn(props: ICompositeUnitProps) {\n // Section with \"squishy\" time scale\n const {\n width = 300,\n noteMode = \"unlabeled\",\n labelOffset = 30,\n noteComponent,\n shouldRenderNote,\n } = props;\n\n const { totalHeight, axisType } = useMacrostratColumnData();\n const _compositeScale = useCompositeScale();\n\n const unlabeledUnits = useContext(UnlabeledDivisionsContext);\n const unitsToLabel = noteMode == \"unlabeled\" ? unlabeledUnits : undefined;\n\n const selectUnit = useUnitSelectionDispatch();\n\n return h(\"div.section-labels-column\", [\n h(\n ColumnNotesProvider,\n {\n units: [],\n scale: _compositeScale,\n totalHeight,\n axisType,\n },\n h(\n SVG,\n {\n height: totalHeight,\n innerWidth: width - 4,\n paddingH: 1,\n paddingLeft: 3,\n },\n h(UnitNamesColumn, {\n divisions: unitsToLabel,\n paddingLeft: labelOffset,\n width,\n noteComponent,\n shouldRenderNote,\n scale: _compositeScale,\n onClickNote(note) {\n selectUnit(note.data, null, null);\n },\n }),\n ),\n ),\n ]);\n}\n\nexport function ColumnNotesProvider(props) {\n // A fake column axis provider that allows scales to cross\n const { children, scale, totalHeight, pixelScale } = props;\n\n const { axisType } = useMacrostratColumnData();\n\n return h(\n ColumnContext.Provider,\n {\n value: {\n divisions: [],\n scale,\n scaleClamped: scale,\n pixelHeight: totalHeight,\n pixelsPerMeter: pixelScale,\n axisType,\n zoom: 1,\n },\n },\n children,\n );\n}\n\nexport { TrackedLabeledUnit, ICompositeUnitProps };\n"],"names":["styles","id"],"mappings":";;;;;;;;AAwBA,MAAM,IAAI,YAAYA,GAAM;AAM5B,MAAM,sBAAsB,cAAc,IAAI;AAC9C,MAAM,4BAA4B,cAAc,IAAI;AAEpD,MAAM,uBAAuB,CAAC,MAAM,EAAE;AAE/B,SAAS,qBAAqB,OAAO;AAI1C,QAAM,EAAE,UAAU,OAAO,aAAa,yBAAyB;AAC/D,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAElD,IAAI;AACN,QAAM,kBAAkB,OAAqB,EAAE;AAC/C,QAAM,uBAAuB;AAAA,IAC3B,CAAC,KAAK,YAAY;AAChB,YAAM,KAAK,WAAW,GAAG;AACzB,sBAAgB,QAAQ,EAAE,IAAI;AAC9B,UAAI,OAAO,KAAK,gBAAgB,OAAO,EAAE,UAAU,MAAM,QAAQ;AAC/D;AAAA;AAAA,UAEE,MAAM,OAAO,CAAC,MAAM;AAClB,kBAAMC,MAAK,WAAW,CAAC;AACvB,mBAAO,gBAAgB,QAAQA,GAAE,KAAK;AAAA,UACxC,CAAC;AAAA,QAAA;AAAA,MAEL;AAAA,IACF;AAAA,IACA,CAAC,iBAAiB,OAAO,UAAU;AAAA,EAAA;AAGrC,QAAM,QAAQ;AACd,SAAO;AAAA,IACL,oBAAoB;AAAA,IACpB,EAAE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QACP,OAAO;AAAA,QACP;AAAA,QACA;AAAA,MAAA;AAAA,MAEF;AAAA,QACE;AAAA,QACA;AAAA,UACE,QAAQ;AAAA,UACR,YAAY,QAAQ;AAAA,UACpB,UAAU;AAAA,UACV,aAAa;AAAA,QAAA;AAAA,QAEf,EAAE,iBAAiB;AAAA,UACjB,WAAW;AAAA,UACX,aAAa;AAAA,UACb;AAAA,UACA;AAAA,UACA;AAAA,UACA,OAAO;AAAA,UACP,YAAY,MAAM;AAChB,uBAAW,KAAK,MAAM,MAAM,IAAI;AAAA,UAClC;AAAA,QAAA,CACD;AAAA,MAAA;AAAA,IACH;AAAA,EACF,CACD;AACH;AAEO,SAAS,oBAAoB,OAAO;AAEzC,QAAM,EAAE,UAAU,OAAO,aAAa,eAAe;AAErD,QAAM,EAAE,SAAA,IAAa,wBAAA;AAErB,SAAO;AAAA,IACL,cAAc;AAAA,IACd;AAAA,MACE,OAAO;AAAA,QACL,WAAW,CAAA;AAAA,QACX;AAAA,QACA,cAAc;AAAA,QACd,aAAa;AAAA,QACb,gBAAgB;AAAA,QAChB;AAAA,QACA,MAAM;AAAA,MAAA;AAAA,IACR;AAAA,IAEF;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const h$1 = require("@macrostrat/hyper");
|
|
3
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
4
|
+
const h__default = /* @__PURE__ */ _interopDefault(h$1);
|
|
2
5
|
const styles = {
|
|
3
6
|
"unit-label": "_unit-label_tidbs_1"
|
|
4
7
|
};
|
|
5
|
-
|
|
8
|
+
let h = h__default.default.styled(styles);
|
|
9
|
+
Object.assign(h, styles);
|
|
10
|
+
module.exports = h;
|
|
6
11
|
//# sourceMappingURL=composite.module.sass.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composite.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"composite.module.sass.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import h$1 from "@macrostrat/hyper";
|
|
1
2
|
const styles = {
|
|
2
3
|
"unit-label": "_unit-label_tidbs_1"
|
|
3
4
|
};
|
|
5
|
+
let h = h$1.styled(styles);
|
|
6
|
+
Object.assign(h, styles);
|
|
4
7
|
export {
|
|
5
|
-
|
|
8
|
+
h as default
|
|
6
9
|
};
|
|
7
10
|
//# sourceMappingURL=composite.module.sass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"composite.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"composite.module.sass.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
package/dist/units/index.cjs
CHANGED
|
@@ -100,6 +100,8 @@ function EnvironmentColoredUnitComponent(props) {
|
|
|
100
100
|
...props
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
+
exports.flattenLithologies = colors.flattenLithologies;
|
|
104
|
+
exports.getMixedColorForData = colors.getMixedColorForData;
|
|
103
105
|
exports.getMixedUnitColor = colors.getMixedUnitColor;
|
|
104
106
|
exports.AnnotatedUnitsColumn = composite.AnnotatedUnitsColumn;
|
|
105
107
|
exports.ColumnNotesProvider = composite.ColumnNotesProvider;
|
package/dist/units/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n LithologyColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes, UnitProps } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { getMixedUnitColor } from \"./colors\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { resolveID } from \"./resolvers\";\nimport { Lithology } from \"@macrostrat/api-types\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\nexport * from \"./colors\";\n\nexport function UnitsColumn({ width = 100 }) {\n /*\n A column showing units with USGS color fill\n */\n return h(LithologyColumn, { width }, h(UnitBoxes));\n}\n\nexport function 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 function BasicUnitComponent({ division, ...rest }) {\n /** A unit that allows directly setting colors and patterns. */\n\n return h(UnitComponent, {\n division,\n ...rest,\n backgroundColor: division.color,\n patternID: division.patternID,\n });\n}\n\nexport function UnitComponent({ division, nColumns = 2, ...rest }) {\n const width = rest.width ?? useColumnLayout()?.width;\n\n const nOverlappingUnits = division.overlappingUnits?.length ?? 0;\n const _nColumns = nOverlappingUnits == 0 ? 1 : nColumns;\n const columnIx = (division.column ?? 0) % _nColumns;\n const reducedWidth = width / _nColumns;\n const x = (columnIx * width) / _nColumns;\n\n return h(TrackedLabeledUnit, {\n division,\n ...rest,\n width: reducedWidth,\n x,\n });\n}\n\ninterface UnitColorOptions {\n asBackground?: boolean;\n}\n\nexport function useUnitColor(unit, opts: UnitColorOptions = {}): string | null {\n /** Get the color for a unit based on its lithology */\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || lithMap == null) return null;\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, lithMap, inDarkMode, asBackground]);\n}\n\nexport function ColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColor(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nexport function useUnitColorByEnvironment(\n unit,\n opts: UnitColorOptions = {},\n): string | null {\n /** Get the color for a unit based on its lithology */\n const environmentMap = useEnvironments();\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || environmentMap == null) return null;\n let c = getMixedUnitColor(unit, environmentMap, inDarkMode, asBackground, {\n key: \"environ\",\n id_key: \"environ_id\",\n });\n if (c != null) {\n return c;\n }\n // Fallback to lithology color if no environment color is found\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, environmentMap, lithMap, inDarkMode, asBackground]);\n}\n\nexport function EnvironmentColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColorByEnvironment(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nfunction getPatternID(\n liths: Array<Lithology>,\n lithMap: Map<number, Lithology>,\n): string | null {\n if (lithMap == null || liths == null || liths.length == 0) {\n return null;\n }\n const patternIDs = new Set<string>();\n for (const lith of liths) {\n const lithData = lithMap.get(lith.lith_id);\n if (lithData) {\n patternIDs.add(`${lithData.fill}`);\n }\n }\n let id = patternIDs.values()[0];\n if (id == \"0\") return null;\n return id;\n}\n"],"names":["h","LithologyColumn","UnitBoxes","UnitNamesColumn","useColumnLayout","TrackedLabeledUnit","useLithologies","useInDarkMode","useMemo","getMixedUnitColor","resolveID","useGeologicPattern","useEnvironments"],"mappings":";;;;;;;;;;;;;;AAqBO,SAAS,YAAY,EAAE,QAAQ,OAAO;AAI3C,SAAOA,WAAAA,QAAEC,iBAAAA,iBAAiB,EAAE,SAASD,WAAAA,QAAEE,MAAAA,SAAS,CAAC;AACnD;AAEO,SAAS,kBAAkB,OAA4B;AAK5D,QAAM,EAAE,aAAa,OAAO,cAAc,GAAG,cAAc,OAAO;AAElE,SAAOF,mBAAE;AAAA,IACPA,WAAAA,QAAE,aAAa;AAAA,MACb,OAAO;AAAA,IAAA,CACR;AAAA,IACDA,WAAAA,QAAEG,MAAAA,iBAAiB;AAAA,MACjB,WAAW,aAAa,cAAc,WAAW;AAAA,MACjD,aAAa;AAAA,MACb,OAAO,QAAQ,cAAc;AAAA,IAAA,CAC9B;AAAA,EAAA,CACF;AACH;AAEO,SAAS,mBAAmB,EAAE,UAAU,GAAG,QAAQ;AAGxD,SAAOH,WAAAA,QAAE,eAAe;AAAA,IACtB;AAAA,IACA,GAAG;AAAA,IACH,iBAAiB,SAAS;AAAA,IAC1B,WAAW,SAAS;AAAA,EAAA,CACrB;AACH;AAEO,SAAS,cAAc,EAAE,UAAU,WAAW,GAAG,GAAG,QAAQ;AACjE,QAAM,QAAQ,KAAK,SAASI,iBAAAA,gBAAA,GAAmB;AAE/C,QAAM,oBAAoB,SAAS,kBAAkB,UAAU;AAC/D,QAAM,YAAY,qBAAqB,IAAI,IAAI;AAC/C,QAAM,YAAY,SAAS,UAAU,KAAK;AAC1C,QAAM,eAAe,QAAQ;AAC7B,QAAM,IAAK,WAAW,QAAS;AAE/B,SAAOJ,WAAAA,QAAEK,UAAAA,oBAAoB;AAAA,IAC3B;AAAA,IACA,GAAG;AAAA,IACH,OAAO;AAAA,IACP;AAAA,EAAA,CACD;AACH;AAMO,SAAS,aAAa,MAAM,OAAyB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kB,0BAA0B,MAAM,QAAQ;AAEhE,QAAM,YAAYD,MAAAA,QAAQ,MAAM;AAC9B,WAAOE,UAAAA,UAAU,MAAM,QAAQ;AAAA,EACjC,GAAG,CAAC,MAAM,UAAU,OAAO,CAAC;AAE5B,QAAM,OAAOC,iBAAAA,mBAAmB,SAAS;AAEzC,SAAOX,WAAAA,QAAE,eAAe;AAAA,IACtB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n LithologyColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes, UnitProps } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { getMixedUnitColor } from \"./colors\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { resolveID } from \"./resolvers\";\nimport { Lithology } from \"@macrostrat/api-types\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\nexport * from \"./colors\";\n\nexport function UnitsColumn({ width = 100 }) {\n /*\n A column showing units with USGS color fill\n */\n return h(LithologyColumn, { width }, h(UnitBoxes));\n}\n\nexport function 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 function BasicUnitComponent({ division, ...rest }) {\n /** A unit that allows directly setting colors and patterns. */\n\n return h(UnitComponent, {\n division,\n ...rest,\n backgroundColor: division.color,\n patternID: division.patternID,\n });\n}\n\nexport function UnitComponent({ division, nColumns = 2, ...rest }) {\n const width = rest.width ?? useColumnLayout()?.width;\n\n const nOverlappingUnits = division.overlappingUnits?.length ?? 0;\n const _nColumns = nOverlappingUnits == 0 ? 1 : nColumns;\n const columnIx = (division.column ?? 0) % _nColumns;\n const reducedWidth = width / _nColumns;\n const x = (columnIx * width) / _nColumns;\n\n return h(TrackedLabeledUnit, {\n division,\n ...rest,\n width: reducedWidth,\n x,\n });\n}\n\ninterface UnitColorOptions {\n asBackground?: boolean;\n}\n\nexport function useUnitColor(unit, opts: UnitColorOptions = {}): string | null {\n /** Get the color for a unit based on its lithology */\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || lithMap == null) return null;\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, lithMap, inDarkMode, asBackground]);\n}\n\nexport function ColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColor(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nexport function useUnitColorByEnvironment(\n unit,\n opts: UnitColorOptions = {},\n): string | null {\n /** Get the color for a unit based on its lithology */\n const environmentMap = useEnvironments();\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || environmentMap == null) return null;\n let c = getMixedUnitColor(unit, environmentMap, inDarkMode, asBackground, {\n key: \"environ\",\n id_key: \"environ_id\",\n });\n if (c != null) {\n return c;\n }\n // Fallback to lithology color if no environment color is found\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, environmentMap, lithMap, inDarkMode, asBackground]);\n}\n\nexport function EnvironmentColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColorByEnvironment(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nfunction getPatternID(\n liths: Array<Lithology>,\n lithMap: Map<number, Lithology>,\n): string | null {\n if (lithMap == null || liths == null || liths.length == 0) {\n return null;\n }\n const patternIDs = new Set<string>();\n for (const lith of liths) {\n const lithData = lithMap.get(lith.lith_id);\n if (lithData) {\n patternIDs.add(`${lithData.fill}`);\n }\n }\n let id = patternIDs.values()[0];\n if (id == \"0\") return null;\n return id;\n}\n"],"names":["h","LithologyColumn","UnitBoxes","UnitNamesColumn","useColumnLayout","TrackedLabeledUnit","useLithologies","useInDarkMode","useMemo","getMixedUnitColor","resolveID","useGeologicPattern","useEnvironments"],"mappings":";;;;;;;;;;;;;;AAqBO,SAAS,YAAY,EAAE,QAAQ,OAAO;AAI3C,SAAOA,WAAAA,QAAEC,iBAAAA,iBAAiB,EAAE,SAASD,WAAAA,QAAEE,MAAAA,SAAS,CAAC;AACnD;AAEO,SAAS,kBAAkB,OAA4B;AAK5D,QAAM,EAAE,aAAa,OAAO,cAAc,GAAG,cAAc,OAAO;AAElE,SAAOF,mBAAE;AAAA,IACPA,WAAAA,QAAE,aAAa;AAAA,MACb,OAAO;AAAA,IAAA,CACR;AAAA,IACDA,WAAAA,QAAEG,MAAAA,iBAAiB;AAAA,MACjB,WAAW,aAAa,cAAc,WAAW;AAAA,MACjD,aAAa;AAAA,MACb,OAAO,QAAQ,cAAc;AAAA,IAAA,CAC9B;AAAA,EAAA,CACF;AACH;AAEO,SAAS,mBA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AAAA,EAAA,CACJ;AACH;AAEO,SAAS,0BACd,MACA,OAAyB,IACV;AAEf,QAAM,iBAAiBY,aAAAA,gBAAA;AACvB,QAAM,UAAUN,aAAAA,eAAA;AAChB,QAAM,aAAaC,aAAAA,cAAA;AACnB,QAAM,EAAE,eAAe,KAAA,IAAS;AAEhC,SAAOC,MAAAA,QAAQ,MAAM;AACnB,QAAI,QAAQ,QAAQ,kBAAkB,KAAM,QAAO;AACnD,QAAI,IAAIC,OAAAA,kBAAkB,MAAM,gBAAgB,YAAY,cAAc;AAAA,MACxE,KAAK;AAAA,MACL,QAAQ;AAAA,IAAA,CACT;AACD,QAAI,KAAK,MAAM;AACb,aAAO;AAAA,IACT;AAEA,WAAOA,OAAAA,kBAAkB,MAAM,SAAS,YAAY,YAAY;AAAA,EAClE,GAAG,CAAC,MAAM,SAAS,gBAAgB,SAAS,YAAY,YAAY,CAAC;AACvE;AAEO,SAAS,gCAAgC,OAAO;AAGrD,QAAM,kBAAkB,0BAA0B,MAAM,QAAQ;AAEhE,QAAM,YAAYD,MAAAA,QAAQ,MAAM;AAC9B,WAAOE,UAAAA,UAAU,MAAM,QAAQ;AAAA,EACjC,GAAG,CAAC,MAAM,UAAU,OAAO,CAAC;AAE5B,QAAM,OAAOC,iBAAAA,mBAAmB,SAAS;AAEzC,SAAOX,WAAAA,QAAE,eAAe;AAAA,IACtB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH;;;;;;;;;;;;;;;;;;;"}
|
package/dist/units/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { UnitNamesColumn } from "./names.js";
|
|
|
4
4
|
import { UnitBoxes } from "./boxes.js";
|
|
5
5
|
import { useInDarkMode } from "@macrostrat/ui-components";
|
|
6
6
|
import { getMixedUnitColor } from "./colors.js";
|
|
7
|
+
import { flattenLithologies, getMixedColorForData } from "./colors.js";
|
|
7
8
|
import { TrackedLabeledUnit } from "./composite.js";
|
|
8
9
|
import { AnnotatedUnitsColumn, ColumnNotesProvider, CompositeUnitComponent, CompositeUnitsColumn, LabelTrackerProvider, SectionLabelsColumn } from "./composite.js";
|
|
9
10
|
import { useLithologies, useEnvironments } from "@macrostrat/data-provider";
|
|
@@ -111,6 +112,8 @@ export {
|
|
|
111
112
|
TrackedLabeledUnit,
|
|
112
113
|
UnitComponent,
|
|
113
114
|
UnitsColumn,
|
|
115
|
+
flattenLithologies,
|
|
116
|
+
getMixedColorForData,
|
|
114
117
|
getMixedUnitColor,
|
|
115
118
|
useUnitColor,
|
|
116
119
|
useUnitColorByEnvironment
|
package/dist/units/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n LithologyColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes, UnitProps } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { getMixedUnitColor } from \"./colors\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { resolveID } from \"./resolvers\";\nimport { Lithology } from \"@macrostrat/api-types\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\nexport * from \"./colors\";\n\nexport function UnitsColumn({ width = 100 }) {\n /*\n A column showing units with USGS color fill\n */\n return h(LithologyColumn, { width }, h(UnitBoxes));\n}\n\nexport function 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 function BasicUnitComponent({ division, ...rest }) {\n /** A unit that allows directly setting colors and patterns. */\n\n return h(UnitComponent, {\n division,\n ...rest,\n backgroundColor: division.color,\n patternID: division.patternID,\n });\n}\n\nexport function UnitComponent({ division, nColumns = 2, ...rest }) {\n const width = rest.width ?? useColumnLayout()?.width;\n\n const nOverlappingUnits = division.overlappingUnits?.length ?? 0;\n const _nColumns = nOverlappingUnits == 0 ? 1 : nColumns;\n const columnIx = (division.column ?? 0) % _nColumns;\n const reducedWidth = width / _nColumns;\n const x = (columnIx * width) / _nColumns;\n\n return h(TrackedLabeledUnit, {\n division,\n ...rest,\n width: reducedWidth,\n x,\n });\n}\n\ninterface UnitColorOptions {\n asBackground?: boolean;\n}\n\nexport function useUnitColor(unit, opts: UnitColorOptions = {}): string | null {\n /** Get the color for a unit based on its lithology */\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || lithMap == null) return null;\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, lithMap, inDarkMode, asBackground]);\n}\n\nexport function ColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColor(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nexport function useUnitColorByEnvironment(\n unit,\n opts: UnitColorOptions = {},\n): string | null {\n /** Get the color for a unit based on its lithology */\n const environmentMap = useEnvironments();\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || environmentMap == null) return null;\n let c = getMixedUnitColor(unit, environmentMap, inDarkMode, asBackground, {\n key: \"environ\",\n id_key: \"environ_id\",\n });\n if (c != null) {\n return c;\n }\n // Fallback to lithology color if no environment color is found\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, environmentMap, lithMap, inDarkMode, asBackground]);\n}\n\nexport function EnvironmentColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColorByEnvironment(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nfunction getPatternID(\n liths: Array<Lithology>,\n lithMap: Map<number, Lithology>,\n): string | null {\n if (lithMap == null || liths == null || liths.length == 0) {\n return null;\n }\n const patternIDs = new Set<string>();\n for (const lith of liths) {\n const lithData = lithMap.get(lith.lith_id);\n if (lithData) {\n patternIDs.add(`${lithData.fill}`);\n }\n }\n let id = patternIDs.values()[0];\n if (id == \"0\") return null;\n return id;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/units/index.ts"],"sourcesContent":["import h from \"@macrostrat/hyper\";\nimport {\n LithologyColumn,\n useGeologicPattern,\n} from \"@macrostrat/column-components\";\nimport { UnitNamesColumn } from \"./names\";\nimport { ICompositeUnitProps } from \"./composite\";\nimport { UnitBoxes, UnitProps } from \"./boxes\";\nimport { useColumnLayout } from \"@macrostrat/column-components\";\nimport { useInDarkMode } from \"@macrostrat/ui-components\";\nimport { getMixedUnitColor } from \"./colors\";\nimport { TrackedLabeledUnit } from \"./composite\";\nimport { useEnvironments, useLithologies } from \"@macrostrat/data-provider\";\nimport { useMemo } from \"react\";\nimport { resolveID } from \"./resolvers\";\nimport { Lithology } from \"@macrostrat/api-types\";\n\nexport * from \"./composite\";\nexport * from \"./types\";\nexport * from \"./colors\";\n\nexport function UnitsColumn({ width = 100 }) {\n /*\n A column showing units with USGS color fill\n */\n return h(LithologyColumn, { width }, h(UnitBoxes));\n}\n\nexport function 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 function BasicUnitComponent({ division, ...rest }) {\n /** A unit that allows directly setting colors and patterns. */\n\n return h(UnitComponent, {\n division,\n ...rest,\n backgroundColor: division.color,\n patternID: division.patternID,\n });\n}\n\nexport function UnitComponent({ division, nColumns = 2, ...rest }) {\n const width = rest.width ?? useColumnLayout()?.width;\n\n const nOverlappingUnits = division.overlappingUnits?.length ?? 0;\n const _nColumns = nOverlappingUnits == 0 ? 1 : nColumns;\n const columnIx = (division.column ?? 0) % _nColumns;\n const reducedWidth = width / _nColumns;\n const x = (columnIx * width) / _nColumns;\n\n return h(TrackedLabeledUnit, {\n division,\n ...rest,\n width: reducedWidth,\n x,\n });\n}\n\ninterface UnitColorOptions {\n asBackground?: boolean;\n}\n\nexport function useUnitColor(unit, opts: UnitColorOptions = {}): string | null {\n /** Get the color for a unit based on its lithology */\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || lithMap == null) return null;\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, lithMap, inDarkMode, asBackground]);\n}\n\nexport function ColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColor(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nexport function useUnitColorByEnvironment(\n unit,\n opts: UnitColorOptions = {},\n): string | null {\n /** Get the color for a unit based on its lithology */\n const environmentMap = useEnvironments();\n const lithMap = useLithologies();\n const inDarkMode = useInDarkMode();\n const { asBackground = true } = opts;\n\n return useMemo(() => {\n if (unit == null || environmentMap == null) return null;\n let c = getMixedUnitColor(unit, environmentMap, inDarkMode, asBackground, {\n key: \"environ\",\n id_key: \"environ_id\",\n });\n if (c != null) {\n return c;\n }\n // Fallback to lithology color if no environment color is found\n return getMixedUnitColor(unit, lithMap, inDarkMode, asBackground);\n }, [unit?.unit_id, environmentMap, lithMap, inDarkMode, asBackground]);\n}\n\nexport function EnvironmentColoredUnitComponent(props) {\n /** A unit component that is colored using a mixture of lithologies.\n * This is a separate component because it depends on more providers/contexts to determine coloring. */\n const backgroundColor = useUnitColorByEnvironment(props.division);\n\n const patternID = useMemo(() => {\n return resolveID(props.division); // ?? getPatternID(props.division.lith, lithMap);\n }, [props.division?.unit_id]);\n\n const fill = useGeologicPattern(patternID);\n\n return h(UnitComponent, {\n fill,\n backgroundColor,\n ...props,\n });\n}\n\nfunction getPatternID(\n liths: Array<Lithology>,\n lithMap: Map<number, Lithology>,\n): string | null {\n if (lithMap == null || liths == null || liths.length == 0) {\n return null;\n }\n const patternIDs = new Set<string>();\n for (const lith of liths) {\n const lithData = lithMap.get(lith.lith_id);\n if (lithData) {\n patternIDs.add(`${lithData.fill}`);\n }\n }\n let id = patternIDs.values()[0];\n if (id == \"0\") return null;\n return id;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAqBO,SAAS,YAAY,EAAE,QAAQ,OAAO;AAI3C,SAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,CAAC;AACnD;AAEO,SAAS,kBAAkB,OAA4B;AAK5D,QAAM,EAAE,aAAa,OAAO,cAAc,GAAG,cAAc,OAAO;AAElE,SAAO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AC,MAAM,UAAU,OAAO,CAAC;AAE5B,QAAM,OAAO,mBAAmB,SAAS;AAEzC,SAAO,EAAE,eAAe;AAAA,IACtB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH;AAEO,SAAS,0BACd,MACA,OAAyB,IACV;AAEf,QAAM,iBAAiB,gBAAA;AACvB,QAAM,UAAU,eAAA;AAChB,QAAM,aAAa,cAAA;AACnB,QAAM,EAAE,eAAe,KAAA,IAAS;AAEhC,SAAO,QAAQ,MAAM;AACnB,QAAI,QAAQ,QAAQ,kBAAkB,KAAM,QAAO;AACnD,QAAI,IAAI,kBAAkB,MAAM,gBAAgB,YAAY,cAAc;AAAA,MACxE,KAAK;AAAA,MACL,QAAQ;AAAA,IAAA,CACT;AACD,QAAI,KAAK,MAAM;AACb,aAAO;AAAA,IACT;AAEA,WAAO,kBAAkB,MAAM,SAAS,YAAY,YAAY;AAAA,EAClE,GAAG,CAAC,MAAM,SAAS,gBAAgB,SAAS,YAAY,YAAY,CAAC;AACvE;AAEO,SAAS,gCAAgC,OAAO;AAGrD,QAAM,kBAAkB,0BAA0B,MAAM,QAAQ;AAEhE,QAAM,YAAY,QAAQ,MAAM;AAC9B,WAAO,UAAU,MAAM,QAAQ;AAAA,EACjC,GAAG,CAAC,MAAM,UAAU,OAAO,CAAC;AAE5B,QAAM,OAAO,mBAAmB,SAAS;AAEzC,SAAO,EAAE,eAAe;AAAA,IACtB;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH;"}
|
package/dist/units/resolvers.cjs
CHANGED
|
@@ -55,6 +55,16 @@ const symbolIndex = {
|
|
|
55
55
|
argillite: 624,
|
|
56
56
|
diamictite: 681
|
|
57
57
|
};
|
|
58
|
+
function getBestFGDCPatternForLithologyList(liths) {
|
|
59
|
+
let lithsSorted = [...liths];
|
|
60
|
+
lithsSorted.sort((a, b) => b.prop - a.prop);
|
|
61
|
+
let firstLith = lithsSorted[0];
|
|
62
|
+
let sym = symbolIndex[firstLith.name];
|
|
63
|
+
if (sym != null) {
|
|
64
|
+
return { lith: firstLith, patternID: `${sym}` };
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
58
68
|
const resolveID = (d) => {
|
|
59
69
|
if (d.lith == null || d.lith.length == 0) {
|
|
60
70
|
return null;
|
|
@@ -109,6 +119,7 @@ const patternScale = {
|
|
|
109
119
|
const scalePattern = (id) => {
|
|
110
120
|
return patternScale[`${id}`] ?? 1;
|
|
111
121
|
};
|
|
122
|
+
exports.getBestFGDCPatternForLithologyList = getBestFGDCPatternForLithologyList;
|
|
112
123
|
exports.resolveID = resolveID;
|
|
113
124
|
exports.scalePattern = scalePattern;
|
|
114
125
|
//# sourceMappingURL=resolvers.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.cjs","sources":["../../src/units/resolvers.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"resolvers.cjs","sources":["../../src/units/resolvers.ts"],"sourcesContent":["import { Lithology, UnitLithology } from \"@macrostrat/api-types\";\nimport { LithologyCore } from \"@macrostrat/api-types/src/lithologies\";\n\nconst symbolIndex = {\n \"dolomite-limestone\": 641,\n lime_mudstone: 627,\n sandstone: 607,\n \"quartz arenite\": 607,\n litharenite: 608,\n sand: 608,\n siltstone: 616,\n silt: 616,\n siliciclastic: 615,\n mud: 620,\n \"dolomitic siltstone\": 616,\n shale: 620,\n limestone: 627,\n dolomite: 642,\n conglomerate: 602,\n carbonate: 627,\n \"dolomite-mudstone\": 642,\n dolostone: 642,\n mudstone: 620,\n slate: 703,\n \"sandy-dolomite\": 645,\n quartzite: 702,\n halite: 668,\n gypsum: 667,\n evaporite: 667,\n claystone: 620,\n anhydrite: 667,\n gabbro: 720,\n basalt: 717,\n diabase: 717,\n rhyolite: 722,\n andesite: 723,\n till: 681,\n loess: 684,\n \"calcareous ooze\": 653,\n \"siliceous ooze\": 653,\n chalk: 626,\n gravel: 601,\n plutonic: 721,\n granite: 719,\n clay: 660,\n syenite: 722,\n tuff: 711,\n volcanic: 725,\n metamorphic: 707,\n volcaniclastic: 714,\n migmatite: 709,\n gneiss: 708,\n tonalite: 727,\n granodiorite: 725,\n monzonite: 723,\n argillite: 624,\n diamictite: 681,\n};\n\nexport function getBestFGDCPatternForLithologyList<\n T extends UnitLithology | Lithology,\n>(liths: T[]): { lith: T; patternID: string } | null {\n let lithsSorted = [...liths];\n lithsSorted.sort((a, b) => b.prop - a.prop);\n let firstLith = lithsSorted[0];\n let sym = symbolIndex[firstLith.name];\n if (sym != null) {\n return { lith: firstLith, patternID: `${sym}` };\n }\n return null;\n}\n\nconst resolveID = (d: any) => {\n if (d.lith == null || d.lith.length == 0) {\n return null;\n }\n let liths = [...d.lith];\n let environs = d.environ.map((d) => d.name).join(\" \");\n liths.sort((a, b) => b.prop - a.prop);\n\n //console.log(d, d.unit_name, liths.map(d => d.name), environs)\n\n let sym = null;\n\n // overrides for IODP columns\n if (d.unit_name == \"clay\") {\n return \"650\";\n }\n if (d.unit_name == \"calcareous clay\") {\n return \"651\";\n }\n\n for (const k of liths) {\n if (k.name == \"sandstone\") {\n // Special cases for sandstone\n if (environs.includes(\"dune\")) {\n return \"609\";\n }\n if (environs.includes(\"marine\")) {\n return \"608\";\n }\n if (environs.includes(\"shore\")) {\n return \"611\";\n }\n if (environs.includes(\"loess\")) {\n return \"686\";\n }\n }\n\n if (k.name == \"conglomerate\") {\n // Special cases for sandstone\n if (environs.includes(\"fluvial\")) {\n return \"603\";\n }\n }\n\n if (k.name.includes(\"tuff\")) {\n return \"711\";\n }\n sym = symbolIndex[k.name];\n if (sym != null) {\n return sym;\n }\n\n if (k.type == \"volcanic\") {\n return \"725\";\n }\n }\n return sym;\n};\n\nconst patternScale = {\n \"609\": 1.5,\n \"603\": 1.5,\n};\n\nconst scalePattern = (id) => {\n return patternScale[`${id}`] ?? 1;\n};\n\nexport { resolveID, scalePattern };\n"],"names":["d"],"mappings":";;AAGA,MAAM,cAA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1
|
+
import { Lithology, UnitLithology } from '@macrostrat/api-types';
|
|
2
|
+
export declare function getBestFGDCPatternForLithologyList<T extends UnitLithology | Lithology>(liths: T[]): {
|
|
3
|
+
lith: T;
|
|
4
|
+
patternID: string;
|
|
5
|
+
} | null;
|
|
1
6
|
declare const resolveID: (d: any) => any;
|
|
2
7
|
declare const scalePattern: (id: any) => any;
|
|
3
8
|
export { resolveID, scalePattern };
|
package/dist/units/resolvers.js
CHANGED
|
@@ -53,6 +53,16 @@ const symbolIndex = {
|
|
|
53
53
|
argillite: 624,
|
|
54
54
|
diamictite: 681
|
|
55
55
|
};
|
|
56
|
+
function getBestFGDCPatternForLithologyList(liths) {
|
|
57
|
+
let lithsSorted = [...liths];
|
|
58
|
+
lithsSorted.sort((a, b) => b.prop - a.prop);
|
|
59
|
+
let firstLith = lithsSorted[0];
|
|
60
|
+
let sym = symbolIndex[firstLith.name];
|
|
61
|
+
if (sym != null) {
|
|
62
|
+
return { lith: firstLith, patternID: `${sym}` };
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
56
66
|
const resolveID = (d) => {
|
|
57
67
|
if (d.lith == null || d.lith.length == 0) {
|
|
58
68
|
return null;
|
|
@@ -108,6 +118,7 @@ const scalePattern = (id) => {
|
|
|
108
118
|
return patternScale[`${id}`] ?? 1;
|
|
109
119
|
};
|
|
110
120
|
export {
|
|
121
|
+
getBestFGDCPatternForLithologyList,
|
|
111
122
|
resolveID,
|
|
112
123
|
scalePattern
|
|
113
124
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.js","sources":["../../src/units/resolvers.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"resolvers.js","sources":["../../src/units/resolvers.ts"],"sourcesContent":["import { Lithology, UnitLithology } from \"@macrostrat/api-types\";\nimport { LithologyCore } from \"@macrostrat/api-types/src/lithologies\";\n\nconst symbolIndex = {\n \"dolomite-limestone\": 641,\n lime_mudstone: 627,\n sandstone: 607,\n \"quartz arenite\": 607,\n litharenite: 608,\n sand: 608,\n siltstone: 616,\n silt: 616,\n siliciclastic: 615,\n mud: 620,\n \"dolomitic siltstone\": 616,\n shale: 620,\n limestone: 627,\n dolomite: 642,\n conglomerate: 602,\n carbonate: 627,\n \"dolomite-mudstone\": 642,\n dolostone: 642,\n mudstone: 620,\n slate: 703,\n \"sandy-dolomite\": 645,\n quartzite: 702,\n halite: 668,\n gypsum: 667,\n evaporite: 667,\n claystone: 620,\n anhydrite: 667,\n gabbro: 720,\n basalt: 717,\n diabase: 717,\n rhyolite: 722,\n andesite: 723,\n till: 681,\n loess: 684,\n \"calcareous ooze\": 653,\n \"siliceous ooze\": 653,\n chalk: 626,\n gravel: 601,\n plutonic: 721,\n granite: 719,\n clay: 660,\n syenite: 722,\n tuff: 711,\n volcanic: 725,\n metamorphic: 707,\n volcaniclastic: 714,\n migmatite: 709,\n gneiss: 708,\n tonalite: 727,\n granodiorite: 725,\n monzonite: 723,\n argillite: 624,\n diamictite: 681,\n};\n\nexport function getBestFGDCPatternForLithologyList<\n T extends UnitLithology | Lithology,\n>(liths: T[]): { lith: T; patternID: string } | null {\n let lithsSorted = [...liths];\n lithsSorted.sort((a, b) => b.prop - a.prop);\n let firstLith = lithsSorted[0];\n let sym = symbolIndex[firstLith.name];\n if (sym != null) {\n return { lith: firstLith, patternID: `${sym}` };\n }\n return null;\n}\n\nconst resolveID = (d: any) => {\n if (d.lith == null || d.lith.length == 0) {\n return null;\n }\n let liths = [...d.lith];\n let environs = d.environ.map((d) => d.name).join(\" \");\n liths.sort((a, b) => b.prop - a.prop);\n\n //console.log(d, d.unit_name, liths.map(d => d.name), environs)\n\n let sym = null;\n\n // overrides for IODP columns\n if (d.unit_name == \"clay\") {\n return \"650\";\n }\n if (d.unit_name == \"calcareous clay\") {\n return \"651\";\n }\n\n for (const k of liths) {\n if (k.name == \"sandstone\") {\n // Special cases for sandstone\n if (environs.includes(\"dune\")) {\n return \"609\";\n }\n if (environs.includes(\"marine\")) {\n return \"608\";\n }\n if (environs.includes(\"shore\")) {\n return \"611\";\n }\n if (environs.includes(\"loess\")) {\n return \"686\";\n }\n }\n\n if (k.name == \"conglomerate\") {\n // Special cases for sandstone\n if (environs.includes(\"fluvial\")) {\n return \"603\";\n }\n }\n\n if (k.name.includes(\"tuff\")) {\n return \"711\";\n }\n sym = symbolIndex[k.name];\n if (sym != null) {\n return sym;\n }\n\n if (k.type == \"volcanic\") {\n return \"725\";\n }\n }\n return sym;\n};\n\nconst patternScale = {\n \"609\": 1.5,\n \"603\": 1.5,\n};\n\nconst scalePattern = (id) => {\n return patternScale[`${id}`] ?? 1;\n};\n\nexport { resolveID, scalePattern };\n"],"names":["d"],"mappings":"AAGA,MAAM,cAAc;AAAA,EAClB,sBAAsB;AAAA,EACtB,eAAe;AAAA,EACf,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb,MAAM;AAAA,EACN,WAAW;AAAA,EACX,MAAM;AAAA,EACN,eAAe;AAAA,EACf,KAAK;AAAA,EACL,uBAAuB;AAAA,EACvB,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,cAAc;AAAA,EACd,WAAW;AAAA,EACX,qBAAqB;AAAA,EACrB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,OAAO;AAAA,EACP,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,UAAU;AAAA,EACV,MAAM;AAAA,EACN,OAAO;AAAA,EACP,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,MAAM;AAAA,EACN,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,UAAI,SAAS,SAAS,SAAS,GAAG;AAChC,eAAO;AAAA,MACT;AAAA,IACF;AAEA,QAAI,EAAE,KAAK,SAAS,MAAM,GAAG;AAC3B,aAAO;AAAA,IACT;AACA,UAAM,YAAY,EAAE,IAAI;AACxB,QAAI,OAAO,MAAM;AACf,aAAO;AAAA,IACT;AAEA,QAAI,EAAE,QAAQ,YAAY;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEA,MAAM,eAAe;AAAA,EACnB,OAAO;AAAA,EACP,OAAO;AACT;AAEA,MAAM,eAAe,CAAC,OAAO;AAC3B,SAAO,aAAa,GAAG,EAAE,EAAE,KAAK;AAClC;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrostrat/column-views",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Data views for Macrostrat stratigraphic columns",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -49,17 +49,17 @@
|
|
|
49
49
|
"@macrostrat/api-types": "^1.1.5",
|
|
50
50
|
"@macrostrat/color-utils": "^1.2.1",
|
|
51
51
|
"@macrostrat/column-components": "^2.0.4",
|
|
52
|
-
"@macrostrat/data-components": "^1.1.
|
|
52
|
+
"@macrostrat/data-components": "^1.1.1",
|
|
53
53
|
"@macrostrat/data-provider": "^1.0.0",
|
|
54
54
|
"@macrostrat/hyper": "^3.0.6",
|
|
55
|
-
"@macrostrat/map-interface": "^2.0.
|
|
56
|
-
"@macrostrat/map-styles": "^2.0
|
|
57
|
-
"@macrostrat/mapbox-react": "^3.0.
|
|
58
|
-
"@macrostrat/mapbox-utils": "^1.7.
|
|
55
|
+
"@macrostrat/map-interface": "^2.0.2",
|
|
56
|
+
"@macrostrat/map-styles": "^2.1.0",
|
|
57
|
+
"@macrostrat/mapbox-react": "^3.0.2",
|
|
58
|
+
"@macrostrat/mapbox-utils": "^1.7.2",
|
|
59
59
|
"@macrostrat/stratigraphy-utils": "^1.2.1",
|
|
60
60
|
"@macrostrat/svg-map-components": "^2.0.1",
|
|
61
61
|
"@macrostrat/timescale": "^3.0.1",
|
|
62
|
-
"@macrostrat/ui-components": "^5.0.
|
|
62
|
+
"@macrostrat/ui-components": "^5.0.5",
|
|
63
63
|
"@turf/boolean-point-in-polygon": "^7.3.2",
|
|
64
64
|
"@turf/buffer": "^7.3.2",
|
|
65
65
|
"@turf/centroid": "^7.3.2",
|
|
@@ -84,14 +84,15 @@
|
|
|
84
84
|
"d3-shape": "^3.2.0",
|
|
85
85
|
"jotai": "^2.16.0",
|
|
86
86
|
"jotai-scope": "^0.10.0",
|
|
87
|
-
"mapbox-gl": "^
|
|
87
|
+
"mapbox-gl": "^3.0.0",
|
|
88
|
+
"p-map": "^7.0.4",
|
|
88
89
|
"react-spring": "^9.7.5",
|
|
89
90
|
"topojson-client": "^3.1.0",
|
|
90
91
|
"zustand": "^5.0.3",
|
|
91
92
|
"zustand-computed": "^2.0.2"
|
|
92
93
|
},
|
|
93
94
|
"devDependencies": {
|
|
94
|
-
"@macrostrat/web-components-bundler": "1.0.
|
|
95
|
+
"@macrostrat/web-components-bundler": "1.0.1"
|
|
95
96
|
},
|
|
96
97
|
"publishConfig": {
|
|
97
98
|
"access": "public"
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import type { BaseUnit } from "@macrostrat/api-types";
|
|
16
16
|
import { type AtomMap, createScopedStore } from "@macrostrat/data-components";
|
|
17
17
|
import { atom } from "jotai";
|
|
18
|
+
import { useEffect } from "react";
|
|
18
19
|
|
|
19
20
|
export const scope = createScopedStore();
|
|
20
21
|
|
|
@@ -3,11 +3,18 @@ import { buildGeoJSONSource } from "@macrostrat/mapbox-utils";
|
|
|
3
3
|
import type { Style } from "mapbox-gl";
|
|
4
4
|
|
|
5
5
|
export function buildColumnsStyle(color: string): Style {
|
|
6
|
-
let columnColor =
|
|
6
|
+
let columnColor: any =
|
|
7
|
+
color ?? getCSSVariable("--text-subtle-color", "black");
|
|
7
8
|
const columnSelectedColor = getCSSVariable("--selection-color", "purple");
|
|
8
9
|
|
|
9
|
-
// If color is in the geojson properties, use that
|
|
10
|
-
|
|
10
|
+
// If color is in the feature state or geojson properties, use that as second choice
|
|
11
|
+
|
|
12
|
+
columnColor = [
|
|
13
|
+
"coalesce",
|
|
14
|
+
["feature-state", "color"],
|
|
15
|
+
["get", "color"],
|
|
16
|
+
columnColor,
|
|
17
|
+
];
|
|
11
18
|
|
|
12
19
|
return {
|
|
13
20
|
sources: {
|