@douyinfe/semi-foundation 2.69.1-alpha.0 → 2.69.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/datePicker/yearAndMonthFoundation.ts +29 -9
- package/lib/cjs/datePicker/yearAndMonthFoundation.js +39 -8
- package/lib/cjs/resizable/foundation.d.ts +5 -2
- package/lib/cjs/resizable/group/index.d.ts +3 -6
- package/lib/cjs/resizable/group/index.js +23 -90
- package/lib/cjs/resizable/groupConstants.d.ts +16 -0
- package/lib/cjs/resizable/groupConstants.js +25 -0
- package/lib/cjs/resizable/resizable.css +0 -86
- package/lib/cjs/resizable/resizable.scss +3 -100
- package/lib/cjs/resizable/single/index.d.ts +1 -1
- package/lib/cjs/resizable/single/index.js +2 -2
- package/lib/cjs/resizable/singleConstants.d.ts +105 -0
- package/lib/cjs/resizable/singleConstants.js +67 -0
- package/lib/cjs/resizable/utils.js +5 -5
- package/lib/cjs/resizable/variables.scss +0 -8
- package/lib/es/datePicker/yearAndMonthFoundation.js +39 -8
- package/lib/es/resizable/foundation.d.ts +5 -2
- package/lib/es/resizable/foundation.js +3 -2
- package/lib/es/resizable/group/index.d.ts +3 -6
- package/lib/es/resizable/group/index.js +23 -90
- package/lib/es/resizable/groupConstants.d.ts +16 -0
- package/lib/es/resizable/groupConstants.js +19 -0
- package/lib/es/resizable/resizable.css +0 -86
- package/lib/es/resizable/resizable.scss +3 -100
- package/lib/es/resizable/single/index.d.ts +1 -1
- package/lib/es/resizable/single/index.js +1 -1
- package/lib/es/resizable/singleConstants.d.ts +105 -0
- package/lib/es/resizable/singleConstants.js +61 -0
- package/lib/es/resizable/utils.js +5 -5
- package/lib/es/resizable/variables.scss +0 -8
- package/package.json +3 -3
- package/resizable/foundation.ts +15 -4
- package/resizable/group/index.ts +29 -92
- package/resizable/groupConstants.ts +25 -0
- package/resizable/resizable.scss +3 -100
- package/resizable/single/index.ts +1 -1
- package/resizable/{types.ts → singleConstants.ts} +65 -0
- package/resizable/utils.ts +6 -7
- package/resizable/variables.scss +0 -8
- package/lib/cjs/resizable/types.d.ts +0 -41
- package/lib/cjs/resizable/types.js +0 -12
- package/lib/es/resizable/types.d.ts +0 -41
- package/lib/es/resizable/types.js +0 -6
|
@@ -105,9 +105,9 @@ export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthA
|
|
|
105
105
|
const month = copy(currentMonth);
|
|
106
106
|
month[panelType] = item.month;
|
|
107
107
|
|
|
108
|
-
//
|
|
108
|
+
// Make sure the time on the right panel is always greater than or equal to the time on the left panel
|
|
109
109
|
if (type === 'monthRange' && panelType === left && currentYear[left] === currentYear[right] && item.value > month[right]) {
|
|
110
|
-
month[right] = item.month
|
|
110
|
+
month[right] = item.month ;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
this._adapter.setCurrentMonth(month);
|
|
@@ -121,8 +121,19 @@ export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthA
|
|
|
121
121
|
const { disabledDate, locale } = this._adapter.getProps();
|
|
122
122
|
const { months, currentMonth } = this._adapter.getStates();
|
|
123
123
|
|
|
124
|
+
const oppositeType = panelType === strings.PANEL_TYPE_LEFT ? 'right' : 'left';
|
|
125
|
+
|
|
124
126
|
const currentDate = setYear(Date.now(), item.year);
|
|
125
127
|
const isCurrentMonthDisabled = disabledDate(setMonth(currentDate, currentMonth[panelType] - 1));
|
|
128
|
+
// whether the date on the opposite is legal
|
|
129
|
+
const isOppositeMonthDisabled = disabledDate(setMonth(setYear(Date.now(), year[oppositeType]), currentMonth[oppositeType] - 1));
|
|
130
|
+
|
|
131
|
+
if (!isCurrentMonthDisabled && !isOppositeMonthDisabled) {
|
|
132
|
+
// all panel Date is legal
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
let finalYear = year;
|
|
136
|
+
let finalMonth = currentMonth;
|
|
126
137
|
if (isCurrentMonthDisabled) {
|
|
127
138
|
const currentIndex = months.findIndex(({ month }) => month === currentMonth[panelType]);
|
|
128
139
|
let validMonth: typeof months[number];
|
|
@@ -131,15 +142,24 @@ export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthA
|
|
|
131
142
|
if (!validMonth) {
|
|
132
143
|
validMonth = months.slice(0, currentIndex).find(({ month }) => !disabledDate(setMonth(currentDate, month - 1)));
|
|
133
144
|
}
|
|
134
|
-
if (validMonth) {
|
|
135
|
-
|
|
136
|
-
month
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
if (validMonth && !isOppositeMonthDisabled) {
|
|
146
|
+
// only currentPanel Date is illegal
|
|
147
|
+
// just need to modify the month of the current panel
|
|
148
|
+
finalMonth[panelType] = validMonth.month;
|
|
149
|
+
} else if (validMonth && isOppositeMonthDisabled) {
|
|
150
|
+
// all panel Date is illegal
|
|
151
|
+
// change the value to the legal value calculated by the current panel
|
|
152
|
+
finalYear = { 'left': item.year, 'right': item.year };
|
|
153
|
+
finalMonth = { 'left': validMonth.month, 'right': validMonth.month };
|
|
141
154
|
}
|
|
155
|
+
} else if (!isCurrentMonthDisabled && isOppositeMonthDisabled) {
|
|
156
|
+
// only opposite panel Date is illegal
|
|
157
|
+
// change the value to the legal value in the current panel
|
|
158
|
+
finalYear = { 'left': item.year, 'right': item.year };
|
|
159
|
+
finalMonth = { 'left': currentMonth[panelType], 'right': currentMonth[panelType] };
|
|
142
160
|
}
|
|
161
|
+
this._adapter.setCurrentYearAndMonth(finalYear, finalMonth);
|
|
162
|
+
this._adapter.notifySelectYearAndMonth(finalYear, finalMonth);
|
|
143
163
|
}
|
|
144
164
|
|
|
145
165
|
backToMain() {
|
|
@@ -55,9 +55,9 @@ class YearAndMonthFoundation extends _foundation.default {
|
|
|
55
55
|
const right = _constants.strings.PANEL_TYPE_RIGHT;
|
|
56
56
|
const month = (0, _fastCopy.default)(currentMonth);
|
|
57
57
|
month[panelType] = item.month;
|
|
58
|
-
//
|
|
58
|
+
// Make sure the time on the right panel is always greater than or equal to the time on the left panel
|
|
59
59
|
if (type === 'monthRange' && panelType === left && currentYear[left] === currentYear[right] && item.value > month[right]) {
|
|
60
|
-
month[right] = item.month
|
|
60
|
+
month[right] = item.month;
|
|
61
61
|
}
|
|
62
62
|
this._adapter.setCurrentMonth(month);
|
|
63
63
|
this._adapter.notifySelectMonth(month);
|
|
@@ -74,8 +74,17 @@ class YearAndMonthFoundation extends _foundation.default {
|
|
|
74
74
|
months,
|
|
75
75
|
currentMonth
|
|
76
76
|
} = this._adapter.getStates();
|
|
77
|
+
const oppositeType = panelType === _constants.strings.PANEL_TYPE_LEFT ? 'right' : 'left';
|
|
77
78
|
const currentDate = (0, _dateFns.setYear)(Date.now(), item.year);
|
|
78
79
|
const isCurrentMonthDisabled = disabledDate((0, _dateFns.setMonth)(currentDate, currentMonth[panelType] - 1));
|
|
80
|
+
// whether the date on the opposite is legal
|
|
81
|
+
const isOppositeMonthDisabled = disabledDate((0, _dateFns.setMonth)((0, _dateFns.setYear)(Date.now(), year[oppositeType]), currentMonth[oppositeType] - 1));
|
|
82
|
+
if (!isCurrentMonthDisabled && !isOppositeMonthDisabled) {
|
|
83
|
+
// all panel Date is legal
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
let finalYear = year;
|
|
87
|
+
let finalMonth = currentMonth;
|
|
79
88
|
if (isCurrentMonthDisabled) {
|
|
80
89
|
const currentIndex = months.findIndex(_ref => {
|
|
81
90
|
let {
|
|
@@ -99,14 +108,36 @@ class YearAndMonthFoundation extends _foundation.default {
|
|
|
99
108
|
return !disabledDate((0, _dateFns.setMonth)(currentDate, month - 1));
|
|
100
109
|
});
|
|
101
110
|
}
|
|
102
|
-
if (validMonth) {
|
|
103
|
-
|
|
104
|
-
month
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
111
|
+
if (validMonth && !isOppositeMonthDisabled) {
|
|
112
|
+
// only currentPanel Date is illegal
|
|
113
|
+
// just need to modify the month of the current panel
|
|
114
|
+
finalMonth[panelType] = validMonth.month;
|
|
115
|
+
} else if (validMonth && isOppositeMonthDisabled) {
|
|
116
|
+
// all panel Date is illegal
|
|
117
|
+
// change the value to the legal value calculated by the current panel
|
|
118
|
+
finalYear = {
|
|
119
|
+
'left': item.year,
|
|
120
|
+
'right': item.year
|
|
121
|
+
};
|
|
122
|
+
finalMonth = {
|
|
123
|
+
'left': validMonth.month,
|
|
124
|
+
'right': validMonth.month
|
|
125
|
+
};
|
|
108
126
|
}
|
|
127
|
+
} else if (!isCurrentMonthDisabled && isOppositeMonthDisabled) {
|
|
128
|
+
// only opposite panel Date is illegal
|
|
129
|
+
// change the value to the legal value in the current panel
|
|
130
|
+
finalYear = {
|
|
131
|
+
'left': item.year,
|
|
132
|
+
'right': item.year
|
|
133
|
+
};
|
|
134
|
+
finalMonth = {
|
|
135
|
+
'left': currentMonth[panelType],
|
|
136
|
+
'right': currentMonth[panelType]
|
|
137
|
+
};
|
|
109
138
|
}
|
|
139
|
+
this._adapter.setCurrentYearAndMonth(finalYear, finalMonth);
|
|
140
|
+
this._adapter.notifySelectYearAndMonth(finalYear, finalMonth);
|
|
110
141
|
}
|
|
111
142
|
backToMain() {
|
|
112
143
|
this._adapter.notifyBackToMain();
|
|
@@ -1,2 +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,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import BaseFoundation, { DefaultAdapter } from '../../base/foundation';
|
|
3
|
-
import { ResizeStartCallback, ResizeCallback } from "../
|
|
2
|
+
import { ResizeStartCallback, ResizeCallback } from "../singleConstants";
|
|
4
3
|
export interface ResizeHandlerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
5
4
|
registerEvents: () => void;
|
|
6
5
|
unregisterEvents: () => void;
|
|
@@ -35,11 +34,10 @@ export interface ResizeGroupAdapter<P = Record<string, any>, S = Record<string,
|
|
|
35
34
|
export declare class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<ResizeGroupAdapter<P, S>, P, S> {
|
|
36
35
|
constructor(adapter: ResizeGroupAdapter<P, S>);
|
|
37
36
|
get groupRef(): HTMLDivElement | null;
|
|
38
|
-
get groupSize(): number;
|
|
39
37
|
direction: 'horizontal' | 'vertical';
|
|
40
38
|
itemMinusMap: Map<number, number>;
|
|
41
39
|
totalMinus: number;
|
|
42
|
-
|
|
40
|
+
avaliableSize: number;
|
|
43
41
|
init(): void;
|
|
44
42
|
get window(): Window | null;
|
|
45
43
|
registerEvents: () => void;
|
|
@@ -47,7 +45,6 @@ export declare class ResizeGroupFoundation<P = Record<string, any>, S = Record<s
|
|
|
47
45
|
onResizeStart: (handlerIndex: number, e: MouseEvent) => void;
|
|
48
46
|
onResizing: (e: MouseEvent) => void;
|
|
49
47
|
onResizeEnd: (e: MouseEvent) => void;
|
|
50
|
-
|
|
51
|
-
ensureConstraint: import("lodash").DebouncedFunc<() => void>;
|
|
48
|
+
calculateSpace: () => void;
|
|
52
49
|
destroy(): void;
|
|
53
50
|
}
|
|
@@ -4,7 +4,6 @@ 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"));
|
|
8
7
|
var _utils = require("../utils");
|
|
9
8
|
var _foundation = _interopRequireDefault(require("../../base/foundation"));
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -48,18 +47,16 @@ class ResizeGroupFoundation extends _foundation.default {
|
|
|
48
47
|
// offset caused by padding and border
|
|
49
48
|
const lastStyle = this.window.getComputedStyle(lastItem);
|
|
50
49
|
const nextStyle = this.window.getComputedStyle(nextItem);
|
|
51
|
-
lastOffset = (0, _utils.getOffset)(lastStyle, this.direction)
|
|
52
|
-
nextOffset = (0, _utils.getOffset)(nextStyle, this.direction)
|
|
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);
|
|
50
|
+
lastOffset = (0, _utils.getOffset)(lastStyle, this.direction);
|
|
51
|
+
nextOffset = (0, _utils.getOffset)(nextStyle, this.direction);
|
|
55
52
|
const states = this.getStates();
|
|
56
53
|
this.setState({
|
|
57
54
|
isResizing: true,
|
|
58
55
|
originalPosition: {
|
|
59
56
|
x: clientX,
|
|
60
57
|
y: clientY,
|
|
61
|
-
lastItemSize,
|
|
62
|
-
nextItemSize,
|
|
58
|
+
lastItemSize: this.direction === 'horizontal' ? lastItem.offsetWidth : lastItem.offsetHeight,
|
|
59
|
+
nextItemSize: this.direction === 'horizontal' ? nextItem.offsetWidth : nextItem.offsetHeight,
|
|
63
60
|
lastOffset,
|
|
64
61
|
nextOffset
|
|
65
62
|
},
|
|
@@ -106,33 +103,28 @@ class ResizeGroupFoundation extends _foundation.default {
|
|
|
106
103
|
} = props;
|
|
107
104
|
let lastItem = this._adapter.getItem(curHandler),
|
|
108
105
|
nextItem = this._adapter.getItem(curHandler + 1);
|
|
109
|
-
let parentSize = this.
|
|
106
|
+
let parentSize = this.direction === 'horizontal' ? this.groupRef.offsetWidth : this.groupRef.offsetHeight;
|
|
107
|
+
let availableSize = parentSize - this.totalMinus;
|
|
110
108
|
let delta = direction === 'horizontal' ? clientX - initX : clientY - initY;
|
|
111
109
|
let lastNewSize = lastItemSize + delta;
|
|
112
110
|
let nextNewSize = nextItemSize - delta;
|
|
113
111
|
// 判断是否超出限制
|
|
114
|
-
let lastFlag = (0, _utils.judgeConstraint)(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler),
|
|
115
|
-
nextFlag = (0, _utils.judgeConstraint)(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1),
|
|
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);
|
|
116
114
|
if (lastFlag) {
|
|
117
|
-
lastNewSize = (0, _utils.adjustNewSize)(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler),
|
|
115
|
+
lastNewSize = (0, _utils.adjustNewSize)(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), availableSize, lastOffset);
|
|
118
116
|
nextNewSize = lastItemSize + nextItemSize - lastNewSize;
|
|
119
117
|
}
|
|
120
118
|
if (nextFlag) {
|
|
121
|
-
nextNewSize = (0, _utils.adjustNewSize)(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1),
|
|
119
|
+
nextNewSize = (0, _utils.adjustNewSize)(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), availableSize, nextOffset);
|
|
122
120
|
lastNewSize = lastItemSize + nextItemSize - nextNewSize;
|
|
123
121
|
}
|
|
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);
|
|
130
122
|
if (direction === 'horizontal') {
|
|
131
|
-
lastItem.style.width =
|
|
132
|
-
nextItem.style.width =
|
|
123
|
+
lastItem.style.width = lastNewSize / parentSize * 100 + '%';
|
|
124
|
+
nextItem.style.width = nextNewSize / parentSize * 100 + '%';
|
|
133
125
|
} else if (direction === 'vertical') {
|
|
134
|
-
lastItem.style.height =
|
|
135
|
-
nextItem.style.height =
|
|
126
|
+
lastItem.style.height = lastNewSize / parentSize * 100 + '%';
|
|
127
|
+
nextItem.style.height = nextNewSize / parentSize * 100 + '%';
|
|
136
128
|
}
|
|
137
129
|
let lastFunc = this._adapter.getItemChange(curHandler),
|
|
138
130
|
nextFunc = this._adapter.getItemChange(curHandler + 1);
|
|
@@ -177,14 +169,14 @@ class ResizeGroupFoundation extends _foundation.default {
|
|
|
177
169
|
});
|
|
178
170
|
this.unregisterEvents();
|
|
179
171
|
};
|
|
180
|
-
this.
|
|
172
|
+
this.calculateSpace = () => {
|
|
181
173
|
const props = this.getProps();
|
|
182
174
|
const {
|
|
183
175
|
direction
|
|
184
176
|
} = props;
|
|
185
177
|
// calculate accurate space for group item
|
|
186
178
|
let handlerSizes = new Array(this._adapter.getHandlerCount()).fill(0);
|
|
187
|
-
let
|
|
179
|
+
let groupSize = direction === 'horizontal' ? this.groupRef.offsetWidth : this.groupRef.offsetHeight;
|
|
188
180
|
this.totalMinus = 0;
|
|
189
181
|
for (let i = 0; i < this._adapter.getHandlerCount(); i++) {
|
|
190
182
|
let handlerSize = direction === 'horizontal' ? this._adapter.getHandler(i).offsetWidth : this._adapter.getHandler(i).offsetHeight;
|
|
@@ -206,8 +198,8 @@ class ResizeGroupFoundation extends _foundation.default {
|
|
|
206
198
|
const child = this._adapter.getItem(i);
|
|
207
199
|
let minSize = this._adapter.getItemMin(i),
|
|
208
200
|
maxSize = this._adapter.getItemMax(i);
|
|
209
|
-
let minSizePercent = minSize ? (0, _utils.getPixelSize)(minSize,
|
|
210
|
-
maxSizePercent = maxSize ? (0, _utils.getPixelSize)(maxSize,
|
|
201
|
+
let minSizePercent = minSize ? (0, _utils.getPixelSize)(minSize, groupSize) / groupSize * 100 : 0,
|
|
202
|
+
maxSizePercent = maxSize ? (0, _utils.getPixelSize)(maxSize, groupSize) / groupSize * 100 : 100;
|
|
211
203
|
if (minSizePercent > maxSizePercent) {
|
|
212
204
|
console.warn('[Semi ResizableItem]: min size bigger than max size');
|
|
213
205
|
}
|
|
@@ -217,17 +209,15 @@ class ResizeGroupFoundation extends _foundation.default {
|
|
|
217
209
|
if (typeof defaultSize === 'string') {
|
|
218
210
|
if (defaultSize.endsWith('%')) {
|
|
219
211
|
itemSizePercent = parseFloat(defaultSize.slice(0, -1));
|
|
220
|
-
this.itemPercentMap.set(i, itemSizePercent);
|
|
221
212
|
} else if (defaultSize.endsWith('px')) {
|
|
222
|
-
itemSizePercent = parseFloat(defaultSize.slice(0, -2)) /
|
|
223
|
-
this.itemPercentMap.set(i, itemSizePercent);
|
|
213
|
+
itemSizePercent = parseFloat(defaultSize.slice(0, -2)) / groupSize * 100;
|
|
224
214
|
} else if (/^-?\d+(\.\d+)?$/.test(defaultSize)) {
|
|
225
215
|
// 仅由数字组成,表示按比例分配剩下空间
|
|
226
216
|
undefineLoc.set(i, parseFloat(defaultSize));
|
|
227
217
|
undefinedTotal += parseFloat(defaultSize);
|
|
228
218
|
continue;
|
|
229
219
|
}
|
|
230
|
-
} else
|
|
220
|
+
} else {
|
|
231
221
|
undefineLoc.set(i, defaultSize);
|
|
232
222
|
undefinedTotal += defaultSize;
|
|
233
223
|
continue;
|
|
@@ -256,78 +246,21 @@ class ResizeGroupFoundation extends _foundation.default {
|
|
|
256
246
|
}
|
|
257
247
|
undefineLoc.forEach((value, key) => {
|
|
258
248
|
const child = this._adapter.getItem(key);
|
|
259
|
-
const percent = value / undefinedTotal * undefineSizePercent;
|
|
260
|
-
this.itemPercentMap.set(key, percent);
|
|
261
249
|
if (direction === 'horizontal') {
|
|
262
|
-
child.style.width = `calc(${
|
|
250
|
+
child.style.width = `calc(${undefineSizePercent / undefinedTotal * value}% - ${this.itemMinusMap.get(key)}px)`;
|
|
263
251
|
} else {
|
|
264
|
-
child.style.height = `calc(${
|
|
252
|
+
child.style.height = `calc(${undefineSizePercent / undefinedTotal * value}% - ${this.itemMinusMap.get(key)}px)`;
|
|
265
253
|
}
|
|
266
254
|
});
|
|
267
255
|
};
|
|
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);
|
|
315
256
|
}
|
|
316
257
|
get groupRef() {
|
|
317
258
|
return this._adapter.getGroupRef();
|
|
318
259
|
}
|
|
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
|
-
}
|
|
326
260
|
init() {
|
|
327
261
|
this.direction = this.getProp('direction');
|
|
328
262
|
this.itemMinusMap = new Map();
|
|
329
|
-
this.
|
|
330
|
-
this.initSpace();
|
|
263
|
+
this.calculateSpace();
|
|
331
264
|
}
|
|
332
265
|
get window() {
|
|
333
266
|
var _a;
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
};
|
|
@@ -11,72 +11,6 @@
|
|
|
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
|
-
}
|
|
80
14
|
.semi-resizable-group {
|
|
81
15
|
display: flex;
|
|
82
16
|
position: relative;
|
|
@@ -97,24 +31,4 @@
|
|
|
97
31
|
justify-content: center;
|
|
98
32
|
background-color: var(--semi-color-fill-0);
|
|
99
33
|
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;
|
|
120
34
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import './variables.scss';
|
|
2
|
+
|
|
2
3
|
$module: #{$prefix}-resizable;
|
|
3
4
|
|
|
4
5
|
.#{$module} {
|
|
@@ -12,83 +13,8 @@ $module: #{$prefix}-resizable;
|
|
|
12
13
|
position: absolute;
|
|
13
14
|
user-select: none;
|
|
14
15
|
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
|
-
}
|
|
90
16
|
}
|
|
91
|
-
|
|
17
|
+
|
|
92
18
|
&-group {
|
|
93
19
|
display: flex;
|
|
94
20
|
position: relative;
|
|
@@ -111,28 +37,5 @@ $module: #{$prefix}-resizable;
|
|
|
111
37
|
justify-content: center;
|
|
112
38
|
background-color: var(--semi-color-fill-0);
|
|
113
39
|
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;
|
|
137
40
|
}
|
|
138
41
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../../base/foundation';
|
|
2
|
-
import { Size, NumberSize, Direction } from "../
|
|
2
|
+
import { Size, NumberSize, Direction } from "../singleConstants";
|
|
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
|
|
8
|
+
var _singleConstants = require("../singleConstants");
|
|
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 ||
|
|
306
|
+
return porps.size || porps.defaultSize || _singleConstants.DEFAULT_SIZE;
|
|
307
307
|
}
|
|
308
308
|
get size() {
|
|
309
309
|
let width = 0;
|