@fonixtree/magic-design 1.0.218 → 1.0.220

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.
Files changed (95) hide show
  1. package/es/assets/images/layout-icon/banner-layout1.png +0 -0
  2. package/es/assets/images/layout-icon/banner-layout2.svg +6 -0
  3. package/es/assets/images/layout-icon/center.png +0 -0
  4. package/es/assets/images/layout-icon/grouped-image-layout1.png +0 -0
  5. package/es/assets/images/layout-icon/left.png +0 -0
  6. package/es/assets/images/layout-icon/right.png +0 -0
  7. package/es/common/LinkModal/SelectPicture/imgs/picture-bg.png +0 -0
  8. package/es/common/LinkModal/SelectPicture/index.js +135 -0
  9. package/es/common/LinkModal/SelectPicture/index.less +88 -0
  10. package/es/common/LinkModal/index.js +6 -0
  11. package/es/common/PictureModal/index.js +37 -0
  12. package/es/common/PictureModal/index.less +41 -0
  13. package/es/composite-comp/bol/components/Banner/defaultJSON.js +28 -0
  14. package/es/composite-comp/bol/components/Banner/pc/components/BannerContent.js +82 -0
  15. package/es/composite-comp/bol/components/Banner/pc/components/SwiperBannerPc.js +270 -0
  16. package/es/composite-comp/bol/components/Banner/pc/index.js +43 -14
  17. package/es/composite-comp/bol/components/Banner/pc/index.less +81 -9
  18. package/es/composite-comp/bol/config-panels/BannerConfig/index.js +26 -0
  19. package/es/composite-comp/bol/second-config-panels/BannerSecondConfig/index.js +17 -1
  20. package/es/composite-comp/dito/components/GroupedImage/defaultJSON.js +149 -0
  21. package/es/composite-comp/dito/components/GroupedImage/index.js +88 -0
  22. package/es/composite-comp/dito/components/GroupedImage/pc/index.js +417 -0
  23. package/es/composite-comp/dito/components/GroupedImage/pc/index.less +124 -0
  24. package/es/composite-comp/dito/components/Recommend/pc/index.js +2 -2
  25. package/es/composite-comp/dito/components/Recommend/pc/index.less +3 -1
  26. package/es/composite-comp/dito/config-panels/GroupedImageConfig/ConfigGroup/index.js +146 -0
  27. package/es/composite-comp/dito/config-panels/GroupedImageConfig/imgs/defaultImg.png +0 -0
  28. package/es/composite-comp/dito/config-panels/GroupedImageConfig/index.js +127 -0
  29. package/es/composite-comp/dito/second-config-panels/GroupedImageSecondConfig/index.js +290 -0
  30. package/es/composite-comp/dito/second-config-panels/GroupedImageSecondConfig/index.less +21 -0
  31. package/es/constants/component-types.js +9 -3
  32. package/es/constants/index.js +6 -1
  33. package/es/constants/layout.js +30 -2
  34. package/es/core/Designer/ConfigPanel/index.js +217 -4
  35. package/es/core/Designer/ConfigPanel/index.less +39 -0
  36. package/es/core/Renderer/index.js +25 -4
  37. package/es/locale/en/en.json +1 -0
  38. package/es/locale/es/es.json +1 -0
  39. package/es/locale/id/id.json +1 -0
  40. package/es/meta-comp/components/Image/index.js +15 -11
  41. package/es/meta-comp/config-panels/ImageConfig/index.js +25 -8
  42. package/es/mobx/Frame.js +5 -0
  43. package/es/mobx/Store.js +4 -1
  44. package/es/utils/businessUtil.js +11 -0
  45. package/es/utils/coreUtil.js +23 -4
  46. package/es/utils/dataUtil.js +14 -0
  47. package/lib/assets/images/layout-icon/banner-layout1.png +0 -0
  48. package/lib/assets/images/layout-icon/banner-layout2.svg +6 -0
  49. package/lib/assets/images/layout-icon/center.png +0 -0
  50. package/lib/assets/images/layout-icon/grouped-image-layout1.png +0 -0
  51. package/lib/assets/images/layout-icon/left.png +0 -0
  52. package/lib/assets/images/layout-icon/right.png +0 -0
  53. package/lib/common/LinkModal/SelectPicture/imgs/picture-bg.png +0 -0
  54. package/lib/common/LinkModal/SelectPicture/index.js +135 -0
  55. package/lib/common/LinkModal/SelectPicture/index.less +88 -0
  56. package/lib/common/LinkModal/index.js +6 -0
  57. package/lib/common/PictureModal/index.js +37 -0
  58. package/lib/common/PictureModal/index.less +41 -0
  59. package/lib/composite-comp/bol/components/Banner/defaultJSON.js +28 -0
  60. package/lib/composite-comp/bol/components/Banner/pc/components/BannerContent.js +82 -0
  61. package/lib/composite-comp/bol/components/Banner/pc/components/SwiperBannerPc.js +270 -0
  62. package/lib/composite-comp/bol/components/Banner/pc/index.js +43 -14
  63. package/lib/composite-comp/bol/components/Banner/pc/index.less +81 -9
  64. package/lib/composite-comp/bol/config-panels/BannerConfig/index.js +26 -0
  65. package/lib/composite-comp/bol/second-config-panels/BannerSecondConfig/index.js +17 -1
  66. package/lib/composite-comp/dito/components/GroupedImage/defaultJSON.js +149 -0
  67. package/lib/composite-comp/dito/components/GroupedImage/index.js +88 -0
  68. package/lib/composite-comp/dito/components/GroupedImage/pc/index.js +417 -0
  69. package/lib/composite-comp/dito/components/GroupedImage/pc/index.less +124 -0
  70. package/lib/composite-comp/dito/components/Recommend/pc/index.js +2 -2
  71. package/lib/composite-comp/dito/components/Recommend/pc/index.less +3 -1
  72. package/lib/composite-comp/dito/config-panels/GroupedImageConfig/ConfigGroup/index.js +146 -0
  73. package/lib/composite-comp/dito/config-panels/GroupedImageConfig/imgs/defaultImg.png +0 -0
  74. package/lib/composite-comp/dito/config-panels/GroupedImageConfig/index.js +127 -0
  75. package/lib/composite-comp/dito/second-config-panels/GroupedImageSecondConfig/index.js +290 -0
  76. package/lib/composite-comp/dito/second-config-panels/GroupedImageSecondConfig/index.less +21 -0
  77. package/lib/constants/component-types.js +9 -3
  78. package/lib/constants/index.js +6 -1
  79. package/lib/constants/layout.js +30 -2
  80. package/lib/core/Designer/ConfigPanel/index.js +217 -4
  81. package/lib/core/Designer/ConfigPanel/index.less +39 -0
  82. package/lib/core/Renderer/index.js +25 -4
  83. package/lib/locale/en/en.json +1 -0
  84. package/lib/locale/es/es.json +1 -0
  85. package/lib/locale/id/id.json +1 -0
  86. package/lib/meta-comp/components/Image/index.js +15 -11
  87. package/lib/meta-comp/config-panels/ImageConfig/index.js +25 -8
  88. package/lib/mobx/Frame.js +5 -0
  89. package/lib/mobx/Store.js +4 -1
  90. package/lib/utils/businessUtil.js +11 -0
  91. package/lib/utils/coreUtil.js +23 -4
  92. package/lib/utils/dataUtil.js +14 -0
  93. package/package.json +3 -2
  94. package/es/utils/pluginsUtil.js +0 -1
  95. package/lib/utils/pluginsUtil.js +0 -1
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.groupedImageGroupSourceJSON = exports.getDefaultJSON = exports.createImageMeta = void 0;
7
+
8
+ var _uuid = require("uuid");
9
+
10
+ var __assign = void 0 && (void 0).__assign || function () {
11
+ __assign = Object.assign || function (t) {
12
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
13
+ s = arguments[i];
14
+
15
+ for (var p in s) {
16
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
17
+ }
18
+ }
19
+
20
+ return t;
21
+ };
22
+
23
+ return __assign.apply(this, arguments);
24
+ };
25
+
26
+ var createTextMeta = function createTextMeta(parentId, text, color, fontSize, fontWeight) {
27
+ if (color === void 0) {
28
+ color = '#232F46';
29
+ }
30
+
31
+ if (fontSize === void 0) {
32
+ fontSize = 14;
33
+ }
34
+
35
+ if (fontWeight === void 0) {
36
+ fontWeight = 400;
37
+ }
38
+
39
+ return {
40
+ parentId: parentId,
41
+ id: (0, _uuid.v4)(),
42
+ open: true,
43
+ type: 'TEXT',
44
+ specialContent: [],
45
+ text: text,
46
+ content: {
47
+ sizeType: 'Customize font styles',
48
+ fontFamily: 'Open Sans',
49
+ fontWeight: fontWeight,
50
+ fontSize: fontSize,
51
+ color: color
52
+ },
53
+ underline: {
54
+ open: false,
55
+ textDecorationColor: '',
56
+ textDecorationStyle: 'solid'
57
+ },
58
+ vertical: {}
59
+ };
60
+ };
61
+
62
+ var createImageMeta = function createImageMeta(parentId) {
63
+ return {
64
+ parentId: parentId,
65
+ id: (0, _uuid.v4)(),
66
+ open: true,
67
+ type: 'IMAGE',
68
+ content: {
69
+ h5Name: '',
70
+ pcName: '',
71
+ h5ImgSrc: '',
72
+ pcImgSrc: '',
73
+ clickUrl: ''
74
+ },
75
+ hover: {
76
+ open: false,
77
+ backgroundType: 'enlarge',
78
+ magnification: 1.5,
79
+ pcImgHoverUrl: '',
80
+ h5ImgHoverUrl: ''
81
+ }
82
+ };
83
+ };
84
+
85
+ exports.createImageMeta = createImageMeta;
86
+
87
+ var groupedImageGroupSourceJSON = function groupedImageGroupSourceJSON(parentId, text) {
88
+ var groupId = (0, _uuid.v4)();
89
+ var baseImage = createImageMeta(groupId);
90
+ var baseGroupName = createTextMeta(groupId, text, '#232F46', 14, 600);
91
+ return {
92
+ id: groupId,
93
+ parentId: parentId,
94
+ image: baseImage,
95
+ groupName: baseGroupName,
96
+ title: createTextMeta(groupId, 'Group Title', '#CE1126', 16, 700),
97
+ images: [createImageMeta(groupId), createImageMeta(groupId), createImageMeta(groupId), createImageMeta(groupId)],
98
+ hover: {
99
+ open: true,
100
+ image: __assign(__assign({}, createImageMeta(groupId)), {
101
+ open: false
102
+ }),
103
+ groupName: __assign(__assign({}, createTextMeta(groupId, text, '#CE1126', 14, 600)), {
104
+ open: false
105
+ })
106
+ }
107
+ };
108
+ };
109
+
110
+ exports.groupedImageGroupSourceJSON = groupedImageGroupSourceJSON;
111
+
112
+ var getDefaultJSON = function getDefaultJSON() {
113
+ var groupId = (0, _uuid.v4)();
114
+ return {
115
+ id: groupId,
116
+ type: 'GROUPED_IMAGE',
117
+ groupSource: [groupedImageGroupSourceJSON(groupId, 'Group Name'), groupedImageGroupSourceJSON(groupId, 'Group Name'), groupedImageGroupSourceJSON(groupId, 'Group Name')],
118
+ spacing: {
119
+ pc: {
120
+ paddingTop: 0,
121
+ paddingBottom: 0,
122
+ paddingLeft: 0,
123
+ paddingRight: 0,
124
+ marginBottom: window.magicDesign.compSpacing ? window.magicDesign.compSpacing * 1.5 : 48
125
+ },
126
+ mobile: {
127
+ paddingTop: 0,
128
+ paddingBottom: 0,
129
+ paddingLeft: 0,
130
+ paddingRight: 0,
131
+ marginBottom: window.magicDesign.compSpacing || 32
132
+ }
133
+ },
134
+ customize: {
135
+ layout: {
136
+ pcLayout: 'layout1',
137
+ h5Layout: 'layout1'
138
+ }
139
+ },
140
+ background: {
141
+ opacity: 100,
142
+ color: '#FFFFFF',
143
+ image: '',
144
+ bgType: 'color'
145
+ }
146
+ };
147
+ };
148
+
149
+ exports.getDefaultJSON = getDefaultJSON;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _pc = _interopRequireDefault(require("./pc"));
11
+
12
+ var _defaultJSON = require("./defaultJSON");
13
+
14
+ var _coreUtil = require("../../../../utils/coreUtil");
15
+
16
+ var _compositeDecorator = _interopRequireDefault(require("../../../../decorator/compositeDecorator"));
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
+
24
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
25
+
26
+ var __extends = void 0 && (void 0).__extends || function () {
27
+ var _extendStatics = function extendStatics(d, b) {
28
+ _extendStatics = Object.setPrototypeOf || {
29
+ __proto__: []
30
+ } instanceof Array && function (d, b) {
31
+ d.__proto__ = b;
32
+ } || function (d, b) {
33
+ for (var p in b) {
34
+ if (b.hasOwnProperty(p)) d[p] = b[p];
35
+ }
36
+ };
37
+
38
+ return _extendStatics(d, b);
39
+ };
40
+
41
+ return function (d, b) {
42
+ _extendStatics(d, b);
43
+
44
+ function __() {
45
+ this.constructor = d;
46
+ }
47
+
48
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
49
+ };
50
+ }();
51
+
52
+ var __decorate = void 0 && (void 0).__decorate || function (decorators, target, key, desc) {
53
+ var c = arguments.length,
54
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
55
+ d;
56
+ if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) {
57
+ if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
58
+ }
59
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
60
+ };
61
+
62
+ var GroupedImage =
63
+ /** @class */
64
+ function (_super) {
65
+ __extends(GroupedImage, _super);
66
+
67
+ function GroupedImage() {
68
+ return _super !== null && _super.apply(this, arguments) || this;
69
+ }
70
+
71
+ GroupedImage.prototype.render = function () {
72
+ var nodeData = this.props.nodeData;
73
+ return /*#__PURE__*/_react["default"].createElement("div", null, (0, _coreUtil.isPc)() ? /*#__PURE__*/_react["default"].createElement(_pc["default"], {
74
+ panelProps: nodeData
75
+ }) : null);
76
+ };
77
+
78
+ GroupedImage.defaultProps = {
79
+ nodeData: {}
80
+ };
81
+ GroupedImage.type = 'GROUPED_IMAGE';
82
+ GroupedImage.getDefaultJSON = _defaultJSON.getDefaultJSON;
83
+ GroupedImage = __decorate([_compositeDecorator["default"]], GroupedImage);
84
+ return GroupedImage;
85
+ }(_react.Component);
86
+
87
+ var _default = GroupedImage;
88
+ exports["default"] = _default;
@@ -0,0 +1,417 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ require("./index.less");
11
+
12
+ var _classnames = _interopRequireDefault(require("classnames"));
13
+
14
+ var _components = require("../../../../../meta-comp/components");
15
+
16
+ var _commonUtil = require("../../../../../utils/commonUtil");
17
+
18
+ var _mobx = require("../../../../../mobx");
19
+
20
+ var _Iconfont = _interopRequireDefault(require("../../../../../common/Iconfont"));
21
+
22
+ var _lodash = _interopRequireDefault(require("lodash.throttle"));
23
+
24
+ var _coreUtil = require("../../../../../utils/coreUtil");
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
+
28
+ var __extends = void 0 && (void 0).__extends || function () {
29
+ var _extendStatics = function extendStatics(d, b) {
30
+ _extendStatics = Object.setPrototypeOf || {
31
+ __proto__: []
32
+ } instanceof Array && function (d, b) {
33
+ d.__proto__ = b;
34
+ } || function (d, b) {
35
+ for (var p in b) {
36
+ if (b.hasOwnProperty(p)) d[p] = b[p];
37
+ }
38
+ };
39
+
40
+ return _extendStatics(d, b);
41
+ };
42
+
43
+ return function (d, b) {
44
+ _extendStatics(d, b);
45
+
46
+ function __() {
47
+ this.constructor = d;
48
+ }
49
+
50
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
51
+ };
52
+ }();
53
+
54
+ var GroupedImagePc =
55
+ /** @class */
56
+ function (_super) {
57
+ __extends(GroupedImagePc, _super);
58
+
59
+ function GroupedImagePc() {
60
+ var _this = _super !== null && _super.apply(this, arguments) || this;
61
+
62
+ _this.scrollRef = /*#__PURE__*/_react["default"].createRef();
63
+ _this.preGroupSource = '';
64
+ _this.state = {
65
+ tabIndex: 0,
66
+ tabLeft: 0,
67
+ tabWidth: 0,
68
+ groupSource: [],
69
+ scrollToLeftDisabled: true,
70
+ scrollToRightDisabled: true
71
+ }; // 数据迁移:将旧的image1-4迁移到images数组
72
+
73
+ _this.migrateData = function (groupSource) {
74
+ groupSource.forEach(function (group) {
75
+ // 如果存在旧的image1-4字段且没有images数组,进行迁移
76
+ if (!group.images && (group.image1 || group.image2 || group.image3 || group.image4)) {
77
+ group.images = [];
78
+ [group.image1, group.image2, group.image3, group.image4].forEach(function (img) {
79
+ if (img) {
80
+ group.images.push(img);
81
+ }
82
+ }); // 删除旧字段
83
+
84
+ delete group.image1;
85
+ delete group.image2;
86
+ delete group.image3;
87
+ delete group.image4;
88
+ } // 确保images数组存在
89
+
90
+
91
+ if (!group.images) {
92
+ group.images = [];
93
+ }
94
+ });
95
+ };
96
+
97
+ _this.initScroll = function (resetPosition) {
98
+ if (resetPosition === void 0) {
99
+ resetPosition = false;
100
+ }
101
+
102
+ setTimeout(function () {
103
+ var scrollDom = _this.scrollRef.current;
104
+
105
+ if (scrollDom) {
106
+ // 如果需要重置位置,将滚动条重置到最左边
107
+ if (resetPosition) {
108
+ // 先禁用滚动监听,避免触发状态更新
109
+ scrollDom.onscroll = null; // 使用requestAnimationFrame延迟一帧,让tab切换的视觉效果先完成
110
+
111
+ requestAnimationFrame(function () {
112
+ if (scrollDom) {
113
+ // 使用scrollTo并设置behavior为'auto',覆盖CSS的scroll-behavior: smooth
114
+ // 这样重置时不会有明显的滚动动画效果
115
+ scrollDom.scrollTo({
116
+ left: 0,
117
+ behavior: 'auto'
118
+ });
119
+ }
120
+ });
121
+ }
122
+
123
+ _this.setScrollDisabled(scrollDom);
124
+
125
+ scrollDom.onscroll = (0, _lodash["default"])(function () {
126
+ _this.setScrollDisabled(scrollDom);
127
+ }, 100);
128
+ }
129
+ }, 0);
130
+ };
131
+
132
+ _this.setScrollDisabled = function (scrollDom) {
133
+ var scrollToLeftDisabled = scrollDom.scrollLeft === 0;
134
+ var scrollToRightDisabled = scrollDom.clientWidth + scrollDom.scrollLeft >= scrollDom.scrollWidth - 1;
135
+
136
+ _this.setState({
137
+ scrollToLeftDisabled: scrollToLeftDisabled,
138
+ scrollToRightDisabled: scrollToRightDisabled
139
+ });
140
+ };
141
+
142
+ _this.initTab = function (index) {
143
+ var selectedTabDom = document.querySelector(".m-grouped-image-pc .tab-select-wrap .tabTitle:nth-child(" + (index + 1) + ")");
144
+ var tabLeft = 0;
145
+ var tabWidth = 0;
146
+
147
+ if (selectedTabDom) {
148
+ tabLeft = selectedTabDom.offsetLeft;
149
+ tabWidth = selectedTabDom.offsetWidth;
150
+ }
151
+
152
+ _this.setState({
153
+ tabLeft: tabLeft,
154
+ tabWidth: tabWidth
155
+ });
156
+ };
157
+
158
+ _this.onTabClick = function (e, index) {
159
+ var _a = _this.state,
160
+ tabIndex = _a.tabIndex,
161
+ groupSource = _a.groupSource;
162
+ if (tabIndex === index) return;
163
+ var tab = groupSource[index]; // 在切换tab之前,立即重置滚动位置到最左边,避免滚动效果
164
+
165
+ var scrollDom = _this.scrollRef.current;
166
+
167
+ if (scrollDom) {
168
+ scrollDom.onscroll = null; // 先禁用滚动监听
169
+
170
+ scrollDom.scrollLeft = 0; // 立即重置,不使用任何动画
171
+ } // 先更新本地状态,确保tabIndex立即更新
172
+
173
+
174
+ _this.setState({
175
+ tabIndex: index
176
+ }, function () {
177
+ _this.initTab(index); // 重新初始化滚动(不重置位置,因为已经重置过了)
178
+
179
+
180
+ _this.initScroll(false);
181
+ }); // 然后更新store状态,触发props更新
182
+ // 使用setTimeout确保本地状态先更新完成
183
+
184
+
185
+ setTimeout(function () {
186
+ if (tab) {
187
+ _mobx.store.setState({
188
+ clickedGroup: tab.id,
189
+ clickedFloor: _mobx.store.getFloorIdByGroupId(tab.id)
190
+ });
191
+ }
192
+ }, 0);
193
+ };
194
+
195
+ _this.scrollToRight = function () {
196
+ var scrollDom = _this.scrollRef.current;
197
+
198
+ if (scrollDom) {
199
+ var _a = _this.state,
200
+ tabIndex = _a.tabIndex,
201
+ groupSource = _a.groupSource;
202
+ var current = groupSource[tabIndex] || {};
203
+ var images = current.images || []; // 如果当前tab的图片可以滚动,则滚动图片
204
+
205
+ if (scrollDom.clientWidth + scrollDom.scrollLeft < scrollDom.scrollWidth - 1) {
206
+ scrollDom.scrollTo({
207
+ left: scrollDom.scrollLeft + scrollDom.clientWidth,
208
+ behavior: 'smooth'
209
+ });
210
+ } else {
211
+ // 否则切换到下一个tab
212
+ var nextTabIndex = (tabIndex + 1) % groupSource.length;
213
+
214
+ _this.onTabClick(null, nextTabIndex);
215
+ }
216
+ }
217
+ };
218
+
219
+ _this.scrollToLeft = function () {
220
+ var scrollDom = _this.scrollRef.current;
221
+
222
+ if (scrollDom) {
223
+ var _a = _this.state,
224
+ tabIndex = _a.tabIndex,
225
+ groupSource = _a.groupSource; // 如果当前tab的图片可以向左滚动,则滚动图片
226
+
227
+ if (scrollDom.scrollLeft > 0) {
228
+ scrollDom.scrollTo({
229
+ left: scrollDom.scrollLeft - scrollDom.clientWidth,
230
+ behavior: 'smooth'
231
+ });
232
+ } else {
233
+ // 否则切换到上一个tab
234
+ var prevTabIndex = (tabIndex - 1 + groupSource.length) % groupSource.length;
235
+
236
+ _this.onTabClick(null, prevTabIndex);
237
+ }
238
+ }
239
+ };
240
+
241
+ return _this;
242
+ }
243
+
244
+ GroupedImagePc.prototype.componentDidMount = function () {
245
+ var _this = this;
246
+
247
+ var panelProps = this.props.panelProps; // 数据迁移
248
+
249
+ this.migrateData(panelProps.groupSource);
250
+ var source = [];
251
+ panelProps.groupSource.forEach(function (m) {
252
+ var show = m.image.open || m.groupName.open;
253
+ if (show) source.push(m);
254
+ });
255
+ var groupSource = source.length > 0 ? source : panelProps.groupSource;
256
+ this.preGroupSource = JSON.stringify(groupSource);
257
+ this.setState({
258
+ groupSource: groupSource
259
+ }, function () {
260
+ _this.initTab(0);
261
+
262
+ _this.initScroll();
263
+ });
264
+ };
265
+
266
+ GroupedImagePc.prototype.componentWillReceiveProps = function (nextProps) {
267
+ var _this = this;
268
+
269
+ var tabIndex = this.state.tabIndex;
270
+ var panelProps = nextProps.panelProps; // 数据迁移
271
+
272
+ this.migrateData(panelProps.groupSource);
273
+ var source = [];
274
+ panelProps.groupSource.forEach(function (m) {
275
+ var show = m.image.open || m.groupName.open;
276
+ if (show) source.push(m);
277
+ });
278
+ var groupSource = source.length > 0 ? source : panelProps.groupSource;
279
+ var groupSourceStr = JSON.stringify(groupSource); // 只有当groupSource真正变化时才更新状态
280
+
281
+ if (groupSourceStr !== this.preGroupSource) {
282
+ this.preGroupSource = groupSourceStr;
283
+ this.setState({
284
+ groupSource: groupSource
285
+ }, function () {
286
+ // 使用当前的tabIndex,确保获取最新状态
287
+ var currentTabIndex = _this.state.tabIndex;
288
+ var newTabIndex = currentTabIndex;
289
+ if (currentTabIndex >= groupSource.length) newTabIndex = 0;
290
+
291
+ _this.initTab(newTabIndex);
292
+
293
+ _this.initScroll(); // 只有当tabIndex需要调整时才更新
294
+
295
+
296
+ if (newTabIndex !== currentTabIndex) {
297
+ _this.setState({
298
+ tabIndex: newTabIndex
299
+ });
300
+ }
301
+ });
302
+ }
303
+ };
304
+
305
+ GroupedImagePc.prototype.render = function () {
306
+ var _this = this;
307
+
308
+ var _a = this.state,
309
+ tabIndex = _a.tabIndex,
310
+ tabLeft = _a.tabLeft,
311
+ tabWidth = _a.tabWidth,
312
+ groupSource = _a.groupSource,
313
+ scrollToLeftDisabled = _a.scrollToLeftDisabled,
314
+ scrollToRightDisabled = _a.scrollToRightDisabled;
315
+ var current = groupSource[tabIndex] || {};
316
+ var images = current.images || [];
317
+
318
+ var _image = current.hover && current.hover.open && current.hover.image.open ? current.hover.image : current.image;
319
+
320
+ var _groupName = current.hover && current.hover.open && current.hover.groupName.open ? current.hover.groupName : current.groupName;
321
+
322
+ return /*#__PURE__*/_react["default"].createElement("div", {
323
+ className: (0, _classnames["default"])('m-grouped-image-pc', {
324
+ 'less-than-4': images.length <= 4
325
+ })
326
+ }, /*#__PURE__*/_react["default"].createElement("div", {
327
+ className: "tab-select-wrap"
328
+ }, groupSource.map(function (tab, index) {
329
+ var useImage = index === tabIndex && tab.hover.open && tab.hover.image.open ? tab.hover.image : tab.image;
330
+ return /*#__PURE__*/_react["default"].createElement("div", {
331
+ key: tab.id,
332
+ className: (0, _classnames["default"])('tabTitle'),
333
+ onClick: function onClick(e) {
334
+ return _this.onTabClick(e, index);
335
+ }
336
+ }, tab.image.open && useImage && /*#__PURE__*/_react["default"].createElement(_components.MetaImage, {
337
+ data: useImage
338
+ }));
339
+ })), /*#__PURE__*/_react["default"].createElement("div", {
340
+ className: "tab-content"
341
+ }, current.title && current.title.open && /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
342
+ className: "title",
343
+ data: current.title
344
+ }), /*#__PURE__*/_react["default"].createElement("div", {
345
+ className: "image-list-wrapper"
346
+ }, images.length > 0 && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
347
+ className: "image-list",
348
+ ref: this.scrollRef
349
+ }, images.map(function (img, idx) {
350
+ if (!img || !img.open) return null;
351
+ return /*#__PURE__*/_react["default"].createElement("div", {
352
+ key: (0, _commonUtil.ensure)(function () {
353
+ return img.id;
354
+ }, idx),
355
+ className: "image-item",
356
+ onClick: function onClick(e) {
357
+ // 只在设计模式下才触发联动
358
+ if (!(0, _coreUtil.isDesignMode)()) {
359
+ return;
360
+ } // 点击图片时,联动到第三级属性面板
361
+
362
+
363
+ e.stopPropagation();
364
+ e.preventDefault(); // 获取当前tab的group id和楼层id
365
+
366
+ var panelProps = _this.props.panelProps;
367
+ var currentGroupId = current.id; // panelProps.id 就是楼层ID
368
+
369
+ var floorId = panelProps.id; // 一次性设置所有需要的状态,确保联动正常
370
+
371
+ _mobx.store.setState({
372
+ clickedGroup: currentGroupId,
373
+ clickedFloor: floorId,
374
+ clickedImage: img.id
375
+ });
376
+ },
377
+ style: {
378
+ cursor: (0, _coreUtil.isDesignMode)() ? 'pointer' : 'default'
379
+ }
380
+ }, /*#__PURE__*/_react["default"].createElement(_components.MetaImage, {
381
+ data: img
382
+ }));
383
+ }))), images.length === 0 && /*#__PURE__*/_react["default"].createElement("div", {
384
+ className: "image-list"
385
+ }, /*#__PURE__*/_react["default"].createElement("div", {
386
+ className: "empty-placeholder"
387
+ }, "No images")))), /*#__PURE__*/_react["default"].createElement("div", {
388
+ className: "arrow-icon-wrapper"
389
+ }, /*#__PURE__*/_react["default"].createElement("div", {
390
+ className: (0, _classnames["default"])('arrow-icon', 'left', {
391
+ disabled: scrollToLeftDisabled && tabIndex === 0 && groupSource.length <= 1
392
+ }),
393
+ onClick: this.scrollToLeft
394
+ }, /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
395
+ color: "#fff",
396
+ size: 16,
397
+ type: "icon-outlined-left"
398
+ })), /*#__PURE__*/_react["default"].createElement("div", {
399
+ className: (0, _classnames["default"])('arrow-icon', 'right', {
400
+ disabled: scrollToRightDisabled && tabIndex === groupSource.length - 1 && groupSource.length <= 1
401
+ }),
402
+ onClick: this.scrollToRight
403
+ }, /*#__PURE__*/_react["default"].createElement(_Iconfont["default"], {
404
+ color: "#fff",
405
+ size: 16,
406
+ type: "icon-outlined-right"
407
+ }))));
408
+ };
409
+
410
+ GroupedImagePc.defaultProps = {
411
+ panelProps: {}
412
+ };
413
+ return GroupedImagePc;
414
+ }(_react["default"].Component);
415
+
416
+ var _default = GroupedImagePc;
417
+ exports["default"] = _default;