@decaf-ts/ui-decorators 0.6.6 → 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 +117 -45
- package/lib/esm/ui/DecafComponent.js +96 -12
- package/lib/esm/ui/DecafComponent.js.map +1 -1
- package/lib/esm/ui/DecafEventHandler.d.ts +18 -1
- package/lib/esm/ui/DecafEventHandler.js +27 -1
- 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 -5
- package/lib/esm/ui/decorators.js +21 -5
- 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 +96 -11
- package/lib/ui/DecafComponent.d.ts +117 -45
- package/lib/ui/DecafComponent.js.map +1 -1
- package/lib/ui/DecafEventHandler.cjs +27 -1
- package/lib/ui/DecafEventHandler.d.ts +18 -1
- 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 +22 -5
- package/lib/ui/decorators.d.ts +12 -5
- package/lib/ui/decorators.js.map +1 -1
- package/lib/ui/types.d.ts +5 -1
- package/package.json +4 -2
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'>`.
|
|
@@ -507,9 +512,21 @@ function uipageprop(page = 1) {
|
|
|
507
512
|
*/
|
|
508
513
|
function uion(event, handler) {
|
|
509
514
|
return function uion(original, propertyKey) {
|
|
510
|
-
(0, decoration_1.propMetadata)((0, utils_1.getUIAttributeKey)(propertyKey, constants_1.UIKeys.EVENTS), {
|
|
515
|
+
(0, decoration_1.propMetadata)((0, utils_1.getUIAttributeKey)(propertyKey, constants_1.UIKeys.EVENTS), {
|
|
516
|
+
...(typeof event === "object" ? event : { [event]: handler }),
|
|
517
|
+
})(original, propertyKey);
|
|
511
518
|
};
|
|
512
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
|
+
}
|
|
513
530
|
/**
|
|
514
531
|
* A decorator function that associates a UI rendering handler with the 'render' event.
|
|
515
532
|
*
|
|
@@ -518,7 +535,7 @@ function uion(event, handler) {
|
|
|
518
535
|
* @returns A decorated function that binds the handler to the 'render' event.
|
|
519
536
|
*/
|
|
520
537
|
function uionrender(handler) {
|
|
521
|
-
return uion(
|
|
538
|
+
return uion("render", handler);
|
|
522
539
|
}
|
|
523
540
|
/**
|
|
524
541
|
* @description Decorator that marks a property as a column in a UI table
|
|
@@ -563,8 +580,8 @@ function uitablecol(sequence, valueParserFn) {
|
|
|
563
580
|
name: propertyKey,
|
|
564
581
|
props: {
|
|
565
582
|
sequence,
|
|
566
|
-
|
|
567
|
-
}
|
|
583
|
+
...(!valueParserFn ? {} : { valueParserFn }),
|
|
584
|
+
},
|
|
568
585
|
};
|
|
569
586
|
(0, decoration_1.propMetadata)((0, utils_1.getUIAttributeKey)(propertyKey, constants_1.UIKeys.UILISTPROP), metadata)(target, propertyKey);
|
|
570
587
|
};
|
package/lib/ui/decorators.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CrudOperationKeys, UIFunctionLike, UILayoutCol } from "./types";
|
|
2
|
-
import { DecafComponent } from "./DecafComponent";
|
|
1
|
+
import { CrudOperationKeys, UIEventName, UIFunctionLike, UILayoutCol } from "./types";
|
|
3
2
|
/**
|
|
4
3
|
* @description Decorator that hides a property during specific CRUD operations
|
|
5
4
|
* @summary Controls property visibility based on operation type
|
|
@@ -144,7 +143,7 @@ export declare function hidden(): (object: any, propertyKey?: any) => void;
|
|
|
144
143
|
* Model->>RenderingEngine: Return tag and props
|
|
145
144
|
* RenderingEngine->>UI: Render with specified element
|
|
146
145
|
*/
|
|
147
|
-
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;
|
|
148
147
|
/**
|
|
149
148
|
* @description Decorator that maps a model property to a UI component property
|
|
150
149
|
* @summary Specifies how a property should be passed to a UI component
|
|
@@ -409,7 +408,7 @@ export declare function uipageprop(page?: number): (original: any, propertyKey?:
|
|
|
409
408
|
/**
|
|
410
409
|
* A decorator factory that binds a UI event to a specified handler function.
|
|
411
410
|
* This is used to attach event handlers to specific lifecycle events of a `DecafComponent`,
|
|
412
|
-
* such as `render`
|
|
411
|
+
* such as `render` | `initialize` | `handleClick` | `refresh`
|
|
413
412
|
*
|
|
414
413
|
* @param event - The name of the lifecycle event to bind the handler to.
|
|
415
414
|
* Must be one of the keys in `Pick<DecafComponent, 'render' | 'initialize'>`.
|
|
@@ -425,7 +424,15 @@ export declare function uipageprop(page?: number): (original: any, propertyKey?:
|
|
|
425
424
|
* }
|
|
426
425
|
* ```
|
|
427
426
|
*/
|
|
428
|
-
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;
|
|
429
436
|
/**
|
|
430
437
|
* A decorator function that associates a UI rendering handler with the 'render' event.
|
|
431
438
|
*
|
package/lib/ui/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/ui/decorators.ts"],"names":[],"mappings":";;AAkDA,wBAOC;AA+BD,0BAOC;AAqCD,wBAOC;AA4CD,
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/ui/decorators.ts"],"names":[],"mappings":";;AAkDA,wBAOC;AA+BD,0BAOC;AAqCD,wBAOC;AA4CD,8BAuBC;AA6CD,wBAcC;AAwDD,0BA4BC;AAmDD,gCAcC;AAoDD,oCAaC;AA+DD,gCAOC;AAqBD,oBASC;AASD,8BAEC;AASD,gCAEC;AAuCD,gCAcC;AA9oBD,+CAAqC;AACrC,qDAAoD;AAWpD,2DAAwD;AACxD,uCAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,MAAM,CAAC,GAAG,UAA+B;IACvD,OAAO,SAAS,MAAM,CAAC,MAAW,EAAE,WAAiB;QACnD,OAAO,IAAA,yBAAY,EACjB,IAAA,yBAAiB,EAAC,WAAW,EAAE,kBAAM,CAAC,MAAM,CAAC,EAC7C,UAAU,CACX,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,SAAgB,OAAO,CAAC,QAAgB,CAAC;IACvC,OAAO,SAAS,OAAO,CAAC,MAAW,EAAE,WAAiB;QACpD,OAAO,IAAA,yBAAY,EAAC,IAAA,yBAAiB,EAAC,WAAW,EAAE,kBAAM,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CACtE,MAAM,EACN,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,SAAgB,MAAM;IACpB,OAAO,MAAM,CACX,6BAAa,CAAC,MAAM,EACpB,6BAAa,CAAC,IAAI,EAClB,6BAAa,CAAC,MAAM,EACpB,6BA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AACH,SAAgB,SAAS,CAAC,OAAuB;IAC/C,OAAO,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,OAAuB;IAChD,OAAO,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,SAAgB,UAAU,CAAC,QAAgB,EAAE,aAA8B;IACzE,OAAO,CAAC,MAAW,EAAE,WAAiB,EAAE,EAAE;QACxC,MAAM,QAAQ,GAAgC;YAC5C,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE;gBACL,QAAQ;gBACR,GAAG,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC;aAC7C;SACF,CAAC;QACF,IAAA,yBAAY,EAAC,IAAA,yBAAiB,EAAC,WAAW,EAAE,kBAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,CACvE,MAAM,EACN,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/ui/types.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { OperationKeys } from "@decaf-ts/db-decorators";
|
|
10
10
|
import { UIKeys, UIMediaBreakPoints } from "./constants";
|
|
11
|
+
import { DecafEventHandler } from "./DecafEventHandler";
|
|
11
12
|
/**
|
|
12
13
|
* @description Interface for defining a UI field or component
|
|
13
14
|
* @summary Represents a renderable UI element with properties and children
|
|
@@ -83,6 +84,7 @@ export interface FieldProperties {
|
|
|
83
84
|
step?: number;
|
|
84
85
|
format?: string;
|
|
85
86
|
pk?: string;
|
|
87
|
+
subType?: string;
|
|
86
88
|
multiple?: boolean;
|
|
87
89
|
customTypes?: string | string[];
|
|
88
90
|
options?: Record<string, unknown>[];
|
|
@@ -174,8 +176,10 @@ export type UILayoutCol = number | "half" | "full" | "auto" | "expand";
|
|
|
174
176
|
*/
|
|
175
177
|
export type UIListItemPosition = "title" | "description" | "info" | "subinfo";
|
|
176
178
|
export type UIFunctionLike = (...args: any[]) => any | Promise<any>;
|
|
179
|
+
export type UIEventName = keyof Pick<DecafEventHandler, "render" | "initialize" | "handleClick" | "refresh">;
|
|
180
|
+
export type UIEventProperty = Record<string, UIFunctionLike>;
|
|
177
181
|
export type UIHandlerMetadata = {
|
|
178
|
-
handlers?:
|
|
182
|
+
handlers?: UIEventProperty;
|
|
179
183
|
};
|
|
180
184
|
/**
|
|
181
185
|
* @typedef UILayoutPropMetadata
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decaf-ts/ui-decorators",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"description": "Extension of decorator validation to ui elements to allow for web integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -89,6 +89,8 @@
|
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@decaf-ts/db-decorators": "latest",
|
|
91
91
|
"@decaf-ts/decoration": "latest",
|
|
92
|
-
"@decaf-ts/decorator-validation": "latest"
|
|
92
|
+
"@decaf-ts/decorator-validation": "latest",
|
|
93
|
+
"better-docs": "^2.7.3",
|
|
94
|
+
"taffydb": "^2.7.3"
|
|
93
95
|
}
|
|
94
96
|
}
|