@contember/interface 2.0.0-alpha.4 → 2.0.0-alpha.40
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/api-extractor.json +3 -0
- package/dist/development/index.cjs +20 -25
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +8 -10
- package/dist/development/index.js.map +1 -1
- package/dist/development/{bootstrap → src/bootstrap}/ApplicationEntrypoint.cjs +7 -7
- package/dist/development/src/bootstrap/ApplicationEntrypoint.cjs.map +1 -0
- package/dist/development/{bootstrap → src/bootstrap}/ApplicationEntrypoint.js +7 -7
- package/dist/development/src/bootstrap/ApplicationEntrypoint.js.map +1 -0
- package/dist/development/{bootstrap → src/bootstrap}/DataViewPageNameKeyProvider.cjs +1 -1
- package/dist/development/src/bootstrap/DataViewPageNameKeyProvider.cjs.map +1 -0
- package/dist/development/{bootstrap → src/bootstrap}/DataViewPageNameKeyProvider.js +1 -1
- package/dist/development/src/bootstrap/DataViewPageNameKeyProvider.js.map +1 -0
- package/dist/development/{components → src/components}/binding/ClearFieldTrigger.cjs +4 -4
- package/dist/development/src/components/binding/ClearFieldTrigger.cjs.map +1 -0
- package/dist/development/{components → src/components}/binding/ClearFieldTrigger.js +2 -2
- package/dist/development/src/components/binding/ClearFieldTrigger.js.map +1 -0
- package/dist/development/{components → src/components}/binding/DisconnectEntityTrigger.cjs +5 -5
- package/dist/development/src/components/binding/DisconnectEntityTrigger.cjs.map +1 -0
- package/dist/development/{components → src/components}/binding/DisconnectEntityTrigger.js +4 -4
- package/dist/development/src/components/binding/DisconnectEntityTrigger.js.map +1 -0
- package/dist/development/src/components/binding/EntityBeforePersist.cjs.map +1 -0
- package/dist/development/src/components/binding/EntityBeforePersist.js.map +1 -0
- package/dist/{production → development/src}/components/binding/RedirectOnPersist.cjs +2 -2
- package/dist/development/src/components/binding/RedirectOnPersist.cjs.map +1 -0
- package/dist/development/{components → src/components}/binding/RedirectOnPersist.js +2 -2
- 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/{hooks → src/hooks}/useIsApplicationOutdated.cjs +8 -8
- package/dist/development/src/hooks/useIsApplicationOutdated.cjs.map +1 -0
- package/dist/development/{hooks → src/hooks}/useIsApplicationOutdated.js +1 -1
- package/dist/development/src/hooks/useIsApplicationOutdated.js.map +1 -0
- package/dist/production/index.cjs +20 -25
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +8 -10
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/bootstrap/ApplicationEntrypoint.cjs.map +1 -0
- package/dist/production/src/bootstrap/ApplicationEntrypoint.js.map +1 -0
- package/dist/production/src/bootstrap/DataViewPageNameKeyProvider.cjs.map +1 -0
- package/dist/production/src/bootstrap/DataViewPageNameKeyProvider.js.map +1 -0
- package/dist/production/{components → src/components}/binding/ClearFieldTrigger.cjs +2 -2
- package/dist/production/src/components/binding/ClearFieldTrigger.cjs.map +1 -0
- package/dist/production/src/components/binding/ClearFieldTrigger.js.map +1 -0
- package/dist/production/{components → src/components}/binding/DisconnectEntityTrigger.cjs +3 -3
- package/dist/production/src/components/binding/DisconnectEntityTrigger.cjs.map +1 -0
- package/dist/production/{components → src/components}/binding/DisconnectEntityTrigger.js +2 -2
- package/dist/production/src/components/binding/DisconnectEntityTrigger.js.map +1 -0
- package/dist/production/src/components/binding/EntityBeforePersist.cjs.map +1 -0
- package/dist/production/src/components/binding/EntityBeforePersist.js.map +1 -0
- package/dist/{development → production/src}/components/binding/RedirectOnPersist.cjs +2 -2
- package/dist/production/src/components/binding/RedirectOnPersist.cjs.map +1 -0
- package/dist/production/{components → src/components}/binding/RedirectOnPersist.js +2 -2
- 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/{hooks → src/hooks}/useIsApplicationOutdated.cjs +8 -8
- package/dist/production/src/hooks/useIsApplicationOutdated.cjs.map +1 -0
- package/dist/production/{hooks → src/hooks}/useIsApplicationOutdated.js +1 -1
- package/dist/production/src/hooks/useIsApplicationOutdated.js.map +1 -0
- package/dist/types/bootstrap/ApplicationEntrypoint.d.ts.map +1 -1
- package/dist/types/components/binding/DisconnectEntityTrigger.d.ts.map +1 -1
- package/dist/types/components/binding/EntityBeforePersist.d.ts +1 -1
- package/dist/types/components/binding/EntityBeforePersist.d.ts.map +1 -1
- package/dist/types/components/binding/RedirectOnPersist.d.ts +3 -1
- package/dist/types/components/binding/RedirectOnPersist.d.ts.map +1 -1
- package/dist/types/components/binding/index.d.ts +0 -2
- package/dist/types/components/binding/index.d.ts.map +1 -1
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/index.d.ts.map +1 -1
- package/dist/types/hooks/useBlockNavigationOnDirtyState.d.ts +7 -0
- package/dist/types/hooks/useBlockNavigationOnDirtyState.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -21
- package/src/bootstrap/ApplicationEntrypoint.tsx +1 -1
- package/src/components/binding/DisconnectEntityTrigger.tsx +3 -2
- package/src/components/binding/RedirectOnPersist.tsx +3 -3
- package/src/components/binding/index.ts +0 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useBlockNavigationOnDirtyState.ts +40 -0
- package/src/hooks/useIsApplicationOutdated.ts +1 -1
- package/src/tsconfig.json +0 -1
- package/tsconfig.json +7 -0
- package/tsdoc.json +6 -0
- package/dist/development/bootstrap/ApplicationEntrypoint.cjs.map +0 -1
- package/dist/development/bootstrap/ApplicationEntrypoint.js.map +0 -1
- package/dist/development/bootstrap/DataViewPageNameKeyProvider.cjs.map +0 -1
- package/dist/development/bootstrap/DataViewPageNameKeyProvider.js.map +0 -1
- package/dist/development/components/binding/ClearFieldTrigger.cjs.map +0 -1
- package/dist/development/components/binding/ClearFieldTrigger.js.map +0 -1
- package/dist/development/components/binding/DeleteEntityTrigger.cjs +0 -36
- package/dist/development/components/binding/DeleteEntityTrigger.cjs.map +0 -1
- package/dist/development/components/binding/DeleteEntityTrigger.js +0 -36
- package/dist/development/components/binding/DeleteEntityTrigger.js.map +0 -1
- package/dist/development/components/binding/DisconnectEntityTrigger.cjs.map +0 -1
- package/dist/development/components/binding/DisconnectEntityTrigger.js.map +0 -1
- package/dist/development/components/binding/EntityBeforePersist.cjs.map +0 -1
- package/dist/development/components/binding/EntityBeforePersist.js.map +0 -1
- package/dist/development/components/binding/PersistTrigger.cjs +0 -37
- package/dist/development/components/binding/PersistTrigger.cjs.map +0 -1
- package/dist/development/components/binding/PersistTrigger.js +0 -37
- package/dist/development/components/binding/PersistTrigger.js.map +0 -1
- package/dist/development/components/binding/RedirectOnPersist.cjs.map +0 -1
- package/dist/development/components/binding/RedirectOnPersist.js.map +0 -1
- package/dist/development/hooks/useIsApplicationOutdated.cjs.map +0 -1
- package/dist/development/hooks/useIsApplicationOutdated.js.map +0 -1
- package/dist/production/bootstrap/ApplicationEntrypoint.cjs.map +0 -1
- package/dist/production/bootstrap/ApplicationEntrypoint.js.map +0 -1
- package/dist/production/bootstrap/DataViewPageNameKeyProvider.cjs.map +0 -1
- package/dist/production/bootstrap/DataViewPageNameKeyProvider.js.map +0 -1
- package/dist/production/components/binding/ClearFieldTrigger.cjs.map +0 -1
- package/dist/production/components/binding/ClearFieldTrigger.js.map +0 -1
- package/dist/production/components/binding/DeleteEntityTrigger.cjs +0 -28
- package/dist/production/components/binding/DeleteEntityTrigger.cjs.map +0 -1
- package/dist/production/components/binding/DeleteEntityTrigger.js +0 -28
- package/dist/production/components/binding/DeleteEntityTrigger.js.map +0 -1
- package/dist/production/components/binding/DisconnectEntityTrigger.cjs.map +0 -1
- package/dist/production/components/binding/DisconnectEntityTrigger.js.map +0 -1
- package/dist/production/components/binding/EntityBeforePersist.cjs.map +0 -1
- package/dist/production/components/binding/EntityBeforePersist.js.map +0 -1
- package/dist/production/components/binding/PersistTrigger.cjs +0 -29
- package/dist/production/components/binding/PersistTrigger.cjs.map +0 -1
- package/dist/production/components/binding/PersistTrigger.js +0 -29
- package/dist/production/components/binding/PersistTrigger.js.map +0 -1
- package/dist/production/components/binding/RedirectOnPersist.cjs.map +0 -1
- package/dist/production/components/binding/RedirectOnPersist.js.map +0 -1
- package/dist/production/hooks/useIsApplicationOutdated.cjs.map +0 -1
- package/dist/production/hooks/useIsApplicationOutdated.js.map +0 -1
- package/dist/types/components/binding/DeleteEntityTrigger.d.ts +0 -10
- package/dist/types/components/binding/DeleteEntityTrigger.d.ts.map +0 -1
- package/dist/types/components/binding/PersistTrigger.d.ts +0 -9
- package/dist/types/components/binding/PersistTrigger.d.ts.map +0 -1
- package/src/components/binding/DeleteEntityTrigger.tsx +0 -36
- package/src/components/binding/PersistTrigger.tsx +0 -35
- /package/dist/development/{components → src/components}/binding/EntityBeforePersist.cjs +0 -0
- /package/dist/development/{components → src/components}/binding/EntityBeforePersist.js +0 -0
- /package/dist/production/{bootstrap → src/bootstrap}/ApplicationEntrypoint.cjs +0 -0
- /package/dist/production/{bootstrap → src/bootstrap}/ApplicationEntrypoint.js +0 -0
- /package/dist/production/{bootstrap → src/bootstrap}/DataViewPageNameKeyProvider.cjs +0 -0
- /package/dist/production/{bootstrap → src/bootstrap}/DataViewPageNameKeyProvider.js +0 -0
- /package/dist/production/{components → src/components}/binding/ClearFieldTrigger.js +0 -0
- /package/dist/production/{components → src/components}/binding/EntityBeforePersist.cjs +0 -0
- /package/dist/production/{components → src/components}/binding/EntityBeforePersist.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsApplicationOutdated.cjs","sources":["../../../../../packages/interface/src/hooks/useIsApplicationOutdated.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nconst defaultCheckIntervalMs = 30_000\n\n\nexport const useIsApplicationOutdated = ({ checkIntervalMs = defaultCheckIntervalMs }: {\n\tcheckIntervalMs?: number\n} = {}) => {\n\tconst [initialVersion] = useState(() => {\n\t\treturn getVersionFromDocument(document.head)\n\t})\n\tconst [isOutdated, setIsOutdated] = useState(false)\n\tconst fetchVersion = useFetchVersion()\n\n\tconst checkVersion = useCallback(async () => {\n\t\tif (document.hidden) {\n\t\t\treturn\n\t\t}\n\t\tconst version = await fetchVersion()\n\t\tif (version && version !== initialVersion) {\n\t\t\tsetIsOutdated(true)\n\t\t}\n\t}, [fetchVersion, initialVersion])\n\tconst shouldCheck = !!initialVersion && !isOutdated\n\n\tuseEffect(() => {\n\t\tif (!shouldCheck) {\n\t\t\treturn\n\t\t}\n\t\tconst handle = setInterval(checkVersion, checkIntervalMs)\n\t\treturn () => clearInterval(handle)\n\t}, [checkIntervalMs, checkVersion, shouldCheck])\n\n\tuseEffect(() => {\n\t\tif (!shouldCheck) {\n\t\t\treturn\n\t\t}\n\t\tdocument.addEventListener('visibilitychange', checkVersion)\n\t\treturn () => document.removeEventListener('visibilitychange', checkVersion)\n\t}, [checkVersion, shouldCheck])\n\n\treturn isOutdated\n}\n\nconst getVersionFromDocument = (node: ParentNode) => {\n\tconst meta = node.querySelector<HTMLMetaElement>('meta[name=contember-build-version]')\n\treturn meta?.content\n}\n\nconst useFetchVersion = () => {\n\treturn useCallback(async () => {\n\t\ttry {\n\t\t\tconst result = await (await fetch(window.location.href)).text()\n\t\t\tconst html = document.createElement('html')\n\t\t\thtml.innerHTML = result\n\t\t\treturn getVersionFromDocument(html)\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn undefined\n\t\t}\n\t}, [])\n}\n"],"names":["useState","useCallback","useEffect"],"mappings":";;;AAEA,MAAM,yBAAyB;AAGxB,MAAM,2BAA2B,CAAC,EAAE,kBAAkB,uBAAuB,IAEhF,CAAA,MAAO;AACV,QAAM,CAAC,cAAc,IAAIA,MAAAA,SAAS,MAAM;AAChC,WAAA,uBAAuB,SAAS,IAAI;AAAA,EAAA,CAC3C;AACD,QAAM,CAAC,YAAY,aAAa,IAAIA,MAAAA,SAAS,KAAK;AAClD,QAAM,eAAe,gBAAgB;AAE/B,QAAA,eAAeC,MAAAA,YAAY,YAAY;AAC5C,QAAI,SAAS,QAAQ;AACpB;AAAA,IAAA;AAEK,UAAA,UAAU,MAAM,aAAa;AAC/B,QAAA,WAAW,YAAY,gBAAgB;AAC1C,oBAAc,IAAI;AAAA,IAAA;AAAA,EACnB,GACE,CAAC,cAAc,cAAc,CAAC;AACjC,QAAM,cAAc,CAAC,CAAC,kBAAkB,CAAC;AAEzCC,QAAAA,UAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IAAA;AAEK,UAAA,SAAS,YAAY,cAAc,eAAe;AACjD,WAAA,MAAM,cAAc,MAAM;AAAA,EAC/B,GAAA,CAAC,iBAAiB,cAAc,WAAW,CAAC;AAE/CA,QAAAA,UAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IAAA;AAEQ,aAAA,iBAAiB,oBAAoB,YAAY;AAC1D,WAAO,MAAM,SAAS,oBAAoB,oBAAoB,YAAY;AAAA,EAAA,GACxE,CAAC,cAAc,WAAW,CAAC;AAEvB,SAAA;AACR;AAEA,MAAM,yBAAyB,CAAC,SAAqB;AAC9C,QAAA,OAAO,KAAK,cAA+B,oCAAoC;AACrF,SAAO,MAAM;AACd;AAEA,MAAM,kBAAkB,MAAM;AAC7B,SAAOD,kBAAY,YAAY;AAC1B,QAAA;AACG,YAAA,SAAS,OAAO,MAAM,MAAM,OAAO,SAAS,IAAI,GAAG,KAAK;AACxD,YAAA,OAAO,SAAS,cAAc,MAAM;AAC1C,WAAK,YAAY;AACjB,aAAO,uBAAuB,IAAI;AAAA,aAC1B,GAAG;AACX,cAAQ,MAAM,CAAC;AACR,aAAA;AAAA,IAAA;AAAA,EAET,GAAG,EAAE;AACN;;"}
|
|
@@ -11,7 +11,7 @@ const useIsApplicationOutdated = ({ checkIntervalMs = defaultCheckIntervalMs } =
|
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
const version = await fetchVersion();
|
|
14
|
-
if (version !== initialVersion) {
|
|
14
|
+
if (version && version !== initialVersion) {
|
|
15
15
|
setIsOutdated(true);
|
|
16
16
|
}
|
|
17
17
|
}, [fetchVersion, initialVersion]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsApplicationOutdated.js","sources":["../../../../../packages/interface/src/hooks/useIsApplicationOutdated.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nconst defaultCheckIntervalMs = 30_000\n\n\nexport const useIsApplicationOutdated = ({ checkIntervalMs = defaultCheckIntervalMs }: {\n\tcheckIntervalMs?: number\n} = {}) => {\n\tconst [initialVersion] = useState(() => {\n\t\treturn getVersionFromDocument(document.head)\n\t})\n\tconst [isOutdated, setIsOutdated] = useState(false)\n\tconst fetchVersion = useFetchVersion()\n\n\tconst checkVersion = useCallback(async () => {\n\t\tif (document.hidden) {\n\t\t\treturn\n\t\t}\n\t\tconst version = await fetchVersion()\n\t\tif (version && version !== initialVersion) {\n\t\t\tsetIsOutdated(true)\n\t\t}\n\t}, [fetchVersion, initialVersion])\n\tconst shouldCheck = !!initialVersion && !isOutdated\n\n\tuseEffect(() => {\n\t\tif (!shouldCheck) {\n\t\t\treturn\n\t\t}\n\t\tconst handle = setInterval(checkVersion, checkIntervalMs)\n\t\treturn () => clearInterval(handle)\n\t}, [checkIntervalMs, checkVersion, shouldCheck])\n\n\tuseEffect(() => {\n\t\tif (!shouldCheck) {\n\t\t\treturn\n\t\t}\n\t\tdocument.addEventListener('visibilitychange', checkVersion)\n\t\treturn () => document.removeEventListener('visibilitychange', checkVersion)\n\t}, [checkVersion, shouldCheck])\n\n\treturn isOutdated\n}\n\nconst getVersionFromDocument = (node: ParentNode) => {\n\tconst meta = node.querySelector<HTMLMetaElement>('meta[name=contember-build-version]')\n\treturn meta?.content\n}\n\nconst useFetchVersion = () => {\n\treturn useCallback(async () => {\n\t\ttry {\n\t\t\tconst result = await (await fetch(window.location.href)).text()\n\t\t\tconst html = document.createElement('html')\n\t\t\thtml.innerHTML = result\n\t\t\treturn getVersionFromDocument(html)\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn undefined\n\t\t}\n\t}, [])\n}\n"],"names":[],"mappings":";AAEA,MAAM,yBAAyB;AAGxB,MAAM,2BAA2B,CAAC,EAAE,kBAAkB,uBAAuB,IAEhF,CAAA,MAAO;AACV,QAAM,CAAC,cAAc,IAAI,SAAS,MAAM;AAChC,WAAA,uBAAuB,SAAS,IAAI;AAAA,EAAA,CAC3C;AACD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,eAAe,gBAAgB;AAE/B,QAAA,eAAe,YAAY,YAAY;AAC5C,QAAI,SAAS,QAAQ;AACpB;AAAA,IAAA;AAEK,UAAA,UAAU,MAAM,aAAa;AAC/B,QAAA,WAAW,YAAY,gBAAgB;AAC1C,oBAAc,IAAI;AAAA,IAAA;AAAA,EACnB,GACE,CAAC,cAAc,cAAc,CAAC;AACjC,QAAM,cAAc,CAAC,CAAC,kBAAkB,CAAC;AAEzC,YAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IAAA;AAEK,UAAA,SAAS,YAAY,cAAc,eAAe;AACjD,WAAA,MAAM,cAAc,MAAM;AAAA,EAC/B,GAAA,CAAC,iBAAiB,cAAc,WAAW,CAAC;AAE/C,YAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IAAA;AAEQ,aAAA,iBAAiB,oBAAoB,YAAY;AAC1D,WAAO,MAAM,SAAS,oBAAoB,oBAAoB,YAAY;AAAA,EAAA,GACxE,CAAC,cAAc,WAAW,CAAC;AAEvB,SAAA;AACR;AAEA,MAAM,yBAAyB,CAAC,SAAqB;AAC9C,QAAA,OAAO,KAAK,cAA+B,oCAAoC;AACrF,SAAO,MAAM;AACd;AAEA,MAAM,kBAAkB,MAAM;AAC7B,SAAO,YAAY,YAAY;AAC1B,QAAA;AACG,YAAA,SAAS,OAAO,MAAM,MAAM,OAAO,SAAS,IAAI,GAAG,KAAK;AACxD,YAAA,OAAO,SAAS,cAAc,MAAM;AAC1C,WAAK,YAAY;AACjB,aAAO,uBAAuB,IAAI;AAAA,aAC1B,GAAG;AACX,cAAQ,MAAM,CAAC;AACR,aAAA;AAAA,IAAA;AAAA,EAET,GAAG,EAAE;AACN;"}
|
|
@@ -4,45 +4,40 @@ const reactRouting = require("@contember/react-routing");
|
|
|
4
4
|
const reactBinding = require("@contember/react-binding");
|
|
5
5
|
const reactIdentity = require("@contember/react-identity");
|
|
6
6
|
const reactDevbar = require("@contember/react-devbar");
|
|
7
|
-
const ApplicationEntrypoint = require("./bootstrap/ApplicationEntrypoint.cjs");
|
|
8
|
-
const ClearFieldTrigger = require("./components/binding/ClearFieldTrigger.cjs");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const useIsApplicationOutdated = require("./hooks/useIsApplicationOutdated.cjs");
|
|
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 useIsApplicationOutdated = require("./src/hooks/useIsApplicationOutdated.cjs");
|
|
13
|
+
const useBlockNavigationOnDirtyState = require("./src/hooks/useBlockNavigationOnDirtyState.cjs");
|
|
15
14
|
Object.defineProperty(exports, "createErrorHandler", {
|
|
16
15
|
enumerable: true,
|
|
17
16
|
get: () => reactDevbar.createErrorHandler
|
|
18
17
|
});
|
|
19
18
|
exports.ApplicationEntrypoint = ApplicationEntrypoint.ApplicationEntrypoint;
|
|
20
19
|
exports.ClearFieldTrigger = ClearFieldTrigger.ClearFieldTrigger;
|
|
21
|
-
exports.DeleteEntityTrigger = DeleteEntityTrigger.DeleteEntityTrigger;
|
|
22
20
|
exports.DisconnectEntityTrigger = DisconnectEntityTrigger.DisconnectEntityTrigger;
|
|
23
|
-
exports.PersistTrigger = PersistTrigger.PersistTrigger;
|
|
24
21
|
exports.EntityBeforePersist = EntityBeforePersist.EntityBeforePersist;
|
|
25
22
|
exports.RedirectOnPersist = RedirectOnPersist.RedirectOnPersist;
|
|
26
23
|
exports.useIsApplicationOutdated = useIsApplicationOutdated.useIsApplicationOutdated;
|
|
24
|
+
exports.useBlockNavigationOnDirtyState = useBlockNavigationOnDirtyState.useBlockNavigationOnDirtyState;
|
|
27
25
|
Object.keys(reactRouting).forEach((k) => {
|
|
28
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
26
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: () => reactRouting[k]
|
|
29
|
+
});
|
|
33
30
|
});
|
|
34
31
|
Object.keys(reactBinding).forEach((k) => {
|
|
35
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
32
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: () => reactBinding[k]
|
|
35
|
+
});
|
|
40
36
|
});
|
|
41
37
|
Object.keys(reactIdentity).forEach((k) => {
|
|
42
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
38
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: () => reactIdentity[k]
|
|
41
|
+
});
|
|
47
42
|
});
|
|
48
43
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -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
|
@@ -2,23 +2,21 @@ export * from "@contember/react-routing";
|
|
|
2
2
|
export * from "@contember/react-binding";
|
|
3
3
|
export * from "@contember/react-identity";
|
|
4
4
|
import { createErrorHandler } from "@contember/react-devbar";
|
|
5
|
-
import { ApplicationEntrypoint } from "./bootstrap/ApplicationEntrypoint.js";
|
|
6
|
-
import { ClearFieldTrigger } from "./components/binding/ClearFieldTrigger.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { useIsApplicationOutdated } from "./hooks/useIsApplicationOutdated.js";
|
|
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 { useIsApplicationOutdated } from "./src/hooks/useIsApplicationOutdated.js";
|
|
11
|
+
import { useBlockNavigationOnDirtyState } from "./src/hooks/useBlockNavigationOnDirtyState.js";
|
|
13
12
|
export {
|
|
14
13
|
ApplicationEntrypoint,
|
|
15
14
|
ClearFieldTrigger,
|
|
16
|
-
DeleteEntityTrigger,
|
|
17
15
|
DisconnectEntityTrigger,
|
|
18
16
|
EntityBeforePersist,
|
|
19
|
-
PersistTrigger,
|
|
20
17
|
RedirectOnPersist,
|
|
21
18
|
createErrorHandler,
|
|
19
|
+
useBlockNavigationOnDirtyState,
|
|
22
20
|
useIsApplicationOutdated
|
|
23
21
|
};
|
|
24
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -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\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","jsx","EnvironmentContext","RoutingProvider","ContemberClient","EnvironmentExtensionProvider","projectEnvironmentExtension","DataViewPageNameKeyProvider","IdentityProvider","IdentityEnvironmentProvider"],"mappings":";;;;;;;;AAeA,MAAM,gBAAgB,CAAC,UAA+C;AACjE,MAAA,OAAO,MAAM,eAAe,UAAU;AACnC,UAAA,IAAI,MAAM,iFAAiF;AAAA,EAAA;AAEnG;AAKa,MAAA,wBAAwB,CAAC,UAAsC;AAC3E,gBAAc,KAAK;AAEnB,QAAM,UAAU,MAAM,eAAeA,aAAAA,YAAY,OAAO;AAExD,QAAM,UAA+B;AAAA,IACpC,UAAU,MAAM;AAAA,IAChB,QAAQ,MAAM,UAAU,EAAE,OAAO,EAAE,MAAM,MAAM;AAAA,IAC/C,mBAAmB,QAAQ,iBAAiB;AAAA,EAC7C;AAIC,SAAAC,2BAAA,IAACC,gCAAmB,UAAnB,EAA4B,OAAO,SACnC,UAAAD,2BAAAA,IAACE,aAAAA,iBAAiB,EAAA,GAAG,SACpB,UAAAF,2BAAA;AAAA,IAACG,YAAA;AAAA,IAAA;AAAA,MACA,YAAY,MAAM;AAAA,MAClB,cAAc,MAAM;AAAA,MACpB,YAAY,MAAM;AAAA,MAClB,SAAS,MAAM;AAAA,MACf,OAAO,MAAM;AAAA,MAEb,yCAACC,2CAA6B,EAAA,WAAWC,2CAA6B,OAAO,MAAM,WAAW,MAC7F,UAAAL,2BAAA,IAACM,4BACA,6BAAA,EAAA,UAAAN,2BAAA,IAACO,kCACA,UAACP,2BAAA,IAAAQ,cAAA,6BAAA,EACC,gBAAM,SACR,CAAA,EACD,CAAA,EACD,CAAA,EACD,CAAA;AAAA,IAAA;AAAA,KAEF,EACD,CAAA;AAEF;;"}
|
|
@@ -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\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":[],"mappings":";;;;;;AAeA,MAAM,gBAAgB,CAAC,UAA+C;AACjE,MAAA,OAAO,MAAM,eAAe,UAAU;AACnC,UAAA,IAAI,MAAM,iFAAiF;AAAA,EAAA;AAEnG;AAKa,MAAA,wBAAwB,CAAC,UAAsC;AAC3E,gBAAc,KAAK;AAEnB,QAAM,UAAU,MAAM,eAAe,YAAY,OAAO;AAExD,QAAM,UAA+B;AAAA,IACpC,UAAU,MAAM;AAAA,IAChB,QAAQ,MAAM,UAAU,EAAE,OAAO,EAAE,MAAM,MAAM;AAAA,IAC/C,mBAAmB,QAAQ,iBAAiB;AAAA,EAC7C;AAIC,SAAA,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,SACnC,UAAA,oBAAC,iBAAiB,EAAA,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,8BAAC,8BAA6B,EAAA,WAAW,6BAA6B,OAAO,MAAM,WAAW,MAC7F,UAAA,oBAAC,6BACA,EAAA,UAAA,oBAAC,oBACA,UAAC,oBAAA,6BAAA,EACC,gBAAM,SACR,CAAA,EACD,CAAA,EACD,CAAA,EACD,CAAA;AAAA,IAAA;AAAA,KAEF,EACD,CAAA;AAEF;"}
|
|
@@ -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","jsx","DataViewKeyProvider"],"mappings":";;;;;AAIO,MAAM,8BAA8B,CAAC,EAAE,eAAwC;AAC/E,QAAA,WAAWA,kCAAqB;AAEtC,SACEC,2BAAAA,IAAAC,cAAAA,qBAAA,EAAoB,OAAO,YAAY,IACtC,UACF;AAEF;;"}
|
|
@@ -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":[],"mappings":";;;AAIO,MAAM,8BAA8B,CAAC,EAAE,eAAwC;AAC/E,QAAA,WAAW,qBAAqB;AAEtC,SACE,oBAAA,qBAAA,EAAoB,OAAO,YAAY,IACtC,UACF;AAEF;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const reactSlot = require("@radix-ui/react-slot");
|
|
6
6
|
const reactBinding = require("@contember/react-binding");
|
|
7
7
|
const ClearFieldTrigger = reactBinding.Component(({ field, ...props }) => {
|
|
8
8
|
const fieldAccessor = reactBinding.useField(field);
|
|
9
|
-
const clearField =
|
|
9
|
+
const clearField = React.useCallback(() => {
|
|
10
10
|
fieldAccessor.updateValue(null);
|
|
11
11
|
}, [fieldAccessor]);
|
|
12
12
|
return /* @__PURE__ */ jsxRuntime.jsx(reactSlot.Slot, { onClick: clearField, ...props });
|
|
@@ -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","jsx","Slot","Field"],"mappings":";;;;;;AASO,MAAM,oBAAoBA,aAAAA,UAAkC,CAAC,EAAE,OAAO,GAAG,YAAY;AACrF,QAAA,gBAAgBC,sBAAS,KAAK;AAC9B,QAAA,aAAaC,MAAAA,YAAY,MAAM;AACpC,kBAAc,YAAY,IAAI;AAAA,EAAA,GAC5B,CAAC,aAAa,CAAC;AAClB,SAAQC,2BAAAA,IAAAC,UAAAA,MAAA,EAAK,SAAS,YAAa,GAAG,OAAO;AAC9C,GAAG,CAAC,EAAE,YAAY;AACV,SAAAD,+BAACE,aAAAA,SAAM,OAAc;AAC7B,CAAC;;"}
|
|
@@ -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":[],"mappings":";;;;AASO,MAAM,oBAAoB,UAAkC,CAAC,EAAE,OAAO,GAAG,YAAY;AACrF,QAAA,gBAAgB,SAAS,KAAK;AAC9B,QAAA,aAAa,YAAY,MAAM;AACpC,kBAAc,YAAY,IAAI;AAAA,EAAA,GAC5B,CAAC,aAAa,CAAC;AAClB,SAAQ,oBAAA,MAAA,EAAK,SAAS,YAAa,GAAG,OAAO;AAC9C,GAAG,CAAC,EAAE,YAAY;AACV,SAAA,oBAAC,SAAM,OAAc;AAC7B,CAAC;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
4
|
+
const React = require("react");
|
|
5
5
|
const reactSlot = require("@radix-ui/react-slot");
|
|
6
6
|
const reactBinding = require("@contember/react-binding");
|
|
7
7
|
const SlotButton = reactSlot.Slot;
|
|
@@ -9,7 +9,7 @@ const DisconnectEntityTrigger = ({ immediatePersist, onPersistError, onPersistSu
|
|
|
9
9
|
const entity = reactBinding.useEntity();
|
|
10
10
|
const triggerPersist = reactBinding.usePersist();
|
|
11
11
|
const isMutating = reactBinding.useMutationState();
|
|
12
|
-
const onClick =
|
|
12
|
+
const onClick = React.useCallback(() => {
|
|
13
13
|
if (field) {
|
|
14
14
|
entity.disconnectEntityAtField({ field });
|
|
15
15
|
} else {
|
|
@@ -17,7 +17,7 @@ const DisconnectEntityTrigger = ({ immediatePersist, onPersistError, onPersistSu
|
|
|
17
17
|
if (!parent) {
|
|
18
18
|
throw new reactBinding.BindingError("Cannot disconnect root entity");
|
|
19
19
|
}
|
|
20
|
-
if (
|
|
20
|
+
if (reactBinding.isEntityListAccessor(parent)) {
|
|
21
21
|
parent.disconnectEntity(entity);
|
|
22
22
|
} else {
|
|
23
23
|
const subTreeNode = entity.environment.getSubTreeNode();
|
|
@@ -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 { BindingError, EntityListAccessor, ErrorPersistResult,\n\tisEntityListAccessor, SuccessfulPersistResult, SugaredRelativeSingleEntity, useEntity, useMutationState, usePersist } from '@contember/react-binding'\n\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","jsx"],"mappings":";;;;;;AAMA,MAAM,aAAaA,UAAA;AAUN,MAAA,0BAA0B,CAAC,EAAE,kBAAkB,gBAAgB,kBAAkB,OAAO,GAAG,YAA0C;AACjJ,QAAM,SAASC,aAAAA,UAAU;AACzB,QAAM,iBAAiBC,aAAAA,WAAW;AAClC,QAAM,aAAaC,aAAAA,iBAAiB;AAC9B,QAAA,UAAUC,MAAAA,YAAY,MAAM;AACjC,QAAI,OAAO;AACH,aAAA,wBAAwB,EAAE,OAAO;AAAA,IAAA,OAClC;AACA,YAAA,SAAS,OAAO,UAAU;AAChC,UAAI,CAAC,QAAQ;AACN,cAAA,IAAIC,0BAAa,+BAA+B;AAAA,MAAA;AAEnD,UAAAC,aAAAA,qBAAqB,MAAM,GAAG;AACjC,eAAO,iBAAiB,MAAM;AAAA,MAAA,OACxB;AACA,cAAA,cAAc,OAAO,YAAY,eAAe;AAClD,YAAA,YAAY,SAAS,UAAU;AAC5B,gBAAA,IAAID,0BAAa,+BAA+B;AAAA,QAAA;AAEvD,eAAO,wBAAwB,EAAE,OAAO,YAAY,MAAM,MAAM;AAAA,MAAA;AAAA,IACjE;AAGD,QAAI,kBAAkB;AACrB,qBACE,EAAA,KAAK,gBAAgB,EACrB,MAAM,cAAc;AAAA,IAAA;AAAA,EACvB,GACE,CAAC,OAAO,kBAAkB,QAAQ,gBAAgB,kBAAkB,cAAc,CAAC;AAGrF,SAAAE,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,UAAU,aAAa,OAAO;AAAA,MAC7B,GAAG;AAAA,IAAA;AAAA,EACL;AAEF;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
-
import { useEntity, usePersist, useMutationState, BindingError,
|
|
4
|
+
import { useEntity, usePersist, useMutationState, BindingError, isEntityListAccessor } from "@contember/react-binding";
|
|
5
5
|
const SlotButton = Slot;
|
|
6
6
|
const DisconnectEntityTrigger = ({ immediatePersist, onPersistError, onPersistSuccess, field, ...props }) => {
|
|
7
7
|
const entity = useEntity();
|
|
@@ -15,7 +15,7 @@ const DisconnectEntityTrigger = ({ immediatePersist, onPersistError, onPersistSu
|
|
|
15
15
|
if (!parent) {
|
|
16
16
|
throw new BindingError("Cannot disconnect root entity");
|
|
17
17
|
}
|
|
18
|
-
if (parent
|
|
18
|
+
if (isEntityListAccessor(parent)) {
|
|
19
19
|
parent.disconnectEntity(entity);
|
|
20
20
|
} else {
|
|
21
21
|
const subTreeNode = entity.environment.getSubTreeNode();
|
|
@@ -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 { BindingError, EntityListAccessor, ErrorPersistResult,\n\tisEntityListAccessor, SuccessfulPersistResult, SugaredRelativeSingleEntity, useEntity, useMutationState, usePersist } from '@contember/react-binding'\n\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":[],"mappings":";;;;AAMA,MAAM,aAAa;AAUN,MAAA,0BAA0B,CAAC,EAAE,kBAAkB,gBAAgB,kBAAkB,OAAO,GAAG,YAA0C;AACjJ,QAAM,SAAS,UAAU;AACzB,QAAM,iBAAiB,WAAW;AAClC,QAAM,aAAa,iBAAiB;AAC9B,QAAA,UAAU,YAAY,MAAM;AACjC,QAAI,OAAO;AACH,aAAA,wBAAwB,EAAE,OAAO;AAAA,IAAA,OAClC;AACA,YAAA,SAAS,OAAO,UAAU;AAChC,UAAI,CAAC,QAAQ;AACN,cAAA,IAAI,aAAa,+BAA+B;AAAA,MAAA;AAEnD,UAAA,qBAAqB,MAAM,GAAG;AACjC,eAAO,iBAAiB,MAAM;AAAA,MAAA,OACxB;AACA,cAAA,cAAc,OAAO,YAAY,eAAe;AAClD,YAAA,YAAY,SAAS,UAAU;AAC5B,gBAAA,IAAI,aAAa,+BAA+B;AAAA,QAAA;AAEvD,eAAO,wBAAwB,EAAE,OAAO,YAAY,MAAM,MAAM;AAAA,MAAA;AAAA,IACjE;AAGD,QAAI,kBAAkB;AACrB,qBACE,EAAA,KAAK,gBAAgB,EACrB,MAAM,cAAc;AAAA,IAAA;AAAA,EACvB,GACE,CAAC,OAAO,kBAAkB,QAAQ,gBAAgB,kBAAkB,cAAc,CAAC;AAGrF,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,UAAU,aAAa,OAAO;AAAA,MAC7B,GAAG;AAAA,IAAA;AAAA,EACL;AAEF;"}
|
|
@@ -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,eAAoF;AACzHA,eAAAA,uBAAuB,QAAQ;AACxB,SAAA;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,eAAoF;AACzH,yBAAuB,QAAQ;AACxB,SAAA;AACR;"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const reactBinding = require("@contember/react-binding");
|
|
4
4
|
const reactRouting = require("@contember/react-routing");
|
|
5
|
-
const RedirectOnPersist = ({ to }) => {
|
|
5
|
+
const RedirectOnPersist = ({ to, parameters }) => {
|
|
6
6
|
const redirect = reactRouting.useRedirect();
|
|
7
7
|
reactBinding.useEntityPersistSuccess((getEntity, options) => {
|
|
8
8
|
if (options.successType !== "justSuccess") {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
redirect(to);
|
|
11
|
+
redirect(to, parameters);
|
|
12
12
|
});
|
|
13
13
|
return null;
|
|
14
14
|
};
|
|
@@ -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,YAAY;AACLC,uCAAA,CAAC,WAAW,YAAY;AAC3C,QAAA,QAAQ,gBAAgB,eAAe;AAC1C;AAAA,IAAA;AAED,aAAS,IAAI,UAAU;AAAA,EAAA,CACvB;AACM,SAAA;AACR;;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useEntityPersistSuccess } from "@contember/react-binding";
|
|
2
2
|
import { useRedirect } from "@contember/react-routing";
|
|
3
|
-
const RedirectOnPersist = ({ to }) => {
|
|
3
|
+
const RedirectOnPersist = ({ to, parameters }) => {
|
|
4
4
|
const redirect = useRedirect();
|
|
5
5
|
useEntityPersistSuccess((getEntity, options) => {
|
|
6
6
|
if (options.successType !== "justSuccess") {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
|
-
redirect(to);
|
|
9
|
+
redirect(to, parameters);
|
|
10
10
|
});
|
|
11
11
|
return null;
|
|
12
12
|
};
|
|
@@ -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,YAAY;AACL,0BAAA,CAAC,WAAW,YAAY;AAC3C,QAAA,QAAQ,gBAAgB,eAAe;AAC1C;AAAA,IAAA;AAED,aAAS,IAAI,UAAU;AAAA,EAAA,CACvB;AACM,SAAA;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":";;;;;AAMa,MAAA,iCAAiC,CAAC,SAA2D,YAGpG;AACL,QAAM,UAAUA,aAAAA,kBAAkB;AAC5B,QAAA,aAAaC,aAAO,OAAO;AACjC,aAAW,UAAU;AACrB,QAAM,aAAaC,aAAAA,iBAAiB;AAC9B,QAAA,gBAAgBD,aAAO,UAAU;AACvC,gBAAc,UAAU;AACxB,QAAM,UAAUE,aAAAA,WAAW;AAEMC,gDAAAC,MAAAA,YAAY,OAAM,UAAS;AAC3D,QAAI,CAAC,WAAW,WAAW,cAAc,SAAS;AACjD;AAAA,IAAA;AAEK,UAAA,SAAS,MAAM,QAAQ;AAC7B,QAAI,WAAW,UAAU;AACxB,YAAM,gBAAgB;AACtB;AAAA,IAAA;AAGD,QAAI,WAAW,QAAQ;AAClB,UAAA;AACGC,cAAAA,UAAS,MAAM,QAAQ;AAC7B,iBAAS,mBAAmBA,OAAM;AAAA,eAC1B,GAAQ;AAChB,iBAAS,iBAAiB,CAAC;AAC3B,cAAM,gBAAgB;AACtB;AAAA,MAAA;AAAA,IACD;AAAA,KAEC,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBlockNavigationOnDirtyState.js","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":["result"],"mappings":";;;AAMa,MAAA,iCAAiC,CAAC,SAA2D,YAGpG;AACL,QAAM,UAAU,kBAAkB;AAC5B,QAAA,aAAa,OAAO,OAAO;AACjC,aAAW,UAAU;AACrB,QAAM,aAAa,iBAAiB;AAC9B,QAAA,gBAAgB,OAAO,UAAU;AACvC,gBAAc,UAAU;AACxB,QAAM,UAAU,WAAW;AAEM,mCAAA,YAAY,OAAM,UAAS;AAC3D,QAAI,CAAC,WAAW,WAAW,cAAc,SAAS;AACjD;AAAA,IAAA;AAEK,UAAA,SAAS,MAAM,QAAQ;AAC7B,QAAI,WAAW,UAAU;AACxB,YAAM,gBAAgB;AACtB;AAAA,IAAA;AAGD,QAAI,WAAW,QAAQ;AAClB,UAAA;AACGA,cAAAA,UAAS,MAAM,QAAQ;AAC7B,iBAAS,mBAAmBA,OAAM;AAAA,eAC1B,GAAQ;AAChB,iBAAS,iBAAiB,CAAC;AAC3B,cAAM,gBAAgB;AACtB;AAAA,MAAA;AAAA,IACD;AAAA,KAEC,CAAC,SAAS,SAAS,OAAO,CAAC,CAAC;AAChC;"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const React = require("react");
|
|
4
4
|
const defaultCheckIntervalMs = 3e4;
|
|
5
5
|
const useIsApplicationOutdated = ({ checkIntervalMs = defaultCheckIntervalMs } = {}) => {
|
|
6
|
-
const [initialVersion] =
|
|
6
|
+
const [initialVersion] = React.useState(() => {
|
|
7
7
|
return getVersionFromDocument(document.head);
|
|
8
8
|
});
|
|
9
|
-
const [isOutdated, setIsOutdated] =
|
|
9
|
+
const [isOutdated, setIsOutdated] = React.useState(false);
|
|
10
10
|
const fetchVersion = useFetchVersion();
|
|
11
|
-
const checkVersion =
|
|
11
|
+
const checkVersion = React.useCallback(async () => {
|
|
12
12
|
if (document.hidden) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
const version = await fetchVersion();
|
|
16
|
-
if (version !== initialVersion) {
|
|
16
|
+
if (version && version !== initialVersion) {
|
|
17
17
|
setIsOutdated(true);
|
|
18
18
|
}
|
|
19
19
|
}, [fetchVersion, initialVersion]);
|
|
20
20
|
const shouldCheck = !!initialVersion && !isOutdated;
|
|
21
|
-
|
|
21
|
+
React.useEffect(() => {
|
|
22
22
|
if (!shouldCheck) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
const handle = setInterval(checkVersion, checkIntervalMs);
|
|
26
26
|
return () => clearInterval(handle);
|
|
27
27
|
}, [checkIntervalMs, checkVersion, shouldCheck]);
|
|
28
|
-
|
|
28
|
+
React.useEffect(() => {
|
|
29
29
|
if (!shouldCheck) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
@@ -39,7 +39,7 @@ const getVersionFromDocument = (node) => {
|
|
|
39
39
|
return meta?.content;
|
|
40
40
|
};
|
|
41
41
|
const useFetchVersion = () => {
|
|
42
|
-
return
|
|
42
|
+
return React.useCallback(async () => {
|
|
43
43
|
try {
|
|
44
44
|
const result = await (await fetch(window.location.href)).text();
|
|
45
45
|
const html = document.createElement("html");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsApplicationOutdated.cjs","sources":["../../../../../packages/interface/src/hooks/useIsApplicationOutdated.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nconst defaultCheckIntervalMs = 30_000\n\n\nexport const useIsApplicationOutdated = ({ checkIntervalMs = defaultCheckIntervalMs }: {\n\tcheckIntervalMs?: number\n} = {}) => {\n\tconst [initialVersion] = useState(() => {\n\t\treturn getVersionFromDocument(document.head)\n\t})\n\tconst [isOutdated, setIsOutdated] = useState(false)\n\tconst fetchVersion = useFetchVersion()\n\n\tconst checkVersion = useCallback(async () => {\n\t\tif (document.hidden) {\n\t\t\treturn\n\t\t}\n\t\tconst version = await fetchVersion()\n\t\tif (version && version !== initialVersion) {\n\t\t\tsetIsOutdated(true)\n\t\t}\n\t}, [fetchVersion, initialVersion])\n\tconst shouldCheck = !!initialVersion && !isOutdated\n\n\tuseEffect(() => {\n\t\tif (!shouldCheck) {\n\t\t\treturn\n\t\t}\n\t\tconst handle = setInterval(checkVersion, checkIntervalMs)\n\t\treturn () => clearInterval(handle)\n\t}, [checkIntervalMs, checkVersion, shouldCheck])\n\n\tuseEffect(() => {\n\t\tif (!shouldCheck) {\n\t\t\treturn\n\t\t}\n\t\tdocument.addEventListener('visibilitychange', checkVersion)\n\t\treturn () => document.removeEventListener('visibilitychange', checkVersion)\n\t}, [checkVersion, shouldCheck])\n\n\treturn isOutdated\n}\n\nconst getVersionFromDocument = (node: ParentNode) => {\n\tconst meta = node.querySelector<HTMLMetaElement>('meta[name=contember-build-version]')\n\treturn meta?.content\n}\n\nconst useFetchVersion = () => {\n\treturn useCallback(async () => {\n\t\ttry {\n\t\t\tconst result = await (await fetch(window.location.href)).text()\n\t\t\tconst html = document.createElement('html')\n\t\t\thtml.innerHTML = result\n\t\t\treturn getVersionFromDocument(html)\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn undefined\n\t\t}\n\t}, [])\n}\n"],"names":["useState","useCallback","useEffect"],"mappings":";;;AAEA,MAAM,yBAAyB;AAGxB,MAAM,2BAA2B,CAAC,EAAE,kBAAkB,uBAAuB,IAEhF,CAAA,MAAO;AACV,QAAM,CAAC,cAAc,IAAIA,MAAAA,SAAS,MAAM;AAChC,WAAA,uBAAuB,SAAS,IAAI;AAAA,EAAA,CAC3C;AACD,QAAM,CAAC,YAAY,aAAa,IAAIA,MAAAA,SAAS,KAAK;AAClD,QAAM,eAAe,gBAAgB;AAE/B,QAAA,eAAeC,MAAAA,YAAY,YAAY;AAC5C,QAAI,SAAS,QAAQ;AACpB;AAAA,IAAA;AAEK,UAAA,UAAU,MAAM,aAAa;AAC/B,QAAA,WAAW,YAAY,gBAAgB;AAC1C,oBAAc,IAAI;AAAA,IAAA;AAAA,EACnB,GACE,CAAC,cAAc,cAAc,CAAC;AACjC,QAAM,cAAc,CAAC,CAAC,kBAAkB,CAAC;AAEzCC,QAAAA,UAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IAAA;AAEK,UAAA,SAAS,YAAY,cAAc,eAAe;AACjD,WAAA,MAAM,cAAc,MAAM;AAAA,EAC/B,GAAA,CAAC,iBAAiB,cAAc,WAAW,CAAC;AAE/CA,QAAAA,UAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IAAA;AAEQ,aAAA,iBAAiB,oBAAoB,YAAY;AAC1D,WAAO,MAAM,SAAS,oBAAoB,oBAAoB,YAAY;AAAA,EAAA,GACxE,CAAC,cAAc,WAAW,CAAC;AAEvB,SAAA;AACR;AAEA,MAAM,yBAAyB,CAAC,SAAqB;AAC9C,QAAA,OAAO,KAAK,cAA+B,oCAAoC;AACrF,SAAO,MAAM;AACd;AAEA,MAAM,kBAAkB,MAAM;AAC7B,SAAOD,kBAAY,YAAY;AAC1B,QAAA;AACG,YAAA,SAAS,OAAO,MAAM,MAAM,OAAO,SAAS,IAAI,GAAG,KAAK;AACxD,YAAA,OAAO,SAAS,cAAc,MAAM;AAC1C,WAAK,YAAY;AACjB,aAAO,uBAAuB,IAAI;AAAA,aAC1B,GAAG;AACX,cAAQ,MAAM,CAAC;AACR,aAAA;AAAA,IAAA;AAAA,EAET,GAAG,EAAE;AACN;;"}
|
|
@@ -11,7 +11,7 @@ const useIsApplicationOutdated = ({ checkIntervalMs = defaultCheckIntervalMs } =
|
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
const version = await fetchVersion();
|
|
14
|
-
if (version !== initialVersion) {
|
|
14
|
+
if (version && version !== initialVersion) {
|
|
15
15
|
setIsOutdated(true);
|
|
16
16
|
}
|
|
17
17
|
}, [fetchVersion, initialVersion]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsApplicationOutdated.js","sources":["../../../../../packages/interface/src/hooks/useIsApplicationOutdated.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\n\nconst defaultCheckIntervalMs = 30_000\n\n\nexport const useIsApplicationOutdated = ({ checkIntervalMs = defaultCheckIntervalMs }: {\n\tcheckIntervalMs?: number\n} = {}) => {\n\tconst [initialVersion] = useState(() => {\n\t\treturn getVersionFromDocument(document.head)\n\t})\n\tconst [isOutdated, setIsOutdated] = useState(false)\n\tconst fetchVersion = useFetchVersion()\n\n\tconst checkVersion = useCallback(async () => {\n\t\tif (document.hidden) {\n\t\t\treturn\n\t\t}\n\t\tconst version = await fetchVersion()\n\t\tif (version && version !== initialVersion) {\n\t\t\tsetIsOutdated(true)\n\t\t}\n\t}, [fetchVersion, initialVersion])\n\tconst shouldCheck = !!initialVersion && !isOutdated\n\n\tuseEffect(() => {\n\t\tif (!shouldCheck) {\n\t\t\treturn\n\t\t}\n\t\tconst handle = setInterval(checkVersion, checkIntervalMs)\n\t\treturn () => clearInterval(handle)\n\t}, [checkIntervalMs, checkVersion, shouldCheck])\n\n\tuseEffect(() => {\n\t\tif (!shouldCheck) {\n\t\t\treturn\n\t\t}\n\t\tdocument.addEventListener('visibilitychange', checkVersion)\n\t\treturn () => document.removeEventListener('visibilitychange', checkVersion)\n\t}, [checkVersion, shouldCheck])\n\n\treturn isOutdated\n}\n\nconst getVersionFromDocument = (node: ParentNode) => {\n\tconst meta = node.querySelector<HTMLMetaElement>('meta[name=contember-build-version]')\n\treturn meta?.content\n}\n\nconst useFetchVersion = () => {\n\treturn useCallback(async () => {\n\t\ttry {\n\t\t\tconst result = await (await fetch(window.location.href)).text()\n\t\t\tconst html = document.createElement('html')\n\t\t\thtml.innerHTML = result\n\t\t\treturn getVersionFromDocument(html)\n\t\t} catch (e) {\n\t\t\tconsole.error(e)\n\t\t\treturn undefined\n\t\t}\n\t}, [])\n}\n"],"names":[],"mappings":";AAEA,MAAM,yBAAyB;AAGxB,MAAM,2BAA2B,CAAC,EAAE,kBAAkB,uBAAuB,IAEhF,CAAA,MAAO;AACV,QAAM,CAAC,cAAc,IAAI,SAAS,MAAM;AAChC,WAAA,uBAAuB,SAAS,IAAI;AAAA,EAAA,CAC3C;AACD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAClD,QAAM,eAAe,gBAAgB;AAE/B,QAAA,eAAe,YAAY,YAAY;AAC5C,QAAI,SAAS,QAAQ;AACpB;AAAA,IAAA;AAEK,UAAA,UAAU,MAAM,aAAa;AAC/B,QAAA,WAAW,YAAY,gBAAgB;AAC1C,oBAAc,IAAI;AAAA,IAAA;AAAA,EACnB,GACE,CAAC,cAAc,cAAc,CAAC;AACjC,QAAM,cAAc,CAAC,CAAC,kBAAkB,CAAC;AAEzC,YAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IAAA;AAEK,UAAA,SAAS,YAAY,cAAc,eAAe;AACjD,WAAA,MAAM,cAAc,MAAM;AAAA,EAC/B,GAAA,CAAC,iBAAiB,cAAc,WAAW,CAAC;AAE/C,YAAU,MAAM;AACf,QAAI,CAAC,aAAa;AACjB;AAAA,IAAA;AAEQ,aAAA,iBAAiB,oBAAoB,YAAY;AAC1D,WAAO,MAAM,SAAS,oBAAoB,oBAAoB,YAAY;AAAA,EAAA,GACxE,CAAC,cAAc,WAAW,CAAC;AAEvB,SAAA;AACR;AAEA,MAAM,yBAAyB,CAAC,SAAqB;AAC9C,QAAA,OAAO,KAAK,cAA+B,oCAAoC;AACrF,SAAO,MAAM;AACd;AAEA,MAAM,kBAAkB,MAAM;AAC7B,SAAO,YAAY,YAAY;AAC1B,QAAA;AACG,YAAA,SAAS,OAAO,MAAM,MAAM,OAAO,SAAS,IAAI,GAAG,KAAK;AACxD,YAAA,OAAO,SAAS,cAAc,MAAM;AAC1C,WAAK,YAAY;AACjB,aAAO,uBAAuB,IAAI;AAAA,aAC1B,GAAG;AACX,cAAQ,MAAM,CAAC;AACR,aAAA;AAAA,IAAA;AAAA,EAET,GAAG,EAAE;AACN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationEntrypoint.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/ApplicationEntrypoint.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoD,MAAM,0BAA0B,CAAA;AACxG,OAAO,EAAmB,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"ApplicationEntrypoint.d.ts","sourceRoot":"","sources":["../../../src/bootstrap/ApplicationEntrypoint.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoD,MAAM,0BAA0B,CAAA;AACxG,OAAO,EAAmB,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAwC,MAAM,0BAA0B,CAAA;AAIzF,MAAM,WAAW,0BAA2B,SAAQ,oBAAoB;IACvE,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,QAAQ,CAAA;IACjB,QAAQ,EAAE,SAAS,CAAA;IACnB,WAAW,CAAC,EAAE,WAAW,CAAA;CACzB;AAQD;;GAEG;AACH,eAAO,MAAM,qBAAqB,UAAW,0BAA0B,4CAmCtE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisconnectEntityTrigger.d.ts","sourceRoot":"","sources":["../../../../src/components/binding/DisconnectEntityTrigger.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAe,MAAM,OAAO,CAAA;AAE7D,OAAO,EAAoC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"DisconnectEntityTrigger.d.ts","sourceRoot":"","sources":["../../../../src/components/binding/DisconnectEntityTrigger.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAe,MAAM,OAAO,CAAA;AAE7D,OAAO,EAAoC,kBAAkB,EACtC,uBAAuB,EAAE,2BAA2B,EAA2C,MAAM,0BAA0B,CAAA;AAKtJ,MAAM,WAAW,4BAA4B;IAC5C,gBAAgB,CAAC,EAAE,IAAI,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;IACnB,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAA;IAC5D,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAA;IACrD,KAAK,CAAC,EAAE,2BAA2B,CAAC,OAAO,CAAC,CAAA;CAC5C;AAED,eAAO,MAAM,uBAAuB,4EAA6E,4BAA4B,4CAqC5I,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EntityAccessor } from '@contember/react-binding';
|
|
2
2
|
export declare const EntityBeforePersist: ({ listener }: {
|
|
3
|
-
listener: EntityAccessor.EntityEventListenerMap[
|
|
3
|
+
listener: EntityAccessor.EntityEventListenerMap["beforePersist"];
|
|
4
4
|
}) => null;
|
|
5
5
|
//# sourceMappingURL=EntityBeforePersist.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityBeforePersist.d.ts","sourceRoot":"","sources":["../../../../src/components/binding/EntityBeforePersist.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA0B,MAAM,0BAA0B,CAAA;AAEjF,eAAO,MAAM,mBAAmB,iBAAkB;IAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"EntityBeforePersist.d.ts","sourceRoot":"","sources":["../../../../src/components/binding/EntityBeforePersist.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA0B,MAAM,0BAA0B,CAAA;AAEjF,eAAO,MAAM,mBAAmB,iBAAkB;IAAE,QAAQ,EAAE,cAAc,CAAC,sBAAsB,CAAC,eAAe,CAAC,CAAA;CAAC,SAGpH,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { RequestParameters } from '@contember/react-routing';
|
|
1
2
|
import { RoutingLinkTarget } from '@contember/react-routing';
|
|
2
|
-
export declare const RedirectOnPersist: ({ to }: {
|
|
3
|
+
export declare const RedirectOnPersist: ({ to, parameters }: {
|
|
3
4
|
to: RoutingLinkTarget;
|
|
5
|
+
parameters?: RequestParameters;
|
|
4
6
|
}) => null;
|
|
5
7
|
//# sourceMappingURL=RedirectOnPersist.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedirectOnPersist.d.ts","sourceRoot":"","sources":["../../../../src/components/binding/RedirectOnPersist.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RedirectOnPersist.d.ts","sourceRoot":"","sources":["../../../../src/components/binding/RedirectOnPersist.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAe,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,eAAO,MAAM,iBAAiB,uBAAwB;IAAE,EAAE,EAAE,iBAAiB,CAAC;IAAC,UAAU,CAAC,EAAE,iBAAiB,CAAA;CAAE,SAS9G,CAAA"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export * from './ClearFieldTrigger';
|
|
2
|
-
export * from './DeleteEntityTrigger';
|
|
3
2
|
export * from './DisconnectEntityTrigger';
|
|
4
|
-
export * from './PersistTrigger';
|
|
5
3
|
export * from './EntityBeforePersist';
|
|
6
4
|
export * from './RedirectOnPersist';
|
|
7
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/binding/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/binding/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,kCAAkC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ErrorPersistResult, SuccessfulPersistResult } from '@contember/react-binding';
|
|
2
|
+
export type BlockNavigationOnDirtyStateResult = 'save' | 'discard' | 'cancel';
|
|
3
|
+
export declare const useBlockNavigationOnDirtyState: (handler: () => Promise<BlockNavigationOnDirtyStateResult>, options?: {
|
|
4
|
+
onPersistSuccess?: (result: SuccessfulPersistResult) => void;
|
|
5
|
+
onPersistError?: (result: ErrorPersistResult) => void;
|
|
6
|
+
}) => void;
|
|
7
|
+
//# sourceMappingURL=useBlockNavigationOnDirtyState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBlockNavigationOnDirtyState.d.ts","sourceRoot":"","sources":["../../../src/hooks/useBlockNavigationOnDirtyState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAmD,MAAM,0BAA0B,CAAA;AAIvI,MAAM,MAAM,iCAAiC,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAA;AAE7E,eAAO,MAAM,8BAA8B,YAAa,MAAM,OAAO,CAAC,iCAAiC,CAAC,YAAY;IACnH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAA;IAC5D,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAA;CACrD,SA8BA,CAAA"}
|