Browse Source

esswisdom_wx

master
dong 1 year ago
commit
aafc725125
100 changed files with 14665 additions and 0 deletions
  1. 31
    0
      .eslintrc.js
  2. 105
    0
      api/index.js
  3. 56
    0
      app.js
  4. 44
    0
      app.json
  5. 17
    0
      app.wxss
  6. 235
    0
      ec-canvas/ec-canvas.js
  7. 4
    0
      ec-canvas/ec-canvas.json
  8. 4
    0
      ec-canvas/ec-canvas.wxml
  9. 4
    0
      ec-canvas/ec-canvas.wxss
  10. 4
    0
      ec-canvas/echarts-liquidfill.min.js
  11. 22
    0
      ec-canvas/echarts.js
  12. 121
    0
      ec-canvas/wx-canvas.js
  13. 13
    0
      miniprogram_npm/dayjs/index.js
  14. 1
    0
      miniprogram_npm/dayjs/index.js.map
  15. 5701
    0
      miniprogram_npm/moment/index.js
  16. 1
    0
      miniprogram_npm/moment/index.js.map
  17. 3895
    0
      miniprogram_npm/tdesign-miniprogram/.wechatide.ib.json
  18. 52
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/README.en-US.md
  19. 140
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/README.md
  20. 81
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.d.ts
  21. 104
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.js
  22. 10
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.json
  23. 49
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.wxml
  24. 19
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.wxs
  25. 169
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.wxss
  26. 8
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/index.d.ts
  27. 10
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/index.js
  28. 3
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/props.d.ts
  29. 46
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/props.js
  30. 31
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/show.d.ts
  31. 33
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/show.js
  32. 51
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/template/grid.wxml
  33. 20
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/template/list.wxml
  34. 58
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/type.d.ts
  35. 1
    0
      miniprogram_npm/tdesign-miniprogram/action-sheet/type.js
  36. 28
    0
      miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.d.ts
  37. 86
    0
      miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.js
  38. 7
    0
      miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.json
  39. 20
    0
      miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.wxml
  40. 137
    0
      miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.wxss
  41. 3
    0
      miniprogram_npm/tdesign-miniprogram/avatar-group/props.d.ts
  42. 20
    0
      miniprogram_npm/tdesign-miniprogram/avatar-group/props.js
  43. 27
    0
      miniprogram_npm/tdesign-miniprogram/avatar-group/type.d.ts
  44. 1
    0
      miniprogram_npm/tdesign-miniprogram/avatar-group/type.js
  45. 60
    0
      miniprogram_npm/tdesign-miniprogram/avatar/README.en-US.md
  46. 133
    0
      miniprogram_npm/tdesign-miniprogram/avatar/README.md
  47. 23
    0
      miniprogram_npm/tdesign-miniprogram/avatar/avatar.d.ts
  48. 76
    0
      miniprogram_npm/tdesign-miniprogram/avatar/avatar.js
  49. 9
    0
      miniprogram_npm/tdesign-miniprogram/avatar/avatar.json
  50. 54
    0
      miniprogram_npm/tdesign-miniprogram/avatar/avatar.wxml
  51. 26
    0
      miniprogram_npm/tdesign-miniprogram/avatar/avatar.wxs
  52. 104
    0
      miniprogram_npm/tdesign-miniprogram/avatar/avatar.wxss
  53. 3
    0
      miniprogram_npm/tdesign-miniprogram/avatar/props.d.ts
  54. 39
    0
      miniprogram_npm/tdesign-miniprogram/avatar/props.js
  55. 48
    0
      miniprogram_npm/tdesign-miniprogram/avatar/type.d.ts
  56. 1
    0
      miniprogram_npm/tdesign-miniprogram/avatar/type.js
  57. 33
    0
      miniprogram_npm/tdesign-miniprogram/back-top/README.en-US.md
  58. 69
    0
      miniprogram_npm/tdesign-miniprogram/back-top/README.md
  59. 26
    0
      miniprogram_npm/tdesign-miniprogram/back-top/back-top.d.ts
  60. 73
    0
      miniprogram_npm/tdesign-miniprogram/back-top/back-top.js
  61. 7
    0
      miniprogram_npm/tdesign-miniprogram/back-top/back-top.json
  62. 17
    0
      miniprogram_npm/tdesign-miniprogram/back-top/back-top.wxml
  63. 91
    0
      miniprogram_npm/tdesign-miniprogram/back-top/back-top.wxss
  64. 3
    0
      miniprogram_npm/tdesign-miniprogram/back-top/props.d.ts
  65. 30
    0
      miniprogram_npm/tdesign-miniprogram/back-top/props.js
  66. 34
    0
      miniprogram_npm/tdesign-miniprogram/back-top/type.d.ts
  67. 1
    0
      miniprogram_npm/tdesign-miniprogram/back-top/type.js
  68. 36
    0
      miniprogram_npm/tdesign-miniprogram/badge/README.en-US.md
  69. 77
    0
      miniprogram_npm/tdesign-miniprogram/badge/README.md
  70. 21
    0
      miniprogram_npm/tdesign-miniprogram/badge/badge.d.ts
  71. 43
    0
      miniprogram_npm/tdesign-miniprogram/badge/badge.js
  72. 5
    0
      miniprogram_npm/tdesign-miniprogram/badge/badge.json
  73. 44
    0
      miniprogram_npm/tdesign-miniprogram/badge/badge.wxml
  74. 70
    0
      miniprogram_npm/tdesign-miniprogram/badge/badge.wxs
  75. 110
    0
      miniprogram_npm/tdesign-miniprogram/badge/badge.wxss
  76. 3
    0
      miniprogram_npm/tdesign-miniprogram/badge/index.d.ts
  77. 3
    0
      miniprogram_npm/tdesign-miniprogram/badge/index.js
  78. 3
    0
      miniprogram_npm/tdesign-miniprogram/badge/props.d.ts
  79. 41
    0
      miniprogram_npm/tdesign-miniprogram/badge/props.js
  80. 42
    0
      miniprogram_npm/tdesign-miniprogram/badge/type.d.ts
  81. 1
    0
      miniprogram_npm/tdesign-miniprogram/badge/type.js
  82. 223
    0
      miniprogram_npm/tdesign-miniprogram/button/README.en-US.md
  83. 223
    0
      miniprogram_npm/tdesign-miniprogram/button/README.md
  84. 36
    0
      miniprogram_npm/tdesign-miniprogram/button/button.d.ts
  85. 100
    0
      miniprogram_npm/tdesign-miniprogram/button/button.js
  86. 8
    0
      miniprogram_npm/tdesign-miniprogram/button/button.json
  87. 61
    0
      miniprogram_npm/tdesign-miniprogram/button/button.wxml
  88. 477
    0
      miniprogram_npm/tdesign-miniprogram/button/button.wxss
  89. 3
    0
      miniprogram_npm/tdesign-miniprogram/button/index.d.ts
  90. 3
    0
      miniprogram_npm/tdesign-miniprogram/button/index.js
  91. 3
    0
      miniprogram_npm/tdesign-miniprogram/button/props.d.ts
  92. 104
    0
      miniprogram_npm/tdesign-miniprogram/button/props.js
  93. 112
    0
      miniprogram_npm/tdesign-miniprogram/button/type.d.ts
  94. 1
    0
      miniprogram_npm/tdesign-miniprogram/button/type.js
  95. 48
    0
      miniprogram_npm/tdesign-miniprogram/calendar/README.en-US.md
  96. 106
    0
      miniprogram_npm/tdesign-miniprogram/calendar/README.md
  97. 47
    0
      miniprogram_npm/tdesign-miniprogram/calendar/calendar.d.ts
  98. 170
    0
      miniprogram_npm/tdesign-miniprogram/calendar/calendar.js
  99. 9
    0
      miniprogram_npm/tdesign-miniprogram/calendar/calendar.json
  100. 0
    0
      miniprogram_npm/tdesign-miniprogram/calendar/calendar.wxml

+ 31
- 0
.eslintrc.js View File

@@ -0,0 +1,31 @@
1
+/*
2
+ * Eslint config file
3
+ * Documentation: https://eslint.org/docs/user-guide/configuring/
4
+ * Install the Eslint extension before using this feature.
5
+ */
6
+module.exports = {
7
+  env: {
8
+    es6: true,
9
+    browser: true,
10
+    node: true,
11
+  },
12
+  ecmaFeatures: {
13
+    modules: true,
14
+  },
15
+  parserOptions: {
16
+    ecmaVersion: 2018,
17
+    sourceType: 'module',
18
+  },
19
+  globals: {
20
+    wx: true,
21
+    App: true,
22
+    Page: true,
23
+    getCurrentPages: true,
24
+    getApp: true,
25
+    Component: true,
26
+    requirePlugin: true,
27
+    requireMiniProgram: true,
28
+  },
29
+  // extends: 'eslint:recommended',
30
+  rules: {},
31
+}

+ 105
- 0
api/index.js View File

@@ -0,0 +1,105 @@
1
+// api.jshttp://zlink.bjdexn.cn
2
+// const baseUrl = 'http://192.168.8.198:8888';  // 替换为您的接口基础 URL
3
+// const baseUrl = 'https://zlink.bjdexn.cn';  // 替换为您的接口基础 URL
4
+const baseUrl = 'https://esos-iot.bjdexn.cn';  // 替换为您的接口基础 URL
5
+
6
+// 封装网络请求方法
7
+function request(url, method, data) {
8
+  return new Promise((resolve, reject) => {
9
+    if (url!='/platform/login') {
10
+      wx.getStorage({
11
+        key: 'cookies',
12
+        success: function(res) {
13
+          wx.request({
14
+            url: baseUrl + url,
15
+            header: {
16
+              'Content-Type': 'application/x-www-form-urlencoded',
17
+              Cookie:res.data},
18
+            method: method,
19
+            data:data,
20
+            success:function(res) {
21
+              // console.log(res);
22
+              // 请求成功处理
23
+              if (res.data.code === 0) {
24
+                resolve(res.data);
25
+              } else {
26
+                reject(res.data.msg);
27
+                if (res.data.status === 400) {
28
+                  wx.navigateTo({
29
+                    url: '/pages/login/index', // 登录页面的路径,注意路径前面加上 '/' 表示从根目录开始
30
+                  });
31
+                }else{
32
+                  wx.navigateTo({
33
+                    url: '/pages/login/index', // 登录页面的路径,注意路径前面加上 '/' 表示从根目录开始
34
+                  });  
35
+                }
36
+              }
37
+            },
38
+            fail:function(err) {
39
+              console.log(err);
40
+              wx.navigateTo({
41
+                url: '/pages/login/index', // 登录页面的路径,注意路径前面加上 '/' 表示从根目录开始
42
+              });
43
+            }
44
+          });
45
+        },
46
+        fail: function(err) {
47
+          console.log(err);
48
+          wx.navigateTo({
49
+            url: '/pages/login/index', // 登录页面的路径,注意路径前面加上 '/' 表示从根目录开始
50
+          });
51
+        }
52
+      }) 
53
+    }else{
54
+          wx.request({
55
+            url: baseUrl + url,
56
+            header: {
57
+              'Content-Type': 'application/x-www-form-urlencoded'},
58
+            method: method,
59
+            data:data,
60
+            success:function(res) {
61
+              // 请求成功处理
62
+              if (res.statusCode === 200) {
63
+                resolve(res.data);
64
+              } else {
65
+                reject(res.statusCode);
66
+              }
67
+            },
68
+            fail:function(err) {
69
+              wx.navigateTo({
70
+                url: '/pages/login/index', // 登录页面的路径,注意路径前面加上 '/' 表示从根目录开始
71
+              });
72
+            }
73
+          });
74
+        }
75
+      });
76
+  }
77
+// 导出封装的请求方法
78
+module.exports = {
79
+  request: request
80
+};
81
+
82
+// // 在需要使用网络请求的页面中引入封装的 api.js 文件
83
+// const api = require('api.js');
84
+
85
+// // 示例:发送一个 GET 请求
86
+// api.request('/users', 'GET')
87
+//   .then((res) => {
88
+//     console.log('请求成功:', res);
89
+//     // 在这里处理返回的数据
90
+//   })
91
+//   .catch((err) => {
92
+//     console.error('请求失败:', err);
93
+//     // 在这里处理请求失败的情况
94
+//   });
95
+
96
+// // 示例:发送一个 POST 请求
97
+// api.request('/users', 'POST', { name: 'John', age: 30 })
98
+//   .then((res) => {
99
+//     console.log('请求成功:', res);
100
+//     // 在这里处理返回的数据
101
+//   })
102
+//   .catch((err) => {
103
+//     console.error('请求失败:', err);
104
+//     // 在这里处理请求失败的情况
105
+//   });

+ 56
- 0
app.js View File

@@ -0,0 +1,56 @@
1
+// app.js
2
+App({
3
+  onLaunch() {
4
+    // 展示本地存储能力
5
+    const logs = wx.getStorageSync('logs') || []
6
+    logs.unshift(Date.now())
7
+    wx.setStorageSync('logs', logs)
8
+
9
+    // 登录
10
+    wx.login({
11
+      success: res => {
12
+        // 发送 res.code 到后台换取 openId, sessionKey, unionId
13
+      }
14
+    })
15
+    wx.getSystemInfo({
16
+      success: res => {
17
+     
18
+        // 手机系统状态栏高度
19
+        wx.setStorageSync('statusBarHeight', res.statusBarHeight)
20
+  
21
+        const platform = res.platform
22
+        const menu =  wx.getMenuButtonBoundingClientRect()
23
+  
24
+        //menu为胶囊,判断是否能读到胶囊位置,读不到则用具体一般数值表示
25
+        if (menu) {
26
+          wx.setStorageSync('menu', menu)
27
+  
28
+          // 导航栏高度
29
+          wx.setStorageSync('navBarHeight', menu.height+(menu.top-res.statusBarHeight) *2 )
30
+  
31
+          // 状态栏加导航栏
32
+  
33
+          wx.setStorageSync('navStatusBarHeight', res.statusBarHeight+ menu.height+(menu.top-res.statusBarHeight) *2 )
34
+  
35
+  
36
+        }else{
37
+          wx.setStorageSync('menu', null)
38
+  
39
+          // 导航栏高度
40
+          wx.setStorageSync('navBarHeight', platform === 'android' ? 48 : 44)
41
+  
42
+           // 状态栏加导航栏
43
+  
44
+           wx.setStorageSync('navStatusBarHeight', res.statusBarHeight+ (platform === 'android' ? 48 : 44) )
45
+  
46
+        }
47
+  
48
+      }, fail(err) {
49
+        console.log(err);
50
+      }
51
+    })
52
+  },
53
+  globalData: {
54
+    userInfo: null
55
+  }
56
+})

+ 44
- 0
app.json View File

@@ -0,0 +1,44 @@
1
+{
2
+  "pages": [
3
+    "pages/index/index",
4
+    "pages/login/index",
5
+    "pages/monitor/index",
6
+    "pages/monitorevent/index",
7
+    "pages/setup/index",
8
+    "pages/details/index",
9
+    "pages/station/index",
10
+    "pages/setuplevel/index",
11
+    "pages/user/index",
12
+    "pages/powerstation/index",
13
+    "pages/privacy/index",
14
+    "pages/healthy/index",
15
+    "pages/account/index"
16
+  ],
17
+  "window": {
18
+    "navigationBarTextStyle": "black",
19
+    "navigationBarTitleText": "云链智安",
20
+    "navigationBarBackgroundColor": "#ffffff"
21
+  },
22
+  "componentFramework": "glass-easel",
23
+  "sitemapLocation": "sitemap.json",
24
+  "lazyCodeLoading": "requiredComponents",
25
+  "__usePrivacyCheck__": true,
26
+  "tabBar": {
27
+    "selectedColor":"#007544",
28
+    "list": [
29
+      {
30
+      "pagePath": "pages/index/index",
31
+      "text": "概览",
32
+      
33
+      "iconPath": "static/sz.png",
34
+      "selectedIconPath": "static/sz1.png"
35
+    } , {
36
+      "pagePath": "pages/setup/index",
37
+      "text": "设置",
38
+      "iconPath": "static/user1.png",
39
+      "selectedIconPath": "static/user2.png"
40
+    } 
41
+  ]
42
+  }
43
+  
44
+}

+ 17
- 0
app.wxss View File

@@ -0,0 +1,17 @@
1
+.container {
2
+  position: absolute;
3
+  top: 0;
4
+  /* bottom: 0; */
5
+  left: 0;
6
+  right: 0;
7
+
8
+  display: flex;
9
+  flex-direction: column;
10
+  align-items: center;
11
+  /* justify-content: space-between; */
12
+  box-sizing: border-box;
13
+} 
14
+page {
15
+  /* font-family:"PingFangSC-Thin"; */
16
+   font-size:28rpx;          /*微信小程序中,使用rpx做单位*/
17
+}

+ 235
- 0
ec-canvas/ec-canvas.js View File

@@ -0,0 +1,235 @@
1
+import WxCanvas from './wx-canvas';
2
+import * as echarts from './echarts';
3
+
4
+let ctx;
5
+
6
+function compareVersion(v1, v2) {
7
+  v1 = v1.split('.')
8
+  v2 = v2.split('.')
9
+  const len = Math.max(v1.length, v2.length)
10
+
11
+  while (v1.length < len) {
12
+    v1.push('0')
13
+  }
14
+  while (v2.length < len) {
15
+    v2.push('0')
16
+  }
17
+
18
+  for (let i = 0; i < len; i++) {
19
+    const num1 = parseInt(v1[i])
20
+    const num2 = parseInt(v2[i])
21
+
22
+    if (num1 > num2) {
23
+      return 1
24
+    } else if (num1 < num2) {
25
+      return -1
26
+    }
27
+  }
28
+  return 0
29
+}
30
+
31
+Component({
32
+  properties: {
33
+    canvasId: {
34
+      type: String,
35
+      value: 'ec-canvas'
36
+    },
37
+
38
+    ec: {
39
+      type: Object
40
+    },
41
+
42
+    forceUseOldCanvas: {
43
+      type: Boolean,
44
+      value: false
45
+    }
46
+  },
47
+
48
+  data: {
49
+    isUseNewCanvas: false
50
+  },
51
+
52
+  ready: function () {
53
+    if (!this.data.ec) {
54
+      console.warn('组件需绑定 ec 变量,例:<ec-canvas id="mychart-dom-bar" '
55
+        + 'canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>');
56
+      return;
57
+    }
58
+
59
+    if (!this.data.ec.lazyLoad) {
60
+      this.init();
61
+    }
62
+  },
63
+
64
+  methods: {
65
+    init: function (callback) {
66
+      const version = wx.getSystemInfoSync().SDKVersion
67
+
68
+      const canUseNewCanvas = compareVersion(version, '2.9.0') >= 0;
69
+      const forceUseOldCanvas = this.data.forceUseOldCanvas;
70
+      const isUseNewCanvas = canUseNewCanvas && !forceUseOldCanvas;
71
+      this.setData({ isUseNewCanvas });
72
+
73
+      if (forceUseOldCanvas && canUseNewCanvas) {
74
+        console.warn('开发者强制使用旧canvas,建议关闭');
75
+      }
76
+
77
+      if (isUseNewCanvas) {
78
+        // console.log('微信基础库版本大于2.9.0,开始使用<canvas type="2d"/>');
79
+        // 2.9.0 可以使用 <canvas type="2d"></canvas>
80
+        this.initByNewWay(callback);
81
+      } else {
82
+        const isValid = compareVersion(version, '1.9.91') >= 0
83
+        if (!isValid) {
84
+          console.error('微信基础库版本过低,需大于等于 1.9.91。'
85
+            + '参见:https://github.com/ecomfe/echarts-for-weixin'
86
+            + '#%E5%BE%AE%E4%BF%A1%E7%89%88%E6%9C%AC%E8%A6%81%E6%B1%82');
87
+          return;
88
+        } else {
89
+          // console.warn('建议将微信基础库调整大于等于2.9.0版本。升级后绘图将有更好性能');
90
+          this.initByOldWay(callback);
91
+        }
92
+      }
93
+    },
94
+
95
+    initByOldWay(callback) {
96
+      // 1.9.91 <= version < 2.9.0:原来的方式初始化
97
+      ctx = wx.createCanvasContext(this.data.canvasId, this);
98
+      const canvas = new WxCanvas(ctx, this.data.canvasId, false);
99
+
100
+      echarts.setCanvasCreator(() => {
101
+        return canvas;
102
+      });
103
+      // const canvasDpr = wx.getSystemInfoSync().pixelRatio // 微信旧的canvas不能传入dpr
104
+      const canvasDpr = 1
105
+      var query = wx.createSelectorQuery().in(this);
106
+      query.select('.ec-canvas').boundingClientRect(res => {
107
+        if (typeof callback === 'function') {
108
+          this.chart = callback(canvas, res.width, res.height, canvasDpr);
109
+        }
110
+        else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
111
+          this.chart = this.data.ec.onInit(canvas, res.width, res.height, canvasDpr);
112
+        }
113
+        else {
114
+          this.triggerEvent('init', {
115
+            canvas: canvas,
116
+            width: res.width,
117
+            height: res.height,
118
+            canvasDpr: canvasDpr // 增加了dpr,可方便外面echarts.init
119
+          });
120
+        }
121
+      }).exec();
122
+    },
123
+
124
+    initByNewWay(callback) {
125
+      // version >= 2.9.0:使用新的方式初始化
126
+      const query = wx.createSelectorQuery().in(this)
127
+      query
128
+        .select('.ec-canvas')
129
+        .fields({ node: true, size: true })
130
+        .exec(res => {
131
+          const canvasNode = res[0].node
132
+          this.canvasNode = canvasNode
133
+
134
+          const canvasDpr = wx.getSystemInfoSync().pixelRatio
135
+          const canvasWidth = res[0].width
136
+          const canvasHeight = res[0].height
137
+
138
+          const ctx = canvasNode.getContext('2d')
139
+
140
+          const canvas = new WxCanvas(ctx, this.data.canvasId, true, canvasNode)
141
+          echarts.setCanvasCreator(() => {
142
+            return canvas
143
+          })
144
+
145
+          if (typeof callback === 'function') {
146
+            this.chart = callback(canvas, canvasWidth, canvasHeight, canvasDpr)
147
+          } else if (this.data.ec && typeof this.data.ec.onInit === 'function') {
148
+            this.chart = this.data.ec.onInit(canvas, canvasWidth, canvasHeight, canvasDpr)
149
+          } else {
150
+            this.triggerEvent('init', {
151
+              canvas: canvas,
152
+              width: canvasWidth,
153
+              height: canvasHeight,
154
+              dpr: canvasDpr
155
+            })
156
+          }
157
+        })
158
+    },
159
+    canvasToTempFilePath(opt) {
160
+      if (this.data.isUseNewCanvas) {
161
+        // 新版
162
+        const query = wx.createSelectorQuery().in(this)
163
+        query
164
+          .select('.ec-canvas')
165
+          .fields({ node: true, size: true })
166
+          .exec(res => {
167
+            const canvasNode = res[0].node
168
+            opt.canvas = canvasNode
169
+            wx.canvasToTempFilePath(opt)
170
+          })
171
+      } else {
172
+        // 旧的  
173
+        if (!opt.canvasId) {
174
+          opt.canvasId = this.data.canvasId;
175
+        }
176
+        ctx.draw(true, () => {
177
+          wx.canvasToTempFilePath(opt, this);
178
+        });
179
+      }
180
+    },
181
+
182
+    touchStart(e) {
183
+      if (this.chart && e.touches.length > 0) {
184
+        var touch = e.touches[0];
185
+        var handler = this.chart.getZr().handler;
186
+        handler.dispatch('mousedown', {
187
+          zrX: touch.x,
188
+          zrY: touch.y
189
+        });
190
+        handler.dispatch('mousemove', {
191
+          zrX: touch.x,
192
+          zrY: touch.y
193
+        });
194
+        handler.processGesture(wrapTouch(e), 'start');
195
+      }
196
+    },
197
+
198
+    touchMove(e) {
199
+      if (this.chart && e.touches.length > 0) {
200
+        var touch = e.touches[0];
201
+        var handler = this.chart.getZr().handler;
202
+        handler.dispatch('mousemove', {
203
+          zrX: touch.x,
204
+          zrY: touch.y
205
+        });
206
+        handler.processGesture(wrapTouch(e), 'change');
207
+      }
208
+    },
209
+
210
+    touchEnd(e) {
211
+      if (this.chart) {
212
+        const touch = e.changedTouches ? e.changedTouches[0] : {};
213
+        var handler = this.chart.getZr().handler;
214
+        handler.dispatch('mouseup', {
215
+          zrX: touch.x,
216
+          zrY: touch.y
217
+        });
218
+        handler.dispatch('click', {
219
+          zrX: touch.x,
220
+          zrY: touch.y
221
+        });
222
+        handler.processGesture(wrapTouch(e), 'end');
223
+      }
224
+    }
225
+  }
226
+});
227
+
228
+function wrapTouch(event) {
229
+  for (let i = 0; i < event.touches.length; ++i) {
230
+    const touch = event.touches[i];
231
+    touch.offsetX = touch.x;
232
+    touch.offsetY = touch.y;
233
+  }
234
+  return event;
235
+}

+ 4
- 0
ec-canvas/ec-canvas.json View File

@@ -0,0 +1,4 @@
1
+{
2
+  "component": true,
3
+  "usingComponents": {}
4
+}

+ 4
- 0
ec-canvas/ec-canvas.wxml View File

@@ -0,0 +1,4 @@
1
+<!-- 新的:接口对其了H5 -->
2
+<canvas wx:if="{{isUseNewCanvas}}" type="2d" class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>
3
+<!-- 旧的 -->
4
+<canvas wx:else class="ec-canvas" canvas-id="{{ canvasId }}" bindinit="init" bindtouchstart="{{ ec.disableTouch ? '' : 'touchStart' }}" bindtouchmove="{{ ec.disableTouch ? '' : 'touchMove' }}" bindtouchend="{{ ec.disableTouch ? '' : 'touchEnd' }}"></canvas>

+ 4
- 0
ec-canvas/ec-canvas.wxss View File

@@ -0,0 +1,4 @@
1
+.ec-canvas {
2
+  width: 100%;
3
+  height: 100%;
4
+}

+ 4
- 0
ec-canvas/echarts-liquidfill.min.js
File diff suppressed because it is too large
View File


+ 22
- 0
ec-canvas/echarts.js
File diff suppressed because it is too large
View File


+ 121
- 0
ec-canvas/wx-canvas.js View File

