@macrostrat/map-interface 2.0.2 → 2.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/dev/vector-tile-features.cjs +3 -3
  3. package/dist/dev/vector-tile-features.cjs.map +1 -1
  4. package/dist/dev/vector-tile-features.js +1 -1
  5. package/dist/dev/vector-tile-features.js.map +1 -1
  6. package/dist/index.cjs +6 -18
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.ts +0 -1
  9. package/dist/index.js +1 -13
  10. package/dist/index.js.map +1 -1
  11. package/dist/location-details/index.d.ts +0 -1
  12. package/dist/location-details/info-blocks.cjs +0 -22
  13. package/dist/location-details/info-blocks.cjs.map +1 -1
  14. package/dist/location-details/info-blocks.js +0 -22
  15. package/dist/location-details/info-blocks.js.map +1 -1
  16. package/dist/location-details/macrostrat-linked.cjs +82 -129
  17. package/dist/location-details/macrostrat-linked.cjs.map +1 -1
  18. package/dist/location-details/macrostrat-linked.js +29 -75
  19. package/dist/location-details/macrostrat-linked.js.map +1 -1
  20. package/dist/location-details/physiography.cjs +2 -2
  21. package/dist/location-details/physiography.cjs.map +1 -1
  22. package/dist/location-details/physiography.js +1 -1
  23. package/dist/location-details/physiography.js.map +1 -1
  24. package/dist/location-details/reg-strat.cjs +2 -2
  25. package/dist/location-details/reg-strat.cjs.map +1 -1
  26. package/dist/location-details/reg-strat.js +1 -1
  27. package/dist/location-details/reg-strat.js.map +1 -1
  28. package/dist/map-interface.css +43 -215
  29. package/dist/map-view.cjs +6 -9
  30. package/dist/map-view.cjs.map +1 -1
  31. package/dist/map-view.d.ts +1 -1
  32. package/dist/map-view.js +7 -10
  33. package/dist/map-view.js.map +1 -1
  34. package/package.json +3 -4
  35. package/src/dev/vector-tile-features.ts +1 -1
  36. package/src/index.ts +0 -1
  37. package/src/location-details/index.ts +0 -1
  38. package/src/location-details/macrostrat-linked.ts +29 -81
  39. package/src/location-details/main.module.sass +0 -1
  40. package/src/location-details/physiography.ts +1 -1
  41. package/src/location-details/reg-strat.ts +1 -1
  42. package/src/map-view.ts +11 -8
  43. package/dist/expansion-panel/headers.cjs +0 -22
  44. package/dist/expansion-panel/headers.cjs.map +0 -1
  45. package/dist/expansion-panel/headers.d.ts +0 -1
  46. package/dist/expansion-panel/headers.js +0 -20
  47. package/dist/expansion-panel/headers.js.map +0 -1
  48. package/dist/expansion-panel/index.cjs +0 -128
  49. package/dist/expansion-panel/index.cjs.map +0 -1
  50. package/dist/expansion-panel/index.d.ts +0 -18
  51. package/dist/expansion-panel/index.js +0 -125
  52. package/dist/expansion-panel/index.js.map +0 -1
  53. package/dist/expansion-panel/main.module.sass.cjs +0 -32
  54. package/dist/expansion-panel/main.module.sass.cjs.map +0 -1
  55. package/dist/expansion-panel/main.module.sass.js +0 -30
  56. package/dist/expansion-panel/main.module.sass.js.map +0 -1
  57. package/dist/location-details/fetch.d.ts +0 -4
  58. package/dist/location-details/utils/index.cjs +0 -15
  59. package/dist/location-details/utils/index.cjs.map +0 -1
  60. package/dist/location-details/utils/index.js +0 -15
  61. package/dist/location-details/utils/index.js.map +0 -1
  62. package/dist/location-details/xdd-panel/article.cjs +0 -64
  63. package/dist/location-details/xdd-panel/article.cjs.map +0 -1
  64. package/dist/location-details/xdd-panel/article.d.ts +0 -1
  65. package/dist/location-details/xdd-panel/article.js +0 -62
  66. package/dist/location-details/xdd-panel/article.js.map +0 -1
  67. package/dist/location-details/xdd-panel/index.cjs +0 -71
  68. package/dist/location-details/xdd-panel/index.cjs.map +0 -1
  69. package/dist/location-details/xdd-panel/index.d.ts +0 -18
  70. package/dist/location-details/xdd-panel/index.js +0 -69
  71. package/dist/location-details/xdd-panel/index.js.map +0 -1
  72. package/dist/location-details/xdd-panel/journal.cjs +0 -27
  73. package/dist/location-details/xdd-panel/journal.cjs.map +0 -1
  74. package/dist/location-details/xdd-panel/journal.d.ts +0 -20
  75. package/dist/location-details/xdd-panel/journal.js +0 -25
  76. package/dist/location-details/xdd-panel/journal.js.map +0 -1
  77. package/src/expansion-panel/headers.ts +0 -18
  78. package/src/expansion-panel/index.ts +0 -135
  79. package/src/expansion-panel/main.module.sass +0 -157
  80. package/src/location-details/fetch.ts +0 -57
  81. package/src/location-details/location-details.stories.ts +0 -92
  82. package/src/location-details/xdd-panel/article.ts +0 -67
  83. package/src/location-details/xdd-panel/index.ts +0 -70
  84. package/src/location-details/xdd-panel/journal.ts +0 -60
