@ray-js/ray-ipc-half-horizontal-drag 0.0.6-beta-2 → 0.0.7-beta.0
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 +11 -124
- package/lib/lynx/index.d.ts +4 -0
- package/lib/lynx/index.js +83 -0
- package/lib/lynx/index.module.less +197 -0
- package/lib/props.d.ts +6 -1
- package/lib/webview.d.ts +5 -0
- package/lib/webview.js +129 -0
- package/package.json +5 -3
package/lib/index.js
CHANGED
|
@@ -1,128 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
const _excluded = ["renderMode"];
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
showCloseBtn,
|
|
14
|
-
onCloseClick = NILL,
|
|
15
|
-
closeBtnTitle = 'Close',
|
|
16
|
-
closeBtnIcon
|
|
17
|
-
} = props;
|
|
18
|
-
const renderCloseBtn = () => {
|
|
19
|
-
if (!showCloseBtn) return null;
|
|
20
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
21
|
-
className: styles.closeBtn,
|
|
22
|
-
onClick: onCloseClick
|
|
23
|
-
}, closeBtnIcon, closeBtnTitle);
|
|
24
|
-
};
|
|
25
|
-
if (!data || !data.length) return null;
|
|
26
|
-
if (data.length === 1) {
|
|
27
|
-
const item = data[0];
|
|
28
|
-
const {
|
|
29
|
-
tag,
|
|
30
|
-
tagStyle,
|
|
31
|
-
tagClassName,
|
|
32
|
-
title,
|
|
33
|
-
onClick = NILL
|
|
34
|
-
} = item || {};
|
|
35
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
36
|
-
className: clsx(styles.content, className, {
|
|
37
|
-
[styles.moreContent]: showCloseBtn
|
|
38
|
-
}),
|
|
39
|
-
style: _objectSpread({}, style)
|
|
40
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
41
|
-
style: _objectSpread(_objectSpread({}, item.style), {}, {
|
|
42
|
-
backgroundImage: item.backgroundImage ? `url(${item.backgroundImage})` : undefined,
|
|
43
|
-
background: item.background || undefined
|
|
44
|
-
}),
|
|
45
|
-
className: clsx(styles.one_data_item, styles.item, item.className, {
|
|
46
|
-
[styles.one_data_item_width]: showCloseBtn
|
|
47
|
-
}),
|
|
48
|
-
onClick: onClick
|
|
49
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
50
|
-
className: styles.icon
|
|
51
|
-
}, item.icon), /*#__PURE__*/React.createElement(View, {
|
|
52
|
-
className: styles.title
|
|
53
|
-
}, title), !!tag && /*#__PURE__*/React.createElement(View, {
|
|
54
|
-
style: _objectSpread({}, tagStyle),
|
|
55
|
-
className: clsx(styles.tag, tagClassName)
|
|
56
|
-
}, tag)), renderCloseBtn());
|
|
57
|
-
}
|
|
58
|
-
if (data.length === 2) {
|
|
59
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
60
|
-
className: clsx(styles.content, styles.towContent, className, {
|
|
61
|
-
[styles.moreContent]: showCloseBtn
|
|
62
|
-
}),
|
|
63
|
-
style: _objectSpread({}, style)
|
|
64
|
-
}, data.map((item, idx) => {
|
|
65
|
-
const {
|
|
66
|
-
title,
|
|
67
|
-
tag,
|
|
68
|
-
tagStyle,
|
|
69
|
-
tagClassName,
|
|
70
|
-
onClick = NILL
|
|
71
|
-
} = item;
|
|
72
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
73
|
-
key: idx // eslint-disable-line
|
|
74
|
-
,
|
|
75
|
-
style: _objectSpread(_objectSpread({}, item.style), {}, {
|
|
76
|
-
backgroundImage: item.backgroundImage ? `url(${item.backgroundImage})` : undefined,
|
|
77
|
-
background: item.background || undefined
|
|
78
|
-
}),
|
|
79
|
-
onClick: onClick,
|
|
80
|
-
className: clsx(styles.two_data_item, styles.item, item.className, {
|
|
81
|
-
[styles.two_data_item_width]: showCloseBtn
|
|
82
|
-
})
|
|
83
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
84
|
-
className: styles.icon
|
|
85
|
-
}, item.icon), /*#__PURE__*/React.createElement(View, {
|
|
86
|
-
className: styles.title
|
|
87
|
-
}, title), !!tag && /*#__PURE__*/React.createElement(View, {
|
|
88
|
-
style: _objectSpread({}, tagStyle),
|
|
89
|
-
className: clsx(styles.tag, tagClassName)
|
|
90
|
-
}, tag));
|
|
91
|
-
}), renderCloseBtn());
|
|
92
|
-
}
|
|
93
|
-
if (data.length >= 3) {
|
|
94
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
95
|
-
className: clsx(styles.content, styles.moreContent, className),
|
|
96
|
-
style: _objectSpread({}, style)
|
|
97
|
-
}, data.map((item, idx) => {
|
|
98
|
-
const {
|
|
99
|
-
title,
|
|
100
|
-
tag,
|
|
101
|
-
tagStyle,
|
|
102
|
-
tagClassName,
|
|
103
|
-
onClick = NILL
|
|
104
|
-
} = item;
|
|
105
|
-
return /*#__PURE__*/React.createElement(View
|
|
106
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
107
|
-
, {
|
|
108
|
-
key: idx,
|
|
109
|
-
style: _objectSpread(_objectSpread({}, item.style), {}, {
|
|
110
|
-
backgroundImage: item.backgroundImage ? `url(${item.backgroundImage})` : undefined,
|
|
111
|
-
background: item.background || undefined
|
|
112
|
-
}),
|
|
113
|
-
className: clsx(styles.item, styles.more_data_item, item.className),
|
|
114
|
-
onClick: onClick
|
|
115
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
116
|
-
className: styles.icon
|
|
117
|
-
}, item.icon), /*#__PURE__*/React.createElement(View, {
|
|
118
|
-
className: styles.title
|
|
119
|
-
}, title), !!tag && /*#__PURE__*/React.createElement(View, {
|
|
120
|
-
style: _objectSpread({}, tagStyle),
|
|
121
|
-
className: clsx(styles.tag, tagClassName)
|
|
122
|
-
}, tag));
|
|
123
|
-
}), renderCloseBtn());
|
|
124
|
-
}
|
|
125
|
-
return null;
|
|
4
|
+
import WebViewHalfHorizontalDrag from './webview';
|
|
5
|
+
import LynxHalfHorizontalDrag from './lynx';
|
|
6
|
+
const HalfHorizontalDrag = _ref => {
|
|
7
|
+
let {
|
|
8
|
+
renderMode = 'webview'
|
|
9
|
+
} = _ref,
|
|
10
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
11
|
+
if (renderMode === 'lynx') return /*#__PURE__*/React.createElement(LynxHalfHorizontalDrag, props);
|
|
12
|
+
return /*#__PURE__*/React.createElement(WebViewHalfHorizontalDrag, props);
|
|
126
13
|
};
|
|
127
14
|
HalfHorizontalDrag.displayName = 'HalfHorizontalDrag';
|
|
128
15
|
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
const _excluded = ["background"];
|
|
4
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { ScrollView, Text, View } from '@ray-js/ray';
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
import styles from './index.module.less';
|
|
9
|
+
|
|
10
|
+
// Ray's newer host supports hideScrollbar; older supported Ray declarations omit it.
|
|
11
|
+
// Keep this native-only prop local rather than changing installed dependency types.
|
|
12
|
+
|
|
13
|
+
const LynxScrollView = ScrollView;
|
|
14
|
+
const isText = value => typeof value === 'string' || typeof value === 'number';
|
|
15
|
+
|
|
16
|
+
// Keep gradients on the explicit property: this build chain drops background shorthand gradients.
|
|
17
|
+
const getBackgroundStyle = function () {
|
|
18
|
+
let style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
19
|
+
const {
|
|
20
|
+
background
|
|
21
|
+
} = style,
|
|
22
|
+
rest = _objectWithoutProperties(style, _excluded);
|
|
23
|
+
if (typeof background === 'string' && background.includes('gradient(')) {
|
|
24
|
+
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
25
|
+
backgroundImage: background.trim().replace(/;$/, '')
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return style;
|
|
29
|
+
};
|
|
30
|
+
const LynxHalfHorizontalDrag = _ref => {
|
|
31
|
+
let {
|
|
32
|
+
data,
|
|
33
|
+
className,
|
|
34
|
+
style,
|
|
35
|
+
showCloseBtn = false,
|
|
36
|
+
closeBtnTitle = 'Close',
|
|
37
|
+
closeBtnIcon,
|
|
38
|
+
onCloseClick,
|
|
39
|
+
onScroll
|
|
40
|
+
} = _ref;
|
|
41
|
+
if (!data || data.length === 0) return null;
|
|
42
|
+
const scrollable = data.length >= 3 || showCloseBtn;
|
|
43
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
44
|
+
className: clsx(styles.root, className),
|
|
45
|
+
style: style
|
|
46
|
+
}, /*#__PURE__*/React.createElement(LynxScrollView, {
|
|
47
|
+
className: styles.viewport,
|
|
48
|
+
scrollX: scrollable,
|
|
49
|
+
scrollY: false,
|
|
50
|
+
hideScrollbar: true,
|
|
51
|
+
onScroll: onScroll
|
|
52
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
53
|
+
className: clsx(styles.track, !scrollable && styles.staticTrack)
|
|
54
|
+
}, data.map((item, index) => /*#__PURE__*/React.createElement(View, {
|
|
55
|
+
key: index // eslint-disable-line react/no-array-index-key
|
|
56
|
+
,
|
|
57
|
+
className: clsx(styles.item, scrollable ? styles.scrollingItem : styles.staticItem, data.length === 1 && scrollable && styles.singleScrollingItem, index === 0 && styles.firstItem, index === data.length - 1 && !showCloseBtn && styles.lastItem, item.className),
|
|
58
|
+
style: getBackgroundStyle(_objectSpread(_objectSpread({}, item.style), {}, {
|
|
59
|
+
backgroundImage: item.backgroundImage ? `url(${item.backgroundImage})` : undefined,
|
|
60
|
+
background: item.background || undefined
|
|
61
|
+
})),
|
|
62
|
+
onClick: item.onClick
|
|
63
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
64
|
+
className: styles.icon
|
|
65
|
+
}, item.icon), /*#__PURE__*/React.createElement(View, {
|
|
66
|
+
className: styles.title
|
|
67
|
+
}, isText(item.title) ? /*#__PURE__*/React.createElement(Text, {
|
|
68
|
+
className: styles.titleText,
|
|
69
|
+
"text-maxline": 2
|
|
70
|
+
}, item.title) : item.title), !!item.tag && /*#__PURE__*/React.createElement(View, {
|
|
71
|
+
className: clsx(styles.tag, item.tagClassName),
|
|
72
|
+
style: getBackgroundStyle(item.tagStyle)
|
|
73
|
+
}, isText(item.tag) ? /*#__PURE__*/React.createElement(Text, {
|
|
74
|
+
className: styles.tagText,
|
|
75
|
+
"text-maxline": 1
|
|
76
|
+
}, item.tag) : item.tag))), showCloseBtn && /*#__PURE__*/React.createElement(View, {
|
|
77
|
+
className: styles.closeBtn,
|
|
78
|
+
onClick: onCloseClick
|
|
79
|
+
}, closeBtnIcon, isText(closeBtnTitle) ? /*#__PURE__*/React.createElement(Text, {
|
|
80
|
+
className: styles.closeText
|
|
81
|
+
}, closeBtnTitle) : closeBtnTitle))));
|
|
82
|
+
};
|
|
83
|
+
export default LynxHalfHorizontalDrag;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// Only used by the explicit Lynx renderer. Legacy CSS is kept byte-for-byte.
|
|
2
|
+
.root {
|
|
3
|
+
--half-drag-height: 110rpx;
|
|
4
|
+
--half-drag-tag-inset: 20rpx;
|
|
5
|
+
--half-drag-item-width: 336rpx;
|
|
6
|
+
--half-drag-single-width: 686rpx;
|
|
7
|
+
--half-drag-side: 32rpx;
|
|
8
|
+
--half-drag-gap: 12rpx;
|
|
9
|
+
--half-drag-close-gap: 14rpx;
|
|
10
|
+
--half-drag-radius: 32rpx;
|
|
11
|
+
--half-drag-icon-size: 48rpx;
|
|
12
|
+
--half-drag-title-gap: 24rpx;
|
|
13
|
+
--half-drag-font-size: 28rpx;
|
|
14
|
+
--half-drag-line-height: 40rpx;
|
|
15
|
+
width: 100%;
|
|
16
|
+
min-width: 0;
|
|
17
|
+
height: var(--half-drag-height);
|
|
18
|
+
box-sizing: content-box;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
padding-top: 48rpx;
|
|
22
|
+
}
|
|
23
|
+
.viewport {
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: calc(var(--half-drag-height) + var(--half-drag-tag-inset));
|
|
26
|
+
margin-top: calc(0px - var(--half-drag-tag-inset));
|
|
27
|
+
flex-shrink: 0;
|
|
28
|
+
}
|
|
29
|
+
.track {
|
|
30
|
+
overflow: visible;
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: row;
|
|
33
|
+
align-items: center;
|
|
34
|
+
align-self: flex-start;
|
|
35
|
+
flex-shrink: 0;
|
|
36
|
+
height: calc(var(--half-drag-height) + var(--half-drag-tag-inset));
|
|
37
|
+
padding-top: var(--half-drag-tag-inset);
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
}
|
|
40
|
+
.staticTrack {
|
|
41
|
+
width: 100%;
|
|
42
|
+
}
|
|
43
|
+
.item {
|
|
44
|
+
overflow: visible;
|
|
45
|
+
position: relative;
|
|
46
|
+
flex-shrink: 0;
|
|
47
|
+
height: var(--half-drag-height);
|
|
48
|
+
border-radius: var(--half-drag-radius);
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: row;
|
|
51
|
+
align-items: center;
|
|
52
|
+
padding: 0 40rpx;
|
|
53
|
+
box-sizing: border-box;
|
|
54
|
+
color: #000;
|
|
55
|
+
background-color: #fff;
|
|
56
|
+
background-size: cover;
|
|
57
|
+
background-repeat: no-repeat;
|
|
58
|
+
background-position: center;
|
|
59
|
+
}
|
|
60
|
+
.scrollingItem {
|
|
61
|
+
width: var(--half-drag-item-width);
|
|
62
|
+
margin-left: var(--half-drag-gap);
|
|
63
|
+
}
|
|
64
|
+
.singleScrollingItem {
|
|
65
|
+
width: var(--half-drag-single-width);
|
|
66
|
+
}
|
|
67
|
+
.staticItem {
|
|
68
|
+
flex: 1;
|
|
69
|
+
min-width: 0;
|
|
70
|
+
margin-left: var(--half-drag-side);
|
|
71
|
+
}
|
|
72
|
+
.firstItem {
|
|
73
|
+
margin-left: var(--half-drag-side);
|
|
74
|
+
}
|
|
75
|
+
.lastItem {
|
|
76
|
+
margin-right: var(--half-drag-side);
|
|
77
|
+
}
|
|
78
|
+
.icon {
|
|
79
|
+
width: var(--half-drag-icon-size);
|
|
80
|
+
height: var(--half-drag-icon-size);
|
|
81
|
+
flex-shrink: 0;
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
}
|
|
86
|
+
.title {
|
|
87
|
+
flex: 1;
|
|
88
|
+
min-width: 0;
|
|
89
|
+
margin-left: var(--half-drag-title-gap);
|
|
90
|
+
overflow: hidden;
|
|
91
|
+
font-size: var(--half-drag-font-size);
|
|
92
|
+
line-height: var(--half-drag-line-height);
|
|
93
|
+
}
|
|
94
|
+
.titleText {
|
|
95
|
+
width: 100%;
|
|
96
|
+
max-height: calc(var(--half-drag-line-height) + var(--half-drag-line-height));
|
|
97
|
+
font-size: var(--half-drag-font-size);
|
|
98
|
+
line-height: var(--half-drag-line-height);
|
|
99
|
+
white-space: normal;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
text-overflow: ellipsis;
|
|
102
|
+
}
|
|
103
|
+
.tag {
|
|
104
|
+
position: absolute;
|
|
105
|
+
right: -6rpx;
|
|
106
|
+
top: calc(0px - var(--half-drag-tag-inset));
|
|
107
|
+
height: 40rpx;
|
|
108
|
+
line-height: 40rpx;
|
|
109
|
+
border-radius: 40rpx;
|
|
110
|
+
border-bottom-right-radius: 0;
|
|
111
|
+
padding: 0 20rpx;
|
|
112
|
+
font-size: 24rpx;
|
|
113
|
+
font-weight: 600;
|
|
114
|
+
background-color: #ebebeb;
|
|
115
|
+
background-image: linear-gradient(345deg, #b2b0b0 1%, #ebebeb 100%);
|
|
116
|
+
color: rgba(0, 0, 0, 0.4);
|
|
117
|
+
max-width: 128rpx;
|
|
118
|
+
white-space: nowrap;
|
|
119
|
+
overflow: hidden;
|
|
120
|
+
}
|
|
121
|
+
.tagText {
|
|
122
|
+
max-width: 128rpx;
|
|
123
|
+
height: 40rpx;
|
|
124
|
+
line-height: 40rpx;
|
|
125
|
+
font-size: 24rpx;
|
|
126
|
+
white-space: nowrap;
|
|
127
|
+
overflow: hidden;
|
|
128
|
+
text-overflow: ellipsis;
|
|
129
|
+
}
|
|
130
|
+
.closeText {
|
|
131
|
+
font-size: var(--half-drag-font-size);
|
|
132
|
+
white-space: nowrap;
|
|
133
|
+
}
|
|
134
|
+
.closeBtn {
|
|
135
|
+
height: var(--half-drag-height);
|
|
136
|
+
flex-shrink: 0;
|
|
137
|
+
display: flex;
|
|
138
|
+
flex-direction: row;
|
|
139
|
+
align-items: center;
|
|
140
|
+
justify-content: center;
|
|
141
|
+
margin-left: var(--half-drag-close-gap);
|
|
142
|
+
margin-right: var(--half-drag-side);
|
|
143
|
+
border-radius: var(--half-drag-radius);
|
|
144
|
+
color: #f04c4c;
|
|
145
|
+
background-color: rgba(240, 76, 76, 0.2);
|
|
146
|
+
padding: 0 32rpx;
|
|
147
|
+
font-size: var(--half-drag-font-size);
|
|
148
|
+
font-weight: 500;
|
|
149
|
+
}
|
|
150
|
+
@media (min-width: 600px) {
|
|
151
|
+
.root {
|
|
152
|
+
--half-drag-height: 55px;
|
|
153
|
+
--half-drag-tag-inset: 10px;
|
|
154
|
+
--half-drag-item-width: 168px;
|
|
155
|
+
--half-drag-single-width: 343px;
|
|
156
|
+
--half-drag-side: 16px;
|
|
157
|
+
--half-drag-gap: 6px;
|
|
158
|
+
--half-drag-close-gap: 7px;
|
|
159
|
+
--half-drag-radius: 16px;
|
|
160
|
+
--half-drag-icon-size: 24px;
|
|
161
|
+
--half-drag-title-gap: 12px;
|
|
162
|
+
--half-drag-font-size: 16px;
|
|
163
|
+
--half-drag-line-height: 20px;
|
|
164
|
+
padding-top: 24px;
|
|
165
|
+
}
|
|
166
|
+
.item {
|
|
167
|
+
padding: 0 20px;
|
|
168
|
+
}
|
|
169
|
+
.tag {
|
|
170
|
+
right: -3px;
|
|
171
|
+
height: 20px;
|
|
172
|
+
line-height: 20px;
|
|
173
|
+
padding: 0 10px;
|
|
174
|
+
font-size: 14px;
|
|
175
|
+
max-width: 64px;
|
|
176
|
+
}
|
|
177
|
+
.tagText {
|
|
178
|
+
max-width: 64px;
|
|
179
|
+
height: 20px;
|
|
180
|
+
line-height: 20px;
|
|
181
|
+
font-size: 14px;
|
|
182
|
+
}
|
|
183
|
+
.closeBtn {
|
|
184
|
+
padding: 0 16px;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
@media (min-width: 920px) {
|
|
188
|
+
.root {
|
|
189
|
+
--half-drag-font-size: 18px;
|
|
190
|
+
}
|
|
191
|
+
.tag {
|
|
192
|
+
font-size: 16px;
|
|
193
|
+
}
|
|
194
|
+
.tagText {
|
|
195
|
+
font-size: 16px;
|
|
196
|
+
}
|
|
197
|
+
}
|
package/lib/props.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { ScrollView } from '@ray-js/ray';
|
|
2
3
|
export type Data = {
|
|
3
|
-
title:
|
|
4
|
+
title: React.ReactNode;
|
|
4
5
|
backgroundImage?: string;
|
|
5
6
|
background?: string;
|
|
6
7
|
icon?: React.ReactNode;
|
|
@@ -12,6 +13,10 @@ export type Data = {
|
|
|
12
13
|
onClick?: () => void;
|
|
13
14
|
};
|
|
14
15
|
export interface IProps {
|
|
16
|
+
/** Explicit page renderer; defaults to the unchanged WebView implementation. */
|
|
17
|
+
renderMode?: 'webview' | 'lynx';
|
|
18
|
+
/** Lynx horizontal ScrollView event, used for integration diagnostics. */
|
|
19
|
+
onScroll?: React.ComponentProps<typeof ScrollView>['onScroll'];
|
|
15
20
|
/**
|
|
16
21
|
* @description.zh 数据
|
|
17
22
|
* @description.en datas
|
package/lib/webview.d.ts
ADDED
package/lib/webview.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { View } from '@ray-js/ray';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import styles from './index.module.less';
|
|
7
|
+
const NILL = () => null;
|
|
8
|
+
const HalfHorizontalDrag = props => {
|
|
9
|
+
const {
|
|
10
|
+
className,
|
|
11
|
+
style,
|
|
12
|
+
data,
|
|
13
|
+
showCloseBtn,
|
|
14
|
+
onCloseClick = NILL,
|
|
15
|
+
closeBtnTitle = 'Close',
|
|
16
|
+
closeBtnIcon
|
|
17
|
+
} = props;
|
|
18
|
+
const renderCloseBtn = () => {
|
|
19
|
+
if (!showCloseBtn) return null;
|
|
20
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
21
|
+
className: styles.closeBtn,
|
|
22
|
+
onClick: onCloseClick
|
|
23
|
+
}, closeBtnIcon, closeBtnTitle);
|
|
24
|
+
};
|
|
25
|
+
if (!data || !data.length) return null;
|
|
26
|
+
if (data.length === 1) {
|
|
27
|
+
const item = data[0];
|
|
28
|
+
const {
|
|
29
|
+
tag,
|
|
30
|
+
tagStyle,
|
|
31
|
+
tagClassName,
|
|
32
|
+
title,
|
|
33
|
+
onClick = NILL
|
|
34
|
+
} = item || {};
|
|
35
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
36
|
+
className: clsx(styles.content, className, {
|
|
37
|
+
[styles.moreContent]: showCloseBtn
|
|
38
|
+
}),
|
|
39
|
+
style: _objectSpread({}, style)
|
|
40
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
41
|
+
style: _objectSpread(_objectSpread({}, item.style), {}, {
|
|
42
|
+
backgroundImage: item.backgroundImage ? `url(${item.backgroundImage})` : undefined,
|
|
43
|
+
background: item.background || undefined
|
|
44
|
+
}),
|
|
45
|
+
className: clsx(styles.one_data_item, styles.item, item.className, {
|
|
46
|
+
[styles.one_data_item_width]: showCloseBtn
|
|
47
|
+
}),
|
|
48
|
+
onClick: onClick
|
|
49
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
50
|
+
className: styles.icon
|
|
51
|
+
}, item.icon), /*#__PURE__*/React.createElement(View, {
|
|
52
|
+
className: styles.title
|
|
53
|
+
}, title), !!tag && /*#__PURE__*/React.createElement(View, {
|
|
54
|
+
style: _objectSpread({}, tagStyle),
|
|
55
|
+
className: clsx(styles.tag, tagClassName)
|
|
56
|
+
}, tag)), renderCloseBtn());
|
|
57
|
+
}
|
|
58
|
+
if (data.length === 2) {
|
|
59
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
60
|
+
className: clsx(styles.content, styles.towContent, className, {
|
|
61
|
+
[styles.moreContent]: showCloseBtn
|
|
62
|
+
}),
|
|
63
|
+
style: _objectSpread({}, style)
|
|
64
|
+
}, data.map((item, idx) => {
|
|
65
|
+
const {
|
|
66
|
+
title,
|
|
67
|
+
tag,
|
|
68
|
+
tagStyle,
|
|
69
|
+
tagClassName,
|
|
70
|
+
onClick = NILL
|
|
71
|
+
} = item;
|
|
72
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
73
|
+
key: idx // eslint-disable-line
|
|
74
|
+
,
|
|
75
|
+
style: _objectSpread(_objectSpread({}, item.style), {}, {
|
|
76
|
+
backgroundImage: item.backgroundImage ? `url(${item.backgroundImage})` : undefined,
|
|
77
|
+
background: item.background || undefined
|
|
78
|
+
}),
|
|
79
|
+
onClick: onClick,
|
|
80
|
+
className: clsx(styles.two_data_item, styles.item, item.className, {
|
|
81
|
+
[styles.two_data_item_width]: showCloseBtn
|
|
82
|
+
})
|
|
83
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
84
|
+
className: styles.icon
|
|
85
|
+
}, item.icon), /*#__PURE__*/React.createElement(View, {
|
|
86
|
+
className: styles.title
|
|
87
|
+
}, title), !!tag && /*#__PURE__*/React.createElement(View, {
|
|
88
|
+
style: _objectSpread({}, tagStyle),
|
|
89
|
+
className: clsx(styles.tag, tagClassName)
|
|
90
|
+
}, tag));
|
|
91
|
+
}), renderCloseBtn());
|
|
92
|
+
}
|
|
93
|
+
if (data.length >= 3) {
|
|
94
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
95
|
+
className: clsx(styles.content, styles.moreContent, className),
|
|
96
|
+
style: _objectSpread({}, style)
|
|
97
|
+
}, data.map((item, idx) => {
|
|
98
|
+
const {
|
|
99
|
+
title,
|
|
100
|
+
tag,
|
|
101
|
+
tagStyle,
|
|
102
|
+
tagClassName,
|
|
103
|
+
onClick = NILL
|
|
104
|
+
} = item;
|
|
105
|
+
return /*#__PURE__*/React.createElement(View
|
|
106
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
107
|
+
, {
|
|
108
|
+
key: idx,
|
|
109
|
+
style: _objectSpread(_objectSpread({}, item.style), {}, {
|
|
110
|
+
backgroundImage: item.backgroundImage ? `url(${item.backgroundImage})` : undefined,
|
|
111
|
+
background: item.background || undefined
|
|
112
|
+
}),
|
|
113
|
+
className: clsx(styles.item, styles.more_data_item, item.className),
|
|
114
|
+
onClick: onClick
|
|
115
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
116
|
+
className: styles.icon
|
|
117
|
+
}, item.icon), /*#__PURE__*/React.createElement(View, {
|
|
118
|
+
className: styles.title
|
|
119
|
+
}, title), !!tag && /*#__PURE__*/React.createElement(View, {
|
|
120
|
+
style: _objectSpread({}, tagStyle),
|
|
121
|
+
className: clsx(styles.tag, tagClassName)
|
|
122
|
+
}, tag));
|
|
123
|
+
}), renderCloseBtn());
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
};
|
|
127
|
+
HalfHorizontalDrag.displayName = 'HalfHorizontalDrag';
|
|
128
|
+
export {};
|
|
129
|
+
export default HalfHorizontalDrag;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/ray-ipc-half-horizontal-drag",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7-beta.0",
|
|
4
4
|
"description": "水平方向可拖动,显示出下一个组件的小部分内容",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"start:wechat": "ray start ./example -t wechat --verbose",
|
|
29
29
|
"start:web": "ray start ./example -t web",
|
|
30
30
|
"prepublishOnly": "yarn build",
|
|
31
|
-
"release-it": "standard-version"
|
|
31
|
+
"release-it": "standard-version",
|
|
32
|
+
"test": "node --test tests/render-mode.test.cjs",
|
|
33
|
+
"typecheck": "tsc --noEmit"
|
|
32
34
|
},
|
|
33
35
|
"peerDependencies": {
|
|
34
36
|
"@ray-js/ray": "^1.4.9"
|
|
@@ -41,7 +43,7 @@
|
|
|
41
43
|
"@commitlint/cli": "^7.2.1",
|
|
42
44
|
"@commitlint/config-conventional": "^9.0.1",
|
|
43
45
|
"@ray-js/cli": "^1.4.9",
|
|
44
|
-
"@ray-js/panel-sdk": "^1.
|
|
46
|
+
"@ray-js/panel-sdk": "^1.16.1",
|
|
45
47
|
"@ray-js/ray": "^1.4.9",
|
|
46
48
|
"core-js": "^3.19.1",
|
|
47
49
|
"eslint-config-tuya-panel": "^0.4.2",
|