@ray-js/lamp-circle-picker 1.0.7 → 1.0.8-beta-2
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/component/index.js +4 -0
- package/lib/component/props.d.ts +13 -12
- package/lib/component/props.js +3 -1
- package/lib/component/rjs/index.js +19 -8
- package/lib/component/rjs/index.rjs +14 -0
- package/lib/index.d.ts +1 -17
- package/lib/index.js +9 -3
- package/lib/props.d.ts +60 -0
- package/package.json +8 -10
package/lib/component/index.js
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import RectColorPicker from './rjs';
|
|
4
4
|
export default function RectColor(props) {
|
|
5
|
+
const canvasIdRef = React.useRef(props.canvasId || `canvasId_${String(+new Date()).slice(-3)}_${String(Math.random()).slice(-3)}`);
|
|
5
6
|
return /*#__PURE__*/React.createElement(RectColorPicker, {
|
|
7
|
+
canvasId: canvasIdRef.current,
|
|
6
8
|
radius: props.radius,
|
|
7
9
|
innerRingRadius: props.innerRingRadius,
|
|
8
10
|
value: props.value,
|
|
9
11
|
useEventChannel: props.useEventChannel,
|
|
10
12
|
eventChannelName: props.eventChannelName,
|
|
13
|
+
touchCircleStrokeStyle: props.touchCircleStrokeStyle,
|
|
14
|
+
touchCircleLineWidth: props.touchCircleLineWidth,
|
|
11
15
|
bindstart: e => {
|
|
12
16
|
const {
|
|
13
17
|
detail
|
package/lib/component/props.d.ts
CHANGED
|
@@ -29,18 +29,6 @@ export interface IProps {
|
|
|
29
29
|
* @default 'lampCirclePickerEventChannel'
|
|
30
30
|
*/
|
|
31
31
|
eventChannelName?: string;
|
|
32
|
-
/**
|
|
33
|
-
* @description.zh 注意⚠️:基础库版本大于2.18.0, 是否启用事件通道,当多个 rjs 组件同时使用时,用于优化 rjs 间数据传输时的性能问题
|
|
34
|
-
* @description.en Note ⚠️ : The base library version is greater than 2.18.0, Whether to enable event channels to optimize the performance of data transfer between rjs when multiple rjs components are used simultaneously
|
|
35
|
-
* @default false
|
|
36
|
-
*/
|
|
37
|
-
useEventChannel?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* @description.zh 事件通道名称
|
|
40
|
-
* @description.en Event channel name
|
|
41
|
-
* @default 'lampCirclePickerEventChannel'
|
|
42
|
-
*/
|
|
43
|
-
eventChannelName?: string;
|
|
44
32
|
/**
|
|
45
33
|
* @description.zh 手指按下时的回调函数
|
|
46
34
|
* @description.en Finger press when the callback function
|
|
@@ -59,5 +47,18 @@ export interface IProps {
|
|
|
59
47
|
* @default ''
|
|
60
48
|
*/
|
|
61
49
|
onTouchEnd?: (value: number) => void;
|
|
50
|
+
/**
|
|
51
|
+
* @description.en touchCircleStrokeStyle
|
|
52
|
+
* @description.zh 触摸圆环描边颜色
|
|
53
|
+
* @default null
|
|
54
|
+
*/
|
|
55
|
+
touchCircleStrokeStyle?: string;
|
|
56
|
+
/**
|
|
57
|
+
* @description.en touchCircleLineWidth
|
|
58
|
+
* @description.zh 触摸圆环描边宽度
|
|
59
|
+
* @default null
|
|
60
|
+
*/
|
|
61
|
+
touchCircleLineWidth?: number;
|
|
62
|
+
canvasId?: string;
|
|
62
63
|
}
|
|
63
64
|
export declare const defaultProps: IProps;
|
package/lib/component/props.js
CHANGED
|
@@ -35,15 +35,17 @@ Component({
|
|
|
35
35
|
},
|
|
36
36
|
onTouchStart: Function,
|
|
37
37
|
onTouchMove: Function,
|
|
38
|
-
onTouchEnd: Function
|
|
38
|
+
onTouchEnd: Function,
|
|
39
|
+
touchCircleStrokeStyle: String,
|
|
40
|
+
touchCircleLineWidth: Number,
|
|
41
|
+
canvasId: String
|
|
39
42
|
},
|
|
40
43
|
data: {
|
|
41
44
|
render: null,
|
|
42
45
|
isTouch: false,
|
|
43
46
|
touchType: '',
|
|
44
47
|
colorText: '',
|
|
45
|
-
tipRectPosition: ETipRectPosition.LEFT
|
|
46
|
-
canvasId: "canvasId_".concat(String(+new Date()).slice(-3), "_").concat(String(Math.random()).slice(-3))
|
|
48
|
+
tipRectPosition: ETipRectPosition.LEFT
|
|
47
49
|
},
|
|
48
50
|
observers: {
|
|
49
51
|
'value.**'(v) {
|
|
@@ -89,26 +91,35 @@ Component({
|
|
|
89
91
|
innerRingRadius,
|
|
90
92
|
value = 0,
|
|
91
93
|
useEventChannel,
|
|
92
|
-
eventChannelName
|
|
94
|
+
eventChannelName,
|
|
95
|
+
touchCircleStrokeStyle,
|
|
96
|
+
touchCircleLineWidth
|
|
93
97
|
} = this.data;
|
|
94
98
|
const ratio = getSystemInfo().pixelRatio || 2;
|
|
95
99
|
canvasId && this.render.renderAnnulusColor(canvasId, radius, innerRingRadius, ratio, {
|
|
96
100
|
useEventChannel,
|
|
97
|
-
eventChannelName
|
|
101
|
+
eventChannelName,
|
|
102
|
+
touchCircleStrokeStyle,
|
|
103
|
+
touchCircleLineWidth
|
|
98
104
|
});
|
|
99
|
-
this._updatePosByRgb(value);
|
|
100
105
|
this.lastValue = value;
|
|
101
106
|
},
|
|
107
|
+
initedCanvas() {
|
|
108
|
+
const {
|
|
109
|
+
value = 0
|
|
110
|
+
} = this.data;
|
|
111
|
+
this._updatePosByRgb(value);
|
|
112
|
+
},
|
|
102
113
|
_updatePosByRgb(value) {
|
|
103
114
|
var _this$render;
|
|
104
115
|
if (value === undefined) {
|
|
105
116
|
return;
|
|
106
117
|
}
|
|
107
|
-
(_this$render = this.render) === null || _this$render === void 0
|
|
118
|
+
(_this$render = this.render) === null || _this$render === void 0 || _this$render._getAnglePositionByValue(value);
|
|
108
119
|
},
|
|
109
120
|
_getRgb(x, y) {
|
|
110
121
|
var _this$render2;
|
|
111
|
-
(_this$render2 = this.render) === null || _this$render2 === void 0
|
|
122
|
+
(_this$render2 = this.render) === null || _this$render2 === void 0 || _this$render2.getAnnulusImageData(x, y);
|
|
112
123
|
},
|
|
113
124
|
_getAnnulusImageData(dataRes) {
|
|
114
125
|
const {
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// commonColor.rjs
|
|
2
2
|
export default Render({
|
|
3
3
|
rectContext: null,
|
|
4
|
+
touchCircleStrokeStyle: null,
|
|
5
|
+
touchCircleLineWidth: null,
|
|
4
6
|
|
|
5
7
|
// 环形色盘
|
|
6
8
|
async renderAnnulusColor(id, radius, innerRingRadius, temp = 0, options = {}) {
|
|
7
9
|
let canvas = null;
|
|
10
|
+
const { touchCircleStrokeStyle, touchCircleLineWidth } = options || {}
|
|
11
|
+
this.touchCircleStrokeStyle = touchCircleStrokeStyle
|
|
12
|
+
this.touchCircleLineWidth = touchCircleLineWidth
|
|
8
13
|
try {
|
|
9
14
|
canvas = await getCanvasById(id);
|
|
10
15
|
} catch (error) {
|
|
@@ -60,6 +65,7 @@ export default Render({
|
|
|
60
65
|
canvas.style.height = `${radius * 2}px`;
|
|
61
66
|
this.annulusContext = ctx;
|
|
62
67
|
this.renderAnnulusColorThumb(id, temp);
|
|
68
|
+
this.callMethod('initedCanvas', {})
|
|
63
69
|
},
|
|
64
70
|
async renderAnnulusColorThumb(id, temp = 0) {
|
|
65
71
|
if (!this.canvasThumb) {
|
|
@@ -110,6 +116,14 @@ export default Render({
|
|
|
110
116
|
ctx.shadowColor = 'rgba(0, 0, 0, 0.2)';
|
|
111
117
|
ctx.fillStyle = 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
|
|
112
118
|
ctx.fill();
|
|
119
|
+
|
|
120
|
+
if(this.touchCircleStrokeStyle) {
|
|
121
|
+
ctx.shadowColor = this.touchCircleStrokeStyle;
|
|
122
|
+
}
|
|
123
|
+
if(this.touchCircleLineWidth) {
|
|
124
|
+
ctx.shadowBlur = this.touchCircleLineWidth;
|
|
125
|
+
}
|
|
126
|
+
|
|
113
127
|
ctx.strokeStyle = '#fff';
|
|
114
128
|
ctx.lineWidth = 8;
|
|
115
129
|
ctx.stroke();
|
package/lib/index.d.ts
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
radius?: number;
|
|
4
|
-
innerRingRadius?: number;
|
|
5
|
-
value: number;
|
|
6
|
-
useEventChannel?: boolean;
|
|
7
|
-
eventChannelName?: string;
|
|
8
|
-
temperature?: number;
|
|
9
|
-
titleStyle?: React.CSSProperties;
|
|
10
|
-
descStyle?: React.CSSProperties;
|
|
11
|
-
style?: React.CSSProperties;
|
|
12
|
-
onTouchStart?: (v: number) => void;
|
|
13
|
-
onTouchMove?: (v: number) => void;
|
|
14
|
-
onTouchEnd?: (v: number) => void;
|
|
15
|
-
titleStyle?: React.CSSProperties;
|
|
16
|
-
descStyle?: React.CSSProperties;
|
|
17
|
-
style?: React.CSSProperties;
|
|
18
|
-
}
|
|
2
|
+
import { IProps } from './props';
|
|
19
3
|
declare const LampCirclePicker: {
|
|
20
4
|
(props: IProps): React.JSX.Element;
|
|
21
5
|
defaultProps: {
|
package/lib/index.js
CHANGED
|
@@ -20,8 +20,12 @@ const LampCirclePicker = props => {
|
|
|
20
20
|
descStyle,
|
|
21
21
|
style,
|
|
22
22
|
onTouchStart,
|
|
23
|
+
desc,
|
|
23
24
|
onTouchMove,
|
|
24
|
-
onTouchEnd
|
|
25
|
+
onTouchEnd,
|
|
26
|
+
showInnerCircle = true,
|
|
27
|
+
touchCircleLineWidth,
|
|
28
|
+
touchCircleStrokeStyle
|
|
25
29
|
} = props;
|
|
26
30
|
const innerImgRadius = innerRingRadius * 4 * 0.8;
|
|
27
31
|
const _value = value !== null && value !== void 0 ? value : temperature;
|
|
@@ -34,12 +38,14 @@ const LampCirclePicker = props => {
|
|
|
34
38
|
innerRingRadius: innerRingRadius,
|
|
35
39
|
useEventChannel: useEventChannel || false,
|
|
36
40
|
eventChannelName: eventChannelName,
|
|
41
|
+
touchCircleLineWidth: touchCircleLineWidth,
|
|
42
|
+
touchCircleStrokeStyle: touchCircleStrokeStyle,
|
|
37
43
|
onTouchStart: onTouchStart,
|
|
38
44
|
onTouchMove: onTouchMove,
|
|
39
45
|
onTouchEnd: onTouchEnd
|
|
40
46
|
}), /*#__PURE__*/React.createElement(View, {
|
|
41
47
|
className: clsx(styled.innerBox, styled.flexCenter)
|
|
42
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
|
48
|
+
}, showInnerCircle && /*#__PURE__*/React.createElement(Image, {
|
|
43
49
|
src: ring,
|
|
44
50
|
className: styled.ringIcon,
|
|
45
51
|
style: {
|
|
@@ -54,7 +60,7 @@ const LampCirclePicker = props => {
|
|
|
54
60
|
}, Math.trunc(_value / 10), "%"), /*#__PURE__*/React.createElement(Text, {
|
|
55
61
|
className: styled.desc,
|
|
56
62
|
style: descStyle
|
|
57
|
-
}, Strings.getLang('temperature')))));
|
|
63
|
+
}, desc || Strings.getLang('temperature')))));
|
|
58
64
|
};
|
|
59
65
|
const nilFn = () => null;
|
|
60
66
|
LampCirclePicker.defaultProps = {
|
package/lib/props.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export interface IProps {
|
|
2
3
|
/**
|
|
3
4
|
* @description.zh 默认数值
|
|
@@ -5,6 +6,12 @@ export interface IProps {
|
|
|
5
6
|
* @default
|
|
6
7
|
*/
|
|
7
8
|
value: number;
|
|
9
|
+
/**
|
|
10
|
+
* @description.en temperature
|
|
11
|
+
* @description.zh 色温
|
|
12
|
+
* @default null
|
|
13
|
+
*/
|
|
14
|
+
temperature?: number;
|
|
8
15
|
/**
|
|
9
16
|
* @description.zh 内部色环宽度
|
|
10
17
|
* @description.en The width of inner color ring
|
|
@@ -35,4 +42,57 @@ export interface IProps {
|
|
|
35
42
|
* @default ''
|
|
36
43
|
*/
|
|
37
44
|
onTouchEnd?: (value: number) => void;
|
|
45
|
+
/**
|
|
46
|
+
* @description.en showInnerCircle
|
|
47
|
+
* @description.zh 展示数值圆环
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
showInnerCircle?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* @description.en useEventChannel
|
|
53
|
+
* @description.zh 使用事件
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
useEventChannel?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* @description.en eventChannelName
|
|
59
|
+
* @description.zh 事件名
|
|
60
|
+
* @default null
|
|
61
|
+
*/
|
|
62
|
+
eventChannelName?: string;
|
|
63
|
+
/**
|
|
64
|
+
* @description.en titleStyle
|
|
65
|
+
* @description.zh 标题样式
|
|
66
|
+
* @default null
|
|
67
|
+
*/
|
|
68
|
+
titleStyle?: React.CSSProperties;
|
|
69
|
+
/**
|
|
70
|
+
* @description.en descStyle
|
|
71
|
+
* @description.zh 描述样式
|
|
72
|
+
* @default null
|
|
73
|
+
*/
|
|
74
|
+
descStyle?: React.CSSProperties;
|
|
75
|
+
/**
|
|
76
|
+
* @description.en style
|
|
77
|
+
* @description.zh 样式
|
|
78
|
+
* @default null
|
|
79
|
+
*/
|
|
80
|
+
style?: React.CSSProperties;
|
|
81
|
+
/**
|
|
82
|
+
* @description.en touchCircleStrokeStyle
|
|
83
|
+
* @description.zh 触摸圆环描边颜色
|
|
84
|
+
* @default null
|
|
85
|
+
*/
|
|
86
|
+
touchCircleStrokeStyle?: string;
|
|
87
|
+
/**
|
|
88
|
+
* @description.en touchCircleLineWidth
|
|
89
|
+
* @description.zh 触摸圆环描边宽度
|
|
90
|
+
* @default null
|
|
91
|
+
*/
|
|
92
|
+
touchCircleLineWidth?: number;
|
|
93
|
+
/**
|
|
94
|
+
* @description.en desc
|
|
95
|
+
* @description.zh 中间文案
|
|
96
|
+
*/
|
|
97
|
+
desc?: string;
|
|
38
98
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/lamp-circle-picker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8-beta-2",
|
|
4
4
|
"description": "照明缺角色环",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
|
20
20
|
"build": "ray build --type=component",
|
|
21
|
-
"watch": "ray start --type=component",
|
|
21
|
+
"watch": "ray start --type=component --output ./example/src/lib",
|
|
22
22
|
"build:tuya": "ray build ./example --target=tuya",
|
|
23
23
|
"build:wechat": "ray build ./example --target=wechat",
|
|
24
24
|
"build:web": "ray build ./example --target=web",
|
|
25
25
|
"build:native": "ray build ./example --target=native",
|
|
26
26
|
"start:native": "ray start ./example -t native --verbose",
|
|
27
|
-
"start:tuya": "ray start ./example
|
|
27
|
+
"start:tuya": "ray start ./example",
|
|
28
28
|
"start:wechat": "ray start ./example -t wechat --verbose",
|
|
29
29
|
"start:web": "ray start ./example -t web",
|
|
30
30
|
"prepublishOnly": "yarn build",
|
|
@@ -36,13 +36,11 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@commitlint/cli": "^7.2.1",
|
|
38
38
|
"@commitlint/config-conventional": "^9.0.1",
|
|
39
|
-
"@ray-js/babel-preset-standard": "^0.
|
|
40
|
-
"@ray-js/cli": "
|
|
41
|
-
"@ray-js/
|
|
42
|
-
"@ray-js/
|
|
43
|
-
"@ray-js/
|
|
44
|
-
"@ray-js/rn-transformer-helper": "^0.5.5",
|
|
45
|
-
"@ray-js/types": "^0.6.14",
|
|
39
|
+
"@ray-js/babel-preset-standard": "^0.4.11",
|
|
40
|
+
"@ray-js/cli": "^1.4.44",
|
|
41
|
+
"@ray-js/panel-sdk": "^1.12.0",
|
|
42
|
+
"@ray-js/ray": "^1.4.9",
|
|
43
|
+
"@ray-js/types": "^0.6.15",
|
|
46
44
|
"@types/node": "^17.0.43",
|
|
47
45
|
"core-js": "^3.19.1",
|
|
48
46
|
"eslint-config-tuya-panel": "^0.4.1",
|