@decaf-ts/ui-decorators 0.6.7 → 0.6.8
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/README.md +5 -0
- package/dist/ui-decorators.cjs +1 -1
- package/dist/ui-decorators.cjs.map +1 -1
- package/dist/ui-decorators.js +1 -1
- package/dist/ui-decorators.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/ui/DecafComponent.d.ts +73 -7
- package/lib/esm/ui/DecafComponent.js +59 -0
- package/lib/esm/ui/DecafComponent.js.map +1 -1
- package/lib/esm/ui/DecafEventHandler.d.ts +16 -0
- package/lib/esm/ui/DecafEventHandler.js +24 -0
- package/lib/esm/ui/DecafEventHandler.js.map +1 -1
- package/lib/esm/ui/constants.d.ts +117 -0
- package/lib/esm/ui/constants.js +117 -0
- package/lib/esm/ui/constants.js.map +1 -1
- package/lib/esm/ui/decorators.d.ts +12 -6
- package/lib/esm/ui/decorators.js +16 -2
- package/lib/esm/ui/decorators.js.map +1 -1
- package/lib/esm/ui/types.d.ts +5 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/ui/DecafComponent.cjs +61 -1
- package/lib/ui/DecafComponent.d.ts +73 -7
- package/lib/ui/DecafComponent.js.map +1 -1
- package/lib/ui/DecafEventHandler.cjs +24 -0
- package/lib/ui/DecafEventHandler.d.ts +16 -0
- package/lib/ui/DecafEventHandler.js.map +1 -1
- package/lib/ui/constants.cjs +118 -1
- package/lib/ui/constants.d.ts +117 -0
- package/lib/ui/constants.js.map +1 -1
- package/lib/ui/decorators.cjs +17 -2
- package/lib/ui/decorators.d.ts +12 -6
- package/lib/ui/decorators.js.map +1 -1
- package/lib/ui/types.d.ts +5 -1
- package/package.json +4 -2
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DecafComponent = void 0;
|
|
3
|
+
exports.DecafComponent = exports.isClassConstructor = void 0;
|
|
4
4
|
const logging_1 = require("@decaf-ts/logging");
|
|
5
5
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
6
|
+
const isClassConstructor = (value) => {
|
|
7
|
+
return typeof value === "function" && /^class\s/.test(String(value));
|
|
8
|
+
};
|
|
9
|
+
exports.isClassConstructor = isClassConstructor;
|
|
6
10
|
/**
|
|
7
11
|
* Base class for all Decaf UI components, providing common state management,
|
|
8
12
|
* logging, localization, navigation hooks, CRUD context metadata, and
|
|
@@ -92,6 +96,7 @@ class DecafComponent extends logging_1.LoggedClass {
|
|
|
92
96
|
* @default false
|
|
93
97
|
*/
|
|
94
98
|
this.initialized = false;
|
|
99
|
+
this.events = {};
|
|
95
100
|
this.handlers = {};
|
|
96
101
|
}
|
|
97
102
|
get repository() {
|
|
@@ -153,6 +158,61 @@ class DecafComponent extends logging_1.LoggedClass {
|
|
|
153
158
|
.for(this.submit)
|
|
154
159
|
.info(`submit for ${this.componentName} with ${JSON.stringify(args)}`);
|
|
155
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* @description Normalizes handler definitions into executable functions.
|
|
163
|
+
* @summary Iterates through a handlers map and ensures each entry is stored as a callable
|
|
164
|
+
* function on the component. Plain functions are stored directly, while handler classes are
|
|
165
|
+
* instantiated so their `handle` method (or a keyed override) becomes the registered handler.
|
|
166
|
+
* This allows decorators to accept either inline functions or handler classes transparently.
|
|
167
|
+
* @template T Extends `DecafEventHandler` to constrain handler class types.
|
|
168
|
+
* @param handlers - Dictionary of handler names mapped to functions or handler constructors.
|
|
169
|
+
* @param instance - Optional target handler instance; defaults to the current component.
|
|
170
|
+
*/
|
|
171
|
+
parseHandlers(handlers, instance) {
|
|
172
|
+
const result = {};
|
|
173
|
+
Object.entries(handlers).forEach(([key, fn]) => {
|
|
174
|
+
if ((0, exports.isClassConstructor)(fn)) {
|
|
175
|
+
const clazz = new fn();
|
|
176
|
+
const event = key in clazz ? clazz[key] : clazz.handle;
|
|
177
|
+
result[key] = event;
|
|
178
|
+
instance.handlers[key] = event;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
result[key] = fn;
|
|
182
|
+
instance.handlers[key] = fn;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* @description Registers event callbacks on the component instance.
|
|
189
|
+
* @summary Processes an events map produced by decorators where each value can be a factory
|
|
190
|
+
* returning a function or a component constructor. When a constructor is returned, the method
|
|
191
|
+
* matching the event key is instantiated and stored; otherwise the produced function is
|
|
192
|
+
* assigned directly. This enables flexible event binding definitions for derived components.
|
|
193
|
+
* @template T Extends `DecafComponent<Model>` to scope acceptable event owners.
|
|
194
|
+
* @param events - Dictionary of event names mapped to function factories or component constructors.
|
|
195
|
+
* @param instance - Optional component instance to receive the events; defaults to `this`.
|
|
196
|
+
*/
|
|
197
|
+
parseEvents(events, instance) {
|
|
198
|
+
const result = {};
|
|
199
|
+
Object.entries(events).forEach(([key, fn]) => {
|
|
200
|
+
const name = key;
|
|
201
|
+
const evt = fn();
|
|
202
|
+
if ((0, exports.isClassConstructor)(evt)) {
|
|
203
|
+
const fn = new evt()[key];
|
|
204
|
+
if (fn) {
|
|
205
|
+
result[name] = fn;
|
|
206
|
+
instance.events[name] = fn;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
result[name] = fn;
|
|
211
|
+
instance.events[name] = fn;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
return result;
|
|
215
|
+
}
|
|
156
216
|
}
|
|
157
217
|
exports.DecafComponent = DecafComponent;
|
|
158
218
|
//# sourceMappingURL=DecafComponent.js.map
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { LoggedClass } from "@decaf-ts/logging";
|
|
2
|
-
import { UIFunctionLike } from "./types";
|
|
2
|
+
import { CrudOperationKeys, UIEventProperty, UIFunctionLike } from "./types";
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
4
|
import { IRepository, OperationKeys } from "@decaf-ts/db-decorators";
|
|
5
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
6
|
+
import { DecafEventHandler } from "./DecafEventHandler";
|
|
5
7
|
type PrimaryKeyType = string | number | bigint;
|
|
8
|
+
export declare const isClassConstructor: <C>(value: UIFunctionLike | Constructor<C>) => value is Constructor<C>;
|
|
6
9
|
/**
|
|
7
10
|
* Base class for all Decaf UI components, providing common state management,
|
|
8
11
|
* logging, localization, navigation hooks, CRUD context metadata, and
|
|
@@ -27,6 +30,20 @@ export declare abstract class DecafComponent<M extends Model> extends LoggedClas
|
|
|
27
30
|
* @type {PrimaryKeyType | PrimaryKeyType[]}
|
|
28
31
|
*/
|
|
29
32
|
modelId?: PrimaryKeyType | PrimaryKeyType[];
|
|
33
|
+
/**
|
|
34
|
+
* @description Pre-built filtering expression applied to repository queries.
|
|
35
|
+
* @summary Supply a custom `AttributeOption` to control how records are constrained. When omitted,
|
|
36
|
+
* the directive derives a condition from `filterBy` or `pk`, comparing it against `modelId`.
|
|
37
|
+
* @type {any}
|
|
38
|
+
*/
|
|
39
|
+
filter: any;
|
|
40
|
+
/**
|
|
41
|
+
* @description Model field used when generating the default condition.
|
|
42
|
+
* @summary Indicates which key should be compared to `modelId` when `filter` is not provided.
|
|
43
|
+
* Defaults to the configured primary key so overrides are only needed for custom lookups.
|
|
44
|
+
* @type {string}
|
|
45
|
+
*/
|
|
46
|
+
filterBy: string;
|
|
30
47
|
/**
|
|
31
48
|
* @description The CRUD operation type to be performed on the model.
|
|
32
49
|
* @summary Specifies which operation (Create, Read, Update, Delete) this component instance
|
|
@@ -77,10 +94,37 @@ export declare abstract class DecafComponent<M extends Model> extends LoggedClas
|
|
|
77
94
|
* @summary Specifies which field in the model should be used as the primary key.
|
|
78
95
|
* This is typically used for identifying unique records in operations like update and delete.
|
|
79
96
|
* If not explicitly set, it defaults to the repository's configured primary key or 'id'.
|
|
80
|
-
* @type {
|
|
81
|
-
|
|
97
|
+
* @type {string}
|
|
98
|
+
1 */
|
|
99
|
+
pk: string;
|
|
100
|
+
/**
|
|
101
|
+
* @description Angular change detection service for manual change detection control.
|
|
102
|
+
* @summary Injected service that provides manual control over change detection cycles.
|
|
103
|
+
* This is essential for ensuring that programmatic DOM changes (like setting accordion
|
|
104
|
+
* attributes) are properly reflected in the component's state and trigger appropriate
|
|
105
|
+
* view updates when modifications occur outside the normal Angular change detection flow.
|
|
106
|
+
* @protected
|
|
82
107
|
*/
|
|
83
|
-
|
|
108
|
+
protected changeDetectorRef?: any;
|
|
109
|
+
/**
|
|
110
|
+
* @description Controls field visibility based on CRUD operations.
|
|
111
|
+
* @summary Can be a boolean or an array of operation keys where the field should be hidden.
|
|
112
|
+
* @type {boolean | CrudOperationKeys[]}
|
|
113
|
+
*/
|
|
114
|
+
hidden?: boolean | CrudOperationKeys[];
|
|
115
|
+
/**
|
|
116
|
+
* @description Label for the file upload field.
|
|
117
|
+
* @summary Provides a user-friendly label for the file upload input.
|
|
118
|
+
*
|
|
119
|
+
* @type {string | undefined}
|
|
120
|
+
*/
|
|
121
|
+
label?: string;
|
|
122
|
+
/**
|
|
123
|
+
* @description Whether the field is read-only.
|
|
124
|
+
* @type {boolean}
|
|
125
|
+
* @public
|
|
126
|
+
*/
|
|
127
|
+
readonly?: boolean;
|
|
84
128
|
/**
|
|
85
129
|
* @description Flag to enable or disable dark mode support for the component.
|
|
86
130
|
* @summary When enabled, the component will automatically detect the system's dark mode
|
|
@@ -216,8 +260,8 @@ export declare abstract class DecafComponent<M extends Model> extends LoggedClas
|
|
|
216
260
|
* @default false
|
|
217
261
|
*/
|
|
218
262
|
protected initialized: boolean;
|
|
219
|
-
protected events
|
|
220
|
-
protected handlers:
|
|
263
|
+
protected events: UIEventProperty;
|
|
264
|
+
protected handlers: UIEventProperty;
|
|
221
265
|
constructor();
|
|
222
266
|
get repository(): IRepository<M>;
|
|
223
267
|
set repository(repository: IRepository<M>);
|
|
@@ -238,7 +282,7 @@ export declare abstract class DecafComponent<M extends Model> extends LoggedClas
|
|
|
238
282
|
* @param args - A variable number of arguments used for translation.
|
|
239
283
|
* @returns A promise that resolves with the translation result.
|
|
240
284
|
*/
|
|
241
|
-
|
|
285
|
+
translate(...args: unknown[]): Promise<any>;
|
|
242
286
|
preview(...args: unknown[]): Promise<void>;
|
|
243
287
|
/**
|
|
244
288
|
* Submits data or performs an action associated with the component.
|
|
@@ -247,5 +291,27 @@ export declare abstract class DecafComponent<M extends Model> extends LoggedClas
|
|
|
247
291
|
* @returns A promise that resolves with the result of the submit operation.
|
|
248
292
|
*/
|
|
249
293
|
submit(...args: unknown[]): Promise<any>;
|
|
294
|
+
/**
|
|
295
|
+
* @description Normalizes handler definitions into executable functions.
|
|
296
|
+
* @summary Iterates through a handlers map and ensures each entry is stored as a callable
|
|
297
|
+
* function on the component. Plain functions are stored directly, while handler classes are
|
|
298
|
+
* instantiated so their `handle` method (or a keyed override) becomes the registered handler.
|
|
299
|
+
* This allows decorators to accept either inline functions or handler classes transparently.
|
|
300
|
+
* @template T Extends `DecafEventHandler` to constrain handler class types.
|
|
301
|
+
* @param handlers - Dictionary of handler names mapped to functions or handler constructors.
|
|
302
|
+
* @param instance - Optional target handler instance; defaults to the current component.
|
|
303
|
+
*/
|
|
304
|
+
protected parseHandlers<T extends DecafEventHandler>(handlers: UIEventProperty, instance: T): UIEventProperty;
|
|
305
|
+
/**
|
|
306
|
+
* @description Registers event callbacks on the component instance.
|
|
307
|
+
* @summary Processes an events map produced by decorators where each value can be a factory
|
|
308
|
+
* returning a function or a component constructor. When a constructor is returned, the method
|
|
309
|
+
* matching the event key is instantiated and stored; otherwise the produced function is
|
|
310
|
+
* assigned directly. This enables flexible event binding definitions for derived components.
|
|
311
|
+
* @template T Extends `DecafComponent<Model>` to scope acceptable event owners.
|
|
312
|
+
* @param events - Dictionary of event names mapped to function factories or component constructors.
|
|
313
|
+
* @param instance - Optional component instance to receive the events; defaults to `this`.
|
|
314
|
+
*/
|
|
315
|
+
protected parseEvents<T extends DecafComponent<Model>>(events: UIEventProperty, instance: T): UIEventProperty;
|
|
250
316
|
}
|
|
251
317
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecafComponent.js","sourceRoot":"","sources":["../../src/ui/DecafComponent.ts"],"names":[],"mappings":";;;AAAA,+CAAgD;AAGhD,2DAAqE;
|
|
1
|
+
{"version":3,"file":"DecafComponent.js","sourceRoot":"","sources":["../../src/ui/DecafComponent.ts"],"names":[],"mappings":";;;AAAA,+CAAgD;AAGhD,2DAAqE;AAM9D,MAAM,kBAAkB,GAAG,CAChC,KAAsC,EACb,EAAE;IAC3B,OAAO,OAAO,KAAK,KAAK,UAAU,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC;AAJW,QAAA,kBAAkB,sBAI7B;AAEF;;;;GAIG;AACH,MAAsB,cAAgC,SAAQ,qBAAW;IAyRvE;QACE,KAAK,EAAE,CAAC;QA1JV;;;;;;;;;WASG;QACO,mBAAc,GAAY,IAAI,CAAC;QAEzC;;;;;;;;;WASG;QACO,eAAU,GAAY,KAAK,CAAC;QAYtC;;;;;;;;;WASG;QACH,SAAI,GAA4B,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;QAE5C;;;;;;;;;WASG;QACH,UAAK,GAA4B,EAAE,CAAC;QAEpC;;;;;;;WAOG;QACH,UAAK,GAAY,EAAE,CAAC;QAEpB;;;;;;;WAOG;QACH,YAAO,GAAY,KAAK,CAAC;QA6BzB;;;;;;;;WAQG;QACgB,kBAAa,GAAG,6BAAa,CAAC;QAyBjD;;;;;;;WAOG;QACO,gBAAW,GAAY,KAAK,CAAC;QAE7B,WAAM,GAAoB,EAAE,CAAC;QAE7B,aAAQ,GAAoB,EAAE,CAAC;IAIzC,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAA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AAkB,EAAI,GAAG,CAAC,EAAE,CAAC;gBAC/B,MAAM,EAAE,GAAG,IAAI,GAAG,EAAE,CAAC,GAAc,CAAmB,CAAC;gBACvD,IAAI,EAAE,EAAE,CAAC;oBACP,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;oBAClB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;gBAC7B,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;gBAClB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YAC7B,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/ZD,wCA+ZC"}
|
|
@@ -32,6 +32,30 @@ class DecafEventHandler extends DecafComponent_1.DecafComponent {
|
|
|
32
32
|
.for(this.handle)
|
|
33
33
|
.info(`component ${this.componentName} handling ${JSON.stringify(args)}`);
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Handles an click event with the provided arguments.
|
|
37
|
+
* Logs the event handling process, including the component name and the arguments passed.
|
|
38
|
+
*
|
|
39
|
+
* @param args - The arguments for the event handler.
|
|
40
|
+
* @returns void
|
|
41
|
+
*/
|
|
42
|
+
handleClick(...args) {
|
|
43
|
+
this.log
|
|
44
|
+
.for(this.handleClick)
|
|
45
|
+
.info(`component ${this.componentName} handling click ${JSON.stringify(args)}`);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Handles an click event with the provided arguments.
|
|
49
|
+
* Logs the event handling process, including the component name and the arguments passed.
|
|
50
|
+
*
|
|
51
|
+
* @param args - The arguments for the event handler.
|
|
52
|
+
* @returns void
|
|
53
|
+
*/
|
|
54
|
+
handleAction(...args) {
|
|
55
|
+
this.log
|
|
56
|
+
.for(this.handleAction)
|
|
57
|
+
.info(`component ${this.componentName} handling action ${JSON.stringify(args)}`);
|
|
58
|
+
}
|
|
35
59
|
}
|
|
36
60
|
exports.DecafEventHandler = DecafEventHandler;
|
|
37
61
|
//# sourceMappingURL=DecafEventHandler.js.map
|
|
@@ -24,4 +24,20 @@ export declare class DecafEventHandler extends DecafComponent<Model> {
|
|
|
24
24
|
* @returns void
|
|
25
25
|
*/
|
|
26
26
|
handle(...args: unknown[]): void;
|
|
27
|
+
/**
|
|
28
|
+
* Handles an click event with the provided arguments.
|
|
29
|
+
* Logs the event handling process, including the component name and the arguments passed.
|
|
30
|
+
*
|
|
31
|
+
* @param args - The arguments for the event handler.
|
|
32
|
+
* @returns void
|
|
33
|
+
*/
|
|
34
|
+
handleClick(...args: unknown[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Handles an click event with the provided arguments.
|
|
37
|
+
* Logs the event handling process, including the component name and the arguments passed.
|
|
38
|
+
*
|
|
39
|
+
* @param args - The arguments for the event handler.
|
|
40
|
+
* @returns void
|
|
41
|
+
*/
|
|
42
|
+
handleAction(...args: unknown[]): void;
|
|
27
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecafEventHandler.js","sourceRoot":"","sources":["../../src/ui/DecafEventHandler.ts"],"names":[],"mappings":";;;AACA,yDAAkD;AAElD;;;;;;;GAOG;AACH,MAAa,iBAAkB,SAAQ,+BAAqB;IAC1D;;;;;OAKG;IACH;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,IAAe;QACvB,IAAI,CAAC,GAAG;aACL,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;aAChB,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,aAAa,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"DecafEventHandler.js","sourceRoot":"","sources":["../../src/ui/DecafEventHandler.ts"],"names":[],"mappings":";;;AACA,yDAAkD;AAElD;;;;;;;GAOG;AACH,MAAa,iBAAkB,SAAQ,+BAAqB;IAC1D;;;;;OAKG;IACH;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,IAAe;QACvB,IAAI,CAAC,GAAG;aACL,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;aAChB,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,aAAa,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,GAAG,IAAe;QAC5B,IAAI,CAAC,GAAG;aACL,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC;aACrB,IAAI,CACH,aAAa,IAAI,CAAC,aAAa,mBAAmB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CACzE,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CAAC,GAAG,IAAe;QAC7B,IAAI,CAAC,GAAG;aACL,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC;aACtB,IAAI,CACH,aAAa,IAAI,CAAC,aAAa,oBAAoB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAC1E,CAAC;IACN,CAAC;CACF;AArDD,8CAqDC"}
|
package/lib/ui/constants.cjs
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* @memberOf module:ui-decorators
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.HTML5CheckTypes = exports.HTML5InputTypes = exports.HTML5DateFormat = exports.ValidatableByAttribute = exports.ValidatableByType = exports.UIKeys = exports.UIMediaBreakPoints = void 0;
|
|
11
|
+
exports.WindowColorSchemes = exports.ActionRoles = exports.LayoutGridGaps = exports.ElementPositions = exports.ElementSizes = exports.TransactionHooks = exports.ComponentEventNames = exports.HTML5CheckTypes = exports.HTML5InputTypes = exports.HTML5DateFormat = exports.ValidatableByAttribute = exports.ValidatableByType = exports.UIKeys = exports.UIMediaBreakPoints = void 0;
|
|
12
12
|
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
13
|
+
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
13
14
|
var UIMediaBreakPoints;
|
|
14
15
|
(function (UIMediaBreakPoints) {
|
|
15
16
|
UIMediaBreakPoints["SMALL"] = "small";
|
|
@@ -255,4 +256,120 @@ exports.HTML5CheckTypes = [
|
|
|
255
256
|
exports.HTML5InputTypes.CHECKBOX,
|
|
256
257
|
exports.HTML5InputTypes.RADIO,
|
|
257
258
|
];
|
|
259
|
+
/**
|
|
260
|
+
* @description Event name constants.
|
|
261
|
+
* @summary Contains constants for standardized event names used throughout the application.
|
|
262
|
+
* These constants ensure consistent event naming across components and make it easier to
|
|
263
|
+
* track and handle events. Each constant represents a specific application event type.
|
|
264
|
+
* @typedef {Object} ComponentEventNames
|
|
265
|
+
* @property {string} BackButtonClickEvent - Event fired when back button navigation ends
|
|
266
|
+
* @property {string} Render - Event after component initialize action occurs
|
|
267
|
+
* @property {string} Refresh - Event fired when a refresh action occurs
|
|
268
|
+
* @property {string} Click - Event fired when a click action occurs
|
|
269
|
+
* @property {string} Change - Event fired when a change action occurs
|
|
270
|
+
* @property {string} Submit - Event fired when a form submission occurs
|
|
271
|
+
* @property {string} ValidationError - Event fired when a validation error occurs
|
|
272
|
+
* @property {string} ThemeChange - Event fired when a theme change occurs
|
|
273
|
+
* @property {string} FormGroupLoaded - Event fired when a reactve form group is loaded
|
|
274
|
+
* @const ComponentEventNames
|
|
275
|
+
*/
|
|
276
|
+
exports.ComponentEventNames = {
|
|
277
|
+
Render: "render",
|
|
278
|
+
BackButtonClickEvent: "backButtonNavigationEndEvent",
|
|
279
|
+
Refresh: "RefreshEvent",
|
|
280
|
+
Click: "ClickEvent",
|
|
281
|
+
Change: "ChangeEvent",
|
|
282
|
+
Submit: "SubmitEvent",
|
|
283
|
+
ValidationError: "validationErrorEvent",
|
|
284
|
+
ThemeChange: "themeChangeEvent",
|
|
285
|
+
FormGroupLoaded: "formGroupLoadedEvent",
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* @description Lifecycle hook labels for repository transactions.
|
|
289
|
+
* @summary Provides canonical names for CRUD lifecycle callbacks so decorators and
|
|
290
|
+
* components can register work before or after repository operations in a consistent way.
|
|
291
|
+
* Each key maps to the string used when wiring transaction middleware.
|
|
292
|
+
* @const TransactionHooks
|
|
293
|
+
*/
|
|
294
|
+
exports.TransactionHooks = {
|
|
295
|
+
BeforeCreate: "beforeCreate",
|
|
296
|
+
AfterCreate: "afterCreate",
|
|
297
|
+
BeforeUpdate: "beforeUpdate",
|
|
298
|
+
AfterUpdate: "afterUpdate",
|
|
299
|
+
BeforeDelete: "beforeDelete",
|
|
300
|
+
AfterDelete: "afterDelete",
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* @description Standardized size tokens for UI elements.
|
|
304
|
+
* @summary Defines the semantic size keywords supported by layout and form decorators.
|
|
305
|
+
* These values feed rendering engines so components can express sizing in a uniform vocabulary.
|
|
306
|
+
* @const ElementSizes
|
|
307
|
+
*/
|
|
308
|
+
exports.ElementSizes = {
|
|
309
|
+
xsmall: "xsmall",
|
|
310
|
+
small: "small",
|
|
311
|
+
medium: "medium",
|
|
312
|
+
default: "default",
|
|
313
|
+
large: "large",
|
|
314
|
+
xLarge: "xlarge",
|
|
315
|
+
"2xLarge": "2xlarge",
|
|
316
|
+
auto: "auto",
|
|
317
|
+
expand: "expand",
|
|
318
|
+
block: "block",
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* @description Alignment keywords for element positioning.
|
|
322
|
+
* @summary Supplies canonical position values (horizontal and vertical) that decorators can
|
|
323
|
+
* use when aligning labels, controls, or helper text across components.
|
|
324
|
+
* @const ElementPositions
|
|
325
|
+
*/
|
|
326
|
+
exports.ElementPositions = {
|
|
327
|
+
left: "left",
|
|
328
|
+
center: "center",
|
|
329
|
+
right: "right",
|
|
330
|
+
top: "top",
|
|
331
|
+
bottom: "bottom",
|
|
332
|
+
};
|
|
333
|
+
/**
|
|
334
|
+
* @description Grid spacing presets for layout decorators.
|
|
335
|
+
* @summary Maps human-readable gap sizes to the tokens interpreted by the rendering engine
|
|
336
|
+
* when building CSS grid layouts, enabling predictable spacing across components.
|
|
337
|
+
* @const LayoutGridGaps
|
|
338
|
+
*/
|
|
339
|
+
exports.LayoutGridGaps = {
|
|
340
|
+
small: "small",
|
|
341
|
+
medium: "medium",
|
|
342
|
+
large: "large",
|
|
343
|
+
collapse: "collapse",
|
|
344
|
+
none: "",
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* @description Canonical action role identifiers for UI controls.
|
|
348
|
+
* @summary Enumerates the semantic roles a button or action may represent so decorators and
|
|
349
|
+
* renderers can attach consistent behaviors and styling (including CRUD verbs tied to
|
|
350
|
+
* `OperationKeys`).
|
|
351
|
+
* @const ActionRoles
|
|
352
|
+
*/
|
|
353
|
+
exports.ActionRoles = {
|
|
354
|
+
cancel: "cancel",
|
|
355
|
+
confirm: "confirm",
|
|
356
|
+
submit: "submit",
|
|
357
|
+
clear: "clear",
|
|
358
|
+
back: "back",
|
|
359
|
+
[db_decorators_1.OperationKeys.CREATE]: db_decorators_1.OperationKeys.CREATE,
|
|
360
|
+
[db_decorators_1.OperationKeys.READ]: db_decorators_1.OperationKeys.READ,
|
|
361
|
+
[db_decorators_1.OperationKeys.UPDATE]: db_decorators_1.OperationKeys.UPDATE,
|
|
362
|
+
[db_decorators_1.OperationKeys.DELETE]: db_decorators_1.OperationKeys.DELETE,
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* @description Allowed color scheme tokens for windowed surfaces.
|
|
366
|
+
* @summary Provides the supported theme identifiers exposed to consuming apps so they
|
|
367
|
+
* can target light, dark, or unset window color schemes in a predictable way.
|
|
368
|
+
* @const WindowColorSchemes
|
|
369
|
+
*/
|
|
370
|
+
exports.WindowColorSchemes = {
|
|
371
|
+
light: "light",
|
|
372
|
+
dark: "dark",
|
|
373
|
+
undefined: "undefined",
|
|
374
|
+
};
|
|
258
375
|
//# sourceMappingURL=constants.js.map
|
package/lib/ui/constants.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Validator } from "@decaf-ts/decorator-validation";
|
|
10
10
|
import { Constructor } from "@decaf-ts/decoration";
|
|
11
|
+
import { OperationKeys } from "@decaf-ts/db-decorators";
|
|
11
12
|
export declare enum UIMediaBreakPoints {
|
|
12
13
|
SMALL = "small",
|
|
13
14
|
MEDIUM = "medium",
|
|
@@ -230,3 +231,119 @@ export declare const HTML5InputTypes: {
|
|
|
230
231
|
* @memberOf module:ui-decorators
|
|
231
232
|
*/
|
|
232
233
|
export declare const HTML5CheckTypes: string[];
|
|
234
|
+
/**
|
|
235
|
+
* @description Event name constants.
|
|
236
|
+
* @summary Contains constants for standardized event names used throughout the application.
|
|
237
|
+
* These constants ensure consistent event naming across components and make it easier to
|
|
238
|
+
* track and handle events. Each constant represents a specific application event type.
|
|
239
|
+
* @typedef {Object} ComponentEventNames
|
|
240
|
+
* @property {string} BackButtonClickEvent - Event fired when back button navigation ends
|
|
241
|
+
* @property {string} Render - Event after component initialize action occurs
|
|
242
|
+
* @property {string} Refresh - Event fired when a refresh action occurs
|
|
243
|
+
* @property {string} Click - Event fired when a click action occurs
|
|
244
|
+
* @property {string} Change - Event fired when a change action occurs
|
|
245
|
+
* @property {string} Submit - Event fired when a form submission occurs
|
|
246
|
+
* @property {string} ValidationError - Event fired when a validation error occurs
|
|
247
|
+
* @property {string} ThemeChange - Event fired when a theme change occurs
|
|
248
|
+
* @property {string} FormGroupLoaded - Event fired when a reactve form group is loaded
|
|
249
|
+
* @const ComponentEventNames
|
|
250
|
+
*/
|
|
251
|
+
export declare const ComponentEventNames: {
|
|
252
|
+
readonly Render: "render";
|
|
253
|
+
readonly BackButtonClickEvent: "backButtonNavigationEndEvent";
|
|
254
|
+
readonly Refresh: "RefreshEvent";
|
|
255
|
+
readonly Click: "ClickEvent";
|
|
256
|
+
readonly Change: "ChangeEvent";
|
|
257
|
+
readonly Submit: "SubmitEvent";
|
|
258
|
+
readonly ValidationError: "validationErrorEvent";
|
|
259
|
+
readonly ThemeChange: "themeChangeEvent";
|
|
260
|
+
readonly FormGroupLoaded: "formGroupLoadedEvent";
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* @description Lifecycle hook labels for repository transactions.
|
|
264
|
+
* @summary Provides canonical names for CRUD lifecycle callbacks so decorators and
|
|
265
|
+
* components can register work before or after repository operations in a consistent way.
|
|
266
|
+
* Each key maps to the string used when wiring transaction middleware.
|
|
267
|
+
* @const TransactionHooks
|
|
268
|
+
*/
|
|
269
|
+
export declare const TransactionHooks: {
|
|
270
|
+
readonly BeforeCreate: "beforeCreate";
|
|
271
|
+
readonly AfterCreate: "afterCreate";
|
|
272
|
+
readonly BeforeUpdate: "beforeUpdate";
|
|
273
|
+
readonly AfterUpdate: "afterUpdate";
|
|
274
|
+
readonly BeforeDelete: "beforeDelete";
|
|
275
|
+
readonly AfterDelete: "afterDelete";
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* @description Standardized size tokens for UI elements.
|
|
279
|
+
* @summary Defines the semantic size keywords supported by layout and form decorators.
|
|
280
|
+
* These values feed rendering engines so components can express sizing in a uniform vocabulary.
|
|
281
|
+
* @const ElementSizes
|
|
282
|
+
*/
|
|
283
|
+
export declare const ElementSizes: {
|
|
284
|
+
readonly xsmall: "xsmall";
|
|
285
|
+
readonly small: "small";
|
|
286
|
+
readonly medium: "medium";
|
|
287
|
+
readonly default: "default";
|
|
288
|
+
readonly large: "large";
|
|
289
|
+
readonly xLarge: "xlarge";
|
|
290
|
+
readonly "2xLarge": "2xlarge";
|
|
291
|
+
readonly auto: "auto";
|
|
292
|
+
readonly expand: "expand";
|
|
293
|
+
readonly block: "block";
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* @description Alignment keywords for element positioning.
|
|
297
|
+
* @summary Supplies canonical position values (horizontal and vertical) that decorators can
|
|
298
|
+
* use when aligning labels, controls, or helper text across components.
|
|
299
|
+
* @const ElementPositions
|
|
300
|
+
*/
|
|
301
|
+
export declare const ElementPositions: {
|
|
302
|
+
readonly left: "left";
|
|
303
|
+
readonly center: "center";
|
|
304
|
+
readonly right: "right";
|
|
305
|
+
readonly top: "top";
|
|
306
|
+
readonly bottom: "bottom";
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* @description Grid spacing presets for layout decorators.
|
|
310
|
+
* @summary Maps human-readable gap sizes to the tokens interpreted by the rendering engine
|
|
311
|
+
* when building CSS grid layouts, enabling predictable spacing across components.
|
|
312
|
+
* @const LayoutGridGaps
|
|
313
|
+
*/
|
|
314
|
+
export declare const LayoutGridGaps: {
|
|
315
|
+
readonly small: "small";
|
|
316
|
+
readonly medium: "medium";
|
|
317
|
+
readonly large: "large";
|
|
318
|
+
readonly collapse: "collapse";
|
|
319
|
+
readonly none: "";
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* @description Canonical action role identifiers for UI controls.
|
|
323
|
+
* @summary Enumerates the semantic roles a button or action may represent so decorators and
|
|
324
|
+
* renderers can attach consistent behaviors and styling (including CRUD verbs tied to
|
|
325
|
+
* `OperationKeys`).
|
|
326
|
+
* @const ActionRoles
|
|
327
|
+
*/
|
|
328
|
+
export declare const ActionRoles: {
|
|
329
|
+
readonly cancel: "cancel";
|
|
330
|
+
readonly confirm: "confirm";
|
|
331
|
+
readonly submit: "submit";
|
|
332
|
+
readonly clear: "clear";
|
|
333
|
+
readonly back: "back";
|
|
334
|
+
readonly create: OperationKeys.CREATE;
|
|
335
|
+
readonly read: OperationKeys.READ;
|
|
336
|
+
readonly update: OperationKeys.UPDATE;
|
|
337
|
+
readonly delete: OperationKeys.DELETE;
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* @description Allowed color scheme tokens for windowed surfaces.
|
|
341
|
+
* @summary Provides the supported theme identifiers exposed to consuming apps so they
|
|
342
|
+
* can target light, dark, or unset window color schemes in a predictable way.
|
|
343
|
+
* @const WindowColorSchemes
|
|
344
|
+
*/
|
|
345
|
+
export declare const WindowColorSchemes: {
|
|
346
|
+
readonly light: "light";
|
|
347
|
+
readonly dark: "dark";
|
|
348
|
+
readonly undefined: "undefined";
|
|
349
|
+
};
|
package/lib/ui/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/ui/constants.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,yEAoBwC;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/ui/constants.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH,yEAoBwC;AAExC,2DAAwD;AAExD,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,qCAAe,CAAA;IACf,uCAAiB,CAAA;IACjB,qCAAe,CAAA;IACf,uCAAiB,CAAA;AACnB,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACU,QAAA,MAAM,GAAG;IACpB,OAAO,EAAE,IAAI;IACb,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,WAAW;IACpB,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,QAAQ;IACrB,YAAY,EAAE,uBAAuB;IAErC,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;IAC5B,QAAQ,EAAE,YAAY;IAEtB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,SAAS;IAEnB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ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A,cAAc,GAAG;IAC5B,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,EAAE;CACA,CAAC;AAEX;;;;;;GAMG;AACU,QAAA,WAAW,GAAG;IACzB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,CAAC,6BAAa,CAAC,MAAM,CAAC,EAAE,6BAAa,CAAC,MAAM;IAC5C,CAAC,6BAAa,CAAC,IAAI,CAAC,EAAE,6BAAa,CAAC,IAAI;IACxC,CAAC,6BAAa,CAAC,MAAM,CAAC,EAAE,6BAAa,CAAC,MAAM;IAC5C,CAAC,6BAAa,CAAC,MAAM,CAAC,EAAE,6BAAa,CAAC,MAAM;CACpC,CAAC;AAEX;;;;;GAKG;AACU,QAAA,kBAAkB,GAAG;IAChC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,WAAW;CACd,CAAC"}
|
package/lib/ui/decorators.cjs
CHANGED
|
@@ -10,6 +10,7 @@ exports.uilistprop = uilistprop;
|
|
|
10
10
|
exports.uilayoutprop = uilayoutprop;
|
|
11
11
|
exports.uipageprop = uipageprop;
|
|
12
12
|
exports.uion = uion;
|
|
13
|
+
exports.uionclick = uionclick;
|
|
13
14
|
exports.uionrender = uionrender;
|
|
14
15
|
exports.uitablecol = uitablecol;
|
|
15
16
|
const constants_1 = require("./constants.cjs");
|
|
@@ -172,6 +173,10 @@ function hidden() {
|
|
|
172
173
|
*/
|
|
173
174
|
function uielement(tag, props, serialize = false) {
|
|
174
175
|
return (original, propertyKey) => {
|
|
176
|
+
if (typeof tag === "object") {
|
|
177
|
+
props = tag;
|
|
178
|
+
tag = "";
|
|
179
|
+
}
|
|
175
180
|
const metadata = {
|
|
176
181
|
tag: tag,
|
|
177
182
|
serialize: serialize,
|
|
@@ -489,7 +494,7 @@ function uipageprop(page = 1) {
|
|
|
489
494
|
/**
|
|
490
495
|
* A decorator factory that binds a UI event to a specified handler function.
|
|
491
496
|
* This is used to attach event handlers to specific lifecycle events of a `DecafComponent`,
|
|
492
|
-
* such as `render`
|
|
497
|
+
* such as `render` | `initialize` | `handleClick` | `refresh`
|
|
493
498
|
*
|
|
494
499
|
* @param event - The name of the lifecycle event to bind the handler to.
|
|
495
500
|
* Must be one of the keys in `Pick<DecafComponent, 'render' | 'initialize'>`.
|
|
@@ -508,10 +513,20 @@ function uipageprop(page = 1) {
|
|
|
508
513
|
function uion(event, handler) {
|
|
509
514
|
return function uion(original, propertyKey) {
|
|
510
515
|
(0, decoration_1.propMetadata)((0, utils_1.getUIAttributeKey)(propertyKey, constants_1.UIKeys.EVENTS), {
|
|
511
|
-
[event]: handler,
|
|
516
|
+
...(typeof event === "object" ? event : { [event]: handler }),
|
|
512
517
|
})(original, propertyKey);
|
|
513
518
|
};
|
|
514
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* A decorator function that associates a UI click handler with the 'handleClick' event.
|
|
522
|
+
*
|
|
523
|
+
* @param handler - A function that conforms to the `UIFunctionLike` type, which will be executed
|
|
524
|
+
* when the 'handleClick' event is triggered.
|
|
525
|
+
* @returns A decorated function that binds the handler to the 'handleClick' event.
|
|
526
|
+
*/
|
|
527
|
+
function uionclick(handler) {
|
|
528
|
+
return uion("handleClick", handler);
|
|
529
|
+
}
|
|
515
530
|
/**
|
|
516
531
|
* A decorator function that associates a UI rendering handler with the 'render' event.
|
|
517
532
|
*
|
package/lib/ui/decorators.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { CrudOperationKeys, UIFunctionLike, UILayoutCol } from "./types";
|
|
2
|
-
import { DecafComponent } from "./DecafComponent";
|
|
3
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
1
|
+
import { CrudOperationKeys, UIEventName, UIFunctionLike, UILayoutCol } from "./types";
|
|
4
2
|
/**
|
|
5
3
|
* @description Decorator that hides a property during specific CRUD operations
|
|
6
4
|
* @summary Controls property visibility based on operation type
|
|
@@ -145,7 +143,7 @@ export declare function hidden(): (object: any, propertyKey?: any) => void;
|
|
|
145
143
|
* Model->>RenderingEngine: Return tag and props
|
|
146
144
|
* RenderingEngine->>UI: Render with specified element
|
|
147
145
|
*/
|
|
148
|
-
export declare function uielement(tag: string, props?: Record<string, any>, serialize?: boolean): (original: any, propertyKey?: any) => void;
|
|
146
|
+
export declare function uielement(tag: string | Record<string, any>, props?: Record<string, any>, serialize?: boolean): (original: any, propertyKey?: any) => void;
|
|
149
147
|
/**
|
|
150
148
|
* @description Decorator that maps a model property to a UI component property
|
|
151
149
|
* @summary Specifies how a property should be passed to a UI component
|
|
@@ -410,7 +408,7 @@ export declare function uipageprop(page?: number): (original: any, propertyKey?:
|
|
|
410
408
|
/**
|
|
411
409
|
* A decorator factory that binds a UI event to a specified handler function.
|
|
412
410
|
* This is used to attach event handlers to specific lifecycle events of a `DecafComponent`,
|
|
413
|
-
* such as `render`
|
|
411
|
+
* such as `render` | `initialize` | `handleClick` | `refresh`
|
|
414
412
|
*
|
|
415
413
|
* @param event - The name of the lifecycle event to bind the handler to.
|
|
416
414
|
* Must be one of the keys in `Pick<DecafComponent, 'render' | 'initialize'>`.
|
|
@@ -426,7 +424,15 @@ export declare function uipageprop(page?: number): (original: any, propertyKey?:
|
|
|
426
424
|
* }
|
|
427
425
|
* ```
|
|
428
426
|
*/
|
|
429
|
-
export declare function uion(event:
|
|
427
|
+
export declare function uion(event: UIEventName | Record<string, UIFunctionLike>, handler: UIFunctionLike): (original: object, propertyKey?: string) => void;
|
|
428
|
+
/**
|
|
429
|
+
* A decorator function that associates a UI click handler with the 'handleClick' event.
|
|
430
|
+
*
|
|
431
|
+
* @param handler - A function that conforms to the `UIFunctionLike` type, which will be executed
|
|
432
|
+
* when the 'handleClick' event is triggered.
|
|
433
|
+
* @returns A decorated function that binds the handler to the 'handleClick' event.
|
|
434
|
+
*/
|
|
435
|
+
export declare function uionclick(handler: UIFunctionLike): (original: object, propertyKey?: string) => void;
|
|
430
436
|
/**
|
|
431
437
|
* A decorator function that associates a UI rendering handler with the 'render' event.
|
|
432
438
|
*
|