@cratis/arc.react 18.0.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 (311) hide show
  1. package/Arc.tsx +44 -0
  2. package/ArcContext.ts +23 -0
  3. package/Bindings.ts +15 -0
  4. package/README.md +65 -0
  5. package/WellKnownBindings.ts +9 -0
  6. package/commands/CommandScope.tsx +57 -0
  7. package/commands/CommandScopeImplementation.ts +68 -0
  8. package/commands/ICommandScope.ts +31 -0
  9. package/commands/for_CommandScopeImplementation/FakeCommand.ts +59 -0
  10. package/commands/for_CommandScopeImplementation/when_executing_with_three_commands_were_two_having_changes.ts +25 -0
  11. package/commands/for_CommandScopeImplementation/when_none_of_the_added_commands_has_changes.ts +19 -0
  12. package/commands/for_CommandScopeImplementation/when_one_of_the_added_commands_has_changes.ts +19 -0
  13. package/commands/for_CommandScopeImplementation/when_property_changes_on_added_command.ts +26 -0
  14. package/commands/for_CommandScopeImplementation/when_reverting_with_three_commands_were_two_having_changes.ts +25 -0
  15. package/commands/for_CommandScopeImplementation/when_there_are_no_commands.ts +10 -0
  16. package/commands/for_useCommand/FakeCommand.ts +31 -0
  17. package/commands/for_useCommand/when_creating_instance.ts +41 -0
  18. package/commands/for_useCommand/when_creating_instance_with_initial_values.ts +38 -0
  19. package/commands/for_useCommand/when_creating_instance_without_optional_context_values.ts +37 -0
  20. package/commands/index.ts +8 -0
  21. package/commands/useCommand.ts +70 -0
  22. package/commands/useCommandScope.ts +9 -0
  23. package/dialogs/BusyIndicatorDialogRequest.ts +18 -0
  24. package/dialogs/CloseDialog.ts +9 -0
  25. package/dialogs/ConfirmationDialogRequest.ts +22 -0
  26. package/dialogs/DialogButtons.ts +28 -0
  27. package/dialogs/DialogComponents.tsx +113 -0
  28. package/dialogs/DialogContext.ts +33 -0
  29. package/dialogs/DialogProps.ts +14 -0
  30. package/dialogs/DialogResponse.ts +9 -0
  31. package/dialogs/DialogResult.ts +32 -0
  32. package/dialogs/ShowDialog.ts +9 -0
  33. package/dialogs/index.ts +16 -0
  34. package/dialogs/useBusyIndicator.ts +41 -0
  35. package/dialogs/useConfirmationDialog.ts +39 -0
  36. package/dialogs/useDialog.tsx +55 -0
  37. package/dist/cjs/Arc.d.ts +12 -0
  38. package/dist/cjs/Arc.d.ts.map +1 -0
  39. package/dist/cjs/Arc.js +25 -0
  40. package/dist/cjs/Arc.js.map +1 -0
  41. package/dist/cjs/ArcContext.d.ts +12 -0
  42. package/dist/cjs/ArcContext.d.ts.map +1 -0
  43. package/dist/cjs/ArcContext.js +16 -0
  44. package/dist/cjs/ArcContext.js.map +1 -0
  45. package/dist/cjs/Bindings.d.ts +5 -0
  46. package/dist/cjs/Bindings.d.ts.map +1 -0
  47. package/dist/cjs/Bindings.js +15 -0
  48. package/dist/cjs/Bindings.js.map +1 -0
  49. package/dist/cjs/WellKnownBindings.d.ts +4 -0
  50. package/dist/cjs/WellKnownBindings.d.ts.map +1 -0
  51. package/dist/cjs/WellKnownBindings.js +8 -0
  52. package/dist/cjs/WellKnownBindings.js.map +1 -0
  53. package/dist/cjs/commands/CommandScope.d.ts +13 -0
  54. package/dist/cjs/commands/CommandScope.d.ts.map +1 -0
  55. package/dist/cjs/commands/CommandScope.js +39 -0
  56. package/dist/cjs/commands/CommandScope.js.map +1 -0
  57. package/dist/cjs/commands/CommandScopeImplementation.d.ts +16 -0
  58. package/dist/cjs/commands/CommandScopeImplementation.d.ts.map +1 -0
  59. package/dist/cjs/commands/CommandScopeImplementation.js +52 -0
  60. package/dist/cjs/commands/CommandScopeImplementation.js.map +1 -0
  61. package/dist/cjs/commands/ICommandScope.d.ts +8 -0
  62. package/dist/cjs/commands/ICommandScope.d.ts.map +1 -0
  63. package/dist/cjs/commands/index.d.ts +6 -0
  64. package/dist/cjs/commands/index.d.ts.map +1 -0
  65. package/dist/cjs/commands/index.js +15 -0
  66. package/dist/cjs/commands/index.js.map +1 -0
  67. package/dist/cjs/commands/useCommand.d.ts +6 -0
  68. package/dist/cjs/commands/useCommand.d.ts.map +1 -0
  69. package/dist/cjs/commands/useCommand.js +47 -0
  70. package/dist/cjs/commands/useCommand.js.map +1 -0
  71. package/dist/cjs/commands/useCommandScope.d.ts +2 -0
  72. package/dist/cjs/commands/useCommandScope.d.ts.map +1 -0
  73. package/dist/cjs/commands/useCommandScope.js +11 -0
  74. package/dist/cjs/commands/useCommandScope.js.map +1 -0
  75. package/dist/cjs/dialogs/BusyIndicatorDialogRequest.d.ts +6 -0
  76. package/dist/cjs/dialogs/BusyIndicatorDialogRequest.d.ts.map +1 -0
  77. package/dist/cjs/dialogs/BusyIndicatorDialogRequest.js +13 -0
  78. package/dist/cjs/dialogs/BusyIndicatorDialogRequest.js.map +1 -0
  79. package/dist/cjs/dialogs/CloseDialog.d.ts +3 -0
  80. package/dist/cjs/dialogs/CloseDialog.d.ts.map +1 -0
  81. package/dist/cjs/dialogs/ConfirmationDialogRequest.d.ts +8 -0
  82. package/dist/cjs/dialogs/ConfirmationDialogRequest.d.ts.map +1 -0
  83. package/dist/cjs/dialogs/ConfirmationDialogRequest.js +15 -0
  84. package/dist/cjs/dialogs/ConfirmationDialogRequest.js.map +1 -0
  85. package/dist/cjs/dialogs/DialogButtons.d.ts +7 -0
  86. package/dist/cjs/dialogs/DialogButtons.d.ts.map +1 -0
  87. package/dist/cjs/dialogs/DialogButtons.js +10 -0
  88. package/dist/cjs/dialogs/DialogButtons.js.map +1 -0
  89. package/dist/cjs/dialogs/DialogComponents.d.ts +20 -0
  90. package/dist/cjs/dialogs/DialogComponents.d.ts.map +1 -0
  91. package/dist/cjs/dialogs/DialogComponents.js +34 -0
  92. package/dist/cjs/dialogs/DialogComponents.js.map +1 -0
  93. package/dist/cjs/dialogs/DialogContext.d.ts +10 -0
  94. package/dist/cjs/dialogs/DialogContext.d.ts.map +1 -0
  95. package/dist/cjs/dialogs/DialogContext.js +40 -0
  96. package/dist/cjs/dialogs/DialogContext.js.map +1 -0
  97. package/dist/cjs/dialogs/DialogProps.d.ts +5 -0
  98. package/dist/cjs/dialogs/DialogProps.d.ts.map +1 -0
  99. package/dist/cjs/dialogs/DialogResponse.d.ts +3 -0
  100. package/dist/cjs/dialogs/DialogResponse.d.ts.map +1 -0
  101. package/dist/cjs/dialogs/DialogResult.d.ts +8 -0
  102. package/dist/cjs/dialogs/DialogResult.d.ts.map +1 -0
  103. package/dist/cjs/dialogs/DialogResult.js +11 -0
  104. package/dist/cjs/dialogs/DialogResult.js.map +1 -0
  105. package/dist/cjs/dialogs/ShowDialog.d.ts +3 -0
  106. package/dist/cjs/dialogs/ShowDialog.d.ts.map +1 -0
  107. package/dist/cjs/dialogs/index.d.ts +14 -0
  108. package/dist/cjs/dialogs/index.d.ts.map +1 -0
  109. package/dist/cjs/dialogs/index.js +33 -0
  110. package/dist/cjs/dialogs/index.js.map +1 -0
  111. package/dist/cjs/dialogs/useBusyIndicator.d.ts +5 -0
  112. package/dist/cjs/dialogs/useBusyIndicator.d.ts.map +1 -0
  113. package/dist/cjs/dialogs/useBusyIndicator.js +21 -0
  114. package/dist/cjs/dialogs/useBusyIndicator.js.map +1 -0
  115. package/dist/cjs/dialogs/useConfirmationDialog.d.ts +5 -0
  116. package/dist/cjs/dialogs/useConfirmationDialog.d.ts.map +1 -0
  117. package/dist/cjs/dialogs/useConfirmationDialog.js +20 -0
  118. package/dist/cjs/dialogs/useConfirmationDialog.js.map +1 -0
  119. package/dist/cjs/dialogs/useDialog.d.ts +5 -0
  120. package/dist/cjs/dialogs/useDialog.d.ts.map +1 -0
  121. package/dist/cjs/dialogs/useDialog.js +34 -0
  122. package/dist/cjs/dialogs/useDialog.js.map +1 -0
  123. package/dist/cjs/identity/IdentityProvider.d.ts +10 -0
  124. package/dist/cjs/identity/IdentityProvider.d.ts.map +1 -0
  125. package/dist/cjs/identity/IdentityProvider.js +48 -0
  126. package/dist/cjs/identity/IdentityProvider.js.map +1 -0
  127. package/dist/cjs/identity/index.d.ts +3 -0
  128. package/dist/cjs/identity/index.d.ts.map +1 -0
  129. package/dist/cjs/identity/index.js +11 -0
  130. package/dist/cjs/identity/index.js.map +1 -0
  131. package/dist/cjs/identity/useIdentity.d.ts +3 -0
  132. package/dist/cjs/identity/useIdentity.d.ts.map +1 -0
  133. package/dist/cjs/identity/useIdentity.js +15 -0
  134. package/dist/cjs/identity/useIdentity.js.map +1 -0
  135. package/dist/cjs/index.d.ts +9 -0
  136. package/dist/cjs/index.d.ts.map +1 -0
  137. package/dist/cjs/index.js +20 -0
  138. package/dist/cjs/index.js.map +1 -0
  139. package/dist/cjs/queries/SetPage.d.ts +2 -0
  140. package/dist/cjs/queries/SetPage.d.ts.map +1 -0
  141. package/dist/cjs/queries/SetPageSize.d.ts +2 -0
  142. package/dist/cjs/queries/SetPageSize.d.ts.map +1 -0
  143. package/dist/cjs/queries/SetSorting.d.ts +3 -0
  144. package/dist/cjs/queries/SetSorting.d.ts.map +1 -0
  145. package/dist/cjs/queries/index.d.ts +6 -0
  146. package/dist/cjs/queries/index.d.ts.map +1 -0
  147. package/dist/cjs/queries/index.js +12 -0
  148. package/dist/cjs/queries/index.js.map +1 -0
  149. package/dist/cjs/queries/useObservableQuery.d.ts +16 -0
  150. package/dist/cjs/queries/useObservableQuery.d.ts.map +1 -0
  151. package/dist/cjs/queries/useObservableQuery.js +54 -0
  152. package/dist/cjs/queries/useObservableQuery.js.map +1 -0
  153. package/dist/cjs/queries/useQuery.d.ts +19 -0
  154. package/dist/cjs/queries/useQuery.d.ts.map +1 -0
  155. package/dist/cjs/queries/useQuery.js +76 -0
  156. package/dist/cjs/queries/useQuery.js.map +1 -0
  157. package/dist/esm/Arc.d.ts +12 -0
  158. package/dist/esm/Arc.d.ts.map +1 -0
  159. package/dist/esm/Arc.js +23 -0
  160. package/dist/esm/Arc.js.map +1 -0
  161. package/dist/esm/ArcContext.d.ts +12 -0
  162. package/dist/esm/ArcContext.d.ts.map +1 -0
  163. package/dist/esm/ArcContext.js +14 -0
  164. package/dist/esm/ArcContext.js.map +1 -0
  165. package/dist/esm/Bindings.d.ts +5 -0
  166. package/dist/esm/Bindings.d.ts.map +1 -0
  167. package/dist/esm/Bindings.js +13 -0
  168. package/dist/esm/Bindings.js.map +1 -0
  169. package/dist/esm/WellKnownBindings.d.ts +4 -0
  170. package/dist/esm/WellKnownBindings.d.ts.map +1 -0
  171. package/dist/esm/WellKnownBindings.js +6 -0
  172. package/dist/esm/WellKnownBindings.js.map +1 -0
  173. package/dist/esm/commands/CommandScope.d.ts +13 -0
  174. package/dist/esm/commands/CommandScope.d.ts.map +1 -0
  175. package/dist/esm/commands/CommandScope.js +36 -0
  176. package/dist/esm/commands/CommandScope.js.map +1 -0
  177. package/dist/esm/commands/CommandScopeImplementation.d.ts +16 -0
  178. package/dist/esm/commands/CommandScopeImplementation.d.ts.map +1 -0
  179. package/dist/esm/commands/CommandScopeImplementation.js +50 -0
  180. package/dist/esm/commands/CommandScopeImplementation.js.map +1 -0
  181. package/dist/esm/commands/ICommandScope.d.ts +8 -0
  182. package/dist/esm/commands/ICommandScope.d.ts.map +1 -0
  183. package/dist/esm/commands/ICommandScope.js +2 -0
  184. package/dist/esm/commands/ICommandScope.js.map +1 -0
  185. package/dist/esm/commands/index.d.ts +6 -0
  186. package/dist/esm/commands/index.d.ts.map +1 -0
  187. package/dist/esm/commands/index.js +5 -0
  188. package/dist/esm/commands/index.js.map +1 -0
  189. package/dist/esm/commands/useCommand.d.ts +6 -0
  190. package/dist/esm/commands/useCommand.d.ts.map +1 -0
  191. package/dist/esm/commands/useCommand.js +45 -0
  192. package/dist/esm/commands/useCommand.js.map +1 -0
  193. package/dist/esm/commands/useCommandScope.d.ts +2 -0
  194. package/dist/esm/commands/useCommandScope.d.ts.map +1 -0
  195. package/dist/esm/commands/useCommandScope.js +9 -0
  196. package/dist/esm/commands/useCommandScope.js.map +1 -0
  197. package/dist/esm/dialogs/BusyIndicatorDialogRequest.d.ts +6 -0
  198. package/dist/esm/dialogs/BusyIndicatorDialogRequest.d.ts.map +1 -0
  199. package/dist/esm/dialogs/BusyIndicatorDialogRequest.js +11 -0
  200. package/dist/esm/dialogs/BusyIndicatorDialogRequest.js.map +1 -0
  201. package/dist/esm/dialogs/CloseDialog.d.ts +3 -0
  202. package/dist/esm/dialogs/CloseDialog.d.ts.map +1 -0
  203. package/dist/esm/dialogs/CloseDialog.js +2 -0
  204. package/dist/esm/dialogs/CloseDialog.js.map +1 -0
  205. package/dist/esm/dialogs/ConfirmationDialogRequest.d.ts +8 -0
  206. package/dist/esm/dialogs/ConfirmationDialogRequest.d.ts.map +1 -0
  207. package/dist/esm/dialogs/ConfirmationDialogRequest.js +13 -0
  208. package/dist/esm/dialogs/ConfirmationDialogRequest.js.map +1 -0
  209. package/dist/esm/dialogs/DialogButtons.d.ts +7 -0
  210. package/dist/esm/dialogs/DialogButtons.d.ts.map +1 -0
  211. package/dist/esm/dialogs/DialogButtons.js +10 -0
  212. package/dist/esm/dialogs/DialogButtons.js.map +1 -0
  213. package/dist/esm/dialogs/DialogComponents.d.ts +20 -0
  214. package/dist/esm/dialogs/DialogComponents.d.ts.map +1 -0
  215. package/dist/esm/dialogs/DialogComponents.js +31 -0
  216. package/dist/esm/dialogs/DialogComponents.js.map +1 -0
  217. package/dist/esm/dialogs/DialogContext.d.ts +10 -0
  218. package/dist/esm/dialogs/DialogContext.d.ts.map +1 -0
  219. package/dist/esm/dialogs/DialogContext.js +18 -0
  220. package/dist/esm/dialogs/DialogContext.js.map +1 -0
  221. package/dist/esm/dialogs/DialogProps.d.ts +5 -0
  222. package/dist/esm/dialogs/DialogProps.d.ts.map +1 -0
  223. package/dist/esm/dialogs/DialogProps.js +2 -0
  224. package/dist/esm/dialogs/DialogProps.js.map +1 -0
  225. package/dist/esm/dialogs/DialogResponse.d.ts +3 -0
  226. package/dist/esm/dialogs/DialogResponse.d.ts.map +1 -0
  227. package/dist/esm/dialogs/DialogResponse.js +2 -0
  228. package/dist/esm/dialogs/DialogResponse.js.map +1 -0
  229. package/dist/esm/dialogs/DialogResult.d.ts +8 -0
  230. package/dist/esm/dialogs/DialogResult.d.ts.map +1 -0
  231. package/dist/esm/dialogs/DialogResult.js +11 -0
  232. package/dist/esm/dialogs/DialogResult.js.map +1 -0
  233. package/dist/esm/dialogs/ShowDialog.d.ts +3 -0
  234. package/dist/esm/dialogs/ShowDialog.d.ts.map +1 -0
  235. package/dist/esm/dialogs/ShowDialog.js +2 -0
  236. package/dist/esm/dialogs/ShowDialog.js.map +1 -0
  237. package/dist/esm/dialogs/index.d.ts +14 -0
  238. package/dist/esm/dialogs/index.d.ts.map +1 -0
  239. package/dist/esm/dialogs/index.js +10 -0
  240. package/dist/esm/dialogs/index.js.map +1 -0
  241. package/dist/esm/dialogs/useBusyIndicator.d.ts +5 -0
  242. package/dist/esm/dialogs/useBusyIndicator.d.ts.map +1 -0
  243. package/dist/esm/dialogs/useBusyIndicator.js +19 -0
  244. package/dist/esm/dialogs/useBusyIndicator.js.map +1 -0
  245. package/dist/esm/dialogs/useConfirmationDialog.d.ts +5 -0
  246. package/dist/esm/dialogs/useConfirmationDialog.d.ts.map +1 -0
  247. package/dist/esm/dialogs/useConfirmationDialog.js +18 -0
  248. package/dist/esm/dialogs/useConfirmationDialog.js.map +1 -0
  249. package/dist/esm/dialogs/useDialog.d.ts +5 -0
  250. package/dist/esm/dialogs/useDialog.d.ts.map +1 -0
  251. package/dist/esm/dialogs/useDialog.js +32 -0
  252. package/dist/esm/dialogs/useDialog.js.map +1 -0
  253. package/dist/esm/identity/IdentityProvider.d.ts +10 -0
  254. package/dist/esm/identity/IdentityProvider.d.ts.map +1 -0
  255. package/dist/esm/identity/IdentityProvider.js +45 -0
  256. package/dist/esm/identity/IdentityProvider.js.map +1 -0
  257. package/dist/esm/identity/index.d.ts +3 -0
  258. package/dist/esm/identity/index.d.ts.map +1 -0
  259. package/dist/esm/identity/index.js +3 -0
  260. package/dist/esm/identity/index.js.map +1 -0
  261. package/dist/esm/identity/useIdentity.d.ts +3 -0
  262. package/dist/esm/identity/useIdentity.d.ts.map +1 -0
  263. package/dist/esm/identity/useIdentity.js +13 -0
  264. package/dist/esm/identity/useIdentity.js.map +1 -0
  265. package/dist/esm/index.d.ts +9 -0
  266. package/dist/esm/index.d.ts.map +1 -0
  267. package/dist/esm/index.js +12 -0
  268. package/dist/esm/index.js.map +1 -0
  269. package/dist/esm/queries/SetPage.d.ts +2 -0
  270. package/dist/esm/queries/SetPage.d.ts.map +1 -0
  271. package/dist/esm/queries/SetPage.js +2 -0
  272. package/dist/esm/queries/SetPage.js.map +1 -0
  273. package/dist/esm/queries/SetPageSize.d.ts +2 -0
  274. package/dist/esm/queries/SetPageSize.d.ts.map +1 -0
  275. package/dist/esm/queries/SetPageSize.js +2 -0
  276. package/dist/esm/queries/SetPageSize.js.map +1 -0
  277. package/dist/esm/queries/SetSorting.d.ts +3 -0
  278. package/dist/esm/queries/SetSorting.d.ts.map +1 -0
  279. package/dist/esm/queries/SetSorting.js +2 -0
  280. package/dist/esm/queries/SetSorting.js.map +1 -0
  281. package/dist/esm/queries/index.d.ts +6 -0
  282. package/dist/esm/queries/index.d.ts.map +1 -0
  283. package/dist/esm/queries/index.js +3 -0
  284. package/dist/esm/queries/index.js.map +1 -0
  285. package/dist/esm/queries/useObservableQuery.d.ts +16 -0
  286. package/dist/esm/queries/useObservableQuery.d.ts.map +1 -0
  287. package/dist/esm/queries/useObservableQuery.js +51 -0
  288. package/dist/esm/queries/useObservableQuery.js.map +1 -0
  289. package/dist/esm/queries/useQuery.d.ts +19 -0
  290. package/dist/esm/queries/useQuery.d.ts.map +1 -0
  291. package/dist/esm/queries/useQuery.js +73 -0
  292. package/dist/esm/queries/useQuery.js.map +1 -0
  293. package/dist/esm/tsconfig.tsbuildinfo +1 -0
  294. package/global.d.ts +11 -0
  295. package/identity/IdentityProvider.tsx +61 -0
  296. package/identity/for_IdentityProvider/when_refreshing_identity.ts +59 -0
  297. package/identity/index.ts +5 -0
  298. package/identity/useIdentity.ts +19 -0
  299. package/index.ts +18 -0
  300. package/package.json +69 -0
  301. package/queries/SetPage.ts +7 -0
  302. package/queries/SetPageSize.ts +7 -0
  303. package/queries/SetSorting.ts +9 -0
  304. package/queries/for_useQuery/FakeQuery.ts +25 -0
  305. package/queries/for_useQuery/when_creating_instance.ts +63 -0
  306. package/queries/for_useQuery/when_creating_instance_with_sorting.ts +55 -0
  307. package/queries/for_useQuery/when_creating_instance_without_optional_context_values.ts +59 -0
  308. package/queries/for_useQueryWithPaging/when_creating_instance_with_paging.ts +67 -0
  309. package/queries/index.ts +8 -0
  310. package/queries/useObservableQuery.ts +83 -0
  311. package/queries/useQuery.ts +113 -0
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var tsyringe = require('tsyringe');
4
+ var queries = require('@cratis/arc/queries');
5
+ var WellKnownBindings = require('./WellKnownBindings.js');
6
+
7
+ class Bindings {
8
+ static initialize(microservice, apiBasePath, origin, httpHeadersCallback) {
9
+ tsyringe.container.registerSingleton(WellKnownBindings.WellKnownBindings.microservice, microservice);
10
+ tsyringe.container.register(queries.IQueryProvider, { useValue: new queries.QueryProvider(microservice, apiBasePath ?? '', origin ?? '', httpHeadersCallback ?? (() => ({}))) });
11
+ }
12
+ }
13
+
14
+ exports.Bindings = Bindings;
15
+ //# sourceMappingURL=Bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bindings.js","sources":["../../Bindings.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { container } from 'tsyringe';\nimport { IQueryProvider, QueryProvider } from '@cratis/arc/queries';\nimport { Constructor } from '@cratis/fundamentals';\nimport { WellKnownBindings } from './WellKnownBindings';\nimport { GetHttpHeaders } from '@cratis/arc';\n\nexport class Bindings {\n static initialize(microservice: string, apiBasePath?: string, origin?: string, httpHeadersCallback?: GetHttpHeaders): void {\n container.registerSingleton(WellKnownBindings.microservice, microservice);\n container.register(IQueryProvider as Constructor<IQueryProvider>, { useValue: new QueryProvider(microservice, apiBasePath ?? '', origin ?? '', httpHeadersCallback ?? (() => ({}))) });\n }\n}"],"names":["container","WellKnownBindings","IQueryProvider","QueryProvider"],"mappings":";;;;;;MASa,QAAQ,CAAA;IACjB,OAAO,UAAU,CAAC,YAAoB,EAAE,WAAoB,EAAE,MAAe,EAAE,mBAAoC,EAAA;QAC/GA,kBAAS,CAAC,iBAAiB,CAACC,mCAAiB,CAAC,YAAY,EAAE,YAAY,CAAC;AACzE,QAAAD,kBAAS,CAAC,QAAQ,CAACE,sBAA6C,EAAE,EAAE,QAAQ,EAAE,IAAIC,qBAAa,CAAC,YAAY,EAAE,WAAW,IAAI,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,mBAAmB,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1L;AACH;;;;"}
@@ -0,0 +1,4 @@
1
+ export declare const WellKnownBindings: {
2
+ microservice: string;
3
+ };
4
+ //# sourceMappingURL=WellKnownBindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WellKnownBindings.d.ts","sourceRoot":"","sources":["../../WellKnownBindings.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB;;CAE7B,CAAC"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ const WellKnownBindings = {
4
+ microservice: 'Microservice'
5
+ };
6
+
7
+ exports.WellKnownBindings = WellKnownBindings;
8
+ //# sourceMappingURL=WellKnownBindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WellKnownBindings.js","sources":["../../WellKnownBindings.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Well-known IoC binding constants.\n */\nexport const WellKnownBindings = {\n microservice: 'Microservice'\n};\n"],"names":[],"mappings":";;AAMO,MAAM,iBAAiB,GAAG;AAC7B,IAAA,YAAY,EAAE;;;;;"}
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { Command, CommandResult } from '@cratis/arc/commands';
3
+ import { ICommandScope } from './ICommandScope';
4
+ export declare const CommandScopeContext: React.Context<ICommandScope>;
5
+ export type CommandScopeChanged = (hasChanges: boolean) => void;
6
+ export type CommandScopeExecute = () => Promise<Map<Command, CommandResult>>;
7
+ export type AddCommand = (command: Command) => void;
8
+ export interface ICommandScopeProps {
9
+ children?: JSX.Element | JSX.Element[];
10
+ setHasChanges?: CommandScopeChanged;
11
+ }
12
+ export declare const CommandScope: (props: ICommandScopeProps) => import("react/jsx-runtime").JSX.Element;
13
+ //# sourceMappingURL=CommandScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandScope.d.ts","sourceRoot":"","sources":["../../../commands/CommandScope.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,aAAa,EAAkB,MAAM,sBAAsB,CAAC;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAahD,eAAO,MAAM,mBAAmB,8BAAiE,CAAC;AAElG,MAAM,MAAM,mBAAmB,GAAG,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;AAChE,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;AAE7E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IAC/B,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACvC,aAAa,CAAC,EAAE,mBAAmB,CAAC;CACvC;AAED,eAAO,MAAM,YAAY,GAAI,OAAO,kBAAkB,4CAyBrD,CAAC"}
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var commands = require('@cratis/arc/commands');
6
+ var CommandScopeImplementation = require('./CommandScopeImplementation.js');
7
+
8
+ const defaultCommandScopeContext = {
9
+ addCommand: () => { },
10
+ execute: async () => {
11
+ return new commands.CommandResults(new Map());
12
+ },
13
+ hasChanges: false,
14
+ revertChanges: () => { }
15
+ };
16
+ const CommandScopeContext = React.createContext(defaultCommandScopeContext);
17
+ const CommandScope = (props) => {
18
+ const [hasChanges, setHasChanges] = React.useState(false);
19
+ const [commandScope, setCommandScope] = React.useState(defaultCommandScopeContext);
20
+ React.useEffect(() => {
21
+ const commandScopeImplementation = new CommandScopeImplementation.CommandScopeImplementation((value) => {
22
+ setHasChanges(value);
23
+ });
24
+ setCommandScope(commandScopeImplementation);
25
+ }, []);
26
+ if (commandScope) {
27
+ commandScope.hasChanges = hasChanges;
28
+ }
29
+ return (jsxRuntime.jsx(CommandScopeContext.Provider, { value: {
30
+ addCommand: (command) => commandScope.addCommand(command),
31
+ execute: () => commandScope.execute(),
32
+ revertChanges: () => commandScope.revertChanges(),
33
+ hasChanges
34
+ }, children: props.children }));
35
+ };
36
+
37
+ exports.CommandScope = CommandScope;
38
+ exports.CommandScopeContext = CommandScopeContext;
39
+ //# sourceMappingURL=CommandScope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandScope.js","sources":["../../../commands/CommandScope.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React, { useEffect, useState } from 'react';\nimport { Command, CommandResult, CommandResults } from '@cratis/arc/commands';\nimport { CommandScopeImplementation } from './CommandScopeImplementation';\nimport { ICommandScope } from './ICommandScope';\n\n/* eslint-disable @typescript-eslint/no-empty-function */\nconst defaultCommandScopeContext: ICommandScope = {\n addCommand: () => { },\n execute: async () => {\n return new CommandResults(new Map());\n },\n hasChanges: false,\n revertChanges: () => { }\n};\n/* eslint-enable @typescript-eslint/no-empty-function */\n\nexport const CommandScopeContext = React.createContext<ICommandScope>(defaultCommandScopeContext);\n\nexport type CommandScopeChanged = (hasChanges: boolean) => void;\nexport type CommandScopeExecute = () => Promise<Map<Command, CommandResult>>;\n\nexport type AddCommand = (command: Command) => void;\n\nexport interface ICommandScopeProps {\n children?: JSX.Element | JSX.Element[];\n setHasChanges?: CommandScopeChanged;\n}\n\nexport const CommandScope = (props: ICommandScopeProps) => {\n const [hasChanges, setHasChanges] = useState(false);\n const [commandScope, setCommandScope] = useState<ICommandScope>(defaultCommandScopeContext);\n\n useEffect(() => {\n const commandScopeImplementation = new CommandScopeImplementation((value) => {\n setHasChanges(value);\n });\n setCommandScope(commandScopeImplementation);\n }, []);\n\n if (commandScope) {\n commandScope.hasChanges = hasChanges;\n }\n\n return (\n <CommandScopeContext.Provider value={{\n addCommand: (command) => commandScope!.addCommand(command),\n execute: () => commandScope.execute(),\n revertChanges: () => commandScope.revertChanges(),\n hasChanges\n }}>\n {props.children}\n </CommandScopeContext.Provider>\n );\n};\n"],"names":["CommandResults","useState","useEffect","CommandScopeImplementation","_jsx"],"mappings":";;;;;;;AASA,MAAM,0BAA0B,GAAkB;AAC9C,IAAA,UAAU,EAAE,MAAK,EAAG,CAAC;IACrB,OAAO,EAAE,YAAW;AAChB,QAAA,OAAO,IAAIA,uBAAc,CAAC,IAAI,GAAG,EAAE,CAAC;IACxC,CAAC;AACD,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,aAAa,EAAE,MAAK,EAAG;CAC1B;AAGM,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAAgB,0BAA0B;AAYzF,MAAM,YAAY,GAAG,CAAC,KAAyB,KAAI;IACtD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;IACnD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAGA,cAAQ,CAAgB,0BAA0B,CAAC;IAE3FC,eAAS,CAAC,MAAK;QACX,MAAM,0BAA0B,GAAG,IAAIC,qDAA0B,CAAC,CAAC,KAAK,KAAI;YACxE,aAAa,CAAC,KAAK,CAAC;AACxB,QAAA,CAAC,CAAC;QACF,eAAe,CAAC,0BAA0B,CAAC;IAC/C,CAAC,EAAE,EAAE,CAAC;IAEN,IAAI,YAAY,EAAE;AACd,QAAA,YAAY,CAAC,UAAU,GAAG,UAAU;IACxC;AAEA,IAAA,QACIC,cAAA,CAAC,mBAAmB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE;YACjC,UAAU,EAAE,CAAC,OAAO,KAAK,YAAa,CAAC,UAAU,CAAC,OAAO,CAAC;AAC1D,YAAA,OAAO,EAAE,MAAM,YAAY,CAAC,OAAO,EAAE;AACrC,YAAA,aAAa,EAAE,MAAM,YAAY,CAAC,aAAa,EAAE;YACjD;AACH,SAAA,EAAA,QAAA,EACI,KAAK,CAAC,QAAQ,EAAA,CACY;AAEvC;;;;;"}
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { ICommand, CommandResults } from '@cratis/arc/commands';
3
+ import { ICommandScope } from './ICommandScope';
4
+ export declare class CommandScopeImplementation implements ICommandScope {
5
+ private readonly _setHasChanges;
6
+ private _commands;
7
+ private _hasChanges;
8
+ constructor(_setHasChanges: React.Dispatch<React.SetStateAction<boolean>>);
9
+ get hasChanges(): boolean;
10
+ set hasChanges(value: boolean);
11
+ addCommand(command: ICommand): void;
12
+ execute(): Promise<CommandResults>;
13
+ revertChanges(): void;
14
+ private evaluateHasChanges;
15
+ }
16
+ //# sourceMappingURL=CommandScopeImplementation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandScopeImplementation.d.ts","sourceRoot":"","sources":["../../../commands/CommandScopeImplementation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,qBAAa,0BAA2B,YAAW,aAAa;IAIhD,OAAO,CAAC,QAAQ,CAAC,cAAc;IAH3C,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,WAAW,CAAS;gBAEC,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAI1F,IAAI,UAAU,IAAI,OAAO,CAExB;IAED,IAAI,UAAU,CAAC,KAAK,EAAE,OAAO,EAE5B;IAGD,UAAU,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IAW7B,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC;IAYxC,aAAa;IAKb,OAAO,CAAC,kBAAkB;CAW7B"}
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ var commands = require('@cratis/arc/commands');
4
+
5
+ class CommandScopeImplementation {
6
+ _setHasChanges;
7
+ _commands = [];
8
+ _hasChanges = false;
9
+ constructor(_setHasChanges) {
10
+ this._setHasChanges = _setHasChanges;
11
+ }
12
+ get hasChanges() {
13
+ return this._hasChanges;
14
+ }
15
+ set hasChanges(value) {
16
+ this._hasChanges = value;
17
+ }
18
+ addCommand(command) {
19
+ if (this._commands.some(_ => _ == command)) {
20
+ return;
21
+ }
22
+ this._commands.push(command);
23
+ this.evaluateHasChanges();
24
+ command.onPropertyChanged(this.evaluateHasChanges, this);
25
+ }
26
+ async execute() {
27
+ const commandsToCommandResult = new Map();
28
+ for (const command of this._commands.filter(_ => _.hasChanges === true)) {
29
+ const commandResult = await command.execute();
30
+ commandsToCommandResult.set(command, commandResult);
31
+ }
32
+ this.evaluateHasChanges();
33
+ return new commands.CommandResults(commandsToCommandResult);
34
+ }
35
+ revertChanges() {
36
+ this._commands.forEach(command => command.revertChanges());
37
+ this.evaluateHasChanges();
38
+ }
39
+ evaluateHasChanges() {
40
+ let hasCommandChanges = false;
41
+ this._commands.forEach(command => {
42
+ if (command.hasChanges) {
43
+ hasCommandChanges = true;
44
+ }
45
+ });
46
+ this._hasChanges = hasCommandChanges;
47
+ this._setHasChanges(hasCommandChanges);
48
+ }
49
+ }
50
+
51
+ exports.CommandScopeImplementation = CommandScopeImplementation;
52
+ //# sourceMappingURL=CommandScopeImplementation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandScopeImplementation.js","sources":["../../../commands/CommandScopeImplementation.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React from 'react';\nimport { ICommand, CommandResults } from '@cratis/arc/commands';\nimport { ICommandScope } from './ICommandScope';\n\n\n/**\n * Represents an implementation of {@link ICommandScope}.\n */\nexport class CommandScopeImplementation implements ICommandScope {\n private _commands: ICommand[] = [];\n private _hasChanges = false;\n\n constructor(private readonly _setHasChanges: React.Dispatch<React.SetStateAction<boolean>>) {\n }\n\n /** @inheritdoc */\n get hasChanges(): boolean {\n return this._hasChanges;\n }\n\n set hasChanges(value: boolean) {\n this._hasChanges = value;\n }\n\n /** @inheritdoc */\n addCommand(command: ICommand): void {\n if (this._commands.some(_ => _ == command)) {\n return;\n }\n\n this._commands.push(command);\n this.evaluateHasChanges();\n command.onPropertyChanged(this.evaluateHasChanges, this);\n }\n\n /** @inheritdoc */\n async execute(): Promise<CommandResults> {\n const commandsToCommandResult = new Map();\n\n for (const command of this._commands.filter(_ => _.hasChanges === true)) {\n const commandResult = await command.execute();\n commandsToCommandResult.set(command, commandResult);\n }\n this.evaluateHasChanges();\n return new CommandResults(commandsToCommandResult);\n }\n\n /** @inheritdoc */\n revertChanges() {\n this._commands.forEach(command => command.revertChanges());\n this.evaluateHasChanges();\n }\n\n private evaluateHasChanges() {\n let hasCommandChanges = false;\n this._commands.forEach(command => {\n if (command.hasChanges) {\n hasCommandChanges = true;\n }\n });\n\n this._hasChanges = hasCommandChanges;\n this._setHasChanges(hasCommandChanges);\n }\n}\n"],"names":["CommandResults"],"mappings":";;;;MAWa,0BAA0B,CAAA;AAIN,IAAA,cAAA;IAHrB,SAAS,GAAe,EAAE;IAC1B,WAAW,GAAG,KAAK;AAE3B,IAAA,WAAA,CAA6B,cAA6D,EAAA;QAA7D,IAAA,CAAA,cAAc,GAAd,cAAc;IAC3C;AAGA,IAAA,IAAI,UAAU,GAAA;QACV,OAAO,IAAI,CAAC,WAAW;IAC3B;IAEA,IAAI,UAAU,CAAC,KAAc,EAAA;AACzB,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK;IAC5B;AAGA,IAAA,UAAU,CAAC,OAAiB,EAAA;AACxB,QAAA,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,EAAE;YACxC;QACJ;AAEA,QAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,kBAAkB,EAAE;QACzB,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC;IAC5D;AAGA,IAAA,MAAM,OAAO,GAAA;AACT,QAAA,MAAM,uBAAuB,GAAG,IAAI,GAAG,EAAE;QAEzC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,EAAE;AACrE,YAAA,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE;AAC7C,YAAA,uBAAuB,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC;QACvD;QACA,IAAI,CAAC,kBAAkB,EAAE;AACzB,QAAA,OAAO,IAAIA,uBAAc,CAAC,uBAAuB,CAAC;IACtD;IAGA,aAAa,GAAA;AACT,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;QAC1D,IAAI,CAAC,kBAAkB,EAAE;IAC7B;IAEQ,kBAAkB,GAAA;QACtB,IAAI,iBAAiB,GAAG,KAAK;AAC7B,QAAA,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,IAAG;AAC7B,YAAA,IAAI,OAAO,CAAC,UAAU,EAAE;gBACpB,iBAAiB,GAAG,IAAI;YAC5B;AACJ,QAAA,CAAC,CAAC;AAEF,QAAA,IAAI,CAAC,WAAW,GAAG,iBAAiB;AACpC,QAAA,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC;IAC1C;AACH;;;;"}
@@ -0,0 +1,8 @@
1
+ import { ICommand, CommandResults } from '@cratis/arc/commands';
2
+ export interface ICommandScope {
3
+ hasChanges: boolean;
4
+ addCommand(command: ICommand): void;
5
+ execute(): Promise<CommandResults>;
6
+ revertChanges(): void;
7
+ }
8
+ //# sourceMappingURL=ICommandScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ICommandScope.d.ts","sourceRoot":"","sources":["../../../commands/ICommandScope.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKhE,MAAM,WAAW,aAAa;IAI1B,UAAU,EAAE,OAAO,CAAC;IAMpB,UAAU,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IAMpC,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC;IAKnC,aAAa,IAAI,IAAI,CAAC;CACzB"}
@@ -0,0 +1,6 @@
1
+ export * from './ICommandScope';
2
+ export * from './CommandScope';
3
+ export * from './CommandScopeImplementation';
4
+ export * from './useCommand';
5
+ export * from './useCommandScope';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../commands/index.ts"],"names":[],"mappings":"AAGA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var CommandScope = require('./CommandScope.js');
4
+ var CommandScopeImplementation = require('./CommandScopeImplementation.js');
5
+ var useCommand = require('./useCommand.js');
6
+ var useCommandScope = require('./useCommandScope.js');
7
+
8
+
9
+
10
+ exports.CommandScope = CommandScope.CommandScope;
11
+ exports.CommandScopeContext = CommandScope.CommandScopeContext;
12
+ exports.CommandScopeImplementation = CommandScopeImplementation.CommandScopeImplementation;
13
+ exports.useCommand = useCommand.useCommand;
14
+ exports.useCommandScope = useCommandScope.useCommandScope;
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -0,0 +1,6 @@
1
+ import { Constructor } from '@cratis/fundamentals';
2
+ import { Command } from '@cratis/arc/commands';
3
+ export type SetCommandValues<TCommandContent> = (command: TCommandContent) => void;
4
+ export type ClearCommandValues = () => void;
5
+ export declare function useCommand<TCommand extends Command<TCommandContent, TCommandResponse>, TCommandContent = object, TCommandResponse = object>(commandType: Constructor<TCommand>, initialValues?: TCommandContent): [TCommand, SetCommandValues<TCommandContent>, ClearCommandValues];
6
+ //# sourceMappingURL=useCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCommand.d.ts","sourceRoot":"","sources":["../../../commands/useCommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAK/C,MAAM,MAAM,gBAAgB,CAAC,eAAe,IAAI,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,CAAC;AACnF,MAAM,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC;AAQ5C,wBAAgB,UAAU,CACtB,QAAQ,SAAS,OAAO,CAAC,eAAe,EAAE,gBAAgB,CAAC,EAC3D,eAAe,GAAG,MAAM,EACxB,gBAAgB,GAAG,MAAM,EAEzB,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC,EAClC,aAAa,CAAC,EAAE,eAAe,GAChC,CAAC,QAAQ,EAAE,gBAAgB,CAAC,eAAe,CAAC,EAAE,kBAAkB,CAAC,CA2CnE"}
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var CommandScope = require('./CommandScope.js');
5
+ var ArcContext = require('../ArcContext.js');
6
+
7
+ function useCommand(commandType, initialValues) {
8
+ const command = React.useRef(null);
9
+ const [hasChanges, setHasChanges] = React.useState(false);
10
+ const arc = React.useContext(ArcContext.ArcContext);
11
+ const propertyChangedCallback = React.useCallback(() => {
12
+ if (command.current?.hasChanges !== hasChanges) {
13
+ setHasChanges(command.current?.hasChanges ?? false);
14
+ }
15
+ }, []);
16
+ command.current = React.useMemo(() => {
17
+ const instance = new commandType();
18
+ instance.setMicroservice(arc.microservice);
19
+ instance.setApiBasePath(arc.apiBasePath ?? '');
20
+ instance.setOrigin(arc.origin ?? '');
21
+ instance.setHttpHeadersCallback(arc.httpHeadersCallback ?? (() => ({})));
22
+ if (initialValues) {
23
+ instance.setInitialValues(initialValues);
24
+ }
25
+ instance.onPropertyChanged(propertyChangedCallback, instance);
26
+ return instance;
27
+ }, []);
28
+ const context = React.useContext(CommandScope.CommandScopeContext);
29
+ context.addCommand?.(command.current);
30
+ const setCommandValues = (values) => {
31
+ const valuesRecord = values;
32
+ command.current.properties.forEach((property) => {
33
+ if (valuesRecord[property] !== undefined && valuesRecord[property] != null) {
34
+ command.current[property] = valuesRecord[property];
35
+ }
36
+ });
37
+ };
38
+ const clearCommandValues = () => {
39
+ command.current.properties.forEach((property) => {
40
+ command.current[property] = undefined;
41
+ });
42
+ };
43
+ return [command.current, setCommandValues, clearCommandValues];
44
+ }
45
+
46
+ exports.useCommand = useCommand;
47
+ //# sourceMappingURL=useCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCommand.js","sources":["../../../commands/useCommand.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from '@cratis/fundamentals';\nimport { useState, useCallback, useContext, useRef, useMemo } from 'react';\nimport { Command } from '@cratis/arc/commands';\nimport React from 'react';\nimport { CommandScopeContext } from './CommandScope';\nimport { ArcContext } from '../ArcContext';\n\nexport type SetCommandValues<TCommandContent> = (command: TCommandContent) => void;\nexport type ClearCommandValues = () => void;\n\n/**\n * Use a command in a component.\n * @param commandType Type of the command to use.\n * @param initialValues Any initial values to set for the command.\n * @returns Tuple with the command, a {@link SetCommandValues<TCommandContent>} delegate to set values on command and {@link ClearCommandValues} delegate clear values.\n */\nexport function useCommand<\n TCommand extends Command<TCommandContent, TCommandResponse>,\n TCommandContent = object,\n TCommandResponse = object\n>(\n commandType: Constructor<TCommand>,\n initialValues?: TCommandContent\n): [TCommand, SetCommandValues<TCommandContent>, ClearCommandValues] {\n const command = useRef<TCommand | null>(null);\n const [hasChanges, setHasChanges] = useState(false);\n const arc = useContext(ArcContext);\n\n const propertyChangedCallback = useCallback(() => {\n if (command.current?.hasChanges !== hasChanges) {\n setHasChanges(command.current?.hasChanges ?? false);\n }\n }, []);\n\n command.current = useMemo(() => {\n const instance = new commandType();\n instance.setMicroservice(arc.microservice);\n instance.setApiBasePath(arc.apiBasePath ?? '');\n instance.setOrigin(arc.origin ?? '');\n instance.setHttpHeadersCallback(arc.httpHeadersCallback ?? (() => ({})));\n if (initialValues) {\n instance.setInitialValues(initialValues);\n }\n instance.onPropertyChanged(propertyChangedCallback, instance);\n return instance;\n }, []);\n\n const context = React.useContext(CommandScopeContext);\n context.addCommand?.(command.current! as Command<object, object>);\n\n const setCommandValues = (values: TCommandContent) => {\n const valuesRecord = values as Record<string, unknown>;\n command!.current!.properties.forEach((property: string) => {\n if (valuesRecord[property] !== undefined && valuesRecord[property] != null) {\n (command.current as Record<string, unknown>)[property] = valuesRecord[property];\n }\n });\n };\n\n const clearCommandValues = () => {\n command.current!.properties.forEach((property: string) => {\n (command.current as Record<string, unknown>)[property] = undefined;\n });\n };\n\n return [command.current!, setCommandValues, clearCommandValues];\n}\n"],"names":["useRef","useState","useContext","ArcContext","useCallback","useMemo","CommandScopeContext"],"mappings":";;;;;;AAmBM,SAAU,UAAU,CAKtB,WAAkC,EAClC,aAA+B,EAAA;AAE/B,IAAA,MAAM,OAAO,GAAGA,YAAM,CAAkB,IAAI,CAAC;IAC7C,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;AACnD,IAAA,MAAM,GAAG,GAAGC,gBAAU,CAACC,qBAAU,CAAC;AAElC,IAAA,MAAM,uBAAuB,GAAGC,iBAAW,CAAC,MAAK;QAC7C,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,KAAK,UAAU,EAAE;YAC5C,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,IAAI,KAAK,CAAC;QACvD;IACJ,CAAC,EAAE,EAAE,CAAC;AAEN,IAAA,OAAO,CAAC,OAAO,GAAGC,aAAO,CAAC,MAAK;AAC3B,QAAA,MAAM,QAAQ,GAAG,IAAI,WAAW,EAAE;AAClC,QAAA,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC;QAC1C,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;QAC9C,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;AACpC,QAAA,QAAQ,CAAC,sBAAsB,CAAC,GAAG,CAAC,mBAAmB,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;QACxE,IAAI,aAAa,EAAE;AACf,YAAA,QAAQ,CAAC,gBAAgB,CAAC,aAAa,CAAC;QAC5C;AACA,QAAA,QAAQ,CAAC,iBAAiB,CAAC,uBAAuB,EAAE,QAAQ,CAAC;AAC7D,QAAA,OAAO,QAAQ;IACnB,CAAC,EAAE,EAAE,CAAC;IAEN,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAACC,gCAAmB,CAAC;IACrD,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,OAAmC,CAAC;AAEjE,IAAA,MAAM,gBAAgB,GAAG,CAAC,MAAuB,KAAI;QACjD,MAAM,YAAY,GAAG,MAAiC;QACtD,OAAQ,CAAC,OAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAgB,KAAI;AACtD,YAAA,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,SAAS,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE;gBACvE,OAAO,CAAC,OAAmC,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC;YACnF;AACJ,QAAA,CAAC,CAAC;AACN,IAAA,CAAC;IAED,MAAM,kBAAkB,GAAG,MAAK;QAC5B,OAAO,CAAC,OAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,QAAgB,KAAI;AACpD,YAAA,OAAO,CAAC,OAAmC,CAAC,QAAQ,CAAC,GAAG,SAAS;AACtE,QAAA,CAAC,CAAC;AACN,IAAA,CAAC;IAED,OAAO,CAAC,OAAO,CAAC,OAAQ,EAAE,gBAAgB,EAAE,kBAAkB,CAAC;AACnE;;;;"}
@@ -0,0 +1,2 @@
1
+ export declare function useCommandScope(): import("./ICommandScope").ICommandScope;
2
+ //# sourceMappingURL=useCommandScope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCommandScope.d.ts","sourceRoot":"","sources":["../../../commands/useCommandScope.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,4CAE9B"}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var CommandScope = require('./CommandScope.js');
5
+
6
+ function useCommandScope() {
7
+ return React.useContext(CommandScope.CommandScopeContext);
8
+ }
9
+
10
+ exports.useCommandScope = useCommandScope;
11
+ //# sourceMappingURL=useCommandScope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCommandScope.js","sources":["../../../commands/useCommandScope.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React from 'react';\nimport { CommandScopeContext } from './CommandScope';\n\nexport function useCommandScope() {\n return React.useContext(CommandScopeContext);\n}\n"],"names":["CommandScopeContext"],"mappings":";;;;;SAMgB,eAAe,GAAA;AAC3B,IAAA,OAAO,KAAK,CAAC,UAAU,CAACA,gCAAmB,CAAC;AAChD;;;;"}
@@ -0,0 +1,6 @@
1
+ export declare class BusyIndicatorDialogRequest {
2
+ readonly title: string;
3
+ readonly message: string;
4
+ constructor(title: string, message: string);
5
+ }
6
+ //# sourceMappingURL=BusyIndicatorDialogRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BusyIndicatorDialogRequest.d.ts","sourceRoot":"","sources":["../../../dialogs/BusyIndicatorDialogRequest.ts"],"names":[],"mappings":"AAMA,qBAAa,0BAA0B;IAQ/B,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM;gBADf,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM;CAE/B"}
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ class BusyIndicatorDialogRequest {
4
+ title;
5
+ message;
6
+ constructor(title, message) {
7
+ this.title = title;
8
+ this.message = message;
9
+ }
10
+ }
11
+
12
+ exports.BusyIndicatorDialogRequest = BusyIndicatorDialogRequest;
13
+ //# sourceMappingURL=BusyIndicatorDialogRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BusyIndicatorDialogRequest.js","sources":["../../../dialogs/BusyIndicatorDialogRequest.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Represents the request for a busy indicator dialog, typically for spinners.\n */\nexport class BusyIndicatorDialogRequest {\n\n /**\n * Initializes a new instance of {@link BusyIndicatorDialogRequest}.\n * @param {String} title The title of the dialog.\n * @param {String} message The message to show in the dialog.\n */\n constructor(\n readonly title: string,\n readonly message: string) {\n }\n}\n"],"names":[],"mappings":";;MAMa,0BAA0B,CAAA;AAQtB,IAAA,KAAA;AACA,IAAA,OAAA;IAFb,WAAA,CACa,KAAa,EACb,OAAe,EAAA;QADf,IAAA,CAAA,KAAK,GAAL,KAAK;QACL,IAAA,CAAA,OAAO,GAAP,OAAO;IACpB;AACH;;;;"}
@@ -0,0 +1,3 @@
1
+ import { DialogResult } from './DialogResult';
2
+ export type CloseDialog<TResponse> = (result: DialogResult, response?: TResponse) => void;
3
+ //# sourceMappingURL=CloseDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloseDialog.d.ts","sourceRoot":"","sources":["../../../dialogs/CloseDialog.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,MAAM,MAAM,WAAW,CAAC,SAAS,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { DialogButtons } from './DialogButtons';
2
+ export declare class ConfirmationDialogRequest {
3
+ readonly title: string;
4
+ readonly message: string;
5
+ readonly buttons: DialogButtons;
6
+ constructor(title: string, message: string, buttons: DialogButtons);
7
+ }
8
+ //# sourceMappingURL=ConfirmationDialogRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfirmationDialogRequest.d.ts","sourceRoot":"","sources":["../../../dialogs/ConfirmationDialogRequest.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKhD,qBAAa,yBAAyB;IAS9B,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,QAAQ,CAAC,OAAO,EAAE,aAAa;gBAFtB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa;CAEtC"}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ class ConfirmationDialogRequest {
4
+ title;
5
+ message;
6
+ buttons;
7
+ constructor(title, message, buttons) {
8
+ this.title = title;
9
+ this.message = message;
10
+ this.buttons = buttons;
11
+ }
12
+ }
13
+
14
+ exports.ConfirmationDialogRequest = ConfirmationDialogRequest;
15
+ //# sourceMappingURL=ConfirmationDialogRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfirmationDialogRequest.js","sources":["../../../dialogs/ConfirmationDialogRequest.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { DialogButtons } from './DialogButtons';\n\n/**\n * Represents the request for a standard dialog.\n */\nexport class ConfirmationDialogRequest {\n\n /**\n * Initializes a new instance of {@link ConfirmationDialogRequest}.\n * @param {String} title The title of the dialog.\n * @param {String} message The message to show in the dialog.\n * @param {DialogButtons} buttons Buttons to use in the dialog.\n */\n constructor(\n readonly title: string,\n readonly message: string,\n readonly buttons: DialogButtons) {\n }\n}\n"],"names":[],"mappings":";;MAQa,yBAAyB,CAAA;AASrB,IAAA,KAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AAHb,IAAA,WAAA,CACa,KAAa,EACb,OAAe,EACf,OAAsB,EAAA;QAFtB,IAAA,CAAA,KAAK,GAAL,KAAK;QACL,IAAA,CAAA,OAAO,GAAP,OAAO;QACP,IAAA,CAAA,OAAO,GAAP,OAAO;IACpB;AACH;;;;"}
@@ -0,0 +1,7 @@
1
+ export declare enum DialogButtons {
2
+ Ok = 1,
3
+ OkCancel = 2,
4
+ YesNo = 3,
5
+ YesNoCancel = 4
6
+ }
7
+ //# sourceMappingURL=DialogButtons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogButtons.d.ts","sourceRoot":"","sources":["../../../dialogs/DialogButtons.ts"],"names":[],"mappings":"AAMA,oBAAY,aAAa;IAKrB,EAAE,IAAI;IAKN,QAAQ,IAAI;IAKZ,KAAK,IAAI;IAKT,WAAW,IAAI;CAClB"}
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ exports.DialogButtons = void 0;
4
+ (function (DialogButtons) {
5
+ DialogButtons[DialogButtons["Ok"] = 1] = "Ok";
6
+ DialogButtons[DialogButtons["OkCancel"] = 2] = "OkCancel";
7
+ DialogButtons[DialogButtons["YesNo"] = 3] = "YesNo";
8
+ DialogButtons[DialogButtons["YesNoCancel"] = 4] = "YesNoCancel";
9
+ })(exports.DialogButtons || (exports.DialogButtons = {}));
10
+ //# sourceMappingURL=DialogButtons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogButtons.js","sources":["../../../dialogs/DialogButtons.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Defines the buttons that can be shown on a standard dialog.\n */\nexport enum DialogButtons {\n\n /**\n * Show an OK button.\n */\n Ok = 1,\n\n /**\n * Show OK and Cancel buttons.\n */\n OkCancel = 2,\n\n /**\n * Show Yes and No buttons.\n */\n YesNo = 3,\n\n /**\n * Show Yes, No and Cancel buttons.\n */\n YesNoCancel = 4\n}\n"],"names":["DialogButtons"],"mappings":";;AAMYA;AAAZ,CAAA,UAAY,aAAa,EAAA;AAKrB,IAAA,aAAA,CAAA,aAAA,CAAA,IAAA,CAAA,GAAA,CAAA,CAAA,GAAA,IAAM;AAKN,IAAA,aAAA,CAAA,aAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAY;AAKZ,IAAA,aAAA,CAAA,aAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AAKT,IAAA,aAAA,CAAA,aAAA,CAAA,aAAA,CAAA,GAAA,CAAA,CAAA,GAAA,aAAe;AACnB,CAAC,EArBWA,qBAAa,KAAbA,qBAAa,GAAA,EAAA,CAAA,CAAA;;"}
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { ShowDialog } from './ShowDialog';
3
+ import { ConfirmationDialogRequest } from './ConfirmationDialogRequest';
4
+ import { BusyIndicatorDialogRequest } from './BusyIndicatorDialogRequest';
5
+ import { CloseDialog } from './CloseDialog';
6
+ export interface IDialogComponents {
7
+ confirmation?: React.FC<ConfirmationDialogRequest>;
8
+ showConfirmation: ShowDialog<ConfirmationDialogRequest>;
9
+ busyIndicator?: React.FC<BusyIndicatorDialogRequest>;
10
+ showBusyIndicator: ShowDialog<BusyIndicatorDialogRequest>;
11
+ closeBusyIndicator: CloseDialog<object>;
12
+ }
13
+ export declare const DialogComponentsContext: React.Context<IDialogComponents>;
14
+ export interface DialogComponentsProps {
15
+ children?: JSX.Element | JSX.Element[];
16
+ confirmation?: React.FC<ConfirmationDialogRequest>;
17
+ busyIndicator?: React.FC<BusyIndicatorDialogRequest>;
18
+ }
19
+ export declare const DialogComponents: (props: DialogComponentsProps) => import("react/jsx-runtime").JSX.Element;
20
+ //# sourceMappingURL=DialogComponents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogComponents.d.ts","sourceRoot":"","sources":["../../../dialogs/DialogComponents.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,MAAM,WAAW,iBAAiB;IAK9B,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAAC,CAAC;IAKnD,gBAAgB,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC;IAKxD,aAAa,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAC;IAKrD,iBAAiB,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC;IAK1D,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC3C;AAKD,eAAO,MAAM,uBAAuB,kCAKlC,CAAC;AAKH,MAAM,WAAW,qBAAqB;IAIlC,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IAMvC,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAAC,CAAC;IAMnD,aAAa,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAC;CACxD;AAiCD,eAAO,MAAM,gBAAgB,GAAI,OAAO,qBAAqB,4CAM5D,CAAC"}
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var DialogResult = require('./DialogResult.js');
6
+ var useDialog = require('./useDialog.js');
7
+ var DialogButtons = require('./DialogButtons.js');
8
+
9
+ const DialogComponentsContext = React.createContext({
10
+ showConfirmation: () => Promise.resolve([DialogResult.DialogResult.Cancelled, {}]),
11
+ showBusyIndicator: () => Promise.resolve([DialogResult.DialogResult.Cancelled, {}]),
12
+ closeBusyIndicator: () => { }
13
+ });
14
+ const DialogComponentsWrapper = (props) => {
15
+ const [Confirmation, showConfirmation] = useDialog.useDialog(props.confirmation ?? React.Fragment);
16
+ const [BusyIndicator, showBusyIndicator, closeBusyIndicatorDialogContext] = useDialog.useDialog(props.busyIndicator ?? React.Fragment);
17
+ const configuration = {
18
+ confirmation: Confirmation,
19
+ showConfirmation,
20
+ busyIndicator: BusyIndicator,
21
+ showBusyIndicator,
22
+ closeBusyIndicator: closeBusyIndicatorDialogContext.closeDialog
23
+ };
24
+ return (jsxRuntime.jsx(DialogComponentsContext.Provider, { value: configuration, children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [props.children, props.confirmation &&
25
+ jsxRuntime.jsx(Confirmation, { title: '', message: '', buttons: DialogButtons.DialogButtons.Ok }), props.busyIndicator &&
26
+ jsxRuntime.jsx(BusyIndicator, { title: '', message: '' })] }) }));
27
+ };
28
+ const DialogComponents = (props) => {
29
+ return (jsxRuntime.jsx(DialogComponentsWrapper, { ...props, children: props.children }));
30
+ };
31
+
32
+ exports.DialogComponents = DialogComponents;
33
+ exports.DialogComponentsContext = DialogComponentsContext;
34
+ //# sourceMappingURL=DialogComponents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogComponents.js","sources":["../../../dialogs/DialogComponents.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport React from 'react';\nimport { DialogResult } from './DialogResult';\nimport { ShowDialog } from './ShowDialog';\nimport { useDialog } from './useDialog';\nimport { ConfirmationDialogRequest } from './ConfirmationDialogRequest';\nimport { BusyIndicatorDialogRequest } from './BusyIndicatorDialogRequest';\nimport { DialogButtons } from './DialogButtons';\nimport { CloseDialog } from './CloseDialog';\n\n/**\n * Defines the interface representing the context of dialog components.\n */\nexport interface IDialogComponents {\n\n /**\n * The confirmation dialog component.\n */\n confirmation?: React.FC<ConfirmationDialogRequest>;\n\n /**\n * Shows a confirmation dialog with the specified request.\n */\n showConfirmation: ShowDialog<ConfirmationDialogRequest>;\n\n /**\n * The busy indicator dialog component, typically used for spinners.\n */\n busyIndicator?: React.FC<BusyIndicatorDialogRequest>;\n\n /**\n * Shows a busy indicator dialog with the specified request.\n */\n showBusyIndicator: ShowDialog<BusyIndicatorDialogRequest>;\n\n /**\n * Closes the busy indicator dialog.\n */\n closeBusyIndicator: CloseDialog<object>;\n}\n\n/**\n * The context for dialog components.\n */\nexport const DialogComponentsContext = React.createContext<IDialogComponents>({\n showConfirmation: () => Promise.resolve([DialogResult.Cancelled, {}]),\n showBusyIndicator: () => Promise.resolve([DialogResult.Cancelled, {}]),\n /* eslint-disable-next-line @typescript-eslint/no-empty-function */\n closeBusyIndicator: () => { }\n});\n\n/**\n * Props for the DialogComponentsWrapper component.\n */\nexport interface DialogComponentsProps {\n /**\n * Optional children elements to render within the dialog components context.\n */\n children?: JSX.Element | JSX.Element[];\n\n /**\n * Optional confirmation dialog component to use.\n * If not provided, a default empty fragment will be used.\n */\n confirmation?: React.FC<ConfirmationDialogRequest>;\n\n /**\n * Optional busy indicator dialog component to use.\n * If not provided, a default empty fragment will be used.\n */\n busyIndicator?: React.FC<BusyIndicatorDialogRequest>;\n}\n\nconst DialogComponentsWrapper = (props: DialogComponentsProps) => {\n const [Confirmation, showConfirmation] = useDialog(props.confirmation ?? React.Fragment as React.FC<ConfirmationDialogRequest>);\n const [BusyIndicator, showBusyIndicator, closeBusyIndicatorDialogContext] = useDialog(props.busyIndicator ?? React.Fragment as React.FC<BusyIndicatorDialogRequest>);\n\n const configuration: IDialogComponents = {\n confirmation: Confirmation,\n showConfirmation,\n busyIndicator: BusyIndicator,\n showBusyIndicator,\n closeBusyIndicator: closeBusyIndicatorDialogContext.closeDialog\n };\n\n return (\n <DialogComponentsContext.Provider value={configuration}>\n <>\n {props.children}\n {props.confirmation &&\n <Confirmation title='' message='' buttons={DialogButtons.Ok} />}\n\n {props.busyIndicator &&\n <BusyIndicator title='' message='' />}\n </>\n </DialogComponentsContext.Provider>\n );\n};\n\n/**\n * A React component that provides a context for dialog components.\n * @param props The properties for the dialog components wrapper.\n * @returns A React component that provides the dialog components context.\n */\nexport const DialogComponents = (props: DialogComponentsProps) => {\n return (\n <DialogComponentsWrapper {...props}>\n {props.children}\n </DialogComponentsWrapper>\n );\n};\n"],"names":["DialogResult","useDialog","_jsx","_jsxs","DialogButtons"],"mappings":";;;;;;;;AA8CO,MAAM,uBAAuB,GAAG,KAAK,CAAC,aAAa,CAAoB;AAC1E,IAAA,gBAAgB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAACA,yBAAY,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACrE,IAAA,iBAAiB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAACA,yBAAY,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAEtE,IAAA,kBAAkB,EAAE,MAAK,EAAG;AAC/B,CAAA;AAwBD,MAAM,uBAAuB,GAAG,CAAC,KAA4B,KAAI;AAC7D,IAAA,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,GAAGC,mBAAS,CAAC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,QAA+C,CAAC;AAC/H,IAAA,MAAM,CAAC,aAAa,EAAE,iBAAiB,EAAE,+BAA+B,CAAC,GAAGA,mBAAS,CAAC,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,QAAgD,CAAC;AAEpK,IAAA,MAAM,aAAa,GAAsB;AACrC,QAAA,YAAY,EAAE,YAAY;QAC1B,gBAAgB;AAChB,QAAA,aAAa,EAAE,aAAa;QAC5B,iBAAiB;QACjB,kBAAkB,EAAE,+BAA+B,CAAC;KACvD;AAED,IAAA,QACIC,cAAA,CAAC,uBAAuB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,EAAA,QAAA,EAClDC,kDACK,KAAK,CAAC,QAAQ,EACd,KAAK,CAAC,YAAY;AACf,oBAAAD,cAAA,CAAC,YAAY,EAAA,EAAC,KAAK,EAAC,EAAE,EAAC,OAAO,EAAC,EAAE,EAAC,OAAO,EAAEE,2BAAa,CAAC,EAAE,GAAI,EAElE,KAAK,CAAC,aAAa;AAChB,oBAAAF,cAAA,CAAC,aAAa,EAAA,EAAC,KAAK,EAAC,EAAE,EAAC,OAAO,EAAC,EAAE,EAAA,CAAG,CAAA,EAAA,CAC1C,EAAA,CAC4B;AAE3C,CAAC;AAOM,MAAM,gBAAgB,GAAG,CAAC,KAA4B,KAAI;IAC7D,QACIA,cAAA,CAAC,uBAAuB,EAAA,EAAA,GAAK,KAAK,EAAA,QAAA,EAC7B,KAAK,CAAC,QAAQ,EAAA,CACO;AAElC;;;;;"}
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { CloseDialog } from './CloseDialog';
3
+ export declare class DialogContextContent<TRequest, TResponse> {
4
+ readonly request: TRequest;
5
+ readonly closeDialog: CloseDialog<TResponse>;
6
+ constructor(request: TRequest, closeDialog: CloseDialog<TResponse>);
7
+ }
8
+ export declare const DialogContext: React.Context<DialogContextContent<object, object>>;
9
+ export declare const useDialogContext: <TRequest = object, TResponse = object>() => DialogContextContent<TRequest, TResponse>;
10
+ //# sourceMappingURL=DialogContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogContext.d.ts","sourceRoot":"","sources":["../../../dialogs/DialogContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,qBAAa,oBAAoB,CAAC,QAAQ,EAAE,SAAS;IAOrC,QAAQ,CAAC,OAAO,EAAE,QAAQ;IAAE,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC;gBAA/D,OAAO,EAAE,QAAQ,EAAW,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC;CAEvF;AAKD,eAAO,MAAM,aAAa,qDAAwE,CAAC;AAMnG,eAAO,MAAM,gBAAgB,GAAI,QAAQ,GAAG,MAAM,EAAE,SAAS,GAAG,MAAM,OAAK,oBAAoB,CAAC,QAAQ,EAAE,SAAS,CAElH,CAAC"}
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ function _interopNamespaceDefault(e) {
6
+ var n = Object.create(null);
7
+ if (e) {
8
+ Object.keys(e).forEach(function (k) {
9
+ if (k !== 'default') {
10
+ var d = Object.getOwnPropertyDescriptor(e, k);
11
+ Object.defineProperty(n, k, d.get ? d : {
12
+ enumerable: true,
13
+ get: function () { return e[k]; }
14
+ });
15
+ }
16
+ });
17
+ }
18
+ n.default = e;
19
+ return Object.freeze(n);
20
+ }
21
+
22
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
23
+
24
+ class DialogContextContent {
25
+ request;
26
+ closeDialog;
27
+ constructor(request, closeDialog) {
28
+ this.request = request;
29
+ this.closeDialog = closeDialog;
30
+ }
31
+ }
32
+ const DialogContext = React__namespace.createContext(undefined);
33
+ const useDialogContext = () => {
34
+ return React.useContext(DialogContext);
35
+ };
36
+
37
+ exports.DialogContext = DialogContext;
38
+ exports.DialogContextContent = DialogContextContent;
39
+ exports.useDialogContext = useDialogContext;
40
+ //# sourceMappingURL=DialogContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogContext.js","sources":["../../../dialogs/DialogContext.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport * as React from 'react';\nimport { useContext } from 'react';\nimport { CloseDialog } from './CloseDialog';\n\n/**\n * Represents the content of the dialog context, including the request and a function to close the dialog.\n */\nexport class DialogContextContent<TRequest, TResponse> {\n\n /**\n * Initializes a new instance of {@link DialogContextContent}.\n * @param request The request for the dialog, which contains the data needed to display the dialog. \n * @param closeDialog A function to close the dialog, which takes a result and an optional response.\n */\n constructor(readonly request: TRequest, readonly closeDialog: CloseDialog<TResponse>) {\n }\n}\n\n/**\n * The context for dialog components, providing access to the current dialog request and a method to close the dialog.\n */\nexport const DialogContext = React.createContext<DialogContextContent<object, object>>(undefined!);\n\n/**\n * A custom hook to access the dialog context in your components.\n * @returns The current dialog context, which includes the request and a method to close the dialog.\n */\nexport const useDialogContext = <TRequest = object, TResponse = object>(): DialogContextContent<TRequest, TResponse> => {\n return useContext(DialogContext) as unknown as DialogContextContent<TRequest, TResponse>;\n};\n"],"names":["React","useContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MAUa,oBAAoB,CAAA;AAOR,IAAA,OAAA;AAA4B,IAAA,WAAA;IAAjD,WAAA,CAAqB,OAAiB,EAAW,WAAmC,EAAA;QAA/D,IAAA,CAAA,OAAO,GAAP,OAAO;QAAqB,IAAA,CAAA,WAAW,GAAX,WAAW;IAC5D;AACH;AAKM,MAAM,aAAa,GAAGA,gBAAK,CAAC,aAAa,CAAuC,SAAU;AAM1F,MAAM,gBAAgB,GAAG,MAAuF;AACnH,IAAA,OAAOC,gBAAU,CAAC,aAAa,CAAyD;AAC5F;;;;;;"}
@@ -0,0 +1,5 @@
1
+ import { CloseDialog } from './CloseDialog';
2
+ export interface DialogProps<TResponse = object> {
3
+ closeDialog: CloseDialog<TResponse>;
4
+ }
5
+ //# sourceMappingURL=DialogProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogProps.d.ts","sourceRoot":"","sources":["../../../dialogs/DialogProps.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,MAAM,WAAW,WAAW,CAAC,SAAS,GAAG,MAAM;IAI3C,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;CACvC"}
@@ -0,0 +1,3 @@
1
+ import { DialogResult } from './DialogResult';
2
+ export type DialogResponse<TResponse = object> = [DialogResult, TResponse?];
3
+ //# sourceMappingURL=DialogResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DialogResponse.d.ts","sourceRoot":"","sources":["../../../dialogs/DialogResponse.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,MAAM,MAAM,cAAc,CAAC,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC"}