@ray-js/ray-ipc-half-horizontal-drag 0.0.5-beta-1 → 0.0.6-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/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,102 +1,126 @@
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.length === 2 || datas.length === 1) {
82
- const Container = showCloseBtn ? ScrollView : View;
83
- return /*#__PURE__*/React.createElement(Container, {
84
- hideScrollbar: true,
85
- className: `half_horizontal_drag ${styles.container} ${className || ''}`,
86
- style: style,
87
- scrollX: showCloseBtn
88
- }, datasRender(datas.length), renderCloseBtn());
89
- }
90
- if (datas.length > 2) {
91
- return /*#__PURE__*/React.createElement(ScrollView, {
92
- hideScrollbar: true,
93
- className: `half_horizontal_drag ${styles.container} ${className || ''}`,
94
- style: style,
95
- scrollX: true
96
- }, datasRender(datas.length), renderCloseBtn());
97
- }
98
- return /*#__PURE__*/React.createElement(React.Fragment, null);
99
- })());
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
+ }, data.map((item, idx) => {
64
+ const {
65
+ title,
66
+ tag,
67
+ tagStyle,
68
+ tagClassName,
69
+ onClick = NILL
70
+ } = item;
71
+ return /*#__PURE__*/React.createElement(View, {
72
+ key: idx // eslint-disable-line
73
+ ,
74
+ style: _objectSpread(_objectSpread({}, item.style), {}, {
75
+ backgroundImage: item.backgroundImage ? `url(${item.backgroundImage})` : undefined,
76
+ background: item.background || undefined
77
+ }),
78
+ onClick: onClick,
79
+ className: clsx(styles.two_data_item, styles.item, item.className, {
80
+ [styles.two_data_item_width]: showCloseBtn
81
+ })
82
+ }, /*#__PURE__*/React.createElement(View, {
83
+ className: styles.icon
84
+ }, item.icon), /*#__PURE__*/React.createElement(View, {
85
+ className: styles.title
86
+ }, title), !!tag && /*#__PURE__*/React.createElement(View, {
87
+ style: _objectSpread({}, tagStyle),
88
+ className: clsx(styles.tag, tagClassName)
89
+ }, tag));
90
+ }), renderCloseBtn());
91
+ }
92
+ if (data.length >= 3) {
93
+ return /*#__PURE__*/React.createElement(View, {
94
+ className: clsx(styles.content, styles.moreContent, className)
95
+ }, data.map((item, idx) => {
96
+ const {
97
+ title,
98
+ tag,
99
+ tagStyle,
100
+ tagClassName,
101
+ onClick = NILL
102
+ } = item;
103
+ return /*#__PURE__*/React.createElement(View
104
+ // eslint-disable-next-line react/no-array-index-key
105
+ , {
106
+ key: idx,
107
+ style: _objectSpread(_objectSpread({}, item.style), {}, {
108
+ backgroundImage: item.backgroundImage ? `url(${item.backgroundImage})` : undefined,
109
+ background: item.background || undefined
110
+ }),
111
+ className: clsx(styles.item, styles.more_data_item, item.className),
112
+ onClick: onClick
113
+ }, /*#__PURE__*/React.createElement(View, {
114
+ className: styles.icon
115
+ }, item.icon), /*#__PURE__*/React.createElement(View, {
116
+ className: styles.title
117
+ }, title), !!tag && /*#__PURE__*/React.createElement(View, {
118
+ style: _objectSpread({}, tagStyle),
119
+ className: clsx(styles.tag, tagClassName)
120
+ }, tag));
121
+ }), renderCloseBtn());
122
+ }
123
+ return null;
100
124
  };
101
125
  HalfHorizontalDrag.displayName = 'HalfHorizontalDrag';
102
126
  export {};
@@ -1,119 +1,118 @@
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
+ display: flex;
10
+ overflow-x: scroll;
11
+ overflow-y: visible;
12
+ &::-webkit-scrollbar {
13
+ display: none;
14
+ }
15
+ }
16
+ .one_data_item {
17
+ margin: 0 32rpx;
18
+ }
19
+ .one_data_item_width {
20
+ width: 686rpx;
21
+ min-width: 686rpx;
22
+ margin: 0 0 0 32rpx;
23
+ }
24
+ .two_data_item {
25
+ flex: 1;
26
+ margin-left: 32rpx;
27
+ &:last-child {
28
+ margin-right: 32rpx;
29
+ }
53
30
  }
