UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 1.61 kB
import{copy as e}from"../../../../i18n/copy.mjs";import{zodToJsonSchema as t}from"../../utils/helpers.mjs";import n from"../../utils/zod-safe-parse.mjs";import r from"../../custom-field.mjs";import i from"../../utils/key-to-title.mjs";import{textFieldConfig as a}from"./config.mjs";import{defaultTextFieldAiGuidance as o}from"../../ai-guidance.mjs";import s from"zod";var c=class extends r{type=a.type;config;key;props;constructor(t,n){super(),this.key=t,this.props=n,this.config={key:this.key,type:this.type,details:{label:this.props?.details?.label??e(`admin:fields.${this.type}.${this.key}.label`,{defaultMessage:i(this.key)}),summary:this.props?.details?.summary,placeholder:this.props?.details?.placeholder},ai:this.props?.ai,localized:this.props?.localized??!0,default:this.props?.default??``,index:this.props?.index,ui:{hidden:this.props?.ui?.hidden,disabled:this.props?.ui?.disabled,condition:this.props?.ui?.condition,width:this.props?.ui?.width},validation:this.props?.validation}}get supportsAi(){return!0}get defaultAiGuidance(){return o}get jsonSchema(){return t(this.config.validation?.zod,{type:`string`})}getSchemaDefinition(e){return{data:{columns:[{name:this.key,type:e.db.getDataType(`text`),nullable:!0,default:this.config.default}]},error:void 0}}formatResponseValue(e){return e??this.config.default??null}formatAiGeneratedValue(e){return{success:!0,value:typeof e==`string`?e:String(e??``)}}normalizeInputValue(e){return typeof e==`string`?e.trim():e}uniqueValidation(e){let t=n(e,s.string());return t.valid?{valid:!0}:t}};export{c as default}; //# sourceMappingURL=custom-field.mjs.map