UNPKG

@vaadin/hilla-models

Version:

Generative form models for Hilla

51 lines 1.41 kB
export const nothing = Symbol('nothing'); const detachedTarget = Object.create({ toString: () => ':detached:', }, { model: { value: undefined }, value: { value: nothing }, }); export const $key = Symbol('key'); export const $name = Symbol('name'); export const $owner = Symbol('owner'); export const $meta = Symbol('meta'); export const $optional = Symbol('optional'); export const $defaultValue = Symbol('defaultValue'); export const $constraints = Symbol('constraints'); export const $members = Symbol('members'); export const $assertSupportedModel = Symbol('assertSupportedModel'); export const Model = Object.create(null, { [$key]: { value: 'model', }, [$name]: { value: 'unknown', }, [$owner]: { value: detachedTarget, }, [$meta]: {}, [$optional]: { value: false, }, [$defaultValue]: {}, [$constraints]: { value: [], }, [Symbol.toStringTag]: { get() { return this[$name]; }, }, [Symbol.hasInstance]: { value(o) { return typeof o === 'object' && o != null && (this === o || Object.prototype.isPrototypeOf.call(this, o)); }, }, toString: { value() { return `[${String(this[$owner])} / ${String(this[$key])}${this[$optional] ? '?' : ''}] ${this[$name]}`; }, }, }); //# sourceMappingURL=Model.js.map