Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/build/frontend/multi.step.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '5e3d76c791d4c1479bd9');
<?php return array('dependencies' => array(), 'version' => '9457afa85f7e33a36e73');
2 changes: 1 addition & 1 deletion assets/build/frontend/multi.step.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 61 additions & 20 deletions assets/src/frontend/multi.step/PageState.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function PageState( node, state ) {
this.offset = +node.dataset.pageOffset;
this.state = state;
this.inputs = [];
this.inputBindings = new Map();
this.canSwitch = new ReactiveVar( null );
this.isShow = new ReactiveVar( 1 === this.index );

Expand Down Expand Up @@ -117,25 +118,7 @@ PageState.prototype.observeInput = function ( node ) {
*/
const input = node.jfbSync;

this.handleInputEnter( input );

input.loading.watch( () => {
if ( input.loading.current ) {
this.canSwitch.current = false;
}
else {
this.updateState();
}
} );

if ( !input.reporting.restrictions.length ) {
return input;
}

this.inputs.push( input );
input.watchValidity( () => this.updateState() );

return input;
return this.registerInput( input );
};
/**
* Buttons for switching between pages are hidden conditional blocks
Expand Down Expand Up @@ -309,6 +292,64 @@ PageState.prototype.handleInputEnter = function ( input ) {
} );
};

PageState.prototype.registerInput = function (
input,
{ includeInValidation = true } = {},
) {
if ( !input || this.inputBindings.has( input ) ) {
return input;
}

this.handleInputEnter( input );

const clearLoadingWatch = input.loading.watch( () => {
if ( input.loading.current ) {
this.canSwitch.current = false;
}
else {
this.updateState();
}
} );

const binding = {
clearLoadingWatch,
clearValidityWatch: null,
};

if ( input.reporting.restrictions.length ) {
this.inputs.push( input );
binding.clearValidityWatch = input.watchValidity(
() => this.updateState(),
);

if ( !includeInValidation ) {
this.inputs = this.inputs.filter( current => current !== input );
}
}

this.inputBindings.set( input, binding );

return input;
};

PageState.prototype.unregisterInput = function ( input ) {
if ( !this.inputBindings.has( input ) ) {
return;
}

const binding = this.inputBindings.get( input );

binding?.clearLoadingWatch?.();
binding?.clearValidityWatch?.();

this.inputBindings.delete( input );
this.inputs = this.inputs.filter( current => current !== input );
};

PageState.prototype.getTrackedInputs = function () {
return Array.from( this.inputBindings.keys() );
};

PageState.prototype.getOffsetTop = function () {
return getOffsetTop( this.node ) - this.offset;
};
Expand All @@ -323,4 +364,4 @@ PageState.prototype.updateOffsetByProgress = function () {
this.offset += +this.state.progress.node.clientHeight;
};

export default PageState;
export default PageState;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-hooks'), 'version' => '71c674619f1496535237');
<?php return array('dependencies' => array('react', 'wp-hooks'), 'version' => '837b7bd5a587bf6dfcae');
2 changes: 1 addition & 1 deletion modules/blocks-v2/repeater-field/assets/build/editor.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'cfddc8ad525d1e417123');
<?php return array('dependencies' => array(), 'version' => 'af68623a6181673fd69b');
Loading
Loading