@fluid-topics/ft-select 1.4.4 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,7 @@ export declare class FtSelect extends FtLitElement implements FtSelectProperties
43
43
  private handleAlphanumericPress;
44
44
  private getOptionId;
45
45
  private onSelectOption;
46
+ setValue(value: any, fireEvent?: boolean): void;
46
47
  private selectOption;
47
48
  private hideOptions;
48
49
  connectedCallback(): void;
@@ -265,17 +265,24 @@ class FtSelect extends FtLitElement {
265
265
  }
266
266
  onSelectOption(e) {
267
267
  e.stopPropagation();
268
- const option = this.options.find((opt) => opt.value === e.target.value);
269
- this.selectOption(option);
268
+ this.setValue(e.target.value);
270
269
  }
271
- selectOption(option) {
270
+ setValue(value, fireEvent = true) {
271
+ const option = this.options.find((opt) => deepEqual(opt.value, value));
272
+ if (option) {
273
+ this.selectOption(option, fireEvent);
274
+ }
275
+ }
276
+ selectOption(option, fireEvent = true) {
272
277
  var _a, _b;
273
278
  if (!deepEqual((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value, option === null || option === void 0 ? void 0 : option.value)) {
274
279
  this.selectedOption = option;
275
280
  for (const otherOption of this.options) {
276
281
  otherOption.selected = otherOption === option;
277
282
  }
278
- this.dispatchEvent(new CustomEvent("change", { detail: (_b = this.selectedOption) === null || _b === void 0 ? void 0 : _b.value }));
283
+ if (fireEvent) {
284
+ this.dispatchEvent(new CustomEvent("change", { detail: (_b = this.selectedOption) === null || _b === void 0 ? void 0 : _b.value }));
285
+ }
279
286
  }
280
287
  this.optionsDisplayed = false;
281
288
  }