@sanity/form-toolkit
3.0.173.0.18
dist/form-schema/index.js.map~
dist/form-schema/index.js.mapModified+1−1
Index: package/dist/form-schema/index.js.map
===================================================================
--- package/dist/form-schema/index.js.map
+++ package/dist/form-schema/index.js.map
@@ -1,1 +1,1 @@
-{"version":3,"file":"index.js","names":["props.path.slice(0, 2)","path","props.renderDefault(props)","props.renderDefault","props.renderDefault({\n ...props,\n schemaType: {\n ...props.schemaType,\n options: {...props.schemaType.options, list: validationTypesByFieldType[type]},\n },\n })","props.schemaType.options","validationTypesByFieldType[type]"],"sources":["../../src/form-schema/schema-types/form.ts","../../src/form-schema/components/validation-type.tsx","../../src/form-schema/schema-types/form-field.ts","../../src/form-schema/schema-types/index.ts","../../src/form-schema/index.ts"],"sourcesContent":["import {FaWpforms} from 'react-icons/fa'\nimport {defineField, defineType, type SchemaTypeDefinition} from 'sanity'\n\nimport type {FieldsOption} from '..'\n\nexport const formType = (fields: FieldsOption): SchemaTypeDefinition => {\n // const fieldsOf =\n // fields && fields.length ? [{type: 'formField'}, ...fields] : [{type: 'formField'}]\n return defineType({\n name: 'form',\n title: 'Form',\n type: 'document',\n icon: FaWpforms,\n fields: [\n defineField({\n name: 'title',\n title: 'Form Title',\n type: 'string',\n description: 'Internal title for the form',\n validation: (Rule) => Rule.required(),\n }),\n defineField({\n name: 'id',\n title: 'Form ID',\n type: 'slug',\n options: {\n source: 'title',\n },\n // validation: (Rule) => Rule.required(),\n }),\n defineField({\n name: 'fields',\n title: 'Form Fields',\n type: 'array',\n of: [{type: 'formField'}, ...fields],\n }),\n defineField({\n name: 'submitButton',\n title: 'Submit Button',\n type: 'object',\n fields: [\n defineField({\n name: 'text',\n title: 'Button Text',\n type: 'string',\n initialValue: 'Submit',\n }),\n ],\n }),\n ],\n })\n}\n","import type {StringInputProps} from 'sanity'\nimport {useFormValue} from 'sanity'\n\nimport type {FormField} from '../../form-renderer/components/types'\nimport {validationTypesByFieldType} from '../schema-types/form-field'\n\nexport const ValidationType = (props: StringInputProps) => {\n // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- parent value shape is defined by the formField schema type\n const {type} = useFormValue(props.path.slice(0, 2)) as FormField\n if (!type || !props.schemaType?.options) return props.renderDefault(props)\n return props.renderDefault({\n ...props,\n schemaType: {\n ...props.schemaType,\n options: {...props.schemaType.options, list: validationTypesByFieldType[type]},\n },\n })\n}\n","import {LuTextCursorInput} from 'react-icons/lu'\nimport {defineField, defineType} from 'sanity'\n\nimport {ValidationType} from '../components/validation-type'\ninterface ValidationContextDocument {\n fields?: Array<{\n name: string\n type?: string\n }>\n}\n\n// Validation options by field type\nexport const validationTypesByFieldType: Record<string, string[]> = {\n 'checkbox': ['minSelectedCount', 'maxSelectedCount'],\n 'color': [],\n 'date': ['minDate', 'maxDate'],\n 'datetime-local': ['minDate', 'maxDate'],\n 'email': ['pattern'],\n 'file': ['maxSize', 'fileType'],\n 'hidden': [],\n 'number': ['min', 'max'],\n // password: ['minLength', 'pattern'],\n 'radio': [],\n 'range': ['min', 'max', 'step'],\n 'select': [],\n 'tel': ['pattern'],\n 'text': ['minLength', 'maxLength', 'pattern'],\n 'textarea': ['minLength', 'maxLength'],\n 'time': [],\n 'url': ['pattern'],\n}\nconst fieldTypeTitle = (fieldType: string): string => {\n switch (fieldType) {\n case 'datetime-local':\n return 'Date & Time'\n case 'textarea':\n return 'Text Area'\n case 'tel':\n return 'Phone Number'\n default:\n return fieldType.charAt(0).toUpperCase() + fieldType.slice(1)\n }\n}\n\nexport const formFieldType = defineType({\n name: 'formField',\n title: 'Form Field',\n type: 'object',\n icon: LuTextCursorInput,\n fields: [\n defineField({\n name: 'type',\n title: 'Field Type',\n type: 'string',\n options: {\n list: Object.keys(validationTypesByFieldType).map((type) => {\n return {title: fieldTypeTitle(type), value: type}\n }),\n },\n }),\n defineField({\n name: 'label',\n title: 'Field Label',\n type: 'string',\n }),\n defineField({\n name: 'name',\n title: 'Field Name',\n type: 'string',\n description:\n 'Must start with a letter and contain only letters, numbers, underscores, or hyphens. Must be unique within the form.',\n validation: (Rule) =>\n Rule.required().custom((name, context) => {\n if (!name) {\n return 'Required'\n }\n // Check format (HTML ID/name rules)\n if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(name)) {\n return 'Field name must start with a letter and contain only letters, numbers, underscores, or hyphens'\n }\n\n // Check uniqueness across all fields\n // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- document shape is defined by the form schema type\n const doc = context.document as ValidationContextDocument\n const allFieldNames = doc?.fields?.map((field) => field.name) || []\n\n // Count occurrences of this name\n const nameCount = allFieldNames.filter((n) => n === name).length\n\n // If we find more than one occurrence (including current field), it's not unique\n if (nameCount > 1) {\n return 'Field name must be unique across all form fields'\n }\n\n // Check for reserved HTML form attributes\n const reservedNames = [\n 'action',\n 'method',\n 'target',\n 'enctype',\n 'accept-charset',\n 'autocomplete',\n 'novalidate',\n 'rel',\n 'submit',\n 'reset',\n ]\n if (reservedNames.includes(name.toLowerCase())) {\n return 'This name is reserved for HTML form attributes. Please choose a different name.'\n }\n\n return true\n }),\n }),\n defineField({\n name: 'required',\n title: 'Required',\n type: 'boolean',\n initialValue: false,\n }),\n defineField({\n name: 'validation',\n title: 'Validation Rules',\n type: 'array',\n hidden: ({parent}) => {\n if (!parent?.type) return true\n const validationTypes = validationTypesByFieldType[parent.type]\n return !validationTypes || validationTypes.length === 0\n },\n of: [\n {\n type: 'object',\n fields: [\n defineField({\n name: 'type',\n title: 'Validation Type',\n type: 'string',\n options: {\n // TODO: I think this needs to be a custom input component?\n // list: ({parent}) => (parent?.type ? validationTypesByFieldType[parent.type] : []),\n list: [],\n },\n components: {\n input: ValidationType,\n },\n }),\n defineField({\n name: 'value',\n title: 'Value',\n type: 'string',\n }),\n defineField({\n name: 'message',\n title: 'Error Message',\n type: 'string',\n }),\n ],\n preview: {\n select: {\n title: 'type',\n subtitle: 'value',\n },\n },\n },\n ],\n }),\n defineField({\n name: 'choices',\n title: 'Choices',\n type: 'array',\n hidden: ({parent}) => {\n return !['select', 'radio', 'checkbox'].includes(parent?.type)\n },\n of: [\n {\n type: 'object',\n fields: [\n defineField({\n name: 'label',\n title: 'Label',\n type: 'string',\n }),\n defineField({\n name: 'value',\n title: 'Value',\n type: 'string',\n }),\n ],\n },\n ],\n }),\n defineField({\n name: 'options',\n title: 'Field Options',\n type: 'object',\n hidden: ({parent}) => {\n return ['select', 'radio', 'checkbox', 'file'].includes(parent?.type)\n },\n fields: [\n defineField({\n name: 'placeholder',\n title: 'Placeholder',\n type: 'string',\n }),\n defineField({\n name: 'defaultValue',\n title: 'Default Value',\n type: 'string',\n }),\n ],\n }),\n ],\n preview: {\n select: {\n label: 'label',\n name: 'name',\n type: 'type',\n },\n prepare({label, name, type}) {\n return {\n title: label || name,\n subtitle: type,\n }\n },\n },\n})\n","import type {SchemaTypeDefinition} from 'sanity'\n\nimport type {FieldsOption} from '..'\nimport {formType} from './form'\nimport {formFieldType} from './form-field'\n\nexport const schema = (fields: FieldsOption): {types: SchemaTypeDefinition[]} => {\n return {types: [formType(fields), formFieldType]}\n}\n","import {definePlugin, type FieldDefinition} from 'sanity'\n\n// import {structureTool} from 'sanity/structure'\n// import {FormRenderer} from './components/form-renderer'\nimport {schema} from './schema-types'\n// import {defaultDocumentNode} from './structure'\n\n/**\n * Usage in `sanity.config.ts` (or .js)\n *\n * ```ts\n * import {defineConfig} from 'sanity'\n * import {formSchema} from '@sanity/form-toolkit/form-schema'\n *\n * export default defineConfig({\n * // ...\n * plugins: [formSchema()],\n * })\n * ```\n */\nexport type FieldsOption = Array<FieldDefinition>\ninterface FormSchemaPluginOptions {\n /**\n * Array of field definitions to be used in the form schema.\n */\n fields?: FieldsOption\n}\n\nexport const formSchema = definePlugin<FormSchemaPluginOptions | void>((options) => {\n return {\n name: 'form-toolkit_form-schema',\n schema: schema(options?.fields ?? []),\n // plugins: [structureTool({defaultDocumentNode})],\n }\n})\n"],"mappings":";;;;AAKA,MAAa,YAAY,WAGhB,WAAW;CAChB,MAAM;CACN,O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O;GAC3B,OAAO;IACL,OAAO,SAAS;IAChB,UAAU;GACZ;EACF;CACF;AACF,CAAC,GC3NY,UAAU,YACd,EAAC,OAAO,CAAC,SAAS,MAAM,GAAG,aAAa,EAAC,ICqBrC,aAAa,cAA8C,aAC/D;CACL,MAAM;CACN,QAAQ,OAAO,SAAS,UAAU,CAAC,CAAC;AAEtC,EACD"}
\ No newline at end of file
+{"version":3,"file":"index.js","names":["props.path.slice(0, 2)","path","props.renderDefault(props)","props.renderDefault","props.renderDefault({\n ...props,\n schemaType: {\n ...props.schemaType,\n options: {...props.schemaType.options, list: validationTypesByFieldType[type]},\n },\n })","props.schemaType.options","validationTypesByFieldType[type]","_c","\"checkbox\"","\"color\"","\"date\"","\"email\"","\"file\"","\"hidden\"","\"number\"","\"radio\"","\"range\"","\"select\"","\"tel\"","\"text\"","\"textarea\"","\"time\"","\"url\""],"sources":["../../src/form-schema/schema-types/form.ts","../../src/form-schema/components/validation-type.tsx","../../src/form-schema/schema-types/form-field.ts","../../src/form-schema/schema-types/index.ts","../../src/form-schema/index.ts"],"sourcesContent":["import {FaWpforms} from 'react-icons/fa'\nimport {defineField, defineType, type SchemaTypeDefinition} from 'sanity'\n\nimport type {FieldsOption} from '..'\n\nexport const formType = (fields: FieldsOption): SchemaTypeDefinition => {\n // const fieldsOf =\n // fields && fields.length ? [{type: 'formField'}, ...fields] : [{type: 'formField'}]\n return defineType({\n name: 'form',\n title: 'Form',\n type: 'document',\n icon: FaWpforms,\n fields: [\n defineField({\n name: 'title',\n title: 'Form Title',\n type: 'string',\n description: 'Internal title for the form',\n validation: (Rule) => Rule.required(),\n }),\n defineField({\n name: 'id',\n title: 'Form ID',\n type: 'slug',\n options: {\n source: 'title',\n },\n // validation: (Rule) => Rule.required(),\n }),\n defineField({\n name: 'fields',\n title: 'Form Fields',\n type: 'array',\n of: [{type: 'formField'}, ...fields],\n }),\n defineField({\n name: 'submitButton',\n title: 'Submit Button',\n type: 'object',\n fields: [\n defineField({\n name: 'text',\n title: 'Button Text',\n type: 'string',\n initialValue: 'Submit',\n }),\n ],\n }),\n ],\n })\n}\n","import type {StringInputProps} from 'sanity'\nimport {useFormValue} from 'sanity'\n\nimport type {FormField} from '../../form-renderer/components/types'\nimport {validationTypesByFieldType} from '../schema-types/form-field'\n\nexport const ValidationType = (props: StringInputProps) => {\n // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- parent value shape is defined by the formField schema type\n const {type} = useFormValue(props.path.slice(0, 2)) as FormField\n if (!type || !props.schemaType?.options) return props.renderDefault(props)\n return props.renderDefault({\n ...props,\n schemaType: {\n ...props.schemaType,\n options: {...props.schemaType.options, list: validationTypesByFieldType[type]},\n },\n })\n}\n","import {LuTextCursorInput} from 'react-icons/lu'\nimport {defineField, defineType} from 'sanity'\n\nimport {ValidationType} from '../components/validation-type'\ninterface ValidationContextDocument {\n fields?: Array<{\n name: string\n type?: string\n }>\n}\n\n// Validation options by field type\nexport const validationTypesByFieldType: Record<string, string[]> = {\n 'checkbox': ['minSelectedCount', 'maxSelectedCount'],\n 'color': [],\n 'date': ['minDate', 'maxDate'],\n 'datetime-local': ['minDate', 'maxDate'],\n 'email': ['pattern'],\n 'file': ['maxSize', 'fileType'],\n 'hidden': [],\n 'number': ['min', 'max'],\n // password: ['minLength', 'pattern'],\n 'radio': [],\n 'range': ['min', 'max', 'step'],\n 'select': [],\n 'tel': ['pattern'],\n 'text': ['minLength', 'maxLength', 'pattern'],\n 'textarea': ['minLength', 'maxLength'],\n 'time': [],\n 'url': ['pattern'],\n}\nconst fieldTypeTitle = (fieldType: string): string => {\n switch (fieldType) {\n case 'datetime-local':\n return 'Date & Time'\n case 'textarea':\n return 'Text Area'\n case 'tel':\n return 'Phone Number'\n default:\n return fieldType.charAt(0).toUpperCase() + fieldType.slice(1)\n }\n}\n\nexport const formFieldType = defineType({\n name: 'formField',\n title: 'Form Field',\n type: 'object',\n icon: LuTextCursorInput,\n fields: [\n defineField({\n name: 'type',\n title: 'Field Type',\n type: 'string',\n options: {\n list: Object.keys(validationTypesByFieldType).map((type) => {\n return {title: fieldTypeTitle(type), value: type}\n }),\n },\n }),\n defineField({\n name: 'label',\n title: 'Field Label',\n type: 'string',\n }),\n defineField({\n name: 'name',\n title: 'Field Name',\n type: 'string',\n description:\n 'Must start with a letter and contain only letters, numbers, underscores, or hyphens. Must be unique within the form.',\n validation: (Rule) =>\n Rule.required().custom((name, context) => {\n if (!name) {\n return 'Required'\n }\n // Check format (HTML ID/name rules)\n if (!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(name)) {\n return 'Field name must start with a letter and contain only letters, numbers, underscores, or hyphens'\n }\n\n // Check uniqueness across all fields\n // oxlint-disable-next-line typescript-eslint/no-unsafe-type-assertion -- document shape is defined by the form schema type\n const doc = context.document as ValidationContextDocument\n const allFieldNames = doc?.fields?.map((field) => field.name) || []\n\n // Count occurrences of this name\n const nameCount = allFieldNames.filter((n) => n === name).length\n\n // If we find more than one occurrence (including current field), it's not unique\n if (nameCount > 1) {\n return 'Field name must be unique across all form fields'\n }\n\n // Check for reserved HTML form attributes\n const reservedNames = [\n 'action',\n 'method',\n 'target',\n 'enctype',\n 'accept-charset',\n 'autocomplete',\n 'novalidate',\n 'rel',\n 'submit',\n 'reset',\n ]\n if (reservedNames.includes(name.toLowerCase())) {\n return 'This name is reserved for HTML form attributes. Please choose a different name.'\n }\n\n return true\n }),\n }),\n defineField({\n name: 'required',\n title: 'Required',\n type: 'boolean',\n initialValue: false,\n }),\n defineField({\n name: 'validation',\n title: 'Validation Rules',\n type: 'array',\n hidden: ({parent}) => {\n if (!parent?.type) return true\n const validationTypes = validationTypesByFieldType[parent.type]\n return !validationTypes || validationTypes.length === 0\n },\n of: [\n {\n type: 'object',\n fields: [\n defineField({\n name: 'type',\n title: 'Validation Type',\n type: 'string',\n options: {\n // TODO: I think this needs to be a custom input component?\n // list: ({parent}) => (parent?.type ? validationTypesByFieldType[parent.type] : []),\n list: [],\n },\n components: {\n input: ValidationType,\n },\n }),\n defineField({\n name: 'value',\n title: 'Value',\n type: 'string',\n }),\n defineField({\n name: 'message',\n title: 'Error Message',\n type: 'string',\n }),\n ],\n preview: {\n select: {\n title: 'type',\n subtitle: 'value',\n },\n },\n },\n ],\n }),\n defineField({\n name: 'choices',\n title: 'Choices',\n type: 'array',\n hidden: ({parent}) => {\n return !['select', 'radio', 'checkbox'].includes(parent?.type)\n },\n of: [\n {\n type: 'object',\n fields: [\n defineField({\n name: 'label',\n title: 'Label',\n type: 'string',\n }),\n defineField({\n name: 'value',\n title: 'Value',\n type: 'string',\n }),\n ],\n },\n ],\n }),\n defineField({\n name: 'options',\n title: 'Field Options',\n type: 'object',\n hidden: ({parent}) => {\n return ['select', 'radio', 'checkbox', 'file'].includes(parent?.type)\n },\n fields: [\n defineField({\n name: 'placeholder',\n title: 'Placeholder',\n type: 'string',\n }),\n defineField({\n name: 'defaultValue',\n title: 'Default Value',\n type: 'string',\n }),\n ],\n }),\n ],\n preview: {\n select: {\n label: 'label',\n name: 'name',\n type: 'type',\n },\n prepare({label, name, type}) {\n return {\n title: label || name,\n subtitle: type,\n }\n },\n },\n})\n","import type {SchemaTypeDefinition} from 'sanity'\n\nimport type {FieldsOption} from '..'\nimport {formType} from './form'\nimport {formFieldType} from './form-field'\n\nexport const schema = (fields: FieldsOption): {types: SchemaTypeDefinition[]} => {\n return {types: [formType(fields), formFieldType]}\n}\n","import {definePlugin, type FieldDefinition} from 'sanity'\n\n// import {structureTool} from 'sanity/structure'\n// import {FormRenderer} from './components/form-renderer'\nimport {schema} from './schema-types'\n// import {defaultDocumentNode} from './structure'\n\n/**\n * Usage in `sanity.config.ts` (or .js)\n *\n * ```ts\n * import {defineConfig} from 'sanity'\n * import {formSchema} from '@sanity/form-toolkit/form-schema'\n *\n * export default defineConfig({\n * // ...\n * plugins: [formSchema()],\n * })\n * ```\n */\nexport type FieldsOption = Array<FieldDefinition>\ninterface FormSchemaPluginOptions {\n /**\n * Array of field definitions to be used in the form schema.\n */\n fields?: FieldsOption\n}\n\nexport const formSchema = definePlugin<FormSchemaPluginOptions | void>((options) => {\n return {\n name: 'form-toolkit_form-schema',\n schema: schema(options?.fields ?? []),\n // plugins: [structureTool({defaultDocumentNode})],\n }\n})\n"],"mappings":";;;;AAKA,MAAa,YAAY,WAGhB,WAAW;CAChB,MAAM;CACN,OAAO;CACP,MAAM;CACN,MAAM;CACN,QAAQ;EACN,YAAY;GACV,MAAM;GACN,OAAO;GACP,MAAM;GACN,aAAa;GACb,aAAa,SAAS,KAAK,SAAS;EACtC,CAAC;EACD,YAAY;GACV,MAAM;GACN,OAAO;GACP,MAAM;GACN,SAAS,EACP,QAAQ,QACV;EAEF,CAAC;EACD,YAAY;GACV,MAAM;GACN,OAAO;GACP,MAAM;GACN,IAAI,CAAC,EAAC,MAAM,YAAW,GAAG,GAAG,MAAM;EACrC,CAAC;EACD,YAAY;GACV,MAAM;GACN,OAAO;GACP,MAAM;GACN,QAAQ,CACN,YAAY;IACV,MAAM;IACN,OAAO;IACP,MAAM;IACN,cAAc;GAChB,CAAC,CACH;EACF,CAAC;CACH;AACF,CAAC,GC5CU,kBAAkB,UAA4B;eAE7BA;CAAMC,AAAAA,EAAAA,OAAAA,MAAAA,oBAAN,KAAA,MAAM,KAAK,MAAM,GAAG,CAAC,GAAfA,EAAAA,KAAAA,MAAAA;CAAlC,IAAM,EAAC,SAAQ,aAAaD,EAAsB;CAClD,IAAI,CAAC,QAAQ,CAAC,MAAM,YAAY,SAAA;EAAgBE,IAAAA;EAAP,qCAAa,KAAA,MAAA,cAAc,KAAK,GAAzBC,EAAAA,KAAAA,mBAAAD;;CAKC,IAAA,KAAA,2BAA2B,OAJrEE;CAAP,OAIiBC,EAAAA,OAAAA,SAAAA,EAAAA,OAAgCC,MAJ1C,KAAA,MAAM,cAAc;EACzB,GAAG;EACH,YAAY;GACV,GAAG,MAAM;GACT,SAAS;IAAC,GAAG,MAAM,WAAW;IAAS,MAAMA;GAAgC;EAC/E;CACF,CAAC,GAFgBD,E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