@contember/react-binding 1.3.0-alpha.8 → 2.0.0-alpha.1

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 (86) hide show
  1. package/dist/development/accessorPropagation/useEntityListSubTreeLoader.cjs +47 -0
  2. package/dist/development/accessorPropagation/useEntityListSubTreeLoader.cjs.map +1 -0
  3. package/dist/development/accessorPropagation/useEntityListSubTreeLoader.js +47 -0
  4. package/dist/development/accessorPropagation/useEntityListSubTreeLoader.js.map +1 -0
  5. package/dist/development/accessorSorting/sortEntities.cjs +1 -4
  6. package/dist/development/accessorSorting/sortEntities.cjs.map +1 -1
  7. package/dist/development/accessorSorting/sortEntities.js +1 -4
  8. package/dist/development/accessorSorting/sortEntities.js.map +1 -1
  9. package/dist/development/helperComponents/DimensionRenderer.cjs +29 -0
  10. package/dist/development/helperComponents/DimensionRenderer.cjs.map +1 -0
  11. package/dist/development/helperComponents/DimensionRenderer.js +29 -0
  12. package/dist/development/helperComponents/DimensionRenderer.js.map +1 -0
  13. package/dist/development/helperComponents/If.cjs +22 -19
  14. package/dist/development/helperComponents/If.cjs.map +1 -1
  15. package/dist/development/helperComponents/If.js +22 -19
  16. package/dist/development/helperComponents/If.js.map +1 -1
  17. package/dist/development/helperComponents/Variable.cjs +18 -0
  18. package/dist/development/helperComponents/Variable.cjs.map +1 -0
  19. package/dist/development/helperComponents/Variable.js +18 -0
  20. package/dist/development/helperComponents/Variable.js.map +1 -0
  21. package/dist/development/index.cjs +6 -0
  22. package/dist/development/index.cjs.map +1 -1
  23. package/dist/development/index.js +6 -0
  24. package/dist/development/index.js.map +1 -1
  25. package/dist/production/accessorPropagation/useEntityListSubTreeLoader.cjs +47 -0
  26. package/dist/production/accessorPropagation/useEntityListSubTreeLoader.cjs.map +1 -0
  27. package/dist/production/accessorPropagation/useEntityListSubTreeLoader.js +47 -0
  28. package/dist/production/accessorPropagation/useEntityListSubTreeLoader.js.map +1 -0
  29. package/dist/production/accessorSorting/sortEntities.cjs +1 -4
  30. package/dist/production/accessorSorting/sortEntities.cjs.map +1 -1
  31. package/dist/production/accessorSorting/sortEntities.js +1 -4
  32. package/dist/production/accessorSorting/sortEntities.js.map +1 -1
  33. package/dist/production/helperComponents/DimensionRenderer.cjs +18 -0
  34. package/dist/production/helperComponents/DimensionRenderer.cjs.map +1 -0
  35. package/dist/production/helperComponents/DimensionRenderer.js +18 -0
  36. package/dist/production/helperComponents/DimensionRenderer.js.map +1 -0
  37. package/dist/production/helperComponents/If.cjs +9 -6
  38. package/dist/production/helperComponents/If.cjs.map +1 -1
  39. package/dist/production/helperComponents/If.js +9 -6
  40. package/dist/production/helperComponents/If.js.map +1 -1
  41. package/dist/production/helperComponents/Variable.cjs +14 -0
  42. package/dist/production/helperComponents/Variable.cjs.map +1 -0
  43. package/dist/production/helperComponents/Variable.js +14 -0
  44. package/dist/production/helperComponents/Variable.js.map +1 -0
  45. package/dist/production/index.cjs +6 -0
  46. package/dist/production/index.cjs.map +1 -1
  47. package/dist/production/index.js +6 -0
  48. package/dist/production/index.js.map +1 -1
  49. package/dist/types/accessorPropagation/EnvironmentContext.d.ts +1 -1
  50. package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
  51. package/dist/types/accessorPropagation/index.d.ts +1 -0
  52. package/dist/types/accessorPropagation/index.d.ts.map +1 -1
  53. package/dist/types/accessorPropagation/useEntityListSubTreeLoader.d.ts +10 -0
  54. package/dist/types/accessorPropagation/useEntityListSubTreeLoader.d.ts.map +1 -0
  55. package/dist/types/accessorPropagation/useGetEntityListSubTree.d.ts +2 -2
  56. package/dist/types/accessorPropagation/useGetEntityListSubTree.d.ts.map +1 -1
  57. package/dist/types/accessorPropagation/useGetEntitySubTree.d.ts +2 -2
  58. package/dist/types/accessorPropagation/useGetEntitySubTree.d.ts.map +1 -1
  59. package/dist/types/accessorSorting/sortEntities.d.ts.map +1 -1
  60. package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
  61. package/dist/types/coreComponents/EntityList.d.ts.map +1 -1
  62. package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
  63. package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
  64. package/dist/types/coreComponents/Field.d.ts.map +1 -1
  65. package/dist/types/coreComponents/HasMany.d.ts.map +1 -1
  66. package/dist/types/coreComponents/HasOne.d.ts.map +1 -1
  67. package/dist/types/entityEvents/useDerivedField.d.ts.map +1 -1
  68. package/dist/types/helperComponents/DimensionRenderer.d.ts +9 -0
  69. package/dist/types/helperComponents/DimensionRenderer.d.ts.map +1 -0
  70. package/dist/types/helperComponents/If.d.ts +4 -0
  71. package/dist/types/helperComponents/If.d.ts.map +1 -1
  72. package/dist/types/helperComponents/LabelMiddleware.d.ts.map +1 -1
  73. package/dist/types/helperComponents/SugaredField.d.ts.map +1 -1
  74. package/dist/types/helperComponents/Variable.d.ts +8 -0
  75. package/dist/types/helperComponents/Variable.d.ts.map +1 -0
  76. package/dist/types/helperComponents/index.d.ts +2 -0
  77. package/dist/types/helperComponents/index.d.ts.map +1 -1
  78. package/dist/types/tsconfig.tsbuildinfo +1 -1
  79. package/package.json +11 -11
  80. package/src/accessorPropagation/index.ts +1 -0
  81. package/src/accessorPropagation/useEntityListSubTreeLoader.ts +69 -0
  82. package/src/accessorSorting/sortEntities.ts +1 -4
  83. package/src/helperComponents/DimensionRenderer.tsx +25 -0
  84. package/src/helperComponents/If.tsx +15 -10
  85. package/src/helperComponents/Variable.tsx +18 -0
  86. package/src/helperComponents/index.ts +2 -0
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ const useExtendTree = require("./useExtendTree.cjs");
5
+ const EntityListSubTree = require("../coreComponents/EntityListSubTree.cjs");
6
+ const useEntityListSubTreeLoader = (entities, children, state) => {
7
+ const [displayedState, setDisplayedState] = react.useState({
8
+ entities: void 0,
9
+ treeRootId: void 0,
10
+ state: void 0
11
+ });
12
+ const currentlyLoading = react.useRef();
13
+ const [loadingState, setLoadingState] = react.useState("initial");
14
+ const extendTree = useExtendTree.useExtendTree();
15
+ react.useEffect(() => {
16
+ (async () => {
17
+ if (!entities || displayedState.state === state && displayedState.entities === entities || currentlyLoading.current?.entities === entities && currentlyLoading.current?.state === state) {
18
+ return;
19
+ }
20
+ currentlyLoading.current = {
21
+ entities,
22
+ state
23
+ };
24
+ if (displayedState.entities) {
25
+ setLoadingState("refreshing");
26
+ }
27
+ const newTreeRootId = await extendTree(
28
+ react.createElement(EntityListSubTree.EntityListSubTree, {
29
+ ...entities,
30
+ children
31
+ })
32
+ );
33
+ currentlyLoading.current = void 0;
34
+ if (newTreeRootId) {
35
+ setDisplayedState({
36
+ entities,
37
+ treeRootId: newTreeRootId,
38
+ state
39
+ });
40
+ setLoadingState("loaded");
41
+ }
42
+ })();
43
+ }, [displayedState, extendTree, entities, children, state]);
44
+ return [displayedState, loadingState];
45
+ };
46
+ exports.useEntityListSubTreeLoader = useEntityListSubTreeLoader;
47
+ //# sourceMappingURL=useEntityListSubTreeLoader.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityListSubTreeLoader.cjs","sources":["../../../src/accessorPropagation/useEntityListSubTreeLoader.ts"],"sourcesContent":["import { createElement, ReactNode, useEffect, useRef, useState } from 'react'\nimport { SugaredQualifiedEntityList, TreeRootId } from '@contember/binding'\nimport { useExtendTree } from './useExtendTree'\nimport { EntityListSubTree } from '../coreComponents'\n\nexport type UseEntityListSubTreeLoaderResult<State> = {\n\tentities: SugaredQualifiedEntityList | undefined\n\ttreeRootId: TreeRootId | undefined\n\tstate: State | undefined\n}\n\nexport type EntityListSubTreeLoaderState =\n\t| 'initial'\n\t| 'refreshing'\n\t| 'loaded'\n\nexport const useEntityListSubTreeLoader = <State>(entities: SugaredQualifiedEntityList | undefined, children: ReactNode, state?: State): [UseEntityListSubTreeLoaderResult<State>, EntityListSubTreeLoaderState] => {\n\tconst [displayedState, setDisplayedState] = useState<UseEntityListSubTreeLoaderResult<State>>({\n\t\tentities: undefined,\n\t\ttreeRootId: undefined,\n\t\tstate: undefined,\n\t})\n\tconst currentlyLoading = useRef<{\n\t\tentities: SugaredQualifiedEntityList\n\t\tstate?: State\n\t}>()\n\n\tconst [loadingState, setLoadingState] = useState<EntityListSubTreeLoaderState>('initial')\n\tconst extendTree = useExtendTree()\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tif (\n\t\t\t\t!entities\n\t\t\t\t|| displayedState.state === state && displayedState.entities === entities\n\t\t\t\t|| currentlyLoading.current?.entities === entities && currentlyLoading.current?.state === state\n\t\t\t) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tcurrentlyLoading.current = {\n\t\t\t\tentities,\n\t\t\t\tstate,\n\t\t\t}\n\n\t\t\tif (displayedState.entities) {\n\t\t\t\tsetLoadingState('refreshing')\n\t\t\t}\n\n\t\t\tconst newTreeRootId = await extendTree(\n\t\t\t\tcreateElement(EntityListSubTree, {\n\t\t\t\t\t...entities,\n\t\t\t\t\tchildren,\n\t\t\t\t}),\n\t\t\t)\n\t\t\tcurrentlyLoading.current = undefined\n\t\t\tif (newTreeRootId) {\n\t\t\t\tsetDisplayedState({\n\t\t\t\t\tentities: entities,\n\t\t\t\t\ttreeRootId: newTreeRootId,\n\t\t\t\t\tstate: state,\n\t\t\t\t})\n\t\t\t\tsetLoadingState('loaded')\n\t\t\t}\n\t\t})()\n\t}, [displayedState, extendTree, entities, children, state])\n\n\treturn [displayedState, loadingState]\n}\n"],"names":["useState","useRef","useExtendTree","useEffect","createElement","EntityListSubTree"],"mappings":";;;;;AAgBO,MAAM,6BAA6B,CAAQ,UAAkD,UAAqB,UAA2F;AACnN,QAAM,CAAC,gBAAgB,iBAAiB,IAAIA,eAAkD;AAAA,IAC7F,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,OAAO;AAAA,EAAA,CACP;AACD,QAAM,mBAAmBC,MAAAA;AAKzB,QAAM,CAAC,cAAc,eAAe,IAAID,eAAuC,SAAS;AACxF,QAAM,aAAaE,cAAAA;AAEnBC,QAAAA,UAAU,MAAM;AACf,KAAC,YAAY;AACZ,UACC,CAAC,YACE,eAAe,UAAU,SAAS,eAAe,aAAa,YAC9D,iBAAiB,SAAS,aAAa,YAAY,iBAAiB,SAAS,UAAU,OACzF;AACD;AAAA,MACD;AAEA,uBAAiB,UAAU;AAAA,QAC1B;AAAA,QACA;AAAA,MAAA;AAGD,UAAI,eAAe,UAAU;AAC5B,wBAAgB,YAAY;AAAA,MAC7B;AAEA,YAAM,gBAAgB,MAAM;AAAA,QAC3BC,MAAAA,cAAcC,kBAAAA,mBAAmB;AAAA,UAChC,GAAG;AAAA,UACH;AAAA,QAAA,CACA;AAAA,MAAA;AAEF,uBAAiB,UAAU;AAC3B,UAAI,eAAe;AACA,0BAAA;AAAA,UACjB;AAAA,UACA,YAAY;AAAA,UACZ;AAAA,QAAA,CACA;AACD,wBAAgB,QAAQ;AAAA,MACzB;AAAA,IAAA;EACE,GACD,CAAC,gBAAgB,YAAY,UAAU,UAAU,KAAK,CAAC;AAEnD,SAAA,CAAC,gBAAgB,YAAY;AACrC;;"}
@@ -0,0 +1,47 @@
1
+ import { useState, useRef, useEffect, createElement } from "react";
2
+ import { useExtendTree } from "./useExtendTree.js";
3
+ import { EntityListSubTree } from "../coreComponents/EntityListSubTree.js";
4
+ const useEntityListSubTreeLoader = (entities, children, state) => {
5
+ const [displayedState, setDisplayedState] = useState({
6
+ entities: void 0,
7
+ treeRootId: void 0,
8
+ state: void 0
9
+ });
10
+ const currentlyLoading = useRef();
11
+ const [loadingState, setLoadingState] = useState("initial");
12
+ const extendTree = useExtendTree();
13
+ useEffect(() => {
14
+ (async () => {
15
+ if (!entities || displayedState.state === state && displayedState.entities === entities || currentlyLoading.current?.entities === entities && currentlyLoading.current?.state === state) {
16
+ return;
17
+ }
18
+ currentlyLoading.current = {
19
+ entities,
20
+ state
21
+ };
22
+ if (displayedState.entities) {
23
+ setLoadingState("refreshing");
24
+ }
25
+ const newTreeRootId = await extendTree(
26
+ createElement(EntityListSubTree, {
27
+ ...entities,
28
+ children
29
+ })
30
+ );
31
+ currentlyLoading.current = void 0;
32
+ if (newTreeRootId) {
33
+ setDisplayedState({
34
+ entities,
35
+ treeRootId: newTreeRootId,
36
+ state
37
+ });
38
+ setLoadingState("loaded");
39
+ }
40
+ })();
41
+ }, [displayedState, extendTree, entities, children, state]);
42
+ return [displayedState, loadingState];
43
+ };
44
+ export {
45
+ useEntityListSubTreeLoader
46
+ };
47
+ //# sourceMappingURL=useEntityListSubTreeLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEntityListSubTreeLoader.js","sources":["../../../src/accessorPropagation/useEntityListSubTreeLoader.ts"],"sourcesContent":["import { createElement, ReactNode, useEffect, useRef, useState } from 'react'\nimport { SugaredQualifiedEntityList, TreeRootId } from '@contember/binding'\nimport { useExtendTree } from './useExtendTree'\nimport { EntityListSubTree } from '../coreComponents'\n\nexport type UseEntityListSubTreeLoaderResult<State> = {\n\tentities: SugaredQualifiedEntityList | undefined\n\ttreeRootId: TreeRootId | undefined\n\tstate: State | undefined\n}\n\nexport type EntityListSubTreeLoaderState =\n\t| 'initial'\n\t| 'refreshing'\n\t| 'loaded'\n\nexport const useEntityListSubTreeLoader = <State>(entities: SugaredQualifiedEntityList | undefined, children: ReactNode, state?: State): [UseEntityListSubTreeLoaderResult<State>, EntityListSubTreeLoaderState] => {\n\tconst [displayedState, setDisplayedState] = useState<UseEntityListSubTreeLoaderResult<State>>({\n\t\tentities: undefined,\n\t\ttreeRootId: undefined,\n\t\tstate: undefined,\n\t})\n\tconst currentlyLoading = useRef<{\n\t\tentities: SugaredQualifiedEntityList\n\t\tstate?: State\n\t}>()\n\n\tconst [loadingState, setLoadingState] = useState<EntityListSubTreeLoaderState>('initial')\n\tconst extendTree = useExtendTree()\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tif (\n\t\t\t\t!entities\n\t\t\t\t|| displayedState.state === state && displayedState.entities === entities\n\t\t\t\t|| currentlyLoading.current?.entities === entities && currentlyLoading.current?.state === state\n\t\t\t) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tcurrentlyLoading.current = {\n\t\t\t\tentities,\n\t\t\t\tstate,\n\t\t\t}\n\n\t\t\tif (displayedState.entities) {\n\t\t\t\tsetLoadingState('refreshing')\n\t\t\t}\n\n\t\t\tconst newTreeRootId = await extendTree(\n\t\t\t\tcreateElement(EntityListSubTree, {\n\t\t\t\t\t...entities,\n\t\t\t\t\tchildren,\n\t\t\t\t}),\n\t\t\t)\n\t\t\tcurrentlyLoading.current = undefined\n\t\t\tif (newTreeRootId) {\n\t\t\t\tsetDisplayedState({\n\t\t\t\t\tentities: entities,\n\t\t\t\t\ttreeRootId: newTreeRootId,\n\t\t\t\t\tstate: state,\n\t\t\t\t})\n\t\t\t\tsetLoadingState('loaded')\n\t\t\t}\n\t\t})()\n\t}, [displayedState, extendTree, entities, children, state])\n\n\treturn [displayedState, loadingState]\n}\n"],"names":[],"mappings":";;;AAgBO,MAAM,6BAA6B,CAAQ,UAAkD,UAAqB,UAA2F;AACnN,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAkD;AAAA,IAC7F,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,OAAO;AAAA,EAAA,CACP;AACD,QAAM,mBAAmB;AAKzB,QAAM,CAAC,cAAc,eAAe,IAAI,SAAuC,SAAS;AACxF,QAAM,aAAa;AAEnB,YAAU,MAAM;AACf,KAAC,YAAY;AACZ,UACC,CAAC,YACE,eAAe,UAAU,SAAS,eAAe,aAAa,YAC9D,iBAAiB,SAAS,aAAa,YAAY,iBAAiB,SAAS,UAAU,OACzF;AACD;AAAA,MACD;AAEA,uBAAiB,UAAU;AAAA,QAC1B;AAAA,QACA;AAAA,MAAA;AAGD,UAAI,eAAe,UAAU;AAC5B,wBAAgB,YAAY;AAAA,MAC7B;AAEA,YAAM,gBAAgB,MAAM;AAAA,QAC3B,cAAc,mBAAmB;AAAA,UAChC,GAAG;AAAA,UACH;AAAA,QAAA,CACA;AAAA,MAAA;AAEF,uBAAiB,UAAU;AAC3B,UAAI,eAAe;AACA,0BAAA;AAAA,UACjB;AAAA,UACA,YAAY;AAAA,UACZ;AAAA,QAAA,CACA;AACD,wBAAgB,QAAQ;AAAA,MACzB;AAAA,IAAA;EACE,GACD,CAAC,gBAAgB,YAAY,UAAU,UAAU,KAAK,CAAC;AAEnD,SAAA,CAAC,gBAAgB,YAAY;AACrC;"}
@@ -7,10 +7,7 @@ const sortEntities = (entities, sortByField) => {
7
7
  return entities.sort((a, b) => {
8
8
  const aField = a.getRelativeSingleField(sortByField);
9
9
  const bField = b.getRelativeSingleField(sortByField);
10
- if (typeof aField.value === "number" && typeof bField.value === "number") {
11
- return aField.value - bField.value;
12
- }
13
- return 0;
10
+ return (aField.value ?? Number.MAX_SAFE_INTEGER) - (bField.value ?? Number.MAX_SAFE_INTEGER);
14
11
  });
15
12
  };
