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