ESM
import "@arcgis/common-components/components/arcgis-value-picker-collection";
Inheritance
ArcgisValuePickerCollection→HTMLElement

Demo

Properties

PropertyAttributeType
auto-destroy-disabled
can-next
can-play
can-previous

autoDestroyDisabled

Property
Type
boolean

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() method when you are done to prevent memory leaks.

Attribute
auto-destroy-disabled
Default value
false

canNext

Property
Type
boolean

Determines whether the user can interact with the next button. This property is automatically set to false when currentValue matches the last index of items.

Attribute
can-next
Default value
false
Example
const valuePicker = document.querySelector("arcgis-value-picker");
const valuePickerCollection = document.querySelector("arcgis-value-picker-collection");
const collection = new Collection([
{ name: "Isaac Newton", dob: new Date(1643, 0, 4)},
{ name: "Albert Einstein", dob: new Date(1879, 2, 14)},
{ name: "Ernest Rutherford", dob: new Date(1871, 7, 20)}
]);
valuePickerCollection.items = collection;
valuePickerCollection.currentValue = valuePickerCollection.items.at(0);
if (valuePickerCollection.canNext === true) {
valuePicker.next();
console.log(valuePickerCollection.currentValue.name); // "Albert Einstein"
}

canPlay

Property
Type
boolean

Determines whether the user can interact with the play/pause button.

Attribute
can-play
Default value
false

canPrevious

Property
Type
boolean

Determines whether the user can interact with the previous button. This property is automatically set to false when currentValue matches the first index of items.

Attribute
can-previous
Default value
false
Example
const valuePicker = document.querySelector("arcgis-value-picker");
const valuePickerCollection = document.querySelector("arcgis-value-picker-collection");
const collection = new Collection([
{ name: "Isaac Newton", dob: new Date(1643, 0, 4)},
{ name: "Albert Einstein", dob: new Date(1879, 2, 14)},
{ name: "Ernest Rutherford", dob: new Date(1871, 7, 20)}
]);
valuePickerCollection.items = collection;
valuePickerCollection.currentValue = valuePickerCollection.items.at(1);
if (valuePickerCollection.canPrevious === true) {
valuePicker.previous();
console.log(valuePickerCollection.currentValue.name); // "Isaac Newton"
}

currentValue

Property
Type
unknown | undefined

The currently selected collection item. Note that because the type of items is a Collection of any shape, this component identifies currentValue by reference rather than matching a field that may not always be present. Ensure that currentValue is always assigned from an existing element within items.

Example
const valuePickerCollection = document.querySelector("arcgis-value-picker-collection");
const collection = new Collection([
{ name: "Isaac Newton", dob: new Date(1643, 0, 4)},
{ name: "Albert Einstein", dob: new Date(1879, 2, 14)},
{ name: "Ernest Rutherford", dob: new Date(1871, 7, 20)}
]);
valuePickerCollection.items = collection;
// 3 different approaches to setting currentValue
// Acceptable. currentValue is a reference to items
valuePickerCollection.currentValue = valuePickerCollection.items.at(0);
// Acceptable. currentValue is assigned to the element at the index of items returned by find()
valuePickerCollection.currentValue = valuePickerCollection.items.find(
({ name }) => name === "Albert Einstein"
);
// Invalid. The component has no mechanism to predict which field should be used to match this property to an index.
valuePickerCollection.currentValue = { name: "Isaac Newton", dob: new Date(1643, 0, 4) };

items

Property
Type
Collection | undefined

The collection of arbitrary items that arcgis-value-picker can iterate over.

Methods

MethodSignature
inherited
componentOnReady(): Promise<this>
destroy(): Promise<void>

componentOnReady

inherited Method
Signature
componentOnReady (): Promise<this>

Creates a promise that resolves once the component is fully loaded.

Returns
Promise<this>
Example
const arcgisValuePickerCollection = document.createElement("arcgis-value-picker-collection");
document.body.append(arcgisValuePickerCollection);
await arcgisValuePickerCollection.componentOnReady();
console.log("arcgis-value-picker-collection is ready to go!");

destroy

Method
Signature
destroy (): Promise<void>

Permanently destroys the component.

Returns
Promise<void>

Events

NameType
CustomEvent<{ name: "canNext" | "canPlay" | "canPrevious" | "currentValue"; }>

arcgisPropertyChange

Event
arcgisPropertyChange: CustomEvent<{ name: "canNext" | "canPlay" | "canPrevious" | "currentValue"; }>
bubbles composed cancelable