16
13
  exports.sortEntities = sortEntities;
@@ -1 +1 @@
1
- {"version":3,"file":"sortEntities.cjs","sources":["../../../src/accessorSorting/sortEntities.ts"],"sourcesContent":["import { EntityAccessor, RelativeSingleField } from '@contember/binding'\n\nexport const sortEntities = (\n\tentities: EntityAccessor[],\n\tsortByField: RelativeSingleField | undefined,\n): EntityAccessor[] => {\n\tif (!sortByField) {\n\t\treturn entities\n\t}\n\treturn entities.sort((a, b) => {\n\t\tconst aField = a.getRelativeSingleField<number>(sortByField)\n\t\tconst bField = b.getRelativeSingleField<number>(sortByField)\n\n\t\tif (typeof aField.value === 'number' && typeof bField.value === 'number') {\n\t\t\treturn aField.value - bField.value\n\t\t}\n\t\treturn 0\n\t})\n}\n"],"names":[],"mappings":";;AAEa,MAAA,eAAe,CAC3B,UACA,gBACsB;AACtB,MAAI,CAAC,aAAa;AACV,WAAA;AAAA,EACR;AACA,SAAO,SAAS,KAAK,CAAC,GAAG,MAAM;AACxB,UAAA,SAAS,EAAE,uBAA+B,WAAW;AACrD,UAAA,SAAS,EAAE,uBAA+B,WAAW;AAE3D,QAAI,OAAO,OAAO,UAAU,YAAY,OAAO,OAAO,UAAU,UAAU;AAClE,aAAA,OAAO,QAAQ,OAAO;AAAA,IAC9B;AACO,WAAA;AAAA,EAAA,CACP;AACF;;"}
1
+ {"version":3,"file":"sortEntities.cjs","sources":["../../../src/accessorSorting/sortEntities.ts"],"sourcesContent":["import { EntityAccessor, RelativeSingleField } from '@contember/binding'\n\nexport const sortEntities = (\n\tentities: EntityAccessor[],\n\tsortByField: RelativeSingleField | undefined,\n): EntityAccessor[] => {\n\tif (!sortByField) {\n\t\treturn entities\n\t}\n\treturn entities.sort((a, b) => {\n\t\tconst aField = a.getRelativeSingleField<number>(sortByField)\n\t\tconst bField = b.getRelativeSingleField<number>(sortByField)\n\n\t\treturn (aField.value ?? Number.MAX_SAFE_INTEGER) - (bField.value ?? Number.MAX_SAFE_INTEGER)\n\t})\n}\n"],"names":[],"mappings":";;AAEa,MAAA,eAAe,CAC3B,UACA,gBACsB;AACtB,MAAI,CAAC,aAAa;AACV,WAAA;AAAA,EACR;AACA,SAAO,SAAS,KAAK,CAAC,GAAG,MAAM;AACxB,UAAA,SAAS,EAAE,uBAA+B,WAAW;AACrD,UAAA,SAAS,EAAE,uBAA+B,WAAW;AAE3D,YAAQ,OAAO,SAAS,OAAO,qBAAqB,OAAO,SAAS,OAAO;AAAA,EAAA,CAC3E;AACF;;"}
@@ -5,10 +5,7 @@ const sortEntities = (entities, sortByField) => {
5
5
  return entities.sort((a, b) => {
6
6
  const aField = a.getRelativeSingleField(sortByField);
7
7
  const bField = b.getRelativeSingleField(sortByField);
8
- if (typeof aField.value === "number" && typeof bField.value === "number") {
9
- return aField.value - bField.value;
10
- }
11
- return 0;
8
+ return (aField.value ?? Number.MAX_SAFE_INTEGER) - (bField.value ?? Number.MAX_SAFE_INTEGER);
12
9
  });
13
10
  };
