@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
|
@@ -12,7 +12,6 @@ export interface AnchorAdapter<P extends AnchorBaseProps = AnchorBaseProps, S ex
|
|
|
12
12
|
notifyChange: (currentLink: string, previousLink: string) => void;
|
|
13
13
|
notifyClick: (e: E, link: string) => void;
|
|
14
14
|
}
|
|
15
|
-
/** The props the foundation reads */
|
|
16
15
|
export interface AnchorBaseProps {
|
|
17
16
|
defaultAnchor?: string;
|
|
18
17
|
scrollMotion?: boolean;
|
|
@@ -20,7 +19,6 @@ export interface AnchorBaseProps {
|
|
|
20
19
|
offsetTop?: number;
|
|
21
20
|
scrollIntoViewOptions?: Options;
|
|
22
21
|
}
|
|
23
|
-
/** The state the foundation reads */
|
|
24
22
|
export interface AnchorBaseState {
|
|
25
23
|
activeLink: string;
|
|
26
24
|
links: string[];
|
|
@@ -40,8 +38,7 @@ export default class AnchorFoundation<P extends AnchorBaseProps = AnchorBaseProp
|
|
|
40
38
|
/** Runs once the links have registered: listens to the container, applies `defaultAnchor` */
|
|
41
39
|
init(): void;
|
|
42
40
|
destroy(): void;
|
|
43
|
-
|
|
44
|
-
handleContainerChange(): void;
|
|
41
|
+
handleContainerChange: () => void;
|
|
45
42
|
syncSlideBar: () => void;
|
|
46
43
|
addLink: (link: string) => void;
|
|
47
44
|
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
|
}
|
|
@@ -113,31 +113,30 @@ var AnchorFoundation = class extends BaseFoundation {
|
|
|
113
113
|
this.#throttledScroll.cancel();
|
|
114
114
|
this.#debouncedScrollEnd.cancel();
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (this._adapter.getContainer() !== this.#container) {
|
|
116
|
+
handleContainerChange = () => {
|
|
117
|
+
if (this.adapter.getContainer() !== this.#container) {
|
|
119
118
|
this.#unbind();
|
|
120
119
|
this.#bind();
|
|
121
120
|
}
|
|
122
|
-
}
|
|
121
|
+
};
|
|
123
122
|
syncSlideBar = () => {
|
|
124
|
-
const linkNode = this.
|
|
123
|
+
const linkNode = this.adapter.getAnchorNode(`.${cssClasses.PREFIX}-link-title-active`);
|
|
125
124
|
if (linkNode && linkNode.offsetTop !== this.#slideBarTop) {
|
|
126
125
|
this.#slideBarTop = linkNode.offsetTop;
|
|
127
|
-
this.
|
|
126
|
+
this.adapter.setState({ slideBarTop: `${this.#slideBarTop}px` });
|
|
128
127
|
}
|
|
129
128
|
};
|
|
130
129
|
addLink = (link) => {
|
|
131
|
-
this.
|
|
130
|
+
this.adapter.setState({ links: [...this.getState("links"), link] });
|
|
132
131
|
};
|
|
133
132
|
removeLink = (link) => {
|
|
134
133
|
const links = this.getState("links");
|
|
135
134
|
const index = links.indexOf(link);
|
|
136
|
-
if (index !== -1) this.
|
|
135
|
+
if (index !== -1) this.adapter.setState({ links: links.toSpliced(index, 1) });
|
|
137
136
|
};
|
|
138
137
|
handleClick = (e, link) => {
|
|
139
138
|
this.#goToLink(link, true);
|
|
140
|
-
this.
|
|
139
|
+
this.adapter.notifyClick(e, link);
|
|
141
140
|
};
|
|
142
141
|
};
|
|
143
142
|
export { AnchorFoundation as default };
|
|
@@ -4,12 +4,10 @@ export type AudioInfo = {
|
|
|
4
4
|
cover?: string;
|
|
5
5
|
src: string;
|
|
6
6
|
};
|
|
7
|
-
/** The props the foundation reads with getProp */
|
|
8
7
|
export interface AudioPlayerBaseProps {
|
|
9
8
|
audioUrl: string | AudioInfo | (AudioInfo | string)[];
|
|
10
9
|
skipDuration?: number;
|
|
11
10
|
}
|
|
12
|
-
/** The state the foundation reads and writes */
|
|
13
11
|
export interface AudioPlayerBaseState {
|
|
14
12
|
isPlaying: boolean;
|
|
15
13
|
currentIndex: number;
|
|
@@ -30,17 +28,16 @@ export default class AudioPlayerFoundation<P extends AudioPlayerBaseProps = Audi
|
|
|
30
28
|
init(): void;
|
|
31
29
|
handleAudioPlay: () => void;
|
|
32
30
|
handleAudioPause: () => void;
|
|
33
|
-
handleStatusClick()
|
|
34
|
-
handleTimeUpdate()
|
|
35
|
-
handleTrackChange(direction:
|
|
36
|
-
handleTimeChange(value: number)
|
|
37
|
-
handleSpeedChange(value: {
|
|
31
|
+
handleStatusClick: () => void;
|
|
32
|
+
handleTimeUpdate: () => void;
|
|
33
|
+
handleTrackChange: (direction: "next" | "prev") => void;
|
|
34
|
+
handleTimeChange: (value: number) => void;
|
|
35
|
+
handleSpeedChange: (value: {
|
|
38
36
|
label: string;
|
|
39
37
|
value: number;
|
|
40
|
-
})
|
|
41
|
-
handleSeek(direction: number)
|
|
42
|
-
handleRefresh()
|
|
43
|
-
handleVolumeChange(value: number)
|
|
44
|
-
|
|
45
|
-
handleVolumeSilent(): void;
|
|
38
|
+
}) => void;
|
|
39
|
+
handleSeek: (direction: number) => void;
|
|
40
|
+
handleRefresh: () => void;
|
|
41
|
+
handleVolumeChange: (value: number) => void;
|
|
42
|
+
handleVolumeSilent: () => void;
|
|
46
43
|
}
|
|
@@ -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,16 @@ 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
|
-
}
|
|
111
|
-
|
|
112
|
-
handleVolumeSilent() {
|
|
110
|
+
};
|
|
111
|
+
handleVolumeSilent = () => {
|
|
113
112
|
this.handleVolumeChange(this.getState("volume") === 0 ? 50 : 0);
|
|
114
|
-
}
|
|
113
|
+
};
|
|
115
114
|
};
|
|
116
115
|
export { AudioPlayerFoundation as default };
|
|
@@ -11,7 +11,6 @@ export interface StateOptionItem extends DataItem {
|
|
|
11
11
|
_source?: DataItem | string | number;
|
|
12
12
|
}
|
|
13
13
|
export type AutoCompleteData = ReadonlyArray<DataItem | string | number>;
|
|
14
|
-
/** The props the foundation reads with getProps */
|
|
15
14
|
export interface AutoCompleteBaseProps {
|
|
16
15
|
data?: AutoCompleteData;
|
|
17
16
|
defaultActiveFirstOption?: boolean;
|
|
@@ -23,7 +22,6 @@ export interface AutoCompleteBaseProps {
|
|
|
23
22
|
renderSelectedItem?(this: void, option: DataItem): string;
|
|
24
23
|
value?: string | number;
|
|
25
24
|
}
|
|
26
|
-
/** The state the foundation reads with getStates */
|
|
27
25
|
export interface AutoCompleteBaseState {
|
|
28
26
|
focusIndex: number;
|
|
29
27
|
inputValue?: string | number;
|
|
@@ -57,21 +55,21 @@ export default class AutoCompleteFoundation<P extends AutoCompleteBaseProps = Au
|
|
|
57
55
|
visible: boolean;
|
|
58
56
|
};
|
|
59
57
|
init(): void;
|
|
60
|
-
handleKeyDown(event: Pick<KeyboardEvent,
|
|
58
|
+
handleKeyDown: (event: Pick<KeyboardEvent, "key" | "preventDefault"> & Parameters<typeof isComposing>[0]) => void;
|
|
61
59
|
/** Mousedown outside the input and dropdown while shown */
|
|
62
|
-
handleClickOutside(_e: MouseEvent)
|
|
60
|
+
handleClickOutside: (_e: MouseEvent) => void;
|
|
63
61
|
/**
|
|
64
62
|
* Hides the dropdown and reports dropdownVisibleChange(false), without blurring the input or moving focus.
|
|
65
63
|
* Called when Vue KeepAlive deactivates the host.
|
|
66
64
|
*/
|
|
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)
|
|
65
|
+
close: () => void;
|
|
66
|
+
handleInputClick: (e: Pick<MouseEvent, "detail" | "target" | "currentTarget">) => void;
|
|
67
|
+
handleSearch: (inputValue: string) => void;
|
|
68
|
+
handleSelect: (stateOption: StateOptionItem, optionIndex?: number) => void;
|
|
69
|
+
handleDataChange: (newData: any[]) => void;
|
|
70
|
+
handleValueChange: (selectedValue: AutoCompleteBaseProps["value"]) => void;
|
|
71
|
+
handleClear: () => void;
|
|
72
|
+
handleOptionMouseEnter: (optionIndex: number) => void;
|
|
73
|
+
handleFocus: (e: FE) => void;
|
|
74
|
+
handleBlur: (e: FE) => void;
|
|
77
75
|
}
|
|
@@ -29,7 +29,6 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
29
29
|
static #getRenderSelectedItem({ renderSelectedItem }) {
|
|
30
30
|
return renderSelectedItem ?? ((option) => option?.value);
|
|
31
31
|
}
|
|
32
|
-
/** The input text, selection and highlight that `selectedValue` shows */
|
|
33
32
|
static #valueStates(props, selectedValue) {
|
|
34
33
|
if (selectedValue === void 0) return {
|
|
35
34
|
inputValue: "",
|
|
@@ -64,8 +63,8 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
64
63
|
selectedOptionIndex = AutoCompleteFoundation.#generateList(data).findIndex((option) => renderSelectedItem(AutoCompleteFoundation.#toDataItem(option)) === searchValue);
|
|
65
64
|
}
|
|
66
65
|
if (selectedOptionIndex === -1 && defaultActiveFirstOption) {
|
|
67
|
-
if (focusIndex !== 0) this.
|
|
68
|
-
} else if (selectedOptionIndex !== focusIndex) this.
|
|
66
|
+
if (focusIndex !== 0) this.adapter.updateFocusIndex(0);
|
|
67
|
+
} else if (selectedOptionIndex !== focusIndex) this.adapter.updateFocusIndex(selectedOptionIndex);
|
|
69
68
|
}
|
|
70
69
|
#modifyFocusIndexOnPanelOpen() {
|
|
71
70
|
let { inputValue } = this.getStates();
|
|
@@ -75,8 +74,8 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
75
74
|
const { focusIndex, options } = this.getStates();
|
|
76
75
|
const visibleOptions = options.filter((item) => item.show);
|
|
77
76
|
const index = getEnabledStepIndex(offset, focusIndex, visibleOptions.length, (i) => visibleOptions[i].disabled);
|
|
78
|
-
this.
|
|
79
|
-
if (index !== -1) this.
|
|
77
|
+
this.adapter.updateFocusIndex(index);
|
|
78
|
+
if (index !== -1) this.adapter.updateScrollTop(index);
|
|
80
79
|
}
|
|
81
80
|
#handleArrowKeyDown(offset) {
|
|
82
81
|
const { visible } = this.getStates();
|
|
@@ -92,23 +91,23 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
92
91
|
} else this.#closeDropdown();
|
|
93
92
|
}
|
|
94
93
|
#openDropdown() {
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
94
|
+
this.adapter.toggleListVisible(true);
|
|
95
|
+
this.adapter.notifyDropdownVisibleChange(true);
|
|
97
96
|
this.#modifyFocusIndexOnPanelOpen();
|
|
98
97
|
}
|
|
99
98
|
#closeDropdown() {
|
|
100
99
|
if (!this.getState("visible")) return;
|
|
101
|
-
this.
|
|
102
|
-
this.
|
|
100
|
+
this.adapter.toggleListVisible(false);
|
|
101
|
+
this.adapter.notifyDropdownVisibleChange(false);
|
|
103
102
|
}
|
|
104
103
|
#updateSelection(option) {
|
|
105
104
|
const selection = /* @__PURE__ */ new Map();
|
|
106
105
|
if (option) selection.set(option.label, option);
|
|
107
|
-
this.
|
|
106
|
+
this.adapter.updateSelection(selection);
|
|
108
107
|
}
|
|
109
108
|
#notifySelect(option) {
|
|
110
|
-
if (this.#backwardLabelInValue()) this.
|
|
111
|
-
else this.
|
|
109
|
+
if (this.#backwardLabelInValue()) this.adapter.notifySelect(option);
|
|
110
|
+
else this.adapter.notifySelect(option.value);
|
|
112
111
|
}
|
|
113
112
|
static getInitialState(props) {
|
|
114
113
|
const value = props.value !== void 0 ? props.value : props.defaultValue;
|
|
@@ -123,7 +122,7 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
123
122
|
this.#initialized = true;
|
|
124
123
|
if (this.getProp("defaultOpen") && !this.getProp("disabled")) this.#openDropdown();
|
|
125
124
|
}
|
|
126
|
-
handleKeyDown(event) {
|
|
125
|
+
handleKeyDown = (event) => {
|
|
127
126
|
const listHidden = this.getProp("loading") && this.getState("visible");
|
|
128
127
|
switch (isComposing(event) ? "" : event.key) {
|
|
129
128
|
case "ArrowUp":
|
|
@@ -144,34 +143,34 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
144
143
|
break;
|
|
145
144
|
case "Tab": this.#closeDropdown();
|
|
146
145
|
}
|
|
147
|
-
this.
|
|
148
|
-
}
|
|
146
|
+
this.adapter.notifyKeyDown(event);
|
|
147
|
+
};
|
|
149
148
|
/** Mousedown outside the input and dropdown while shown */
|
|
150
|
-
handleClickOutside(_e) {
|
|
149
|
+
handleClickOutside = (_e) => {
|
|
151
150
|
this.#closeDropdown();
|
|
152
|
-
}
|
|
151
|
+
};
|
|
153
152
|
/**
|
|
154
153
|
* Hides the dropdown and reports dropdownVisibleChange(false), without blurring the input or moving focus.
|
|
155
154
|
* Called when Vue KeepAlive deactivates the host.
|
|
156
155
|
*/
|
|
157
|
-
close() {
|
|
156
|
+
close = () => {
|
|
158
157
|
this.#closeDropdown();
|
|
159
|
-
}
|
|
160
|
-
handleInputClick(e) {
|
|
158
|
+
};
|
|
159
|
+
handleInputClick = (e) => {
|
|
161
160
|
const { disabled } = this.getProps();
|
|
162
161
|
if (!disabled && !isInnerControlActivation(e)) {
|
|
163
162
|
if (this.getState("visible")) this.#closeDropdown();
|
|
164
163
|
else this.#openDropdown();
|
|
165
164
|
}
|
|
166
|
-
}
|
|
167
|
-
handleSearch(inputValue) {
|
|
168
|
-
this.
|
|
169
|
-
this.
|
|
170
|
-
this.
|
|
165
|
+
};
|
|
166
|
+
handleSearch = (inputValue) => {
|
|
167
|
+
this.adapter.updateInputValue(inputValue);
|
|
168
|
+
this.adapter.notifySearch(inputValue);
|
|
169
|
+
this.adapter.notifyChange(inputValue);
|
|
171
170
|
this.#modifyFocusIndex(inputValue);
|
|
172
171
|
if (!this.getState("visible")) this.#openDropdown();
|
|
173
|
-
}
|
|
174
|
-
handleSelect(stateOption, optionIndex) {
|
|
172
|
+
};
|
|
173
|
+
handleSelect = (stateOption, optionIndex) => {
|
|
175
174
|
const { renderSelectedItem } = this.getProps();
|
|
176
175
|
const option = AutoCompleteFoundation.#toDataItem(stateOption);
|
|
177
176
|
let newInputValue = "";
|
|
@@ -179,41 +178,41 @@ var AutoCompleteFoundation = class AutoCompleteFoundation extends BaseFoundation
|
|
|
179
178
|
newInputValue = renderSelectedItem(option);
|
|
180
179
|
warning(typeof newInputValue !== "string", "Warning: [Semi AutoComplete] renderSelectedItem must return string, please check your function return");
|
|
181
180
|
} else newInputValue = option.value;
|
|
182
|
-
if (this.
|
|
181
|
+
if (this.isControlledComponent()) {
|
|
183
182
|
this.#closeDropdown();
|
|
184
183
|
this.#notifySelect(option);
|
|
185
184
|
} else {
|
|
186
|
-
this.
|
|
185
|
+
this.adapter.updateInputValue(newInputValue);
|
|
187
186
|
this.#updateSelection(option);
|
|
188
187
|
this.#notifySelect(option);
|
|
189
188
|
this.#closeDropdown();
|
|
190
189
|
}
|
|
191
|
-
this.
|
|
192
|
-
this.
|
|
193
|
-
}
|
|
194
|
-
handleDataChange(newData) {
|
|
190
|
+
this.adapter.notifyChange(newInputValue);
|
|
191
|
+
this.adapter.updateFocusIndex(optionIndex);
|
|
192
|
+
};
|
|
193
|
+
handleDataChange = (newData) => {
|
|
195
194
|
const options = AutoCompleteFoundation.#generateList(newData);
|
|
196
|
-
this.
|
|
195
|
+
this.adapter.updateOptionList(options);
|
|
197
196
|
let { inputValue } = this.getStates();
|
|
198
197
|
this.#modifyFocusIndex(inputValue);
|
|
199
|
-
}
|
|
200
|
-
handleValueChange(selectedValue) {
|
|
198
|
+
};
|
|
199
|
+
handleValueChange = (selectedValue) => {
|
|
201
200
|
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
|
-
}
|
|
201
|
+
this.adapter.updateInputValue(inputValue);
|
|
202
|
+
this.adapter.updateSelection(selection);
|
|
203
|
+
this.adapter.updateFocusIndex(focusIndex);
|
|
204
|
+
};
|
|
205
|
+
handleClear = () => {
|
|
206
|
+
this.adapter.notifyClear();
|
|
207
|
+
};
|
|
208
|
+
handleOptionMouseEnter = (optionIndex) => {
|
|
209
|
+
this.adapter.updateFocusIndex(optionIndex);
|
|
210
|
+
};
|
|
211
|
+
handleFocus = (e) => {
|
|
212
|
+
this.adapter.notifyFocus(e);
|
|
213
|
+
};
|
|
214
|
+
handleBlur = (e) => {
|
|
215
|
+
this.adapter.notifyBlur(e);
|
|
216
|
+
};
|
|
218
217
|
};
|
|
219
218
|
export { AutoCompleteFoundation as default };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation.js";
|
|
2
|
-
/** The props the foundation reads */
|
|
3
2
|
export interface AvatarBaseProps {
|
|
4
3
|
gap?: number;
|
|
5
4
|
}
|
|
@@ -21,9 +20,9 @@ export interface AvatarAdapter<P = AvatarBaseProps, S = AvatarBaseState, E = unk
|
|
|
21
20
|
export default class AvatarFoundation<P extends AvatarBaseProps = AvatarBaseProps, S extends AvatarBaseState = AvatarBaseState, E = unknown> extends BaseFoundation<AvatarAdapter<P, S, E>, P, S> {
|
|
22
21
|
init(): void;
|
|
23
22
|
destroy(): void;
|
|
24
|
-
handleSrcChange()
|
|
25
|
-
handleImgLoadError()
|
|
26
|
-
handleEnter(e: E)
|
|
27
|
-
handleLeave(e: E)
|
|
28
|
-
changeScale()
|
|
23
|
+
handleSrcChange: () => void;
|
|
24
|
+
handleImgLoadError: () => void;
|
|
25
|
+
handleEnter: (e: E) => void;
|
|
26
|
+
handleLeave: (e: E) => void;
|
|
27
|
+
changeScale: () => void;
|
|
29
28
|
}
|
|
@@ -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 };
|
|
@@ -91,7 +91,6 @@ $width-avatar-bottom_slot_square_extra_large-border: 2px; // extra large 头像
|
|
|
91
91
|
|
|
92
92
|
$color-avatar-top_slot_text: var(--semi-color-bg-0); //顶部 Slot 文字颜色
|
|
93
93
|
|
|
94
|
-
// top slot offset; positions the slot together with the scale below
|
|
95
94
|
$spacing-avatar-top_slot_small-shift: -28px; // small 顶部 slot 偏移量, 和 scale 一起控制 slot 的位置
|
|
96
95
|
$spacing-avatar-top_slot_default-shift: -32px; // default 顶部 slot 偏移量, 和 scale 一起控制 slot 的位置
|
|
97
96
|
$spacing-avatar-top_slot_medium-shift: -30px; // medium 顶部 slot 偏移量, 和 scale 一起控制 slot 的位置
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation.js";
|
|
2
|
-
/** What `target()` returns: the window or a scrollable element */
|
|
3
2
|
export type Target = Window | HTMLElement;
|
|
4
|
-
/** The props the foundation reads */
|
|
5
3
|
export interface BackTopBaseProps {
|
|
6
4
|
target?: () => Target | null;
|
|
7
5
|
visibilityHeight?: number;
|
|
@@ -19,8 +17,7 @@ export default class BackTopFoundation<P extends BackTopBaseProps = BackTopBaseP
|
|
|
19
17
|
/** Children sit inside a native button, so interactive ones would nest; development only */
|
|
20
18
|
static warnInteractiveChildren(button?: Element | null): void;
|
|
21
19
|
init(): void;
|
|
22
|
-
|
|
23
|
-
handleTargetChange(): void;
|
|
20
|
+
handleTargetChange: () => void;
|
|
24
21
|
destroy(): void;
|
|
25
|
-
onClick(e: E)
|
|
22
|
+
onClick: (e: E) => void;
|
|
26
23
|
}
|
|
@@ -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 */
|
|
@@ -37,18 +37,17 @@ var BackTopFoundation = class extends BaseFoundation {
|
|
|
37
37
|
init() {
|
|
38
38
|
this.#bind();
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
handleTargetChange() {
|
|
40
|
+
handleTargetChange = () => {
|
|
42
41
|
if (this.getProps().target() !== this.#targetNode) {
|
|
43
42
|
this.#unbind();
|
|
44
43
|
this.#bind();
|
|
45
44
|
}
|
|
46
|
-
}
|
|
45
|
+
};
|
|
47
46
|
destroy() {
|
|
48
47
|
this.#unbind();
|
|
49
48
|
this.#cancelAnimation?.();
|
|
50
49
|
}
|
|
51
|
-
onClick(e) {
|
|
50
|
+
onClick = (e) => {
|
|
52
51
|
const targetNode = this.#targetNode;
|
|
53
52
|
if (targetNode) {
|
|
54
53
|
this.#cancelAnimation?.();
|
|
@@ -63,7 +62,7 @@ var BackTopFoundation = class extends BaseFoundation {
|
|
|
63
62
|
}
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
|
-
this.
|
|
67
|
-
}
|
|
65
|
+
this.adapter.notifyClick(e);
|
|
66
|
+
};
|
|
68
67
|
};
|
|
69
68
|
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
|
}
|