@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 +1 @@
1
- {"version":3,"file":"map-view.js","sources":["../src/map-view.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n use3DTerrain,\n getTerrainLayerForStyle,\n useMapStatus,\n} from \"@macrostrat/mapbox-react\";\nimport React from \"react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n getMapPosition,\n getMapboxStyle,\n mergeStyles,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef, useState } from \"react\";\nimport styles from \"./main.module.sass\";\nimport {\n MapLoadingReporter,\n MapMovedReporter,\n MapPaddingManager,\n MapResizeManager,\n} from \"./helpers\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nimport { getMapPadding } from \"./utils\";\nimport { useAsyncEffect } from \"@macrostrat/ui-components\";\n\nconst h = hyper.styled(styles);\n\ntype MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, \"container\">;\n\nexport interface MapViewProps extends MapboxCoreOptions {\n showLineSymbols?: boolean;\n children?: React.ReactNode;\n mapboxToken?: string;\n // Deprecated\n accessToken?: string;\n terrainSourceID?: string;\n enableTerrain?: boolean;\n infoMarkerPosition?: mapboxgl.LngLatLike;\n mapPosition?: MapPosition;\n initializeMap?: (\n container: HTMLElement,\n args: MapboxOptionsExt,\n ) => mapboxgl.Map;\n onMapLoaded?: (map: mapboxgl.Map) => void;\n onStyleLoaded?: (map: mapboxgl.Map) => void;\n onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;\n /** This map sets its own viewport, rather than being positioned by a parent.\n * This is a hack to ensure that the map can overflow its \"safe area\" when false */\n standalone?: boolean;\n /** Overlay styles to apply to the map: a list of mapbox style objects or fragments to\n * overlay on top of the main map style at runtime */\n overlayStyles?: Partial<mapboxgl.StyleSpecification>[];\n /** A function to transform the map style before it is loaded */\n transformStyle?: (\n style: mapboxgl.StyleSpecification,\n ) => mapboxgl.StyleSpecification;\n loadingIgnoredSources?: string[];\n id?: string;\n className?: string;\n}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n logoPosition: \"bottom-left\",\n trackResize: false,\n antialias: true,\n // This is a legacy option for Mapbox GL v2\n // @ts-ignore\n optimizeForTerrain: true,\n ...rest,\n });\n\n let _mapPosition = mapPosition;\n if (_mapPosition == null && rest.center == null && rest.bounds == null) {\n // If no map positioning information is provided, we use the default\n _mapPosition = defaultMapPosition;\n }\n\n // set initial map position\n if (_mapPosition != null) {\n setMapPosition(map, _mapPosition);\n }\n\n return map;\n}\n\nconst defaultMapPosition: MapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000,\n },\n};\n\nexport function MapView(props: MapViewProps) {\n let { terrainSourceID } = props;\n const {\n enableTerrain = true,\n style,\n mapPosition,\n initializeMap = defaultInitializeMap,\n children,\n mapboxToken,\n // Deprecated\n accessToken,\n infoMarkerPosition,\n transformRequest,\n projection,\n onMapLoaded = null,\n onStyleLoaded = null,\n onMapMoved = null,\n standalone = false,\n overlayStyles,\n transformStyle,\n trackResize = true,\n loadingIgnoredSources = [\"elevationMarker\", \"crossSectionEndpoints\"],\n id = \"map\",\n className,\n ...rest\n } = props;\n if (enableTerrain) {\n terrainSourceID ??= \"mapbox-3d-dem\";\n }\n\n useEffect(() => {\n if (id != null) {\n console.warn(\n \"Setting a specific element ID for the map is deprecated. Please use className instead.\",\n );\n }\n }, [id]);\n\n const _mapboxToken = mapboxToken ?? accessToken;\n\n if (_mapboxToken != null) {\n mapboxgl.accessToken = _mapboxToken;\n }\n\n const dispatch = useMapDispatch();\n let mapRef = useMapRef();\n const ref = useRef<HTMLDivElement>();\n const parentRef = useRef<HTMLDivElement>();\n\n const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);\n\n const estMapPosition: MapPosition | null =\n mapRef.current == null ? mapPosition : getMapPosition(mapRef.current);\n const { mapUse3D, mapIsRotated } = mapViewInfo(estMapPosition);\n const is3DAvailable = (mapUse3D ?? false) && enableTerrain;\n\n useEffect(() => {\n /** Manager to update map style */\n if (baseStyle == null) return;\n let map = mapRef.current;\n\n let newStyle: mapboxgl.StyleSpecification = baseStyle;\n\n const overlayStyles = props.overlayStyles ?? [];\n\n if (overlayStyles.length > 0) {\n newStyle = mergeStyles(newStyle, ...overlayStyles);\n }\n\n /** If we can, we try to update the map style with terrain information\n * immediately, before the style is loaded. This allows us to avoid a\n * flash of the map without terrain.\n *\n * To do this, we need to estimate the map position before load, which\n * doesn't always work.\n */\n if (is3DAvailable) {\n // We can update the style with terrain layers immediately\n const terrainStyle = getTerrainLayerForStyle(newStyle, terrainSourceID);\n newStyle = mergeStyles(newStyle, terrainStyle);\n }\n\n if (transformStyle != null) {\n newStyle = transformStyle(newStyle);\n }\n\n if (map != null) {\n dispatch({ type: \"set-style-loaded\", payload: false });\n map.setStyle(newStyle);\n } else {\n const map = initializeMap(ref.current, {\n style: newStyle,\n projection,\n mapPosition,\n transformRequest,\n ...rest,\n });\n dispatch({ type: \"set-map\", payload: map });\n map.setPadding(getMapPadding(ref, parentRef), { animate: false });\n onMapLoaded?.(map);\n }\n }, [baseStyle, overlayStyles, transformStyle]);\n\n useAsyncEffect(async () => {\n /** Manager to update map style */\n let newStyle: mapboxgl.StyleSpecification;\n if (typeof style === \"string\") {\n newStyle = await getMapboxStyle(style, {\n access_token: mapboxgl.accessToken,\n });\n } else {\n newStyle = style;\n }\n setBaseStyle(newStyle);\n }, [style]);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const mapClassName = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": is3DAvailable,\n },\n `${_projection}-projection`,\n );\n\n const parentClassName = classNames(\n {\n standalone,\n },\n className,\n );\n\n return h(\n \"div.map-view-container.main-view\",\n { ref: parentRef, className: parentClassName },\n [\n h(\"div.mapbox-map.map-view\", { ref, className: mapClassName, id }),\n h(MapLoadingReporter, {\n ignoredSources: loadingIgnoredSources,\n }),\n h(StyleLoadedReporter, { onStyleLoaded }),\n h(MapMovedReporter, { onMapMoved }),\n // Subsitute for trackResize: true that allows map resizing to\n // be tied to a specific ref component\n h.if(trackResize)(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, {\n containerRef: ref,\n parentRef,\n infoMarkerPosition,\n }),\n h(MapTerrainManager, { mapUse3D: is3DAvailable, terrainSourceID, style }),\n children,\n ],\n );\n}\n\nfunction StyleLoadedReporter({ onStyleLoaded = null }) {\n /** Check back every 0.1 seconds to see if the map has loaded.\n * We do it this way because mapboxgl loading events are unreliable */\n const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);\n const mapRef = useMapRef();\n const dispatch = useMapDispatch();\n\n useEffect(() => {\n if (isStyleLoaded) return;\n const interval = setInterval(() => {\n const map = mapRef.current;\n if (map == null) return;\n if (map.isStyleLoaded()) {\n // Wait a tick before setting the style loaded state\n dispatch({ type: \"set-style-loaded\", payload: true });\n onStyleLoaded?.(map);\n clearInterval(interval);\n }\n }, 50);\n return () => clearInterval(interval);\n }, [isStyleLoaded]);\n\n return null;\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n style,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n style?: mapboxgl.StyleSpecification | string;\n}) {\n use3DTerrain(mapUse3D, terrainSourceID);\n\n return null;\n}\n"],"names":["hyper","styles","overlayStyles","map"],"mappings":";;;;;;;;;;;AA+BA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAwC7B,SAAS,qBAAqB,WAAW,OAAyB,IAAI;AACpE,QAAM,EAAE,aAAa,GAAG,KAAA,IAAS;AAEjC,QAAM,MAAM,IAAI,SAAS,IAAI;AAAA,IAC3B;AAAA,IACA,SAAS;AAAA,IACT,cAAc;AAAA,IACd,aAAa;AAAA,IACb,WAAW;AAAA;AAAA;AAAA,IAGX,oBAAoB;AAAA,IACpB,GAAG;AAAA,EAAA,CACJ;AAED,MAAI,eAAe;AACnB,MAAI,gBAAgB,QAAQ,KAAK,UAAU,QAAQ,KAAK,UAAU,MAAM;AAEtE,mBAAe;AAAA,EACjB;AAGA,MAAI,gBAAgB,MAAM;AACxB,mBAAe,KAAK,YAAY;AAAA,EAClC;AAEA,SAAO;AACT;AAEA,MAAM,qBAAkC;AAAA,EACtC,QAAQ;AAAA,IACN,KAAK;AAAA,IACL,KAAK;AAAA,IACL,UAAU;AAAA,EAAA;AAEd;AAEO,SAAS,QAAQ,OAAqB;AAC3C,MAAI,EAAE,oBAAoB;AAC1B,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,aAAa;AAAA,IACb,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,wBAAwB,CAAC,mBAAmB,uBAAuB;AAAA,IACnE,KAAK;AAAA,IACL;AAAA,IACA,GAAG;AAAA,EAAA,IACD;AACJ,MAAI,eAAe;AACjB,wBAAoB;AAAA,EACtB;AAEA,YAAU,MAAM;AACd,QAAI,MAAM,MAAM;AACd,cAAQ;AAAA,QAC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YAAM,MAAM,OAAO;AACnB,UAAI,OAAO,KAAM;AACjB,UAAI,IAAI,iBAAiB;AAEvB,iBAAS,EAAE,MAAM,oBAAoB,SAAS,MAAM;AACpD,wBAAgB,GAAG;AACnB,sBAAc,QAAQ;AAAA,MACxB;AAAA,IACF,GAAG,EAAE;AACL,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,aAAa,CAAC;AAElB,SAAO;AACT;AAEO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,eAAa,UAAU,eAAe;AAEtC,SAAO;AACT;"}
1
+ {"version":3,"file":"map-view.js","sources":["../src/map-view.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport {\n useMapRef,\n useMapDispatch,\n use3DTerrain,\n getTerrainLayerForStyle,\n useMapStatus,\n useMapStyleFragments,\n} from \"@macrostrat/mapbox-react\";\nimport React from \"react\";\nimport {\n mapViewInfo,\n MapPosition,\n setMapPosition,\n getMapPosition,\n getMapboxStyle,\n mergeStyles,\n} from \"@macrostrat/mapbox-utils\";\nimport classNames from \"classnames\";\nimport mapboxgl from \"mapbox-gl\";\nimport { useEffect, useRef, useState } from \"react\";\nimport styles from \"./main.module.sass\";\nimport {\n MapLoadingReporter,\n MapMovedReporter,\n MapPaddingManager,\n MapResizeManager,\n} from \"./helpers\";\nimport \"mapbox-gl/dist/mapbox-gl.css\";\nimport { getMapPadding } from \"./utils\";\nimport { useAsyncEffect } from \"@macrostrat/ui-components\";\n\nconst h = hyper.styled(styles);\n\ntype MapboxCoreOptions = Omit<mapboxgl.MapboxOptions, \"container\">;\n\nexport interface MapViewProps extends MapboxCoreOptions {\n showLineSymbols?: boolean;\n children?: React.ReactNode;\n mapboxToken?: string;\n // Deprecated\n accessToken?: string;\n terrainSourceID?: string;\n enableTerrain?: boolean;\n infoMarkerPosition?: mapboxgl.LngLatLike;\n mapPosition?: MapPosition;\n initializeMap?: (\n container: HTMLElement,\n args: MapboxOptionsExt,\n ) => mapboxgl.Map;\n onMapLoaded?: (map: mapboxgl.Map) => void;\n onStyleLoaded?: (map: mapboxgl.Map) => void;\n onMapMoved?: (mapPosition: MapPosition, map: mapboxgl.Map) => void;\n /** This map sets its own viewport, rather than being positioned by a parent.\n * This is a hack to ensure that the map can overflow its \"safe area\" when false */\n standalone?: boolean;\n /** Overlay styles to apply to the map: a list of mapbox style objects or fragments to\n * overlay on top of the main map style at runtime */\n overlayStyles?: Partial<mapboxgl.StyleSpecification>[];\n /** A function to transform the map style before it is loaded */\n transformStyle?: (\n style: mapboxgl.StyleSpecification,\n ) => mapboxgl.StyleSpecification;\n loadingIgnoredSources?: string[];\n id?: string;\n className?: string;\n}\n\nexport interface MapboxOptionsExt extends MapboxCoreOptions {\n mapPosition?: MapPosition;\n}\n\nfunction defaultInitializeMap(container, args: MapboxOptionsExt = {}) {\n const { mapPosition, ...rest } = args;\n\n const map = new mapboxgl.Map({\n container,\n maxZoom: 18,\n logoPosition: \"bottom-left\",\n trackResize: false,\n antialias: true,\n // This is a legacy option for Mapbox GL v2\n // @ts-ignore\n optimizeForTerrain: true,\n ...rest,\n });\n\n let _mapPosition = mapPosition;\n if (_mapPosition == null && rest.center == null && rest.bounds == null) {\n // If no map positioning information is provided, we use the default\n _mapPosition = defaultMapPosition;\n }\n\n // set initial map position\n if (_mapPosition != null) {\n setMapPosition(map, _mapPosition);\n }\n\n return map;\n}\n\nconst defaultMapPosition: MapPosition = {\n camera: {\n lat: 34,\n lng: -120,\n altitude: 300000,\n },\n};\n\nexport function MapView(props: MapViewProps) {\n let { terrainSourceID } = props;\n const {\n enableTerrain = true,\n style,\n mapPosition,\n initializeMap = defaultInitializeMap,\n children,\n mapboxToken,\n // Deprecated\n accessToken,\n infoMarkerPosition,\n transformRequest,\n projection,\n onMapLoaded = null,\n onStyleLoaded = null,\n onMapMoved = null,\n standalone = false,\n overlayStyles,\n transformStyle,\n trackResize = true,\n loadingIgnoredSources = [\"elevationMarker\", \"crossSectionEndpoints\"],\n id = \"map\",\n className,\n ...rest\n } = props;\n\n useEffect(() => {\n if (id != null) {\n console.warn(\n \"Setting a specific element ID for the map is deprecated. Please use className instead.\",\n );\n }\n }, [id]);\n\n const _mapboxToken = mapboxToken ?? accessToken;\n\n if (_mapboxToken != null) {\n mapboxgl.accessToken = _mapboxToken;\n }\n\n const dispatch = useMapDispatch();\n let mapRef = useMapRef();\n const ref = useRef<HTMLDivElement>();\n const parentRef = useRef<HTMLDivElement>();\n\n const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);\n\n /** Get overlay styles from map context. These are added after the base style is loaded, and can be used\n * to add layers to the map at runtime, even after initialization. They are merged with any overlay styles\n * passed in as props.\n */\n const _ctxOverlayStyles = useMapStyleFragments() as any[];\n\n const estMapPosition: MapPosition | null =\n mapRef.current == null ? mapPosition : getMapPosition(mapRef.current);\n const { mapUse3D, mapIsRotated } = mapViewInfo(estMapPosition);\n const is3DAvailable = (mapUse3D ?? false) && enableTerrain;\n\n useEffect(() => {\n /** Manager to update map style */\n if (baseStyle == null) return;\n let map = mapRef.current;\n\n let newStyle: mapboxgl.StyleSpecification = baseStyle;\n\n const _overlayStyles = overlayStyles ?? [];\n\n if (_overlayStyles.length > 0 || _ctxOverlayStyles.length > 0) {\n newStyle = mergeStyles(newStyle, ..._overlayStyles, ..._ctxOverlayStyles);\n }\n\n /** If we can, we try to update the map style with terrain information\n * immediately, before the style is loaded. This allows us to avoid a\n * flash of the map without terrain.\n *\n * To do this, we need to estimate the map position before load, which\n * doesn't always work.\n */\n if (is3DAvailable) {\n // We can update the style with terrain layers immediately\n const terrainStyle = getTerrainLayerForStyle(newStyle, terrainSourceID);\n newStyle = mergeStyles(newStyle, terrainStyle);\n }\n\n if (transformStyle != null) {\n newStyle = transformStyle(newStyle);\n }\n\n if (map != null) {\n dispatch({ type: \"set-style-loaded\", payload: false });\n map.setStyle(newStyle);\n } else {\n const map = initializeMap(ref.current, {\n style: newStyle,\n projection,\n mapPosition,\n transformRequest,\n ...rest,\n });\n dispatch({ type: \"set-map\", payload: map });\n map.setPadding(getMapPadding(ref, parentRef), { animate: false });\n onMapLoaded?.(map);\n }\n }, [baseStyle, overlayStyles, _ctxOverlayStyles, transformStyle]);\n\n useAsyncEffect(async () => {\n /** Manager to update map style */\n let newStyle: mapboxgl.StyleSpecification;\n if (typeof style === \"string\") {\n newStyle = await getMapboxStyle(style, {\n access_token: mapboxgl.accessToken,\n });\n } else {\n newStyle = style;\n }\n setBaseStyle(newStyle);\n }, [style]);\n\n // Get map projection\n const _projection = mapRef.current?.getProjection()?.name ?? \"mercator\";\n\n const mapClassName = classNames(\n {\n \"is-rotated\": mapIsRotated ?? false,\n \"is-3d-available\": is3DAvailable,\n },\n `${_projection}-projection`,\n );\n\n const parentClassName = classNames(\n {\n standalone,\n },\n className,\n );\n\n return h(\n \"div.map-view-container.main-view\",\n { ref: parentRef, className: parentClassName },\n [\n h(\"div.mapbox-map.map-view\", { ref, className: mapClassName, id }),\n h(MapLoadingReporter, {\n ignoredSources: loadingIgnoredSources,\n }),\n h(StyleLoadedReporter, { onStyleLoaded }),\n h(MapMovedReporter, { onMapMoved }),\n // Subsitute for trackResize: true that allows map resizing to\n // be tied to a specific ref component\n h.if(trackResize)(MapResizeManager, { containerRef: ref }),\n h(MapPaddingManager, {\n containerRef: ref,\n parentRef,\n infoMarkerPosition,\n }),\n h(MapTerrainManager, { mapUse3D: is3DAvailable, terrainSourceID, style }),\n children,\n ],\n );\n}\n\nfunction StyleLoadedReporter({ onStyleLoaded = null }) {\n /** Check back every 0.1 seconds to see if the map has loaded.\n * We do it this way because mapboxgl loading events are unreliable */\n const isStyleLoaded = useMapStatus((state) => state.isStyleLoaded);\n const mapRef = useMapRef();\n const dispatch = useMapDispatch();\n\n useEffect(() => {\n if (isStyleLoaded) return;\n const interval = setInterval(() => {\n const map = mapRef.current;\n if (map == null) return;\n if (map.isStyleLoaded()) {\n // Wait a tick before setting the style loaded state\n dispatch({ type: \"set-style-loaded\", payload: true });\n onStyleLoaded?.(map);\n clearInterval(interval);\n }\n }, 50);\n return () => clearInterval(interval);\n }, [isStyleLoaded]);\n\n return null;\n}\n\nexport function MapTerrainManager({\n mapUse3D,\n terrainSourceID,\n}: {\n mapUse3D?: boolean;\n terrainSourceID?: string;\n style?: mapboxgl.StyleSpecification | string;\n}) {\n use3DTerrain(mapUse3D, terrainSourceID);\n\n return null;\n}\n"],"names":["hyper","styles","map"],"mappings":";;;;;;;;;;;AAgCA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAwC7B,SAAS,qBAAqB,WAAW,OAAyB,IAAI;AACpE,QAAM,EAAE,aAAa,GAAG,KAAA,IAAS;AAEjC,QAAM,MAAM,IAAI,SAAS,IAAI;AAAA,IAC3B;AAAA,IACA,SAAS;AAAA,IACT,cAAc;AAAA,IACd,aAAa;AAAA,IACb,WAAW;AAAA;AAAA;AAAA,IAGX,oBAAoB;AAAA,IACpB,GAAG;AAAA,EAAA,CACJ;AAED,MAAI,eAAe;AACnB,MAAI,gBAAgB,QAAQ,KAAK,UAAU,QAAQ,KAAK,UAAU,MAAM;AAEtE,mBAAe;AAAA,EACjB;AAGA,MAAI,gBAAgB,MAAM;AACxB,mBAAe,KAAK,YAAY;AAAA,EAClC;AAEA,SAAO;AACT;AAEA,MAAM,qBAAkC;AAAA,EACtC,QAAQ;AAAA,IACN,KAAK;AAAA,IACL,KAAK;AAAA,IACL,UAAU;AAAA,EAAA;AAEd;AAEO,SAAS,QAAQ,OAAqB;AAC3C,MAAI,EAAE,oBAAoB;AAC1B,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,aAAa;AAAA,IACb,aAAa;AAAA,IACb;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,wBA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EJ;AAEA,SAAS,oBAAoB,EAAE,gBAAgB,QAAQ;AAGrD,QAAM,gBAAgB,aAAa,CAAC,UAAU,MAAM,aAAa;AACjE,QAAM,SAAS,UAAA;AACf,QAAM,WAAW,eAAA;AAEjB,YAAU,MAAM;AACd,QAAI,cAAe;AACnB,UAAM,WAAW,YAAY,MAAM;AACjC,YAAM,MAAM,OAAO;AACnB,UAAI,OAAO,KAAM;AACjB,UAAI,IAAI,iBAAiB;AAEvB,iBAAS,EAAE,MAAM,oBAAoB,SAAS,MAAM;AACpD,wBAAgB,GAAG;AACnB,sBAAc,QAAQ;AAAA,MACxB;AAAA,IACF,GAAG,EAAE;AACL,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,aAAa,CAAC;AAElB,SAAO;AACT;AAEO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAIG;AACD,eAAa,UAAU,eAAe;AAEtC,SAAO;AACT;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@macrostrat/map-interface",
3
- "version": "2.0.2",
3
+ "version": "2.2.0",
4
4
  "description": "Map interface for Macrostrat",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,10 +48,9 @@
48
48
  "dependencies": {
49
49
  "@blueprintjs/core": "^6.6.1",
50
50
  "@macrostrat/color-utils": "^1.2.1",
51
- "@macrostrat/data-components": "^1.1.1",
51
+ "@macrostrat/data-components": "^1.1.3",
52
52
  "@macrostrat/hyper": "^3.0.6",
53
- "@macrostrat/map-interface": "2.0.2",
54
- "@macrostrat/mapbox-react": "^3.0.2",
53
+ "@macrostrat/mapbox-react": "^3.1.0",
55
54
  "@macrostrat/mapbox-utils": "^1.7.2",
56
55
  "@macrostrat/ui-components": "^5.0.5",
57
56
  "@mapbox/tilebelt": "^2.0.0",
@@ -6,7 +6,7 @@ import styles from "./main.module.sass";
6
6
  import { useCallback, useEffect, useRef, useState } from "react";
7
7
  import { JSONView } from "@macrostrat/ui-components";
8
8
  import { group } from "d3-array";
9
- import { ExpansionPanel } from "../expansion-panel";
9
+ import { ExpansionPanel } from "@macrostrat/data-components";
10
10
 
11
11
  const h = hyper.styled(styles);
12
12
 
package/src/index.ts CHANGED
@@ -6,6 +6,5 @@ export * from "./map-view";
6
6
  export * from "./controls";
7
7
  export * from "./helpers";
8
8
  export * from "./utils";
9
- export * from "./expansion-panel";
10
9
  export * from "./location-details";
11
10
  export * from "./hash-string";
@@ -1,5 +1,4 @@
1
1
  export * from "./fossil-collections";
2
- export * from "./xdd-panel";
3
2
  export * from "./reg-strat";
4
3
  export * from "./physiography";
5
4
  export * from "./macrostrat-linked";
@@ -1,17 +1,13 @@
1
- import hyper from "@macrostrat/hyper";
2
1
  import {
3
2
  ExpansionPanel,
4
3
  ExpandableDetailsPanel,
5
- ExpansionBody,
6
- } from "@macrostrat/map-interface";
7
- import styles from "./main.module.sass";
4
+ LithologyList,
5
+ } from "@macrostrat/data-components";
8
6
  import { scaleLinear } from "@visx/scale";
9
7
  import { AxisBottom } from "@visx/axis";
10
8
  import chroma from "chroma-js";
11
- import { LithologyList } from "@macrostrat/data-components";
12
- import { AttrChip, AgeChip } from "./info-blocks";
13
-
14
- const h = hyper.styled(styles);
9
+ import { AgeChip } from "./info-blocks";
10
+ import h from "./main.module.sass";
15
11
 
16
12
  export function MacrostratLinkedData(props) {
17
13
  const {
@@ -43,7 +39,6 @@ export function MacrostratLinkedData(props) {
43
39
  h(FossilOccs, { source }),
44
40
  h(LithsAndClasses, { source, lithologyURL }),
45
41
  h(Environments, { source, environmentURL }),
46
- h(Economy, { source }),
47
42
  ]),
48
43
  ],
49
44
  );
