@joinbox/formsync
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -6,3 +6,3 @@ # Change Log | ||
# [2.2.0](https://github.com/joinbox/ui-components/compare/@joinbox/formsync@2.1.3...@joinbox/formsync@2.2.0) (2021-12-03) | ||
## [2.2.1](https://github.com/joinbox/ui-components/compare/@joinbox/formsync@2.0.2...@joinbox/formsync@2.2.1) (2022-04-27) | ||
@@ -13,47 +13,13 @@ | ||
* **dpl:** fix build task ([b0b80eb](https://github.com/joinbox/ui-components/commit/b0b80ebb9e5e38a49c60843160d697843b235d04)) | ||
### Features | ||
* **FormSync:** add debounce for auto-submit ([9b940b0](https://github.com/joinbox/ui-components/commit/9b940b06d9a0f178015c1c22013636e0d5a6857b)) | ||
## [2.1.3](https://github.com/joinbox/ui-components/compare/@joinbox/formsync@2.1.2...@joinbox/formsync@2.1.3) (2021-07-14) | ||
**Note:** Version bump only for package @joinbox/formsync | ||
## [2.1.2](https://github.com/joinbox/ui-components/compare/@joinbox/formsync@2.1.1...@joinbox/formsync@2.1.2) (2021-07-14) | ||
### Bug Fixes | ||
* fix comment fauxpas ([6502b03](https://github.com/joinbox/ui-components/commit/6502b031f4c202301078e7a2c91dc2a3e46cbe1a)) | ||
* Fix main files in package.json ([1bd07b2](https://github.com/joinbox/ui-components/commit/1bd07b28a92881f499edac71e25453010bb2fe6c)) | ||
## [2.1.1](https://github.com/joinbox/ui-components/compare/@joinbox/formsync@2.1.0...@joinbox/formsync@2.1.1) (2021-07-06) | ||
### Bug Fixes | ||
* fix versions in package.json (to match latest release) ([77137df](https://github.com/joinbox/ui-components/commit/77137df6758b2d39ee06941ba3e6a062c1f5b9e4)) | ||
* **formsync:** check if element is already defined ([b740185](https://github.com/joinbox/ui-components/commit/b740185ac0f4935f4d2a093c77610ac880b3c64d)) | ||
* **formsync:** don't copy attributes if missing on source ([99ac7ce](https://github.com/joinbox/ui-components/commit/99ac7ce0caa70095ffcfd591c30be3221e339d7f)) | ||
# [2.1.0](https://github.com/joinbox/ui-components/compare/@joinbox/formsync@2.0.3...@joinbox/formsync@2.1.0) (2021-07-06) | ||
### Features | ||
* **FormSync:** add debounce for auto-submit ([9b940b0](https://github.com/joinbox/ui-components/commit/9b940b06d9a0f178015c1c22013636e0d5a6857b)) | ||
* **FormSync:** submit original form if user presses enter in cloned input ([f818b07](https://github.com/joinbox/ui-components/commit/f818b079413825fec13441b0f79108142b849482)) | ||
* **FormSync:** sync disabled attribute ([abc5d2f](https://github.com/joinbox/ui-components/commit/abc5d2fabfed6b46cb5ba8d46c8c3a2bc9af4a6d)) | ||
@@ -65,13 +31,2 @@ | ||
## [2.0.3](https://github.com/joinbox/ui-components/compare/@joinbox/formsync@2.0.2...@joinbox/formsync@2.0.3) (2021-06-21) | ||
### Bug Fixes | ||
* **formsync:** check if element is already defined ([b740185](https://github.com/joinbox/ui-components/commit/b740185ac0f4935f4d2a093c77610ac880b3c64d)) | ||
## 2.0.2 (2021-06-01) | ||
@@ -78,0 +33,0 @@ |
@@ -183,2 +183,2 @@ (function () { | ||
}()); | ||
})(); |
@@ -118,2 +118,3 @@ (function () { | ||
autoSubmit = [], | ||
submitOnEnter = false, | ||
} = {}) { | ||
@@ -132,2 +133,3 @@ if (!(originalElement instanceof HTMLElement)) { | ||
this.autoSubmit = autoSubmit; | ||
this.submitOnEnter = submitOnEnter; | ||
this.property = property; | ||
@@ -138,2 +140,3 @@ this.setupOriginalWatcher(); | ||
this.setupAutoSubmitWatcher(); | ||
this.setupEnterWatcher(); | ||
} | ||
@@ -171,2 +174,9 @@ | ||
setupEnterWatcher() { | ||
if (!this.submitOnEnter) return; | ||
this.clonedElement.addEventListener('keyup', (ev) => { | ||
if (ev.key === 'Enter') this.submitOriginalForm(); | ||
}); | ||
} | ||
/** | ||
@@ -271,2 +281,6 @@ * On init, sync original to cloned; also syncing backwards would not make any sense as | ||
), | ||
}, { | ||
name: 'data-submit-on-enter', | ||
property: 'submitOnEnter', | ||
transform: value => (value === null || value === undefined) ? false : true, | ||
}]), | ||
@@ -477,2 +491,3 @@ ); | ||
property: this.getInputProperty(originalInput), | ||
submitOnEnter: this.submitOnEnter, | ||
}); | ||
@@ -490,2 +505,2 @@ // Store sync instance on element to update it later (see radio workaround above) | ||
}()); | ||
})(); |
{ | ||
"name": "@joinbox/formsync", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Synchronizes forms and elements between an original form (e.g. one created by Drupal) and another form (e.g. freely created as a template based on mockups).", | ||
@@ -22,8 +22,8 @@ "main": "FormSyncElement.js", | ||
"devDependencies": { | ||
"@joinbox/eslint-config-joinbox": "^1.0.8", | ||
"ava": "^3.15.0", | ||
"babel-eslint": "^10.1.0", | ||
"jsdom": "^16.4.0", | ||
"@babel/eslint-parser": "^7.17.0", | ||
"@joinbox/eslint-config-joinbox": "^1.0.10", | ||
"ava": "^4.2.0", | ||
"jsdom": "^19.0.0", | ||
"lerna": "^4.0.0", | ||
"rollup": "^2.50.2" | ||
"rollup": "^2.70.1" | ||
}, | ||
@@ -33,3 +33,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "789d8e897a31192844a5dcb2a995ea1eb40f4e80" | ||
"gitHead": "446d4e2bea4c69ab28152c786ff98422500dcabe" | ||
} |
@@ -108,4 +108,6 @@ # Form Sync | ||
(this is required in order to work with Drupal's AJAX based forms). | ||
- data-form-elements-selector: CSS selector for all input elements that should be cloned and synced | ||
- `data-form-elements-selector`: CSS selector for all input elements that should be cloned and synced | ||
between the original and the cloned input. | ||
- `data-submit-on-enter` (optional, boolean attribute): Submit original form if user presses enter | ||
while the input is focused. | ||
@@ -112,0 +114,0 @@ #### Content |
@@ -36,2 +36,6 @@ import canReadAttributes from '../../../src/shared/canReadAttributes.js'; | ||
), | ||
}, { | ||
name: 'data-submit-on-enter', | ||
property: 'submitOnEnter', | ||
transform: value => (value === null || value === undefined) ? false : true, | ||
}]), | ||
@@ -242,2 +246,3 @@ ); | ||
property: this.getInputProperty(originalInput), | ||
submitOnEnter: this.submitOnEnter, | ||
}); | ||
@@ -244,0 +249,0 @@ // Store sync instance on element to update it later (see radio workaround above) |
@@ -27,2 +27,3 @@ import submitForm from './submitForm.js'; | ||
autoSubmit = [], | ||
submitOnEnter = false, | ||
} = {}) { | ||
@@ -41,2 +42,3 @@ if (!(originalElement instanceof HTMLElement)) { | ||
this.autoSubmit = autoSubmit; | ||
this.submitOnEnter = submitOnEnter; | ||
this.property = property; | ||
@@ -47,2 +49,3 @@ this.setupOriginalWatcher(); | ||
this.setupAutoSubmitWatcher(); | ||
this.setupEnterWatcher(); | ||
} | ||
@@ -80,2 +83,9 @@ | ||
setupEnterWatcher() { | ||
if (!this.submitOnEnter) return; | ||
this.clonedElement.addEventListener('keyup', (ev) => { | ||
if (ev.key === 'Enter') this.submitOriginalForm(); | ||
}); | ||
} | ||
/** | ||
@@ -82,0 +92,0 @@ * On init, sync original to cloned; also syncing backwards would not make any sense as |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
95223
1870
165