@ankhorage/zora 27.5.3 → 27.6.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 (276) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +1 -1
  3. package/dist/capabilities/index.js +13 -1
  4. package/dist/capabilities/index.js.map +5 -4
  5. package/dist/features/calendar/adapters/inbound/Calendar.d.ts +5 -0
  6. package/dist/features/calendar/adapters/inbound/Calendar.d.ts.map +1 -0
  7. package/dist/features/calendar/adapters/inbound/Calendar.js +126 -0
  8. package/dist/features/calendar/adapters/inbound/Calendar.js.map +1 -0
  9. package/dist/features/calendar/application/createCalendarMonth.d.ts +9 -0
  10. package/dist/features/calendar/application/createCalendarMonth.d.ts.map +1 -0
  11. package/dist/features/calendar/application/createCalendarMonth.js +25 -0
  12. package/dist/features/calendar/application/createCalendarMonth.js.map +1 -0
  13. package/dist/features/calendar/application/isCalendarDateDisabled.d.ts +10 -0
  14. package/dist/features/calendar/application/isCalendarDateDisabled.d.ts.map +1 -0
  15. package/dist/features/calendar/application/isCalendarDateDisabled.js +23 -0
  16. package/dist/features/calendar/application/isCalendarDateDisabled.js.map +1 -0
  17. package/dist/features/calendar/calendarMeta.d.ts +10 -0
  18. package/dist/features/calendar/calendarMeta.d.ts.map +1 -0
  19. package/dist/features/calendar/calendarMeta.js +10 -0
  20. package/dist/features/calendar/calendarMeta.js.map +1 -0
  21. package/dist/features/calendar/public.d.ts +2 -0
  22. package/dist/features/calendar/public.d.ts.map +1 -1
  23. package/dist/features/calendar/public.js +1 -1
  24. package/dist/features/calendar/public.js.map +1 -1
  25. package/dist/features/data-table/adapters/inbound/DataTable.d.ts +1 -1
  26. package/dist/features/data-table/adapters/inbound/DataTable.d.ts.map +1 -1
  27. package/dist/features/data-table/adapters/inbound/DataTable.js +82 -23
  28. package/dist/features/data-table/adapters/inbound/DataTable.js.map +1 -1
  29. package/dist/features/date-picker/composition/DatePickerContent.d.ts +1 -1
  30. package/dist/features/date-picker/composition/DatePickerContent.d.ts.map +1 -1
  31. package/dist/features/date-picker/composition/DatePickerContent.js +5 -104
  32. package/dist/features/date-picker/composition/DatePickerContent.js.map +1 -1
  33. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphController.js +7 -2
  34. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphController.js.map +1 -1
  35. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.d.ts.map +1 -1
  36. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js +27 -4
  37. package/dist/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.js.map +1 -1
  38. package/dist/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.d.ts.map +1 -1
  39. package/dist/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.js +18 -6
  40. package/dist/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.js.map +1 -1
  41. package/dist/features/grid-view/adapters/inbound/GridView.d.ts +1 -1
  42. package/dist/features/grid-view/adapters/inbound/GridView.d.ts.map +1 -1
  43. package/dist/features/grid-view/adapters/inbound/GridView.js +6 -5
  44. package/dist/features/grid-view/adapters/inbound/GridView.js.map +1 -1
  45. package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.d.ts.map +1 -1
  46. package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.js +2 -0
  47. package/dist/features/registry/ZORA_BASE_COMPONENT_REGISTRY.js.map +1 -1
  48. package/dist/features/registry/componentMeta.d.ts.map +1 -1
  49. package/dist/features/registry/componentMeta.js +2 -0
  50. package/dist/features/registry/componentMeta.js.map +1 -1
  51. package/dist/features/timeline/adapters/inbound/Timeline.d.ts.map +1 -1
  52. package/dist/features/timeline/adapters/inbound/Timeline.js +17 -11
  53. package/dist/features/timeline/adapters/inbound/Timeline.js.map +1 -1
  54. package/dist/readerFree.d.ts +1 -0
  55. package/dist/readerFree.d.ts.map +1 -1
  56. package/dist/readerFree.js +1 -0
  57. package/dist/readerFree.js.map +1 -1
  58. package/dist/types/calendar.d.ts +24 -0
  59. package/dist/types/calendar.d.ts.map +1 -0
  60. package/dist/types/calendar.js +2 -0
  61. package/dist/types/calendar.js.map +1 -0
  62. package/dist/types/data-table.d.ts +4 -0
  63. package/dist/types/data-table.d.ts.map +1 -1
  64. package/dist/types/data-table.js.map +1 -1
  65. package/dist/types/grid-view.d.ts +2 -0
  66. package/dist/types/grid-view.d.ts.map +1 -1
  67. package/dist/types/grid-view.js.map +1 -1
  68. package/dist/types/timeline.d.ts +3 -0
  69. package/dist/types/timeline.d.ts.map +1 -1
  70. package/dist/types/timeline.js.map +1 -1
  71. package/package.json +2 -2
  72. package/src/features/calendar/adapters/inbound/Calendar.interaction.test.tsx +115 -0
  73. package/src/features/calendar/adapters/inbound/Calendar.tsx +219 -0
  74. package/src/features/calendar/application/createCalendarMonth.test.ts +23 -0
  75. package/src/features/calendar/application/createCalendarMonth.ts +38 -0
  76. package/src/features/calendar/application/isCalendarDateDisabled.test.ts +49 -0
  77. package/src/features/calendar/application/isCalendarDateDisabled.ts +41 -0
  78. package/src/features/calendar/calendarMeta.ts +11 -0
  79. package/src/features/calendar/public.test.ts +14 -0
  80. package/src/features/calendar/public.ts +7 -0
  81. package/src/features/data-table/adapters/inbound/DataTable.test.tsx +242 -0
  82. package/src/features/data-table/adapters/inbound/DataTable.tsx +162 -38
  83. package/src/features/date-picker/composition/DatePickerContent.tsx +8 -192
  84. package/src/features/date-picker/public.test.ts +2 -1
  85. package/src/features/graph-view/adapters/inbound/web-artifact/createGraphController.ts +9 -2
  86. package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.test.ts +210 -4
  87. package/src/features/graph-view/adapters/inbound/web-artifact/createGraphRuntime.ts +36 -3
  88. package/src/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.test.ts +33 -0
  89. package/src/features/graph-view/adapters/inbound/web-artifact/placeAddedGraphNodes.ts +19 -5
  90. package/src/features/grid-view/adapters/inbound/GridView.tsx +6 -4
  91. package/src/features/registry/ZORA_BASE_COMPONENT_REGISTRY.ts +2 -0
  92. package/src/features/registry/componentMeta.ts +2 -0
  93. package/src/features/timeline/adapters/inbound/Timeline.test.tsx +175 -0
  94. package/src/features/timeline/adapters/inbound/Timeline.tsx +47 -26
  95. package/src/readerFree.ts +7 -0
  96. package/src/types/calendar.ts +25 -0
  97. package/src/types/data-table.ts +4 -0
  98. package/src/types/grid-view.ts +2 -0
  99. package/src/types/timeline.ts +3 -0
  100. package/web-dist/chunks/{Accordion-k81eyekh.js → Accordion-0j4xzcwz.js} +2 -2
  101. package/web-dist/chunks/{Accordion-5f9e10c6.js → Accordion-252dr90x.js} +1 -1
  102. package/web-dist/chunks/{Accordion-0pryvztw.js → Accordion-260pyaxy.js} +1 -1
  103. package/web-dist/chunks/{Accordion-g9hn7fht.js → Accordion-4c7hqeg3.js} +1 -1
  104. package/web-dist/chunks/{Accordion-0z8nry94.js → Accordion-4kmh6s2k.js} +1 -1
  105. package/web-dist/chunks/{Accordion-g758dqfc.js → Accordion-5pbvgvqc.js} +1 -1
  106. package/web-dist/chunks/{Accordion-jp5xt2kz.js → Accordion-5z8pbn4z.js} +1 -1
  107. package/web-dist/chunks/{Accordion-qzx53csd.js → Accordion-6jsea4e0.js} +4 -4
  108. package/web-dist/chunks/{Accordion-yd025qec.js → Accordion-7788ybcs.js} +2 -2
  109. package/web-dist/chunks/{Accordion-ppksc4jh.js → Accordion-7mnan4q4.js} +4 -4
  110. package/web-dist/chunks/{Accordion-0pm8dvcy.js → Accordion-8j7t77tf.js} +2 -2
  111. package/web-dist/chunks/{Accordion-6tesp7jr.js → Accordion-c44m1q0m.js} +1 -1
  112. package/web-dist/chunks/{Accordion-a6h4ff7g.js → Accordion-f2n2zz1x.js} +2 -2
  113. package/web-dist/chunks/{Accordion-ep9xpmbw.js → Accordion-fbehwpr1.js} +3 -3
  114. package/web-dist/chunks/{Accordion-j09h3pg1.js → Accordion-hf4nfkn0.js} +7 -7
  115. package/web-dist/chunks/{Accordion-xr81ntxh.js → Accordion-hh48jjhk.js} +4 -4
  116. package/web-dist/chunks/{Accordion-3qz6s2z9.js → Accordion-j6bs1yfn.js} +1 -1
  117. package/web-dist/chunks/{Accordion-dnpfe329.js → Accordion-jh94mg56.js} +3 -3
  118. package/web-dist/chunks/{Accordion-6c2ykyad.js → Accordion-jx9tc6p1.js} +2 -2
  119. package/web-dist/chunks/{Accordion-8xgdw6ry.js → Accordion-kcca65d8.js} +1 -1
  120. package/web-dist/chunks/{Accordion-g009pehq.js → Accordion-m3xb7z7j.js} +3 -3
  121. package/web-dist/chunks/{Accordion-eqkmzs33.js → Accordion-mpebzjby.js} +1 -1
  122. package/web-dist/chunks/{Accordion-n29svm40.js → Accordion-ms1y70gq.js} +1 -1
  123. package/web-dist/chunks/{Accordion-t0k1cjca.js → Accordion-neg1cgeh.js} +7 -5
  124. package/web-dist/chunks/{Accordion-wfrt39d2.js → Accordion-nnhznqgf.js} +1 -1
  125. package/web-dist/chunks/{Accordion-cqdfhyr9.js → Accordion-np16p9mh.js} +1 -1
  126. package/web-dist/chunks/{Accordion-zjygy6n2.js → Accordion-p2f0e4pn.js} +3 -3
  127. package/web-dist/chunks/{Accordion-q1vqpaw6.js → Accordion-p7mxkxhs.js} +4 -4
  128. package/web-dist/chunks/{Accordion-d6f4vr6s.js → Accordion-r6zvzrkd.js} +1 -1
  129. package/web-dist/chunks/Accordion-r86ce0wj.js +237 -0
  130. package/web-dist/chunks/{Accordion-b8659jt9.js → Accordion-rwc34cn2.js} +1 -1
  131. package/web-dist/chunks/{Accordion-rcff84ws.js → Accordion-s9nbkzky.js} +1 -1
  132. package/web-dist/chunks/{Accordion-01s50nga.js → Accordion-sxzts6bj.js} +1 -1
  133. package/web-dist/chunks/{Accordion-36nt5xmp.js → Accordion-t2cvrn0r.js} +4 -4
  134. package/web-dist/chunks/{Accordion-y5kdx80m.js → Accordion-tnt1txfq.js} +3 -3
  135. package/web-dist/chunks/{Accordion-bj7hv2dq.js → Accordion-vq8zrnwh.js} +1 -1
  136. package/web-dist/chunks/{Accordion-hh6jrz1e.js → Accordion-w0prbwy0.js} +4 -4
  137. package/web-dist/chunks/{Accordion-zqzqg9yc.js → Accordion-wvghkwxx.js} +6 -6
  138. package/web-dist/chunks/{Accordion-cp82h5jx.js → Accordion-wx0jp5cn.js} +4 -4
  139. package/web-dist/chunks/{Accordion-bwp6m0zd.js → Accordion-yb4as6wc.js} +2 -2
  140. package/web-dist/chunks/{Accordion-e9c80kn7.js → Accordion-yrzm02g2.js} +2 -2
  141. package/web-dist/components/accordion/Accordion.js +3 -3
  142. package/web-dist/components/accordion-item/AccordionItem.js +3 -3
  143. package/web-dist/components/app-bar/AppBar.js +8 -8
  144. package/web-dist/components/app-header/AppHeader.js +8 -8
  145. package/web-dist/components/app-shell/AppShell.js +2 -2
  146. package/web-dist/components/auth-screen/AuthScreen.js +12 -12
  147. package/web-dist/components/avatar/Avatar.js +3 -3
  148. package/web-dist/components/avatar-group/AvatarGroup.js +3 -3
  149. package/web-dist/components/badge/Badge.js +2 -2
  150. package/web-dist/components/barcode-scanner-view/BarcodeScannerView.js +11 -11
  151. package/web-dist/components/bottom-sheet/BottomSheet.js +3 -3
  152. package/web-dist/components/bottom-sheet-flat-list/BottomSheetFlatList.js +3 -3
  153. package/web-dist/components/bottom-sheet-scroll-view/BottomSheetScrollView.js +3 -3
  154. package/web-dist/components/bottom-sheet-section-list/BottomSheetSectionList.js +3 -3
  155. package/web-dist/components/bottom-sheet-view/BottomSheetView.js +3 -3
  156. package/web-dist/components/bottom-sheet-virtualized-list/BottomSheetVirtualizedList.js +3 -3
  157. package/web-dist/components/breadcrumbs/Breadcrumbs.js +5 -5
  158. package/web-dist/components/button/Button.js +5 -5
  159. package/web-dist/components/button-group/ButtonGroup.js +5 -5
  160. package/web-dist/components/calendar/Calendar.d.ts +8 -0
  161. package/web-dist/components/calendar/Calendar.dependency-0.d.ts +27 -0
  162. package/web-dist/components/calendar/Calendar.dependency-1.d.ts +3 -0
  163. package/web-dist/components/calendar/Calendar.js +25 -0
  164. package/web-dist/components/calendar/Calendar.types-0.d.ts +27 -0
  165. package/web-dist/components/calendar/Calendar.types-1.d.ts +146 -0
  166. package/web-dist/components/calendar/index.d.ts +2 -0
  167. package/web-dist/components/calendar/index.js +2 -0
  168. package/web-dist/components/camera-permission-view/CameraPermissionView.js +11 -11
  169. package/web-dist/components/card/Card.js +10 -10
  170. package/web-dist/components/chat-list-item/ChatListItem.js +6 -6
  171. package/web-dist/components/checkbox/Checkbox.js +4 -4
  172. package/web-dist/components/checkbox-group/CheckboxGroup.js +4 -4
  173. package/web-dist/components/chess-board/ChessBoard.js +2 -2
  174. package/web-dist/components/chip/Chip.js +4 -4
  175. package/web-dist/components/chip-group/ChipGroup.js +4 -4
  176. package/web-dist/components/collection-editor/CollectionEditor.js +10 -10
  177. package/web-dist/components/color-hue-scale/ColorHueScale.js +6 -6
  178. package/web-dist/components/color-picker/ColorPicker.js +6 -6
  179. package/web-dist/components/color-tone/ColorTone.js +6 -6
  180. package/web-dist/components/color-wheel/ColorWheel.js +6 -6
  181. package/web-dist/components/content-rail/ContentRail.js +5 -5
  182. package/web-dist/components/data-table/DataTable.d.ts +1 -1
  183. package/web-dist/components/data-table/DataTable.js +149 -64
  184. package/web-dist/components/data-table/DataTable.types-0.d.ts +4 -0
  185. package/web-dist/components/date-picker/DatePicker.js +19 -160
  186. package/web-dist/components/dialog/Dialog.js +4 -4
  187. package/web-dist/components/divider/Divider.js +2 -2
  188. package/web-dist/components/empty-state/EmptyState.js +11 -11
  189. package/web-dist/components/explorer/Explorer.js +5 -5
  190. package/web-dist/components/field/Field.js +4 -4
  191. package/web-dist/components/file-explorer/FileExplorer.js +5 -5
  192. package/web-dist/components/flat-list/FlatList.js +5 -5
  193. package/web-dist/components/forgot-password-form/ForgotPasswordForm.js +12 -12
  194. package/web-dist/components/form/Form.js +8 -8
  195. package/web-dist/components/form-actions/FormActions.js +8 -8
  196. package/web-dist/components/form-error/FormError.js +8 -8
  197. package/web-dist/components/game/Game.js +3 -3
  198. package/web-dist/components/game-entity/GameEntity.js +3 -3
  199. package/web-dist/components/game-field/GameField.js +3 -3
  200. package/web-dist/components/game-input-zone/GameInputZone.js +3 -3
  201. package/web-dist/components/game-measurement-probe/GameMeasurementProbe.js +3 -3
  202. package/web-dist/components/game-overlay/GameOverlay.js +3 -3
  203. package/web-dist/components/gradient/Gradient.js +3 -3
  204. package/web-dist/components/gradient-renderer-provider/GradientRendererProvider.js +3 -3
  205. package/web-dist/components/graph-view/GraphView.js +34 -11
  206. package/web-dist/components/grid/Grid.js +2 -2
  207. package/web-dist/components/grid-view/GridView.d.ts +1 -1
  208. package/web-dist/components/grid-view/GridView.js +1 -1
  209. package/web-dist/components/grid-view/GridView.types-0.d.ts +2 -0
  210. package/web-dist/components/hero/Hero.js +10 -10
  211. package/web-dist/components/icon-button/IconButton.js +5 -5
  212. package/web-dist/components/image/Image.js +3 -3
  213. package/web-dist/components/list/List.js +5 -5
  214. package/web-dist/components/list-item/ListItem.js +5 -5
  215. package/web-dist/components/list-section/ListSection.js +5 -5
  216. package/web-dist/components/matrix-grid/MatrixGrid.js +1 -1
  217. package/web-dist/components/media-card/MediaCard.js +10 -10
  218. package/web-dist/components/media-explorer/MediaExplorer.js +5 -5
  219. package/web-dist/components/message-bubble/MessageBubble.js +6 -6
  220. package/web-dist/components/metric-card/MetricCard.js +10 -10
  221. package/web-dist/components/missing-element/MissingElement.js +3 -3
  222. package/web-dist/components/o-auth-provider-button/OAuthProviderButton.js +12 -12
  223. package/web-dist/components/o-auth-provider-list/OAuthProviderList.js +12 -12
  224. package/web-dist/components/opening-book/OpeningBook.js +2 -2
  225. package/web-dist/components/otp-form/OtpForm.js +12 -12
  226. package/web-dist/components/pagination/Pagination.js +5 -5
  227. package/web-dist/components/palette-item/PaletteItem.js +10 -10
  228. package/web-dist/components/popover-menu/PopoverMenu.js +4 -4
  229. package/web-dist/components/post-card/PostCard.js +10 -10
  230. package/web-dist/components/product-card/ProductCard.js +10 -10
  231. package/web-dist/components/progress/Progress.js +3 -3
  232. package/web-dist/components/progress-ring/ProgressRing.js +3 -3
  233. package/web-dist/components/radio/Radio.js +4 -4
  234. package/web-dist/components/radio-group/RadioGroup.js +4 -4
  235. package/web-dist/components/rating/Rating.js +2 -2
  236. package/web-dist/components/reader/Reader.js +11 -11
  237. package/web-dist/components/scan-overlay/ScanOverlay.js +11 -11
  238. package/web-dist/components/screen/Screen.js +2 -2
  239. package/web-dist/components/screen-section/ScreenSection.js +3 -3
  240. package/web-dist/components/scroll-view/ScrollView.js +2 -2
  241. package/web-dist/components/search-input/SearchInput.js +6 -6
  242. package/web-dist/components/section-header/SectionHeader.js +3 -3
  243. package/web-dist/components/section-list/SectionList.js +5 -5
  244. package/web-dist/components/select/Select.js +8 -8
  245. package/web-dist/components/sign-in-form/SignInForm.js +12 -12
  246. package/web-dist/components/sign-up-form/SignUpForm.js +12 -12
  247. package/web-dist/components/skeleton/Skeleton.js +13 -13
  248. package/web-dist/components/skeleton-card/SkeletonCard.js +13 -13
  249. package/web-dist/components/skeleton-list/SkeletonList.js +13 -13
  250. package/web-dist/components/skeleton-text/SkeletonText.js +13 -13
  251. package/web-dist/components/spatial-grid/SpatialGrid.js +1 -1
  252. package/web-dist/components/surface/Surface.js +3 -3
  253. package/web-dist/components/switch/Switch.js +2 -2
  254. package/web-dist/components/tab/Tab.js +2 -2
  255. package/web-dist/components/tab-list/TabList.js +2 -2
  256. package/web-dist/components/tab-panel/TabPanel.js +2 -2
  257. package/web-dist/components/tabs/Tabs.js +2 -2
  258. package/web-dist/components/text-input/TextInput.js +6 -6
  259. package/web-dist/components/theme-mode-toggle/ThemeModeToggle.js +5 -5
  260. package/web-dist/components/tile-grid/TileGrid.js +1 -1
  261. package/web-dist/components/time-grid/TimeGrid.js +1 -1
  262. package/web-dist/components/time-picker/TimePicker.js +9 -9
  263. package/web-dist/components/timeline/Timeline.dependency-2.d.ts +8 -2
  264. package/web-dist/components/timeline/Timeline.dependency-3.d.ts +23 -0
  265. package/web-dist/components/timeline/Timeline.dependency-4.d.ts +3 -0
  266. package/web-dist/components/timeline/Timeline.js +30 -11
  267. package/web-dist/components/timeline/Timeline.types-0.d.ts +5 -1
  268. package/web-dist/components/toast/Toast.js +4 -4
  269. package/web-dist/components/toast-provider/ToastProvider.js +4 -4
  270. package/web-dist/components/toolbar/Toolbar.js +10 -10
  271. package/web-dist/components/tree-item/TreeItem.js +7 -7
  272. package/web-dist/components/uploader/Uploader.js +14 -14
  273. package/web-dist/components/view/View.js +2 -2
  274. package/web-dist/manifest.json +720 -673
  275. package/web-dist/runtime/ZoraProvider.js +3 -3
  276. /package/web-dist/chunks/{Accordion-kpk964z0.js → Accordion-a8k3cvj0.js} +0 -0
