@contember/binding 1.1.0-rc.5 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/development/accessorPropagation/AccessorProvider.js +7 -14
  2. package/dist/development/accessorPropagation/AccessorProvider.js.map +1 -1
  3. package/dist/development/accessorPropagation/BindingOperationsProvider.js +3 -7
  4. package/dist/development/accessorPropagation/BindingOperationsProvider.js.map +1 -1
  5. package/dist/development/accessorPropagation/EntityKeyProvider.js +3 -7
  6. package/dist/development/accessorPropagation/EntityKeyProvider.js.map +1 -1
  7. package/dist/development/accessorPropagation/EnvironmentContext.js +39 -56
  8. package/dist/development/accessorPropagation/EnvironmentContext.js.map +1 -1
  9. package/dist/development/accessorPropagation/TreeRootIdProvider.js +3 -7
  10. package/dist/development/accessorPropagation/TreeRootIdProvider.js.map +1 -1
  11. package/dist/development/accessorSorting/SetOrderFieldOnCreate.js +104 -89
  12. package/dist/development/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
  13. package/dist/development/accessorTree/AccessorTree.js +20 -39
  14. package/dist/development/accessorTree/AccessorTree.js.map +1 -1
  15. package/dist/development/accessorTree/RuntimeId.js +1 -1
  16. package/dist/development/accessorTree/RuntimeId.js.map +1 -1
  17. package/dist/development/accessorTree/accessorTreeStateReducer.js.map +1 -1
  18. package/dist/development/core/AccessorErrorManager.js +6 -6
  19. package/dist/development/core/AccessorErrorManager.js.map +1 -1
  20. package/dist/development/core/Config.js.map +1 -1
  21. package/dist/development/core/DataBinding.js +16 -16
  22. package/dist/development/core/DataBinding.js.map +1 -1
  23. package/dist/development/core/DirtinessTracker.js.map +1 -1
  24. package/dist/development/core/EventManager.js +11 -11
  25. package/dist/development/core/EventManager.js.map +1 -1
  26. package/dist/development/core/IncrementalMarkerBuilder.js +5 -5
  27. package/dist/development/core/IncrementalMarkerBuilder.js.map +1 -1
  28. package/dist/development/core/MarkerTreeGenerator.js +6 -6
  29. package/dist/development/core/MarkerTreeGenerator.js.map +1 -1
  30. package/dist/development/core/MutationGenerator.js +7 -7
  31. package/dist/development/core/MutationGenerator.js.map +1 -1
  32. package/dist/development/core/RealmKeyGenerator.js +2 -2
  33. package/dist/development/core/RealmKeyGenerator.js.map +1 -1
  34. package/dist/development/core/StateInitializer.js +8 -8
  35. package/dist/development/core/StateInitializer.js.map +1 -1
  36. package/dist/development/core/TreeAugmenter.js.map +1 -1
  37. package/dist/development/core/TreeStore.js +7 -7
  38. package/dist/development/core/TreeStore.js.map +1 -1
  39. package/dist/development/core/exceptions/ErrorLocator.js +3 -3
  40. package/dist/development/core/exceptions/ErrorLocator.js.map +1 -1
  41. package/dist/development/core/schema/SchemaLoader.js +2 -2
  42. package/dist/development/core/schema/SchemaLoader.js.map +1 -1
  43. package/dist/development/core/state/StateIterator.js.map +1 -1
  44. package/dist/development/coreComponents/Component.js.map +1 -1
  45. package/dist/development/coreComponents/DataBindingProvider.js +11 -11
  46. package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
  47. package/dist/development/coreComponents/Entity.js +11 -15
  48. package/dist/development/coreComponents/Entity.js.map +1 -1
  49. package/dist/development/coreComponents/EntityList.js +35 -31
  50. package/dist/development/coreComponents/EntityList.js.map +1 -1
  51. package/dist/development/coreComponents/EntityListSubTree.js +41 -41
  52. package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
  53. package/dist/development/coreComponents/EntitySubTree.js +63 -51
  54. package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
  55. package/dist/development/coreComponents/Field.js +28 -20
  56. package/dist/development/coreComponents/Field.js.map +1 -1
  57. package/dist/development/coreComponents/HasMany.js +30 -33
  58. package/dist/development/coreComponents/HasMany.js.map +1 -1
  59. package/dist/development/coreComponents/HasOne.js +30 -33
  60. package/dist/development/coreComponents/HasOne.js.map +1 -1
  61. package/dist/development/coreComponents/ParentEntity.js +12 -6
  62. package/dist/development/coreComponents/ParentEntity.js.map +1 -1
  63. package/dist/development/fieldHelpers/helpers/FieldHelper.js +1 -1
  64. package/dist/development/fieldHelpers/helpers/FieldHelper.js.map +1 -1
  65. package/dist/development/helperComponents/DeferredSubTrees.js +83 -86
  66. package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
  67. package/dist/development/helperComponents/EntityView.js +5 -3
  68. package/dist/development/helperComponents/EntityView.js.map +1 -1
  69. package/dist/development/helperComponents/FieldView.js +50 -36
  70. package/dist/development/helperComponents/FieldView.js.map +1 -1
  71. package/dist/development/helperComponents/If.js +70 -63
  72. package/dist/development/helperComponents/If.js.map +1 -1
  73. package/dist/development/helperComponents/StaticRender.js +9 -5
  74. package/dist/development/helperComponents/StaticRender.js.map +1 -1
  75. package/dist/development/helperComponents/SugaredField.js +6 -13
  76. package/dist/development/helperComponents/SugaredField.js.map +1 -1
  77. package/dist/development/helperComponents/helpers/FilterEvaluator.js.map +1 -1
  78. package/dist/development/markers/EntityListSubTreeMarker.js +2 -2
  79. package/dist/development/markers/EntityListSubTreeMarker.js.map +1 -1
  80. package/dist/development/markers/EntitySubTreeMarker.js +2 -2
  81. package/dist/development/markers/EntitySubTreeMarker.js.map +1 -1
  82. package/dist/development/markers/FieldMarker.js +2 -2
  83. package/dist/development/markers/FieldMarker.js.map +1 -1
  84. package/dist/development/markers/HasManyRelationMarker.js +3 -3
  85. package/dist/development/markers/HasManyRelationMarker.js.map +1 -1
  86. package/dist/development/markers/HasOneRelationMarker.js +2 -2
  87. package/dist/development/markers/HasOneRelationMarker.js.map +1 -1
  88. package/dist/development/queryLanguage/CacheStore.js +1 -1
  89. package/dist/development/queryLanguage/CacheStore.js.map +1 -1
  90. package/dist/development/queryLanguage/Parser.js +7 -7
  91. package/dist/development/queryLanguage/Parser.js.map +1 -1
  92. package/dist/development/queryLanguage/QueryLanguage.js +6 -6
  93. package/dist/development/queryLanguage/QueryLanguage.js.map +1 -1
  94. package/dist/development/structures/BijectiveIndexedMap.js +1 -1
  95. package/dist/development/structures/BijectiveIndexedMap.js.map +1 -1
  96. package/dist/development/structures/LRUCache.js +1 -1
  97. package/dist/development/structures/LRUCache.js.map +1 -1
  98. package/dist/development/structures/WeakIdCache.js.map +1 -1
  99. package/dist/production/accessorPropagation/AccessorProvider.js +2 -8
  100. package/dist/production/accessorPropagation/AccessorProvider.js.map +1 -1
  101. package/dist/production/accessorPropagation/BindingOperationsProvider.js +2 -5
  102. package/dist/production/accessorPropagation/BindingOperationsProvider.js.map +1 -1
  103. package/dist/production/accessorPropagation/EntityKeyProvider.js +2 -5
  104. package/dist/production/accessorPropagation/EntityKeyProvider.js.map +1 -1
  105. package/dist/production/accessorPropagation/EnvironmentContext.js +23 -43
  106. package/dist/production/accessorPropagation/EnvironmentContext.js.map +1 -1
  107. package/dist/production/accessorPropagation/TreeRootIdProvider.js +2 -5
  108. package/dist/production/accessorPropagation/TreeRootIdProvider.js.map +1 -1
  109. package/dist/production/accessorSorting/SetOrderFieldOnCreate.js +62 -62
  110. package/dist/production/accessorSorting/SetOrderFieldOnCreate.js.map +1 -1
  111. package/dist/production/accessorTree/AccessorTree.js +3 -21
  112. package/dist/production/accessorTree/AccessorTree.js.map +1 -1
  113. package/dist/production/accessorTree/RuntimeId.js +1 -1
  114. package/dist/production/accessorTree/RuntimeId.js.map +1 -1
  115. package/dist/production/accessorTree/accessorTreeStateReducer.js.map +1 -1
  116. package/dist/production/core/AccessorErrorManager.js +6 -6
  117. package/dist/production/core/AccessorErrorManager.js.map +1 -1
  118. package/dist/production/core/Config.js.map +1 -1
  119. package/dist/production/core/DataBinding.js +16 -16
  120. package/dist/production/core/DataBinding.js.map +1 -1
  121. package/dist/production/core/DirtinessTracker.js.map +1 -1
  122. package/dist/production/core/EventManager.js +11 -11
  123. package/dist/production/core/EventManager.js.map +1 -1
  124. package/dist/production/core/IncrementalMarkerBuilder.js +5 -5
  125. package/dist/production/core/IncrementalMarkerBuilder.js.map +1 -1
  126. package/dist/production/core/MarkerTreeGenerator.js +6 -6
  127. package/dist/production/core/MarkerTreeGenerator.js.map +1 -1
  128. package/dist/production/core/MutationGenerator.js +7 -7
  129. package/dist/production/core/MutationGenerator.js.map +1 -1
  130. package/dist/production/core/RealmKeyGenerator.js +2 -2
  131. package/dist/production/core/RealmKeyGenerator.js.map +1 -1
  132. package/dist/production/core/StateInitializer.js +8 -8
  133. package/dist/production/core/StateInitializer.js.map +1 -1
  134. package/dist/production/core/TreeAugmenter.js.map +1 -1
  135. package/dist/production/core/TreeStore.js +7 -7
  136. package/dist/production/core/TreeStore.js.map +1 -1
  137. package/dist/production/core/exceptions/ErrorLocator.js +3 -3
  138. package/dist/production/core/exceptions/ErrorLocator.js.map +1 -1
  139. package/dist/production/core/schema/SchemaLoader.js +2 -2
  140. package/dist/production/core/schema/SchemaLoader.js.map +1 -1
  141. package/dist/production/core/state/StateIterator.js.map +1 -1
  142. package/dist/production/coreComponents/Component.js.map +1 -1
  143. package/dist/production/coreComponents/DataBindingProvider.js +10 -9
  144. package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
  145. package/dist/production/coreComponents/Entity.js +7 -10
  146. package/dist/production/coreComponents/Entity.js.map +1 -1
  147. package/dist/production/coreComponents/EntityList.js +25 -28
  148. package/dist/production/coreComponents/EntityList.js.map +1 -1
  149. package/dist/production/coreComponents/EntityListSubTree.js +29 -28
  150. package/dist/production/coreComponents/EntityListSubTree.js.map +1 -1
  151. package/dist/production/coreComponents/EntitySubTree.js +39 -34
  152. package/dist/production/coreComponents/EntitySubTree.js.map +1 -1
  153. package/dist/production/coreComponents/Field.js +20 -20
  154. package/dist/production/coreComponents/Field.js.map +1 -1
  155. package/dist/production/coreComponents/HasMany.js +18 -20
  156. package/dist/production/coreComponents/HasMany.js.map +1 -1
  157. package/dist/production/coreComponents/HasOne.js +18 -20
  158. package/dist/production/coreComponents/HasOne.js.map +1 -1
  159. package/dist/production/coreComponents/ParentEntity.js +8 -6
  160. package/dist/production/coreComponents/ParentEntity.js.map +1 -1
  161. package/dist/production/fieldHelpers/helpers/FieldHelper.js +1 -1
  162. package/dist/production/fieldHelpers/helpers/FieldHelper.js.map +1 -1
  163. package/dist/production/helperComponents/DeferredSubTrees.js +67 -77
  164. package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
  165. package/dist/production/helperComponents/EntityView.js +1 -3
  166. package/dist/production/helperComponents/EntityView.js.map +1 -1
  167. package/dist/production/helperComponents/FieldView.js +38 -31
  168. package/dist/production/helperComponents/FieldView.js.map +1 -1
  169. package/dist/production/helperComponents/If.js +40 -52
  170. package/dist/production/helperComponents/If.js.map +1 -1
  171. package/dist/production/helperComponents/StaticRender.js +5 -5
  172. package/dist/production/helperComponents/StaticRender.js.map +1 -1
  173. package/dist/production/helperComponents/SugaredField.js +2 -8
  174. package/dist/production/helperComponents/SugaredField.js.map +1 -1
  175. package/dist/production/helperComponents/helpers/FilterEvaluator.js.map +1 -1
  176. package/dist/production/markers/EntityListSubTreeMarker.js +2 -2
  177. package/dist/production/markers/EntityListSubTreeMarker.js.map +1 -1
  178. package/dist/production/markers/EntitySubTreeMarker.js +2 -2
  179. package/dist/production/markers/EntitySubTreeMarker.js.map +1 -1
  180. package/dist/production/markers/FieldMarker.js +2 -2
  181. package/dist/production/markers/FieldMarker.js.map +1 -1
  182. package/dist/production/markers/HasManyRelationMarker.js +2 -2
  183. package/dist/production/markers/HasManyRelationMarker.js.map +1 -1
  184. package/dist/production/markers/HasOneRelationMarker.js +2 -2
  185. package/dist/production/markers/HasOneRelationMarker.js.map +1 -1
  186. package/dist/production/queryLanguage/CacheStore.js +1 -1
  187. package/dist/production/queryLanguage/CacheStore.js.map +1 -1
  188. package/dist/production/queryLanguage/Parser.js +7 -7
  189. package/dist/production/queryLanguage/Parser.js.map +1 -1
  190. package/dist/production/queryLanguage/QueryLanguage.js +6 -6
  191. package/dist/production/queryLanguage/QueryLanguage.js.map +1 -1
  192. package/dist/production/structures/BijectiveIndexedMap.js +1 -1
  193. package/dist/production/structures/BijectiveIndexedMap.js.map +1 -1
  194. package/dist/production/structures/LRUCache.js +1 -1
  195. package/dist/production/structures/LRUCache.js.map +1 -1
  196. package/dist/production/structures/WeakIdCache.js.map +1 -1
  197. package/dist/types/tsconfig.tsbuildinfo +1 -1
  198. package/package.json +13 -13
  199. package/LICENSE +0 -186
