@ray-js/lamp-style-slider 0.0.3-beta-1 → 0.0.3-beta-3

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
@@ -6,6 +6,7 @@ import "core-js/modules/es.array.slice.js";
6
6
  import React, { useRef, useState, useEffect } from 'react';
7
7
  import { View, Text } from '@ray-js/ray';
8
8
  import Slider from '@ray-js/components-ty-slider/lib/slider';
9
+ import { toStyle } from '@ray-js/components-ty-slider';
9
10
  import { useDebounceFn, useThrottleFn } from 'ahooks';
10
11
  import { formatPercent } from './utils';
11
12
  import styles from './index.module.less';
@@ -147,25 +148,25 @@ function OpacitySlider(props) {
147
148
  onTouchEnd && onTouchEnd(detail.end + min);
148
149
  endRefValue.current = detail.end + min;
149
150
  },
150
- trackStyle: _objectSpread(_objectSpread({
151
+ trackStyle: toStyle(_objectSpread(_objectSpread({
151
152
  width: '646rpx',
152
153
  height: '56rpx',
153
154
  position: 'relative',
154
155
  borderRadius: '28rpx'
155
156
  }, trackStyle), {}, {
156
157
  background: trackBackgroundColor
157
- }),
158
- barStyle: {
158
+ })),
159
+ barStyle: toStyle({
159
160
  background: 'transparent'
160
- },
161
- thumbEndStyle: _objectSpread({
161
+ }),
162
+ thumbEndStyle: toStyle(_objectSpread({
162
163
  width: '62rpx',
163
164
  height: '62rpx',
164
165
  border: '8rpx solid #fff',
165
166
  borderRadius: '50%',
166
167
  boxShadow: 'rgb(255 255 255 / 10%) 0px 0px 1px',
167
168
  background: "".concat(disable ? '#000' : 'transparent')
168
- }, thumbStyle)
169
+ }, thumbStyle))
169
170
  })));
170
171
  }
171
172
  OpacitySlider.defaultProps = defaultProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lamp-style-slider",
3
- "version": "0.0.3-beta-1",
3
+ "version": "0.0.3-beta-3",
4
4
  "description": "照明样式的基础滑动条",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -59,7 +59,7 @@
59
59
  ]
60
60
  },
61
61
  "dependencies": {
62
- "@ray-js/components-ty-slider": "^0.2.36-beta-1"
62
+ "@ray-js/components-ty-slider": "0.2.36-beta-3"
63
63
  },
