@tuya-miniapp/smart-ui 0.0.1-beta-3 → 0.0.1-beta-5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- @import '../common/index.css';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px);left:50%;position:absolute;top:50%;transform:translate(100%,-50%)}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
1
+ @import '../common/index.css';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.van-picker-column__unit_text{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px)}.van-picker-column__unit_hidden{opacity:0}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
@@ -128,7 +128,11 @@ VantComponent({
128
128
  const optionsV = options.slice(renderStart, renderEnd);
129
129
  return this.set({ optionsV, renderStart, renderNum });
130
130
  }
131
- return this.set({ optionsV: options });
131
+ return this.set({
132
+ optionsV: options,
133
+ renderStart: 0,
134
+ renderNum: options.length,
135
+ });
132
136
  },
133
137
  adjustIndex(index) {
134
138
  const { data } = this;
@@ -8,10 +8,8 @@
8
8
  catch:touchmove="onTouchMove"
9
9
  bind:touchend="onTouchEnd"
10
10
  bind:touchcancel="onTouchEnd"
11
- maxtext="{{ maxText }}"
12
- change:maxtext="{{ computed.unitStyle }}"
13
11
  >
14
- <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart }) }}"
12
+ <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart, unit }) }}"
15
13
  bind:transitionend="onTransitionEnd"
16
14
  id="options">
17
15
  <view
@@ -24,9 +22,10 @@
24
22
  bindtap="onClickItem"
25
23
  >{{ computed.optionText(option, valueKey) }}</view>
26
24
  </view>
27
- <view wx:if="{{unit}}" >
25
+ <view wx:if="{{unit}}" class="van-picker-column__unit" style="height: {{ itemHeight }}px">
26
+ <view class="van-picker-column__unit_text van-picker-column__unit_hidden" >{{unit}}</view>
28
27
  <text class="van-picker-column__max-text">{{ maxText }}</text>
29
- <view class="van-picker-column__unit" >{{unit}}</view>
28
+ <view class="van-picker-column__unit_text" >{{unit}}</view>
30
29
  </view>
31
30
 
32
31
  </view>
@@ -17,19 +17,6 @@ function rootStyle(data) {
17
17
  });
18
18
  }
19
19
 
20
- function unitStyle(value, oldValue, ownerInstance) {
21
- var maxTextDom = ownerInstance.selectComponent('.van-picker-column__max-text');
22
- var optionsDom = ownerInstance.selectComponent('#options');
23
- var unitDom = ownerInstance.selectComponent('.van-picker-column__unit');
24
- if (unitDom && maxTextDom) {
25
- var maxWidth = maxTextDom.getBoundingClientRect().width;
26
- optionsDom.setStyle({ 'text-indent': '-8rpx' });
27
- unitDom.setStyle({
28
- transform: 'translate(' + maxWidth / 2 + 'px,-50%)',
29
- });
30
- }
31
- }
32
-
33
20
  function wrapperStyle(data) {
34
21
  var offset =
35
22
  data.offset + (data.itemHeight * (data.visibleItemCount - 1)) / 2;
@@ -40,12 +27,14 @@ function wrapperStyle(data) {
40
27
  offset = addUnit(offset);
41
28
  if (data.animate) {
42
29
  return style({
30
+ 'text-indent': data.unit ? '-8rpx' : '0',
43
31
  transition: 'transform ' + data.duration + 'ms',
44
32
  'line-height': addUnit(data.itemHeight),
45
33
  transform: 'translate3d(0, ' + offset + ', 0)',
46
34
  });
47
35
  }
48
36
  return style({
37
+ 'text-indent': data.unit ? '-8rpx' : '0',
49
38
  'line-height': addUnit(data.itemHeight),
50
39
  transform: 'translate3d(0, ' + offset + ', 0)',
51
40
  });
@@ -55,5 +44,4 @@ module.exports = {
55
44
  optionText: optionText,
56
45
  rootStyle: rootStyle,
57
46
  wrapperStyle: wrapperStyle,
58
- unitStyle: unitStyle,
59
47
  };
@@ -1 +1 @@
1
- @import '../common/index.wxss';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px);left:50%;position:absolute;top:50%;transform:translate(100%,-50%)}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
1
+ @import '../common/index.wxss';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.van-picker-column__unit_text{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px)}.van-picker-column__unit_hidden{opacity:0}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
@@ -1,3 +1,4 @@
1
+ import CheckMarkIcon from '@tuya-miniapp/icons/dist/svg/Checkmark';
1
2
  import { canIUseModel } from '../common/version';
2
3
  import { VantComponent } from '../common/component';
3
4
  import { useParent } from '../common/relation';
