@contember/react-binding 2.0.0-alpha.16 → 2.0.0-alpha.18

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 (400) hide show
  1. package/dist/development/index.cjs +2 -9
  2. package/dist/development/index.cjs.map +1 -1
  3. package/dist/development/index.js +1 -8
  4. package/dist/development/index.js.map +1 -1
  5. package/dist/development/src/accessorPropagation/AccessorProvider.cjs +1 -1
  6. package/dist/development/src/accessorPropagation/AccessorProvider.cjs.map +1 -1
  7. package/dist/development/src/accessorPropagation/AccessorProvider.js +1 -1
  8. package/dist/development/src/accessorPropagation/AccessorProvider.js.map +1 -1
  9. package/dist/development/src/accessorPropagation/BindingOperationsContext.cjs +2 -1
  10. package/dist/development/src/accessorPropagation/BindingOperationsContext.cjs.map +1 -1
  11. package/dist/development/src/accessorPropagation/BindingOperationsContext.js +2 -1
  12. package/dist/development/src/accessorPropagation/BindingOperationsContext.js.map +1 -1
  13. package/dist/development/src/accessorPropagation/EntityKeyContext.cjs.map +1 -1
  14. package/dist/development/src/accessorPropagation/EntityKeyContext.js.map +1 -1
  15. package/dist/development/src/accessorPropagation/EntityKeyProvider.cjs +1 -1
  16. package/dist/development/src/accessorPropagation/EntityKeyProvider.cjs.map +1 -1
  17. package/dist/development/src/accessorPropagation/EntityKeyProvider.js +1 -1
  18. package/dist/development/src/accessorPropagation/EntityKeyProvider.js.map +1 -1
  19. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.cjs +14 -37
  20. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.cjs.map +1 -1
  21. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.js +15 -38
  22. package/dist/development/src/accessorPropagation/useAccessorUpdateSubscription.js.map +1 -1
  23. package/dist/development/src/accessorPropagation/useEntity.cjs +4 -4
  24. package/dist/development/src/accessorPropagation/useEntity.cjs.map +1 -1
  25. package/dist/development/src/accessorPropagation/useEntity.js +4 -4
  26. package/dist/development/src/accessorPropagation/useEntity.js.map +1 -1
  27. package/dist/development/src/accessorPropagation/useEntityKey.cjs.map +1 -1
  28. package/dist/development/src/accessorPropagation/useEntityKey.js.map +1 -1
  29. package/dist/development/src/accessorPropagation/useEntityList.cjs +3 -3
  30. package/dist/development/src/accessorPropagation/useEntityList.cjs.map +1 -1
  31. package/dist/development/src/accessorPropagation/useEntityList.js +3 -3
  32. package/dist/development/src/accessorPropagation/useEntityList.js.map +1 -1
  33. package/dist/development/src/accessorPropagation/useEntityListSubTree.cjs +1 -1
  34. package/dist/development/src/accessorPropagation/useEntityListSubTree.cjs.map +1 -1
  35. package/dist/development/src/accessorPropagation/useEntityListSubTree.js +1 -1
  36. package/dist/development/src/accessorPropagation/useEntityListSubTree.js.map +1 -1
  37. package/dist/development/src/accessorPropagation/useEntitySubTree.cjs +1 -1
  38. package/dist/development/src/accessorPropagation/useEntitySubTree.cjs.map +1 -1
  39. package/dist/development/src/accessorPropagation/useEntitySubTree.js +1 -1
  40. package/dist/development/src/accessorPropagation/useEntitySubTree.js.map +1 -1
  41. package/dist/development/src/accessorPropagation/useField.cjs +3 -3
  42. package/dist/development/src/accessorPropagation/useField.cjs.map +1 -1
  43. package/dist/development/src/accessorPropagation/useField.js +3 -3
  44. package/dist/development/src/accessorPropagation/useField.js.map +1 -1
  45. package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.cjs +2 -2
  46. package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.cjs.map +1 -1
  47. package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.js +2 -2
  48. package/dist/development/src/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
  49. package/dist/development/src/accessorSorting/addEntityAtIndex.cjs +1 -1
  50. package/dist/development/src/accessorSorting/addEntityAtIndex.cjs.map +1 -1
  51. package/dist/development/src/accessorSorting/addEntityAtIndex.js +1 -1
  52. package/dist/development/src/accessorSorting/addEntityAtIndex.js.map +1 -1
  53. package/dist/development/src/accessorSorting/repairEntitiesOrder.cjs +1 -1
  54. package/dist/development/src/accessorSorting/repairEntitiesOrder.cjs.map +1 -1
  55. package/dist/development/src/accessorSorting/repairEntitiesOrder.js +1 -1
  56. package/dist/development/src/accessorSorting/repairEntitiesOrder.js.map +1 -1
  57. package/dist/development/src/accessorSorting/sortEntities.cjs +2 -2
  58. package/dist/development/src/accessorSorting/sortEntities.cjs.map +1 -1
  59. package/dist/development/src/accessorSorting/sortEntities.js +2 -2
  60. package/dist/development/src/accessorSorting/sortEntities.js.map +1 -1
  61. package/dist/development/src/accessorTree/AccessorTree.cjs +16 -6
  62. package/dist/development/src/accessorTree/AccessorTree.cjs.map +1 -1
  63. package/dist/development/src/accessorTree/AccessorTree.js +16 -6
  64. package/dist/development/src/accessorTree/AccessorTree.js.map +1 -1
  65. package/dist/development/src/accessorTree/useDataBinding.cjs +23 -36
  66. package/dist/development/src/accessorTree/useDataBinding.cjs.map +1 -1
  67. package/dist/development/src/accessorTree/useDataBinding.js +26 -39
  68. package/dist/development/src/accessorTree/useDataBinding.js.map +1 -1
  69. package/dist/development/src/accessorTree/useEnvironmentWithSchema.cjs +31 -0
  70. package/dist/development/src/accessorTree/useEnvironmentWithSchema.cjs.map +1 -0
  71. package/dist/development/src/accessorTree/useEnvironmentWithSchema.js +31 -0
  72. package/dist/development/src/accessorTree/useEnvironmentWithSchema.js.map +1 -0
  73. package/dist/development/src/coreComponents/Component.cjs.map +1 -1
  74. package/dist/development/src/coreComponents/Component.js.map +1 -1
  75. package/dist/development/src/coreComponents/DataBindingProvider.cjs +4 -14
  76. package/dist/development/src/coreComponents/DataBindingProvider.cjs.map +1 -1
  77. package/dist/development/src/coreComponents/DataBindingProvider.js +4 -14
  78. package/dist/development/src/coreComponents/DataBindingProvider.js.map +1 -1
  79. package/dist/development/src/coreComponents/EntityListSubTree.cjs +5 -14
  80. package/dist/development/src/coreComponents/EntityListSubTree.cjs.map +1 -1
  81. package/dist/development/src/coreComponents/EntityListSubTree.js +5 -14
  82. package/dist/development/src/coreComponents/EntityListSubTree.js.map +1 -1
  83. package/dist/development/src/coreComponents/EntitySubTree.cjs +7 -16
  84. package/dist/development/src/coreComponents/EntitySubTree.cjs.map +1 -1
  85. package/dist/development/src/coreComponents/EntitySubTree.js +7 -16
  86. package/dist/development/src/coreComponents/EntitySubTree.js.map +1 -1
  87. package/dist/development/src/entityEvents/useDerivedField.cjs +3 -3
  88. package/dist/development/src/entityEvents/useDerivedField.cjs.map +1 -1
  89. package/dist/development/src/entityEvents/useDerivedField.js +3 -3
  90. package/dist/development/src/entityEvents/useDerivedField.js.map +1 -1
  91. package/dist/development/src/helperComponents/DeferredSubTrees.cjs +2 -3
  92. package/dist/development/src/helperComponents/DeferredSubTrees.cjs.map +1 -1
  93. package/dist/development/src/helperComponents/DeferredSubTrees.js +3 -4
  94. package/dist/development/src/helperComponents/DeferredSubTrees.js.map +1 -1
  95. package/dist/development/src/helperComponents/FieldView.cjs +1 -1
  96. package/dist/development/src/helperComponents/FieldView.cjs.map +1 -1
  97. package/dist/development/src/helperComponents/FieldView.js +1 -1
  98. package/dist/development/src/helperComponents/FieldView.js.map +1 -1
  99. package/dist/development/src/markers/IncrementalMarkerBuilder.cjs +56 -0
  100. package/dist/development/src/markers/IncrementalMarkerBuilder.cjs.map +1 -0
  101. package/dist/development/src/markers/IncrementalMarkerBuilder.js +56 -0
  102. package/dist/development/src/markers/IncrementalMarkerBuilder.js.map +1 -0
  103. package/dist/development/src/markers/MarkerStaticAnalyzer.cjs +110 -0
  104. package/dist/development/src/markers/MarkerStaticAnalyzer.cjs.map +1 -0
  105. package/dist/development/src/markers/MarkerStaticAnalyzer.js +110 -0
  106. package/dist/development/src/markers/MarkerStaticAnalyzer.js.map +1 -0
  107. package/dist/development/src/markers/MarkerTreeGenerator.cjs +52 -0
  108. package/dist/development/src/markers/MarkerTreeGenerator.cjs.map +1 -0
  109. package/dist/development/src/markers/MarkerTreeGenerator.js +52 -0
  110. package/dist/development/src/markers/MarkerTreeGenerator.js.map +1 -0
  111. package/dist/production/index.cjs +2 -9
  112. package/dist/production/index.cjs.map +1 -1
  113. package/dist/production/index.js +1 -8
  114. package/dist/production/index.js.map +1 -1
  115. package/dist/production/src/accessorPropagation/AccessorProvider.cjs +1 -1
  116. package/dist/production/src/accessorPropagation/AccessorProvider.cjs.map +1 -1
  117. package/dist/production/src/accessorPropagation/AccessorProvider.js +1 -1
  118. package/dist/production/src/accessorPropagation/AccessorProvider.js.map +1 -1
  119. package/dist/production/src/accessorPropagation/BindingOperationsContext.cjs +2 -1
  120. package/dist/production/src/accessorPropagation/BindingOperationsContext.cjs.map +1 -1
  121. package/dist/production/src/accessorPropagation/BindingOperationsContext.js +2 -1
  122. package/dist/production/src/accessorPropagation/BindingOperationsContext.js.map +1 -1
  123. package/dist/production/src/accessorPropagation/EntityKeyContext.cjs.map +1 -1
  124. package/dist/production/src/accessorPropagation/EntityKeyContext.js.map +1 -1
  125. package/dist/production/src/accessorPropagation/EntityKeyProvider.cjs.map +1 -1
  126. package/dist/production/src/accessorPropagation/EntityKeyProvider.js.map +1 -1
  127. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.cjs +14 -37
  128. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.cjs.map +1 -1
  129. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.js +15 -38
  130. package/dist/production/src/accessorPropagation/useAccessorUpdateSubscription.js.map +1 -1
  131. package/dist/production/src/accessorPropagation/useEntity.cjs +4 -4
  132. package/dist/production/src/accessorPropagation/useEntity.cjs.map +1 -1
  133. package/dist/production/src/accessorPropagation/useEntity.js +4 -4
  134. package/dist/production/src/accessorPropagation/useEntity.js.map +1 -1
  135. package/dist/production/src/accessorPropagation/useEntityKey.cjs.map +1 -1
  136. package/dist/production/src/accessorPropagation/useEntityKey.js.map +1 -1
  137. package/dist/production/src/accessorPropagation/useEntityList.cjs +3 -3
  138. package/dist/production/src/accessorPropagation/useEntityList.cjs.map +1 -1
  139. package/dist/production/src/accessorPropagation/useEntityList.js +3 -3
  140. package/dist/production/src/accessorPropagation/useEntityList.js.map +1 -1
  141. package/dist/production/src/accessorPropagation/useEntityListSubTree.cjs +1 -1
  142. package/dist/production/src/accessorPropagation/useEntityListSubTree.cjs.map +1 -1
  143. package/dist/production/src/accessorPropagation/useEntityListSubTree.js +1 -1
  144. package/dist/production/src/accessorPropagation/useEntityListSubTree.js.map +1 -1
  145. package/dist/production/src/accessorPropagation/useEntitySubTree.cjs +1 -1
  146. package/dist/production/src/accessorPropagation/useEntitySubTree.cjs.map +1 -1
  147. package/dist/production/src/accessorPropagation/useEntitySubTree.js +1 -1
  148. package/dist/production/src/accessorPropagation/useEntitySubTree.js.map +1 -1
  149. package/dist/production/src/accessorPropagation/useField.cjs +3 -3
  150. package/dist/production/src/accessorPropagation/useField.cjs.map +1 -1
  151. package/dist/production/src/accessorPropagation/useField.js +3 -3
  152. package/dist/production/src/accessorPropagation/useField.js.map +1 -1
  153. package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.cjs +2 -2
  154. package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.cjs.map +1 -1
  155. package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.js +2 -2
  156. package/dist/production/src/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
  157. package/dist/production/src/accessorSorting/addEntityAtIndex.cjs +1 -1
  158. package/dist/production/src/accessorSorting/addEntityAtIndex.cjs.map +1 -1
  159. package/dist/production/src/accessorSorting/addEntityAtIndex.js +1 -1
  160. package/dist/production/src/accessorSorting/addEntityAtIndex.js.map +1 -1
  161. package/dist/production/src/accessorSorting/repairEntitiesOrder.cjs +1 -1
  162. package/dist/production/src/accessorSorting/repairEntitiesOrder.cjs.map +1 -1
  163. package/dist/production/src/accessorSorting/repairEntitiesOrder.js +1 -1
  164. package/dist/production/src/accessorSorting/repairEntitiesOrder.js.map +1 -1
  165. package/dist/production/src/accessorSorting/sortEntities.cjs +2 -2
  166. package/dist/production/src/accessorSorting/sortEntities.cjs.map +1 -1
  167. package/dist/production/src/accessorSorting/sortEntities.js +2 -2
  168. package/dist/production/src/accessorSorting/sortEntities.js.map +1 -1
  169. package/dist/production/src/accessorTree/AccessorTree.cjs +3 -1
  170. package/dist/production/src/accessorTree/AccessorTree.cjs.map +1 -1
  171. package/dist/production/src/accessorTree/AccessorTree.js +3 -1
  172. package/dist/production/src/accessorTree/AccessorTree.js.map +1 -1
  173. package/dist/production/src/accessorTree/useDataBinding.cjs +23 -36
  174. package/dist/production/src/accessorTree/useDataBinding.cjs.map +1 -1
  175. package/dist/production/src/accessorTree/useDataBinding.js +26 -39
  176. package/dist/production/src/accessorTree/useDataBinding.js.map +1 -1
  177. package/dist/production/src/accessorTree/useEnvironmentWithSchema.cjs +31 -0
  178. package/dist/production/src/accessorTree/useEnvironmentWithSchema.cjs.map +1 -0
  179. package/dist/production/src/accessorTree/useEnvironmentWithSchema.js +31 -0
  180. package/dist/production/src/accessorTree/useEnvironmentWithSchema.js.map +1 -0
  181. package/dist/production/src/coreComponents/Component.cjs.map +1 -1
  182. package/dist/production/src/coreComponents/Component.js.map +1 -1
  183. package/dist/production/src/coreComponents/DataBindingProvider.cjs +3 -5
  184. package/dist/production/src/coreComponents/DataBindingProvider.cjs.map +1 -1
  185. package/dist/production/src/coreComponents/DataBindingProvider.js +3 -5
  186. package/dist/production/src/coreComponents/DataBindingProvider.js.map +1 -1
  187. package/dist/production/src/coreComponents/EntityListSubTree.cjs +2 -11
  188. package/dist/production/src/coreComponents/EntityListSubTree.cjs.map +1 -1
  189. package/dist/production/src/coreComponents/EntityListSubTree.js +2 -11
  190. package/dist/production/src/coreComponents/EntityListSubTree.js.map +1 -1
  191. package/dist/production/src/coreComponents/EntitySubTree.cjs +2 -11
  192. package/dist/production/src/coreComponents/EntitySubTree.cjs.map +1 -1
  193. package/dist/production/src/coreComponents/EntitySubTree.js +2 -11
  194. package/dist/production/src/coreComponents/EntitySubTree.js.map +1 -1
  195. package/dist/production/src/entityEvents/useDerivedField.cjs +3 -3
  196. package/dist/production/src/entityEvents/useDerivedField.cjs.map +1 -1
  197. package/dist/production/src/entityEvents/useDerivedField.js +3 -3
  198. package/dist/production/src/entityEvents/useDerivedField.js.map +1 -1
  199. package/dist/production/src/helperComponents/DeferredSubTrees.cjs +2 -3
  200. package/dist/production/src/helperComponents/DeferredSubTrees.cjs.map +1 -1
  201. package/dist/production/src/helperComponents/DeferredSubTrees.js +3 -4
  202. package/dist/production/src/helperComponents/DeferredSubTrees.js.map +1 -1
  203. package/dist/production/src/helperComponents/FieldView.cjs +1 -1
  204. package/dist/production/src/helperComponents/FieldView.cjs.map +1 -1
  205. package/dist/production/src/helperComponents/FieldView.js +1 -1
  206. package/dist/production/src/helperComponents/FieldView.js.map +1 -1
  207. package/dist/production/src/markers/IncrementalMarkerBuilder.cjs +56 -0
  208. package/dist/production/src/markers/IncrementalMarkerBuilder.cjs.map +1 -0
  209. package/dist/production/src/markers/IncrementalMarkerBuilder.js +56 -0
  210. package/dist/production/src/markers/IncrementalMarkerBuilder.js.map +1 -0
  211. package/dist/production/src/markers/MarkerStaticAnalyzer.cjs +110 -0
  212. package/dist/production/src/markers/MarkerStaticAnalyzer.cjs.map +1 -0
  213. package/dist/production/src/markers/MarkerStaticAnalyzer.js +110 -0
  214. package/dist/production/src/markers/MarkerStaticAnalyzer.js.map +1 -0
  215. package/dist/production/src/markers/MarkerTreeGenerator.cjs +52 -0
  216. package/dist/production/src/markers/MarkerTreeGenerator.cjs.map +1 -0
  217. package/dist/production/src/markers/MarkerTreeGenerator.js +52 -0
  218. package/dist/production/src/markers/MarkerTreeGenerator.js.map +1 -0
  219. package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +1 -1
  220. package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
  221. package/dist/types/accessorPropagation/EntityKeyContext.d.ts +2 -1
  222. package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
  223. package/dist/types/accessorPropagation/EntityKeyProvider.d.ts +2 -1
  224. package/dist/types/accessorPropagation/EntityKeyProvider.d.ts.map +1 -1
  225. package/dist/types/accessorPropagation/EnvironmentContext.d.ts +2 -2
  226. package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
  227. package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +1 -1
  228. package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -1
  229. package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts +7 -12
  230. package/dist/types/accessorPropagation/useAccessorUpdateSubscription.d.ts.map +1 -1
  231. package/dist/types/accessorPropagation/useEntityKey.d.ts +2 -1
  232. package/dist/types/accessorPropagation/useEntityKey.d.ts.map +1 -1
  233. package/dist/types/accessorPropagation/useEntitySubTree.d.ts +1 -2
  234. package/dist/types/accessorPropagation/useEntitySubTree.d.ts.map +1 -1
  235. package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +1 -1
  236. package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
  237. package/dist/types/accessorSorting/index.d.ts +0 -2
  238. package/dist/types/accessorSorting/index.d.ts.map +1 -1
  239. package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -1
  240. package/dist/types/accessorTree/AccessorTreeState.d.ts +1 -4
  241. package/dist/types/accessorTree/AccessorTreeState.d.ts.map +1 -1
  242. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +1 -1
  243. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -1
  244. package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts +0 -2
  245. package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts.map +1 -1
  246. package/dist/types/accessorTree/DirtinessContext.d.ts +1 -1
  247. package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -1
  248. package/dist/types/accessorTree/MutationStateContext.d.ts +1 -1
  249. package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -1
  250. package/dist/types/accessorTree/index.d.ts +0 -1
  251. package/dist/types/accessorTree/index.d.ts.map +1 -1
  252. package/dist/types/accessorTree/useDataBinding.d.ts +6 -2
  253. package/dist/types/accessorTree/useDataBinding.d.ts.map +1 -1
  254. package/dist/types/accessorTree/useEnvironmentWithSchema.d.ts +3 -0
  255. package/dist/types/accessorTree/useEnvironmentWithSchema.d.ts.map +1 -0
  256. package/dist/types/coreComponents/Component.d.ts +1 -1
  257. package/dist/types/coreComponents/Component.d.ts.map +1 -1
  258. package/dist/types/coreComponents/DataBindingProvider.d.ts +8 -8
  259. package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
  260. package/dist/types/coreComponents/Entity.d.ts +1 -1
  261. package/dist/types/coreComponents/Entity.d.ts.map +1 -1
  262. package/dist/types/coreComponents/EntityListSubTree.d.ts +1 -1
  263. package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
  264. package/dist/types/coreComponents/EntitySubTree.d.ts +1 -1
  265. package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
  266. package/dist/types/coreComponents/ParentEntity.d.ts +1 -1
  267. package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -1
  268. package/dist/types/coreComponents/index.d.ts +0 -1
  269. package/dist/types/coreComponents/index.d.ts.map +1 -1
  270. package/dist/types/helperComponents/DeferredSubTrees.d.ts +1 -1
  271. package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -1
  272. package/dist/types/helperComponents/If.d.ts +1 -1
  273. package/dist/types/helperComponents/If.d.ts.map +1 -1
  274. package/dist/types/helperComponents/LabelMiddleware.d.ts +1 -1
  275. package/dist/types/helperComponents/LabelMiddleware.d.ts.map +1 -1
  276. package/dist/types/helperComponents/StaticRender.d.ts +1 -1
  277. package/dist/types/helperComponents/StaticRender.d.ts.map +1 -1
  278. package/dist/types/helperComponents/Variable.d.ts +1 -1
  279. package/dist/types/helperComponents/Variable.d.ts.map +1 -1
  280. package/dist/types/index.d.ts +1 -1
  281. package/dist/types/index.d.ts.map +1 -1
  282. package/dist/types/markers/IncrementalMarkerBuilder.d.ts +5 -0
  283. package/dist/types/markers/IncrementalMarkerBuilder.d.ts.map +1 -0
  284. package/dist/types/{coreComponents → markers}/MarkerProvider.d.ts +1 -2
  285. package/dist/types/markers/MarkerProvider.d.ts.map +1 -0
  286. package/dist/types/markers/MarkerStaticAnalyzer.d.ts +14 -0
  287. package/dist/types/markers/MarkerStaticAnalyzer.d.ts.map +1 -0
  288. package/dist/types/markers/MarkerTreeGenerator.d.ts +10 -0
  289. package/dist/types/markers/MarkerTreeGenerator.d.ts.map +1 -0
  290. package/dist/types/markers/index.d.ts +3 -0
  291. package/dist/types/markers/index.d.ts.map +1 -0
  292. package/dist/types/tsconfig.tsbuildinfo +1 -1
  293. package/package.json +8 -7
  294. package/src/accessorPropagation/AccessorProvider.tsx +1 -1
  295. package/src/accessorPropagation/BindingOperationsContext.ts +1 -0
  296. package/src/accessorPropagation/EntityKeyContext.ts +2 -1
  297. package/src/accessorPropagation/EntityKeyProvider.tsx +2 -1
  298. package/src/accessorPropagation/useAccessorUpdateSubscription.ts +19 -87
  299. package/src/accessorPropagation/useEntity.ts +4 -4
  300. package/src/accessorPropagation/useEntityKey.ts +2 -2
  301. package/src/accessorPropagation/useEntityList.ts +3 -3
  302. package/src/accessorPropagation/useEntityListSubTree.ts +1 -1
  303. package/src/accessorPropagation/useEntitySubTree.ts +3 -4
  304. package/src/accessorPropagation/useField.ts +3 -3
  305. package/src/accessorSorting/SetOrderFieldOnCreate.tsx +2 -2
  306. package/src/accessorSorting/addEntityAtIndex.ts +1 -1
  307. package/src/accessorSorting/index.ts +0 -2
  308. package/src/accessorSorting/repairEntitiesOrder.ts +1 -1
  309. package/src/accessorSorting/sortEntities.ts +2 -2
  310. package/src/accessorTree/AccessorTree.tsx +17 -12
  311. package/src/accessorTree/AccessorTreeState.ts +1 -4
  312. package/src/accessorTree/AccessorTreeStateOptions.ts +0 -2
  313. package/src/accessorTree/index.ts +0 -1
  314. package/src/accessorTree/useDataBinding.ts +35 -44
  315. package/src/accessorTree/useEnvironmentWithSchema.ts +31 -0
  316. package/src/coreComponents/Component.tsx +2 -2
  317. package/src/coreComponents/DataBindingProvider.tsx +22 -35
  318. package/src/coreComponents/EntityListSubTree.tsx +4 -18
  319. package/src/coreComponents/EntitySubTree.tsx +5 -20
  320. package/src/coreComponents/index.ts +0 -1
  321. package/src/entityEvents/useDerivedField.ts +3 -3
  322. package/src/helperComponents/DeferredSubTrees.tsx +1 -5
  323. package/src/helperComponents/FieldView.tsx +1 -1
  324. package/src/index.ts +1 -1
  325. package/src/markers/IncrementalMarkerBuilder.ts +60 -0
  326. package/src/{coreComponents → markers}/MarkerProvider.ts +2 -2
  327. package/src/markers/MarkerStaticAnalyzer.ts +132 -0
  328. package/src/markers/MarkerTreeGenerator.ts +72 -0
  329. package/src/markers/index.ts +2 -0
  330. package/src/tsconfig.json +2 -1
  331. package/src/typings/react-fix.d.ts +12 -0
  332. package/tests/cases/unit/model/markerTreeGenerator.spec.tsx +44 -9
  333. package/tests/lib/bindingFactory.ts +1 -1
  334. package/dist/development/src/MarkerTreeGenerator.cjs +0 -89
  335. package/dist/development/src/MarkerTreeGenerator.cjs.map +0 -1
  336. package/dist/development/src/MarkerTreeGenerator.js +0 -89
  337. package/dist/development/src/MarkerTreeGenerator.js.map +0 -1
  338. package/dist/development/src/accessorSorting/errors.cjs +0 -10
  339. package/dist/development/src/accessorSorting/errors.cjs.map +0 -1
  340. package/dist/development/src/accessorSorting/errors.js +0 -10
  341. package/dist/development/src/accessorSorting/errors.js.map +0 -1
  342. package/dist/development/src/accessorSorting/moveEntity.cjs +0 -42
  343. package/dist/development/src/accessorSorting/moveEntity.cjs.map +0 -1
  344. package/dist/development/src/accessorSorting/moveEntity.js +0 -42
  345. package/dist/development/src/accessorSorting/moveEntity.js.map +0 -1
  346. package/dist/development/src/accessorSorting/useSortedEntities.cjs +0 -80
  347. package/dist/development/src/accessorSorting/useSortedEntities.cjs.map +0 -1
  348. package/dist/development/src/accessorSorting/useSortedEntities.js +0 -80
  349. package/dist/development/src/accessorSorting/useSortedEntities.js.map +0 -1
  350. package/dist/development/src/accessorTree/accessorTreeStateReducer.cjs +0 -34
  351. package/dist/development/src/accessorTree/accessorTreeStateReducer.cjs.map +0 -1
  352. package/dist/development/src/accessorTree/accessorTreeStateReducer.js +0 -34
  353. package/dist/development/src/accessorTree/accessorTreeStateReducer.js.map +0 -1
  354. package/dist/development/src/core/IncrementalMarkerBuilder.cjs +0 -63
  355. package/dist/development/src/core/IncrementalMarkerBuilder.cjs.map +0 -1
  356. package/dist/development/src/core/IncrementalMarkerBuilder.js +0 -63
  357. package/dist/development/src/core/IncrementalMarkerBuilder.js.map +0 -1
  358. package/dist/production/src/MarkerTreeGenerator.cjs +0 -89
  359. package/dist/production/src/MarkerTreeGenerator.cjs.map +0 -1
  360. package/dist/production/src/MarkerTreeGenerator.js +0 -89
  361. package/dist/production/src/MarkerTreeGenerator.js.map +0 -1
  362. package/dist/production/src/accessorSorting/errors.cjs +0 -10
  363. package/dist/production/src/accessorSorting/errors.cjs.map +0 -1
  364. package/dist/production/src/accessorSorting/errors.js +0 -10
  365. package/dist/production/src/accessorSorting/errors.js.map +0 -1
  366. package/dist/production/src/accessorSorting/moveEntity.cjs +0 -42
  367. package/dist/production/src/accessorSorting/moveEntity.cjs.map +0 -1
  368. package/dist/production/src/accessorSorting/moveEntity.js +0 -42
  369. package/dist/production/src/accessorSorting/moveEntity.js.map +0 -1
  370. package/dist/production/src/accessorSorting/useSortedEntities.cjs +0 -80
  371. package/dist/production/src/accessorSorting/useSortedEntities.cjs.map +0 -1
  372. package/dist/production/src/accessorSorting/useSortedEntities.js +0 -80
  373. package/dist/production/src/accessorSorting/useSortedEntities.js.map +0 -1
  374. package/dist/production/src/accessorTree/accessorTreeStateReducer.cjs +0 -34
  375. package/dist/production/src/accessorTree/accessorTreeStateReducer.cjs.map +0 -1
  376. package/dist/production/src/accessorTree/accessorTreeStateReducer.js +0 -34
  377. package/dist/production/src/accessorTree/accessorTreeStateReducer.js.map +0 -1
  378. package/dist/production/src/core/IncrementalMarkerBuilder.cjs +0 -63
  379. package/dist/production/src/core/IncrementalMarkerBuilder.cjs.map +0 -1
  380. package/dist/production/src/core/IncrementalMarkerBuilder.js +0 -63
  381. package/dist/production/src/core/IncrementalMarkerBuilder.js.map +0 -1
  382. package/dist/types/MarkerTreeGenerator.d.ts +0 -14
  383. package/dist/types/MarkerTreeGenerator.d.ts.map +0 -1
  384. package/dist/types/accessorSorting/errors.d.ts +0 -3
  385. package/dist/types/accessorSorting/errors.d.ts.map +0 -1
  386. package/dist/types/accessorSorting/moveEntity.d.ts +0 -4
  387. package/dist/types/accessorSorting/moveEntity.d.ts.map +0 -1
  388. package/dist/types/accessorSorting/useSortedEntities.d.ts +0 -5
  389. package/dist/types/accessorSorting/useSortedEntities.d.ts.map +0 -1
  390. package/dist/types/accessorTree/accessorTreeStateReducer.d.ts +0 -4
  391. package/dist/types/accessorTree/accessorTreeStateReducer.d.ts.map +0 -1
  392. package/dist/types/core/IncrementalMarkerBuilder.d.ts +0 -7
  393. package/dist/types/core/IncrementalMarkerBuilder.d.ts.map +0 -1
  394. package/dist/types/coreComponents/MarkerProvider.d.ts.map +0 -1
  395. package/src/MarkerTreeGenerator.ts +0 -121
  396. package/src/accessorSorting/errors.ts +0 -9
  397. package/src/accessorSorting/moveEntity.ts +0 -65
  398. package/src/accessorSorting/useSortedEntities.ts +0 -102
  399. package/src/accessorTree/accessorTreeStateReducer.ts +0 -36
  400. package/src/core/IncrementalMarkerBuilder.ts +0 -64
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListSubTree.js","sources":["../../../../../packages/react-binding/src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode, useCallback } from 'react'\nimport {\n\tuseAccessorUpdateSubscription,\n\tuseEntityListSubTreeParameters,\n\tuseGetEntityListSubTree,\n} from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '@contember/binding'\nimport { Environment } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '@contember/binding'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n(\n\t| {}\n\t| {\n\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\tlistProps?: ListProps\n\t\t }\n)\n\n/**\n * Creates a subtree with list of entities in current data binding context.\n *\n * @example\n * ```\n * <EntityListSubTree entities=\"Post\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntityListSubTree()\n\t\tconst parameters = useEntityListSubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityListSubtree(environment, props)\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":["this"],"mappings":";;;;;;;;;;AA2CO,MAAM,oBAAoB;AAAA,EAChC,CAAyB,UAA0D;AACxD,8BAAA,MAAM,YAAY,6CAA6C;AAEzF,UAAM,aAAa;AACb,UAAA,aAAa,+BAA+B,KAAK;AACvD,UAAM,cAAc;AAAA,MACnB,MAAM,WAAW,YAAY,MAAM,UAAU;AAAA,MAC7C,CAAC,YAAY,YAAY,MAAM,UAAU;AAAA,IAAA;AAEpC,UAAA,WAAW,8BAA8B,WAAW;AAQ1D,WAAQ,uBAAA,YAAA,EAAY,GAAG,OAAO,YAAvB,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA2C,GAAAA,MAAA;AAAA,EACnD;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAO,cAAc,2CAA2C,OAAO,QAAQ,WAAW;AAAA,MAC3F;AACA,aAAO,cAAc,8BAA8B,OAAO,QAAQ,WAAW;AAAA,IAC9E;AAAA,IACA,cAAc,CACb,UAAA,uBAAC,cAAY,GAAG,OAAO,UAAU,GAChC,UAAA;AAAA,MAAC,uBAAA,OAAA,EAAM,OAAO,iBAAd,GAAA,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAgC,GAAAA,MAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,KAFR,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAGA,GAAAA,MAAA;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,sCAAsC,aAAa,KAAK;AAAA,IAC3F;AAAA,EACD;AAAA,EACA;AACD;"}
1
+ {"version":3,"file":"EntityListSubTree.js","sources":["../../../../../packages/react-binding/src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityListSubTree } from '../accessorPropagation'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '@contember/binding'\nimport { Environment, MarkerFactory, PRIMARY_KEY_NAME, TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n(\n\t| {}\n\t| {\n\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\tlistProps?: ListProps\n\t\t }\n)\n\n/**\n * Creates a subtree with list of entities in current data binding context.\n *\n * @example\n * ```\n * <EntityListSubTree entities=\"Post\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\t\tconst accessor = useEntityListSubTree(props, ...props.treeRootId ? [props.treeRootId] : [])\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityListSubtree(environment, props)\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":["this"],"mappings":";;;;;;;AAoCO,MAAM,oBAAoB;AAAA,EAChC,CAAyB,UAA0D;AACxD,8BAAA,MAAM,YAAY,6CAA6C;AACnF,UAAA,WAAW,qBAAqB,OAAO,GAAG,MAAM,aAAa,CAAC,MAAM,UAAU,IAAI,CAAA,CAAE;AAQ1F,WAAQ,uBAAA,YAAA,EAAY,GAAG,OAAO,YAAvB,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA2C,GAAAA,MAAA;AAAA,EACnD;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAO,cAAc,2CAA2C,OAAO,QAAQ,WAAW;AAAA,MAC3F;AACA,aAAO,cAAc,8BAA8B,OAAO,QAAQ,WAAW;AAAA,IAC9E;AAAA,IACA,cAAc,CACb,UAAA,uBAAC,cAAY,GAAG,OAAO,UAAU,GAChC,UAAA;AAAA,MAAC,uBAAA,OAAA,EAAM,OAAO,iBAAd,GAAA,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAgC,GAAAA,MAAA;AAAA,MAC/B,MAAM;AAAA,IAAA,KAFR,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAGA,GAAAA,MAAA;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,sCAAsC,aAAa,KAAK;AAAA,IAC3F;AAAA,EACD;AAAA,EACA;AACD;"}
@@ -2,28 +2,19 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxDevRuntime = require("react/jsx-dev-runtime");
4
4
  const reactUtils = require("@contember/react-utils");
5
- const React = require("react");
6
5
  const binding = require("@contember/binding");
7
6
  const Component = require("./Component.cjs");
8
7
  const Entity = require("./Entity.cjs");
9
8
  const Field = require("./Field.cjs");
10
9
  const SetOrderFieldOnCreate = require("../accessorSorting/SetOrderFieldOnCreate.cjs");
11
- const useGetEntitySubTree = require("../accessorPropagation/useGetEntitySubTree.cjs");
12
- const useEntitySubTreeParameters = require("../accessorPropagation/useEntitySubTreeParameters.cjs");
13
- const useAccessorUpdateSubscription = require("../accessorPropagation/useAccessorUpdateSubscription.cjs");
10
+ const useEntitySubTree = require("../accessorPropagation/useEntitySubTree.cjs");
14
11
  const EntitySubTree = Component.Component(
15
12
  (props) => {
16
13
  reactUtils.useConstantValueInvariant(props.isCreating, "EntitySubTree: cannot update isCreating");
17
- const getSubTree = useGetEntitySubTree.useGetEntitySubTree();
18
- const parameters = useEntitySubTreeParameters.useEntitySubTreeParameters(props);
19
- const getAccessor = React.useCallback(
20
- () => getSubTree(parameters, props.treeRootId),
21
- [getSubTree, parameters, props.treeRootId]
22
- );
23
- const accessor = useAccessorUpdateSubscription.useAccessorUpdateSubscription(getAccessor);
14
+ const accessor = useEntitySubTree.useEntitySubTree(props, ...props.treeRootId ? [props.treeRootId] : []);
24
15
  return /* @__PURE__ */ jsxDevRuntime.jsxDEV(Entity.Entity, { ...props, accessor }, void 0, false, {
25
16
  fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/EntitySubTree.tsx",
26
- lineNumber: 63,
17
+ lineNumber: 48,
27
18
  columnNumber: 10
28
19
  }, void 0);
