@cloudbase/weda-ui 3.6.2 → 3.6.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.
@@ -7,8 +7,8 @@ const pattern = {
7
7
  cnName: /^[\u2E80-\uFE4F]{2,6}(?:·[\u2E80-\uFE4F]{2,6})*$/,
8
8
  userName: /^[\da-zA-Z\u2E80-\uFE4F \s]{2,}$/,
9
9
  carId: /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/,
10
- mobile: /^1[3456789]\d{9}$/,
11
- tel: /^(0\d{2,3}-)?(\d{7,8})$/,
10
+ mobile: /^(\+\d{1,4}[\s-]?)?(\(?\d{1,4}\)?[\s-]?)?(\d{1,4}[\s-]?)?(\d{1,4})?\d{1,9}(\s?(x|ext)\s?\d{1,6})?$/,
11
+ tel: /^(\+\d{1,4}[\s-]?)?(\(?\d{1,4}\)?[\s-]?)?(\d{1,4}[\s-]?)?(\d{1,4})?\d{1,9}(\s?(x|ext)\s?\d{1,6})?$/,
12
12
  address: /^[\da-zA-Z\u2E80-\uFE4F \s-]{4,400}$/,
13
13
  date: /((^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(10|12|0?[13578])([-\/\._])(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(11|0?[469])([-\/\._])(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(0?2)([-\/\._])(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([3579][26]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][13579][26])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][13579][26])([-\/\._])(0?2)([-\/\._])(29)$))/,
14
14
  numVcode: /^[0-9]{4,8}$/,
@@ -39,7 +39,7 @@ export const MenuLogo = React.memo(function MenuLogo({ navigationStyle, classNam
39
39
  });
40
40
  // icon回显
41
41
  export const IconShow = ({ onIcon, menuColor, menuFontSize }) => {
42
- return (_jsx(_Fragment, { children: (onIcon === null || onIcon === void 0 ? void 0 : onIcon.includes('td:')) ? (_jsx(IconFont, { name: onIcon === null || onIcon === void 0 ? void 0 : onIcon.split(':')[1], className: `${CLASS_PREFIX}__fonticon`, style: { color: menuColor, fontSize: menuFontSize } })) : (_jsx("div", { className: `${CLASS_PREFIX}__fonticon lcap-icon lcap-icon-${onIcon}`, style: { color: menuColor, fontSize: menuFontSize } })) }));
42
+ return (_jsx(_Fragment, { children: (onIcon === null || onIcon === void 0 ? void 0 : onIcon.includes('td:')) ? (_jsx(IconFont, { name: onIcon === null || onIcon === void 0 ? void 0 : onIcon.split(':')[1], className: `${CLASS_PREFIX}__fonticon wd-icon`, style: { color: menuColor, fontSize: menuFontSize } })) : (_jsx("div", { className: `${CLASS_PREFIX}__fonticon lcap-icon lcap-icon-${onIcon}`, style: { color: menuColor, fontSize: menuFontSize } })) }));
43
43
  };
44
44
  // 菜单图标
45
45
  export const renderMenuIcon = (iconUrl, iconPath, navigationStyle) => {
@@ -94,7 +94,8 @@
94
94
  background-color: #f5f7fa;
95
95
  }
96
96
  .weda-RichTextView table td {
97
- background-color: white;
97
+ background-color: #ffffff;
98
+ text-align: center;
98
99
  }
99
100
  .weda-RichTextView table th > p,
100
101
  .weda-RichTextView table td > p {
@@ -81,10 +81,10 @@ export declare const WdInput: React.ForwardRefExoticComponent<CommonPropsType &
81
81
  }]>> & {
82
82
  wrapClassName?: string;
83
83
  classRoot?: string;
84
- inputPattern?: string;
84
+ inputPattern?: RegExp;
85
85
  } & React.RefAttributes<any>>;
86
86
  export type WdInputProps = CommonPropsType & DataType & EventsType & {
87
87
  wrapClassName?: string;
88
88
  classRoot?: string;
89
- inputPattern?: string;
89
+ inputPattern?: RegExp;
90
90
  };
@@ -9,6 +9,6 @@ const rules = [{ format: 'mobile', message: '手机校验失败' }];
9
9
  export const WdInputPhone = forwardRef(function WdInputPhone(props, ref) {
10
10
  const { classPrefix } = useConfig();
11
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 }));
12
+ const pattern = /^[()\d\s+-ext]{0,20}$/;
13
+ return (_jsx(WdInput, { ...props, inputPattern: pattern, maxLength: 20, wrapClassName: wrapCls, classRoot: "input-phone", rules: rules, ref: ref }));
14
14
  });
