@douyinfe/semi-foundation 2.19.0-beta.0 → 2.19.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/anchor/anchor.scss +1 -8
- package/anchor/rtl.scss +0 -1
- package/anchor/variables.scss +1 -0
- package/calendar/eventUtil.ts +8 -7
- package/calendar/foundation.ts +14 -14
- package/datePicker/monthsGridFoundation.ts +10 -3
- package/dropdown/foundation.ts +2 -1
- package/dropdown/menuFoundation.ts +2 -1
- package/getBabelConfig.js +0 -12
- package/lib/cjs/anchor/anchor.css +1 -10
- package/lib/cjs/anchor/anchor.scss +1 -8
- package/lib/cjs/anchor/constants.js +1 -4
- package/lib/cjs/anchor/foundation.js +5 -12
- package/lib/cjs/anchor/linkFoundation.js +4 -9
- package/lib/cjs/anchor/rtl.scss +0 -1
- package/lib/cjs/anchor/variables.scss +1 -0
- package/lib/cjs/autoComplete/constants.js +1 -4
- package/lib/cjs/autoComplete/foundation.js +14 -33
- package/lib/cjs/autoComplete/optionFoundation.js +4 -9
- package/lib/cjs/avatar/constants.js +1 -4
- package/lib/cjs/avatar/foundation.js +4 -9
- package/lib/cjs/backtop/constants.js +1 -4
- package/lib/cjs/backtop/foundation.js +4 -9
- package/lib/cjs/badge/constants.js +1 -4
- package/lib/cjs/banner/constants.js +1 -4
- package/lib/cjs/banner/foundation.js +4 -9
- package/lib/cjs/base/constants.js +2 -6
- package/lib/cjs/base/env.js +1 -4
- package/lib/cjs/base/foundation.js +5 -10
- package/lib/cjs/base/index.js +3 -6
- package/lib/cjs/breadcrumb/constants.js +1 -4
- package/lib/cjs/breadcrumb/foundation.js +6 -13
- package/lib/cjs/breadcrumb/itemFoundation.js +4 -9
- package/lib/cjs/button/constants.js +1 -4
- package/lib/cjs/calendar/constants.js +1 -4
- package/lib/cjs/calendar/eventUtil.d.ts +3 -3
- package/lib/cjs/calendar/eventUtil.js +28 -53
- package/lib/cjs/calendar/foundation.js +63 -85
- package/lib/cjs/card/constants.js +1 -4
- package/lib/cjs/carousel/constants.js +1 -4
- package/lib/cjs/carousel/foundation.js +5 -12
- package/lib/cjs/cascader/constants.js +1 -4
- package/lib/cjs/cascader/foundation.js +55 -100
- package/lib/cjs/cascader/util.js +9 -30
- package/lib/cjs/checkbox/checkboxFoundation.js +6 -13
- package/lib/cjs/checkbox/checkboxGroupFoundation.js +9 -18
- package/lib/cjs/checkbox/constants.js +1 -4
- package/lib/cjs/collapse/constants.js +1 -4
- package/lib/cjs/collapse/foundation.js +9 -20
- package/lib/cjs/collapsible/constants.js +1 -4
- package/lib/cjs/datePicker/_utils/formatter.js +3 -12
- package/lib/cjs/datePicker/_utils/getDayOfWeek.js +1 -4
- package/lib/cjs/datePicker/_utils/getDefaultFormatToken.js +1 -4
- package/lib/cjs/datePicker/_utils/getDefaultPickerDate.js +5 -10
- package/lib/cjs/datePicker/_utils/getFullDateOffset.js +3 -6
- package/lib/cjs/datePicker/_utils/getInsetInputFormatToken.js +2 -11
- package/lib/cjs/datePicker/_utils/getInsetInputValueFromInsetInputStr.js +1 -4
- package/lib/cjs/datePicker/_utils/getMonthTable.js +2 -11
- package/lib/cjs/datePicker/_utils/getMonthsInYear.js +3 -16
- package/lib/cjs/datePicker/_utils/getYears.js +2 -9
- package/lib/cjs/datePicker/_utils/index.js +16 -30
- package/lib/cjs/datePicker/_utils/isAfter.js +3 -6
- package/lib/cjs/datePicker/_utils/isBefore.js +3 -6
- package/lib/cjs/datePicker/_utils/isBetween.js +3 -6
- package/lib/cjs/datePicker/_utils/isDate.js +1 -4
- package/lib/cjs/datePicker/_utils/isSameDay.js +3 -6
- package/lib/cjs/datePicker/_utils/isTimestamp.js +3 -6
- package/lib/cjs/datePicker/_utils/isUnixTimestamp.js +3 -6
- package/lib/cjs/datePicker/_utils/isValidDate.js +1 -4
- package/lib/cjs/datePicker/_utils/isWithinInterval.js +3 -6
- package/lib/cjs/datePicker/_utils/parser.js +1 -4
- package/lib/cjs/datePicker/constants.js +3 -10
- package/lib/cjs/datePicker/foundation.js +42 -85
- package/lib/cjs/datePicker/inputFoundation.js +7 -20
- package/lib/cjs/datePicker/monthFoundation.js +5 -12
- package/lib/cjs/datePicker/monthsGridFoundation.js +47 -68
- package/lib/cjs/datePicker/yearAndMonthFoundation.js +4 -9
- package/lib/cjs/descriptions/constants.js +1 -4
- package/lib/cjs/divider/constants.js +1 -4
- package/lib/cjs/dropdown/constants.js +1 -4
- package/lib/cjs/dropdown/foundation.js +7 -15
- package/lib/cjs/dropdown/menuFoundation.js +11 -31
- package/lib/cjs/empty/constants.js +1 -4
- package/lib/cjs/form/constants.js +1 -4
- package/lib/cjs/form/foundation.js +64 -104
- package/lib/cjs/form/interface.js +1 -3
- package/lib/cjs/form/utils.js +14 -29
- package/lib/cjs/grid/constants.js +1 -4
- package/lib/cjs/icons/constants.js +1 -4
- package/lib/cjs/input/constants.js +1 -4
- package/lib/cjs/input/foundation.js +7 -18
- package/lib/cjs/input/textareaFoundation.js +6 -13
- package/lib/cjs/input/util/calculateNodeHeight.js +3 -17
- package/lib/cjs/input/util/getSizingData.js +5 -10
- package/lib/cjs/inputNumber/constants.js +4 -11
- package/lib/cjs/inputNumber/foundation.js +11 -30
- package/lib/cjs/layout/constants.js +1 -4
- package/lib/cjs/list/constants.js +1 -4
- package/lib/cjs/modal/constants.js +1 -4
- package/lib/cjs/modal/modalContentFoundation.js +4 -9
- package/lib/cjs/modal/modalFoundation.js +4 -9
- package/lib/cjs/navigation/NavItem.js +6 -21
- package/lib/cjs/navigation/constants.js +1 -4
- package/lib/cjs/navigation/foundation.js +22 -37
- package/lib/cjs/navigation/itemFoundation.js +4 -9
- package/lib/cjs/navigation/subNavFoundation.js +10 -21
- package/lib/cjs/notification/constants.js +1 -4
- package/lib/cjs/notification/notificationFoundation.js +5 -12
- package/lib/cjs/notification/notificationListFoundation.js +4 -9
- package/lib/cjs/overflowList/constants.js +3 -10
- package/lib/cjs/overflowList/foundation.js +12 -29
- package/lib/cjs/pagination/constants.js +1 -4
- package/lib/cjs/pagination/foundation.js +18 -37
- package/lib/cjs/popconfirm/constants.js +1 -4
- package/lib/cjs/popconfirm/popconfirmFoundation.js +3 -6
- package/lib/cjs/popover/constants.js +2 -9
- package/lib/cjs/progress/constants.js +1 -4
- package/lib/cjs/radio/constants.js +1 -4
- package/lib/cjs/radio/radioFoundation.js +3 -6
- package/lib/cjs/radio/radioGroupFoundation.js +6 -11
- package/lib/cjs/radio/radioInnerFoundation.js +5 -10
- package/lib/cjs/rating/constants.js +1 -4
- package/lib/cjs/rating/foundation.js +7 -20
- package/lib/cjs/scrollList/constants.js +1 -4
- package/lib/cjs/scrollList/foundation.js +3 -6
- package/lib/cjs/scrollList/itemFoundation.js +8 -21
- package/lib/cjs/scrollList/scrollTo.js +1 -4
- package/lib/cjs/select/constants.js +1 -4
- package/lib/cjs/select/foundation.js +56 -98
- package/lib/cjs/select/optionFoundation.js +4 -9
- package/lib/cjs/sideSheet/constants.js +1 -4
- package/lib/cjs/sideSheet/sideSheetFoundation.js +6 -15
- package/lib/cjs/skeleton/constants.js +1 -4
- package/lib/cjs/slider/constants.js +1 -4
- package/lib/cjs/slider/foundation.js +13 -24
- package/lib/cjs/space/constants.js +1 -4
- package/lib/cjs/spin/constants.js +1 -4
- package/lib/cjs/spin/foundation.js +5 -12
- package/lib/cjs/steps/constants.js +1 -4
- package/lib/cjs/switch/constants.js +1 -4
- package/lib/cjs/switch/foundation.js +4 -9
- package/lib/cjs/table/bodyFoundation.js +9 -22
- package/lib/cjs/table/cellFoundation.js +3 -6
- package/lib/cjs/table/constants.js +1 -4
- package/lib/cjs/table/foundation.js +76 -117
- package/lib/cjs/table/tableRowFoundation.js +3 -6
- package/lib/cjs/table/tableSelectionCellFoundation.js +3 -6
- package/lib/cjs/table/utils.js +42 -71
- package/lib/cjs/tabs/constants.js +1 -4
- package/lib/cjs/tabs/foundation.js +8 -23
- package/lib/cjs/tag/constants.js +1 -4
- package/lib/cjs/tagInput/constants.js +1 -4
- package/lib/cjs/tagInput/foundation.js +12 -31
- package/lib/cjs/tagInput/utils/getSplitedArray.js +3 -6
- package/lib/cjs/timePicker/ComboxFoundation.js +10 -29
- package/lib/cjs/timePicker/constants.js +1 -4
- package/lib/cjs/timePicker/foundation.js +26 -45
- package/lib/cjs/timePicker/inputFoundation.js +4 -9
- package/lib/cjs/timePicker/utils/index.js +7 -14
- package/lib/cjs/timePicker/utils/localeDate.js +2 -9
- package/lib/cjs/timeline/constants.js +1 -4
- package/lib/cjs/toast/constants.js +1 -4
- package/lib/cjs/toast/toastFoundation.js +5 -12
- package/lib/cjs/toast/toastListFoundation.js +5 -12
- package/lib/cjs/tooltip/constants.js +1 -4
- package/lib/cjs/tooltip/foundation.js +29 -56
- package/lib/cjs/transfer/constants.js +1 -4
- package/lib/cjs/transfer/foundation.js +24 -47
- package/lib/cjs/transfer/transferUtils.js +16 -45
- package/lib/cjs/tree/constants.js +1 -4
- package/lib/cjs/tree/foundation.js +41 -76
- package/lib/cjs/tree/treeUtil.js +60 -107
- package/lib/cjs/treeSelect/constants.js +1 -4
- package/lib/cjs/treeSelect/foundation.js +49 -82
- package/lib/cjs/typography/constants.js +1 -4
- package/lib/cjs/upload/constants.js +1 -4
- package/lib/cjs/upload/foundation.js +56 -112
- package/lib/cjs/upload/utils.js +13 -32
- package/lib/cjs/utils/Event.js +9 -23
- package/lib/cjs/utils/FocusHandle.js +6 -15
- package/lib/cjs/utils/Logger.js +1 -4
- package/lib/cjs/utils/Store.js +5 -20
- package/lib/cjs/utils/a11y.js +8 -13
- package/lib/cjs/utils/array.js +6 -15
- package/lib/cjs/utils/arrayMove.js +3 -12
- package/lib/cjs/utils/classnames.js +6 -15
- package/lib/cjs/utils/date-fns-extra.js +7 -18
- package/lib/cjs/utils/dom.js +5 -12
- package/lib/cjs/utils/function.js +1 -4
- package/lib/cjs/utils/getDataAttr.js +2 -13
- package/lib/cjs/utils/getHighlight.js +7 -22
- package/lib/cjs/utils/getMotionObjFromProps.js +4 -9
- package/lib/cjs/utils/index.js +5 -15
- package/lib/cjs/utils/isBothNaN.js +1 -4
- package/lib/cjs/utils/isElement.js +1 -4
- package/lib/cjs/utils/isEnterPress.js +3 -6
- package/lib/cjs/utils/isEscPress.js +3 -6
- package/lib/cjs/utils/isNullOrUndefined.js +1 -4
- package/lib/cjs/utils/isNumber.js +1 -4
- package/lib/cjs/utils/isObject.js +1 -4
- package/lib/cjs/utils/isPromise.js +3 -6
- package/lib/cjs/utils/isString.js +1 -4
- package/lib/cjs/utils/keyCode.js +1 -4
- package/lib/cjs/utils/log.js +3 -6
- package/lib/cjs/utils/number.js +1 -4
- package/lib/cjs/utils/object.js +10 -27
- package/lib/cjs/utils/set.js +4 -9
- package/lib/cjs/utils/shallowEqualObjects.js +3 -10
- package/lib/cjs/utils/touchPolyfill.js +5 -12
- package/lib/cjs/utils/type.js +1 -3
- package/lib/cjs/utils/uuid.js +3 -14
- package/lib/cjs/utils/warning.js +1 -4
- package/lib/es/anchor/anchor.css +1 -10
- package/lib/es/anchor/anchor.scss +1 -8
- package/lib/es/anchor/foundation.js +2 -4
- package/lib/es/anchor/linkFoundation.js +1 -2
- package/lib/es/anchor/rtl.scss +0 -1
- package/lib/es/anchor/variables.scss +1 -0
- package/lib/es/autoComplete/foundation.js +11 -26
- package/lib/es/autoComplete/optionFoundation.js +1 -2
- package/lib/es/avatar/foundation.js +1 -2
- package/lib/es/backtop/foundation.js +1 -2
- package/lib/es/banner/foundation.js +1 -2
- package/lib/es/base/foundation.js +2 -3
- package/lib/es/breadcrumb/foundation.js +3 -6
- package/lib/es/breadcrumb/itemFoundation.js +1 -2
- package/lib/es/calendar/eventUtil.d.ts +3 -3
- package/lib/es/calendar/eventUtil.js +27 -56
- package/lib/es/calendar/foundation.js +60 -90
- package/lib/es/carousel/foundation.js +2 -4
- package/lib/es/cascader/foundation.js +49 -94
- package/lib/es/cascader/util.js +6 -21
- package/lib/es/checkbox/checkboxFoundation.js +3 -6
- package/lib/es/checkbox/checkboxGroupFoundation.js +6 -9
- package/lib/es/collapse/foundation.js +6 -10
- package/lib/es/datePicker/_utils/formatter.js +2 -5
- package/lib/es/datePicker/_utils/getDefaultPickerDate.js +2 -3
- package/lib/es/datePicker/_utils/getInsetInputFormatToken.js +1 -4
- package/lib/es/datePicker/_utils/getMonthTable.js +1 -5
- package/lib/es/datePicker/_utils/getMonthsInYear.js +2 -9
- package/lib/es/datePicker/_utils/getYears.js +1 -3
- package/lib/es/datePicker/constants.js +2 -7
- package/lib/es/datePicker/foundation.js +39 -70
- package/lib/es/datePicker/inputFoundation.js +4 -11
- package/lib/es/datePicker/monthFoundation.js +2 -4
- package/lib/es/datePicker/monthsGridFoundation.js +40 -55
- package/lib/es/datePicker/yearAndMonthFoundation.js +1 -2
- package/lib/es/dropdown/foundation.js +4 -7
- package/lib/es/dropdown/menuFoundation.js +8 -21
- package/lib/es/form/foundation.js +59 -91
- package/lib/es/form/utils.js +11 -19
- package/lib/es/input/foundation.js +4 -9
- package/lib/es/input/textareaFoundation.js +3 -5
- package/lib/es/input/util/calculateNodeHeight.js +2 -10
- package/lib/es/input/util/getSizingData.js +2 -5
- package/lib/es/inputNumber/constants.js +3 -8
- package/lib/es/inputNumber/foundation.js +8 -18
- package/lib/es/modal/modalContentFoundation.js +1 -2
- package/lib/es/modal/modalFoundation.js +1 -2
- package/lib/es/navigation/NavItem.js +5 -11
- package/lib/es/navigation/foundation.js +19 -25
- package/lib/es/navigation/itemFoundation.js +1 -3
- package/lib/es/navigation/subNavFoundation.js +7 -13
- package/lib/es/notification/notificationFoundation.js +2 -4
- package/lib/es/notification/notificationListFoundation.js +1 -3
- package/lib/es/overflowList/constants.js +2 -3
- package/lib/es/overflowList/foundation.js +9 -23
- package/lib/es/pagination/foundation.js +15 -28
- package/lib/es/popover/constants.js +1 -2
- package/lib/es/radio/radioGroupFoundation.js +3 -4
- package/lib/es/radio/radioInnerFoundation.js +2 -3
- package/lib/es/rating/foundation.js +4 -13
- package/lib/es/scrollList/itemFoundation.js +5 -13
- package/lib/es/select/foundation.js +50 -88
- package/lib/es/select/optionFoundation.js +1 -2
- package/lib/es/sideSheet/sideSheetFoundation.js +3 -7
- package/lib/es/slider/foundation.js +10 -16
- package/lib/es/spin/foundation.js +2 -4
- package/lib/es/switch/foundation.js +1 -2
- package/lib/es/table/bodyFoundation.js +6 -11
- package/lib/es/table/foundation.js +67 -93
- package/lib/es/table/utils.js +33 -51
- package/lib/es/tabs/foundation.js +5 -18
- package/lib/es/tagInput/foundation.js +9 -21
- package/lib/es/timePicker/ComboxFoundation.js +7 -16
- package/lib/es/timePicker/foundation.js +23 -37
- package/lib/es/timePicker/inputFoundation.js +1 -2
- package/lib/es/timePicker/utils/index.js +4 -6
- package/lib/es/timePicker/utils/localeDate.js +1 -2
- package/lib/es/toast/toastFoundation.js +2 -4
- package/lib/es/toast/toastListFoundation.js +2 -4
- package/lib/es/tooltip/foundation.js +26 -46
- package/lib/es/transfer/foundation.js +21 -43
- package/lib/es/transfer/transferUtils.js +13 -33
- package/lib/es/tree/foundation.js +38 -70
- package/lib/es/tree/treeUtil.js +57 -109
- package/lib/es/treeSelect/foundation.js +45 -73
- package/lib/es/upload/foundation.js +52 -118
- package/lib/es/upload/utils.js +12 -25
- package/lib/es/utils/Event.js +5 -12
- package/lib/es/utils/FocusHandle.js +3 -7
- package/lib/es/utils/Store.js +4 -12
- package/lib/es/utils/a11y.js +5 -6
- package/lib/es/utils/array.js +3 -5
- package/lib/es/utils/arrayMove.js +2 -6
- package/lib/es/utils/classnames.js +3 -6
- package/lib/es/utils/date-fns-extra.js +6 -14
- package/lib/es/utils/dom.js +1 -2
- package/lib/es/utils/getDataAttr.js +1 -5
- package/lib/es/utils/getHighlight.js +4 -14
- package/lib/es/utils/getMotionObjFromProps.js +1 -2
- package/lib/es/utils/object.js +7 -15
- package/lib/es/utils/set.js +1 -2
- package/lib/es/utils/shallowEqualObjects.js +2 -5
- package/lib/es/utils/touchPolyfill.js +2 -6
- package/lib/es/utils/uuid.js +2 -7
- package/package.json +2 -4
- package/select/foundation.ts +2 -2
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
2
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
3
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
4
|
-
|
|
5
1
|
/* eslint-disable no-param-reassign */
|
|
6
2
|
import BaseFoundation from '../base/foundation';
|
|
7
3
|
import warning from '../utils/warning';
|
|
8
4
|
export default class RatingFoundation extends BaseFoundation {
|
|
9
5
|
constructor(adapter) {
|
|
10
|
-
super(
|
|
6
|
+
super(Object.assign(Object.assign({}, RatingFoundation.defaultAdapter), adapter));
|
|
11
7
|
|
|
12
8
|
this.handleStarFocusVisible = event => {
|
|
13
9
|
const {
|
|
@@ -164,8 +160,6 @@ export default class RatingFoundation extends BaseFoundation {
|
|
|
164
160
|
}
|
|
165
161
|
|
|
166
162
|
handleKeyDown(event, value) {
|
|
167
|
-
var _context;
|
|
168
|
-
|
|
169
163
|
const {
|
|
170
164
|
key
|
|
171
165
|
} = event;
|
|
@@ -195,7 +189,7 @@ export default class RatingFoundation extends BaseFoundation {
|
|
|
195
189
|
newValue = tempValue;
|
|
196
190
|
}
|
|
197
191
|
|
|
198
|
-
if (
|
|
192
|
+
if (['ArrowRight', 'ArrowUp', 'ArrowLeft', 'ArrowDown'].includes(key)) {
|
|
199
193
|
this._adapter.notifyKeyDown(event);
|
|
200
194
|
|
|
201
195
|
this._adapter.updateValue(newValue);
|
|
@@ -208,16 +202,13 @@ export default class RatingFoundation extends BaseFoundation {
|
|
|
208
202
|
}
|
|
209
203
|
|
|
210
204
|
changeFocusStar(value, event) {
|
|
211
|
-
var _context2;
|
|
212
|
-
|
|
213
205
|
const {
|
|
214
206
|
count,
|
|
215
207
|
allowHalf,
|
|
216
208
|
preventScroll
|
|
217
209
|
} = this.getProps();
|
|
218
210
|
const index = Math.ceil(value) - 1;
|
|
219
|
-
|
|
220
|
-
const starElement = _mapInstanceProperty(_context2 = [...event.currentTarget.childNodes]).call(_context2, item => item.childNodes[0].childNodes);
|
|
211
|
+
const starElement = [...event.currentTarget.childNodes].map(item => item.childNodes[0].childNodes);
|
|
221
212
|
|
|
222
213
|
if (index < 0) {
|
|
223
214
|
starElement[count][0].focus({
|
|
@@ -233,7 +224,7 @@ export default class RatingFoundation extends BaseFoundation {
|
|
|
233
224
|
}
|
|
234
225
|
export class RatingItemFoundation extends BaseFoundation {
|
|
235
226
|
constructor(adapter) {
|
|
236
|
-
super(
|
|
227
|
+
super(Object.assign(Object.assign({}, RatingItemFoundation.defaultAdapter), adapter));
|
|
237
228
|
|
|
238
229
|
this.handleFocusVisible = (event, star) => {
|
|
239
230
|
const {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import _findIndex from "lodash/findIndex";
|
|
2
2
|
import _find from "lodash/find";
|
|
3
3
|
import _slice from "lodash/slice";
|
|
4
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
5
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
6
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
7
|
-
import _Array$from from "@babel/runtime-corejs3/core-js-stable/array/from";
|
|
8
4
|
import BaseFoundation from '../base/foundation';
|
|
9
5
|
import isElement from '../utils/isElement';
|
|
10
6
|
import { append, prepend } from '../utils/dom';
|
|
@@ -20,14 +16,14 @@ export default class ItemFoundation extends BaseFoundation {
|
|
|
20
16
|
list
|
|
21
17
|
} = this.getProps();
|
|
22
18
|
|
|
23
|
-
if (index > -1 &&
|
|
19
|
+
if (index > -1 && Array.isArray(list) && list.length && isElement(listWrapper)) {
|
|
24
20
|
const indexInData = index % list.length;
|
|
25
21
|
const item = list[indexInData];
|
|
26
22
|
const node = listWrapper.children[index];
|
|
27
23
|
|
|
28
24
|
this._adapter.setSelectedNode(node);
|
|
29
25
|
|
|
30
|
-
this._adapter.notifySelectItem(
|
|
26
|
+
this._adapter.notifySelectItem(Object.assign(Object.assign({}, item), {
|
|
31
27
|
value: item.value,
|
|
32
28
|
type,
|
|
33
29
|
index: indexInData
|
|
@@ -62,7 +58,7 @@ export default class ItemFoundation extends BaseFoundation {
|
|
|
62
58
|
this._cachedSelectedNode = node;
|
|
63
59
|
|
|
64
60
|
if (cachedIndexData !== indexInData) {
|
|
65
|
-
this._adapter.notifySelectItem(
|
|
61
|
+
this._adapter.notifySelectItem(Object.assign(Object.assign({}, item), {
|
|
66
62
|
value: item.value,
|
|
67
63
|
type,
|
|
68
64
|
index: indexInData
|
|
@@ -226,16 +222,13 @@ export default class ItemFoundation extends BaseFoundation {
|
|
|
226
222
|
|
|
227
223
|
getNearestNodeInfo(listWrapper, selector) {
|
|
228
224
|
if (isElement(listWrapper) && isElement(selector)) {
|
|
229
|
-
var _context;
|
|
230
|
-
|
|
231
225
|
const selectorRect = selector.getBoundingClientRect();
|
|
232
226
|
const selectorTop = selectorRect.top;
|
|
233
227
|
const itemNodes = listWrapper.querySelectorAll('li');
|
|
234
228
|
let nearestNode = null;
|
|
235
229
|
let nearestIndex = -1;
|
|
236
230
|
let nearestDistance = Infinity;
|
|
237
|
-
|
|
238
|
-
_mapInstanceProperty(_context = _Array$from(itemNodes)).call(_context, (node, index) => {
|
|
231
|
+
Array.from(itemNodes).map((node, index) => {
|
|
239
232
|
const rect = node.getBoundingClientRect();
|
|
240
233
|
const rectTop = rect.top;
|
|
241
234
|
const absDistance = Math.abs(rectTop - selectorTop);
|
|
@@ -246,7 +239,6 @@ export default class ItemFoundation extends BaseFoundation {
|
|
|
246
239
|
nearestIndex = index;
|
|
247
240
|
}
|
|
248
241
|
});
|
|
249
|
-
|
|
250
242
|
return {
|
|
251
243
|
nearestNode,
|
|
252
244
|
nearestIndex
|
|
@@ -269,7 +261,7 @@ export default class ItemFoundation extends BaseFoundation {
|
|
|
269
261
|
const currentTarget = e.target;
|
|
270
262
|
const itemNodes = listWrapper.querySelectorAll(targetTagName);
|
|
271
263
|
const list = this.getProp('list');
|
|
272
|
-
const length =
|
|
264
|
+
const length = Array.isArray(list) ? list.length : 0;
|
|
273
265
|
let targetIndex = -1;
|
|
274
266
|
let indexInList = -1;
|
|
275
267
|
let infoInList = null;
|
|
@@ -2,27 +2,14 @@ import _omit from "lodash/omit";
|
|
|
2
2
|
import _isEqual from "lodash/isEqual";
|
|
3
3
|
import _isString from "lodash/isString";
|
|
4
4
|
import _isNumber from "lodash/isNumber";
|
|
5
|
-
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
6
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
7
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
8
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
9
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
10
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
11
|
-
import _Map from "@babel/runtime-corejs3/core-js-stable/map";
|
|
12
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
13
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
14
|
-
import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find-index";
|
|
15
|
-
import _keysInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/keys";
|
|
16
|
-
import _valuesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/values";
|
|
17
|
-
import _entriesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/entries";
|
|
18
5
|
|
|
19
6
|
var __rest = this && this.__rest || function (s, e) {
|
|
20
7
|
var t = {};
|
|
21
8
|
|
|
22
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) &&
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
23
10
|
|
|
24
|
-
if (s != null && typeof
|
|
25
|
-
if (
|
|
11
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
12
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
26
13
|
}
|
|
27
14
|
return t;
|
|
28
15
|
};
|
|
@@ -39,7 +26,7 @@ import isEnterPress from '../utils/isEnterPress';
|
|
|
39
26
|
import { handlePrevent } from '../utils/a11y';
|
|
40
27
|
export default class SelectFoundation extends BaseFoundation {
|
|
41
28
|
constructor(adapter) {
|
|
42
|
-
super(
|
|
29
|
+
super(Object.assign({}, adapter)); // keyboard event listner
|
|
43
30
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
44
31
|
|
|
45
32
|
this._keydownHandler = null;
|
|
@@ -104,11 +91,9 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
104
91
|
let width;
|
|
105
92
|
|
|
106
93
|
if (dropdownMatchSelectWidth) {
|
|
107
|
-
var _context;
|
|
108
|
-
|
|
109
94
|
if (style && _isNumber(style.width)) {
|
|
110
95
|
width = style.width;
|
|
111
|
-
} else if (style && _isString(style.width) && !
|
|
96
|
+
} else if (style && _isString(style.width) && !style.width.includes('%')) {
|
|
112
97
|
width = style.width;
|
|
113
98
|
} else {
|
|
114
99
|
width = this._adapter.getTriggerWidth();
|
|
@@ -177,9 +162,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
177
162
|
switch (true) {
|
|
178
163
|
case isMultiple && Boolean(selections.size):
|
|
179
164
|
try {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
value = _mapInstanceProperty(_context2 = [...selections]).call(_context2, item => // At this point item1 is directly the object
|
|
165
|
+
value = [...selections].map(item => // At this point item1 is directly the object
|
|
183
166
|
onChangeWithObject ? item[1] : item[1].value);
|
|
184
167
|
} catch (error) {
|
|
185
168
|
value = [];
|
|
@@ -219,8 +202,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
219
202
|
|
|
220
203
|
if (allowCreate && this._isControlledComponent()) {
|
|
221
204
|
originalOptions = this.getState('options');
|
|
222
|
-
|
|
223
|
-
_forEachInstanceProperty(originalOptions).call(originalOptions, item => item._show = true);
|
|
205
|
+
originalOptions.forEach(item => item._show = true);
|
|
224
206
|
} else {
|
|
225
207
|
// originalOptions = this.getState('options');
|
|
226
208
|
// The options in state cannot be used directly here, because it is possible to update the optionList and props.value at the same time, and the options in state are still old at this time
|
|
@@ -253,25 +235,21 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
253
235
|
|
|
254
236
|
|
|
255
237
|
_updateSingle(propValue, originalOptions) {
|
|
256
|
-
const selections = new
|
|
238
|
+
const selections = new Map();
|
|
257
239
|
const {
|
|
258
240
|
onChangeWithObject
|
|
259
241
|
} = this.getProps(); // When onChangeWithObject is true, the defaultValue or Value passed by the props should be the object, which corresponds to the result returned by onChange, so the value of the object needs to be taken as a judgment comparison
|
|
260
242
|
|
|
261
243
|
const selectedValue = onChangeWithObject && typeof propValue !== 'undefined' ? propValue.value : propValue;
|
|
262
|
-
|
|
263
|
-
const selectedOptions = _filterInstanceProperty(originalOptions).call(originalOptions, option => option.value === selectedValue);
|
|
264
|
-
|
|
244
|
+
const selectedOptions = originalOptions.filter(option => option.value === selectedValue);
|
|
265
245
|
const noMatchOptionInList = !selectedOptions.length && typeof selectedValue !== 'undefined'; // If the current value, there is a matching option in the optionList
|
|
266
246
|
|
|
267
247
|
if (selectedOptions.length) {
|
|
268
248
|
const selectedOption = selectedOptions[0];
|
|
269
|
-
|
|
270
|
-
const optionExist = _Object$assign({}, selectedOption); // if (onChangeWithObject) {
|
|
249
|
+
const optionExist = Object.assign({}, selectedOption); // if (onChangeWithObject) {
|
|
271
250
|
// OptionExist = {... propValue }; // value is the object with the'value 'Key
|
|
272
251
|
// }
|
|
273
252
|
|
|
274
|
-
|
|
275
253
|
selections.set(optionExist.label, optionExist);
|
|
276
254
|
} else if (noMatchOptionInList) {
|
|
277
255
|
// If the current value does not have a corresponding item in the optionList, construct an option and update it to the selection. However, it does not need to be inserted into the list
|
|
@@ -283,7 +261,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
283
261
|
};
|
|
284
262
|
|
|
285
263
|
if (onChangeWithObject) {
|
|
286
|
-
optionNotExist =
|
|
264
|
+
optionNotExist = Object.assign(Object.assign({}, propValue), {
|
|
287
265
|
_notExist: true,
|
|
288
266
|
_scrollIndex: -1
|
|
289
267
|
});
|
|
@@ -300,36 +278,33 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
300
278
|
const nowSelections = this.getState('selections');
|
|
301
279
|
let selectedOptionList = []; // Multiple selection is to determine whether it is an array to avoid the problem of defaultValue/value incoming string error
|
|
302
280
|
|
|
303
|
-
const propValueIsArray =
|
|
304
|
-
|
|
281
|
+
const propValueIsArray = Array.isArray(propValue);
|
|
305
282
|
this.checkMultipleProps(); // If N values are currently selected, the corresponding option data is retrieved from the current selections for retrieval. Because these selected options may not exist in the new optionList
|
|
306
283
|
|
|
307
284
|
if (nowSelections.size) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
selectedOptionList = _mapInstanceProperty(_context3 = [...nowSelections]).call(_context3, item => item[1]);
|
|
285
|
+
selectedOptionList = [...nowSelections].map(item => item[1]);
|
|
311
286
|
}
|
|
312
287
|
|
|
313
|
-
const selections = new
|
|
288
|
+
const selections = new Map();
|
|
314
289
|
let selectedValues = propValue;
|
|
315
290
|
const {
|
|
316
291
|
onChangeWithObject
|
|
317
292
|
} = this.getProps(); // When onChangeWithObject is true
|
|
318
293
|
|
|
319
294
|
if (onChangeWithObject && propValueIsArray) {
|
|
320
|
-
selectedValues =
|
|
295
|
+
selectedValues = propValue.map(item => item.value);
|
|
321
296
|
}
|
|
322
297
|
|
|
323
298
|
if (propValueIsArray && selectedValues.length) {
|
|
324
|
-
|
|
299
|
+
selectedValues.forEach((selectedValue, i) => {
|
|
325
300
|
// The current value exists in the current optionList
|
|
326
|
-
const index =
|
|
301
|
+
const index = originalOptions.findIndex(option => option.value === selectedValue);
|
|
327
302
|
|
|
328
303
|
if (index !== -1) {
|
|
329
304
|
selections.set(originalOptions[index].label, originalOptions[index]);
|
|
330
305
|
} else {
|
|
331
306
|
// The current value exists in the optionList that has been selected before the change, and does not exist in the current optionList, then directly take the corresponding value from the selections, no need to construct a new option
|
|
332
|
-
const indexInSelectedList =
|
|
307
|
+
const indexInSelectedList = selectedOptionList.findIndex(option => option.value === selectedValue);
|
|
333
308
|
|
|
334
309
|
if (indexInSelectedList !== -1) {
|
|
335
310
|
const option = selectedOptionList[indexInSelectedList];
|
|
@@ -341,10 +316,10 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
341
316
|
label: selectedValue,
|
|
342
317
|
_notExist: true
|
|
343
318
|
};
|
|
344
|
-
onChangeWithObject ? optionNotExist =
|
|
319
|
+
onChangeWithObject ? optionNotExist = Object.assign(Object.assign({}, propValue[i]), {
|
|
345
320
|
_notExist: true
|
|
346
321
|
}) : null;
|
|
347
|
-
selections.set(optionNotExist.label,
|
|
322
|
+
selections.set(optionNotExist.label, Object.assign(Object.assign({}, optionNotExist), {
|
|
348
323
|
_scrollIndex: -1
|
|
349
324
|
}));
|
|
350
325
|
}
|
|
@@ -396,13 +371,11 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
396
371
|
const options = originalOptions || this.getState('options'); // When searchable, when the drop-down box expands
|
|
397
372
|
|
|
398
373
|
if (isFilterable) {
|
|
399
|
-
var _context4;
|
|
400
|
-
|
|
401
374
|
// Also clears the options filter to show all candidates
|
|
402
375
|
// Options created dynamically but not selected are also filtered out
|
|
403
376
|
const sugInput = '';
|
|
404
377
|
|
|
405
|
-
const newOptions =
|
|
378
|
+
const newOptions = this._filterOption(options, sugInput).filter(item => !item._inputCreateOnly);
|
|
406
379
|
|
|
407
380
|
this._adapter.updateOptions(newOptions);
|
|
408
381
|
|
|
@@ -489,12 +462,12 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
489
462
|
} = _a,
|
|
490
463
|
rest = __rest(_a, ["value", "label"]);
|
|
491
464
|
|
|
492
|
-
const selections = new
|
|
465
|
+
const selections = new Map().set(label, Object.assign({
|
|
493
466
|
value,
|
|
494
467
|
label
|
|
495
468
|
}, rest)); // First trigger onSelect, then trigger onChange
|
|
496
469
|
|
|
497
|
-
this._notifySelect(value,
|
|
470
|
+
this._notifySelect(value, Object.assign({
|
|
498
471
|
value,
|
|
499
472
|
label
|
|
500
473
|
}, rest)); // If it is a controlled component, directly notify
|
|
@@ -532,26 +505,26 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
532
505
|
} = this.getProps();
|
|
533
506
|
|
|
534
507
|
if (selections.has(label)) {
|
|
535
|
-
this._notifyDeselect(value,
|
|
508
|
+
this._notifyDeselect(value, Object.assign({
|
|
536
509
|
value,
|
|
537
510
|
label
|
|
538
511
|
}, rest));
|
|
539
512
|
|
|
540
513
|
selections.delete(label);
|
|
541
514
|
} else if (maxLimit && selections.size === maxLimit) {
|
|
542
|
-
this._adapter.notifyMaxLimit(
|
|
515
|
+
this._adapter.notifyMaxLimit(Object.assign({
|
|
543
516
|
value,
|
|
544
517
|
label
|
|
545
518
|
}, _omit(rest, '_scrollIndex')));
|
|
546
519
|
|
|
547
520
|
return;
|
|
548
521
|
} else {
|
|
549
|
-
this._notifySelect(value,
|
|
522
|
+
this._notifySelect(value, Object.assign({
|
|
550
523
|
value,
|
|
551
524
|
label
|
|
552
525
|
}, rest));
|
|
553
526
|
|
|
554
|
-
selections.set(label,
|
|
527
|
+
selections.set(label, Object.assign({
|
|
555
528
|
value,
|
|
556
529
|
label
|
|
557
530
|
}, rest));
|
|
@@ -598,7 +571,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
598
571
|
}
|
|
599
572
|
|
|
600
573
|
clearSelected() {
|
|
601
|
-
const selections = new
|
|
574
|
+
const selections = new Map();
|
|
602
575
|
|
|
603
576
|
if (this._isControlledComponent()) {
|
|
604
577
|
this._notifyChange(selections);
|
|
@@ -630,8 +603,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
630
603
|
const {
|
|
631
604
|
allowCreate
|
|
632
605
|
} = this.getProps();
|
|
633
|
-
|
|
634
|
-
const newOptions = _mapInstanceProperty(options).call(options, option => {
|
|
606
|
+
const newOptions = options.map(option => {
|
|
635
607
|
if (selections.has(option.label)) {
|
|
636
608
|
option._selected = true;
|
|
637
609
|
|
|
@@ -744,15 +716,11 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
744
716
|
} else if (typeof filter === 'boolean' && filter) {
|
|
745
717
|
// 2. When true, the default filter is used
|
|
746
718
|
const input = sugInput.toLowerCase();
|
|
747
|
-
return
|
|
748
|
-
var _context5;
|
|
749
|
-
|
|
719
|
+
return originalOptions.map(option => {
|
|
750
720
|
const label = option.label.toString().toLowerCase();
|
|
751
721
|
const groupLabel = option._parentGroup && option._parentGroup.label;
|
|
752
|
-
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
const matchGroup = _isString(groupLabel) && _includesInstanceProperty(_context5 = groupLabel.toLowerCase()).call(_context5, input);
|
|
722
|
+
const matchOption = label.includes(input);
|
|
723
|
+
const matchGroup = _isString(groupLabel) && groupLabel.toLowerCase().includes(input);
|
|
756
724
|
|
|
757
725
|
if (matchOption || matchGroup) {
|
|
758
726
|
option._show = true;
|
|
@@ -764,7 +732,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
764
732
|
});
|
|
765
733
|
} else if (typeof filter === 'function') {
|
|
766
734
|
// 3. When passing in a custom function, use a custom function for filtering
|
|
767
|
-
return
|
|
735
|
+
return originalOptions.map(option => {
|
|
768
736
|
filter(sugInput, option) ? option._show = true : option._show = false;
|
|
769
737
|
return option;
|
|
770
738
|
});
|
|
@@ -787,8 +755,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
787
755
|
};
|
|
788
756
|
let createOptionIndex = -1;
|
|
789
757
|
let matchOptionIndex = -1;
|
|
790
|
-
|
|
791
|
-
_forEachInstanceProperty(optionsAfterFilter).call(optionsAfterFilter, (option, index) => {
|
|
758
|
+
optionsAfterFilter.forEach((option, index) => {
|
|
792
759
|
if (!option._show && !option._inputCreateOnly) {
|
|
793
760
|
return;
|
|
794
761
|
} // The matching algorithm is not necessarily through labels?
|
|
@@ -811,11 +778,11 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
811
778
|
}
|
|
812
779
|
|
|
813
780
|
if (matchOptionIndex !== -1) {
|
|
814
|
-
optionsAfterFilter =
|
|
781
|
+
optionsAfterFilter = optionsAfterFilter.filter(item => !item._inputCreateOnly);
|
|
815
782
|
}
|
|
816
783
|
} else {
|
|
817
784
|
// Delete input unselected items
|
|
818
|
-
optionsAfterFilter =
|
|
785
|
+
optionsAfterFilter = optionsAfterFilter.filter(item => !item._inputCreateOnly);
|
|
819
786
|
}
|
|
820
787
|
} // TODO Promise supports asynchronous creation
|
|
821
788
|
|
|
@@ -924,9 +891,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
924
891
|
focusIndex,
|
|
925
892
|
options
|
|
926
893
|
} = this.getStates();
|
|
927
|
-
|
|
928
|
-
const visibleOptions = _filterInstanceProperty(options).call(options, item => item._show); // let visibleOptions = options;
|
|
929
|
-
|
|
894
|
+
const visibleOptions = options.filter(item => item._show); // let visibleOptions = options;
|
|
930
895
|
|
|
931
896
|
const optionsLength = visibleOptions.length;
|
|
932
897
|
let index = focusIndex + offset;
|
|
@@ -1072,8 +1037,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1072
1037
|
this.open();
|
|
1073
1038
|
} else {
|
|
1074
1039
|
if (focusIndex !== -1) {
|
|
1075
|
-
const visibleOptions =
|
|
1076
|
-
|
|
1040
|
+
const visibleOptions = options.filter(item => item._show);
|
|
1077
1041
|
const {
|
|
1078
1042
|
length
|
|
1079
1043
|
} = visibleOptions; // fix issue 1201
|
|
@@ -1107,7 +1071,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1107
1071
|
const length = selections.size;
|
|
1108
1072
|
|
|
1109
1073
|
if (length && !inputValue) {
|
|
1110
|
-
const keys = [...
|
|
1074
|
+
const keys = [...selections.keys()];
|
|
1111
1075
|
let index = length - 1;
|
|
1112
1076
|
let targetLabel = keys[index];
|
|
1113
1077
|
let targetItem = selections.get(targetLabel);
|
|
@@ -1140,7 +1104,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1140
1104
|
} = this.getProps();
|
|
1141
1105
|
const stateSelections = this.getState('selections');
|
|
1142
1106
|
let notifyVal;
|
|
1143
|
-
const selectionsProps = [...
|
|
1107
|
+
const selectionsProps = [...selections.values()];
|
|
1144
1108
|
|
|
1145
1109
|
const isMultiple = this._isMultiple();
|
|
1146
1110
|
|
|
@@ -1164,7 +1128,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1164
1128
|
break;
|
|
1165
1129
|
|
|
1166
1130
|
case !onChangeWithObject && isMultiple:
|
|
1167
|
-
notifyVal = selectionsProps.length ?
|
|
1131
|
+
notifyVal = selectionsProps.length ? selectionsProps.map(props => props.value) : [];
|
|
1168
1132
|
|
|
1169
1133
|
this._adapter.notifyChange(notifyVal);
|
|
1170
1134
|
|
|
@@ -1177,8 +1141,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1177
1141
|
|
|
1178
1142
|
_removeInternalKey(option) {
|
|
1179
1143
|
// eslint-disable-next-line
|
|
1180
|
-
let newOption =
|
|
1181
|
-
|
|
1144
|
+
let newOption = Object.assign({}, option);
|
|
1182
1145
|
delete newOption._parentGroup;
|
|
1183
1146
|
delete newOption._show;
|
|
1184
1147
|
delete newOption._selected;
|
|
@@ -1208,8 +1171,8 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1208
1171
|
let diff = true;
|
|
1209
1172
|
|
|
1210
1173
|
if (!isMultiple) {
|
|
1211
|
-
const selectionProps = [...
|
|
1212
|
-
const oldSelectionProps = [...
|
|
1174
|
+
const selectionProps = [...selections.values()];
|
|
1175
|
+
const oldSelectionProps = [...oldSelections.values()];
|
|
1213
1176
|
const optionLabel = selectionProps[0] ? selectionProps[0].label : selectionProps[0];
|
|
1214
1177
|
const oldOptionLabel = oldSelectionProps[0] ? oldSelectionProps[0].label : oldSelectionProps[0];
|
|
1215
1178
|
diff = !_isEqual(optionLabel, oldOptionLabel);
|
|
@@ -1224,11 +1187,10 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1224
1187
|
const stateSelections = this.getState('selections');
|
|
1225
1188
|
const values = [];
|
|
1226
1189
|
|
|
1227
|
-
for (const item of
|
|
1228
|
-
let val =
|
|
1190
|
+
for (const item of selections.entries()) {
|
|
1191
|
+
let val = Object.assign({
|
|
1229
1192
|
label: item[0]
|
|
1230
1193
|
}, item[1]);
|
|
1231
|
-
|
|
1232
1194
|
val = this._removeInternalKey(val);
|
|
1233
1195
|
values.push(val);
|
|
1234
1196
|
}
|
|
@@ -1322,9 +1284,9 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1322
1284
|
isOpen,
|
|
1323
1285
|
isFocus
|
|
1324
1286
|
} = this.getStates(); // Under normal circumstances, blur will be accompanied by clickOutsideHandler, so the notify of blur can be called uniformly in clickOutsideHandler
|
|
1325
|
-
// But when autoFocus, because clickOutsideHandler is not register, you need to listen for the trigger's blur and trigger the notify callback
|
|
1287
|
+
// But when autoFocus or the panel is close, because clickOutsideHandler is not register or unregister, you need to listen for the trigger's blur and trigger the notify callback
|
|
1326
1288
|
|
|
1327
|
-
if (
|
|
1289
|
+
if (isFocus && !isOpen) {
|
|
1328
1290
|
this._notifyBlur(e);
|
|
1329
1291
|
}
|
|
1330
1292
|
}
|
|
@@ -1362,7 +1324,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1362
1324
|
if (onChangeWithObject) {
|
|
1363
1325
|
selectedValues = options;
|
|
1364
1326
|
} else {
|
|
1365
|
-
selectedValues =
|
|
1327
|
+
selectedValues = options.map(option => option.value);
|
|
1366
1328
|
}
|
|
1367
1329
|
|
|
1368
1330
|
this.handleValueChange(selectedValues);
|
|
@@ -1385,7 +1347,7 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1385
1347
|
} = currentProps;
|
|
1386
1348
|
const selectedValues = value || defaultValue;
|
|
1387
1349
|
|
|
1388
|
-
if (!isNullOrUndefined(selectedValues) && !
|
|
1350
|
+
if (!isNullOrUndefined(selectedValues) && !Array.isArray(selectedValues)) {
|
|
1389
1351
|
/* istanbul ignore next */
|
|
1390
1352
|
warning(true, '[Semi Select] defaultValue/value should be array type in multiple mode');
|
|
1391
1353
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
2
1
|
import BaseFoundation from '../base/foundation';
|
|
3
2
|
export default class OptionFoundation extends BaseFoundation {
|
|
4
3
|
constructor(adapter) {
|
|
5
|
-
super(
|
|
4
|
+
super(Object.assign({}, adapter));
|
|
6
5
|
} // eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
7
6
|
|
|
8
7
|
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import _noop from "lodash/noop";
|
|
2
2
|
import _get from "lodash/get";
|
|
3
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
4
|
-
import _bindInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/bind";
|
|
5
3
|
import BaseFoundation from '../base/foundation';
|
|
6
4
|
import KeyCode from '../utils/keyCode';
|
|
7
5
|
export default class SideSheetFoundation extends BaseFoundation {
|
|
8
6
|
constructor(adapter) {
|
|
9
7
|
var _this;
|
|
10
8
|
|
|
11
|
-
super(
|
|
9
|
+
super(Object.assign(Object.assign({}, SideSheetFoundation.defaultAdapter), adapter));
|
|
12
10
|
_this = this;
|
|
13
11
|
|
|
14
12
|
this.mergeMotionProp = (motion, prop, cb) => {
|
|
15
|
-
const mergedMotion = typeof motion === 'undefined' || motion ?
|
|
13
|
+
const mergedMotion = typeof motion === 'undefined' || motion ? Object.assign(Object.assign({}, motion), {
|
|
16
14
|
[prop]: function () {
|
|
17
15
|
const curr = _get(motion, prop);
|
|
18
16
|
|
|
@@ -52,9 +50,7 @@ export default class SideSheetFoundation extends BaseFoundation {
|
|
|
52
50
|
});
|
|
53
51
|
|
|
54
52
|
if (keepDOM) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
mergedMotion = this.mergeMotionProp(mergedMotion, 'didLeave', _bindInstanceProperty(_context = this._adapter.toggleHidden).call(_context, this, true));
|
|
53
|
+
mergedMotion = this.mergeMotionProp(mergedMotion, 'didLeave', this._adapter.toggleHidden.bind(this, true));
|
|
58
54
|
}
|
|
59
55
|
|
|
60
56
|
return mergedMotion;
|