@ray-js/lamp-style-slider 0.0.6-beta-6 → 0.0.6-beta-8

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/lib/index.js CHANGED
@@ -2,8 +2,8 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars */
3
3
  import React, { useRef, useState, useEffect } from 'react';
4
4
  import { View, Text } from '@ray-js/ray';
5
- import Slider from '@ray-js/components-ty-slider/lib/SjsSlider';
6
- import { toStyle } from '@ray-js/components-ty-slider';
5
+ import Slider from '@ray-js/components-ty-slider';
6
+ import PerfText from '@ray-js/components-ty-perf-text';
7
7
  import { useDebounceFn, useThrottleFn } from 'ahooks';
8
8
  import { formatPercent } from './utils';
9
9
  import styles from './index.module.less';
@@ -31,33 +31,32 @@ function OpacitySlider(props) {
31
31
  enableTouch = true,
32
32
  onTouchStart,
33
33
  onTouchMove,
34
- onTouchEnd
34
+ onTouchEnd,
35
+ textShowType = 'ray'
35
36
  } = props;
37
+ console.log('🚀 ~ index ~ value:', value);
36
38
  const startRefValue = useRef(-1);
37
- const handTouchMove = useThrottleFn(_ref2 => {
38
- let {
39
- detail
40
- } = _ref2;
39
+ const handTouchMove = useThrottleFn(value => {
41
40
  if (!onTouchMove || disable) {
42
41
  return;
43
42
  }
44
43
  isMove.current = true;
45
- lastValue.current = detail.end + min;
46
- if (detail.end + min === preValue.current) {
44
+ lastValue.current = value;
45
+ if (value === preValue.current) {
47
46
  return;
48
47
  }
49
48
  if (timer.current) {
50
49
  return;
51
50
  }
52
- onTouchMove && onTouchMove(detail.end + min);
51
+ onTouchMove && onTouchMove(value);
53
52
  if (!textValue && label) {
54
- setControllerValue(detail.end + min);
53
+ setControllerValue(value);
55
54
  }
56
- preValue.current = detail.end + min;
55
+ preValue.current = value;
57
56
  clearTimeout(timer.current);
58
57
  timer.current = null;
59
58
  if (lastValue.current !== preValue.current) {
60
- onTouchMove && onTouchMove(lastValue.current + min);
59
+ onTouchMove && onTouchMove(lastValue.current);
61
60
  }
62
61
  }, {
63
62
  wait: 80
@@ -75,11 +74,16 @@ function OpacitySlider(props) {
75
74
  }, {
76
75
  wait: 150
77
76
  }).run;
77
+ const eventName = `OpacitySlider_${instanceId.current}`;
78
78
  return /*#__PURE__*/React.createElement(View, {
79
79
  style: style
80
- }, label && controllerValue !== -1 && (() => {
80
+ }, label && (() => {
81
81
  return /*#__PURE__*/React.createElement(View, {
82
- className: styles.textRow
82
+ className: styles.textRow,
83
+ style: {
84
+ opacity: controllerValue === -1 ? 0 : 1,
85
+ transition: 'opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1)'
86
+ }
83
87
  }, /*#__PURE__*/React.createElement(Text, {
84
88
  className: styles.label,
85
89
  style: labelStyle
@@ -88,7 +92,15 @@ function OpacitySlider(props) {
88
92
  style: {
89
93
  margin: '0 4px'
90
94
  }
91
- }, "\xB7"), /*#__PURE__*/React.createElement(Text, {
95
+ }, "\xB7"), textShowType === 'sjs' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PerfText, {
96
+ instanceId: eventName,
97
+ className: styles.value,
98
+ defaultValue: controllerValue,
99
+ valueStart: -100 * min / (max - min),
100
+ valueScale: 100 / (max - min),
101
+ eventName: eventName,
102
+ style: valueStyle
103
+ }), "%") : /*#__PURE__*/React.createElement(Text, {
92
104
  className: styles.value,
93
105
  style: valueStyle
94
106
  }, textValue || `${formatPercent(controllerValue, {
@@ -105,57 +117,52 @@ function OpacitySlider(props) {
105
117
  }, trackStyle)
106
118
  }, /*#__PURE__*/React.createElement(Slider, {
107
119
  instanceId: props.instanceId || instanceId.current,
108
- min: 0,
109
- max: max - min,
110
- disable: disable,
111
- end: controllerValue - min,
120
+ min: min,
121
+ max: max,
122
+ disabled: disable,
123
+ moveEventName: eventName,
124
+ value: value,
112
125
  step: 1,
113
126
  enableTouch: enableTouch,
114
- bindstart: _ref => {
115
- let {
116
- detail
117
- } = _ref;
127
+ onBeforeChange: value => {
118
128
  if (!onTouchStart || disable) {
119
129
  return;
120
130
  }
121
- if (detail.end === startRefValue.current) {
131
+ if (value === startRefValue.current) {
122
132
  return;
123
133
  }
124
134
  isMove.current = false;
125
- onTouchStart && onTouchStart(detail.end);
126
- startRefValue.current = detail.end;
135
+ onTouchStart && onTouchStart(value);
136
+ startRefValue.current = value;
127
137
  },
128
- bindmove: handTouchMove,
138
+ onChange: handTouchMove,
129
139
  hideThumbButton: controllerValue === -1,
130
- bindend: _ref3 => {
131
- let {
132
- detail
133
- } = _ref3;
140
+ onAfterChange: value => {
134
141
  if (!onTouchEnd || disable) {
135
142
  return;
136
143
  }
137
- if (detail.end + min === endRefValue.current) {
144
+ if (value === endRefValue.current) {
138
145
  return;
139
146
  }
140
147
  clearTimeout(moveTimer.current);
141
148
  moveTimer.current = setTimeout(() => {
142
149
  isMove.current = false;
143
150
  }, 100);
144
- onTouchEnd && onTouchEnd(detail.end + min);
145
- endRefValue.current = detail.end + min;
151
+ onTouchEnd && onTouchEnd(value);
152
+ endRefValue.current = value;
146
153
  },
147
- trackStyle: toStyle(_objectSpread(_objectSpread({
154
+ trackStyle: _objectSpread(_objectSpread({
148
155
  width: '646rpx',
149
156
  height: '56rpx',
150
157
  position: 'relative',
151
158
  borderRadius: '28rpx'
152
159
  }, trackStyle), {}, {
153
160
  background: trackBackgroundColor
154
- })),
155
- barStyle: toStyle({
156
- background: 'transparent'
157
161
  }),
158
- thumbStyle: toStyle(_objectSpread({
162
+ barStyle: {
163
+ background: 'transparent'
164
+ },
165
+ thumbStyle: _objectSpread({
159
166
  width: '62rpx',
160
167
  height: '62rpx',
161
168
  border: '8rpx solid #fff',
@@ -163,7 +170,7 @@ function OpacitySlider(props) {
163
170
  boxShadow: 'rgb(255 255 255 / 10%) 0px 0px 1px',
164
171
  background: `${'transparent'}`,
165
172
  transition: 'opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1)'
166
- }, thumbStyle)),
173
+ }, thumbStyle),
167
174
  thumbStyleRenderFormatter: {
168
175
  background: props === null || props === void 0 ? void 0 : (_props$thumbColorForm = props.thumbColorFormatterConfig) === null || _props$thumbColorForm === void 0 ? void 0 : _props$thumbColorForm.formatter
169
176
  },
@@ -23,5 +23,6 @@
23
23
  letter-spacing: 0px;
24
24
  text-align: left;
25
25
  opacity: .9;
26
+ display: inherit;
26
27
  }
27
28
  }
package/lib/props.d.ts CHANGED
@@ -109,5 +109,11 @@ export interface IProps {
109
109
  formatter: string;
110
110
  scale?: number;
111
111
  };
112
+ /**
113
+ * @description.en text show type
114
+ * @description.zh 文本显示类型
115
+ * @default 'ray'
116
+ */
117
+ textShowType?: 'ray' | 'sjs';
112
118
  }
113
119
  export declare const defaultProps: IProps;
package/lib/props.js CHANGED
@@ -11,5 +11,6 @@ export const defaultProps = {
11
11
  max: 1000,
12
12
  onTouchStart: () => null,
13
13
  onTouchMove: () => null,
14
- onTouchEnd: () => null
14
+ onTouchEnd: () => null,
15
+ textShowType: 'ray'
15
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-style-slider",
3
- "version": "0.0.6-beta-6",
3
+ "version": "0.0.6-beta-8",
4
4
  "description": "照明样式的基础滑动条",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -59,6 +59,7 @@
59
59
  ]
60
60
  },
61
61
  "dependencies": {
62
+ "@ray-js/components-ty-perf-text": "^0.0.9",
62
63
  "@ray-js/components-ty-slider": "^0.3.8"
63
64
  },
64
65
  "resolutions": {
@@ -71,4 +72,4 @@
71
72
  "email": "tuyafe@tuya.com"
72
73
  }
73
74
  ]
74
- }
75
+ }