@fibrae/semi-foundation 0.1.0 → 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 +17 -17
- 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
|
@@ -41,7 +41,7 @@ export default class AnchorFoundation<P extends AnchorBaseProps = AnchorBaseProp
|
|
|
41
41
|
init(): void;
|
|
42
42
|
destroy(): void;
|
|
43
43
|
/** Rebinds scroll listeners when `getContainer` returns a different node */
|
|
44
|
-
handleContainerChange()
|
|
44
|
+
handleContainerChange: () => void;
|
|
45
45
|
syncSlideBar: () => void;
|
|
46
46
|
addLink: (link: string) => void;
|
|
47
47
|
removeLink: (link: string) => void;
|
|
@@ -9,7 +9,7 @@ var AnchorFoundation = class extends BaseFoundation {
|
|
|
9
9
|
#throttledScroll = throttle(() => this.handleScroll(), 100);
|
|
10
10
|
#debouncedScrollEnd = debounce(() => this.#handleClickLink(), 100);
|
|
11
11
|
#bind() {
|
|
12
|
-
const container = this.
|
|
12
|
+
const container = this.adapter.getContainer();
|
|
13
13
|
this.#container = container;
|
|
14
14
|
container.addEventListener("scroll", this.#throttledScroll);
|
|
15
15
|
container.addEventListener("scroll", this.#debouncedScrollEnd);
|
|
@@ -19,11 +19,11 @@ var AnchorFoundation = class extends BaseFoundation {
|
|
|
19
19
|
this.#container?.removeEventListener("scroll", this.#debouncedScrollEnd);
|
|
20
20
|
this.#container = null;
|
|
21
21
|
}
|
|
22
|
-
#scrollIntoView
|
|
22
|
+
#scrollIntoView(link) {
|
|
23
23
|
const { scrollMotion, targetOffset, scrollIntoViewOptions } = this.getProps();
|
|
24
24
|
const behavior = scrollMotion ? "smooth" : "auto";
|
|
25
25
|
if (link) {
|
|
26
|
-
const destNode = this.
|
|
26
|
+
const destNode = this.adapter.getContentNode(link);
|
|
27
27
|
const scrollOpts = {
|
|
28
28
|
block: "start",
|
|
29
29
|
...scrollIntoViewOptions,
|
|
@@ -43,31 +43,31 @@ var AnchorFoundation = class extends BaseFoundation {
|
|
|
43
43
|
};
|
|
44
44
|
if (destNode) scrollIntoView(destNode, scrollOpts);
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
}
|
|
47
47
|
#handleClickLink() {
|
|
48
|
-
this.
|
|
48
|
+
this.adapter.setState({ clickLink: false });
|
|
49
49
|
}
|
|
50
50
|
#goToLink(link, shouldNotify) {
|
|
51
|
-
const destNode = this.
|
|
52
|
-
const prevLink = this.
|
|
51
|
+
const destNode = this.adapter.getContentNode(link);
|
|
52
|
+
const prevLink = this.adapter.getState("activeLink");
|
|
53
53
|
this.setActiveLink(link, prevLink, shouldNotify);
|
|
54
|
-
if (destNode) this.
|
|
54
|
+
if (destNode) this.adapter.setState({ clickLink: true }, () => {
|
|
55
55
|
this.#scrollIntoView(link);
|
|
56
56
|
this.#debouncedScrollEnd();
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
setActiveLink(link, prevLink, shouldNotify = true) {
|
|
60
|
-
if (this.
|
|
61
|
-
this.
|
|
62
|
-
if (shouldNotify) this.
|
|
60
|
+
if (this.adapter.getState("activeLink") !== link) {
|
|
61
|
+
this.adapter.setState({ activeLink: link }, this.syncSlideBar);
|
|
62
|
+
if (shouldNotify) this.adapter.notifyChange(link, prevLink);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
getLinksTop() {
|
|
66
|
-
const container = this.
|
|
66
|
+
const container = this.adapter.getContainer();
|
|
67
67
|
const containerTop = "getBoundingClientRect" in container ? container.getBoundingClientRect().top : 0;
|
|
68
68
|
const { offsetTop } = this.getProps();
|
|
69
69
|
return this.getState("links").map((link) => {
|
|
70
|
-
const node = this.
|
|
70
|
+
const node = this.adapter.getContentNode(link);
|
|
71
71
|
return node && node.getBoundingClientRect().top - containerTop - offsetTop || -Infinity;
|
|
72
72
|
});
|
|
73
73
|
}
|
|
@@ -114,30 +114,30 @@ var AnchorFoundation = class extends BaseFoundation {
|
|
|
114
114
|
this.#debouncedScrollEnd.cancel();
|
|
115
115
|
}
|
|
116
116
|
/** Rebinds scroll listeners when `getContainer` returns a different node */
|
|
117
|
-
handleContainerChange() {
|
|
118
|
-
if (this.
|
|
117
|
+
handleContainerChange = () => {
|
|
118
|
+
if (this.adapter.getContainer() !== this.#container) {
|
|
119
119
|
this.#unbind();
|
|
120
120
|
this.#bind();
|
|
121
121
|
}
|
|
122
|
-
}
|
|
122
|
+
};
|
|
123
123
|
syncSlideBar = () => {
|
|
124
|
-
const linkNode = this.
|
|
124
|
+
const linkNode = this.adapter.getAnchorNode(`.${cssClasses.PREFIX}-link-title-active`);
|
|
125
125
|
if (linkNode && linkNode.offsetTop !== this.#slideBarTop) {
|
|
126
126
|
this.#slideBarTop = linkNode.offsetTop;
|
|
127
|
-
this.
|
|
127
|
+
this.adapter.setState({ slideBarTop: `${this.#slideBarTop}px` });
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
addLink = (link) => {
|
|
131
|
-
this.
|
|
131
|
+
this.adapter.setState({ links: [...this.getState("links"), link] });
|
|
132
132
|
};
|
|
133
133
|
removeLink = (link) => {
|
|
134
134
|
const links = this.getState("links");
|
|
135
135
|
const index = links.indexOf(link);
|
|
136
|
-
if (index !== -1) this.
|
|
136
|
+
if (index !== -1) this.adapter.setState({ links: links.toSpliced(index, 1) });
|
|
137
137
|
};
|
|
138
138
|
handleClick = (e, link) => {
|
|
139
139
|
this.#goToLink(link, true);
|
|
140
|
-
this.
|
|
140
|
+
this.adapter.notifyClick(e, link);
|
|
141
141
|
};
|
|
142
142
|
};
|
|
143
143
|
export { AnchorFoundation as default };
|
|
@@ -30,17 +30,17 @@ export default class AudioPlayerFoundation<P extends AudioPlayerBaseProps = Audi
|
|
|
30
30
|
init(): void;
|
|
31
31
|
handleAudioPlay: () => void;
|
|
32
32
|
handleAudioPause: () => void;
|
|
33
|
-
handleStatusClick()
|
|
34
|
-
handleTimeUpdate()
|
|
35
|
-
handleTrackChange(direction:
|
|
36
|
-
handleTimeChange(value: number)
|
|
37
|
-
handleSpeedChange(value: {
|
|
33
|
+
handleStatusClick: () => void;
|
|
34
|
+
handleTimeUpdate: () => void;
|
|
35
|
+
handleTrackChange: (direction: "next" | "prev") => void;
|
|
36
|
+
handleTimeChange: (value: number) => void;
|
|
37
|
+
handleSpeedChange: (value: {
|
|
38
38
|
label: string;
|
|
39
39
|
value: number;
|
|
40
|
-
})
|
|
41
|
-
handleSeek(direction: number)
|
|
42
|
-
handleRefresh()
|
|
43
|
-
handleVolumeChange(value: number)
|
|
40
|
+
}) => void;
|
|
41
|
+
handleSeek: (direction: number) => void;
|
|
42
|
+
handleRefresh: () => void;
|
|
43
|
+
handleVolumeChange: (value: number) => void;
|
|
44
44
|
/** Mutes, or restores half volume when muted */
|
|
45
|
-
handleVolumeSilent()
|
|
45
|
+
handleVolumeSilent: () => void;
|
|
46
46
|
}
|
|
@@ -17,7 +17,7 @@ var AudioPlayerFoundation = class extends BaseFoundation {
|
|
|
17
17
|
this.setState({ error: true });
|
|
18
18
|
}
|
|
19
19
|
#getAudioRef() {
|
|
20
|
-
return this.
|
|
20
|
+
return this.adapter.getAudioRef();
|
|
21
21
|
}
|
|
22
22
|
#resetAudioState() {
|
|
23
23
|
this.setState({
|
|
@@ -47,18 +47,18 @@ var AudioPlayerFoundation = class extends BaseFoundation {
|
|
|
47
47
|
handleAudioPause = () => {
|
|
48
48
|
this.setState({ isPlaying: false });
|
|
49
49
|
};
|
|
50
|
-
handleStatusClick() {
|
|
50
|
+
handleStatusClick = () => {
|
|
51
51
|
const audio = this.#getAudioRef();
|
|
52
52
|
if (!audio) return;
|
|
53
53
|
if (audio.paused) ignoreExpectedMediaErrors(audio.play());
|
|
54
54
|
else audio.pause();
|
|
55
|
-
}
|
|
56
|
-
handleTimeUpdate() {
|
|
55
|
+
};
|
|
56
|
+
handleTimeUpdate = () => {
|
|
57
57
|
const audio = this.#getAudioRef();
|
|
58
58
|
if (!audio) return;
|
|
59
59
|
this.setState({ currentTime: audio.currentTime });
|
|
60
|
-
}
|
|
61
|
-
handleTrackChange(direction) {
|
|
60
|
+
};
|
|
61
|
+
handleTrackChange = (direction) => {
|
|
62
62
|
if (!this.#getAudioRef()) return;
|
|
63
63
|
const audioUrl = this.getProp("audioUrl");
|
|
64
64
|
if (Array.isArray(audioUrl)) {
|
|
@@ -71,28 +71,28 @@ var AudioPlayerFoundation = class extends BaseFoundation {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
this.#resetAudioState();
|
|
74
|
-
}
|
|
75
|
-
handleTimeChange(value) {
|
|
74
|
+
};
|
|
75
|
+
handleTimeChange = (value) => {
|
|
76
76
|
const audio = this.#getAudioRef();
|
|
77
77
|
if (!audio || !Number.isFinite(audio.duration) || !Number.isFinite(value)) return;
|
|
78
78
|
const time = Math.min(Math.max(value, 0), audio.duration);
|
|
79
79
|
audio.currentTime = time;
|
|
80
80
|
this.setState({ currentTime: time });
|
|
81
|
-
}
|
|
82
|
-
handleSpeedChange(value) {
|
|
81
|
+
};
|
|
82
|
+
handleSpeedChange = (value) => {
|
|
83
83
|
const audio = this.#getAudioRef();
|
|
84
84
|
if (!audio) return;
|
|
85
85
|
audio.defaultPlaybackRate = audio.playbackRate = value.value;
|
|
86
86
|
this.setState({ currentRate: value });
|
|
87
|
-
}
|
|
88
|
-
handleSeek(direction) {
|
|
87
|
+
};
|
|
88
|
+
handleSeek = (direction) => {
|
|
89
89
|
const audio = this.#getAudioRef();
|
|
90
90
|
if (!audio) return;
|
|
91
91
|
if (!Number.isFinite(audio.duration)) return;
|
|
92
92
|
const skipDuration = this.getProp("skipDuration");
|
|
93
93
|
audio.currentTime = Math.min(Math.max(audio.currentTime + direction * skipDuration, 0), audio.duration);
|
|
94
|
-
}
|
|
95
|
-
handleRefresh() {
|
|
94
|
+
};
|
|
95
|
+
handleRefresh = () => {
|
|
96
96
|
const audio = this.#getAudioRef();
|
|
97
97
|
if (!audio) return;
|
|
98
98
|
if (this.getState("error")) audio.load();
|
|
@@ -100,17 +100,17 @@ var AudioPlayerFoundation = class extends BaseFoundation {
|
|
|
100
100
|
audio.currentTime = 0;
|
|
101
101
|
this.setState({ currentTime: 0 });
|
|
102
102
|
}
|
|
103
|
-
}
|
|
104
|
-
handleVolumeChange(value) {
|
|
103
|
+
};
|
|
104
|
+
handleVolumeChange = (value) => {
|
|
105
105
|
const audio = this.#getAudioRef();
|
|
106
106
|
if (!audio) return;
|
|
107
107
|
const volume = Math.floor(value);
|
|
108
108
|
audio.volume = volume / 100;
|
|
109
109
|
this.setState({ volume });
|
|
110
|
-
}
|
|
110
|
+
};
|
|
111
111
|
/** Mutes, or restores half volume when muted */
|
|
112
|
-
handleVolumeSilent() {
|
|
112
|
+
handleVolumeSilent = () => {
|
|
113
113
|
this.handleVolumeChange(this.getState("volume") === 0 ? 50 : 0);
|
|
114
|
-
}
|
|
114
|
+
};
|
|
115
115
|
};
|
|
116
116
|
export { AudioPlayerFoundation as default };
|
|
@@ -57,21 +57,21 @@ export default class AutoCompleteFoundation<P extends AutoCompleteBaseProps = Au
|
|
|
57
57
|
visible: boolean;
|
|
58
58
|
};
|
|
59
59
|
init(): void;
|
|
60
|
-
handleKeyDown(event: Pick<KeyboardEvent,
|
|
60
|
+
handleKeyDown: (event: Pick<KeyboardEvent, "key" | "preventDefault"> & Parameters<typeof isComposing>[0]) => void;
|
|
61
61
|
/** Mousedown outside the input and dropdown while shown */
|
|
62
|
-
handleClickOutside(_e: MouseEvent)
|
|
62
|
+
handleClickOutside: (_e: MouseEvent) => void;
|
|
63
63
|
/**
|
|
64
64
|
* Hides the dropdown and reports dropdownVisibleChange(false), without blurring the input or moving focus.
|
|
65
65
|
* Called when Vue KeepAlive deactivates the host.
|
|
66
66
|
*/
|
|
67
|
-
close()
|
|
68
|
-
handleInputClick(e: Pick<MouseEvent,
|
|
69
|
-
handleSearch(inputValue: string)
|
|
70
|
-
handleSelect(stateOption: StateOptionItem, optionIndex?: number)
|
|
71
|
-
handleDataChange(newData: any[])
|
|
72
|
-
handleValueChange(selectedValue: AutoCompleteBaseProps[
|
|
73
|
-
handleClear()
|
|
74
|
-
handleOptionMouseEnter(optionIndex: number)
|
|
75
|
-
handleFocus(e: FE)
|
|
76
|
-
handleBlur(e: FE)
|
|
67
|
+
close: () => void;
|
|
68
|
+
handleInputClick: (e: Pick<MouseEvent, "detail" | "target" | "currentTarget">) => void;
|
|
69
|
+
handleSearch: (inputValue: string) => void;
|
|
70
|
+
handleSelect: (stateOption: StateOptionItem, optionIndex?: number) => void;
|
|
71
|
+
handleDataChange: (newData: any[]) => void;
|
|
72
|
+
handleValueChange: (selectedValue: AutoCompleteBaseProps["value"]) => void;
|
|
73
|
+
handleClear: () => void;
|
|
74
|
+
handleOptionMouseEnter: (optionIndex: number) => void;
|
|
75
|
+
handleFocus: (e: FE) => void;
|
|
76
|
+
handleBlur: (e: FE) => void;
|
|
77
77
|
}
|
|
@@ -64,8 +64,8 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
64
64
|
selectedOptionIndex = AutoCompleteFoundation.#generateList(data).findIndex((option) => renderSelectedItem(AutoCompleteFoundation.#toDataItem(option)) === searchValue);
|
|
65
65
|
}
|
|
66
66
|
if (selectedOptionIndex === -1 && defaultActiveFirstOption) {
|
|
67
|
-
if (focusIndex !== 0) this.
|
|
68
|
-
} else if (selectedOptionIndex !== focusIndex) this.
|
|
67
|
+
if (focusIndex !== 0) this.adapter.updateFocusIndex(0);
|
|
68
|
+
} else if (selectedOptionIndex !== focusIndex) this.adapter.updateFocusIndex(selectedOptionIndex);
|
|
69
69
|
}
|
|
70
70
|
#modifyFocusIndexOnPanelOpen() {
|
|
71
71
|
let { inputValue } = this.getStates();
|
|
@@ -75,8 +75,8 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
75
75
|
const { focusIndex, options } = this.getStates();
|
|
76
76
|
const visibleOptions = options.filter((item) => item.show);
|
|
77
77
|
const index = getEnabledStepIndex(offset, focusIndex, visibleOptions.length, (i) => visibleOptions[i].disabled);
|
|
78
|
-
this.
|
|
79
|
-
if (index !== -1) this.
|
|
78
|
+
this.adapter.updateFocusIndex(index);
|
|
79
|
+
if (index !== -1) this.adapter.updateScrollTop(index);
|
|
80
80
|
}
|
|
81
81
|
#handleArrowKeyDown(offset) {
|
|
82
82
|
const { visible } = this.getStates();
|
|
@@ -92,23 +92,23 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
92
92
|
} else this.#closeDropdown();
|
|
93
93
|
}
|
|
94
94
|
#openDropdown() {
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
95
|
+
this.adapter.toggleListVisible(true);
|
|
96
|
+
this.adapter.notifyDropdownVisibleChange(true);
|
|
97
97
|
this.#modifyFocusIndexOnPanelOpen();
|
|
98
98
|
}
|
|
99
99
|
#closeDropdown() {
|
|
100
100
|
if (!this.getState("visible")) return;
|
|
101
|
-
this.
|
|
102
|
-
this.
|
|
101
|
+
this.adapter.toggleListVisible(false);
|
|
102
|
+
this.adapter.notifyDropdownVisibleChange(false);
|
|
103
103
|
}
|
|
104
104
|
#updateSelection(option) {
|
|
105
105
|
const selection = /* @__PURE__ */ new Map();
|
|
106
106
|
if (option) selection.set(option.label, option);
|
|
107
|
-
this.
|
|
107
|
+
this.adapter.updateSelection(selection);
|
|
108
108
|
}
|
|
109
109
|
#notifySelect(option) {
|
|
110
|
-
if (this.#backwardLabelInValue()) this.
|
|
111
|
-
else this.
|
|
110
|
+
if (this.#backwardLabelInValue()) this.adapter.notifySelect(option);
|
|
111
|
+
else this.adapter.notifySelect(option.value);
|
|
112
112
|
}
|
|
113
113
|
static getInitialState(props) {
|
|
114
114
|
const value = props.value !== void 0 ? props.value : props.defaultValue;
|
|
@@ -123,7 +123,7 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
123
123
|
this.#initialized = true;
|
|
124
124
|
if (this.getProp("defaultOpen") && !this.getProp("disabled")) this.#openDropdown();
|
|
125
125
|
}
|
|
126
|
-
handleKeyDown(event) {
|
|
126
|
+
handleKeyDown = (event) => {
|
|
127
127
|
const listHidden = this.getProp("loading") && this.getState("visible");
|
|
128
128
|
switch (isComposing(event) ? "" : event.key) {
|
|
129
129
|
case "ArrowUp":
|
|
@@ -144,34 +144,34 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
144
144
|
break;
|
|
145
145
|
case "Tab": this.#closeDropdown();
|
|
146
146
|
}
|
|
147
|
-
this.
|
|
148
|
-
}
|
|
147
|
+
this.adapter.notifyKeyDown(event);
|
|
148
|
+
};
|
|
149
149
|
/** Mousedown outside the input and dropdown while shown */
|
|
150
|
-
handleClickOutside(_e) {
|
|
150
|
+
handleClickOutside = (_e) => {
|
|
151
151
|
this.#closeDropdown();
|
|
152
|
-
}
|
|
152
|
+
};
|
|
153
153
|
/**
|
|
154
154
|
* Hides the dropdown and reports dropdownVisibleChange(false), without blurring the input or moving focus.
|
|
155
155
|
* Called when Vue KeepAlive deactivates the host.
|
|
156
156
|
*/
|
|
157
|
-
close() {
|
|
157
|
+
close = () => {
|
|
158
158
|
this.#closeDropdown();
|
|
159
|
-
}
|
|
160
|
-
handleInputClick(e) {
|
|
159
|
+
};
|
|
160
|
+
handleInputClick = (e) => {
|
|
161
161
|
const { disabled } = this.getProps();
|
|
162
162
|
if (!disabled && !isInnerControlActivation(e)) {
|
|
163
163
|
if (this.getState("visible")) this.#closeDropdown();
|
|
164
164
|
else this.#openDropdown();
|
|
165
165
|
}
|
|
166
|
-
}
|
|
167
|
-
handleSearch(inputValue) {
|
|
168
|
-
this.
|
|
169
|
-
this.
|
|
170
|
-
this.
|
|
166
|
+
};
|
|
167
|
+
handleSearch = (inputValue) => {
|
|
168
|
+
this.adapter.updateInputValue(inputValue);
|
|
169
|
+
this.adapter.notifySearch(inputValue);
|
|
170
|
+
this.adapter.notifyChange(inputValue);
|
|
171
171
|
this.#modifyFocusIndex(inputValue);
|
|
172
172
|
if (!this.getState("visible")) this.#openDropdown();
|
|
173
|
-
}
|
|
174
|
-
handleSelect(stateOption, optionIndex) {
|
|
173
|
+
};
|
|
174
|
+
handleSelect = (stateOption, optionIndex) => {
|
|
175
175
|
const { renderSelectedItem } = this.getProps();
|
|
176
176
|
const option = AutoCompleteFoundation.#toDataItem(stateOption);
|
|
177
177
|
let newInputValue = "";
|
|
@@ -179,41 +179,41 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
179
179
|
newInputValue = renderSelectedItem(option);
|
|
180
180
|
warning(typeof newInputValue !== "string", "Warning: [Semi AutoComplete] renderSelectedItem must return string, please check your function return");
|
|
181
181
|
} else newInputValue = option.value;
|
|
182
|
-
if (this.
|
|
182
|
+
if (this.isControlledComponent()) {
|
|
183
183
|
this.#closeDropdown();
|
|
184
184
|
this.#notifySelect(option);
|
|
185
185
|
} else {
|
|
186
|
-
this.
|
|
186
|
+
this.adapter.updateInputValue(newInputValue);
|
|
187
187
|
this.#updateSelection(option);
|
|
188
188
|
this.#notifySelect(option);
|
|
189
189
|
this.#closeDropdown();
|
|
190
190
|
}
|
|
191
|
-
this.
|
|
192
|
-
this.
|
|
193
|
-
}
|
|
194
|
-
handleDataChange(newData) {
|
|
191
|
+
this.adapter.notifyChange(newInputValue);
|
|
192
|
+
this.adapter.updateFocusIndex(optionIndex);
|
|
193
|
+
};
|
|
194
|
+
handleDataChange = (newData) => {
|
|
195
195
|
const options = AutoCompleteFoundation.#generateList(newData);
|
|
196
|
-
this.
|
|
196
|
+
this.adapter.updateOptionList(options);
|
|
197
197
|
let { inputValue } = this.getStates();
|
|
198
198
|
this.#modifyFocusIndex(inputValue);
|
|
199
|
-
}
|
|
200
|
-
handleValueChange(selectedValue) {
|
|
199
|
+
};
|
|
200
|
+
handleValueChange = (selectedValue) => {
|
|
201
201
|
const { inputValue, selection, focusIndex } = AutoCompleteFoundation.#valueStates(this.getProps(), selectedValue);
|
|
202
|
-
this.
|
|
203
|
-
this.
|
|
204
|
-
this.
|
|
205
|
-
}
|
|
206
|
-
handleClear() {
|
|
207
|
-
this.
|
|
208
|
-
}
|
|
209
|
-
handleOptionMouseEnter(optionIndex) {
|
|
210
|
-
this.
|
|
211
|
-
}
|
|
212
|
-
handleFocus(e) {
|
|
213
|
-
this.
|
|
214
|
-
}
|
|
215
|
-
handleBlur(e) {
|
|
216
|
-
this.
|
|
217
|
-
}
|
|
202
|
+
this.adapter.updateInputValue(inputValue);
|
|
203
|
+
this.adapter.updateSelection(selection);
|
|
204
|
+
this.adapter.updateFocusIndex(focusIndex);
|
|
205
|
+
};
|
|
206
|
+
handleClear = () => {
|
|
207
|
+
this.adapter.notifyClear();
|
|
208
|
+
};
|
|
209
|
+
handleOptionMouseEnter = (optionIndex) => {
|
|
210
|
+
this.adapter.updateFocusIndex(optionIndex);
|
|
211
|
+
};
|
|
212
|
+
handleFocus = (e) => {
|
|
213
|
+
this.adapter.notifyFocus(e);
|
|
214
|
+
};
|
|
215
|
+
handleBlur = (e) => {
|
|
216
|
+
this.adapter.notifyBlur(e);
|
|
217
|
+
};
|
|
218
218
|
};
|
|
219
219
|
export { AutoCompleteFoundation as default };
|
|
@@ -21,9 +21,9 @@ export interface AvatarAdapter<P = AvatarBaseProps, S = AvatarBaseState, E = unk
|
|
|
21
21
|
export default class AvatarFoundation<P extends AvatarBaseProps = AvatarBaseProps, S extends AvatarBaseState = AvatarBaseState, E = unknown> extends BaseFoundation<AvatarAdapter<P, S, E>, P, S> {
|
|
22
22
|
init(): void;
|
|
23
23
|
destroy(): void;
|
|
24
|
-
handleSrcChange()
|
|
25
|
-
handleImgLoadError()
|
|
26
|
-
handleEnter(e: E)
|
|
27
|
-
handleLeave(e: E)
|
|
28
|
-
changeScale()
|
|
24
|
+
handleSrcChange: () => void;
|
|
25
|
+
handleImgLoadError: () => void;
|
|
26
|
+
handleEnter: (e: E) => void;
|
|
27
|
+
handleLeave: (e: E) => void;
|
|
28
|
+
changeScale: () => void;
|
|
29
29
|
}
|
|
@@ -5,27 +5,27 @@ var AvatarFoundation = class extends BaseFoundation {
|
|
|
5
5
|
this.changeScale();
|
|
6
6
|
}
|
|
7
7
|
destroy() {}
|
|
8
|
-
handleSrcChange() {
|
|
9
|
-
this.
|
|
10
|
-
}
|
|
11
|
-
handleImgLoadError() {
|
|
12
|
-
if (this.
|
|
13
|
-
}
|
|
14
|
-
handleEnter(e) {
|
|
15
|
-
this.
|
|
16
|
-
}
|
|
17
|
-
handleLeave(e) {
|
|
18
|
-
this.
|
|
19
|
-
}
|
|
20
|
-
changeScale() {
|
|
8
|
+
handleSrcChange = () => {
|
|
9
|
+
this.adapter.setImgExist(true);
|
|
10
|
+
};
|
|
11
|
+
handleImgLoadError = () => {
|
|
12
|
+
if (this.adapter.notifyError() !== false) this.adapter.setImgExist(false);
|
|
13
|
+
};
|
|
14
|
+
handleEnter = (e) => {
|
|
15
|
+
this.adapter.notifyEnter(e);
|
|
16
|
+
};
|
|
17
|
+
handleLeave = (e) => {
|
|
18
|
+
this.adapter.notifyLeave(e);
|
|
19
|
+
};
|
|
20
|
+
changeScale = () => {
|
|
21
21
|
const { gap } = this.getProps();
|
|
22
|
-
const widths = this.
|
|
22
|
+
const widths = this.adapter.getTextWidths();
|
|
23
23
|
if (!widths) return;
|
|
24
24
|
const { container: nodeWidth, text: stringNodeWidth } = widths;
|
|
25
25
|
if (nodeWidth !== 0 && stringNodeWidth !== 0 && gap * 2 < nodeWidth) {
|
|
26
26
|
const scale = nodeWidth - gap * 2 > stringNodeWidth ? 1 : (nodeWidth - gap * 2) / stringNodeWidth;
|
|
27
|
-
this.
|
|
27
|
+
this.adapter.setScale(scale);
|
|
28
28
|
}
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
30
|
};
|
|
31
31
|
export { AvatarFoundation as default };
|
|
@@ -20,7 +20,7 @@ export default class BackTopFoundation<P extends BackTopBaseProps = BackTopBaseP
|
|
|
20
20
|
static warnInteractiveChildren(button?: Element | null): void;
|
|
21
21
|
init(): void;
|
|
22
22
|
/** Rebinds the scroll listener when `target` returns a different element */
|
|
23
|
-
handleTargetChange()
|
|
23
|
+
handleTargetChange: () => void;
|
|
24
24
|
destroy(): void;
|
|
25
|
-
onClick(e: E)
|
|
25
|
+
onClick: (e: E) => void;
|
|
26
26
|
}
|
|
@@ -20,14 +20,14 @@ var BackTopFoundation = class extends BaseFoundation {
|
|
|
20
20
|
cancelAnimationFrame(this.#frame);
|
|
21
21
|
}
|
|
22
22
|
#getScroll(target) {
|
|
23
|
-
return
|
|
23
|
+
return "scrollY" in target ? target.scrollY : target.scrollTop;
|
|
24
24
|
}
|
|
25
25
|
#handleScroll = () => {
|
|
26
26
|
cancelAnimationFrame(this.#frame);
|
|
27
27
|
this.#frame = requestAnimationFrame(() => {
|
|
28
28
|
const { visibilityHeight } = this.getProps();
|
|
29
29
|
const visible = this.#getScroll(this.#targetNode) > visibilityHeight;
|
|
30
|
-
if (visible !== Boolean(this.getStates().visible)) this.
|
|
30
|
+
if (visible !== Boolean(this.getStates().visible)) this.adapter.updateVisible(visible);
|
|
31
31
|
});
|
|
32
32
|
};
|
|
33
33
|
/** Children sit inside a native button, so interactive ones would nest; development only */
|
|
@@ -38,17 +38,17 @@ var BackTopFoundation = class extends BaseFoundation {
|
|
|
38
38
|
this.#bind();
|
|
39
39
|
}
|
|
40
40
|
/** Rebinds the scroll listener when `target` returns a different element */
|
|
41
|
-
handleTargetChange() {
|
|
41
|
+
handleTargetChange = () => {
|
|
42
42
|
if (this.getProps().target() !== this.#targetNode) {
|
|
43
43
|
this.#unbind();
|
|
44
44
|
this.#bind();
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
};
|
|
47
47
|
destroy() {
|
|
48
48
|
this.#unbind();
|
|
49
49
|
this.#cancelAnimation?.();
|
|
50
50
|
}
|
|
51
|
-
onClick(e) {
|
|
51
|
+
onClick = (e) => {
|
|
52
52
|
const targetNode = this.#targetNode;
|
|
53
53
|
if (targetNode) {
|
|
54
54
|
this.#cancelAnimation?.();
|
|
@@ -63,7 +63,7 @@ var BackTopFoundation = class extends BaseFoundation {
|
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
this.
|
|
67
|
-
}
|
|
66
|
+
this.adapter.notifyClick(e);
|
|
67
|
+
};
|
|
68
68
|
};
|
|
69
69
|
export { BackTopFoundation as default };
|
|
@@ -5,5 +5,5 @@ export interface BannerAdapter<P extends object = object, S extends object = obj
|
|
|
5
5
|
notifyClose: (e: E) => void;
|
|
6
6
|
}
|
|
7
7
|
export default class BannerFoundation<P extends object = object, S extends object = object, E = unknown> extends BaseFoundation<BannerAdapter<P, S, E>, P, S> {
|
|
8
|
-
removeBanner(e: E)
|
|
8
|
+
removeBanner: (e: E) => void;
|
|
9
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import BaseFoundation from "../base/foundation.js";
|
|
2
2
|
// src/banner/foundation.ts
|
|
3
3
|
var BannerFoundation = class extends BaseFoundation {
|
|
4
|
-
removeBanner(e) {
|
|
5
|
-
this.
|
|
6
|
-
this.
|
|
7
|
-
}
|
|
4
|
+
removeBanner = (e) => {
|
|
5
|
+
this.adapter.notifyClose(e);
|
|
6
|
+
this.adapter.hide();
|
|
7
|
+
};
|
|
8
8
|
};
|
|
9
9
|
export { BannerFoundation as default };
|
|
@@ -15,16 +15,16 @@ export default class AutoCloseFoundation<P extends AutoCloseBaseProps = AutoClos
|
|
|
15
15
|
#private;
|
|
16
16
|
init(): void;
|
|
17
17
|
destroy(): void;
|
|
18
|
-
leave()
|
|
19
|
-
pauseCloseTimer()
|
|
20
|
-
resumeCloseTimer()
|
|
18
|
+
leave: () => void;
|
|
19
|
+
pauseCloseTimer: () => void;
|
|
20
|
+
resumeCloseTimer: () => void;
|
|
21
21
|
startCloseTimer(): void;
|
|
22
|
-
clickClose(e: {
|
|
22
|
+
clickClose: (e: {
|
|
23
23
|
stopPropagation: () => void;
|
|
24
|
-
})
|
|
25
|
-
close(e?: {
|
|
24
|
+
}) => void;
|
|
25
|
+
close: (e?: {
|
|
26
26
|
stopPropagation: () => void;
|
|
27
|
-
})
|
|
27
|
+
}) => void;
|
|
28
28
|
clearCloseTimer(): void;
|
|
29
|
-
restartCloseTimer()
|
|
29
|
+
restartCloseTimer: () => void;
|
|
30
30
|
}
|