14
11
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"sortEntities.js","sources":["../../../src/accessorSorting/sortEntities.ts"],"sourcesContent":["import { EntityAccessor, RelativeSingleField } from '@contember/binding'\n\nexport const sortEntities = (\n\tentities: EntityAccessor[],\n\tsortByField: RelativeSingleField | undefined,\n): EntityAccessor[] => {\n\tif (!sortByField) {\n\t\treturn entities\n\t}\n\treturn entities.sort((a, b) => {\n\t\tconst aField = a.getRelativeSingleField<number>(sortByField)\n\t\tconst bField = b.getRelativeSingleField<number>(sortByField)\n\n\t\tif (typeof aField.value === 'number' && typeof bField.value === 'number') {\n\t\t\treturn aField.value - bField.value\n\t\t}\n\t\treturn 0\n\t})\n}\n"],"names":[],"mappings":"AAEa,MAAA,eAAe,CAC3B,UACA,gBACsB;AACtB,MAAI,CAAC,aAAa;AACV,WAAA;AAAA,EACR;AACA,SAAO,SAAS,KAAK,CAAC,GAAG,MAAM;AACxB,UAAA,SAAS,EAAE,uBAA+B,WAAW;AACrD,UAAA,SAAS,EAAE,uBAA+B,WAAW;AAE3D,QAAI,OAAO,OAAO,UAAU,YAAY,OAAO,OAAO,UAAU,UAAU;AAClE,aAAA,OAAO,QAAQ,OAAO;AAAA,IAC9B;AACO,WAAA;AAAA,EAAA,CACP;AACF;"}
1
+ {"version":3,"file":"sortEntities.js","sources":["../../../src/accessorSorting/sortEntities.ts"],"sourcesContent":["import { EntityAccessor, RelativeSingleField } from '@contember/binding'\n\nexport const sortEntities = (\n\tentities: EntityAccessor[],\n\tsortByField: RelativeSingleField | undefined,\n): EntityAccessor[] => {\n\tif (!sortByField) {\n\t\treturn entities\n\t}\n\treturn entities.sort((a, b) => {\n\t\tconst aField = a.getRelativeSingleField<number>(sortByField)\n\t\tconst bField = b.getRelativeSingleField<number>(sortByField)\n\n\t\treturn (aField.value ?? Number.MAX_SAFE_INTEGER) - (bField.value ?? Number.MAX_SAFE_INTEGER)\n\t})\n}\n"],"names":[],"mappings":"AAEa,MAAA,eAAe,CAC3B,UACA,gBACsB;AACtB,MAAI,CAAC,aAAa;AACV,WAAA;AAAA,EACR;AACA,SAAO,SAAS,KAAK,CAAC,GAAG,MAAM;AACxB,UAAA,SAAS,EAAE,uBAA+B,WAAW;AACrD,UAAA,SAAS,EAAE,uBAA+B,WAAW;AAE3D,YAAQ,OAAO,SAAS,OAAO,qBAAqB,OAAO,SAAS,OAAO;AAAA,EAAA,CAC3E;AACF;"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxDevRuntime = require("react/jsx-dev-runtime");
4
+ const EnvironmentContext = require("../accessorPropagation/EnvironmentContext.cjs");
5
+ const Component = require("../coreComponents/Component.cjs");
6
+ const DimensionRenderer = Component.Component(({ dimension, as, children }, env) => {
7
+ const dimensions = env.getDimensionOrElse(dimension, []);
8
+ return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: dimensions.map((value) => /* @__PURE__ */ jsxDevRuntime.jsxDEV(
9
+ EnvironmentContext.EnvironmentMiddleware,
10
+ {
11
+ create: (it) => it.withVariables({ [as]: value }),
12
+ children
13
+ },
14
+ value,
15
+ false,
16
+ {
17
+ fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/DimensionRenderer.tsx",
18
+ lineNumber: 17,
19
+ columnNumber: 4
20
+ },
21
+ void 0
22
+ )) }, void 0, false, {
23
+ fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/DimensionRenderer.tsx",
24
+ lineNumber: 15,
25
+ columnNumber: 9
26
+ }, void 0);
27
+ });
28
+ exports.DimensionRenderer = DimensionRenderer;
29
+ //# sourceMappingURL=DimensionRenderer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DimensionRenderer.cjs","sources":["../../../src/helperComponents/DimensionRenderer.tsx"],"sourcesContent":["import * as React from 'react'\nimport { ReactNode } from 'react'\nimport { EnvironmentMiddleware } from '../accessorPropagation'\nimport { Component } from '../coreComponents'\n\nexport type DimensionRendererProps = {\n\tdimension: string\n\tas: string\n\tchildren: ReactNode\n}\n\nexport const DimensionRenderer = Component<DimensionRendererProps>(({ dimension, as, children }, env) => {\n\tconst dimensions = env.getDimensionOrElse(dimension, [])\n\n\treturn <>\n\t\t{dimensions.map(value => (\n\t\t\t<EnvironmentMiddleware\n\t\t\t\tcreate={it => it.withVariables({ [as]: value })}\n\t\t\t\tkey={value}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</EnvironmentMiddleware>\n\t\t))}\n\t</>\n})\n"],"names":["Component","jsxDEV","Fragment","EnvironmentMiddleware","this"],"mappings":";;;;;AAWa,MAAA,oBAAoBA,oBAAkC,CAAC,EAAE,WAAW,IAAI,YAAY,QAAQ;AACxG,QAAM,aAAa,IAAI,mBAAmB,WAAW,CAAE,CAAA;AAEhD,SAAAC,8BAAAA,OAAAC,cAAAA,UAAA,EACL,UAAW,WAAA,IAAI,CACf,UAAAD,8BAAA;AAAA,IAACE,mBAAA;AAAA,IAAA;AAAA,MACA,QAAQ,QAAM,GAAG,cAAc,EAAE,CAAC,EAAE,GAAG,OAAO;AAAA,MAG7C;AAAA,IAAA;AAAA,IAFI;AAAA,IAFN;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAAA,CAMA,EARK,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EASP,GAAAA,MAAA;AACD,CAAC;;"}
@@ -0,0 +1,29 @@
1
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
2
+ import { EnvironmentMiddleware } from "../accessorPropagation/EnvironmentContext.js";
3
+ import { Component } from "../coreComponents/Component.js";
4
+ const DimensionRenderer = Component(({ dimension, as, children }, env) => {
5
+ const dimensions = env.getDimensionOrElse(dimension, []);
6
+ return /* @__PURE__ */ jsxDEV(Fragment, { children: dimensions.map((value) => /* @__PURE__ */ jsxDEV(
7
+ EnvironmentMiddleware,
8
+ {
9
+ create: (it) => it.withVariables({ [as]: value }),
10
+ children
11
+ },
12
+ value,
13
+ false,
14
+ {
15
+ fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/DimensionRenderer.tsx",
16
+ lineNumber: 17,
17
+ columnNumber: 4
18
+ },
19
+ void 0
20
+ )) }, void 0, false, {
21
+ fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/DimensionRenderer.tsx",
22
+ lineNumber: 15,
23
+ columnNumber: 9
24
+ }, void 0);
25
+ });
26
+ export {
27
+ DimensionRenderer
28
+ };
29
+ //# sourceMappingURL=DimensionRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DimensionRenderer.js","sources":["../../../src/helperComponents/DimensionRenderer.tsx"],"sourcesContent":["import * as React from 'react'\nimport { ReactNode } from 'react'\nimport { EnvironmentMiddleware } from '../accessorPropagation'\nimport { Component } from '../coreComponents'\n\nexport type DimensionRendererProps = {\n\tdimension: string\n\tas: string\n\tchildren: ReactNode\n}\n\nexport const DimensionRenderer = Component<DimensionRendererProps>(({ dimension, as, children }, env) => {\n\tconst dimensions = env.getDimensionOrElse(dimension, [])\n\n\treturn <>\n\t\t{dimensions.map(value => (\n\t\t\t<EnvironmentMiddleware\n\t\t\t\tcreate={it => it.withVariables({ [as]: value })}\n\t\t\t\tkey={value}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</EnvironmentMiddleware>\n\t\t))}\n\t</>\n})\n"],"names":["this"],"mappings":";;;AAWa,MAAA,oBAAoB,UAAkC,CAAC,EAAE,WAAW,IAAI,YAAY,QAAQ;AACxG,QAAM,aAAa,IAAI,mBAAmB,WAAW,CAAE,CAAA;AAEhD,SAAA,uBAAA,UAAA,EACL,UAAW,WAAA,IAAI,CACf,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,QAAQ,QAAM,GAAG,cAAc,EAAE,CAAC,EAAE,GAAG,OAAO;AAAA,MAG7C;AAAA,IAAA;AAAA,IAFI;AAAA,IAFN;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA,CAMA,EARK,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EASP,GAAAA,MAAA;AACD,CAAC;"}
@@ -10,40 +10,43 @@ const Component = require("../coreComponents/Component.cjs");
10
10
  const useEntity = require("../accessorPropagation/useEntity.cjs");
