From e06bf3c2d22442c52aac4c647aed0154d71360f8 Mon Sep 17 00:00:00 2001 From: Ivan S Glazunov Date: Sat, 7 Sep 2024 22:35:03 +0300 Subject: [PATCH] 0.0.58 --- imports/react-handler.tsx | 28 ++++++++++++++++++++-------- package-lock.json | 12 ++++++------ package.json | 4 ++-- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/imports/react-handler.tsx b/imports/react-handler.tsx index 449ef67..e244311 100644 --- a/imports/react-handler.tsx +++ b/imports/react-handler.tsx @@ -13,6 +13,7 @@ import { GoI, useGoCore, GoProvider } from './go'; import $ from 'jquery'; import isEqual from 'lodash/isEqual'; import isEmpty from 'lodash/isEmpty'; +import flatten from 'lodash/flatten'; export const r: any = (path) => { if (r.requires[path]) return r.requires[path]; @@ -170,20 +171,27 @@ export function ReactHandlerEditor({ export const ReactHandlerTreeItem = memo(function ReactHandlerTreeItem({ go, setHandler, + goPath = [], }: { go: any; setHandler?: any; + goPath?: GoI[]; }) { const deep = useDeep(); const hgo = go.hgo; const handlerId = hgo?.linkId; - // const handler = handlerId ? deep.get(handlerId) : undefined; + const handler = handlerId ? deep.get(handlerId) : undefined; const [open, setOpen] = useState(false); const keys = Object.keys(go.children); const v = deep.ml.byId[go.value]; + const isActive = useMemo(() => !!goPath.find(f => f.path === go.path), [goPath]); + useEffect(() => { + if (isActive) setOpen(true); + }, [isActive]); + return {!!go && } {!!go && } - {/* {!!handler && <> + {!!handler && <> - } */} + } {!!open && - {keys.map(k => )} + {keys.map(k => )} } @@ -243,6 +251,9 @@ export function ReactHandlersProvider({ useEffect(() => { if (handler) disclosure.onOpen(); }, [handler]); + useEffect(() => { + if (!disclosure.isOpen) setHandler(undefined); + }, [disclosure.isOpen]); useEffect(() => { $(document).on('click', '.deep-link-id', function(e) { const handlerId = $(this).data('deep-link-id'); @@ -294,6 +305,7 @@ export function ReactHandlersProvider({ // }; const goRoot = focuses?.[0]?.go?.root(); const [sync, setSync] = useState(_sync); + const goPath = useMemo(() => flatten(focuses.map(f => f.go.parents())), [focuses]); return @@ -308,7 +320,7 @@ export function ReactHandlersProvider({ setFocuses([]); }}>X handlers: - + {/* {renderFocuses(focuses)} go: {!!goRoot && renderFocuses([{ handlerId: goRoot?.linkId, go: goRoot }], 0, 'go')} */} diff --git a/package-lock.json b/package-lock.json index ed5c05d..1fb63ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@deep-foundation/perception-imports", - "version": "0.0.56", + "version": "0.0.57", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@deep-foundation/perception-imports", - "version": "0.0.56", + "version": "0.0.57", "license": "Unlicense", "dependencies": { "@capacitor-community/background-geolocation": "^1.2.17", @@ -63,7 +63,7 @@ "node": "^18" }, "peerDependencies": { - "@deep-foundation/deeplinks": "^0.0.441", + "@deep-foundation/deeplinks": "^0.0.443", "react": "^18.3.1" } }, @@ -4852,9 +4852,9 @@ "peer": true }, "node_modules/@deep-foundation/deeplinks": { - "version": "0.0.441", - "resolved": "https://registry.npmjs.org/@deep-foundation/deeplinks/-/deeplinks-0.0.441.tgz", - "integrity": "sha512-BbpWewd1tLmKk2fkUKtFUSRoJba10k0KXB1FvSnL2+o98x3yICDlDm0K7oXqYwPg6egpFrCBmeCYAfaZpSvnUg==", + "version": "0.0.443", + "resolved": "https://registry.npmjs.org/@deep-foundation/deeplinks/-/deeplinks-0.0.443.tgz", + "integrity": "sha512-CqmabCxZosT8KcEIMCEhoWLDBeg//SqkIQGgxSF5n7jkMLrvstpZE5xyqe6jtsh1TvBy0KOpBPayeLJwB/e3rA==", "peer": true, "dependencies": { "@chainsafe/libp2p-yamux": "^6.0.2", diff --git a/package.json b/package.json index d640d19..09eaf63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@deep-foundation/perception-imports", - "version": "0.0.56", + "version": "0.0.58", "license": "Unlicense", "type": "module", "scripts": { @@ -13,7 +13,7 @@ "app:dev": "npm run app:sync; (cd ../; rm -rf app; npm run dev)" }, "peerDependencies": { - "@deep-foundation/deeplinks": "^0.0.441", + "@deep-foundation/deeplinks": "^0.0.443", "react": "^18.3.1" }, "engines": {