64
64
  "maintainers": [
65
65
  {
@@ -1,176 +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 instanceId
22
- * @description.zh 唯一ID
23
- */
24
- instanceId: string;
25
- /**
26
- * @description.en className
27
- * @description.zh 样式
28
- */
29
- className?: string;
30
- /**
31
- * @description.en disable
32
- * @description.zh disable
33
- * @default false
34
- */
35
- disable?: boolean;
36
- /**
37
- * @description.en Right slider initial value/one-way slider initial value
38
- * @description.zh 右滑块初始值/单向滑条初始值
39
- * @default 30
40
- */
41
- end?: number;
42
- /**
43
- * @description.en min
44
- * @description.zh 最小值, 建议用 endMin 代替
45
- * @default 0
46
- */
47
- min?: number;
48
- /**
49
- * @description.en max
50
- * @description.zh 最大值
51
- * @default 100
52
- */
53
- max?: number;
54
- /**
55
- * @description.en step
56
- * @description.zh 阶段值
57
- * @default 1
58
- */
59
- step?: number;
60
- /**
61
- * @description.en step
62
- * @description.zh 阶段值
63
- */
64
- forceStep?: number;
65
- /**
66
- * @description.en thumbStyle
67
- * @description.zh 滑块样式
68
- */
69
- thumbStyle?: React.CSSProperties;
70
- /**
71
- * @description.en trackStyle
72
- * @description.zh 轨道样式
73
- */
74
- trackStyle?: React.CSSProperties;
75
- /**
76
- * @description.en barStyle
77
- * @description.zh 滑条样式
78
- */
79
- barStyle?: React.CSSProperties;
80
- /**
81
- * @description.en stepStyle
82
- * @description.zh step样式
83
- */
84
- stepStyle?: React.CSSProperties;
85
- /**
86
- * @description.en bar stepStyle
87
- * @description.zh bar step样式
88
- */
89
- activeStepStyle?: React.CSSProperties;
90
- /**
91
- * @description.en hideThumb
92
- * @description.zh 隐藏滑块
93
- * @default false
94
- */
95
- hideThumb?: boolean;
96
- /**
97
- * @description.en showSteps
98
- * @description.zh 显示阶段提示
99
- * @default false
100
- */
101
- showSteps?: boolean;
102
- /**
103
- * @description.en direction
104
- * @description.zh 方向
105
- * @default horizontal
106
- */
107
- direction?: 'horizontal' | 'vertical';
108
- /**
109
- * @description.en callback
110
- * @description.zh 回调
111
- */
112
- 'bind:onChange'?: (event: EventType<'onChange'>) => void;
113
- /**
114
- * @description.en callback
115
- * @description.zh 回调
116
- */
117
- 'bind:onEnd'?: (event: EventType<'onEnd'>) => void;
118
- /**
119
- * @description.en callback
120
- * @description.zh 回调
121
- */
122
- 'bind:onStart'?: (event: EventType<'onStart'>) => void;
123
- /**
124
- * @description.en reverse
125
- * @description.zh 是否反转
126
- * @default false
127
- */
128
- reverse?: boolean;
129
- /**
130
- * @description.en enableTouch
131
- * @description.zh 使用触摸跳跃
132
- * @default false
133
- */
134
- enableTouch?: boolean;
135
- /**
136
- * @description.en enableTouchBar
137
- * @description.zh 使用触摸bar增加偏移
138
- * @default false
139
- */
140
- enableTouchBar?: boolean;
141
- /**
142
- * @description.en showText
143
- * @description.zh 在bar上显示文本
144
- * @default false
145
- */
146
- showText?: boolean;
147
- /**
148
- * @description.en textStyle
149
- * @description.zh bar文本样式
150
- */
151
- textStyle?: React.CSSProperties;
152
- /**
153
- * @description.en textTemplate
154
- * @description.zh 文本格式化,例如 textTemplate="比率 {{text}} %"
155
- */
156
- textTemplate?: string;
157
- /**
158
- * @description.en calc style, such as { background: "rgba(0,0,0, {{text / 100 }}" }
159
- * @description.zh 动态计算thumb样式,如 { background: "rgba(0,0,0, {{text /100 }})" }
160
- */
161
- thumbStyleCalc?: Partial<Record<keyof React.CSSProperties, string>>;
162
- /**
163
- * @description.en hideBarOnFirstRender
164
- * @description.zh 首次渲染时隐藏bar
165
- */
166
- hideBarOnFirstRender?: boolean;
167
- /**
168
- * @description.en hotAreaStyle
169
- * @description.zh 点击热区样式
170
- */
171
- hotAreaStyle?: React.CSSProperties;
172
- }
173
-
174
- const SjsSlider: React.FC<SjsSliderProps>;
175
-
176
- export default SjsSlider;
@@ -1,188 +0,0 @@
1
- import "core-js/modules/es.number.constructor.js";
2
- import "core-js/modules/es.regexp.exec.js";
3
- import "core-js/modules/es.regexp.test.js";
4
- import "core-js/modules/es.array.concat.js";
5
- import "core-js/modules/es.array.map.js";
6
- import "core-js/modules/es.array.fill.js";
7
- import "core-js/modules/es.parse-int.js";
8
- // eslint-disable-next-line no-undef
9
- Component({
10
- options: {
11
- addGlobalClass: true
12
- },
13
- properties: {
14
- className: {
15
- type: String,
16
- value: ''
17
- },
18
- disable: {
19
- type: Boolean,
20
- value: false
21
- },
22
- // 左滑块初始值
23
- start: {
24
- type: Number
25
- },
26
- // 左滑块最小值限制
27
- startMin: {
28
- type: Number
29
- },
30
- // 左滑块最大值限制
31
- startMax: {
32
- type: Number
33
- },
34
- // 右滑块初始值/单向滑条初始值
35
- end: {
36
- type: Number
37
- },
38
- watchStart: {
39
- type: Number
40
- },
41
- watchEnd: {
42
- type: Number
43
- },
44
- // 右滑块最小值/单向滑条最小值
45
- endMin: {
46
- type: Number
47
- },
48
- // 右滑块最大值/单向滑条最大值
49
- endMax: {
50
- type: Number
51
- },
52
- // 最小值
53
- min: {
54
- type: Number,
55
- value: 0
56
- },
57
- // 最大值
58
- max: {
59
- type: Number,
60
- value: 100
61
- },
62
- // 阶段值
63
- step: {
64
- type: Number,
65
- value: 1
66
- },
67
- // 阶段值
68
- forceStep: {
69
- type: Number
70
- },
71
- // 滑块样式
72
- thumbStyle: {
73
- type: String
74
- },
75
- // 轨道样式
76
- trackStyle: {
77
- type: String
78
- },
79
- // 滑条样式
80
- barStyle: {
81
- type: String
82
- },
83
- // step样式
84
- stepStyle: {
85
- type: String
86
- },
87
- // step样式
88
- activeStepStyle: {
89
- type: String
90
- },
91
- // 方向 "horizontal" | "vertical"
92
- direction: {
93
- type: String
94
- },
95
- // 隐藏滑块
96
- hideThumb: {
97
- type: Boolean,
98
- value: false
99
- },
100
- // 显示阶段提示
101
- showSteps: {
102
- type: Boolean,
103
- value: false
104
- },
105
- // 反转
106
- reverse: {
107
- type: Boolean,
108
- value: false
109
- },
110
- // 使用触摸跳跃
111
- enableTouch: {
112
- type: Boolean,
113
- value: true
114
- },
115
- // 使用触摸bar增加偏移
116
- enableTouchBar: {
117
- type: Boolean,
118
- value: false
119
- },
120
- // 唯一ID
121
- instanceId: {
122
- type: String
123
- },
124
- // 在bar上显示文本
125
- showText: {
126
- type: Boolean
127
- },
128
- // bar文本样式
129
- textStyle: {
130
- type: String
131
- },
132
- // 文本格式化,例如 textTemplate="比率 {{text}} %"
133
- textTemplate: {
134
- type: String
135
- },
136
- // 动态计算thumb样式,如 { background: "rgba(0,0,0, {{text}}/100)" }
137
- thumbStyleCalc: {
138
- type: Object
139
- },
140
- // 首次渲染时隐藏bar
141
- hideBarOnFirstRender: {
142
- type: Boolean,
143
- value: false
144
- },
145
- // 点击热区样式
146
- hotAreaStyle: {
147
- type: String
148
- }
149
- },
150
- data: {
151
- steps: [],
152
- text: ''
153
- },
154
- lifetimes: {
155
- /**
156
- * 组件的方法列表
157
- */
158
- ready: function ready() {
159
- var isNumber = function (n) {
160
- return /\d+/.test(n);
161
- };
162
- var getNumber = function (n, def) {
163
- return isNumber(n) ? n : def;
164
- };
165
- if (!this.data.showSteps) return;
166
- var stepCount = this.data.step || this.data.forceStep;
167
- var max = getNumber(this.data.max, 100);
168
- var min = getNumber(this.data.min, 0);
169
- var steps = new Array(parseInt(String((max - min) / stepCount), 10)).fill(0).map(function (_, i) {
170
- return i;
171
- }).concat(-1);
172
- this.setData({
173
- steps: steps
174
- });
175
- }
176
- },
177
- methods: {
178
- setText: function setText(_ref) {
179
- var instanceId = _ref.instanceId,
180
- content = _ref.content;
181
- if (!this.data.showText) return;
182
- if (instanceId !== this.data.instanceId) return;
183
- this.setData({
184
- text: content
185
- });
186
- }
187
- }
188
- });
@@ -1,3 +0,0 @@
1
- {
2
- "component": true
3
- }
@@ -1,184 +0,0 @@
1
- .rayui-slider {
2
- --slider-height: 10px;
3
- --slider-top-position: 2.5px;
4
- --range-width: 20px;
5
- --range-left-position: 20px;
6
- --thumb-height: 24px;
7
- --thumb-width: 24px;
8
- --thumb-left-position: 30px;
9
- --thumb-active-color: #ffffff;
10
-
11
- border-radius: 5px;
12
- background: #e0e0e0;
13
- height: var(--slider-height);
14
- margin: var(--slider-top-position);
15
- position: relative;
16
- display: flex;
17
- align-items: center;
18
-
19
- &-steps {
20
- position: absolute;
21
- left: 0;
22
- width: 100%;
23
- height: 100%;
24
- top: 50%;
25
- transform: translateY(-50%);
26
- display: flex;
27
- justify-content: space-between;
28
- align-items: center;
29
- &-dot {
30
- width: 4px;
31
- height: 4px;
32
- border-radius: 50%;
33
- background-color: #328eff;
34
- &:first-child {
35
- opacity: 0;
36
- }
37
- &:last-child {
38
- opacity: 0;
39
- }
40
- }
41
- }
42
-
43
- &-bar {
44
- display: none;
45
- position: absolute;
46
- width: var(--range-width);
47
- height: var(--slider-height);
48
- background: #328eff;
49
- cursor: pointer;
50
- border-top-left-radius: 5px;
51
- border-bottom-left-radius: 5px;
52
- flex-shrink: 0;
53
- will-change: width;
54
- overflow: hidden;
55
- .rayui-slider-steps-dot {
56
- background-color: rgba(51, 255, 241, 0.75);
57
- }
58
- &-text {
59
- position: absolute;
60
- top: 50%;
61
- left: 50%;
62
- transform: translate(-50%, -50%);
63
- display: inline-block;
64
- font-size: 12px;
65
- color: #fff;
66
- white-space: nowrap;
67
- }
68
-
69
- &-steps_wrap {
70
- position: absolute;
71
- pointer-events: none;
72
- top: 0;
73
- left: 0;
74
- width: 100%;
75
- height: 100%;
76
- }
77
- }
78
-
79
- &-thumb {
80
- position: absolute;
81
- will-change: left;
82
- display: none;
83
-
84
- &-start {
85
- top: 50%;
86
- transform: translateY(-50%);
87
- display: none;
88
- &-render {
89
- width: var(--thumb-width);
90
- height: var(--thumb-height);
91
- border-radius: 50%;
92
- background: var(--thumb-active-color);
93
- cursor: pointer;
94
- box-shadow: rgb(0 0 0 / 12%) 0px 0.5px 4px, rgb(0 0 0 / 12%) 0px 6px 13px;
95
- }
96
- }
97
- &-end {
98
- top: 50%;
99
- transform: translateY(-50%);
100
- display: none;
101
- &-render {
102
- width: var(--thumb-width);
103
- height: var(--thumb-height);
104
- border-radius: 50%;
105
- background: var(--thumb-active-color);
106
- cursor: pointer;
107
- box-shadow: rgb(0 0 0 / 12%) 0px 0.5px 4px, rgb(0 0 0 / 12%) 0px 6px 13px;
108
- }
109
- }
110
- }
111
-
112
- &.reverse {
113
- .rayui-slider {
114
- &-bar {
115
- right: 0;
116
- left: auto;
117
- border-top-right-radius: 5px;
118
- border-bottom-right-radius: 5px;
119
- }
120
- }
121
- }
122
-
123
- &.vertical {
124
- --slider-width: 300px;
125
- width: var(--slider-height);
126
- height: var(--slider-width);
127
- align-items: flex-start;
128
- justify-content: center;
129
-
130
- .rayui-slider {
131
- &-steps {
132
- height: 100%;
133
- top: 0;
134
- left: 50%;
135
- transform: translateX(-50%);
136
- flex-direction: column;
137
- align-items: center;
138
- }
139
- &-bar {
140
- height: var(--range-width);
141
- width: var(--slider-height);
142
- top: calc(var(--range-left-position) + var(--thumb-width) / 2);
143
- border-top-right-radius: 5px;
144
- border-bottom-right-radius: 5px;
145
- transform: translateX(-50%);
146
- left: 50%;
147
- will-change: height;
148
- }
149
- &-thumb {
150
- will-change: top;
151
- &-start {
152
- left: 50%;
153
- transform: translateX(-50%);
154
- }
155
- &-end {
156
- left: 50%;
157
- transform: translateX(-50%);
158
- }
159
- }
160
- }
161
- }
162
-
163
- &.vertical.reverse {
164
- .rayui-slider {
165
- &-bar {
166
- top: auto;
167
- bottom: 0;
168
- }
169
- }
170
- }
171
-
172
- &.disabled {
173
- pointer-events: none;
174
- }
175
- }
176
-
177
- .rayui-slider_wrap {
178
- padding: 20rpx 0;
179
-
180
- &.vertical {
181
- padding: 0 20rpx;
182
- display: inline-block;
183
- }
184
- }