@greypan/web-ui 6.4.0 → 8.0.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/README.CN.md +211 -50
- package/README.md +222 -61
- package/dist/assets/glass.js +1 -1
- package/dist/assets/glass.js.map +1 -1
- package/dist/assets/selection-control.js +6 -0
- package/dist/assets/selection-control.js.map +1 -0
- package/dist/assets/toast-containers.js.map +1 -1
- package/dist/components/autocomplete/index.d.ts +19 -5
- package/dist/components/autocomplete/index.js +142 -108
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/autocomplete/style.js +1 -1
- package/dist/components/autocomplete/style.js.map +1 -1
- package/dist/components/avatar/index.js +4 -4
- package/dist/components/badge/style.js.map +1 -1
- package/dist/components/button/index.js +15 -15
- package/dist/components/button/style.js.map +1 -1
- package/dist/components/button-group/index.js +5 -5
- package/dist/components/checkbox/index.d.ts +9 -2
- package/dist/components/checkbox/index.js +50 -26
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/checkbox/style.js +1 -1
- package/dist/components/checkbox/style.js.map +1 -1
- package/dist/components/checkbox-group/index.d.ts +3 -0
- package/dist/components/checkbox-group/index.js +27 -16
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/checkbox-group/style.js +1 -1
- package/dist/components/checkbox-group/style.js.map +1 -1
- package/dist/components/collapse/index.js.map +1 -1
- package/dist/components/context-menu/index.d.ts +10 -0
- package/dist/components/context-menu/index.js +51 -34
- package/dist/components/context-menu/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +6 -0
- package/dist/components/dialog/index.js +49 -21
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/dialog/style.js +1 -1
- package/dist/components/dialog/style.js.map +1 -1
- package/dist/components/drawer/index.d.ts +22 -4
- package/dist/components/drawer/index.js +141 -110
- package/dist/components/drawer/index.js.map +1 -1
- package/dist/components/drawer/style.js +1 -1
- package/dist/components/drawer/style.js.map +1 -1
- package/dist/components/dropdown/index.d.ts +21 -1
- package/dist/components/dropdown/index.js +77 -51
- package/dist/components/dropdown/index.js.map +1 -1
- package/dist/components/editable-text/index.d.ts +471 -0
- package/dist/components/editable-text/index.js +206 -0
- package/dist/components/editable-text/index.js.map +1 -0
- package/dist/components/editable-text/style.js +6 -0
- package/dist/components/editable-text/style.js.map +1 -0
- package/dist/components/image-preview/index.js +103 -80
- package/dist/components/image-preview/index.js.map +1 -1
- package/dist/components/image-preview/style.js +1 -1
- package/dist/components/image-preview/style.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +39 -38
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.js +12 -6
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input/style.js.map +1 -1
- package/dist/components/input-number/index.js +15 -15
- package/dist/components/layout/index.js +9 -9
- package/dist/components/layout/index.js.map +1 -1
- package/dist/components/layout/style.js +1 -1
- package/dist/components/layout/style.js.map +1 -1
- package/dist/components/popover/index.d.ts +8 -2
- package/dist/components/popover/index.js +53 -55
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/radio/index.d.ts +1 -1
- package/dist/components/radio/index.js +22 -21
- package/dist/components/radio/index.js.map +1 -1
- package/dist/components/radio/style.js +1 -1
- package/dist/components/radio/style.js.map +1 -1
- package/dist/components/radio-group/index.d.ts +3 -0
- package/dist/components/radio-group/index.js +27 -16
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/radio-group/style.js +1 -1
- package/dist/components/radio-group/style.js.map +1 -1
- package/dist/components/segmented/index.d.ts +4 -1
- package/dist/components/segmented/index.js +42 -29
- package/dist/components/segmented/index.js.map +1 -1
- package/dist/components/segmented/style.js +1 -1
- package/dist/components/segmented/style.js.map +1 -1
- package/dist/components/segmented-trigger/style.js +1 -1
- package/dist/components/segmented-trigger/style.js.map +1 -1
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +38 -34
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/slider/index.js +11 -11
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/style.js +1 -1
- package/dist/components/slider/style.js.map +1 -1
- package/dist/components/svg-draw-lines/index.d.ts +13 -2
- package/dist/components/svg-draw-lines/index.js +44 -31
- package/dist/components/svg-draw-lines/index.js.map +1 -1
- package/dist/components/switch/index.js +12 -12
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/style.js.map +1 -1
- package/dist/components/textarea/index.js +6 -6
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/textarea/style.js.map +1 -1
- package/dist/components/theme/index.d.ts +15 -0
- package/dist/components/theme/index.js +178 -21
- package/dist/components/theme/index.js.map +1 -1
- package/dist/components/theme/style.js +1 -1
- package/dist/components/theme/style.js.map +1 -1
- package/dist/components/toast/index.d.ts +1 -1
- package/dist/components/toast/manager.d.ts +1 -3
- package/dist/components/toast/manager.js +92 -49
- package/dist/components/toast/manager.js.map +1 -1
- package/dist/components/toast/style.js.map +1 -1
- package/dist/components/toast/toast.d.ts +37 -0
- package/dist/components/toast/toast.js +74 -21
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toast/types.d.ts +0 -4
- package/dist/components/tooltip/index.d.ts +6 -1
- package/dist/components/tooltip/index.js +21 -19
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/shared/gesture/drag-gesture.js +66 -64
- package/dist/shared/gesture/drag-gesture.js.map +1 -1
- package/dist/shared/gesture/physics.js +7 -29
- package/dist/shared/gesture/physics.js.map +1 -1
- package/dist/shared/menu-behavior/index.js +3 -4
- package/dist/shared/menu-behavior/index.js.map +1 -1
- package/dist/shared/option-portal/combobox-shell.js +48 -7
- package/dist/shared/option-portal/combobox-shell.js.map +1 -1
- package/dist/shared/option-portal/index.js +9 -9
- package/dist/shared/overlay/anchored-panel.js +36 -31
- package/dist/shared/overlay/anchored-panel.js.map +1 -1
- package/dist/shared/overlay/native-dialog-presence.js +16 -0
- package/dist/shared/overlay/native-dialog-presence.js.map +1 -1
- package/dist/shared/overlay/nested-drawer-layers.js +7 -4
- package/dist/shared/overlay/nested-drawer-layers.js.map +1 -1
- package/dist/shared/overlay/open-overlay.js +198 -0
- package/dist/shared/overlay/open-overlay.js.map +1 -0
- package/dist/shared/overlay/presence.js +19 -22
- package/dist/shared/overlay/presence.js.map +1 -1
- package/dist/shared/theme/duration.js +9 -0
- package/dist/shared/theme/duration.js.map +1 -0
- package/dist/shared/theme/reduced-motion.js +15 -0
- package/dist/shared/theme/reduced-motion.js.map +1 -0
- package/dist/shared/theme/root-sync.js +42 -0
- package/dist/shared/theme/root-sync.js.map +1 -0
- package/package.json +1 -1
- package/dist/shared/overlay/composition.js +0 -57
- package/dist/shared/overlay/composition.js.map +0 -1
- package/dist/shared/overlay/lifecycle.js +0 -41
- package/dist/shared/overlay/lifecycle.js.map +0 -1
- package/dist/vite.svg +0 -1
|
@@ -373,6 +373,12 @@ declare const WebUiAutocomplete_base: {
|
|
|
373
373
|
* 可编辑输入框:`value` 即当前输入文本(表单值),键入时按 `filter` 模式过滤候选,
|
|
374
374
|
* 选择 option 时文本回填为该项 label,`selected-value` 暴露该项的 value。
|
|
375
375
|
* `allow-custom-value` 开启后,Enter 可把不匹配候选的原文作为 custom value 显式提交。
|
|
376
|
+
*
|
|
377
|
+
* 触发器跟随 select 的 wrapper div 模式:`slot[name="trigger"]` 可替换默认触发器
|
|
378
|
+
* (shadow 内的 `web-ui-input`);多行触发器(如 `web-ui-textarea`)保留 Enter 换行语义,
|
|
379
|
+
* 关闭面板用 Escape 或 blur。
|
|
380
|
+
* tab 位只属于触发器自身:默认触发器是 shadow 内 input,自定义触发器由消费者提供
|
|
381
|
+
* 可聚焦元素(README 契约);包装 div 恒为 tabindex="-1",不占顺序焦点,避免双 tab 位。
|
|
376
382
|
*/
|
|
377
383
|
export declare class WebUiAutocomplete extends WebUiAutocomplete_base {
|
|
378
384
|
static styles: import('lit').CSSResult[];
|
|
@@ -403,6 +409,7 @@ export declare class WebUiAutocomplete extends WebUiAutocomplete_base {
|
|
|
403
409
|
private _isOpen;
|
|
404
410
|
private _activeIndex;
|
|
405
411
|
private _focused;
|
|
412
|
+
private _hasTriggerSlot;
|
|
406
413
|
private static _nextInstanceId;
|
|
407
414
|
private readonly _idPrefix;
|
|
408
415
|
private readonly _a11yOptionIds;
|
|
@@ -412,13 +419,19 @@ export declare class WebUiAutocomplete extends WebUiAutocomplete_base {
|
|
|
412
419
|
private _portalContent?;
|
|
413
420
|
private readonly _scrollLock;
|
|
414
421
|
private readonly _optionPortal;
|
|
422
|
+
private readonly _trigger;
|
|
423
|
+
private readonly _overlay;
|
|
415
424
|
private readonly _panel;
|
|
416
425
|
get isOpen(): boolean;
|
|
417
426
|
get open(): boolean;
|
|
427
|
+
focus(options?: FocusOptions): void;
|
|
428
|
+
blur(): void;
|
|
418
429
|
private _onClickOutside;
|
|
419
430
|
private _onFocusOut;
|
|
420
431
|
private _handlePanelPointerDown;
|
|
421
432
|
connectedCallback(): void;
|
|
433
|
+
private _onTriggerSlotChange;
|
|
434
|
+
private _syncTriggerSlot;
|
|
422
435
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
423
436
|
disconnectedCallback(): void;
|
|
424
437
|
firstUpdated(): void;
|
|
@@ -427,6 +440,7 @@ export declare class WebUiAutocomplete extends WebUiAutocomplete_base {
|
|
|
427
440
|
formDisabledCallback(disabled: boolean): void;
|
|
428
441
|
private _syncValidity;
|
|
429
442
|
private _syncOpenAttribute;
|
|
443
|
+
private _syncOverlayInert;
|
|
430
444
|
private _syncSelectedValue;
|
|
431
445
|
private _syncOptionA11y;
|
|
432
446
|
private _getA11yOptionId;
|
|
@@ -449,11 +463,11 @@ export declare class WebUiAutocomplete extends WebUiAutocomplete_base {
|
|
|
449
463
|
private _findExactOption;
|
|
450
464
|
private _hasExactOption;
|
|
451
465
|
private _selectCustomValue;
|
|
452
|
-
private
|
|
453
|
-
private
|
|
454
|
-
private
|
|
455
|
-
private
|
|
456
|
-
private
|
|
466
|
+
private _onTriggerInput;
|
|
467
|
+
private _onTriggerClick;
|
|
468
|
+
private _onTriggerFocusIn;
|
|
469
|
+
private _onTriggerFocusOut;
|
|
470
|
+
private _isSlottedFocus;
|
|
457
471
|
private readonly _openController;
|
|
458
472
|
private _open;
|
|
459
473
|
private _close;
|
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import e from "../../_virtual/_@oxc-project_runtime@0.149.0/helpers/esm/decorate.js";
|
|
2
|
-
import "../option/index.js";
|
|
3
2
|
import t from "../../assets/glass.js";
|
|
4
|
-
import n from "../../
|
|
3
|
+
import { normalizeLiteral as n } from "../../shared/normalize/index.js";
|
|
5
4
|
import { FormAssociated as r, FormAssociationController as i, defineFormAssociation as a } from "../../shared/form-association/index.js";
|
|
6
|
-
import
|
|
5
|
+
import "../input/index.js";
|
|
6
|
+
import "../option/index.js";
|
|
7
|
+
import o from "../../assets/overlay-motion.js";
|
|
7
8
|
import { dispatchOpenChangeEvent as s } from "../../shared/open-state/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import { createComboboxOpenController as l, createOptionListenerBinding as u, handleComboboxFocusOut as d, nextWrappingIndex as f } from "../../shared/option-portal/combobox-shell.js";
|
|
9
|
+
import { createComboboxOpenController as c, createOptionListenerBinding as l, defineComboboxTrigger as u, handleComboboxFocusOut as d, nextWrappingIndex as f } from "../../shared/option-portal/combobox-shell.js";
|
|
10
10
|
import { defineOptionPortal as p } from "../../shared/option-portal/index.js";
|
|
11
11
|
import { defineAnchoredPanel as m } from "../../shared/overlay/anchored-panel.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import v from "
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
12
|
+
import { defineOpenOverlay as h } from "../../shared/overlay/open-overlay.js";
|
|
13
|
+
import { applyOverlayVariables as g, defineOverlayPortal as _ } from "../../shared/overlay/portal.js";
|
|
14
|
+
import { defineScrollLockLease as v } from "../../shared/scroll-lock/scroll-lock.js";
|
|
15
|
+
import y from "./style.js";
|
|
16
|
+
import { LitElement as b, html as x, nothing as S, unsafeCSS as C } from "lit";
|
|
17
|
+
import { customElement as w, property as T, state as E } from "lit/decorators.js";
|
|
18
|
+
import { ifDefined as D } from "lit/directives/if-defined.js";
|
|
18
19
|
//#region src/components/autocomplete/index.ts
|
|
19
|
-
var
|
|
20
|
+
var O, k = [
|
|
20
21
|
"none",
|
|
21
22
|
"prefix",
|
|
22
23
|
"contains"
|
|
23
24
|
];
|
|
24
|
-
function
|
|
25
|
+
function A(e) {
|
|
25
26
|
return e instanceof Element && e.getAttribute("slot") === "empty";
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
function j(e) {
|
|
29
|
+
return e instanceof Element && e.slot === "trigger";
|
|
30
|
+
}
|
|
31
|
+
var M = class extends r(b) {
|
|
28
32
|
static {
|
|
29
|
-
|
|
33
|
+
O = this;
|
|
30
34
|
}
|
|
31
35
|
constructor(...e) {
|
|
32
36
|
super(...e), this.placeholder = "", this.borderless = !1, this.disabled = !1, this.readonly = !1, this.required = !1, this.portal = !1, this.noScrollLock = !1, this.allowCustomValue = !1, this.name = "", this.ariaLabel = null, this._filter = "contains", this._value = "", this._selectedValue = "", this._formAssociation = a({
|
|
@@ -45,19 +49,33 @@ var A = class extends r(y) {
|
|
|
45
49
|
typeof e == "string" && (this.value = e);
|
|
46
50
|
},
|
|
47
51
|
syncValidity: () => this._syncValidity()
|
|
48
|
-
}).make(), this._formAssociationController = new i(this, this._formAssociation), this._isOpen = !1, this._activeIndex = -1, this._focused = !1, this._idPrefix = `web-ui-autocomplete-${++
|
|
52
|
+
}).make(), this._formAssociationController = new i(this, this._formAssociation), this._isOpen = !1, this._activeIndex = -1, this._focused = !1, this._hasTriggerSlot = !1, this._idPrefix = `web-ui-autocomplete-${++O._nextInstanceId}`, this._a11yOptionIds = /* @__PURE__ */ new WeakMap(), this._nextA11yOptionId = 0, this._options = [], this._scrollLock = v().make(), this._optionPortal = p().make({
|
|
49
53
|
element: this,
|
|
50
54
|
idPrefix: `${this._idPrefix}-option`,
|
|
51
55
|
getPortal: () => this._portal,
|
|
52
56
|
getPortalContent: () => this._portalContent,
|
|
53
57
|
isOpen: () => this.portal && this._isOpen,
|
|
54
|
-
getMigratableNodes: () => Array.from(this.childNodes).filter((e) => !
|
|
58
|
+
getMigratableNodes: () => Array.from(this.childNodes).filter((e) => !A(e) && !j(e)),
|
|
55
59
|
hasUpdated: () => this.hasUpdated,
|
|
56
60
|
requestUpdate: () => this.requestUpdate(),
|
|
57
61
|
bindOption: (e) => this._bindOption(e),
|
|
58
62
|
unbindOption: (e) => this._unbindOption(e)
|
|
63
|
+
}), this._trigger = u().make({
|
|
64
|
+
getWrapper: () => this.shadowRoot?.querySelector(".autocomplete-trigger") ?? null,
|
|
65
|
+
getCustomTrigger: () => {
|
|
66
|
+
let e = this.shadowRoot?.querySelector("slot[name=\"trigger\"]")?.assignedElements()[0];
|
|
67
|
+
return e instanceof HTMLElement ? e : null;
|
|
68
|
+
},
|
|
69
|
+
getFallbackTrigger: () => this.shadowRoot?.querySelector(".autocomplete-input") ?? null,
|
|
70
|
+
onInput: (e) => this._onTriggerInput(e),
|
|
71
|
+
onClick: () => this._onTriggerClick(),
|
|
72
|
+
onFocusIn: (e) => this._onTriggerFocusIn(e),
|
|
73
|
+
onFocusOut: (e) => this._onTriggerFocusOut(e)
|
|
74
|
+
}), this._overlay = h().make({
|
|
75
|
+
requestClose: () => this._close(),
|
|
76
|
+
isConnected: () => this.isConnected
|
|
59
77
|
}), this._panel = m().make({
|
|
60
|
-
getAnchor: () => this.shadowRoot?.querySelector(".
|
|
78
|
+
getAnchor: () => this._trigger.getTrigger() ?? this.shadowRoot?.querySelector(".autocomplete-trigger") ?? null,
|
|
61
79
|
getLocalPanel: () => this.shadowRoot?.querySelector(".autocomplete-overlay") ?? null,
|
|
62
80
|
getPositioning: () => ({
|
|
63
81
|
placement: "bottom-start",
|
|
@@ -66,16 +84,17 @@ var A = class extends r(y) {
|
|
|
66
84
|
strategy: this.portal ? "fixed" : "absolute"
|
|
67
85
|
}),
|
|
68
86
|
isPortal: () => this.portal,
|
|
69
|
-
createPortal: () => this._createPortal()
|
|
87
|
+
createPortal: () => this._createPortal(),
|
|
88
|
+
openOverlay: this._overlay
|
|
70
89
|
}), this._onClickOutside = (e) => {
|
|
71
|
-
|
|
72
|
-
let t = e.composedPath(), n = this._panel.getPanel();
|
|
73
|
-
!t.includes(this) && !(n && c.containsEvent(n, e)) && this._close();
|
|
90
|
+
this._isOpen && (e.composedPath().includes(this) || this._panel.getHandle()?.containsEvent(e) || this._close());
|
|
74
91
|
}, this._onFocusOut = () => {
|
|
75
|
-
d(this, () => this._panel.
|
|
92
|
+
d(this, () => this._panel.getHandle(), () => this._isOpen, () => this._close());
|
|
76
93
|
}, this._handlePanelPointerDown = (e) => {
|
|
77
94
|
e.preventDefault();
|
|
78
|
-
}, this.
|
|
95
|
+
}, this._onTriggerSlotChange = () => {
|
|
96
|
+
this._syncTriggerSlot();
|
|
97
|
+
}, this._optionListeners = l({
|
|
79
98
|
onClick: (e) => this._handleOptionClick(e),
|
|
80
99
|
onPointerOver: (e) => this._handleOptionPointerOver(e),
|
|
81
100
|
onPointerDown: (e) => this._handleOptionPointerDown(e),
|
|
@@ -94,16 +113,12 @@ var A = class extends r(y) {
|
|
|
94
113
|
this._optionPortal.scheduleRefresh();
|
|
95
114
|
}, this._onKeydown = (e) => {
|
|
96
115
|
if (!(this._isDisabled || this.readonly)) switch (e.key) {
|
|
97
|
-
case "Escape":
|
|
98
|
-
this._isOpen && (this._close(), e.preventDefault());
|
|
99
|
-
break;
|
|
100
116
|
case "ArrowDown":
|
|
101
|
-
e.preventDefault(), this._isOpen ? this._navigateActive(1) : this._open(!0);
|
|
102
|
-
break;
|
|
103
117
|
case "ArrowUp":
|
|
104
|
-
|
|
118
|
+
if (this._isOpen && this._trigger.isMultilineEdit(e)) break;
|
|
119
|
+
e.preventDefault(), this._isOpen ? this._navigateActive(e.key === "ArrowDown" ? 1 : -1) : this._open(!0);
|
|
105
120
|
break;
|
|
106
|
-
case "Enter": if (this._isOpen) {
|
|
121
|
+
case "Enter": if (this._isOpen && !this._trigger.isMultilineEdit(e)) {
|
|
107
122
|
e.preventDefault();
|
|
108
123
|
let t = this._options[this._activeIndex];
|
|
109
124
|
if (t && !t.disabled && !t.hasAttribute("data-filtered")) {
|
|
@@ -118,19 +133,21 @@ var A = class extends r(y) {
|
|
|
118
133
|
this.allowCustomValue && this._value && !this._hasExactOption(this._value) && this._selectCustomValue();
|
|
119
134
|
}
|
|
120
135
|
}
|
|
121
|
-
}, this.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
t.value !== this._value && (this.value = t.value, this._activeIndex = -1, this._syncActiveOption(), this._isOpen || this._open());
|
|
125
|
-
}, this._onInnerChange = (e) => {
|
|
126
|
-
e.stopPropagation();
|
|
127
|
-
}, this._onFocus = () => {
|
|
128
|
-
this._isDisabled || (this._focused = !0);
|
|
129
|
-
}, this._onInputClick = () => {
|
|
136
|
+
}, this._onTriggerInput = (e) => {
|
|
137
|
+
this._isDisabled || this.readonly || e !== this._value && (this.value = e, this._activeIndex = -1, this._syncActiveOption(), this._isOpen || this._open());
|
|
138
|
+
}, this._onTriggerClick = () => {
|
|
130
139
|
this._isDisabled || this.readonly || this._options.length > 0 && this._open();
|
|
131
|
-
}, this.
|
|
132
|
-
this._focused = !
|
|
133
|
-
|
|
140
|
+
}, this._onTriggerFocusIn = (e) => {
|
|
141
|
+
this._isDisabled || (this._focused = !0, this._isSlottedFocus(e) && this.dispatchEvent(new FocusEvent("focus", {
|
|
142
|
+
composed: !0,
|
|
143
|
+
relatedTarget: e.relatedTarget
|
|
144
|
+
})));
|
|
145
|
+
}, this._onTriggerFocusOut = (e) => {
|
|
146
|
+
this._focused = !1, this._isSlottedFocus(e) && this.dispatchEvent(new FocusEvent("blur", {
|
|
147
|
+
composed: !0,
|
|
148
|
+
relatedTarget: e.relatedTarget
|
|
149
|
+
}));
|
|
150
|
+
}, this._openController = c({
|
|
134
151
|
canOpen: () => !this._isDisabled && !this.readonly,
|
|
135
152
|
getIsOpen: () => this._isOpen,
|
|
136
153
|
setIsOpen: (e) => {
|
|
@@ -154,9 +171,9 @@ var A = class extends r(y) {
|
|
|
154
171
|
}
|
|
155
172
|
static {
|
|
156
173
|
this.styles = [
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
C(t),
|
|
175
|
+
C(o),
|
|
176
|
+
C(y)
|
|
160
177
|
];
|
|
161
178
|
}
|
|
162
179
|
get filter() {
|
|
@@ -164,7 +181,7 @@ var A = class extends r(y) {
|
|
|
164
181
|
}
|
|
165
182
|
set filter(e) {
|
|
166
183
|
let t = this._filter;
|
|
167
|
-
this._filter =
|
|
184
|
+
this._filter = n(e, k, "contains"), this.requestUpdate("filter", t);
|
|
168
185
|
}
|
|
169
186
|
get value() {
|
|
170
187
|
return this._value;
|
|
@@ -192,8 +209,18 @@ var A = class extends r(y) {
|
|
|
192
209
|
get open() {
|
|
193
210
|
return this._isOpen;
|
|
194
211
|
}
|
|
212
|
+
focus(e) {
|
|
213
|
+
this._trigger.focusTrigger(e);
|
|
214
|
+
}
|
|
215
|
+
blur() {
|
|
216
|
+
this._trigger.blurTrigger();
|
|
217
|
+
}
|
|
195
218
|
connectedCallback() {
|
|
196
|
-
super.connectedCallback(), this._optionPortal.bindHost(), this.addEventListener("keydown", this._onKeydown), this.addEventListener("focusout", this._onFocusOut), document.addEventListener("click", this._onClickOutside);
|
|
219
|
+
super.connectedCallback(), this._optionPortal.bindHost(), this._trigger.bind(), this.addEventListener("keydown", this._onKeydown), this.addEventListener("focusout", this._onFocusOut), document.addEventListener("click", this._onClickOutside);
|
|
220
|
+
}
|
|
221
|
+
_syncTriggerSlot() {
|
|
222
|
+
let e = Array.from(this.children).some(j);
|
|
223
|
+
this._hasTriggerSlot !== e && (this._hasTriggerSlot = e, this.hasUpdated && this._reconfigureOverlay());
|
|
197
224
|
}
|
|
198
225
|
attributeChangedCallback(e, t, n) {
|
|
199
226
|
super.attributeChangedCallback(e, t, n), e === "selected-value" && this.isConnected && n !== this._selectedValue && queueMicrotask(() => {
|
|
@@ -201,19 +228,18 @@ var A = class extends r(y) {
|
|
|
201
228
|
});
|
|
202
229
|
}
|
|
203
230
|
disconnectedCallback() {
|
|
204
|
-
super.disconnectedCallback(), this._optionPortal.dispose(), this.removeEventListener("keydown", this._onKeydown), this.removeEventListener("focusout", this._onFocusOut), document.removeEventListener("click", this._onClickOutside), this._options.forEach(this._unbindOption), this._close(), this._portal = void 0, this._portalContent = void 0, this._panel.dispose(), this._scrollLock.release();
|
|
231
|
+
super.disconnectedCallback(), this._optionPortal.dispose(), this._trigger.dispose(), this.removeEventListener("keydown", this._onKeydown), this.removeEventListener("focusout", this._onFocusOut), document.removeEventListener("click", this._onClickOutside), this._options.forEach(this._unbindOption), this._close(), this._portal = void 0, this._portalContent = void 0, this._panel.dispose(), this._scrollLock.release();
|
|
205
232
|
}
|
|
206
233
|
firstUpdated() {
|
|
207
|
-
requestAnimationFrame(() => {
|
|
234
|
+
this._trigger.bind(), requestAnimationFrame(() => {
|
|
208
235
|
this.isConnected && this._optionPortal.scheduleRefresh();
|
|
209
236
|
});
|
|
210
237
|
}
|
|
211
238
|
willUpdate() {
|
|
212
|
-
this._refreshOptions(), this._optionPortal.ensureOptionIds(this._options), this._syncSelectedValue(), this._applyFilter(), this._syncOptionA11y(), this._syncActiveOption();
|
|
239
|
+
this._syncTriggerSlot(), this._refreshOptions(), this._optionPortal.ensureOptionIds(this._options), this._syncSelectedValue(), this._applyFilter(), this._syncOptionA11y(), this._syncActiveOption();
|
|
213
240
|
}
|
|
214
241
|
updated(e) {
|
|
215
|
-
|
|
216
|
-
t && t.value !== this._value && (t.value = this._value), (e.has("portal") || e.has("overlayContainer")) && requestAnimationFrame(() => this._reconfigureOverlay()), e.has("noScrollLock") && this._syncScrollLock(), this.toggleAttribute("focused", this._focused), this._syncOpenAttribute(), this._syncValidity(), this._syncEmptyState();
|
|
242
|
+
this._trigger.setValue(this._value), (e.has("portal") || e.has("overlayContainer")) && requestAnimationFrame(() => this._reconfigureOverlay()), e.has("noScrollLock") && this._syncScrollLock(), this.toggleAttribute("focused", this._focused), this._syncOpenAttribute(), this._syncOverlayInert(), this._syncValidity(), this._syncEmptyState();
|
|
217
243
|
}
|
|
218
244
|
formDisabledCallback(e) {
|
|
219
245
|
this._formAssociation.setDisabled(e), e && this._isOpen && this._close();
|
|
@@ -225,6 +251,9 @@ var A = class extends r(y) {
|
|
|
225
251
|
_syncOpenAttribute() {
|
|
226
252
|
this.toggleAttribute("open", this._isOpen);
|
|
227
253
|
}
|
|
254
|
+
_syncOverlayInert() {
|
|
255
|
+
this._panel.getHandle()?.setInert(this._isDisabled || this.readonly);
|
|
256
|
+
}
|
|
228
257
|
_syncSelectedValue() {
|
|
229
258
|
let e = this._value.trim().toLowerCase(), t = e ? this._options.find((t) => !t.disabled && t.label.trim().toLowerCase() === e)?.value ?? "" : "";
|
|
230
259
|
this._setSelectedValue(t);
|
|
@@ -296,6 +325,10 @@ var A = class extends r(y) {
|
|
|
296
325
|
composed: !0
|
|
297
326
|
}));
|
|
298
327
|
}
|
|
328
|
+
_isSlottedFocus(e) {
|
|
329
|
+
let t = e.target;
|
|
330
|
+
return t instanceof Node && !!this.shadowRoot && !this.shadowRoot.contains(t);
|
|
331
|
+
}
|
|
299
332
|
_open(e = !1) {
|
|
300
333
|
this._openController.open(e);
|
|
301
334
|
}
|
|
@@ -306,26 +339,26 @@ var A = class extends r(y) {
|
|
|
306
339
|
s(this, this._isOpen);
|
|
307
340
|
}
|
|
308
341
|
_openOverlay(e = !1) {
|
|
309
|
-
this._panel.open(e), this._syncEmptyState();
|
|
342
|
+
this._panel.open(e), this._syncOverlayInert(), this._syncEmptyState();
|
|
310
343
|
}
|
|
311
344
|
async _closeOverlay() {
|
|
312
345
|
await this._panel.close(() => this._isOpen) && (this._portal = void 0, this._portalContent = void 0);
|
|
313
346
|
}
|
|
314
347
|
_reconfigureOverlay() {
|
|
315
|
-
this._portal = void 0, this._portalContent = void 0, this._panel.reconfigure(this._isOpen);
|
|
348
|
+
this._portal = void 0, this._portalContent = void 0, this._panel.reconfigure(this._isOpen), this._syncOverlayInert();
|
|
316
349
|
}
|
|
317
350
|
_syncScrollLock(e = this._isOpen) {
|
|
318
351
|
this._scrollLock.sync(e && !this.noScrollLock);
|
|
319
352
|
}
|
|
320
353
|
_createPortal() {
|
|
321
|
-
let e =
|
|
354
|
+
let e = _().make({
|
|
322
355
|
container: this.overlayContainer,
|
|
323
356
|
target: this,
|
|
324
|
-
style: `${t}\n${
|
|
357
|
+
style: `${t}\n${o}\n${y}`,
|
|
325
358
|
className: "wui-glass autocomplete-overlay portal wui-floating-panel",
|
|
326
359
|
onContentChange: (e) => {
|
|
327
360
|
this._optionPortal.scheduleRefresh();
|
|
328
|
-
let t = e.flatMap((e) => [...e.removedNodes]).filter(
|
|
361
|
+
let t = e.flatMap((e) => [...e.removedNodes]).filter(A);
|
|
329
362
|
if (t.length) {
|
|
330
363
|
this._portal?.removeContent(t);
|
|
331
364
|
let e = this._portal?.panel.querySelector(".autocomplete-empty");
|
|
@@ -333,18 +366,18 @@ var A = class extends r(y) {
|
|
|
333
366
|
}
|
|
334
367
|
}
|
|
335
368
|
});
|
|
336
|
-
this._portal = e,
|
|
369
|
+
this._portal = e, g(e.panel, this, [
|
|
337
370
|
"--wui-overlay-min-width",
|
|
338
371
|
"--wui-autocomplete-max-width",
|
|
339
372
|
"--wui-autocomplete-max-height"
|
|
340
373
|
]), e.panel.setAttribute("aria-hidden", "true"), e.panel.addEventListener("pointerdown", this._handlePanelPointerDown);
|
|
374
|
+
let n = document.createElement("div");
|
|
375
|
+
n.className = "autocomplete-scroll";
|
|
341
376
|
let r = document.createElement("div");
|
|
342
|
-
r.className = "autocomplete-
|
|
377
|
+
r.className = "autocomplete-content", this._portalContent = r;
|
|
343
378
|
let i = document.createElement("div");
|
|
344
|
-
i.className = "autocomplete-
|
|
345
|
-
let
|
|
346
|
-
a.className = "autocomplete-empty", a.hidden = !0, a.dataset.wuiA11yEmpty = this._getEmptySlotText(), r.append(i), i.append(a), e.panel.append(r);
|
|
347
|
-
for (let t of Array.from(this.childNodes)) t instanceof Comment || (k(t) ? e.appendContent([t], a) : e.appendContent([t], i));
|
|
379
|
+
i.className = "autocomplete-empty", i.hidden = !0, i.dataset.wuiA11yEmpty = this._getEmptySlotText(), n.append(r), r.append(i), e.panel.append(n);
|
|
380
|
+
for (let t of Array.from(this.childNodes)) t instanceof Comment || j(t) || (A(t) ? e.appendContent([t], i) : e.appendContent([t], r));
|
|
348
381
|
return e;
|
|
349
382
|
}
|
|
350
383
|
_getLabelledbyText() {
|
|
@@ -359,36 +392,37 @@ var A = class extends r(y) {
|
|
|
359
392
|
return (this.shadowRoot?.querySelector("slot[name=\"empty\"]"))?.assignedElements().map((e) => e.textContent?.trim()).filter(Boolean).join(" ").trim() || "无匹配选项";
|
|
360
393
|
}
|
|
361
394
|
render() {
|
|
362
|
-
let e = `${this._idPrefix}-listbox`, t = `${this._idPrefix}-label`, n = this._getLabelledbyText(), r = this._options.filter((e) => !e.hasAttribute("data-filtered")), i = this._isOpen && this._activeIndex >= 0 ? this._options[this._activeIndex] : void 0, a = i ? this._getA11yOptionId(i) :
|
|
363
|
-
return
|
|
395
|
+
let e = `${this._idPrefix}-listbox`, t = `${this._idPrefix}-label`, n = this._getLabelledbyText(), r = this._options.filter((e) => !e.hasAttribute("data-filtered")), i = this._isOpen && this._activeIndex >= 0 ? this._options[this._activeIndex] : void 0, a = i ? this._getA11yOptionId(i) : S;
|
|
396
|
+
return x`
|
|
364
397
|
<div class="wui-autocomplete-inner">
|
|
365
|
-
${n ?
|
|
366
|
-
<div
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
398
|
+
${n ? x`<span class="autocomplete-a11y-only" id=${t}>${n}</span>` : S}
|
|
399
|
+
<div
|
|
400
|
+
class="autocomplete-trigger"
|
|
401
|
+
?data-custom-trigger=${this._hasTriggerSlot}
|
|
402
|
+
role="combobox"
|
|
403
|
+
aria-expanded=${this._isOpen}
|
|
404
|
+
aria-haspopup="listbox"
|
|
405
|
+
aria-autocomplete="list"
|
|
406
|
+
aria-controls=${e}
|
|
407
|
+
aria-disabled=${String(this._isDisabled)}
|
|
408
|
+
aria-readonly=${this.readonly ? "true" : S}
|
|
409
|
+
aria-label=${D(this.ariaLabel)}
|
|
410
|
+
aria-labelledby=${n ? t : S}
|
|
411
|
+
aria-activedescendant=${a}
|
|
412
|
+
tabindex="-1"
|
|
413
|
+
>
|
|
414
|
+
<slot name="trigger" @slotchange=${this._onTriggerSlotChange}></slot>
|
|
415
|
+
${this._hasTriggerSlot ? S : x`<web-ui-input
|
|
416
|
+
class="autocomplete-input"
|
|
417
|
+
.value=${this._value}
|
|
418
|
+
placeholder=${this.placeholder}
|
|
419
|
+
name=${this.name}
|
|
420
|
+
?borderless=${this.borderless}
|
|
421
|
+
?disabled=${this._isDisabled}
|
|
422
|
+
?readonly=${this.readonly}
|
|
423
|
+
?required=${this.required}
|
|
424
|
+
aria-label=${D(this.ariaLabel || n || void 0)}
|
|
425
|
+
></web-ui-input>`}
|
|
392
426
|
</div>
|
|
393
427
|
<div
|
|
394
428
|
class="autocomplete-a11y-listbox"
|
|
@@ -397,7 +431,7 @@ var A = class extends r(y) {
|
|
|
397
431
|
?hidden=${!this._isOpen}
|
|
398
432
|
aria-hidden=${String(!this._isOpen)}
|
|
399
433
|
>
|
|
400
|
-
${r.map((e) =>
|
|
434
|
+
${r.map((e) => x`<div
|
|
401
435
|
id=${this._getA11yOptionId(e)}
|
|
402
436
|
role="option"
|
|
403
437
|
aria-selected=${e.value === this._selectedValue ? "true" : "false"}
|
|
@@ -427,46 +461,46 @@ var A = class extends r(y) {
|
|
|
427
461
|
`;
|
|
428
462
|
}
|
|
429
463
|
};
|
|
430
|
-
e([
|
|
464
|
+
e([T({
|
|
431
465
|
type: String,
|
|
432
466
|
reflect: !0
|
|
433
|
-
})],
|
|
467
|
+
})], M.prototype, "placeholder", void 0), e([T({
|
|
434
468
|
type: Boolean,
|
|
435
469
|
reflect: !0
|
|
436
|
-
})],
|
|
470
|
+
})], M.prototype, "borderless", void 0), e([T({
|
|
437
471
|
type: Boolean,
|
|
438
472
|
reflect: !0
|
|
439
|
-
})],
|
|
473
|
+
})], M.prototype, "disabled", void 0), e([T({
|
|
440
474
|
type: Boolean,
|
|
441
475
|
reflect: !0
|
|
442
|
-
})],
|
|
476
|
+
})], M.prototype, "readonly", void 0), e([T({
|
|
443
477
|
type: Boolean,
|
|
444
478
|
reflect: !0
|
|
445
|
-
})],
|
|
479
|
+
})], M.prototype, "required", void 0), e([T({
|
|
446
480
|
type: Boolean,
|
|
447
481
|
reflect: !0
|
|
448
|
-
})],
|
|
482
|
+
})], M.prototype, "portal", void 0), e([T({
|
|
449
483
|
type: Boolean,
|
|
450
484
|
reflect: !0,
|
|
451
485
|
attribute: "no-scroll-lock"
|
|
452
|
-
})],
|
|
486
|
+
})], M.prototype, "noScrollLock", void 0), e([T({
|
|
453
487
|
type: Boolean,
|
|
454
488
|
reflect: !0,
|
|
455
489
|
attribute: "allow-custom-value"
|
|
456
|
-
})],
|
|
490
|
+
})], M.prototype, "allowCustomValue", void 0), e([T({ attribute: !1 })], M.prototype, "overlayContainer", void 0), e([T({
|
|
457
491
|
type: String,
|
|
458
492
|
reflect: !0
|
|
459
|
-
})],
|
|
493
|
+
})], M.prototype, "name", void 0), e([T({
|
|
460
494
|
type: String,
|
|
461
495
|
attribute: "aria-label"
|
|
462
|
-
})],
|
|
496
|
+
})], M.prototype, "ariaLabel", void 0), e([T({
|
|
463
497
|
type: String,
|
|
464
498
|
attribute: "aria-labelledby"
|
|
465
|
-
})],
|
|
499
|
+
})], M.prototype, "ariaLabelledby", void 0), e([T({
|
|
466
500
|
type: String,
|
|
467
501
|
reflect: !0
|
|
468
|
-
})],
|
|
502
|
+
})], M.prototype, "filter", null), e([E()], M.prototype, "_value", void 0), e([E()], M.prototype, "_selectedValue", void 0), e([E()], M.prototype, "_isOpen", void 0), e([E()], M.prototype, "_activeIndex", void 0), e([E()], M.prototype, "_focused", void 0), e([E()], M.prototype, "_hasTriggerSlot", void 0), M = O = e([w("web-ui-autocomplete")], M);
|
|
469
503
|
//#endregion
|
|
470
|
-
export {
|
|
504
|
+
export { M as WebUiAutocomplete };
|
|
471
505
|
|
|
472
506
|
//# sourceMappingURL=index.js.map
|