@ray-js/lamp-circle-picker 1.0.8-beta-2 → 1.0.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/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 <LampCirclePicker value={temperature} onTouchMove={handleMove} onTouchEnd={handleEnd} />;
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
@@ -0,0 +1,11 @@
1
+ import { Routes } from '@ray-js/types';
2
+
3
+ export const routes: Routes = [
4
+ {
5
+ route: '/',
6
+ path: '/pages/index',
7
+ name: 'Page',
8
+ },
9
+ ];
10
+
11
+ export const tabBar = {};
@@ -0,0 +1,7 @@
1
+ @primary-color: #ff592a;
2
+
3
+ // font
4
+ @font-gray-0: #040a23;
5
+ @font-gray-1: #656979;
6
+ @font-gray-2: #9aa0b1;
7
+ @font-gray-3: #e1e5ec;
@@ -1,16 +1,16 @@
1
- export const web = {
1
+ export var web = {
2
2
  backgroundColor: '#f2f4f6',
3
3
  navigationBarTitleText: ''
4
4
  };
5
- export const wechat = {
5
+ export var wechat = {
6
6
  backgroundColor: '#f2f4f6',
7
7
  navigationBarTitleText: ''
8
8
  };
9
- export const tuya = {
9
+ export var tuya = {
10
10
  backgroundColor: '#f2f4f6',
11
11
  navigationBarTitleText: ''
12
12
  };
13
- export const native = {
13
+ export var native = {
14
14
  backgroundColor: 'transparent',
15
15
  isBleOfflineOverlay: false,
16
16
  useSafeAreaView: true,
@@ -1,3 +1,3 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { IProps } from './props';
3
- export default function RectColor(props: IProps): React.JSX.Element;
3
+ export default function RectColor(props: IProps): JSX.Element;
@@ -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
- touchCircleStrokeStyle: props.touchCircleStrokeStyle,
14
- touchCircleLineWidth: props.touchCircleLineWidth,
15
- bindstart: e => {
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
- const {
24
- detail
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
- const {
31
- detail
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
  });
@@ -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;
@@ -1,9 +1,21 @@
1
1
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
2
- const nilFn = () => null;
3
- export const defaultProps = {
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
- const ETipRectPosition = {
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
- canvasId: String
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
- const {
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
- const {
72
- canvasId
73
- } = this.data;
75
+ ready: function ready() {
76
+ var _this = this;
77
+ var canvasId = this.data.canvasId;
74
78
  this.initCanvas();
75
- setTimeout(() => {
76
- this.initCanvas();
77
- this.render.checkIsRender(canvasId);
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
- const {
89
- canvasId,
90
- radius,
91
- innerRingRadius,
92
- value = 0,
93
- useEventChannel,
94
- eventChannelName,
95
- touchCircleStrokeStyle,
96
- touchCircleLineWidth
97
- } = this.data;
98
- const ratio = getSystemInfo().pixelRatio || 2;
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
- touchCircleStrokeStyle,
103
- touchCircleLineWidth
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
- const {
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 || _this$render._getAnglePositionByValue(value);
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 || _this$render2.getAnnulusImageData(x, y);
128
+ (_this$render2 = this.render) === null || _this$render2 === void 0 ? void 0 : _this$render2.getAnnulusImageData(x, y);
123
129
  },
124
- _getAnnulusImageData(dataRes) {
125
- const {
126
- position,
127
- touchType
128
- } = dataRes;
130
+ _getAnnulusImageData: function _getAnnulusImageData(dataRes) {
131
+ var position = dataRes.position,
132
+ touchType = dataRes.touchType;
129
133
  this.touchType = touchType;
130
- const result = this._getLengthByAnglePosition(position.x, position.y);
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
- const {
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
- let angleData = 0;
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
- const result = Math.round(angleData / 270 * 1000);
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.createRadialGradient(
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
- grd.addColorStop(0, '#FFCD65');
51
- grd.addColorStop(0.7, '#FEECAB');
52
- grd.addColorStop(1, '#CEEDFF');
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
- const _angle = 135;
197
- const realAngle = ((180 - _angle) / 180) * Math.PI;
198
- const thumbPositionY =
199
- radius + (innerRingRadius + (radius - innerRingRadius) / 2) * Math.sin(realAngle);
200
- const thumbPositionX =
201
- radius - (innerRingRadius + (radius - innerRingRadius) / 2) * Math.cos(realAngle);
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
  },
@@ -2,10 +2,8 @@
2
2
  import Render from './index.rjs';
3
3
  Component({
4
4
  lifetimes: {
5
- created() {
5
+ ready: function ready() {
6
6
  this.render = new Render(this);
7
- },
8
- ready() {
9
7
  this.render.renderChannel();
10
8
  }
11
9
  }
@@ -2,7 +2,8 @@ export default Render({
2
2
  renderChannel() {
3
3
  try {
4
4
  const eventChannelName = 'lampCirclePickerEventChannel';
5
- this.instance.eventChannel.on(eventChannelName, (e) => {
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) {
@@ -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
@@ -1,6 +1,4 @@
1
1
  import { kit } from '@ray-js/panel-sdk';
2
2
  import Strings from './strings';
3
- const {
4
- I18N
5
- } = kit;
3
+ var I18N = kit.I18N;
6
4
  export default new I18N(Strings);
@@ -1,16 +1,16 @@
1
- export const web = {
1
+ export var web = {
2
2
  backgroundColor: '#f2f4f6',
3
3
  navigationBarTitleText: ''
4
4
  };
5
- export const wechat = {
5
+ export var wechat = {
6
6
  backgroundColor: '#f2f4f6',
7
7
  navigationBarTitleText: ''
8
8
  };
9
- export const tuya = {
9
+ export var tuya = {
10
10
  backgroundColor: '#f2f4f6',
11
11
  navigationBarTitleText: ''
12
12
  };
13
- export const native = {
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
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { IProps } from './props';
3
3
  declare const LampCirclePicker: {
4
- (props: IProps): React.JSX.Element;
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 React from 'react';
2
- import { View, Image, Text } from '@ray-js/components';
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
- const {
9
- ring
10
- } = res;
11
- const LampCirclePicker = props => {
12
- const {
13
- value,
14
- temperature,
15
- radius,
16
- innerRingRadius,
17
- useEventChannel,
18
- eventChannelName,
19
- titleStyle,
20
- descStyle,
21
- style,
22
- onTouchStart,
23
- desc,
24
- onTouchMove,
25
- onTouchEnd,
26
- showInnerCircle = true,
27
- touchCircleLineWidth,
28
- touchCircleStrokeStyle
29
- } = props;
30
- const innerImgRadius = innerRingRadius * 4 * 0.8;
31
- const _value = value !== null && value !== void 0 ? value : temperature;
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(Image, {
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
- }, desc || Strings.getLang('temperature')))));
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
- /// <reference types="react" />
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
@@ -1,6 +1,6 @@
1
1
  import ring from './ring.png';
2
2
  import colorBg from './colorBg.png';
3
3
  export default {
4
- ring,
5
- colorBg
4
+ ring: ring,
5
+ colorBg: colorBg
6
6
  };
@@ -1,5 +1,5 @@
1
1
  declare const rgb2hsv: any, hsv2rgb: any;
2
- type HSL = {
2
+ declare type HSL = {
3
3
  h: number;
4
4
  s: number;
5
5
  l: number;
@@ -1,23 +1,21 @@
1
1
  import { utils } from '@ray-js/panel-sdk';
2
- const {
3
- rgb2hsv,
4
- hsv2rgb
5
- } = utils;
2
+ var rgb2hsv = utils.rgb2hsv,
3
+ hsv2rgb = utils.hsv2rgb;
6
4
  /* eslint-disable no-param-reassign */
7
- const rgbToHsl = (r, g, b) => {
5
+ var rgbToHsl = function (r, g, b) {
8
6
  r /= 255;
9
7
  g /= 255;
10
8
  b /= 255;
11
- const max = Math.max(r, g, b);
12
- const min = Math.min(r, g, b);
13
- let h;
14
- let s;
15
- const l = (max + min) / 2;
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
- const d = max - min;
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.8-beta-2",
3
+ "version": "1.0.9",
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 --output ./example/src/lib",
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.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",
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",