@ray-js/lamp-saturation-slider 1.1.1 → 1.1.4-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.
@@ -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,62 +1,61 @@
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
- onTouchStart = props.onTouchStart,
24
- onTouchMove = props.onTouchMove,
25
- onTouchEnd = props.onTouchEnd;
26
- var startRefValue = useRef(-1);
27
- var endRefValue = useRef(-1);
28
- var instanceId = useRef("Color_".concat(String(+new Date()).slice(-4), "_").concat(String(Math.random()).slice(-2)));
29
- var _useState = useState(-1),
30
- _useState2 = _slicedToArray(_useState, 2),
31
- controllerSaturation = _useState2[0],
32
- setControllerSaturation = _useState2[1];
33
- 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(() => {
34
29
  if (preSaturation.current !== saturation) {
35
30
  setControllerSaturation(saturation);
36
31
  }
37
32
  }, [saturation]);
38
- var _useMemo = useMemo(function () {
39
- return hsvToRgb(hue, 1000, 1000);
40
- }, [hue]),
41
- r = _useMemo.r,
42
- g = _useMemo.g,
43
- b = _useMemo.b;
44
- 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]);
45
38
  return /*#__PURE__*/React.createElement(View, {
46
39
  style: {
47
- position: 'relative'
40
+ position: 'relative',
41
+ background: '#fff',
42
+ width: `${646}rpx`,
43
+ height: `${88}rpx`,
44
+ borderRadius: `${28}rpx`
48
45
  }
49
46
  }, /*#__PURE__*/React.createElement(Slider, {
50
47
  instanceId: instanceId.current,
51
48
  hue: hue,
52
49
  min: 0,
53
50
  max: 1000,
51
+ closed: closed,
54
52
  disable: disable,
55
53
  end: controllerSaturation,
56
54
  step: 1,
57
- maxRangeOffset: 16,
58
- bindstart: function handleTouchStart(_ref) {
59
- var detail = _ref.detail;
55
+ bindstart: _ref => {
56
+ let {
57
+ detail
58
+ } = _ref;
60
59
  if (!onTouchStart || disable) {
61
60
  return;
62
61
  }
@@ -66,8 +65,10 @@ function SaturationSlider(props) {
66
65
  onTouchStart && onTouchStart(detail.end);
67
66
  startRefValue.current = detail.end;
68
67
  },
69
- bindmove: function handTouchMove(_ref2) {
70
- var detail = _ref2.detail;
68
+ bindmove: _ref2 => {
69
+ let {
70
+ detail
71
+ } = _ref2;
71
72
  if (!onTouchMove || disable) {
72
73
  return;
73
74
  }
@@ -78,24 +79,29 @@ function SaturationSlider(props) {
78
79
  if (timer.current) {
79
80
  return;
80
81
  }
82
+
83
+ // 移动更新的频率
84
+
81
85
  // 移动结束后多久进行更新
82
86
 
83
- timer.current = setTimeout(function () {
87
+ timer.current = setTimeout(() => {
84
88
  onTouchMove && onTouchMove(detail.end);
85
89
  preSaturation.current = detail.end;
86
90
  clearTimeout(timer.current);
87
91
  timer.current = null;
88
92
  clearTimeout(timer1.current);
89
93
  timer1.current = null;
90
- timer1.current = setTimeout(function () {
94
+ timer1.current = setTimeout(() => {
91
95
  if (lastSaturation.current !== preSaturation.current) {
92
96
  onTouchMove && onTouchMove(lastSaturation.current);
93
97
  }
94
98
  }, 200);
95
99
  }, 50);
96
100
  },
97
- bindend: function handTouchEnd(_ref3) {
98
- var detail = _ref3.detail;
101
+ bindend: _ref3 => {
102
+ let {
103
+ detail
104
+ } = _ref3;
99
105
  if (!onTouchEnd || disable) {
100
106
  return;
101
107
  }
@@ -106,23 +112,23 @@ function SaturationSlider(props) {
106
112
  endRefValue.current = detail.end;
107
113
  },
108
114
  trackStyle: _objectSpread(_objectSpread({
109
- width: "".concat(646, "rpx"),
110
- height: "".concat(88, "rpx"),
111
- borderRadius: "".concat(28, "rpx")
115
+ width: `${646}rpx`,
116
+ height: `${88}rpx`,
117
+ borderRadius: `${28}rpx`
112
118
  }, trackStyle), {}, {
113
- background: bg
119
+ background: `linear-gradient(to right, rgba(${r}, ${g}, ${b}, 0.01) 0%, rgba(${r}, ${g}, ${b}, 1) 100%)`
114
120
  }),
115
121
  barStyle: {
116
122
  background: 'transparent'
117
123
  },
118
- thumbEndStyle: _objectSpread({
124
+ thumbStyle: _objectSpread({
119
125
  width: '32rpx',
120
126
  height: '104rpx',
121
- border: "9rpx solid #fff",
127
+ border: `9rpx solid #fff`,
122
128
  borderRadius: '28rpx',
123
- background: "".concat(disable ? '#000' : 'transparent')
129
+ background: `${disable ? '#000' : 'transparent'}`
124
130
  }, thumbStyle)
125
131
  }));
126
132
  }
127
- SaturationSlider.defaultProps = defaultProps;
128
- export default SaturationSlider;
133
+ LampSaturationSlider.defaultProps = defaultProps;
134
+ export default LampSaturationSlider;
package/lib/props.d.ts CHANGED
@@ -6,6 +6,12 @@ export interface IProps {
6
6
  * @default false
7
7
  */
8
8
  disable?: boolean;
9
+ /**
10
+ * @description.zh 灯关闭状态时 thumb的状态
11
+ * @description.en The state of thumb when the light is off
12
+ * @default false
13
+ */
14
+ closed?: boolean;
9
15
  /**
10
16
  * @description.zh 滑动槽样式
11
17
  * @description.en Sliding groove style
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.1",
3
+ "version": "1.1.4-beta-1",
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-1",
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,230 +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 left value
43
- * @description.zh 左滑块初始值
44
- * @default 0
45
- */
46
- start?: number;
47
- /**
48
- * @description.en watch value and change
49
- * @description.zh 监听值,并随之变化
50
- */
51
- watchStart?: number;
52
- /**
53
- * @description.en left value min
54
- * @description.zh 左滑块最小值限制
55
- */
56
- startMin?: number;
57
- /**
58
- * @description.en left value max
59
- * @description.zh 左滑块最大值限制
60
- */
61
- startMax?: number;
62
- /**
63
- * @description.en Right slider initial value/one-way slider initial value
64
- * @description.zh 右滑块初始值/单向滑条初始值
65
- * @default 30
66
- */
67
- end?: number;
68
- /**
69
- * @description.en watch value and change
70
- * @description.zh 监听值,并随之变化
71
- */
72
- watchEnd?: number;
73
- /**
74
- * @description.en Right slider min/one-way slider min
75
- * @description.zh 右滑块最小值/单向滑条最小值
76
- */
77
- endMin?: number;
78
- /**
79
- * @description.en Right slider Max/one-way slider Max
80
- * @description.zh 右滑块最大值/单向滑条最大值
81
- */
82
- endMax?: number;
83
- /**
84
- * @description.en min
85
- * @description.zh 最小值, 建议用 endMin 代替
86
- * @default 0
87
- * @deprecated
88
- */
89
- min?: number;
90
- /**
91
- * @description.en max
92
- * @description.zh 最大值
93
- * @default 100
94
- */
95
- max?: number;
96
- /**
97
- * @description.en step
98
- * @description.zh 阶段值
99
- * @default 1
100
- */
101
- step?: number;
102
- /**
103
- * @description.en step
104
- * @description.zh 阶段值
105
- */
106
- forceStep?: number;
107
- /**
108
- * @description.en thumbStyle
109
- * @description.zh 滑块样式
110
- */
111
- thumbStartStyle?: React.CSSProperties;
112
- /**
113
- * @description.en thumbStyle
114
- * @description.zh 滑块样式
115
- */
116
- thumbEndStyle?: React.CSSProperties;
117
- /**
118
- * @description.en trackStyle
119
- * @description.zh 轨道样式
120
- */
121
- trackStyle?: React.CSSProperties;
122
- /**
123
- * @description.en barStyle
124
- * @description.zh 滑条样式
125
- */
126
- barStyle?: React.CSSProperties;
127
- /**
128
- * @description.en stepStyle
129
- * @description.zh step样式
130
- */
131
- stepStyle?: React.CSSProperties;
132
- /**
133
- * @description.en bar stepStyle
134
- * @description.zh bar step样式
135
- */
136
- activeStepStyle?: React.CSSProperties;
137
- /**
138
- * @description.en mode
139
- * @description.zh 单向还是双向
140
- * @default normal
141
- */
142
- mode?: 'range' | 'normal';
143
- /**
144
- * @description.en barPad
145
- * @description.zh 控制滑动bar的偏移量,用于样式微调
146
- */
147
- barPad?: number;
148
- /**
149
- * @description.en maxRangeOffset
150
- * @description.zh 按钮对齐偏移
151
- * @default null
152
- */
153
- maxRangeOffset?: number;
154
- /**
155
- * @description.en hideThumb
156
- * @description.zh 隐藏滑块
157
- * @default false
158
- */
159
- hideThumb?: boolean;
160
- /**
161
- * @description.en showSteps
162
- * @description.zh 显示阶段提示
163
- * @default false
164
- */
165
- showSteps?: boolean;
166
- /**
167
- * @description.en direction
168
- * @description.zh 方向
169
- * @default horizontal
170
- */
171
- direction?: 'horizontal' | 'vertical';
172
- /**
173
- * @description.en callback
174
- * @description.zh 回调
175
- */
176
- bindmove?: (event: EventType<'move'>) => void;
177
- /**
178
- * @description.en callback
179
- * @description.zh 回调
180
- */
181
- bindend?: (event: EventType<'end'>) => void;
182
- /**
183
- * @description.en callback
184
- * @description.zh 回调
185
- */
186
- bindstart?: (event: EventType<'start'>) => void;
187
- /**
188
- * @description.en reverse
189
- * @description.zh 是否反转
190
- * @default false
191
- */
192
- reverse?: boolean;
193
- /**
194
- * @description.en enableTouch
195
- * @description.zh 使用触摸跳跃
196
- * @default false
197
- */
198
- enableTouch?: boolean;
199
- /**
200
- * @description.en enableTouchBar
201
- * @description.zh 使用触摸bar增加偏移
202
- * @default false
203
- */
204
- enableTouchBar?: boolean;
205
- /**
206
- * @description.en showText
207
- * @description.zh 在bar上显示文本
208
- * @default false
209
- */
210
- showText?: boolean;
211
- /**
212
- * @description.en textStyle
213
- * @description.zh bar文本样式
214
- */
215
- textStyle?: React.CSSProperties;
216
- /**
217
- * @description.en textTemplate
218
- * @description.zh 文本格式化,例如 textTemplate="比率 {{text}} %"
219
- */
220
- textTemplate?: string;
221
- /**
222
- * @description.en calc style, such as { background: "rgba(0,0,0, {{text / 100 }}" }
223
- * @description.zh 动态计算thumb样式,如 { background: "rgba(0,0,0, {{text /100 }})" }
224
- */
225
- thumbStyleCalc?: Partial<Record<keyof React.CSSProperties, string>>;
226
- }
227
-
228
- const SjsSlider: React.FC<SjsSliderProps>;
229
-
230
- export default SjsSlider;