@@ -203,7 +198,7 @@ function MacrostratAgeInfo(props) {
203
198
  return h(
204
199
  ExpandableDetailsPanel,
205
200
  { headerElement: h(MacrostratAgeInfoCore, props) },
206
- h(ExpansionBody, { title: "Age refinement" }, h(AgeRefinementPlot, props)),
201
+ h(AgeRefinementPlot, props),
207
202
  );
208
203
  }
209
204
 
@@ -220,23 +215,20 @@ function MatchBasis(props) {
220
215
  h("div.description", "Matched stratigraphic unit"),
221
216
  ]),
222
217
  },
223
- h(ExpansionBody, { title: "All matched names" }, [
224
- source.macrostrat.strat_names?.map((name, i) => {
225
- let lastElement: boolean =
226
- i == source.macrostrat.strat_names.length - 1;
227
- return h("span", { key: i }, [
228
- h(
229
- "a.externalLink",
230
- {
231
- href: stratNameURL + "/" + name.strat_name_id,
232
- key: i,
233
- },
234
- [name.rank_name],
235
- ),
236
- h.if(!lastElement)([", "]),
237
- ]);
238
- }),
239
- ]),
218
+ source.macrostrat.strat_names?.map((name, i) => {
219
+ let lastElement: boolean = i == source.macrostrat.strat_names.length - 1;
220
+ return h("span", { key: i }, [
221
+ h(
222
+ "a.externalLink",
223
+ {
224
+ href: stratNameURL + "/" + name.strat_name_id,
225
+ key: i,
226
+ },
227
+ [name.rank_name],
228
+ ),
229
+ h.if(!lastElement)([", "]),
230
+ ]);
231
+ }),
240
232
  );
