-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
82 lines (65 loc) · 2.35 KB
/
Copy pathtypes.ts
File metadata and controls
82 lines (65 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { type PluginsCommonOptions } from "adminforth";
/**
* A JSON-Schema-like node used to describe the form. Only a subset of JSON Schema
* is supported, extended with `x-*` keywords that control rendering.
*/
export interface JsonFormSchema {
title?: string;
description?: string;
type?: "object" | "array" | "string" | "integer" | "number" | "boolean";
/** Object */
properties?: Record<string, JsonFormSchema>;
required?: string[];
/** Array */
items?: JsonFormSchema;
minItems?: number;
maxItems?: number;
uniqueItems?: boolean;
/** Scalar */
enum?: (string | number | boolean)[];
const?: string | number | boolean;
minLength?: number;
maxLength?: number;
minimum?: number;
maximum?: number;
readOnly?: boolean;
default?: any;
/** Discriminated union */
oneOf?: JsonFormSchema[];
/**
* Controls how this node is rendered. Supported values:
* - objects: `grid`, `nav-vertical`
* - arrays: `nav-horizontal`, `table`, `table-object`, `checkboxes-inline`
* - scalars: `textarea`, `color`, `range`, `radios`, `radios-inline`, `checkbox`
*/
"x-format"?: string;
/** Titles for `enum` values, in the same order as `enum`. */
"x-enumTitles"?: string[];
/** Grid placement when parent object uses `x-format: grid`. `columns` out of 12. */
"x-grid"?: { columns?: number };
/** Per-validation-rule custom error messages, e.g. `{ minLength: "...", required: "..." }`. */
"x-messages"?: Record<string, string>;
/** Bootstrap-icon class shown near a field title, e.g. `bi bi-person-fill`. */
"x-titleIconClass"?: string;
/** Enables drag & reorder for arrays. */
"x-sortable"?: boolean;
/** Mustache-like template for array item tab titles, e.g. `{{ i1 }}) {{ value.name }}`. */
"x-titleTemplate"?: string;
/** Discriminator property name for `oneOf` unions. */
"x-discriminator"?: string;
/** Title of a `oneOf` branch shown in the variant switcher. */
"x-switcherTitle"?: string;
/** Keep a `const` value locked (used for discriminator markers). */
"x-enforceConst"?: boolean;
}
export interface PluginOptions extends PluginsCommonOptions {
/**
* Name of the field (column) that stores the JSON data.
* The column MUST be of AdminForth `json` datatype.
*/
fieldName: string;
/**
* JSON Schema describing the form to render for the field.
*/
schema: JsonFormSchema;
}