Skip to content

Types

The Types module exports shared TypeScript types and constants used across the component library. Import from @cratis/components/types.

Describes the shape of a JSON Schema object used by ObjectContentEditor, SchemaEditor, and related components.

import { JsonSchema, JsonSchemaProperty } from '@cratis/components/types';
const schema: JsonSchema = {
type: 'object',
required: ['name'],
properties: {
name: { type: 'string', description: 'Full name' },
age: { type: 'integer' },
email: { type: 'string', format: 'email' }
}
};
PropertyTypeDescription
titlestringHuman-readable title
namestringSchema name
$idstringSchema identifier
$refstringReference to another schema
typestringJSON type (object, array, string, number, integer, boolean)
formatstringFormat hint (e.g. date-time, email, uri, uuid)
descriptionstringProperty description — displayed as a tooltip
propertiesRecord<string, JsonSchemaProperty>Object properties
itemsJsonSchemaSchema for array items
requiredstring[]Names of required properties
definitionsRecord<string, JsonSchema>Reusable sub-schemas
PropertyTypeDescription
idstringProperty identifier
namestringProperty name
typestringJSON type
formatstringFormat hint
descriptionstringDescription shown as tooltip
itemsJsonSchemaSchema for array items
propertiesRecord<string, JsonSchemaProperty>Nested properties
requiredbooleanWhether the property is required
$refstringReference to another schema

A recursive type representing any valid JSON value.

import { Json } from '@cratis/components/types';
type Json = string | number | boolean | null | Json[] | { [key: string]: Json };

Use Json for the object prop on ObjectContentEditor and for onChange callbacks.

Represents a JSON type and format pair. Used to describe the type/format combinations that a schema editor or form field supports.

import { TypeFormat, DEFAULT_TYPE_FORMATS } from '@cratis/components/types';

A pre-defined list of common type/format combinations:

jsonTypeformat
string(none)
stringguid
stringdate-time
stringdate
stringtime
integer(none)
integerint16
integerint32
integerint64
number(none)
numberfloat

Represents a single step in a breadcrumb navigation path.

import { NavigationItem } from '@cratis/components/types';
interface NavigationItem {
name: string;
path: string[];
}

Used internally by ObjectNavigationalBar.