241
233
  }
242
234
 
@@ -318,14 +310,13 @@ function LithsAndClasses(props) {
318
310
  title: "Lithology",
319
311
  value: h(LithTypes, { lith_types }),
320
312
  },
321
- h(ExpansionBody, { title: "Matched lithologies" }, [
322
- h(LithologyList, {
323
- lithologies,
324
- onClickItem: (e, lith) => {
325
- window.open(lithologyURL + "/" + lith.lith_id, "_self");
326
- },
327
- }),
328
- ]),
313
+ h(LithologyList, {
314
+ label: "Matched lithologies",
315
+ lithologies,
316
+ onClickItem: (e, lith) => {
317
+ window.open(lithologyURL + "/" + lith.lith_id, "_self");
318
+ },
319
+ }),
329
320
  );
330
321
  }
331
322
 
@@ -357,52 +348,9 @@ function Environments(props) {
357
348
  title: "Environment",
358
349
  value: h(EnvironTypes, { environ_types }),
359
350
  },
360
- h(ExpansionBody, { title: "Matched environments" }, [
361
- h(LithologyList, {
362
- lithologies,
363
- onClickItem: (e, environ) => {
364
- console.log("environ", environmentURL);
365
- window.open(environmentURL + "/" + environ.environ_id, "_self");
366
- },
367
- }),
368
- ]),
369
- );
370
- }
371
-
372
- function EconType(props) {
373
- const { econ_types } = props;
374
-
375
- return h.if(econ_types && econ_types.length > 0)("div", [
376
- econ_types?.map((econClass, i) => {
377
- return h(AttrChip, {
378
- key: i,
379
- name: econClass.name,
380
- color: econClass.color,
381
- });
351
+ h(LithologyList, {
352
+ label: "Matched environments",
353
+ lithologies,
382
354
  }),
383
- ]);
384
- }
385
-
386
- function Economy(props) {
387
- const { source } = props;
388
- const { macrostrat } = source;
389
- const { econs = null, econ_types = null } = macrostrat;
390
- if (!econs) return h("div");
391
-
392
- return h.if(econs && econs.length > 0)(
393
- ExpandableDetailsPanel,
394
- {
395
- title: "Economy ",
396
- value: h(EconType, { econ_types }),
397
- },
398
- h(ExpansionBody, { title: "Matched economic attributes" }, [
399
- econs?.map((econ, i) => {
400
- return h(AttrChip, {
401
- key: i,
402
- name: econ.econ,
403
- color: econ.color,
404
- });
405
- }),
406
- ]),
407
355
  );
408
356
  }
@@ -22,7 +22,6 @@
22
22
 
23
23
  .expansion-summary-title
24
24
  margin-right: 0.8em
25
-
26
25
  &:after
27
26
  content: ":"
28
27
 
@@ -1,5 +1,5 @@
1
1
  import h from "@macrostrat/hyper";
2
- import { ExpansionPanel } from "@macrostrat/map-interface";
2
+ import { ExpansionPanel } from "@macrostrat/data-components";
3
3
 
4
4
  export function Physiography(props) {
5
5
  const { mapInfo, expanded = true } = props;
@@ -1,5 +1,5 @@
1
1
  import h from "@macrostrat/hyper";
2
- import { ExpansionPanel } from "@macrostrat/map-interface";
2
+ import { ExpansionPanel } from "@macrostrat/data-components";
3
3
  import { addCommas } from "./utils";
4
4
 
5
5
  export function RegionalStratigraphy({
package/src/map-view.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  use3DTerrain,
6
6
  getTerrainLayerForStyle,
7
7
  useMapStatus,
8
+ useMapStyleFragments,
8
9
  } from "@macrostrat/mapbox-react";
9
10
  import React from "react";
10
11
  import {
@@ -132,9 +133,6 @@ export function MapView(props: MapViewProps) {
132
133
  className,
133
134
  ...rest
134
135
  } = props;
135
- if (enableTerrain) {
136
- terrainSourceID ??= "mapbox-3d-dem";
137
- }
138
136
 
139
137
  useEffect(() => {
140
138
  if (id != null) {
@@ -157,6 +155,12 @@ export function MapView(props: MapViewProps) {
157
155
 
158
156
  const [baseStyle, setBaseStyle] = useState<mapboxgl.Style>(null);
159
157
 
158
+ /** Get overlay styles from map context. These are added after the base style is loaded, and can be used
159
+ * to add layers to the map at runtime, even after initialization. They are merged with any overlay styles
160
+ * passed in as props.
161
+ */
162
+ const _ctxOverlayStyles = useMapStyleFragments() as any[];
163
+
160
164
  const estMapPosition: MapPosition | null =
161
165
  mapRef.current == null ? mapPosition : getMapPosition(mapRef.current);
162
166
  const { mapUse3D, mapIsRotated } = mapViewInfo(estMapPosition);
@@ -169,10 +173,10 @@ export function MapView(props: MapViewProps) {
169
173
 
170
174
  let newStyle: mapboxgl.StyleSpecification = baseStyle;
171
175
 
172
- const overlayStyles = props.overlayStyles ?? [];
176
+ const _overlayStyles = overlayStyles ?? [];
173
177
 
174
- if (overlayStyles.length > 0) {
175
- newStyle = mergeStyles(newStyle, ...overlayStyles);
178
+ if (_overlayStyles.length > 0 || _ctxOverlayStyles.length > 0) {
179
+ newStyle = mergeStyles(newStyle, ..._overlayStyles, ..._ctxOverlayStyles);
176
180
  }
177
181
 
178
182
  /** If we can, we try to update the map style with terrain information
@@ -207,7 +211,7 @@ export function MapView(props: MapViewProps) {
207
211
  map.setPadding(getMapPadding(ref, parentRef), { animate: false });
208
212
  onMapLoaded?.(map);
209
213
  }
210
- }, [baseStyle, overlayStyles, transformStyle]);
214
+ }, [baseStyle, overlayStyles, _ctxOverlayStyles, transformStyle]);
211
215
 
212
216
  useAsyncEffect(async () => {
213
217
  /** Manager to update map style */
@@ -292,7 +296,6 @@ function StyleLoadedReporter({ onStyleLoaded = null }) {
292
296
  export function MapTerrainManager({
293
297
  mapUse3D,
294
298
  terrainSourceID,
295
- style,
296
299
  }: {
297
300
  mapUse3D?: boolean;
298
301
  terrainSourceID?: string;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const h$1 = require("@macrostrat/hyper");
4
- const main_module = require("./main.module.sass.cjs");
5
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
6
- const h__default = /* @__PURE__ */ _interopDefault(h$1);
7
- const h = h__default.default.styled(main_module.default);
8
- function PanelSubhead(props) {
9
- const { title, component = "h3", children, ...rest } = props;
10
- return h("div.panel-subhead", rest, [
11
- h(
12
- component,
13
- {
14
- className: "title"
15
- },
16
- title
17
- ),
18
- children
19
- ]);
20
- }
21
- exports.PanelSubhead = PanelSubhead;
22
- //# sourceMappingURL=headers.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"headers.cjs","sources":["../../src/expansion-panel/headers.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\n\nconst h = hyper.styled(styles);\n\nexport function PanelSubhead(props) {\n const { title, component = \"h3\", children, ...rest } = props;\n return h(\"div.panel-subhead\", rest, [\n h(\n component,\n {\n className: \"title\",\n },\n title,\n ),\n children,\n ]);\n}\n"],"names":["hyper","styles"],"mappings":";;;;;;AAGA,MAAM,IAAIA,WAAAA,QAAM,OAAOC,mBAAM;AAEtB,SAAS,aAAa,OAAO;AAClC,QAAM,EAAE,OAAO,YAAY,MAAM,UAAU,GAAG,SAAS;AACvD,SAAO,EAAE,qBAAqB,MAAM;AAAA,IAClC;AAAA,MACE;AAAA,MACA;AAAA,QACE,WAAW;AAAA,MAAA;AAAA,MAEb;AAAA,IAAA;AAAA,IAEF;AAAA,EAAA,CACD;AACH;;"}
@@ -1 +0,0 @@
1
- export declare function PanelSubhead(props: any): import('react').DOMElement<any, Element>;
@@ -1,20 +0,0 @@
1
- import h$1 from "@macrostrat/hyper";
2
- import h$2 from "./main.module.sass.js";
3
- const h = h$1.styled(h$2);
4
- function PanelSubhead(props) {
5
- const { title, component = "h3", children, ...rest } = props;
6
- return h("div.panel-subhead", rest, [
7
- h(
8
- component,
9
- {
10
- className: "title"
11
- },
12
- title
13
- ),
14
- children
15
- ]);
16
- }
17
- export {
18
- PanelSubhead
19
- };
20
- //# sourceMappingURL=headers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"headers.js","sources":["../../src/expansion-panel/headers.ts"],"sourcesContent":["import hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\n\nconst h = hyper.styled(styles);\n\nexport function PanelSubhead(props) {\n const { title, component = \"h3\", children, ...rest } = props;\n return h(\"div.panel-subhead\", rest, [\n h(\n component,\n {\n className: \"title\",\n },\n title,\n ),\n children,\n ]);\n}\n"],"names":["hyper","styles"],"mappings":";;AAGA,MAAM,IAAIA,IAAM,OAAOC,GAAM;AAEtB,SAAS,aAAa,OAAO;AAClC,QAAM,EAAE,OAAO,YAAY,MAAM,UAAU,GAAG,SAAS;AACvD,SAAO,EAAE,qBAAqB,MAAM;AAAA,IAClC;AAAA,MACE;AAAA,MACA;AAAA,QACE,WAAW;AAAA,MAAA;AAAA,MAEb;AAAA,IAAA;AAAA,IAEF;AAAA,EAAA,CACD;AACH;"}
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const React = require("react");
4
- const core = require("@blueprintjs/core");
5
- const h$1 = require("@macrostrat/hyper");
6
- const main_module = require("./main.module.sass.cjs");
7
- const classNames = require("classnames");
8
- const headers = require("./headers.cjs");
9
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
10
- const h__default = /* @__PURE__ */ _interopDefault(h$1);
11
- const classNames__default = /* @__PURE__ */ _interopDefault(classNames);
12
- const h = h__default.default.styled(main_module.default);
13
- function ExpansionPanelSummary(props) {
14
- const { expanded, children, onChange, className, title, titleComponent } = props;
15
- const icon = expanded ? "chevron-up" : "chevron-down";
16
- return h(
17
- headers.PanelSubhead,
18
- {
19
- className: classNames__default.default("expansion-panel-header", className),
20
- onClick: onChange,
21
- title,
22
- component: titleComponent
23
- },
24
- [children, h(core.Icon, { icon, className: "expansion-panel-icon" })]
25
- );
26
- }
27
- function ExpansionPanelBase(props) {
28
- let {
29
- title,
30
- titleComponent = "h3",
31
- children,
32
- expanded,
33
- helpText,
34
- onChange = () => {
35
- },
36
- sideComponent = null,
37
- className
38
- } = props;
39
- const [isOpen, setOpen] = React.useState(expanded || false);
40
- const onChange_ = () => {
41
- onChange();
42
- setOpen(!isOpen);
43
- };
44
- return h(
45
- "div.expansion-panel-base",
46
- {
47
- className: classNames__default.default(className, {
48
- expanded: isOpen,
49
- collapsed: !isOpen
50
- })
51
- },
52
- [
53
- h(
54
- ExpansionPanelSummary,
55
- {
56
- onChange: onChange_,
57
- expanded: isOpen,
58
- title,
59
- titleComponent
60
- },
61
- h("div.expansion-summary-title-help", [
62
- h("span.expansion-panel-subtext", helpText),
63
- " ",
64
- sideComponent
65
- ])
66
- ),
67
- h(core.Collapse, { isOpen }, h("div.expansion-children", null, children))
68
- ]
69
- );
70
- }
71
- function InfoPanelSection(props) {
72
- let { title, children, className, headerElement = null } = props;
73
- return h("div.info-panel-section", { className }, [
74
- h("div.panel-subhead", null, headerElement ?? h("h3", title)),
75
- h("div.panel-content", null, children)
76
- ]);
77
- }
78
- function ExpansionPanel(props) {
79
- return h(ExpansionPanelBase, {
80
- ...props,
81
- className: "expansion-panel"
82
- });
83
- }
84
- function SubExpansionPanel(props) {
85
- return h(ExpansionPanelBase, {
86
- ...props,
87
- className: "expansion-panel sub-expansion-panel",
88
- titleComponent: "h4"
89
- });
90
- }
91
- function ExpandableDetailsPanel(props) {
92
- let { title, children, value, headerElement, className } = props;
93
- const [isOpen, setIsOpen] = React.useState(false);
94
- headerElement ??= h([h("div.title", title), value]);
95
- return h("div.expandable-details", { className }, [
96
- h("div.expandable-details-main", [
97
- h("div.expandable-details-header", headerElement),
98
- h("div.expandable-details-toggle", [
99
- h(core.Button, {
100
- small: true,
101
- minimal: true,
102
- active: isOpen,
103
- onClick: () => setIsOpen(!isOpen),
104
- icon: "more"
105
- })
106
- ])
107
- ]),
108
- h(
109
- core.Collapse,
110
- { isOpen },
111
- h("div.expandable-details-children", null, children)
112
- )
113
- ]);
114
- }
115
- function ExpansionBody({ title, className, children }) {
116
- return h("div.expansion-body", { className }, [
117
- h("div.expansion-panel-detail-header", title),
118
- h("div.expansion-panel-detail-body", null, children)
119
- ]);
120
- }
121
- exports.PanelSubhead = headers.PanelSubhead;
122
- exports.ExpandableDetailsPanel = ExpandableDetailsPanel;
123
- exports.ExpansionBody = ExpansionBody;
124
- exports.ExpansionPanel = ExpansionPanel;
125
- exports.ExpansionPanelSummary = ExpansionPanelSummary;
126
- exports.InfoPanelSection = InfoPanelSection;
127
- exports.SubExpansionPanel = SubExpansionPanel;
128
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/expansion-panel/index.ts"],"sourcesContent":["import { useState } from \"react\";\nimport { Collapse, Icon } from \"@blueprintjs/core\";\nimport hyper from \"@macrostrat/hyper\";\nimport styles from \"./main.module.sass\";\nimport classNames from \"classnames\";\nimport { Button } from \"@blueprintjs/core\";\nimport { PanelSubhead } from \"./headers\";\n\nconst h = hyper.styled(styles);\n\nfunction ExpansionPanelSummary(props) {\n const { expanded, children, onChange, className, title, titleComponent } =\n props;\n const icon = expanded ? \"chevron-up\" : \"chevron-down\";\n return h(\n PanelSubhead,\n {\n className: classNames(\"expansion-panel-header\", className),\n onClick: onChange,\n title,\n component: titleComponent,\n },\n [children, h(Icon, { icon, className: \"expansion-panel-icon\" })],\n );\n}\n\nfunction ExpansionPanelBase(props) {\n let {\n title,\n titleComponent = \"h3\",\n children,\n expanded,\n helpText,\n onChange = () => {},\n sideComponent = null,\n className,\n } = props;\n const [isOpen, setOpen] = useState(expanded || false);\n\n const onChange_ = () => {\n onChange();\n setOpen(!isOpen);\n };\n\n return h(\n \"div.expansion-panel-base\",\n {\n className: classNames(className, {\n expanded: isOpen,\n collapsed: !isOpen,\n }),\n },\n [\n h(\n ExpansionPanelSummary,\n {\n onChange: onChange_,\n expanded: isOpen,\n title,\n titleComponent,\n },\n h(\"div.expansion-summary-title-help\", [\n h(\"span.expansion-panel-subtext\", helpText),\n \" \",\n sideComponent,\n ]),\n ),\n h(Collapse, { isOpen }, h(\"div.expansion-children\", null, children)),\n ],\n );\n}\n\nexport function InfoPanelSection(props) {\n let { title, children, className, headerElement = null } = props;\n return h(\"div.info-panel-section\", { className }, [\n h(\"div.panel-subhead\", null, headerElement ?? h(\"h3\", title)),\n h(\"div.panel-content\", null, children),\n ]);\n}\n\nfunction ExpansionPanel(props) {\n return h(ExpansionPanelBase, {\n ...props,\n className: \"expansion-panel\",\n });\n}\n\nfunction SubExpansionPanel(props) {\n return h(ExpansionPanelBase, {\n ...props,\n className: \"expansion-panel sub-expansion-panel\",\n titleComponent: \"h4\",\n });\n}\n\nfunction ExpandableDetailsPanel(props) {\n let { title, children, value, headerElement, className } = props;\n const [isOpen, setIsOpen] = useState(false);\n headerElement ??= h([h(\"div.title\", title), value]);\n return h(\"div.expandable-details\", { className }, [\n h(\"div.expandable-details-main\", [\n h(\"div.expandable-details-header\", headerElement),\n h(\"div.expandable-details-toggle\", [\n h(Button, {\n small: true,\n minimal: true,\n active: isOpen,\n onClick: () => setIsOpen(!isOpen),\n icon: \"more\",\n }),\n ]),\n ]),\n h(\n Collapse,\n { isOpen },\n h(\"div.expandable-details-children\", null, children),\n ),\n ]);\n}\n\nfunction ExpansionBody({ title, className, children }) {\n return h(\"div.expansion-body\", { className }, [\n h(\"div.expansion-panel-detail-header\", title),\n h(\"div.expansion-panel-detail-body\", null, children),\n ]);\n}\n\nexport {\n ExpansionPanel,\n ExpansionPanelSummary,\n ExpandableDetailsPanel,\n SubExpansionPanel,\n ExpansionBody,\n PanelSubhead,\n};\n"],"names":["hyper","styles","PanelSubhead","classNames","Icon","useState","Collapse","Button"],"mappings":";;;;;;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,IAC5C,EAAE,mCAAmC,MAAM,QAAQ;AAAA,EAAA,CACpD;AACH;;;;;;;;"}
@@ -1,18 +0,0 @@
1
- import { PanelSubhead } from './headers';
2
- declare function ExpansionPanelSummary(props: any): import('react').FunctionComponentElement<any>;
3
- export declare function InfoPanelSection(props: any): import('react').ReactElement<{
4
- className: any;
5
- }, string | import('react').JSXElementConstructor<any>>;
6
- declare function ExpansionPanel(props: any): import('react').FunctionComponentElement<any>;
7
- declare function SubExpansionPanel(props: any): import('react').FunctionComponentElement<any>;
8
- declare function ExpandableDetailsPanel(props: any): import('react').ReactElement<{
9
- className: any;
10
- }, string | import('react').JSXElementConstructor<any>>;
11
- declare function ExpansionBody({ title, className, children }: {
12
- title: any;
13
- className: any;
14
- children: any;
15
- }): import('react').ReactElement<{
16
- className: any;
17
- }, string | import('react').JSXElementConstructor<any>>;
18
- export { ExpansionPanel, ExpansionPanelSummary, ExpandableDetailsPanel, SubExpansionPanel, ExpansionBody, PanelSubhead, };