dynamicformdjx-react 0.0.1 → 0.0.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/README.md +84 -2
- package/dist/index.cjs +8 -8
- package/dist/index.css +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +811 -311
- package/dist/origin/DynamicCascadeInput.d.ts +17 -0
- package/dist/origin/DynamicInput.d.ts +14 -4
- package/dist/types/index.d.ts +33 -0
- package/dist/utils/tools.d.ts +10 -0
- package/package.json +25 -10
- package/dist/types/dyForm.d.ts +0 -44
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ValueType, DyRandomFun, DyBtnConfig, DyListConfig, DyCasConfig, DyCasFormItem, ExposeType } from '../types';
|
|
2
|
+
type DynamicCascadeInputProps = {
|
|
3
|
+
depth?: number;
|
|
4
|
+
value: ValueType;
|
|
5
|
+
isController?: boolean;
|
|
6
|
+
dyCls?: string;
|
|
7
|
+
randomFun?: DyRandomFun;
|
|
8
|
+
newChildTxt?: (it: DyCasFormItem) => string;
|
|
9
|
+
onChange: (v: ValueType) => void;
|
|
10
|
+
onReset?: () => void;
|
|
11
|
+
onMerge?: (v: ValueType, ori: DyCasFormItem[]) => void;
|
|
12
|
+
btnConfigs?: DyBtnConfig;
|
|
13
|
+
configs?: DyCasConfig;
|
|
14
|
+
dyListConfigs?: DyListConfig;
|
|
15
|
+
};
|
|
16
|
+
declare const DynamicCascadeInput: import('react').ForwardRefExoticComponent<DynamicCascadeInputProps & import('react').RefAttributes<ExposeType>>;
|
|
17
|
+
export default DynamicCascadeInput;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import { ExposeType } from '../types';
|
|
2
|
-
type
|
|
3
|
-
size?:
|
|
1
|
+
import { ExposeType, FSize, ValueType, DyRandomFun, DyBtnConfig, DyListConfig, DyConfig, DyCFormItem } from '../types';
|
|
2
|
+
type DynamicInputProps = {
|
|
3
|
+
size?: FSize;
|
|
4
|
+
value: ValueType;
|
|
5
|
+
isController?: boolean;
|
|
6
|
+
dyCls?: string;
|
|
7
|
+
randomFun?: DyRandomFun;
|
|
8
|
+
onChange: (v: ValueType) => void;
|
|
9
|
+
onReset?: () => void;
|
|
10
|
+
onMerge?: (v: ValueType, ori: DyCFormItem[]) => void;
|
|
11
|
+
btnConfigs?: DyBtnConfig;
|
|
12
|
+
configs?: DyConfig;
|
|
13
|
+
dyListConfigs?: DyListConfig;
|
|
4
14
|
};
|
|
5
|
-
declare const DynamicInput: import('react').ForwardRefExoticComponent<
|
|
15
|
+
declare const DynamicInput: import('react').ForwardRefExoticComponent<DynamicInputProps & import('react').RefAttributes<ExposeType>>;
|
|
6
16
|
export default DynamicInput;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
export type DyCFormItem = {
|
|
2
|
+
rId: string;
|
|
3
|
+
key: string;
|
|
4
|
+
value: string;
|
|
5
|
+
isArray?: boolean;
|
|
6
|
+
isNumber?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type DyCasFormItem = {
|
|
9
|
+
rId: string;
|
|
10
|
+
key: string;
|
|
11
|
+
value: string | DyCasFormItem[];
|
|
12
|
+
isArray?: boolean;
|
|
13
|
+
isNumber?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type FSize = "small" | "large" | "default";
|
|
16
|
+
export type DyBtnConfig = Record<'resetTxt' | 'newTxt' | 'mergeTxt', string>;
|
|
17
|
+
export type DyConfig = {
|
|
18
|
+
hideReset?: boolean;
|
|
19
|
+
maxHeight?: string;
|
|
20
|
+
autoScroll?: boolean;
|
|
21
|
+
allowFilter?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type DyCasConfig = {
|
|
24
|
+
showBorder?: boolean;
|
|
25
|
+
retractLen?: number;
|
|
26
|
+
borderColors?: string[];
|
|
27
|
+
showPad?: boolean;
|
|
28
|
+
} & Omit<DyConfig, 'autoScroll'>;
|
|
29
|
+
export type DyListConfig = {
|
|
30
|
+
arraySplitSymbol: string;
|
|
31
|
+
};
|
|
32
|
+
export type ValueType = Record<string, any>;
|
|
33
|
+
export type DyRandomFun = (id?: number | string) => string;
|
|
1
34
|
export type ExposeType = {
|
|
2
35
|
onSet?: (obj?: object) => void;
|
|
3
36
|
getResult?: (t: 'res' | 'ori') => DyCFormItem[] | object;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ValueType, DyCFormItem, DyRandomFun, DyCasFormItem } from '../types';
|
|
2
|
+
declare const tranArr: (obj: ValueType, arrayFun: DyRandomFun, splitSymbol: string) => DyCFormItem[];
|
|
3
|
+
declare const resetObj: (arr: DyCFormItem[], splitSymbol: string) => ValueType;
|
|
4
|
+
declare const parseValue: (value: string, isArray?: boolean, isNumber?: boolean, splitSym?: string) => any;
|
|
5
|
+
declare const formatNumberInput: (val: string, isArray?: boolean, splitSymbol?: string) => string;
|
|
6
|
+
declare const getDepthColor: (depth: number) => string;
|
|
7
|
+
declare const saferRepairColor: (colors: string[], i: number) => string;
|
|
8
|
+
declare function updateArrayAtPath(items: DyCasFormItem[], path: number[], // 指向某个 item(最后一个数字是下标)
|
|
9
|
+
updater: (arr: DyCasFormItem[], index: number) => DyCasFormItem[]): DyCasFormItem[];
|
|
10
|
+
export { tranArr, resetObj, parseValue, formatNumberInput, getDepthColor, saferRepairColor, updateArrayAtPath };
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dynamicformdjx-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "xczcdjx",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"description": "Dynamic form for React",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/xczcdjx/dynamicFormReact"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/xczcdjx/dynamicFormReact#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/xczcdjx/dynamicFormReact/issues"
|
|
15
|
+
},
|
|
8
16
|
"main": "dist/index.cjs",
|
|
9
17
|
"module": "dist/index.mjs",
|
|
10
18
|
"types": "dist/index.d.ts",
|
|
@@ -15,9 +23,17 @@
|
|
|
15
23
|
"require": "./dist/index.cjs"
|
|
16
24
|
}
|
|
17
25
|
},
|
|
18
|
-
"files": [
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": [
|
|
30
|
+
"**/*.css"
|
|
31
|
+
],
|
|
32
|
+
"keywords": [
|
|
33
|
+
"react",
|
|
34
|
+
"typescript",
|
|
35
|
+
"dynamicForm"
|
|
36
|
+
],
|
|
21
37
|
"scripts": {
|
|
22
38
|
"dev-r": "vite",
|
|
23
39
|
"build-r": "tsc -b && vite build",
|
|
@@ -28,26 +44,25 @@
|
|
|
28
44
|
"react": "^18.0.0",
|
|
29
45
|
"react-dom": "^18.0.0"
|
|
30
46
|
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
},
|
|
33
47
|
"devDependencies": {
|
|
34
48
|
"@eslint/js": "^9.39.1",
|
|
35
49
|
"@types/node": "^24.10.1",
|
|
36
50
|
"@types/react": "^18.3.27",
|
|
37
51
|
"@types/react-dom": "^18.3.7",
|
|
38
52
|
"@vitejs/plugin-react": "^5.1.1",
|
|
53
|
+
"antd": "^5.29.1",
|
|
54
|
+
"clsx": "^2.1.1",
|
|
39
55
|
"eslint": "^9.39.1",
|
|
40
56
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
41
57
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
42
58
|
"globals": "^16.5.0",
|
|
43
59
|
"less": "^4.4.2",
|
|
60
|
+
"react": "^18.0.0",
|
|
61
|
+
"react-dom": "^18.0.0",
|
|
44
62
|
"typescript": "~5.9.3",
|
|
45
63
|
"typescript-eslint": "^8.46.4",
|
|
46
64
|
"vite": "^7.2.4",
|
|
47
65
|
"vite-plugin-dts": "^4.5.4",
|
|
48
|
-
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
49
|
-
"antd": "^5.29.1",
|
|
50
|
-
"react": "^18.0.0",
|
|
51
|
-
"react-dom": "^18.0.0"
|
|
66
|
+
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
52
67
|
}
|
|
53
68
|
}
|
package/dist/types/dyForm.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export {}
|
|
2
|
-
declare global {
|
|
3
|
-
type DyCFormItem = {
|
|
4
|
-
rId: string;
|
|
5
|
-
key: string;
|
|
6
|
-
value: string;
|
|
7
|
-
isArray?: boolean;
|
|
8
|
-
isNumber?: boolean;
|
|
9
|
-
};
|
|
10
|
-
type DyCasFormItem = {
|
|
11
|
-
rId: string;
|
|
12
|
-
key: string;
|
|
13
|
-
value: string | DyCasFormItem[];
|
|
14
|
-
isArray?: boolean
|
|
15
|
-
isNumber?: boolean
|
|
16
|
-
};
|
|
17
|
-
type FSize = "small" | "large" | "default"
|
|
18
|
-
type DyBtnConfig = Record<'resetTxt' | 'newTxt' | 'mergeTxt', string>
|
|
19
|
-
type DyConfig = {
|
|
20
|
-
// 隐藏重置按钮 (默认false)
|
|
21
|
-
hideReset?: boolean;
|
|
22
|
-
// 输入栏最大高度 (默认300px)
|
|
23
|
-
maxHeight?: string;
|
|
24
|
-
// 新增项超过高度时是否自动滚动 (默认true)
|
|
25
|
-
autoScroll?: boolean;
|
|
26
|
-
// 允许输入过滤 (默认true)
|
|
27
|
-
allowFilter?: boolean;
|
|
28
|
-
// ...
|
|
29
|
-
}
|
|
30
|
-
type DyCasConfig = {
|
|
31
|
-
showBorder?:boolean
|
|
32
|
-
retractLen?:number
|
|
33
|
-
borderColors?:string[]
|
|
34
|
-
showPad?:boolean
|
|
35
|
-
} & Omit<DyConfig, 'autoScroll'>
|
|
36
|
-
type DyListConfig = {
|
|
37
|
-
// 分隔符
|
|
38
|
-
arraySplitSymbol: string
|
|
39
|
-
// ...
|
|
40
|
-
}
|
|
41
|
-
type ValueType = Record<string, any>
|
|
42
|
-
// 内部新建键值对id
|
|
43
|
-
type DyRandomFun = (id?: number | string) => string
|
|
44
|
-
}
|