Skip to content

Latest commit

 

History

History

src

Just for you known

The react-declarative is not just a form builder. This one is a huge framework with dashboard adaptive cards builder, crud-based List component and more.

Adding a new field type

Make changes by analogy sequentially in the following files

Create a new field

  1. model/IField.ts - Add new field properties

  2. config/createField.tsx - File registration (during execution)

  3. config/initialValue.ts - Default value for the field

  4. config/isStatefull.ts - Mark If you're creating a field, not a layout

  5. model/FieldType.ts - Adding a field entry to enum

  6. model/TypedField.ts - Strong typing declaration for the userspace

Register field slot

  1. components/One/slots/CheckBoxSlot - Duplicate this folder and update naming

  2. components/One/components/ISlotFactoryContext.ts - Update slot context interface

  3. components/One/components/SlotFactory/SlotContext.ts - Update slots context value

Composition hierarchy

In order of composition during execution

  1. IField - Field retrieved from the userspace

  2. IEntity - A field connected to the instance of the One component

  3. IManaged - A wrapper over the change callback and the current object, designed to prevent recursive repaints and provide a convenient api for a field developer

IMPORTANT: TypedField only checks at the time of static type checking. The internal implementation of the One component performs exactly the composition of objects without any typecheck

Also The Field Type.Init allows defaultValue the value for Field Type.Component fields if it emits several properties in onChange object. The FieldType.Phony keeps the field without any defaultValue so Object.keys(data) will not see It