11
11
  const useEnvironment = require("../accessorPropagation/useEnvironment.cjs");
12
12
  const If = Component.Component(
13
- (props) => {
14
- return typeof props.condition !== "function" ? /* @__PURE__ */ jsxDevRuntime.jsxDEV(IfFilter, { condition: props.condition, children: props.children }, void 0, false, {
13
+ ({ condition, ...props }) => {
14
+ if (props.children && props.then) {
15
+ throw new Error("If component cannot have both children and then prop");
16
+ }
17
+ return typeof condition !== "function" ? /* @__PURE__ */ jsxDevRuntime.jsxDEV(IfFilter, { condition, ...props }, void 0, false, {
15
18
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
16
- lineNumber: 30,
19
+ lineNumber: 37,
17
20
  columnNumber: 6
18
- }, void 0) : /* @__PURE__ */ jsxDevRuntime.jsxDEV(IfCallback, { condition: props.condition, children: props.children }, void 0, false, {
21
+ }, void 0) : /* @__PURE__ */ jsxDevRuntime.jsxDEV(IfCallback, { condition, ...props }, void 0, false, {
19
22
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
20
- lineNumber: 31,
23
+ lineNumber: 38,
21
24
  columnNumber: 6
22
25
  }, void 0);
23
26
  },
24
27
  "If"
25
28
  );
26
29
  const IfCallback = Component.Component(
27
- ({ children, condition }) => {
30
+ ({ children, condition, then, else: elseIn }) => {
28
31
  const entity = useEntity.useEntity();
29
32
  const evaluated = react.useMemo(() => condition(entity), [condition, entity]);
30
- return evaluated ? /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children }, void 0, false, {
33
+ return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: evaluated ? children ?? then : elseIn }, void 0, false, {
31
34
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
32
- lineNumber: 41,
33
- columnNumber: 22
34
- }, void 0) : null;
35
+ lineNumber: 48,
36
+ columnNumber: 10
37
+ }, void 0);
35
38
  },
36
39
  ({ children }) => {
37
40
  return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children }, void 0, false, {
38
41
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
39
- lineNumber: 44,
42
+ lineNumber: 51,
40
43
  columnNumber: 10
41
44
  }, void 0);
