import { ExternalComponentSchemaProperty } from './components.js'; import { JSONSchema } from './schema.js'; export type ExternalComponentSchemaHandler = (property: ExternalComponentSchemaProperty) => ExternalComponentSchemaProperty; /** * Defines a custom data type, that can be expanded into multiple properties. Handler is defined as a function that * accepts all the nested properties and returns a new schema. This can be used to define nested structures that * redirect the properties to a nested definition, like Item does. * * `ui` property can be returned as well to customize UI settings for the type (accepts parameters of `ui:options` of UI * Schema (https://rjsf-team.github.io/react-jsonschema-form/docs/api-reference/uiSchema/) ) * * A name of a custom type has to start with a capital letter. * * @param handler * @see https://doc.sitecore.com/xmc/en/developers/xm-cloud/the-simple-field-types.html * https://doc.sitecore.com/xmc/en/developers/xm-cloud/the-link-field-types.html * @example * * registerDataType( * (schema) => ({ * type: 'string', * description: 'My custom data type', * ...schema * }), * { name: 'MyDataType' } * ) * * registerComponent(MyComponent, { * name: 'MyComponent', * properties: { * myField: { * type: 'MyDataType', * title: 'Title will mix with the description' * } * } * }) * */ export declare function registerDataType(handler: ExternalComponentSchemaHandler, { name }: { name: string; }): void; /** * Using `registerDataType` BYOC defines set of data types that are available in XM cloud. * It includes simple types like Date, String, etc, and then complex types link Link, Item and List. * * Custom types start with a capital letter. * - Top level field values are accessed directly by their names. * - Nested fields inside Item, can be accessed via `item.fields..value` notation, or using * `getFieldValue(item.fields, * 'fieldName', defaultValue)` JSS helper. * - List items are accessed via `list[0].fields..value` notation. * * When describing types of properties in components, you can use types provided by JSS: Field<...> and LinkField, * ItemField, ListField, ImageField, etc. The following is a list of all types, their respective JSS types and data * shapes. * | Type | Typescript | Shape | * | ------------------- | ---------------- | ----- | * | File | FileField | { src: string, title: string, displayName: string } | * | Date | Field | "2021-01-01T00:00:00.000Z" | * | Datetime | Field | "2021-01-01T00:00:00.000Z" | * | RichText | Field | "

Some text

" | * | SingleLineText | Field | "Some text" | * | MultiLineText | Field | "Some\ntext" | * | Image | ImageField | { src: string, ... } | * | Checkbox | Field | true | * | Item | Item | { name: string, displayName: string, id: string, url: string, fields: { [key: string]: Field } } | * | List | Item[] | { name: string, displayName: string, id: string, url: string, fields: { [key: string]: Field } }[] | * | Link | LinkField | { href: string, text: string, linktype: string, title: string, class: string, target: string, anchor: string, querystring: string } | * | DropLink | Item | { name: string, displayName: string, id: string, url: string, fields: { [key: string]: Field } } | * | DropTree | Item | { name: string, displayName: string, id: string, url: string, fields: { [key: string]: Field } } | * | String | Field | "Some text" | * | Number | Field | 123 | * | Integer | Field | 123 | * | Boolean | Field | true | * * @example * * registerComponent(MyComponent, { * name: 'MyComponent', * description: 'Description of my example component', * properties: { * myField: { * type: 'Datetime', * title: 'My Field' * }, * activities: { * type: 'List', * properties: { * name: { * type: 'String', * title: 'Name of a person' * }, * rank: { * type: 'Number', * description: 'Numerical rank, like 1, 2, 3, etc' * } * } * }, * myItem: { * type: 'Item', * properties: { * nestedField: { * type: 'Number' * title: 'Nested Field * } * } * } * } * }) * * * function MyComponebnt(props: {myField: string, myItem: { fields: { nestedField: number } }, activities: { fields: { name: string, rank: number } }[] }) { * return <> *
{props.myField}
*
{props.myItem.fields.nestedField} or {getFieldValue(props.myItem.fields, 'nestedField')}
* * } * */ export declare const BYOCDataTypes: Record; export declare const XMTypes: { readonly Link: () => { type: string; properties: { href: { required: boolean; type: string; title: string; description: string; }; text: { type: string; title: string; description: string; }; linktype: { type: string; enum: string[]; default: string; title: string; description: string; }; title: { type: string; title: string; description: string; }; class: { type: string; title: string; description: string; }; target: { type: string; title: string; description: string; enum: string[]; }; anchor: { type: string; title: string; description: string; }; querystring: { type: string; title: string; description: string; }; }; }; readonly DropLink: ({ properties, ...schema }: ExternalComponentSchemaProperty) => { type: string; properties: { name: { type: string; }; displayName: { type: string; }; id: { type: string; }; url: { type: string; }; fields: { type: string; properties: {}; }; }; additionalProperties?: JSONSchema | boolean; required?: string[]; minProperties?: number; maxProperties?: number; patternProperties?: Record; dependencies?: Record; enum?: import("json-schema").JSONSchema7Type[] | undefined | undefined; title?: string | undefined | undefined; description?: string | undefined | undefined; default?: import("json-schema").JSONSchema7Type | undefined; isHidden?: boolean; ui?: import("./schema.js").UISchema; }; readonly DropTree: ({ properties, ...schema }: ExternalComponentSchemaProperty) => { type: string; properties: { name: { type: string; }; displayName: { type: string; }; id: { type: string; }; url: { type: string; }; fields: { type: string; properties: {}; }; }; additionalProperties?: JSONSchema | boolean; required?: string[]; minProperties?: number; maxProperties?: number; patternProperties?: Record; dependencies?: Record; enum?: import("json-schema").JSONSchema7Type[] | undefined | undefined; title?: string | undefined | undefined; description?: string | undefined | undefined; default?: import("json-schema").JSONSchema7Type | undefined; isHidden?: boolean; ui?: import("./schema.js").UISchema; }; readonly File: () => { type: string; properties: { src: { type: string; title: string; description: string; }; title: { type: string; title: string; description: string; }; displayName: { type: string; title: string; description: string; }; }; }; readonly Date: () => { type: string; format: string; }; readonly Datetime: () => { type: string; format: string; }; readonly RichText: () => { type: string; }; readonly Image: (schema: ExternalComponentSchemaProperty) => { type: string; properties: { src: { type: string; }; }; }; readonly SingleLineText: () => void; readonly MultiLineText: () => { type: string; }; readonly Checkbox: () => { type: string; }; readonly String: () => { type: string; }; readonly Number: () => { type: string; }; readonly Boolean: () => { type: string; }; readonly Item: ({ properties, ...schema }: ExternalComponentSchemaProperty) => { type: string; properties: { name: { type: string; }; displayName: { type: string; }; id: { type: string; }; url: { type: string; }; fields: { type: string; properties: {}; }; }; additionalProperties?: JSONSchema | boolean; required?: string[]; minProperties?: number; maxProperties?: number; patternProperties?: Record; dependencies?: Record; enum?: import("json-schema").JSONSchema7Type[] | undefined | undefined; title?: string | undefined | undefined; description?: string | undefined | undefined; default?: import("json-schema").JSONSchema7Type | undefined; isHidden?: boolean; ui?: import("./schema.js").UISchema; }; readonly List: ({ properties, ...schema }: ExternalComponentSchemaProperty) => { type: string; items: { type: string; properties: { name: { type: string; }; displayName: { type: string; }; id: { type: string; }; url: { type: string; }; fields: { type: string; properties: {}; }; }; }; additionalProperties?: JSONSchema | boolean; required?: string[]; minProperties?: number; maxProperties?: number; patternProperties?: Record; dependencies?: Record; enum?: import("json-schema").JSONSchema7Type[] | undefined | undefined; title?: string | undefined | undefined; description?: string | undefined | undefined; default?: import("json-schema").JSONSchema7Type | undefined; isHidden?: boolean; ui?: import("./schema.js").UISchema; }; }; export type XMTypes = typeof XMTypes; //# sourceMappingURL=datatypes.d.ts.map