@cratis/components 4.25.2 → 4.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compat-manifest.json +11 -11
- package/dist/esm/SchemaEditor/NameCell.d.ts +5 -1
- package/dist/esm/SchemaEditor/NameCell.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/NameCell.js +2 -2
- package/dist/esm/SchemaEditor/NameCell.js.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditor.d.ts +63 -48
- package/dist/esm/SchemaEditor/SchemaEditor.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditor.js +83 -25
- package/dist/esm/SchemaEditor/SchemaEditor.js.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditorLabels.d.ts +98 -0
- package/dist/esm/SchemaEditor/SchemaEditorLabels.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditorLabels.js +4 -0
- package/dist/esm/SchemaEditor/SchemaEditorLabels.js.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditorLayout.d.ts +6 -0
- package/dist/esm/SchemaEditor/SchemaEditorLayout.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditorLayout.js +4 -0
- package/dist/esm/SchemaEditor/SchemaEditorLayout.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/Property.d.ts +30 -0
- package/dist/esm/SchemaEditor/Tree/Property.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/Property.js +4 -0
- package/dist/esm/SchemaEditor/Tree/Property.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/PropertyConcept.d.ts +15 -0
- package/dist/esm/SchemaEditor/Tree/PropertyConcept.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/PropertyConcept.js +4 -0
- package/dist/esm/SchemaEditor/Tree/PropertyConcept.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/PropertyConceptsContext.d.ts +22 -0
- package/dist/esm/SchemaEditor/Tree/PropertyConceptsContext.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/PropertyConceptsContext.js +10 -0
- package/dist/esm/SchemaEditor/Tree/PropertyConceptsContext.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/PropertyType.d.ts +22 -0
- package/dist/esm/SchemaEditor/Tree/PropertyType.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/PropertyType.js +15 -0
- package/dist/esm/SchemaEditor/Tree/PropertyType.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/PropertyTypeBadge.d.ts +20 -0
- package/dist/esm/SchemaEditor/Tree/PropertyTypeBadge.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/PropertyTypeBadge.js +11 -0
- package/dist/esm/SchemaEditor/Tree/PropertyTypeBadge.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/PropertyTypeMenu.d.ts +28 -0
- package/dist/esm/SchemaEditor/Tree/PropertyTypeMenu.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/PropertyTypeMenu.js +37 -0
- package/dist/esm/SchemaEditor/Tree/PropertyTypeMenu.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaEditorContext.d.ts +42 -0
- package/dist/esm/SchemaEditor/Tree/SchemaEditorContext.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaEditorContext.js +12 -0
- package/dist/esm/SchemaEditor/Tree/SchemaEditorContext.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaEditorParts.d.ts +60 -0
- package/dist/esm/SchemaEditor/Tree/SchemaEditorParts.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaEditorParts.js +4 -0
- package/dist/esm/SchemaEditor/Tree/SchemaEditorParts.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyContext.d.ts +13 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyContext.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyContext.js +4 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyContext.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRow.d.ts +13 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRow.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRow.js +107 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRow.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRowState.d.ts +16 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRowState.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRowState.js +4 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRowState.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/TreeSchemaEditor.d.ts +116 -0
- package/dist/esm/SchemaEditor/Tree/TreeSchemaEditor.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/TreeSchemaEditor.js +96 -0
- package/dist/esm/SchemaEditor/Tree/TreeSchemaEditor.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/propertyNaming.d.ts +35 -0
- package/dist/esm/SchemaEditor/Tree/propertyNaming.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/propertyNaming.js +34 -0
- package/dist/esm/SchemaEditor/Tree/propertyNaming.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/propertyTree.d.ts +30 -0
- package/dist/esm/SchemaEditor/Tree/propertyTree.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/propertyTree.js +36 -0
- package/dist/esm/SchemaEditor/Tree/propertyTree.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/propertyTypeDisplay.d.ts +22 -0
- package/dist/esm/SchemaEditor/Tree/propertyTypeDisplay.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/propertyTypeDisplay.js +45 -0
- package/dist/esm/SchemaEditor/Tree/propertyTypeDisplay.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/schemaConversion.d.ts +95 -0
- package/dist/esm/SchemaEditor/Tree/schemaConversion.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/schemaConversion.js +171 -0
- package/dist/esm/SchemaEditor/Tree/schemaConversion.js.map +1 -0
- package/dist/esm/SchemaEditor/TypeCell.d.ts +3 -1
- package/dist/esm/SchemaEditor/TypeCell.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/TypeCell.js +2 -2
- package/dist/esm/SchemaEditor/TypeCell.js.map +1 -1
- package/dist/esm/SchemaEditor/defaultSchemaEditorLabels.d.ts +9 -0
- package/dist/esm/SchemaEditor/defaultSchemaEditorLabels.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/defaultSchemaEditorLabels.js +51 -0
- package/dist/esm/SchemaEditor/defaultSchemaEditorLabels.js.map +1 -0
- package/dist/esm/SchemaEditor/index.d.ts +12 -0
- package/dist/esm/SchemaEditor/index.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/index.js +7 -1
- package/dist/esm/SchemaEditor/index.js.map +1 -1
- package/dist/esm/SchemaEditor/resolveSchemaEditorLabels.d.ts +4 -0
- package/dist/esm/SchemaEditor/resolveSchemaEditorLabels.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/resolveSchemaEditorLabels.js +13 -0
- package/dist/esm/SchemaEditor/resolveSchemaEditorLabels.js.map +1 -0
- package/dist/esm/styles.SchemaEditor.css +346 -0
- package/dist/esm/styles.css +346 -0
- package/dist/esm/types/parts.d.ts +25 -0
- package/dist/esm/types/parts.d.ts.map +1 -1
- package/dist/esm/types/parts.js +25 -0
- package/dist/esm/types/parts.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaConversion.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/schemaConversion.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,2BAAwB,CAAC;AAC7E,OAAO,KAAK,EAAE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,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,CAE3F;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,QAAQ,EAAE,CAE7G;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,CAOnF"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { PropertyType } from './PropertyType.js';
|
|
2
|
+
import { uniquePropertyName, conceptPropertyName } from './propertyNaming.js';
|
|
3
|
+
import { findPropertyById } from './propertyTree.js';
|
|
4
|
+
|
|
5
|
+
const CONCEPT_KEYWORD = 'x-concept';
|
|
6
|
+
const KEY_KEYWORD = 'x-key';
|
|
7
|
+
const isComplex = (type) => type === PropertyType.Object || type === PropertyType.ObjectArray;
|
|
8
|
+
const identifier = () => Math.random().toString(36).slice(2, 10) + Math.random().toString(36).slice(2, 6);
|
|
9
|
+
function schemaPropertyType(value) {
|
|
10
|
+
const items = value.items;
|
|
11
|
+
switch (value.type) {
|
|
12
|
+
case 'string':
|
|
13
|
+
if (value.format === 'date')
|
|
14
|
+
return PropertyType.Date;
|
|
15
|
+
if (value.format === 'time')
|
|
16
|
+
return PropertyType.Time;
|
|
17
|
+
return PropertyType.String;
|
|
18
|
+
case 'number':
|
|
19
|
+
case 'integer':
|
|
20
|
+
return PropertyType.Number;
|
|
21
|
+
case 'boolean':
|
|
22
|
+
return PropertyType.Boolean;
|
|
23
|
+
case 'object':
|
|
24
|
+
return PropertyType.Object;
|
|
25
|
+
case 'array':
|
|
26
|
+
if (items?.type === 'number' || items?.type === 'integer')
|
|
27
|
+
return PropertyType.NumberArray;
|
|
28
|
+
if (items?.type === 'object')
|
|
29
|
+
return PropertyType.ObjectArray;
|
|
30
|
+
return PropertyType.StringArray;
|
|
31
|
+
default:
|
|
32
|
+
return PropertyType.String;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function schemaPropertyToProperty(name, value, required) {
|
|
36
|
+
const node = value;
|
|
37
|
+
const type = schemaPropertyType(node);
|
|
38
|
+
const concept = node[CONCEPT_KEYWORD];
|
|
39
|
+
const flags = {
|
|
40
|
+
...(required.has(name) ? { isRequired: true } : {}),
|
|
41
|
+
...(node[KEY_KEYWORD] === true ? { isKey: true } : {}),
|
|
42
|
+
};
|
|
43
|
+
const container = (type === PropertyType.Object ? node : type === PropertyType.ObjectArray ? node.items : undefined);
|
|
44
|
+
if (container?.properties) {
|
|
45
|
+
const childRequired = new Set(container.required ?? []);
|
|
46
|
+
return {
|
|
47
|
+
id: identifier(),
|
|
48
|
+
name,
|
|
49
|
+
type,
|
|
50
|
+
...flags,
|
|
51
|
+
children: Object.entries(container.properties).map(([childName, child]) => schemaPropertyToProperty(childName, child, childRequired)),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
id: identifier(),
|
|
56
|
+
name,
|
|
57
|
+
type,
|
|
58
|
+
...flags,
|
|
59
|
+
...(typeof concept === 'string' && concept.length > 0 ? { concept } : {}),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function jsonSchemaToProperties(schema) {
|
|
63
|
+
if (!schema?.properties)
|
|
64
|
+
return [];
|
|
65
|
+
const required = new Set(schema.required ?? []);
|
|
66
|
+
return Object.entries(schema.properties).map(([name, value]) => schemaPropertyToProperty(name, value, required));
|
|
67
|
+
}
|
|
68
|
+
function primitiveSchema(property) {
|
|
69
|
+
switch (property.type) {
|
|
70
|
+
case PropertyType.Number:
|
|
71
|
+
return { type: 'number' };
|
|
72
|
+
case PropertyType.Boolean:
|
|
73
|
+
return { type: 'boolean' };
|
|
74
|
+
case PropertyType.Date:
|
|
75
|
+
return { type: 'string', format: 'date' };
|
|
76
|
+
case PropertyType.Time:
|
|
77
|
+
return { type: 'string', format: 'time' };
|
|
78
|
+
case PropertyType.Object:
|
|
79
|
+
return { type: 'object', ...objectSchema(property.children ?? []) };
|
|
80
|
+
case PropertyType.StringArray:
|
|
81
|
+
return { type: 'array', items: { type: 'string' } };
|
|
82
|
+
case PropertyType.NumberArray:
|
|
83
|
+
return { type: 'array', items: { type: 'number' } };
|
|
84
|
+
case PropertyType.ObjectArray:
|
|
85
|
+
return { type: 'array', items: { type: 'object', ...objectSchema(property.children ?? []) } };
|
|
86
|
+
default:
|
|
87
|
+
return { type: 'string' };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function propertySchema(property) {
|
|
91
|
+
return {
|
|
92
|
+
...primitiveSchema(property),
|
|
93
|
+
...(property.concept ? { [CONCEPT_KEYWORD]: property.concept } : {}),
|
|
94
|
+
...(property.isKey === true ? { [KEY_KEYWORD]: true } : {}),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function objectSchema(properties) {
|
|
98
|
+
const schemaProperties = {};
|
|
99
|
+
for (const property of properties) {
|
|
100
|
+
schemaProperties[property.name] = propertySchema(property);
|
|
101
|
+
}
|
|
102
|
+
const required = properties.filter(property => property.isRequired === true).map(property => property.name);
|
|
103
|
+
return { properties: schemaProperties, ...(required.length > 0 ? { required } : {}) };
|
|
104
|
+
}
|
|
105
|
+
function propertiesToJsonSchema(properties) {
|
|
106
|
+
return { type: 'object', ...objectSchema(properties) };
|
|
107
|
+
}
|
|
108
|
+
function newProperty(siblings, type, existingCount, concept) {
|
|
109
|
+
const base = isComplex(type) ? 'nested' : 'property';
|
|
110
|
+
const name = concept ? uniquePropertyName(siblings, conceptPropertyName(concept)) : `${base}${existingCount + 1}`;
|
|
111
|
+
return {
|
|
112
|
+
id: identifier(),
|
|
113
|
+
name,
|
|
114
|
+
type,
|
|
115
|
+
...(concept ? { concept } : {}),
|
|
116
|
+
...(isComplex(type) ? { children: [] } : {}),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function addProperty(properties, type, existingCount, concept) {
|
|
120
|
+
return [...properties, newProperty(properties, type, existingCount, concept)];
|
|
121
|
+
}
|
|
122
|
+
function addChildProperty(properties, parentId, type, existingCount, concept) {
|
|
123
|
+
const siblings = findPropertyById(properties, parentId)?.children ?? [];
|
|
124
|
+
const child = newProperty(siblings, type, existingCount, concept);
|
|
125
|
+
const insert = (level) => level.map(property => {
|
|
126
|
+
if (property.id === parentId)
|
|
127
|
+
return { ...property, children: [...(property.children ?? []), child] };
|
|
128
|
+
return property.children ? { ...property, children: insert(property.children) } : property;
|
|
129
|
+
});
|
|
130
|
+
return insert(properties);
|
|
131
|
+
}
|
|
132
|
+
function removeProperty(properties, targetId) {
|
|
133
|
+
return properties
|
|
134
|
+
.filter(property => property.id !== targetId)
|
|
135
|
+
.map(property => property.children ? { ...property, children: removeProperty(property.children, targetId) } : property);
|
|
136
|
+
}
|
|
137
|
+
function updateProperty(properties, targetId, update) {
|
|
138
|
+
return properties.map(property => {
|
|
139
|
+
if (property.id === targetId)
|
|
140
|
+
return update(property);
|
|
141
|
+
return property.children ? { ...property, children: updateProperty(property.children, targetId, update) } : property;
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function renameProperty(properties, targetId, newName) {
|
|
145
|
+
return updateProperty(properties, targetId, property => ({ ...property, name: newName }));
|
|
146
|
+
}
|
|
147
|
+
function changePropertyType(properties, targetId, newType, concept) {
|
|
148
|
+
return updateProperty(properties, targetId, property => ({
|
|
149
|
+
...property,
|
|
150
|
+
type: newType,
|
|
151
|
+
concept,
|
|
152
|
+
children: isComplex(newType) ? (property.children ?? []) : undefined,
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
function toggleRequiredProperty(properties, targetId) {
|
|
156
|
+
return updateProperty(properties, targetId, property => ({ ...property, isRequired: !property.isRequired || undefined }));
|
|
157
|
+
}
|
|
158
|
+
function setRequiredProperty(properties, targetId, isRequired) {
|
|
159
|
+
return updateProperty(properties, targetId, property => ({ ...property, isRequired }));
|
|
160
|
+
}
|
|
161
|
+
function setKeyProperty(properties, targetId) {
|
|
162
|
+
const target = properties.find(property => property.id === targetId);
|
|
163
|
+
return properties.map(property => ({
|
|
164
|
+
...property,
|
|
165
|
+
...(target ? { isKey: property.id === targetId && target.isKey !== true ? true : undefined } : {}),
|
|
166
|
+
...(property.children ? { children: setKeyProperty(property.children, targetId) } : {}),
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export { CONCEPT_KEYWORD, KEY_KEYWORD, addChildProperty, addProperty, changePropertyType, jsonSchemaToProperties, propertiesToJsonSchema, removeProperty, renameProperty, setKeyProperty, setRequiredProperty, toggleRequiredProperty };
|
|
171
|
+
//# sourceMappingURL=schemaConversion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaConversion.js","sources":["../../../../SchemaEditor/Tree/schemaConversion.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { JsonSchema, JsonSchemaProperty } from '../../types/JsonSchema';\nimport type { Property } from './Property';\nimport { PropertyType } from './PropertyType';\nimport { conceptPropertyName, uniquePropertyName } from './propertyNaming';\nimport { findPropertyById } from './propertyTree';\n\n/**\n * The JSON Schema keyword carrying the concept a property is typed as. It annotates the primitive node the\n * concept wraps rather than replacing it, so anything that does not know about concepts — code generation,\n * an export, another tool — still reads a valid schema of the underlying primitive.\n */\nexport const CONCEPT_KEYWORD = 'x-concept';\n\n/**\n * The JSON Schema keyword marking the property that identifies its parent object. Written as `true` on the\n * property; at most one property of an object carries it.\n */\nexport const KEY_KEYWORD = 'x-key';\n\ntype SchemaNode = Record<string, unknown>;\n\nconst isComplex = (type: PropertyType): boolean => type === PropertyType.Object || type === PropertyType.ObjectArray;\n\nconst identifier = (): string => Math.random().toString(36).slice(2, 10) + Math.random().toString(36).slice(2, 6);\n\n// ── JsonSchema → Property[] ─────────────────────────────────────────\n\nfunction schemaPropertyType(value: SchemaNode): PropertyType {\n const items = value.items as { type?: string } | undefined;\n\n switch (value.type) {\n case 'string':\n if (value.format === 'date') return PropertyType.Date;\n if (value.format === 'time') return PropertyType.Time;\n return PropertyType.String;\n case 'number':\n case 'integer':\n return PropertyType.Number;\n case 'boolean':\n return PropertyType.Boolean;\n case 'object':\n return PropertyType.Object;\n case 'array':\n if (items?.type === 'number' || items?.type === 'integer') return PropertyType.NumberArray;\n if (items?.type === 'object') return PropertyType.ObjectArray;\n return PropertyType.StringArray;\n default:\n return PropertyType.String;\n }\n}\n\nfunction schemaPropertyToProperty(name: string, value: JsonSchemaProperty, required: ReadonlySet<string>): Property {\n const node = value as unknown as SchemaNode;\n const type = schemaPropertyType(node);\n const concept = node[CONCEPT_KEYWORD];\n const flags = {\n ...(required.has(name) ? { isRequired: true } : {}),\n ...(node[KEY_KEYWORD] === true ? { isKey: true } : {}),\n };\n\n const container = (type === PropertyType.Object ? node : type === PropertyType.ObjectArray ? node.items : undefined) as\n | { properties?: Record<string, JsonSchemaProperty>; required?: string[] }\n | undefined;\n\n if (container?.properties) {\n const childRequired = new Set(container.required ?? []);\n return {\n id: identifier(),\n name,\n type,\n ...flags,\n children: Object.entries(container.properties).map(([childName, child]) =>\n schemaPropertyToProperty(childName, child, childRequired)),\n };\n }\n\n return {\n id: identifier(),\n name,\n type,\n ...flags,\n ...(typeof concept === 'string' && concept.length > 0 ? { concept } : {}),\n };\n}\n\n/**\n * Converts a JSON Schema object into a property tree. Generates a new id for every property.\n * @param schema The schema to read; `undefined` and schemas without properties give an empty tree.\n * @returns The root properties.\n */\nexport function jsonSchemaToProperties(schema: JsonSchema | undefined): Property[] {\n if (!schema?.properties) return [];\n const required = new Set(schema.required ?? []);\n return Object.entries(schema.properties).map(([name, value]) => schemaPropertyToProperty(name, value, required));\n}\n\n// ── Property[] → JsonSchema ─────────────────────────────────────────\n\nfunction primitiveSchema(property: Property): SchemaNode {\n switch (property.type) {\n case PropertyType.Number:\n return { type: 'number' };\n case PropertyType.Boolean:\n return { type: 'boolean' };\n case PropertyType.Date:\n return { type: 'string', format: 'date' };\n case PropertyType.Time:\n return { type: 'string', format: 'time' };\n case PropertyType.Object:\n return { type: 'object', ...objectSchema(property.children ?? []) };\n case PropertyType.StringArray:\n return { type: 'array', items: { type: 'string' } };\n case PropertyType.NumberArray:\n return { type: 'array', items: { type: 'number' } };\n case PropertyType.ObjectArray:\n return { type: 'array', items: { type: 'object', ...objectSchema(property.children ?? []) } };\n default:\n return { type: 'string' };\n }\n}\n\nfunction propertySchema(property: Property): JsonSchemaProperty {\n return {\n ...primitiveSchema(property),\n ...(property.concept ? { [CONCEPT_KEYWORD]: property.concept } : {}),\n ...(property.isKey === true ? { [KEY_KEYWORD]: true } : {}),\n } as unknown as JsonSchemaProperty;\n}\n\nfunction objectSchema(properties: Property[]): { properties: Record<string, JsonSchemaProperty>; required?: string[] } {\n const schemaProperties: Record<string, JsonSchemaProperty> = {};\n for (const property of properties) {\n schemaProperties[property.name] = propertySchema(property);\n }\n const required = properties.filter(property => property.isRequired === true).map(property => property.name);\n return { properties: schemaProperties, ...(required.length > 0 ? { required } : {}) };\n}\n\n/**\n * Converts a property tree into a JSON Schema object. Empty `required` lists are omitted, and a property\n * typed as a concept or marked as the key carries the `x-concept` and `x-key` keywords.\n * @param properties The root properties.\n * @returns The schema.\n */\nexport function propertiesToJsonSchema(properties: Property[]): JsonSchema {\n return { type: 'object', ...objectSchema(properties) } as JsonSchema;\n}\n\n// ── Pure tree edits ─────────────────────────────────────────────────\n\nfunction newProperty(siblings: Property[], type: PropertyType, existingCount: number, concept?: string): Property {\n const base = isComplex(type) ? 'nested' : 'property';\n const name = concept ? uniquePropertyName(siblings, conceptPropertyName(concept)) : `${base}${existingCount + 1}`;\n\n return {\n id: identifier(),\n name,\n type,\n ...(concept ? { concept } : {}),\n ...(isComplex(type) ? { children: [] } : {}),\n };\n}\n\n/**\n * Appends a property to the root.\n * @param properties The root properties.\n * @param type The type of the new property.\n * @param existingCount The number of properties already in the tree, used to generate the default name; see {@link totalPropertyCount}.\n * @param concept The concept the property is typed as. When given the property is named after it.\n * @returns The new tree.\n */\nexport function addProperty(properties: Property[], type: PropertyType, existingCount: number, concept?: string): Property[] {\n return [...properties, newProperty(properties, type, existingCount, concept)];\n}\n\n/**\n * Appends a property to a nested object or object list.\n * @param properties The root properties.\n * @param parentId The id of the parent property.\n * @param type The type of the new property.\n * @param existingCount The number of properties already in the tree, used to generate the default name.\n * @param concept The concept the property is typed as.\n * @returns The new tree.\n */\nexport function addChildProperty(\n properties: Property[],\n parentId: string,\n type: PropertyType,\n existingCount: number,\n concept?: string,\n): Property[] {\n const siblings = findPropertyById(properties, parentId)?.children ?? [];\n const child = newProperty(siblings, type, existingCount, concept);\n const insert = (level: Property[]): Property[] => level.map(property => {\n if (property.id === parentId) return { ...property, children: [...(property.children ?? []), child] };\n return property.children ? { ...property, children: insert(property.children) } : property;\n });\n return insert(properties);\n}\n\n/**\n * Removes a property, and everything nested under it.\n * @param properties The root properties.\n * @param targetId The id of the property to remove.\n * @returns The new tree.\n */\nexport function removeProperty(properties: Property[], targetId: string): Property[] {\n return properties\n .filter(property => property.id !== targetId)\n .map(property => property.children ? { ...property, children: removeProperty(property.children, targetId) } : property);\n}\n\nfunction updateProperty(properties: Property[], targetId: string, update: (property: Property) => Property): Property[] {\n return properties.map(property => {\n if (property.id === targetId) return update(property);\n return property.children ? { ...property, children: updateProperty(property.children, targetId, update) } : property;\n });\n}\n\n/**\n * Renames a property. Its requiredness travels with it, because both are stored against the property.\n * @param properties The root properties.\n * @param targetId The id of the property to rename.\n * @param newName The new name.\n * @returns The new tree.\n */\nexport function renameProperty(properties: Property[], targetId: string, newName: string): Property[] {\n return updateProperty(properties, targetId, property => ({ ...property, name: newName }));\n}\n\n/**\n * Changes the type of a property. Choosing a plain primitive drops the concept; choosing an object or\n * object list keeps the children, and any other type drops them.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @param newType The new type.\n * @param concept The concept the property is now typed as, if any.\n * @returns The new tree.\n */\nexport function changePropertyType(properties: Property[], targetId: string, newType: PropertyType, concept?: string): Property[] {\n return updateProperty(properties, targetId, property => ({\n ...property,\n type: newType,\n concept,\n children: isComplex(newType) ? (property.children ?? []) : undefined,\n }));\n}\n\n/**\n * Flips whether a property is required.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @returns The new tree.\n */\nexport function toggleRequiredProperty(properties: Property[], targetId: string): Property[] {\n return updateProperty(properties, targetId, property => ({ ...property, isRequired: !property.isRequired || undefined }));\n}\n\n/**\n * Sets whether a property is required. Requiring a nested property does not require its parent.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @param isRequired Whether the property must be present.\n * @returns The new tree.\n */\nexport function setRequiredProperty(properties: Property[], targetId: string, isRequired: boolean): Property[] {\n return updateProperty(properties, targetId, property => ({ ...property, isRequired }));\n}\n\n/**\n * Makes a property the key of its parent object, moving the key when a sibling held it. Choosing the\n * property that already is the key clears it, so an object can also have no key.\n * @param properties The root properties.\n * @param targetId The id of the property.\n * @returns The new tree.\n */\nexport function setKeyProperty(properties: Property[], targetId: string): Property[] {\n const target = properties.find(property => property.id === targetId);\n return properties.map(property => ({\n ...property,\n ...(target ? { isKey: property.id === targetId && target.isKey !== true ? true : undefined } : {}),\n ...(property.children ? { children: setKeyProperty(property.children, targetId) } : {}),\n }));\n}\n"],"names":[],"mappings":";;;;AAcO,MAAM,eAAe,GAAG;AAMxB,MAAM,WAAW,GAAG;AAI3B,MAAM,SAAS,GAAG,CAAC,IAAkB,KAAc,IAAI,KAAK,YAAY,CAAC,MAAM,IAAI,IAAI,KAAK,YAAY,CAAC,WAAW;AAEpH,MAAM,UAAU,GAAG,MAAc,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KA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AAE,CAAC,QAAQ,CAAC,UAAU,IAAI,SAAS,EAAE,CAAC,CAAC;AAC7H;SASgB,mBAAmB,CAAC,UAAsB,EAAE,QAAgB,EAAE,UAAmB,EAAA;AAC7F,IAAA,OAAO,cAAc,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,KAAK,EAAE,GAAG,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;AAC1F;AASM,SAAU,cAAc,CAAC,UAAsB,EAAE,QAAgB,EAAA;AACnE,IAAA,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC;IACpE,OAAO,UAAU,CAAC,GAAG,CAAC,QAAQ,KAAK;AAC/B,QAAA,GAAG,QAAQ;AACX,QAAA,IAAI,MAAM,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,EAAE,CAAC;QAClG,IAAI,QAAQ,CAAC,QAAQ,GAAG,EAAE,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;AAC1F,KAAA,CAAC,CAAC;AACP;;"}
|
|
@@ -10,8 +10,10 @@ export interface TypeCellProps {
|
|
|
10
10
|
onNavigateToProperty: (propertyName: string) => void;
|
|
11
11
|
onNavigateToArrayItems: (propertyName: string) => void;
|
|
12
12
|
onRemoveProperty: (propertyName: string) => void;
|
|
13
|
+
/** When false the remove button is not offered (a protected property). Defaults to `true`. */
|
|
14
|
+
canRemove?: boolean;
|
|
13
15
|
/** Resolved (merged with defaults) SchemaEditor labels for the cell's buttons. */
|
|
14
16
|
labels: SchemaEditorLabels;
|
|
15
17
|
}
|
|
16
|
-
export declare const TypeCell: ({ rowData, isEditMode, typeFormats, onUpdateProperty, onUpdateArrayItemType, onNavigateToProperty, onNavigateToArrayItems, onRemoveProperty, labels, }: TypeCellProps) => string | import("react").JSX.Element;
|
|
18
|
+
export declare const TypeCell: ({ rowData, isEditMode, typeFormats, onUpdateProperty, onUpdateArrayItemType, onNavigateToProperty, onNavigateToArrayItems, onRemoveProperty, canRemove, labels, }: TypeCellProps) => string | import("react").JSX.Element;
|
|
17
19
|
//# sourceMappingURL=TypeCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeCell.d.ts","sourceRoot":"","sources":["../../../SchemaEditor/TypeCell.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAqB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAgB,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,gBAAgB,EAAE,CACd,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,kBAAkB,EAC/B,KAAK,EAAE,OAAO,EACd,iBAAiB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAC9C,IAAI,CAAC;IACV,qBAAqB,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxE,oBAAoB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,sBAAsB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,gBAAgB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,kFAAkF;IAClF,MAAM,EAAE,kBAAkB,CAAC;CAC9B;AAOD,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"TypeCell.d.ts","sourceRoot":"","sources":["../../../SchemaEditor/TypeCell.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAqB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAgB,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,gBAAgB,EAAE,CACd,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,kBAAkB,EAC/B,KAAK,EAAE,OAAO,EACd,iBAAiB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,KAC9C,IAAI,CAAC;IACV,qBAAqB,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxE,oBAAoB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,sBAAsB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACvD,gBAAgB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,8FAA8F;IAC9F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kFAAkF;IAClF,MAAM,EAAE,kBAAkB,CAAC;CAC9B;AAOD,eAAO,MAAM,QAAQ,sKAWlB,aAAa,yCAoMf,CAAC"}
|
|
@@ -8,7 +8,7 @@ const CONTAINER_TYPES = [
|
|
|
8
8
|
{ label: 'array', value: 'array' },
|
|
9
9
|
{ label: 'object', value: 'object' },
|
|
10
10
|
];
|
|
11
|
-
const TypeCell = ({ rowData, isEditMode, typeFormats, onUpdateProperty, onUpdateArrayItemType, onNavigateToProperty, onNavigateToArrayItems, onRemoveProperty, labels, }) => {
|
|
11
|
+
const TypeCell = ({ rowData, isEditMode, typeFormats, onUpdateProperty, onUpdateArrayItemType, onNavigateToProperty, onNavigateToArrayItems, onRemoveProperty, canRemove = true, labels, }) => {
|
|
12
12
|
const DEFAULT_TYPE_OPTIONS = [
|
|
13
13
|
{ label: 'string', value: 'string' },
|
|
14
14
|
{ label: 'integer', value: 'integer' },
|
|
@@ -93,7 +93,7 @@ const TypeCell = ({ rowData, isEditMode, typeFormats, onUpdateProperty, onUpdate
|
|
|
93
93
|
gap: '0.5rem',
|
|
94
94
|
}, children: [rowData.type === 'array' &&
|
|
95
95
|
rowData.items?.type === 'object' &&
|
|
96
|
-
rowData.name && (jsx(Tooltip, { content: labels.navigateToItemDefinition, position: 'top', children: jsx(Button, { variant: 'ghost', size: 'small', icon: jsx(faIcons.FaArrowRight, {}), onClick: () => onNavigateToArrayItems(rowData.name), "aria-label": labels.navigateToItemDefinition }) })), rowData.type === 'object' && rowData.name && (jsx(Tooltip, { content: labels.navigateToProperties, position: 'top', children: jsx(Button, { variant: 'ghost', size: 'small', icon: jsx(faIcons.FaArrowRight, {}), onClick: () => onNavigateToProperty(rowData.name), "aria-label": labels.navigateToProperties }) })), rowData.name && (jsx(Tooltip, { content: labels.deleteProperty, position: 'top', children: jsx(Button, { variant: 'ghost', tone: 'critical', size: 'small', icon: jsx(faIcons.FaTrash, {}), onClick: () => onRemoveProperty(rowData.name), "aria-label": labels.deleteProperty }) }))] })] }));
|
|
96
|
+
rowData.name && (jsx(Tooltip, { content: labels.navigateToItemDefinition, position: 'top', children: jsx(Button, { variant: 'ghost', size: 'small', icon: jsx(faIcons.FaArrowRight, {}), onClick: () => onNavigateToArrayItems(rowData.name), "aria-label": labels.navigateToItemDefinition }) })), rowData.type === 'object' && rowData.name && (jsx(Tooltip, { content: labels.navigateToProperties, position: 'top', children: jsx(Button, { variant: 'ghost', size: 'small', icon: jsx(faIcons.FaArrowRight, {}), onClick: () => onNavigateToProperty(rowData.name), "aria-label": labels.navigateToProperties }) })), rowData.name && canRemove && (jsx(Tooltip, { content: labels.deleteProperty, position: 'top', children: jsx(Button, { variant: 'ghost', tone: 'critical', size: 'small', icon: jsx(faIcons.FaTrash, {}), onClick: () => onRemoveProperty(rowData.name), "aria-label": labels.deleteProperty }) }))] })] }));
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
export { TypeCell };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeCell.js","sources":["../../../SchemaEditor/TypeCell.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Button } from '../Common/Button';\nimport { Dropdown } from '../Dropdown/Dropdown';\nimport { Tooltip } from '../Common/Tooltip';\nimport * as faIcons from 'react-icons/fa6';\nimport { TypeFormat } from '../types/TypeFormat';\nimport { JsonSchemaProperty } from '../types/JsonSchema';\nimport type { SchemaEditorLabels } from './SchemaEditor';\n\nexport interface TypeCellProps {\n rowData: JsonSchemaProperty;\n isEditMode: boolean;\n typeFormats: TypeFormat[];\n onUpdateProperty: (\n oldName: string,\n field: keyof JsonSchemaProperty,\n value: unknown,\n additionalUpdates?: Partial<JsonSchemaProperty>,\n ) => void;\n onUpdateArrayItemType: (propertyName: string, itemType: string) => void;\n onNavigateToProperty: (propertyName: string) => void;\n onNavigateToArrayItems: (propertyName: string) => void;\n onRemoveProperty: (propertyName: string) => void;\n /** Resolved (merged with defaults) SchemaEditor labels for the cell's buttons. */\n labels: SchemaEditorLabels;\n}\n\nconst CONTAINER_TYPES = [\n { label: 'array', value: 'array' },\n { label: 'object', value: 'object' },\n];\n\nexport const TypeCell = ({\n rowData,\n isEditMode,\n typeFormats,\n onUpdateProperty,\n onUpdateArrayItemType,\n onNavigateToProperty,\n onNavigateToArrayItems,\n onRemoveProperty,\n labels,\n}: TypeCellProps) => {\n const DEFAULT_TYPE_OPTIONS = [\n { label: 'string', value: 'string' },\n { label: 'integer', value: 'integer' },\n { label: 'number', value: 'number' },\n { label: 'boolean', value: 'boolean' },\n ];\n\n const formatOptions =\n typeFormats.length > 0\n ? typeFormats.map((tf) => {\n const format = !tf.format || tf.format === '' ? tf.jsonType : tf.format;\n return { label: format, value: format };\n })\n : DEFAULT_TYPE_OPTIONS;\n\n const allTypeOptions = [...formatOptions, ...CONTAINER_TYPES];\n\n const displayValue = rowData.format || rowData.type || 'string';\n const currentValue = rowData.format || rowData.type || 'string';\n\n const handleTypeChange = (\n value: string,\n propertyName: string,\n isArrayItem: boolean = false,\n ) => {\n if (value === 'array' || value === 'object') {\n if (isArrayItem) {\n onUpdateArrayItemType(propertyName, value);\n } else {\n onUpdateProperty(propertyName, 'type', value, { format: undefined });\n }\n } else {\n const typeFormat = typeFormats.find((tf) => {\n const effectiveFormat =\n !tf.format || tf.format === '' ? tf.jsonType : tf.format;\n return effectiveFormat === value;\n });\n\n if (typeFormat) {\n if (isArrayItem) {\n onUpdateArrayItemType(propertyName, typeFormat.jsonType);\n } else {\n if (typeFormat.format && typeFormat.format !== '') {\n onUpdateProperty(propertyName, 'type', typeFormat.jsonType, {\n format: value,\n });\n } else {\n onUpdateProperty(propertyName, 'type', typeFormat.jsonType, {\n format: undefined,\n });\n }\n }\n } else {\n if (isArrayItem) {\n onUpdateArrayItemType(propertyName, value);\n } else {\n onUpdateProperty(propertyName, 'type', value, { format: undefined });\n }\n }\n }\n };\n\n if (!isEditMode) {\n if (rowData.type === 'array') {\n const itemType = rowData.items?.type || 'string';\n const isNavigable = itemType === 'object';\n return (\n <div\n className='cratis:flex cratis:items-center cratis:gap-2 cratis:w-full'\n style={{ height: '100%' }}\n title={\n isNavigable ? 'Click to navigate to item definition' : undefined\n }\n >\n <span>Array of {itemType}</span>\n {isNavigable && (\n <>\n <div style={{ flex: 1 }} />\n <span style={{ display: 'flex', alignItems: 'center' }}>\n <faIcons.FaArrowRight\n style={{\n fontSize: '1rem',\n color: 'var(--cratis-primary-color)',\n }}\n />\n </span>\n </>\n )}\n </div>\n );\n } else if (rowData.type === 'object') {\n return (\n <div\n className='cratis:flex cratis:items-center cratis:gap-2 cratis:w-full'\n style={{ height: '100%' }}\n title='Click to navigate to object properties'\n >\n <span>Object</span>\n <div style={{ flex: 1 }} />\n <span style={{ display: 'flex', alignItems: 'center' }}>\n <faIcons.FaArrowRight\n style={{\n fontSize: '1rem',\n color: 'var(--cratis-primary-color)',\n }}\n />\n </span>\n </div>\n );\n }\n return displayValue;\n }\n\n return (\n <div className='cratis:flex cratis:items-center cratis:gap-2 cratis:w-full' style={{ minHeight: '2.5rem' }}>\n <Dropdown<string>\n aria-label={labels.propertyType}\n value={currentValue}\n options={allTypeOptions}\n optionLabel='label'\n optionValue='value'\n onChange={(value) => handleTypeChange(value, rowData.name || '')}\n className='cratis:flex-1'\n />\n {rowData.type === 'array' && rowData.items && (\n <>\n <span\n style={{\n whiteSpace: 'nowrap',\n display: 'flex',\n alignItems: 'center',\n }}\n >\n of\n </span>\n <Dropdown<string>\n aria-label={labels.arrayItemType}\n value={rowData.items.type || 'string'}\n options={allTypeOptions}\n optionLabel='label'\n optionValue='value'\n onChange={(value) =>\n handleTypeChange(value, rowData.name || '', true)\n }\n className='cratis:flex-1'\n />\n </>\n )}\n <div\n style={{\n marginLeft: 'auto',\n display: 'flex',\n alignItems: 'center',\n gap: '0.5rem',\n }}\n >\n {rowData.type === 'array' &&\n rowData.items?.type === 'object' &&\n rowData.name && (\n <Tooltip content={labels.navigateToItemDefinition} position='top'>\n <Button\n variant='ghost'\n size='small'\n icon={<faIcons.FaArrowRight />}\n onClick={() => onNavigateToArrayItems(rowData.name!)}\n aria-label={labels.navigateToItemDefinition}\n />\n </Tooltip>\n )}\n {rowData.type === 'object' && rowData.name && (\n <Tooltip content={labels.navigateToProperties} position='top'>\n <Button\n variant='ghost'\n size='small'\n icon={<faIcons.FaArrowRight />}\n onClick={() => onNavigateToProperty(rowData.name!)}\n aria-label={labels.navigateToProperties}\n />\n </Tooltip>\n )}\n {rowData.name && (\n <Tooltip content={labels.deleteProperty} position='top'>\n <Button\n variant='ghost'\n tone='critical'\n size='small'\n icon={<faIcons.FaTrash />}\n onClick={() => onRemoveProperty(rowData.name!)}\n aria-label={labels.deleteProperty}\n />\n </Tooltip>\n )}\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;AA6BA,MAAM,eAAe,GAAG;AACpB,IAAA,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;AAClC,IAAA,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;CACvC;AAEM,MAAM,QAAQ,GAAG,CAAC,EACrB,OAAO,EACP,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,GACM,KAAI;AAChB,IAAA,MAAM,oBAAoB,GAAG;AACzB,QAAA,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;AACpC,QAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;AACtC,QAAA,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;AACpC,QAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;KACzC;AAED,IAAA,MAAM,aAAa,GACf,WAAW,CAAC,MAAM,GAAG;UACf,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,KAAI;YACnB,MAAM,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,IAAI,EAAE,CAAC,MAAM,KAAK,EAAE,GAAG,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,MAAM;YACvE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;AAC3C,QAAA,CAAC;UACD,oBAAoB;IAE9B,MAAM,cAAc,GAAG,CAAC,GAAG,aAAa,EAAE,GAAG,eAAe,CAAC;IAE7D,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAA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zDA,GAAA,CAAC,MAAM,EAAA,EACH,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,OAAO,EACZ,IAAI,EAAEA,GAAA,CAAC,OAAO,CAAC,YAAY,EAAA,EAAA,CAAG,EAC9B,OAAO,EAAE,MAAM,oBAAoB,CAAC,OAAO,CAAC,IAAK,CAAC,gBACtC,MAAM,CAAC,oBAAoB,EAAA,CACzC,GACI,CACb,EACA,OAAO,CAAC,IAAI,KACTA,GAAA,CAAC,OAAO,EAAA,EAAC,OAAO,EAAE,MAAM,CAAC,cAAc,EAAE,QAAQ,EAAC,KAAK,EAAA,QAAA,EACnDA,GAAA,CAAC,MAAM,IACH,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,UAAU,EACf,IAAI,EAAC,OAAO,EACZ,IAAI,EAAEA,IAAC,OAAO,CAAC,OAAO,EAAA,EAAA,CAAG,EACzB,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAO,CAAC,IAAK,CAAC,gBAClC,MAAM,CAAC,cAAc,EAAA,CACnC,EAAA,CACI,CACb,CAAA,EAAA,CACC,CAAA,EAAA,CACJ;AAEd;;"}
|
|
1
|
+
{"version":3,"file":"TypeCell.js","sources":["../../../SchemaEditor/TypeCell.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Button } from '../Common/Button';\nimport { Dropdown } from '../Dropdown/Dropdown';\nimport { Tooltip } from '../Common/Tooltip';\nimport * as faIcons from 'react-icons/fa6';\nimport { TypeFormat } from '../types/TypeFormat';\nimport { JsonSchemaProperty } from '../types/JsonSchema';\nimport type { SchemaEditorLabels } from './SchemaEditor';\n\nexport interface TypeCellProps {\n rowData: JsonSchemaProperty;\n isEditMode: boolean;\n typeFormats: TypeFormat[];\n onUpdateProperty: (\n oldName: string,\n field: keyof JsonSchemaProperty,\n value: unknown,\n additionalUpdates?: Partial<JsonSchemaProperty>,\n ) => void;\n onUpdateArrayItemType: (propertyName: string, itemType: string) => void;\n onNavigateToProperty: (propertyName: string) => void;\n onNavigateToArrayItems: (propertyName: string) => void;\n onRemoveProperty: (propertyName: string) => void;\n /** When false the remove button is not offered (a protected property). Defaults to `true`. */\n canRemove?: boolean;\n /** Resolved (merged with defaults) SchemaEditor labels for the cell's buttons. */\n labels: SchemaEditorLabels;\n}\n\nconst CONTAINER_TYPES = [\n { label: 'array', value: 'array' },\n { label: 'object', value: 'object' },\n];\n\nexport const TypeCell = ({\n rowData,\n isEditMode,\n typeFormats,\n onUpdateProperty,\n onUpdateArrayItemType,\n onNavigateToProperty,\n onNavigateToArrayItems,\n onRemoveProperty,\n canRemove = true,\n labels,\n}: TypeCellProps) => {\n const DEFAULT_TYPE_OPTIONS = [\n { label: 'string', value: 'string' },\n { label: 'integer', value: 'integer' },\n { label: 'number', value: 'number' },\n { label: 'boolean', value: 'boolean' },\n ];\n\n const formatOptions =\n typeFormats.length > 0\n ? typeFormats.map((tf) => {\n const format = !tf.format || tf.format === '' ? tf.jsonType : tf.format;\n return { label: format, value: format };\n })\n : DEFAULT_TYPE_OPTIONS;\n\n const allTypeOptions = [...formatOptions, ...CONTAINER_TYPES];\n\n const displayValue = rowData.format || rowData.type || 'string';\n const currentValue = rowData.format || rowData.type || 'string';\n\n const handleTypeChange = (\n value: string,\n propertyName: string,\n isArrayItem: boolean = false,\n ) => {\n if (value === 'array' || value === 'object') {\n if (isArrayItem) {\n onUpdateArrayItemType(propertyName, value);\n } else {\n onUpdateProperty(propertyName, 'type', value, { format: undefined });\n }\n } else {\n const typeFormat = typeFormats.find((tf) => {\n const effectiveFormat =\n !tf.format || tf.format === '' ? tf.jsonType : tf.format;\n return effectiveFormat === value;\n });\n\n if (typeFormat) {\n if (isArrayItem) {\n onUpdateArrayItemType(propertyName, typeFormat.jsonType);\n } else {\n if (typeFormat.format && typeFormat.format !== '') {\n onUpdateProperty(propertyName, 'type', typeFormat.jsonType, {\n format: value,\n });\n } else {\n onUpdateProperty(propertyName, 'type', typeFormat.jsonType, {\n format: undefined,\n });\n }\n }\n } else {\n if (isArrayItem) {\n onUpdateArrayItemType(propertyName, value);\n } else {\n onUpdateProperty(propertyName, 'type', value, { format: undefined });\n }\n }\n }\n };\n\n if (!isEditMode) {\n if (rowData.type === 'array') {\n const itemType = rowData.items?.type || 'string';\n const isNavigable = itemType === 'object';\n return (\n <div\n className='cratis:flex cratis:items-center cratis:gap-2 cratis:w-full'\n style={{ height: '100%' }}\n title={\n isNavigable ? 'Click to navigate to item definition' : undefined\n }\n >\n <span>Array of {itemType}</span>\n {isNavigable && (\n <>\n <div style={{ flex: 1 }} />\n <span style={{ display: 'flex', alignItems: 'center' }}>\n <faIcons.FaArrowRight\n style={{\n fontSize: '1rem',\n color: 'var(--cratis-primary-color)',\n }}\n />\n </span>\n </>\n )}\n </div>\n );\n } else if (rowData.type === 'object') {\n return (\n <div\n className='cratis:flex cratis:items-center cratis:gap-2 cratis:w-full'\n style={{ height: '100%' }}\n title='Click to navigate to object properties'\n >\n <span>Object</span>\n <div style={{ flex: 1 }} />\n <span style={{ display: 'flex', alignItems: 'center' }}>\n <faIcons.FaArrowRight\n style={{\n fontSize: '1rem',\n color: 'var(--cratis-primary-color)',\n }}\n />\n </span>\n </div>\n );\n }\n return displayValue;\n }\n\n return (\n <div className='cratis:flex cratis:items-center cratis:gap-2 cratis:w-full' style={{ minHeight: '2.5rem' }}>\n <Dropdown<string>\n aria-label={labels.propertyType}\n value={currentValue}\n options={allTypeOptions}\n optionLabel='label'\n optionValue='value'\n onChange={(value) => handleTypeChange(value, rowData.name || '')}\n className='cratis:flex-1'\n />\n {rowData.type === 'array' && rowData.items && (\n <>\n <span\n style={{\n whiteSpace: 'nowrap',\n display: 'flex',\n alignItems: 'center',\n }}\n >\n of\n </span>\n <Dropdown<string>\n aria-label={labels.arrayItemType}\n value={rowData.items.type || 'string'}\n options={allTypeOptions}\n optionLabel='label'\n optionValue='value'\n onChange={(value) =>\n handleTypeChange(value, rowData.name || '', true)\n }\n className='cratis:flex-1'\n />\n </>\n )}\n <div\n style={{\n marginLeft: 'auto',\n display: 'flex',\n alignItems: 'center',\n gap: '0.5rem',\n }}\n >\n {rowData.type === 'array' &&\n rowData.items?.type === 'object' &&\n rowData.name && (\n <Tooltip content={labels.navigateToItemDefinition} position='top'>\n <Button\n variant='ghost'\n size='small'\n icon={<faIcons.FaArrowRight />}\n onClick={() => onNavigateToArrayItems(rowData.name!)}\n aria-label={labels.navigateToItemDefinition}\n />\n </Tooltip>\n )}\n {rowData.type === 'object' && rowData.name && (\n <Tooltip content={labels.navigateToProperties} position='top'>\n <Button\n variant='ghost'\n size='small'\n icon={<faIcons.FaArrowRight />}\n onClick={() => onNavigateToProperty(rowData.name!)}\n aria-label={labels.navigateToProperties}\n />\n </Tooltip>\n )}\n {rowData.name && canRemove && (\n <Tooltip content={labels.deleteProperty} position='top'>\n <Button\n variant='ghost'\n tone='critical'\n size='small'\n icon={<faIcons.FaTrash />}\n onClick={() => onRemoveProperty(rowData.name!)}\n aria-label={labels.deleteProperty}\n />\n </Tooltip>\n )}\n </div>\n </div>\n );\n};\n"],"names":["_jsxs","_Fragment","_jsx"],"mappings":";;;;;;AA+BA,MAAM,eAAe,GAAG;AACpB,IAAA,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;AAClC,IAAA,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;CACvC;AAEM,MAAM,QAAQ,GAAG,CAAC,EACrB,OAAO,EACP,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,SAAS,GAAG,IAAI,EAChB,MAAM,GACM,KAAI;AAChB,IAAA,MAAM,oBAAoB,GAAG;AACzB,QAAA,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;AACpC,QAAA,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,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,CAAC,gBAClC,MAAM,CAAC,cAAc,EAAA,CACnC,EAAA,CACI,CACb,CAAA,EAAA,CACC,CAAA,EAAA,CACJ;AAEd;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SchemaEditorLabels } from './SchemaEditorLabels.js';
|
|
2
|
+
/** Every label with its English default, so the editor never has to guard an unset one. */
|
|
3
|
+
export declare const completeSchemaEditorLabels: Required<SchemaEditorLabels>;
|
|
4
|
+
/**
|
|
5
|
+
* English defaults for {@link SchemaEditorLabels}. The labels added for the tree layout and the capabilities are
|
|
6
|
+
* optional on the type, and are present here with their English text.
|
|
7
|
+
*/
|
|
8
|
+
export declare const defaultSchemaEditorLabels: SchemaEditorLabels;
|
|
9
|
+
//# sourceMappingURL=defaultSchemaEditorLabels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultSchemaEditorLabels.d.ts","sourceRoot":"","sources":["../../../SchemaEditor/defaultSchemaEditorLabels.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAE/D,2FAA2F;AAC3F,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,kBAAkB,CA8CnE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,kBAA+C,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const completeSchemaEditorLabels = {
|
|
2
|
+
edit: 'Edit',
|
|
3
|
+
save: 'Save',
|
|
4
|
+
cancel: 'Cancel',
|
|
5
|
+
addProperty: 'Add Property',
|
|
6
|
+
actions: 'Actions',
|
|
7
|
+
navigateBack: 'Navigate back',
|
|
8
|
+
emptyMessage: 'No properties defined',
|
|
9
|
+
navigateToItemDefinition: 'Navigate to item definition',
|
|
10
|
+
navigateToProperties: 'Navigate to object properties',
|
|
11
|
+
propertyName: 'Property name',
|
|
12
|
+
propertyType: 'Property type',
|
|
13
|
+
arrayItemType: 'Array item type',
|
|
14
|
+
deleteProperty: 'Delete property',
|
|
15
|
+
invalidJson: 'The schema must contain valid JSON before it can be edited.',
|
|
16
|
+
schema: 'Schema properties',
|
|
17
|
+
addPropertyTo: (propertyName) => `Add property to ${propertyName}`,
|
|
18
|
+
nestedProperties: (propertyName) => `Properties of ${propertyName}`,
|
|
19
|
+
propertyNameFor: (propertyName) => `Name of ${propertyName}`,
|
|
20
|
+
renameHint: 'Double-click or press F2 to rename',
|
|
21
|
+
deletePropertyFor: (propertyName) => `Delete ${propertyName}`,
|
|
22
|
+
changeType: (propertyName, typeName) => `Change type of ${propertyName}, currently ${typeName}`,
|
|
23
|
+
propertyTypes: 'Property types',
|
|
24
|
+
concepts: 'Concepts',
|
|
25
|
+
noConcepts: 'No concepts defined',
|
|
26
|
+
required: 'Required',
|
|
27
|
+
requiredProperty: (propertyName) => `Required in schema: ${propertyName}`,
|
|
28
|
+
requiredHelp: 'The property must be present in the object. An empty value still counts as present.',
|
|
29
|
+
keyProperty: (propertyName) => `Use ${propertyName} as the key property`,
|
|
30
|
+
setAsKey: 'Use as the key that identifies the object',
|
|
31
|
+
isKey: 'This is the key that identifies the object. Select it again to clear it.',
|
|
32
|
+
keyColumn: 'Key',
|
|
33
|
+
requiredColumn: 'Required',
|
|
34
|
+
protectedProperty: 'This property cannot be renamed or removed.',
|
|
35
|
+
nameRequired: 'Enter a name.',
|
|
36
|
+
nameReserved: (name) => `${name} is reserved and cannot be used as a name.`,
|
|
37
|
+
nameDuplicate: (name) => `Another property is already named ${name}.`,
|
|
38
|
+
typeString: 'Text',
|
|
39
|
+
typeNumber: 'Number',
|
|
40
|
+
typeBoolean: 'Yes or no',
|
|
41
|
+
typeDate: 'Date',
|
|
42
|
+
typeTime: 'Time',
|
|
43
|
+
typeStringArray: 'List of text',
|
|
44
|
+
typeNumberArray: 'List of numbers',
|
|
45
|
+
typeObject: 'Object',
|
|
46
|
+
typeObjectArray: 'List of objects',
|
|
47
|
+
};
|
|
48
|
+
const defaultSchemaEditorLabels = completeSchemaEditorLabels;
|
|
49
|
+
|
|
50
|
+
export { completeSchemaEditorLabels, defaultSchemaEditorLabels };
|
|
51
|
+
//# sourceMappingURL=defaultSchemaEditorLabels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultSchemaEditorLabels.js","sources":["../../../SchemaEditor/defaultSchemaEditorLabels.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { SchemaEditorLabels } from './SchemaEditorLabels';\n\n/** Every label with its English default, so the editor never has to guard an unset one. */\nexport const completeSchemaEditorLabels: Required<SchemaEditorLabels> = {\n edit: 'Edit',\n save: 'Save',\n cancel: 'Cancel',\n addProperty: 'Add Property',\n actions: 'Actions',\n navigateBack: 'Navigate back',\n emptyMessage: 'No properties defined',\n navigateToItemDefinition: 'Navigate to item definition',\n navigateToProperties: 'Navigate to object properties',\n propertyName: 'Property name',\n propertyType: 'Property type',\n arrayItemType: 'Array item type',\n deleteProperty: 'Delete property',\n invalidJson: 'The schema must contain valid JSON before it can be edited.',\n schema: 'Schema properties',\n addPropertyTo: (propertyName) => `Add property to ${propertyName}`,\n nestedProperties: (propertyName) => `Properties of ${propertyName}`,\n propertyNameFor: (propertyName) => `Name of ${propertyName}`,\n renameHint: 'Double-click or press F2 to rename',\n deletePropertyFor: (propertyName) => `Delete ${propertyName}`,\n changeType: (propertyName, typeName) => `Change type of ${propertyName}, currently ${typeName}`,\n propertyTypes: 'Property types',\n concepts: 'Concepts',\n noConcepts: 'No concepts defined',\n required: 'Required',\n requiredProperty: (propertyName) => `Required in schema: ${propertyName}`,\n requiredHelp: 'The property must be present in the object. An empty value still counts as present.',\n keyProperty: (propertyName) => `Use ${propertyName} as the key property`,\n setAsKey: 'Use as the key that identifies the object',\n isKey: 'This is the key that identifies the object. Select it again to clear it.',\n keyColumn: 'Key',\n requiredColumn: 'Required',\n protectedProperty: 'This property cannot be renamed or removed.',\n nameRequired: 'Enter a name.',\n nameReserved: (name) => `${name} is reserved and cannot be used as a name.`,\n nameDuplicate: (name) => `Another property is already named ${name}.`,\n typeString: 'Text',\n typeNumber: 'Number',\n typeBoolean: 'Yes or no',\n typeDate: 'Date',\n typeTime: 'Time',\n typeStringArray: 'List of text',\n typeNumberArray: 'List of numbers',\n typeObject: 'Object',\n typeObjectArray: 'List of objects',\n};\n\n/**\n * English defaults for {@link SchemaEditorLabels}. The labels added for the tree layout and the capabilities are\n * optional on the type, and are present here with their English text.\n */\nexport const defaultSchemaEditorLabels: SchemaEditorLabels = completeSchemaEditorLabels;\n"],"names":[],"mappings":"AAMO,MAAM,0BAA0B,GAAiC;AACpE,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,MAAM,EAAE,QAAQ;AAChB,IAAA,WAAW,EAAE,cAAc;AAC3B,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,YAAY,EAAE,eAAe;AAC7B,IAAA,YAAY,EAAE,uBAAuB;AACrC,IAAA,wBAAwB,EAAE,6BAA6B;AACvD,IAAA,oBAAoB,EAAE,+BAA+B;AACrD,IAAA,YAAY,EAAE,eAAe;AAC7B,IAAA,YAAY,EAAE,eAAe;AAC7B,IAAA,aAAa,EAAE,iBAAiB;AAChC,IAAA,cAAc,EAAE,iBAAiB;AACjC,IAAA,WAAW,EAAE,6DAA6D;AAC1E,IAAA,MAAM,EAAE,mBAAmB;IAC3B,aAAa,EAAE,CAAC,YAAY,KAAK,CAAA,gBAAA,EAAmB,YAAY,CAAA,CAAE;IAClE,gBAAgB,EAAE,CAAC,YAAY,KAAK,CAAA,cAAA,EAAiB,YAAY,CAAA,CAAE;IACnE,eAAe,EAAE,CAAC,YAAY,KAAK,CAAA,QAAA,EAAW,YAAY,CAAA,CAAE;AAC5D,IAAA,UAAU,EAAE,oCAAoC;IAChD,iBAAiB,EAAE,CAAC,YAAY,KAAK,CAAA,OAAA,EAAU,YA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
|
+
export type { SchemaEditorParts, SchemaEditorPartAttributes, SchemaEditorMenuPartAttributes } from './Tree/SchemaEditorParts.js';
|
|
4
|
+
export type { SchemaPropertyContext } from './Tree/SchemaPropertyContext.js';
|
|
5
|
+
export type { SchemaPropertyRowState } from './Tree/SchemaPropertyRowState.js';
|
|
6
|
+
export { PropertyConceptsProvider, usePropertyConcepts } from './Tree/PropertyConceptsContext.js';
|
|
7
|
+
export type { PropertyConceptsProviderProps } from './Tree/PropertyConceptsContext.js';
|
|
8
|
+
export type { Property } from './Tree/Property.js';
|
|
9
|
+
export { PropertyType } from './Tree/PropertyType.js';
|
|
10
|
+
export type { PropertyConcept } from './Tree/PropertyConcept.js';
|
|
11
|
+
export { PropertyNameProblem, conceptPropertyName, findPropertyNameProblem, uniquePropertyName, } from './Tree/propertyNaming.js';
|
|
12
|
+
export { findPropertyById, findPropertyByName, findSiblingProperties, totalPropertyCount } from './Tree/propertyTree.js';
|
|
13
|
+
export { CONCEPT_KEYWORD, KEY_KEYWORD, addChildProperty, addProperty, changePropertyType, jsonSchemaToProperties, propertiesToJsonSchema, removeProperty, renameProperty, setKeyProperty, setRequiredProperty, toggleRequiredProperty, } from './Tree/schemaConversion.js';
|
|
2
14
|
export * from '../types/JsonSchema.js';
|
|
3
15
|
export * from '../types/TypeFormat.js';
|
|
4
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../SchemaEditor/index.ts"],"names":[],"mappings":"AAGA,cAAc,mBAAgB,CAAC;AAC/B,cAAc,wBAAqB,CAAC;AACpC,cAAc,wBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../SchemaEditor/index.ts"],"names":[],"mappings":"AAGA,cAAc,mBAAgB,CAAC;AAC/B,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAC/D,YAAY,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,8BAA8B,EAAE,MAAM,6BAA0B,CAAC;AAC9H,YAAY,EAAE,qBAAqB,EAAE,MAAM,iCAA8B,CAAC;AAC1E,YAAY,EAAE,sBAAsB,EAAE,MAAM,kCAA+B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,mCAAgC,CAAC;AAC/F,YAAY,EAAE,6BAA6B,EAAE,MAAM,mCAAgC,CAAC;AACpF,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAqB,CAAC;AACnD,YAAY,EAAE,eAAe,EAAE,MAAM,2BAAwB,CAAC;AAC9D,OAAO,EACH,mBAAmB,EACnB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACrB,MAAM,0BAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,wBAAqB,CAAC;AACtH,OAAO,EACH,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,sBAAsB,GACzB,MAAM,4BAAyB,CAAC;AACjC,cAAc,wBAAqB,CAAC;AACpC,cAAc,wBAAqB,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
export { SchemaEditor
|
|
1
|
+
export { SchemaEditor } from './SchemaEditor.js';
|
|
2
|
+
export { PropertyConceptsProvider, usePropertyConcepts } from './Tree/PropertyConceptsContext.js';
|
|
3
|
+
export { PropertyType } from './Tree/PropertyType.js';
|
|
4
|
+
export { PropertyNameProblem, conceptPropertyName, findPropertyNameProblem, uniquePropertyName } from './Tree/propertyNaming.js';
|
|
5
|
+
export { findPropertyById, findPropertyByName, findSiblingProperties, totalPropertyCount } from './Tree/propertyTree.js';
|
|
6
|
+
export { CONCEPT_KEYWORD, KEY_KEYWORD, addChildProperty, addProperty, changePropertyType, jsonSchemaToProperties, propertiesToJsonSchema, removeProperty, renameProperty, setKeyProperty, setRequiredProperty, toggleRequiredProperty } from './Tree/schemaConversion.js';
|
|
2
7
|
export { DEFAULT_TYPE_FORMATS } from '../types/TypeFormat.js';
|
|
8
|
+
export { defaultSchemaEditorLabels } from './defaultSchemaEditorLabels.js';
|
|
3
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SchemaEditorLabels } from './SchemaEditorLabels.js';
|
|
2
|
+
/** Merges the host's labels over the English defaults, ignoring any that are `undefined`. */
|
|
3
|
+
export declare const resolveSchemaEditorLabels: (labels: Partial<SchemaEditorLabels> | undefined) => Required<SchemaEditorLabels>;
|
|
4
|
+
//# sourceMappingURL=resolveSchemaEditorLabels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSchemaEditorLabels.d.ts","sourceRoot":"","sources":["../../../SchemaEditor/resolveSchemaEditorLabels.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAsB,CAAC;AAE/D,6FAA6F;AAC7F,eAAO,MAAM,yBAAyB,WAAY,OAAO,CAAC,kBAAkB,CAAC,GAAG,SAAS,KAAG,QAAQ,CAAC,kBAAkB,CAMtH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { completeSchemaEditorLabels } from './defaultSchemaEditorLabels.js';
|
|
2
|
+
|
|
3
|
+
const resolveSchemaEditorLabels = (labels) => {
|
|
4
|
+
const resolved = { ...completeSchemaEditorLabels };
|
|
5
|
+
for (const [key, value] of Object.entries(labels ?? {})) {
|
|
6
|
+
if (value !== undefined)
|
|
7
|
+
resolved[key] = value;
|
|
8
|
+
}
|
|
9
|
+
return resolved;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { resolveSchemaEditorLabels };
|
|
13
|
+
//# sourceMappingURL=resolveSchemaEditorLabels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveSchemaEditorLabels.js","sources":["../../../SchemaEditor/resolveSchemaEditorLabels.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { completeSchemaEditorLabels } from './defaultSchemaEditorLabels';\nimport type { SchemaEditorLabels } from './SchemaEditorLabels';\n\n/** Merges the host's labels over the English defaults, ignoring any that are `undefined`. */\nexport const resolveSchemaEditorLabels = (labels: Partial<SchemaEditorLabels> | undefined): Required<SchemaEditorLabels> => {\n const resolved: Record<string, unknown> = { ...completeSchemaEditorLabels };\n for (const [key, value] of Object.entries(labels ?? {})) {\n if (value !== undefined) resolved[key] = value;\n }\n return resolved as unknown as Required<SchemaEditorLabels>;\n};\n"],"names":[],"mappings":";;AAOO,MAAM,yBAAyB,GAAG,CAAC,MAA+C,KAAkC;AACvH,IAAA,MAAM,QAAQ,GAA4B,EAAE,GAAG,0BAA0B,EAAE;AAC3E,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE;QACrD,IAAI,KAAK,KAAK,SAAS;AAAE,YAAA,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK;IAClD;AACA,IAAA,OAAO,QAAmD;AAC9D;;"}
|