@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
package/README.md CHANGED
@@ -1 +1,320 @@
1
- # 框架 ui 组件库
1
+ # 快捷表单
2
+
3
+ **引入**
4
+
5
+ ```ts
6
+ import { FairysTaroSimpleForm } from '@fairys/taro-tools-simple-form';
7
+ ```
8
+
9
+ ## 组件参数
10
+
11
+ ```ts
12
+ import { ReactNode } from 'react';
13
+ import type { FormItemProps, FormListProps } from '@carefrees/form-utils-react-taro';
14
+ import { FairysTaroRadioGroupProps } from './components/radio.group';
15
+ import { FairysTaroCalendarProps } from './components/calendar';
16
+ import { FairysTaroCascaderProps } from './components/cascader';
17
+ import { FairysTaroCheckboxGroupProps } from './components/checkbox.group';
18
+ import { FairysTaroDatePickerProps } from './components/date.picker';
19
+ import { FairysTaroPickerProps } from './components/picker';
20
+ import { FairysTaroPopupSearchProps } from './components/popup.search';
21
+ import { TaroInputProps, TaroInputNumberProps, RadioGroupProps, RadioProps, RangeProps, RateProps, SignatureProps, SwitchProps, TextAreaProps, UploaderProps } from '@nutui/nutui-react-taro';
22
+ export interface ItemType<T, K = TaroInputProps> extends FormItemProps {
23
+ /**输入框类型*/
24
+ type?: T;
25
+ /**输入框属性*/
26
+ attr?: K;
27
+ /**自定义渲染函数*/
28
+ render?: undefined;
29
+ /**是否添加隐藏组件*/
30
+ isHide?: boolean;
31
+ /**是否添加置空组件*/
32
+ isEmpty?: boolean;
33
+ }
34
+ type CustomType = {
35
+ isEmpty?: boolean;
36
+ type?: 'custom';
37
+ render?: any;
38
+ isHide?: boolean;
39
+ attr?: any;
40
+ label?: ReactNode | {
41
+ text?: string;
42
+ };
43
+ } & FormItemProps;
44
+ type CustomRenderType = {
45
+ isEmpty?: boolean;
46
+ type?: 'render';
47
+ render?: React.ReactNode;
48
+ isHide?: boolean;
49
+ attr?: any;
50
+ label?: ReactNode | {
51
+ text?: string;
52
+ };
53
+ } & FormItemProps;
54
+ type CustomFormListType = {
55
+ isEmpty?: boolean;
56
+ type?: 'formList';
57
+ isHide?: boolean;
58
+ attr?: any;
59
+ label?: ReactNode | {
60
+ text?: string;
61
+ };
62
+ } & FormListProps;
63
+ 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;
64
+ export declare const ConfigListItem: (props: {
65
+ items: InputConfigType[];
66
+ }) => import("react/jsx-runtime").JSX.Element;
67
+ export declare const ConfigItem: (config: InputConfigType) => import("react/jsx-runtime").JSX.Element;
68
+ /**
69
+ * 简版表单
70
+ * 用于快速创建表单,支持文本输入、选择框、单选框、复选框等常用表单元素。
71
+ * */
72
+ import { useForm } from '@carefrees/form-utils-react-taro';
73
+ import { FormProps } from '@carefrees/form-utils-react-taro';
74
+ export interface FairysTaroSimpleFormProps extends FormProps {
75
+ }
76
+ export declare const FairysTaroSimpleForm: {
77
+ (props: FairysTaroSimpleFormProps): import("react/jsx-runtime").JSX.Element;
78
+ Item: (config: InputConfigType) => import("react/jsx-runtime").JSX.Element;
79
+ ListItem: (props: {
80
+ items: InputConfigType[];
81
+ }) => import("react/jsx-runtime").JSX.Element;
82
+ useForm: typeof useForm;
83
+ 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];
84
+ };
85
+
86
+ ```
87
+
88
+ 其他请参考[@carefrees/form-utils-react-taro](https://sunlxy.github.io/carefrees-form-utils/react/taro.html)
89
+
90
+ ## 案例
91
+
92
+ ```tsx
93
+ import { View, Text } from '@tarojs/components';
94
+ import {
95
+ connectToastMessage,
96
+ FairysTaroMainPage,
97
+ FairysTaroMainPageSearch,
98
+ FairysTaroMainPageBody,
99
+ FairysTaroMainPageFooter,
100
+ globalDataInstance,
101
+ } from '@fairys/taro-tools-react';
102
+ import { Button } from '@nutui/nutui-react-taro';
103
+ import { FairysTaroSimpleForm } from '@fairys/taro-tools-simple-form';
104
+
105
+ function Index() {
106
+ const form = FairysTaroSimpleForm.useForm();
107
+
108
+ const onSubmit = () => {
109
+ form
110
+ .validate()
111
+ .then((values) => {
112
+ console.log(values);
113
+ globalDataInstance.showMessage({
114
+ type: 'success',
115
+ content: '表单成功',
116
+ });
117
+ })
118
+ .catch((error) => {
119
+ globalDataInstance.showMessage({
120
+ type: 'error',
121
+ content: error.message || '表单校验失败',
122
+ });
123
+ });
124
+ };
125
+
126
+ return (
127
+ <FairysTaroMainPage>
128
+ <FairysTaroMainPageSearch>
129
+ <FairysTaroSimpleForm form={form}>
130
+ <FairysTaroSimpleForm.Item label="用户名" name="username" type="fairysCalendar" />
131
+ <FairysTaroSimpleForm.Item
132
+ label="级联选择器"
133
+ name="cascader"
134
+ type="fairysCascader"
135
+ rules={[{ required: true, message: '请选择级联选择器' }]}
136
+ attr={{
137
+ options: [
138
+ { value: 'A0', text: 'A0_1' },
139
+ {
140
+ value: 'B0',
141
+ text: 'B0_1',
142
+ children: [
143
+ { value: 'B11', text: 'B11_1', leaf: true },
144
+ { value: 'B12', text: 'B12_1' },
145
+ ],
146
+ },
147
+ { value: 'C0', text: 'C0_1' },
148
+ ],
149
+ }}
150
+ />
151
+ <FairysTaroSimpleForm.Item
152
+ label="复选框组"
153
+ name="checkboxGroup"
154
+ type="fairysCheckboxGroup"
155
+ rules={[{ required: true, message: '请选择复选框组' }]}
156
+ attr={{
157
+ items: [
158
+ { value: 'A0', label: 'A0_1' },
159
+ { value: 'B0', label: 'B0_1' },
160
+ { value: 'C0', label: 'C0_1' },
161
+ ],
162
+ }}
163
+ />
164
+ <FairysTaroSimpleForm.Item
165
+ label="日期选择器"
166
+ name="datePicker"
167
+ type="fairysDatePicker"
168
+ rules={[{ required: true, message: '请选择日期选择器' }]}
169
+ attr={{
170
+ type: 'datetime',
171
+ }}
172
+ />
173
+ <FairysTaroSimpleForm.Item
174
+ label="选择器"
175
+ name="picker"
176
+ type="fairysPicker"
177
+ attr={{
178
+ options: [
179
+ // 第一列
180
+ [
181
+ { label: '周一', value: 'Monday' },
182
+ { label: '周二', value: 'Tuesday' },
183
+ { label: '周三', value: 'Wednesday' },
184
+ { label: '周四', value: 'Thursday' },
185
+ { label: '周五', value: 'Friday' },
186
+ ],
187
+ // 第二列
188
+ [
189
+ { label: '上午', value: 'Morning' },
190
+ { label: '下午', value: 'Afternoon' },
191
+ { label: '晚上', value: 'Evening' },
192
+ ],
193
+ ],
194
+ }}
195
+ />
196
+ <FairysTaroSimpleForm.Item
197
+ label="搜索选择器"
198
+ name="popupSearch"
199
+ type="fairysPopupSearch"
200
+ attr={{
201
+ placeholder: '请选择',
202
+ mode: 'single',
203
+ options: [
204
+ { value: 'A0', label: 'A0_1' },
205
+ { value: 'B0', label: 'B0_1' },
206
+ { value: 'C0', label: 'C0_1' },
207
+ { value: 'D0', label: 'D0_1' },
208
+ { value: 'E0', label: 'E0_1' },
209
+ { value: 'F0', label: 'F0_1' },
210
+ { value: 'G0', label: 'G0_1' },
211
+ { value: 'H0', label: 'H0_1' },
212
+ { value: 'I0', label: 'I0_1' },
213
+ { value: 'J0', label: 'J0_1' },
214
+ { value: 'K0', label: 'K0_1' },
215
+ { value: 'L0', label: 'L0_1' },
216
+ { value: 'M0', label: 'M0_1' },
217
+ ],
218
+ }}
219
+ />
220
+ <FairysTaroSimpleForm.Item
221
+ label="搜索选择器(表格)"
222
+ name="popupSearch-table"
223
+ type="fairysPopupSearch"
224
+ attr={{
225
+ placeholder: '请选择',
226
+ mode: 'single',
227
+ renderType: 'table',
228
+ columns: [
229
+ { title: '选项值', key: 'value' },
230
+ { title: '选项标签', key: 'label' },
231
+ ],
232
+ options: [
233
+ { value: 'A0', label: 'A0_1' },
234
+ { value: 'B0', label: 'B0_1' },
235
+ { value: 'C0', label: 'C0_1' },
236
+ { value: 'D0', label: 'D0_1' },
237
+ { value: 'E0', label: 'E0_1' },
238
+ { value: 'F0', label: 'F0_1' },
239
+ { value: 'G0', label: 'G0_1' },
240
+ { value: 'H0', label: 'H0_1' },
241
+ { value: 'I0', label: 'I0_1' },
242
+ { value: 'J0', label: 'J0_1' },
243
+ { value: 'K0', label: 'K0_1' },
244
+ { value: 'L0', label: 'L0_1' },
245
+ { value: 'M0', label: 'M0_1' },
246
+ ],
247
+ }}
248
+ />
249
+
250
+ <FairysTaroSimpleForm.Item
251
+ label="多选搜索选择器"
252
+ name="m-popupSearch"
253
+ type="fairysPopupSearch"
254
+ attr={{
255
+ placeholder: '请选择',
256
+ mode: 'multiple',
257
+ options: [
258
+ { value: 'A0', label: 'A0_1' },
259
+ { value: 'B0', label: 'B0_1' },
260
+ { value: 'C0', label: 'C0_1' },
261
+ { value: 'D0', label: 'D0_1' },
262
+ { value: 'E0', label: 'E0_1' },
263
+ { value: 'F0', label: 'F0_1' },
264
+ { value: 'G0', label: 'G0_1' },
265
+ { value: 'H0', label: 'H0_1' },
266
+ { value: 'I0', label: 'I0_1' },
267
+ { value: 'J0', label: 'J0_1' },
268
+ { value: 'K0', label: 'K0_1' },
269
+ { value: 'L0', label: 'L0_1' },
270
+ { value: 'M0', label: 'M0_1' },
271
+ ],
272
+ }}
273
+ />
274
+ <FairysTaroSimpleForm.Item
275
+ label="多选搜索选择器(表格)"
276
+ name="m-popupSearch-table"
277
+ type="fairysPopupSearch"
278
+ attr={{
279
+ placeholder: '请选择',
280
+ mode: 'multiple',
281
+ renderType: 'table',
282
+ isNeedManage: true,
283
+ columns: [
284
+ { title: '选项值', key: 'value' },
285
+ { title: '选项标签', key: 'label' },
286
+ ],
287
+ options: [
288
+ { value: 'A0', label: 'A0_1' },
289
+ { value: 'B0', label: 'B0_1' },
290
+ { value: 'C0', label: 'C0_1' },
291
+ { value: 'D0', label: 'D0_1' },
292
+ { value: 'E0', label: 'E0_1' },
293
+ { value: 'F0', label: 'F0_1' },
294
+ { value: 'G0', label: 'G0_1' },
295
+ { value: 'H0', label: 'H0_1' },
296
+ { value: 'I0', label: 'I0_1' },
297
+ { value: 'J0', label: 'J0_1' },
298
+ { value: 'K0', label: 'K0_1' },
299
+ { value: 'L0', label: 'L0_1' },
300
+ { value: 'M0', label: 'M0_1' },
301
+ ],
302
+ }}
303
+ />
304
+ </FairysTaroSimpleForm>
305
+ </FairysTaroMainPageSearch>
306
+ <FairysTaroMainPageBody>
307
+
308
+ </FairysTaroMainPageBody>
309
+ <FairysTaroMainPageFooter
310
+ style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', padding: '0.3rem 0.5rem' }}
311
+ >
312
+ <Button block type="primary" onClick={onSubmit}>
313
+ 提交
314
+ </Button>
315
+ </FairysTaroMainPageFooter>
316
+ </FairysTaroMainPage>
317
+ );
318
+ }
319
+ export default connectToastMessage(Index);
320
+ ```
@@ -0,0 +1,10 @@
1
+ import { ViewProps } from '@tarojs/components';
2
+ import { CalendarProps } from '@nutui/nutui-react-taro';
3
+ export interface FairysTaroCalendarProps extends Partial<CalendarProps> {
4
+ placeholder?: string;
5
+ value?: string;
6
+ className?: string;
7
+ style?: ViewProps['style'];
8
+ onChange?: (value: string, date: string | string[]) => void;
9
+ }
10
+ export declare const FairysTaroCalendarBase: (props: FairysTaroCalendarProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,35 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { View } from "@tarojs/components";
3
+ import { Calendar } from "@nutui/nutui-react-taro";
4
+ import { useState } from "react";
5
+ import { FairysTaroTextClearBase } from "../clear/index.js";
6
+ const FairysTaroCalendarBase = (props)=>{
7
+ const { placeholder = "\u8BF7\u9009\u62E9", value, className, style, onChange, ...rest } = props;
8
+ const [visible, setVisible] = useState(false);
9
+ return /*#__PURE__*/ jsxs(View, {
10
+ className: `fairys-taro-calendar ${className || ''}`,
11
+ style: style,
12
+ children: [
13
+ /*#__PURE__*/ jsx(FairysTaroTextClearBase, {
14
+ warpClassName: "fairys-taro-calendar-text",
15
+ isValue: !!value,
16
+ onTextClick: ()=>setVisible(true),
17
+ onClearClick: ()=>onChange?.(void 0, void 0),
18
+ children: value || placeholder
19
+ }),
20
+ /*#__PURE__*/ jsx(Calendar, {
21
+ ...rest,
22
+ visible: visible,
23
+ defaultValue: value,
24
+ onClose: ()=>setVisible(false),
25
+ onConfirm: (date)=>{
26
+ const [year, month, day] = date;
27
+ if (year) onChange?.(`${year}-${month}-${day}`, date);
28
+ else onChange?.(void 0, date);
29
+ setVisible(false);
30
+ }
31
+ })
32
+ ]
33
+ });
34
+ };
35
+ export { FairysTaroCalendarBase };
@@ -0,0 +1,10 @@
1
+ import { CascaderProps, CascaderOption } from '@nutui/nutui-react-taro';
2
+ export interface FairysTaroCascaderProps extends Omit<Partial<CascaderProps>, 'visible' | 'onClose' | 'onChange' | 'value'> {
3
+ placeholder?: string;
4
+ labelInValue?: boolean;
5
+ value?: (string | number | CascaderOption)[];
6
+ onChange?: (value: (string | number | CascaderOption)[], pathNodes: CascaderOption[]) => void;
7
+ bodyClassName?: string;
8
+ bodyStyle?: React.CSSProperties;
9
+ }
10
+ export declare const FairysTaroCascaderBase: (props: FairysTaroCascaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,85 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { View } from "@tarojs/components";
3
+ import { Cascader } from "@nutui/nutui-react-taro";
4
+ import { useMemo, useState } from "react";
5
+ import { FairysTaroTextClearBase } from "../clear/index.js";
6
+ const FairysTaroCascaderBase = (props)=>{
7
+ const { placeholder = "\u8BF7\u9009\u62E9", value, className, style, onChange, labelInValue = true, options, optionKey, bodyClassName, bodyStyle, ...rest } = props;
8
+ const [visible, setVisible] = useState(false);
9
+ const valueKey = optionKey?.valueKey || 'value';
10
+ const textKey = optionKey?.textKey || 'text';
11
+ const childrenKey = optionKey?.childrenKey || 'children';
12
+ const render = useMemo(()=>{
13
+ if (Array.isArray(value) && value.length) if (labelInValue) return value.map((it)=>{
14
+ if ('string' == typeof it || 'number' == typeof it) return it;
15
+ if (labelInValue) return it?.[textKey] || '';
16
+ return '';
17
+ }).filter(Boolean).join('/');
18
+ else {
19
+ const _value = [];
20
+ let _options = options || [];
21
+ while(_options.length){
22
+ const it = _options.shift();
23
+ if ('string' == typeof it || 'number' == typeof it) {
24
+ const findx = _options.findIndex((it)=>it[valueKey] === it);
25
+ if (findx) {
26
+ _value.push(it?.[textKey]);
27
+ _options = it?.[childrenKey] || [];
28
+ } else break;
29
+ } else break;
30
+ }
31
+ return _value.join('/');
32
+ }
33
+ return '';
34
+ }, [
35
+ value,
36
+ labelInValue,
37
+ valueKey,
38
+ textKey
39
+ ]);
40
+ const _value = useMemo(()=>{
41
+ if (Array.isArray(value) && value.length) return value.map((it)=>{
42
+ if ('string' == typeof it || 'number' == typeof it) return it;
43
+ if (labelInValue) return it[valueKey];
44
+ return '';
45
+ }).filter((it)=>'' !== it);
46
+ return [];
47
+ }, [
48
+ value,
49
+ labelInValue,
50
+ valueKey
51
+ ]);
52
+ return /*#__PURE__*/ jsxs(View, {
53
+ className: `fairys-taro-cascader ${className || ''}`,
54
+ style: style,
55
+ children: [
56
+ /*#__PURE__*/ jsx(FairysTaroTextClearBase, {
57
+ warpClassName: "fairys-taro-cascader-text",
58
+ isValue: !!render,
59
+ onTextClick: ()=>setVisible(true),
60
+ onClearClick: ()=>onChange?.(void 0, void 0),
61
+ children: render || placeholder
62
+ }),
63
+ /*#__PURE__*/ jsx(Cascader, {
64
+ ...rest,
65
+ className: `fairys-taro-cascader-body fairystaroform__text-left ${bodyClassName || ''}`,
66
+ style: bodyStyle,
67
+ optionKey: optionKey,
68
+ options: options,
69
+ value: _value,
70
+ visible: visible,
71
+ onChange: (value, pathNodes)=>{
72
+ if (labelInValue) {
73
+ const _value = pathNodes.map((it)=>{
74
+ const { children, ...rest } = it;
75
+ return rest;
76
+ });
77
+ onChange?.(_value, pathNodes);
78
+ } else onChange?.(value, pathNodes);
79
+ },
80
+ onClose: ()=>setVisible(false)
81
+ })
82
+ ]
83
+ });
84
+ };
85
+ export { FairysTaroCascaderBase };
@@ -0,0 +1,5 @@
1
+ import { CheckboxGroupProps, CheckboxProps } from '@nutui/nutui-react-taro';
2
+ export interface FairysTaroCheckboxGroupProps extends Partial<CheckboxGroupProps> {
3
+ items?: Partial<CheckboxProps>[];
4
+ }
5
+ export declare const FairysTaroCheckboxGroupBase: (props: FairysTaroCheckboxGroupProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Checkbox, CheckboxGroup } from "@nutui/nutui-react-taro";
3
+ const FairysTaroCheckboxGroupBase = (props)=>{
4
+ const { items, className, ...rest } = props;
5
+ return /*#__PURE__*/ jsx(CheckboxGroup, {
6
+ className: `fairys-taro-checkbox-group ${className || ''}`,
7
+ direction: "horizontal",
8
+ ...rest,
9
+ children: items?.map((item)=>/*#__PURE__*/ jsx(Checkbox, {
10
+ ...item
11
+ }, item.value))
12
+ });
13
+ };
14
+ export { FairysTaroCheckboxGroupBase };
@@ -0,0 +1,21 @@
1
+ import { ITouchEvent } from '@tarojs/components';
2
+ export interface SVG_IconProps {
3
+ className?: string;
4
+ style?: React.CSSProperties;
5
+ viewBox?: string;
6
+ name?: string;
7
+ color?: string;
8
+ width?: string | number;
9
+ height?: string | number;
10
+ size?: string | number;
11
+ svg64?: string;
12
+ svgSrc?: string;
13
+ children?: React.ReactNode;
14
+ fallback?: boolean;
15
+ isValue?: boolean;
16
+ warpClassName?: string;
17
+ warpStyle?: React.CSSProperties;
18
+ onTextClick?: (event: ITouchEvent) => void;
19
+ onClearClick?: (event: React.MouseEvent) => void;
20
+ }
21
+ export declare const FairysTaroTextClearBase: (props: SVG_IconProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Close2 } from "@nutui/icons-react-taro";
3
+ import { Text, View } from "@tarojs/components";
4
+ import clsx from "clsx";
5
+ import { Fragment, useMemo } from "react";
6
+ const FairysTaroTextClearBase = (props)=>{
7
+ const { isValue = true, children, warpClassName, warpStyle, onTextClick, onClearClick, ...rest } = props;
8
+ const clsx_text = useMemo(()=>clsx('fairys-taro-text fairystaroform__flex-1', {
9
+ 'fairys-taro-text-placeholder fairystaroform__text-gray-600 fairystaroform__font-normal': !isValue,
10
+ 'fairys-taro-text-value fairystaroform__text-black': isValue
11
+ }), [
12
+ isValue
13
+ ]);
14
+ return /*#__PURE__*/ jsxs(View, {
15
+ className: `fairys-taro-clear fairystaroform__flex fairystaroform__items-center fairystaroform__gap-1 ${warpClassName || ''}`,
16
+ style: warpStyle,
17
+ children: [
18
+ /*#__PURE__*/ jsx(Text, {
19
+ onClick: onTextClick,
20
+ className: clsx_text,
21
+ children: children
22
+ }),
23
+ isValue ? /*#__PURE__*/ jsx(Close2, {
24
+ color: "#c2c4cc",
25
+ onClick: onClearClick,
26
+ ...rest
27
+ }) : /*#__PURE__*/ jsx(Fragment, {})
28
+ ]
29
+ });
30
+ };
31
+ export { FairysTaroTextClearBase };
@@ -0,0 +1,18 @@
1
+ import { DatePickerProps } from '@nutui/nutui-react-taro';
2
+ export interface FairysTaroDatePickerProps extends Omit<Partial<DatePickerProps>, 'value' | 'onChange'> {
3
+ placeholder?: string;
4
+ /**
5
+ * 日期格式
6
+ * @description
7
+ * 当 type 为 date 时,格式为 YYYY-MM-DD
8
+ * 当 type 为 time 时,格式为 HH:mm:ss
9
+ * 当 type 为 year-month 时,格式为 YYYY-MM
10
+ * 当 type 为 month-day 时,格式为 MM-DD
11
+ * 当 type 为 datehour 时,格式为 YYYY-MM-DD HH
12
+ * 当 type 为 datetime 时,格式为 YYYY-MM-DD HH:mm
13
+ * 当 type 为 hour-minutes 时,格式为 HH:mm
14
+ */
15
+ value?: string | Date;
16
+ onChange?: (value?: string) => void;
17
+ }
18
+ export declare const FairysTaroDatePickerBase: (props: FairysTaroDatePickerProps) => import("react/jsx-runtime").JSX.Element;