29
20
  },
@@ -38,13 +29,13 @@ const EntitySubTree = Component.Component(
38
29
  /* @__PURE__ */ jsxDevRuntime.jsxDEV(Entity.Entity, { ...props, accessor: 0, children: [
39
30
  /* @__PURE__ */ jsxDevRuntime.jsxDEV(Field.Field, { field: binding.PRIMARY_KEY_NAME }, void 0, false, {
40
31
  fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/EntitySubTree.tsx",
41
- lineNumber: 75,
32
+ lineNumber: 60,
42
33
  columnNumber: 6
43
34
  }, void 0),
44
35
  props.children
45
36
  ] }, void 0, true, {
46
37
  fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/EntitySubTree.tsx",
47
- lineNumber: 74,
38
+ lineNumber: 59,
48
39
  columnNumber: 5
49
40
  }, void 0),
50
41
  props.isCreating && "orderField" in props && /* @__PURE__ */ jsxDevRuntime.jsxDEV(
@@ -58,14 +49,14 @@ const EntitySubTree = Component.Component(
58
49
  false,
59
50
  {
60
51
  fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/EntitySubTree.tsx",
61
- lineNumber: 79,
52
+ lineNumber: 64,
62
53
  columnNumber: 6
63
54
  },
64
55
  void 0
65
56
  )
66
57
  ] }, void 0, true, {
67
58
  fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/EntitySubTree.tsx",
68
- lineNumber: 73,
59
+ lineNumber: 58,
69
60
  columnNumber: 4
70
61
  }, void 0),
