@ray-js/lamp-style-slider 0.0.3-beta-4 → 0.0.3-beta-6
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.config.js +3 -3
- package/lib/index.d.ts +2 -2
- package/lib/index.js +55 -58
- package/lib/props.d.ts +9 -0
- package/lib/props.js +4 -10
- package/lib/utils/index.js +7 -9
- package/package.json +6 -6
package/lib/index.config.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const tuya = {
|
|
2
2
|
backgroundColor: '#f2f4f6',
|
|
3
3
|
navigationBarTitleText: 'Ray 跨端组件'
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export const wechat = {
|
|
6
6
|
backgroundColor: '#f2f4f6',
|
|
7
7
|
navigationBarTitleText: 'Ray 跨端组件'
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export const native = {
|
|
10
10
|
backgroundColor: '#000000',
|
|
11
11
|
isBleOfflineOverlay: false,
|
|
12
12
|
useSafeAreaView: true,
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { IProps } from './props';
|
|
3
|
-
declare function OpacitySlider(props: IProps): JSX.Element;
|
|
3
|
+
declare function OpacitySlider(props: IProps): React.JSX.Element;
|
|
4
4
|
declare namespace OpacitySlider {
|
|
5
5
|
var defaultProps: IProps;
|
|
6
6
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
-
import "core-js/modules/es.array.concat.js";
|
|
4
|
-
import "core-js/modules/es.array.slice.js";
|
|
5
2
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
6
3
|
import React, { useRef, useState, useEffect } from 'react';
|
|
7
4
|
import { View, Text } from '@ray-js/ray';
|
|
@@ -12,37 +9,35 @@ import { formatPercent } from './utils';
|
|
|
12
9
|
import styles from './index.module.less';
|
|
13
10
|
import { defaultProps } from './props';
|
|
14
11
|
function OpacitySlider(props) {
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
max =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var handTouchMove = useThrottleFn(function (_ref2) {
|
|
45
|
-
var detail = _ref2.detail;
|
|
12
|
+
var _props$thumbColorForm, _props$thumbColorForm2;
|
|
13
|
+
const preValue = useRef(-1);
|
|
14
|
+
const lastValue = useRef(null);
|
|
15
|
+
const timer = useRef(null);
|
|
16
|
+
const moveTimer = useRef(null);
|
|
17
|
+
const isMove = useRef(false);
|
|
18
|
+
const {
|
|
19
|
+
label,
|
|
20
|
+
min = 0,
|
|
21
|
+
max = 1000,
|
|
22
|
+
rangeOffset = 38,
|
|
23
|
+
value,
|
|
24
|
+
style,
|
|
25
|
+
trackStyle = {},
|
|
26
|
+
thumbStyle = {},
|
|
27
|
+
textValue,
|
|
28
|
+
disable = false,
|
|
29
|
+
valueStyle,
|
|
30
|
+
trackBackgroundColor,
|
|
31
|
+
enableTouch = true,
|
|
32
|
+
onTouchStart,
|
|
33
|
+
onTouchMove,
|
|
34
|
+
onTouchEnd
|
|
35
|
+
} = props;
|
|
36
|
+
const startRefValue = useRef(-1);
|
|
37
|
+
const handTouchMove = useThrottleFn(_ref2 => {
|
|
38
|
+
let {
|
|
39
|
+
detail
|
|
40
|
+
} = _ref2;
|
|
46
41
|
if (!onTouchMove || disable) {
|
|
47
42
|
return;
|
|
48
43
|
}
|
|
@@ -67,25 +62,22 @@ function OpacitySlider(props) {
|
|
|
67
62
|
}, {
|
|
68
63
|
wait: 80
|
|
69
64
|
}).run;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
controllerValue = _useState2[0],
|
|
75
|
-
setControllerValue = _useState2[1];
|
|
76
|
-
useEffect(function () {
|
|
65
|
+
const endRefValue = useRef(-1);
|
|
66
|
+
const instanceId = useRef(`Color_${String(+new Date()).slice(-4)}_${String(Math.random()).slice(-2)}`);
|
|
67
|
+
const [controllerValue, setControllerValue] = useState(-1);
|
|
68
|
+
useEffect(() => {
|
|
77
69
|
if (!isMove.current && value !== controllerValue) {
|
|
78
70
|
updateControlVal(value);
|
|
79
71
|
}
|
|
80
72
|
}, [value]);
|
|
81
|
-
|
|
73
|
+
const updateControlVal = useDebounceFn(val => {
|
|
82
74
|
setControllerValue(val);
|
|
83
75
|
}, {
|
|
84
76
|
wait: 150
|
|
85
77
|
}).run;
|
|
86
78
|
return /*#__PURE__*/React.createElement(View, {
|
|
87
79
|
style: style
|
|
88
|
-
}, label &&
|
|
80
|
+
}, label && (() => {
|
|
89
81
|
return /*#__PURE__*/React.createElement(View, {
|
|
90
82
|
className: styles.textRow
|
|
91
83
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
@@ -98,12 +90,12 @@ function OpacitySlider(props) {
|
|
|
98
90
|
}, "\xB7"), /*#__PURE__*/React.createElement(Text, {
|
|
99
91
|
className: styles.value,
|
|
100
92
|
style: valueStyle
|
|
101
|
-
}, textValue ||
|
|
102
|
-
min
|
|
103
|
-
max
|
|
93
|
+
}, textValue || `${formatPercent(controllerValue, {
|
|
94
|
+
min,
|
|
95
|
+
max,
|
|
104
96
|
minPercent: min
|
|
105
|
-
})
|
|
106
|
-
}(), /*#__PURE__*/React.createElement(View, {
|
|
97
|
+
})}%`));
|
|
98
|
+
})(), /*#__PURE__*/React.createElement(View, {
|
|
107
99
|
style: _objectSpread({
|
|
108
100
|
width: '646rpx',
|
|
109
101
|
height: '56rpx',
|
|
@@ -114,14 +106,13 @@ function OpacitySlider(props) {
|
|
|
114
106
|
instanceId: instanceId.current,
|
|
115
107
|
min: 0,
|
|
116
108
|
max: max - min,
|
|
117
|
-
closed: false,
|
|
118
109
|
disable: disable,
|
|
119
110
|
end: controllerValue - min,
|
|
120
111
|
step: 1,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
112
|
+
bindstart: _ref => {
|
|
113
|
+
let {
|
|
114
|
+
detail
|
|
115
|
+
} = _ref;
|
|
125
116
|
if (!onTouchStart || disable) {
|
|
126
117
|
return;
|
|
127
118
|
}
|
|
@@ -133,8 +124,10 @@ function OpacitySlider(props) {
|
|
|
133
124
|
startRefValue.current = detail.end;
|
|
134
125
|
},
|
|
135
126
|
bindmove: handTouchMove,
|
|
136
|
-
bindend:
|
|
137
|
-
|
|
127
|
+
bindend: _ref3 => {
|
|
128
|
+
let {
|
|
129
|
+
detail
|
|
130
|
+
} = _ref3;
|
|
138
131
|
if (!onTouchEnd || disable) {
|
|
139
132
|
return;
|
|
140
133
|
}
|
|
@@ -142,7 +135,7 @@ function OpacitySlider(props) {
|
|
|
142
135
|
return;
|
|
143
136
|
}
|
|
144
137
|
clearTimeout(moveTimer.current);
|
|
145
|
-
moveTimer.current = setTimeout(
|
|
138
|
+
moveTimer.current = setTimeout(() => {
|
|
146
139
|
isMove.current = false;
|
|
147
140
|
}, 100);
|
|
148
141
|
onTouchEnd && onTouchEnd(detail.end + min);
|
|
@@ -165,8 +158,12 @@ function OpacitySlider(props) {
|
|
|
165
158
|
border: '8rpx solid #fff',
|
|
166
159
|
borderRadius: '50%',
|
|
167
160
|
boxShadow: 'rgb(255 255 255 / 10%) 0px 0px 1px',
|
|
168
|
-
background:
|
|
169
|
-
}, thumbStyle))
|
|
161
|
+
background: `${disable ? '#000' : 'transparent'}`
|
|
162
|
+
}, thumbStyle)),
|
|
163
|
+
thumbStyleRenderFormatter: {
|
|
164
|
+
background: props === null || props === void 0 ? void 0 : (_props$thumbColorForm = props.thumbColorFormatterConfig) === null || _props$thumbColorForm === void 0 ? void 0 : _props$thumbColorForm.formatter
|
|
165
|
+
},
|
|
166
|
+
thumbStyleRenderValueScale: props === null || props === void 0 ? void 0 : (_props$thumbColorForm2 = props.thumbColorFormatterConfig) === null || _props$thumbColorForm2 === void 0 ? void 0 : _props$thumbColorForm2.scale
|
|
170
167
|
})));
|
|
171
168
|
}
|
|
172
169
|
OpacitySlider.defaultProps = defaultProps;
|
package/lib/props.d.ts
CHANGED
|
@@ -95,5 +95,14 @@ export interface IProps {
|
|
|
95
95
|
* @default () => {}
|
|
96
96
|
*/
|
|
97
97
|
onTouchEnd?: (value: number) => void;
|
|
98
|
+
/**
|
|
99
|
+
* @description.en style
|
|
100
|
+
* @description.zh 按钮hsv背景渲染,例如 "hsl(valuedeg 100% 50%)"
|
|
101
|
+
* @default null
|
|
102
|
+
*/
|
|
103
|
+
thumbColorFormatterConfig?: {
|
|
104
|
+
formatter: string;
|
|
105
|
+
scale?: number;
|
|
106
|
+
};
|
|
98
107
|
}
|
|
99
108
|
export declare const defaultProps: IProps;
|
package/lib/props.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable prettier/prettier */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export const defaultProps = {
|
|
5
5
|
value: 1,
|
|
6
6
|
trackStyle: {},
|
|
7
7
|
enableTouch: true,
|
|
@@ -10,13 +10,7 @@ export var defaultProps = {
|
|
|
10
10
|
style: {},
|
|
11
11
|
min: 0,
|
|
12
12
|
max: 1000,
|
|
13
|
-
onTouchStart:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
onTouchMove: function onTouchMove() {
|
|
17
|
-
return null;
|
|
18
|
-
},
|
|
19
|
-
onTouchEnd: function onTouchEnd() {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
13
|
+
onTouchStart: () => null,
|
|
14
|
+
onTouchMove: () => null,
|
|
15
|
+
onTouchEnd: () => null
|
|
22
16
|
};
|
package/lib/utils/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
_ref$minPercent = _ref.minPercent,
|
|
9
|
-
minPercent = _ref$minPercent === void 0 ? 0 : _ref$minPercent;
|
|
1
|
+
export const formatPercent = function () {
|
|
2
|
+
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
3
|
+
let {
|
|
4
|
+
min = 0,
|
|
5
|
+
max = 1000,
|
|
6
|
+
minPercent = 0
|
|
7
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
10
8
|
return Math.min(100, Math.round((100 - minPercent) * (value - min) / (max - min) + minPercent));
|
|
11
9
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/lamp-style-slider",
|
|
3
|
-
"version": "0.0.3-beta-
|
|
3
|
+
"version": "0.0.3-beta-6",
|
|
4
4
|
"description": "照明样式的基础滑动条",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
|
13
13
|
"build": "ray build --type=component",
|
|
14
14
|
"watch": "ray start --type=component",
|
|
15
|
-
"build:tuya": "ray build ./example
|
|
15
|
+
"build:tuya": "ray build ./example",
|
|
16
16
|
"build:wechat": "ray build ./example --target=wechat",
|
|
17
17
|
"build:web": "ray build ./example --target=web",
|
|
18
18
|
"build:native": "ray build ./example --target=native",
|
|
19
19
|
"start:native": "ray start ./example -t native --verbose",
|
|
20
|
-
"start:tuya": "ray start ./example
|
|
20
|
+
"start:tuya": "ray start ./example --verbose",
|
|
21
21
|
"start:wechat": "ray start ./example -t wechat --verbose",
|
|
22
22
|
"start:web": "ray start ./example -t web",
|
|
23
23
|
"prepublishOnly": "yarn build",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"@commitlint/cli": "^7.2.1",
|
|
32
32
|
"@commitlint/config-conventional": "^9.0.1",
|
|
33
33
|
"@ray-js/babel-preset-standard": "^0.6.14",
|
|
34
|
-
"@ray-js/cli": "^
|
|
34
|
+
"@ray-js/cli": "^1.4.9",
|
|
35
35
|
"@ray-js/panel-sdk": "^1.1.4",
|
|
36
|
-
"@ray-js/ray": "^
|
|
36
|
+
"@ray-js/ray": "^1.4.9",
|
|
37
37
|
"@ray-js/rn-transformer-helper": "^0.5.5",
|
|
38
38
|
"@types/node": "^17.0.43",
|
|
39
39
|
"core-js": "^3.19.1",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@ray-js/components-ty-slider": "0.2.36-beta-
|
|
62
|
+
"@ray-js/components-ty-slider": "0.2.36-beta-6"
|
|
63
63
|
},
|
|
64
64
|
"maintainers": [
|
|
65
65
|
{
|