@@ -2,15 +2,12 @@ import React from 'react';
2
2
 
3
3
  import type { DatePickerProps } from '../../../types/date-picker';
4
4
  import { Button } from '../../button/public';
5
+ import { Calendar } from '../../calendar/public';
5
6
  import { View } from '../../layout/public';
6
7
  import { PickerHeader } from '../../picker/composition/PickerHeader';
7
- import { Text } from '../../typography/public';
8
- import { formatLocalDate, parseLocalDate } from '../utils/localDate';
8
+ import { parseLocalDate } from '../utils/localDate';
9
9
 
10
- const WEEKDAY_LABELS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] as const;
11
- const DAY_CELL_WIDTH = 42;
12
-
13
- /*** Renders the shared calendar content used by native BottomSheet and web Popover hosts. */
10
+ /*** Hosts the shared compact Calendar inside the existing DatePicker overlay surfaces. */
14
11
  export function DatePickerContent({
15
12
  description,
16
13
  interactionPolicy,
@@ -22,30 +19,21 @@ export function DatePickerContent({
22
19
  testID,
23
20
  value,
24
21
  }: DatePickerContentProps) {
25
- const [displayMonth, setDisplayMonth] = React.useState(() => resolveInitialMonth(value, minDate));
26
- const monthDays = React.useMemo(() => createMonthDays(displayMonth), [displayMonth]);
27
22
  const resolvedMaxDate = React.useMemo(() => parseLocalDate(maxDate), [maxDate]);
28
23
  const resolvedMinDate = React.useMemo(() => parseLocalDate(minDate), [minDate]);
24
+ const selectedDate = React.useMemo(() => parseLocalDate(value), [value]);
29
25
 
30
26
  return (
31
27
  <View gap="m" p="m" testID={testID ? `${testID}-content` : undefined}>
32
28
  <PickerHeader description={description} title={label ?? 'Choose date'} />
33
- <DatePickerMonthNavigation
34
- displayMonth={displayMonth}
29
+ <Calendar
30
+ density="compact"
35
31
  interactionPolicy={interactionPolicy}
36
32
  maxDate={resolvedMaxDate}
37
33
  minDate={resolvedMinDate}
38
- onMonthChange={setDisplayMonth}
39
- />
40
- <DatePickerWeekdays />
41
- <DatePickerCalendar
42
- interactionPolicy={interactionPolicy}
43
- maxDate={resolvedMaxDate}
44
- minDate={resolvedMinDate}
45
- monthDays={monthDays}
46
- onSelect={onSelect}
34
+ onSelectedDateChange={onSelect}
35
+ selectedDate={selectedDate ?? null}
47
36
  testID={testID}
48
- value={value}
49
37
  />
50
38
  <Button fullWidth interactionPolicy={interactionPolicy} onPress={onDismiss} variant="ghost">
51
39
  Cancel
@@ -61,175 +49,3 @@ interface DatePickerContentProps extends Pick<
61
49
  onDismiss: () => void;
62
50
  onSelect: (value: Date) => void;
63
51
  }
64
-
65
- /*** Renders previous and next month controls for the calendar. */
66
- function DatePickerMonthNavigation({
67
- displayMonth,
68
- interactionPolicy,
69
- maxDate,
70
- minDate,
71
- onMonthChange,
72
- }: {
73
- displayMonth: Date;
74
- interactionPolicy: DatePickerProps['interactionPolicy'];
75
- maxDate: Date | undefined;
76
- minDate: Date | undefined;
77
- onMonthChange: (month: Date) => void;
78
- }) {
79
- const previousMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() - 1, 1);
80
- const nextMonth = new Date(displayMonth.getFullYear(), displayMonth.getMonth() + 1, 1);
81
-
82
- return (
83
- <View align="center" direction="row" justify="space-between">
84
- <Button
85
- disabled={!canNavigateToMonth(previousMonth, minDate, maxDate)}
86
- interactionPolicy={interactionPolicy}
87
- onPress={() => onMonthChange(previousMonth)}
88
- size="s"
89
- variant="ghost"
90
- >
91
- Previous
92
- </Button>
93
- <Text align="center" variant="label" weight="semiBold">
94
- {formatMonthLabel(displayMonth)}
95
- </Text>
96
- <Button
97
- disabled={!canNavigateToMonth(nextMonth, minDate, maxDate)}
98
- interactionPolicy={interactionPolicy}
99
- onPress={() => onMonthChange(nextMonth)}
100
- size="s"
101
- variant="ghost"
102
- >
103
- Next
104
- </Button>
105
- </View>
106
- );
107
- }
108
-
109
- /*** Renders weekday headings for the calendar grid. */
110
- function DatePickerWeekdays() {
111
- return (
112
- <View direction="row" justify="space-between">
113
- {WEEKDAY_LABELS.map((weekday) => (
114
- <View key={weekday} width={DAY_CELL_WIDTH}>
115
- <Text align="center" emphasis="muted" variant="caption" weight="semiBold">
116
- {weekday}
117
- </Text>
118
- </View>
119
- ))}
120
- </View>
121
- );
122
- }
123
-
124
- /*** Renders selectable day cells for the current calendar month. */
125
- function DatePickerCalendar({
126
- interactionPolicy,
127
- maxDate,
128
- minDate,
129
- monthDays,
130
- onSelect,
131
- testID,
132
- value,
133
- }: {
134
- interactionPolicy: DatePickerProps['interactionPolicy'];
135
- maxDate: Date | undefined;
136
- minDate: Date | undefined;
137
- monthDays: readonly (Date | null)[];
138
- onSelect: (value: Date) => void;
139
- testID: string | undefined;
140
- value: DatePickerProps['value'];
141
- }) {
142
- return (
143
- <View direction="row" gap="xs" wrap="wrap">
144
- {monthDays.map((day, index) => {
145
- if (!day) return <View key={`empty-${index}`} width={DAY_CELL_WIDTH} />;
146
- const selected = isSameLocalDay(value, day);
147
- return (
148
- <View key={day.toISOString()} width={DAY_CELL_WIDTH}>
149
- <Button
150
- color={selected ? 'primary' : 'neutral'}
151
- disabled={isDateDisabled(day, minDate, maxDate)}
152
- interactionPolicy={interactionPolicy}
153
- onPress={() => onSelect(day)}
154
- size="s"
155
- testID={testID ? `${testID}-day-${day.getDate()}` : undefined}
156
- variant={selected ? 'solid' : 'ghost'}
157
- >
158
- {day.getDate()}
159
- </Button>
160
- </View>
161
- );
162
- })}
163
- </View>
164
- );
165
- }
166
-
167
- /*** Compares a serialized date to one local calendar day. */
168
- function isSameLocalDay(left: string | null, right: Date): boolean {
169
- return left === formatLocalDate(right);
170
- }
171
-
172
- /*** Normalizes a Date to the start of its local calendar day. */
173
- function startOfLocalDay(value: Date): Date {
174
- return new Date(value.getFullYear(), value.getMonth(), value.getDate());
175
- }
176
-
177
- /*** Reports whether one local calendar day precedes another. */
178
- function isBeforeLocalDay(left: Date, right: Date): boolean {
179
- return startOfLocalDay(left).getTime() < startOfLocalDay(right).getTime();
180
- }
181
-
182
- /*** Reports whether one local calendar day follows another. */
183
- function isAfterLocalDay(left: Date, right: Date): boolean {
184
- return startOfLocalDay(left).getTime() > startOfLocalDay(right).getTime();
185
- }
186
-
187
- /*** Reports whether a date falls outside the configured picker range. */
188
- function isDateDisabled(
189
- value: Date,
190
- minDate: Date | undefined,
191
- maxDate: Date | undefined,
192
- ): boolean {
193
- if (minDate && isBeforeLocalDay(value, minDate)) return true;
194
- if (maxDate && isAfterLocalDay(value, maxDate)) return true;
195
- return false;
196
- }
197
-
198
- /*** Formats the current calendar month for the picker heading. */
199
- function formatMonthLabel(value: Date): string {
200
- return value.toLocaleDateString(undefined, { month: 'long', year: 'numeric' });
201
- }
202
-
203
- /*** Builds the padded calendar grid for one month. */
204
- function createMonthDays(month: Date): (Date | null)[] {
205
- const firstDay = new Date(month.getFullYear(), month.getMonth(), 1);
206
- const dayCount = new Date(month.getFullYear(), month.getMonth() + 1, 0).getDate();
207
- const populatedLength = firstDay.getDay() + dayCount;
208
- const paddedLength = Math.ceil(populatedLength / 7) * 7;
209
-
210
- return Array.from({ length: paddedLength }, (_, index) =>
211
- index < firstDay.getDay()
212
- ? null
213
- : new Date(month.getFullYear(), month.getMonth(), index - firstDay.getDay() + 1),
214
- );
215
- }
216
-
217
- /*** Resolves the month initially shown by the calendar. */
218
- function resolveInitialMonth(value: string | null, minDate: string | undefined): Date {
219
- const base = parseLocalDate(value) ?? parseLocalDate(minDate) ?? new Date();
220
- return new Date(base.getFullYear(), base.getMonth(), 1);
221
- }
222
-
223
- /*** Reports whether the configured range intersects a candidate month. */
224
- function canNavigateToMonth(
225
- month: Date,
226
- minDate: Date | undefined,
227
- maxDate: Date | undefined,
228
- ): boolean {
229
- const firstDay = new Date(month.getFullYear(), month.getMonth(), 1);
230
- const lastDay = new Date(month.getFullYear(), month.getMonth() + 1, 0);
231
-
232
- if (maxDate && isAfterLocalDay(firstDay, maxDate)) return false;
233
- if (minDate && isBeforeLocalDay(lastDay, minDate)) return false;
234
- return true;
235
- }
@@ -19,5 +19,6 @@ test('DatePicker keeps one manifest contract across native and web presentation
19
19
  expect(nativeSource).toContain('useBottomSheet()');
20
20
  expect(webSource).toContain('<Popover');
21
21
  expect(webSource).not.toContain('useBottomSheet');
22
- expect(contentSource).toContain('DatePickerCalendar');
22
+ expect(contentSource).toContain('<Calendar');
23
+ expect(contentSource).toContain('density="compact"');
23
24
  });
@@ -194,12 +194,19 @@ function measureRenderedNodes(cy: Core, nodeIds: readonly string[]): GraphViewMe
194
194
  const nodes = [...new Set(nodeIds)].flatMap((id) => {
195
195
  const node = cy.getElementById(id);
196
196
  if (!node.isNode()) return [];
197
+ const bounds = node.isParent() ? node.renderedBoundingBox() : null;
197
198
 
198
199
  return [
199
200
  {
200
201
  id,
201
- position: node.renderedPosition(),
202
- size: { width: node.renderedOuterWidth(), height: node.renderedOuterHeight() },
202
+ position:
203
+ bounds === null
204
+ ? node.renderedPosition()
205
+ : { x: bounds.x1 + bounds.w / 2, y: bounds.y1 + bounds.h / 2 },
206
+ size:
207
+ bounds === null
208
+ ? { width: node.renderedOuterWidth(), height: node.renderedOuterHeight() }
209
+ : { width: bounds.w, height: bounds.h },
203
210
  },
204
211
  ];
205
212
  });
@@ -111,8 +111,18 @@ test('fits changed topology but preserves viewport and avoids relayout for highl
111
111
 
112
112
  test('preserves a stable topology removal without relayout, fit, or retained-node movement', async () => {
113
113
  const ready = Promise.withResolvers<GraphViewController>();
114
- const calls = { sort: 0 };
115
- const runtime = createGraphRuntime(undefined, { current: { onReady: ready.resolve } });
114
+ const calls = { complete: 0, ready: 0, sort: 0 };
115
+ const runtime = createGraphRuntime(undefined, {
116
+ current: {
117
+ onLayoutComplete: () => {
118
+ calls.complete += 1;
119
+ },
120
+ onReady: (controller) => {
121
+ calls.ready += 1;
122
+ ready.resolve(controller);
123
+ },
124
+ },
125
+ });
116
126
  const nodes = Array.from({ length: 87 }, (_, index) => ({ id: `repository-${index}` }));
117
127
  const input = {
118
128
  nodes,
@@ -127,7 +137,7 @@ test('preserves a stable topology removal without relayout, fit, or retained-nod
127
137
  return 0;
128
138
  },
129
139
  },
130
- richNodeRendering: false,
140
+ richNodeRendering: true,
131
141
  topologyUpdatePolicy: 'preserve-positions' as const,
132
142
  };
133
143
  try {
@@ -146,15 +156,166 @@ test('preserves a stable topology removal without relayout, fit, or retained-nod
146
156
  nodes: nodes.slice(0, -1),
147
157
  edges: input.edges.slice(0, -1),
148
158
  });
159
+ runtime.setNodeSize('repository-0', { height: 24, width: 48 });
160
+ await new Promise((resolve) => setTimeout(resolve, 0));
149
161
 
150
- expect(controller.measureNodes?.(retainedIds)).toEqual(before);
162
+ expect(
163
+ controller.measureNodes?.(retainedIds)?.nodes.map(({ id, position }) => ({ id, position })),
164
+ ).toEqual(before?.nodes.map(({ id, position }) => ({ id, position })));
151
165
  expect(controller.getViewport()).toEqual(viewport);
166
+ expect(calls.ready).toBe(1);
167
+ expect(calls.complete).toBe(1);
152
168
  expect(calls.sort).toBe(sortCount);
153
169
  } finally {
154
170
  runtime.destroy();
155
171
  }
156
172
  });
