diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml new file mode 100644 index 0000000000..ab65e6faa4 --- /dev/null +++ b/.github/workflows/config.yml @@ -0,0 +1,131 @@ +# name: Build & Test + +# on: push + +# env: +# NODE_VERSION: 18.x + +# jobs: +# test: +# runs-on: ubuntu-latest +# steps: +# - run: echo "Triggered by ${{ github.event_name }} event." + +# - name: Check out repository code ${{ github.repository }} on ${{ github.ref }} +# uses: actions/checkout@v3 + +# - name: Set up Node.js ${{ env.NODE_VERSION }} +# uses: actions/setup-node@v3 +# with: +# node-version: ${{ env.NODE_VERSION }} +# cache: 'npm' + +# - name: Cache node modules +# uses: actions/cache@v3 +# with: +# path: node_modules +# key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} +# restore-keys: | +# ${{ runner.os }}-node- + +# - name: Installing dependencies +# if: steps.cache.outputs.cache-hit != 'true' +# uses: borales/actions-yarn@v4 +# with: +# cmd: install --frozen-lockfile + +# - name: Lint +# uses: borales/actions-yarn@v4 +# with: +# cmd: lint + +# - name: Build +# uses: borales/actions-yarn@v4 +# with: +# cmd: build + +# - name: Test +# uses: borales/actions-yarn@v4 +# with: +# cmd: test + +name: Build & Test + +on: push + +env: + NODE_VERSION: 18.x + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - run: echo "Triggered by ${{ github.event_name }} event." + + - name: Check out repository code ${{ github.repository }} on ${{ github.ref }} + uses: actions/checkout@v3 + + - name: Set up Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: Cache node modules + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Installing dependencies + if: steps.cache.outputs.cache-hit != 'true' + uses: borales/actions-yarn@v4 + with: + cmd: install --frozen-lockfile + + - name: Lint + uses: borales/actions-yarn@v4 + with: + cmd: lint + + build: + needs: setup + runs-on: ubuntu-latest + steps: + - name: Check out repository code ${{ github.repository }} on ${{ github.ref }} + uses: actions/checkout@v3 + + - name: Restore node modules from cache + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Build + uses: borales/actions-yarn@v4 + with: + cmd: build + + test: + needs: setup + runs-on: ubuntu-latest + steps: + - name: Check out repository code ${{ github.repository }} on ${{ github.ref }} + uses: actions/checkout@v3 + + - name: Restore node modules from cache + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Test + uses: borales/actions-yarn@v4 + with: + cmd: test \ No newline at end of file diff --git a/Changelog.md b/Changelog.md index 1217765d59..286a98346c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -22,6 +22,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - FIO-7207: changed tooltip and removed 'Hide label' option from the list of layout components - FIO-7074: fixed an issue where setting submission on wizard does not update data - FIO-7082: Moved Wizard Breadcrumbs Type to form settings + - FIO-7224: Fixed issues with layout components when Condensed mode is enabled + - FIO-4833: Removes Hide Label setting from Well, Columns, Tabs and Table components since they do not render a label + - FIO-5910: allow manual input for w and W date formats + - FIO-6370: Fixes issues with PasswordStrength Addon settings + - FIO-7146: formiojs-circleci-to-ghactions ## 5.0.0-rc.26 ### Changed diff --git a/src/Embed.js b/src/Embed.js index ad25434a47..97908a1f34 100644 --- a/src/Embed.js +++ b/src/Embed.js @@ -142,7 +142,7 @@ export class Formio { } // eslint-disable-next-line max-statements - static async init(element, builder = false) { + static async init(element, options = {}, builder = false) { Formio.cdn = new CDN(Formio.config.cdn); Formio.config.libs = Formio.config.libs || { uswds: { @@ -160,10 +160,19 @@ export class Formio { const id = Formio.config.id || `formio-${Math.random().toString(36).substring(7)}`; // Create a new wrapper and add the element inside of a new wrapper. - const wrapper = Formio.createElement('div', { + let wrapper = Formio.createElement('div', { 'id': `"${id}-wrapper"` }); element.parentNode.insertBefore(wrapper, element); + + // If we include the libraries, then we will attempt to run this in shadow dom. + if (Formio.config.includeLibs && (typeof wrapper.attachShadow === 'function') && !Formio.config.premium) { + wrapper = wrapper.attachShadow({ + mode: 'open' + }); + options.shadowRoot = wrapper; + } + element.parentNode.removeChild(element); wrapper.appendChild(element); @@ -246,7 +255,7 @@ export class Formio { } static async createForm(element, form, options) { - const wrapper = await Formio.init(element); + const wrapper = await Formio.init(element, options); return Formio.FormioClass.createForm(element, form, { ...options, ...{ noLoader: true } @@ -278,7 +287,7 @@ export class Formio { } static async builder(element, form, options) { - const wrapper = await Formio.init(element, true); + const wrapper = await Formio.init(element, options, true); return Formio.FormioClass.builder(element, form, options).then((instance) => { Formio.debug('Builder created', instance); Formio.debug('Removing loader'); diff --git a/src/WebformBuilder.js b/src/WebformBuilder.js index b7df181d86..461e4559bd 100644 --- a/src/WebformBuilder.js +++ b/src/WebformBuilder.js @@ -1588,8 +1588,15 @@ export default class WebformBuilder extends Component { } } + // If the edit form has any nested form inside, we get a partial data (nested form's data) in the + // event.data property + let editFormData; + if (event.changed.instance && event.changed.instance.root && event.changed.instance.root.id !== this.editForm.id) { + editFormData = this.editForm.data; + } + // Update the component. - this.updateComponent(event.data.componentJson || event.data, event.changed); + this.updateComponent(event.data.componentJson || editFormData || event.data, event.changed); } }); diff --git a/src/addons/index.js b/src/addons/index.js index 1555897676..fb579eb0c7 100644 --- a/src/addons/index.js +++ b/src/addons/index.js @@ -7,7 +7,11 @@ export const editForms = [ key: 'settings', display: 'form', input: true, - components, + components: components.map((comp) => { + comp.tableView = false; + return comp; + }), + tableView: false, defaultValue: { data: defaultSettings }, diff --git a/src/components/_classes/component/Component.js b/src/components/_classes/component/Component.js index 3fa7232550..c64abaa4eb 100644 --- a/src/components/_classes/component/Component.js +++ b/src/components/_classes/component/Component.js @@ -768,7 +768,7 @@ export default class Component extends Element { let contentMargin = ''; if (this.component.hideLabel) { - const margin = this.labelWidth + this.labelMargin; + const margin = isCondensed ? 0 : this.labelWidth + this.labelMargin; contentMargin = isRightPosition ? `margin-right: ${margin}%` : ''; contentMargin = isLeftPosition ? `margin-left: ${margin}%` : ''; } diff --git a/src/components/_classes/component/editForm/Component.edit.addons.js b/src/components/_classes/component/editForm/Component.edit.addons.js index b3ac3f7da1..7d63552572 100644 --- a/src/components/_classes/component/editForm/Component.edit.addons.js +++ b/src/components/_classes/component/editForm/Component.edit.addons.js @@ -10,6 +10,33 @@ export default [ input: true, key: 'addons', label: 'Addons', + templates: { + // eslint-disable-next-line quotes + header: `
+
{{ t(components[0].label) }}
+
Settings
+
`, + // eslint-disable-next-line quotes + row: `
+
+ {{ row.name.label }} +
+
+ Click Edit to see addon's settings +
+ + {% if (!instance.options.readOnly && !instance.disabled) { %} +
+
+ + {% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %} + + {% } %} +
+
+ {% } %} +
`, + }, components: [ { label: 'Name', @@ -32,7 +59,10 @@ export default [ })); }, }, - input: true + input: true, + validate: { + required: true, + }, }, ...editForms, ] diff --git a/src/components/columns/Columns.js b/src/components/columns/Columns.js index cb21879754..c18ab5da6b 100644 --- a/src/components/columns/Columns.js +++ b/src/components/columns/Columns.js @@ -74,7 +74,7 @@ export default class ColumnsComponent extends NestedComponent { if (!column.size) { column.size = 'md'; } - column.currentWidth = column.width || 0; + column.currentWidth = this.options.condensedMode ? this.gridSize : column.width || 0; // Ensure there is a components array. if (!Array.isArray(column.components)) { column.components = []; diff --git a/src/components/columns/editForm/Columns.edit.display.js b/src/components/columns/editForm/Columns.edit.display.js index bf6973b583..a19b1151c1 100644 --- a/src/components/columns/editForm/Columns.edit.display.js +++ b/src/components/columns/editForm/Columns.edit.display.js @@ -112,5 +112,9 @@ export default [ tooltip: 'Will automatically adjust columns based on if nested components are hidden.', key: 'autoAdjust', input: true - } + }, + { + key: 'hideLabel', + ignore: true + }, ]; diff --git a/src/components/file/fixtures/comp3.js b/src/components/file/fixtures/comp3.js new file mode 100644 index 0000000000..3e6cf953c1 --- /dev/null +++ b/src/components/file/fixtures/comp3.js @@ -0,0 +1,29 @@ +export default { + type: 'form', + display: 'form', + components: [ + { + label: 'Upload', + tableView: false, + storage: 'base64', + webcam: false, + fileTypes: [ + { + label: '', + value: '' + } + ], + key: 'file', + type: 'file', + input: true + }, + { + type: 'button', + label: 'Submit', + key: 'submit', + disableOnInvalid: true, + input: true, + tableView: false + } + ], +}; diff --git a/src/components/table/editForm/Table.edit.display.js b/src/components/table/editForm/Table.edit.display.js index 31282d7e5e..634e000e4b 100644 --- a/src/components/table/editForm/Table.edit.display.js +++ b/src/components/table/editForm/Table.edit.display.js @@ -124,4 +124,8 @@ export default [ tooltip: 'Condense the size of the table.', weight: 704 }, + { + key: 'hideLabel', + ignore: true + }, ]; diff --git a/src/components/tabs/editForm/Tabs.edit.display.js b/src/components/tabs/editForm/Tabs.edit.display.js index 7a9615763d..1f1fb19b0d 100644 --- a/src/components/tabs/editForm/Tabs.edit.display.js +++ b/src/components/tabs/editForm/Tabs.edit.display.js @@ -81,4 +81,8 @@ export default [ key: 'verticalLayout', input: true }, + { + key: 'hideLabel', + ignore: true + }, ]; diff --git a/src/utils/utils.js b/src/utils/utils.js index 1359933ef0..473ba571b3 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -803,8 +803,10 @@ export function convertFormatToMask(format) { .replace(/M{3}/g, '***') // Short month conversion if input as text. .replace(/e/g, 'Q') + // Month number conversion. + .replace(/W/g, '99') // Year conversion. - .replace(/[ydhmsHMG]/g, '9') + .replace(/[ydhmswHMG]/g, '9') // AM/PM conversion. .replace(/a/g, 'AA'); } diff --git a/yarn.lock b/yarn.lock index 8229110dac..d3822a5834 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2033,11 +2033,16 @@ core-js@^2.0.0, core-js@^2.4.0: resolved "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz#d9333dfa7b065e347cc5682219d6f690859cc2ec" integrity sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ== -core-js@^3.0.0, core-js@^3.21.1, core-js@^3.30.2, core-js@^3.31.0: +core-js@^3.0.0, core-js@^3.21.1, core-js@^3.30.2: version "3.32.0" resolved "https://registry.npmjs.org/core-js/-/core-js-3.32.0.tgz#7643d353d899747ab1f8b03d2803b0312a0fb3b6" integrity sha512-rd4rYZNlF3WuoYuRIDEmbR/ga9CeuWX9U05umAvgrrZoHY4Z++cp/xwPQMvUpBB4Ag6J8KfD80G0zwCyaSxDww== +core-js@^3.32.1: + version "3.32.2" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.32.2.tgz#172fb5949ef468f93b4be7841af6ab1f21992db7" + integrity sha512-pxXSw1mYZPDGvTQqEc5vgIb83jGQKFGYWY76z4a7weZXUolw3G+OvpZqSRcfYOoOVUQJYEPsWeQK8pKEnUtWxQ== + core-util-is@1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -3687,9 +3692,9 @@ get-caller-file@^2.0.5: integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== get-func-name@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" - integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig== + version "2.0.2" + resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.2.tgz#0d7cf20cd13fda808669ffa88f4ffc7a3943fc41" + integrity sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ== get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0, get-intrinsic@^1.2.1: version "1.2.1" @@ -8148,10 +8153,10 @@ value-or-function@^3.0.0: resolved "https://registry.npmjs.org/value-or-function/-/value-or-function-3.0.0.tgz#1c243a50b595c1be54a754bfece8563b9ff8d813" integrity sha512-jdBB2FrWvQC/pnPtIqcLsMaQgjhdb6B7tk1MMyTKapox+tQZbdRP4uLxu/JY0t7fbfDCUMnuelzEYv5GsxHhdg== -vanilla-picker@^2.12.1: - version "2.12.1" - resolved "https://registry.npmjs.org/vanilla-picker/-/vanilla-picker-2.12.1.tgz#6e619eecf553891b8d2d042b745a23c91f19f34c" - integrity sha512-2qrEP9VYylKXbyzXKsbu2dferBTvqnlsr29XjHwFE+/MEp0VNj6oEUESLDtKZ7DWzGdSv1x/+ujqFZF+KsO3cg== +vanilla-picker@^2.12.2: + version "2.12.2" + resolved "https://registry.yarnpkg.com/vanilla-picker/-/vanilla-picker-2.12.2.tgz#b4c6a3f4015dbd208080265fe7edd311709aa251" + integrity sha512-dk0gNeNL9fQFGd1VEhNDQfFlbCqAiksRh1H2tVPlavkH88n/a/y30rXi9PPKrYPTK5kEfPO4xcldt4ts/1wIAg== dependencies: "@sphinxxxx/color-conversion" "^2.2.2"