@ray-js/ray-ipc-half-horizontal-drag 0.0.5-beta-2 → 0.0.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.
package/lib/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { IProps, IPropDatas } from './props';
2
+ import { IProps, Data } from './props';
3
3
  declare const HalfHorizontalDrag: React.FC<IProps>;
4
- export { type IProps, type IPropDatas };
4
+ export { type IProps, type Data };
5
5
  export default HalfHorizontalDrag;
package/lib/index.js CHANGED
@@ -1,103 +1,128 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import "core-js/modules/esnext.iterator.map.js";
2
3
  import React from 'react';
4
+ import { View } from '@ray-js/ray';
3
5
  import clsx from 'clsx';
4
- import { View, ScrollView, Image } from '@ray-js/ray';
5
6
  import styles from './index.module.less';
6
7
  const NILL = () => null;
7
8
  const HalfHorizontalDrag = props => {
8
9
  const {
9
10
  className,
10
- classNameBox,
11
11
  style,
12
- datas,
13
- onBgClick,
14
- onRightClick,
12
+ data,
15
13
  showCloseBtn,
16
14
  onCloseClick = NILL,
17
- closeBtnTitle,
15
+ closeBtnTitle = 'Close',
18
16
  closeBtnIcon
19
17
  } = props;
20
- const onCurRightImage = (e, data) => {
21
- onRightClick && onRightClick(data);
22
- e.stopPropagation();
23
- };
24
- const onCurBgClick = (e, data) => {
25
- onBgClick && onBgClick(data);
26
- };
27
- const datasRender = num => {
28
- const classBox = clsx({
29
- [styles.container_box_1]: num === 1,
30
- [styles.container_box_2]: num === 2,
31
- [styles.container_box_3]: num > 2,
32
- [styles.container_box_1_width]: num === 1 && showCloseBtn,
33
- [styles.container_box_2_width]: num === 2 && showCloseBtn
34
- });
35
- return /*#__PURE__*/React.createElement(React.Fragment, null, datas.map(data => {
36
- return /*#__PURE__*/React.createElement(View, {
37
- className: `${styles.container_box} ${classBox} ${classNameBox}`,
38
- key: data.id
39
- }, /*#__PURE__*/React.createElement(View, {
40
- className: styles.container_box_content,
41
- onClick: e => onCurBgClick(e, data)
42
- }, /*#__PURE__*/React.createElement(Image, {
43
- className: styles.container_box_content_bg,
44
- mode: "aspectFill",
45
- src: data.bgImage
46
- }), /*#__PURE__*/React.createElement(View, {
47
- style: {
48
- flex: 1,
49
- width: '100%',
50
- display: 'flex',
51
- flexDirection: 'row',
52
- position: 'relative'
53
- }
54
- }, /*#__PURE__*/React.createElement(View, {
55
- style: {
56
- flex: 1,
57
- overflow: 'hidden'
58
- }
59
- }, /*#__PURE__*/React.createElement(View, {
60
- className: `${styles.container_box_content_name}`
61
- }, data.name), /*#__PURE__*/React.createElement(View, {
62
- className: `${styles.container_box_content_subName}`
63
- }, data.subName)), /*#__PURE__*/React.createElement(Image, {
64
- className: styles.container_box_content_icon,
65
- mode: "aspectFill",
66
- src: data.rightIcon,
67
- onClick: e => onCurRightImage(e, data)
68
- }))));
69
- }));
70
- };
71
18
  const renderCloseBtn = () => {
72
- if (!showCloseBtn) {
73
- return null;
74
- }
19
+ if (!showCloseBtn) return null;
75
20
  return /*#__PURE__*/React.createElement(View, {
76
- className: styles.close_btn,
21
+ className: styles.closeBtn,
77
22
  onClick: onCloseClick
78
23
  }, closeBtnIcon, closeBtnTitle);
79
24
  };
80
- return /*#__PURE__*/React.createElement(React.Fragment, null, (() => {
81
- if (!datas || !datas.length) return null;
82
- if (datas.length === 2 || datas.length === 1) {
83
- const Container = showCloseBtn ? ScrollView : View;
84
- return /*#__PURE__*/React.createElement(Container, {
85
- hideScrollbar: true,
86
- className: `half_horizontal_drag ${styles.container} ${className || ''}`,
87
- style: style,
88
- scrollX: showCloseBtn
89
- }, datasRender(datas.length), renderCloseBtn());
90
- }
91
- if (datas.length > 2) {
92
- return /*#__PURE__*/React.createElement(ScrollView, {
93
- hideScrollbar: true,
94
- className: `half_horizontal_drag ${styles.container} ${className || ''}`,
95
- style: style,
96
- scrollX: true
97
- }, datasRender(datas.length), renderCloseBtn());
98
- }
99
- return /*#__PURE__*/React.createElement(React.Fragment, null);
100
- })());
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;
101
126
  };
