@tuya-miniapp/smart-ui 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,6 +39,10 @@ SmartComponent({
39
39
  type: Boolean,
40
40
  value: true,
41
41
  },
42
+ safeAreaInsetBottomMin: {
43
+ type: Number,
44
+ value: 16,
45
+ },
42
46
  rootPortal: {
43
47
  type: Boolean,
44
48
  value: false,
@@ -8,6 +8,7 @@
8
8
  overlay="{{ overlay }}"
9
9
  custom-class="smart-action-sheet custom-class"
10
10
  safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
11
+ safe-area-inset-bottom-min="{{ safeAreaInsetBottomMin }}"
11
12
  close-on-click-overlay="{{ closeOnClickOverlay }}"
12
13
  root-portal="{{ rootPortal }}"
13
14
  bind:close="onClickOverlay"
@@ -42,9 +42,13 @@ const Dialog = (options) => {
42
42
  delete options.context;
43
43
  delete options.selector;
44
44
  if (dialog) {
45
+ const optionsWithInputValue = Object.assign({}, options);
46
+ if (typeof options.value === 'string') {
47
+ optionsWithInputValue.inputValue = options.value;
48
+ }
45
49
  dialog.setData(Object.assign({ callback: (action, instance) => {
46
50
  action === 'confirm' ? resolve(instance) : reject(instance);
47
- } }, options));
51
+ } }, optionsWithInputValue));
48
52
  wx.nextTick(() => {
49
53
  dialog.setData({ show: true });
50
54
  });
@@ -25,6 +25,14 @@ SmartComponent({
25
25
  type: Boolean,
26
26
  value: false,
27
27
  },
28
+ useSlot: {
29
+ type: Boolean,
30
+ value: false,
31
+ },
32
+ transition: {
33
+ type: String,
34
+ value: 'slide-down',
35
+ },
28
36
  top: null,
29
37
  },
