@arcgis/map-components
Version:
ArcGIS Map Components
454 lines (453 loc) • 24.5 kB
TypeScript
/// <reference path="../../index.d.ts" />
import type ListItem from "@arcgis/core/widgets/LayerList/ListItem.js";
import type ActionToggle from "@arcgis/core/support/actions/ActionToggle.js";
import type ActionButton from "@arcgis/core/support/actions/ActionButton.js";
import type TableList from "@arcgis/core/widgets/TableList.js";
import type Collection from "@arcgis/core/core/Collection.js";
import type CatalogLayerList from "@arcgis/core/widgets/CatalogLayerList.js";
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
import type { ArcgisReferenceElement, IconName } from "../types.js";
import type { LayerListViewModelTriggerActionEvent } from "@arcgis/core/widgets/LayerList/LayerListViewModel.js";
import type { MapViewOrSceneView } from "@arcgis/core/views/MapViewOrSceneView.js";
import type { CatalogLayerListProperties } from "@arcgis/core/widgets/CatalogLayerList.js";
import type { FilterPredicate, ListItemModifier, State, VisibilityAppearance } from "@arcgis/core/widgets/LayerList/types.js";
import type { HeadingLevel } from "@arcgis/core/widgets/support/types.js";
import type { Icon } from "@esri/calcite-components/components/calcite-icon";
import type { TableListProperties } from "@arcgis/core/widgets/TableList.js";
import type { FlowLayer } from "@arcgis/core/widgets/LayerList.js";
/**
* The Layer List provides a way to display a list of layers and switch on/off their visibility.
* The [listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#listItemCreatedFunction) and the [ListItem](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/ListItem/) API provides access to each layer's properties, allows
* the developer to configure actions related to the layer, and allows the developer to add content to the item related to the layer.
*
* > **Notes**
* >
* > - The Layer List does not emit an event when the visibility of a layer changes. To respond to layer visibility changes, watch the [visible](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#visible) property of layers in the [allLayers](https://developers.arcgis.com/javascript/latest/references/core/Map/#allLayers) property with [reactiveUtils](https://developers.arcgis.com/javascript/latest/references/core/core/reactiveUtils/).
* > - To hide layers in the map from the Layer List, you must set the [listMode](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#listMode) property on the desired layers to `hide`.
* > - When a [KnowledgeGraphLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/KnowledgeGraphLayer/) is present in the map, the Layer List will display the [tables](https://developers.arcgis.com/javascript/latest/references/core/layers/KnowledgeGraphLayer/#tables) as a [tableList](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#tableList) ListItem.
* > - When a [CatalogLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/) is present in the map, the Layer List will display the [dynamicGroupLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/#dynamicGroupLayer) in a [catalogLayerList](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#catalogLayerList) ListItem.
*
* > **Keyboard Navigation**
* >
* > - The Layer List supports keyboard navigation using the [Treegrid Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/treegrid/) for improved accessibility. Refer to the Calcite List component documentation for detailed keyboard interaction guidelines: [Calcite List Keyboard Navigation](https://developers.arcgis.com/calcite-design-system/components/list/#keyboard-navigation).
*
* > [!WARNING]
* > In version 6.0, the implementation of [arcgis-layer-list](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/) will be updated under the hood to that of [arcgis-layer-list-next](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list-next/), and the way events for [catalogLayerList](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#catalogLayerList) and [tableList](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#tableList) are handled will change. We encourage using the [arcgis-layer-list-next](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list-next/) component and providing feedback.
*
* @since 4.28
*/
export abstract class ArcgisLayerList extends LitElement {
/**
* If true, the component will not be destroyed automatically when it is
* disconnected from the document. This is useful when you want to move the
* component to a different place on the page, or temporarily hide it. If this
* is set, make sure to call the [destroy()](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#destroy) method when you are done to
* prevent memory leaks.
*
* @default false
*/
accessor autoDestroyDisabled: boolean;
/** The CatalogLayerList that displays a catalog layer's dynamic group layer. */
get catalogLayerList(): CatalogLayerList | null | undefined;
/**
* [CatalogLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/) specific properties.
* Catalog layers will display their [CatalogLayer#dynamicGroupLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CatalogLayer/#dynamicGroupLayer) as an expandable [catalogLayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#catalogLayerList) in the LayerList component.
* This list item will only be displayed when catalog layers with dynamic group layers are loaded in the map.
* These are the properties that are used to configure the [catalogLayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#catalogLayerList).
*
* @since 4.30
* @see [catalogLayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#catalogLayerList)
* @example
* ```js
* layerListElement.catalogOptions = {
* listItemCreatedFunction: (event) => {
* const { item } = event;
* item.actionsSections = [
* [
* {
* title: "Add layer to map",
* icon: "add-layer",
* id: "add-layer"
* }
* ]
* ];
* },
* selectionMode: "single",
* visibleElements: {
* filter: true
* }
* };
* ```
*/
accessor catalogOptions: CatalogLayerListProperties | null | undefined;
/**
* Indicates whether a component is closed. When `true`, the component will be hidden.
*
* @default false
* @since 4.33
*/
accessor closed: boolean;
/**
* Indicates whether the component is collapsed.
* When collapsed, only the collapse button and heading are displayed.
*
* @default false
* @since 4.29
* @see [showCollapseButton](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#showCollapseButton)
* @example
* ```js
* layerListElement.collapsed = true;
* ```
*/
accessor collapsed: boolean;
/**
* Indicates whether [list items](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/ListItem/) may be reordered within the list by dragging and dropping.
* MapImageLayer [MapImageLayer#sublayers](https://developers.arcgis.com/javascript/latest/references/core/layers/MapImageLayer/#sublayers) can be reordered only within their parent MapImageLayer and can not be dragged out as a separate layer.
* Drag won't be enabled until the number of list items is equal to or greater than than the value set set in [minDragEnabledItems](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#minDragEnabledItems).
*
* @default false
* @since 4.29
* @see [minDragEnabledItems](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#minDragEnabledItems)
* @example
* ```js
* layerListElement.dragEnabled = true;
* ```
*/
accessor dragEnabled: boolean;
/**
* Placeholder text used in the filter input if [visibleElements.filter](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#visibleElements) is true.
*
* @default ""
* @since 4.29
* @see [showFilter](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#showFilter)
* @example
* ```js
* layerListElement.filterPlaceholder = "Filter layers";
* ```
*/
accessor filterPlaceholder: string;
/**
* Specifies a function to handle filtering [list items](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/ListItem/).
*
* @since 4.32
* @example
* ```js
* layerListElement.filterPredicate = (item) => item.title.toLowerCase().includes("streets");
* ```
*/
accessor filterPredicate: FilterPredicate | null | undefined;
/**
* The value of the filter input if [visibleElements.filter](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#visibleElements) is true.
*
* @default ""
* @since 4.29
* @see [showFilter](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#showFilter)
* @example
* ```js
* reactiveUtils.watch(
* () => layerListElement.filterText,
* (filterText) => console.log(filterText)
* );
* ```
*/
accessor filterText: string;
/**
* Indicates the heading level to use for the heading of the component.
* By default, the heading is rendered as a level 2 heading (e.g., `<h2>Layer List</h2>`).
* Depending on the component's placement in your app, you may need to adjust this heading for proper semantics.
* This is important for meeting accessibility standards.
*
* @default 2
* @since 4.29
* @see [showHeading](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#showHeading)
* @example
* ```js
* layerListElement.headingLevel = 3;
* ```
*/
accessor headingLevel: HeadingLevel;
/**
* Indicates whether to display the [LayerList#catalogLayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#catalogLayerList).
*
* @default false
* @since 5.0
*/
accessor hideCatalogLayerList: boolean;
/**
* Indicates whether the status indicators will be displayed.
*
* @default false
* @since 5.0
*/
accessor hideStatusIndicators: boolean;
/**
* Icon which represents the component.
* Typically used when the component is controlled by another component (e.g. by the Expand component).
*
* @default "layers"
* @since 4.27
* @see [Calcite Icons](https://developers.arcgis.com/calcite-design-system/icons/)
*/
get icon(): Icon["icon"];
set icon(value: IconName);
/**
* [KnowledgeGraphLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/KnowledgeGraphLayer/) specific properties.
* Knowledge graph layers will display [KnowledgeGraphLayer#tables](https://developers.arcgis.com/javascript/latest/references/core/layers/KnowledgeGraphLayer/#tables)
* as an expandable [tableList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#tableList) in the LayerList component.
* This tables list item will only be displayed when knowledge graph layers with tables are loaded in the map.
* These are the properties that are used to configure the [tableList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#tableList).
*
* @since 4.30
* @see [tableList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#tableList)
* @example
* ```js
* layerListElement.knowledgeGraphOptions = {
* filterPlaceholder: "Filter tables",
* listItemCreatedFunction: (event) => {
* const { item } = event;
* item.actionsSections = [
* [
* {
* icon: "table",
* id: "open-table",
* title: "Show table"
* },
* {
* icon: "information",
* id: "information",
* title: "Show information"
* }
* ]
* ];
* },
* minFilterItems: 1,
* visibleElements: {
* errors: true,
* filter: true,
* statusIndicators: true
* }
* }
* ```
*/
accessor knowledgeGraphOptions: TableListProperties | null | undefined;
/**
* The component's default label.
*
* @since 4.7
*/
accessor label: string;
/**
* A function that executes each time a [ListItem](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/ListItem/) is created.
* Use this function to add actions and panels to list items, and to override
* the default settings of a list item. Actions can be added to list items
* using the [ListItem#actionsSections](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/ListItem/#actionsSections)
* property of the ListItem.
*
* @since 4.4
* @see [Sample - LayerList component with actions](https://developers.arcgis.com/javascript/latest/sample-code/widgets-layerlist-actions/)
* @example
* ```js
* layerListElement.listItemCreatedFunction = async function (event) {
*
* // The event object contains properties of the
* // layer in the LayerList component.
*
* let item = event.item;
*
* // Wait for the layer to load and the item title to become available
* await item.layer.when();
*
* if (item.title === "US Demographics") {
* // open the list item in the LayerList component
* item.open = true;
* // change the title to something more descriptive
* item.title = "Population by county";
* // set an action for zooming to the full extent of the layer
* item.actionsSections = [[{
* title: "Go to full extent",
* icon: "zoom-out-fixed",
* id: "full-extent"
* }]];
* }
* };
* ```
*/
accessor listItemCreatedFunction: ListItemModifier | null | undefined;
/**
* The minimum number of list items required to enable drag and drop reordering with [dragEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#dragEnabled).
*
* @default 2
* @since 4.29
* @see [dragEnabled](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#dragEnabled)
* @example
* ```js
* layerListElement.dragEnabled = true;
* layerListElement.minDragEnabledItems = 5;
* ```
*/
accessor minDragEnabledItems: number;
/**
* The minimum number of list items required to display the [visibleElements.filter](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/LayerListVisibleElements/) input box.
*
* @default 10
* @since 4.29
* @see [showFilter](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-layer-list/#showFilter)
* @example
* ```js
* layerListElement.showFilter = true;
* layerListElement.minFilterItems = 5;
* ```
*/
accessor minFilterItems: number;
/**
* A collection of [Layer](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/)s that are opened
* in a [catalogLayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#catalogLayerList) or [tableList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#tableList) flow item.
* This property is useful for backing out of the catalog layer list or table list
* programmatically to the parent layer list.
*
* @default []
* @since 4.31
* @see [catalogLayerList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#catalogLayerList)
* @see [tableList](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#tableList)
* @example
* ```js
* // back out of the catalog layer list to the main layer list
* layerListElement.openedLayers.pop();
* ```
*/
get openedLayers(): Collection<FlowLayer>;
/** A collection of ListItems representing operational layers. */
get operationalItems(): Collection<ListItem>;
/**
* By assigning the `id` attribute of the Map or Scene component to this property, you can position a child component anywhere in the DOM while still maintaining a connection to the Map or Scene.
*
* @see [Associate components with a Map or Scene component](https://developers.arcgis.com/javascript/latest/programming-patterns/#associate-components-with-a-map-or-scene-component)
*/
accessor referenceElement: ArcgisReferenceElement | string | undefined;
/**
* A collection of selected [ListItem](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/ListItem/)s representing operational layers
* selected by the user.
*
* @see [selectionMode](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#selectionMode)
*/
accessor selectedItems: Collection<ListItem>;
/**
* Specifies the selection mode.
* Selected items are available in the [selectedItems](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#selectedItems) property.
*
* | Value | Description |
* | ----- | ----------- |
* | multiple | Allows any number of items to be selected at once. This is useful when you want to apply an operation to multiple items at the same time. |
* | none | Disables selection. Use this when you want to prevent selecting items. |
* | single | Allows only one item to be selected at a time. If another item is selected, the previous selection is cleared. This is useful when you want to ensure that a maximum of one item is selected at a time. |
* | single-persist | Allows only one item to be selected at a time and prevents de-selection. Once an item is selected, it remains selected until another item is selected. This is useful when you want to ensure that there is always exactly one selected item. |
*
* @default "none"
* @since 4.29
* @see [selectedItems](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#selectedItems)
* @example
* ```js
* layerListElement.selectionMode = "multiple";
* ```
*/
accessor selectionMode: "multiple" | "single" | "none" | "single-persist";
/**
* Indicates whether to display a close button in the header.
*
* @default false
* @since 5.0
*/
accessor showCloseButton: boolean;
/**
* Indicates whether to display a collapse button in the header.
*
* @default false
* @since 5.0
*/
accessor showCollapseButton: boolean;
/**
* Indicates whether to display layers with load errors.
*
* @default false
* @since 5.0
*/
accessor showErrors: boolean;
/**
* Indicates whether to display a filter input box when then number of list items is equal to or greater than the value set in [LayerList#minFilterItems](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#minFilterItems), allowing users to filter layers by their title.
*
* @default false
* @since 5.0
*/
accessor showFilter: boolean;
/**
* Indicates whether to display the layer list heading. The heading text is "Layer List". The heading level can be set with the [LayerList#headingLevel](https://developers.arcgis.com/javascript/latest/references/core/widgets/LayerList/#headingLevel).
*
* @default false
* @since 5.0
*/
accessor showHeading: boolean;
/**
* Indicates whether temporary layer indicators will be displayed for layers with [Layer#persistenceEnabled](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#persistenceEnabled) set to `false`. A [temporary icon](https://developers.arcgis.com/calcite-design-system/icons/?icon=temporary&library=Calcite%20UI&query=temporary) will be displayed on the near side of the layer title.
*
* @default false
* @since 5.0
*/
accessor showTemporaryLayerIndicators: boolean;
/**
* The current state of the component.
*
* @default "disabled"
*/
get state(): State;
/** The TableList that displays the tables associated with a KnowledgeGraphLayer. */
get tableList(): TableList | null | undefined;
/**
* The view associated with the component.
* > **Note:** The recommended approach is to fully migrate applications to use map and scene components and avoid using MapView and SceneView directly. However, if you are migrating a large application from widgets to components, you might prefer a more gradual transition. To support this use case, the SDK includes this `view` property which connects a component to a MapView or SceneView. Ultimately, once migration is complete, the arcgis-layer-list component will be associated with a map or scene component rather than using the `view` property.
*/
accessor view: MapViewOrSceneView | null | undefined;
/**
* Determines the icons used to indicate visibility.
*
* | Value | Description | Example |
* | ----- | ----------- | ------- |
* | default | Displays view icons on the far side. Icons are hidden except on hover or if they have keyboard focus. See [view-visible](https://developers.arcgis.com/calcite-design-system/icons/?icon=view-visible&library=Calcite%20UI&query=view) and [view-hide](https://developers.arcgis.com/calcite-design-system/icons/?icon=view-hide&library=Calcite%20UI&query=view) calcite icons. |  |
* | checkbox | Displays checkbox icons on the near side. See [check-square-f](https://developers.arcgis.com/calcite-design-system/icons/?icon=check-square-f&library=Calcite%20UI&query=check) and [square](https://developers.arcgis.com/calcite-design-system/icons/?icon=square&library=Calcite%20UI&query=square) calcite icons. |  |
*
* @default "default"
* @since 4.29
* @example
* ```js
* layerListElement.visibilityAppearance = "checkbox";
* ```
*/
accessor visibilityAppearance: VisibilityAppearance;
/** Permanently destroy the component. */
destroy(): Promise<void>;
/**
* @param action
* @param item
*/
triggerAction(action: ActionButton | ActionToggle, item: ListItem): Promise<void>;
"@setterTypes": {
icon?: IconName;
};
/**
* Emitted when the component's close button is clicked.
*
* @since 4.33
*/
readonly arcgisClose: import("@arcgis/lumina").TargetedEvent<this, void>;
/** Emitted when the value of a property is changed. Use this to listen to changes to properties. */
readonly arcgisPropertyChange: import("@arcgis/lumina").TargetedEvent<this, { name: "state"; }>;
/** Emitted when the component associated with a map or scene view is ready to be interacted with. */
readonly arcgisReady: import("@arcgis/lumina").TargetedEvent<this, void>;
/** Emitted when an action is triggered on the component. */
readonly arcgisTriggerAction: import("@arcgis/lumina").TargetedEvent<this, LayerListViewModelTriggerActionEvent>;
readonly "@eventTypes": {
arcgisClose: ArcgisLayerList["arcgisClose"]["detail"];
arcgisPropertyChange: ArcgisLayerList["arcgisPropertyChange"]["detail"];
arcgisReady: ArcgisLayerList["arcgisReady"]["detail"];
arcgisTriggerAction: ArcgisLayerList["arcgisTriggerAction"]["detail"];
};
}