@airpower/web 0.2.27 → 0.2.29

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,5 +1,5 @@
1
1
  import { EnumKey } from '@airpower/enum/dist/enum/type';
2
- import { DecoratorTarget, ITransformerConstructor } from '@airpower/transformer';
2
+ import { ITransformerConstructor, TransformerField } from '@airpower/transformer';
3
3
  import { WebEnumConstructor } from '../../enum/type';
4
4
  import { RootModel } from '../../model/RootModel';
5
5
  import { IFieldConfig } from './IFieldConfig';
@@ -8,23 +8,23 @@ import { FieldConfigOptionalKey } from './type';
8
8
  * ### 为属性标记配置
9
9
  * @param config 配置项
10
10
  */
11
- export declare function Field<K extends EnumKey = EnumKey>(config?: FieldConfigOptionalKey<IFieldConfig<K>>): (target: DecoratorTarget, key: string) => void;
11
+ export declare function Field<M extends RootModel, K extends EnumKey = EnumKey>(config?: FieldConfigOptionalKey<IFieldConfig<K>>): (instance: M, field: keyof M) => void;
12
12
  /**
13
13
  * ### 获取属性的配置
14
14
  * @returns 配置对象
15
- * @param TargetClass 目标类
16
- * @param key 属性名
15
+ * @param Class 目标类
16
+ * @param field 属性名
17
17
  */
18
- export declare function getFieldConfig<M extends RootModel, K extends EnumKey = EnumKey>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): IFieldConfig<K>;
18
+ export declare function getFieldConfig<M extends RootModel, K extends EnumKey = EnumKey>(Class: ITransformerConstructor<M>, field: TransformerField<M>): IFieldConfig<K>;
19
19
  /**
20
20
  * ### 获取属性的枚举字典
21
- * @param TargetClass 目标类
22
- * @param key 属性名
21
+ * @param Class 目标类
22
+ * @param field 属性名
23
23
  */
24
- export declare function getDictionary<M extends RootModel, K extends EnumKey = EnumKey>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): WebEnumConstructor<K> | undefined;
24
+ export declare function getDictionary<M extends RootModel, K extends EnumKey = EnumKey>(Class: ITransformerConstructor<M>, field: TransformerField<M>): WebEnumConstructor<K> | undefined;
25
25
  /**
26
26
  * ### 获取属性的标题
27
- * @param TargetClass 目标类
28
- * @param key string 属性名
27
+ * @param Class 目标类
28
+ * @param field string 属性名
29
29
  */
30
- export declare function getFieldLabel<M extends RootModel>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): string;
30
+ export declare function getFieldLabel<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): string;
@@ -1,4 +1,4 @@
1
- import { DecoratorTarget, ITransformerConstructor } from '@airpower/transformer';
1
+ import { ITransformerConstructor, TransformerField } from '@airpower/transformer';
2
2
  import { RootModel } from '../../model/RootModel';
3
3
  import { FieldConfigOptionalKey } from '../@Field/type';
4
4
  import { IFormField } from './IFormField';
@@ -6,21 +6,21 @@ import { IFormField } from './IFormField';
6
6
  * ### 标记该字段可用于表单配置
7
7
  * @param config 配置项
8
8
  */
9
- export declare function Form(config?: FieldConfigOptionalKey<IFormField>): (target: DecoratorTarget, key: string) => void;
9
+ export declare function Form<M extends RootModel>(config?: FieldConfigOptionalKey<IFormField>): (instance: M, key: keyof M) => void;
10
10
  /**
11
11
  * ### 获取对象某个字段标记的表单配置项
12
- * @param TargetClass 目标类
13
- * @param key 属性名
12
+ * @param Class 目标类
13
+ * @param field 属性名
14
14
  */
15
- export declare function getFormConfig<M extends RootModel>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): IFormField;
15
+ export declare function getFormConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): IFormField;
16
16
  /**
17
17
  * ### 获取标记了表单配置的字段列表
18
- * @param TargetClass 目标类
18
+ * @param Class 目标类
19
19
  */
20
- export declare function getFormFieldList<M extends RootModel>(TargetClass: ITransformerConstructor<M>): Array<keyof M | string>;
20
+ export declare function getFormFieldList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<TransformerField<M>>;
21
21
  /**
22
22
  * ### 获取指定类的表单字段配置项列表
23
- * @param TargetClass 目标类
24
- * @param keyList 选择字段列表
23
+ * @param Class 目标类
24
+ * @param fieldList 选择字段列表
25
25
  */