@@ -1,6 +1,6 @@
1
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
1
2
  import { useState, useCallback, useEffect } from "react";
2
3
  import { useConstantValueInvariant } from "@contember/react-utils";
3
- import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
4
4
  import { Component } from "../coreComponents/Component.js";
5
5
  import { useBindingOperations } from "../accessorPropagation/useBindingOperations.js";
6
6
  import { useMutationState } from "../accessorTree/useMutationState.js";
@@ -11,97 +11,94 @@ import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
11
11
  import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
12
12
  import { EntityFieldMarkersContainer } from "../markers/EntityFieldMarkersContainer.js";
13
13
  import { EntityFieldsWithHoistablesMarker } from "../markers/EntityFieldsWithHoistablesMarker.js";
14
- var _jsxFileName = "/__w/interface/interface/packages/binding/src/helperComponents/DeferredSubTrees.tsx";
15
- const DeferredSubTrees = Component((props) => {
16
- const {
17
- extendTree
18
- } = useBindingOperations();
19
- const isMutating = useMutationState();
20
- const [loadState, setLoadState] = useState({
21
- name: "initial"
22
- });
23
- const [abortController] = useState(() => new AbortController());
24
- const signal = abortController.signal;
25
- const hasEntity = useHasEntity();
26
- useConstantValueInvariant(hasEntity);
27
- if (hasEntity) {
28
- useEntityBeforePersist(useCallback((getAccessor) => {
29
- if (getAccessor().existsOnServer) {
14
+ const DeferredSubTrees = Component(
15
+ (props) => {
16
+ const { extendTree } = useBindingOperations();
17
+ const isMutating = useMutationState();
18
+ const [loadState, setLoadState] = useState({ name: "initial" });
19
+ const [abortController] = useState(() => new AbortController());
20
+ const signal = abortController.signal;
21
+ const hasEntity = useHasEntity();
22
+ useConstantValueInvariant(hasEntity);
23
+ if (hasEntity) {
24
+ useEntityBeforePersist(
25
+ useCallback((getAccessor) => {
26
+ if (getAccessor().existsOnServer) {
27
+ return;
28
+ }
29
+ setLoadState({ name: "initial" });
30
+ }, [])
31
+ );
32
+ }
33
+ useEffect(() => {
34
+ return () => {
35
+ abortController.abort();
36
+ };
37
+ }, [abortController]);
38
+ const environment = useEnvironment();
39
+ useEffect(() => {
40
+ if (isMutating || loadState.name !== "initial" || signal.aborted) {
30
41
  return;
31
42
  }
32
- setLoadState({
33
- name: "initial"
43
+ setLoadState({ name: "loading" });
44
+ const newFragment = /* @__PURE__ */ jsxDEV(OnlyKeepSubTrees, { children: props.children }, void 0, false, {
45
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/DeferredSubTrees.tsx",
46
+ lineNumber: 63,
47
+ columnNumber: 24
48
+ }, globalThis);
49
+ extendTree(newFragment, { signal, environment }).then((treeRootId) => !signal.aborted && setLoadState({ name: "success", treeRootId })).catch((error) => {
50
+ if (signal.aborted) {
51
+ return;
52
+ }
53
+ throw error;
34
54
  });
35
- }, []));
36
- }
37
- useEffect(() => {
38
- return () => {
39
- abortController.abort();
40
- };
41
- }, [abortController]);
42
- const environment = useEnvironment();
43
- useEffect(() => {
44
- if (isMutating || loadState.name !== "initial" || signal.aborted) {
45
- return;
55
+ }, [environment, extendTree, isMutating, loadState.name, props.children, signal]);
56
+ switch (loadState.name) {
57
+ case "initial":
58
+ case "loading":
59
+ return /* @__PURE__ */ jsxDEV(Fragment, { children: props.fallback }, void 0, false, {
60
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/DeferredSubTrees.tsx",
61
+ lineNumber: 78,
62
+ columnNumber: 12
63
+ }, globalThis);
64
+ case "success":
65
+ return /* @__PURE__ */ jsxDEV(TreeRootIdProvider, { treeRootId: loadState.treeRootId, children: props.children }, void 0, false, {
66
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/DeferredSubTrees.tsx",
67
+ lineNumber: 84,
68
+ columnNumber: 12
69
+ }, globalThis);
46
70
  }
47
- setLoadState({
48
- name: "loading"
49
- });
50
- const newFragment = /* @__PURE__ */ jsxDEV(OnlyKeepSubTrees, {
51
- children: props.children
52
- }, void 0, false, {
53
- fileName: _jsxFileName,
54
- lineNumber: 63,
55
- columnNumber: 24
56
- }, void 0);
57
- extendTree(newFragment, {
58
- signal,
59
- environment
60
- }).then((treeRootId) => !signal.aborted && setLoadState({
61
- name: "success",
62
- treeRootId
63
- })).catch((error) => {
64
- if (signal.aborted) {
65
- return;
71
+ },
72
+ {
73
+ staticRender: (props) => /* @__PURE__ */ jsxDEV(Fragment, { children: [
74
+ props.children,
75
+ props.fallback
76
+ ] }, void 0, true, {
77
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/DeferredSubTrees.tsx",
78
+ lineNumber: 89,
79
+ columnNumber: 4
80
+ }, globalThis),
81
+ generateBranchMarker: (props, fields, environment) => {
82
+ const fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment);
83
+ fieldsWithHoistablesMarker.subTrees?.clear();
84
+ return fieldsWithHoistablesMarker;
85
+ }
86
+ },
87
+ "DeferredSubTree"
88
+ );
89
+ const OnlyKeepSubTrees = Component(
90
+ () => null,
91
+ {
92
+ generateBranchMarker: (props, fields) => {
93
+ const emptyFields = MarkerFactory.createEntityFieldMarkersContainer(void 0);
94
+ if (fields instanceof EntityFieldMarkersContainer) {
95
+ return emptyFields;
66
96
  }
67
- throw error;
68
- });
69
- }, [environment, extendTree, isMutating, loadState.name, props.children, signal]);
70
- switch (loadState.name) {
71
- case "initial":
72
- case "loading":
73
- return /* @__PURE__ */ jsxDEV(Fragment, {
74
- children: props.fallback
75
- }, void 0, false);
76
- case "success":
77
- return /* @__PURE__ */ jsxDEV(TreeRootIdProvider, {
78
- treeRootId: loadState.treeRootId,
79
- children: props.children
80
- }, void 0, false, {
81
- fileName: _jsxFileName,
82
- lineNumber: 84,
83
- columnNumber: 12
84
- }, void 0);
85
- }
86
- }, {
87
- staticRender: (props) => /* @__PURE__ */ jsxDEV(Fragment, {
88
- children: [props.children, props.fallback]
89
- }, void 0, true),
90
- generateBranchMarker: (props, fields, environment) => {
91
- const fieldsWithHoistablesMarker = MarkerFactory.createEntityFieldsWithHoistablesMarker(fields, environment);
92
- fieldsWithHoistablesMarker.subTrees?.clear();
93
- return fieldsWithHoistablesMarker;
94
- }
95
- }, "DeferredSubTree");
96
- const OnlyKeepSubTrees = Component(() => null, {
97
- generateBranchMarker: (props, fields) => {
98
- const emptyFields = MarkerFactory.createEntityFieldMarkersContainer(void 0);
99
- if (fields instanceof EntityFieldMarkersContainer) {
100
- return emptyFields;
97
+ return new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, void 0);
101
98
  }
102
- return new EntityFieldsWithHoistablesMarker(emptyFields, fields.subTrees, void 0);
103
- }
104
- }, "OnlyKeepSubTrees");
99
+ },
100
+ "OnlyKeepSubTrees"
101
+ );
105
102
  export {
106
103
  DeferredSubTrees
107
104
  };
@@ -1 +1 @@
1
- {"version":3,"file":"DeferredSubTrees.js","sources":["../../../src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { useMutationState } from '../accessorTree'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { TreeRootId } from '../treeParameters'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '../accessors'\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\t\tname: 'success'\n\t\t\ttreeRootId: TreeRootId | undefined\n\t }\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":["DeferredSubTrees","Component","props","extendTree","useBindingOperations","isMutating","useMutationState","loadState","setLoadState","useState","name","abortController","AbortController","signal","hasEntity","useHasEntity","useConstantValueInvariant","useCallback","getAccessor","existsOnServer","useEffect","abort","environment","useEnvironment","aborted","newFragment","children","then","treeRootId","catch","error","_Fragment","fallback","staticRender","_jsxDEV","generateBranchMarker","fields","fieldsWithHoistablesMarker","MarkerFactory","createEntityFieldsWithHoistablesMarker","subTrees","clear","OnlyKeepSubTrees","emptyFields","createEntityF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Y,CAAC,EACnFC,MAAMC,CAAS,UAAA;AACf,UAAIjB,OAAOW,SAAS;AACnB;AAAA,MACD;AACMM,YAAAA;AAAAA,IAAAA,CACN;AAAA,EAAA,GACA,CAACR,aAAanB,YAAYE,YAAYE,UAAUG,MAAMR,MAAMwB,UAAUb,MAAM,CAAC;AAEhF,UAAQN,UAAUG;AAAAA,SACZ;AAAA,SACA;AACJ,oCAAOqB,UAAA;AAAA,QAAA,UAAG7B,MAAM8B;AAAAA,MAAAA,GAAY,QAAA,KAAA;AAAA,SACxB;AAKJ,oCAAQ,oBAAkB;AAAA,QAAC,YAAYzB,UAAUqB;AAAAA,QAAW,UAAE1B,MAAMwB;AAAAA,MAAAA,GAAQ,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAsB,MAAA;AAAA;AAErG,GACA;AAAA,EACCO,cAAc/B,CACb,UAAAgC,uBAAAH,UAAA;AAAA,IAAA,UAAA,CACE7B,MAAMwB,UACNxB,MAAM8B,QAAQ;AAAA,EAAA,GAEhB,QAAA,IAAA;AAAA,EACDG,sBAAsB,CAACjC,OAAOkC,QAAQd,gBAAgB;AACrD,UAAMe,6BAA6BC,cAAcC,uCAAuCH,QAAQd,WAAW;AAM3Ge,+BAA2BG,UAAUC;AAE9BJ,WAAAA;AAAAA,EACR;AACD,GACA,iBAAiB;AAGlB,MAAMK,mBAAmBzC,UACxB,MAAM,MACN;AAAA,EACCkC,sBAAsB,CAACjC,OAAOkC,WAAW;AAElCO,UAAAA,cAAcL,cAAcM,kCAAkCC,MAAS;AAE7E,QAAIT,kBAAkBU,6BAA6B;AAC3CH,aAAAA;AAAAA,IACR;AACA,WAAO,IAAII,iCAAiCJ,aAAaP,OAAOI,UAAUK,MAAS;AAAA,EACpF;AACD,GACA,kBAAkB;"}
1
+ {"version":3,"file":"DeferredSubTrees.js","sources":["../../../src/helperComponents/DeferredSubTrees.tsx"],"sourcesContent":["import { ReactNode, useCallback, useEffect, useState } from 'react'\nimport { TreeRootIdProvider, useBindingOperations, useHasEntity, useEnvironment } from '../accessorPropagation'\nimport { useMutationState } from '../accessorTree'\nimport { Component } from '../coreComponents'\nimport { useEntityBeforePersist } from '../entityEvents'\nimport { EntityFieldMarkersContainer, EntityFieldsWithHoistablesMarker } from '../markers'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { TreeRootId } from '../treeParameters'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { EntityAccessor } from '../accessors'\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\t\tname: 'success'\n\t\t\ttreeRootId: TreeRootId | undefined\n\t }\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":";;;;;;;;;;;;;AAwBO,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,UAAU,SAAS,aAAa,OAAO,SAAS;AACjE;AAAA,MACD;AACa,mBAAA,EAAE,MAAM,UAAA,CAAW;AAEhC,YAAM,cAAc,uBAAC,kBAAkB,EAAA,UAAA,MAAM,SAAzB,GAAA,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAkC,GAAAA,UAAA;AAE3C,iBAAA,aAAa,EAAE,QAAQ,YAAa,CAAA,EAC7C,KAAK,gBAAc,CAAC,OAAO,WAAW,aAAa,EAAE,MAAM,WAAW,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"}
@@ -2,9 +2,11 @@ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
2
2
  import { useEntity } from "../accessorPropagation/useEntity.js";
3
3
  function EntityView(props) {
4
4
  const entity = "field" in props ? useEntity(props.field) : useEntity();
5
- return /* @__PURE__ */ jsxDEV(Fragment, {
6
- children: props.render(entity)
7
- }, void 0, false);
5
+ return /* @__PURE__ */ jsxDEV(Fragment, { children: props.render(entity) }, void 0, false, {
6
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/EntityView.tsx",
7
+ lineNumber: 15,
8
+ columnNumber: 9
9
+ }, this);
8
10
  }
9
11
  export {
10
12
  EntityView
@@ -1 +1 @@
1
- {"version":3,"file":"EntityView.js","sources":["../../../src/helperComponents/EntityView.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\n\nexport interface EntityViewProps {\n\trender: (entity: EntityAccessor) => ReactNode\n\tfield?: string | SugaredRelativeSingleEntity\n}\n\nexport function EntityView(props: EntityViewProps) {\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst entity = 'field' in props ? useEntity(props.field)! : useEntity()\n\n\treturn <>{props.render(entity)}</>\n}\n"],"names":["EntityView","props","entity","useEntity","field","_Fragment","render"],"mappings":";;AAUO,SAASA,WAAWC,OAAwB;AAElD,QAAMC,SAAS,WAAWD,QAAQE,UAAUF,MAAMG,KAAK,IAAKD;AAE5D,gCAAOE,UAAA;AAAA,IAAA,UAAGJ,MAAMK,OAAOJ,MAAM;AAAA,EAAA,GAAK,QAAA,KAAA;AACnC;"}
1
+ {"version":3,"file":"EntityView.js","sources":["../../../src/helperComponents/EntityView.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport type { EntityAccessor } from '../accessors'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\n\nexport interface EntityViewProps {\n\trender: (entity: EntityAccessor) => ReactNode\n\tfield?: string | SugaredRelativeSingleEntity\n}\n\nexport function EntityView(props: EntityViewProps) {\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst entity = 'field' in props ? useEntity(props.field)! : useEntity()\n\n\treturn <>{props.render(entity)}</>\n}\n"],"names":[],"mappings":";;AAUO,SAAS,WAAW,OAAwB;AAElD,QAAM,SAAS,WAAW,QAAQ,UAAU,MAAM,KAAK,IAAK;AAE5D,SAAU,uBAAA,UAAA,EAAA,UAAA,MAAM,OAAO,MAAM,EAAtB,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAwB,GAAA,IAAA;AAChC;"}
@@ -1,46 +1,60 @@
1
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
1
2
  import { useConstantLengthInvariant, useArrayMapMemo } from "@contember/react-utils";
2
3
  import { useCallback, useMemo } from "react";
3
4
  import { throwBindingError } from "../BindingError.js";
4
5
  import { SugaredField } from "./SugaredField.js";
5
- import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
6
6
  import { Component } from "../coreComponents/Component.js";
7
7
  import { useEntity } from "../accessorPropagation/useEntity.js";
8
8
  import { QueryLanguage } from "../queryLanguage/QueryLanguage.js";
9
- var _jsxFileName = "/__w/interface/interface/packages/binding/src/helperComponents/FieldView.tsx";
10
- const FieldView = Component((props) => {
11
- const {
12
- fallbackIfUnpersisted,
13
- render
14
- } = props;
15
- const fields = "fields" in props && Array.isArray(props.fields) ? props.fields : "field" in props && props.field ? [props.field] : throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`);
16
- useConstantLengthInvariant(fields, `The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`);
17
- const entityAccessor = useEntity();
18
- const environment = entityAccessor.environment;
19
- const desugarField = useCallback((rsf) => QueryLanguage.desugarRelativeSingleField(rsf, environment), [environment]);
20
- const desugaredFields = useArrayMapMemo(fields, desugarField);
21
- const retrieveField = useCallback((desugaredRsf) => entityAccessor.getRelativeSingleField(desugaredRsf), [entityAccessor]);
22
- const accessors = useArrayMapMemo(desugaredFields, retrieveField);
23
- const output = useMemo(() => {
24
- if (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== void 0) {
25
- return fallbackIfUnpersisted;
26
- }
27
- return render(...accessors);
28
- }, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render]);
29
- return /* @__PURE__ */ jsxDEV(Fragment, {
30
- children: output
31
- }, void 0, false);
32
- }, (props) => {
33
- const fields = "fields" in props && Array.isArray(props.fields) ? props.fields : "field" in props && props.field ? [props.field] : throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`);
34
- return /* @__PURE__ */ jsxDEV(Fragment, {
35
- children: [props.fallbackIfUnpersisted, fields.map((field, i) => /* @__PURE__ */ jsxDEV(SugaredField, {
36
- field
37
- }, i, false, {
38
- fileName: _jsxFileName,
39
- lineNumber: 87,
40
- columnNumber: 6
41
- }, void 0))]
42
- }, void 0, true);
43
- }, "FieldView");
9
+ const FieldView = Component(
10
+ (props) => {
11
+ const { fallbackIfUnpersisted, render } = props;
12
+ const fields = "fields" in props && Array.isArray(props.fields) ? props.fields : "field" in props && props.field ? [props.field] : throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`);
13
+ useConstantLengthInvariant(
14
+ fields,
15
+ `The number of fields in the 'fields' prop of the 'FieldView' must remain constant between renders!`
16
+ );
17
+ const entityAccessor = useEntity();
18
+ const environment = entityAccessor.environment;
19
+ const desugarField = useCallback(
20
+ (rsf) => QueryLanguage.desugarRelativeSingleField(rsf, environment),
21
+ [environment]
22
+ );
23
+ const desugaredFields = useArrayMapMemo(fields, desugarField);
24
+ const retrieveField = useCallback(
25
+ (desugaredRsf) => entityAccessor.getRelativeSingleField(desugaredRsf),
26
+ [entityAccessor]
27
+ );
28
+ const accessors = useArrayMapMemo(desugaredFields, retrieveField);
29
+ const output = useMemo(() => {
30
+ if (!entityAccessor.existsOnServer && fallbackIfUnpersisted !== void 0) {
31
+ return fallbackIfUnpersisted;
32
+ }
33
+ return render(...accessors);
34
+ }, [accessors, entityAccessor.existsOnServer, fallbackIfUnpersisted, render]);
35
+ return /* @__PURE__ */ jsxDEV(Fragment, { children: output }, void 0, false, {
36
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/FieldView.tsx",
37
+ lineNumber: 74,
38
+ columnNumber: 10
39
+ }, globalThis);
40
+ },
41
+ (props) => {
42
+ const fields = "fields" in props && Array.isArray(props.fields) ? props.fields : "field" in props && props.field ? [props.field] : throwBindingError(`FieldView: failed to supply either the 'field' or the 'fields' prop.`);
43
+ return /* @__PURE__ */ jsxDEV(Fragment, { children: [
44
+ props.fallbackIfUnpersisted,
45
+ fields.map((field, i) => /* @__PURE__ */ jsxDEV(SugaredField, { field }, i, false, {
46
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/FieldView.tsx",
47
+ lineNumber: 87,
48
+ columnNumber: 6
49
+ }, globalThis))
50
+ ] }, void 0, true, {
51
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/FieldView.tsx",
52
+ lineNumber: 84,
53
+ columnNumber: 4
54
+ }, globalThis);
55
+ },
56
+ "FieldView"
57
+ );
44
58
  export {
45
59
  FieldView
46
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"FieldView.js","sources":["../../../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 } from '../accessors'\nimport { throwBindingError } from '../BindingError'\nimport { Component } from '../coreComponents'\nimport { QueryLanguage } from '../queryLanguage'\nimport type { FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '../treeParameters'\nimport { SugaredField } from './SugaredField'\n\ninterface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\ntype FieldViewProps = FieldViewCommonProps &\n\t(\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n// Just short type aliases so that we can type the overloads in a tractable fashion.\ntype FV = FieldValue\ntype SRSF = string | SugaredRelativeSingleField\ntype CP = FieldViewCommonProps\ntype RN = ReactNode\ntype REN = ReactElement | null\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? [props.field]\n\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: SRSF) => 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? [props.field]\n\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 {\n\t<FV1 extends FV>(props: CP & { field: SRSF; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV>(props: CP & { fields: [SRSF]; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV, FV2 extends FV>(\n\t\tprops: CP & { fields: [SRSF, SRSF]; render: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => RN },\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF]\n\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV, FV5 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t\tfield5: FieldAccessor<FV5>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t(props: FieldViewProps): REN\n}\n"],"names":["FieldView","Component","props","fallbackIfUnpersisted","render","fields","Array","isArray","field","throwBindingError","useConstantLengthInvariant","entityAccessor","useEntity","environment","desugarField","useCallback","rsf","QueryLanguage","desugarRelativeSingleField","desugaredFields","useArrayMapMemo","retrieveField","desugaredRsf","getRelativeSingleField","accessors","output","useMemo","existsOnServer","undefined","_Fragment","map","i","_jsxDEV"],"mappings":";;;;;;;;;AAiCaA,MAAAA,YAAYC,UACxBC,CAAS,UAAA;AACF,QAAA;AAAA,IAAEC;AAAAA,IAAuBC;AAAAA,EAAWF,IAAAA;AAC1C,QAAMG,SACL,YAAYH,SAASI,MAAMC,QAAQL,MAAMG,MAAM,IAC5CH,MAAMG,SACN,WAAWH,SAASA,MAAMM,QAC1B,CAACN,MAAMM,KAAK,IACZC,kBAAmB,sEAAqE;AAE5FC,6BACCL,QACC,oGAAmG;AAIrG,QAAMM,iBAAiBC;AACvB,QAAMC,cAAcF,eAAeE;AAE7BC,QAAAA,eAAeC,YACpB,CAACC,QAAcC,cAAcC,2BAA2BF,KAAKH,WAAW,GACxE,CAACA,WAAW,CAAC;AAERM,QAAAA,kBAAkBC,gBAAgBf,QAAQS,YAAY;AAEtDO,QAAAA,gBAAgBN,YACrB,CAACO,iBAAsCX,eAAeY,uBAAuBD,YAAY,GACzF,CAACX,cAAc,CAAC;AAEXa,QAAAA,YAAYJ,gBAAgBD,iBAAiBE,aAAa;AAI1DI,QAAAA,SAASC,QAAQ,MAAM;AAC5B,QAAI,CAACf,eAAegB,kBAAkBxB,0BAA0ByB,QAAW;AACnEzB,aAAAA;AAAAA,IACR;AACOC,WAAAA,OAAO,GAAGoB,SAAS;AAAA,EAAA,GACxB,CAACA,WAAWb,eAAegB,gBAAgBxB,uBAAuBC,MAAM,CAAC;AAE5E,gCAAOyB,UAAA;AAAA,IAAA,UAAGJ;AAAAA,EAAAA,GAAU,QAAA,KAAA;AACrB,GACAvB,CAAS,UAAA;AACR,QAAMG,SACL,YAAYH,SAASI,MAAMC,QAAQL,MAAMG,MAAM,IAC5CH,MAAMG,SACN,WAAWH,SAASA,MAAMM,QAC1B,CAACN,MAAMM,KAAK,IACZC,kBAAmB,sEAAqE;AAC5F,gCACCoB,UAAA;AAAA,IAAA,UAAA,CACE3B,MAAMC,uBACNE,OAAOyB,IAAI,CAACtB,OAAOuB,MACnBC,uBAAC,cAAY;AAAA,MAAS;AAAA,IAAA,GAAHD,GAAC,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA,GAAA,MAAA,CACpB,CAAC;AAAA,EAAA,GACA,QAAA,IAAA;AAEL,GACA,WAAW;"}
1
+ {"version":3,"file":"FieldView.js","sources":["../../../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 } from '../accessors'\nimport { throwBindingError } from '../BindingError'\nimport { Component } from '../coreComponents'\nimport { QueryLanguage } from '../queryLanguage'\nimport type { FieldValue, RelativeSingleField, SugaredRelativeSingleField } from '../treeParameters'\nimport { SugaredField } from './SugaredField'\n\ninterface FieldViewCommonProps {\n\tfallbackIfUnpersisted?: ReactNode\n}\n\ntype FieldViewProps = FieldViewCommonProps &\n\t(\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfield: string | SugaredRelativeSingleField\n\t\t }\n\t\t| {\n\t\t\t\trender: (...accessors: FieldAccessor[]) => ReactNode\n\t\t\t\tfields: Array<string | SugaredRelativeSingleField>\n\t\t }\n\t)\n\n// Just short type aliases so that we can type the overloads in a tractable fashion.\ntype FV = FieldValue\ntype SRSF = string | SugaredRelativeSingleField\ntype CP = FieldViewCommonProps\ntype RN = ReactNode\ntype REN = ReactElement | null\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? [props.field]\n\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: SRSF) => 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? [props.field]\n\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 {\n\t<FV1 extends FV>(props: CP & { field: SRSF; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV>(props: CP & { fields: [SRSF]; render: (field1: FieldAccessor<FV1>) => RN }): REN\n\t<FV1 extends FV, FV2 extends FV>(\n\t\tprops: CP & { fields: [SRSF, SRSF]; render: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>) => RN },\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF]\n\t\t\trender: (field1: FieldAccessor<FV1>, field2: FieldAccessor<FV2>, field3: FieldAccessor<FV3>) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t\t\t\tfield4: FieldAccessor<FV4>,\n\t\t\t) => RN\n\t\t},\n\t): REN\n\t<FV1 extends FV, FV2 extends FV, FV3 extends FV, FV4 extends FV, FV5 extends FV>(\n\t\tprops: CP & {\n\t\t\tfields: [SRSF, SRSF, SRSF, SRSF, SRSF]\n\t\t\trender: (\n\t\t\t\tfield1: FieldAccessor<FV1>,\n\t\t\t\tfield2: FieldAccessor<FV2>,\n\t\t\t\tfield3: FieldAccessor<FV3>,\n\t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C5F,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,UAAoC,CACpC;AAAA,IAAA,KAJF,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAKA,GAAAA,UAAA;AAAA,EAEF;AAAA,EACA;AACD;"}
@@ -1,76 +1,83 @@
1
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
1
2
  import { useMemo } from "react";
2
3
  import { FilterFieldsCollector } from "./helpers/FilterFieldsCollector.js";
3
4
  import { FilterEvaluator } from "./helpers/FilterEvaluator.js";
4
- import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
5
5
  import { Field } from "../coreComponents/Field.js";
6
6
  import { Component } from "../coreComponents/Component.js";
7
7
  import { useEntity } from "../accessorPropagation/useEntity.js";
8
8
  import { QueryLanguage } from "../queryLanguage/QueryLanguage.js";
9
9
  import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
10
- var _jsxFileName = "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx";
11
- const If = Component((props) => {
12
- return typeof props.condition !== "function" ? /* @__PURE__ */ jsxDEV(IfFilter, {
13
- condition: props.condition,
14
- children: props.children
15
- }, void 0, false, {
16
- fileName: _jsxFileName,
17
- lineNumber: 27,
18
- columnNumber: 6
19
- }, void 0) : /* @__PURE__ */ jsxDEV(IfCallback, {
20
- condition: props.condition,
21
- children: props.children
22
- }, void 0, false, {
23
- fileName: _jsxFileName,
24
- lineNumber: 28,
25
- columnNumber: 6
26
- }, void 0);
27
- }, "If");
28
- const IfCallback = Component(({
29
- children,
30
- condition
31
- }) => {
32
- const entity = useEntity();
33
- const evaluated = useMemo(() => condition(entity), [condition, entity]);
34
- return evaluated ? /* @__PURE__ */ jsxDEV(Fragment, {
35
- children
36
- }, void 0, false) : null;
37
- }, ({
38
- children
39
- }) => {
40
- return /* @__PURE__ */ jsxDEV(Fragment, {
41
- children
42
- }, void 0, false);
43
- }, "IfCallback");
44
- const IfFilter = Component(({
45
- children,
46
- condition
47
- }) => {
48
- const env = useEnvironment();
49
- const entity = useEntity();
50
- const schema = env.getSchema();
51
- const evaluated = useMemo(() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)), [condition, entity, env, schema]);
52
- return evaluated ? /* @__PURE__ */ jsxDEV(Fragment, {
53
- children
54
- }, void 0, false) : null;
55
- }, ({
56
- children,
57
- condition
58
- }, env) => {
59
- const desugaredFilter = QueryLanguage.desugarFilter(condition, env);
60
- const collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity);
61
- const additionalFields = /* @__PURE__ */ jsxDEV(Fragment, {
62
- children: Array.from(collectedFields).map((it) => /* @__PURE__ */ jsxDEV(Field, {
63
- field: it
64
- }, it, false, {
65
- fileName: _jsxFileName,
10
+ const If = Component(
11
+ (props) => {
12
+ return typeof props.condition !== "function" ? /* @__PURE__ */ jsxDEV(IfFilter, { condition: props.condition, children: props.children }, void 0, false, {
13
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
14
+ lineNumber: 27,
15
+ columnNumber: 6
16
+ }, globalThis) : /* @__PURE__ */ jsxDEV(IfCallback, { condition: props.condition, children: props.children }, void 0, false, {
17
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
18
+ lineNumber: 28,
19
+ columnNumber: 6
20
+ }, globalThis);
21
+ },
22
+ "If"
23
+ );
24
+ const IfCallback = Component(
25
+ ({ children, condition }) => {
26
+ const entity = useEntity();
27
+ const evaluated = useMemo(() => condition(entity), [condition, entity]);
28
+ return evaluated ? /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
29
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
30
+ lineNumber: 38,
31
+ columnNumber: 22
32
+ }, globalThis) : null;
33
+ },
34
+ ({ children }) => {
35
+ return /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
36
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
37
+ lineNumber: 41,
38
+ columnNumber: 10
39
+ }, globalThis);
40
+ },
41
+ "IfCallback"
42
+ );
43
+ const IfFilter = Component(
44
+ ({ children, condition }) => {
45
+ const env = useEnvironment();
46
+ const entity = useEntity();
47
+ const schema = env.getSchema();
48
+ const evaluated = useMemo(
49
+ () => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),
50
+ [condition, entity, env, schema]
51
+ );
52
+ return evaluated ? /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
53
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
54
+ lineNumber: 57,
55
+ columnNumber: 22
56
+ }, globalThis) : null;
57
+ },
58
+ ({ children, condition }, env) => {
59
+ const desugaredFilter = QueryLanguage.desugarFilter(condition, env);
60
+ const collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity);
61
+ const additionalFields = /* @__PURE__ */ jsxDEV(Fragment, { children: Array.from(collectedFields).map((it) => /* @__PURE__ */ jsxDEV(Field, { field: it }, it, false, {
62
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
66
63
  lineNumber: 62,
67
64
  columnNumber: 69
68
- }, void 0))
69
- }, void 0, false);
70
- return /* @__PURE__ */ jsxDEV(Fragment, {
71
- children: [additionalFields, children]
72
- }, void 0, true);
73
- }, "IfFilter");
65
+ }, globalThis)) }, void 0, false, {
66
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
67
+ lineNumber: 62,
68
+ columnNumber: 28
69
+ }, globalThis);
70
+ return /* @__PURE__ */ jsxDEV(Fragment, { children: [
71
+ additionalFields,
72
+ children
73
+ ] }, void 0, true, {
74
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/If.tsx",
75
+ lineNumber: 64,
76
+ columnNumber: 10
77
+ }, globalThis);
78
+ },
79
+ "IfFilter"
80
+ );
74
81
  export {
75
82
  If
76
83
  };
@@ -1 +1 @@
1
- {"version":3,"file":"If.js","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '../accessors'\nimport { QueryLanguage } from '../queryLanguage'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '../treeParameters'\nimport { FilterFieldsCollector } from './helpers/FilterFieldsCollector'\nimport { FilterEvaluator } from './helpers/FilterEvaluator'\n\nexport type IfProps =\n\t| IfFilterProps\n\t| IfCallbackProps\n\nexport interface IfFilterProps {\n\tcondition: string | Filter\n\tchildren?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n}\n\nexport const If = Component<IfProps>(props => {\n\t\treturn typeof props.condition !== 'function'\n\t\t\t? <IfFilter condition={props.condition}>{props.children}</IfFilter>\n\t\t\t: <IfCallback condition={props.condition}>{props.children}</IfCallback>\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition }) => {\n\t\tconst env = useEnvironment()\n\t\tconst entity = useEntity()\n\n\t\tconst schema = env.getSchema()\n\t\tconst evaluated = useMemo(\n\t\t\t() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),\n\t\t\t[condition, entity, env, schema],\n\t\t)\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children, condition }, env) => {\n\t\tconst desugaredFilter = QueryLanguage.desugarFilter(condition, env)\n\t\tconst collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity)\n\t\tconst additionalFields = <>{Array.from(collectedFields).map(it => <Field field={it} key={it} />)}</>\n\n\t\treturn <>\n\t\t\t{additionalFields}\n\t\t\t{children}\n\t\t</>\n\t},\n\t'IfFilter',\n)\n\n"],"names":["If","Component","props","condition","children","_jsxDEV","IfCallback","entity","useEntity","evaluated","useMemo","_Fragment","IfFilter","env","useEnvironment","schema","getSchema","FilterEvaluator","evaluateFilter","QueryLanguage","desugarFilter","desugaredFilter","collectedFields","FilterFieldsCollector","collectFields","getSubTreeNode","additionalFields","Array","from","map","it"],"mappings":";;;;;;;;;;AAwBaA,MAAAA,KAAKC,UAAmBC,CAAS,UAAA;AAC5C,SAAO,OAAOA,MAAMC,cAAc,oCAC9B,UAAQ;AAAA,IAAC,WAAWD,MAAMC;AAAAA,IAAU,UAAED,MAAME;AAAAA,EAAAA,GAAQ,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAY,GAAA,MAAA,IACjEC,uBAAC,YAAU;AAAA,IAAC,WAAWH,MAAMC;AAAAA,IAAU,UAAED,MAAME;AAAAA,EAAAA,GAAQ,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAc,MAAA;AACzE,GACA,IAAI;AAGL,MAAME,aAAaL,UAClB,CAAC;AAAA,EAAEG;AAAAA,EAAUD;AAAU,MAAM;AAC5B,QAAMI,SAASC;AACTC,QAAAA,YAAYC,QAAQ,MAAMP,UAAUI,MAAM,GAAG,CAACJ,WAAWI,MAAM,CAAC;AAE/DE,SAAAA,mCAAYE,UAAA;AAAA,IAAA;AAAA,EAAW,GAAA,QAAA,KAAA,IAAO;AACtC,GACA,CAAC;AAAA,EAAEP;AAAS,MAAM;AACjB,gCAAOO,UAAA;AAAA,IAAA;AAAA,EAAA,GAAe,QAAA,KAAA;AACvB,GACA,YAAY;AAGb,MAAMC,WAAWX,UAChB,CAAC;AAAA,EAAEG;AAAAA,EAAUD;AAAU,MAAM;AAC5B,QAAMU,MAAMC;AACZ,QAAMP,SAASC;AAETO,QAAAA,SAASF,IAAIG;AACbP,QAAAA,YAAYC,QACjB,MAAM,IAAIO,gBAAgBF,MAAM,EAAEG,eAAeX,QAAQY,cAAcC,cAAcjB,WAAWU,GAAG,CAAC,GACpG,CAACV,WAAWI,QAAQM,KAAKE,MAAM,CAAC;AAG1BN,SAAAA,mCAAYE,UAAA;AAAA,IAAA;AAAA,EAAW,GAAA,QAAA,KAAA,IAAO;AACtC,GACA,CAAC;AAAA,EAAEP;AAAAA,EAAUD;AAAU,GAAGU,QAAQ;AACjC,QAAMQ,kBAAkBF,cAAcC,cAAcjB,WAAWU,GAAG;AAClE,QAAMS,kBAAkB,IAAIC,sBAAsBV,IAAIG,UAAW,GAAEK,eAAe,EAAEG,cAAcX,IAAIY,eAAc,EAAGlB,MAAM;AACvHmB,QAAAA,0CAAmBf,UAAA;AAAA,IAAA,UAAGgB,MAAMC,KAAKN,eAAe,EAAEO,IAAIC,CAAAA,8BAAO,OAAK;AAAA,MAAC,OAAOA;AAAAA,IAAAA,GAASA,IAAE,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA,GAAI,MAAA,CAAA;AAAA,EAAA,GAAK,QAAA,KAAA;AAEpG,gCAAOnB,UAAA;AAAA,IAAA,UACLe,CAAAA,kBACAtB,QAAQ;AAAA,EAAA,GACP,QAAA,IAAA;AACJ,GACA,UAAU;"}
1
+ {"version":3,"file":"If.js","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '../accessors'\nimport { QueryLanguage } from '../queryLanguage'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '../treeParameters'\nimport { FilterFieldsCollector } from './helpers/FilterFieldsCollector'\nimport { FilterEvaluator } from './helpers/FilterEvaluator'\n\nexport type IfProps =\n\t| IfFilterProps\n\t| IfCallbackProps\n\nexport interface IfFilterProps {\n\tcondition: string | Filter\n\tchildren?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n}\n\nexport const If = Component<IfProps>(props => {\n\t\treturn typeof props.condition !== 'function'\n\t\t\t? <IfFilter condition={props.condition}>{props.children}</IfFilter>\n\t\t\t: <IfCallback condition={props.condition}>{props.children}</IfCallback>\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition }) => {\n\t\tconst env = useEnvironment()\n\t\tconst entity = useEntity()\n\n\t\tconst schema = env.getSchema()\n\t\tconst evaluated = useMemo(\n\t\t\t() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),\n\t\t\t[condition, entity, env, schema],\n\t\t)\n\n\t\treturn evaluated ? <>{children}</> : null\n\t},\n\t({ children, condition }, env) => {\n\t\tconst desugaredFilter = QueryLanguage.desugarFilter(condition, env)\n\t\tconst collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity)\n\t\tconst additionalFields = <>{Array.from(collectedFields).map(it => <Field field={it} key={it} />)}</>\n\n\t\treturn <>\n\t\t\t{additionalFields}\n\t\t\t{children}\n\t\t</>\n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AAH,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA,GAAAA,UAAY,IAAM;AAAA,EACtC;AAAA,EACA,CAAC,EAAE,UAAU,aAAa,QAAQ;AACjC,UAAM,kBAAkB,cAAc,cAAc,WAAW,GAAG;AAClE,UAAM,kBAAkB,IAAI,sBAAsB,IAAI,UAAU,GAAG,eAAe,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM;AAC7H,UAAM,mBAAmB,uBAAA,UAAA,EAAG,UAAM,MAAA,KAAK,eAAe,EAAE,IAAI,CAAA,OAAO,uBAAA,OAAA,EAAM,OAAO,GAAA,GAAS,IAAvB,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA,GAAAA,UAA2B,CAAE,EAAtE,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAwE,GAAAA,UAAA;AAEjG,WACE,uBAAA,UAAA,EAAA,UAAA;AAAA,MAAA;AAAA,MACA;AAAA,IAAA,KAFK,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAGP,GAAAA,UAAA;AAAA,EACD;AAAA,EACA;AACD;"}
@@ -1,10 +1,14 @@
1
1
  import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
2
2
  import { Component } from "../coreComponents/Component.js";
3
- const StaticRender = Component(() => null, ({
4
- children
5
- }) => /* @__PURE__ */ jsxDEV(Fragment, {
6
- children
7
- }, void 0, false), "StaticRender");
3
+ const StaticRender = Component(
4
+ () => null,
5
+ ({ children }) => /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
6
+ fileName: "/__w/interface/interface/packages/binding/src/helperComponents/StaticRender.tsx",
7
+ lineNumber: 10,
8
+ columnNumber: 20
9
+ }, globalThis),
10
+ "StaticRender"
11
+ );
8
12
  export {
9
13
  StaticRender
10
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"StaticRender.js","sources":["../../../src/helperComponents/StaticRender.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { Component } from '../coreComponents'\n\nexport interface StaticRenderProps {\n\tchildren?: ReactNode\n}\n\nexport const StaticRender = Component<StaticRenderProps>(\n\t() => null,\n\t({ children }) => <>{children}</>,\n\t'StaticRender',\n)\n"],"names":["StaticRender","Component","children","_Fragment"],"mappings":";;AAOO,MAAMA,eAAeC,UAC3B,MAAM,MACN,CAAC;AAAA,EAAEC;AAAS,6BAAMC,UAAA;AAAA,EAAA;AAAW,GAAI,QAAA,KAAA,GACjC,cAAc;"}
1
+ {"version":3,"file":"StaticRender.js","sources":["../../../src/helperComponents/StaticRender.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { Component } from '../coreComponents'\n\nexport interface StaticRenderProps {\n\tchildren?: ReactNode\n}\n\nexport const StaticRender = Component<StaticRenderProps>(\n\t() => null,\n\t({ children }) => <>{children}</>,\n\t'StaticRender',\n)\n"],"names":["this"],"mappings":";;AAOO,MAAM,eAAe;AAAA,EAC3B,MAAM;AAAA,EACN,CAAC,EAAE,SAAS,yCAAS,SAAH,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAY,GAAAA,UAAA;AAAA,EAC9B;AACD;"}