import Layer from '@arcgis/core/layers/Layer'; import Sublayer from '@arcgis/core/layers/support/Sublayer'; import WMSSublayer from '@arcgis/core/layers/support/WMSSublayer'; import EsriMap from '@arcgis/core/Map'; type SublayerType = Sublayer | WMSSublayer; type RefType = EsriMap | Layer | SublayerType; /** * Represents an item within the toc. */ interface BaseTocItem { /** Provides access to the real object represented by the toc item. */ readonly ref: RefType; /** The type of this toc item. */ readonly type: TocItemType; /** The children of this item. */ readonly children: TocItem[]; /** True if this item is the root item (no further parent). */ readonly isRoot: boolean; /** True if this item is a leaf (no further children). */ readonly isLeaf: boolean; /** True if this item is the first child of its parent. */ readonly isFirstChild: boolean; /** True if this item is the last child of its parent. */ readonly isLastChild: boolean; /** True if this item is currently opened (expanded). */ readonly isOpen: boolean; /** The list mode of this item. */ readonly listMode: ListMode; /** The toggle mode for the children of this item. */ readonly childrenToggleMode: ChildrenToggleMode; /** True if the item currently has any hidden children. */ readonly hasHiddenChildren: boolean; /** * Sets the "open" (expanded) state of this toc item. */ setOpen(open: boolean): void; /** * Sets the open state (expanded) state of this toc item and its sub tree. */ setOpenOnTree(open: boolean): void; } /** * A toc item that represents the root. */ interface TocItemRoot extends BaseTocItem { readonly type: "root"; readonly ref: EsriMap; } /** * A toc item that represents a layer. */ interface TocItemLayer extends BaseTocItem { readonly type: "layer"; readonly ref: Layer; } /** * A toc item that represents a sublayer. */ interface TocItemSublayer extends BaseTocItem { readonly type: "sublayer"; readonly ref: SublayerType; } /** * Represents an item within the toc. * * @see {@link BaseTocItem} for common item properties. */ type TocItem = TocItemRoot | TocItemLayer | TocItemSublayer; /** * An item's list mode. * * - `"show"`: Show this item. * - `"hide"`: Do not show this item. * - `"hide-children"`: Show this item, but not its children. * * Note that an item may still be hidden, even if its list mode is `"show"` or `"hide-children"`, * if one of its parent uses `listMode` `"hide"` or `"hide-children"`. */ type ListMode = "show" | "hide" | "hide-children"; /** * The toggle mode for children of a {@link TocItem}. * * - `"independent"`: children can be toggled on or off independently from each other * - `"exclusive"`: only one child can be toggled on at a time * - `"inherited"`: the mode is inherited from the parent */ type ChildrenToggleMode = "independent" | "exclusive" | "inherited"; /** * The type of the toc item. * Well-known types are: * * `layer` - item represents an layer (in the sense of a `@arcgis/core/layer/Layer` instance) * * `sublayer` - item represents a sub layer (e.g. `wms` or `map-image` sublayer) * * `root` - item is the root of the layer tree * The list may be extended in the future. */ type TocItemType = "root" | "layer" | "sublayer"; export type { BaseTocItem, ChildrenToggleMode, ListMode, RefType, SublayerType, TocItem, TocItemLayer, TocItemRoot, TocItemSublayer, TocItemType };