@vertigis/workflow 5.33.1 → 5.35.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 (433) hide show
  1. package/Activator.d.ts +6 -2
  2. package/Collections.d.ts +8 -5
  3. package/EnumUtils.d.ts +1 -0
  4. package/Errors.d.ts +10 -1
  5. package/Errors.js +1 -1
  6. package/Hooks.d.ts +4 -1
  7. package/IActivityHandler.d.ts +20 -6
  8. package/LanguageStringUtils.js +1 -1
  9. package/ProgramInspectorFacility.d.ts +1 -0
  10. package/Task.d.ts +1 -0
  11. package/activities/app/GetApplicationData.d.ts +2 -2
  12. package/activities/app/GetApplicationInfo.d.ts +6 -3
  13. package/activities/app/GetUserInfo.d.ts +6 -3
  14. package/activities/app/PublishEvent.d.ts +2 -2
  15. package/activities/app/RemoveApplicationData.d.ts +2 -2
  16. package/activities/app/RunCommand.d.ts +6 -3
  17. package/activities/app/RunOperation.d.ts +10 -4
  18. package/activities/app/SetApplicationData.d.ts +2 -2
  19. package/activities/arcgis/AddAttachment.d.ts +2 -2
  20. package/activities/arcgis/AddFeatureLayer.d.ts +2 -2
  21. package/activities/arcgis/AddFeatures.d.ts +2 -2
  22. package/activities/arcgis/AddFeatures.js +1 -1
  23. package/activities/arcgis/AddGraphics.d.ts +10 -4
  24. package/activities/arcgis/ArcadeScript.d.ts +2 -2
  25. package/activities/arcgis/AreaEngineTask.d.ts +2 -2
  26. package/activities/arcgis/BufferEngineTask.d.ts +2 -2
  27. package/activities/arcgis/BufferServiceTask.d.ts +2 -2
  28. package/activities/arcgis/CastGeometry.d.ts +2 -2
  29. package/activities/arcgis/ClearGraphics.d.ts +2 -2
  30. package/activities/arcgis/ClipEngineTask.d.ts +2 -2
  31. package/activities/arcgis/ClosestFacilityTask.d.ts +2 -2
  32. package/activities/arcgis/CompareGeometries.d.ts +2 -2
  33. package/activities/arcgis/CreateGraphic.d.ts +2 -2
  34. package/activities/arcgis/CreatePoint.d.ts +2 -2
  35. package/activities/arcgis/CutEngineTask.d.ts +2 -2
  36. package/activities/arcgis/DeleteAttachments.d.ts +2 -2
  37. package/activities/arcgis/DeleteFeatures.d.ts +2 -2
  38. package/activities/arcgis/DensifyEngineTask.d.ts +2 -2
  39. package/activities/arcgis/DifferenceEngineTask.d.ts +2 -2
  40. package/activities/arcgis/DistanceEngineTask.d.ts +2 -2
  41. package/activities/arcgis/DistanceServiceTask.d.ts +2 -2
  42. package/activities/arcgis/ExtendedSpatialReferenceInfoEngineTask.d.ts +2 -2
  43. package/activities/arcgis/FeatureSetFromJson.d.ts +2 -2
  44. package/activities/arcgis/FlipEngineTask.d.ts +2 -2
  45. package/activities/arcgis/FromGeoCoordinateStringServiceTask.d.ts +2 -2
  46. package/activities/arcgis/GeneralizeEngineTask.d.ts +2 -2
  47. package/activities/arcgis/GenerateArcGisToken.d.ts +2 -2
  48. package/activities/arcgis/GenerateWebmapForReport.d.ts +2 -2
  49. package/activities/arcgis/Geocode.d.ts +2 -2
  50. package/activities/arcgis/GeometryFromJson.d.ts +2 -2
  51. package/activities/arcgis/Geoprocessing.d.ts +2 -2
  52. package/activities/arcgis/GeoprocessingAsync.d.ts +2 -2
  53. package/activities/arcgis/GetAttributeValue.d.ts +2 -2
  54. package/activities/arcgis/GetAttributeValues.d.ts +2 -2
  55. package/activities/arcgis/GetCentroid.d.ts +2 -2
  56. package/activities/arcgis/GetCodedValueDomain.d.ts +2 -2
  57. package/activities/arcgis/GetCurrentPosition.d.ts +2 -2
  58. package/activities/arcgis/GetFeatureGeometries.d.ts +2 -2
  59. package/activities/arcgis/GetFeatureGeometry.d.ts +2 -2
  60. package/activities/arcgis/GetFeatureLayerInfo.d.ts +2 -2
  61. package/activities/arcgis/GetFeatureSetExtent.d.ts +2 -2
  62. package/activities/arcgis/GetFeatureSetObjectIds.d.ts +2 -2
  63. package/activities/arcgis/GetFormElementItemsFromFeatures.d.ts +2 -2
  64. package/activities/arcgis/GetGeometryExtent.d.ts +2 -2
  65. package/activities/arcgis/GetGraphics.d.ts +2 -2
  66. package/activities/arcgis/GetLayer.d.ts +2 -2
  67. package/activities/arcgis/GetLayerDefinitionExpression.d.ts +2 -2
  68. package/activities/arcgis/GetLayerProperty.d.ts +2 -2
  69. package/activities/arcgis/GetLayerVisibility.d.ts +2 -2
  70. package/activities/arcgis/GetMap.d.ts +2 -2
  71. package/activities/arcgis/GetMapScreenshot.d.ts +2 -2
  72. package/activities/arcgis/GetPortalUser.d.ts +2 -2
  73. package/activities/arcgis/GetTable.d.ts +2 -2
  74. package/activities/arcgis/GetViewExtent.d.ts +2 -2
  75. package/activities/arcgis/GetViewpoint.d.ts +2 -2
  76. package/activities/arcgis/IntersectEngineTask.d.ts +2 -2
  77. package/activities/arcgis/LabelPointsServiceTask.d.ts +2 -2
  78. package/activities/arcgis/LengthEngineTask.d.ts +2 -2
  79. package/activities/arcgis/MapProvider.d.ts +4 -1
  80. package/activities/arcgis/NearestCoordinateEngineTask.d.ts +2 -2
  81. package/activities/arcgis/NearestVertexEngineTask.d.ts +2 -2
  82. package/activities/arcgis/NearestVerticesEngineTask.d.ts +2 -2
  83. package/activities/arcgis/OffsetEngineTask.d.ts +2 -2
  84. package/activities/arcgis/ProjectServiceTask.d.ts +2 -2
  85. package/activities/arcgis/QueryAttachmentInfos.d.ts +2 -2
  86. package/activities/arcgis/QueryTask.d.ts +10 -4
  87. package/activities/arcgis/RefreshLayer.d.ts +2 -2
  88. package/activities/arcgis/RegisterCorsUrl.d.ts +2 -2
  89. package/activities/arcgis/RelateEngineTask.d.ts +2 -2
  90. package/activities/arcgis/RelationServiceTask.d.ts +2 -2
  91. package/activities/arcgis/RelationshipQueryTask.d.ts +2 -2
  92. package/activities/arcgis/RemoveFeatureSetFields.d.ts +2 -2
  93. package/activities/arcgis/RemoveGraphics.d.ts +2 -2
  94. package/activities/arcgis/RemoveLayer.d.ts +2 -2
  95. package/activities/arcgis/RendererFromJson.d.ts +2 -2
  96. package/activities/arcgis/ReshapeServiceTask.d.ts +2 -2
  97. package/activities/arcgis/ReverseGeocode.d.ts +2 -2
  98. package/activities/arcgis/RotateEngineTask.d.ts +2 -2
  99. package/activities/arcgis/RouteTask.d.ts +2 -2
  100. package/activities/arcgis/RunPrint.d.ts +2 -2
  101. package/activities/arcgis/RunReport.d.ts +2 -2
  102. package/activities/arcgis/RunWorkflow.d.ts +21 -3
  103. package/activities/arcgis/RunWorkflow.js +1 -1
  104. package/activities/arcgis/SendLayerToAttributeTable.d.ts +2 -2
  105. package/activities/arcgis/ServiceAreaTask.d.ts +2 -2
  106. package/activities/arcgis/SetFeatureAttribute.d.ts +2 -2
  107. package/activities/arcgis/SetFeatureGeometry.d.ts +2 -2
  108. package/activities/arcgis/SetFeaturePopup.d.ts +2 -2
  109. package/activities/arcgis/SetFeatureSymbol.d.ts +2 -2
  110. package/activities/arcgis/SetImageryLayerOptions.d.ts +2 -2
  111. package/activities/arcgis/SetLayerDefinitionExpression.d.ts +2 -2
  112. package/activities/arcgis/SetLayerPopup.d.ts +2 -2
  113. package/activities/arcgis/SetLayerProperty.d.ts +2 -2
  114. package/activities/arcgis/SetLayerVisibility.d.ts +2 -2
  115. package/activities/arcgis/SetMap.d.ts +6 -3
  116. package/activities/arcgis/SetViewExtent.d.ts +2 -2
  117. package/activities/arcgis/SetViewpoint.d.ts +2 -2
  118. package/activities/arcgis/ShowFeaturePopup.d.ts +2 -2
  119. package/activities/arcgis/ShowResults.d.ts +5 -2
  120. package/activities/arcgis/SimplifyEngineTask.d.ts +2 -2
  121. package/activities/arcgis/SortFeatureSet.d.ts +2 -2
  122. package/activities/arcgis/SymbolFromJson.d.ts +2 -2
  123. package/activities/arcgis/ToGeoCoordinateStringServiceTask.d.ts +2 -2
  124. package/activities/arcgis/UnionEngineTask.d.ts +2 -2
  125. package/activities/arcgis/UnionServiceTask.d.ts +2 -2
  126. package/activities/arcgis/UpdateAttachment.d.ts +2 -2
  127. package/activities/arcgis/UpdateFeatures.d.ts +2 -2
  128. package/activities/arcgis/runUtils.d.ts +6 -2
  129. package/activities/browser/GetBrowserInfo.d.ts +2 -2
  130. package/activities/browser/InjectCss.d.ts +2 -2
  131. package/activities/core/AddItem.d.ts +2 -2
  132. package/activities/core/AddItems.d.ts +2 -2
  133. package/activities/core/Annotation.d.ts +2 -2
  134. package/activities/core/Cast.d.ts +2 -2
  135. package/activities/core/ChannelProvider.d.ts +1 -0
  136. package/activities/core/ClearItems.d.ts +2 -2
  137. package/activities/core/Container.d.ts +2 -2
  138. package/activities/core/ConvertBytesToText.d.ts +2 -2
  139. package/activities/core/ConvertDataTableToFeatureSet.d.ts +2 -2
  140. package/activities/core/ConvertTextToBytes.d.ts +2 -2
  141. package/activities/core/ConvertToJson.d.ts +2 -2
  142. package/activities/core/CreateFile.d.ts +2 -2
  143. package/activities/core/CreateValue.d.ts +2 -2
  144. package/activities/core/DecodeUriComponent.d.ts +2 -2
  145. package/activities/core/Delay.d.ts +2 -2
  146. package/activities/core/EncodeUriComponent.d.ts +2 -2
  147. package/activities/core/Evaluate.d.ts +2 -2
  148. package/activities/core/EvaluateAsync.d.ts +2 -2
  149. package/activities/core/Exit.d.ts +2 -2
  150. package/activities/core/ForEach.d.ts +2 -2
  151. package/activities/core/FormatDate.d.ts +5 -5
  152. package/activities/core/FormatDate.js +1 -1
  153. package/activities/core/GetBase64StringFromBytes.d.ts +2 -2
  154. package/activities/core/GetBase64StringFromFile.d.ts +2 -2
  155. package/activities/core/GetBytesFromBase64String.d.ts +2 -2
  156. package/activities/core/GetFirstItem.d.ts +2 -2
  157. package/activities/core/GetItemAtIndex.d.ts +2 -2
  158. package/activities/core/GetLastItem.d.ts +2 -2
  159. package/activities/core/GetLogLevel.d.ts +2 -2
  160. package/activities/core/GetTextFromFile.d.ts +2 -2
  161. package/activities/core/GetWorkflowInputs.d.ts +2 -2
  162. package/activities/core/If.d.ts +2 -2
  163. package/activities/core/Log.d.ts +2 -2
  164. package/activities/core/Loop.d.ts +2 -2
  165. package/activities/core/ParseJson.d.ts +2 -2
  166. package/activities/core/ParseNumber.d.ts +2 -2
  167. package/activities/core/ParseUrl.d.ts +2 -2
  168. package/activities/core/Placeholder.d.ts +2 -2
  169. package/activities/core/RegexMatches.d.ts +2 -2
  170. package/activities/core/RegexReplace.d.ts +2 -2
  171. package/activities/core/RemoveItem.d.ts +2 -2
  172. package/activities/core/RunActivity.d.ts +2 -2
  173. package/activities/core/RunSubworkflow.d.ts +2 -2
  174. package/activities/core/SetLogLevel.d.ts +2 -2
  175. package/activities/core/SetProperty.d.ts +2 -2
  176. package/activities/core/SetWorkflowOutput.d.ts +2 -2
  177. package/activities/core/Subworkflow.d.ts +2 -2
  178. package/activities/core/Switch.d.ts +2 -2
  179. package/activities/core/TextReplace.d.ts +2 -2
  180. package/activities/core/Throw.d.ts +2 -2
  181. package/activities/core/TryCatch.d.ts +2 -2
  182. package/activities/core/WebRequest.d.ts +2 -2
  183. package/activities/core/converters.d.ts +1 -1
  184. package/activities/csv/ConvertCsvToDataTable.d.ts +2 -2
  185. package/activities/csv/ConvertDataTableToCsv.d.ts +2 -2
  186. package/activities/essentials/GetEssentialsSite.d.ts +2 -2
  187. package/activities/essentials/RunEssentialsWorkflow.d.ts +2 -2
  188. package/activities/essentials/RunEssentialsWorkflowActivity.d.ts +2 -2
  189. package/activities/forms/ActivateFormElement.d.ts +2 -2
  190. package/activities/forms/AddFormElement.d.ts +2 -2
  191. package/activities/forms/ClearFormElementError.d.ts +2 -2
  192. package/activities/forms/CompleteForm.d.ts +2 -2
  193. package/activities/forms/DisplayForm.d.ts +6 -3
  194. package/activities/forms/FilterFormElementItems.d.ts +2 -2
  195. package/activities/forms/FormRenderer.d.ts +1 -0
  196. package/activities/forms/FormRenderer.js +1 -1
  197. package/activities/forms/GetFormElementItemsFromCollection.d.ts +2 -2
  198. package/activities/forms/GetFormElementProperty.d.ts +2 -2
  199. package/activities/forms/GetFormElementValue.d.ts +2 -2
  200. package/activities/forms/GetFormEventData.d.ts +2 -2
  201. package/activities/forms/HideFormElement.d.ts +2 -2
  202. package/activities/forms/PropagateFormEvent.d.ts +2 -2
  203. package/activities/forms/SetCurrentFormElementItem.d.ts +2 -2
  204. package/activities/forms/SetFormElementError.d.ts +2 -2
  205. package/activities/forms/SetFormElementEvent.d.ts +2 -2
  206. package/activities/forms/SetFormElementItemProperty.d.ts +2 -2
  207. package/activities/forms/SetFormElementItems.d.ts +2 -2
  208. package/activities/forms/SetFormElementProperty.d.ts +3 -3
  209. package/activities/forms/ShowFormElement.d.ts +2 -2
  210. package/activities/image/GetImageMetadata.d.ts +2 -2
  211. package/activities/image/RotateImage.d.ts +2 -2
  212. package/activities/index.d.ts +1 -0
  213. package/activities/index.js +1 -1
  214. package/activities/math/Abs.d.ts +2 -2
  215. package/activities/math/Cos.d.ts +2 -2
  216. package/activities/math/Max.d.ts +2 -2
  217. package/activities/math/Min.d.ts +2 -2
  218. package/activities/math/Pow.d.ts +2 -2
  219. package/activities/math/Random.d.ts +2 -2
  220. package/activities/math/Sin.d.ts +2 -2
  221. package/activities/math/Sqrt.d.ts +2 -2
  222. package/activities/math/Tan.d.ts +2 -2
  223. package/activities/pdf/AddGeoreferenceToPdf.d.ts +19 -0
  224. package/activities/pdf/AddGeoreferenceToPdf.js +1 -0
  225. package/activities/pdf/ExtractPdfPages.d.ts +2 -2
  226. package/activities/pdf/MergePdfs.d.ts +2 -2
  227. package/activities/server/CopyFile.d.ts +2 -2
  228. package/activities/server/CreateDirectory.d.ts +2 -2
  229. package/activities/server/CreateDownload.d.ts +2 -2
  230. package/activities/server/CreateEmailAttachment.d.ts +2 -2
  231. package/activities/server/CreateZipFromDirectory.d.ts +2 -2
  232. package/activities/server/DeleteDirectory.d.ts +2 -2
  233. package/activities/server/DeleteFile.d.ts +2 -2
  234. package/activities/server/DirectoryExists.d.ts +2 -2
  235. package/activities/server/ExtractZipToDirectory.d.ts +2 -2
  236. package/activities/server/FileExists.d.ts +2 -2
  237. package/activities/server/GetDirectoriesInDirectory.d.ts +2 -2
  238. package/activities/server/GetFilesInDirectory.d.ts +2 -2
  239. package/activities/server/MoveFile.d.ts +2 -2
  240. package/activities/server/ReadFile.d.ts +2 -2
  241. package/activities/server/ReadFileBytes.d.ts +2 -2
  242. package/activities/server/RunApplication.d.ts +2 -2
  243. package/activities/server/RunPython.d.ts +2 -2
  244. package/activities/server/SendEmail.d.ts +2 -2
  245. package/activities/server/SqlNonQuery.d.ts +2 -2
  246. package/activities/server/SqlQuery.d.ts +2 -2
  247. package/activities/server/SqlQueryUnsafe.d.ts +2 -2
  248. package/activities/server/WriteFile.d.ts +2 -2
  249. package/activities/server/WriteFileBytes.d.ts +2 -2
  250. package/activities/ui/Alert.d.ts +6 -3
  251. package/activities/ui/Confirm.d.ts +10 -4
  252. package/activities/ui/Prompt.d.ts +10 -4
  253. package/activities/wab/OpenWidget.d.ts +2 -2
  254. package/activities/wab/PublishWidgetData.d.ts +2 -2
  255. package/activities/xlsx/ConvertDataTableToXlsx.d.ts +2 -2
  256. package/activities/xlsx/ConvertXlsxToDataSet.d.ts +2 -2
  257. package/definition/Program.d.ts +4 -1
  258. package/definition/ProgramInspector.d.ts +4 -1
  259. package/definition/Reference.d.ts +4 -1
  260. package/diagnostics/ConsoleDebugLogger.d.ts +4 -1
  261. package/diagnostics/logging.d.ts +4 -1
  262. package/execution/ActivityLoader.d.ts +4 -1
  263. package/execution/Engine.d.ts +16 -4
  264. package/execution/IDebugSession.d.ts +4 -1
  265. package/execution/ProgramRunner.js +1 -1
  266. package/forms/Calendar.d.ts +1 -1
  267. package/forms/FormComponent.d.ts +4 -3
  268. package/forms/FormComponent.js +1 -1
  269. package/forms/FormDefinition.d.ts +100 -19
  270. package/forms/FormElement.d.ts +3 -17
  271. package/forms/FormElement.js +1 -1
  272. package/forms/FormHost.d.ts +29 -8
  273. package/forms/FormHost.js +1 -1
  274. package/forms/FormPresenterHost.d.ts +33 -7
  275. package/forms/common.d.ts +6 -7
  276. package/forms/common.js +1 -1
  277. package/forms/components/AccordionGroup.d.ts +15 -0
  278. package/forms/components/AccordionGroup.js +1 -0
  279. package/forms/components/AutoComplete.d.ts +7 -0
  280. package/forms/components/AutoComplete.js +1 -0
  281. package/forms/components/ButtonBar.d.ts +13 -0
  282. package/forms/components/ButtonBar.js +1 -0
  283. package/forms/components/CheckBox.d.ts +7 -0
  284. package/forms/components/CheckBox.js +1 -0
  285. package/forms/components/CheckGroup.d.ts +7 -0
  286. package/forms/components/CheckGroup.js +1 -0
  287. package/forms/components/Custom.d.ts +7 -0
  288. package/forms/components/Custom.js +1 -0
  289. package/forms/components/DatePicker.d.ts +6 -16
  290. package/forms/components/DatePicker.js +1 -1
  291. package/forms/components/DateRangePicker.d.ts +10 -8
  292. package/forms/components/DateRangePicker.js +1 -1
  293. package/forms/components/DateTimePicker.d.ts +6 -8
  294. package/forms/components/DateTimePicker.js +1 -1
  295. package/forms/components/DropDownList.d.ts +7 -0
  296. package/forms/components/DropDownList.js +1 -0
  297. package/forms/components/FilePicker.d.ts +9 -0
  298. package/forms/components/FilePicker.js +1 -0
  299. package/forms/components/Form.d.ts +23 -0
  300. package/forms/components/Form.js +1 -0
  301. package/forms/components/FormLabelNumberField.d.ts +15 -0
  302. package/forms/components/FormLabelNumberField.js +1 -0
  303. package/forms/components/GeometryPicker.d.ts +4 -0
  304. package/forms/components/GeometryPicker.js +1 -0
  305. package/forms/components/GeometryPickerListItem.d.ts +23 -0
  306. package/forms/components/GeometryPickerListItem.js +1 -0
  307. package/forms/components/HorizontalRule.d.ts +7 -0
  308. package/forms/components/HorizontalRule.js +1 -0
  309. package/forms/components/Image.d.ts +7 -0
  310. package/forms/components/Image.js +1 -0
  311. package/forms/components/ItemPicker.d.ts +17 -0
  312. package/forms/components/ItemPicker.js +1 -0
  313. package/forms/components/ListBox.d.ts +7 -0
  314. package/forms/components/ListBox.js +1 -0
  315. package/forms/components/Markdown.d.ts +1 -1
  316. package/forms/components/Markdown.js +1 -1
  317. package/forms/components/Number.d.ts +7 -0
  318. package/forms/components/Number.js +1 -0
  319. package/forms/components/NumberRangeSlider.d.ts +11 -8
  320. package/forms/components/NumberRangeSlider.js +1 -1
  321. package/forms/components/NumberSlider.d.ts +9 -8
  322. package/forms/components/NumberSlider.js +1 -1
  323. package/forms/components/RadioGroup.d.ts +7 -0
  324. package/forms/components/RadioGroup.js +1 -0
  325. package/forms/components/Scanner.d.ts +9 -0
  326. package/forms/components/Scanner.js +1 -0
  327. package/forms/components/Section.d.ts +14 -0
  328. package/forms/components/Section.js +1 -0
  329. package/forms/components/Signature.d.ts +11 -0
  330. package/forms/components/Signature.js +1 -0
  331. package/forms/components/SignatureDialog.d.ts +22 -0
  332. package/forms/components/SignatureDialog.js +1 -0
  333. package/forms/components/Text.d.ts +1 -1
  334. package/forms/components/Text.js +1 -1
  335. package/forms/components/TextArea.d.ts +1 -1
  336. package/forms/components/TextArea.js +1 -1
  337. package/forms/components/TextBox.d.ts +1 -1
  338. package/forms/components/TextBox.js +1 -1
  339. package/forms/components/TimePicker.d.ts +7 -0
  340. package/forms/components/TimePicker.js +1 -0
  341. package/forms/constants.d.ts +19 -31
  342. package/forms/constants.js +1 -1
  343. package/forms/dateUtilities.d.ts +41 -9
  344. package/forms/dateUtilities.js +1 -1
  345. package/forms/elements/AutoComplete.d.ts +7 -0
  346. package/forms/elements/AutoComplete.js +1 -0
  347. package/forms/elements/Number.d.ts +5 -0
  348. package/forms/elements/Number.js +1 -0
  349. package/forms/elements/NumberRangeSlider.d.ts +5 -3
  350. package/forms/elements/NumberRangeSlider.js +1 -1
  351. package/forms/elements/NumberSlider.d.ts +0 -3
  352. package/forms/elements/NumberSlider.js +0 -1
  353. package/forms/elements/Scanner.d.ts +9 -0
  354. package/forms/elements/Scanner.js +1 -0
  355. package/forms/elements/Signature.d.ts +16 -0
  356. package/forms/elements/Signature.js +1 -0
  357. package/forms/elements/types.d.ts +4 -2
  358. package/forms/index.d.ts +6 -2
  359. package/forms/index.js +1 -1
  360. package/forms/keyboard.d.ts +1 -0
  361. package/forms/numberFormatter.d.ts +5 -6
  362. package/forms/numberFormatter.js +1 -1
  363. package/forms/numberUtilities.d.ts +113 -0
  364. package/forms/numberUtilities.js +1 -0
  365. package/forms/presenter.d.ts +1 -0
  366. package/forms/presenter.js +1 -1
  367. package/forms/renderers.d.ts +5 -43
  368. package/forms/renderers.js +1 -1
  369. package/forms/textUtilities.d.ts +6 -4
  370. package/forms/textUtilities.js +1 -1
  371. package/forms/utils.d.ts +102 -20
  372. package/forms/utils.js +1 -1
  373. package/index.d.ts +1 -1
  374. package/index.js +0 -1
  375. package/libs/version.d.ts +1 -1
  376. package/libs/version.js +1 -1
  377. package/package.json +10 -10
  378. package/app/ActivityPackUtils.d.ts +0 -10
  379. package/app/ActivityPackUtils.js +0 -1
  380. package/app/AppActivity.d.ts +0 -82
  381. package/app/AppActivity.js +0 -1
  382. package/app/RegisterCustomFormElementBase.d.ts +0 -34
  383. package/app/RegisterCustomFormElementBase.js +0 -1
  384. package/forms/LegacyStyles.d.ts +0 -498
  385. package/forms/LegacyStyles.js +0 -1
  386. package/forms/assets/arrow.d.ts +0 -4
  387. package/forms/assets/arrow.js +0 -1
  388. package/forms/assets/chevron.d.ts +0 -3
  389. package/forms/assets/chevron.js +0 -1
  390. package/forms/assets/cross.d.ts +0 -3
  391. package/forms/assets/cross.js +0 -1
  392. package/forms/assets/datetime.d.ts +0 -3
  393. package/forms/assets/datetime.js +0 -1
  394. package/forms/assets/remove.d.ts +0 -2
  395. package/forms/assets/remove.js +0 -1
  396. package/forms/assets/scan.d.ts +0 -4
  397. package/forms/assets/scan.js +0 -1
  398. package/forms/assets/stock.d.ts +0 -5
  399. package/forms/assets/stock.js +0 -1
  400. package/forms/components/DateRange.d.ts +0 -6
  401. package/forms/components/DateRange.js +0 -1
  402. package/forms/components/Navigator.d.ts +0 -1
  403. package/forms/components/Navigator.js +0 -1
  404. package/forms/components/ReactDateRangeCalendar.d.ts +0 -6
  405. package/forms/components/ReactDateRangeCalendar.js +0 -1
  406. package/forms/components/SyntheticButton.d.ts +0 -1
  407. package/forms/components/SyntheticButton.js +0 -1
  408. package/forms/components/TimePickerInput.d.ts +0 -24
  409. package/forms/components/TimePickerInput.js +0 -1
  410. package/forms/components/TimerManager.d.ts +0 -7
  411. package/forms/components/TimerManager.js +0 -1
  412. package/forms/components/utils.d.ts +0 -2
  413. package/forms/components/utils.js +0 -1
  414. package/forms/datetime.d.ts +0 -5
  415. package/forms/datetime.js +0 -1
  416. package/forms/files.d.ts +0 -4
  417. package/forms/files.js +0 -1
  418. package/forms/geometry.d.ts +0 -4
  419. package/forms/geometry.js +0 -1
  420. package/forms/number.d.ts +0 -11
  421. package/forms/number.js +0 -1
  422. package/forms/numberSliderUtilities.d.ts +0 -12
  423. package/forms/numberSliderUtilities.js +0 -1
  424. package/forms/scanner.d.ts +0 -4
  425. package/forms/scanner.js +0 -1
  426. package/forms/selectors.d.ts +0 -10
  427. package/forms/selectors.js +0 -1
  428. package/forms/styles/daterange.css +0 -1
  429. package/forms/styles/daterange.d.ts +0 -1
  430. package/forms/styles/daterange.js +0 -1
  431. package/forms/styles/stock.css +0 -1
  432. package/forms/styles/stock.d.ts +0 -1
  433. package/forms/styles/stock.js +0 -1
