import type SingleChoiceInput from "./SingleChoiceInput.js"; import type { SingleChoiceInputProperties } from "./SingleChoiceInput.js"; export interface DynamicChoiceInputProperties extends SingleChoiceInputProperties, Partial> {} /** * The `DynamicChoiceInput` class defines the desired user interface for a dynamic choice group input. It lets users select a field value from a list of choices generated by an [Arcade](https://developers.arcgis.com/arcade) expression, rather than a fixed list. It is supported in both single and batch feature editing. Use a [dynamic choice input](/references/core/form/elements/inputs/DynamicChoiceInput/) when the available options depend on the feature being edited, values entered in other fields, or data queried from another layer or table. * * This [FieldElement.input](https://developers.arcgis.com/javascript/latest/references/core/form/elements/FieldElement/#input) is used in [field elements](https://developers.arcgis.com/javascript/latest/references/core/form/elements/FieldElement/) that are set within a [feature layer's](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#formTemplate) `formTemplate`. This is displayed within the [Editor](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-editor/). * * To configure a dynamic choice input, set its [choiceExpression](https://developers.arcgis.com/javascript/latest/references/core/form/elements/inputs/DynamicChoiceInput/#choiceExpression) to the name of an Arcade expression in the form template's [FormTemplate.expressionInfos](https://developers.arcgis.com/javascript/latest/references/core/form/FormTemplate/#expressionInfos). The expression returns a dictionary containing a `choices` array, where each choice has a `name` for its display text and a `code` for the value stored in the field. * * @since 5.2 * @see [FieldElement](https://developers.arcgis.com/javascript/latest/references/core/form/elements/FieldElement/) * @see [Sample - Edit features with dynamic choices](https://developers.arcgis.com/javascript/latest/sample-code/editor-dynamic-choices/) * @example * // Creates a new dynamic choice input for a field element within a form * const dynamicChoiceInput = new DynamicChoiceInput({ * choiceExpression: dynamicChoiceExpression.name, // reference to the defined expression * noValueOptionLabel: "No Value (null)", // label for the option representing a null value * showNoValueOption: false, // whether to display the choice representing a null value (i.e., "No Value") * }); */ export default class DynamicChoiceInput extends SingleChoiceInput { constructor(properties?: DynamicChoiceInputProperties); /** * A reference to an [Arcade](https://developers.arcgis.com/javascript/latest/arcade/) expression that returns a dictionary. The dictionary should have a `choices` array of objects, with each object in the array having a `name` property that is the text displayed to the user, and a `code` property that is the value assigned to the field when that choice is selected. * * @see [Sample - Edit features with dynamic choices ](https://developers.arcgis.com/javascript/latest/sample-code/editor-dynamic-choices/) * @example * // Set the choice expression for the dynamic choice input * fieldElement.input = new DynamicChoiceInput({ * choiceExpression: dynamicChoiceExpression.name * }); * * const dynamicChoiceExpression = new ExpressionInfo({ * name: "dynamic-material-choices", * title: "Dynamic material choices", * expression: * `var choices = [ * { name: "Unknown", code: 0 }, * { name: "Cast Iron - CAS", code: 83 }, * { name: "Copper - COP", code: 84 }, * { name: "Ductile Iron - DIP", code: 88 }, * { name: "Polyvinyl Chloride - PVC", code: 94 }, * { name: "Lead - LP", code: 109 } * ]; * return { * choices: choices * };`, * returnType: "dictionary", * }); */ accessor choiceExpression: string | null | undefined; /** The type of form element input. */ get type(): "dynamic-choice"; /** * Creates a deep clone of the `DynamicChoiceInput` class. * * @returns A deep clone of the `DynamicChoiceInput` instance. */ clone(): DynamicChoiceInput; }