@ray-js/lamp-style-slider 0.0.6-beta-7 → 0.0.6-beta-8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -2,8 +2,8 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
3
  import React, { useRef, useState, useEffect } from 'react';
4
4
  import { View, Text } from '@ray-js/ray';
5
- import Slider from '@ray-js/components-ty-slider/lib/SjsSlider';
6
- import { toStyle } from '@ray-js/components-ty-slider';
5
+ import Slider from '@ray-js/components-ty-slider';
6
+ import PerfText from '@ray-js/components-ty-perf-text';
7
7
  import { useDebounceFn, useThrottleFn } from 'ahooks';
8
8
  import { formatPercent } from './utils';
9
9
  import styles from './index.module.less';
@@ -31,33 +31,32 @@ function OpacitySlider(props) {
31
31
  enableTouch = true,
32
32
  onTouchStart,
33
33
  onTouchMove,
34
- onTouchEnd
34
+ onTouchEnd,
35
+ textShowType = 'ray'
35
36
  } = props;
37
+ console.log('🚀 ~ index ~ value:', value);
36
38
  const startRefValue = useRef(-1);
37
- const handTouchMove = useThrottleFn(_ref2 => {
38
- let {
39
- detail
40
- } = _ref2;
39
+ const handTouchMove = useThrottleFn(value => {
41
40
  if (!onTouchMove || disable) {
42
41
  return;
43
42
  }
44
43
  isMove.current = true;
45
- lastValue.current = detail.end + min;
46
- if (detail.end + min === preValue.current) {
44
+ lastValue.current = value;
45
+ if (value === preValue.current) {
47
46
  return;
48
47
  }
49
48
  if (timer.current) {
50
49
  return;
51
50
  }
52
- onTouchMove && onTouchMove(detail.end + min);
51
+ onTouchMove && onTouchMove(value);
53
52
  if (!textValue && label) {
54
- setControllerValue(detail.end + min);
53
+ setControllerValue(value);
55
54
  }
56
- preValue.current = detail.end + min;
55
+ preValue.current = value;
57
56
  clearTimeout(timer.current);
58
57
  timer.current = null;
59
58
  if (lastValue.current !== preValue.current) {
60
- onTouchMove && onTouchMove(lastValue.current + min);
59
+ onTouchMove && onTouchMove(lastValue.current);
61
60
  }
62
61
  }, {
63
62
  wait: 80
@@ -75,6 +74,7 @@ function OpacitySlider(props) {
75
74
  }, {
76
75
  wait: 150
77
76
  }).run;
77
+ const eventName = `OpacitySlider_${instanceId.current}`;
78
78
  return /*#__PURE__*/React.createElement(View, {
79
79
  style: style
80
80
  }, label && (() => {
@@ -92,7 +92,15 @@ function OpacitySlider(props) {
92
92
  style: {
93
93
  margin: '0 4px'
94
94
  }
95
- }, "\xB7"), /*#__PURE__*/React.createElement(Text, {
95
+ }, "\xB7"), textShowType === 'sjs' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PerfText, {
96
+ instanceId: eventName,
97
+ className: styles.value,
98
+ defaultValue: controllerValue,
99
+ valueStart: -100 * min / (max - min),
100
+ valueScale: 100 / (max - min),
101
+ eventName: eventName,
102
+ style: valueStyle
103
+ }), "%") : /*#__PURE__*/React.createElement(Text, {
96
104
  className: styles.value,
97
105
  style: valueStyle
98
106
  }, textValue || `${formatPercent(controllerValue, {
@@ -109,57 +117,52 @@ function OpacitySlider(props) {
109
117
  }, trackStyle)
110
118
  }, /*#__PURE__*/React.createElement(Slider, {
111
119
  instanceId: props.instanceId || instanceId.current,
112
- min: 0,
113
- max: max - min,
114
- disable: disable,
115
- end: controllerValue - min,
120
+ min: min,
121
+ max: max,
122
+ disabled: disable,
123
+ moveEventName: eventName,
124
+ value: value,
116
125
  step: 1,
117
126
  enableTouch: enableTouch,
118
- bindstart: _ref => {
119
- let {
120
- detail
121
- } = _ref;
127
+ onBeforeChange: value => {
122
128
  if (!onTouchStart || disable) {
123
129
  return;
124
130
  }
125
- if (detail.end === startRefValue.current) {
131
+ if (value === startRefValue.current) {
126
132
  return;
127
133
  }
128
134
  isMove.current = false;
129
- onTouchStart && onTouchStart(detail.end);
130
- startRefValue.current = detail.end;
135
+ onTouchStart && onTouchStart(value);
136
+ startRefValue.current = value;
131
137
  },
132
- bindmove: handTouchMove,
138
+ onChange: handTouchMove,
133
139
  hideThumbButton: controllerValue === -1,
134
- bindend: _ref3 => {
135
- let {
136
- detail
137
- } = _ref3;
140
+ onAfterChange: value => {
138
141
  if (!onTouchEnd || disable) {
139
142
  return;
140
143
  }
141
- if (detail.end + min === endRefValue.current) {
144
+ if (value === endRefValue.current) {
142
145
  return;
143
146
  }
144
147
  clearTimeout(moveTimer.current);
145
148
  moveTimer.current = setTimeout(() => {
146
149
  isMove.current = false;
147
150
  }, 100);
148
- onTouchEnd && onTouchEnd(detail.end + min);
149
- endRefValue.current = detail.end + min;
151
+ onTouchEnd && onTouchEnd(value);
152
+ endRefValue.current = value;
150
153
  },
151
- trackStyle: toStyle(_objectSpread(_objectSpread({
154
+ trackStyle: _objectSpread(_objectSpread({
152
155
  width: '646rpx',
153
156
  height: '56rpx',
154
157
  position: 'relative',
155
158
  borderRadius: '28rpx'
156
159
  }, trackStyle), {}, {
157
160
  background: trackBackgroundColor
158
- })),
159
- barStyle: toStyle({
160
- background: 'transparent'
161
161
  }),
162
- thumbStyle: toStyle(_objectSpread({
162
+ barStyle: {
163
+ background: 'transparent'
164
+ },
165
+ thumbStyle: _objectSpread({
163
166
  width: '62rpx',
164
167
  height: '62rpx',
165
168
  border: '8rpx solid #fff',
@@ -167,7 +170,7 @@ function OpacitySlider(props) {
167
170
  boxShadow: 'rgb(255 255 255 / 10%) 0px 0px 1px',
168
171
  background: `${'transparent'}`,
169
172
  transition: 'opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1)'
170
- }, thumbStyle)),
173
+ }, thumbStyle),
171
174
  thumbStyleRenderFormatter: {
172
175
  background: props === null || props === void 0 ? void 0 : (_props$thumbColorForm = props.thumbColorFormatterConfig) === null || _props$thumbColorForm === void 0 ? void 0 : _props$thumbColorForm.formatter
173
176
  },
@@ -23,5 +23,6 @@
23
23
  letter-spacing: 0px;
24
24
  text-align: left;
25
25
  opacity: .9;
26
+ display: inherit;
26
27
  }
27
28
  }
package/lib/props.d.ts CHANGED
@@ -109,5 +109,11 @@ export interface IProps {
109
109
  formatter: string;
110
110
  scale?: number;
111
111
  };
112
+ /**
113
+ * @description.en text show type
114
+ * @description.zh 文本显示类型
115
+ * @default 'ray'
116
+ */
117
+ textShowType?: 'ray' | 'sjs';
112
118
  }
113
119
  export declare const defaultProps: IProps;
package/lib/props.js CHANGED
@@ -11,5 +11,6 @@ export const defaultProps = {
11
11
  max: 1000,
12
12
  onTouchStart: () => null,
13
13
  onTouchMove: () => null,
14
- onTouchEnd: () => null
14
+ onTouchEnd: () => null,
15
+ textShowType: 'ray'
15
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-style-slider",
3
- "version": "0.0.6-beta-7",
3
+ "version": "0.0.6-beta-8",
4
4
  "description": "照明样式的基础滑动条",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -59,6 +59,7 @@
59
59
  ]
60
60
  },
61
61
  "dependencies": {
62
+ "@ray-js/components-ty-perf-text": "^0.0.9",
62
63
  "@ray-js/components-ty-slider": "^0.3.8"
63
64
  },
64
65
  "resolutions": {
@@ -71,4 +72,4 @@
71
72
  "email": "tuyafe@tuya.com"
72
73
  }
73
74
  ]
74
- }
75
+ }