42
45
  },
43
46
  "IfCallback"
44
47
  );
45
48
  const IfFilter = Component.Component(
46
- ({ children, condition }) => {
49
+ ({ children, condition, then, else: elseIn }) => {
47
50
  const env = useEnvironment.useEnvironment();
48
51
  const entity = useEntity.useEntity();
49
52
  const schema = env.getSchema();
@@ -51,22 +54,22 @@ const IfFilter = Component.Component(
51
54
  () => new FilterEvaluator.FilterEvaluator(schema).evaluateFilter(entity, binding.QueryLanguage.desugarFilter(condition, env)),
52
55
  [condition, entity, env, schema]
53
56
  );
54
- return evaluated ? /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children }, void 0, false, {
57
+ return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: evaluated ? children ?? then : elseIn }, void 0, false, {
55
58
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
56
- lineNumber: 60,
57
- columnNumber: 22
58
- }, void 0) : null;
59
+ lineNumber: 66,
60
+ columnNumber: 10
61
+ }, void 0);
59
62
  },
60
63
  ({ children, condition }, env) => {
61
64
  const desugaredFilter = binding.QueryLanguage.desugarFilter(condition, env);
62
65
  const collectedFields = new FilterFieldsCollector.FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity);
63
66
  const additionalFields = /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: Array.from(collectedFields).map((it) => /* @__PURE__ */ jsxDevRuntime.jsxDEV(Field.Field, { field: it }, it, false, {
64
67
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
65
- lineNumber: 65,
68
+ lineNumber: 71,
66
69
  columnNumber: 69
67
70
  }, void 0)) }, void 0, false, {
68
71
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
69
- lineNumber: 65,
72
+ lineNumber: 71,
70
73
  columnNumber: 28
71
74
  }, void 0);
72
75
  return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: [
@@ -74,7 +77,7 @@ const IfFilter = Component.Component(
74
77
  children
75
78
  ] }, void 0, true, {
76
79
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
77
- lineNumber: 67,
80
+ lineNumber: 73,
78
81
  columnNumber: 10
79
82
  }, void 0);
80
83
  },
