ezfw-core 1.0.49 → 1.0.50
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.
- package/components/input/EzInput.ts +11 -3
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ const cls = cx(styles);
|
|
|
7
7
|
|
|
8
8
|
declare const ez: {
|
|
9
9
|
_createElement(config: unknown): Promise<HTMLElement>;
|
|
10
|
+
getControllerSync(name: string): { state: Record<string, unknown>; [key: string]: unknown } | null;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export interface EzInputConfig extends EzBaseComponentConfig {
|
|
@@ -156,11 +157,18 @@ export class EzInput extends EzBaseComponent {
|
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
// Handle onEnter
|
|
159
|
-
if (cfg.onEnter
|
|
160
|
-
const onEnterFn = cfg.onEnter;
|
|
160
|
+
if (cfg.onEnter) {
|
|
161
161
|
this._input.addEventListener('keydown', e => {
|
|
162
162
|
if (e.key === 'Enter') {
|
|
163
|
-
|
|
163
|
+
if (typeof cfg.onEnter === 'function') {
|
|
164
|
+
cfg.onEnter(this._input!.value);
|
|
165
|
+
} else if (typeof cfg.onEnter === 'string' && cfg.controller) {
|
|
166
|
+
const ctrl = ez.getControllerSync(cfg.controller);
|
|
167
|
+
const method = ctrl?.[cfg.onEnter];
|
|
168
|
+
if (typeof method === 'function') {
|
|
169
|
+
(method as (value: string) => void).call(ctrl, this._input!.value);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
164
172
|
}
|
|
165
173
|
});
|
|
166
174
|
}
|