@airpower/web 0.2.13 → 0.2.14

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.
@@ -3,11 +3,12 @@ import { DecoratorTarget } from '@airpower/transformer';
3
3
  import { RootModel } from '../../../base';
4
4
  import { WebEnumConstructor } from '../../../util';
5
5
  import { IFieldConfig } from './IFieldConfig';
6
+ import { FieldConfigOptionalKey } from './type';
6
7
  /**
7
8
  * ### 为属性标记配置
8
9
  * @param config 配置项
9
10
  */
10
- export declare function Field<K extends EnumKey = EnumKey>(config?: IFieldConfig<K>): (target: DecoratorTarget, key: string) => void;
11
+ export declare function Field<K extends EnumKey = EnumKey>(config?: FieldConfigOptionalKey<IFieldConfig<K>>): (target: DecoratorTarget, key: string) => void;
11
12
  /**
12
13
  * ### 获取属性的配置
13
14
  * @returns 配置对象
@@ -1,2 +1,3 @@
1
1
  export * from './Field';
2
2
  export * from './IFieldConfig';
3
+ export * from './type';
@@ -0,0 +1,10 @@
1
+ import { IFieldConfig } from './IFieldConfig';
2
+ /**
3
+ * # 字段配置 `Key` 变为可选
4
+ */
5
+ export type FieldConfigOptionalKey<T extends IFieldConfig> = Omit<T, 'key'> & {
6
+ /**
7
+ * ### 这个属性名你不用传入,你传了我也不认
8
+ */
9
+ key?: string;
10
+ };
@@ -1,11 +1,12 @@
1
1
  import { DecoratorTarget } from '@airpower/transformer';
2
2
  import { RootModel } from '../../../base';
3
+ import { FieldConfigOptionalKey } from '../@Field';
3
4
  import { IFormField } from './IFormField';
4
5
  /**
5
6
  * ### 标记该字段可用于表单配置
6
7
  * @param config 配置项
7
8
  */
8
- export declare function Form(config?: IFormField): (target: DecoratorTarget, key: string) => void;
9
+ export declare function Form(config?: FieldConfigOptionalKey<IFormField>): (target: DecoratorTarget, key: string) => void;
9
10
  /**
10
11
  * ### 获取对象某个字段标记的表单配置项
11
12
  * @param target 目标类或对象
@@ -1,11 +1,12 @@
1
1
  import { DecoratorTarget } from '@airpower/transformer';
2
2
  import { RootModel } from '../../../base';
3
+ import { FieldConfigOptionalKey } from '../@Field';
3
4
  import { ISearchField } from './ISearchField';
4
5
  /**
5
6
  * ### 标记该字段可用于表单配置
6
7
  * @param config 配置项
7
8
  */
8
- export declare function Search(config?: ISearchField): (target: DecoratorTarget, key: string) => void;
9
+ export declare function Search(config?: FieldConfigOptionalKey<ISearchField>): (target: DecoratorTarget, key: string) => void;
9
10
  /**
10
11
  * ### 获取对象某个字段标记的搜索配置项
11
12
  * @param target 目标类或对象
@@ -1,11 +1,12 @@
1
1
  import { DecoratorTarget } from '@airpower/transformer';
2
2
  import { RootModel } from '../../../base';
3
+ import { FieldConfigOptionalKey } from '../@Field';
3
4
  import { ITableColumn } from './ITableColumn';
4
5
  /**
5
6
  * ### 为属性标记是表格字段
6
7
  * @param config 表格列的配置
7
8
  */
8
- export declare function Table(config?: ITableColumn): (target: DecoratorTarget, key: string) => void;
9
+ export declare function Table(config?: FieldConfigOptionalKey<ITableColumn>): (target: DecoratorTarget, key: string) => void;
9
10
  /**
10
11
  * ### 获取对象的属性表格的配置
11
12
  * @param target 目标对象
@@ -5,8 +5,7 @@
5
5
  */
6
6
  export interface IBaseField {
7
7
  /**
8
- * ### 字段标题
9
- * 此字段无需传入, 将自动从被标记类的属性上读取
8
+ * ### 字段名称
10
9
  */
11
- key?: string;
10
+ key: string;
12
11
  }
package/dist/main.js CHANGED
@@ -1147,6 +1147,7 @@ class AbstractCurdService extends AbstractService {
1147
1147
  const KEY$4 = `${DecoratorUtil.DecoratorKeyPrefix}[Field]`;
1148
1148
  function Field(config = {}) {
1149
1149
  return (target, key) => {
1150
+ config.key = key;
1150
1151
  DecoratorUtil.setFieldConfig(target, key, KEY$4, config);
1151
1152
  };
1152
1153
  }
@@ -1166,13 +1167,13 @@ const LIST_KEY$2 = `${DecoratorUtil.DecoratorKeyPrefix}[FormList]`;
1166
1167
  function Form(config = {}) {
1167
1168
  return (target, key) => {
1168
1169
  config.key = key;
1169
- return DecoratorUtil.setFieldConfig(target, key, KEY$3, config, LIST_KEY$2);
1170
+ DecoratorUtil.setFieldConfig(target, key, KEY$3, config);
1170
1171
  };
1171
1172
  }
1172
1173
  function getFormConfig(target, key) {
1173
1174
  const formConfig = DecoratorUtil.getFieldConfig(target, key, KEY$3, true);
1174
1175
  if (!formConfig) {
1175
- return {};
1176
+ return { key };
1176
1177
  }
1177
1178
  if (!formConfig.dictionary) {
1178
1179
  const props = getFieldConfig(target, key);
@@ -1213,13 +1214,13 @@ const LIST_KEY$1 = `${DecoratorUtil.DecoratorKeyPrefix}[SearchList]`;
1213
1214
  function Search(config = {}) {
1214
1215
  return (target, key) => {
1215
1216
  config.key = key;
1216
- return DecoratorUtil.setFieldConfig(target, key, KEY$1, config, LIST_KEY$1);
1217
+ DecoratorUtil.setFieldConfig(target, key, KEY$1, config);
1217
1218
  };
1218
1219
  }
1219
1220
  function getSearchConfig(target, key) {
1220
1221
  const formConfig = DecoratorUtil.getFieldConfig(target, key, KEY$1, true);
1221
1222
  if (!formConfig) {
1222
- return {};
1223
+ return { key };
1223
1224
  }
1224
1225
  return formConfig;
1225
1226
  }
@@ -1238,13 +1239,13 @@ const LIST_KEY = `${DecoratorUtil.DecoratorKeyPrefix}[TableList]`;
1238
1239
  function Table(config = {}) {
1239
1240
  return (target, key) => {
1240
1241
  config.key = key;
1241
- return DecoratorUtil.setFieldConfig(target, key, KEY, config, LIST_KEY);
1242
+ DecoratorUtil.setFieldConfig(target, key, KEY, config);
1242
1243
  };
1243
1244
  }
1244
1245
  function getTableConfig(target, key) {
1245
1246
  const tableConfig = DecoratorUtil.getFieldConfig(target, key, KEY, true);
1246
1247
  if (!tableConfig) {
1247
- return {};
1248
+ return { key };
1248
1249
  }
1249
1250
  return tableConfig;
1250
1251
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airpower/web",
3
3
  "type": "module",
4
- "version": "0.2.13",
4
+ "version": "0.2.14",
5
5
  "description": "AirPower-Web",
6
6
  "author": {
7
7
  "name": "Hamm",