@douyinfe/semi-foundation 2.69.0 → 2.69.1-alpha.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.
Files changed (40) hide show
  1. package/lib/cjs/resizable/foundation.d.ts +2 -5
  2. package/lib/cjs/resizable/group/index.d.ts +6 -3
  3. package/lib/cjs/resizable/group/index.js +90 -23
  4. package/lib/cjs/resizable/resizable.css +86 -0
  5. package/lib/cjs/resizable/resizable.scss +100 -3
  6. package/lib/cjs/resizable/single/index.d.ts +1 -1
  7. package/lib/cjs/resizable/single/index.js +2 -2
  8. package/lib/cjs/resizable/types.d.ts +41 -0
  9. package/lib/cjs/resizable/types.js +12 -0
  10. package/lib/cjs/resizable/utils.js +5 -5
  11. package/lib/cjs/resizable/variables.scss +8 -0
  12. package/lib/es/resizable/foundation.d.ts +2 -5
  13. package/lib/es/resizable/foundation.js +2 -3
  14. package/lib/es/resizable/group/index.d.ts +6 -3
  15. package/lib/es/resizable/group/index.js +90 -23
  16. package/lib/es/resizable/resizable.css +86 -0
  17. package/lib/es/resizable/resizable.scss +100 -3
  18. package/lib/es/resizable/single/index.d.ts +1 -1
  19. package/lib/es/resizable/single/index.js +1 -1
  20. package/lib/es/resizable/types.d.ts +41 -0
  21. package/lib/es/resizable/types.js +6 -0
  22. package/lib/es/resizable/utils.js +5 -5
  23. package/lib/es/resizable/variables.scss +8 -0
  24. package/package.json +3 -3
  25. package/resizable/foundation.ts +4 -15
  26. package/resizable/group/index.ts +92 -29
  27. package/resizable/resizable.scss +100 -3
  28. package/resizable/single/index.ts +1 -1
  29. package/resizable/{singleConstants.ts → types.ts} +0 -65
  30. package/resizable/utils.ts +7 -6
  31. package/resizable/variables.scss +8 -0
  32. package/lib/cjs/resizable/groupConstants.d.ts +0 -16
  33. package/lib/cjs/resizable/groupConstants.js +0 -25
  34. package/lib/cjs/resizable/singleConstants.d.ts +0 -105
  35. package/lib/cjs/resizable/singleConstants.js +0 -67
  36. package/lib/es/resizable/groupConstants.d.ts +0 -16
  37. package/lib/es/resizable/groupConstants.js +0 -19
  38. package/lib/es/resizable/singleConstants.d.ts +0 -105
  39. package/lib/es/resizable/singleConstants.js +0 -61
  40. package/resizable/groupConstants.ts +0 -25
@@ -1,5 +1,2 @@
1
- import { ResizableHandlerFoundation, ResizableFoundation } from './single';
2
- import { ResizeGroupFoundation, ResizeItemFoundation, ResizeHandlerFoundation } from './group';
3
- import type { ResizableHandlerAdapter, ResizableAdapter } from './single';
4
- import type { ResizeGroupAdapter, ResizeItemAdapter, ResizeHandlerAdapter } from './group';
5
- export { ResizableHandlerAdapter, ResizableHandlerFoundation, ResizableFoundation, ResizableAdapter, ResizeGroupAdapter, ResizeItemAdapter, ResizeHandlerAdapter, ResizeGroupFoundation, ResizeItemFoundation, ResizeHandlerFoundation };
1
+ export { ResizableHandlerAdapter, ResizableHandlerFoundation, ResizableFoundation, ResizableAdapter } from './single';
2
+ export { ResizeGroupAdapter, ResizeItemAdapter, ResizeHandlerAdapter, ResizeGroupFoundation, ResizeItemFoundation, ResizeHandlerFoundation } from './group';
@@ -1,5 +1,6 @@
1
+ /// <reference types="lodash" />
1
2
  import BaseFoundation, { DefaultAdapter } from '../../base/foundation';
2
- import { ResizeStartCallback, ResizeCallback } from "../singleConstants";
3
+ import { ResizeStartCallback, ResizeCallback } from "../types";
3
4
  export interface ResizeHandlerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
4
5
  registerEvents: () => void;
5
6
  unregisterEvents: () => void;
