UNPKG

react-native-tree-multi-select

Version:

A super-fast, customizable tree view component for React Native with multi-selection, checkboxes, and search filtering capabilities.

86 lines (85 loc) 2.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTreeViewStore = getTreeViewStore; exports.useTreeViewStore = useTreeViewStore; var _zustand = require("zustand"); // Map to store individual tree view stores by id const treeViewStores = new Map(); // a function that returns a strongly typed version of `treeViewStores` const typedStore = () => treeViewStores; function getTreeViewStore(id) { if (!typedStore().has(id)) { const store = (0, _zustand.create)(set => ({ checked: new Set(), updateChecked: checked => set({ checked }), indeterminate: new Set(), updateIndeterminate: indeterminate => set({ indeterminate }), expanded: new Set(), updateExpanded: expanded => set({ expanded }), initialTreeViewData: [], updateInitialTreeViewData: initialTreeViewData => set({ initialTreeViewData }), nodeMap: new Map(), updateNodeMap: nodeMap => set({ nodeMap }), childToParentMap: new Map(), updateChildToParentMap: childToParentMap => set({ childToParentMap }), searchText: "", updateSearchText: searchText => set({ searchText }), searchKeys: [""], updateSearchKeys: searchKeys => set({ searchKeys }), innerMostChildrenIds: [], updateInnerMostChildrenIds: innerMostChildrenIds => set({ innerMostChildrenIds }), selectionPropagation: { toChildren: true, toParents: true }, setSelectionPropagation: selectionPropagation => set({ selectionPropagation: { // Default selection propagation for parent and children to true if not specified toChildren: selectionPropagation.toChildren ?? true, toParents: selectionPropagation.toParents ?? true } }), cleanUpTreeViewStore: () => set({ checked: new Set(), indeterminate: new Set(), expanded: new Set(), initialTreeViewData: [], nodeMap: new Map(), childToParentMap: new Map(), searchText: "", searchKeys: [""], innerMostChildrenIds: [], selectionPropagation: { toChildren: true, toParents: true } }) })); typedStore().set(id, store); } return typedStore().get(id); } function useTreeViewStore(id) { return getTreeViewStore(id); } //# sourceMappingURL=treeView.store.js.map