@rosoftlab/formly 1.0.1-alpha-4 → 1.0.1-alpha-6
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseModel, BaseService } from '@rosoftlab/core';
|
|
1
|
+
import { BaseModel, MetadataStorage, BaseService } from '@rosoftlab/core';
|
|
2
2
|
|
|
3
3
|
// import { BaseModel, BaseService } from "@rosoftlab/core";
|
|
4
4
|
class BaseModelFormly extends BaseModel {
|
|
@@ -6,14 +6,14 @@ class BaseModelFormly extends BaseModel {
|
|
|
6
6
|
return this.getFormlyFieldsForObject(baseService, this);
|
|
7
7
|
}
|
|
8
8
|
getFormlyFieldsForObject(baseService, instance) {
|
|
9
|
-
const formlyLayout =
|
|
9
|
+
const formlyLayout = MetadataStorage.getMetadata('FormlyLayout', instance);
|
|
10
10
|
const formlyFields = [];
|
|
11
11
|
const that = instance;
|
|
12
12
|
if (formlyLayout) {
|
|
13
13
|
formlyLayout.forEach(property => {
|
|
14
14
|
if (property.key !== 'id') {
|
|
15
15
|
const value = that[property.key] !== undefined ? that[property.key] : property.defaultValue;
|
|
16
|
-
const propType =
|
|
16
|
+
const propType = MetadataStorage.getMetadata('design:type', instance, property.key);
|
|
17
17
|
const required = property.required !== undefined ? property.required : false;
|
|
18
18
|
if (typeof propType === 'function' &&
|
|
19
19
|
propType.prototype &&
|
|
@@ -100,10 +100,10 @@ class BaseServiceFormly extends BaseService {
|
|
|
100
100
|
|
|
101
101
|
function FormlyLayout(config) {
|
|
102
102
|
return (target, propertyName) => {
|
|
103
|
-
const annotations =
|
|
103
|
+
const annotations = MetadataStorage.getMetadata('FormlyLayout', target) || [];
|
|
104
104
|
config.key = propertyName;
|
|
105
105
|
annotations.push(config);
|
|
106
|
-
|
|
106
|
+
MetadataStorage.setMetadata('FormlyLayout', annotations, target);
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rosoftlab-formly.mjs","sources":["../../../../projects/rosoftlab/formly/src/lib/base-model-formly.ts","../../../../projects/rosoftlab/formly/src/lib/formly-base-service.ts","../../../../projects/rosoftlab/formly/src/lib/formly-layout.ts","../../../../projects/rosoftlab/formly/src/public-api.ts","../../../../projects/rosoftlab/formly/src/rosoftlab-formly.ts"],"sourcesContent":["import { FormlyFieldConfig } from \"@ngx-formly/core\";\r\n// import { BaseModel, BaseService } from \"@rosoftlab/core\";\r\nimport { BaseModel, BaseService } from \"@rosoftlab/core\";\r\nimport { FormlyModelConfig } from \"./interfaces/formly-model-config\";\r\n\r\n\r\nexport class BaseModelFormly extends BaseModel {\r\n public showErrorState: false\r\n getFormlyFields(baseService: BaseService<BaseModelFormly>) { \r\n return this.getFormlyFieldsForObject(baseService, this);\r\n }\r\n private getFormlyFieldsForObject(baseService: BaseService<BaseModelFormly>, instance: any) {\r\n const formlyLayout: FormlyModelConfig[] =
|
|
1
|
+
{"version":3,"file":"rosoftlab-formly.mjs","sources":["../../../../projects/rosoftlab/formly/src/lib/base-model-formly.ts","../../../../projects/rosoftlab/formly/src/lib/formly-base-service.ts","../../../../projects/rosoftlab/formly/src/lib/formly-layout.ts","../../../../projects/rosoftlab/formly/src/public-api.ts","../../../../projects/rosoftlab/formly/src/rosoftlab-formly.ts"],"sourcesContent":["import { FormlyFieldConfig } from \"@ngx-formly/core\";\r\n// import { BaseModel, BaseService } from \"@rosoftlab/core\";\r\nimport { BaseModel, BaseService, MetadataStorage } from \"@rosoftlab/core\";\r\nimport { FormlyModelConfig } from \"./interfaces/formly-model-config\";\r\n\r\n\r\nexport class BaseModelFormly extends BaseModel {\r\n public showErrorState: false\r\n getFormlyFields(baseService: BaseService<BaseModelFormly>) { \r\n return this.getFormlyFieldsForObject(baseService, this);\r\n }\r\n private getFormlyFieldsForObject(baseService: BaseService<BaseModelFormly>, instance: any) {\r\n const formlyLayout: FormlyModelConfig[] = MetadataStorage.getMetadata('FormlyLayout', instance);\r\n const formlyFields: FormlyFieldConfig[] = [];\r\n const that = instance;\r\n if (formlyLayout) {\r\n formlyLayout.forEach(property => {\r\n if (property.key !== 'id') {\r\n const value = that[property.key] !== undefined ? that[property.key] : property.defaultValue;\r\n const propType = MetadataStorage.getMetadata('design:type', instance, property.key)\r\n const required = property.required !== undefined ? property.required : false\r\n if (typeof propType === 'function' &&\r\n propType.prototype &&\r\n propType.prototype.constructor === propType &&\r\n propType.prototype.constructor.toString().startsWith('class ')) {\r\n const fields = this.getFormlyFieldsForObject(baseService, new propType())\r\n if (fields)\r\n formlyFields.push(\r\n {\r\n key: property.key,\r\n props: {\r\n translate: true,\r\n label: property.label\r\n },\r\n wrappers: ['panel'],\r\n fieldGroup: fields\r\n }\r\n )\r\n } else {\r\n switch (property.type) {\r\n case \"select\": {\r\n formlyFields.push(\r\n {\r\n key: property.key,\r\n type: property.type,\r\n defaultValue: value,\r\n props: {\r\n translate: true,\r\n label: property.label,\r\n required,\r\n labelPosition: 'floating',\r\n description: property.description,\r\n placeholder: property.placeholder,\r\n options: baseService.getSelectValues(property.key),\r\n valueProp: property.valueProp || 'value',\r\n labelProp: property.labelProp || 'label',\r\n },\r\n })\r\n break;\r\n }\r\n case \"toggle\": {\r\n formlyFields.push(\r\n {\r\n key: property.key,\r\n type: property.type,\r\n defaultValue: value,\r\n props: {\r\n translate: true,\r\n label: property.label,\r\n required,\r\n description: property.description,\r\n placeholder: property.placeholder,\r\n },\r\n })\r\n break;\r\n }\r\n default: {\r\n formlyFields.push(\r\n {\r\n key: property.key,\r\n type: property.type,\r\n defaultValue: value,\r\n props: {\r\n translate: true,\r\n label: property.label,\r\n required,\r\n labelPosition: 'floating',\r\n description: property.description,\r\n placeholder: property.placeholder\r\n },\r\n })\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n });\r\n }\r\n return formlyFields;\r\n }\r\n\r\n}","import { BaseService } from \"@rosoftlab/core\";\r\nimport { BaseModelFormly } from \"./base-model-formly\";\r\n\r\nexport class BaseServiceFormly<T extends BaseModelFormly> extends BaseService<T> {\r\n\r\n public getFormlyFields(model: T) {\r\n return model.getFormlyFields(this);\r\n }\r\n}\r\n","import { MetadataStorage } from \"@rosoftlab/core\";\r\nimport { FormlyModelConfig } from \"./interfaces/formly-model-config\";\r\nexport function FormlyLayout(config: FormlyModelConfig) {\r\n return (target: any, propertyName: string) => {\r\n const annotations = MetadataStorage.getMetadata('FormlyLayout', target) || [];\r\n config.key = propertyName;\r\n annotations.push(config);\r\n\r\n MetadataStorage.setMetadata('FormlyLayout', annotations, target);\r\n };\r\n}\r\n","/*\r\n * Public API Surface of formly\r\n */\r\n\r\nexport * from './lib/base-model-formly';\r\nexport * from './lib/formly-base-service';\r\nexport * from './lib/formly-layout';\r\nexport * from './lib/interfaces/formly-model-config';\r\n\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AACA;AAKM,MAAO,eAAgB,SAAQ,SAAS,CAAA;AAE5C,IAAA,eAAe,CAAC,WAAyC,EAAA;QACvD,OAAO,IAAI,CAAC,wBAAwB,CAAC,WAAW,EAAE,IAAI,CAAC;;IAEjD,wBAAwB,CAAC,WAAyC,EAAE,QAAa,EAAA;QACvF,MAAM,YAAY,GAAwB,eAAe,CAAC,WAAW,CAAC,cAAc,EAAE,QAAQ,CAAC;QAC/F,MAAM,YAAY,GAAwB,EAAE;QAC5C,MAAM,IAAI,GAAG,QAAQ;QACrB,IAAI,YAAY,EAAE;AAChB,YAAA,YAAY,CAAC,OAAO,CAAC,QAAQ,IAAG;AAC9B,gBAAA,IAAI,QAAQ,CAAC,GAAG,KAAK,IAAI,EAAE;oBACzB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,YAAY;AAC3F,oBAAA,MAAM,QAAQ,GAAG,eAAe,CAAC,W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AoB,KAAI;AACzC,QAAA,MAAM,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,IAAI,EAAE;AAC7E,QAAA,MAAM,CAAC,GAAG,GAAG,YAAY;AACzB,QAAA,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;QAExB,eAAe,CAAC,WAAW,CAAC,cAAc,EAAE,WAAW,EAAE,MAAM,CAAC;AACpE,KAAC;AACL;;ACVA;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rosoftlab/formly",
|
|
3
|
-
"version": "1.0.1-alpha-
|
|
3
|
+
"version": "1.0.1-alpha-6",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": "^18.2.9",
|
|
6
6
|
"@angular/core": "^18.2.9",
|
|
7
7
|
"@ngx-formly/core": "^6.3.0",
|
|
8
|
-
"@rosoftlab/core": "1.0.1-alpha-
|
|
8
|
+
"@rosoftlab/core": "1.0.1-alpha-6"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"tslib": "^2.6.2"
|