@ray-js/lamp-circle-picker 1.0.7-beta-1 → 1.0.8-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.
@@ -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
@@ -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;
@@ -8,5 +8,7 @@ export const defaultProps = {
8
8
  eventChannelName: 'lampCirclePickerEventChannel',
9
9
  onTouchStart: nilFn,
10
10
  onTouchMove: nilFn,
11
- onTouchEnd: nilFn
11
+ onTouchEnd: nilFn,
12
+ touchCircleStrokeStyle: null,
13
+ touchCircleLineWidth: null
12
14
  };
@@ -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 ? void 0 : _this$render._getAnglePositionByValue(value);
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 ? void 0 : _this$render2.getAnnulusImageData(x, y);
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
- interface IProps {
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
@@ -21,7 +21,10 @@ const LampCirclePicker = props => {
21
21
  style,
22
22
  onTouchStart,
23
23
  onTouchMove,
24
- onTouchEnd
24
+ onTouchEnd,
25
+ showInnerCircle = true,
26
+ touchCircleLineWidth,
27
+ touchCircleStrokeStyle
25
28
  } = props;
26
29
  const innerImgRadius = innerRingRadius * 4 * 0.8;
27
30
  const _value = value !== null && value !== void 0 ? value : temperature;
@@ -34,12 +37,14 @@ const LampCirclePicker = props => {
34
37
  innerRingRadius: innerRingRadius,
35
38
  useEventChannel: useEventChannel || false,
36
39
  eventChannelName: eventChannelName,
40
+ touchCircleLineWidth: touchCircleLineWidth,
41
+ touchCircleStrokeStyle: touchCircleStrokeStyle,
37
42
  onTouchStart: onTouchStart,
38
43
  onTouchMove: onTouchMove,
39
44
  onTouchEnd: onTouchEnd
40
45
  }), /*#__PURE__*/React.createElement(View, {
41
46
  className: clsx(styled.innerBox, styled.flexCenter)
42
- }, /*#__PURE__*/React.createElement(Image, {
47
+ }, showInnerCircle && /*#__PURE__*/React.createElement(Image, {
43
48
  src: ring,
44
49
  className: styled.ringIcon,
45
50
  style: {
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,52 @@ 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;
38
93
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-circle-picker",
3
- "version": "1.0.7-beta-1",
3
+ "version": "1.0.8-beta-1",
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 -t tuya --verbose",
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.6.14",
40
- "@ray-js/cli": "0.6.16",
41
- "@ray-js/ray": "^0.6.14",
42
- "@ray-js/components": "^0.6.14",
43
- "@ray-js/framework": "^0.6.14",
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",