@contember/react-binding 1.3.0-alpha.9 → 1.3.0-rc.3
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.
- package/dist/development/accessorPropagation/useEntityListSubTreeLoader.cjs +47 -0
- package/dist/development/accessorPropagation/useEntityListSubTreeLoader.cjs.map +1 -0
- package/dist/development/accessorPropagation/useEntityListSubTreeLoader.js +47 -0
- package/dist/development/accessorPropagation/useEntityListSubTreeLoader.js.map +1 -0
- package/dist/development/accessorSorting/sortEntities.cjs +1 -4
- package/dist/development/accessorSorting/sortEntities.cjs.map +1 -1
- package/dist/development/accessorSorting/sortEntities.js +1 -4
- package/dist/development/accessorSorting/sortEntities.js.map +1 -1
- package/dist/development/coreComponents/DataBindingProvider.cjs +8 -3
- package/dist/development/coreComponents/DataBindingProvider.cjs.map +1 -1
- package/dist/development/coreComponents/DataBindingProvider.js +8 -3
- package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/development/helperComponents/DeferredSubTrees.cjs +1 -1
- package/dist/development/helperComponents/DeferredSubTrees.js +1 -1
- package/dist/development/helperComponents/DimensionRenderer.cjs +29 -0
- package/dist/development/helperComponents/DimensionRenderer.cjs.map +1 -0
- package/dist/development/helperComponents/DimensionRenderer.js +29 -0
- package/dist/development/helperComponents/DimensionRenderer.js.map +1 -0
- package/dist/development/helperComponents/If.cjs +32 -23
- package/dist/development/helperComponents/If.cjs.map +1 -1
- package/dist/development/helperComponents/If.js +32 -23
- package/dist/development/helperComponents/If.js.map +1 -1
- package/dist/development/helperComponents/Variable.cjs +18 -0
- package/dist/development/helperComponents/Variable.cjs.map +1 -0
- package/dist/development/helperComponents/Variable.js +18 -0
- package/dist/development/helperComponents/Variable.js.map +1 -0
- package/dist/development/index.cjs +6 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +6 -0
- package/dist/development/index.js.map +1 -1
- package/dist/production/accessorPropagation/useEntityListSubTreeLoader.cjs +47 -0
- package/dist/production/accessorPropagation/useEntityListSubTreeLoader.cjs.map +1 -0
- package/dist/production/accessorPropagation/useEntityListSubTreeLoader.js +47 -0
- package/dist/production/accessorPropagation/useEntityListSubTreeLoader.js.map +1 -0
- package/dist/production/accessorSorting/sortEntities.cjs +1 -4
- package/dist/production/accessorSorting/sortEntities.cjs.map +1 -1
- package/dist/production/accessorSorting/sortEntities.js +1 -4
- package/dist/production/accessorSorting/sortEntities.js.map +1 -1
- package/dist/production/coreComponents/DataBindingProvider.cjs +2 -1
- package/dist/production/coreComponents/DataBindingProvider.cjs.map +1 -1
- package/dist/production/coreComponents/DataBindingProvider.js +2 -1
- package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
- package/dist/production/helperComponents/DeferredSubTrees.cjs +1 -1
- package/dist/production/helperComponents/DeferredSubTrees.js +1 -1
- package/dist/production/helperComponents/DimensionRenderer.cjs +18 -0
- package/dist/production/helperComponents/DimensionRenderer.cjs.map +1 -0
- package/dist/production/helperComponents/DimensionRenderer.js +18 -0
- package/dist/production/helperComponents/DimensionRenderer.js.map +1 -0
- package/dist/production/helperComponents/If.cjs +19 -10
- package/dist/production/helperComponents/If.cjs.map +1 -1
- package/dist/production/helperComponents/If.js +20 -11
- package/dist/production/helperComponents/If.js.map +1 -1
- package/dist/production/helperComponents/Variable.cjs +14 -0
- package/dist/production/helperComponents/Variable.cjs.map +1 -0
- package/dist/production/helperComponents/Variable.js +14 -0
- package/dist/production/helperComponents/Variable.js.map +1 -0
- package/dist/production/index.cjs +6 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +6 -0
- package/dist/production/index.js.map +1 -1
- package/dist/types/accessorPropagation/EnvironmentContext.d.ts +1 -1
- package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/index.d.ts +1 -0
- package/dist/types/accessorPropagation/index.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useEntityListSubTreeLoader.d.ts +10 -0
- package/dist/types/accessorPropagation/useEntityListSubTreeLoader.d.ts.map +1 -0
- package/dist/types/accessorPropagation/useGetEntityListSubTree.d.ts +2 -2
- package/dist/types/accessorPropagation/useGetEntityListSubTree.d.ts.map +1 -1
- package/dist/types/accessorPropagation/useGetEntitySubTree.d.ts +2 -2
- package/dist/types/accessorPropagation/useGetEntitySubTree.d.ts.map +1 -1
- package/dist/types/accessorSorting/sortEntities.d.ts.map +1 -1
- package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
- package/dist/types/coreComponents/EntityList.d.ts.map +1 -1
- package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
- package/dist/types/coreComponents/Field.d.ts.map +1 -1
- package/dist/types/coreComponents/HasMany.d.ts.map +1 -1
- package/dist/types/coreComponents/HasOne.d.ts.map +1 -1
- package/dist/types/entityEvents/useDerivedField.d.ts.map +1 -1
- package/dist/types/helperComponents/DimensionRenderer.d.ts +9 -0
- package/dist/types/helperComponents/DimensionRenderer.d.ts.map +1 -0
- package/dist/types/helperComponents/If.d.ts +4 -0
- package/dist/types/helperComponents/If.d.ts.map +1 -1
- package/dist/types/helperComponents/LabelMiddleware.d.ts.map +1 -1
- package/dist/types/helperComponents/SugaredField.d.ts.map +1 -1
- package/dist/types/helperComponents/Variable.d.ts +8 -0
- package/dist/types/helperComponents/Variable.d.ts.map +1 -0
- package/dist/types/helperComponents/index.d.ts +2 -0
- package/dist/types/helperComponents/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/accessorPropagation/index.ts +1 -0
- package/src/accessorPropagation/useEntityListSubTreeLoader.ts +69 -0
- package/src/accessorSorting/sortEntities.ts +1 -4
- package/src/coreComponents/DataBindingProvider.tsx +8 -1
- package/src/helperComponents/DimensionRenderer.tsx +25 -0
- package/src/helperComponents/If.tsx +24 -13
- package/src/helperComponents/Variable.tsx +18 -0
- 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
|
-
|
|
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\
|
|
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
|
-
|
|
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\
|
|
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;"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
4
|
const react = require("react");
|
|
5
5
|
const useDataBinding = require("../accessorTree/useDataBinding.cjs");
|
|
6
|
+
const TreeRootIdProvider = require("../accessorPropagation/TreeRootIdProvider.cjs");
|
|
6
7
|
const AccessorTree = require("../accessorTree/AccessorTree.cjs");
|
|
7
8
|
const DataBindingProvider = react.memo(function DataBindingProvider2(props) {
|
|
8
9
|
const accessorTreeState = useDataBinding.useDataBinding(props);
|
|
@@ -14,10 +15,14 @@ const DataBindingProvider = react.memo(function DataBindingProvider2(props) {
|
|
|
14
15
|
},
|
|
15
16
|
props.children
|
|
16
17
|
) : props.children;
|
|
17
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(AccessorTree.AccessorTree, { state: accessorTreeState, children }, void 0, false, {
|
|
18
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(TreeRootIdProvider.TreeRootIdProvider, { treeRootId: void 0, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(AccessorTree.AccessorTree, { state: accessorTreeState, children }, void 0, false, {
|
|
18
19
|
fileName: "/__w/interface/interface/packages/react-binding/src/coreComponents/DataBindingProvider.tsx",
|
|
19
|
-
lineNumber:
|
|
20
|
-
columnNumber:
|
|
20
|
+
lineNumber: 56,
|
|
21
|
+
columnNumber: 4
|
|
22
|
+
}, this) }, void 0, false, {
|
|
23
|
+
fileName: "/__w/interface/interface/packages/react-binding/src/coreComponents/DataBindingProvider.tsx",
|
|
24
|
+
lineNumber: 55,
|
|
25
|
+
columnNumber: 3
|
|
21
26
|
}, this);
|
|
22
27
|
});
|
|
23
28
|
exports.DataBindingProvider = DataBindingProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataBindingProvider.cjs","sources":["../../../src/coreComponents/DataBindingProvider.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode } from 'react'\nimport { AccessorTree, AccessorTreeState, AccessorTreeStateOptions, useDataBinding } from '../accessorTree'\n\nexport type DataBindingProviderStateComponent<StateProps> = (\n\t| {\n\t\tstateComponent?: never;\n\t\tstateProps?: never;\n\t}\n\t| {\n\t\tstateComponent: ComponentType<StateProps & DataBindingStateComponentProps>\n\t\tstateProps?: StateProps\n\t}\n)\n\nexport type DataBindingProviderBaseProps =\n\t& AccessorTreeStateOptions\n\nexport interface DataBindingStateComponentProps {\n\taccessorTreeState: AccessorTreeState\n\tchildren?: ReactNode\n}\n\nexport type DataBindingProviderProps<StateProps> =\n\t& DataBindingProviderBaseProps\n\t& DataBindingProviderStateComponent<StateProps>\n\n/**\n * The `DataBindingProvider` is a root component for all other data binding related components.\n *\n * @example\n * ```\n * <DataBindingProvider stateComponent={FeedbackRenderer} />\n * ```\n *\n * @group Data binding\n */\nexport const DataBindingProvider = memo(function DataBindingProvider<StateProps extends DataBindingStateComponentProps>(\n\tprops: DataBindingProviderProps<StateProps>,\n) {\n\tconst accessorTreeState = useDataBinding(props)\n\n\tconst children =\n\t\t'stateComponent' in props && props.stateComponent\n\t\t\t? createElement(\n\t\t\t\t\tprops.stateComponent,\n\t\t\t\t\t{\n\t\t\t\t\t\t...props.stateProps!,\n\t\t\t\t\t\taccessorTreeState: accessorTreeState,\n\t\t\t\t\t},\n\t\t\t\t\tprops.children,\n\t\t\t )\n\t\t\t: props.children\n\treturn <AccessorTree state={accessorTreeState}
|
|
1
|
+
{"version":3,"file":"DataBindingProvider.cjs","sources":["../../../src/coreComponents/DataBindingProvider.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode } from 'react'\nimport { AccessorTree, AccessorTreeState, AccessorTreeStateOptions, useDataBinding } from '../accessorTree'\nimport { TreeRootIdProvider } from '../accessorPropagation'\n\nexport type DataBindingProviderStateComponent<StateProps> = (\n\t| {\n\t\tstateComponent?: never;\n\t\tstateProps?: never;\n\t}\n\t| {\n\t\tstateComponent: ComponentType<StateProps & DataBindingStateComponentProps>\n\t\tstateProps?: StateProps\n\t}\n)\n\nexport type DataBindingProviderBaseProps =\n\t& AccessorTreeStateOptions\n\nexport interface DataBindingStateComponentProps {\n\taccessorTreeState: AccessorTreeState\n\tchildren?: ReactNode\n}\n\nexport type DataBindingProviderProps<StateProps> =\n\t& DataBindingProviderBaseProps\n\t& DataBindingProviderStateComponent<StateProps>\n\n/**\n * The `DataBindingProvider` is a root component for all other data binding related components.\n *\n * @example\n * ```\n * <DataBindingProvider stateComponent={FeedbackRenderer} />\n * ```\n *\n * @group Data binding\n */\nexport const DataBindingProvider = memo(function DataBindingProvider<StateProps extends DataBindingStateComponentProps>(\n\tprops: DataBindingProviderProps<StateProps>,\n) {\n\tconst accessorTreeState = useDataBinding(props)\n\n\tconst children =\n\t\t'stateComponent' in props && props.stateComponent\n\t\t\t? createElement(\n\t\t\t\t\tprops.stateComponent,\n\t\t\t\t\t{\n\t\t\t\t\t\t...props.stateProps!,\n\t\t\t\t\t\taccessorTreeState: accessorTreeState,\n\t\t\t\t\t},\n\t\t\t\t\tprops.children,\n\t\t\t )\n\t\t\t: props.children\n\treturn (\n\t\t<TreeRootIdProvider treeRootId={undefined}>\n\t\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t\t{children}\n\t\t\t</AccessorTree>\n\t\t</TreeRootIdProvider>\n\t)\n}) as <StateProps>(props: DataBindingProviderProps<StateProps>) => ReactElement\n"],"names":["memo","DataBindingProvider","useDataBinding","createElement","jsxDEV","TreeRootIdProvider","AccessorTree"],"mappings":";;;;;;;AAqCO,MAAM,sBAAsBA,MAAA,KAAK,SAASC,qBAChD,OACC;AACK,QAAA,oBAAoBC,8BAAe,KAAK;AAE9C,QAAM,WACL,oBAAoB,SAAS,MAAM,iBAChCC,MAAA;AAAA,IACA,MAAM;AAAA,IACN;AAAA,MACC,GAAG,MAAM;AAAA,MACT;AAAA,IACD;AAAA,IACA,MAAM;AAAA,EAAA,IAEN,MAAM;AAET,SAAAC,8BAAAA,OAACC,mBAAAA,sBAAmB,YAAY,QAC/B,+CAACC,aAAAA,cAAa,EAAA,OAAO,mBACnB,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAA,IAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAIA,GAAA,IAAA;AAEF,CAAC;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
2
|
import { memo, createElement } from "react";
|
|
3
3
|
import { useDataBinding } from "../accessorTree/useDataBinding.js";
|
|
4
|
+
import { TreeRootIdProvider } from "../accessorPropagation/TreeRootIdProvider.js";
|
|
4
5
|
import { AccessorTree } from "../accessorTree/AccessorTree.js";
|
|
5
6
|
const DataBindingProvider = memo(function DataBindingProvider2(props) {
|
|
6
7
|
const accessorTreeState = useDataBinding(props);
|
|
@@ -12,10 +13,14 @@ const DataBindingProvider = memo(function DataBindingProvider2(props) {
|
|
|
12
13
|
},
|
|
13
14
|
props.children
|
|
14
15
|
) : props.children;
|
|
15
|
-
return /* @__PURE__ */ jsxDEV(AccessorTree, { state: accessorTreeState, children }, void 0, false, {
|
|
16
|
+
return /* @__PURE__ */ jsxDEV(TreeRootIdProvider, { treeRootId: void 0, children: /* @__PURE__ */ jsxDEV(AccessorTree, { state: accessorTreeState, children }, void 0, false, {
|
|
16
17
|
fileName: "/__w/interface/interface/packages/react-binding/src/coreComponents/DataBindingProvider.tsx",
|
|
17
|
-
lineNumber:
|
|
18
|
-
columnNumber:
|
|
18
|
+
lineNumber: 56,
|
|
19
|
+
columnNumber: 4
|
|
20
|
+
}, this) }, void 0, false, {
|
|
21
|
+
fileName: "/__w/interface/interface/packages/react-binding/src/coreComponents/DataBindingProvider.tsx",
|
|
22
|
+
lineNumber: 55,
|
|
23
|
+
columnNumber: 3
|
|
19
24
|
}, this);
|
|
20
25
|
});
|
|
21
26
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataBindingProvider.js","sources":["../../../src/coreComponents/DataBindingProvider.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode } from 'react'\nimport { AccessorTree, AccessorTreeState, AccessorTreeStateOptions, useDataBinding } from '../accessorTree'\n\nexport type DataBindingProviderStateComponent<StateProps> = (\n\t| {\n\t\tstateComponent?: never;\n\t\tstateProps?: never;\n\t}\n\t| {\n\t\tstateComponent: ComponentType<StateProps & DataBindingStateComponentProps>\n\t\tstateProps?: StateProps\n\t}\n)\n\nexport type DataBindingProviderBaseProps =\n\t& AccessorTreeStateOptions\n\nexport interface DataBindingStateComponentProps {\n\taccessorTreeState: AccessorTreeState\n\tchildren?: ReactNode\n}\n\nexport type DataBindingProviderProps<StateProps> =\n\t& DataBindingProviderBaseProps\n\t& DataBindingProviderStateComponent<StateProps>\n\n/**\n * The `DataBindingProvider` is a root component for all other data binding related components.\n *\n * @example\n * ```\n * <DataBindingProvider stateComponent={FeedbackRenderer} />\n * ```\n *\n * @group Data binding\n */\nexport const DataBindingProvider = memo(function DataBindingProvider<StateProps extends DataBindingStateComponentProps>(\n\tprops: DataBindingProviderProps<StateProps>,\n) {\n\tconst accessorTreeState = useDataBinding(props)\n\n\tconst children =\n\t\t'stateComponent' in props && props.stateComponent\n\t\t\t? createElement(\n\t\t\t\t\tprops.stateComponent,\n\t\t\t\t\t{\n\t\t\t\t\t\t...props.stateProps!,\n\t\t\t\t\t\taccessorTreeState: accessorTreeState,\n\t\t\t\t\t},\n\t\t\t\t\tprops.children,\n\t\t\t )\n\t\t\t: props.children\n\treturn <AccessorTree state={accessorTreeState}
|
|
1
|
+
{"version":3,"file":"DataBindingProvider.js","sources":["../../../src/coreComponents/DataBindingProvider.tsx"],"sourcesContent":["import { ComponentType, createElement, memo, ReactElement, ReactNode } from 'react'\nimport { AccessorTree, AccessorTreeState, AccessorTreeStateOptions, useDataBinding } from '../accessorTree'\nimport { TreeRootIdProvider } from '../accessorPropagation'\n\nexport type DataBindingProviderStateComponent<StateProps> = (\n\t| {\n\t\tstateComponent?: never;\n\t\tstateProps?: never;\n\t}\n\t| {\n\t\tstateComponent: ComponentType<StateProps & DataBindingStateComponentProps>\n\t\tstateProps?: StateProps\n\t}\n)\n\nexport type DataBindingProviderBaseProps =\n\t& AccessorTreeStateOptions\n\nexport interface DataBindingStateComponentProps {\n\taccessorTreeState: AccessorTreeState\n\tchildren?: ReactNode\n}\n\nexport type DataBindingProviderProps<StateProps> =\n\t& DataBindingProviderBaseProps\n\t& DataBindingProviderStateComponent<StateProps>\n\n/**\n * The `DataBindingProvider` is a root component for all other data binding related components.\n *\n * @example\n * ```\n * <DataBindingProvider stateComponent={FeedbackRenderer} />\n * ```\n *\n * @group Data binding\n */\nexport const DataBindingProvider = memo(function DataBindingProvider<StateProps extends DataBindingStateComponentProps>(\n\tprops: DataBindingProviderProps<StateProps>,\n) {\n\tconst accessorTreeState = useDataBinding(props)\n\n\tconst children =\n\t\t'stateComponent' in props && props.stateComponent\n\t\t\t? createElement(\n\t\t\t\t\tprops.stateComponent,\n\t\t\t\t\t{\n\t\t\t\t\t\t...props.stateProps!,\n\t\t\t\t\t\taccessorTreeState: accessorTreeState,\n\t\t\t\t\t},\n\t\t\t\t\tprops.children,\n\t\t\t )\n\t\t\t: props.children\n\treturn (\n\t\t<TreeRootIdProvider treeRootId={undefined}>\n\t\t\t<AccessorTree state={accessorTreeState}>\n\t\t\t\t{children}\n\t\t\t</AccessorTree>\n\t\t</TreeRootIdProvider>\n\t)\n}) as <StateProps>(props: DataBindingProviderProps<StateProps>) => ReactElement\n"],"names":["DataBindingProvider"],"mappings":";;;;;AAqCO,MAAM,sBAAsB,KAAK,SAASA,qBAChD,OACC;AACK,QAAA,oBAAoB,eAAe,KAAK;AAE9C,QAAM,WACL,oBAAoB,SAAS,MAAM,iBAChC;AAAA,IACA,MAAM;AAAA,IACN;AAAA,MACC,GAAG,MAAM;AAAA,MACT;AAAA,IACD;AAAA,IACA,MAAM;AAAA,EAAA,IAEN,MAAM;AAET,SAAA,uBAAC,sBAAmB,YAAY,QAC/B,iCAAC,cAAa,EAAA,OAAO,mBACnB,SADF,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAA,IAEA,EAHD,GAAA,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAIA,GAAA,IAAA;AAEF,CAAC;"}
|
|
@@ -9,8 +9,8 @@ const useBindingOperations = require("../accessorPropagation/useBindingOperation
|
|
|
9
9
|
const useMutationState = require("../accessorTree/useMutationState.cjs");
|
|
10
10
|
const useHasEntity = require("../accessorPropagation/useHasEntity.cjs");
|
|
11
11
|
const useEntityBeforePersist = require("../entityEvents/useEntityBeforePersist.cjs");
|
|
12
|
-
const TreeRootIdProvider = require("../accessorPropagation/TreeRootIdProvider.cjs");
|
|
13
12
|
const useEnvironment = require("../accessorPropagation/useEnvironment.cjs");
|
|
13
|
+
const TreeRootIdProvider = require("../accessorPropagation/TreeRootIdProvider.cjs");
|
|
14
14
|
const DeferredSubTrees = Component.Component(
|
|
15
15
|
(props) => {
|
|
16
16
|
const { extendTree } = useBindingOperations.useBindingOperations();
|
|
@@ -7,8 +7,8 @@ import { useBindingOperations } from "../accessorPropagation/useBindingOperation
|
|
|
7
7
|
import { useMutationState } from "../accessorTree/useMutationState.js";
|
|
8
8
|
import { useHasEntity } from "../accessorPropagation/useHasEntity.js";
|
|
9
9
|
import { useEntityBeforePersist } from "../entityEvents/useEntityBeforePersist.js";
|
|
10
|
-
import { TreeRootIdProvider } from "../accessorPropagation/TreeRootIdProvider.js";
|
|
11
10
|
import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
|
|
11
|
+
import { TreeRootIdProvider } from "../accessorPropagation/TreeRootIdProvider.js";
|
|
12
12
|
const DeferredSubTrees = Component(
|
|
13
13
|
(props) => {
|
|
14
14
|
const { extendTree } = useBindingOperations();
|
|
@@ -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,47 @@ 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
|
-
|
|
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:
|
|
19
|
+
lineNumber: 37,
|
|
17
20
|
columnNumber: 6
|
|
18
|
-
}, void 0) : /* @__PURE__ */ jsxDevRuntime.jsxDEV(IfCallback, { condition
|
|
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:
|
|
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
|
|
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:
|
|
33
|
-
columnNumber:
|
|
34
|
-
}, void 0)
|
|
35
|
+
lineNumber: 48,
|
|
36
|
+
columnNumber: 10
|
|
37
|
+
}, void 0);
|
|
35
38
|
},
|
|
36
|
-
({ children }) => {
|
|
37
|
-
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children
|
|
39
|
+
({ children, then, else: elseIn }) => {
|
|
40
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: [
|
|
41
|
+
children,
|
|
42
|
+
then,
|
|
43
|
+
elseIn
|
|
44
|
+
] }, void 0, true, {
|
|
38
45
|
fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
|
|
39
|
-
lineNumber:
|
|
46
|
+
lineNumber: 51,
|
|
40
47
|
columnNumber: 10
|
|
41
48
|
}, void 0);
|
|
42
49
|
},
|
|
43
50
|
"IfCallback"
|
|
44
51
|
);
|
|
45
52
|
const IfFilter = Component.Component(
|
|
46
|
-
({ children, condition }) => {
|
|
53
|
+
({ children, condition, then, else: elseIn }) => {
|
|
47
54
|
const env = useEnvironment.useEnvironment();
|
|
48
55
|
const entity = useEntity.useEntity();
|
|
49
56
|
const schema = env.getSchema();
|
|
@@ -51,30 +58,32 @@ const IfFilter = Component.Component(
|
|
|
51
58
|
() => new FilterEvaluator.FilterEvaluator(schema).evaluateFilter(entity, binding.QueryLanguage.desugarFilter(condition, env)),
|
|
52
59
|
[condition, entity, env, schema]
|
|
53
60
|
);
|
|
54
|
-
return
|
|
61
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: evaluated ? children ?? then : elseIn }, void 0, false, {
|
|
55
62
|
fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
|
|
56
|
-
lineNumber:
|
|
57
|
-
columnNumber:
|
|
58
|
-
}, void 0)
|
|
63
|
+
lineNumber: 70,
|
|
64
|
+
columnNumber: 10
|
|
65
|
+
}, void 0);
|
|
59
66
|
},
|
|
60
|
-
({ children, condition }, env) => {
|
|
67
|
+
({ children, condition, then, else: elseIn }, env) => {
|
|
61
68
|
const desugaredFilter = binding.QueryLanguage.desugarFilter(condition, env);
|
|
62
69
|
const collectedFields = new FilterFieldsCollector.FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity);
|
|
63
70
|
const additionalFields = /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: Array.from(collectedFields).map((it) => /* @__PURE__ */ jsxDevRuntime.jsxDEV(Field.Field, { field: it }, it, false, {
|
|
64
71
|
fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
|
|
65
|
-
lineNumber:
|
|
72
|
+
lineNumber: 75,
|
|
66
73
|
columnNumber: 69
|
|
67
74
|
}, void 0)) }, void 0, false, {
|
|
68
75
|
fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
|
|
69
|
-
lineNumber:
|
|
76
|
+
lineNumber: 75,
|
|
70
77
|
columnNumber: 28
|
|
71
78
|
}, void 0);
|
|
72
79
|
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: [
|
|
73
80
|
additionalFields,
|
|
74
|
-
children
|
|
81
|
+
children,
|
|
82
|
+
then,
|
|
83
|
+
elseIn
|
|
75
84
|
] }, void 0, true, {
|
|
76
85
|
fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
|
|
77
|
-
lineNumber:
|
|
86
|
+
lineNumber: 77,
|
|
78
87
|
columnNumber: 10
|
|
79
88
|
}, void 0);
|
|
80
89
|
},
|
|
@@ -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
|
|
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, then, else: elseIn }) => {\n\t\treturn <>\n\t\t\t{children}\n\t\t\t{then}\n\t\t\t{elseIn}\n\t\t</>\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, then, else: elseIn }, 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\t{then}\n\t\t\t{elseIn}\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,GAAG,MAApC,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA,GAAAC,MAA2C,IAC3CC,8BAAA,OAAC,YAAW,EAAA,WAAuB,GAAG,MAAtC,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA6C,GAAAD,MAAA;AAAA,EACjD;AAAA,EACA;AACD;AAEA,MAAM,aAAaD,UAAA;AAAA,EAClB,CAAC,EAAE,UAAU,WAAW,MAAM,MAAM,aAAa;AAChD,UAAM,SAASG,UAAAA;AACT,UAAA,YAAYC,cAAQ,MAAM,UAAU,MAAM,GAAG,CAAC,WAAW,MAAM,CAAC;AAEtE,WAAUF,qCAAAG,cAAAA,UAAA,EAAA,UAAA,YAAa,YAAY,OAAQ,OAApC,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA2C,GAAAJ,MAAA;AAAA,EACnD;AAAA,EACA,CAAC,EAAE,UAAU,MAAM,MAAM,aAAa;AACrC,WACEC,8BAAA,OAAAG,wBAAA,EAAA,UAAA;AAAA,MAAA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,KAHK,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAIP,GAAAJ,MAAA;AAAA,EACD;AAAA,EACA;AACD;AAEA,MAAM,WAAWD,UAAA;AAAA,EAChB,CAAC,EAAE,UAAU,WAAW,MAAM,MAAM,aAAa;AAChD,UAAM,MAAMM,eAAAA;AACZ,UAAM,SAASH,UAAAA;AAET,UAAA,SAAS,IAAI;AACnB,UAAM,YAAYC,MAAA;AAAA,MACjB,MAAM,IAAIG,gBAAAA,gBAAgB,MAAM,EAAE,eAAe,QAAQC,QAAAA,cAAc,cAAc,WAAW,GAAG,CAAC;AAAA,MACpG,CAAC,WAAW,QAAQ,KAAK,MAAM;AAAA,IAAA;AAEhC,WAAUN,qCAAAG,cAAAA,UAAA,EAAA,UAAA,YAAa,YAAY,OAAQ,OAApC,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA2C,GAAAJ,MAAA;AAAA,EACnD;AAAA,EACA,CAAC,EAAE,UAAU,WAAW,MAAM,MAAM,UAAU,QAAQ;AACrD,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,MACA;AAAA,MACA;AAAA,IAAA,KAJK,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAKP,GAAAJ,MAAA;AAAA,EACD;AAAA,EACA;AACD;;"}
|
|
@@ -8,40 +8,47 @@ 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
|
-
|
|
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:
|
|
17
|
+
lineNumber: 37,
|
|
15
18
|
columnNumber: 6
|
|
16
|
-
}, void 0) : /* @__PURE__ */ jsxDEV(IfCallback, { condition
|
|
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:
|
|
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
|
|
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:
|
|
31
|
-
columnNumber:
|
|
32
|
-
}, void 0)
|
|
33
|
+
lineNumber: 48,
|
|
34
|
+
columnNumber: 10
|
|
35
|
+
}, void 0);
|
|
33
36
|
},
|
|
34
|
-
({ children }) => {
|
|
35
|
-
return /* @__PURE__ */ jsxDEV(Fragment, { children
|
|
37
|
+
({ children, then, else: elseIn }) => {
|
|
38
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children: [
|
|
39
|
+
children,
|
|
40
|
+
then,
|
|
41
|
+
elseIn
|
|
42
|
+
] }, void 0, true, {
|
|
36
43
|
fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
|
|
37
|
-
lineNumber:
|
|
44
|
+
lineNumber: 51,
|
|
38
45
|
columnNumber: 10
|
|
39
46
|
}, void 0);
|
|
40
47
|
},
|
|
41
48
|
"IfCallback"
|
|
42
49
|
);
|
|
43
50
|
const IfFilter = Component(
|
|
44
|
-
({ children, condition }) => {
|
|
51
|
+
({ children, condition, then, else: elseIn }) => {
|
|
45
52
|
const env = useEnvironment();
|
|
46
53
|
const entity = useEntity();
|
|
47
54
|
const schema = env.getSchema();
|
|
@@ -49,30 +56,32 @@ const IfFilter = Component(
|
|
|
49
56
|
() => new FilterEvaluator(schema).evaluateFilter(entity, QueryLanguage.desugarFilter(condition, env)),
|
|
50
57
|
[condition, entity, env, schema]
|
|
51
58
|
);
|
|
52
|
-
return
|
|
59
|
+
return /* @__PURE__ */ jsxDEV(Fragment, { children: evaluated ? children ?? then : elseIn }, void 0, false, {
|
|
53
60
|
fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
|
|
54
|
-
lineNumber:
|
|
55
|
-
columnNumber:
|
|
56
|
-
}, void 0)
|
|
61
|
+
lineNumber: 70,
|
|
62
|
+
columnNumber: 10
|
|
63
|
+
}, void 0);
|
|
57
64
|
},
|
|
58
|
-
({ children, condition }, env) => {
|
|
65
|
+
({ children, condition, then, else: elseIn }, env) => {
|
|
59
66
|
const desugaredFilter = QueryLanguage.desugarFilter(condition, env);
|
|
60
67
|
const collectedFields = new FilterFieldsCollector(env.getSchema(), desugaredFilter).collectFields(env.getSubTreeNode().entity);
|
|
61
68
|
const additionalFields = /* @__PURE__ */ jsxDEV(Fragment, { children: Array.from(collectedFields).map((it) => /* @__PURE__ */ jsxDEV(Field, { field: it }, it, false, {
|
|
62
69
|
fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
|
|
63
|
-
lineNumber:
|
|
70
|
+
lineNumber: 75,
|
|
64
71
|
columnNumber: 69
|
|
65
72
|
}, void 0)) }, void 0, false, {
|
|
66
73
|
fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
|
|
67
|
-
lineNumber:
|
|
74
|
+
lineNumber: 75,
|
|
68
75
|
columnNumber: 28
|
|
69
76
|
}, void 0);
|
|
70
77
|
return /* @__PURE__ */ jsxDEV(Fragment, { children: [
|
|
71
78
|
additionalFields,
|
|
72
|
-
children
|
|
79
|
+
children,
|
|
80
|
+
then,
|
|
81
|
+
elseIn
|
|
73
82
|
] }, void 0, true, {
|
|
74
83
|
fileName: "/__w/interface/interface/packages/react-binding/src/helperComponents/If.tsx",
|
|
75
|
-
lineNumber:
|
|
84
|
+
lineNumber: 77,
|
|
76
85
|
columnNumber: 10
|
|
77
86
|
}, void 0);
|
|
78
87
|
},
|
|
@@ -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
|
|
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, then, else: elseIn }) => {\n\t\treturn <>\n\t\t\t{children}\n\t\t\t{then}\n\t\t\t{elseIn}\n\t\t</>\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, then, else: elseIn }, 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\t{then}\n\t\t\t{elseIn}\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;AACA,WAAO,OAAO,cAAc,oCACxB,UAAS,EAAA,WAAuB,GAAG,MAApC,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA,GAAAA,MAA2C,IAC3C,uBAAC,YAAW,EAAA,WAAuB,GAAG,MAAtC,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA6C,GAAAA,MAAA;AAAA,EACjD;AAAA,EACA;AACD;AAEA,MAAM,aAAa;AAAA,EAClB,CAAC,EAAE,UAAU,WAAW,MAAM,MAAM,aAAa;AAChD,UAAM,SAAS;AACT,UAAA,YAAY,QAAQ,MAAM,UAAU,MAAM,GAAG,CAAC,WAAW,MAAM,CAAC;AAEtE,WAAU,uBAAA,UAAA,EAAA,UAAA,YAAa,YAAY,OAAQ,OAApC,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA2C,GAAAA,MAAA;AAAA,EACnD;AAAA,EACA,CAAC,EAAE,UAAU,MAAM,MAAM,aAAa;AACrC,WACE,uBAAA,UAAA,EAAA,UAAA;AAAA,MAAA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,KAHK,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAIP,GAAAA,MAAA;AAAA,EACD;AAAA,EACA;AACD;AAEA,MAAM,WAAW;AAAA,EAChB,CAAC,EAAE,UAAU,WAAW,MAAM,MAAM,aAAa;AAChD,UAAM,MAAM;AACZ,UAAM,SAAS;AAET,UAAA,SAAS,IAAI;AACnB,UAAM,YAAY;AAAA,MACjB,MAAM,IAAI,gBAAgB,MAAM,EAAE,eAAe,QAAQ,cAAc,cAAc,WAAW,GAAG,CAAC;AAAA,MACpG,CAAC,WAAW,QAAQ,KAAK,MAAM;AAAA,IAAA;AAEhC,WAAU,uBAAA,UAAA,EAAA,UAAA,YAAa,YAAY,OAAQ,OAApC,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAA2C,GAAAA,MAAA;AAAA,EACnD;AAAA,EACA,CAAC,EAAE,UAAU,WAAW,MAAM,MAAM,UAAU,QAAQ;AACrD,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,MACA;AAAA,MACA;AAAA,IAAA,KAJK,QAAA,MAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAKP,GAAAA,MAAA;AAAA,EACD;AAAA,EACA;AACD;"}
|