@cloudbase/weda-ui 0.2.8 → 0.2.12

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 (104) hide show
  1. package/package.json +62 -41
  2. package/src/configs/.DS_Store +0 -0
  3. package/src/configs/components/button.json +7 -3
  4. package/src/configs/components/form/richText.json +1 -1
  5. package/src/configs/components/form/uploader.json +29 -1
  6. package/src/configs/components/form/uploaderFile.json +158 -0
  7. package/src/configs/components/image.json +12 -3
  8. package/src/configs/components/link.json +3 -3
  9. package/src/configs/components/richtextview.json +2 -2
  10. package/src/configs/components/scrollVeiw.json +5 -5
  11. package/src/configs/components/swiper.json +6 -6
  12. package/src/configs/components/tabs.json +3 -3
  13. package/src/configs/components/text.json +39 -4
  14. package/src/configs/index.js +6 -5
  15. package/src/mp/components/button/index.js +1 -0
  16. package/src/mp/components/button/index.wxss +8 -0
  17. package/src/mp/components/form/select/index.js +18 -0
  18. package/src/mp/components/form/uploader/index.js +26 -29
  19. package/src/mp/components/form/uploaderFile/index.js +247 -0
  20. package/src/mp/components/form/uploaderFile/index.json +9 -0
  21. package/src/mp/components/form/uploaderFile/index.wxml +46 -0
  22. package/src/mp/components/form/uploaderFile/index.wxss +104 -0
  23. package/src/mp/components/text/index.js +33 -0
  24. package/src/mp/components/text/index.wxml +1 -1
  25. package/src/mp/components/text/index.wxss +18 -0
  26. package/src/mp/index.json +1 -0
  27. package/src/mp/utils/platform.js +20 -0
  28. package/src/mp/utils/tcb.js +11 -0
  29. package/src/web/actions/showModal/{index.jsx → index.tsx} +53 -3
  30. package/src/web/components/auth/index.js +2 -2
  31. package/src/web/components/button/index.css +9 -0
  32. package/src/web/components/button/{index.jsx → index.tsx} +27 -41
  33. package/src/web/components/container/{index.jsx → index.tsx} +6 -10
  34. package/src/web/components/drawer/index.tsx +57 -0
  35. package/src/web/components/form/checkbox/{index.jsx → index.tsx} +24 -48
  36. package/src/web/components/form/enumSelect/MultipleSelect.jsx +89 -0
  37. package/src/web/components/form/enumSelect/NormalSelect.tsx +94 -0
  38. package/src/web/components/form/enumSelect/SelectContainer.jsx +43 -0
  39. package/src/web/components/form/enumSelect/index.jsx +9 -0
  40. package/src/web/components/form/enumSelect/props/defaultProps.js +39 -0
  41. package/src/web/components/form/enumSelect/props/propsTypes.js +50 -0
  42. package/src/web/components/form/form/index.tsx +48 -0
  43. package/src/web/components/form/formcell/{index.jsx → index.tsx} +6 -13
  44. package/src/web/components/form/input/index.css +4 -0
  45. package/src/web/components/form/input/{index.jsx → index.tsx} +33 -67
  46. package/src/web/components/form/radio/{index.jsx → index.tsx} +19 -42
  47. package/src/web/components/form/{renderDecorator.jsx → renderDecorator.tsx} +1 -3
  48. package/src/web/components/form/select/{h5.jsx → h5.tsx} +18 -62
  49. package/src/web/components/form/select/{index.jsx → index.tsx} +51 -94
  50. package/src/web/components/form/select/region/{cities.js → cities.ts} +1 -1
  51. package/src/web/components/form/select/region/{index.js → index.ts} +3 -3
  52. package/src/web/components/form/select/region/{provinces.js → provinces.ts} +1 -1
  53. package/src/web/components/form/select/region/{regions.js → regions.ts} +1 -1
  54. package/src/web/components/form/select/time.jsx +2 -2
  55. package/src/web/components/form/switch/{index.jsx → index.tsx} +30 -47
  56. package/src/web/components/form/textarea/{index.jsx → index.tsx} +22 -55
  57. package/src/web/components/form/tips/{index.jsx → index.tsx} +8 -22
  58. package/src/web/components/form/types.d.ts +12 -0
  59. package/src/web/components/form/uploader/{index.jsx → index.tsx} +16 -14
  60. package/src/web/components/form/uploader/{uploader.h5.jsx → uploader.h5.tsx} +67 -57
  61. package/src/web/components/form/uploader/{uploader.pc.jsx → uploader.pc.tsx} +26 -43
  62. package/src/web/components/form/uploaderFile/fail.svg +12 -0
  63. package/src/web/components/form/uploaderFile/index.css +423 -0
  64. package/src/web/components/form/uploaderFile/index.jsx +30 -0
  65. package/src/web/components/form/uploaderFile/pending.svg +18 -0
  66. package/src/web/components/form/uploaderFile/success.svg +12 -0
  67. package/src/web/components/form/uploaderFile/uploadFile.h5.jsx +562 -0
  68. package/src/web/components/form/uploaderFile/uploadFile.pc.jsx +487 -0
  69. package/src/web/components/image/{image.jsx → image.tsx} +8 -21
  70. package/src/web/components/image/{index.jsx → index.tsx} +22 -37
  71. package/src/web/components/index.js +36 -1
  72. package/src/web/components/link/{index.jsx → index.tsx} +19 -36
  73. package/src/web/components/modal/{index.jsx → index.tsx} +24 -10
  74. package/src/web/components/picker/{datePicker.jsx → datePicker.tsx} +11 -12
  75. package/src/web/components/picker/{picker.jsx → picker.tsx} +7 -10
  76. package/src/web/components/picker/{timePicker.jsx → timePicker.tsx} +8 -16
  77. package/src/web/components/richText/{const.js → const.ts} +0 -0
  78. package/src/web/components/richText/index.jsx +5 -2
  79. package/src/web/components/richTextView/index.tsx +67 -0
  80. package/src/web/components/scrollView/{index.jsx → index.tsx} +18 -33
  81. package/src/web/components/slot/{index.jsx → index.tsx} +8 -9
  82. package/src/web/components/swiper/index.css +1 -1
  83. package/src/web/components/swiper/{index.jsx → index.tsx} +66 -73
  84. package/src/web/components/tabs/index.tsx +33 -0
  85. package/src/web/components/tabs/{tabs.h5.jsx → tabs.h5.tsx} +4 -33
  86. package/src/web/components/tabs/{tabs.pc.jsx → tabs.pc.tsx} +5 -39
  87. package/src/web/components/text/index.css +18 -0
  88. package/src/web/components/text/index.tsx +69 -0
  89. package/src/web/components/uploaderFileView/index.css +11 -0
  90. package/src/web/components/uploaderFileView/index.jsx +75 -0
  91. package/src/web/components/uploaderView/{index.jsx → index.tsx} +12 -15
  92. package/src/web/types.d.ts +20 -0
  93. package/src/web/utils/constant.js +2 -0
  94. package/src/web/utils/loading-fallback.tsx +2 -0
  95. package/src/web/utils/platform.js +77 -6
  96. package/src/web/utils/useSetState.ts +14 -0
  97. package/src/web/utils/useSyncValue.ts +17 -0
  98. package/src/configs/components/button.svg +0 -18
  99. package/src/web/components/drawer/index.jsx +0 -64
  100. package/src/web/components/form/form/index.jsx +0 -76
  101. package/src/web/components/richTextView/index.jsx +0 -89
  102. package/src/web/components/tabs/index.jsx +0 -10
  103. package/src/web/components/text/index.jsx +0 -71
  104. package/src/web/utils/useSyncValue.js +0 -14
