@ray-js/lamp-saturation-slider 1.1.5 → 1.1.6-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.
@@ -0,0 +1,95 @@
1
+ [English](./README.md) | 简体中文
2
+
3
+ # @ray-js/lamp-saturation-slider
4
+
5
+ > 照明饱和度 Slider
6
+
7
+ ## 安装
8
+
9
+ ```sh
10
+ $ npm install @ray-js/components-ty-lamp
11
+ // 或者
12
+ $ yarn add @ray-js/components-ty-lamp
13
+ ```
14
+
15
+ ## 使用
16
+
17
+ ```ts
18
+ // 属性
19
+ export interface IProps {
20
+ /**
21
+ * @description.zh 禁止滑动
22
+ * @description.en Ban sliding
23
+ * @default false
24
+ */
25
+ disable?: boolean;
26
+ /**
27
+ * @description.zh 滑动槽样式
28
+ * @description.en
29
+ * @default {}
30
+ */
31
+ trackStyle?: React.CSSProperties;
32
+ /**
33
+ * @description.zh slider值
34
+ * @description.en slider value
35
+ * @default 0
36
+ */
37
+ value: number;
38
+ /**
39
+ * @description.zh slider 展示的颜色值 对应hsv的hue
40
+ * @description.en slider value
41
+ * @default 0
42
+ */
43
+ hue: number; // 0 - 359
44
+ /**
45
+ * @description.zh slider 手指点击时触发
46
+ * @description.en slider Value changes
47
+ * @default () => {}
48
+ */
49
+ onTouchStart?: (value: number) => void;
50
+ /**
51
+ * @description.zh slider 手指拖动时触发
52
+ * @description.en slider Value changes
53
+ * @default () => {}
54
+ */
55
+ onTouchMove?: (value: number) => void;
56
+ /**
57
+ * @description.zh slider 手指离开时触发
58
+ * @description.en Values change after the trigger
59
+ * @default () => {}
60
+ */
61
+ onTouchEnd?: (value: number) => void;
62
+ }
63
+
64
+ export const defaultProps: IProps = {
65
+ value: 0,
66
+ onTouchStart: () => null,
67
+ onTouchMove: () => null,
68
+ onTouchEnd: () => null,
69
+ };
70
+ ```
71
+
72
+ ```tsx
73
+ import { LampSaturationSlider } from '@ray-js/components-ty-lamp';
74
+
75
+ export default () => {
76
+ const [saturation, setSaturation] = useState(100);
77
+
78
+ useEffect(() => {
79
+ // 模拟dp上报
80
+ setTimeout(() => {
81
+ setSaturation(321);
82
+ }, 3000);
83
+ }, []);
84
+
85
+ return (
86
+ <LampSaturationSlider
87
+ hue={100}
88
+ value={saturation}
89
+ onTouchEnd={val => {
90
+ setSaturation(val);
91
+ }}
92
+ />
93
+ );
94
+ };
95
+ ```
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
3
  import React, { useRef, useState, useEffect, useMemo } from 'react';
4
4
  import { View } from '@ray-js/components';
5
- import Slider from '@ray-js/components-ty-slider/lib/slider';
5
+ import Slider from '@ray-js/components-ty-slider/lib/SjsSlider';
6
6
  import { toStyle } from '@ray-js/components-ty-slider';
7
7
  import { hsvToRgb } from './utils';
8
8
  import { defaultProps } from './props';
@@ -21,7 +21,8 @@ function LampSaturationSlider(props) {
21
21
  onTouchStart,
22
22
  onTouchMove,
23
23
  onTouchEnd,
24
- enableTouch = true
24
+ enableTouch = true,
25
+ max = 1000
25
26
  } = props;
26
27
  const startRefValue = useRef(-1);
27
28
  const endRefValue = useRef(-1);
@@ -48,7 +49,7 @@ function LampSaturationSlider(props) {
48
49
  }, /*#__PURE__*/React.createElement(Slider, {
49
50
  instanceId: props.instanceId || instanceId.current,
50
51
  min: 0,
51
- max: 1000,
52
+ max: max,
52
53
  disable: disable,
53
54
  end: controllerSaturation,
54
55
  enableTouch: enableTouch,
@@ -132,7 +133,7 @@ function LampSaturationSlider(props) {
132
133
  thumbStyleRenderFormatter: {
133
134
  background: `hsl(${props.hue}deg 100% value%)`
134
135
  },
135
- thumbStyleRenderValueScale: 0.05,
136
+ thumbStyleRenderValueScale: max === 1000 ? 0.05 : 0.5,
136
137
  thumbStyleRenderValueStart: 50,
137
138
  thumbStyleRenderValueReverse: true
138
139
  }));
package/lib/props.d.ts CHANGED
@@ -58,5 +58,11 @@ export interface IProps {
58
58
  * @default true
59
59
  */
60
60
  enableTouch?: boolean;
61
+ /**
62
+ * @description.en Maximum color temperature
63
+ * @description.zh 最大色温
64
+ * @default 1000
65
+ */
66
+ max?: 100 | 1000;
61
67
  }
62
68
  export declare const defaultProps: IProps;
package/lib/props.js CHANGED
@@ -6,5 +6,7 @@ export const defaultProps = {
6
6
  trackStyle: {},
7
7
  onTouchStart: () => null,
8
8
  onTouchMove: () => null,
9
- onTouchEnd: () => null
9
+ onTouchEnd: () => null,
10
+ max: 1000,
11
+ hue: 0
10
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-saturation-slider",
3
- "version": "1.1.5",
3
+ "version": "1.1.6-beta-2",
4
4
  "description": "照明色温Slider",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -60,7 +60,7 @@
60
60
  ]
61
61
  },
62
62
  "dependencies": {
63
- "@ray-js/components-ty-slider": "^0.2.40"
63
+ "@ray-js/components-ty-slider": "^0.2.52"
64
64
  },
65
65
  "maintainers": [
66
66
  {