@contember/interface 2.1.0-alpha.37 → 2.1.0-alpha.39
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 +43 -0
- package/dist/development/index.cjs.map +1 -0
- package/dist/development/index.js +22 -0
- package/dist/development/index.js.map +1 -0
- package/dist/development/src/bootstrap/ApplicationEntrypoint.cjs +67 -0
- package/dist/development/src/bootstrap/ApplicationEntrypoint.cjs.map +1 -0
- package/dist/development/src/bootstrap/ApplicationEntrypoint.js +67 -0
- package/dist/development/src/bootstrap/ApplicationEntrypoint.js.map +1 -0
- package/dist/development/src/bootstrap/DataViewPageNameKeyProvider.cjs +15 -0
- package/dist/development/src/bootstrap/DataViewPageNameKeyProvider.cjs.map +1 -0
- package/dist/development/src/bootstrap/DataViewPageNameKeyProvider.js +15 -0
- package/dist/development/src/bootstrap/DataViewPageNameKeyProvider.js.map +1 -0
- package/dist/development/src/components/binding/ClearFieldTrigger.cjs +25 -0
- package/dist/development/src/components/binding/ClearFieldTrigger.cjs.map +1 -0
- package/dist/development/src/components/binding/ClearFieldTrigger.js +25 -0
- package/dist/development/src/components/binding/ClearFieldTrigger.js.map +1 -0
- package/dist/development/src/components/binding/DisconnectEntityTrigger.cjs +52 -0
- package/dist/development/src/components/binding/DisconnectEntityTrigger.cjs.map +1 -0
- package/dist/development/src/components/binding/DisconnectEntityTrigger.js +52 -0
- package/dist/development/src/components/binding/DisconnectEntityTrigger.js.map +1 -0
- package/dist/development/src/components/binding/EntityBeforePersist.cjs +9 -0
- package/dist/development/src/components/binding/EntityBeforePersist.cjs.map +1 -0
- package/dist/development/src/components/binding/EntityBeforePersist.js +9 -0
- package/dist/development/src/components/binding/EntityBeforePersist.js.map +1 -0
- package/dist/development/src/components/binding/RedirectOnPersist.cjs +16 -0
- package/dist/development/src/components/binding/RedirectOnPersist.cjs.map +1 -0
- package/dist/development/src/components/binding/RedirectOnPersist.js +16 -0
- package/dist/development/src/components/binding/RedirectOnPersist.js.map +1 -0
- package/dist/development/src/hooks/useBlockNavigationOnDirtyState.cjs +36 -0
- package/dist/development/src/hooks/useBlockNavigationOnDirtyState.cjs.map +1 -0
- package/dist/development/src/hooks/useBlockNavigationOnDirtyState.js +36 -0
- package/dist/development/src/hooks/useBlockNavigationOnDirtyState.js.map +1 -0
- package/dist/development/src/hooks/useIsApplicationOutdated.cjs +55 -0
- package/dist/development/src/hooks/useIsApplicationOutdated.cjs.map +1 -0
- package/dist/development/src/hooks/useIsApplicationOutdated.js +55 -0
- package/dist/development/src/hooks/useIsApplicationOutdated.js.map +1 -0
- package/dist/production/index.cjs +43 -0
- package/dist/production/index.cjs.map +1 -0
- package/dist/production/index.js +22 -0
- package/dist/production/index.js.map +1 -0
- package/dist/production/src/bootstrap/ApplicationEntrypoint.cjs +35 -0
- package/dist/production/src/bootstrap/ApplicationEntrypoint.cjs.map +1 -0
- package/dist/production/src/bootstrap/ApplicationEntrypoint.js +35 -0
- package/dist/production/src/bootstrap/ApplicationEntrypoint.js.map +1 -0
- package/dist/production/src/bootstrap/DataViewPageNameKeyProvider.cjs +11 -0
- package/dist/production/src/bootstrap/DataViewPageNameKeyProvider.cjs.map +1 -0
- package/dist/production/src/bootstrap/DataViewPageNameKeyProvider.js +11 -0
- package/dist/production/src/bootstrap/DataViewPageNameKeyProvider.js.map +1 -0
- package/dist/production/src/components/binding/ClearFieldTrigger.cjs +17 -0
- package/dist/production/src/components/binding/ClearFieldTrigger.cjs.map +1 -0
- package/dist/production/src/components/binding/ClearFieldTrigger.js +17 -0
- package/dist/production/src/components/binding/ClearFieldTrigger.js.map +1 -0
- package/dist/production/src/components/binding/DisconnectEntityTrigger.cjs +44 -0
- package/dist/production/src/components/binding/DisconnectEntityTrigger.cjs.map +1 -0
- package/dist/production/src/components/binding/DisconnectEntityTrigger.js +44 -0
- package/dist/production/src/components/binding/DisconnectEntityTrigger.js.map +1 -0
- package/dist/production/src/components/binding/EntityBeforePersist.cjs +9 -0
- package/dist/production/src/components/binding/EntityBeforePersist.cjs.map +1 -0
- package/dist/production/src/components/binding/EntityBeforePersist.js +9 -0
- package/dist/production/src/components/binding/EntityBeforePersist.js.map +1 -0
- package/dist/production/src/components/binding/RedirectOnPersist.cjs +16 -0
- package/dist/production/src/components/binding/RedirectOnPersist.cjs.map +1 -0
- package/dist/production/src/components/binding/RedirectOnPersist.js +16 -0
- package/dist/production/src/components/binding/RedirectOnPersist.js.map +1 -0
- package/dist/production/src/hooks/useBlockNavigationOnDirtyState.cjs +36 -0
- package/dist/production/src/hooks/useBlockNavigationOnDirtyState.cjs.map +1 -0
- package/dist/production/src/hooks/useBlockNavigationOnDirtyState.js +36 -0
- package/dist/production/src/hooks/useBlockNavigationOnDirtyState.js.map +1 -0
- package/dist/production/src/hooks/useIsApplicationOutdated.cjs +55 -0
- package/dist/production/src/hooks/useIsApplicationOutdated.cjs.map +1 -0
- package/dist/production/src/hooks/useIsApplicationOutdated.js +55 -0
- package/dist/production/src/hooks/useIsApplicationOutdated.js.map +1 -0
- package/dist/types/bootstrap/ApplicationEntrypoint.d.ts +16 -0
- package/dist/types/bootstrap/ApplicationEntrypoint.d.ts.map +1 -0
- package/dist/types/bootstrap/DataViewPageNameKeyProvider.d.ts +5 -0
- package/dist/types/bootstrap/DataViewPageNameKeyProvider.d.ts.map +1 -0
- package/dist/types/bootstrap/index.d.ts +2 -0
- package/dist/types/bootstrap/index.d.ts.map +1 -0
- package/dist/types/components/binding/ClearFieldTrigger.d.ts +8 -0
- package/dist/types/components/binding/ClearFieldTrigger.d.ts.map +1 -0
- package/dist/types/components/binding/DisconnectEntityTrigger.d.ts +11 -0
- package/dist/types/components/binding/DisconnectEntityTrigger.d.ts.map +1 -0
- package/dist/types/components/binding/EntityBeforePersist.d.ts +5 -0
- package/dist/types/components/binding/EntityBeforePersist.d.ts.map +1 -0
- package/dist/types/components/binding/RedirectOnPersist.d.ts +7 -0
- package/dist/types/components/binding/RedirectOnPersist.d.ts.map +1 -0
- package/dist/types/components/binding/index.d.ts +5 -0
- package/dist/types/components/binding/index.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +3 -0
- package/dist/types/hooks/index.d.ts.map +1 -0
- package/dist/types/hooks/useBlockNavigationOnDirtyState.d.ts +7 -0
- package/dist/types/hooks/useBlockNavigationOnDirtyState.d.ts.map +1 -0
- package/dist/types/hooks/useIsApplicationOutdated.d.ts +4 -0
- package/dist/types/hooks/useIsApplicationOutdated.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +13 -13
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactRouting = require("@contember/react-routing");
|
|
4
|
+
const reactBinding = require("@contember/react-binding");
|
|
5
|
+
const reactIdentity = require("@contember/react-identity");
|
|
6
|
+
const reactDevbar = require("@contember/react-devbar");
|
|
7
|
+
const ApplicationEntrypoint = require("./src/bootstrap/ApplicationEntrypoint.cjs");
|
|
8
|
+
const ClearFieldTrigger = require("./src/components/binding/ClearFieldTrigger.cjs");
|
|
9
|
+
const DisconnectEntityTrigger = require("./src/components/binding/DisconnectEntityTrigger.cjs");
|
|
10
|
+
const EntityBeforePersist = require("./src/components/binding/EntityBeforePersist.cjs");
|
|
11
|
+
const RedirectOnPersist = require("./src/components/binding/RedirectOnPersist.cjs");
|
|
12
|
+
const useBlockNavigationOnDirtyState = require("./src/hooks/useBlockNavigationOnDirtyState.cjs");
|
|
13
|
+
const useIsApplicationOutdated = require("./src/hooks/useIsApplicationOutdated.cjs");
|
|
14
|
+
Object.defineProperty(exports, "createErrorHandler", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: () => reactDevbar.createErrorHandler
|
|
17
|
+
});
|
|
18
|
+
exports.ApplicationEntrypoint = ApplicationEntrypoint.ApplicationEntrypoint;
|
|
19
|
+
exports.ClearFieldTrigger = ClearFieldTrigger.ClearFieldTrigger;
|
|
20
|
+
exports.DisconnectEntityTrigger = DisconnectEntityTrigger.DisconnectEntityTrigger;
|
|
21
|
+
exports.EntityBeforePersist = EntityBeforePersist.EntityBeforePersist;
|
|
22
|
+
exports.RedirectOnPersist = RedirectOnPersist.RedirectOnPersist;
|
|
23
|
+
exports.useBlockNavigationOnDirtyState = useBlockNavigationOnDirtyState.useBlockNavigationOnDirtyState;
|
|
24
|
+
exports.useIsApplicationOutdated = useIsApplicationOutdated.useIsApplicationOutdated;
|
|
25
|
+
Object.keys(reactRouting).forEach((k) => {
|
|
26
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: () => reactRouting[k]
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
Object.keys(reactBinding).forEach((k) => {
|
|
32
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: () => reactBinding[k]
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
Object.keys(reactIdentity).forEach((k) => {
|
|
38
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: () => reactIdentity[k]
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from "@contember/react-routing";
|
|
2
|
+
export * from "@contember/react-binding";
|
|
3
|
+
export * from "@contember/react-identity";
|
|
4
|
+
import { createErrorHandler } from "@contember/react-devbar";
|
|
5
|
+
import { ApplicationEntrypoint } from "./src/bootstrap/ApplicationEntrypoint.js";
|
|
6
|
+
import { ClearFieldTrigger } from "./src/components/binding/ClearFieldTrigger.js";
|
|
7
|
+
import { DisconnectEntityTrigger } from "./src/components/binding/DisconnectEntityTrigger.js";
|
|
8
|
+
import { EntityBeforePersist } from "./src/components/binding/EntityBeforePersist.js";
|
|
9
|
+
import { RedirectOnPersist } from "./src/components/binding/RedirectOnPersist.js";
|
|
10
|
+
import { useBlockNavigationOnDirtyState } from "./src/hooks/useBlockNavigationOnDirtyState.js";
|
|
11
|
+
import { useIsApplicationOutdated } from "./src/hooks/useIsApplicationOutdated.js";
|
|
12
|
+
export {
|
|
13
|
+
ApplicationEntrypoint,
|
|
14
|
+
ClearFieldTrigger,
|
|
15
|
+
DisconnectEntityTrigger,
|
|
16
|
+
EntityBeforePersist,
|
|
17
|
+
RedirectOnPersist,
|
|
18
|
+
createErrorHandler,
|
|
19
|
+
useBlockNavigationOnDirtyState,
|
|
20
|
+
useIsApplicationOutdated
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const reactBinding = require("@contember/react-binding");
|
|
5
|
+
const reactClient = require("@contember/react-client");
|
|
6
|
+
const reactRouting = require("@contember/react-routing");
|
|
7
|
+
const DataViewPageNameKeyProvider = require("./DataViewPageNameKeyProvider.cjs");
|
|
8
|
+
const reactIdentity = require("@contember/react-identity");
|
|
9
|
+
const validateProps = (props) => {
|
|
10
|
+
if (typeof props.apiBaseUrl !== "string") {
|
|
11
|
+
throw new Error(`The ENV variables haven't been set. Check your \`.env.development.local\` file.`);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const ApplicationEntrypoint = (props) => {
|
|
15
|
+
validateProps(props);
|
|
16
|
+
const rootEnv = props.environment ?? reactBinding.Environment.create();
|
|
17
|
+
const routing = {
|
|
18
|
+
basePath: props.basePath,
|
|
19
|
+
routes: props.routes ?? { index: { path: "/" } },
|
|
20
|
+
defaultDimensions: rootEnv.getAllDimensions()
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.EnvironmentContext.Provider, { value: rootEnv, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactRouting.RoutingProvider, { ...routing, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
23
|
+
reactClient.ContemberClient,
|
|
24
|
+
{
|
|
25
|
+
apiBaseUrl: props.apiBaseUrl,
|
|
26
|
+
sessionToken: props.sessionToken,
|
|
27
|
+
loginToken: props.loginToken,
|
|
28
|
+
project: props.project,
|
|
29
|
+
stage: props.stage,
|
|
30
|
+
children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.EnvironmentExtensionProvider, { extension: reactIdentity.projectEnvironmentExtension, state: props.project ?? null, children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(DataViewPageNameKeyProvider.DataViewPageNameKeyProvider, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactIdentity.IdentityProvider, { children: /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactIdentity.IdentityEnvironmentProvider, { children: props.children }, void 0, false, {
|
|
31
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
32
|
+
lineNumber: 49,
|
|
33
|
+
columnNumber: 9
|
|
34
|
+
}, void 0) }, void 0, false, {
|
|
35
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
36
|
+
lineNumber: 48,
|
|
37
|
+
columnNumber: 8
|
|
38
|
+
}, void 0) }, void 0, false, {
|
|
39
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
40
|
+
lineNumber: 47,
|
|
41
|
+
columnNumber: 7
|
|
42
|
+
}, void 0) }, void 0, false, {
|
|
43
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
44
|
+
lineNumber: 46,
|
|
45
|
+
columnNumber: 6
|
|
46
|
+
}, void 0)
|
|
47
|
+
},
|
|
48
|
+
void 0,
|
|
49
|
+
false,
|
|
50
|
+
{
|
|
51
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
52
|
+
lineNumber: 39,
|
|
53
|
+
columnNumber: 5
|
|
54
|
+
},
|
|
55
|
+
void 0
|
|
56
|
+
) }, void 0, false, {
|
|
57
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
58
|
+
lineNumber: 38,
|
|
59
|
+
columnNumber: 4
|
|
60
|
+
}, void 0) }, void 0, false, {
|
|
61
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
62
|
+
lineNumber: 37,
|
|
63
|
+
columnNumber: 3
|
|
64
|
+
}, void 0);
|
|
65
|
+
};
|
|
66
|
+
exports.ApplicationEntrypoint = ApplicationEntrypoint;
|
|
67
|
+
//# sourceMappingURL=ApplicationEntrypoint.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicationEntrypoint.cjs","sources":["../../../../../packages/interface/src/bootstrap/ApplicationEntrypoint.tsx"],"sourcesContent":["import { Environment, EnvironmentContext, EnvironmentExtensionProvider } from '@contember/react-binding'\nimport { ContemberClient, ContemberClientProps } from '@contember/react-client'\nimport { ReactNode } from 'react'\nimport { RouteMap, RoutingContextValue, RoutingProvider } from '@contember/react-routing'\nimport { DataViewPageNameKeyProvider } from './DataViewPageNameKeyProvider'\nimport { IdentityEnvironmentProvider, IdentityProvider, projectEnvironmentExtension } from '@contember/react-identity'\n\nexport interface ApplicationEntrypointProps extends ContemberClientProps {\n\tbasePath: string\n\tsessionToken?: string\n\troutes?: RouteMap\n\tchildren: ReactNode\n\tenvironment?: Environment\n}\n\nconst validateProps = (props: Partial<ApplicationEntrypointProps>) => {\n\tif (typeof props.apiBaseUrl !== 'string') {\n\t\tthrow new Error(`The ENV variables haven't been set. Check your \\`.env.development.local\\` file.`) // TODO: better message\n\t}\n}\n\n/**\n * @group Entrypoints\n */\nexport const ApplicationEntrypoint = (props: ApplicationEntrypointProps) => {\n\tvalidateProps(props)\n\n\tconst rootEnv = props.environment ?? Environment.create()\n\n\tconst routing: RoutingContextValue = {\n\t\tbasePath: props.basePath,\n\t\troutes: props.routes ?? { index: { path: '/' } },\n\t\tdefaultDimensions: rootEnv.getAllDimensions(),\n\t}\n\n\treturn (\n\t\t<EnvironmentContext.Provider value={rootEnv}>\n\t\t\t<RoutingProvider {...routing}>\n\t\t\t\t<ContemberClient\n\t\t\t\t\tapiBaseUrl={props.apiBaseUrl}\n\t\t\t\t\tsessionToken={props.sessionToken}\n\t\t\t\t\tloginToken={props.loginToken}\n\t\t\t\t\tproject={props.project}\n\t\t\t\t\tstage={props.stage}\n\t\t\t\t>\n\t\t\t\t\t<EnvironmentExtensionProvider extension={projectEnvironmentExtension} state={props.project ?? null}>\n\t\t\t\t\t\t<DataViewPageNameKeyProvider>\n\t\t\t\t\t\t\t<IdentityProvider>\n\t\t\t\t\t\t\t\t<IdentityEnvironmentProvider>\n\t\t\t\t\t\t\t\t\t{props.children}\n\t\t\t\t\t\t\t\t</IdentityEnvironmentProvider>\n\t\t\t\t\t\t\t</IdentityProvider>\n\t\t\t\t\t\t</DataViewPageNameKeyProvider>\n\t\t\t\t\t</EnvironmentExtensionProvider>\n\t\t\t\t</ContemberClient>\n\t\t\t</RoutingProvider>\n\t\t</EnvironmentContext.Provider>\n\t)\n}\n"],"names":["Environment","jsxDEV","EnvironmentContext","RoutingProvider","ContemberClient","EnvironmentExtensionProvider","projectEnvironmentExtension","DataViewPageNameKeyProvider","IdentityProvider","IdentityEnvironmentProvider","this"],"mappings":";;;;;;;;AAeA,MAAM,gBAAgB,CAAC,UAA+C;AACrE,MAAI,OAAO,MAAM,eAAe,UAAU;AACzC,UAAM,IAAI,MAAM,iFAAiF;AAAA,EAClG;AACD;AAKO,MAAM,wBAAwB,CAAC,UAAsC;AAC3E,gBAAc,KAAK;AAEnB,QAAM,UAAU,MAAM,eAAeA,aAAAA,YAAY,OAAA;AAEjD,QAAM,UAA+B;AAAA,IACpC,UAAU,MAAM;AAAA,IAChB,QAAQ,MAAM,UAAU,EAAE,OAAO,EAAE,MAAM,MAAI;AAAA,IAC7C,mBAAmB,QAAQ,iBAAA;AAAA,EAAiB;AAG7C,SACCC,8BAAAA,OAACC,aAAAA,mBAAmB,UAAnB,EAA4B,OAAO,SACnC,UAAAD,8BAAAA,OAACE,aAAAA,iBAAA,EAAiB,GAAG,SACpB,UAAAF,8BAAAA;AAAAA,IAACG,YAAAA;AAAAA,IAAA;AAAA,MACA,YAAY,MAAM;AAAA,MAClB,cAAc,MAAM;AAAA,MACpB,YAAY,MAAM;AAAA,MAClB,SAAS,MAAM;AAAA,MACf,OAAO,MAAM;AAAA,MAEb,UAAAH,8BAAAA,OAACI,2CAAA,EAA6B,WAAWC,cAAAA,6BAA6B,OAAO,MAAM,WAAW,MAC7F,UAAAL,8BAAAA,OAACM,4BAAAA,+BACA,UAAAN,qCAACO,cAAAA,kBAAA,EACA,UAAAP,8BAAAA,OAACQ,cAAAA,6BAAA,EACC,gBAAM,YADR,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAC,MAEA,EAAA,GAHD,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAIA,EAAA,GALD,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAMA,EAAA,GAPD,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAQA;AAAA,IAAA;AAAA,IAfD;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA,EAgBA,GAjBD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAkBA,EAAA,GAnBD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAoBA;AAEF;;"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { Environment, EnvironmentContext, EnvironmentExtensionProvider } from "@contember/react-binding";
|
|
3
|
+
import { ContemberClient } from "@contember/react-client";
|
|
4
|
+
import { RoutingProvider } from "@contember/react-routing";
|
|
5
|
+
import { DataViewPageNameKeyProvider } from "./DataViewPageNameKeyProvider.js";
|
|
6
|
+
import { projectEnvironmentExtension, IdentityProvider, IdentityEnvironmentProvider } from "@contember/react-identity";
|
|
7
|
+
const validateProps = (props) => {
|
|
8
|
+
if (typeof props.apiBaseUrl !== "string") {
|
|
9
|
+
throw new Error(`The ENV variables haven't been set. Check your \`.env.development.local\` file.`);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const ApplicationEntrypoint = (props) => {
|
|
13
|
+
validateProps(props);
|
|
14
|
+
const rootEnv = props.environment ?? Environment.create();
|
|
15
|
+
const routing = {
|
|
16
|
+
basePath: props.basePath,
|
|
17
|
+
routes: props.routes ?? { index: { path: "/" } },
|
|
18
|
+
defaultDimensions: rootEnv.getAllDimensions()
|
|
19
|
+
};
|
|
20
|
+
return /* @__PURE__ */ jsxDEV(EnvironmentContext.Provider, { value: rootEnv, children: /* @__PURE__ */ jsxDEV(RoutingProvider, { ...routing, children: /* @__PURE__ */ jsxDEV(
|
|
21
|
+
ContemberClient,
|
|
22
|
+
{
|
|
23
|
+
apiBaseUrl: props.apiBaseUrl,
|
|
24
|
+
sessionToken: props.sessionToken,
|
|
25
|
+
loginToken: props.loginToken,
|
|
26
|
+
project: props.project,
|
|
27
|
+
stage: props.stage,
|
|
28
|
+
children: /* @__PURE__ */ jsxDEV(EnvironmentExtensionProvider, { extension: projectEnvironmentExtension, state: props.project ?? null, children: /* @__PURE__ */ jsxDEV(DataViewPageNameKeyProvider, { children: /* @__PURE__ */ jsxDEV(IdentityProvider, { children: /* @__PURE__ */ jsxDEV(IdentityEnvironmentProvider, { children: props.children }, void 0, false, {
|
|
29
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
30
|
+
lineNumber: 49,
|
|
31
|
+
columnNumber: 9
|
|
32
|
+
}, void 0) }, void 0, false, {
|
|
33
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
34
|
+
lineNumber: 48,
|
|
35
|
+
columnNumber: 8
|
|
36
|
+
}, void 0) }, void 0, false, {
|
|
37
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
38
|
+
lineNumber: 47,
|
|
39
|
+
columnNumber: 7
|
|
40
|
+
}, void 0) }, void 0, false, {
|
|
41
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
42
|
+
lineNumber: 46,
|
|
43
|
+
columnNumber: 6
|
|
44
|
+
}, void 0)
|
|
45
|
+
},
|
|
46
|
+
void 0,
|
|
47
|
+
false,
|
|
48
|
+
{
|
|
49
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
50
|
+
lineNumber: 39,
|
|
51
|
+
columnNumber: 5
|
|
52
|
+
},
|
|
53
|
+
void 0
|
|
54
|
+
) }, void 0, false, {
|
|
55
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
56
|
+
lineNumber: 38,
|
|
57
|
+
columnNumber: 4
|
|
58
|
+
}, void 0) }, void 0, false, {
|
|
59
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/ApplicationEntrypoint.tsx",
|
|
60
|
+
lineNumber: 37,
|
|
61
|
+
columnNumber: 3
|
|
62
|
+
}, void 0);
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
ApplicationEntrypoint
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=ApplicationEntrypoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApplicationEntrypoint.js","sources":["../../../../../packages/interface/src/bootstrap/ApplicationEntrypoint.tsx"],"sourcesContent":["import { Environment, EnvironmentContext, EnvironmentExtensionProvider } from '@contember/react-binding'\nimport { ContemberClient, ContemberClientProps } from '@contember/react-client'\nimport { ReactNode } from 'react'\nimport { RouteMap, RoutingContextValue, RoutingProvider } from '@contember/react-routing'\nimport { DataViewPageNameKeyProvider } from './DataViewPageNameKeyProvider'\nimport { IdentityEnvironmentProvider, IdentityProvider, projectEnvironmentExtension } from '@contember/react-identity'\n\nexport interface ApplicationEntrypointProps extends ContemberClientProps {\n\tbasePath: string\n\tsessionToken?: string\n\troutes?: RouteMap\n\tchildren: ReactNode\n\tenvironment?: Environment\n}\n\nconst validateProps = (props: Partial<ApplicationEntrypointProps>) => {\n\tif (typeof props.apiBaseUrl !== 'string') {\n\t\tthrow new Error(`The ENV variables haven't been set. Check your \\`.env.development.local\\` file.`) // TODO: better message\n\t}\n}\n\n/**\n * @group Entrypoints\n */\nexport const ApplicationEntrypoint = (props: ApplicationEntrypointProps) => {\n\tvalidateProps(props)\n\n\tconst rootEnv = props.environment ?? Environment.create()\n\n\tconst routing: RoutingContextValue = {\n\t\tbasePath: props.basePath,\n\t\troutes: props.routes ?? { index: { path: '/' } },\n\t\tdefaultDimensions: rootEnv.getAllDimensions(),\n\t}\n\n\treturn (\n\t\t<EnvironmentContext.Provider value={rootEnv}>\n\t\t\t<RoutingProvider {...routing}>\n\t\t\t\t<ContemberClient\n\t\t\t\t\tapiBaseUrl={props.apiBaseUrl}\n\t\t\t\t\tsessionToken={props.sessionToken}\n\t\t\t\t\tloginToken={props.loginToken}\n\t\t\t\t\tproject={props.project}\n\t\t\t\t\tstage={props.stage}\n\t\t\t\t>\n\t\t\t\t\t<EnvironmentExtensionProvider extension={projectEnvironmentExtension} state={props.project ?? null}>\n\t\t\t\t\t\t<DataViewPageNameKeyProvider>\n\t\t\t\t\t\t\t<IdentityProvider>\n\t\t\t\t\t\t\t\t<IdentityEnvironmentProvider>\n\t\t\t\t\t\t\t\t\t{props.children}\n\t\t\t\t\t\t\t\t</IdentityEnvironmentProvider>\n\t\t\t\t\t\t\t</IdentityProvider>\n\t\t\t\t\t\t</DataViewPageNameKeyProvider>\n\t\t\t\t\t</EnvironmentExtensionProvider>\n\t\t\t\t</ContemberClient>\n\t\t\t</RoutingProvider>\n\t\t</EnvironmentContext.Provider>\n\t)\n}\n"],"names":["this"],"mappings":";;;;;;AAeA,MAAM,gBAAgB,CAAC,UAA+C;AACrE,MAAI,OAAO,MAAM,eAAe,UAAU;AACzC,UAAM,IAAI,MAAM,iFAAiF;AAAA,EAClG;AACD;AAKO,MAAM,wBAAwB,CAAC,UAAsC;AAC3E,gBAAc,KAAK;AAEnB,QAAM,UAAU,MAAM,eAAe,YAAY,OAAA;AAEjD,QAAM,UAA+B;AAAA,IACpC,UAAU,MAAM;AAAA,IAChB,QAAQ,MAAM,UAAU,EAAE,OAAO,EAAE,MAAM,MAAI;AAAA,IAC7C,mBAAmB,QAAQ,iBAAA;AAAA,EAAiB;AAG7C,SACC,uBAAC,mBAAmB,UAAnB,EAA4B,OAAO,SACnC,UAAA,uBAAC,iBAAA,EAAiB,GAAG,SACpB,UAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA,YAAY,MAAM;AAAA,MAClB,cAAc,MAAM;AAAA,MACpB,YAAY,MAAM;AAAA,MAClB,SAAS,MAAM;AAAA,MACf,OAAO,MAAM;AAAA,MAEb,UAAA,uBAAC,8BAAA,EAA6B,WAAW,6BAA6B,OAAO,MAAM,WAAW,MAC7F,UAAA,uBAAC,+BACA,UAAA,uBAAC,kBAAA,EACA,UAAA,uBAAC,6BAAA,EACC,gBAAM,YADR,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAEA,EAAA,GAHD,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAIA,EAAA,GALD,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAMA,EAAA,GAPD,QAAA,OAAA;AAAA,QAAA,UAAA;AAAA,QAAA,YAAA;AAAA,QAAA,cAAA;AAAA,MAAA,GAAAA,MAQA;AAAA,IAAA;AAAA,IAfD;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA,EAgBA,GAjBD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAkBA,EAAA,GAnBD,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAoBA;AAEF;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const reactRouting = require("@contember/react-routing");
|
|
5
|
+
const reactDataview = require("@contember/react-dataview");
|
|
6
|
+
const DataViewPageNameKeyProvider = ({ children }) => {
|
|
7
|
+
const pageName = reactRouting.useCurrentRequest()?.pageName;
|
|
8
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactDataview.DataViewKeyProvider, { value: pageName ?? "", children }, void 0, false, {
|
|
9
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/DataViewPageNameKeyProvider.tsx",
|
|
10
|
+
lineNumber: 9,
|
|
11
|
+
columnNumber: 3
|
|
12
|
+
}, void 0);
|
|
13
|
+
};
|
|
14
|
+
exports.DataViewPageNameKeyProvider = DataViewPageNameKeyProvider;
|
|
15
|
+
//# sourceMappingURL=DataViewPageNameKeyProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataViewPageNameKeyProvider.cjs","sources":["../../../../../packages/interface/src/bootstrap/DataViewPageNameKeyProvider.tsx"],"sourcesContent":["import { useCurrentRequest } from '@contember/react-routing'\nimport { DataViewKeyProvider } from '@contember/react-dataview'\nimport { ReactNode } from 'react'\n\nexport const DataViewPageNameKeyProvider = ({ children }: { children: ReactNode }) => {\n\tconst pageName = useCurrentRequest()?.pageName\n\n\treturn (\n\t\t<DataViewKeyProvider value={pageName ?? ''}>\n\t\t\t{children}\n\t\t</DataViewKeyProvider>\n\t)\n}\n"],"names":["useCurrentRequest","jsxDEV","DataViewKeyProvider","this"],"mappings":";;;;;AAIO,MAAM,8BAA8B,CAAC,EAAE,eAAwC;AACrF,QAAM,WAAWA,aAAAA,qBAAqB;AAEtC,SACCC,8BAAAA,OAACC,mCAAA,EAAoB,OAAO,YAAY,IACtC,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAEA;AAEF;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useCurrentRequest } from "@contember/react-routing";
|
|
3
|
+
import { DataViewKeyProvider } from "@contember/react-dataview";
|
|
4
|
+
const DataViewPageNameKeyProvider = ({ children }) => {
|
|
5
|
+
const pageName = useCurrentRequest()?.pageName;
|
|
6
|
+
return /* @__PURE__ */ jsxDEV(DataViewKeyProvider, { value: pageName ?? "", children }, void 0, false, {
|
|
7
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/bootstrap/DataViewPageNameKeyProvider.tsx",
|
|
8
|
+
lineNumber: 9,
|
|
9
|
+
columnNumber: 3
|
|
10
|
+
}, void 0);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
DataViewPageNameKeyProvider
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=DataViewPageNameKeyProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataViewPageNameKeyProvider.js","sources":["../../../../../packages/interface/src/bootstrap/DataViewPageNameKeyProvider.tsx"],"sourcesContent":["import { useCurrentRequest } from '@contember/react-routing'\nimport { DataViewKeyProvider } from '@contember/react-dataview'\nimport { ReactNode } from 'react'\n\nexport const DataViewPageNameKeyProvider = ({ children }: { children: ReactNode }) => {\n\tconst pageName = useCurrentRequest()?.pageName\n\n\treturn (\n\t\t<DataViewKeyProvider value={pageName ?? ''}>\n\t\t\t{children}\n\t\t</DataViewKeyProvider>\n\t)\n}\n"],"names":["this"],"mappings":";;;AAIO,MAAM,8BAA8B,CAAC,EAAE,eAAwC;AACrF,QAAM,WAAW,qBAAqB;AAEtC,SACC,uBAAC,qBAAA,EAAoB,OAAO,YAAY,IACtC,SAAA,GADF,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAEA;AAEF;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const reactSlot = require("@radix-ui/react-slot");
|
|
6
|
+
const reactBinding = require("@contember/react-binding");
|
|
7
|
+
const ClearFieldTrigger = reactBinding.Component(({ field, ...props }) => {
|
|
8
|
+
const fieldAccessor = reactBinding.useField(field);
|
|
9
|
+
const clearField = React.useCallback(() => {
|
|
10
|
+
fieldAccessor.updateValue(null);
|
|
11
|
+
}, [fieldAccessor]);
|
|
12
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactSlot.Slot, { onClick: clearField, ...props }, void 0, false, {
|
|
13
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/components/binding/ClearFieldTrigger.tsx",
|
|
14
|
+
lineNumber: 15,
|
|
15
|
+
columnNumber: 9
|
|
16
|
+
}, void 0);
|
|
17
|
+
}, ({ field }) => {
|
|
18
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(reactBinding.Field, { field }, void 0, false, {
|
|
19
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/components/binding/ClearFieldTrigger.tsx",
|
|
20
|
+
lineNumber: 17,
|
|
21
|
+
columnNumber: 9
|
|
22
|
+
}, void 0);
|
|
23
|
+
});
|
|
24
|
+
exports.ClearFieldTrigger = ClearFieldTrigger;
|
|
25
|
+
//# sourceMappingURL=ClearFieldTrigger.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClearFieldTrigger.cjs","sources":["../../../../../../packages/interface/src/components/binding/ClearFieldTrigger.tsx"],"sourcesContent":["import { ReactNode, useCallback } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { Component, Field, SugaredRelativeSingleField, useField } from '@contember/react-binding'\n\nexport interface ClearFieldTriggerProps {\n\tfield: SugaredRelativeSingleField['field']\n\tchildren: ReactNode\n}\n\nexport const ClearFieldTrigger = Component<ClearFieldTriggerProps>(({ field, ...props }) => {\n\tconst fieldAccessor = useField(field)\n\tconst clearField = useCallback(() => {\n\t\tfieldAccessor.updateValue(null)\n\t}, [fieldAccessor])\n\treturn <Slot onClick={clearField} {...props} />\n}, ({ field }) => {\n\treturn <Field field={field} />\n})\n"],"names":["Component","useField","useCallback","jsxDEV","Slot","this","Field"],"mappings":";;;;;;AASO,MAAM,oBAAoBA,aAAAA,UAAkC,CAAC,EAAE,OAAO,GAAG,YAAY;AAC3F,QAAM,gBAAgBC,aAAAA,SAAS,KAAK;AACpC,QAAM,aAAaC,MAAAA,YAAY,MAAM;AACpC,kBAAc,YAAY,IAAI;AAAA,EAC/B,GAAG,CAAC,aAAa,CAAC;AAClB,SAAOC,8BAAAA,OAACC,UAAAA,MAAA,EAAK,SAAS,YAAa,GAAG,MAAA,GAA/B,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAC,MAAsC;AAC9C,GAAG,CAAC,EAAE,YAAY;AACjB,SAAOF,8BAAAA,OAACG,aAAAA,SAAM,MAAA,GAAP,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAD,MAAqB;AAC7B,CAAC;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { Component, useField, Field } from "@contember/react-binding";
|
|
5
|
+
const ClearFieldTrigger = Component(({ field, ...props }) => {
|
|
6
|
+
const fieldAccessor = useField(field);
|
|
7
|
+
const clearField = useCallback(() => {
|
|
8
|
+
fieldAccessor.updateValue(null);
|
|
9
|
+
}, [fieldAccessor]);
|
|
10
|
+
return /* @__PURE__ */ jsxDEV(Slot, { onClick: clearField, ...props }, void 0, false, {
|
|
11
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/components/binding/ClearFieldTrigger.tsx",
|
|
12
|
+
lineNumber: 15,
|
|
13
|
+
columnNumber: 9
|
|
14
|
+
}, void 0);
|
|
15
|
+
}, ({ field }) => {
|
|
16
|
+
return /* @__PURE__ */ jsxDEV(Field, { field }, void 0, false, {
|
|
17
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/components/binding/ClearFieldTrigger.tsx",
|
|
18
|
+
lineNumber: 17,
|
|
19
|
+
columnNumber: 9
|
|
20
|
+
}, void 0);
|
|
21
|
+
});
|
|
22
|
+
export {
|
|
23
|
+
ClearFieldTrigger
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=ClearFieldTrigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClearFieldTrigger.js","sources":["../../../../../../packages/interface/src/components/binding/ClearFieldTrigger.tsx"],"sourcesContent":["import { ReactNode, useCallback } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport { Component, Field, SugaredRelativeSingleField, useField } from '@contember/react-binding'\n\nexport interface ClearFieldTriggerProps {\n\tfield: SugaredRelativeSingleField['field']\n\tchildren: ReactNode\n}\n\nexport const ClearFieldTrigger = Component<ClearFieldTriggerProps>(({ field, ...props }) => {\n\tconst fieldAccessor = useField(field)\n\tconst clearField = useCallback(() => {\n\t\tfieldAccessor.updateValue(null)\n\t}, [fieldAccessor])\n\treturn <Slot onClick={clearField} {...props} />\n}, ({ field }) => {\n\treturn <Field field={field} />\n})\n"],"names":["this"],"mappings":";;;;AASO,MAAM,oBAAoB,UAAkC,CAAC,EAAE,OAAO,GAAG,YAAY;AAC3F,QAAM,gBAAgB,SAAS,KAAK;AACpC,QAAM,aAAa,YAAY,MAAM;AACpC,kBAAc,YAAY,IAAI;AAAA,EAC/B,GAAG,CAAC,aAAa,CAAC;AAClB,SAAO,uBAAC,MAAA,EAAK,SAAS,YAAa,GAAG,MAAA,GAA/B,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAAsC;AAC9C,GAAG,CAAC,EAAE,YAAY;AACjB,SAAO,uBAAC,SAAM,MAAA,GAAP,QAAA,OAAA;AAAA,IAAA,UAAA;AAAA,IAAA,YAAA;AAAA,IAAA,cAAA;AAAA,EAAA,GAAAA,MAAqB;AAC7B,CAAC;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const jsxDevRuntime = require("react/jsx-dev-runtime");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const reactSlot = require("@radix-ui/react-slot");
|
|
6
|
+
const reactBinding = require("@contember/react-binding");
|
|
7
|
+
const SlotButton = reactSlot.Slot;
|
|
8
|
+
const DisconnectEntityTrigger = ({ immediatePersist, onPersistError, onPersistSuccess, field, ...props }) => {
|
|
9
|
+
const entity = reactBinding.useEntity();
|
|
10
|
+
const triggerPersist = reactBinding.usePersist();
|
|
11
|
+
const isMutating = reactBinding.useMutationState();
|
|
12
|
+
const onClick = React.useCallback(() => {
|
|
13
|
+
if (field) {
|
|
14
|
+
entity.disconnectEntityAtField({ field });
|
|
15
|
+
} else {
|
|
16
|
+
const parent = entity.getParent();
|
|
17
|
+
if (!parent) {
|
|
18
|
+
throw new reactBinding.BindingError("Cannot disconnect root entity");
|
|
19
|
+
}
|
|
20
|
+
if (reactBinding.isEntityListAccessor(parent)) {
|
|
21
|
+
parent.disconnectEntity(entity);
|
|
22
|
+
} else {
|
|
23
|
+
const subTreeNode = entity.environment.getSubTreeNode();
|
|
24
|
+
if (subTreeNode.type !== "entity") {
|
|
25
|
+
throw new reactBinding.BindingError("Cannot disconnect root entity");
|
|
26
|
+
}
|
|
27
|
+
parent.disconnectEntityAtField({ field: subTreeNode.field.name });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (immediatePersist) {
|
|
31
|
+
triggerPersist().then(onPersistSuccess).catch(onPersistError);
|
|
32
|
+
}
|
|
33
|
+
}, [field, immediatePersist, entity, triggerPersist, onPersistSuccess, onPersistError]);
|
|
34
|
+
return /* @__PURE__ */ jsxDevRuntime.jsxDEV(
|
|
35
|
+
SlotButton,
|
|
36
|
+
{
|
|
37
|
+
onClick,
|
|
38
|
+
disabled: isMutating ? true : void 0,
|
|
39
|
+
...props
|
|
40
|
+
},
|
|
41
|
+
void 0,
|
|
42
|
+
false,
|
|
43
|
+
{
|
|
44
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/components/binding/DisconnectEntityTrigger.tsx",
|
|
45
|
+
lineNumber: 56,
|
|
46
|
+
columnNumber: 3
|
|
47
|
+
},
|
|
48
|
+
void 0
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
exports.DisconnectEntityTrigger = DisconnectEntityTrigger;
|
|
52
|
+
//# sourceMappingURL=DisconnectEntityTrigger.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisconnectEntityTrigger.cjs","sources":["../../../../../../packages/interface/src/components/binding/DisconnectEntityTrigger.tsx"],"sourcesContent":["import { ComponentType, ReactNode, useCallback } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport {\n\tBindingError,\n\tEntityListAccessor,\n\tErrorPersistResult,\n\tisEntityListAccessor,\n\tSuccessfulPersistResult,\n\tSugaredRelativeSingleEntity,\n\tuseEntity,\n\tuseMutationState,\n\tusePersist,\n} from '@contember/react-binding'\n\nconst SlotButton = Slot as ComponentType<React.ButtonHTMLAttributes<HTMLButtonElement>>\n\nexport interface DisconnectEntityTriggerProps {\n\timmediatePersist?: true\n\tchildren: ReactNode\n\tonPersistSuccess?: (result: SuccessfulPersistResult) => void\n\tonPersistError?: (result: ErrorPersistResult) => void\n\tfield?: SugaredRelativeSingleEntity['field']\n}\n\nexport const DisconnectEntityTrigger = ({ immediatePersist, onPersistError, onPersistSuccess, field, ...props }: DisconnectEntityTriggerProps) => {\n\tconst entity = useEntity()\n\tconst triggerPersist = usePersist()\n\tconst isMutating = useMutationState()\n\tconst onClick = useCallback(() => {\n\t\tif (field) {\n\t\t\tentity.disconnectEntityAtField({ field })\n\t\t} else {\n\t\t\tconst parent = entity.getParent()\n\t\t\tif (!parent) {\n\t\t\t\tthrow new BindingError('Cannot disconnect root entity')\n\t\t\t}\n\t\t\tif (isEntityListAccessor(parent)) {\n\t\t\t\tparent.disconnectEntity(entity)\n\t\t\t} else {\n\t\t\t\tconst subTreeNode = entity.environment.getSubTreeNode()\n\t\t\t\tif (subTreeNode.type !== 'entity') {\n\t\t\t\t\tthrow new BindingError('Cannot disconnect root entity')\n\t\t\t\t}\n\t\t\t\tparent.disconnectEntityAtField({ field: subTreeNode.field.name })\n\t\t\t}\n\t\t}\n\n\t\tif (immediatePersist) {\n\t\t\ttriggerPersist()\n\t\t\t\t.then(onPersistSuccess)\n\t\t\t\t.catch(onPersistError)\n\t\t}\n\t}, [field, immediatePersist, entity, triggerPersist, onPersistSuccess, onPersistError])\n\n\treturn (\n\t\t<SlotButton\n\t\t\tonClick={onClick}\n\t\t\tdisabled={isMutating ? true : undefined}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n"],"names":["Slot","useEntity","usePersist","useMutationState","useCallback","BindingError","isEntityListAccessor","jsxDEV","this"],"mappings":";;;;;;AAcA,MAAM,aAAaA,UAAAA;AAUZ,MAAM,0BAA0B,CAAC,EAAE,kBAAkB,gBAAgB,kBAAkB,OAAO,GAAG,YAA0C;AACjJ,QAAM,SAASC,aAAAA,UAAA;AACf,QAAM,iBAAiBC,aAAAA,WAAA;AACvB,QAAM,aAAaC,aAAAA,iBAAA;AACnB,QAAM,UAAUC,MAAAA,YAAY,MAAM;AACjC,QAAI,OAAO;AACV,aAAO,wBAAwB,EAAE,OAAO;AAAA,IACzC,OAAO;AACN,YAAM,SAAS,OAAO,UAAA;AACtB,UAAI,CAAC,QAAQ;AACZ,cAAM,IAAIC,aAAAA,aAAa,+BAA+B;AAAA,MACvD;AACA,UAAIC,aAAAA,qBAAqB,MAAM,GAAG;AACjC,eAAO,iBAAiB,MAAM;AAAA,MAC/B,OAAO;AACN,cAAM,cAAc,OAAO,YAAY,eAAA;AACvC,YAAI,YAAY,SAAS,UAAU;AAClC,gBAAM,IAAID,aAAAA,aAAa,+BAA+B;AAAA,QACvD;AACA,eAAO,wBAAwB,EAAE,OAAO,YAAY,MAAM,MAAM;AAAA,MACjE;AAAA,IACD;AAEA,QAAI,kBAAkB;AACrB,qBAAA,EACE,KAAK,gBAAgB,EACrB,MAAM,cAAc;AAAA,IACvB;AAAA,EACD,GAAG,CAAC,OAAO,kBAAkB,QAAQ,gBAAgB,kBAAkB,cAAc,CAAC;AAEtF,SACCE,8BAAAA;AAAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,UAAU,aAAa,OAAO;AAAA,MAC7B,GAAG;AAAA,IAAA;AAAA,IAHL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAC;AAAAA,EAAA;AAMF;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { useEntity, usePersist, useMutationState, BindingError, isEntityListAccessor } from "@contember/react-binding";
|
|
5
|
+
const SlotButton = Slot;
|
|
6
|
+
const DisconnectEntityTrigger = ({ immediatePersist, onPersistError, onPersistSuccess, field, ...props }) => {
|
|
7
|
+
const entity = useEntity();
|
|
8
|
+
const triggerPersist = usePersist();
|
|
9
|
+
const isMutating = useMutationState();
|
|
10
|
+
const onClick = useCallback(() => {
|
|
11
|
+
if (field) {
|
|
12
|
+
entity.disconnectEntityAtField({ field });
|
|
13
|
+
} else {
|
|
14
|
+
const parent = entity.getParent();
|
|
15
|
+
if (!parent) {
|
|
16
|
+
throw new BindingError("Cannot disconnect root entity");
|
|
17
|
+
}
|
|
18
|
+
if (isEntityListAccessor(parent)) {
|
|
19
|
+
parent.disconnectEntity(entity);
|
|
20
|
+
} else {
|
|
21
|
+
const subTreeNode = entity.environment.getSubTreeNode();
|
|
22
|
+
if (subTreeNode.type !== "entity") {
|
|
23
|
+
throw new BindingError("Cannot disconnect root entity");
|
|
24
|
+
}
|
|
25
|
+
parent.disconnectEntityAtField({ field: subTreeNode.field.name });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (immediatePersist) {
|
|
29
|
+
triggerPersist().then(onPersistSuccess).catch(onPersistError);
|
|
30
|
+
}
|
|
31
|
+
}, [field, immediatePersist, entity, triggerPersist, onPersistSuccess, onPersistError]);
|
|
32
|
+
return /* @__PURE__ */ jsxDEV(
|
|
33
|
+
SlotButton,
|
|
34
|
+
{
|
|
35
|
+
onClick,
|
|
36
|
+
disabled: isMutating ? true : void 0,
|
|
37
|
+
...props
|
|
38
|
+
},
|
|
39
|
+
void 0,
|
|
40
|
+
false,
|
|
41
|
+
{
|
|
42
|
+
fileName: "/home/runner/work/contember/contember/packages/interface/src/components/binding/DisconnectEntityTrigger.tsx",
|
|
43
|
+
lineNumber: 56,
|
|
44
|
+
columnNumber: 3
|
|
45
|
+
},
|
|
46
|
+
void 0
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
DisconnectEntityTrigger
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=DisconnectEntityTrigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisconnectEntityTrigger.js","sources":["../../../../../../packages/interface/src/components/binding/DisconnectEntityTrigger.tsx"],"sourcesContent":["import { ComponentType, ReactNode, useCallback } from 'react'\nimport { Slot } from '@radix-ui/react-slot'\nimport {\n\tBindingError,\n\tEntityListAccessor,\n\tErrorPersistResult,\n\tisEntityListAccessor,\n\tSuccessfulPersistResult,\n\tSugaredRelativeSingleEntity,\n\tuseEntity,\n\tuseMutationState,\n\tusePersist,\n} from '@contember/react-binding'\n\nconst SlotButton = Slot as ComponentType<React.ButtonHTMLAttributes<HTMLButtonElement>>\n\nexport interface DisconnectEntityTriggerProps {\n\timmediatePersist?: true\n\tchildren: ReactNode\n\tonPersistSuccess?: (result: SuccessfulPersistResult) => void\n\tonPersistError?: (result: ErrorPersistResult) => void\n\tfield?: SugaredRelativeSingleEntity['field']\n}\n\nexport const DisconnectEntityTrigger = ({ immediatePersist, onPersistError, onPersistSuccess, field, ...props }: DisconnectEntityTriggerProps) => {\n\tconst entity = useEntity()\n\tconst triggerPersist = usePersist()\n\tconst isMutating = useMutationState()\n\tconst onClick = useCallback(() => {\n\t\tif (field) {\n\t\t\tentity.disconnectEntityAtField({ field })\n\t\t} else {\n\t\t\tconst parent = entity.getParent()\n\t\t\tif (!parent) {\n\t\t\t\tthrow new BindingError('Cannot disconnect root entity')\n\t\t\t}\n\t\t\tif (isEntityListAccessor(parent)) {\n\t\t\t\tparent.disconnectEntity(entity)\n\t\t\t} else {\n\t\t\t\tconst subTreeNode = entity.environment.getSubTreeNode()\n\t\t\t\tif (subTreeNode.type !== 'entity') {\n\t\t\t\t\tthrow new BindingError('Cannot disconnect root entity')\n\t\t\t\t}\n\t\t\t\tparent.disconnectEntityAtField({ field: subTreeNode.field.name })\n\t\t\t}\n\t\t}\n\n\t\tif (immediatePersist) {\n\t\t\ttriggerPersist()\n\t\t\t\t.then(onPersistSuccess)\n\t\t\t\t.catch(onPersistError)\n\t\t}\n\t}, [field, immediatePersist, entity, triggerPersist, onPersistSuccess, onPersistError])\n\n\treturn (\n\t\t<SlotButton\n\t\t\tonClick={onClick}\n\t\t\tdisabled={isMutating ? true : undefined}\n\t\t\t{...props}\n\t\t/>\n\t)\n}\n"],"names":["this"],"mappings":";;;;AAcA,MAAM,aAAa;AAUZ,MAAM,0BAA0B,CAAC,EAAE,kBAAkB,gBAAgB,kBAAkB,OAAO,GAAG,YAA0C;AACjJ,QAAM,SAAS,UAAA;AACf,QAAM,iBAAiB,WAAA;AACvB,QAAM,aAAa,iBAAA;AACnB,QAAM,UAAU,YAAY,MAAM;AACjC,QAAI,OAAO;AACV,aAAO,wBAAwB,EAAE,OAAO;AAAA,IACzC,OAAO;AACN,YAAM,SAAS,OAAO,UAAA;AACtB,UAAI,CAAC,QAAQ;AACZ,cAAM,IAAI,aAAa,+BAA+B;AAAA,MACvD;AACA,UAAI,qBAAqB,MAAM,GAAG;AACjC,eAAO,iBAAiB,MAAM;AAAA,MAC/B,OAAO;AACN,cAAM,cAAc,OAAO,YAAY,eAAA;AACvC,YAAI,YAAY,SAAS,UAAU;AAClC,gBAAM,IAAI,aAAa,+BAA+B;AAAA,QACvD;AACA,eAAO,wBAAwB,EAAE,OAAO,YAAY,MAAM,MAAM;AAAA,MACjE;AAAA,IACD;AAEA,QAAI,kBAAkB;AACrB,qBAAA,EACE,KAAK,gBAAgB,EACrB,MAAM,cAAc;AAAA,IACvB;AAAA,EACD,GAAG,CAAC,OAAO,kBAAkB,QAAQ,gBAAgB,kBAAkB,cAAc,CAAC;AAEtF,SACC;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,UAAU,aAAa,OAAO;AAAA,MAC7B,GAAG;AAAA,IAAA;AAAA,IAHL;AAAA,IAAA;AAAA,IAAA;AAAA,MAAA,UAAA;AAAA,MAAA,YAAA;AAAA,MAAA,cAAA;AAAA,IAAA;AAAA,IAAAA;AAAAA,EAAA;AAMF;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactBinding = require("@contember/react-binding");
|
|
4
|
+
const EntityBeforePersist = ({ listener }) => {
|
|
5
|
+
reactBinding.useEntityBeforePersist(listener);
|
|
6
|
+
return null;
|
|
7
|
+
};
|
|
8
|
+
exports.EntityBeforePersist = EntityBeforePersist;
|
|
9
|
+
//# sourceMappingURL=EntityBeforePersist.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityBeforePersist.cjs","sources":["../../../../../../packages/interface/src/components/binding/EntityBeforePersist.tsx"],"sourcesContent":["import { EntityAccessor, useEntityBeforePersist } from '@contember/react-binding'\n\nexport const EntityBeforePersist = ({ listener }: { listener: EntityAccessor.EntityEventListenerMap['beforePersist'] }) => {\n\tuseEntityBeforePersist(listener)\n\treturn null\n}\n"],"names":["useEntityBeforePersist"],"mappings":";;;AAEO,MAAM,sBAAsB,CAAC,EAAE,eAAqF;AAC1HA,eAAAA,uBAAuB,QAAQ;AAC/B,SAAO;AACR;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntityBeforePersist.js","sources":["../../../../../../packages/interface/src/components/binding/EntityBeforePersist.tsx"],"sourcesContent":["import { EntityAccessor, useEntityBeforePersist } from '@contember/react-binding'\n\nexport const EntityBeforePersist = ({ listener }: { listener: EntityAccessor.EntityEventListenerMap['beforePersist'] }) => {\n\tuseEntityBeforePersist(listener)\n\treturn null\n}\n"],"names":[],"mappings":";AAEO,MAAM,sBAAsB,CAAC,EAAE,eAAqF;AAC1H,yBAAuB,QAAQ;AAC/B,SAAO;AACR;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactBinding = require("@contember/react-binding");
|
|
4
|
+
const reactRouting = require("@contember/react-routing");
|
|
5
|
+
const RedirectOnPersist = ({ to, parameters }) => {
|
|
6
|
+
const redirect = reactRouting.useRedirect();
|
|
7
|
+
reactBinding.useEntityPersistSuccess((getEntity, options) => {
|
|
8
|
+
if (options.successType !== "justSuccess") {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
redirect(to, parameters);
|
|
12
|
+
});
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
exports.RedirectOnPersist = RedirectOnPersist;
|
|
16
|
+
//# sourceMappingURL=RedirectOnPersist.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedirectOnPersist.cjs","sources":["../../../../../../packages/interface/src/components/binding/RedirectOnPersist.tsx"],"sourcesContent":["import { useEntityPersistSuccess } from '@contember/react-binding'\nimport { RequestParameters, useRedirect } from '@contember/react-routing'\nimport { RoutingLinkTarget } from '@contember/react-routing'\n\nexport const RedirectOnPersist = ({ to, parameters }: { to: RoutingLinkTarget; parameters?: RequestParameters }) => {\n\tconst redirect = useRedirect()\n\tuseEntityPersistSuccess((getEntity, options) => {\n\t\tif (options.successType !== 'justSuccess') {\n\t\t\treturn\n\t\t}\n\t\tredirect(to, parameters)\n\t})\n\treturn null\n}\n"],"names":["useRedirect","useEntityPersistSuccess"],"mappings":";;;;AAIO,MAAM,oBAAoB,CAAC,EAAE,IAAI,iBAA4E;AACnH,QAAM,WAAWA,aAAAA,YAAA;AACjBC,uCAAwB,CAAC,WAAW,YAAY;AAC/C,QAAI,QAAQ,gBAAgB,eAAe;AAC1C;AAAA,IACD;AACA,aAAS,IAAI,UAAU;AAAA,EACxB,CAAC;AACD,SAAO;AACR;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEntityPersistSuccess } from "@contember/react-binding";
|
|
2
|
+
import { useRedirect } from "@contember/react-routing";
|
|
3
|
+
const RedirectOnPersist = ({ to, parameters }) => {
|
|
4
|
+
const redirect = useRedirect();
|
|
5
|
+
useEntityPersistSuccess((getEntity, options) => {
|
|
6
|
+
if (options.successType !== "justSuccess") {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
redirect(to, parameters);
|
|
10
|
+
});
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
RedirectOnPersist
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=RedirectOnPersist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedirectOnPersist.js","sources":["../../../../../../packages/interface/src/components/binding/RedirectOnPersist.tsx"],"sourcesContent":["import { useEntityPersistSuccess } from '@contember/react-binding'\nimport { RequestParameters, useRedirect } from '@contember/react-routing'\nimport { RoutingLinkTarget } from '@contember/react-routing'\n\nexport const RedirectOnPersist = ({ to, parameters }: { to: RoutingLinkTarget; parameters?: RequestParameters }) => {\n\tconst redirect = useRedirect()\n\tuseEntityPersistSuccess((getEntity, options) => {\n\t\tif (options.successType !== 'justSuccess') {\n\t\t\treturn\n\t\t}\n\t\tredirect(to, parameters)\n\t})\n\treturn null\n}\n"],"names":[],"mappings":";;AAIO,MAAM,oBAAoB,CAAC,EAAE,IAAI,iBAA4E;AACnH,QAAM,WAAW,YAAA;AACjB,0BAAwB,CAAC,WAAW,YAAY;AAC/C,QAAI,QAAQ,gBAAgB,eAAe;AAC1C;AAAA,IACD;AACA,aAAS,IAAI,UAAU;AAAA,EACxB,CAAC;AACD,SAAO;AACR;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const reactBinding = require("@contember/react-binding");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const reactRouting = require("@contember/react-routing");
|
|
6
|
+
const useBlockNavigationOnDirtyState = (handler, options) => {
|
|
7
|
+
const isDirty = reactBinding.useDirtinessState();
|
|
8
|
+
const isDirtyRef = React.useRef(isDirty);
|
|
9
|
+
isDirtyRef.current = isDirty;
|
|
10
|
+
const isMutating = reactBinding.useMutationState();
|
|
11
|
+
const isMutatingRef = React.useRef(isMutating);
|
|
12
|
+
isMutatingRef.current = isMutating;
|
|
13
|
+
const persist = reactBinding.usePersist();
|
|
14
|
+
reactRouting.useRegisterRequestChangeListener(React.useCallback(async (event) => {
|
|
15
|
+
if (!isDirtyRef.current || isMutatingRef.current) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const result = await handler();
|
|
19
|
+
if (result === "cancel") {
|
|
20
|
+
event.abortNavigation();
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (result === "save") {
|
|
24
|
+
try {
|
|
25
|
+
const result2 = await persist();
|
|
26
|
+
options?.onPersistSuccess?.(result2);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
options?.onPersistError?.(e);
|
|
29
|
+
event.abortNavigation();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}, [handler, options, persist]));
|
|
34
|
+
};
|
|
35
|
+
exports.useBlockNavigationOnDirtyState = useBlockNavigationOnDirtyState;
|
|
36
|
+
//# sourceMappingURL=useBlockNavigationOnDirtyState.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBlockNavigationOnDirtyState.cjs","sources":["../../../../../packages/interface/src/hooks/useBlockNavigationOnDirtyState.ts"],"sourcesContent":["import { ErrorPersistResult, SuccessfulPersistResult, useDirtinessState, useMutationState, usePersist } from '@contember/react-binding'\nimport { useCallback, useRef } from 'react'\nimport { useRegisterRequestChangeListener } from '@contember/react-routing'\n\nexport type BlockNavigationOnDirtyStateResult = 'save' | 'discard' | 'cancel'\n\nexport const useBlockNavigationOnDirtyState = (handler: () => Promise<BlockNavigationOnDirtyStateResult>, options?: {\n\tonPersistSuccess?: (result: SuccessfulPersistResult) => void\n\tonPersistError?: (result: ErrorPersistResult) => void\n}) => {\n\tconst isDirty = useDirtinessState()\n\tconst isDirtyRef = useRef(isDirty)\n\tisDirtyRef.current = isDirty\n\tconst isMutating = useMutationState()\n\tconst isMutatingRef = useRef(isMutating)\n\tisMutatingRef.current = isMutating\n\tconst persist = usePersist()\n\n\tuseRegisterRequestChangeListener(useCallback(async event => {\n\t\tif (!isDirtyRef.current || isMutatingRef.current) {\n\t\t\treturn\n\t\t}\n\t\tconst result = await handler()\n\t\tif (result === 'cancel') {\n\t\t\tevent.abortNavigation()\n\t\t\treturn\n\t\t}\n\n\t\tif (result === 'save') {\n\t\t\ttry {\n\t\t\t\tconst result = await persist()\n\t\t\t\toptions?.onPersistSuccess?.(result)\n\t\t\t} catch (e: any) {\n\t\t\t\toptions?.onPersistError?.(e)\n\t\t\t\tevent.abortNavigation()\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\t}, [handler, options, persist]))\n}\n"],"names":["useDirtinessState","useRef","useMutationState","usePersist","useRegisterRequestChangeListener","useCallback","result"],"mappings":";;;;;AAMO,MAAM,iCAAiC,CAAC,SAA2D,YAGpG;AACL,QAAM,UAAUA,aAAAA,kBAAA;AAChB,QAAM,aAAaC,MAAAA,OAAO,OAAO;AACjC,aAAW,UAAU;AACrB,QAAM,aAAaC,aAAAA,iBAAA;AACnB,QAAM,gBAAgBD,MAAAA,OAAO,UAAU;AACvC,gBAAc,UAAU;AACxB,QAAM,UAAUE,aAAAA,WAAA;AAEhBC,gDAAiCC,MAAAA,YAAY,OAAM,UAAS;AAC3D,QAAI,CAAC,WAAW,WAAW,cAAc,SAAS;AACjD;AAAA,IACD;AACA,UAAM,SAAS,MAAM,QAAA;AACrB,QAAI,WAAW,UAAU;AACxB,YAAM,gBAAA;AACN;AAAA,IACD;AAEA,QAAI,WAAW,QAAQ;AACtB,UAAI;AACH,cAAMC,UAAS,MAAM,QAAA;AACrB,iBAAS,mBAAmBA,OAAM;AAAA,MACnC,SAAS,GAAQ;AAChB,iBAAS,iBAAiB,CAAC;AAC3B,cAAM,gBAAA;AACN;AAAA,MACD;AAAA,IACD;AAAA,EACD,GAAG,CAAC,SAAS,SAAS,OAAO,CAAC,CAAC;AAChC;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useDirtinessState, useMutationState, usePersist } from "@contember/react-binding";
|
|
2
|
+
import { useRef, useCallback } from "react";
|
|
3
|
+
import { useRegisterRequestChangeListener } from "@contember/react-routing";
|
|
4
|
+
const useBlockNavigationOnDirtyState = (handler, options) => {
|
|
5
|
+
const isDirty = useDirtinessState();
|
|
6
|
+
const isDirtyRef = useRef(isDirty);
|
|
7
|
+
isDirtyRef.current = isDirty;
|
|
8
|
+
const isMutating = useMutationState();
|
|
9
|
+
const isMutatingRef = useRef(isMutating);
|
|
10
|
+
isMutatingRef.current = isMutating;
|
|
11
|
+
const persist = usePersist();
|
|
12
|
+
useRegisterRequestChangeListener(useCallback(async (event) => {
|
|
13
|
+
if (!isDirtyRef.current || isMutatingRef.current) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const result = await handler();
|
|
17
|
+
if (result === "cancel") {
|
|
18
|
+
event.abortNavigation();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (result === "save") {
|
|
22
|
+
try {
|
|
23
|
+
const result2 = await persist();
|
|
24
|
+
options?.onPersistSuccess?.(result2);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
options?.onPersistError?.(e);
|
|
27
|
+
event.abortNavigation();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, [handler, options, persist]));
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
useBlockNavigationOnDirtyState
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=useBlockNavigationOnDirtyState.js.map
|