valuesSubstore
Manages the selected option values and quantities for every configuration. Each config has its own isolated ValuesStoreItem, stored in valuesConfigs. The form constraint engine reads from this substore to evaluate which elements/options should be shown or hidden.
Table of contents
Properties
Methods
Properties
valuesConfigs
valuesConfigs: Record<number, ValuesStoreItemVariables>Map from config ID to its values, quantities, and selected-products state.
Each entry holds:
values: TValues—Record<elementId, string[]>of selected option IDs or free-text valuesquantities: TQuantities—Record<elementId, Record<optionId, number>>of option quantitiesselectedProductsIds: Set<number>— IDs of products linked to selected optionsselectedProductsQuantities: Record<number, number>— product quantities
Entries are created by configsSubstore.addConfig and removed by configsSubstore.removeConfig.
type TValues = Record<string, string[]>;type TQuantities = Record<string, Record<string, number>>;Related
configsSubstore.configs— each config ID has a corresponding entry hereformSubstore.fromConfigs— parallel map of form statefinishedConfigsSubstore.getFinishedConfigs— aggregates values from this mapnumberFormatterSubstore.calculateConfigPrice— reads values and quantities from heresubmitSubstore.submit— reads values from here to build the API payload
Methods
setElementValue
setElementValue: ( configId: number, elementId: number, value: string[],) => voidSets the selected values for a specific element in a config.
Replaces the entire value array for elementId. Pass an empty array to deselect all options. The constraint engine re-evaluates automatically after this call.
Parameters
| Name | Type | Description |
|---|---|---|
configId | number | Target configuration |
elementId | number | Target element |
value | string[] | Array of selected option IDs or free-text values |
Related
valuesConfigshandleChangeInput— higher-level helper that calls this internally
setOptionQuantity
setOptionQuantity: ( configId: number, elementId: number, optionId: number, quantity: number,) => voidSets the quantity of a specific option within an element for the given config.
Does not affect whether the option is selected — selection is managed via setElementValue.
Parameters
| Name | Type | Description |
|---|---|---|
configId | number | Target configuration |
elementId | number | Element containing the option |
optionId | number | Option whose quantity to set |
quantity | number | New quantity value |
Related
valuesConfigsnumberFormatterSubstore.calculateOptionPriceWithQuantities— reads quantities from this map
setValues
setValues: (configId: number, values: TValues) => voidBulk-replaces all values for the given config.
Replaces the entire values map for configId. Use this when restoring state (e.g., from a draft) rather than setting values one element at a time.
Parameters
| Name | Type | Description |
|---|---|---|
configId | number | Target configuration |
values | TValues | Complete values map (Record<elementId, string[]>) |
Related
valuesConfigssetQuantities— bulk-replace quantities
setQuantities
setQuantities: (configId: number, quantities: TQuantities) => voidBulk-replaces all quantities for the given config.
Replaces the entire quantities map for configId. Use alongside setValues when restoring full config state.
Parameters
| Name | Type | Description |
|---|---|---|
configId | number | Target configuration |
quantities | TQuantities | Complete quantities map (Record<elementId, Record<optionId, number>>) |
Related
valuesConfigssetValues— bulk-replace values
handleChangeInput
handleChangeInput: (args: { configId: number; type: TElement["type"]; elementId: number; optionIdOrValue: string | number;}) => voidHandles a user input event — toggles a checkbox option or sets a single value depending on element type.
This is the recommended method for wiring up UI input handlers. It implements the correct selection logic for each element type:
- Checkbox elements: toggles the option in the current values array (adds if absent, removes if present)
- All other types (radio, select, text, …): replaces the current selection with
[optionIdOrValue]
Parameters
| Name | Type | Description |
|---|---|---|
args.configId | number | Target configuration |
args.type | TElement["type"] | Element type — controls toggle vs replace behaviour |
args.elementId | number | Target element |
args.optionIdOrValue | string | number | Option ID (for option-based elements) or free-text value |
Related
setElementValue— called internally by this methodvaluesConfigs— updated by this callformSubstore.fromConfigs— elementtypeis read from here