@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
|
@@ -29,7 +29,9 @@ const DERIVE_PROP_KEYS = [
|
|
|
29
29
|
"value"
|
|
30
30
|
];
|
|
31
31
|
var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
32
|
+
static #missingEntities = /* @__PURE__ */ new WeakSet();
|
|
32
33
|
#initialized = false;
|
|
34
|
+
#blurPending = false;
|
|
33
35
|
#typeahead = new Typeahead();
|
|
34
36
|
static #getFilteredData({ treeNodeFilterProp, filterSorter, keyMaps }, { filteredKeys, keyEntities, inputValue }) {
|
|
35
37
|
const realFilterProp = treeNodeFilterProp !== "label" ? treeNodeFilterProp : keyMaps?.label ?? "label";
|
|
@@ -48,8 +50,7 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
48
50
|
searchText: itemSearchPath
|
|
49
51
|
});
|
|
50
52
|
});
|
|
51
|
-
|
|
52
|
-
return filteredList;
|
|
53
|
+
return typeof filterSorter === "function" ? filteredList.toSorted((a, b) => filterSorter(a.pathData, b.pathData, inputValue)) : filteredList;
|
|
53
54
|
}
|
|
54
55
|
/** Each path of a multiple-mode value, with the key it points at (undefined for an empty path) */
|
|
55
56
|
static #valuePaths(value, { onChangeWithObject, keyMaps }) {
|
|
@@ -72,7 +73,6 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
72
73
|
if (props.value === void 0) return [];
|
|
73
74
|
return CascaderFoundation.#valuePaths(props.value, props).filter(({ key }) => key !== void 0 && !keyEntities[key]).map(({ path }) => path);
|
|
74
75
|
}
|
|
75
|
-
/** The states that select `value` from `state`, and the entities with a placeholder for a value treeData lacks */
|
|
76
76
|
static #selectionFor(props, state, value, keyEntities) {
|
|
77
77
|
const { changeOnSelect, onChangeWithObject, keyMaps, loadData, multiple } = props;
|
|
78
78
|
const { activeKeys, loadingKeys, keyEntities: keyEntityState, selectedKeys: selectedKeysState } = state;
|
|
@@ -101,9 +101,9 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
101
101
|
value: val
|
|
102
102
|
},
|
|
103
103
|
key,
|
|
104
|
-
path: valuePath
|
|
105
|
-
_notExist: true
|
|
104
|
+
path: valuePath
|
|
106
105
|
};
|
|
106
|
+
CascaderFoundation.#missingEntities.add(optionNotExist);
|
|
107
107
|
updateStates.selectedKeys = /* @__PURE__ */ new Set([key]);
|
|
108
108
|
keyEntities = {
|
|
109
109
|
...keyEntities,
|
|
@@ -145,36 +145,43 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
145
145
|
}
|
|
146
146
|
#notifySingleChange(item) {
|
|
147
147
|
const valueProp = this.getProp("onChangeWithObject") ? [] : "value";
|
|
148
|
-
this.
|
|
148
|
+
this.adapter.notifyChange(this.getItemPropPath(item.key, valueProp));
|
|
149
149
|
}
|
|
150
150
|
#notifyMultipleChange(checkedKeys) {
|
|
151
151
|
const valueProp = this.getProp("onChangeWithObject") ? [] : "value";
|
|
152
152
|
const keyEntities = this.getState("keyEntities");
|
|
153
153
|
const paths = [...checkedKeys].map((checkedKey) => this.getItemPropPath(checkedKey, valueProp, keyEntities));
|
|
154
|
-
this.
|
|
154
|
+
this.adapter.notifyChange([...CascaderFoundation.#missingValuePaths(this.getProps(), keyEntities), ...paths]);
|
|
155
155
|
}
|
|
156
156
|
#isLeaf(item) {
|
|
157
157
|
return CascaderFoundation.#isLeafData(item, this.getProp("loadData"));
|
|
158
158
|
}
|
|
159
159
|
#clearInput() {
|
|
160
|
-
this.
|
|
160
|
+
this.adapter.updateStates({ inputValue: "" });
|
|
161
161
|
}
|
|
162
162
|
#notifyBlur(e) {
|
|
163
|
-
this
|
|
163
|
+
if (!this.#blurPending) return;
|
|
164
|
+
this.#blurPending = false;
|
|
165
|
+
this.adapter.notifyBlur(e);
|
|
166
|
+
}
|
|
167
|
+
/** A single pick closes the dropdown and reports the blur at once, so a Form with trigger="blur" validates */
|
|
168
|
+
#closeAfterPick(e, key) {
|
|
169
|
+
this.#close(key);
|
|
170
|
+
this.#notifyBlur(e);
|
|
164
171
|
}
|
|
165
172
|
#close(key) {
|
|
166
173
|
const { multiple } = this.getProps();
|
|
167
|
-
this.
|
|
174
|
+
this.adapter.updateStates({
|
|
168
175
|
isOpen: false,
|
|
169
176
|
keyboardKey: null
|
|
170
177
|
});
|
|
171
|
-
this.
|
|
178
|
+
this.adapter.notifyDropdownVisibleChange(false);
|
|
172
179
|
if (this.#isFilterable()) {
|
|
173
180
|
const { selectedKeys } = this.getStates();
|
|
174
181
|
let inputValue = "";
|
|
175
182
|
if (key && !multiple) inputValue = this.renderDisplayText(key);
|
|
176
183
|
else if (selectedKeys.size && !multiple) inputValue = this.renderDisplayText([...selectedKeys][0]);
|
|
177
|
-
this.
|
|
184
|
+
this.adapter.updateStates({
|
|
178
185
|
inputValue,
|
|
179
186
|
isSearching: false
|
|
180
187
|
});
|
|
@@ -182,28 +189,26 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
182
189
|
}
|
|
183
190
|
}
|
|
184
191
|
#notifyFocus(e) {
|
|
185
|
-
this
|
|
192
|
+
if (!this.#blurPending && !this.#isDisabled()) {
|
|
193
|
+
this.#blurPending = true;
|
|
194
|
+
this.adapter.notifyFocus(e);
|
|
195
|
+
}
|
|
186
196
|
}
|
|
187
197
|
#getCacheValue(keyEntities) {
|
|
188
198
|
const { selectedKeys, keyEntities: prevKeyEntities } = this.getStates();
|
|
189
199
|
const selectedKey = Array.from(selectedKeys)[0];
|
|
190
200
|
const entity = keyEntities[selectedKey] ?? prevKeyEntities[selectedKey];
|
|
191
201
|
if (!entity) return;
|
|
192
|
-
return entity
|
|
202
|
+
return CascaderFoundation.#missingEntities.has(entity) ? entity.path : entity.valuePath;
|
|
193
203
|
}
|
|
194
|
-
/**
|
|
195
|
-
* Filtered keys for the current props: remote mode treats the current treeData nodes as results without
|
|
196
|
-
* matching; local mode matches by filterTreeNode.
|
|
197
|
-
*/
|
|
198
204
|
#calcFilteredKeys(sugInput, keyEntities) {
|
|
199
205
|
if (!sugInput) return [];
|
|
200
206
|
const { treeNodeFilterProp, filterTreeNode, filterLeafOnly, remote, keyMaps } = this.getProps();
|
|
201
207
|
const realFilterProp = treeNodeFilterProp !== "label" ? treeNodeFilterProp : keyMaps?.label ?? "label";
|
|
202
208
|
keyEntities ??= this.getState("keyEntities");
|
|
203
|
-
const entities = Object.values(keyEntities);
|
|
204
|
-
if (remote) return entities.filter((item) =>
|
|
205
|
-
return entities.filter(({ key,
|
|
206
|
-
if (_notExist) return false;
|
|
209
|
+
const entities = Object.values(keyEntities).filter((item) => !CascaderFoundation.#missingEntities.has(item));
|
|
210
|
+
if (remote) return entities.filter((item) => filterTreeNode && !filterLeafOnly || this.#isLeaf(item.data)).map((item) => item.key);
|
|
211
|
+
return entities.filter(({ key, data }) => {
|
|
207
212
|
const filteredPath = this.getItemPropPath(key, realFilterProp, keyEntities);
|
|
208
213
|
return filter(sugInput, data, filterTreeNode, filteredPath);
|
|
209
214
|
}).filter((item) => filterTreeNode && !filterLeafOnly || this.#isLeaf(item.data)).map((item) => item.key);
|
|
@@ -238,7 +243,7 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
238
243
|
curResolvedCheckedKeys.forEach((itemKey) => {
|
|
239
244
|
checkedEntities.push(keyEntities[itemKey]);
|
|
240
245
|
});
|
|
241
|
-
this.
|
|
246
|
+
this.adapter.notifyOnExceed(checkedEntities);
|
|
242
247
|
return;
|
|
243
248
|
}
|
|
244
249
|
} else if (checkedKeys.size < curCheckedKeys.size && curCheckedKeys.size + missingCount > max) {
|
|
@@ -246,11 +251,11 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
246
251
|
curCheckedKeys.forEach((itemKey) => {
|
|
247
252
|
checkedEntities.push(keyEntities[itemKey]);
|
|
248
253
|
});
|
|
249
|
-
this.
|
|
254
|
+
this.adapter.notifyOnExceed(checkedEntities);
|
|
250
255
|
return;
|
|
251
256
|
}
|
|
252
257
|
}
|
|
253
|
-
if (!this.
|
|
258
|
+
if (!this.isControlledComponent()) this.adapter.updateStates({
|
|
254
259
|
checkedKeys: curCheckedKeys,
|
|
255
260
|
halfCheckedKeys: curHalfCheckedKeys,
|
|
256
261
|
resolvedCheckedKeys: curResolvedCheckedKeys,
|
|
@@ -274,14 +279,14 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
274
279
|
checkedKeys.forEach((itemKey) => {
|
|
275
280
|
checkedEntities.push(keyEntities[itemKey]);
|
|
276
281
|
});
|
|
277
|
-
this.
|
|
282
|
+
this.adapter.notifyOnExceed(checkedEntities);
|
|
278
283
|
return;
|
|
279
284
|
}
|
|
280
285
|
}
|
|
281
286
|
newCheckedKeys.add(key);
|
|
282
287
|
targetStatus = true;
|
|
283
288
|
}
|
|
284
|
-
if (!this.
|
|
289
|
+
if (!this.isControlledComponent()) this.adapter.updateStates({
|
|
285
290
|
checkedKeys: newCheckedKeys,
|
|
286
291
|
checkedEntities: keyEntities
|
|
287
292
|
});
|
|
@@ -296,26 +301,26 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
296
301
|
if (valueItem !== void 0) values.push(valueItem);
|
|
297
302
|
});
|
|
298
303
|
const formatValue = values.length === 1 ? values[0] : values;
|
|
299
|
-
this.
|
|
304
|
+
this.adapter.notifySelect(formatValue);
|
|
300
305
|
}
|
|
301
306
|
#toggle2SearchInput(isShow) {
|
|
302
|
-
if (isShow) this.
|
|
303
|
-
else this.
|
|
307
|
+
if (isShow) this.adapter.toggleInputShow(isShow, () => this.focus());
|
|
308
|
+
else this.adapter.toggleInputShow(isShow, () => void 0);
|
|
304
309
|
}
|
|
305
310
|
#handleShowNextByHover(item) {
|
|
306
311
|
const { keyEntities } = this.getStates();
|
|
307
312
|
const { data, key } = item;
|
|
308
313
|
const isLeaf = this.#isLeaf(data);
|
|
309
314
|
const activeKeys = keyEntities[key].path;
|
|
310
|
-
this.
|
|
315
|
+
this.adapter.updateStates({ activeKeys: new Set(activeKeys) });
|
|
311
316
|
if (!isLeaf) this.#notifyIfLoadData(item);
|
|
312
317
|
}
|
|
313
318
|
#handleNodeLoad({ data, key }) {
|
|
314
319
|
const newLoadedKeys = new Set(this.getState("loadedKeys")).add(key);
|
|
315
320
|
const newLoadingKeys = new Set(this.getState("loadingKeys"));
|
|
316
321
|
newLoadingKeys.delete(key);
|
|
317
|
-
this.
|
|
318
|
-
this.
|
|
322
|
+
this.adapter.notifyOnLoad(newLoadedKeys, data);
|
|
323
|
+
this.adapter.updateStates({
|
|
319
324
|
loadingKeys: newLoadingKeys,
|
|
320
325
|
loadedKeys: newLoadedKeys
|
|
321
326
|
});
|
|
@@ -326,14 +331,14 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
326
331
|
const { loadedKeys, loadingKeys, keyEntities } = this.getStates();
|
|
327
332
|
if (loadedKeys.has(key) || loadingKeys.has(key)) return;
|
|
328
333
|
const optionPath = this.getItemPropPath(key, [], keyEntities);
|
|
329
|
-
this.
|
|
330
|
-
this.
|
|
334
|
+
this.adapter.updateStates({ loadingKeys: new Set(loadingKeys).add(key) });
|
|
335
|
+
this.adapter.notifyLoadData(optionPath, this.#handleNodeLoad.bind(this, item), this.#handleNodeLoadReject.bind(this, item));
|
|
331
336
|
}
|
|
332
337
|
}
|
|
333
338
|
#handleNodeLoadReject(item) {
|
|
334
339
|
const newLoadingKeys = new Set(this.getState("loadingKeys"));
|
|
335
340
|
newLoadingKeys.delete(item.key);
|
|
336
|
-
this.
|
|
341
|
+
this.adapter.updateStates({ loadingKeys: newLoadingKeys });
|
|
337
342
|
}
|
|
338
343
|
#handleSingleSelect(e, item) {
|
|
339
344
|
const { changeOnSelect: allowChange, filterLeafOnly, multiple, enableLeafClick, clickToSelect } = this.getProps();
|
|
@@ -344,35 +349,34 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
344
349
|
const selectedKey = [key];
|
|
345
350
|
const hasChanged = key !== [...selectedKeys][0];
|
|
346
351
|
if (!isLeaf && !allowChange && !isSearching && !(multiple && clickToSelect)) {
|
|
347
|
-
this.
|
|
352
|
+
this.adapter.updateStates({ activeKeys: new Set(activeKeys) });
|
|
348
353
|
this.#notifyIfLoadData(item);
|
|
349
354
|
return;
|
|
350
355
|
}
|
|
351
356
|
if (multiple) {
|
|
352
|
-
this.
|
|
357
|
+
this.adapter.updateStates({ activeKeys: new Set(activeKeys) });
|
|
353
358
|
if (clickToSelect || isLeaf && enableLeafClick) this.onItemCheckboxClick(item);
|
|
354
359
|
} else {
|
|
355
|
-
this.
|
|
360
|
+
this.adapter.notifySelect(data.value);
|
|
356
361
|
if (hasChanged) {
|
|
357
362
|
this.#notifySingleChange(item);
|
|
358
363
|
this.#notifyIfLoadData(item);
|
|
359
|
-
if (this.
|
|
360
|
-
this.
|
|
361
|
-
if (isLeaf || !filterLeafOnly && isSearching) this
|
|
364
|
+
if (this.isControlledComponent()) {
|
|
365
|
+
this.adapter.updateStates({ activeKeys: new Set(activeKeys) });
|
|
366
|
+
if (isLeaf || !filterLeafOnly && isSearching) this.#closeAfterPick(e);
|
|
362
367
|
return;
|
|
363
368
|
}
|
|
364
|
-
this.
|
|
369
|
+
this.adapter.updateStates({
|
|
365
370
|
activeKeys: new Set(activeKeys),
|
|
366
371
|
selectedKeys: new Set(selectedKey)
|
|
367
372
|
});
|
|
368
|
-
if (isLeaf) this
|
|
369
|
-
|
|
370
|
-
} else this.close(e);
|
|
373
|
+
if (isLeaf || !filterLeafOnly && isSearching) this.#closeAfterPick(e, key);
|
|
374
|
+
} else this.#closeAfterPick(e);
|
|
371
375
|
}
|
|
372
376
|
}
|
|
373
377
|
#updateSelectedKey(value, keyEntities) {
|
|
374
378
|
const selection = CascaderFoundation.#selectionFor(this.getProps(), this.getStates(), value, keyEntities);
|
|
375
|
-
this.
|
|
379
|
+
this.adapter.updateStates(selection.updateStates);
|
|
376
380
|
return selection.keyEntities;
|
|
377
381
|
}
|
|
378
382
|
#reCalcActiveKeys() {
|
|
@@ -380,7 +384,7 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
380
384
|
const selectedItem = keyEntities[[...selectedKeys][0]];
|
|
381
385
|
if (!selectedItem) return;
|
|
382
386
|
const newActiveKeys = new Set(selectedItem.path);
|
|
383
|
-
if (!isEqual(newActiveKeys, activeKeys)) this.
|
|
387
|
+
if (!isEqual(newActiveKeys, activeKeys)) this.adapter.updateStates({ activeKeys: newActiveKeys });
|
|
384
388
|
}
|
|
385
389
|
/** Right (`into`) and Left on an option of the columns */
|
|
386
390
|
#handleColumnKey(option, into) {
|
|
@@ -390,7 +394,7 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
390
394
|
if (!isOpen) {
|
|
391
395
|
if (!this.#isOptionDisabled(option)) this.#handleShowNextByHover(option);
|
|
392
396
|
} else if (option.children?.length) this.#moveTo(option.children[0].key, 0);
|
|
393
|
-
} else if (isOpen) this.
|
|
397
|
+
} else if (isOpen) this.adapter.updateStates({ activeKeys: new Set(option.path.slice(0, -1)) });
|
|
394
398
|
else if (option.parent) {
|
|
395
399
|
const { parent } = option;
|
|
396
400
|
const column = parent.parent ? parent.parent.children : CascaderFoundation.getRenderData(this.getProps(), this.getStates());
|
|
@@ -398,10 +402,9 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
398
402
|
}
|
|
399
403
|
}
|
|
400
404
|
#moveTo(key, index) {
|
|
401
|
-
this.
|
|
402
|
-
this.
|
|
405
|
+
this.adapter.updateStates({ keyboardKey: key });
|
|
406
|
+
this.adapter.scrollToOption(key, index);
|
|
403
407
|
}
|
|
404
|
-
/** The options of the shown columns in display order, with their index in their column */
|
|
405
408
|
#getShownOptions() {
|
|
406
409
|
const { activeKeys } = this.getStates();
|
|
407
410
|
const topLevel = CascaderFoundation.getRenderData(this.getProps(), this.getStates());
|
|
@@ -419,9 +422,9 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
419
422
|
let keyEntities = convertDataToEntities(treeData, keyMaps);
|
|
420
423
|
let cacheValue;
|
|
421
424
|
if (Object.keys(keyEntities).length > 0) cacheValue = this.#getCacheValue(keyEntities);
|
|
422
|
-
const selectedValue = !this.
|
|
425
|
+
const selectedValue = !this.isControlledComponent() ? cacheValue : value === void 0 ? [] : value;
|
|
423
426
|
if (selectedValue != null) keyEntities = this.#updateSelectedKey(selectedValue, keyEntities);
|
|
424
|
-
else this.
|
|
427
|
+
else this.adapter.updateStates({ keyEntities });
|
|
425
428
|
this.#recalculateFilteredKeys(isSearching ? inputValue : void 0, keyEntities);
|
|
426
429
|
}
|
|
427
430
|
/**
|
|
@@ -438,13 +441,13 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
438
441
|
filteredKeys: new Set(filteredKeys)
|
|
439
442
|
};
|
|
440
443
|
if (nextKeyEntities) updateStates.keyEntities = nextKeyEntities;
|
|
441
|
-
this.
|
|
444
|
+
this.adapter.updateStates(updateStates);
|
|
442
445
|
}
|
|
443
446
|
#handleValueChange(value) {
|
|
444
447
|
const { keyEntities } = this.getStates();
|
|
445
448
|
this.#updateSelectedKey(value, keyEntities);
|
|
446
449
|
const { isOpen, selectedKeys } = this.getStates();
|
|
447
|
-
if (this.#isFilterable() && !this.getProp("multiple") && !isOpen && selectedKeys.size) this.
|
|
450
|
+
if (this.#isFilterable() && !this.getProp("multiple") && !isOpen && selectedKeys.size) this.adapter.updateStates({ inputValue: this.renderDisplayText([...selectedKeys][0]) });
|
|
448
451
|
}
|
|
449
452
|
getItemPropPath(selectedKey, prop, keyEntities) {
|
|
450
453
|
return CascaderFoundation.getItemPropPath(selectedKey, prop, keyEntities || this.getState("keyEntities"));
|
|
@@ -497,7 +500,6 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
497
500
|
static hasMultipleValue(props, { checkedKeys, keyEntities }) {
|
|
498
501
|
return checkedKeys.size > 0 || CascaderFoundation.#missingValuePaths(props, keyEntities).length > 0;
|
|
499
502
|
}
|
|
500
|
-
/** Checked, half checked and merged keys for a list of checked keys */
|
|
501
503
|
static calcCheckedState(keys, keyEntities, { checkRelation, autoMergeValue, leafOnly }) {
|
|
502
504
|
if (checkRelation !== strings.RELATED) return {
|
|
503
505
|
checkedKeys: new Set(keys),
|
|
@@ -593,19 +595,17 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
593
595
|
}
|
|
594
596
|
return state;
|
|
595
597
|
}
|
|
596
|
-
/** The flattened search results while searching, otherwise the top level */
|
|
597
598
|
static getRenderData(props, state) {
|
|
598
599
|
const { keyEntities, isSearching } = state;
|
|
599
600
|
if (isSearching && Boolean(props.filterTreeNode)) return CascaderFoundation.#getFilteredData(props, state);
|
|
600
|
-
return Object.values(keyEntities).filter((item) => item.parentKey === null && !item
|
|
601
|
+
return Object.values(keyEntities).filter((item) => item.parentKey === null && !CascaderFoundation.#missingEntities.has(item)).sort((a, b) => a.ind - b.ind);
|
|
601
602
|
}
|
|
602
|
-
/** Whether an option opens a column: it has children, or loadData may load some */
|
|
603
603
|
static isBranch(data, loadData) {
|
|
604
604
|
return Boolean(data.children?.length) || Boolean(loadData && !data.isLeaf);
|
|
605
605
|
}
|
|
606
606
|
/**
|
|
607
|
-
*
|
|
608
|
-
*
|
|
607
|
+
* An option that is both active and selected shows only as selected, and in multiple mode selection is the
|
|
608
|
+
* checkbox's, so the row is never marked selected.
|
|
609
609
|
*/
|
|
610
610
|
static getTreeItemState(key, sets, multiple, expandable) {
|
|
611
611
|
const active = sets.activeKeys.has(key);
|
|
@@ -634,7 +634,7 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
634
634
|
static getItemPropPath(selectedKey, prop, keyEntities) {
|
|
635
635
|
const selectedItem = keyEntities[selectedKey];
|
|
636
636
|
let path = [];
|
|
637
|
-
if (!selectedItem) {} else if (selectedItem
|
|
637
|
+
if (!selectedItem) {} else if (CascaderFoundation.#missingEntities.has(selectedItem)) path = selectedItem.path;
|
|
638
638
|
else {
|
|
639
639
|
const keyPath = selectedItem.path;
|
|
640
640
|
path = Array.isArray(prop) ? keyPath.map((key) => keyEntities[key].data) : keyPath.map((key) => keyEntities[key].data[prop]);
|
|
@@ -659,14 +659,14 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
659
659
|
this.#initialized = true;
|
|
660
660
|
if (this.getProp("defaultOpen") && !this.#isDisabled()) this.open();
|
|
661
661
|
}
|
|
662
|
-
handleKeyDown(e) {
|
|
662
|
+
handleKeyDown = (e) => {
|
|
663
663
|
if (e.key === "Escape") {
|
|
664
664
|
if (this.getState("isOpen")) {
|
|
665
665
|
e.preventDefault();
|
|
666
|
-
this.close(
|
|
666
|
+
this.close();
|
|
667
667
|
}
|
|
668
668
|
}
|
|
669
|
-
}
|
|
669
|
+
};
|
|
670
670
|
/**
|
|
671
671
|
* Keys of the open popup (APG combobox with a tree popup, or a listbox while searching); focus stays on the
|
|
672
672
|
* trigger or its search input. Up, Down, Home and End move within the current column or the search results;
|
|
@@ -675,7 +675,7 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
675
675
|
* starting with them (APG tree typeahead). In a search input Space and typed characters edit the text; while
|
|
676
676
|
* searching only Up, Down and Enter navigate. Returns whether the key was used.
|
|
677
677
|
*/
|
|
678
|
-
handleOptionKeyDown(e, { editing, rtl }) {
|
|
678
|
+
handleOptionKeyDown = (e, { editing, rtl }) => {
|
|
679
679
|
const states = this.getStates();
|
|
680
680
|
const { key } = e;
|
|
681
681
|
if (!states.isOpen || e.ctrlKey || e.metaKey || e.altKey || editing && key === " ") return false;
|
|
@@ -719,94 +719,107 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
719
719
|
e.preventDefault();
|
|
720
720
|
this.#moveTo(options[target].key, target);
|
|
721
721
|
return true;
|
|
722
|
-
}
|
|
722
|
+
};
|
|
723
723
|
/**
|
|
724
724
|
* After an update, the host reports whether the options (treeData or keyMaps) and value changed by its own change
|
|
725
725
|
* detection. Re-collecting the options also re-resolves the value.
|
|
726
726
|
*/
|
|
727
|
-
handleInputsChange({ optionsChanged, valueChanged }, value) {
|
|
727
|
+
handleInputsChange = ({ optionsChanged, valueChanged }, value) => {
|
|
728
728
|
if (this.getProp("multiple")) {
|
|
729
729
|
if (optionsChanged) this.#recalculateFilteredKeys();
|
|
730
730
|
return;
|
|
731
731
|
}
|
|
732
732
|
if (optionsChanged) this.#collectOptions();
|
|
733
733
|
else if (valueChanged) this.#handleValueChange(value);
|
|
734
|
-
}
|
|
735
|
-
open() {
|
|
734
|
+
};
|
|
735
|
+
open = () => {
|
|
736
736
|
const filterable = this.#isFilterable();
|
|
737
737
|
const { multiple } = this.getProps();
|
|
738
738
|
const { isSearching } = this.getStates();
|
|
739
|
-
this.
|
|
739
|
+
this.adapter.updateStates({ isOpen: true });
|
|
740
740
|
if (filterable) {
|
|
741
|
-
this.
|
|
741
|
+
this.adapter.updateStates({
|
|
742
742
|
inputValue: "",
|
|
743
743
|
isSearching: false,
|
|
744
744
|
filteredKeys: /* @__PURE__ */ new Set()
|
|
745
745
|
});
|
|
746
|
-
if (isSearching) this.
|
|
746
|
+
if (isSearching) this.adapter.notifyOnSearch("");
|
|
747
747
|
if (!multiple) this.#toggle2SearchInput(true);
|
|
748
748
|
}
|
|
749
|
-
if (this.
|
|
750
|
-
this.
|
|
751
|
-
}
|
|
749
|
+
if (this.isControlledComponent()) this.#reCalcActiveKeys();
|
|
750
|
+
this.adapter.notifyDropdownVisibleChange(true);
|
|
751
|
+
};
|
|
752
752
|
/** Mousedown outside the trigger and dropdown while open */
|
|
753
|
-
handleClickOutside(e) {
|
|
754
|
-
this.close(e);
|
|
755
|
-
}
|
|
756
|
-
close(e, key) {
|
|
757
|
-
this.#close(key);
|
|
753
|
+
handleClickOutside = (e) => {
|
|
758
754
|
this.#notifyBlur(e);
|
|
759
|
-
|
|
755
|
+
this.#close();
|
|
756
|
+
};
|
|
757
|
+
/** Focus entered the trigger (its search input, tags, clear button) or the dropdown from outside, by any means */
|
|
758
|
+
handleFocusEnter = (e) => {
|
|
759
|
+
this.#notifyFocus(e);
|
|
760
|
+
};
|
|
761
|
+
/**
|
|
762
|
+
* The focus left the trigger and the dropdown (the component checks where it went): reports the blur. An open
|
|
763
|
+
* dropdown closes when the focus went to another element (APG combobox); a window blur has no target and keeps
|
|
764
|
+
* it, as the native select does.
|
|
765
|
+
*/
|
|
766
|
+
handleFocusLeave = (e) => {
|
|
767
|
+
this.#notifyBlur(e);
|
|
768
|
+
if (e.relatedTarget && this.getState("isOpen")) this.#close();
|
|
769
|
+
};
|
|
770
|
+
/** Closes the dropdown; the focus stays in the component, so no blur */
|
|
771
|
+
close = () => {
|
|
772
|
+
this.#close();
|
|
773
|
+
};
|
|
760
774
|
/** Closes without a blur; called when Vue KeepAlive deactivates the host */
|
|
761
|
-
deactivate() {
|
|
775
|
+
deactivate = () => {
|
|
762
776
|
this.#close();
|
|
763
|
-
}
|
|
764
|
-
focus() {
|
|
765
|
-
this.
|
|
766
|
-
}
|
|
767
|
-
blur() {
|
|
768
|
-
this.
|
|
769
|
-
}
|
|
777
|
+
};
|
|
778
|
+
focus = () => {
|
|
779
|
+
this.adapter.focusCombobox();
|
|
780
|
+
};
|
|
781
|
+
blur = () => {
|
|
782
|
+
this.adapter.blurCombobox();
|
|
783
|
+
};
|
|
770
784
|
/** Leaves search mode after the closed dropdown finishes its exit */
|
|
771
|
-
endSearching() {
|
|
772
|
-
this.
|
|
773
|
-
}
|
|
785
|
+
endSearching = () => {
|
|
786
|
+
this.adapter.updateStates({ isSearching: false });
|
|
787
|
+
};
|
|
774
788
|
/** A key that opens the dropdown sets the current option before the list mounts; it is scrolled to once shown */
|
|
775
|
-
handlePopoverOpen() {
|
|
789
|
+
handlePopoverOpen = () => {
|
|
776
790
|
const keyboardKey = this.getState("keyboardKey");
|
|
777
791
|
if (!keyboardKey) return;
|
|
778
792
|
const shown = this.#getShownOptions().find(({ option }) => option.key === keyboardKey);
|
|
779
|
-
if (shown) this.
|
|
780
|
-
}
|
|
781
|
-
handleItemClick(e, item) {
|
|
793
|
+
if (shown) this.adapter.scrollToOption(keyboardKey, shown.index);
|
|
794
|
+
};
|
|
795
|
+
handleItemClick = (e, item) => {
|
|
782
796
|
if (this.#isDisabled()) return;
|
|
783
797
|
this.#handleSingleSelect(e, item);
|
|
784
|
-
}
|
|
785
|
-
handleItemHover(_e, item) {
|
|
798
|
+
};
|
|
799
|
+
handleItemHover = (_e, item) => {
|
|
786
800
|
if (this.#isDisabled()) return;
|
|
787
801
|
this.#handleShowNextByHover(item);
|
|
788
|
-
}
|
|
789
|
-
onItemCheckboxClick(item) {
|
|
802
|
+
};
|
|
803
|
+
onItemCheckboxClick = (item) => {
|
|
790
804
|
if (this.#isDisabled()) return;
|
|
791
805
|
this.#handleMultipleSelect(item);
|
|
792
|
-
}
|
|
793
|
-
handleClick(e) {
|
|
806
|
+
};
|
|
807
|
+
handleClick = (e) => {
|
|
794
808
|
const isDisabled = this.#isDisabled();
|
|
795
809
|
const isFilterable = this.#isFilterable();
|
|
796
810
|
const { isOpen } = this.getStates();
|
|
797
811
|
if (isDisabled || isInnerControlActivation(e)) return;
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}
|
|
812
|
+
this.#notifyFocus(e);
|
|
813
|
+
if (!isOpen) this.open();
|
|
814
|
+
else if (!isFilterable) this.close();
|
|
815
|
+
};
|
|
803
816
|
/**
|
|
804
817
|
* Enter toggles like a click; Down and Up open a closed popup (APG combobox). Without a search input (select-only
|
|
805
818
|
* combobox) Space also opens it, and Home and End open it on the first and last option of the first column.
|
|
806
819
|
* While open with no current option (handleOptionKeyDown left the key), Space outside a text field acts like
|
|
807
820
|
* Enter, as in Select and TreeSelect. A search input keeps Space, Home and End for its text.
|
|
808
821
|
*/
|
|
809
|
-
handleSelectionKeyDown(keyboardEvent) {
|
|
822
|
+
handleSelectionKeyDown = (keyboardEvent) => {
|
|
810
823
|
const { key } = keyboardEvent;
|
|
811
824
|
const isOpen = this.getState("isOpen");
|
|
812
825
|
const opensOnArrow = (key === "ArrowDown" || key === "ArrowUp") && !isOpen;
|
|
@@ -821,73 +834,73 @@ var CascaderFoundation = class CascaderFoundation extends BaseFoundation {
|
|
|
821
834
|
const index = key === "Home" ? 0 : column.length - 1;
|
|
822
835
|
if (column[index]) this.#moveTo(column[index].key, index);
|
|
823
836
|
}
|
|
824
|
-
}
|
|
825
|
-
handleInputChange(sugInput) {
|
|
837
|
+
};
|
|
838
|
+
handleInputChange = (sugInput) => {
|
|
826
839
|
const filteredKeys = this.#calcFilteredKeys(sugInput);
|
|
827
|
-
this.
|
|
840
|
+
this.adapter.updateStates({
|
|
828
841
|
inputValue: sugInput,
|
|
829
842
|
isSearching: Boolean(sugInput),
|
|
830
843
|
filteredKeys: new Set(filteredKeys),
|
|
831
844
|
keyboardKey: null
|
|
832
845
|
});
|
|
833
|
-
this.
|
|
834
|
-
}
|
|
835
|
-
handleClear() {
|
|
846
|
+
this.adapter.notifyOnSearch(sugInput);
|
|
847
|
+
};
|
|
848
|
+
handleClear = () => {
|
|
836
849
|
const { isSearching, keyEntities, inputValue } = this.getStates();
|
|
837
850
|
const { multiple } = this.getProps();
|
|
838
851
|
const isFilterable = this.#isFilterable();
|
|
839
|
-
const isControlled = this.
|
|
852
|
+
const isControlled = this.isControlledComponent();
|
|
840
853
|
const newState = {};
|
|
841
854
|
if (multiple) {
|
|
842
855
|
const hasValue = CascaderFoundation.hasMultipleValue(this.getProps(), this.getStates());
|
|
843
856
|
newState.isSearching = false;
|
|
844
857
|
this.#clearInput();
|
|
845
|
-
if (inputValue) this.
|
|
858
|
+
if (inputValue) this.adapter.notifyOnSearch("");
|
|
846
859
|
newState.checkedKeys = /* @__PURE__ */ new Set([]);
|
|
847
860
|
newState.halfCheckedKeys = /* @__PURE__ */ new Set([]);
|
|
848
861
|
newState.selectedKeys = /* @__PURE__ */ new Set([]);
|
|
849
862
|
newState.activeKeys = /* @__PURE__ */ new Set([]);
|
|
850
863
|
newState.resolvedCheckedKeys = /* @__PURE__ */ new Set([]);
|
|
851
864
|
newState.checkedEntities = keyEntities;
|
|
852
|
-
if (hasValue) this.
|
|
865
|
+
if (hasValue) this.adapter.notifyChange([]);
|
|
853
866
|
} else if (isFilterable && isSearching) {
|
|
854
867
|
newState.isSearching = false;
|
|
855
868
|
this.#clearInput();
|
|
856
|
-
this.
|
|
869
|
+
this.adapter.notifyOnSearch("");
|
|
857
870
|
} else {
|
|
858
871
|
if (isFilterable) {
|
|
859
872
|
newState.inputValue = "";
|
|
860
873
|
this.#clearInput();
|
|
861
|
-
this.
|
|
874
|
+
this.adapter.notifyOnSearch("");
|
|
862
875
|
}
|
|
863
876
|
if (!isControlled) newState.selectedKeys = /* @__PURE__ */ new Set([]);
|
|
864
877
|
newState.activeKeys = /* @__PURE__ */ new Set([]);
|
|
865
878
|
newState.filteredKeys = /* @__PURE__ */ new Set([]);
|
|
866
|
-
this.
|
|
879
|
+
this.adapter.notifyChange([]);
|
|
867
880
|
}
|
|
868
|
-
this.
|
|
869
|
-
this.
|
|
870
|
-
}
|
|
871
|
-
handleListScroll(e, ind) {
|
|
881
|
+
this.adapter.updateStates(newState);
|
|
882
|
+
this.adapter.notifyClear();
|
|
883
|
+
};
|
|
884
|
+
handleListScroll = (e, ind) => {
|
|
872
885
|
const { activeKeys, keyEntities } = this.getStates();
|
|
873
886
|
const lastActiveKey = [...activeKeys].at(-1);
|
|
874
887
|
const data = lastActiveKey ? keyEntities?.[lastActiveKey]?.data ?? null : null;
|
|
875
|
-
this.
|
|
888
|
+
this.adapter.notifyListScroll(e, {
|
|
876
889
|
panelIndex: ind,
|
|
877
890
|
activeNode: data
|
|
878
891
|
});
|
|
879
|
-
}
|
|
880
|
-
handleTagRemoveByKey(key) {
|
|
892
|
+
};
|
|
893
|
+
handleTagRemoveByKey = (key) => {
|
|
881
894
|
const { keyEntities } = this.getStates();
|
|
882
895
|
const { disabled } = this.getProps();
|
|
883
896
|
if (disabled) return;
|
|
884
897
|
const removedItem = keyEntities[key];
|
|
885
898
|
if (removedItem && !removedItem.data?.disabled) this.#handleMultipleSelect(removedItem);
|
|
886
|
-
}
|
|
887
|
-
handleTagRemoveInTrigger(pos) {
|
|
899
|
+
};
|
|
900
|
+
handleTagRemoveInTrigger = (pos) => {
|
|
888
901
|
const { treeData, keyMaps } = this.getProps();
|
|
889
902
|
const key = getKeyByPos(pos, treeData, keyMaps);
|
|
890
903
|
this.handleTagRemoveByKey(key);
|
|
891
|
-
}
|
|
904
|
+
};
|
|
892
905
|
};
|
|
893
906
|
export { CascaderFoundation as default };
|
package/dist/cascader/util.d.ts
CHANGED
|
@@ -6,11 +6,7 @@ export interface KeyMapProps {
|
|
|
6
6
|
children?: string;
|
|
7
7
|
isLeaf?: string;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
* @returns whether option matches sugInput; a function filterTreeNode decides with (sugInput, target, option).
|
|
11
|
-
*/
|
|
12
9
|
export declare function filter(sugInput: string, option: BasicCascaderData, filterTreeNode: any, filteredPath?: string[]): any;
|
|
13
|
-
/** One column per level of the active path: the top level, then the children of each active node that has some */
|
|
14
10
|
export declare function getColumns<T extends {
|
|
15
11
|
key: string;
|
|
16
12
|
data: {
|
|
@@ -21,10 +17,7 @@ export declare function getColumns<T extends {
|
|
|
21
17
|
items: T[];
|
|
22
18
|
level: number;
|
|
23
19
|
}[];
|
|
24
|
-
/**
|
|
25
|
-
* The labels of a search result joined by the separator, split into the runs that match the keyword and the rest. Only
|
|
26
|
-
* a string label is matched, as the default filter does; any other label passes through whole.
|
|
27
|
-
*/
|
|
20
|
+
/** Only a string label is matched, as the default filter does; any other label passes through whole */
|
|
28
21
|
export declare function highlightParts<T>(searchText: T[], keyword: string, separator: string): {
|
|
29
22
|
text: string | T;
|
|
30
23
|
match: boolean;
|