@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,7 +1,8 @@
1
1
  import { getItemDirection, getPixelSize } from "../utils";
2
2
  import BaseFoundation, { DefaultAdapter } from '../../base/foundation';
3
- import { ResizeStartCallback, ResizeCallback } from "../singleConstants";
3
+ import { ResizeStartCallback, ResizeCallback } from "../types";
4
4
  import { adjustNewSize, judgeConstraint, getOffset } from "../utils";
5
+ import { debounce } from "lodash";
5
6
  export interface ResizeHandlerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
6
7
  registerEvents: () => void;
7
8
  unregisterEvents: () => void
@@ -61,16 +62,23 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
61
62
  return this._adapter.getGroupRef();
62
63
  }
63
64
 
65
+ get groupSize(): number {
66
+ const { direction } = this.getProps();
67
+ let groupSize = direction === 'horizontal' ? this.groupRef.offsetWidth : this.groupRef.offsetHeight;
68
+ return groupSize;
69
+ }
70
+
64
71
  direction: 'horizontal' | 'vertical'
65
- itemMinusMap: Map<number, number>;
72
+ itemMinusMap: Map<number, number>; // 这个是为了给handler留出空间,方便维护每一个item的size为cal(percent% - minus)
66
73
  totalMinus: number;
67
- avaliableSize: number;
74
+ itemPercentMap: Map<number, number>; // 内部维护一个百分比数组,消除浮点计算误差
68
75
 
69
76
 
70
77
  init(): void {
71
78
  this.direction = this.getProp('direction');
72
79
  this.itemMinusMap = new Map();
73
- this.calculateSpace();
80
+ this.itemPercentMap = new Map();
81
+ this.initSpace();
74
82
  }
75
83
  get window(): Window | null {
76
84
  return this.groupRef.ownerDocument.defaultView as Window ?? null;
@@ -93,16 +101,18 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
93
101
  const lastStyle = this.window.getComputedStyle(lastItem);
94
102
  const nextStyle = this.window.getComputedStyle(nextItem);
95
103
 
96
- lastOffset = getOffset(lastStyle, this.direction);
97
- nextOffset = getOffset(nextStyle, this.direction);
104
+ lastOffset = getOffset(lastStyle, this.direction) + this.itemMinusMap.get(handlerIndex);
105
+ nextOffset = getOffset(nextStyle, this.direction) + this.itemMinusMap.get(handlerIndex + 1);
106
+ let lastItemSize = (this.direction === 'horizontal' ? lastItem.offsetWidth : lastItem.offsetHeight) + this.itemMinusMap.get(handlerIndex),
107
+ nextItemSize = (this.direction === 'horizontal' ? nextItem.offsetWidth : nextItem.offsetHeight) + this.itemMinusMap.get(handlerIndex + 1);
98
108
  const states = this.getStates();
99
109
  this.setState({
100
110
  isResizing: true,
101
111
  originalPosition: {
102
112
  x: clientX,
103
113
  y: clientY,
104
- lastItemSize: (this.direction === 'horizontal' ? lastItem.offsetWidth : lastItem.offsetHeight),
105
- nextItemSize: (this.direction === 'horizontal' ? nextItem.offsetWidth : nextItem.offsetHeight),
114
+ lastItemSize,
115
+ nextItemSize,
106
116
  lastOffset,
107
117
  nextOffset,
108
118
  },
@@ -138,33 +148,38 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
138
148
  const props = this.getProps();
139
149
  const { direction } = props;
140
150
  let lastItem = this._adapter.getItem(curHandler), nextItem = this._adapter.getItem(curHandler + 1);
141
- let parentSize = this.direction === 'horizontal' ? this.groupRef.offsetWidth : this.groupRef.offsetHeight;
142
- let availableSize = parentSize - this.totalMinus;
143
-
151
+ let parentSize = this.groupSize;
144
152
  let delta = direction === 'horizontal' ? (clientX - initX) : (clientY - initY);
145
153
  let lastNewSize = lastItemSize + delta;
146
154
  let nextNewSize = nextItemSize - delta;
147
155
 
148
156
  // 判断是否超出限制
149
- let lastFlag = judgeConstraint(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), availableSize, lastOffset),
150
- nextFlag = judgeConstraint(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), availableSize, nextOffset);
157
+ let lastFlag = judgeConstraint(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), parentSize, lastOffset),
158
+ nextFlag = judgeConstraint(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), parentSize, nextOffset);
151
159
 
