plain-design 1.0.0-beta.31 → 1.0.0-beta.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/dist/plain-design.commonjs.min.js +18 -18
  2. package/dist/plain-design.min.css +11 -6
  3. package/dist/plain-design.min.js +18 -18
  4. package/dist/report.html +38 -38
  5. package/package.json +3 -3
  6. package/src/packages/components/$previewer/ImagePreviewerFixedContainer.tsx +107 -0
  7. package/src/packages/components/$previewer/image-previewer-fixed-container.scss +18 -0
  8. package/src/packages/components/$previewer/index.tsx +52 -0
  9. package/src/packages/components/Application/service/useApplicationService.tsx +2 -0
  10. package/src/packages/components/Carousel/carousel.scss +391 -0
  11. package/src/packages/components/Carousel/index.tsx +569 -22
  12. package/src/packages/components/CarouselItem/index.tsx +77 -0
  13. package/src/packages/components/ImagePreviewer/ImagePreviewer.tsx +572 -0
  14. package/src/packages/components/ImagePreviewer/ImagePreviewerButtonBar.tsx +140 -0
  15. package/src/packages/components/ImagePreviewer/ImagePreviewerCarouselImage.tsx +54 -0
  16. package/src/packages/components/ImagePreviewer/ImagePreviewerGallery.tsx +202 -0
  17. package/src/packages/components/ImagePreviewer/PreviewerLoading.tsx +26 -0
  18. package/src/packages/components/ImagePreviewer/image-previewer.scss +244 -0
  19. package/src/packages/components/ImagePreviewer/image-previewer.utils.tsx +135 -0
  20. package/src/packages/components/ImagePreviewer/index.tsx +5 -0
  21. package/src/packages/components/ImagePreviewer/previewer-loading.scss +52 -0
  22. package/src/packages/components/Input/useMultipleInput.tsx +2 -79
  23. package/src/packages/components/Scroll/index.tsx +6 -6
  24. package/src/packages/components/SortList/index.tsx +191 -0
  25. package/src/packages/components/SortList/sort-list.scss +11 -0
  26. package/src/packages/components/StackCard/index.tsx +260 -0
  27. package/src/packages/components/StackCard/stack-card.scss +28 -0
  28. package/src/packages/components/StackCardItem/index.tsx +23 -0
  29. package/src/packages/components/Table/standard/PlcOperation/PlcOperation.tsx +1 -1
  30. package/src/packages/components/Table/standard/PlcTree/RenderPlcTreeNode.tsx +2 -1
  31. package/src/packages/components/Table/table/body/row.tsx +1 -1
  32. package/src/packages/components/Table/table/use/useTableDraggier.row.tsx +1 -1
  33. package/src/packages/components/Table/table/utils/createTableHooks.ts +1 -1
  34. package/src/packages/components/ThemeEditor/index.tsx +25 -24
  35. package/src/packages/components/Tree/RenderTreeNode.tsx +2 -1
  36. package/src/packages/components/Tree/index.tsx +2 -1
  37. package/src/packages/components/VirtualList/index.tsx +12 -3
  38. package/src/packages/components/VirtualList/useVirtualList.tsx +129 -86
  39. package/src/packages/components/VirtualList/virtual-list.scss +31 -17
  40. package/src/packages/components/VirtualTable/index.tsx +1 -1
  41. package/src/packages/entry.tsx +5 -1
  42. package/src/packages/i18n/lang/en-us.ts +36 -0
  43. package/src/packages/i18n/lang/zh-cn.ts +36 -0
  44. package/src/packages/uses/useDragHorizontalScroll.ts +82 -0
  45. package/src/packages/utils/ComponentUtils.ts +10 -0
  46. package/src/packages/utils/buildCycleIndexList.ts +31 -0
  47. package/src/packages/utils/getDeviceInfo.ts +44 -44
  48. package/src/packages/utils/getRectAutoFormat.ts +9 -0
  49. package/src/packages/utils/notNull.ts +9 -0
  50. package/src/pages/index/app.scss +1 -1
  51. package/src/pages/index/components/normal/DemoCarousel.tsx +178 -73
  52. package/src/pages/index/components/normal/DemoKeepAlive.tsx +25 -25
  53. package/src/pages/index/components/normal/DemoSortList.tsx +70 -0
  54. package/src/pages/index/components/normal/DemoStackCard.tsx +356 -0
  55. package/src/pages/index/components/normal/DemoVirtualList.tsx +89 -3
  56. package/src/pages/index/components/service/DemoImagePreviewer.tsx +185 -0
  57. package/src/pages/index/home/AppHome.tsx +18 -3
  58. package/src/pages/index/home/menus.tsx +3 -1
  59. package/src/packages/components/CarouselGroup/carousel.scss +0 -143
  60. package/src/packages/components/CarouselGroup/index.tsx +0 -274
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plain-design",
3
- "version": "1.0.0-beta.31",
3
+ "version": "1.0.0-beta.33",
4
4
  "description": "",