102
127
  HalfHorizontalDrag.displayName = 'HalfHorizontalDrag';
103
128
  export {};
@@ -1,119 +1,119 @@
1
- @class-prefix: ~'half_horizontal_drag';
2
-
3
- .@{class-prefix} {
4
- color: #000;
5
- font-size: 48rpx;
6
- font-weight: bold;
7
- }
8
-
9
- .container {
10
- display: flex;
11
- flex-direction: row;
12
- white-space: nowrap;
13
- margin: 48rpx 0;
14
- scrollbar-width: none;
15
- -ms-overflow-style: none;
16
-
17
- &::-webkit-scrollbar {
18
- display: none;
1
+ .content {
2
+ padding: 48rpx 0;
3
+ box-sizing: content-box;
4
+ &.towContent {
5
+ display: flex;
19
6
  }
20
- }
21
-
22
- .container_box_1 {
23
- flex: 1;
24
- }
25
-
26
- .container_box_1_width {
27
- flex: none;
28
- width: 686rpx;
29
- }
30
-
31
- .container_box_2 {
32
- flex: 1;
33
- }
34
-
35
- .container_box_2_width {
36
- flex: none;
37
- width: 335rpx;
38
- }
39
-
40
- .container_box_3 {
41
- width: 314rpx;
42
- }
43
-
44
- .container_box {
45
- height: 110rpx;
46
- overflow: hidden;
47
- display: inline-block;
48
- margin-left: 16rpx;
49
- border-radius: 32rpx;
50
-
51
- &:last-child {
52
- margin-right: 32rpx;
7
+ &.moreContent {
8
+ // padding: 48rpx 0;
9
+ padding-right: 32rpx;
10
+ display: flex;
11
+ overflow-x: scroll;
12
+ overflow-y: visible;
13
+ &::-webkit-scrollbar {
14
+ display: none;
15
+ }
16
+ }
17
+ .one_data_item {
18
+ margin: 0 32rpx;
19
+ }
20
+ .one_data_item_width {
21
+ width: 686rpx;
22
+ min-width: 686rpx;
23
+ margin: 0 0 0 32rpx;
24
+ }
25
+ .two_data_item {
26
+ flex: 1;
27
+ margin-left: 32rpx;
28
+ &:last-child {
29
+ margin-right: 32rpx;
30
+ }
53
31
  }
54
-
55
- &_content {
32
+ .two_data_item_width {
33
+ flex: none;
34
+ margin-left: 14rpx;
35
+ width: 336rpx;
36
+ min-width: 336rpx;
37
+ &:first-child {
38
+ margin-left: 32rpx;
39
+ }
40
+ &:last-child {
41
+ margin-right: 0;
42
+ }
43
+ }
44
+ .more_data_item {
45
+ width: 336rpx;
46
+ min-width: 336rpx;
47
+ margin-left: 12rpx;
48
+ &:first-child {
49
+ margin-left: 32rpx;
50
+ }
51
+ // &:last-child {
52
+ // margin-right: 32rpx;
53
+ // }
54
+ }
55
+ .item {
56
+ position: relative;
57
+ border-radius: 32rpx;
58
+ height: 110rpx;
56
59
  display: flex;
57
- flex-direction: row;
58
- height: 100%;
59
- padding: 18rpx 0 18rpx 24rpx;
60
- justify-content: space-between;
61
60
  align-items: center;
62
- position: relative;
63
-
64
- &_bg {
65
- position: absolute;
66
- left: 0;
67
- top: 0;
68
- width: 100%;
69
- height: 100%;
61
+ padding: 0 40rpx;
62
+ color: #000;
63
+ background: #fff;
64
+ background-size: cover;
65
+ background-repeat: no-repeat;
66
+ background-position: center;
67
+ .icon {
68
+ width: 48rpx;
69
+ height: 48rpx;
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: center;
70
73
  }
71
-
72
- &_name {
74
+ .title {
75
+ flex: 1;
76
+ display: -webkit-box; /* 必须结合以下两个属性使用 */
77
+ -webkit-box-orient: vertical; /* 垂直箱子布局 */
78
+ margin-left: 24rpx;
79
+ -webkit-line-clamp: 2; /* 显示的行数 */
80
+ overflow: hidden; /* 溢出隐藏 */
81
+ text-overflow: ellipsis; /* 溢出显示省略号 */
73
82
  font-size: 28rpx;
74
- color: #fff;
75
- overflow: hidden;
76
- text-overflow: ellipsis;
83
+ line-height: 40rpx;
77
84
  }
78
-
79
- &_subName {
85
+ .tag {
86
+ position: absolute;
87
+ right: -6rpx;
88
+ top: -20rpx;
89
+ color: #fff;
90
+ height: 40rpx;
91
+ line-height: 40rpx;
92
+ border-radius: 40rpx;
93
+ border-bottom-right-radius: 0px;
94
+ padding: 0 20rpx;
80
95
  font-size: 24rpx;
81
- color: rgba(255, 255, 255, 0.7);
82
- overflow: hidden;
83
- text-overflow: ellipsis;
84
- }
85
-
86
- &_icon {
87
- margin: 0 8rpx;
88
- width: 44rpx;
89
- height: 44rpx;
90
- margin-right: 10rpx;
96
+ background: linear-gradient(345deg, #B2B0B0 1%, #EBEBEB 100%);
97
+ font-weight: 600;
98
+ color: rgba(0, 0, 0, 0.4);
99
+ max-width: 128rpx;
100
+ white-space: nowrap; /* 禁止换行 */
101
+ overflow: hidden; /* 隐藏溢出内容 */
102
+ text-overflow: ellipsis; /* 单行溢出显示省略号 */
91
103
  }
92
104
  }
93
105
  }
94
-
95
- .right_icon_bg {
96
- width: 40rpx;
97
- height: 40rpx;
98
- border-radius: 40rpx;
99
- background: #fff;
100
- margin-right: 10rpx;
106
+ .closeBtn {
101
107
  display: flex;
102
108
  align-items: center;
103
109
  justify-content: center;
104
- }
105
-
106
- .close_btn {
107
- position: relative;
108
- display: inline-block;
109
110
  margin-left: 14rpx;
110
- margin-right: 32rpx;
111
+ background-color: red;
112
+ // margin-right: 32rpx;
111
113
  border-radius: 32rpx;
112
- height: 110rpx;
113
- line-height: 110rpx;
114
114
  background-color: rgba(240, 76, 76, 0.2);
115
- vertical-align: top;
116
- padding: 0 32rpx;
117
115
  color: #F04C4C;
116
+ padding: 0 32rpx;
118
117
  font-size: 28rpx;
118
+ font-weight: 500;
119
119
  }
package/lib/props.d.ts CHANGED
@@ -1,43 +1,40 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
+ export type Data = {
3
+ title: string;
4
+ backgroundImage?: string;
5
+ background?: string;
6
+ icon?: React.ReactNode;
7
+ className?: string;
8
+ style?: React.CSSProperties;
9
+ tag?: string;
10
+ tagClassName?: string;
11
+ tagStyle?: React.CSSProperties;
12
+ onClick?: () => void;
13
+ };
2
14
  export interface IProps {
3
15
  /**
4
16
  * @description.zh 数据
5
17
  * @description.en datas
6
18
  */
7
- datas: IPropDatas[];
19
+ data: Data[];
8
20
  /**
9
21
  * @description.zh 类名
10
22
  * @description.en class name
11
23
  */
12
24
  className?: string;
13
- /**
14
- * @description.zh 盒子类名
15
- * @description.en class name box
16
- */
17
- classNameBox?: string;
18
25
  /**
19
26
  * @description.zh 样式
20
27
  * @description.en Style
21
28
  */
22
29
  style?: React.CSSProperties;
23
30
  /**
24
- * @description.zh 点击事件
25
- * @description.en bg image
26
- */
27
- onBgClick?: (data: IPropDatas) => void;
28
- /**
29
- * @description.zh 点击事件
30
- * @description.en bg image
31
- */
32
- onRightClick?: (data: IPropDatas) => void;
33
- /**
34
- * @description.zh 是否显示关闭按钮
31
+ * @description.zh 是否展示关闭按钮
35
32
  * @description.en Whether to display the close button
36
33
  */
37
34
  showCloseBtn?: boolean;
38
35
  /**
39
- * @description.zh 点击关闭按钮触发的回调
40
- * @description.en Callback triggered by clicking the close button
36
+ * @description.zh 点击关闭按钮的回调函数
37
+ * @description.en Callback function when the close button is clicked
41
38
  */
42
39
  onCloseClick?: (e: any) => void;
43
40
  /**
@@ -51,30 +48,3 @@ export interface IProps {
51
48
  */
52
49
  closeBtnIcon?: React.ReactElement;
53
50
  }
54
- export interface IPropDatas {
55
- /**
56
- * @description.zh 唯一标识
57
- * @description.en id
58
- */
59
- id: string;
60
- /**
61
- * @description.zh 名称
62
- * @description.en name
63
- */
64
- name?: string;
65
- /**
66
- * @description.zh 子名称
67
- * @description.en sub name
68
- */
69
- subName?: string;
70
- /**
71
- * @description.zh 右侧图标
72
- * @description.en right icon
73
- */
74
- rightIcon?: string;
75
- /**
76
- * @description.zh 背景图
77
- * @description.en bg image
78
- */
79
- bgImage?: string;
80
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ray-ipc-half-horizontal-drag",
3
- "version": "0.0.5-beta-2",
3
+ "version": "0.0.6-beta-2",
4
4
  "description": "水平方向可拖动,显示出下一个组件的小部分内容",
5
5
  "main": "lib/index",
6
6
  "files": [
@@ -34,19 +34,20 @@
34
34
  "@ray-js/ray": "^1.4.9"
35
35
  },
36
36
  "dependencies": {
37
- "clsx": "^1.2.1"
37
+ "clsx": "^1.2.1",
38
+ "uuid": "^11.0.4"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@commitlint/cli": "^7.2.1",
41
42
  "@commitlint/config-conventional": "^9.0.1",
42
43
  "@ray-js/cli": "^1.4.9",
44
+ "@ray-js/panel-sdk": "^1.13.0-storage.7",
43
45
  "@ray-js/ray": "^1.4.9",
44
46
  "core-js": "^3.19.1",
45
47
  "eslint-config-tuya-panel": "^0.4.2",
46
48
  "husky": "^1.2.0",
47
49
  "lint-staged": "^10.2.11",
48
- "standard-version": "9.3.2",
49
- "@ray-js/panel-sdk": "^1.13.0-storage.7"
50
+ "standard-version": "9.3.2"
50
51
  },
51
52
  "resolutions": {
52
53
  "@ray-js/builder-mp": "1.4.15"