@ray-js/lamp-style-slider 0.0.6-beta-7 → 0.0.6-beta-9
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 +43 -39
- package/lib/index.module.less +1 -0
- package/lib/props.d.ts +6 -0
- package/lib/props.js +2 -1
- package/package.json +3 -2
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
|
|
6
|
-
import
|
|
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(
|
|
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 =
|
|
46
|
-
if (
|
|
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(
|
|
51
|
+
onTouchMove && onTouchMove(value);
|
|
53
52
|
if (!textValue && label) {
|
|
54
|
-
setControllerValue(
|
|
53
|
+
setControllerValue(value);
|
|
55
54
|
}
|
|
56
|
-
preValue.current =
|
|
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
|
|
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,16 @@ function OpacitySlider(props) {
|
|
|
92
92
|
style: {
|
|
93
93
|
margin: '0 4px'
|
|
94
94
|
}
|
|
95
|
-
}, "\xB7"), /*#__PURE__*/React.createElement(
|
|
95
|
+
}, "\xB7"), textShowType === 'sjs' ? /*#__PURE__*/React.createElement(View, {
|
|
96
|
+
className: styles.value,
|
|
97
|
+
style: valueStyle
|
|
98
|
+
}, /*#__PURE__*/React.createElement(PerfText, {
|
|
99
|
+
instanceId: eventName,
|
|
100
|
+
defaultValue: controllerValue,
|
|
101
|
+
valueStart: -100 * min / (max - min),
|
|
102
|
+
valueScale: 100 / (max - min),
|
|
103
|
+
eventName: eventName
|
|
104
|
+
}), "%") : /*#__PURE__*/React.createElement(Text, {
|
|
96
105
|
className: styles.value,
|
|
97
106
|
style: valueStyle
|
|
98
107
|
}, textValue || `${formatPercent(controllerValue, {
|
|
@@ -109,57 +118,52 @@ function OpacitySlider(props) {
|
|
|
109
118
|
}, trackStyle)
|
|
110
119
|
}, /*#__PURE__*/React.createElement(Slider, {
|
|
111
120
|
instanceId: props.instanceId || instanceId.current,
|
|
112
|
-
min:
|
|
113
|
-
max: max
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
min: min,
|
|
122
|
+
max: max,
|
|
123
|
+
disabled: disable,
|
|
124
|
+
moveEventName: eventName,
|
|
125
|
+
value: value,
|
|
116
126
|
step: 1,
|
|
117
127
|
enableTouch: enableTouch,
|
|
118
|
-
|
|
119
|
-
let {
|
|
120
|
-
detail
|
|
121
|
-
} = _ref;
|
|
128
|
+
onBeforeChange: value => {
|
|
122
129
|
if (!onTouchStart || disable) {
|
|
123
130
|
return;
|
|
124
131
|
}
|
|
125
|
-
if (
|
|
132
|
+
if (value === startRefValue.current) {
|
|
126
133
|
return;
|
|
127
134
|
}
|
|
128
135
|
isMove.current = false;
|
|
129
|
-
onTouchStart && onTouchStart(
|
|
130
|
-
startRefValue.current =
|
|
136
|
+
onTouchStart && onTouchStart(value);
|
|
137
|
+
startRefValue.current = value;
|
|
131
138
|
},
|
|
132
|
-
|
|
139
|
+
onChange: handTouchMove,
|
|
133
140
|
hideThumbButton: controllerValue === -1,
|
|
134
|
-
|
|
135
|
-
let {
|
|
136
|
-
detail
|
|
137
|
-
} = _ref3;
|
|
141
|
+
onAfterChange: value => {
|
|
138
142
|
if (!onTouchEnd || disable) {
|
|
139
143
|
return;
|
|
140
144
|
}
|
|
141
|
-
if (
|
|
145
|
+
if (value === endRefValue.current) {
|
|
142
146
|
return;
|
|
143
147
|
}
|
|
144
148
|
clearTimeout(moveTimer.current);
|
|
145
149
|
moveTimer.current = setTimeout(() => {
|
|
146
150
|
isMove.current = false;
|
|
147
151
|
}, 100);
|
|
148
|
-
onTouchEnd && onTouchEnd(
|
|
149
|
-
endRefValue.current =
|
|
152
|
+
onTouchEnd && onTouchEnd(value);
|
|
153
|
+
endRefValue.current = value;
|
|
150
154
|
},
|
|
151
|
-
trackStyle:
|
|
155
|
+
trackStyle: _objectSpread(_objectSpread({
|
|
152
156
|
width: '646rpx',
|
|
153
157
|
height: '56rpx',
|
|
154
158
|
position: 'relative',
|
|
155
159
|
borderRadius: '28rpx'
|
|
156
160
|
}, trackStyle), {}, {
|
|
157
161
|
background: trackBackgroundColor
|
|
158
|
-
})),
|
|
159
|
-
barStyle: toStyle({
|
|
160
|
-
background: 'transparent'
|
|
161
162
|
}),
|
|
162
|
-
|
|
163
|
+
barStyle: {
|
|
164
|
+
background: 'transparent'
|
|
165
|
+
},
|
|
166
|
+
thumbStyle: _objectSpread({
|
|
163
167
|
width: '62rpx',
|
|
164
168
|
height: '62rpx',
|
|
165
169
|
border: '8rpx solid #fff',
|
|
@@ -167,7 +171,7 @@ function OpacitySlider(props) {
|
|
|
167
171
|
boxShadow: 'rgb(255 255 255 / 10%) 0px 0px 1px',
|
|
168
172
|
background: `${'transparent'}`,
|
|
169
173
|
transition: 'opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1)'
|
|
170
|
-
}, thumbStyle)
|
|
174
|
+
}, thumbStyle),
|
|
171
175
|
thumbStyleRenderFormatter: {
|
|
172
176
|
background: props === null || props === void 0 ? void 0 : (_props$thumbColorForm = props.thumbColorFormatterConfig) === null || _props$thumbColorForm === void 0 ? void 0 : _props$thumbColorForm.formatter
|
|
173
177
|
},
|
package/lib/index.module.less
CHANGED
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/lamp-style-slider",
|
|
3
|
-
"version": "0.0.6-beta-
|
|
3
|
+
"version": "0.0.6-beta-9",
|
|
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
|
+
}
|