@terraware/web-components 3.5.12-rc.7 → 3.5.12

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 (230) hide show
  1. package/components/AntSwitch/index.js +27 -0
  2. package/components/AntSwitch/styles.scss +66 -0
  3. package/components/Autocomplete/Autocomplete.js +131 -0
  4. package/components/Autocomplete/styles.scss +155 -0
  5. package/components/Badge/index.js +32 -0
  6. package/components/BusySpinner/index.js +49 -0
  7. package/components/Button/Button.js +51 -0
  8. package/components/Button/button.test.js +25 -0
  9. package/components/Button/styles.scss +453 -0
  10. package/components/Checkbox.js +70 -0
  11. package/components/Confirm/index.js +94 -0
  12. package/components/DatePicker/DatePicker.js +150 -0
  13. package/components/DatePicker/styles.scss +95 -0
  14. package/components/DialogBox/DialogBox.js +91 -0
  15. package/components/DialogBox/styles.scss +165 -0
  16. package/components/Divisor.js +21 -0
  17. package/components/Dropdown.js +102 -0
  18. package/components/ErrorBox/ErrorBox.js +47 -0
  19. package/components/ErrorBox/styles.scss +63 -0
  20. package/components/FileChooser/index.js +137 -0
  21. package/components/FormBottomBar/index.js +90 -0
  22. package/components/Icon/Icon.js +25 -0
  23. package/components/Icon/icons/index.js +241 -0
  24. package/components/Icon/styles.scss +41 -0
  25. package/components/IconTooltip/index.js +61 -0
  26. package/components/Map/MapBox.d.ts.map +1 -1
  27. package/components/Map/MapBox.js +479 -0
  28. package/components/Map/MapContainer.js +30 -0
  29. package/components/Map/MapDateSliderControl.js +66 -0
  30. package/components/Map/MapDrawer.js +45 -0
  31. package/components/Map/MapLegend.js +172 -0
  32. package/components/Map/MapViewStyleControl.js +74 -0
  33. package/components/Map/ReactMapboxWrapper.d.ts +3 -0
  34. package/components/Map/ReactMapboxWrapper.d.ts.map +1 -0
  35. package/components/Map/ReactMapboxWrapper.js +9 -0
  36. package/components/Map/index.js +190 -0
  37. package/components/Map/styles.scss +130 -0
  38. package/components/Map/types.js +24 -0
  39. package/components/Map/useMaintainLayerOrder.js +32 -0
  40. package/components/Message/Message.js +67 -0
  41. package/components/Message/styles.scss +202 -0
  42. package/components/MultiSelect/MultiSelect.test.js +75 -0
  43. package/components/MultiSelect/index.js +120 -0
  44. package/components/MultiSelect/styles.scss +180 -0
  45. package/components/Navbar/NavFooter.js +17 -0
  46. package/components/Navbar/NavItem.js +73 -0
  47. package/components/Navbar/NavSection.js +22 -0
  48. package/components/Navbar/Navbar.js +46 -0
  49. package/components/Navbar/SubNavbar.js +17 -0
  50. package/components/Navbar/styles.scss +155 -0
  51. package/components/Note.js +25 -0
  52. package/components/PageForm/index.js +43 -0
  53. package/components/PhotoChooser/index.js +137 -0
  54. package/components/Pill/index.js +46 -0
  55. package/components/Pill/styles.scss +50 -0
  56. package/components/PillList/index.js +29 -0
  57. package/components/PillList/styles.scss +12 -0
  58. package/components/PlacementWrapper/index.js +63 -0
  59. package/components/PopoverMenu/Popover.js +88 -0
  60. package/components/PopoverMenu/index.js +59 -0
  61. package/components/PopoverMultiSelect/index.js +62 -0
  62. package/components/PopoverMultiSelect/styles.scss +10 -0
  63. package/components/ProgressCircle/ProgressCircle.js +34 -0
  64. package/components/ProgressCircle/styles.scss +87 -0
  65. package/components/RadioButton.js +25 -0
  66. package/components/Select/Select.js +19 -0
  67. package/components/Select/SelectT.js +245 -0
  68. package/components/Select/styles.scss +307 -0
  69. package/components/Separator/index.js +21 -0
  70. package/components/Size.js +5 -0
  71. package/components/Slider/index.js +60 -0
  72. package/components/SummaryBox.js +73 -0
  73. package/components/Tabs/index.js +111 -0
  74. package/components/TextTruncated/index.js +146 -0
  75. package/components/Textfield/Textfield.js +172 -0
  76. package/components/Textfield/TruncatedTextArea.js +71 -0
  77. package/components/Textfield/styles.scss +271 -0
  78. package/components/Tooltip/Tooltip.js +54 -0
  79. package/components/ViewPhotosDialog/index.js +136 -0
  80. package/components/ViewPhotosDialog/styles.scss +18 -0
  81. package/components/svg/BlobbyGrayIconImage.js +39 -0
  82. package/components/svg/BlobbyGrayIconImport.js +39 -0
  83. package/components/svg/BlobbyGrayIconUploadToTheCloud.js +39 -0
  84. package/components/svg/BlobbyIconCloudChecked.js +156 -0
  85. package/components/svg/BlobbyIconExportOrUploadPhoto.js +156 -0
  86. package/components/svg/BlobbyIconFolder.js +156 -0
  87. package/components/svg/BlobbyIconGraphReport.js +156 -0
  88. package/components/svg/BlobbyIconHappy.js +156 -0
  89. package/components/svg/BlobbyIconHeartMonitor.js +156 -0
  90. package/components/svg/BlobbyIconLeaf.js +156 -0
  91. package/components/svg/BlobbyIconLibrary.js +156 -0
  92. package/components/svg/BlobbyIconNursery.js +158 -0
  93. package/components/svg/BlobbyIconOrganization.js +156 -0
  94. package/components/svg/BlobbyIconParchment.js +156 -0
  95. package/components/svg/BlobbyIconPeople.js +156 -0
  96. package/components/svg/BlobbyIconSeedBank.js +156 -0
  97. package/components/svg/BlobbyIconSeedling.js +156 -0
  98. package/components/svg/BlobbyIconSeeds.js +156 -0
  99. package/components/svg/BlobbyIconSite.js +159 -0
  100. package/components/svg/BlobbyIconSparkles.js +156 -0
  101. package/components/svg/BlobbyIconWrench.js +156 -0
  102. package/components/svg/Bug.js +25 -0
  103. package/components/svg/Calendar.js +25 -0
  104. package/components/svg/CaretDown.js +25 -0
  105. package/components/svg/CaretLeft.js +25 -0
  106. package/components/svg/CaretRight.js +25 -0
  107. package/components/svg/CaretUp.js +25 -0
  108. package/components/svg/ChevronDown.js +25 -0
  109. package/components/svg/ChevronUp.js +25 -0
  110. package/components/svg/Close.js +25 -0
  111. package/components/svg/Critical.js +25 -0
  112. package/components/svg/Edit.js +156 -0
  113. package/components/svg/Error.js +25 -0
  114. package/components/svg/Filter.js +25 -0
  115. package/components/svg/Folder.js +25 -0
  116. package/components/svg/Help.js +25 -0
  117. package/components/svg/Home.js +25 -0
  118. package/components/svg/IconAdd.js +25 -0
  119. package/components/svg/IconArrowRight.js +27 -0
  120. package/components/svg/IconBusinessNetwork.js +25 -0
  121. package/components/svg/IconCancel.js +25 -0
  122. package/components/svg/IconChargingBattery.js +25 -0
  123. package/components/svg/IconCheckmark.js +25 -0
  124. package/components/svg/IconCoinInHand.js +25 -0
  125. package/components/svg/IconColumns.js +25 -0
  126. package/components/svg/IconComment.js +26 -0
  127. package/components/svg/IconDashboard.js +25 -0
  128. package/components/svg/IconDataMigration.js +25 -0
  129. package/components/svg/IconEdit.js +27 -0
  130. package/components/svg/IconExport.js +25 -0
  131. package/components/svg/IconExternalLink.js +25 -0
  132. package/components/svg/IconEye.js +25 -0
  133. package/components/svg/IconEyeOff.js +25 -0
  134. package/components/svg/IconFile.js +25 -0
  135. package/components/svg/IconFolder.js +25 -0
  136. package/components/svg/IconFullScreen.js +26 -0
  137. package/components/svg/IconFutures.js +25 -0
  138. package/components/svg/IconGraphReport.js +25 -0
  139. package/components/svg/IconHeartMonitor.js +25 -0
  140. package/components/svg/IconHelp.js +27 -0
  141. package/components/svg/IconHistory.js +25 -0
  142. package/components/svg/IconImport.js +25 -0
  143. package/components/svg/IconIndex.js +25 -0
  144. package/components/svg/IconLayers.js +25 -0
  145. package/components/svg/IconLibrary.js +26 -0
  146. package/components/svg/IconList.js +25 -0
  147. package/components/svg/IconLivePlant.js +25 -0
  148. package/components/svg/IconLocations.js +25 -0
  149. package/components/svg/IconMail.js +25 -0
  150. package/components/svg/IconManager.js +25 -0
  151. package/components/svg/IconMarker.js +25 -0
  152. package/components/svg/IconMenu.js +25 -0
  153. package/components/svg/IconMenuHorizontal.js +25 -0
  154. package/components/svg/IconModule.js +25 -0
  155. package/components/svg/IconMyLocation.js +25 -0
  156. package/components/svg/IconNote.js +27 -0
  157. package/components/svg/IconNursery.js +27 -0
  158. package/components/svg/IconOrg.js +25 -0
  159. package/components/svg/IconParchment.js +25 -0
  160. package/components/svg/IconPhoto.js +25 -0
  161. package/components/svg/IconRedo.js +25 -0
  162. package/components/svg/IconRestorationSite.js +25 -0
  163. package/components/svg/IconSeedBank.js +25 -0
  164. package/components/svg/IconSeedling.js +25 -0
  165. package/components/svg/IconSettings.js +25 -0
  166. package/components/svg/IconSlice.js +25 -0
  167. package/components/svg/IconSubmit.js +25 -0
  168. package/components/svg/IconSubtract.js +27 -0
  169. package/components/svg/IconSynced.js +25 -0
  170. package/components/svg/IconTrashCan.js +25 -0
  171. package/components/svg/IconTreasureMap.js +25 -0
  172. package/components/svg/IconUndo.js +25 -0
  173. package/components/svg/IconVariable.js +25 -0
  174. package/components/svg/IconWifi.js +25 -0
  175. package/components/svg/Info.js +25 -0
  176. package/components/svg/Key.js +25 -0
  177. package/components/svg/Leaf.js +25 -0
  178. package/components/svg/Lock.js +25 -0
  179. package/components/svg/Logo.js +43 -0
  180. package/components/svg/MenuVertical.js +25 -0
  181. package/components/svg/Notification.js +25 -0
  182. package/components/svg/Person.js +25 -0
  183. package/components/svg/Plus.js +25 -0
  184. package/components/svg/RestorationSite.js +25 -0
  185. package/components/svg/Search.js +25 -0
  186. package/components/svg/Seeds.js +25 -0
  187. package/components/svg/Site.js +25 -0
  188. package/components/svg/Sparkles.js +25 -0
  189. package/components/svg/Species.js +25 -0
  190. package/components/svg/Species2.js +156 -0
  191. package/components/svg/Spinner.js +52 -0
  192. package/components/svg/Success.js +25 -0
  193. package/components/svg/SuccessFilled.js +25 -0
  194. package/components/svg/TerrawareLogoDesktop.js +49 -0
  195. package/components/svg/TerrawareLogoMobile.js +30 -0
  196. package/components/svg/Touchscreen.js +25 -0
  197. package/components/svg/UploadCloud.js +156 -0
  198. package/components/svg/Warning.js +25 -0
  199. package/components/svg/WelcomeClipboard.js +133 -0
  200. package/components/svg/index.js +832 -0
  201. package/components/table/EnhancedTableToolbar.js +76 -0
  202. package/components/table/EnhancedTableToolbarV2.js +49 -0
  203. package/components/table/TableCellRenderer.js +244 -0
  204. package/components/table/TableHeader.js +75 -0
  205. package/components/table/TableHeaderItem.js +100 -0
  206. package/components/table/density.js +28 -0
  207. package/components/table/index.js +346 -0
  208. package/components/table/sort.js +72 -0
  209. package/components/table/sort.test.js +37 -0
  210. package/components/table/types.js +5 -0
  211. package/components/types/index.js +5 -0
  212. package/fonts/Inter.ttf +0 -0
  213. package/index.css +11 -0
  214. package/index.js +377 -0
  215. package/package.json +2 -5
  216. package/setupTests.js +5 -0
  217. package/style-dictionary-dist/TerrawareTheme.js +193 -0
  218. package/style-dictionary-dist/terraware.scss +414 -0
  219. package/theme.js +86 -0
  220. package/utils/date.js +124 -0
  221. package/utils/date.test.js +87 -0
  222. package/utils/index.js +53 -0
  223. package/utils/preventDefaultEvent.js +8 -0
  224. package/utils/text.js +17 -0
  225. package/utils/text.test.js +23 -0
  226. package/utils/useDeviceInfo.js +85 -0
  227. package/index.cjs.js +0 -88606
  228. package/index.cjs.js.map +0 -1
  229. package/index.esm.js +0 -88533
  230. package/index.esm.js.map +0 -1
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _material = require("@mui/material");
10
+ var _utils = require("../../utils");
11
+ var _AntSwitch = _interopRequireDefault(require("../AntSwitch"));
12
+ var _Icon = _interopRequireDefault(require("../Icon/Icon"));
13
+ const MapLegend = _ref => {
14
+ let {
15
+ legends
16
+ } = _ref;
17
+ const theme = (0, _material.useTheme)();
18
+ const {
19
+ isMobile,
20
+ isDesktop
21
+ } = (0, _utils.useDeviceInfo)();
22
+ const legendComponents = legends.map((legend, index) => {
23
+ const isFirst = index === 0;
24
+ const isLast = index === legends.length - 1;
25
+ const switchComponent = legend.type === 'highlight' ? /*#__PURE__*/_react.default.createElement(_AntSwitch.default, {
26
+ disabled: legend.disabled,
27
+ checked: legend.visible,
28
+ onChange: legend.setVisible
29
+ }) : undefined;
30
+ const titleComponent = /*#__PURE__*/_react.default.createElement(_material.Typography, {
31
+ fontSize: "16px",
32
+ fontWeight: 600,
33
+ width: isMobile ? '100%' : undefined,
34
+ marginRight: isMobile ? 0 : theme.spacing(4),
35
+ paddingLeft: switchComponent ? theme.spacing(1) : theme.spacing(0)
36
+ }, legend.title, legend.tooltip && /*#__PURE__*/_react.default.createElement(_material.Tooltip, {
37
+ title: legend.tooltip,
38
+ sx: {
39
+ display: 'inline-block',
40
+ verticalAlign: 'text-top',
41
+ marginLeft: theme.spacing(1)
42
+ }
43
+ }, /*#__PURE__*/_react.default.createElement(_material.Box, {
44
+ display: "flex"
45
+ }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
46
+ fillColor: theme.palette.TwClrIcnInfo,
47
+ name: "info",
48
+ size: "small"
49
+ }))));
50
+ const itemComponents = legend.items.map((item, itemIndex) => {
51
+ const onClick = legend.disabled ? undefined : legend.type === 'layer' ? item.disabled ? undefined : () => legend.setSelectedLayer(item.id) : legend.type === 'marker' ? item.disabled ? undefined : () => {
52
+ var _setVisible, _ref2;
53
+ return (_setVisible = (_ref2 = item).setVisible) === null || _setVisible === void 0 ? void 0 : _setVisible.call(_ref2, !item.visible);
54
+ } : undefined;
55
+ const disabled = legend.disabled || (legend.type === 'layer' ? item.disabled : legend.type === 'marker' ? item.disabled : false) || false;
56
+ const selected = legend.type === 'layer' ? item.id === legend.selectedLayer : legend.type === 'marker' ? item.visible : false;
57
+ const logoComponent = () => {
58
+ if (item.style.type === 'icon') {
59
+ return /*#__PURE__*/_react.default.createElement(_Icon.default, {
60
+ name: item.style.iconName,
61
+ fillColor: item.style.iconColor,
62
+ style: {
63
+ marginRight: theme.spacing(1)
64
+ },
65
+ size: 'small'
66
+ });
67
+ } else {
68
+ var _item$style$borderCol, _item$style$opacity;
69
+ return /*#__PURE__*/_react.default.createElement(_material.Box, {
70
+ display: 'flex',
71
+ sx: {
72
+ border: "2px solid ".concat((_item$style$borderCol = item.style.borderColor) !== null && _item$style$borderCol !== void 0 ? _item$style$borderCol : theme.palette.TwClrBaseGreen300),
73
+ opacity: disabled ? 0.7 : 1.0,
74
+ height: '16px',
75
+ width: '24px',
76
+ minWidth: '24px',
77
+ marginRight: theme.spacing(1)
78
+ }
79
+ }, /*#__PURE__*/_react.default.createElement(_material.Box, {
80
+ height: '16px',
81
+ width: '24px',
82
+ sx: {
83
+ backgroundColor: item.style.fillColor,
84
+ backgroundImage: item.style.fillPatternUrl ? "url('".concat(item.style.fillPatternUrl, "')") : undefined,
85
+ backgroundRepeat: 'repeat',
86
+ opacity: (_item$style$opacity = item.style.opacity) !== null && _item$style$opacity !== void 0 ? _item$style$opacity : 0.2
87
+ }
88
+ }));
89
+ }
90
+ };
91
+ const visibleComponent = () => {
92
+ switch (legend.type) {
93
+ case 'marker':
94
+ const featureItem = item;
95
+ const visibleIcon = featureItem.visible ? /*#__PURE__*/_react.default.createElement(_Icon.default, {
96
+ name: "iconEye"
97
+ }) : /*#__PURE__*/_react.default.createElement(_Icon.default, {
98
+ name: "iconEyeOff"
99
+ });
100
+ return /*#__PURE__*/_react.default.createElement(_material.Box, {
101
+ display: "flex"
102
+ }, visibleIcon);
103
+ case 'layer':
104
+ const layerItem = item;
105
+ return /*#__PURE__*/_react.default.createElement(_material.Box, {
106
+ display: "flex",
107
+ sx: {
108
+ visibility: layerItem.id === legend.selectedLayer ? 'visible' : 'hidden'
109
+ }
110
+ }, /*#__PURE__*/_react.default.createElement(_Icon.default, {
111
+ name: "checkmark",
112
+ style: {
113
+ marginRight: theme.spacing(1)
114
+ }
115
+ }));
116
+ case 'highlight':
117
+ return undefined;
118
+ }
119
+ };
120
+ return /*#__PURE__*/_react.default.createElement(_material.Box, {
121
+ onClick: onClick,
122
+ display: "flex",
123
+ alignItems: "center",
124
+ sx: {
125
+ cursor: onClick ? 'pointer' : 'default',
126
+ background: selected ? theme.palette.TwClrBgSecondary : 'none',
127
+ borderRadius: theme.spacing(1),
128
+ padding: theme.spacing(1, 1),
129
+ opacity: disabled ? '0.5' : 1
130
+ },
131
+ justifyContent: 'space-between',
132
+ key: "".concat(index, "-").concat(itemIndex)
133
+ }, /*#__PURE__*/_react.default.createElement(_material.Box, {
134
+ display: "flex",
135
+ alignItems: "center",
136
+ paddingRight: theme.spacing(1)
137
+ }, logoComponent(), /*#__PURE__*/_react.default.createElement(_material.Typography, {
138
+ fontSize: "14px",
139
+ fontWeight: 400
140
+ }, item.label)), /*#__PURE__*/_react.default.createElement(_material.Box, {
141
+ display: "flex"
142
+ }, visibleComponent()));
143
+ });
144
+ return /*#__PURE__*/_react.default.createElement(_material.Box, {
145
+ key: legend.title,
146
+ sx: {
147
+ opacity: legend.disabled ? 0.7 : 1
148
+ },
149
+ borderBottom: isLast ? 'none' : "1px solid ".concat(theme.palette.TwClrBrdrTertiary)
150
+ }, /*#__PURE__*/_react.default.createElement(_material.Box, {
151
+ paddingBottom: 2,
152
+ paddingTop: isFirst ? 0 : 2,
153
+ flexDirection: 'column'
154
+ }, /*#__PURE__*/_react.default.createElement(_material.Box, {
155
+ display: "flex",
156
+ alignItems: 'center',
157
+ paddingLeft: theme.spacing(1)
158
+ }, switchComponent, titleComponent), itemComponents));
159
+ });
160
+ return /*#__PURE__*/_react.default.createElement(_material.Box, {
161
+ display: "flex",
162
+ justifyItems: "flex-start",
163
+ padding: theme.spacing(2, 1),
164
+ flexDirection: 'column',
165
+ maxWidth: isDesktop ? '184px' : 'stretch',
166
+ minWidth: isDesktop ? '160px' : undefined,
167
+ width: isDesktop ? 'auto' : 'stretch',
168
+ margin: 0,
169
+ overflow: 'scroll'
170
+ }, legendComponents);
171
+ };
172
+ var _default = exports.default = MapLegend;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _material = require("@mui/material");
11
+ var _PopoverMenu = _interopRequireDefault(require("../PopoverMenu"));
12
+ var _types = require("./types");
13
+ const MapViewStyleControl = _ref => {
14
+ var _mapViewStyleNames2;
15
+ let {
16
+ containerId,
17
+ mapViewStyle,
18
+ mapViewStyleNames,
19
+ setMapViewStyle
20
+ } = _ref;
21
+ const theme = (0, _material.useTheme)();
22
+ const viewOptions = (0, _react.useMemo)(() => {
23
+ return _types.MapViewStyles.map(style => {
24
+ var _mapViewStyleNames;
25
+ return {
26
+ label: (_mapViewStyleNames = mapViewStyleNames === null || mapViewStyleNames === void 0 ? void 0 : mapViewStyleNames(style)) !== null && _mapViewStyleNames !== void 0 ? _mapViewStyleNames : style,
27
+ value: style
28
+ };
29
+ });
30
+ }, [mapViewStyleNames]);
31
+ const onSelectMapViewStyle = (0, _react.useCallback)(item => {
32
+ setMapViewStyle(item.value);
33
+ }, []);
34
+ const container = (0, _react.useMemo)(() => {
35
+ if (containerId) {
36
+ return document.getElementById(containerId);
37
+ }
38
+ }, [containerId]);
39
+ return /*#__PURE__*/_react.default.createElement(_material.Box, {
40
+ sx: {
41
+ position: 'absolute',
42
+ top: '10px',
43
+ left: '45px',
44
+ zIndex: 10,
45
+ height: 28,
46
+ backgroundColor: "".concat(theme.palette.TwClrBaseWhite),
47
+ borderRadius: '4px',
48
+ display: 'flex',
49
+ alignItems: 'center',
50
+ '& .MuiButtonBase-root': {
51
+ padding: 0
52
+ },
53
+ '& .MuiButtonBase-root.MuiMenuItem-root': {
54
+ fontSize: '12px'
55
+ },
56
+ '& svg': {
57
+ marginLeft: 0
58
+ }
59
+ }
60
+ }, /*#__PURE__*/_react.default.createElement(_PopoverMenu.default, {
61
+ anchor: /*#__PURE__*/_react.default.createElement(_material.Box, {
62
+ component: "span",
63
+ sx: {
64
+ fontSize: '12px',
65
+ paddingLeft: theme.spacing(0.5),
66
+ color: theme.palette.TwClrTxt
67
+ }
68
+ }, (_mapViewStyleNames2 = mapViewStyleNames === null || mapViewStyleNames === void 0 ? void 0 : mapViewStyleNames(mapViewStyle)) !== null && _mapViewStyleNames2 !== void 0 ? _mapViewStyleNames2 : mapViewStyle),
69
+ container: container,
70
+ menuSections: [viewOptions],
71
+ onClick: onSelectMapViewStyle
72
+ }));
73
+ };
74
+ var _default = exports.default = MapViewStyleControl;
@@ -0,0 +1,3 @@
1
+ import ReactMapbox from 'react-map-gl/mapbox';
2
+ export default ReactMapbox;
3
+ //# sourceMappingURL=ReactMapboxWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReactMapboxWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/Map/ReactMapboxWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAE9C,eAAe,WAAW,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _mapbox = _interopRequireDefault(require("react-map-gl/mapbox"));
9
+ var _default = exports.default = _mapbox.default;
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _MapBox = _interopRequireDefault(require("./MapBox"));
11
+ var _MapContainer = _interopRequireDefault(require("./MapContainer"));
12
+ var _MapDrawer = _interopRequireDefault(require("./MapDrawer"));
13
+ var _MapLegend = _interopRequireDefault(require("./MapLegend"));
14
+ const MapComponent = props => {
15
+ const {
16
+ clusterRadius,
17
+ controlBottomLeft,
18
+ controlTopRight,
19
+ cursorInteract,
20
+ cursorMap,
21
+ disableDoubleClickZoom,
22
+ disableZoom,
23
+ drawerChildren,
24
+ drawerOpen,
25
+ drawerSize,
26
+ drawerTitle,
27
+ features,
28
+ hideFullScreenControl,
29
+ hideLegend,
30
+ hideMapViewStyleControl,
31
+ hideZoomControl,
32
+ initialSelectedLayerId,
33
+ initialMapViewStyle,
34
+ initialViewState,
35
+ mapContainerId,
36
+ mapId,
37
+ onClickCanvas,
38
+ setDrawerOpen,
39
+ token
40
+ } = props;
41
+ const [mapViewStyle, setMapViewStyle] = (0, _react.useState)(initialMapViewStyle !== null && initialMapViewStyle !== void 0 ? initialMapViewStyle : 'Streets');
42
+ const [visibleHighlights, setVisibleHighlights] = (0, _react.useState)([]);
43
+ const setHighlightVisible = (0, _react.useCallback)(highlightId => visible => {
44
+ if (visible) {
45
+ setVisibleHighlights(_visibleHighlights => [..._visibleHighlights, highlightId]);
46
+ } else {
47
+ setVisibleHighlights(_visibleHighlights => _visibleHighlights.filter(_highlightId => _highlightId !== highlightId));
48
+ }
49
+ }, []);
50
+ const [visibleMarkers, setVisibleMarkers] = (0, _react.useState)([]);
51
+ const setMarkerVisible = (0, _react.useCallback)(markerGroupId => visible => {
52
+ if (visible) {
53
+ setVisibleMarkers(_visibleMarkers => [..._visibleMarkers, markerGroupId]);
54
+ } else {
55
+ setVisibleMarkers(_visibleMarkers => _visibleMarkers.filter(_markerGroupId => _markerGroupId !== markerGroupId));
56
+ }
57
+ }, []);
58
+ const [selectedLayer, setSelectedLayer] = (0, _react.useState)(initialSelectedLayerId);
59
+ const legends = (0, _react.useMemo)(() => {
60
+ return features === null || features === void 0 ? void 0 : features.map(feature => {
61
+ const baseLegendGroup = {
62
+ disabled: feature.sectionDisabled,
63
+ title: feature.sectionTitle,
64
+ tooltip: feature.sectionTooltip
65
+ };
66
+ switch (feature.type) {
67
+ case 'highlight':
68
+ return {
69
+ ...baseLegendGroup,
70
+ items: feature.legendItems,
71
+ type: 'highlight',
72
+ visible: visibleHighlights.findIndex(highlightId => highlightId === feature.highlight.highlightId) >= 0,
73
+ setVisible: setHighlightVisible(feature.highlight.highlightId)
74
+ };
75
+ case 'layer':
76
+ return {
77
+ ...baseLegendGroup,
78
+ items: feature.layers.map(layer => ({
79
+ disabled: layer.disabled,
80
+ id: layer.layerId,
81
+ label: layer.label,
82
+ style: layer.style
83
+ })),
84
+ selectedLayer,
85
+ setSelectedLayer,
86
+ type: 'layer'
87
+ };
88
+ case 'marker':
89
+ return {
90
+ ...baseLegendGroup,
91
+ items: feature.groups.map(group => ({
92
+ disabled: group.disabled,
93
+ id: group.markerGroupId,
94
+ label: group.label,
95
+ style: group.style,
96
+ setVisible: setMarkerVisible(group.markerGroupId),
97
+ visible: visibleMarkers.findIndex(markerId => markerId === group.markerGroupId) >= 0
98
+ })),
99
+ type: 'marker'
100
+ };
101
+ }
102
+ });
103
+ }, [features, selectedLayer, visibleHighlights, visibleMarkers]);
104
+ const layers = (0, _react.useMemo)(() => {
105
+ var _features$filter, _features$filter$flat;
106
+ return features === null || features === void 0 ? void 0 : (_features$filter = features.filter(feature => feature.type === 'layer')) === null || _features$filter === void 0 ? void 0 : (_features$filter$flat = _features$filter.flatMap(feature => feature.layers)) === null || _features$filter$flat === void 0 ? void 0 : _features$filter$flat.filter(layer => layer.layerId === selectedLayer);
107
+ }, [features, selectedLayer]);
108
+ const highlightGroups = (0, _react.useMemo)(() => {
109
+ var _features$filter2, _features$filter2$map;
110
+ return features === null || features === void 0 ? void 0 : (_features$filter2 = features.filter(feature => feature.type === 'highlight')) === null || _features$filter2 === void 0 ? void 0 : (_features$filter2$map = _features$filter2.map(feature => feature.highlight)) === null || _features$filter2$map === void 0 ? void 0 : _features$filter2$map.filter(highlight => visibleHighlights.findIndex(_highlightId => _highlightId === highlight.highlightId) >= 0);
111
+ }, [features, visibleHighlights]);
112
+ const markerGroups = (0, _react.useMemo)(() => {
113
+ var _features$filter3;
114
+ return features === null || features === void 0 ? void 0 : (_features$filter3 = features.filter(feature => feature.type === 'marker')) === null || _features$filter3 === void 0 ? void 0 : _features$filter3.flatMap(feature => feature.groups).filter(group => visibleMarkers.findIndex(_markerId => _markerId === group.markerGroupId) >= 0);
115
+ }, [features, visibleMarkers]);
116
+ const mapViewState = (0, _react.useMemo)(() => {
117
+ if (initialViewState) {
118
+ return initialViewState;
119
+ } else if (features) {
120
+ const coordinates = features.filter(feature => feature.type === 'layer').flatMap(feature => feature.layers).flatMap(layer => layer.features).map(geoFeature => geoFeature.geometry.coordinates).flat().flat().flat();
121
+ if (coordinates.length > 0) {
122
+ let minLat = Infinity;
123
+ let maxLat = -Infinity;
124
+ let minLng = Infinity;
125
+ let maxLng = -Infinity;
126
+ for (const [lng, lat] of coordinates) {
127
+ minLat = Math.min(minLat, lat);
128
+ maxLat = Math.max(maxLat, lat);
129
+ minLng = Math.min(minLng, lng);
130
+ maxLng = Math.max(maxLng, lng);
131
+ }
132
+ const centerLng = (minLng + maxLng) / 2;
133
+ const centerLat = (minLat + maxLat) / 2;
134
+ return {
135
+ latitude: centerLat,
136
+ longitude: centerLng,
137
+ zoom: 12
138
+ };
139
+ }
140
+ }
141
+ }, [initialViewState]);
142
+ const mapImageUrls = (0, _react.useMemo)(() => {
143
+ var _features$filter4, _features$filter5;
144
+ const layerFeatures = (_features$filter4 = features === null || features === void 0 ? void 0 : features.filter(feature => feature.type === 'layer')) !== null && _features$filter4 !== void 0 ? _features$filter4 : [];
145
+ const highlightFeatures = (_features$filter5 = features === null || features === void 0 ? void 0 : features.filter(feature => feature.type === 'highlight')) !== null && _features$filter5 !== void 0 ? _features$filter5 : [];
146
+ const layerImageUrls = layerFeatures.flatMap(feature => feature.layers).map(layer => layer.style.fillPatternUrl).filter(url => url !== undefined);
147
+ const highlightImageUrls = highlightFeatures.flatMap(feature => feature.highlight.highlights).map(highlight => highlight.style.fillPatternUrl).filter(url => url !== undefined);
148
+ const imageUrls = new Set(layerImageUrls);
149
+ highlightImageUrls.forEach(url => imageUrls.add(url));
150
+ return Array.from(imageUrls);
151
+ }, [features]);
152
+ return /*#__PURE__*/_react.default.createElement(_MapContainer.default, {
153
+ containerId: mapContainerId !== null && mapContainerId !== void 0 ? mapContainerId : 'map-container',
154
+ map: /*#__PURE__*/_react.default.createElement(_MapBox.default, {
155
+ clusterRadius: clusterRadius,
156
+ containerId: mapContainerId !== null && mapContainerId !== void 0 ? mapContainerId : 'map-container',
157
+ controlBottomLeft: controlBottomLeft,
158
+ controlTopRight: controlTopRight,
159
+ cursorInteract: cursorInteract,
160
+ cursorMap: cursorMap,
161
+ disableDoubleClickZoom: disableDoubleClickZoom,
162
+ disableZoom: disableZoom,
163
+ drawerOpen: drawerOpen,
164
+ hideFullScreenControl: hideFullScreenControl,
165
+ hideMapViewStyleControl: hideMapViewStyleControl,
166
+ hideZoomControl: hideZoomControl,
167
+ highlightGroups: highlightGroups,
168
+ initialViewState: mapViewState,
169
+ layers: layers,
170
+ mapId: mapId !== null && mapId !== void 0 ? mapId : 'mapId',
171
+ mapImageUrls: mapImageUrls,
172
+ mapViewStyle: mapViewStyle,
173
+ markerGroups: markerGroups,
174
+ onClickCanvas: onClickCanvas,
175
+ setMapViewStyle: setMapViewStyle,
176
+ token: token
177
+ }),
178
+ drawer: /*#__PURE__*/_react.default.createElement(_MapDrawer.default, {
179
+ open: drawerOpen !== null && drawerOpen !== void 0 ? drawerOpen : false,
180
+ onClose: () => setDrawerOpen === null || setDrawerOpen === void 0 ? void 0 : setDrawerOpen(false),
181
+ size: drawerSize !== null && drawerSize !== void 0 ? drawerSize : 'small',
182
+ title: drawerTitle !== null && drawerTitle !== void 0 ? drawerTitle : ''
183
+ }, drawerChildren),
184
+ drawerOpen: drawerOpen,
185
+ legend: !hideLegend && legends && /*#__PURE__*/_react.default.createElement(_MapLegend.default, {
186
+ legends: legends
187
+ })
188
+ });
189
+ };
190
+ var _default = exports.default = MapComponent;
@@ -0,0 +1,130 @@
1
+ @import '../../style-dictionary-dist/terraware.scss';
2
+
3
+ .map-container {
4
+ border: 1px solid $tw-clr-brdr-tertiary;
5
+ border-radius: 8px;
6
+ display: flex;
7
+ overflow: hidden;
8
+
9
+ &--desktop {
10
+ flex-direction: row;
11
+ height: 700px;
12
+ max-height: 700px;
13
+
14
+ :fullscreen {
15
+ max-height: none;
16
+ }
17
+ }
18
+
19
+ &--mobile {
20
+ flex-direction: column;
21
+ }
22
+
23
+ &--mobile-drawer-open {
24
+ border: none;
25
+ border-radius: none;
26
+ }
27
+
28
+ .map-holder {
29
+ display: flex;
30
+ flex-direction: column;
31
+ height: auto;
32
+ width: 100%;
33
+
34
+ &--hidden {
35
+ display: none;
36
+ }
37
+ }
38
+ }
39
+
40
+ .map-drawer {
41
+ display: flex;
42
+ flex-direction: column;
43
+ background: $tw-clr-base-white;
44
+
45
+ &--mobile {
46
+ width: stretch;
47
+ }
48
+
49
+ &--small {
50
+ min-width: 280px;
51
+ width: 280px;
52
+ }
53
+ &--medium {
54
+ min-width: 420px;
55
+ width: 420px;
56
+ }
57
+
58
+ &--header {
59
+ padding: $tw-spc-base-x-small;
60
+ display: flex;
61
+ justify-content: space-between;
62
+ align-items: center;
63
+ .title {
64
+ font-family: $tw-fnt-mssg-title-font-family;
65
+ font-size: $tw-fnt-mssg-title-font-size;
66
+ font-weight: $tw-fnt-mssg-title-font-weight;
67
+ line-height: $tw-fnt-mssg-title-line-height;
68
+ color: $tw-clr-txt;
69
+ text-align: center;
70
+ text-overflow: ellipsis;
71
+ overflow: hidden;
72
+ white-space: nowrap;
73
+ margin: 0;
74
+ width: 100%;
75
+ }
76
+
77
+ .icon-close {
78
+ fill: $tw-clr-icn-secondary;
79
+ height: $tw-sz-base-medium;
80
+ width: $tw-sz-base-medium;
81
+ }
82
+ }
83
+
84
+ &--body {
85
+ background: $tw-clr-base-white;
86
+ padding: $tw-spc-base-x-small $tw-spc-base-small;
87
+ text-align: start;
88
+ overflow: auto;
89
+ white-space: pre-wrap;
90
+ }
91
+
92
+ &--message {
93
+ font-family: $tw-fnt-dlg-bx-message-font-family;
94
+ font-size: $tw-fnt-dlg-bx-message-font-size;
95
+ font-weight: $tw-fnt-dlg-bx-message-font-weight;
96
+ line-height: $tw-fnt-dlg-bx-message-line-height;
97
+ color: $tw-clr-txt;
98
+ width: 100%;
99
+ text-align: start;
100
+ }
101
+ }
102
+
103
+ .map-marker {
104
+ width: 24px;
105
+ height: 24px;
106
+ align-items: center;
107
+ background-color: white;
108
+ border: 1px solid black;
109
+ border-radius: 50%;
110
+ cursor: pointer;
111
+ display: flex;
112
+ flex-direction: column;
113
+ justify-content: center;
114
+
115
+ &--cluster {
116
+ width: 42px;
117
+ height: 42px;
118
+
119
+ .count {
120
+ font-family: 'Inter', sans-serif;
121
+ font-size: 10px;
122
+ font-weight: 600;
123
+ line-height: 16px;
124
+ color: $tw-clr-txt;
125
+ text-align: center;
126
+ margin: 0;
127
+ width: 100%;
128
+ }
129
+ }
130
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stylesUrl = exports.MapViewStyles = void 0;
7
+ /**
8
+ * Properties class for GeoJson, with a few reserved object defined.
9
+ */
10
+
11
+ // Each layer item will become a feature, with a property of id.
12
+
13
+ // Each layer will become a set of features that have the same type.
14
+
15
+ // Additional shading/annotations for map entities
16
+
17
+ const MapViewStyles = exports.MapViewStyles = ['Outdoors', 'Satellite', 'Light', 'Dark', 'Streets'];
18
+ const stylesUrl = exports.stylesUrl = {
19
+ Outdoors: 'mapbox://styles/mapbox/outdoors-v12?optimize=true',
20
+ Satellite: 'mapbox://styles/mapbox/satellite-streets-v12?optimize=true',
21
+ Streets: 'mapbox://styles/mapbox/streets-v12?optimize=true',
22
+ Light: 'mapbox://styles/mapbox/light-v11?optimize=true',
23
+ Dark: 'mapbox://styles/mapbox/dark-v11?optimize=true'
24
+ };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useMaintainLayerOrder = void 0;
7
+ var _react = require("react");
8
+ /**
9
+ * Ensures that all given layers maintain strict order in the Mapbox layer stack.
10
+ */
11
+ const useMaintainLayerOrder = (mapRef, orderedLayerIds) => {
12
+ (0, _react.useEffect)(() => {
13
+ const map = mapRef.current;
14
+ if (!map) {
15
+ return;
16
+ }
17
+
18
+ // Only move layers that exist
19
+ const existingLayerIds = orderedLayerIds.filter(id => map.getLayer(id));
20
+
21
+ // Reverse iterate so first in array ends up lowest
22
+ for (let i = existingLayerIds.length - 1; i >= 0; i--) {
23
+ const layerId = existingLayerIds[i];
24
+ try {
25
+ map.moveLayer(layerId, i < existingLayerIds.length - 1 ? existingLayerIds[i + 1] : undefined);
26
+ } catch (e) {
27
+ // moveLayer will throw if layer doesn't exist in current style
28
+ }
29
+ }
30
+ }, [mapRef, orderedLayerIds]);
31
+ };
32
+ exports.useMaintainLayerOrder = useMaintainLayerOrder;