@terraware/web-components 4.2.25 → 4.2.26-rc.1

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 (323) hide show
  1. package/_vendor/react-multi-carousel/index.js +13 -0
  2. package/_vendor/react-multi-carousel/lib/Arrows.js +13 -0
  3. package/_vendor/react-multi-carousel/lib/Carousel.js +19 -0
  4. package/_vendor/react-multi-carousel/lib/CarouselItems.js +14 -0
  5. package/_vendor/react-multi-carousel/lib/Dots.js +16 -0
  6. package/_vendor/react-multi-carousel/lib/index.js +13 -0
  7. package/_vendor/react-multi-carousel/lib/types.js +13 -0
  8. package/_vendor/react-multi-carousel/lib/utils/clones.js +14 -0
  9. package/_vendor/react-multi-carousel/lib/utils/common.js +13 -0
  10. package/_vendor/react-multi-carousel/lib/utils/dots.js +14 -0
  11. package/_vendor/react-multi-carousel/lib/utils/elementWidth.js +12 -0
  12. package/_vendor/react-multi-carousel/lib/utils/index.js +20 -0
  13. package/_vendor/react-multi-carousel/lib/utils/mouseOrTouchMove.js +14 -0
  14. package/_vendor/react-multi-carousel/lib/utils/next.js +13 -0
  15. package/_vendor/react-multi-carousel/lib/utils/previous.js +14 -0
  16. package/_vendor/react-multi-carousel/lib/utils/throttle.js +12 -0
  17. package/_vendor/react-multi-carousel/lib/utils/throwError.js +14 -0
  18. package/_virtual/Arrows.js +3 -0
  19. package/_virtual/Carousel.js +3 -0
  20. package/_virtual/CarouselItems.js +3 -0
  21. package/_virtual/Dots.js +3 -0
  22. package/_virtual/_commonjsHelpers.js +5 -0
  23. package/_virtual/clones.js +3 -0
  24. package/_virtual/common.js +3 -0
  25. package/_virtual/dots2.js +3 -0
  26. package/_virtual/elementWidth.js +3 -0
  27. package/_virtual/index.js +7 -0
  28. package/_virtual/index2.js +3 -0
  29. package/_virtual/index3.js +3 -0
  30. package/_virtual/mouseOrTouchMove.js +3 -0
  31. package/_virtual/next.js +3 -0
  32. package/_virtual/previous.js +3 -0
  33. package/_virtual/throttle.js +3 -0
  34. package/_virtual/throwError.js +3 -0
  35. package/_virtual/types.js +3 -0
  36. package/components/AntSwitch/index.js +6 -4
  37. package/components/Autocomplete/Autocomplete.js +19 -16
  38. package/components/Badge/index.js +8 -6
  39. package/components/BusySpinner/index.js +11 -8
  40. package/components/Button/Button.js +12 -9
  41. package/components/Checkbox.js +11 -8
  42. package/components/Confirm/index.js +14 -17
  43. package/components/DatePicker/DatePicker.js +19 -23
  44. package/components/DialogBox/DialogBox.js +25 -20
  45. package/components/Divisor.js +11 -8
  46. package/components/Dropdown.js +18 -15
  47. package/components/EditableTable/index.js +17 -14
  48. package/components/ErrorBox/ErrorBox.js +18 -15
  49. package/components/FileChooser/index.js +20 -15
  50. package/components/FormBottomBar/index.js +15 -12
  51. package/components/Icon/Icon.js +9 -6
  52. package/components/Icon/icons/index.js +252 -251
  53. package/components/IconTooltip/index.js +14 -9
  54. package/components/Map/MapBox.js +35 -32
  55. package/components/Map/MapContainer.js +10 -6
  56. package/components/Map/MapDateSliderControl.js +14 -12
  57. package/components/Map/MapDrawer.js +16 -12
  58. package/components/Map/MapLegend.js +32 -28
  59. package/components/Map/MapViewStyleControl.js +11 -9
  60. package/components/Map/ReactMapboxWrapper.js +1 -1
  61. package/components/Map/index.js +13 -11
  62. package/components/Map/types.js +5 -3
  63. package/components/Map/useMaintainLayerOrder.js +5 -2
  64. package/components/Markdown/index.js +6 -4
  65. package/components/Message/Message.js +25 -20
  66. package/components/MultiSelect/index.js +26 -23
  67. package/components/Navbar/NavFooter.js +8 -5
  68. package/components/Navbar/NavItem.js +14 -11
  69. package/components/Navbar/NavSection.js +10 -7
  70. package/components/Navbar/Navbar.js +16 -11
  71. package/components/Navbar/SubNavbar.js +8 -5
  72. package/components/Note.js +10 -7
  73. package/components/OverlayModal/OverlayModal.js +13 -11
  74. package/components/PageForm/index.js +15 -12
  75. package/components/PhotoChooser/index.js +30 -25
  76. package/components/PhotosCarousel/index.d.ts.map +1 -1
  77. package/components/PhotosCarousel/index.js +17 -13
  78. package/components/Pill/index.js +14 -11
  79. package/components/PillList/index.js +10 -7
  80. package/components/PlacementWrapper/index.js +8 -6
  81. package/components/PopoverMenu/Popover.js +12 -9
  82. package/components/PopoverMenu/index.js +14 -11
  83. package/components/PopoverMultiSelect/index.js +14 -11
  84. package/components/ProgressCircle/ProgressCircle.js +12 -9
  85. package/components/RadioButton.js +9 -6
  86. package/components/Select/Select.js +9 -6
  87. package/components/Select/SelectT.js +30 -26
  88. package/components/Separator/index.js +7 -5
  89. package/components/Size.js +1 -1
  90. package/components/Slider/index.js +9 -6
  91. package/components/SummaryBox.js +13 -10
  92. package/components/Tabs/index.js +22 -18
  93. package/components/TextTruncated/index.js +13 -20
  94. package/components/Textfield/Textfield.js +34 -28
  95. package/components/Textfield/TruncatedTextArea.js +12 -10
  96. package/components/TimelineSlider/TimelineMarker.js +8 -6
  97. package/components/TimelineSlider/TimelineRail.js +6 -4
  98. package/components/TimelineSlider/index.js +14 -12
  99. package/components/Tooltip/Tooltip.js +12 -7
  100. package/components/ViewPhotosDialog/index.js +14 -11
  101. package/components/VirtualWalkthrough/Annotation.js +10 -8
  102. package/components/VirtualWalkthrough/AnnotationEditPane.js +23 -21
  103. package/components/VirtualWalkthrough/AnnotationPanel.js +16 -14
  104. package/components/VirtualWalkthrough/Application.js +9 -7
  105. package/components/VirtualWalkthrough/AutoRotator.js +5 -3
  106. package/components/VirtualWalkthrough/BlockingSpinner.js +10 -7
  107. package/components/VirtualWalkthrough/BoundaryRing.js +8 -6
  108. package/components/VirtualWalkthrough/BoundaryWall.js +8 -6
  109. package/components/VirtualWalkthrough/CameraInfo.js +15 -13
  110. package/components/VirtualWalkthrough/ControlsInfoPane.js +59 -57
  111. package/components/VirtualWalkthrough/GradientSky.js +8 -6
  112. package/components/VirtualWalkthrough/SplatControls.js +37 -35
  113. package/components/VirtualWalkthrough/SplatCrop.js +6 -4
  114. package/components/VirtualWalkthrough/SplatFadeCrop.js +7 -5
  115. package/components/VirtualWalkthrough/SplatModel.js +17 -14
  116. package/components/VirtualWalkthrough/SplatRevealRain.js +6 -4
  117. package/components/VirtualWalkthrough/TfAnnotationManager.js +8 -5
  118. package/components/VirtualWalkthrough/TfXrNavigation.js +7 -5
  119. package/components/VirtualWalkthrough/VirtualWalkthroughViewer.js +47 -45
  120. package/components/VirtualWalkthrough/VrAnnotationPanel.js +9 -7
  121. package/components/VirtualWalkthrough/XrAnnotationInteraction.js +9 -7
  122. package/components/VirtualWalkthrough/XrExitButton.js +9 -7
  123. package/components/VirtualWalkthrough/XrGazeDwell.js +9 -7
  124. package/components/VirtualWalkthrough/XrPointerRay.js +9 -7
  125. package/components/VirtualWalkthrough/boundary-ring.js +7 -5
  126. package/components/VirtualWalkthrough/boundary-wall.js +8 -6
  127. package/components/VirtualWalkthrough/groundPlane.js +6 -3
  128. package/components/VirtualWalkthrough/gsplat-fade-crop-effect.js +5 -2
  129. package/components/VirtualWalkthrough/splatFormat.js +6 -4
  130. package/components/VirtualWalkthrough/vr-annotation-panel-layout.js +4 -2
  131. package/components/VirtualWalkthrough/vr-annotation-panel.js +8 -5
  132. package/components/VirtualWalkthrough/walkthrough-camera.js +6 -4
  133. package/components/VirtualWalkthrough/xr-annotation-candidates.js +8 -6
  134. package/components/VirtualWalkthrough/xr-annotation-interaction.js +9 -6
  135. package/components/VirtualWalkthrough/xr-annotation-targeting.js +5 -2
  136. package/components/VirtualWalkthrough/xr-button-arming.js +4 -2
  137. package/components/VirtualWalkthrough/xr-button-hold.js +5 -3
  138. package/components/VirtualWalkthrough/xr-exit-button.js +10 -8
  139. package/components/VirtualWalkthrough/xr-face-buttons.js +6 -4
  140. package/components/VirtualWalkthrough/xr-gaze-dwell-state.js +5 -3
  141. package/components/VirtualWalkthrough/xr-gaze-dwell.js +9 -7
  142. package/components/VirtualWalkthrough/xr-interactive-ui.js +10 -8
  143. package/components/VirtualWalkthrough/xr-pointer-ray.js +5 -3
  144. package/components/VirtualWalkthrough/xr-progress-pie.js +4 -2
  145. package/components/VirtualWalkthrough/xr-ray-quad.js +5 -2
  146. package/components/VirtualWalkthrough/xr-scene-bounds.js +5 -3
  147. package/components/VirtualWalkthrough/xr-teleport-gesture.js +4 -2
  148. package/components/svg/BlobbyGrayIconImage.js +13 -11
  149. package/components/svg/BlobbyGrayIconImport.js +13 -11
  150. package/components/svg/BlobbyGrayIconUploadToTheCloud.js +13 -11
  151. package/components/svg/BlobbyIconCloudChecked.js +41 -39
  152. package/components/svg/BlobbyIconExportOrUploadPhoto.js +41 -39
  153. package/components/svg/BlobbyIconFolder.js +41 -39
  154. package/components/svg/BlobbyIconGraphReport.js +41 -39
  155. package/components/svg/BlobbyIconHappy.js +41 -39
  156. package/components/svg/BlobbyIconHeartMonitor.js +41 -39
  157. package/components/svg/BlobbyIconLeaf.js +41 -39
  158. package/components/svg/BlobbyIconLibrary.js +41 -39
  159. package/components/svg/BlobbyIconNursery.js +41 -39
  160. package/components/svg/BlobbyIconOrganization.js +41 -39
  161. package/components/svg/BlobbyIconParchment.js +41 -39
  162. package/components/svg/BlobbyIconPeople.js +41 -39
  163. package/components/svg/BlobbyIconSeedBank.js +41 -39
  164. package/components/svg/BlobbyIconSeedling.js +41 -39
  165. package/components/svg/BlobbyIconSeeds.js +41 -39
  166. package/components/svg/BlobbyIconSite.js +42 -40
  167. package/components/svg/BlobbyIconSparkles.js +41 -39
  168. package/components/svg/BlobbyIconWrench.js +41 -39
  169. package/components/svg/Bug.js +8 -6
  170. package/components/svg/Calendar.js +8 -6
  171. package/components/svg/CaretDown.js +8 -6
  172. package/components/svg/CaretLeft.js +8 -6
  173. package/components/svg/CaretRight.js +8 -6
  174. package/components/svg/CaretUp.js +8 -6
  175. package/components/svg/ChevronDown.js +8 -6
  176. package/components/svg/ChevronUp.js +8 -6
  177. package/components/svg/Close.js +8 -6
  178. package/components/svg/Critical.js +8 -6
  179. package/components/svg/Edit.js +41 -39
  180. package/components/svg/Error.js +8 -6
  181. package/components/svg/Filter.js +8 -6
  182. package/components/svg/Folder.js +8 -6
  183. package/components/svg/Help.js +8 -6
  184. package/components/svg/Home.js +8 -6
  185. package/components/svg/IconAdd.js +8 -6
  186. package/components/svg/IconArrowRight.js +8 -6
  187. package/components/svg/IconBusinessNetwork.js +8 -6
  188. package/components/svg/IconCalendar.js +8 -6
  189. package/components/svg/IconCancel.js +8 -6
  190. package/components/svg/IconChargingBattery.js +8 -6
  191. package/components/svg/IconChecklist.js +8 -6
  192. package/components/svg/IconCheckmark.js +8 -6
  193. package/components/svg/IconCoinInHand.js +8 -6
  194. package/components/svg/IconColumns.js +8 -6
  195. package/components/svg/IconComment.js +8 -6
  196. package/components/svg/IconDashboard.js +8 -6
  197. package/components/svg/IconDataMigration.js +8 -6
  198. package/components/svg/IconDocument.js +8 -6
  199. package/components/svg/IconDownloadFromTheCloud.js +8 -6
  200. package/components/svg/IconEdit.js +8 -6
  201. package/components/svg/IconExpand.js +8 -6
  202. package/components/svg/IconExport.js +8 -6
  203. package/components/svg/IconExternalLink.js +8 -6
  204. package/components/svg/IconEye.js +8 -6
  205. package/components/svg/IconEyeOff.js +8 -6
  206. package/components/svg/IconFile.js +8 -6
  207. package/components/svg/IconFolder.js +8 -6
  208. package/components/svg/IconFullScreen.js +8 -6
  209. package/components/svg/IconFutures.js +8 -6
  210. package/components/svg/IconGraphReport.js +8 -6
  211. package/components/svg/IconHeartMonitor.js +8 -6
  212. package/components/svg/IconHelp.js +8 -6
  213. package/components/svg/IconHistory.js +8 -6
  214. package/components/svg/IconImport.js +8 -6
  215. package/components/svg/IconIndex.js +8 -6
  216. package/components/svg/IconLayers.js +8 -6
  217. package/components/svg/IconLibrary.js +8 -6
  218. package/components/svg/IconList.js +8 -6
  219. package/components/svg/IconLivePlant.js +8 -6
  220. package/components/svg/IconLocations.js +8 -6
  221. package/components/svg/IconMail.js +8 -6
  222. package/components/svg/IconManager.js +8 -6
  223. package/components/svg/IconMarker.js +8 -6
  224. package/components/svg/IconMenu.js +8 -6
  225. package/components/svg/IconMenuHorizontal.js +8 -6
  226. package/components/svg/IconModule.js +8 -6
  227. package/components/svg/IconMyLocation.js +8 -6
  228. package/components/svg/IconNote.js +8 -6
  229. package/components/svg/IconNursery.js +8 -6
  230. package/components/svg/IconOrg.js +8 -6
  231. package/components/svg/IconParchment.js +8 -6
  232. package/components/svg/IconPhoto.js +8 -6
  233. package/components/svg/IconPlantsFilled.js +8 -6
  234. package/components/svg/IconRedo.js +8 -6
  235. package/components/svg/IconRestorationSite.js +8 -6
  236. package/components/svg/IconSeedBank.js +8 -6
  237. package/components/svg/IconSeedling.js +8 -6
  238. package/components/svg/IconSettings.js +8 -6
  239. package/components/svg/IconSlice.js +8 -6
  240. package/components/svg/IconSubmit.js +8 -6
  241. package/components/svg/IconSubtract.js +8 -6
  242. package/components/svg/IconSynced.js +8 -6
  243. package/components/svg/IconTrashCan.js +8 -6
  244. package/components/svg/IconTreasureMap.js +8 -6
  245. package/components/svg/IconUnavailable.js +8 -6
  246. package/components/svg/IconUndo.js +8 -6
  247. package/components/svg/IconVariable.js +8 -6
  248. package/components/svg/IconVideo.js +9 -7
  249. package/components/svg/IconWifi.js +8 -6
  250. package/components/svg/Info.js +8 -6
  251. package/components/svg/Key.js +8 -6
  252. package/components/svg/Leaf.js +8 -6
  253. package/components/svg/Lock.js +8 -6
  254. package/components/svg/Logo.js +16 -14
  255. package/components/svg/MenuVertical.js +8 -6
  256. package/components/svg/Notification.js +8 -6
  257. package/components/svg/Person.js +8 -6
  258. package/components/svg/Plus.js +8 -6
  259. package/components/svg/RestorationSite.js +8 -6
  260. package/components/svg/Search.js +8 -6
  261. package/components/svg/Seeds.js +8 -6
  262. package/components/svg/Site.js +8 -6
  263. package/components/svg/Sparkles.js +8 -6
  264. package/components/svg/Species.js +8 -6
  265. package/components/svg/Species2.js +41 -39
  266. package/components/svg/Spinner.js +16 -14
  267. package/components/svg/Star.js +8 -6
  268. package/components/svg/Success.js +8 -6
  269. package/components/svg/SuccessFilled.js +8 -6
  270. package/components/svg/TerrawareLogoDesktop.js +17 -15
  271. package/components/svg/TerrawareLogoMobile.js +9 -7
  272. package/components/svg/Touchscreen.js +8 -6
  273. package/components/svg/UploadCloud.js +41 -39
  274. package/components/svg/Warning.js +8 -6
  275. package/components/svg/WelcomeClipboard.js +32 -30
  276. package/components/svg/index.js +127 -127
  277. package/components/table/EnhancedTableToolbar.js +18 -15
  278. package/components/table/EnhancedTableToolbarV2.js +8 -6
  279. package/components/table/TableCellRenderer.js +37 -32
  280. package/components/table/TableHeader.js +17 -14
  281. package/components/table/TableHeaderItem.js +18 -15
  282. package/components/table/density.js +5 -3
  283. package/components/table/index.js +40 -37
  284. package/components/table/sort.js +6 -4
  285. package/components/table/types.js +1 -1
  286. package/components/types/index.js +1 -1
  287. package/hooks/useBoolean.js +4 -2
  288. package/hooks/useCameraPosition.js +5 -2
  289. package/hooks/useDevicePerformance.js +6 -3
  290. package/hooks/useXr.js +6 -4
  291. package/index.js +55 -58
  292. package/package.json +6 -2
  293. package/style-dictionary-dist/TerrawareTheme.js +2 -1
  294. package/theme.js +5 -2
  295. package/utils/color.js +5 -2
  296. package/utils/date.js +7 -6
  297. package/utils/index.js +4 -5
  298. package/utils/preventDefaultEvent.js +2 -1
  299. package/utils/text.js +3 -2
  300. package/utils/useDeviceInfo.js +2 -1
  301. package/virtualWalkthrough.js +23 -31
  302. package/components/Button/button.test.js +0 -23
  303. package/components/MultiSelect/MultiSelect.test.js +0 -73
  304. package/components/VirtualWalkthrough/TfXrNavigation.test.js +0 -110
  305. package/components/VirtualWalkthrough/boundary-ring.test.js +0 -109
  306. package/components/VirtualWalkthrough/boundary-wall.test.js +0 -203
  307. package/components/VirtualWalkthrough/groundPlane.test.js +0 -45
  308. package/components/VirtualWalkthrough/splatFormat.test.js +0 -51
  309. package/components/VirtualWalkthrough/vr-annotation-panel-layout.test.js +0 -26
  310. package/components/VirtualWalkthrough/xr-annotation-targeting.test.js +0 -66
  311. package/components/VirtualWalkthrough/xr-button-arming.test.js +0 -35
  312. package/components/VirtualWalkthrough/xr-button-hold.test.js +0 -57
  313. package/components/VirtualWalkthrough/xr-exit-button.test.js +0 -23
  314. package/components/VirtualWalkthrough/xr-face-buttons.test.js +0 -82
  315. package/components/VirtualWalkthrough/xr-gaze-dwell-state.test.js +0 -61
  316. package/components/VirtualWalkthrough/xr-interactive-ui.test.js +0 -165
  317. package/components/VirtualWalkthrough/xr-progress-pie.test.js +0 -79
  318. package/components/VirtualWalkthrough/xr-ray-quad.test.js +0 -37
  319. package/components/VirtualWalkthrough/xr-scene-bounds.test.js +0 -70
  320. package/components/VirtualWalkthrough/xr-teleport-gesture.test.js +0 -90
  321. package/components/table/sort.test.js +0 -35
  322. package/utils/date.test.js +0 -84
  323. package/utils/text.test.js +0 -21
