Skip to content

Commit

Permalink
Adding more jsdocs.
Browse files Browse the repository at this point in the history
  • Loading branch information
travist committed Apr 25, 2024
1 parent be3876b commit 8d20d51
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@formio/js",
"version": "5.0.0-rc.46",
"version": "5.0.0-rc.47",
"description": "JavaScript powered Forms with JSON Form Builder",
"main": "lib/cjs/index.js",
"exports": {
Expand Down
4 changes: 3 additions & 1 deletion src/Webform.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ function getOptions(options) {
* @property {boolean} [allowPrevious] - Allow the previous button (for Wizard forms).
* @property {string[]} [wizardButtonOrder] - The order of the buttons (for Wizard forms).
* @property {boolean} [showCheckboxBackground] - Show the checkbox background.
* @property {boolean} [inputsOnly] - Only show inputs in the form and no labels.
* @property {boolean} [building] - If we are in the process of building the form.
* @property {number} [zoom] - The zoom for PDF forms.
*/

Expand Down Expand Up @@ -1640,7 +1642,7 @@ export default class Webform extends NestedDataComponent {
*
* @returns {Promise} - A promise when the form is done submitting.
*/
submit(before, options = {}) {
submit(before = null, options = {}) {
this.submissionInProcess = true;
if (!before) {
return this.beforeSubmit(options).then(() => this.executeSubmit(options));
Expand Down
14 changes: 5 additions & 9 deletions src/components/_classes/component/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export default class Component extends Element {
return this.options.renderMode === 'html';
}

renderTemplate(name, data = {}, modeOption) {
renderTemplate(name, data = {}, modeOption = '') {
// Need to make this fall back to form if renderMode is not found similar to how we search templates.
const mode = modeOption || this.options.renderMode || 'form';
data.component = this.component;
Expand Down Expand Up @@ -1019,7 +1019,7 @@ export default class Component extends Element {
* @param string
* @returns {*}
*/
sanitize(dirty, forceSanitize, options) {
sanitize(dirty, forceSanitize = false, options = {}) {
if (!this.shouldSanitizeValue && !forceSanitize) {
return dirty;
}
Expand Down Expand Up @@ -3213,7 +3213,7 @@ export default class Component extends Element {
* @param {*} silentCheck
* @returns
*/
checkValidity(data, dirty, row, silentCheck, errors = []) {
checkValidity(data = null, dirty = false, row = null, silentCheck = false, errors = []) {
data = data || this.rootValue;
row = row || this.data;
console.log('Deprecation warning: Component.checkValidity() will be deprecated in 6.x version of renderer. Use Component.validateComponent instead.');
Expand Down Expand Up @@ -3674,19 +3674,15 @@ export default class Component extends Element {
window.scrollTo(left + window.scrollX, top + window.scrollY);
}

focus(index) {
focus(index = (this.refs.input.length - 1)) {
if ('beforeFocus' in this.parent) {
this.parent.beforeFocus(this);
}

if (this.refs.input?.length) {
const focusingInput = typeof index === 'number' && this.refs.input[index]
? this.refs.input[index]
: this.refs.input[this.refs.input.length - 1];

const focusingInput = this.refs.input[index];
if (this.component.widget?.type === 'calendar') {
const sibling = focusingInput.nextSibling;

if (sibling) {
sibling.focus();
}
Expand Down
10 changes: 5 additions & 5 deletions src/components/_classes/nested/NestedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default class NestedComponent extends Field {
*
* @param {function} fn - Called for every component.
*/
everyComponent(fn, options) {
everyComponent(fn, options = {}) {
const components = this.getComponents();
_.each(components, (component, index) => {
if (fn(component, components, index) === false) {
Expand Down Expand Up @@ -282,7 +282,7 @@ export default class NestedComponent extends Field {
* @param {function} fn - Called with the component once it is retrieved.
* @return {Object} - The component retrieved.
*/
getComponentById(id, fn) {
getComponentById(id, fn = null) {
let comp = null;
this.everyComponent((component, components) => {
if (component.id === id) {
Expand Down Expand Up @@ -394,7 +394,7 @@ export default class NestedComponent extends Field {
* @param {HTMLElement} before - A DOM element to insert this element before.
* @return {Component} - The created component instance.
*/
addComponent(component, data, before, noAdd) {
addComponent(component, data = null, before = null, noAdd = false) {
data = data || this.data;
this.components = this.components || [];
component = this.hook('addComponent', component, data, before, noAdd);
Expand Down Expand Up @@ -520,7 +520,7 @@ export default class NestedComponent extends Field {
* @param {function} fn - Called once the component is removed.
* @return {null}
*/
removeComponentByKey(key, fn) {
removeComponentByKey(key, fn = null) {
const comp = this.getComponent(key, (component, components) => {
this.removeComponent(component, components);
if (fn) {
Expand All @@ -542,7 +542,7 @@ export default class NestedComponent extends Field {
* @param {function} fn - Called when the component is removed.
* @return {null}
*/
removeComponentById(id, fn) {
removeComponentById(id, fn = null) {
const comp = this.getComponentById(id, (component, components) => {
this.removeComponent(component, components);
if (fn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default class NestedArrayComponent extends NestedDataComponent {
return result;
}

everyComponent(fn, rowIndex, options) {
everyComponent(fn, rowIndex, options = {}) {
if (_.isObject(rowIndex)) {
options = rowIndex;
rowIndex = null;
Expand Down
2 changes: 1 addition & 1 deletion src/components/_classes/nesteddata/NestedDataComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class NestedDataComponent extends NestedComponent {
return result;
}

everyComponent(fn, options) {
everyComponent(fn, options = {}) {
if (options?.email) {
if (options.fromRoot) {
delete options.fromRoot;
Expand Down
7 changes: 1 addition & 6 deletions src/utils/Evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Evaluator as CoreEvaluator } from '@formio/core/utils';
export class Evaluator extends CoreEvaluator {
static cache = {};
static protectedEval = false;
static noeval = false;
static template(template, hash) {
hash = hash || stringHash(template);
if (Evaluator.cache[hash]) {
Expand Down Expand Up @@ -55,9 +56,3 @@ export class Evaluator extends CoreEvaluator {
return Array.isArray(args) ? func(...args) : func(args);
}
}

Evaluator.registerEvaluator = (evaluator) => {
Object.keys(evaluator).forEach((key) => {
Evaluator[key] = evaluator[key];
});
};

0 comments on commit 8d20d51

Please sign in to comment.