@ftjs/core 0.1.2 → 0.1.3

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/index.js CHANGED
@@ -90,7 +90,7 @@ const setStorage = (key, value, cache) => {
90
90
  localStorage.setItem(key, JSON.stringify(obj));
91
91
  }
92
92
  };
93
- const transferVueArrayPropsToObject = (arr) => {
93
+ function transferVueArrayPropsToObject(arr) {
94
94
  const props = {};
95
95
  arr.forEach((item) => {
96
96
  if (typeof item === "string") {
@@ -100,7 +100,7 @@ const transferVueArrayPropsToObject = (arr) => {
100
100
  }
101
101
  });
102
102
  return props;
103
- };
103
+ }
104
104
  const getPropsKeys = (arr) => {
105
105
  return arr.map((item) => {
106
106
  if (typeof item === "string") {
@@ -455,7 +455,6 @@ const defineFtForm = (setup, renderMap, _runtimeProps) => {
455
455
  return () => h(FormComponent, null, {
456
456
  ...ctx.slots,
457
457
  formContent: () => visibleColumns.value.map((column) => {
458
- var _a;
459
458
  if (!renderMap.has(column.type)) {
460
459
  console.warn(
461
460
  `[@ftjs/core]: 没有配置 column.type ${column.type}, 请检查该组件是否注册`
@@ -467,7 +466,7 @@ const defineFtForm = (setup, renderMap, _runtimeProps) => {
467
466
  column,
468
467
  // 是否为查看模式
469
468
  isView: column.isView,
470
- key: column.field ?? ((_a = column.fields) == null ? void 0 : _a[0])
469
+ key: getField(column)
471
470
  });
472
471
  })
473
472
  });
@@ -7,7 +7,10 @@ export interface TableTypeMap<TableData extends Record<string, any>, SearchData
7
7
  tableSlots: {};
8
8
  tableColumn: FtTableColumn<TableData>;
9
9
  formColumn: FtFormColumnBase<SearchData>;
10
- extendedProps: {};
10
+ extendedProps: {
11
+ testProps: string;
12
+ onTestEvent: () => void;
13
+ };
11
14
  internalFormProps: {};
12
15
  internalTableProps: {};
13
16
  };
@@ -1,10 +1,9 @@
1
1
  import { ComputedRef } from 'vue';
2
2
  import { TableTypeMap, FtTableIntrinsicProps } from './define-components';
3
3
  import { SplitEventKeys } from '../type-helper';
4
- type TableInject<TableData extends Record<string, any>, FormData extends Record<string, any> = TableData, Type extends keyof TableTypeMap<TableData, FormData> = "default"> = SplitEventKeys<FtTableIntrinsicProps<TableData, FormData, Type> & TableTypeMap<TableData, FormData>[Type]["extendedProps"]> & {
4
+ export type TableInject<TableData extends Record<string, any>, FormData extends Record<string, any> = TableData, Type extends keyof TableTypeMap<TableData, FormData> = "default"> = SplitEventKeys<FtTableIntrinsicProps<TableData, FormData, Type> & TableTypeMap<TableData, FormData>[Type]["extendedProps"]> & {
5
5
  formColumns: ComputedRef<TableTypeMap<TableData, FormData>[Type]["formColumn"][]>;
6
6
  tableColumns: ComputedRef<TableTypeMap<TableData, FormData>[Type]["tableColumn"][]>;
7
7
  };
8
8
  export declare const useTable: <TableData extends Record<string, any>, FormData extends Record<string, any>, Type extends keyof TableTypeMap<TableData, FormData>>(props: FtTableIntrinsicProps<TableData, FormData, Type>, runtimePropsKeys: string[]) => void;
9
9
  export declare const useTableInject: <TableData extends Record<string, any>, FormData extends Record<string, any> = TableData, Type extends keyof TableTypeMap<TableData, FormData> = "default">() => TableInject<TableData, FormData, Type> | undefined;
10
- export {};
@@ -1,4 +1,4 @@
1
- import { ComputedRef, MaybeRef } from 'vue';
1
+ import { ComputedRef, MaybeRef, Ref } from 'vue';
2
2
  /**
3
3
  * 临时工具类型减1
4
4
  */
@@ -27,7 +27,7 @@ export type Unrefs<T> = {
27
27
  * 工具类型:将对象的属性值转换为 {@link MaybeRef}
28
28
  */
29
29
  export type Refs<T> = {
30
- [K in keyof T]: MaybeRef<T[K]>;
30
+ [K in keyof T]: T[K] extends Ref<any> ? T[K] : MaybeRef<T[K]>;
31
31
  };
32
32
  /**
33
33
  * 工具类型:将对象的属性转换为元组
@@ -47,12 +47,6 @@ type UnionToTuple<T> = ((T extends any ? (t: T) => T : never) extends infer U ?
47
47
  export type WithLengthKeys<T> = (keyof T)[] & {
48
48
  length: TupleKeys<T>["length"];
49
49
  };
50
- /**
51
- * 工具类型:将对象中所有属性值转为 {@link ComputedRef}
52
- */
53
- export type ComputedRefKeys<T> = {
54
- [K in keyof T]-?: T[K] extends ComputedRef<any> ? T[K] : ComputedRef<T[K]>;
55
- };
56
50
  /**
57
51
  * 工具类型:将对象中所有属性值分流,分为事件和非事件
58
52
  *
@@ -0,0 +1 @@
1
+ export {};
package/dist/utils.d.ts CHANGED
@@ -4,6 +4,9 @@ import { FtFormColumnBase } from './form/columns';
4
4
  export declare const isBrowser: boolean;
5
5
  export declare const getField: <T extends Record<string, any>>(column: FtFormColumnBase<T>) => RecordPath<T>;
6
6
  export declare const isEmptyStrOrNull: (val: any) => boolean;
7
+ /**
8
+ * 深拷贝(简化版)
9
+ */
7
10
  export declare const cloneDeep: <T>(obj: T) => T;
8
11
  export declare const get: (obj: any, path: string) => any;
9
12
  export declare const set: (obj: any, path: string, value: any) => void;
@@ -36,5 +39,5 @@ export type RuntimeProps<T extends readonly any[] = []> = T[number] | [
36
39
  validator?(value: unknown, props: any): boolean;
37
40
  }
38
41
  ];
39
- export declare const transferVueArrayPropsToObject: (arr: RuntimeProps[]) => any;
42
+ export declare function transferVueArrayPropsToObject<T extends readonly any[] = []>(arr: RuntimeProps<T>[]): any;
40
43
  export declare const getPropsKeys: (arr: RuntimeProps<any>[]) => any[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ftjs/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "keywords": [],
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "scripts": {
38
38
  "build": "vite build",
39
39
  "minify": "pnpm dlx esbuild ./dist/index.js --minify --outfile=./dist/index.min.js",
40
- "test": "vitest",
40
+ "test": "vitest --typecheck",
41
41
  "test:coverage": "vitest run --coverage",
42
42
  "pub": "tsx ../../scripts/publish.ts"
43
43
  }