@cloudbase/weda-ui-mp 3.25.1 → 3.26.0

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.
@@ -95,7 +95,7 @@ export function transform(chartType, dataInput, chartInput) {
95
95
  if (!series[idx]) {
96
96
  series[idx] = {
97
97
  type: chartType,
98
- name: chartType === 'pie' ? undefined : eachYaxis.Cn_Name ?? eachYaxis.Name,
98
+ name: chartType === 'pie' ? undefined : eachYaxis?.Cn_Name ?? eachYaxis?.Name,
99
99
  stack: chartInput.isPile ? 'pile' : undefined,
100
100
  showSymbol: chartType === 'pie' ? undefined : chartInput.isSeriesShowSymbol,
101
101
  label: {
@@ -111,11 +111,11 @@ export function transform(chartType, dataInput, chartInput) {
111
111
  chartType === 'pie'
112
112
  ? [
113
113
  {
114
- value: eachYaxis.Value,
114
+ value: eachYaxis?.Value,
115
115
  name: item.XLabel.Value.toString(),
116
116
  },
117
117
  ]
118
- : [eachYaxis.Value],
118
+ : [eachYaxis?.Value],
119
119
  };
120
120
 
121
121
  if (chartInput.isUnit || chartInput.isPercent) {
@@ -124,11 +124,11 @@ export function transform(chartType, dataInput, chartInput) {
124
124
  } else {
125
125
  if (chartType === 'pie') {
126
126
  series[idx].data.push({
127
- value: eachYaxis.Value,
127
+ value: eachYaxis?.Value,
128
128
  name: item.XLabel.Value.toString(),
129
129
  });
130
130
  } else {
131
- series[idx].data.push(eachYaxis.Value);
131
+ series[idx].data.push(eachYaxis?.Value);
132
132
  }
133
133
  }
134
134
 
@@ -175,8 +175,8 @@ export function transform(chartType, dataInput, chartInput) {
175
175
  item.YLabels.forEach((eachYaxis) => {
176
176
  if (eachYaxis.Group_Name) {
177
177
  series[groups.indexOf(eachYaxis.Group_Name)].data.push({
178
- value: eachYaxis.Value,
179
- name: eachYaxis.Cn_Name ?? eachYaxis.Name,
178
+ value: eachYaxis?.Value,
179
+ name: eachYaxis?.Cn_Name ?? eachYaxis?.Name,
180
180
  });
181
181
 
182
182
  for (let i = 0; i < groups.length; i++) {
@@ -0,0 +1,199 @@
1
+ import classNames from '../../utils/classnames';
2
+ import { commonCompBehavior } from '../../utils/common-behavior';
3
+ import { WD_PREFIX } from '../../utils/constant';
4
+ import { WD_DRAWER_PLACEMENT } from '../../utils/enum';
5
+ import { convertLegacyEnum } from '../../utils/platform';
6
+ const DEFAULT_DURATION = 300;
7
+ Component({
8
+ options: {
9
+ virtualHost: true,
10
+ multipleSlots: true,
11
+ },
12
+ behaviors: [commonCompBehavior],
13
+ properties: {
14
+ className: {
15
+ type: String,
16
+ value: '',
17
+ },
18
+ style: {
19
+ type: String,
20
+ value: '',
21
+ },
22
+ id: {
23
+ type: String,
24
+ value: '',
25
+ },
26
+ visible: {
27
+ type: Boolean,
28
+ value: false,
29
+ },
30
+ closeType: {
31
+ type: Array,
32
+ value: ['outerClick'],
33
+ },
34
+ mask: {
35
+ type: Boolean,
36
+ value: true,
37
+ },
38
+ placement: {
39
+ type: String,
40
+ value: 'right',
41
+ },
42
+ enableHeaderSlot: {
43
+ type: Boolean,
44
+ value: true,
45
+ },
46
+ enableContentSlot: {
47
+ type: Boolean,
48
+ value: true,
49
+ },
50
+ enableFooterSlot: {
51
+ type: Boolean,
52
+ value: false,
53
+ },
54
+ },
55
+ data: {
56
+ cls: '',
57
+ styleMain: '',
58
+ classPrefix: WD_PREFIX,
59
+ isrDrawerShow: false, // 抽屉主体内容显示控制
60
+ openInfo: null,
61
+ closeInfo: null,
62
+ drawerMaskClasses: '', // 遮罩层样式
63
+ drawerClasses: '', // 主体内容样式
64
+ animatedStatus: 'enter-active',
65
+ drawerStyle: '',
66
+ },
67
+ lifetimes: {
68
+ attached() {
69
+ this.updateWidgetAPI();
70
+ },
71
+ detached() {
72
+ // 组件卸载时清理定时器
73
+ clearTimeout(this.openTimer);
74
+ clearTimeout(this.activeTimer);
75
+ },
76
+ },
77
+ methods: {
78
+ updateWidgetAPI() {
79
+ this.setReadonlyAttributes &&
80
+ this.setReadonlyAttributes({
81
+ open: this.onOpen.bind(this),
82
+ close: this.onClose.bind(this),
83
+ modalState: this.data.isrDrawerShow ? 'open' : 'close',
84
+ openInfo: this.data.openInfo,
85
+ closeInfo: this.data.closeInfo,
86
+ });
87
+ },
88
+ /**
89
+ * 控制抽屉打开/关闭
90
+ * @param {Boolean} isOpen
91
+ */
92
+ dealShow(isOpen, params, isTrigger = true) {
93
+ const openDuration = isOpen ? 0 : DEFAULT_DURATION;
94
+ const closeDuration = isOpen ? DEFAULT_DURATION : 0;
95
+ // 设置抽屉动画(受控定时器,防止泄漏)
96
+ clearTimeout(this.openTimer);
97
+ clearTimeout(this.activeTimer);
98
+ // eslint-disable-next-line rulesdir/no-timer
99
+ this.openTimer = setTimeout(() => {
100
+ this.setData({
101
+ isrDrawerShow: isOpen,
102
+ animatedStatus: isOpen ? 'enter' : 'exit',
103
+ });
104
+ }, openDuration);
105
+ // eslint-disable-next-line rulesdir/no-timer
106
+ this.activeTimer = setTimeout(() => {
107
+ this.setData({
108
+ animatedStatus: isOpen ? 'enter-active' : 'exit-active',
109
+ });
110
+ }, closeDuration);
111
+
112
+ if (isTrigger) {
113
+ this.triggerEvent(isOpen ? 'open' : 'close', params);
114
+ }
115
+ },
116
+ /**
117
+ * 关闭抽屉
118
+ */
119
+ onClose(params) {
120
+ this.dealShow(false, params);
121
+ this.setData({
122
+ closeInfo: params?.info || params,
123
+ });
124
+ },
125
+ /**
126
+ * 开启抽屉
127
+ */
128
+ onOpen(params) {
129
+ this.dealShow(true, params);
130
+ this.setData({
131
+ openInfo: params?.info || params,
132
+ });
133
+ },
134
+ /**
135
+ * 点击遮罩层
136
+ */
137
+ maskClick() {
138
+ if (this.data.closeType.includes('outerClick')) {
139
+ this.onClose();
140
+ }
141
+ },
142
+ },
143
+ observers: {
144
+ 'style,className,mask,placement,animatedStatus': function (style, className, mask, placement, animatedStatus) {
145
+ const styleMain = style?.match(/(display:).*?(;)/g)?.join('');
146
+ // 响应式css api
147
+ const cls = classNames({
148
+ [`${WD_PREFIX}-drawer`]: true,
149
+ [`${WD_PREFIX}-mp-drawer`]: true,
150
+ [className]: className,
151
+ });
152
+ // 遮罩层样式
153
+ const drawerMaskClasses = classNames({
154
+ [`${WD_PREFIX}-drawer-mask`]: mask,
155
+ [`${WD_PREFIX}-drawer-overlay`]: !mask,
156
+ [`${WD_PREFIX}-drawer-mask-${animatedStatus}`]: true,
157
+ });
158
+
159
+ // 主体内容样式
160
+ const _placement = convertLegacyEnum(placement, WD_DRAWER_PLACEMENT, 'right');
161
+ const drawerClasses = classNames({
162
+ [`${WD_PREFIX}-drawer-content-wrapper`]: true,
163
+ [`${WD_PREFIX}-drawer-${_placement}`]: true,
164
+ [`${WD_PREFIX}-drawer-${_placement}-${animatedStatus}`]: true,
165
+ });
166
+
167
+ let drawerStyle = style;
168
+ if (['right', 'left'].includes(_placement)) {
169
+ drawerStyle =
170
+ 'height:100%;' +
171
+ drawerStyle
172
+ .split(';')
173
+ .filter((item) => !item?.trim()?.startsWith('height:'))
174
+ .join(';');
175
+ } else {
176
+ drawerStyle =
177
+ 'width:100%;' +
178
+ drawerStyle
179
+ .split(';')
180
+ .filter((item) => !item?.trim()?.startsWith('width:'))
181
+ .join(';');
182
+ }
183
+
184
+ this.setData({
185
+ styleMain,
186
+ cls,
187
+ drawerMaskClasses,
188
+ drawerClasses,
189
+ drawerStyle,
190
+ });
191
+ },
192
+ visible: function (visible) {
193
+ this.dealShow(visible, {}, false);
194
+ },
195
+ 'isrDrawerShow,openInfo,closeInfo': function () {
196
+ this.updateWidgetAPI();
197
+ },
198
+ },
199
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "shared",
4
+ "usingComponents": {}
5
+ }
@@ -0,0 +1,24 @@
1
+ <view id="{{id}}" style="{{styleMain}}" class="{{cls}}">
2
+ <block wx:if="{{isrDrawerShow}}">
3
+ <!-- 遮罩层 -->
4
+ <view class="{{drawerMaskClasses}}" bindtap="maskClick" />
5
+ <!-- 抽屉主体 -->
6
+ <view class="{{drawerClasses}}" style="{{drawerStyle}}">
7
+ <!-- 抽屉头部 -->
8
+ <view wx:if="{{enableHeaderSlot}}" class="{{classPrefix + '-drawer-header'}}">
9
+ <slot name="headerSlot"></slot>
10
+ </view>
11
+
12
+ <!-- 抽屉内容 -->
13
+ <view wx:if="{{enableContentSlot}}" class="{{classPrefix + '-drawer-body'}}">
14
+ <slot name="contentSlot"></slot>
15
+
16
+ </view>
17
+
18
+ <!-- 抽屉底部 -->
19
+ <view wx:if="{{enableFooterSlot}}" class="{{classPrefix + '-drawer-footer'}}">
20
+ <slot name="footerSlot"></slot>
21
+ </view>
22
+ </view>
23
+ </block>
24
+ </view>
@@ -0,0 +1,2 @@
1
+ @import '../../style/wd-design.wxss';
2
+ @import './wd-drawer.wxss';
@@ -0,0 +1,162 @@
1
+ @charset "UTF-8";
2
+ ._B00_Xa {
3
+ /* 如果生成的wxss 为空文件似乎会导致IDE编译报错, 所以这里给他弄个占位 */
4
+ word-break: inherit;
5
+ }
6
+
7
+ .wd-pc-drawer {
8
+ --wd-drawer-width: 23.625rem;
9
+ --wd-drawer-height: 23.625rem;
10
+ }
11
+
12
+ .wd-h5-drawer,
13
+ .wd-mp-drawer {
14
+ --wd-drawer-width: 17.5rem;
15
+ --wd-drawer-height: 17.5rem;
16
+ }
17
+
18
+ .wd-drawer-mask {
19
+ position: fixed;
20
+ top: 0;
21
+ left: 0;
22
+ width: 100%;
23
+ height: 100%;
24
+ background-color: rgba(0, 0, 0, 0.45);
25
+ z-index: 999;
26
+ }
27
+ .wd-drawer-mask-enter {
28
+ opacity: 0;
29
+ }
30
+ .wd-drawer-mask-enter-active {
31
+ opacity: 1;
32
+ transition: opacity 0.3s ease-in-out;
33
+ }
34
+ .wd-drawer-mask-exit {
35
+ opacity: 1;
36
+ }
37
+ .wd-drawer-mask-exit-active {
38
+ opacity: 0;
39
+ transition: opacity 0.3s ease-in-out;
40
+ }
41
+
42
+ .wd-drawer-content-wrapper {
43
+ position: fixed;
44
+ background: #fff;
45
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
46
+ display: flex;
47
+ flex-direction: column;
48
+ z-index: 1000;
49
+ }
50
+ .wd-drawer-right {
51
+ top: 0;
52
+ right: 0;
53
+ height: 100%;
54
+ width: var(--wd-drawer-width);
55
+ }
56
+ .wd-drawer-right-enter {
57
+ transform: translateX(100%);
58
+ }
59
+ .wd-drawer-right-enter-active {
60
+ transform: translateX(0);
61
+ transition: transform 0.3s ease-in-out;
62
+ }
63
+ .wd-drawer-right-exit {
64
+ transform: translateX(0);
65
+ }
66
+ .wd-drawer-right-exit-active {
67
+ transform: translateX(100%);
68
+ transition: transform 0.3s ease-in-out;
69
+ }
70
+ .wd-drawer-left {
71
+ top: 0;
72
+ left: 0;
73
+ height: 100%;
74
+ width: var(--wd-drawer-width);
75
+ }
76
+ .wd-drawer-left-enter {
77
+ transform: translateX(-100%);
78
+ }
79
+ .wd-drawer-left-enter-active {
80
+ transform: translateX(0);
81
+ transition: transform 0.3s ease-in-out;
82
+ }
83
+ .wd-drawer-left-exit {
84
+ transform: translateX(0);
85
+ }
86
+ .wd-drawer-left-exit-active {
87
+ transform: translateX(-100%);
88
+ transition: transform 0.3s ease-in-out;
89
+ }
90
+ .wd-drawer-top {
91
+ top: 0;
92
+ left: 0;
93
+ width: 100%;
94
+ height: var(--wd-drawer-height);
95
+ }
96
+ .wd-drawer-top-enter {
97
+ transform: translateY(-100%);
98
+ }
99
+ .wd-drawer-top-enter-active {
100
+ transform: translateY(0);
101
+ transition: transform 0.3s ease-in-out;
102
+ }
103
+ .wd-drawer-top-exit {
104
+ transform: translateY(0);
105
+ }
106
+ .wd-drawer-top-exit-active {
107
+ transform: translateY(-100%);
108
+ transition: transform 0.3s ease-in-out;
109
+ }
110
+ .wd-drawer-bottom {
111
+ bottom: 0;
112
+ left: 0;
113
+ width: 100%;
114
+ height: var(--wd-drawer-height);
115
+ }
116
+ .wd-drawer-bottom-enter {
117
+ transform: translateY(100%);
118
+ }
119
+ .wd-drawer-bottom-enter-active {
120
+ transform: translateY(0);
121
+ transition: transform 0.3s ease-in-out;
122
+ }
123
+ .wd-drawer-bottom-exit {
124
+ transform: translateY(0);
125
+ }
126
+ .wd-drawer-bottom-exit-active {
127
+ transform: translateY(100%);
128
+ transition: transform 0.3s ease-in-out;
129
+ }
130
+ .wd-drawer-header {
131
+ display: flex;
132
+ align-items: center;
133
+ justify-content: space-between;
134
+ padding: 20px 24px;
135
+ border-bottom: 1px solid #f0f0f0;
136
+ flex-shrink: 0;
137
+ }
138
+ .wd-drawer-body {
139
+ flex: 1;
140
+ padding: 20px 24px;
141
+ overflow-y: auto;
142
+ }
143
+ .wd-drawer-footer {
144
+ border-top: 1px solid #f0f0f0;
145
+ padding: 20px 24px;
146
+ }
147
+
148
+ .wd-drawer-content-wrapper {
149
+ padding-bottom: constant(safe-area-inset-bottom);
150
+ /* 兼容 iOS < 11.2 */
151
+ padding-bottom: env(safe-area-inset-bottom);
152
+ /* 兼容 iOS >= 11.2 */
153
+ }
154
+
155
+ .wd-drawer-overlay {
156
+ position: fixed;
157
+ top: 0;
158
+ left: 0;
159
+ width: 100%;
160
+ height: 100%;
161
+ z-index: 999;
162
+ }
@@ -1,7 +1,6 @@
1
1
  import classNames from '../../utils/classnames';
2
2
  import { commonCompBehavior } from '../../utils/common-behavior';
3
3
  import { WD_PREFIX } from '../../utils/constant';
4
-
5
4
  Component({
6
5
  options: {
7
6
  virtualHost: true,
@@ -101,14 +100,18 @@ Component({
101
100
  */
102
101
  onClose(params) {
103
102
  this.dealShow(false, params);
104
- this.setData({ closeInfo: params?.info || params });
103
+ this.setData({
104
+ closeInfo: params?.info || params,
105
+ });
105
106
  },
106
107
  /**
107
108
  * 开启弹窗
108
109
  */
109
110
  onOpen(params) {
110
111
  this.dealShow(true, params);
111
- this.setData({ openInfo: params?.info || params });
112
+ this.setData({
113
+ openInfo: params?.info || params,
114
+ });
112
115
  },
113
116
  /**
114
117
  * 点击遮罩层
@@ -128,10 +131,12 @@ Component({
128
131
  defaultMaskShow,
129
132
  isBdShow,
130
133
  ) {
131
- const defaultWidth = { center: 'calc(100% - 4.57rem)', bottom: '100%' }[position];
134
+ const defaultWidth = {
135
+ center: 'calc(100% - 4.57rem)',
136
+ bottom: '100%',
137
+ }[position];
132
138
  const styleShow = `width: ${defaultWidth};` + style;
133
139
  const styleMain = style?.match(/(display:).*?(;)/g)?.join('');
134
-
135
140
  // 响应式css api
136
141
  const cls = classNames({
137
142
  [`${WD_PREFIX}-modal`]: true,
@@ -147,6 +152,7 @@ Component({
147
152
  [`${WD_PREFIX}-modal-mask__fadeout`]: isMaskShow,
148
153
  [`${WD_PREFIX}-modal-mask__hide`]: !defaultMaskShow,
149
154
  });
155
+
150
156
  // 主体内容样式
151
157
  const modalBdClasses = classNames({
152
158
  'weda-modal-new': true,
@@ -174,7 +180,9 @@ Component({
174
180
  [`${WD_PREFIX}-modal-bd__ft-text-btn`]: ['confirm', 'notice'].includes(template),
175
181
  [`${WD_PREFIX}-modal-bd__ft-text-btn--vertical`]: template === 'notice',
176
182
  });
177
- this.setData({ modalFtClasses });
183
+ this.setData({
184
+ modalFtClasses,
185
+ });
178
186
  },
179
187
  },
180
188
  });
@@ -1,16 +1,16 @@
1
1
  <view id="{{id}}" style="{{styleMain}}" class="{{cls}}">
2
- <block wx:if="{{maskPreToShow}}">
3
- <view class="{{modalMaskClasses}}" bindtap="maskClick" />
4
- <view style="{{styleShow}}" class="{{modalBdClasses}}">
5
- <view class="{{classPrefix + '-modal-bd__hd'}}">
6
- <slot name="headerSlot"></slot>
7
- </view>
8
- <view class="{{classPrefix + '-modal-bd__main'}}">
9
- <slot name="contentSlot"></slot>
10
- </view>
11
- <view class="{{classPrefix + '-modal-bd__ft'}} {{modalFtClasses}}">
12
- <slot name="footerSlot"></slot>
13
- </view>
14
- </view>
15
- </block>
2
+ <block wx:if="{{maskPreToShow}}">
3
+ <view class="{{modalMaskClasses}}" bindtap="maskClick" />
4
+ <view style="{{styleShow}}" class="{{modalBdClasses}}">
5
+ <view class="{{classPrefix + '-modal-bd__hd'}}">
6
+ <slot name="headerSlot"></slot>
7
+ </view>
8
+ <view class="{{classPrefix + '-modal-bd__main'}}">
9
+ <slot name="contentSlot"></slot>
10
+ </view>
11
+ <view class="{{classPrefix + '-modal-bd__ft'}} {{modalFtClasses}}">
12
+ <slot name="footerSlot"></slot>
13
+ </view>
14
+ </view>
15
+ </block>
16
16
  </view>
@@ -210,4 +210,7 @@
210
210
 
211
211
  .weda-modal-new {
212
212
  padding-bottom: constant(safe-area-inset-bottom);
213
+ /* 兼容 iOS < 11.2 */
214
+ padding-bottom: env(safe-area-inset-bottom);
215
+ /* 兼容 iOS >= 11.2 */
213
216
  }
@@ -52,6 +52,9 @@
52
52
  width: 100%;
53
53
  background: var(--wd-tabs-bg);
54
54
  }
55
+ .wd-tabs-root.wd-event-tap:active {
56
+ box-shadow: unset;
57
+ }
55
58
  .wd-tabs__header {
56
59
  display: flex;
57
60
  flex-direction: row;
package/index.json CHANGED
@@ -21,6 +21,7 @@
21
21
  "WdMenuLayout": "components/wd-menu-layout/index",
22
22
  "WdMenuList": "components/wd-menu-list/index",
23
23
  "WdModal": "components/wd-modal/index",
24
+ "WdDrawer": "components/wd-drawer/index",
24
25
  "WdOfficialAccount": "components/wd-official-account/index",
25
26
  "CustomerService": "components/customer-service/index",
26
27
  "FormTime": "components/form-time/index",
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "miniprogram": "./",
4
4
  "packageManager": "yarn@3.0.2",
5
5
  "dependencies": {},
6
- "version": "3.25.1",
6
+ "version": "3.26.0",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"
package/utils/enum.js CHANGED
@@ -1271,3 +1271,22 @@ export const WD_CODE_EDITOR_THEME = [
1271
1271
  { label: '暗黑', value: 'githubDark' },
1272
1272
  { label: '明亮', value: 'githubLight' },
1273
1273
  ];
1274
+
1275
+ export const WD_DRAWER_PLACEMENT = [
1276
+ {
1277
+ label: '右',
1278
+ value: 'right',
1279
+ },
1280
+ {
1281
+ label: '左',
1282
+ value: 'left',
1283
+ },
1284
+ {
1285
+ label: '上',
1286
+ value: 'top',
1287
+ },
1288
+ {
1289
+ label: '下',
1290
+ value: 'bottom',
1291
+ },
1292
+ ];