152
160
  if (lastFlag) {
153
- lastNewSize = adjustNewSize(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), availableSize, lastOffset);
161
+ lastNewSize = adjustNewSize(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), parentSize, lastOffset);
154
162
  nextNewSize = lastItemSize + nextItemSize - lastNewSize;
155
163
  }
156
164
 
157
165
  if (nextFlag) {
158
- nextNewSize = adjustNewSize(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), availableSize, nextOffset);
166
+ nextNewSize = adjustNewSize(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), parentSize, nextOffset);
159
167
  lastNewSize = lastItemSize + nextItemSize - nextNewSize;
160
168
  }
161
169
 
170
+ let lastItemPercent = this.itemPercentMap.get(curHandler),
171
+ nextItemPercent = this.itemPercentMap.get(curHandler + 1);
172
+
173
+ let lastNewPercent = (lastNewSize) / parentSize * 100;
174
+ let nextNewPercent = lastItemPercent + nextItemPercent - lastNewPercent; // 消除浮点误差
175
+ this.itemPercentMap.set(curHandler, lastNewPercent);
176
+ this.itemPercentMap.set(curHandler + 1, nextNewPercent);
162
177
  if (direction === 'horizontal') {
163
- lastItem.style.width = (lastNewSize) / parentSize * 100 + '%';
164
- nextItem.style.width = (nextNewSize) / parentSize * 100 + '%';
178
+ lastItem.style.width = `calc(${lastNewPercent}% - ${this.itemMinusMap.get(curHandler)}px)`;
179
+ nextItem.style.width = `calc(${nextNewPercent}% - ${this.itemMinusMap.get(curHandler + 1)}px)`;
165
180
  } else if (direction === 'vertical') {
166
- lastItem.style.height = (lastNewSize) / parentSize * 100 + '%';
167
- nextItem.style.height = (nextNewSize) / parentSize * 100 + '%';
181
+ lastItem.style.height = `calc(${lastNewPercent}% - ${this.itemMinusMap.get(curHandler)}px)`;
182
+ nextItem.style.height = `calc(${nextNewPercent}% - ${this.itemMinusMap.get(curHandler + 1)}px)`;
168
183
  }
169
184
 
170
185
  let lastFunc = this._adapter.getItemChange(curHandler),
@@ -197,13 +212,13 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
197
212
  this.unregisterEvents();
198
213
  }
199
214
 
