UNPKG

@prefecthq/prefect-ui-library

Version:

This library is the Vue and Typescript component library for [Prefect 2](https://github.com/PrefectHQ/prefect) and [Prefect Cloud 2](https://www.prefect.io/cloud/). _The components and utilities in this project are not meant to be used independently_.

36 lines (27 loc) 938 B
import { PNumberInput, PCombobox } from '@prefecthq/prefect-design' import { SchemaPropertyService } from '@/services/schemas/properties/SchemaPropertyService' import { SchemaPropertyComponentWithProps } from '@/services/schemas/utilities' import { SchemaValue } from '@/types/schemas' export class SchemaPropertyInteger extends SchemaPropertyService { protected get default(): unknown { return this.property.default ?? null } protected override get component(): SchemaPropertyComponentWithProps { if (this.has('enum')) { return this.withProps(PCombobox, { options: this.getSelectOptions(), }) } return this.withProps(PNumberInput) } protected request(value: SchemaValue): unknown { return value } protected response(value: SchemaValue): unknown { const result = parseInt(value as string) if (isNaN(result)) { return this.invalid() } return result } }