5
5
  "main": "dist/plain-design.min.js",
6
6
  "module": "dist/plain-design.commonjs.min.js",
@@ -19,7 +19,7 @@
19
19
  "peerDependencies": {
20
20
  "exceljs": "^4.2.1",
21
21
  "file-saver": "^2.0.5",
22
- "plain-design-composition": "^0.0.177",
22
+ "plain-design-composition": "^0.0.181",
23
23
  "react": "^18.0.1",
24
24
  "react-dom": "^18.0.1"
25
25
  },
@@ -68,7 +68,7 @@
68
68
  "fork-ts-checker-webpack-plugin": "^6.2.4",
69
69
  "mini-css-extract-plugin": "^1.4.1",
70
70
  "mockjs": "^1.1.0",
71
- "plain-design-composition": "^0.0.180",
71
+ "plain-design-composition": "^0.0.182",
72
72
  "postcss": "^8.2.13",
73
73
  "postcss-loader": "^4.2.0",
74
74
  "qs": "^6.10.1",
@@ -0,0 +1,107 @@
1
+ import {designComponent, getComponentCls, iHTMLDivElement, nextIndex, onBeforeUnmount, onMounted, PropType, reactive, useClasses, useRefs, useStyles} from "plain-design-composition";
2
+ import {getCenterRect, iImagePreviewerOption, ImagePreviewerHooks} from "../ImagePreviewer/image-previewer.utils";
3
+ import {ImagePreviewer} from "../ImagePreviewer";
4
+ import {getRectAutoFormat} from "../../utils/getRectAutoFormat";
5
+ import {unit} from "plain-utils/string/unit";
6
+ import {createEffects} from "plain-utils/utils/createEffects";
7
+ import {addElementListener} from "plain-utils/dom/addElementListener";
8
+ import {delay} from "plain-utils/utils/delay";
9
+ import './image-previewer-fixed-container.scss';
10
+
11
+ export const ImagePreviewerFixedContainer = designComponent({
12
+ name: 'image-previewer-fixed-container',
13
+ props: {
14
+ option: { type: Object as PropType<iImagePreviewerOption>, required: true }
15
+ },
16
+ setup({ props }) {
17
+
18
+ const { refs, onRef } = useRefs({ el: iHTMLDivElement });
19
+
20
+ const state = reactive({
21
+ ready: false,
22
+ });
23
+
24
+ const classes = useClasses(() => [
25
+ getComponentCls('image-previewer-fixed-container')
26
+ ]);
27
+
28
+ const styles = useStyles(style => {style.zIndex = nextIndex();});
29
+
30
+ const { effects: setupEffects } = createEffects();
31
+
32
+ onMounted(async () => {
33
+ const containerWidth = Math.floor(refs.el!.offsetWidth);
34
+ const containerHeight = Math.floor(refs.el!.offsetHeight - props.option.galleryHeight - props.option.separatorHeight);
35
+ const containerRatio = Number((containerWidth / containerHeight).toFixed(1));
36
+
37
+ const imageElement = props.option.imageElement;
38
+
39
+ if (!imageElement) {
40
+ state.ready = true;
41
+ return;
42
+ }
43
+ /**
44
+ * 如果原始imageElement存在,则创建一个影子图片元素展示过度动画
45
+ * @author 韦胜健
46
+ * @date 2024/1/5 11:22
47
+ */
48
+ const shadowImageElement = imageElement.cloneNode(true) as HTMLImageElement;
49
+ const imageElementRect = getRectAutoFormat(imageElement);
50
+ props.option.oldSourceImageOpacity = imageElement.style.opacity;
51
+ imageElement.style.opacity = "0";
52
+
53
+ shadowImageElement.style.position = 'fixed';
54
+ shadowImageElement.style.top = unit(imageElementRect.top)!;
55
+ shadowImageElement.style.left = unit(imageElementRect.left)!;
56
+ shadowImageElement.style.width = unit(imageElementRect.width)!;
57
+ shadowImageElement.style.height = unit(imageElementRect.height)!;
58
+ shadowImageElement.style.transition = 'all ease 300ms';
59
+ shadowImageElement.style.zIndex = '999999';
60
+ shadowImageElement.style.objectFit = window.getComputedStyle(imageElement).objectFit
61
+
62
+ /*开启动画时阻止页面滚动*/
63
+ setupEffects.push(
64
+ addElementListener(shadowImageElement, 'wheel', e => {
65
+ e.preventDefault();
66
+ e.stopPropagation();
67
+ })
68
+ );
69
+
70
+ const newRect = getCenterRect({ containerElement: { containerHeight, containerWidth, containerRatio }, imageElement });
71
+
72
+ document.body.appendChild(shadowImageElement);
73
+ setupEffects.push(() => {document.body.removeChild(shadowImageElement);});
74
+ await delay();
75
+ shadowImageElement.style.top = unit(newRect.top.toFixed(0))!;
76
+ shadowImageElement.style.left = unit(newRect.left.toFixed(0))!;
77
+ shadowImageElement.style.height = unit(newRect.height.toFixed(0))!;
78
+ shadowImageElement.style.width = unit(newRect.width.toFixed(0))!;
79
+ const clearListener = addElementListener(shadowImageElement, 'transitionend', () => {
80
+ state.ready = true;
81
+ const clearHook = ImagePreviewerHooks.onImagePreviewerReady.use(async (data) => {
82
+ if (data.option.id !== props.option.id) {
83
+ return;
84
+ }
85
+ await delay();
86
+ clearHook();
87
+ setupEffects.clear();
88
+ });
89
+ setupEffects.push(clearHook);
90
+ });
91
+ setupEffects.push(clearListener);
92
+ });
93
+
94
+ onBeforeUnmount(setupEffects.clear);
95
+
96
+ return () => (
97
+ <div className={classes.value} ref={onRef.el}>
98
+ {state.ready && (
99
+ <ImagePreviewer
100
+ option={props.option}
101
+ style={styles.value}
102
+ />
103
+ )}
104
+ </div>
105
+ );
106
+ },
107
+ });
@@ -0,0 +1,18 @@
1
+ @include comp(image-previewer-fixed-container) {
2
+ position: fixed;
3
+ inset: 0;
4
+
5
+ @include comp(carousel) {
6
+ position: absolute;
7
+ top: 0;
8
+ right: 0;
9
+ left: 0;
10
+ }
11
+
12
+ .image-previewer-component-gallery {
13
+ position: absolute;
14
+ bottom: 0;
15
+ left: 0;
16
+ right: 0;
17
+ }
18
+ }
@@ -0,0 +1,52 @@
1
+ import {reactive} from "plain-design-composition";
2
+ import {createImagePreviewerOption, iImagePreviewerOption, iImagePreviewerParamOption} from "../ImagePreviewer/image-previewer.utils";
3
+ import {ImagePreviewerFixedContainer} from "./ImagePreviewerFixedContainer";
4
+ import {getDeviceInfo} from "../../utils/getDeviceInfo";
5
+
6
+ /**
7
+ * 图片预览服务
8
+ * @author 韦胜健
9
+ * @date 2024/1/8 10:04
10
+ */
11
+ export const $previewer = (() => {
12
+
13
+ const state = reactive({
14
+ /*有service option不同,image previewer同时只能显示一个*/
15
+ option: null as null | iImagePreviewerOption,
16
+ });
17
+
18
+ /**
19
+ * 大图查看图片
20
+ * @author 韦胜健
21
+ * @date 2024/1/5 11:22
22
+ */
23
+ const preview = async (param: iImagePreviewerParamOption, imageElement?: HTMLImageElement) => {
24
+
25
+ const isMobile = getDeviceInfo().deviceType === 'mobile';
26
+
27
+ state.option = createImagePreviewerOption(param, imageElement, {
28
+ autoHeight: false,
29
+ mask: true,
30
+ globalKeyboardEvent: true,
31
+ button: true,
32
+ ...isMobile ? {
33
+ gallery: false,
34
+ button: false,
35
+ swipeButton: false,
36
+ galleryHeight: 0,
37
+ } : {},
38
+ });
39
+ };
40
+
41
+ const close = (optionOrId: string | iImagePreviewerOption) => {
42
+ const optionId = typeof optionOrId === "string" ? optionOrId : optionOrId.id;
43
+ if (!!state.option && state.option.id === optionId) {state.option = null;}
44
+ };
45
+
46
+ const render = () => !!state.option && <ImagePreviewerFixedContainer option={state.option}/>;
47
+
48
+ return { preview, render, close };
49
+
50
+ })();
51
+
52
+ export default $previewer;
@@ -2,6 +2,7 @@ import {getComponentCls, getCurrentDesignInstance, markRaw, onBeforeUnmount, Por
2
2
  import {defer, DFD} from 'plain-utils/utils/defer';
3
3
  import {createCounter} from "plain-utils/utils/createCounter";
4
4
  import {APPLICATION_SERVICE_CONTAINER_CLASS, ApplicationHooks} from "../utils/application.utils";
5
+ import {$previewer} from "../../$previewer";
5
6
 
6
7
  /**
7
8
  * applications渲染manager数组的时候,给manager传递的 getManagerData函数的返回值类型
@@ -104,6 +105,7 @@ export function useApplicationService() {
104
105
  render: () => (
105
106
  <Portal to="body">
106
107
  <div className={getComponentCls(APPLICATION_SERVICE_CONTAINER_CLASS)}>
108
+ {$previewer.render()}
107
109
  {state.managers.map(({ getManagerData, RenderComponent, dfd, id }, index) => {
108
110
  return (
109
111
  <RenderComponent
@@ -0,0 +1,391 @@
1
+ @include comp(carousel) {
2
+
3
+ @include comp(carousel-item) {
4
+ //transition: transform 10000ms ease;
5
+ transition: transform 300ms ease;
6
+ display: flex;
7
+ .carousel-item-inner {
8
+ flex: 1;
9
+ }
10
+ .previewer-loading {
11
+ position: absolute;
12
+ inset: 0;
13
+ display: flex;
14
+ align-items: center;
15
+ justify-content: center;
16
+ width: 100%;
17
+ height: 100%;
18
+ color: white;
19
+ font-size: 36px;
20
+ }
21
+ }
22
+
23
+ &.carousel-horizontal {
24
+ width: 100%;
25
+ overflow: hidden;
26
+ position: relative;
27
+
28
+ .carousel-container {
29
+ width: 100%;
30
+ display: flex;
31
+ align-items: stretch;
32
+ overflow: visible;
33
+ transition: transform ease 300ms;
34
+ position: relative;
35
+ z-index: 1;
36
+ }
37
+
38
+ @include comp(carousel-item) {
39
+ flex-shrink: 0;
40
+ flex-grow: 0;
41
+ width: 100%;
42
+ position: relative;
43
+
44
+ .carousel-item-inner {
45
+ transition: linear transform 300ms;
46
+ }
47
+ }
48
+
49
+ &.carousel-card {
50
+ overflow: visible;
51
+
52
+ .carousel-active {
53
+ z-index: 2;
54
+ }
55
+
56
+ .carousel-prev {
57
+ .carousel-item-inner {
58
+ transform: translateX(12%) scale(0.75);
59
+ transform-origin: right center;
60
+ }
61
+ }
62
+
63
+ .carousel-next {
64
+ .carousel-item-inner {
65
+ transform: translateX(-12%) scale(0.75);
66
+ transform-origin: left center;
67
+ }
68
+ }
69
+ }
70
+
71
+ .carousel-indicator {
72
+ position: absolute;
73
+ left: 0;
74
+ right: 0;
75
+ bottom: 0;
76
+ pointer-events: none;
77
+ display: flex;
78
+ align-items: center;
79
+ justify-content: center;
80
+ padding: 16px;
81
+ z-index: 2;
82
+ opacity: 1;
83
+ transition: all linear 99s;
84
+
85
+ & > div {
86
+ pointer-events: auto;
87
+ cursor: pointer;
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: center;
91
+ }
92
+
93
+ &.carousel-indicator-style-line {
94
+ & > div {
95
+ height: 16px;
96
+ width: 20px;
97
+ transition: all ease 300ms;
98
+
99
+ &:before {
100
+ background-color: rgba(#CECECE, 0.75);
101
+ width: 100%;
102
+ height: 2px;
103
+ content: '';
104
+ transform: skew(30deg);
105
+ }
106
+
107
+ & + div {
108
+ margin-left: 8px;
109
+ }
110
+
111
+ &.carousel-indicator-item-active {
112
+ width: 30px;
113
+
114
+ &:before {
115
+ background-color: #CECECE;
116
+ height: 4px;
117
+ }
118
+ }
119
+ }
120
+ }
121
+
122
+ &.carousel-indicator-style-dot {
123
+ & > div {
124
+ height: 16px;
125
+ width: 16px;
126
+
127
+ &:before {
128
+ background-color: rgba(#CECECE, 0.75);
129
+ transition: all ease 300ms;
130
+ border-radius: 5px;
131
+ height: 5px;
132
+ width: 5px;
133
+ content: '';
134
+ }
135
+
136
+ & + div {
137
+ margin-left: 8px;
138
+ }
139
+
140
+ &.carousel-indicator-item-active {
141
+ &:before {
142
+ background-color: #CECECE;
143
+ border-radius: 10px;
144
+ height: 10px;
145
+ width: 10px;
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ &.carousel-indicator-style-text {
152
+ left: auto;
153
+ background-color: rgba(black, 0.15);
154
+ color: white;
155
+ border-radius: 100px;
156
+ padding: 0;
157
+ min-width: 44px;
158
+ height: 28px;
159
+ text-align: center;
160
+ margin-right: 16px;
161
+ margin-bottom: 16px;
162
+ font-size: 12px;
163
+ line-height: 20px;
164
+ }
165
+ }
166
+
167
+ .carousel-switch-button {
168
+ pointer-events: none;
169
+ opacity: 1;
170
+ transition: all linear 99s;
171
+ z-index: 3;
172
+ position: absolute;
173
+ inset: 0;
174
+ display: flex;
175
+ align-items: center;
176
+ justify-content: space-between;
177
+ padding: 0 16px;
178
+
179
+ .carousel-switch-button-prev,
180
+ .carousel-switch-button-next {
181
+ height: 32px;
182
+ width: 32px;
183
+ border-radius: 32px;
184
+ display: flex;
185
+ align-items: center;
186
+ justify-content: center;
187
+ color: #f1f1f1;
188
+ pointer-events: auto;
189
+ background-color: rgba(0, 0, 0, 0.3);
190
+ cursor: pointer;
191
+
192
+ &:hover {
193
+ background-color: rgba(0, 0, 0, 0.2);
194
+ }
195
+ }
196
+ }
197
+
198
+ &.carousel-touching {
199
+ .carousel-switch-button, .carousel-indicator {
200
+ opacity: 0.99;
201
+ }
202
+ }
203
+ }
204
+
205
+ &.carousel-vertical {
206
+ width: 100%;
207
+ height: 100%;
208
+ overflow: hidden;
209
+ position: relative;
210
+
211
+ .carousel-container {
212
+ width: 100%;
213
+ height: 100%;
214
+
215
+ display: flex;
216
+ align-items: stretch;
217
+ flex-direction: column;
218
+
219
+ overflow: visible;
220
+ transition: transform ease 300ms;
221
+
222
+ @include comp(carousel-item) {
223
+ flex-shrink: 0;
224
+ flex-grow: 0;
225
+ height: 100%;
226
+ width: 100%;
227
+ position: relative;
228
+ z-index: 1;
229
+
230
+ .carousel-item-inner {
231
+ height: 100%;
232
+ transition: linear transform 300ms;
233
+ }
234
+ }
235
+ }
236
+
237
+ .carousel-indicator {
238
+ position: absolute;
239
+ top: 0;
240
+ right: 0;
241
+ bottom: 0;
242
+ pointer-events: none;
243
+ display: flex;
244
+ align-items: center;
245
+ justify-content: center;
246
+ flex-direction: column;
247
+ padding: 8px;
248
+ z-index: 2;
249
+
250
+ & > div {
251
+ pointer-events: auto;
252
+ cursor: pointer;
253
+ display: flex;
254
+ align-items: center;
255
+ justify-content: center;
256
+ }
257
+
258
+ &.carousel-indicator-style-line {
259
+ & > div {
260
+ height: 20px;
261
+ width: 16px;
262
+ transition: all ease 300ms;
263
+
264
+ &:before {
265
+ background-color: rgba(#CECECE, 0.75);
266
+ height: 100%;
267
+ width: 2px;
268
+ content: '';
269
+ transform: skewY(30deg);
270
+ transition: all ease 300ms;
271
+ }
272
+
273
+ & + div {
274
+ margin-top: 16px;
275
+ }
276
+
277
+ &.carousel-indicator-item-active {
278
+ &:before {
279
+ background-color: white;
280
+ width: 4px;
281
+ height: 30px;
282
+ }
283
+ }
284
+ }
285
+ }
286
+
287
+ &.carousel-indicator-style-dot {
288
+ & > div {
289
+ height: 4px;
290
+ width: 4px;
291
+ background-color: rgba(white, 0.45);
292
+ transition: all ease 300ms;
293
+ border-radius: 4px;
294
+
295
+ & + div {
296
+ margin-top: 8px;
297
+ }
298
+
299
+ &.carousel-indicator-item-active {
300
+ background-color: white;
301
+ height: 4px;
302
+ width: 4px;
303
+ }
304
+ }
305
+ }
306
+ }
307
+
308
+ .carousel-switch-button {
309
+ pointer-events: none;
310
+ opacity: 1;
311
+ transition: all linear 99s;
312
+ z-index: 3;
313
+ position: absolute;
314
+ inset: 0;
315
+ display: flex;
316
+ flex-direction: column;
317
+ align-items: flex-end;
318
+ justify-content: space-between;
319
+ padding: 4px;
320
+
321
+ .carousel-switch-button-prev,
322
+ .carousel-switch-button-next {
323
+ height: 24px;
324
+ width: 24px;
325
+ display: flex;
326
+ align-items: center;
327
+ justify-content: center;
328
+ color: #f1f1f1;
329
+ pointer-events: auto;
330
+ background-color: rgba(0, 0, 0, 0.3);
331
+ cursor: pointer;
332
+
333
+ &:hover {
334
+ background-color: rgba(0, 0, 0, 0.2);
335
+ }
336
+ }
337
+ }
338
+ }
339
+
340
+ &:not(.carousel-disable-swiper) {
341
+ @include comp(carousel-item) {
342
+ user-select: none;
343
+ }
344
+ }
345
+
346
+ .carousel-cover {
347
+ position: absolute;
348
+ inset: 0;
349
+ pointer-events: none;
350
+ z-index: 4;
351
+
352
+ & > * {
353
+ pointer-events: auto;
354
+ }
355
+ }
356
+
357
+ &.carousel-full-height {
358
+ height: 100%;
359
+ }
360
+
361
+ &.carousel-full-height,
362
+ &.carousel-fixed-height {
363
+ .carousel-container {
364
+ height: 100%;
365
+ }
366
+
367
+ @include comp(carousel-item) {
368
+ height: 100%;
369
+ .carousel-item-inner {
370
+ height: 100%;
371
+ }
372
+ }
373
+ }
374
+
375
+ &.carousel-large-switch-button {
376
+ .carousel-switch-button {
377
+ .carousel-switch-button-prev, .carousel-switch-button-next {
378
+ font-size: 28px;
379
+ height: auto !important;
380
+ width: auto !important;
381
+ padding: 20px 5px;
382
+ border-radius: 0;
383
+ background-color: rgba(black, 0.1);
384
+
385
+ &:hover {
386
+ background-color: rgba(black, 0.2);
387
+ }
388
+ }
389
+ }
390
+ }
391
+ }