import _ from 'lodash'; import { BaseComponent, ISelectOptionItem } from './base-component'; export class SelectComponent extends BaseComponent { protected override getComponentCustomProperties() { return { options: this.getSelectOptions(), }; } private getSelectOptions(): ISelectOptionItem[] { return ( this.properties.allow // Joi v18 prepends a `{ override: true }` marker to `allow` when `.only()` is set. // Strip only that marker (and nulls, which historically were not rendered as options), // NOT every object — a user could legitimately have `.valid({ key: 'x' })` with an // object literal, and we shouldn't silently drop it. ?.filter((option: any) => option !== null && !(typeof option === 'object' && option?.override === true)) ?.map((option: string) => { return { label: _.startCase(option), value: option, }; }) ?? [] ); } }