@@ -1,37 +0,0 @@
1
- import { Vec3 } from 'playcanvas';
2
- import { rayQuadHit } from './xr-ray-quad';
3
- const CENTER = new Vec3(0, 0, 0);
4
- const RIGHT = new Vec3(1, 0, 0);
5
- const UP = new Vec3(0, 1, 0);
6
- describe('rayQuadHit', () => {
7
- it('hits the centre straight on', () => {
8
- const hit = rayQuadHit(new Vec3(0, 0, 5), new Vec3(0, 0, -1), CENTER, RIGHT, UP, 1, 1);
9
- expect(hit).not.toBeNull();
10
- expect(hit?.u).toBeCloseTo(0, 5);
11
- expect(hit?.v).toBeCloseTo(0, 5);
12
- });
13
- it('maps an off-centre hit to normalized quad coordinates', () => {
14
- const hit = rayQuadHit(new Vec3(0.5, -0.25, 5), new Vec3(0, 0, -1), CENTER, RIGHT, UP, 1, 1);
15
- expect(hit?.u).toBeCloseTo(0.5, 5);
16
- expect(hit?.v).toBeCloseTo(-0.25, 5);
17
- });
18
- it('returns null when the hit falls outside the rectangle', () => {
19
- expect(rayQuadHit(new Vec3(2, 0, 5), new Vec3(0, 0, -1), CENTER, RIGHT, UP, 1, 1)).toBeNull();
20
- });
21
- it('returns null for a ray parallel to the quad plane', () => {
22
- expect(rayQuadHit(new Vec3(0, 0, 5), new Vec3(1, 0, 0), CENTER, RIGHT, UP, 1, 1)).toBeNull();
23
- });
24
- it('returns null when the quad is behind the ray origin', () => {
25
- expect(rayQuadHit(new Vec3(0, 0, 5), new Vec3(0, 0, 1), CENTER, RIGHT, UP, 1, 1)).toBeNull();
26
- });
27
- it('respects half extents (scales u/v by them)', () => {
28
- // half width 2: an x offset of 1 maps to u = 0.5.
29
- const hit = rayQuadHit(new Vec3(1, 0, 5), new Vec3(0, 0, -1), CENTER, RIGHT, UP, 2, 1);
30
- expect(hit?.u).toBeCloseTo(0.5, 5);
31
- });
32
- it('normalizes a non-unit ray direction', () => {
33
- const hit = rayQuadHit(new Vec3(0, 0, 5), new Vec3(0, 0, -3), CENTER, RIGHT, UP, 1, 1);
34
- expect(hit).not.toBeNull();
35
- expect(hit?.u).toBeCloseTo(0, 5);
36
- });
37
- });
@@ -1,70 +0,0 @@
1
- import { clampToCircle, distanceToCircleEdge } from './xr-scene-bounds';
2
- describe('clampToCircle', () => {
3
- it('leaves a point inside the circle untouched', () => {
4
- expect(clampToCircle(1, 2, 0, 0, 5)).toEqual({
5
- x: 1,
6
- z: 2,
7
- distance: 0
8
- });
9
- });
10
- it('leaves a point exactly on the edge untouched', () => {
11
- expect(clampToCircle(5, 0, 0, 0, 5)).toEqual({
12
- x: 5,
13
- z: 0,
14
- distance: 0
15
- });
16
- });
17
- it('projects a point outside back onto the edge', () => {
18
- const result = clampToCircle(10, 0, 0, 0, 4);
19
- expect(result.x).toBeCloseTo(4);
20
- expect(result.z).toBeCloseTo(0);
21
- expect(result.distance).toBeCloseTo(6);
22
- });
23
- it('projects along the line from the center, preserving direction', () => {
24
- const result = clampToCircle(30, 40, 0, 0, 5);
25
- expect(result.x).toBeCloseTo(3);
26
- expect(result.z).toBeCloseTo(4);
27
- expect(result.distance).toBeCloseTo(45);
28
- });
29
- it('respects an off-origin center', () => {
30
- const result = clampToCircle(12, -3, 2, -3, 4);
31
- expect(result.x).toBeCloseTo(6);
32
- expect(result.z).toBeCloseTo(-3);
33
- expect(result.distance).toBeCloseTo(6);
34
- });
35
- it('leaves a point at the exact center untouched rather than dividing by zero', () => {
36
- const result = clampToCircle(2, -3, 2, -3, 4);
37
- expect(result).toEqual({
38
- x: 2,
39
- z: -3,
40
- distance: 0
41
- });
42
- expect(Number.isNaN(result.x)).toBe(false);
43
- });
44
- it('leaves the point untouched for a non-positive radius', () => {
45
- expect(clampToCircle(10, 10, 0, 0, 0)).toEqual({
46
- x: 10,
47
- z: 10,
48
- distance: 0
49
- });
50
- expect(clampToCircle(10, 10, 0, 0, -1)).toEqual({
51
- x: 10,
52
- z: 10,
53
- distance: 0
54
- });
55
- });
56
- });
57
- describe('distanceToCircleEdge', () => {
58
- it('is negative inside the circle', () => {
59
- expect(distanceToCircleEdge(1, 0, 0, 0, 5)).toBeCloseTo(-4);
60
- });
61
- it('is zero on the edge', () => {
62
- expect(distanceToCircleEdge(0, 5, 0, 0, 5)).toBeCloseTo(0);
63
- });
64
- it('is positive outside the circle', () => {
65
- expect(distanceToCircleEdge(8, 0, 0, 0, 5)).toBeCloseTo(3);
66
- });
67
- it('respects an off-origin center', () => {
68
- expect(distanceToCircleEdge(2, 9, 2, 3, 4)).toBeCloseTo(2);
69
- });
70
- });
@@ -1,90 +0,0 @@
1
- import { TeleportGestureLatch } from './xr-teleport-gesture';
2
- const source = () => ({});
3
-
4
- /** An ordinary aiming frame: pressed, teleport on, ray clear of interactive UI. */
5
- const AIMING = {
6
- pressed: true,
7
- teleportDisabled: false,
8
- uiBlocked: false
9
- };
10
- describe('TeleportGestureLatch', () => {
11
- it('allows a press that never aimed at UI', () => {
12
- const latch = new TeleportGestureLatch();
13
- const src = source();
14
- latch.track(src, AIMING);
15
- latch.track(src, AIMING);
16
- expect(latch.consumeBlocked(src)).toBe(false);
17
- });
18
- it('blocks a press whose last aiming frame was over UI, even after the ray leaves on release', () => {
19
- const latch = new TeleportGestureLatch();
20
- const src = source();
21
- latch.track(src, {
22
- ...AIMING,
23
- uiBlocked: true
24
- });
25
-
26
- // The release-time ray no longer hits the UI, but the cached arc hit is from the frame above.
27
- expect(latch.consumeBlocked(src)).toBe(true);
28
- });
29
- it('allows a press that swept across UI but came to rest on open floor', () => {
30
- const latch = new TeleportGestureLatch();
31
- const src = source();
32
- latch.track(src, AIMING);
33
- latch.track(src, {
34
- ...AIMING,
35
- uiBlocked: true
36
- });
37
- latch.track(src, AIMING);
38
- expect(latch.consumeBlocked(src)).toBe(false);
39
- });
40
- it('latches a teleport-disabled frame for the rest of the press', () => {
41
- const latch = new TeleportGestureLatch();
42
- const src = source();
43
- latch.track(src, {
44
- ...AIMING,
45
- teleportDisabled: true
46
- });
47
- latch.track(src, AIMING);
48
- expect(latch.consumeBlocked(src)).toBe(true);
49
- });
50
- it('clears the latches once consumed, so the next press starts clean', () => {
51
- const latch = new TeleportGestureLatch();
52
- const src = source();
53
- latch.track(src, {
54
- pressed: true,
55
- teleportDisabled: true,
56
- uiBlocked: true
57
- });
58
- expect(latch.consumeBlocked(src)).toBe(true);
59
- latch.track(src, AIMING);
60
- expect(latch.consumeBlocked(src)).toBe(false);
61
- });
62
- it('drops latches from a press that ended without being consumed', () => {
63
- const latch = new TeleportGestureLatch();
64
- const src = source();
65
- latch.track(src, {
66
- pressed: true,
67
- teleportDisabled: true,
68
- uiBlocked: true
69
- });
70
- latch.track(src, {
71
- pressed: false,
72
- teleportDisabled: true,
73
- uiBlocked: true
74
- });
75
- latch.track(src, AIMING);
76
- expect(latch.consumeBlocked(src)).toBe(false);
77
- });
78
- it('tracks each input source independently', () => {
79
- const latch = new TeleportGestureLatch();
80
- const left = source();
81
- const right = source();
82
- latch.track(left, {
83
- ...AIMING,
84
- uiBlocked: true
85
- });
86
- latch.track(right, AIMING);
87
- expect(latch.consumeBlocked(right)).toBe(false);
88
- expect(latch.consumeBlocked(left)).toBe(true);
89
- });
90
- });
@@ -1,35 +0,0 @@
1
- import { descendingComparator } from './sort';
2
- const rowA = {
3
- string1: 'foo',
4
- string2: 'same',
5
- number1: '1050',
6
- number2: '150',
7
- number3: '1.100'
8
- };
9
- const rowB = {
10
- string1: 'barbaz',
11
- string2: 'same',
12
- number1: '1099',
13
- number2: '21.001',
14
- number3: '1.1'
15
- };
16
- test('compare unequal string fields', () => {
17
- const cmp = descendingComparator(rowA, rowB, 'string1', 'desc');
18
- expect(cmp).toEqual(-1);
19
- });
20
- test('compare equal string fields', () => {
21
- const cmp = descendingComparator(rowA, rowB, 'string2', 'desc');
22
- expect(cmp).toEqual(0);
23
- });
24
- test('compare unequal number fields with same whole number digits', () => {
25
- const cmp = descendingComparator(rowA, rowB, 'number1', 'desc');
26
- expect(Math.sign(cmp)).toEqual(-1);
27
- });
28
- test('compare unequal number fields with differing whole number digits', () => {
29
- const cmp = descendingComparator(rowA, rowB, 'number2', 'desc');
30
- expect(Math.sign(cmp)).toEqual(1);
31
- });
32
- test('compare equal number fields', () => {
33
- const cmp = descendingComparator(rowA, rowB, 'number3', 'desc');
34
- expect(Math.sign(cmp)).toEqual(0);
35
- });
@@ -1,84 +0,0 @@
1
- import { DateTime } from 'luxon';
2
- import getDateDisplayValue, { getTodaysDateFormatted, isInTheFuture } from './date';
3
- test('isInTheFuture should handle date ISO string and specified time zones', () => {
4
- expect(isInTheFuture('2023-01-10', 'Asia/Bangkok')).toBe(false);
5
- expect(isInTheFuture('2023-01-10', 'America/Los_Angeles')).toBe(false);
6
- expect(isInTheFuture('3023-01-10', 'America/Los_Angeles')).toBe(true);
7
- });
8
- test('isInTheFuture should handle date ISO string and default time zone', () => {
9
- expect(isInTheFuture('2023-01-10')).toBe(false);
10
- expect(isInTheFuture('3023-01-10')).toBe(true);
11
- });
12
- test('isInTheFuture should handle millis and specified time zones', () => {
13
- expect(isInTheFuture(Date.now(), 'Asia/Bangkok')).toBe(false);
14
- expect(isInTheFuture(new Date('3023-01-10').getTime(), 'Asia/Bangkok')).toBe(true);
15
- });
16
- test('isInTheFuture should handle millis and default time zone', () => {
17
- expect(isInTheFuture(Date.now())).toBe(false);
18
- expect(isInTheFuture(new Date('3023-01-10').getTime())).toBe(true);
19
- });
20
- test('isInTheFuture should handle JS Date object and specified time zones', () => {
21
- expect(isInTheFuture(new Date(), 'Asia/Bangkok')).toBe(false);
22
- expect(isInTheFuture(new Date('3023-01-10'), 'Asia/Bangkok')).toBe(true);
23
- });
24
- test('isInTheFuture should handle JS Date object and default time zone', () => {
25
- expect(isInTheFuture(new Date())).toBe(false);
26
- expect(isInTheFuture(new Date('3023-01-10'))).toBe(true);
27
- });
28
- test('isInTheFuture should handle DateTime object and specified time zones', () => {
29
- expect(isInTheFuture(DateTime.now(), 'Asia/Bangkok')).toBe(false);
30
- expect(isInTheFuture(DateTime.fromISO('3023-01-10'), 'Asia/Bangkok')).toBe(true);
31
- // check that a DateTime with preset zone is a no-op
32
- expect(isInTheFuture(DateTime.now().setZone('Asia/Bangkok'), 'Asia/Bangkok')).toBe(false);
33
- expect(isInTheFuture(DateTime.fromISO('3023-01-10').setZone('Asia/Bangkok'), 'Asia/Bangkok')).toBe(true);
34
- });
35
- test('isInTheFuture should handle JS Date object and default time zone', () => {
36
- expect(isInTheFuture(DateTime.now())).toBe(false);
37
- expect(isInTheFuture(DateTime.fromISO('3023-01-10'))).toBe(true);
38
- });
39
- test('should show todays date formatted for a time zone', () => {
40
- const formatted = getTodaysDateFormatted('Asia/Bangkok');
41
- expect(!!formatted.match(/\d\d\d\d-\d\d-\d\d/)).toBe(true);
42
- });
43
- test('should show todays date formatted for default time zone', () => {
44
- const formatted = getTodaysDateFormatted();
45
- expect(!!formatted.match(/\d\d\d\d-\d\d-\d\d/)).toBe(true);
46
- });
47
- test('should return valid date display value for ISO date string with time zones', () => {
48
- expect(getDateDisplayValue('2021-08-05T19:39:16Z', 'America/Los_Angeles')).toBe('2021-08-05');
49
- expect(getDateDisplayValue('2021-08-05T19:39:16Z', 'Asia/Bangkok')).toBe('2021-08-06');
50
- });
51
- test('should return valid date display value for ISO date string with default time zone', () => {
52
- expect(getDateDisplayValue('2021-08-05T19:39:16Z')).toBe('2021-08-05');
53
- });
54
- test('should return valid date display value for default date ISO string with time zones', () => {
55
- expect(getDateDisplayValue('2021-08-05', 'America/Los_Angeles')).toBe('2021-08-05');
56
- expect(getDateDisplayValue('2021-08-05', 'Asia/Bangkok')).toBe('2021-08-05');
57
- });
58
- test('should return valid date display value for default date string with default time zone', () => {
59
- expect(getDateDisplayValue('2021-08-05')).toBe('2021-08-05');
60
- });
61
- test('should return valid date display value for millis with default time zone', () => {
62
- expect(getDateDisplayValue(new Date('2021-08-05T19:39:16Z').getTime())).toBe('2021-08-05');
63
- });
64
- test('should return valid date display value for JS Date object with default time zone', () => {
65
- expect(getDateDisplayValue(new Date('2021-08-05T19:39:16Z'))).toBe('2021-08-05');
66
- });
67
- test('should return valid date display value for DateTime object with default time zone', () => {
68
- expect(getDateDisplayValue(DateTime.fromISO('2021-08-05T19:39:16Z'))).toBe('2021-08-05');
69
- });
70
- test('should return valid date display value for millis with time zones', () => {
71
- expect(getDateDisplayValue(new Date('2021-08-05T19:39:16Z').getTime(), 'America/Los_Angeles')).toBe('2021-08-05');
72
- expect(getDateDisplayValue(new Date('2021-08-05T19:39:16Z').getTime(), 'Asia/Bangkok')).toBe('2021-08-06');
73
- });
74
- test('should return valid date display value for JS Date object with time zones', () => {
75
- expect(getDateDisplayValue(new Date('2021-08-05T19:39:16Z'), 'America/Los_Angeles')).toBe('2021-08-05');
76
- expect(getDateDisplayValue(new Date('2021-08-05T19:39:16Z'), 'Asia/Bangkok')).toBe('2021-08-06');
77
- });
78
- test('should return valid date display value for DateTime object with time zones', () => {
79
- expect(getDateDisplayValue(DateTime.fromISO('2021-08-05T19:39:16Z'), 'America/Los_Angeles')).toBe('2021-08-05');
80
- expect(getDateDisplayValue(DateTime.fromISO('2021-08-05T19:39:16Z'), 'Asia/Bangkok')).toBe('2021-08-06');
81
- // check that a DateTime with preset zone is a no-op
82
- expect(getDateDisplayValue(DateTime.fromISO('2021-08-05T19:39:16Z').setZone('America/Los_Angeles'), 'America/Los_Angeles')).toBe('2021-08-05');
83
- expect(getDateDisplayValue(DateTime.fromISO('2021-08-05T19:39:16Z').setZone('America/Los_Angeles'), 'Asia/Bangkok')).toBe('2021-08-06');
84
- });
@@ -1,21 +0,0 @@
1
- import { titleCase } from './text';
2
- test('titleCase for a single word', () => {
3
- const lowerCaseWord = titleCase('species');
4
- expect(lowerCaseWord === 'Species').toBe(true);
5
- const capitalizedWord = titleCase('Species');
6
- expect(capitalizedWord === 'Species').toBe(true);
7
- const allCapsWord = titleCase('SPECIES');
8
- expect(allCapsWord === 'SPECIES').toBe(true);
9
- const reverseCapWord = titleCase('sPECIES');
10
- expect(reverseCapWord === 'Species').toBe(true);
11
- });
12
- test('titleCase for multiple words', () => {
13
- const lowerCaseString = titleCase('common name');
14
- expect(lowerCaseString === 'Common Name').toBe(true);
15
- const capitalizedString = titleCase('Common Name');
16
- expect(capitalizedString === 'Common Name').toBe(true);
17
- const allCapsString = titleCase('common NAME');
18
- expect(allCapsString === 'Common NAME').toBe(true);
19
- const reverseCapString = titleCase('cOMMON nAME');
20
- expect(reverseCapString === 'Common Name').toBe(true);
21
- });