diff --git a/frontend/packages/erd-core/src/stores/hiddenNodes/actions.ts b/frontend/packages/erd-core/src/stores/hiddenNodes/actions.ts new file mode 100644 index 000000000..e4f6b8f4e --- /dev/null +++ b/frontend/packages/erd-core/src/stores/hiddenNodes/actions.ts @@ -0,0 +1,14 @@ +import { hiddenNodesStore } from './store' + +export const addHiddenNode = (nodeId: string) => { + if (!hiddenNodesStore.nodes.includes(nodeId)) { + hiddenNodesStore.nodes.push(nodeId) + } +} + +export const removeHiddenNode = (nodeId: string) => { + const index = hiddenNodesStore.nodes.indexOf(nodeId) + if (index !== -1) { + hiddenNodesStore.nodes.splice(index, 1) + } +} diff --git a/frontend/packages/erd-core/src/stores/hiddenNodes/hooks.ts b/frontend/packages/erd-core/src/stores/hiddenNodes/hooks.ts new file mode 100644 index 000000000..85957af1c --- /dev/null +++ b/frontend/packages/erd-core/src/stores/hiddenNodes/hooks.ts @@ -0,0 +1,7 @@ +import { useSnapshot } from 'valtio' +import { hiddenNodesStore } from './store' + +export const useHiddenNodesStore = () => { + const { nodes } = useSnapshot(hiddenNodesStore) + return nodes +} diff --git a/frontend/packages/erd-core/src/stores/hiddenNodes/index.ts b/frontend/packages/erd-core/src/stores/hiddenNodes/index.ts new file mode 100644 index 000000000..5d8918fa2 --- /dev/null +++ b/frontend/packages/erd-core/src/stores/hiddenNodes/index.ts @@ -0,0 +1,3 @@ +export * from './store' +export * from './actions' +export * from './hooks' diff --git a/frontend/packages/erd-core/src/stores/hiddenNodes/store.ts b/frontend/packages/erd-core/src/stores/hiddenNodes/store.ts new file mode 100644 index 000000000..6a7e59e74 --- /dev/null +++ b/frontend/packages/erd-core/src/stores/hiddenNodes/store.ts @@ -0,0 +1,9 @@ +import { proxy } from 'valtio' + +type HiddenNodesStore = { + nodes: string[] +} + +export const hiddenNodesStore = proxy({ + nodes: [], +})