Skip to content

Commit 9d58822

Browse files
authored
Merge pull request #151 from erqk/v8
V8
2 parents 821dd82 + 15b3989 commit 9d58822

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.codeActionsOnSave": {
4+
"source.organizeImports": "explicit"
5+
}
6+
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 8.5.0 (2024-10-14)
2+
3+
[aee0865]: https://github.com/erqk/ng-dynamic-json-form/commit/aee08654eb545081a88d74fbe98da91483706631
4+
5+
| Commit | Type | Description |
6+
| --------- | ---- | ----------------------------- |
7+
| [aee0865] | feat | Add `onChange` event emitter. |
8+
19
# 8.4.8 (2024-09-27)
210

311
[d0b36b0]: https://github.com/erqk/ng-dynamic-json-form/commit/d0b36b0c3c2dbefe1834903cbbe0a2a1eac62338

lib/core/ng-dynamic-json-form.component.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ export class NgDynamicJsonFormComponent
223223
@Input() optionsSources?: { [key: string]: Observable<OptionItem[]> };
224224

225225
@Output() formGet = new EventEmitter<UntypedFormGroup>();
226+
/**
227+
* The value change event of the form, which trigger by the user
228+
* (by checking click or keydown event)
229+
*/
230+
@Output() onChange = new EventEmitter<any>();
226231
@Output() optionsLoaded = new EventEmitter();
227232
@Output() displayValue = new EventEmitter<FormDisplayValue>();
228233
@Output() updateStatusFunctions = new EventEmitter<FormStatusFunctions>();
@@ -393,15 +398,9 @@ export class NgDynamicJsonFormComponent
393398
tap(() => this._onTouched())
394399
);
395400

396-
const allowDirtyState$ = merge(
397-
event$('focusin'),
398-
event$('click'),
399-
event$('keydown')
400-
).pipe(
401+
const allowDirtyState$ = merge(event$('click'), event$('keydown')).pipe(
401402
take(1),
402-
tap(() => {
403-
this._allowFormDirty = true;
404-
})
403+
tap(() => (this._allowFormDirty = true))
405404
);
406405

407406
merge(allowDirtyState$, onTouched$, conditions$, valueChanges$)
@@ -477,6 +476,10 @@ export class NgDynamicJsonFormComponent
477476
markFormPristine(this.form);
478477
};
479478

479+
if (this._allowFormDirty) {
480+
this.onChange.emit(this.form?.value);
481+
}
482+
480483
setErrors();
481484
updateValue();
482485
updateDisplayValue();

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng-dynamic-json-form",
3-
"version": "8.4.8",
3+
"version": "8.5.0",
44
"author": {
55
"name": "erqk",
66
"url": "https://github.com/erqk"

src/assets/docs/v8/form-component/form-component_en.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ See [Custom Loading](../../v8/custom-loading/custom-loading_en.md).
124124

125125
The event called after form generation complete. The generated `UntypedFormGroup` will be emitted.
126126

127+
### onChange
128+
129+
The event of form value when it's changed by user.
130+
127131
### optionsLoaded
128132

129133
The event called after all of the options are loaded.

src/assets/docs/v8/form-component/form-component_zh-TW.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ submit(): void {
124124

125125
當表單生成完畢時觸發的事件,並將生成的 `UntypeFormGroup` 發送出去。
126126

127+
### onChange
128+
129+
用戶行為導致的表單的值變化事件。
130+
127131
### optionsLoaded
128132

129133
當所有選項載入完成後觸發。

0 commit comments

Comments
 (0)