@webority/ui-elements 0.37.0 → 0.38.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/WuiAutocomplete-Comrnbmf.js +13 -0
- package/dist/WuiCommandPalette-CKna1GlO.js +2 -0
- package/dist/WuiConsentBanner-CFll7vxN.js +201 -0
- package/dist/WuiContextMenu-CBy0O4HT.js +1 -0
- package/dist/WuiCountrySelect-oLBUHvMM.js +1 -0
- package/dist/WuiDatePicker-nB1B3eWW.js +31 -0
- package/dist/WuiDateRange-Di5YE9mg.js +25 -0
- package/dist/WuiDock-BD2HgMmP.js +1 -0
- package/dist/WuiImageCrop-Cr3D2iPo.js +17 -0
- package/dist/WuiMultiSelect-BUw-7apM.js +25 -0
- package/dist/WuiOtp-BbO_75RB.js +14 -0
- package/dist/WuiPhone-GJglNelp.js +15 -0
- package/dist/WuiSelect-DvtN4qC2.js +14 -0
- package/dist/WuiSlider-Br6V2amU.js +49 -0
- package/dist/WuiSortable-Bd7Fz5Ox.js +1 -0
- package/dist/WuiTagInput-DzEZooIn.js +6 -0
- package/dist/WuiTimePicker-Bolpp93P.js +9 -0
- package/dist/WuiTour-DiKZEWeb.js +15 -0
- package/dist/WuiTree-SA0QU9AF.js +1 -0
- package/dist/WuiWizardStep-DIHxrXn9.js +1 -0
- package/dist/anchorOverlay-WcDeH46q.js +1 -0
- package/dist/calendarMath-BC2wGCD-.js +1 -0
- package/dist/countries-CvmZ2xpG.js +1 -0
- package/dist/elementBase-BlsR4tqa.js +1 -0
- package/dist/elements/autocomplete.js +1 -6
- package/dist/elements/command-palette.js +1 -6
- package/dist/elements/consent-banner.js +1 -6
- package/dist/elements/context-menu.js +1 -6
- package/dist/elements/country-select.js +1 -6
- package/dist/elements/date-range.js +1 -6
- package/dist/elements/datepicker.js +1 -6
- package/dist/elements/dock.js +1 -6
- package/dist/elements/image-crop.js +1 -6
- package/dist/elements/kanban.js +1 -6
- package/dist/elements/multiselect.js +1 -6
- package/dist/elements/otp.js +1 -6
- package/dist/elements/phone.js +1 -6
- package/dist/elements/select.js +1 -6
- package/dist/elements/slider.js +1 -6
- package/dist/elements/sortable.js +1 -6
- package/dist/elements/status-icon.js +1 -6
- package/dist/elements/taginput.js +1 -6
- package/dist/elements/timepicker.js +1 -6
- package/dist/elements/tour.js +1 -6
- package/dist/elements/tree.js +1 -6
- package/dist/elements/wizard.js +1 -5
- package/dist/examples.mobile.json-GS1_MGh9.js +1 -0
- package/dist/fileViewerImage-Y9QBn2Rj.js +6 -0
- package/dist/fileViewerMedia-CaJaVnjE.js +1 -0
- package/dist/fileViewerPdf-BN0zuehw.js +19 -0
- package/dist/fileViewerUi-DasgDsU-.js +1 -0
- package/dist/focusOrigin-2imUSs-u.js +1 -0
- package/dist/formMirror-BgY7zkC3.js +1 -0
- package/dist/formatters-BAE__8ye.js +1 -0
- package/dist/helpers.js +1 -5
- package/dist/iconGlyphs.g-CUm_mfze.js +1 -0
- package/dist/kanban-CdELdS3U.js +1 -0
- package/dist/listboxKeyNav-DMIvs9d6.js +1 -0
- package/dist/max-CNrKnpEj.js +17 -0
- package/dist/optionLabel-DsX2fhWs.js +1 -0
- package/dist/statusIcons-2X4iGkKL.js +10 -0
- package/dist/textMatch-wdY7XLIc.js +1 -0
- package/dist/themeTransition-lkmQm8FR.js +1 -0
- package/dist/tokenCommit-BKckxgtg.js +2 -0
- package/dist/ui-calendar.global.js +1 -1
- package/dist/ui-calendar.js +1 -9905
- package/dist/ui-chart.js +21 -34563
- package/dist/ui-chat-core.js +10 -347
- package/dist/ui-chat.js +10 -1066
- package/dist/ui-elements.global.js +52 -53
- package/dist/ui-elements.js +1 -692
- package/dist/ui-file-viewer.js +1 -311
- package/dist/ui-rich-text.js +193 -16887
- package/dist/wuiHttp-BC8co934.js +1 -0
- package/package.json +5 -7
- package/dist/WuiAutocomplete-ByxnwJNQ.js +0 -283
- package/dist/WuiCommandPalette-CtZ04JxZ.js +0 -130
- package/dist/WuiConsentBanner-oVe-jxCO.js +0 -399
- package/dist/WuiContextMenu-Bx_U2X3t.js +0 -211
- package/dist/WuiCountrySelect-CUAwKnL9.js +0 -28
- package/dist/WuiDatePicker-DkNbc-z7.js +0 -325
- package/dist/WuiDateRange-BocnVO6L.js +0 -233
- package/dist/WuiDock-BSDY9g8Q.js +0 -57
- package/dist/WuiImageCrop-1yaAONTk.js +0 -462
- package/dist/WuiMultiSelect-BrCGRNCt.js +0 -416
- package/dist/WuiOtp-D8-4Pqil.js +0 -128
- package/dist/WuiPhone-BvbhiP2r.js +0 -731
- package/dist/WuiSelect-BXrpiuXG.js +0 -214
- package/dist/WuiSlider-BcU0psYf.js +0 -256
- package/dist/WuiSortable-JjJqstSU.js +0 -280
- package/dist/WuiTagInput-D1ay3OcL.js +0 -158
- package/dist/WuiTimePicker-C7n-VFGt.js +0 -370
- package/dist/WuiTour-R5O9l--J.js +0 -205
- package/dist/WuiTree-DXP7pGeI.js +0 -393
- package/dist/WuiWizardStep-BU5w9_Ds.js +0 -221
- package/dist/anchorOverlay-DluGZ8ef.js +0 -23
- package/dist/calendarMath-BAF2Jkg_.js +0 -42
- package/dist/countries-B-M_LTgS.js +0 -1234
- package/dist/elementBase-Bg1xpvup.js +0 -9
- package/dist/examples.mobile.json-BMXTGiGC.js +0 -250
- package/dist/fileViewerImage-Dky4nQZS.js +0 -185
- package/dist/fileViewerMedia-DPk_YcvC.js +0 -133
- package/dist/fileViewerPdf-BnIsj-J-.js +0 -15799
- package/dist/fileViewerUi-R6hlcShk.js +0 -272
- package/dist/formMirror-jGf5M4gk.js +0 -29
- package/dist/formatters-DusKbTyV.js +0 -138
- package/dist/iconGlyphs.g-Cpg1BUHm.js +0 -215
- package/dist/kanban-BIiEMkTK.js +0 -985
- package/dist/listboxKeyNav-zts_8d5e.js +0 -36
- package/dist/max-BDKx469G.js +0 -14478
- package/dist/optionLabel-Dn-I7zyp.js +0 -16
- package/dist/statusIcons-C3zjycpa.js +0 -37
- package/dist/textMatch-DEUjlkdy.js +0 -27
- package/dist/themeTransition-BpCuMnjk.js +0 -589
- package/dist/tokenCommit-VWz-2jEf.js +0 -20
- package/dist/wuiHttp-oeHs7X_c.js +0 -118
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=`wui-csrf`,t=`RequestVerificationToken`,n=Object.freeze({fragment:`X-Wui-Fragment`,message:`X-Wui-Message`,redirect:`X-Wui-Redirect`,result:`X-Wui-Result`,keepOpen:`X-Wui-Keep-Open`,toastVariant:`X-Wui-Toast-Variant`}),r=Object.freeze([`ok`,`validation`,`forbidden`,`client`,`server`,`network`,`aborted`,`stale`,`session`]),i=new Set([`GET`,`HEAD`]);function a(t=document){let n=t.querySelector(`meta[name="${e}"]`),r=n?.getAttribute(`content`);return r?{header:n.getAttribute(`data-header`)||`RequestVerificationToken`,token:r}:null}var o=e=>{try{return new URL(e,window.location.href).origin===window.location.origin}catch{return!1}};function s(e){return e>=200&&e<300?`ok`:e===401?`session`:e===403?`forbidden`:e===422?`validation`:e>=400&&e<500?`client`:`server`}var c=e=>e?.name===`AbortError`;async function l(e,t={}){let r=(t.method||`GET`).toUpperCase(),l=t.navigate||(e=>window.location.assign(e)),u={Accept:`text/html`,"X-Requested-With":`XMLHttpRequest`,"X-Wui-Request":`1`,...t.headers};if(!i.has(r)&&o(e)){let e=a();e&&(u[e.header]=e.token)}let d=e=>{if(e==null)return null;try{return decodeURIComponent(e)}catch{return e}},f=(e,t=null,r=``)=>{let i=e=>t?.headers.get(e)??null;return{kind:e,ok:e===`ok`,status:t?.status??0,html:r,response:t,message:d(i(n.message)),redirect:i(n.redirect),result:i(n.result),keepOpen:i(n.keepOpen)===`1`,toastVariant:i(n.toastVariant),fragment:i(n.fragment)===`1`}},p;try{p=await fetch(e,{method:r,body:t.body,headers:u,signal:t.signal,credentials:`same-origin`})}catch(e){return f(c(e)||t.signal?.aborted?`aborted`:`network`)}let m=s(p.status);if(m===`ok`&&p.redirected&&p.headers.get(n.fragment)!==`1`&&(m=`session`),m===`session`)return l(p.status===401?p.headers.get(`Location`)||window.location.href:p.url),f(m,p);let h=``;if(m===`ok`||m===`validation`)try{h=await p.text()}catch(e){return f(c(e)||t.signal?.aborted?`aborted`:`network`,p)}return f(m,p,h)}function u(){let e=null,t=0;return{async run(n,r={}){e?.abort();let i=new AbortController;e=i;let a=++t,o=r.signal;o&&(o.aborted?i.abort():o.addEventListener(`abort`,()=>i.abort(),{once:!0}));let s=await l(n,{...r,signal:i.signal});return e===i&&(e=null),a!==t&&s.kind!==`aborted`?{...s,kind:`stale`,ok:!1}:s},abort(){e?.abort(),e=null}}}export{s as a,l as c,n as i,t as n,u as o,r,a as s,e as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/ui-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.38.0",
|
|
4
4
|
"description": "Webority framework-agnostic UI custom elements (<wui-*>) — the single implementation of the interactive components, styled by @webority/theme. Used natively in Razor and wrapped by @webority/ui-react.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -8,14 +8,12 @@
|
|
|
8
8
|
"access": "public",
|
|
9
9
|
"registry": "https://registry.npmjs.org/"
|
|
10
10
|
},
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/Webority/webority-ui.git",
|
|
14
|
-
"directory": "packages/elements"
|
|
15
|
-
},
|
|
16
11
|
"files": [
|
|
17
12
|
"dist",
|
|
18
|
-
"THIRD-PARTY-NOTICES.txt"
|
|
13
|
+
"THIRD-PARTY-NOTICES.txt",
|
|
14
|
+
"!dist/**/__tests__",
|
|
15
|
+
"!dist/**/*.test.*",
|
|
16
|
+
"!dist/**/*.map"
|
|
19
17
|
],
|
|
20
18
|
"main": "./dist/ui-elements.js",
|
|
21
19
|
"module": "./dist/ui-elements.js",
|
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./elementBase-Bg1xpvup.js";
|
|
2
|
-
import { n as t, r as n, t as r } from "./anchorOverlay-DluGZ8ef.js";
|
|
3
|
-
import { t as i } from "./formMirror-jGf5M4gk.js";
|
|
4
|
-
import { t as a } from "./iconGlyphs.g-Cpg1BUHm.js";
|
|
5
|
-
import { n as o, t as s } from "./listboxKeyNav-zts_8d5e.js";
|
|
6
|
-
import { n as c, r as l, t as u } from "./optionLabel-Dn-I7zyp.js";
|
|
7
|
-
//#region src/WuiAutocomplete.js
|
|
8
|
-
var d = class extends e {
|
|
9
|
-
static formAssociated = !0;
|
|
10
|
-
_accessibleName() {
|
|
11
|
-
return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
|
|
12
|
-
}
|
|
13
|
-
static get observedAttributes() {
|
|
14
|
-
return [
|
|
15
|
-
"value",
|
|
16
|
-
"placeholder",
|
|
17
|
-
"disabled",
|
|
18
|
-
"min-chars",
|
|
19
|
-
"debounce",
|
|
20
|
-
"remote",
|
|
21
|
-
"size",
|
|
22
|
-
"aria-label",
|
|
23
|
-
"allow-custom",
|
|
24
|
-
"aria-invalid"
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
constructor() {
|
|
28
|
-
super(), this._value = "", this._label = "", this._optionsProp = null, this._loading = !1, this._active = -1, this._timer = null, this._reqSeq = 0, this._pendingSearch = null, this._typeahead = "", this._typeaheadTimer = null;
|
|
29
|
-
try {
|
|
30
|
-
this._internals = this.attachInternals();
|
|
31
|
-
} catch {
|
|
32
|
-
this._internals = null;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
connectedCallback() {
|
|
36
|
-
if (!this._rendered) {
|
|
37
|
-
this._defaultCaptured ||= (this._defaultValue = this._value, !0), this.render();
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (this._bindGlobal?.(), this._pendingSearch) {
|
|
41
|
-
let { query: e, seq: t } = this._pendingSearch;
|
|
42
|
-
clearTimeout(this._timer), this._timer = setTimeout(() => this._fireSearch(e, t), this._debounceMs);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
formResetCallback() {
|
|
46
|
-
this.value = this._defaultValue || "";
|
|
47
|
-
}
|
|
48
|
-
attributeChangedCallback(e, t, n) {
|
|
49
|
-
if (e === "value") {
|
|
50
|
-
this.value = n;
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (e === "aria-invalid") {
|
|
54
|
-
this._syncInvalid();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
this._rendered && this.render();
|
|
58
|
-
}
|
|
59
|
-
_syncInvalid() {
|
|
60
|
-
let e = this.querySelector(".search-select-control");
|
|
61
|
-
e && (this.hasAttribute("aria-invalid") ? e.setAttribute("aria-invalid", "true") : e.removeAttribute("aria-invalid"));
|
|
62
|
-
}
|
|
63
|
-
get value() {
|
|
64
|
-
return this._value;
|
|
65
|
-
}
|
|
66
|
-
set value(e) {
|
|
67
|
-
this._value = e == null ? "" : String(e), i(this, this._value);
|
|
68
|
-
let t = this._readOptions().find((e) => String(e.value) === this._value);
|
|
69
|
-
this._label = t ? p(t.label) : "", this._syncInput(), this._renderOptions("");
|
|
70
|
-
}
|
|
71
|
-
set options(e) {
|
|
72
|
-
this._optionsProp = Array.isArray(e) ? e : [];
|
|
73
|
-
let t = this._readOptions().find((e) => String(e.value) === this._value);
|
|
74
|
-
t && (this._label = p(t.label)), this._renderOptions(), this._syncInput();
|
|
75
|
-
}
|
|
76
|
-
get options() {
|
|
77
|
-
return this._readOptions();
|
|
78
|
-
}
|
|
79
|
-
set loading(e) {
|
|
80
|
-
this._loading = !!e, this._renderLoading(), this._renderOptions();
|
|
81
|
-
}
|
|
82
|
-
get loading() {
|
|
83
|
-
return this._loading;
|
|
84
|
-
}
|
|
85
|
-
get _remote() {
|
|
86
|
-
return this.hasAttribute("remote");
|
|
87
|
-
}
|
|
88
|
-
get _allowCustom() {
|
|
89
|
-
return this.hasAttribute("allow-custom");
|
|
90
|
-
}
|
|
91
|
-
_matchesKnownOption(e) {
|
|
92
|
-
let t = e.toLowerCase();
|
|
93
|
-
return this._readOptions().some((e) => p(e.label).toLowerCase() === t || String(e.value ?? "").toLowerCase() === t);
|
|
94
|
-
}
|
|
95
|
-
get _minChars() {
|
|
96
|
-
return Math.max(0, Number(this.getAttribute("min-chars")) || +!!this._remote);
|
|
97
|
-
}
|
|
98
|
-
get _debounceMs() {
|
|
99
|
-
let e = this.getAttribute("debounce");
|
|
100
|
-
if (e == null || e === "") return 250;
|
|
101
|
-
let t = Number(e);
|
|
102
|
-
return Number.isFinite(t) && t >= 0 ? t : 250;
|
|
103
|
-
}
|
|
104
|
-
_snapshotDeclared() {
|
|
105
|
-
if (this._declared) return;
|
|
106
|
-
let e = [...this.querySelectorAll(":scope > wui-option")];
|
|
107
|
-
e.length && (this._declared = e.map((e) => ({
|
|
108
|
-
value: e.getAttribute("value") ?? e.textContent.trim(),
|
|
109
|
-
label: e.innerHTML,
|
|
110
|
-
icon: e.getAttribute("icon") || void 0,
|
|
111
|
-
[u]: !0,
|
|
112
|
-
selected: e.hasAttribute("selected")
|
|
113
|
-
})));
|
|
114
|
-
}
|
|
115
|
-
_readOptions() {
|
|
116
|
-
return this._optionsProp ? this._optionsProp : (this._snapshotDeclared(), this._declared || []);
|
|
117
|
-
}
|
|
118
|
-
render() {
|
|
119
|
-
this._snapshotDeclared();
|
|
120
|
-
let e = this.getAttribute("placeholder") || "Search…", t = this.getAttribute("size"), n = t === "sm" ? " search-select-sm" : t === "lg" ? " search-select-lg" : "";
|
|
121
|
-
this.id ||= `wui-autocomplete-${Math.random().toString(36).slice(2, 9)}`;
|
|
122
|
-
let r = `${this.id}-listbox`;
|
|
123
|
-
this._listboxId = r, this.innerHTML = `
|
|
124
|
-
<div class="search-select${n}">
|
|
125
|
-
<div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${f(r)}" aria-label="${f(this._accessibleName())}"${this.hasAttribute("aria-invalid") ? " aria-invalid=\"true\"" : ""}>
|
|
126
|
-
<input class="search-select-input search-select-ac-input" placeholder="${f(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute("disabled") ? " disabled" : ""} />
|
|
127
|
-
<span class="search-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
|
|
128
|
-
<button type="button" class="search-select-clear" aria-label="Clear" hidden>${a("x")}</button>
|
|
129
|
-
</div>
|
|
130
|
-
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${f(r)}" tabindex="-1" hidden>
|
|
131
|
-
<div class="search-select-options"></div>
|
|
132
|
-
<div class="search-select-empty" hidden>No matches</div>
|
|
133
|
-
<div class="search-select-hint" hidden>Type to search…</div>
|
|
134
|
-
</div>
|
|
135
|
-
</div>`, this._rendered = !0, i(this, this._value), this._wire(), this._syncInput(), this._renderOptions();
|
|
136
|
-
}
|
|
137
|
-
_refs() {
|
|
138
|
-
return {
|
|
139
|
-
control: this.querySelector(".search-select-control"),
|
|
140
|
-
input: this.querySelector(".search-select-ac-input"),
|
|
141
|
-
menu: this.querySelector(".search-select-menu"),
|
|
142
|
-
spinner: this.querySelector(".search-select-spinner"),
|
|
143
|
-
clear: this.querySelector(".search-select-clear"),
|
|
144
|
-
optionsWrap: this.querySelector(".search-select-options"),
|
|
145
|
-
empty: this.querySelector(".search-select-empty"),
|
|
146
|
-
hint: this.querySelector(".search-select-hint")
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
_optionEls() {
|
|
150
|
-
return [...this.querySelectorAll(".search-select-option")];
|
|
151
|
-
}
|
|
152
|
-
_syncInput() {
|
|
153
|
-
let { input: e, clear: t } = this._refs();
|
|
154
|
-
e && document.activeElement !== e && (e.value = this._label), t && (t.hidden = !this._value && !e?.value);
|
|
155
|
-
}
|
|
156
|
-
_renderLoading() {
|
|
157
|
-
let { spinner: e } = this._refs();
|
|
158
|
-
e && (e.hidden = !this._loading);
|
|
159
|
-
}
|
|
160
|
-
_renderOptions(e) {
|
|
161
|
-
let t = this._refs();
|
|
162
|
-
if (!t.optionsWrap) return;
|
|
163
|
-
let n = e ?? (t.input ? t.input.value : ""), r = n.trim().toLowerCase(), i = this._readOptions();
|
|
164
|
-
!this._remote && r && (i = i.filter((e) => p(e.label).toLowerCase().includes(r)));
|
|
165
|
-
let a = n.trim(), o = this._allowCustom && a && !this._matchesKnownOption(a) ? [...i, {
|
|
166
|
-
value: a,
|
|
167
|
-
custom: !0
|
|
168
|
-
}] : i, s = this._listboxId || `${this.id || "wui-autocomplete"}-listbox`;
|
|
169
|
-
t.optionsWrap.innerHTML = o.map((e, t) => {
|
|
170
|
-
let n = `${s}-opt-${t}`;
|
|
171
|
-
if (e.custom) {
|
|
172
|
-
let t = `Add “${c(e.value)}”`;
|
|
173
|
-
return `<button type="button" role="option" id="${f(n)}" class="search-select-option search-select-option-custom" data-value="${f(e.value)}" data-custom="true" aria-selected="false">${t}</button>`;
|
|
174
|
-
}
|
|
175
|
-
let r = String(e.value) === String(this._value);
|
|
176
|
-
return `<button type="button" role="option" id="${f(n)}" class="search-select-option${r ? " selected" : ""}" data-value="${f(e.value)}" aria-selected="${r}">${l(e)}</button>`;
|
|
177
|
-
}).join(""), this._active = -1, t.control?.removeAttribute("aria-activedescendant");
|
|
178
|
-
let u = r.length < this._minChars;
|
|
179
|
-
t.hint && (t.hint.hidden = !(this._remote && u && !i.length)), t.empty && (t.empty.hidden = this._loading || o.length > 0 || this._remote && u), this._reanchor?.();
|
|
180
|
-
}
|
|
181
|
-
_wire() {
|
|
182
|
-
this._teardown();
|
|
183
|
-
let e = this._refs();
|
|
184
|
-
if (!e.control || !e.input) return;
|
|
185
|
-
let a = () => r(e.control, e.menu, { matchWidth: !0 }), c = () => this._optionEls().filter((e) => !e.hidden), l = (t, { reveal: n = !0 } = {}) => {
|
|
186
|
-
let r = c();
|
|
187
|
-
this._active = t, o(e.optionsWrap, t >= 0 && r[t] || null), t >= 0 && r[t] ? (n && r[t].scrollIntoView({ block: "nearest" }), e.control.setAttribute("aria-activedescendant", r[t].id)) : e.control.removeAttribute("aria-activedescendant");
|
|
188
|
-
}, u = () => !e.menu.hidden, d = () => {
|
|
189
|
-
u() && a();
|
|
190
|
-
}, f = () => {
|
|
191
|
-
e.menu.hidden = !1, e.control.setAttribute("aria-expanded", "true"), e.control.classList.add("open"), a(), t(this, d), this._renderOptions();
|
|
192
|
-
}, m = () => {
|
|
193
|
-
e.menu.hidden = !0, e.control.setAttribute("aria-expanded", "false"), e.control.classList.remove("open"), l(-1), clearTimeout(this._typeaheadTimer), this._typeaheadTimer = null, this._typeahead = "", this._syncInput(), n(this);
|
|
194
|
-
}, h = (t) => {
|
|
195
|
-
let n = t.dataset.custom === "true";
|
|
196
|
-
this._value = t.dataset.value, this._label = n ? t.dataset.value : p(t.innerHTML), i(this, this._value), e.input.value = this._label, this.dispatchEvent(new CustomEvent("change", {
|
|
197
|
-
bubbles: !0,
|
|
198
|
-
detail: { isCustom: n }
|
|
199
|
-
})), m(), e.input.focus();
|
|
200
|
-
}, g = (t) => {
|
|
201
|
-
this._value = t, this._label = t, i(this, t), e.input.value = t, this.dispatchEvent(new CustomEvent("change", {
|
|
202
|
-
bubbles: !0,
|
|
203
|
-
detail: { isCustom: !0 }
|
|
204
|
-
})), m();
|
|
205
|
-
}, _ = () => {
|
|
206
|
-
let t = e.input.value;
|
|
207
|
-
if (e.clear && (e.clear.hidden = !t), u() || f(), this._remote) {
|
|
208
|
-
if (this._renderOptions(t), clearTimeout(this._timer), t.trim().length < this._minChars) {
|
|
209
|
-
this._pendingSearch = null;
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
let e = ++this._reqSeq;
|
|
213
|
-
this._pendingSearch = {
|
|
214
|
-
query: t,
|
|
215
|
-
seq: e
|
|
216
|
-
}, this._timer = setTimeout(() => this._fireSearch(t, e), this._debounceMs);
|
|
217
|
-
} else this._renderOptions(t);
|
|
218
|
-
};
|
|
219
|
-
this._navHandler = s({
|
|
220
|
-
getVisibleOptions: c,
|
|
221
|
-
getActive: () => this._active,
|
|
222
|
-
setActive: (e) => l(e),
|
|
223
|
-
onEnter: (t, n) => {
|
|
224
|
-
if (n[this._active]) h(n[this._active]);
|
|
225
|
-
else if (this._allowCustom) {
|
|
226
|
-
let t = e.input.value.trim();
|
|
227
|
-
t && !this._matchesKnownOption(t) && g(t);
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
onEscape: () => {
|
|
231
|
-
this._navHandler.clearTypeahead(), m();
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
let v = (e) => {
|
|
235
|
-
let t = e.target?.tagName === "INPUT" || e.target?.tagName === "TEXTAREA";
|
|
236
|
-
if (e.key === "ArrowDown") {
|
|
237
|
-
e.preventDefault(), u() || f();
|
|
238
|
-
let t = c();
|
|
239
|
-
l(Math.min(this._active + 1, t.length - 1));
|
|
240
|
-
return;
|
|
241
|
-
} else if (e.key === "ArrowUp") {
|
|
242
|
-
e.preventDefault(), l(Math.max(this._active - 1, 0));
|
|
243
|
-
return;
|
|
244
|
-
} else if ((e.key === "Home" || e.key === "End" || e.key === "PageDown" || e.key === "PageUp") && (!u() || t)) return;
|
|
245
|
-
else if (e.key.length === 1 && (e.ctrlKey || e.metaKey || e.altKey || !u() || e.target?.tagName === "INPUT" || e.target?.tagName === "TEXTAREA") && (!u() || e.target?.tagName === "INPUT" || e.target?.tagName === "TEXTAREA")) return;
|
|
246
|
-
this._navHandler.handler(e);
|
|
247
|
-
};
|
|
248
|
-
e.input.addEventListener("focus", () => f()), e.input.addEventListener("input", _), e.input.addEventListener("keydown", v), e.menu.addEventListener("keydown", v), e.input.addEventListener("blur", (t) => {
|
|
249
|
-
if (!this._allowCustom || t.relatedTarget && this.contains(t.relatedTarget)) return;
|
|
250
|
-
let n = e.input.value.trim();
|
|
251
|
-
!n || n === this._label || this._matchesKnownOption(n) || g(n);
|
|
252
|
-
}), e.optionsWrap.addEventListener("click", (e) => {
|
|
253
|
-
let t = e.target.closest(".search-select-option");
|
|
254
|
-
t && h(t);
|
|
255
|
-
}), e.optionsWrap.addEventListener("mousemove", (e) => {
|
|
256
|
-
let t = e.target.closest(".search-select-option");
|
|
257
|
-
t && !t.classList.contains("is-active") && l(this._optionEls().indexOf(t), { reveal: !1 });
|
|
258
|
-
}), e.optionsWrap.addEventListener("mouseleave", () => l(-1)), e.clear?.addEventListener("click", () => {
|
|
259
|
-
this._value = "", this._label = "", i(this, ""), e.input.value = "", e.clear.hidden = !0, this._renderOptions(""), this.dispatchEvent(new Event("change", { bubbles: !0 })), e.input.focus();
|
|
260
|
-
}), this._bindGlobal = () => {
|
|
261
|
-
this._teardown(), this._onDocClick = (e) => {
|
|
262
|
-
u() && !this.contains(e.target) && m();
|
|
263
|
-
}, document.addEventListener("click", this._onDocClick), u() && t(this, d);
|
|
264
|
-
}, this._bindGlobal();
|
|
265
|
-
}
|
|
266
|
-
_fireSearch(e, t) {
|
|
267
|
-
this._pendingSearch = null, this.dispatchEvent(new CustomEvent("search", {
|
|
268
|
-
bubbles: !0,
|
|
269
|
-
detail: {
|
|
270
|
-
query: e,
|
|
271
|
-
seq: t
|
|
272
|
-
}
|
|
273
|
-
}));
|
|
274
|
-
}
|
|
275
|
-
_teardown() {
|
|
276
|
-
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), n(this), clearTimeout(this._timer), this._navHandler?.teardown();
|
|
277
|
-
}
|
|
278
|
-
disconnectedCallback() {
|
|
279
|
-
this._teardown();
|
|
280
|
-
}
|
|
281
|
-
}, f = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), p = (e) => String(e ?? "").replace(/<[^>]*>/g, "");
|
|
282
|
-
//#endregion
|
|
283
|
-
export { d as t };
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./elementBase-Bg1xpvup.js";
|
|
2
|
-
import { n as t } from "./optionLabel-Dn-I7zyp.js";
|
|
3
|
-
import { t as n } from "./textMatch-DEUjlkdy.js";
|
|
4
|
-
//#region src/WuiCommandPalette.js
|
|
5
|
-
var r = "[role=\"option\"]", i = "No results", a = class extends e {
|
|
6
|
-
static get observedAttributes() {
|
|
7
|
-
return [
|
|
8
|
-
"filter",
|
|
9
|
-
"highlight",
|
|
10
|
-
"empty-text"
|
|
11
|
-
];
|
|
12
|
-
}
|
|
13
|
-
constructor() {
|
|
14
|
-
super(), this._activeId = null, this._lastQuery = null, this._lastIds = null, this._userChose = !1, this._onKeyDown = (e) => this._handleKeyDown(e), this._onClick = (e) => {
|
|
15
|
-
let t = this._optionFrom(e.target);
|
|
16
|
-
t && this._select(t);
|
|
17
|
-
}, this._onMouseDown = (e) => {
|
|
18
|
-
this._optionFrom(e.target, !0) && e.preventDefault();
|
|
19
|
-
}, this._onMouseMove = (e) => {
|
|
20
|
-
let t = this._optionFrom(e.target);
|
|
21
|
-
t && t.id !== this._activeId && (this._userChose = !0, this._setActive(t, !1));
|
|
22
|
-
}, this._onInput = (e) => {
|
|
23
|
-
!this.hasAttribute("filter") || e.target !== this._input() || (this._applyFilter(), this.refresh());
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
connectedCallback() {
|
|
27
|
-
this._teardown(), this.addEventListener("keydown", this._onKeyDown), this.addEventListener("click", this._onClick), this.addEventListener("mousedown", this._onMouseDown), this.addEventListener("mousemove", this._onMouseMove), this.addEventListener("input", this._onInput), this.hasAttribute("filter") && this._applyFilter(), this.refresh();
|
|
28
|
-
}
|
|
29
|
-
disconnectedCallback() {
|
|
30
|
-
this._teardown();
|
|
31
|
-
}
|
|
32
|
-
attributeChangedCallback() {
|
|
33
|
-
this.isConnected && (this.hasAttribute("filter") && this._applyFilter(), this.refresh());
|
|
34
|
-
}
|
|
35
|
-
get filter() {
|
|
36
|
-
return this.hasAttribute("filter");
|
|
37
|
-
}
|
|
38
|
-
set filter(e) {
|
|
39
|
-
this.toggleAttribute("filter", !!e);
|
|
40
|
-
}
|
|
41
|
-
get highlight() {
|
|
42
|
-
return this.getAttribute("highlight") !== "false";
|
|
43
|
-
}
|
|
44
|
-
set highlight(e) {
|
|
45
|
-
this.setAttribute("highlight", e ? "true" : "false");
|
|
46
|
-
}
|
|
47
|
-
get emptyText() {
|
|
48
|
-
return this.getAttribute("empty-text") ?? i;
|
|
49
|
-
}
|
|
50
|
-
set emptyText(e) {
|
|
51
|
-
this.setAttribute("empty-text", String(e ?? ""));
|
|
52
|
-
}
|
|
53
|
-
refresh() {
|
|
54
|
-
let e = this._input(), t = e ? e.value : "", n = t !== this._lastQuery;
|
|
55
|
-
this._lastQuery = t;
|
|
56
|
-
let r = this._selectableOptions(), i = r.map((e) => e.id).join("\n"), a = i !== this._lastIds;
|
|
57
|
-
this._lastIds = i;
|
|
58
|
-
let o = !n && (this._userChose || !a) ? r.find((e) => e.id === this._activeId) : null;
|
|
59
|
-
o || (this._userChose = !1), this._setActive(o ?? r[0] ?? null, n);
|
|
60
|
-
}
|
|
61
|
-
_input() {
|
|
62
|
-
return this.querySelector("[role=\"combobox\"]");
|
|
63
|
-
}
|
|
64
|
-
_optionFrom(e, t = !1) {
|
|
65
|
-
let n = e?.closest?.(r);
|
|
66
|
-
return n && this.contains(n) && !this._isHidden(n) && (t || !this._isDisabled(n)) ? n : null;
|
|
67
|
-
}
|
|
68
|
-
_isDisabled(e) {
|
|
69
|
-
return e.getAttribute("aria-disabled") === "true";
|
|
70
|
-
}
|
|
71
|
-
_isHidden(e) {
|
|
72
|
-
return e.hidden || !!e.closest("[role=\"group\"]")?.hidden;
|
|
73
|
-
}
|
|
74
|
-
_selectableOptions() {
|
|
75
|
-
return [...this.querySelectorAll(r)].filter((e) => !this._isHidden(e) && !this._isDisabled(e));
|
|
76
|
-
}
|
|
77
|
-
_setActive(e, t) {
|
|
78
|
-
this._activeId = e ? e.id : null;
|
|
79
|
-
for (let t of this.querySelectorAll(r)) t.setAttribute("aria-selected", t === e ? "true" : "false");
|
|
80
|
-
let n = this._input();
|
|
81
|
-
n && (e ? n.setAttribute("aria-activedescendant", e.id) : n.removeAttribute("aria-activedescendant")), e && t && e.scrollIntoView({ block: "nearest" });
|
|
82
|
-
}
|
|
83
|
-
_move(e) {
|
|
84
|
-
let t = this._selectableOptions();
|
|
85
|
-
if (!t.length) return;
|
|
86
|
-
let n = t.findIndex((e) => e.id === this._activeId), r = n < 0 ? e > 0 ? 0 : t.length - 1 : (n + e + t.length) % t.length;
|
|
87
|
-
this._userChose = !0, this._setActive(t[r], !0);
|
|
88
|
-
}
|
|
89
|
-
_handleKeyDown(e) {
|
|
90
|
-
if (e.target === this._input()) {
|
|
91
|
-
if (e.key === "ArrowDown" || e.key === "ArrowUp") e.preventDefault(), this._move(e.key === "ArrowDown" ? 1 : -1);
|
|
92
|
-
else if (e.key === "Enter" && !e.isComposing) {
|
|
93
|
-
let t = this._selectableOptions().find((e) => e.id === this._activeId);
|
|
94
|
-
if (!t) return;
|
|
95
|
-
e.preventDefault(), this._select(t);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
_select(e) {
|
|
100
|
-
this.dispatchEvent(new CustomEvent("wui-command-palette:select", {
|
|
101
|
-
bubbles: !0,
|
|
102
|
-
cancelable: !0,
|
|
103
|
-
detail: {
|
|
104
|
-
key: e.dataset.key ?? null,
|
|
105
|
-
groupKey: e.dataset.groupKey ?? null,
|
|
106
|
-
id: e.id
|
|
107
|
-
}
|
|
108
|
-
})) && e.dataset.href && this._navigate(e.dataset.href);
|
|
109
|
-
}
|
|
110
|
-
_navigate(e) {
|
|
111
|
-
window.location.assign(e);
|
|
112
|
-
}
|
|
113
|
-
_applyFilter() {
|
|
114
|
-
let e = this._input(), i = (e ? e.value : "").trim(), a = i.toLowerCase(), o = this.highlight, s = 0;
|
|
115
|
-
for (let e of this.querySelectorAll(r)) {
|
|
116
|
-
let r = e.querySelector(".wui-cmd-item-label"), c = e.dataset.label ?? r?.textContent ?? "", l = !a || c.toLowerCase().includes(a);
|
|
117
|
-
e.hidden = !l, l && s++, r && (r.innerHTML = n(c, o ? i : "").map((e) => e.match ? `<mark class="wui-cmd-mark">${t(e.text)}</mark>` : t(e.text)).join(""));
|
|
118
|
-
}
|
|
119
|
-
for (let e of this.querySelectorAll("[role=\"group\"]")) e.hidden = ![...e.querySelectorAll(r)].some((e) => !e.hidden);
|
|
120
|
-
let c = this.querySelector("[role=\"listbox\"]");
|
|
121
|
-
c && (c.hidden = s === 0);
|
|
122
|
-
let l = this.querySelector(".wui-cmd-empty");
|
|
123
|
-
l && (l.textContent = a && s === 0 ? this.emptyText : "");
|
|
124
|
-
}
|
|
125
|
-
_teardown() {
|
|
126
|
-
this.removeEventListener("keydown", this._onKeyDown), this.removeEventListener("click", this._onClick), this.removeEventListener("mousedown", this._onMouseDown), this.removeEventListener("mousemove", this._onMouseMove), this.removeEventListener("input", this._onInput);
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
//#endregion
|
|
130
|
-
export { a as t };
|