@fibrae/semi-foundation 0.1.1 → 0.2.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.
- package/dist/anchor/foundation.d.ts +1 -1
- package/dist/anchor/foundation.js +21 -21
- package/dist/audio-player/foundation.d.ts +10 -10
- package/dist/audio-player/foundation.js +19 -19
- package/dist/auto-complete/foundation.d.ts +12 -12
- package/dist/auto-complete/foundation.js +51 -51
- package/dist/avatar/foundation.d.ts +5 -5
- package/dist/avatar/foundation.js +16 -16
- package/dist/backtop/foundation.d.ts +2 -2
- package/dist/backtop/foundation.js +7 -7
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -8
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -3
- package/dist/base/foundation.js +12 -11
- package/dist/breadcrumb/foundation.d.ts +5 -5
- package/dist/breadcrumb/foundation.js +9 -10
- package/dist/breadcrumb/item-foundation.d.ts +3 -3
- package/dist/breadcrumb/item-foundation.js +6 -6
- package/dist/calendar/event-util.js +1 -1
- package/dist/calendar/foundation.js +4 -4
- package/dist/calendar/month-foundation.d.ts +2 -2
- package/dist/calendar/month-foundation.js +6 -6
- package/dist/carousel/foundation.d.ts +17 -17
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +34 -26
- package/dist/cascader/foundation.js +143 -121
- package/dist/checkbox/checkbox-foundation.d.ts +2 -2
- package/dist/checkbox/checkbox-foundation.js +15 -15
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -2
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -1
- package/dist/code-highlight/index.js +3 -3
- package/dist/collapse/foundation.d.ts +2 -2
- package/dist/collapse/foundation.js +7 -7
- package/dist/collapsible/foundation.d.ts +3 -3
- package/dist/collapsible/foundation.js +8 -8
- package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
- package/dist/color-picker/alpha-slider-foundation.js +10 -10
- package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
- package/dist/color-picker/color-choose-area-foundation.js +14 -14
- package/dist/color-picker/color-slider-foundation.d.ts +2 -4
- package/dist/color-picker/color-slider-foundation.js +10 -10
- package/dist/color-picker/data-part-foundation.d.ts +5 -5
- package/dist/color-picker/data-part-foundation.js +11 -11
- package/dist/color-picker/foundation.d.ts +4 -4
- package/dist/color-picker/foundation.js +10 -10
- package/dist/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/cropper/foundation.d.ts +15 -15
- package/dist/cropper/foundation.js +26 -23
- package/dist/date-picker/_utils/picker-type.d.ts +1 -1
- package/dist/date-picker/foundation.d.ts +36 -36
- package/dist/date-picker/foundation.js +125 -129
- package/dist/date-picker/input-foundation.d.ts +9 -9
- package/dist/date-picker/input-foundation.js +28 -28
- package/dist/date-picker/months-grid-foundation.d.ts +16 -16
- package/dist/date-picker/months-grid-foundation.js +64 -65
- package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
- package/dist/date-picker/year-and-month-foundation.js +11 -11
- package/dist/drag-move/foundation.d.ts +2 -2
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -5
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -1
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -9
- package/dist/feedback/foundation.js +33 -33
- package/dist/form/form-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -61
- package/dist/highlight/foundation.js +1 -1
- package/dist/hot-keys/foundation.d.ts +2 -2
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -4
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -3
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -8
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -9
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -10
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -3
- package/dist/input/text-entry-foundation.js +14 -14
- package/dist/input/textarea-foundation.d.ts +7 -7
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/foundation.d.ts +16 -14
- package/dist/input-number/foundation.js +54 -53
- package/dist/json-viewer/foundation.d.ts +8 -8
- package/dist/json-viewer/foundation.js +23 -23
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +1 -1
- package/dist/markdown-render/foundation.js +4 -4
- package/dist/modal/modal-content-foundation.d.ts +7 -7
- package/dist/modal/modal-content-foundation.js +20 -20
- package/dist/modal/modal-foundation.d.ts +6 -6
- package/dist/modal/modal-foundation.js +24 -24
- package/dist/navigation/foundation.d.ts +1 -1
- package/dist/navigation/foundation.js +14 -14
- package/dist/navigation/item-foundation.d.ts +1 -1
- package/dist/navigation/item-foundation.js +8 -8
- package/dist/navigation/sub-nav-foundation.d.ts +3 -3
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -7
- package/dist/notification/notification-list-foundation.js +12 -12
- package/dist/overflow-list/foundation.d.ts +4 -4
- package/dist/overflow-list/foundation.js +18 -18
- package/dist/pagination/foundation.d.ts +8 -8
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +5 -5
- package/dist/pincode/foundation.js +22 -22
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -7
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- package/dist/radio/radio-foundation.d.ts +5 -5
- package/dist/radio/radio-foundation.js +15 -15
- package/dist/radio/radio-group-foundation.d.ts +2 -2
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -10
- package/dist/rating/foundation.js +35 -35
- package/dist/resizable/group/index.d.ts +6 -6
- package/dist/resizable/group/index.js +40 -40
- package/dist/resizable/single/index.d.ts +2 -2
- package/dist/resizable/single/index.js +9 -9
- package/dist/scroll-list/item-foundation.d.ts +7 -7
- package/dist/scroll-list/item-foundation.js +35 -35
- package/dist/select/foundation.d.ts +42 -56
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -27
- package/dist/select/option-foundation.js +10 -18
- package/dist/side-sheet/side-sheet-foundation.d.ts +6 -6
- package/dist/side-sheet/side-sheet-foundation.js +22 -22
- package/dist/slider/foundation.d.ts +16 -16
- package/dist/slider/foundation.js +46 -46
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -2
- package/dist/spin/foundation.js +6 -6
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -2
- package/dist/switch/foundation.js +7 -7
- package/dist/table/foundation.d.ts +14 -14
- package/dist/table/foundation.js +93 -93
- package/dist/table/utils.d.ts +2 -2
- package/dist/tabs/foundation.d.ts +5 -5
- package/dist/tabs/foundation.js +17 -17
- package/dist/tag-input/foundation.d.ts +11 -11
- package/dist/tag-input/foundation.js +52 -52
- package/dist/time-picker/foundation.d.ts +13 -13
- package/dist/time-picker/foundation.js +39 -39
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- package/dist/tooltip/foundation.d.ts +9 -9
- package/dist/tooltip/foundation.js +67 -61
- package/dist/transfer/foundation.d.ts +22 -9
- package/dist/transfer/foundation.js +38 -23
- package/dist/tree/foundation.d.ts +14 -14
- package/dist/tree/foundation.js +61 -61
- package/dist/tree/shared.d.ts +1 -1
- package/dist/tree-select/foundation.d.ts +26 -20
- package/dist/tree-select/foundation.js +91 -83
- package/dist/typography/ellipsis.d.ts +4 -4
- package/dist/typography/ellipsis.js +8 -8
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -17
- package/dist/upload/foundation.js +92 -92
- package/dist/upload/utils.d.ts +3 -3
- package/dist/upload/utils.js +6 -6
- package/dist/user-guide/foundation.d.ts +3 -3
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +1 -1
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -4
- package/dist/utils/focus-handle.d.ts +1 -1
- package/dist/utils/focus-handle.js +1 -2
- package/dist/utils/focus-scope.d.ts +5 -5
- package/dist/utils/focus-scope.js +10 -10
- package/dist/utils/is-promise.d.ts +1 -1
- package/dist/utils/release-holder.d.ts +2 -2
- package/dist/utils/release-holder.js +4 -4
- package/dist/video-player/foundation.d.ts +15 -15
- package/dist/video-player/foundation.js +89 -89
- package/dist/video-player/progress-foundation.d.ts +2 -2
- package/dist/video-player/progress-foundation.js +12 -12
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
12
12
|
return this.getProp("direction");
|
|
13
13
|
}
|
|
14
14
|
get #groupRef() {
|
|
15
|
-
return this.
|
|
15
|
+
return this.adapter.getGroupRef();
|
|
16
16
|
}
|
|
17
17
|
get #groupSize() {
|
|
18
18
|
return this.#direction === "horizontal" ? this.#groupRef.offsetWidth : this.#groupRef.offsetHeight;
|
|
@@ -29,11 +29,11 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
29
29
|
}
|
|
30
30
|
#clampItem(index, size) {
|
|
31
31
|
const groupSize = this.#groupSize;
|
|
32
|
-
return clamp$1(size, this.#toPixels(this.
|
|
32
|
+
return clamp$1(size, this.#toPixels(this.adapter.getItemMin(index) ?? "0%", groupSize), this.#toPixels(this.adapter.getItemMax(index) ?? "100%", groupSize));
|
|
33
33
|
}
|
|
34
34
|
#applyDelta(curHandler, { lastItemSize, nextItemSize }, delta, e) {
|
|
35
35
|
const direction = this.#direction;
|
|
36
|
-
let lastItem = this.
|
|
36
|
+
let lastItem = this.adapter.getItem(curHandler), nextItem = this.adapter.getItem(curHandler + 1);
|
|
37
37
|
let parentSize = this.#groupSize;
|
|
38
38
|
let lastNewSize = lastItemSize + delta;
|
|
39
39
|
let nextNewSize = nextItemSize - delta;
|
|
@@ -59,7 +59,7 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
59
59
|
lastItem.style.height = `calc(${lastNewPercent}% - ${this.#itemMinusMap.get(curHandler)}px)`;
|
|
60
60
|
nextItem.style.height = `calc(${nextNewPercent}% - ${this.#itemMinusMap.get(curHandler + 1)}px)`;
|
|
61
61
|
}
|
|
62
|
-
let lastFunc = this.
|
|
62
|
+
let lastFunc = this.adapter.getItemChange(curHandler), nextFunc = this.adapter.getItemChange(curHandler + 1);
|
|
63
63
|
let [lastDir, nextDir] = getItemDirection(direction);
|
|
64
64
|
if (lastFunc) lastFunc({
|
|
65
65
|
width: lastItem.offsetWidth,
|
|
@@ -72,8 +72,8 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
72
72
|
this.#syncAria();
|
|
73
73
|
}
|
|
74
74
|
#notifyResizeEnd(curHandler, e) {
|
|
75
|
-
let lastItem = this.
|
|
76
|
-
let lastFunc = this.
|
|
75
|
+
let lastItem = this.adapter.getItem(curHandler), nextItem = this.adapter.getItem(curHandler + 1);
|
|
76
|
+
let lastFunc = this.adapter.getItemEnd(curHandler), nextFunc = this.adapter.getItemEnd(curHandler + 1);
|
|
77
77
|
let [lastDir, nextDir] = getItemDirection(this.#direction);
|
|
78
78
|
if (lastFunc) lastFunc({
|
|
79
79
|
width: lastItem.offsetWidth,
|
|
@@ -89,8 +89,8 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
89
89
|
if (!parentSize) return;
|
|
90
90
|
const percent = (px) => px / parentSize * 100;
|
|
91
91
|
const limits = (index) => {
|
|
92
|
-
const min = this.
|
|
93
|
-
const max = this.
|
|
92
|
+
const min = this.adapter.getItemMin(index);
|
|
93
|
+
const max = this.adapter.getItemMax(index);
|
|
94
94
|
const minus = this.#itemMinusMap.get(index);
|
|
95
95
|
return {
|
|
96
96
|
min: percent((min ? this.#toPixels(min, parentSize) : 0) + minus),
|
|
@@ -98,9 +98,9 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
const round = (value) => String(Number(value.toFixed(1)));
|
|
101
|
-
for (let i = 0; i < this.
|
|
102
|
-
const handler = this.
|
|
103
|
-
const item = this.
|
|
101
|
+
for (let i = 0; i < this.adapter.getHandlerCount() && i + 1 < this.adapter.getItemCount(); i++) {
|
|
102
|
+
const handler = this.adapter.getHandler(i);
|
|
103
|
+
const item = this.adapter.getItem(i);
|
|
104
104
|
const last = limits(i);
|
|
105
105
|
const next = limits(i + 1);
|
|
106
106
|
const total = this.#itemPercentMap.get(i) + this.#itemPercentMap.get(i + 1);
|
|
@@ -113,11 +113,11 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
113
113
|
}
|
|
114
114
|
#measureHandlerRoom() {
|
|
115
115
|
const horizontal = this.#direction === "horizontal";
|
|
116
|
-
const handlerSizes = Array.from({ length: this.
|
|
117
|
-
const handler = this.
|
|
116
|
+
const handlerSizes = Array.from({ length: this.adapter.getHandlerCount() }, (_, i) => {
|
|
117
|
+
const handler = this.adapter.getHandler(i);
|
|
118
118
|
return horizontal ? handler.offsetWidth : handler.offsetHeight;
|
|
119
119
|
});
|
|
120
|
-
const itemCount = this.
|
|
120
|
+
const itemCount = this.adapter.getItemCount();
|
|
121
121
|
for (let i = 0; i < itemCount; i++) {
|
|
122
122
|
const before = i > 0 ? handlerSizes[i - 1] / 2 : 0;
|
|
123
123
|
const after = i < itemCount - 1 ? handlerSizes[i] / 2 : 0;
|
|
@@ -131,12 +131,12 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
131
131
|
this.#measureHandlerRoom();
|
|
132
132
|
let totalSizePercent = 0;
|
|
133
133
|
let undefineLoc = /* @__PURE__ */ new Map(), undefinedTotal = 0;
|
|
134
|
-
for (let i = 0; i < this.
|
|
135
|
-
const child = this.
|
|
136
|
-
let minSize = this.
|
|
134
|
+
for (let i = 0; i < this.adapter.getItemCount(); i++) {
|
|
135
|
+
const child = this.adapter.getItem(i);
|
|
136
|
+
let minSize = this.adapter.getItemMin(i), maxSize = this.adapter.getItemMax(i);
|
|
137
137
|
let minSizePercent = minSize ? this.#toPixels(minSize, parentSize) / parentSize * 100 : 0, maxSizePercent = maxSize ? this.#toPixels(maxSize, parentSize) / parentSize * 100 : 100;
|
|
138
138
|
if (minSizePercent > maxSizePercent) console.warn("[Semi ResizableItem]: min size bigger than max size");
|
|
139
|
-
let defaultSize = this.
|
|
139
|
+
let defaultSize = this.adapter.getItemDefaultSize(i);
|
|
140
140
|
if (defaultSize) {
|
|
141
141
|
let itemSizePercent;
|
|
142
142
|
if (typeof defaultSize === "string") {
|
|
@@ -168,7 +168,7 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
168
168
|
undefineSizePercent = 10;
|
|
169
169
|
}
|
|
170
170
|
undefineLoc.forEach((value, key) => {
|
|
171
|
-
const child = this.
|
|
171
|
+
const child = this.adapter.getItem(key);
|
|
172
172
|
const percent = value / undefinedTotal * undefineSizePercent;
|
|
173
173
|
this.#itemPercentMap.set(key, percent);
|
|
174
174
|
if (direction === "horizontal") child.style.width = `calc(${percent}% - ${this.#itemMinusMap.get(key)}px)`;
|
|
@@ -177,7 +177,7 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
177
177
|
this.#syncAria();
|
|
178
178
|
}
|
|
179
179
|
#measure(handlerIndex, x, y) {
|
|
180
|
-
let lastItem = this.
|
|
180
|
+
let lastItem = this.adapter.getItem(handlerIndex), nextItem = this.adapter.getItem(handlerIndex + 1);
|
|
181
181
|
return {
|
|
182
182
|
x,
|
|
183
183
|
y,
|
|
@@ -188,8 +188,8 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
188
188
|
/** Returns false when either item's onResizeStart returned false */
|
|
189
189
|
#notifyResizeStart(handlerIndex, e) {
|
|
190
190
|
const [lastDir, nextDir] = getItemDirection(this.#direction);
|
|
191
|
-
const lastResult = this.
|
|
192
|
-
const nextResult = this.
|
|
191
|
+
const lastResult = this.adapter.getItemStart(handlerIndex)?.(e, lastDir);
|
|
192
|
+
const nextResult = this.adapter.getItemStart(handlerIndex + 1)?.(e, nextDir);
|
|
193
193
|
return lastResult !== false && nextResult !== false;
|
|
194
194
|
}
|
|
195
195
|
init() {
|
|
@@ -200,27 +200,27 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
200
200
|
/**
|
|
201
201
|
* Re-runs initSpace the first time the group is measurable (#3336); later resizes must not, or the drag is lost.
|
|
202
202
|
*/
|
|
203
|
-
handleGroupResize() {
|
|
203
|
+
handleGroupResize = () => {
|
|
204
204
|
if (!this.#sizeInitialized && this.#groupSize > 0) this.#initSpace();
|
|
205
|
-
}
|
|
205
|
+
};
|
|
206
206
|
/**
|
|
207
207
|
* Moves each item's inline size to the new axis, where the handlers take a different length
|
|
208
208
|
*/
|
|
209
|
-
handleDirectionChange() {
|
|
209
|
+
handleDirectionChange = () => {
|
|
210
210
|
const [stale, current] = this.#direction === "horizontal" ? ["height", "width"] : ["width", "height"];
|
|
211
211
|
this.#measureHandlerRoom();
|
|
212
|
-
for (let i = 0; i < this.
|
|
213
|
-
const item = this.
|
|
212
|
+
for (let i = 0; i < this.adapter.getItemCount(); i++) {
|
|
213
|
+
const item = this.adapter.getItem(i);
|
|
214
214
|
item.style.removeProperty(stale);
|
|
215
215
|
item.style[current] = `calc(${this.#itemPercentMap.get(i)}% - ${this.#itemMinusMap.get(i)}px)`;
|
|
216
216
|
}
|
|
217
217
|
this.#syncAria();
|
|
218
|
-
}
|
|
218
|
+
};
|
|
219
219
|
/**
|
|
220
220
|
* Keyboard resize, reported like a drag: arrows move 1% of the group (Shift: 10%), Home and End go to the
|
|
221
221
|
* limits. Returns whether the key was handled.
|
|
222
222
|
*/
|
|
223
|
-
resizeByKey(handlerIndex, e) {
|
|
223
|
+
resizeByKey = (handlerIndex, e) => {
|
|
224
224
|
if (e.altKey || e.ctrlKey || e.metaKey) return false;
|
|
225
225
|
const [backKey, forwardKey] = this.#direction === "horizontal" ? ["ArrowLeft", "ArrowRight"] : ["ArrowUp", "ArrowDown"];
|
|
226
226
|
const groupSize = this.#groupSize;
|
|
@@ -237,8 +237,8 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
237
237
|
this.#notifyResizeEnd(handlerIndex, e);
|
|
238
238
|
}
|
|
239
239
|
return true;
|
|
240
|
-
}
|
|
241
|
-
onResizeStart(handlerIndex, e) {
|
|
240
|
+
};
|
|
241
|
+
onResizeStart = (handlerIndex, e) => {
|
|
242
242
|
if (isSecondaryPress(e) || !this.#notifyResizeStart(handlerIndex, e)) return;
|
|
243
243
|
const states = this.getStates();
|
|
244
244
|
this.setState({
|
|
@@ -250,15 +250,15 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
250
250
|
},
|
|
251
251
|
curHandler: handlerIndex
|
|
252
252
|
});
|
|
253
|
-
}
|
|
254
|
-
onResizing(e) {
|
|
253
|
+
};
|
|
254
|
+
onResizing = (e) => {
|
|
255
255
|
const state = this.getStates();
|
|
256
256
|
if (!state.isResizing) return;
|
|
257
257
|
const { curHandler, originalPosition } = state;
|
|
258
258
|
const delta = this.#direction === "horizontal" ? e.clientX - originalPosition.x : e.clientY - originalPosition.y;
|
|
259
259
|
this.#applyDelta(curHandler, originalPosition, delta, e);
|
|
260
|
-
}
|
|
261
|
-
onResizeEnd(e) {
|
|
260
|
+
};
|
|
261
|
+
onResizeEnd = (e) => {
|
|
262
262
|
const { isResizing, curHandler } = this.getStates();
|
|
263
263
|
if (!isResizing) return;
|
|
264
264
|
this.#notifyResizeEnd(curHandler, e);
|
|
@@ -266,19 +266,19 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
266
266
|
isResizing: false,
|
|
267
267
|
curHandler: null
|
|
268
268
|
});
|
|
269
|
-
}
|
|
269
|
+
};
|
|
270
270
|
ensureConstraint = debounce(() => {
|
|
271
271
|
if (!this.#groupSize) return;
|
|
272
272
|
const direction = this.#direction;
|
|
273
|
-
const itemCount = this.
|
|
273
|
+
const itemCount = this.adapter.getItemCount();
|
|
274
274
|
let continueFlag = true;
|
|
275
275
|
for (let i = 0; i < itemCount; i++) {
|
|
276
|
-
const child = this.
|
|
276
|
+
const child = this.adapter.getItem(i);
|
|
277
277
|
const childSize = direction === "horizontal" ? child.offsetWidth : child.offsetHeight;
|
|
278
278
|
const childNewSize = this.#clampItem(i, childSize);
|
|
279
279
|
if (childNewSize !== childSize) {
|
|
280
280
|
const j = [...Array.from({ length: itemCount - i - 1 }, (_, k) => i + 1 + k), ...Array.from({ length: i }, (_, k) => i - 1 - k)].find((index) => {
|
|
281
|
-
const item = this.
|
|
281
|
+
const item = this.adapter.getItem(index);
|
|
282
282
|
const itemSize = direction === "horizontal" ? item.offsetWidth : item.offsetHeight;
|
|
283
283
|
return this.#clampItem(index, itemSize) === itemSize;
|
|
284
284
|
});
|
|
@@ -286,7 +286,7 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
286
286
|
continueFlag = false;
|
|
287
287
|
console.warn("[Semi ResizableGroup]: no enough space to adjust min/max size");
|
|
288
288
|
} else {
|
|
289
|
-
const item = this.
|
|
289
|
+
const item = this.adapter.getItem(j);
|
|
290
290
|
const childPercent = this.#itemPercentMap.get(i);
|
|
291
291
|
const itemPercent = this.#itemPercentMap.get(j);
|
|
292
292
|
const childNewPercent = (childNewSize + this.#itemMinusMap.get(i)) / this.#groupSize * 100;
|
|
@@ -77,12 +77,12 @@ export declare class ResizableFoundation<P extends ResizableBaseProps = Resizabl
|
|
|
77
77
|
* Reads the size and limits for aria-valuenow, -valuemin and -valuemax. A change of the limits alone goes
|
|
78
78
|
* unnoticed until the next resize.
|
|
79
79
|
*/
|
|
80
|
-
updateAriaRange()
|
|
80
|
+
updateAriaRange: () => void;
|
|
81
81
|
/**
|
|
82
82
|
* Keyboard resize along the axis of the edge, KEYBOARD_STEP px per press, reported like a drag.
|
|
83
83
|
* Returns whether the key was handled.
|
|
84
84
|
*/
|
|
85
|
-
resizeByKey(direction: Direction, e: KeyboardEvent)
|
|
85
|
+
resizeByKey: (direction: Direction, e: KeyboardEvent) => boolean;
|
|
86
86
|
onResizeStart: (e: PointerEvent, direction: Direction) => void;
|
|
87
87
|
onResizing: (event: PointerEvent) => void;
|
|
88
88
|
onResizeEnd: (event: PointerEvent) => void;
|
|
@@ -278,7 +278,7 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
|
|
|
278
278
|
const flexBaseChanged = states.flexBasis !== newState.flexBasis;
|
|
279
279
|
if (widthChanged || heightChanged || flexBaseChanged) {
|
|
280
280
|
this.setState(newState);
|
|
281
|
-
this.
|
|
281
|
+
this.adapter.notifyChange({
|
|
282
282
|
width: newState.width,
|
|
283
283
|
height: newState.height
|
|
284
284
|
}, event, direction);
|
|
@@ -294,7 +294,7 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
|
|
|
294
294
|
#endResize(event, endSize = this.#size) {
|
|
295
295
|
const { isResizing, direction } = this.getStates();
|
|
296
296
|
if (!isResizing || !this.#resizable) return;
|
|
297
|
-
this.
|
|
297
|
+
this.adapter.notifyResizeEnd(endSize, event, direction);
|
|
298
298
|
this.#restoreControlledSize();
|
|
299
299
|
this.setState({
|
|
300
300
|
isResizing: false,
|
|
@@ -305,11 +305,11 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
|
|
|
305
305
|
}, () => this.updateAriaRange());
|
|
306
306
|
}
|
|
307
307
|
#beginResize(e, direction, { clientX, clientY }) {
|
|
308
|
-
this.#resizable = this.
|
|
308
|
+
this.#resizable = this.adapter.getResizable();
|
|
309
309
|
if (!this.#resizable || !this.#window) return false;
|
|
310
310
|
const props = this.getProps();
|
|
311
311
|
const states = this.getStates();
|
|
312
|
-
if (this.
|
|
312
|
+
if (this.adapter.notifyResizeStart(e, direction) === false) return false;
|
|
313
313
|
const { size } = props;
|
|
314
314
|
if (size) {
|
|
315
315
|
const { height, width } = size;
|
|
@@ -371,9 +371,9 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
|
|
|
371
371
|
* Reads the size and limits for aria-valuenow, -valuemin and -valuemax. A change of the limits alone goes
|
|
372
372
|
* unnoticed until the next resize.
|
|
373
373
|
*/
|
|
374
|
-
updateAriaRange() {
|
|
374
|
+
updateAriaRange = () => {
|
|
375
375
|
if (this.getStates().isResizing) return;
|
|
376
|
-
this.#resizable = this.
|
|
376
|
+
this.#resizable = this.adapter.getResizable();
|
|
377
377
|
if (!this.#resizable || !this.#window) return;
|
|
378
378
|
this.#setBoundary();
|
|
379
379
|
const { parentSize, minWidth, minHeight, maxWidth, maxHeight } = this.#getLimits();
|
|
@@ -391,12 +391,12 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
|
|
|
391
391
|
}
|
|
392
392
|
};
|
|
393
393
|
if (!isEqual(ariaRange, this.getStates().ariaRange)) this.setState({ ariaRange });
|
|
394
|
-
}
|
|
394
|
+
};
|
|
395
395
|
/**
|
|
396
396
|
* Keyboard resize along the axis of the edge, KEYBOARD_STEP px per press, reported like a drag.
|
|
397
397
|
* Returns whether the key was handled.
|
|
398
398
|
*/
|
|
399
|
-
resizeByKey(direction, e) {
|
|
399
|
+
resizeByKey = (direction, e) => {
|
|
400
400
|
if (e.altKey || e.ctrlKey || e.metaKey) return false;
|
|
401
401
|
const vertical = direction === "top" || direction === "bottom";
|
|
402
402
|
const delta = new Map(vertical ? [["ArrowUp", -10], ["ArrowDown", 10]] : [["ArrowLeft", -10], ["ArrowRight", 10]]).get(e.key);
|
|
@@ -415,7 +415,7 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
|
|
|
415
415
|
this.#endResize(e, this.#changedSize ?? this.#size);
|
|
416
416
|
}
|
|
417
417
|
return true;
|
|
418
|
-
}
|
|
418
|
+
};
|
|
419
419
|
onResizeStart = (e, direction) => {
|
|
420
420
|
if (!isSecondaryPress(e)) this.#beginResize(e, direction, e);
|
|
421
421
|
};
|
|
@@ -40,17 +40,17 @@ export default class ItemFoundation<I extends Item = Item, P extends ScrollItemB
|
|
|
40
40
|
/**
|
|
41
41
|
* APG single-select listbox keyboard, selection follows focus; the column scrolls once `selectedIndex` returns
|
|
42
42
|
*/
|
|
43
|
-
handleKeyDown(event: KeyboardEvent)
|
|
43
|
+
handleKeyDown: (event: KeyboardEvent) => void;
|
|
44
44
|
/** Click on an item in normal mode */
|
|
45
|
-
selectIndex(index: number)
|
|
45
|
+
selectIndex: (index: number) => void;
|
|
46
46
|
/** Click in a wheel column: the item under the pointer is selected once scrolling settles */
|
|
47
|
-
handleWheelClick(e: Pick<Event,
|
|
47
|
+
handleWheelClick: (e: Pick<Event, "target">) => void;
|
|
48
48
|
/** Scroll of the column: in wheel mode the item at the selector is selected once scrolling settles */
|
|
49
|
-
handleScroll()
|
|
49
|
+
handleScroll: () => void;
|
|
50
50
|
/** The list length changed */
|
|
51
|
-
syncList()
|
|
51
|
+
syncList: () => void;
|
|
52
52
|
/** The owner changed `selectedIndex` */
|
|
53
|
-
syncSelectedIndex(selectedIndex: number, previous: number)
|
|
53
|
+
syncSelectedIndex: (selectedIndex: number, previous: number) => void;
|
|
54
54
|
/** Centres the item last selected */
|
|
55
|
-
scrollToSelected(duration?: number)
|
|
55
|
+
scrollToSelected: (duration?: number) => void;
|
|
56
56
|
}
|
|
@@ -28,11 +28,11 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
28
28
|
return Array.isArray(list) && list.length > 0 && index > -1 && Boolean(list[index % list.length]?.disabled);
|
|
29
29
|
}
|
|
30
30
|
#indexOf(node) {
|
|
31
|
-
return Array.from(this.
|
|
31
|
+
return Array.from(this.adapter.getListNode().children).indexOf(node);
|
|
32
32
|
}
|
|
33
33
|
#getNodeByOffset(refNode, offset) {
|
|
34
34
|
const { list, cycled, mode } = this.getProps();
|
|
35
|
-
const listNode = this.
|
|
35
|
+
const listNode = this.adapter.getListNode();
|
|
36
36
|
if (isElement(refNode) && isElement(listNode) && Array.isArray(list) && list.length) {
|
|
37
37
|
const sameCopyStep = offset % list.length;
|
|
38
38
|
if (sameCopyStep) {
|
|
@@ -51,7 +51,7 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
51
51
|
}
|
|
52
52
|
#highlightNearestNode() {
|
|
53
53
|
if (this.getProps().mode !== wheelMode) return;
|
|
54
|
-
const listNode = this.
|
|
54
|
+
const listNode = this.adapter.getListNode();
|
|
55
55
|
const node = this.#getNearestNodeInfo().nearestNode || this.#selectedNode;
|
|
56
56
|
if (isElement(node) && isElement(listNode)) {
|
|
57
57
|
for (const child of Array.from(listNode.children)) child.classList.remove(cssClasses.SELECTED);
|
|
@@ -66,7 +66,7 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
66
66
|
return this.#cancelScroll !== null;
|
|
67
67
|
}
|
|
68
68
|
#scrollToPos(targetTop, duration) {
|
|
69
|
-
const wrapper = this.
|
|
69
|
+
const wrapper = this.adapter.getScrollNode();
|
|
70
70
|
this.#select.cancel();
|
|
71
71
|
if (duration && this.getProps().motion) {
|
|
72
72
|
this.#stopScroll();
|
|
@@ -83,11 +83,11 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
83
83
|
#scrollToNode(node, duration) {
|
|
84
84
|
if (!node) return;
|
|
85
85
|
const itemHeight = node.offsetHeight || numbers.DEFAULT_ITEM_HEIGHT;
|
|
86
|
-
const targetTop = (node.offsetTop || this.
|
|
86
|
+
const targetTop = (node.offsetTop || this.adapter.getListNode().children.length * itemHeight / 2) - (this.adapter.getScrollNode().offsetHeight - itemHeight) / 2;
|
|
87
87
|
this.#scrollToPos(targetTop, duration);
|
|
88
88
|
}
|
|
89
89
|
#scrollToCenter(node) {
|
|
90
|
-
const wrapper = this.
|
|
90
|
+
const wrapper = this.adapter.getScrollNode();
|
|
91
91
|
if (isElement(node) && isElement(wrapper)) {
|
|
92
92
|
const scrollRect = wrapper.getBoundingClientRect();
|
|
93
93
|
const selectedRect = node.getBoundingClientRect();
|
|
@@ -98,20 +98,20 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
98
98
|
#recoverSelectedNode() {
|
|
99
99
|
const { cycled, mode, selectedIndex } = this.getProps();
|
|
100
100
|
if (cycled && mode === wheelMode || this.#selectedNode?.isConnected) return false;
|
|
101
|
-
const node = this.
|
|
101
|
+
const node = this.adapter.getListNode().children[selectedIndex > -1 ? selectedIndex : 0];
|
|
102
102
|
this.#cacheSelectedNode(node);
|
|
103
103
|
this.#cacheWillSelectNode(node);
|
|
104
104
|
return Boolean(node);
|
|
105
105
|
}
|
|
106
106
|
#selectNode(node) {
|
|
107
107
|
const { type, list: data, selectedIndex } = this.getProps();
|
|
108
|
-
const listNode = this.
|
|
108
|
+
const listNode = this.adapter.getListNode();
|
|
109
109
|
if (isElement(node) && isElement(listNode)) {
|
|
110
110
|
const indexInData = Array.from(listNode.children).findIndex((ele) => ele === node) % data.length;
|
|
111
111
|
const item = data[indexInData];
|
|
112
112
|
this.#cacheWillSelectNode(node);
|
|
113
113
|
this.#scrollToCenter(node);
|
|
114
|
-
if (indexInData !== selectedIndex % data.length) this.
|
|
114
|
+
if (indexInData !== selectedIndex % data.length) this.adapter.notifySelectItem({
|
|
115
115
|
...item,
|
|
116
116
|
value: item.value,
|
|
117
117
|
type,
|
|
@@ -121,8 +121,8 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
121
121
|
}
|
|
122
122
|
#initWheelList(callback) {
|
|
123
123
|
const { list } = this.getProps();
|
|
124
|
-
const listNode = this.
|
|
125
|
-
const wrapper = this.
|
|
124
|
+
const listNode = this.adapter.getListNode();
|
|
125
|
+
const wrapper = this.adapter.getScrollNode();
|
|
126
126
|
if (isElement(wrapper) && isElement(listNode) && list && list.length) {
|
|
127
127
|
const prependCount = this.shouldPrepend(listNode, wrapper);
|
|
128
128
|
const appendCount = this.shouldAppend(listNode, wrapper);
|
|
@@ -134,8 +134,8 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
134
134
|
}
|
|
135
135
|
#adjustInfiniteList() {
|
|
136
136
|
const { list } = this.getProps();
|
|
137
|
-
const listNode = this.
|
|
138
|
-
const wrapper = this.
|
|
137
|
+
const listNode = this.adapter.getListNode();
|
|
138
|
+
const wrapper = this.adapter.getScrollNode();
|
|
139
139
|
const nodeTag = "li";
|
|
140
140
|
if (isElement(wrapper) && isElement(listNode) && list && list.length) {
|
|
141
141
|
const allNodes = listNode.querySelectorAll(nodeTag);
|
|
@@ -154,8 +154,8 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
#getNearestNodeInfo() {
|
|
157
|
-
const listNode = this.
|
|
158
|
-
const selector = this.
|
|
157
|
+
const listNode = this.adapter.getListNode();
|
|
158
|
+
const selector = this.adapter.getSelectorNode();
|
|
159
159
|
if (isElement(listNode) && isElement(selector)) {
|
|
160
160
|
const selectorTop = selector.getBoundingClientRect().top;
|
|
161
161
|
const itemNodes = listNode.querySelectorAll("li");
|
|
@@ -178,10 +178,10 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
#getTargetNode(e) {
|
|
181
|
-
const listNode = this.
|
|
181
|
+
const listNode = this.adapter.getListNode();
|
|
182
182
|
if (e && isElement(listNode)) {
|
|
183
183
|
const targetTagName = "li";
|
|
184
|
-
const currentTarget = e.target;
|
|
184
|
+
const currentTarget = e.target instanceof Node ? e.target : null;
|
|
185
185
|
const itemNodes = listNode.querySelectorAll(targetTagName);
|
|
186
186
|
const { list } = this.getProps();
|
|
187
187
|
const length = Array.isArray(list) ? list.length : 0;
|
|
@@ -250,7 +250,7 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
250
250
|
}
|
|
251
251
|
init() {
|
|
252
252
|
const { mode, cycled, selectedIndex } = this.getProps();
|
|
253
|
-
const selectedNode = this.
|
|
253
|
+
const selectedNode = this.adapter.getListNode().children[typeof selectedIndex === "number" && selectedIndex > -1 ? selectedIndex : 0];
|
|
254
254
|
this.#cacheSelectedNode(selectedNode);
|
|
255
255
|
this.#cacheWillSelectNode(selectedNode);
|
|
256
256
|
if (mode === wheelMode && cycled) this.#initWheelList(() => this.#scrollToNode(selectedNode, 0));
|
|
@@ -264,7 +264,7 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
264
264
|
/**
|
|
265
265
|
* APG single-select listbox keyboard, selection follows focus; the column scrolls once `selectedIndex` returns
|
|
266
266
|
*/
|
|
267
|
-
handleKeyDown(event) {
|
|
267
|
+
handleKeyDown = (event) => {
|
|
268
268
|
const { list, selectedIndex, cycled, type } = this.getProps();
|
|
269
269
|
let target = getListTargetIndex(event.key, selectedIndex, list.length, (index) => Boolean(list[index].disabled), { loop: cycled });
|
|
270
270
|
if (target === null && this.#typeahead.accepts(event)) {
|
|
@@ -277,47 +277,47 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
277
277
|
}
|
|
278
278
|
event.preventDefault();
|
|
279
279
|
this.#select.cancel();
|
|
280
|
-
if (target !== selectedIndex) this.
|
|
280
|
+
if (target !== selectedIndex) this.adapter.notifySelectItem({
|
|
281
281
|
...list[target],
|
|
282
282
|
type,
|
|
283
283
|
index: target
|
|
284
284
|
});
|
|
285
|
-
}
|
|
285
|
+
};
|
|
286
286
|
/** Click on an item in normal mode */
|
|
287
|
-
selectIndex(index) {
|
|
287
|
+
selectIndex = (index) => {
|
|
288
288
|
const { type, list } = this.getProps();
|
|
289
|
-
const listNode = this.
|
|
289
|
+
const listNode = this.adapter.getListNode();
|
|
290
290
|
if (index > -1 && Array.isArray(list) && list.length && isElement(listNode)) {
|
|
291
291
|
const indexInData = index % list.length;
|
|
292
292
|
const item = list[indexInData];
|
|
293
293
|
this.#cacheWillSelectNode(listNode.children[index]);
|
|
294
294
|
this.#select.cancel();
|
|
295
|
-
this.
|
|
295
|
+
this.adapter.notifySelectItem({
|
|
296
296
|
...item,
|
|
297
297
|
value: item.value,
|
|
298
298
|
type,
|
|
299
299
|
index: indexInData
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
|
-
}
|
|
302
|
+
};
|
|
303
303
|
/** Click in a wheel column: the item under the pointer is selected once scrolling settles */
|
|
304
|
-
handleWheelClick(e) {
|
|
304
|
+
handleWheelClick = (e) => {
|
|
305
305
|
const { targetNode, infoInList } = this.#getTargetNode(e);
|
|
306
306
|
if (targetNode && infoInList && !infoInList.disabled) this.#select(targetNode);
|
|
307
|
-
}
|
|
307
|
+
};
|
|
308
308
|
/** Scroll of the column: in wheel mode the item at the selector is selected once scrolling settles */
|
|
309
|
-
handleScroll() {
|
|
309
|
+
handleScroll = () => {
|
|
310
310
|
const info = this.#getNearestNodeInfo();
|
|
311
311
|
if (!info) return;
|
|
312
312
|
if (this.getProps().cycled) this.#adjustList();
|
|
313
313
|
if (!this.#isAnimating) this.#select(info.nearestNode);
|
|
314
|
-
}
|
|
314
|
+
};
|
|
315
315
|
/** The list length changed */
|
|
316
|
-
syncList() {
|
|
316
|
+
syncList = () => {
|
|
317
317
|
if (this.#recoverSelectedNode()) this.scrollToSelected();
|
|
318
|
-
}
|
|
318
|
+
};
|
|
319
319
|
/** The owner changed `selectedIndex` */
|
|
320
|
-
syncSelectedIndex(selectedIndex, previous) {
|
|
320
|
+
syncSelectedIndex = (selectedIndex, previous) => {
|
|
321
321
|
if (this.#recoverSelectedNode()) {
|
|
322
322
|
this.scrollToSelected();
|
|
323
323
|
return;
|
|
@@ -327,10 +327,10 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
327
327
|
if (!list.length || willSelectIndex % list.length !== selectedIndex % list.length) this.#cacheWillSelectNode(this.#getNodeByOffset(this.#selectedNode, selectedIndex - previous));
|
|
328
328
|
this.#cacheSelectedNode(this.#willSelectNode);
|
|
329
329
|
this.scrollToSelected();
|
|
330
|
-
}
|
|
330
|
+
};
|
|
331
331
|
/** Centres the item last selected */
|
|
332
|
-
scrollToSelected(duration = numbers.DEFAULT_SCROLL_DURATION) {
|
|
332
|
+
scrollToSelected = (duration = numbers.DEFAULT_SCROLL_DURATION) => {
|
|
333
333
|
this.#scrollToNode(this.#selectedNode, duration);
|
|
334
|
-
}
|
|
334
|
+
};
|
|
335
335
|
};
|
|
336
336
|
export { ItemFoundation as default };
|