@@ -30,6 +31,7 @@ VantComponent({
30
31
  data: {
31
32
  direction: '',
32
33
  parentDisabled: false,
34
+ icon: CheckMarkIcon,
33
35
  },
34
36
  methods: {
35
37
  updateFromParent() {
@@ -13,7 +13,8 @@
13
13
  <slot wx:if="{{ useIconSlot }}" name="icon" />
14
14
  <van-icon
15
15
  wx:else
16
- name="success"
16
+ name="{{ icon }}"
17
+ color="{{ value ? '#fff' : 'none'}}"
17
18
  class="{{ utils.bem('radio__icon', [shape, { disabled: disabled || parentDisabled, checked: value === name }]) }}"
18
19
  style="{{ computed.iconStyle({ iconSize, checkedColor, disabled, parentDisabled, value, name }) }}"
19
20
  custom-class="icon-class"
@@ -6,7 +6,7 @@
6
6
  wx:if="{{ showMinus }}"
7
7
  data-type="minus"
8
8
  style="{{ computed.buttonStyle({ buttonSize }) }}"
9
- class="minus-class {{ utils.bem('stepper__minus', { disabled: disabled || disableMinus || currentValue <= min }) }}"
9
+ class="minus-class {{ utils.bem('stepper__minus', { disabled: disabled || disableMinus || currentValue <= +min }) }}"
10
10
  hover-class="van-stepper__minus--hover"
11
11
  hover-stay-time="70"
12
12
  bind:tap="onTap"
@@ -31,7 +31,7 @@
31
31
  wx:if="{{ showPlus }}"
32
32
  data-type="plus"
33
33
  style="{{ computed.buttonStyle({ buttonSize }) }}"
34
- class="plus-class {{ utils.bem('stepper__plus', { disabled: disabled || disablePlus || currentValue >= max }) }}"
34
+ class="plus-class {{ utils.bem('stepper__plus', { disabled: disabled || disablePlus || currentValue >= +max }) }}"
35
35
  hover-class="van-stepper__plus--hover"
36
36
  hover-stay-time="70"
37
37
  bind:tap="onTap"
@@ -1 +1 @@
1
- @import '../common/index.css';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px);left:50%;position:absolute;top:50%;transform:translate(100%,-50%)}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
1
+ @import '../common/index.css';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.van-picker-column__unit_text{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px)}.van-picker-column__unit_hidden{opacity:0}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
@@ -130,7 +130,11 @@ var DEFAULT_DURATION = 200;
130
130
  var optionsV = options.slice(renderStart, renderEnd);
131
131
  return this.set({ optionsV: optionsV, renderStart: renderStart, renderNum: renderNum });
132
132
  }
133
- return this.set({ optionsV: options });
133
+ return this.set({
134
+ optionsV: options,
135
+ renderStart: 0,
136
+ renderNum: options.length,
137
+ });
134
138
  },
135
139
  adjustIndex: function (index) {
136
140
  var data = this.data;
@@ -8,10 +8,8 @@
8
8
  catch:touchmove="onTouchMove"
9
9
  bind:touchend="onTouchEnd"
10
10
  bind:touchcancel="onTouchEnd"
11
- maxtext="{{ maxText }}"
12
- change:maxtext="{{ computed.unitStyle }}"
13
11
  >
14
- <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart }) }}"
12
+ <view style="{{ computed.wrapperStyle({ offset, itemHeight, visibleItemCount, animate, duration, renderStart, unit }) }}"
15
13
  bind:transitionend="onTransitionEnd"
16
14
  id="options">
17
15
  <view
@@ -24,9 +22,10 @@
24
22
  bindtap="onClickItem"
25
23
  >{{ computed.optionText(option, valueKey) }}</view>
26
24
  </view>
27
- <view wx:if="{{unit}}" >
25
+ <view wx:if="{{unit}}" class="van-picker-column__unit" style="height: {{ itemHeight }}px">
26
+ <view class="van-picker-column__unit_text van-picker-column__unit_hidden" >{{unit}}</view>
28
27
  <text class="van-picker-column__max-text">{{ maxText }}</text>
29
- <view class="van-picker-column__unit" >{{unit}}</view>
28
+ <view class="van-picker-column__unit_text" >{{unit}}</view>
30
29
  </view>
31
30
 
32
31
  </view>
@@ -17,19 +17,6 @@ function rootStyle(data) {
17
17
  });
18
18
  }
19
19
 
