@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.
Files changed (47) hide show
  1. package/README.md +320 -1
  2. package/esm/components/calendar/index.d.ts +10 -0
  3. package/esm/components/calendar/index.js +35 -0
  4. package/esm/components/cascader/index.d.ts +10 -0
  5. package/esm/components/cascader/index.js +85 -0
  6. package/esm/components/checkbox.group/index.d.ts +5 -0
  7. package/esm/components/checkbox.group/index.js +14 -0
  8. package/esm/components/clear/index.d.ts +21 -0
  9. package/esm/components/clear/index.js +31 -0
  10. package/esm/components/date.picker/index.d.ts +18 -0
  11. package/esm/components/date.picker/index.js +122 -0
  12. package/esm/components/index.d.ts +8 -0
  13. package/esm/components/index.js +8 -0
  14. package/esm/components/picker/index.d.ts +9 -0
  15. package/esm/components/picker/index.js +45 -0
  16. package/esm/components/popup.search/base.d.ts +2 -0
  17. package/esm/components/popup.search/base.js +70 -0
  18. package/esm/components/popup.search/index.d.ts +9 -0
  19. package/esm/components/popup.search/index.js +157 -0
  20. package/esm/components/popup.search/instance.d.ts +169 -0
  21. package/esm/components/popup.search/instance.js +319 -0
  22. package/esm/components/popup.search/list.table.d.ts +1 -0
  23. package/esm/components/popup.search/list.table.js +89 -0
  24. package/esm/components/popup.search/list.virtual.d.ts +1 -0
  25. package/esm/components/popup.search/list.virtual.js +60 -0
  26. package/esm/components/radio.group/index.d.ts +5 -0
  27. package/esm/components/radio.group/index.js +13 -0
  28. package/esm/index.d.ts +17 -0
  29. package/esm/index.js +15 -0
  30. package/esm/interface.d.ts +3 -0
  31. package/esm/interface.js +0 -0
  32. package/esm/item.config.d.ts +57 -0
  33. package/esm/item.config.js +125 -0
  34. package/esm/styles/index.css +167 -0
  35. package/lib/index.js +91 -0
  36. package/package.json +2 -2
  37. package/src/components/calendar/index.tsx +10 -11
  38. package/src/components/cascader/index.tsx +9 -11
  39. package/src/components/clear/index.tsx +49 -0
  40. package/src/components/date.picker/index.tsx +11 -11
  41. package/src/components/index.ts +8 -0
  42. package/src/components/picker/index.tsx +9 -11
  43. package/src/components/popup.search/index.tsx +86 -64
  44. package/src/components/popup.search/instance.ts +40 -9
  45. package/src/components/popup.search/list.table.tsx +3 -2
  46. package/src/components/popup.search/list.virtual.tsx +3 -2
  47. package/src/index.tsx +4 -1