@@ -1,20 +0,0 @@
1
- export interface XDDSnippet {
2
- pubname: string;
3
- publisher: string;
4
- _gddid: string;
5
- title: string;
6
- doi: string;
7
- coverDate: string;
8
- URL: string;
9
- authors: string;
10
- hits: number;
11
- highlight: string[];
12
- }
13
- type JournalProps = {
14
- articles: XDDSnippet[];
15
- name: string;
16
- publisher: string;
17
- nestedExpanded?: boolean;
18
- };
19
- export declare function JournalLegacy(props: JournalProps): import('react').FunctionComponentElement<any>;
20
- export {};
@@ -1,25 +0,0 @@
1
- import { Article } from "./article.js";
2
- import "@blueprintjs/core";
3
- import h from "@macrostrat/hyper";
4
- import { SubExpansionPanel } from "@macrostrat/map-interface";
5
- function JournalLegacy(props) {
6
- const { articles, name, publisher, nestedExpanded } = props;
7
- articles[0].pubname;
8
- return h(
9
- SubExpansionPanel,
10
- {
11
- title: name,
12
- helpText: publisher,
13
- expanded: nestedExpanded
14
- },
15
- [
16
- articles.map((article, i) => {
17
- return h(Article, { key: i, data: article });
18
- })
19
- ]
20
- );
21
- }
22
- export {
23
- JournalLegacy
24
- };
25
- //# sourceMappingURL=journal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"journal.js","sources":["../../../src/location-details/xdd-panel/journal.ts"],"sourcesContent":["import { Article } from \"./article\";\nimport { Divider } from \"@blueprintjs/core\";\nimport h from \"@macrostrat/hyper\";\nimport { SubExpansionPanel } from \"@macrostrat/map-interface\";\n\nexport interface XDDSnippet {\n pubname: string;\n publisher: string;\n _gddid: string;\n title: string;\n doi: string;\n coverDate: string;\n URL: string;\n authors: string;\n hits: number;\n highlight: string[];\n}\n\nfunction Journal(props) {\n return h(\"div.journal\", [\n h(\"div.journal-title\", [\n h(\"h2.journal-title-text\", [\n props.data.name,\n h(\"small.journal-source\", [props.data]),\n ]),\n ]),\n h(Divider),\n props.data.articles.map((article, i) => {\n return h(Article, { key: i, data: article });\n }),\n ]);\n}\n\ntype JournalProps = {\n articles: XDDSnippet[];\n name: string;\n publisher: string;\n nestedExpanded?: boolean;\n};\n\n// Still up for review\nexport function JournalLegacy(props: JournalProps) {\n const { articles, name, publisher, nestedExpanded } = props;\n\n const helpText = articles[0].pubname;\n\n return h(\n SubExpansionPanel,\n {\n title: name,\n helpText: publisher,\n expanded: nestedExpanded,\n },\n [\n articles.map((article, i) => {\n return h(Article, { key: i, data: article });\n }),\n ],\n );\n}\n"],"names":[],"mappings":";;;;AAyCO,SAAS,cAAc,OAAqB;AACjD,QAAM,EAAE,UAAU,MAAM,WAAW,mBAAmB;AAErC,WAAS,CAAC,EAAE;AAE7B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,MACE,OAAO;AAAA,MACP,UAAU;AAAA,MACV,UAAU;AAAA,IAAA;AAAA,IAEZ;AAAA,MACE,SAAS,IAAI,CAAC,SAAS,MAAM;AAC3B,eAAO,EAAE,SAAS,EAAE,KAAK,GAAG,MAAM,SAAS;AAAA,MAC7C,CAAC;AAAA,IAAA;AAAA,EACH;AAEJ;"}
@@ -1,18 +0,0 @@
1
- import hyper from "@macrostrat/hyper";
2
- import styles from "./main.module.sass";
3
-
4
- const h = hyper.styled(styles);
5
-
6
- export function PanelSubhead(props) {
7
- const { title, component = "h3", children, ...rest } = props;
8
- return h("div.panel-subhead", rest, [
9
- h(
10
- component,
11
- {
12
- className: "title",
13
- },
14
- title,
15
- ),
16
- children,
17
- ]);
18
- }
@@ -1,135 +0,0 @@
1
- import { useState } from "react";
2
- import { Collapse, Icon } from "@blueprintjs/core";
3
- import hyper from "@macrostrat/hyper";
4
- import styles from "./main.module.sass";
5
- import classNames from "classnames";
6
- import { Button } from "@blueprintjs/core";
7
- import { PanelSubhead } from "./headers";
8
-
9
- const h = hyper.styled(styles);
10
-
11
- function ExpansionPanelSummary(props) {
12
- const { expanded, children, onChange, className, title, titleComponent } =
13
- props;
14
- const icon = expanded ? "chevron-up" : "chevron-down";
15
- return h(
16
- PanelSubhead,
17
- {
18
- className: classNames("expansion-panel-header", className),
19
- onClick: onChange,
20
- title,
21
- component: titleComponent,
22
- },
23
- [children, h(Icon, { icon, className: "expansion-panel-icon" })],
24
- );
25
- }
26
-
27
- function ExpansionPanelBase(props) {
28
- let {
29
- title,
30
- titleComponent = "h3",
31
- children,
32
- expanded,
33
- helpText,
34
- onChange = () => {},
35
- sideComponent = null,
36
- className,
37
- } = props;
38
- const [isOpen, setOpen] = useState(expanded || false);
39
-
40
- const onChange_ = () => {
41
- onChange();
42
- setOpen(!isOpen);
43
- };
44
-
45
- return h(
46
- "div.expansion-panel-base",
47
- {
48
- className: classNames(className, {
49
- expanded: isOpen,
50
- collapsed: !isOpen,
51
- }),
52
- },
53
- [
54
- h(
55
- ExpansionPanelSummary,
56
- {
57
- onChange: onChange_,
58
- expanded: isOpen,
59
- title,
60
- titleComponent,
61
- },
62
- h("div.expansion-summary-title-help", [
63
- h("span.expansion-panel-subtext", helpText),
64
- " ",
65
- sideComponent,
66
- ]),
67
- ),
68
- h(Collapse, { isOpen }, h("div.expansion-children", null, children)),
69
- ],
70
- );
71
- }
72
-
73
- export function InfoPanelSection(props) {
74
- let { title, children, className, headerElement = null } = props;
75
- return h("div.info-panel-section", { className }, [
76
- h("div.panel-subhead", null, headerElement ?? h("h3", title)),
77
- h("div.panel-content", null, children),
78
- ]);
79
- }
80
-
81
- function ExpansionPanel(props) {
82
- return h(ExpansionPanelBase, {
83
- ...props,
84
- className: "expansion-panel",
85
- });
86
- }
87
-
88
- function SubExpansionPanel(props) {
89
- return h(ExpansionPanelBase, {
90
- ...props,
91
- className: "expansion-panel sub-expansion-panel",
92
- titleComponent: "h4",
93
- });
94
- }
95
-
96
- function ExpandableDetailsPanel(props) {
97
- let { title, children, value, headerElement, className } = props;
98
- const [isOpen, setIsOpen] = useState(false);
99
- headerElement ??= h([h("div.title", title), value]);
100
- return h("div.expandable-details", { className }, [
101
- h("div.expandable-details-main", [
102
- h("div.expandable-details-header", headerElement),
103
- h("div.expandable-details-toggle", [
104
- h(Button, {
105
- small: true,
106
- minimal: true,
107
- active: isOpen,
108
- onClick: () => setIsOpen(!isOpen),
109
- icon: "more",
110
- }),
111
- ]),
112
- ]),
113
- h(
114
- Collapse,
115
- { isOpen },
116
- h("div.expandable-details-children", null, children),
117
- ),
118
- ]);
119
- }
120
-
121
- function ExpansionBody({ title, className, children }) {
122
- return h("div.expansion-body", { className }, [
123
- h("div.expansion-panel-detail-header", title),
124
- h("div.expansion-panel-detail-body", null, children),
125
- ]);
126
- }
127
-
128
- export {
129
- ExpansionPanel,
130
- ExpansionPanelSummary,
131
- ExpandableDetailsPanel,
132
- SubExpansionPanel,
133
- ExpansionBody,
134
- PanelSubhead,
135
- };
@@ -1,157 +0,0 @@
1
-
2
- .panel-subhead
3
- padding: 0 1rem
4
- border: 1px solid var(--panel-rule-color)
5
- border-bottom: 1px solid var(--panel-rule-color)
6
- background-color: var(--accent-color)
7
- display: flex
8
- flex-direction: row
9
- align-items: center
10
- z-index: 1
11
- gap: var(--panel-header-gap, 0.5rem)
12
- top: -1px
13
- position: sticky
14
- min-height: var(--panel-header-height, 40px)
15
- h1, h2, h3, h4
16
- font-family: Montserrat,sans-serif
17
- font-weight: 700
18
- margin: 0
19
- h4
20
- font-weight: 600
21
- .title
22
- flex-grow: 1
23
-
24
- .expansion-panel-icon
25
- margin-right: -0.35em
26
-
27
- // :global(.bp6-dark) .panel-subhead
28
- // margin 0 1px
29
-
30
- .info-panel-section
31
- &>.panel-subhead
32
- margin: -1px calc(var(--panel-padding-h) * -1) 0
33
-
34
- .expansion-panel
35
- padding: 0
36
- flex-wrap: wrap
37
- margin-top: -1px
38
- // &.collapsed
39
- // .expansion-panel-header
40
- // border-bottom-width: 0;
41
-
42
- .sub-expansion-panel
43
- margin: -1px calc(var(--panel-padding-h) * -0.5) 0
44
- overflow: hidden
45
- &:first-child
46
- .expansion-panel-header
47
- border-top-width: 0
48
- .panel-subhead
49
- border-top: none
50
- border-bottom: none
51
-
52
- .expansion-panel-header
53
- background-color: var(--accent-secondary-color)
54
- cursor: pointer
55
- padding: 0 1rem
56
-
57
- &:hover
58
- background-color: var(--accent-secondary-hover-color)
59
- h2, h3, h4
60
- font-weight: 500
61
- border-bottom: 1px solid var(--tertiary-border-color)
62
- border-top: 1px solid var(--tertiary-border-color)
63
- align-items: center
64
-
65
- .expansion-summary-title-help
66
- margin-left: 5px
67
- :global(.bp6-icon)
68
- margin-left: 5px
69
-
70
- .expansion-panel-header
71
- cursor: pointer
72
- &:hover
73
- background-color: var(--accent-hover-color)
74
- :global(.bp6-icon)
75
- transform: translate(0,3px)
76
-
77
- .expansion-children
78
- padding: 0 1rem
79
- .expansion-panel
80
- margin-left: -1rem
81
- margin-right: -1rem
82
- &:first-child
83
- margin-top: 0
84
- &>:first-child
85
- margin-top: 1rem
86
- &>:last-child
87
- margin-bottom: 1rem
88
-
89
-
90
-
91
- .expansion-panel-subtext
92
- font-size: 85%
93
- font-weight: 400
94
-
95
- :global
96
- .expansion-panel-root
97
- padding-left: 15px !important
98
-
99
- .expansion-panel-detail
100
- display: block !important
101
- padding: 0 !important
102
-
103
- .expansion-panel-detail-sub
104
- display: block !important
105
-
106
- // New expandable panel for details
107
- .expandable-details-main
108
- display: flex
109
- flex-direction: row
110
- align-items: center
111
- justify-content: space-between
112
- margin: 3px 0
113
-
114
- .expandable-details-header
115
- display: inline-flex
116
- flex-direction: row
117
- align-items: baseline
118
- flex-grow: 1
119
-
120
- .expandable-details-children
121
- position: relative
122
-
123
- .expandable-details-toggle
124
- :global(.bp6-button)
125
- font-size: 10px
126
-
127
- .expandable-details
128
- &.macrostrat-unit
129
- .title:after
130
- content: none
131
- .title
132
- margin-right: 1em
133
- &:after
134
- content: ":"
135
-
136
- .expansion-body
137
- display: inline-block
138
- //flex-direction row
139
- align-items: baseline
140
- background-color: var(--tertiary-background)
141
- padding: 2px 6px
142
- border-radius: 4px
143
- width: 100%
144
- box-shadow: 0px 1px 2px 1px rgba(0,0,0,0.2)
145
- margin-bottom: 6px
146
-
147
- .expansion-panel-detail-header
148
- font-size: 90%
149
- font-style: italic
150
- margin-right: 1em
151
- display: inline
152
- color: var(--secondary-color)
153
- &:after
154
- content: ":"
155
-
156
- .expansion-panel-detail-body
157
- display: inline
@@ -1,57 +0,0 @@
1
- import { useAPIResult } from "@macrostrat/ui-components";
2
-
3
- const apiV2Prefix = `https://dev.macrostrat.org/api/v2`;
4
- const gddDomain = `https://xdd.wisc.edu`;
5
- const paleobioDomain = `https://paleobiodb.org`;
6
-
7
- export function fetchMapInfo(lng, lat, z) {
8
- return useAPIResult(`${apiV2Prefix}/mobile/map_query_v2`, {
9
- lng,
10
- lat,
11
- z,
12
- })?.success?.data;
13
- }
14
-
15
- export function fetchColumnInfo(lng, lat) {
16
- return useAPIResult(`${apiV2Prefix}/columns`, {
17
- lat,
18
- lng,
19
- response: "long",
20
- })?.success?.data?.[0];
21
- }
22
-
23
- export function fetchXddInfo(stratNames) {
24
- return useAPIResult(`${gddDomain}/api/v1/snippets`, {
25
- article_limit: 20,
26
- term: stratNames?.map((d) => d.rank_name).join(","),
27
- })?.success?.data;
28
- }
29
-
30
- export function fetchFossilInfo(lng, lat) {
31
- const collectionResponse = useAPIResult(
32
- `${paleobioDomain}/data1.2/colls/list.json?lngmin=${lng - 0.1}&lngmax=${lng + 0.1}&latmin=${lat - 0.1}&latmax=${lat + 0.1}`,
33
- )?.records;
34
-
35
- const occurrences = useAPIResult(
36
- `${paleobioDomain}/data1.2/occs/list.json?lngmin=${lng - 0.1}&lngmax=${lng + 0.1}&latmin=${lat - 0.1}&latmax=${lat + 0.1}`,
37
- )?.records;
38
-
39
- if (!collectionResponse || !occurrences) {
40
- return null;
41
- }
42
-
43
- try {
44
- return collectionResponse.map((col) => {
45
- col.occurrences = [];
46
- occurrences.forEach((occ) => {
47
- if (occ.cid === col.oid) {
48
- col.occurrences.push(occ);
49
- }
50
- });
51
- return col;
52
- });
53
- } catch (error) {
54
- console.log(error);
55
- return [];
56
- }
57
- }
@@ -1,92 +0,0 @@
1
- import { ComponentMeta } from "@storybook/react-vite";
2
- import h from "@macrostrat/hyper";
3
- import { RegionalStratigraphy } from "./reg-strat";
4
- import { Physiography } from "./physiography";
5
- import { MacrostratLinkedData } from "./macrostrat-linked";
6
- import { XddExpansion } from "./xdd-panel";
7
- import {
8
- fetchMapInfo,
9
- fetchColumnInfo,
10
- fetchXddInfo,
11
- fetchFossilInfo,
12
- } from "./fetch";
13
- import { FossilCollections } from "./fossil-collections";
14
-
15
- export default {
16
- title: "Map interface/Location panel details",
17
- // More on argTypes: https://storybook.js.org/docs/react/api/argtypes
18
- args: {},
19
- } as ComponentMeta<any>;
20
-
21
- const lat = 44.60085563149249;
22
- const lng = -96.16783150353609;
23
- const zoom = 3.9392171056922325;
24
-
25
- export function RegionalStratigraphyExample() {
26
- const mapInfo = fetchMapInfo(lng, lat, zoom);
27
- const columnInfo = fetchColumnInfo(lng, lat);
28
-
29
- return h(RegionalStratigraphy, {
30
- mapInfo,
31
- columnInfo,
32
- columnURL: "https://dev.macrostrat.org/columns/",
33
- expanded: true,
34
- });
35
- }
36
-
37
- export function PhysiographyExample() {
38
- const mapInfo = fetchMapInfo(lng, lat, zoom);
39
-
40
- return h(Physiography, {
41
- mapInfo,
42
- expanded: true,
43
- });
44
- }
45
-
46
- export function MacrostratLinkedDataExample() {
47
- const mapInfo = fetchMapInfo(lng, lat, zoom);
48
-
49
- if (mapInfo == null) {
50
- return null;
51
- }
52
-
53
- const source =
54
- mapInfo && mapInfo?.mapData && mapInfo?.mapData.length
55
- ? mapInfo?.mapData[0]
56
- : {
57
- name: null,
58
- descrip: null,
59
- comments: null,
60
- liths: [],
61
- b_int: {},
62
- t_int: {},
63
- ref: {},
64
- };
65
-
66
- return h(MacrostratLinkedData, {
67
- mapInfo,
68
- source,
69
- stratNameURL: "https://dev.macrostrat.org/lex/strat-names",
70
- environmentURL: "https://dev.macrostrat.org/lex/environments",
71
- intervalURL: "https://dev.macrostrat.org/lex/intervals",
72
- lithologyURL: "https://dev.macrostrat.org/lex/lithologies",
73
- expanded: true,
74
- });
75
- }
76
-
77
- export function xddInfoExample() {
78
- const mapInfo = fetchMapInfo(lng, lat, zoom);
79
- const xddInfo = fetchXddInfo(mapInfo?.mapData?.[0]?.macrostrat?.strat_names);
80
-
81
- if (!xddInfo) {
82
- return null;
83
- }
84
-
85
- return h(XddExpansion, { xddInfo, expanded: true, nestedExpanded: true });
86
- }
87
-
88
- export function FossilsExample() {
89
- const fossilInfo = fetchFossilInfo(-89.3938453, 43.0735407);
90
-
91
- return h(FossilCollections, { data: fossilInfo, expanded: true });
92
- }
@@ -1,67 +0,0 @@
1
- import React, { useState } from "react";
2
- import { Collapse, Button } from "@blueprintjs/core";
3
- import { AuthorList } from "@macrostrat/ui-components";
4
- import h from "@macrostrat/hyper";
5
-
6
- export function Article(props) {
7
- const [expanded, setExpanded] = useState(false);
8
- const { data } = props;
9
-
10
- const toggleExpand = () => {
11
- setExpanded(!expanded);
12
- };
13
-
14
- // Attempt to pull out only the year and not the whole date
15
- let year;
16
- try {
17
- year = data.coverDate ? data.coverDate.match(/\d{4}/)[0] : "";
18
- } catch (e) {
19
- year = "";
20
- }
21
-
22
- const authors = data?.authors?.split("; ") ?? [];
23
-
24
- const authorList =
25
- authors.length > 0 ? h(AuthorList, { names: authors }) : "Unknown";
26
-
27
- const iconName = expanded ? "chevron-up" : "chevron-down";
28
-
29
- return h("div.article", [
30
- h("div.article-title", [
31
- h("p.article-author", [authorList, year.length ? ` ${year}. ` : ""]),
32
- h(
33
- "a.title-link",
34
- { href: data.URL, target: "_blank" },
35
- h("strong", [data.title + "."]),
36
- ),
37
- h(
38
- "span",
39
- {},
40
- h(Button, {
41
- onClick: toggleExpand,
42
- minimal: true,
43
- rightIcon: iconName,
44
- className: "flat-btn",
45
- }),
46
- ),
47
- ]),
48
- h(
49
- Collapse,
50
- { isOpen: expanded },
51
- h(
52
- "span",
53
- { className: expanded ? "" : "hidden" },
54
- h(
55
- "div.quotes",
56
- {},
57
- data.highlight.map((snippet, si) =>
58
- h("p.gdd-snippet", {
59
- key: si,
60
- dangerouslySetInnerHTML: { __html: `...${snippet}...` },
61
- }),
62
- ),
63
- ),
64
- ),
65
- ),
66
- ]);
67
- }
@@ -1,70 +0,0 @@
1
- import { Spinner } from "@blueprintjs/core";
2
- import h from "@macrostrat/hyper";
3
- import { XDDSnippet, JournalLegacy } from "./journal";
4
- import { ExpansionPanel } from "@macrostrat/map-interface";
5
-
6
- export function XddExpansion({
7
- xddInfo,
8
- expanded = false,
9
- nestedExpanded = true,
10
- }) {
11
- return h(xDDPanelCore, {
12
- className: "regional-panel",
13
- data: xddInfo,
14
- isFetching: xddInfo == undefined || xddInfo.length === 0,
15
- expanded,
16
- nestedExpanded,
17
- });
18
- }
19
-
20
- export function xDDPanelCore({
21
- isFetching,
22
- data: xddInfo,
23
- expanded,
24
- nestedExpanded,
25
- ...rest
26
- }) {
27
- const groupedData = groupSnippetsByJournal(xddInfo);
28
-
29
- return h(
30
- ExpansionPanel,
31
- {
32
- className: "regional-panel",
33
- title: "Primary literature",
34
- helpText: "via xDD",
35
- ...rest,
36
- expanded,
37
- },
38
- [
39
- h.if(isFetching)(Spinner),
40
- h.if(!isFetching && xddInfo.length > 0)([
41
- Array.from(groupedData.entries())?.map(([journal, snippets]) => {
42
- return h(JournalLegacy, {
43
- nestedExpanded,
44
- name: journal,
45
- articles: snippets,
46
- publisher: snippets[0].publisher,
47
- key: journal,
48
- });
49
- }),
50
- ]),
51
- ],
52
- );
53
- }
54
-
55
- function groupSnippetsByJournal(
56
- snippets: XDDSnippet[],
57
- ): Map<string, XDDSnippet[]> {
58
- const journals = new Map<string, XDDSnippet[]>();
59
- if (!snippets || snippets.length === 0) {
60
- return journals;
61
- }
62
- for (let snippet of snippets) {
63
- const { pubname: journal } = snippet;
64
- if (!journals.has(journal)) {
65
- journals.set(journal, []);
66
- }
67
- journals.get(journal).push(snippet);
68
- }
69
- return journals;
70
- }