ezfw-core 1.0.14 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,9 @@ export interface EzInputConfig extends EzBaseComponentConfig {
16
16
  value?: string | number;
17
17
  name?: string;
18
18
  formData?: string;
19
+ onKeydown?: (e: KeyboardEvent, ctrl: unknown) => void;
20
+ onKeyup?: (e: KeyboardEvent, ctrl: unknown) => void;
21
+ onEnter?: (value: string, ctrl: unknown) => void;
19
22
  }
20
23
 
21
24
  export class EzInput extends EzBaseComponent {
@@ -77,6 +80,31 @@ export class EzInput extends EzBaseComponent {
77
80
  }
78
81
  });
79
82
 
83
+ const getController = () => {
84
+ const ctrlName = this.config.controller;
85
+ return ctrlName ? ez.getControllerSync(ctrlName) : null;
86
+ };
87
+
88
+ if (cfg.onKeydown) {
89
+ input.addEventListener('keydown', e => {
90
+ cfg.onKeydown!(e, getController());
91
+ });
92
+ }
93
+
94
+ if (cfg.onKeyup) {
95
+ input.addEventListener('keyup', e => {
96
+ cfg.onKeyup!(e, getController());
97
+ });
98
+ }
99
+
100
+ if (cfg.onEnter) {
101
+ input.addEventListener('keydown', e => {
102
+ if (e.key === 'Enter') {
103
+ cfg.onEnter!(input.value, getController());
104
+ }
105
+ });
106
+ }
107
+
80
108
  row.appendChild(input);
81
109
  wrapper.appendChild(row);
82
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezfw-core",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Ez Framework - A declarative component framework for building modern web applications",
5
5
  "type": "module",
6
6
  "main": "./core/ez.ts",