@@ -0,0 +1,122 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { View } from "@tarojs/components";
3
+ import { DatePicker } from "@nutui/nutui-react-taro";
4
+ import { useMemo, useState } from "react";
5
+ import { FairysTaroTextClearBase } from "../clear/index.js";
6
+ const getDate = (selectedValue, type)=>{
7
+ if (Array.isArray(selectedValue) && selectedValue.length) {
8
+ const [year, month, day, hour, minute, second] = selectedValue;
9
+ let date = `${year}-${month}-${day} ${hour}:${minute}`;
10
+ if ('date' === type) date = `${year}-${month}-${day}`;
11
+ else if ('time' === type) date = `${hour}:${minute}:${second}`;
12
+ else if ('year-month' === type) date = `${year}-${month}`;
13
+ else if ('month-day' === type) date = `${month}-${day}`;
14
+ else if ('datehour' === type) date = `${year}-${month}-${day} ${hour}`;
15
+ else if ('datetime' === type) date = `${year}-${month}-${day} ${hour}:${minute}`;
16
+ else if ('hour-minutes' === type) date = `${hour}:${minute}`;
17
+ return date;
18
+ }
19
+ };
20
+ const renderDate = (date, type)=>{
21
+ let renderStr;
22
+ let _value;
23
+ const defaultValue = new Date();
24
+ if (date) {
25
+ const isDate = date instanceof Date;
26
+ if ('date' === type) if (isDate) {
27
+ renderStr = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
28
+ _value = date;
29
+ } else {
30
+ const [year, month, day] = date.split(/[-|\s]/);
31
+ renderStr = `${year}-${month}-${day}`;
32
+ _value = new Date(`${year}-${month}-${day}`);
33
+ }
34
+ else if ('time' === type) if (isDate) {
35
+ renderStr = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
36
+ _value = date;
37
+ } else {
38
+ const [hour, minute, second] = date.split(/[:|]/);
39
+ renderStr = `${hour}:${minute}:${second}`;
40
+ _value = new Date(`${defaultValue.getFullYear()}-${defaultValue.getMonth() + 1}-${defaultValue.getDate()} ${hour}:${minute}:${second}`);
41
+ }
42
+ else if ('year-month' === type) if (isDate) {
43
+ renderStr = `${date.getFullYear()}-${date.getMonth() + 1}`;
44
+ _value = date;
45
+ } else {
46
+ const [year, month] = date.split(/[-|\s]/);
47
+ renderStr = `${year}-${month}`;
48
+ _value = new Date(`${year}-${month}-01`);
49
+ }
50
+ else if ('month-day' === type) if (isDate) {
51
+ renderStr = `${date.getMonth() + 1}-${date.getDate()}`;
52
+ _value = date;
53
+ } else {
54
+ const [month, day] = date.split(/[-|\s]/);
55
+ renderStr = `${month}-${day}`;
56
+ _value = new Date(`${defaultValue.getFullYear()}-${month}-${day}`);
57
+ }
58
+ else if ('datehour' === type) if (isDate) {
59
+ renderStr = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}`;
60
+ _value = date;
61
+ } else {
62
+ const [year, month, day, hour] = date.split(/[-|\s|:]/);
63
+ renderStr = `${year}-${month}-${day} ${hour}`;
64
+ _value = new Date(`${year}-${month}-${day} ${hour}:00:00`);
65
+ }
66
+ else if ('datetime' === type) if (isDate) {
67
+ renderStr = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}`;
68
+ _value = date;
69
+ } else {
70
+ const [year, month, day, hour, minute] = date.split(/[-|\s|:]/);
71
+ renderStr = `${year}-${month}-${day} ${hour}:${minute}`;
72
+ _value = new Date(`${year}-${month}-${day} ${hour}:${minute}:00`);
73
+ }
74
+ else if ('hour-minutes' === type) if (isDate) {
75
+ renderStr = `${date.getHours()}:${date.getMinutes()}`;
76
+ _value = date;
77
+ } else {
78
+ const [hour, minute] = date.split(/[:|]/);
79
+ renderStr = `${hour}:${minute}`;
80
+ _value = new Date(`${defaultValue.getFullYear()}-${defaultValue.getMonth() + 1}-${defaultValue.getDate()} ${hour}:${minute}:00`);
81
+ }
82
+ }
83
+ return {
84
+ renderStr,
85
+ _value
86
+ };
87
+ };
88
+ const FairysTaroDatePickerBase = (props)=>{
89
+ const { placeholder = "\u8BF7\u9009\u62E9", value, className, style, onChange, type = 'date', ...rest } = props;
90
+ const [visible, setVisible] = useState(false);
91
+ const render = useMemo(()=>renderDate(value, type), [
92
+ value,
93
+ type
94
+ ]);
95
+ return /*#__PURE__*/ jsxs(View, {
96
+ className: `fairys-taro-date-picker ${className || ''}`,
97
+ style: style,
98
+ children: [
99
+ /*#__PURE__*/ jsx(FairysTaroTextClearBase, {
100
+ warpClassName: "fairys-taro-date-picker-text",
101
+ isValue: !!render.renderStr,
102
+ onTextClick: ()=>setVisible(true),
103
+ onClearClick: ()=>onChange?.(void 0),
104
+ children: render.renderStr || placeholder
105
+ }),
106
+ /*#__PURE__*/ jsx(DatePicker, {
107
+ type: type,
108
+ showChinese: true,
109
+ ...rest,
110
+ value: render._value,
111
+ visible: visible,
112
+ onClose: ()=>setVisible(false),
113
+ onConfirm: (_, selectedValue)=>{
114
+ if (Array.isArray(selectedValue) && selectedValue.length) onChange?.(getDate(selectedValue, type));
115
+ else onChange?.(void 0);
116
+ setVisible(false);
117
+ }
118
+ })
119
+ ]
120
+ });
121
+ };
122
+ export { FairysTaroDatePickerBase };
@@ -0,0 +1,8 @@
1
+ export * from './calendar';
2
+ export * from './cascader';
3
+ export * from './checkbox.group';
4
+ export * from './clear';
5
+ export * from './date.picker';
6
+ export * from './picker';
7
+ export * from './popup.search';
8
+ export * from './radio.group';
@@ -0,0 +1,8 @@
1
+ export * from "./calendar/index.js";
2
+ export * from "./cascader/index.js";
3
+ export * from "./checkbox.group/index.js";
4
+ export * from "./clear/index.js";
5
+ export * from "./date.picker/index.js";
6
+ export * from "./picker/index.js";
7
+ export * from "./popup.search/index.js";
8
+ export * from "./radio.group/index.js";
@@ -0,0 +1,9 @@
1
+ import { TaroPickerProps, PickerOptions } from '@nutui/nutui-react-taro';
2
+ export interface FairysTaroPickerProps extends Omit<Partial<TaroPickerProps>, 'value' | 'onChange'> {
3
+ placeholder?: string;
4
+ value?: PickerOptions;
5
+ onChange?: (value: PickerOptions) => void;
6
+ bodyClassName?: string;
7
+ bodyStyle?: React.CSSProperties;
8
+ }
9
+ export declare const FairysTaroPickerBase: (props: FairysTaroPickerProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,45 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { View } from "@tarojs/components";
3
+ import { Picker } from "@nutui/nutui-react-taro";
4
+ import { useMemo, useState } from "react";
5
+ import { FairysTaroTextClearBase } from "../clear/index.js";
6
+ const FairysTaroPickerBase = (props)=>{
7
+ const { placeholder = "\u8BF7\u9009\u62E9", bodyClassName, bodyStyle, className, style, value, onChange, ...rest } = props;
8
+ const [visible, setVisible] = useState(false);
9
+ const _renderValue = useMemo(()=>{
10
+ if (Array.isArray(value)) return value.map((item)=>item.label).join(' / ');
11
+ }, [
12
+ value
13
+ ]);
14
+ const _value = useMemo(()=>{
15
+ if (Array.isArray(value)) return value.map((item)=>item.value);
16
+ }, [
17
+ value
18
+ ]);
19
+ return /*#__PURE__*/ jsxs(View, {
20
+ className: `fairys-taro-picker ${className || ''}`,
21
+ style: style,
22
+ children: [
23
+ /*#__PURE__*/ jsx(FairysTaroTextClearBase, {
24
+ warpClassName: "fairys-taro-picker-text",
25
+ isValue: !!_renderValue,
26
+ onTextClick: ()=>setVisible(true),
27
+ onClearClick: ()=>onChange?.(void 0),
28
+ children: _renderValue || placeholder
29
+ }),
30
+ /*#__PURE__*/ jsx(Picker, {
31
+ ...rest,
32
+ className: `fairys-taro-picker-body fairystaroform__text-left ${bodyClassName || ''}`,
33
+ style: bodyStyle,
34
+ value: _value,
35
+ visible: visible,
36
+ onClose: ()=>setVisible(false),
37
+ onConfirm: (selectedOptions)=>{
38
+ setVisible(false);
39
+ onChange?.(selectedOptions);
40
+ }
41
+ })
42
+ ]
43
+ });
44
+ };
45
+ export { FairysTaroPickerBase };
@@ -0,0 +1,2 @@
1
+ export declare function FairysTaroPopupSearchFooterBase<T = any>(): import("react/jsx-runtime").JSX.Element;
2
+ export declare function FairysTaroPopupSearchInputBase<T = any>(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,70 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { View } from "@tarojs/components";
3
+ import { Button, Checkbox, Input } from "@nutui/nutui-react-taro";
4
+ import { Fragment } from "react";
5
+ import { useFairysTaroPopupSearchBaseInstanceContext } from "./instance.js";
6
+ import { Del, Search } from "@nutui/icons-react-taro";
7
+ function FairysTaroPopupSearchFooterBase() {
8
+ const [state, instance] = useFairysTaroPopupSearchBaseInstanceContext();
9
+ const operationStatus = state.operationStatus;
10
+ return /*#__PURE__*/ jsxs(View, {
11
+ className: "fairys-taro-popup-search-content-footer fairystaroform__flex fairystaroform__flex-row fairystaroform__items-center fairystaroform__flex-nowrap fairystaroform__py-2 fairystaroform__box-border fairystaroform__px-2",
12
+ children: [
13
+ /*#__PURE__*/ jsxs(View, {
14
+ className: "fairystaroform__flex-1 fairystaroform__flex fairystaroform__flex-row fairystaroform__items-center fairystaroform__flex-nowrap fairystaroform__justify-between",
15
+ children: [
16
+ /*#__PURE__*/ jsx(View, {
17
+ className: "fairystaroform__flex-1",
18
+ children: /*#__PURE__*/ jsx(Checkbox, {
19
+ checked: state.allChecked,
20
+ onChange: instance.onAllChecked,
21
+ label: "\u5168\u9009"
22
+ })
23
+ }),
24
+ 'manage' === operationStatus ? /*#__PURE__*/ jsx(View, {
25
+ className: "fairystaroform__flex-1 fairystaroform__flex fairystaroform__flex-row fairystaroform__items-center fairystaroform__flex-nowrap fairystaroform__justify-end",
26
+ children: /*#__PURE__*/ jsx(Button, {
27
+ icon: /*#__PURE__*/ jsx(Del, {
28
+ color: "#fff"
29
+ }),
30
+ type: "danger",
31
+ onClick: ()=>instance.onDeleteData(),
32
+ children: "\u5220\u9664"
33
+ })
34
+ }) : /*#__PURE__*/ jsx(Fragment, {})
35
+ ]
36
+ }),
37
+ 'select' === operationStatus ? /*#__PURE__*/ jsx(View, {
38
+ className: "fairystaroform__flex-1",
39
+ children: /*#__PURE__*/ jsx(Button, {
40
+ onClick: instance.onSave,
41
+ block: true,
42
+ type: "primary",
43
+ children: "\u786E\u5B9A"
44
+ })
45
+ }) : /*#__PURE__*/ jsx(Fragment, {})
46
+ ]
47
+ });
48
+ }
49
+ function FairysTaroPopupSearchInputBase() {
50
+ const [state, instance] = useFairysTaroPopupSearchBaseInstanceContext({
51
+ sync: true
52
+ });
53
+ const search = state.search || '';
54
+ return /*#__PURE__*/ jsxs(View, {
55
+ className: "fairys-taro-popup-search-content-header fairystaroform__flex fairystaroform__flex-row fairystaroform__items-center fairystaroform__flex-nowrap fairystaroform__px-1 fairystaroform__box-border fairystaroform__pr-4 fairystaroform__border-b-1 fairystaroform__border-b-solid fairystaroform__border-b-gray-200",
56
+ children: [
57
+ /*#__PURE__*/ jsx(Input, {
58
+ placeholder: "\u8BF7\u8F93\u5165",
59
+ value: search,
60
+ onChange: instance.onSearch
61
+ }),
62
+ /*#__PURE__*/ jsx(View, {
63
+ children: /*#__PURE__*/ jsx(Search, {
64
+ className: "fairys-taro-popup-search-content-header-search fairystaroform__text-gray-600 fairystaroform__cursor-pointer"
65
+ })
66
+ })
67
+ ]
68
+ });
69
+ }
70
+ export { FairysTaroPopupSearchFooterBase, FairysTaroPopupSearchInputBase };
@@ -0,0 +1,9 @@
1
+ import { TaroPopupProps } from '@nutui/nutui-react-taro';
2
+ import type { FairysTaroPopupSearchBaseInstanceMount } from './instance';
3
+ /**
4
+ * 如果是多选,怎么移除某几个选中项
5
+ * */
6
+ export interface FairysTaroPopupSearchProps<T = any> extends Partial<TaroPopupProps>, FairysTaroPopupSearchBaseInstanceMount<T> {
7
+ placeholder?: string;
8
+ }
9
+ export declare function FairysTaroPopupSearchBase<T = any>(props: FairysTaroPopupSearchProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,157 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Text, View } from "@tarojs/components";
3
+ import { Popup } from "@nutui/nutui-react-taro";
4
+ import { Fragment, useEffect, useMemo } from "react";
5
+ import { FairysTaroPopupSearchBaseInstanceContext, useFairysTaroPopupSearchBaseInstance, useFairysTaroPopupSearchBaseInstanceContext } from "./instance.js";
6
+ import { FairysTaroPopupSearchFooterBase, FairysTaroPopupSearchInputBase } from "./base.js";
7
+ import { FairysTaroPopupSearchListVirtual } from "./list.virtual.js";
8
+ import { FairysTaroPopupSearchListTable } from "./list.table.js";
9
+ import { FairysTaroTextClearBase } from "../clear/index.js";
10
+ function RenderList() {
11
+ const [state, instance] = useFairysTaroPopupSearchBaseInstanceContext();
12
+ const renderList = instance.renderList;
13
+ const _tempFilterDataList = state._tempFilterDataList;
14
+ const operationStatus = state.operationStatus;
15
+ return renderList?.(_tempFilterDataList || [], operationStatus, instance) || /*#__PURE__*/ jsx(Fragment, {});
16
+ }
17
+ function FairysTaroPopupSearchBodyBase() {
18
+ const [state, instance] = useFairysTaroPopupSearchBaseInstanceContext();
19
+ const renderType = instance.renderType;
20
+ const showSearch = instance.showSearch;
21
+ const mode = instance.mode;
22
+ const columns = instance.columns;
23
+ const options = instance.options;
24
+ const isNeedManage = instance.isNeedManage;
25
+ const value = instance.value;
26
+ const visible = state.visible;
27
+ useMemo(()=>{
28
+ if (isNeedManage || instance.isUseOptions()) instance.updateState({
29
+ value,
30
+ _tempValue: value
31
+ });
32
+ else instance.updateState({
33
+ value,
34
+ _tempValue: void 0
35
+ });
36
+ }, [
37
+ value,
38
+ isNeedManage,
39
+ visible
40
+ ]);
41
+ useMemo(()=>instance.updateState({
42
+ dataList: options || [],
43
+ _tempFilterDataList: options || []
44
+ }), [
45
+ options
46
+ ]);
47
+ useMemo(()=>instance.updateState({
48
+ mode
49
+ }), [
50
+ mode
51
+ ]);
52
+ useMemo(()=>instance.updateState({
53
+ columns
54
+ }), [
55
+ columns
56
+ ]);
57
+ useEffect(()=>{
58
+ if (visible && 'function' == typeof instance.onLoadData) instance.onSearch('');
59
+ }, [
60
+ visible
61
+ ]);
62
+ return /*#__PURE__*/ jsxs(View, {
63
+ className: "fairys-taro-popup-search-content-inner fairystaroform__flex fairystaroform__flex-1 fairystaroform__flex-col fairystaroform__overflow-hidden",
64
+ children: [
65
+ showSearch ? /*#__PURE__*/ jsx(FairysTaroPopupSearchInputBase, {}) : /*#__PURE__*/ jsx(Fragment, {}),
66
+ /*#__PURE__*/ jsx(View, {
67
+ style: {
68
+ flex: 1,
69
+ overflow: 'hidden'
70
+ },
71
+ children: 'list' === renderType ? /*#__PURE__*/ jsx(FairysTaroPopupSearchListVirtual, {}) : 'table' === renderType ? /*#__PURE__*/ jsx(FairysTaroPopupSearchListTable, {}) : 'custom' === renderType ? /*#__PURE__*/ jsx(RenderList, {}) : /*#__PURE__*/ jsx(Fragment, {})
72
+ }),
73
+ 'multiple' === mode ? /*#__PURE__*/ jsx(FairysTaroPopupSearchFooterBase, {}) : /*#__PURE__*/ jsx(Fragment, {})
74
+ ]
75
+ });
76
+ }
77
+ function FairysTaroPopupSearchBase(props) {
78
+ const { placeholder = "\u8BF7\u9009\u62E9", className, style, value, onChange, onLoadData, otherRequestParams, maxWidth, maxHeight, renderText, renderListItemText, showRowDeleteButton = true, showSearch = true, renderList, options, columns, mode = 'single', rowKey = 'value', displayField = 'label', renderType = 'list', maxTagCount = 9, tableProps = {}, useTableProps, isNeedManage = false, isUseOptionsChecked = true, ...rest } = props;
79
+ const [state, instance] = useFairysTaroPopupSearchBaseInstance();
80
+ instance.maxWidth = maxWidth;
81
+ instance.maxHeight = maxHeight;
82
+ instance.renderText = renderText;
83
+ instance.renderList = renderList;
84
+ instance.onLoadData = onLoadData;
85
+ instance.otherRequestParams = otherRequestParams;
86
+ instance.onChange = onChange;
87
+ instance.renderListItemText = renderListItemText;
88
+ instance.tableProps = tableProps;
89
+ instance.useTableProps = useTableProps;
90
+ instance.isNeedManage = isNeedManage;
91
+ instance.isUseOptionsChecked = isUseOptionsChecked;
92
+ instance.rowKey = rowKey;
93
+ instance.displayField = displayField;
94
+ instance.mode = mode;
95
+ instance.columns = columns;
96
+ instance.renderType = renderType;
97
+ instance.showRowDeleteButton = showRowDeleteButton;
98
+ instance.showSearch = showSearch;
99
+ instance.maxTagCount = maxTagCount;
100
+ instance.options = options;
101
+ instance.value = value;
102
+ const operationStatus = state.operationStatus;
103
+ const visible = state.visible;
104
+ useMemo(()=>instance.ctor(), [
105
+ maxWidth,
106
+ maxHeight
107
+ ]);
108
+ const renderTextValue = useMemo(()=>{
109
+ if (instance.renderText) return instance.renderText(value, instance);
110
+ if ('multiple' === instance.mode) {
111
+ if (Array.isArray(value)) {
112
+ if (value.length > maxTagCount) return `${value.slice(0, maxTagCount).map((item)=>item[instance.displayField]).join(',')}...`;
113
+ return value.map((item)=>item[instance.displayField]).join(',');
114
+ }
115
+ return '';
116
+ }
117
+ return value?.[instance.displayField];
118
+ }, [
119
+ value,
120
+ mode,
121
+ maxTagCount
122
+ ]);
123
+ return /*#__PURE__*/ jsxs(View, {
124
+ className: `fairys-taro-popup-search ${className || ''}`,
125
+ style: style,
126
+ children: [
127
+ /*#__PURE__*/ jsx(FairysTaroTextClearBase, {
128
+ warpClassName: "fairys-taro-popup-search-text-container",
129
+ isValue: !!renderTextValue,
130
+ onTextClick: ()=>instance.updateState({
131
+ visible: true
132
+ }),
133
+ onClearClick: ()=>onChange?.(void 0),
134
+ children: renderTextValue || placeholder
135
+ }),
136
+ /*#__PURE__*/ jsx(Popup, {
137
+ lockScroll: true,
138
+ position: "bottom",
139
+ closeable: true,
140
+ ...rest,
141
+ left: 'multiple' === mode && isNeedManage ? /*#__PURE__*/ jsx(Text, {
142
+ onClick: instance.updateOperationStatus,
143
+ children: 'select' == operationStatus ? "\u7BA1\u7406" : "\u5B8C\u6210"
144
+ }) : /*#__PURE__*/ jsx(Fragment, {}),
145
+ visible: visible,
146
+ onClose: instance.onClose,
147
+ overlayClassName: "fairys-taro-popup-search-overlay",
148
+ className: "fairys-taro-popup-search-content fairystaroform__flex fairystaroform__flex-col fairystaroform__overflow-hidden",
149
+ children: /*#__PURE__*/ jsx(FairysTaroPopupSearchBaseInstanceContext.Provider, {
150
+ value: instance,
151
+ children: visible ? /*#__PURE__*/ jsx(FairysTaroPopupSearchBodyBase, {}) : /*#__PURE__*/ jsx(Fragment, {})
152
+ })
153
+ })
154
+ ]
155
+ });
156
+ }
157
+ export { FairysTaroPopupSearchBase };
@@ -0,0 +1,169 @@
1
+ import { TableColumnProps, TaroTableProps } from '@nutui/nutui-react-taro';
2
+ export declare class FairysTaroPopupSearchBaseInstanceMount<T = any> {
3
+ /**选中项改变时触发*/
4
+ onChange?: (value: T[] | T | undefined) => void;
5
+ onLoadData?: (params: any, instance: FairysTaroPopupSearchBaseInstanceMount<T>) => Promise<T[]>;
6
+ /**其他请求参数*/
7
+ otherRequestParams?: (params: any, instance: FairysTaroPopupSearchBaseInstanceMount<T>) => any;
8
+ /**自定义输入框显示文本*/
9
+ renderText?: (data: T | T[], instance: FairysTaroPopupSearchBaseInstanceMount<T>) => React.ReactNode;
10
+ /**自定义渲染列表项文本*/
11
+ renderListItemText?: (data: T, instance: FairysTaroPopupSearchBaseInstanceMount<T>) => React.ReactNode;
12
+ /**自定义渲染列表数据*/
13
+ renderList?: (dataList: T[], type: 'select' | 'manage', instance: FairysTaroPopupSearchBaseInstanceMount<T>) => React.ReactNode;
14
+ /**选择模式*/
15
+ mode?: 'multiple' | 'single';
16
+ /**列表项的唯一键值*/
17
+ rowKey?: string;
18
+ /**提示框 显示字段*/
19
+ displayField?: string;
20
+ /**列表列配置*/
21
+ columns?: TableColumnProps[];
22
+ /**最大弹窗宽度*/
23
+ maxWidth?: number;
24
+ /**最大弹窗高度*/
25
+ maxHeight?: number;
26
+ /**是否需要管理已选择的数据*/
27
+ isNeedManage?: boolean;
28
+ /**是否选中状态,在使用 options 参数渲染固定列数据的时候是否需要选中状态*/
29
+ isUseOptionsChecked?: boolean;
30
+ /**
31
+ * 渲染类型
32
+ * @default 'list'
33
+ * */
34
+ renderType?: 'list' | 'table' | 'custom';
35
+ /**表格属性*/
36
+ tableProps?: Partial<TaroTableProps>;
37
+ /**自定义表格属性*/
38
+ useTableProps?: (tableProps: Partial<TaroTableProps>, instance: FairysTaroPopupSearchBaseInstanceMount<T>) => Partial<TaroTableProps>;
39
+ /**是否显示删除按钮*/
40
+ showRowDeleteButton?: boolean;
41
+ /**是否显示搜索框*/
42
+ showSearch?: boolean;
43
+ /**选中项*/
44
+ value?: T | T[];
45
+ /**选择数据*/
46
+ options?: ({
47
+ label?: string;
48
+ value?: string | number;
49
+ [x: string]: any;
50
+ } & T)[];
51
+ /**
52
+ * 最大渲染个数数量
53
+ */
54
+ maxTagCount?: number;
55
+ }
56
+ export interface FairysTaroPopupSearchBaseInstanceState<T = any> {
57
+ /**无用默认值*/
58
+ __defaultValue: string;
59
+ visible: boolean;
60
+ /**选中项*/
61
+ value: T | T[] | undefined;
62
+ dataList: T[];
63
+ /**
64
+ * 临时过滤数据列表
65
+ * 使用 options 参数并且在 operationStatus = select 时使用,根据主键字段值和显示字段值进行过滤
66
+ * 在 operationStatus = manage 时,过滤 _tempValue 中的值,根据主键字段值和显示字段值进行过滤
67
+ */
68
+ _tempFilterDataList: T[];
69
+ search?: string;
70
+ /**
71
+ * 临时值(多选时使用),用于临时存在,点击保存后赋值给 value
72
+ */
73
+ _tempValue: T | T[] | undefined;
74
+ /**操作状态
75
+ * @default 'select'
76
+ */
77
+ operationStatus: 'manage' | 'select';
78
+ /**选中列表数据*/
79
+ manageSelectedDataList: T[];
80
+ /**全选按钮是否选中状态*/
81
+ allChecked: boolean;
82
+ /**选择模式
83
+ * @default 'single'
84
+ */
85
+ mode?: 'multiple' | 'single';
86
+ /**列表列配置*/
87
+ columns?: TableColumnProps[];
88
+ }
89
+ export declare class FairysTaroPopupSearchBaseInstance<T = any> extends FairysTaroPopupSearchBaseInstanceMount<T> {
90
+ /**窗口高度*/
91
+ windowHeight: number;
92
+ /**窗口宽度*/
93
+ windowWidth: number;
94
+ /**弹窗宽度*/
95
+ popupWidth: number;
96
+ /**弹窗高度*/
97
+ popupHeight: number;
98
+ state: FairysTaroPopupSearchBaseInstanceState<T>;
99
+ ctor(): void;
100
+ /**更新状态*/
101
+ updateState: (state: Partial<typeof this.state>) => void;
102
+ /**判断是否使用 options 参数,并且不是管理模式*/
103
+ isUseOptions: () => boolean;
104
+ /**搜索*/
105
+ onSearch: (keyword: string) => Promise<void>;
106
+ /**保存数据*/
107
+ onSave: () => void;
108
+ /**清空数据*/
109
+ onClear: () => void;
110
+ /**是否选中数据*/
111
+ isCheckedData: (data: T) => boolean;
112
+ /**单个选中数据*/
113
+ onCheckedData: (data: T, checked: boolean) => void;
114
+ /**全选按钮*/
115
+ onAllChecked: () => void;
116
+ /**关闭弹窗*/
117
+ onClose: () => void;
118
+ /**更新操作状态*/
119
+ updateOperationStatus: () => void;
120
+ /**删除选中数据*/
121
+ onDeleteData: (data?: T) => void;
122
+ }
123
+ export declare function useFairysTaroPopupSearchBaseInstance<T = any>(): readonly [{
124
+ readonly __defaultValue: string;
125
+ readonly visible: boolean;
126
+ readonly value: import("valtio").Snapshot<T> | readonly import("valtio").Snapshot<T>[];
127
+ readonly dataList: readonly import("valtio").Snapshot<T>[];
128
+ readonly _tempFilterDataList: readonly import("valtio").Snapshot<T>[];
129
+ readonly search?: string;
130
+ readonly _tempValue: import("valtio").Snapshot<T> | readonly import("valtio").Snapshot<T>[];
131
+ readonly operationStatus: "manage" | "select";
132
+ readonly manageSelectedDataList: readonly import("valtio").Snapshot<T>[];
133
+ readonly allChecked: boolean;
134
+ readonly mode?: "multiple" | "single";
135
+ readonly columns?: readonly {
136
+ readonly key: string;
137
+ readonly title?: string;
138
+ readonly align?: string;
139
+ readonly sorter?: ((a: any, b: any) => number) | boolean | string;
140
+ readonly render?: (rowData: any, rowIndex: number) => string | import("react").ReactNode;
141
+ readonly fixed?: import("@nutui/nutui-react-taro").PositionX;
142
+ readonly width?: number;
143
+ }[];
144
+ }, FairysTaroPopupSearchBaseInstance<T>, string];
145
+ export declare const FairysTaroPopupSearchBaseInstanceContext: import("react").Context<FairysTaroPopupSearchBaseInstance<any>>;
146
+ export declare function useFairysTaroPopupSearchBaseInstanceContext<T = any>(options?: {
147
+ sync?: boolean;
148
+ }): readonly [{
149
+ readonly __defaultValue: string;
150
+ readonly visible: boolean;
151
+ readonly value: import("valtio").Snapshot<T> | readonly import("valtio").Snapshot<T>[];
152
+ readonly dataList: readonly import("valtio").Snapshot<T>[];
153
+ readonly _tempFilterDataList: readonly import("valtio").Snapshot<T>[];
154
+ readonly search?: string;
155
+ readonly _tempValue: import("valtio").Snapshot<T> | readonly import("valtio").Snapshot<T>[];
156
+ readonly operationStatus: "manage" | "select";
157
+ readonly manageSelectedDataList: readonly import("valtio").Snapshot<T>[];
158
+ readonly allChecked: boolean;
159
+ readonly mode?: "multiple" | "single";
160
+ readonly columns?: readonly {
161
+ readonly key: string;
162
+ readonly title?: string;
163
+ readonly align?: string;
164
+ readonly sorter?: ((a: any, b: any) => number) | boolean | string;
165
+ readonly render?: (rowData: any, rowIndex: number) => string | import("react").ReactNode;
166
+ readonly fixed?: import("@nutui/nutui-react-taro").PositionX;
167
+ readonly width?: number;
168
+ }[];
169
+ }, FairysTaroPopupSearchBaseInstance<T>, string];