@@ -1 +1 @@
1
- {"version":3,"file":"If.cjs","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '@contember/binding'\nimport { QueryLanguage } from '@contember/binding'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '@contember/binding'\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\n/**\n * @group Logic Components\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":["Component","jsxDEV","this","useEntity","useMemo","useEnvironment","FilterEvaluator","QueryLanguage","FilterFieldsCollector","Fragment","Field"],"mappings":";;;;;;;;;;;AA2BO,MAAM,KAAKA,UAAA;AAAA,EAAmB,CAAS,UAAA;AACrC,WAAA,OAAO,MAAM,cAAc,aAC/BC,8BAAA,OAAC,YAAS,WAAW,MAAM,WAAY,UAAA,MAAM,SAA7C,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA,GAAAC,MAAsD,IACrDD,8BAAAA,OAAA,YAAA,EAAW,WAAW,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AU,GAAG,eAAe,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM;AAC7H,UAAM,mBAAmBP,8BAAAA,OAAAQ,cAAA,UAAA,EAAG,UAAM,MAAA,KAAK,eAAe,EAAE,IAAI,CAAA,OAAOR,8BAAA,OAAAS,aAAA,EAAM,OAAO,GAAA,GAAS,IAAvB,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA,GAAAR,MAA2B,CAAE,EAAtE,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAwE,GAAAA,MAAA;AAEjG,WACED,8BAAA,OAAAQ,wBAAA,EAAA,UAAA;AAAA,MAAA;AAAA,MACA;AAAA,IAAA,KAFK,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAGP,GAAAP,MAAA;AAAA,EACD;AAAA,EACA;AACD;;"}
1
+ {"version":3,"file":"If.cjs","sources":["../../../src/helperComponents/If.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useMemo } from 'react'\nimport { Component, Field } from '../coreComponents'\nimport { EntityAccessor } from '@contember/binding'\nimport { QueryLanguage } from '@contember/binding'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '@contember/binding'\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\tthen?: ReactNode\n\telse?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n\tthen?: ReactNode\n\telse?: ReactNode\n}\n\n/**\n * @group Logic Components\n */\nexport const If = Component<IfProps>(({ condition, ...props }) => {\n\t\tif (props.children && props.then) {\n\t\t\tthrow new Error('If component cannot have both children and then prop')\n\t\t}\n\t\treturn typeof condition !== 'function'\n\t\t\t? <IfFilter condition={condition} {...props} />\n\t\t\t: <IfCallback condition={condition} {...props} />\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition, then, else: elseIn }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn <>{evaluated ? (children ?? then) : elseIn}</>\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition, then, else: elseIn }) => {\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\t\treturn <>{evaluated ? (children ?? then) : elseIn}</>\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"],"names":["Component","this","jsxDEV","useEntity","useMemo","Fragment","useEnvironment","FilterEvaluator","QueryLanguage","FilterFieldsCollector","Field"],"mappings":";;;;;;;;;;;AA+BO,MAAM,KAAKA,UAAA;AAAA,EAAmB,CAAC,EAAE,WAAW,GAAG,YAAY;AAC5D,QAAA,MAAM,YAAY,MAAM,MAAM;AAC3B,YAAA,IAAI,MAAM,sDAAsD;AAAA,IACvE;AACA,WAAO,OAAO,cAAc,kDACxB,UAAS,EAAA,WAAuB,GA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AAQ,OAApC,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA2C,GAAAJ,MAAA;AAAA,EACnD;AAAA,EACA,CAAC,EAAE,UAAU,aAAa,QAAQ;AACjC,UAAM,kBAAkBO,QAAA,cAAc,cAAc,WAAW,GAAG;AAClE,UAAM,kBAAkB,IAAIC,4CAAsB,IAAI,UAAU,GAAG,eAAe,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM;AAC7H,UAAM,mBAAmBP,8BAAAA,OAAAG,cAAA,UAAA,EAAG,UAAM,MAAA,KAAK,eAAe,EAAE,IAAI,CAAA,OAAOH,8BAAA,OAAAQ,aAAA,EAAM,OAAO,GAAA,GAAS,IAAvB,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA,GAAAT,MAA2B,CAAE,EAAtE,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAwE,GAAAA,MAAA;AAEjG,WACEC,8BAAA,OAAAG,wBAAA,EAAA,UAAA;AAAA,MAAA;AAAA,MACA;AAAA,IAAA,KAFK,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAGP,GAAAJ,MAAA;AAAA,EACD;AAAA,EACA;AACD;;"}
@@ -8,40 +8,43 @@ import { Component } from "../coreComponents/Component.js";
8
8
  import { useEntity } from "../accessorPropagation/useEntity.js";
9
9
  import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
10
10
  const If = Component(
11
- (props) => {
12
- return typeof props.condition !== "function" ? /* @__PURE__ */ jsxDEV(IfFilter, { condition: props.condition, children: props.children }, void 0, false, {
11
+ ({ condition, ...props }) => {
12
+ if (props.children && props.then) {
13
+ throw new Error("If component cannot have both children and then prop");
14
+ }
15
+ return typeof condition !== "function" ? /* @__PURE__ */ jsxDEV(IfFilter, { condition, ...props }, void 0, false, {
13
16
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
14
- lineNumber: 30,
17
+ lineNumber: 37,
15
18
  columnNumber: 6
16
- }, void 0) : /* @__PURE__ */ jsxDEV(IfCallback, { condition: props.condition, children: props.children }, void 0, false, {
19
+ }, void 0) : /* @__PURE__ */ jsxDEV(IfCallback, { condition, ...props }, void 0, false, {
17
20
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
18
- lineNumber: 31,
21
+ lineNumber: 38,
19
22
  columnNumber: 6
20
23
  }, void 0);
21
24
  },
22
25
  "If"
23
26
  );
24
27
  const IfCallback = Component(
25
- ({ children, condition }) => {
28
+ ({ children, condition, then, else: elseIn }) => {
26
29
  const entity = useEntity();
27
30
  const evaluated = useMemo(() => condition(entity), [condition, entity]);
28
- return evaluated ? /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
31
+ return /* @__PURE__ */ jsxDEV(Fragment, { children: evaluated ? children ?? then : elseIn }, void 0, false, {
29
32
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
30
- lineNumber: 41,
31
- columnNumber: 22
32
- }, void 0) : null;
33
+ lineNumber: 48,
34
+ columnNumber: 10
35
+ }, void 0);
33
36
  },
34
37
  ({ children }) => {
35
38
  return /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
36
39
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
37
- lineNumber: 44,
40
+ lineNumber: 51,
38
41
  columnNumber: 10
39
42
  }, void 0);
40
43
  },
41
44
  "IfCallback"
42
45
  );
