n-design-readonly-plugin 1.0.2 → 1.0.4
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/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +5 -3
- package/dist/index.cjs.js +57 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.es.js +1044 -173
- package/dist/withReadonly.d.ts +7 -71
- package/package.json +8 -3
- package/.DS_Store +0 -0
- package/.gitignore +0 -31
- package/n-design-readonly-plugin-1.0.0.tgz +0 -0
- package/playground/App.vue +0 -77
- package/playground/index.html +0 -16
- package/playground/main.ts +0 -12
- package/playground/reset.css +0 -126
- package/src/index.ts +0 -52
- package/src/types/env.d.ts +0 -11
- package/src/withReadonly.tsx +0 -414
- package/tsconfig.json +0 -19
- package/vite.config.playground.ts +0 -17
- package/vite.config.ts +0 -20
package/dist/withReadonly.d.ts
CHANGED
|
@@ -1,71 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} | {
|
|
9
|
-
type: BooleanConstructor;
|
|
10
|
-
default: undefined;
|
|
11
|
-
} | {
|
|
12
|
-
type: StringConstructor;
|
|
13
|
-
default: string;
|
|
14
|
-
} | {
|
|
15
|
-
type: PropType<ValueToLabelFn>;
|
|
16
|
-
default: null;
|
|
17
|
-
};
|
|
18
|
-
modelValue: {
|
|
19
|
-
type: PropType<FormModelValue>;
|
|
20
|
-
default: undefined;
|
|
21
|
-
};
|
|
22
|
-
readonly: {
|
|
23
|
-
type: BooleanConstructor;
|
|
24
|
-
default: undefined;
|
|
25
|
-
};
|
|
26
|
-
emptyText: {
|
|
27
|
-
type: StringConstructor;
|
|
28
|
-
default: string;
|
|
29
|
-
};
|
|
30
|
-
valueToLabel: {
|
|
31
|
-
type: PropType<ValueToLabelFn>;
|
|
32
|
-
default: null;
|
|
33
|
-
};
|
|
34
|
-
}, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
}>, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, string[], string, import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, Readonly<import('vue').ExtractPropTypes<{
|
|
37
|
-
[x: string]: {
|
|
38
|
-
type: PropType<FormModelValue>;
|
|
39
|
-
default: undefined;
|
|
40
|
-
} | {
|
|
41
|
-
type: BooleanConstructor;
|
|
42
|
-
default: undefined;
|
|
43
|
-
} | {
|
|
44
|
-
type: StringConstructor;
|
|
45
|
-
default: string;
|
|
46
|
-
} | {
|
|
47
|
-
type: PropType<ValueToLabelFn>;
|
|
48
|
-
default: null;
|
|
49
|
-
};
|
|
50
|
-
modelValue: {
|
|
51
|
-
type: PropType<FormModelValue>;
|
|
52
|
-
default: undefined;
|
|
53
|
-
};
|
|
54
|
-
readonly: {
|
|
55
|
-
type: BooleanConstructor;
|
|
56
|
-
default: undefined;
|
|
57
|
-
};
|
|
58
|
-
emptyText: {
|
|
59
|
-
type: StringConstructor;
|
|
60
|
-
default: string;
|
|
61
|
-
};
|
|
62
|
-
valueToLabel: {
|
|
63
|
-
type: PropType<ValueToLabelFn>;
|
|
64
|
-
default: null;
|
|
65
|
-
};
|
|
66
|
-
}>> & {
|
|
67
|
-
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
68
|
-
}, {
|
|
69
|
-
[x: string]: FormModelValue | ValueToLabelFn;
|
|
70
|
-
}, {}>;
|
|
71
|
-
export {};
|
|
1
|
+
import { Component } from 'vue';
|
|
2
|
+
export declare function withReadonly(BaseComponent: Component): import('vue').FunctionalComponent<any, any, any> | {
|
|
3
|
+
new (...args: any[]): any;
|
|
4
|
+
__isFragment?: never;
|
|
5
|
+
__isTeleport?: never;
|
|
6
|
+
__isSuspense?: never;
|
|
7
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n-design-readonly-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "只读模式插件 for n-designv3",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
|
-
""
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"CHANGELOG.md"
|
|
18
20
|
],
|
|
19
21
|
"scripts": {
|
|
20
22
|
"dev": "vite --config vite.config.playground.ts",
|
|
@@ -31,7 +33,7 @@
|
|
|
31
33
|
"hoc"
|
|
32
34
|
],
|
|
33
35
|
"author": "pangsh<psh2416623245@163.com>",
|
|
34
|
-
"license": "
|
|
36
|
+
"license": "MIT",
|
|
35
37
|
"packageManager": "pnpm@10.21.0",
|
|
36
38
|
"devDependencies": {
|
|
37
39
|
"@types/node": "^25.2.0",
|
|
@@ -41,5 +43,8 @@
|
|
|
41
43
|
"vite": "^7.3.1",
|
|
42
44
|
"vite-plugin-dts": "^4.5.4",
|
|
43
45
|
"vue": "3.3.4"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@nancal-icon/icons-vue": "^1.0.8"
|
|
44
49
|
}
|
|
45
50
|
}
|
package/.DS_Store
DELETED
|
Binary file
|
package/.gitignore
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Logs
|
|
2
|
-
logs
|
|
3
|
-
*.log
|
|
4
|
-
npm-debug.log*
|
|
5
|
-
yarn-debug.log*
|
|
6
|
-
yarn-error.log*
|
|
7
|
-
pnpm-debug.log*
|
|
8
|
-
lerna-debug.log*
|
|
9
|
-
|
|
10
|
-
node_modules
|
|
11
|
-
.DS_Store
|
|
12
|
-
dist
|
|
13
|
-
dist-ssr
|
|
14
|
-
coverage
|
|
15
|
-
*.local
|
|
16
|
-
package-lock.json
|
|
17
|
-
report.html
|
|
18
|
-
|
|
19
|
-
/cypress/videos/
|
|
20
|
-
/cypress/screenshots/
|
|
21
|
-
|
|
22
|
-
# Editor directories and files
|
|
23
|
-
.vscode/*
|
|
24
|
-
!.vscode/extensions.json
|
|
25
|
-
!.vscode/settings.json
|
|
26
|
-
.idea
|
|
27
|
-
*.suo
|
|
28
|
-
*.ntvs*
|
|
29
|
-
*.njsproj
|
|
30
|
-
*.sln
|
|
31
|
-
*.sw?
|
|
Binary file
|
package/playground/App.vue
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="form-wrapper">
|
|
3
|
-
<nk-form :readonly="false" :model="form" :rules="rules">
|
|
4
|
-
<nk-form-item label="用户名" name="name">
|
|
5
|
-
<nk-input placeholder="用户名" v-model:value="form.name"></nk-input>
|
|
6
|
-
</nk-form-item>
|
|
7
|
-
<n-row>
|
|
8
|
-
<n-col :span="24">
|
|
9
|
-
<nk-form-item label="下拉options" name="ep6ClusterObjId">
|
|
10
|
-
<nk-select
|
|
11
|
-
allowClear
|
|
12
|
-
placeholder="请选择"
|
|
13
|
-
:options="options"
|
|
14
|
-
:showSearch="false"
|
|
15
|
-
v-model:value="form.ep6ClusterObjId"
|
|
16
|
-
>
|
|
17
|
-
</nk-select>
|
|
18
|
-
</nk-form-item>
|
|
19
|
-
</n-col>
|
|
20
|
-
</n-row>
|
|
21
|
-
<n-row>
|
|
22
|
-
<n-col :span="24">
|
|
23
|
-
<nk-form-item label="下拉options" name="ep6ClusterObjId">
|
|
24
|
-
<n-select
|
|
25
|
-
allowClear
|
|
26
|
-
placeholder="请选择"
|
|
27
|
-
:options="options"
|
|
28
|
-
:showSearch="false"
|
|
29
|
-
v-model:value="form.ep6ClusterObjId"
|
|
30
|
-
>
|
|
31
|
-
</n-select>
|
|
32
|
-
</nk-form-item>
|
|
33
|
-
</n-col>
|
|
34
|
-
</n-row>
|
|
35
|
-
</nk-form>
|
|
36
|
-
</div>
|
|
37
|
-
</template>
|
|
38
|
-
|
|
39
|
-
<script lang="ts" setup>
|
|
40
|
-
import { reactive } from "vue";
|
|
41
|
-
|
|
42
|
-
const form = reactive({
|
|
43
|
-
name: "张三",
|
|
44
|
-
ep6ClusterObjId: "1",
|
|
45
|
-
});
|
|
46
|
-
const options = [
|
|
47
|
-
{
|
|
48
|
-
label: "选项1",
|
|
49
|
-
value: "1",
|
|
50
|
-
externalValue: "externalValue1",
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
label: "选项2",
|
|
54
|
-
value: "2",
|
|
55
|
-
externalValue: "externalValue2",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
label: "选项3",
|
|
59
|
-
value: "3",
|
|
60
|
-
externalValue: "externalValue3",
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
const rules = {
|
|
64
|
-
name: [{ required: true, message: "请输入用户名" }],
|
|
65
|
-
ep6ClusterObjId: [{ required: true, message: "请选择" }],
|
|
66
|
-
};
|
|
67
|
-
</script>
|
|
68
|
-
<style>
|
|
69
|
-
.form-wrapper {
|
|
70
|
-
width: 100%;
|
|
71
|
-
height: 100vh;
|
|
72
|
-
padding: 20px;
|
|
73
|
-
box-sizing: border-box;
|
|
74
|
-
position: relative;
|
|
75
|
-
background-color: bisque;
|
|
76
|
-
}
|
|
77
|
-
</style>
|
package/playground/index.html
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8" />
|
|
6
|
-
<link rel="icon" href="/favicon.ico" />
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
|
-
<title>NkReadonlyHOC Playground</title>
|
|
9
|
-
</head>
|
|
10
|
-
|
|
11
|
-
<body>
|
|
12
|
-
<div id="app"></div>
|
|
13
|
-
<script type="module" src="./main.ts"></script>
|
|
14
|
-
</body>
|
|
15
|
-
|
|
16
|
-
</html>
|
package/playground/main.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// main.ts
|
|
2
|
-
import { createApp } from 'vue';
|
|
3
|
-
import App from './App.vue';
|
|
4
|
-
import { NkReadonlyPlugin } from '../src/index';
|
|
5
|
-
import NDesign from 'n-designv3';
|
|
6
|
-
import 'n-designv3/dist/nancal.variable.min.css';
|
|
7
|
-
import './reset.css'
|
|
8
|
-
|
|
9
|
-
const app = createApp(App);
|
|
10
|
-
app.use(NDesign);
|
|
11
|
-
app.use(NkReadonlyPlugin); // ← 一行注册!
|
|
12
|
-
app.mount('#app');
|
package/playground/reset.css
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
html,
|
|
2
|
-
body,
|
|
3
|
-
div,
|
|
4
|
-
span,
|
|
5
|
-
applet,
|
|
6
|
-
object,
|
|
7
|
-
iframe,
|
|
8
|
-
p,
|
|
9
|
-
blockquote,
|
|
10
|
-
pre,
|
|
11
|
-
a,
|
|
12
|
-
abbr,
|
|
13
|
-
acronym,
|
|
14
|
-
address,
|
|
15
|
-
big,
|
|
16
|
-
cite,
|
|
17
|
-
code,
|
|
18
|
-
del,
|
|
19
|
-
dfn,
|
|
20
|
-
em,
|
|
21
|
-
img,
|
|
22
|
-
ins,
|
|
23
|
-
kbd,
|
|
24
|
-
q,
|
|
25
|
-
s,
|
|
26
|
-
samp,
|
|
27
|
-
small,
|
|
28
|
-
strike,
|
|
29
|
-
strong,
|
|
30
|
-
sub,
|
|
31
|
-
sup,
|
|
32
|
-
tt,
|
|
33
|
-
var,
|
|
34
|
-
b,
|
|
35
|
-
u,
|
|
36
|
-
i,
|
|
37
|
-
center,
|
|
38
|
-
dl,
|
|
39
|
-
dt,
|
|
40
|
-
dd,
|
|
41
|
-
ol,
|
|
42
|
-
ul,
|
|
43
|
-
li,
|
|
44
|
-
fieldset,
|
|
45
|
-
form,
|
|
46
|
-
label,
|
|
47
|
-
legend,
|
|
48
|
-
table,
|
|
49
|
-
caption,
|
|
50
|
-
tbody,
|
|
51
|
-
tfoot,
|
|
52
|
-
thead,
|
|
53
|
-
tr,
|
|
54
|
-
th,
|
|
55
|
-
td,
|
|
56
|
-
article,
|
|
57
|
-
aside,
|
|
58
|
-
canvas,
|
|
59
|
-
details,
|
|
60
|
-
embed,
|
|
61
|
-
figure,
|
|
62
|
-
figcaption,
|
|
63
|
-
footer,
|
|
64
|
-
header,
|
|
65
|
-
hgroup,
|
|
66
|
-
menu,
|
|
67
|
-
nav,
|
|
68
|
-
output,
|
|
69
|
-
ruby,
|
|
70
|
-
section,
|
|
71
|
-
summary,
|
|
72
|
-
time,
|
|
73
|
-
mark,
|
|
74
|
-
audio,
|
|
75
|
-
video {
|
|
76
|
-
margin: 0;
|
|
77
|
-
padding: 0;
|
|
78
|
-
border: 0;
|
|
79
|
-
font-size: 100%;
|
|
80
|
-
font: inherit;
|
|
81
|
-
// vertical-align: baseline;
|
|
82
|
-
}
|
|
83
|
-
/* HTML5 display-role reset for older browsers */
|
|
84
|
-
article,
|
|
85
|
-
aside,
|
|
86
|
-
details,
|
|
87
|
-
figcaption,
|
|
88
|
-
figure,
|
|
89
|
-
footer,
|
|
90
|
-
header,
|
|
91
|
-
hgroup,
|
|
92
|
-
menu,
|
|
93
|
-
nav,
|
|
94
|
-
section {
|
|
95
|
-
display: block;
|
|
96
|
-
}
|
|
97
|
-
body {
|
|
98
|
-
line-height: 1;
|
|
99
|
-
}
|
|
100
|
-
ol,
|
|
101
|
-
ul {
|
|
102
|
-
list-style: none;
|
|
103
|
-
}
|
|
104
|
-
blockquote,
|
|
105
|
-
q {
|
|
106
|
-
quotes: none;
|
|
107
|
-
}
|
|
108
|
-
blockquote:before,
|
|
109
|
-
blockquote:after,
|
|
110
|
-
q:before,
|
|
111
|
-
q:after {
|
|
112
|
-
content: '';
|
|
113
|
-
content: none;
|
|
114
|
-
}
|
|
115
|
-
table {
|
|
116
|
-
border-collapse: collapse;
|
|
117
|
-
border-spacing: 0;
|
|
118
|
-
}
|
|
119
|
-
html,
|
|
120
|
-
body {
|
|
121
|
-
width: 100%;
|
|
122
|
-
height: 100%;
|
|
123
|
-
padding: 0;
|
|
124
|
-
margin: 0;
|
|
125
|
-
font-family: 'PingFang SC-Medium', 'PingFang SC-Regular', 'PingFang SC', 'STHeitiSC-Light', 'Helvetica-Light', 'Arial', 'sans-serif';
|
|
126
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import type { App, Plugin } from 'vue';
|
|
3
|
-
import { withReadonly } from './withReadonly';
|
|
4
|
-
|
|
5
|
-
// 👇 直接从 n-designv3 导入组件(构建时 external,不打包)
|
|
6
|
-
import {
|
|
7
|
-
Input,
|
|
8
|
-
InputNumber,
|
|
9
|
-
Textarea,
|
|
10
|
-
Select,
|
|
11
|
-
TreeSelect,
|
|
12
|
-
Cascader,
|
|
13
|
-
DatePicker,
|
|
14
|
-
TimePicker,
|
|
15
|
-
Radio,
|
|
16
|
-
Checkbox,
|
|
17
|
-
Switch,
|
|
18
|
-
Form,
|
|
19
|
-
} from 'n-designv3';
|
|
20
|
-
|
|
21
|
-
const COMPONENTS = {
|
|
22
|
-
Input,
|
|
23
|
-
InputNumber,
|
|
24
|
-
Textarea,
|
|
25
|
-
Select,
|
|
26
|
-
SelectOption: Select.Option,
|
|
27
|
-
TreeSelect,
|
|
28
|
-
Cascader,
|
|
29
|
-
DatePicker,
|
|
30
|
-
TimePicker,
|
|
31
|
-
Radio,
|
|
32
|
-
Checkbox,
|
|
33
|
-
RadioGroup: Radio.Group,
|
|
34
|
-
CheckboxGroup: Checkbox.Group,
|
|
35
|
-
Switch,
|
|
36
|
-
Form,
|
|
37
|
-
FormItem: Form.Item,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const NkReadonlyPlugin: Plugin = {
|
|
41
|
-
install(app: App) {
|
|
42
|
-
for (const [name, Comp] of Object.entries(COMPONENTS)) {
|
|
43
|
-
if (Comp) {
|
|
44
|
-
const ReadonlyComp = withReadonly(Comp);
|
|
45
|
-
app.component(`Nk${name}`, ReadonlyComp);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// 可选:导出 HOC 供用户按需使用
|
|
52
|
-
export { withReadonly };
|