@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
|
@@ -66,19 +66,19 @@ export default class PreviewInnerFoundation<P extends PreviewInnerBaseProps = Pr
|
|
|
66
66
|
static getSrcList(src: string | string[]): string[];
|
|
67
67
|
static getCurrentIndex(props: Record<string, any>, state: Record<string, any>): number;
|
|
68
68
|
static canSwitch(direction: 'prev' | 'next', currentIndex: number, total: number, infinite: boolean): boolean;
|
|
69
|
-
beforeShow()
|
|
70
|
-
afterHide()
|
|
69
|
+
beforeShow: () => void;
|
|
70
|
+
afterHide: () => void;
|
|
71
71
|
destroy(): void;
|
|
72
|
-
handleMouseMove: (e:
|
|
73
|
-
handleKeyboardActivity: (e:
|
|
74
|
-
updateTimer()
|
|
72
|
+
handleMouseMove: (e: unknown) => void;
|
|
73
|
+
handleKeyboardActivity: (e: unknown) => void;
|
|
74
|
+
updateTimer: () => void;
|
|
75
75
|
handleWheel: (e: WheelEvent) => void;
|
|
76
|
-
handleMouseUp(e: MouseEvent)
|
|
76
|
+
handleMouseUp: (e: MouseEvent) => void;
|
|
77
77
|
handleMouseDown: ({ button, clientX, clientY }: Pick<MouseEvent, "button" | "clientX" | "clientY">) => void;
|
|
78
|
-
handleKeyDown(e: KeyboardEvent)
|
|
79
|
-
handleSwitchImage(direction: SwitchDirection)
|
|
78
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
79
|
+
handleSwitchImage: (direction: SwitchDirection) => void;
|
|
80
80
|
handleDownload: () => void;
|
|
81
|
-
handlePreviewClose: (e:
|
|
81
|
+
handlePreviewClose: (e: Pick<Event, "preventDefault" | "stopPropagation">) => void;
|
|
82
82
|
handleAdjustRatio: (type: RatioType) => void;
|
|
83
83
|
handleRotateImage: (direction: RotateDirection) => void;
|
|
84
84
|
handleZoomImage: (newZoom: number, notify?: boolean, e?: WheelEvent) => void;
|
|
@@ -32,15 +32,15 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
|
|
|
32
32
|
};
|
|
33
33
|
#mouseMoveHandler = throttle((e) => {
|
|
34
34
|
const { viewerVisible } = this.getStates();
|
|
35
|
-
if (this.
|
|
35
|
+
if (this.adapter.isValidTarget(e)) {
|
|
36
36
|
if (!viewerVisible) this.setState({ viewerVisible: true });
|
|
37
37
|
this.updateTimer();
|
|
38
38
|
} else this.#clearTimer();
|
|
39
39
|
}, 50);
|
|
40
40
|
#handleEscape = () => {
|
|
41
41
|
if (!this.getProp("closeOnEsc")) return false;
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
42
|
+
this.adapter.notifyVisibleChange(false);
|
|
43
|
+
this.adapter.notifyClose();
|
|
44
44
|
return true;
|
|
45
45
|
};
|
|
46
46
|
#clearTimer() {
|
|
@@ -91,24 +91,24 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
|
|
|
91
91
|
if (total <= 1) return false;
|
|
92
92
|
return infinite || (direction === "prev" ? currentIndex > 0 : currentIndex < total - 1);
|
|
93
93
|
}
|
|
94
|
-
beforeShow() {
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
94
|
+
beforeShow = () => {
|
|
95
|
+
this.adapter.registerKeyDownListener();
|
|
96
|
+
this.adapter.openLayer(this.#handleEscape);
|
|
97
|
+
this.adapter.disabledBodyScroll();
|
|
98
98
|
this.updateTimer();
|
|
99
|
-
}
|
|
100
|
-
afterHide() {
|
|
101
|
-
this.
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
99
|
+
};
|
|
100
|
+
afterHide = () => {
|
|
101
|
+
this.adapter.unregisterKeyDownListener();
|
|
102
|
+
this.adapter.closeLayer();
|
|
103
|
+
this.adapter.enabledBodyScroll();
|
|
104
104
|
this.#clearTimer();
|
|
105
105
|
this.setState({
|
|
106
106
|
viewerVisible: true,
|
|
107
107
|
rotation: 0,
|
|
108
108
|
preloadAfterVisibleChange: true
|
|
109
109
|
});
|
|
110
|
-
this.
|
|
111
|
-
}
|
|
110
|
+
this.adapter.setRatio("adaptation");
|
|
111
|
+
};
|
|
112
112
|
destroy() {
|
|
113
113
|
this.#mouseMoveHandler.cancel();
|
|
114
114
|
}
|
|
@@ -117,27 +117,27 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
|
|
|
117
117
|
};
|
|
118
118
|
handleKeyboardActivity = (e) => {
|
|
119
119
|
if (!this.getState("viewerVisible")) this.setState({ viewerVisible: true });
|
|
120
|
-
if (this.
|
|
120
|
+
if (this.adapter.isValidTarget(e)) this.updateTimer();
|
|
121
121
|
else this.#clearTimer();
|
|
122
122
|
};
|
|
123
|
-
updateTimer() {
|
|
123
|
+
updateTimer = () => {
|
|
124
124
|
const { viewerVisibleDelay, visible } = this.getProps();
|
|
125
125
|
this.#clearTimer();
|
|
126
126
|
if (visible) this.#timer = setTimeout(this.#handleViewVisibleChange, viewerVisibleDelay);
|
|
127
|
-
}
|
|
127
|
+
};
|
|
128
128
|
handleWheel = (e) => {
|
|
129
129
|
this.#onWheel(e);
|
|
130
130
|
handlePrevent(e);
|
|
131
131
|
};
|
|
132
|
-
handleMouseUp(e) {
|
|
132
|
+
handleMouseUp = (e) => {
|
|
133
133
|
if (e.button !== 0) return;
|
|
134
134
|
const { maskClosable } = this.getProps();
|
|
135
|
-
let couldClose = this.
|
|
135
|
+
let couldClose = this.adapter.isValidTarget(e);
|
|
136
136
|
const { clientX, clientY } = e;
|
|
137
137
|
const { x, y } = this.#startMouseDown;
|
|
138
138
|
if (Math.abs(clientX - x) > 5 || Math.abs(y - clientY) > 5) couldClose = false;
|
|
139
|
-
if (couldClose && maskClosable) this.
|
|
140
|
-
}
|
|
139
|
+
if (couldClose && maskClosable) this.adapter.notifyVisibleChange(false);
|
|
140
|
+
};
|
|
141
141
|
handleMouseDown = ({ button, clientX, clientY }) => {
|
|
142
142
|
if (button !== 0) return;
|
|
143
143
|
this.#startMouseDown = {
|
|
@@ -145,8 +145,8 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
|
|
|
145
145
|
y: clientY
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
|
-
handleKeyDown(e) {
|
|
149
|
-
if (!this.
|
|
148
|
+
handleKeyDown = (e) => {
|
|
149
|
+
if (!this.adapter.isEventInPreview(e)) return;
|
|
150
150
|
if (e.key === "Escape" && this.getProp("closeOnEsc")) return;
|
|
151
151
|
this.handleKeyboardActivity(e);
|
|
152
152
|
if (!(e.key === "ArrowLeft" || e.key === "ArrowRight") || e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || isEditable(e.target)) return;
|
|
@@ -157,50 +157,50 @@ var PreviewInnerFoundation = class PreviewInnerFoundation extends BaseFoundation
|
|
|
157
157
|
e.preventDefault();
|
|
158
158
|
this.handleSwitchImage(direction);
|
|
159
159
|
}
|
|
160
|
-
}
|
|
161
|
-
handleSwitchImage(direction) {
|
|
160
|
+
};
|
|
161
|
+
handleSwitchImage = (direction) => {
|
|
162
162
|
const step = direction === "prev" ? -1 : 1;
|
|
163
163
|
const srcLength = this.#getImgSrc().length;
|
|
164
164
|
const newIndex = (this.#getCurrentIndex() + step + srcLength) % srcLength;
|
|
165
|
-
if (this.
|
|
166
|
-
if (this.
|
|
165
|
+
if (this.isControlledComponent("currentIndex")) {
|
|
166
|
+
if (this.adapter.getIsInGroup()) this.adapter.getContext("setCurrentIndex")?.(newIndex);
|
|
167
167
|
} else this.setState({ currentIndex: newIndex });
|
|
168
|
-
this.
|
|
168
|
+
this.adapter.notifyChange(newIndex, direction);
|
|
169
169
|
this.setState({
|
|
170
170
|
direction,
|
|
171
171
|
rotation: 0
|
|
172
172
|
});
|
|
173
|
-
}
|
|
173
|
+
};
|
|
174
174
|
handleDownload = () => {
|
|
175
175
|
const currentIndex = this.#getCurrentIndex();
|
|
176
|
-
const setDownloadName = this.
|
|
176
|
+
const setDownloadName = this.adapter.getSetDownloadFunc();
|
|
177
177
|
const downloadSrc = this.#getImgSrc()[currentIndex];
|
|
178
178
|
if (downloadSrc === void 0) return;
|
|
179
179
|
const downloadName = setDownloadName ? setDownloadName(downloadSrc) : downloadSrc.slice(downloadSrc.lastIndexOf("/") + 1).split("?")[0];
|
|
180
|
-
downloadImage(downloadSrc, downloadName, this.
|
|
181
|
-
this.
|
|
180
|
+
downloadImage(downloadSrc, downloadName, this.adapter.notifyDownloadError);
|
|
181
|
+
this.adapter.notifyDownload(downloadSrc, currentIndex);
|
|
182
182
|
};
|
|
183
183
|
handlePreviewClose = (e) => {
|
|
184
|
-
this.
|
|
185
|
-
this.
|
|
184
|
+
this.adapter.notifyVisibleChange(false);
|
|
185
|
+
this.adapter.notifyClose();
|
|
186
186
|
handlePrevent(e);
|
|
187
187
|
};
|
|
188
188
|
handleAdjustRatio = (type) => {
|
|
189
|
-
this.
|
|
190
|
-
this.
|
|
189
|
+
this.adapter.setRatio(type);
|
|
190
|
+
this.adapter.notifyRatioChange(type);
|
|
191
191
|
};
|
|
192
192
|
handleRotateImage = (direction) => {
|
|
193
193
|
const { rotation } = this.getStates();
|
|
194
194
|
const newRotation = rotation + (direction === "left" ? -90 : 90);
|
|
195
195
|
this.setState({ rotation: newRotation });
|
|
196
|
-
this.
|
|
196
|
+
this.adapter.notifyRotateChange(newRotation);
|
|
197
197
|
};
|
|
198
198
|
handleZoomImage = (newZoom, notify = true, e) => {
|
|
199
199
|
const { zoom } = this.getStates();
|
|
200
200
|
const { maxZoom, minZoom } = this.getProps();
|
|
201
201
|
const nextZoom = clampZoom(newZoom, minZoom, maxZoom);
|
|
202
202
|
if (zoom !== nextZoom) {
|
|
203
|
-
if (notify) this.
|
|
203
|
+
if (notify) this.adapter.notifyZoom(nextZoom, nextZoom > zoom);
|
|
204
204
|
this.setState({
|
|
205
205
|
zoom: nextZoom,
|
|
206
206
|
zoomEvent: e
|
|
@@ -38,14 +38,14 @@ export default class InputFoundation<P extends InputBaseProps = InputBaseProps,
|
|
|
38
38
|
}, value?: string | number): boolean;
|
|
39
39
|
static getInputType(type: string, mode: string | undefined, eyeClosed: boolean): string;
|
|
40
40
|
init(): void;
|
|
41
|
-
handleValueChange(value: string | number)
|
|
42
|
-
handleClear(e:
|
|
43
|
-
handleClick(e: Pick<Event,
|
|
44
|
-
handleModeChange(mode: string)
|
|
45
|
-
handleClickEye()
|
|
46
|
-
handleBlur(e: unknown)
|
|
47
|
-
handleInput(e: IE)
|
|
48
|
-
handleKeyDown(e: KE)
|
|
49
|
-
handleKeyUp(e: KE)
|
|
50
|
-
handleClickPrefixOrSuffix()
|
|
41
|
+
handleValueChange: (value: string | number) => void;
|
|
42
|
+
handleClear: (e: unknown) => void;
|
|
43
|
+
handleClick: (e: Pick<Event, "target" | "currentTarget">) => void;
|
|
44
|
+
handleModeChange: (mode: string) => void;
|
|
45
|
+
handleClickEye: () => void;
|
|
46
|
+
handleBlur: (e: unknown) => void;
|
|
47
|
+
handleInput: (e: IE) => void;
|
|
48
|
+
handleKeyDown: (e: KE) => void;
|
|
49
|
+
handleKeyUp: (e: KE) => void;
|
|
50
|
+
handleClickPrefixOrSuffix: () => void;
|
|
51
51
|
}
|
package/dist/input/foundation.js
CHANGED
|
@@ -16,64 +16,62 @@ var InputFoundation = class extends TextEntryFoundation {
|
|
|
16
16
|
if (this.#initialized) return;
|
|
17
17
|
this.#initialized = true;
|
|
18
18
|
const { disabled, autoFocus, autofocus } = this.getProps();
|
|
19
|
-
if (!disabled && (autoFocus || autofocus)) this.
|
|
19
|
+
if (!disabled && (autoFocus || autofocus)) this.adapter.focusInput();
|
|
20
20
|
}
|
|
21
|
-
handleValueChange(value) {
|
|
22
|
-
this.
|
|
21
|
+
handleValueChange = (value) => {
|
|
22
|
+
this.adapter.setState({
|
|
23
23
|
value,
|
|
24
24
|
cachedValue: value
|
|
25
25
|
});
|
|
26
|
-
}
|
|
27
|
-
handleClear(e) {
|
|
28
|
-
let eventObj = e;
|
|
26
|
+
};
|
|
27
|
+
handleClear = (e) => {
|
|
29
28
|
const value = "";
|
|
30
|
-
if (!this.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
const { isFocus } = this._adapter.getStates();
|
|
29
|
+
if (!this.isControlledComponent("value")) this.adapter.setValue(value);
|
|
30
|
+
const eventObj = Object.assign(typeof e === "object" && e !== null ? e : {}, { [strings.CLEARBTN_CLICKED_EVENT_FLAG]: true });
|
|
31
|
+
this.adapter.notifyChange(value, eventObj);
|
|
32
|
+
this.adapter.notifyClear(eventObj);
|
|
33
|
+
};
|
|
34
|
+
handleClick = (e) => {
|
|
35
|
+
const { disabled } = this.adapter.getProps();
|
|
36
|
+
const { isFocus } = this.adapter.getStates();
|
|
39
37
|
if (disabled || isFocus) return;
|
|
40
|
-
if (this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
38
|
+
if (this.adapter.isEventTarget(e)) {
|
|
39
|
+
this.adapter.focusInput();
|
|
40
|
+
this.adapter.toggleFocusing(true);
|
|
43
41
|
}
|
|
44
|
-
}
|
|
45
|
-
handleModeChange(mode) {
|
|
46
|
-
if (mode === "password") this.
|
|
47
|
-
else this.
|
|
48
|
-
}
|
|
49
|
-
handleClickEye() {
|
|
50
|
-
const eyeClosed = this.
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
}
|
|
55
|
-
handleBlur(e) {
|
|
42
|
+
};
|
|
43
|
+
handleModeChange = (mode) => {
|
|
44
|
+
if (mode === "password") this.adapter.setEyeClosed(true);
|
|
45
|
+
else this.adapter.setEyeClosed(false);
|
|
46
|
+
};
|
|
47
|
+
handleClickEye = () => {
|
|
48
|
+
const eyeClosed = this.adapter.getState("eyeClosed");
|
|
49
|
+
this.adapter.focusInput();
|
|
50
|
+
this.adapter.toggleFocusing(true);
|
|
51
|
+
this.adapter.setEyeClosed(!eyeClosed);
|
|
52
|
+
};
|
|
53
|
+
handleBlur = (e) => {
|
|
56
54
|
const { value } = this.getStates();
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
}
|
|
60
|
-
handleInput(e) {
|
|
61
|
-
this.
|
|
62
|
-
}
|
|
63
|
-
handleKeyDown(e) {
|
|
64
|
-
this.
|
|
65
|
-
if (e.key === "Enter" && !isComposing(e)) this.
|
|
66
|
-
}
|
|
67
|
-
handleKeyUp(e) {
|
|
68
|
-
this.
|
|
69
|
-
}
|
|
70
|
-
handleClickPrefixOrSuffix() {
|
|
71
|
-
const { disabled } = this.
|
|
72
|
-
const { isFocus } = this.
|
|
55
|
+
this.adapter.toggleFocusing(false);
|
|
56
|
+
this.adapter.notifyBlur(value, e);
|
|
57
|
+
};
|
|
58
|
+
handleInput = (e) => {
|
|
59
|
+
this.adapter.notifyInput(e);
|
|
60
|
+
};
|
|
61
|
+
handleKeyDown = (e) => {
|
|
62
|
+
this.adapter.notifyKeyDown(e);
|
|
63
|
+
if (e.key === "Enter" && !isComposing(e)) this.adapter.notifyEnterPress(e);
|
|
64
|
+
};
|
|
65
|
+
handleKeyUp = (e) => {
|
|
66
|
+
this.adapter.notifyKeyUp(e);
|
|
67
|
+
};
|
|
68
|
+
handleClickPrefixOrSuffix = () => {
|
|
69
|
+
const { disabled } = this.adapter.getProps();
|
|
70
|
+
const { isFocus } = this.adapter.getStates();
|
|
73
71
|
if (!disabled && !isFocus) {
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
72
|
+
this.adapter.focusInput();
|
|
73
|
+
this.adapter.toggleFocusing(true);
|
|
76
74
|
}
|
|
77
|
-
}
|
|
75
|
+
};
|
|
78
76
|
};
|
|
79
77
|
export { InputFoundation as default };
|
|
@@ -47,9 +47,9 @@ export default class TextEntryFoundation<A extends TextEntryAdapter<P, S, CE>, P
|
|
|
47
47
|
}): V;
|
|
48
48
|
/** The length the counter and maxLength count: `getValueLength` when given, otherwise UTF-16 units */
|
|
49
49
|
static getValueCount(value?: string, getValueLength?: (value: string) => number): number;
|
|
50
|
-
handleChange(value: string, e: unknown)
|
|
50
|
+
handleChange: (value: string, e: unknown) => void;
|
|
51
51
|
handleCompositionStart: (e: CE) => void;
|
|
52
|
-
handleCompositionEnd: (e:
|
|
52
|
+
handleCompositionEnd: (e: CE & Pick<Event, "target">) => void;
|
|
53
53
|
handleCompositionUpdate: (e: CE) => void;
|
|
54
|
-
handleFocus(e: unknown)
|
|
54
|
+
handleFocus: (e: unknown) => void;
|
|
55
55
|
}
|
|
@@ -18,8 +18,8 @@ var TextEntryFoundation = class TextEntryFoundation extends BaseFoundation {
|
|
|
18
18
|
return maxLength ? this.handleVisibleMaxLength(value) : value;
|
|
19
19
|
}
|
|
20
20
|
changeValue(value, e) {
|
|
21
|
-
if (!this.
|
|
22
|
-
this.
|
|
21
|
+
if (!this.isControlledComponent()) this.adapter.setValue(value);
|
|
22
|
+
this.adapter.notifyChange(value, e);
|
|
23
23
|
}
|
|
24
24
|
handleVisibleMaxLength(value) {
|
|
25
25
|
const { maxLength, getValueLength } = this.getProps();
|
|
@@ -49,30 +49,30 @@ var TextEntryFoundation = class TextEntryFoundation extends BaseFoundation {
|
|
|
49
49
|
if (!value) return 0;
|
|
50
50
|
return typeof getValueLength === "function" ? getValueLength(value) : value.length;
|
|
51
51
|
}
|
|
52
|
-
handleChange(value, e) {
|
|
52
|
+
handleChange = (value, e) => {
|
|
53
53
|
const { composition } = this.getProps();
|
|
54
54
|
let nextValue = value;
|
|
55
55
|
if (composition && this.#compositionEnter) {
|
|
56
|
-
this.
|
|
56
|
+
this.adapter.setValue(nextValue);
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
if (!this.#compositionEnter) nextValue = this.getNextValue(nextValue);
|
|
60
60
|
this.changeValue(nextValue, e);
|
|
61
|
-
}
|
|
61
|
+
};
|
|
62
62
|
handleCompositionStart = (e) => {
|
|
63
63
|
this.#compositionEnter = true;
|
|
64
64
|
this.#composedSinceFocus = true;
|
|
65
|
-
this.
|
|
65
|
+
this.adapter.notifyCompositionStart(e);
|
|
66
66
|
};
|
|
67
67
|
handleCompositionEnd = (e) => {
|
|
68
68
|
const { composition } = this.getProps();
|
|
69
|
-
const value = e.target.value;
|
|
69
|
+
const value = e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement ? e.target.value : "";
|
|
70
70
|
this.#compositionEnter = false;
|
|
71
|
-
this.
|
|
71
|
+
this.adapter.notifyCompositionEnd(e);
|
|
72
72
|
if (composition) {
|
|
73
73
|
const nextValue = this.getNextValue(value);
|
|
74
74
|
this.changeValue(nextValue, e);
|
|
75
|
-
if (this.
|
|
75
|
+
if (this.isControlledComponent()) this.adapter.setValue(this.getProp("value"));
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
const { getValueLength, maxLength } = this.getProps();
|
|
@@ -81,13 +81,13 @@ var TextEntryFoundation = class TextEntryFoundation extends BaseFoundation {
|
|
|
81
81
|
if (nextValue !== value) this.changeValue(nextValue, e);
|
|
82
82
|
};
|
|
83
83
|
handleCompositionUpdate = (e) => {
|
|
84
|
-
this.
|
|
84
|
+
this.adapter.notifyCompositionUpdate(e);
|
|
85
85
|
};
|
|
86
|
-
handleFocus(e) {
|
|
86
|
+
handleFocus = (e) => {
|
|
87
87
|
const { value } = this.getStates();
|
|
88
88
|
this.#composedSinceFocus = false;
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
91
|
-
}
|
|
89
|
+
this.adapter.toggleFocusing(true);
|
|
90
|
+
this.adapter.notifyFocus(value, e);
|
|
91
|
+
};
|
|
92
92
|
};
|
|
93
93
|
export { TextEntryFoundation as default };
|
|
@@ -44,10 +44,10 @@ export default class TextAreaFoundation<P extends TextAreaBaseProps = TextAreaBa
|
|
|
44
44
|
init(): void;
|
|
45
45
|
destroy(): void;
|
|
46
46
|
/** Re-fits the inline height without field-sizing; hosts call it when the value, `autosize` or the node changes */
|
|
47
|
-
fitAutosize()
|
|
48
|
-
handleValueChange(value: string)
|
|
49
|
-
handleBlur(e: unknown)
|
|
50
|
-
handleKeyDown(e: KE)
|
|
47
|
+
fitAutosize: () => void;
|
|
48
|
+
handleValueChange: (value: string) => void;
|
|
49
|
+
handleBlur: (e: unknown) => void;
|
|
50
|
+
handleKeyDown: (e: KE) => void;
|
|
51
51
|
handleResize: (entries: {
|
|
52
52
|
contentRect?: {
|
|
53
53
|
width: number;
|
|
@@ -55,7 +55,7 @@ export default class TextAreaFoundation<P extends TextAreaBaseProps = TextAreaBa
|
|
|
55
55
|
};
|
|
56
56
|
target?: Element;
|
|
57
57
|
}[]) => void;
|
|
58
|
-
handleClear(e: Pick<Event,
|
|
59
|
-
handleClick(e: Pick<Event,
|
|
60
|
-
handleCounterClick()
|
|
58
|
+
handleClear: (e: Pick<Event, "stopPropagation">) => void;
|
|
59
|
+
handleClick: (e: Pick<Event, "target" | "currentTarget">) => void;
|
|
60
|
+
handleCounterClick: () => void;
|
|
61
61
|
}
|
|
@@ -27,8 +27,8 @@ var TextAreaFoundation = class extends TextEntryFoundation {
|
|
|
27
27
|
this.#fitInline = false;
|
|
28
28
|
}
|
|
29
29
|
/** Re-fits the inline height without field-sizing; hosts call it when the value, `autosize` or the node changes */
|
|
30
|
-
fitAutosize() {
|
|
31
|
-
const textarea = this.#fitInline ? this.
|
|
30
|
+
fitAutosize = () => {
|
|
31
|
+
const textarea = this.#fitInline ? this.adapter.getTextarea() : null;
|
|
32
32
|
if (!textarea) return;
|
|
33
33
|
if (!this.getProps().autosize) {
|
|
34
34
|
if (this.#fitted) {
|
|
@@ -52,33 +52,33 @@ var TextAreaFoundation = class extends TextEntryFoundation {
|
|
|
52
52
|
this.#observed = textarea;
|
|
53
53
|
this.#lastWidth = NaN;
|
|
54
54
|
}
|
|
55
|
-
}
|
|
56
|
-
handleValueChange(value) {
|
|
57
|
-
this.
|
|
55
|
+
};
|
|
56
|
+
handleValueChange = (value) => {
|
|
57
|
+
this.adapter.setState({
|
|
58
58
|
value,
|
|
59
59
|
cachedValue: value
|
|
60
60
|
});
|
|
61
|
-
}
|
|
62
|
-
handleBlur(e) {
|
|
61
|
+
};
|
|
62
|
+
handleBlur = (e) => {
|
|
63
63
|
const { value } = this.getStates();
|
|
64
64
|
const { maxLength } = this.getProps();
|
|
65
65
|
let realValue = value;
|
|
66
66
|
if (maxLength && this.composedSinceFocus) {
|
|
67
67
|
realValue = this.handleVisibleMaxLength(value);
|
|
68
68
|
if (realValue !== value) {
|
|
69
|
-
if (!this.
|
|
70
|
-
this.
|
|
69
|
+
if (!this.isControlledComponent()) this.adapter.setValue(realValue);
|
|
70
|
+
this.adapter.notifyChange(realValue, e);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
75
|
-
}
|
|
76
|
-
handleKeyDown(e) {
|
|
73
|
+
this.adapter.toggleFocusing(false);
|
|
74
|
+
this.adapter.notifyBlur(realValue, e);
|
|
75
|
+
};
|
|
76
|
+
handleKeyDown = (e) => {
|
|
77
77
|
const { disabledEnterStartNewLine } = this.getProps();
|
|
78
78
|
if (disabledEnterStartNewLine && e.key === "Enter" && !e.shiftKey) e.preventDefault();
|
|
79
|
-
this.
|
|
80
|
-
if (e.key === "Enter" && !isComposing(e)) this.
|
|
81
|
-
}
|
|
79
|
+
this.adapter.notifyKeyDown(e);
|
|
80
|
+
if (e.key === "Enter" && !isComposing(e)) this.adapter.notifyEnterPress(e);
|
|
81
|
+
};
|
|
82
82
|
handleResize = (entries) => {
|
|
83
83
|
const entry = entries?.[0];
|
|
84
84
|
const rect = entry?.contentRect;
|
|
@@ -95,36 +95,36 @@ var TextAreaFoundation = class extends TextEntryFoundation {
|
|
|
95
95
|
}
|
|
96
96
|
if (this.getProps().autosize) {
|
|
97
97
|
if (last && last.height === height) return;
|
|
98
|
-
this.
|
|
98
|
+
this.adapter.notifyResize({ height: entry.target.getBoundingClientRect().height });
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
if (last && last.width === width && last.height === height) return;
|
|
102
|
-
this.
|
|
102
|
+
this.adapter.notifyResize({
|
|
103
103
|
height,
|
|
104
104
|
width
|
|
105
105
|
});
|
|
106
106
|
};
|
|
107
|
-
handleClear(e) {
|
|
108
|
-
if (!this.
|
|
109
|
-
this.
|
|
110
|
-
this.
|
|
107
|
+
handleClear = (e) => {
|
|
108
|
+
if (!this.isControlledComponent("value")) this.adapter.setValue("");
|
|
109
|
+
this.adapter.notifyChange("", e);
|
|
110
|
+
this.adapter.notifyClear(e);
|
|
111
111
|
e.stopPropagation();
|
|
112
|
-
}
|
|
113
|
-
handleClick(e) {
|
|
114
|
-
const { disabled, readonly } = this.
|
|
115
|
-
const { isFocus } = this.
|
|
112
|
+
};
|
|
113
|
+
handleClick = (e) => {
|
|
114
|
+
const { disabled, readonly } = this.adapter.getProps();
|
|
115
|
+
const { isFocus } = this.adapter.getStates();
|
|
116
116
|
if (disabled || readonly || isFocus) return;
|
|
117
|
-
if (this.
|
|
118
|
-
this.
|
|
119
|
-
this.
|
|
117
|
+
if (this.adapter.isEventTarget(e)) {
|
|
118
|
+
this.adapter.focusInput();
|
|
119
|
+
this.adapter.toggleFocusing(true);
|
|
120
120
|
}
|
|
121
|
-
}
|
|
122
|
-
handleCounterClick() {
|
|
123
|
-
const { disabled, readonly } = this.
|
|
124
|
-
const { isFocus } = this.
|
|
121
|
+
};
|
|
122
|
+
handleCounterClick = () => {
|
|
123
|
+
const { disabled, readonly } = this.adapter.getProps();
|
|
124
|
+
const { isFocus } = this.adapter.getStates();
|
|
125
125
|
if (disabled || readonly || isFocus) return;
|
|
126
|
-
this.
|
|
127
|
-
this.
|
|
128
|
-
}
|
|
126
|
+
this.adapter.focusInput();
|
|
127
|
+
this.adapter.toggleFocusing(true);
|
|
128
|
+
};
|
|
129
129
|
};
|
|
130
130
|
export { TextAreaFoundation as default };
|
|
@@ -35,6 +35,8 @@ export interface InputNumberBaseProps {
|
|
|
35
35
|
export declare function reachesBound(number: number | null | undefined, bound: number | undefined, direction: 1 | -1): boolean;
|
|
36
36
|
/** The members of a keyboard event the foundation reads; DOM events and React synthetic events both satisfy it */
|
|
37
37
|
export type InputNumberKeyEvent = Pick<KeyboardEvent, 'key' | 'preventDefault' | 'shiftKey' | 'altKey' | 'ctrlKey' | 'metaKey'> & Parameters<typeof isComposing>[0];
|
|
38
|
+
/** The members of a step button's pointerdown the foundation reads, which it keeps for the repeats while the button is held */
|
|
39
|
+
export type InputNumberPressEvent = Pick<PointerEvent, 'button' | 'currentTarget' | 'pointerId' | 'shiftKey' | 'stopPropagation'>;
|
|
38
40
|
/** FE and KE are the host's focus and keydown events, which the foundation passes on to the callbacks */
|
|
39
41
|
export interface InputNumberAdapter<P extends InputNumberBaseProps = InputNumberBaseProps, S extends BaseInputNumberState = BaseInputNumberState, FE = unknown, KE = unknown> extends DefaultAdapter<P, S> {
|
|
40
42
|
setValue: (value: string, cb?: () => void) => void;
|
|
@@ -62,8 +64,8 @@ export default class InputNumberFoundation<P extends InputNumberBaseProps = Inpu
|
|
|
62
64
|
#private;
|
|
63
65
|
protected isControlled(): boolean;
|
|
64
66
|
protected isCurrency(): boolean;
|
|
65
|
-
protected add(step?: number, event?:
|
|
66
|
-
protected minus(step?: number, event?:
|
|
67
|
+
protected add(step?: number, event?: Pick<KeyboardEvent, 'shiftKey'>): string;
|
|
68
|
+
protected minus(step?: number, event?: Pick<KeyboardEvent, 'shiftKey'>): string;
|
|
67
69
|
protected formatCurrency(value: number | string): string;
|
|
68
70
|
/** `forDisplay` formats for the unfocused input: currency format and scientific notation apply only then */
|
|
69
71
|
protected doFormat(value?: string | number, needAdjustPrec?: boolean, forDisplay?: boolean): string;
|
|
@@ -81,23 +83,23 @@ export default class InputNumberFoundation<P extends InputNumberBaseProps = Inpu
|
|
|
81
83
|
/** The first render's state, so the formatted value shows without a second render (#2548); there is no init() */
|
|
82
84
|
static getInitialState(props: Record<string, any>): BaseInputNumberState;
|
|
83
85
|
destroy(): void;
|
|
84
|
-
handleInputFocus(e: FE)
|
|
85
|
-
handleInputChange(value: string, event: unknown)
|
|
86
|
-
handleInputKeyDown(event: KE)
|
|
87
|
-
handleInputBlur(e: FE)
|
|
88
|
-
handleInputMouseEnter()
|
|
89
|
-
handleInputMouseLeave()
|
|
90
|
-
handleInputMouseMove()
|
|
86
|
+
handleInputFocus: (e: FE) => void;
|
|
87
|
+
handleInputChange: (value: string, event: unknown) => void;
|
|
88
|
+
handleInputKeyDown: (event: KE) => void;
|
|
89
|
+
handleInputBlur: (e: FE) => void;
|
|
90
|
+
handleInputMouseEnter: () => void;
|
|
91
|
+
handleInputMouseLeave: () => void;
|
|
92
|
+
handleInputMouseMove: () => void;
|
|
91
93
|
/** Ends the repeat of a held button; follows pointerup and pointercancel */
|
|
92
|
-
handlePressEnd()
|
|
94
|
+
handlePressEnd: () => void;
|
|
93
95
|
/**
|
|
94
96
|
* Under keepFocus or innerButtons a press on a step button never blurs the input, even when it steps nothing. This
|
|
95
97
|
* belongs on mousedown: cancelling pointerdown would also suppress the mousedown that outside-click listeners of
|
|
96
98
|
* other open popups wait for.
|
|
97
99
|
*/
|
|
98
|
-
handleStepMouseDown(event: Pick<Event,
|
|
99
|
-
handleUpPress(event:
|
|
100
|
-
handleDownPress(event:
|
|
100
|
+
handleStepMouseDown: (event: Pick<Event, "preventDefault">) => void;
|
|
101
|
+
handleUpPress: (event: InputNumberPressEvent) => void;
|
|
102
|
+
handleDownPress: (event: InputNumberPressEvent) => void;
|
|
101
103
|
/**
|
|
102
104
|
* A changed controlled `value`, after the commit that received it. It never notifies: the parent already holds
|
|
103
105
|
* this value, and an out-of-range one is shown as given until the user interacts.
|
|
@@ -106,5 +108,5 @@ export default class InputNumberFoundation<P extends InputNumberBaseProps = Inpu
|
|
|
106
108
|
* be on blur (and the text right after a step), an unparsable value replaces the text. Otherwise the value is
|
|
107
109
|
* formatted like on blur, except that it is not clamped, and an unparsable one empties it.
|
|
108
110
|
*/
|
|
109
|
-
handleValueChange(value: number | string)
|
|
111
|
+
handleValueChange: (value: number | string) => void;
|
|
110
112
|
}
|