Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import MyCustomValidationList from './custom/MyCustomValidationList'
import MyCustomImageInput from './custom/MyCustomImageInput'
import MyCustomFileInput from './custom/MyCustomFileInput'
import MyCustomSlugInput from './custom/MyCustomSlugInput'
import applyPatch from '../../../src/simplePatch'
import resolveReferenceInput from './custom/resolveReferenceInput'
import {arrayToJSONMatchPath} from '@sanity/mutator'
import InputWithCustomState from './custom/InputWithCustomState'
import {set, unset} from '../../../src/utils/patches'
import {resolvePreviewComponent} from '../../../src/defaultConfig'
const SCHEMA_NAMES = Object.keys(sourceSchemas)
const params = parseParams(document.location.pathname)
const schema =
params.schemaName && params.typeName && Schema.compile(sourceSchemas[params.schemaName])
const PERSISTKEY = `form-builder-value-${params.schemaName}-${params.typeName}`
const schemaType = schema && schema.get(params.typeName)
function logPatch(patch) {
const {type, path, ...rest} = patch
console.log(
// eslint-disable-line no-console
'%c%s%c %s =>',
'color:#2097ac',
type,
'color:inherit',
arrayToJSONMatchPath(path || []),
rest
)
import React from 'react'
import Undoable from './lib/Undoable'
import Schema from '@sanity/schema'
import {FormBuilder} from '../../src'
import applyPatch from '../../src/simplePatch'
const schema = Schema.compile({
name: 'simple',
types: [
{
name: 'book',
type: 'object',
fields: [
{
name: 'title',
type: 'string',
title: 'Book title'
},
{
name: 'author',
type: 'string',
title: 'Name of author'
},
import React from 'react'
import FormBuilder from '../../src'
import applyPatch from '../../src/simplePatch'
import Schema from '@sanity/schema'
const schema = Schema.compile({
name: 'simple',
types: [
{
name: 'book',
type: 'object',
fields: [
{
name: 'title',
type: 'string',
title: 'Book title'
},
{
name: 'author',
type: 'string',
title: 'Name of author'
},
assetSourceData,
slug,
geopoint,
legacyRichDate,
imageAsset,
fileAsset,
imageCrop,
imageHotspot,
imageMetadata,
imageDimensions,
imagePalette,
imagePaletteSwatch
].filter(Boolean)
}
const compiled = Schema.compile({
name: schemaDef.name,
types
})
compiled._source = schemaDef
compiled._validation = validation
return inferValidation(compiled)
}
const {uniqBy, startCase} = require('lodash')
const generateHelpUrl = require('@sanity/generate-help-url')
const schemaCompiler = require('@sanity/schema')
const oneline = require('oneline')
const helpUrls = require('./helpUrls')
const SchemaError = require('./SchemaError')
const Schema = schemaCompiler.default || schemaCompiler
const skipTypes = ['document', 'reference']
const allowedJsonTypes = ['object', 'array']
const disallowedCustomizedMembers = ['object', 'array', 'image', 'file', 'block']
const scalars = ['string', 'number', 'boolean']
function getBaseType(baseSchema, typeName) {
return Schema.compile({
types: baseSchema._original.types.concat([
{name: `__placeholder__`, type: typeName, options: {hotspot: true}}
])
}).get('__placeholder__')
}
function getTypeName(str) {
const name = startCase(str).replace(/\s+/g, '')
return name === 'Number' ? 'Float' : name
module.exports = schemaDef => {
const validated = validateSchema(schemaDef.types).getTypes()
const validation = groupProblems(validated)
const hasErrors = validation.some(group => group.problems.some(isError))
let types = []
if (!hasErrors) {
types = [
...schemaDef.types,
assetSourceData,
slug,
geopoint,
legacyRichDate,
imageAsset,
fileAsset,
imageCrop,
imageHotspot,
imageMetadata,
imageDimensions,
module.exports = schemaDef => {
const validated = validateSchema(schemaDef.types).getTypes()
const validation = groupProblems(validated)
const hasErrors = validation.some(group => group.problems.some(isError))
let types = []
if (!hasErrors) {
types = [
...schemaDef.types,
assetSourceData,
slug,
geopoint,
legacyRichDate,
imageAsset,
fileAsset,
imageCrop,
imageHotspot,