@ray-js/lamp-circle-picker 1.0.10-beta-1 → 1.0.11-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 CHANGED
@@ -87,13 +87,13 @@ interface IProps {
87
87
  /**
88
88
  * @description.en touchCircleStrokeStyle
89
89
  * @description.zh 触摸圆环描边颜色与 ctx.shadowColor 值相同
90
- * @default null
90
+ * @default ''
91
91
  */
92
92
  touchCircleStrokeStyle?: string;
93
93
  /**
94
94
  * @description.en touchCircleLineWidth
95
95
  * @description.zh 触摸圆环描边宽度与 ctx.shadowBlur 值相同
96
- * @default null
96
+ * @default 0
97
97
  */
98
98
  touchCircleLineWidth?: number;
99
99
  /**
@@ -0,0 +1,3 @@
1
+ {
2
+ "component": true
3
+ }
@@ -0,0 +1,15 @@
1
+ // src/demoRjs/index.rjs
2
+ var demoRjs_default = Render({
3
+ renderChannel() {
4
+ try {
5
+ const eventChannelName = 'lampCirclePickerEventChannel';
6
+ this.instance.eventChannel.on(eventChannelName, e => {
7
+ console.warn('eventChannel get', e);
8
+ });
9
+ } catch (e) {
10
+ console.warn(e);
11
+ }
12
+ },
13
+ });
14
+ export { demoRjs_default as default };
15
+ //# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2RlbW9SanMvaW5kZXgucmpzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyJleHBvcnQgZGVmYXVsdCBSZW5kZXIoe1xuICByZW5kZXJDaGFubmVsKCkge1xuICAgIHRyeSB7XG4gICAgICBjb25zdCBldmVudENoYW5uZWxOYW1lID0gJ2xhbXBDaXJjbGVQaWNrZXJFdmVudENoYW5uZWwnO1xuICAgICAgY29uc29sZS5sb2codGhpcy5pbnN0YW5jZSwgJ3RoaXMuaW5zdGFuY2V0aGlzLmluc3RhbmNlJyk7XG4gICAgICB0aGlzLmluc3RhbmNlLmV2ZW50Q2hhbm5lbC5vbihldmVudENoYW5uZWxOYW1lLCBlID0+IHtcbiAgICAgICAgY29uc29sZS53YXJuKCdldmVudENoYW5uZWwgZ2V0JywgZSk7XG4gICAgICB9KTtcbiAgICB9IGNhdGNoIChlKSB7XG4gICAgICBjb25zb2xlLndhcm4oZSk7XG4gICAgfVxuICB9LFxufSk7XG4iXSwKICAibWFwcGluZ3MiOiAiO0FBQUEsSUFBTyxrQkFBUSxPQUFPO0FBQUEsRUFDcEIsZ0JBQWdCO0FBQ2QsUUFBSTtBQUNGLFlBQU0sbUJBQW1CO0FBQ3pCLGNBQVEsSUFBSSxLQUFLLFVBQVUsNEJBQTRCO0FBQ3ZELFdBQUssU0FBUyxhQUFhLEdBQUcsa0JBQWtCLE9BQUs7QUFDbkQsZ0JBQVEsS0FBSyxvQkFBb0IsQ0FBQztBQUFBLE1BQ3BDLENBQUM7QUFBQSxJQUNILFNBQVMsR0FBRztBQUNWLGNBQVEsS0FBSyxDQUFDO0FBQUEsSUFDaEI7QUFBQSxFQUNGO0FBQ0YsQ0FBQzsiLAogICJuYW1lcyI6IFtdCn0K
@@ -0,0 +1,4 @@
1
+ <view
2
+ class="container"
3
+ >
4
+ </view>
@@ -35,13 +35,21 @@ export default function Home() {
35
35
  <DemoBlock title="基础用法">
36
36
  <LampCirclePicker
37
37
  value={temperature}
38
- // innerRingRadius={60}
39
- // radius={80}
40
38
  useEventChannel
41
39
  onTouchMove={handleMove}
42
40
  onTouchEnd={handleEnd}
43
41
  />
44
42
  </DemoBlock>
43
+
44
+ <DemoBlock title="HideThumb">
45
+ <LampCirclePicker
46
+ value={temperature}
47
+ useEventChannel
48
+ hideThumb
49
+ onTouchMove={handleMove}
50
+ onTouchEnd={handleEnd}
51
+ />
52
+ </DemoBlock>
45
53
  <DemoBlock title="自定义色盘颜色">
46
54
  <LampCirclePicker
47
55
  value={temperature}
@@ -53,7 +61,7 @@ export default function Home() {
53
61
  { offset: 1, color: '#0000ff' },
54
62
  ]}
55
63
  style={{
56
- background: '#222',
64
+ background: '#ddd',
57
65
  }}
58
66
  innerBorderStyle={{
59
67
  width: 2,
@@ -1,16 +1,16 @@
1
- export var web = {
1
+ export const web = {
2
2
  backgroundColor: '#f2f4f6',
3
3
  navigationBarTitleText: ''
4
4
  };
5
- export var wechat = {
5
+ export const wechat = {
6
6
  backgroundColor: '#f2f4f6',
7
7
  navigationBarTitleText: ''
8
8
  };
9
- export var tuya = {
9
+ export const tuya = {
10
10
  backgroundColor: '#f2f4f6',
11
11
  navigationBarTitleText: ''
12
12
  };
13
- export var native = {
13
+ export const native = {
14
14
  backgroundColor: 'transparent',
15
15
  isBleOfflineOverlay: false,
16
16
  useSafeAreaView: true,
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { IProps } from './props';
3
- export default function RectColor(props: IProps): JSX.Element;
3
+ export default function RectColor(props: IProps): React.JSX.Element;
@@ -1,30 +1,42 @@
1
1
  /* eslint-disable prettier/prettier */
2
2
  import React from 'react';
3
3
  import RectColorPicker from './rjs';
4
+ import { useStdPx2Adapt } from '../hooks';
4
5
  export default function RectColor(props) {
6
+ var _props$hideThumb, _props$colorList;
7
+ const radius = useStdPx2Adapt(props.radius);
8
+ const innerRingRadius = useStdPx2Adapt(props.innerRingRadius);
9
+ const touchCircleLineWidth = useStdPx2Adapt(props.touchCircleLineWidth);
5
10
  return /*#__PURE__*/React.createElement(RectColorPicker, {
6
- radius: props.radius,
7
- innerRingRadius: props.innerRingRadius,
11
+ radius: radius,
12
+ innerRingRadius: innerRingRadius,
8
13
  value: props.value,
14
+ hideThumb: (_props$hideThumb = props.hideThumb) !== null && _props$hideThumb !== void 0 ? _props$hideThumb : false,
9
15
  canvasId: props.canvasId,
10
- colorList: props.colorList,
16
+ colorList: (_props$colorList = props.colorList) !== null && _props$colorList !== void 0 ? _props$colorList : [],
11
17
  useEventChannel: props.useEventChannel,
12
18
  eventChannelName: props.eventChannelName,
13
19
  touchCircleStrokeStyle: props.touchCircleStrokeStyle,
14
- touchCircleLineWidth: props.touchCircleLineWidth,
15
- bindstart: function onTouchStart(e) {
16
- var detail = e.detail;
17
- var temp = Math.floor(detail);
20
+ touchCircleLineWidth: touchCircleLineWidth,
21
+ bindstart: e => {
22
+ const {
23
+ detail
24
+ } = e;
25
+ const temp = Math.floor(detail);
18
26
  props.onTouchStart && props.onTouchStart(temp);
19
27
  },
20
- bindmove: function onTouchMove(e) {
21
- var detail = e.detail;
22
- var temp = Math.floor(detail);
28
+ bindmove: e => {
29
+ const {
30
+ detail
31
+ } = e;
32
+ const temp = Math.floor(detail);
23
33
  props.onTouchMove && props.onTouchMove(temp);
24
34
  },
25
- bindend: function onTouchEnd(e) {
26
- var detail = e.detail;
27
- var temp = Math.floor(detail);
35
+ bindend: e => {
36
+ const {
37
+ detail
38
+ } = e;
39
+ const temp = Math.floor(detail);
28
40
  props.onTouchEnd && props.onTouchEnd(temp);
29
41
  }
30
42
  });
@@ -1,10 +1,22 @@
1
1
  export interface IProps {
2
+ /**
3
+ * @description.zh canvasId
4
+ * @description.en canvasId
5
+ * @default
6
+ */
7
+ canvasId: string;
2
8
  /**
3
9
  * @description.zh 默认数值
4
10
  * @description.en default value
5
11
  * @default
6
12
  */
7
13
  value: number;
14
+ /**
15
+ * @description.zh 是否隐藏拖拽圆环
16
+ * @description.en Whether to hide the drag ring
17
+ * @default false
18
+ */
19
+ hideThumb: boolean;
8
20
  /**
9
21
  * @description.zh 内部色环宽度
10
22
  * @description.en Drag the color ring width
@@ -58,13 +70,13 @@ export interface IProps {
58
70
  /**
59
71
  * @description.en touchCircleStrokeStyle
60
72
  * @description.zh 触摸圆环描边颜色
61
- * @default null
73
+ * @default ''
62
74
  */
63
75
  touchCircleStrokeStyle?: string;
64
76
  /**
65
77
  * @description.en touchCircleLineWidth
66
78
  * @description.zh 触摸圆环描边宽度
67
- * @default null
79
+ * @default 0
68
80
  */
69
81
  touchCircleLineWidth?: number;
70
82
  }
@@ -1,8 +1,6 @@
1
1
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
2
- var nilFn = function () {
3
- return null;
4
- };
5
- export var defaultProps = {
2
+ const nilFn = () => null;
3
+ export const defaultProps = {
6
4
  value: 0,
7
5
  innerRingRadius: 80,
8
6
  radius: 140,
@@ -1,8 +1,5 @@
1
- import "core-js/modules/es.number.constructor.js";
2
- import "core-js/modules/es.json.stringify.js";
3
1
  import Render from './index.rjs';
4
- import { getSystemInfo } from '@ray-js/api';
5
- var ETipRectPosition = {
2
+ const ETipRectPosition = {
6
3
  LEFT: 'LEFT',
7
4
  RIGHT: 'RIGHT'
8
5
  };
@@ -11,6 +8,10 @@ var ETipRectPosition = {
11
8
  Component({
12
9
  properties: {
13
10
  canvasId: String,
11
+ hideThumb: {
12
+ type: Boolean,
13
+ value: false
14
+ },
14
15
  containerStyle: {
15
16
  type: String,
16
17
  value: 'position: relative;'
@@ -54,7 +55,7 @@ Component({
54
55
  tipRectPosition: ETipRectPosition.LEFT
55
56
  },
56
57
  observers: {
57
- 'value.**': function value(v) {
58
+ 'value.**'(v) {
58
59
  if (this.touchType === 'move') {
59
60
  return;
60
61
  }
@@ -65,81 +66,88 @@ Component({
65
66
  }
66
67
  },
67
68
  lifetimes: {
68
- attached: function attached() {
69
+ attached() {
69
70
  this.render = new Render(this);
70
- var _this$data = this.data,
71
- radius = _this$data.radius,
72
- innerRingRadius = _this$data.innerRingRadius;
71
+ const {
72
+ radius,
73
+ innerRingRadius
74
+ } = this.data;
73
75
  this.render._setCircles(radius, innerRingRadius);
74
76
  },
75
- ready: function ready() {
76
- var _this = this;
77
- var canvasId = this.data.canvasId;
77
+ ready() {
78
+ const {
79
+ canvasId
80
+ } = this.data;
78
81
  this.initCanvas();
79
- setTimeout(function () {
80
- _this.initCanvas();
81
- _this.render.checkIsRender(canvasId);
82
+ setTimeout(() => {
83
+ this.initCanvas();
84
+ this.render.checkIsRender(canvasId);
82
85
  }, 300);
83
86
  }
84
87
  },
85
88
  methods: {
86
- getCanvas: function getCanvas(canvas) {
89
+ getCanvas(canvas) {
87
90
  if (JSON.stringify(canvas) === '{}') {
88
91
  this.initCanvas();
89
92
  }
90
93
  },
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;
104
- canvasId && this.render.renderAnnulusColor(canvasId, radius, innerRingRadius, ratio, {
105
- useEventChannel: useEventChannel,
106
- eventChannelName: eventChannelName,
107
- colorList: colorList,
108
- touchCircleStrokeStyle: touchCircleStrokeStyle,
109
- touchCircleLineWidth: touchCircleLineWidth
94
+ initCanvas() {
95
+ const {
96
+ canvasId,
97
+ radius,
98
+ innerRingRadius,
99
+ value = 0,
100
+ hideThumb = false,
101
+ useEventChannel,
102
+ eventChannelName,
103
+ colorList,
104
+ touchCircleStrokeStyle = '',
105
+ touchCircleLineWidth = 0
106
+ } = this.data;
107
+ canvasId && this.render.renderAnnulusColor(canvasId, radius, innerRingRadius, value, {
108
+ useEventChannel,
109
+ eventChannelName,
110
+ hideThumb,
111
+ colorList,
112
+ touchCircleStrokeStyle,
113
+ touchCircleLineWidth
110
114
  });
111
- // this._updatePosByRgb(value);
112
115
  this.lastValue = value;
113
116
  },
114
- initedCanvas: function initedCanvas() {
115
- var _this$data$value = this.data.value,
116
- value = _this$data$value === void 0 ? 0 : _this$data$value;
117
- this._updatePosByRgb(value);
117
+ initedCanvas() {
118
+ const {
119
+ value
120
+ } = this.data;
121
+ value !== undefined && this._updatePosByRgb(value);
118
122
  },
119
- _updatePosByRgb: function _updatePosByRgb(value) {
123
+ _updatePosByRgb(value) {
120
124
  var _this$render;
121
125
  if (value === undefined) {
122
126
  return;
123
127
  }
124
- (_this$render = this.render) === null || _this$render === void 0 ? void 0 : _this$render._getAnglePositionByValue(value);
128
+ (_this$render = this.render) === null || _this$render === void 0 || _this$render._getAnglePositionByValue(value);
125
129
  },
126
- _getRgb: function _getRgb(x, y) {
130
+ _getRgb(x, y) {
127
131
  var _this$render2;
128
- (_this$render2 = this.render) === null || _this$render2 === void 0 ? void 0 : _this$render2.getAnnulusImageData(x, y);
132
+ (_this$render2 = this.render) === null || _this$render2 === void 0 || _this$render2.getAnnulusImageData(x, y);
129
133
  },
130
- _getAnnulusImageData: function _getAnnulusImageData(dataRes) {
131
- var position = dataRes.position,
132
- touchType = dataRes.touchType;
134
+ _getAnnulusImageData(dataRes) {
135
+ const {
136
+ position,
137
+ touchType
138
+ } = dataRes;
133
139
  this.touchType = touchType;
134
- var result = this._getLengthByAnglePosition(position.x, position.y);
140
+ const result = this._getLengthByAnglePosition(position.x, position.y);
135
141
  this.lastValue = result;
136
142
  this.triggerEvent(touchType, result);
137
143
  },
138
- _getLengthByAnglePosition: function _getLengthByAnglePosition(x, y) {
139
- var radius = this.data.radius;
144
+ _getLengthByAnglePosition(x, y) {
145
+ const {
146
+ radius
147
+ } = this.data;
140
148
  var radian = Math.atan2(y - radius, x - radius); // 弧度
141
149
  var angle = radian * (180 / Math.PI); // 角度
142
- var angleData = 0;
150
+ let angleData = 0;
143
151
  if (+angle > 135 && +angle <= 180) {
144
152
  angleData = angle - 135;
145
153
  } else if (angle > -180 && angle <= 0) {
@@ -147,7 +155,7 @@ Component({
147
155
  } else if (angle > 0 && angle <= 45) {
148
156
  angleData = 225 + angle;
149
157
  }
150
- var result = Math.round(angleData / 270 * 1000);
158
+ const result = Math.round(angleData / 270 * 1000);
151
159
  return result;
152
160
  }
153
161
  }
@@ -7,9 +7,10 @@ export default Render({
7
7
  // 环形色盘
8
8
  async renderAnnulusColor(id, radius, innerRingRadius, temp = 0, options = {}) {
9
9
  let canvas = null;
10
- const { touchCircleStrokeStyle, touchCircleLineWidth } = options || {};
10
+ const { touchCircleStrokeStyle = '', touchCircleLineWidth = 0, hideThumb = false } = options || {};
11
11
  this.touchCircleStrokeStyle = touchCircleStrokeStyle;
12
12
  this.touchCircleLineWidth = touchCircleLineWidth;
13
+ this.hideThumb = hideThumb;
13
14
 
14
15
  try {
15
16
  canvas = await getCanvasById(id);
@@ -59,10 +60,13 @@ export default Render({
59
60
  canvas.style.width = `${radius * 2}px`;
60
61
  canvas.style.height = `${radius * 2}px`;
61
62
  this.annulusContext = ctx;
62
- this.renderAnnulusColorThumb(id, temp);
63
+ !this.hideThumb && this.renderAnnulusColorThumb(id, temp);
63
64
  this.callMethod('initedCanvas', {});
64
65
  },
65
66
  async renderAnnulusColorThumb(id, temp = 0) {
67
+ if (!this.hideThumb) {
68
+ return;
69
+ }
66
70
  if (!this.canvasThumb) {
67
71
  this.canvasThumb = await getCanvasById(`${id}_thumb`);
68
72
  this.canvasThumbCtx = this.canvasThumb.getContext('2d');
@@ -94,6 +98,9 @@ export default Render({
94
98
  this.updateThumbPosition(x, y, { r: data[0], g: data[1], b: data[2] });
95
99
  },
96
100
  updateThumbPosition(x, y, rgb) {
101
+ if (!this.hideThumb) {
102
+ return;
103
+ }
97
104
  if (!this.canvasThumb) {
98
105
  console.error('canvasThumb not found');
99
106
  return;
@@ -223,6 +230,10 @@ export default Render({
223
230
  this._getRgb(validXY.x, validXY.y);
224
231
  },
225
232
  handleCanvasMoveEvent(evt) {
233
+ if (!this.hideThumb) {
234
+ return;
235
+ }
236
+
226
237
  this.touchType = 'move';
227
238
  const { changedTouches } = evt;
228
239
  const [point] = changedTouches;
@@ -234,11 +245,17 @@ export default Render({
234
245
  this._getRgb(validXY.x, validXY.y);
235
246
  },
236
247
  addEventListeners() {
248
+ if (!this.hideThumb) {
249
+ return;
250
+ }
237
251
  this.canvasThumb.addEventListener('touchstart', this.handleCanvasStartEvent, false);
238
252
  this.canvasThumb.addEventListener('touchmove', this.handleCanvasMoveEvent, false);
239
253
  this.canvasThumb.addEventListener('touchend', this.handleCanvasEndEvent, false);
240
254
  },
241
255
  removeEventListeners() {
256
+ if (!this.hideThumb) {
257
+ return;
258
+ }
242
259
  this.canvasThumb.removeEventListener('touchstart', this.handleCanvasStartEvent);
243
260
  this.canvasThumb.removeEventListener('touchmove', this.handleCanvasMoveEvent);
244
261
  this.canvasThumb.removeEventListener('touchend', this.handleCanvasEndEvent);
@@ -2,7 +2,7 @@
2
2
  import Render from './index.rjs';
3
3
  Component({
4
4
  lifetimes: {
5
- ready: function ready() {
5
+ ready() {
6
6
  this.render = new Render(this);
7
7
  this.render.renderChannel();
8
8
  }
@@ -2,7 +2,6 @@ export default Render({
2
2
  renderChannel() {
3
3
  try {
4
4
  const eventChannelName = 'lampCirclePickerEventChannel';
5
- console.log(this.instance, 'this.instancethis.instance');
6
5
  this.instance.eventChannel.on(eventChannelName, e => {
7
6
  console.warn('eventChannel get', e);
8
7
  });
package/lib/hooks.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description 将标准像素转换为适配后的像素
3
+ * @param stdPx 标准像素
4
+ * @param toFixed 保留小数点后几位
5
+ * @returns 适配后的像素
6
+ */
7
+ export declare const useStdPx2Adapt: (stdPx: number, toFixed?: number) => number;
package/lib/hooks.js ADDED
@@ -0,0 +1,15 @@
1
+ import { useMemo } from 'react';
2
+ import { getSystemCacheInfo } from './utils';
3
+ /**
4
+ * @description 将标准像素转换为适配后的像素
5
+ * @param stdPx 标准像素
6
+ * @param toFixed 保留小数点后几位
7
+ * @returns 适配后的像素
8
+ */
9
+ export const useStdPx2Adapt = function (stdPx) {
10
+ let toFixed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
11
+ const {
12
+ screenWidth
13
+ } = useMemo(() => getSystemCacheInfo(), [stdPx]);
14
+ return +(stdPx * (screenWidth / 375)).toFixed(toFixed) || stdPx;
15
+ };
@@ -1,3 +1,14 @@
1
1
  import { kit } from '@ray-js/panel-sdk';
2
- declare const _default: kit.I18N;
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
+ }>;
3
14
  export default _default;
package/lib/i18n/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { kit } from '@ray-js/panel-sdk';
2
2
  import Strings from './strings';
3
- var I18N = kit.I18N;
3
+ const {
4
+ I18N
5
+ } = kit;
4
6
  export default new I18N(Strings);
@@ -1,16 +1,16 @@
1
- export var web = {
1
+ export const web = {
2
2
  backgroundColor: '#f2f4f6',
3
3
  navigationBarTitleText: ''
4
4
  };
5
- export var wechat = {
5
+ export const wechat = {
6
6
  backgroundColor: '#f2f4f6',
7
7
  navigationBarTitleText: ''
8
8
  };
9
- export var tuya = {
9
+ export const tuya = {
10
10
  backgroundColor: '#f2f4f6',
11
11
  navigationBarTitleText: ''
12
12
  };
13
- export var native = {
13
+ export const native = {
14
14
  backgroundColor: 'transparent',
15
15
  isBleOfflineOverlay: false,
16
16
  useSafeAreaView: true,
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { IProps } from './props';
3
3
  declare const LampCirclePicker: {
4
- (props: IProps): JSX.Element;
4
+ (props: IProps): React.JSX.Element;
5
5
  defaultProps: {
6
6
  radius: number;
7
7
  innerRingRadius: number;
package/lib/index.js CHANGED
@@ -1,47 +1,45 @@
1
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";
2
+ import "core-js/modules/esnext.iterator.map.js";
6
3
  import React, { useMemo } from 'react';
7
4
  import { View, Text } from '@ray-js/components';
8
5
  import clsx from 'clsx';
9
6
  import Strings from './i18n';
10
7
  import AnnulusPickerColor from './component';
11
8
  import styled from './index.module.less';
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 ? {
9
+ const LampCirclePicker = props => {
10
+ const {
11
+ value,
12
+ hideThumb,
13
+ temperature,
14
+ radius,
15
+ innerRingRadius,
16
+ colorList,
17
+ useEventChannel,
18
+ eventChannelName,
19
+ titleStyle,
20
+ descStyle,
21
+ descText,
22
+ showInnerCircle = true,
23
+ touchCircleLineWidth = 0,
24
+ touchCircleStrokeStyle = '',
25
+ innerBorderStyle = {
29
26
  width: 5,
30
27
  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));
28
+ },
29
+ style,
30
+ onTouchStart,
31
+ onTouchMove,
32
+ onTouchEnd
33
+ } = props;
34
+ const innerImgRadius = innerRingRadius * 4 * 0.8;
35
+ const _value = value !== null && value !== void 0 ? value : temperature;
36
+ const canvasId = useMemo(() => {
37
+ return `canvasId_${String(+new Date()).slice(-3)}_${String(Math.random()).slice(-3)}`;
40
38
  }, []);
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) {
39
+ const borderWidth = innerBorderStyle === null || innerBorderStyle === void 0 ? void 0 : innerBorderStyle.width;
40
+ const borderColor = innerBorderStyle === null || innerBorderStyle === void 0 ? void 0 : innerBorderStyle.color;
41
+ const _colorList = useMemo(() => {
42
+ return colorList.map(i => {
45
43
  return _objectSpread(_objectSpread({}, i), {}, {
46
44
  offset: i.offset * 0.75
47
45
  });
@@ -52,6 +50,7 @@ var LampCirclePicker = function (props) {
52
50
  style: style
53
51
  }, /*#__PURE__*/React.createElement(AnnulusPickerColor, {
54
52
  canvasId: canvasId,
53
+ hideThumb: hideThumb,
55
54
  value: _value,
56
55
  radius: radius,
57
56
  touchCircleLineWidth: touchCircleLineWidth,
@@ -71,7 +70,7 @@ var LampCirclePicker = function (props) {
71
70
  width: innerImgRadius,
72
71
  height: innerImgRadius,
73
72
  borderRadius: innerImgRadius,
74
- border: "".concat(borderWidth, "px solid ").concat(borderColor)
73
+ border: `${borderWidth}px solid ${borderColor}`
75
74
  }
76
75
  }), /*#__PURE__*/React.createElement(View, {
77
76
  className: clsx(styled.textBox, styled.flexCenter)
@@ -83,9 +82,7 @@ var LampCirclePicker = function (props) {
83
82
  style: descStyle
84
83
  }, descText !== null && descText !== void 0 ? descText : Strings.getLang('temperature')))));
85
84
  };
86
- var nilFn = function () {
87
- return null;
88
- };
85
+ const nilFn = () => null;
89
86
  LampCirclePicker.defaultProps = {
90
87
  radius: 140,
91
88
  innerRingRadius: 80,
package/lib/props.d.ts CHANGED
@@ -14,6 +14,12 @@ export interface IProps {
14
14
  * @default
15
15
  */
16
16
  value: number;
17
+ /**
18
+ * @description.zh 是否隐藏拖拽圆环
19
+ * @description.en Whether to hide the drag ring
20
+ * @default false
21
+ */
22
+ hideThumb: boolean;
17
23
  /**
18
24
  * @description.en temperature
19
25
  * @description.zh 色温
@@ -99,13 +105,13 @@ export interface IProps {
99
105
  /**
100
106
  * @description.en touchCircleStrokeStyle
101
107
  * @description.zh 触摸圆环描边颜色与 ctx.shadowColor 值相同
102
- * @default null
108
+ * @default '
103
109
  */
104
110
  touchCircleStrokeStyle?: string;
105
111
  /**
106
112
  * @description.en touchCircleLineWidth
107
113
  * @description.zh 触摸圆环描边宽度与 ctx.shadowBlur 值相同
108
- * @default null
114
+ * @default 0
109
115
  */
110
116
  touchCircleLineWidth?: number;
111
117
  }
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: ring,
5
- colorBg: colorBg
4
+ ring,
5
+ colorBg
6
6
  };
@@ -1,8 +1,12 @@
1
1
  declare const rgb2hsv: any, hsv2rgb: any;
2
- declare type HSL = {
2
+ type HSL = {
3
3
  h: number;
4
4
  s: number;
5
5
  l: number;
6
6
  };
7
7
  declare const rgbToHsl: (r: number, g: number, b: number) => HSL;
8
+ export declare const getSystemCacheInfo: () => {
9
+ screenWidth: number;
10
+ screenHeight: number;
11
+ };
8
12
  export { rgbToHsl, rgb2hsv, hsv2rgb };
@@ -1,21 +1,24 @@
1
1
  import { utils } from '@ray-js/panel-sdk';
2
- var rgb2hsv = utils.rgb2hsv,
3
- hsv2rgb = utils.hsv2rgb;
2
+ import { getSystemInfoSync } from '@ray-js/ray';
3
+ const {
4
+ rgb2hsv,
5
+ hsv2rgb
6
+ } = utils;
4
7
  /* eslint-disable no-param-reassign */
5
- var rgbToHsl = function (r, g, b) {
8
+ const rgbToHsl = (r, g, b) => {
6
9
  r /= 255;
7
10
  g /= 255;
8
11
  b /= 255;
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;
12
+ const max = Math.max(r, g, b);
13
+ const min = Math.min(r, g, b);
14
+ let h;
15
+ let s;
16
+ const l = (max + min) / 2;
14
17
  if (max === min) {
15
18
  h = 0;
16
19
  s = 0; // achromatic
17
20
  } else {
18
- var d = max - min;
21
+ const d = max - min;
19
22
  s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
20
23
  switch (max) {
21
24
  case r:
@@ -34,8 +37,15 @@ var rgbToHsl = function (r, g, b) {
34
37
  }
35
38
  return {
36
39
  h: h * 360,
37
- s: s,
38
- l: l
40
+ s,
41
+ l
39
42
  };
40
43
  };
44
+ let __systemCacheInfo = null;
45
+ export const getSystemCacheInfo = () => {
46
+ if (!__systemCacheInfo) {
47
+ __systemCacheInfo = getSystemInfoSync();
48
+ }
49
+ return __systemCacheInfo;
50
+ };
41
51
  export { rgbToHsl, rgb2hsv, hsv2rgb };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-circle-picker",
3
- "version": "1.0.10-beta-1",
3
+ "version": "1.0.11-beta-1",
4
4
  "description": "照明缺角色环",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -18,16 +18,9 @@
18
18
  ],
19
19
  "scripts": {
20
20
  "lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
21
+ "dev": "yarn start:tuya",
21
22
  "build": "ray build --type=component",
22
- "watch": "ray start --type=component",
23
- "build:tuya": "ray build ./example --target=tuya",
24
- "build:wechat": "ray build ./example --target=wechat",
25
- "build:web": "ray build ./example --target=web",
26
- "build:native": "ray build ./example --target=native",
27
- "start:native": "ray start ./example -t native --verbose",
28
- "start:tuya": "ray start ./example -t tuya --verbose",
29
- "start:wechat": "ray start ./example -t wechat --verbose",
30
- "start:web": "ray start ./example -t web",
23
+ "start:tuya": "ray start ./example",
31
24
  "prepublishOnly": "yarn build",
32
25
  "release-it": "standard-version"
33
26
  },
@@ -37,12 +30,10 @@
37
30
  "devDependencies": {
38
31
  "@commitlint/cli": "^7.2.1",
39
32
  "@commitlint/config-conventional": "^9.0.1",
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",
33
+ "@ray-js/babel-preset-standard": "^1.5.45",
34
+ "@ray-js/cli": "^1.5.45",
35
+ "@ray-js/panel-sdk": "^1.13.1",
36
+ "@ray-js/ray": "^1.5.45",
46
37
  "@ray-js/rn-transformer-helper": "^0.5.5",
47
38
  "@ray-js/types": "^0.6.14",
48
39
  "@types/node": "^17.0.43",