@@ -506,6 +506,57 @@ function transformSchemaIntoTree(node, rootNode, config) {
506506 return rootNode ;
507507}
508508
509+ var BlinkformsClient = /** @class */ ( function ( ) {
510+ function BlinkformsClient ( ) {
511+ this . tree = null ;
512+ this . state = null ;
513+ this . stateTransformers = [ ] ;
514+ this . contextUpdateHandlers = [ ] ;
515+ this . contextTransformers = [ ] ;
516+ this . rootConfig = { } ;
517+ }
518+ BlinkformsClient . prototype . configure = function ( conf ) {
519+ this . rootConfig = ( __assign ( { } , this . rootConfig , conf ) ) ;
520+ } ;
521+ BlinkformsClient . prototype . registerHandlers = function ( handlers ) {
522+ var newHandlers = __assign ( { } , this . rootConfig . handlers ) ;
523+ Object . keys ( handlers ) . forEach ( function ( key ) {
524+ newHandlers [ key ] = __assign ( { } , newHandlers [ key ] , handlers [ key ] ) ;
525+ } ) ;
526+ this . rootConfig = ( __assign ( { } , this . rootConfig , { handlers : __assign ( { } , this . rootConfig . handlers , newHandlers ) } ) ) ;
527+ } ;
528+ BlinkformsClient . prototype . handleFormStateUpdate = function ( state , root ) {
529+ var _this = this ;
530+ this . state = state ;
531+ this . stateTransformers . forEach ( function ( t ) {
532+ _this . state = t ( _this . state , root ) ;
533+ } ) ;
534+ } ;
535+ BlinkformsClient . prototype . handleFormContextUpdate = function ( context , source ) {
536+ this . contextUpdateHandlers . forEach ( function ( t ) {
537+ t ( context , source ) ;
538+ } ) ;
539+ } ;
540+ BlinkformsClient . prototype . handleFormContextMapping = function ( fn , source ) {
541+ this . contextTransformers . forEach ( function ( t ) {
542+ t ( fn , source ) ;
543+ } ) ;
544+ } ;
545+ BlinkformsClient . prototype . render = function ( schema , options ) {
546+ var _this = this ;
547+ if ( options === void 0 ) { options = null ; }
548+ this . tree = transformSchemaIntoTree ( schema , null , __assign ( { rootSetState : function ( state , root ) { return _this . handleFormStateUpdate ( state , root ) ; } , rootSetContext : function ( context , source ) { return _this . handleFormContextUpdate ( context , source ) ; } , rootModifyContext : function ( fn , source ) { return _this . handleFormContextMapping ( fn , source ) ; } , rootState : { } } , this . rootConfig , options ) ) ;
549+ return this ;
550+ } ;
551+ BlinkformsClient . prototype . getTree = function ( ) {
552+ return this . tree ;
553+ } ;
554+ BlinkformsClient . prototype . getState = function ( ) {
555+ return this . state ;
556+ } ;
557+ return BlinkformsClient ;
558+ } ( ) ) ;
559+
509560var CompositeNode = /** @class */ ( function ( _super ) {
510561 __extends ( CompositeNode , _super ) ;
511562 function CompositeNode ( ) {
@@ -593,4 +644,4 @@ var SimpleNode = /** @class */ (function (_super) {
593644 return SimpleNode ;
594645} ( Node ) ) ;
595646
596- export { CompositeNode , SimpleNode , defaultParserConfig , recTransformSchemaIntoTree , isNodeMetaOutputValue , getMetaOutputSourceNodeByPath , transformOutputToRawData , validateRoot , transformSchemaIntoTree , NodeType , Node , RootNode , isNodeErrorPure } ;
647+ export { BlinkformsClient , CompositeNode , SimpleNode , defaultParserConfig , recTransformSchemaIntoTree , isNodeMetaOutputValue , getMetaOutputSourceNodeByPath , transformOutputToRawData , validateRoot , transformSchemaIntoTree , NodeType , Node , RootNode , isNodeErrorPure } ;
0 commit comments