@contember/react-binding 2.0.0-alpha.19 → 2.0.0-alpha.20
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/index.cjs +0 -2
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +0 -2
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/accessorPropagation/BindingOperationsContext.cjs +0 -1
- package/dist/development/src/accessorPropagation/BindingOperationsContext.cjs.map +1 -1
- package/dist/development/src/accessorPropagation/BindingOperationsContext.js +0 -1
- package/dist/development/src/accessorPropagation/BindingOperationsContext.js.map +1 -1
- package/dist/development/src/coreComponents/Field.cjs +3 -4
- package/dist/development/src/coreComponents/Field.cjs.map +1 -1
- package/dist/development/src/coreComponents/Field.js +3 -4
- package/dist/development/src/coreComponents/Field.js.map +1 -1
- package/dist/development/src/helperComponents/helpers/evaluateCondition.cjs +14 -21
- package/dist/development/src/helperComponents/helpers/evaluateCondition.cjs.map +1 -1
- package/dist/development/src/helperComponents/helpers/evaluateCondition.js +14 -21
- package/dist/development/src/helperComponents/helpers/evaluateCondition.js.map +1 -1
- package/dist/production/index.cjs +0 -2
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +0 -2
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/accessorPropagation/BindingOperationsContext.cjs +0 -1
- package/dist/production/src/accessorPropagation/BindingOperationsContext.cjs.map +1 -1
- package/dist/production/src/accessorPropagation/BindingOperationsContext.js +0 -1
- package/dist/production/src/accessorPropagation/BindingOperationsContext.js.map +1 -1
- package/dist/production/src/coreComponents/Field.cjs +1 -2
- package/dist/production/src/coreComponents/Field.cjs.map +1 -1
- package/dist/production/src/coreComponents/Field.js +1 -2
- package/dist/production/src/coreComponents/Field.js.map +1 -1
- package/dist/production/src/helperComponents/helpers/evaluateCondition.cjs +14 -21
- package/dist/production/src/helperComponents/helpers/evaluateCondition.cjs.map +1 -1
- package/dist/production/src/helperComponents/helpers/evaluateCondition.js +14 -21
- package/dist/production/src/helperComponents/helpers/evaluateCondition.js.map +1 -1
- package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
- package/dist/types/accessorPropagation/index.d.ts +0 -1
- package/dist/types/accessorPropagation/index.d.ts.map +1 -1
- package/dist/types/coreComponents/Field.d.ts.map +1 -1
- package/dist/types/helperComponents/helpers/evaluateCondition.d.ts +2 -2
- package/dist/types/helperComponents/helpers/evaluateCondition.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/accessorPropagation/BindingOperationsContext.ts +0 -1
- package/src/accessorPropagation/index.ts +0 -1
- package/src/coreComponents/Field.tsx +0 -2
- package/src/helperComponents/helpers/evaluateCondition.ts +16 -23
- package/tests/cases/unit/helperComponents/evaluateCondition.spec.ts +0 -4
- package/dist/development/src/accessorPropagation/useGetTreeFilters.cjs +0 -6
- package/dist/development/src/accessorPropagation/useGetTreeFilters.cjs.map +0 -1
- package/dist/development/src/accessorPropagation/useGetTreeFilters.js +0 -6
- package/dist/development/src/accessorPropagation/useGetTreeFilters.js.map +0 -1
- package/dist/production/src/accessorPropagation/useGetTreeFilters.cjs +0 -6
- package/dist/production/src/accessorPropagation/useGetTreeFilters.cjs.map +0 -1
- package/dist/production/src/accessorPropagation/useGetTreeFilters.js +0 -6
- package/dist/production/src/accessorPropagation/useGetTreeFilters.js.map +0 -1
- package/dist/types/accessorPropagation/useGetTreeFilters.d.ts +0 -3
- package/dist/types/accessorPropagation/useGetTreeFilters.d.ts.map +0 -1
- package/src/accessorPropagation/useGetTreeFilters.ts +0 -4
|
@@ -34,7 +34,6 @@ const useField = require("./src/accessorPropagation/useField.cjs");
|
|
|
34
34
|
const useGetEntityByKey = require("./src/accessorPropagation/useGetEntityByKey.cjs");
|
|
35
35
|
const useGetEntityListSubTree = require("./src/accessorPropagation/useGetEntityListSubTree.cjs");
|
|
36
36
|
const useGetEntitySubTree = require("./src/accessorPropagation/useGetEntitySubTree.cjs");
|
|
37
|
-
const useGetTreeFilters = require("./src/accessorPropagation/useGetTreeFilters.cjs");
|
|
38
37
|
const usePersist = require("./src/accessorPropagation/usePersist.cjs");
|
|
39
38
|
const useTreeRootId = require("./src/accessorPropagation/useTreeRootId.cjs");
|
|
40
39
|
const addEntityAtIndex = require("./src/accessorSorting/addEntityAtIndex.cjs");
|
|
@@ -103,7 +102,6 @@ exports.useField = useField.useField;
|
|
|
103
102
|
exports.useGetEntityByKey = useGetEntityByKey.useGetEntityByKey;
|
|
104
103
|
exports.useGetEntityListSubTree = useGetEntityListSubTree.useGetEntityListSubTree;
|
|
105
104
|
exports.useGetEntitySubTree = useGetEntitySubTree.useGetEntitySubTree;
|
|
106
|
-
exports.useGetTreeFilters = useGetTreeFilters.useGetTreeFilters;
|
|
107
105
|
exports.usePersist = usePersist.usePersist;
|
|
108
106
|
exports.useTreeRootId = useTreeRootId.useTreeRootId;
|
|
109
107
|
exports.addEntityAtIndex = addEntityAtIndex.addEntityAtIndex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -32,7 +32,6 @@ import { useField } from "./src/accessorPropagation/useField.js";
|
|
|
32
32
|
import { useGetEntityByKey } from "./src/accessorPropagation/useGetEntityByKey.js";
|
|
33
33
|
import { useGetEntityListSubTree } from "./src/accessorPropagation/useGetEntityListSubTree.js";
|
|
34
34
|
import { useGetEntitySubTree } from "./src/accessorPropagation/useGetEntitySubTree.js";
|
|
35
|
-
import { useGetTreeFilters } from "./src/accessorPropagation/useGetTreeFilters.js";
|
|
36
35
|
import { usePersist } from "./src/accessorPropagation/usePersist.js";
|
|
37
36
|
import { useTreeRootId } from "./src/accessorPropagation/useTreeRootId.js";
|
|
38
37
|
import { addEntityAtIndex } from "./src/accessorSorting/addEntityAtIndex.js";
|
|
@@ -131,7 +130,6 @@ export {
|
|
|
131
130
|
useGetEntityByKey,
|
|
132
131
|
useGetEntityListSubTree,
|
|
133
132
|
useGetEntitySubTree,
|
|
134
|
-
useGetTreeFilters,
|
|
135
133
|
useHasEntity,
|
|
136
134
|
useLabelMiddleware,
|
|
137
135
|
useMutationState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -20,7 +20,6 @@ const defaultBindingOperations = Object.freeze({
|
|
|
20
20
|
getEntityListSubTree: getRejecter("retrieve an entity list sub tree"),
|
|
21
21
|
getEntitySubTree: getRejecter("retrieve a single entity sub tree"),
|
|
22
22
|
getEntityByKey: getRejecter("retrieve an entity by key"),
|
|
23
|
-
getTreeFilters: getRejecter("retrieve tree filters"),
|
|
24
23
|
batchDeferredUpdates: getRejecter("batch deferred updates"),
|
|
25
24
|
extendTree: getRejecter("extendTree"),
|
|
26
25
|
persist: getRejecter("persist"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BindingOperationsContext.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/BindingOperationsContext.ts"],"sourcesContent":["import { createContext, ReactNode } from 'react'\nimport type { BindingOperations } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nconst getRejecter = (operation: string) => () => {\n\tthrow new BindingError(\n\t\t`Trying to ${operation} but data binding is unavailable. You likely used a bound component outside ` +\n\t\t\t`<DataBindingProvider /> or it tried to reach its accessor whilst the tree was in an non-interactive state ` +\n\t\t\t`(e.g. still loading).`,\n\t)\n}\n\nexport const defaultBindingOperations = Object.freeze<BindingOperations<ReactNode>>({\n\tget contentClient() {\n\t\treturn getRejecter('retrieve the content api client')()\n\t},\n\tget systemClient() {\n\t\treturn getRejecter('retrieve the system api client')()\n\t},\n\tget tenantClient() {\n\t\treturn getRejecter('retrieve the tenant api client')()\n\t},\n\tgetEntityListSubTree: getRejecter('retrieve an entity list sub tree'),\n\tgetEntitySubTree: getRejecter('retrieve a single entity sub tree'),\n\tgetEntityByKey: getRejecter('retrieve an entity by key'),\n\
|
|
1
|
+
{"version":3,"file":"BindingOperationsContext.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/BindingOperationsContext.ts"],"sourcesContent":["import { createContext, ReactNode } from 'react'\nimport type { BindingOperations } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nconst getRejecter = (operation: string) => () => {\n\tthrow new BindingError(\n\t\t`Trying to ${operation} but data binding is unavailable. You likely used a bound component outside ` +\n\t\t\t`<DataBindingProvider /> or it tried to reach its accessor whilst the tree was in an non-interactive state ` +\n\t\t\t`(e.g. still loading).`,\n\t)\n}\n\nexport const defaultBindingOperations = Object.freeze<BindingOperations<ReactNode>>({\n\tget contentClient() {\n\t\treturn getRejecter('retrieve the content api client')()\n\t},\n\tget systemClient() {\n\t\treturn getRejecter('retrieve the system api client')()\n\t},\n\tget tenantClient() {\n\t\treturn getRejecter('retrieve the tenant api client')()\n\t},\n\tgetEntityListSubTree: getRejecter('retrieve an entity list sub tree'),\n\tgetEntitySubTree: getRejecter('retrieve a single entity sub tree'),\n\tgetEntityByKey: getRejecter('retrieve an entity by key'),\n\tbatchDeferredUpdates: getRejecter('batch deferred updates'),\n\textendTree: getRejecter('extendTree'),\n\tpersist: getRejecter('persist'),\n\tfetchData: getRejecter('fetchData'),\n})\n\nexport const BindingOperationsContext = createContext<BindingOperations<ReactNode>>(defaultBindingOperations)\n"],"names":["BindingError","createContext"],"mappings":";;;;AAIA,MAAM,cAAc,CAAC,cAAsB,MAAM;AAChD,QAAM,IAAIA,QAAA;AAAA,IACT,aAAa,SAAS;AAAA,EAAA;AAIxB;AAEa,MAAA,2BAA2B,OAAO,OAAqC;AAAA,EACnF,IAAI,gBAAgB;AACZ,WAAA,YAAY,iCAAiC;EACrD;AAAA,EACA,IAAI,eAAe;AACX,WAAA,YAAY,gCAAgC;EACpD;AAAA,EACA,IAAI,eAAe;AACX,WAAA,YAAY,gCAAgC;EACpD;AAAA,EACA,sBAAsB,YAAY,kCAAkC;AAAA,EACpE,kBAAkB,YAAY,mCAAmC;AAAA,EACjE,gBAAgB,YAAY,2BAA2B;AAAA,EACvD,sBAAsB,YAAY,wBAAwB;AAAA,EAC1D,YAAY,YAAY,YAAY;AAAA,EACpC,SAAS,YAAY,SAAS;AAAA,EAC9B,WAAW,YAAY,WAAW;AACnC,CAAC;AAEY,MAAA,2BAA2BC,oBAA4C,wBAAwB;;;"}
|
|
@@ -18,7 +18,6 @@ const defaultBindingOperations = Object.freeze({
|
|
|
18
18
|
getEntityListSubTree: getRejecter("retrieve an entity list sub tree"),
|
|
19
19
|
getEntitySubTree: getRejecter("retrieve a single entity sub tree"),
|
|
20
20
|
getEntityByKey: getRejecter("retrieve an entity by key"),
|
|
21
|
-
getTreeFilters: getRejecter("retrieve tree filters"),
|
|
22
21
|
batchDeferredUpdates: getRejecter("batch deferred updates"),
|
|
23
22
|
extendTree: getRejecter("extendTree"),
|
|
24
23
|
persist: getRejecter("persist"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BindingOperationsContext.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/BindingOperationsContext.ts"],"sourcesContent":["import { createContext, ReactNode } from 'react'\nimport type { BindingOperations } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nconst getRejecter = (operation: string) => () => {\n\tthrow new BindingError(\n\t\t`Trying to ${operation} but data binding is unavailable. You likely used a bound component outside ` +\n\t\t\t`<DataBindingProvider /> or it tried to reach its accessor whilst the tree was in an non-interactive state ` +\n\t\t\t`(e.g. still loading).`,\n\t)\n}\n\nexport const defaultBindingOperations = Object.freeze<BindingOperations<ReactNode>>({\n\tget contentClient() {\n\t\treturn getRejecter('retrieve the content api client')()\n\t},\n\tget systemClient() {\n\t\treturn getRejecter('retrieve the system api client')()\n\t},\n\tget tenantClient() {\n\t\treturn getRejecter('retrieve the tenant api client')()\n\t},\n\tgetEntityListSubTree: getRejecter('retrieve an entity list sub tree'),\n\tgetEntitySubTree: getRejecter('retrieve a single entity sub tree'),\n\tgetEntityByKey: getRejecter('retrieve an entity by key'),\n\
|
|
1
|
+
{"version":3,"file":"BindingOperationsContext.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/BindingOperationsContext.ts"],"sourcesContent":["import { createContext, ReactNode } from 'react'\nimport type { BindingOperations } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nconst getRejecter = (operation: string) => () => {\n\tthrow new BindingError(\n\t\t`Trying to ${operation} but data binding is unavailable. You likely used a bound component outside ` +\n\t\t\t`<DataBindingProvider /> or it tried to reach its accessor whilst the tree was in an non-interactive state ` +\n\t\t\t`(e.g. still loading).`,\n\t)\n}\n\nexport const defaultBindingOperations = Object.freeze<BindingOperations<ReactNode>>({\n\tget contentClient() {\n\t\treturn getRejecter('retrieve the content api client')()\n\t},\n\tget systemClient() {\n\t\treturn getRejecter('retrieve the system api client')()\n\t},\n\tget tenantClient() {\n\t\treturn getRejecter('retrieve the tenant api client')()\n\t},\n\tgetEntityListSubTree: getRejecter('retrieve an entity list sub tree'),\n\tgetEntitySubTree: getRejecter('retrieve a single entity sub tree'),\n\tgetEntityByKey: getRejecter('retrieve an entity by key'),\n\tbatchDeferredUpdates: getRejecter('batch deferred updates'),\n\textendTree: getRejecter('extendTree'),\n\tpersist: getRejecter('persist'),\n\tfetchData: getRejecter('fetchData'),\n})\n\nexport const BindingOperationsContext = createContext<BindingOperations<ReactNode>>(defaultBindingOperations)\n"],"names":[],"mappings":";;AAIA,MAAM,cAAc,CAAC,cAAsB,MAAM;AAChD,QAAM,IAAI;AAAA,IACT,aAAa,SAAS;AAAA,EAAA;AAIxB;AAEa,MAAA,2BAA2B,OAAO,OAAqC;AAAA,EACnF,IAAI,gBAAgB;AACZ,WAAA,YAAY,iCAAiC;EACrD;AAAA,EACA,IAAI,eAAe;AACX,WAAA,YAAY,gCAAgC;EACpD;AAAA,EACA,IAAI,eAAe;AACX,WAAA,YAAY,gCAAgC;EACpD;AAAA,EACA,sBAAsB,YAAY,kCAAkC;AAAA,EACpE,kBAAkB,YAAY,mCAAmC;AAAA,EACjE,gBAAgB,YAAY,2BAA2B;AAAA,EACvD,sBAAsB,YAAY,wBAAwB;AAAA,EAC1D,YAAY,YAAY,YAAY;AAAA,EACpC,SAAS,YAAY,SAAS;AAAA,EAC9B,WAAW,YAAY,WAAW;AACnC,CAAC;AAEY,MAAA,2BAA2B,cAA4C,wBAAwB;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
-
const client = require("@contember/client");
|
|
5
4
|
const binding = require("@contember/binding");
|
|
6
5
|
const Component = require("./Component.cjs");
|
|
7
6
|
const useField = require("../accessorPropagation/useField.cjs");
|
|
@@ -11,16 +10,16 @@ const Field = Component.Component(
|
|
|
11
10
|
if (props.format !== void 0) {
|
|
12
11
|
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: props.format(field.value) }, void 0, false, {
|
|
13
12
|
fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/Field.tsx",
|
|
14
|
-
lineNumber:
|
|
13
|
+
lineNumber: 26,
|
|
15
14
|
columnNumber: 11
|
|
16
15
|
}, void 0);
|
|
17
16
|
}
|
|
18
|
-
if (field.value
|
|
17
|
+
if (field.value === null || typeof field.value === "boolean") {
|
|
19
18
|
return null;
|
|
20
19
|
}
|
|
21
20
|
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(jsxDevRuntime.Fragment, { children: field.value }, void 0, false, {
|
|
22
21
|
fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/Field.tsx",
|
|
23
|
-
lineNumber:
|
|
22
|
+
lineNumber: 35,
|
|
24
23
|
columnNumber: 10
|
|
25
24
|
}, void 0);
|
|
26
25
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/Field.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Field.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/Field.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useField } from '../accessorPropagation'\nimport { MarkerFactory } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\nimport { Component } from './Component'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\n\nexport interface FieldBasicProps extends SugaredRelativeSingleField {}\n\nexport interface FieldRuntimeProps<Persisted extends FieldValue = FieldValue> {\n\tformat?: (value: Persisted | null) => ReactNode\n}\n\nexport interface FieldProps<Persisted extends FieldValue = FieldValue>\n\textends FieldBasicProps,\n\tFieldRuntimeProps<Persisted> {}\n\n/**\n * @group Data binding\n */\nexport const Field = Component(\n\t<Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => {\n\t\tconst field = useField<Persisted>(props)\n\n\t\tif (props.format !== undefined) {\n\t\t\treturn <>{props.format(field.value)}</>\n\t\t}\n\n\t\tif (\n\t\t\tfield.value === null ||\n\t\t\ttypeof field.value === 'boolean'\n\t\t) {\n\t\t\treturn null\n\t\t}\n\t\treturn <>{field.value}</>\n\t},\n\t{\n\t\tgenerateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),\n\t\tgenerateEnvironment: (props, environment) => {\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props)\n\t\t},\n\t},\n\t'Field',\n) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement\n"],"names":["Component","useField","jsxDEV","Fragment","this","MarkerFactory","TreeNodeEnvironmentFactory"],"mappings":";;;;;;AAoBO,MAAM,QAAQA,UAAA;AAAA,EACpB,CAA4C,UAAiC;AACtE,UAAA,QAAQC,kBAAoB,KAAK;AAEnC,QAAA,MAAM,WAAW,QAAW;AAC/B,aAAUC,qCAAAC,cAAAA,UAAA,EAAA,UAAA,MAAM,OAAO,MAAM,KAAK,EAA3B,GAAA,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAA6B,GAAAC,MAAA;AAAA,IACrC;AAEA,QACC,MAAM,UAAU,QAChB,OAAO,MAAM,UAAU,WACtB;AACM,aAAA;AAAA,IACR;AACO,WAAAF,8BAAA,OAAAC,cAAA,UAAA,EAAG,gBAAM,MAAT,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAe,GAAAC,MAAA;AAAA,EACvB;AAAA,EACA;AAAA,IACC,oBAAoB,CAAC,OAAO,gBAAgBC,QAAc,cAAA,kBAAkB,OAAO,WAAW;AAAA,IAC9F,qBAAqB,CAAC,OAAO,gBAAgB;AACrC,aAAAC,mCAA2B,0BAA0B,aAAa,KAAK;AAAA,IAC/E;AAAA,EACD;AAAA,EACA;AACD;;"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
|
|
2
|
-
import { GraphQlBuilder } from "@contember/client";
|
|
3
2
|
import { MarkerFactory, TreeNodeEnvironmentFactory } from "@contember/binding";
|
|
4
3
|
import { Component } from "./Component.js";
|
|
5
4
|
import { useField } from "../accessorPropagation/useField.js";
|
|
@@ -9,16 +8,16 @@ const Field = Component(
|
|
|
9
8
|
if (props.format !== void 0) {
|
|
10
9
|
return /* @__PURE__ */ jsxDEV(Fragment, { children: props.format(field.value) }, void 0, false, {
|
|
11
10
|
fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/Field.tsx",
|
|
12
|
-
lineNumber:
|
|
11
|
+
lineNumber: 26,
|
|
13
12
|
columnNumber: 11
|
|
14
13
|
}, void 0);
|
|
15
14
|
}
|
|
16
|
-
if (field.value
|
|
15
|
+
if (field.value === null || typeof field.value === "boolean") {
|
|
17
16
|
return null;
|
|
18
17
|
}
|
|
19
18
|
return /* @__PURE__ */ jsxDEV(Fragment, { children: field.value }, void 0, false, {
|
|
20
19
|
fileName: "/home/runner/work/contember/contember/packages/react-binding/src/coreComponents/Field.tsx",
|
|
21
|
-
lineNumber:
|
|
20
|
+
lineNumber: 35,
|
|
22
21
|
columnNumber: 10
|
|
23
22
|
}, void 0);
|
|
24
23
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sources":["../../../../../packages/react-binding/src/coreComponents/Field.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Field.js","sources":["../../../../../packages/react-binding/src/coreComponents/Field.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useField } from '../accessorPropagation'\nimport { MarkerFactory } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\nimport { Component } from './Component'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\n\nexport interface FieldBasicProps extends SugaredRelativeSingleField {}\n\nexport interface FieldRuntimeProps<Persisted extends FieldValue = FieldValue> {\n\tformat?: (value: Persisted | null) => ReactNode\n}\n\nexport interface FieldProps<Persisted extends FieldValue = FieldValue>\n\textends FieldBasicProps,\n\tFieldRuntimeProps<Persisted> {}\n\n/**\n * @group Data binding\n */\nexport const Field = Component(\n\t<Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => {\n\t\tconst field = useField<Persisted>(props)\n\n\t\tif (props.format !== undefined) {\n\t\t\treturn <>{props.format(field.value)}</>\n\t\t}\n\n\t\tif (\n\t\t\tfield.value === null ||\n\t\t\ttypeof field.value === 'boolean'\n\t\t) {\n\t\t\treturn null\n\t\t}\n\t\treturn <>{field.value}</>\n\t},\n\t{\n\t\tgenerateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),\n\t\tgenerateEnvironment: (props, environment) => {\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props)\n\t\t},\n\t},\n\t'Field',\n) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement\n"],"names":["this"],"mappings":";;;;AAoBO,MAAM,QAAQ;AAAA,EACpB,CAA4C,UAAiC;AACtE,UAAA,QAAQ,SAAoB,KAAK;AAEnC,QAAA,MAAM,WAAW,QAAW;AAC/B,aAAU,uBAAA,UAAA,EAAA,UAAA,MAAM,OAAO,MAAM,KAAK,EAA3B,GAAA,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAA6B,GAAAA,MAAA;AAAA,IACrC;AAEA,QACC,MAAM,UAAU,QAChB,OAAO,MAAM,UAAU,WACtB;AACM,aAAA;AAAA,IACR;AACO,WAAA,uBAAA,UAAA,EAAG,gBAAM,MAAT,GAAA,QAAA,OAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAe,GAAAA,MAAA;AAAA,EACvB;AAAA,EACA;AAAA,IACC,oBAAoB,CAAC,OAAO,gBAAgB,cAAc,kBAAkB,OAAO,WAAW;AAAA,IAC9F,qBAAqB,CAAC,OAAO,gBAAgB;AACrC,aAAA,2BAA2B,0BAA0B,aAAa,KAAK;AAAA,IAC/E;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const client = require("@contember/client");
|
|
4
3
|
const binding = require("@contember/binding");
|
|
5
|
-
const unwrapGraphqlLiteral = (value) => {
|
|
6
|
-
if (value instanceof client.GraphQlLiteral) {
|
|
7
|
-
return value.value;
|
|
8
|
-
}
|
|
9
|
-
return value;
|
|
10
|
-
};
|
|
11
4
|
const evaluateCondition = (value, condition) => {
|
|
12
5
|
const handlers = {
|
|
13
6
|
and: (expr) => expr.every((it) => evaluateCondition(value, it)),
|
|
14
7
|
or: (expr) => expr.some((it) => evaluateCondition(value, it)),
|
|
15
8
|
not: (expr) => !evaluateCondition(value, expr),
|
|
16
|
-
eq: (expr) => value ===
|
|
17
|
-
notEq: (expr) => value !==
|
|
9
|
+
eq: (expr) => value === expr,
|
|
10
|
+
notEq: (expr) => value !== expr,
|
|
18
11
|
isNull: (expr) => value === null === expr,
|
|
19
|
-
in: (expr) => expr.
|
|
20
|
-
notIn: (expr) => !expr.
|
|
21
|
-
lt: (expr) => value !== null && value <
|
|
22
|
-
lte: (expr) => value !== null && value <=
|
|
23
|
-
gt: (expr) => value !== null && value >
|
|
24
|
-
gte: (expr) => value !== null && value >=
|
|
25
|
-
contains: (expr) => typeof value === "string" && value.includes(
|
|
26
|
-
startsWith: (expr) => typeof value === "string" && value.startsWith(
|
|
27
|
-
endsWith: (expr) => typeof value === "string" && value.endsWith(
|
|
28
|
-
containsCI: (expr) => typeof value === "string" && value.toLowerCase().includes(
|
|
29
|
-
startsWithCI: (expr) => typeof value === "string" && value.toLowerCase().startsWith(
|
|
30
|
-
endsWithCI: (expr) => typeof value === "string" && value.toLowerCase().endsWith(
|
|
12
|
+
in: (expr) => expr.includes(value),
|
|
13
|
+
notIn: (expr) => !expr.includes(value),
|
|
14
|
+
lt: (expr) => value !== null && value < expr,
|
|
15
|
+
lte: (expr) => value !== null && value <= expr,
|
|
16
|
+
gt: (expr) => value !== null && value > expr,
|
|
17
|
+
gte: (expr) => value !== null && value >= expr,
|
|
18
|
+
contains: (expr) => typeof value === "string" && value.includes(expr),
|
|
19
|
+
startsWith: (expr) => typeof value === "string" && value.startsWith(expr),
|
|
20
|
+
endsWith: (expr) => typeof value === "string" && value.endsWith(expr),
|
|
21
|
+
containsCI: (expr) => typeof value === "string" && value.toLowerCase().includes(expr.toLowerCase()),
|
|
22
|
+
startsWithCI: (expr) => typeof value === "string" && value.toLowerCase().startsWith(expr.toLowerCase()),
|
|
23
|
+
endsWithCI: (expr) => typeof value === "string" && value.toLowerCase().endsWith(expr.toLowerCase()),
|
|
31
24
|
never: () => false,
|
|
32
25
|
always: () => true,
|
|
33
26
|
// deprecated
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateCondition.cjs","sources":["../../../../../../packages/react-binding/src/helperComponents/helpers/evaluateCondition.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"evaluateCondition.cjs","sources":["../../../../../../packages/react-binding/src/helperComponents/helpers/evaluateCondition.ts"],"sourcesContent":["import { Input } from '@contember/client'\nimport { FieldValue } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nexport const evaluateCondition = (value: FieldValue | null, condition: Input.Condition<Input.ColumnValue>) => {\n\tconst handlers: {\n\t\t[K in keyof Required<Input.Condition<any>>]: (\n\t\t\tparam: Exclude<Input.Condition<any>[K], undefined>,\n\t\t) => boolean\n\t} = {\n\t\tand: expr => expr.every(it => evaluateCondition(value, it)),\n\t\tor: expr => expr.some(it => evaluateCondition(value, it)),\n\t\tnot: expr => !evaluateCondition(value, expr),\n\t\teq: expr => value === expr,\n\t\tnotEq: expr => value !== expr,\n\t\tisNull: expr => (value === null) === expr,\n\t\tin: expr => expr.includes(value),\n\t\tnotIn: expr => !expr.includes(value),\n\t\tlt: expr => value !== null && value < expr,\n\t\tlte: expr => value !== null && value <= expr,\n\t\tgt: expr => value !== null && value > expr,\n\t\tgte: expr => value !== null && value >= expr,\n\t\tcontains: expr => typeof value === 'string' && value.includes(expr),\n\t\tstartsWith: expr => typeof value === 'string' && value.startsWith(expr),\n\t\tendsWith: expr => typeof value === 'string' && value.endsWith(expr),\n\t\tcontainsCI: expr => typeof value === 'string' && value.toLowerCase().includes(expr.toLowerCase()),\n\t\tstartsWithCI: expr => typeof value === 'string' && value.toLowerCase().startsWith(expr.toLowerCase()),\n\t\tendsWithCI: expr => typeof value === 'string' && value.toLowerCase().endsWith(expr.toLowerCase()),\n\t\tnever: () => false,\n\t\talways: () => true,\n\t\t// deprecated\n\t\tnull: expr => (value === null) === expr,\n\t}\n\treturn Object.entries(condition).every(([operator, argument]) => {\n\t\tif (value === undefined) {\n\t\t\treturn true\n\t\t}\n\t\tconst handlerKey = operator as keyof typeof handlers\n\t\tconst handler = handlers[handlerKey]\n\t\tif (!handler) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn (handler as any)(argument)\n\t})\n}\n"],"names":["BindingError"],"mappings":";;;AAIa,MAAA,oBAAoB,CAAC,OAA0B,cAAkD;AAC7G,QAAM,WAIF;AAAA,IACH,KAAK,UAAQ,KAAK,MAAM,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IAC1D,IAAI,UAAQ,KAAK,KAAK,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IACxD,KAAK,CAAA,SAAQ,CAAC,kBAAkB,OAAO,IAAI;AAAA,IAC3C,IAAI,UAAQ,UAAU;AAAA,IACtB,OAAO,UAAQ,UAAU;AAAA,IACzB,QAAQ,CAAS,SAAA,UAAU,SAAU;AAAA,IACrC,IAAI,CAAA,SAAQ,KAAK,SAAS,KAAK;AAAA,IAC/B,OAAO,CAAA,SAAQ,CAAC,KAAK,SAAS,KAAK;AAAA,IACnC,IAAI,CAAA,SAAQ,UAAU,QAAQ,QAAQ;AAAA,IACtC,KAAK,CAAA,SAAQ,UAAU,QAAQ,SAAS;AAAA,IACxC,IAAI,CAAA,SAAQ,UAAU,QAAQ,QAAQ;AAAA,IACtC,KAAK,CAAA,SAAQ,UAAU,QAAQ,SAAS;AAAA,IACxC,UAAU,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI;AAAA,IAClE,YAAY,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,WAAW,IAAI;AAAA,IACtE,UAAU,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI;AAAA,IAClE,YAAY,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,cAAc,SAAS,KAAK,YAAA,CAAa;AAAA,IAChG,cAAc,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,cAAc,WAAW,KAAK,YAAA,CAAa;AAAA,IACpG,YAAY,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,cAAc,SAAS,KAAK,YAAA,CAAa;AAAA,IAChG,OAAO,MAAM;AAAA,IACb,QAAQ,MAAM;AAAA;AAAA,IAEd,MAAM,CAAS,SAAA,UAAU,SAAU;AAAA,EAAA;AAE7B,SAAA,OAAO,QAAQ,SAAS,EAAE,MAAM,CAAC,CAAC,UAAU,QAAQ,MAAM;AAChE,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACA,UAAM,aAAa;AACb,UAAA,UAAU,SAAS,UAAU;AACnC,QAAI,CAAC,SAAS;AACb,YAAM,IAAIA,QAAa,aAAA;AAAA,IACxB;AACA,WAAQ,QAAgB,QAAQ;AAAA,EAAA,CAChC;AACF;;"}
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
import { GraphQlLiteral } from "@contember/client";
|
|
2
1
|
import { BindingError } from "@contember/binding";
|
|
3
|
-
const unwrapGraphqlLiteral = (value) => {
|
|
4
|
-
if (value instanceof GraphQlLiteral) {
|
|
5
|
-
return value.value;
|
|
6
|
-
}
|
|
7
|
-
return value;
|
|
8
|
-
};
|
|
9
2
|
const evaluateCondition = (value, condition) => {
|
|
10
3
|
const handlers = {
|
|
11
4
|
and: (expr) => expr.every((it) => evaluateCondition(value, it)),
|
|
12
5
|
or: (expr) => expr.some((it) => evaluateCondition(value, it)),
|
|
13
6
|
not: (expr) => !evaluateCondition(value, expr),
|
|
14
|
-
eq: (expr) => value ===
|
|
15
|
-
notEq: (expr) => value !==
|
|
7
|
+
eq: (expr) => value === expr,
|
|
8
|
+
notEq: (expr) => value !== expr,
|
|
16
9
|
isNull: (expr) => value === null === expr,
|
|
17
|
-
in: (expr) => expr.
|
|
18
|
-
notIn: (expr) => !expr.
|
|
19
|
-
lt: (expr) => value !== null && value <
|
|
20
|
-
lte: (expr) => value !== null && value <=
|
|
21
|
-
gt: (expr) => value !== null && value >
|
|
22
|
-
gte: (expr) => value !== null && value >=
|
|
23
|
-
contains: (expr) => typeof value === "string" && value.includes(
|
|
24
|
-
startsWith: (expr) => typeof value === "string" && value.startsWith(
|
|
25
|
-
endsWith: (expr) => typeof value === "string" && value.endsWith(
|
|
26
|
-
containsCI: (expr) => typeof value === "string" && value.toLowerCase().includes(
|
|
27
|
-
startsWithCI: (expr) => typeof value === "string" && value.toLowerCase().startsWith(
|
|
28
|
-
endsWithCI: (expr) => typeof value === "string" && value.toLowerCase().endsWith(
|
|
10
|
+
in: (expr) => expr.includes(value),
|
|
11
|
+
notIn: (expr) => !expr.includes(value),
|
|
12
|
+
lt: (expr) => value !== null && value < expr,
|
|
13
|
+
lte: (expr) => value !== null && value <= expr,
|
|
14
|
+
gt: (expr) => value !== null && value > expr,
|
|
15
|
+
gte: (expr) => value !== null && value >= expr,
|
|
16
|
+
contains: (expr) => typeof value === "string" && value.includes(expr),
|
|
17
|
+
startsWith: (expr) => typeof value === "string" && value.startsWith(expr),
|
|
18
|
+
endsWith: (expr) => typeof value === "string" && value.endsWith(expr),
|
|
19
|
+
containsCI: (expr) => typeof value === "string" && value.toLowerCase().includes(expr.toLowerCase()),
|
|
20
|
+
startsWithCI: (expr) => typeof value === "string" && value.toLowerCase().startsWith(expr.toLowerCase()),
|
|
21
|
+
endsWithCI: (expr) => typeof value === "string" && value.toLowerCase().endsWith(expr.toLowerCase()),
|
|
29
22
|
never: () => false,
|
|
30
23
|
always: () => true,
|
|
31
24
|
// deprecated
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateCondition.js","sources":["../../../../../../packages/react-binding/src/helperComponents/helpers/evaluateCondition.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"evaluateCondition.js","sources":["../../../../../../packages/react-binding/src/helperComponents/helpers/evaluateCondition.ts"],"sourcesContent":["import { Input } from '@contember/client'\nimport { FieldValue } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nexport const evaluateCondition = (value: FieldValue | null, condition: Input.Condition<Input.ColumnValue>) => {\n\tconst handlers: {\n\t\t[K in keyof Required<Input.Condition<any>>]: (\n\t\t\tparam: Exclude<Input.Condition<any>[K], undefined>,\n\t\t) => boolean\n\t} = {\n\t\tand: expr => expr.every(it => evaluateCondition(value, it)),\n\t\tor: expr => expr.some(it => evaluateCondition(value, it)),\n\t\tnot: expr => !evaluateCondition(value, expr),\n\t\teq: expr => value === expr,\n\t\tnotEq: expr => value !== expr,\n\t\tisNull: expr => (value === null) === expr,\n\t\tin: expr => expr.includes(value),\n\t\tnotIn: expr => !expr.includes(value),\n\t\tlt: expr => value !== null && value < expr,\n\t\tlte: expr => value !== null && value <= expr,\n\t\tgt: expr => value !== null && value > expr,\n\t\tgte: expr => value !== null && value >= expr,\n\t\tcontains: expr => typeof value === 'string' && value.includes(expr),\n\t\tstartsWith: expr => typeof value === 'string' && value.startsWith(expr),\n\t\tendsWith: expr => typeof value === 'string' && value.endsWith(expr),\n\t\tcontainsCI: expr => typeof value === 'string' && value.toLowerCase().includes(expr.toLowerCase()),\n\t\tstartsWithCI: expr => typeof value === 'string' && value.toLowerCase().startsWith(expr.toLowerCase()),\n\t\tendsWithCI: expr => typeof value === 'string' && value.toLowerCase().endsWith(expr.toLowerCase()),\n\t\tnever: () => false,\n\t\talways: () => true,\n\t\t// deprecated\n\t\tnull: expr => (value === null) === expr,\n\t}\n\treturn Object.entries(condition).every(([operator, argument]) => {\n\t\tif (value === undefined) {\n\t\t\treturn true\n\t\t}\n\t\tconst handlerKey = operator as keyof typeof handlers\n\t\tconst handler = handlers[handlerKey]\n\t\tif (!handler) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn (handler as any)(argument)\n\t})\n}\n"],"names":[],"mappings":";AAIa,MAAA,oBAAoB,CAAC,OAA0B,cAAkD;AAC7G,QAAM,WAIF;AAAA,IACH,KAAK,UAAQ,KAAK,MAAM,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IAC1D,IAAI,UAAQ,KAAK,KAAK,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IACxD,KAAK,CAAA,SAAQ,CAAC,kBAAkB,OAAO,IAAI;AAAA,IAC3C,IAAI,UAAQ,UAAU;AAAA,IACtB,OAAO,UAAQ,UAAU;AAAA,IACzB,QAAQ,CAAS,SAAA,UAAU,SAAU;AAAA,IACrC,IAAI,CAAA,SAAQ,KAAK,SAAS,KAAK;AAAA,IAC/B,OAAO,CAAA,SAAQ,CAAC,KAAK,SAAS,KAAK;AAAA,IACnC,IAAI,CAAA,SAAQ,UAAU,QAAQ,QAAQ;AAAA,IACtC,KAAK,CAAA,SAAQ,UAAU,QAAQ,SAAS;AAAA,IACxC,IAAI,CAAA,SAAQ,UAAU,QAAQ,QAAQ;AAAA,IACtC,KAAK,CAAA,SAAQ,UAAU,QAAQ,SAAS;AAAA,IACxC,UAAU,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI;AAAA,IAClE,YAAY,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,WAAW,IAAI;AAAA,IACtE,UAAU,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI;AAAA,IAClE,YAAY,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,cAAc,SAAS,KAAK,YAAA,CAAa;AAAA,IAChG,cAAc,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,cAAc,WAAW,KAAK,YAAA,CAAa;AAAA,IACpG,YAAY,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,cAAc,SAAS,KAAK,YAAA,CAAa;AAAA,IAChG,OAAO,MAAM;AAAA,IACb,QAAQ,MAAM;AAAA;AAAA,IAEd,MAAM,CAAS,SAAA,UAAU,SAAU;AAAA,EAAA;AAE7B,SAAA,OAAO,QAAQ,SAAS,EAAE,MAAM,CAAC,CAAC,UAAU,QAAQ,MAAM;AAChE,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACA,UAAM,aAAa;AACb,UAAA,UAAU,SAAS,UAAU;AACnC,QAAI,CAAC,SAAS;AACb,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAQ,QAAgB,QAAQ;AAAA,EAAA,CAChC;AACF;"}
|
|
@@ -34,7 +34,6 @@ const useField = require("./src/accessorPropagation/useField.cjs");
|
|
|
34
34
|
const useGetEntityByKey = require("./src/accessorPropagation/useGetEntityByKey.cjs");
|
|
35
35
|
const useGetEntityListSubTree = require("./src/accessorPropagation/useGetEntityListSubTree.cjs");
|
|
36
36
|
const useGetEntitySubTree = require("./src/accessorPropagation/useGetEntitySubTree.cjs");
|
|
37
|
-
const useGetTreeFilters = require("./src/accessorPropagation/useGetTreeFilters.cjs");
|
|
38
37
|
const usePersist = require("./src/accessorPropagation/usePersist.cjs");
|
|
39
38
|
const useTreeRootId = require("./src/accessorPropagation/useTreeRootId.cjs");
|
|
40
39
|
const addEntityAtIndex = require("./src/accessorSorting/addEntityAtIndex.cjs");
|
|
@@ -103,7 +102,6 @@ exports.useField = useField.useField;
|
|
|
103
102
|
exports.useGetEntityByKey = useGetEntityByKey.useGetEntityByKey;
|
|
104
103
|
exports.useGetEntityListSubTree = useGetEntityListSubTree.useGetEntityListSubTree;
|
|
105
104
|
exports.useGetEntitySubTree = useGetEntitySubTree.useGetEntitySubTree;
|
|
106
|
-
exports.useGetTreeFilters = useGetTreeFilters.useGetTreeFilters;
|
|
107
105
|
exports.usePersist = usePersist.usePersist;
|
|
108
106
|
exports.useTreeRootId = useTreeRootId.useTreeRootId;
|
|
109
107
|
exports.addEntityAtIndex = addEntityAtIndex.addEntityAtIndex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/production/index.js
CHANGED
|
@@ -32,7 +32,6 @@ import { useField } from "./src/accessorPropagation/useField.js";
|
|
|
32
32
|
import { useGetEntityByKey } from "./src/accessorPropagation/useGetEntityByKey.js";
|
|
33
33
|
import { useGetEntityListSubTree } from "./src/accessorPropagation/useGetEntityListSubTree.js";
|
|
34
34
|
import { useGetEntitySubTree } from "./src/accessorPropagation/useGetEntitySubTree.js";
|
|
35
|
-
import { useGetTreeFilters } from "./src/accessorPropagation/useGetTreeFilters.js";
|
|
36
35
|
import { usePersist } from "./src/accessorPropagation/usePersist.js";
|
|
37
36
|
import { useTreeRootId } from "./src/accessorPropagation/useTreeRootId.js";
|
|
38
37
|
import { addEntityAtIndex } from "./src/accessorSorting/addEntityAtIndex.js";
|
|
@@ -131,7 +130,6 @@ export {
|
|
|
131
130
|
useGetEntityByKey,
|
|
132
131
|
useGetEntityListSubTree,
|
|
133
132
|
useGetEntitySubTree,
|
|
134
|
-
useGetTreeFilters,
|
|
135
133
|
useHasEntity,
|
|
136
134
|
useLabelMiddleware,
|
|
137
135
|
useMutationState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -20,7 +20,6 @@ const defaultBindingOperations = Object.freeze({
|
|
|
20
20
|
getEntityListSubTree: getRejecter("retrieve an entity list sub tree"),
|
|
21
21
|
getEntitySubTree: getRejecter("retrieve a single entity sub tree"),
|
|
22
22
|
getEntityByKey: getRejecter("retrieve an entity by key"),
|
|
23
|
-
getTreeFilters: getRejecter("retrieve tree filters"),
|
|
24
23
|
batchDeferredUpdates: getRejecter("batch deferred updates"),
|
|
25
24
|
extendTree: getRejecter("extendTree"),
|
|
26
25
|
persist: getRejecter("persist"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BindingOperationsContext.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/BindingOperationsContext.ts"],"sourcesContent":["import { createContext, ReactNode } from 'react'\nimport type { BindingOperations } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nconst getRejecter = (operation: string) => () => {\n\tthrow new BindingError(\n\t\t`Trying to ${operation} but data binding is unavailable. You likely used a bound component outside ` +\n\t\t\t`<DataBindingProvider /> or it tried to reach its accessor whilst the tree was in an non-interactive state ` +\n\t\t\t`(e.g. still loading).`,\n\t)\n}\n\nexport const defaultBindingOperations = Object.freeze<BindingOperations<ReactNode>>({\n\tget contentClient() {\n\t\treturn getRejecter('retrieve the content api client')()\n\t},\n\tget systemClient() {\n\t\treturn getRejecter('retrieve the system api client')()\n\t},\n\tget tenantClient() {\n\t\treturn getRejecter('retrieve the tenant api client')()\n\t},\n\tgetEntityListSubTree: getRejecter('retrieve an entity list sub tree'),\n\tgetEntitySubTree: getRejecter('retrieve a single entity sub tree'),\n\tgetEntityByKey: getRejecter('retrieve an entity by key'),\n\
|
|
1
|
+
{"version":3,"file":"BindingOperationsContext.cjs","sources":["../../../../../packages/react-binding/src/accessorPropagation/BindingOperationsContext.ts"],"sourcesContent":["import { createContext, ReactNode } from 'react'\nimport type { BindingOperations } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nconst getRejecter = (operation: string) => () => {\n\tthrow new BindingError(\n\t\t`Trying to ${operation} but data binding is unavailable. You likely used a bound component outside ` +\n\t\t\t`<DataBindingProvider /> or it tried to reach its accessor whilst the tree was in an non-interactive state ` +\n\t\t\t`(e.g. still loading).`,\n\t)\n}\n\nexport const defaultBindingOperations = Object.freeze<BindingOperations<ReactNode>>({\n\tget contentClient() {\n\t\treturn getRejecter('retrieve the content api client')()\n\t},\n\tget systemClient() {\n\t\treturn getRejecter('retrieve the system api client')()\n\t},\n\tget tenantClient() {\n\t\treturn getRejecter('retrieve the tenant api client')()\n\t},\n\tgetEntityListSubTree: getRejecter('retrieve an entity list sub tree'),\n\tgetEntitySubTree: getRejecter('retrieve a single entity sub tree'),\n\tgetEntityByKey: getRejecter('retrieve an entity by key'),\n\tbatchDeferredUpdates: getRejecter('batch deferred updates'),\n\textendTree: getRejecter('extendTree'),\n\tpersist: getRejecter('persist'),\n\tfetchData: getRejecter('fetchData'),\n})\n\nexport const BindingOperationsContext = createContext<BindingOperations<ReactNode>>(defaultBindingOperations)\n"],"names":["BindingError","createContext"],"mappings":";;;;AAIA,MAAM,cAAc,CAAC,cAAsB,MAAM;AAChD,QAAM,IAAIA,QAAA;AAAA,IACT,aAAa,SAAS;AAAA,EAAA;AAIxB;AAEa,MAAA,2BAA2B,OAAO,OAAqC;AAAA,EACnF,IAAI,gBAAgB;AACZ,WAAA,YAAY,iCAAiC;EACrD;AAAA,EACA,IAAI,eAAe;AACX,WAAA,YAAY,gCAAgC;EACpD;AAAA,EACA,IAAI,eAAe;AACX,WAAA,YAAY,gCAAgC;EACpD;AAAA,EACA,sBAAsB,YAAY,kCAAkC;AAAA,EACpE,kBAAkB,YAAY,mCAAmC;AAAA,EACjE,gBAAgB,YAAY,2BAA2B;AAAA,EACvD,sBAAsB,YAAY,wBAAwB;AAAA,EAC1D,YAAY,YAAY,YAAY;AAAA,EACpC,SAAS,YAAY,SAAS;AAAA,EAC9B,WAAW,YAAY,WAAW;AACnC,CAAC;AAEY,MAAA,2BAA2BC,oBAA4C,wBAAwB;;;"}
|
|
@@ -18,7 +18,6 @@ const defaultBindingOperations = Object.freeze({
|
|
|
18
18
|
getEntityListSubTree: getRejecter("retrieve an entity list sub tree"),
|
|
19
19
|
getEntitySubTree: getRejecter("retrieve a single entity sub tree"),
|
|
20
20
|
getEntityByKey: getRejecter("retrieve an entity by key"),
|
|
21
|
-
getTreeFilters: getRejecter("retrieve tree filters"),
|
|
22
21
|
batchDeferredUpdates: getRejecter("batch deferred updates"),
|
|
23
22
|
extendTree: getRejecter("extendTree"),
|
|
24
23
|
persist: getRejecter("persist"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BindingOperationsContext.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/BindingOperationsContext.ts"],"sourcesContent":["import { createContext, ReactNode } from 'react'\nimport type { BindingOperations } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nconst getRejecter = (operation: string) => () => {\n\tthrow new BindingError(\n\t\t`Trying to ${operation} but data binding is unavailable. You likely used a bound component outside ` +\n\t\t\t`<DataBindingProvider /> or it tried to reach its accessor whilst the tree was in an non-interactive state ` +\n\t\t\t`(e.g. still loading).`,\n\t)\n}\n\nexport const defaultBindingOperations = Object.freeze<BindingOperations<ReactNode>>({\n\tget contentClient() {\n\t\treturn getRejecter('retrieve the content api client')()\n\t},\n\tget systemClient() {\n\t\treturn getRejecter('retrieve the system api client')()\n\t},\n\tget tenantClient() {\n\t\treturn getRejecter('retrieve the tenant api client')()\n\t},\n\tgetEntityListSubTree: getRejecter('retrieve an entity list sub tree'),\n\tgetEntitySubTree: getRejecter('retrieve a single entity sub tree'),\n\tgetEntityByKey: getRejecter('retrieve an entity by key'),\n\
|
|
1
|
+
{"version":3,"file":"BindingOperationsContext.js","sources":["../../../../../packages/react-binding/src/accessorPropagation/BindingOperationsContext.ts"],"sourcesContent":["import { createContext, ReactNode } from 'react'\nimport type { BindingOperations } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nconst getRejecter = (operation: string) => () => {\n\tthrow new BindingError(\n\t\t`Trying to ${operation} but data binding is unavailable. You likely used a bound component outside ` +\n\t\t\t`<DataBindingProvider /> or it tried to reach its accessor whilst the tree was in an non-interactive state ` +\n\t\t\t`(e.g. still loading).`,\n\t)\n}\n\nexport const defaultBindingOperations = Object.freeze<BindingOperations<ReactNode>>({\n\tget contentClient() {\n\t\treturn getRejecter('retrieve the content api client')()\n\t},\n\tget systemClient() {\n\t\treturn getRejecter('retrieve the system api client')()\n\t},\n\tget tenantClient() {\n\t\treturn getRejecter('retrieve the tenant api client')()\n\t},\n\tgetEntityListSubTree: getRejecter('retrieve an entity list sub tree'),\n\tgetEntitySubTree: getRejecter('retrieve a single entity sub tree'),\n\tgetEntityByKey: getRejecter('retrieve an entity by key'),\n\tbatchDeferredUpdates: getRejecter('batch deferred updates'),\n\textendTree: getRejecter('extendTree'),\n\tpersist: getRejecter('persist'),\n\tfetchData: getRejecter('fetchData'),\n})\n\nexport const BindingOperationsContext = createContext<BindingOperations<ReactNode>>(defaultBindingOperations)\n"],"names":[],"mappings":";;AAIA,MAAM,cAAc,CAAC,cAAsB,MAAM;AAChD,QAAM,IAAI;AAAA,IACT,aAAa,SAAS;AAAA,EAAA;AAIxB;AAEa,MAAA,2BAA2B,OAAO,OAAqC;AAAA,EACnF,IAAI,gBAAgB;AACZ,WAAA,YAAY,iCAAiC;EACrD;AAAA,EACA,IAAI,eAAe;AACX,WAAA,YAAY,gCAAgC;EACpD;AAAA,EACA,IAAI,eAAe;AACX,WAAA,YAAY,gCAAgC;EACpD;AAAA,EACA,sBAAsB,YAAY,kCAAkC;AAAA,EACpE,kBAAkB,YAAY,mCAAmC;AAAA,EACjE,gBAAgB,YAAY,2BAA2B;AAAA,EACvD,sBAAsB,YAAY,wBAAwB;AAAA,EAC1D,YAAY,YAAY,YAAY;AAAA,EACpC,SAAS,YAAY,SAAS;AAAA,EAC9B,WAAW,YAAY,WAAW;AACnC,CAAC;AAEY,MAAA,2BAA2B,cAA4C,wBAAwB;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const client = require("@contember/client");
|
|
5
4
|
const binding = require("@contember/binding");
|
|
6
5
|
const Component = require("./Component.cjs");
|
|
7
6
|
const useField = require("../accessorPropagation/useField.cjs");
|
|
@@ -11,7 +10,7 @@ const Field = Component.Component(
|
|
|
11
10
|
if (props.format !== void 0) {
|
|
12
11
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.format(field.value) });
|
|
13
12
|
}
|
|
14
|
-
if (field.value
|
|
13
|
+
if (field.value === null || typeof field.value === "boolean") {
|
|
15
14
|
return null;
|
|
16
15
|
}
|
|
17
16
|
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: field.value });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/Field.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Field.cjs","sources":["../../../../../packages/react-binding/src/coreComponents/Field.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useField } from '../accessorPropagation'\nimport { MarkerFactory } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\nimport { Component } from './Component'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\n\nexport interface FieldBasicProps extends SugaredRelativeSingleField {}\n\nexport interface FieldRuntimeProps<Persisted extends FieldValue = FieldValue> {\n\tformat?: (value: Persisted | null) => ReactNode\n}\n\nexport interface FieldProps<Persisted extends FieldValue = FieldValue>\n\textends FieldBasicProps,\n\tFieldRuntimeProps<Persisted> {}\n\n/**\n * @group Data binding\n */\nexport const Field = Component(\n\t<Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => {\n\t\tconst field = useField<Persisted>(props)\n\n\t\tif (props.format !== undefined) {\n\t\t\treturn <>{props.format(field.value)}</>\n\t\t}\n\n\t\tif (\n\t\t\tfield.value === null ||\n\t\t\ttypeof field.value === 'boolean'\n\t\t) {\n\t\t\treturn null\n\t\t}\n\t\treturn <>{field.value}</>\n\t},\n\t{\n\t\tgenerateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),\n\t\tgenerateEnvironment: (props, environment) => {\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props)\n\t\t},\n\t},\n\t'Field',\n) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement\n"],"names":["Component","useField","jsx","Fragment","MarkerFactory","TreeNodeEnvironmentFactory"],"mappings":";;;;;;AAoBO,MAAM,QAAQA,UAAA;AAAA,EACpB,CAA4C,UAAiC;AACtE,UAAA,QAAQC,kBAAoB,KAAK;AAEnC,QAAA,MAAM,WAAW,QAAW;AAC/B,aAAUC,2BAAA,IAAAC,qBAAA,EAAA,UAAA,MAAM,OAAO,MAAM,KAAK,EAAE,CAAA;AAAA,IACrC;AAEA,QACC,MAAM,UAAU,QAChB,OAAO,MAAM,UAAU,WACtB;AACM,aAAA;AAAA,IACR;AACO,WAAAD,2BAAAA,IAAAC,WAAAA,UAAA,EAAG,gBAAM,MAAM,CAAA;AAAA,EACvB;AAAA,EACA;AAAA,IACC,oBAAoB,CAAC,OAAO,gBAAgBC,QAAc,cAAA,kBAAkB,OAAO,WAAW;AAAA,IAC9F,qBAAqB,CAAC,OAAO,gBAAgB;AACrC,aAAAC,mCAA2B,0BAA0B,aAAa,KAAK;AAAA,IAC/E;AAAA,EACD;AAAA,EACA;AACD;;"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { GraphQlBuilder } from "@contember/client";
|
|
3
2
|
import { MarkerFactory, TreeNodeEnvironmentFactory } from "@contember/binding";
|
|
4
3
|
import { Component } from "./Component.js";
|
|
5
4
|
import { useField } from "../accessorPropagation/useField.js";
|
|
@@ -9,7 +8,7 @@ const Field = Component(
|
|
|
9
8
|
if (props.format !== void 0) {
|
|
10
9
|
return /* @__PURE__ */ jsx(Fragment, { children: props.format(field.value) });
|
|
11
10
|
}
|
|
12
|
-
if (field.value
|
|
11
|
+
if (field.value === null || typeof field.value === "boolean") {
|
|
13
12
|
return null;
|
|
14
13
|
}
|
|
15
14
|
return /* @__PURE__ */ jsx(Fragment, { children: field.value });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","sources":["../../../../../packages/react-binding/src/coreComponents/Field.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Field.js","sources":["../../../../../packages/react-binding/src/coreComponents/Field.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useField } from '../accessorPropagation'\nimport { MarkerFactory } from '@contember/binding'\nimport type { FieldValue, SugaredRelativeSingleField } from '@contember/binding'\nimport { Component } from './Component'\nimport { TreeNodeEnvironmentFactory } from '@contember/binding'\n\nexport interface FieldBasicProps extends SugaredRelativeSingleField {}\n\nexport interface FieldRuntimeProps<Persisted extends FieldValue = FieldValue> {\n\tformat?: (value: Persisted | null) => ReactNode\n}\n\nexport interface FieldProps<Persisted extends FieldValue = FieldValue>\n\textends FieldBasicProps,\n\tFieldRuntimeProps<Persisted> {}\n\n/**\n * @group Data binding\n */\nexport const Field = Component(\n\t<Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => {\n\t\tconst field = useField<Persisted>(props)\n\n\t\tif (props.format !== undefined) {\n\t\t\treturn <>{props.format(field.value)}</>\n\t\t}\n\n\t\tif (\n\t\t\tfield.value === null ||\n\t\t\ttypeof field.value === 'boolean'\n\t\t) {\n\t\t\treturn null\n\t\t}\n\t\treturn <>{field.value}</>\n\t},\n\t{\n\t\tgenerateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),\n\t\tgenerateEnvironment: (props, environment) => {\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props)\n\t\t},\n\t},\n\t'Field',\n) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement\n"],"names":[],"mappings":";;;;AAoBO,MAAM,QAAQ;AAAA,EACpB,CAA4C,UAAiC;AACtE,UAAA,QAAQ,SAAoB,KAAK;AAEnC,QAAA,MAAM,WAAW,QAAW;AAC/B,aAAU,oBAAA,UAAA,EAAA,UAAA,MAAM,OAAO,MAAM,KAAK,EAAE,CAAA;AAAA,IACrC;AAEA,QACC,MAAM,UAAU,QAChB,OAAO,MAAM,UAAU,WACtB;AACM,aAAA;AAAA,IACR;AACO,WAAA,oBAAA,UAAA,EAAG,gBAAM,MAAM,CAAA;AAAA,EACvB;AAAA,EACA;AAAA,IACC,oBAAoB,CAAC,OAAO,gBAAgB,cAAc,kBAAkB,OAAO,WAAW;AAAA,IAC9F,qBAAqB,CAAC,OAAO,gBAAgB;AACrC,aAAA,2BAA2B,0BAA0B,aAAa,KAAK;AAAA,IAC/E;AAAA,EACD;AAAA,EACA;AACD;"}
|
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const client = require("@contember/client");
|
|
4
3
|
const binding = require("@contember/binding");
|
|
5
|
-
const unwrapGraphqlLiteral = (value) => {
|
|
6
|
-
if (value instanceof client.GraphQlLiteral) {
|
|
7
|
-
return value.value;
|
|
8
|
-
}
|
|
9
|
-
return value;
|
|
10
|
-
};
|
|
11
4
|
const evaluateCondition = (value, condition) => {
|
|
12
5
|
const handlers = {
|
|
13
6
|
and: (expr) => expr.every((it) => evaluateCondition(value, it)),
|
|
14
7
|
or: (expr) => expr.some((it) => evaluateCondition(value, it)),
|
|
15
8
|
not: (expr) => !evaluateCondition(value, expr),
|
|
16
|
-
eq: (expr) => value ===
|
|
17
|
-
notEq: (expr) => value !==
|
|
9
|
+
eq: (expr) => value === expr,
|
|
10
|
+
notEq: (expr) => value !== expr,
|
|
18
11
|
isNull: (expr) => value === null === expr,
|
|
19
|
-
in: (expr) => expr.
|
|
20
|
-
notIn: (expr) => !expr.
|
|
21
|
-
lt: (expr) => value !== null && value <
|
|
22
|
-
lte: (expr) => value !== null && value <=
|
|
23
|
-
gt: (expr) => value !== null && value >
|
|
24
|
-
gte: (expr) => value !== null && value >=
|
|
25
|
-
contains: (expr) => typeof value === "string" && value.includes(
|
|
26
|
-
startsWith: (expr) => typeof value === "string" && value.startsWith(
|
|
27
|
-
endsWith: (expr) => typeof value === "string" && value.endsWith(
|
|
28
|
-
containsCI: (expr) => typeof value === "string" && value.toLowerCase().includes(
|
|
29
|
-
startsWithCI: (expr) => typeof value === "string" && value.toLowerCase().startsWith(
|
|
30
|
-
endsWithCI: (expr) => typeof value === "string" && value.toLowerCase().endsWith(
|
|
12
|
+
in: (expr) => expr.includes(value),
|
|
13
|
+
notIn: (expr) => !expr.includes(value),
|
|
14
|
+
lt: (expr) => value !== null && value < expr,
|
|
15
|
+
lte: (expr) => value !== null && value <= expr,
|
|
16
|
+
gt: (expr) => value !== null && value > expr,
|
|
17
|
+
gte: (expr) => value !== null && value >= expr,
|
|
18
|
+
contains: (expr) => typeof value === "string" && value.includes(expr),
|
|
19
|
+
startsWith: (expr) => typeof value === "string" && value.startsWith(expr),
|
|
20
|
+
endsWith: (expr) => typeof value === "string" && value.endsWith(expr),
|
|
21
|
+
containsCI: (expr) => typeof value === "string" && value.toLowerCase().includes(expr.toLowerCase()),
|
|
22
|
+
startsWithCI: (expr) => typeof value === "string" && value.toLowerCase().startsWith(expr.toLowerCase()),
|
|
23
|
+
endsWithCI: (expr) => typeof value === "string" && value.toLowerCase().endsWith(expr.toLowerCase()),
|
|
31
24
|
never: () => false,
|
|
32
25
|
always: () => true,
|
|
33
26
|
// deprecated
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluateCondition.cjs","sources":["../../../../../../packages/react-binding/src/helperComponents/helpers/evaluateCondition.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"evaluateCondition.cjs","sources":["../../../../../../packages/react-binding/src/helperComponents/helpers/evaluateCondition.ts"],"sourcesContent":["import { Input } from '@contember/client'\nimport { FieldValue } from '@contember/binding'\nimport { BindingError } from '@contember/binding'\n\nexport const evaluateCondition = (value: FieldValue | null, condition: Input.Condition<Input.ColumnValue>) => {\n\tconst handlers: {\n\t\t[K in keyof Required<Input.Condition<any>>]: (\n\t\t\tparam: Exclude<Input.Condition<any>[K], undefined>,\n\t\t) => boolean\n\t} = {\n\t\tand: expr => expr.every(it => evaluateCondition(value, it)),\n\t\tor: expr => expr.some(it => evaluateCondition(value, it)),\n\t\tnot: expr => !evaluateCondition(value, expr),\n\t\teq: expr => value === expr,\n\t\tnotEq: expr => value !== expr,\n\t\tisNull: expr => (value === null) === expr,\n\t\tin: expr => expr.includes(value),\n\t\tnotIn: expr => !expr.includes(value),\n\t\tlt: expr => value !== null && value < expr,\n\t\tlte: expr => value !== null && value <= expr,\n\t\tgt: expr => value !== null && value > expr,\n\t\tgte: expr => value !== null && value >= expr,\n\t\tcontains: expr => typeof value === 'string' && value.includes(expr),\n\t\tstartsWith: expr => typeof value === 'string' && value.startsWith(expr),\n\t\tendsWith: expr => typeof value === 'string' && value.endsWith(expr),\n\t\tcontainsCI: expr => typeof value === 'string' && value.toLowerCase().includes(expr.toLowerCase()),\n\t\tstartsWithCI: expr => typeof value === 'string' && value.toLowerCase().startsWith(expr.toLowerCase()),\n\t\tendsWithCI: expr => typeof value === 'string' && value.toLowerCase().endsWith(expr.toLowerCase()),\n\t\tnever: () => false,\n\t\talways: () => true,\n\t\t// deprecated\n\t\tnull: expr => (value === null) === expr,\n\t}\n\treturn Object.entries(condition).every(([operator, argument]) => {\n\t\tif (value === undefined) {\n\t\t\treturn true\n\t\t}\n\t\tconst handlerKey = operator as keyof typeof handlers\n\t\tconst handler = handlers[handlerKey]\n\t\tif (!handler) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn (handler as any)(argument)\n\t})\n}\n"],"names":["BindingError"],"mappings":";;;AAIa,MAAA,oBAAoB,CAAC,OAA0B,cAAkD;AAC7G,QAAM,WAIF;AAAA,IACH,KAAK,UAAQ,KAAK,MAAM,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IAC1D,IAAI,UAAQ,KAAK,KAAK,QAAM,kBAAkB,OAAO,EAAE,CAAC;AAAA,IACxD,KAAK,CAAA,SAAQ,CAAC,kBAAkB,OAAO,IAAI;AAAA,IAC3C,IAAI,UAAQ,UAAU;AAAA,IACtB,OAAO,UAAQ,UAAU;AAAA,IACzB,QAAQ,CAAS,SAAA,UAAU,SAAU;AAAA,IACrC,IAAI,CAAA,SAAQ,KAAK,SAAS,KAAK;AAAA,IAC/B,OAAO,CAAA,SAAQ,CAAC,KAAK,SAAS,KAAK;AAAA,IACnC,IAAI,CAAA,SAAQ,UAAU,QAAQ,QAAQ;AAAA,IACtC,KAAK,CAAA,SAAQ,UAAU,QAAQ,SAAS;AAAA,IACxC,IAAI,CAAA,SAAQ,UAAU,QAAQ,QAAQ;AAAA,IACtC,KAAK,CAAA,SAAQ,UAAU,QAAQ,SAAS;AAAA,IACxC,UAAU,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI;AAAA,IAClE,YAAY,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,WAAW,IAAI;AAAA,IACtE,UAAU,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,SAAS,IAAI;AAAA,IAClE,YAAY,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,cAAc,SAAS,KAAK,YAAA,CAAa;AAAA,IAChG,cAAc,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,cAAc,WAAW,KAAK,YAAA,CAAa;AAAA,IACpG,YAAY,CAAQ,SAAA,OAAO,UAAU,YAAY,MAAM,cAAc,SAAS,KAAK,YAAA,CAAa;AAAA,IAChG,OAAO,MAAM;AAAA,IACb,QAAQ,MAAM;AAAA;AAAA,IAEd,MAAM,CAAS,SAAA,UAAU,SAAU;AAAA,EAAA;AAE7B,SAAA,OAAO,QAAQ,SAAS,EAAE,MAAM,CAAC,CAAC,UAAU,QAAQ,MAAM;AAChE,QAAI,UAAU,QAAW;AACjB,aAAA;AAAA,IACR;AACA,UAAM,aAAa;AACb,UAAA,UAAU,SAAS,UAAU;AACnC,QAAI,CAAC,SAAS;AACb,YAAM,IAAIA,QAAa,aAAA;AAAA,IACxB;AACA,WAAQ,QAAgB,QAAQ;AAAA,EAAA,CAChC;AACF;;"}
|