@sentry/scraps 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/README.md +74 -8
  2. package/dist/alert/alert.js +0 -3
  3. package/dist/badge/badge.js +1 -2
  4. package/dist/badge/tag.js +4 -4
  5. package/dist/button/button.js +1 -0
  6. package/dist/button/index.d.ts +0 -1
  7. package/dist/button/index.js +0 -1
  8. package/dist/button/linkButton.js +1 -0
  9. package/dist/button/styles.js +157 -152
  10. package/dist/clipboard/copyToClipboardButton.d.ts +15 -0
  11. package/dist/clipboard/copyToClipboardButton.js +32 -0
  12. package/dist/clipboard/index.d.ts +1 -0
  13. package/dist/clipboard/index.js +1 -0
  14. package/dist/code/index.d.ts +1 -0
  15. package/dist/code/index.js +1 -0
  16. package/dist/codeBlock/codeBlock.d.ts +68 -0
  17. package/dist/codeBlock/codeBlock.js +243 -0
  18. package/dist/codeBlock/index.d.ts +2 -0
  19. package/dist/codeBlock/index.js +2 -0
  20. package/dist/codeBlock/prism.d.ts +11 -0
  21. package/dist/codeBlock/prism.js +101 -0
  22. package/dist/codeBlock/styles.d.ts +2 -0
  23. package/dist/codeBlock/styles.js +133 -0
  24. package/dist/compactSelect/compactSelect.d.ts +21 -0
  25. package/dist/compactSelect/compactSelect.js +150 -0
  26. package/dist/compactSelect/composite.d.ts +54 -0
  27. package/dist/compactSelect/composite.js +101 -0
  28. package/dist/compactSelect/control.d.ts +112 -0
  29. package/dist/compactSelect/control.js +355 -0
  30. package/dist/compactSelect/gridList/index.d.ts +46 -0
  31. package/dist/compactSelect/gridList/index.js +102 -0
  32. package/dist/compactSelect/gridList/option.d.ts +15 -0
  33. package/dist/compactSelect/gridList/option.js +111 -0
  34. package/dist/compactSelect/gridList/section.d.ts +15 -0
  35. package/dist/compactSelect/gridList/section.js +58 -0
  36. package/dist/compactSelect/highlightText.d.ts +6 -0
  37. package/dist/compactSelect/highlightText.js +33 -0
  38. package/dist/compactSelect/index.d.ts +9 -0
  39. package/dist/compactSelect/index.js +8 -0
  40. package/dist/compactSelect/list.d.ts +94 -0
  41. package/dist/compactSelect/list.js +167 -0
  42. package/dist/compactSelect/listBox/index.d.ts +84 -0
  43. package/dist/compactSelect/listBox/index.js +175 -0
  44. package/dist/compactSelect/listBox/option.d.ts +19 -0
  45. package/dist/compactSelect/listBox/option.js +101 -0
  46. package/dist/compactSelect/listBox/section.d.ts +21 -0
  47. package/dist/compactSelect/listBox/section.js +58 -0
  48. package/dist/compactSelect/menuComponents.d.ts +89 -0
  49. package/dist/compactSelect/menuComponents.js +117 -0
  50. package/dist/compactSelect/selectFilterContext.d.ts +2 -0
  51. package/dist/compactSelect/selectFilterContext.js +3 -0
  52. package/dist/compactSelect/styles.d.ts +39 -0
  53. package/dist/compactSelect/styles.js +155 -0
  54. package/dist/compactSelect/types.d.ts +1 -0
  55. package/dist/compactSelect/types.js +0 -0
  56. package/dist/compactSelect/useVirtualizedItems.d.ts +52 -0
  57. package/dist/compactSelect/useVirtualizedItems.js +74 -0
  58. package/dist/compactSelect/utils.d.ts +80 -0
  59. package/dist/compactSelect/utils.js +264 -0
  60. package/dist/confirm/index.d.ts +153 -0
  61. package/dist/confirm/index.js +132 -0
  62. package/dist/dateTime/config.d.ts +23 -0
  63. package/dist/dateTime/config.js +50 -0
  64. package/dist/dateTime/context.d.ts +18 -0
  65. package/dist/dateTime/context.js +46 -0
  66. package/dist/dateTime/dateTime.d.ts +6 -0
  67. package/dist/dateTime/dateTime.js +30 -0
  68. package/dist/dateTime/format.d.ts +24 -0
  69. package/dist/dateTime/format.js +45 -0
  70. package/dist/dateTime/index.d.ts +6 -0
  71. package/dist/dateTime/index.js +6 -0
  72. package/dist/dateTime/intlFormatter.d.ts +9 -0
  73. package/dist/dateTime/intlFormatter.js +16 -0
  74. package/dist/dateTime/parseDate.d.ts +3 -0
  75. package/dist/dateTime/parseDate.js +12 -0
  76. package/dist/descriptionList/descriptionList.js +4 -3
  77. package/dist/disclosure/disclosure.js +2 -2
  78. package/dist/dragHandle/dragHandle.d.ts +3 -1
  79. package/dist/dragHandle/dragHandle.js +8 -5
  80. package/dist/drawer/components.d.ts +46 -0
  81. package/dist/drawer/components.js +265 -0
  82. package/dist/drawer/globalDrawer.d.ts +106 -0
  83. package/dist/drawer/globalDrawer.js +173 -0
  84. package/dist/drawer/index.d.ts +3 -0
  85. package/dist/drawer/index.js +2 -0
  86. package/dist/drawer/useDrawerResizing.d.ts +19 -0
  87. package/dist/drawer/useDrawerResizing.js +111 -0
  88. package/dist/drawer/useDrawerWidth.d.ts +1 -0
  89. package/dist/drawer/useDrawerWidth.js +42 -0
  90. package/dist/dropdownMenu/content.d.ts +1 -0
  91. package/dist/dropdownMenu/content.js +1 -0
  92. package/dist/dropdownMenu/context.d.ts +39 -0
  93. package/dist/dropdownMenu/context.js +3 -0
  94. package/dist/dropdownMenu/dropdownMenu.d.ts +70 -0
  95. package/dist/dropdownMenu/dropdownMenu.js +109 -0
  96. package/dist/dropdownMenu/index.d.ts +2 -0
  97. package/dist/dropdownMenu/index.js +1 -0
  98. package/dist/dropdownMenu/item.d.ts +140 -0
  99. package/dist/dropdownMenu/item.js +142 -0
  100. package/dist/dropdownMenu/list.d.ts +85 -0
  101. package/dist/dropdownMenu/list.js +429 -0
  102. package/dist/dropdownMenu/search.d.ts +16 -0
  103. package/dist/dropdownMenu/search.js +16 -0
  104. package/dist/dropdownMenu/section.d.ts +21 -0
  105. package/dist/dropdownMenu/section.js +40 -0
  106. package/dist/dropdownMenu/separator.d.ts +7 -0
  107. package/dist/dropdownMenu/separator.js +15 -0
  108. package/dist/dropdownMenu/useDropdownMenuKeyboard.d.ts +24 -0
  109. package/dist/dropdownMenu/useDropdownMenuKeyboard.js +31 -0
  110. package/dist/dropdownMenu/useDropdownMenuRowLayout.d.ts +29 -0
  111. package/dist/dropdownMenu/useDropdownMenuRowLayout.js +64 -0
  112. package/dist/dropdownMenu/useDropdownRootMenuState.d.ts +13 -0
  113. package/dist/dropdownMenu/useDropdownRootMenuState.js +30 -0
  114. package/dist/dropdownMenu/useDropdownSubmenuState.d.ts +19 -0
  115. package/dist/dropdownMenu/useDropdownSubmenuState.js +25 -0
  116. package/dist/dropdownMenu/utils.d.ts +21 -0
  117. package/dist/dropdownMenu/utils.js +55 -0
  118. package/dist/duration/formatElapsedDuration.d.ts +4 -0
  119. package/dist/duration/formatElapsedDuration.js +10 -0
  120. package/dist/duration/getDuration.d.ts +68 -0
  121. package/dist/duration/getDuration.js +80 -0
  122. package/dist/duration/index.d.ts +2 -0
  123. package/dist/duration/index.js +2 -0
  124. package/dist/form/FormSearch.d.ts +19 -0
  125. package/dist/form/FormSearch.js +4 -0
  126. package/dist/form/autoSaveForm.d.ts +110 -0
  127. package/dist/form/autoSaveForm.js +100 -0
  128. package/dist/{formPresentation → form}/displayField.js +2 -2
  129. package/dist/form/field/baseField.d.ts +23 -0
  130. package/dist/form/field/baseField.js +116 -0
  131. package/dist/form/field/checkboxField.d.ts +11 -0
  132. package/dist/form/field/checkboxField.js +42 -0
  133. package/dist/form/field/checkboxGroupField.d.ts +16 -0
  134. package/dist/form/field/checkboxGroupField.js +80 -0
  135. package/dist/form/field/compactSelectField.d.ts +19 -0
  136. package/dist/form/field/compactSelectField.js +77 -0
  137. package/dist/{formPresentation → form/field}/fieldIds.js +1 -1
  138. package/dist/form/field/inputField.d.ts +19 -0
  139. package/dist/form/field/inputField.js +31 -0
  140. package/dist/{formPresentation → form/field}/meta.js +6 -6
  141. package/dist/form/field/numberField.d.ts +5 -0
  142. package/dist/form/field/numberField.js +11 -0
  143. package/dist/form/field/passwordField.d.ts +3 -0
  144. package/dist/form/field/passwordField.js +27 -0
  145. package/dist/form/field/radioGroupField.d.ts +16 -0
  146. package/dist/form/field/radioGroupField.js +92 -0
  147. package/dist/form/field/rangeField.d.ts +8 -0
  148. package/dist/form/field/rangeField.js +34 -0
  149. package/dist/form/field/selectAsyncField.d.ts +31 -0
  150. package/dist/form/field/selectAsyncField.js +22 -0
  151. package/dist/form/field/selectField.d.ts +9 -0
  152. package/dist/form/field/selectField.js +72 -0
  153. package/dist/form/field/switchField.d.ts +7 -0
  154. package/dist/form/field/switchField.js +37 -0
  155. package/dist/form/field/textAreaField.d.ts +7 -0
  156. package/dist/form/field/textAreaField.js +25 -0
  157. package/dist/{formPresentation → form}/formContext.js +1 -1
  158. package/dist/form/formErrorContext/index.d.ts +9 -0
  159. package/dist/form/formErrorContext/index.js +7 -0
  160. package/dist/form/index.d.ts +9 -0
  161. package/dist/form/index.js +8 -0
  162. package/dist/{formPresentation → form/layout}/base.d.ts +1 -1
  163. package/dist/{formPresentation → form/layout}/base.js +1 -1
  164. package/dist/form/layout/fieldGroup.d.ts +6 -0
  165. package/dist/form/layout/fieldGroup.js +60 -0
  166. package/dist/{formPresentation/fieldLayout.d.ts → form/layout/index.d.ts} +1 -1
  167. package/dist/{formPresentation/fieldLayout.js → form/layout/index.js} +3 -3
  168. package/dist/{formPresentation → form/layout}/useStackedLayout.js +1 -1
  169. package/dist/form/scrapsForm.d.ts +220 -0
  170. package/dist/form/scrapsForm.js +126 -0
  171. package/dist/fzf.d.ts +9 -0
  172. package/dist/fzf.js +155 -0
  173. package/dist/hotkey/hotkey.d.ts +9 -8
  174. package/dist/hotkey/hotkey.js +13 -6
  175. package/dist/hotkey/index.d.ts +2 -1
  176. package/dist/hotkey/index.js +2 -1
  177. package/dist/hotkey/keyMappings.d.ts +1 -15
  178. package/dist/hotkey/keyMappings.js +29 -174
  179. package/dist/hotkey/useHotkeys.d.ts +3 -47
  180. package/dist/hotkey/useHotkeys.js +8 -42
  181. package/dist/image/image.js +2 -1
  182. package/dist/info/infoTip.d.ts +1 -1
  183. package/dist/info/infoTip.js +4 -3
  184. package/dist/input/index.d.ts +0 -3
  185. package/dist/input/index.js +0 -2
  186. package/dist/input/input.d.ts +2 -0
  187. package/dist/input/input.js +2 -0
  188. package/dist/input/passwordManagerIgnoreProps.d.ts +11 -0
  189. package/dist/input/passwordManagerIgnoreProps.js +8 -0
  190. package/dist/layout/container.d.ts +8 -2
  191. package/dist/layout/container.js +2 -2
  192. package/dist/layout/index.d.ts +2 -2
  193. package/dist/layout/index.js +1 -1
  194. package/dist/layout/styles.d.ts +2 -1
  195. package/dist/layout/styles.js +11 -5
  196. package/dist/legacyDatetime.d.ts +21 -0
  197. package/dist/legacyDatetime.js +13 -0
  198. package/dist/link/index.d.ts +1 -1
  199. package/dist/link/index.js +1 -1
  200. package/dist/link/link.js +4 -3
  201. package/dist/link/linkBehaviorContext.d.ts +11 -0
  202. package/dist/link/linkBehaviorContext.js +48 -11
  203. package/dist/menu/index.d.ts +1 -1
  204. package/dist/menu/index.js +1 -1
  205. package/dist/menu/menu.d.ts +14 -8
  206. package/dist/menu/menu.js +163 -60
  207. package/dist/modal/components.d.ts +19 -0
  208. package/dist/modal/components.js +99 -0
  209. package/dist/modal/errorBoundary.d.ts +2 -0
  210. package/dist/modal/errorBoundary.js +35 -0
  211. package/dist/modal/index.d.ts +33 -0
  212. package/dist/modal/index.js +260 -0
  213. package/dist/modal/portal.d.ts +1 -0
  214. package/dist/modal/portal.js +10 -0
  215. package/dist/modal/state.d.ts +17 -0
  216. package/dist/modal/state.js +41 -0
  217. package/dist/modal/types.d.ts +75 -0
  218. package/dist/modal/types.js +0 -0
  219. package/dist/numberInput/index.d.ts +3 -0
  220. package/dist/numberInput/index.js +2 -0
  221. package/dist/{input → numberInput}/numberDragInput.d.ts +1 -1
  222. package/dist/{input → numberInput}/numberDragInput.js +1 -1
  223. package/dist/{input → numberInput}/numberInput.d.ts +1 -1
  224. package/dist/{input → numberInput}/numberInput.js +1 -1
  225. package/dist/overlayContext.d.ts +29 -0
  226. package/dist/overlayContext.js +7 -0
  227. package/dist/pagination/index.d.ts +1 -0
  228. package/dist/pagination/index.js +1 -0
  229. package/dist/pagination/pagination.d.ts +24 -0
  230. package/dist/pagination/pagination.js +63 -0
  231. package/dist/pictureInPicture/index.d.ts +2 -0
  232. package/dist/pictureInPicture/index.js +2 -0
  233. package/dist/pictureInPicture/pictureInPicture.d.ts +47 -0
  234. package/dist/pictureInPicture/pictureInPicture.js +100 -0
  235. package/dist/pictureInPicture/pictureInPicturePortal.d.ts +16 -0
  236. package/dist/pictureInPicture/pictureInPicturePortal.js +46 -0
  237. package/dist/pictureInPicture/portalContext.d.ts +2 -0
  238. package/dist/pictureInPicture/portalContext.js +3 -0
  239. package/dist/relativeTime/getRelativeDate.d.ts +14 -0
  240. package/dist/relativeTime/getRelativeDate.js +107 -0
  241. package/dist/relativeTime/index.d.ts +3 -0
  242. package/dist/relativeTime/index.js +3 -0
  243. package/dist/relativeTime/relativeTime.d.ts +55 -0
  244. package/dist/relativeTime/relativeTime.js +102 -0
  245. package/dist/relativeTime/useRelativeTimeFormatter.d.ts +2 -0
  246. package/dist/relativeTime/useRelativeTimeFormatter.js +10 -0
  247. package/dist/revealOnHover/revealOnHover.js +1 -1
  248. package/dist/segmentedControl/segmentedControl.js +1 -1
  249. package/dist/select/filter.d.ts +4 -0
  250. package/dist/select/filter.js +12 -0
  251. package/dist/select/index.d.ts +3 -0
  252. package/dist/select/index.js +2 -0
  253. package/dist/select/option.d.ts +16 -0
  254. package/dist/select/option.js +81 -0
  255. package/dist/select/reactSelectWrapper.d.ts +8 -0
  256. package/dist/select/reactSelectWrapper.js +25 -0
  257. package/dist/select/select.d.ts +79 -0
  258. package/dist/select/select.js +454 -0
  259. package/dist/select/styles.d.ts +9 -0
  260. package/dist/select/styles.js +27 -0
  261. package/dist/select/types.d.ts +60 -0
  262. package/dist/select/types.js +0 -0
  263. package/dist/select/virtualizedMenuList.d.ts +24 -0
  264. package/dist/select/virtualizedMenuList.js +123 -0
  265. package/dist/slideOverPanel.d.ts +20 -0
  266. package/dist/slideOverPanel.js +141 -0
  267. package/dist/splitPanel/splitPanel.d.ts +3 -1
  268. package/dist/splitPanel/splitPanel.js +2 -1
  269. package/dist/table/table.d.ts +1 -1
  270. package/dist/table/table.js +39 -20
  271. package/dist/table/useColumnResize.d.ts +6 -5
  272. package/dist/table/useColumnResize.js +5 -4
  273. package/dist/tabs/context.d.ts +9 -0
  274. package/dist/tabs/context.js +9 -0
  275. package/dist/tabs/index.d.ts +2 -0
  276. package/dist/tabs/index.js +1 -0
  277. package/dist/tabs/item.d.ts +24 -0
  278. package/dist/tabs/item.js +4 -0
  279. package/dist/tabs/tab.d.ts +22 -0
  280. package/dist/tabs/tab.js +208 -0
  281. package/dist/tabs/tabList.d.ts +18 -0
  282. package/dist/tabs/tabList.js +258 -0
  283. package/dist/tabs/tabPanels.d.ts +13 -0
  284. package/dist/tabs/tabPanels.js +62 -0
  285. package/dist/tabs/tabs.d.ts +53 -0
  286. package/dist/tabs/tabs.js +59 -0
  287. package/dist/tabs/utils.d.ts +3 -0
  288. package/dist/tabs/utils.js +6 -0
  289. package/dist/text/heading.d.ts +1 -1
  290. package/dist/text/heading.js +1 -1
  291. package/dist/text/prose.d.ts +2 -2
  292. package/dist/text/styles.js +1 -1
  293. package/dist/text/text.d.ts +1 -1
  294. package/dist/text/text.js +1 -1
  295. package/dist/theme/dark.js +9 -9
  296. package/dist/theme/light.js +9 -9
  297. package/dist/theme/theme.d.ts +34 -34
  298. package/dist/theme/theme.js +9 -0
  299. package/dist/theme/types.d.ts +20 -2
  300. package/dist/tooltip/tooltip.js +2 -5
  301. package/dist/translation/index.d.ts +1 -0
  302. package/dist/translation/index.js +1 -0
  303. package/dist/translation/translate.d.ts +9 -0
  304. package/dist/translation/translate.js +5 -0
  305. package/dist/translation/translationContext.d.ts +2 -1
  306. package/dist/translation/translationContext.js +2 -1
  307. package/dist/useMedia.d.ts +15 -0
  308. package/dist/useMedia.js +24 -0
  309. package/dist/useOnClickOutside.d.ts +2 -0
  310. package/dist/useOnClickOutside.js +22 -0
  311. package/dist/useOverlay.d.ts +1 -0
  312. package/dist/useOverlay.js +1 -0
  313. package/dist/useVirtualCollection.d.ts +154 -0
  314. package/dist/useVirtualCollection.js +143 -0
  315. package/dist/useVirtualRows.d.ts +26 -0
  316. package/dist/useVirtualRows.js +26 -0
  317. package/dist/virtualCollectionLayout.d.ts +51 -0
  318. package/dist/virtualCollectionLayout.js +49 -0
  319. package/fonts/OFL.txt +94 -0
  320. package/fonts/roboto-mono-variable-cyrillic-ext.woff2 +0 -0
  321. package/fonts/roboto-mono-variable-cyrillic.woff2 +0 -0
  322. package/fonts/roboto-mono-variable-greek.woff2 +0 -0
  323. package/fonts/roboto-mono-variable-latin-ext.woff2 +0 -0
  324. package/fonts/roboto-mono-variable-vietnamese.woff2 +0 -0
  325. package/fonts/roboto-mono-variable.woff2 +0 -0
  326. package/fonts/rubik-variable-cyrillic-ext.woff2 +0 -0
  327. package/fonts/rubik-variable-cyrillic.woff2 +0 -0
  328. package/fonts/rubik-variable-latin-ext.woff2 +0 -0
  329. package/fonts/rubik-variable.woff2 +0 -0
  330. package/fonts.css +211 -0
  331. package/package.json +140 -23
  332. package/dist/datetime.d.ts +0 -39
  333. package/dist/datetime.js +0 -20
  334. package/dist/formPresentation/index.d.ts +0 -8
  335. package/dist/formPresentation/index.js +0 -8
  336. package/dist/interactionStateLayer/index.d.ts +0 -1
  337. package/dist/interactionStateLayer/index.js +0 -1
  338. package/dist/interactionStateLayer/interactionStateLayer.d.ts +0 -23
  339. package/dist/interactionStateLayer/interactionStateLayer.js +0 -67
  340. package/dist/unreachable.d.ts +0 -1
  341. package/dist/unreachable.js +0 -4
  342. /package/dist/{formPresentation → form}/autoSaveContext.d.ts +0 -0
  343. /package/dist/{formPresentation → form}/autoSaveContext.js +0 -0
  344. /package/dist/{formPresentation → form}/displayField.d.ts +0 -0
  345. /package/dist/{formPresentation → form/field}/fieldIds.d.ts +0 -0
  346. /package/dist/{formPresentation → form/field}/groupContext.d.ts +0 -0
  347. /package/dist/{formPresentation → form/field}/groupContext.js +0 -0
  348. /package/dist/{formPresentation → form/field}/meta.d.ts +0 -0
  349. /package/dist/{formPresentation → form}/formContext.d.ts +0 -0
  350. /package/dist/{formPresentation → form}/icons.d.ts +0 -0
  351. /package/dist/{formPresentation → form}/icons.js +0 -0
  352. /package/dist/{formPresentation → form/layout}/useStackedLayout.d.ts +0 -0
