@fairys/taro-tools-simple-form-ui 0.0.5

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 (68) hide show
  1. package/README.md +0 -0
  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 +127 -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 +91 -0
  24. package/esm/components/popup.search/list.virtual.d.ts +1 -0
  25. package/esm/components/popup.search/list.virtual.js +71 -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/form/form.d.ts +30 -0
  29. package/esm/form/form.item.d.ts +54 -0
  30. package/esm/form/form.item.js +172 -0
  31. package/esm/form/form.js +31 -0
  32. package/esm/form/instance/index.d.ts +63 -0
  33. package/esm/form/instance/index.js +141 -0
  34. package/esm/form/item.config.d.ts +87 -0
  35. package/esm/form/item.config.js +105 -0
  36. package/esm/form/layout.d.ts +1784 -0
  37. package/esm/form/layout.js +134 -0
  38. package/esm/index.d.ts +5 -0
  39. package/esm/index.js +5 -0
  40. package/esm/interface.d.ts +4 -0
  41. package/esm/interface.js +0 -0
  42. package/esm/item.config.d.ts +0 -0
  43. package/esm/item.config.js +0 -0
  44. package/esm/styles/index.css +352 -0
  45. package/lib/index.js +96 -0
  46. package/package.json +38 -0
  47. package/src/components/calendar/index.tsx +45 -0
  48. package/src/components/cascader/index.tsx +127 -0
  49. package/src/components/checkbox.group/index.tsx +16 -0
  50. package/src/components/clear/index.tsx +49 -0
  51. package/src/components/date.picker/index.tsx +167 -0
  52. package/src/components/index.ts +8 -0
  53. package/src/components/picker/index.tsx +57 -0
  54. package/src/components/popup.search/base.tsx +51 -0
  55. package/src/components/popup.search/index.tsx +198 -0
  56. package/src/components/popup.search/instance.ts +440 -0
  57. package/src/components/popup.search/list.table.tsx +92 -0
  58. package/src/components/popup.search/list.virtual.tsx +84 -0
  59. package/src/components/radio.group/index.tsx +16 -0
  60. package/src/form/form.item.tsx +280 -0
  61. package/src/form/form.tsx +54 -0
  62. package/src/form/instance/index.ts +222 -0
  63. package/src/form/item.config.tsx +189 -0
  64. package/src/form/layout.tsx +232 -0
  65. package/src/index.tsx +5 -0
  66. package/src/interface.ts +4 -0
  67. package/src/item.config.tsx +202 -0
  68. package/src/styles/index.css +39 -0