@@ -34,10 +35,11 @@ export interface ResizeGroupAdapter<P = Record<string, any>, S = Record<string,
34
35
  export declare class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<ResizeGroupAdapter<P, S>, P, S> {
35
36
  constructor(adapter: ResizeGroupAdapter<P, S>);
36
37
  get groupRef(): HTMLDivElement | null;
38
+ get groupSize(): number;
37
39
  direction: 'horizontal' | 'vertical';
38
40
  itemMinusMap: Map<number, number>;
39
41
  totalMinus: number;
40
- avaliableSize: number;
42
+ itemPercentMap: Map<number, number>;
41
43
  init(): void;
42
44
  get window(): Window | null;
43
45
  registerEvents: () => void;
@@ -45,6 +47,7 @@ export declare class ResizeGroupFoundation<P = Record<string, any>, S = Record<s
45
47
  onResizeStart: (handlerIndex: number, e: MouseEvent) => void;
46
48
  onResizing: (e: MouseEvent) => void;
47
49
  onResizeEnd: (e: MouseEvent) => void;
48
- calculateSpace: () => void;
50
+ initSpace: () => void;
51
+ ensureConstraint: import("lodash").DebouncedFunc<() => void>;
49
52
  destroy(): void;
50
53
  }
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ResizeItemFoundation = exports.ResizeHandlerFoundation = exports.ResizeGroupFoundation = void 0;
7
+ var _debounce2 = _interopRequireDefault(require("lodash/debounce"));
7
8
  var _utils = require("../utils");
8
9
  var _foundation = _interopRequireDefault(require("../../base/foundation"));
9
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -47,16 +48,18 @@ class ResizeGroupFoundation extends _foundation.default {
47
48
  // offset caused by padding and border
48
49
  const lastStyle = this.window.getComputedStyle(lastItem);
49
50
  const nextStyle = this.window.getComputedStyle(nextItem);
50
- lastOffset = (0, _utils.getOffset)(lastStyle, this.direction);
51
- nextOffset = (0, _utils.getOffset)(nextStyle, this.direction);
51
+ lastOffset = (0, _utils.getOffset)(lastStyle, this.direction) + this.itemMinusMap.get(handlerIndex);
52
+ nextOffset = (0, _utils.getOffset)(nextStyle, this.direction) + this.itemMinusMap.get(handlerIndex + 1);
53
+ let lastItemSize = (this.direction === 'horizontal' ? lastItem.offsetWidth : lastItem.offsetHeight) + this.itemMinusMap.get(handlerIndex),
54
+ nextItemSize = (this.direction === 'horizontal' ? nextItem.offsetWidth : nextItem.offsetHeight) + this.itemMinusMap.get(handlerIndex + 1);
52
55
  const states = this.getStates();
53
56
  this.setState({
54
57
  isResizing: true,
55
58
  originalPosition: {
56
59
  x: clientX,
57
60
  y: clientY,
58
- lastItemSize: this.direction === 'horizontal' ? lastItem.offsetWidth : lastItem.offsetHeight,
59
- nextItemSize: this.direction === 'horizontal' ? nextItem.offsetWidth : nextItem.offsetHeight,
61
+ lastItemSize,
62
+ nextItemSize,
60
63
  lastOffset,
61
64
  nextOffset
62
65
  },
@@ -103,28 +106,33 @@ class ResizeGroupFoundation extends _foundation.default {
103
106
  } = props;
104
107
  let lastItem = this._adapter.getItem(curHandler),
105
108
  nextItem = this._adapter.getItem(curHandler + 1);
106
- let parentSize = this.direction === 'horizontal' ? this.groupRef.offsetWidth : this.groupRef.offsetHeight;
107
- let availableSize = parentSize - this.totalMinus;
109
+ let parentSize = this.groupSize;
108
110
  let delta = direction === 'horizontal' ? clientX - initX : clientY - initY;
109
111
  let lastNewSize = lastItemSize + delta;
110
112
  let nextNewSize = nextItemSize - delta;
111
113
  // 判断是否超出限制
112
- let lastFlag = (0, _utils.judgeConstraint)(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), availableSize, lastOffset),
113
- nextFlag = (0, _utils.judgeConstraint)(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), availableSize, nextOffset);
114
+ let lastFlag = (0, _utils.judgeConstraint)(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), parentSize, lastOffset),
115
+ nextFlag = (0, _utils.judgeConstraint)(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), parentSize, nextOffset);
114
116
  if (lastFlag) {
115
- lastNewSize = (0, _utils.adjustNewSize)(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), availableSize, lastOffset);
117
+ lastNewSize = (0, _utils.adjustNewSize)(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), parentSize, lastOffset);
116
118
  nextNewSize = lastItemSize + nextItemSize - lastNewSize;
