From 8d20d51f685d03e4ca7d4963dbd89f3b9c52d165 Mon Sep 17 00:00:00 2001 From: Travis Tidwell Date: Thu, 25 Apr 2024 13:10:27 -0500 Subject: [PATCH] Adding more jsdocs. --- package.json | 2 +- src/Webform.js | 4 +++- src/components/_classes/component/Component.js | 14 +++++--------- src/components/_classes/nested/NestedComponent.js | 10 +++++----- .../_classes/nestedarray/NestedArrayComponent.js | 2 +- .../_classes/nesteddata/NestedDataComponent.js | 2 +- src/utils/Evaluator.js | 7 +------ 7 files changed, 17 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 0af7086d11..380b7e8804 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/Webform.js b/src/Webform.js index 48de614951..4930c8b7a4 100644 --- a/src/Webform.js +++ b/src/Webform.js @@ -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. */ @@ -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)); diff --git a/src/components/_classes/component/Component.js b/src/components/_classes/component/Component.js index 9daa721c25..108d909ece 100644 --- a/src/components/_classes/component/Component.js +++ b/src/components/_classes/component/Component.js @@ -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; @@ -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; } @@ -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.'); @@ -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(); } diff --git a/src/components/_classes/nested/NestedComponent.js b/src/components/_classes/nested/NestedComponent.js index 188d367274..0e438862ee 100644 --- a/src/components/_classes/nested/NestedComponent.js +++ b/src/components/_classes/nested/NestedComponent.js @@ -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) { @@ -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) { @@ -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); @@ -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) { @@ -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) { diff --git a/src/components/_classes/nestedarray/NestedArrayComponent.js b/src/components/_classes/nestedarray/NestedArrayComponent.js index 0b0edafedb..b3dbb00455 100644 --- a/src/components/_classes/nestedarray/NestedArrayComponent.js +++ b/src/components/_classes/nestedarray/NestedArrayComponent.js @@ -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; diff --git a/src/components/_classes/nesteddata/NestedDataComponent.js b/src/components/_classes/nesteddata/NestedDataComponent.js index c6a4271c72..463ec8cce4 100644 --- a/src/components/_classes/nesteddata/NestedDataComponent.js +++ b/src/components/_classes/nesteddata/NestedDataComponent.js @@ -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; diff --git a/src/utils/Evaluator.js b/src/utils/Evaluator.js index fdd316eacc..8d00349747 100644 --- a/src/utils/Evaluator.js +++ b/src/utils/Evaluator.js @@ -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]) { @@ -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]; - }); -};