@fibrae/semi-foundation 0.1.1 → 0.3.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 -4
- package/dist/anchor/foundation.js +21 -22
- package/dist/audio-player/foundation.d.ts +10 -13
- package/dist/audio-player/foundation.js +19 -20
- package/dist/auto-complete/foundation.d.ts +12 -14
- package/dist/auto-complete/foundation.js +51 -52
- package/dist/avatar/foundation.d.ts +5 -6
- package/dist/avatar/foundation.js +16 -16
- package/dist/avatar/variables.scss +0 -1
- package/dist/backtop/foundation.d.ts +2 -5
- package/dist/backtop/foundation.js +7 -8
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -9
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -4
- package/dist/base/foundation.js +12 -11
- package/dist/base/list-store.d.ts +0 -1
- 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.d.ts +0 -10
- package/dist/calendar/event-util.js +1 -11
- package/dist/calendar/foundation.d.ts +1 -6
- package/dist/calendar/foundation.js +5 -9
- package/dist/calendar/month-foundation.d.ts +2 -3
- package/dist/calendar/month-foundation.js +6 -7
- package/dist/carousel/foundation.d.ts +17 -19
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +36 -32
- package/dist/cascader/foundation.js +145 -132
- package/dist/cascader/util.d.ts +1 -8
- package/dist/cascader/util.js +1 -8
- package/dist/checkbox/checkbox-foundation.d.ts +3 -7
- package/dist/checkbox/checkbox-foundation.js +15 -17
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -3
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -2
- 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-picker.scss +0 -2
- 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/color-picker/interface.d.ts +0 -1
- package/dist/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/config-provider/responsive-types.d.ts +0 -16
- package/dist/cropper/foundation.d.ts +15 -16
- package/dist/cropper/foundation.js +26 -24
- package/dist/date-picker/_utils/get-default-picker-date.d.ts +0 -3
- package/dist/date-picker/_utils/get-default-picker-date.js +0 -3
- package/dist/date-picker/_utils/get-inset-input-format-token.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-format-token.js +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.js +0 -2
- package/dist/date-picker/_utils/parser.d.ts +0 -3
- package/dist/date-picker/_utils/parser.js +0 -7
- package/dist/date-picker/_utils/picker-type.d.ts +1 -3
- package/dist/date-picker/_utils/picker-type.js +0 -2
- package/dist/date-picker/_utils/to-callback-args.d.ts +0 -1
- package/dist/date-picker/_utils/to-callback-args.js +0 -1
- package/dist/date-picker/date-picker.scss +0 -3
- package/dist/date-picker/foundation.d.ts +39 -58
- package/dist/date-picker/foundation.js +126 -153
- package/dist/date-picker/input-foundation.d.ts +10 -16
- package/dist/date-picker/input-foundation.js +28 -30
- package/dist/date-picker/month-foundation.d.ts +0 -3
- package/dist/date-picker/month-foundation.js +0 -2
- package/dist/date-picker/months-grid-foundation.d.ts +17 -26
- package/dist/date-picker/months-grid-foundation.js +65 -75
- 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 -3
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -7
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -2
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -10
- package/dist/feedback/foundation.js +33 -33
- package/dist/feedback/variables.scss +1 -5
- package/dist/float-button/float-button.css +0 -1
- package/dist/float-button/float-button.scss +0 -2
- package/dist/form/form-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/form.scss +0 -12
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -76
- package/dist/form/interface.d.ts +2 -15
- package/dist/form/utils.d.ts +0 -8
- package/dist/form/utils.js +0 -7
- package/dist/form/variables.scss +1 -4
- package/dist/grid/variables.scss +0 -10
- package/dist/highlight/foundation.d.ts +0 -2
- package/dist/highlight/foundation.js +1 -3
- package/dist/hot-keys/foundation.d.ts +2 -3
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -6
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -4
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.d.ts +0 -3
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -9
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -10
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -11
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -5
- package/dist/input/text-entry-foundation.js +14 -15
- package/dist/input/textarea-foundation.d.ts +7 -8
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/caret.d.ts +0 -1
- package/dist/input-number/caret.js +0 -1
- package/dist/input-number/foundation.d.ts +16 -19
- package/dist/input-number/foundation.js +54 -58
- package/dist/json-viewer/foundation.d.ts +8 -10
- package/dist/json-viewer/foundation.js +23 -24
- package/dist/locale/interface.d.ts +0 -3
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +2 -7
- package/dist/markdown-render/foundation.js +5 -9
- 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 -8
- package/dist/navigation/foundation.js +14 -20
- 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 -4
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -8
- package/dist/notification/notification-list-foundation.js +12 -13
- package/dist/notification/variables.scss +0 -1
- package/dist/overflow-list/foundation.d.ts +4 -6
- package/dist/overflow-list/foundation.js +18 -19
- package/dist/pagination/foundation.d.ts +8 -10
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +6 -9
- package/dist/pincode/foundation.js +23 -26
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -9
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- package/dist/progress/generates.d.ts +1 -4
- package/dist/progress/generates.js +1 -4
- package/dist/progress/utils.d.ts +1 -1
- package/dist/progress/utils.js +1 -1
- package/dist/radio/radio-foundation.d.ts +5 -9
- package/dist/radio/radio-foundation.js +15 -16
- package/dist/radio/radio-group-foundation.d.ts +2 -3
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -15
- package/dist/rating/foundation.js +35 -38
- package/dist/resizable/group/index.d.ts +6 -10
- package/dist/resizable/group/index.js +40 -44
- package/dist/resizable/resizable.scss +0 -1
- package/dist/resizable/single/index.d.ts +3 -7
- package/dist/resizable/single/index.js +10 -13
- package/dist/scroll-list/item-foundation.d.ts +7 -9
- package/dist/scroll-list/item-foundation.js +35 -36
- package/dist/scroll-list/variables.scss +1 -6
- package/dist/select/foundation.d.ts +42 -57
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -28
- package/dist/select/option-foundation.js +10 -19
- package/dist/select/variables.scss +1 -8
- package/dist/side-sheet/side-sheet-foundation.d.ts +7 -12
- package/dist/side-sheet/side-sheet-foundation.js +23 -27
- package/dist/side-sheet/variables.scss +1 -3
- package/dist/slider/foundation.d.ts +17 -28
- package/dist/slider/foundation.js +47 -59
- package/dist/slider/variables.scss +1 -5
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -4
- package/dist/spin/foundation.js +6 -7
- package/dist/spin/variables.scss +1 -3
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -3
- package/dist/switch/foundation.js +7 -7
- package/dist/switch/switch.scss +1 -1
- package/dist/switch/variables.scss +1 -5
- package/dist/table/foundation.d.ts +24 -33
- package/dist/table/foundation.js +144 -108
- package/dist/table/table.scss +0 -1
- package/dist/table/utils.d.ts +2 -10
- package/dist/table/utils.js +0 -13
- package/dist/table/variables.scss +1 -5
- package/dist/tabs/foundation.d.ts +5 -14
- package/dist/tabs/foundation.js +17 -21
- package/dist/tabs/tabs.scss +1 -1
- package/dist/tag/focus.js +0 -1
- package/dist/tag-input/foundation.d.ts +11 -13
- package/dist/tag-input/foundation.js +52 -53
- package/dist/tag-input/tag-input.scss +0 -1
- package/dist/tag-input/utils/tag-focus.d.ts +0 -1
- package/dist/tag-input/utils/tag-focus.js +0 -1
- package/dist/time-picker/combox-foundation.d.ts +3 -11
- package/dist/time-picker/combox-foundation.js +3 -10
- package/dist/time-picker/foundation.d.ts +13 -23
- package/dist/time-picker/foundation.js +39 -48
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/time-picker/utils/index.d.ts +0 -11
- package/dist/time-picker/utils/index.js +0 -11
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- package/dist/tooltip/adjust-position.d.ts +1 -2
- package/dist/tooltip/constants.d.ts +0 -3
- package/dist/tooltip/constants.js +0 -3
- package/dist/tooltip/foundation.d.ts +9 -12
- package/dist/tooltip/foundation.js +67 -63
- package/dist/tooltip/position.scss +0 -1
- package/dist/transfer/foundation.d.ts +22 -13
- package/dist/transfer/foundation.js +38 -24
- package/dist/tree/foundation.d.ts +14 -16
- package/dist/tree/foundation.js +61 -62
- package/dist/tree/shared.d.ts +2 -4
- package/dist/tree/shared.js +0 -2
- package/dist/tree/tree-util.d.ts +0 -5
- package/dist/tree/tree-util.js +0 -5
- package/dist/tree-select/foundation.d.ts +26 -22
- package/dist/tree-select/foundation.js +91 -86
- package/dist/typography/ellipsis.d.ts +5 -7
- package/dist/typography/ellipsis.js +8 -10
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/typography/typography.scss +0 -1
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -23
- package/dist/upload/foundation.js +93 -103
- package/dist/upload/utils.d.ts +3 -8
- package/dist/upload/utils.js +6 -11
- package/dist/user-guide/foundation.d.ts +3 -5
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +2 -6
- package/dist/utils/a11y.js +1 -4
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -4
- package/dist/utils/array.d.ts +0 -6
- package/dist/utils/array.js +0 -6
- package/dist/utils/date-fns-extra.js +1 -5
- package/dist/utils/dom.d.ts +0 -1
- package/dist/utils/dom.js +0 -1
- package/dist/utils/escape-html.js +0 -3
- package/dist/utils/field-sizing.d.ts +0 -2
- package/dist/utils/field-sizing.js +0 -2
- package/dist/utils/focus-handle.d.ts +1 -2
- package/dist/utils/focus-handle.js +1 -3
- package/dist/utils/focus-scope.d.ts +5 -6
- package/dist/utils/focus-scope.js +10 -11
- 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/utils/scroll-lock.d.ts +3 -4
- package/dist/utils/scroll-lock.js +3 -4
- package/dist/utils/tween.d.ts +0 -1
- package/dist/utils/tween.js +0 -1
- package/dist/utils/uuid.d.ts +0 -1
- package/dist/utils/uuid.js +0 -1
- package/dist/utils/warning.d.ts +0 -1
- package/dist/utils/warning.js +0 -1
- 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 -3
- package/dist/video-player/progress-foundation.js +12 -13
- package/dist/video-player/variables.scss +1 -1
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -367,13 +367,10 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
|
|
|
367
367
|
init() {
|
|
368
368
|
this.updateAriaRange();
|
|
369
369
|
}
|
|
370
|
-
/**
|
|
371
|
-
|
|
372
|
-
* unnoticed until the next resize.
|
|
373
|
-
*/
|
|
374
|
-
updateAriaRange() {
|
|
370
|
+
/** A change of the limits alone goes unnoticed until the next resize. */
|
|
371
|
+
updateAriaRange = () => {
|
|
375
372
|
if (this.getStates().isResizing) return;
|
|
376
|
-
this.#resizable = this.
|
|
373
|
+
this.#resizable = this.adapter.getResizable();
|
|
377
374
|
if (!this.#resizable || !this.#window) return;
|
|
378
375
|
this.#setBoundary();
|
|
379
376
|
const { parentSize, minWidth, minHeight, maxWidth, maxHeight } = this.#getLimits();
|
|
@@ -391,12 +388,12 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
|
|
|
391
388
|
}
|
|
392
389
|
};
|
|
393
390
|
if (!isEqual(ariaRange, this.getStates().ariaRange)) this.setState({ ariaRange });
|
|
394
|
-
}
|
|
391
|
+
};
|
|
395
392
|
/**
|
|
396
393
|
* Keyboard resize along the axis of the edge, KEYBOARD_STEP px per press, reported like a drag.
|
|
397
394
|
* Returns whether the key was handled.
|
|
398
395
|
*/
|
|
399
|
-
resizeByKey(direction, e) {
|
|
396
|
+
resizeByKey = (direction, e) => {
|
|
400
397
|
if (e.altKey || e.ctrlKey || e.metaKey) return false;
|
|
401
398
|
const vertical = direction === "top" || direction === "bottom";
|
|
402
399
|
const delta = new Map(vertical ? [["ArrowUp", -10], ["ArrowDown", 10]] : [["ArrowLeft", -10], ["ArrowRight", 10]]).get(e.key);
|
|
@@ -415,7 +412,7 @@ var ResizableFoundation = class ResizableFoundation extends BaseFoundation {
|
|
|
415
412
|
this.#endResize(e, this.#changedSize ?? this.#size);
|
|
416
413
|
}
|
|
417
414
|
return true;
|
|
418
|
-
}
|
|
415
|
+
};
|
|
419
416
|
onResizeStart = (e, direction) => {
|
|
420
417
|
if (!isSecondaryPress(e)) this.#beginResize(e, direction, e);
|
|
421
418
|
};
|
|
@@ -6,7 +6,6 @@ export interface Item {
|
|
|
6
6
|
text?: string;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
}
|
|
9
|
-
/** The props the foundation reads with getProp */
|
|
10
9
|
export interface ScrollItemBaseProps<I extends Item = Item> {
|
|
11
10
|
cycled?: boolean;
|
|
12
11
|
list?: I[];
|
|
@@ -40,17 +39,16 @@ export default class ItemFoundation<I extends Item = Item, P extends ScrollItemB
|
|
|
40
39
|
/**
|
|
41
40
|
* APG single-select listbox keyboard, selection follows focus; the column scrolls once `selectedIndex` returns
|
|
42
41
|
*/
|
|
43
|
-
handleKeyDown(event: KeyboardEvent)
|
|
42
|
+
handleKeyDown: (event: KeyboardEvent) => void;
|
|
44
43
|
/** Click on an item in normal mode */
|
|
45
|
-
selectIndex(index: number)
|
|
44
|
+
selectIndex: (index: number) => void;
|
|
46
45
|
/** Click in a wheel column: the item under the pointer is selected once scrolling settles */
|
|
47
|
-
handleWheelClick(e: Pick<Event,
|
|
46
|
+
handleWheelClick: (e: Pick<Event, "target">) => void;
|
|
48
47
|
/** Scroll of the column: in wheel mode the item at the selector is selected once scrolling settles */
|
|
49
|
-
handleScroll()
|
|
48
|
+
handleScroll: () => void;
|
|
50
49
|
/** The list length changed */
|
|
51
|
-
syncList()
|
|
50
|
+
syncList: () => void;
|
|
52
51
|
/** The owner changed `selectedIndex` */
|
|
53
|
-
syncSelectedIndex(selectedIndex: number, previous: number)
|
|
54
|
-
|
|
55
|
-
scrollToSelected(duration?: number): void;
|
|
52
|
+
syncSelectedIndex: (selectedIndex: number, previous: number) => void;
|
|
53
|
+
scrollToSelected: (duration?: number) => void;
|
|
56
54
|
}
|
|
@@ -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,9 @@ 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
|
-
}
|
|
331
|
-
|
|
332
|
-
scrollToSelected(duration = numbers.DEFAULT_SCROLL_DURATION) {
|
|
330
|
+
};
|
|
331
|
+
scrollToSelected = (duration = numbers.DEFAULT_SCROLL_DURATION) => {
|
|
333
332
|
this.#scrollToNode(this.#selectedNode, duration);
|
|
334
|
-
}
|
|
333
|
+
};
|
|
335
334
|
};
|
|
336
335
|
export { ItemFoundation as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
$color-scrollList-bg: var(--semi-color-bg-3); // 滚动列表背景色
|
|
4
4
|
$color-scrollList-border: var(--semi-color-border); // 滚动列表描边颜色
|
|
5
5
|
$color-scrollList_header-bg: transparent; // 滚动列表 header 背景色
|
|
@@ -14,7 +14,6 @@ $color-scrollList_selected_item-text: var(--semi-color-text-0); // 滚动列表
|
|
|
14
14
|
$color-scrollList_selected_item-icon: var(--semi-color-text-2); // 滚动列表选中选项图标颜色
|
|
15
15
|
$color-scrollList_footer-border: var(--semi-color-border); // 滚动列表底部描边颜色
|
|
16
16
|
|
|
17
|
-
// Width/Height
|
|
18
17
|
$height-scrollList: 300px;
|
|
19
18
|
$height-scrollList_item: 36px;
|
|
20
19
|
$width-scrollList_item-border: $border-thickness-control;
|
|
@@ -23,7 +22,6 @@ $width-scrollList_item_wheel_selector-border: $border-thickness-control;
|
|
|
23
22
|
$height-scrollList_line: 1px;
|
|
24
23
|
$width-scrollList_footer-border: $border-thickness-control;
|
|
25
24
|
|
|
26
|
-
// Spacing
|
|
27
25
|
$spacing-scrollList_header-paddingY: 0;
|
|
28
26
|
$spacing-scrollList_header-paddingX: 16px;
|
|
29
27
|
$spacing-scrollList_header_title-paddingY: $spacing-base;
|
|
@@ -39,12 +37,9 @@ $spacing-scrollList_item_wheel_list_shade_pre-marginTop: -1 * ($height-scrollLis
|
|
|
39
37
|
$spacing-scrollList_item_wheel_list_shade_post-marginTop: $height-scrollList_item * 0.5 + $border-thickness-control;
|
|
40
38
|
$spacing-scrollList_footer-padding: 10px;
|
|
41
39
|
|
|
42
|
-
// Radius
|
|
43
40
|
$radius-scrollList: var(--semi-border-radius-medium);
|
|
44
41
|
|
|
45
|
-
// Font
|
|
46
42
|
$font-scrollList_header_title-fontWeight: $font-weight-bold;
|
|
47
43
|
$font-scrollList_item_wheel_item_selected-fontWeight: $font-weight-bold;
|
|
48
44
|
|
|
49
|
-
// Other
|
|
50
45
|
$shadow-scrollList: var(--semi-shadow-elevated);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation.js";
|
|
2
2
|
import { isComposing } from "../utils/key-code.js";
|
|
3
|
-
import { BasicOptionProps } from "./option-foundation.js";
|
|
4
|
-
/** The props the foundation reads with getProps */
|
|
3
|
+
import { BasicOptionProps, OptionRecord } from "./option-foundation.js";
|
|
5
4
|
export interface SelectBaseProps {
|
|
6
5
|
allowCreate?: boolean;
|
|
7
6
|
autoClearSearchValue?: boolean;
|
|
@@ -29,16 +28,19 @@ export interface SelectBaseState {
|
|
|
29
28
|
isFocus: boolean;
|
|
30
29
|
isFullTags: boolean;
|
|
31
30
|
isOpen: boolean;
|
|
32
|
-
options:
|
|
31
|
+
options: OptionRecord[];
|
|
32
|
+
/** The selected options' data by value */
|
|
33
33
|
selections: Map<any, any>;
|
|
34
34
|
showInput: boolean;
|
|
35
35
|
}
|
|
36
|
+
/** The fields the foundation reads from a keydown, so a host framework's own event type also fits */
|
|
37
|
+
export type SelectKeyEvent = Pick<KeyboardEvent, 'key' | 'target' | 'currentTarget' | 'ctrlKey' | 'metaKey' | 'altKey' | 'shiftKey' | 'preventDefault' | 'stopPropagation'> & Parameters<typeof isComposing>[0];
|
|
36
38
|
/** LE is the host's option list scroll event, which the foundation only passes through */
|
|
37
39
|
export interface SelectAdapter<P extends SelectBaseProps = SelectBaseProps, S extends SelectBaseState = SelectBaseState, LE = unknown> extends DefaultAdapter<P, S> {
|
|
38
40
|
updateFocusState(focus: boolean): void;
|
|
39
41
|
focusTrigger(): void;
|
|
40
|
-
getOptionsFromChildren():
|
|
41
|
-
updateOptions(options:
|
|
42
|
+
getOptionsFromChildren(): OptionRecord[];
|
|
43
|
+
updateOptions(options: OptionRecord[]): void;
|
|
42
44
|
updateFocusIndex(index: number): void;
|
|
43
45
|
updateSelection(selection: Map<any, any>): void;
|
|
44
46
|
openMenu(cb?: () => void): void;
|
|
@@ -73,68 +75,51 @@ type PropValue = LabelValue | Record<string, any>;
|
|
|
73
75
|
export default class SelectFoundation<P extends SelectBaseProps = SelectBaseProps, S extends SelectBaseState = SelectBaseState, LE = unknown> extends BaseFoundation<SelectAdapter<P, S, LE>, P, S> {
|
|
74
76
|
#private;
|
|
75
77
|
/** `options` is the host's option list from optionList or the option children */
|
|
76
|
-
static getInitialState(props: SelectBaseProps, options:
|
|
77
|
-
options:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
label?: string | number | unknown;
|
|
81
|
-
children?: unknown;
|
|
82
|
-
disabled?: boolean;
|
|
83
|
-
showTick?: boolean;
|
|
84
|
-
className?: string;
|
|
85
|
-
style?: Record<string, any>;
|
|
86
|
-
} | {
|
|
87
|
-
_show: boolean;
|
|
88
|
-
_selected: boolean;
|
|
89
|
-
value?: string | number;
|
|
90
|
-
label?: string | number | unknown;
|
|
91
|
-
children?: unknown;
|
|
92
|
-
disabled?: boolean;
|
|
93
|
-
showTick?: boolean;
|
|
94
|
-
className?: string;
|
|
95
|
-
style?: Record<string, any>;
|
|
96
|
-
})[];
|
|
78
|
+
static getInitialState(props: SelectBaseProps, options: OptionRecord[]): {
|
|
79
|
+
options: OptionRecord<BasicOptionProps, {
|
|
80
|
+
label?: unknown;
|
|
81
|
+
}>[];
|
|
97
82
|
selections: Map<any, any>;
|
|
98
83
|
focusIndex: number;
|
|
99
84
|
overflowItemCount: number;
|
|
100
85
|
};
|
|
101
86
|
init(): void;
|
|
102
|
-
focus(optionsForOpen?:
|
|
87
|
+
focus: (optionsForOpen?: OptionRecord[], openDropdown?: boolean) => void;
|
|
103
88
|
/** After an update, the host reports whether the options (optionList or children) and value changed by its own change detection */
|
|
104
|
-
handleInputsChange({ optionsChanged, valueChanged }: {
|
|
89
|
+
handleInputsChange: ({ optionsChanged, valueChanged }: {
|
|
105
90
|
optionsChanged: boolean;
|
|
106
91
|
valueChanged: boolean;
|
|
107
|
-
}, value: PropValue)
|
|
108
|
-
handleClick(e: Pick<MouseEvent,
|
|
109
|
-
open(_acInput?: string, originalOptions?:
|
|
110
|
-
handleClickOutside(e: MouseEvent)
|
|
111
|
-
close(closeConfig?: {
|
|
112
|
-
event?:
|
|
92
|
+
}, value: PropValue) => void;
|
|
93
|
+
handleClick: (e: Pick<MouseEvent, "target" | "currentTarget" | "detail">) => void;
|
|
94
|
+
open: (_acInput?: string, originalOptions?: OptionRecord[]) => void;
|
|
95
|
+
handleClickOutside: (e: MouseEvent) => void;
|
|
96
|
+
close: (closeConfig?: {
|
|
97
|
+
event?: unknown;
|
|
113
98
|
closeCb?: () => void;
|
|
114
99
|
notToggleInput?: boolean;
|
|
115
100
|
returnFocus?: boolean;
|
|
116
|
-
})
|
|
117
|
-
onSelect(option:
|
|
118
|
-
clearSelected()
|
|
119
|
-
removeTag(item: BasicOptionProps)
|
|
120
|
-
clearInput(event?:
|
|
121
|
-
handleInputChange(sugInput: string, event: unknown)
|
|
122
|
-
handleKeyDown(event:
|
|
123
|
-
handleContainerKeyDown(event: Pick<KeyboardEvent,
|
|
124
|
-
handleMouseEnter(e:
|
|
125
|
-
handleMouseLeave(e:
|
|
126
|
-
handleClearClick(e?: MouseEvent)
|
|
127
|
-
handleOptionMouseEnter(optionIndex: number)
|
|
128
|
-
handleListScroll(e: LE)
|
|
129
|
-
handleTriggerFocus(e:
|
|
130
|
-
handleTriggerBlur(e:
|
|
131
|
-
handleInputFocus(e:
|
|
132
|
-
handleInputBlur()
|
|
133
|
-
selectAll()
|
|
134
|
-
updateScrollTop()
|
|
135
|
-
updateOverflowItemCount(selectionLength: number, overFlowCount?: number)
|
|
136
|
-
updateIsFullTags()
|
|
137
|
-
handlePopoverClose()
|
|
138
|
-
handleSlotMouseEnter()
|
|
101
|
+
}) => void;
|
|
102
|
+
onSelect: (option: OptionRecord, optionIndex: number, event: unknown) => void;
|
|
103
|
+
clearSelected: () => void;
|
|
104
|
+
removeTag: (item: BasicOptionProps) => void;
|
|
105
|
+
clearInput: (event?: unknown) => void;
|
|
106
|
+
handleInputChange: (sugInput: string, event: unknown) => void;
|
|
107
|
+
handleKeyDown: (event: SelectKeyEvent) => void;
|
|
108
|
+
handleContainerKeyDown: (event: Pick<KeyboardEvent, "key" | "shiftKey" | "preventDefault" | "stopPropagation"> & Parameters<typeof isComposing>[0]) => void;
|
|
109
|
+
handleMouseEnter: (e: unknown) => void;
|
|
110
|
+
handleMouseLeave: (e: unknown) => void;
|
|
111
|
+
handleClearClick: (e?: Pick<MouseEvent, "stopPropagation">) => void;
|
|
112
|
+
handleOptionMouseEnter: (optionIndex: number) => void;
|
|
113
|
+
handleListScroll: (e: LE) => void;
|
|
114
|
+
handleTriggerFocus: (e: unknown) => void;
|
|
115
|
+
handleTriggerBlur: (e: unknown) => void;
|
|
116
|
+
handleInputFocus: (e: unknown) => void;
|
|
117
|
+
handleInputBlur: () => void;
|
|
118
|
+
selectAll: () => void;
|
|
119
|
+
updateScrollTop: () => void;
|
|
120
|
+
updateOverflowItemCount: (selectionLength: number, overFlowCount?: number) => void;
|
|
121
|
+
updateIsFullTags: () => void;
|
|
122
|
+
handlePopoverClose: () => void;
|
|
123
|
+
handleSlotMouseEnter: () => void;
|
|
139
124
|
}
|
|
140
125
|
export {};
|