117
119
  }
118
120
  if (nextFlag) {
119
- nextNewSize = (0, _utils.adjustNewSize)(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), availableSize, nextOffset);
121
+ nextNewSize = (0, _utils.adjustNewSize)(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), parentSize, nextOffset);
120
122
  lastNewSize = lastItemSize + nextItemSize - nextNewSize;
121
123
  }
124
+ let lastItemPercent = this.itemPercentMap.get(curHandler),
125
+ nextItemPercent = this.itemPercentMap.get(curHandler + 1);
126
+ let lastNewPercent = lastNewSize / parentSize * 100;
127
+ let nextNewPercent = lastItemPercent + nextItemPercent - lastNewPercent; // 消除浮点误差
128
+ this.itemPercentMap.set(curHandler, lastNewPercent);
129
+ this.itemPercentMap.set(curHandler + 1, nextNewPercent);
122
130
  if (direction === 'horizontal') {
123
- lastItem.style.width = lastNewSize / parentSize * 100 + '%';
124
- nextItem.style.width = nextNewSize / parentSize * 100 + '%';
131
+ lastItem.style.width = `calc(${lastNewPercent}% - ${this.itemMinusMap.get(curHandler)}px)`;
132
+ nextItem.style.width = `calc(${nextNewPercent}% - ${this.itemMinusMap.get(curHandler + 1)}px)`;
125
133
  } else if (direction === 'vertical') {
126
- lastItem.style.height = lastNewSize / parentSize * 100 + '%';
127
- nextItem.style.height = nextNewSize / parentSize * 100 + '%';
134
+ lastItem.style.height = `calc(${lastNewPercent}% - ${this.itemMinusMap.get(curHandler)}px)`;
135
+ nextItem.style.height = `calc(${nextNewPercent}% - ${this.itemMinusMap.get(curHandler + 1)}px)`;
128
136
  }
129
137
  let lastFunc = this._adapter.getItemChange(curHandler),
130
138
  nextFunc = this._adapter.getItemChange(curHandler + 1);
@@ -169,14 +177,14 @@ class ResizeGroupFoundation extends _foundation.default {
169
177
  });
170
178
  this.unregisterEvents();
171
179
  };