30
38
  data: {
@@ -2,7 +2,7 @@
2
2
  <wxs src="./index.wxs" module="computed" />
3
3
 
4
4
  <smart-transition
5
- name="slide-down"
5
+ name="{{ transition }}"
6
6
  show="{{ show }}"
7
7
  custom-class="smart-notify__container"
8
8
  custom-style="{{ computed.rootStyle({ zIndex, top }) }}"
@@ -16,6 +16,7 @@
16
16
  wx:if="{{ safeAreaInsetTop }}"
17
17
  style="height: {{ statusBarHeight }}px"
18
18
  />
19
- <text>{{ message }}</text>
19
+ <slot wx:if="{{ useSlot }}" />
20
+ <text wx:else>{{ message }}</text>
20
21
  </view>
21
22
  </smart-transition>
@@ -1,5 +1,6 @@
1
1
  interface NotifyOptions {
2
2
  type?: 'primary' | 'success' | 'danger' | 'warning';
3
+ transition?: 'fade' | 'fade-up' | 'fade-down' | 'fade-left' | 'fade-right' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right';
3
4
  color?: string;
4
5
  zIndex?: number;
5
6
  top?: number;
@@ -2,6 +2,7 @@ import closeIcon from '@tuya-miniapp/icons/dist/svg/Xmark';
2
2
  import { SmartComponent } from '../common/component';
3
3
  import { transition } from '../mixins/transition';
4
4
  import { getSystemInfoSync } from '../common/utils';
5
+ const { safeArea, screenHeight, statusBarHeight } = getSystemInfoSync() || {};
5
6
  SmartComponent({
6
7
  classes: [
7
8
  'enter-class',
@@ -51,6 +52,10 @@ SmartComponent({
51
52
  type: Boolean,
52
53
  value: true,
53
54
  },
55
+ safeAreaInsetBottomMin: {
56
+ type: Number,
57
+ value: 0,
58
+ },
54
59
  safeAreaInsetTop: {
55
60
  type: Boolean,
56
61
  value: false,
@@ -70,14 +75,15 @@ SmartComponent({
70
75
  },
71
76
  data: {
72
77
  closeIcon,
73
- bottomSafeHeight: 16,
78
+ bottomSafeHeight: 0,
74
79
  },
75
80
  mounted() {
76
81
  if (!this.data.safeAreaInsetBottom)
77
82
  return;
78
- const { safeArea, screenHeight, statusBarHeight } = getSystemInfoSync() || {};
79
83
  const bottomSafeHeight = screenHeight - (safeArea === null || safeArea === void 0 ? void 0 : safeArea.height) - statusBarHeight;
80
- this.setData({ bottomSafeHeight: bottomSafeHeight || 16 });
84
+ this.setData({
85
+ bottomSafeHeight: Math.max(bottomSafeHeight, this.data.safeAreaInsetBottomMin),
86
+ });
81
87
  },
82
88
  created() {
83
89
  this.observeClass();
@@ -44,6 +44,10 @@ var button_1 = require("../mixins/button");
44
44
  type: Boolean,
45
45
  value: true,
46
46
  },
47
+ safeAreaInsetBottomMin: {
48
+ type: Number,
49
+ value: 16,
50
+ },
47
51
  rootPortal: {
48
52
  type: Boolean,
49
53
  value: false,
@@ -8,6 +8,7 @@
8
8
  overlay="{{ overlay }}"
9
9
  custom-class="smart-action-sheet custom-class"
10
10
  safe-area-inset-bottom="{{ safeAreaInsetBottom }}"
11
+ safe-area-inset-bottom-min="{{ safeAreaInsetBottomMin }}"
11
12
  close-on-click-overlay="{{ closeOnClickOverlay }}"
12
13
  root-portal="{{ rootPortal }}"
13
14
  bind:close="onClickOverlay"
@@ -55,9 +55,13 @@ var Dialog = function (options) {
55
55
  delete options.context;
56
56
  delete options.selector;
57
57
  if (dialog) {
58
+ var optionsWithInputValue = __assign({}, options);
59
+ if (typeof options.value === 'string') {
60
+ optionsWithInputValue.inputValue = options.value;
61
+ }
58
62
  dialog.setData(__assign({ callback: function (action, instance) {
59
63
  action === 'confirm' ? resolve(instance) : reject(instance);
60
- } }, options));
64
+ } }, optionsWithInputValue));
61
65
  wx.nextTick(function () {
62
66
  dialog.setData({ show: true });
63
67
  });
@@ -27,6 +27,14 @@ var utils_1 = require("../common/utils");
27
27
  type: Boolean,
28
28
  value: false,
29
29
  },
30
+ useSlot: {
31
+ type: Boolean,
32
+ value: false,
33
+ },
34
+ transition: {
35
+ type: String,
36
+ value: 'slide-down',
37
+ },
30
38
  top: null,
31
39
  },
32
40
  data: {
@@ -2,7 +2,7 @@
2
2
  <wxs src="./index.wxs" module="computed" />
3
3
 
4
4
  <smart-transition
5
- name="slide-down"
5
+ name="{{ transition }}"
6
6
  show="{{ show }}"
7
7
  custom-class="smart-notify__container"
8
8
  custom-style="{{ computed.rootStyle({ zIndex, top }) }}"
@@ -16,6 +16,7 @@
16
16
  wx:if="{{ safeAreaInsetTop }}"
17
17
  style="height: {{ statusBarHeight }}px"
18
18
  />
19
- <text>{{ message }}</text>
19
+ <slot wx:if="{{ useSlot }}" />
20
+ <text wx:else>{{ message }}</text>
20
21
  </view>
21
22
  </smart-transition>
@@ -1,5 +1,6 @@
1
1
  interface NotifyOptions {
2
2
  type?: 'primary' | 'success' | 'danger' | 'warning';
3
+ transition?: 'fade' | 'fade-up' | 'fade-down' | 'fade-left' | 'fade-right' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right';
3
4
  color?: string;
4
5
  zIndex?: number;
5
6
  top?: number;
@@ -7,6 +7,7 @@ var Xmark_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Xmark"));
7
7
  var component_1 = require("../common/component");
8
8
  var transition_1 = require("../mixins/transition");
9
9
  var utils_1 = require("../common/utils");
10
+ var _a = (0, utils_1.getSystemInfoSync)() || {}, safeArea = _a.safeArea, screenHeight = _a.screenHeight, statusBarHeight = _a.statusBarHeight;
10
11
  (0, component_1.SmartComponent)({
11
12
  classes: [
12
13
  'enter-class',
@@ -56,6 +57,10 @@ var utils_1 = require("../common/utils");
56
57
  type: Boolean,
57
58
  value: true,
58
59
  },
60
+ safeAreaInsetBottomMin: {
61
+ type: Number,
62
+ value: 0,
63
+ },
59
64
  safeAreaInsetTop: {
60
65
  type: Boolean,
61
66
  value: false,
@@ -75,14 +80,15 @@ var utils_1 = require("../common/utils");
75
80
  },
76
81
  data: {
77
82
  closeIcon: Xmark_1.default,
78
- bottomSafeHeight: 16,
83
+ bottomSafeHeight: 0,
79
84
  },
80
85
  mounted: function () {
81
86
  if (!this.data.safeAreaInsetBottom)
82
87
  return;
83
- var _a = (0, utils_1.getSystemInfoSync)() || {}, safeArea = _a.safeArea, screenHeight = _a.screenHeight, statusBarHeight = _a.statusBarHeight;
84
88
  var bottomSafeHeight = screenHeight - (safeArea === null || safeArea === void 0 ? void 0 : safeArea.height) - statusBarHeight;
85
- this.setData({ bottomSafeHeight: bottomSafeHeight || 16 });
89
+ this.setData({
90
+ bottomSafeHeight: Math.max(bottomSafeHeight, this.data.safeAreaInsetBottomMin),
91
+ });
86
92
  },
87
93
  created: function () {
88
94
  this.observeClass();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",