@ray-js/lamp-saturation-slider 1.1.2-beta-1 → 1.1.4-beta-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- export var tuya = {
1
+ export const tuya = {
2
2
  backgroundColor: '#f2f4f6',
3
3
  navigationBarTitleText: 'Ray 跨端组件'
4
4
  };
5
- export var wechat = {
5
+ export const wechat = {
6
6
  backgroundColor: '#f2f4f6',
7
7
  navigationBarTitleText: 'Ray 跨端组件'
8
8
  };
9
- export var native = {
9
+ export const native = {
10
10
  backgroundColor: 'transparent',
11
11
  isBleOfflineOverlay: false,
12
12
  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
- declare function SaturationSlider(props: IProps): JSX.Element;
4
- declare namespace SaturationSlider {
3
+ declare function LampSaturationSlider(props: IProps): React.JSX.Element;
4
+ declare namespace LampSaturationSlider {
5
5
  var defaultProps: IProps;
6
6
  }
7
- export default SaturationSlider;
7
+ export default LampSaturationSlider;
package/lib/index.js CHANGED
@@ -1,55 +1,47 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import "core-js/modules/es.array.concat.js";
4
- import "core-js/modules/es.array.slice.js";
5
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
6
3
  import React, { useRef, useState, useEffect, useMemo } from 'react';
7
4
  import { View } from '@ray-js/components';
5
+ import Slider from '@ray-js/components-ty-slider/lib/slider';
8
6
  import { hsvToRgb } from './utils';
9
- import Slider from './components/slider';
10
7
  import { defaultProps } from './props';
11
- function SaturationSlider(props) {
12
- var preSaturation = useRef(-1);
13
- var lastSaturation = useRef(null);
14
- var timer = useRef(null);
15
- var timer1 = useRef(null);
16
- var saturation = props.value,
17
- hue = props.hue,
18
- _props$trackStyle = props.trackStyle,
19
- trackStyle = _props$trackStyle === void 0 ? {} : _props$trackStyle,
20
- _props$thumbStyle = props.thumbStyle,
21
- thumbStyle = _props$thumbStyle === void 0 ? {} : _props$thumbStyle,
22
- disable = props.disable,
23
- closed = props.closed,
24
- onTouchStart = props.onTouchStart,
25
- onTouchMove = props.onTouchMove,
26
- onTouchEnd = props.onTouchEnd;
27
- var startRefValue = useRef(-1);
28
- var endRefValue = useRef(-1);
29
- var instanceId = useRef("Color_".concat(String(+new Date()).slice(-4), "_").concat(String(Math.random()).slice(-2)));
30
- var _useState = useState(-1),
31
- _useState2 = _slicedToArray(_useState, 2),
32
- controllerSaturation = _useState2[0],
33
- setControllerSaturation = _useState2[1];
34
- useEffect(function () {
8
+ function LampSaturationSlider(props) {
9
+ const preSaturation = useRef(-1);
10
+ const lastSaturation = useRef(null);
11
+ const timer = useRef(null);
12
+ const timer1 = useRef(null);
13
+ const {
14
+ value: saturation,
15
+ hue,
16
+ trackStyle = {},
17
+ thumbStyle = {},
18
+ disable,
19
+ closed,
20
+ onTouchStart,
21
+ onTouchMove,
22
+ onTouchEnd
23
+ } = props;
24
+ const startRefValue = useRef(-1);
25
+ const endRefValue = useRef(-1);
26
+ const instanceId = useRef(`Color_${String(+new Date()).slice(-4)}_${String(Math.random()).slice(-2)}`);
27
+ const [controllerSaturation, setControllerSaturation] = useState(-1);
28
+ useEffect(() => {
35
29
  if (preSaturation.current !== saturation) {
36
30
  setControllerSaturation(saturation);
37
31
  }
38
32
  }, [saturation]);
39
- var _useMemo = useMemo(function () {
40
- return hsvToRgb(hue, 1000, 1000);
41
- }, [hue]),
42
- r = _useMemo.r,
43
- g = _useMemo.g,
44
- b = _useMemo.b;
45
- var bg = "linear-gradient(to right, rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", 0.01) 0%, rgba(").concat(r, ", ").concat(g, ", ").concat(b, ", 1) 100%)");
33
+ const {
34
+ r,
35
+ g,
36
+ b
37
+ } = useMemo(() => hsvToRgb(hue, 1000, 1000), [hue]);
46
38
  return /*#__PURE__*/React.createElement(View, {
47
39
  style: {
48
40
  position: 'relative',
49
41
  background: '#fff',
50
- width: "".concat(646, "rpx"),
51
- height: "".concat(88, "rpx"),
52
- borderRadius: "".concat(28, "rpx")
42
+ width: `${646}rpx`,
43
+ height: `${88}rpx`,
44
+ borderRadius: `${28}rpx`
53
45
  }
54
46
  }, /*#__PURE__*/React.createElement(Slider, {
55
47
  instanceId: instanceId.current,
@@ -60,9 +52,10 @@ function SaturationSlider(props) {
60
52
  disable: disable,
61
53
  end: controllerSaturation,
62
54
  step: 1,
63
- maxRangeOffset: 20,
64
- bindstart: function handleTouchStart(_ref) {
65
- var detail = _ref.detail;
55
+ bindstart: _ref => {
56
+ let {
57
+ detail
58
+ } = _ref;
66
59
  if (!onTouchStart || disable) {
67
60
  return;
68
61
  }
@@ -72,8 +65,10 @@ function SaturationSlider(props) {
72
65
  onTouchStart && onTouchStart(detail.end);
73
66
  startRefValue.current = detail.end;
74
67
  },
75
- bindmove: function handTouchMove(_ref2) {
76
- var detail = _ref2.detail;
68
+ bindmove: _ref2 => {
69
+ let {
70
+ detail
71
+ } = _ref2;
77
72
  if (!onTouchMove || disable) {
78
73
  return;
79
74
  }
@@ -84,24 +79,29 @@ function SaturationSlider(props) {
84
79
  if (timer.current) {
85
80
  return;
86
81
  }
82
+
83
+ // 移动更新的频率
84
+
87
85
  // 移动结束后多久进行更新
88
86
 
89
- timer.current = setTimeout(function () {
87
+ timer.current = setTimeout(() => {
90
88
  onTouchMove && onTouchMove(detail.end);
91
89
  preSaturation.current = detail.end;
92
90
  clearTimeout(timer.current);
93
91
  timer.current = null;
94
92
  clearTimeout(timer1.current);
95
93
  timer1.current = null;
96
- timer1.current = setTimeout(function () {
94
+ timer1.current = setTimeout(() => {
97
95
  if (lastSaturation.current !== preSaturation.current) {
98
96
  onTouchMove && onTouchMove(lastSaturation.current);
99
97
  }
100
98
  }, 200);
101
99
  }, 50);
102
100
  },
103
- bindend: function handTouchEnd(_ref3) {
104
- var detail = _ref3.detail;
101
+ bindend: _ref3 => {
102
+ let {
103
+ detail
104
+ } = _ref3;
105
105
  if (!onTouchEnd || disable) {
106
106
  return;
107
107
  }
@@ -112,23 +112,23 @@ function SaturationSlider(props) {
112
112
  endRefValue.current = detail.end;
113
113
  },
114
114
  trackStyle: _objectSpread(_objectSpread({
115
- width: "".concat(646, "rpx"),
116
- height: "".concat(88, "rpx"),
117
- borderRadius: "".concat(28, "rpx")
115
+ width: `${646}rpx`,
116
+ height: `${88}rpx`,
117
+ borderRadius: `${28}rpx`
118
118
  }, trackStyle), {}, {
119
- background: bg
119
+ background: `linear-gradient(to right, rgba(${r}, ${g}, ${b}, 0.01) 0%, rgba(${r}, ${g}, ${b}, 1) 100%)`
120
120
  }),
121
121
  barStyle: {
122
122
  background: 'transparent'
123
123
  },
124
- thumbEndStyle: _objectSpread({
124
+ thumbStyle: _objectSpread({
125
125
  width: '32rpx',
126
126
  height: '104rpx',
127
- border: "9rpx solid #fff",
127
+ border: `9rpx solid #fff`,
128
128
  borderRadius: '28rpx',
129
- background: "".concat(disable ? '#000' : 'transparent')
129
+ background: `${disable ? '#000' : 'transparent'}`
130
130
  }, thumbStyle)
131
131
  }));
132
132
  }
133
- SaturationSlider.defaultProps = defaultProps;
134
- export default SaturationSlider;
133
+ LampSaturationSlider.defaultProps = defaultProps;
134
+ export default LampSaturationSlider;
package/lib/props.js CHANGED
@@ -1,16 +1,10 @@
1
1
  /* eslint-disable prettier/prettier */
2
2
  /* eslint-disable @typescript-eslint/no-empty-function */
3
3
 
4
- export var defaultProps = {
4
+ export const defaultProps = {
5
5
  value: 1,
6
6
  trackStyle: {},
7
- onTouchStart: function onTouchStart() {
8
- return null;
9
- },
10
- onTouchMove: function onTouchMove() {
11
- return null;
12
- },
13
- onTouchEnd: function onTouchEnd() {
14
- return null;
15
- }
7
+ onTouchStart: () => null,
8
+ onTouchMove: () => null,
9
+ onTouchEnd: () => null
16
10
  };
@@ -1,29 +1,22 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
1
  import { utils } from '@ray-js/panel-sdk';
3
- var rgb2hsv = utils.rgb2hsv,
4
- hsv2rgb = utils.hsv2rgb;
5
- var rgbToHsv = function (r, g, b) {
6
- var _rgb2hsv = rgb2hsv(r, g, b),
7
- _rgb2hsv2 = _slicedToArray(_rgb2hsv, 3),
8
- h = _rgb2hsv2[0],
9
- s = _rgb2hsv2[1],
10
- v = _rgb2hsv2[2];
2
+ const {
3
+ rgb2hsv,
4
+ hsv2rgb
5
+ } = utils;
6
+ const rgbToHsv = (r, g, b) => {
7
+ const [h, s, v] = rgb2hsv(r, g, b);
11
8
  return {
12
- h: h,
13
- s: s,
14
- v: v
9
+ h,
10
+ s,
11
+ v
15
12
  };
16
13
  };
17
- var hsvToRgb = function (h, s, v) {
18
- var _hsv2rgb = hsv2rgb(h, s, v),
19
- _hsv2rgb2 = _slicedToArray(_hsv2rgb, 3),
20
- r = _hsv2rgb2[0],
21
- g = _hsv2rgb2[1],
22
- b = _hsv2rgb2[2];
14
+ const hsvToRgb = (h, s, v) => {
15
+ const [r, g, b] = hsv2rgb(h, s, v);
23
16
  return {
24
- r: r,
25
- g: g,
26
- b: b
17
+ r,
18
+ g,
19
+ b
27
20
  };
28
21
  };
29
22
  export { rgbToHsv, hsvToRgb };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-saturation-slider",
3
- "version": "1.1.2-beta-1",
3
+ "version": "1.1.4-beta-2",
4
4
  "description": "照明色温Slider",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -8,13 +8,6 @@
8
8
  ],
9
9
  "license": "MIT",
10
10
  "types": "lib/index.d.ts",
11
- "maintainers": [
12
- "tuya_npm",
13
- {
14
- "name": "tuyafe",
15
- "email": "tuyafe@tuya.com"
16
- }
17
- ],
18
11
  "scripts": {
19
12
  "lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
20
13
  "build": "ray build --type=component",
@@ -24,7 +17,7 @@
24
17
  "build:web": "ray build ./example --target=web",
25
18
  "build:native": "ray build ./example --target=native",
26
19
  "start:native": "ray start ./example -t native --verbose",
27
- "start:tuya": "ray start ./example -t tuya --verbose",
20
+ "start:tuya": "ray start ./example --verbose",
28
21
  "start:wechat": "ray start ./example -t wechat --verbose",
29
22
  "start:web": "ray start ./example -t web",
30
23
  "prepublishOnly": "yarn build",
@@ -36,9 +29,8 @@
36
29
  "@commitlint/cli": "^7.2.1",
37
30
  "@commitlint/config-conventional": "^9.0.1",
38
31
  "@ray-js/babel-preset-standard": "^0.6.14",
39
- "@ray-js/cli": "^0.6.14",
40
- "@ray-js/components": "^0.6.14",
41
- "@ray-js/ray": "^0.6.14",
32
+ "@ray-js/cli": "^1.4.9",
33
+ "@ray-js/ray": "^1.4.9",
42
34
  "@ray-js/rn-transformer-helper": "^0.5.5",
43
35
  "@ray-js/types": "^0.6.14",
44
36
  "@types/node": "^17.0.43",
@@ -65,7 +57,13 @@
65
57
  ]
66
58
  },
67
59
  "dependencies": {
68
- "@ray-js/components-ty-slider": "^0.2.20",
60
+ "@ray-js/components-ty-slider": "0.2.36-beta-2",
69
61
  "@ray-js/panel-sdk": "^1.1.4"
70
- }
62
+ },
63
+ "maintainers": [
64
+ {
65
+ "name": "tuyafe",
66
+ "email": "tuyafe@tuya.com"
67
+ }
68
+ ]
71
69
  }
@@ -1,236 +0,0 @@
1
- /* eslint-disable react/require-default-props */
2
- import React from 'react';
3
-
4
- export interface EventType<T> {
5
- type: T;
6
- timeStamp: number;
7
- target: any;
8
- currentTarget: any;
9
- detail: SjsSliderEventData;
10
- }
11
-
12
- export interface SjsSliderEventData {
13
- start: number;
14
- end: number;
15
- range: number;
16
- position: 'start' | 'end';
17
- }
18
-
19
- export interface SjsSliderProps {
20
- /**
21
- * @description.en hue值
22
- * @description.zh hue value
23
- */
24
- hue: number;
25
- /**
26
- * @description.en instanceId
27
- * @description.zh 唯一ID
28
- */
29
- instanceId: string;
30
- /**
31
- * @description.en className
32
- * @description.zh 样式
33
- */
34
- className?: string;
35
- /**
36
- * @description.en disable
37
- * @description.zh disable
38
- * @default false
39
- */
40
- disable?: boolean;
41
- /**
42
- * @description.en closed
43
- * @description.zh closed
44
- * @default false
45
- */
46
- closed?: boolean;
47
- /**
48
- * @description.en left value
49
- * @description.zh 左滑块初始值
50
- * @default 0
51
- */
52
- start?: number;
53
- /**
54
- * @description.en watch value and change
55
- * @description.zh 监听值,并随之变化
56
- */
57
- watchStart?: number;
58
- /**
59
- * @description.en left value min
60
- * @description.zh 左滑块最小值限制
61
- */
62
- startMin?: number;
63
- /**
64
- * @description.en left value max
65
- * @description.zh 左滑块最大值限制
66
- */
67
- startMax?: number;
68
- /**
69
- * @description.en Right slider initial value/one-way slider initial value
70
- * @description.zh 右滑块初始值/单向滑条初始值
71
- * @default 30
72
- */
73
- end?: number;
74
- /**
75
- * @description.en watch value and change
76
- * @description.zh 监听值,并随之变化
77
- */
78
- watchEnd?: number;
79
- /**
80
- * @description.en Right slider min/one-way slider min
81
- * @description.zh 右滑块最小值/单向滑条最小值
82
- */
83
- endMin?: number;
84
- /**
85
- * @description.en Right slider Max/one-way slider Max
86
- * @description.zh 右滑块最大值/单向滑条最大值
87
- */
88
- endMax?: number;
89
- /**
90
- * @description.en min
91
- * @description.zh 最小值, 建议用 endMin 代替
92
- * @default 0
93
- * @deprecated
94
- */
95
- min?: number;
96
- /**
97
- * @description.en max
98
- * @description.zh 最大值
99
- * @default 100
100
- */
101
- max?: number;
102
- /**
103
- * @description.en step
104
- * @description.zh 阶段值
105
- * @default 1
106
- */
107
- step?: number;
108
- /**
109
- * @description.en step
110
- * @description.zh 阶段值
111
- */
112
- forceStep?: number;
113
- /**
114
- * @description.en thumbStyle
115
- * @description.zh 滑块样式
116
- */
117
- thumbStartStyle?: React.CSSProperties;
118
- /**
119
- * @description.en thumbStyle
120
- * @description.zh 滑块样式
121
- */
122
- thumbEndStyle?: React.CSSProperties;
123
- /**
124
- * @description.en trackStyle
125
- * @description.zh 轨道样式
126
- */
127
- trackStyle?: React.CSSProperties;
128
- /**
129
- * @description.en barStyle
130
- * @description.zh 滑条样式
131
- */
132
- barStyle?: React.CSSProperties;
133
- /**
134
- * @description.en stepStyle
135
- * @description.zh step样式
136
- */
137
- stepStyle?: React.CSSProperties;
138
- /**
139
- * @description.en bar stepStyle
140
- * @description.zh bar step样式
141
- */
142
- activeStepStyle?: React.CSSProperties;
143
- /**
144
- * @description.en mode
145
- * @description.zh 单向还是双向
146
- * @default normal
147
- */
148
- mode?: 'range' | 'normal';
149
- /**
150
- * @description.en barPad
151
- * @description.zh 控制滑动bar的偏移量,用于样式微调
152
- */
153
- barPad?: number;
154
- /**
155
- * @description.en maxRangeOffset
156
- * @description.zh 按钮对齐偏移
157
- * @default null
158
- */
159
- maxRangeOffset?: number;
160
- /**
161
- * @description.en hideThumb
162
- * @description.zh 隐藏滑块
163
- * @default false
164
- */
165
- hideThumb?: boolean;
166
- /**
167
- * @description.en showSteps
168
- * @description.zh 显示阶段提示
169
- * @default false
170
- */
171
- showSteps?: boolean;
172
- /**
173
- * @description.en direction
174
- * @description.zh 方向
175
- * @default horizontal
176
- */
177
- direction?: 'horizontal' | 'vertical';
178
- /**
179
- * @description.en callback
180
- * @description.zh 回调
181
- */
182
- bindmove?: (event: EventType<'move'>) => void;
183
- /**
184
- * @description.en callback
185
- * @description.zh 回调
186
- */
187
- bindend?: (event: EventType<'end'>) => void;
188
- /**
189
- * @description.en callback
190
- * @description.zh 回调
191
- */
192
- bindstart?: (event: EventType<'start'>) => void;
193
- /**
194
- * @description.en reverse
195
- * @description.zh 是否反转
196
- * @default false
197
- */
198
- reverse?: boolean;
199
- /**
200
- * @description.en enableTouch
201
- * @description.zh 使用触摸跳跃
202
- * @default false
203
- */
204
- enableTouch?: boolean;
205
- /**
206
- * @description.en enableTouchBar
207
- * @description.zh 使用触摸bar增加偏移
208
- * @default false
209
- */
210
- enableTouchBar?: boolean;
211
- /**
212
- * @description.en showText
213
- * @description.zh 在bar上显示文本
214
- * @default false
215
- */
216
- showText?: boolean;
217
- /**
218
- * @description.en textStyle
219
- * @description.zh bar文本样式
220
- */
221
- textStyle?: React.CSSProperties;
222
- /**
223
- * @description.en textTemplate
224
- * @description.zh 文本格式化,例如 textTemplate="比率 {{text}} %"
225
- */
226
- textTemplate?: string;
227
- /**
228
- * @description.en calc style, such as { background: "rgba(0,0,0, {{text / 100 }}" }
229
- * @description.zh 动态计算thumb样式,如 { background: "rgba(0,0,0, {{text /100 }})" }
230
- */
231
- thumbStyleCalc?: Partial<Record<keyof React.CSSProperties, string>>;
232
- }
233
-
234
- const SjsSlider: React.FC<SjsSliderProps>;
235
-
236
- export default SjsSlider;