172
- this.calculateSpace = () => {
180
+ this.initSpace = () => {
173
181
  const props = this.getProps();
174
182
  const {
175
183
  direction
176
184
  } = props;
177
185
  // calculate accurate space for group item
178
186
  let handlerSizes = new Array(this._adapter.getHandlerCount()).fill(0);
179
- let groupSize = direction === 'horizontal' ? this.groupRef.offsetWidth : this.groupRef.offsetHeight;
187
+ let parentSize = this.groupSize;
180
188
  this.totalMinus = 0;
181
189
  for (let i = 0; i < this._adapter.getHandlerCount(); i++) {
182
190
  let handlerSize = direction === 'horizontal' ? this._adapter.getHandler(i).offsetWidth : this._adapter.getHandler(i).offsetHeight;
@@ -198,8 +206,8 @@ class ResizeGroupFoundation extends _foundation.default {
198
206
  const child = this._adapter.getItem(i);
199
207
  let minSize = this._adapter.getItemMin(i),
200
208
  maxSize = this._adapter.getItemMax(i);
201
- let minSizePercent = minSize ? (0, _utils.getPixelSize)(minSize, groupSize) / groupSize * 100 : 0,
202
- maxSizePercent = maxSize ? (0, _utils.getPixelSize)(maxSize, groupSize) / groupSize * 100 : 100;
209
+ let minSizePercent = minSize ? (0, _utils.getPixelSize)(minSize, parentSize) / parentSize * 100 : 0,
210
+ maxSizePercent = maxSize ? (0, _utils.getPixelSize)(maxSize, parentSize) / parentSize * 100 : 100;
203
211
  if (minSizePercent > maxSizePercent) {
204
212
  console.warn('[Semi ResizableItem]: min size bigger than max size');
205
213
  }
@@ -209,15 +217,17 @@ class ResizeGroupFoundation extends _foundation.default {
209
217
  if (typeof defaultSize === 'string') {
210
218
  if (defaultSize.endsWith('%')) {
211
219
  itemSizePercent = parseFloat(defaultSize.slice(0, -1));
220
+ this.itemPercentMap.set(i, itemSizePercent);
212
221
  } else if (defaultSize.endsWith('px')) {
213
- itemSizePercent = parseFloat(defaultSize.slice(0, -2)) / groupSize * 100;
222
+ itemSizePercent = parseFloat(defaultSize.slice(0, -2)) / parentSize * 100;
223
+ this.itemPercentMap.set(i, itemSizePercent);
214
224
  } else if (/^-?\d+(\.\d+)?$/.test(defaultSize)) {
215
225
  // 仅由数字组成,表示按比例分配剩下空间
216
226
  undefineLoc.set(i, parseFloat(defaultSize));
217
227
  undefinedTotal += parseFloat(defaultSize);
218
228
  continue;
219
229
  }
220
- } else {
230
+ } else if (typeof defaultSize === 'number') {
221
231
  undefineLoc.set(i, defaultSize);
222
232
  undefinedTotal += defaultSize;
223
233
  continue;
@@ -246,21 +256,78 @@ class ResizeGroupFoundation extends _foundation.default {
246
256
  }
247
257
  undefineLoc.forEach((value, key) => {
248
258
  const child = this._adapter.getItem(key);
259
+ const percent = value / undefinedTotal * undefineSizePercent;
260
+ this.itemPercentMap.set(key, percent);
249
261
  if (direction === 'horizontal') {
250
- child.style.width = `calc(${undefineSizePercent / undefinedTotal * value}% - ${this.itemMinusMap.get(key)}px)`;
262
+ child.style.width = `calc(${percent}% - ${this.itemMinusMap.get(key)}px)`;
251
263
  } else {
252
- child.style.height = `calc(${undefineSizePercent / undefinedTotal * value}% - ${this.itemMinusMap.get(key)}px)`;
264
+ child.style.height = `calc(${percent}% - ${this.itemMinusMap.get(key)}px)`;
253
265
  }
254
266
  });
255
267
  };
268
+ this.ensureConstraint = (0, _debounce2.default)(() => {
269
+ // 浏览器拖拽时保证px值最大最小仍生效
270
+ const {
271
+ direction
272
+ } = this.getProps();
273
+ const itemCount = this._adapter.getItemCount();
274
+ let continueFlag = true;
275
+ for (let i = 0; i < itemCount; i++) {
276
+ const child = this._adapter.getItem(i);
277
+ const childSize = direction === 'horizontal' ? child.offsetWidth : child.offsetHeight;
278
+ // 判断由非鼠标拖拽导致item的size变化过程中是否有超出限制的情况
279
+ const childFlag = (0, _utils.judgeConstraint)(childSize, this._adapter.getItemMin(i), this._adapter.getItemMax(i), this.groupSize, this.itemMinusMap.get(i));
280
+ if (childFlag) {
281
+ const childNewSize = (0, _utils.adjustNewSize)(childSize, this._adapter.getItemMin(i), this._adapter.getItemMax(i), this.groupSize, this.itemMinusMap.get(i));
282
+ for (let j = i + 1; j < itemCount; j++) {
283
+ // 找到下一个没有超出限制的item
284
+ const item = this._adapter.getItem(j);
285
+ const itemSize = direction === 'horizontal' ? item.offsetWidth : item.offsetHeight;
286
+ const itemFlag = (0, _utils.judgeConstraint)(itemSize, this._adapter.getItemMin(j), this._adapter.getItemMax(j), this.groupSize, this.itemMinusMap.get(j));
287
+ if (!itemFlag) {
288
+ let childPercent = this.itemPercentMap.get(i),
289
+ itemPercent = this.itemPercentMap.get(j);
290
+ let childNewPercent = childNewSize / this.groupSize * 100;
291
+ let itemNewPercent = childPercent + itemPercent - childNewPercent;
292
+ this.itemPercentMap.set(i, childNewPercent);
293
+ this.itemPercentMap.set(j, itemNewPercent);
294
+ if (direction === 'horizontal') {
295
+ child.style.width = `calc(${childNewPercent}% - ${this.itemMinusMap.get(i)}px)`;
296
+ item.style.width = `calc(${itemNewPercent}% - ${this.itemMinusMap.get(j)}px)`;
297
+ } else {
298
+ child.style.height = `calc(${childNewPercent}% - ${this.itemMinusMap.get(i)}px)`;
299
+ item.style.height = `calc(${itemNewPercent}% - ${this.itemMinusMap.get(j)}px)`;
300
+ }
301
+ break;
302
+ } else {
303
+ if (j === itemCount - 1) {
304
+ continueFlag = false;
305
+ console.warn('[Semi ResizableGroup]: no enough space to adjust min/max size');
306
+ }
307
+ }
308
+ }
309
+ }
310
+ if (!continueFlag) {
311
+ break;
312
+ }
313
+ }
314
+ }, 200);
256
315
  }
257
316
  get groupRef() {
258
317
  return this._adapter.getGroupRef();
259
318
  }
319
+ get groupSize() {
320
+ const {
321
+ direction
322
+ } = this.getProps();
323
+ let groupSize = direction === 'horizontal' ? this.groupRef.offsetWidth : this.groupRef.offsetHeight;
324
+ return groupSize;
325
+ }
260
326
  init() {
261
327
  this.direction = this.getProp('direction');
262
328
  this.itemMinusMap = new Map();
263
- this.calculateSpace();
329
+ this.itemPercentMap = new Map();
330
+ this.initSpace();
264
331
  }
265
332
  get window() {
266
333
  var _a;
@@ -11,6 +11,72 @@
11
11
  user-select: none;
12
12
  z-index: 2000;
13
13
  }
14
+ .semi-resizable-resizableHandler-top {
15
+ width: 100%;
16
+ height: 10px;
17
+ top: 0;
18
+ left: 0;
19
+ cursor: row-resize;
20
+ top: -5px;
21
+ }
22
+ .semi-resizable-resizableHandler-right {
23
+ width: 10px;
24
+ height: 100%;
25
+ top: 0;
26
+ left: 0;
27
+ cursor: col-resize;
28
+ left: auto;
29
+ right: -5px;
30
+ }
31
+ .semi-resizable-resizableHandler-bottom {
32
+ width: 100%;
33
+ height: 10px;
34
+ top: 0;
35
+ left: 0;
36
+ cursor: row-resize;
37
+ top: auto;
38
+ bottom: -5px;
39
+ }
40
+ .semi-resizable-resizableHandler-left {
41
+ width: 10px;
42
+ height: 100%;
43
+ top: 0;
44
+ left: 0;
45
+ cursor: col-resize;
46
+ left: -5px;
47
+ }
48
+ .semi-resizable-resizableHandler-topRight {
49
+ width: 20px;
50
+ height: 20px;
51
+ position: absolute;
52
+ right: -10px;
53
+ top: -10px;
54
+ cursor: ne-resize;
55
+ }
56
+ .semi-resizable-resizableHandler-bottomRight {
57
+ width: 20px;
58
+ height: 20px;
59
+ position: absolute;
60
+ right: -10px;
61
+ bottom: -10px;
62
+ cursor: se-resize;
63
+ }
64
+ .semi-resizable-resizableHandler-bottomLeft {
65
+ width: 20px;
66
+ height: 20px;
67
+ position: absolute;
68
+ left: -10px;
69
+ bottom: -10px;
70
+ cursor: sw-resize;
71
+ }
72
+ .semi-resizable-resizableHandler-topLeft {
73
+ width: 20px;
74
+ height: 20px;
75
+ position: absolute;
76
+ left: -10px;
77
+ top: -10px;
78
+ cursor: nw-resize;
79
+ }
14
80
  .semi-resizable-group {
15
81
  display: flex;
16
82
  position: relative;
@@ -31,4 +97,24 @@
31
97
  justify-content: center;
32
98
  background-color: var(--semi-color-fill-0);
33
99
  opacity: 1;
100
+ }
101
+ .semi-resizable-handler-vertical {
102
+ width: 100%;
103
+ height: 10px;
104
+ flex-shrink: 0;
105
+ cursor: row-resize;
106
+ }
107
+ .semi-resizable-handler-horizontal {
108
+ height: 100%;
109
+ width: 10px;
110
+ flex-shrink: 0;
111
+ cursor: col-resize;
112
+ }
113
+ .semi-resizable-background {
114
+ height: 100%;
115
+ width: 100%;
116
+ inset: 0;
117
+ z-index: 2010;
118
+ opacity: 0;
119
+ position: fixed;
34
120
  }
@@ -1,5 +1,4 @@
1
- @import './variables.scss';
2
-
1
+ @import "./variables.scss";
3
2
  $module: #{$prefix}-resizable;
4
3
 
5
4
  .#{$module} {
@@ -13,8 +12,83 @@ $module: #{$prefix}-resizable;
13
12
  position: absolute;
14
13
  user-select: none;
15
14
  z-index: $z-resizable_handler;
15
+
16
+ // 基础样式
17
+ @mixin row-resize-base {
18
+ width: 100%;
19
+ height: $height-row-handler;
20
+ top: 0;
21
+ left: 0;
22
+ cursor: row-resize;
23
+ }
24
+
25
+ @mixin col-resize-base {
26
+ width: $width-col-handler;
27
+ height: 100%;
28
+ top: 0;
29
+ left: 0;
30
+ cursor: col-resize;
31
+ }
32
+
33
+ @mixin edge-resize-base {
34
+ width: $width-edge-handler;
35
+ height: $height-edge-handler;
36
+ position: absolute;
37
+ }
38
+
39
+ // 方向样式
40
+ &-top {
41
+ @include row-resize-base;
42
+ top: calc(-1 * $height-row-handler / 2);
43
+ }
44
+
45
+ &-right {
46
+ @include col-resize-base;
47
+ left: auto;
48
+ right: calc(-1 * $width-col-handler / 2);
49
+ }
50
+
51
+ &-bottom {
52
+ @include row-resize-base;
53
+ top: auto;
54
+ bottom: calc(-1 * $height-row-handler / 2);
55
+ }
56
+
57
+ &-left {
58
+ @include col-resize-base;
59
+ left: calc(-1 * $width-col-handler / 2);
60
+ }
61
+
62
+ // 边角样式
63
+ &-topRight {
64
+ @include edge-resize-base;
65
+ right: calc(-1 * $width-edge-handler / 2);
66
+ top: calc(-1 * $height-edge-handler / 2);
67
+ cursor: ne-resize;
68
+ }
69
+
70
+ &-bottomRight {
71
+ @include edge-resize-base;
72
+ right: calc(-1 * $width-edge-handler / 2);
73
+ bottom: calc(-1 * $height-edge-handler / 2);
74
+ cursor: se-resize;
75
+ }
76
+
77
+ &-bottomLeft {
78
+ @include edge-resize-base;
79
+ left: calc(-1 * $width-edge-handler / 2);
80
+ bottom: calc(-1 * $height-edge-handler / 2);
81
+ cursor: sw-resize;
82
+ }
83
+
84
+ &-topLeft {
85
+ @include edge-resize-base;
86
+ left: calc(-1 * $width-edge-handler / 2);
87
+ top: calc(-1 * $height-edge-handler / 2);
88
+ cursor: nw-resize;
89
+ }
16
90
  }
17
-
91
+
18
92
  &-group {
19
93
  display: flex;
20
94
  position: relative;
@@ -37,5 +111,28 @@ $module: #{$prefix}-resizable;
37
111
  justify-content: center;
38
112
  background-color: var(--semi-color-fill-0);
39
113
  opacity: 1;
114
+
115
+ &-vertical {
116
+ width: 100%;
117
+ height: $height-vertical-handler;
118
+ flex-shrink: 0;
119
+ cursor: row-resize;
120
+ }
121
+
122
+ &-horizontal {
123
+ height: 100%;
124
+ width: $width-horizontal-handler;
125
+ flex-shrink: 0;
126
+ cursor: col-resize;
127
+ }
128
+ }
129
+
130
+ &-background {
131
+ height: 100%;
132
+ width: 100%;
133
+ inset: 0;
134
+ z-index: $z-resizable_background;
135
+ opacity: 0;
136
+ position: fixed;
40
137
  }
41
138
  }
@@ -1,5 +1,5 @@
1
1
  import BaseFoundation, { DefaultAdapter } from '../../base/foundation';
2
- import { Size, NumberSize, Direction } from "../singleConstants";
2
+ import { Size, NumberSize, Direction } from "../types";
3
3
  export interface ResizableHandlerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
4
4
  registerEvent: () => void;
5
5
  unregisterEvent: () => void;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ResizableHandlerFoundation = exports.ResizableFoundation = void 0;
7
7
  var _foundation = _interopRequireDefault(require("../../base/foundation"));
8
- var _singleConstants = require("../singleConstants");
8
+ var _types = require("../types");
9
9
  var _utils = require("../utils");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
11
  class ResizableHandlerFoundation extends _foundation.default {
@@ -303,7 +303,7 @@ class ResizableFoundation extends _foundation.default {
303
303
  }
304
304
  get propSize() {
305
305
  const porps = this.getProps();
306
- return porps.size || porps.defaultSize || _singleConstants.DEFAULT_SIZE;
306
+ return porps.size || porps.defaultSize || _types.DEFAULT_SIZE;
307
307
  }
308
308
  get size() {
309
309
  let width = 0;
@@ -0,0 +1,41 @@
1
+ export declare const directions: readonly ["top", "right", "bottom", "left", "topRight", "bottomRight", "bottomLeft", "topLeft"];
2
+ export type Direction = 'top' | 'right' | 'bottom' | 'left' | 'topRight' | 'bottomRight' | 'bottomLeft' | 'topLeft';
3
+ export interface HandleClassName {
4
+ top?: string;
5
+ right?: string;
6
+ bottom?: string;
7
+ left?: string;
8
+ topRight?: string;
9
+ bottomRight?: string;
10
+ bottomLeft?: string;
11
+ topLeft?: string;
12
+ }
13
+ export type HandlerCallback = (e: MouseEvent, direction: Direction) => void;
14
+ export interface Enable {
15
+ top?: boolean;
16
+ right?: boolean;
17
+ bottom?: boolean;
18
+ left?: boolean;
19
+ topRight?: boolean;
20
+ bottomRight?: boolean;
21
+ bottomLeft?: boolean;
22
+ topLeft?: boolean;
23
+ }
24
+ export interface Size {
25
+ width?: string | number;
26
+ height?: string | number;
27
+ }
28
+ export interface NumberSize {
29
+ width: number;
30
+ height: number;
31
+ }
32
+ export interface NewSize {
33
+ newHeight: number | string;
34
+ newWidth: number | string;
35
+ }
36
+ export declare const DEFAULT_SIZE: {
37
+ width: string;
38
+ height: string;
39
+ };
40
+ export type ResizeCallback = (size: Size, event: MouseEvent, direction: Direction) => void;
41
+ export type ResizeStartCallback = (e: MouseEvent, dir: Direction) => void | boolean;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.directions = exports.DEFAULT_SIZE = void 0;
7
+ // single
8
+ const directions = exports.directions = ['top', 'right', 'bottom', 'left', 'topRight', 'bottomRight', 'bottomLeft', 'topLeft'];
9
+ const DEFAULT_SIZE = exports.DEFAULT_SIZE = {
10
+ width: 'auto',
11
+ height: 'auto'
12
+ };
@@ -101,10 +101,10 @@ const judgeConstraint = function (newSize, min, max, parentSize) {
101
101
  max = max !== null && max !== void 0 ? max : "100%";
102
102
  const minSize = getPixelSize(min, parentSize);
103
103
  const maxSize = getPixelSize(max, parentSize);
104
- if (newSize <= minSize + offset) {
104
+ if (newSize < minSize + offset) {
105
105
  return true;
106
106
  }
107
- if (newSize >= maxSize - offset) {
107
+ if (newSize > maxSize) {
108
108
  return true;
109
109
  }
110
110
  return false;
@@ -115,11 +115,11 @@ const adjustNewSize = (newSize, min, max, parentSize, offset) => {
115
115
  max = max !== null && max !== void 0 ? max : "100%";
116
116
  const minSize = getPixelSize(min, parentSize);
117
117
  const maxSize = getPixelSize(max, parentSize);
118
- if (newSize <= minSize + offset) {
118
+ if (newSize < minSize + offset) {
119
119
  return minSize + offset;
120
120
  }
121
- if (newSize >= maxSize - offset) {
122
- return maxSize - offset;
121
+ if (newSize > maxSize) {
122
+ return maxSize;
123
123
  }
124
124
  return newSize;
125
125
  };
@@ -1 +1,9 @@
1
1
  $z-resizable_handler: 2000 !default; // 伸缩框组件中handler的z-index
2
+ $z-resizable_background: 2010; // 伸缩框组件中背景的z-index
3
+
4
+ $height-row-handler: 10px; // 单个伸缩框中上下handler的高度
5
+ $width-col-handler: 10px; // 单个伸缩框中左右handler的宽度
6
+ $width-edge-handler: 20px; // 单个伸缩框中边角handler的宽度
7
+ $height-edge-handler: 20px; // 单个伸缩框中边角handler的高度
8
+ $width-horizontal-handler: 10px; // 组合伸缩框中水平方向handler的宽度
9
+ $height-vertical-handler: 10px; // 组合伸缩框中垂直方向handler的高度
@@ -1,5 +1,2 @@
1
- import { ResizableHandlerFoundation, ResizableFoundation } from './single';
2
- import { ResizeGroupFoundation, ResizeItemFoundation, ResizeHandlerFoundation } from './group';
3
- import type { ResizableHandlerAdapter, ResizableAdapter } from './single';
4
- import type { ResizeGroupAdapter, ResizeItemAdapter, ResizeHandlerAdapter } from './group';
5
- export { ResizableHandlerAdapter, ResizableHandlerFoundation, ResizableFoundation, ResizableAdapter, ResizeGroupAdapter, ResizeItemAdapter, ResizeHandlerAdapter, ResizeGroupFoundation, ResizeItemFoundation, ResizeHandlerFoundation };
1
+ export { ResizableHandlerAdapter, ResizableHandlerFoundation, ResizableFoundation, ResizableAdapter } from './single';
2
+ export { ResizeGroupAdapter, ResizeItemAdapter, ResizeHandlerAdapter, ResizeGroupFoundation, ResizeItemFoundation, ResizeHandlerFoundation } from './group';
@@ -1,3 +1,2 @@
1
- import { ResizableHandlerFoundation, ResizableFoundation } from './single';
2
- import { ResizeGroupFoundation, ResizeItemFoundation, ResizeHandlerFoundation } from './group';
3
- export { ResizableHandlerFoundation, ResizableFoundation, ResizeGroupFoundation, ResizeItemFoundation, ResizeHandlerFoundation };
1
+ export { ResizableHandlerFoundation, ResizableFoundation } from './single';
2
+ export { ResizeGroupFoundation, ResizeItemFoundation, ResizeHandlerFoundation } from './group';
@@ -1,5 +1,6 @@
1
+ /// <reference types="lodash" />
1
2
  import BaseFoundation, { DefaultAdapter } from '../../base/foundation';
2
- import { ResizeStartCallback, ResizeCallback } from "../singleConstants";
3
+ import { ResizeStartCallback, ResizeCallback } from "../types";
3
4
  export interface ResizeHandlerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
4
5
  registerEvents: () => void;
5
6
  unregisterEvents: () => void;
@@ -34,10 +35,11 @@ export interface ResizeGroupAdapter<P = Record<string, any>, S = Record<string,
34
35
  export declare class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<ResizeGroupAdapter<P, S>, P, S> {
35
36
  constructor(adapter: ResizeGroupAdapter<P, S>);
36
37
  get groupRef(): HTMLDivElement | null;
38
+ get groupSize(): number;
37
39
  direction: 'horizontal' | 'vertical';
38
40
  itemMinusMap: Map<number, number>;
39
41
  totalMinus: number;
40
- avaliableSize: number;
42
+ itemPercentMap: Map<number, number>;
41
43
  init(): void;
42
44
  get window(): Window | null;
43
45
  registerEvents: () => void;
@@ -45,6 +47,7 @@ export declare class ResizeGroupFoundation<P = Record<string, any>, S = Record<s
45
47
  onResizeStart: (handlerIndex: number, e: MouseEvent) => void;
46
48
  onResizing: (e: MouseEvent) => void;
47
49
  onResizeEnd: (e: MouseEvent) => void;
48
- calculateSpace: () => void;
50
+ initSpace: () => void;
51
+ ensureConstraint: import("lodash").DebouncedFunc<() => void>;
49
52
  destroy(): void;
50
53
  }