@greypan/web-ui 3.0.1 → 5.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 +495 -125
- package/README.md +504 -125
- package/dist/_virtual/{_@oxc-project_runtime@0.140.0 → _@oxc-project_runtime@0.146.0}/helpers/esm/decorate.js +1 -1
- package/dist/assets/glass.js +1 -1
- package/dist/assets/glass.js.map +1 -1
- package/dist/assets/menu-portal.js +1 -1
- package/dist/assets/menu-portal.js.map +1 -1
- package/dist/assets/overlay-motion.js +1 -1
- package/dist/assets/overlay-motion.js.map +1 -1
- package/dist/assets/toast-containers.js +1 -1
- package/dist/assets/toast-containers.js.map +1 -1
- package/dist/components/autocomplete/index.d.ts +12 -12
- package/dist/components/autocomplete/index.js +162 -111
- 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.d.ts +0 -1
- package/dist/components/avatar/index.js +8 -13
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/back-top/index.js +2 -2
- package/dist/components/back-top/index.js.map +1 -1
- package/dist/components/back-top/style.js +1 -1
- package/dist/components/back-top/style.js.map +1 -1
- package/dist/components/badge/index.d.ts +1 -0
- package/dist/components/badge/index.js +12 -14
- package/dist/components/badge/index.js.map +1 -1
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +52 -38
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/button/style.js +1 -1
- package/dist/components/button/style.js.map +1 -1
- package/dist/components/button-group/index.d.ts +1 -2
- package/dist/components/button-group/index.js +21 -23
- package/dist/components/button-group/index.js.map +1 -1
- package/dist/components/button-group/style.js +1 -1
- package/dist/components/button-group/style.js.map +1 -1
- package/dist/components/checkbox/index.d.ts +4 -7
- package/dist/components/checkbox/index.js +56 -38
- 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 +4 -10
- package/dist/components/checkbox-group/index.js +74 -60
- package/dist/components/checkbox-group/index.js.map +1 -1
- package/dist/components/collapse/index.d.ts +66 -0
- package/dist/components/collapse/index.js +159 -0
- package/dist/components/collapse/index.js.map +1 -0
- package/dist/components/collapse/style.js +6 -0
- package/dist/components/collapse/style.js.map +1 -0
- package/dist/components/context-menu/index.d.ts +29 -0
- package/dist/components/context-menu/index.js +168 -53
- 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 +34 -13
- 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 +45 -0
- package/dist/components/drawer/index.js +270 -56
- 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 +2 -0
- package/dist/components/dropdown/index.js +24 -14
- package/dist/components/dropdown/index.js.map +1 -1
- package/dist/components/dropdown-divider/index.js +1 -1
- package/dist/components/dropdown-header/index.js +1 -1
- package/dist/components/dropdown-header/style.js +1 -1
- package/dist/components/dropdown-header/style.js.map +1 -1
- package/dist/components/dropdown-item/index.js +3 -2
- package/dist/components/dropdown-item/index.js.map +1 -1
- package/dist/components/dropdown-item/style.js +1 -1
- package/dist/components/dropdown-item/style.js.map +1 -1
- package/dist/components/empty/index.d.ts +1 -0
- package/dist/components/empty/index.js +24 -22
- package/dist/components/empty/index.js.map +1 -1
- package/dist/components/empty/style.js +1 -1
- package/dist/components/empty/style.js.map +1 -1
- package/dist/components/icon/index.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +21 -20
- package/dist/components/input/index.d.ts +2 -3
- package/dist/components/input/index.js +62 -52
- package/dist/components/input/index.js.map +1 -1
- package/dist/components/input/style.js +1 -1
- package/dist/components/input/style.js.map +1 -1
- package/dist/components/input-number/index.d.ts +2 -3
- package/dist/components/input-number/index.js +58 -38
- package/dist/components/input-number/index.js.map +1 -1
- package/dist/components/input-number/style.js +1 -1
- package/dist/components/input-number/style.js.map +1 -1
- package/dist/components/layout/index.d.ts +76 -3
- package/dist/components/layout/index.js +250 -39
- 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/option/index.js +1 -1
- package/dist/components/option/style.js +1 -1
- package/dist/components/option/style.js.map +1 -1
- package/dist/components/popover/index.d.ts +2 -1
- package/dist/components/popover/index.js +14 -8
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/popover/style.js +1 -1
- package/dist/components/popover/style.js.map +1 -1
- package/dist/components/radio/index.d.ts +4 -7
- package/dist/components/radio/index.js +51 -37
- 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 +4 -10
- package/dist/components/radio-group/index.js +70 -52
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/segmented/index.d.ts +14 -12
- package/dist/components/segmented/index.js +132 -54
- 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/index.d.ts +1 -2
- package/dist/components/segmented-trigger/index.js +23 -21
- package/dist/components/segmented-trigger/index.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 +13 -8
- package/dist/components/select/index.js +114 -75
- package/dist/components/select/index.js.map +1 -1
- package/dist/components/select/style.js +1 -1
- package/dist/components/select/style.js.map +1 -1
- package/dist/components/slider/index.d.ts +6 -7
- package/dist/components/slider/index.js +99 -64
- 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/spinner/index.d.ts +0 -2
- package/dist/components/spinner/index.js +14 -13
- package/dist/components/spinner/index.js.map +1 -1
- package/dist/components/spinner/style.js +1 -1
- package/dist/components/spinner/style.js.map +1 -1
- package/dist/components/svg-draw-lines/index.js +1 -1
- package/dist/components/switch/index.d.ts +13 -6
- package/dist/components/switch/index.js +102 -41
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/style.js +1 -1
- package/dist/components/switch/style.js.map +1 -1
- package/dist/components/textarea/index.d.ts +5 -6
- package/dist/components/textarea/index.js +74 -67
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/textarea/style.js +1 -1
- package/dist/components/textarea/style.js.map +1 -1
- package/dist/components/theme/index.js +1 -1
- package/dist/components/theme/style.js +1 -1
- package/dist/components/theme/style.js.map +1 -1
- package/dist/components/toast/style.js +1 -1
- package/dist/components/toast/style.js.map +1 -1
- package/dist/components/toast/toast.js +12 -12
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/tooltip/index.js +3 -3
- package/dist/components/tooltip/index.js.map +1 -1
- package/dist/components/tooltip/style.js +1 -1
- package/dist/components/tooltip/style.js.map +1 -1
- package/dist/icons/generated/heroicons-arrow-down-16-solid.d.ts +6 -0
- package/dist/icons/generated/heroicons-arrow-up-16-solid.d.ts +6 -0
- package/dist/icons/generated/heroicons-bars-arrow-down-16-solid.d.ts +6 -0
- package/dist/icons/generated/heroicons-bars-arrow-down-16-solid.js +10 -0
- package/dist/icons/generated/heroicons-bars-arrow-down-16-solid.js.map +1 -0
- package/dist/icons/generated/heroicons-bars-arrow-up-16-solid.d.ts +6 -0
- package/dist/icons/generated/heroicons-bars-arrow-up-16-solid.js +10 -0
- package/dist/icons/generated/heroicons-bars-arrow-up-16-solid.js.map +1 -0
- package/dist/icons/generated/lucide-clapperboard.d.ts +6 -0
- package/dist/icons/generated/lucide-clapperboard.js +10 -0
- package/dist/icons/generated/lucide-clapperboard.js.map +1 -0
- package/dist/icons/generated/lucide-code.d.ts +6 -0
- package/dist/icons/generated/lucide-code.js +10 -0
- package/dist/icons/generated/lucide-code.js.map +1 -0
- package/dist/icons/generated/lucide-ellipsis-vertical.d.ts +6 -0
- package/dist/icons/generated/lucide-ellipsis-vertical.js +10 -0
- package/dist/icons/generated/lucide-ellipsis-vertical.js.map +1 -0
- package/dist/icons/generated/lucide-eye.d.ts +6 -0
- package/dist/icons/generated/lucide-eye.js +10 -0
- package/dist/icons/generated/lucide-eye.js.map +1 -0
- package/dist/icons/generated/lucide-headphones.d.ts +6 -0
- package/dist/icons/generated/lucide-headphones.js +10 -0
- package/dist/icons/generated/lucide-headphones.js.map +1 -0
- package/dist/icons/generated/lucide-link.d.ts +6 -0
- package/dist/icons/generated/lucide-link.js +10 -0
- package/dist/icons/generated/lucide-link.js.map +1 -0
- package/dist/icons/generated/lucide-list-filter.d.ts +6 -0
- package/dist/icons/generated/lucide-list-filter.js +10 -0
- package/dist/icons/generated/lucide-list-filter.js.map +1 -0
- package/dist/icons/generated/lucide-list-restart.d.ts +6 -0
- package/dist/icons/generated/lucide-list-restart.js +10 -0
- package/dist/icons/generated/lucide-list-restart.js.map +1 -0
- package/dist/icons/generated/lucide-pen-line.d.ts +6 -0
- package/dist/icons/generated/lucide-pen-line.js +10 -0
- package/dist/icons/generated/lucide-pen-line.js.map +1 -0
- package/dist/icons/generated/lucide-play.d.ts +6 -0
- package/dist/icons/generated/lucide-play.js +10 -0
- package/dist/icons/generated/lucide-play.js.map +1 -0
- package/dist/icons/generated/lucide-sliders-horizontal.d.ts +6 -0
- package/dist/icons/generated/lucide-sliders-horizontal.js +10 -0
- package/dist/icons/generated/lucide-sliders-horizontal.js.map +1 -0
- package/dist/icons/generated/lucide-tag.d.ts +6 -0
- package/dist/icons/generated/lucide-tag.js +10 -0
- package/dist/icons/generated/lucide-tag.js.map +1 -0
- package/dist/icons/generated/tabler-sort-ascending-letters.d.ts +6 -0
- package/dist/icons/generated/tabler-sort-ascending-letters.js +10 -0
- package/dist/icons/generated/tabler-sort-ascending-letters.js.map +1 -0
- package/dist/icons/index.d.ts +15 -0
- package/dist/icons/index.js +18 -3
- package/dist/node_modules/.pnpm/@floating-ui_core@1.8.0/node_modules/@floating-ui/core/dist/floating-ui.core.js +1 -3
- package/dist/node_modules/.pnpm/@floating-ui_core@1.8.0/node_modules/@floating-ui/core/dist/floating-ui.core.js.map +1 -1
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.12/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +2 -1
- package/dist/node_modules/.pnpm/@floating-ui_utils@0.2.12/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js.map +1 -1
- package/dist/shared/events/user-change.js.map +1 -1
- package/dist/shared/form-association/index.js +41 -0
- package/dist/shared/form-association/index.js.map +1 -0
- package/dist/shared/gesture/drag-gesture.js +133 -0
- package/dist/shared/gesture/drag-gesture.js.map +1 -0
- package/dist/shared/gesture/physics.js +45 -0
- package/dist/shared/gesture/physics.js.map +1 -0
- package/dist/shared/group-management/index.js +111 -0
- package/dist/shared/group-management/index.js.map +1 -0
- package/dist/shared/menu-portal/menu-portal.js +22 -10
- package/dist/shared/menu-portal/menu-portal.js.map +1 -1
- package/dist/shared/menu-portal/menu-tree.js +22 -7
- package/dist/shared/menu-portal/menu-tree.js.map +1 -1
- package/dist/shared/option-portal/index.js +65 -0
- package/dist/shared/option-portal/index.js.map +1 -0
- package/dist/shared/overlay/native-dialog-presence.js.map +1 -1
- package/dist/shared/overlay/nested-drawer-layers.js +55 -0
- package/dist/shared/overlay/nested-drawer-layers.js.map +1 -0
- package/dist/shared/overlay/overlay.js +1 -1
- package/dist/shared/overlay/overlay.js.map +1 -1
- package/dist/shared/overlay/portal.js +47 -13
- package/dist/shared/overlay/portal.js.map +1 -1
- package/dist/shared/overlay/presence.js.map +1 -1
- package/dist/shared/visible-area/index.js +69 -0
- package/dist/shared/visible-area/index.js.map +1 -0
- package/package.json +8 -4
|
@@ -1,26 +1,59 @@
|
|
|
1
|
-
import e from "../../_virtual/_@oxc-project_runtime@0.
|
|
1
|
+
import e from "../../_virtual/_@oxc-project_runtime@0.146.0/helpers/esm/decorate.js";
|
|
2
2
|
import "../option/index.js";
|
|
3
3
|
import t from "../../assets/glass.js";
|
|
4
4
|
import n from "../../assets/overlay-motion.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
5
|
+
import { FormAssociationController as r, defineFormAssociation as i } from "../../shared/form-association/index.js";
|
|
6
|
+
import { normalizeLiteral as a } from "../../shared/normalize/index.js";
|
|
7
|
+
import { defineOptionPortal as o } from "../../shared/option-portal/index.js";
|
|
8
|
+
import { defineAnchoredPanel as s } from "../../shared/overlay/anchored-panel.js";
|
|
9
|
+
import { applyOverlayVariables as c, defineOverlayPortal as l } from "../../shared/overlay/portal.js";
|
|
10
|
+
import { defineScrollLockLease as u } from "../../shared/scroll-lock/scroll-lock.js";
|
|
11
|
+
import d from "./style.js";
|
|
12
|
+
import { LitElement as f, html as p, nothing as m, unsafeCSS as h } from "lit";
|
|
13
|
+
import { customElement as g, property as _, state as v } from "lit/decorators.js";
|
|
14
|
+
import { ifDefined as y } from "lit/directives/if-defined.js";
|
|
13
15
|
//#region src/components/autocomplete/index.ts
|
|
14
|
-
var
|
|
16
|
+
var b, x = [
|
|
15
17
|
"none",
|
|
16
18
|
"prefix",
|
|
17
19
|
"contains"
|
|
18
|
-
]
|
|
20
|
+
];
|
|
21
|
+
function S(e) {
|
|
22
|
+
return e instanceof Element && e.getAttribute("slot") === "empty";
|
|
23
|
+
}
|
|
24
|
+
var C = class extends f {
|
|
19
25
|
static {
|
|
20
|
-
|
|
26
|
+
b = this;
|
|
21
27
|
}
|
|
22
28
|
constructor(...e) {
|
|
23
|
-
super(...e), this.
|
|
29
|
+
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 = i({
|
|
30
|
+
host: this,
|
|
31
|
+
initialize: () => {
|
|
32
|
+
let e = this.getAttribute("value");
|
|
33
|
+
e !== null && (this._value = e);
|
|
34
|
+
},
|
|
35
|
+
getState: () => this._value,
|
|
36
|
+
setState: (e) => {
|
|
37
|
+
this.value = e;
|
|
38
|
+
},
|
|
39
|
+
getFormValue: () => this._value,
|
|
40
|
+
getFormState: () => this._value,
|
|
41
|
+
restoreState: (e) => {
|
|
42
|
+
typeof e == "string" && (this.value = e);
|
|
43
|
+
},
|
|
44
|
+
syncValidity: () => this._syncValidity()
|
|
45
|
+
}).make(), this._formAssociationController = new r(this, this._formAssociation), this._isOpen = !1, this._activeIndex = -1, this._focused = !1, this._idPrefix = `web-ui-autocomplete-${++b._nextInstanceId}`, this._a11yOptionIds = /* @__PURE__ */ new WeakMap(), this._nextA11yOptionId = 0, this._options = [], this._scrollLock = u().make(), this._optionPortal = o().make({
|
|
46
|
+
element: this,
|
|
47
|
+
idPrefix: `${this._idPrefix}-option`,
|
|
48
|
+
getPortal: () => this._portal,
|
|
49
|
+
getPortalContent: () => this._portalContent,
|
|
50
|
+
isOpen: () => this.portal && this._isOpen,
|
|
51
|
+
getMigratableNodes: () => Array.from(this.childNodes).filter((e) => !S(e)),
|
|
52
|
+
hasUpdated: () => this.hasUpdated,
|
|
53
|
+
requestUpdate: () => this.requestUpdate(),
|
|
54
|
+
bindOption: (e) => this._bindOption(e),
|
|
55
|
+
unbindOption: (e) => this._unbindOption(e)
|
|
56
|
+
}), this._panel = s().make({
|
|
24
57
|
getAnchor: () => this.shadowRoot?.querySelector(".input-wrapper") ?? null,
|
|
25
58
|
getLocalPanel: () => this.shadowRoot?.querySelector(".autocomplete-overlay") ?? null,
|
|
26
59
|
getPositioning: () => ({
|
|
@@ -42,25 +75,21 @@ var g, _ = [
|
|
|
42
75
|
}, this._handlePanelPointerDown = (e) => {
|
|
43
76
|
e.preventDefault();
|
|
44
77
|
}, this._bindOption = (e) => {
|
|
45
|
-
e.addEventListener("click", this._handleOptionClick), e.addEventListener("pointerover", this._handleOptionPointerOver), e.addEventListener("pointerdown", this._handleOptionPointerDown), e.addEventListener("option-update", this._onOptionUpdate)
|
|
78
|
+
e.addEventListener("click", this._handleOptionClick), e.addEventListener("pointerover", this._handleOptionPointerOver), e.addEventListener("pointerdown", this._handleOptionPointerDown), e.addEventListener("option-update", this._onOptionUpdate);
|
|
46
79
|
}, this._unbindOption = (e) => {
|
|
47
|
-
e.removeEventListener("click", this._handleOptionClick), e.removeEventListener("pointerover", this._handleOptionPointerOver), e.removeEventListener("pointerdown", this._handleOptionPointerDown), e.removeEventListener("option-update", this._onOptionUpdate)
|
|
48
|
-
}, this._onOptionRegister = () => {
|
|
49
|
-
this._scheduleOptionsRefresh();
|
|
50
|
-
}, this._onOptionUnregister = (e) => {
|
|
51
|
-
e.target instanceof HTMLElement && e.target.localName === "web-ui-option" && this._pendingUnregisteredOptions.add(e.target), this._scheduleOptionsRefresh();
|
|
52
|
-
}, this._onSlotChange = () => {
|
|
53
|
-
this._scheduleOptionsRefresh();
|
|
80
|
+
e.removeEventListener("click", this._handleOptionClick), e.removeEventListener("pointerover", this._handleOptionPointerOver), e.removeEventListener("pointerdown", this._handleOptionPointerDown), e.removeEventListener("option-update", this._onOptionUpdate);
|
|
54
81
|
}, this._handleOptionClick = (e) => {
|
|
55
82
|
if (!(e.currentTarget instanceof HTMLElement)) return;
|
|
56
83
|
let t = e.currentTarget;
|
|
57
84
|
t.disabled || this._selectOption(t);
|
|
58
85
|
}, this._onOptionUpdate = () => {
|
|
59
|
-
this.
|
|
86
|
+
this._optionPortal.scheduleRefresh();
|
|
60
87
|
}, this._handleOptionPointerOver = (e) => {
|
|
61
88
|
e.pointerType !== "touch" && (!this._isOpen || !(e.currentTarget instanceof HTMLElement) || (this._activeIndex = -1, this._syncActiveOption()));
|
|
62
89
|
}, this._handleOptionPointerDown = (e) => {
|
|
63
90
|
e.preventDefault();
|
|
91
|
+
}, this._onSlotChange = () => {
|
|
92
|
+
this._optionPortal.scheduleRefresh();
|
|
64
93
|
}, this._onKeydown = (e) => {
|
|
65
94
|
if (!(this._isDisabled || this.readonly)) switch (e.key) {
|
|
66
95
|
case "Escape":
|
|
@@ -72,13 +101,20 @@ var g, _ = [
|
|
|
72
101
|
case "ArrowUp":
|
|
73
102
|
e.preventDefault(), this._isOpen ? this._navigateActive(-1) : this._open(!0);
|
|
74
103
|
break;
|
|
75
|
-
case "Enter":
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
104
|
+
case "Enter": if (this._isOpen) {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
let t = this._options[this._activeIndex];
|
|
107
|
+
if (t && !t.disabled && !t.hasAttribute("data-filtered")) {
|
|
108
|
+
this._selectOption(t);
|
|
109
|
+
return;
|
|
80
110
|
}
|
|
81
|
-
|
|
111
|
+
let n = this._findExactOption(this._value);
|
|
112
|
+
if (n) {
|
|
113
|
+
this._selectOption(n);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
this.allowCustomValue && this._value && !this._hasExactOption(this._value) && this._selectCustomValue();
|
|
117
|
+
}
|
|
82
118
|
}
|
|
83
119
|
}, this._onInput = (e) => {
|
|
84
120
|
if (this._isDisabled || this.readonly) return;
|
|
@@ -87,16 +123,18 @@ var g, _ = [
|
|
|
87
123
|
}, this._onInnerChange = (e) => {
|
|
88
124
|
e.stopPropagation();
|
|
89
125
|
}, this._onFocus = () => {
|
|
90
|
-
this._isDisabled || (this._focused = !0
|
|
126
|
+
this._isDisabled || (this._focused = !0);
|
|
127
|
+
}, this._onInputClick = () => {
|
|
128
|
+
this._isDisabled || this.readonly || this._options.length > 0 && this._open();
|
|
91
129
|
}, this._onBlur = () => {
|
|
92
130
|
this._focused = !1;
|
|
93
131
|
};
|
|
94
132
|
}
|
|
95
133
|
static {
|
|
96
134
|
this.styles = [
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
d
|
|
135
|
+
h(t),
|
|
136
|
+
h(n),
|
|
137
|
+
h(d)
|
|
100
138
|
];
|
|
101
139
|
}
|
|
102
140
|
static {
|
|
@@ -107,14 +145,14 @@ var g, _ = [
|
|
|
107
145
|
}
|
|
108
146
|
set filter(e) {
|
|
109
147
|
let t = this._filter;
|
|
110
|
-
this._filter =
|
|
148
|
+
this._filter = a(e, x, "contains"), this.requestUpdate("filter", t);
|
|
111
149
|
}
|
|
112
150
|
get value() {
|
|
113
151
|
return this._value;
|
|
114
152
|
}
|
|
115
153
|
set value(e) {
|
|
116
154
|
let t = this._value;
|
|
117
|
-
this._value = e, this.
|
|
155
|
+
this._value = e, this._formAssociation.sync(), this.requestUpdate("value", t);
|
|
118
156
|
}
|
|
119
157
|
get selectedValue() {
|
|
120
158
|
return this._selectedValue;
|
|
@@ -124,7 +162,7 @@ var g, _ = [
|
|
|
124
162
|
(t !== e || this.getAttribute("selected-value") !== e) && (this._selectedValue = e, this.setAttribute("selected-value", e), t !== e && this.requestUpdate("selectedValue", t));
|
|
125
163
|
}
|
|
126
164
|
get _isDisabled() {
|
|
127
|
-
return this.disabled || this.
|
|
165
|
+
return this.disabled || this._formAssociation.isFormDisabled();
|
|
128
166
|
}
|
|
129
167
|
static {
|
|
130
168
|
this._nextInstanceId = 0;
|
|
@@ -136,9 +174,7 @@ var g, _ = [
|
|
|
136
174
|
return this._isOpen;
|
|
137
175
|
}
|
|
138
176
|
connectedCallback() {
|
|
139
|
-
super.connectedCallback(), this.
|
|
140
|
-
let e = this.getAttribute("value");
|
|
141
|
-
e !== null && (this._value = e, this._internals?.setFormValue?.(e)), this.addEventListener("option-register", this._onOptionRegister), this.addEventListener("option-unregister", this._onOptionUnregister), this.addEventListener("keydown", this._onKeydown), this.addEventListener("focusout", this._onFocusOut), document.addEventListener("click", this._onClickOutside);
|
|
177
|
+
super.connectedCallback(), this._optionPortal.bindHost(), this.addEventListener("keydown", this._onKeydown), this.addEventListener("focusout", this._onFocusOut), document.addEventListener("click", this._onClickOutside);
|
|
142
178
|
}
|
|
143
179
|
attributeChangedCallback(e, t, n) {
|
|
144
180
|
super.attributeChangedCallback(e, t, n), e === "selected-value" && this.isConnected && n !== this._selectedValue && queueMicrotask(() => {
|
|
@@ -146,41 +182,38 @@ var g, _ = [
|
|
|
146
182
|
});
|
|
147
183
|
}
|
|
148
184
|
disconnectedCallback() {
|
|
149
|
-
super.disconnectedCallback(), this.
|
|
185
|
+
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();
|
|
150
186
|
}
|
|
151
187
|
firstUpdated() {
|
|
152
188
|
requestAnimationFrame(() => {
|
|
153
|
-
this.isConnected && this.
|
|
189
|
+
this.isConnected && this._optionPortal.scheduleRefresh();
|
|
154
190
|
});
|
|
155
191
|
}
|
|
156
|
-
_queryOptions() {
|
|
157
|
-
let e = this.portal ? this._panel.getPanel() : null, t = e ? [...e.querySelectorAll("web-ui-option")] : [];
|
|
158
|
-
return t.length > 0 ? t : [...this.querySelectorAll("web-ui-option")];
|
|
159
|
-
}
|
|
160
192
|
willUpdate() {
|
|
161
|
-
this._refreshOptions(), this.
|
|
193
|
+
this._refreshOptions(), this._optionPortal.ensureOptionIds(this._options), this._syncSelectedValue(), this._applyFilter(), this._syncOptionA11y(), this._syncActiveOption();
|
|
162
194
|
}
|
|
163
195
|
updated(e) {
|
|
164
196
|
let t = this.shadowRoot?.querySelector(".autocomplete-input");
|
|
165
197
|
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();
|
|
166
198
|
}
|
|
167
199
|
formResetCallback() {
|
|
168
|
-
this.
|
|
200
|
+
this._formAssociation.reset();
|
|
169
201
|
}
|
|
170
202
|
formDisabledCallback(e) {
|
|
171
|
-
this.
|
|
203
|
+
this._formAssociation.setDisabled(e), e && this._isOpen && this._close();
|
|
172
204
|
}
|
|
173
205
|
formStateRestoreCallback(e) {
|
|
174
|
-
|
|
206
|
+
this._formAssociation.restore(e);
|
|
175
207
|
}
|
|
176
208
|
_syncValidity() {
|
|
177
|
-
|
|
209
|
+
let e = this._formAssociation.getInternals();
|
|
210
|
+
!e || typeof e.setValidity != "function" || (this._isDisabled || this.readonly || !this.required || this._value ? e.setValidity({}) : e.setValidity({ valueMissing: !0 }, "请输入内容"));
|
|
178
211
|
}
|
|
179
212
|
_syncOpenAttribute() {
|
|
180
213
|
this.toggleAttribute("open", this._isOpen);
|
|
181
214
|
}
|
|
182
215
|
_syncSelectedValue() {
|
|
183
|
-
let e = this._value.trim().toLowerCase(), t = e ? this._options.find((t) => t.label.trim().toLowerCase() === e)?.value ?? "" : "";
|
|
216
|
+
let e = this._value.trim().toLowerCase(), t = e ? this._options.find((t) => !t.disabled && t.label.trim().toLowerCase() === e)?.value ?? "" : "";
|
|
184
217
|
this._setSelectedValue(t);
|
|
185
218
|
}
|
|
186
219
|
_syncOptionA11y() {
|
|
@@ -188,20 +221,6 @@ var g, _ = [
|
|
|
188
221
|
e.setAttribute("role", "option"), e.setAttribute("aria-selected", e.value === this._selectedValue ? "true" : "false"), e.setAttribute("aria-hidden", "true");
|
|
189
222
|
});
|
|
190
223
|
}
|
|
191
|
-
_ensureOptionIds() {
|
|
192
|
-
let e = new Set(this._options.map((e) => e.id).filter(Boolean));
|
|
193
|
-
this._options.forEach((t) => {
|
|
194
|
-
if (t.id) return;
|
|
195
|
-
let n = this._optionIds.get(t);
|
|
196
|
-
if (!n || e.has(n)) {
|
|
197
|
-
do
|
|
198
|
-
n = `${this._idPrefix}-option-${++this._nextOptionId}`;
|
|
199
|
-
while (e.has(n));
|
|
200
|
-
this._optionIds.set(t, n);
|
|
201
|
-
}
|
|
202
|
-
t.id = n, e.add(n);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
224
|
_getA11yOptionId(e) {
|
|
206
225
|
let t = this._a11yOptionIds.get(e);
|
|
207
226
|
return t || (t = `${this._idPrefix}-a11y-option-${++this._nextA11yOptionId}`, this._a11yOptionIds.set(e, t)), t;
|
|
@@ -216,28 +235,14 @@ var g, _ = [
|
|
|
216
235
|
this._activeIndex >= 0 && (!n || n.hasAttribute("data-filtered") || n.disabled) && (this._activeIndex = -1, this._syncActiveOption());
|
|
217
236
|
}
|
|
218
237
|
_syncEmptyState() {
|
|
219
|
-
let e = this._panel.getPanel();
|
|
220
|
-
|
|
221
|
-
let
|
|
222
|
-
|
|
223
|
-
let n = this._options.filter((e) => !e.hasAttribute("data-filtered"));
|
|
224
|
-
t.hidden = !(this._options.length > 0 && n.length === 0);
|
|
238
|
+
let e = this._panel.getPanel()?.querySelector(".autocomplete-empty"), t = this._options.filter((e) => !e.hasAttribute("data-filtered")), n = this._isOpen && this._options.length > 0 && t.length === 0;
|
|
239
|
+
e && (e.hidden = !n);
|
|
240
|
+
let r = (this.shadowRoot?.querySelector("slot[name=\"empty\"]"))?.assignedElements().map((e) => e.textContent?.trim()).filter(Boolean).join(" ").trim() || e?.dataset.wuiA11yEmpty || "无匹配选项", i = this.shadowRoot?.querySelector(".autocomplete-empty-a11y");
|
|
241
|
+
i && (i.textContent = r, i.hidden = !n);
|
|
225
242
|
}
|
|
226
243
|
_refreshOptions() {
|
|
227
|
-
let e = this._options[this._activeIndex], t = this.
|
|
228
|
-
this._options
|
|
229
|
-
}
|
|
230
|
-
_syncPortalContent() {
|
|
231
|
-
if (!this._portal || !this._portalContent) return;
|
|
232
|
-
for (let e of this._pendingUnregisteredOptions) !this._portalContent.contains(e) && !this.contains(e) && this._portal.removeContent([e]);
|
|
233
|
-
if (this._pendingUnregisteredOptions.clear(), !this._isOpen) return;
|
|
234
|
-
let e = Array.from(this.childNodes);
|
|
235
|
-
e.length && this._portal.appendContent(e, this._portalContent);
|
|
236
|
-
}
|
|
237
|
-
_scheduleOptionsRefresh() {
|
|
238
|
-
queueMicrotask(() => {
|
|
239
|
-
this.isConnected && (this._syncPortalContent(), this.requestUpdate());
|
|
240
|
-
});
|
|
244
|
+
let e = this._options[this._activeIndex], t = this._optionPortal.refresh(this._options, e);
|
|
245
|
+
this._options = t.options, this._activeIndex = t.activeIndex;
|
|
241
246
|
}
|
|
242
247
|
_navigateActive(e) {
|
|
243
248
|
let t = this._options.filter((e) => !e.disabled && !e.hasAttribute("data-filtered"));
|
|
@@ -261,13 +266,30 @@ var g, _ = [
|
|
|
261
266
|
composed: !0
|
|
262
267
|
})));
|
|
263
268
|
}
|
|
269
|
+
_findExactOption(e) {
|
|
270
|
+
let t = e.trim().toLowerCase();
|
|
271
|
+
if (t) return this._options.find((e) => !e.disabled && e.label.trim().toLowerCase() === t);
|
|
272
|
+
}
|
|
273
|
+
_hasExactOption(e) {
|
|
274
|
+
let t = e.trim().toLowerCase();
|
|
275
|
+
return this._options.some((e) => e.label.trim().toLowerCase() === t);
|
|
276
|
+
}
|
|
277
|
+
_selectCustomValue() {
|
|
278
|
+
this._close(), this.dispatchEvent(new Event("input", {
|
|
279
|
+
bubbles: !0,
|
|
280
|
+
composed: !0
|
|
281
|
+
})), this.dispatchEvent(new Event("change", {
|
|
282
|
+
bubbles: !0,
|
|
283
|
+
composed: !0
|
|
284
|
+
}));
|
|
285
|
+
}
|
|
264
286
|
_open(e = !1) {
|
|
265
287
|
this._isDisabled || this.readonly || this._isOpen || (this._isOpen = !0, this._dispatchOpenChange(), e ? this._setInitialActiveOption() : this._syncActiveOption(), this._syncScrollLock(), this.portal ? requestAnimationFrame(() => {
|
|
266
288
|
this._isOpen && this._openOverlay(e);
|
|
267
289
|
}) : this._openOverlay(e));
|
|
268
290
|
}
|
|
269
291
|
_close() {
|
|
270
|
-
this._isOpen && (this.
|
|
292
|
+
this._isOpen && (this._optionPortal.syncPortalContent(), this._isOpen = !1, this._dispatchOpenChange(), this._activeIndex = -1, this._options.forEach((e) => e.removeAttribute("active")), this._syncScrollLock(!1), this._closeOverlay());
|
|
271
293
|
}
|
|
272
294
|
_dispatchOpenChange() {
|
|
273
295
|
this.dispatchEvent(new CustomEvent("open-change", {
|
|
@@ -289,19 +311,34 @@ var g, _ = [
|
|
|
289
311
|
this._scrollLock.sync(e && !this.noScrollLock);
|
|
290
312
|
}
|
|
291
313
|
_createPortal() {
|
|
292
|
-
let e =
|
|
314
|
+
let e = l().make({
|
|
293
315
|
container: this.overlayContainer,
|
|
294
316
|
target: this,
|
|
295
|
-
style: `${t}\n${n}\n${
|
|
296
|
-
className: "wui-glass autocomplete-overlay portal wui-floating-panel"
|
|
317
|
+
style: `${t}\n${n}\n${d}`,
|
|
318
|
+
className: "wui-glass autocomplete-overlay portal wui-floating-panel",
|
|
319
|
+
onContentChange: (e) => {
|
|
320
|
+
this._optionPortal.scheduleRefresh();
|
|
321
|
+
let t = e.flatMap((e) => [...e.removedNodes]).filter(S);
|
|
322
|
+
if (t.length) {
|
|
323
|
+
this._portal?.removeContent(t);
|
|
324
|
+
let e = this._portal?.panel.querySelector(".autocomplete-empty");
|
|
325
|
+
e && (e.textContent = "无匹配选项", e.dataset.wuiA11yEmpty = "无匹配选项");
|
|
326
|
+
}
|
|
327
|
+
}
|
|
297
328
|
});
|
|
298
|
-
this._portal = e, e.panel
|
|
329
|
+
this._portal = e, c(e.panel, this, [
|
|
330
|
+
"--wui-overlay-min-width",
|
|
331
|
+
"--wui-autocomplete-max-width",
|
|
332
|
+
"--wui-autocomplete-max-height"
|
|
333
|
+
]), e.panel.setAttribute("aria-hidden", "true"), e.panel.addEventListener("pointerdown", this._handlePanelPointerDown);
|
|
299
334
|
let r = document.createElement("div");
|
|
300
335
|
r.className = "autocomplete-scroll";
|
|
301
336
|
let i = document.createElement("div");
|
|
302
337
|
i.className = "autocomplete-content", this._portalContent = i;
|
|
303
|
-
let
|
|
304
|
-
|
|
338
|
+
let a = document.createElement("div");
|
|
339
|
+
a.className = "autocomplete-empty", a.hidden = !0, a.dataset.wuiA11yEmpty = this._getEmptySlotText(), r.append(i), i.append(a), e.panel.append(r);
|
|
340
|
+
for (let t of Array.from(this.childNodes)) S(t) ? e.appendContent([t], a) : e.appendContent([t], i);
|
|
341
|
+
return e;
|
|
305
342
|
}
|
|
306
343
|
_getLabelledbyText() {
|
|
307
344
|
if (!this.ariaLabelledby) return "";
|
|
@@ -311,11 +348,14 @@ var g, _ = [
|
|
|
311
348
|
return e.querySelector(`#${n}`)?.textContent?.trim() ?? "";
|
|
312
349
|
}).filter(Boolean).join(" ") : "";
|
|
313
350
|
}
|
|
351
|
+
_getEmptySlotText() {
|
|
352
|
+
return (this.shadowRoot?.querySelector("slot[name=\"empty\"]"))?.assignedElements().map((e) => e.textContent?.trim()).filter(Boolean).join(" ").trim() || "无匹配选项";
|
|
353
|
+
}
|
|
314
354
|
render() {
|
|
315
|
-
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) :
|
|
316
|
-
return
|
|
355
|
+
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) : m;
|
|
356
|
+
return p`
|
|
317
357
|
<div class="wui-autocomplete-inner">
|
|
318
|
-
${n ?
|
|
358
|
+
${n ? p`<span class="autocomplete-a11y-only" id=${t}>${n}</span>` : m}
|
|
319
359
|
<div class="wui-glass input-wrapper">
|
|
320
360
|
<input
|
|
321
361
|
class="autocomplete-input"
|
|
@@ -323,8 +363,8 @@ var g, _ = [
|
|
|
323
363
|
placeholder=${this.placeholder}
|
|
324
364
|
name=${this.name}
|
|
325
365
|
.value=${this._value}
|
|
326
|
-
aria-label=${
|
|
327
|
-
aria-labelledby=${n ? t :
|
|
366
|
+
aria-label=${y(this.ariaLabel)}
|
|
367
|
+
aria-labelledby=${n ? t : m}
|
|
328
368
|
?disabled=${this._isDisabled}
|
|
329
369
|
?readonly=${this.readonly}
|
|
330
370
|
?required=${this.required}
|
|
@@ -334,10 +374,11 @@ var g, _ = [
|
|
|
334
374
|
aria-autocomplete="list"
|
|
335
375
|
aria-controls=${e}
|
|
336
376
|
aria-disabled=${String(this._isDisabled)}
|
|
337
|
-
aria-readonly=${this.readonly ? "true" :
|
|
377
|
+
aria-readonly=${this.readonly ? "true" : m}
|
|
338
378
|
aria-activedescendant=${a}
|
|
339
379
|
@input=${this._onInput}
|
|
340
380
|
@change=${this._onInnerChange}
|
|
381
|
+
@click=${this._onInputClick}
|
|
341
382
|
@focus=${this._onFocus}
|
|
342
383
|
@blur=${this._onBlur}
|
|
343
384
|
/>
|
|
@@ -349,7 +390,7 @@ var g, _ = [
|
|
|
349
390
|
?hidden=${!this._isOpen}
|
|
350
391
|
aria-hidden=${String(!this._isOpen)}
|
|
351
392
|
>
|
|
352
|
-
${r.map((e) =>
|
|
393
|
+
${r.map((e) => p`<div
|
|
353
394
|
id=${this._getA11yOptionId(e)}
|
|
354
395
|
role="option"
|
|
355
396
|
aria-selected=${e.value === this._selectedValue ? "true" : "false"}
|
|
@@ -359,6 +400,7 @@ var g, _ = [
|
|
|
359
400
|
${e.label}
|
|
360
401
|
</div>`)}
|
|
361
402
|
</div>
|
|
403
|
+
<div class="autocomplete-a11y-only autocomplete-empty-a11y" role="status" hidden></div>
|
|
362
404
|
<div
|
|
363
405
|
class="wui-glass autocomplete-overlay wui-floating-panel"
|
|
364
406
|
hidden
|
|
@@ -368,7 +410,9 @@ var g, _ = [
|
|
|
368
410
|
<div class="autocomplete-scroll">
|
|
369
411
|
<div class="autocomplete-content">
|
|
370
412
|
<slot @slotchange=${this._onSlotChange}></slot>
|
|
371
|
-
<div class="autocomplete-empty" hidden
|
|
413
|
+
<div class="autocomplete-empty" hidden>
|
|
414
|
+
<slot name="empty">无匹配选项</slot>
|
|
415
|
+
</div>
|
|
372
416
|
</div>
|
|
373
417
|
</div>
|
|
374
418
|
</div>
|
|
@@ -376,39 +420,46 @@ var g, _ = [
|
|
|
376
420
|
`;
|
|
377
421
|
}
|
|
378
422
|
};
|
|
379
|
-
e([
|
|
423
|
+
e([_({
|
|
380
424
|
type: String,
|
|
381
425
|
reflect: !0
|
|
382
|
-
})],
|
|
426
|
+
})], C.prototype, "placeholder", void 0), e([_({
|
|
427
|
+
type: Boolean,
|
|
428
|
+
reflect: !0
|
|
429
|
+
})], C.prototype, "borderless", void 0), e([_({
|
|
383
430
|
type: Boolean,
|
|
384
431
|
reflect: !0
|
|
385
|
-
})],
|
|
432
|
+
})], C.prototype, "disabled", void 0), e([_({
|
|
386
433
|
type: Boolean,
|
|
387
434
|
reflect: !0
|
|
388
|
-
})],
|
|
435
|
+
})], C.prototype, "readonly", void 0), e([_({
|
|
389
436
|
type: Boolean,
|
|
390
437
|
reflect: !0
|
|
391
|
-
})],
|
|
438
|
+
})], C.prototype, "required", void 0), e([_({
|
|
392
439
|
type: Boolean,
|
|
393
440
|
reflect: !0
|
|
394
|
-
})],
|
|
441
|
+
})], C.prototype, "portal", void 0), e([_({
|
|
395
442
|
type: Boolean,
|
|
396
443
|
reflect: !0,
|
|
397
444
|
attribute: "no-scroll-lock"
|
|
398
|
-
})],
|
|
445
|
+
})], C.prototype, "noScrollLock", void 0), e([_({
|
|
446
|
+
type: Boolean,
|
|
447
|
+
reflect: !0,
|
|
448
|
+
attribute: "allow-custom-value"
|
|
449
|
+
})], C.prototype, "allowCustomValue", void 0), e([_({ attribute: !1 })], C.prototype, "overlayContainer", void 0), e([_({
|
|
399
450
|
type: String,
|
|
400
451
|
reflect: !0
|
|
401
|
-
})],
|
|
452
|
+
})], C.prototype, "name", void 0), e([_({
|
|
402
453
|
type: String,
|
|
403
454
|
attribute: "aria-label"
|
|
404
|
-
})],
|
|
455
|
+
})], C.prototype, "ariaLabel", void 0), e([_({
|
|
405
456
|
type: String,
|
|
406
457
|
attribute: "aria-labelledby"
|
|
407
|
-
})],
|
|
458
|
+
})], C.prototype, "ariaLabelledby", void 0), e([_({
|
|
408
459
|
type: String,
|
|
409
460
|
reflect: !0
|
|
410
|
-
})],
|
|
461
|
+
})], C.prototype, "filter", null), e([v()], C.prototype, "_value", void 0), e([v()], C.prototype, "_selectedValue", void 0), e([v()], C.prototype, "_isOpen", void 0), e([v()], C.prototype, "_activeIndex", void 0), e([v()], C.prototype, "_focused", void 0), C = b = e([g("web-ui-autocomplete")], C);
|
|
411
462
|
//#endregion
|
|
412
|
-
export {
|
|
463
|
+
export { C as WebUiAutocomplete };
|
|
413
464
|
|
|
414
465
|
//# sourceMappingURL=index.js.map
|