@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,8 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ export * from './ICommandScope';
5
+ export * from './CommandScope';
6
+ export * from './CommandScopeImplementation';
7
+ export * from './useCommand';
8
+ export * from './useCommandScope';
@@ -0,0 +1,70 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { Constructor } from '@cratis/fundamentals';
5
+ import { useState, useCallback, useContext, useRef, useMemo } from 'react';
6
+ import { Command } from '@cratis/arc/commands';
7
+ import React from 'react';
8
+ import { CommandScopeContext } from './CommandScope';
9
+ import { ArcContext } from '../ArcContext';
10
+
11
+ export type SetCommandValues<TCommandContent> = (command: TCommandContent) => void;
12
+ export type ClearCommandValues = () => void;
13
+
14
+ /**
15
+ * Use a command in a component.
16
+ * @param commandType Type of the command to use.
17
+ * @param initialValues Any initial values to set for the command.
18
+ * @returns Tuple with the command, a {@link SetCommandValues<TCommandContent>} delegate to set values on command and {@link ClearCommandValues} delegate clear values.
19
+ */
20
+ export function useCommand<
21
+ TCommand extends Command<TCommandContent, TCommandResponse>,
22
+ TCommandContent = object,
23
+ TCommandResponse = object
24
+ >(
25
+ commandType: Constructor<TCommand>,
26
+ initialValues?: TCommandContent
27
+ ): [TCommand, SetCommandValues<TCommandContent>, ClearCommandValues] {
28
+ const command = useRef<TCommand | null>(null);
29
+ const [hasChanges, setHasChanges] = useState(false);
30
+ const arc = useContext(ArcContext);
31
+
32
+ const propertyChangedCallback = useCallback(() => {
33
+ if (command.current?.hasChanges !== hasChanges) {
34
+ setHasChanges(command.current?.hasChanges ?? false);
35
+ }
36
+ }, []);
37
+
38
+ command.current = useMemo(() => {
39
+ const instance = new commandType();
40
+ instance.setMicroservice(arc.microservice);
41
+ instance.setApiBasePath(arc.apiBasePath ?? '');
42
+ instance.setOrigin(arc.origin ?? '');
43
+ instance.setHttpHeadersCallback(arc.httpHeadersCallback ?? (() => ({})));
44
+ if (initialValues) {
45
+ instance.setInitialValues(initialValues);
46
+ }
47
+ instance.onPropertyChanged(propertyChangedCallback, instance);
48
+ return instance;
49
+ }, []);
50
+
51
+ const context = React.useContext(CommandScopeContext);
52
+ context.addCommand?.(command.current! as Command<object, object>);
53
+
54
+ const setCommandValues = (values: TCommandContent) => {
55
+ const valuesRecord = values as Record<string, unknown>;
56
+ command!.current!.properties.forEach((property: string) => {
57
+ if (valuesRecord[property] !== undefined && valuesRecord[property] != null) {
58
+ (command.current as Record<string, unknown>)[property] = valuesRecord[property];
59
+ }
60
+ });
61
+ };
62
+
63
+ const clearCommandValues = () => {
64
+ command.current!.properties.forEach((property: string) => {
65
+ (command.current as Record<string, unknown>)[property] = undefined;
66
+ });
67
+ };
68
+
69
+ return [command.current!, setCommandValues, clearCommandValues];
70
+ }
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import React from 'react';
5
+ import { CommandScopeContext } from './CommandScope';
6
+
7
+ export function useCommandScope() {
8
+ return React.useContext(CommandScopeContext);
9
+ }
@@ -0,0 +1,18 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ /**
5
+ * Represents the request for a busy indicator dialog, typically for spinners.
6
+ */
7
+ export class BusyIndicatorDialogRequest {
8
+
9
+ /**
10
+ * Initializes a new instance of {@link BusyIndicatorDialogRequest}.
11
+ * @param {String} title The title of the dialog.
12
+ * @param {String} message The message to show in the dialog.
13
+ */
14
+ constructor(
15
+ readonly title: string,
16
+ readonly message: string) {
17
+ }
18
+ }
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { DialogResult } from './DialogResult';
5
+
6
+ /**
7
+ * Represents the delegate when a dialog is closed with a response.
8
+ */
9
+ export type CloseDialog<TResponse> = (result: DialogResult, response?: TResponse) => void;
@@ -0,0 +1,22 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { DialogButtons } from './DialogButtons';
5
+
6
+ /**
7
+ * Represents the request for a standard dialog.
8
+ */
9
+ export class ConfirmationDialogRequest {
10
+
11
+ /**
12
+ * Initializes a new instance of {@link ConfirmationDialogRequest}.
13
+ * @param {String} title The title of the dialog.
14
+ * @param {String} message The message to show in the dialog.
15
+ * @param {DialogButtons} buttons Buttons to use in the dialog.
16
+ */
17
+ constructor(
18
+ readonly title: string,
19
+ readonly message: string,
20
+ readonly buttons: DialogButtons) {
21
+ }
22
+ }
@@ -0,0 +1,28 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ /**
5
+ * Defines the buttons that can be shown on a standard dialog.
6
+ */
7
+ export enum DialogButtons {
8
+
9
+ /**
10
+ * Show an OK button.
11
+ */
12
+ Ok = 1,
13
+
14
+ /**
15
+ * Show OK and Cancel buttons.
16
+ */
17
+ OkCancel = 2,
18
+
19
+ /**
20
+ * Show Yes and No buttons.
21
+ */
22
+ YesNo = 3,
23
+
24
+ /**
25
+ * Show Yes, No and Cancel buttons.
26
+ */
27
+ YesNoCancel = 4
28
+ }
@@ -0,0 +1,113 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import React from 'react';
5
+ import { DialogResult } from './DialogResult';
6
+ import { ShowDialog } from './ShowDialog';
7
+ import { useDialog } from './useDialog';
8
+ import { ConfirmationDialogRequest } from './ConfirmationDialogRequest';
9
+ import { BusyIndicatorDialogRequest } from './BusyIndicatorDialogRequest';
10
+ import { DialogButtons } from './DialogButtons';
11
+ import { CloseDialog } from './CloseDialog';
12
+
13
+ /**
14
+ * Defines the interface representing the context of dialog components.
15
+ */
16
+ export interface IDialogComponents {
17
+
18
+ /**
19
+ * The confirmation dialog component.
20
+ */
21
+ confirmation?: React.FC<ConfirmationDialogRequest>;
22
+
23
+ /**
24
+ * Shows a confirmation dialog with the specified request.
25
+ */
26
+ showConfirmation: ShowDialog<ConfirmationDialogRequest>;
27
+
28
+ /**
29
+ * The busy indicator dialog component, typically used for spinners.
30
+ */
31
+ busyIndicator?: React.FC<BusyIndicatorDialogRequest>;
32
+
33
+ /**
34
+ * Shows a busy indicator dialog with the specified request.
35
+ */
36
+ showBusyIndicator: ShowDialog<BusyIndicatorDialogRequest>;
37
+
38
+ /**
39
+ * Closes the busy indicator dialog.
40
+ */
41
+ closeBusyIndicator: CloseDialog<object>;
42
+ }
43
+
44
+ /**
45
+ * The context for dialog components.
46
+ */
47
+ export const DialogComponentsContext = React.createContext<IDialogComponents>({
48
+ showConfirmation: () => Promise.resolve([DialogResult.Cancelled, {}]),
49
+ showBusyIndicator: () => Promise.resolve([DialogResult.Cancelled, {}]),
50
+ /* eslint-disable-next-line @typescript-eslint/no-empty-function */
51
+ closeBusyIndicator: () => { }
52
+ });
53
+
54
+ /**
55
+ * Props for the DialogComponentsWrapper component.
56
+ */
57
+ export interface DialogComponentsProps {
58
+ /**
59
+ * Optional children elements to render within the dialog components context.
60
+ */
61
+ children?: JSX.Element | JSX.Element[];
62
+
63
+ /**
64
+ * Optional confirmation dialog component to use.
65
+ * If not provided, a default empty fragment will be used.
66
+ */
67
+ confirmation?: React.FC<ConfirmationDialogRequest>;
68
+
69
+ /**
70
+ * Optional busy indicator dialog component to use.
71
+ * If not provided, a default empty fragment will be used.
72
+ */
73
+ busyIndicator?: React.FC<BusyIndicatorDialogRequest>;
74
+ }
75
+
76
+ const DialogComponentsWrapper = (props: DialogComponentsProps) => {
77
+ const [Confirmation, showConfirmation] = useDialog(props.confirmation ?? React.Fragment as React.FC<ConfirmationDialogRequest>);
78
+ const [BusyIndicator, showBusyIndicator, closeBusyIndicatorDialogContext] = useDialog(props.busyIndicator ?? React.Fragment as React.FC<BusyIndicatorDialogRequest>);
79
+
80
+ const configuration: IDialogComponents = {
81
+ confirmation: Confirmation,
82
+ showConfirmation,
83
+ busyIndicator: BusyIndicator,
84
+ showBusyIndicator,
85
+ closeBusyIndicator: closeBusyIndicatorDialogContext.closeDialog
86
+ };
87
+
88
+ return (
89
+ <DialogComponentsContext.Provider value={configuration}>
90
+ <>
91
+ {props.children}
92
+ {props.confirmation &&
93
+ <Confirmation title='' message='' buttons={DialogButtons.Ok} />}
94
+
95
+ {props.busyIndicator &&
96
+ <BusyIndicator title='' message='' />}
97
+ </>
98
+ </DialogComponentsContext.Provider>
99
+ );
100
+ };
101
+
102
+ /**
103
+ * A React component that provides a context for dialog components.
104
+ * @param props The properties for the dialog components wrapper.
105
+ * @returns A React component that provides the dialog components context.
106
+ */
107
+ export const DialogComponents = (props: DialogComponentsProps) => {
108
+ return (
109
+ <DialogComponentsWrapper {...props}>
110
+ {props.children}
111
+ </DialogComponentsWrapper>
112
+ );
113
+ };
@@ -0,0 +1,33 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import * as React from 'react';
5
+ import { useContext } from 'react';
6
+ import { CloseDialog } from './CloseDialog';
7
+
8
+ /**
9
+ * Represents the content of the dialog context, including the request and a function to close the dialog.
10
+ */
11
+ export class DialogContextContent<TRequest, TResponse> {
12
+
13
+ /**
14
+ * Initializes a new instance of {@link DialogContextContent}.
15
+ * @param request The request for the dialog, which contains the data needed to display the dialog.
16
+ * @param closeDialog A function to close the dialog, which takes a result and an optional response.
17
+ */
18
+ constructor(readonly request: TRequest, readonly closeDialog: CloseDialog<TResponse>) {
19
+ }
20
+ }
21
+
22
+ /**
23
+ * The context for dialog components, providing access to the current dialog request and a method to close the dialog.
24
+ */
25
+ export const DialogContext = React.createContext<DialogContextContent<object, object>>(undefined!);
26
+
27
+ /**
28
+ * A custom hook to access the dialog context in your components.
29
+ * @returns The current dialog context, which includes the request and a method to close the dialog.
30
+ */
31
+ export const useDialogContext = <TRequest = object, TResponse = object>(): DialogContextContent<TRequest, TResponse> => {
32
+ return useContext(DialogContext) as unknown as DialogContextContent<TRequest, TResponse>;
33
+ };
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { CloseDialog } from './CloseDialog';
5
+
6
+ /**
7
+ * Represents the properties for a dialog component, including a method to close the dialog.
8
+ */
9
+ export interface DialogProps<TResponse = object> {
10
+ /**
11
+ * A function to close the dialog, which takes a result and an optional response.
12
+ */
13
+ closeDialog: CloseDialog<TResponse>;
14
+ }
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { DialogResult } from './DialogResult';
5
+
6
+ /**
7
+ * Represents the response from a dialog, including the result and an optional response object.
8
+ */
9
+ export type DialogResponse<TResponse = object> = [DialogResult, TResponse?];
@@ -0,0 +1,32 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ /**
5
+ * Defines the possible results from a dialog interaction.
6
+ */
7
+ export enum DialogResult {
8
+ /**
9
+ * Indicates that no action was taken or the dialog was closed without a specific result.
10
+ */
11
+ None = 0,
12
+
13
+ /**
14
+ * Indicates that the user confirmed the action, typically by clicking "Yes" or "OK".
15
+ */
16
+ Yes = 1,
17
+
18
+ /**
19
+ * Indicates that the user declined the action, typically by clicking "No".
20
+ */
21
+ No = 2,
22
+
23
+ /**
24
+ * Indicates that the user acknowledged the action, typically by clicking "OK".
25
+ */
26
+ Ok = 3,
27
+
28
+ /**
29
+ * Indicates that the dialog was cancelled, typically by clicking "Cancel".
30
+ */
31
+ Cancelled = 4
32
+ }
@@ -0,0 +1,9 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { DialogResponse } from './DialogResponse';
5
+
6
+ /**
7
+ * Represents a function that shows a dialog and returns a promise that resolves with the dialog response.
8
+ */
9
+ export type ShowDialog<TProps, TResponse = object> = (props?: TProps) => Promise<DialogResponse<TResponse>>;
@@ -0,0 +1,16 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ export * from './BusyIndicatorDialogRequest';
5
+ export * from './CloseDialog';
6
+ export * from './ConfirmationDialogRequest';
7
+ export * from './DialogButtons';
8
+ export * from './DialogComponents';
9
+ export * from './DialogContext';
10
+ export * from './DialogProps';
11
+ export * from './DialogResponse';
12
+ export * from './DialogResult';
13
+ export * from './ShowDialog';
14
+ export * from './useBusyIndicator';
15
+ export * from './useConfirmationDialog';
16
+ export * from './useDialog';
@@ -0,0 +1,41 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { useContext } from 'react';
5
+ import { DialogComponentsContext, IDialogComponents } from './DialogComponents';
6
+ import { DialogResult } from './DialogResult';
7
+ import { BusyIndicatorDialogRequest } from './BusyIndicatorDialogRequest';
8
+
9
+ /**
10
+ * Represents the signature for showing a confirmation dialog.
11
+ * @param title Optional title of the confirmation dialog.
12
+ * @param message Optional message to display in the confirmation dialog.
13
+ * @return A promise that resolves to a tuple containing the dialog result and any additional data.
14
+ */
15
+ export type ShowBusyIndicatorDialog = (title?: string, message?: string) => Promise<DialogResult>;
16
+
17
+ /**
18
+ * Represents the signature for closing a busy indicator dialog.
19
+ */
20
+ export type CloseBusyIndicatorDialog = () => void;
21
+
22
+ /**
23
+ * Uses a busy indicator dialog in your application.
24
+ * @param title Optional title of the confirmation dialog.
25
+ * @param message Optional message to display in the confirmation dialog.
26
+ * @returns A tuple containing the a function to show the dialog and one to close the dialog.
27
+ */
28
+ export const useBusyIndicator = (title?: string, message?: string): [ShowBusyIndicatorDialog, CloseBusyIndicatorDialog] => {
29
+ const components = useContext<IDialogComponents>(DialogComponentsContext);
30
+
31
+ return [
32
+ async (delegateTitle?: string, delegateMessage?: string) => {
33
+ const request = new BusyIndicatorDialogRequest(
34
+ delegateTitle ?? title ?? '',
35
+ delegateMessage ?? message ?? '');
36
+ const [result] = await components.showBusyIndicator(request);
37
+ return result;
38
+ },
39
+ () => components.closeBusyIndicator?.(DialogResult.Cancelled)
40
+ ];
41
+ };
@@ -0,0 +1,39 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { useContext } from 'react';
5
+ import { DialogButtons } from './DialogButtons';
6
+ import { DialogComponentsContext, IDialogComponents } from './DialogComponents';
7
+ import { ConfirmationDialogRequest } from './ConfirmationDialogRequest';
8
+ import { DialogResult } from './DialogResult';
9
+
10
+ /**
11
+ * Represents the signature for showing a confirmation dialog.
12
+ * @param title Optional title of the confirmation dialog.
13
+ * @param message Optional message to display in the confirmation dialog.
14
+ * @param buttons Optional buttons to display in the confirmation dialog. If not provided, defaults to `DialogButtons.Ok`.
15
+ * @return A promise that resolves to a tuple containing the dialog result and any additional data.
16
+ */
17
+ export type ShowConfirmationDialog = (title?: string, message?: string, buttons?: DialogButtons) => Promise<DialogResult>;
18
+
19
+ /**
20
+ * Uses a confirmation dialog in your application.
21
+ * @param title Optional title of the confirmation dialog.
22
+ * @param message Optional message to display in the confirmation dialog.
23
+ * @param buttons Optional buttons to display in the confirmation dialog. If not provided, defaults to `DialogButtons.Ok`.
24
+ * @returns A tuple containing function to show the dialog.
25
+ */
26
+ export const useConfirmationDialog = (title?: string, message?: string, buttons?: DialogButtons): [ShowConfirmationDialog] => {
27
+ const components = useContext<IDialogComponents>(DialogComponentsContext);
28
+
29
+ return [
30
+ async (delegateTitle?: string, delegateMessage?: string, delegateButtons?: DialogButtons) => {
31
+ const request = new ConfirmationDialogRequest(
32
+ delegateTitle ?? title ?? '',
33
+ delegateMessage ?? message ?? '',
34
+ delegateButtons ?? buttons ?? DialogButtons.Ok);
35
+ const [result] = await components.showConfirmation(request);
36
+ return result;
37
+ }
38
+ ];
39
+ };
@@ -0,0 +1,55 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { DialogContext, DialogContextContent } from './DialogContext';
5
+ import { DialogResponse } from './DialogResponse';
6
+ import { DialogResult } from './DialogResult';
7
+ import { useCallback, useRef, useState, ComponentType, FC, useMemo } from 'react';
8
+ import { ShowDialog } from './ShowDialog';
9
+
10
+ /**
11
+ * Use a dialog component in you application. This hook manages the visibility and properties of the dialog.
12
+ * @param DialogComponent The dialog component to use.
13
+ * @returns A tuple containing the wrapped dialog component and a function to show the dialog.
14
+ * The wrapped dialog component will receive the properties passed to it, excluding the `closeDialog` property.
15
+ */
16
+ export function useDialog<TResponse = object, TProps = object>(
17
+ DialogComponent: ComponentType<TProps>
18
+ ): [FC<TProps>, ShowDialog<TProps, TResponse>, DialogContextContent<TProps, TResponse>] {
19
+
20
+ const [visible, setVisible] = useState(false);
21
+ const [dialogProps, setDialogProps] = useState<TProps | undefined>();
22
+ const resolverRef = useRef<((value: DialogResponse<TResponse>) => void) | undefined>(undefined);
23
+
24
+ const showDialog = useCallback((p?: TProps) => {
25
+ setDialogProps(p);
26
+ setVisible(true);
27
+ return new Promise<DialogResponse<TResponse>>((resolve) => {
28
+ resolverRef.current = resolve;
29
+ });
30
+ }, []);
31
+
32
+ const closeDialog = useCallback((result: DialogResult, value?: TResponse) => {
33
+ setVisible(false);
34
+ resolverRef.current?.([result, value]);
35
+ resolverRef.current = undefined;
36
+ }, []);
37
+
38
+ const dialogContextValue = useRef<DialogContextContent<TProps, TResponse>>(undefined!);
39
+ dialogContextValue.current = useMemo(() => {
40
+ return new DialogContextContent(dialogProps!, closeDialog);
41
+ }, [dialogProps, closeDialog]);
42
+
43
+ const DialogWrapper: FC<TProps> = (extraProps) => {
44
+ return visible ? (
45
+ <DialogContext.Provider value={dialogContextValue.current as unknown as DialogContextContent<object, object>}>
46
+ <DialogComponent
47
+ {...extraProps}
48
+ {...(dialogProps as TProps)}
49
+ closeDialog={closeDialog} />
50
+ </DialogContext.Provider>
51
+ ) : null;
52
+ };
53
+
54
+ return [DialogWrapper, showDialog, dialogContextValue.current];
55
+ }
@@ -0,0 +1,12 @@
1
+ import { GetHttpHeaders } from '@cratis/arc';
2
+ export interface ArcProps {
3
+ children?: JSX.Element | JSX.Element[];
4
+ microservice?: string;
5
+ development?: boolean;
6
+ origin?: string;
7
+ basePath?: string;
8
+ apiBasePath?: string;
9
+ httpHeadersCallback?: GetHttpHeaders;
10
+ }
11
+ export declare const Arc: (props: ArcProps) => import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=Arc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Arc.d.ts","sourceRoot":"","sources":["../../Arc.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,cAAc,CAAC;CACxC;AAED,eAAO,MAAM,GAAG,GAAI,OAAO,QAAQ,4CAwBlC,CAAC"}
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var CommandScope = require('./commands/CommandScope.js');
5
+ require('@cratis/arc/commands');
6
+ require('react');
7
+ var ArcContext = require('./ArcContext.js');
8
+ var IdentityProvider = require('./identity/IdentityProvider.js');
9
+ var Bindings = require('./Bindings.js');
10
+
11
+ const Arc = (props) => {
12
+ const configuration = {
13
+ microservice: props.microservice ?? '',
14
+ development: props.development ?? false,
15
+ origin: props.origin ?? '',
16
+ basePath: props.basePath ?? '',
17
+ apiBasePath: props.apiBasePath ?? '',
18
+ httpHeadersCallback: props.httpHeadersCallback
19
+ };
20
+ Bindings.Bindings.initialize(configuration.microservice, configuration.apiBasePath, configuration.origin, configuration.httpHeadersCallback);
21
+ return (jsxRuntime.jsx(ArcContext.ArcContext.Provider, { value: configuration, children: jsxRuntime.jsx(IdentityProvider.IdentityProvider, { httpHeadersCallback: props.httpHeadersCallback, children: jsxRuntime.jsx(CommandScope.CommandScope, { children: props.children }) }) }));
22
+ };
23
+
24
+ exports.Arc = Arc;
25
+ //# sourceMappingURL=Arc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Arc.js","sources":["../../Arc.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 { CommandScope } from './commands';\nimport { IdentityProvider } from './identity';\nimport { Bindings } from './Bindings';\nimport { ArcConfiguration, ArcContext } from './ArcContext';\nimport { GetHttpHeaders } from '@cratis/arc';\n\nexport interface ArcProps {\n children?: JSX.Element | JSX.Element[];\n microservice?: string;\n development?: boolean;\n origin?: string;\n basePath?: string;\n apiBasePath?: string;\n httpHeadersCallback?: GetHttpHeaders;\n}\n\nexport const Arc = (props: ArcProps) => {\n const configuration: ArcConfiguration = {\n microservice: props.microservice ?? '',\n development: props.development ?? false,\n origin: props.origin ?? '',\n basePath: props.basePath ?? '',\n apiBasePath: props.apiBasePath ?? '',\n httpHeadersCallback: props.httpHeadersCallback\n };\n\n Bindings.initialize(\n configuration.microservice,\n configuration.apiBasePath,\n configuration.origin,\n configuration.httpHeadersCallback);\n\n return (\n <ArcContext.Provider value={configuration}>\n <IdentityProvider httpHeadersCallback={props.httpHeadersCallback}>\n <CommandScope>\n {props.children}\n </CommandScope>\n </IdentityProvider>\n </ArcContext.Provider>);\n};"],"names":["Bindings","_jsx","ArcContext","IdentityProvider","CommandScope"],"mappings":";;;;;;;;;;AAmBO,MAAM,GAAG,GAAG,CAAC,KAAe,KAAI;AACnC,IAAA,MAAM,aAAa,GAAqB;AACpC,QAAA,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,EAAE;AACtC,QAAA,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,KAAK;AACvC,QAAA,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,EAAE;AAC1B,QAAA,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,EAAE;AAC9B,QAAA,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE;QACpC,mBAAmB,EAAE,KAAK,CAAC;KAC9B;AAED,IAAAA,iBAAQ,CAAC,UAAU,CACf,aAAa,CAAC,YAAY,EAC1B,aAAa,CAAC,WAAW,EACzB,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,mBAAmB,CAAC;AAEtC,IAAA,QACIC,cAAA,CAACC,qBAAU,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,aAAa,EAAA,QAAA,EACrCD,cAAA,CAACE,iCAAgB,EAAA,EAAC,mBAAmB,EAAE,KAAK,CAAC,mBAAmB,EAAA,QAAA,EAC5DF,cAAA,CAACG,yBAAY,EAAA,EAAA,QAAA,EACR,KAAK,CAAC,QAAQ,EAAA,CACJ,EAAA,CACA,EAAA,CACD;AAC9B;;;;"}
@@ -0,0 +1,12 @@
1
+ import { GetHttpHeaders } from '@cratis/arc';
2
+ import React from 'react';
3
+ export interface ArcConfiguration {
4
+ microservice: string;
5
+ development?: boolean;
6
+ origin?: string;
7
+ basePath?: string;
8
+ apiBasePath?: string;
9
+ httpHeadersCallback?: GetHttpHeaders;
10
+ }
11
+ export declare const ArcContext: React.Context<ArcConfiguration>;
12
+ //# sourceMappingURL=ArcContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArcContext.d.ts","sourceRoot":"","sources":["../../ArcContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAW,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,gBAAgB;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,cAAc,CAAC;CACxC;AAED,eAAO,MAAM,UAAU,iCAOrB,CAAC"}
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var arc = require('@cratis/arc');
4
+ var React = require('react');
5
+
6
+ const ArcContext = React.createContext({
7
+ microservice: arc.Globals.microservice,
8
+ development: false,
9
+ origin: '',
10
+ basePath: '',
11
+ apiBasePath: '',
12
+ httpHeadersCallback: () => ({})
13
+ });
14
+
15
+ exports.ArcContext = ArcContext;
16
+ //# sourceMappingURL=ArcContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArcContext.js","sources":["../../ArcContext.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 { GetHttpHeaders, Globals } from '@cratis/arc';\nimport React from 'react';\n\nexport interface ArcConfiguration {\n microservice: string;\n development?: boolean\n origin?: string;\n basePath?: string;\n apiBasePath?: string;\n httpHeadersCallback?: GetHttpHeaders;\n}\n\nexport const ArcContext = React.createContext<ArcConfiguration>({\n microservice: Globals.microservice,\n development: false,\n origin: '',\n basePath: '',\n apiBasePath: '',\n httpHeadersCallback: () => ({})\n});\n"],"names":["Globals"],"mappings":";;;;;AAeO,MAAM,UAAU,GAAG,KAAK,CAAC,aAAa,CAAmB;IAC5D,YAAY,EAAEA,WAAO,CAAC,YAAY;AAClC,IAAA,WAAW,EAAE,KAAK;AAClB,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,QAAQ,EAAE,EAAE;AACZ,IAAA,WAAW,EAAE,EAAE;AACf,IAAA,mBAAmB,EAAE,OAAO,EAAE;AACjC,CAAA;;;;"}
@@ -0,0 +1,5 @@
1
+ import { GetHttpHeaders } from '@cratis/arc';
2
+ export declare class Bindings {
3
+ static initialize(microservice: string, apiBasePath?: string, origin?: string, httpHeadersCallback?: GetHttpHeaders): void;
4
+ }
5
+ //# sourceMappingURL=Bindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bindings.d.ts","sourceRoot":"","sources":["../../Bindings.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,qBAAa,QAAQ;IACjB,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,EAAE,cAAc,GAAG,IAAI;CAI7H"}