package/src/mp/index.json CHANGED
@@ -12,6 +12,7 @@
12
12
  "Textarea": "components/form/textarea/index",
13
13
  "Select": "components/form/select/index",
14
14
  "Uploader": "components/form/uploader/index",
15
+ "UploaderFile": "components/form/uploaderFile/index",
15
16
  "Container": "components/container/index",
16
17
  "Slot": {
17
18
  "type": "native",
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 文件字节转换
3
+ */
4
+ export const transSize = (size) => {
5
+ const b = parseInt(size) || 0;
6
+ const getBig = (d) => Math.ceil(d / 1024) || 0;
7
+ if (b < 1024) {
8
+ return `${size}B`;
9
+ }
10
+ const k = getBig(size);
11
+ if (k < 1024) {
12
+ return `${k}K`;
13
+ }
14
+ const m = getBig(k);
15
+ if (m < 1024) {
16
+ return `${m}M`;
17
+ }
18
+ const g = getBig(m);
19
+ return `${g}G`;
20
+ };
@@ -1,3 +1,14 @@
1
1
  export async function getCloudInstance() {
2
2
  return await getApp().app.cloud.getCloudInstance();
3
3
  }
4
+
5
+ /**
6
+ * 获取单个临时链接
7
+ * 单个cos文件,返回字符串
8
+ * 多个cos文件,返回 {fileID: src} 这样的对象
9
+ */
10
+ export async function getTempFileURL(data) {
11
+ if (getApp().app.cloud.getTempFileURL) {
12
+ return await getApp().app.cloud.getTempFileURL(data);
13
+ }
14
+ }
@@ -1,6 +1,56 @@
1
+ import * as ReactDOM from 'react-dom';
1
2
  import * as React from 'react';
2
- import { Modal, Button, Text } from 'tea-component';
3
- import 'tea-component/es/tea.css';
3
+ import { forwardRef, useState, useEffect, useImperativeHandle } from 'react';
4
+ import { Modal, Button, Text, ModalProps, ConfigProvider } from 'tea-component';
5
+ import type { ModalShowHandle, ModalShowOptions } from 'tea-component/lib/modal/ModalShow';
6
+
7
+
8
+ interface ModalShowInstance {
9
+ setVisible: React.Dispatch<React.SetStateAction<boolean>>;
10
+ }
11
+
12
+ const ModalShow = forwardRef(function ModalShow(
13
+ props: ModalProps,
14
+ ref: React.Ref<ModalShowInstance>
15
+ ) {
16
+ const [visible, setVisible] = useState(false);
17
+
18
+ // 渲染之后,马上显示
19
+ useEffect(() => {
20
+ setVisible(true);
21
+ }, []);
22
+
23
+ // 实例 ref 到外部
24
+ useImperativeHandle(ref, () => ({ setVisible }));
25
+
26
+ return <Modal {...props} visible={visible} />;
27
+ });
28
+
29
+
30
+ function show(options: ModalShowOptions): ModalShowHandle {
31
+ const el = document.createElement("div");
32
+
33
+ const instanceRef = React.createRef<ModalShowInstance>();
34
+
35
+ ReactDOM.render(
36
+ <ConfigProvider classPrefix="wedatea2td">
37
+ <ModalShow
38
+ {...options}
39
+ ref={instanceRef}
40
+ onExited={() => ReactDOM.unmountComponentAtNode(el)}
41
+ />
42
+ </ConfigProvider>,
43
+ el
44
+ );
45
+
46
+ return {
47
+ destroy: () => {
48
+ if (instanceRef.current) {
49
+ instanceRef.current.setVisible(false);
50
+ }
51
+ },
52
+ };
53
+ }
4
54
 
5
55
  export default async function showModal({ data }) {
6
56
  const {
@@ -19,7 +69,7 @@ export default async function showModal({ data }) {
19
69
  return new Promise((resolve) => {
20
70
  const base = { cancel: false, confirm: false, content: null };
21
71
 
22
- const modal = Modal.show({
72
+ const modal = show({
23
73
  caption: title,
24
74
  children: (
25
75
  <>
@@ -17,7 +17,7 @@ export default function Auth({ className }) {
17
17
  [className]: className,
18
18
  });
19
19
 
20
- const [authState, setAuthState] = React.useState(AUTHSTATE.SignIn);
20
+ const [authState, setAuthState] = React.useState(AUTHSTATE.SIGNIN);
21
21
  const [user, setUser] = React.useState({});
22
22
  const [tcb, setTcb] = React.useState(undefined);
23
23
 
@@ -42,7 +42,7 @@ export default function Auth({ className }) {
42
42
  // console.log('<<<<<<<wedaaaa', tcb);
43
43
 
44
44
  return tcb ? (
45
- authState === AUTHSTATE.SignedIn && user ? (
45
+ authState === AUTHSTATE.SIGNEDIN && user ? (
46
46
  <div className={cls}>
47
47
  <header className="tcb-header">
48
48
  {/* Hello, {user.uid} */}
@@ -9,3 +9,12 @@
9
9
  .weda-button.weda-button-mini {
10
10
  font-size: smaller;
11
11
  }
12
+ .weda-button.weda-button-large {
13
+ font-size: large;
14
+ display: block;
15
+ padding-left: 14px;
16
+ padding-right: 14px;
17
+ text-align: center;
18
+ width: 100%;
19
+ }
20
+
@@ -1,14 +1,13 @@
1
1
  import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
3
- import { Button as TeaButton, ConfigProvider } from 'tea-component';
2
+ import { Button as TeaButton, ButtonProps, ConfigProvider } from 'tea-component';
4
3
  import classNames from '../../utils/classnames';
4
+ import { usePlatform } from '../../utils/platform';
5
+ import { CommonPropsType, unknownFunction } from '../../types';
5
6
 
6
7
  import './index.css';
7
8
 
8
- import { usePlatform } from '../../utils/platform';
9
-
10
9
  // 不用 react-weui 而直接用底层实现的原因是 react-weui 不能支持表单类型
11
- export default function Button({
10
+ const Button = ({
12
11
  text = '按钮',
13
12
  size = 'default',
14
13
  type = 'primary',
@@ -16,16 +15,17 @@ export default function Button({
16
15
  formType,
17
16
  loading = false,
18
17
  disabled = false,
19
- events = {},
18
+ events = ({} as Record<string, unknownFunction>),
20
19
  className,
21
20
  style,
22
21
  id,
23
- }) {
24
- const platform = usePlatform();
25
- const isH5 = platform === 'h5';
22
+ }: PropsType) => {
23
+ const platform: string = usePlatform();
24
+ const isH5: boolean = platform === 'h5';
26
25
  const cls = classNames({
27
26
  'weda-ui': true,
28
27
  'weda-button': true,
28
+ 'weda-button-large': size === 'large',
29
29
  'weda-button-mini': size === 'mini',
30
30
  'weui-btn': isH5,
31
31
  'weui-btn_mini': isH5 && size === 'mini',
@@ -57,8 +57,6 @@ export default function Button({
57
57
  );
58
58
  }
59
59
 
60
- let teaType = type;
61
- if(teaType === 'warn') teaType = 'error';
62
60
  return (
63
61
  <ConfigProvider classPrefix="wedatea2td">
64
62
  <TeaButton
@@ -66,7 +64,7 @@ return (
66
64
  onClick={onClick}
67
65
  disabled={disabled}
68
66
  htmlType={formType}
69
- type={teaType}
67
+ type={toTeaButtonType(type)}
70
68
  style={style}
71
69
  className={cls}
72
70
  id={id}
@@ -77,52 +75,40 @@ return (
77
75
  );
78
76
  }
79
77
 
80
- Button.propTypes = {
78
+ function toTeaButtonType(type: PropsType['type'] ): ButtonProps['type'] {
79
+ if(type === 'primary') return type;
80
+ if(type === 'warn') return 'error';
81
+ if(type === 'default') return 'primary';
82
+ return 'primary';
83
+ }
84
+
85
+ export interface PropsType extends CommonPropsType {
81
86
  /**
82
87
  * 内容
83
88
  */
84
- text: PropTypes.string,
85
-
89
+ text?: string;
86
90
  /**
87
91
  * 样式类型
88
92
  */
89
- type: PropTypes.oneOf(['primary', 'warn', 'default']),
90
-
93
+ type?: "primary" | "warn" | "default";
91
94
  /**
92
95
  * 大小
93
96
  */
94
- size: PropTypes.oneOf(['default', 'mini']),
95
-
97
+ size?: "default" | "mini" | "large";
96
98
  /**
97
99
  * 是否禁用
98
100
  */
99
- disabled: PropTypes.bool,
100
-
101
+ disabled?: boolean;
101
102
  /**
102
103
  * 加载中
103
104
  */
104
- loading: PropTypes.bool,
105
-
106
- /**
107
- * 组件事件
108
- */
109
- events: PropTypes.objectOf(PropTypes.func),
105
+ loading?: boolean;
110
106
 
111
107
  /**
112
108
  * 用于 form 类型
113
109
  */
114
- formType: PropTypes.oneOf(['button', 'submit', 'reset']),
115
-
116
- className: PropTypes.string,
117
- contentSlot: PropTypes.string,
118
- style: PropTypes.object,
119
- id: PropTypes.string,
120
- };
110
+ formType?: "button" | "submit" | "reset";
111
+ contentSlot?: string;
112
+ }
121
113
 
122
- /**
123
- * 默认属性
124
- */
125
- Button.defaultProps = {
126
- type: 'primary',
127
- size: 'default',
128
- };
114
+ export default Button;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
2
+ import { CommonPropsType } from '../../types';
3
3
  import classNames from '../../utils/classnames';
4
4
 
5
5
  export default function Container({
@@ -9,7 +9,7 @@ export default function Container({
9
9
  className,
10
10
  style,
11
11
  id
12
- }) {
12
+ }: PropsType) {
13
13
  return (
14
14
  <div
15
15
  role="container"
@@ -29,11 +29,7 @@ export default function Container({
29
29
  );
30
30
  }
31
31
 
32
- Container.propTypes = {
33
- className: PropTypes.string,
34
- children: PropTypes.any,
35
- title: PropTypes.string,
36
- events: PropTypes.objectOf(PropTypes.func),
37
- id: PropTypes.string,
38
- style: PropTypes.object
39
- };
32
+ export interface PropsType extends CommonPropsType {
33
+ title?: string;
34
+
35
+ }
@@ -0,0 +1,57 @@
1
+ import * as React from 'react';
2
+ import { ConfigProvider, Drawer, DrawerProps } from 'tea-component';
3
+ import { CommonPropsType } from '../../types';
4
+
5
+ const TeaDrawer = ({
6
+ size,
7
+ title,
8
+ style,
9
+ events,
10
+ visible,
11
+ subtitle,
12
+ showMask,
13
+ className,
14
+ placement,
15
+ extraSlot,
16
+ footerSlot,
17
+ childrenSlot,
18
+ disableCloseIcon,
19
+ outerClickClosable,
20
+ }: PropsType) => {
21
+ const eventsList = {
22
+ onClose: () => events?.onClose && events.onClose({}),
23
+ onExited: () => events?.onExited && events.onExited({}),
24
+ };
25
+ return (
26
+ <ConfigProvider classPrefix="wedatea2td">
27
+ <Drawer
28
+ size={size}
29
+ title={title}
30
+ style={style}
31
+ visible={visible}
32
+ extra={extraSlot}
33
+ footer={footerSlot}
34
+ subtitle={subtitle}
35
+ showMask={showMask}
36
+ className={className}
37
+ placement={placement}
38
+ disableCloseIcon={disableCloseIcon}
39
+ outerClickClosable={outerClickClosable}
40
+ {...eventsList}
41
+ >
42
+ {childrenSlot}
43
+ </Drawer>
44
+ </ConfigProvider>
45
+ );
46
+ };
47
+
48
+ export interface PropsType extends CommonPropsType, Pick<DrawerProps, 'size'|'title'|'showMask'|'placement'|'disableCloseIcon'|'outerClickClosable'|'subtitle'> {
49
+ visible: boolean;
50
+ title?: string;
51
+ extraSlot?: React.ReactNode;
52
+ footerSlot?: React.ReactNode;
53
+ childrenSlot?: React.ReactNode;
54
+ }
55
+
56
+ export default TeaDrawer;
57
+ export { TeaDrawer };
@@ -1,5 +1,4 @@
1
1
  import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
3
2
  import { Checkbox as TeaCheckbox, ConfigProvider } from 'tea-component';
4
3
 
5
4
  import classNames from '../../../utils/classnames';
@@ -8,23 +7,24 @@ import isObjectEqual from '../../../utils/isObjectEqual';
8
7
  import fromEntries from 'object.fromentries';
9
8
  import { usePlatform } from '../../../utils/platform';
10
9
  import { renderDecorator } from '../renderDecorator';
10
+ import { CommonFormPropsType } from '../types';
11
11
 
12
12
  export default function Checkbox({
13
13
  // 系统属性
14
14
  id,
15
15
  className,
16
16
  style,
17
- events,
17
+ events = {},
18
18
  // 组件属性
19
- name,
20
- label,
19
+ name = 'formCheckbox',
20
+ label = '标题',
21
21
  labelVisible = true,
22
- range,
23
- layout,
24
- disabled,
25
- requiredFlag,
22
+ range = [],
23
+ layout = 'horizontal',
24
+ disabled = false,
25
+ requiredFlag = false,
26
26
  decorator
27
- }) {
27
+ }: PropsType) {
28
28
  const cls = classNames({
29
29
  'weda-ui': true,
30
30
  'weda-checkbox': true,
@@ -45,7 +45,7 @@ export default function Checkbox({
45
45
  : range.filter(({checked}) => checked).map(({value}) => value)
46
46
  );
47
47
  // 两次range不同时, 需要刷新checkedItems
48
- const prevRangeRef = React.useRef();
48
+ const prevRangeRef = React.useRef<object[]>();
49
49
  React.useEffect(() => {
50
50
  if (!isObjectEqual(prevRangeRef.current, range)) {
51
51
  prevRangeRef.current = range;
@@ -64,15 +64,17 @@ export default function Checkbox({
64
64
  e.stopPropagation();
65
65
  const checked = !checkedItems[value];
66
66
  const newMap = Object.assign({}, checkedItems, { [value]: checked });
67
- setCheckedItems(newMap);
68
- events.change(
69
- {
70
- value: Object.entries(newMap)
71
- .filter(([, checked]) => checked)
72
- .map(([value]) => value),
73
- },
74
- { originEvent: e }
75
- );
67
+ if (!disabled) {
68
+ setCheckedItems(newMap);
69
+ events.change(
70
+ {
71
+ value: Object.entries(newMap)
72
+ .filter(([, checked]) => checked)
73
+ .map(([value]) => value),
74
+ },
75
+ { originEvent: e }
76
+ );
77
+ }
76
78
  };
77
79
  return onChange;
78
80
  };
@@ -164,32 +166,6 @@ export default function Checkbox({
164
166
  );
165
167
  }
166
168
 
167
- Checkbox.propTypes = {
168
- // 系统属性
169
- id: PropTypes.string,
170
- className: PropTypes.string,
171
- style: PropTypes.string,
172
- events: PropTypes.objectOf(PropTypes.func),
173
- // 组件属性
174
- name: PropTypes.string,
175
- label: PropTypes.string,
176
- labelVisible: PropTypes.bool,
177
- range: PropTypes.array,
178
- layout: PropTypes.oneOf(['horizontal', 'vertical']),
179
- disabled: PropTypes.bool,
180
- requiredFlag: PropTypes.bool,
181
- decorator: PropTypes.oneOfType([PropTypes.array, PropTypes.node])
182
- };
183
-
184
- Checkbox.defaultProps = {
185
- // 系统属性
186
- events: {},
187
- // 组件属性
188
- name: 'formCheckbox',
189
- label: '标题',
190
- labelVisible: true,
191
- range: [],
192
- layout: 'horizontal',
193
- disabled: false,
194
- requiredFlag: false,
195
- };
169
+ export interface PropsType extends CommonFormPropsType {
170
+ range?: {label: string, value: any; [key: string]: any}[];
171
+ }
@@ -0,0 +1,89 @@
1
+ import * as React from 'react';
2
+ import { SelectMultiple } from 'tea-component';
3
+
4
+ import SelectContainer from './SelectContainer';
5
+
6
+ import { normalProps } from './props/defaultProps';
7
+ import { propTypes } from './props/propsTypes';
8
+
9
+ const MultipleSelect = ({
10
+ // 系统属性
11
+ id,
12
+ style,
13
+ className,
14
+ events,
15
+ // weda 组件属性
16
+ label,
17
+ labelVisible,
18
+ layout,
19
+ requiredFlag,
20
+ decorator,
21
+ // tea组件属性
22
+ value,
23
+ placeholder,
24
+ disabled,
25
+ onChange,
26
+ clearable,
27
+ appearance,
28
+ allOption,
29
+ matchButtonWidth,
30
+ virtual,
31
+ searchable,
32
+ size,
33
+ options,
34
+ // 业务属性
35
+ isModelApp,
36
+ }) => {
37
+ const onSelectChange = (values) => {
38
+ // @ts-ignore
39
+ events.change && events.change({ value: values });
40
+ if (onChange) {
41
+ onChange(values);
42
+ }
43
+ };
44
+
45
+ const multipleSelectProps = {
46
+ placeholder,
47
+ disabled,
48
+ clearable,
49
+ appearance,
50
+ key: id,
51
+ options,
52
+ onChange: onSelectChange,
53
+ matchButtonWidth,
54
+ searchable,
55
+ size,
56
+ defaultValue: value || [],
57
+ allOption,
58
+ staging: false,
59
+ virtual,
60
+ };
61
+
62
+ if (isModelApp) {
63
+ return <SelectMultiple {...multipleSelectProps} />;
64
+ }
65
+ return (
66
+ <SelectContainer
67
+ style={style}
68
+ className={className}
69
+ label={label}
70
+ labelVisible={labelVisible}
71
+ layout={layout}
72
+ // @ts-ignore
73
+ multiCell={false}
74
+ requiredFlag={requiredFlag}
75
+ decorator={decorator}
76
+ id={id}
77
+ >
78
+ <SelectMultiple {...multipleSelectProps} />
79
+ </SelectContainer>
80
+ );
81
+ };
82
+ MultipleSelect.propTypes = {
83
+ ...propTypes,
84
+ };
85
+ MultipleSelect.defaultProps = {
86
+ ...normalProps,
87
+ };
88
+
89
+ export default MultipleSelect;
@@ -0,0 +1,94 @@
1
+ import * as React from 'react';
2
+ import { Select } from 'tea-component';
3
+
4
+ import SelectContainer from './SelectContainer';
5
+
6
+ import { multipleProps } from './props/defaultProps';
7
+ import { propTypes } from './props/propsTypes';
8
+ import { useSyncValue } from '../../../utils/useSyncValue';
9
+
10
+ const { useState, useEffect } = React;
11
+
12
+
13
+
14
+ const NormalSelect = ({
15
+ // 系统属性
16
+ id,
17
+ style,
18
+ className,
19
+ events,
20
+ // weda 组件属性
21
+ label,
22
+ labelVisible,
23
+ layout,
24
+ requiredFlag,
25
+ decorator,
26
+ // tea组件属性
27
+ value,
28
+ placeholder,
29
+ disabled,
30
+ onChange,
31
+ clearable,
32
+ appearance,
33
+ matchButtonWidth,
34
+ virtual,
35
+ searchable,
36
+ size,
37
+ options,
38
+ // 业务属性
39
+ isModelApp,
40
+ }) => {
41
+ const [selectedValue, setSelectedValue] = useSyncValue(value);
42
+
43
+ const onSelectChange = (value) => {
44
+ // @ts-ignore
45
+ setSelectedValue(value);
46
+ events.change && events.change({ value });
47
+ if (onChange) {
48
+ onChange(value || '');
49
+ }
50
+ };
51
+
52
+ const singleSelectProps = {
53
+ placeholder,
54
+ disabled,
55
+ clearable,
56
+ appearance,
57
+ key: id,
58
+ options,
59
+ onChange: onSelectChange,
60
+ value: selectedValue,
61
+ matchButtonWidth,
62
+ virtual,
63
+ searchable,
64
+ size,
65
+ };
66
+
67
+ if (isModelApp) {
68
+ return <Select {...singleSelectProps} />;
69
+ }
70
+ return (
71
+ <SelectContainer
72
+ style={style}
73
+ className={className}
74
+ label={label}
75
+ labelVisible={labelVisible}
76
+ layout={layout}
77
+ // @ts-ignore
78
+ multiCell={false}
79
+ requiredFlag={requiredFlag}
80
+ decorator={decorator}
81
+ id={id}
82
+ >
83
+ <Select {...singleSelectProps} />
84
+ </SelectContainer>
85
+ );
86
+ };
87
+ NormalSelect.propTypes = {
88
+ ...propTypes,
89
+ };
90
+ NormalSelect.defaultProps = {
91
+ ...multipleProps,
92
+ };
93
+
94
+ export default NormalSelect;
@@ -0,0 +1,43 @@
1
+ import * as React from 'react';
2
+ import classNames from '../../../utils/classnames';
3
+ import { selectContainerPropsTypes } from './props/propsTypes';
4
+ import { renderDecorator } from '../renderDecorator';
5
+
6
+ const SelectContainer = ({
7
+ style,
8
+ className,
9
+ // weda 组件属性
10
+ id,
11
+ label,
12
+ labelVisible,
13
+ layout,
14
+ requiredFlag,
15
+ decorator,
16
+ children,
17
+ }) => {
18
+ const cls = classNames({
19
+ 'weda-ui': true,
20
+ [className]: className,
21
+ });
22
+ const subCls = classNames({
23
+ 'weui-cell': true,
24
+ 'weui-cell_active': true,
25
+ 'weui-cell_form': true,
26
+ 'weui-cell_disabled': true,
27
+ });
28
+ const SelectComponent = <div className={subCls}>{children}</div>;
29
+ return renderDecorator(
30
+ SelectComponent,
31
+ decorator
32
+ )({
33
+ id,
34
+ className: cls,
35
+ style,
36
+ label: labelVisible ? label : null,
37
+ layout,
38
+ multiCell: false,
39
+ requiredFlag,
40
+ });
41
+ };
42
+ SelectContainer.propTypes = selectContainerPropsTypes;
43
+ export default SelectContainer;