@@ -184,19 +184,22 @@ const getSearchValues = (searchValues) => {
184
184
  };
185
185
  });
186
186
  };
187
- const getPageParam = (_sort, params, _defaultPageSize, _defaultPageIndex, supportManyRelated, columns, isSupportMultipleSort) => {
187
+ const getPageParam = ({ defaultSort, sort: _sort, params, _defaultPageSize, _defaultPageIndex, supportManyRelated, columns, isSupportMultipleSort, }) => {
188
+ let sort = defaultSort;
189
+ // 运行态有值,以运行态为准
190
+ if ((_sort === null || _sort === void 0 ? void 0 : _sort.length) && _sort[0].order) {
191
+ params.orderBy = _sort[0].by;
192
+ params.orderType = _sort[0].order;
193
+ sort = _sort;
194
+ }
188
195
  // 后端根据业务字段排序
189
- const sort = _sort.map((n) => {
196
+ sort = sort.map((n) => {
190
197
  var _a;
191
198
  return ({
192
199
  ...n,
193
200
  by: ((_a = columns === null || columns === void 0 ? void 0 : columns.find((i) => n.by === i.slotKey)) === null || _a === void 0 ? void 0 : _a.fieldKey) || n.by,
194
201
  });
195
202
  });
196
- if ((sort === null || sort === void 0 ? void 0 : sort.length) && sort[0].order) {
197
- params.orderBy = sort[0].by;
198
- params.orderType = sort[0].order;
199
- }
200
203
  const _pageSize = parseInt(`${params.pageSize}`);
201
204
  params.pageSize = isNaN(_pageSize) ? _defaultPageSize : _pageSize;
202
205
  const _pageNo = parseInt(`${params.pageNo}`);
@@ -219,7 +222,7 @@ export const getQueryParams = ({ queryParams, wList, viewFieldsData, connectorPa
219
222
  var _a, _b;
220
223
  const _defaultPageSize = 10;
221
224
  const _defaultPageIndex = 1;
222
- const { pageIndex: pageNo, pageSize, sort } = queryParams;
225
+ const { pageIndex: pageNo, pageSize, sort, defaultSort } = queryParams;
223
226
  let params = {
224
227
  pageNo,
225
228
  pageSize,
@@ -266,7 +269,16 @@ export const getQueryParams = ({ queryParams, wList, viewFieldsData, connectorPa
266
269
  params = Object.assign({}, connectorParams, params);
267
270
  }
268
271
  // 运行态主动排序进行覆盖
269
- params = getPageParam(sort, params, _defaultPageSize, _defaultPageIndex, supportManyRelated, columns, isSupportMultipleSort);
272
+ params = getPageParam({
273
+ defaultSort,
274
+ sort,
275
+ params,
276
+ _defaultPageSize,
277
+ _defaultPageIndex,
278
+ supportManyRelated,
279
+ columns,
280
+ isSupportMultipleSort,
281
+ });
270
282
  return params;
271
283
  };
272
284
  // 获取视图
@@ -151,10 +151,11 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
151
151
  const [queryParams, setQueryParams] = useState({
152
152
  pageIndex: initPageIndex,
153
153
  pageSize: initPageSize,
154
- sort: _sort,
154
+ sort: [],
155
155
  searchValues: [],
156
156
  orderBy,
157
157
  orderType,
158
+ defaultSort: _sort,
158
159
  });
159
160
  const columnSetsKey = columnSets === null || columnSets === void 0 ? void 0 : columnSets.map((i) => i.key);
160
161
  // 过滤权限字段
@@ -629,7 +630,8 @@ export const WdTable = forwardRef(function TableComp(tableProps, ref) {
629
630
  pageSize: defaultPageSize,
630
631
  orderBy: orderBy,
631
632
  orderType: orderType,
632
- sort: _sort,
633
+ defaultSort: _sort,
634
+ sort: [],
633
635
  }));
634
636
  }
635
637
  else {
@@ -0,0 +1 @@
1
+ export declare function getHeight(id: any): number | "auto";
@@ -0,0 +1,45 @@
1
+ const HIDDEN_TEXTAREA_STYLE = `
2
+ min-height:0 !important;
3
+ max-height:none !important;
4
+ height:0 !important;
5
+ visibility:hidden !important;
6
+ overflow-y:hidden !important;
7
+ position:absolute !important;
8
+ z-index:-1000 !important;
9
+ top:0 !important;
10
+ right:0 !important
11
+ `;
12
+ const SIZING_PROPS = [
13
+ 'letter-spacing',
14
+ 'line-height',
15
+ 'padding-top',
16
+ 'padding-bottom',
17
+ 'font-family',
18
+ 'font-weight',
19
+ 'font-size',
20
+ 'font-variant',
21
+ 'text-rendering',
22
+ 'text-transform',
23
+ 'width',
24
+ 'text-indent',
25
+ 'padding-left',
26
+ 'padding-right',
27
+ 'border-width',
28
+ 'box-sizing',
29
+ ];
30
+ export function getHeight(id) {
31
+ const textarea = document.getElementById(id);
32
+ if (!textarea)
33
+ return 'auto';
34
+ const style = window.getComputedStyle(textarea);
35
+ const value = textarea.value || textarea.placeholder;
36
+ const sizingStyle = SIZING_PROPS.map((name) => `${name}:${style.getPropertyValue(name)}`).join(';');
37
+ let hiddenText = document.createElement('textarea');
38
+ hiddenText.setAttribute('style', `${sizingStyle};${HIDDEN_TEXTAREA_STYLE}`);
39
+ hiddenText.value = value;
40
+ document.body.appendChild(hiddenText);
41
+ const height = hiddenText.scrollHeight;
42
+ document.body.removeChild(hiddenText);
43
+ hiddenText = null;
44
+ return height;
45
+ }
@@ -7,6 +7,7 @@ import { useFormInputTrait } from '../form-input-hooks';
7
7
  import { filterPropsWithOn, getUuid } from '../../utils/tool';
8
8
  import { useSize } from '../../utils/hooks/useFormLegacy';
9
9
  import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default';
10
+ import { getHeight } from './calcTextareaHeight';
10
11
  /**
11
12
  * 标准化:多行输入组件
12
13
  */
@@ -40,16 +41,13 @@ export const WdTextarea = forwardRef(function WdTextarea(props, ref) {
40
41
  const autoScroll = function () {
41
42
  if (!autoHeight || !textareaRef.current)
42
43
  return;
43
- textareaRef.current.style.height = 'auto';
44
- if (textareaRef.current.scrollHeight >= textareaRef.current.offsetHeight) {
45
- textareaRef.current.style.height =
46
- textareaRef.current.scrollHeight + 'px';
47
- }
44
+ const height = getHeight(inputId);
45
+ textareaRef.current.style.height = height + 'px';
48
46
  };
49
47
  useEffect(() => {
50
48
  autoScroll();
51
49
  // eslint-disable-next-line react-hooks/exhaustive-deps
52
- }, [autoHeight]);
50
+ }, [autoHeight, inputId]);
53
51
  /** 内部事件 */
54
52
  const onChange = function (e) {
55
53
  var _a;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.6.2",
3
+ "version": "3.6.5",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",