26
- export declare function getFormConfigList<M extends RootModel>(TargetClass: ITransformerConstructor<M>, keyList?: Array<keyof M | string>): IFormField[];
26
+ export declare function getFormConfigList<M extends RootModel>(Class: ITransformerConstructor<M>, fieldList?: Array<TransformerField<M>>): IFormField[];
@@ -35,7 +35,6 @@ export interface IFormField extends IBaseField {
35
35
  suffixIcon?: string;
36
36
  /**
37
37
  * ### 最大数字
38
- * 默认配置 `WebConfig.maxNumber` 仅在 `number` 时有效
39
38
  */
40
39
  max?: number;
41
40
  /**
@@ -1,17 +1,18 @@
1
- import { DecoratorTarget, ITransformerConstructor, Transformer } from '@airpower/transformer';
1
+ import { ITransformerConstructor } from '@airpower/transformer';
2
+ import { RootModel } from '../../model/RootModel';
2
3
  import { IModelConfig } from './IModelConfig';
3
4
  /**
4
5
  * ### 为模型类标记配置项
5
6
  * @param config 配置项
6
7
  */
7
- export declare function Model<T extends IModelConfig = IModelConfig>(config?: T): (target: DecoratorTarget) => void;
8
+ export declare function Model<M extends RootModel, T extends IModelConfig = IModelConfig>(config?: T): (Class: ITransformerConstructor<M>) => void;
8
9
  /**
9
10
  * ### 获取模型类配置项
10
- * @param TargetClass 目标类
11
+ * @param Class 目标类
11
12
  */
12
- export declare function getModelConfig<E extends Transformer, T extends IModelConfig = IModelConfig>(TargetClass: ITransformerConstructor<E>): T;
13
+ export declare function getModelConfig<M extends RootModel, T extends IModelConfig = IModelConfig>(Class: ITransformerConstructor<M>): T;
13
14
  /**
14
15
  * ### 获取模型类名称
15
- * @param TargetClass 目标类
16
+ * @param Class 目标类
16
17
  */
17
- export declare function getModelName<E extends Transformer>(TargetClass: ITransformerConstructor<E>): string;
18
+ export declare function getModelName<M extends RootModel>(Class: ITransformerConstructor<M>): string;
@@ -1,4 +1,4 @@
1
- import { DecoratorTarget, ITransformerConstructor } from '@airpower/transformer';
1
+ import { ITransformerConstructor, TransformerField } from '@airpower/transformer';
2
2
  import { RootModel } from '../../model/RootModel';
3
3
  import { FieldConfigOptionalKey } from '../@Field/type';
4
4
  import { ISearchField } from './ISearchField';
@@ -6,21 +6,21 @@ import { ISearchField } from './ISearchField';
6
6
  * ### 标记该字段可用于表单配置
7
7
  * @param config 配置项
8
8
  */
9
- export declare function Search(config?: FieldConfigOptionalKey<ISearchField>): (target: DecoratorTarget, key: string) => void;
9
+ export declare function Search<M extends RootModel>(config?: FieldConfigOptionalKey<ISearchField>): (instance: M, field: keyof M) => void;
10
10
  /**
11
11
  * ### 获取对象某个字段标记的搜索配置项
12
- * @param TargetClass 目标类
13
- * @param key 属性名
12
+ * @param Class 目标类
13
+ * @param field 属性名
14
14
  */
15
- export declare function getSearchConfig<M extends RootModel>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): ISearchField;
15
+ export declare function getSearchConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): ISearchField;
16
16
  /**
17
17
  * ### 获取标记了搜索配置的字段列表
18
- * @param TargetClass 目标类
18
+ * @param Class 目标类
19
19
  */
20
- export declare function getSearchFieldList<M extends RootModel>(TargetClass: ITransformerConstructor<M>): Array<keyof M | string>;
20
+ export declare function getSearchFieldList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<TransformerField<M>>;
21
21
  /**
22
22
  * ### 获取指定类的搜索字段配置项列表
23
- * @param TargetClass 目标类
24
- * @param keyList 选择字段列表
23
+ * @param Class 目标类
24
+ * @param fieldList 选择字段列表
25
25
  */
26
- export declare function getSearchConfigList<M extends RootModel>(TargetClass: ITransformerConstructor<M>, keyList?: Array<keyof M | string>): ISearchField[];
26
+ export declare function getSearchConfigList<M extends RootModel>(Class: ITransformerConstructor<M>, fieldList?: Array<TransformerField<M>>): ISearchField[];
@@ -1,4 +1,4 @@
1
- import { DecoratorTarget, ITransformerConstructor } from '@airpower/transformer';
1
+ import { ITransformerConstructor, TransformerField } from '@airpower/transformer';
2
2
  import { RootModel } from '../../model/RootModel';
3
3
  import { FieldConfigOptionalKey } from '../@Field/type';
4
4
  import { ITableColumn } from './ITableColumn';
@@ -6,21 +6,21 @@ import { ITableColumn } from './ITableColumn';
6
6
  * ### 为属性标记是表格字段
7
7
  * @param config 表格列的配置
8
8
  */
9
- export declare function Table(config?: FieldConfigOptionalKey<ITableColumn>): (target: DecoratorTarget, key: string) => void;
9
+ export declare function Table<M extends RootModel>(config?: FieldConfigOptionalKey<ITableColumn>): (instance: M, field: keyof M) => void;
10
10
  /**
11
11
  * ### 获取对象的属性表格的配置
12
- * @param TargetClass 目标类
13
- * @param key 属性名
12
+ * @param Class 目标类
13
+ * @param field 属性名
14
14
  */