@@ -0,0 +1,64 @@
1
+ import { useCallback, useLayoutEffect, useMemo } from "react";
2
+ import { useTheme } from "@emotion/react";
3
+ import { SECTION_ITEM_SPACE } from "../menu/index.js";
4
+ import { estimateRowHeight, useVirtualCollection } from "../useVirtualCollection.js";
5
+ import { SEPARATOR_HEIGHT } from "./separator.js";
6
+ function useDropdownMenuRowLayout({ collection, focusedKey, isWidthLocked, menuRef, onLockWidth, size, virtualized, widestKey }) {
7
+ const theme = useTheme();
8
+ const sectionRowSpace = parseFloat(theme.space[SECTION_ITEM_SPACE]);
9
+ const itemsAfterSections = useMemo(()=>new Set(collection.filter((_, index)=>collection[index - 1]?.type === 'section').map((node)=>node.key)), [
10
+ collection
11
+ ]);
12
+ const sectionsByKey = useMemo(()=>new Map(collection.filter((node)=>'section' === node.type).map((node)=>[
13
+ node.key,
14
+ node
15
+ ])), [
16
+ collection
17
+ ]);
18
+ const estimateSize = useCallback((node)=>{
19
+ if ('section' === node.type) {
20
+ const separator = node.key === collection[0]?.key ? 0 : SEPARATOR_HEIGHT;
21
+ const heading = node.rendered ? estimateRowHeight(node, void 0, size, sectionRowSpace) : 0;
22
+ return separator + heading;
23
+ }
24
+ const section = null === node.parentKey || void 0 === node.parentKey ? void 0 : sectionsByKey.get(node.parentKey);
25
+ const height = estimateRowHeight(node, section, size, sectionRowSpace);
26
+ return itemsAfterSections.has(node.key) ? height + SEPARATOR_HEIGHT : height;
27
+ }, [
28
+ collection,
29
+ itemsAfterSections,
30
+ sectionsByKey,
31
+ size,
32
+ sectionRowSpace
33
+ ]);
34
+ const virtual = useVirtualCollection({
35
+ collection,
36
+ enabled: virtualized,
37
+ estimateSize,
38
+ scrollRef: menuRef,
39
+ focusedKey,
40
+ sectionRowSpace,
41
+ size,
42
+ widestKey
43
+ });
44
+ const isWidestRowMounted = virtual.rows.some((row)=>row.node.key === widestKey);
45
+ useLayoutEffect(()=>{
46
+ const menu = menuRef.current;
47
+ if (!virtualized || !isWidestRowMounted || isWidthLocked || !menu) return;
48
+ const { width } = menu.style;
49
+ menu.style.width = 'max-content';
50
+ onLockWidth(Math.ceil(menu.getBoundingClientRect().width));
51
+ menu.style.width = width;
52
+ }, [
53
+ virtualized,
54
+ isWidestRowMounted,
55
+ isWidthLocked,
56
+ menuRef,
57
+ onLockWidth
58
+ ]);
59
+ return {
60
+ itemsAfterSections,
61
+ virtual
62
+ };
63
+ }
64
+ export { useDropdownMenuRowLayout };
@@ -0,0 +1,13 @@
1
+ import type { RootMenuTriggerState } from '@react-stately/menu';
2
+ import type { OverlayTriggerState } from '@react-stately/overlays';
3
+ /**
4
+ * State for the root menu, matching react-stately's `useMenuTriggerState`.
5
+ *
6
+ * `useOverlay` keeps owning the open state and positioning, so this wraps its
7
+ * overlay state instead of creating another one, and adds the stack of open
8
+ * submenus that `useSubmenuTrigger` reads.
9
+ *
10
+ * A root menu rendered inside another menu starts its own tree, but closing
11
+ * it, for example by selecting one of its items, also closes the outer menu.
12
+ */
13
+ export declare function useDropdownRootMenuState(overlayState: OverlayTriggerState, parentMenuState?: RootMenuTriggerState): RootMenuTriggerState;
@@ -0,0 +1,30 @@
1
+ import { useState } from "react";
2
+ function useDropdownRootMenuState(overlayState, parentMenuState) {
3
+ const [expandedKeysStack, setExpandedKeysStack] = useState([]);
4
+ const [wasOpen, setWasOpen] = useState(overlayState.isOpen);
5
+ if (wasOpen !== overlayState.isOpen) {
6
+ setWasOpen(overlayState.isOpen);
7
+ if (!overlayState.isOpen) setExpandedKeysStack([]);
8
+ }
9
+ const { isOpen, setOpen, open, close, toggle } = overlayState;
10
+ const closeParentMenu = parentMenuState?.close;
11
+ return {
12
+ isOpen,
13
+ setOpen,
14
+ focusStrategy: 'first',
15
+ open: ()=>open(),
16
+ toggle: ()=>toggle(),
17
+ close: ()=>{
18
+ setExpandedKeysStack([]);
19
+ close();
20
+ closeParentMenu?.();
21
+ },
22
+ expandedKeysStack,
23
+ openSubmenu: (triggerKey, level)=>setExpandedKeysStack((stack)=>level > stack.length ? stack : [
24
+ ...stack.slice(0, level),
25
+ triggerKey
26
+ ]),
27
+ closeSubmenu: (triggerKey, level)=>setExpandedKeysStack((stack)=>stack[level] === triggerKey ? stack.slice(0, level) : stack)
28
+ };
29
+ }
30
+ export { useDropdownRootMenuState };
@@ -0,0 +1,19 @@
1
+ import type { RootMenuTriggerState, SubmenuTriggerState } from '@react-stately/menu';
2
+ import type { Key } from '@react-types/shared';
3
+ interface UseDropdownSubmenuStateOptions {
4
+ /** How deep the submenu sits in the menu tree, starting at 0. */
5
+ level: number;
6
+ rootMenuState: RootMenuTriggerState;
7
+ /** Key of the item that opens the submenu. */
8
+ triggerKey: Key;
9
+ }
10
+ /**
11
+ * State for a submenu trigger, matching react-stately's `useSubmenuTriggerState`.
12
+ *
13
+ * react-stately takes the submenu level from the number of open submenus when
14
+ * the trigger mounts. A virtualized menu mounts triggers as they scroll into
15
+ * view, possibly while a sibling submenu is open, which would place the
16
+ * trigger one level too deep. The level comes from the menu tree instead.
17
+ */
18
+ export declare function useDropdownSubmenuState({ level, rootMenuState, triggerKey, }: UseDropdownSubmenuStateOptions): SubmenuTriggerState;
19
+ export {};
@@ -0,0 +1,25 @@
1
+ import { useState } from "react";
2
+ function useDropdownSubmenuState({ level, rootMenuState, triggerKey }) {
3
+ const { expandedKeysStack, openSubmenu, closeSubmenu, close: closeAll } = rootMenuState;
4
+ const isOpen = expandedKeysStack[level] === triggerKey;
5
+ const [focusStrategy, setFocusStrategy] = useState(null);
6
+ const open = (strategy)=>{
7
+ setFocusStrategy(strategy ?? null);
8
+ openSubmenu(triggerKey, level);
9
+ };
10
+ const close = ()=>{
11
+ setFocusStrategy(null);
12
+ closeSubmenu(triggerKey, level);
13
+ };
14
+ return {
15
+ focusStrategy,
16
+ isOpen,
17
+ open,
18
+ close,
19
+ closeAll,
20
+ submenuLevel: level,
21
+ setOpen: ()=>{},
22
+ toggle: (strategy)=>isOpen ? close() : open(strategy)
23
+ };
24
+ }
25
+ export { useDropdownSubmenuState };
@@ -0,0 +1,21 @@
1
+ import type { useResolveLinkHref } from '../link/linkBehaviorContext.js';
2
+ import type { MenuItemProps } from './item.js';
3
+ /**
4
+ * Recursively removes hidden items, including those nested in submenus
5
+ * Apply href to items that have a to or externalHref prop
6
+ */
7
+ export declare function removeHiddenItemsAndSetHref(source: MenuItemProps[], resolveHref: ReturnType<typeof useResolveLinkHref>): MenuItemProps[];
8
+ /** Items with children render as a section, unless they open a submenu. */
9
+ export declare function isMenuSection(item: MenuItemProps): boolean;
10
+ export declare function filterMenuItems(items: MenuItemProps[], search: string): MenuItemProps[];
11
+ /**
12
+ * Number of items a menu lists, counting the items inside sections but not
13
+ * the sections themselves. Matches the count `DropdownMenuList` virtualizes by.
14
+ */
15
+ export declare function countMenuItems(items: MenuItemProps[]): number;
16
+ /** The key of the menu item an event fired on, if it fired on one. */
17
+ export declare function getMenuItemKey(target: EventTarget | null): string | undefined;
18
+ /**
19
+ * Recursively finds and returns disabled items
20
+ */
21
+ export declare function getDisabledKeys(source: MenuItemProps[]): Array<MenuItemProps['key']>;
@@ -0,0 +1,55 @@
1
+ import { getSearchScore } from "../fzf.js";
2
+ function removeHiddenItemsAndSetHref(source, resolveHref) {
3
+ return source.filter((item)=>!item.hidden).map((item)=>{
4
+ const href = item.to ? resolveHref(item.to) : item.externalHref;
5
+ return {
6
+ ...item,
7
+ ...void 0 === href ? {} : {
8
+ href
9
+ },
10
+ ...item.children ? {
11
+ children: removeHiddenItemsAndSetHref(item.children, resolveHref)
12
+ } : {}
13
+ };
14
+ });
15
+ }
16
+ function isMenuSection(item) {
17
+ return Boolean(item.children && item.children.length > 0 && !item.submenu);
18
+ }
19
+ function filterMenuItems(items, search) {
20
+ const query = search.trim();
21
+ if (!query) return items;
22
+ return items.flatMap((item)=>{
23
+ if (item.children && !item.submenu) {
24
+ const children = filterMenuItems(item.children, query);
25
+ return children.length > 0 ? [
26
+ {
27
+ ...item,
28
+ children
29
+ }
30
+ ] : [];
31
+ }
32
+ const text = item.textValue ?? ('string' == typeof item.label ? item.label : '');
33
+ return getSearchScore(text, query) > 0 ? [
34
+ item
35
+ ] : [];
36
+ });
37
+ }
38
+ function countMenuItems(items) {
39
+ return items.reduce((count, item)=>count + (isMenuSection(item) ? item.children?.length ?? 0 : 1), 0);
40
+ }
41
+ function getMenuItemKey(target) {
42
+ if (!(target instanceof HTMLElement) || !target.getAttribute('role')?.startsWith('menuitem')) return;
43
+ return target.dataset.key;
44
+ }
45
+ function getDisabledKeys(source) {
46
+ return source.reduce((acc, cur)=>{
47
+ if (cur.disabled) {
48
+ acc.push(cur.key);
49
+ return acc;
50
+ }
51
+ if (cur.children) return acc.concat(getDisabledKeys(cur.children));
52
+ return acc;
53
+ }, []);
54
+ }
55
+ export { countMenuItems, filterMenuItems, getDisabledKeys, getMenuItemKey, isMenuSection, removeHiddenItemsAndSetHref };
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Formats elapsed ms as "5.3s" under a minute, else "1m 30s" or "1h 2m 3s".
3
+ */
4
+ export declare function formatElapsedDuration(ms: number): string;
@@ -0,0 +1,10 @@
1
+ function formatElapsedDuration(ms) {
2
+ const tenths = Math.floor(ms / 100);
3
+ if (tenths < 600) return `${(tenths / 10).toFixed(1)}s`;
4
+ const totalSeconds = Math.floor(ms / 1000);
5
+ const hours = Math.floor(totalSeconds / 3600);
6
+ const minutes = Math.floor(totalSeconds % 3600 / 60);
7
+ const seconds = totalSeconds % 60;
8
+ return hours > 0 ? `${hours}h ${minutes}m ${seconds}s` : `${minutes}m ${seconds}s`;
9
+ }
10
+ export { formatElapsedDuration };
@@ -0,0 +1,68 @@
1
+ import type { Translation } from '../translation/translate.js';
2
+ export interface DurationOptions {
3
+ absolute?: boolean;
4
+ /** Smallest display unit. Defaults to milliseconds. */
5
+ minimumUnit?: DurationUnit;
6
+ precision?: number;
7
+ style?: 'long' | 'short' | 'narrow';
8
+ }
9
+ declare const units: readonly [{
10
+ readonly unit: "year";
11
+ readonly size: 31536000000;
12
+ readonly long: (count: number, { tn }: Translation) => string;
13
+ readonly short: ({ t }: Translation) => string;
14
+ readonly narrow: ({ t }: Translation) => string;
15
+ }, {
16
+ readonly unit: "month";
17
+ readonly size: 2629800000;
18
+ readonly long: (count: number, { tn }: Translation) => string;
19
+ readonly short: ({ t }: Translation) => string;
20
+ readonly narrow: ({ pgettext }: Translation) => string;
21
+ }, {
22
+ readonly unit: "week";
23
+ readonly size: 604800000;
24
+ readonly long: (count: number, { tn }: Translation) => string;
25
+ readonly short: ({ t }: Translation) => string;
26
+ readonly narrow: ({ t }: Translation) => string;
27
+ }, {
28
+ readonly unit: "day";
29
+ readonly size: 86400000;
30
+ readonly long: (count: number, { tn }: Translation) => string;
31
+ readonly short: ({ t }: Translation) => string;
32
+ readonly narrow: ({ t }: Translation) => string;
33
+ }, {
34
+ readonly unit: "hour";
35
+ readonly size: 3600000;
36
+ readonly long: (count: number, { tn }: Translation) => string;
37
+ readonly short: ({ t }: Translation) => string;
38
+ readonly narrow: ({ t }: Translation) => string;
39
+ }, {
40
+ readonly unit: "minute";
41
+ readonly size: 60000;
42
+ readonly long: (count: number, { tn }: Translation) => string;
43
+ readonly short: ({ t }: Translation) => string;
44
+ readonly narrow: ({ pgettext }: Translation) => string;
45
+ }, {
46
+ readonly unit: "second";
47
+ readonly size: 1000;
48
+ readonly long: (count: number, { tn }: Translation) => string;
49
+ readonly short: ({ t }: Translation) => string;
50
+ readonly narrow: ({ t }: Translation) => string;
51
+ }, {
52
+ readonly unit: "millisecond";
53
+ readonly size: 1;
54
+ readonly long: (count: number, { tn }: Translation) => string;
55
+ readonly short: ({ t }: Translation) => string;
56
+ readonly narrow: ({ t }: Translation) => string;
57
+ }, {
58
+ readonly unit: "microsecond";
59
+ readonly size: 0.001;
60
+ readonly long: (count: number, { tn }: Translation) => string;
61
+ readonly short: () => string;
62
+ readonly narrow: () => string;
63
+ }];
64
+ export type DurationUnit = (typeof units)[number]['unit'];
65
+ /** Format seconds using the shared application translations. */
66
+ export declare function getDuration(seconds: number, options?: DurationOptions): string;
67
+ export declare function getDurationWithMessages(seconds: number, { precision, style, absolute, minimumUnit, }: DurationOptions, messages: Translation): string;
68
+ export {};
@@ -0,0 +1,80 @@
1
+ import { getSnapshot } from "../dateTime/config.js";
2
+ const units = [
3
+ {
4
+ unit: 'year',
5
+ size: 31536000000,
6
+ long: (count, { tn })=>tn('year', 'years', count),
7
+ short: ({ t })=>t('yr'),
8
+ narrow: ({ t })=>t('y')
9
+ },
10
+ {
11
+ unit: 'month',
12
+ size: 2629800000,
13
+ long: (count, { tn })=>tn('month', 'months', count),
14
+ short: ({ t })=>t('mo'),
15
+ narrow: ({ pgettext })=>pgettext('abbreviated months', 'm')
16
+ },
17
+ {
18
+ unit: 'week',
19
+ size: 604800000,
20
+ long: (count, { tn })=>tn('week', 'weeks', count),
21
+ short: ({ t })=>t('wk'),
22
+ narrow: ({ t })=>t('w')
23
+ },
24
+ {
25
+ unit: 'day',
26
+ size: 86400000,
27
+ long: (count, { tn })=>tn('day', 'days', count),
28
+ short: ({ t })=>t('d'),
29
+ narrow: ({ t })=>t('d')
30
+ },
31
+ {
32
+ unit: 'hour',
33
+ size: 3600000,
34
+ long: (count, { tn })=>tn('hour', 'hours', count),
35
+ short: ({ t })=>t('hr'),
36
+ narrow: ({ t })=>t('h')
37
+ },
38
+ {
39
+ unit: 'minute',
40
+ size: 60000,
41
+ long: (count, { tn })=>tn('minute', 'minutes', count),
42
+ short: ({ t })=>t('min'),
43
+ narrow: ({ pgettext })=>pgettext('abbreviated minutes', 'm')
44
+ },
45
+ {
46
+ unit: 'second',
47
+ size: 1000,
48
+ long: (count, { tn })=>tn('second', 'seconds', count),
49
+ short: ({ t })=>t('s'),
50
+ narrow: ({ t })=>t('s')
51
+ },
52
+ {
53
+ unit: 'millisecond',
54
+ size: 1,
55
+ long: (count, { tn })=>tn('millisecond', 'milliseconds', count),
56
+ short: ({ t })=>t('ms'),
57
+ narrow: ({ t })=>t('ms')
58
+ },
59
+ {
60
+ unit: 'microsecond',
61
+ size: 0.001,
62
+ long: (count, { tn })=>tn('microsecond', 'microseconds', count),
63
+ short: ()=>'μs',
64
+ narrow: ()=>'μs'
65
+ }
66
+ ];
67
+ function getDuration(seconds, options = {}) {
68
+ return getDurationWithMessages(seconds, options, getSnapshot().messages);
69
+ }
70
+ function getDurationWithMessages(seconds, { precision = 0, style = 'long', absolute = false, minimumUnit = 'millisecond' }, messages) {
71
+ const milliseconds = 1000 * seconds;
72
+ const magnitude = Math.abs(milliseconds);
73
+ const unit = units.find(({ size, unit })=>magnitude >= size || minimumUnit === unit) ?? units[8];
74
+ const value = (absolute ? magnitude : milliseconds) / unit.size;
75
+ const label = value.toFixed(precision);
76
+ if ('long' !== style) return `${label}${unit[style](messages)}`;
77
+ const count = precision <= 0 ? Math.round(value) : value;
78
+ return `${label} ${unit.long(count, messages)}`;
79
+ }
80
+ export { getDuration, getDurationWithMessages };
@@ -0,0 +1,2 @@
1
+ export { getDuration, type DurationOptions, type DurationUnit } from './getDuration.js';
2
+ export { formatElapsedDuration } from './formatElapsedDuration.js';
@@ -0,0 +1,2 @@
1
+ export { getDuration } from "./getDuration.js";
2
+ export { formatElapsedDuration } from "./formatElapsedDuration.js";
@@ -0,0 +1,19 @@
1
+ import type { ReactNode } from 'react';
2
+ interface FormSearchProps {
3
+ children: ReactNode;
4
+ /**
5
+ * Route pattern for settings search (e.g., '/settings/account/details/').
6
+ * This prop is used by the static extraction script to associate
7
+ * form fields with their navigation route. It has no runtime effect.
8
+ */
9
+ route: string;
10
+ }
11
+ /**
12
+ * Wrapper component that marks form fields as searchable in settings search.
13
+ * The `route` prop is extracted at build time by scripts/extractFormFields.ts
14
+ * to generate the form field registry used for search.
15
+ *
16
+ * This component has no runtime behavior - it simply renders its children.
17
+ */
18
+ export declare function FormSearch({ children }: FormSearchProps): ReactNode;
19
+ export {};
@@ -0,0 +1,4 @@
1
+ function FormSearch({ children }) {
2
+ return children;
3
+ }
4
+ export { FormSearch };
@@ -0,0 +1,110 @@
1
+ import type * as React from 'react';
2
+ import type { DeepKeys, DeepValue, FieldApi } from '@tanstack/react-form';
3
+ import { type UseMutationOptions } from '@tanstack/react-query';
4
+ import { type z } from 'zod';
5
+ import { type BoundFieldComponents } from './scrapsForm.js';
6
+ /**
7
+ * Configuration for confirmation dialogs before applying changes.
8
+ * Used for dangerous operations like security settings.
9
+ * Always focuses the Cancel button for safety.
10
+ *
11
+ * @example
12
+ * // Simple string - always show this message
13
+ * confirm="Are you sure you want to save?"
14
+ *
15
+ * @example
16
+ * // Function - return message based on new value, or undefined to skip
17
+ * confirm={(value) => value ? "Enable this feature?" : "Disable this feature?"}
18
+ */
19
+ type ConfirmConfig<TValue = unknown> = React.ReactNode | ((value: TValue) => React.ReactNode | undefined);
20
+ type SchemaInput<TSchema extends z.ZodObject> = z.input<TSchema>;
21
+ type SchemaOutput<TSchema extends z.ZodObject> = z.output<TSchema>;
22
+ /** Form data type coming from the schema input */
23
+ type SchemaFieldName<TSchema extends z.ZodObject> = Extract<DeepKeys<SchemaInput<TSchema>>, string>;
24
+ /** FieldApi’s TData must be DeepValue<TParentData, TName> */
25
+ type SchemaFieldInputValue<TSchema extends z.ZodObject, TFieldName extends SchemaFieldName<TSchema>> = DeepValue<SchemaInput<TSchema>, TFieldName>;
26
+ type AutoSaveFormRenderArg<TSchema extends z.ZodObject, TFieldName extends SchemaFieldName<TSchema>> = FieldApi<SchemaInput<TSchema>, TFieldName, SchemaFieldInputValue<TSchema, TFieldName>, undefined, // TOnMount
27
+ undefined, // TOnChange
28
+ undefined, // TOnChangeAsync
29
+ undefined, // TOnBlur
30
+ undefined, // TOnBlurAsync
31
+ undefined, // TOnSubmit
32
+ undefined, // TOnSubmitAsync
33
+ undefined, // TOnDynamic
34
+ undefined, // TOnDynamicAsync
35
+ undefined, // TFormOnMount
36
+ undefined, // TFormOnChange
37
+ undefined, // TFormOnChangeAsync
38
+ undefined, // TFormOnBlur
39
+ undefined, // TFormOnBlurAsync
40
+ undefined, // TFormOnSubmit
41
+ undefined, // TFormOnSubmitAsync
42
+ undefined, // TFormOnDynamic
43
+ undefined, // TFormOnDynamicAsync
44
+ undefined, // TFormOnServer
45
+ unknown> & {
46
+ [K in keyof BoundFieldComponents]: BoundFieldComponents[K];
47
+ };
48
+ /**
49
+ * A component that provides field props and mutation state via render prop.
50
+ *
51
+ * @example
52
+ * <AutoSaveForm
53
+ * name="lastName"
54
+ * schema={baseUserSchema}
55
+ * initialValue={user.data?.lastName ?? ''}
56
+ * mutationOptions={{
57
+ * mutationFn: async (data) => api.patch('/user', data),
58
+ * }}
59
+ * >
60
+ * {field => (
61
+ * <InputField
62
+ * label="Last Name:"
63
+ * required
64
+ * value={field.state.value}
65
+ * onChange={field.handleChange}
66
+ * />
67
+ * )}
68
+ * </AutoSaveForm>
69
+ */
70
+ interface AutoSaveFormProps<TData, TContext, TSchema extends z.ZodObject, TFieldName extends Extract<keyof SchemaInput<TSchema>, string>> {
71
+ /**
72
+ * Render prop that receives field props and additional props
73
+ */
74
+ children: (field: AutoSaveFormRenderArg<TSchema, TFieldName>) => React.ReactElement | null;
75
+ /**
76
+ * Initial value - must match the schema's type for this field
77
+ */
78
+ initialValue: SchemaInput<TSchema>[TFieldName];
79
+ /**
80
+ * TanStack Query mutation options - mutationFn receives single-field data
81
+ */
82
+ mutationOptions: UseMutationOptions<TData, Error, NoInfer<Record<TFieldName, SchemaOutput<TSchema>[TFieldName]>>, TContext>;
83
+ /**
84
+ * Field name - must be a valid string key in the schema
85
+ */
86
+ name: TFieldName;
87
+ /**
88
+ * Zod schema for validation
89
+ */
90
+ schema: TSchema;
91
+ /**
92
+ * Optional confirmation dialog before saving.
93
+ * Shows a modal and requires user confirmation before applying changes.
94
+ *
95
+ * @example
96
+ * // Simple string - always show this message
97
+ * confirm="Are you sure you want to save this change?"
98
+ *
99
+ * @example
100
+ * // Function - return message based on new value, or undefined to skip
101
+ * confirm={(value) => value ? "Enable this feature?" : "Disable this feature?"}
102
+ *
103
+ * @example
104
+ * // Function with conditional confirmation
105
+ * confirm={(value) => value === 'dangerous' ? "This is irreversible!" : undefined}
106
+ */
107
+ confirm?: ConfirmConfig<SchemaInput<TSchema>[TFieldName]>;
108
+ }
109
+ export declare function AutoSaveForm<TData, TContext, TSchema extends z.ZodObject<z.ZodRawShape>, TFieldName extends Extract<keyof SchemaInput<TSchema>, string>>(props: AutoSaveFormProps<TData, TContext, TSchema, TFieldName>): import("@emotion/react/jsx-runtime").JSX.Element;
110
+ export {};
@@ -0,0 +1,100 @@
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { useId, useRef } from "react";
3
+ import { useMutation } from "@tanstack/react-query";
4
+ import { openConfirmModal } from "../confirm/index.js";
5
+ import { AutoSaveContextProvider } from "./autoSaveContext.js";
6
+ import { useFormErrorMapper } from "./formErrorContext/index.js";
7
+ import { setFieldErrors, useScrapsForm } from "./scrapsForm.js";
8
+ import { useTranslation } from "../translation/useTranslation.js";
9
+ function AutoSaveForm(props) {
10
+ const { name, schema, initialValue, mutationOptions, confirm, children } = props;
11
+ const { t } = useTranslation();
12
+ const mapFormError = useFormErrorMapper();
13
+ const id = useId();
14
+ const mutation = useMutation(mutationOptions);
15
+ const pendingConfirmRef = useRef(false);
16
+ const resetOnErrorRef = useRef(false);
17
+ const form = useScrapsForm({
18
+ formId: `${name}-${id}-(auto-save)`,
19
+ defaultValues: {
20
+ [name]: initialValue
21
+ },
22
+ validators: {
23
+ onChange: schema.pick({
24
+ [name]: true
25
+ })
26
+ },
27
+ listeners: {
28
+ onBlur: ({ formApi, fieldApi })=>{
29
+ if (!fieldApi.state.meta.isDefaultValue) formApi.handleSubmit();
30
+ }
31
+ },
32
+ onSubmit: ({ value, formApi })=>{
33
+ if ('pending' === mutation.status || pendingConfirmRef.current) return Promise.resolve();
34
+ const onError = (error)=>{
35
+ if (resetOnErrorRef.current) formApi.reset();
36
+ const fallbackMessage = t('Failed to save');
37
+ const mappedError = mapFormError(error, formApi.state.values, fallbackMessage);
38
+ if (mappedError && 'fieldErrors' in mappedError && setFieldErrors(formApi, mappedError.fieldErrors)) return;
39
+ setFieldErrors(formApi, {
40
+ [name]: {
41
+ message: mappedError && 'message' in mappedError ? mappedError.message : fallbackMessage
42
+ }
43
+ });
44
+ };
45
+ const onSuccess = ()=>{
46
+ formApi.reset();
47
+ };
48
+ const parsedValue = schema.pick({
49
+ [name]: true
50
+ }).safeParse(value);
51
+ if (!parsedValue.success) return Promise.resolve();
52
+ const submittedValue = parsedValue.data;
53
+ const fieldValue = value[name];
54
+ const confirmMessage = 'function' == typeof confirm ? confirm(fieldValue) : confirm;
55
+ if (confirmMessage) {
56
+ pendingConfirmRef.current = true;
57
+ return new Promise((resolve)=>{
58
+ openConfirmModal({
59
+ message: confirmMessage,
60
+ isDangerous: true,
61
+ onConfirm: ()=>{
62
+ pendingConfirmRef.current = false;
63
+ mutation.mutateAsync(submittedValue, {
64
+ onError,
65
+ onSuccess
66
+ }).then(()=>{
67
+ resolve();
68
+ }, resolve);
69
+ },
70
+ onClose: ()=>{
71
+ if (pendingConfirmRef.current) {
72
+ form.reset();
73
+ resolve();
74
+ }
75
+ pendingConfirmRef.current = false;
76
+ }
77
+ });
78
+ });
79
+ }
80
+ return mutation.mutateAsync(submittedValue, {
81
+ onError,
82
+ onSuccess
83
+ }).catch(()=>{});
84
+ }
85
+ });
86
+ return /*#__PURE__*/ jsx(form.AppForm, {
87
+ form: form,
88
+ children: /*#__PURE__*/ jsx(AutoSaveContextProvider, {
89
+ value: {
90
+ status: mutation.status,
91
+ resetOnErrorRef
92
+ },
93
+ children: /*#__PURE__*/ jsx(form.AppField, {
94
+ name: name,
95
+ children: (field)=>children(field)
96
+ })
97
+ })
98
+ });
99
+ }
100
+ export { AutoSaveForm };
@@ -3,8 +3,8 @@ import { DescriptionList } from "../descriptionList/index.js";
3
3
  import { InfoText } from "../info/index.js";
4
4
  import { Container, Stack } from "../layout/index.js";
5
5
  import { Text } from "../text/index.js";
6
- import { BaseLayout, LayoutLabel } from "./base.js";
7
- import { useStackedLayout } from "./useStackedLayout.js";
6
+ import { BaseLayout, LayoutLabel } from "./layout/base.js";
7
+ import { useStackedLayout } from "./layout/useStackedLayout.js";
8
8
  function RowDisplay(props) {
9
9
  const stacked = useStackedLayout();
10
10
  return /*#__PURE__*/ jsx(DisplayLayout, {