157
173
 
174
+ test('keeps added compound targets inside a preserved user viewport without relayout', async () => {
175
+ await withGraphViewportAsync(async () => {
176
+ const ready = Promise.withResolvers<GraphViewController>();
177
+ const calls = { ready: 0, sort: 0 };
178
+ const controllers: GraphViewController[] = [];
179
+ const runtime = createGraphRuntime(undefined, {
180
+ current: {
181
+ onReady: (controller) => {
182
+ calls.ready += 1;
183
+ controllers.push(controller);
184
+ ready.resolve(controller);
185
+ },
186
+ },
187
+ });
188
+ const input = {
189
+ nodes: [{ id: 'README' }, { id: 'src' }],
190
+ edges: [],
191
+ layout: 'grid' as const,
192
+ layoutOptions: {
193
+ sort: () => {
194
+ calls.sort += 1;
195
+ return 0;
196
+ },
197
+ },
198
+ richNodeRendering: false,
199
+ topologyUpdatePolicy: 'preserve-positions' as const,
200
+ };
201
+ try {
202
+ runtime.update(input);
203
+ const controller = await ready.promise;
204
+ controller.fit();
205
+ controller.setZoom(0.8);
206
+ controller.setPan({ x: -40, y: -30 });
207
+ const viewport = controller.getViewport();
208
+ const retainedPosition = controller.measureNodes?.(['README']);
209
+ const sortCount = calls.sort;
210
+
211
+ runtime.update({
212
+ ...input,
213
+ nodes: [
214
+ { id: 'README' },
215
+ { id: 'src' },
216
+ { id: 'src.features', parentId: 'src' },
217
+ { id: 'src.features.nested', parentId: 'src.features' },
218
+ ],
219
+ });
220
+
221
+ expect(controller.getViewport()).toEqual(viewport);
222
+ expect(viewport).toEqual({ zoom: 0.8, pan: { x: -40, y: -30 } });
223
+ expect(controller.measureNodes?.(['README'])).toEqual(retainedPosition);
224
+ expect(calls.ready).toBe(1);
225
+ expect(controllers).toEqual([controller]);
226
+ expect(calls.sort).toBe(sortCount);
227
+ expectCompoundMeasurementsToFitViewport(controller, ['src.features', 'src.features.nested']);
228
+ } finally {
229
+ runtime.destroy();
230
+ }
231
+ });
232
+ });
233
+
234
+ test('lays out a late initial rich-node measurement without a topology change', async () => {
235
+ const ready = Promise.withResolvers<GraphViewController>();
236
+ const completed = Promise.withResolvers<void>();
237
+ const calls = { sort: 0 };
238
+ const callbacks: { current: GraphViewCallbacks } = { current: { onReady: ready.resolve } };
239
+ const runtime = createGraphRuntime(undefined, callbacks);
240
+ const input = {
241
+ nodes: [{ id: 'a' }, { id: 'b' }],
242
+ edges: [{ source: 'a', target: 'b' }],
243
+ layout: 'grid' as const,
244
+ layoutOptions: {
245
+ sort: () => {
246
+ calls.sort += 1;
247
+ return 0;
248
+ },
249
+ },
250
+ richNodeRendering: true,
251
+ topologyUpdatePolicy: 'preserve-positions' as const,
252
+ };
253
+ try {
254
+ runtime.update(input);
255
+ await ready.promise;
256
+ const sortCount = calls.sort;
257
+ callbacks.current = { onLayoutComplete: () => completed.resolve() };
258
+
259
+ runtime.setNodeSize('a', { height: 24, width: 48 });
260
+ await completed.promise;
261
+
262
+ expect(calls.sort).toBeGreaterThan(sortCount);
263
+ } finally {
264
+ runtime.destroy();
265
+ }
266
+ });
267
+
268
+ test('keeps explicit fit and layout available after preserving a rich-node topology removal', async () => {
269
+ const ready = Promise.withResolvers<GraphViewController>();
270
+ const completed = Promise.withResolvers<void>();
271
+ const calls = { sort: 0 };
272
+ const callbacks: { current: GraphViewCallbacks } = { current: { onReady: ready.resolve } };
273
+ const runtime = createGraphRuntime(undefined, callbacks);
274
+ const nodes = Array.from({ length: 87 }, (_, index) => ({ id: `repository-${index}` }));
275
+ const input = {
276
+ nodes,
277
+ edges: nodes.slice(1).flatMap((node, index) => {
278
+ const source = nodes.at(index);
279
+ return source ? [{ id: `dependency-${index}`, source: source.id, target: node.id }] : [];
280
+ }),
281
+ layout: 'grid' as const,
282
+ layoutOptions: {
283
+ sort: () => {
284
+ calls.sort += 1;
285
+ return 0;
286
+ },
287
+ },
288
+ richNodeRendering: true,
289
+ topologyUpdatePolicy: 'preserve-positions' as const,
290
+ };
291
+ try {
292
+ runtime.update(input);
293
+ const controller = await ready.promise;
294
+ controller.setZoom(0.7);
295
+ controller.setPan({ x: 40, y: 30 });
296
+ const preservedInput = {
297
+ ...input,
298
+ nodes: nodes.slice(0, -1),
299
+ edges: input.edges.slice(0, -1),
300
+ };
301
+ runtime.update(preservedInput);
302
+ runtime.setNodeSize('repository-0', { height: 24, width: 48 });
303
+ await new Promise((resolve) => setTimeout(resolve, 0));
304
+ const preservedSorts = calls.sort;
305
+ const preservedViewport = controller.getViewport();
306
+
307
+ controller.fit();
308
+ expect(controller.getViewport()).not.toEqual(preservedViewport);
309
+ callbacks.current = { onLayoutComplete: () => completed.resolve() };
310
+ runtime.update({ ...preservedInput, layout: 'circle' });
311
+ await completed.promise;
312
+
313
+ expect(calls.sort).toBeGreaterThan(preservedSorts);
314
+ } finally {
315
+ runtime.destroy();
316
+ }
317
+ });
318
+
158
319
  test('fits a changed layout algorithm even when visible topology is unchanged', async () => {
159
320
  const initial = Promise.withResolvers<GraphViewController>();
160
321
  const completed = Promise.withResolvers<GraphViewController>();
@@ -197,6 +358,51 @@ function expectMeasuredNodesToFit(controller: GraphViewController, nodeIds: read
197
358
  }
198
359
  }
199
360
 
361
+ function expectCompoundMeasurementsToFitViewport(
362
+ controller: GraphViewController,
363
+ nodeIds: readonly string[],
364
+ ) {
365
+ const measurement = controller.measureNodes?.(nodeIds);
366
+ expect(measurement).not.toBeNull();
367
+ if (measurement === null) return;
368
+ expect(measurement.viewport).toEqual({ width: 992, height: 440 });
369
+ expect(measurement.nodes).toHaveLength(2);
370
+ expect(measurement.nodes.map((node) => node.id)).toEqual(nodeIds);
371
+ for (const node of measurement.nodes) {
372
+ expect(Number.isFinite(node.position.x)).toBe(true);
373
+ expect(Number.isFinite(node.position.y)).toBe(true);
374
+ expect(node.size.width).toBeGreaterThan(0);
375
+ expect(node.size.height).toBeGreaterThan(0);
376
+ const left = node.position.x - node.size.width / 2;
377
+ const right = node.position.x + node.size.width / 2;
378
+ const top = node.position.y - node.size.height / 2;
379
+ const bottom = node.position.y + node.size.height / 2;
380
+ expect(left).toBeGreaterThanOrEqual(0);
381
+ expect(right).toBeLessThanOrEqual(measurement.viewport.width);
382
+ expect(top).toBeGreaterThanOrEqual(0);
383
+ expect(bottom).toBeLessThanOrEqual(measurement.viewport.height);
384
+ expect(node.position.x).toBeGreaterThanOrEqual(left);
385
+ expect(node.position.x).toBeLessThanOrEqual(right);
386
+ expect(node.position.y).toBeGreaterThanOrEqual(top);
387
+ expect(node.position.y).toBeLessThanOrEqual(bottom);
388
+ }
389
+ }
390
+
391
+ async function withGraphViewportAsync(run: () => Promise<void>) {
392
+ const probe = cytoscape({ headless: true });
393
+ const core = Object.getPrototypeOf(probe) as { height: () => number; width: () => number };
394
+ probe.destroy();
395
+ const { height, width } = core;
396
+ core.height = () => 440;
397
+ core.width = () => 992;
398
+ try {
399
+ await run();
400
+ } finally {
401
+ core.height = height;
402
+ core.width = width;
403
+ }
404
+ }
405
+
200
406
  test('preserves selection and positions through hover presentation updates without relayout', async () => {
201
407
  const ready = Promise.withResolvers<GraphViewController>();
202
408
  const events: GraphViewElementEvent[] = [];
@@ -62,6 +62,7 @@ interface GraphRuntimeState {
62
62
  readonly labelSizedNodeIds: Set<string>;
63
63
  readonly loopSizer: ReturnType<typeof createGraphLoopSizer>;
64
64
  readonly pendingInitialFitRef: { current: boolean };
65
+ readonly preservedTopologyMeasurementRef: { current: boolean };
65
66
  readonly readyRef: { current: boolean };
66
67
  readonly settledLayoutRef: { current: GraphRuntimeUpdate['layout'] | null };
67
68
  readonly settledTopologyRef: { current: string | null };
@@ -83,6 +84,7 @@ export function createGraphRuntime(
83
84
  minZoom: 0.05,
84
85
  maxZoom: 2,
85
86
  selectionType: 'additive',
87
+ styleEnabled: true,
86
88
  userPanningEnabled: true,
87
89
  });
88
90
  const state = createRuntimeState(cy, container, callbacksRef, readLatestPointerDown);
@@ -132,6 +134,7 @@ function createRuntimeState(
132
134
  labelSizedNodeIds: new Set<string>(),
133
135
  loopSizer: createGraphLoopSizer(cy),
134
136
  pendingInitialFitRef: { current: false },
137
+ preservedTopologyMeasurementRef: { current: false },
135
138
  readyRef,
136
139
  settledLayoutRef: { current: null as GraphRuntimeUpdate['layout'] | null },
137
140
  settledTopologyRef: { current: null as string | null },
@@ -182,13 +185,13 @@ function updateRuntime(state: GraphRuntimeState, input: GraphRuntimeUpdate) {
182
185
  state.fitPaddingRef.current = input.fitPadding ?? 50;
183
186
  state.viewport.configure(input);
184
187
  const preservesTopology = shouldPreserveTopology(state, previous, input);
188
+ beginPreservedTopologyMeasurementWindow(state, previous, input, preservesTopology);
185
189
  const retainedNodeIds = getRetainedNodeIds(previous, input, preservesTopology);
186
190
  const retainedGeometry =
187
191
  retainedNodeIds === null ? null : getGraphGeometryKey(state.cy, retainedNodeIds);
188
192
  state.cy.batch(() => {
189
193
  if (previous?.nodes !== input.nodes || previous.edges !== input.edges) {
190
194
  syncGraphElements(state.cy, input.nodes, input.edges);
191
- if (preservesTopology) placeAddedGraphNodes(state.cy, previous?.nodes ?? [], input.nodes);
192
195
  }
193
196
  if (
194
197
  previous?.styleRules !== input.styleRules ||
@@ -198,6 +201,7 @@ function updateRuntime(state: GraphRuntimeState, input: GraphRuntimeUpdate) {
198
201
  applyGraphStyles(state.cy, input.styleRules, input.richNodeRendering);
199
202
  }
200
203
  });
204
+ if (preservesTopology) placeAddedGraphNodes(state.cy, previous?.nodes ?? [], input.nodes);
201
205
  sizeGraphNodesToLabels(
202
206
  state.cy,
203
207
  state.labelSizedNodeIds,
@@ -248,7 +252,28 @@ function shouldPreserveTopology(
248
252
  );
249
253
  }
250
254
 
251
- /*** Limit stable-update geometry checks to nodes that existed before reconciliation. */
255
+ /***
256
+ * Retain measurements emitted by the overlay commit that follows one controlled topology update.
257
+ * A later resize remains geometry input and therefore schedules its normal relayout.
258
+ */
259
+ function beginPreservedTopologyMeasurementWindow(
260
+ state: GraphRuntimeState,
261
+ previous: GraphRuntimeUpdate | null,
262
+ input: GraphRuntimeUpdate,
263
+ preservesTopology: boolean,
264
+ ) {
265
+ const topologyChanged =
266
+ previous !== null &&
267
+ getGraphTopologyKey(previous.nodes, previous.edges) !==
268
+ getGraphTopologyKey(input.nodes, input.edges);
269
+ state.preservedTopologyMeasurementRef.current = preservesTopology && topologyChanged;
270
+ if (!state.preservedTopologyMeasurementRef.current) return;
271
+ scheduleGraphFrame(() => {
272
+ state.preservedTopologyMeasurementRef.current = false;
273
+ });
274
+ }
275
+
276
+ /*** Limit stable-update geometry checks to retained leaves with independently stable positions. */
252
277
  function getRetainedNodeIds(
253
278
  previous: GraphRuntimeUpdate | null,
254
279
  input: GraphRuntimeUpdate,
@@ -256,7 +281,14 @@ function getRetainedNodeIds(
256
281
  ): ReadonlySet<string> | null {
257
282
  if (!preservesTopology || previous === null) return null;
258
283
  const nextNodeIds = new Set(input.nodes.map((node) => node.id));
259
- return new Set(previous.nodes.map((node) => node.id).filter((id) => nextNodeIds.has(id)));
284
+ const nextParentIds = new Set(
285
+ input.nodes.flatMap((node) => (node.parentId === undefined ? [] : [node.parentId])),
286
+ );
287
+ return new Set(
288
+ previous.nodes
289
+ .map((node) => node.id)
290
+ .filter((id) => nextNodeIds.has(id) && !nextParentIds.has(id)),
291
+ );
260
292
  }
261
293
 
262
294
  /*** Start a generation-safe layout whose completion is the only normal automatic fit trigger. */
@@ -422,6 +454,7 @@ function setNodeSize(state: GraphRuntimeState, id: string, size: GraphViewSize)
422
454
  if (previous?.width === size.width && previous.height === size.height) return;
423
455
  state.nodeSizes.set(id, size);
424
456
  applyNodeSize(state.cy, id, size);
457
+ if (state.preservedTopologyMeasurementRef.current) return;
425
458
  scheduleMeasuredNodeRelayout(state);
426
459
  }
427
460
 
@@ -0,0 +1,33 @@
1
+ import { expect, test } from 'bun:test';
2
+ import cytoscape from 'cytoscape';
3
+
4
+ import { placeAddedGraphNodes } from './placeAddedGraphNodes';
5
+
6
+ test('positions added compound descendants at the visible viewport when no retained leaf remains', () => {
7
+ const cy = cytoscape({
8
+ headless: true,
9
+ elements: [
10
+ { data: { id: 'src' } },
11
+ { data: { id: 'src.features', parent: 'src' } },
12
+ { data: { id: 'src.features.nested', parent: 'src.features' } },
13
+ ],
14
+ });
15
+ try {
16
+ cy.extent = () => ({ x1: 100, x2: 300, y1: 40, y2: 200, w: 200, h: 160 });
17
+
18
+ placeAddedGraphNodes(
19
+ cy,
20
+ [{ id: 'src' }],
21
+ [
22
+ { id: 'src' },
23
+ { id: 'src.features', parentId: 'src' },
24
+ { id: 'src.features.nested', parentId: 'src.features' },
25
+ ],
26
+ );
27
+
28
+ expect(cy.getElementById('src.features').isParent()).toBe(true);
29
+ expect(cy.getElementById('src.features.nested').position()).toEqual({ x: 200, y: 120 });
30
+ } finally {
31
+ cy.destroy();
32
+ }
33
+ });
@@ -20,18 +20,32 @@ export function placeAddedGraphNodes(
20
20
  .sort((left, right) => left.id.localeCompare(right.id));
21
21
  if (addedNodes.length === 0) return;
22
22
 
23
+ const addedLeaves = addedNodes
24
+ .map((node) => cy.getElementById(node.id))
25
+ .filter((node) => !node.empty() && !node.isParent());
26
+ if (addedLeaves.length === 0) return;
27
+
23
28
  const retainedNodes = cy
24
29
  .nodes()
25
30
  .filter((node) => previousNodeIds.has(node.id()) && !node.isParent());
26
31
  const bounds = retainedNodes.boundingBox({ includeEdges: false, includeLabels: true });
27
- const origin = retainedNodes.empty() ? { x: 0, y: 0 } : { x: bounds.x2 + GRID_GAP, y: bounds.y1 };
28
- const columns = Math.ceil(Math.sqrt(addedNodes.length));
29
- addedNodes.forEach((node, index) => {
30
- const graphNode = cy.getElementById(node.id);
31
- if (graphNode.empty() || graphNode.isParent()) return;
32
+ const origin = retainedNodes.empty()
33
+ ? getVisibleViewportCenter(cy)
34
+ : { x: bounds.x2 + GRID_GAP, y: bounds.y1 };
35
+ const columns = Math.ceil(Math.sqrt(addedLeaves.length));
36
+ addedLeaves.forEach((graphNode, index) => {
32
37
  graphNode.position({
33
38
  x: origin.x + (index % columns) * GRID_GAP,
34
39
  y: origin.y + Math.floor(index / columns) * GRID_GAP,
35
40
  });
36
41
  });
37
42
  }
43
+
44
+ /*** Return the model point at the center of the unchanged visible viewport. */
45
+ function getVisibleViewportCenter(cy: Core) {
46
+ const extent = cy.extent();
47
+ return {
48
+ x: (extent.x1 + extent.x2) / 2,
49
+ y: (extent.y1 + extent.y2) / 2,
50
+ };
51
+ }