@@ -0,0 +1,121 @@
1
+export default class WxCanvas {
2
+  constructor(ctx, canvasId, isNew, canvasNode) {
3
+    this.ctx = ctx;
4
+    this.canvasId = canvasId;
5
+    this.chart = null;
6
+    this.isNew = isNew
7
+    if (isNew) {
8
+      this.canvasNode = canvasNode;
9
+    }
10
+    else {
11
+      this._initStyle(ctx);
12
+    }
13
+
14
+    // this._initCanvas(zrender, ctx);
15
+
16
+    this._initEvent();
17
+  }
18
+
19
+  getContext(contextType) {
20
+    if (contextType === '2d') {
21
+      return this.ctx;
22
+    }
23
+  }
24
+
25
+  // canvasToTempFilePath(opt) {
26
+  //   if (!opt.canvasId) {
27
+  //     opt.canvasId = this.canvasId;
28
+  //   }
29
+  //   return wx.canvasToTempFilePath(opt, this);
30
+  // }
31
+
32
+  setChart(chart) {
33
+    this.chart = chart;
34
+  }
35
+
36
+  attachEvent() {
37
+    // noop
38
+  }
39
+
40
+  detachEvent() {
41
+    // noop
42
+  }
43
+
44
+  _initCanvas(zrender, ctx) {
45
+    zrender.util.getContext = function () {
46
+      return ctx;
47
+    };
48
+
49
+    zrender.util.$override('measureText', function (text, font) {
50
+      ctx.font = font || '12px sans-serif';
51
+      return ctx.measureText(text);
52
+    });
53
+  }
54
+
55
+  _initStyle(ctx) {
56
+    var styles = ['fillStyle', 'strokeStyle', 'globalAlpha',
57
+      'textAlign', 'textBaseAlign', 'shadow', 'lineWidth',
58
+      'lineCap', 'lineJoin', 'lineDash', 'miterLimit', 'fontSize'];
59
+
60
+    styles.forEach(style => {
61
+      Object.defineProperty(ctx, style, {
62
+        set: value => {
63
+          if (style !== 'fillStyle' && style !== 'strokeStyle'
64
+            || value !== 'none' && value !== null
65
+          ) {
66
+            ctx['set' + style.charAt(0).toUpperCase() + style.slice(1)](value);
67
+          }
68
+        }
69
+      });
70
+    });
71
+
72
+    ctx.createRadialGradient = () => {
73
+      return ctx.createCircularGradient(arguments);
74
+    };
75
+  }
76
+
77
+  _initEvent() {
78
+    this.event = {};
79
+    const eventNames = [{
80
+      wxName: 'touchStart',
81
+      ecName: 'mousedown'
82
+    }, {
83
+      wxName: 'touchMove',
84
+      ecName: 'mousemove'
85
+    }, {
86
+      wxName: 'touchEnd',
87
+      ecName: 'mouseup'
88
+    }, {
89
+      wxName: 'touchEnd',
90
+      ecName: 'click'
91
+    }];
92
+
93
+    eventNames.forEach(name => {
94
+      this.event[name.wxName] = e => {
95
+        const touch = e.touches[0];
96
+        this.chart.getZr().handler.dispatch(name.ecName, {
97
+          zrX: name.wxName === 'tap' ? touch.clientX : touch.x,
98
+          zrY: name.wxName === 'tap' ? touch.clientY : touch.y
99
+        });
100
+      };
101
+    });
102
+  }
103
+
104
+  set width(w) {
105
+    if (this.canvasNode) this.canvasNode.width = w
106
+  }
107
+  set height(h) {
108
+    if (this.canvasNode) this.canvasNode.height = h
109
+  }
110
+
111
+  get width() {
112
+    if (this.canvasNode)
113
+      return this.canvasNode.width
114
+    return 0
115
+  }
116
+  get height() {
117
+    if (this.canvasNode)
118
+      return this.canvasNode.height
119
+    return 0
120
+  }
121
+}

+ 13
- 0
miniprogram_npm/dayjs/index.js
File diff suppressed because it is too large
View File


+ 1
- 0
miniprogram_npm/dayjs/index.js.map
File diff suppressed because it is too large
View File


+ 5701
- 0
miniprogram_npm/moment/index.js
File diff suppressed because it is too large
View File


+ 1
- 0
miniprogram_npm/moment/index.js.map
File diff suppressed because it is too large
View File


+ 3895
- 0
miniprogram_npm/tdesign-miniprogram/.wechatide.ib.json
File diff suppressed because it is too large
View File


+ 52
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/README.en-US.md View File

@@ -0,0 +1,52 @@
1
+:: BASE_DOC ::
2
+
3
+## API
4
+
5
+### ActionSheet Props
6
+
7
+name | type | default | description | required
8
+-- | -- | -- | -- | --
9
+style | Object | - | CSS(Cascading Style Sheets) | N
10
+custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
11
+align | String | center | `0.29.0`。options: center/left | N
12
+cancel-text | String | - | \- | N
13
+count | Number | 8 | \- | N
14
+description | String | - | `0.29.0` | N
15
+items | Array | - | required。Typescript:`Array<string \| ActionSheetItem>` `interface ActionSheetItem {label: string; color?: string; disabled?: boolean;icon?: string;suffixIcon?: string; }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/action-sheet/type.ts) | Y
16
+popup-props | Object | {} | Typescript:`PopupProps`,[Popup API Documents](./popup?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/action-sheet/type.ts) | N
17
+show-cancel | Boolean | true | \- | N
18
+show-overlay | Boolean | true | \- | N
19
+theme | String | list | options: list/grid | N
20
+using-custom-navbar | Boolean | false | \- | N
21
+visible | Boolean | false | required | Y
22
+default-visible | Boolean | undefined | required。uncontrolled property | Y
23
+
24
+### ActionSheet Events
25
+
26
+name | params | description
27
+-- | -- | --
28
+cancel | \- | \-
29
+close | `(trigger: TriggerSource)` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/action-sheet/type.ts)。<br/>`type TriggerSource = 'overlay' \| 'command' \| 'select' `<br/>
30
+selected | `(selected: ActionSheetItem \| string, index: number)` | \-
31
+### ActionSheet External Classes
32
+
33
+className | Description
34
+-- | --
35
+t-class | \-
36
+t-class-cancel | \-
37
+t-class-content | \-
38
+
39
+### CSS Variables
40
+
41
+The component provides the following CSS variables, which can be used to customize styles.
42
+Name | Default Value | Description 
43
+-- | -- | --
44
+--td-action-sheet-border-color | @gray-color-1 | - 
45
+--td-action-sheet-border-radius | @radius-extra-large | - 
46
+--td-action-sheet-cancel-color | @font-gray-1 | - 
47
+--td-action-sheet-cancel-height | 96rpx | - 
48
+--td-action-sheet-color | @font-gray-1 | - 
49
+--td-action-sheet-description-color | @font-gray-3 | - 
50
+--td-action-sheet-list-item-disabled-color | @font-gray-4 | - 
51
+--td-action-sheet-list-item-height | 112rpx | - 
52
+--td-action-sheet-text-align | center | -

+ 140
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/README.md View File

@@ -0,0 +1,140 @@
1
+---
2
+title: ActionSheet 动作面板
3
+description: 由用户操作后触发的一种特定的模态弹出框 ,呈现一组与当前情境相关的两个或多个选项。
4
+spline: data
5
+isComponent: true
6
+---
7
+
8
+<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-89%25-blue" /></span>
9
+
10
+<div style="background: #ecf2fe; display: flex; align-items: center; line-height: 20px; padding: 14px 24px; border-radius: 3px; color: #555a65">
11
+  <svg fill="none" viewBox="0 0 16 16" width="16px" height="16px" style="margin-right: 5px">
12
+    <path fill="#0052d9" d="M8 15A7 7 0 108 1a7 7 0 000 14zM7.4 4h1.2v1.2H7.4V4zm.1 2.5h1V12h-1V6.5z" fillOpacity="0.9"></path>
13
+  </svg>
14
+  该组件于 0.9.0 版本上线,请留意版本。
15
+</div>
16
+
17
+## 引入
18
+
19
+全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
20
+
21
+```json
22
+"usingComponents": {
23
+  "t-action-sheet": "tdesign-miniprogram/action-sheet/action-sheet",
24
+}
25
+```
26
+
27
+## 代码演示
28
+
29
+<a href="https://developers.weixin.qq.com/s/EM7cxim37USn" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a>
30
+
31
+<blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" >
32
+<p>Tips: 请确保开发者工具为打开状态。导入开发者工具后,依次执行:npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p>
33
+</blockquote>
34
+
35
+### 组件类型
36
+
37
+列表型动作面板
38
+
39
+{{ list }}
40
+
41
+宫格型动作面板
42
+
43
+{{ grid }}
44
+
45
+### 组件状态
46
+
47
+宫格型动作面板
48
+
49
+{{ status }}
50
+
51
+### 组件样式
52
+
53
+列表型对齐方式
54
+
55
+{{ align }}
56
+
57
+### 支持指令调用
58
+
59
+```javascript
60
+import ActionSheet, { ActionSheetTheme } from 'tdesign-miniprogram/action-sheet/index';
61
+
62
+// 指令调用不同于组件引用不需要传入visible
63
+const basicListOption: ActionSheetShowOption = {
64
+  theme: ActionSheetTheme.List,
65
+  selector: '#t-action-sheet',
66
+  items: [
67
+    {
68
+      label: '默认选项',
69
+    },
70
+    {
71
+      label: '失效选项',
72
+      disabled: true,
73
+    },
74
+    {
75
+      label: '警告选项',
76
+      color: '#e34d59',
77
+    },
78
+  ],
79
+};
80
+
81
+const handler = ActionSheet.show(basicListOption);
82
+```
83
+
84
+指令调用的关闭如下
85
+
86
+```javascript
87
+handler.close();
88
+```
89
+
90
+
91
+## API
92
+
93
+### ActionSheet Props
94
+
95
+名称 | 类型 | 默认值 | 描述 | 必传
96
+-- | -- | -- | -- | --
97
+style | Object | - | 样式 | N
98
+custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
99
+align | String | center | `0.29.0`。水平对齐方式。可选项:center/left | N
100
+cancel-text | String | - | 设置取消按钮的文本 | N
101
+count | Number | 8 | 设置每页展示菜单的数量,仅当 type=grid 时有效 | N
102
+description | String | - | `0.29.0`。动作面板描述文字 | N
103
+items | Array | - | 必需。菜单项。TS 类型:`Array<string \| ActionSheetItem>` `interface ActionSheetItem {label: string; color?: string; disabled?: boolean;icon?: string;suffixIcon?: string; }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/action-sheet/type.ts) | Y
104
+popup-props | Object | {} | popupProps透传。TS 类型:`PopupProps`,[Popup API Documents](./popup?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/action-sheet/type.ts) | N
105
+show-cancel | Boolean | true | 是否显示取消按钮 | N
106
+show-overlay | Boolean | true | 是否显示遮罩层 | N
107
+theme | String | list | 展示类型,列表和表格形式展示。可选项:list/grid | N
108
+using-custom-navbar | Boolean | false | 是否使用了自定义导航栏 | N
109
+visible | Boolean | false | 必需。显示与隐藏 | Y
110
+default-visible | Boolean | undefined | 必需。显示与隐藏。非受控属性 | Y
111
+
112
+### ActionSheet Events
113
+
114
+名称 | 参数 | 描述
115
+-- | -- | --
116
+cancel | \- | 点击取消按钮时触发
117
+close | `(trigger: TriggerSource)` | 关闭时触发。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/action-sheet/type.ts)。<br/>`type TriggerSource = 'overlay' \| 'command' \| 'select' `<br/>
118
+selected | `(selected: ActionSheetItem \| string, index: number)` | 选择菜单项时触发
119
+### ActionSheet External Classes
120
+
121
+类名 | 描述
122
+-- | --
123
+t-class | 根节点样式类
124
+t-class-cancel | 取消样式类
125
+t-class-content | 内容样式类
126
+
127
+### CSS Variables
128
+
129
+组件提供了下列 CSS 变量,可用于自定义样式。
130
+名称 | 默认值 | 描述 
131
+-- | -- | --
132
+--td-action-sheet-border-color | @gray-color-1 | - 
133
+--td-action-sheet-border-radius | @radius-extra-large | - 
134
+--td-action-sheet-cancel-color | @font-gray-1 | - 
135
+--td-action-sheet-cancel-height | 96rpx | - 
136
+--td-action-sheet-color | @font-gray-1 | - 
137
+--td-action-sheet-description-color | @font-gray-3 | - 
138
+--td-action-sheet-list-item-disabled-color | @font-gray-4 | - 
139
+--td-action-sheet-list-item-height | 112rpx | - 
140
+--td-action-sheet-text-align | center | -

+ 81
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.d.ts View File

@@ -0,0 +1,81 @@
1
+import { SuperComponent } from '../common/src/index';
2
+export default class ActionSheet extends SuperComponent {
3
+    static show: (options: import("./show").ActionSheetShowOption) => WechatMiniprogram.Component.TrivialInstance;
4
+    behaviors: string[];
5
+    externalClasses: string[];
6
+    properties: {
7
+        align?: {
8
+            type: StringConstructor;
9
+            value?: "center" | "left";
10
+        };
11
+        cancelText?: {
12
+            type: StringConstructor;
13
+            value?: string;
14
+        };
15
+        count?: {
16
+            type: NumberConstructor;
17
+            value?: number;
18
+        };
19
+        description?: {
20
+            type: StringConstructor;
21
+            value?: string;
22
+        };
23
+        items: {
24
+            type: ArrayConstructor;
25
+            value?: (string | import("./type").ActionSheetItem)[];
26
+        };
27
+        popupProps?: {
28
+            type: ObjectConstructor;
29
+            value?: import("../popup").TdPopupProps;
30
+        };
31
+        showCancel?: {
32
+            type: BooleanConstructor;
33
+            value?: boolean;
34
+        };
35
+        showOverlay?: {
36
+            type: BooleanConstructor;
37
+            value?: boolean;
38
+        };
39
+        theme?: {
40
+            type: StringConstructor;
41
+            value?: "list" | "grid";
42
+        };
43
+        usingCustomNavbar?: {
44
+            type: BooleanConstructor;
45
+            value?: boolean;
46
+        };
47
+        visible: {
48
+            type: BooleanConstructor;
49
+            value?: boolean;
50
+        };
51
+        defaultVisible: {
52
+            type: BooleanConstructor;
53
+            value?: boolean;
54
+        };
55
+    };
56
+    data: {
57
+        prefix: string;
58
+        classPrefix: string;
59
+        gridThemeItems: any[];
60
+        currentSwiperIndex: number;
61
+        defaultPopUpProps: {};
62
+        defaultPopUpzIndex: number;
63
+    };
64
+    controlledProps: {
65
+        key: string;
66
+        event: string;
67
+    }[];
68
+    ready(): void;
69
+    methods: {
70
+        onSwiperChange(e: WechatMiniprogram.TouchEvent): void;
71
+        splitGridThemeActions(): void;
72
+        show(options: any): void;
73
+        memoInitialData(): void;
74
+        close(): void;
75
+        onPopupVisibleChange({ detail }: {
76
+            detail: any;
77
+        }): void;
78
+        onSelect(event: WechatMiniprogram.TouchEvent): void;
79
+        onCancel(): void;
80
+    };
81
+}

+ 104
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.js View File

@@ -0,0 +1,104 @@
1
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+};
7
+import { chunk } from '../common/utils';
8
+import { SuperComponent, wxComponent } from '../common/src/index';
9
+import config from '../common/config';
10
+import { ActionSheetTheme, show } from './show';
11
+import props from './props';
12
+import useCustomNavbar from '../mixins/using-custom-navbar';
13
+const { prefix } = config;
14
+const name = `${prefix}-action-sheet`;
15
+let ActionSheet = class ActionSheet extends SuperComponent {
16
+    constructor() {
17
+        super(...arguments);
18
+        this.behaviors = [useCustomNavbar];
19
+        this.externalClasses = [`${prefix}-class`, `${prefix}-class-content`, `${prefix}-class-cancel`];
20
+        this.properties = Object.assign({}, props);
21
+        this.data = {
22
+            prefix,
23
+            classPrefix: name,
24
+            gridThemeItems: [],
25
+            currentSwiperIndex: 0,
26
+            defaultPopUpProps: {},
27
+            defaultPopUpzIndex: 11500,
28
+        };
29
+        this.controlledProps = [
30
+            {
31
+                key: 'visible',
32
+                event: 'visible-change',
33
+            },
34
+        ];
35
+        this.methods = {
36
+            onSwiperChange(e) {
37
+                const { detail: { current }, } = e;
38
+                this.setData({
39
+                    currentSwiperIndex: current,
40
+                });
41
+            },
42
+            splitGridThemeActions() {
43
+                if (this.data.theme !== ActionSheetTheme.Grid)
44
+                    return;
45
+                this.setData({
46
+                    gridThemeItems: chunk(this.data.items, this.data.count),
47
+                });
48
+            },
49
+            show(options) {
50
+                this.setData(Object.assign(Object.assign(Object.assign({}, this.initialData), options), { visible: true }));
51
+                this.splitGridThemeActions();
52
+                this.autoClose = true;
53
+                this._trigger('visible-change', { visible: true });
54
+            },
55
+            memoInitialData() {
56
+                this.initialData = Object.assign(Object.assign({}, this.properties), this.data);
57
+            },
58
+            close() {
59
+                this.triggerEvent('close', { trigger: 'command' });
60
+                this._trigger('visible-change', { visible: false });
61
+            },
62
+            onPopupVisibleChange({ detail }) {
63
+                if (!detail.visible) {
64
+                    this.triggerEvent('close', { trigger: 'overlay' });
65
+                    this._trigger('visible-change', { visible: false });
66
+                }
67
+                if (this.autoClose) {
68
+                    this.setData({ visible: false });
69
+                    this.autoClose = false;
70
+                }
71
+            },
72
+            onSelect(event) {
73
+                const { currentSwiperIndex, items, gridThemeItems, count, theme } = this.data;
74
+                const { index } = event.currentTarget.dataset;
75
+                const isSwiperMode = theme === ActionSheetTheme.Grid;
76
+                const item = isSwiperMode ? gridThemeItems[currentSwiperIndex][index] : items[index];
77
+                const realIndex = isSwiperMode ? index + currentSwiperIndex * count : index;
78
+                if (item) {
79
+                    this.triggerEvent('selected', { selected: item, index: realIndex });
80
+                    if (!item.disabled) {
81
+                        this.triggerEvent('close', { trigger: 'select' });
82
+                        this._trigger('visible-change', { visible: false });
83
+                    }
84
+                }
85
+            },
86
+            onCancel() {
87
+                this.triggerEvent('cancel');
88
+                if (this.autoClose) {
89
+                    this.setData({ visible: false });
90
+                    this.autoClose = false;
91
+                }
92
+            },
93
+        };
94
+    }
95
+    ready() {
96
+        this.memoInitialData();
97
+        this.splitGridThemeActions();
98
+    }
99
+};
100
+ActionSheet.show = show;
101
+ActionSheet = __decorate([
102
+    wxComponent()
103
+], ActionSheet);
104
+export default ActionSheet;

+ 10
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.json View File

@@ -0,0 +1,10 @@
1
+{
2
+  "component": true,
3
+  "styleIsolation": "apply-shared",
4
+  "usingComponents": {
5
+    "t-icon": "../icon/icon",
6
+    "t-popup": "../popup/popup",
7
+    "t-grid": "../grid/grid",
8
+    "t-grid-item": "../grid-item/grid-item"
9
+  }
10
+}

+ 49
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.wxml View File

@@ -0,0 +1,49 @@
1
+<wxs src="./action-sheet.wxs" module="this" />
2
+<wxs src="../common/utils.wxs" module="_" />
3
+<import src="./template/list.wxml" />
4
+<import src="./template/grid.wxml" />
5
+
6
+<view id="{{classPrefix}}" style="{{_._style([style, customStyle])}}" class="{{classPrefix}} class {{prefix}}-class">
7
+  <t-popup
8
+    visible="{{visible}}"
9
+    placement="bottom"
10
+    usingCustomNavbar="{{usingCustomNavbar}}"
11
+    bind:visible-change="onPopupVisibleChange"
12
+    show-overlay="{{showOverlay}}"
13
+    z-index="{{ popupProps.zIndex || defaultPopUpzIndex }}"
14
+    overlay-props="{{ popupProps.overlayProps || defaultPopUpProps }}"
15
+  >
16
+    <view
17
+      class="{{_.cls(classPrefix + '__content', [['grid', gridThemeItems.length]])}} {{prefix}}-class-content"
18
+      tabindex="0"
19
+    >
20
+      <view wx:if="{{description}}" tabindex="0" class="{{_.cls(classPrefix + '__description', [align])}}"
21
+        >{{description}}</view
22
+      >
23
+      <block wx:if="{{gridThemeItems.length}}">
24
+        <template is="grid" data="{{classPrefix, prefix, gridThemeItems, count, currentSwiperIndex}}" />
25
+      </block>
26
+      <view wx:elif="{{items && items.length}}" class="{{classPrefix}}__list">
27
+        <block wx:for="{{ items }}" wx:key="index">
28
+          <template
29
+            is="list"
30
+            data="{{index, classPrefix, listThemeItemClass: _.cls(classPrefix + '__list-item', [align, [disabled, item.disabled]]), item}}"
31
+          />
32
+        </block>
33
+      </view>
34
+    </view>
35
+    <slot />
36
+    <view wx:if="{{showCancel}}" class="{{classPrefix}}__footer">
37
+      <view class="{{classPrefix}}__gap-{{theme}}" />
38
+      <view
39
+        class="{{classPrefix}}__cancel {{prefix}}-class-cancel"
40
+        hover-class="{{classPrefix}}__cancel--hover"
41
+        hover-stay-time="70"
42
+        bind:tap="onCancel"
43
+        aria-role="button"
44
+      >
45
+        {{ cancelText }}
46
+      </view>
47
+    </view>
48
+  </t-popup>
49
+</view>

+ 19
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.wxs View File

@@ -0,0 +1,19 @@
1
+var getListThemeItemClass = function (props) {
2
+  var classPrefix = props.classPrefix;
3
+  var item = props.item;
4
+  var prefix = props.prefix;
5
+  var classList = [classPrefix + '__list-item'];
6
+  if (item.disabled) {
7
+    classList.push(prefix + '-is-disabled');
8
+  }
9
+  return classList.join(' ');
10
+};
11
+
12
+var isImage = function (name) {
13
+  return name.indexOf('/') !== -1;
14
+};
15
+
16
+module.exports = {
17
+  getListThemeItemClass: getListThemeItemClass,
18
+  isImage: isImage,
19
+};

+ 169
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/action-sheet.wxss View File

