@cloudbase/weda-ui 3.4.11 → 3.4.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 (150) hide show
  1. package/dist/configs/components/common/form-input-required.js +3 -3
  2. package/dist/configs/components/customer-service.js +3 -0
  3. package/dist/configs/components/dataView.js +20 -10
  4. package/dist/configs/components/form-checkbox.js +15 -2
  5. package/dist/configs/components/form-email.js +17 -2
  6. package/dist/configs/components/form-input.js +17 -2
  7. package/dist/configs/components/form-phone.js +17 -2
  8. package/dist/configs/components/form-radio.js +15 -2
  9. package/dist/configs/components/form-select-multiple.js +362 -0
  10. package/dist/configs/components/form-switch.js +15 -2
  11. package/dist/configs/components/form-text-area.js +15 -2
  12. package/dist/configs/components/form-url.js +17 -2
  13. package/dist/configs/components/form-user-tree-select.js +13 -0
  14. package/dist/configs/components/listView.js +32 -49
  15. package/dist/configs/components/table.json +1 -54
  16. package/dist/configs/components/wd-bubble.js +46 -8
  17. package/dist/configs/components/wd-button.js +3 -0
  18. package/dist/configs/components/wd-checkbox.js +464 -0
  19. package/dist/configs/components/wd-form.js +66 -10
  20. package/dist/configs/components/wd-input-email.js +37 -0
  21. package/dist/configs/components/wd-input-phone.js +43 -0
  22. package/dist/configs/components/wd-input-url.js +37 -0
  23. package/dist/configs/components/wd-input.js +94 -0
  24. package/dist/configs/components/wd-official-account.js +87 -0
  25. package/dist/configs/components/wd-radio.js +443 -0
  26. package/dist/configs/components/wd-switch.js +315 -0
  27. package/dist/configs/components/wd-table.js +8 -56
  28. package/dist/configs/components/wd-textarea.js +82 -0
  29. package/dist/configs/components/wd-tree.js +443 -0
  30. package/dist/configs/components/web-view.js +3 -0
  31. package/dist/configs/index.js +24 -1
  32. package/dist/configs/type-utils/type-form.js +681 -0
  33. package/dist/docs/common/components/json-schema-view.js +1 -1
  34. package/dist/docs/common/components/methods-view.js +1 -1
  35. package/dist/docs/common/components/properties-view.js +3 -1
  36. package/dist/docs/common/format.js +7 -7
  37. package/dist/docs/common/tableView.js +3 -1
  38. package/dist/enum/index.js +196 -0
  39. package/dist/style/index.scss +1 -1
  40. package/dist/web/actions/showMessage/index.js +4 -1
  41. package/dist/web/components/carousel/index.js +1 -1
  42. package/dist/web/components/customer-service/customer-service.js +19 -2
  43. package/dist/web/components/dataView/index.js +16 -3
  44. package/dist/web/components/flow/common/hooks/useCommonFlowData/flow-get.js +5 -1
  45. package/dist/web/components/flow/common/request.js +5 -5
  46. package/dist/web/components/flow/modules/operations/controls-items/flow-task-info-modal.js +90 -0
  47. package/dist/web/components/form/formcell/index.css +13 -1
  48. package/dist/web/components/form/formcell/index.js +1 -1
  49. package/dist/web/components/form/location/components/LocationH5/location.h5.js +1 -1
  50. package/dist/web/components/form/select/dropdown-select/index.js +7 -1
  51. package/dist/web/components/form/select/h5.js +18 -8
  52. package/dist/web/components/form/select/index.js +9 -9
  53. package/dist/web/components/form/select/region/index.js +1 -1
  54. package/dist/web/components/form/selectMultiple/dropdown-select/h5.js +111 -0
  55. package/dist/web/components/form/selectMultiple/dropdown-select/index.css +270 -0
  56. package/dist/web/components/form/selectMultiple/dropdown-select/index.js +206 -0
  57. package/dist/web/components/form/selectMultiple/dropdown-select/pc.js +115 -0
  58. package/dist/web/components/form/selectMultiple/dropdown-select/ui.js +113 -0
  59. package/dist/web/components/form/selectMultiple/h5.js +40 -0
  60. package/dist/web/components/form/selectMultiple/index.js +94 -0
  61. package/dist/web/components/form/selectMultiple/request.js +76 -0
  62. package/dist/web/components/form/selectMultiple/status/allEmpty.js +5 -0
  63. package/dist/web/components/form/selectMultiple/status/empty.js +19 -0
  64. package/dist/web/components/form/selectMultiple/status/index.css +63 -0
  65. package/dist/web/components/form/selectMultiple/status/index.js +7 -0
  66. package/dist/web/components/form/selectMultiple/status/loading.js +19 -0
  67. package/dist/web/components/form/selectMultiple/status/propsType.js +1 -0
  68. package/dist/web/components/form/selectMultiple/status/retry.js +19 -0
  69. package/dist/web/components/form/tips/index.css +9 -3
  70. package/dist/web/components/form/uploader/index.css +10 -0
  71. package/dist/web/components/form/uploader/uploader.h5.js +60 -62
  72. package/dist/web/components/form/uploader/uploader.pc.js +48 -41
  73. package/dist/web/components/form/uploaderFile/uploadFile.h5.js +8 -33
  74. package/dist/web/components/form/uploaderFile/uploadFile.pc.js +8 -37
  75. package/dist/web/components/form/userOrgSelect/common/fetch-data-service.js +76 -50
  76. package/dist/web/components/form/userOrgSelect/common/utils.js +24 -8
  77. package/dist/web/components/form/userOrgSelect/component/depart-select/depart-select-pc.js +3 -8
  78. package/dist/web/components/form/userOrgSelect/component/depart-select/index.js +14 -18
  79. package/dist/web/components/form/userOrgSelect/component/depart-select/org-modal-pc.js +20 -14
  80. package/dist/web/components/form/userOrgSelect/component/modal-select-h5.js +1 -1
  81. package/dist/web/components/form/userOrgSelect/component/org-tree.js +21 -9
  82. package/dist/web/components/form/userOrgSelect/component/user-select-h5/index.js +57 -10
  83. package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-model.js +2 -7
  84. package/dist/web/components/form/userOrgSelect/component/user-select-pc/user-select-pc.js +6 -4
  85. package/dist/web/components/form/userOrgSelect/component/userOrgSelect.css +8 -2
  86. package/dist/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +25 -51
  87. package/dist/web/components/form/userOrgSelect/hooks/use-depart-data.js +3 -3
  88. package/dist/web/components/form-input-hooks/index.js +39 -14
  89. package/dist/web/components/form-select-multiple/index.js +26 -0
  90. package/dist/web/components/form-user-tree-select/index.js +2 -2
  91. package/dist/web/components/formdetail/index.css +31 -1
  92. package/dist/web/components/formdetail/index.js +30 -0
  93. package/dist/web/components/index.js +17 -1
  94. package/dist/web/components/listView/index.js +20 -5
  95. package/dist/web/components/phone/index.js +26 -1
  96. package/dist/web/components/phoneCode/index.js +3 -1
  97. package/dist/web/components/richText/index.css +70 -67
  98. package/dist/web/components/richText/index.js +311 -251
  99. package/dist/web/components/richText/richtext.module.css +1 -0
  100. package/dist/web/components/richTextView/index.css +39 -0
  101. package/dist/web/components/richTextView/index.js +1 -1
  102. package/dist/web/components/share/index.js +26 -1
  103. package/dist/web/components/wd-checkbox/checkbox.js +34 -0
  104. package/dist/web/components/wd-checkbox/index.js +3 -0
  105. package/dist/web/components/wd-checkbox-list/checkboxList.js +140 -0
  106. package/dist/web/components/wd-checkbox-list/index.js +3 -0
  107. package/dist/web/components/wd-form/index.js +25 -12
  108. package/dist/web/components/wd-form/wd-form.js +42 -0
  109. package/dist/web/components/wd-form-cell/index.js +3 -0
  110. package/dist/web/components/wd-form-cell/wd-form-cell.js +42 -0
  111. package/dist/web/components/wd-form-item/index.js +4 -0
  112. package/dist/web/components/wd-form-item/wd-form-item.js +55 -0
  113. package/dist/web/components/wd-form-item/wd-input-group.js +24 -0
  114. package/dist/web/components/wd-input/index.js +3 -0
  115. package/dist/web/components/wd-input/wd-input.js +155 -0
  116. package/dist/web/components/wd-input-email/index.js +3 -0
  117. package/dist/web/components/wd-input-email/wd-input-email.js +13 -0
  118. package/dist/web/components/wd-input-group/index.js +3 -0
  119. package/dist/web/components/wd-input-group/wd-input-group.js +10 -0
  120. package/dist/web/components/wd-input-phone/index.js +3 -0
  121. package/dist/web/components/wd-input-phone/wd-input-phone.js +14 -0
  122. package/dist/web/components/wd-input-url/index.js +3 -0
  123. package/dist/web/components/wd-input-url/wd-input-url.js +13 -0
  124. package/dist/web/components/wd-input-wrap/index.js +3 -0
  125. package/dist/web/components/wd-input-wrap/wd-input-wrap.js +18 -0
  126. package/dist/web/components/wd-official-account/index.css +29 -0
  127. package/dist/web/components/wd-official-account/index.js +36 -0
  128. package/dist/web/components/wd-radio/index.js +3 -0
  129. package/dist/web/components/wd-radio/wd-radio.js +30 -0
  130. package/dist/web/components/wd-radio-list/index.js +3 -0
  131. package/dist/web/components/wd-radio-list/wd-radio-list.js +104 -0
  132. package/dist/web/components/wd-switch/index.js +3 -0
  133. package/dist/web/components/wd-switch/wd-switch.js +52 -0
  134. package/dist/web/components/wd-table/components/FieldRender/index.js +5 -4
  135. package/dist/web/components/wd-table/components/Table/index.js +12 -2
  136. package/dist/web/components/wd-table/hooks/useQueryParams.js +4 -1
  137. package/dist/web/components/wd-table/utils/index.js +6 -2
  138. package/dist/web/components/wd-table/wd-table.js +70 -57
  139. package/dist/web/components/wd-textarea/index.js +3 -0
  140. package/dist/web/components/wd-textarea/wd-textarea.js +78 -0
  141. package/dist/web/components/wd-tree/index.js +3 -0
  142. package/dist/web/components/wd-tree/utils.js +291 -0
  143. package/dist/web/components/wd-tree/wd-tree.js +193 -0
  144. package/dist/web/utils/constant.js +16 -0
  145. package/dist/web/utils/datasource.js +2 -2
  146. package/dist/web/utils/date.js +3 -3
  147. package/dist/web/utils/hooks/useFormLegacy.js +111 -0
  148. package/dist/web/utils/tool.js +12 -2
  149. package/dist/web/weda-ui.css +193 -3
  150. package/package.json +6 -5
