@cratis/components 4.27.0 → 4.28.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.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/Property.d.ts +6 -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 +12 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.js +13 -0
- package/dist/esm/SchemaEditor/Tree/SchemaOrderedProperty.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/schemaConversion.d.ts +15 -3
- package/dist/esm/SchemaEditor/Tree/schemaConversion.d.ts.map +1 -1
- package/dist/esm/SchemaEditor/Tree/schemaConversion.js +83 -27
- package/dist/esm/SchemaEditor/Tree/schemaConversion.js.map +1 -1
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.d.ts +3 -0
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.js +7 -0
- package/dist/esm/SchemaEditor/Tree/schemaInOriginalOrder.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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaEditorContext.d.ts","sourceRoot":"","sources":["../../../../Schema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,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,QAAQ,MAAM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E,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,12 @@
|
|
|
1
|
+
import type { Property } from './Property.js';
|
|
2
|
+
/** Internal ordering metadata that remains invisible to enumeration and plain property comparisons. */
|
|
3
|
+
export declare const schemaKeywordOrder: unique symbol;
|
|
4
|
+
export declare const itemSchemaKeywordOrder: unique symbol;
|
|
5
|
+
/** A property read from a schema, with the original keyword positions. */
|
|
6
|
+
export interface SchemaOrderedProperty extends Property {
|
|
7
|
+
[schemaKeywordOrder]?: readonly string[];
|
|
8
|
+
[itemSchemaKeywordOrder]?: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
/** Carries original keyword positions onto a property without exposing enumerable metadata. */
|
|
11
|
+
export declare function copySchemaKeywordOrder(source: Partial<SchemaOrderedProperty>, target: SchemaOrderedProperty): Property;
|
|
12
|
+
//# 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;AAE3C,uGAAuG;AACvG,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAC/D,eAAO,MAAM,sBAAsB,eAAmC,CAAC;AAEvE,0EAA0E;AAC1E,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;CAChD;AAED,+FAA+F;AAC/F,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,qBAAqB,GAAG,QAAQ,CAMtH"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const schemaKeywordOrder = Symbol('schemaKeywordOrder');
|
|
2
|
+
const itemSchemaKeywordOrder = Symbol('itemSchemaKeywordOrder');
|
|
3
|
+
function copySchemaKeywordOrder(source, target) {
|
|
4
|
+
for (const keyword of [schemaKeywordOrder, itemSchemaKeywordOrder]) {
|
|
5
|
+
const order = source[keyword];
|
|
6
|
+
if (order)
|
|
7
|
+
Object.defineProperty(target, keyword, { value: order, enumerable: false, configurable: true });
|
|
8
|
+
}
|
|
9
|
+
return target;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { copySchemaKeywordOrder, itemSchemaKeywordOrder, schemaKeywordOrder };
|
|
13
|
+
//# 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';\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/** A property read from a schema, with the original keyword positions. */\nexport interface SchemaOrderedProperty extends Property {\n [schemaKeywordOrder]?: readonly string[];\n [itemSchemaKeywordOrder]?: readonly string[];\n}\n\n/** Carries original keyword positions onto a property without exposing enumerable metadata. */\nexport function copySchemaKeywordOrder(source: Partial<SchemaOrderedProperty>, target: SchemaOrderedProperty): Property {\n for (const keyword of [schemaKeywordOrder, itemSchemaKeywordOrder] as const) {\n const order = source[keyword];\n if (order) Object.defineProperty(target, keyword, { value: order, enumerable: false, configurable: true });\n }\n return target;\n}\n"],"names":[],"mappings":"MAMa,kBAAkB,GAAG,MAAM,CAAC,oBAAoB;MAChD,sBAAsB,GAAG,MAAM,CAAC,wBAAwB;AAS/D,SAAU,sBAAsB,CAAC,MAAsC,EAAE,MAA6B,EAAA;IACxG,KAAK,MAAM,OAAO,IAAI,CAAC,kBAAkB,EAAE,sBAAsB,CAAU,EAAE;AACzE,QAAA,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC;AAC7B,QAAA,IAAI,KAAK;YAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAC9G;AACA,IAAA,OAAO,MAAM;AACjB;;"}
|
|
@@ -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,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{"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,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AAE,IAAI,EAAA,YAAA,EACH,WAAW,EACvB,SAAS,EAAE,CAAA,8DAAA,EAAiE,KAAK,EAAE,IAAI,EAAE,SAAS,IAAI,EAAE,CAAA,CAAE,EAAA,kBAAA,EACzF,MAAM,EAAA,QAAA,EAEtB,CAAC,QAAQ,CAAC,QAAQ,IAAI,EAAE,EAAE,GAAG,CAAC,KAAK,KAChCA,IAAC,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,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,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BAoC1B,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,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeSchemaEditor.js","sources":["../../../../SchemaEditor/Tree/TreeSchemaEditor.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, useMemo, useRef, useState, type ReactNode } from 'react';\nimport { FaPlus } from 'react-icons/fa6';\nimport type { ChangeHandler } from '../../types/ChangeHandler';\nimport type { JsonSchema } from '../../types/JsonSchema';\nimport type { Property } from './Property';\nimport type { PropertyConcept } from './PropertyConcept';\nimport { useOptionalPropertyConcepts } from './PropertyConceptsContext';\nimport { PropertyType } from './PropertyType';\nimport { findPropertyById } from './propertyTree';\nimport { PropertyTypeMenu } from './PropertyTypeMenu';\nimport {\n addChildProperty,\n addProperty,\n changePropertyType,\n jsonSchemaToProperties,\n propertiesToJsonSchema,\n removeProperty,\n renameProperty,\n setKeyProperty,\n setRequiredProperty,\n} from './schemaConversion';\nimport { SchemaEditorContext, type SchemaEditorContextValue, type SchemaEditorOperations } from './SchemaEditorContext';\nimport type { SchemaEditorLabels } from '../SchemaEditorLabels';\nimport type { SchemaEditorParts } from './SchemaEditorParts';\nimport { resolveSchemaEditorLabels } from '../resolveSchemaEditorLabels';\nimport type { SchemaPropertyContext } from './SchemaPropertyContext';\nimport type { SchemaPropertyRowState } from './SchemaPropertyRowState';\nimport { SchemaPropertyRow } from './SchemaPropertyRow';\nimport { totalPropertyCount } from './propertyTree';\n\n/** The props of the tree layout of the {@link SchemaEditor}. */\nexport interface TreeSchemaEditorProps {\n /**\n * The JSON Schema to edit. The editor converts it, keeps the edited property tree itself and reports every\n * edit through {@link TreeSchemaEditorProps.onChange}. Passing the reported schema back, or the same schema\n * again, changes nothing; passing a schema that differs from both replaces the tree and its property ids.\n * Ignored when `properties` is given.\n */\n schema?: JsonSchema;\n\n /** Called with the complete schema after every edit. Only used when the editor owns the property tree. */\n onChange?: ChangeHandler<JsonSchema>;\n\n /** Called with the property tree after every edit, so a host can follow the ids. Only used when the editor owns the property tree. */\n onPropertiesChange?: (properties: Property[]) => void;\n\n /** Called after a property was removed, with the property and everything nested under it. Only used when the editor owns the property tree. */\n onPropertyRemoved?: (property: Property) => void;\n\n /** Called after a property was renamed, with the renamed property and the name it had. Only used when the editor owns the property tree. */\n onPropertyRenamed?: (property: Property, previousName: string) => void;\n\n /**\n * The property tree to show. When given, the editor is controlled: it changes nothing itself and each edit\n * is offered through the matching `onAddProperty`, `onDeleteProperty`… callback, which the host applies.\n * An edit without a callback is not offered.\n */\n properties?: Property[];\n\n /** Controlled mode: add a property to the root. */\n onAddProperty?: (type: PropertyType, concept?: string) => void;\n\n /** Controlled mode: add a property to a nested object. */\n onAddChildProperty?: (parentId: string, type: PropertyType, concept?: string) => void;\n\n /** Controlled mode: remove a property. */\n onDeleteProperty?: (propertyId: string) => void;\n\n /** Controlled mode: rename a property. The name is already checked. */\n onRenameProperty?: (propertyId: string, name: string) => void;\n\n /** Controlled mode: change the type of a property. */\n onChangePropertyType?: (propertyId: string, type: PropertyType, concept?: string) => void;\n\n /** Controlled mode: make a property the key of its object, or clear it when it already is. */\n onSetKeyProperty?: (propertyId: string) => void;\n\n /** Controlled mode: set whether a property must be present. */\n onSetRequiredProperty?: (propertyId: string, isRequired: boolean) => void;\n\n /**\n * The concepts a property can be typed as, offered after the primitive types. Takes precedence over the\n * concepts of a surrounding {@link PropertyConceptsProvider}.\n */\n concepts?: PropertyConcept[];\n\n /**\n * Offers the key toggle. `true` offers it on every property; a function decides per property, for example\n * `(property, context) => context.depth > 0` to leave the root properties out. Off by default, except in\n * controlled mode, where supplying `onSetKeyProperty` implies `true` unless this is explicitly `false`.\n */\n allowKeyProperty?: boolean | ((property: Property, context: SchemaPropertyContext) => boolean);\n\n /**\n * Offers the toggle for whether a property must be present (the `required` list). Off by default, except in\n * controlled mode, where supplying `onSetRequiredProperty` implies `true` unless this is explicitly `false`.\n */\n allowRequired?: boolean;\n\n /** Offers no edits at all: the tree is shown, and only selection and the host's slots remain. */\n readOnly?: boolean;\n\n /** Decides which properties can be neither renamed nor removed. By default none. */\n isPropertyProtected?: (property: Property) => boolean;\n\n /**\n * Extra check of a new name, after the editor has rejected blank, reserved and duplicate names.\n * Return the message to show, or `undefined` to accept the name.\n */\n validatePropertyName?: (name: string, property: Property, siblings: Property[]) => string | undefined;\n\n /** The id of the property to mark as selected. */\n selectedPropertyId?: string | null;\n\n /** Called when a property's row is clicked, or its name is activated from the keyboard. */\n onPropertyClick?: (propertyId: string) => void;\n\n /** Content above the properties, for example the title of the schema. Rendered inside the editor's root, so a host that needs a full-bleed header places its own outside the editor. */\n header?: ReactNode;\n\n /** Content beside the add button, for example further actions. */\n footer?: ReactNode;\n\n /** Content at the start of every row, before the name; for example a connector to drag from or onto. */\n renderPropertyLeading?: (property: Property, context: SchemaPropertyContext) => ReactNode;\n\n /** Content at the end of every row, before the remove button; for example a button that opens rules. */\n renderPropertyAccessory?: (property: Property, context: SchemaPropertyContext) => ReactNode;\n\n /** Content under every row, above its nested properties; for example the rules of the property. Nothing is rendered for `null`, `undefined` and `false`. */\n renderPropertyDetails?: (property: Property, context: SchemaPropertyContext) => ReactNode;\n\n /** Styles and marks the row of a property: extra class names, `data-*` attributes, a tooltip, and whether its type is locked. */\n getPropertyRowState?: (property: Property, context: SchemaPropertyContext) => SchemaPropertyRowState | undefined;\n\n /**\n * Replaces or wraps the badge that shows a property's type. Receives the badge the editor would render, so a\n * host can return it unchanged, wrap it, or render something else. The badge carries `data-property-type`\n * for styling per type.\n */\n renderPropertyTypeBadge?: (property: Property, context: SchemaPropertyContext, defaultBadge: ReactNode) => ReactNode;\n\n /** Replaces any of the editor's strings. Unset ones stay English. */\n labels?: Partial<SchemaEditorLabels>;\n\n /** Accessible name of the editor. Defaults to the `schema` label. */\n 'aria-label'?: string;\n\n /** Id of the element that names the editor. */\n 'aria-labelledby'?: string;\n\n /** Extra class name for the root. */\n className?: string;\n\n /** Attributes for the stable parts of the editor. */\n pt?: SchemaEditorParts;\n}\n\nconst never = () => false;\n\n/**\n * The tree layout of the {@link SchemaEditor} (`layout='tree'`). Edits the properties of a JSON Schema as a tree: names, types, nested objects and lists of objects, and\n * optionally concepts, the key, and whether a property is required.\n *\n * Pass a `schema` and the editor keeps the tree and reports the resulting schema, or pass `properties` and\n * handle each edit yourself. Everything specific to a product — rules, mapping connectors, its own chrome — is\n * attached through the slots (`header`, `footer`, `renderPropertyLeading`, `renderPropertyAccessory`,\n * `renderPropertyDetails`, `renderPropertyTypeBadge`) and `getPropertyRowState`.\n */\nexport const TreeSchemaEditor = ({\n schema,\n onChange,\n onPropertiesChange,\n onPropertyRemoved,\n onPropertyRenamed,\n properties: controlledProperties,\n onAddProperty,\n onAddChildProperty,\n onDeleteProperty,\n onRenameProperty,\n onChangePropertyType,\n onSetKeyProperty,\n onSetRequiredProperty,\n concepts: suppliedConcepts,\n allowKeyProperty,\n allowRequired,\n readOnly = false,\n isPropertyProtected,\n validatePropertyName,\n selectedPropertyId,\n onPropertyClick,\n header,\n footer,\n renderPropertyLeading,\n renderPropertyAccessory,\n renderPropertyDetails,\n getPropertyRowState,\n renderPropertyTypeBadge,\n labels: suppliedLabels,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className,\n pt,\n}: TreeSchemaEditorProps) => {\n const labels = useMemo(() => resolveSchemaEditorLabels(suppliedLabels), [suppliedLabels]);\n const providedConcepts = useOptionalPropertyConcepts();\n const concepts = suppliedConcepts ?? providedConcepts;\n const isControlled = controlledProperties !== undefined;\n const [ownedProperties, setOwnedProperties] = useState<Property[]>(() => jsonSchemaToProperties(schema));\n // The latest tree, kept synchronously so two edits in one event apply one after the other.\n const latest = useRef(ownedProperties);\n useEffect(() => { latest.current = ownedProperties; }, [ownedProperties]);\n const properties = isControlled ? controlledProperties : ownedProperties;\n\n // A schema from outside replaces the tree only when it says something the editor does not already show:\n // handing back what was reported, or the same schema again, must not throw away the property ids.\n const incomingSchema = schema === undefined ? undefined : JSON.stringify(schema);\n const [seenSchema, setSeenSchema] = useState(incomingSchema);\n if (!isControlled && incomingSchema !== seenSchema) {\n setSeenSchema(incomingSchema);\n if (schema !== undefined && incomingSchema !== JSON.stringify(propertiesToJsonSchema(ownedProperties))) {\n setOwnedProperties(jsonSchemaToProperties(schema));\n }\n }\n\n const apply = (next: Property[]) => {\n latest.current = next;\n setOwnedProperties(next);\n onChange?.(propertiesToJsonSchema(next), { source: 'user' });\n onPropertiesChange?.(next);\n };\n\n const ownedOperations: SchemaEditorOperations = {\n addChild: (parentId, type, concept) =>\n apply(addChildProperty(latest.current, parentId, type, totalPropertyCount(latest.current), concept)),\n remove: propertyId => {\n const removed = findPropertyById(latest.current, propertyId);\n apply(removeProperty(latest.current, propertyId));\n if (removed) onPropertyRemoved?.(removed);\n },\n rename: (propertyId, name) => {\n const previousName = findPropertyById(latest.current, propertyId)?.name;\n const next = renameProperty(latest.current, propertyId, name);\n apply(next);\n const renamed = findPropertyById(next, propertyId);\n if (renamed && previousName !== undefined) onPropertyRenamed?.(renamed, previousName);\n },\n changeType: (propertyId, type, concept) => apply(changePropertyType(latest.current, propertyId, type, concept)),\n setKey: propertyId => apply(setKeyProperty(latest.current, propertyId)),\n setRequired: (propertyId, isRequired) => apply(setRequiredProperty(latest.current, propertyId, isRequired)),\n };\n\n const controlledOperations: SchemaEditorOperations = {\n addChild: onAddChildProperty,\n remove: onDeleteProperty,\n rename: onRenameProperty,\n changeType: onChangePropertyType,\n setKey: onSetKeyProperty,\n setRequired: onSetRequiredProperty,\n };\n\n const operations = isControlled ? controlledOperations : ownedOperations;\n const addRoot = isControlled\n ? onAddProperty\n : (type: PropertyType, concept?: string) =>\n apply(addProperty(latest.current, type, totalPropertyCount(latest.current), concept));\n\n // In controlled mode a toggle callback implies its allow flag, unless the host set the flag to false.\n const keyAllowance = allowKeyProperty ?? (isControlled && onSetKeyProperty !== undefined);\n const isKeyAllowed = typeof keyAllowance === 'function'\n ? keyAllowance\n : keyAllowance ? () => true : never;\n const isRequiredAllowed = allowRequired ?? (isControlled && onSetRequiredProperty !== undefined);\n\n const contextValue: SchemaEditorContextValue = {\n labels,\n parts: pt,\n properties,\n concepts,\n readOnly,\n operations,\n selectedPropertyId,\n onPropertyClick,\n isKeyAllowed,\n isRequiredAllowed,\n isProtected: isPropertyProtected ?? never,\n validateName: validatePropertyName,\n getRowState: getPropertyRowState,\n renderLeading: renderPropertyLeading,\n renderAccessory: renderPropertyAccessory,\n renderDetails: renderPropertyDetails,\n renderTypeBadge: renderPropertyTypeBadge,\n };\n\n return (\n <SchemaEditorContext.Provider value={contextValue}>\n <div\n {...pt?.root}\n role='group'\n aria-label={ariaLabelledBy ? undefined : ariaLabel ?? labels.schema}\n aria-labelledby={ariaLabelledBy}\n className={['cratis-schema-editor', pt?.root?.className, className].filter(Boolean).join(' ')}\n data-cratis-part='root'\n data-readonly={readOnly || undefined}\n >\n {header && (\n <div {...pt?.header} className={`cratis-schema-editor__header ${pt?.header?.className ?? ''}`} data-cratis-part='header'>\n {header}\n </div>\n )}\n\n {properties.length === 0 ? (\n <p {...pt?.empty} className={`cratis-schema-editor__empty ${pt?.empty?.className ?? ''}`} data-cratis-part='empty'>\n {labels.emptyMessage}\n </p>\n ) : (\n <ul {...pt?.list} className={`cratis-schema-editor__list ${pt?.list?.className ?? ''}`} data-cratis-part='list'>\n {properties.map(property => (\n <SchemaPropertyRow key={property.id} property={property} siblings={properties} depth={0} />\n ))}\n </ul>\n )}\n\n {(footer || (!readOnly && addRoot)) && (\n <div className='cratis-schema-editor__actions'>\n {!readOnly && addRoot && (\n <PropertyTypeMenu\n labels={labels}\n concepts={concepts}\n triggerPart='add'\n triggerLabel={labels.addProperty}\n parts={pt}\n onSelect={addRoot}\n >\n <FaPlus aria-hidden='true' />\n {labels.addProperty}\n </PropertyTypeMenu>\n )}\n {footer && (\n <div {...pt?.footer} className={`cratis-schema-editor__footer ${pt?.footer?.className ?? ''}`} data-cratis-part='footer'>\n {footer}\n </div>\n )}\n </div>\n )}\n </div>\n </SchemaEditorContext.Provider>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;AAiKA,MAAM,KAAK,GAAG,MAAM,KAAK;AAWlB,MAAM,gBAAgB,GAAG,CAAC,EAC7B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AC5B,MAAM,CAAC,WAAW,CAAA,EAAA,CACJ,CACtB,EACA,MAAM,KACHA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA,6BAAA,EAAgC,EAAE,EAAE,MAAM,EAAE,SAAS,IAAI,EAAE,CAAA,CAAE,EAAA,kBAAA,EAAmB,QAAQ,EAAA,QAAA,EACnH,MAAM,EAAA,CACL,CACT,CAAA,EAAA,CACC,CACT,CAAA,EAAA,CACC,EAAA,CACqB;AAEvC;;"}
|
|
1
|
+
{"version":3,"file":"TreeSchemaEditor.js","sources":["../../../../SchemaEditor/Tree/TreeSchemaEditor.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, useMemo, useRef, useState, type ReactNode } from 'react';\nimport { FaPlus } from 'react-icons/fa6';\nimport type { ChangeHandler } from '../../types/ChangeHandler';\nimport type { JsonSchema } from '../../types/JsonSchema';\nimport type { Property } from './Property';\nimport type { PropertyConcept } from './PropertyConcept';\nimport { useOptionalPropertyConcepts } from './PropertyConceptsContext';\nimport { PropertyType } from './PropertyType';\nimport { findPropertyById } from './propertyTree';\nimport { PropertyTypeMenu } from './PropertyTypeMenu';\nimport {\n addChildProperty,\n addProperty,\n changePropertyType,\n jsonSchemaToProperties,\n propertiesToJsonSchema,\n removeProperty,\n renameProperty,\n setKeyProperty,\n setGeneratedProperty,\n setRequiredProperty,\n} from './schemaConversion';\nimport { SchemaEditorContext, type SchemaEditorContextValue, type SchemaEditorOperations } from './SchemaEditorContext';\nimport type { SchemaEditorLabels } from '../SchemaEditorLabels';\nimport type { SchemaEditorParts } from './SchemaEditorParts';\nimport { resolveSchemaEditorLabels } from '../resolveSchemaEditorLabels';\nimport type { SchemaPropertyContext } from './SchemaPropertyContext';\nimport type { SchemaPropertyRowState } from './SchemaPropertyRowState';\nimport { SchemaPropertyRow } from './SchemaPropertyRow';\nimport { totalPropertyCount } from './propertyTree';\n\n/** The props of the tree layout of the {@link SchemaEditor}. */\nexport interface TreeSchemaEditorProps {\n /**\n * The JSON Schema to edit. The editor converts it, keeps the edited property tree itself and reports every\n * edit through {@link TreeSchemaEditorProps.onChange}. Passing the reported schema back, or the same schema\n * again, changes nothing; passing a schema that differs from both replaces the tree and its property ids.\n * Ignored when `properties` is given.\n */\n schema?: JsonSchema;\n\n /** Called with the complete schema after every edit. Only used when the editor owns the property tree. */\n onChange?: ChangeHandler<JsonSchema>;\n\n /** Called with the property tree after every edit, so a host can follow the ids. Only used when the editor owns the property tree. */\n onPropertiesChange?: (properties: Property[]) => void;\n\n /** Called after a property was removed, with the property and everything nested under it. Only used when the editor owns the property tree. */\n onPropertyRemoved?: (property: Property) => void;\n\n /** Called after a property was renamed, with the renamed property and the name it had. Only used when the editor owns the property tree. */\n onPropertyRenamed?: (property: Property, previousName: string) => void;\n\n /**\n * The property tree to show. When given, the editor is controlled: it changes nothing itself and each edit\n * is offered through the matching `onAddProperty`, `onDeleteProperty`… callback, which the host applies.\n * An edit without a callback is not offered.\n */\n properties?: Property[];\n\n /** Controlled mode: add a property to the root. */\n onAddProperty?: (type: PropertyType, concept?: string) => void;\n\n /** Controlled mode: add a property to a nested object. */\n onAddChildProperty?: (parentId: string, type: PropertyType, concept?: string) => void;\n\n /** Controlled mode: remove a property. */\n onDeleteProperty?: (propertyId: string) => void;\n\n /** Controlled mode: rename a property. The name is already checked. */\n onRenameProperty?: (propertyId: string, name: string) => void;\n\n /** Controlled mode: change the type of a property. */\n onChangePropertyType?: (propertyId: string, type: PropertyType, concept?: string) => void;\n\n /** Controlled mode: make a property the key of its object, or clear it when it already is. */\n onSetKeyProperty?: (propertyId: string) => void;\n\n /** Controlled mode: set whether a property's value is generated. Implies allowGeneratedProperty unless explicitly false. */\n onSetGeneratedProperty?: (propertyId: string, isGenerated: boolean) => void;\n\n /** Controlled mode: set whether a property must be present. */\n onSetRequiredProperty?: (propertyId: string, isRequired: boolean) => void;\n\n /**\n * The concepts a property can be typed as, offered after the primitive types. Takes precedence over the\n * concepts of a surrounding {@link PropertyConceptsProvider}.\n */\n concepts?: PropertyConcept[];\n\n /**\n * Offers the key toggle. `true` offers it on every property; a function decides per property, for example\n * `(property, context) => context.depth > 0` to leave the root properties out. Off by default, except in\n * controlled mode, where supplying `onSetKeyProperty` implies `true` unless this is explicitly `false`.\n */\n allowKeyProperty?: boolean | ((property: Property, context: SchemaPropertyContext) => boolean);\n\n /**\n * Offers the Generated toggle on every property, or on properties accepted by the predicate. Off by default;\n * a controlled onSetGeneratedProperty callback implies true unless explicitly false. The table layout ignores it.\n */\n allowGeneratedProperty?: boolean | ((property: Property, context: SchemaPropertyContext) => boolean);\n\n /**\n * Offers the toggle for whether a property must be present (the `required` list). Off by default, except in\n * controlled mode, where supplying `onSetRequiredProperty` implies `true` unless this is explicitly `false`.\n */\n allowRequired?: boolean;\n\n /** Offers no edits at all: the tree is shown, and only selection and the host's slots remain. */\n readOnly?: boolean;\n\n /** Decides which properties can be neither renamed nor removed. By default none. */\n isPropertyProtected?: (property: Property) => boolean;\n\n /**\n * Extra check of a new name, after the editor has rejected blank, reserved and duplicate names.\n * Return the message to show, or `undefined` to accept the name.\n */\n validatePropertyName?: (name: string, property: Property, siblings: Property[]) => string | undefined;\n\n /** The id of the property to mark as selected. */\n selectedPropertyId?: string | null;\n\n /** Called when a property's row is clicked, or its name is activated from the keyboard. */\n onPropertyClick?: (propertyId: string) => void;\n\n /** Content above the properties, for example the title of the schema. Rendered inside the editor's root, so a host that needs a full-bleed header places its own outside the editor. */\n header?: ReactNode;\n\n /** Content beside the add button, for example further actions. */\n footer?: ReactNode;\n\n /** Content at the start of every row, before the name; for example a connector to drag from or onto. */\n renderPropertyLeading?: (property: Property, context: SchemaPropertyContext) => ReactNode;\n\n /** Content at the end of every row, before the remove button; for example a button that opens rules. */\n renderPropertyAccessory?: (property: Property, context: SchemaPropertyContext) => ReactNode;\n\n /** Content under every row, above its nested properties; for example the rules of the property. Nothing is rendered for `null`, `undefined` and `false`. */\n renderPropertyDetails?: (property: Property, context: SchemaPropertyContext) => ReactNode;\n\n /** Styles and marks the row of a property: extra class names, `data-*` attributes, a tooltip, and whether its type is locked. */\n getPropertyRowState?: (property: Property, context: SchemaPropertyContext) => SchemaPropertyRowState | undefined;\n\n /**\n * Replaces or wraps the badge that shows a property's type. Receives the badge the editor would render, so a\n * host can return it unchanged, wrap it, or render something else. The badge carries `data-property-type`\n * for styling per type.\n */\n renderPropertyTypeBadge?: (property: Property, context: SchemaPropertyContext, defaultBadge: ReactNode) => ReactNode;\n\n /** Replaces any of the editor's strings. Unset ones stay English. */\n labels?: Partial<SchemaEditorLabels>;\n\n /** Accessible name of the editor. Defaults to the `schema` label. */\n 'aria-label'?: string;\n\n /** Id of the element that names the editor. */\n 'aria-labelledby'?: string;\n\n /** Extra class name for the root. */\n className?: string;\n\n /** Attributes for the stable parts of the editor. */\n pt?: SchemaEditorParts;\n}\n\nconst never = () => false;\n\nfunction allowance(flag: TreeSchemaEditorProps['allowKeyProperty'], callback: unknown, isControlled: boolean) {\n const allowed = flag ?? (isControlled && callback !== undefined);\n if (typeof allowed === 'function') return allowed;\n return allowed ? () => true : never;\n}\n\n/**\n * The tree layout of the {@link SchemaEditor} (`layout='tree'`). Edits the properties of a JSON Schema as a tree: names, types, nested objects and lists of objects, and\n * optionally concepts, the key, and whether a property is required.\n *\n * Pass a `schema` and the editor keeps the tree and reports the resulting schema, or pass `properties` and\n * handle each edit yourself. Everything specific to a product — rules, mapping connectors, its own chrome — is\n * attached through the slots (`header`, `footer`, `renderPropertyLeading`, `renderPropertyAccessory`,\n * `renderPropertyDetails`, `renderPropertyTypeBadge`) and `getPropertyRowState`.\n */\nexport const TreeSchemaEditor = ({\n schema,\n onChange,\n onPropertiesChange,\n onPropertyRemoved,\n onPropertyRenamed,\n properties: controlledProperties,\n onAddProperty,\n onAddChildProperty,\n onDeleteProperty,\n onRenameProperty,\n onChangePropertyType,\n onSetKeyProperty,\n onSetGeneratedProperty,\n onSetRequiredProperty,\n concepts: suppliedConcepts,\n allowKeyProperty,\n allowGeneratedProperty,\n allowRequired,\n readOnly = false,\n isPropertyProtected,\n validatePropertyName,\n selectedPropertyId,\n onPropertyClick,\n header,\n footer,\n renderPropertyLeading,\n renderPropertyAccessory,\n renderPropertyDetails,\n getPropertyRowState,\n renderPropertyTypeBadge,\n labels: suppliedLabels,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n className,\n pt,\n}: TreeSchemaEditorProps) => {\n const labels = useMemo(() => resolveSchemaEditorLabels(suppliedLabels), [suppliedLabels]);\n const providedConcepts = useOptionalPropertyConcepts();\n const concepts = suppliedConcepts ?? providedConcepts;\n const isControlled = controlledProperties !== undefined;\n const [ownedProperties, setOwnedProperties] = useState<Property[]>(() => jsonSchemaToProperties(schema));\n // The latest tree, kept synchronously so two edits in one event apply one after the other.\n const latest = useRef(ownedProperties);\n useEffect(() => { latest.current = ownedProperties; }, [ownedProperties]);\n const properties = isControlled ? controlledProperties : ownedProperties;\n\n // A schema from outside replaces the tree only when it says something the editor does not already show:\n // handing back what was reported, or the same schema again, must not throw away the property ids.\n const incomingSchema = schema === undefined ? undefined : JSON.stringify(schema);\n const [seenSchema, setSeenSchema] = useState(incomingSchema);\n if (!isControlled && incomingSchema !== seenSchema) {\n setSeenSchema(incomingSchema);\n if (schema !== undefined && incomingSchema !== JSON.stringify(propertiesToJsonSchema(ownedProperties, schema))) {\n setOwnedProperties(jsonSchemaToProperties(schema));\n }\n }\n\n const apply = (next: Property[]) => {\n latest.current = next;\n setOwnedProperties(next);\n onChange?.(propertiesToJsonSchema(next, schema), { source: 'user' });\n onPropertiesChange?.(next);\n };\n\n const ownedOperations: SchemaEditorOperations = {\n addChild: (parentId, type, concept) =>\n apply(addChildProperty(latest.current, parentId, type, totalPropertyCount(latest.current), concept)),\n remove: propertyId => {\n const removed = findPropertyById(latest.current, propertyId);\n apply(removeProperty(latest.current, propertyId));\n if (removed) onPropertyRemoved?.(removed);\n },\n rename: (propertyId, name) => {\n const previousName = findPropertyById(latest.current, propertyId)?.name;\n const next = renameProperty(latest.current, propertyId, name);\n apply(next);\n const renamed = findPropertyById(next, propertyId);\n if (renamed && previousName !== undefined) onPropertyRenamed?.(renamed, previousName);\n },\n changeType: (propertyId, type, concept) => apply(changePropertyType(latest.current, propertyId, type, concept)),\n setKey: propertyId => apply(setKeyProperty(latest.current, propertyId)),\n setGenerated: (propertyId, isGenerated) => apply(setGeneratedProperty(latest.current, propertyId, isGenerated)),\n setRequired: (propertyId, isRequired) => apply(setRequiredProperty(latest.current, propertyId, isRequired)),\n };\n\n const controlledOperations: SchemaEditorOperations = {\n addChild: onAddChildProperty,\n remove: onDeleteProperty,\n rename: onRenameProperty,\n changeType: onChangePropertyType,\n setKey: onSetKeyProperty,\n setGenerated: onSetGeneratedProperty,\n setRequired: onSetRequiredProperty,\n };\n\n const operations = isControlled ? controlledOperations : ownedOperations;\n const addRoot = isControlled\n ? onAddProperty\n : (type: PropertyType, concept?: string) =>\n apply(addProperty(latest.current, type, totalPropertyCount(latest.current), concept));\n\n const contextValue: SchemaEditorContextValue = {\n labels,\n parts: pt,\n properties,\n concepts,\n readOnly,\n operations,\n selectedPropertyId,\n onPropertyClick,\n isKeyAllowed: allowance(allowKeyProperty, onSetKeyProperty, isControlled),\n isGeneratedAllowed: allowance(allowGeneratedProperty, onSetGeneratedProperty, isControlled),\n isRequiredAllowed: allowRequired ?? (isControlled && onSetRequiredProperty !== undefined),\n isProtected: isPropertyProtected ?? never,\n validateName: validatePropertyName,\n getRowState: getPropertyRowState,\n renderLeading: renderPropertyLeading,\n renderAccessory: renderPropertyAccessory,\n renderDetails: renderPropertyDetails,\n renderTypeBadge: renderPropertyTypeBadge,\n };\n\n return (\n <SchemaEditorContext.Provider value={contextValue}>\n <div\n {...pt?.root}\n role='group'\n aria-label={ariaLabelledBy ? undefined : ariaLabel ?? labels.schema}\n aria-labelledby={ariaLabelledBy}\n className={['cratis-schema-editor', pt?.root?.className, className].filter(Boolean).join(' ')}\n data-cratis-part='root'\n data-readonly={readOnly || undefined}\n >\n {header && (\n <div {...pt?.header} className={`cratis-schema-editor__header ${pt?.header?.className ?? ''}`} data-cratis-part='header'>\n {header}\n </div>\n )}\n\n {properties.length === 0 ? (\n <p {...pt?.empty} className={`cratis-schema-editor__empty ${pt?.empty?.className ?? ''}`} data-cratis-part='empty'>\n {labels.emptyMessage}\n </p>\n ) : (\n <ul {...pt?.list} className={`cratis-schema-editor__list ${pt?.list?.className ?? ''}`} data-cratis-part='list'>\n {properties.map(property => (\n <SchemaPropertyRow key={property.id} property={property} siblings={properties} depth={0} />\n ))}\n </ul>\n )}\n\n {(footer || (!readOnly && addRoot)) && (\n <div className='cratis-schema-editor__actions'>\n {!readOnly && addRoot && (\n <PropertyTypeMenu\n labels={labels}\n concepts={concepts}\n triggerPart='add'\n triggerLabel={labels.addProperty}\n parts={pt}\n onSelect={addRoot}\n >\n <FaPlus aria-hidden='true' />\n {labels.addProperty}\n </PropertyTypeMenu>\n )}\n {footer && (\n <div {...pt?.footer} className={`cratis-schema-editor__footer ${pt?.footer?.className ?? ''}`} data-cratis-part='footer'>\n {footer}\n </div>\n )}\n </div>\n )}\n </div>\n </SchemaEditorContext.Provider>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;AA2KA,MAAM,KAAK,GAAG,MAAM,KAAK;AAEzB,SAAS,SAAS,CAAC,IAA+C,EAAE,QAAiB,EAAE,YAAqB,EAAA;IACxG,MAAM,OAAO,GAAG,IAAI,KAAK,YAAY,IAAI,QAAQ,KAAK,SAAS,CAAC;IAChE,IAAI,OAAO,OAAO,KAAK,UAAU;AAAE,QAAA,OAAO,OAAO;AACjD,IAAA,OAAO,OAAO,GAAG,MAAM,IAAI,GAAG,KAAK;AACvC;AAWO,MAAM,gBAAgB,GAAG,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,iBAAi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AAE,OAAO,EAAA,QAAA,EAAA,CAEjBD,GAAA,CAAC,MAAM,EAAA,EAAA,aAAA,EAAa,MAAM,EAAA,CAAG,EAC5B,MAAM,CAAC,WAAW,CAAA,EAAA,CACJ,CACtB,EACA,MAAM,KACHA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA,6BAAA,EAAgC,EAAE,EAAE,MAAM,EAAE,SAAS,IAAI,EAAE,CAAA,CAAE,EAAA,kBAAA,EAAmB,QAAQ,EAAA,QAAA,EACnH,MAAM,EAAA,CACL,CACT,CAAA,EAAA,CACC,CACT,CAAA,EAAA,CACC,EAAA,CACqB;AAEvC;;"}
|
|
@@ -12,6 +12,8 @@ export declare const CONCEPT_KEYWORD = "x-concept";
|
|
|
12
12
|
* property; at most one property of an object carries it.
|
|
13
13
|
*/
|
|
14
14
|
export declare const KEY_KEYWORD = "x-key";
|
|
15
|
+
/** The JSON Schema keyword marking a value generated when the command runs rather than entered. */
|
|
16
|
+
export declare const GENERATED_KEYWORD = "x-generated";
|
|
15
17
|
/**
|
|
16
18
|
* Converts a JSON Schema object into a property tree. Generates a new id for every property.
|
|
17
19
|
* @param schema The schema to read; `undefined` and schemas without properties give an empty tree.
|
|
@@ -20,11 +22,13 @@ export declare const KEY_KEYWORD = "x-key";
|
|
|
20
22
|
export declare function jsonSchemaToProperties(schema: JsonSchema | undefined): Property[];
|
|
21
23
|
/**
|
|
22
24
|
* Converts a property tree into a JSON Schema object. Empty `required` lists are omitted, and a property
|
|
23
|
-
* typed as a concept or marked as the key carries the `x-concept` and `x-key` keywords.
|
|
25
|
+
* typed as a concept or marked as the key carries the `x-concept` and `x-key` keywords. Vendor keywords are
|
|
26
|
+
* preserved on properties and array items; generated values carry `x-generated: true`.
|
|
24
27
|
* @param properties The root properties.
|
|
28
|
+
* @param base The incoming schema. Root keys other than type, properties and required are preserved.
|
|
25
29
|
* @returns The schema.
|
|
26
30
|
*/
|
|
27
|
-
export declare function propertiesToJsonSchema(properties: Property[]): JsonSchema;
|
|
31
|
+
export declare function propertiesToJsonSchema(properties: Property[], base?: JsonSchema): JsonSchema;
|
|
28
32
|
/**
|
|
29
33
|
* Appends a property to the root.
|
|
30
34
|
* @param properties The root properties.
|
|
@@ -61,7 +65,7 @@ export declare function removeProperty(properties: Property[], targetId: string)
|
|
|
61
65
|
export declare function renameProperty(properties: Property[], targetId: string, newName: string): Property[];
|
|
62
66
|
/**
|
|
63
67
|
* Changes the type of a property. Choosing a plain primitive drops the concept; choosing an object or
|
|
64
|
-
* object list keeps the children, and any other type drops them.
|
|
68
|
+
* object list keeps the children, and any other type drops them. A different item kind clears item metadata.
|
|
65
69
|
* @param properties The root properties.
|
|
66
70
|
* @param targetId The id of the property.
|
|
67
71
|
* @param newType The new type.
|
|
@@ -84,6 +88,14 @@ export declare function toggleRequiredProperty(properties: Property[], targetId:
|
|
|
84
88
|
* @returns The new tree.
|
|
85
89
|
*/
|
|
86
90
|
export declare function setRequiredProperty(properties: Property[], targetId: string, isRequired: boolean): Property[];
|
|
91
|
+
/**
|
|
92
|
+
* Sets whether a property's value is generated. An explicit edit replaces any non-true x-generated value.
|
|
93
|
+
* @param properties The root properties.
|
|
94
|
+
* @param targetId The id of the property.
|
|
95
|
+
* @param isGenerated Whether the value is generated.
|
|
96
|
+
* @returns The new tree.
|
|
97
|
+
*/
|
|
98
|
+
export declare function setGeneratedProperty(properties: Property[], targetId: string, isGenerated: boolean): Property[];
|
|
87
99
|
/**
|
|
88
100
|
* Makes a property the key of its parent object, moving the key when a sibling held it. Choosing the
|
|
89
101
|
* property that already is the key clears it, so an object can also have no key.
|