@ray-js/lamp-circle-picker 1.0.8-beta-2 → 1.0.9-beta-1
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/README.md +51 -1
- package/example/src/app.config.ts +20 -0
- package/example/src/app.less +0 -0
- package/example/src/app.tsx +42 -0
- package/example/src/global.config.ts +57 -0
- package/example/src/pages/index.config.ts +21 -0
- package/example/src/pages/index.module.less +31 -0
- package/example/src/pages/index.tsx +78 -0
- package/example/src/res/.gitkeep +0 -0
- package/example/src/routes.config.ts +11 -0
- package/example/src/variables.less +7 -0
- package/lib/component/index.config.js +4 -4
- package/lib/component/index.d.ts +2 -2
- package/lib/component/index.js +11 -19
- package/lib/component/props.d.ts +8 -1
- package/lib/component/props.js +14 -2
- package/lib/component/rjs/index.js +57 -55
- package/lib/component/rjs/index.rjs +15 -16
- package/lib/demoRjs/index.js +1 -3
- package/lib/demoRjs/index.rjs +2 -1
- package/lib/i18n/index.d.ts +1 -12
- package/lib/i18n/index.js +1 -3
- package/lib/index.config.js +4 -4
- package/lib/index.d.ts +6 -2
- package/lib/index.js +67 -34
- package/lib/props.d.ts +21 -8
- package/lib/res/index.js +2 -2
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +11 -13
- package/package.json +17 -9
package/README.md
CHANGED
|
@@ -28,6 +28,14 @@ interface IProps {
|
|
|
28
28
|
* @default
|
|
29
29
|
*/
|
|
30
30
|
value: number;
|
|
31
|
+
/**
|
|
32
|
+
* @description.zh 色盘渐变颜色列表
|
|
33
|
+
* @description.en Color plate gradient color list
|
|
34
|
+
*/
|
|
35
|
+
colorList?: {
|
|
36
|
+
offset: number;
|
|
37
|
+
color: string;
|
|
38
|
+
}[];
|
|
31
39
|
/**
|
|
32
40
|
* @description.zh 内部色环宽度
|
|
33
41
|
* @description.en The width of inner color ring
|
|
@@ -76,6 +84,20 @@ interface IProps {
|
|
|
76
84
|
```
|
|
77
85
|
|
|
78
86
|
```tsx
|
|
87
|
+
// Basic usage
|
|
88
|
+
import { LampCirclePicker } from '@ray-js/components-ty-lamp';
|
|
89
|
+
|
|
90
|
+
export default () => {
|
|
91
|
+
const [temperature, setTemperature] = useState(20);
|
|
92
|
+
const handleEnd = (v: number) => {
|
|
93
|
+
setTemperature(v);
|
|
94
|
+
};
|
|
95
|
+
return <LampCirclePicker value={temperature} innerRingRadius={80} onTouchEnd={handleEnd} />;
|
|
96
|
+
};
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
// Advanced usage
|
|
79
101
|
import { LampCirclePicker } from '@ray-js/components-ty-lamp';
|
|
80
102
|
|
|
81
103
|
export default () => {
|
|
@@ -86,7 +108,35 @@ export default () => {
|
|
|
86
108
|
const handleEnd = (v: number) => {
|
|
87
109
|
setTemperature(v);
|
|
88
110
|
};
|
|
89
|
-
return
|
|
111
|
+
return (
|
|
112
|
+
<LampCirclePicker
|
|
113
|
+
value={temperature}
|
|
114
|
+
innerRingRadius={80}
|
|
115
|
+
// custom color(optional)
|
|
116
|
+
colorList={[
|
|
117
|
+
{ offset: 0, color: '#ff0000' },
|
|
118
|
+
{ offset: 0.5, color: '#00ff00' },
|
|
119
|
+
{ offset: 1, color: '#0000ff' },
|
|
120
|
+
]}
|
|
121
|
+
style={{
|
|
122
|
+
background: '#222',
|
|
123
|
+
}}
|
|
124
|
+
innerBorderStyle={{
|
|
125
|
+
width: 2,
|
|
126
|
+
color: 'pink',
|
|
127
|
+
}}
|
|
128
|
+
descText="temp"
|
|
129
|
+
descStyle={{
|
|
130
|
+
color: 'red',
|
|
131
|
+
}}
|
|
132
|
+
titleStyle={{
|
|
133
|
+
color: 'blue',
|
|
134
|
+
}}
|
|
135
|
+
useEventChannel
|
|
136
|
+
onTouchMove={handleMove}
|
|
137
|
+
onTouchEnd={handleEnd}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
90
140
|
};
|
|
91
141
|
```
|
|
92
142
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// this file generate by @ray-js/build-plugin-router.
|
|
2
|
+
// do not modify this file!!!
|
|
3
|
+
export const thing = {
|
|
4
|
+
"window": {
|
|
5
|
+
"backgroundColor": "#f2f4f6",
|
|
6
|
+
"navigationBarTitleText": "涂鸦小程序示例",
|
|
7
|
+
"navigationBarBackgroundColor": "#f2f4f6",
|
|
8
|
+
"navigationBarTextStyle": "black"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"BaseKit": "2.0.5",
|
|
12
|
+
"DeviceKit": "2.0.5",
|
|
13
|
+
"MiniKit": "2.0.6",
|
|
14
|
+
"TYKit": "2.0.5"
|
|
15
|
+
},
|
|
16
|
+
"pages": [
|
|
17
|
+
"pages/index"
|
|
18
|
+
]
|
|
19
|
+
};
|
|
20
|
+
|
|
File without changes
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './app.less';
|
|
3
|
+
|
|
4
|
+
class App extends React.Component {
|
|
5
|
+
componentDidMount() {
|
|
6
|
+
console.info('app did mount');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
onLaunch(object: any) {
|
|
10
|
+
console.log('app onLaunch', object);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
onShow(object: any) {
|
|
14
|
+
console.log('app onShow', object);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
onHide(object: any) {
|
|
18
|
+
console.log('app onHide', object);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
onError(object: any) {
|
|
22
|
+
console.log('app onError', object);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
onPageNotFound(object: any) {
|
|
26
|
+
console.log('app onPageNotFound', object);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
onUnhandledRejection(object: any) {
|
|
30
|
+
console.log('app onUnhandledRejection', object);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
onThemeChange(object: any) {
|
|
34
|
+
console.log('app onThemeChange', object);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
render() {
|
|
38
|
+
return this.props.children;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default App;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { GlobalConfig } from '@ray-js/types';
|
|
2
|
+
|
|
3
|
+
export const wechat = {
|
|
4
|
+
window: {
|
|
5
|
+
backgroundColor: '#f2f4f6',
|
|
6
|
+
navigationBarTitleText: 'Ray 小程序示例',
|
|
7
|
+
navigationBarBackgroundColor: '#f2f4f6',
|
|
8
|
+
navigationBarTextStyle: 'black',
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const web = {
|
|
13
|
+
window: {
|
|
14
|
+
backgroundColor: '#f2f4f6',
|
|
15
|
+
navigationBarTitleText: 'Ray Web App',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const native = {
|
|
20
|
+
window: {
|
|
21
|
+
backgroundTextStyle: 'dark',
|
|
22
|
+
navigationBarBackgroundColor: '#fff',
|
|
23
|
+
navigationBarTitleText: '',
|
|
24
|
+
navigationBarTextStyle: 'black',
|
|
25
|
+
backgroundColorTop: 'red',
|
|
26
|
+
navigationStyle: 'custom',
|
|
27
|
+
},
|
|
28
|
+
pageWrapper: [],
|
|
29
|
+
|
|
30
|
+
dependencies: {
|
|
31
|
+
BaseKit: '2.0.5',
|
|
32
|
+
DeviceKit: '2.0.5',
|
|
33
|
+
MiniKit: '2.0.6',
|
|
34
|
+
TYKit: '2.0.5',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const tuya = {
|
|
39
|
+
window: {
|
|
40
|
+
backgroundColor: '#f2f4f6',
|
|
41
|
+
navigationBarTitleText: '涂鸦小程序示例',
|
|
42
|
+
navigationBarBackgroundColor: '#f2f4f6',
|
|
43
|
+
navigationBarTextStyle: 'black',
|
|
44
|
+
},
|
|
45
|
+
dependencies: {
|
|
46
|
+
BaseKit: '2.0.5',
|
|
47
|
+
DeviceKit: '2.0.5',
|
|
48
|
+
MiniKit: '2.0.6',
|
|
49
|
+
TYKit: '2.0.5',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const globalConfig: GlobalConfig = {
|
|
54
|
+
basename: '',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default globalConfig;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const web = {
|
|
2
|
+
backgroundColor: '#f2f4f6',
|
|
3
|
+
navigationBarTitleText: 'LampUnfilledCornerAnnulusPickerWhite',
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const wechat = {
|
|
7
|
+
backgroundColor: '#f2f4f6',
|
|
8
|
+
navigationBarTitleText: 'LampUnfilledCornerAnnulusPickerWhite',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const tuya = {
|
|
12
|
+
backgroundColor: '#f2f4f6',
|
|
13
|
+
navigationBarTitleText: 'LampUnfilledCornerAnnulusPickerWhite',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const native = {
|
|
17
|
+
backgroundColor: 'transparent',
|
|
18
|
+
isBleOfflineOverlay: false,
|
|
19
|
+
useSafeAreaView: true,
|
|
20
|
+
navigationBarTitleText: 'LampUnfilledCornerAnnulusPickerWhite',
|
|
21
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.view {
|
|
2
|
+
width: 100%;
|
|
3
|
+
flex: 1;
|
|
4
|
+
padding-bottom: 48rpx;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.demoBlock {
|
|
8
|
+
padding: 0 16px 20px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.demoBlockTitle {
|
|
12
|
+
position: relative;
|
|
13
|
+
padding: 40rpx 32rpx 32rpx 0px;
|
|
14
|
+
|
|
15
|
+
.demoBlockTitleText {
|
|
16
|
+
color: rgba(0, 0, 0, 0.45);
|
|
17
|
+
font-size: 28rpx;
|
|
18
|
+
padding-left: 16rpx;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.demoBlockTitleText::before {
|
|
22
|
+
position: absolute;
|
|
23
|
+
content: '';
|
|
24
|
+
top: calc(50% - 2rpx);
|
|
25
|
+
left: 0;
|
|
26
|
+
width: 4rpx;
|
|
27
|
+
height: 4rpx;
|
|
28
|
+
border-radius: 50%;
|
|
29
|
+
background-color: rgba(0, 0, 0, 0.45);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { View, Text } from '@ray-js/components';
|
|
3
|
+
import LampCirclePicker from '../../../src/index';
|
|
4
|
+
import DemoRjs from '../../../src/demoRjs';
|
|
5
|
+
|
|
6
|
+
import styles from './index.module.less';
|
|
7
|
+
|
|
8
|
+
const DemoBlock = ({ title, children }) => (
|
|
9
|
+
<View className={styles.demoBlock}>
|
|
10
|
+
<View className={styles.demoBlockTitle}>
|
|
11
|
+
<Text className={styles.demoBlockTitleText}>{title}</Text>
|
|
12
|
+
</View>
|
|
13
|
+
{children}
|
|
14
|
+
</View>
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export default function Home() {
|
|
18
|
+
const [temperature, setTemperature] = useState(20);
|
|
19
|
+
|
|
20
|
+
const handleMove = (v: number) => {
|
|
21
|
+
setTemperature(v);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const handleEnd = (v: number) => {
|
|
25
|
+
setTemperature(v);
|
|
26
|
+
};
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
setTemperature(500);
|
|
30
|
+
}, 3000);
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<View className={styles.view}>
|
|
35
|
+
<DemoBlock title="基础用法">
|
|
36
|
+
<LampCirclePicker
|
|
37
|
+
value={temperature}
|
|
38
|
+
// innerRingRadius={60}
|
|
39
|
+
// radius={80}
|
|
40
|
+
useEventChannel
|
|
41
|
+
onTouchMove={handleMove}
|
|
42
|
+
onTouchEnd={handleEnd}
|
|
43
|
+
/>
|
|
44
|
+
</DemoBlock>
|
|
45
|
+
<DemoBlock title="自定义色盘颜色">
|
|
46
|
+
<LampCirclePicker
|
|
47
|
+
value={temperature}
|
|
48
|
+
innerRingRadius={80}
|
|
49
|
+
showInnerCircle
|
|
50
|
+
colorList={[
|
|
51
|
+
{ offset: 0, color: '#ff0000' },
|
|
52
|
+
{ offset: 0.5, color: '#00ff00' },
|
|
53
|
+
{ offset: 1, color: '#0000ff' },
|
|
54
|
+
]}
|
|
55
|
+
style={{
|
|
56
|
+
background: '#222',
|
|
57
|
+
}}
|
|
58
|
+
innerBorderStyle={{
|
|
59
|
+
width: 2,
|
|
60
|
+
color: 'pink',
|
|
61
|
+
}}
|
|
62
|
+
descText="temp"
|
|
63
|
+
descStyle={{
|
|
64
|
+
color: 'red',
|
|
65
|
+
}}
|
|
66
|
+
titleStyle={{
|
|
67
|
+
color: 'blue',
|
|
68
|
+
}}
|
|
69
|
+
useEventChannel
|
|
70
|
+
onTouchMove={handleMove}
|
|
71
|
+
onTouchEnd={handleEnd}
|
|
72
|
+
/>
|
|
73
|
+
</DemoBlock>
|
|
74
|
+
|
|
75
|
+
<DemoRjs />
|
|
76
|
+
</View>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
File without changes
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var web = {
|
|
2
2
|
backgroundColor: '#f2f4f6',
|
|
3
3
|
navigationBarTitleText: ''
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export var wechat = {
|
|
6
6
|
backgroundColor: '#f2f4f6',
|
|
7
7
|
navigationBarTitleText: ''
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export var tuya = {
|
|
10
10
|
backgroundColor: '#f2f4f6',
|
|
11
11
|
navigationBarTitleText: ''
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export var native = {
|
|
14
14
|
backgroundColor: 'transparent',
|
|
15
15
|
isBleOfflineOverlay: false,
|
|
16
16
|
useSafeAreaView: true,
|
package/lib/component/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { IProps } from './props';
|
|
3
|
-
export default function RectColor(props: IProps):
|
|
3
|
+
export default function RectColor(props: IProps): JSX.Element;
|
package/lib/component/index.js
CHANGED
|
@@ -2,35 +2,27 @@
|
|
|
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)}`);
|
|
6
5
|
return /*#__PURE__*/React.createElement(RectColorPicker, {
|
|
7
|
-
canvasId: canvasIdRef.current,
|
|
8
6
|
radius: props.radius,
|
|
9
7
|
innerRingRadius: props.innerRingRadius,
|
|
10
8
|
value: props.value,
|
|
9
|
+
canvasId: props.canvasId,
|
|
10
|
+
colorList: props.colorList,
|
|
11
11
|
useEventChannel: props.useEventChannel,
|
|
12
12
|
eventChannelName: props.eventChannelName,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
detail
|
|
18
|
-
} = e;
|
|
19
|
-
const temp = Math.floor(detail);
|
|
13
|
+
bindstart: function onTouchStart(e) {
|
|
14
|
+
var detail = e.detail;
|
|
15
|
+
var temp = Math.floor(detail);
|
|
20
16
|
props.onTouchStart && props.onTouchStart(temp);
|
|
21
17
|
},
|
|
22
|
-
bindmove: e
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} = e;
|
|
26
|
-
const temp = Math.floor(detail);
|
|
18
|
+
bindmove: function onTouchMove(e) {
|
|
19
|
+
var detail = e.detail;
|
|
20
|
+
var temp = Math.floor(detail);
|
|
27
21
|
props.onTouchMove && props.onTouchMove(temp);
|
|
28
22
|
},
|
|
29
|
-
bindend: e
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} = e;
|
|
33
|
-
const temp = Math.floor(detail);
|
|
23
|
+
bindend: function onTouchEnd(e) {
|
|
24
|
+
var detail = e.detail;
|
|
25
|
+
var temp = Math.floor(detail);
|
|
34
26
|
props.onTouchEnd && props.onTouchEnd(temp);
|
|
35
27
|
}
|
|
36
28
|
});
|
package/lib/component/props.d.ts
CHANGED
|
@@ -23,6 +23,14 @@ export interface IProps {
|
|
|
23
23
|
* @default false
|
|
24
24
|
*/
|
|
25
25
|
useEventChannel?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* @description.zh 色盘渐变颜色列表
|
|
28
|
+
* @description.en Color plate gradient color list
|
|
29
|
+
*/
|
|
30
|
+
colorList?: {
|
|
31
|
+
offset: number;
|
|
32
|
+
color: string;
|
|
33
|
+
}[];
|
|
26
34
|
/**
|
|
27
35
|
* @description.zh 事件通道名称
|
|
28
36
|
* @description.en Event channel name
|
|
@@ -59,6 +67,5 @@ export interface IProps {
|
|
|
59
67
|
* @default null
|
|
60
68
|
*/
|
|
61
69
|
touchCircleLineWidth?: number;
|
|
62
|
-
canvasId?: string;
|
|
63
70
|
}
|
|
64
71
|
export declare const defaultProps: IProps;
|
package/lib/component/props.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var nilFn = function () {
|
|
3
|
+
return null;
|
|
4
|
+
};
|
|
5
|
+
export var defaultProps = {
|
|
4
6
|
value: 0,
|
|
5
7
|
innerRingRadius: 80,
|
|
6
8
|
radius: 140,
|
|
9
|
+
colorList: [{
|
|
10
|
+
offset: 0,
|
|
11
|
+
color: '#FFCD65'
|
|
12
|
+
}, {
|
|
13
|
+
offset: 0.7,
|
|
14
|
+
color: '#FEECAB'
|
|
15
|
+
}, {
|
|
16
|
+
offset: 1,
|
|
17
|
+
color: '#CEEDFF'
|
|
18
|
+
}],
|
|
7
19
|
useEventChannel: false,
|
|
8
20
|
eventChannelName: 'lampCirclePickerEventChannel',
|
|
9
21
|
onTouchStart: nilFn,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import "core-js/modules/es.number.constructor.js";
|
|
2
|
+
import "core-js/modules/es.json.stringify.js";
|
|
1
3
|
import Render from './index.rjs';
|
|
2
4
|
import { getSystemInfo } from '@ray-js/api';
|
|
3
|
-
|
|
5
|
+
var ETipRectPosition = {
|
|
4
6
|
LEFT: 'LEFT',
|
|
5
7
|
RIGHT: 'RIGHT'
|
|
6
8
|
};
|
|
@@ -8,6 +10,7 @@ const ETipRectPosition = {
|
|
|
8
10
|
// eslint-disable-next-line no-undef
|
|
9
11
|
Component({
|
|
10
12
|
properties: {
|
|
13
|
+
canvasId: String,
|
|
11
14
|
containerStyle: {
|
|
12
15
|
type: String,
|
|
13
16
|
value: 'position: relative;'
|
|
@@ -16,6 +19,10 @@ Component({
|
|
|
16
19
|
type: Number,
|
|
17
20
|
value: 100
|
|
18
21
|
},
|
|
22
|
+
colorList: {
|
|
23
|
+
type: Array,
|
|
24
|
+
value: []
|
|
25
|
+
},
|
|
19
26
|
innerRingRadius: {
|
|
20
27
|
type: Number,
|
|
21
28
|
value: 50
|
|
@@ -33,12 +40,11 @@ Component({
|
|
|
33
40
|
type: String,
|
|
34
41
|
value: 'lampCirclePickerEventChannel'
|
|
35
42
|
},
|
|
36
|
-
onTouchStart: Function,
|
|
37
|
-
onTouchMove: Function,
|
|
38
|
-
onTouchEnd: Function,
|
|
39
43
|
touchCircleStrokeStyle: String,
|
|
40
44
|
touchCircleLineWidth: Number,
|
|
41
|
-
|
|
45
|
+
onTouchStart: Function,
|
|
46
|
+
onTouchMove: Function,
|
|
47
|
+
onTouchEnd: Function
|
|
42
48
|
},
|
|
43
49
|
data: {
|
|
44
50
|
render: null,
|
|
@@ -48,7 +54,7 @@ Component({
|
|
|
48
54
|
tipRectPosition: ETipRectPosition.LEFT
|
|
49
55
|
},
|
|
50
56
|
observers: {
|
|
51
|
-
'value.**'(v) {
|
|
57
|
+
'value.**': function value(v) {
|
|
52
58
|
if (this.touchType === 'move') {
|
|
53
59
|
return;
|
|
54
60
|
}
|
|
@@ -59,85 +65,81 @@ Component({
|
|
|
59
65
|
}
|
|
60
66
|
},
|
|
61
67
|
lifetimes: {
|
|
62
|
-
attached() {
|
|
68
|
+
attached: function attached() {
|
|
63
69
|
this.render = new Render(this);
|
|
64
|
-
|
|
65
|
-
radius,
|
|
66
|
-
innerRingRadius
|
|
67
|
-
} = this.data;
|
|
70
|
+
var _this$data = this.data,
|
|
71
|
+
radius = _this$data.radius,
|
|
72
|
+
innerRingRadius = _this$data.innerRingRadius;
|
|
68
73
|
this.render._setCircles(radius, innerRingRadius);
|
|
69
74
|
},
|
|
70
|
-
ready() {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} = this.data;
|
|
75
|
+
ready: function ready() {
|
|
76
|
+
var _this = this;
|
|
77
|
+
var canvasId = this.data.canvasId;
|
|
74
78
|
this.initCanvas();
|
|
75
|
-
setTimeout(()
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
setTimeout(function () {
|
|
80
|
+
_this.initCanvas();
|
|
81
|
+
_this.render.checkIsRender(canvasId);
|
|
78
82
|
}, 300);
|
|
79
83
|
}
|
|
80
84
|
},
|
|
81
85
|
methods: {
|
|
82
|
-
getCanvas(canvas) {
|
|
86
|
+
getCanvas: function getCanvas(canvas) {
|
|
83
87
|
if (JSON.stringify(canvas) === '{}') {
|
|
84
88
|
this.initCanvas();
|
|
85
89
|
}
|
|
86
90
|
},
|
|
87
|
-
initCanvas() {
|
|
88
|
-
|
|
89
|
-
canvasId,
|
|
90
|
-
radius,
|
|
91
|
-
innerRingRadius,
|
|
92
|
-
value =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
initCanvas: function initCanvas() {
|
|
92
|
+
var _this$data2 = this.data,
|
|
93
|
+
canvasId = _this$data2.canvasId,
|
|
94
|
+
radius = _this$data2.radius,
|
|
95
|
+
innerRingRadius = _this$data2.innerRingRadius,
|
|
96
|
+
_this$data2$value = _this$data2.value,
|
|
97
|
+
value = _this$data2$value === void 0 ? 0 : _this$data2$value,
|
|
98
|
+
useEventChannel = _this$data2.useEventChannel,
|
|
99
|
+
eventChannelName = _this$data2.eventChannelName,
|
|
100
|
+
colorList = _this$data2.colorList,
|
|
101
|
+
touchCircleStrokeStyle = _this$data2.touchCircleStrokeStyle,
|
|
102
|
+
touchCircleLineWidth = _this$data2.touchCircleLineWidth;
|
|
103
|
+
var ratio = getSystemInfo().pixelRatio || 2;
|
|
99
104
|
canvasId && this.render.renderAnnulusColor(canvasId, radius, innerRingRadius, ratio, {
|
|
100
|
-
useEventChannel,
|
|
101
|
-
eventChannelName,
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
useEventChannel: useEventChannel,
|
|
106
|
+
eventChannelName: eventChannelName,
|
|
107
|
+
colorList: colorList,
|
|
108
|
+
touchCircleStrokeStyle: touchCircleStrokeStyle,
|
|
109
|
+
touchCircleLineWidth: touchCircleLineWidth
|
|
104
110
|
});
|
|
111
|
+
// this._updatePosByRgb(value);
|
|
105
112
|
this.lastValue = value;
|
|
106
113
|
},
|
|
107
|
-
initedCanvas() {
|
|
108
|
-
|
|
109
|
-
value = 0
|
|
110
|
-
} = this.data;
|
|
114
|
+
initedCanvas: function initedCanvas() {
|
|
115
|
+
var _this$data$value = this.data.value,
|
|
116
|
+
value = _this$data$value === void 0 ? 0 : _this$data$value;
|
|
111
117
|
this._updatePosByRgb(value);
|
|
112
118
|
},
|
|
113
|
-
_updatePosByRgb(value) {
|
|
119
|
+
_updatePosByRgb: function _updatePosByRgb(value) {
|
|
114
120
|
var _this$render;
|
|
115
121
|
if (value === undefined) {
|
|
116
122
|
return;
|
|
117
123
|
}
|
|
118
|
-
(_this$render = this.render) === null || _this$render === void 0
|
|
124
|
+
(_this$render = this.render) === null || _this$render === void 0 ? void 0 : _this$render._getAnglePositionByValue(value);
|
|
119
125
|
},
|
|
120
|
-
_getRgb(x, y) {
|
|
126
|
+
_getRgb: function _getRgb(x, y) {
|
|
121
127
|
var _this$render2;
|
|
122
|
-
(_this$render2 = this.render) === null || _this$render2 === void 0
|
|
128
|
+
(_this$render2 = this.render) === null || _this$render2 === void 0 ? void 0 : _this$render2.getAnnulusImageData(x, y);
|
|
123
129
|
},
|
|
124
|
-
_getAnnulusImageData(dataRes) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
touchType
|
|
128
|
-
} = dataRes;
|
|
130
|
+
_getAnnulusImageData: function _getAnnulusImageData(dataRes) {
|
|
131
|
+
var position = dataRes.position,
|
|
132
|
+
touchType = dataRes.touchType;
|
|
129
133
|
this.touchType = touchType;
|
|
130
|
-
|
|
134
|
+
var result = this._getLengthByAnglePosition(position.x, position.y);
|
|
131
135
|
this.lastValue = result;
|
|
132
136
|
this.triggerEvent(touchType, result);
|
|
133
137
|
},
|
|
134
|
-
_getLengthByAnglePosition(x, y) {
|
|
135
|
-
|
|
136
|
-
radius
|
|
137
|
-
} = this.data;
|
|
138
|
+
_getLengthByAnglePosition: function _getLengthByAnglePosition(x, y) {
|
|
139
|
+
var radius = this.data.radius;
|
|
138
140
|
var radian = Math.atan2(y - radius, x - radius); // 弧度
|
|
139
141
|
var angle = radian * (180 / Math.PI); // 角度
|
|
140
|
-
|
|
142
|
+
var angleData = 0;
|
|
141
143
|
if (+angle > 135 && +angle <= 180) {
|
|
142
144
|
angleData = angle - 135;
|
|
143
145
|
} else if (angle > -180 && angle <= 0) {
|
|
@@ -145,7 +147,7 @@ Component({
|
|
|
145
147
|
} else if (angle > 0 && angle <= 45) {
|
|
146
148
|
angleData = 225 + angle;
|
|
147
149
|
}
|
|
148
|
-
|
|
150
|
+
var result = Math.round(angleData / 270 * 1000);
|
|
149
151
|
return result;
|
|
150
152
|
}
|
|
151
153
|
}
|
|
@@ -39,17 +39,15 @@ export default Render({
|
|
|
39
39
|
endAngle
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
let grd = ctx.
|
|
43
|
-
0,
|
|
42
|
+
let grd = ctx.createConicGradient(
|
|
43
|
+
startAngle - Math.PI * 0.1,
|
|
44
44
|
radius * 2,
|
|
45
45
|
radius * 2,
|
|
46
|
-
radius * 4,
|
|
47
|
-
radius * 2,
|
|
48
|
-
radius * 2
|
|
49
46
|
);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
|
|
48
|
+
options.colorList?.forEach((item) => {
|
|
49
|
+
grd.addColorStop(item.offset, item.color);
|
|
50
|
+
})
|
|
53
51
|
|
|
54
52
|
//设定曲线粗细度
|
|
55
53
|
ctx.lineWidth = (radius - innerRingRadius) * 2;
|
|
@@ -116,7 +114,7 @@ export default Render({
|
|
|
116
114
|
ctx.shadowColor = 'rgba(0, 0, 0, 0.2)';
|
|
117
115
|
ctx.fillStyle = 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
|
|
118
116
|
ctx.fill();
|
|
119
|
-
|
|
117
|
+
|
|
120
118
|
if(this.touchCircleStrokeStyle) {
|
|
121
119
|
ctx.shadowColor = this.touchCircleStrokeStyle;
|
|
122
120
|
}
|
|
@@ -192,13 +190,14 @@ export default Render({
|
|
|
192
190
|
return { x: thumbPositionX, y: thumbPositionY };
|
|
193
191
|
}
|
|
194
192
|
if (angle > 115 && angle <= 135) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
193
|
+
// 修正在范围外的点击区域导致的取色问题
|
|
194
|
+
const _angle = 135;
|
|
195
|
+
const realAngle = ((180 - _angle) / 180) * Math.PI;
|
|
196
|
+
|
|
197
|
+
const thumbPositionY = radius + (innerRingRadius + (radius - innerRingRadius) / 2) * Math.sin(realAngle);
|
|
198
|
+
|
|
199
|
+
const thumbPositionX = radius - (innerRingRadius + (radius - innerRingRadius) / 2) * Math.cos(realAngle);
|
|
200
|
+
|
|
202
201
|
return { x: thumbPositionX, y: thumbPositionY };
|
|
203
202
|
}
|
|
204
203
|
},
|
package/lib/demoRjs/index.js
CHANGED
package/lib/demoRjs/index.rjs
CHANGED
|
@@ -2,7 +2,8 @@ export default Render({
|
|
|
2
2
|
renderChannel() {
|
|
3
3
|
try {
|
|
4
4
|
const eventChannelName = 'lampCirclePickerEventChannel';
|
|
5
|
-
this.instance.
|
|
5
|
+
console.log(this.instance, 'this.instancethis.instance');
|
|
6
|
+
this.instance.eventChannel.on(eventChannelName, e => {
|
|
6
7
|
console.warn('eventChannel get', e);
|
|
7
8
|
});
|
|
8
9
|
} catch (e) {
|
package/lib/i18n/index.d.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
import { kit } from '@ray-js/panel-sdk';
|
|
2
|
-
declare const _default: kit.I18N
|
|
3
|
-
en: {
|
|
4
|
-
temperature: string;
|
|
5
|
-
};
|
|
6
|
-
zh: {
|
|
7
|
-
temperature: string;
|
|
8
|
-
};
|
|
9
|
-
}, {
|
|
10
|
-
temperature: string;
|
|
11
|
-
} | {
|
|
12
|
-
temperature: string;
|
|
13
|
-
}>;
|
|
2
|
+
declare const _default: kit.I18N;
|
|
14
3
|
export default _default;
|
package/lib/i18n/index.js
CHANGED
package/lib/index.config.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var web = {
|
|
2
2
|
backgroundColor: '#f2f4f6',
|
|
3
3
|
navigationBarTitleText: ''
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export var wechat = {
|
|
6
6
|
backgroundColor: '#f2f4f6',
|
|
7
7
|
navigationBarTitleText: ''
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export var tuya = {
|
|
10
10
|
backgroundColor: '#f2f4f6',
|
|
11
11
|
navigationBarTitleText: ''
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export var native = {
|
|
14
14
|
backgroundColor: 'transparent',
|
|
15
15
|
isBleOfflineOverlay: false,
|
|
16
16
|
useSafeAreaView: true,
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { IProps } from './props';
|
|
3
3
|
declare const LampCirclePicker: {
|
|
4
|
-
(props: IProps):
|
|
4
|
+
(props: IProps): JSX.Element;
|
|
5
5
|
defaultProps: {
|
|
6
6
|
radius: number;
|
|
7
7
|
innerRingRadius: number;
|
|
8
|
+
colorList: {
|
|
9
|
+
offset: number;
|
|
10
|
+
color: string;
|
|
11
|
+
}[];
|
|
8
12
|
useEventChannel: boolean;
|
|
9
13
|
eventChannelName: string;
|
|
10
14
|
titleStyle: {};
|
package/lib/index.js
CHANGED
|
@@ -1,56 +1,77 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import "core-js/modules/es.array.concat.js";
|
|
3
|
+
import "core-js/modules/es.array.slice.js";
|
|
4
|
+
import "core-js/modules/es.array.map.js";
|
|
5
|
+
import "core-js/modules/es.math.trunc.js";
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
import { View, Text } from '@ray-js/components';
|
|
3
8
|
import clsx from 'clsx';
|
|
4
|
-
import res from './res';
|
|
5
9
|
import Strings from './i18n';
|
|
6
10
|
import AnnulusPickerColor from './component';
|
|
7
11
|
import styled from './index.module.less';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
var LampCirclePicker = function (props) {
|
|
13
|
+
var value = props.value,
|
|
14
|
+
temperature = props.temperature,
|
|
15
|
+
radius = props.radius,
|
|
16
|
+
innerRingRadius = props.innerRingRadius,
|
|
17
|
+
colorList = props.colorList,
|
|
18
|
+
useEventChannel = props.useEventChannel,
|
|
19
|
+
eventChannelName = props.eventChannelName,
|
|
20
|
+
titleStyle = props.titleStyle,
|
|
21
|
+
descStyle = props.descStyle,
|
|
22
|
+
descText = props.descText,
|
|
23
|
+
_props$showInnerCircl = props.showInnerCircle,
|
|
24
|
+
showInnerCircle = _props$showInnerCircl === void 0 ? true : _props$showInnerCircl,
|
|
25
|
+
touchCircleLineWidth = props.touchCircleLineWidth,
|
|
26
|
+
touchCircleStrokeStyle = props.touchCircleStrokeStyle,
|
|
27
|
+
_props$innerBorderSty = props.innerBorderStyle,
|
|
28
|
+
innerBorderStyle = _props$innerBorderSty === void 0 ? {
|
|
29
|
+
width: 5,
|
|
30
|
+
color: '#eee'
|
|
31
|
+
} : _props$innerBorderSty,
|
|
32
|
+
style = props.style,
|
|
33
|
+
onTouchStart = props.onTouchStart,
|
|
34
|
+
onTouchMove = props.onTouchMove,
|
|
35
|
+
onTouchEnd = props.onTouchEnd;
|
|
36
|
+
var innerImgRadius = innerRingRadius * 4 * 0.8;
|
|
37
|
+
var _value = value !== null && value !== void 0 ? value : temperature;
|
|
38
|
+
var canvasId = useMemo(function () {
|
|
39
|
+
return "canvasId_".concat(String(+new Date()).slice(-3), "_").concat(String(Math.random()).slice(-3));
|
|
40
|
+
}, []);
|
|
41
|
+
var borderWidth = innerBorderStyle === null || innerBorderStyle === void 0 ? void 0 : innerBorderStyle.width;
|
|
42
|
+
var borderColor = innerBorderStyle === null || innerBorderStyle === void 0 ? void 0 : innerBorderStyle.color;
|
|
43
|
+
var _colorList = useMemo(function () {
|
|
44
|
+
return colorList.map(function (i) {
|
|
45
|
+
return _objectSpread(_objectSpread({}, i), {}, {
|
|
46
|
+
offset: i.offset * 0.75
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}, [colorList]);
|
|
32
50
|
return /*#__PURE__*/React.createElement(View, {
|
|
33
51
|
className: clsx(styled.container, styled.flexCenter),
|
|
34
52
|
style: style
|
|
35
53
|
}, /*#__PURE__*/React.createElement(AnnulusPickerColor, {
|
|
54
|
+
canvasId: canvasId,
|
|
36
55
|
value: _value,
|
|
37
56
|
radius: radius,
|
|
57
|
+
touchCircleLineWidth: touchCircleLineWidth,
|
|
58
|
+
touchCircleStrokeStyle: touchCircleStrokeStyle,
|
|
38
59
|
innerRingRadius: innerRingRadius,
|
|
60
|
+
colorList: _colorList,
|
|
39
61
|
useEventChannel: useEventChannel || false,
|
|
40
62
|
eventChannelName: eventChannelName,
|
|
41
|
-
touchCircleLineWidth: touchCircleLineWidth,
|
|
42
|
-
touchCircleStrokeStyle: touchCircleStrokeStyle,
|
|
43
63
|
onTouchStart: onTouchStart,
|
|
44
64
|
onTouchMove: onTouchMove,
|
|
45
65
|
onTouchEnd: onTouchEnd
|
|
46
66
|
}), /*#__PURE__*/React.createElement(View, {
|
|
47
67
|
className: clsx(styled.innerBox, styled.flexCenter)
|
|
48
|
-
}, showInnerCircle && /*#__PURE__*/React.createElement(
|
|
49
|
-
src: ring,
|
|
68
|
+
}, showInnerCircle && /*#__PURE__*/React.createElement(View, {
|
|
50
69
|
className: styled.ringIcon,
|
|
51
70
|
style: {
|
|
52
71
|
width: innerImgRadius,
|
|
53
|
-
height: innerImgRadius
|
|
72
|
+
height: innerImgRadius,
|
|
73
|
+
borderRadius: innerImgRadius,
|
|
74
|
+
border: "".concat(borderWidth, "px solid ").concat(borderColor)
|
|
54
75
|
}
|
|
55
76
|
}), /*#__PURE__*/React.createElement(View, {
|
|
56
77
|
className: clsx(styled.textBox, styled.flexCenter)
|
|
@@ -60,12 +81,24 @@ const LampCirclePicker = props => {
|
|
|
60
81
|
}, Math.trunc(_value / 10), "%"), /*#__PURE__*/React.createElement(Text, {
|
|
61
82
|
className: styled.desc,
|
|
62
83
|
style: descStyle
|
|
63
|
-
},
|
|
84
|
+
}, descText !== null && descText !== void 0 ? descText : Strings.getLang('temperature')))));
|
|
85
|
+
};
|
|
86
|
+
var nilFn = function () {
|
|
87
|
+
return null;
|
|
64
88
|
};
|
|
65
|
-
const nilFn = () => null;
|
|
66
89
|
LampCirclePicker.defaultProps = {
|
|
67
90
|
radius: 140,
|
|
68
91
|
innerRingRadius: 80,
|
|
92
|
+
colorList: [{
|
|
93
|
+
offset: 0,
|
|
94
|
+
color: '#FFCD65'
|
|
95
|
+
}, {
|
|
96
|
+
offset: 0.5,
|
|
97
|
+
color: '#FEECAB'
|
|
98
|
+
}, {
|
|
99
|
+
offset: 1,
|
|
100
|
+
color: '#CEEDFF'
|
|
101
|
+
}],
|
|
69
102
|
useEventChannel: false,
|
|
70
103
|
eventChannelName: 'lampCirclePickerEventChannel',
|
|
71
104
|
titleStyle: {},
|
package/lib/props.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export interface IProps {
|
|
3
|
+
/**
|
|
4
|
+
* @description.en colorList
|
|
5
|
+
* @description.zh 色盘渐变颜色列表
|
|
6
|
+
*/
|
|
7
|
+
colorList?: {
|
|
8
|
+
offset: number;
|
|
9
|
+
color: string;
|
|
10
|
+
}[];
|
|
3
11
|
/**
|
|
4
12
|
* @description.zh 默认数值
|
|
5
13
|
* @description.en default value
|
|
@@ -66,6 +74,7 @@ export interface IProps {
|
|
|
66
74
|
* @default null
|
|
67
75
|
*/
|
|
68
76
|
titleStyle?: React.CSSProperties;
|
|
77
|
+
descText?: string;
|
|
69
78
|
/**
|
|
70
79
|
* @description.en descStyle
|
|
71
80
|
* @description.zh 描述样式
|
|
@@ -78,21 +87,25 @@ export interface IProps {
|
|
|
78
87
|
* @default null
|
|
79
88
|
*/
|
|
80
89
|
style?: React.CSSProperties;
|
|
90
|
+
/**
|
|
91
|
+
* @description.en innerBorderStyle
|
|
92
|
+
* @description.zh 内部圆环描边
|
|
93
|
+
* @default null
|
|
94
|
+
*/
|
|
95
|
+
innerBorderStyle?: {
|
|
96
|
+
color: string;
|
|
97
|
+
width: number;
|
|
98
|
+
};
|
|
81
99
|
/**
|
|
82
100
|
* @description.en touchCircleStrokeStyle
|
|
83
|
-
* @description.zh
|
|
101
|
+
* @description.zh 触摸圆环描边颜色与 ctx.shadowColor 值相同
|
|
84
102
|
* @default null
|
|
85
103
|
*/
|
|
86
104
|
touchCircleStrokeStyle?: string;
|
|
87
105
|
/**
|
|
88
106
|
* @description.en touchCircleLineWidth
|
|
89
|
-
* @description.zh
|
|
107
|
+
* @description.zh 触摸圆环描边宽度与 ctx.shadowBlur 值相同
|
|
90
108
|
* @default null
|
|
91
109
|
*/
|
|
92
110
|
touchCircleLineWidth?: number;
|
|
93
|
-
/**
|
|
94
|
-
* @description.en desc
|
|
95
|
-
* @description.zh 中间文案
|
|
96
|
-
*/
|
|
97
|
-
desc?: string;
|
|
98
111
|
}
|
package/lib/res/index.js
CHANGED
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
import { utils } from '@ray-js/panel-sdk';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
hsv2rgb
|
|
5
|
-
} = utils;
|
|
2
|
+
var rgb2hsv = utils.rgb2hsv,
|
|
3
|
+
hsv2rgb = utils.hsv2rgb;
|
|
6
4
|
/* eslint-disable no-param-reassign */
|
|
7
|
-
|
|
5
|
+
var rgbToHsl = function (r, g, b) {
|
|
8
6
|
r /= 255;
|
|
9
7
|
g /= 255;
|
|
10
8
|
b /= 255;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
var max = Math.max(r, g, b);
|
|
10
|
+
var min = Math.min(r, g, b);
|
|
11
|
+
var h;
|
|
12
|
+
var s;
|
|
13
|
+
var l = (max + min) / 2;
|
|
16
14
|
if (max === min) {
|
|
17
15
|
h = 0;
|
|
18
16
|
s = 0; // achromatic
|
|
19
17
|
} else {
|
|
20
|
-
|
|
18
|
+
var d = max - min;
|
|
21
19
|
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
22
20
|
switch (max) {
|
|
23
21
|
case r:
|
|
@@ -36,8 +34,8 @@ const rgbToHsl = (r, g, b) => {
|
|
|
36
34
|
}
|
|
37
35
|
return {
|
|
38
36
|
h: h * 360,
|
|
39
|
-
s,
|
|
40
|
-
l
|
|
37
|
+
s: s,
|
|
38
|
+
l: l
|
|
41
39
|
};
|
|
42
40
|
};
|
|
43
41
|
export { rgbToHsl, rgb2hsv, hsv2rgb };
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/lamp-circle-picker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9-beta-1",
|
|
4
4
|
"description": "照明缺角色环",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
7
|
-
"lib"
|
|
7
|
+
"lib",
|
|
8
|
+
"example/src"
|
|
8
9
|
],
|
|
9
10
|
"license": "MIT",
|
|
10
11
|
"types": "lib/index.d.ts",
|
|
@@ -18,13 +19,13 @@
|
|
|
18
19
|
"scripts": {
|
|
19
20
|
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
|
20
21
|
"build": "ray build --type=component",
|
|
21
|
-
"watch": "ray start --type=component
|
|
22
|
+
"watch": "ray start --type=component",
|
|
22
23
|
"build:tuya": "ray build ./example --target=tuya",
|
|
23
24
|
"build:wechat": "ray build ./example --target=wechat",
|
|
24
25
|
"build:web": "ray build ./example --target=web",
|
|
25
26
|
"build:native": "ray build ./example --target=native",
|
|
26
27
|
"start:native": "ray start ./example -t native --verbose",
|
|
27
|
-
"start:tuya": "ray start ./example",
|
|
28
|
+
"start:tuya": "ray start ./example -t tuya --verbose",
|
|
28
29
|
"start:wechat": "ray start ./example -t wechat --verbose",
|
|
29
30
|
"start:web": "ray start ./example -t web",
|
|
30
31
|
"prepublishOnly": "yarn build",
|
|
@@ -36,11 +37,14 @@
|
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@commitlint/cli": "^7.2.1",
|
|
38
39
|
"@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/
|
|
40
|
+
"@ray-js/babel-preset-standard": "^0.6.14",
|
|
41
|
+
"@ray-js/cli": "0.6.16",
|
|
42
|
+
"@ray-js/ray": "^0.6.14",
|
|
43
|
+
"@ray-js/components": "^0.6.14",
|
|
44
|
+
"@ray-js/framework": "^0.6.14",
|
|
45
|
+
"@ray-js/panel-sdk": "^1.1.4",
|
|
46
|
+
"@ray-js/rn-transformer-helper": "^0.5.5",
|
|
47
|
+
"@ray-js/types": "^0.6.14",
|
|
44
48
|
"@types/node": "^17.0.43",
|
|
45
49
|
"core-js": "^3.19.1",
|
|
46
50
|
"eslint-config-tuya-panel": "^0.4.1",
|
|
@@ -48,6 +52,10 @@
|
|
|
48
52
|
"lint-staged": "^10.2.11",
|
|
49
53
|
"standard-version": "9.3.2"
|
|
50
54
|
},
|
|
55
|
+
"resolutions": {
|
|
56
|
+
"shell-quote": "~1.7.3",
|
|
57
|
+
"follow-redirects": "~1.15.6"
|
|
58
|
+
},
|
|
51
59
|
"husky": {
|
|
52
60
|
"hooks": {
|
|
53
61
|
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js",
|