@@ -4,11 +4,12 @@ import { FormPresenterHost } from "./FormPresenterHost";
4
4
  import type { FormElementProps, FormElementRegistration } from "./index";
5
5
  export { FormPresenterHost };
6
6
  export interface FormComponentProps {
7
- host?: FormPresenterHost;
8
- type?: "form" | "body" | "row" | "header" | "main" | "footer" | "element" | "section";
7
+ host: FormPresenterHost;
8
+ type?: "form" | "body" | "row" | "header" | "main" | "footer" | "element" | "section" | "accordionGroup";
9
9
  name?: string;
10
10
  children?: JSX.Element[];
11
11
  }
12
+ /** @product This is intended for internal use only within VertiGIS Studio products. */
12
13
  export declare class FormComponent extends Component<FormComponentProps, {}> {
13
14
  id: string;
14
15
  autoInput: boolean;
@@ -22,7 +23,7 @@ export declare class FormComponent extends Component<FormComponentProps, {}> {
22
23
  setProperty: FormElementProps<any>["setProperty"];
23
24
  setValue: FormElementProps["setValue"];
24
25
  }
25
- export declare class FormElement extends FormComponent {
26
+ export declare class FormElementComponent extends FormComponent {
26
27
  componentDidMount(): void;
27
28
  componentDidUpdate(): void;
28
29
  componentWillUnmount(): void;
@@ -1 +1 @@
1
- import{Component}from"react";import{makeId}from"./utils.js";class FormComponent extends Component{constructor(){super(...arguments),this.raiseEvent=(e,t)=>this.props.host?.post(e,{name:this.props.name,value:t}),this.setProperty=(e,t)=>{const s=this.props.host;var n=this.props.name;s.assignElementProperty(n,e,t)},this.setValue=e=>this.setProperty("value",e)}get elementRegistration(){const e=this.props["host"];if(isFormRenderer(e))return e.getElementRegistration(this.element)}get element(){const{host:e,name:t}=this.props;if(t)return e.find(t)}prepare(){var e;void 0===this.id&&(this.id=makeId()),this.enabled=!0;const t=this.props.host;return!1===t.enabled&&(this.enabled=!1),void 0!==this.element&&(void 0!==(e=t.find(this.element.section))&&!1===e.enabled&&(this.enabled=!1),!1===this.element.enabled&&(this.enabled=!1)),this.element}render(){return this.props.host.renderVisual(this)}}class FormElement extends FormComponent{componentDidMount(){const e=this.props;e.host.refs[e.name]=this}componentDidUpdate(){const e=this.props;e.host.refs[e.name]=this}componentWillUnmount(){const e=this.props;e.host.refs[e.name]=void 0}}function isFormRenderer(e){return!!e&&"function"==typeof e.getElementRegistration}export{FormComponent,FormElement};
1
+ import{Component}from"react";import{makeId}from"./utils.js";class FormComponent extends Component{constructor(){super(...arguments),this.raiseEvent=(e,t)=>this.props.host?.post(e,{name:this.props.name,value:t}),this.setProperty=(e,t)=>{const s=this.props.host;var n=this.props.name;s.assignElementProperty(n,e,t)},this.setValue=e=>this.setProperty("value",e)}get elementRegistration(){const e=this.props["host"];if(isFormRenderer(e))return e.getElementRegistration(this.element)}get element(){const{host:e,name:t}=this.props;if(t)return e.find(t)}prepare(){var e;void 0===this.id&&(this.id=makeId()),this.enabled=!0;const t=this.props.host;return!1===t.enabled&&(this.enabled=!1),void 0!==this.element&&(void 0!==(e=t.find(this.element.section))&&!1===e.enabled&&(this.enabled=!1),!1===this.element.enabled&&(this.enabled=!1)),this.element}render(){return this.props.host.renderVisual(this)}}class FormElementComponent extends FormComponent{componentDidMount(){const e=this.props;e.host.refs[e.name]=this}componentDidUpdate(){const e=this.props;e.host.refs[e.name]=this}componentWillUnmount(){const e=this.props;e.host.refs[e.name]=void 0}}function isFormRenderer(e){return!!e&&"function"==typeof e.getElementRegistration}export{FormComponent,FormElementComponent};
@@ -1,5 +1,9 @@
1
+ import { Lookup } from "../Collections";
1
2
  import { NumberDisplayFormat } from "./numberFormatter";
2
- /** References a container. */
3
+ /**
4
+ * References a container.
5
+ * @product This is intended for internal use only within VertiGIS Studio products.
6
+ */
3
7
  export declare type ContainerRef = "default" | "modal" | {
4
8
  /** Indicates the name of the container. */
5
9
  name: string;
@@ -54,12 +58,18 @@ export interface GeometryRef {
54
58
  /** Indicates the geometry. */
55
59
  geometry: {}[];
56
60
  }
57
- /** References one or more items within the element. */
61
+ /**
62
+ * References one or more items within the element.
63
+ * @product This is intended for internal use only within VertiGIS Studio products.
64
+ */
58
65
  export interface ItemsRef {
59
66
  /** The items that were selected. */
60
67
  items: Item[];
61
68
  }
62
- /** Indicates the number. */
69
+ /**
70
+ * Indicates the number.
71
+ * @product This is intended for internal use only within VertiGIS Studio products.
72
+ */
63
73
  export interface NumberRef {
64
74
  /** Indicates the format for the number. */
65
75
  format: NumberFormat;
@@ -68,7 +78,10 @@ export interface NumberRef {
68
78
  /** Indicates the numeric value. */
69
79
  numeric: number;
70
80
  }
71
- /** References markdown for a markdown-based value. */
81
+ /**
82
+ * References markdown for a markdown-based value.
83
+ * @public
84
+ */
72
85
  export interface MarkdownRef {
73
86
  markdown: string;
74
87
  }
@@ -84,7 +97,16 @@ export interface ScanRef {
84
97
  /** Indicates the returned scanner data. */
85
98
  value: string;
86
99
  }
87
- /** References an error, warnings, and statuses. */
100
+ export interface SignatureRef {
101
+ /** A Data URL describing the image as a PNG. */
102
+ dataUrl: string;
103
+ /** A File object for a PNG image of the signature. */
104
+ file: File;
105
+ }
106
+ /**
107
+ * References an error, warnings, and statuses.
108
+ * @product This is intended for internal use only within VertiGIS Studio products.
109
+ */
88
110
  export interface StatusRef {
89
111
  /** missing - Input is missing. */
90
112
  /** invalid - Input is invalid. */
@@ -93,17 +115,26 @@ export interface StatusRef {
93
115
  /** trivial - Input items are empty, not relevant, not significant etc. */
94
116
  status: "missing" | "invalid" | "failure" | "pending" | "trivial";
95
117
  }
96
- /** References any kind of text. */
118
+ /**
119
+ * References any kind of text.
120
+ * @product This is intended for internal use only within VertiGIS Studio products.
121
+ */
97
122
  export declare type Text = string | MarkdownRef | StatusRef;
98
123
  /**
99
124
  * Indicates how a form element's title should be positioned relative to its content.
100
125
  */
101
126
  export declare type TitleLocation = "above" | "beside";
102
- /** References any kind of value appropriate for a form element. */
103
- export declare type Value = boolean | number | number[] | string | DataRef | DateRangeRef | DateTimeRef | FilesRef | GeometryRef | ItemsRef | NumberRef | ScanRef;
127
+ /**
128
+ * References any kind of value appropriate for a form element.
129
+ * @product This is intended for internal use only within VertiGIS Studio products.
130
+ */
131
+ export declare type Value = boolean | number | number[] | string | DataRef | DateRangeRef | DateTimeRef | FilesRef | GeometryRef | ItemsRef | NumberRef | ScanRef | SignatureRef;
104
132
  /** Types of matching that can be performed when finding an Item within a Form Element. */
105
133
  export declare type ItemMatchType = "index" | "item" | "key" | "label" | "value";
106
- /** References what kind of elements exist. */
134
+ /**
135
+ * References what kind of elements exist.
136
+ * @product This is intended for internal use only within VertiGIS Studio products.
137
+ */
107
138
  export declare type ElementType = "DropDownEdit" | "DropDownList" | "GeometryPicker" | "Header";
108
139
  /** References the format types. */
109
140
  export declare type FormatRef = DateTimeFormat | NumberFormat | GeometryFormat | SectionFormat;
@@ -116,7 +147,34 @@ export declare type DateTimeFormat = "app" | "device" | {
116
147
  /** Indicates the time zone for the date/time value. */
117
148
  timezone: string;
118
149
  };
119
- /** References the number format criteria. */
150
+ /**
151
+ * Constraints to be applied to numeric values within form elements that deal with selecting numbers.
152
+ */
153
+ export interface NumberConstraints {
154
+ /**
155
+ * The highest accepted value. Values higher than this value should be replaced by it.
156
+ * If this is `undefined`, there is no upper limit.
157
+ */
158
+ maximum: number | undefined;
159
+ /**
160
+ * The lowest accepted value. Values lower than this value should be replaced by it.
161
+ * If this is `undefined`, there is no lower limit.
162
+ */
163
+ minimum: number | undefined;
164
+ /**
165
+ * The amount that the number changes when the user increments/decrements the value.
166
+ * This must be a value > 0.
167
+ *
168
+ * If `minimum` is also defined, values must fall on `minimum + step * n` where `n` is an integer.
169
+ * Values that do not should be rounded to the nearest valud step. If `minimum` is not defined,
170
+ * the formula becomes `step * n`.
171
+ */
172
+ step: number;
173
+ }
174
+ /**
175
+ * References the number format criteria.
176
+ * @product This is intended for internal use only within VertiGIS Studio products.
177
+ */
120
178
  export interface NumberFormat {
121
179
  /**
122
180
  * The 3-letter ISO 4217 currency code (e.g "USD", "CAD"). Required when
@@ -134,17 +192,31 @@ export interface NumberFormat {
134
192
  displayFormat?: NumberDisplayFormat;
135
193
  /** Indicates the lower bound. */
136
194
  lowerBound?: number;
137
- /** Indicates the minimum increment/decrement and precision of values. */
195
+ /**
196
+ * Indicates the minimum increment/decrement and precision of values.
197
+ *
198
+ * Positive precision values indicates the number of decimal places to round to.
199
+ * For example, `1` would round to `0.1`, `2` would round to `0.01` etc.
200
+ *
201
+ * Negative precision values indicates the number of whole digits to round to.
202
+ * For example, `-1` would round to `10`, `-2` would round to `100` etc.
203
+ */
138
204
  precision?: number;
139
205
  /** Indicates the step size which is the amount to increment/decrement. */
140
206
  step?: number;
141
207
  /** Indicates the upper bound. */
142
208
  upperBound?: number;
143
209
  }
144
- /** References geometry format. */
210
+ /**
211
+ * References geometry format.
212
+ * @product This is intended for internal use only within VertiGIS Studio products.
213
+ */
145
214
  export declare type GeometryFormat = "polygon" | "polyline" | "point" | "polygon-freehand" | "polyline-freehand" | "extent" | "line";
146
215
  export declare type SectionFormat = "accordion-section" | "unstyled-section" | "fieldset-section" | "basic-section" | "collapsible-section";
147
- /** The `SectionFormat` to use when no value is specified. */
216
+ /**
217
+ * The `SectionFormat` to use when no value is specified.
218
+ * @product This is intended for internal use only within VertiGIS Studio products.
219
+ */
148
220
  export declare const DEFAULT_SECTION_FORMAT = "unstyled-section";
149
221
  /** References a two-dimensional size. */
150
222
  export interface Size {
@@ -153,7 +225,10 @@ export interface Size {
153
225
  /** The width. */
154
226
  width?: number;
155
227
  }
156
- /** Defines a form. */
228
+ /**
229
+ * Defines a form.
230
+ * @product This is intended for internal use only within VertiGIS Studio products.
231
+ */
157
232
  export interface Form {
158
233
  /** Indicates the defaults for the form. */
159
234
  defaults?: {
@@ -164,7 +239,10 @@ export interface Form {
164
239
  [name: string]: Element;
165
240
  };
166
241
  }
167
- /** Defines any element used in a form. */
242
+ /**
243
+ * Defines any element used in a form.
244
+ * @product This is intended for internal use only within VertiGIS Studio products.
245
+ */
168
246
  export interface Element {
169
247
  /**
170
248
  * An accessible description to be used by assistive technologies such as screen readers.
@@ -210,9 +288,7 @@ export interface Element {
210
288
  /** Indicates the item label for items which are opaquely constructed such as geometries in the Geometry Picker. */
211
289
  itemLabel?: Text | Text[];
212
290
  /** Indicates the items. */
213
- items?: {
214
- [key: string]: Item;
215
- };
291
+ items?: Lookup<Item>;
216
292
  /** Indicates the label for the element. */
217
293
  label?: Text;
218
294
  /** Indicates the locally unique identifier for application specific use. */
@@ -280,7 +356,10 @@ export interface Element {
280
356
  /** Indicates how the control wraps text. */
281
357
  wrap?: "hard" | "soft" | "off";
282
358
  }
283
- /** Defines an ad hoc item. */
359
+ /**
360
+ * Defines an ad hoc item.
361
+ * @product This is intended for internal use only within VertiGIS Studio products.
362
+ */
284
363
  export interface Item {
285
364
  /** Indicates the placement of the item. */
286
365
  index?: number;
@@ -304,6 +383,7 @@ export interface Item {
304
383
  styleName?: string;
305
384
  }
306
385
  export declare type EventType = "load" | "cancel" | "checked" | "changed" | "clicked" | "custom" | "dragged" | "suggest" | "submit" | "end" | "verify" | "validate" | "populate" | "prepare";
386
+ /** @product This is intended for internal use only within VertiGIS Studio products. */
307
387
  export interface Event {
308
388
  /** Indicates the name of the element raising the event. */
309
389
  name?: string;
@@ -320,6 +400,7 @@ export interface Event {
320
400
  /** Indicates the cancellation token fro the event. */
321
401
  cancellationToken?: PromiseLike<void>;
322
402
  }
403
+ /** @product This is intended for internal use only within VertiGIS Studio products. */
323
404
  export interface GeometryState {
324
405
  /** Indicates the application specific context. */
325
406
  context?: {};
@@ -6,6 +6,8 @@ import { defs } from "./FormHost";
6
6
  * Properties common to all Form Elements.
7
7
  */
8
8
  export interface BaseFormElementProps {
9
+ /** The CSS class name of the root element. */
10
+ className?: string;
9
11
  /**
10
12
  * The `FormComponent` being used to render the Form Element within this Component.
11
13
  */
@@ -15,27 +17,11 @@ export interface BaseFormElementProps {
15
17
  */
16
18
  element: defs.Element;
17
19
  }
18
- interface FormElementProps {
19
- /**
20
- * Custom classes for this element. Use sparingly.
21
- */
22
- classNames?: string[];
23
- /**
24
- * The `FormComponent` being used to render the Form Element within this Component.
25
- */
26
- component: FormComponent;
27
- /**
28
- * The Form Element to be rendered within this Component.
29
- */
30
- element: defs.Element;
20
+ interface FormElementProps extends BaseFormElementProps {
31
21
  /**
32
22
  * The id of the default input to be associated with the title.
33
23
  */
34
24
  inputId?: string;
35
- /**
36
- * True if the component should render with older styles, because it has not yet been migrated to use `react-ui` components.
37
- */
38
- legacyMode?: boolean;
39
25
  /**
40
26
  * Callback for when the Form Element receives focus.
41
27
  * @param event The focus event.
@@ -1 +1 @@
1
- import FormControl from"@vertigis/react-ui/FormControl";import{forwardRef}from"react";import*as React from"react";import{renderAccessibleDescription,renderDescription,renderError,renderTitle}from"./common.js";import{TitleLocation}from"./constants.js";import{makeSafeClassName,makeUniqueId}from"./utils.js";export default forwardRef((e,r)=>{const{children:t,classNames:o,component:a,element:s,inputId:i,legacyMode:n,...l}=e;var m=a.props.host,p=makeUniqueId(a.props.name),c=renderTitle(m,s,p,i),d=renderDescription(m,s,p),f=renderAccessibleDescription(m,s,p),u=renderError(m,s),h=c?.props?.id,e=d?.props?.id,m=f?.props?.id;const y=[s.type,makeSafeClassName(a.props.name)];n&&y.push("legacy-styled-element"),s.titleLocation===TitleLocation.BESIDE&&y.push("inline-title"),s.styleName&&y.push(makeSafeClassName(s.styleName)),o&&y.push(...o);r={"aria-labelledby":h,"aria-details":e,"aria-describedby":m,className:y.join(" "),error:!!u,id:p,ref:r,...l};let E=[c];return s.titleLocation===TitleLocation.BESIDE?E.push(React.createElement("div",{className:"form-element-content"},d,f,u,t)):(E.push(d),E.push(f),E.push(u),E.push(t)),React.createElement(FormControl,{fullWidth:!0,...r},...E)});
1
+ import FormControl from"@vertigis/react-ui/FormControl";import clsx from"clsx";import{forwardRef}from"react";import*as React from"react";import{renderAccessibleDescription,renderDescription,renderError,renderTitle}from"./common.js";import{formClasses}from"./components/Form.js";import{TitleLocation}from"./constants.js";import{makeSafeClassName,makeUniqueId}from"./utils.js";export default forwardRef((e,r)=>{const{children:o,className:t,component:s,element:a,inputId:i,...m}=e;var n=s.props.host,l=makeUniqueId(s.props.name),p=renderTitle(n,a,l,i),c=renderDescription(n,a,l),e=renderAccessibleDescription(n,a,l),n=renderError(n,a),r={"aria-labelledby":p?.props?.id,"aria-details":c?.props?.id,"aria-describedby":e?.props?.id,className:clsx(t,a.type,{[formClasses.formElementWithTitleBeside]:a.titleLocation===TitleLocation.BESIDE,[makeSafeClassName(s.props.name)]:!!s.props.name,[makeSafeClassName(a.styleName)]:!!a.styleName}),error:!!n,id:l,ref:r,required:a.require,...m};let d=[p];return a.titleLocation===TitleLocation.BESIDE?d.push(React.createElement("div",{className:formClasses.formElementContent},c,e,n,o)):(d.push(c),d.push(e),d.push(n),d.push(o)),React.createElement(FormControl,{fullWidth:!0,...r},...d)});
@@ -1,9 +1,10 @@
1
- /// <reference types="react" />
2
1
  import Bluebird from "bluebird";
3
2
  import { Lookup } from "../Collections";
3
+ import { FormComponent } from "./FormComponent";
4
4
  import * as defs from "./FormDefinition";
5
5
  import { FormPresenterHost } from "./FormPresenterHost";
6
6
  import { FormatOptions } from "./numberFormatter";
7
+ import type { ComponentType, ReactNode } from "react";
7
8
  export { defs };
8
9
  export interface FormEventSubscription {
9
10
  (): boolean;
@@ -20,7 +21,9 @@ export declare abstract class FormHost implements FormPresenterHost {
20
21
  /** Indicates all errors to be assigned. */
21
22
  errors: Lookup<defs.Text>;
22
23
  /** Indicates any reference information relevant to components. */
23
- refs: {};
24
+ refs: {
25
+ [name: string]: FormComponent | undefined;
26
+ };
24
27
  /** Indicates if the form is enabled. */
25
28
  enabled: boolean;
26
29
  /** Indicates if the form is visible. */
@@ -77,6 +80,9 @@ export declare abstract class FormHost implements FormPresenterHost {
77
80
  focus(name: string): void;
78
81
  /** Shows the form. */
79
82
  show(): boolean;
83
+ private isInvalid;
84
+ private getInvalidElements;
85
+ hasInvalidChild(element: defs.Element): boolean;
80
86
  /** Shows the form in a disabled state. */
81
87
  spin(): boolean;
82
88
  /** Hides the form in a disabled state. */
@@ -96,8 +102,6 @@ export declare abstract class FormHost implements FormPresenterHost {
96
102
  * @returns The original text
97
103
  */
98
104
  translateText(content: defs.Text | undefined): string | defs.MarkdownRef;
99
- /** Renders the style for the form. */
100
- renderStyle(css?: string): HTMLStyleElement;
101
105
  /** Renders the form component. */
102
106
  renderVisual(component: {}): any;
103
107
  /** Qualifies an event with defaults. */
@@ -161,10 +165,25 @@ export declare abstract class FormHost implements FormPresenterHost {
161
165
  * other elements but afterwards.
162
166
  */
163
167
  trap(event: defs.Event): boolean;
164
- /** Attempts to cascade the form. */
165
- protected cascade(name: string): boolean;
168
+ /**
169
+ * Cascade the form by clearing the value of any elements downstream of the specified one
170
+ * and triggering the "populate" event for any elements that depend on it directly.
171
+ * @param elementName The name of an elements which has just changed.
172
+ * @returns True if the operation was a success, false otherwise.
173
+ */
174
+ protected cascade(elementName: string): boolean;
166
175
  /** Routes a click event. */
167
176
  protected click(event: defs.Event): boolean;
177
+ /**
178
+ * Checks the specified element to determine if it has a selection,
179
+ * which would justify a dependent being populated at this time.
180
+ *
181
+ * This function is only interested in _initial_ selection defined in the designer
182
+ * rather than changes made in an element's `load` event. Those are handled separately.
183
+ * @param elementName The name of the element being depended upon.
184
+ * @returns True if the element has a selection at this time.
185
+ */
186
+ hasInitialSelectionToDependOn(elementName: string): boolean;
168
187
  /** Routes a prepare event. */
169
188
  protected hydrate(event: defs.Event): boolean;
170
189
  /** Determines if the event origin is a submit button. */
@@ -188,7 +207,7 @@ export declare abstract class FormHost implements FormPresenterHost {
188
207
  /** Coerces a number. */
189
208
  coerceNumber(value: string): number;
190
209
  /** Formats a number. */
191
- formatNumber(value: number, options: FormatOptions): string;
210
+ formatNumber(value: number, options?: FormatOptions): string;
192
211
  /** Renders a custom element. */
193
212
  renderCustom(component: {}, element: defs.Element): JSX.Element;
194
213
  /** Renders a component's state. */
@@ -200,7 +219,8 @@ export declare abstract class FormHost implements FormPresenterHost {
200
219
  private isElementPositionBeforeLastFocused;
201
220
  private setLastFocus;
202
221
  private isSection;
203
- private isAccordionSection;
222
+ isAccordionSection(element?: defs.Element): boolean;
223
+ isCollapsibleSection(element?: defs.Element): boolean;
204
224
  private getAllSectionElements;
205
225
  private getMutuallyExclusiveSectionGroup;
206
226
  /**
@@ -209,4 +229,5 @@ export declare abstract class FormHost implements FormPresenterHost {
209
229
  */
210
230
  updateAccordionSections(expandedAccordionSectionName: string): void;
211
231
  private enforceAccordionConstraints;
232
+ displayDialog(children: (closeDialog: () => void) => ReactNode, DialogComponent: ComponentType<any>): Promise<void>;
212
233
  }
package/forms/FormHost.js CHANGED
@@ -1 +1 @@
1
- import Bluebird from"bluebird";import{Task}from"../Task.js";import{DEFAULT_LOCALE}from"../constants.js";import{FormComponent}from"./FormComponent.js";import*as defs from"./FormDefinition.js";import MutuallyExclusiveSectionGroup from"./MutuallyExclusiveSectionGroup.js";import NumberParser from"./NumberParser.js";import{format}from"./numberFormatter.js";import*as presenter from"./presenter.js";import*as renderers from"./renderers.js";import{CSS}from"./styles/stock.js";import{addStyleToDocument,sort,text}from"./utils.js";const guid="C0166F74-982A-464E-9FB6-9605CB7649C1:",eventName=guid+"FormEvent";function createEvent(e,t){return new CustomEvent(e,{bubbles:!1,cancelable:!1,detail:t})}function overlay(s,i){switch(typeof s){case"boolean":case"number":case"string":return s;case"object":break;default:return i}if(null===s)return i;if(s instanceof Array){let e=i;void 0!==e&&null!==e||(e=[]);let t=0;for(const r of s){var n=overlay(r,e[t]);void 0!==n&&(t<s.length?e[t]=n:e.push(n),++t)}return e}let e=i;void 0===e&&(e={});for(const t in s)e[t]=overlay(s[t],e[t]);return e}function createSubscription(e){function t(){return void 0!==e&&(t.active=!1,e(),!0)}return t.active=!0,t}let staticStyle=void 0;class FormHost{constructor(){this.form={defaults:{},elements:{}},this.errors={},this.refs={},this.enabled=!1,this.visible=!1,this.dismiss=!1,this.custom=!1,this.container=document.createElement("div"),this.eventIndex=0,this.eventQueue=[],this.mutuallyExclusiveSections={},this.nextFocus=!1,this.nextRefresh=!1,this.style=void 0}deriveLocale(){return DEFAULT_LOCALE}mount(){var e=this.container,t=e.parentNode;null==t&&document.body.appendChild(e),this.update()}unmount(){var e=this.container;const t=e.parentNode;void 0!==t&&null!==t&&t.removeChild(e)}observeFocus(e){this.enabled&&e instanceof HTMLElement&&(this.lastFocus&&this.lastFocus.target===e||this.setLastFocus(e))}focus(e){!0===(e=null==e?!1:e)&&(this.lastFocus=void 0),!1===e&&!1===(e=this.nextFocus)&&(e=!0),this.nextFocus=e,this.invalidate(!0!==e?e:void 0)}show(){const e=this.container;if(void 0===e)return!1;this.custom||void 0!==this.focusObserver||e.addEventListener("focus",this.focusObserver=e=>this.observeFocus(e.target),!0),this.enabled||(this.nextRefresh=!0,this.focus()),this.enforceAccordionConstraints();var t=this.errors;for(const r in t){const o=this.form.elements[r];void 0!==o&&null!==o&&(o.error=t[r],this.invalidate(r))}const s=[];let i=!1;for(const a of Object.keys(this.form.elements).map(e=>this.form.elements[e]).filter(e=>!!e.error&&!1!==e.visible)){const l=this.getParentSection(a);if(this.isAccordionSection(l)){var n=this.findName(l);const u=this.getMutuallyExclusiveSectionGroup(n);if(u){const c=s.find(e=>e.group===u);c?c.element.rowNumber>l.rowNumber&&(c.element=l):(s.push({group:u,element:l}),i=!0)}}else this.isSectionCollapsed(l)&&(l.collapsed=!1,i=!0)}for(const h of s)h.group.expandedSection=h.element;return i&&this.invalidate(),this.errors={},this.idle(),!1!==this.nextRefresh&&(this.enabled=!0,this.visible=!0,this.mount()),this.enabled}spin(){return void 0!==this.container&&(this.idle(),this.visible&&!this.enabled||(this.nextRefresh=!0,this.enabled=!1,this.visible=!0,this.mount()),this.visible)}hide(){return void 0!==this.container&&(this.idle(),this.visible&&(this.enabled=!1,this.visible=!1,this.unmount()),!0)}dispose(){if(this.dismiss)return!1;{this.dismiss=!0;const t=this.container;t.dispatchEvent(createEvent(eventName));var e=this.focusObserver;return void 0!==e&&t.removeEventListener("focus",e,!0),this.idle(),this.unmount(),this.refs={},presenter.releaseForm(this.container),this.container=void 0,this.lastFocus=void 0,!(this.eventTask=void 0)}}renderFocus(e,t){var s=this.nextFocus;if(this.enabled&&e instanceof HTMLElement)if(!1!==s)if(void 0!==t){if(t===s||!0===s&&void 0===this.lastFocus)return this.nextFocus=!1,this.setLastFocus(e,t),e.focus(),!0}else{const i=this.lastFocus?.target;if(!0===s&&i instanceof HTMLElement&&e.contains(i))return this.nextFocus=!1,i.focus(),!0}else if(!1===s&&t&&t!==this.lastFocus?.name&&this.isElementPositionBeforeLastFocused(t))return this.setLastFocus(e,t),e.focus(),!0;return!1}renderHtml(e,t){return"string"==typeof e?text.textToHtml(e):text.isMarkdown(e)?text.markdownToHtml(e.markdown,t):""}renderText(e){return"string"==typeof e?e:text.isMarkdown(e)?text.markdownToText(e.markdown):""}translateText(e){return"string"==typeof e||text.isMarkdown(e)?e:text.isStatus(e)?e.status:void 0}renderStyle(e){return"string"==typeof e?addStyleToDocument(e):staticStyle=staticStyle||addStyleToDocument(CSS)}renderVisual(e){return presenter.render(e)||presenter.renderNone(e)}qualifyDefault(e){var t=sort(this.form.elements);for(const r in t){var s=t[r];if(null!=s&&!1!==s.visible&&s.enabled){if(s.default)return e.value=s.value,r;var i=sort(s.items);if(null!=i)for(const o in i){var n=i[o];if(null!=n&&n.visible&&n.enabled&&n.default)return e.item=o,e.value=n.value,r}}}}qualify(e,t){var s;return null==t&&(t={}),"clicked"===e&&void 0===t.name&&(t.name=this.qualifyDefault(t)),t.type=e,void 0===t.routingKey&&(s=t.name,t.routingKey=void 0!==s?e+"$"+s:e),t}post(e,t){t=this.publish(e,t);const s=this.container;void 0!==s&&s.dispatchEvent(createEvent(eventName,t))}subscribe(s){const e=this.container;if(void 0===e)return createSubscription();const i=function(){s=void 0,e.removeEventListener(eventName,t)},t=function(e){const t=e.detail;void 0!==t?Bluebird.resolve().then(function(){"function"==typeof s&&s(t)}):i()};return e.addEventListener(eventName,t),createSubscription(i)}refresh(e){this.custom||("string"==typeof e?(e=this.refs[e],presenter.refresh(e)):(void 0===this.style&&(this.style=this.renderStyle()),this.refs={},presenter.refreshForm(this,this.container)))}invalidate(e){const t=this.nextRefresh;"string"==typeof e&&!0!==t&&(!1===t?this.nextRefresh={[e]:!0}:t[e]=!0),void 0!==e&&!0!==e||(this.nextRefresh=!0),!1===e&&!1===t&&(this.nextRefresh={})}update(){var e=this.nextRefresh;if(!0===e&&(this.nextRefresh=!1,this.refresh()),"object"==typeof e){this.nextRefresh=!1;for(const t in e)!0===e[t]&&this.refresh(t)}}idle(){const e=this.timerHandle;void 0!==e&&(this.timerHandle=void 0,e())}busy(){if(void 0===this.timerHandle&&void 0!==this.container){let e=setTimeout(()=>this.spin());this.timerHandle=function(){void 0!==e&&(clearTimeout(e),e=void 0)}}}publish(e,t){return this.enabled?(t=this.enqueue(e,t),0<this.eventQueue.length&&this.spin(),t):this.qualify(e,t)}enqueue(e,t){return t=this.qualify(e,t),void 0!==this.eventTask?(this.resolveEvent(t),this.eventTask=void 0):this.eventQueue.push(t),t}dequeue(){const e=this.eventQueue;if(0<e.length){var t=this.eventIndex,s=e[t++];return t>=e.length?e.length=this.eventIndex=0:this.eventIndex=t,s}}observe(){const t=this;return Bluebird.attempt(function(){if(void 0!==t.eventTask)return t.eventTask;var e=t.dequeue();return void 0!==e?e:t.show()?(t.eventTask=new Task(e=>{t.resolveEvent=e}),t.eventTask):void 0})}load(e,t){if(void 0===this.container)return!1;if(this.eventQueue.length=this.eventIndex=0,this.eventTask=void 0,this.errors={},this.lastFocus=void 0,this.nextFocus=!0,this.nextRefresh=!0,this.enqueue("load"),this.enqueue("prepare"),null!=e){e=overlay(e,e={defaults:{},elements:{}});this.form=overlay(t,e);for(const s in this.form.elements){let e=this.form.elements[s];if(e=overlay(e,{showFilter:!1,checked:!1,enabled:!0,hoisted:!1,visible:!0,overlay:!1,default:!1,validates:!1,readOnly:!1,require:!1,autoActivate:!1}),e.items)for(const i in e.items)e.items[i]=overlay(e.items[i],{enabled:!0,checked:!1,visible:!0,default:!1,validates:!1});this.form.elements[s]=e}}return!0}route(e){switch(e.type){case"changed":return this.cascade(e.name);case"prepare":return this.hydrate(e);case"suggest":return this.suggest(e);case"clicked":return this.click(e);case"validate":return this.verify(e);case"verify":return this.submit(e);case"checked":return this.changed(e)}return!1}changed(e){return this.enqueue("changed",{name:e.name,item:e.item,value:e.value}),!0}isElementValid(e,t=!0,s={status:void 0}){return null!=e&&(s.status=void 0,text.isStatus(e.error)&&"invalid"===e.error.status?!(s.status="invalid"):!0!==e.require||(this.isElementEffectivelyVisible(e)?!!this.isElementValueDefined(e)||!(s.status="missing"):t))}isElementEffectivelyVisible(e){return null!=e&&(!1!==this.getParentSection(e)?.visible&&!1!==e.visible)}isElementValueDefined(e){if(null==e)return!1;if("CheckBox"===e.type)return!0;var t=e.current;if(null!=t)return!0;t=e.value;if(null!=t&&""!==t)return!0;t=e.label;if(null!=t&&""!==t)return!0;var s=e.items;if(null!=s)for(const n in s){var i=s[n];if(null!=i&&!0===i.checked)return!0}return!1}trap(e){switch(e.type){case"populate":case"load":break;default:return!1}var t=e.name;const s=this.find(t);if(void 0===s||null===s)return!1;e=s.dependsOn;if("string"!=typeof e)return!1;e=this.find(e);return s.enabled=this.isElementEffectivelyVisible(e)&&this.isElementValueDefined(e),this.invalidate(t),!s.enabled}cascade(e){var t=this.find(e);if(null==t||!1===t.dependsOn)return!1;const s={[e]:!0};var i=sort(this.form.elements);for(const r in i){const o=i[r];var n=o.dependsOn;if("string"==typeof n){const a=this.find(n);void 0!==a&&"string"!=typeof a.dependsOn&&(a.dependsOn=!0),!0===s[n]&&(s[r]=!0,o.checked=!1,o.current=void 0,o.label=void 0,o.items=void 0,o.value=void 0,this.invalidate(r),this.enqueue("populate",{name:r}))}else o.dependsOn=!1}return!0}click(e){var t=this.form.elements[e.name];return null!=t&&"ButtonBar"==t.type&&this.validate(e)}hydrate(e){for(const t in sort(this.form.elements))this.enqueue("populate",{name:t}),this.enqueue("load",{name:t});return!0}shouldTriggerValidation(e){var t=this.find(e.name);if(null!=t&&"string"==typeof e.value){e=e.item;if("string"!=typeof e)return!0===t.validates;t=t.items;if(null!=t){e=t[e];if(null!=e)return!0===e.validates}}}validate(e){var t=this.shouldTriggerValidation(e);if(!0!==t)return!1===t&&(this.enqueue("end",{name:e.name,item:e.item,value:e.value,routingKey:"end"}),!0);{const n=this.errors={};var s=sort(this.form.elements);for(const r in s){var i=s[r];null!=i&&(n[r]=void 0,this.enqueue("validate",{name:r}))}return this.enqueue("verify",{name:e.name,item:e.item,value:e.value,routingKey:"verify"}),!0}}verify(e){var t=e.name,s=this.form.elements[t],e={status:void 0};return!this.isElementValid(s,!0,e)&&(e.status&&(this.errors[t]={status:e.status}),!1===this.nextFocus&&this.focus(t),!0)}suggest(e){const t=this.form.elements[e.name];return void 0!==t&&null!==t&&(t.items={message:{label:{status:"trivial"},enabled:!1}},this.invalidate(e.name),!0)}submit(e){return!this.hasErrors()&&(this.enqueue("submit",{name:e.name,item:e.item,value:e.value}),!0)}hasErrors(){var e=this.errors;for(const s in e){var t=e[s];if(null!=t)return!0}return!1}find(e){if(null!=e)return"string"==typeof(e="object"==typeof e?e.name:e)?this.form.elements[e]:void 0}findName(e){for(const t in this.form.elements)if(this.form.elements[t]===e)return t}coerceNumber(e){var t=this.deriveLocale();return new NumberParser(t).parse(e)}formatNumber(e,t){return t?.locale||((t=t||{}).locale=this.deriveLocale()),format(t,e)}renderCustom(e,t){if(e instanceof FormComponent)return renderers.element.renderCustom(e,t)}renderState(e,t,s){return!1}getParentSection(e){e=e.section;if(e){e="string"==typeof e?e:e.name;return this.form.elements[e]}}isSectionCollapsed(e){return!(!e||"Section"!==e.type||"collapsible-section"!==e.format&&"accordion-section"!==e.format)&&!0===e.collapsed}isElementPositionBeforeLastFocused(e){var t=this.lastFocus;if(e&&void 0!==t?.rowNumber&&void 0!==t.rowIndex){e=this.form.elements?.[e];if(e)return void 0!==e.rowNumber&&void 0!==e.rowIndex?e.rowNumber<t.rowNumber||e.rowNumber===t.rowNumber&&e.rowIndex<t.rowIndex:e.index<t.rowNumber||e.index===t.rowNumber&&0<t.rowIndex}return!1}setLastFocus(e,t){this.lastFocus={target:e},t&&(this.lastFocus.name=t,(t=this.form.elements?.[t])&&(void 0!==t.rowNumber&&void 0!==t.rowIndex?(this.lastFocus.rowNumber=t.rowNumber,this.lastFocus.rowIndex=t.rowIndex):(this.lastFocus.rowNumber=t.index,this.lastFocus.rowIndex=0)))}isSection(e){return"Section"===e?.type}isAccordionSection(e){return this.isSection(e)&&"accordion-section"===e.format}getAllSectionElements(){const e={};for(const s in this.form.elements){var t=this.form.elements[s];this.isSection(t)&&(e[s]=t)}return e}getMutuallyExclusiveSectionGroup(t){let s=this.mutuallyExclusiveSections[t];if(!s){var e=this.find(t);if(!this.isAccordionSection(e))return;s=new MutuallyExclusiveSectionGroup({elementName:t,element:e});e=this.getAllSectionElements();const r=Object.keys(sort(e,e=>e.rowNumber));t=r.indexOf(t);for(let e=t-1;0<=e;e--){const o=r[e];var i=this.find(o);if(!this.isAccordionSection(i))break;s.unshift({elementName:o,element:i})}for(let e=t+1;e<r.length;e++){const o=r[e];var n=this.find(o);if(!this.isAccordionSection(n))break;s.push({elementName:o,element:n})}s.forEach(e=>{this.mutuallyExclusiveSections[e.elementName]=s})}return s}updateAccordionSections(t){const e=this.getMutuallyExclusiveSectionGroup(t);e.forEach(e=>{e.element.collapsed=e.elementName!==t}),presenter.refreshForm(this,this.container)}enforceAccordionConstraints(){const e=[];for(const s of Object.keys(this.form.elements).map(e=>({elementName:e,element:this.form.elements[e]})).filter(e=>this.isAccordionSection(e.element)&&!1!==e.element.visible&&!0!==e.element.collapsed).sort((e,t)=>e.element.rowNumber-t.element.rowNumber)){var t=this.getMutuallyExclusiveSectionGroup(s.elementName);-1===e.indexOf(t)?e.push(t):s.element.collapsed=!0}}}export{defs,FormHost};
1
+ import Bluebird from"bluebird";import{Task}from"../Task.js";import{DEFAULT_LOCALE}from"../constants.js";import{FormComponent}from"./FormComponent.js";import*as defs from"./FormDefinition.js";import MutuallyExclusiveSectionGroup from"./MutuallyExclusiveSectionGroup.js";import NumberParser from"./NumberParser.js";import{FormElementTypes}from"./constants.js";import{format}from"./numberFormatter.js";import*as presenter from"./presenter.js";import{renderElement}from"./renderers.js";import{sort,text}from"./utils.js";const guid="C0166F74-982A-464E-9FB6-9605CB7649C1:",eventName=guid+"FormEvent";function createEvent(e,t){return new CustomEvent(e,{bubbles:!1,cancelable:!1,detail:t})}function overlay(i,s){switch(typeof i){case"boolean":case"number":case"string":return i;case"object":break;default:return s}if(null===i)return s;if(i instanceof Array){let e=s;void 0!==e&&null!==e||(e=[]);let t=0;for(const r of i){var n=overlay(r,e[t]);void 0!==n&&(t<i.length?e[t]=n:e.push(n),++t)}return e}let e=s;void 0===e&&(e={});for(const t in i)e[t]=overlay(i[t],e[t]);return e}function createSubscription(e){function t(){return void 0!==e&&(t.active=!1,e(),!0)}return t.active=!0,t}class FormHost{constructor(){this.form={defaults:{},elements:{}},this.errors={},this.refs={},this.enabled=!1,this.visible=!1,this.dismiss=!1,this.custom=!1,this.container=document.createElement("div"),this.eventIndex=0,this.eventQueue=[],this.mutuallyExclusiveSections={},this.nextFocus=!1,this.nextRefresh=!1,this.style=void 0}deriveLocale(){return DEFAULT_LOCALE}mount(){var e=this.container,t=e.parentNode;null==t&&document.body.appendChild(e),this.update()}unmount(){var e=this.container;const t=e.parentNode;void 0!==t&&null!==t&&t.removeChild(e)}observeFocus(e){this.enabled&&e instanceof HTMLElement&&(this.lastFocus&&this.lastFocus.target===e||this.setLastFocus(e))}focus(e){!0===(e=null==e?!1:e)&&(this.lastFocus=void 0),!1===e&&!1===(e=this.nextFocus)&&(e=!0),this.nextFocus=e,this.invalidate(!0!==e?e:void 0)}show(){const e=this.container;if(void 0===e)return!1;this.custom||void 0!==this.focusObserver||e.addEventListener("focus",this.focusObserver=e=>this.observeFocus(e.target),!0),this.enabled||(this.nextRefresh=!0,this.focus()),this.enforceAccordionConstraints();var t=this.errors;for(const i in t){const s=this.form.elements[i];void 0!==s&&null!==s&&(s.error=t[i],this.invalidate(i))}return this.idle(),!1!==this.nextRefresh&&(this.enabled=!0,this.visible=!0,this.mount()),this.enabled}isInvalid(e){return!!e.error&&!1!==e.visible}getInvalidElements(){return Object.keys(this.form.elements).map(e=>this.form.elements[e]).filter(this.isInvalid)}hasInvalidChild(e){for(const i in this.form.elements){var t=this.form.elements[i];if(this.isInvalid(t)&&this.getParentSection(t)===e)return!0}return!1}spin(){return void 0!==this.container&&(this.idle(),this.visible&&!this.enabled||(this.nextRefresh=!0,this.enabled=!1,this.visible=!0,this.mount()),this.visible)}hide(){return void 0!==this.container&&(this.idle(),this.visible&&(this.enabled=!1,this.visible=!1,this.unmount()),!0)}dispose(){if(this.dismiss)return!1;{this.dismiss=!0;const t=this.container;t.dispatchEvent(createEvent(eventName));var e=this.focusObserver;return void 0!==e&&t.removeEventListener("focus",e,!0),this.idle(),this.unmount(),this.refs={},presenter.releaseForm(this.container),this.container=void 0,this.lastFocus=void 0,!(this.eventTask=void 0)}}renderFocus(e,t){var i=this.nextFocus;if(this.enabled&&e instanceof HTMLElement)if(!1!==i)if(void 0!==t){if(t===i||!0===i&&void 0===this.lastFocus)return this.nextFocus=!1,this.setLastFocus(e,t),e.focus(),!0}else{const s=this.lastFocus?.target;if(!0===i&&s instanceof HTMLElement&&e.contains(s))return this.nextFocus=!1,s.focus(),!0}else if(!1===i&&t&&t!==this.lastFocus?.name&&this.isElementPositionBeforeLastFocused(t))return this.setLastFocus(e,t),e.focus(),!0;return!1}renderHtml(e,t){return"string"==typeof e?text.textToHtml(e):text.isMarkdown(e)?text.markdownToSafeHtml(e.markdown,{inline:t===defs.HTMLContentCategory.Phrasing}):""}renderText(e){return"string"==typeof e?e:text.isMarkdown(e)?text.markdownToText(e.markdown):""}translateText(e){return"string"==typeof e||text.isMarkdown(e)?e:text.isStatus(e)?e.status:void 0}renderVisual(e){return presenter.render(e)||presenter.renderNone(e)}qualifyDefault(e){var t=sort(this.form.elements);for(const r in t){var i=t[r];if(null!=i&&!1!==i.visible&&i.enabled){if(i.default)return e.value=i.value,r;var s=sort(i.items);if(null!=s)for(const o in s){var n=s[o];if(null!=n&&n.visible&&n.enabled&&n.default)return e.item=o,e.value=n.value,r}}}}qualify(e,t){var i;return null==t&&(t={}),"clicked"===e&&void 0===t.name&&(t.name=this.qualifyDefault(t)),t.type=e,void 0===t.routingKey&&(i=t.name,t.routingKey=void 0!==i?e+"$"+i:e),t}post(e,t){t=this.publish(e,t);const i=this.container;void 0!==i&&i.dispatchEvent(createEvent(eventName,t))}subscribe(i){const e=this.container;if(void 0===e)return createSubscription();const s=function(){i=void 0,e.removeEventListener(eventName,t)},t=function(e){const t=e.detail;void 0!==t?Bluebird.resolve().then(function(){"function"==typeof i&&i(t)}):s()};return e.addEventListener(eventName,t),createSubscription(s)}refresh(e){this.custom||("string"==typeof e?(e=this.refs[e],presenter.refresh(e)):(this.refs={},presenter.refreshForm(this,this.container)))}invalidate(e){const t=this.nextRefresh;"string"==typeof e&&!0!==t&&(!1===t?this.nextRefresh={[e]:!0}:t[e]=!0),void 0!==e&&!0!==e||(this.nextRefresh=!0),!1===e&&!1===t&&(this.nextRefresh={})}update(){var e=this.nextRefresh;if(!0===e&&(this.nextRefresh=!1,this.refresh()),"object"==typeof e){this.nextRefresh=!1;for(const t in e)!0===e[t]&&this.refresh(t)}}idle(){const e=this.timerHandle;void 0!==e&&(this.timerHandle=void 0,e())}busy(){if(void 0===this.timerHandle&&void 0!==this.container){let e=setTimeout(()=>this.spin());this.timerHandle=function(){void 0!==e&&(clearTimeout(e),e=void 0)}}}publish(e,t){return this.enabled?(t=this.enqueue(e,t),0<this.eventQueue.length&&this.spin(),t):this.qualify(e,t)}enqueue(e,t){return t=this.qualify(e,t),void 0!==this.eventTask?(this.resolveEvent(t),this.eventTask=void 0):this.eventQueue.push(t),t}dequeue(){const e=this.eventQueue;if(0<e.length){var t=this.eventIndex,i=e[t++];return t>=e.length?e.length=this.eventIndex=0:this.eventIndex=t,i}}observe(){const t=this;return Bluebird.attempt(function(){if(void 0!==t.eventTask)return t.eventTask;var e=t.dequeue();return void 0!==e?e:t.show()?(t.eventTask=new Task(e=>{t.resolveEvent=e}),t.eventTask):void 0})}load(e,t){if(void 0===this.container)return!1;if(this.eventQueue.length=this.eventIndex=0,this.eventTask=void 0,this.errors={},this.lastFocus=void 0,this.nextFocus=!0,this.nextRefresh=!0,this.enqueue("load"),this.enqueue("prepare"),null!=e){e=overlay(e,e={defaults:{},elements:{}});this.form=overlay(t,e);for(const i in this.form.elements){let e=this.form.elements[i];if(e=overlay(e,{showFilter:!1,checked:!1,enabled:!0,hoisted:!1,visible:!0,overlay:!1,default:!1,validates:!1,readOnly:!1,require:!1,autoActivate:!1}),e.items)for(const s in e.items)e.items[s]=overlay(e.items[s],{enabled:!0,checked:!1,visible:!0,default:!1,validates:!1});this.form.elements[i]=e}}return!0}route(e){switch(e.type){case"changed":return this.cascade(e.name);case"prepare":return this.hydrate(e);case"suggest":return this.suggest(e);case"clicked":return this.click(e);case"validate":return this.verify(e);case"verify":return this.submit(e);case"checked":return this.changed(e)}return!1}changed(e){return this.enqueue("changed",{name:e.name,item:e.item,value:e.value}),!0}isElementValid(e,t=!0,i={status:void 0}){return null!=e&&(i.status=void 0,text.isStatus(e.error)&&"invalid"===e.error.status?!(i.status="invalid"):!0!==e.require||(this.isElementEffectivelyVisible(e)?!!this.isElementValueDefined(e)||!(i.status="missing"):t))}isElementEffectivelyVisible(e){return null!=e&&(!1!==this.getParentSection(e)?.visible&&!1!==e.visible)}isElementValueDefined(e){if(null==e)return!1;if("CheckBox"===e.type)return!0;var t=e.current;if(null!=t)return!0;t=e.value;if(null!=t&&""!==t)return!0;if("Signature"!==e.type){t=e.label;if(null!=t&&""!==t)return!0}var i=e.items;if(null!=i)for(const n in i){var s=i[n];if(null!=s&&!0===s.checked)return!0}return!1}trap(e){switch(e.type){case"populate":case"load":case"suggest":break;default:return!1}var t=e.name;const i=this.find(t);if(void 0===i||null===i)return!1;e=i.dependsOn;if("string"!=typeof e)return!1;e=this.find(e);return i.enabled=this.isElementEffectivelyVisible(e)&&this.isElementValueDefined(e),this.invalidate(t),!i.enabled}cascade(e){var t=this.find(e);if(null==t||!1===t.dependsOn)return!1;const i={[e]:!0};var s=sort(this.form.elements);for(const r in s){const o=s[r];var n=o.dependsOn;if("string"==typeof n){const l=this.find(n);void 0!==l&&"string"!=typeof l.dependsOn&&(l.dependsOn=!0),!0===i[n]&&(i[r]=!0,o.checked=!1,o.current=void 0,o.label=void 0,o.items=void 0,o.value=void 0,this.invalidate(r),o.dependsOn===e&&this.enqueue("populate",{name:r}))}else o.dependsOn=!1}return!0}click(e){var t=this.form.elements[e.name];return null!=t&&"ButtonBar"==t.type&&this.validate(e)}hasInitialSelectionToDependOn(e){e=this.form.elements[e];return e.type===FormElementTypes.DROPDOWNLIST&&(void 0!==e.current&&null!==e.current)}hydrate(e){for(const i in sort(this.form.elements)){var t=this.form.elements[i].dependsOn;"string"==typeof t&&!this.hasInitialSelectionToDependOn(t)||this.enqueue("populate",{name:i}),this.enqueue("load",{name:i})}return!0}shouldTriggerValidation(e){var t=this.find(e.name);if(null!=t&&"string"==typeof e.value){e=e.item;if("string"!=typeof e)return!0===t.validates;t=t.items;if(null!=t){e=t[e];if(null!=e)return!0===e.validates}}}validate(e){var t=this.shouldTriggerValidation(e);if(!0!==t)return!1===t&&(this.enqueue("end",{name:e.name,item:e.item,value:e.value,routingKey:"end"}),!0);{const n=this.errors={};var i=sort(this.form.elements);for(const r in i){var s=i[r];null!=s&&(n[r]=void 0,this.enqueue("validate",{name:r}))}return this.enqueue("verify",{name:e.name,item:e.item,value:e.value,routingKey:"verify"}),!0}}verify(e){var t=e.name,i=this.form.elements[t],e={status:void 0};return!this.isElementValid(i,!0,e)&&(e.status&&(this.errors[t]={status:e.status}),!1===this.nextFocus&&this.focus(t),!0)}suggest(e){const t=this.form.elements[e.name];return void 0!==t&&null!==t&&(t.items={message:{label:{status:"trivial"},enabled:!1}},this.invalidate(e.name),!0)}submit(e){if(!this.hasErrors()){for(const r in this.form.elements)this.form.elements[r].error=void 0;return this.enqueue("submit",{name:e.name,item:e.item,value:e.value}),!0}var t=this.errors;for(const o in t){const l=this.form.elements[o];void 0!==l&&null!==l&&(l.error=t[o],this.invalidate(o))}const i=[];let s=!1;for(const a of this.getInvalidElements()){const u=this.getParentSection(a);if(this.isAccordionSection(u)){var n=this.findName(u);const h=this.getMutuallyExclusiveSectionGroup(n);if(h){const c=i.find(e=>e.group===h);c?c.element.rowNumber>u.rowNumber&&(c.element=u):(i.push({group:h,element:u}),s=!0)}}else this.isSectionCollapsed(u)&&(u.collapsed=!1,s=!0)}for(const d of i)d.group.expandedSection=d.element;return s&&this.invalidate(),!(this.errors={})}hasErrors(){var e=this.errors;for(const i in e){var t=e[i];if(null!=t)return!0}return!1}find(e){if(null!=e)return"string"==typeof(e="object"==typeof e?e.name:e)?this.form.elements[e]:void 0}findName(e){for(const t in this.form.elements)if(this.form.elements[t]===e)return t}coerceNumber(e){var t=this.deriveLocale();return new NumberParser(t).parse(e)}formatNumber(e,t){return t=t||{locale:this.deriveLocale()},format(t,e)}renderCustom(e,t){if(e instanceof FormComponent)return renderElement(FormElementTypes.CUSTOM,e,t)}renderState(e,t,i){return!1}getParentSection(e){e=e.section;if(e){e="string"==typeof e?e:e.name;return this.form.elements[e]}}isSectionCollapsed(e){return!(!e||"Section"!==e.type||!this.isCollapsibleSection(e)&&!this.isAccordionSection(e))&&!0===e.collapsed}isElementPositionBeforeLastFocused(e){var t=this.lastFocus;if(e&&void 0!==t?.rowNumber&&void 0!==t.rowIndex){e=this.form.elements?.[e];if(e)return void 0!==e.rowNumber&&void 0!==e.rowIndex?e.rowNumber<t.rowNumber||e.rowNumber===t.rowNumber&&e.rowIndex<t.rowIndex:e.index<t.rowNumber||e.index===t.rowNumber&&0<t.rowIndex}return!1}setLastFocus(e,t){this.lastFocus={target:e},t&&(this.lastFocus.name=t,(t=this.form.elements?.[t])&&(void 0!==t.rowNumber&&void 0!==t.rowIndex?(this.lastFocus.rowNumber=t.rowNumber,this.lastFocus.rowIndex=t.rowIndex):(this.lastFocus.rowNumber=t.index,this.lastFocus.rowIndex=0)))}isSection(e){return"Section"===e?.type}isAccordionSection(e){return this.isSection(e)&&"accordion-section"===e.format}isCollapsibleSection(e){return this.isSection(e)&&"collapsible-section"===e.format}getAllSectionElements(){const e={};for(const i in this.form.elements){var t=this.form.elements[i];this.isSection(t)&&(e[i]=t)}return e}getMutuallyExclusiveSectionGroup(t){let i=this.mutuallyExclusiveSections[t];if(!i){var e=this.find(t);if(!this.isAccordionSection(e))return;i=new MutuallyExclusiveSectionGroup({elementName:t,element:e});e=this.getAllSectionElements();const r=Object.keys(sort(e,e=>e.rowNumber));t=r.indexOf(t);for(let e=t-1;0<=e;e--){const o=r[e];var s=this.find(o);if(!this.isAccordionSection(s))break;i.unshift({elementName:o,element:s})}for(let e=t+1;e<r.length;e++){const o=r[e];var n=this.find(o);if(!this.isAccordionSection(n))break;i.push({elementName:o,element:n})}i.forEach(e=>{this.mutuallyExclusiveSections[e.elementName]=i})}return i}updateAccordionSections(t){const e=this.getMutuallyExclusiveSectionGroup(t);e.forEach(e=>{e.element.collapsed=e.elementName!==t}),presenter.refreshForm(this,this.container)}enforceAccordionConstraints(){const e=[];for(const i of Object.keys(this.form.elements).map(e=>({elementName:e,element:this.form.elements[e]})).filter(e=>this.isAccordionSection(e.element)&&!1!==e.element.visible&&!0!==e.element.collapsed).sort((e,t)=>e.element.rowNumber-t.element.rowNumber)){var t=this.getMutuallyExclusiveSectionGroup(i.elementName);-1===e.indexOf(t)?e.push(t):i.element.collapsed=!0}}async displayDialog(e,t){await Promise.resolve()}}export{defs,FormHost};
@@ -1,6 +1,11 @@
1
+ import { FormComponent } from "./FormComponent";
1
2
  import * as defs from "./FormDefinition";
2
3
  import { FormatOptions } from "./numberFormatter";
3
- /** Exposes various features to components that require features of the environment. */
4
+ import type { ComponentType, ReactNode } from "react";
5
+ /**
6
+ * Exposes various features to components that require features of the environment.
7
+ * @product This is intended for internal use only within VertiGIS Studio products.
8
+ */
4
9
  export interface FormPresenterHost {
5
10
  /** Indicates if the form is enabled or not. */
6
11
  enabled: boolean;
@@ -11,11 +16,11 @@ export interface FormPresenterHost {
11
16
  /** Disposes the form. */
12
17
  dispose(): void;
13
18
  /** Translates the supplied value. */
14
- translateText(content: defs.Text): string | defs.MarkdownRef | undefined;
19
+ translateText(content: defs.Text | undefined): string | defs.MarkdownRef | undefined;
15
20
  /** References all elements. */
16
- refs: {};
17
- /** Refreshes the entire form. */
18
- refresh(): void;
21
+ refs: {
22
+ [name: string]: FormComponent | undefined;
23
+ };
19
24
  /** Renders a custom element. */
20
25
  renderCustom(component: {}, element: defs.Element): any;
21
26
  /** Renders the focus. */
@@ -37,7 +42,7 @@ export interface FormPresenterHost {
37
42
  /** Coerces a number from a value. */
38
43
  coerceNumber(value: string): number;
39
44
  /** Formats a value into a string. */
40
- formatNumber(value: number, options: FormatOptions): string;
45
+ formatNumber(value: number, options?: FormatOptions): string;
41
46
  /**
42
47
  * Derives the current locale set by the host application (or default if undefined) will be returned.
43
48
  */
@@ -46,5 +51,26 @@ export interface FormPresenterHost {
46
51
  * Collapses all neighbouring accordion sections except the one specified.
47
52
  * @param expandedAccordionSection The name of the accordion section to be expanded. All others in the group will be collapsed.
48
53
  */
49
- updateAccordionSections(expandedAccordionSection: string): any;
54
+ updateAccordionSections(expandedAccordionSection: string): void;
55
+ /**
56
+ * Returns `true` if the element has a `type` of `"Section"` and a `format` of `"accordion-section"`, `false` otherwise.
57
+ * @param element The element to be inspected.
58
+ */
59
+ isAccordionSection(element: defs.Element): boolean;
60
+ /**
61
+ * Returns `true` if the element has a `type` of `"Section"` and a `format` of `"collapsible-section"`, `false` otherwise.
62
+ * @param element The element to be inspected.
63
+ */
64
+ isCollapsibleSection(element: defs.Element): boolean;
65
+ /**
66
+ * Shows a dialog in the context of the running application.
67
+ * @param children A function that produces the children for the dialog.
68
+ * @param DialogComponent The type of component to use as the dialog.
69
+ */
70
+ displayDialog(children: (closeDialog: () => void) => ReactNode, DialogComponent: ComponentType<any>): Promise<void>;
71
+ /**
72
+ * Returns `true` if the element has a `type` of `"Section"` and at least one visible child with `error` equal to `true`.
73
+ * @param element
74
+ */
75
+ hasInvalidChild(element: defs.Element): boolean;
50
76
  }
package/forms/common.d.ts CHANGED
@@ -11,10 +11,9 @@ export declare function getErrorId(elementId: string): string;
11
11
  * @param elementId The id of the DOM element representing the Form Element.
12
12
  * @param inputId (optional) The id of the DOM element representing the main input for the Form Element.
13
13
  * When specified, the title is marked as "for" that DOM element.
14
- * @param className (optional) An alternative class name to use instead of the default. This is used when some types of section present the title within a button.
15
14
  * @returns A title component, or `null` if there is no title.
16
15
  */
17
- export declare function renderTitle(host: FormPresenterHost, element: defs.Element, elementId: string, inputId?: string, className?: string): JSX.Element;
16
+ export declare function renderTitle(host: FormPresenterHost, element: defs.Element, elementId: string, inputId?: string): JSX.Element;
18
17
  /**
19
18
  * Renders the description for a Form Element.
20
19
  * @param host The form host.
@@ -22,7 +21,7 @@ export declare function renderTitle(host: FormPresenterHost, element: defs.Eleme
22
21
  * @param elementId The id of the DOM element representing the Form Element.
23
22
  * @returns A description component, or `null` if there is no description.
24
23
  */
25
- export declare function renderDescription(host: FormPresenterHost, element: defs.Element, elementId: string): JSX.Element;
24
+ export declare function renderDescription(host: FormPresenterHost, element: defs.Element, elementId: string, className?: string): JSX.Element;
26
25
  /**
27
26
  * Renders the accessible description for a Form Element.
28
27
  * @param host The form host.
@@ -48,16 +47,16 @@ export declare function renderError(host: FormPresenterHost, element: defs.Eleme
48
47
  * @param name The name of the Form Element.
49
48
  * @param host The form presenter host.
50
49
  */
51
- export declare function renderFocus(target: HTMLElement & {
50
+ export declare function renderFocus(target: (HTMLElement & {
52
51
  disabled?: boolean | undefined;
53
- }, name: string, host: FormPresenterHost): void;
52
+ }) | null, name: string | undefined, host: FormPresenterHost): void;
54
53
  /**
55
54
  * Returns a memoized function which asks the host to focus the provided element when the form is
56
55
  * initially shown. Ignores the specified target if it is null or disabled.
57
56
  * @param component The form component
58
57
  * @returns A memoized function that focuses a target HTML element.
59
58
  */
60
- export declare function useFocusCallback(component: FormComponent): (target: ReactNode & {
59
+ export declare function useFocusCallback(component: FormComponent): (target: (ReactNode & {
61
60
  disabled?: boolean;
62
61
  thumbRefs?: any[];
63
- }) => void;
62
+ }) | null) => void;
package/forms/common.js CHANGED
@@ -1 +1 @@
1
- import Box from"@vertigis/react-ui/Box";import FormHelperText from"@vertigis/react-ui/FormHelperText";import FormLabel from"@vertigis/react-ui/FormLabel";import{useCallback}from"react";import*as React from"react";import Markdown from"./components/Markdown.js";import{isMarkdown,markdownToText}from"./textUtilities.js";const ERROR_SUFFIX="-error",DESCRIPTION_SUFFIX="-description",TITLE_SUFFIX="-title";function getTitleId(e){return`${e}${TITLE_SUFFIX}`}function getDescriptionId(e){return`${e}${DESCRIPTION_SUFFIX}`}function getErrorId(e){return`${e}${ERROR_SUFFIX}`}function renderTitle(e,r,t,n,o){return r.title?(o=o||"form-element-title",React.createElement(FormLabel,{className:o,htmlFor:n,id:`${t}-label`},React.createElement(Markdown,{host:e,inline:!0,text:r.title}))):null}function renderDescription(e,r,t){return r.description?React.createElement(FormHelperText,{component:"div",disabled:!r.enabled,error:!1,id:`${t}-description`},React.createElement(Markdown,{host:e,text:r.description})):null}function renderAccessibleDescription(e,r,t){let n=e.translateText(r.accessibleDescription);return n||(r=e.translateText(r.description),n=isMarkdown(r)?markdownToText(r.markdown):r),n?React.createElement(Box,{sx:{display:"none"},id:`${t}-accessible-description`},n):null}function renderError(e,r){return r.error?React.createElement(FormHelperText,{component:"div",error:!0,role:"alert"},React.createElement(Markdown,{host:e,text:r.error})):null}function renderFocus(e,r,t){null===e||e.disabled||t.renderFocus(e,r)}function useFocusCallback(e){const{host:r,name:t}=e.props;return useCallback(e=>{null===(e=Array.isArray(e?.thumbRefs)&&0<e.thumbRefs.length?e.thumbRefs[0].current:e)||e.disabled||r.renderFocus(e,t)},[e.enabled,t,r])}export{getTitleId,getDescriptionId,getErrorId,renderTitle,renderDescription,renderAccessibleDescription,renderError,renderFocus,useFocusCallback};
1
+ import Box from"@vertigis/react-ui/Box";import FormHelperText from"@vertigis/react-ui/FormHelperText";import FormLabel from"@vertigis/react-ui/FormLabel";import{useCallback}from"react";import*as React from"react";import{formClasses}from"./components/Form.js";import Markdown from"./components/Markdown.js";import{hasContent,isMarkdown,markdownToText}from"./textUtilities.js";const ERROR_SUFFIX="-error",DESCRIPTION_SUFFIX="-description",TITLE_SUFFIX="-title";function getTitleId(e){return`${e}${TITLE_SUFFIX}`}function getDescriptionId(e){return`${e}${DESCRIPTION_SUFFIX}`}function getErrorId(e){return`${e}${ERROR_SUFFIX}`}function renderTitle(e,r,t,n){return hasContent(r.title)?React.createElement(FormLabel,{className:formClasses.formElementTitle,htmlFor:n,id:`${t}-label`,required:!!r.require},React.createElement(Markdown,{host:e,inline:!0,text:r.title})):null}function renderDescription(e,r,t,n){return hasContent(r.description)?React.createElement(FormHelperText,{className:n,component:"div",disabled:!r.enabled,error:!1,id:`${t}-description`},React.createElement(Markdown,{host:e,text:r.description})):null}function renderAccessibleDescription(e,r,t){let n=e.translateText(r.accessibleDescription);return n||(r=e.translateText(r.description),n=isMarkdown(r)?markdownToText(r.markdown):r),n?React.createElement(Box,{sx:{display:"none"},id:`${t}-accessible-description`},n):null}function renderError(e,r){return hasContent(r.error)?React.createElement(FormHelperText,{component:"div",error:!0,role:"alert"},React.createElement(Markdown,{host:e,text:r.error})):null}function renderFocus(e,r,t){null===e||e.disabled||t.renderFocus(e,r)}function useFocusCallback(e){const{host:r,name:t}=e.props;return useCallback(e=>{null===(e=Array.isArray(e?.thumbRefs)&&0<e.thumbRefs.length?e.thumbRefs[0].current:e)||e.disabled||r.renderFocus(e,t)},[e.enabled,t,r])}export{getTitleId,getDescriptionId,getErrorId,renderTitle,renderDescription,renderAccessibleDescription,renderError,renderFocus,useFocusCallback};
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { FormComponent } from "../FormComponent";
3
+ interface AccordionGroupProps {
4
+ /** The CSS class name of the root element. */
5
+ className?: string;
6
+ /**
7
+ * The `FormComponent` being used to render the Form Elements within this Component.
8
+ */
9
+ component: FormComponent;
10
+ }
11
+ /**
12
+ * This component contains a set of "Section" Form Elements with a `format` of `"accordion-section"`.
13
+ */
14
+ declare const AccordionGroup: ({ className, component }: AccordionGroupProps) => JSX.Element;
15
+ export default AccordionGroup;
@@ -0,0 +1 @@
1
+ import Box from"@vertigis/react-ui/Box";import{styled}from"@vertigis/react-ui/styles";import*as React from"react";const Root=styled(Box)(({theme:{spacing:o}})=>({marginBottom:o(4),marginTop:o(4)})),AccordionGroup=({className:o,component:t})=>{var t=t.props["children"];return React.createElement(Root,{className:o},t)};export default AccordionGroup;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { BaseFormElementProps } from "../FormElement";
3
+ /**
4
+ * The component for the "Auto Complete" Form Element.
5
+ */
6
+ declare const AutoComplete: ({ className, component, element }: BaseFormElementProps) => JSX.Element;
7
+ export default AutoComplete;
@@ -0,0 +1 @@
1
+ import BaseAutoComplete,{autocompleteClasses,HighlightOption}from"@vertigis/react-ui/Autocomplete";import FormLabelTextField from"@vertigis/react-ui/FormLabelTextField";import Popper from"@vertigis/react-ui/Popper";import Skeleton from"@vertigis/react-ui/Skeleton";import{styled}from"@vertigis/react-ui/styles";import clsx from"clsx";import{useEffect,useMemo,useRef,useState}from"react";import*as React from"react";import{ExclusiveTimer}from"../ExclusiveTimer.js";import FormElement from"../FormElement.js";import{useFocusCallback}from"../common.js";import{autoCompletePropertyConstraints}from"../elements/AutoComplete.js";import{getKeyString}from"../keyboard.js";import{getItemId,makeSafeClassName,makeUniqueId,sortAndFilterItems}from"../utils.js";const StyledAutoComplete=styled(BaseAutoComplete)(()=>({[`.${autocompleteClasses.endAdornment}`]:{right:1}})),popperClasses={skeletonOption:"skeleton-option"},StyledPopper=styled(Popper)(()=>({[`.${autocompleteClasses.listbox}`]:{[`.${autocompleteClasses.option}`]:{display:"block",[`&.${popperClasses.skeletonOption}`]:{'&[data-option-index="0"]':{span:{width:"70%"}},'&[data-option-index="1"]':{span:{width:"85%"}},'&[data-option-index="2"]':{span:{width:"55%"}}}}}})),StyledSkeleton=styled(Skeleton)(()=>({fontSize:"1.25rem",lineHeight:"inherit"})),pendingOption={enabled:!1,label:""},pendingOptions=[pendingOption,pendingOption,pendingOption],AutoComplete=({className:e,component:m,element:c})=>{const{host:d,name:r}=m.props,[t,o]=useState(),[n,a]=useState(""),[l,f]=useState([]),[s,g]=useState(null),i=useRef(!1),p=useRef(!1),u=`${makeUniqueId(r)}-input`;var v=useRef(d.renderText({status:"trivial"}));const y=d.renderText(c.prompt),C=d.renderText(c.tooltip),h=useFocusCallback(m),x=useRef({}),b=useRef({}),S=useMemo(()=>{let e=c.delay;return"number"==typeof e&&!isNaN(e)||(e=autoCompletePropertyConstraints.delay.default),Math.max(e,autoCompletePropertyConstraints.delay.minimum)},[c.delay]),k=useMemo(()=>{let e=c.minLength;return"number"==typeof e&&!isNaN(e)||(e=autoCompletePropertyConstraints.minLength.default),Math.max(e,autoCompletePropertyConstraints.minLength.minimum)},[c.minLength]),E=m.timer||(m.timer=new ExclusiveTimer),O=()=>{d.post("suggest",{name:r,value:c.value,argument:n,cancellationToken:E.cancellationToken}),f(pendingOptions)},T=()=>{c.items={},f([])};return useEffect(()=>{"clear"===t?T():"input"===t&&(i.current=!0,n.length>=k?(c.current=void 0,m.forceUpdate(),E.reset(),E.start(S,O)):0<Object.keys(c.items||{}).length&&T())},[t,n]),useEffect(()=>{var e,t=s?.value;c.value!==t&&(e=getItemId(s,x.current),e=(c.current=e)?b.current[e]:void 0,c.label=e,c.value=t,m.forceUpdate(),d.post("changed",{name:r,value:t,argument:e}))},[s]),useEffect(()=>{var{current:e,items:t,label:r,value:o}=sortAndFilterItems(c);c.current=e,c.label=r,c.value=o,m.forceUpdate();const n={};var a="string"==typeof e?e:void 0;let l=null;const s=[];for(const u in t){var i=t[u];s.push(i);var p=d.renderText(i.label);n[u]=p,a&&u===a&&(l=i)}b.current=n,x.current=t,f(s),g(l)},[c.items]),useEffect(()=>{var e="string"==typeof c.current?c.current:void 0,t=e?x.current[e]:void 0,e=e?b.current[e]:void 0;t?(c.label=e,c.value=t.value,m.forceUpdate(),a(e||"")):(c.value=void 0,m.forceUpdate(),i.current||a("")),g(t||null)},[c.current]),useEffect(()=>{i.current||p.current||a(""),i.current=!1,p.current=!1},[c.label]),React.createElement(FormElement,{className:e,component:m,element:c,inputId:u},React.createElement(StyledAutoComplete,{autoSelect:!0,clearOnEscape:!0,clearOnBlur:!1,disabled:!m.enabled,filterOptions:e=>e,getOptionDisabled:e=>!1===e.enabled,inputValue:n,noOptionsText:v.current,onBlur:()=>{1===l.length&&n.toLowerCase()===b.current[0]?.toLowerCase()?(a(b.current[0]),g(l[0])):(c.label=n,m.forceUpdate())},onChange:(e,t,r,o)=>{p.current=!0,g(t)},onInputChange:(e,t,r)=>{a(t),o(r)},onKeyDown:e=>{"enter"===getKeyString(e)&&e.stopPropagation()},options:l,PopperComponent:StyledPopper,renderOption:(e,t,{inputValue:r})=>{if(t===pendingOption){var o=clsx(e.className,popperClasses.skeletonOption);return React.createElement("li",{...e,className:o,key:e.id},React.createElement(StyledSkeleton,null))}o=getItemId(t,x.current),o={...e,className:clsx(e.className,t.styleName?makeSafeClassName(t.styleName):void 0),title:t.tooltip?d.renderText(t.tooltip):void 0,inputText:r,optionText:o?b.current[o]:""};return React.createElement(HighlightOption,{...o})},renderInput:e=>(e.inputProps={...e.inputProps,id:u,placeholder:y,title:C},React.createElement(FormLabelTextField,{error:!!c.error,...e,fullWidth:!0,inputRef:h})),value:s}))};export default AutoComplete;