20
- function unitStyle(value, oldValue, ownerInstance) {
21
- var maxTextDom = ownerInstance.selectComponent('.van-picker-column__max-text');
22
- var optionsDom = ownerInstance.selectComponent('#options');
23
- var unitDom = ownerInstance.selectComponent('.van-picker-column__unit');
24
- if (unitDom && maxTextDom) {
25
- var maxWidth = maxTextDom.getBoundingClientRect().width;
26
- optionsDom.setStyle({ 'text-indent': '-8rpx' });
27
- unitDom.setStyle({
28
- transform: 'translate(' + maxWidth / 2 + 'px,-50%)',
29
- });
30
- }
31
- }
32
-
33
20
  function wrapperStyle(data) {
34
21
  var offset =
35
22
  data.offset + (data.itemHeight * (data.visibleItemCount - 1)) / 2;
@@ -40,12 +27,14 @@ function wrapperStyle(data) {
40
27
  offset = addUnit(offset);
41
28
  if (data.animate) {
42
29
  return style({
30
+ 'text-indent': data.unit ? '-8rpx' : '0',
43
31
  transition: 'transform ' + data.duration + 'ms',
44
32
  'line-height': addUnit(data.itemHeight),
45
33
  transform: 'translate3d(0, ' + offset + ', 0)',
46
34
  });
47
35
  }
48
36
  return style({
37
+ 'text-indent': data.unit ? '-8rpx' : '0',
49
38
  'line-height': addUnit(data.itemHeight),
50
39
  transform: 'translate3d(0, ' + offset + ', 0)',
51
40
  });
@@ -55,5 +44,4 @@ module.exports = {
55
44
  optionText: optionText,
56
45
  rootStyle: rootStyle,
57
46
  wrapperStyle: wrapperStyle,
58
- unitStyle: unitStyle,
59
47
  };
@@ -1 +1 @@
1
- @import '../common/index.wxss';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px);left:50%;position:absolute;top:50%;transform:translate(100%,-50%)}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
1
+ @import '../common/index.wxss';.van-picker-column{color:var(--picker-option-text-color,var(--app-B6-N3,rgba(0,0,0,.5)));font-size:var(--picker-option-font-size,16px);position:relative;text-align:center}.van-picker-column__item{padding:0 5px}.van-picker-column__item--selected{color:var(--picker-option-selected-text-color,var(--app-B6-N1,#000));font-weight:var(--font-weight-bold,500)}.van-picker-column__item--disabled{opacity:var(--picker-option-disabled-opacity,.3)}.van-picker-column__unit{align-items:center;display:flex;justify-content:center;position:absolute;top:50%;transform:translateY(-50%);width:100%}.van-picker-column__unit_text{color:var(--picker-option-unit-text-color,var(--app-B6-N4,rgba(0,0,0,.4)));font-size:var(--picker-option-unit-font-size,12px)}.van-picker-column__unit_hidden{opacity:0}.van-picker-column__max-text{font-weight:var(--font-weight-bold,500);opacity:0}
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ var Checkmark_1 = __importDefault(require("@tuya-miniapp/icons/dist/svg/Checkmark"));
3
7
  var version_1 = require("../common/version");
4
8
  var component_1 = require("../common/component");
5
9
  var relation_1 = require("../common/relation");
@@ -32,6 +36,7 @@ var relation_1 = require("../common/relation");
32
36
  data: {
33
37
  direction: '',
34
38
  parentDisabled: false,
39
+ icon: Checkmark_1.default,
35
40
  },
36
41
  methods: {
37
42
  updateFromParent: function () {
@@ -13,7 +13,8 @@
13
13
  <slot wx:if="{{ useIconSlot }}" name="icon" />
14
14
  <van-icon
15
15
  wx:else
16
- name="success"
16
+ name="{{ icon }}"
17
+ color="{{ value ? '#fff' : 'none'}}"
17
18
  class="{{ utils.bem('radio__icon', [shape, { disabled: disabled || parentDisabled, checked: value === name }]) }}"
18
19
  style="{{ computed.iconStyle({ iconSize, checkedColor, disabled, parentDisabled, value, name }) }}"
19
20
  custom-class="icon-class"
@@ -6,7 +6,7 @@
6
6
  wx:if="{{ showMinus }}"
7
7
  data-type="minus"
8
8
  style="{{ computed.buttonStyle({ buttonSize }) }}"
9
- class="minus-class {{ utils.bem('stepper__minus', { disabled: disabled || disableMinus || currentValue <= min }) }}"
9
+ class="minus-class {{ utils.bem('stepper__minus', { disabled: disabled || disableMinus || currentValue <= +min }) }}"
10
10
  hover-class="van-stepper__minus--hover"
11
11
  hover-stay-time="70"
12
12
  bind:tap="onTap"
@@ -31,7 +31,7 @@
31
31
  wx:if="{{ showPlus }}"
32
32
  data-type="plus"
33
33
  style="{{ computed.buttonStyle({ buttonSize }) }}"
34
- class="plus-class {{ utils.bem('stepper__plus', { disabled: disabled || disablePlus || currentValue >= max }) }}"
34
+ class="plus-class {{ utils.bem('stepper__plus', { disabled: disabled || disablePlus || currentValue >= +max }) }}"
35
35
  hover-class="van-stepper__plus--hover"
36
36
  hover-stay-time="70"
37
37
  bind:tap="onTap"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "0.0.1-beta-3",
3
+ "version": "0.0.1-beta-5",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",