54
-
55
- &_content {
31
+ .two_data_item_width {
32
+ flex: none;
33
+ margin-left: 14rpx;
34
+ width: 336rpx;
35
+ min-width: 336rpx;
36
+ &:first-child {
37
+ margin-left: 32rpx;
38
+ }
39
+ &:last-child {
40
+ margin-right: 0;
41
+ }
42
+ }
43
+ .more_data_item {
44
+ width: 336rpx;
45
+ min-width: 336rpx;
46
+ margin-left: 12rpx;
47
+ &:first-child {
48
+ margin-left: 32rpx;
49
+ }
50
+ &:last-child {
51
+ margin-right: 32rpx;
52
+ }
53
+ }
54
+ .item {
55
+ position: relative;
56
+ border-radius: 32rpx;
57
+ height: 110rpx;
56
58
  display: flex;
57
- flex-direction: row;
58
- height: 100%;
59
- padding: 18rpx 0 18rpx 24rpx;
60
- justify-content: space-between;
61
59
  align-items: center;
62
- position: relative;
63
-
64
- &_bg {
65
- position: absolute;
66
- left: 0;
67
- top: 0;
68
- width: 100%;
69
- height: 100%;
60
+ padding: 0 40rpx;
61
+ color: #000;
62
+ background: #fff;
63
+ background-size: cover;
64
+ background-repeat: no-repeat;
65
+ background-position: center;
66
+ .icon {
67
+ width: 48rpx;
68
+ height: 48rpx;
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: center;
70
72
  }
71
-
72
- &_name {
73
+ .title {
74
+ flex: 1;
75
+ display: -webkit-box; /* 必须结合以下两个属性使用 */
76
+ -webkit-box-orient: vertical; /* 垂直箱子布局 */
77
+ margin-left: 24rpx;
78
+ -webkit-line-clamp: 2; /* 显示的行数 */
79
+ overflow: hidden; /* 溢出隐藏 */
80
+ text-overflow: ellipsis; /* 溢出显示省略号 */
73
81
  font-size: 28rpx;
74
- color: #fff;
75
- overflow: hidden;
76
- text-overflow: ellipsis;
82
+ line-height: 40rpx;
77
83
  }
78
-
79
- &_subName {
84
+ .tag {
85
+ position: absolute;
86
+ right: -6rpx;
87
+ top: -20rpx;
88
+ color: #fff;
89
+ height: 40rpx;
90
+ line-height: 40rpx;
91
+ border-radius: 40rpx;
92
+ border-bottom-right-radius: 0px;
93
+ padding: 0 20rpx;
80
94
  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;
95
+ background: linear-gradient(345deg, #B2B0B0 1%, #EBEBEB 100%);
96
+ font-weight: 600;
97
+ color: rgba(0, 0, 0, 0.4);
98
+ max-width: 128rpx;
99
+ white-space: nowrap; /* 禁止换行 */
100
+ overflow: hidden; /* 隐藏溢出内容 */
101
+ text-overflow: ellipsis; /* 单行溢出显示省略号 */
91
102
  }
92
103
  }
93
104
  }
94
-
95
- .right_icon_bg {
96
- width: 40rpx;
97
- height: 40rpx;
98
- border-radius: 40rpx;
99
- background: #fff;
100
- margin-right: 10rpx;
105
+ .closeBtn {
101
106
  display: flex;
102
107
  align-items: center;
103
108
  justify-content: center;
104
- }
105
-
106
- .close_btn {
107
- position: relative;
108
- display: inline-block;
109
109
  margin-left: 14rpx;
110
+ background-color: red;
110
111
  margin-right: 32rpx;
111
112
  border-radius: 32rpx;
112
- height: 110rpx;
113
- line-height: 110rpx;
114
113
  background-color: rgba(240, 76, 76, 0.2);
115
- vertical-align: top;
116
- padding: 0 32rpx;
117
114
  color: #F04C4C;
115
+ padding: 0 32rpx;
118
116
  font-size: 28rpx;
117
+ font-weight: 500;
119
118
  }
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-1",
3
+ "version": "0.0.6-beta-1",
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"