@fairys/taro-tools-simple-form 0.0.2 → 0.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/README.md +320 -1
- package/esm/components/calendar/index.d.ts +10 -0
- package/esm/components/calendar/index.js +35 -0
- package/esm/components/cascader/index.d.ts +10 -0
- package/esm/components/cascader/index.js +85 -0
- package/esm/components/checkbox.group/index.d.ts +5 -0
- package/esm/components/checkbox.group/index.js +14 -0
- package/esm/components/clear/index.d.ts +21 -0
- package/esm/components/clear/index.js +31 -0
- package/esm/components/date.picker/index.d.ts +18 -0
- package/esm/components/date.picker/index.js +122 -0
- package/esm/components/index.d.ts +8 -0
- package/esm/components/index.js +8 -0
- package/esm/components/picker/index.d.ts +9 -0
- package/esm/components/picker/index.js +45 -0
- package/esm/components/popup.search/base.d.ts +2 -0
- package/esm/components/popup.search/base.js +70 -0
- package/esm/components/popup.search/index.d.ts +9 -0
- package/esm/components/popup.search/index.js +157 -0
- package/esm/components/popup.search/instance.d.ts +169 -0
- package/esm/components/popup.search/instance.js +319 -0
- package/esm/components/popup.search/list.table.d.ts +1 -0
- package/esm/components/popup.search/list.table.js +89 -0
- package/esm/components/popup.search/list.virtual.d.ts +1 -0
- package/esm/components/popup.search/list.virtual.js +60 -0
- package/esm/components/radio.group/index.d.ts +5 -0
- package/esm/components/radio.group/index.js +13 -0
- package/esm/index.d.ts +17 -0
- package/esm/index.js +15 -0
- package/esm/interface.d.ts +3 -0
- package/esm/interface.js +0 -0
- package/esm/item.config.d.ts +57 -0
- package/esm/item.config.js +125 -0
- package/esm/styles/index.css +167 -0
- package/lib/index.js +91 -0
- package/package.json +2 -2
- package/src/components/calendar/index.tsx +10 -11
- package/src/components/cascader/index.tsx +9 -11
- package/src/components/clear/index.tsx +49 -0
- package/src/components/date.picker/index.tsx +11 -11
- package/src/components/index.ts +8 -0
- package/src/components/picker/index.tsx +9 -11
- package/src/components/popup.search/index.tsx +86 -64
- package/src/components/popup.search/instance.ts +40 -9
- package/src/components/popup.search/list.table.tsx +3 -2
- package/src/components/popup.search/list.virtual.tsx +3 -2
- package/src/index.tsx +4 -1
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { createContext, useContext, useRef } from "react";
|
|
2
|
+
import { proxy, ref, useSnapshot } from "valtio";
|
|
3
|
+
import taro from "@tarojs/taro";
|
|
4
|
+
class FairysTaroPopupSearchBaseInstanceMount {
|
|
5
|
+
onChange;
|
|
6
|
+
onLoadData;
|
|
7
|
+
otherRequestParams;
|
|
8
|
+
renderText;
|
|
9
|
+
renderListItemText;
|
|
10
|
+
renderList;
|
|
11
|
+
mode = 'single';
|
|
12
|
+
rowKey = 'value';
|
|
13
|
+
displayField = 'label';
|
|
14
|
+
columns = [];
|
|
15
|
+
maxWidth;
|
|
16
|
+
maxHeight;
|
|
17
|
+
isNeedManage = false;
|
|
18
|
+
isUseOptionsChecked = true;
|
|
19
|
+
renderType = 'list';
|
|
20
|
+
tableProps = {};
|
|
21
|
+
useTableProps;
|
|
22
|
+
showRowDeleteButton;
|
|
23
|
+
showSearch;
|
|
24
|
+
value;
|
|
25
|
+
options;
|
|
26
|
+
maxTagCount;
|
|
27
|
+
}
|
|
28
|
+
class FairysTaroPopupSearchBaseInstance extends FairysTaroPopupSearchBaseInstanceMount {
|
|
29
|
+
windowHeight = 0;
|
|
30
|
+
windowWidth = 0;
|
|
31
|
+
popupWidth = 0;
|
|
32
|
+
popupHeight = 0;
|
|
33
|
+
state = proxy({
|
|
34
|
+
mode: 'single',
|
|
35
|
+
columns: [],
|
|
36
|
+
__defaultValue: '',
|
|
37
|
+
visible: false,
|
|
38
|
+
value: void 0,
|
|
39
|
+
dataList: [],
|
|
40
|
+
_tempFilterDataList: [],
|
|
41
|
+
search: '',
|
|
42
|
+
_tempValue: void 0,
|
|
43
|
+
operationStatus: 'select',
|
|
44
|
+
manageSelectedDataList: [],
|
|
45
|
+
allChecked: false
|
|
46
|
+
});
|
|
47
|
+
ctor() {
|
|
48
|
+
const isWeb = taro.getEnv() === taro.ENV_TYPE.WEB;
|
|
49
|
+
if (isWeb) {
|
|
50
|
+
this.windowHeight = window.document.documentElement.clientHeight;
|
|
51
|
+
this.windowWidth = window.document.documentElement.clientWidth;
|
|
52
|
+
} else {
|
|
53
|
+
const windowInfo = taro.getWindowInfo();
|
|
54
|
+
this.windowHeight = windowInfo.windowHeight;
|
|
55
|
+
this.windowWidth = windowInfo.windowWidth;
|
|
56
|
+
}
|
|
57
|
+
this.popupHeight = 0.6 * this.windowHeight;
|
|
58
|
+
if (this.maxHeight) this.popupHeight = Math.min(this.popupHeight, this.maxHeight);
|
|
59
|
+
this.popupWidth = 0.8 * this.windowWidth;
|
|
60
|
+
if (this.maxWidth) this.popupWidth = Math.min(this.popupWidth, this.maxWidth);
|
|
61
|
+
}
|
|
62
|
+
updateState = (state)=>{
|
|
63
|
+
for(const key in state){
|
|
64
|
+
const value = state[key];
|
|
65
|
+
if (Array.isArray(value) || '[object Object]' === Object.prototype.toString.call(value)) this.state[key] = ref(value);
|
|
66
|
+
else this.state[key] = value;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
isUseOptions = ()=>{
|
|
70
|
+
if (Array.isArray(this.options) && !this.onLoadData && !this.isNeedManage) return this.isUseOptionsChecked;
|
|
71
|
+
return false;
|
|
72
|
+
};
|
|
73
|
+
onSearch = async (keyword)=>{
|
|
74
|
+
this.state.search = keyword;
|
|
75
|
+
const _keyword = `${keyword || ''}`.trim();
|
|
76
|
+
try {
|
|
77
|
+
if (this.onLoadData && 'select' === this.state.operationStatus) {
|
|
78
|
+
await new Promise((resolve)=>setTimeout(resolve, 500));
|
|
79
|
+
const search = {
|
|
80
|
+
keyword: _keyword
|
|
81
|
+
};
|
|
82
|
+
const dataList = await this.onLoadData(this.otherRequestParams?.(search, this) || search, this);
|
|
83
|
+
if (Array.isArray(dataList)) this.updateState({
|
|
84
|
+
_tempFilterDataList: dataList || [],
|
|
85
|
+
dataList: dataList || []
|
|
86
|
+
});
|
|
87
|
+
else this.updateState({
|
|
88
|
+
_tempFilterDataList: []
|
|
89
|
+
});
|
|
90
|
+
} else if ('select' === this.state.operationStatus) {
|
|
91
|
+
if (!_keyword) return void this.updateState({
|
|
92
|
+
_tempFilterDataList: this.state.dataList || []
|
|
93
|
+
});
|
|
94
|
+
const filterData = (this.state.dataList || []).filter((item)=>{
|
|
95
|
+
const displayText = item[this.displayField]?.toString() || '';
|
|
96
|
+
const valueText = item[this.rowKey]?.toString() || '';
|
|
97
|
+
return displayText.includes(_keyword) || valueText.includes(_keyword);
|
|
98
|
+
});
|
|
99
|
+
this.updateState({
|
|
100
|
+
_tempFilterDataList: filterData
|
|
101
|
+
});
|
|
102
|
+
} else if ('multiple' === this.mode) {
|
|
103
|
+
const v = this.state._tempValue;
|
|
104
|
+
if (Array.isArray(v)) {
|
|
105
|
+
if (!_keyword) return void this.updateState({
|
|
106
|
+
_tempFilterDataList: v || []
|
|
107
|
+
});
|
|
108
|
+
const filterData = v.filter((item)=>{
|
|
109
|
+
const displayText = item[this.displayField]?.toString() || '';
|
|
110
|
+
const valueText = item[this.rowKey]?.toString() || '';
|
|
111
|
+
return displayText.includes(_keyword) || valueText.includes(_keyword);
|
|
112
|
+
});
|
|
113
|
+
this.updateState({
|
|
114
|
+
_tempFilterDataList: filterData
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error(error);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
onSave = ()=>{
|
|
123
|
+
if ('multiple' === this.mode) {
|
|
124
|
+
const dataList = this.state._tempValue || [];
|
|
125
|
+
this.updateState({
|
|
126
|
+
value: dataList,
|
|
127
|
+
_tempValue: dataList,
|
|
128
|
+
allChecked: false
|
|
129
|
+
});
|
|
130
|
+
this.onChange?.(dataList);
|
|
131
|
+
this.onClose();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
onClear = ()=>{
|
|
135
|
+
this.state.value = void 0;
|
|
136
|
+
this.state._tempValue = void 0;
|
|
137
|
+
this.state.allChecked = false;
|
|
138
|
+
this.onChange?.(void 0);
|
|
139
|
+
};
|
|
140
|
+
isCheckedData = (data)=>{
|
|
141
|
+
if ('multiple' === this.mode) {
|
|
142
|
+
if ('manage' === this.state.operationStatus) return -1 !== (this.state.manageSelectedDataList || []).findIndex((item)=>item[this.rowKey] === data[this.rowKey]);
|
|
143
|
+
if (Array.isArray(this.state._tempValue)) {
|
|
144
|
+
const findx = this.state._tempValue.findIndex((item)=>item[this.rowKey] === data[this.rowKey]);
|
|
145
|
+
return -1 !== findx;
|
|
146
|
+
}
|
|
147
|
+
} else if (this.state._tempValue) return this.state._tempValue?.[this.rowKey] === data?.[this.rowKey];
|
|
148
|
+
return false;
|
|
149
|
+
};
|
|
150
|
+
onCheckedData = (data, checked)=>{
|
|
151
|
+
if ('multiple' === this.mode) {
|
|
152
|
+
if ('manage' === this.state.operationStatus) {
|
|
153
|
+
if (checked) {
|
|
154
|
+
const newList = (this.state.manageSelectedDataList || []).filter((item)=>item[this.rowKey] !== data[this.rowKey]);
|
|
155
|
+
this.updateState({
|
|
156
|
+
manageSelectedDataList: [
|
|
157
|
+
...newList
|
|
158
|
+
]
|
|
159
|
+
});
|
|
160
|
+
} else {
|
|
161
|
+
const newList = [
|
|
162
|
+
...this.state.manageSelectedDataList || []
|
|
163
|
+
].concat([
|
|
164
|
+
data
|
|
165
|
+
]);
|
|
166
|
+
this.updateState({
|
|
167
|
+
manageSelectedDataList: newList
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const _tempValue = this.state._tempValue || [];
|
|
173
|
+
if (Array.isArray(_tempValue)) if (checked) {
|
|
174
|
+
const newList = _tempValue.filter((item)=>item[this.rowKey] !== data[this.rowKey]);
|
|
175
|
+
this.updateState({
|
|
176
|
+
_tempValue: [
|
|
177
|
+
...newList
|
|
178
|
+
]
|
|
179
|
+
});
|
|
180
|
+
} else {
|
|
181
|
+
const findx = _tempValue.find((item)=>item[this.rowKey] === data[this.rowKey]);
|
|
182
|
+
if (!findx) {
|
|
183
|
+
const newList = [
|
|
184
|
+
..._tempValue
|
|
185
|
+
].concat([
|
|
186
|
+
data
|
|
187
|
+
]);
|
|
188
|
+
this.updateState({
|
|
189
|
+
_tempValue: newList
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
this.updateState({
|
|
195
|
+
value: data,
|
|
196
|
+
_tempValue: data
|
|
197
|
+
});
|
|
198
|
+
this.onChange?.(data);
|
|
199
|
+
this.onClose();
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
onAllChecked = ()=>{
|
|
203
|
+
if ('multiple' === this.mode) if (this.state.allChecked) {
|
|
204
|
+
if ('manage' === this.state.operationStatus) {
|
|
205
|
+
const _tempFilterDataList = this.state._tempFilterDataList || [];
|
|
206
|
+
const manageSelectedDataList = this.state.manageSelectedDataList || [];
|
|
207
|
+
const selectedList = manageSelectedDataList.filter((item)=>!_tempFilterDataList.find((dataItem)=>dataItem[this.rowKey] === item[this.rowKey]));
|
|
208
|
+
this.updateState({
|
|
209
|
+
manageSelectedDataList: [
|
|
210
|
+
...selectedList
|
|
211
|
+
],
|
|
212
|
+
allChecked: false
|
|
213
|
+
});
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const _tempValue = this.state._tempValue || [];
|
|
217
|
+
const dataList = this.state.dataList || [];
|
|
218
|
+
const newList = _tempValue.filter((item)=>!dataList.find((dataItem)=>dataItem[this.rowKey] === item[this.rowKey]));
|
|
219
|
+
this.updateState({
|
|
220
|
+
_tempValue: newList,
|
|
221
|
+
allChecked: false
|
|
222
|
+
});
|
|
223
|
+
} else {
|
|
224
|
+
if ('manage' === this.state.operationStatus) {
|
|
225
|
+
console.log(this.state._tempFilterDataList);
|
|
226
|
+
this.updateState({
|
|
227
|
+
manageSelectedDataList: this.state._tempFilterDataList || [],
|
|
228
|
+
allChecked: true
|
|
229
|
+
});
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const _tempValue = this.state._tempValue || [];
|
|
233
|
+
const dataList = this.state.dataList || [];
|
|
234
|
+
const newList = [
|
|
235
|
+
..._tempValue
|
|
236
|
+
].concat(dataList);
|
|
237
|
+
this.updateState({
|
|
238
|
+
_tempValue: newList,
|
|
239
|
+
allChecked: true
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
onClose = ()=>{
|
|
244
|
+
this.updateState({
|
|
245
|
+
visible: false,
|
|
246
|
+
allChecked: false,
|
|
247
|
+
manageSelectedDataList: [],
|
|
248
|
+
search: '',
|
|
249
|
+
_tempValue: this.state.value,
|
|
250
|
+
operationStatus: 'select',
|
|
251
|
+
_tempFilterDataList: this.state.dataList || []
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
updateOperationStatus = ()=>{
|
|
255
|
+
if ('multiple' === this.mode) if ('manage' === this.state.operationStatus) this.updateState({
|
|
256
|
+
operationStatus: 'select',
|
|
257
|
+
manageSelectedDataList: [],
|
|
258
|
+
_tempFilterDataList: this.state.dataList || [],
|
|
259
|
+
allChecked: false,
|
|
260
|
+
search: ''
|
|
261
|
+
});
|
|
262
|
+
else this.updateState({
|
|
263
|
+
operationStatus: 'manage',
|
|
264
|
+
manageSelectedDataList: [],
|
|
265
|
+
_tempFilterDataList: this.state._tempValue || [],
|
|
266
|
+
allChecked: false,
|
|
267
|
+
search: ''
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
onDeleteData = (data)=>{
|
|
271
|
+
if ('multiple' === this.mode) if (data) {
|
|
272
|
+
const _newValue = this.state._tempValue || [];
|
|
273
|
+
const _tempFilterDataList = this.state._tempFilterDataList || [];
|
|
274
|
+
if (Array.isArray(_newValue)) {
|
|
275
|
+
const newList = _newValue.filter((item)=>item[this.rowKey] !== data[this.rowKey]);
|
|
276
|
+
const newFilterList = _tempFilterDataList.filter((item)=>item[this.rowKey] !== data[this.rowKey]);
|
|
277
|
+
this.updateState({
|
|
278
|
+
_tempValue: newList,
|
|
279
|
+
_tempFilterDataList: newFilterList
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
const manageSelectedDataList = this.state.manageSelectedDataList || [];
|
|
284
|
+
const _newValue = this.state._tempValue || [];
|
|
285
|
+
const _tempFilterDataList = this.state._tempFilterDataList || [];
|
|
286
|
+
if (Array.isArray(_newValue)) {
|
|
287
|
+
const newList = _newValue.filter((item)=>!manageSelectedDataList.find((manageItem)=>manageItem[this.rowKey] === item[this.rowKey]));
|
|
288
|
+
const newFilterList = _tempFilterDataList.filter((item)=>!manageSelectedDataList.find((manageItem)=>manageItem[this.rowKey] === item[this.rowKey]));
|
|
289
|
+
this.updateState({
|
|
290
|
+
_tempValue: newList,
|
|
291
|
+
_tempFilterDataList: newFilterList,
|
|
292
|
+
manageSelectedDataList: []
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function useFairysTaroPopupSearchBaseInstance() {
|
|
299
|
+
const instanceRef = useRef(new FairysTaroPopupSearchBaseInstance());
|
|
300
|
+
const state = useSnapshot(instanceRef.current.state);
|
|
301
|
+
const __defaultValue = state.__defaultValue;
|
|
302
|
+
return [
|
|
303
|
+
state,
|
|
304
|
+
instanceRef.current,
|
|
305
|
+
__defaultValue
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
const FairysTaroPopupSearchBaseInstanceContext = createContext(new FairysTaroPopupSearchBaseInstance());
|
|
309
|
+
function useFairysTaroPopupSearchBaseInstanceContext(options) {
|
|
310
|
+
const instance = useContext(FairysTaroPopupSearchBaseInstanceContext);
|
|
311
|
+
const state = useSnapshot(instance.state, options);
|
|
312
|
+
const __defaultValue = state.__defaultValue;
|
|
313
|
+
return [
|
|
314
|
+
state,
|
|
315
|
+
instance,
|
|
316
|
+
__defaultValue
|
|
317
|
+
];
|
|
318
|
+
}
|
|
319
|
+
export { FairysTaroPopupSearchBaseInstance, FairysTaroPopupSearchBaseInstanceContext, FairysTaroPopupSearchBaseInstanceMount, useFairysTaroPopupSearchBaseInstance, useFairysTaroPopupSearchBaseInstanceContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function FairysTaroPopupSearchListTable<T = any>(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Checkbox, Table } from "@nutui/nutui-react-taro";
|
|
3
|
+
import { Del } from "@nutui/icons-react-taro";
|
|
4
|
+
import { useFairysTaroPopupSearchBaseInstanceContext } from "./instance.js";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
function TableItemCheckBox(props) {
|
|
7
|
+
const { rowData } = props;
|
|
8
|
+
const [state, instance] = useFairysTaroPopupSearchBaseInstanceContext();
|
|
9
|
+
const _tempValue = state._tempValue;
|
|
10
|
+
const operationStatus = state.operationStatus;
|
|
11
|
+
const manageSelectedDataList = state.manageSelectedDataList;
|
|
12
|
+
const checked = useMemo(()=>instance.isCheckedData(rowData), [
|
|
13
|
+
rowData,
|
|
14
|
+
_tempValue,
|
|
15
|
+
operationStatus,
|
|
16
|
+
manageSelectedDataList
|
|
17
|
+
]);
|
|
18
|
+
return /*#__PURE__*/ jsx(Checkbox, {
|
|
19
|
+
className: "fairys-taro-popup-search-list-virtual-checkbox fairystaroform__flex-1",
|
|
20
|
+
checked: checked,
|
|
21
|
+
onChange: ()=>instance.onCheckedData(rowData, checked)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function TableItemDelete(props) {
|
|
25
|
+
const { rowData } = props;
|
|
26
|
+
const [, instance] = useFairysTaroPopupSearchBaseInstanceContext();
|
|
27
|
+
return /*#__PURE__*/ jsx(Button, {
|
|
28
|
+
size: "mini",
|
|
29
|
+
fill: "none",
|
|
30
|
+
className: "fairys-taro-popup-search-list-virtual-delete-button",
|
|
31
|
+
onClick: ()=>instance.onDeleteData(rowData),
|
|
32
|
+
icon: /*#__PURE__*/ jsx(Del, {
|
|
33
|
+
color: "red"
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function FairysTaroPopupSearchListTable() {
|
|
38
|
+
const [state, instance] = useFairysTaroPopupSearchBaseInstanceContext();
|
|
39
|
+
const popupHeight = instance.popupHeight;
|
|
40
|
+
const data = state._tempFilterDataList || [];
|
|
41
|
+
const operationStatus = state.operationStatus;
|
|
42
|
+
const columns = state.columns || [];
|
|
43
|
+
const tableProps = instance.useTableProps?.(instance.tableProps || {}, instance) || instance.tableProps || {};
|
|
44
|
+
const showRowDeleteButton = instance.showRowDeleteButton;
|
|
45
|
+
const _newColumns = useMemo(()=>{
|
|
46
|
+
const list = [
|
|
47
|
+
{
|
|
48
|
+
key: '__checkbox',
|
|
49
|
+
width: 16,
|
|
50
|
+
align: 'center',
|
|
51
|
+
title: '',
|
|
52
|
+
render: (rowData)=>/*#__PURE__*/ jsx(TableItemCheckBox, {
|
|
53
|
+
rowData: rowData
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
].concat([
|
|
57
|
+
...columns
|
|
58
|
+
]);
|
|
59
|
+
if ('manage' === operationStatus && 'multiple' === instance.mode && showRowDeleteButton) return [
|
|
60
|
+
...list,
|
|
61
|
+
{
|
|
62
|
+
key: '__delete',
|
|
63
|
+
width: 16,
|
|
64
|
+
align: 'center',
|
|
65
|
+
title: '',
|
|
66
|
+
render: (rowData)=>/*#__PURE__*/ jsx(TableItemDelete, {
|
|
67
|
+
rowData: rowData
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
return list;
|
|
72
|
+
}, [
|
|
73
|
+
columns,
|
|
74
|
+
operationStatus,
|
|
75
|
+
showRowDeleteButton
|
|
76
|
+
]);
|
|
77
|
+
return /*#__PURE__*/ jsx(Table, {
|
|
78
|
+
bordered: true,
|
|
79
|
+
...tableProps,
|
|
80
|
+
className: `fairys-taro-popup-search-list-table ${tableProps?.className || ''}`,
|
|
81
|
+
style: {
|
|
82
|
+
height: popupHeight,
|
|
83
|
+
...tableProps?.style || {}
|
|
84
|
+
},
|
|
85
|
+
columns: _newColumns,
|
|
86
|
+
data: data
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export { FairysTaroPopupSearchListTable };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function FairysTaroPopupSearchListVirtual<T = any>(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Cell, Checkbox, VirtualList } from "@nutui/nutui-react-taro";
|
|
3
|
+
import { Del } from "@nutui/icons-react-taro";
|
|
4
|
+
import { useFairysTaroPopupSearchBaseInstanceContext } from "./instance.js";
|
|
5
|
+
import { Fragment, useMemo } from "react";
|
|
6
|
+
function VirtualListItem(props) {
|
|
7
|
+
const { rowData } = props;
|
|
8
|
+
const [state, instance] = useFairysTaroPopupSearchBaseInstanceContext();
|
|
9
|
+
const renderListItemText = instance.renderListItemText;
|
|
10
|
+
const _tempValue = state._tempValue;
|
|
11
|
+
const operationStatus = state.operationStatus;
|
|
12
|
+
const manageSelectedDataList = state.manageSelectedDataList;
|
|
13
|
+
const showRowDeleteButton = instance.showRowDeleteButton;
|
|
14
|
+
const renderText = useMemo(()=>renderListItemText?.(rowData, instance) || rowData[instance.displayField], [
|
|
15
|
+
rowData,
|
|
16
|
+
instance.displayField,
|
|
17
|
+
renderListItemText
|
|
18
|
+
]);
|
|
19
|
+
const checked = useMemo(()=>instance.isCheckedData(rowData), [
|
|
20
|
+
rowData,
|
|
21
|
+
_tempValue,
|
|
22
|
+
operationStatus,
|
|
23
|
+
manageSelectedDataList
|
|
24
|
+
]);
|
|
25
|
+
return /*#__PURE__*/ jsx(Cell, {
|
|
26
|
+
className: "fairys-taro-popup-search-list-virtual-cell",
|
|
27
|
+
title: /*#__PURE__*/ jsx(Checkbox, {
|
|
28
|
+
className: "fairys-taro-popup-search-list-virtual-checkbox fairystaroform__flex-1",
|
|
29
|
+
checked: checked,
|
|
30
|
+
onChange: ()=>instance.onCheckedData(rowData, checked),
|
|
31
|
+
children: renderText
|
|
32
|
+
}),
|
|
33
|
+
extra: 'manage' === operationStatus && showRowDeleteButton ? /*#__PURE__*/ jsx(Button, {
|
|
34
|
+
size: "mini",
|
|
35
|
+
fill: "none",
|
|
36
|
+
className: "fairys-taro-popup-search-list-virtual-delete-button",
|
|
37
|
+
onClick: ()=>instance.onDeleteData(rowData),
|
|
38
|
+
icon: /*#__PURE__*/ jsx(Del, {
|
|
39
|
+
color: "red"
|
|
40
|
+
})
|
|
41
|
+
}) : /*#__PURE__*/ jsx(Fragment, {})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function FairysTaroPopupSearchListVirtual() {
|
|
45
|
+
const [state, instance] = useFairysTaroPopupSearchBaseInstanceContext();
|
|
46
|
+
const popupHeight = instance.popupHeight;
|
|
47
|
+
const _tempFilterDataList = state._tempFilterDataList;
|
|
48
|
+
return /*#__PURE__*/ jsx(VirtualList, {
|
|
49
|
+
containerHeight: popupHeight,
|
|
50
|
+
itemHeight: 46,
|
|
51
|
+
list: _tempFilterDataList,
|
|
52
|
+
itemRender: (item, dataIndex, index)=>/*#__PURE__*/ jsx(VirtualListItem, {
|
|
53
|
+
rowData: item,
|
|
54
|
+
dataIndex: dataIndex,
|
|
55
|
+
index: index
|
|
56
|
+
}),
|
|
57
|
+
itemEqual: false
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export { FairysTaroPopupSearchListVirtual };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RadioGroupProps, RadioProps } from '@nutui/nutui-react-taro';
|
|
2
|
+
export interface FairysTaroRadioGroupProps extends Partial<RadioGroupProps> {
|
|
3
|
+
items?: RadioProps[];
|
|
4
|
+
}
|
|
5
|
+
export declare const FairysTaroRadioGroupBase: (props: FairysTaroRadioGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Radio, RadioGroup } from "@nutui/nutui-react-taro";
|
|
3
|
+
const FairysTaroRadioGroupBase = (props)=>{
|
|
4
|
+
const { items, className, ...rest } = props;
|
|
5
|
+
return /*#__PURE__*/ jsx(RadioGroup, {
|
|
6
|
+
className: `fairys-taro-radio-group ${className || ''}`,
|
|
7
|
+
...rest,
|
|
8
|
+
children: items?.map((item)=>/*#__PURE__*/ jsx(Radio, {
|
|
9
|
+
...item
|
|
10
|
+
}, item.value))
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
export { FairysTaroRadioGroupBase };
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 简版表单
|
|
3
|
+
* 用于快速创建表单,支持文本输入、选择框、单选框、复选框等常用表单元素。
|
|
4
|
+
* */
|
|
5
|
+
import { useForm } from '@carefrees/form-utils-react-taro';
|
|
6
|
+
import { FairysTaroSimpleFormProps } from './interface';
|
|
7
|
+
import { InputConfigType } from './item.config';
|
|
8
|
+
export * from './components';
|
|
9
|
+
export declare const FairysTaroSimpleForm: {
|
|
10
|
+
(props: FairysTaroSimpleFormProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
Item: (config: InputConfigType) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
ListItem: (props: {
|
|
13
|
+
items: InputConfigType[];
|
|
14
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
useForm: typeof useForm;
|
|
16
|
+
useWatch: (name: string, form?: import("@carefrees/form-utils").FormInstanceBase, callBack?: (value: any, form: import("@carefrees/form-utils").FormInstanceBase) => void) => [any, import("@carefrees/form-utils").FormInstanceBase, import("@carefrees/form-utils-react-taro").WatchInstanceBase];
|
|
17
|
+
};
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Form, useForm, useWatch } from "@carefrees/form-utils-react-taro";
|
|
3
|
+
import { ConfigItem, ConfigListItem } from "./item.config.js";
|
|
4
|
+
export * from "./components/index.js";
|
|
5
|
+
const FairysTaroSimpleForm = (props)=>/*#__PURE__*/ jsx(Form, {
|
|
6
|
+
labelMode: "between",
|
|
7
|
+
colCount: 1,
|
|
8
|
+
inputBordered: false,
|
|
9
|
+
...props
|
|
10
|
+
});
|
|
11
|
+
FairysTaroSimpleForm.Item = ConfigItem;
|
|
12
|
+
FairysTaroSimpleForm.ListItem = ConfigListItem;
|
|
13
|
+
FairysTaroSimpleForm.useForm = useForm;
|
|
14
|
+
FairysTaroSimpleForm.useWatch = useWatch;
|
|
15
|
+
export { FairysTaroSimpleForm };
|
package/esm/interface.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { FormItemProps, FormListProps } from '@carefrees/form-utils-react-taro';
|
|
3
|
+
import { FairysTaroRadioGroupProps } from './components/radio.group';
|
|
4
|
+
import { FairysTaroCalendarProps } from './components/calendar';
|
|
5
|
+
import { FairysTaroCascaderProps } from './components/cascader';
|
|
6
|
+
import { FairysTaroCheckboxGroupProps } from './components/checkbox.group';
|
|
7
|
+
import { FairysTaroDatePickerProps } from './components/date.picker';
|
|
8
|
+
import { FairysTaroPickerProps } from './components/picker';
|
|
9
|
+
import { FairysTaroPopupSearchProps } from './components/popup.search';
|
|
10
|
+
import { TaroInputProps, TaroInputNumberProps, RadioGroupProps, RadioProps, RangeProps, RateProps, SignatureProps, SwitchProps, TextAreaProps, UploaderProps } from '@nutui/nutui-react-taro';
|
|
11
|
+
export interface ItemType<T, K = TaroInputProps> extends FormItemProps {
|
|
12
|
+
/**输入框类型*/
|
|
13
|
+
type?: T;
|
|
14
|
+
/**输入框属性*/
|
|
15
|
+
attr?: K;
|
|
16
|
+
/**自定义渲染函数*/
|
|
17
|
+
render?: undefined;
|
|
18
|
+
/**是否添加隐藏组件*/
|
|
19
|
+
isHide?: boolean;
|
|
20
|
+
/**是否添加置空组件*/
|
|
21
|
+
isEmpty?: boolean;
|
|
22
|
+
}
|
|
23
|
+
type CustomType = {
|
|
24
|
+
isEmpty?: boolean;
|
|
25
|
+
type?: 'custom';
|
|
26
|
+
render?: any;
|
|
27
|
+
isHide?: boolean;
|
|
28
|
+
attr?: any;
|
|
29
|
+
label?: ReactNode | {
|
|
30
|
+
text?: string;
|
|
31
|
+
};
|
|
32
|
+
} & FormItemProps;
|
|
33
|
+
type CustomRenderType = {
|
|
34
|
+
isEmpty?: boolean;
|
|
35
|
+
type?: 'render';
|
|
36
|
+
render?: React.ReactNode;
|
|
37
|
+
isHide?: boolean;
|
|
38
|
+
attr?: any;
|
|
39
|
+
label?: ReactNode | {
|
|
40
|
+
text?: string;
|
|
41
|
+
};
|
|
42
|
+
} & FormItemProps;
|
|
43
|
+
type CustomFormListType = {
|
|
44
|
+
isEmpty?: boolean;
|
|
45
|
+
type?: 'formList';
|
|
46
|
+
isHide?: boolean;
|
|
47
|
+
attr?: any;
|
|
48
|
+
label?: ReactNode | {
|
|
49
|
+
text?: string;
|
|
50
|
+
};
|
|
51
|
+
} & FormListProps;
|
|
52
|
+
export type InputConfigType = ItemType<'input', TaroInputProps> | ItemType<'inputNumber', TaroInputNumberProps> | ItemType<'fairysRadioGroup', FairysTaroRadioGroupProps> | ItemType<'fairysCalendar', FairysTaroCalendarProps> | ItemType<'fairysCascader', FairysTaroCascaderProps> | ItemType<'fairysCheckboxGroup', FairysTaroCheckboxGroupProps> | ItemType<'fairysDatePicker', FairysTaroDatePickerProps> | ItemType<'fairysPicker', FairysTaroPickerProps> | ItemType<'fairysPopupSearch', FairysTaroPopupSearchProps> | ItemType<'radioGroup', RadioGroupProps> | ItemType<'radio', RadioProps> | ItemType<'range', RangeProps> | ItemType<'rate', RateProps> | ItemType<'signature', SignatureProps> | ItemType<'switch', SwitchProps> | ItemType<'textarea', TextAreaProps> | ItemType<'uploader', UploaderProps> | CustomType | CustomRenderType | CustomFormListType;
|
|
53
|
+
export declare const ConfigListItem: (props: {
|
|
54
|
+
items: InputConfigType[];
|
|
55
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export declare const ConfigItem: (config: InputConfigType) => import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
export {};
|