@editora/ui-core 0.1.20 → 0.1.21
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/collection.cjs.js +1 -1
- package/dist/collection.esm.js +27 -23
- package/dist/color-picker.cjs.js +8 -8
- package/dist/color-picker.esm.js +7 -7
- package/dist/components/ui-collection.d.ts.map +1 -1
- package/dist/components/ui-multi-select.d.ts.map +1 -1
- package/dist/components/ui-portal.d.ts.map +1 -1
- package/dist/components/ui-positioner.d.ts.map +1 -1
- package/dist/components/ui-sortable.d.ts +8 -0
- package/dist/components/ui-sortable.d.ts.map +1 -1
- package/dist/components/ui-tabs.d.ts.map +1 -1
- package/dist/components/ui-textarea.d.ts.map +1 -1
- package/dist/date-time-picker.cjs.js +4 -4
- package/dist/date-time-picker.esm.js +7 -7
- package/dist/multi-select.cjs.js +3 -3
- package/dist/multi-select.esm.js +39 -31
- package/dist/portal.cjs.js +3 -3
- package/dist/portal.esm.js +11 -10
- package/dist/positioner.cjs.js +2 -2
- package/dist/positioner.esm.js +15 -14
- package/dist/primitives/auto-scroll.d.ts +9 -0
- package/dist/primitives/auto-scroll.d.ts.map +1 -0
- package/dist/primitives/selector.d.ts +4 -0
- package/dist/primitives/selector.d.ts.map +1 -0
- package/dist/selector-BvAh35ve.js +1 -0
- package/dist/selector-WI8pD7YO.mjs +18 -0
- package/dist/sortable.cjs.js +70 -56
- package/dist/sortable.esm.js +644 -561
- package/dist/tabs.cjs.js +7 -7
- package/dist/tabs.esm.js +67 -67
- package/dist/textarea.cjs.js +9 -9
- package/dist/textarea.esm.js +31 -25
- package/dist/transfer-list.cjs.js +29 -29
- package/dist/transfer-list.esm.js +54 -54
- package/package.json +1 -1
package/dist/textarea.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as
|
|
2
|
-
const
|
|
1
|
+
import { E as v } from "./ElementBase-YlTLMsGk.mjs";
|
|
2
|
+
const _ = `
|
|
3
3
|
<svg viewBox="0 0 20 20" aria-hidden="true" focusable="false">
|
|
4
4
|
<path d="m6 6 8 8M14 6l-8 8" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>
|
|
5
5
|
</svg>
|
|
6
|
-
`,
|
|
6
|
+
`, y = `
|
|
7
7
|
:host {
|
|
8
8
|
--ui-textarea-bg: var(--ui-color-surface, #ffffff);
|
|
9
9
|
--ui-textarea-text: var(--ui-color-text, #0f172a);
|
|
@@ -310,14 +310,20 @@ const v = `
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
`;
|
|
313
|
-
function
|
|
314
|
-
return
|
|
313
|
+
function x(r) {
|
|
314
|
+
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
const e = Number(
|
|
316
|
+
function b(r, t) {
|
|
317
|
+
const e = Number(r);
|
|
318
318
|
return Number.isFinite(e) ? e : t;
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
const A = 2147483647;
|
|
321
|
+
function c(r) {
|
|
322
|
+
if (!r) return null;
|
|
323
|
+
const t = Number(r);
|
|
324
|
+
return !Number.isFinite(t) || t < 0 || t > A ? null : Math.trunc(t);
|
|
325
|
+
}
|
|
326
|
+
class z extends v {
|
|
321
327
|
constructor() {
|
|
322
328
|
super(), this._uid = `ui-textarea-${Math.random().toString(36).slice(2, 9)}`, this._textarea = null, this._clearBtn = null, this._countEl = null, this._debounceTimer = null, this._formUnregister = null, this._onInput = this._onInput.bind(this), this._onChange = this._onChange.bind(this), this._onClear = this._onClear.bind(this);
|
|
323
329
|
}
|
|
@@ -425,14 +431,14 @@ class y extends f {
|
|
|
425
431
|
}
|
|
426
432
|
_syncControlAttrs() {
|
|
427
433
|
if (!this._textarea) return;
|
|
428
|
-
const t = this.getAttribute("placeholder") || "", e = this.getAttribute("maxlength"), i = this.getAttribute("minlength"),
|
|
429
|
-
this._textarea.placeholder = t, this._textarea.disabled = a, this._textarea.readOnly = u, this._textarea.required =
|
|
430
|
-
const
|
|
431
|
-
|
|
434
|
+
const t = this.getAttribute("placeholder") || "", e = c(this.getAttribute("maxlength")), i = c(this.getAttribute("minlength")), s = b(this.getAttribute("rows"), 4), a = this.hasAttribute("disabled"), u = this.hasAttribute("readonly"), o = this.hasAttribute("required"), d = this.getAttribute("name") || "", h = this.getAttribute("resize") || "vertical", g = this.getAttribute("validation"), p = this.getAttribute("color"), n = this.getAttribute("radius");
|
|
435
|
+
this._textarea.placeholder = t, this._textarea.disabled = a, this._textarea.readOnly = u, this._textarea.required = o, this._textarea.rows = Math.max(1, s), this._textarea.name = d, this._textarea.style.resize = h, e !== null ? this._textarea.maxLength = e : this._textarea.removeAttribute("maxlength"), i !== null ? this._textarea.minLength = i : this._textarea.removeAttribute("minlength"), g === "error" ? this._textarea.setAttribute("aria-invalid", "true") : this._textarea.removeAttribute("aria-invalid"), p ? this.style.setProperty("--ui-textarea-accent", p) : this.style.removeProperty("--ui-textarea-accent"), n && n !== "none" && n !== "large" && n !== "full" ? this.style.setProperty("--ui-textarea-radius", n) : this.style.removeProperty("--ui-textarea-radius");
|
|
436
|
+
const l = [], m = !!(this.getAttribute("description") || this.querySelector('[slot="description"]')), f = !!(this.getAttribute("data-error") || this.querySelector('[slot="error"]'));
|
|
437
|
+
m && l.push(`${this._uid}-description`), f && l.push(`${this._uid}-error`), (this.hasAttribute("show-count") || c(this.getAttribute("maxlength")) !== null) && l.push(`${this._uid}-count`), !!(this.getAttribute("label") || this.querySelector('[slot="label"]')) ? this._textarea.setAttribute("aria-labelledby", `${this._uid}-label`) : this._textarea.removeAttribute("aria-labelledby"), l.length ? this._textarea.setAttribute("aria-describedby", l.join(" ")) : this._textarea.removeAttribute("aria-describedby");
|
|
432
438
|
}
|
|
433
439
|
_syncDynamicUi() {
|
|
434
|
-
const t = this._textarea?.value || this.getAttribute("value") || "", e = this.getAttribute("maxlength"), i = this.hasAttribute("clearable");
|
|
435
|
-
this._clearBtn && (i && t && !this.hasAttribute("disabled") && !this.hasAttribute("readonly") ? this._clearBtn.removeAttribute("hidden") : this._clearBtn.setAttribute("hidden", "")), this._countEl && (this.hasAttribute("show-count") ||
|
|
440
|
+
const t = this._textarea?.value || this.getAttribute("value") || "", e = c(this.getAttribute("maxlength")), i = this.hasAttribute("clearable");
|
|
441
|
+
this._clearBtn && (i && t && !this.hasAttribute("disabled") && !this.hasAttribute("readonly") ? this._clearBtn.removeAttribute("hidden") : this._clearBtn.setAttribute("hidden", "")), this._countEl && (this.hasAttribute("show-count") || e !== null ? (this._countEl.removeAttribute("hidden"), e !== null ? this._countEl.textContent = `${t.length} / ${e}` : this._countEl.textContent = `${t.length}`) : this._countEl.setAttribute("hidden", ""));
|
|
436
442
|
}
|
|
437
443
|
_applyAutosize() {
|
|
438
444
|
if (!this._textarea) return;
|
|
@@ -441,9 +447,9 @@ class y extends f {
|
|
|
441
447
|
return;
|
|
442
448
|
}
|
|
443
449
|
this._textarea.style.height = "auto";
|
|
444
|
-
const t = this._textarea.scrollHeight, e =
|
|
450
|
+
const t = this._textarea.scrollHeight, e = b(this.getAttribute("max-rows"), 0);
|
|
445
451
|
if (e > 0) {
|
|
446
|
-
const i = getComputedStyle(this._textarea),
|
|
452
|
+
const i = getComputedStyle(this._textarea), s = parseFloat(i.lineHeight || "20") || 20, a = parseFloat(i.borderTopWidth || "0") || 0, u = parseFloat(i.borderBottomWidth || "0") || 0, o = parseFloat(i.paddingTop || "0") || 0, d = parseFloat(i.paddingBottom || "0") || 0, h = s * e + a + u + o + d;
|
|
447
453
|
this._textarea.style.height = `${Math.min(t, h)}px`, this._textarea.style.overflowY = t > h ? "auto" : "hidden";
|
|
448
454
|
return;
|
|
449
455
|
}
|
|
@@ -465,7 +471,7 @@ class y extends f {
|
|
|
465
471
|
_onInput(t) {
|
|
466
472
|
const e = t.target.value;
|
|
467
473
|
this.getAttribute("value") !== e && this.setAttribute("value", e), this._syncDynamicUi(), this._applyAutosize(), this._emit("input", e);
|
|
468
|
-
const i =
|
|
474
|
+
const i = b(this.getAttribute("debounce"), 0);
|
|
469
475
|
i > 0 ? (this._debounceTimer && clearTimeout(this._debounceTimer), this._debounceTimer = setTimeout(() => {
|
|
470
476
|
this._emit("debounced-input", e), this._debounceTimer = null;
|
|
471
477
|
}, i)) : this._emit("debounced-input", e);
|
|
@@ -478,22 +484,22 @@ class y extends f {
|
|
|
478
484
|
t.preventDefault(), !(this.hasAttribute("disabled") || this.hasAttribute("readonly")) && (this.value = "", this._textarea && (this._textarea.value = "", this._textarea.focus()), this._syncDynamicUi(), this._applyAutosize(), this._emit("input", ""), this._emit("change", ""), this.dispatchEvent(new CustomEvent("clear", { bubbles: !0, composed: !0 })));
|
|
479
485
|
}
|
|
480
486
|
render() {
|
|
481
|
-
const t = this.getAttribute("value") || "", e = this.getAttribute("label") || "", i = this.getAttribute("description") || "",
|
|
487
|
+
const t = this.getAttribute("value") || "", e = this.getAttribute("label") || "", i = this.getAttribute("description") || "", s = this.getAttribute("data-error") || "", a = !!(e || i || this.querySelector('[slot="label"]') || this.querySelector('[slot="description"]')), o = this.hasAttribute("clearable") && !!t && !this.hasAttribute("disabled") && !this.hasAttribute("readonly");
|
|
482
488
|
this.setContent(`
|
|
483
|
-
<style>${
|
|
489
|
+
<style>${y}</style>
|
|
484
490
|
<div class="shell" part="shell">
|
|
485
491
|
<div class="meta" part="meta" ${a ? "" : "hidden"}>
|
|
486
|
-
<label id="${this._uid}-label" class="label" part="label"><slot name="label">${
|
|
487
|
-
<div id="${this._uid}-description" class="description" part="description"><slot name="description">${
|
|
492
|
+
<label id="${this._uid}-label" class="label" part="label"><slot name="label">${x(e)}</slot></label>
|
|
493
|
+
<div id="${this._uid}-description" class="description" part="description"><slot name="description">${x(i)}</slot></div>
|
|
488
494
|
</div>
|
|
489
495
|
|
|
490
496
|
<div class="field" part="field">
|
|
491
497
|
<textarea part="textarea"></textarea>
|
|
492
|
-
<button type="button" part="clear" class="clear-btn" aria-label="Clear text" ${
|
|
498
|
+
<button type="button" part="clear" class="clear-btn" aria-label="Clear text" ${o ? "" : "hidden"}>${_}</button>
|
|
493
499
|
</div>
|
|
494
500
|
|
|
495
501
|
<div class="footer" part="footer">
|
|
496
|
-
<div id="${this._uid}-error" class="error" part="error"><slot name="error">${
|
|
502
|
+
<div id="${this._uid}-error" class="error" part="error"><slot name="error">${x(s)}</slot></div>
|
|
497
503
|
<div id="${this._uid}-count" class="count" part="count" hidden></div>
|
|
498
504
|
</div>
|
|
499
505
|
</div>
|
|
@@ -505,7 +511,7 @@ class y extends f {
|
|
|
505
511
|
return t === "label" || t === "description" || t === "data-error";
|
|
506
512
|
}
|
|
507
513
|
}
|
|
508
|
-
typeof customElements < "u" && !customElements.get("ui-textarea") && customElements.define("ui-textarea",
|
|
514
|
+
typeof customElements < "u" && !customElements.get("ui-textarea") && customElements.define("ui-textarea", z);
|
|
509
515
|
export {
|
|
510
|
-
|
|
516
|
+
z as UITextarea
|
|
511
517
|
};
|
|
@@ -656,79 +656,79 @@
|
|
|
656
656
|
min-inline-size: 0;
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
|
-
`;function
|
|
659
|
+
`;function s(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function k(n){if(!n)return[];try{const e=JSON.parse(n);if(!Array.isArray(e))return[];const t=[];return e.forEach(r=>{if(!r||typeof r!="object")return;const a={value:String(r.value??""),label:String(r.label??r.value??""),disabled:!!r.disabled};r.description&&(a.description=String(r.description)),a.value&&t.push(a)}),t}catch{return[]}}function w(n){if(!n)return[];try{const e=JSON.parse(n);return Array.isArray(e)?e.map(t=>String(t)):[]}catch{return[]}}function A(n,e){return new Set(Array.from(n).filter(t=>e.has(t)))}function R(n){return n==="tick"||n==="none"?n:"checkbox"}function p(n,e){return n==null?e:n===""||n==="true"||n==="1"||n==="yes"?!0:n==="false"||n==="0"||n==="no"?!1:e}function $(n){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true"><path d="${n==="right"?"M9 6l6 6-6 6":"M15 6l-6 6 6 6"}"/></svg>`}class S extends q.ElementBase{constructor(){super(...arguments),this._options=[],this._value=[],this._selectedAvailable=new Set,this._selectedChosen=new Set,this._formUnregister=null,this._suppressValueAttr=!1,this._delegatedListenersAttached=!1,this._handleRootClick=e=>{const t=e.target;if(!t)return;const r=t.closest(".move-btn");if(r&&this.root.contains(r)){this._move(r.getAttribute("data-action"));return}const a=t.closest(".item");a&&this.root.contains(a)&&this._toggleItem(a)},this._handleRootKeyDown=e=>{const t=e.target;if(!t)return;const r=t.closest(".item");r&&this.root.contains(r)&&this._onItemKeyDown(e,r)}}static get observedAttributes(){return["options","value","label","description","error","name","disabled","variant","tone","size","radius","elevation","available-label","selected-label","available-empty-label","selected-empty-label","selection-indicator","add-action-label","remove-action-label","show-action-labels","show-action-counts","show-panel-counts"]}get value(){return[...this._value]}set value(e){this._applyValue(e,"api")}connectedCallback(){super.connectedCallback(),this._attachDelegatedListeners(),this._registerWithForm()}disconnectedCallback(){this._formUnregister&&this._formUnregister(),this._detachDelegatedListeners(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){t!==r&&(e==="options"&&(this._options=k(r)),e==="value"&&!this._suppressValueAttr&&(this._value=w(r)),e==="name"&&this.isConnected&&this._registerWithForm(),e==="disabled"&&(this._selectedAvailable.clear(),this._selectedChosen.clear()),this.isConnected&&this.requestRender())}render(){this._options.length||(this._options=k(this.getAttribute("options"))),!this._value.length&&this.getAttribute("value")&&(this._value=w(this.getAttribute("value")));const e=new Set(this._value),t=this._options.filter(i=>!e.has(i.value)),r=this._options.filter(i=>e.has(i.value)),a=new Set(t.map(i=>i.value)),l=new Set(r.map(i=>i.value));this._selectedAvailable=A(this._selectedAvailable,a),this._selectedChosen=A(this._selectedChosen,l);const o=this.getAttribute("label")||"",c=this.getAttribute("description")||"",d=this.getAttribute("error")||"",b=this.getAttribute("available-label")||"Available",h=this.getAttribute("selected-label")||"Selected",C=this.getAttribute("available-empty-label")||"No items available to add.",L=this.getAttribute("selected-empty-label")||"No items selected yet.",E=R(this.getAttribute("selection-indicator")),m=this.getAttribute("add-action-label")||"Add selected",g=this.getAttribute("remove-action-label")||"Remove selected",u=p(this.getAttribute("show-action-labels"),!0),f=p(this.getAttribute("show-action-counts"),!0),v=p(this.getAttribute("show-panel-counts"),!0),x=this.getAttribute("radius"),I=x?` style="--ui-transfer-panel-radius:${s(x)};"`:"",z=()=>E==="none"?"":'<span class="indicator" part="indicator" aria-hidden="true"><span class="indicator-box"><span class="indicator-mark">✓</span></span></span>',y=i=>u?`<span class="move-btn-text">${s(i)}</span>`:"",_=i=>f?`<span class="move-btn-count">${i}</span>`:"",V=t.length?t.map(i=>`<div
|
|
660
660
|
class="item"
|
|
661
661
|
part="item available-item"
|
|
662
662
|
role="option"
|
|
663
663
|
data-side="available"
|
|
664
|
-
data-value="${
|
|
664
|
+
data-value="${s(i.value)}"
|
|
665
665
|
data-selected="${this._selectedAvailable.has(i.value)}"
|
|
666
666
|
aria-selected="${this._selectedAvailable.has(i.value)?"true":"false"}"
|
|
667
667
|
aria-disabled="${i.disabled?"true":"false"}"
|
|
668
668
|
tabindex="${i.disabled?"-1":"0"}"
|
|
669
669
|
>
|
|
670
|
-
${
|
|
670
|
+
${z()}
|
|
671
671
|
<div class="item-copy">
|
|
672
|
-
<span class="item-title">${
|
|
673
|
-
${i.description?`<span class="item-description">${
|
|
672
|
+
<span class="item-title">${s(i.label)}</span>
|
|
673
|
+
${i.description?`<span class="item-description">${s(i.description)}</span>`:""}
|
|
674
674
|
</div>
|
|
675
|
-
</div>`).join(""):`<div class="empty" part="empty">${
|
|
675
|
+
</div>`).join(""):`<div class="empty" part="empty">${s(C)}</div>`,D=r.length?r.map(i=>`<div
|
|
676
676
|
class="item"
|
|
677
677
|
part="item selected-item"
|
|
678
678
|
role="option"
|
|
679
679
|
data-side="chosen"
|
|
680
|
-
data-value="${
|
|
680
|
+
data-value="${s(i.value)}"
|
|
681
681
|
data-selected="${this._selectedChosen.has(i.value)}"
|
|
682
682
|
aria-selected="${this._selectedChosen.has(i.value)?"true":"false"}"
|
|
683
683
|
aria-disabled="${i.disabled?"true":"false"}"
|
|
684
684
|
tabindex="${i.disabled?"-1":"0"}"
|
|
685
685
|
>
|
|
686
|
-
${
|
|
686
|
+
${z()}
|
|
687
687
|
<div class="item-copy">
|
|
688
|
-
<span class="item-title">${
|
|
689
|
-
${i.description?`<span class="item-description">${
|
|
688
|
+
<span class="item-title">${s(i.label)}</span>
|
|
689
|
+
${i.description?`<span class="item-description">${s(i.description)}</span>`:""}
|
|
690
690
|
</div>
|
|
691
|
-
</div>`).join(""):`<div class="empty" part="empty">${
|
|
691
|
+
</div>`).join(""):`<div class="empty" part="empty">${s(L)}</div>`;this.setContent(`
|
|
692
692
|
<style>${U}</style>
|
|
693
693
|
<div class="root"${I} part="root">
|
|
694
|
-
${
|
|
695
|
-
${c?`<p class="description" part="description">${
|
|
694
|
+
${o?`<p class="label" part="label">${s(o)}</p>`:""}
|
|
695
|
+
${c?`<p class="description" part="description">${s(c)}</p>`:""}
|
|
696
696
|
<div class="shell" part="shell">
|
|
697
697
|
<section class="panel" part="panel panel-available">
|
|
698
698
|
<div class="panel-header" part="panel-header">
|
|
699
699
|
<div class="panel-heading">
|
|
700
|
-
<div class="panel-title">${
|
|
701
|
-
${
|
|
700
|
+
<div class="panel-title">${s(b)}</div>
|
|
701
|
+
${v?`<span class="panel-count" part="count">${t.length}</span>`:""}
|
|
702
702
|
</div>
|
|
703
703
|
<div class="panel-help">Choose entries to move into the selected list.</div>
|
|
704
704
|
</div>
|
|
705
|
-
<div class="list" part="list available-list" data-list="available" role="listbox" aria-multiselectable="true">${V}</div>
|
|
705
|
+
<div class="list" part="list available-list" data-list="available" role="listbox" aria-multiselectable="true" aria-label="${s(b)}">${V}</div>
|
|
706
706
|
<div class="summary" part="summary">${t.length} available</div>
|
|
707
707
|
</section>
|
|
708
708
|
<div class="actions" part="actions">
|
|
709
|
-
<button class="move-btn" part="action-button action-add" data-compact="${!
|
|
710
|
-
<span class="move-btn-icon" aria-hidden="true">${
|
|
711
|
-
${
|
|
712
|
-
${
|
|
709
|
+
<button class="move-btn" part="action-button action-add" data-compact="${!u&&!f}" data-action="add" type="button"${u?"":` aria-label="${s(m)}"`}${this._selectedAvailable.size?"":" disabled"}>
|
|
710
|
+
<span class="move-btn-icon" aria-hidden="true">${$("right")}</span>
|
|
711
|
+
${y(m)}
|
|
712
|
+
${_(this._selectedAvailable.size||0)}
|
|
713
713
|
</button>
|
|
714
|
-
<button class="move-btn" part="action-button action-remove" data-compact="${!
|
|
715
|
-
<span class="move-btn-icon" aria-hidden="true">${
|
|
716
|
-
${g
|
|
717
|
-
${
|
|
714
|
+
<button class="move-btn" part="action-button action-remove" data-compact="${!u&&!f}" data-action="remove" type="button"${u?"":` aria-label="${s(g)}"`}${this._selectedChosen.size?"":" disabled"}>
|
|
715
|
+
<span class="move-btn-icon" aria-hidden="true">${$("left")}</span>
|
|
716
|
+
${y(g)}
|
|
717
|
+
${_(this._selectedChosen.size||0)}
|
|
718
718
|
</button>
|
|
719
719
|
</div>
|
|
720
720
|
<section class="panel" part="panel panel-selected">
|
|
721
721
|
<div class="panel-header" part="panel-header">
|
|
722
722
|
<div class="panel-heading">
|
|
723
|
-
<div class="panel-title">${
|
|
724
|
-
${
|
|
723
|
+
<div class="panel-title">${s(h)}</div>
|
|
724
|
+
${v?`<span class="panel-count" part="count">${r.length}</span>`:""}
|
|
725
725
|
</div>
|
|
726
726
|
<div class="panel-help">Use the remove action to send items back.</div>
|
|
727
727
|
</div>
|
|
728
|
-
<div class="list" part="list selected-list" data-list="chosen" role="listbox" aria-multiselectable="true">${D}</div>
|
|
728
|
+
<div class="list" part="list selected-list" data-list="chosen" role="listbox" aria-multiselectable="true" aria-label="${s(h)}">${D}</div>
|
|
729
729
|
<div class="summary" part="summary">${r.length} selected</div>
|
|
730
730
|
</section>
|
|
731
731
|
</div>
|
|
732
|
-
${
|
|
732
|
+
${d?`<p class="error" part="error">${s(d)}</p>`:""}
|
|
733
733
|
</div>
|
|
734
|
-
`)}_toggleItem(e){if(this.hasAttribute("disabled"))return;const t=e.getAttribute("data-side"),r=e.getAttribute("data-value")||"";if(!r)return;const a=t==="chosen"?this._selectedChosen:this._selectedAvailable;a.has(r)?a.delete(r):a.add(r),e.setAttribute("data-selected",a.has(r)?"true":"false"),e.setAttribute("aria-selected",a.has(r)?"true":"false"),this._syncActionButtons()}_onItemKeyDown(e,t){const r=t.getAttribute("data-side");if(!r)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._toggleItem(t);return}if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key))return;e.preventDefault();const a=this.root.querySelector(`[data-list="${r}"]`),
|
|
734
|
+
`)}_toggleItem(e){if(this.hasAttribute("disabled"))return;const t=e.getAttribute("data-side"),r=e.getAttribute("data-value")||"";if(!r)return;const a=t==="chosen"?this._selectedChosen:this._selectedAvailable;a.has(r)?a.delete(r):a.add(r),e.setAttribute("data-selected",a.has(r)?"true":"false"),e.setAttribute("aria-selected",a.has(r)?"true":"false"),this._syncActionButtons()}_onItemKeyDown(e,t){const r=t.getAttribute("data-side");if(!r)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this._toggleItem(t);return}if(!["ArrowDown","ArrowUp","Home","End"].includes(e.key))return;e.preventDefault();const a=this.root.querySelector(`[data-list="${r}"]`),l=Array.from(a?.querySelectorAll('.item[tabindex="0"]')||[]);if(!l.length)return;const o=l.indexOf(t);if(e.key==="Home"){l[0]?.focus();return}if(e.key==="End"){l[l.length-1]?.focus();return}const c=e.key==="ArrowDown"?Math.min(l.length-1,o+1):Math.max(0,o-1);l[c]?.focus()}_move(e){if(!this.hasAttribute("disabled")){if(e==="add"){const t=[...this._value,...Array.from(this._selectedAvailable).filter(r=>!this._value.includes(r))];this._selectedAvailable.clear(),this._applyValue(t,"transfer-right");return}if(e==="remove"){const t=new Set(this._selectedChosen),r=this._value.filter(a=>!t.has(a));this._selectedChosen.clear(),this._applyValue(r,"transfer-left")}}}_attachDelegatedListeners(){this._delegatedListenersAttached||(this.root.addEventListener("click",this._handleRootClick),this.root.addEventListener("keydown",this._handleRootKeyDown),this._delegatedListenersAttached=!0)}_detachDelegatedListeners(){this._delegatedListenersAttached&&(this.root.removeEventListener("click",this._handleRootClick),this.root.removeEventListener("keydown",this._handleRootKeyDown),this._delegatedListenersAttached=!1)}_applyValue(e,t){const r=new Set(this._options.map(o=>o.value)),a=Array.from(new Set(e.filter(o=>o&&(r.size===0||r.has(o))))),l=[...this._value];this._value=a,this._suppressValueAttr=!0;try{a.length?this.setAttribute("value",JSON.stringify(a)):this.removeAttribute("value")}finally{this._suppressValueAttr=!1}a.length>0&&this.removeAttribute("invalid"),this.requestRender(),this.dispatchEvent(new CustomEvent("change",{detail:{value:[...this._value],previousValue:l,selectedItems:this._options.filter(o=>this._value.includes(o.value)),source:t},bubbles:!0,composed:!0}))}_syncActionButtons(){const e=this.root.querySelector('[data-action="add"]'),t=this.root.querySelector('[data-action="remove"]');if(e){e.disabled=this._selectedAvailable.size===0;const r=e.querySelector(".move-btn-count");r&&(r.textContent=String(this._selectedAvailable.size))}if(t){t.disabled=this._selectedChosen.size===0;const r=t.querySelector(".move-btn-count");r&&(r.textContent=String(this._selectedChosen.size))}}_registerWithForm(){this._formUnregister&&(this._formUnregister(),this._formUnregister=null);try{const a=this.getRootNode().host?.closest?.("ui-form")||null||this.closest("ui-form"),l=this.getAttribute("name");a&&typeof a.registerField=="function"&&l&&(this._formUnregister=a.registerField(l,{name:l,getValue:()=>[...this._value],setValue:o=>{const c=Array.isArray(o)?o.map(d=>String(d)):[];this._applyValue(c,"api")},validate:async()=>({valid:!this.hasAttribute("required")||this._value.length>0,message:"Select at least one item."}),setError:o=>{o?(this.setAttribute("error",o),this.setAttribute("invalid","")):(this.removeAttribute("error"),this.removeAttribute("invalid")),this.requestRender()}}))}catch{}}}typeof customElements<"u"&&!customElements.get("ui-transfer-list")&&customElements.define("ui-transfer-list",S);exports.UITransferList=S;
|
|
@@ -658,10 +658,10 @@ const q = `
|
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
660
|
`;
|
|
661
|
-
function
|
|
661
|
+
function s(n) {
|
|
662
662
|
return n.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
663
663
|
}
|
|
664
|
-
function
|
|
664
|
+
function k(n) {
|
|
665
665
|
if (!n) return [];
|
|
666
666
|
try {
|
|
667
667
|
const e = JSON.parse(n);
|
|
@@ -680,7 +680,7 @@ function x(n) {
|
|
|
680
680
|
return [];
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
|
-
function
|
|
683
|
+
function w(n) {
|
|
684
684
|
if (!n) return [];
|
|
685
685
|
try {
|
|
686
686
|
const e = JSON.parse(n);
|
|
@@ -689,7 +689,7 @@ function z(n) {
|
|
|
689
689
|
return [];
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
-
function
|
|
692
|
+
function A(n, e) {
|
|
693
693
|
return new Set(Array.from(n).filter((t) => e.has(t)));
|
|
694
694
|
}
|
|
695
695
|
function R(n) {
|
|
@@ -698,7 +698,7 @@ function R(n) {
|
|
|
698
698
|
function p(n, e) {
|
|
699
699
|
return n == null ? e : n === "" || n === "true" || n === "1" || n === "yes" ? !0 : n === "false" || n === "0" || n === "no" ? !1 : e;
|
|
700
700
|
}
|
|
701
|
-
function
|
|
701
|
+
function $(n) {
|
|
702
702
|
return `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true"><path d="${n === "right" ? "M9 6l6 6-6 6" : "M15 6l-6 6 6 6"}"/></svg>`;
|
|
703
703
|
}
|
|
704
704
|
class U extends D {
|
|
@@ -759,91 +759,91 @@ class U extends D {
|
|
|
759
759
|
this._formUnregister && this._formUnregister(), this._detachDelegatedListeners(), super.disconnectedCallback();
|
|
760
760
|
}
|
|
761
761
|
attributeChangedCallback(e, t, r) {
|
|
762
|
-
t !== r && (e === "options" && (this._options =
|
|
762
|
+
t !== r && (e === "options" && (this._options = k(r)), e === "value" && !this._suppressValueAttr && (this._value = w(r)), e === "name" && this.isConnected && this._registerWithForm(), e === "disabled" && (this._selectedAvailable.clear(), this._selectedChosen.clear()), this.isConnected && this.requestRender());
|
|
763
763
|
}
|
|
764
764
|
render() {
|
|
765
|
-
this._options.length || (this._options =
|
|
766
|
-
const e = new Set(this._value), t = this._options.filter((i) => !e.has(i.value)), r = this._options.filter((i) => e.has(i.value)), a = new Set(t.map((i) => i.value)),
|
|
767
|
-
this._selectedAvailable =
|
|
768
|
-
const
|
|
765
|
+
this._options.length || (this._options = k(this.getAttribute("options"))), !this._value.length && this.getAttribute("value") && (this._value = w(this.getAttribute("value")));
|
|
766
|
+
const e = new Set(this._value), t = this._options.filter((i) => !e.has(i.value)), r = this._options.filter((i) => e.has(i.value)), a = new Set(t.map((i) => i.value)), l = new Set(r.map((i) => i.value));
|
|
767
|
+
this._selectedAvailable = A(this._selectedAvailable, a), this._selectedChosen = A(this._selectedChosen, l);
|
|
768
|
+
const o = this.getAttribute("label") || "", c = this.getAttribute("description") || "", d = this.getAttribute("error") || "", b = this.getAttribute("available-label") || "Available", h = this.getAttribute("selected-label") || "Selected", C = this.getAttribute("available-empty-label") || "No items available to add.", S = this.getAttribute("selected-empty-label") || "No items selected yet.", L = R(this.getAttribute("selection-indicator")), m = this.getAttribute("add-action-label") || "Add selected", g = this.getAttribute("remove-action-label") || "Remove selected", u = p(this.getAttribute("show-action-labels"), !0), f = p(this.getAttribute("show-action-counts"), !0), v = p(this.getAttribute("show-panel-counts"), !0), x = this.getAttribute("radius"), E = x ? ` style="--ui-transfer-panel-radius:${s(x)};"` : "", z = () => L === "none" ? "" : '<span class="indicator" part="indicator" aria-hidden="true"><span class="indicator-box"><span class="indicator-mark">✓</span></span></span>', y = (i) => u ? `<span class="move-btn-text">${s(i)}</span>` : "", _ = (i) => f ? `<span class="move-btn-count">${i}</span>` : "", I = t.length ? t.map(
|
|
769
769
|
(i) => `<div
|
|
770
770
|
class="item"
|
|
771
771
|
part="item available-item"
|
|
772
772
|
role="option"
|
|
773
773
|
data-side="available"
|
|
774
|
-
data-value="${
|
|
774
|
+
data-value="${s(i.value)}"
|
|
775
775
|
data-selected="${this._selectedAvailable.has(i.value)}"
|
|
776
776
|
aria-selected="${this._selectedAvailable.has(i.value) ? "true" : "false"}"
|
|
777
777
|
aria-disabled="${i.disabled ? "true" : "false"}"
|
|
778
778
|
tabindex="${i.disabled ? "-1" : "0"}"
|
|
779
779
|
>
|
|
780
|
-
${
|
|
780
|
+
${z()}
|
|
781
781
|
<div class="item-copy">
|
|
782
|
-
<span class="item-title">${
|
|
783
|
-
${i.description ? `<span class="item-description">${
|
|
782
|
+
<span class="item-title">${s(i.label)}</span>
|
|
783
|
+
${i.description ? `<span class="item-description">${s(i.description)}</span>` : ""}
|
|
784
784
|
</div>
|
|
785
785
|
</div>`
|
|
786
|
-
).join("") : `<div class="empty" part="empty">${
|
|
786
|
+
).join("") : `<div class="empty" part="empty">${s(C)}</div>`, V = r.length ? r.map(
|
|
787
787
|
(i) => `<div
|
|
788
788
|
class="item"
|
|
789
789
|
part="item selected-item"
|
|
790
790
|
role="option"
|
|
791
791
|
data-side="chosen"
|
|
792
|
-
data-value="${
|
|
792
|
+
data-value="${s(i.value)}"
|
|
793
793
|
data-selected="${this._selectedChosen.has(i.value)}"
|
|
794
794
|
aria-selected="${this._selectedChosen.has(i.value) ? "true" : "false"}"
|
|
795
795
|
aria-disabled="${i.disabled ? "true" : "false"}"
|
|
796
796
|
tabindex="${i.disabled ? "-1" : "0"}"
|
|
797
797
|
>
|
|
798
|
-
${
|
|
798
|
+
${z()}
|
|
799
799
|
<div class="item-copy">
|
|
800
|
-
<span class="item-title">${
|
|
801
|
-
${i.description ? `<span class="item-description">${
|
|
800
|
+
<span class="item-title">${s(i.label)}</span>
|
|
801
|
+
${i.description ? `<span class="item-description">${s(i.description)}</span>` : ""}
|
|
802
802
|
</div>
|
|
803
803
|
</div>`
|
|
804
|
-
).join("") : `<div class="empty" part="empty">${
|
|
804
|
+
).join("") : `<div class="empty" part="empty">${s(S)}</div>`;
|
|
805
805
|
this.setContent(`
|
|
806
806
|
<style>${q}</style>
|
|
807
807
|
<div class="root"${E} part="root">
|
|
808
|
-
${
|
|
809
|
-
${c ? `<p class="description" part="description">${
|
|
808
|
+
${o ? `<p class="label" part="label">${s(o)}</p>` : ""}
|
|
809
|
+
${c ? `<p class="description" part="description">${s(c)}</p>` : ""}
|
|
810
810
|
<div class="shell" part="shell">
|
|
811
811
|
<section class="panel" part="panel panel-available">
|
|
812
812
|
<div class="panel-header" part="panel-header">
|
|
813
813
|
<div class="panel-heading">
|
|
814
|
-
<div class="panel-title">${
|
|
815
|
-
${
|
|
814
|
+
<div class="panel-title">${s(b)}</div>
|
|
815
|
+
${v ? `<span class="panel-count" part="count">${t.length}</span>` : ""}
|
|
816
816
|
</div>
|
|
817
817
|
<div class="panel-help">Choose entries to move into the selected list.</div>
|
|
818
818
|
</div>
|
|
819
|
-
<div class="list" part="list available-list" data-list="available" role="listbox" aria-multiselectable="true">${I}</div>
|
|
819
|
+
<div class="list" part="list available-list" data-list="available" role="listbox" aria-multiselectable="true" aria-label="${s(b)}">${I}</div>
|
|
820
820
|
<div class="summary" part="summary">${t.length} available</div>
|
|
821
821
|
</section>
|
|
822
822
|
<div class="actions" part="actions">
|
|
823
|
-
<button class="move-btn" part="action-button action-add" data-compact="${!
|
|
824
|
-
<span class="move-btn-icon" aria-hidden="true">${
|
|
825
|
-
${
|
|
826
|
-
${
|
|
823
|
+
<button class="move-btn" part="action-button action-add" data-compact="${!u && !f}" data-action="add" type="button"${u ? "" : ` aria-label="${s(m)}"`}${this._selectedAvailable.size ? "" : " disabled"}>
|
|
824
|
+
<span class="move-btn-icon" aria-hidden="true">${$("right")}</span>
|
|
825
|
+
${y(m)}
|
|
826
|
+
${_(this._selectedAvailable.size || 0)}
|
|
827
827
|
</button>
|
|
828
|
-
<button class="move-btn" part="action-button action-remove" data-compact="${!
|
|
829
|
-
<span class="move-btn-icon" aria-hidden="true">${
|
|
830
|
-
${g
|
|
831
|
-
${
|
|
828
|
+
<button class="move-btn" part="action-button action-remove" data-compact="${!u && !f}" data-action="remove" type="button"${u ? "" : ` aria-label="${s(g)}"`}${this._selectedChosen.size ? "" : " disabled"}>
|
|
829
|
+
<span class="move-btn-icon" aria-hidden="true">${$("left")}</span>
|
|
830
|
+
${y(g)}
|
|
831
|
+
${_(this._selectedChosen.size || 0)}
|
|
832
832
|
</button>
|
|
833
833
|
</div>
|
|
834
834
|
<section class="panel" part="panel panel-selected">
|
|
835
835
|
<div class="panel-header" part="panel-header">
|
|
836
836
|
<div class="panel-heading">
|
|
837
|
-
<div class="panel-title">${
|
|
838
|
-
${
|
|
837
|
+
<div class="panel-title">${s(h)}</div>
|
|
838
|
+
${v ? `<span class="panel-count" part="count">${r.length}</span>` : ""}
|
|
839
839
|
</div>
|
|
840
840
|
<div class="panel-help">Use the remove action to send items back.</div>
|
|
841
841
|
</div>
|
|
842
|
-
<div class="list" part="list selected-list" data-list="chosen" role="listbox" aria-multiselectable="true">${V}</div>
|
|
842
|
+
<div class="list" part="list selected-list" data-list="chosen" role="listbox" aria-multiselectable="true" aria-label="${s(h)}">${V}</div>
|
|
843
843
|
<div class="summary" part="summary">${r.length} selected</div>
|
|
844
844
|
</section>
|
|
845
845
|
</div>
|
|
846
|
-
${
|
|
846
|
+
${d ? `<p class="error" part="error">${s(d)}</p>` : ""}
|
|
847
847
|
</div>
|
|
848
848
|
`);
|
|
849
849
|
}
|
|
@@ -863,19 +863,19 @@ class U extends D {
|
|
|
863
863
|
}
|
|
864
864
|
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(e.key)) return;
|
|
865
865
|
e.preventDefault();
|
|
866
|
-
const a = this.root.querySelector(`[data-list="${r}"]`),
|
|
867
|
-
if (!
|
|
868
|
-
const
|
|
866
|
+
const a = this.root.querySelector(`[data-list="${r}"]`), l = Array.from(a?.querySelectorAll('.item[tabindex="0"]') || []);
|
|
867
|
+
if (!l.length) return;
|
|
868
|
+
const o = l.indexOf(t);
|
|
869
869
|
if (e.key === "Home") {
|
|
870
|
-
|
|
870
|
+
l[0]?.focus();
|
|
871
871
|
return;
|
|
872
872
|
}
|
|
873
873
|
if (e.key === "End") {
|
|
874
|
-
|
|
874
|
+
l[l.length - 1]?.focus();
|
|
875
875
|
return;
|
|
876
876
|
}
|
|
877
|
-
const c = e.key === "ArrowDown" ? Math.min(
|
|
878
|
-
|
|
877
|
+
const c = e.key === "ArrowDown" ? Math.min(l.length - 1, o + 1) : Math.max(0, o - 1);
|
|
878
|
+
l[c]?.focus();
|
|
879
879
|
}
|
|
880
880
|
_move(e) {
|
|
881
881
|
if (!this.hasAttribute("disabled")) {
|
|
@@ -897,7 +897,7 @@ class U extends D {
|
|
|
897
897
|
this._delegatedListenersAttached && (this.root.removeEventListener("click", this._handleRootClick), this.root.removeEventListener("keydown", this._handleRootKeyDown), this._delegatedListenersAttached = !1);
|
|
898
898
|
}
|
|
899
899
|
_applyValue(e, t) {
|
|
900
|
-
const r = new Set(this._options.map((
|
|
900
|
+
const r = new Set(this._options.map((o) => o.value)), a = Array.from(new Set(e.filter((o) => o && (r.size === 0 || r.has(o))))), l = [...this._value];
|
|
901
901
|
this._value = a, this._suppressValueAttr = !0;
|
|
902
902
|
try {
|
|
903
903
|
a.length ? this.setAttribute("value", JSON.stringify(a)) : this.removeAttribute("value");
|
|
@@ -908,8 +908,8 @@ class U extends D {
|
|
|
908
908
|
new CustomEvent("change", {
|
|
909
909
|
detail: {
|
|
910
910
|
value: [...this._value],
|
|
911
|
-
previousValue:
|
|
912
|
-
selectedItems: this._options.filter((
|
|
911
|
+
previousValue: l,
|
|
912
|
+
selectedItems: this._options.filter((o) => this._value.includes(o.value)),
|
|
913
913
|
source: t
|
|
914
914
|
},
|
|
915
915
|
bubbles: !0,
|
|
@@ -933,17 +933,17 @@ class U extends D {
|
|
|
933
933
|
_registerWithForm() {
|
|
934
934
|
this._formUnregister && (this._formUnregister(), this._formUnregister = null);
|
|
935
935
|
try {
|
|
936
|
-
const a = this.getRootNode().host?.closest?.("ui-form") || null || this.closest("ui-form"),
|
|
937
|
-
a && typeof a.registerField == "function" &&
|
|
938
|
-
name:
|
|
936
|
+
const a = this.getRootNode().host?.closest?.("ui-form") || null || this.closest("ui-form"), l = this.getAttribute("name");
|
|
937
|
+
a && typeof a.registerField == "function" && l && (this._formUnregister = a.registerField(l, {
|
|
938
|
+
name: l,
|
|
939
939
|
getValue: () => [...this._value],
|
|
940
|
-
setValue: (
|
|
941
|
-
const c = Array.isArray(
|
|
940
|
+
setValue: (o) => {
|
|
941
|
+
const c = Array.isArray(o) ? o.map((d) => String(d)) : [];
|
|
942
942
|
this._applyValue(c, "api");
|
|
943
943
|
},
|
|
944
944
|
validate: async () => ({ valid: !this.hasAttribute("required") || this._value.length > 0, message: "Select at least one item." }),
|
|
945
|
-
setError: (
|
|
946
|
-
|
|
945
|
+
setError: (o) => {
|
|
946
|
+
o ? (this.setAttribute("error", o), this.setAttribute("invalid", "")) : (this.removeAttribute("error"), this.removeAttribute("invalid")), this.requestRender();
|
|
947
947
|
}
|
|
948
948
|
}));
|
|
949
949
|
} catch {
|
package/package.json
CHANGED