71
62
  generateEnvironment: (props, oldEnvironment) => {
@@ -1 +1 @@
1
- {"version":3,"file":"EntitySubTree.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '@contember/binding'\nimport { Environment } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '@contember/binding'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\n/**\n * Creates a single entity subtree in current data binding context.\n *\n * @example\n * ```\n * <EntitySubTree entity=\"Post(id = $id)\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":["Component","useConstantValueInvariant","useGetEntitySubTree","useEntitySubTreeParameters","useCallback","useAccessorUpdateSubscription","jsxDEV","Entity","this","MarkerFactory","Fragment","Field","PRIMARY_KEY_NAME","SetOrderFieldOnCreate","TreeNodeEnvironmentFactory"],"mappings":";;;;;;;;;;;;;AA4CO,MAAM,gBAAgBA,UAAA;AAAA,EAC5B,CAAyB,UAA2C;AACzCC,eAAAA,0BAAA,MAAM,YAAY,yCAAyC;AAErF,UAAM,aAAaC,oBAAAA;AACb,UAAA,aAAaC,sDAA2B,KAAK;AACnD,UAAM,cAAcC,MAAA;AAAA,MACnB,MAAM,WAAW,YAAY,MAAM,UAAU;AAAA,MAC7C,CAAC,YAAY,YAAY,MAAM,UAAU;AAAA,IAAA;AAEpC,UAAA,WAAWC,4DAA8B,WAAW;AAQ1D,WAAQC,8BAAA,OAAAC,OAAA,QAAA,EAAQ,GAAG,OAAO,YAAnB,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAuC,GAAAC,MAAA;AAAA,EAC/C;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAOC,QAAc,cAAA,uCAAuC,OAAO,QAAQ,WAAW;AAAA,MACvF;AACA,aAAOA,QAAc,cAAA,0BAA0B,OAAO,QAAQ,WAAW;AAAA,IAC1E;AAAA,IACA,cAAc,WAEZH,8BAAA,OAAAI,cAAA,UAAA,EAAA,UAAA;AAAA,MAAAJ,8BAAA,OAACC,OAAQ,QAAA,EAAA,GAAG,OAAO,UAAU,GAC5B,UAAA;AAAA,QAACD,8BAAA,OAAAK,MAAA,OAAA,EAAM,OAAOC,QAAd,iBAAA,GAAA,QAAA,OAAA;AAAA,UAAA,UAAA;AAAA,UAAA,YAAA;AAAA,UAAA,cAAA;AAAA,QAAgC,GAAAJ,MAAA;AAAA,QAC/B,MAAM;AAAA,MAAA,KAFR,QAAA,MAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAGA,GAAAA,MAAA;AAAA,MACC,MAAM,cAAc,gBAAgB,SACpCF,8BAAA;AAAA,QAACO,sBAAA;AAAA,QAAA;AAAA,UACA,YAAY,MAAM;AAAA,UAClB,oBAAoB,MAAM;AAAA,UAC1B,QAAQ,MAAM;AAAA,QAAA;AAAA,QAHf;AAAA,QAAA;AAAA,QAAA;AAAA,UAAA,UAAA;AAAA,UAAA,YAAA;AAAA,UAAA,cAAA;AAAA,QAAA;AAAA,QAAAL;AAAAA,MAIA;AAAA,IAAA,KAVF,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAYA,GAAAA,MAAA;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAAM,mCAA2B,kCAAkC,aAAa,KAAK;AAAA,IACvF;AAAA,EACD;AAAA,EACA;AACD;;"}
1
+ {"version":3,"file":"EntitySubTree.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode } from 'react'\nimport { useEntitySubTree } from '../accessorPropagation'\nimport type { SugaredQualifiedSingleEntity, SugaredUnconstrainedQualifiedSingleEntity, TreeRootId } from '@contember/binding'\nimport { Environment, MarkerFactory, PRIMARY_KEY_NAME, TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\n/**\n * Creates a single entity subtree in current data binding context.\n *\n * @example\n * ```\n * <EntitySubTree entity=\"Post(id = $id)\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\t\tconst accessor = useEntitySubTree(props, ...props.treeRootId ? [props.treeRootId] : [])\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":["Component","useConstantValueInvariant","useEntitySubTree","jsxDEV","Entity","this","MarkerFactory","Fragment","Field","PRIMARY_KEY_NAME","SetOrderFieldOnCreate","TreeNodeEnvironmentFactory"],"mappings":";;;;;;;;;;AAqCO,MAAM,gBAAgBA,UAAA;AAAA,EAC5B,CAAyB,UAA2C;AACzCC,eAAAA,0BAAA,MAAM,YAAY,yCAAyC;AAC/E,UAAA,WAAWC,iBAAAA,iBAAiB,OAAO,GAAG,MAAM,aAAa,CAAC,MAAM,UAAU,IAAI,CAAA,CAAE;AAOtF,WAAQC,8BAAA,OAAAC,OAAA,QAAA,EAAQ,GAAG,OAAO,YAAnB,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAuC,GAAAC,MAAA;AAAA,EAC/C;AAAA,EACA;AAAA,IACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,UAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,eAAOC,QAAc,cAAA,uCAAuC,OAAO,QAAQ,WAAW;AAAA,MACvF;AACA,aAAOA,QAAc,cAAA,0BAA0B,OAAO,QAAQ,WAAW;AAAA,IAC1E;AAAA,IACA,cAAc,WAEZH,8BAAA,OAAAI,cAAA,UAAA,EAAA,UAAA;AAAA,MAAAJ,8BAAA,OAACC,OAAQ,QAAA,EAAA,GAAG,OAAO,UAAU,GAC5B,UAAA;AAAA,QAACD,8BAAA,OAAAK,MAAA,OAAA,EAAM,OAAOC,QAAd,iBAAA,GAAA,QAAA,OAAA;AAAA,UAAA,UAAA;AAAA,UAAA,YAAA;AAAA,UAAA,cAAA;AAAA,QAAgC,GAAAJ,MAAA;AAAA,QAC/B,MAAM;AAAA,MAAA,KAFR,QAAA,MAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAGA,GAAAA,MAAA;AAAA,MACC,MAAM,cAAc,gBAAgB,SACpCF,8BAAA;AAAA,QAACO,sBAAA;AAAA,QAAA;AAAA,UACA,YAAY,MAAM;AAAA,UAClB,oBAAoB,MAAM;AAAA,UAC1B,QAAQ,MAAM;AAAA,QAAA;AAAA,QAHf;AAAA,QAAA;AAAA,QAAA;AAAA,UAAA,UAAA;AAAA,UAAA,YAAA;AAAA,UAAA,cAAA;AAAA,QAAA;AAAA,QAAAL;AAAAA,MAIA;AAAA,IAAA,KAVF,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAYA,GAAAA,MAAA;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAAM,mCAA2B,kCAAkC,aAAa,KAAK;AAAA,IACvF;AAAA,EACD;AAAA,EACA;AACD;;"}
@@ -1,27 +1,18 @@
1
1
  import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
2
2
  import { useConstantValueInvariant } from "@contember/react-utils";
3
- import { useCallback } from "react";
4
3
  import { MarkerFactory, PRIMARY_KEY_NAME, TreeNodeEnvironmentFactory } from "@contember/binding";
5
4
  import { Component } from "./Component.js";
6
5
  import { Entity } from "./Entity.js";
7
6
  import { Field } from "./Field.js";
8
7
  import { SetOrderFieldOnCreate } from "../accessorSorting/SetOrderFieldOnCreate.js";
9
- import { useGetEntitySubTree } from "../accessorPropagation/useGetEntitySubTree.js";
10
- import { useEntitySubTreeParameters } from "../accessorPropagation/useEntitySubTreeParameters.js";
11
- import { useAccessorUpdateSubscription } from "../accessorPropagation/useAccessorUpdateSubscription.js";
8
+ import { useEntitySubTree } from "../accessorPropagation/useEntitySubTree.js";
12
9
  const EntitySubTree = Component(
13
10
  (props) => {
14
11
  useConstantValueInvariant(props.isCreating, "EntitySubTree: cannot update isCreating");
15
- const getSubTree = useGetEntitySubTree();
16
- const parameters = useEntitySubTreeParameters(props);
17
- const getAccessor = useCallback(
18
- () => getSubTree(parameters, props.treeRootId),
19
- [getSubTree, parameters, props.treeRootId]
20
- );
21
- const accessor = useAccessorUpdateSubscription(getAccessor);
12
+ const accessor = useEntitySubTree(props, ...props.treeRootId ? [props.treeRootId] : []);
22
13
  return /* @__PURE__ */ jsxDEV(Entity, { ...props, accessor }, void 0, false, {
23
14
  fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/EntitySubTree.tsx",
24
- lineNumber: 63,
15
+ lineNumber: 48,
25
16
  columnNumber: 10
26
17
  }, void 0);
27
18
  },
@@ -36,13 +27,13 @@ const EntitySubTree = Component(
36
27
  /* @__PURE__ */ jsxDEV(Entity, { ...props, accessor: 0, children: [
37
28
  /* @__PURE__ */ jsxDEV(Field, { field: PRIMARY_KEY_NAME }, void 0, false, {
38
29
  fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/EntitySubTree.tsx",
39
- lineNumber: 75,
30
+ lineNumber: 60,
40
31
  columnNumber: 6
41
32
  }, void 0),
42
33
  props.children
43
34
  ] }, void 0, true, {
44
35
  fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/EntitySubTree.tsx",
45
- lineNumber: 74,
36
+ lineNumber: 59,
46
37
  columnNumber: 5
47
38
  }, void 0),
48
39
  props.isCreating && "orderField" in props && /* @__PURE__ */ jsxDEV(
@@ -56,14 +47,14 @@ const EntitySubTree = Component(
56
47
  false,
57
48
  {
58
49
  fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/EntitySubTree.tsx",
59
- lineNumber: 79,
50
+ lineNumber: 64,
60
51
  columnNumber: 6
61
52
  },
62
53
  void 0
63
54
  )
64
55
  ] }, void 0, true, {
65
56
  fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/EntitySubTree.tsx",
66
- lineNumber: 73,
57
+ lineNumber: 58,
67
58
  columnNumber: 4
68
59
  }, void 0),
69
60
  generateEnvironment: (props, oldEnvironment) => {
@@ -1 +1 @@
1
- {"version":3,"file":"EntitySubTree.js","sources":["../../../../../packages/react-binding/src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '@contember/binding'\nimport { Environment } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '@contember/binding'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\n/**\n * Creates a single entity subtree in current data binding context.\n *\n * @example\n * ```\n * <EntitySubTree entity=\"Post(id = $id)\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":["this"],"mappings":";;;;;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;AAAA,UAAA,UAAA;AAAA,UAAA,YAAA;AAAA,UAAA,cAAA;AAAA,QAAA;AAAA,QAAAA;AAAAA,MAIA;AAAA,IAAA,KAVF,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAYA,GAAAA,MAAA;AAAA,IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,kCAAkC,aAAa,KAAK;AAAA,IACvF;AAAA,EACD;AAAA,EACA;AACD;"}
1
+ {"version":3,"file":"EntitySubTree.js","sources":["../../../../../packages/react-binding/src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode } from 'react'\nimport { useEntitySubTree } from '../accessorPropagation'\nimport type { SugaredQualifiedSingleEntity, SugaredUnconstrainedQualifiedSingleEntity, TreeRootId } from '@contember/binding'\nimport { Environment, MarkerFactory, PRIMARY_KEY_NAME, TreeNodeEnvironmentFactory } from '@contember/binding'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\n/**\n * Creates a single entity subtree in current data binding context.\n *\n * @example\n * ```\n * <EntitySubTree entity=\"Post(id = $id)\" />\n * ```\n *\n * @group Data binding\n */\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\t\tconst accessor = useEntitySubTree(props, ...props.treeRootId ? [props.treeRootId] : [])\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":["this"],"mappings":";;;;;;;;AAqCO,MAAM,gBAAgB;AAAA,EAC5B,CAAyB,UAA2C;AACzC,8BAAA,MAAM,YAAY,yCAAyC;AAC/E,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IAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,YAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,aAAA,2BAA2B,kCAAkC,aAAa,KAAK;AAAA,IACvF;AAAA,EACD;AAAA,EACA;AACD;"}
@@ -12,16 +12,16 @@ const useDerivedField = (sourceField, derivedField, transform = identityFunction
12
12
  const stableGetEntityReference = potentiallyStaleParent.getAccessor;
13
13
  const desugaredSource = useDesugaredRelativeSingleField.useDesugaredRelativeSingleField(sourceField);
14
14
  const desugaredDerived = useDesugaredRelativeSingleField.useDesugaredRelativeSingleField(derivedField);
15
- const potentiallyStaleSourceAccessor = potentiallyStaleParent.getRelativeSingleField(desugaredSource);
15
+ const potentiallyStaleSourceAccessor = potentiallyStaleParent.getField(desugaredSource);
16
16
  const stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor;
17
17
  const onBeforeUpdate = React.useCallback(
18
18
  (sourceAccessor) => {
19
19
  stableGetEntityReference().batchUpdates((getAccessor) => {
20
- const derivedHostEntity = getAccessor().getRelativeSingleEntity(desugaredDerived);
20
+ const derivedHostEntity = getAccessor().getEntity(desugaredDerived);
21
21
  if (derivedHostEntity.existsOnServer) {
22
22
  return;
23
23
  }
24
- const derivedAccessor = getAccessor().getRelativeSingleField(desugaredDerived);
24
+ const derivedAccessor = getAccessor().getField(desugaredDerived);
25
25
  if (derivedAccessor.isTouched) {
26
26
  return;
27
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useDerivedField.cjs","sources":["../../../../../packages/react-binding/src/entityEvents/useDerivedField.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useDesugaredRelativeSingleField, useEntityKey, useGetEntityByKey } from '../accessorPropagation'\nimport type { FieldAccessor } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\n\nconst identityFunction = <Value>(value: Value) => value\n\n// TODO this is fundamentally wrong. This shouldn't only happen on beforeUpdate, but also on initialize.\n// \twe need a useEffect equivalent.\n\n/**\n * Derived fields are meant for cases when the user is expected to primarily edit the `sourceField` whose optionally\n * transformed value is then copied to the `derivedField`. This happens after each update until either the `derivedField`\n * is touched or until it is persisted at which point the tie between the fields is automatically severed.\n * @deprecated This is fundamentally wrong and shouldn't be used for now.\n */\nexport const useDerivedField = <SourceValue extends FieldValue = FieldValue>(\n\tsourceField: string | SugaredRelativeSingleField,\n\tderivedField: string | SugaredRelativeSingleField,\n\ttransform: (sourceValue: SourceValue | null) => SourceValue | null = identityFunction,\n\tagent: string = 'derivedField',\n) => {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst potentiallyStaleParent = getEntityByKey(entityKey)\n\tconst stableGetEntityReference = potentiallyStaleParent.getAccessor\n\n\tconst desugaredSource = useDesugaredRelativeSingleField(sourceField)\n\tconst desugaredDerived = useDesugaredRelativeSingleField(derivedField)\n\n\tconst potentiallyStaleSourceAccessor = potentiallyStaleParent.getRelativeSingleField<SourceValue>(desugaredSource)\n\tconst stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor\n\n\tconst onBeforeUpdate = useCallback<FieldAccessor.BeforeUpdateListener<SourceValue>>(\n\t\tsourceAccessor => {\n\t\t\tstableGetEntityReference().batchUpdates(getAccessor => {\n\t\t\t\t// This is tricky: we're deliberately getting the Entity, and not the field\n\t\t\t\tconst derivedHostEntity = getAccessor().getRelativeSingleEntity(desugaredDerived)\n\n\t\t\t\tif (derivedHostEntity.existsOnServer) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst derivedAccessor = getAccessor().getRelativeSingleField<SourceValue>(desugaredDerived)\n\n\t\t\t\tif (derivedAccessor.isTouched) {\n\t\t\t\t\t// Querying the user\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst transformedValue = transform(sourceAccessor.value)\n\t\t\t\tderivedAccessor.updateValue(transformedValue, {\n\t\t\t\t\tagent,\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\t[stableGetEntityReference, desugaredDerived, transform, agent],\n\t)\n\n\tuseEffect(\n\t\t() => stableGetSourceReference().addEventListener({ type: 'beforeUpdate' }, onBeforeUpdate),\n\t\t[onBeforeUpdate, stableGetSourceReference],\n\t)\n}\n"],"names":["useEntityKey","useGetEntityByKey","useDesugaredRelativeSingleField","useCallback","useEffect"],"mappings":";;;;;;AAKA,MAAM,mBAAmB,CAAQ,UAAiB;AAW3C,MAAM,kBAAkB,CAC9B,aACA,cACA,YAAqE,kBACrE,QAAgB,mBACZ;AACJ,QAAM,YAAYA,aAAAA;AAClB,QAAM,iBAAiBC,kBAAAA;AACjB,QAAA,yBAAyB,eAAe,SAAS;AACvD,QAAM,2BAA2B,uBAAuB;AAElD,QAAA,kBAAkBC,gEAAgC,WAAW;AAC7D,QAAA,mBAAmBA,gEAAgC,YAAY;AAE/D,QAAA,iCAAiC,uBAAuB,uBAAoC,eAAe;AACjH,QAAM,2BAA2B,+BAA+B;AAEhE,QAAM,iBAAiBC,MAAA;AAAA,IACtB,CAAkB,mBAAA;AACQ,+BAAA,EAAE,aAAa,CAAe,gBAAA;AAEtD,cAAM,oBAAoB,YAAA,EAAc,wBAAwB,gBAAgB;AAEhF,YAAI,kBAAkB,gBAAgB;AACrC;AAAA,QACD;AAEA,cAAM,kBAAkB,YAAA,EAAc,uBAAoC,gBAAgB;AAE1F,YAAI,gBAAgB,WAAW;AAE9B;AAAA,QACD;AAEM,cAAA,mBAAmB,UAAU,eAAe,KAAK;AACvD,wBAAgB,YAAY,kBAAkB;AAAA,UAC7C;AAAA,QAAA,CACA;AAAA,MAAA,CACD;AAAA,IACF;AAAA,IACA,CAAC,0BAA0B,kBAAkB,WAAW,KAAK;AAAA,EAAA;AAG9DC,QAAA;AAAA,IACC,MAAM,yBAA2B,EAAA,iBAAiB,EAAE,MAAM,kBAAkB,cAAc;AAAA,IAC1F,CAAC,gBAAgB,wBAAwB;AAAA,EAAA;AAE3C;;"}
1
+ {"version":3,"file":"useDerivedField.cjs","sources":["../../../../../packages/react-binding/src/entityEvents/useDerivedField.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useDesugaredRelativeSingleField, useEntityKey, useGetEntityByKey } from '../accessorPropagation'\nimport type { FieldAccessor } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\n\nconst identityFunction = <Value>(value: Value) => value\n\n// TODO this is fundamentally wrong. This shouldn't only happen on beforeUpdate, but also on initialize.\n// \twe need a useEffect equivalent.\n\n/**\n * Derived fields are meant for cases when the user is expected to primarily edit the `sourceField` whose optionally\n * transformed value is then copied to the `derivedField`. This happens after each update until either the `derivedField`\n * is touched or until it is persisted at which point the tie between the fields is automatically severed.\n * @deprecated This is fundamentally wrong and shouldn't be used for now.\n */\nexport const useDerivedField = <SourceValue extends FieldValue = FieldValue>(\n\tsourceField: string | SugaredRelativeSingleField,\n\tderivedField: string | SugaredRelativeSingleField,\n\ttransform: (sourceValue: SourceValue | null) => SourceValue | null = identityFunction,\n\tagent: string = 'derivedField',\n) => {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst potentiallyStaleParent = getEntityByKey(entityKey)\n\tconst stableGetEntityReference = potentiallyStaleParent.getAccessor\n\n\tconst desugaredSource = useDesugaredRelativeSingleField(sourceField)\n\tconst desugaredDerived = useDesugaredRelativeSingleField(derivedField)\n\n\tconst potentiallyStaleSourceAccessor = potentiallyStaleParent.getField<SourceValue>(desugaredSource)\n\tconst stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor\n\n\tconst onBeforeUpdate = useCallback<FieldAccessor.BeforeUpdateListener<SourceValue>>(\n\t\tsourceAccessor => {\n\t\t\tstableGetEntityReference().batchUpdates(getAccessor => {\n\t\t\t\t// This is tricky: we're deliberately getting the Entity, and not the field\n\t\t\t\tconst derivedHostEntity = getAccessor().getEntity(desugaredDerived)\n\n\t\t\t\tif (derivedHostEntity.existsOnServer) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst derivedAccessor = getAccessor().getField<SourceValue>(desugaredDerived)\n\n\t\t\t\tif (derivedAccessor.isTouched) {\n\t\t\t\t\t// Querying the user\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst transformedValue = transform(sourceAccessor.value)\n\t\t\t\tderivedAccessor.updateValue(transformedValue, {\n\t\t\t\t\tagent,\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\t[stableGetEntityReference, desugaredDerived, transform, agent],\n\t)\n\n\tuseEffect(\n\t\t() => stableGetSourceReference().addEventListener({ type: 'beforeUpdate' }, onBeforeUpdate),\n\t\t[onBeforeUpdate, stableGetSourceReference],\n\t)\n}\n"],"names":["useEntityKey","useGetEntityByKey","useDesugaredRelativeSingleField","useCallback","useEffect"],"mappings":";;;;;;AAKA,MAAM,mBAAmB,CAAQ,UAAiB;AAW3C,MAAM,kBAAkB,CAC9B,aACA,cACA,YAAqE,kBACrE,QAAgB,mBACZ;AACJ,QAAM,YAAYA,aAAAA;AAClB,QAAM,iBAAiBC,kBAAAA;AACjB,QAAA,yBAAyB,eAAe,SAAS;AACvD,QAAM,2BAA2B,uBAAuB;AAElD,QAAA,kBAAkBC,gEAAgC,WAAW;AAC7D,QAAA,mBAAmBA,gEAAgC,YAAY;AAE/D,QAAA,iCAAiC,uBAAuB,SAAsB,eAAe;AACnG,QAAM,2BAA2B,+BAA+B;AAEhE,QAAM,iBAAiBC,MAAA;AAAA,IACtB,CAAkB,mBAAA;AACQ,+BAAA,EAAE,aAAa,CAAe,gBAAA;AAEtD,cAAM,oBAAoB,YAAA,EAAc,UAAU,gBAAgB;AAElE,YAAI,kBAAkB,gBAAgB;AACrC;AAAA,QACD;AAEA,cAAM,kBAAkB,YAAA,EAAc,SAAsB,gBAAgB;AAE5E,YAAI,gBAAgB,WAAW;AAE9B;AAAA,QACD;AAEM,cAAA,mBAAmB,UAAU,eAAe,KAAK;AACvD,wBAAgB,YAAY,kBAAkB;AAAA,UAC7C;AAAA,QAAA,CACA;AAAA,MAAA,CACD;AAAA,IACF;AAAA,IACA,CAAC,0BAA0B,kBAAkB,WAAW,KAAK;AAAA,EAAA;AAG9DC,QAAA;AAAA,IACC,MAAM,yBAA2B,EAAA,iBAAiB,EAAE,MAAM,kBAAkB,cAAc;AAAA,IAC1F,CAAC,gBAAgB,wBAAwB;AAAA,EAAA;AAE3C;;"}
@@ -10,16 +10,16 @@ const useDerivedField = (sourceField, derivedField, transform = identityFunction
10
10
  const stableGetEntityReference = potentiallyStaleParent.getAccessor;
11
11
  const desugaredSource = useDesugaredRelativeSingleField(sourceField);
12
12
  const desugaredDerived = useDesugaredRelativeSingleField(derivedField);
13
- const potentiallyStaleSourceAccessor = potentiallyStaleParent.getRelativeSingleField(desugaredSource);
13
+ const potentiallyStaleSourceAccessor = potentiallyStaleParent.getField(desugaredSource);
14
14
  const stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor;
15
15
  const onBeforeUpdate = useCallback(
16
16
  (sourceAccessor) => {
17
17
  stableGetEntityReference().batchUpdates((getAccessor) => {
18
- const derivedHostEntity = getAccessor().getRelativeSingleEntity(desugaredDerived);
18
+ const derivedHostEntity = getAccessor().getEntity(desugaredDerived);
19
19
  if (derivedHostEntity.existsOnServer) {
20
20
  return;
21
21
  }
22
- const derivedAccessor = getAccessor().getRelativeSingleField(desugaredDerived);
22
+ const derivedAccessor = getAccessor().getField(desugaredDerived);
23
23
  if (derivedAccessor.isTouched) {
24
24
  return;
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useDerivedField.js","sources":["../../../../../packages/react-binding/src/entityEvents/useDerivedField.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useDesugaredRelativeSingleField, useEntityKey, useGetEntityByKey } from '../accessorPropagation'\nimport type { FieldAccessor } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\n\nconst identityFunction = <Value>(value: Value) => value\n\n// TODO this is fundamentally wrong. This shouldn't only happen on beforeUpdate, but also on initialize.\n// \twe need a useEffect equivalent.\n\n/**\n * Derived fields are meant for cases when the user is expected to primarily edit the `sourceField` whose optionally\n * transformed value is then copied to the `derivedField`. This happens after each update until either the `derivedField`\n * is touched or until it is persisted at which point the tie between the fields is automatically severed.\n * @deprecated This is fundamentally wrong and shouldn't be used for now.\n */\nexport const useDerivedField = <SourceValue extends FieldValue = FieldValue>(\n\tsourceField: string | SugaredRelativeSingleField,\n\tderivedField: string | SugaredRelativeSingleField,\n\ttransform: (sourceValue: SourceValue | null) => SourceValue | null = identityFunction,\n\tagent: string = 'derivedField',\n) => {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst potentiallyStaleParent = getEntityByKey(entityKey)\n\tconst stableGetEntityReference = potentiallyStaleParent.getAccessor\n\n\tconst desugaredSource = useDesugaredRelativeSingleField(sourceField)\n\tconst desugaredDerived = useDesugaredRelativeSingleField(derivedField)\n\n\tconst potentiallyStaleSourceAccessor = potentiallyStaleParent.getRelativeSingleField<SourceValue>(desugaredSource)\n\tconst stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor\n\n\tconst onBeforeUpdate = useCallback<FieldAccessor.BeforeUpdateListener<SourceValue>>(\n\t\tsourceAccessor => {\n\t\t\tstableGetEntityReference().batchUpdates(getAccessor => {\n\t\t\t\t// This is tricky: we're deliberately getting the Entity, and not the field\n\t\t\t\tconst derivedHostEntity = getAccessor().getRelativeSingleEntity(desugaredDerived)\n\n\t\t\t\tif (derivedHostEntity.existsOnServer) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst derivedAccessor = getAccessor().getRelativeSingleField<SourceValue>(desugaredDerived)\n\n\t\t\t\tif (derivedAccessor.isTouched) {\n\t\t\t\t\t// Querying the user\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst transformedValue = transform(sourceAccessor.value)\n\t\t\t\tderivedAccessor.updateValue(transformedValue, {\n\t\t\t\t\tagent,\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\t[stableGetEntityReference, desugaredDerived, transform, agent],\n\t)\n\n\tuseEffect(\n\t\t() => stableGetSourceReference().addEventListener({ type: 'beforeUpdate' }, onBeforeUpdate),\n\t\t[onBeforeUpdate, stableGetSourceReference],\n\t)\n}\n"],"names":[],"mappings":";;;;AAKA,MAAM,mBAAmB,CAAQ,UAAiB;AAW3C,MAAM,kBAAkB,CAC9B,aACA,cACA,YAAqE,kBACrE,QAAgB,mBACZ;AACJ,QAAM,YAAY;AAClB,QAAM,iBAAiB;AACjB,QAAA,yBAAyB,eAAe,SAAS;AACvD,QAAM,2BAA2B,uBAAuB;AAElD,QAAA,kBAAkB,gCAAgC,WAAW;AAC7D,QAAA,mBAAmB,gCAAgC,YAAY;AAE/D,QAAA,iCAAiC,uBAAuB,uBAAoC,eAAe;AACjH,QAAM,2BAA2B,+BAA+B;AAEhE,QAAM,iBAAiB;AAAA,IACtB,CAAkB,mBAAA;AACQ,+BAAA,EAAE,aAAa,CAAe,gBAAA;AAEtD,cAAM,oBAAoB,YAAA,EAAc,wBAAwB,gBAAgB;AAEhF,YAAI,kBAAkB,gBAAgB;AACrC;AAAA,QACD;AAEA,cAAM,kBAAkB,YAAA,EAAc,uBAAoC,gBAAgB;AAE1F,YAAI,gBAAgB,WAAW;AAE9B;AAAA,QACD;AAEM,cAAA,mBAAmB,UAAU,eAAe,KAAK;AACvD,wBAAgB,YAAY,kBAAkB;AAAA,UAC7C;AAAA,QAAA,CACA;AAAA,MAAA,CACD;AAAA,IACF;AAAA,IACA,CAAC,0BAA0B,kBAAkB,WAAW,KAAK;AAAA,EAAA;AAG9D;AAAA,IACC,MAAM,yBAA2B,EAAA,iBAAiB,EAAE,MAAM,kBAAkB,cAAc;AAAA,IAC1F,CAAC,gBAAgB,wBAAwB;AAAA,EAAA;AAE3C;"}
1
+ {"version":3,"file":"useDerivedField.js","sources":["../../../../../packages/react-binding/src/entityEvents/useDerivedField.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react'\nimport { useDesugaredRelativeSingleField, useEntityKey, useGetEntityByKey } from '../accessorPropagation'\nimport type { FieldAccessor } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\n\nconst identityFunction = <Value>(value: Value) => value\n\n// TODO this is fundamentally wrong. This shouldn't only happen on beforeUpdate, but also on initialize.\n// \twe need a useEffect equivalent.\n\n/**\n * Derived fields are meant for cases when the user is expected to primarily edit the `sourceField` whose optionally\n * transformed value is then copied to the `derivedField`. This happens after each update until either the `derivedField`\n * is touched or until it is persisted at which point the tie between the fields is automatically severed.\n * @deprecated This is fundamentally wrong and shouldn't be used for now.\n */\nexport const useDerivedField = <SourceValue extends FieldValue = FieldValue>(\n\tsourceField: string | SugaredRelativeSingleField,\n\tderivedField: string | SugaredRelativeSingleField,\n\ttransform: (sourceValue: SourceValue | null) => SourceValue | null = identityFunction,\n\tagent: string = 'derivedField',\n) => {\n\tconst entityKey = useEntityKey()\n\tconst getEntityByKey = useGetEntityByKey()\n\tconst potentiallyStaleParent = getEntityByKey(entityKey)\n\tconst stableGetEntityReference = potentiallyStaleParent.getAccessor\n\n\tconst desugaredSource = useDesugaredRelativeSingleField(sourceField)\n\tconst desugaredDerived = useDesugaredRelativeSingleField(derivedField)\n\n\tconst potentiallyStaleSourceAccessor = potentiallyStaleParent.getField<SourceValue>(desugaredSource)\n\tconst stableGetSourceReference = potentiallyStaleSourceAccessor.getAccessor\n\n\tconst onBeforeUpdate = useCallback<FieldAccessor.BeforeUpdateListener<SourceValue>>(\n\t\tsourceAccessor => {\n\t\t\tstableGetEntityReference().batchUpdates(getAccessor => {\n\t\t\t\t// This is tricky: we're deliberately getting the Entity, and not the field\n\t\t\t\tconst derivedHostEntity = getAccessor().getEntity(desugaredDerived)\n\n\t\t\t\tif (derivedHostEntity.existsOnServer) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst derivedAccessor = getAccessor().getField<SourceValue>(desugaredDerived)\n\n\t\t\t\tif (derivedAccessor.isTouched) {\n\t\t\t\t\t// Querying the user\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tconst transformedValue = transform(sourceAccessor.value)\n\t\t\t\tderivedAccessor.updateValue(transformedValue, {\n\t\t\t\t\tagent,\n\t\t\t\t})\n\t\t\t})\n\t\t},\n\t\t[stableGetEntityReference, desugaredDerived, transform, agent],\n\t)\n\n\tuseEffect(\n\t\t() => stableGetSourceReference().addEventListener({ type: 'beforeUpdate' }, onBeforeUpdate),\n\t\t[onBeforeUpdate, stableGetSourceReference],\n\t)\n}\n"],"names":[],"mappings":";;;;AAKA,MAAM,mBAAmB,CAAQ,UAAiB;AAW3C,MAAM,kBAAkB,CAC9B,aACA,cACA,YAAqE,kBACrE,QAAgB,mBACZ;AACJ,QAAM,YAAY;AAClB,QAAM,iBAAiB;AACjB,QAAA,yBAAyB,eAAe,SAAS;AACvD,QAAM,2BAA2B,uBAAuB;AAElD,QAAA,kBAAkB,gCAAgC,WAAW;AAC7D,QAAA,mBAAmB,gCAAgC,YAAY;AAE/D,QAAA,iCAAiC,uBAAuB,SAAsB,eAAe;AACnG,QAAM,2BAA2B,+BAA+B;AAEhE,QAAM,iBAAiB;AAAA,IACtB,CAAkB,mBAAA;AACQ,+BAAA,EAAE,aAAa,CAAe,gBAAA;AAEtD,cAAM,oBAAoB,YAAA,EAAc,UAAU,gBAAgB;AAElE,YAAI,kBAAkB,gBAAgB;AACrC;AAAA,QACD;AAEA,cAAM,kBAAkB,YAAA,EAAc,SAAsB,gBAAgB;AAE5E,YAAI,gBAAgB,WAAW;AAE9B;AAAA,QACD;AAEM,cAAA,mBAAmB,UAAU,eAAe,KAAK;AACvD,wBAAgB,YAAY,kBAAkB;AAAA,UAC7C;AAAA,QAAA,CACA;AAAA,MAAA,CACD;AAAA,IACF;AAAA,IACA,CAAC,0BAA0B,kBAAkB,WAAW,KAAK;AAAA,EAAA;AAG9D;AAAA,IACC,MAAM,yBAA2B,EAAA,iBAAiB,EAAE,MAAM,kBAAkB,cAAc;AAAA,IAC1F,CAAC,gBAAgB,wBAAwB;AAAA,EAAA;AAE3C;"}
@@ -9,8 +9,8 @@ const useBindingOperations = require("../accessorPropagation/useBindingOperation
9
9
  const useMutationState = require("../accessorTree/useMutationState.cjs");
10
10
  const useHasEntity = require("../accessorPropagation/useHasEntity.cjs");
11
11
  const useEntityBeforePersist = require("../entityEvents/useEntityBeforePersist.cjs");
12
- const useEnvironment = require("../accessorPropagation/useEnvironment.cjs");
13
12
  const TreeRootIdProvider = require("../accessorPropagation/TreeRootIdProvider.cjs");
13
+ const useEnvironment = require("../accessorPropagation/useEnvironment.cjs");
14
14
  const DeferredSubTrees = Component.Component(
15
15
  (props) => {
16
16
  const { extendTree } = useBindingOperations.useBindingOperations();
@@ -80,8 +80,7 @@ const DeferredSubTrees = Component.Component(
80
80
  }, void 0),
81
81
  generateBranchMarker: (props, fields, environment) => {
82
82
  const fieldsWithHoistablesMarker = binding.MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment);
83
- fieldsWithHoistablesMarker.subTrees?.clear();
84
- return fieldsWithHoistablesMarker;
83
+ return new binding.EntityFieldsWithHoistablesMarker(fieldsWithHoistablesMarker.fields, void 0, fieldsWithHoistablesMarker.parentReference);
85
84
  }
86
85
  },
87
86
  "DeferredSubTree"
@@ -1 +1 @@
1
- {"version":3,"file":"DeferredSubTrees.cjs","sources":["../../../../../packages/react-binding/src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { TreeRootId } from '@contember/binding'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/binding'\nimport { useMutationState } from '../accessorTree'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\tname: 'success'\n\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":["Component","useBindingOperations","useMutationState","useState","useHasEntity","useConstantValueInvariant","useEntityBeforePersist","useCallback","useEffect","useEnvironment","jsxDEV","this","Fragment","TreeRootIdProvider","MarkerFactory","EntityFieldMarkersContainer","EntityFieldsWithHoistablesMarker"],"mappings":";;;;;;;;;;;;;AA2BO,MAAM,mBAAmBA,UAAA;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAeC,qBAAAA;AACvB,UAAM,aAAaC,iBAAAA;AAEb,UAAA,CAAC,WAAW,YAAY,IAAIC,eAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAIA,MAAAA,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAYC,aAAAA;AAClBC,eAAA,0BAA0B,SAAS;AACnC,QAAI,WAAW;AACdC,6BAAA;AAAA,QACCC,MAAA,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,QACjC,GAAG,EAAE;AAAA,MAAA;AAAA,IAEP;AAEAC,UAAAA,UAAU,MAAM;AACf,aAAO,MAAM;AACZ,wBAAgB,MAAM;AAAA,MAAA;AAAA,IACvB,GACE,CAAC,eAAe,CAAC;AAEpB,UAAM,cAAcC,eAAAA;AACpBD,UAAAA,UAAU,MAAM;AACf,UAAI,cAAc,UAAU,SAAS,aAAa,OAAO,SAAS;AACjE;AAAA,MACD;AACa,mBAAA,EAAE,MAAM,UAAA,CAAW;AAEhC,YAAM,cAAcE,qCAAC,kBAAkB,EAAA,UAAA,MAAM,SAAzB,GAAA,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAkC,GAAAC,MAAA;AAE3C,iBAAA,aAAa,EAAE,QAAQ,YAAa,CAAA,EAC7C,KAAK,gBAAc,CAAC,OAAO,WAAW,aAAa,EAAE,MAAM,WAAW,WAAA,CAAY,CAAC,EACnF,MAAM,CAAS,UAAA;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IACpF;AAAA,EACD;AAAA,EACA;AACD;;"}
1
+ {"version":3,"file":"DeferredSubTrees.cjs","sources":["../../../../../packages/react-binding/src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { TreeRootId } from '@contember/binding'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/binding'\nimport { useMutationState } from '../accessorTree'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\tname: 'success'\n\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\n\t\t\treturn new EntityFieldsWithHoistablesMarker(fieldsWithHoistablesMarker.fields, undefined, fieldsWithHoistablesMarker.parentReference)\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":["Component","useBindingOperations","useMutationState","useState","useHasEntity","useConstantValueInvariant","useEntityBeforePersist","useCallback","useEffect","useEnvironment","jsxDEV","this","Fragment","TreeRootIdProvider","MarkerFactory","EntityFieldsWithHoistablesMarker","EntityFieldMarkersContainer"],"mappings":";;;;;;;;;;;;;AA2BO,MAAM,mBAAmBA,UAAA;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAeC,qBAAAA;AACvB,UAAM,aAAaC,iBAAAA;AAEb,UAAA,CAAC,WAAW,YAAY,IAAIC,eAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAIA,MAAAA,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAYC,aAAAA;AAClBC,eAAA,0BAA0B,SAAS;AACnC,QAAI,WAAW;AACdC,6BAAA;AAAA,QACCC,MAAA,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,QACjC,GAAG,EAAE;AAAA,MAAA;AAAA,IAEP;AAEAC,UAAAA,UAAU,MAAM;AACf,aAAO,MAAM;AACZ,wBAAgB,MAAM;AAAA,MAAA;AAAA,IACvB,GACE,CAAC,eAAe,CAAC;AAEpB,UAAM,cAAcC,eAAAA;AACpBD,UAAAA,UAAU,MAAM;AACf,UAAI,cAA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gB;AACrD,YAAM,6BAA6BG,QAAA,cAAc,uCAAuC,QAAQ,WAAW;AAI3G,aAAO,IAAIC,QAAiC,iCAAA,2BAA2B,QAAQ,QAAW,2BAA2B,eAAe;AAAA,IACrI;AAAA,EACD;AAAA,EACA;AACD;AAEA,MAAM,mBAAmBf,UAAA;AAAA,EACxB,MAAM;AAAA,EACN;AAAA,IACC,sBAAsB,CAAC,OAAO,WAAW;AAElC,YAAA,cAAcc,QAAc,cAAA,kCAAkC,MAAS;AAE7E,UAAI,kBAAkBE,QAAAA,6BAA6B;AAC3C,eAAA;AAAA,MACR;AACA,aAAO,IAAID,QAAA,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,IACpF;AAAA,EACD;AAAA,EACA;AACD;;"}
@@ -1,14 +1,14 @@
1
1
  import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
2
2
  import { useState, useCallback, useEffect } from "react";
3
- import { MarkerFactory, EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from "@contember/binding";
3
+ import { MarkerFactory, EntityFieldsWithHoistablesMarker, EntityFieldMarkersContainer } from "@contember/binding";
4
4
  import { useConstantValueInvariant } from "@contember/react-utils";
5
5
  import { Component } from "../coreComponents/Component.js";
6
6
  import { useBindingOperations } from "../accessorPropagation/useBindingOperations.js";
7
7
  import { useMutationState } from "../accessorTree/useMutationState.js";
8
8
  import { useHasEntity } from "../accessorPropagation/useHasEntity.js";
9
9
  import { useEntityBeforePersist } from "../entityEvents/useEntityBeforePersist.js";
10
- import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
11
10
  import { TreeRootIdProvider } from "../accessorPropagation/TreeRootIdProvider.js";
11
+ import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
12
12
  const DeferredSubTrees = Component(
13
13
  (props) => {
14
14
  const { extendTree } = useBindingOperations();
@@ -78,8 +78,7 @@ const DeferredSubTrees = Component(
78
78
  }, void 0),
79
79
  generateBranchMarker: (props, fields, environment) => {
80
80
  const fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment);
81
- fieldsWithHoistablesMarker.subTrees?.clear();
82
- return fieldsWithHoistablesMarker;
81
+ return new EntityFieldsWithHoistablesMarker(fieldsWithHoistablesMarker.fields, void 0, fieldsWithHoistablesMarker.parentReference);
83
82
  }
84
83
  },
85
84
  "DeferredSubTree"
@@ -1 +1 @@
1
- {"version":3,"file":"DeferredSubTrees.js","sources":["../../../../../packages/react-binding/src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { TreeRootId } from '@contember/binding'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/binding'\nimport { useMutationState } from '../accessorTree'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\tname: 'success'\n\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\t\t\t//\n\t\t\t// Mutating from here is fine since we've literally just created it and no other code could possibly possess\n\t\t\t// a reference to this.\n\t\t\tfieldsWithHoistablesMarker.subTrees?.clear()\n\n\t\t\treturn fieldsWithHoistablesMarker\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":["this"],"mappings":";;;;;;;;;;;AA2BO,MAAM,mBAAmB;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAe;AACvB,UAAM,aAAa;AAEb,UAAA,CAAC,WAAW,YAAY,IAAI,SAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAI,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAY;AAClB,8BAA0B,SAAS;AACnC,QAAI,WAAW;AACd;AAAA,QACC,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,QACjC,GAAG,EAAE;AAAA,MAAA;AAAA,IAEP;AAEA,cAAU,MAAM;AACf,aAAO,MAAM;AACZ,wBAAgB,MAAM;AAAA,MAAA;AAAA,IACvB,GACE,CAAC,eAAe,CAAC;AAEpB,UAAM,cAAc;AACpB,cAAU,MAAM;AACf,UAAI,cAAc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AAQ,WAAW;AAM3G,iCAA2B,UAAU;AAE9B,aAAA;AAAA,IACR;AAAA,EACD;AAAA,EACA;AACD;AAEA,MAAM,mBAAmB;AAAA,EACxB,MAAM;AAAA,EACN;AAAA,IACC,sBAAsB,CAAC,OAAO,WAAW;AAElC,YAAA,cAAc,cAAc,kCAAkC,MAAS;AAE7E,UAAI,kBAAkB,6BAA6B;AAC3C,eAAA;AAAA,MACR;AACA,aAAO,IAAI,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,IACpF;AAAA,EACD;AAAA,EACA;AACD;"}
1
+ {"version":3,"file":"DeferredSubTrees.js","sources":["../../../../../packages/react-binding/src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '@contember/binding'\nimport { MarkerFactory } from '@contember/binding'\nimport type { TreeRootId } from '@contember/binding'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '@contember/binding'\nimport { useMutationState } from '../accessorTree'\n\nexport interface DeferredSubTreesProps {\n\tfallback: ReactNode\n\tchildren: ReactNode\n}\n\ntype LoadState =\n\t| { name: 'initial' }\n\t| { name: 'loading' }\n\t| {\n\t\tname: 'success'\n\t\ttreeRootId: TreeRootId | undefined\n\t }\n\n/**\n * @group Data binding\n */\nexport const DeferredSubTrees = Component<DeferredSubTreesProps>(\n\tprops => {\n\t\tconst { extendTree } = useBindingOperations()\n\t\tconst isMutating = useMutationState()\n\n\t\tconst [loadState, setLoadState] = useState<LoadState>({ name: 'initial' })\n\n\t\tconst [abortController] = useState(() => new AbortController())\n\t\tconst signal = abortController.signal\n\n\t\tconst hasEntity = useHasEntity()\n\t\tuseConstantValueInvariant(hasEntity)\n\t\tif (hasEntity) {\n\t\t\tuseEntityBeforePersist(\n\t\t\t\tuseCallback((getAccessor: EntityAccessor.GetEntityAccessor) => {\n\t\t\t\t\t// This is a hack. We're really just circumventing the change of ids after a creation so that nested\n\t\t\t\t\t// components don't error.\n\t\t\t\t\tif (getAccessor().existsOnServer) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tsetLoadState({ name: 'initial' })\n\t\t\t\t}, []),\n\t\t\t)\n\t\t}\n\n\t\tuseEffect(() => {\n\t\t\treturn () => {\n\t\t\t\tabortController.abort()\n\t\t\t}\n\t\t}, [abortController])\n\n\t\tconst environment = useEnvironment()\n\t\tuseEffect(() => {\n\t\t\tif (isMutating || loadState.name !== 'initial' || signal.aborted) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsetLoadState({ name: 'loading' })\n\n\t\t\tconst newFragment = <OnlyKeepSubTrees>{props.children}</OnlyKeepSubTrees>\n\n\t\t\textendTree(newFragment, { signal, environment })\n\t\t\t\t.then(treeRootId => !signal.aborted && setLoadState({ name: 'success', treeRootId }))\n\t\t\t\t.catch(error => {\n\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t})\n\t\t}, [environment, extendTree, isMutating, loadState.name, props.children, signal])\n\n\t\tswitch (loadState.name) {\n\t\t\tcase 'initial':\n\t\t\tcase 'loading':\n\t\t\t\treturn <>{props.fallback}</>\n\t\t\tcase 'success':\n\t\t\t\t// This is tricky. The relations & fields within children will just render normally as if this\n\t\t\t\t// component didn't exist. The sub trees, however, will read the new treeRootId and draw their data\n\t\t\t\t// from the newly loaded batch provided by this component. That way the sub trees (and only the sub trees!)\n\t\t\t\t// effectively get lazy loaded.\n\t\t\t\treturn <TreeRootIdProvider treeRootId={loadState.treeRootId}>{props.children}</TreeRootIdProvider>\n\t\t}\n\t},\n\t{\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t{props.children}\n\t\t\t\t{props.fallback}\n\t\t\t</>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tconst fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment)\n\n\t\t\t// We want to get rid of the subTrees but leave whatever relations and fields are present.\n\n\t\t\treturn new EntityFieldsWithHoistablesMarker(fieldsWithHoistablesMarker.fields, undefined, fieldsWithHoistablesMarker.parentReference)\n\t\t},\n\t},\n\t'DeferredSubTree',\n)\n\nconst OnlyKeepSubTrees = Component<{ children: ReactNode }>(\n\t() => null,\n\t{\n\t\tgenerateBranchMarker: (props, fields) => {\n\t\t\t// This is the complement of the equivalent method above: this time we're only keeping the sub trees.\n\t\t\tconst emptyFields = MarkerFactory.createEntityFieldMarkersContainer(undefined)\n\n\t\t\tif (fields instanceof EntityFieldMarkersContainer) {\n\t\t\t\treturn emptyFields\n\t\t\t}\n\t\t\treturn new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, undefined)\n\t\t},\n\t},\n\t'OnlyKeepSubTrees',\n)\n"],"names":["this"],"mappings":";;;;;;;;;;;AA2BO,MAAM,mBAAmB;AAAA,EAC/B,CAAS,UAAA;AACF,UAAA,EAAE,eAAe;AACvB,UAAM,aAAa;AAEb,UAAA,CAAC,WAAW,YAAY,IAAI,SAAoB,EAAE,MAAM,WAAW;AAEzE,UAAM,CAAC,eAAe,IAAI,SAAS,MAAM,IAAI,gBAAiB,CAAA;AAC9D,UAAM,SAAS,gBAAgB;AAE/B,UAAM,YAAY;AAClB,8BAA0B,SAAS;AACnC,QAAI,WAAW;AACd;AAAA,QACC,YAAY,CAAC,gBAAkD;AAG1D,cAAA,cAAc,gBAAgB;AACjC;AAAA,UACD;AACa,uBAAA,EAAE,MAAM,UAAA,CAAW;AAAA,QACjC,GAAG,EAAE;AAAA,MAAA;AAAA,IAEP;AAEA,cAAU,MAAM;AACf,aAAO,MAAM;AACZ,wBAAgB,MAAM;AAAA,MAAA;AAAA,IACvB,GACE,CAAC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B,CAAC,OAAO,QAAQ,gBAAgB;AACrD,YAAM,6BAA6B,cAAc,uCAAuC,QAAQ,WAAW;AAI3G,aAAO,IAAI,iCAAiC,2BAA2B,QAAQ,QAAW,2BAA2B,eAAe;AAAA,IACrI;AAAA,EACD;AAAA,EACA;AACD;AAEA,MAAM,mBAAmB;AAAA,EACxB,MAAM;AAAA,EACN;AAAA,IACC,sBAAsB,CAAC,OAAO,WAAW;AAElC,YAAA,cAAc,cAAc,kCAAkC,MAAS;AAE7E,UAAI,kBAAkB,6BAA6B;AAC3C,eAAA;AAAA,MACR;AACA,aAAO,IAAI,iCAAiC,aAAa,OAAO,UAAU,MAAS;AAAA,IACpF;AAAA,EACD;AAAA,EACA;AACD;"}
@@ -23,7 +23,7 @@ const FieldView = Component.Component(
23
23
  );
24
24
  const desugaredFields = reactUtils.useArrayMapMemo(fields, desugarField);
25
25
  const retrieveField = React.useCallback(
26
- (desugaredRsf) => entityAccessor.getRelativeSingleField(desugaredRsf),
26
+ (desugaredRsf) => entityAccessor.getField(desugaredRsf),
27
27
  [entityAccessor]
28
28
  );
29
29
  const accessors = reactUtils.useArrayMapMemo(desugaredFields, retrieveField);
@@ -1 +1 @@
1
- {"version":3,"file":"FieldView.cjs","sources":["../../../../../packages/react-binding/src/helperComponents/FieldView.tsx"],"sourcesContent":["import { useArrayMapMemo, useConstantLengthInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback, useMemo } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { FieldAccessor, FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '@contember/binding'\nimport { QueryLanguage, throwBindingError } from '@contember/binding'\nimport { Component } from '../coreComponents'\nimport { SugaredField } from './SugaredField'\n\nexport interface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\nexport type FieldViewProps =\n\t& FieldViewCommonProps\n\t& (\n\t\t| {\n\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n/**\n * Base field view component with no default formatting.\n *\n * @example\n * ```\n * <FieldView\n * field=\"startsAt\"\n * render={(accessor) => <>{accessor.value}</>}\n * />\n * ```\n *\n * @group Field Views\n */\nexport const FieldView = Component<FieldViewProps>(\n\tprops => {\n\t\tconst { fallbackIfUnpersisted, render } = props\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t\t? [props.field]\n\t\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\n\t\tuseConstantLengthInvariant(\n\t\t\tfields,\n\t\t\t`The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`,\n\t\t)\n\n\t\t// TODO over-subscribe less\n\t\tconst entityAccessor = useEntity()\n\t\tconst environment = entityAccessor.environment\n\n\t\tconst desugarField = useCallback(\n\t\t\t(rsf: string | SugaredRelativeSingleField) => QueryLanguage.desugarRelativeSingleField(rsf, environment),\n\t\t\t[environment],\n\t\t)\n\t\tconst desugaredFields = useArrayMapMemo(fields, desugarField)\n\n\t\tconst retrieveField = useCallback(\n\t\t\t(desugaredRsf: RelativeSingleField) => entityAccessor.getRelativeSingleField(desugaredRsf),\n\t\t\t[entityAccessor],\n\t\t)\n\t\tconst accessors = useArrayMapMemo(desugaredFields, retrieveField)\n\n\t\t// TODO we probably want something like useDeferredValue from here.\n\t\t// Will probably just wait for Concurrent React though.\n\t\tconst output = useMemo(() => {\n\t\t\tif (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== undefined) {\n\t\t\t\treturn fallbackIfUnpersisted\n\t\t\t}\n\t\t\treturn render(...accessors)\n\t\t}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render])\n\n\t\treturn <>{output}</>\n\t},\n\tprops => {\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t\t? [props.field]\n\t\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{props.fallbackIfUnpersisted}\n\t\t\t\t{fields.map((field, i) => (\n\t\t\t\t\t<SugaredField key={i} field={field} />\n\t\t\t\t))}\n\t\t\t</>\n\t\t)\n\t},\n\t'FieldView',\n) as FieldViewComponentSignature\n\nexport type FieldViewComponentSignature = {\n\t<FV1 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t\t\trender: (field1: FieldAccessor<FV1>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue, FV4 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>, field4: FieldAccessor<FV4>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue, FV4 extends FieldValue, FV5 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>, field4: FieldAccessor<FV4>, field5: FieldAccessor<FV5>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t(props: FieldViewProps): ReactElement | null\n}\n"],"names":["Component","throwBindingError","useConstantLengthInvariant","useEntity","useCallback","QueryLanguage","useArrayMapMemo","useMemo","this","jsxDEV","Fragment","SugaredField"],"mappings":";;;;;;;;;AAsCO,MAAM,YAAYA,UAAA;AAAA,EACxB,CAAS,UAAA;AACF,UAAA,EAAE,uBAAuB,OAAW,IAAA;AAC1C,UAAM,SACL,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,IAC5C,MAAM,SACN,WAAW,SAAS,MAAM,QACzB,CAAC,MAAM,KAAK,IACZC,0BAAkB,sEAAsE;AAE7FC,eAAA;AAAA,MACC;AAAA,MACA;AAAA,IAAA;AAID,UAAM,iBAAiBC,UAAAA;AACvB,UAAM,cAAc,eAAe;AAEnC,UAAM,eAAeC,MAAA;AAAA,MACpB,CAAC,QAA6CC,QAAc,c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cesContent":["import { useArrayMapMemo, useConstantLengthInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback, useMemo } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { FieldAccessor, FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '@contember/binding'\nimport { QueryLanguage, throwBindingError } from '@contember/binding'\nimport { Component } from '../coreComponents'\nimport { SugaredField } from './SugaredField'\n\nexport interface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\nexport type FieldViewProps =\n\t& FieldViewCommonProps\n\t& (\n\t\t| {\n\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n/**\n * Base field view component with no default formatting.\n *\n * @example\n * ```\n * <FieldView\n * field=\"startsAt\"\n * render={(accessor) => <>{accessor.value}</>}\n * />\n * ```\n *\n * @group Field Views\n */\nexport const FieldView = Component<FieldViewProps>(\n\tprops => {\n\t\tconst { fallbackIfUnpersisted, render } = props\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t\t? [props.field]\n\t\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\n\t\tuseConstantLengthInvariant(\n\t\t\tfields,\n\t\t\t`The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`,\n\t\t)\n\n\t\t// TODO over-subscribe less\n\t\tconst entityAccessor = useEntity()\n\t\tconst environment = entityAccessor.environment\n\n\t\tconst desugarField = useCallback(\n\t\t\t(rsf: string | SugaredRelativeSingleField) => QueryLanguage.desugarRelativeSingleField(rsf, environment),\n\t\t\t[environment],\n\t\t)\n\t\tconst desugaredFields = useArrayMapMemo(fields, desugarField)\n\n\t\tconst retrieveField = useCallback(\n\t\t\t(desugaredRsf: RelativeSingleField) => entityAccessor.getField(desugaredRsf),\n\t\t\t[entityAccessor],\n\t\t)\n\t\tconst accessors = useArrayMapMemo(desugaredFields, retrieveField)\n\n\t\t// TODO we probably want something like useDeferredValue from here.\n\t\t// Will probably just wait for Concurrent React though.\n\t\tconst output = useMemo(() => {\n\t\t\tif (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== undefined) {\n\t\t\t\treturn fallbackIfUnpersisted\n\t\t\t}\n\t\t\treturn render(...accessors)\n\t\t}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render])\n\n\t\treturn <>{output}</>\n\t},\n\tprops => {\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t\t? [props.field]\n\t\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{props.fallbackIfUnpersisted}\n\t\t\t\t{fields.map((field, i) => (\n\t\t\t\t\t<SugaredField key={i} field={field} />\n\t\t\t\t))}\n\t\t\t</>\n\t\t)\n\t},\n\t'FieldView',\n) as FieldViewComponentSignature\n\nexport type FieldViewComponentSignature = {\n\t<FV1 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t\t\trender: (field1: FieldAccessor<FV1>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue, FV4 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>, field4: FieldAccessor<FV4>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue, FV4 extends FieldValue, FV5 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>, field4: FieldAccessor<FV4>, field5: FieldAccessor<FV5>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t(props: FieldViewProps): ReactElement | null\n}\n"],"names":["Component","throwBindingError","useConstantLengthInvariant","useEntity","useCallback","QueryLanguage","useArrayMapMemo","useMemo","this","jsxDEV","Fragment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,MAAM,MAAA;AAAA,MACN,OAAO,IAAI,CAAC,OAAO,MAClBD,8BAAAA,OAAAE,aAAA,cAAA,EAAqB,SAAH,GAAnB,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAH,MAAoC,CACpC;AAAA,IAAA,KAJF,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAKA,GAAAA,MAAA;AAAA,EAEF;AAAA,EACA;AACD;;"}
@@ -21,7 +21,7 @@ const FieldView = Component(
21
21
  );
22
22
  const desugaredFields = useArrayMapMemo(fields, desugarField);
23
23
  const retrieveField = useCallback(
24
- (desugaredRsf) => entityAccessor.getRelativeSingleField(desugaredRsf),
24
+ (desugaredRsf) => entityAccessor.getField(desugaredRsf),
25
25
  [entityAccessor]
26
26
  );
27
27
  const accessors = useArrayMapMemo(desugaredFields, retrieveField);
@@ -1 +1 @@
1
- {"version":3,"file":"FieldView.js","sources":["../../../../../packages/react-binding/src/helperComponents/FieldView.tsx"],"sourcesContent":["import { useArrayMapMemo, useConstantLengthInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback, useMemo } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { FieldAccessor, FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '@contember/binding'\nimport { QueryLanguage, throwBindingError } from '@contember/binding'\nimport { Component } from '../coreComponents'\nimport { SugaredField } from './SugaredField'\n\nexport interface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\nexport type FieldViewProps =\n\t& FieldViewCommonProps\n\t& (\n\t\t| {\n\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n/**\n * Base field view component with no default formatting.\n *\n * @example\n * ```\n * <FieldView\n * field=\"startsAt\"\n * render={(accessor) => <>{accessor.value}</>}\n * />\n * ```\n *\n * @group Field Views\n */\nexport const FieldView = Component<FieldViewProps>(\n\tprops => {\n\t\tconst { fallbackIfUnpersisted, render } = props\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t\t? [props.field]\n\t\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\n\t\tuseConstantLengthInvariant(\n\t\t\tfields,\n\t\t\t`The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`,\n\t\t)\n\n\t\t// TODO over-subscribe less\n\t\tconst entityAccessor = useEntity()\n\t\tconst environment = entityAccessor.environment\n\n\t\tconst desugarField = useCallback(\n\t\t\t(rsf: string | SugaredRelativeSingleField) => QueryLanguage.desugarRelativeSingleField(rsf, environment),\n\t\t\t[environment],\n\t\t)\n\t\tconst desugaredFields = useArrayMapMemo(fields, desugarField)\n\n\t\tconst retrieveField = useCallback(\n\t\t\t(desugaredRsf: RelativeSingleField) => entityAccessor.getRelativeSingleField(desugaredRsf),\n\t\t\t[entityAccessor],\n\t\t)\n\t\tconst accessors = useArrayMapMemo(desugaredFields, retrieveField)\n\n\t\t// TODO we probably want something like useDeferredValue from here.\n\t\t// Will probably just wait for Concurrent React though.\n\t\tconst output = useMemo(() => {\n\t\t\tif (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== undefined) {\n\t\t\t\treturn fallbackIfUnpersisted\n\t\t\t}\n\t\t\treturn render(...accessors)\n\t\t}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render])\n\n\t\treturn <>{output}</>\n\t},\n\tprops => {\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t\t? [props.field]\n\t\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{props.fallbackIfUnpersisted}\n\t\t\t\t{fields.map((field, i) => (\n\t\t\t\t\t<SugaredField key={i} field={field} />\n\t\t\t\t))}\n\t\t\t</>\n\t\t)\n\t},\n\t'FieldView',\n) as FieldViewComponentSignature\n\nexport type FieldViewComponentSignature = {\n\t<FV1 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t\t\trender: (field1: FieldAccessor<FV1>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue, FV4 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>, field4: FieldAccessor<FV4>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue, FV4 extends FieldValue, FV5 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>, field4: FieldAccessor<FV4>, field5: FieldAccessor<FV5>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t(props: FieldViewProps): ReactElement | null\n}\n"],"names":["this"],"mappings":";;;;;;;AAsCO,MAAM,YAAY;AAAA,EACxB,CAAS,UAAA;AACF,UAAA,EAAE,uBAAuB,OAAW,IAAA;AAC1C,UAAM,SACL,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,IAC5C,MAAM,SACN,WAAW,SAAS,MAAM,QACzB,CAAC,MAAM,KAAK,IACZ,kBAAkB,sEAAsE;AAE7F;AAAA,MACC;AAAA,MACA;AAAA,IAAA;AAID,UAAM,iBAAiB;AACvB,UAAM,cAAc,eAAe;AAEnC,UAAM,eAAe;AAAA,MACpB,CAAC,QAA6C,cAAc,2BAA2B,KAAK,WAAW;AAAA,MACvG,CAAC,WAAW;AAAA,IAAA;AAEP,UAAA,kBAAkB,gBAAgB,QAAQ,YAAY;AAE5D,UAAM,gBAAgB;AAAA,MACrB,CAAC,iBAAsC,eAAe,uBAAuB,YAAY;AAAA,MACzF,CAAC,cAAc;AAAA,IAAA;AAEV,UAAA,YAAY,gBAAgB,iBAAiB,aAAa;AAI1D,UAAA,SAAS,QAAQ,MAAM;AAC5B,UAAI,CAAC,eAAe,kBAAkB,0BAA0B,QAAW;AACnE,eAAA;AAAA,MACR;AACO,aAAA,OAAO,GAAG,SAAS;AAAA,IAAA,GACxB,CAAC,WAAW,eAAe,gBAAgB,uBAAuB,MAAM,CAAC;AAE5E,8CAAU,UAAH,UAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAU,GAAAA,MAAA;AAAA,EAClB;AAAA,EACA,CAAS,UAAA;AACR,UAAM,SACL,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,IAC5C,MAAM,SACN,WAAW,SAAS,MAAM,QACzB,CAAC,MAAM,KAAK,IACZ,kBAAkB,sEAAsE;AAC7F,WAEG,uBAAA,UAAA,EAAA,UAAA;AAAA,MAAM,MAAA;AAAA,MACN,OAAO,IAAI,CAAC,OAAO,MAClB,uBAAA,cAAA,EAAqB,SAAH,GAAnB,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAAoC,CACpC;AAAA,IAAA,KAJF,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAKA,GAAAA,MAAA;AAAA,EAEF;AAAA,EACA;AACD;"}
1
+ {"version":3,"file":"FieldView.js","sources":["../../../../../packages/react-binding/src/helperComponents/FieldView.tsx"],"sourcesContent":["import { useArrayMapMemo, useConstantLengthInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback, useMemo } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { FieldAccessor, FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '@contember/binding'\nimport { QueryLanguage, throwBindingError } from '@contember/binding'\nimport { Component } from '../coreComponents'\nimport { SugaredField } from './SugaredField'\n\nexport interface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\nexport type FieldViewProps =\n\t& FieldViewCommonProps\n\t& (\n\t\t| {\n\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n/**\n * Base field view component with no default formatting.\n *\n * @example\n * ```\n * <FieldView\n * field=\"startsAt\"\n * render={(accessor) => <>{accessor.value}</>}\n * />\n * ```\n *\n * @group Field Views\n */\nexport const FieldView = Component<FieldViewProps>(\n\tprops => {\n\t\tconst { fallbackIfUnpersisted, render } = props\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t\t? [props.field]\n\t\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\n\t\tuseConstantLengthInvariant(\n\t\t\tfields,\n\t\t\t`The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`,\n\t\t)\n\n\t\t// TODO over-subscribe less\n\t\tconst entityAccessor = useEntity()\n\t\tconst environment = entityAccessor.environment\n\n\t\tconst desugarField = useCallback(\n\t\t\t(rsf: string | SugaredRelativeSingleField) => QueryLanguage.desugarRelativeSingleField(rsf, environment),\n\t\t\t[environment],\n\t\t)\n\t\tconst desugaredFields = useArrayMapMemo(fields, desugarField)\n\n\t\tconst retrieveField = useCallback(\n\t\t\t(desugaredRsf: RelativeSingleField) => entityAccessor.getField(desugaredRsf),\n\t\t\t[entityAccessor],\n\t\t)\n\t\tconst accessors = useArrayMapMemo(desugaredFields, retrieveField)\n\n\t\t// TODO we probably want something like useDeferredValue from here.\n\t\t// Will probably just wait for Concurrent React though.\n\t\tconst output = useMemo(() => {\n\t\t\tif (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== undefined) {\n\t\t\t\treturn fallbackIfUnpersisted\n\t\t\t}\n\t\t\treturn render(...accessors)\n\t\t}, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render])\n\n\t\treturn <>{output}</>\n\t},\n\tprops => {\n\t\tconst fields =\n\t\t\t'fields' in props && Array.isArray(props.fields)\n\t\t\t\t? props.fields\n\t\t\t\t: 'field' in props && props.field\n\t\t\t\t\t? [props.field]\n\t\t\t\t\t: throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`)\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{props.fallbackIfUnpersisted}\n\t\t\t\t{fields.map((field, i) => (\n\t\t\t\t\t<SugaredField key={i} field={field} />\n\t\t\t\t))}\n\t\t\t</>\n\t\t)\n\t},\n\t'FieldView',\n) as FieldViewComponentSignature\n\nexport type FieldViewComponentSignature = {\n\t<FV1 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t\t\trender: (field1: FieldAccessor<FV1>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue, FV4 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>, field4: FieldAccessor<FV4>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t<FV1 extends FieldValue, FV2 extends FieldValue, FV3 extends FieldValue, FV4 extends FieldValue, FV5 extends FieldValue>(\n\t\tprops:\n\t\t\t& FieldViewCommonProps\n\t\t\t& {\n\t\t\t\tfields: [string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField, string | SugaredRelativeSingleField]\n\t\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>, field4: FieldAccessor<FV4>, field5: FieldAccessor<FV5>) => ReactNode\n\t\t\t},\n\t): ReactElement | null\n\n\t(props: FieldViewProps): ReactElement | null\n}\n"],"names":["this"],"mappings":";;;;;;;AAsCO,MAAM,YAAY;AAAA,EACxB,CAAS,UAAA;AACF,UAAA,EAAE,uBAAuB,OAAW,IAAA;AAC1C,UAAM,SACL,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,IAC5C,MAAM,SACN,WAAW,SAAS,MAAM,QACzB,CAAC,MAAM,KAAK,IACZ,kBAAkB,sEAAsE;AAE7F;AAAA,MACC;AAAA,MACA;AAAA,IAAA;AAID,UAAM,iBAAiB;AACvB,UAAM,cAAc,eAAe;AAEnC,UAAM,eAAe;AAAA,MACpB,CAAC,QAA6C,cAAc,2BAA2B,KAAK,WAAW;AAAA,MACvG,CAAC,WAAW;AAAA,IAAA;AAEP,UAAA,kBAAkB,gBAAgB,QAAQ,YAAY;AAE5D,UAAM,gBAAgB;AAAA,MACrB,CAAC,iBAAsC,eAAe,SAAS,YAAY;AAAA,MAC3E,CAAC,cAAc;AAAA,IAAA;AAEV,UAAA,YAAY,gBAAgB,iBAAiB,aAAa;AAI1D,UAAA,SAAS,QAAQ,MAAM;AAC5B,UAAI,CAAC,eAAe,kBAAkB,0BAA0B,QAAW;AACnE,eAAA;AAAA,MACR;AACO,aAAA,OAAO,GAAG,SAAS;AAAA,IAAA,GACxB,CAAC,WAAW,eAAe,gBAAgB,uBAAuB,MAAM,CAAC;AAE5E,8CAAU,UAAH,UAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAU,GAAAA,MAAA;AAAA,EAClB;AAAA,EACA,CAAS,UAAA;AACR,UAAM,SACL,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,IAC5C,MAAM,SACN,WAAW,SAAS,MAAM,QACzB,CAAC,MAAM,KAAK,IACZ,kBAAkB,sEAAsE;AAC7F,WAEG,uBAAA,UAAA,EAAA,UAAA;AAAA,MAAM,MAAA;AAAA,MACN,OAAO,IAAI,CAAC,OAAO,MAClB,uBAAA,cAAA,EAAqB,SAAH,GAAnB,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAAoC,CACpC;AAAA,IAAA,KAJF,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAKA,GAAAA,MAAA;AAAA,EAEF;AAAA,EACA;AACD;"}
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const binding = require("@contember/binding");
4
+ class IncrementalMarkerBuilder {
5
+ static build(markers) {
6
+ return markers.reduce((acc, addition) => {
7
+ if (addition instanceof binding.EntityFieldMarkersContainer) {
8
+ if (acc instanceof binding.EntityFieldMarkersContainer) {
9
+ return binding.MarkerMerger.mergeEntityFieldsContainers(acc, addition);
10
+ } else {
11
+ return new binding.EntityFieldsWithHoistablesMarker(
12
+ binding.MarkerMerger.mergeEntityFieldsContainers(acc.fields, addition),
13
+ acc.subTrees,
14
+ acc.parentReference
15
+ );
16
+ }
17
+ } else if (addition instanceof binding.EntityFieldsWithHoistablesMarker) {
18
+ if (acc instanceof binding.EntityFieldMarkersContainer) {
19
+ return new binding.EntityFieldsWithHoistablesMarker(
20
+ binding.MarkerMerger.mergeEntityFieldsContainers(acc, addition.fields),
21
+ addition.subTrees,
22
+ addition.parentReference
23
+ );
24
+ } else {
25
+ return new binding.EntityFieldsWithHoistablesMarker(
26
+ binding.MarkerMerger.mergeEntityFieldsContainers(acc.fields, addition.fields),
27
+ binding.MarkerMerger.mergeSubTreeMarkers(acc.subTrees, addition.subTrees),
28
+ binding.TreeParameterMerger.mergeParentEntityParameters(acc.parentReference, addition.parentReference)
29
+ );
30
+ }
31
+ } else {
32
+ if (acc instanceof binding.EntityFieldMarkersContainer) {
33
+ return binding.MarkerMerger.mergeEntityFieldsContainers(
34
+ acc,
35
+ binding.MarkerFactory.createEntityFieldMarkersContainer(addition)
36
+ );
37
+ } else {
38
+ return new binding.EntityFieldsWithHoistablesMarker(
39
+ binding.MarkerMerger.mergeEntityFieldsContainers(
40
+ acc.fields,
41
+ binding.MarkerFactory.createEntityFieldMarkersContainer(addition)
42
+ ),
43
+ acc.subTrees,
44
+ acc.parentReference
45
+ );
46
+ }
47
+ }
48
+ }, new binding.EntityFieldMarkersContainer(
49
+ false,
50
+ /* @__PURE__ */ new Map(),
51
+ /* @__PURE__ */ new Map()
52
+ ));
53
+ }
54
+ }
55
+ exports.IncrementalMarkerBuilder = IncrementalMarkerBuilder;
56
+ //# sourceMappingURL=IncrementalMarkerBuilder.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IncrementalMarkerBuilder.cjs","sources":["../../../../../packages/react-binding/src/markers/IncrementalMarkerBuilder.ts"],"sourcesContent":["import {\n\tEntityFieldMarker,\n\tEntityFieldMarkersContainer,\n\tEntityFieldsWithHoistablesMarker,\n\tMarkerFactory,\n\tMarkerMerger,\n\tTreeParameterMerger,\n} from '@contember/binding'\n\nexport class IncrementalMarkerBuilder {\n\tpublic static build(markers: (EntityFieldMarker | EntityFieldMarkersContainer | EntityFieldsWithHoistablesMarker)[]): EntityFieldsWithHoistablesMarker | EntityFieldMarkersContainer {\n\t\treturn markers.reduce<EntityFieldsWithHoistablesMarker | EntityFieldMarkersContainer>((acc, addition) => {\n\t\t\tif (addition instanceof EntityFieldMarkersContainer) {\n\t\t\t\tif (acc instanceof EntityFieldMarkersContainer) {\n\t\t\t\t\treturn MarkerMerger.mergeEntityFieldsContainers(acc, addition)\n\t\t\t\t} else {\n\t\t\t\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\t\t\t\tMarkerMerger.mergeEntityFieldsContainers(acc.fields, addition),\n\t\t\t\t\t\tacc.subTrees,\n\t\t\t\t\t\tacc.parentReference,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else if (addition instanceof EntityFieldsWithHoistablesMarker) {\n\t\t\t\tif (acc instanceof EntityFieldMarkersContainer) {\n\t\t\t\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\t\t\t\tMarkerMerger.mergeEntityFieldsContainers(acc, addition.fields),\n\t\t\t\t\t\taddition.subTrees,\n\t\t\t\t\t\taddition.parentReference,\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\t\t\t\tMarkerMerger.mergeEntityFieldsContainers(acc.fields, addition.fields),\n\t\t\t\t\t\tMarkerMerger.mergeSubTreeMarkers(acc.subTrees, addition.subTrees),\n\t\t\t\t\t\tTreeParameterMerger.mergeParentEntityParameters(acc.parentReference, addition.parentReference),\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (acc instanceof EntityFieldMarkersContainer) {\n\t\t\t\t\treturn MarkerMerger.mergeEntityFieldsContainers(\n\t\t\t\t\t\tacc,\n\t\t\t\t\t\tMarkerFactory.createEntityFieldMarkersContainer(addition),\n\t\t\t\t\t)\n\t\t\t\t} else {\n\t\t\t\t\treturn new EntityFieldsWithHoistablesMarker(\n\t\t\t\t\t\tMarkerMerger.mergeEntityFieldsContainers(\n\t\t\t\t\t\t\tacc.fields,\n\t\t\t\t\t\t\tMarkerFactory.createEntityFieldMarkersContainer(addition),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tacc.subTrees,\n\t\t\t\t\t\tacc.parentReference,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t}, new EntityFieldMarkersContainer(\n\t\t\tfalse,\n\t\t\tnew Map(),\n\t\t\tnew Map(),\n\t\t))\n\t}\n}\n"],"names":["EntityFieldMarkersContainer","MarkerMerger","EntityFieldsWithHoistablesMarker","TreeParameterMerger","MarkerFactory"],"mappings":";;;AASO,MAAM,yBAAyB;AAAA,EACrC,OAAc,MAAM,SAAiK;AACpL,WAAO,QAAQ,OAAuE,CAAC,KAAK,aAAa;AACxG,UAAI,oBAAoBA,QAAAA,6BAA6B;AACpD,YAAI,eAAeA,QAAAA,6BAA6B;AACxC,iBAAAC,qBAAa,4BAA4B,KAAK,QAAQ;AAAA,QAAA,OACvD;AACN,iBAAO,IAAIC,QAAA;AAAA,YACVD,QAAAA,aAAa,4BAA4B,IAAI,QAAQ,QAAQ;AAAA,YAC7D,IAAI;AAAA,YACJ,IAAI;AAAA,UAAA;AAAA,QAEN;AAAA,MAAA,WACU,oBAAoBC,0CAAkC;AAChE,YAAI,eAAeF,QAAAA,6BAA6B;AAC/C,iBAAO,IAAIE,QAAA;AAAA,YACVD,QAAAA,aAAa,4BAA4B,KAAK,SAAS,MAAM;AAAA,YAC7D,SAAS;AAAA,YACT,SAAS;AAAA,UAAA;AAAA,QACV,OAC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