This package will be used in the Caldera Forms admin for:
See: https://github.com/CalderaWP/Caldera-Forms/issues/3435
This project was bootstrapped with TSDX.
Install with Yarn:
yarn add @calderajs/cf-editor-stateInstall With npm
npm i @calderajs/cf-editor-stateThe API documentation, which is generated using typedoc is avaible at http://cf-editor-state.saturdaydev.com/
import cfEditorState from 'this-package';
const state = cfEditorState();
state.addConditional({ type: 'disable', ID: 'c1' });
state.updateConditonal({ type: 'enable', ID: 'c1' });
state.removeConditonal('c1');
import cfEditorState from 'this-package';
const state = cfEditorState();
//Add one field
state.addField({
ID: 'fld3',
tag: '3',
slug: 'three',
label: 'Three',
});
//Get all the fields
console.log(state.getAllFields());
//Change the field
state.updateField({
ID: 'fld3',
tag: 'three',
slug: 'three',
label: 'Option Three',
});
//Get updated field
console.log(state.getField('fld3'));
//Remove field
state.removeField('fld3');
Processor's can add have magic tags. When a processor is added, it will add a magic tag type. And when a processor is removed, it will remove that tag type.
import cfEditorState from 'this-package';
const state = cfEditorState();
state.addMagicType(
//name of procersor
'special_payment',
//processors use brackets for magic tags
true,
//the processor's magic tags
[
{ tag: 'transaction_id', type: 'string' },
{ tag: 'transaction_status', type: 'string' },
]
);
//Remove a processor's magic tag types:
state.removeMagicTagType('special_payment');
Below is a list of commands you will probably find useful.
yarn startRuns the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.
Your library will be rebuilt if you make edits.
yarn buildBundles the package to the dist folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
yarn testRuns the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.
Or: yarn test --watchAll
yarn docsGenerate documentation site.
Generated using TypeDoc