@decaf-ts/ui-decorators 0.5.32 → 0.6.1
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/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/model/decorators.d.ts +1 -1
- package/lib/esm/model/decorators.js +15 -17
- package/lib/esm/model/decorators.js.map +1 -1
- package/lib/esm/model/model.d.ts +17 -0
- package/lib/esm/model/overrides.d.ts +1 -1
- package/lib/esm/model/overrides.js +74 -0
- package/lib/esm/model/overrides.js.map +1 -1
- package/lib/esm/ui/DecafComponent.d.ts +195 -0
- package/lib/esm/ui/DecafComponent.js +96 -0
- package/lib/esm/ui/DecafComponent.js.map +1 -0
- package/lib/esm/ui/Rendering.d.ts +1 -11
- package/lib/esm/ui/Rendering.js +139 -70
- package/lib/esm/ui/Rendering.js.map +1 -1
- package/lib/esm/ui/constants.d.ts +3 -1
- package/lib/esm/ui/constants.js +10 -10
- package/lib/esm/ui/constants.js.map +1 -1
- package/lib/esm/ui/decorators.d.ts +38 -10
- package/lib/esm/ui/decorators.js +53 -12
- package/lib/esm/ui/decorators.js.map +1 -1
- package/lib/esm/ui/index.d.ts +1 -0
- package/lib/esm/ui/index.js +1 -0
- package/lib/esm/ui/index.js.map +1 -1
- package/lib/esm/ui/types.d.ts +7 -3
- package/lib/esm/ui/utils.d.ts +1 -0
- package/lib/esm/ui/utils.js +24 -12
- package/lib/esm/ui/utils.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/model/decorators.cjs +15 -17
- package/lib/model/decorators.d.ts +1 -1
- package/lib/model/decorators.js.map +1 -1
- package/lib/model/model.d.ts +17 -0
- package/lib/model/overrides.cjs +74 -0
- package/lib/model/overrides.d.ts +1 -1
- package/lib/model/overrides.js.map +1 -1
- package/lib/ui/DecafComponent.cjs +100 -0
- package/lib/ui/DecafComponent.d.ts +195 -0
- package/lib/ui/DecafComponent.js.map +1 -0
- package/lib/ui/Rendering.cjs +138 -69
- package/lib/ui/Rendering.d.ts +1 -11
- package/lib/ui/Rendering.js.map +1 -1
- package/lib/ui/constants.cjs +9 -9
- package/lib/ui/constants.d.ts +3 -1
- package/lib/ui/constants.js.map +1 -1
- package/lib/ui/decorators.cjs +55 -12
- package/lib/ui/decorators.d.ts +38 -10
- package/lib/ui/decorators.js.map +1 -1
- package/lib/ui/index.cjs +1 -0
- package/lib/ui/index.d.ts +1 -0
- package/lib/ui/index.js.map +1 -1
- package/lib/ui/types.d.ts +7 -3
- package/lib/ui/utils.cjs +23 -10
- package/lib/ui/utils.d.ts +1 -0
- package/lib/ui/utils.js.map +1 -1
- package/package.json +2 -3
package/lib/ui/decorators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import {
|
|
1
|
+
import { CrudOperationKeys, UIFunctionLike, UILayoutCol } from "./types";
|
|
2
|
+
import { DecafComponent } from "./DecafComponent";
|
|
3
3
|
/**
|
|
4
4
|
* @description Decorator that hides a property during specific CRUD operations
|
|
5
5
|
* @summary Controls property visibility based on operation type
|
|
@@ -35,7 +35,7 @@ import { CrudOperationKeys, UILayoutCol } from "./types";
|
|
|
35
35
|
* Model->>RenderingEngine: Return hidden operations
|
|
36
36
|
* RenderingEngine->>UI: Render or hide based on current operation
|
|
37
37
|
*/
|
|
38
|
-
export declare function hideOn(...operations: CrudOperationKeys[]): (
|
|
38
|
+
export declare function hideOn(...operations: CrudOperationKeys[]): (object: any, propertyKey?: any) => void;
|
|
39
39
|
/**
|
|
40
40
|
* @description Decorator that sets the order of a UI element
|
|
41
41
|
* @summary Specifies the rendering order for UI components
|
|
@@ -65,7 +65,7 @@ export declare function hideOn(...operations: CrudOperationKeys[]): (target: obj
|
|
|
65
65
|
* uiorder->>property: sets order metadata
|
|
66
66
|
* uiorder->>System: returns decorated property
|
|
67
67
|
*/
|
|
68
|
-
export declare function uiorder(order?: number): (
|
|
68
|
+
export declare function uiorder(order?: number): (object: any, propertyKey?: any) => void;
|
|
69
69
|
/**
|
|
70
70
|
* @description Decorator that completely hides a property in all UI operations
|
|
71
71
|
* @summary Makes a property invisible in all CRUD operations
|
|
@@ -101,7 +101,7 @@ export declare function uiorder(order?: number): (target: object, propertyKey?:
|
|
|
101
101
|
* Model->>RenderingEngine: Return all operations
|
|
102
102
|
* RenderingEngine->>UI: Always hide property
|
|
103
103
|
*/
|
|
104
|
-
export declare function hidden(): (
|
|
104
|
+
export declare function hidden(): (object: any, propertyKey?: any) => void;
|
|
105
105
|
/**
|
|
106
106
|
* @description Decorator that specifies how a property should be rendered as a UI element
|
|
107
107
|
* @summary Maps a model property to a specific UI element with custom properties
|
|
@@ -188,7 +188,7 @@ export declare function uielement(tag: string, props?: Record<string, any>, seri
|
|
|
188
188
|
* Model->>RenderingEngine: Return prop name and stringify flag
|
|
189
189
|
* RenderingEngine->>Component: Pass property with specified name
|
|
190
190
|
*/
|
|
191
|
-
export declare function uiprop(propName?: string | undefined, stringify?: boolean): (target: any, propertyKey
|
|
191
|
+
export declare function uiprop(propName?: string | undefined, stringify?: boolean): (target: any, propertyKey?: any) => void;
|
|
192
192
|
/**
|
|
193
193
|
* @description Decorator that maps a nested model property to a UI component property.
|
|
194
194
|
* @summary Defines how a parent component should render the child model when nested.
|
|
@@ -242,7 +242,7 @@ export declare function uiprop(propName?: string | undefined, stringify?: boolea
|
|
|
242
242
|
* Model->>RenderingEngine: Return prop name, stringify flag, and child tag override
|
|
243
243
|
* RenderingEngine->>Component: Pass property with specified name and render with overridden tag if nested
|
|
244
244
|
*/
|
|
245
|
-
export declare function uichild(clazz: string, tag: string, props?: Record<string, any>, isArray?: boolean, serialize?: boolean): (target: any, propertyKey
|
|
245
|
+
export declare function uichild(clazz: string, tag: string, props?: Record<string, any>, isArray?: boolean, serialize?: boolean): (target: any, propertyKey?: any) => void;
|
|
246
246
|
/**
|
|
247
247
|
* @description Decorator that maps a model property to a list item component
|
|
248
248
|
* @summary Specifies how a property should be rendered in a list context
|
|
@@ -292,7 +292,7 @@ export declare function uichild(clazz: string, tag: string, props?: Record<strin
|
|
|
292
292
|
* RenderingEngine->>ListItems: Render each item using @uilistmodel
|
|
293
293
|
* ListContainer->>RenderingEngine: Return rendered list
|
|
294
294
|
*/
|
|
295
|
-
export declare function uilistprop(propName?: string | undefined, props?: Record<string, any>): (target: any, propertyKey
|
|
295
|
+
export declare function uilistprop(propName?: string | undefined, props?: Record<string, any>): (target: any, propertyKey?: any) => void;
|
|
296
296
|
/**
|
|
297
297
|
* @description Decorator that positions a property in a specific grid layout position
|
|
298
298
|
* @summary Specifies the column and row position for a property in a UI layout grid
|
|
@@ -343,7 +343,7 @@ export declare function uilistprop(propName?: string | undefined, props?: Record
|
|
|
343
343
|
* RenderingEngine->>LayoutContainer: Position element at grid coordinates
|
|
344
344
|
* LayoutContainer->>RenderingEngine: Return positioned element
|
|
345
345
|
*/
|
|
346
|
-
export declare function uilayoutprop(col?: UILayoutCol, row?: number): (target: any, propertyKey
|
|
346
|
+
export declare function uilayoutprop(col?: UILayoutCol, row?: number): (target: any, propertyKey?: any) => void;
|
|
347
347
|
/**
|
|
348
348
|
* @description Decorator that assigns a property to a specific page in multi-page forms
|
|
349
349
|
* @summary Specifies which page a property should appear on in paginated UI layouts
|
|
@@ -405,4 +405,32 @@ export declare function uilayoutprop(col?: UILayoutCol, row?: number): (target:
|
|
|
405
405
|
* RenderingEngine->>PaginationController: Group properties by page
|
|
406
406
|
* PaginationController->>UI: Render current page properties
|
|
407
407
|
*/
|
|
408
|
-
export declare function uipageprop(page?: number): (
|
|
408
|
+
export declare function uipageprop(page?: number): (original: any, propertyKey?: any) => void;
|
|
409
|
+
/**
|
|
410
|
+
* A decorator factory that binds a UI event to a specified handler function.
|
|
411
|
+
* This is used to attach event handlers to specific lifecycle events of a `DecafComponent`,
|
|
412
|
+
* such as `render` or `initialize`.
|
|
413
|
+
*
|
|
414
|
+
* @param event - The name of the lifecycle event to bind the handler to.
|
|
415
|
+
* Must be one of the keys in `Pick<DecafComponent, 'render' | 'initialize'>`.
|
|
416
|
+
* @param handler - The function to be executed when the specified event occurs.
|
|
417
|
+
*
|
|
418
|
+
* @returns A decorator function that applies the event-handler binding to the target object.
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* class MyComponent {
|
|
423
|
+
* @uion('render', () => console.log('Rendering...'))
|
|
424
|
+
* someProperty: string;
|
|
425
|
+
* }
|
|
426
|
+
* ```
|
|
427
|
+
*/
|
|
428
|
+
export declare function uion(event: keyof Pick<DecafComponent, 'render' | 'initialize'>, handler: UIFunctionLike): (original: object, propertyKey?: string) => void;
|
|
429
|
+
/**
|
|
430
|
+
* A decorator function that associates a UI rendering handler with the 'render' event.
|
|
431
|
+
*
|
|
432
|
+
* @param handler - A function that conforms to the `UIFunctionLike` type, which will be executed
|
|
433
|
+
* when the 'render' event is triggered.
|
|
434
|
+
* @returns A decorated function that binds the handler to the 'render' event.
|
|
435
|
+
*/
|
|
436
|
+
export declare function uionrender(handler: UIFunctionLike): (original: object, propertyKey?: string) => void;
|
package/lib/ui/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/ui/decorators.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/ui/decorators.ts"],"names":[],"mappings":";;AAkDA,wBAOC;AA+BD,0BAOC;AAqCD,wBAOC;AA4CD,8BAmBC;AA6CD,wBAcC;AAwDD,0BA4BC;AAmDD,gCAcC;AAoDD,oCAaC;AA+DD,gCAOC;AAqBD,oBAOC;AASD,gCAEC;AAxkBD,+CAAqC;AACrC,qDAAoD;AAUpD,2DAAwD;AACxD,uCAA4C;AAG5C;;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,UAAU,CAAC,QAAa,EAAE,WAAiB;QACzD,OAAO,IAAA,yBAAY,EAAC,IAAA,yBAAiB,EAAC,WAAW,EAAE,kBAAM,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CACpE,QAAQ,EACR,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,IAAI,CAAC,KAA0D,EAAE,OAAuB;IACtG,OAAO,SAAS,IAAI,CAAC,QAAgB,EAAE,WAAoB;QACzD,IAAA,yBAAY,EAAC,IAAA,yBAAiB,EAAC,WAAqB,EAAE,kBAAM,CAAC,MAAM,CAAC,EAAE,EAAC,CAAC,KAAK,CAAC,EAAE,OAAO,EAAC,CAAC,CACvF,QAAQ,EACR,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,OAAuB;IAChD,OAAO,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACjC,CAAC"}
|
package/lib/ui/index.cjs
CHANGED
|
@@ -22,4 +22,5 @@ __exportStar(require("./Rendering.cjs"), exports);
|
|
|
22
22
|
__exportStar(require("./types.cjs"), exports);
|
|
23
23
|
__exportStar(require("./handlers.cjs"), exports);
|
|
24
24
|
__exportStar(require("./utils.cjs"), exports);
|
|
25
|
+
__exportStar(require("./DecafComponent.cjs"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
package/lib/ui/index.d.ts
CHANGED
package/lib/ui/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA4B;AAC5B,mDAA6B;AAC7B,+CAAyB;AACzB,mDAA6B;AAC7B,kDAA4B;AAC5B,8CAAwB;AACxB,iDAA2B;AAC3B,8CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAA4B;AAC5B,mDAA6B;AAC7B,+CAAyB;AACzB,mDAA6B;AAC7B,kDAA4B;AAC5B,8CAAwB;AACxB,iDAA2B;AAC3B,8CAAwB;AACxB,uDAAiC"}
|
package/lib/ui/types.d.ts
CHANGED
|
@@ -162,17 +162,21 @@ export type UILayoutMetadata = {
|
|
|
162
162
|
* @typedef UIClassMetadata
|
|
163
163
|
* @memberOf module:ui-decorators
|
|
164
164
|
*/
|
|
165
|
-
export type UIClassMetadata = UILayoutMetadata | UIModelMetadata | UIListModelMetadata;
|
|
165
|
+
export type UIClassMetadata = UILayoutMetadata | UIModelMetadata | UIHandlerMetadata | UIListModelMetadata;
|
|
166
166
|
/**
|
|
167
167
|
* @typedef UILayoutCol
|
|
168
168
|
* @memberOf module:ui-decorators
|
|
169
169
|
*/
|
|
170
|
-
export type UILayoutCol = number |
|
|
170
|
+
export type UILayoutCol = number | "half" | "full" | "auto" | "expand";
|
|
171
171
|
/**
|
|
172
172
|
* @typedef UIListItemPosition
|
|
173
173
|
* @memberOf module:ui-decorators
|
|
174
174
|
*/
|
|
175
|
-
export type UIListItemPosition =
|
|
175
|
+
export type UIListItemPosition = "title" | "description" | "info" | "subinfo";
|
|
176
|
+
export type UIFunctionLike = (...args: unknown[]) => unknown | Promise<unknown>;
|
|
177
|
+
export type UIHandlerMetadata = {
|
|
178
|
+
handlers?: Record<string, UIFunctionLike>;
|
|
179
|
+
};
|
|
176
180
|
/**
|
|
177
181
|
* @typedef UILayoutPropMetadata
|
|
178
182
|
* @memberOf module:ui-decorators
|
package/lib/ui/utils.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getUIAttributeKey = getUIAttributeKey;
|
|
3
4
|
exports.formatByType = formatByType;
|
|
4
5
|
exports.parseValueByType = parseValueByType;
|
|
5
6
|
exports.parseToNumber = parseToNumber;
|
|
@@ -9,6 +10,10 @@ exports.generateUIModelID = generateUIModelID;
|
|
|
9
10
|
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
10
11
|
const constants_1 = require("./constants.cjs");
|
|
11
12
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
13
|
+
const decoration_1 = require("@decaf-ts/decoration");
|
|
14
|
+
function getUIAttributeKey(prop, key) {
|
|
15
|
+
return decoration_1.Metadata.key(constants_1.UIKeys.REFLECT, decoration_1.DecorationKeys.PROPERTIES, prop, key);
|
|
16
|
+
}
|
|
12
17
|
/**
|
|
13
18
|
* @function formatByType
|
|
14
19
|
*
|
|
@@ -27,7 +32,9 @@ function parseValueByType(type, value, fieldProps) {
|
|
|
27
32
|
let result = undefined;
|
|
28
33
|
switch (type) {
|
|
29
34
|
case Array.name: {
|
|
30
|
-
const parsed = Array.isArray(value)
|
|
35
|
+
const parsed = Array.isArray(value)
|
|
36
|
+
? value.map((v) => parseValueByType(decorator_validation_1.ReservedModels.STRING.name.toLowerCase(), v, fieldProps))
|
|
37
|
+
: [value];
|
|
31
38
|
result = parsed.join(",");
|
|
32
39
|
break;
|
|
33
40
|
}
|
|
@@ -38,7 +45,7 @@ function parseValueByType(type, value, fieldProps) {
|
|
|
38
45
|
const format = fieldProps.format;
|
|
39
46
|
if (value && `${value}`.trim().length) {
|
|
40
47
|
result =
|
|
41
|
-
typeof value === decorator_validation_1.ReservedModels.NUMBER
|
|
48
|
+
typeof value === decorator_validation_1.ReservedModels.NUMBER.name.toLowerCase()
|
|
42
49
|
? new Date(value)
|
|
43
50
|
: value
|
|
44
51
|
? format
|
|
@@ -50,11 +57,15 @@ function parseValueByType(type, value, fieldProps) {
|
|
|
50
57
|
}
|
|
51
58
|
default:
|
|
52
59
|
result =
|
|
53
|
-
typeof value === decorator_validation_1.ReservedModels.OBJECT
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
typeof value === decorator_validation_1.ReservedModels.OBJECT.name.toLowerCase()
|
|
61
|
+
? Array.isArray(value)
|
|
62
|
+
? value.join(",")
|
|
63
|
+
: JSON.stringify(value)
|
|
64
|
+
: typeof value === decorator_validation_1.ReservedModels.BOOLEAN.name.toLowerCase()
|
|
65
|
+
? value
|
|
66
|
+
: typeof value === decorator_validation_1.ReservedModels.STRING.name.toLowerCase()
|
|
67
|
+
? escapeHtml(value)
|
|
68
|
+
: result;
|
|
58
69
|
}
|
|
59
70
|
if (typeof result === "undefined") {
|
|
60
71
|
throw new db_decorators_1.InternalError(`Failed to parse value of type ${type} from ${typeof value} - ${value}`);
|
|
@@ -92,13 +103,15 @@ function revertHtml(value) {
|
|
|
92
103
|
});
|
|
93
104
|
}
|
|
94
105
|
function generateUIModelID(model) {
|
|
95
|
-
let id;
|
|
106
|
+
let id = Date.now();
|
|
96
107
|
try {
|
|
97
|
-
|
|
108
|
+
const pk = decorator_validation_1.Model.pk(model.constructor);
|
|
109
|
+
if (pk)
|
|
110
|
+
id = model[decorator_validation_1.Model.pk(model.constructor)];
|
|
98
111
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
99
112
|
}
|
|
100
113
|
catch (e) {
|
|
101
|
-
|
|
114
|
+
// do nothing;
|
|
102
115
|
}
|
|
103
116
|
const name = model.constructor.name;
|
|
104
117
|
return `${name}-${id}`;
|
package/lib/ui/utils.d.ts
CHANGED
package/lib/ui/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/ui/utils.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/ui/utils.ts"],"names":[],"mappings":";;AAWA,8CAEC;AAOD,oCAWC;AAED,4CAuDC;AAED,sCAOC;AAED,gCAWC;AAED,gCAUC;AAED,8CAcC;AA1ID,yEAKwC;AACxC,+CAAuE;AACvE,2DAAwD;A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KAAK,CAAC,WAAW,CAAuB,CAElD,CAAC;QACb,6DAA6D;IAC/D,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QACpB,cAAc;IAChB,CAAC;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,OAAO,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decaf-ts/ui-decorators",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Extension of decorator validation to ui elements to allow for web integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -88,7 +88,6 @@
|
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@decaf-ts/db-decorators": "latest",
|
|
90
90
|
"@decaf-ts/decoration": "latest",
|
|
91
|
-
"@decaf-ts/decorator-validation": "latest"
|
|
92
|
-
"@decaf-ts/reflection": "latest"
|
|
91
|
+
"@decaf-ts/decorator-validation": "latest"
|
|
93
92
|
}
|
|
94
93
|
}
|