@@ -0,0 +1,169 @@
1
+.t-float-left {
2
+  float: left;
3
+}
4
+.t-float-right {
5
+  float: right;
6
+}
7
+@keyframes tdesign-fade-out {
8
+  from {
9
+    opacity: 1;
10
+  }
11
+  to {
12
+    opacity: 0;
13
+  }
14
+}
15
+.hotspot-expanded.relative {
16
+  position: relative;
17
+}
18
+.hotspot-expanded::after {
19
+  content: '';
20
+  display: block;
21
+  position: absolute;
22
+  left: 0;
23
+  top: 0;
24
+  right: 0;
25
+  bottom: 0;
26
+  transform: scale(1.5);
27
+}
28
+.t-action-sheet__content {
29
+  color: var(--td-action-sheet-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
30
+  border-top-left-radius: var(--td-action-sheet-border-radius, var(--td-radius-extra-large, 24rpx));
31
+  border-top-right-radius: var(--td-action-sheet-border-radius, var(--td-radius-extra-large, 24rpx));
32
+  background-color: var(--td-bg-color-container, var(--td-font-white-1, #ffffff));
33
+  overflow: hidden;
34
+}
35
+.t-action-sheet__content--grid {
36
+  padding-top: 16rpx;
37
+}
38
+.t-action-sheet__content:focus {
39
+  outline: 0;
40
+}
41
+.t-action-sheet__grid {
42
+  padding-bottom: 16rpx;
43
+}
44
+.t-action-sheet__grid--swiper {
45
+  padding-bottom: 48rpx;
46
+}
47
+.t-action-sheet__description {
48
+  color: var(--td-action-sheet-description-color, var(--td-text-color-placeholder, var(--td-font-gray-3, rgba(0, 0, 0, 0.4))));
49
+  line-height: 44rpx;
50
+  font-size: 28rpx;
51
+  text-align: var(--td-action-sheet-text-align, center);
52
+  padding: 24rpx 32rpx;
53
+  position: relative;
54
+}
55
+.t-action-sheet__description:focus {
56
+  outline: 0;
57
+}
58
+.t-action-sheet__description::after {
59
+  content: '';
60
+  display: block;
61
+  position: absolute;
62
+  top: unset;
63
+  bottom: 0;
64
+  left: unset;
65
+  right: unset;
66
+  background-color: var(--td-action-sheet-border-color, var(--td-border-level-1-color, var(--td-gray-color-3, #e7e7e7)));
67
+}
68
+.t-action-sheet__description::after {
69
+  height: 1px;
70
+  left: 0;
71
+  right: 0;
72
+  transform: scaleY(0.5);
73
+}
74
+.t-action-sheet__description--left {
75
+  text-align: left;
76
+}
77
+.t-action-sheet__description--left::after {
78
+  left: 32rpx;
79
+}
80
+.t-action-sheet__list-item {
81
+  display: flex;
82
+  align-items: center;
83
+  justify-content: center;
84
+  position: relative;
85
+  height: var(--td-action-sheet-list-item-height, 112rpx);
86
+  padding: 0 32rpx;
87
+}
88
+.t-action-sheet__list-item::after {
89
+  content: '';
90
+  display: block;
91
+  position: absolute;
92
+  top: unset;
93
+  bottom: 0;
94
+  left: unset;
95
+  right: unset;
96
+  background-color: var(--td-action-sheet-border-color, var(--td-border-level-1-color, var(--td-gray-color-3, #e7e7e7)));
97
+}
98
+.t-action-sheet__list-item::after {
99
+  height: 1px;
100
+  left: 0;
101
+  right: 0;
102
+  transform: scaleY(0.5);
103
+}
104
+.t-action-sheet__list-item:focus {
105
+  outline: 0;
106
+}
107
+.t-action-sheet__list-item--left {
108
+  justify-content: start;
109
+}
110
+.t-action-sheet__list-item--left::after {
111
+  left: 32rpx;
112
+}
113
+.t-action-sheet__list-item--disabled {
114
+  color: var(--td-action-sheet-list-item-disabled-color, var(--td-text-color-disabled, var(--td-font-gray-4, rgba(0, 0, 0, 0.26))));
115
+}
116
+.t-action-sheet__list-item-text {
117
+  font-size: var(--td-font-size-m, 32rpx);
118
+  word-wrap: normal;
119
+  white-space: nowrap;
120
+  overflow: hidden;
121
+  text-overflow: ellipsis;
122
+}
123
+.t-action-sheet__list-item-icon {
124
+  margin-right: 16rpx;
125
+}
126
+.t-action-sheet__list-item-icon--suffix {
127
+  margin-left: auto;
128
+}
129
+.t-action-sheet__swiper-wrap {
130
+  margin-top: 8rpx;
131
+  position: relative;
132
+}
133
+.t-action-sheet__footer {
134
+  background-color: var(--td-bg-color-container, var(--td-font-white-1, #ffffff));
135
+}
136
+.t-action-sheet__gap-list {
137
+  height: 16rpx;
138
+  background-color: var(--td-action-sheet-gap-color, var(--td-bg-color-page, var(--td-gray-color-1, #f3f3f3)));
139
+}
140
+.t-action-sheet__gap-grid {
141
+  height: 1rpx;
142
+  background-color: var(--td-action-sheet-border-color, var(--td-border-level-1-color, var(--td-gray-color-3, #e7e7e7)));
143
+}
144
+.t-action-sheet__cancel {
145
+  display: flex;
146
+  align-items: center;
147
+  justify-content: center;
148
+  color: var(--td-action-sheet-cancel-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
149
+  height: var(--td-action-sheet-cancel-height, 96rpx);
150
+}
151
+.t-action-sheet__dots {
152
+  position: absolute;
153
+  left: 50%;
154
+  bottom: 32rpx;
155
+  transform: translateX(-50%);
156
+  display: flex;
157
+  flex-direction: row;
158
+}
159
+.t-action-sheet__dots-item {
160
+  width: 16rpx;
161
+  height: 16rpx;
162
+  background-color: #dcdcdc;
163
+  border-radius: 50%;
164
+  margin: 0 16rpx;
165
+  transition: all 0.4s ease-in;
166
+}
167
+.t-action-sheet__dots-item.t-is-active {
168
+  background-color: #0052d9;
169
+}

+ 8
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/index.d.ts View File

@@ -0,0 +1,8 @@
1
+/// <reference types="miniprogram-api-typings" />
2
+import { ActionSheetItem, ActionSheetTheme, ActionSheetShowOption } from './show';
3
+export { ActionSheetItem, ActionSheetTheme, ActionSheetShowOption };
4
+declare const _default: {
5
+    show(options: ActionSheetShowOption): WechatMiniprogram.Component.TrivialInstance;
6
+    close(options: ActionSheetShowOption): void;
7
+};
8
+export default _default;

+ 10
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/index.js View File

@@ -0,0 +1,10 @@
1
+import { show, close, ActionSheetTheme } from './show';
2
+export { ActionSheetTheme };
3
+export default {
4
+    show(options) {
5
+        return show(options);
6
+    },
7
+    close(options) {
8
+        return close(options);
9
+    },
10
+};

+ 3
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/props.d.ts View File

@@ -0,0 +1,3 @@
1
+import { TdActionSheetProps } from './type';
2
+declare const props: TdActionSheetProps;
3
+export default props;

+ 46
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/props.js View File

@@ -0,0 +1,46 @@
1
+const props = {
2
+    align: {
3
+        type: String,
4
+        value: 'center',
5
+    },
6
+    cancelText: {
7
+        type: String,
8
+        value: '取消',
9
+    },
10
+    count: {
11
+        type: Number,
12
+        value: 8,
13
+    },
14
+    description: {
15
+        type: String,
16
+        value: '',
17
+    },
18
+    items: {
19
+        type: Array,
20
+    },
21
+    popupProps: {
22
+        type: Object,
23
+        value: {},
24
+    },
25
+    showCancel: {
26
+        type: Boolean,
27
+        value: true,
28
+    },
29
+    showOverlay: {
30
+        type: Boolean,
31
+        value: true,
32
+    },
33
+    theme: {
34
+        type: String,
35
+        value: 'list',
36
+    },
37
+    visible: {
38
+        type: Boolean,
39
+        value: null,
40
+    },
41
+    defaultVisible: {
42
+        type: Boolean,
43
+        value: false,
44
+    },
45
+};
46
+export default props;

+ 31
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/show.d.ts View File

@@ -0,0 +1,31 @@
1
+/// <reference types="miniprogram-api-typings" />
2
+/// <reference types="miniprogram-api-typings" />
3
+export interface ActionSheetItem {
4
+    label: string;
5
+    color?: string;
6
+    disabled?: boolean;
7
+    icon?: string;
8
+}
9
+declare type Context = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
10
+export declare enum ActionSheetTheme {
11
+    List = "list",
12
+    Grid = "grid"
13
+}
14
+interface ActionSheetProps {
15
+    align: 'center' | 'left';
16
+    cancelText?: string;
17
+    count?: number;
18
+    description: string;
19
+    items: Array<string | ActionSheetItem>;
20
+    showCancel?: boolean;
21
+    theme?: ActionSheetTheme;
22
+    visible: boolean;
23
+    defaultVisible?: boolean;
24
+}
25
+export interface ActionSheetShowOption extends Omit<ActionSheetProps, 'visible'> {
26
+    context?: Context;
27
+    selector?: string;
28
+}
29
+export declare const show: (options: ActionSheetShowOption) => WechatMiniprogram.Component.TrivialInstance;
30
+export declare const close: (options: ActionSheetShowOption) => void;
31
+export {};

+ 33
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/show.js View File

@@ -0,0 +1,33 @@
1
+var __rest = (this && this.__rest) || function (s, e) {
2
+    var t = {};
3
+    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+        t[p] = s[p];
5
+    if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+                t[p[i]] = s[p[i]];
9
+        }
10
+    return t;
11
+};
12
+import { getInstance } from '../common/utils';
13
+export var ActionSheetTheme;
14
+(function (ActionSheetTheme) {
15
+    ActionSheetTheme["List"] = "list";
16
+    ActionSheetTheme["Grid"] = "grid";
17
+})(ActionSheetTheme || (ActionSheetTheme = {}));
18
+export const show = function (options) {
19
+    const _a = Object.assign({}, options), { context, selector = '#t-action-sheet' } = _a, otherOptions = __rest(_a, ["context", "selector"]);
20
+    const instance = getInstance(context, selector);
21
+    if (instance) {
22
+        instance.show(Object.assign({}, otherOptions));
23
+        return instance;
24
+    }
25
+    console.error('未找到组件,请确认 selector && context 是否正确');
26
+};
27
+export const close = function (options) {
28
+    const { context, selector = '#t-action-sheet' } = Object.assign({}, options);
29
+    const instance = getInstance(context, selector);
30
+    if (instance) {
31
+        instance.close();
32
+    }
33
+};

+ 51
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/template/grid.wxml View File

@@ -0,0 +1,51 @@
1
+<template name="grid">
2
+  <block wx:if="{{gridThemeItems.length === 1}}">
3
+    <t-grid align="center" t-class="{{classPrefix}}__grid" column="{{count / 2}}" class="{{classPrefix}}__single-wrap">
4
+      <t-grid-item
5
+        t-class="{{classPrefix}}__grid-item"
6
+        class="{{classPrefix}}__square"
7
+        wx:for="{{gridThemeItems[0]}}"
8
+        wx:key="index"
9
+        bind:tap="onSelect"
10
+        data-index="{{index}}"
11
+        icon="{{ { name: item.icon, color: item.color } }}"
12
+        text="{{item.label || ''}}"
13
+        image="{{item.image || ''}}"
14
+        style="--td-grid-item-text-color: {{item.color}}"
15
+      >
16
+      </t-grid-item>
17
+    </t-grid>
18
+  </block>
19
+  <block wx:elif="{{gridThemeItems.length > 1}}">
20
+    <view class="{{classPrefix}}__swiper-wrap">
21
+      <swiper style="height: 456rpx" autoplay="{{false}}" current="{{currentSwiperIndex}}" bindchange="onSwiperChange">
22
+        <swiper-item wx:for="{{gridThemeItems}}" wx:key="index">
23
+          <t-grid align="center" t-class="{{classPrefix}}__grid {{classPrefix}}__grid--swiper" column="{{count / 2}}">
24
+            <t-grid-item
25
+              t-class="{{classPrefix}}__grid-item"
26
+              class="{{classPrefix}}__square"
27
+              wx:for="{{item}}"
28
+              wx:key="index"
29
+              data-index="{{index}}"
30
+              bind:tap="onSelect"
31
+              icon="{{ { name: item.icon, color: item.color } }}"
32
+              text="{{item.label || ''}}"
33
+              image="{{item.image || ''}}"
34
+              style="--td-grid-item-text-color: {{item.color}}"
35
+            >
36
+            </t-grid-item>
37
+          </t-grid>
38
+        </swiper-item>
39
+      </swiper>
40
+      <view class="{{classPrefix}}__nav">
41
+        <view class="{{classPrefix}}__dots">
42
+          <view
43
+            wx:for="{{gridThemeItems.length}}"
44
+            wx:key="index"
45
+            class="{{classPrefix}}__dots-item {{index === currentSwiperIndex ? prefix + '-is-active' : ''}}"
46
+          />
47
+        </view>
48
+      </view>
49
+    </view>
50
+  </block>
51
+</template>

+ 20
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/template/list.wxml View File

@@ -0,0 +1,20 @@
1
+<template name="list">
2
+  <view
3
+    data-index="{{index}}"
4
+    style="{{ item.color ? 'color: ' + item.color : '' }}"
5
+    class="{{listThemeItemClass}}"
6
+    bind:tap="onSelect"
7
+    aria-role="{{ariaRole || 'button'}}"
8
+    aria-label="{{item.label || item}}"
9
+    tabindex="0"
10
+  >
11
+    <t-icon wx:if="{{item.icon}}" name="{{item.icon}}" class="{{classPrefix}}__list-item-icon" size="48rpx"></t-icon>
12
+    <view class="{{classPrefix}}__list-item-text">{{item.label || item}}</view>
13
+    <t-icon
14
+      wx:if="{{item.suffixIcon}}"
15
+      name="{{item.suffixIcon}}"
16
+      class="{{classPrefix}}__list-item-icon {{classPrefix}}__list-item-icon--suffix"
17
+      size="48rpx"
18
+    ></t-icon>
19
+  </view>
20
+</template>

+ 58
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/type.d.ts View File

@@ -0,0 +1,58 @@
1
+import { PopupProps } from '../popup/index';
2
+export interface TdActionSheetProps {
3
+    align?: {
4
+        type: StringConstructor;
5
+        value?: 'center' | 'left';
6
+    };
7
+    cancelText?: {
8
+        type: StringConstructor;
9
+        value?: string;
10
+    };
11
+    count?: {
12
+        type: NumberConstructor;
13
+        value?: number;
14
+    };
15
+    description?: {
16
+        type: StringConstructor;
17
+        value?: string;
18
+    };
19
+    items: {
20
+        type: ArrayConstructor;
21
+        value?: Array<string | ActionSheetItem>;
22
+    };
23
+    popupProps?: {
24
+        type: ObjectConstructor;
25
+        value?: PopupProps;
26
+    };
27
+    showCancel?: {
28
+        type: BooleanConstructor;
29
+        value?: boolean;
30
+    };
31
+    showOverlay?: {
32
+        type: BooleanConstructor;
33
+        value?: boolean;
34
+    };
35
+    theme?: {
36
+        type: StringConstructor;
37
+        value?: 'list' | 'grid';
38
+    };
39
+    usingCustomNavbar?: {
40
+        type: BooleanConstructor;
41
+        value?: boolean;
42
+    };
43
+    visible: {
44
+        type: BooleanConstructor;
45
+        value?: boolean;
46
+    };
47
+    defaultVisible: {
48
+        type: BooleanConstructor;
49
+        value?: boolean;
50
+    };
51
+}
52
+export interface ActionSheetItem {
53
+    label: string;
54
+    color?: string;
55
+    disabled?: boolean;
56
+    icon?: string;
57
+    suffixIcon?: string;
58
+}

+ 1
- 0
miniprogram_npm/tdesign-miniprogram/action-sheet/type.js View File

@@ -0,0 +1 @@
1
+export {};

+ 28
- 0
miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.d.ts View File

@@ -0,0 +1,28 @@
1
+import { SuperComponent, RelationsOptions } from '../common/src/index';
2
+export default class AvatarGroup extends SuperComponent {
3
+    externalClasses: string[];
4
+    properties: import("./type").TdAvatarGroupProps;
5
+    data: {
6
+        prefix: string;
7
+        classPrefix: string;
8
+        hasChild: boolean;
9
+        length: number;
10
+        className: string;
11
+    };
12
+    options: {
13
+        multipleSlots: boolean;
14
+    };
15
+    relations: RelationsOptions;
16
+    lifetimes: {
17
+        attached(): void;
18
+        ready(): void;
19
+    };
20
+    observers: {
21
+        'cascading, size'(): void;
22
+    };
23
+    methods: {
24
+        setClass(): void;
25
+        handleMax(): void;
26
+        handleChildCascading(): void;
27
+    };
28
+}

+ 86
- 0
miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.js View File

@@ -0,0 +1,86 @@
1
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+};
7
+import { SuperComponent, wxComponent } from '../common/src/index';
8
+import config from '../common/config';
9
+import avatarGroupProps from './props';
10
+const { prefix } = config;
11
+const name = `${prefix}-avatar-group`;
12
+let AvatarGroup = class AvatarGroup extends SuperComponent {
13
+    constructor() {
14
+        super(...arguments);
15
+        this.externalClasses = [`${prefix}-class`, `${prefix}-class-content`, `${prefix}-class-image`];
16
+        this.properties = avatarGroupProps;
17
+        this.data = {
18
+            prefix,
19
+            classPrefix: name,
20
+            hasChild: true,
21
+            length: 0,
22
+            className: '',
23
+        };
24
+        this.options = {
25
+            multipleSlots: true,
26
+        };
27
+        this.relations = {
28
+            '../avatar/avatar': {
29
+                type: 'descendant',
30
+            },
31
+        };
32
+        this.lifetimes = {
33
+            attached() {
34
+                this.setClass();
35
+            },
36
+            ready() {
37
+                this.setData({
38
+                    length: this.$children.length,
39
+                });
40
+                this.handleMax();
41
+                this.handleChildCascading();
42
+            },
43
+        };
44
+        this.observers = {
45
+            'cascading, size'() {
46
+                this.setClass();
47
+            },
48
+        };
49
+        this.methods = {
50
+            setClass() {
51
+                const { cascading, size } = this.properties;
52
+                const direction = cascading.split('-')[0];
53
+                const classList = [
54
+                    name,
55
+                    `${prefix}-class`,
56
+                    `${name}-offset-${direction}-${size.indexOf('px') > -1 ? 'medium' : size}`,
57
+                ];
58
+                this.setData({
59
+                    className: classList.join(' '),
60
+                });
61
+            },
62
+            handleMax() {
63
+                const { max } = this.data;
64
+                const len = this.$children.length;
65
+                if (!max || max > len)
66
+                    return;
67
+                const restAvatars = this.$children.splice(max, len - max);
68
+                restAvatars.forEach((child) => {
69
+                    child.hide();
70
+                });
71
+            },
72
+            handleChildCascading() {
73
+                if (this.properties.cascading === 'right-up')
74
+                    return;
75
+                const defaultZIndex = 100;
76
+                this.$children.forEach((child, index) => {
77
+                    child.updateCascading(defaultZIndex - index * 10);
78
+                });
79
+            },
80
+        };
81
+    }
82
+};
83
+AvatarGroup = __decorate([
84
+    wxComponent()
85
+], AvatarGroup);
86
+export default AvatarGroup;

+ 7
- 0
miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.json View File

@@ -0,0 +1,7 @@
1
+{
2
+  "component": true,
3
+  "styleIsolation": "apply-shared",
4
+  "usingComponents": {
5
+    "t-avatar": "../avatar/avatar"
6
+  }
7
+}

+ 20
- 0
miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.wxml View File

@@ -0,0 +1,20 @@
1
+<wxs src="../common/utils.wxs" module="_" />
2
+
3
+<view style="{{_._style([style, customStyle])}}" class="{{className}} class">
4
+  <slot />
5
+  <!-- 自定义折叠元素 -->
6
+  <view class="{{classPrefix}}__collapse--slot">
7
+    <slot name="collapse-avatar" />
8
+  </view>
9
+  <!-- 默认折叠元素 -->
10
+  <view class="{{classPrefix}}__collapse--default" wx:if="{{max && (max < length)}}">
11
+    <t-avatar
12
+      t-class-image="{{prefix}}-avatar--border {{prefix}}-avatar--border-{{size}} {{prefix}}-class-image"
13
+      t-class-content="{{prefix}}-class-content"
14
+      size="{{size}}"
15
+      icon="{{ collapseAvatar ? '' : 'user-add'}}"
16
+      aria-role="none"
17
+      >{{collapseAvatar}}</t-avatar
18
+    >
19
+  </view>
20
+</view>

+ 137
- 0
miniprogram_npm/tdesign-miniprogram/avatar-group/avatar-group.wxss View File

@@ -0,0 +1,137 @@
1
+.t-float-left {
2
+  float: left;
3
+}
4
+.t-float-right {
5
+  float: right;
6
+}
7
+@keyframes tdesign-fade-out {
8
+  from {
9
+    opacity: 1;
10
+  }
11
+  to {
12
+    opacity: 0;
13
+  }
14
+}
15
+.hotspot-expanded.relative {
16
+  position: relative;
17
+}
18
+.hotspot-expanded::after {
19
+  content: '';
20
+  display: block;
21
+  position: absolute;
22
+  left: 0;
23
+  top: 0;
24
+  right: 0;
25
+  bottom: 0;
26
+  transform: scale(1.5);
27
+}
28
+.t-avatar {
29
+  display: flex;
30
+  align-items: center;
31
+  justify-content: center;
32
+  box-sizing: border-box;
33
+  background-color: var(--td-avatar-bg-color, var(--td-brand-color-light-active, var(--td-primary-color-2, #d9e1ff)));
34
+  color: var(--td-avatar-content-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
35
+}
36
+.t-avatar__wrapper {
37
+  display: inline-flex;
38
+  position: relative;
39
+  vertical-align: top;
40
+  margin-left: var(--td-avatar-margin-left, 0);
41
+}
42
+.t-avatar--large {
43
+  width: var(--td-avatar-large-width, 128rpx);
44
+  height: var(--td-avatar-large-width, 128rpx);
45
+  font-size: var(--td-avatar-text-large-font-size, 16px);
46
+}
47
+.t-avatar--large .t-avatar__icon {
48
+  font-size: var(--td-avatar-icon-large-font-size, 64rpx);
49
+}
50
+.t-avatar--medium {
51
+  width: var(--td-avatar-medium-width, 96rpx);
52
+  height: var(--td-avatar-medium-width, 96rpx);
53
+  font-size: var(--td-avatar-text-medium-font-size, var(--td-font-size-base, 28rpx));
54
+}
55
+.t-avatar--medium .t-avatar__icon {
56
+  font-size: var(--td-avatar-icon-medium-font-size, 48rpx);
57
+}
58
+.t-avatar--small {
59
+  width: var(--td-avatar-small-width, 80rpx);
60
+  height: var(--td-avatar-small-width, 80rpx);
61
+  font-size: var(--td-avatar-text-small-font-size, var(--td-font-size-s, 24rpx));
62
+}
63
+.t-avatar--small .t-avatar__icon {
64
+  font-size: var(--td-avatar-icon-small-font-size, 40rpx);
65
+}
66
+.t-avatar .t-image,
67
+.t-avatar__image {
68
+  width: 100%;
69
+  height: 100%;
70
+}
71
+.t-avatar--circle {
72
+  border-radius: var(--td-avatar-circle-border-radius, var(--td-radius-circle, 50%));
73
+  overflow: hidden;
74
+}
75
+.t-avatar--round {
76
+  border-radius: var(--td-avatar-round-border-radius, var(--td-radius-default, 12rpx));
77
+  overflow: hidden;
78
+}
79
+.t-avatar__text,
80
+.t-avatar__icon {
81
+  width: 100%;
82
+  height: 100%;
83
+  display: flex;
84
+  align-items: center;
85
+  justify-content: center;
86
+}
87
+.t-avatar__text:empty,
88
+.t-avatar__icon:empty {
89
+  width: 0;
90
+  height: 0;
91
+}
92
+.t-avatar--border {
93
+  border-color: var(--td-avatar-border-color, #fff);
94
+  border-style: solid;
95
+}
96
+.t-avatar--border-small {
97
+  border-width: var(--td-avatar-border-width-small, 4rpx);
98
+}
99
+.t-avatar--border-medium {
100
+  border-width: var(--td-avatar-border-width-medium, 6rpx);
101
+}
102
+.t-avatar--border-large {
103
+  border-width: var(--td-avatar-border-width-large, 8rpx);
104
+}
105
+.t-avatar-group {
106
+  display: inline-flex;
107
+  align-items: center;
108
+}
109
+.t-avatar-group-offset-left-small {
110
+  --td-avatar-margin-left: var(--td-avatar-group-margin-left-small, -4px);
111
+}
112
+.t-avatar-group-offset-left-medium {
113
+  --td-avatar-margin-left: var(--td-avatar-group-margin-left-medium, -6px);
114
+}
115
+.t-avatar-group-offset-left-large {
116
+  --td-avatar-margin-left: var(--td-avatar-group-margin-left-large, -8px);
117
+}
118
+.t-avatar-group-offset-right-small {
119
+  --td-avatar-margin-left: var(--td-avatar-group-margin-left-small, -4px);
120
+}
121
+.t-avatar-group-offset-right-medium {
122
+  --td-avatar-margin-left: var(--td-avatar-group-margin-left-medium, -6px);
123
+}
124
+.t-avatar-group-offset-right-large {
125
+  --td-avatar-margin-left: var(--td-avatar-group-margin-left-large, -8px);
126
+}
127
+.t-avatar-group__collapse--slot {
128
+  float: left;
129
+}
130
+.t-avatar-group__collapse--slot:not(:empty) + .t-avatar-group__collapse--default {
131
+  display: none;
132
+  float: left;
133
+}
134
+.t-avatar-group__collapse--slot:empty + .t-avatar-group__collapse--default {
135
+  display: block;
136
+  float: left;
137
+}

+ 3
- 0
miniprogram_npm/tdesign-miniprogram/avatar-group/props.d.ts View File

@@ -0,0 +1,3 @@
1
+import { TdAvatarGroupProps } from './type';
2
+declare const props: TdAvatarGroupProps;
3
+export default props;

+ 20
- 0
miniprogram_npm/tdesign-miniprogram/avatar-group/props.js View File

@@ -0,0 +1,20 @@
1
+const props = {
2
+    cascading: {
3
+        type: String,
4
+        value: 'left-up',
5
+    },
6
+    collapseAvatar: {
7
+        type: String,
8
+    },
9
+    externalClasses: {
10
+        type: Array,
11
+    },
12
+    max: {
13
+        type: Number,
14
+    },
15
+    size: {
16
+        type: String,
17
+        value: 'medium',
18
+    },
19
+};
20
+export default props;

+ 27
- 0
miniprogram_npm/tdesign-miniprogram/avatar-group/type.d.ts View File

@@ -0,0 +1,27 @@
1
+export interface TdAvatarGroupProps {
2
+    cascading?: {
3
+        type: StringConstructor;
4
+        value?: CascadingValue;
5
+    };
6
+    collapseAvatar?: {
7
+        type: StringConstructor;
8
+        value?: string;
9
+    };
10
+    style?: {
11
+        type: StringConstructor;
12
+        value?: string;
13
+    };
14
+    externalClasses?: {
15
+        type: ArrayConstructor;
16
+        value?: ['t-class', 't-class-image', 't-class-content'];
17
+    };
18
+    max?: {
19
+        type: NumberConstructor;
20
+        value?: number;
21
+    };
22
+    size?: {
23
+        type: StringConstructor;
24
+        value?: string;
25
+    };
26
+}
27
+export declare type CascadingValue = 'left-up' | 'right-up';

+ 1
- 0
miniprogram_npm/tdesign-miniprogram/avatar-group/type.js View File

@@ -0,0 +1 @@
1
+export {};

+ 60
- 0
miniprogram_npm/tdesign-miniprogram/avatar/README.en-US.md View File

@@ -0,0 +1,60 @@
1
+:: BASE_DOC ::
2
+
3
+## API
4
+### Avatar Props
5
+
6
+name | type | default | description | required
7
+-- | -- | -- | -- | --
8
+alt | String | - | show it when url is not valid | N
9
+badge-props | Object | - | Typescript:`BadgeProps`,[Badge API Documents](./badge?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/avatar/type.ts) | N
10
+bordered | Boolean | false | \- | N
11
+external-classes | Array | - | `['t-class', 't-class-image', 't-class-icon', 't-class-alt', 't-class-content']` | N
12
+hide-on-load-failed | Boolean | false | hide image when loading image failed | N
13
+icon | String / Object | - | \- | N
14
+image | String | - | images url | N
15
+image-props | Object | - | \- | N
16
+shape | String | circle | shape。options:circle/round。Typescript:`ShapeEnum ` `type ShapeEnum = 'circle' \| 'round'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/avatar/type.ts) | N
17
+size | String | medium | size | N
18
+
19
+### Avatar Events
20
+
21
+name | params | description
22
+-- | -- | --
23
+error | \- | trigger on image load failed
24
+
25
+### AvatarGroup Props
26
+
27
+name | type | default | description | required
28
+-- | -- | -- | -- | --
29
+cascading | String | 'right-up' | multiple images cascading。options:left-up/right-up。Typescript:`CascadingValue` `type CascadingValue = 'left-up' \| 'right-up'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/avatar-group/type.ts) | N
30
+collapse-avatar | String / Slot | - | \- | N
31
+external-classes | Array | - | `['t-class', 't-class-image', 't-class-content']` | N
32
+max | Number | - | \- | N
33
+size | String | medium | size | N
34
+
35
+
36
+### CSS Variables
37
+The component provides the following CSS variables, which can be used to customize styles.
38
+Name | Default Value | Description 
39
+-- | -- | --
40
+--td-avatar-group-margin-left-large | -8px | - 
41
+--td-avatar-group-margin-left-medium | -6px | - 
42
+--td-avatar-group-margin-left-small | -4px | - 
43
+--td-avatar-bg-color | @brand-color-light-active | - 
44
+--td-avatar-border-color | #fff | - 
45
+--td-avatar-border-width-large | 8rpx | - 
46
+--td-avatar-border-width-medium | 6rpx | - 
47
+--td-avatar-border-width-small | 4rpx | - 
48
+--td-avatar-circle-border-radius | @radius-circle | - 
49
+--td-avatar-content-color | @brand-color | - 
50
+--td-avatar-icon-large-font-size | 64rpx | - 
51
+--td-avatar-icon-medium-font-size | 48rpx | - 
52
+--td-avatar-icon-small-font-size | 40rpx | - 
53
+--td-avatar-large-width | 128rpx | - 
54
+--td-avatar-margin-left | 0 | - 
55
+--td-avatar-medium-width | 96rpx | - 
56
+--td-avatar-round-border-radius | @radius-default | - 
57
+--td-avatar-small-width | 80rpx | - 
58
+--td-avatar-text-large-font-size | 16px | - 
59
+--td-avatar-text-medium-font-size | @font-size-base | - 
60
+--td-avatar-text-small-font-size | @font-size-s | - 

+ 133
- 0
miniprogram_npm/tdesign-miniprogram/avatar/README.md View File

@@ -0,0 +1,133 @@
1
+---
2
+title: Avatar 头像
3
+description: 用于展示用户头像信息,除了纯展示也可点击进入个人详情等操作。
4
+spline: data
5
+isComponent: true
6
+---
7
+
8
+<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-99%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-85%25-blue" /></span>
9
+## 引入
10
+
11
+全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
12
+
13
+```json
14
+"usingComponents": {
15
+  "t-avatar": "tdesign-miniprogram/avatar/avatar",
16
+  "t-avatar-group": "tdesign-miniprogram/avatar-group/avatar-group"
17
+}
18
+```
19
+
20
+## 代码演示
21
+
22
+<a href="https://developers.weixin.qq.com/s/a86Sfimw7VSO" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a>
23
+
24
+<blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" >
25
+<p>Tips: 请确保开发者工具为打开状态。导入开发者工具后,依次执行:npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p>
26
+</blockquote>
27
+
28
+### 头像类型
29
+
30
+图片头像
31
+
32
+{{ image-avatar }}
33
+
34
+字符头像
35
+
36
+{{ character-avatar }}
37
+
38
+图标头像
39
+
40
+{{ icon-avatar }}
41
+
42
+徽标头像
43
+
44
+{{ badge-avatar }}
45
+
46
+
47
+### 组合头像
48
+
49
+纯展示
50
+
51
+{{ exhibition }}
52
+
53
+带操作
54
+
55
+{{ action }}
56
+
57
+### 头像尺寸
58
+
59
+头像 large/medium/small 尺寸
60
+
61
+{{ size }}
62
+
63
+## API
64
+### Avatar Props
65
+
66
+名称 | 类型 | 默认值 | 说明 | 必传
67
+-- | -- | -- | -- | --
68
+alt | String | - | 头像替换文本,仅当图片加载失败时有效 | N
69
+badge-props | Object | - | 头像右上角提示信息,继承 Badge 组件的全部特性。如:小红点,或者数字。TS 类型:`BadgeProps`,[Badge API Documents](./badge?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/avatar/type.ts) | N
70
+bordered | Boolean | false | 已废弃。是否显示外边框 | N
71
+hide-on-load-failed | Boolean | false | 加载失败时隐藏图片 | N
72
+icon | String / Object | - | 图标。值为字符串表示图标名称,值为 `Object` 类型,表示透传至 `icon`。 | N
73
+image | String | - | 图片地址 | N
74
+image-props | Object | - | 透传至 Image 组件 | N
75
+shape | String | circle | 形状。可选项:circle/round。TS 类型:`ShapeEnum ` `type ShapeEnum = 'circle' \| 'round'`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/avatar/type.ts) | N
76
+size | String | medium | 尺寸,示例值:small/medium/large/24px/38px 等 | N
77
+
78
+### Avatar Events
79
+
80
+名称 | 参数 | 描述
81
+-- | -- | --
82
+error | \- | 图片加载失败时触发
83
+
84
+### Avatar 外部样式类
85
+类名 | 说明
86
+-- | -- 
87
+t-class | 根节点样式类
88
+t-class-image | 图片样式类
89
+t-class-icon | 图标样式类
90
+t-class-alt | 替代文本样式类
91
+t-class-content | 内容样式类
92
+
93
+### AvatarGroup Props
94
+
95
+名称 | 类型 | 默认值 | 说明 | 必传
96
+-- | -- | -- | -- | --
97
+cascading | String | 'left-up' | 图片之间的层叠关系,可选值:左侧图片在上和右侧图片在上。可选项:left-up/right-up。TS 类型:`CascadingValue` `type CascadingValue = 'left-up' \| 'right-up'`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/avatar-group/type.ts) | N
98
+collapse-avatar | String / Slot | - | 头像数量超出时,会出现一个头像折叠元素。该元素内容可自定义。默认为 `+N`。示例:`+5`,`...`, `更多` | N
99
+max | Number | - | 能够同时显示的最多头像数量 | N
100
+size | String | medium | 尺寸,示例值:small/medium/large/24px/38px 等。优先级低于 Avatar.size | N
101
+
102
+### AvatarGroup 外部样式类
103
+类名 | 说明
104
+-- | -- 
105
+t-class | 根节点样式类
106
+t-class-image | 图片样式类
107
+t-class-content | 内容样式类
108
+
109
+### CSS 变量
110
+组件提供了下列 CSS 变量,可用于自定义样式。
111
+名称 | 默认值 | 描述 
112
+-- | -- | --
113
+--td-avatar-group-margin-left-large | -8px | - 
114
+--td-avatar-group-margin-left-medium | -6px | - 
115
+--td-avatar-group-margin-left-small | -4px | - 
116
+--td-avatar-bg-color | @brand-color-light-active | - 
117
+--td-avatar-border-color | #fff | - 
118
+--td-avatar-border-width-large | 8rpx | - 
119
+--td-avatar-border-width-medium | 6rpx | - 
120
+--td-avatar-border-width-small | 4rpx | - 
121
+--td-avatar-circle-border-radius | @radius-circle | - 
122
+--td-avatar-content-color | @brand-color | - 
123
+--td-avatar-icon-large-font-size | 64rpx | - 
124
+--td-avatar-icon-medium-font-size | 48rpx | - 
125
+--td-avatar-icon-small-font-size | 40rpx | - 
126
+--td-avatar-large-width | 128rpx | - 
127
+--td-avatar-margin-left | 0 | - 
128
+--td-avatar-medium-width | 96rpx | - 
129
+--td-avatar-round-border-radius | @radius-default | - 
130
+--td-avatar-small-width | 80rpx | - 
131
+--td-avatar-text-large-font-size | 16px | - 
132
+--td-avatar-text-medium-font-size | @font-size-base | - 
133
+--td-avatar-text-small-font-size | @font-size-s | - 

+ 23
- 0
miniprogram_npm/tdesign-miniprogram/avatar/avatar.d.ts View File

@@ -0,0 +1,23 @@
1
+/// <reference types="miniprogram-api-typings" />
2
+import { SuperComponent, RelationsOptions } from '../common/src/index';
3
+export default class Avatar extends SuperComponent {
4
+    options: WechatMiniprogram.Component.ComponentOptions;
5
+    externalClasses: string[];
6
+    properties: import("./type").TdAvatarProps;
7
+    data: {
8
+        prefix: string;
9
+        classPrefix: string;
10
+        isShow: boolean;
11
+        zIndex: number;
12
+        borderedWithGroup: boolean;
13
+    };
14
+    relations: RelationsOptions;
15
+    observers: {
16
+        icon(icon: any): void;
17
+    };
18
+    methods: {
19
+        hide(): void;
20
+        updateCascading(zIndex: any): void;
21
+        onLoadError(e: WechatMiniprogram.CustomEvent): void;
22
+    };
23
+}

+ 76
- 0
miniprogram_npm/tdesign-miniprogram/avatar/avatar.js View File

@@ -0,0 +1,76 @@
1
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+};
7
+import { SuperComponent, wxComponent } from '../common/src/index';
8
+import config from '../common/config';
9
+import avatarProps from './props';
10
+import { setIcon } from '../common/utils';
11
+const { prefix } = config;
12
+const name = `${prefix}-avatar`;
13
+let Avatar = class Avatar extends SuperComponent {
14
+    constructor() {
15
+        super(...arguments);
16
+        this.options = {
17
+            multipleSlots: true,
18
+        };
19
+        this.externalClasses = [
20
+            `${prefix}-class`,
21
+            `${prefix}-class-image`,
22
+            `${prefix}-class-icon`,
23
+            `${prefix}-class-alt`,
24
+            `${prefix}-class-content`,
25
+        ];
26
+        this.properties = avatarProps;
27
+        this.data = {
28
+            prefix,
29
+            classPrefix: name,
30
+            isShow: true,
31
+            zIndex: 0,
32
+            borderedWithGroup: false,
33
+        };
34
+        this.relations = {
35
+            '../avatar-group/avatar-group': {
36
+                type: 'ancestor',
37
+                linked(parent) {
38
+                    var _a;
39
+                    this.parent = parent;
40
+                    this.setData({
41
+                        size: (_a = this.data.size) !== null && _a !== void 0 ? _a : parent.data.size,
42
+                        borderedWithGroup: true,
43
+                    });
44
+                },
45
+            },
46
+        };
47
+        this.observers = {
48
+            icon(icon) {
49
+                const obj = setIcon('icon', icon, '');
50
+                this.setData(Object.assign({}, obj));
51
+            },
52
+        };
53
+        this.methods = {
54
+            hide() {
55
+                this.setData({
56
+                    isShow: false,
57
+                });
58
+            },
59
+            updateCascading(zIndex) {
60
+                this.setData({ zIndex });
61
+            },
62
+            onLoadError(e) {
63
+                if (this.properties.hideOnLoadFailed) {
64
+                    this.setData({
65
+                        isShow: false,
66
+                    });
67
+                }
68
+                this.triggerEvent('error', e.detail);
69
+            },
70
+        };
71
+    }
72
+};
73
+Avatar = __decorate([
74
+    wxComponent()
75
+], Avatar);
76
+export default Avatar;

+ 9
- 0
miniprogram_npm/tdesign-miniprogram/avatar/avatar.json View File

@@ -0,0 +1,9 @@
1
+{
2
+  "component": true,
3
+  "styleIsolation": "apply-shared",
4
+  "usingComponents": {
5
+    "t-icon": "../icon/icon",
6
+    "t-badge": "../badge/badge",
7
+    "t-image": "../image/image"
8
+  }
9
+}

+ 54
- 0
miniprogram_npm/tdesign-miniprogram/avatar/avatar.wxml View File

@@ -0,0 +1,54 @@
1
+<import src="../common/template/icon.wxml" />
2
+<wxs src="../common/utils.wxs" module="_" />
3
+<wxs src="./avatar.wxs" module="this" />
4
+
5
+<view
6
+  class="{{classPrefix}}__wrapper class {{prefix}}-class"
7
+  style="{{_._style([this.getStyles(isShow, zIndex), style, customStyle])}}"
8
+>
9
+  <t-badge
10
+    color="{{badgeProps.color || ''}}"
11
+    content="{{badgeProps.content || ''}}"
12
+    count="{{badgeProps.count || 0}}"
13
+    dot="{{badgeProps.dot || false}}"
14
+    max-count="{{badgeProps.maxCount || 99}}"
15
+    offset="{{badgeProps.offset || []}}"
16
+    shape="{{badgeProps.shape || 'circle'}}"
17
+    show-zero="{{badgeProps.showZero || false}}"
18
+    size="{{badgeProps.size || 'medium'}}"
19
+    t-class="{{badgeProps.tClass}}"
20
+    t-class-content="{{badgeProps.tClassContent}}"
21
+    t-class-count="{{badgeProps.tClassCount}}"
22
+  >
23
+    <view
24
+      class="{{this.getClass(classPrefix, size, shape, bordered || borderedWithGroup)}} {{prefix}}-class-image"
25
+      style="{{this.getSize(size)}}"
26
+      aria-label="{{ ariaLabel || alt ||'头像'}}"
27
+      aria-role="{{ ariaRole || 'img'}}"
28
+      aria-hidden="{{ ariaHidden }}"
29
+    >
30
+      <t-image
31
+        wx:if="{{image}}"
32
+        t-class="{{prefix}}-image {{classPrefix}}__image"
33
+        t-class-load="{{prefix}}-class-alt"
34
+        style="{{imageProps && imageProps.style || ''}}"
35
+        src="{{image}}"
36
+        mode="{{imageProps && imageProps.mode || 'aspectFill'}}"
37
+        lazy="{{imageProps && imageProps.lazy || false}}"
38
+        loading="{{imageProps && imageProps.loading || 'default'}}"
39
+        shape="{{imageProps && imageProps.shape || 'round'}}"
40
+        webp="{{imageProps && imageProps.webp || false}}"
41
+        error="{{alt || 'default'}}"
42
+        bind:error="onLoadError"
43
+      />
44
+      <template
45
+        wx:elif="{{iconName || _.isNoEmptyObj(iconData)}}"
46
+        is="icon"
47
+        data="{{class: classPrefix + '__icon', tClass: prefix + '-class-icon', name: iconName, ...iconData}}"
48
+      />
49
+      <view wx:else class="{{classPrefix}}__text {{prefix}}-class-content">
50
+        <slot />
51
+      </view>
52
+    </view>
53
+  </t-badge>
54
+</view>

+ 26
- 0
miniprogram_npm/tdesign-miniprogram/avatar/avatar.wxs View File

@@ -0,0 +1,26 @@
1
+module.exports = {
2
+  getClass: function (classPrefix, size, shape, bordered) {
3
+    var hasPx = (size || '').indexOf('px') > -1;
4
+    var borderSize = hasPx ? 'medium' : size;
5
+    var classNames = [
6
+      classPrefix,
7
+      classPrefix + (shape === 'round' ? '--round' : '--circle'),
8
+      bordered ? classPrefix + '--border' + ' ' + classPrefix + '--border-' + borderSize : '',
9
+      hasPx ? '' : classPrefix + '--' + size,
10
+    ];
11
+    return classNames.join(' ');
12
+  },
13
+
14
+  getSize: function (size = 'medium') {
15
+    var pxIndex = size.indexOf('px');
16
+    if (pxIndex > -1) {
17
+      return 'width:' + size + ';height:' + size + ';font-size:' + ((size.slice(0, pxIndex) / 8) * 3 + 2) + 'px;';
18
+    }
19
+  },
20
+
21
+  getStyles: function (isShow, zIndex) {
22
+    var displayStyle = isShow ? '' : 'display: none;';
23
+    var zIndexStyle = zIndex ? 'z-index:' + zIndex + ';' : '';
24
+    return displayStyle + zIndexStyle;
25
+  },
26
+};

+ 104
- 0
miniprogram_npm/tdesign-miniprogram/avatar/avatar.wxss View File

@@ -0,0 +1,104 @@
1
+.t-float-left {
2
+  float: left;
3
+}
4
+.t-float-right {
5
+  float: right;
6
+}
7
+@keyframes tdesign-fade-out {
8
+  from {
9
+    opacity: 1;
10
+  }
11
+  to {
12
+    opacity: 0;
13
+  }
14
+}
15
+.hotspot-expanded.relative {
16
+  position: relative;
17
+}
18
+.hotspot-expanded::after {
19
+  content: '';
20
+  display: block;
21
+  position: absolute;
22
+  left: 0;
23
+  top: 0;
24
+  right: 0;
25
+  bottom: 0;
26
+  transform: scale(1.5);
27
+}
28
+.t-avatar {
29
+  display: flex;
30
+  align-items: center;
31
+  justify-content: center;
32
+  box-sizing: border-box;
33
+  background-color: var(--td-avatar-bg-color, var(--td-brand-color-light-active, var(--td-primary-color-2, #d9e1ff)));
34
+  color: var(--td-avatar-content-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
35
+}
36
+.t-avatar__wrapper {
37
+  display: inline-flex;
38
+  position: relative;
39
+  vertical-align: top;
40
+  margin-left: var(--td-avatar-margin-left, 0);
41
+}
42
+.t-avatar--large {
43
+  width: var(--td-avatar-large-width, 128rpx);
44
+  height: var(--td-avatar-large-width, 128rpx);
45
+  font-size: var(--td-avatar-text-large-font-size, 16px);
46
+}
47
+.t-avatar--large .t-avatar__icon {
48
+  font-size: var(--td-avatar-icon-large-font-size, 64rpx);
49
+}
50
+.t-avatar--medium {
51
+  width: var(--td-avatar-medium-width, 96rpx);
52
+  height: var(--td-avatar-medium-width, 96rpx);
53
+  font-size: var(--td-avatar-text-medium-font-size, var(--td-font-size-base, 28rpx));
54
+}
55
+.t-avatar--medium .t-avatar__icon {
56
+  font-size: var(--td-avatar-icon-medium-font-size, 48rpx);
57
+}
58
+.t-avatar--small {
59
+  width: var(--td-avatar-small-width, 80rpx);
60
+  height: var(--td-avatar-small-width, 80rpx);
61
+  font-size: var(--td-avatar-text-small-font-size, var(--td-font-size-s, 24rpx));
62
+}
63
+.t-avatar--small .t-avatar__icon {
64
+  font-size: var(--td-avatar-icon-small-font-size, 40rpx);
65
+}
66
+.t-avatar .t-image,
67
+.t-avatar__image {
68
+  width: 100%;
69
+  height: 100%;
70
+}
71
+.t-avatar--circle {
72
+  border-radius: var(--td-avatar-circle-border-radius, var(--td-radius-circle, 50%));
73
+  overflow: hidden;
74
+}
75
+.t-avatar--round {
76
+  border-radius: var(--td-avatar-round-border-radius, var(--td-radius-default, 12rpx));
77
+  overflow: hidden;
78
+}
79
+.t-avatar__text,
80
+.t-avatar__icon {
81
+  width: 100%;
82
+  height: 100%;
83
+  display: flex;
84
+  align-items: center;
85
+  justify-content: center;
86
+}
87
+.t-avatar__text:empty,
88
+.t-avatar__icon:empty {
89
+  width: 0;
90
+  height: 0;
91
+}
92
+.t-avatar--border {
93
+  border-color: var(--td-avatar-border-color, #fff);
94
+  border-style: solid;
95
+}
96
+.t-avatar--border-small {
97
+  border-width: var(--td-avatar-border-width-small, 4rpx);
98
+}
99
+.t-avatar--border-medium {
100
+  border-width: var(--td-avatar-border-width-medium, 6rpx);
101
+}
102
+.t-avatar--border-large {
103
+  border-width: var(--td-avatar-border-width-large, 8rpx);
104
+}

+ 3
- 0
miniprogram_npm/tdesign-miniprogram/avatar/props.d.ts View File

@@ -0,0 +1,3 @@
1
+import { TdAvatarProps } from './type';
2
+declare const props: TdAvatarProps;
3
+export default props;

+ 39
- 0
miniprogram_npm/tdesign-miniprogram/avatar/props.js View File

@@ -0,0 +1,39 @@
1
+const props = {
2
+    alt: {
3
+        type: String,
4
+        value: '',
5
+    },
6
+    badgeProps: {
7
+        type: Object,
8
+    },
9
+    bordered: {
10
+        type: Boolean,
11
+        value: false,
12
+    },
13
+    externalClasses: {
14
+        type: Array,
15
+    },
16
+    hideOnLoadFailed: {
17
+        type: Boolean,
18
+        value: false,
19
+    },
20
+    icon: {
21
+        type: null,
22
+    },
23
+    image: {
24
+        type: String,
25
+        value: '',
26
+    },
27
+    imageProps: {
28
+        type: Object,
29
+    },
30
+    shape: {
31
+        type: String,
32
+        value: 'circle',
33
+    },
34
+    size: {
35
+        type: String,
36
+        value: 'medium',
37
+    },
38
+};
39
+export default props;

+ 48
- 0
miniprogram_npm/tdesign-miniprogram/avatar/type.d.ts View File

@@ -0,0 +1,48 @@
1
+import { BadgeProps } from '../badge/index';
2
+export interface TdAvatarProps {
3
+    alt?: {
4
+        type: StringConstructor;
5
+        value?: string;
6
+    };
7
+    badgeProps?: {
8
+        type: ObjectConstructor;
9
+        value?: BadgeProps;
10
+    };
11
+    bordered?: {
12
+        type: BooleanConstructor;
13
+        value?: boolean;
14
+    };
15
+    style?: {
16
+        type: StringConstructor;
17
+        value?: string;
18
+    };
19
+    externalClasses?: {
20
+        type: ArrayConstructor;
21
+        value?: ['t-class', 't-class-image', 't-class-icon', 't-class-alt', 't-class-content'];
22
+    };
23
+    hideOnLoadFailed?: {
24
+        type: BooleanConstructor;
25
+        value?: boolean;
26
+    };
27
+    icon?: {
28
+        type: null;
29
+        value?: string | object;
30
+    };
31
+    image?: {
32
+        type: StringConstructor;
33
+        value?: string;
34
+    };
35
+    imageProps?: {
36
+        type: ObjectConstructor;
37
+        value?: object;
38
+    };
39
+    shape?: {
40
+        type: StringConstructor;
41
+        value?: ShapeEnum;
42
+    };
43
+    size?: {
44
+        type: StringConstructor;
45
+        value?: string;
46
+    };
47
+}
48
+export declare type ShapeEnum = 'circle' | 'round';

+ 1
- 0
miniprogram_npm/tdesign-miniprogram/avatar/type.js View File

@@ -0,0 +1 @@
1
+export {};

+ 33
- 0
miniprogram_npm/tdesign-miniprogram/back-top/README.en-US.md View File

@@ -0,0 +1,33 @@
1
+:: BASE_DOC ::
2
+
3
+## API
4
+
5
+### BackTop Props
6
+
7
+name | type | default | description | required
8
+-- | -- | -- | -- | --
9
+external-classes | Array | - | `['t-class', 't-class-icon', 't-class-text']` | N
10
+visibility-height | Number | 200 | \- | N
11
+scroll-top | Number | 0 | \- | N
12
+fixed | Boolean | true | \- | N
13
+icon | String / Boolean / Object / Slot | - | \- | N
14
+text | String | '' | \- | N
15
+theme | String | round | options:round/half-round/round-dark/half-round-dark | N
16
+
17
+### BackTop Events
18
+
19
+name | params | description
20
+-- | -- | --
21
+to-top | \- | \-
22
+
23
+
24
+### CSS Variables
25
+The component provides the following CSS variables, which can be used to customize styles.
26
+Name | Default Value | Description 
27
+-- | -- | --
28
+--td-back-top-round-bg-color | @font-white-1 | - 
29
+--td-back-top-round-border-color | @component-border | - 
30
+--td-back-top-round-border-radius | @radius-circle | - 
31
+--td-back-top-round-color | @font-gray-1 | - 
32
+--td-back-top-round-dark-bg-color | @gray-color-14 | - 
33
+--td-back-top-round-dark-color | @font-white-1 | - 

+ 69
- 0
miniprogram_npm/tdesign-miniprogram/back-top/README.md View File

@@ -0,0 +1,69 @@
1
+---
2
+title: BackTop 返回顶部
3
+description: 用于当页面过长往下滑动时,帮助用户快速回到页面顶部。
4
+spline: navigation
5
+isComponent: true
6
+---
7
+
8
+<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-100%25-blue" /></span>
9
+## 引入
10
+
11
+全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
12
+
13
+```json
14
+"usingComponents": {
15
+"t-back-top": "tdesign-miniprogram/back-top/back-top",
16
+}
17
+```
18
+
19
+## 代码演示
20
+
21
+<a href="https://developers.weixin.qq.com/s/2aR1demj7aS2" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a>
22
+
23
+<blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" >
24
+<p>Tips: 请确保开发者工具为打开状态。导入开发者工具后,依次执行:npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p>
25
+</blockquote>
26
+
27
+
28
+<img src="https://tdesign.gtimg.com/miniprogram/readme/backtop-1.png" width="375px" height="50%">
29
+
30
+### 基础返回顶部
31
+
32
+{{ base }}
33
+
34
+## API
35
+### BackTop Props
36
+
37
+名称 | 类型 | 默认值 | 说明 | 必传
38
+-- | -- | -- | -- | --
39
+external-classes | Array | - | 组件类名,分别用于设置外层元素、图标、文本内容等元素类名。`['t-class', 't-class-icon', 't-class-text']` | N
40
+visibility-height | Number | 200 | 滚动高度达到此参数值才出现 | N
41
+scroll-top | Number | 0 | 页面滚动距离 | N
42
+fixed | Boolean | true | 是否绝对定位固定到屏幕右下方 | N
43
+icon | String / Boolean / Object / Slot | true | 图标。值为 `false` 表示不显示图标。不传表示使用默认图标 `'backtop'` | N
44
+text | String | '' | 文案 | N
45
+theme | String | round | 预设的样式类型。可选项:round/half-round/round-dark/half-round-dark | N
46
+
47
+### BackTop Events
48
+
49
+名称 | 参数 | 描述
50
+-- | -- | --
51
+to-top | \- | 点击触发
52
+
53
+### BackTop 外部样式类
54
+类名 | 说明
55
+-- | -- 
56
+t-class | 根节点样式类
57
+t-class-icon | 图标样式类
58
+t-class-text | 文本样式类
59
+
60
+### CSS 变量
61
+组件提供了下列 CSS 变量,可用于自定义样式。
62
+名称 | 默认值 | 描述 
63
+-- | -- | --
64
+--td-back-top-round-bg-color | @font-white-1 | - 
65
+--td-back-top-round-border-color | @component-border | - 
66
+--td-back-top-round-border-radius | @radius-circle | - 
67
+--td-back-top-round-color | @font-gray-1 | - 
68
+--td-back-top-round-dark-bg-color | @gray-color-14 | - 
69
+--td-back-top-round-dark-color | @font-white-1 | - 

+ 26
- 0
miniprogram_npm/tdesign-miniprogram/back-top/back-top.d.ts View File

@@ -0,0 +1,26 @@
1
+import { SuperComponent, RelationsOptions } from '../common/src/index';
2
+export default class BackTop extends SuperComponent {
3
+    externalClasses: string[];
4
+    options: {
5
+        multipleSlots: boolean;
6
+    };
7
+    properties: import("./type").TdBackTopProps;
8
+    relations: RelationsOptions;
9
+    data: {
10
+        prefix: string;
11
+        classPrefix: string;
12
+        _icon: any;
13
+        hidden: boolean;
14
+    };
15
+    observers: {
16
+        icon(): void;
17
+        scrollTop(value: number): void;
18
+    };
19
+    lifetimes: {
20
+        ready(): void;
21
+    };
22
+    methods: {
23
+        setIcon(v: any): void;
24
+        toTop(): void;
25
+    };
26
+}

+ 73
- 0
miniprogram_npm/tdesign-miniprogram/back-top/back-top.js View File

@@ -0,0 +1,73 @@
1
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+};
7
+import { SuperComponent, wxComponent } from '../common/src/index';
8
+import config from '../common/config';
9
+import props from './props';
10
+import { calcIcon } from '../common/utils';
11
+const { prefix } = config;
12
+const name = `${prefix}-back-top`;
13
+let BackTop = class BackTop extends SuperComponent {
14
+    constructor() {
15
+        super(...arguments);
16
+        this.externalClasses = [`${prefix}-class`, `${prefix}-class-icon`, `${prefix}-class-text`];
17
+        this.options = {
18
+            multipleSlots: true,
19
+        };
20
+        this.properties = props;
21
+        this.relations = {
22
+            '../pull-down-refresh/pull-down-refresh': {
23
+                type: 'ancestor',
24
+            },
25
+        };
26
+        this.data = {
27
+            prefix,
28
+            classPrefix: name,
29
+            _icon: null,
30
+            hidden: true,
31
+        };
32
+        this.observers = {
33
+            icon() {
34
+                this.setIcon();
35
+            },
36
+            scrollTop(value) {
37
+                const { visibilityHeight } = this.properties;
38
+                this.setData({ hidden: value < visibilityHeight });
39
+            },
40
+        };
41
+        this.lifetimes = {
42
+            ready() {
43
+                const { icon } = this.properties;
44
+                this.setIcon(icon);
45
+            },
46
+        };
47
+        this.methods = {
48
+            setIcon(v) {
49
+                this.setData({
50
+                    _icon: calcIcon(v, 'backtop'),
51
+                });
52
+            },
53
+            toTop() {
54
+                var _a;
55
+                this.triggerEvent('to-top');
56
+                if (this.$parent) {
57
+                    (_a = this.$parent) === null || _a === void 0 ? void 0 : _a.setScrollTop(0);
58
+                    this.setData({ hidden: true });
59
+                }
60
+                else {
61
+                    wx.pageScrollTo({
62
+                        scrollTop: 0,
63
+                        duration: 300,
64
+                    });
65
+                }
66
+            },
67
+        };
68
+    }
69
+};
70
+BackTop = __decorate([
71
+    wxComponent()
72
+], BackTop);
73
+export default BackTop;

+ 7
- 0
miniprogram_npm/tdesign-miniprogram/back-top/back-top.json View File

@@ -0,0 +1,7 @@
1
+{
2
+  "component": true,
3
+  "styleIsolation": "apply-shared",
4
+  "usingComponents": {
5
+    "t-icon": "../icon/icon"
6
+  }
7
+}

+ 17
- 0
miniprogram_npm/tdesign-miniprogram/back-top/back-top.wxml View File

@@ -0,0 +1,17 @@
1
+<import src="../common/template/icon.wxml" />
2
+<wxs src="../common/utils.wxs" module="_" />
3
+
4
+<view
5
+  style="{{_._style([style, customStyle])}}"
6
+  class="class {{prefix}}-class {{_.cls(classPrefix, [['fixed', fixed], theme])}}"
7
+  bindtap="toTop"
8
+  aria-role="button"
9
+  hidden="{{hidden}}"
10
+>
11
+  <view class="{{classPrefix}}__icon" aria-hidden>
12
+    <slot name="icon" />
13
+    <template wx:if="{{_icon}}" is="icon" data="{{tClass: prefix + '-class-icon', ..._icon }}" />
14
+  </view>
15
+  <view wx:if="{{!!text}}" class="{{classPrefix}}__text--{{theme}} {{prefix}}-class-text">{{text}}</view>
16
+  <slot />
17
+</view>

+ 91
- 0
miniprogram_npm/tdesign-miniprogram/back-top/back-top.wxss View File

@@ -0,0 +1,91 @@
1
+.t-float-left {
2
+  float: left;
3
+}
4
+.t-float-right {
5
+  float: right;
6
+}
7
+@keyframes tdesign-fade-out {
8
+  from {
9
+    opacity: 1;
10
+  }
11
+  to {
12
+    opacity: 0;
13
+  }
14
+}
15
+.hotspot-expanded.relative {
16
+  position: relative;
17
+}
18
+.hotspot-expanded::after {
19
+  content: '';
20
+  display: block;
21
+  position: absolute;
22
+  left: 0;
23
+  top: 0;
24
+  right: 0;
25
+  bottom: 0;
26
+  transform: scale(1.5);
27
+}
28
+.t-back-top {
29
+  display: flex;
30
+  flex-direction: column;
31
+  align-items: center;
32
+  justify-content: center;
33
+  background-color: transparent;
34
+  overflow: hidden;
35
+  box-sizing: border-box;
36
+  transition: height 0.2s;
37
+  height: auto;
38
+}
39
+.t-back-top--fixed {
40
+  position: fixed;
41
+  right: var(--td-spacer, 16rpx);
42
+  bottom: calc(var(--td-spacer-2, 32rpx) + env(safe-area-inset-bottom));
43
+}
44
+.t-back-top--round,
45
+.t-back-top--round-dark {
46
+  width: 96rpx;
47
+  height: 96rpx;
48
+  border-radius: var(--td-back-top-round-border-radius, var(--td-radius-circle, 50%));
49
+}
50
+.t-back-top--round,
51
+.t-back-top--half-round {
52
+  color: var(--td-back-top-round-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
53
+  border: 1rpx solid var(--td-back-top-round-border-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
54
+  background-color: var(--td-back-top-round-bg-color, var(--td-bg-color-container, var(--td-font-white-1, #ffffff)));
55
+}
56
+.t-back-top--round-dark,
57
+.t-back-top--half-round-dark {
58
+  color: var(--td-back-top-round-dark-color, var(--td-font-white-1, #ffffff));
59
+  background-color: var(--td-back-top-round-dark-bg-color, var(--td-gray-color-13, #242424));
60
+}
61
+.t-back-top--half-round,
62
+.t-back-top--half-round-dark {
63
+  width: 120rpx;
64
+  height: 80rpx;
65
+  border-radius: 0;
66
+  border-top-left-radius: var(--td-back-top-half-round-border-radius, var(--td-radius-round, 999px));
67
+  border-bottom-left-radius: var(--td-back-top-half-round-border-radius, var(--td-radius-round, 999px));
68
+  flex-direction: row;
69
+  right: 0;
70
+}
71
+.t-back-top__text--round,
72
+.t-back-top__text--round-dark,
73
+.t-back-top__text--half-round,
74
+.t-back-top__text--half-round-dark {
75
+  font-size: var(--td-font-size, 20rpx);
76
+  line-height: 24rpx;
77
+}
78
+.t-back-top__text--half-round,
79
+.t-back-top__text--half-round-dark {
80
+  width: 48rpx;
81
+}
82
+.t-back-top__icon:not(:empty) + .t-back-top__text--half-round,
83
+.t-back-top__icon:not(:empty) + .t-back-top__text--half-round-dark {
84
+  margin-left: 8rpx;
85
+}
86
+.t-back-top__icon {
87
+  display: flex;
88
+  justify-content: center;
89
+  align-items: center;
90
+  font-size: 44rpx;
91
+}

+ 3
- 0
miniprogram_npm/tdesign-miniprogram/back-top/props.d.ts View File

@@ -0,0 +1,3 @@
1
+import { TdBackTopProps } from './type';
2
+declare const props: TdBackTopProps;
3
+export default props;

+ 30
- 0
miniprogram_npm/tdesign-miniprogram/back-top/props.js View File

@@ -0,0 +1,30 @@
1
+const props = {
2
+    externalClasses: {
3
+        type: Array,
4
+    },
5
+    visibilityHeight: {
6
+        type: Number,
7
+        value: 200,
8
+    },
9
+    scrollTop: {
10
+        type: Number,
11
+        value: 0,
12
+    },
13
+    fixed: {
14
+        type: Boolean,
15
+        value: true,
16
+    },
17
+    icon: {
18
+        type: null,
19
+        value: true,
20
+    },
21
+    text: {
22
+        type: String,
23
+        value: '',
24
+    },
25
+    theme: {
26
+        type: String,
27
+        value: 'round',
28
+    },
29
+};
30
+export default props;

+ 34
- 0
miniprogram_npm/tdesign-miniprogram/back-top/type.d.ts View File

@@ -0,0 +1,34 @@
1
+export interface TdBackTopProps {
2
+    style?: {
3
+        type: StringConstructor;
4
+        value?: string;
5
+    };
6
+    externalClasses?: {
7
+        type: ArrayConstructor;
8
+        value?: ['t-class', 't-class-icon', 't-class-text'];
9
+    };
10
+    visibilityHeight?: {
11
+        type: NumberConstructor;
12
+        value?: 200;
13
+    };
14
+    scrollTop?: {
15
+        type: NumberConstructor;
16
+        value: 0;
17
+    };
18
+    fixed?: {
19
+        type: BooleanConstructor;
20
+        value?: boolean;
21
+    };
22
+    icon?: {
23
+        type: null;
24
+        value?: boolean | string | object;
25
+    };
26
+    text?: {
27
+        type: StringConstructor;
28
+        value?: string;
29
+    };
30
+    theme?: {
31
+        type: StringConstructor;
32
+        value?: 'round' | 'half-round' | 'round-dark' | 'half-round-dark';
33
+    };
34
+}

+ 1
- 0
miniprogram_npm/tdesign-miniprogram/back-top/type.js View File

@@ -0,0 +1 @@
1
+export {};

+ 36
- 0
miniprogram_npm/tdesign-miniprogram/badge/README.en-US.md View File

@@ -0,0 +1,36 @@
1
+:: BASE_DOC ::
2
+
3
+## API
4
+### Badge Props
5
+
6
+name | type | default | description | required
7
+-- | -- | -- | -- | --
8
+color | String | - | \- | N
9
+content | String | - | \- | N
10
+count | String / Number / Slot | 0 | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
11
+dot | Boolean | false | \- | N
12
+external-classes | Array | - | `['t-class', 't-class-content', 't-class-count']` | N
13
+max-count | Number | 99 | \- | N
14
+offset | Array | - | Typescript:`Array<string \| number>` | N
15
+shape | String | circle | options:circle/square/bubble/ribbon | N
16
+show-zero | Boolean | false | \- | N
17
+size | String | medium | options:medium/large | N
18
+
19
+
20
+### CSS Variables
21
+The component provides the following CSS variables, which can be used to customize styles.
22
+Name | Default Value | Description 
23
+-- | -- | --
24
+--td-badge-basic-height | 32rpx | - 
25
+--td-badge-basic-padding | 8rpx | - 
26
+--td-badge-basic-width | 32rpx | - 
27
+--td-badge-bg-color | @error-color | - 
28
+--td-badge-border-radius | 4rpx | - 
29
+--td-badge-bubble-border-radius | 20rpx 20rpx 20rpx 1px | - 
30
+--td-badge-dot-size | 16rpx | - 
31
+--td-badge-font-size | @font-size-xs | - 
32
+--td-badge-font-weight | 600 | - 
33
+--td-badge-large-font-size | @font-size-s | - 
34
+--td-badge-large-height | 40rpx | - 
35
+--td-badge-large-padding | 10rpx | - 
36
+--td-badge-text-color | @font-white-1 | - 

+ 77
- 0
miniprogram_npm/tdesign-miniprogram/badge/README.md View File

@@ -0,0 +1,77 @@
1
+---
2
+title: Badge 徽标
3
+description: 用于告知用户,该区域的状态变化或者待处理任务的数量。
4
+spline: data
5
+isComponent: true
6
+---
7
+
8
+<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-100%25-blue" /></span>
9
+## 引入
10
+
11
+全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
12
+
13
+```json
14
+"usingComponents": {
15
+  "t-badge": "tdesign-miniprogram/badge/badge"
16
+}
17
+```
18
+
19
+## 代码演示
20
+
21
+<a href="https://developers.weixin.qq.com/s/TgaeQimG73SD" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a>
22
+
23
+<blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" >
24
+<p>Tips: 请确保开发者工具为打开状态。导入开发者工具后,依次执行:npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p>
25
+</blockquote>
26
+
27
+### 组件类型
28
+
29
+{{ base }}
30
+
31
+### 组件样式
32
+
33
+{{ theme }}
34
+
35
+### 组件尺寸
36
+
37
+{{ size }}
38
+
39
+## API
40
+### Badge Props
41
+
42
+名称 | 类型 | 默认值 | 说明 | 必传
43
+-- | -- | -- | -- | --
44
+color | String | - | 颜色 | N
45
+content | String | - | 徽标内容,示例:`content='自定义内容'`。也可以使用默认插槽定义 | N
46
+count | String / Number / Slot | 0 | 徽标右上角内容。可以是数字,也可以是文字。如:'new'/3/99+。特殊:值为空表示使用插槽渲染。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
47
+dot | Boolean | false | 是否为红点 | N
48
+max-count | Number | 99 | 封顶的数字值 | N
49
+offset | Array | - | 设置状态点的位置偏移,示例:[-10, 20] 或 ['10em', '8rem']。TS 类型:`Array<string \| number>` | N
50
+shape | String | circle | 形状。可选项:circle/square/bubble/ribbon | N
51
+show-zero | Boolean | false | 当数值为 0 时,是否展示徽标 | N
52
+size | String | medium | 尺寸。可选项:medium/large | N
53
+
54
+### Badge 外部样式类
55
+类名 | 说明
56
+-- | -- 
57
+t-class | 根节点样式类
58
+t-class-count | 计数样式类
59
+t-class-content | 内容样式类
60
+
61
+### CSS 变量
62
+组件提供了下列 CSS 变量,可用于自定义样式。
63
+名称 | 默认值 | 描述 
64
+-- | -- | --
65
+--td-badge-basic-height | 32rpx | - 
66
+--td-badge-basic-padding | 8rpx | - 
67
+--td-badge-basic-width | 32rpx | - 
68
+--td-badge-bg-color | @error-color | - 
69
+--td-badge-border-radius | 4rpx | - 
70
+--td-badge-bubble-border-radius | 20rpx 20rpx 20rpx 1px | - 
71
+--td-badge-dot-size | 16rpx | - 
72
+--td-badge-font-size | @font-size-xs | - 
73
+--td-badge-font-weight | 600 | - 
74
+--td-badge-large-font-size | @font-size-s | - 
75
+--td-badge-large-height | 40rpx | - 
76
+--td-badge-large-padding | 10rpx | - 
77
+--td-badge-text-color | @font-white-1 | - 

+ 21
- 0
miniprogram_npm/tdesign-miniprogram/badge/badge.d.ts View File

@@ -0,0 +1,21 @@
1
+import { SuperComponent } from '../common/src/index';
2
+import type { TdBadgeProps } from './type';
3
+export interface BadgeProps extends TdBadgeProps {
4
+}
5
+export default class Badge extends SuperComponent {
6
+    options: {
7
+        multipleSlots: boolean;
8
+    };
9
+    externalClasses: string[];
10
+    properties: TdBadgeProps;
11
+    data: {
12
+        prefix: string;
13
+        classPrefix: string;
14
+        value: string;
15
+        labelID: string;
16
+        descriptionID: string;
17
+    };
18
+    lifetimes: {
19
+        ready(): void;
20
+    };
21
+}

+ 43
- 0
miniprogram_npm/tdesign-miniprogram/badge/badge.js View File

@@ -0,0 +1,43 @@
1
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+};
7
+import { SuperComponent, wxComponent } from '../common/src/index';
8
+import config from '../common/config';
9
+import props from './props';
10
+import { uniqueFactory } from '../common/utils';
11
+const { prefix } = config;
12
+const name = `${prefix}-badge`;
13
+const getUniqueID = uniqueFactory('badge');
14
+let Badge = class Badge extends SuperComponent {
15
+    constructor() {
16
+        super(...arguments);
17
+        this.options = {
18
+            multipleSlots: true,
19
+        };
20
+        this.externalClasses = [`${prefix}-class`, `${prefix}-class-count`, `${prefix}-class-content`];
21
+        this.properties = props;
22
+        this.data = {
23
+            prefix,
24
+            classPrefix: name,
25
+            value: '',
26
+            labelID: '',
27
+            descriptionID: '',
28
+        };
29
+        this.lifetimes = {
30
+            ready() {
31
+                const uniqueID = getUniqueID();
32
+                this.setData({
33
+                    labelID: `${uniqueID}_label`,
34
+                    descriptionID: `${uniqueID}_description`,
35
+                });
36
+            },
37
+        };
38
+    }
39
+};
40
+Badge = __decorate([
41
+    wxComponent()
42
+], Badge);
43
+export default Badge;

+ 5
- 0
miniprogram_npm/tdesign-miniprogram/badge/badge.json View File

@@ -0,0 +1,5 @@
1
+{
2
+  "component": true,
3
+  "styleIsolation": "apply-shared",
4
+  "usingComponents": {}
5
+}

+ 44
- 0
miniprogram_npm/tdesign-miniprogram/badge/badge.wxml View File

@@ -0,0 +1,44 @@
1
+<wxs src="./badge.wxs" module="this" />
2
+<wxs src="../common/utils.wxs" module="_" />
3
+
4
+<!--
5
+  1. labelID 用于描述当前元素的文本
6
+  2. descriptionID 用于描述badge消息的文本
7
+  3. role=option一般用于多个内容合并焦点连续朗读
8
+-->
9
+
10
+<view
11
+  style="{{_._style([style, customStyle])}}"
12
+  class="{{this.getBadgeOuterClass({shape})}} class {{prefix}}-class"
13
+  aria-labelledby="{{labelID}}"
14
+  aria-describedby="{{descriptionID}}"
15
+  aria-role="{{ ariaRole || 'option'}}"
16
+>
17
+  <view id="{{labelID}}" class="{{classPrefix}}__content {{prefix}}-class-content" aria-hidden="true">
18
+    <slot wx:if="{{!content}}" class="{{classPrefix}}__content-slot" />
19
+    <text wx:else class="{{classPrefix}}__content-text">{{content}}</text>
20
+  </view>
21
+  <view
22
+    aria-hidden="true"
23
+    aria-label="{{ ariaLabel || _.getBadgeAriaLabel({dot, count, maxCount}) }}"
24
+    wx:if="{{this.isShowBadge({dot,count,showZero})}}"
25
+    id="{{descriptionID}}"
26
+    class="{{this.getBadgeInnerClass({dot, size, shape, count})}} {{prefix}}-has-count {{prefix}}-class-count"
27
+    style="{{this.getBadgeStyles({color, offset})}}"
28
+    aria-hidden="true"
29
+    aria-label="{{ ariaLabel || _.getBadgeAriaLabel({dot, count, maxCount}) }}"
30
+  >
31
+    <view
32
+      wx:if="{{shape == 'ribbon'}}"
33
+      class="t-badge__ribbon--before"
34
+      style="{{color ? 'border-color: ' + color : ''}}"
35
+    />
36
+    {{ this.getBadgeValue({dot, count, maxCount}) }}
37
+    <view
38
+      wx:if="{{shape == 'ribbon'}}"
39
+      class="t-badge__ribbon--after"
40
+      style="{{color ? 'border-color: ' + color : ''}}"
41
+    />
42
+  </view>
43
+  <slot name="count" />
44
+</view>

+ 70
- 0
miniprogram_npm/tdesign-miniprogram/badge/badge.wxs View File

@@ -0,0 +1,70 @@
1
+var getBadgeValue = function (props) {
2
+  if (props.dot) {
3
+    return '';
4
+  }
5
+  if (isNaN(props.count) || isNaN(props.maxCount)) {
6
+    return props.count;
7
+  }
8
+  return parseInt(props.count) > props.maxCount ? props.maxCount + '+' : props.count;
9
+};
10
+
11
+var hasUnit = function (unit) {
12
+  return (
13
+    unit.indexOf('px') > 0 ||
14
+    unit.indexOf('rpx') > 0 ||
15
+    unit.indexOf('em') > 0 ||
16
+    unit.indexOf('rem') > 0 ||
17
+    unit.indexOf('%') > 0 ||
18
+    unit.indexOf('vh') > 0 ||
19
+    unit.indexOf('vm') > 0
20
+  );
21
+};
22
+
23
+var getBadgeStyles = function (props) {
24
+  var styleStr = '';
25
+  if (props.color) {
26
+    styleStr += 'background:' + props.color + ';';
27
+  }
28
+  if (props.offset[0]) {
29
+    styleStr += 'left: calc(100% + ' + (hasUnit(props.offset[0].toString()) ? props.offset[0] : props.offset[0] + 'px') + ');';
30
+  }
31
+  if (props.offset[1]) {
32
+    styleStr += 'top:' + (hasUnit(props.offset[1].toString()) ? props.offset[1] : props.offset[1] + 'px') + ';';
33
+  }
34
+  return styleStr;
35
+};
36
+
37
+var getBadgeOuterClass = function (props) {
38
+  var baseClass = 't-badge';
39
+  var classNames = [baseClass, props.shape === 'ribbon' ? baseClass + '__ribbon-outer' : ''];
40
+  return classNames.join(' ');
41
+};
42
+
43
+var getBadgeInnerClass = function (props) {
44
+  var baseClass = 't-badge';
45
+  var classNames = [
46
+    baseClass + '--basic',
47
+    props.dot ? baseClass + '--dot' : '',
48
+    baseClass + '--' + props.size,
49
+    baseClass + '--' + props.shape,
50
+    !props.dot && props.count ? baseClass + '--count' : '',
51
+  ];
52
+  return classNames.join(' ');
53
+};
54
+
55
+var isShowBadge = function (props) {
56
+  if (props.dot) {
57
+    return true;
58
+  }
59
+  if (!props.showZero && !isNaN(props.count) && parseInt(props.count) === 0) {
60
+    return false;
61
+  }
62
+  if (props.count == null) return false;
63
+  return true;
64
+};
65
+
66
+module.exports.getBadgeValue = getBadgeValue;
67
+module.exports.getBadgeStyles = getBadgeStyles;
68
+module.exports.getBadgeOuterClass = getBadgeOuterClass;
69
+module.exports.getBadgeInnerClass = getBadgeInnerClass;
70
+module.exports.isShowBadge = isShowBadge;

+ 110
- 0
miniprogram_npm/tdesign-miniprogram/badge/badge.wxss View File

@@ -0,0 +1,110 @@
1
+.t-float-left {
2
+  float: left;
3
+}
4
+.t-float-right {
5
+  float: right;
6
+}
7
+@keyframes tdesign-fade-out {
8
+  from {
9
+    opacity: 1;
10
+  }
11
+  to {
12
+    opacity: 0;
13
+  }
14
+}
15
+.hotspot-expanded.relative {
16
+  position: relative;
17
+}
18
+.hotspot-expanded::after {
19
+  content: '';
20
+  display: block;
21
+  position: absolute;
22
+  left: 0;
23
+  top: 0;
24
+  right: 0;
25
+  bottom: 0;
26
+  transform: scale(1.5);
27
+}
28
+.t-badge {
29
+  position: relative;
30
+  display: inline-block;
31
+  vertical-align: top;
32
+}
33
+.t-badge--basic {
34
+  z-index: 100;
35
+  padding: 0 var(--td-badge-basic-padding, 8rpx);
36
+  font-size: var(--td-badge-font-size, var(--td-font-size-xs, var(--td-font-size, 20rpx)));
37
+  color: var(--td-badge-text-color, var(--td-font-white-1, #ffffff));
38
+  background-color: var(--td-badge-bg-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
39
+  text-align: center;
40
+  height: var(--td-badge-basic-height, 32rpx);
41
+  line-height: var(--td-badge-basic-height, 32rpx);
42
+  font-weight: var(--td-badge-font-weight, 600);
43
+  border-radius: var(--td-badge-border-radius, 4rpx);
44
+}
45
+.t-badge--dot {
46
+  height: var(--td-badge-dot-size, 16rpx);
47
+  border-radius: 50%;
48
+  min-width: var(--td-badge-dot-size, 16rpx);
49
+  padding: 0;
50
+}
51
+.t-badge--count {
52
+  min-width: var(--td-badge-basic-width, 32rpx);
53
+  white-space: nowrap;
54
+  box-sizing: border-box;
55
+}
56
+.t-badge--circle {
57
+  border-radius: calc(var(--td-badge-basic-height, 32rpx) / 2);
58
+}
59
+.t-badge__ribbon-outer {
60
+  position: absolute;
61
+  top: 0;
62
+  right: 0;
63
+}
64
+.t-badge__ribbon--before,
65
+.t-badge__ribbon--after {
66
+  content: '';
67
+  position: absolute;
68
+  width: 0;
69
+  height: 0;
70
+  bottom: 0;
71
+  border-bottom: var(--td-badge-basic-height, 32rpx) solid var(--td-badge-bg-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
72
+}
73
+.t-badge__ribbon--before {
74
+  left: calc(-1 * var(--td-badge-basic-height, 32rpx) + 1rpx);
75
+  border-left: var(--td-badge-basic-height, 32rpx) solid transparent;
76
+}
77
+.t-badge__ribbon--after {
78
+  right: calc(-1 * var(--td-badge-basic-height, 32rpx) + 1rpx);
79
+  border-right: var(--td-badge-basic-height, 32rpx) solid transparent;
80
+}
81
+.t-badge--ribbon {
82
+  display: inline-block;
83
+  transform: rotate(45deg);
84
+  transform-origin: center center;
85
+  border-radius: 0;
86
+}
87
+.t-badge--bubble {
88
+  border-radius: var(--td-badge-bubble-border-radius, 20rpx 20rpx 20rpx 1px);
89
+}
90
+.t-badge--large {
91
+  font-size: var(--td-badge-large-font-size, var(--td-font-size-s, 24rpx));
92
+  height: var(--td-badge-large-height, 40rpx);
93
+  min-width: var(--td-badge-large-height, 40rpx);
94
+  line-height: var(--td-badge-large-height, 40rpx);
95
+  padding: 0 var(--td-badge-large-padding, 10rpx);
96
+}
97
+.t-badge--large.t-badge--circle {
98
+  border-radius: calc(var(--td-badge-large-height, 40rpx) / 2);
99
+}
100
+.t-badge__content:not(:empty) + .t-has-count {
101
+  transform: translate(-50%, -50%);
102
+  position: absolute;
103
+  left: 100%;
104
+  top: 0;
105
+}
106
+.t-badge__content-text {
107
+  display: block;
108
+  line-height: 48rpx;
109
+  color: var(--td-badge-content-text-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
110
+}

+ 3
- 0
miniprogram_npm/tdesign-miniprogram/badge/index.d.ts View File

@@ -0,0 +1,3 @@
1
+export * from './type';
2
+export * from './props';
3
+export * from './badge';

+ 3
- 0
miniprogram_npm/tdesign-miniprogram/badge/index.js View File

@@ -0,0 +1,3 @@
1
+export * from './type';
2
+export * from './props';
3
+export * from './badge';

+ 3
- 0
miniprogram_npm/tdesign-miniprogram/badge/props.d.ts View File

@@ -0,0 +1,3 @@
1
+import { TdBadgeProps } from './type';
2
+declare const props: TdBadgeProps;
3
+export default props;

+ 41
- 0
miniprogram_npm/tdesign-miniprogram/badge/props.js View File

@@ -0,0 +1,41 @@
1
+const props = {
2
+    color: {
3
+        type: String,
4
+        value: '',
5
+    },
6
+    content: {
7
+        type: String,
8
+        value: '',
9
+    },
10
+    count: {
11
+        type: null,
12
+        value: 0,
13
+    },
14
+    dot: {
15
+        type: Boolean,
16
+        value: false,
17
+    },
18
+    externalClasses: {
19
+        type: Array,
20
+    },
21
+    maxCount: {
22
+        type: Number,
23
+        value: 99,
24
+    },
25
+    offset: {
26
+        type: Array,
27
+    },
28
+    shape: {
29
+        type: String,
30
+        value: 'circle',
31
+    },
32
+    showZero: {
33
+        type: Boolean,
34
+        value: false,
35
+    },
36
+    size: {
37
+        type: String,
38
+        value: 'medium',
39
+    },
40
+};
41
+export default props;

+ 42
- 0
miniprogram_npm/tdesign-miniprogram/badge/type.d.ts View File

@@ -0,0 +1,42 @@
1
+export interface TdBadgeProps {
2
+    color?: {
3
+        type: StringConstructor;
4
+        value?: string;
5
+    };
6
+    content?: {
7
+        type: StringConstructor;
8
+        value?: string;
9
+    };
10
+    count?: {
11
+        type: null;
12
+        value?: string | number;
13
+    };
14
+    dot?: {
15
+        type: BooleanConstructor;
16
+        value?: boolean;
17
+    };
18
+    externalClasses?: {
19
+        type: ArrayConstructor;
20
+        value?: ['t-class', 't-class-content', 't-class-count'];
21
+    };
22
+    maxCount?: {
23
+        type: NumberConstructor;
24
+        value?: number;
25
+    };
26
+    offset?: {
27
+        type: ArrayConstructor;
28
+        value?: Array<string | number>;
29
+    };
30
+    shape?: {
31
+        type: StringConstructor;
32
+        value?: 'circle' | 'square' | 'bubble' | 'ribbon';
33
+    };
34
+    showZero?: {
35
+        type: BooleanConstructor;
36
+        value?: boolean;
37
+    };
38
+    size?: {
39
+        type: StringConstructor;
40
+        value?: 'medium' | 'large';
41
+    };
42
+}

+ 1
- 0
miniprogram_npm/tdesign-miniprogram/badge/type.js View File

@@ -0,0 +1 @@
1
+export {};

+ 223
- 0
miniprogram_npm/tdesign-miniprogram/button/README.en-US.md View File

@@ -0,0 +1,223 @@
1
+---
2
+title: Button
3
+description: Buttons are used to open a closed-loop task, such as "delete" an object, "buy" an item, etc.
4
+spline: base
5
+isComponent: true
6
+---
7
+
8
+<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-83%25-blue" /></span>
9
+
10
+
11
+## Usage
12
+
13
+For global import, configure it in `app.json` in the root directory of the miniprogram. For local import, configure it in `index.json` of the page or component that needs to be imported.
14
+
15
+```json
16
+"usingComponents": {
17
+  "t-button": "tdesign-miniprogram/button/button"
18
+}
19
+```
20
+
21
+
22
+## Code Demo
23
+
24
+### 01 Component Type
25
+
26
+#### Basic Buttons
27
+
28
+{{ base }}
29
+
30
+#### Icon Button
31
+
32
+{{ icon-btn }}
33
+
34
+#### Ghost Button
35
+
36
+{{ ghost-btn }}
37
+
38
+#### Combination Button
39
+
40
+{{ group-btn }}
41
+
42
+#### Banner Button
43
+
44
+{{ block-btn }}
45
+
46
+### 02 Component State
47
+
48
+#### Buttons for different states
49
+
50
+{{ disabled }}
51
+
52
+### 03 Component Style
53
+
54
+#### Different sizes of buttons
55
+
56
+{{ size }}
57
+
58
+#### Different shaped buttons
59
+
60
+{{ shape }}
61
+
62
+#### Different color theme buttons
63
+
64
+{{ theme }}
65
+
66
+
67
+
68
+## API
69
+### Button Props
70
+
71
+name | type | default | description | required
72
+-- | -- | -- | -- | --
73
+t-id | String | - | button tag id | N
74
+block | Boolean | false | make button to be a block-level element | N
75
+content | String / Slot | - | button's children elements | N
76
+custom-dataset | Object | - | Typescript:`any` | N
77
+disabled | Boolean | false | disable the button, make it can not be clicked | N
78
+external-classes | Array | - | `['t-class', 't-class-icon', 't-class-loading']` | N
79
+ghost | Boolean | false | make background-color to be transparent | N
80
+icon | String / Object | - | icon name | N
81
+loading | Boolean | false | set button to be loading state | N
82
+loading-props | Object | - | Typescript:`LoadingProps`,[Loading API Documents](./loading?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/button/type.ts) | N
83
+shape | String | rectangle | button shape。options:rectangle/square/round/circle | N
84
+size | String | medium | a button has three size。options:small/medium/large。Typescript:`SizeEnum` | N
85
+suffix | Slot | - | \- | N
86
+theme | String | default | button theme。options:default/primary/danger | N
87
+type | String | - | type of button element, same as formType of Miniprogram。options:submit/reset | N
88
+variant | String | base | button variant。options:base/outline/text | N
89
+open-type | String | - | options:contact/share/getPhoneNumber/getUserInfo/launchApp/openSetting/feedback/chooseAvatar/agreePrivacyAuthorization | N
90
+hover-stop-propagation | Boolean | false | \- | N
91
+hover-start-time | Number | 20 | \- | N
92
+hover-stay-time | Number | 70 | \- | N
93
+lang | String | en | options:en/zh_CN/zh_TW | N
94
+session-from | String | - | \- | N
95
+send-message-title | String | 当前标题 | \- | N
96
+send-message-path | String | 当前分享路径 | \- | N
97
+send-message-img | String | 截图 | \- | N
98
+app-parameter | String | - | \- | N
99
+show-message-card | Boolean | false | \- | N
100
+bindgetuserinfo | Eventhandle | - | \- | N
101
+bindcontact | Eventhandle | - | \- | N
102
+bindgetphonenumber | Eventhandle | - | \- | N
103
+binderror | Eventhandle | - | \- | N
104
+bindopensetting | Eventhandle | - | \- | N
105
+bindlaunchapp | Eventhandle | - | \- | N
106
+bindchooseavatar | Eventhandle | - | \- | N
107
+bindagreeprivacyauthorization | Eventhandle | - | \-| N
108
+
109
+### Button Events
110
+
111
+name | params | description
112
+-- | -- | --
113
+tap | `(e: MouseEvent)` | trigger on click
114
+
115
+
116
+### Button ExternalClasses
117
+类名 | 说明
118
+-- | -- 
119
+t-class | root
120
+t-class-icon | icon node
121
+t-class-loading | loading node
122
+
123
+
124
+### CSS Variables
125
+The component provides the following CSS variables, which can be used to customize styles.
126
+Name | Default Value | Description 
127
+-- | -- | --
128
+--td-button-border-radius | @radius-default | - 
129
+--td-button-border-width | 4rpx | - 
130
+--td-button-danger-active-bg-color | @error-color-7 | - 
131
+--td-button-danger-active-border-color | @error-color-7 | - 
132
+--td-button-danger-bg-color | @error-color | - 
133
+--td-button-danger-border-color | @error-color | - 
134
+--td-button-danger-color | @font-white-1 | - 
135
+--td-button-danger-dashed-border-color | @button-danger-dashed-color | - 
136
+--td-button-danger-dashed-color | @error-color | - 
137
+--td-button-danger-dashed-disabled-color | @button-danger-disabled-color | - 
138
+--td-button-danger-disabled-bg | @error-color-3 | - 
139
+--td-button-danger-disabled-border-color | @error-color-3 | - 
140
+--td-button-danger-disabled-color | @font-white-1 | - 
141
+--td-button-danger-outline-active-bg-color | @bg-color-container-active | - 
142
+--td-button-danger-outline-active-border-color | @error-color-7 | - 
143
+--td-button-danger-outline-border-color | @button-danger-outline-color | - 
144
+--td-button-danger-outline-color | @error-color | - 
145
+--td-button-danger-outline-disabled-color | @error-color-3 | - 
146
+--td-button-danger-text-active-bg-color | @bg-color-container-active | - 
147
+--td-button-danger-text-color | @error-color | - 
148
+--td-button-danger-text-disabled-color | @button-danger-disabled-color | - 
149
+--td-button-default-active-bg-color | @bg-color-component-active | - 
150
+--td-button-default-active-border-color | @bg-color-component-active | - 
151
+--td-button-default-bg-color | @bg-color-component | - 
152
+--td-button-default-border-color | @bg-color-component | - 
153
+--td-button-default-color | @font-gray-1 | - 
154
+--td-button-default-disabled-bg | @bg-color-component-disabled | - 
155
+--td-button-default-disabled-border-color | @bg-color-component-disabled | - 
156
+--td-button-default-disabled-color | @font-gray-4 | - 
157
+--td-button-default-outline-active-bg-color | @bg-color-container-active | - 
158
+--td-button-default-outline-active-border-color | @component-border | - 
159
+--td-button-default-outline-border-color | @component-border | - 
160
+--td-button-default-outline-color | @font-gray-1 | - 
161
+--td-button-default-outline-disabled-color | @component-border | - 
162
+--td-button-default-text-active-bg-color | @bg-color-container-active | - 
163
+--td-button-extra-small-font-size | @font-size-base | - 
164
+--td-button-extra-small-height | 56rpx | - 
165
+--td-button-extra-small-icon-font-size | 36rpx | - 
166
+--td-button-extra-small-padding-horizontal | 16rpx | - 
167
+--td-button-font-weight | 600 | - 
168
+--td-button-ghost-border-color | @button-ghost-color | - 
169
+--td-button-ghost-color | @bg-color-container | - 
170
+--td-button-ghost-danger-border-color | @error-color | - 
171
+--td-button-ghost-danger-color | @error-color | - 
172
+--td-button-ghost-disabled-color | rgba(255, 255, 255, 0.35) | - 
173
+--td-button-ghost-primary-border-color | @brand-color | - 
174
+--td-button-ghost-primary-color | @brand-color | - 
175
+--td-button-icon-border-radius | 8rpx | - 
176
+--td-button-icon-spacer | @spacer | - 
177
+--td-button-large-font-size | @font-size-m | - 
178
+--td-button-large-height | 96rpx | - 
179
+--td-button-large-icon-font-size | 48rpx | - 
180
+--td-button-large-padding-horizontal | 40rpx | - 
181
+--td-button-light-active-bg-color | @brand-color-light-active | - 
182
+--td-button-light-active-border-color | @brand-color-light-active | - 
183
+--td-button-light-bg-color | @brand-color-light | - 
184
+--td-button-light-border-color | @brand-color-light | - 
185
+--td-button-light-color | @brand-color | - 
186
+--td-button-light-disabled-bg | @brand-color-light | - 
187
+--td-button-light-disabled-border-color | @brand-color-light | - 
188
+--td-button-light-disabled-color | @brand-color-disabled | - 
189
+--td-button-light-outline-active-bg-color | @brand-color-light-active | - 
190
+--td-button-light-outline-active-border-color | @brand-color-active | - 
191
+--td-button-light-outline-bg-color | @brand-color-light | - 
192
+--td-button-light-outline-border-color | @button-light-outline-color | - 
193
+--td-button-light-outline-color | @brand-color | - 
194
+--td-button-light-outline-disabled-color | @brand-color-disabled | - 
195
+--td-button-light-text-active-bg-color | @bg-color-container-active | - 
196
+--td-button-light-text-color | @brand-color | - 
197
+--td-button-medium-font-size | @font-size-m | - 
198
+--td-button-medium-height | 80rpx | - 
199
+--td-button-medium-icon-font-size | 40rpx | - 
200
+--td-button-medium-padding-horizontal | 32rpx | - 
201
+--td-button-primary-active-bg-color | @brand-color-active | - 
202
+--td-button-primary-active-border-color | @brand-color-active | - 
203
+--td-button-primary-bg-color | @brand-color | - 
204
+--td-button-primary-border-color | @brand-color | - 
205
+--td-button-primary-color | @font-white-1 | - 
206
+--td-button-primary-dashed-border-color | @button-primary-dashed-color | - 
207
+--td-button-primary-dashed-color | @brand-color | - 
208
+--td-button-primary-dashed-disabled-color | @brand-color-disabled | - 
209
+--td-button-primary-disabled-bg | @brand-color-disabled | - 
210
+--td-button-primary-disabled-border-color | @brand-color-disabled | - 
211
+--td-button-primary-disabled-color | @font-white-1 | - 
212
+--td-button-primary-outline-active-bg-color | @bg-color-container-active | - 
213
+--td-button-primary-outline-active-border-color | @brand-color-active | - 
214
+--td-button-primary-outline-border-color | @button-primary-outline-color | - 
215
+--td-button-primary-outline-color | @brand-color | - 
216
+--td-button-primary-outline-disabled-color | @brand-color-disabled | - 
217
+--td-button-primary-text-active-bg-color | @bg-color-container-active | - 
218
+--td-button-primary-text-color | @brand-color | - 
219
+--td-button-primary-text-disabled-color | @brand-color-disabled | - 
220
+--td-button-small-font-size | @font-size-base | - 
221
+--td-button-small-height | 64rpx | - 
222
+--td-button-small-icon-font-size | 36rpx | - 
223
+--td-button-small-padding-horizontal | 24rpx | - 

+ 223
- 0
miniprogram_npm/tdesign-miniprogram/button/README.md View File

@@ -0,0 +1,223 @@
1
+---
2
+title: Button 按钮
3
+description: 用于开启一个闭环的操作任务,如“删除”对象、“购买”商品等。
4
+spline: base
5
+isComponent: true
6
+---
7
+
8
+<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-83%25-blue" /></span>
9
+## 引入
10
+
11
+全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
12
+
13
+```json
14
+"usingComponents": {
15
+  "t-button": "tdesign-miniprogram/button/button"
16
+}
17
+```
18
+
19
+## 代码演示
20
+
21
+<a href="https://developers.weixin.qq.com/s/F1cSo7mm75SS" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a>
22
+
23
+<blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" >
24
+<p>Tips: 请确保开发者工具为打开状态。导入开发者工具后,依次执行:npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p>
25
+</blockquote>
26
+
27
+
28
+### 01 组件类型
29
+
30
+#### 基础按钮
31
+
32
+{{ base }}
33
+
34
+#### 图标按钮
35
+
36
+{{ icon-btn }}
37
+
38
+#### 幽灵按钮
39
+
40
+{{ ghost-btn }}
41
+
42
+#### 组合按钮
43
+
44
+{{ group-btn }}
45
+
46
+#### 通栏按钮
47
+
48
+{{ block-btn }}
49
+
50
+### 02 组件状态
51
+
52
+#### 按钮禁用态
53
+
54
+{{ disabled }}
55
+
56
+### 03 组件样式
57
+
58
+#### 按钮尺寸
59
+
60
+{{ size }}
61
+
62
+#### 按钮形状
63
+
64
+{{ shape }}
65
+
66
+#### 按钮主题
67
+
68
+{{ theme }}
69
+
70
+## API
71
+### Button Props
72
+
73
+名称 | 类型 | 默认值 | 说明 | 必传
74
+-- | -- | -- | -- | --
75
+t-id | String | - | 按钮标签id | N
76
+block | Boolean | false | 是否为块级元素 | N
77
+content | String / Slot | - | 按钮内容 | N
78
+custom-dataset | Object | - | 自定义 dataset,可通过 event.currentTarget.dataset.custom 获取。TS 类型:`any` | N
79
+disabled | Boolean | false | 禁用状态 | N
80
+ghost | Boolean | false | 是否为幽灵按钮(镂空按钮) | N
81
+icon | String / Object | - | 图标名称。值为字符串表示图标名称,值为 `Object` 类型,表示透传至 `icon`。 | N
82
+loading | Boolean | false | 是否显示为加载状态,skyline模式下暂不支持该属性 | N
83
+loading-props | Object | - | 透传至 Loading 组件。TS 类型:`LoadingProps`,[Loading API Documents](./loading?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/button/type.ts) | N
84
+shape | String | rectangle | 按钮形状,有 4 种:长方形、正方形、圆角长方形、圆形。可选项:rectangle/square/round/circle | N
85
+size | String | medium | 组件尺寸。可选项:extra-small/small/medium/large。TS 类型:`SizeEnum` | N
86
+suffix | Slot | - | 右侧内容,可用于定义右侧图标 | N
87
+theme | String | default | 组件风格,依次为品牌色、危险色。可选项:default/primary/danger/light | N
88
+type | String | - | 同小程序的 formType。可选项:submit/reset | N
89
+variant | String | base | 按钮形式,基础、线框、文字。可选项:base/outline/dashed/text | N
90
+open-type | String | - | 微信开放能力。<br />具体释义:<br />`contact` 打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从 bindcontact 回调中获得具体信息,<a href="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/customer-message/customer-message.html">具体说明</a> (*小程序插件中不能使用*);<br />`share` 触发用户转发,使用前建议先阅读<a href="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html#使用指引">使用指引</a>;<br />`getPhoneNumber` 获取用户手机号,可以从 bindgetphonenumber 回调中获取到用户信息,<a href="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html">具体说明</a> (*小程序插件中不能使用*);<br />`getUserInfo` 获取用户信息,可以从 bindgetuserinfo 回调中获取到用户信息 (*小程序插件中不能使用*);<br />`launchApp` 打开APP,可以通过 app-parameter 属性设定向 APP 传的参数<a href="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/launchApp.html">具体说明</a>;<br />`openSetting` 打开授权设置页;<br />`feedback` 打开“意见反馈”页面,用户可提交反馈内容并上传<a href="https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/wx.getLogManager.html">日志</a>,开发者可以登录<a href="https://mp.weixin.qq.com/">小程序管理后台</a>后进入左侧菜单“客服反馈”页面获取到反馈内容;<br />`chooseAvatar` 获取用户头像,可以从 bindchooseavatar 回调中获取到头像信息;<br />`agreePrivacyAuthorization`用户同意隐私协议按钮。用户点击一次此按钮后,所有隐私接口可以正常调用。可通过`bindagreeprivacyauthorization`监听用户同意隐私协议事件。隐私合规开发指南详情可见《<a href="https://developers.weixin.qq.com/miniprogram/dev/framework/user-privacy/PrivacyAuthorize.html">小程序隐私协议开发指南</a>》。<br />[小程序官方文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html)。可选项:contact/share/getPhoneNumber/getUserInfo/launchApp/openSetting/feedback/chooseAvatar/agreePrivacyAuthorization | N
91
+hover-class | String | '' | 指定按钮按下去的样式类,按钮不为加载或禁用状态时有效。当 `hover-class="none"` 时,没有点击态效果 | N
92
+hover-stop-propagation | Boolean | false | 指定是否阻止本节点的祖先节点出现点击态 | N
93
+hover-start-time | Number | 20 | 按住后多久出现点击态,单位毫秒 | N
94
+hover-stay-time | Number | 70 | 手指松开后点击态保留时间,单位毫秒 | N
95
+lang | String | en | 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。。<br />具体释义:<br />`en` 英文;<br />`zh_CN` 简体中文;<br />`zh_TW` 繁体中文。<br />[小程序官方文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html)。可选项:en/zh_CN/zh_TW | N
96
+session-from | String | - | 会话来源,open-type="contact"时有效 | N
97
+send-message-title | String | 当前标题 | 会话内消息卡片标题,open-type="contact"时有效 | N
98
+send-message-path | String | 当前分享路径 | 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效 | N
99
+send-message-img | String | 截图 | 会话内消息卡片图片,open-type="contact"时有效 | N
100
+app-parameter | String | - | 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 | N
101
+show-message-card | Boolean | false | 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效 | N
102
+bindgetuserinfo | Eventhandle | - | 用户点击该按钮时,会返回获取到的用户信息,回调的 detail 数据与<a href="https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html">wx.getUserInfo</a>返回的一致,open-type="getUserInfo"时有效 | N
103
+bindcontact | Eventhandle | - | 客服消息回调,open-type="contact"时有效 | N
104
+bindgetphonenumber | Eventhandle | - | 获取用户手机号回调,open-type=getPhoneNumber时有效 | N
105
+binderror | Eventhandle | - | 当使用开放能力时,发生错误的回调,open-type=launchApp时有效 | N
106
+bindopensetting | Eventhandle | - | 在打开授权设置页后回调,open-type=openSetting时有效 | N
107
+bindlaunchapp | Eventhandle | - | 打开 APP 成功的回调,open-type=launchApp时有效 | N
108
+bindchooseavatar | Eventhandle | - | 获取用户头像回调,open-type=chooseAvatar时有效 | N
109
+bindagreeprivacyauthorization | Eventhandle | - | 用户同意隐私协议事件回调,open-type=agreePrivacyAuthorization时有效 | N
110
+
111
+### Button Events
112
+
113
+名称 | 参数 | 描述
114
+-- | -- | --
115
+tap | `event` | 点击按钮,当按钮不为加载或禁用状态时触发
116
+
117
+### Button 外部样式类
118
+类名 | 说明
119
+-- | -- 
120
+t-class | 根节点样式类
121
+t-class-icon | 图标样式类
122
+t-class-loading | 加载样式类
123
+
124
+### CSS 变量
125
+组件提供了下列 CSS 变量,可用于自定义样式。
126
+名称 | 默认值 | 描述 
127
+-- | -- | --
128
+--td-button-border-radius | @radius-default | - 
129
+--td-button-border-width | 4rpx | - 
130
+--td-button-danger-active-bg-color | @error-color-7 | - 
131
+--td-button-danger-active-border-color | @error-color-7 | - 
132
+--td-button-danger-bg-color | @error-color | - 
133
+--td-button-danger-border-color | @error-color | - 
134
+--td-button-danger-color | @font-white-1 | - 
135
+--td-button-danger-dashed-border-color | @button-danger-dashed-color | - 
136
+--td-button-danger-dashed-color | @error-color | - 
137
+--td-button-danger-dashed-disabled-color | @button-danger-disabled-color | - 
138
+--td-button-danger-disabled-bg | @error-color-3 | - 
139
+--td-button-danger-disabled-border-color | @error-color-3 | - 
140
+--td-button-danger-disabled-color | @font-white-1 | - 
141
+--td-button-danger-outline-active-bg-color | @bg-color-container-active | - 
142
+--td-button-danger-outline-active-border-color | @error-color-7 | - 
143
+--td-button-danger-outline-border-color | @button-danger-outline-color | - 
144
+--td-button-danger-outline-color | @error-color | - 
145
+--td-button-danger-outline-disabled-color | @error-color-3 | - 
146
+--td-button-danger-text-active-bg-color | @bg-color-container-active | - 
147
+--td-button-danger-text-color | @error-color | - 
148
+--td-button-danger-text-disabled-color | @button-danger-disabled-color | - 
149
+--td-button-default-active-bg-color | @bg-color-component-active | - 
150
+--td-button-default-active-border-color | @bg-color-component-active | - 
151
+--td-button-default-bg-color | @bg-color-component | - 
152
+--td-button-default-border-color | @bg-color-component | - 
153
+--td-button-default-color | @font-gray-1 | - 
154
+--td-button-default-disabled-bg | @bg-color-component-disabled | - 
155
+--td-button-default-disabled-border-color | @bg-color-component-disabled | - 
156
+--td-button-default-disabled-color | @font-gray-4 | - 
157
+--td-button-default-outline-active-bg-color | @bg-color-container-active | - 
158
+--td-button-default-outline-active-border-color | @component-border | - 
159
+--td-button-default-outline-border-color | @component-border | - 
160
+--td-button-default-outline-color | @font-gray-1 | - 
161
+--td-button-default-outline-disabled-color | @component-border | - 
162
+--td-button-default-text-active-bg-color | @bg-color-container-active | - 
163
+--td-button-extra-small-font-size | @font-size-base | - 
164
+--td-button-extra-small-height | 56rpx | - 
165
+--td-button-extra-small-icon-font-size | 36rpx | - 
166
+--td-button-extra-small-padding-horizontal | 16rpx | - 
167
+--td-button-font-weight | 600 | - 
168
+--td-button-ghost-border-color | @button-ghost-color | - 
169
+--td-button-ghost-color | @bg-color-container | - 
170
+--td-button-ghost-danger-border-color | @error-color | - 
171
+--td-button-ghost-danger-color | @error-color | - 
172
+--td-button-ghost-disabled-color | rgba(255, 255, 255, 0.35) | - 
173
+--td-button-ghost-primary-border-color | @brand-color | - 
174
+--td-button-ghost-primary-color | @brand-color | - 
175
+--td-button-icon-border-radius | 8rpx | - 
176
+--td-button-icon-spacer | @spacer | - 
177
+--td-button-large-font-size | @font-size-m | - 
178
+--td-button-large-height | 96rpx | - 
179
+--td-button-large-icon-font-size | 48rpx | - 
180
+--td-button-large-padding-horizontal | 40rpx | - 
181
+--td-button-light-active-bg-color | @brand-color-light-active | - 
182
+--td-button-light-active-border-color | @brand-color-light-active | - 
183
+--td-button-light-bg-color | @brand-color-light | - 
184
+--td-button-light-border-color | @brand-color-light | - 
185
+--td-button-light-color | @brand-color | - 
186
+--td-button-light-disabled-bg | @brand-color-light | - 
187
+--td-button-light-disabled-border-color | @brand-color-light | - 
188
+--td-button-light-disabled-color | @brand-color-disabled | - 
189
+--td-button-light-outline-active-bg-color | @brand-color-light-active | - 
190
+--td-button-light-outline-active-border-color | @brand-color-active | - 
191
+--td-button-light-outline-bg-color | @brand-color-light | - 
192
+--td-button-light-outline-border-color | @button-light-outline-color | - 
193
+--td-button-light-outline-color | @brand-color | - 
194
+--td-button-light-outline-disabled-color | @brand-color-disabled | - 
195
+--td-button-light-text-active-bg-color | @bg-color-container-active | - 
196
+--td-button-light-text-color | @brand-color | - 
197
+--td-button-medium-font-size | @font-size-m | - 
198
+--td-button-medium-height | 80rpx | - 
199
+--td-button-medium-icon-font-size | 40rpx | - 
200
+--td-button-medium-padding-horizontal | 32rpx | - 
201
+--td-button-primary-active-bg-color | @brand-color-active | - 
202
+--td-button-primary-active-border-color | @brand-color-active | - 
203
+--td-button-primary-bg-color | @brand-color | - 
204
+--td-button-primary-border-color | @brand-color | - 
205
+--td-button-primary-color | @font-white-1 | - 
206
+--td-button-primary-dashed-border-color | @button-primary-dashed-color | - 
207
+--td-button-primary-dashed-color | @brand-color | - 
208
+--td-button-primary-dashed-disabled-color | @brand-color-disabled | - 
209
+--td-button-primary-disabled-bg | @brand-color-disabled | - 
210
+--td-button-primary-disabled-border-color | @brand-color-disabled | - 
211
+--td-button-primary-disabled-color | @font-white-1 | - 
212
+--td-button-primary-outline-active-bg-color | @bg-color-container-active | - 
213
+--td-button-primary-outline-active-border-color | @brand-color-active | - 
214
+--td-button-primary-outline-border-color | @button-primary-outline-color | - 
215
+--td-button-primary-outline-color | @brand-color | - 
216
+--td-button-primary-outline-disabled-color | @brand-color-disabled | - 
217
+--td-button-primary-text-active-bg-color | @bg-color-container-active | - 
218
+--td-button-primary-text-color | @brand-color | - 
219
+--td-button-primary-text-disabled-color | @brand-color-disabled | - 
220
+--td-button-small-font-size | @font-size-base | - 
221
+--td-button-small-height | 64rpx | - 
222
+--td-button-small-icon-font-size | 36rpx | - 
223
+--td-button-small-padding-horizontal | 24rpx | - 

+ 36
- 0
miniprogram_npm/tdesign-miniprogram/button/button.d.ts View File

@@ -0,0 +1,36 @@
1
+import { SuperComponent } from '../common/src/index';
2
+import type { TdButtonProps } from './type';
3
+export interface ButtonProps extends TdButtonProps {
4
+}
5
+export default class Button extends SuperComponent {
6
+    externalClasses: string[];
7
+    behaviors: string[];
8
+    properties: TdButtonProps;
9
+    options: {
10
+        multipleSlots: boolean;
11
+    };
12
+    data: {
13
+        prefix: string;
14
+        className: string;
15
+        classPrefix: string;
16
+    };
17
+    observers: {
18
+        'theme, size, plain, block, shape, disabled, loading, variant'(): void;
19
+        icon(icon: any): void;
20
+    };
21
+    lifetimes: {
22
+        attached(): void;
23
+    };
24
+    methods: {
25
+        setClass(): void;
26
+        getuserinfo(e: any): void;
27
+        contact(e: any): void;
28
+        getphonenumber(e: any): void;
29
+        error(e: any): void;
30
+        opensetting(e: any): void;
31
+        launchapp(e: any): void;
32
+        chooseavatar(e: any): void;
33
+        agreeprivacyauthorization(e: any): void;
34
+        handleTap(e: any): void;
35
+    };
36
+}

+ 100
- 0
miniprogram_npm/tdesign-miniprogram/button/button.js View File

@@ -0,0 +1,100 @@
1
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+};
7
+import { SuperComponent, wxComponent } from '../common/src/index';
8
+import config from '../common/config';
9
+import props from './props';
10
+import { canIUseFormFieldButton } from '../common/version';
11
+import { setIcon } from '../common/utils';
12
+const { prefix } = config;
13
+const name = `${prefix}-button`;
14
+let Button = class Button extends SuperComponent {
15
+    constructor() {
16
+        super(...arguments);
17
+        this.externalClasses = [`${prefix}-class`, `${prefix}-class-icon`, `${prefix}-class-loading`];
18
+        this.behaviors = canIUseFormFieldButton() ? ['wx://form-field-button'] : [];
19
+        this.properties = props;
20
+        this.options = {
21
+            multipleSlots: true,
22
+        };
23
+        this.data = {
24
+            prefix,
25
+            className: '',
26
+            classPrefix: name,
27
+        };
28
+        this.observers = {
29
+            'theme, size, plain, block, shape, disabled, loading, variant'() {
30
+                this.setClass();
31
+            },
32
+            icon(icon) {
33
+                const obj = setIcon('icon', icon, '');
34
+                this.setData(Object.assign({}, obj));
35
+            },
36
+        };
37
+        this.lifetimes = {
38
+            attached() {
39
+                this.setClass();
40
+            },
41
+        };
42
+        this.methods = {
43
+            setClass() {
44
+                const classList = [
45
+                    name,
46
+                    `${prefix}-class`,
47
+                    `${name}--${this.data.variant || 'base'}`,
48
+                    `${name}--${this.data.theme || 'default'}`,
49
+                    `${name}--${this.data.shape || 'rectangle'}`,
50
+                    `${name}--size-${this.data.size || 'medium'}`,
51
+                ];
52
+                if (this.data.block) {
53
+                    classList.push(`${name}--block`);
54
+                }
55
+                if (this.data.disabled) {
56
+                    classList.push(`${name}--disabled`);
57
+                }
58
+                if (this.data.ghost) {
59
+                    classList.push(`${name}--ghost`);
60
+                }
61
+                this.setData({
62
+                    className: classList.join(' '),
63
+                });
64
+            },
65
+            getuserinfo(e) {
66
+                this.triggerEvent('getuserinfo', e.detail);
67
+            },
68
+            contact(e) {
69
+                this.triggerEvent('contact', e.detail);
70
+            },
71
+            getphonenumber(e) {
72
+                this.triggerEvent('getphonenumber', e.detail);
73
+            },
74
+            error(e) {
75
+                this.triggerEvent('error', e.detail);
76
+            },
77
+            opensetting(e) {
78
+                this.triggerEvent('opensetting', e.detail);
79
+            },
80
+            launchapp(e) {
81
+                this.triggerEvent('launchapp', e.detail);
82
+            },
83
+            chooseavatar(e) {
84
+                this.triggerEvent('chooseavatar', e.detail);
85
+            },
86
+            agreeprivacyauthorization(e) {
87
+                this.triggerEvent('agreeprivacyauthorization', e.detail);
88
+            },
89
+            handleTap(e) {
90
+                if (this.data.disabled || this.data.loading)
91
+                    return;
92
+                this.triggerEvent('tap', e);
93
+            },
94
+        };
95
+    }
96
+};
97
+Button = __decorate([
98
+    wxComponent()
99
+], Button);
100
+export default Button;

+ 8
- 0
miniprogram_npm/tdesign-miniprogram/button/button.json View File

@@ -0,0 +1,8 @@
1
+{
2
+  "component": true,
3
+  "styleIsolation": "apply-shared",
4
+  "usingComponents": {
5
+    "t-icon": "../icon/icon",
6
+    "t-loading": "../loading/loading"
7
+  }
8
+}

+ 61
- 0
miniprogram_npm/tdesign-miniprogram/button/button.wxml View File

@@ -0,0 +1,61 @@
1
+<import src="../common/template/icon.wxml" />
2
+<wxs src="../common/utils.wxs" module="_" />
3
+
4
+<button
5
+  id="{{tId}}"
6
+  style="{{_._style([style, customStyle])}}"
7
+  data-custom="{{ customDataset }}"
8
+  class="class {{className}}"
9
+  form-type="{{disabled || loading ? '' : type}}"
10
+  open-type="{{disabled || loading ? '' : openType}}"
11
+  hover-stop-propagation="{{hoverStopPropagation}}"
12
+  hover-start-time="{{hoverStartTime}}"
13
+  hover-stay-time="{{hoverStayTime}}"
14
+  lang="{{lang}}"
15
+  session-from="{{sessionFrom}}"
16
+  hover-class="{{disabled || loading ? '' : (hoverClass || classPrefix + '--hover')}}"
17
+  send-message-title="{{sendMessageTitle}}"
18
+  send-message-path="{{sendMessagePath}}"
19
+  send-message-img="{{sendMessageImg}}"
20
+  app-parameter="{{appParameter}}"
21
+  show-message-card="{{showMessageCard}}"
22
+  catch:tap="handleTap"
23
+  bind:getuserinfo="getuserinfo"
24
+  bind:contact="contact"
25
+  bind:getphonenumber="getphonenumber"
26
+  bind:error="error"
27
+  bind:opensetting="opensetting"
28
+  bind:launchapp="launchapp"
29
+  bind:chooseavatar="chooseavatar"
30
+  bind:agreeprivacyauthorization="agreeprivacyauthorization"
31
+  aria-label="{{ariaLabel}}"
32
+>
33
+  <template
34
+    wx:if="{{iconName || _.isNoEmptyObj(iconData)}}"
35
+    is="icon"
36
+    data="{{class: classPrefix + '__icon', tClass: prefix + '-class-icon', ariaHidden: true, name: iconName, ...iconData}}"
37
+  />
38
+  <t-loading
39
+    wx:if="{{loading}}"
40
+    delay="{{loadingProps.delay || 0}}"
41
+    duration="{{loadingProps.duration || 800}}"
42
+    indicator="{{loadingProps.indicator || true}}"
43
+    inheritColor="{{loadingProps.inheritColor || true}}"
44
+    layout="{{loadingProps.layout || 'horizontal'}}"
45
+    pause="{{loadingProps.pause || false}}"
46
+    progress="{{loadingProps.progress || 0}}"
47
+    reverse="{{loadingProps.reverse || false}}"
48
+    size="{{loadingProps.size || '40rpx'}}"
49
+    text="{{loadingProps.text || '' }}"
50
+    theme="{{loadingProps.theme || 'circular'}}"
51
+    loading
52
+    t-class="{{classPrefix}}__loading {{classPrefix}}__loading--wrapper"
53
+    t-class-indicator="{{classPrefix}}__loading--indicator {{prefix}}-class-loading"
54
+  />
55
+  <view class="{{classPrefix}}__content">
56
+    <slot name="content" />
57
+    <block wx:if="{{content}}">{{content}}</block>
58
+    <slot />
59
+  </view>
60
+  <slot name="suffix" />
61
+</button>

+ 477
- 0
miniprogram_npm/tdesign-miniprogram/button/button.wxss View File

@@ -0,0 +1,477 @@
1
+.t-float-left {
2
+  float: left;
3
+}
4
+.t-float-right {
5
+  float: right;
6
+}
7
+@keyframes tdesign-fade-out {
8
+  from {
9
+    opacity: 1;
10
+  }
11
+  to {
12
+    opacity: 0;
13
+  }
14
+}
15
+.hotspot-expanded.relative {
16
+  position: relative;
17
+}
18
+.hotspot-expanded::after {
19
+  content: '';
20
+  display: block;
21
+  position: absolute;
22
+  left: 0;
23
+  top: 0;
24
+  right: 0;
25
+  bottom: 0;
26
+  transform: scale(1.5);
27
+}
28
+.t-button--size-extra-small {
29
+  font-size: var(--td-button-extra-small-font-size, var(--td-font-size-base, 28rpx));
30
+  padding-left: var(--td-button-extra-small-padding-horizontal, 16rpx);
31
+  padding-right: var(--td-button-extra-small-padding-horizontal, 16rpx);
32
+  height: var(--td-button-extra-small-height, 56rpx);
33
+  line-height: var(--td-button-extra-small-height, 56rpx);
34
+}
35
+.t-button--size-extra-small .t-button__icon {
36
+  font-size: var(--td-button-extra-small-icon-font-size, 36rpx);
37
+}
38
+.t-button--size-small {
39
+  font-size: var(--td-button-small-font-size, var(--td-font-size-base, 28rpx));
40
+  padding-left: var(--td-button-small-padding-horizontal, 24rpx);
41
+  padding-right: var(--td-button-small-padding-horizontal, 24rpx);
42
+  height: var(--td-button-small-height, 64rpx);
43
+  line-height: var(--td-button-small-height, 64rpx);
44
+}
45
+.t-button--size-small .t-button__icon {
46
+  font-size: var(--td-button-small-icon-font-size, 36rpx);
47
+}
48
+.t-button--size-medium {
49
+  font-size: var(--td-button-medium-font-size, var(--td-font-size-m, 32rpx));
50
+  padding-left: var(--td-button-medium-padding-horizontal, 32rpx);
51
+  padding-right: var(--td-button-medium-padding-horizontal, 32rpx);
52
+  height: var(--td-button-medium-height, 80rpx);
53
+  line-height: var(--td-button-medium-height, 80rpx);
54
+}
55
+.t-button--size-medium .t-button__icon {
56
+  font-size: var(--td-button-medium-icon-font-size, 40rpx);
57
+}
58
+.t-button--size-large {
59
+  font-size: var(--td-button-large-font-size, var(--td-font-size-m, 32rpx));
60
+  padding-left: var(--td-button-large-padding-horizontal, 40rpx);
61
+  padding-right: var(--td-button-large-padding-horizontal, 40rpx);
62
+  height: var(--td-button-large-height, 96rpx);
63
+  line-height: var(--td-button-large-height, 96rpx);
64
+}
65
+.t-button--size-large .t-button__icon {
66
+  font-size: var(--td-button-large-icon-font-size, 48rpx);
67
+}
68
+.t-button--default {
69
+  color: var(--td-button-default-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
70
+  background-color: var(--td-button-default-bg-color, var(--td-bg-color-component, var(--td-gray-color-3, #e7e7e7)));
71
+  border-color: var(--td-button-default-border-color, var(--td-bg-color-component, var(--td-gray-color-3, #e7e7e7)));
72
+}
73
+.t-button--default::after {
74
+  border-width: var(--td-button-border-width, 4rpx);
75
+  border-color: var(--td-button-default-border-color, var(--td-bg-color-component, var(--td-gray-color-3, #e7e7e7)));
76
+}
77
+.t-button--default.t-button--hover {
78
+  z-index: 0;
79
+  border-color: var(--td-button-default-active-border-color, var(--td-bg-color-component-active, var(--td-gray-color-6, #a6a6a6)));
80
+}
81
+.t-button--default.t-button--hover::after {
82
+  background-color: var(--td-button-default-active-bg-color, var(--td-bg-color-component-active, var(--td-gray-color-6, #a6a6a6)));
83
+  border-color: var(--td-button-default-active-border-color, var(--td-bg-color-component-active, var(--td-gray-color-6, #a6a6a6)));
84
+}
85
+.t-button--default.t-button--disabled {
86
+  color: var(--td-button-default-disabled-color, var(--td-text-color-disabled, var(--td-font-gray-4, rgba(0, 0, 0, 0.26))));
87
+  background-color: var(--td-button-default-disabled-bg, var(--td-bg-color-component-disabled, var(--td-gray-color-2, #eeeeee)));
88
+  border-color: var(--td-button-default-disabled-border-color, var(--td-bg-color-component-disabled, var(--td-gray-color-2, #eeeeee)));
89
+}
90
+.t-button--default.t-button--disabled::after {
91
+  border-color: var(--td-button-default-disabled-border-color, var(--td-bg-color-component-disabled, var(--td-gray-color-2, #eeeeee)));
92
+}
93
+.t-button--primary {
94
+  color: var(--td-button-primary-color, var(--td-font-white-1, #ffffff));
95
+  background-color: var(--td-button-primary-bg-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
96
+  border-color: var(--td-button-primary-border-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
97
+}
98
+.t-button--primary::after {
99
+  border-width: var(--td-button-border-width, 4rpx);
100
+  border-color: var(--td-button-primary-border-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
101
+}
102
+.t-button--primary.t-button--hover {
103
+  z-index: 0;
104
+  border-color: var(--td-button-primary-active-border-color, var(--td-brand-color-active, var(--td-primary-color-8, #003cab)));
105
+}
106
+.t-button--primary.t-button--hover::after {
107
+  background-color: var(--td-button-primary-active-bg-color, var(--td-brand-color-active, var(--td-primary-color-8, #003cab)));
108
+  border-color: var(--td-button-primary-active-border-color, var(--td-brand-color-active, var(--td-primary-color-8, #003cab)));
109
+}
110
+.t-button--primary.t-button--disabled {
111
+  color: var(--td-button-primary-disabled-color, var(--td-font-white-1, #ffffff));
112
+  background-color: var(--td-button-primary-disabled-bg, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
113
+  border-color: var(--td-button-primary-disabled-border-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
114
+}
115
+.t-button--primary.t-button--disabled::after {
116
+  border-color: var(--td-button-primary-disabled-border-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
117
+}
118
+.t-button--light {
119
+  color: var(--td-button-light-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
120
+  background-color: var(--td-button-light-bg-color, var(--td-brand-color-light, var(--td-primary-color-1, #f2f3ff)));
121
+  border-color: var(--td-button-light-border-color, var(--td-brand-color-light, var(--td-primary-color-1, #f2f3ff)));
122
+}
123
+.t-button--light::after {
124
+  border-width: var(--td-button-border-width, 4rpx);
125
+  border-color: var(--td-button-light-border-color, var(--td-brand-color-light, var(--td-primary-color-1, #f2f3ff)));
126
+}
127
+.t-button--light.t-button--hover {
128
+  z-index: 0;
129
+  border-color: var(--td-button-light-active-border-color, var(--td-brand-color-light-active, var(--td-primary-color-2, #d9e1ff)));
130
+}
131
+.t-button--light.t-button--hover::after {
132
+  background-color: var(--td-button-light-active-bg-color, var(--td-brand-color-light-active, var(--td-primary-color-2, #d9e1ff)));
133
+  border-color: var(--td-button-light-active-border-color, var(--td-brand-color-light-active, var(--td-primary-color-2, #d9e1ff)));
134
+}
135
+.t-button--light.t-button--disabled {
136
+  color: var(--td-button-light-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
137
+  background-color: var(--td-button-light-disabled-bg, var(--td-brand-color-light, var(--td-primary-color-1, #f2f3ff)));
138
+  border-color: var(--td-button-light-disabled-border-color, var(--td-brand-color-light, var(--td-primary-color-1, #f2f3ff)));
139
+}
140
+.t-button--light.t-button--disabled::after {
141
+  border-color: var(--td-button-light-disabled-border-color, var(--td-brand-color-light, var(--td-primary-color-1, #f2f3ff)));
142
+}
143
+.t-button--danger {
144
+  color: var(--td-button-danger-color, var(--td-font-white-1, #ffffff));
145
+  background-color: var(--td-button-danger-bg-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
146
+  border-color: var(--td-button-danger-border-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
147
+}
148
+.t-button--danger::after {
149
+  border-width: var(--td-button-border-width, 4rpx);
150
+  border-color: var(--td-button-danger-border-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
151
+}
152
+.t-button--danger.t-button--hover {
153
+  z-index: 0;
154
+  border-color: var(--td-button-danger-active-border-color, var(--td-error-color-7, #ad352f));
155
+}
156
+.t-button--danger.t-button--hover::after {
157
+  background-color: var(--td-button-danger-active-bg-color, var(--td-error-color-7, #ad352f));
158
+  border-color: var(--td-button-danger-active-border-color, var(--td-error-color-7, #ad352f));
159
+}
160
+.t-button--danger.t-button--disabled {
161
+  color: var(--td-button-danger-disabled-color, var(--td-font-white-1, #ffffff));
162
+  background-color: var(--td-button-danger-disabled-bg, var(--td-error-color-3, #ffb9b0));
163
+  border-color: var(--td-button-danger-disabled-border-color, var(--td-error-color-3, #ffb9b0));
164
+}
165
+.t-button--danger.t-button--disabled::after {
166
+  border-color: var(--td-button-danger-disabled-border-color, var(--td-error-color-3, #ffb9b0));
167
+}
168
+.t-button {
169
+  display: inline-flex;
170
+  align-items: center;
171
+  justify-content: center;
172
+  position: relative;
173
+  white-space: nowrap;
174
+  text-align: center;
175
+  background-image: none;
176
+  transition: all 0.3s;
177
+  touch-action: manipulation;
178
+  border-radius: var(--td-button-border-radius, var(--td-radius-default, 12rpx));
179
+  outline: none;
180
+  font-family: PingFang SC, Microsoft YaHei, Arial Regular;
181
+  font-weight: var(--td-button-font-weight, 600);
182
+  vertical-align: top;
183
+  box-sizing: border-box;
184
+  cursor: pointer;
185
+  -webkit-tap-highlight-color: transparent;
186
+  -webkit-user-select: none;
187
+  user-select: none;
188
+  /* stylelint-disable-next-line */
189
+  -webkit-appearance: none;
190
+}
191
+.t-button::after {
192
+  border-radius: calc(var(--td-button-border-radius, var(--td-radius-default, 12rpx)) * 2);
193
+}
194
+.t-button--text {
195
+  color: var(--td-button-default-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
196
+  background: none;
197
+  border: 0;
198
+}
199
+.t-button--text::after {
200
+  border: 0;
201
+}
202
+.t-button--text.t-button--hover::after {
203
+  background-color: var(--td-button-default-text-active-bg-color, var(--td-bg-color-container-active, var(--td-gray-color-3, #e7e7e7)));
204
+}
205
+.t-button--text.t-button--primary {
206
+  color: var(--td-button-primary-text-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
207
+  background: none;
208
+}
209
+.t-button--text.t-button--primary.t-button--hover::after {
210
+  background-color: var(--td-button-primary-text-active-bg-color, var(--td-bg-color-container-active, var(--td-gray-color-3, #e7e7e7)));
211
+}
212
+.t-button--text.t-button--primary.t-button--disabled {
213
+  color: var(--td-button-primary-text-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
214
+  background: none;
215
+}
216
+.t-button--text.t-button--danger {
217
+  color: var(--td-button-danger-text-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
218
+  background: none;
219
+}
220
+.t-button--text.t-button--danger.t-button--hover::after {
221
+  background-color: var(--td-button-danger-text-active-bg-color, var(--td-bg-color-container-active, var(--td-gray-color-3, #e7e7e7)));
222
+}
223
+.t-button--text.t-button--danger.t-button--disabled {
224
+  color: var(--td-button-danger-text-disabled-color, var(--td-button-danger-disabled-color, var(--td-font-white-1, #ffffff)));
225
+  background: none;
226
+}
227
+.t-button--text.t-button--light {
228
+  color: var(--td-button-light-text-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
229
+  background: none;
230
+}
231
+.t-button--text.t-button--light.t-button--hover::after {
232
+  background-color: var(--td-button-light-text-active-bg-color, var(--td-bg-color-container-active, var(--td-gray-color-3, #e7e7e7)));
233
+}
234
+.t-button--text.t-button--disabled {
235
+  color: var(--td-button-default-disabled-color, var(--td-text-color-disabled, var(--td-font-gray-4, rgba(0, 0, 0, 0.26))));
236
+}
237
+.t-button--ghost {
238
+  background-color: transparent;
239
+  color: var(--td-button-ghost-color, var(--td-bg-color-container, var(--td-font-white-1, #ffffff)));
240
+  border-color: var(--td-button-ghost-border-color, var(--td-button-ghost-color, var(--td-bg-color-container, var(--td-font-white-1, #ffffff))));
241
+}
242
+.t-button--ghost::after {
243
+  border-color: var(--td-button-ghost-border-color, var(--td-button-ghost-color, var(--td-bg-color-container, var(--td-font-white-1, #ffffff))));
244
+}
245
+.t-button--ghost.t-button--hover::after {
246
+  background: none;
247
+}
248
+.t-button--ghost.t-button--primary {
249
+  color: var(--td-button-ghost-primary-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
250
+  border-color: var(--td-button-ghost-primary-border-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
251
+}
252
+.t-button--ghost.t-button--primary::after {
253
+  border-color: var(--td-button-ghost-primary-border-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
254
+}
255
+.t-button--ghost.t-button--danger {
256
+  color: var(--td-button-ghost-danger-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
257
+  border-color: var(--td-button-ghost-danger-border-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
258
+}
259
+.t-button--ghost.t-button--danger::after {
260
+  border-color: var(--td-button-ghost-danger-border-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
261
+}
262
+.t-button--ghost.t-button--disabled {
263
+  background-color: transparent;
264
+  color: var(--td-button-ghost-disabled-color, rgba(255, 255, 255, 0.35));
265
+  border-color: var(--td-button-ghost-disabled-color, rgba(255, 255, 255, 0.35));
266
+}
267
+.t-button--ghost.t-button--disabled::after {
268
+  border-color: var(--td-button-ghost-disabled-color, rgba(255, 255, 255, 0.35));
269
+}
270
+.t-button--outline {
271
+  color: var(--td-button-default-outline-color, var(--td-text-color-primary, var(--td-font-gray-1, rgba(0, 0, 0, 0.9))));
272
+  background-color: transparent;
273
+  border-color: var(--td-button-default-outline-border-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
274
+}
275
+.t-button--outline::after {
276
+  border-color: var(--td-button-default-outline-border-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
277
+}
278
+.t-button--outline.t-button--hover::after {
279
+  background-color: var(--td-button-default-outline-active-bg-color, var(--td-bg-color-container-active, var(--td-gray-color-3, #e7e7e7)));
280
+  border-color: var(--td-button-default-outline-active-border-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
281
+}
282
+.t-button--outline.t-button--disabled {
283
+  color: var(--td-button-default-outline-disabled-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
284
+  border-color: var(--td-button-default-outline-disabled-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
285
+}
286
+.t-button--outline.t-button--disabled::after {
287
+  border-color: var(--td-button-default-outline-disabled-color, var(--td-component-border, var(--td-gray-color-4, #dcdcdc)));
288
+}
289
+.t-button--outline.t-button--primary {
290
+  color: var(--td-button-primary-outline-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
291
+  border-color: var(--td-button-primary-outline-border-color, var(--td-button-primary-outline-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9))));
292
+}
293
+.t-button--outline.t-button--primary::after {
294
+  border-color: var(--td-button-primary-outline-border-color, var(--td-button-primary-outline-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9))));
295
+}
296
+.t-button--outline.t-button--primary.t-button--hover {
297
+  color: var(--td-button-primary-outline-active-border-color, var(--td-brand-color-active, var(--td-primary-color-8, #003cab)));
298
+}
299
+.t-button--outline.t-button--primary.t-button--hover::after {
300
+  background-color: var(--td-button-primary-outline-active-bg-color, var(--td-bg-color-container-active, var(--td-gray-color-3, #e7e7e7)));
301
+  border-color: var(--td-button-primary-outline-active-border-color, var(--td-brand-color-active, var(--td-primary-color-8, #003cab)));
302
+}
303
+.t-button--outline.t-button--primary.t-button--disabled {
304
+  background-color: transparent;
305
+  color: var(--td-button-primary-outline-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
306
+  border-color: var(--td-button-primary-outline-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
307
+}
308
+.t-button--outline.t-button--primary.t-button--disabled::after {
309
+  border-color: var(--td-button-primary-outline-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
310
+}
311
+.t-button--outline.t-button--danger {
312
+  color: var(--td-button-danger-outline-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
313
+  border-color: var(--td-button-danger-outline-border-color, var(--td-button-danger-outline-color, var(--td-error-color, var(--td-error-color-6, #d54941))));
314
+}
315
+.t-button--outline.t-button--danger::after {
316
+  border-color: var(--td-button-danger-outline-border-color, var(--td-button-danger-outline-color, var(--td-error-color, var(--td-error-color-6, #d54941))));
317
+}
318
+.t-button--outline.t-button--danger.t-button--hover {
319
+  color: var(--td-button-danger-outline-active-border-color, var(--td-error-color-7, #ad352f));
320
+}
321
+.t-button--outline.t-button--danger.t-button--hover::after {
322
+  background-color: var(--td-button-danger-outline-active-bg-color, var(--td-bg-color-container-active, var(--td-gray-color-3, #e7e7e7)));
323
+  border-color: var(--td-button-danger-outline-active-border-color, var(--td-error-color-7, #ad352f));
324
+}
325
+.t-button--outline.t-button--danger.t-button--disabled {
326
+  background-color: transparent;
327
+  color: var(--td-button-danger-outline-disabled-color, var(--td-error-color-3, #ffb9b0));
328
+  border-color: var(--td-button-danger-outline-disabled-color, var(--td-error-color-3, #ffb9b0));
329
+}
330
+.t-button--outline.t-button--danger.t-button--disabled::after {
331
+  border-color: var(--td-button-danger-outline-disabled-color, var(--td-error-color-3, #ffb9b0));
332
+}
333
+.t-button--outline.t-button--light {
334
+  color: var(--td-button-light-outline-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
335
+  background-color: var(--td-button-light-outline-bg-color, var(--td-brand-color-light, var(--td-primary-color-1, #f2f3ff)));
336
+  border-color: var(--td-button-light-outline-border-color, var(--td-button-light-outline-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9))));
337
+}
338
+.t-button--outline.t-button--light::after {
339
+  border-color: var(--td-button-light-outline-border-color, var(--td-button-light-outline-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9))));
340
+}
341
+.t-button--outline.t-button--light.t-button--hover {
342
+  color: var(--td-button-light-outline-active-border-color, var(--td-brand-color-active, var(--td-primary-color-8, #003cab)));
343
+}
344
+.t-button--outline.t-button--light.t-button--hover::after {
345
+  background-color: var(--td-button-light-outline-active-bg-color, var(--td-brand-color-light-active, var(--td-primary-color-2, #d9e1ff)));
346
+  border-color: var(--td-button-light-outline-active-border-color, var(--td-brand-color-active, var(--td-primary-color-8, #003cab)));
347
+}
348
+.t-button--outline.t-button--light.t-button--disabled {
349
+  background-color: transparent;
350
+  color: var(--td-button-light-outline-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
351
+  border-color: var(--td-button-light-outline-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
352
+}
353
+.t-button--outline.t-button--light.t-button--disabled::after {
354
+  border-color: var(--td-button-light-outline-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
355
+}
356
+.t-button--dashed {
357
+  background-color: transparent;
358
+  border-style: dashed;
359
+}
360
+.t-button--dashed.t-button--primary {
361
+  color: var(--td-button-primary-dashed-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9)));
362
+  border-color: var(--td-button-primary-dashed-border-color, var(--td-button-primary-dashed-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9))));
363
+}
364
+.t-button--dashed.t-button--primary::after {
365
+  border-color: var(--td-button-primary-dashed-border-color, var(--td-button-primary-dashed-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9))));
366
+}
367
+.t-button--dashed.t-button--primary.t-button--disabled {
368
+  background-color: transparent;
369
+  color: var(--td-button-primary-dashed-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
370
+  border-color: var(--td-button-primary-dashed-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
371
+}
372
+.t-button--dashed.t-button--primary.t-button--disabled::after {
373
+  border-color: var(--td-button-primary-dashed-disabled-color, var(--td-brand-color-disabled, var(--td-primary-color-3, #b5c7ff)));
374
+}
375
+.t-button--dashed.t-button--danger {
376
+  color: var(--td-button-danger-dashed-color, var(--td-error-color, var(--td-error-color-6, #d54941)));
377
+  border-color: var(--td-button-danger-dashed-border-color, var(--td-button-danger-dashed-color, var(--td-error-color, var(--td-error-color-6, #d54941))));
378
+}
379
+.t-button--dashed.t-button--danger::after {
380
+  border-color: var(--td-button-danger-dashed-border-color, var(--td-button-danger-dashed-color, var(--td-error-color, var(--td-error-color-6, #d54941))));
381
+}
382
+.t-button--dashed.t-button--danger.t-button--disabled {
383
+  background-color: transparent;
384
+  color: var(--td-button-danger-dashed-disabled-color, var(--td-button-danger-disabled-color, var(--td-font-white-1, #ffffff)));
385
+}
386
+.t-button--dashed.t-button--danger.t-button--disabled::after {
387
+  border-color: var(--td-button-danger-dashed-disabled-color, var(--td-button-danger-disabled-color, var(--td-font-white-1, #ffffff)));
388
+}
389
+.t-button__loading + .t-button__content:not(:empty),
390
+.t-button__icon + .t-button__content:not(:empty) {
391
+  margin-left: 8rpx;
392
+}
393
+.t-button__icon {
394
+  border-radius: var(--td-button-icon-border-radius, 8rpx);
395
+}
396
+.t-button--round.t-button--size-large {
397
+  border-radius: calc(var(--td-button-large-height, 96rpx) / 2);
398
+}
399
+.t-button--round.t-button--size-large::after {
400
+  border-radius: var(--td-button-large-height, 96rpx);
401
+}
402
+.t-button--round.t-button--size-medium {
403
+  border-radius: calc(var(--td-button-medium-height, 80rpx) / 2);
404
+}
405
+.t-button--round.t-button--size-medium::after {
406
+  border-radius: var(--td-button-medium-height, 80rpx);
407
+}
408
+.t-button--round.t-button--size-small {
409
+  border-radius: calc(var(--td-button-small-height, 64rpx) / 2);
410
+}
411
+.t-button--round.t-button--size-small::after {
412
+  border-radius: var(--td-button-small-height, 64rpx);
413
+}
414
+.t-button--round.t-button--size-extra-small {
415
+  border-radius: calc(var(--td-button-extra-small-height, 56rpx) / 2);
416
+}
417
+.t-button--round.t-button--size-extra-small::after {
418
+  border-radius: var(--td-button-extra-small-height, 56rpx);
419
+}
420
+.t-button--square {
421
+  padding: 0;
422
+}
423
+.t-button--square.t-button--size-large {
424
+  width: var(--td-button-large-height, 96rpx);
425
+}
426
+.t-button--square.t-button--size-medium {
427
+  width: var(--td-button-medium-height, 80rpx);
428
+}
429
+.t-button--square.t-button--size-small {
430
+  width: var(--td-button-small-height, 64rpx);
431
+}
432
+.t-button--square.t-button--size-extra-small {
433
+  width: var(--td-button-extra-small-height, 56rpx);
434
+}
435
+.t-button--circle {
436
+  padding: 0;
437
+  border-radius: 50%;
438
+}
439
+.t-button--circle.t-button--size-large {
440
+  width: var(--td-button-large-height, 96rpx);
441
+}
442
+.t-button--circle.t-button--size-large::after {
443
+  border-radius: 50%;
444
+}
445
+.t-button--circle.t-button--size-medium {
446
+  width: var(--td-button-medium-height, 80rpx);
447
+}
448
+.t-button--circle.t-button--size-medium::after {
449
+  border-radius: 50%;
450
+}
451
+.t-button--circle.t-button--size-small {
452
+  width: var(--td-button-small-height, 64rpx);
453
+}
454
+.t-button--circle.t-button--size-small::after {
455
+  border-radius: 50%;
456
+}
457
+.t-button--circle.t-button--size-extra-small {
458
+  width: var(--td-button-extra-small-height, 56rpx);
459
+}
460
+.t-button--circle.t-button--size-extra-small::after {
461
+  border-radius: 50%;
462
+}
463
+.t-button--block {
464
+  display: flex;
465
+  width: 100%;
466
+}
467
+.t-button--disabled {
468
+  cursor: not-allowed;
469
+}
470
+.t-button__loading--wrapper {
471
+  display: flex;
472
+  align-items: center;
473
+  justify-content: center;
474
+}
475
+.t-button.t-button--hover::after {
476
+  z-index: -1;
477
+}

+ 3
- 0
miniprogram_npm/tdesign-miniprogram/button/index.d.ts View File

@@ -0,0 +1,3 @@
1
+export * from './props';
2
+export * from './type';
3
+export * from './button';

+ 3
- 0
miniprogram_npm/tdesign-miniprogram/button/index.js View File

@@ -0,0 +1,3 @@
1
+export * from './props';
2
+export * from './type';
3
+export * from './button';

+ 3
- 0
miniprogram_npm/tdesign-miniprogram/button/props.d.ts View File

@@ -0,0 +1,3 @@
1
+import { TdButtonProps } from './type';
2
+declare const props: TdButtonProps;
3
+export default props;

+ 104
- 0
miniprogram_npm/tdesign-miniprogram/button/props.js View File

@@ -0,0 +1,104 @@
1
+const props = {
2
+    tId: {
3
+        type: String,
4
+        value: '',
5
+    },
6
+    block: {
7
+        type: Boolean,
8
+        value: false,
9
+    },
10
+    content: {
11
+        type: String,
12
+    },
13
+    customDataset: {
14
+        type: null,
15
+    },
16
+    disabled: {
17
+        type: Boolean,
18
+        value: false,
19
+    },
20
+    externalClasses: {
21
+        type: Array,
22
+    },
23
+    ghost: {
24
+        type: Boolean,
25
+        value: false,
26
+    },
27
+    icon: {
28
+        type: null,
29
+    },
30
+    loading: {
31
+        type: Boolean,
32
+        value: false,
33
+    },
34
+    loadingProps: {
35
+        type: Object,
36
+    },
37
+    shape: {
38
+        type: String,
39
+        value: 'rectangle',
40
+    },
41
+    size: {
42
+        type: String,
43
+        value: 'medium',
44
+    },
45
+    theme: {
46
+        type: String,
47
+        value: 'default',
48
+    },
49
+    type: {
50
+        type: String,
51
+    },
52
+    variant: {
53
+        type: String,
54
+        value: 'base',
55
+    },
56
+    openType: {
57
+        type: String,
58
+    },
59
+    hoverClass: {
60
+        type: String,
61
+        value: '',
62
+    },
63
+    hoverStopPropagation: {
64
+        type: Boolean,
65
+        value: false,
66
+    },
67
+    hoverStartTime: {
68
+        type: Number,
69
+        value: 20,
70
+    },
71
+    hoverStayTime: {
72
+        type: Number,
73
+        value: 70,
74
+    },
75
+    lang: {
76
+        type: String,
77
+        value: 'en',
78
+    },
79
+    sessionFrom: {
80
+        type: String,
81
+        value: '',
82
+    },
83
+    sendMessageTitle: {
84
+        type: String,
85
+        value: '',
86
+    },
87
+    sendMessagePath: {
88
+        type: String,
89
+        value: '',
90
+    },
91
+    sendMessageImg: {
92
+        type: String,
93
+        value: '',
94
+    },
95
+    appParameter: {
96
+        type: String,
97
+        value: '',
98
+    },
99
+    showMessageCard: {
100
+        type: Boolean,
101
+        value: false,
102
+    },
103
+};
104
+export default props;

+ 112
- 0
miniprogram_npm/tdesign-miniprogram/button/type.d.ts View File

@@ -0,0 +1,112 @@
1
+import { LoadingProps } from '../loading/index';
2
+import { SizeEnum } from '../common/common';
3
+export interface TdButtonProps {
4
+    tId?: {
5
+        type: StringConstructor;
6
+        value?: string;
7
+    };
8
+    block?: {
9
+        type: BooleanConstructor;
10
+        value?: boolean;
11
+    };
12
+    content?: {
13
+        type: StringConstructor;
14
+        value?: string;
15
+    };
16
+    customDataset?: {
17
+        type: ObjectConstructor;
18
+        value?: any;
19
+    };
20
+    disabled?: {
21
+        type: BooleanConstructor;
22
+        value?: boolean;
23
+    };
24
+    externalClasses?: {
25
+        type: ArrayConstructor;
26
+        value?: ['t-class', 't-class-icon', 't-class-loading'];
27
+    };
28
+    ghost?: {
29
+        type: BooleanConstructor;
30
+        value?: boolean;
31
+    };
32
+    icon?: {
33
+        type: null;
34
+        value?: string | object;
35
+    };
36
+    loading?: {
37
+        type: BooleanConstructor;
38
+        value?: boolean;
39
+    };
40
+    loadingProps?: {
41
+        type: ObjectConstructor;
42
+        value?: LoadingProps;
43
+    };
44
+    shape?: {
45
+        type: StringConstructor;
46
+        value?: 'rectangle' | 'square' | 'round' | 'circle';
47
+    };
48
+    size?: {
49
+        type: StringConstructor;
50
+        value?: SizeEnum;
51
+    };
52
+    theme?: {
53
+        type: StringConstructor;
54
+        value?: 'default' | 'primary' | 'danger';
55
+    };
56
+    type?: {
57
+        type: StringConstructor;
58
+        value?: 'submit' | 'reset';
59
+    };
60
+    variant?: {
61
+        type: StringConstructor;
62
+        value?: 'base' | 'outline' | 'text';
63
+    };
64
+    openType?: {
65
+        type: StringConstructor;
66
+        value?: 'contact' | 'share' | 'getPhoneNumber' | 'getUserInfo' | 'launchApp' | 'openSetting' | 'feedback' | 'chooseAvatar' | 'agreePrivacyAuthorization';
67
+    };
68
+    hoverClass?: {
69
+        type: StringConstructor;
70
+        value?: string;
71
+    };
72
+    hoverStopPropagation?: {
73
+        type: BooleanConstructor;
74
+        value?: boolean;
75
+    };
76
+    hoverStartTime?: {
77
+        type: NumberConstructor;
78
+        value?: number;
79
+    };
80
+    hoverStayTime?: {
81
+        type: NumberConstructor;
82
+        value?: number;
83
+    };
84
+    lang?: {
85
+        type: StringConstructor;
86
+        value?: 'en' | 'zh_CN' | 'zh_TW';
87
+    };
88
+    sessionFrom?: {
89
+        type: StringConstructor;
90
+        value?: string;
91
+    };
92
+    sendMessageTitle?: {
93
+        type: StringConstructor;
94
+        value?: string;
95
+    };
96
+    sendMessagePath?: {
97
+        type: StringConstructor;
98
+        value?: string;
99
+    };
100
+    sendMessageImg?: {
101
+        type: StringConstructor;
102
+        value?: string;
103
+    };
104
+    appParameter?: {
105
+        type: StringConstructor;
106
+        value?: string;
107
+    };
108
+    showMessageCard?: {
109
+        type: BooleanConstructor;
110
+        value?: boolean;
111
+    };
112
+}

+ 1
- 0
miniprogram_npm/tdesign-miniprogram/button/type.js View File

@@ -0,0 +1 @@
1
+export {};

+ 48
- 0
miniprogram_npm/tdesign-miniprogram/calendar/README.en-US.md View File

@@ -0,0 +1,48 @@
1
+:: BASE_DOC ::
2
+
3
+## API
4
+
5
+### Calendar Props
6
+
7
+name | type | default | description | required
8
+-- | -- | -- | -- | --
9
+style | Object | - | CSS(Cascading Style Sheets) | N
10
+custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
11
+auto-close | Boolean | true | `0.34.0` | N
12
+confirm-btn | String / Object / Slot | '' | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/calendar/type.ts) | N
13
+first-day-of-week | Number | 0 | \- | N
14
+format | Function | - | Typescript:`CalendarFormatType ` `type CalendarFormatType = (day: TDate) => TDate` `type TDateType = 'selected' \| 'disabled' \| 'start' \| 'centre' \| 'end' \| ''` `interface TDate { date: Date; day: number; type: TDateType; className?: string; prefix?: string; suffix?: string;}`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/calendar/type.ts) | N
15
+max-date | Number | - | \- | N
16
+min-date | Number | - | \- | N
17
+title | String / Slot | '请选择日期' | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
18
+type | String | 'single' | options: single/multiple/range | N
19
+use-popup | Boolean | true | `0.32.0` | N
20
+using-custom-navbar | Boolean | false | \- | N
21
+value | Number / Array | - | Typescript:`number \| number[]` | N
22
+default-value | Number / Array | undefined | uncontrolled property。Typescript:`number \| number[]` | N
23
+visible | Boolean | false | \- | N
24
+
25
+### Calendar Events
26
+
27
+name | params | description
28
+-- | -- | --
29
+change | `(value: timestamp)` | `0.28.0`
30
+close | `(trigger: CalendarTrigger)` | `0.34.0`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/calendar/type.ts)。<br/>`type CalendarTrigger = 'close-btn' \| 'confirm-btn' \| 'overlay'`<br/>
31
+confirm | `(value: timestamp)` | \-
32
+select | `(value: timestamp)` | `0.28.0`
33
+
34
+### CSS Variables
35
+
36
+The component provides the following CSS variables, which can be used to customize styles.
37
+Name | Default Value | Description 
38
+-- | -- | --
39
+--td-calendar-active-color | @brand-color | - 
40
+--td-calendar-bg-color | @bg-color-container | - 
41
+--td-calendar-days-color | @font-gray-2 | - 
42
+--td-calendar-item-centre-color | @brand-color-light | - 
43
+--td-calendar-item-disabled-color | @font-gray-4 | - 
44
+--td-calendar-item-suffix-color | @font-gray-3 | - 
45
+--td-calendar-radius | 24rpx | - 
46
+--td-calendar-selected-color | @font-white-1 | - 
47
+--td-calendar-title-color | @font-gray-1 | - 
48
+--td-calendar-title-font-size | 18px | -

+ 106
- 0
miniprogram_npm/tdesign-miniprogram/calendar/README.md View File

@@ -0,0 +1,106 @@
1
+---
2
+title: Calendar 日历
3
+description: 按照日历形式展示数据或日期的容器。
4
+spline: form
5
+isComponent: true
6
+---
7
+<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-100%25-blue" /></span>
8
+
9
+<div style="background: #ecf2fe; display: flex; align-items: center; line-height: 20px; padding: 14px 24px; border-radius: 3px; color: #555a65">
10
+  <svg fill="none" viewBox="0 0 16 16" width="16px" height="16px" style="margin-right: 5px">
11
+    <path fill="#0052d9" d="M8 15A7 7 0 108 1a7 7 0 000 14zM7.4 4h1.2v1.2H7.4V4zm.1 2.5h1V12h-1V6.5z" fillOpacity="0.9"></path>
12
+  </svg>
13
+  该组件于 0.22.0 版本上线,请留意版本。
14
+</div>
15
+
16
+## 引入
17
+
18
+全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
19
+
20
+```json
21
+"usingComponents": {
22
+  "t-calendar": "tdesign-miniprogram/calendar/calendar"
23
+}
24
+```
25
+
26
+## 代码演示
27
+
28
+<a href="https://developers.weixin.qq.com/s/jb5E2imk7QSV" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a>
29
+
30
+<blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" >
31
+<p>Tips: 请确保开发者工具为打开状态。导入开发者工具后,依次执行:npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p>
32
+</blockquote>
33
+
34
+### 组件类型
35
+#### 单个选择日期
36
+
37
+{{ base }}
38
+
39
+#### 多个选择日期
40
+
41
+{{ multiple }}
42
+
43
+#### 区间选择日期
44
+
45
+{{ range }}
46
+
47
+### 组件样式
48
+
49
+#### 自定义文案
50
+
51
+{{ custom-text }}
52
+
53
+#### 自定义区间
54
+
55
+{{ custom-range }}
56
+
57
+#### 不使用 Popup
58
+
59
+{{ without-popup }}
60
+
61
+## API
62
+
63
+### Calendar Props
64
+
65
+名称 | 类型 | 默认值 | 描述 | 必传
66
+-- | -- | -- | -- | --
67
+style | Object | - | 样式 | N
68
+custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
69
+auto-close | Boolean | true | `0.34.0`。自动关闭;在点击关闭按钮、确认按钮、遮罩层时自动关闭,不需要手动设置 visible | N
70
+confirm-btn | String / Object / Slot | '' | 确认按钮。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/calendar/type.ts) | N
71
+first-day-of-week | Number | 0 | 第一天从星期几开始,默认 0 = 周日 | N
72
+format | Function | - | 用于格式化日期的函数。TS 类型:`CalendarFormatType ` `type CalendarFormatType = (day: TDate) => TDate` `type TDateType = 'selected' \| 'disabled' \| 'start' \| 'centre' \| 'end' \| ''` `interface TDate { date: Date; day: number; type: TDateType; className?: string; prefix?: string; suffix?: string;}`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/calendar/type.ts) | N
73
+max-date | Number | - | 最大可选的日期,不传则默认半年后 | N
74
+min-date | Number | - | 最小可选的日期,不传则默认今天 | N
75
+title | String / Slot | '请选择日期' | 标题。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
76
+type | String | 'single' | 日历的选择类型,single = 单选;multiple = 多选; range = 区间选择。可选项:single/multiple/range | N
77
+use-popup | Boolean | true | `0.32.0`。是否使用弹出层包裹日历 | N
78
+using-custom-navbar | Boolean | false | 是否使用了自定义导航栏 | N
79
+value | Number / Array | - | 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组。TS 类型:`number \| number[]` | N
80
+default-value | Number / Array | undefined | 当前选择的日期,不传则默认今天,当 type = multiple 或 range 时传入数组。非受控属性。TS 类型:`number \| number[]` | N
81
+visible | Boolean | false | 是否显示日历;`usePopup` 为 true 时有效 | N
82
+
83
+### Calendar Events
84
+
85
+名称 | 参数 | 描述
86
+-- | -- | --
87
+change | `(value: timestamp)` | `0.28.0`。不显示 confirm-btn 时,完成选择时触发(暂不支持 type = multiple)
88
+close | `(trigger: CalendarTrigger)` | `0.34.0`。关闭按钮时触发。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/calendar/type.ts)。<br/>`type CalendarTrigger = 'close-btn' \| 'confirm-btn' \| 'overlay'`<br/>
89
+confirm | `(value: timestamp)` | 点击确认按钮时触发
90
+select | `(value: timestamp)` | `0.28.0`。点击日期时触发
91
+
92
+### CSS Variables
93
+
94
+组件提供了下列 CSS 变量,可用于自定义样式。
95
+名称 | 默认值 | 描述 
96
+-- | -- | --
97
+--td-calendar-active-color | @brand-color | - 
98
+--td-calendar-bg-color | @bg-color-container | - 
99
+--td-calendar-days-color | @font-gray-2 | - 
100
+--td-calendar-item-centre-color | @brand-color-light | - 
101
+--td-calendar-item-disabled-color | @font-gray-4 | - 
102
+--td-calendar-item-suffix-color | @font-gray-3 | - 
103
+--td-calendar-radius | 24rpx | - 
104
+--td-calendar-selected-color | @font-white-1 | - 
105
+--td-calendar-title-color | @font-gray-1 | - 
106
+--td-calendar-title-font-size | 18px | -

+ 47
- 0
miniprogram_npm/tdesign-miniprogram/calendar/calendar.d.ts View File

@@ -0,0 +1,47 @@
1
+/// <reference types="miniprogram-api-typings" />
2
+import { SuperComponent } from '../common/src/index';
3
+import { TdCalendarProps } from './type';
4
+export interface CalendarProps extends TdCalendarProps {
5
+}
6
+export default class Calendar extends SuperComponent {
7
+    behaviors: string[];
8
+    externalClasses: string[];
9
+    options: WechatMiniprogram.Component.ComponentOptions;
10
+    properties: TdCalendarProps;
11
+    data: {
12
+        prefix: string;
13
+        classPrefix: string;
14
+        months: any[];
15
+        scrollIntoView: string;
16
+        innerConfirmBtn: {
17
+            content: string;
18
+        };
19
+    };
20
+    controlledProps: {
21
+        key: string;
22
+        event: string;
23
+    }[];
24
+    lifetimes: {
25
+        created(): void;
26
+        ready(): void;
27
+    };
28
+    observers: {
29
+        type(v: any): void;
30
+        confirmBtn(v: any): void;
31
+        'firstDayOfWeek,minDate,maxDate'(firstDayOfWeek: any, minDate: any, maxDate: any): void;
32
+        value(v: any): void;
33
+        visible(v: any): void;
34
+        format(v: any): void;
35
+    };
36
+    methods: {
37
+        initialValue(): void;
38
+        scrollIntoView(): void;
39
+        calcMonths(): void;
40
+        close(trigger: any): void;
41
+        onVisibleChange(): void;
42
+        handleClose(): void;
43
+        handleSelect(e: any): void;
44
+        onTplButtonTap(): void;
45
+        toTime(val: any): any;
46
+    };
47
+}

+ 170
- 0
miniprogram_npm/tdesign-miniprogram/calendar/calendar.js View File

@@ -0,0 +1,170 @@
1
+var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+    return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+};
7
+import { SuperComponent, wxComponent } from '../common/src/index';
8
+import config from '../common/config';
9
+import props from './props';
10
+import TCalendar from '../common/shared/calendar/index';
11
+import useCustomNavbar from '../mixins/using-custom-navbar';
12
+const { prefix } = config;
13
+const name = `${prefix}-calendar`;
14
+let Calendar = class Calendar extends SuperComponent {
15
+    constructor() {
16
+        super(...arguments);
17
+        this.behaviors = [useCustomNavbar];
18
+        this.externalClasses = [`${prefix}-class`];
19
+        this.options = {
20
+            multipleSlots: true,
21
+        };
22
+        this.properties = props;
23
+        this.data = {
24
+            prefix,
25
+            classPrefix: name,
26
+            months: [],
27
+            scrollIntoView: '',
28
+            innerConfirmBtn: { content: '确定' },
29
+        };
30
+        this.controlledProps = [
31
+            {
32
+                key: 'value',
33
+                event: 'confirm',
34
+            },
35
+            {
36
+                key: 'value',
37
+                event: 'change',
38
+            },
39
+        ];
40
+        this.lifetimes = {
41
+            created() {
42
+                this.base = new TCalendar(this.properties);
43
+            },
44
+            ready() {
45
+                this.initialValue();
46
+                this.setData({
47
+                    days: this.base.getDays(),
48
+                });
49
+                this.calcMonths();
50
+                if (!this.data.usePopup) {
51
+                    this.scrollIntoView();
52
+                }
53
+            },
54
+        };
55
+        this.observers = {
56
+            type(v) {
57
+                this.base.type = v;
58
+            },
59
+            confirmBtn(v) {
60
+                if (typeof v === 'string') {
61
+                    this.setData({ innerConfirmBtn: v === 'slot' ? 'slot' : { content: v } });
62
+                }
63
+                else if (typeof v === 'object') {
64
+                    this.setData({ innerConfirmBtn: v });
65
+                }
66
+            },
67
+            'firstDayOfWeek,minDate,maxDate'(firstDayOfWeek, minDate, maxDate) {
68
+                firstDayOfWeek && (this.base.firstDayOfWeek = firstDayOfWeek);
69
+                minDate && (this.base.minDate = minDate);
70
+                maxDate && (this.base.maxDate = maxDate);
71
+                this.calcMonths();
72
+            },
73
+            value(v) {
74
+                this.base.value = v;
75
+                this.calcMonths();
76
+            },
77
+            visible(v) {
78
+                if (v) {
79
+                    this.scrollIntoView();
80
+                    this.base.value = this.data.value;
81
+                    this.calcMonths();
82
+                }
83
+            },
84
+            format(v) {
85
+                const { usePopup, visible } = this.data;
86
+                this.base.format = v;
87
+                if (!usePopup || visible) {
88
+                    this.calcMonths();
89
+                }
90
+            },
91
+        };
92
+        this.methods = {
93
+            initialValue() {
94
+                const { value, type, minDate } = this.data;
95
+                if (!value) {
96
+                    const today = new Date();
97
+                    const now = minDate || new Date(today.getFullYear(), today.getMonth(), today.getDate()).getTime();
98
+                    const initialValue = type === 'single' ? now : [now];
99
+                    if (type === 'range') {
100
+                        initialValue[1] = now + 24 * 3600 * 1000;
101
+                    }
102
+                    this.setData({
103
+                        value: initialValue,
104
+                    });
105
+                    this.base.value = initialValue;
106
+                }
107
+            },
108
+            scrollIntoView() {
109
+                const { value } = this.data;
110
+                if (!value)
111
+                    return;
112
+                const date = new Date(Array.isArray(value) ? value[0] : value);
113
+                if (date) {
114
+                    this.setData({
115
+                        scrollIntoView: `year_${date.getFullYear()}_month_${date.getMonth()}`,
116
+                    });
117
+                }
118
+            },
119
+            calcMonths() {
120
+                const months = this.base.getMonths();
121
+                this.setData({
122
+                    months,
123
+                });
124
+            },
125
+            close(trigger) {
126
+                if (this.data.autoClose) {
127
+                    this.setData({ visible: false });
128
+                }
129
+                this.triggerEvent('close', { trigger });
130
+            },
131
+            onVisibleChange() {
132
+                this.close('overlay');
133
+            },
134
+            handleClose() {
135
+                this.close('close-btn');
136
+            },
137
+            handleSelect(e) {
138
+                const { date, year, month } = e.currentTarget.dataset;
139
+                if (date.type === 'disabled')
140
+                    return;
141
+                const rawValue = this.base.select({ cellType: date.type, year, month, date: date.day });
142
+                const value = this.toTime(rawValue);
143
+                this.calcMonths();
144
+                if (this.data.confirmBtn == null) {
145
+                    if (this.data.type === 'single' || rawValue.length === 2) {
146
+                        this.setData({ visible: false });
147
+                        this._trigger('change', { value });
148
+                    }
149
+                }
150
+                this.triggerEvent('select', { value });
151
+            },
152
+            onTplButtonTap() {
153
+                const rawValue = this.base.getTrimValue();
154
+                const value = this.toTime(rawValue);
155
+                this.close('confirm-btn');
156
+                this._trigger('confirm', { value });
157
+            },
158
+            toTime(val) {
159
+                if (Array.isArray(val)) {
160
+                    return val.map((item) => item.getTime());
161
+                }
162
+                return val.getTime();
163
+            },
164
+        };
165
+    }
166
+};
167
+Calendar = __decorate([
168
+    wxComponent()
169
+], Calendar);
170
+export default Calendar;

+ 9
- 0
miniprogram_npm/tdesign-miniprogram/calendar/calendar.json View File

@@ -0,0 +1,9 @@
1
+{
2
+  "component": true,
3
+  "styleIsolation": "apply-shared",
4
+  "usingComponents": {
5
+    "t-popup": "../popup/popup",
6
+    "t-button": "../button/button",
7
+    "t-icon": "../icon/icon"
8
+  }
9
+}

+ 0
- 0
miniprogram_npm/tdesign-miniprogram/calendar/calendar.wxml View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save