15
- export declare function getTableConfig<M extends RootModel>(TargetClass: ITransformerConstructor<M>, key: keyof M | string): ITableColumn;
15
+ export declare function getTableConfig<M extends RootModel>(Class: ITransformerConstructor<M>, field: TransformerField<M>): ITableColumn;
16
16
  /**
17
17
  * ### 获取标记了表格配置的字段列表
18
- * @param TargetClass 目标类
18
+ * @param Class 目标类
19
19
  */
20
- export declare function getTableFieldList<M extends RootModel>(TargetClass: ITransformerConstructor<M>): Array<keyof M | string>;
20
+ export declare function getTableFieldList<M extends RootModel>(Class: ITransformerConstructor<M>): Array<TransformerField<M>>;
21
21
  /**
22
22
  * ### 获取字段标记的表格字段配置列表
23
- * @param TargetClass 目标类
24
- * @param keyList 字段列表
23
+ * @param Class 目标类
24
+ * @param fieldList 字段列表
25
25
  */
26
- export declare function getTableConfigList<M extends RootModel>(TargetClass: ITransformerConstructor<M>, keyList?: Array<keyof M | string>): Array<ITableColumn>;
26
+ export declare function getTableConfigList<M extends RootModel>(Class: ITransformerConstructor<M>, fieldList?: Array<TransformerField<M>>): Array<ITableColumn>;
@@ -1,3 +1,12 @@
1
+ /**
2
+ * ### 表格列浮动
3
+ */
1
4
  export type TableFixed = 'left' | 'right';
5
+ /**
6
+ * ### 表格列排序
7
+ */
2
8
  export type TableSortable = 'custom' | boolean;
9
+ /**
10
+ * ### 表格列对齐方式
11
+ */
3
12
  export type TableAlign = 'left' | 'center' | 'right';
package/dist/main.js CHANGED
@@ -685,117 +685,110 @@ __publicField(WebConfig, "treeProps", {
685
685
  children: "children",
686
686
  label: "name"
687
687
  });
