@cratis/components 4.27.0 → 4.29.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/SchemaEditor.d.ts +4 -1
- package/dist/esm/SchemaEditor/SchemaEditor.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditor.js +3 -1
- package/dist/esm/SchemaEditor/SchemaEditor.js.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditorLabels.d.ts +6 -0
- package/dist/esm/SchemaEditor/SchemaEditorLabels.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/SchemaEditorLabels.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/GeneratedToggle.d.ts +11 -0
- package/dist/esm/SchemaEditor/Tree/GeneratedToggle.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/GeneratedToggle.js +24 -0
- package/dist/esm/SchemaEditor/Tree/GeneratedToggle.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/KeywordFamily.d.ts +14 -0
- package/dist/esm/SchemaEditor/Tree/KeywordFamily.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/KeywordFamily.js +11 -0
- package/dist/esm/SchemaEditor/Tree/KeywordFamily.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/Property.d.ts +14 -0
- package/dist/esm/SchemaEditor/Tree/Property.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/Property.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/SchemaEditorContext.d.ts +2 -0
- package/dist/esm/SchemaEditor/Tree/SchemaEditorContext.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/SchemaEditorContext.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/SchemaEditorParts.d.ts +2 -0
- package/dist/esm/SchemaEditor/Tree/SchemaEditorParts.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/SchemaEditorParts.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.d.ts +19 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.js +15 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOriginalShape.d.ts +21 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOriginalShape.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOriginalShape.js +4 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOriginalShape.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRow.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRow.js +2 -2
- package/dist/esm/SchemaEditor/Tree/SchemaPropertyRow.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/TreeSchemaEditor.d.ts +8 -1
- package/dist/esm/SchemaEditor/Tree/TreeSchemaEditor.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/TreeSchemaEditor.js +15 -11
- package/dist/esm/SchemaEditor/Tree/TreeSchemaEditor.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/keywordApplicability.d.ts +41 -0
- package/dist/esm/SchemaEditor/Tree/keywordApplicability.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/keywordApplicability.js +56 -0
- package/dist/esm/SchemaEditor/Tree/keywordApplicability.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/originalShape.d.ts +30 -0
- package/dist/esm/SchemaEditor/Tree/originalShape.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/originalShape.js +70 -0
- package/dist/esm/SchemaEditor/Tree/originalShape.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/schemaConversion.d.ts +17 -3
- package/dist/esm/SchemaEditor/Tree/schemaConversion.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/schemaConversion.js +111 -55
- package/dist/esm/SchemaEditor/Tree/schemaConversion.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.d.ts +5 -0
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.js +10 -0
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/schemaPropertyType.d.ts +11 -0
- package/dist/esm/SchemaEditor/Tree/schemaPropertyType.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/schemaPropertyType.js +31 -0
- package/dist/esm/SchemaEditor/Tree/schemaPropertyType.js.map +1 -0
- package/dist/esm/SchemaEditor/Tree/standardKeywords.d.ts +18 -0
- package/dist/esm/SchemaEditor/Tree/standardKeywords.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/standardKeywords.js +22 -0
- package/dist/esm/SchemaEditor/Tree/standardKeywords.js.map +1 -0
- package/dist/esm/SchemaEditor/defaultSchemaEditorLabels.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/defaultSchemaEditorLabels.js +3 -0
- package/dist/esm/SchemaEditor/defaultSchemaEditorLabels.js.map +1 -1
- package/dist/esm/SchemaEditor/index.d.ts +1 -1
- package/dist/esm/SchemaEditor/index.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/index.js +1 -1
- package/dist/esm/SchemaEditor/schemaHelpers.d.ts +9 -0
- package/dist/esm/SchemaEditor/schemaHelpers.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/schemaHelpers.js +20 -1
- package/dist/esm/SchemaEditor/schemaHelpers.js.map +1 -1
- package/dist/esm/styles.SchemaEditor.css +7 -10
- package/dist/esm/styles.css +7 -10
- package/dist/esm/types/parts.d.ts +2 -1
- package/dist/esm/types/parts.d.ts.map +1 -1
- package/dist/esm/types/parts.js +2 -1
- package/dist/esm/types/parts.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var KeywordFamily;
|
|
2
|
+
(function (KeywordFamily) {
|
|
3
|
+
KeywordFamily["None"] = "none";
|
|
4
|
+
KeywordFamily["String"] = "string";
|
|
5
|
+
KeywordFamily["Number"] = "number";
|
|
6
|
+
KeywordFamily["Array"] = "array";
|
|
7
|
+
KeywordFamily["Object"] = "object";
|
|
8
|
+
})(KeywordFamily || (KeywordFamily = {}));
|
|
9
|
+
|
|
10
|
+
export { KeywordFamily };
|
|
11
|
+
//# sourceMappingURL=KeywordFamily.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KeywordFamily.js","sources":["../../../../SchemaEditor/Tree/KeywordFamily.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\n/** A group of JSON Schema keywords that only constrain values of one kind of type. */\nexport enum KeywordFamily {\n /** Types without constraint keywords of their own, such as booleans. */\n None = 'none',\n\n /** String values, including the date and time types. */\n String = 'string',\n\n /** Number values. */\n Number = 'number',\n\n /** Array values, whatever the item kind. */\n Array = 'array',\n\n /** Object values. */\n Object = 'object',\n}\n"],"names":[],"mappings":"IAIY;AAAZ,CAAA,UAAY,aAAa,EAAA;AAErB,IAAA,aAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AAGb,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AAGjB,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AAGjB,IAAA,aAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AAGf,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACrB,CAAC,EAfW,aAAa,KAAb,aAAa,GAAA,EAAA,CAAA,CAAA;;"}
|
|
@@ -24,6 +24,20 @@ export interface Property {
|
|
|
24
24
|
children?: Property[];
|
|
25
25
|
/** Whether the property identifies its parent object. At most one property of an object is the key. */
|
|
26
26
|
isKey?: boolean;
|
|
27
|
+
/** Whether the value is generated when the command runs rather than entered. */
|
|
28
|
+
isGenerated?: boolean;
|
|
29
|
+
/** Other `x-` keywords on this property's schema node, preserved verbatim. */
|
|
30
|
+
vendorKeywords?: Readonly<Record<string, unknown>>;
|
|
31
|
+
/** `x-` keywords on an array's items node, preserved verbatim. */
|
|
32
|
+
itemVendorKeywords?: Readonly<Record<string, unknown>>;
|
|
33
|
+
/**
|
|
34
|
+
* Standard JSON Schema keywords on this property's schema node that the editor does not model, such as
|
|
35
|
+
* `description`, `default`, `enum` or `minLength`, preserved verbatim. They are omitted when there are
|
|
36
|
+
* none. Changing the type drops those that no longer apply.
|
|
37
|
+
*/
|
|
38
|
+
schemaKeywords?: Readonly<Record<string, unknown>>;
|
|
39
|
+
/** Standard JSON Schema keywords on an array's items node that the editor does not model, preserved verbatim. */
|
|
40
|
+
itemSchemaKeywords?: Readonly<Record<string, unknown>>;
|
|
27
41
|
/** Whether the property must be present in its parent object (membership in the JSON Schema `required` list). */
|
|
28
42
|
isRequired?: boolean;
|
|
29
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Property.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/Property.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAC;IAEb,4CAA4C;IAC5C,IAAI,EAAE,YAAY,CAAC;IAEnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IAEtB,uGAAuG;IACvG,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,iHAAiH;IACjH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB"}
|
|
1
|
+
{"version":3,"file":"Property.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/Property.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAC;IAEb,4CAA4C;IAC5C,IAAI,EAAE,YAAY,CAAC;IAEnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IAEtB,uGAAuG;IACvG,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,gFAAgF;IAChF,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEnD,kEAAkE;IAClE,kBAAkB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEvD;;;;OAIG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEnD,iHAAiH;IACjH,kBAAkB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEvD,iHAAiH;IACjH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Property.js","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/Property.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 { PropertyType } from './PropertyType';\n\n/**\n * One editable property of a schema. The editor works on a tree of these and converts to and from\n * JSON Schema at its boundary.\n */\nexport interface Property {\n /**\n * Identifies the property for the lifetime of an editor session. Ids are generated when a schema is\n * converted into a tree, so they are not stable across sessions: persist the {@link Property.name},\n * not the id.\n */\n id: string;\n\n /** The name of the property; the key of the property in the JSON Schema object. */\n name: string;\n\n /** The kind of value the property holds. */\n type: PropertyType;\n\n /**\n * The name of the concept this property is typed as, when it is typed as one rather than as a bare\n * primitive. The concept wraps the primitive in {@link Property.type}, so everything that reasons about\n * the type keeps working; the name is carried alongside because that is what the domain calls the value.\n */\n concept?: string;\n\n /** The properties of a nested object, or of each item of an object list. */\n children?: Property[];\n\n /** Whether the property identifies its parent object. At most one property of an object is the key. */\n isKey?: boolean;\n\n /** Whether the property must be present in its parent object (membership in the JSON Schema `required` list). */\n isRequired?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Property.js","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/Property.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 { PropertyType } from './PropertyType';\n\n/**\n * One editable property of a schema. The editor works on a tree of these and converts to and from\n * JSON Schema at its boundary.\n */\nexport interface Property {\n /**\n * Identifies the property for the lifetime of an editor session. Ids are generated when a schema is\n * converted into a tree, so they are not stable across sessions: persist the {@link Property.name},\n * not the id.\n */\n id: string;\n\n /** The name of the property; the key of the property in the JSON Schema object. */\n name: string;\n\n /** The kind of value the property holds. */\n type: PropertyType;\n\n /**\n * The name of the concept this property is typed as, when it is typed as one rather than as a bare\n * primitive. The concept wraps the primitive in {@link Property.type}, so everything that reasons about\n * the type keeps working; the name is carried alongside because that is what the domain calls the value.\n */\n concept?: string;\n\n /** The properties of a nested object, or of each item of an object list. */\n children?: Property[];\n\n /** Whether the property identifies its parent object. At most one property of an object is the key. */\n isKey?: boolean;\n\n /** Whether the value is generated when the command runs rather than entered. */\n isGenerated?: boolean;\n\n /** Other `x-` keywords on this property's schema node, preserved verbatim. */\n vendorKeywords?: Readonly<Record<string, unknown>>;\n\n /** `x-` keywords on an array's items node, preserved verbatim. */\n itemVendorKeywords?: Readonly<Record<string, unknown>>;\n\n /**\n * Standard JSON Schema keywords on this property's schema node that the editor does not model, such as\n * `description`, `default`, `enum` or `minLength`, preserved verbatim. They are omitted when there are\n * none. Changing the type drops those that no longer apply.\n */\n schemaKeywords?: Readonly<Record<string, unknown>>;\n\n /** Standard JSON Schema keywords on an array's items node that the editor does not model, preserved verbatim. */\n itemSchemaKeywords?: Readonly<Record<string, unknown>>;\n\n /** Whether the property must be present in its parent object (membership in the JSON Schema `required` list). */\n isRequired?: boolean;\n}\n"]}
|
|
@@ -13,6 +13,7 @@ export interface SchemaEditorOperations {
|
|
|
13
13
|
rename?: (propertyId: string, name: string) => void;
|
|
14
14
|
changeType?: (propertyId: string, type: PropertyType, concept?: string) => void;
|
|
15
15
|
setKey?: (propertyId: string) => void;
|
|
16
|
+
setGenerated?: (propertyId: string, isGenerated: boolean) => void;
|
|
16
17
|
setRequired?: (propertyId: string, isRequired: boolean) => void;
|
|
17
18
|
}
|
|
18
19
|
/** Everything the rows of an editor share. Internal: hosts configure the editor through its props. */
|
|
@@ -26,6 +27,7 @@ export interface SchemaEditorContextValue {
|
|
|
26
27
|
selectedPropertyId: string | null | undefined;
|
|
27
28
|
onPropertyClick: ((propertyId: string) => void) | undefined;
|
|
28
29
|
isKeyAllowed: (property: Property, context: SchemaPropertyContext) => boolean;
|
|
30
|
+
isGeneratedAllowed: (property: Property, context: SchemaPropertyContext) => boolean;
|
|
29
31
|
isRequiredAllowed: boolean;
|
|
30
32
|
isProtected: (property: Property) => boolean;
|
|
31
33
|
validateName: ((name: string, property: Property, siblings: Property[]) => string | undefined) | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaEditorContext.d.ts","sourceRoot":"","sources":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AAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;IAC/F,eAAe,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;IACjG,aAAa,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;IAC/F,eAAe,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,SAAS,KAAK,SAAS,CAAC,GAAG,SAAS,CAAC;CAC7H;AAED,6DAA6D;AAC7D,eAAO,MAAM,mBAAmB,+DAAiE,CAAC;AAElG,kFAAkF;AAClF,eAAO,MAAM,sBAAsB,QAAO,wBAIzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaEditorContext.js","sources":["../../../../SchemaEditor/Tree/SchemaEditorContext.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 { createContext, useContext, type ReactNode } from 'react';\nimport type { Property } from './Property';\nimport type { PropertyConcept } from './PropertyConcept';\nimport type { PropertyType } from './PropertyType';\nimport type { SchemaEditorLabels } from '../SchemaEditorLabels';\nimport type { SchemaEditorParts } from './SchemaEditorParts';\nimport type { SchemaPropertyContext } from './SchemaPropertyContext';\nimport type { SchemaPropertyRowState } from './SchemaPropertyRowState';\n\n/** The edits the editor can currently perform. An edit that is `undefined` is not offered. */\nexport interface SchemaEditorOperations {\n addChild?: (parentId: string, type: PropertyType, concept?: string) => void;\n remove?: (propertyId: string) => void;\n rename?: (propertyId: string, name: string) => void;\n changeType?: (propertyId: string, type: PropertyType, concept?: string) => void;\n setKey?: (propertyId: string) => void;\n setRequired?: (propertyId: string, isRequired: boolean) => void;\n}\n\n/** Everything the rows of an editor share. Internal: hosts configure the editor through its props. */\nexport interface SchemaEditorContextValue {\n labels: Required<SchemaEditorLabels>;\n parts: SchemaEditorParts | undefined;\n properties: Property[];\n concepts: PropertyConcept[] | undefined;\n readOnly: boolean;\n operations: SchemaEditorOperations;\n selectedPropertyId: string | null | undefined;\n onPropertyClick: ((propertyId: string) => void) | undefined;\n isKeyAllowed: (property: Property, context: SchemaPropertyContext) => boolean;\n isRequiredAllowed: boolean;\n isProtected: (property: Property) => boolean;\n validateName: ((name: string, property: Property, siblings: Property[]) => string | undefined) | undefined;\n getRowState: ((property: Property, context: SchemaPropertyContext) => SchemaPropertyRowState | undefined) | undefined;\n renderLeading: ((property: Property, context: SchemaPropertyContext) => ReactNode) | undefined;\n renderAccessory: ((property: Property, context: SchemaPropertyContext) => ReactNode) | undefined;\n renderDetails: ((property: Property, context: SchemaPropertyContext) => ReactNode) | undefined;\n renderTypeBadge: ((property: Property, context: SchemaPropertyContext, defaultBadge: ReactNode) => ReactNode) | undefined;\n}\n\n/** Carries the editor's shared configuration to its rows. */\nexport const SchemaEditorContext = createContext<SchemaEditorContextValue | undefined>(undefined);\n\n/** Reads the editor's shared configuration. Rows only render inside an editor. */\nexport const useSchemaEditorContext = (): SchemaEditorContextValue => {\n const value = useContext(SchemaEditorContext);\n if (!value) throw new Error('A schema property row must be rendered inside a SchemaEditor.');\n return value;\n};\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"SchemaEditorContext.js","sources":["../../../../SchemaEditor/Tree/SchemaEditorContext.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 { createContext, useContext, type ReactNode } from 'react';\nimport type { Property } from './Property';\nimport type { PropertyConcept } from './PropertyConcept';\nimport type { PropertyType } from './PropertyType';\nimport type { SchemaEditorLabels } from '../SchemaEditorLabels';\nimport type { SchemaEditorParts } from './SchemaEditorParts';\nimport type { SchemaPropertyContext } from './SchemaPropertyContext';\nimport type { SchemaPropertyRowState } from './SchemaPropertyRowState';\n\n/** The edits the editor can currently perform. An edit that is `undefined` is not offered. */\nexport interface SchemaEditorOperations {\n addChild?: (parentId: string, type: PropertyType, concept?: string) => void;\n remove?: (propertyId: string) => void;\n rename?: (propertyId: string, name: string) => void;\n changeType?: (propertyId: string, type: PropertyType, concept?: string) => void;\n setKey?: (propertyId: string) => void;\n setGenerated?: (propertyId: string, isGenerated: boolean) => void;\n setRequired?: (propertyId: string, isRequired: boolean) => void;\n}\n\n/** Everything the rows of an editor share. Internal: hosts configure the editor through its props. */\nexport interface SchemaEditorContextValue {\n labels: Required<SchemaEditorLabels>;\n parts: SchemaEditorParts | undefined;\n properties: Property[];\n concepts: PropertyConcept[] | undefined;\n readOnly: boolean;\n operations: SchemaEditorOperations;\n selectedPropertyId: string | null | undefined;\n onPropertyClick: ((propertyId: string) => void) | undefined;\n isKeyAllowed: (property: Property, context: SchemaPropertyContext) => boolean;\n isGeneratedAllowed: (property: Property, context: SchemaPropertyContext) => boolean;\n isRequiredAllowed: boolean;\n isProtected: (property: Property) => boolean;\n validateName: ((name: string, property: Property, siblings: Property[]) => string | undefined) | undefined;\n getRowState: ((property: Property, context: SchemaPropertyContext) => SchemaPropertyRowState | undefined) | undefined;\n renderLeading: ((property: Property, context: SchemaPropertyContext) => ReactNode) | undefined;\n renderAccessory: ((property: Property, context: SchemaPropertyContext) => ReactNode) | undefined;\n renderDetails: ((property: Property, context: SchemaPropertyContext) => ReactNode) | undefined;\n renderTypeBadge: ((property: Property, context: SchemaPropertyContext, defaultBadge: ReactNode) => ReactNode) | undefined;\n}\n\n/** Carries the editor's shared configuration to its rows. */\nexport const SchemaEditorContext = createContext<SchemaEditorContextValue | undefined>(undefined);\n\n/** Reads the editor's shared configuration. Rows only render inside an editor. */\nexport const useSchemaEditorContext = (): SchemaEditorContextValue => {\n const value = useContext(SchemaEditorContext);\n if (!value) throw new Error('A schema property row must be rendered inside a SchemaEditor.');\n return value;\n};\n"],"names":[],"mappings":";;MA8Ca,mBAAmB,GAAG,aAAa,CAAuC,SAAS;AAGzF,MAAM,sBAAsB,GAAG,MAA+B;AACjE,IAAA,MAAM,KAAK,GAAG,UAAU,CAAC,mBAAmB,CAAC;AAC7C,IAAA,IAAI,CAAC,KAAK;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC;AAC5F,IAAA,OAAO,KAAK;AAChB;;"}
|
|
@@ -40,6 +40,8 @@ export interface SchemaEditorParts {
|
|
|
40
40
|
required?: SchemaEditorPartAttributes<HTMLLabelElement>;
|
|
41
41
|
/** The key toggle. Carries `data-pressed` while the property is the key. */
|
|
42
42
|
key?: ButtonHTMLAttributes<HTMLButtonElement>;
|
|
43
|
+
/** The Generated toggle, or non-interactive marker when editing is unavailable. Carries `data-pressed` while the value is generated. */
|
|
44
|
+
generated?: ButtonHTMLAttributes<HTMLButtonElement>;
|
|
43
45
|
/** The wrapper of the host's accessory slot. */
|
|
44
46
|
accessory?: SchemaEditorPartAttributes<HTMLSpanElement>;
|
|
45
47
|
/** The button that removes a property. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaEditorParts.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/SchemaEditorParts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAEvF,0FAA0F;AAC1F,MAAM,MAAM,0BAA0B,CAAC,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAAC,GAAG;IAC1E,CAAC,SAAS,EAAE,QAAQ,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACxE,CAAC;AAEF,qFAAqF;AACrF,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG;IACpG,CAAC,SAAS,EAAE,Q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,CAAC,EAAE,0BAA0B,CAAC,cAAc,CAAC,CAAC;IAErD,0EAA0E;IAC1E,GAAG,CAAC,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IAE9C,mDAAmD;IACnD,KAAK,CAAC,EAAE,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;IAEzD,4BAA4B;IAC5B,OAAO,CAAC,EAAE,0BAA0B,CAAC,oBAAoB,CAAC,CAAC;IAE3D,iEAAiE;IACjE,MAAM,CAAC,EAAE,0BAA0B,CAAC,cAAc,CAAC,CAAC;CACvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaEditorParts.js","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/SchemaEditorParts.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 { ButtonHTMLAttributes, HTMLAttributes, InputHTMLAttributes } from 'react';\n\n/** Attributes passed through to one part of the editor, including `data-*` attributes. */\nexport type SchemaEditorPartAttributes<TElement> = HTMLAttributes<TElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\n/** Styling attributes passed to a part the editor renders through a popover menu. */\nexport type SchemaEditorMenuPartAttributes = Pick<HTMLAttributes<HTMLElement>, 'className' | 'style'> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\n/**\n * Stable Cratis-owned parts for styling a {@link SchemaEditor}. Each is marked with a matching\n * `data-cratis-part` attribute and receives what is passed here; the editor's own wiring wins.\n */\nexport interface SchemaEditorParts {\n /** The editor root. Carries `data-readonly` while the editor is read-only. */\n root?: SchemaEditorPartAttributes<HTMLDivElement>;\n\n /** The wrapper of the host's `header`. */\n header?: SchemaEditorPartAttributes<HTMLDivElement>;\n\n /** A list of properties: the root list, or the properties nested under a property. */\n list?: SchemaEditorPartAttributes<HTMLUListElement>;\n\n /** One property with everything nested under it. Carries `data-property-type`. */\n property?: SchemaEditorPartAttributes<HTMLLIElement>;\n\n /** The row of one property. Carries `data-selected` while the host marks it selected. */\n row?: SchemaEditorPartAttributes<HTMLDivElement>;\n\n /** The wrapper of the host's leading slot. */\n leading?: SchemaEditorPartAttributes<HTMLSpanElement>;\n\n /** The control that shows the name and starts renaming. */\n name?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The input shown while renaming. Carries `data-invalid` for a name that cannot be used. */\n nameInput?: InputHTMLAttributes<HTMLInputElement>;\n\n /** The read-only badge of a property's type. Carries `data-property-type`, and `data-locked` while the type is locked. */\n badge?: SchemaEditorPartAttributes<HTMLSpanElement>;\n\n /** The button that opens the menu of types. */\n typeButton?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The popover of the menu of types. */\n menu?: SchemaEditorMenuPartAttributes;\n\n /** One entry of the menu of types. */\n menuItem?: SchemaEditorMenuPartAttributes;\n\n /** The label of the required toggle. */\n required?: SchemaEditorPartAttributes<HTMLLabelElement>;\n\n /** The key toggle. Carries `data-pressed` while the property is the key. */\n key?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The wrapper of the host's accessory slot. */\n accessory?: SchemaEditorPartAttributes<HTMLSpanElement>;\n\n /** The button that removes a property. */\n remove?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The marker shown instead of the remove button for a protected property. */\n protected?: SchemaEditorPartAttributes<HTMLSpanElement>;\n\n /** The wrapper of the host's details slot, shown under the row. */\n details?: SchemaEditorPartAttributes<HTMLDivElement>;\n\n /** The button that adds a property, at the root or in a nested object. */\n add?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The text shown when there are no properties. */\n empty?: SchemaEditorPartAttributes<HTMLParagraphElement>;\n\n /** A validation message. */\n message?: SchemaEditorPartAttributes<HTMLParagraphElement>;\n\n /** The wrapper of the host's `footer`, beside the add button. */\n footer?: SchemaEditorPartAttributes<HTMLDivElement>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SchemaEditorParts.js","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/SchemaEditorParts.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 { ButtonHTMLAttributes, HTMLAttributes, InputHTMLAttributes } from 'react';\n\n/** Attributes passed through to one part of the editor, including `data-*` attributes. */\nexport type SchemaEditorPartAttributes<TElement> = HTMLAttributes<TElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\n/** Styling attributes passed to a part the editor renders through a popover menu. */\nexport type SchemaEditorMenuPartAttributes = Pick<HTMLAttributes<HTMLElement>, 'className' | 'style'> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n};\n\n/**\n * Stable Cratis-owned parts for styling a {@link SchemaEditor}. Each is marked with a matching\n * `data-cratis-part` attribute and receives what is passed here; the editor's own wiring wins.\n */\nexport interface SchemaEditorParts {\n /** The editor root. Carries `data-readonly` while the editor is read-only. */\n root?: SchemaEditorPartAttributes<HTMLDivElement>;\n\n /** The wrapper of the host's `header`. */\n header?: SchemaEditorPartAttributes<HTMLDivElement>;\n\n /** A list of properties: the root list, or the properties nested under a property. */\n list?: SchemaEditorPartAttributes<HTMLUListElement>;\n\n /** One property with everything nested under it. Carries `data-property-type`. */\n property?: SchemaEditorPartAttributes<HTMLLIElement>;\n\n /** The row of one property. Carries `data-selected` while the host marks it selected. */\n row?: SchemaEditorPartAttributes<HTMLDivElement>;\n\n /** The wrapper of the host's leading slot. */\n leading?: SchemaEditorPartAttributes<HTMLSpanElement>;\n\n /** The control that shows the name and starts renaming. */\n name?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The input shown while renaming. Carries `data-invalid` for a name that cannot be used. */\n nameInput?: InputHTMLAttributes<HTMLInputElement>;\n\n /** The read-only badge of a property's type. Carries `data-property-type`, and `data-locked` while the type is locked. */\n badge?: SchemaEditorPartAttributes<HTMLSpanElement>;\n\n /** The button that opens the menu of types. */\n typeButton?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The popover of the menu of types. */\n menu?: SchemaEditorMenuPartAttributes;\n\n /** One entry of the menu of types. */\n menuItem?: SchemaEditorMenuPartAttributes;\n\n /** The label of the required toggle. */\n required?: SchemaEditorPartAttributes<HTMLLabelElement>;\n\n /** The key toggle. Carries `data-pressed` while the property is the key. */\n key?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The Generated toggle, or non-interactive marker when editing is unavailable. Carries `data-pressed` while the value is generated. */\n generated?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The wrapper of the host's accessory slot. */\n accessory?: SchemaEditorPartAttributes<HTMLSpanElement>;\n\n /** The button that removes a property. */\n remove?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The marker shown instead of the remove button for a protected property. */\n protected?: SchemaEditorPartAttributes<HTMLSpanElement>;\n\n /** The wrapper of the host's details slot, shown under the row. */\n details?: SchemaEditorPartAttributes<HTMLDivElement>;\n\n /** The button that adds a property, at the root or in a nested object. */\n add?: ButtonHTMLAttributes<HTMLButtonElement>;\n\n /** The text shown when there are no properties. */\n empty?: SchemaEditorPartAttributes<HTMLParagraphElement>;\n\n /** A validation message. */\n message?: SchemaEditorPartAttributes<HTMLParagraphElement>;\n\n /** The wrapper of the host's `footer`, beside the add button. */\n footer?: SchemaEditorPartAttributes<HTMLDivElement>;\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Property } from './Property.js';
|
|
2
|
+
import type { SchemaOriginalShape } from './SchemaOriginalShape.js';
|
|
3
|
+
/** Internal ordering metadata that remains invisible to enumeration and plain property comparisons. */
|
|
4
|
+
export declare const schemaKeywordOrder: unique symbol;
|
|
5
|
+
export declare const itemSchemaKeywordOrder: unique symbol;
|
|
6
|
+
/** Internal original type and format metadata, invisible to enumeration like the key order. */
|
|
7
|
+
export declare const schemaOriginalShape: unique symbol;
|
|
8
|
+
/** Internal order of the `required` names of an object, or of the items of an object list. */
|
|
9
|
+
export declare const schemaRequiredOrder: unique symbol;
|
|
10
|
+
/** A property read from a schema, with the original keyword positions and node shape. */
|
|
11
|
+
export interface SchemaOrderedProperty extends Property {
|
|
12
|
+
[schemaKeywordOrder]?: readonly string[];
|
|
13
|
+
[itemSchemaKeywordOrder]?: readonly string[];
|
|
14
|
+
[schemaOriginalShape]?: SchemaOriginalShape;
|
|
15
|
+
[schemaRequiredOrder]?: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
/** Carries original keyword positions and node shape onto a property without exposing enumerable metadata. */
|
|
18
|
+
export declare function copySchemaKeywordOrder(source: Partial<SchemaOrderedProperty>, target: SchemaOrderedProperty): Property;
|
|
19
|
+
//# sourceMappingURL=SchemaOrderedProperty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaOrderedProperty.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/SchemaOrderedProperty.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAAuB,CAAC;AAEjE,uGAAuG;AACvG,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAC/D,eAAO,MAAM,sBAAsB,eAAmC,CAAC;AAEvE,+FAA+F;AAC/F,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE,8FAA8F;AAC9F,eAAO,MAAM,mBAAmB,eAAgC,CAAC;AAEjE,yFAAyF;AACzF,MAAM,WAAW,qBAAsB,SAAQ,QAAQ;IACnD,CAAC,kBAAkB,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,CAAC,sBAAsB,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,CAAC,mBAAmB,CAAC,CAAC,EAAE,mBAAmB,CAAC;IAC5C,CAAC,mBAAmB,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAED,8GAA8G;AAC9G,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,qBAAqB,GAAG,QAAQ,CAMtH"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const schemaKeywordOrder = Symbol('schemaKeywordOrder');
|
|
2
|
+
const itemSchemaKeywordOrder = Symbol('itemSchemaKeywordOrder');
|
|
3
|
+
const schemaOriginalShape = Symbol('schemaOriginalShape');
|
|
4
|
+
const schemaRequiredOrder = Symbol('schemaRequiredOrder');
|
|
5
|
+
function copySchemaKeywordOrder(source, target) {
|
|
6
|
+
for (const keyword of [schemaKeywordOrder, itemSchemaKeywordOrder, schemaOriginalShape, schemaRequiredOrder]) {
|
|
7
|
+
const value = source[keyword];
|
|
8
|
+
if (value)
|
|
9
|
+
Object.defineProperty(target, keyword, { value, enumerable: false, configurable: true });
|
|
10
|
+
}
|
|
11
|
+
return target;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { copySchemaKeywordOrder, itemSchemaKeywordOrder, schemaKeywordOrder, schemaOriginalShape, schemaRequiredOrder };
|
|
15
|
+
//# sourceMappingURL=SchemaOrderedProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaOrderedProperty.js","sources":["../../../../SchemaEditor/Tree/SchemaOrderedProperty.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 { Property } from './Property';\nimport type { SchemaOriginalShape } from './SchemaOriginalShape';\n\n/** Internal ordering metadata that remains invisible to enumeration and plain property comparisons. */\nexport const schemaKeywordOrder = Symbol('schemaKeywordOrder');\nexport const itemSchemaKeywordOrder = Symbol('itemSchemaKeywordOrder');\n\n/** Internal original type and format metadata, invisible to enumeration like the key order. */\nexport const schemaOriginalShape = Symbol('schemaOriginalShape');\n\n/** Internal order of the `required` names of an object, or of the items of an object list. */\nexport const schemaRequiredOrder = Symbol('schemaRequiredOrder');\n\n/** A property read from a schema, with the original keyword positions and node shape. */\nexport interface SchemaOrderedProperty extends Property {\n [schemaKeywordOrder]?: readonly string[];\n [itemSchemaKeywordOrder]?: readonly string[];\n [schemaOriginalShape]?: SchemaOriginalShape;\n [schemaRequiredOrder]?: readonly string[];\n}\n\n/** Carries original keyword positions and node shape onto a property without exposing enumerable metadata. */\nexport function copySchemaKeywordOrder(source: Partial<SchemaOrderedProperty>, target: SchemaOrderedProperty): Property {\n for (const keyword of [schemaKeywordOrder, itemSchemaKeywordOrder, schemaOriginalShape, schemaRequiredOrder] as const) {\n const value = source[keyword];\n if (value) Object.defineProperty(target, keyword, { value, enumerable: false, configurable: true });\n }\n return target;\n}\n"],"names":[],"mappings":"MAOa,kBAAkB,GAAG,MAAM,CAAC,oBAAoB;MAChD,sBAAsB,GAAG,MAAM,CAAC,wBAAwB;MAGxD,mBAAmB,GAAG,MAAM,CAAC,qBAAqB;MAGlD,mBAAmB,GAAG,MAAM,CAAC,qBAAqB;AAWzD,SAAU,sBAAsB,CAAC,MAAsC,EAAE,MAA6B,EAAA;AACxG,IAAA,KAAK,MAAM,OAAO,IAAI,CAAC,kBAAkB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,mBAAmB,CAAU,EAAE;AACnH,QAAA,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC;AAC7B,QAAA,IAAI,KAAK;AAAE,YAAA,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACvG;AACA,IAAA,OAAO,MAAM;AACjB;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PropertyType } from './PropertyType.js';
|
|
2
|
+
/**
|
|
3
|
+
* The `type` and `format` of a property node exactly as read, so an untouched property is written back
|
|
4
|
+
* identically even where the editor models it more coarsely: `integer`, a type array, no type at all, or
|
|
5
|
+
* a format other than date and time.
|
|
6
|
+
*/
|
|
7
|
+
export interface SchemaOriginalShape {
|
|
8
|
+
/** The type the property had when it was read; the shape only applies while the property still has it. */
|
|
9
|
+
propertyType: PropertyType;
|
|
10
|
+
/** The `type` and `format` of the property node, only those present. */
|
|
11
|
+
node: Readonly<Record<string, unknown>>;
|
|
12
|
+
/** The `type` and `format` of an array's items node; absent when the array had no items node object. */
|
|
13
|
+
item?: Readonly<Record<string, unknown>>;
|
|
14
|
+
/** The `items` of an array when it is not an object, such as `true`, `false` or a tuple list, kept verbatim. */
|
|
15
|
+
rawItems?: {
|
|
16
|
+
readonly value: unknown;
|
|
17
|
+
};
|
|
18
|
+
/** Whether an object, or the items of an object list, had no `properties` keyword. */
|
|
19
|
+
withoutProperties?: boolean;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=SchemaOriginalShape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaOriginalShape.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/SchemaOriginalShape.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAChC,0GAA0G;IAC1G,YAAY,EAAE,YAAY,CAAC;IAE3B,wEAAwE;IACxE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAExC,wGAAwG;IACxG,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEzC,gHAAgH;IAChH,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAEvC,sFAAsF;IACtF,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaOriginalShape.js","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/SchemaOriginalShape.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG","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 { PropertyType } from './PropertyType';\n\n/**\n * The `type` and `format` of a property node exactly as read, so an untouched property is written back\n * identically even where the editor models it more coarsely: `integer`, a type array, no type at all, or\n * a format other than date and time.\n */\nexport interface SchemaOriginalShape {\n /** The type the property had when it was read; the shape only applies while the property still has it. */\n propertyType: PropertyType;\n\n /** The `type` and `format` of the property node, only those present. */\n node: Readonly<Record<string, unknown>>;\n\n /** The `type` and `format` of an array's items node; absent when the array had no items node object. */\n item?: Readonly<Record<string, unknown>>;\n\n /** The `items` of an array when it is not an object, such as `true`, `false` or a tuple list, kept verbatim. */\n rawItems?: { readonly value: unknown };\n\n /** Whether an object, or the items of an object list, had no `properties` keyword. */\n withoutProperties?: boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaPropertyRow.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/SchemaPropertyRow.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"SchemaPropertyRow.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/SchemaPropertyRow.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAY,CAAC;AAS3C,uEAAuE;AACvE,MAAM,WAAW,sBAAsB;IACnC,0BAA0B;IAC1B,QAAQ,EAAE,QAAQ,CAAC;IAEnB,8DAA8D;IAC9D,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAErB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;CACjB;AAID,4GAA4G;AAC5G,eAAO,MAAM,iBAAiB,kCAAmC,sBAAsB,gCAuRtF,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useId, useRef, useState, useEffect } from 'react';
|
|
3
3
|
import { FaKey, FaLock, FaXmark, FaPlus } from 'react-icons/fa6';
|
|
4
|
+
import { GeneratedToggle } from './GeneratedToggle.js';
|
|
4
5
|
import { findPropertyNameProblem, PropertyNameProblem } from './propertyNaming.js';
|
|
5
6
|
import { PropertyTypeBadge } from './PropertyTypeBadge.js';
|
|
6
7
|
import { PropertyTypeMenu } from './PropertyTypeMenu.js';
|
|
@@ -23,7 +24,6 @@ const SchemaPropertyRow = ({ property, siblings, depth }) => {
|
|
|
23
24
|
const canRename = !readOnly && !isProtected && operations.rename !== undefined;
|
|
24
25
|
const canRemove = !readOnly && !isProtected && operations.remove !== undefined;
|
|
25
26
|
const canChangeType = !readOnly && operations.changeType !== undefined && rowState?.lockType !== true;
|
|
26
|
-
const canSetRequired = context.isRequiredAllowed && operations.setRequired !== undefined;
|
|
27
27
|
const canSetKey = !readOnly && operations.setKey !== undefined && context.isKeyAllowed(property, rowContext);
|
|
28
28
|
const canAddChild = !readOnly && operations.addChild !== undefined && hasNestedProperties(property.type);
|
|
29
29
|
const lockReason = rowState?.lockType === true ? rowState.lockTypeReason : undefined;
|
|
@@ -100,7 +100,7 @@ const SchemaPropertyRow = ({ property, siblings, depth }) => {
|
|
|
100
100
|
stopEditing(); }, onKeyDown: handleEditKeyDown }), problem && (jsx("p", { ...parts?.message, id: messageId, role: 'alert', className: `cratis-schema-editor__message ${parts?.message?.className ?? ''}`, "data-cratis-part": 'message', children: problem }))] })) : canRename || isSelectable ? (jsx("button", { ...parts?.name, type: 'button', title: canRename ? labels.renameHint : undefined, "aria-keyshortcuts": canRename ? 'F2' : undefined, className: `cratis-schema-editor__name ${parts?.name?.className ?? ''}`, "data-cratis-part": 'name', onDoubleClick: startEditing, onKeyDown: event => { if (event.key === 'F2') {
|
|
101
101
|
event.preventDefault();
|
|
102
102
|
startEditing();
|
|
103
|
-
} }, children: property.name })) : (jsx("span", { className: `cratis-schema-editor__name cratis-schema-editor__name--static ${parts?.name?.className ?? ''}`, "data-cratis-part": 'name', children: property.name })), canChangeType ? (jsx(PropertyTypeMenu, { labels: labels, concepts: context.concepts, triggerPart: 'typeButton', triggerLabel: labels.changeType(property.name, property.concept ?? typeName), parts: parts, onSelect: (type, concept) => operations.changeType?.(property.id, type, concept), children: typeBadge })) : typeBadge,
|
|
103
|
+
} }, children: property.name })) : (jsx("span", { className: `cratis-schema-editor__name cratis-schema-editor__name--static ${parts?.name?.className ?? ''}`, "data-cratis-part": 'name', children: property.name })), canChangeType ? (jsx(PropertyTypeMenu, { labels: labels, concepts: context.concepts, triggerPart: 'typeButton', triggerLabel: labels.changeType(property.name, property.concept ?? typeName), parts: parts, onSelect: (type, concept) => operations.changeType?.(property.id, type, concept), children: typeBadge })) : typeBadge, context.isRequiredAllowed && operations.setRequired !== undefined && (jsxs("label", { ...parts?.required, title: labels.requiredHelp, className: `cratis-schema-editor__required ${parts?.required?.className ?? ''}`, "data-cratis-part": 'required', children: [jsx("input", { type: 'checkbox', checked: property.isRequired === true, disabled: readOnly, "aria-label": labels.requiredProperty(property.name), "aria-description": labels.requiredHelp, onChange: event => operations.setRequired?.(property.id, event.target.checked) }), labels.required] })), canSetKey && (jsx("button", { ...parts?.key, type: 'button', "aria-pressed": property.isKey === true, "aria-label": labels.keyProperty(property.name), title: property.isKey ? labels.isKey : labels.setAsKey, className: `cratis-schema-editor__toggle cratis-schema-editor__key ${parts?.key?.className ?? ''}`, "data-cratis-part": 'key', "data-pressed": property.isKey === true || undefined, onClick: () => operations.setKey?.(property.id), children: jsx(FaKey, { "aria-hidden": 'true' }) })), jsx(GeneratedToggle, { property: property, rowContext: rowContext }), context.renderAccessory && (jsx("span", { ...parts?.accessory, className: `cratis-schema-editor__accessory ${parts?.accessory?.className ?? ''}`, "data-cratis-part": 'accessory', children: context.renderAccessory(property, rowContext) })), isProtected ? (jsx("span", { ...parts?.protected, role: 'img', "aria-label": labels.protectedProperty, title: labels.protectedProperty, className: `cratis-schema-editor__protected ${parts?.protected?.className ?? ''}`, "data-cratis-part": 'protected', children: jsx(FaLock, { "aria-hidden": 'true' }) })) : canRemove && (jsx("button", { ...parts?.remove, type: 'button', "aria-label": labels.deletePropertyFor(property.name), title: labels.deletePropertyFor(property.name), className: `cratis-schema-editor__remove ${parts?.remove?.className ?? ''}`, "data-cratis-part": 'remove', onClick: () => operations.remove?.(property.id), children: jsx(FaXmark, { "aria-hidden": 'true' }) }))] }), details && (jsx("div", { ...parts?.details, className: `cratis-schema-editor__details ${parts?.details?.className ?? ''}`, "data-cratis-part": 'details', children: details })), hasNestedProperties(property.type) && (jsxs(Fragment, { children: [(property.children ?? []).length > 0 && (jsx("ul", { ...parts?.list, "aria-label": nestedLabel, className: `cratis-schema-editor__list cratis-schema-editor__list--nested ${parts?.list?.className ?? ''}`, "data-cratis-part": 'list', children: (property.children ?? []).map(child => (jsx(SchemaPropertyRow, { property: child, siblings: property.children ?? [], depth: depth + 1 }, child.id))) })), canAddChild && (jsxs(PropertyTypeMenu, { labels: labels, concepts: context.concepts, triggerPart: 'add', triggerLabel: labels.addPropertyTo(property.name), parts: parts, onSelect: (type, concept) => operations.addChild?.(property.id, type, concept), children: [jsx(FaPlus, { "aria-hidden": 'true' }), labels.addProperty] }))] }))] }));
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
export { SchemaPropertyRow };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaPropertyRow.js","sources":["../../../../SchemaEditor/Tree/SchemaPropertyRow.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 { useEffect, useId, useRef, useState, type KeyboardEvent, type MouseEvent } from 'react';\nimport { FaKey, FaLock, FaPlus, FaXmark } from 'react-icons/fa6';\nimport type { Property } from './Property';\nimport { PropertyNameProblem, findPropertyNameProblem } from './propertyNaming';\nimport { PropertyTypeBadge } from './PropertyTypeBadge';\nimport { PropertyTypeMenu } from './PropertyTypeMenu';\nimport { useSchemaEditorContext } from './SchemaEditorContext';\nimport type { SchemaPropertyContext } from './SchemaPropertyContext';\nimport { hasNestedProperties, propertyTypeName } from './propertyTypeDisplay';\n\n/** Props for one row of the editor, and everything nested under it. */\nexport interface SchemaPropertyRowProps {\n /** The property shown. */\n property: Property;\n\n /** The properties that share its parent, including itself. */\n siblings: Property[];\n\n /** How deeply the property is nested. */\n depth: number;\n}\n\nconst interactiveSelector = 'button, input, label, textarea, select, a, [role=\"menu\"]';\n\n/** One property: its row of controls, the host's details beneath it, and the properties nested under it. */\nexport const SchemaPropertyRow = ({ property, siblings, depth }: SchemaPropertyRowProps) => {\n const context = useSchemaEditorContext();\n const { labels, parts, operations, readOnly } = context;\n const messageId = useId();\n const nameInput = useRef<HTMLInputElement>(null);\n const [isEditing, setIsEditing] = useState(false);\n const [draftName, setDraftName] = useState(property.name);\n const [problem, setProblem] = useState<string | undefined>(undefined);\n\n const rowContext: SchemaPropertyContext = { depth, siblings, properties: context.properties, readOnly };\n const rowState = context.getRowState?.(property, rowContext);\n const details = context.renderDetails?.(property, rowContext);\n const isProtected = context.isProtected(property);\n const canRename = !readOnly && !isProtected && operations.rename !== undefined;\n const canRemove = !readOnly && !isProtected && operations.remove !== undefined;\n const canChangeType = !readOnly && operations.changeType !== undefined && rowState?.lockType !== true;\n const canSetRequired = context.isRequiredAllowed && operations.setRequired !== undefined;\n const canSetKey = !readOnly && operations.setKey !== undefined && context.isKeyAllowed(property, rowContext);\n const canAddChild = !readOnly && operations.addChild !== undefined && hasNestedProperties(property.type);\n const lockReason = rowState?.lockType === true ? rowState.lockTypeReason : undefined;\n const isSelected = context.selectedPropertyId === property.id;\n const typeName = propertyTypeName(property.type, labels);\n const nestedLabel = labels.nestedProperties(property.name);\n\n useEffect(() => {\n if (isEditing) nameInput.current?.select();\n }, [isEditing]);\n\n const startEditing = () => {\n if (!canRename) return;\n setDraftName(property.name);\n setProblem(undefined);\n setIsEditing(true);\n };\n\n const stopEditing = () => {\n setIsEditing(false);\n setProblem(undefined);\n };\n\n const describe = (name: string): string | undefined => {\n const found = findPropertyNameProblem(name, property.id, siblings);\n if (found === PropertyNameProblem.Empty) return labels.nameRequired;\n if (found === PropertyNameProblem.Reserved) return labels.nameReserved(name);\n if (found === PropertyNameProblem.Duplicate) return labels.nameDuplicate(name);\n return context.validateName?.(name, property, siblings);\n };\n\n const commit = (): boolean => {\n const name = draftName.trim();\n if (name === property.name) {\n stopEditing();\n return true;\n }\n const message = describe(name);\n if (message) {\n setProblem(message);\n return false;\n }\n stopEditing();\n operations.rename?.(property.id, name);\n return true;\n };\n\n const handleEditKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n commit();\n } else if (event.key === 'Escape') {\n event.stopPropagation();\n stopEditing();\n }\n };\n\n const handleRowClick = (event: MouseEvent<HTMLDivElement>) => {\n const target = event.target as HTMLElement;\n const optedIn = target.closest('[data-schema-row-select]');\n if (optedIn && event.currentTarget.contains(optedIn)) {\n context.onPropertyClick?.(property.id);\n return;\n }\n const interactive = target.closest(interactiveSelector);\n if (interactive && interactive.getAttribute('data-cratis-part') !== 'name') return;\n context.onPropertyClick?.(property.id);\n };\n\n const defaultBadge = <PropertyTypeBadge property={property} labels={labels} part={parts?.badge} lockReason={lockReason} />;\n const typeBadge = context.renderTypeBadge ? context.renderTypeBadge(property, rowContext, defaultBadge) : defaultBadge;\n const rowAttributes = rowState?.attributes ?? {};\n const isSelectable = context.onPropertyClick !== undefined;\n\n return (\n <li\n {...parts?.property}\n className={`cratis-schema-editor__property ${parts?.property?.className ?? ''}`}\n data-cratis-part='property'\n data-property-type={property.type}\n >\n <div\n {...parts?.row}\n {...rowAttributes}\n title={rowState?.title}\n className={`cratis-schema-editor__row ${rowState?.className ?? ''} ${parts?.row?.className ?? ''}`}\n data-cratis-part='row'\n data-selected={isSelected || undefined}\n onClick={handleRowClick}\n >\n {context.renderLeading && (\n <span {...parts?.leading} className={`cratis-schema-editor__leading ${parts?.leading?.className ?? ''}`} data-cratis-part='leading'>\n {context.renderLeading(property, rowContext)}\n </span>\n )}\n\n {isEditing ? (\n <span className='cratis-schema-editor__name-edit'>\n <input\n {...parts?.nameInput}\n ref={nameInput}\n type='text'\n value={draftName}\n aria-label={labels.propertyNameFor(property.name)}\n aria-invalid={problem !== undefined || undefined}\n aria-describedby={problem ? messageId : undefined}\n className={`cratis-schema-editor__name-input ${parts?.nameInput?.className ?? ''}`}\n data-cratis-part='nameInput'\n data-invalid={problem !== undefined || undefined}\n onChange={event => { setDraftName(event.target.value); setProblem(undefined); }}\n onBlur={() => { if (!commit()) stopEditing(); }}\n onKeyDown={handleEditKeyDown}\n />\n {problem && (\n <p\n {...parts?.message}\n id={messageId}\n role='alert'\n className={`cratis-schema-editor__message ${parts?.message?.className ?? ''}`}\n data-cratis-part='message'\n >\n {problem}\n </p>\n )}\n </span>\n ) : canRename || isSelectable ? (\n <button\n {...parts?.name}\n type='button'\n title={canRename ? labels.renameHint : undefined}\n aria-keyshortcuts={canRename ? 'F2' : undefined}\n className={`cratis-schema-editor__name ${parts?.name?.className ?? ''}`}\n data-cratis-part='name'\n onDoubleClick={startEditing}\n onKeyDown={event => { if (event.key === 'F2') { event.preventDefault(); startEditing(); } }}\n >\n {property.name}\n </button>\n ) : (\n <span className={`cratis-schema-editor__name cratis-schema-editor__name--static ${parts?.name?.className ?? ''}`} data-cratis-part='name'>\n {property.name}\n </span>\n )}\n\n {canChangeType ? (\n <PropertyTypeMenu\n labels={labels}\n concepts={context.concepts}\n triggerPart='typeButton'\n triggerLabel={labels.changeType(property.name, property.concept ?? typeName)}\n parts={parts}\n onSelect={(type, concept) => operations.changeType?.(property.id, type, concept)}\n >\n {typeBadge}\n </PropertyTypeMenu>\n ) : typeBadge}\n\n {canSetRequired && (\n <label\n {...parts?.required}\n title={labels.requiredHelp}\n className={`cratis-schema-editor__required ${parts?.required?.className ?? ''}`}\n data-cratis-part='required'\n >\n <input\n type='checkbox'\n checked={property.isRequired === true}\n disabled={readOnly}\n aria-label={labels.requiredProperty(property.name)}\n aria-description={labels.requiredHelp}\n onChange={event => operations.setRequired?.(property.id, event.target.checked)}\n />\n {labels.required}\n </label>\n )}\n\n {canSetKey && (\n <button\n {...parts?.key}\n type='button'\n aria-pressed={property.isKey === true}\n aria-label={labels.keyProperty(property.name)}\n title={property.isKey ? labels.isKey : labels.setAsKey}\n className={`cratis-schema-editor__key ${parts?.key?.className ?? ''}`}\n data-cratis-part='key'\n data-pressed={property.isKey === true || undefined}\n onClick={() => operations.setKey?.(property.id)}\n >\n <FaKey aria-hidden='true' />\n </button>\n )}\n\n {context.renderAccessory && (\n <span {...parts?.accessory} className={`cratis-schema-editor__accessory ${parts?.accessory?.className ?? ''}`} data-cratis-part='accessory'>\n {context.renderAccessory(property, rowContext)}\n </span>\n )}\n\n {isProtected ? (\n <span\n {...parts?.protected}\n role='img'\n aria-label={labels.protectedProperty}\n title={labels.protectedProperty}\n className={`cratis-schema-editor__protected ${parts?.protected?.className ?? ''}`}\n data-cratis-part='protected'\n >\n <FaLock aria-hidden='true' />\n </span>\n ) : canRemove && (\n <button\n {...parts?.remove}\n type='button'\n aria-label={labels.deletePropertyFor(property.name)}\n title={labels.deletePropertyFor(property.name)}\n className={`cratis-schema-editor__remove ${parts?.remove?.className ?? ''}`}\n data-cratis-part='remove'\n onClick={() => operations.remove?.(property.id)}\n >\n <FaXmark aria-hidden='true' />\n </button>\n )}\n </div>\n\n {details && (\n <div {...parts?.details} className={`cratis-schema-editor__details ${parts?.details?.className ?? ''}`} data-cratis-part='details'>\n {details}\n </div>\n )}\n\n {hasNestedProperties(property.type) && (\n <>\n {(property.children ?? []).length > 0 && (\n <ul\n {...parts?.list}\n aria-label={nestedLabel}\n className={`cratis-schema-editor__list cratis-schema-editor__list--nested ${parts?.list?.className ?? ''}`}\n data-cratis-part='list'\n >\n {(property.children ?? []).map(child => (\n <SchemaPropertyRow key={child.id} property={child} siblings={property.children ?? []} depth={depth + 1} />\n ))}\n </ul>\n )}\n {canAddChild && (\n <PropertyTypeMenu\n labels={labels}\n concepts={context.concepts}\n triggerPart='add'\n triggerLabel={labels.addPropertyTo(property.name)}\n parts={parts}\n onSelect={(type, concept) => operations.addChild?.(property.id, type, concept)}\n >\n <FaPlus aria-hidden='true' />\n {labels.addProperty}\n </PropertyTypeMenu>\n )}\n </>\n )}\n </li>\n );\n};\n"],"names":["_jsx","_jsxs","_Fragment"],"mappings":";;;;;;;;;AAyBA,MAAM,mBAAmB,GAAG,0DAA0D;AAG/E,MAAM,iBAAiB,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAA0B,KAAI;AACvF,IAAA,MAAM,OAAO,GAAG,sBAAsB,EAAE;IACxC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,OAAO;AACvD,IAAA,MAAM,SAAS,GAAG,KAAK,EAAE;AACzB,IAAA,MAAM,SAAS,GAAG,MAAM,CAAmB,IAAI,CAAC;IAChD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACjD,IAAA,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;IACzD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC;AAErE,IAAA,MAAM,UAAU,GAA0B,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE;IACvG,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,QAAQ,EAAE,UAAU,CAAC;IAC5D,MAAM,OAAO,GAAG,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AAA,CAAC,iBAAiB,EAAA,EAAgB,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,GAAG,CAAC,EAAA,EAA9E,KAAK,CAAC,EAAE,CAA0E,CAC7G,CAAC,EAAA,CACD,CACR,EACA,WAAW,KACRC,IAAA,CAAC,gBAAgB,EAAA,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,WAAW,EAAC,KAAK,EACjB,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,EACjD,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,aAE9ED,GAAA,CAAC,MAAM,EAAA,EAAA,aAAA,EAAa,MAAM,GAAG,EAC5B,MAAM,CAAC,WAAW,IACJ,CACtB,CAAA,EAAA,CACF,CACN,CAAA,EAAA,CACA;AAEb;;"}
|
|
1
|
+
{"version":3,"file":"SchemaPropertyRow.js","sources":["../../../../SchemaEditor/Tree/SchemaPropertyRow.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 { useEffect, useId, useRef, useState, type KeyboardEvent, type MouseEvent } from 'react';\nimport { FaKey, FaLock, FaPlus, FaXmark } from 'react-icons/fa6';\nimport type { Property } from './Property';\nimport { GeneratedToggle } from './GeneratedToggle';\nimport { PropertyNameProblem, findPropertyNameProblem } from './propertyNaming';\nimport { PropertyTypeBadge } from './PropertyTypeBadge';\nimport { PropertyTypeMenu } from './PropertyTypeMenu';\nimport { useSchemaEditorContext } from './SchemaEditorContext';\nimport type { SchemaPropertyContext } from './SchemaPropertyContext';\nimport { hasNestedProperties, propertyTypeName } from './propertyTypeDisplay';\n\n/** Props for one row of the editor, and everything nested under it. */\nexport interface SchemaPropertyRowProps {\n /** The property shown. */\n property: Property;\n\n /** The properties that share its parent, including itself. */\n siblings: Property[];\n\n /** How deeply the property is nested. */\n depth: number;\n}\n\nconst interactiveSelector = 'button, input, label, textarea, select, a, [role=\"menu\"]';\n\n/** One property: its row of controls, the host's details beneath it, and the properties nested under it. */\nexport const SchemaPropertyRow = ({ property, siblings, depth }: SchemaPropertyRowProps) => {\n const context = useSchemaEditorContext();\n const { labels, parts, operations, readOnly } = context;\n const messageId = useId();\n const nameInput = useRef<HTMLInputElement>(null);\n const [isEditing, setIsEditing] = useState(false);\n const [draftName, setDraftName] = useState(property.name);\n const [problem, setProblem] = useState<string | undefined>(undefined);\n\n const rowContext: SchemaPropertyContext = { depth, siblings, properties: context.properties, readOnly };\n const rowState = context.getRowState?.(property, rowContext);\n const details = context.renderDetails?.(property, rowContext);\n const isProtected = context.isProtected(property);\n const canRename = !readOnly && !isProtected && operations.rename !== undefined;\n const canRemove = !readOnly && !isProtected && operations.remove !== undefined;\n const canChangeType = !readOnly && operations.changeType !== undefined && rowState?.lockType !== true;\n const canSetKey = !readOnly && operations.setKey !== undefined && context.isKeyAllowed(property, rowContext);\n const canAddChild = !readOnly && operations.addChild !== undefined && hasNestedProperties(property.type);\n const lockReason = rowState?.lockType === true ? rowState.lockTypeReason : undefined;\n const isSelected = context.selectedPropertyId === property.id;\n const typeName = propertyTypeName(property.type, labels);\n const nestedLabel = labels.nestedProperties(property.name);\n\n useEffect(() => {\n if (isEditing) nameInput.current?.select();\n }, [isEditing]);\n\n const startEditing = () => {\n if (!canRename) return;\n setDraftName(property.name);\n setProblem(undefined);\n setIsEditing(true);\n };\n\n const stopEditing = () => {\n setIsEditing(false);\n setProblem(undefined);\n };\n\n const describe = (name: string): string | undefined => {\n const found = findPropertyNameProblem(name, property.id, siblings);\n if (found === PropertyNameProblem.Empty) return labels.nameRequired;\n if (found === PropertyNameProblem.Reserved) return labels.nameReserved(name);\n if (found === PropertyNameProblem.Duplicate) return labels.nameDuplicate(name);\n return context.validateName?.(name, property, siblings);\n };\n\n const commit = (): boolean => {\n const name = draftName.trim();\n if (name === property.name) {\n stopEditing();\n return true;\n }\n const message = describe(name);\n if (message) {\n setProblem(message);\n return false;\n }\n stopEditing();\n operations.rename?.(property.id, name);\n return true;\n };\n\n const handleEditKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n commit();\n } else if (event.key === 'Escape') {\n event.stopPropagation();\n stopEditing();\n }\n };\n\n const handleRowClick = (event: MouseEvent<HTMLDivElement>) => {\n const target = event.target as HTMLElement;\n const optedIn = target.closest('[data-schema-row-select]');\n if (optedIn && event.currentTarget.contains(optedIn)) {\n context.onPropertyClick?.(property.id);\n return;\n }\n const interactive = target.closest(interactiveSelector);\n if (interactive && interactive.getAttribute('data-cratis-part') !== 'name') return;\n context.onPropertyClick?.(property.id);\n };\n\n const defaultBadge = <PropertyTypeBadge property={property} labels={labels} part={parts?.badge} lockReason={lockReason} />;\n const typeBadge = context.renderTypeBadge ? context.renderTypeBadge(property, rowContext, defaultBadge) : defaultBadge;\n const rowAttributes = rowState?.attributes ?? {};\n const isSelectable = context.onPropertyClick !== undefined;\n\n return (\n <li\n {...parts?.property}\n className={`cratis-schema-editor__property ${parts?.property?.className ?? ''}`}\n data-cratis-part='property'\n data-property-type={property.type}\n >\n <div\n {...parts?.row}\n {...rowAttributes}\n title={rowState?.title}\n className={`cratis-schema-editor__row ${rowState?.className ?? ''} ${parts?.row?.className ?? ''}`}\n data-cratis-part='row'\n data-selected={isSelected || undefined}\n onClick={handleRowClick}\n >\n {context.renderLeading && (\n <span {...parts?.leading} className={`cratis-schema-editor__leading ${parts?.leading?.className ?? ''}`} data-cratis-part='leading'>\n {context.renderLeading(property, rowContext)}\n </span>\n )}\n\n {isEditing ? (\n <span className='cratis-schema-editor__name-edit'>\n <input\n {...parts?.nameInput}\n ref={nameInput}\n type='text'\n value={draftName}\n aria-label={labels.propertyNameFor(property.name)}\n aria-invalid={problem !== undefined || undefined}\n aria-describedby={problem ? messageId : undefined}\n className={`cratis-schema-editor__name-input ${parts?.nameInput?.className ?? ''}`}\n data-cratis-part='nameInput'\n data-invalid={problem !== undefined || undefined}\n onChange={event => { setDraftName(event.target.value); setProblem(undefined); }}\n onBlur={() => { if (!commit()) stopEditing(); }}\n onKeyDown={handleEditKeyDown}\n />\n {problem && (\n <p\n {...parts?.message}\n id={messageId}\n role='alert'\n className={`cratis-schema-editor__message ${parts?.message?.className ?? ''}`}\n data-cratis-part='message'\n >\n {problem}\n </p>\n )}\n </span>\n ) : canRename || isSelectable ? (\n <button\n {...parts?.name}\n type='button'\n title={canRename ? labels.renameHint : undefined}\n aria-keyshortcuts={canRename ? 'F2' : undefined}\n className={`cratis-schema-editor__name ${parts?.name?.className ?? ''}`}\n data-cratis-part='name'\n onDoubleClick={startEditing}\n onKeyDown={event => { if (event.key === 'F2') { event.preventDefault(); startEditing(); } }}\n >\n {property.name}\n </button>\n ) : (\n <span className={`cratis-schema-editor__name cratis-schema-editor__name--static ${parts?.name?.className ?? ''}`} data-cratis-part='name'>\n {property.name}\n </span>\n )}\n\n {canChangeType ? (\n <PropertyTypeMenu\n labels={labels}\n concepts={context.concepts}\n triggerPart='typeButton'\n triggerLabel={labels.changeType(property.name, property.concept ?? typeName)}\n parts={parts}\n onSelect={(type, concept) => operations.changeType?.(property.id, type, concept)}\n >\n {typeBadge}\n </PropertyTypeMenu>\n ) : typeBadge}\n\n {context.isRequiredAllowed && operations.setRequired !== undefined && (\n <label\n {...parts?.required}\n title={labels.requiredHelp}\n className={`cratis-schema-editor__required ${parts?.required?.className ?? ''}`}\n data-cratis-part='required'\n >\n <input\n type='checkbox'\n checked={property.isRequired === true}\n disabled={readOnly}\n aria-label={labels.requiredProperty(property.name)}\n aria-description={labels.requiredHelp}\n onChange={event => operations.setRequired?.(property.id, event.target.checked)}\n />\n {labels.required}\n </label>\n )}\n\n {canSetKey && (\n <button\n {...parts?.key}\n type='button'\n aria-pressed={property.isKey === true}\n aria-label={labels.keyProperty(property.name)}\n title={property.isKey ? labels.isKey : labels.setAsKey}\n className={`cratis-schema-editor__toggle cratis-schema-editor__key ${parts?.key?.className ?? ''}`}\n data-cratis-part='key'\n data-pressed={property.isKey === true || undefined}\n onClick={() => operations.setKey?.(property.id)}\n >\n <FaKey aria-hidden='true' />\n </button>\n )}\n\n <GeneratedToggle property={property} rowContext={rowContext} />\n\n {context.renderAccessory && (\n <span {...parts?.accessory} className={`cratis-schema-editor__accessory ${parts?.accessory?.className ?? ''}`} data-cratis-part='accessory'>\n {context.renderAccessory(property, rowContext)}\n </span>\n )}\n\n {isProtected ? (\n <span\n {...parts?.protected}\n role='img'\n aria-label={labels.protectedProperty}\n title={labels.protectedProperty}\n className={`cratis-schema-editor__protected ${parts?.protected?.className ?? ''}`}\n data-cratis-part='protected'\n >\n <FaLock aria-hidden='true' />\n </span>\n ) : canRemove && (\n <button\n {...parts?.remove}\n type='button'\n aria-label={labels.deletePropertyFor(property.name)}\n title={labels.deletePropertyFor(property.name)}\n className={`cratis-schema-editor__remove ${parts?.remove?.className ?? ''}`}\n data-cratis-part='remove'\n onClick={() => operations.remove?.(property.id)}\n >\n <FaXmark aria-hidden='true' />\n </button>\n )}\n </div>\n\n {details && (\n <div {...parts?.details} className={`cratis-schema-editor__details ${parts?.details?.className ?? ''}`} data-cratis-part='details'>\n {details}\n </div>\n )}\n\n {hasNestedProperties(property.type) && (\n <>\n {(property.children ?? []).length > 0 && (\n <ul\n {...parts?.list}\n aria-label={nestedLabel}\n className={`cratis-schema-editor__list cratis-schema-editor__list--nested ${parts?.list?.className ?? ''}`}\n data-cratis-part='list'\n >\n {(property.children ?? []).map(child => (\n <SchemaPropertyRow key={child.id} property={child} siblings={property.children ?? []} depth={depth + 1} />\n ))}\n </ul>\n )}\n {canAddChild && (\n <PropertyTypeMenu\n labels={labels}\n concepts={context.concepts}\n triggerPart='add'\n triggerLabel={labels.addPropertyTo(property.name)}\n parts={parts}\n onSelect={(type, concept) => operations.addChild?.(property.id, type, concept)}\n >\n <FaPlus aria-hidden='true' />\n {labels.addProperty}\n </PropertyTypeMenu>\n )}\n </>\n )}\n </li>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;AA0BA,MAAM,mBAAmB,GAAG,0DAA0D;AAG/E,MAAM,iBAAiB,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAA0B,KAAI;AACvF,IAAA,MAAM,OAAO,GAAG,sBAAsB,EAAE;IACxC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,OAAO;AACvD,IAAA,MAAM,SAAS,GAAG,KAAK,EAAE;AACzB,IAAA,MAAM,SAAS,GAAG,MAAM,CAAmB,IAAI,CAAC;IAChD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACjD,IAAA,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;IACzD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAqB,SAAS,CAAC;AAErE,IAAA,MAAM,UAAU,GAA0B,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE;IACvG,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,QAAQ,EAAE,UAAU,CAAC;IAC5D,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,GAAG,QAAQ,EAAE,UAAU,CAAC;IAC7D,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC;AACjD,IAAA,MAAM,SAAS,GAAG,CAAC,QAAQ,IAAI,CAAC,WAAW,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS;AAC9E,IAAA,MAAM,SAAS,GAAG,CAAC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,EAAE,OAAO,CAAC,QAAQ,EAC1B,WAAW,EAAC,KAAK,EACjB,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,EACjD,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,EAAA,QAAA,EAAA,CAE9ED,GAAA,CAAC,MAAM,EAAA,EAAA,aAAA,EAAa,MAAM,EAAA,CAAG,EAC5B,MAAM,CAAC,WAAW,CAAA,EAAA,CACJ,CACtB,IACF,CACN,CAAA,EAAA,CACA;AAEb;;"}
|
|
@@ -43,6 +43,8 @@ export interface TreeSchemaEditorProps {
|
|
|
43
43
|
onChangePropertyType?: (propertyId: string, type: PropertyType, concept?: string) => void;
|
|
44
44
|
/** Controlled mode: make a property the key of its object, or clear it when it already is. */
|
|
45
45
|
onSetKeyProperty?: (propertyId: string) => void;
|
|
46
|
+
/** Controlled mode: set whether a property's value is generated. Implies allowGeneratedProperty unless explicitly false. */
|
|
47
|
+
onSetGeneratedProperty?: (propertyId: string, isGenerated: boolean) => void;
|
|
46
48
|
/** Controlled mode: set whether a property must be present. */
|
|
47
49
|
onSetRequiredProperty?: (propertyId: string, isRequired: boolean) => void;
|
|
48
50
|
/**
|
|
@@ -56,6 +58,11 @@ export interface TreeSchemaEditorProps {
|
|
|
56
58
|
* controlled mode, where supplying `onSetKeyProperty` implies `true` unless this is explicitly `false`.
|
|
57
59
|
*/
|
|
58
60
|
allowKeyProperty?: boolean | ((property: Property, context: SchemaPropertyContext) => boolean);
|
|
61
|
+
/**
|
|
62
|
+
* Offers the Generated toggle on every property, or on properties accepted by the predicate. Off by default;
|
|
63
|
+
* a controlled onSetGeneratedProperty callback implies true unless explicitly false. The table layout ignores it.
|
|
64
|
+
*/
|
|
65
|
+
allowGeneratedProperty?: boolean | ((property: Property, context: SchemaPropertyContext) => boolean);
|
|
59
66
|
/**
|
|
60
67
|
* Offers the toggle for whether a property must be present (the `required` list). Off by default, except in
|
|
61
68
|
* controlled mode, where supplying `onSetRequiredProperty` implies `true` unless this is explicitly `false`.
|
|
@@ -112,5 +119,5 @@ export interface TreeSchemaEditorProps {
|
|
|
112
119
|
* attached through the slots (`header`, `footer`, `renderPropertyLeading`, `renderPropertyAccessory`,
|
|
113
120
|
* `renderPropertyDetails`, `renderPropertyTypeBadge`) and `getPropertyRowState`.
|
|
114
121
|
*/
|
|
115
|
-
export declare const TreeSchemaEditor: ({ schema, onChange, onPropertiesChange, onPropertyRemoved, onPropertyRenamed, properties: controlledProperties, onAddProperty, onAddChildProperty, onDeleteProperty, onRenameProperty, onChangePropertyType, onSetKeyProperty, onSetRequiredProperty, concepts: suppliedConcepts, allowKeyProperty, allowRequired, readOnly, isPropertyProtected, validatePropertyName, selectedPropertyId, onPropertyClick, header, footer, renderPropertyLeading, renderPropertyAccessory, renderPropertyDetails, getPropertyRowState, renderPropertyTypeBadge, labels: suppliedLabels, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className, pt, }: TreeSchemaEditorProps) => import("react").JSX.Element;
|
|
122
|
+
export declare const TreeSchemaEditor: ({ schema, onChange, onPropertiesChange, onPropertyRemoved, onPropertyRenamed, properties: controlledProperties, onAddProperty, onAddChildProperty, onDeleteProperty, onRenameProperty, onChangePropertyType, onSetKeyProperty, onSetGeneratedProperty, onSetRequiredProperty, concepts: suppliedConcepts, allowKeyProperty, allowGeneratedProperty, allowRequired, readOnly, isPropertyProtected, validatePropertyName, selectedPropertyId, onPropertyClick, header, footer, renderPropertyLeading, renderPropertyAccessory, renderPropertyDetails, getPropertyRowState, renderPropertyTypeBadge, labels: suppliedLabels, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className, pt, }: TreeSchemaEditorProps) => import("react").JSX.Element;
|
|
116
123
|
//# sourceMappingURL=TreeSchemaEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeSchemaEditor.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/TreeSchemaEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAwC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"TreeSchemaEditor.d.ts","sourceRoot":"","sources":["../../../../SchemaEditor/Tree/TreeSchemaEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAwC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA2B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAgB,CAAC;AAgB9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAqB,CAAC;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA0B,CAAC;AAIvE,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IAClC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;I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F,4JAA4J;IAC5J,qBAAqB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,SAAS,CAAC;IAE1F,iIAAiI;IACjI,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,sBAAsB,GAAG,SAAS,CAAC;IAEjH;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,SAAS,KAAK,SAAS,CAAC;IAErH,qEAAqE;IACrE,MAAM,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAErC,qEAAqE;IACrE,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,+CAA+C;IAC/C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,qDAAqD;IACrD,EAAE,CAAC,EAAE,iBAAiB,CAAC;CAC1B;AAUD;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,2qBAoC1B,qBAAqB,gCA6IvB,CAAC"}
|
|
@@ -4,13 +4,19 @@ import { FaPlus } from 'react-icons/fa6';
|
|
|
4
4
|
import { useOptionalPropertyConcepts } from './PropertyConceptsContext.js';
|
|
5
5
|
import { findPropertyById, totalPropertyCount } from './propertyTree.js';
|
|
6
6
|
import { PropertyTypeMenu } from './PropertyTypeMenu.js';
|
|
7
|
-
import { jsonSchemaToProperties, propertiesToJsonSchema, setRequiredProperty, setKeyProperty, changePropertyType, renameProperty, removeProperty, addChildProperty, addProperty } from './schemaConversion.js';
|
|
7
|
+
import { jsonSchemaToProperties, propertiesToJsonSchema, setRequiredProperty, setGeneratedProperty, setKeyProperty, changePropertyType, renameProperty, removeProperty, addChildProperty, addProperty } from './schemaConversion.js';
|
|
8
8
|
import { SchemaEditorContext } from './SchemaEditorContext.js';
|
|
9
9
|
import { resolveSchemaEditorLabels } from '../resolveSchemaEditorLabels.js';
|
|
10
10
|
import { SchemaPropertyRow } from './SchemaPropertyRow.js';
|
|
11
11
|
|
|
12
12
|
const never = () => false;
|
|
13
|
-
|
|
13
|
+
function allowance(flag, callback, isControlled) {
|
|
14
|
+
const allowed = flag ?? (isControlled && callback !== undefined);
|
|
15
|
+
if (typeof allowed === 'function')
|
|
16
|
+
return allowed;
|
|
17
|
+
return allowed ? () => true : never;
|
|
18
|
+
}
|
|
19
|
+
const TreeSchemaEditor = ({ schema, onChange, onPropertiesChange, onPropertyRemoved, onPropertyRenamed, properties: controlledProperties, onAddProperty, onAddChildProperty, onDeleteProperty, onRenameProperty, onChangePropertyType, onSetKeyProperty, onSetGeneratedProperty, onSetRequiredProperty, concepts: suppliedConcepts, allowKeyProperty, allowGeneratedProperty, allowRequired, readOnly = false, isPropertyProtected, validatePropertyName, selectedPropertyId, onPropertyClick, header, footer, renderPropertyLeading, renderPropertyAccessory, renderPropertyDetails, getPropertyRowState, renderPropertyTypeBadge, labels: suppliedLabels, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className, pt, }) => {
|
|
14
20
|
const labels = useMemo(() => resolveSchemaEditorLabels(suppliedLabels), [suppliedLabels]);
|
|
15
21
|
const providedConcepts = useOptionalPropertyConcepts();
|
|
16
22
|
const concepts = suppliedConcepts ?? providedConcepts;
|
|
@@ -23,14 +29,14 @@ const TreeSchemaEditor = ({ schema, onChange, onPropertiesChange, onPropertyRemo
|
|
|
23
29
|
const [seenSchema, setSeenSchema] = useState(incomingSchema);
|
|
24
30
|
if (!isControlled && incomingSchema !== seenSchema) {
|
|
25
31
|
setSeenSchema(incomingSchema);
|
|
26
|
-
if (schema !== undefined && incomingSchema !== JSON.stringify(propertiesToJsonSchema(ownedProperties))) {
|
|
32
|
+
if (schema !== undefined && incomingSchema !== JSON.stringify(propertiesToJsonSchema(ownedProperties, schema))) {
|
|
27
33
|
setOwnedProperties(jsonSchemaToProperties(schema));
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
const apply = (next) => {
|
|
31
37
|
latest.current = next;
|
|
32
38
|
setOwnedProperties(next);
|
|
33
|
-
onChange?.(propertiesToJsonSchema(next), { source: 'user' });
|
|
39
|
+
onChange?.(propertiesToJsonSchema(next, schema), { source: 'user' });
|
|
34
40
|
onPropertiesChange?.(next);
|
|
35
41
|
};
|
|
36
42
|
const ownedOperations = {
|
|
@@ -51,6 +57,7 @@ const TreeSchemaEditor = ({ schema, onChange, onPropertiesChange, onPropertyRemo
|
|
|
51
57
|
},
|
|
52
58
|
changeType: (propertyId, type, concept) => apply(changePropertyType(latest.current, propertyId, type, concept)),
|
|
53
59
|
setKey: propertyId => apply(setKeyProperty(latest.current, propertyId)),
|
|
60
|
+
setGenerated: (propertyId, isGenerated) => apply(setGeneratedProperty(latest.current, propertyId, isGenerated)),
|
|
54
61
|
setRequired: (propertyId, isRequired) => apply(setRequiredProperty(latest.current, propertyId, isRequired)),
|
|
55
62
|
};
|
|
56
63
|
const controlledOperations = {
|
|
@@ -59,17 +66,13 @@ const TreeSchemaEditor = ({ schema, onChange, onPropertiesChange, onPropertyRemo
|
|
|
59
66
|
rename: onRenameProperty,
|
|
60
67
|
changeType: onChangePropertyType,
|
|
61
68
|
setKey: onSetKeyProperty,
|
|
69
|
+
setGenerated: onSetGeneratedProperty,
|
|
62
70
|
setRequired: onSetRequiredProperty,
|
|
63
71
|
};
|
|
64
72
|
const operations = isControlled ? controlledOperations : ownedOperations;
|
|
65
73
|
const addRoot = isControlled
|
|
66
74
|
? onAddProperty
|
|
67
75
|
: (type, concept) => apply(addProperty(latest.current, type, totalPropertyCount(latest.current), concept));
|
|
68
|
-
const keyAllowance = allowKeyProperty ?? (isControlled && onSetKeyProperty !== undefined);
|
|
69
|
-
const isKeyAllowed = typeof keyAllowance === 'function'
|
|
70
|
-
? keyAllowance
|
|
71
|
-
: keyAllowance ? () => true : never;
|
|
72
|
-
const isRequiredAllowed = allowRequired ?? (isControlled && onSetRequiredProperty !== undefined);
|
|
73
76
|
const contextValue = {
|
|
74
77
|
labels,
|
|
75
78
|
parts: pt,
|
|
@@ -79,8 +82,9 @@ const TreeSchemaEditor = ({ schema, onChange, onPropertiesChange, onPropertyRemo
|
|
|
79
82
|
operations,
|
|
80
83
|
selectedPropertyId,
|
|
81
84
|
onPropertyClick,
|
|
82
|
-
isKeyAllowed,
|
|
83
|
-
|
|
85
|
+
isKeyAllowed: allowance(allowKeyProperty, onSetKeyProperty, isControlled),
|
|
86
|
+
isGeneratedAllowed: allowance(allowGeneratedProperty, onSetGeneratedProperty, isControlled),
|
|
87
|
+
isRequiredAllowed: allowRequired ?? (isControlled && onSetRequiredProperty !== undefined),
|
|
84
88
|
isProtected: isPropertyProtected ?? never,
|
|
85
89
|
validateName: validatePropertyName,
|
|
86
90
|
getRowState: getPropertyRowState,
|