createProperty - bettyblocks/cli GitHub Wiki
If you want to create a new property via the onDrop/addChild modal of a component, you can add the createProperty
key to the configuration of a property option like this:
import { CreatePropertyKind } from '@betty-blocks/component-sdk';
property: property('Question', {
value: '',
ref: { id: '#numberInputProperty' },
configuration: {
createProperty: {
type: CreatePropertyKind.INTEGER,
},
allowedKinds: ['INTEGER', 'PRICE'],
disabled: true,
},
showInAddChild: true,
}),
This key will show an input field instead of the property selector with the option to switch to the property selector. When the user fills in this input, a new property will be created with that name.
When a user wants to select an existing property, allowedKinds
will ensure he can only select the defined kinds INTEGER
or PRICE
in this case.