@cloudbase/weda-ui 3.21.2 → 3.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import { useState, useCallback, useRef, useEffect } from 'react';
3
3
  import { useConfig } from '../../utils/config-context';
4
4
  import { usePlatform } from '../../utils/platform';
5
5
  import WdIcon from '../wd-icon';
6
- import { useSyncedRef } from '@react-hookz/web';
6
+ import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web';
7
7
  import { renderSlot } from './util';
8
8
  export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProps }) => {
9
9
  const { classPrefix } = useConfig();
@@ -57,27 +57,29 @@ export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
57
57
  useEffect(() => {
58
58
  setSelectedTab(selectedIndex);
59
59
  }, [selectedIndex]);
60
+ const debouncedChangeEvent = useDebouncedCallback((value) => {
61
+ var _a;
62
+ (_a = restProps === null || restProps === void 0 ? void 0 : restProps.events) === null || _a === void 0 ? void 0 : _a.change(value);
63
+ }, [restProps],
64
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
65
+ 300);
60
66
  // 渲染菜单
61
67
  const RenderTabItem = (index, item) => {
62
68
  return (_jsxs("div", { className: `${classPrefix}-tabs__item ${(item === null || item === void 0 ? void 0 : item.selected) ? 'is-selected' : ''} ${(item === null || item === void 0 ? void 0 : item.isDisabled) ? 'is-disabled' : ''}`, onClick: () => {
63
- var _a, _b, _c, _d, _e, _f, _g;
69
+ var _a, _b, _c, _d, _e, _f;
64
70
  if (!(item === null || item === void 0 ? void 0 : item.isDisabled) && !(item === null || item === void 0 ? void 0 : item.selected)) {
65
71
  if (restProps.direction !== 'vertical') {
66
72
  const parentWidths = (_b = (_a = navWrapRef === null || navWrapRef === void 0 ? void 0 : navWrapRef.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.clientWidth;
67
73
  const result = parentWidths * ((position === null || position === void 0 ? void 0 : position.index) + Number('1')) -
68
- (((_c = itemOffsetData.get(index)) === null || _c === void 0 ? void 0 : _c.clientWidth) +
69
- ((_d = itemOffsetData.get(index)) === null || _d === void 0 ? void 0 : _d.offset));
70
- if (result >= 0 &&
71
- itemOffsetData.get(index).offset <=
72
- parentWidths * (position === null || position === void 0 ? void 0 : position.index)) {
74
+ (((_c = itemOffsetData.get(index)) === null || _c === void 0 ? void 0 : _c.clientWidth) + ((_d = itemOffsetData.get(index)) === null || _d === void 0 ? void 0 : _d.offset));
75
+ if (result >= 0 && itemOffsetData.get(index).offset <= parentWidths * (position === null || position === void 0 ? void 0 : position.index)) {
73
76
  setPosition({
74
77
  index: position.index,
75
78
  offset: -itemOffsetData.get(index).offset,
76
79
  });
77
80
  }
78
81
  // 大于父级容器
79
- if (result < 0 &&
80
- result - parentWidths * (position === null || position === void 0 ? void 0 : position.index) < position.offset) {
82
+ if (result < 0 && result - parentWidths * (position === null || position === void 0 ? void 0 : position.index) < position.offset) {
81
83
  setPosition({
82
84
  index: position.index,
83
85
  offset: result + position.offset,
@@ -89,13 +91,11 @@ export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
89
91
  // HACK widget 时序
90
92
  if ((_f = (_e = $node.current) === null || _e === void 0 ? void 0 : _e._getInstanceRef()) === null || _f === void 0 ? void 0 : _f.current) {
91
93
  const currentSelectedValue = item === null || item === void 0 ? void 0 : item.value;
92
- if (currentSelectedValue !==
93
- $node.current._getInstanceRef().current.selectedValue) {
94
- $node.current._getInstanceRef().current.selectedValue =
95
- currentSelectedValue;
94
+ if (currentSelectedValue !== $node.current._getInstanceRef().current.selectedValue) {
95
+ $node.current._getInstanceRef().current.selectedValue = currentSelectedValue;
96
96
  }
97
97
  }
98
- (_g = restProps === null || restProps === void 0 ? void 0 : restProps.events) === null || _g === void 0 ? void 0 : _g.change({ value: item === null || item === void 0 ? void 0 : item.value });
98
+ debouncedChangeEvent({ value: item === null || item === void 0 ? void 0 : item.value });
99
99
  }
100
100
  }, children: [(item === null || item === void 0 ? void 0 : item.iconType) !== 'none' && (item === null || item === void 0 ? void 0 : item.iconPosition) === 'prefix' ? (_jsx("div", { className: `${classPrefix}-tabs__item-icon`, children: _jsx(WdIcon, { type: item === null || item === void 0 ? void 0 : item.iconType, name: (item === null || item === void 0 ? void 0 : item.iconType) === 'inner' ? item === null || item === void 0 ? void 0 : item.innerIcon : item === null || item === void 0 ? void 0 : item.outerImage, src: (item === null || item === void 0 ? void 0 : item.iconType) === 'custom' ? item === null || item === void 0 ? void 0 : item.outerImage : '', size: "xs" }) })) : null, _jsx("div", { className: `${classPrefix}-tabs__item-text`, children: item === null || item === void 0 ? void 0 : item.label }), (item === null || item === void 0 ? void 0 : item.iconType) !== 'none' && (item === null || item === void 0 ? void 0 : item.iconPosition) === 'suffix' ? (_jsx("div", { className: `${classPrefix}-tabs__item-icon`, children: _jsx(WdIcon, { type: item === null || item === void 0 ? void 0 : item.iconType, name: (item === null || item === void 0 ? void 0 : item.iconType) === 'inner' ? item === null || item === void 0 ? void 0 : item.innerIcon : item === null || item === void 0 ? void 0 : item.outerImage, src: (item === null || item === void 0 ? void 0 : item.iconType) === 'custom' ? item === null || item === void 0 ? void 0 : item.outerImage : '', size: "xs" }) })) : null] }));
101
101
  };
@@ -108,8 +108,7 @@ export const WdTabsPc = ({ isMultipleSlot, tabsDatas, selectedIndex, ...restProp
108
108
  });
109
109
  } })), _jsx("div", { className: `${classPrefix}-tabs__header-item-wrap`, children: _jsx("div", { ref: navWrapRef, className: `${classPrefix}-tabs__header-item-content`, style: {
110
110
  transform: `translate(${position.offset}px, 0px)`,
111
- }, children: tabsDatas === null || tabsDatas === void 0 ? void 0 : tabsDatas.map((item, index) => RenderTabItem(index, item)) }) }), showButton &&
112
- position.index + Number('2') < Object.keys(menuOffset).length && (_jsx("div", { className: `${classPrefix}-tabs__header-nav-right`, onClick: () => {
111
+ }, children: tabsDatas === null || tabsDatas === void 0 ? void 0 : tabsDatas.map((item, index) => RenderTabItem(index, item)) }) }), showButton && position.index + Number('2') < Object.keys(menuOffset).length && (_jsx("div", { className: `${classPrefix}-tabs__header-nav-right`, onClick: () => {
113
112
  const result = menuPosition - menuOffset[position.index + Number('1')];
114
113
  setMenuPosition(result);
115
114
  setPosition({
@@ -81,7 +81,7 @@ export const getFieldsTypeName = (fields) => {
81
81
  else if (type === 'number' && format === 'time') {
82
82
  item.fieldsTypeName = '时间';
83
83
  }
84
- else if (type === 'string' && format === 'x-enum') {
84
+ else if (['string', 'array'].includes(type) && format === 'x-enum') {
85
85
  item.fieldsTypeName = '枚举';
86
86
  }
87
87
  else if (type === 'object' && format === 'x-location') {
@@ -102,6 +102,9 @@ export const getFieldsTypeName = (fields) => {
102
102
  else if (type === 'string' && format === 'related' && fatherAction === 'related') {
103
103
  item.fieldsTypeName = '主子明细';
104
104
  }
105
+ else if (type === 'string' && format === 'related') {
106
+ item.fieldsTypeName = '主子明细';
107
+ }
105
108
  else if (type === 'string' && format === 'father-son') {
106
109
  item.fieldsTypeName = '关联关系';
107
110
  }
@@ -117,6 +120,21 @@ export const getFieldsTypeName = (fields) => {
117
120
  else if (type === 'array' && format === 'one-many') {
118
121
  item.fieldsTypeName = '一对多';
119
122
  }
123
+ else if (format === 'many-one') {
124
+ item.fieldsTypeName = '多对一';
125
+ }
126
+ else if (format === 'one-one') {
127
+ item.fieldsTypeName = '一对一';
128
+ }
129
+ else if (format === 'many-many') {
130
+ item.fieldsTypeName = '多对多';
131
+ }
132
+ else if (format === 'one-many') {
133
+ item.fieldsTypeName = '一对多';
134
+ }
135
+ else if (type === 'string' && format === 'tel') {
136
+ item.fieldsTypeName = '电话';
137
+ }
120
138
  return item;
121
139
  });
122
140
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/weda-ui",
3
- "version": "3.21.2",
3
+ "version": "3.21.4",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index",
6
6
  "miniprogram": "mpdist",