@@ -0,0 +1,155 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint max-lines: [error, 500] */
3
+ import { forwardRef, useImperativeHandle, useEffect, useMemo, useRef, useState, useCallback, } from 'react';
4
+ import { WdFormItem, WdInputGroup } from '../wd-form-item';
5
+ import { useFormInputTrait } from '../form-input-hooks';
6
+ import { WdIcon } from '../wd-icon';
7
+ import { filterPropsWithOn, getUuid } from '../../utils/tool';
8
+ import { FORM_MAX_LENGTH, KEY_DOWN_CODE } from '../../utils/constant';
9
+ import classNames from '../../utils/classnames';
10
+ import { useSyncValue } from '../../utils/hooks/useSyncValue';
11
+ import { usePlatform } from '../../utils/platform';
12
+ import { useSize, useRules, converValueFix, converInputValue, useStringProp, } from '../../utils/hooks/useFormLegacy';
13
+ import { useConfig } from '../../utils/config-context';
14
+ import isEqual from 'lodash.isequal';
15
+ const inputTypes = { idcard: 'text', digit: 'number' };
16
+ /**
17
+ * 标准化:单行输入组件
18
+ */
19
+ export const WdInput = forwardRef(function WdInput(props, ref) {
20
+ const { name, password = false, type = 'text', placeholder = '请输入', focus: _focus = false, maxLength = FORM_MAX_LENGTH, clearable = true, events, block: _block, prefixType, prefixIcon, prefixSrc, suffixType, suffixIcon, suffixSrc, classRoot = 'input', wrapClassName = '', counterVisible, label, required, inputPattern, } = props;
21
+ const { before, after, inputValue } = useStringProp(props);
22
+ const [innerHandle, setInnerHandle] = useState({}); // hook里挂出的属性
23
+ const [currentInputValue, setCurrentInputValue] = useSyncValue(inputValue); // 监听inputValue
24
+ const formValue = useMemo(() => converValueFix(inputValue, before, after, type), [inputValue, before, after, type]);
25
+ const rules = useRules(props); // 含前后缀和必填时,仅对输入框校验
26
+ const traitProps = {
27
+ ...props,
28
+ rules,
29
+ value: formValue,
30
+ inputRef: ref,
31
+ setInnerHandle,
32
+ };
33
+ const { value, // 代表组件值,含前后缀
34
+ onChange: _onChange, disabled, readOnly, validateErrorMsg, validateState, visible, layout, } = useFormInputTrait(traitProps);
35
+ const wrapRef = useRef(null);
36
+ const valueRef = useRef(value);
37
+ const size = useSize(props);
38
+ const block = usePlatform() === 'h5' ? true : _block;
39
+ const { classPrefix } = useConfig();
40
+ const startWithOnProps = useMemo(() => filterPropsWithOn(props), [props]);
41
+ const inputId = useMemo(() => getUuid(), []);
42
+ const [focus, setFocus] = useSyncValue(_focus);
43
+ const inputType = password ? 'password' : inputTypes[type] || type;
44
+ const hasClearIcon = clearable && focus && !disabled && (currentInputValue === null || currentInputValue === void 0 ? void 0 : currentInputValue.length) > 0;
45
+ const counter = typeof currentInputValue === 'string' ? currentInputValue.length : 0;
46
+ const root = `${classPrefix}-${classRoot}`;
47
+ const inputWrap = `${classPrefix}-form-input-wrap`;
48
+ const inputCls = `${classPrefix}-form-input-wrap__input`;
49
+ const contentCls = `${inputWrap}__content`;
50
+ const prefixCls = `${inputWrap}__before`;
51
+ const prefixIconCls = `${root}__icon-before`;
52
+ const suffixCls = `${inputWrap}__after`;
53
+ const suffixIconCls = `${root}__icon-after`;
54
+ const cls = classNames(inputWrap, wrapClassName, `size-width-${size} size-font-${size}`, `${root}-${classRoot}`, `size-height-${size}`, {
55
+ 'size-width-hundred': block,
56
+ 'is-disabled': disabled,
57
+ [`${inputWrap}--no-radius-left`]: before,
58
+ [`${inputWrap}--no-radius-right`]: after,
59
+ [`${inputWrap}--no-radius`]: before && after,
60
+ });
61
+ const countCls = `${classPrefix}-input__limit-number`;
62
+ useEffect(() => {
63
+ // eslint-disable-next-line rulesdir/no-timer
64
+ setTimeout(() => changeForm(value));
65
+ // eslint-disable-next-line react-hooks/exhaustive-deps
66
+ }, []);
67
+ useEffect(() => {
68
+ if (isEqual(valueRef.current, value))
69
+ return; // 监听非输入引起的value变化,比如调用 setValue, clearValue
70
+ const currentInputValue = converInputValue(value, before, after);
71
+ setCurrentInputValue(currentInputValue);
72
+ }, [value, before, after, setCurrentInputValue]);
73
+ const changeForm = useCallback((val) => {
74
+ valueRef.current = val;
75
+ _onChange(val);
76
+ }, [_onChange]);
77
+ const onChange = (e) => {
78
+ var _a;
79
+ const text = typeof e === 'string' ? e : e.target.value;
80
+ if (maxLength > 0 && text.length > maxLength) {
81
+ return;
82
+ }
83
+ const reg = new RegExp(inputPattern);
84
+ if (inputPattern && !reg.test(text)) {
85
+ return;
86
+ }
87
+ setCurrentInputValue(text);
88
+ const newValue = converValueFix(text, before, after, type);
89
+ changeForm(newValue);
90
+ (_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: newValue }, { originEvent: e });
91
+ };
92
+ const onClear = (e) => {
93
+ var _a, _b;
94
+ setCurrentInputValue('');
95
+ const newValue = converValueFix('', before, after, type);
96
+ changeForm(newValue);
97
+ (_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: newValue }, { originEvent: e });
98
+ (_b = events.clear) === null || _b === void 0 ? void 0 : _b.call(events, { originValue: value }, { originEvent: e });
99
+ e.preventDefault();
100
+ };
101
+ const onKeyDown = (e) => {
102
+ if (e.key === 'enter' || e.keyCode === KEY_DOWN_CODE) {
103
+ events.confirm({ value: converValueFix(e.target.value, before, after, type) }, { originEvent: e });
104
+ }
105
+ if (inputType === 'number' && e.key === 'e') {
106
+ e.preventDefault();
107
+ }
108
+ };
109
+ const onFocus = (e) => {
110
+ events.focus({ value: converValueFix(e.target.value, before, after, type) }, { originEvent: e });
111
+ setFocus(true);
112
+ };
113
+ const onBlur = (e) => {
114
+ events.blur({ value: converValueFix(e.target.value, before, after, type) }, { originEvent: e });
115
+ setFocus(false);
116
+ };
117
+ useImperativeHandle(ref, () => ({
118
+ ...innerHandle,
119
+ name,
120
+ value,
121
+ label,
122
+ required,
123
+ visible,
124
+ disabled,
125
+ readOnly,
126
+ before,
127
+ after,
128
+ }), [
129
+ innerHandle,
130
+ name,
131
+ value,
132
+ label,
133
+ required,
134
+ visible,
135
+ disabled,
136
+ readOnly,
137
+ before,
138
+ after,
139
+ ]);
140
+ const formItemProps = {
141
+ ...props,
142
+ validateErrorMsg,
143
+ validateState,
144
+ readOnly,
145
+ readValue: value,
146
+ disabled,
147
+ classRoot,
148
+ inputId,
149
+ layout,
150
+ };
151
+ const inputGroupProps = { before, after, block, classRoot, size };
152
+ if (!visible)
153
+ return null;
154
+ return (_jsx(WdFormItem, { ...formItemProps, children: _jsx(WdInputGroup, { ...inputGroupProps, children: _jsxs("div", { className: cls, ref: wrapRef, onFocus: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add('is-focused'); }, onBlur: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove('is-focused'); }, children: [prefixType && (_jsx("div", { className: prefixCls, children: _jsx(WdIcon, { size: size, name: prefixIcon, type: prefixType, src: prefixSrc, className: prefixIconCls }) })), _jsx("div", { className: contentCls, children: _jsx("input", { id: inputId, className: inputCls, type: inputType, placeholder: placeholder, value: currentInputValue, disabled: disabled, name: name, autoFocus: focus, autoComplete: "off", maxLength: maxLength, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, ...startWithOnProps }) }), hasClearIcon && (_jsx("div", { className: suffixCls, children: _jsx(WdIcon, { className: `${classPrefix}-icon__trigger`, name: "td:close-circle-filled", onMouseDown: onClear }) })), !hasClearIcon && suffixType && (_jsx("div", { className: suffixCls, children: _jsx(WdIcon, { size: size, name: suffixIcon, type: suffixType, src: suffixSrc, className: suffixIconCls }) })), counterVisible && (_jsxs("span", { className: countCls, children: [counter, "/", maxLength] }))] }) }) }));
155
+ });
@@ -0,0 +1,3 @@
1
+ import { WdInputEmail } from './wd-input-email';
2
+ export { WdInputEmail } from './wd-input-email';
3
+ export default WdInputEmail;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { useConfig } from '../../utils/config-context';
4
+ import { WdInput } from '../wd-input';
5
+ const rules = [{ format: 'email', message: '邮箱校验失败' }];
6
+ /**
7
+ * 标准化:邮箱输入组件
8
+ */
9
+ export const WdInputEmail = forwardRef(function WdInputEmail(props, ref) {
10
+ const { classPrefix } = useConfig();
11
+ const wrapCls = `${classPrefix}-form-input-email-wrap`;
12
+ return (_jsx(WdInput, { ...props, ref: ref, wrapClassName: wrapCls, classRoot: "input-email", rules: rules }));
13
+ });
@@ -0,0 +1,3 @@
1
+ import { WdInputGroup } from './wd-input-group';
2
+ export { WdInputGroup } from './wd-input-group';
3
+ export default WdInputGroup;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import classNames from '../../utils/classnames';
3
+ import { useConfig } from '../../utils/config-context';
4
+ export const WdInputGroup = ({ before, after, className, children, }) => {
5
+ // 兼容旧版组件的属性值
6
+ const { classPrefix } = useConfig();
7
+ const compClassName = `${classPrefix}-form-input-group `;
8
+ const classList = [compClassName];
9
+ return (_jsxs("div", { className: classNames(...classList, className), children: [before && (_jsx("div", { className: `${classPrefix}-form-input-group__addon ${classPrefix}-form-input-group__addon-left`, children: before })), _jsx("div", { className: `${classPrefix}-form-input-group__content`, children: children }), after && (_jsx("div", { className: `${classPrefix}-form-input-group__addon ${classPrefix}-form-input-group__addon-right`, children: after }))] }));
10
+ };
@@ -0,0 +1,3 @@
1
+ import { WdInputPhone } from './wd-input-phone';
2
+ export { WdInputPhone } from './wd-input-phone';
3
+ export default WdInputPhone;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { useConfig } from '../../utils/config-context';
4
+ import { WdInput } from '../wd-input';
5
+ const rules = [{ format: 'mobile', message: '手机校验失败' }];
6
+ /**
7
+ * 标准化:电话输入组件
8
+ */
9
+ export const WdInputPhone = forwardRef(function WdInputPhone(props, ref) {
10
+ const { classPrefix } = useConfig();
11
+ const wrapCls = `${classPrefix}-form-input-number-wrap `;
12
+ const pattern = '^[0-9\\-]{0,11}$';
13
+ return (_jsx(WdInput, { ...props, inputPattern: pattern, maxLength: 11, wrapClassName: wrapCls, classRoot: "input-phone", rules: rules, ref: ref }));
14
+ });
@@ -0,0 +1,3 @@
1
+ import { WdInputUrl } from './wd-input-url';
2
+ export { WdInputUrl } from './wd-input-url';
3
+ export default WdInputUrl;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from 'react';
3
+ import { useConfig } from '../../utils/config-context';
4
+ import { WdInput } from '../wd-input';
5
+ const rules = [{ format: 'url', message: 'url校验失败' }];
6
+ /**
7
+ * 标准化:URL输入组件
8
+ */
9
+ export const WdInputUrl = forwardRef(function WdInputUrl(props, ref) {
10
+ const { classPrefix } = useConfig();
11
+ const wrapCls = `${classPrefix}-form-input-url-wrap`;
12
+ return (_jsx(WdInput, { ...props, ref: ref, classRoot: "input-url", wrapClassName: wrapCls, rules: rules }));
13
+ });
@@ -0,0 +1,3 @@
1
+ import { WdInputWrap } from './wd-input-wrap';
2
+ export { WdInputWrap } from './wd-input-wrap';
3
+ export default WdInputWrap;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import classNames from '../../utils/classnames';
4
+ import { useConfig } from '../../utils/config-context';
5
+ // import { WdIcon } from '../index';
6
+ export const WdInputWrap = ({ className, children, before, after, }) => {
7
+ // 兼容旧版组件的属性值
8
+ const { classPrefix } = useConfig();
9
+ const compClassName = `${classPrefix}-form-input-wrap `;
10
+ const classList = [compClassName];
11
+ classList.push(className);
12
+ const InputWrap = React.useRef(null);
13
+ return (_jsxs("div", { className: classNames(...classList), ref: InputWrap, onFocus: () => {
14
+ InputWrap.current.classList.add('is-focused');
15
+ }, onBlur: () => {
16
+ InputWrap.current.classList.remove('is-focused');
17
+ }, children: [before && (_jsx("div", { className: `${classPrefix}-form-input-wrap__before`, children: before })), children && (_jsx("div", { className: `${classPrefix}-form-input-wrap__content`, children: children })), after && (_jsx("div", { className: `${classPrefix}-form-input-wrap__after`, children: after }))] }));
18
+ };
@@ -0,0 +1,29 @@
1
+ .weda-official-account {
2
+ height: 106px;
3
+ background-color: #fff;
4
+ padding: 10px 15px;
5
+ border: 1px solid #f2f2f2;
6
+ border-radius: 2px;
7
+ }
8
+ .weda-official-account__title {
9
+ margin-bottom: 12px;
10
+ font-size: 12px;
11
+ }
12
+ .weda-official-account__left {
13
+ display: flex;
14
+ }
15
+ .weda-official-account__left__img {
16
+ height: 54px;
17
+ width: 54px;
18
+ border-radius: 100%;
19
+ margin-right: 8px;
20
+ }
21
+ .weda-official-account .weda-official-account__label {
22
+ font-size: 12px;
23
+ }
24
+ .weda-official-account
25
+ .wedatea2td-justify-grid__col--right
26
+ .weda-official-account__btn {
27
+ border-color: var(--weui-WECHAT);
28
+ color: var(--weui-WECHAT);
29
+ }
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ * @Date: 2023-04-18 19:14:42
4
+ * @LastEditTime: 2023-05-04 11:54:50
5
+ * @Description:
6
+ */
7
+ import * as React from 'react';
8
+ import { Text, Justify, ConfigProvider, Bubble } from 'tea-component';
9
+ import classNames from '../../utils/classnames';
10
+ import { WdButton } from '../../components/wd-button';
11
+ // @ts-ignore忽略ts交验
12
+ // eslint-disable-next-line rulesdir/no-phantom-deps,import/no-unresolved
13
+ import { autorun } from 'mobx';
14
+ import './index.css';
15
+ export default function WdOfficialAccount(props) {
16
+ var _a, _b;
17
+ const { className, id, style } = props;
18
+ const [editorPlatforms, setEditorPlatforms] = React.useState([]);
19
+ const dispose = React.useMemo(() => {
20
+ return autorun(() => {
21
+ var _a, _b;
22
+ setEditorPlatforms((_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.editorPlatforms);
23
+ });
24
+ }, []);
25
+ React.useEffect(() => {
26
+ return () => {
27
+ dispose();
28
+ };
29
+ }, [dispose]);
30
+ return (_jsx(ConfigProvider, { classPrefix: "wedatea2td", children: ((_b = (_a = window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.isEditorMode) ||
31
+ (editorPlatforms === null || editorPlatforms === void 0 ? void 0 : editorPlatforms.includes('MP')) ? (_jsx(Bubble, { content: _jsxs(_Fragment, { children: ["\u8BF7\u53D1\u5E03\u540E\u5728\u5FAE\u4FE1\u4E2D\u67E5\u770B\u8BE5\u7EC4\u4EF6\u5B9E\u9645\u6548\u679C\uFF0C\u5F53\u524D\u7EC4\u4EF6\u4EC5\u5728\u7279\u5B9A\u5C0F\u7A0B\u5E8F\u6253\u5F00\u573A\u666F\u4E0B\u5C55\u793A\uFF0C", _jsx("br", {}), _jsx("a", { href: "https://developers.weixin.qq.com/miniprogram/dev/component/official-account.html", target: "_blank", rel: "noreferrer", children: "\u67E5\u770B\u8BF4\u660E" })] }), children: _jsxs("div", { className: classNames({
32
+ [className]: className,
33
+ 'weda-ui': true,
34
+ 'weda-official-account': true,
35
+ }), id: id, style: style, children: [_jsx(Text, { parent: "p", theme: "label", className: "weda-official-account__title", children: "\u67D0\u67D0\u5C0F\u7A0B\u5E8F\u5173\u8054\u7684\u516C\u4F17\u53F7" }), _jsx(Justify, { left: _jsxs("div", { className: "weda-official-account__left", children: [_jsx("img", { className: "weda-official-account__left__img", src: "https://qcloudimg.tencent-cloud.cn/raw/4a29d51b504f12b4933ce4490110b4dc.svg", alt: "" }), _jsxs("div", { children: [_jsx(Text, { reset: true, parent: "p", children: "\u516C\u4F17\u53F7\u540D\u79F0" }), _jsx(Text, { className: "weda-official-account__label", reset: true, parent: "p", theme: "label", children: "\u516C\u4F17\u53F7\u7B80\u4ECB" })] })] }), right: _jsx(WdButton, { theme: "primary", variant: "outline", style: { fontSize: '14px' }, text: "\u5173\u6CE8", size: "mini", className: "weda-official-account__btn" }) })] }) })) : null }));
36
+ }
@@ -0,0 +1,3 @@
1
+ import { WdRadio } from './wd-radio';
2
+ export { WdRadio } from './wd-radio';
3
+ export default WdRadio;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import classNames from '../../utils/classnames';
4
+ import { useConfig } from '../../utils/config-context';
5
+ import getLocalCounter from '../../utils/getLocalCounter';
6
+ export const WdRadio = ({ index, option, name, size, disabled, readOnly, checkedItemValue, getChangeHandler, }) => {
7
+ const { classPrefix } = useConfig();
8
+ const { label, value: optionValue } = option;
9
+ // 类名
10
+ const classList = [];
11
+ switch (size) {
12
+ case 'sm':
13
+ classList.push(`size-sm `);
14
+ break;
15
+ case 'md':
16
+ classList.push(`size-md `);
17
+ break;
18
+ case 'lg':
19
+ classList.push(`size-lg `);
20
+ break;
21
+ default:
22
+ classList.push();
23
+ }
24
+ // 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
25
+ const hashcode = useMemo(() => getLocalCounter(), []);
26
+ const _id = `radio-${hashcode}-${index}`;
27
+ const _name = `radio-${hashcode}-${name}`;
28
+ const NUMBER_1 = 1;
29
+ return (_jsxs("label", { className: `${classPrefix}-radio-wrap ${classNames(classList)} ${`${checkedItemValue}` === `${optionValue}` ? 'is-checked' : ''} ${disabled || readOnly ? 'is-disabled' : ''} ${'radio' + (index + NUMBER_1)}`, onClick: getChangeHandler(optionValue), children: [_jsx("input", { className: `${classPrefix}-radio-input `, id: _id, name: _name, type: "radio", value: optionValue, disabled: disabled || readOnly, checked: `${checkedItemValue}` === `${optionValue}`, onChange: (e) => e.stopPropagation(), onClick: (e) => e.stopPropagation() }), _jsx("span", { className: `${classPrefix}-radio-inner ` }), label && _jsx("span", { className: `${classPrefix}-radio-label`, children: label })] }));
30
+ };
@@ -0,0 +1,3 @@
1
+ import { WdRadioList } from './wd-radio-list';
2
+ export { WdRadioList } from './wd-radio-list';
3
+ export default WdRadioList;
@@ -0,0 +1,104 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
3
+ import React, { useState, useEffect } from 'react';
4
+ import classNames from '../../utils/classnames';
5
+ import { useConfig } from '../../utils/config-context';
6
+ import { WdRadio } from '../index';
7
+ import { WdFormItem } from '../wd-form-item';
8
+ import { emptyObject } from '../../utils/constant';
9
+ import { usePlatform } from '../../utils/platform';
10
+ import { useSize } from '../../utils/hooks/useFormLegacy';
11
+ import { useFormInputTrait } from '../form-input-hooks';
12
+ import { callWedaApi } from '../../utils/tcb';
13
+ import destr from 'destr';
14
+ export const WdRadioList = React.forwardRef(function WdRadioList(props, inputRef) {
15
+ const { range, direction, events = emptyObject, format = '', enumName = '', label, } = props;
16
+ const size = useSize(props);
17
+ const [innerHandle, setInnerHandle] = React.useState({}); // hook里挂出的属性
18
+ /** 兼容从 Form 获取属性,必须引入,自动挂载组件方法 */
19
+ const traitProps = { ...props, inputRef, setInnerHandle };
20
+ const { value: defaultValue, onChange: outerOnChange, disabled, readOnly, validateErrorMsg, validateState, visible, name, value, required, layout, } = useFormInputTrait(traitProps);
21
+ const [options, setOptions] = React.useState(format === 'x-enum' ? [] : range);
22
+ const [checkedItemValue, setCheckedItemValue] = useState(defaultValue);
23
+ const { classPrefix } = useConfig();
24
+ const platform = usePlatform();
25
+ const compClassName = `${classPrefix}-radio-group `;
26
+ // 类名
27
+ const classList = [compClassName];
28
+ ['inline'].includes(direction) &&
29
+ classList.push(`${classPrefix}-radio-group--inner `);
30
+ /**
31
+ * 在ios h5端, label和input的绑定不生效
32
+ * 导致 onChange 事件触发有问题, 所以改为监听 onClick 事件
33
+ */
34
+ const getChangeHandler = function (value) {
35
+ const onChange = function (e) {
36
+ var _a, _b;
37
+ e.stopPropagation();
38
+ if (!disabled && !readOnly) {
39
+ if (checkedItemValue && `${checkedItemValue}` === `${value}`) {
40
+ setCheckedItemValue('');
41
+ (_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: '' }, { originEvent: e });
42
+ outerOnChange === null || outerOnChange === void 0 ? void 0 : outerOnChange('');
43
+ }
44
+ else {
45
+ setCheckedItemValue(value);
46
+ (_b = events.change) === null || _b === void 0 ? void 0 : _b.call(events, { value }, { originEvent: e });
47
+ outerOnChange === null || outerOnChange === void 0 ? void 0 : outerOnChange(value);
48
+ }
49
+ }
50
+ };
51
+ return onChange;
52
+ };
53
+ useEffect(() => {
54
+ setCheckedItemValue(defaultValue);
55
+ }, [defaultValue, options]);
56
+ useEffect(() => {
57
+ if (format !== 'x-enum') {
58
+ setOptions(range);
59
+ }
60
+ }, [range, format]);
61
+ useEffect(() => {
62
+ // 如果绑定字段类型为枚举,且传入自定义选项集的名称则默认使用自定义选项集的内容作为选项
63
+ if (format === 'x-enum' && enumName) {
64
+ fetchData({ OptNameList: [enumName], PageIndex: 1, PageSize: 10 });
65
+ }
66
+ // eslint-disable-next-line react-hooks/exhaustive-deps
67
+ }, []);
68
+ React.useImperativeHandle(inputRef, () => ({
69
+ ...innerHandle,
70
+ name,
71
+ value,
72
+ label,
73
+ required,
74
+ visible,
75
+ disabled,
76
+ readOnly,
77
+ }), [innerHandle, name, value, label, required, visible, disabled, readOnly]);
78
+ const fetchData = async (param) => {
79
+ var _a, _b, _c;
80
+ const data = await callWedaApi({
81
+ action: 'DescribeGeneralOptionsDetailList',
82
+ data: param,
83
+ });
84
+ const config = (_c = destr((_b = (_a = data === null || data === void 0 ? void 0 : data.Items) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.Config)) !== null && _c !== void 0 ? _c : [];
85
+ const enumOption = config.map((item) => {
86
+ return {
87
+ label: item.value,
88
+ value: item.key,
89
+ };
90
+ });
91
+ setOptions(enumOption);
92
+ };
93
+ const labelSize = () => {
94
+ if (['h5'].includes(platform) ||
95
+ (['horizontal', ''].includes(layout) &&
96
+ ['vertical'].includes(direction))) {
97
+ return 'xs';
98
+ }
99
+ return size;
100
+ };
101
+ return (visible && (_jsx(WdFormItem, { ...props, testId: "form-radio-group", validateErrorMsg: validateErrorMsg, validateState: validateState, readValue: defaultValue, disabled: disabled, classRoot: 'radio', size: labelSize(), layout: layout, children: _jsx("div", { className: classNames(classList), children: options === null || options === void 0 ? void 0 : options.map((Item, Index) => {
102
+ return (_createElement(WdRadio, { ...props, key: Index, index: Index, size: ['h5'].includes(platform) ? 'lg' : props === null || props === void 0 ? void 0 : props.size, option: Item, disabled: disabled, readOnly: readOnly, getChangeHandler: getChangeHandler, checkedItemValue: checkedItemValue }));
103
+ }) }) })));
104
+ });
@@ -0,0 +1,3 @@
1
+ import { WdSwitch } from './wd-switch';
2
+ export { WdSwitch } from './wd-switch';
3
+ export default WdSwitch;
@@ -0,0 +1,52 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import classNames from '../../utils/classnames';
4
+ import { useConfig } from '../../utils/config-context';
5
+ import { usePlatform } from '../../utils/platform';
6
+ import { WdFormItem } from '../wd-form-item';
7
+ import getLocalCounter from '../../utils/getLocalCounter';
8
+ import { useSyncValue } from '../../utils/hooks/useSyncValue';
9
+ import { emptyObject } from '../../utils/constant';
10
+ import { useFormInputTrait } from '../form-input-hooks';
11
+ import { useSize } from '../../utils/hooks/useFormLegacy';
12
+ export const WdSwitch = React.forwardRef(function FormSwitch(props, inputRef) {
13
+ const {
14
+ // 系统属性
15
+ name, label, events = emptyObject, } = props;
16
+ const size = useSize(props);
17
+ const [innerHandle, setInnerHandle] = React.useState({}); // hook里挂出的属性
18
+ /** 兼容从 Form 获取属性,必须引入,自动挂载组件方法 */
19
+ const traitProps = { ...props, inputRef, setInnerHandle };
20
+ const { value: defaultChecked, onChange: outerOnChange, disabled, readOnly, validateErrorMsg, validateState, visible, value, required, layout, } = useFormInputTrait(traitProps);
21
+ const [checked, setChecked] = useSyncValue(defaultChecked);
22
+ const { classPrefix } = useConfig();
23
+ const platform = usePlatform();
24
+ // 现在低码组件往源码组件传入的id不唯一, 暂时使用hashcode替代
25
+ const hashcode = getLocalCounter();
26
+ const _id = `switch-${hashcode}`;
27
+ const switchCls = classNames({
28
+ 'is-checked': checked,
29
+ 'is-disabled': disabled || readOnly,
30
+ 'size-sm': !['h5'].includes(platform) && ['sm'].includes(size),
31
+ 'size-md': !['h5'].includes(platform) && ['md'].includes(size),
32
+ 'size-lg': ['h5'].includes(platform) || ['lg'].includes(size),
33
+ });
34
+ React.useImperativeHandle(inputRef, () => ({
35
+ ...innerHandle,
36
+ name,
37
+ value,
38
+ label,
39
+ required,
40
+ visible,
41
+ disabled,
42
+ readOnly,
43
+ }), [innerHandle, name, value, label, required, visible, disabled, readOnly]);
44
+ const onChange = (ev) => {
45
+ var _a;
46
+ const value = ev.target.checked;
47
+ setChecked(value);
48
+ outerOnChange === null || outerOnChange === void 0 ? void 0 : outerOnChange(value);
49
+ (_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value }, { orgianalEvent: ev });
50
+ };
51
+ return (visible && (_jsx(WdFormItem, { ...props, testId: "form-switch", validateErrorMsg: validateErrorMsg, validateState: validateState, readValue: defaultChecked, classRoot: 'switch', disabled: disabled, layout: layout, children: _jsxs("label", { className: `${classPrefix}-switch ${switchCls}`, htmlFor: _id, children: [_jsx("input", { id: _id, name: name, className: `${classPrefix}-switch__input `, type: "checkbox", checked: checked, disabled: disabled || readOnly, onChange: onChange }), _jsx("div", { className: `${classPrefix}-switch__box` })] }, _id) })));
52
+ });
@@ -16,6 +16,7 @@ import { QuoteModal } from './QuoteModal';
16
16
  import { TABLE_SLOT_PREFIX } from '../../../../utils/constant';
17
17
  import { getPrimaryField } from '../../../../utils/datasource';
18
18
  import { useConfig } from '../../../../utils/config-context';
19
+ import { EnumHoc } from '../../../../utils/hooks/EnumHoc';
19
20
  import { ImagePreview } from './ImagePreview';
20
21
  const MODAL_SIZE = 'auto';
21
22
  // 文字提示框包裹组件
@@ -208,10 +209,10 @@ export const DataItemView = ({ fields, modelType, value }) => {
208
209
  * object,展示表格组件
209
210
  */
210
211
  export const DataTableView = ({ fields, value }) => {
212
+ var _a;
211
213
  const { classPrefix } = useConfig();
214
+ const rawFields = (_a = Object === null || Object === void 0 ? void 0 : Object.entries(fields.properties)) === null || _a === void 0 ? void 0 : _a.map(([name, field]) => Object.assign({}, field, { name }));
212
215
  const columns = useMemo(() => {
213
- var _a;
214
- const rawFields = (_a = Object === null || Object === void 0 ? void 0 : Object.entries(fields.properties)) === null || _a === void 0 ? void 0 : _a.map(([name, field]) => Object.assign({}, field, { name }));
215
216
  const rawFieldsSort = rawFields.sort((a, b) => a['x-index'] - b['x-index']);
216
217
  const baseColumns = getColumns({
217
218
  columnSets: [],
@@ -219,8 +220,8 @@ export const DataTableView = ({ fields, value }) => {
219
220
  isH5: false,
220
221
  });
221
222
  return baseColumns;
222
- }, [fields]);
223
- return (_jsx(ConfigProvider, { classPrefix: classPrefix, children: _jsx(Table, { className: `${classPrefix}-table-wrap`, bordered: "all", recordKey: "_id", records: [].concat(value), columns: columns }) }));
223
+ }, [rawFields]);
224
+ return (_jsx(ConfigProvider, { classPrefix: classPrefix, children: _jsx(EnumHoc, { fields: rawFields, children: _jsx(Table, { className: `${classPrefix}-table-wrap`, bordered: "all", recordKey: "_id", records: [].concat(value), columns: columns }) }) }));
224
225
  };
225
226
  /**
226
227
  * array类型,展示组件
@@ -4,7 +4,7 @@ import { Icon, Table, StatusTip, ConfigProvider } from 'tea-component';
4
4
  import { useResizeObserver } from '@react-hookz/web';
5
5
  import { useConfig } from '../../../../utils/config-context';
6
6
  import { isInIde } from '../../../../utils/platform';
7
- const { sortable, radioable, selectable, injectable, pageable, autotip, scrollable, } = Table.addons;
7
+ const { sortable, radioable, selectable, injectable, pageable, autotip, scrollable, columnsResizable, } = Table.addons;
8
8
  import StatusContent from '../../../statusContent';
9
9
  import classNames from '../../../../utils/classnames';
10
10
  import { setTableHeaderStyle } from './util';
@@ -16,7 +16,7 @@ const miniPageSize = 10;
16
16
  const tableHeight = { sm: 500, md: 580, lg: 880 };
17
17
  const tableHeaderHeight = 51;
18
18
  // eslint-disable-next-line complexity
19
- export const BaseTableCom = ({ recordKey, className, columns, records, sortColumns, sort, onSelectChange, selectedKeys, rowColor, isError, isLoading, queryParams, total = defaultTotal, refreshTable, onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageIndex, rowClick, currentSize, isNoDataSourceBind, isH5, emptyText: _emptyText, }) => {
19
+ export const BaseTableCom = ({ recordKey, className, columns, setColumns, records, sortColumns, sort, onSelectChange, selectedKeys, rowColor, isError, isLoading, queryParams, total = defaultTotal, refreshTable, onQueryChange, enablePagination, columnSelectType, defaultPageSize, defaultPageIndex, rowClick, currentSize, isNoDataSourceBind, isH5, emptyText: _emptyText, }) => {
20
20
  var _a;
21
21
  const tableRef = useRef(null);
22
22
  const { classPrefix } = useConfig();
@@ -71,6 +71,16 @@ export const BaseTableCom = ({ recordKey, className, columns, records, sortColum
71
71
  }),
72
72
  }),
73
73
  ];
74
+ // 仅运行态可编辑
75
+ if (!isInIde()) {
76
+ tableAddons.push(columnsResizable({
77
+ onResizeEnd: (columns) => {
78
+ setColumns(columns);
79
+ },
80
+ minWidth: 92,
81
+ maxWidth: 1000,
82
+ }));
83
+ }
74
84
  // 支撑分页的最大高度
75
85
  const tableDomHeight = (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight;
76
86
  // 支持表格滚动,高度超过 500 开始显示滚动条
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react';
2
2
  import { getQueryParams } from '../utils';
3
3
  import isObjectEqual from '../../../utils/isObjectEqual';
4
4
  // const defaultCount = 1;
5
- export const useQueryParams = ({ queryParams, wList, viewFieldsData, connectorParams, isModel, isViewTable, events, }) => {
5
+ export const useQueryParams = ({ queryParams, wList, viewFieldsData, connectorParams, isModel, isViewTable, events, columns, }) => {
6
6
  const queryRef = useRef({});
7
7
  const [query, setQuery] = useState(() => {
8
8
  return getQueryParams({
@@ -12,6 +12,7 @@ export const useQueryParams = ({ queryParams, wList, viewFieldsData, connectorPa
12
12
  connectorParams,
13
13
  isModel,
14
14
  isViewTable,
15
+ columns,
15
16
  });
16
17
  });
17
18
  useEffect(() => {
@@ -23,6 +24,7 @@ export const useQueryParams = ({ queryParams, wList, viewFieldsData, connectorPa
23
24
  connectorParams,
24
25
  isModel,
25
26
  isViewTable,
27
+ columns,
26
28
  });
27
29
  if (!isObjectEqual(queryRef.current, query)) {
28
30
  queryRef.current = query;
@@ -36,6 +38,7 @@ export const useQueryParams = ({ queryParams, wList, viewFieldsData, connectorPa
36
38
  queryParams,
37
39
  viewFieldsData,
38
40
  wList,
41
+ columns,
39
42
  ]);
40
43
  return { query };
41
44
  };