@@ -0,0 +1,189 @@
1
+ /**
2
+ * 表单配置
3
+ */
4
+ import { View } from '@tarojs/components';
5
+
6
+ import { Fragment } from 'react';
7
+ import { FairysTaroValtioFormItem, FairysTaroValtioFormHideItem } from './form.item';
8
+ import type { FairysTaroValtioFormItemProps } from './form.item';
9
+ import { FairysTaroRadioGroupBase, FairysTaroRadioGroupProps } from 'components/radio.group';
10
+ import { FairysTaroCalendarBase, FairysTaroCalendarProps } from 'components/calendar';
11
+ import { FairysTaroCascaderBase, FairysTaroCascaderProps } from 'components/cascader';
12
+ import { FairysTaroCheckboxGroupBase, FairysTaroCheckboxGroupProps } from 'components/checkbox.group';
13
+ import { FairysTaroDatePickerBase, FairysTaroDatePickerProps } from 'components/date.picker';
14
+ import { FairysTaroPickerBase, FairysTaroPickerProps } from 'components/picker';
15
+ import { FairysTaroPopupSearchBase, FairysTaroPopupSearchProps } from 'components/popup.search';
16
+ import {
17
+ Input,
18
+ TaroInputProps,
19
+ InputNumber,
20
+ TaroInputNumberProps,
21
+ RadioGroup,
22
+ RadioGroupProps,
23
+ Radio,
24
+ RadioProps,
25
+ Range,
26
+ RangeProps,
27
+ Rate,
28
+ RateProps,
29
+ Signature,
30
+ SignatureProps,
31
+ Switch,
32
+ SwitchProps,
33
+ TextArea,
34
+ TextAreaProps,
35
+ Uploader,
36
+ UploaderProps,
37
+ } from '@nutui/nutui-react-taro';
38
+
39
+ export type MObject<T> = { [K in keyof T]: T[K] };
40
+ export type MakeFieldRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
41
+
42
+ /**
43
+ * 表单项配置基础类型
44
+ */
45
+ export interface FairysTaroValtioFormItemRowConfingBaseType<T, M, K = undefined> {
46
+ /**输入框类型*/
47
+ type: T;
48
+ /**输入框属性*/
49
+ attrs?: Partial<T extends undefined ? TaroInputProps : M>;
50
+ /**自定义渲染函数*/
51
+ render?: K;
52
+ /**是否添加隐藏组件*/
53
+ isHide?: boolean;
54
+ /**是否添加置空组件*/
55
+ isEmpty?: boolean;
56
+ }
57
+
58
+ /**
59
+ * 单个表单项配置类型
60
+ */
61
+ interface FairysTaroValtioFormItemRowConfing<T, M, K = undefined>
62
+ extends FairysTaroValtioFormItemRowConfingBaseType<T, M, K>,
63
+ Omit<FairysTaroValtioFormItemProps, 'attrs'> {}
64
+
65
+ /**
66
+ * 表单项配置映射类型
67
+ */
68
+ export type MappedType<T extends MObject<T>> = {
69
+ [K in keyof T]: FairysTaroValtioFormItemRowConfing<K, T[K]>;
70
+ }[keyof T];
71
+
72
+ /**
73
+ * 表单项组件名对应组件类型
74
+ */
75
+ export interface FairysTaroValtioFormItemTypeConfing {
76
+ /**输入框*/
77
+ input: TaroInputProps;
78
+ /**数字输入框*/
79
+ inputNumber: TaroInputNumberProps;
80
+ /**单选组*/
81
+ fairysRadioGroup: FairysTaroRadioGroupProps;
82
+ /**日历组件*/
83
+ fairysCalendar: FairysTaroCalendarProps;
84
+ /**级联选择器*/
85
+ fairysCascader: FairysTaroCascaderProps;
86
+ /**多选组*/
87
+ fairysCheckboxGroup: FairysTaroCheckboxGroupProps;
88
+ /**日期选择器*/
89
+ fairysDatePicker: FairysTaroDatePickerProps;
90
+ /**选择器*/
91
+ fairysPicker: FairysTaroPickerProps;
92
+ /**弹出搜索框*/
93
+ fairysPopupSearch: FairysTaroPopupSearchProps;
94
+ /**单选组*/
95
+ radioGroup: RadioGroupProps;
96
+ /**单选框*/
97
+ radio: RadioProps;
98
+ /**范围选择器*/
99
+ range: RangeProps;
100
+ /**评分组件*/
101
+ rate: RateProps;
102
+ /**签名组件*/
103
+ signature: SignatureProps;
104
+ /**开关组件*/
105
+ switch: SwitchProps;
106
+ /**多行文本输入框*/
107
+ textarea: TextAreaProps;
108
+ /**上传组件*/
109
+ uploader: UploaderProps;
110
+ }
111
+
112
+ /**
113
+ * 表单项配置类型
114
+ */
115
+ export type FairysTaroValtioInputConfigType =
116
+ | MappedType<FairysTaroValtioFormItemTypeConfing>
117
+ | FairysTaroValtioFormItemRowConfing<'custom', any, React.ReactNode>
118
+ | FairysTaroValtioFormItemRowConfing<'render', any, React.ReactNode>;
119
+
120
+ const create_itemConfig = (configList: FairysTaroValtioInputConfigType[]) => {
121
+ return (
122
+ <Fragment>
123
+ {configList.map((item, index) => {
124
+ const { type, isHide, attrs = {}, isEmpty, ...rest } = item;
125
+ const newItem = { attrs, ...rest };
126
+ /**自定义表单组件*/
127
+ if (type === 'custom') {
128
+ newItem.children = item.render || <Fragment />;
129
+ } else if (type === 'render') {
130
+ // 自定义渲染内容
131
+ return <Fragment key={index}>{item.render}</Fragment>;
132
+ } else if (type === 'input') {
133
+ newItem.children = <Input align="right" clearable {...attrs} />;
134
+ } else if (type === 'inputNumber') {
135
+ newItem.children = <InputNumber {...attrs} />;
136
+ } else if (type === 'fairysRadioGroup') {
137
+ newItem.children = <FairysTaroRadioGroupBase {...attrs} />;
138
+ } else if (type === 'radioGroup') {
139
+ newItem.children = <RadioGroup {...attrs} />;
140
+ } else if (type === 'radio') {
141
+ newItem.children = <Radio {...attrs} />;
142
+ } else if (type === 'range') {
143
+ newItem.children = <Range {...attrs} />;
144
+ } else if (type === 'rate') {
145
+ newItem.children = <Rate {...attrs} />;
146
+ } else if (type === 'signature') {
147
+ newItem.children = <Signature {...attrs} />;
148
+ } else if (type === 'switch') {
149
+ newItem.children = <Switch {...attrs} />;
150
+ } else if (type === 'textarea') {
151
+ newItem.children = <TextArea {...attrs} />;
152
+ } else if (type === 'uploader') {
153
+ newItem.children = <Uploader {...attrs} />;
154
+ } else if (type === 'fairysCalendar') {
155
+ newItem.children = <FairysTaroCalendarBase {...attrs} />;
156
+ } else if (type === 'fairysCascader') {
157
+ const title = attrs.title || (typeof item.label === 'string' ? item.label : '') || '请选择';
158
+ newItem.children = <FairysTaroCascaderBase {...attrs} title={title} />;
159
+ } else if (type === 'fairysCheckboxGroup') {
160
+ newItem.children = <FairysTaroCheckboxGroupBase {...attrs} />;
161
+ } else if (type === 'fairysDatePicker') {
162
+ const title = attrs.title || (typeof item.label === 'string' ? item.label : '') || '请选择';
163
+ newItem.children = <FairysTaroDatePickerBase {...attrs} title={title} />;
164
+ } else if (type === 'fairysPicker') {
165
+ const title = attrs.title || (typeof item.label === 'string' ? item.label : '') || '请选择';
166
+ newItem.children = <FairysTaroPickerBase {...attrs} title={title} />;
167
+ } else if (type === 'fairysPopupSearch') {
168
+ const title = attrs.title || (typeof item.label === 'string' ? item.label : '') || '请选择';
169
+ newItem.children = <FairysTaroPopupSearchBase {...attrs} title={title} />;
170
+ }
171
+ if (isEmpty) {
172
+ return <View key={index} className="fairys-taro-simple-form-item-empty" />;
173
+ }
174
+ if (isHide) {
175
+ return <FairysTaroValtioFormHideItem key={index} {...(newItem as FairysTaroValtioFormItemProps)} />;
176
+ }
177
+ return <FairysTaroValtioFormItem key={index} {...(newItem as FairysTaroValtioFormItemProps)} />;
178
+ })}
179
+ </Fragment>
180
+ );
181
+ };
182
+
183
+ export const FairysTaroValtioFormConfigListItem = (props: { items: FairysTaroValtioInputConfigType[] }) => {
184
+ return create_itemConfig(props.items);
185
+ };
186
+
187
+ export const FairysTaroValtioFormConfigItem = (config: FairysTaroValtioInputConfigType) => {
188
+ return create_itemConfig([config]);
189
+ };
@@ -0,0 +1,232 @@
1
+ import { createContext, Fragment, useContext, useMemo, useRef } from 'react';
2
+ import { View } from '@tarojs/components';
3
+ import clsx from 'clsx';
4
+ import { proxy, useSnapshot } from 'valtio';
5
+
6
+ export interface FairysTaroValtioFormLayoutContextOptions {
7
+ /**列数据*/
8
+ colCount?: number;
9
+ /**规则校验失败错误提示位置*/
10
+ errorLayout?: 'left-bottom' | 'right-bottom' | 'top-right' | 'top-left';
11
+ /**
12
+ * label显示模式
13
+ * @platform taro 支持 between
14
+ */
15
+ labelMode?: 'left' | 'top' | 'between';
16
+ /**表单项 className*/
17
+ formItemClassName?: string;
18
+ /**表单项 style*/
19
+ formItemStyle?: React.CSSProperties;
20
+ /**表单项 label className*/
21
+ formItemLabelClassName?: string;
22
+ /**表单项 label style*/
23
+ formItemLabelStyle?: React.CSSProperties;
24
+ /**
25
+ * 底部边框
26
+ */
27
+ bottomBordered?: boolean;
28
+ }
29
+
30
+ export interface FairysTaroValtioFormLayoutProps extends FairysTaroValtioFormLayoutContextOptions {
31
+ /**
32
+ * @description gap 属性是用来设置网格行与列之间的间隙,该属性是row-gap and column-gap的简写形式。
33
+ */
34
+ gap?: string | number;
35
+ /**标题*/
36
+ title?: React.ReactNode;
37
+ /**额外内容*/
38
+ extra?: React.ReactNode;
39
+ /**内容*/
40
+ children?: React.ReactNode;
41
+ /**是否占据整行*/
42
+ isAllColSpan?: boolean;
43
+ className?: string;
44
+ style?: React.CSSProperties;
45
+ /**头部ClassName*/
46
+ headerClassName?: string;
47
+ /**头部样式*/
48
+ headerStyle?: React.CSSProperties;
49
+ /**内容ClassName*/
50
+ bodyClassName?: string;
51
+ /**内容样式*/
52
+ bodyStyle?: React.CSSProperties;
53
+ /**是否边框*/
54
+ bordered?: boolean;
55
+ /**显示阴影*/
56
+ boxShadow?: boolean;
57
+ }
58
+
59
+ export class FairysTaroValtioFormLayoutInstance {
60
+ state = proxy<FairysTaroValtioFormLayoutContextOptions>({
61
+ colCount: 1,
62
+ errorLayout: 'right-bottom',
63
+ labelMode: 'between',
64
+ bottomBordered: true,
65
+ });
66
+ updated = (options: FairysTaroValtioFormLayoutContextOptions = {}) => {
67
+ const keys = Object.keys(options);
68
+ for (let index = 0; index < keys.length; index++) {
69
+ const key = keys[index];
70
+ this.state[key] = options[key];
71
+ }
72
+ };
73
+ }
74
+
75
+ export const useFairysTaroValtioFormLayoutInstance = (instance?: FairysTaroValtioFormLayoutInstance) => {
76
+ const ref = useRef<FairysTaroValtioFormLayoutInstance>();
77
+ if (!ref.current) {
78
+ if (instance) {
79
+ ref.current = instance;
80
+ } else {
81
+ ref.current = new FairysTaroValtioFormLayoutInstance();
82
+ }
83
+ }
84
+ return ref.current;
85
+ };
86
+
87
+ export const FairysTaroValtioFormLayoutContext = createContext<FairysTaroValtioFormLayoutInstance>(
88
+ new FairysTaroValtioFormLayoutInstance(),
89
+ );
90
+
91
+ export const useFairysTaroValtioFormLayoutContext = () => {
92
+ const instance = useContext(FairysTaroValtioFormLayoutContext);
93
+ const state = useSnapshot(instance.state);
94
+ return [state, instance] as const;
95
+ };
96
+
97
+ export function FairysTaroValtioFormLayout(props: FairysTaroValtioFormLayoutProps) {
98
+ const formLayoutInstance = useFairysTaroValtioFormLayoutInstance();
99
+ const [state] = useFairysTaroValtioFormLayoutContext();
100
+ const parent_colCount = state.colCount || 1;
101
+ const parent_errorLayout = state.errorLayout || 'right-bottom';
102
+ const parent_labelMode = state.labelMode || 'between';
103
+ const parent_formItemClassName = state.formItemClassName;
104
+ const parent_formItemStyle = state.formItemStyle;
105
+ const parent_formItemLabelClassName = state.formItemLabelClassName;
106
+ const parent_formItemLabelStyle = state.formItemLabelStyle;
107
+ const parent_bottomBordered = state.bottomBordered;
108
+ const {
109
+ colCount = parent_colCount,
110
+ errorLayout = parent_errorLayout,
111
+ labelMode = parent_labelMode,
112
+ formItemClassName = parent_formItemClassName,
113
+ formItemStyle = parent_formItemStyle,
114
+ formItemLabelClassName = parent_formItemLabelClassName,
115
+ formItemLabelStyle = parent_formItemLabelStyle,
116
+ bottomBordered = parent_bottomBordered,
117
+ gap,
118
+ title,
119
+ extra,
120
+ children,
121
+ isAllColSpan = false,
122
+ className,
123
+ style,
124
+ headerClassName,
125
+ headerStyle,
126
+ bodyClassName,
127
+ bodyStyle,
128
+ bordered,
129
+ boxShadow,
130
+ } = props;
131
+
132
+ useMemo(
133
+ () =>
134
+ formLayoutInstance.updated({
135
+ colCount,
136
+ errorLayout,
137
+ labelMode,
138
+ formItemClassName,
139
+ formItemStyle,
140
+ formItemLabelClassName,
141
+ formItemLabelStyle,
142
+ bottomBordered,
143
+ }),
144
+ [
145
+ colCount,
146
+ errorLayout,
147
+ labelMode,
148
+ formItemClassName,
149
+ formItemStyle,
150
+ formItemLabelClassName,
151
+ formItemLabelStyle,
152
+ bottomBordered,
153
+ ],
154
+ );
155
+
156
+ const layoutCls = useMemo(
157
+ () =>
158
+ clsx(
159
+ `fairys-taro-valtio-form-layout fairystaroform__text-[0.6rem] fairystaroform__w-full fairystaroform__box-border fairystaroform__rounded-md`,
160
+ {
161
+ 'fairys-taro-valtio-form-layout-all-col-span': isAllColSpan,
162
+ 'fairys-taro-form-valtio-layout-box-shadow': boxShadow,
163
+ 'fairystaroform__border fairystaroform__border-solid fairystaroform__border-gray-100': bordered,
164
+ },
165
+ className,
166
+ ),
167
+ [className, isAllColSpan, bordered, boxShadow],
168
+ );
169
+
170
+ const headerCls = useMemo(
171
+ () =>
172
+ clsx(
173
+ `fairys-taro-valtio-form-layout-header fairystaroform__flex fairystaroform__justify-between fairystaroform__items-center fairystaroform__flex-row fairystaroform__py-[0.45rem] fairystaroform__border-b fairystaroform__border-b-solid fairystaroform__border-b-gray-100 fairystaroform__box-border`,
174
+ {
175
+ 'fairystaroform__px-[0.4rem]': bordered || boxShadow,
176
+ 'fairystaroform__px-[0.1rem]': !bordered && !boxShadow,
177
+ },
178
+ headerClassName,
179
+ ),
180
+ [headerClassName, bordered, boxShadow],
181
+ );
182
+
183
+ const headerTitleCls = useMemo(
184
+ () => clsx(`fairys-taro-valtio-form-layout-header-title fairystaroform__font-bold fairystaroform__box-border`),
185
+ [],
186
+ );
187
+ const headerExtraCls = useMemo(
188
+ () => clsx(`fairys-taro-valtio-form-layout-header-extra fairystaroform__box-border`),
189
+ [],
190
+ );
191
+
192
+ const body_base = useMemo(() => {
193
+ return clsx(
194
+ 'fairys-taro-valtio-form-layout-body fairystaroform__px-[0.25rem] fairystaroform__w-full fairystaroform__grid fairystaroform__gap-[0.14rem] fairystaroform__box-border',
195
+ bodyClassName,
196
+ );
197
+ }, [bodyClassName]);
198
+
199
+ const styleBase = useMemo(() => {
200
+ const css: React.CSSProperties = {};
201
+ if (typeof gap === 'string') {
202
+ css.gap = gap;
203
+ }
204
+ if (typeof gap === 'number') {
205
+ css.gap = `${gap}px`;
206
+ }
207
+ if (colCount) {
208
+ css.gridTemplateColumns = `repeat(${colCount}, auto)`;
209
+ }
210
+ return css;
211
+ }, [colCount, gap]);
212
+
213
+ return (
214
+ <FairysTaroValtioFormLayoutContext.Provider value={formLayoutInstance}>
215
+ <View className={layoutCls} style={style}>
216
+ <View>
217
+ {title || extra ? (
218
+ <View style={headerStyle} className={headerCls}>
219
+ <View className={headerTitleCls}>{title}</View>
220
+ <View className={headerExtraCls}>{extra}</View>
221
+ </View>
222
+ ) : (
223
+ <Fragment />
224
+ )}
225
+ </View>
226
+ <View className={body_base} style={{ ...styleBase, ...bodyStyle }}>
227
+ {children}
228
+ </View>
229
+ </View>
230
+ </FairysTaroValtioFormLayoutContext.Provider>
231
+ );
232
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,5 @@
1
+ export * from './components';
2
+ export * from './form/instance';
3
+ export * from './form/layout';
4
+ export * from './form/form';
5
+ export * from './form/form.item';
@@ -0,0 +1,4 @@
1
+ export type MObject<T> = {
2
+ [K in keyof T]: T[K];
3
+ };
4
+ export type MakeFieldRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
@@ -0,0 +1,202 @@
1
+ // /**
2
+ // * 表单配置
3
+ // */
4
+ // import { View } from '@tarojs/components';
5
+ // import { Fragment } from 'react';
6
+ // import type { FormItemProps, FormListProps } from '@carefrees/form-utils-react-taro';
7
+ // import { FormItem, FormHideItem, FormHideList, FormList } from '@carefrees/form-utils-react-taro';
8
+ // import { FairysTaroRadioGroupBase, FairysTaroRadioGroupProps } from 'components/radio.group';
9
+ // import { FairysTaroCalendarBase, FairysTaroCalendarProps } from 'components/calendar';
10
+ // import { FairysTaroCascaderBase, FairysTaroCascaderProps } from 'components/cascader';
11
+ // import { FairysTaroCheckboxGroupBase, FairysTaroCheckboxGroupProps } from 'components/checkbox.group';
12
+ // import { FairysTaroDatePickerBase, FairysTaroDatePickerProps } from 'components/date.picker';
13
+ // import { FairysTaroPickerBase, FairysTaroPickerProps } from 'components/picker';
14
+ // import { FairysTaroPopupSearchBase, FairysTaroPopupSearchProps } from 'components/popup.search';
15
+
16
+ // import {
17
+ // Input,
18
+ // TaroInputProps,
19
+ // InputNumber,
20
+ // TaroInputNumberProps,
21
+ // RadioGroup,
22
+ // RadioGroupProps,
23
+ // Radio,
24
+ // RadioProps,
25
+ // Range,
26
+ // RangeProps,
27
+ // Rate,
28
+ // RateProps,
29
+ // Signature,
30
+ // SignatureProps,
31
+ // Switch,
32
+ // SwitchProps,
33
+ // TextArea,
34
+ // TextAreaProps,
35
+ // Uploader,
36
+ // UploaderProps,
37
+ // } from '@nutui/nutui-react-taro';
38
+
39
+ // export type MObject<T> = { [K in keyof T]: T[K] };
40
+ // export type MakeFieldRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
41
+
42
+ // /**
43
+ // * 表单项配置基础类型
44
+ // */
45
+ // export interface FormItemRowConfingBaseType<T, M, K = undefined> {
46
+ // /**输入框类型*/
47
+ // type: T;
48
+ // /**输入框属性*/
49
+ // attrs?: Partial<T extends undefined ? TaroInputProps : M>;
50
+ // /**自定义渲染函数*/
51
+ // render?: K;
52
+ // /**是否添加隐藏组件*/
53
+ // isHide?: boolean;
54
+ // /**是否添加置空组件*/
55
+ // isEmpty?: boolean;
56
+ // }
57
+
58
+ // /**
59
+ // * 单个表单项配置类型
60
+ // */
61
+ // interface FormItemRowConfing<T, M, K = undefined>
62
+ // extends FormItemRowConfingBaseType<T, M, K>,
63
+ // Omit<FormItemProps, 'attrs'> { }
64
+
65
+ // /**
66
+ // * 表单项配置映射类型
67
+ // */
68
+ // export type MappedType<T extends MObject<T>> = {
69
+ // [K in keyof T]: FormItemRowConfing<K, T[K]>;
70
+ // }[keyof T];
71
+
72
+ // /**
73
+ // * 表单项组件名对应组件类型
74
+ // */
75
+ // export interface FormItemTypeConfing {
76
+ // /**输入框*/
77
+ // input: TaroInputProps;
78
+ // /**数字输入框*/
79
+ // inputNumber: TaroInputNumberProps;
80
+ // /**单选组*/
81
+ // fairysRadioGroup: FairysTaroRadioGroupProps;
82
+ // /**日历组件*/
83
+ // fairysCalendar: FairysTaroCalendarProps;
84
+ // /**级联选择器*/
85
+ // fairysCascader: FairysTaroCascaderProps;
86
+ // /**多选组*/
87
+ // fairysCheckboxGroup: FairysTaroCheckboxGroupProps;
88
+ // /**日期选择器*/
89
+ // fairysDatePicker: FairysTaroDatePickerProps;
90
+ // /**选择器*/
91
+ // fairysPicker: FairysTaroPickerProps;
92
+ // /**弹出搜索框*/
93
+ // fairysPopupSearch: FairysTaroPopupSearchProps;
94
+ // /**单选组*/
95
+ // radioGroup: RadioGroupProps;
96
+ // /**单选框*/
97
+ // radio: RadioProps;
98
+ // /**范围选择器*/
99
+ // range: RangeProps;
100
+ // /**评分组件*/
101
+ // rate: RateProps;
102
+ // /**签名组件*/
103
+ // signature: SignatureProps;
104
+ // /**开关组件*/
105
+ // switch: SwitchProps;
106
+ // /**多行文本输入框*/
107
+ // textarea: TextAreaProps;
108
+ // /**上传组件*/
109
+ // uploader: UploaderProps;
110
+ // }
111
+
112
+ // /**
113
+ // * 自定义表单列表项配置类型
114
+ // */
115
+ // export type CustomFormListType = FormItemRowConfingBaseType<'formList', any, React.ReactNode> & Omit<FormListProps, 'attrs'>;
116
+ // /**
117
+ // * 表单项配置类型
118
+ // */
119
+ // export type InputConfigType =
120
+ // | MappedType<FormItemTypeConfing>
121
+ // | FormItemRowConfing<'custom', any, React.ReactNode>
122
+ // | FormItemRowConfing<'render', any, React.ReactNode>
123
+ // | CustomFormListType;
124
+
125
+ // const create_itemConfig = (configList: InputConfigType[]) => {
126
+ // return (
127
+ // <Fragment>
128
+ // {configList.map((item, index) => {
129
+ // const { type, isHide, attrs = {}, isEmpty, ...rest } = item;
130
+ // const newItem = { attrs, ...rest };
131
+ // /**自定义表单组件*/
132
+ // if (type === 'custom') {
133
+ // newItem.children = item.render || <Fragment />;
134
+ // } else if (type === 'render') {
135
+ // // 自定义渲染内容
136
+ // return <Fragment key={index}>{item.render}</Fragment>;
137
+ // } else if (type === 'formList') {
138
+ // if (typeof item.children === 'function') {
139
+ // if (isHide) {
140
+ // return <FormHideList sort={`${index}`} key={index} {...rest} children={item.children} name={item.name} />;
141
+ // }
142
+ // return <FormList sort={`${index}`} key={index} {...rest} children={item.children} name={item.name} />;
143
+ // }
144
+ // return <Fragment key={index} />;
145
+ // } else if (type === 'input') {
146
+ // newItem.children = <Input align="right" clearable {...attrs} />;
147
+ // } else if (type === 'inputNumber') {
148
+ // newItem.children = <InputNumber {...attrs} />;
149
+ // } else if (type === 'fairysRadioGroup') {
150
+ // newItem.children = <FairysTaroRadioGroupBase {...attrs} />;
151
+ // } else if (type === 'radioGroup') {
152
+ // newItem.children = <RadioGroup {...attrs} />;
153
+ // } else if (type === 'radio') {
154
+ // newItem.children = <Radio {...attrs} />;
155
+ // } else if (type === 'range') {
156
+ // newItem.children = <Range {...attrs} />;
157
+ // } else if (type === 'rate') {
158
+ // newItem.children = <Rate {...attrs} />;
159
+ // } else if (type === 'signature') {
160
+ // newItem.children = <Signature {...attrs} />;
161
+ // } else if (type === 'switch') {
162
+ // newItem.children = <Switch {...attrs} />;
163
+ // } else if (type === 'textarea') {
164
+ // newItem.children = <TextArea {...attrs} />;
165
+ // } else if (type === 'uploader') {
166
+ // newItem.children = <Uploader {...attrs} />;
167
+ // } else if (type === 'fairysCalendar') {
168
+ // newItem.children = <FairysTaroCalendarBase {...attrs} />;
169
+ // } else if (type === 'fairysCascader') {
170
+ // const title = attrs.title || (typeof item.label === 'string' ? item.label : '') || '请选择';
171
+ // newItem.children = <FairysTaroCascaderBase {...attrs} title={title} />;
172
+ // } else if (type === 'fairysCheckboxGroup') {
173
+ // newItem.children = <FairysTaroCheckboxGroupBase {...attrs} />;
174
+ // } else if (type === 'fairysDatePicker') {
175
+ // const title = attrs.title || (typeof item.label === 'string' ? item.label : '') || '请选择';
176
+ // newItem.children = <FairysTaroDatePickerBase {...attrs} title={title} />;
177
+ // } else if (type === 'fairysPicker') {
178
+ // const title = attrs.title || (typeof item.label === 'string' ? item.label : '') || '请选择';
179
+ // newItem.children = <FairysTaroPickerBase {...attrs} title={title} />;
180
+ // } else if (type === 'fairysPopupSearch') {
181
+ // const title = attrs.title || (typeof item.label === 'string' ? item.label : '') || '请选择';
182
+ // newItem.children = <FairysTaroPopupSearchBase {...attrs} title={title} />;
183
+ // }
184
+ // if (isEmpty) {
185
+ // return <View key={index} className="fairys-taro-simple-form-item-empty" />;
186
+ // }
187
+ // if (isHide) {
188
+ // return <FormHideItem sort={`${index}`} key={index} {...(newItem as FormItemProps)} />;
189
+ // }
190
+ // return <FormItem sort={`${index}`} key={index} {...(newItem as FormItemProps)} />;
191
+ // })}
192
+ // </Fragment>
193
+ // );
194
+ // };
195
+
196
+ // export const ConfigListItem = (props: { items: InputConfigType[] }) => {
197
+ // return create_itemConfig(props.items);
198
+ // };
199
+
200
+ // export const ConfigItem = (config: InputConfigType) => {
201
+ // return create_itemConfig([config]);
202
+ // };
@@ -0,0 +1,39 @@
1
+ @import '@carefrees/form-utils-react-taro/assets/index.css';
2
+
3
+ @unocss preflights;
4
+ @unocss default;
5
+
6
+ .nut-cell.fairys-taro-popup-search-list-virtual-cell > .nut-cell-left > .nut-cell-title {
7
+ width: 100%;
8
+ }
9
+
10
+ .nut-cell.fairys-taro-popup-search-list-virtual-cell > .nut-cell-extra {
11
+ flex: none;
12
+ }
13
+
14
+ .fairys-taro-popup-search-list-table .nut-table-main-head-tr {
15
+ z-index: 10;
16
+ position: relative;
17
+ }
18
+
19
+ /* 解决宽度不一致造成的固定列阴影错位 */
20
+ .fairys-taro-popup-search-list-table .nut-table-main-body-tr-td,
21
+ .fairys-taro-popup-search-list-table .nut-table-main-head-tr-th {
22
+ box-sizing: border-box;
23
+ }
24
+
25
+ .fairys-taro-valtio-form-item-label.required::before {
26
+ content: '*';
27
+ color: red;
28
+ display: inline-block;
29
+ margin-inline-end: 0.2rem;
30
+ box-sizing: border-box;
31
+ }
32
+
33
+ .fairys-taro-valtio-form-layout.fairys-taro-form-layout-all-col-span {
34
+ grid-column: 1 / -1;
35
+ }
36
+
37
+ .fairys-taro-valtio-form-layout.fairys-taro-form-layout-box-shadow {
38
+ box-shadow: 0 6px 16px -8px #00000014, 0 9px 28px #0000000d, 0 12px 48px 16px #00000008;
39
+ }