@decaf-ts/ui-decorators 0.4.4 → 0.4.5
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/LICENSE.md +0 -0
- package/README.md +0 -0
- package/package.json +1 -1
- package/dist/esm/ui-decorators.bundle.min.esm.js +0 -2
- package/dist/esm/ui-decorators.bundle.min.esm.js.LICENSE.txt +0 -14
- package/dist/ui-decorators.bundle.min.js +0 -2
- package/dist/ui-decorators.bundle.min.js.LICENSE.txt +0 -14
- package/lib/esm/index.d.ts +0 -12
- package/lib/esm/index.js +0 -14
- package/lib/esm/model/Renderable.d.ts +0 -3
- package/lib/esm/model/Renderable.js +0 -3
- package/lib/esm/model/decorators.d.ts +0 -25
- package/lib/esm/model/decorators.js +0 -41
- package/lib/esm/model/index.d.ts +0 -8
- package/lib/esm/model/index.js +0 -10
- package/lib/esm/model/model.d.ts +0 -115
- package/lib/esm/model/model.js +0 -3
- package/lib/esm/model/overrides.d.ts +0 -1
- package/lib/esm/model/overrides.js +0 -7
- package/lib/esm/ui/Rendering.d.ts +0 -182
- package/lib/esm/ui/Rendering.js +0 -317
- package/lib/esm/ui/constants.d.ts +0 -64
- package/lib/esm/ui/constants.js +0 -88
- package/lib/esm/ui/decorators.d.ts +0 -34
- package/lib/esm/ui/decorators.js +0 -62
- package/lib/esm/ui/errors.d.ts +0 -4
- package/lib/esm/ui/errors.js +0 -8
- package/lib/esm/ui/index.d.ts +0 -11
- package/lib/esm/ui/index.js +0 -13
- package/lib/esm/ui/interfaces.d.ts +0 -5
- package/lib/esm/ui/interfaces.js +0 -3
- package/lib/esm/ui/types.d.ts +0 -46
- package/lib/esm/ui/types.js +0 -3
- package/lib/esm/ui/utils.d.ts +0 -11
- package/lib/esm/ui/utils.js +0 -59
- package/lib/index.cjs +0 -29
- package/lib/index.d.ts +0 -12
- package/lib/model/Renderable.cjs +0 -2
- package/lib/model/Renderable.d.ts +0 -3
- package/lib/model/decorators.cjs +0 -43
- package/lib/model/decorators.d.ts +0 -25
- package/lib/model/index.cjs +0 -24
- package/lib/model/index.d.ts +0 -8
- package/lib/model/model.cjs +0 -2
- package/lib/model/model.d.ts +0 -115
- package/lib/model/overrides.cjs +0 -7
- package/lib/model/overrides.d.ts +0 -1
- package/lib/ui/Rendering.cjs +0 -319
- package/lib/ui/Rendering.d.ts +0 -182
- package/lib/ui/constants.cjs +0 -89
- package/lib/ui/constants.d.ts +0 -64
- package/lib/ui/decorators.cjs +0 -66
- package/lib/ui/decorators.d.ts +0 -34
- package/lib/ui/errors.cjs +0 -10
- package/lib/ui/errors.d.ts +0 -4
- package/lib/ui/index.cjs +0 -27
- package/lib/ui/index.d.ts +0 -11
- package/lib/ui/interfaces.cjs +0 -2
- package/lib/ui/interfaces.d.ts +0 -5
- package/lib/ui/types.cjs +0 -2
- package/lib/ui/types.d.ts +0 -46
- package/lib/ui/utils.cjs +0 -64
- package/lib/ui/utils.d.ts +0 -11
package/lib/ui/decorators.cjs
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hideOn = hideOn;
|
|
4
|
-
exports.hidden = hidden;
|
|
5
|
-
exports.uielement = uielement;
|
|
6
|
-
exports.uiprop = uiprop;
|
|
7
|
-
require("reflect-metadata");
|
|
8
|
-
const constants_1 = require("./constants.cjs");
|
|
9
|
-
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
10
|
-
const Rendering_1 = require("./Rendering.cjs");
|
|
11
|
-
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
12
|
-
/**
|
|
13
|
-
* @namespace ui-decorators.ui.decorators
|
|
14
|
-
* @memberOf ui-decorators.ui
|
|
15
|
-
*/
|
|
16
|
-
function hideOn(...operations) {
|
|
17
|
-
return (0, decorator_validation_1.propMetadata)(Rendering_1.RenderingEngine.key(constants_1.UIKeys.HIDDEN), operations);
|
|
18
|
-
}
|
|
19
|
-
function hidden() {
|
|
20
|
-
return hideOn(db_decorators_1.OperationKeys.CREATE, db_decorators_1.OperationKeys.READ, db_decorators_1.OperationKeys.UPDATE, db_decorators_1.OperationKeys.DELETE);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Adds the UIElement definition as metadata to the property, allowing it to be read by any {@link RenderStrategy}
|
|
24
|
-
*
|
|
25
|
-
* @param {string} tag The component/HTML element tag name
|
|
26
|
-
* @param {{}} [props] The properties to pass to that component/HTML Element
|
|
27
|
-
* @param serialize
|
|
28
|
-
*
|
|
29
|
-
* @decorator uielement
|
|
30
|
-
*
|
|
31
|
-
* @category Decorators
|
|
32
|
-
* @subcategory ui-decorators
|
|
33
|
-
*/
|
|
34
|
-
function uielement(tag, props, serialize = false) {
|
|
35
|
-
return (original, propertyKey) => {
|
|
36
|
-
const metadata = {
|
|
37
|
-
tag: tag,
|
|
38
|
-
serialize: serialize,
|
|
39
|
-
props: Object.assign({
|
|
40
|
-
name: propertyKey,
|
|
41
|
-
}, props || {}),
|
|
42
|
-
};
|
|
43
|
-
return (0, decorator_validation_1.propMetadata)(Rendering_1.RenderingEngine.key(constants_1.UIKeys.ELEMENT), metadata)(original, propertyKey);
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Adds the UIProp definition as metadata to the property, allowing it to be read by any {@link RenderStrategy}
|
|
48
|
-
*
|
|
49
|
-
* this requires a '@uimodel' with a defined tag
|
|
50
|
-
*
|
|
51
|
-
* @param {string} [propName] the property name that will be passed to the component. defaults to the PropertyKey
|
|
52
|
-
*
|
|
53
|
-
* @decorator uiprop
|
|
54
|
-
*
|
|
55
|
-
* @category Decorators
|
|
56
|
-
* @subcategory ui-decorators
|
|
57
|
-
*/
|
|
58
|
-
function uiprop(propName = undefined, stringify = false) {
|
|
59
|
-
return (target, propertyKey) => {
|
|
60
|
-
const metadata = {
|
|
61
|
-
name: propName || propertyKey,
|
|
62
|
-
stringify: stringify,
|
|
63
|
-
};
|
|
64
|
-
(0, decorator_validation_1.propMetadata)(Rendering_1.RenderingEngine.key(constants_1.UIKeys.PROP), metadata)(target, propertyKey);
|
|
65
|
-
};
|
|
66
|
-
}
|
package/lib/ui/decorators.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import "reflect-metadata";
|
|
2
|
-
import { CrudOperationKeys } from "./types";
|
|
3
|
-
/**
|
|
4
|
-
* @namespace ui-decorators.ui.decorators
|
|
5
|
-
* @memberOf ui-decorators.ui
|
|
6
|
-
*/
|
|
7
|
-
export declare function hideOn(...operations: CrudOperationKeys[]): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
|
|
8
|
-
export declare function hidden(): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
|
|
9
|
-
/**
|
|
10
|
-
* Adds the UIElement definition as metadata to the property, allowing it to be read by any {@link RenderStrategy}
|
|
11
|
-
*
|
|
12
|
-
* @param {string} tag The component/HTML element tag name
|
|
13
|
-
* @param {{}} [props] The properties to pass to that component/HTML Element
|
|
14
|
-
* @param serialize
|
|
15
|
-
*
|
|
16
|
-
* @decorator uielement
|
|
17
|
-
*
|
|
18
|
-
* @category Decorators
|
|
19
|
-
* @subcategory ui-decorators
|
|
20
|
-
*/
|
|
21
|
-
export declare function uielement(tag: string, props?: Record<string, any>, serialize?: boolean): (original: any, propertyKey?: any) => void;
|
|
22
|
-
/**
|
|
23
|
-
* Adds the UIProp definition as metadata to the property, allowing it to be read by any {@link RenderStrategy}
|
|
24
|
-
*
|
|
25
|
-
* this requires a '@uimodel' with a defined tag
|
|
26
|
-
*
|
|
27
|
-
* @param {string} [propName] the property name that will be passed to the component. defaults to the PropertyKey
|
|
28
|
-
*
|
|
29
|
-
* @decorator uiprop
|
|
30
|
-
*
|
|
31
|
-
* @category Decorators
|
|
32
|
-
* @subcategory ui-decorators
|
|
33
|
-
*/
|
|
34
|
-
export declare function uiprop(propName?: string | undefined, stringify?: boolean): (target: any, propertyKey: string) => void;
|
package/lib/ui/errors.cjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RenderingError = void 0;
|
|
4
|
-
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
5
|
-
class RenderingError extends db_decorators_1.BaseError {
|
|
6
|
-
constructor(msg) {
|
|
7
|
-
super(RenderingError.name, msg);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.RenderingError = RenderingError;
|
package/lib/ui/errors.d.ts
DELETED
package/lib/ui/index.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @namespace ui-decorators.ui
|
|
4
|
-
* @memberOf ui-decorators
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
__exportStar(require("./constants.cjs"), exports);
|
|
22
|
-
__exportStar(require("./decorators.cjs"), exports);
|
|
23
|
-
__exportStar(require("./errors.cjs"), exports);
|
|
24
|
-
__exportStar(require("./interfaces.cjs"), exports);
|
|
25
|
-
__exportStar(require("./Rendering.cjs"), exports);
|
|
26
|
-
__exportStar(require("./types.cjs"), exports);
|
|
27
|
-
__exportStar(require("./utils.cjs"), exports);
|
package/lib/ui/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @namespace ui-decorators.ui
|
|
3
|
-
* @memberOf ui-decorators
|
|
4
|
-
*/
|
|
5
|
-
export * from "./constants";
|
|
6
|
-
export * from "./decorators";
|
|
7
|
-
export * from "./errors";
|
|
8
|
-
export * from "./interfaces";
|
|
9
|
-
export * from "./Rendering";
|
|
10
|
-
export * from "./types";
|
|
11
|
-
export * from "./utils";
|
package/lib/ui/interfaces.cjs
DELETED
package/lib/ui/interfaces.d.ts
DELETED
package/lib/ui/types.cjs
DELETED
package/lib/ui/types.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { OperationKeys } from "@decaf-ts/db-decorators";
|
|
2
|
-
export interface FieldDefinition<T = void> {
|
|
3
|
-
tag: string;
|
|
4
|
-
rendererId?: string;
|
|
5
|
-
props: T & FieldProperties;
|
|
6
|
-
children?: FieldDefinition<T>[];
|
|
7
|
-
}
|
|
8
|
-
export interface FieldProperties {
|
|
9
|
-
name: string;
|
|
10
|
-
type: string;
|
|
11
|
-
value: string | number | Date;
|
|
12
|
-
hidden?: boolean;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
required?: boolean;
|
|
15
|
-
readonly?: boolean;
|
|
16
|
-
maxLength?: number;
|
|
17
|
-
minLength?: number;
|
|
18
|
-
max?: number | Date;
|
|
19
|
-
min?: number | Date;
|
|
20
|
-
pattern?: string;
|
|
21
|
-
step?: number;
|
|
22
|
-
format?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @typedef UIElementMetadata
|
|
26
|
-
* @memberOf ui-decorators.ui.decorators
|
|
27
|
-
*/
|
|
28
|
-
export type UIElementMetadata = {
|
|
29
|
-
tag: string;
|
|
30
|
-
props?: Record<string, any>;
|
|
31
|
-
serialize?: boolean;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* @typedef UIElementMetadata
|
|
35
|
-
* @memberOf ui-decorators.ui.decorators
|
|
36
|
-
*/
|
|
37
|
-
export type UIModelMetadata = Omit<UIElementMetadata, "serialize">;
|
|
38
|
-
/**
|
|
39
|
-
* @typedef UIPropMetadata
|
|
40
|
-
* @memberOf ui-decorators.ui.decorators
|
|
41
|
-
*/
|
|
42
|
-
export type UIPropMetadata = {
|
|
43
|
-
name: string;
|
|
44
|
-
stringify: boolean;
|
|
45
|
-
};
|
|
46
|
-
export type CrudOperationKeys = OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE;
|
package/lib/ui/utils.cjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatByType = formatByType;
|
|
4
|
-
exports.parseToNumber = parseToNumber;
|
|
5
|
-
exports.escapeHtml = escapeHtml;
|
|
6
|
-
exports.revertHtml = revertHtml;
|
|
7
|
-
exports.generateUIModelID = generateUIModelID;
|
|
8
|
-
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
9
|
-
const constants_1 = require("./constants.cjs");
|
|
10
|
-
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
11
|
-
/**
|
|
12
|
-
* @function formatByType
|
|
13
|
-
*
|
|
14
|
-
* @memberOf ui-decorators-web.ui
|
|
15
|
-
*/
|
|
16
|
-
function formatByType(type, value, ...args) {
|
|
17
|
-
if (type === constants_1.UIKeys.DATE) {
|
|
18
|
-
const format = args.shift() || constants_1.HTML5DateFormat;
|
|
19
|
-
return (0, decorator_validation_1.formatDate)(new Date(value), format);
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
23
|
-
function parseToNumber(value) {
|
|
24
|
-
if (typeof value === "number" && !isNaN(value))
|
|
25
|
-
return value;
|
|
26
|
-
const parsed = Number(value);
|
|
27
|
-
if (!isNaN(parsed))
|
|
28
|
-
return parsed;
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
function escapeHtml(value) {
|
|
32
|
-
if (!value)
|
|
33
|
-
return undefined;
|
|
34
|
-
const tagsToReplace = {
|
|
35
|
-
"&": "&",
|
|
36
|
-
"<": "<",
|
|
37
|
-
">": ">",
|
|
38
|
-
};
|
|
39
|
-
return `${value}`.replace(/[&<>]/g, (tag) => {
|
|
40
|
-
return tagsToReplace[tag] || tag;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function revertHtml(value) {
|
|
44
|
-
const tagsToReplace = {
|
|
45
|
-
"&": "&",
|
|
46
|
-
"<": "<",
|
|
47
|
-
">": ">",
|
|
48
|
-
};
|
|
49
|
-
return `${value}`.replace(/<|>|&/g, (tag) => {
|
|
50
|
-
return tagsToReplace[tag] || tag;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
function generateUIModelID(model) {
|
|
54
|
-
let id;
|
|
55
|
-
try {
|
|
56
|
-
id = (0, db_decorators_1.findModelId)(model);
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
58
|
-
}
|
|
59
|
-
catch (e) {
|
|
60
|
-
id = Date.now();
|
|
61
|
-
}
|
|
62
|
-
const name = model.constructor.name;
|
|
63
|
-
return `${name}-${id}`;
|
|
64
|
-
}
|
package/lib/ui/utils.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
|
-
/**
|
|
3
|
-
* @function formatByType
|
|
4
|
-
*
|
|
5
|
-
* @memberOf ui-decorators-web.ui
|
|
6
|
-
*/
|
|
7
|
-
export declare function formatByType(type: any, value: any, ...args: unknown[]): string | number;
|
|
8
|
-
export declare function parseToNumber(value: string | number): number | undefined;
|
|
9
|
-
export declare function escapeHtml(value: string): string | undefined;
|
|
10
|
-
export declare function revertHtml(value: string): string;
|
|
11
|
-
export declare function generateUIModelID<M extends Model>(model: M): string;
|