@ray-js/lamp-saturation-slider 0.0.1-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 ADDED
@@ -0,0 +1,62 @@
1
+ English | [简体中文](./README-zh_CN.md)
2
+
3
+ # @ray-js/lamp-saturation-slider
4
+
5
+ [![latest](https://img.shields.io/npm/v/@ray-js/lamp-saturation-slider/latest.svg)](https://www.npmjs.com/package/@ray-js/lamp-saturation-slider) [![download](https://img.shields.io/npm/dt/@ray-js/lamp-saturation-slider.svg)](https://www.npmjs.com/package/@ray-js/lamp-saturation-slider)
6
+
7
+ > 照明饱和度 Slider
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ $ npm install @ray-js/lamp-saturation-slider
13
+ # or
14
+ $ yarn add @ray-js/lamp-saturation-slider
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ // 滑动条拖动时持续触发
21
+ onChange?: (value: RGB) => void;
22
+ // 滑动条拖动后,松手触发
23
+ onAfterChange?: (value: RGB) => void;
24
+ // 滑动条值
25
+ value: number;
26
+ // 滑动条默认RGB值
27
+ defaultColor: RGB;
28
+ ```
29
+
30
+ ```tsx
31
+ import LampSaturationSlider from '@ray-js/lamp-saturation-slider';
32
+ export default () => {
33
+ const value = 0;
34
+ const [rgbSaturationValue, setRgbSaturationValue] = useState({
35
+ r: 255,
36
+ g: 0,
37
+ b: 0,
38
+ });
39
+ const [rgbValue, setRgbValue] = useState({
40
+ r: 255,
41
+ g: 0,
42
+ b: 0,
43
+ });
44
+ return (
45
+ <View className={styles.view}>
46
+ <DemoBlock title="基础用法">
47
+ <Text className={styles.demoBlockTitleText}>
48
+ RGB:{`${rgbSaturationValue.r},${rgbSaturationValue.g},${rgbSaturationValue.b}`}
49
+ </Text>
50
+
51
+ <LampSaturationSlider
52
+ value={value}
53
+ defaultColor={rgbValue}
54
+ onChange={val => {
55
+ setRgbSaturationValue(val);
56
+ }}
57
+ />
58
+ </DemoBlock>
59
+ </View>
60
+ );
61
+ };
62
+ ```
@@ -0,0 +1 @@
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=_interopRequireDefault(require("react"));var _rayPanelUtils=require("@ray-js/ray-panel-utils");var _components=require("@ray-js/components");var _props=require("./props");var _jsxFileName="/drone/src/src/index.tsx";var _styleSheet=styles;function LampSaturationSlider(props){var defaultValue=props.value,defaultColor=props.defaultColor;var HValue=_rayPanelUtils.ColorUtils.rgbToHsl(defaultColor.r,defaultColor.g,defaultColor.b).h;var onChange=function(event){var rgb=_rayPanelUtils.ColorUtils.hslToRgb(HValue,event/100,0.5);props.onChange&&props.onChange(rgb);};var onAfterChange=function(event){var rgb=_rayPanelUtils.ColorUtils.hslToRgb(HValue,event/100,0.5);props.onAfterChange&&props.onAfterChange(rgb);};return _react.default.createElement(_components.Slider,{min:0,max:100,step:1,value:defaultValue,onChange:function(va){onAfterChange(va.value);},onChanging:function onChanging(va){onChange(va.value);},backgroundColor:"linear-gradient(to right, hsl("+HValue+", 0%, 100%), hsl("+HValue+", 100%, 50%))",activeColor:"transparent",__self:this,__source:{fileName:_jsxFileName,lineNumber:24,columnNumber:10}});}LampSaturationSlider.defaultProps=_props.defaultProps;var _default=LampSaturationSlider;exports.default=_default;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.wechat=exports.tuya=exports.native=void 0;var tuya={backgroundColor:'#f2f4f6',navigationBarTitleText:'Ray 跨端组件'};exports.tuya=tuya;var wechat={backgroundColor:'#f2f4f6',navigationBarTitleText:'Ray 跨端组件'};exports.wechat=wechat;var native={backgroundColor:'transparent',isBleOfflineOverlay:false,useSafeAreaView:true,navigationBarTitleText:'Ray 跨端组件'};exports.native=native;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.wechat=exports.tuya=exports.native=void 0;var tuya={backgroundColor:'#f2f4f6',navigationBarTitleText:'Ray 跨端组件'};exports.tuya=tuya;var wechat={backgroundColor:'#f2f4f6',navigationBarTitleText:'Ray 跨端组件'};exports.wechat=wechat;var native={backgroundColor:'transparent',isBleOfflineOverlay:false,useSafeAreaView:true,navigationBarTitleText:'Ray 跨端组件'};exports.native=native;
@@ -0,0 +1,14 @@
1
+ export var tuya = {
2
+ backgroundColor: '#f2f4f6',
3
+ navigationBarTitleText: 'Ray 跨端组件'
4
+ };
5
+ export var wechat = {
6
+ backgroundColor: '#f2f4f6',
7
+ navigationBarTitleText: 'Ray 跨端组件'
8
+ };
9
+ export var native = {
10
+ backgroundColor: 'transparent',
11
+ isBleOfflineOverlay: false,
12
+ useSafeAreaView: true,
13
+ navigationBarTitleText: 'Ray 跨端组件'
14
+ };
@@ -0,0 +1,14 @@
1
+ export var tuya = {
2
+ backgroundColor: '#f2f4f6',
3
+ navigationBarTitleText: 'Ray 跨端组件'
4
+ };
5
+ export var wechat = {
6
+ backgroundColor: '#f2f4f6',
7
+ navigationBarTitleText: 'Ray 跨端组件'
8
+ };
9
+ export var native = {
10
+ backgroundColor: 'transparent',
11
+ isBleOfflineOverlay: false,
12
+ useSafeAreaView: true,
13
+ navigationBarTitleText: 'Ray 跨端组件'
14
+ };
@@ -0,0 +1,14 @@
1
+ export var tuya = {
2
+ backgroundColor: '#f2f4f6',
3
+ navigationBarTitleText: 'Ray 跨端组件'
4
+ };
5
+ export var wechat = {
6
+ backgroundColor: '#f2f4f6',
7
+ navigationBarTitleText: 'Ray 跨端组件'
8
+ };
9
+ export var native = {
10
+ backgroundColor: 'transparent',
11
+ isBleOfflineOverlay: false,
12
+ useSafeAreaView: true,
13
+ navigationBarTitleText: 'Ray 跨端组件'
14
+ };
@@ -0,0 +1,14 @@
1
+ export var tuya = {
2
+ backgroundColor: '#f2f4f6',
3
+ navigationBarTitleText: 'Ray 跨端组件'
4
+ };
5
+ export var wechat = {
6
+ backgroundColor: '#f2f4f6',
7
+ navigationBarTitleText: 'Ray 跨端组件'
8
+ };
9
+ export var native = {
10
+ backgroundColor: 'transparent',
11
+ isBleOfflineOverlay: false,
12
+ useSafeAreaView: true,
13
+ navigationBarTitleText: 'Ray 跨端组件'
14
+ };
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { IProps } from './props';
3
+ declare function LampSaturationSlider(props: IProps): JSX.Element;
4
+ declare namespace LampSaturationSlider {
5
+ var defaultProps: IProps;
6
+ }
7
+ export default LampSaturationSlider;
@@ -0,0 +1 @@
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _react=_interopRequireDefault(require("react"));var _rayPanelUtils=require("@ray-js/ray-panel-utils");var _components=require("@ray-js/components");var _props=require("./props");var _jsxFileName="/drone/src/src/index.tsx";var _styleSheet=styles;function LampSaturationSlider(props){var defaultValue=props.value,defaultColor=props.defaultColor;var HValue=_rayPanelUtils.ColorUtils.rgbToHsl(defaultColor.r,defaultColor.g,defaultColor.b).h;var onChange=function(event){var rgb=_rayPanelUtils.ColorUtils.hslToRgb(HValue,event/100,0.5);props.onChange&&props.onChange(rgb);};var onAfterChange=function(event){var rgb=_rayPanelUtils.ColorUtils.hslToRgb(HValue,event/100,0.5);props.onAfterChange&&props.onAfterChange(rgb);};return _react.default.createElement(_components.Slider,{min:0,max:100,step:1,value:defaultValue,onChange:function(va){onAfterChange(va.value);},onChanging:function onChanging(va){onChange(va.value);},backgroundColor:"linear-gradient(to right, hsl("+HValue+", 0%, 100%), hsl("+HValue+", 100%, 50%))",activeColor:"transparent",__self:this,__source:{fileName:_jsxFileName,lineNumber:24,columnNumber:10}});}LampSaturationSlider.defaultProps=_props.defaultProps;var _default=LampSaturationSlider;exports.default=_default;
package/lib/index.js ADDED
@@ -0,0 +1,39 @@
1
+ import "core-js/modules/es.array.concat.js";
2
+ import React from 'react';
3
+ import { ColorUtils } from '@ray-js/ray-panel-utils';
4
+ import { Slider } from '@ray-js/components';
5
+ import { defaultProps } from './props';
6
+
7
+ function LampSaturationSlider(props) {
8
+ var defaultValue = props.value,
9
+ defaultColor = props.defaultColor;
10
+ var HValue = ColorUtils.rgbToHsl(defaultColor.r, defaultColor.g, defaultColor.b).h;
11
+
12
+ var onChange = function (event) {
13
+ var rgb = ColorUtils.hslToRgb(HValue, event / 100, 0.5);
14
+ props.onChange && props.onChange(rgb);
15
+ };
16
+
17
+ var onAfterChange = function (event) {
18
+ var rgb = ColorUtils.hslToRgb(HValue, event / 100, 0.5);
19
+ props.onAfterChange && props.onAfterChange(rgb);
20
+ };
21
+
22
+ return /*#__PURE__*/React.createElement(Slider, {
23
+ min: 0,
24
+ max: 100,
25
+ step: 1,
26
+ value: defaultValue,
27
+ onChange: function (va) {
28
+ onAfterChange(va.value);
29
+ },
30
+ onChanging: function onChanging(va) {
31
+ onChange(va.value);
32
+ },
33
+ backgroundColor: "linear-gradient(to right, hsl(".concat(HValue, ", 0%, 100%), hsl(").concat(HValue, ", 100%, 50%))"),
34
+ activeColor: "transparent"
35
+ });
36
+ }
37
+
38
+ LampSaturationSlider.defaultProps = defaultProps;
39
+ export default LampSaturationSlider;
@@ -0,0 +1,5 @@
1
+ .text {
2
+ color: #000;
3
+ font-size: 48rpx;
4
+ font-weight: bold;
5
+ }
@@ -0,0 +1,39 @@
1
+ import "core-js/modules/es.array.concat.js";
2
+ import React from 'react';
3
+ import { ColorUtils } from '@ray-js/ray-panel-utils';
4
+ import { Slider } from '@ray-js/components';
5
+ import { defaultProps } from './props';
6
+
7
+ function LampSaturationSlider(props) {
8
+ var defaultValue = props.value,
9
+ defaultColor = props.defaultColor;
10
+ var HValue = ColorUtils.rgbToHsl(defaultColor.r, defaultColor.g, defaultColor.b).h;
11
+
12
+ var onChange = function (event) {
13
+ var rgb = ColorUtils.hslToRgb(HValue, event / 100, 0.5);
14
+ props.onChange && props.onChange(rgb);
15
+ };
16
+
17
+ var onAfterChange = function (event) {
18
+ var rgb = ColorUtils.hslToRgb(HValue, event / 100, 0.5);
19
+ props.onAfterChange && props.onAfterChange(rgb);
20
+ };
21
+
22
+ return /*#__PURE__*/React.createElement(Slider, {
23
+ min: 0,
24
+ max: 100,
25
+ step: 1,
26
+ value: defaultValue,
27
+ onChange: function (va) {
28
+ onAfterChange(va.value);
29
+ },
30
+ onChanging: function onChanging(va) {
31
+ onChange(va.value);
32
+ },
33
+ backgroundColor: "linear-gradient(to right, hsl(".concat(HValue, ", 0%, 100%), hsl(").concat(HValue, ", 100%, 50%))"),
34
+ activeColor: "transparent"
35
+ });
36
+ }
37
+
38
+ LampSaturationSlider.defaultProps = defaultProps;
39
+ export default LampSaturationSlider;
@@ -0,0 +1,39 @@
1
+ import "core-js/modules/es.array.concat.js";
2
+ import React from 'react';
3
+ import { ColorUtils } from '@ray-js/ray-panel-utils';
4
+ import { Slider } from '@ray-js/components';
5
+ import { defaultProps } from './props';
6
+
7
+ function LampSaturationSlider(props) {
8
+ var defaultValue = props.value,
9
+ defaultColor = props.defaultColor;
10
+ var HValue = ColorUtils.rgbToHsl(defaultColor.r, defaultColor.g, defaultColor.b).h;
11
+
12
+ var onChange = function (event) {
13
+ var rgb = ColorUtils.hslToRgb(HValue, event / 100, 0.5);
14
+ props.onChange && props.onChange(rgb);
15
+ };
16
+
17
+ var onAfterChange = function (event) {
18
+ var rgb = ColorUtils.hslToRgb(HValue, event / 100, 0.5);
19
+ props.onAfterChange && props.onAfterChange(rgb);
20
+ };
21
+
22
+ return /*#__PURE__*/React.createElement(Slider, {
23
+ min: 0,
24
+ max: 100,
25
+ step: 1,
26
+ value: defaultValue,
27
+ onChange: function (va) {
28
+ onAfterChange(va.value);
29
+ },
30
+ onChanging: function onChanging(va) {
31
+ onChange(va.value);
32
+ },
33
+ backgroundColor: "linear-gradient(to right, hsl(".concat(HValue, ", 0%, 100%), hsl(").concat(HValue, ", 100%, 50%))"),
34
+ activeColor: "transparent"
35
+ });
36
+ }
37
+
38
+ LampSaturationSlider.defaultProps = defaultProps;
39
+ export default LampSaturationSlider;
@@ -0,0 +1,39 @@
1
+ import "core-js/modules/es.array.concat.js";
2
+ import React from 'react';
3
+ import { ColorUtils } from '@ray-js/ray-panel-utils';
4
+ import { Slider } from '@ray-js/components';
5
+ import { defaultProps } from './props';
6
+
7
+ function LampSaturationSlider(props) {
8
+ var defaultValue = props.value,
9
+ defaultColor = props.defaultColor;
10
+ var HValue = ColorUtils.rgbToHsl(defaultColor.r, defaultColor.g, defaultColor.b).h;
11
+
12
+ var onChange = function (event) {
13
+ var rgb = ColorUtils.hslToRgb(HValue, event / 100, 0.5);
14
+ props.onChange && props.onChange(rgb);
15
+ };
16
+
17
+ var onAfterChange = function (event) {
18
+ var rgb = ColorUtils.hslToRgb(HValue, event / 100, 0.5);
19
+ props.onAfterChange && props.onAfterChange(rgb);
20
+ };
21
+
22
+ return /*#__PURE__*/React.createElement(Slider, {
23
+ min: 0,
24
+ max: 100,
25
+ step: 1,
26
+ value: defaultValue,
27
+ onChange: function (va) {
28
+ onAfterChange(va.value);
29
+ },
30
+ onChanging: function onChanging(va) {
31
+ onChange(va.value);
32
+ },
33
+ backgroundColor: "linear-gradient(to right, hsl(".concat(HValue, ", 0%, 100%), hsl(").concat(HValue, ", 100%, 50%))"),
34
+ activeColor: "transparent"
35
+ });
36
+ }
37
+
38
+ LampSaturationSlider.defaultProps = defaultProps;
39
+ export default LampSaturationSlider;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.defaultProps=void 0;var defaultProps={onChange:function onChange(){return null;},onAfterChange:function onAfterChange(){return null;},value:0,defaultColor:{r:255,g:0,b:0}};exports.defaultProps=defaultProps;
package/lib/props.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ export interface IProps {
2
+ /**
3
+ * @description.zh slider值 范围0 - 100
4
+ * @description.en slider value range 0 - 100
5
+ * @default 0
6
+ */
7
+ value: number;
8
+ /**
9
+ * @description.zh slider 值改变时触发
10
+ * @description.en slider Value changes
11
+ * @default '() => {}'
12
+ */
13
+ onChange: (value: RGB) => void;
14
+ /**
15
+ * @description.zh 值改变后触发
16
+ * @description.en Values change after the trigger
17
+ * @default '() => {}'
18
+ */
19
+ onAfterChange?: (value: RGB) => void;
20
+ /**
21
+ * @description.zh 默认传入的RGB值
22
+ * @description.en The default incoming RGB values
23
+ * @default '() => {}'
24
+ */
25
+ defaultColor: RGB;
26
+ }
27
+ export declare type RGB = {
28
+ r: number;
29
+ g: number;
30
+ b: number;
31
+ };
32
+ export declare const defaultProps: IProps;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.defaultProps=void 0;var defaultProps={onChange:function onChange(){return null;},onAfterChange:function onAfterChange(){return null;},value:0,defaultColor:{r:255,g:0,b:0}};exports.defaultProps=defaultProps;
package/lib/props.js ADDED
@@ -0,0 +1,14 @@
1
+ export var defaultProps = {
2
+ onChange: function onChange() {
3
+ return null;
4
+ },
5
+ onAfterChange: function onAfterChange() {
6
+ return null;
7
+ },
8
+ value: 0,
9
+ defaultColor: {
10
+ r: 255,
11
+ g: 0,
12
+ b: 0
13
+ }
14
+ };
@@ -0,0 +1,14 @@
1
+ export var defaultProps = {
2
+ onChange: function onChange() {
3
+ return null;
4
+ },
5
+ onAfterChange: function onAfterChange() {
6
+ return null;
7
+ },
8
+ value: 0,
9
+ defaultColor: {
10
+ r: 255,
11
+ g: 0,
12
+ b: 0
13
+ }
14
+ };
@@ -0,0 +1,14 @@
1
+ export var defaultProps = {
2
+ onChange: function onChange() {
3
+ return null;
4
+ },
5
+ onAfterChange: function onAfterChange() {
6
+ return null;
7
+ },
8
+ value: 0,
9
+ defaultColor: {
10
+ r: 255,
11
+ g: 0,
12
+ b: 0
13
+ }
14
+ };
@@ -0,0 +1,14 @@
1
+ export var defaultProps = {
2
+ onChange: function onChange() {
3
+ return null;
4
+ },
5
+ onAfterChange: function onAfterChange() {
6
+ return null;
7
+ },
8
+ value: 0,
9
+ defaultColor: {
10
+ r: 255,
11
+ g: 0,
12
+ b: 0
13
+ }
14
+ };
@@ -0,0 +1,13 @@
1
+ declare module '*.less';
2
+ declare global {
3
+ interface Window {
4
+ devToolsExtension?: () => any;
5
+ ty: Ty;
6
+ }
7
+ }
8
+
9
+ interface Ty {
10
+ [key]: any;
11
+ }
12
+
13
+ declare const ty: Ty;
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@ray-js/lamp-saturation-slider",
3
+ "version": "0.0.1-beta-1",
4
+ "description": "照明饱和度Slider",
5
+ "main": "lib/index",
6
+ "files": [
7
+ "lib"
8
+ ],
9
+ "license": "MIT",
10
+ "types": "lib/index.d.ts",
11
+ "maintainers": [
12
+ "tuya_npm",
13
+ {
14
+ "name": "tuyafe",
15
+ "email": "tuyafe@tuya.com"
16
+ }
17
+ ],
18
+ "scripts": {
19
+ "lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
20
+ "build": "ray build --type=component",
21
+ "watch": "ray start --type=component",
22
+ "build:tuya": "ray build ./example --target=tuya",
23
+ "build:wechat": "ray build ./example --target=wechat",
24
+ "build:web": "ray build ./example --target=web",
25
+ "build:native": "ray build ./example --target=native",
26
+ "start:native": "ray start ./example -t native --verbose",
27
+ "start:tuya": "ray start ./example -t tuya --verbose",
28
+ "start:wechat": "ray start ./example -t wechat --verbose",
29
+ "start:web": "ray start ./example -t web",
30
+ "prepublishOnly": "yarn build",
31
+ "release-it": "standard-version"
32
+ },
33
+ "peerDependencies": {
34
+ "@ray-js/components": "^0.3.19-beta-a6eb801d",
35
+ "@ray-js/framework": "^0.3.19-beta-a6eb801d"
36
+ },
37
+ "devDependencies": {
38
+ "@commitlint/cli": "^7.2.1",
39
+ "@commitlint/config-conventional": "^9.0.1",
40
+ "@ray-js/babel-preset-standard": "^0.3.19-beta-a6eb801d",
41
+ "@ray-js/cli": "^0.3.19-beta-a6eb801d",
42
+ "@ray-js/components": "^0.3.19-beta-a6eb801d",
43
+ "@ray-js/framework": "^0.3.19-beta-a6eb801d",
44
+ "@ray-js/rn-transformer-helper": "^0.3.19-beta-a6eb801d",
45
+ "@ray-js/types": "^0.3.19-beta-a6eb801d",
46
+ "@types/node": "^17.0.43",
47
+ "core-js": "^3.19.1",
48
+ "eslint-config-tuya-panel": "^0.4.1",
49
+ "husky": "^1.2.0",
50
+ "lint-staged": "^10.2.11",
51
+ "standard-version": "9.3.2"
52
+ },
53
+ "husky": {
54
+ "hooks": {
55
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS --config commitlint.config.js",
56
+ "pre-commit": "lint-staged"
57
+ }
58
+ },
59
+ "lint-staged": {
60
+ "*.{ts,tsx,js,jsx}": [
61
+ "eslint --fix",
62
+ "git add"
63
+ ],
64
+ "*.{json,md,yml,yaml}": [
65
+ "prettier --write",
66
+ "git add"
67
+ ]
68
+ }
69
+ }