688
- var __defProp$7 = Object.defineProperty;
689
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
690
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, key + "", value);
691
688
  class DecoratorUtil {
692
689
  /**
693
690
  * ### 设置一个类配置项
694
- * @param target 目标实体类
691
+ * @param Class 目标类
695
692
  * @param classConfigKey 配置项索引键值
696
693
  * @param classConfig 配置的参数
697
694
  */
698
- static setClassConfig(target, classConfigKey, classConfig) {
699
- this.setProperty(target.prototype, classConfigKey, classConfig);
695
+ static setClassConfig(Class, classConfigKey, classConfig) {
696
+ this.setProperty(Class.prototype, classConfigKey, classConfig);
700
697
  }
701
698
  /**
702
699
  * ### 递归获取指定类的配置项
703
- * @param target 目标类
700
+ * @param Class 目标类
704
701
  * @param classConfigKey 配置项的Key
705
702
  * @param defaultValue `可选` 类装饰器请传入配置项实例
706
703
  * @param isObject `可选` 是否是对象配置
707
704
  */
708
- static getClassConfig(target, classConfigKey, defaultValue = void 0, isObject = false) {
709
- let classConfig = Reflect.get(target, classConfigKey);
705
+ static getClassConfig(Class, classConfigKey, defaultValue = void 0, isObject = false) {
706
+ let classConfig = Reflect.get(Class, classConfigKey);
710
707
  if (!isObject) {
711
708
  if (classConfig) {
712
709
  return classConfig;
713
710
  }
714
- const superClass2 = Reflect.getPrototypeOf(target);
715
- if (!superClass2 || superClass2.constructor.name === Transformer.name) {
711
+ const SuperClass2 = Reflect.getPrototypeOf(Class);
712
+ if (!SuperClass2 || SuperClass2.prototype.constructor.name === Transformer.name) {
716
713
  return void 0;
717
714
  }
718
- return this.getClassConfig(superClass2, classConfigKey);
715
+ return this.getClassConfig(SuperClass2, classConfigKey);
719
716
  }
720
717
  classConfig = classConfig || {};
721
- const superClass = Reflect.getPrototypeOf(target);
722
- if (!superClass || superClass.constructor.name === Transformer.name) {
718
+ const SuperClass = Reflect.getPrototypeOf(Class);
719
+ if (!SuperClass || SuperClass.constructor.name === Transformer.name) {
723
720
  return defaultValue;
724
721
  }
725
722
  return {
726
- ...this.getClassConfig(superClass, classConfigKey, defaultValue, isObject),
723
+ ...this.getClassConfig(SuperClass, classConfigKey, defaultValue, isObject),
727
724
  ...classConfig
728
725
  };
729
726
  }
730
727
  /**
731
728
  * ### 设置一个属性配置项
732
- * @param target 目标类
733
- * @param key 属性
729
+ * @param instance 目标实例
730
+ * @param field 属性
734
731
  * @param fieldConfigKey 配置项索引键值
735
732
  * @param fieldConfig 配置的参数
736
733
  * @param fieldListKey `可选` 类配置项列表索引值
737
734
  */
738
- static setFieldConfig(target, key, fieldConfigKey, fieldConfig, fieldListKey) {
735
+ static setFieldConfig(instance, field, fieldConfigKey, fieldConfig, fieldListKey) {
739
736
  if (fieldListKey) {
740
- this.addFieldDecoratorKey(target, key, fieldListKey);
737
+ this.addFieldDecoratorKey(instance, field, fieldListKey);
741
738
  }
742
- this.setProperty(target, `${fieldConfigKey}[${key}]`, fieldConfig);
739
+ this.setProperty(instance, `${fieldConfigKey}[${field.toString()}]`, fieldConfig);
743
740
  }
744
741
  /**
745
742
  * ### 获取类指定属性的指定类型的配置
746
- * @param target 目标类
747
- * @param key 属性
743
+ * @param Class 目标类
744
+ * @param field 属性
748
745
  * @param fieldConfigKey FieldConfigKey
749
746
  * @param isObject `可选` 是否对象配置
750
747
  */
751
- static getFieldConfig(target, key, fieldConfigKey, isObject = false) {
752
- if (typeof target !== "object") {
753
- target = target.prototype;
754
- }
755
- let fieldConfig = Reflect.get(target, `${fieldConfigKey}[${key}]`);
748
+ static getFieldConfig(Class, field, fieldConfigKey, isObject = false) {
749
+ let fieldConfig = Reflect.get(Class.prototype, `${fieldConfigKey}[${field.toString()}]`);
750
+ const SuperClass = Reflect.getPrototypeOf(Class);
756
751
  if (!isObject) {
757
752
  if (fieldConfig !== void 0) {
758
753
  return fieldConfig;
759
754
  }
760
- const superClass2 = Reflect.getPrototypeOf(target);
761
- if (!superClass2 || superClass2.constructor.name === Transformer.name) {
755
+ if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
762
756
  return void 0;
763
757
  }
764
- return this.getFieldConfig(superClass2, key, fieldConfigKey);
758
+ return this.getFieldConfig(SuperClass, field, fieldConfigKey);
765
759
  }
766
760
  fieldConfig = fieldConfig || {};
767
- const superClass = Reflect.getPrototypeOf(target);
768
- if (!superClass || superClass.constructor.name === Transformer.name) {
761
+ if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
769
762
  return {};
770
763
  }
771
764
  return {
772
- ...this.getFieldConfig(superClass, key, fieldConfigKey, true),
765
+ ...this.getFieldConfig(SuperClass, field, fieldConfigKey, true),
773
766
  ...fieldConfig
774
767
  };
775
768
  }
776
769
  /**
777
770
  * ### 获取类标记了装饰器的属性列表
778
- * @param target 目标类
771
+ * @param Class 目标类
779
772
  * @param fieldConfigKey FieldConfigKey
780
773
  * @param list `递归参数` 无需传入
781
774
  */
782
- static getFieldList(target, fieldConfigKey, list = []) {
783
- const fieldList = Reflect.get(target, fieldConfigKey) || [];
775
+ static getFieldList(Class, fieldConfigKey, list = []) {
776
+ const fieldList = Reflect.get(Class.prototype, fieldConfigKey) || [];
784
777
  fieldList.forEach((item) => list.includes(item) || list.push(item));
785
- const superClass = Reflect.getPrototypeOf(target);
786
- if (!superClass || superClass.constructor.name === Transformer.name) {
778
+ const SuperClass = Reflect.getPrototypeOf(Class);
779
+ if (!SuperClass || SuperClass.prototype.constructor.name === Transformer.name) {
787
780
  return list;
788
781
  }
789
- return this.getFieldList(superClass, fieldConfigKey, list);
782
+ return this.getFieldList(SuperClass, fieldConfigKey, list);
790
783
  }
791
784
  /**
792
785
  * ### 反射添加属性
793
- * @param target 目标类
794
- * @param key 配置key
786
+ * @param instance 目标属性
787
+ * @param propertyKey 配置key
795
788
  * @param value 配置值
796
789
  */
797
- static setProperty(target, key, value) {
798
- Reflect.defineProperty(target, key, {
790
+ static setProperty(instance, propertyKey, value) {
791
+ Reflect.defineProperty(instance, propertyKey, {
799
792
  enumerable: false,
800
793
  value,
801
794
  writable: false,
@@ -804,17 +797,16 @@ class DecoratorUtil {
804
797
  }
805
798
  /**
806
799
  * ### 设置一个属性的包含装饰器索引
807
- * @param target 目标类
808
- * @param key 属性
809
- * @param fieldListKey 类配置项列表索引值
800
+ * @param instance 目标类
801
+ * @param field 属性
802
+ * @param propertyKey 类配置项列表索引值
810
803
  */
811
- static addFieldDecoratorKey(target, key, fieldListKey) {
812
- const list = Reflect.get(target, fieldListKey) || [];
813
- list.push(key);
814
- this.setProperty(target, fieldListKey, list);
804
+ static addFieldDecoratorKey(instance, field, propertyKey) {
805
+ const list = Reflect.get(instance, propertyKey) || [];
806
+ list.push(field);
807
+ this.setProperty(instance, propertyKey, list);
815
808
  }
816
809
  }
817
- __publicField$3(DecoratorUtil, "DecoratorKeyPrefix", "[AirPower]");
818
810
  class Transformer {
819
811
  /**
820
812
  * ### 从 `JSON` 转换到当前类的对象
@@ -862,10 +854,10 @@ class Transformer {
862
854
  const instance = new Class();
863
855
  const fieldList = Object.keys(instance);
864
856
  for (const field of fieldList) {
865
- const jsonKey = this.getJsonKey(instance, field);
857
+ const jsonKey = this.getJsonKey(Class, field);
866
858
  const fieldData = json[jsonKey];
867
859
  instance[field] = fieldData;
868
- const toClass = getToClass(instance, field);
860
+ const toClass = getToClass(Class, field);
869
861
  if (toClass !== void 0) {
870
862
  try {
871
863
  ;
@@ -875,8 +867,8 @@ class Transformer {
875
867
  continue;
876
868
  }
877
869
  }
878
- const FieldTypeClass = getType(instance, field);
879
- const isArray2 = getArray(instance, field);
870
+ const FieldTypeClass = getType(Class, field);
871
+ const isArray2 = getArray(Class, field);
880
872
  if (isArray2) {
881
873
  const fieldValueList = [];
882
874
  if (typeof fieldData === "object" && Array.isArray(fieldData)) {
@@ -910,7 +902,7 @@ class Transformer {
910
902
  }
911
903
  }
912
904
  for (const fieldKey of fieldList) {
913
- const alias = getAlias(instance, fieldKey) || fieldKey;
905
+ const alias = getAlias(Class, fieldKey) || fieldKey;
914
906
  if (alias === fieldKey) {
915
907
  continue;
916
908
  }
@@ -920,19 +912,19 @@ class Transformer {
920
912
  }
921
913
  /**
922
914
  * ### 获取 JSON 的 key
923
- * @param instance 目标实例
915
+ * @param Class 目标实例
924
916
  * @param field 属性 key
925
917
  */
926
- static getJsonKey(instance, field) {
927
- const alias = getAlias(instance, field);
918
+ static getJsonKey(Class, field) {
919
+ const alias = getAlias(Class, field);
928
920
  if (alias) {
929
921
  return alias;
930
922
  }
931
- const prefix = getPrefix(instance);
923
+ const prefix = getPrefix(Class);
932
924
  if (!prefix) {
933
925
  return field;
934
926
  }
935
- const ignorePrefix = getIgnorePrefix(instance, field);
927
+ const ignorePrefix = getIgnorePrefix(Class, field);
936
928
  if (!ignorePrefix) {
937
929
  return prefix + field;
938
930
  }
@@ -984,6 +976,7 @@ class Transformer {
984
976
  * 会自动进行数据别名转换
985
977
  */
986
978
  toJson() {
979
+ const Class = this.constructor;
987
980
  const fieldList = Object.keys(this);
988
981
  const json = {};
989
982
  for (const field of fieldList) {
@@ -991,9 +984,9 @@ class Transformer {
991
984
  if (data === null || data === void 0) {
992
985
  continue;
993
986
  }
994
- const jsonKey = Transformer.getJsonKey(this, field);
987
+ const jsonKey = Transformer.getJsonKey(Class, field);
995
988
  json[jsonKey] = data;
996
- const toJson = getToJson(this, field);
989
+ const toJson = getToJson(Class, field);
997
990
  if (toJson !== void 0) {
998
991
  try {
999
992
  json[jsonKey] = toJson(this);
@@ -1021,66 +1014,68 @@ class Transformer {
1021
1014
  return json;
1022
1015
  }
1023
1016
  }
1024
- const KEY$5 = `${DecoratorUtil.DecoratorKeyPrefix}[Alias]`;
1017
+ const KEY$5 = "[Alias]";
1025
1018
  function Alias(alias) {
1026
- return (target, key) => DecoratorUtil.setFieldConfig(target, key, KEY$5, alias);
1019
+ return (instance, field) => {
1020
+ DecoratorUtil.setFieldConfig(instance, field, KEY$5, alias);
1021
+ };
1027
1022
  }
1028
- function getAlias(target, key) {
1029
- return (DecoratorUtil.getFieldConfig(target, key.toString(), KEY$5) || "").toString();
1023
+ function getAlias(Class, field) {
1024
+ return (DecoratorUtil.getFieldConfig(Class, field, KEY$5) || "").toString();
1030
1025
  }
1031
- const KEY$4$1 = `${DecoratorUtil.DecoratorKeyPrefix}[IgnorePrefix]`;
1026
+ const KEY$4$1 = "[IgnorePrefix]";
1032
1027
  function IgnorePrefix() {
1033
- return (target, key) => DecoratorUtil.setFieldConfig(target, key, KEY$4$1, true);
1028
+ return (instance, field) => DecoratorUtil.setFieldConfig(instance, field, KEY$4$1, true);
1034
1029
  }
1035
- function getIgnorePrefix(target, key) {
1036
- return !!DecoratorUtil.getFieldConfig(target, key.toString(), KEY$4$1);
1030
+ function getIgnorePrefix(Class, field) {
1031
+ return !!DecoratorUtil.getFieldConfig(Class, field, KEY$4$1);
1037
1032
  }
1038
- const KEY$3$1 = `${DecoratorUtil.DecoratorKeyPrefix}[Prefix]`;
1033
+ const KEY$3$1 = "[Prefix]";
1039
1034
  function Prefix(prefix) {
1040
- return (target) => DecoratorUtil.setClassConfig(target, KEY$3$1, prefix);
1035
+ return (Class) => DecoratorUtil.setClassConfig(Class, KEY$3$1, prefix);
1041
1036
  }
1042
- function getPrefix(target) {
1043
- return DecoratorUtil.getClassConfig(target, KEY$3$1, "");
1037
+ function getPrefix(Class) {
1038
+ return DecoratorUtil.getClassConfig(Class, KEY$3$1, "");
1044
1039
  }
1045
- const KEY$2$1 = `${DecoratorUtil.DecoratorKeyPrefix}[ToClass]`;
1040
+ const KEY$2$1 = "[ToClass]";
1046
1041
  function ToClass(func) {
1047
- return (target, key) => DecoratorUtil.setFieldConfig(target, key, KEY$2$1, func);
1042
+ return (instance, field) => DecoratorUtil.setFieldConfig(instance, field, KEY$2$1, func);
1048
1043
  }
1049
- function getToClass(target, key) {
1050
- return DecoratorUtil.getFieldConfig(target, key.toString(), KEY$2$1);
1044
+ function getToClass(target, field) {
1045
+ return DecoratorUtil.getFieldConfig(target, field, KEY$2$1);
1051
1046
  }
1052
- const KEY$1$1 = `${DecoratorUtil.DecoratorKeyPrefix}[ToJson]`;
1047
+ const KEY$1$1 = "[ToJson]";
1053
1048
  function ToJson(func) {
1054
- return (target, key) => DecoratorUtil.setFieldConfig(target, key, KEY$1$1, func);
1049
+ return (instance, key) => DecoratorUtil.setFieldConfig(instance, key, KEY$1$1, func);
1055
1050
  }
1056
- function getToJson(target, key) {
1057
- return DecoratorUtil.getFieldConfig(target, key.toString(), KEY$1$1);
1051
+ function getToJson(Class, field) {
1052
+ return DecoratorUtil.getFieldConfig(Class, field, KEY$1$1);
1058
1053
  }
1059
- const KEY$6 = `${DecoratorUtil.DecoratorKeyPrefix}[Type]`;
1060
- const KEY_ARRAY = `${DecoratorUtil.DecoratorKeyPrefix}[Array]`;
1054
+ const KEY$6 = "[Type]";
1055
+ const KEY_ARRAY = "[Array]";
1061
1056
  function Type(type, array = false) {
1062
- return (target, key) => {
1063
- DecoratorUtil.setFieldConfig(target, key, KEY$6, type);
1057
+ return (instance, field) => {
1058
+ DecoratorUtil.setFieldConfig(instance, field, KEY$6, type);
1064
1059
  if (array) {
1065
- DecoratorUtil.setFieldConfig(target, key, KEY_ARRAY, array);
1060
+ DecoratorUtil.setFieldConfig(instance, field, KEY_ARRAY, array);
1066
1061
  }
1067
1062
  };
1068
1063
  }
1069
- function getType(target, key) {
1070
- return DecoratorUtil.getFieldConfig(target, key.toString(), KEY$6) || void 0;
1064
+ function getType(Class, field) {
1065
+ return DecoratorUtil.getFieldConfig(Class, field, KEY$6) || void 0;
1071
1066
  }
1072
- function getArray(target, key) {
1073
- return !!DecoratorUtil.getFieldConfig(target, key.toString(), KEY_ARRAY);
1067
+ function getArray(Class, field) {
1068
+ return !!DecoratorUtil.getFieldConfig(Class, field, KEY_ARRAY);
1074
1069
  }
1075
- const KEY$4 = `${DecoratorUtil.DecoratorKeyPrefix}[MODEL]`;
1070
+ const KEY$4 = "[MODEL]";
1076
1071
  function Model(config = {}) {
1077
- return (target) => DecoratorUtil.setClassConfig(target, KEY$4, config);
1072
+ return (Class) => DecoratorUtil.setClassConfig(Class, KEY$4, config);
1078
1073
  }
1079
- function getModelConfig(TargetClass) {
1080
- return DecoratorUtil.getClassConfig(TargetClass, KEY$4, {}, true);
1074
+ function getModelConfig(Class) {
1075
+ return DecoratorUtil.getClassConfig(Class, KEY$4, {}, true);
1081
1076
  }
1082
- function getModelName(TargetClass) {
1083
- return getModelConfig(TargetClass).label || TargetClass.name;
1077
+ function getModelName(Class) {
1078
+ return getModelConfig(Class).label || Class.name;
1084
1079
  }
1085
1080
  var PermissionAction = /* @__PURE__ */ ((PermissionAction2) => {
1086
1081
  PermissionAction2["ADD"] = "add";
@@ -10194,23 +10189,23 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
10194
10189
  }
10195
10190
  });
10196
10191
  const Empty = /* @__PURE__ */ _export_sfc(_sfc_main$q, [["__scopeId", "data-v-f633fb7c"]]);
10197
- const KEY$3 = `${DecoratorUtil.DecoratorKeyPrefix}[Field]`;
10192
+ const KEY$3 = "[Field]";
10198
10193
  function Field(config = {}) {
10199
- return (target, key) => {
10200
- config.key = key;
10201
- DecoratorUtil.setFieldConfig(target, key, KEY$3, config);
10194
+ return (instance, field) => {
10195
+ config.key = field.toString();
10196
+ DecoratorUtil.setFieldConfig(instance, field, KEY$3, config);
10202
10197
  };
10203
10198
  }
10204
- function getFieldConfig(TargetClass, key) {
10205
- return DecoratorUtil.getFieldConfig(TargetClass, key.toString(), KEY$3, true) || {};
10199
+ function getFieldConfig(Class, field) {
10200
+ return DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$3, true) || {};
10206
10201
  }
10207
- function getDictionary(TargetClass, key) {
10202
+ function getDictionary(Class, field) {
10208
10203
  var _a;
10209
- return (_a = getFieldConfig(TargetClass, key)) == null ? void 0 : _a.dictionary;
10204
+ return (_a = getFieldConfig(Class, field)) == null ? void 0 : _a.dictionary;
10210
10205
  }
10211
- function getFieldLabel(TargetClass, key) {
10206
+ function getFieldLabel(Class, field) {
10212
10207
  var _a;
10213
- return ((_a = getFieldConfig(TargetClass, key)) == null ? void 0 : _a.label) || key.toString();
10208
+ return ((_a = getFieldConfig(Class, field)) == null ? void 0 : _a.label) || field.toString();
10214
10209
  }
10215
10210
  const _sfc_main$p = /* @__PURE__ */ defineComponent({
10216
10211
  __name: "FormField",
@@ -13637,35 +13632,35 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
13637
13632
  };
13638
13633
  }
13639
13634
  });
13640
- const KEY$2 = `${DecoratorUtil.DecoratorKeyPrefix}[Form]`;
13641
- const LIST_KEY$2 = `${DecoratorUtil.DecoratorKeyPrefix}[FormList]`;
13635
+ const KEY$2 = "[Form]";
13636
+ const LIST_KEY$2 = "[FormList]";
13642
13637
  function Form(config = {}) {
13643
- return (target, key) => {
13644
- config.key = key;
13645
- DecoratorUtil.setFieldConfig(target, key, KEY$2, config, LIST_KEY$2);
13638
+ return (instance, key) => {
13639
+ config.key = key.toString();
13640
+ DecoratorUtil.setFieldConfig(instance, key, KEY$2, config, LIST_KEY$2);
13646
13641
  };
13647
13642
  }
13648
- function getFormConfig(TargetClass, key) {
13649
- const formConfig = DecoratorUtil.getFieldConfig(TargetClass, key.toString(), KEY$2, true);
13643
+ function getFormConfig(Class, field) {
13644
+ const formConfig = DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$2, true);
13650
13645
  if (!formConfig) {
13651
- return { key: key.toString() };
13646
+ return { key: field.toString() };
13652
13647
  }
13653
13648
  if (!formConfig.dictionary) {
13654
- const props = getFieldConfig(TargetClass, key);
13649
+ const props = getFieldConfig(Class, field);
13655
13650
  if (props && props.dictionary) {
13656
13651
  formConfig.dictionary = props.dictionary;
13657
13652
  }
13658
13653
  }
13659
13654
  return formConfig;
13660
13655
  }
13661
- function getFormFieldList(TargetClass) {
13662
- return DecoratorUtil.getFieldList(TargetClass, LIST_KEY$2);
13656
+ function getFormFieldList(Class) {
13657
+ return DecoratorUtil.getFieldList(Class, LIST_KEY$2);
13663
13658
  }
13664
- function getFormConfigList(TargetClass, keyList = []) {
13665
- if (keyList.length === 0) {
13666
- keyList = getFormFieldList(TargetClass);
13659
+ function getFormConfigList(Class, fieldList = []) {
13660
+ if (fieldList.length === 0) {
13661
+ fieldList = getFormFieldList(Class);
13667
13662
  }
13668
- const list = keyList.map((key) => getFormConfig(TargetClass, key));
13663
+ const list = fieldList.map((field) => getFormConfig(Class, field));
13669
13664
  return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
13670
13665
  }
13671
13666
  var FormTrim = /* @__PURE__ */ ((FormTrim2) => {
@@ -16761,56 +16756,54 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
16761
16756
  };
16762
16757
  }
16763
16758
  });
16764
- const KEY$1 = `${DecoratorUtil.DecoratorKeyPrefix}[Search]`;
16765
- const LIST_KEY$1 = `${DecoratorUtil.DecoratorKeyPrefix}[SearchList]`;
16759
+ const KEY$1 = "[Search]";
16760
+ const LIST_KEY$1 = "[SearchList]";
16766
16761
  function Search(config = {}) {
16767
- return (target, key) => {
16768
- config.key = key;
16769
- DecoratorUtil.setFieldConfig(target, key, KEY$1, config, LIST_KEY$1);
16762
+ return (instance, field) => {
16763
+ config.key = field.toString();
16764
+ DecoratorUtil.setFieldConfig(instance, field, KEY$1, config, LIST_KEY$1);
16770
16765
  };
16771
16766
  }
16772
- function getSearchConfig(TargetClass, key) {
16773
- const instance = new TargetClass();
16774
- const formConfig = DecoratorUtil.getFieldConfig(instance, key.toString(), KEY$1, true);
16767
+ function getSearchConfig(Class, field) {
16768
+ const formConfig = DecoratorUtil.getFieldConfig(Class, field.toString(), KEY$1, true);
16775
16769
  if (!formConfig) {
16776
- return { key: key.toString() };
16770
+ return { key: field.toString() };
16777
16771
  }
16778
16772
  return formConfig;
16779
16773
  }
16780
- function getSearchFieldList(TargetClass) {
16781
- return DecoratorUtil.getFieldList(TargetClass, LIST_KEY$1);
16774
+ function getSearchFieldList(Class) {
16775
+ return DecoratorUtil.getFieldList(Class, LIST_KEY$1);
16782
16776
  }
16783
- function getSearchConfigList(TargetClass, keyList = []) {
16784
- if (keyList.length === 0) {
16785
- keyList = getSearchFieldList(TargetClass);
16777
+ function getSearchConfigList(Class, fieldList = []) {
16778
+ if (fieldList.length === 0) {
16779
+ fieldList = getSearchFieldList(Class);
16786
16780
  }
16787
- const list = keyList.map((key) => getSearchConfig(TargetClass, key));
16781
+ const list = fieldList.map((field) => getSearchConfig(Class, field));
16788
16782
  return list.filter((item) => !item.hide).sort((a, b) => (b.order || 0) - (a.order || 0));
16789
16783
  }
16790
- const KEY = `${DecoratorUtil.DecoratorKeyPrefix}[Table]`;
16791
- const LIST_KEY = `${DecoratorUtil.DecoratorKeyPrefix}[TableList]`;
16784
+ const KEY = "[Table]";
16785
+ const LIST_KEY = "[TableList]";
16792
16786
  function Table(config = {}) {
16793
- return (target, key) => {
16794
- config.key = key;
16795
- DecoratorUtil.setFieldConfig(target, key, KEY, config, LIST_KEY);
16787
+ return (instance, field) => {
16788
+ config.key = field.toString();
16789
+ DecoratorUtil.setFieldConfig(instance, field, KEY, config, LIST_KEY);
16796
16790
  };
16797
16791
  }
16798
- function getTableConfig(TargetClass, key) {
16799
- const instance = new TargetClass();
16800
- const tableConfig = DecoratorUtil.getFieldConfig(instance, key.toString(), KEY, true);
16792
+ function getTableConfig(Class, field) {
16793
+ const tableConfig = DecoratorUtil.getFieldConfig(Class, field, KEY, true);
16801
16794
  if (!tableConfig) {
16802
- return { key: key.toString() };
16795
+ return { key: field.toString() };
16803
16796
  }
16804
16797
  return tableConfig;
16805
16798
  }
16806
- function getTableFieldList(TargetClass) {
16807
- return DecoratorUtil.getFieldList(TargetClass, LIST_KEY);
16799
+ function getTableFieldList(Class) {
16800
+ return DecoratorUtil.getFieldList(Class, LIST_KEY);
16808
16801
  }
16809
- function getTableConfigList(TargetClass, keyList = []) {
16810
- if (keyList.length === 0) {
16811
- keyList = getTableFieldList(TargetClass);
16802
+ function getTableConfigList(Class, fieldList = []) {
16803
+ if (fieldList.length === 0) {
16804
+ fieldList = getTableFieldList(Class);
16812
16805
  }
16813
- const list = keyList.map((key) => getTableConfig(TargetClass, key));
16806
+ const list = fieldList.map((field) => getTableConfig(Class, field));
16814
16807
  return list.sort((a, b) => (b.order || 0) - (a.order || 0));
16815
16808
  }
16816
16809
  var __defProp$2 = Object.defineProperty;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airpower/web",
3
3
  "type": "module",
4
- "version": "0.2.27",
4
+ "version": "0.2.29",
5
5
  "description": "AirPower-Web",
6
6
  "author": {
7
7
  "name": "Hamm",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@airpower/enum": "^0.0.10",
43
43
  "@airpower/i18n": "^0.0.4",
44
- "@airpower/transformer": "^0.1.2",
44
+ "@airpower/transformer": "^0.1.6",
45
45
  "@airpower/util": "^0.1.3",
46
46
  "@element-plus/icons-vue": "^2.3.1",
47
47
  "axios": "^1.8.4",
File without changes