@steedos-widgets/antd 6.10.34-beta.11 → 6.10.34
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/antd.umd.js +79 -20
- package/dist/assets.json +5 -5
- package/dist/components/Select.d.ts +13 -1
- package/dist/meta.js +115 -53
- package/dist/types/components/Select.d.ts +13 -1
- package/package.json +2 -2
package/dist/antd.umd.js
CHANGED
|
@@ -33,12 +33,18 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
33
33
|
};
|
|
34
34
|
return _assign.apply(this, arguments);
|
|
35
35
|
};
|
|
36
|
+
function __rest(s, e) {
|
|
37
|
+
var t = {};
|
|
38
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
40
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
41
|
+
}
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
36
44
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
37
45
|
var e = new Error(message);
|
|
38
46
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
39
47
|
};
|
|
40
|
-
|
|
41
|
-
// 使用 Amis 的 FormItem HOC 包装,可以自动处理数据绑定
|
|
42
48
|
var AntdSelect = function AntdSelect(props) {
|
|
43
49
|
var value = props.value,
|
|
44
50
|
onChange = props.onChange,
|
|
@@ -49,19 +55,74 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
49
55
|
isLoading = _b === void 0 ? false : _b,
|
|
50
56
|
_c = props.selectProps,
|
|
51
57
|
selectProps = _c === void 0 ? {} : _c,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
required = props.required,
|
|
59
|
+
disabled = props.disabled,
|
|
60
|
+
cx = props.classnames,
|
|
61
|
+
render = props.render,
|
|
62
|
+
// Amis 渲染函数
|
|
63
|
+
env = props.env,
|
|
64
|
+
scope = props.scope;
|
|
65
|
+
// 获取用户输入的选项模板字符串 (optionTpl)
|
|
66
|
+
var optionRenderTpl = selectProps.optionTpl;
|
|
67
|
+
// 获取用户输入的标签模板字符串 (labelTpl)
|
|
68
|
+
var labelRenderTpl = selectProps.labelTpl;
|
|
69
|
+
// 【新增】安全地解构 selectProps,排除可能与组件内部或 options 冲突的属性
|
|
70
|
+
// 排除模板属性
|
|
71
|
+
selectProps.optionTpl;
|
|
72
|
+
selectProps.labelTpl;
|
|
73
|
+
// 【关键优化】排除 disabled,防止它禁用整个 Select (除非它来自组件根 props)
|
|
74
|
+
selectProps.disabled;
|
|
75
|
+
// 排除其他可能冲突的属性(如 options, value, onChange 等)
|
|
76
|
+
selectProps.options;
|
|
77
|
+
selectProps.value;
|
|
78
|
+
selectProps.onChange;
|
|
79
|
+
var
|
|
80
|
+
// 捕获所有剩余的属性,用于透传给 Antd Select
|
|
81
|
+
restSelectProps = __rest(selectProps, ["optionTpl", "labelTpl", "disabled", "options", "value", "onChange"]);
|
|
82
|
+
// 1. 格式化选项 (略,保持不变) ...
|
|
55
83
|
var antdOptions = React.useMemo(function () {
|
|
56
|
-
return (amisOptions || []).map(function (item) {
|
|
57
|
-
|
|
84
|
+
return (amisOptions || []).map(function (item, index) {
|
|
85
|
+
var optionItem = {
|
|
58
86
|
label: item.label,
|
|
59
87
|
value: item.value,
|
|
60
|
-
disabled: item.disabled
|
|
88
|
+
disabled: item.disabled,
|
|
89
|
+
// disabled 在这里:控制单个选项的可用性
|
|
90
|
+
data: item
|
|
61
91
|
};
|
|
92
|
+
if (optionRenderTpl && typeof optionRenderTpl === 'string') {
|
|
93
|
+
optionItem.label = render('body', {
|
|
94
|
+
type: 'tpl',
|
|
95
|
+
tpl: optionRenderTpl
|
|
96
|
+
}, {
|
|
97
|
+
data: optionItem.data,
|
|
98
|
+
key: index
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return optionItem;
|
|
62
102
|
});
|
|
63
|
-
}, [amisOptions]);
|
|
64
|
-
// 2.
|
|
103
|
+
}, [amisOptions, optionRenderTpl, scope, env, render]);
|
|
104
|
+
// 2. 实现 customLabelRender 函数 (略,保持不变) ...
|
|
105
|
+
var customLabelRender = React.useMemo(function () {
|
|
106
|
+
if (!labelRenderTpl || typeof labelRenderTpl !== 'string') {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
return function (renderProps) {
|
|
110
|
+
var fullOption = antdOptions.find(function (opt) {
|
|
111
|
+
return opt.value === renderProps.value;
|
|
112
|
+
});
|
|
113
|
+
if (!fullOption) {
|
|
114
|
+
return renderProps.label;
|
|
115
|
+
}
|
|
116
|
+
return render('body', {
|
|
117
|
+
type: 'tpl',
|
|
118
|
+
tpl: labelRenderTpl
|
|
119
|
+
}, {
|
|
120
|
+
data: fullOption.data,
|
|
121
|
+
key: renderProps.value
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
}, [labelRenderTpl, antdOptions, render]);
|
|
125
|
+
// 3. 处理 loading 状态 (略,保持不变) ...
|
|
65
126
|
if (isLoading) {
|
|
66
127
|
return React__default["default"].createElement(antd.Spin, {
|
|
67
128
|
style: {
|
|
@@ -70,28 +131,26 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
70
131
|
}
|
|
71
132
|
});
|
|
72
133
|
}
|
|
73
|
-
//
|
|
134
|
+
// 4. 处理值变化 (略,保持不变) ...
|
|
74
135
|
var handleChange = function handleChange(newValue) {
|
|
75
|
-
// 关键:通过 props.onChange 将值回传给 Amis 表单
|
|
76
136
|
onChange(newValue);
|
|
77
137
|
};
|
|
138
|
+
// 5. 渲染 Antd Select
|
|
78
139
|
return React__default["default"].createElement("div", {
|
|
79
140
|
className: cx('AntdSelect-Wrapper', props.className)
|
|
80
|
-
}, React__default["default"].createElement(antd.Select
|
|
81
|
-
// 绑定值和 onChange 事件
|
|
82
|
-
, _assign({
|
|
83
|
-
// 绑定值和 onChange 事件
|
|
141
|
+
}, React__default["default"].createElement(antd.Select, _assign({
|
|
84
142
|
value: value,
|
|
85
143
|
onChange: handleChange,
|
|
86
|
-
// 渲染选项
|
|
87
144
|
options: antdOptions,
|
|
88
|
-
// antd Select 默认属性
|
|
89
145
|
placeholder: placeholder,
|
|
146
|
+
required: required,
|
|
147
|
+
disabled: disabled,
|
|
90
148
|
allowClear: true,
|
|
91
149
|
style: {
|
|
92
150
|
width: '100%'
|
|
93
|
-
}
|
|
94
|
-
|
|
151
|
+
},
|
|
152
|
+
labelRender: customLabelRender
|
|
153
|
+
}, restSelectProps)));
|
|
95
154
|
};
|
|
96
155
|
exports.AntdSelect = AntdSelect;
|
|
97
156
|
Object.defineProperty(exports, '__esModule', {
|
package/dist/assets.json
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
{
|
|
18
18
|
"package": "@steedos-widgets/antd",
|
|
19
19
|
"urls": [
|
|
20
|
-
"https://unpkg.com/@steedos-widgets/antd@6.10.34
|
|
21
|
-
"https://unpkg.com/@steedos-widgets/antd@6.10.34
|
|
20
|
+
"https://unpkg.com/@steedos-widgets/antd@6.10.34/dist/antd.umd.js",
|
|
21
|
+
"https://unpkg.com/@steedos-widgets/antd@6.10.34/dist/antd.umd.css"
|
|
22
22
|
],
|
|
23
23
|
"library": "BuilderAntd"
|
|
24
24
|
}
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"npm": {
|
|
30
30
|
"package": "@steedos-widgets/antd"
|
|
31
31
|
},
|
|
32
|
-
"url": "https://unpkg.com/@steedos-widgets/antd@6.10.34
|
|
32
|
+
"url": "https://unpkg.com/@steedos-widgets/antd@6.10.34/dist/meta.js",
|
|
33
33
|
"urls": {
|
|
34
|
-
"default": "https://unpkg.com/@steedos-widgets/antd@6.10.34
|
|
35
|
-
"design": "https://unpkg.com/@steedos-widgets/antd@6.10.34
|
|
34
|
+
"default": "https://unpkg.com/@steedos-widgets/antd@6.10.34/dist/meta.js",
|
|
35
|
+
"design": "https://unpkg.com/@steedos-widgets/antd@6.10.34/dist/meta.js"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
]
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './Select.css';
|
|
3
|
-
|
|
3
|
+
interface AntdSelectProps extends React.ComponentProps<any> {
|
|
4
|
+
value?: any;
|
|
5
|
+
onChange: (value: any) => void;
|
|
6
|
+
options?: any[];
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
isLoading?: boolean;
|
|
9
|
+
selectProps?: any;
|
|
10
|
+
classnames?: (...args: (string | false | null | undefined)[]) => string;
|
|
11
|
+
render: (schema: any, props?: any, scope?: any) => React.ReactNode;
|
|
12
|
+
env: any;
|
|
13
|
+
scope: any;
|
|
14
|
+
}
|
|
15
|
+
declare const AntdSelect: React.FC<AntdSelectProps>;
|
|
4
16
|
export { AntdSelect };
|
package/dist/meta.js
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
docUrl: "",
|
|
48
48
|
screenshot: "",
|
|
49
49
|
npm: {
|
|
50
|
-
package: "@steedos-widgets/antd",
|
|
50
|
+
package: "@steedos-widgets/antd",
|
|
51
51
|
version: "{{version}}",
|
|
52
52
|
exportName: "AntdSelect",
|
|
53
53
|
main: "",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
engines: ["amis"],
|
|
66
66
|
// 2. Amis Core Configuration
|
|
67
67
|
amis: {
|
|
68
|
-
name: 'antd-select',
|
|
69
|
-
icon: "fa-fw
|
|
68
|
+
name: 'antd-select',
|
|
69
|
+
icon: "fa-fw fas fa-caret-square-down"
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
var Select = __assign(__assign({}, config), {
|
|
@@ -83,14 +83,12 @@
|
|
|
83
83
|
],
|
|
84
84
|
// 4. Amis Renderer and Editor Plugin Configuration
|
|
85
85
|
amis: {
|
|
86
|
-
// Renderer Registration Info
|
|
87
86
|
render: {
|
|
88
87
|
type: config.amis.name,
|
|
89
|
-
usage: "formitem",
|
|
88
|
+
usage: "formitem",
|
|
90
89
|
weight: 1,
|
|
91
90
|
framework: "react"
|
|
92
91
|
},
|
|
93
|
-
// Editor Plugin Configuration
|
|
94
92
|
plugin: {
|
|
95
93
|
rendererName: config.amis.name,
|
|
96
94
|
$schema: '/schemas/FormItem.json',
|
|
@@ -99,10 +97,10 @@
|
|
|
99
97
|
tags: [config.group],
|
|
100
98
|
order: -9999,
|
|
101
99
|
icon: config.amis.icon,
|
|
102
|
-
// Default scaffolding structure
|
|
103
100
|
scaffold: {
|
|
104
101
|
type: config.amis.name,
|
|
105
102
|
label: config.title,
|
|
103
|
+
name: 'select_field',
|
|
106
104
|
options: [
|
|
107
105
|
{ label: 'Option One', value: 'one' },
|
|
108
106
|
{ label: 'Option Two', value: 'two' },
|
|
@@ -110,55 +108,119 @@
|
|
|
110
108
|
},
|
|
111
109
|
previewSchema: { type: config.amis.name, label: 'Preview', placeholder: 'Please select' },
|
|
112
110
|
panelTitle: 'Select Dropdown Settings',
|
|
113
|
-
//
|
|
111
|
+
// ====== OPTIMIZED PANEL CONTROLS (General & Advanced Tabs) START ======
|
|
114
112
|
panelControls: [
|
|
115
|
-
// ====== Basic Properties ======
|
|
116
113
|
{
|
|
117
|
-
type: '
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
114
|
+
type: 'tabs',
|
|
115
|
+
tabs: [
|
|
116
|
+
// =================================== 标签页 1: General ===================================
|
|
117
|
+
{
|
|
118
|
+
title: 'General',
|
|
119
|
+
body: [
|
|
120
|
+
{ type: 'switch', name: 'selectProps.allowClear', label: 'Allow Clear', value: true },
|
|
121
|
+
{ type: 'switch', name: 'isLoading', label: 'Show Loading Indicator' },
|
|
122
|
+
{
|
|
123
|
+
type: 'select',
|
|
124
|
+
name: 'selectProps.mode',
|
|
125
|
+
label: 'Selection Mode',
|
|
126
|
+
options: [
|
|
127
|
+
{ label: 'Single Select (Default)', value: undefined },
|
|
128
|
+
{ label: 'Multiple Select', value: 'multiple' },
|
|
129
|
+
{ label: 'Tags', value: 'tags' }
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
type: 'switch',
|
|
134
|
+
name: 'selectProps.showSearch',
|
|
135
|
+
label: 'Enable Search',
|
|
136
|
+
pipeIn: function (value) { return value !== false; },
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
type: 'select',
|
|
140
|
+
name: 'selectProps.size',
|
|
141
|
+
label: 'Size',
|
|
142
|
+
options: [
|
|
143
|
+
{ label: 'Default', value: 'default' },
|
|
144
|
+
{ label: 'Large', value: 'large' },
|
|
145
|
+
{ label: 'Small', value: 'small' }
|
|
146
|
+
],
|
|
147
|
+
value: 'default',
|
|
148
|
+
},
|
|
149
|
+
{ type: 'switch', name: 'selectProps.bordered', label: 'Show Border', value: true },
|
|
150
|
+
{
|
|
151
|
+
type: 'combo',
|
|
152
|
+
name: 'options',
|
|
153
|
+
label: 'Options',
|
|
154
|
+
"multiLine": true,
|
|
155
|
+
multiple: true,
|
|
156
|
+
items: [
|
|
157
|
+
{ type: 'input-text', name: 'label', label: 'Display Value' },
|
|
158
|
+
{ type: 'input-text', name: 'value', label: 'Actual Value' }
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{ type: 'input-text', name: 'source', label: 'API Data Source (URL)' }
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
// =================================== 标签页 2: Advanced ===================================
|
|
165
|
+
{
|
|
166
|
+
title: 'Advanced',
|
|
167
|
+
body: [
|
|
168
|
+
// --- Custom Option Template (NEW) ---
|
|
169
|
+
{
|
|
170
|
+
type: 'textarea', // 接收文本模板
|
|
171
|
+
name: 'selectProps.optionTpl', // 新属性名
|
|
172
|
+
label: 'Custom Option Template',
|
|
173
|
+
description: 'Use Amis template syntax (e.g., <span>\\${label} (\\${value})</span>) to render each option item.',
|
|
174
|
+
language: 'html', // 方便输入 HTML 结构
|
|
175
|
+
},
|
|
176
|
+
// --- Custom Option Template (NEW) ---
|
|
177
|
+
{
|
|
178
|
+
type: 'textarea', // 接收文本模板
|
|
179
|
+
name: 'selectProps.labelTpl', // 新属性名
|
|
180
|
+
label: 'Custom Label Template',
|
|
181
|
+
description: 'Use Amis template syntax (e.g., <span>\\${label} (\\${value})</span>) to render each option item.',
|
|
182
|
+
language: 'html', // 方便输入 HTML 结构
|
|
183
|
+
},
|
|
184
|
+
// --- Multi-select Tagging ---
|
|
185
|
+
{
|
|
186
|
+
type: 'number',
|
|
187
|
+
name: 'selectProps.maxTagCount',
|
|
188
|
+
label: 'Max Tags to Display',
|
|
189
|
+
description: 'When exceeded, remaining tags are collapsed.',
|
|
190
|
+
min: 0,
|
|
191
|
+
visibleOn: 'this.selectProps && (this.selectProps.mode === "multiple" || this.selectProps.mode === "tags")',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
type: 'select',
|
|
195
|
+
name: 'selectProps.maxTagPlaceholder',
|
|
196
|
+
label: 'Overflow Tag Placeholder',
|
|
197
|
+
options: [
|
|
198
|
+
{ label: 'Default (count)', value: undefined },
|
|
199
|
+
{ label: 'Custom text...', value: 'expression' }
|
|
200
|
+
],
|
|
201
|
+
visibleOn: 'this.selectProps && (this.selectProps.mode === "multiple" || this.selectProps.mode === "tags")',
|
|
202
|
+
},
|
|
203
|
+
// --- Input Limits ---
|
|
204
|
+
{
|
|
205
|
+
type: 'number',
|
|
206
|
+
name: 'selectProps.maxLength',
|
|
207
|
+
label: 'Max Input Length (Search)',
|
|
208
|
+
},
|
|
209
|
+
// --- Dropdown Overlay ---
|
|
210
|
+
{
|
|
211
|
+
type: 'switch',
|
|
212
|
+
name: 'selectProps.dropdownMatchSelectWidth',
|
|
213
|
+
label: 'Dropdown Width Match',
|
|
214
|
+
value: true,
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
type: 'input-text',
|
|
218
|
+
name: 'selectProps.dropdownClassName',
|
|
219
|
+
label: 'Dropdown Class Name',
|
|
220
|
+
},
|
|
221
|
+
]
|
|
222
|
+
}
|
|
140
223
|
]
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
type: 'switch',
|
|
144
|
-
name: 'selectProps.showSearch', // Maps to the selectProps object
|
|
145
|
-
label: 'Searchable',
|
|
146
|
-
pipeIn: function (value) { return value !== false; },
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
type: 'select',
|
|
150
|
-
name: 'selectProps.mode',
|
|
151
|
-
label: 'Selection Mode',
|
|
152
|
-
options: [
|
|
153
|
-
{ label: 'Single Select (Default)', value: undefined },
|
|
154
|
-
{ label: 'Multiple Select', value: 'multiple' },
|
|
155
|
-
{ label: 'Tags', value: 'tags' }
|
|
156
|
-
]
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
type: 'switch',
|
|
160
|
-
name: 'required', // Amis Form validation property
|
|
161
|
-
label: 'Is Required',
|
|
162
224
|
}
|
|
163
225
|
]
|
|
164
226
|
}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './Select.css';
|
|
3
|
-
|
|
3
|
+
interface AntdSelectProps extends React.ComponentProps<any> {
|
|
4
|
+
value?: any;
|
|
5
|
+
onChange: (value: any) => void;
|
|
6
|
+
options?: any[];
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
isLoading?: boolean;
|
|
9
|
+
selectProps?: any;
|
|
10
|
+
classnames?: (...args: (string | false | null | undefined)[]) => string;
|
|
11
|
+
render: (schema: any, props?: any, scope?: any) => React.ReactNode;
|
|
12
|
+
env: any;
|
|
13
|
+
scope: any;
|
|
14
|
+
}
|
|
15
|
+
declare const AntdSelect: React.FC<AntdSelectProps>;
|
|
4
16
|
export { AntdSelect };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos-widgets/antd",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "6.10.34
|
|
4
|
+
"version": "6.10.34",
|
|
5
5
|
"main": "dist/antd.cjs.js",
|
|
6
6
|
"module": "dist/antd.esm.js",
|
|
7
7
|
"unpkg": "dist/antd.umd.js",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"rollup-plugin-tslib-resolve-id": "^0.0.0",
|
|
47
47
|
"rollup-plugin-visualizer": "^5.8.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "04513a8e8a3a36c20ae93dfc58c6209e42766db7"
|
|
50
50
|
}
|