import type Collection from "../core/Collection.js"; import type Item from "./Item.js"; import type { EventedAccessor } from "../core/Evented.js"; import type { Action, ItemModifier, LayerListModelProperties, LayerListModelTriggerActionEvent, State } from "./types.js"; import type { MapViewOrSceneView } from "../views/MapViewOrSceneView.js"; export interface LayerListModelEvents { /** * Emitted when the user clicks an [action](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionButton/) or * [action toggle](https://developers.arcgis.com/javascript/latest/references/core/support/actions/ActionToggle/) in a layer list. * Use this event to run custom logic when a specific action is triggered. * The event object is a [LayerListModelTriggerActionEvent](https://developers.arcgis.com/javascript/latest/references/core/layerList/types/#LayerListModelTriggerActionEvent). * * @see [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/layerList/LayerListModel/#event-trigger-action) */ "trigger-action": LayerListModelTriggerActionEvent; } /** * Manages the [Item](https://developers.arcgis.com/javascript/latest/references/core/layerList/Item/) instances displayed for operational layers in a layer-list workflow. * The collection tracks the view's layers and layer views, creates and updates list items, and supports * custom item configuration, actions, visibility filtering, and reordering. * To exclude a layer from the collection, set its [Layer.listMode](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#listMode) property to `hide`. * * @beta * @since 5.2 */ export default class LayerListModel extends EventedAccessor { /** * @deprecated * Do not directly reference this property. * Use EventNames and EventTypes helpers from \@arcgis/core/Evented */ "@eventTypes": LayerListModelEvents; constructor(properties?: LayerListModelProperties); /** * Indicates whether items should report when their associated layers are being published. * When `false`, the [Item.publishing](https://developers.arcgis.com/javascript/latest/references/core/layerList/Item/#publishing) property is always `false`. * * @default false */ accessor checkPublishStatusEnabled: boolean; /** * A function called when each [Item](https://developers.arcgis.com/javascript/latest/references/core/layerList/Item/) is created. * Use the callback to modify supported item properties or add actions through * the [Item.actionsSections](https://developers.arcgis.com/javascript/latest/references/core/layerList/Item/#actionsSections) property. */ accessor listItemCreatedFunction: ItemModifier | null | undefined; /** * Indicates whether to ignore the [Layer.listMode](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#listMode) property when determining which layers to display. * When `true`, layers with a `listMode` of `hide` are included. * * @default false * @see [Layer.listMode](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#listMode) */ accessor listModeDisabled: boolean; /** * The items representing operational layers in the view. * Items are ordered to match the map's layer order and can include nested child items. * To exclude a layer, set its [Layer.listMode](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#listMode) property to `hide`. * * @see [Layer.listMode](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#listMode) */ get operationalItems(): Collection; /** * The current state of the collection. * Returns `disabled` when no view is set, `loading` while the view is not ready, and `ready` when * the view is ready to provide operational layer items. * * @default "disabled" */ get state(): State; /** The total number of items, including nested child items. */ get totalItems(): number; /** The map or scene view that supplies the operational layers and layer views for this collection. */ accessor view: MapViewOrSceneView | null | undefined; /** * Moves a layer item within the map or between supported parent layers. * The item must represent a layer, and sublayers cannot be moved with this method. * The target index uses the layer collection's order, where `0` represents the top position in the list. * * @param targetItem - The item to move. * @param fromParentItem - The item's current parent, if it has one. * @param toParentItem - The target parent, if the item is being moved into a child collection. * @param newIndex - The target position in the destination collection. */ moveItem(targetItem: Item | null | undefined, fromParentItem: Item | null | undefined, toParentItem: Item | null | undefined, newIndex: number): void; /** * Executes an enabled action associated with an item and emits the * [@trigger-action](https://developers.arcgis.com/javascript/latest/references/core/layerList/LayerListModel/#event-trigger-action) event. * Disabled actions are ignored. * * @param action - The action to execute. * @param item - The item associated with the action. */ triggerAction(action: Action, item: Item): void; }