43
46
  const IfFilter = Component(
44
- ({ children, condition }) => {
47
+ ({ children, condition, then, else: elseIn }) => {
45
48
  const env = useEnvironment();
46
49
  const entity = useEntity();
47
50
  const schema = env.getSchema();
@@ -49,22 +52,22 @@ const IfFilter = Component(
49
52
  () => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),
50
53
  [condition, entity, env, schema]
51
54
  );
52
- return evaluated ? /* @__PURE__ */ jsxDEV(Fragment, { children }, void 0, false, {
55
+ return /* @__PURE__ */ jsxDEV(Fragment, { children: evaluated ? children ?? then : elseIn }, void 0, false, {
53
56
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
54
- lineNumber: 60,
55
- columnNumber: 22
56
- }, void 0) : null;
57
+ lineNumber: 66,
58
+ columnNumber: 10
59
+ }, void 0);
57
60
  },
58
61
  ({ children, condition }, env) => {
59
62
  const desugaredFilter = QueryLanguage.desugarFilter(condition, env);
60
63
  const collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity);
61
64
  const additionalFields = /* @__PURE__ */ jsxDEV(Fragment, { children: Array.from(collectedFields).map((it) => /* @__PURE__ */ jsxDEV(Field, { field: it }, it, false, {
62
65
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
63
- lineNumber: 65,
66
+ lineNumber: 71,
64
67
  columnNumber: 69
65
68
  }, void 0)) }, void 0, false, {
66
69
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
67
- lineNumber: 65,
70
+ lineNumber: 71,
68
71
  columnNumber: 28
69
72
  }, void 0);
70
73
  return /* @__PURE__ */ jsxDEV(Fragment, { children: [
@@ -72,7 +75,7 @@ const IfFilter = Component(
72
75
  children
73
76
  ] }, void 0, true, {
74
77
  fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
75
- lineNumber: 67,
78
+ lineNumber: 73,
76
79
  columnNumber: 10
77
80
  }, void 0);
78
81
  },
@@ -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 '@contember/binding'\nimport { QueryLanguage } from '@contember/binding'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '@contember/binding'\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\n/**\n * @group Logic Components\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":["this"],"mappings":";;;;;;;;;AA2BO,MAAM,KAA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;AAAA,IAAA,GAAAA,MAAY,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,MAA2B,CAAE,EAAtE,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAwE,GAAAA,MAAA;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,MAAA;AAAA,EACD;AAAA,EACA;AACD;"}
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 '@contember/binding'\nimport { QueryLanguage } from '@contember/binding'\nimport { useEntity, useEnvironment } from '../accessorPropagation'\nimport { Filter } from '@contember/binding'\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\tthen?: ReactNode\n\telse?: ReactNode\n}\n\nexport interface IfCallbackProps {\n\tcondition: (accessor: EntityAccessor) => boolean\n\tchildren?: ReactNode\n\tthen?: ReactNode\n\telse?: ReactNode\n}\n\n/**\n * @group Logic Components\n */\nexport const If = Component<IfProps>(({ condition, ...props }) => {\n\t\tif (props.children && props.then) {\n\t\t\tthrow new Error('If component cannot have both children and then prop')\n\t\t}\n\t\treturn typeof condition !== 'function'\n\t\t\t? <IfFilter condition={condition} {...props} />\n\t\t\t: <IfCallback condition={condition} {...props} />\n\t},\n\t'If',\n)\n\nconst IfCallback = Component<IfCallbackProps>(\n\t({ children, condition, then, else: elseIn }) => {\n\t\tconst entity = useEntity()\n\t\tconst evaluated = useMemo(() => condition(entity), [condition, entity])\n\n\t\treturn <>{evaluated ? (children ?? then) : elseIn}</>\n\t},\n\t({ children }) => {\n\t\treturn <>{children}</>\n\t},\n\t'IfCallback',\n)\n\nconst IfFilter = Component<IfFilterProps>(\n\t({ children, condition, then, else: elseIn }) => {\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\t\treturn <>{evaluated ? (children ?? then) : elseIn}</>\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"],"names":["this"],"mappings":";;;;;;;;;AA+BO,MAAM,KAAK;AAAA,EAAmB,CAAC,EAAE,WAAW,GAAG,YAAY;AAC5D,QAAA,MAAM,YAAY,MAAM,MAAM;AAC3B,YAAA,IAAI,MAAM,sDAAsD;AAAA,IACvE;A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A,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA2C,GAAAA,MAAA;AAAA,EACnD;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,MAA2B,CAAE,EAAtE,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAwE,GAAAA,MAAA;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,MAAA;AAAA,EACD;AAAA,EACA;AACD;"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxDevRuntime = require("react/jsx-dev-runtime");
4
+ const react = require("react");
5
+ const useEnvironment = require("../accessorPropagation/useEnvironment.cjs");
6
+ const Variable = react.memo(({ name, format }) => {
7
+ const environment = useEnvironment.useEnvironment();
8
+ const value = environment.getVariableOrElse(name, void 0) ?? environment.getParameter(name);
9
+ const formatted = react.useMemo(() => format ? format(value) : value, [format, value]);
10
+ return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: formatted }, void 0, false, {
11
+ fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/Variable.tsx",
12
+ lineNumber: 16,
13
+ columnNumber: 9
14
+ }, void 0);
15
+ });
16
+ Variable.displayName = "Variable";
17
+ exports.Variable = Variable;
18
+ //# sourceMappingURL=Variable.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Variable.cjs","sources":["../../../src/helperComponents/Variable.tsx"],"sourcesContent":["import { Environment } from '@contember/binding'\nimport { memo, ReactElement, ReactNode, useMemo } from 'react'\nimport { useEnvironment } from '../accessorPropagation'\n\nexport interface VariableProps {\n\tname: Environment.Name\n\tformat?: (value: ReactNode) => ReactNode\n}\n\nexport const Variable = memo(({ name, format }: VariableProps): ReactElement => {\n\tconst environment = useEnvironment()\n\tconst value = environment.getVariableOrElse<undefined, ReactNode & Environment.Value>(name, undefined) ?? environment.getParameter(name)\n\n\tconst formatted = useMemo(() => (format ? format(value) : value), [format, value])\n\n\treturn <>{formatted}</>\n})\nVariable.displayName = 'Variable'\n"],"names":["memo","useEnvironment","useMemo","this"],"mappings":";;;;;AASO,MAAM,WAAWA,MAAAA,KAAK,CAAC,EAAE,MAAM,aAA0C;AAC/E,QAAM,cAAcC,eAAAA;AACd,QAAA,QAAQ,YAAY,kBAA4D,MAAM,MAAS,KAAK,YAAY,aAAa,IAAI;AAEjI,QAAA,YAAYC,MAAAA,QAAQ,MAAO,SAAS,OAAO,KAAK,IAAI,OAAQ,CAAC,QAAQ,KAAK,CAAC;AAEjF,wEAAU,UAAH,aAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAa,GAAAC,MAAA;AACrB,CAAC;AACD,SAAS,cAAc;;"}
@@ -0,0 +1,18 @@
1
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
2
+ import { memo, useMemo } from "react";
3
+ import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
4
+ const Variable = memo(({ name, format }) => {
5
+ const environment = useEnvironment();
6
+ const value = environment.getVariableOrElse(name, void 0) ?? environment.getParameter(name);
7
+ const formatted = useMemo(() => format ? format(value) : value, [format, value]);
8
+ return /* @__PURE__ */ jsxDEV(Fragment, { children: formatted }, void 0, false, {
9
+ fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/Variable.tsx",
10
+ lineNumber: 16,
11
+ columnNumber: 9
12
+ }, void 0);
13
+ });
14
+ Variable.displayName = "Variable";
15
+ export {
16
+ Variable
17
+ };
18
+ //# sourceMappingURL=Variable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Variable.js","sources":["../../../src/helperComponents/Variable.tsx"],"sourcesContent":["import { Environment } from '@contember/binding'\nimport { memo, ReactElement, ReactNode, useMemo } from 'react'\nimport { useEnvironment } from '../accessorPropagation'\n\nexport interface VariableProps {\n\tname: Environment.Name\n\tformat?: (value: ReactNode) => ReactNode\n}\n\nexport const Variable = memo(({ name, format }: VariableProps): ReactElement => {\n\tconst environment = useEnvironment()\n\tconst value = environment.getVariableOrElse<undefined, ReactNode & Environment.Value>(name, undefined) ?? environment.getParameter(name)\n\n\tconst formatted = useMemo(() => (format ? format(value) : value), [format, value])\n\n\treturn <>{formatted}</>\n})\nVariable.displayName = 'Variable'\n"],"names":["this"],"mappings":";;;AASO,MAAM,WAAW,KAAK,CAAC,EAAE,MAAM,aAA0C;AAC/E,QAAM,cAAc;AACd,QAAA,QAAQ,YAAY,kBAA4D,MAAM,MAAS,KAAK,YAAY,aAAa,IAAI;AAEjI,QAAA,YAAY,QAAQ,MAAO,SAAS,OAAO,KAAK,IAAI,OAAQ,CAAC,QAAQ,KAAK,CAAC;AAEjF,4CAAU,UAAH,aAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAa,GAAAA,MAAA;AACrB,CAAC;AACD,SAAS,cAAc;"}
@@ -26,6 +26,7 @@ const useHasEntity = require("./accessorPropagation/useHasEntity.cjs");
26
26
  const useEntityList = require("./accessorPropagation/useEntityList.cjs");
27
27
  const useEntityListSubTree = require("./accessorPropagation/useEntityListSubTree.cjs");
28
28
  const useEntityListSubTreeParameters = require("./accessorPropagation/useEntityListSubTreeParameters.cjs");
29
+ const useEntityListSubTreeLoader = require("./accessorPropagation/useEntityListSubTreeLoader.cjs");
29
30
  const useEntitySubTree = require("./accessorPropagation/useEntitySubTree.cjs");
30
31
  const useEntitySubTreeParameters = require("./accessorPropagation/useEntitySubTreeParameters.cjs");
31
32
  const useEnvironment = require("./accessorPropagation/useEnvironment.cjs");
@@ -61,12 +62,14 @@ const useEntityPersistError = require("./entityEvents/useEntityPersistError.cjs"
61
62
  const useEntityPersistSuccess = require("./entityEvents/useEntityPersistSuccess.cjs");
62
63
  const useOnConnectionUpdate = require("./entityEvents/useOnConnectionUpdate.cjs");
63
64
  const DeferredSubTrees = require("./helperComponents/DeferredSubTrees.cjs");
65
+ const DimensionRenderer = require("./helperComponents/DimensionRenderer.cjs");
64
66
  const EntityView = require("./helperComponents/EntityView.cjs");
65
67
  const If = require("./helperComponents/If.cjs");
66
68
  const FieldView = require("./helperComponents/FieldView.cjs");
67
69
  const LabelMiddleware = require("./helperComponents/LabelMiddleware.cjs");
68
70
  const StaticRender = require("./helperComponents/StaticRender.cjs");
69
71
  const SugaredField = require("./helperComponents/SugaredField.cjs");
72
+ const Variable = require("./helperComponents/Variable.cjs");
70
73
  exports.MarkerTreeGenerator = MarkerTreeGenerator.MarkerTreeGenerator;
71
74
  exports.AccessorTree = AccessorTree.AccessorTree;
72
75
  exports.accessorTreeStateReducer = accessorTreeStateReducer.accessorTreeStateReducer;
@@ -94,6 +97,7 @@ exports.useHasEntity = useHasEntity.useHasEntity;
94
97
  exports.useEntityList = useEntityList.useEntityList;
95
98
  exports.useEntityListSubTree = useEntityListSubTree.useEntityListSubTree;
96
99
  exports.useEntityListSubTreeParameters = useEntityListSubTreeParameters.useEntityListSubTreeParameters;
100
+ exports.useEntityListSubTreeLoader = useEntityListSubTreeLoader.useEntityListSubTreeLoader;
97
101
  exports.useEntitySubTree = useEntitySubTree.useEntitySubTree;
98
102
  exports.useEntitySubTreeParameters = useEntitySubTreeParameters.useEntitySubTreeParameters;
99
103
  exports.useEnvironment = useEnvironment.useEnvironment;
@@ -130,6 +134,7 @@ exports.useEntityPersistError = useEntityPersistError.useEntityPersistError;
130
134
  exports.useEntityPersistSuccess = useEntityPersistSuccess.useEntityPersistSuccess;
131
135
  exports.useOnConnectionUpdate = useOnConnectionUpdate.useOnConnectionUpdate;
132
136
  exports.DeferredSubTrees = DeferredSubTrees.DeferredSubTrees;
137
+ exports.DimensionRenderer = DimensionRenderer.DimensionRenderer;
133
138
  exports.EntityView = EntityView.EntityView;
134
139
  exports.If = If.If;
135
140
  exports.FieldView = FieldView.FieldView;
@@ -138,6 +143,7 @@ exports.LabelMiddlewareProvider = LabelMiddleware.LabelMiddlewareProvider;
138
143
  exports.useLabelMiddleware = LabelMiddleware.useLabelMiddleware;
139
144
  exports.StaticRender = StaticRender.StaticRender;
140
145
  exports.SugaredField = SugaredField.SugaredField;
146
+ exports.Variable = Variable.Variable;
141
147
  Object.keys(binding).forEach((k) => {
142
148
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
143
149
  Object.defineProperty(exports, k, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -24,6 +24,7 @@ import { useHasEntity } from "./accessorPropagation/useHasEntity.js";
24
24
  import { useEntityList } from "./accessorPropagation/useEntityList.js";
25
25
  import { useEntityListSubTree } from "./accessorPropagation/useEntityListSubTree.js";
26
26
  import { useEntityListSubTreeParameters } from "./accessorPropagation/useEntityListSubTreeParameters.js";
27
+ import { useEntityListSubTreeLoader } from "./accessorPropagation/useEntityListSubTreeLoader.js";
27
28
  import { useEntitySubTree } from "./accessorPropagation/useEntitySubTree.js";
28
29
  import { useEntitySubTreeParameters } from "./accessorPropagation/useEntitySubTreeParameters.js";
29
30
  import { useEnvironment } from "./accessorPropagation/useEnvironment.js";
@@ -59,12 +60,14 @@ import { useEntityPersistError } from "./entityEvents/useEntityPersistError.js";
59
60
  import { useEntityPersistSuccess } from "./entityEvents/useEntityPersistSuccess.js";
60
61
  import { useOnConnectionUpdate } from "./entityEvents/useOnConnectionUpdate.js";
61
62
  import { DeferredSubTrees } from "./helperComponents/DeferredSubTrees.js";
63
+ import { DimensionRenderer } from "./helperComponents/DimensionRenderer.js";
62
64
  import { EntityView } from "./helperComponents/EntityView.js";
63
65
  import { If } from "./helperComponents/If.js";
64
66
  import { FieldView } from "./helperComponents/FieldView.js";
65
67
  import { LabelMiddlewareContext, LabelMiddlewareProvider, useLabelMiddleware } from "./helperComponents/LabelMiddleware.js";
66
68
  import { StaticRender } from "./helperComponents/StaticRender.js";
67
69
  import { SugaredField } from "./helperComponents/SugaredField.js";
70
+ import { Variable } from "./helperComponents/Variable.js";
68
71
  export {
69
72
  AccessorProvider,
70
73
  AccessorTree,
@@ -72,6 +75,7 @@ export {
72
75
  Component,
73
76
  DataBindingProvider,
74
77
  DeferredSubTrees,
78
+ DimensionRenderer,
75
79
  DirtinessContext,
76
80
  Entity,
77
81
  EntityKeyProvider,
@@ -96,6 +100,7 @@ export {
96
100
  StaticRender,
97
101
  SugaredField,
98
102
  TreeRootIdProvider,
103
+ Variable,
99
104
  accessorTreeStateReducer,
100
105
  addEntityAtIndex,
101
106
  moveEntity,
@@ -118,6 +123,7 @@ export {
118
123
  useEntityKey,
119
124
  useEntityList,
120
125
  useEntityListSubTree,
126
+ useEntityListSubTreeLoader,
121
127
  useEntityListSubTreeParameters,
122
128
  useEntityPersistError,
123
129
  useEntityPersistSuccess,