200
- calculateSpace = () => {
215
+ initSpace = () => {
201
216
  const props = this.getProps();
202
217
  const { direction } = props;
203
218
 
204
219
  // calculate accurate space for group item
205
220
  let handlerSizes = new Array(this._adapter.getHandlerCount()).fill(0);
206
- let groupSize = direction === 'horizontal' ? this.groupRef.offsetWidth : this.groupRef.offsetHeight;
221
+ let parentSize = this.groupSize;
207
222
  this.totalMinus = 0;
208
223
  for (let i = 0; i < this._adapter.getHandlerCount(); i++) {
209
224
  let handlerSize = direction === 'horizontal' ? this._adapter.getHandler(i).offsetWidth : this._adapter.getHandler(i).offsetHeight;
@@ -225,8 +240,8 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
225
240
  }
226
241
  const child = this._adapter.getItem(i);
227
242
  let minSize = this._adapter.getItemMin(i), maxSize = this._adapter.getItemMax(i);
228
- let minSizePercent = minSize ? getPixelSize(minSize, groupSize) / groupSize * 100 : 0,
229
- maxSizePercent = maxSize ? getPixelSize(maxSize, groupSize) / groupSize * 100 : 100;
243
+ let minSizePercent = minSize ? getPixelSize(minSize, parentSize) / parentSize * 100 : 0,
244
+ maxSizePercent = maxSize ? getPixelSize(maxSize, parentSize) / parentSize * 100 : 100;
230
245
  if (minSizePercent > maxSizePercent) {
231
246
  console.warn('[Semi ResizableItem]: min size bigger than max size');
232
247
  }
@@ -237,21 +252,21 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
237
252
  if (typeof defaultSize === 'string') {
238
253
  if (defaultSize.endsWith('%')) {
239
254
  itemSizePercent = parseFloat(defaultSize.slice(0, -1));
255
+ this.itemPercentMap.set(i, itemSizePercent);
240
256
  } else if (defaultSize.endsWith('px')) {
241
- itemSizePercent = parseFloat(defaultSize.slice(0, -2)) / groupSize * 100;
257
+ itemSizePercent = parseFloat(defaultSize.slice(0, -2)) / parentSize * 100;
258
+ this.itemPercentMap.set(i, itemSizePercent);
242
259
  } else if (/^-?\d+(\.\d+)?$/.test(defaultSize)) {
243
260
  // 仅由数字组成,表示按比例分配剩下空间
244
261
  undefineLoc.set(i, parseFloat(defaultSize));
245
262
  undefinedTotal += parseFloat(defaultSize);
246
263
  continue;
247
264
  }
248
- } else {
265
+ } else if (typeof defaultSize === 'number') {
249
266
  undefineLoc.set(i, defaultSize);
250
267
  undefinedTotal += defaultSize;
251
268
  continue;
252
269
  }
253
-
254
-
255
270
  totalSizePercent += itemSizePercent;
256
271
 
257
272
  if (direction === 'horizontal') {
@@ -279,14 +294,62 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
279
294
 
280
295
  undefineLoc.forEach((value, key) => {
281
296
  const child = this._adapter.getItem(key);
297
+ const percent = value / undefinedTotal * undefineSizePercent;
298
+ this.itemPercentMap.set(key, percent);
282
299
  if (direction === 'horizontal') {
283
- child.style.width = `calc(${undefineSizePercent / undefinedTotal * value}% - ${this.itemMinusMap.get(key)}px)`;
300
+ child.style.width = `calc(${percent}% - ${this.itemMinusMap.get(key)}px)`;
284
301
  } else {
285
- child.style.height = `calc(${undefineSizePercent / undefinedTotal * value}% - ${this.itemMinusMap.get(key)}px)`;
302
+ child.style.height = `calc(${percent}% - ${this.itemMinusMap.get(key)}px)`;
286
303
  }
287
304
  });
288
305
  }
289
306
 
307
+ ensureConstraint = debounce(() => {
308
+ // 浏览器拖拽时保证px值最大最小仍生效
309
+ const { direction } = this.getProps();
310
+ const itemCount = this._adapter.getItemCount();
311
+ let continueFlag = true;
312
+ for (let i = 0; i < itemCount; i++) {
313
+ const child = this._adapter.getItem(i);
314
+ const childSize = direction === 'horizontal' ? child.offsetWidth : child.offsetHeight;
315
+ // 判断由非鼠标拖拽导致item的size变化过程中是否有超出限制的情况
316
+ const childFlag = judgeConstraint(childSize, this._adapter.getItemMin(i), this._adapter.getItemMax(i), this.groupSize, this.itemMinusMap.get(i));
317
+ if (childFlag) {
318
+ const childNewSize = adjustNewSize(childSize, this._adapter.getItemMin(i), this._adapter.getItemMax(i), this.groupSize, this.itemMinusMap.get(i));
319
+ for (let j = i + 1; j < itemCount; j++) {
320
+ // 找到下一个没有超出限制的item
321
+ const item = this._adapter.getItem(j);
322
+ const itemSize = direction === 'horizontal' ? item.offsetWidth : item.offsetHeight;
323
+ const itemFlag = judgeConstraint(itemSize, this._adapter.getItemMin(j), this._adapter.getItemMax(j), this.groupSize, this.itemMinusMap.get(j));
324
+ if (!itemFlag) {
325
+ let childPercent = this.itemPercentMap.get(i),
326
+ itemPercent = this.itemPercentMap.get(j);
327
+ let childNewPercent = childNewSize / this.groupSize * 100;
328
+ let itemNewPercent = childPercent + itemPercent - childNewPercent;
329
+ this.itemPercentMap.set(i, childNewPercent);
330
+ this.itemPercentMap.set(j, itemNewPercent);
331
+ if (direction === 'horizontal') {
332
+ child.style.width = `calc(${childNewPercent}% - ${this.itemMinusMap.get(i)}px)`;
333
+ item.style.width = `calc(${itemNewPercent}% - ${this.itemMinusMap.get(j)}px)`;
334
+ } else {
335
+ child.style.height = `calc(${childNewPercent}% - ${this.itemMinusMap.get(i)}px)`;
336
+ item.style.height = `calc(${itemNewPercent}% - ${this.itemMinusMap.get(j)}px)`;
337
+ }
338
+ break;
339
+ } else {
340
+ if (j === itemCount - 1) {
341
+ continueFlag = false;
342
+ console.warn('[Semi ResizableGroup]: no enough space to adjust min/max size');
343
+ }
344
+ }
345
+ }
346
+ }
347
+ if (!continueFlag) {
348
+ break;
349
+ }
350
+ }
351
+ }, 200)
352
+
290
353
  destroy(): void {
291
354
 
292
355
  }
@@ -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 { DEFAULT_SIZE, Size, NumberSize, Direction, NewSize } from "../singleConstants";
2
+ import { DEFAULT_SIZE, Size, NumberSize, Direction, NewSize } from "../types";
3
3
  import { getStringSize, getNumberSize, has, calculateNewMax, findNextSnap, snap, clamp } from "../utils";
4
4
  export interface ResizableHandlerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
5
5
  registerEvent: () => void;
@@ -1,71 +1,6 @@
1
1
  // single
2
- const rowStyleBase = {
3
- width: '100%',
4
- height: '10px',
5
- top: '0px',
6
- left: '0px',
7
- cursor: 'row-resize',
8
- } as const;
9
- const colStyleBase = {
10
- width: '10px',
11
- height: '100%',
12
- top: '0px',
13
- left: '0px',
14
- cursor: 'col-resize',
15
- } as const;
16
- const edgeStyleBase = {
17
- width: '20px',
18
- height: '20px',
19
- position: 'absolute',
20
- } as const;
21
-
22
2
  export const directions = ['top', 'right', 'bottom', 'left', 'topRight', 'bottomRight', 'bottomLeft', 'topLeft'] as const;
23
3
 
24
- export const directionStyles = {
25
- top: {
26
- ...rowStyleBase,
27
- top: '-5px',
28
- },
29
- right: {
30
- ...colStyleBase,
31
- left: undefined,
32
- right: '-5px',
33
- },
34
- bottom: {
35
- ...rowStyleBase,
36
- top: undefined,
37
- bottom: '-5px',
38
- },
39
- left: {
40
- ...colStyleBase,
41
- left: '-5px',
42
- },
43
- topRight: {
44
- ...edgeStyleBase,
45
- right: '-10px',
46
- top: '-10px',
47
- cursor: 'ne-resize',
48
- },
49
- bottomRight: {
50
- ...edgeStyleBase,
51
- right: '-10px',
52
- bottom: '-10px',
53
- cursor: 'se-resize',
54
- },
55
- bottomLeft: {
56
- ...edgeStyleBase,
57
- left: '-10px',
58
- bottom: '-10px',
59
- cursor: 'sw-resize',
60
- },
61
- topLeft: {
62
- ...edgeStyleBase,
63
- left: '-10px',
64
- top: '-10px',
65
- cursor: 'nw-resize',
66
- },
67
- } as const;
68
-
69
4
  export type Direction = 'top' | 'right' | 'bottom' | 'left' | 'topRight' | 'bottomRight' | 'bottomLeft' | 'topLeft';
70
5
 
71
6
  export interface HandleClassName {
@@ -80,7 +80,8 @@ export const calculateNewMax = (
80
80
  minWidth,
81
81
  minHeight,
82
82
  };
83
- };export const getItemDirection = (dir: 'vertical' | 'horizontal') => {
83
+ };
84
+ export const getItemDirection = (dir: 'vertical' | 'horizontal') => {
84
85
  if (dir === 'vertical') {
85
86
  return ['bottom', 'top'];
86
87
  } else {
@@ -104,10 +105,10 @@ export const judgeConstraint = (newSize: number, min: string, max: string, paren
104
105
  max = max ?? "100%";
105
106
  const minSize = getPixelSize(min, parentSize);
106
107
  const maxSize = getPixelSize(max, parentSize);
107
- if (newSize <= minSize + offset) {
108
+ if (newSize < minSize + offset) {
108
109
  return true;
109
110
  }
110
- if (newSize >= maxSize - offset) {
111
+ if (newSize > maxSize) {
111
112
  return true;
112
113
  }
113
114
  return false;
@@ -118,11 +119,11 @@ export const adjustNewSize = (newSize: number, min: string, max: string, parentS
118
119
  max = max ?? "100%";
119
120
  const minSize = getPixelSize(min, parentSize);
120
121
  const maxSize = getPixelSize(max, parentSize);
121
- if (newSize <= minSize + offset) {
122
+ if (newSize < minSize + offset) {
122
123
  return minSize + offset;
123
124
  }
124
- if (newSize >= maxSize - offset) {
125
- return maxSize - offset;
125
+ if (newSize > maxSize) {
126
+ return maxSize;
126
127
  }
127
128
  return newSize;
128
129
  };
@@ -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,16 +0,0 @@
1
- export declare const directionStyles: {
2
- readonly horizontal: {
3
- readonly width: "8px";
4
- readonly flexShrink: 0;
5
- readonly height: "100%";
6
- readonly margin: "0";
7
- readonly cursor: "col-resize";
8
- };
9
- readonly vertical: {
10
- readonly width: "100%";
11
- readonly height: "8px";
12
- readonly flexShrink: 0;
13
- readonly margin: "0";
14
- readonly cursor: "row-resize";
15
- };
16
- };
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.directionStyles = void 0;
7
- // group
8
- const rowStyleBase = {
9
- width: '100%',
10
- height: '8px',
11
- flexShrink: 0,
12
- margin: '0',
13
- cursor: 'row-resize'
14
- };
15
- const colStyleBase = {
16
- width: '8px',
17
- flexShrink: 0,
18
- height: '100%',
19
- margin: '0',
20
- cursor: 'col-resize'
21
- };
22
- const directionStyles = exports.directionStyles = {
23
- horizontal: Object.assign({}, colStyleBase),
24
- vertical: Object.assign({}, rowStyleBase)
25
- };
@@ -1,105 +0,0 @@
1
- export declare const directions: readonly ["top", "right", "bottom", "left", "topRight", "bottomRight", "bottomLeft", "topLeft"];
2
- export declare const directionStyles: {
3
- readonly top: {
4
- readonly top: "-5px";
5
- readonly width: "100%";
6
- readonly height: "10px";
7
- readonly left: "0px";
8
- readonly cursor: "row-resize";
9
- };
10
- readonly right: {
11
- readonly left: any;
12
- readonly right: "-5px";
13
- readonly width: "10px";
14
- readonly height: "100%";
15
- readonly top: "0px";
16
- readonly cursor: "col-resize";
17
- };
18
- readonly bottom: {
19
- readonly top: any;
20
- readonly bottom: "-5px";
21
- readonly width: "100%";
22
- readonly height: "10px";
23
- readonly left: "0px";
24
- readonly cursor: "row-resize";
25
- };
26
- readonly left: {
27
- readonly left: "-5px";
28
- readonly width: "10px";
29
- readonly height: "100%";
30
- readonly top: "0px";
31
- readonly cursor: "col-resize";
32
- };
33
- readonly topRight: {
34
- readonly right: "-10px";
35
- readonly top: "-10px";
36
- readonly cursor: "ne-resize";
37
- readonly width: "20px";
38
- readonly height: "20px";
39
- readonly position: "absolute";
40
- };
41
- readonly bottomRight: {
42
- readonly right: "-10px";
43
- readonly bottom: "-10px";
44
- readonly cursor: "se-resize";
45
- readonly width: "20px";
46
- readonly height: "20px";
47
- readonly position: "absolute";
48
- };
49
- readonly bottomLeft: {
50
- readonly left: "-10px";
51
- readonly bottom: "-10px";
52
- readonly cursor: "sw-resize";
53
- readonly width: "20px";
54
- readonly height: "20px";
55
- readonly position: "absolute";
56
- };
57
- readonly topLeft: {
58
- readonly left: "-10px";
59
- readonly top: "-10px";
60
- readonly cursor: "nw-resize";
61
- readonly width: "20px";
62
- readonly height: "20px";
63
- readonly position: "absolute";
64
- };
65
- };
66
- export type Direction = 'top' | 'right' | 'bottom' | 'left' | 'topRight' | 'bottomRight' | 'bottomLeft' | 'topLeft';
67
- export interface HandleClassName {
68
- top?: string;
69
- right?: string;
70
- bottom?: string;
71
- left?: string;
72
- topRight?: string;
73
- bottomRight?: string;
74
- bottomLeft?: string;
75
- topLeft?: string;
76
- }
77
- export type HandlerCallback = (e: MouseEvent, direction: Direction) => void;
78
- export interface Enable {
79
- top?: boolean;
80
- right?: boolean;
81
- bottom?: boolean;
82
- left?: boolean;
83
- topRight?: boolean;
84
- bottomRight?: boolean;
85
- bottomLeft?: boolean;
86
- topLeft?: boolean;
87
- }
88
- export interface Size {
89
- width?: string | number;
90
- height?: string | number;
91
- }
92
- export interface NumberSize {
93
- width: number;
94
- height: number;
95
- }
96
- export interface NewSize {
97
- newHeight: number | string;
98
- newWidth: number | string;
99
- }
100
- export declare const DEFAULT_SIZE: {
101
- width: string;
102
- height: string;
103
- };
104
- export type ResizeCallback = (size: Size, event: MouseEvent, direction: Direction) => void;
105
- export type ResizeStartCallback = (e: MouseEvent, dir: Direction) => void | boolean;