@logosphere-ui/core 0.0.0-alpha.7 → 0.0.0-alpha.9
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/badge-CHWTCGQG.js +72 -0
- package/dist/badge-DVvdodRb.cjs +13 -0
- package/dist/badge.cjs +1 -0
- package/dist/badge.js +4 -0
- package/dist/breadcrumb-BB61Xt0s.js +41 -0
- package/dist/breadcrumb-Cop-B1J7.cjs +12 -0
- package/dist/breadcrumb.cjs +1 -0
- package/dist/breadcrumb.js +4 -0
- package/dist/button-BqOMevro.js +58 -0
- package/dist/button-CDRccsk9.cjs +10 -0
- package/dist/button.cjs +1 -0
- package/dist/button.js +4 -0
- package/dist/card-CNoTUaJC.js +98 -0
- package/dist/card-KiNHfEi2.cjs +43 -0
- package/dist/card.cjs +1 -0
- package/dist/card.js +4 -0
- package/dist/chatbot-BNGCxSf9.js +485 -0
- package/dist/chatbot-P32-Xv7e.cjs +160 -0
- package/dist/chatbot.cjs +1 -0
- package/dist/chatbot.js +4 -0
- package/dist/checkbox-CdDTRdKV.cjs +37 -0
- package/dist/checkbox-g6kl2jGR.js +119 -0
- package/dist/checkbox.cjs +1 -0
- package/dist/checkbox.js +4 -0
- package/dist/combobox-CeK7yW2F.cjs +99 -0
- package/dist/combobox-DTUSFw9V.js +270 -0
- package/dist/combobox.cjs +1 -0
- package/dist/combobox.js +4 -0
- package/dist/datepicker-BQOVo1Pr.cjs +115 -0
- package/dist/datepicker-ChdQsc_l.js +751 -0
- package/dist/datepicker.cjs +1 -0
- package/dist/datepicker.js +4 -0
- package/dist/download-manager-BSIMTGaK.cjs +97 -0
- package/dist/download-manager-a541AYhr.js +381 -0
- package/dist/download-manager.cjs +1 -0
- package/dist/download-manager.js +4 -0
- package/dist/formfield-BOgRugzm.js +118 -0
- package/dist/formfield-D_7NFFoe.cjs +27 -0
- package/dist/formfield.cjs +1 -0
- package/dist/formfield.js +4 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +32 -3207
- package/dist/index.umd.js +106 -85
- package/dist/input-CoY1ZcPF.cjs +46 -0
- package/dist/input-CxBP0i-3.js +194 -0
- package/dist/input.cjs +1 -0
- package/dist/input.js +4 -0
- package/dist/modal-CnwRIdd8.js +110 -0
- package/dist/modal-DQ8VFL-P.cjs +39 -0
- package/dist/modal.cjs +1 -0
- package/dist/modal.js +4 -0
- package/dist/popover-C2p5Pmts.cjs +30 -0
- package/dist/popover-CaVOXo_k.js +140 -0
- package/dist/popover.cjs +1 -0
- package/dist/popover.js +4 -0
- package/dist/switch-CG4SSjTg.js +64 -0
- package/dist/switch-Rnnn10bn.cjs +17 -0
- package/dist/switch.cjs +1 -0
- package/dist/switch.js +4 -0
- package/dist/tab-BYU_XEhp.js +176 -0
- package/dist/tab-DcjAlXzU.cjs +40 -0
- package/dist/tab.cjs +1 -0
- package/dist/tab.js +4 -0
- package/dist/text-area-Dw4CUBcz.js +206 -0
- package/dist/text-area-eT-oCnqZ.cjs +44 -0
- package/dist/textarea.cjs +1 -0
- package/dist/textarea.js +4 -0
- package/dist/ui-icon-CVEyvL5D.cjs +22 -0
- package/dist/ui-icon-ltkJROhR.js +51 -0
- package/package.json +31 -20
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { unsafeCSS as l, css as d, LitElement as p, html as _ } from "lit";
|
|
2
|
+
import { property as n, query as w, customElement as b } from "lit/decorators.js";
|
|
3
|
+
const u = ":host{display:block}.switch{display:inline-block;position:relative}.switch--md{width:36px;height:20px}.switch--sm{width:32px;height:18px}.switch__input{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.switch__track{position:absolute;top:0;left:0;width:100%;height:100%;border-radius:var(--radius-full);cursor:pointer;transition:background-color var(--transition-speed-base) var(--transition-timing);background-color:var(--color-gray-300)}.switch__track--on{background-color:var(--color-primary)}.switch__track--disabled{cursor:not-allowed}.switch__track--disabled-on{background-color:color-mix(in srgb,var(--color-primary) 30%,transparent)}.switch__track--disabled-off{background-color:var(--color-gray-200)}.switch__thumb{position:absolute;background-color:#fff;border-radius:var(--radius-full);box-shadow:var(--shadow-xs);top:2px;left:2px;transform:translate(0);transition:transform var(--transition-speed-base) var(--transition-timing)}.switch--md .switch__thumb{width:16px;height:16px}.switch--sm .switch__thumb{width:14px;height:14px}.switch__thumb--on.switch--md .switch__thumb,.switch__track--on~.switch__thumb{transform:translate(16px)}.switch__track--on+.switch__thumb{transform:translate(16px)}";
|
|
4
|
+
var m = Object.defineProperty, k = Object.getOwnPropertyDescriptor, a = (e, t, r, c) => {
|
|
5
|
+
for (var s = c > 1 ? void 0 : c ? k(t, r) : t, o = e.length - 1, h; o >= 0; o--)
|
|
6
|
+
(h = e[o]) && (s = (c ? h(t, r, s) : h(s)) || s);
|
|
7
|
+
return c && s && m(t, r, s), s;
|
|
8
|
+
};
|
|
9
|
+
let i = class extends p {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments), this.checked = !1, this.disabled = !1, this.size = "md";
|
|
12
|
+
}
|
|
13
|
+
onChange(e) {
|
|
14
|
+
const t = e.target;
|
|
15
|
+
this.checked = t.checked, this.dispatchEvent(new CustomEvent("change", {
|
|
16
|
+
detail: { checked: this.checked }
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
const e = `switch switch--${this.size}`, t = [
|
|
21
|
+
"switch__track",
|
|
22
|
+
this.checked && !this.disabled ? "switch__track--on" : "",
|
|
23
|
+
this.disabled ? "switch__track--disabled" : "",
|
|
24
|
+
this.disabled && this.checked ? "switch__track--disabled-on" : "",
|
|
25
|
+
this.disabled && !this.checked ? "switch__track--disabled-off" : ""
|
|
26
|
+
].filter(Boolean).join(" "), r = this.checked ? "translateX(16px)" : "translateX(0)";
|
|
27
|
+
return _`
|
|
28
|
+
<label class="${e}">
|
|
29
|
+
<input
|
|
30
|
+
class="switch__input"
|
|
31
|
+
type="checkbox"
|
|
32
|
+
?checked=${this.checked}
|
|
33
|
+
?disabled=${this.disabled}
|
|
34
|
+
@change=${this.onChange}
|
|
35
|
+
/>
|
|
36
|
+
<div class="${t}">
|
|
37
|
+
<span
|
|
38
|
+
class="switch__thumb"
|
|
39
|
+
style="transform: ${r}"
|
|
40
|
+
></span>
|
|
41
|
+
</div>
|
|
42
|
+
</label>
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
i.styles = [d`${l(u)}`];
|
|
47
|
+
a([
|
|
48
|
+
n({ type: Boolean })
|
|
49
|
+
], i.prototype, "checked", 2);
|
|
50
|
+
a([
|
|
51
|
+
n({ type: Boolean })
|
|
52
|
+
], i.prototype, "disabled", 2);
|
|
53
|
+
a([
|
|
54
|
+
n({ type: String })
|
|
55
|
+
], i.prototype, "size", 2);
|
|
56
|
+
a([
|
|
57
|
+
w("input")
|
|
58
|
+
], i.prototype, "inputElement", 2);
|
|
59
|
+
i = a([
|
|
60
|
+
b("logosphere-switch")
|
|
61
|
+
], i);
|
|
62
|
+
export {
|
|
63
|
+
i as S
|
|
64
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";const a=require("lit"),r=require("lit/decorators.js"),d=":host{display:block}.switch{display:inline-block;position:relative}.switch--md{width:36px;height:20px}.switch--sm{width:32px;height:18px}.switch__input{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.switch__track{position:absolute;top:0;left:0;width:100%;height:100%;border-radius:var(--radius-full);cursor:pointer;transition:background-color var(--transition-speed-base) var(--transition-timing);background-color:var(--color-gray-300)}.switch__track--on{background-color:var(--color-primary)}.switch__track--disabled{cursor:not-allowed}.switch__track--disabled-on{background-color:color-mix(in srgb,var(--color-primary) 30%,transparent)}.switch__track--disabled-off{background-color:var(--color-gray-200)}.switch__thumb{position:absolute;background-color:#fff;border-radius:var(--radius-full);box-shadow:var(--shadow-xs);top:2px;left:2px;transform:translate(0);transition:transform var(--transition-speed-base) var(--transition-timing)}.switch--md .switch__thumb{width:16px;height:16px}.switch--sm .switch__thumb{width:14px;height:14px}.switch__thumb--on.switch--md .switch__thumb,.switch__track--on~.switch__thumb{transform:translate(16px)}.switch__track--on+.switch__thumb{transform:translate(16px)}";var l=Object.defineProperty,p=Object.getOwnPropertyDescriptor,c=(o,t,s,e)=>{for(var i=e>1?void 0:e?p(t,s):t,h=o.length-1,n;h>=0;h--)(n=o[h])&&(i=(e?n(t,s,i):n(i))||i);return e&&i&&l(t,s,i),i};exports.Switch=class extends a.LitElement{constructor(){super(...arguments),this.checked=!1,this.disabled=!1,this.size="md"}onChange(t){const s=t.target;this.checked=s.checked,this.dispatchEvent(new CustomEvent("change",{detail:{checked:this.checked}}))}render(){const t=`switch switch--${this.size}`,s=["switch__track",this.checked&&!this.disabled?"switch__track--on":"",this.disabled?"switch__track--disabled":"",this.disabled&&this.checked?"switch__track--disabled-on":"",this.disabled&&!this.checked?"switch__track--disabled-off":""].filter(Boolean).join(" "),e=this.checked?"translateX(16px)":"translateX(0)";return a.html`
|
|
2
|
+
<label class="${t}">
|
|
3
|
+
<input
|
|
4
|
+
class="switch__input"
|
|
5
|
+
type="checkbox"
|
|
6
|
+
?checked=${this.checked}
|
|
7
|
+
?disabled=${this.disabled}
|
|
8
|
+
@change=${this.onChange}
|
|
9
|
+
/>
|
|
10
|
+
<div class="${s}">
|
|
11
|
+
<span
|
|
12
|
+
class="switch__thumb"
|
|
13
|
+
style="transform: ${e}"
|
|
14
|
+
></span>
|
|
15
|
+
</div>
|
|
16
|
+
</label>
|
|
17
|
+
`}};exports.Switch.styles=[a.css`${a.unsafeCSS(d)}`];c([r.property({type:Boolean})],exports.Switch.prototype,"checked",2);c([r.property({type:Boolean})],exports.Switch.prototype,"disabled",2);c([r.property({type:String})],exports.Switch.prototype,"size",2);c([r.query("input")],exports.Switch.prototype,"inputElement",2);exports.Switch=c([r.customElement("logosphere-switch")],exports.Switch);
|
package/dist/switch.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./switch-Rnnn10bn.cjs");Object.defineProperty(exports,"Switch",{enumerable:!0,get:()=>e.Switch});
|
package/dist/switch.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { unsafeCSS as p, css as f, LitElement as v, nothing as c, html as r } from "lit";
|
|
2
|
+
import { property as b, state as h, query as _, customElement as u } from "lit/decorators.js";
|
|
3
|
+
const y = ".tab{width:100%;font-family:var(--font-family-base)}.tab__list{display:flex;overflow-x:auto;overflow-y:hidden;border-bottom:1px solid var(--color-border);scroll-behavior:smooth;-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none}.tab__list::-webkit-scrollbar{display:none}.tab__button{display:inline-flex;flex-direction:row;align-items:center;gap:var(--spacing-2);padding:var(--spacing-3) var(--spacing-4);min-width:120px;position:relative;cursor:pointer;border:none;border-bottom:2px solid transparent;background:transparent;font-family:var(--font-family-base);white-space:nowrap;transition:background-color var(--transition-speed-base) var(--transition-timing),border-color var(--transition-speed-base) var(--transition-timing)}.tab__button:hover:not(.tab__button--disabled):not(.tab__button--active){background-color:var(--color-tertiary-bg)}.tab__button--active{border-bottom-color:var(--color-primary)}.tab__button--disabled{cursor:not-allowed;opacity:.4;pointer-events:none}.tab__icon{font-size:var(--font-size-xl);flex-shrink:0;color:inherit;line-height:1}.tab__content{display:flex;flex-direction:column;align-items:flex-start}.tab__label{font-weight:var(--font-weight-medium);font-size:var(--font-size-sm);color:var(--color-body-text)}.tab__label--inactive{color:var(--color-tertiary)}.tab__description{font-size:var(--font-size-xs);text-align:left;color:var(--color-tertiary)}.tab__description--active{color:var(--color-secondary)}.tab__panel{padding:var(--spacing-4);outline:none}.tab__panel--hidden{display:none}";
|
|
4
|
+
var g = Object.defineProperty, w = Object.getOwnPropertyDescriptor, n = (e, i, t, a) => {
|
|
5
|
+
for (var s = a > 1 ? void 0 : a ? w(i, t) : i, l = e.length - 1, d; l >= 0; l--)
|
|
6
|
+
(d = e[l]) && (s = (a ? d(i, t, s) : d(s)) || s);
|
|
7
|
+
return a && s && g(i, t, s), s;
|
|
8
|
+
};
|
|
9
|
+
let o = class extends v {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments), this.tabs = [], this.activeTab = "", this.lazy = !0, this.variant = "default", this._focusedIndex = 0, this._renderedTabs = /* @__PURE__ */ new Set();
|
|
12
|
+
}
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
super.connectedCallback(), !this.activeTab && this.tabs.length > 0 && (this.activeTab = this.tabs[0].id);
|
|
15
|
+
}
|
|
16
|
+
willUpdate(e) {
|
|
17
|
+
if (super.willUpdate(e), e.has("activeTab") && this.activeTab) {
|
|
18
|
+
this._renderedTabs.add(this.activeTab);
|
|
19
|
+
const i = this.tabs.findIndex((t) => t.id === this.activeTab);
|
|
20
|
+
i !== -1 && (this._focusedIndex = i);
|
|
21
|
+
}
|
|
22
|
+
e.has("tabs") && this.tabs.length > 0 && (this.tabs.some((t) => t.id === this.activeTab) || (this.activeTab = this.tabs[0].id), this._focusedIndex = this.tabs.findIndex((t) => t.id === this.activeTab));
|
|
23
|
+
}
|
|
24
|
+
// ==================== EVENTS ====================
|
|
25
|
+
handleTabClick(e, i) {
|
|
26
|
+
if (i) return;
|
|
27
|
+
const t = this.activeTab;
|
|
28
|
+
this.activeTab = e, this._focusedIndex = this.tabs.findIndex((a) => a.id === e), this.dispatchEvent(
|
|
29
|
+
new CustomEvent("tab-change", {
|
|
30
|
+
detail: { oldTab: t, newTab: e },
|
|
31
|
+
bubbles: !0,
|
|
32
|
+
composed: !0
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
handleKeyDown(e) {
|
|
37
|
+
const { tabs: i } = this;
|
|
38
|
+
if (i.filter((s) => !s.disabled).length === 0) return;
|
|
39
|
+
let t = this._focusedIndex;
|
|
40
|
+
const a = this._focusedIndex;
|
|
41
|
+
switch (e.key) {
|
|
42
|
+
case "ArrowLeft":
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
do
|
|
45
|
+
t = t > 0 ? t - 1 : i.length - 1;
|
|
46
|
+
while (i[t]?.disabled && t !== a);
|
|
47
|
+
break;
|
|
48
|
+
case "ArrowRight":
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
do
|
|
51
|
+
t = t < i.length - 1 ? t + 1 : 0;
|
|
52
|
+
while (i[t]?.disabled && t !== a);
|
|
53
|
+
break;
|
|
54
|
+
case "Home":
|
|
55
|
+
for (e.preventDefault(), t = 0; i[t]?.disabled && t < i.length - 1; ) t++;
|
|
56
|
+
break;
|
|
57
|
+
case "End":
|
|
58
|
+
for (e.preventDefault(), t = i.length - 1; i[t]?.disabled && t > 0; ) t--;
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (t !== this._focusedIndex && !i[t]?.disabled) {
|
|
64
|
+
const s = this.activeTab;
|
|
65
|
+
this._focusedIndex = t, this.activeTab = i[t].id, this.updateComplete.then(() => {
|
|
66
|
+
this.shadowRoot?.querySelector(
|
|
67
|
+
`[role="tab"][data-tab-id="${i[t].id}"]`
|
|
68
|
+
)?.focus();
|
|
69
|
+
}), this.dispatchEvent(
|
|
70
|
+
new CustomEvent("tab-change", {
|
|
71
|
+
detail: { oldTab: s, newTab: i[t].id },
|
|
72
|
+
bubbles: !0,
|
|
73
|
+
composed: !0
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
scrollTabIntoView(e) {
|
|
79
|
+
this.updateComplete.then(() => {
|
|
80
|
+
const i = this.shadowRoot?.querySelector(
|
|
81
|
+
`[role="tab"][data-tab-id="${e}"]`
|
|
82
|
+
);
|
|
83
|
+
if (i && this.tablist) {
|
|
84
|
+
const t = this.tablist.getBoundingClientRect(), a = i.getBoundingClientRect();
|
|
85
|
+
a.left < t.left ? this.tablist.scrollLeft -= t.left - a.left + 16 : a.right > t.right && (this.tablist.scrollLeft += a.right - t.right + 16);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
// ==================== RENDER ====================
|
|
90
|
+
renderTabButton(e, i) {
|
|
91
|
+
const t = this.activeTab === e.id, a = this._focusedIndex === i, s = [
|
|
92
|
+
"tab__button",
|
|
93
|
+
t ? "tab__button--active" : "",
|
|
94
|
+
e.disabled ? "tab__button--disabled" : ""
|
|
95
|
+
].filter(Boolean).join(" "), l = ["tab__label", t ? "" : "tab__label--inactive"].filter(Boolean).join(" "), d = ["tab__description", t ? "tab__description--active" : ""].filter(Boolean).join(" ");
|
|
96
|
+
return r`
|
|
97
|
+
<button
|
|
98
|
+
role="tab"
|
|
99
|
+
class=${s}
|
|
100
|
+
data-tab-id=${e.id}
|
|
101
|
+
aria-selected=${t ? "true" : "false"}
|
|
102
|
+
aria-controls="panel-${e.id}"
|
|
103
|
+
tabindex=${t || a ? "0" : "-1"}
|
|
104
|
+
?disabled=${e.disabled}
|
|
105
|
+
@click=${() => this.handleTabClick(e.id, e.disabled)}
|
|
106
|
+
@focus=${() => this.scrollTabIntoView(e.id)}
|
|
107
|
+
>
|
|
108
|
+
${e.icon ? r`<i class="${e.icon} tab__icon"></i>` : c}
|
|
109
|
+
<div class="tab__content">
|
|
110
|
+
<span class=${l}>${e.label}</span>
|
|
111
|
+
${e.description ? r`<span class=${d}>${e.description}</span>` : c}
|
|
112
|
+
</div>
|
|
113
|
+
</button>
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
renderTabPanel(e) {
|
|
117
|
+
const i = this.activeTab === e.id;
|
|
118
|
+
if (!(!this.lazy || this._renderedTabs.has(e.id))) return c;
|
|
119
|
+
const a = ["tab__panel", i ? "" : "tab__panel--hidden"].filter(Boolean).join(" ");
|
|
120
|
+
return r`
|
|
121
|
+
<div
|
|
122
|
+
role="tabpanel"
|
|
123
|
+
id="panel-${e.id}"
|
|
124
|
+
aria-labelledby="tab-${e.id}"
|
|
125
|
+
class=${a}
|
|
126
|
+
tabindex="0"
|
|
127
|
+
>
|
|
128
|
+
<slot name=${`panel-${e.id}`}>
|
|
129
|
+
${typeof e.content == "string" ? r`${e.content}` : c}
|
|
130
|
+
</slot>
|
|
131
|
+
</div>
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
render() {
|
|
135
|
+
return r`
|
|
136
|
+
<div class="tab">
|
|
137
|
+
<div role="tablist" aria-label="Tabs" class="tab__list" @keydown=${this.handleKeyDown}>
|
|
138
|
+
${this.tabs.map((e, i) => this.renderTabButton(e, i))}
|
|
139
|
+
</div>
|
|
140
|
+
<div class="tab__panels">${this.tabs.map((e) => this.renderTabPanel(e))}</div>
|
|
141
|
+
</div>
|
|
142
|
+
`;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
o.styles = [
|
|
146
|
+
f`
|
|
147
|
+
${p(y)}
|
|
148
|
+
`
|
|
149
|
+
];
|
|
150
|
+
n([
|
|
151
|
+
b({ type: Array })
|
|
152
|
+
], o.prototype, "tabs", 2);
|
|
153
|
+
n([
|
|
154
|
+
b({ type: String })
|
|
155
|
+
], o.prototype, "activeTab", 2);
|
|
156
|
+
n([
|
|
157
|
+
b({ type: Boolean })
|
|
158
|
+
], o.prototype, "lazy", 2);
|
|
159
|
+
n([
|
|
160
|
+
b({ type: String })
|
|
161
|
+
], o.prototype, "variant", 2);
|
|
162
|
+
n([
|
|
163
|
+
h()
|
|
164
|
+
], o.prototype, "_focusedIndex", 2);
|
|
165
|
+
n([
|
|
166
|
+
h()
|
|
167
|
+
], o.prototype, "_renderedTabs", 2);
|
|
168
|
+
n([
|
|
169
|
+
_('[role="tablist"]')
|
|
170
|
+
], o.prototype, "tablist", 2);
|
|
171
|
+
o = n([
|
|
172
|
+
u("logosphere-tab")
|
|
173
|
+
], o);
|
|
174
|
+
export {
|
|
175
|
+
o as L
|
|
176
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";const s=require("lit"),n=require("lit/decorators.js"),c=".tab{width:100%;font-family:var(--font-family-base)}.tab__list{display:flex;overflow-x:auto;overflow-y:hidden;border-bottom:1px solid var(--color-border);scroll-behavior:smooth;-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none}.tab__list::-webkit-scrollbar{display:none}.tab__button{display:inline-flex;flex-direction:row;align-items:center;gap:var(--spacing-2);padding:var(--spacing-3) var(--spacing-4);min-width:120px;position:relative;cursor:pointer;border:none;border-bottom:2px solid transparent;background:transparent;font-family:var(--font-family-base);white-space:nowrap;transition:background-color var(--transition-speed-base) var(--transition-timing),border-color var(--transition-speed-base) var(--transition-timing)}.tab__button:hover:not(.tab__button--disabled):not(.tab__button--active){background-color:var(--color-tertiary-bg)}.tab__button--active{border-bottom-color:var(--color-primary)}.tab__button--disabled{cursor:not-allowed;opacity:.4;pointer-events:none}.tab__icon{font-size:var(--font-size-xl);flex-shrink:0;color:inherit;line-height:1}.tab__content{display:flex;flex-direction:column;align-items:flex-start}.tab__label{font-weight:var(--font-weight-medium);font-size:var(--font-size-sm);color:var(--color-body-text)}.tab__label--inactive{color:var(--color-tertiary)}.tab__description{font-size:var(--font-size-xs);text-align:left;color:var(--color-tertiary)}.tab__description--active{color:var(--color-secondary)}.tab__panel{padding:var(--spacing-4);outline:none}.tab__panel--hidden{display:none}";var h=Object.defineProperty,p=Object.getOwnPropertyDescriptor,r=(d,e,a,t)=>{for(var i=t>1?void 0:t?p(e,a):e,o=d.length-1,l;o>=0;o--)(l=d[o])&&(i=(t?l(e,a,i):l(i))||i);return t&&i&&h(e,a,i),i};exports.LogosphereTab=class extends s.LitElement{constructor(){super(...arguments),this.tabs=[],this.activeTab="",this.lazy=!0,this.variant="default",this._focusedIndex=0,this._renderedTabs=new Set}connectedCallback(){super.connectedCallback(),!this.activeTab&&this.tabs.length>0&&(this.activeTab=this.tabs[0].id)}willUpdate(e){if(super.willUpdate(e),e.has("activeTab")&&this.activeTab){this._renderedTabs.add(this.activeTab);const a=this.tabs.findIndex(t=>t.id===this.activeTab);a!==-1&&(this._focusedIndex=a)}e.has("tabs")&&this.tabs.length>0&&(this.tabs.some(t=>t.id===this.activeTab)||(this.activeTab=this.tabs[0].id),this._focusedIndex=this.tabs.findIndex(t=>t.id===this.activeTab))}handleTabClick(e,a){if(a)return;const t=this.activeTab;this.activeTab=e,this._focusedIndex=this.tabs.findIndex(i=>i.id===e),this.dispatchEvent(new CustomEvent("tab-change",{detail:{oldTab:t,newTab:e},bubbles:!0,composed:!0}))}handleKeyDown(e){const{tabs:a}=this;if(a.filter(o=>!o.disabled).length===0)return;let t=this._focusedIndex;const i=this._focusedIndex;switch(e.key){case"ArrowLeft":e.preventDefault();do t=t>0?t-1:a.length-1;while(a[t]?.disabled&&t!==i);break;case"ArrowRight":e.preventDefault();do t=t<a.length-1?t+1:0;while(a[t]?.disabled&&t!==i);break;case"Home":for(e.preventDefault(),t=0;a[t]?.disabled&&t<a.length-1;)t++;break;case"End":for(e.preventDefault(),t=a.length-1;a[t]?.disabled&&t>0;)t--;break;default:return}if(t!==this._focusedIndex&&!a[t]?.disabled){const o=this.activeTab;this._focusedIndex=t,this.activeTab=a[t].id,this.updateComplete.then(()=>{this.shadowRoot?.querySelector(`[role="tab"][data-tab-id="${a[t].id}"]`)?.focus()}),this.dispatchEvent(new CustomEvent("tab-change",{detail:{oldTab:o,newTab:a[t].id},bubbles:!0,composed:!0}))}}scrollTabIntoView(e){this.updateComplete.then(()=>{const a=this.shadowRoot?.querySelector(`[role="tab"][data-tab-id="${e}"]`);if(a&&this.tablist){const t=this.tablist.getBoundingClientRect(),i=a.getBoundingClientRect();i.left<t.left?this.tablist.scrollLeft-=t.left-i.left+16:i.right>t.right&&(this.tablist.scrollLeft+=i.right-t.right+16)}})}renderTabButton(e,a){const t=this.activeTab===e.id,i=this._focusedIndex===a,o=["tab__button",t?"tab__button--active":"",e.disabled?"tab__button--disabled":""].filter(Boolean).join(" "),l=["tab__label",t?"":"tab__label--inactive"].filter(Boolean).join(" "),b=["tab__description",t?"tab__description--active":""].filter(Boolean).join(" ");return s.html`
|
|
2
|
+
<button
|
|
3
|
+
role="tab"
|
|
4
|
+
class=${o}
|
|
5
|
+
data-tab-id=${e.id}
|
|
6
|
+
aria-selected=${t?"true":"false"}
|
|
7
|
+
aria-controls="panel-${e.id}"
|
|
8
|
+
tabindex=${t||i?"0":"-1"}
|
|
9
|
+
?disabled=${e.disabled}
|
|
10
|
+
@click=${()=>this.handleTabClick(e.id,e.disabled)}
|
|
11
|
+
@focus=${()=>this.scrollTabIntoView(e.id)}
|
|
12
|
+
>
|
|
13
|
+
${e.icon?s.html`<i class="${e.icon} tab__icon"></i>`:s.nothing}
|
|
14
|
+
<div class="tab__content">
|
|
15
|
+
<span class=${l}>${e.label}</span>
|
|
16
|
+
${e.description?s.html`<span class=${b}>${e.description}</span>`:s.nothing}
|
|
17
|
+
</div>
|
|
18
|
+
</button>
|
|
19
|
+
`}renderTabPanel(e){const a=this.activeTab===e.id;if(!(!this.lazy||this._renderedTabs.has(e.id)))return s.nothing;const i=["tab__panel",a?"":"tab__panel--hidden"].filter(Boolean).join(" ");return s.html`
|
|
20
|
+
<div
|
|
21
|
+
role="tabpanel"
|
|
22
|
+
id="panel-${e.id}"
|
|
23
|
+
aria-labelledby="tab-${e.id}"
|
|
24
|
+
class=${i}
|
|
25
|
+
tabindex="0"
|
|
26
|
+
>
|
|
27
|
+
<slot name=${`panel-${e.id}`}>
|
|
28
|
+
${typeof e.content=="string"?s.html`${e.content}`:s.nothing}
|
|
29
|
+
</slot>
|
|
30
|
+
</div>
|
|
31
|
+
`}render(){return s.html`
|
|
32
|
+
<div class="tab">
|
|
33
|
+
<div role="tablist" aria-label="Tabs" class="tab__list" @keydown=${this.handleKeyDown}>
|
|
34
|
+
${this.tabs.map((e,a)=>this.renderTabButton(e,a))}
|
|
35
|
+
</div>
|
|
36
|
+
<div class="tab__panels">${this.tabs.map(e=>this.renderTabPanel(e))}</div>
|
|
37
|
+
</div>
|
|
38
|
+
`}};exports.LogosphereTab.styles=[s.css`
|
|
39
|
+
${s.unsafeCSS(c)}
|
|
40
|
+
`];r([n.property({type:Array})],exports.LogosphereTab.prototype,"tabs",2);r([n.property({type:String})],exports.LogosphereTab.prototype,"activeTab",2);r([n.property({type:Boolean})],exports.LogosphereTab.prototype,"lazy",2);r([n.property({type:String})],exports.LogosphereTab.prototype,"variant",2);r([n.state()],exports.LogosphereTab.prototype,"_focusedIndex",2);r([n.state()],exports.LogosphereTab.prototype,"_renderedTabs",2);r([n.query('[role="tablist"]')],exports.LogosphereTab.prototype,"tablist",2);exports.LogosphereTab=r([n.customElement("logosphere-tab")],exports.LogosphereTab);
|
package/dist/tab.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./tab-DcjAlXzU.cjs");Object.defineProperty(exports,"LogosphereTab",{enumerable:!0,get:()=>e.LogosphereTab});
|
package/dist/tab.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { unsafeCSS as d, css as y, LitElement as c, nothing as l, html as u } from "lit";
|
|
2
|
+
import { query as m, property as i, state as _, customElement as v } from "lit/decorators.js";
|
|
3
|
+
import { live as f } from "lit/directives/live.js";
|
|
4
|
+
import "./formfield-BOgRugzm.js";
|
|
5
|
+
import "./ui-icon-ltkJROhR.js";
|
|
6
|
+
const b = ".textarea__field{width:100%;background:transparent;border:none;outline:none;font-size:var(--font-size-sm);font-family:var(--font-family-base);color:var(--color-body-text);box-sizing:border-box;line-height:1.5}.textarea__field::placeholder{color:var(--color-tertiary)}.textarea__field:disabled{cursor:not-allowed}.textarea__field--resize-none{resize:none}.textarea__field--resize-vertical{resize:vertical}.textarea__field--resize-horizontal{resize:horizontal}.textarea__field--resize-both{resize:both}.textarea__field--auto-resize{resize:none;overflow:hidden}.textarea__clear-btn{border:none;background:transparent;color:var(--color-gray-400);cursor:pointer;padding:0;display:inline-flex;align-items:flex-start;align-self:flex-start;margin-top:var(--spacing-1);outline:none;flex-shrink:0;transition:color var(--transition-speed-fast) var(--transition-timing)}.textarea__clear-btn:hover{color:var(--color-gray-600)}";
|
|
7
|
+
var x = Object.defineProperty, g = Object.getOwnPropertyDescriptor, r = (e, a, s, n) => {
|
|
8
|
+
for (var o = n > 1 ? void 0 : n ? g(a, s) : a, h = e.length - 1, p; h >= 0; h--)
|
|
9
|
+
(p = e[h]) && (o = (n ? p(a, s, o) : p(o)) || o);
|
|
10
|
+
return n && o && x(a, s, o), o;
|
|
11
|
+
};
|
|
12
|
+
let t = class extends c {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.value = "", this.placeholder = "", this.name = "", this.autocomplete = "", this.rows = 3, this.wrap = "soft", this.resize = "vertical", this.autoResize = !1, this.size = "default", this.variant = "default", this.showClear = !1, this.label = "", this.helper = "", this.error = "", this.required = !1, this.disabled = !1, this.readonly = !1, this._internalError = "", this.handleInput = (e) => {
|
|
15
|
+
const a = e.target;
|
|
16
|
+
this.value = a.value, this.autoResize && this.adjustHeight(), this._internalError && (this._internalError = "", this._textareaElement.setCustomValidity("")), this.dispatchEvent(new CustomEvent("input", {
|
|
17
|
+
bubbles: !0,
|
|
18
|
+
composed: !0,
|
|
19
|
+
detail: { value: this.value, originalEvent: e }
|
|
20
|
+
}));
|
|
21
|
+
}, this.handleChange = (e) => {
|
|
22
|
+
const a = e.target;
|
|
23
|
+
this.value = a.value, a.checkValidity() || (this._internalError = a.validationMessage), this.dispatchEvent(new CustomEvent("change", {
|
|
24
|
+
bubbles: !0,
|
|
25
|
+
composed: !0,
|
|
26
|
+
detail: { value: this.value, originalEvent: e }
|
|
27
|
+
}));
|
|
28
|
+
}, this.handleKeyDown = (e) => {
|
|
29
|
+
this.dispatchEvent(new CustomEvent("keydown", {
|
|
30
|
+
bubbles: !0,
|
|
31
|
+
composed: !0,
|
|
32
|
+
detail: { key: e.key, originalEvent: e }
|
|
33
|
+
}));
|
|
34
|
+
}, this.handleKeyUp = (e) => {
|
|
35
|
+
this.dispatchEvent(new CustomEvent("keyup", {
|
|
36
|
+
bubbles: !0,
|
|
37
|
+
composed: !0,
|
|
38
|
+
detail: { key: e.key, originalEvent: e }
|
|
39
|
+
}));
|
|
40
|
+
}, this.handleClear = () => {
|
|
41
|
+
this.value = "", this._textareaElement && (this._textareaElement.value = "", this.autoResize && this.adjustHeight()), this.dispatchEvent(new CustomEvent("clear", { bubbles: !0, composed: !0 })), this.dispatchEvent(new CustomEvent("input", {
|
|
42
|
+
bubbles: !0,
|
|
43
|
+
composed: !0,
|
|
44
|
+
detail: { value: "", originalEvent: null }
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
get textareaElement() {
|
|
49
|
+
return this._textareaElement;
|
|
50
|
+
}
|
|
51
|
+
focus() {
|
|
52
|
+
this._textareaElement?.focus();
|
|
53
|
+
}
|
|
54
|
+
blur() {
|
|
55
|
+
this._textareaElement?.blur();
|
|
56
|
+
}
|
|
57
|
+
select() {
|
|
58
|
+
this._textareaElement?.select();
|
|
59
|
+
}
|
|
60
|
+
setSelectionRange(e, a, s) {
|
|
61
|
+
this._textareaElement?.setSelectionRange(e, a, s);
|
|
62
|
+
}
|
|
63
|
+
checkValidity() {
|
|
64
|
+
return this._textareaElement?.checkValidity() ?? !0;
|
|
65
|
+
}
|
|
66
|
+
reportValidity() {
|
|
67
|
+
return this._textareaElement?.reportValidity() ?? !0;
|
|
68
|
+
}
|
|
69
|
+
setCustomValidity(e) {
|
|
70
|
+
this._textareaElement?.setCustomValidity(e), this._internalError = e, this.requestUpdate();
|
|
71
|
+
}
|
|
72
|
+
adjustHeight() {
|
|
73
|
+
!this.autoResize || !this._textareaElement || (this._textareaElement.style.height = "auto", this._textareaElement.style.height = `${this._textareaElement.scrollHeight}px`);
|
|
74
|
+
}
|
|
75
|
+
updated(e) {
|
|
76
|
+
super.updated(e), e.has("value") && this.autoResize && this.adjustHeight();
|
|
77
|
+
}
|
|
78
|
+
getResizeClass() {
|
|
79
|
+
return this.autoResize ? "textarea__field--auto-resize" : {
|
|
80
|
+
none: "textarea__field--resize-none",
|
|
81
|
+
vertical: "textarea__field--resize-vertical",
|
|
82
|
+
horizontal: "textarea__field--resize-horizontal",
|
|
83
|
+
both: "textarea__field--resize-both"
|
|
84
|
+
}[this.resize];
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
const e = this.error || this._internalError, a = this.showClear && this.value && !this.disabled && !this.readonly, s = `textarea__field ${this.getResizeClass()}`;
|
|
88
|
+
return u`
|
|
89
|
+
<logosphere-formfield
|
|
90
|
+
.label=${this.label}
|
|
91
|
+
.helper=${this.helper}
|
|
92
|
+
.error=${e}
|
|
93
|
+
.required=${this.required}
|
|
94
|
+
.disabled=${this.disabled}
|
|
95
|
+
.readonly=${this.readonly}
|
|
96
|
+
.placeholder=${this.placeholder}
|
|
97
|
+
.size=${this.size}
|
|
98
|
+
.variant=${this.variant}
|
|
99
|
+
>
|
|
100
|
+
<textarea
|
|
101
|
+
class="${s}"
|
|
102
|
+
.value=${f(this.value)}
|
|
103
|
+
placeholder=${this.placeholder || l}
|
|
104
|
+
name=${this.name || l}
|
|
105
|
+
autocomplete=${this.autocomplete || l}
|
|
106
|
+
?required=${this.required}
|
|
107
|
+
?disabled=${this.disabled}
|
|
108
|
+
?readonly=${this.readonly}
|
|
109
|
+
minlength=${this.minlength ?? l}
|
|
110
|
+
maxlength=${this.maxlength ?? l}
|
|
111
|
+
rows=${this.rows}
|
|
112
|
+
cols=${this.cols ?? l}
|
|
113
|
+
wrap=${this.wrap}
|
|
114
|
+
@input=${this.handleInput}
|
|
115
|
+
@change=${this.handleChange}
|
|
116
|
+
@keydown=${this.handleKeyDown}
|
|
117
|
+
@keyup=${this.handleKeyUp}
|
|
118
|
+
></textarea>
|
|
119
|
+
${a ? u`
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
slot="suffix"
|
|
123
|
+
class="textarea__clear-btn"
|
|
124
|
+
@click=${this.handleClear}
|
|
125
|
+
tabindex="-1"
|
|
126
|
+
>
|
|
127
|
+
<ui-icon name="uil-times" size="14"></ui-icon>
|
|
128
|
+
</button>
|
|
129
|
+
` : l}
|
|
130
|
+
</logosphere-formfield>
|
|
131
|
+
`;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
t.styles = [y`${d(b)}`];
|
|
135
|
+
r([
|
|
136
|
+
m("textarea")
|
|
137
|
+
], t.prototype, "_textareaElement", 2);
|
|
138
|
+
r([
|
|
139
|
+
i({ type: String })
|
|
140
|
+
], t.prototype, "value", 2);
|
|
141
|
+
r([
|
|
142
|
+
i({ type: String })
|
|
143
|
+
], t.prototype, "placeholder", 2);
|
|
144
|
+
r([
|
|
145
|
+
i({ type: String })
|
|
146
|
+
], t.prototype, "name", 2);
|
|
147
|
+
r([
|
|
148
|
+
i({ type: String })
|
|
149
|
+
], t.prototype, "autocomplete", 2);
|
|
150
|
+
r([
|
|
151
|
+
i({ type: Number })
|
|
152
|
+
], t.prototype, "minlength", 2);
|
|
153
|
+
r([
|
|
154
|
+
i({ type: Number })
|
|
155
|
+
], t.prototype, "maxlength", 2);
|
|
156
|
+
r([
|
|
157
|
+
i({ type: Number })
|
|
158
|
+
], t.prototype, "rows", 2);
|
|
159
|
+
r([
|
|
160
|
+
i({ type: Number })
|
|
161
|
+
], t.prototype, "cols", 2);
|
|
162
|
+
r([
|
|
163
|
+
i({ type: String })
|
|
164
|
+
], t.prototype, "wrap", 2);
|
|
165
|
+
r([
|
|
166
|
+
i({ type: String })
|
|
167
|
+
], t.prototype, "resize", 2);
|
|
168
|
+
r([
|
|
169
|
+
i({ type: Boolean })
|
|
170
|
+
], t.prototype, "autoResize", 2);
|
|
171
|
+
r([
|
|
172
|
+
i({ type: String })
|
|
173
|
+
], t.prototype, "size", 2);
|
|
174
|
+
r([
|
|
175
|
+
i({ type: String })
|
|
176
|
+
], t.prototype, "variant", 2);
|
|
177
|
+
r([
|
|
178
|
+
i({ type: Boolean })
|
|
179
|
+
], t.prototype, "showClear", 2);
|
|
180
|
+
r([
|
|
181
|
+
i({ type: String })
|
|
182
|
+
], t.prototype, "label", 2);
|
|
183
|
+
r([
|
|
184
|
+
i({ type: String })
|
|
185
|
+
], t.prototype, "helper", 2);
|
|
186
|
+
r([
|
|
187
|
+
i({ type: String })
|
|
188
|
+
], t.prototype, "error", 2);
|
|
189
|
+
r([
|
|
190
|
+
i({ type: Boolean })
|
|
191
|
+
], t.prototype, "required", 2);
|
|
192
|
+
r([
|
|
193
|
+
i({ type: Boolean })
|
|
194
|
+
], t.prototype, "disabled", 2);
|
|
195
|
+
r([
|
|
196
|
+
i({ type: Boolean })
|
|
197
|
+
], t.prototype, "readonly", 2);
|
|
198
|
+
r([
|
|
199
|
+
_()
|
|
200
|
+
], t.prototype, "_internalError", 2);
|
|
201
|
+
t = r([
|
|
202
|
+
v("logosphere-textarea")
|
|
203
|
+
], t);
|
|
204
|
+
export {
|
|
205
|
+
t as T
|
|
206
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";const i=require("lit"),t=require("lit/decorators.js"),p=require("lit/directives/live.js");require("./formfield-D_7NFFoe.cjs");require("./ui-icon-CVEyvL5D.cjs");const u=".textarea__field{width:100%;background:transparent;border:none;outline:none;font-size:var(--font-size-sm);font-family:var(--font-family-base);color:var(--color-body-text);box-sizing:border-box;line-height:1.5}.textarea__field::placeholder{color:var(--color-tertiary)}.textarea__field:disabled{cursor:not-allowed}.textarea__field--resize-none{resize:none}.textarea__field--resize-vertical{resize:vertical}.textarea__field--resize-horizontal{resize:horizontal}.textarea__field--resize-both{resize:both}.textarea__field--auto-resize{resize:none;overflow:hidden}.textarea__clear-btn{border:none;background:transparent;color:var(--color-gray-400);cursor:pointer;padding:0;display:inline-flex;align-items:flex-start;align-self:flex-start;margin-top:var(--spacing-1);outline:none;flex-shrink:0;transition:color var(--transition-speed-fast) var(--transition-timing)}.textarea__clear-btn:hover{color:var(--color-gray-600)}";var d=Object.defineProperty,y=Object.getOwnPropertyDescriptor,r=(l,e,a,o)=>{for(var s=o>1?void 0:o?y(e,a):e,n=l.length-1,h;n>=0;n--)(h=l[n])&&(s=(o?h(e,a,s):h(s))||s);return o&&s&&d(e,a,s),s};exports.TextArea=class extends i.LitElement{constructor(){super(...arguments),this.value="",this.placeholder="",this.name="",this.autocomplete="",this.rows=3,this.wrap="soft",this.resize="vertical",this.autoResize=!1,this.size="default",this.variant="default",this.showClear=!1,this.label="",this.helper="",this.error="",this.required=!1,this.disabled=!1,this.readonly=!1,this._internalError="",this.handleInput=e=>{const a=e.target;this.value=a.value,this.autoResize&&this.adjustHeight(),this._internalError&&(this._internalError="",this._textareaElement.setCustomValidity("")),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{value:this.value,originalEvent:e}}))},this.handleChange=e=>{const a=e.target;this.value=a.value,a.checkValidity()||(this._internalError=a.validationMessage),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:{value:this.value,originalEvent:e}}))},this.handleKeyDown=e=>{this.dispatchEvent(new CustomEvent("keydown",{bubbles:!0,composed:!0,detail:{key:e.key,originalEvent:e}}))},this.handleKeyUp=e=>{this.dispatchEvent(new CustomEvent("keyup",{bubbles:!0,composed:!0,detail:{key:e.key,originalEvent:e}}))},this.handleClear=()=>{this.value="",this._textareaElement&&(this._textareaElement.value="",this.autoResize&&this.adjustHeight()),this.dispatchEvent(new CustomEvent("clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0,detail:{value:"",originalEvent:null}}))}}get textareaElement(){return this._textareaElement}focus(){this._textareaElement?.focus()}blur(){this._textareaElement?.blur()}select(){this._textareaElement?.select()}setSelectionRange(e,a,o){this._textareaElement?.setSelectionRange(e,a,o)}checkValidity(){return this._textareaElement?.checkValidity()??!0}reportValidity(){return this._textareaElement?.reportValidity()??!0}setCustomValidity(e){this._textareaElement?.setCustomValidity(e),this._internalError=e,this.requestUpdate()}adjustHeight(){!this.autoResize||!this._textareaElement||(this._textareaElement.style.height="auto",this._textareaElement.style.height=`${this._textareaElement.scrollHeight}px`)}updated(e){super.updated(e),e.has("value")&&this.autoResize&&this.adjustHeight()}getResizeClass(){return this.autoResize?"textarea__field--auto-resize":{none:"textarea__field--resize-none",vertical:"textarea__field--resize-vertical",horizontal:"textarea__field--resize-horizontal",both:"textarea__field--resize-both"}[this.resize]}render(){const e=this.error||this._internalError,a=this.showClear&&this.value&&!this.disabled&&!this.readonly,o=`textarea__field ${this.getResizeClass()}`;return i.html`
|
|
2
|
+
<logosphere-formfield
|
|
3
|
+
.label=${this.label}
|
|
4
|
+
.helper=${this.helper}
|
|
5
|
+
.error=${e}
|
|
6
|
+
.required=${this.required}
|
|
7
|
+
.disabled=${this.disabled}
|
|
8
|
+
.readonly=${this.readonly}
|
|
9
|
+
.placeholder=${this.placeholder}
|
|
10
|
+
.size=${this.size}
|
|
11
|
+
.variant=${this.variant}
|
|
12
|
+
>
|
|
13
|
+
<textarea
|
|
14
|
+
class="${o}"
|
|
15
|
+
.value=${p.live(this.value)}
|
|
16
|
+
placeholder=${this.placeholder||i.nothing}
|
|
17
|
+
name=${this.name||i.nothing}
|
|
18
|
+
autocomplete=${this.autocomplete||i.nothing}
|
|
19
|
+
?required=${this.required}
|
|
20
|
+
?disabled=${this.disabled}
|
|
21
|
+
?readonly=${this.readonly}
|
|
22
|
+
minlength=${this.minlength??i.nothing}
|
|
23
|
+
maxlength=${this.maxlength??i.nothing}
|
|
24
|
+
rows=${this.rows}
|
|
25
|
+
cols=${this.cols??i.nothing}
|
|
26
|
+
wrap=${this.wrap}
|
|
27
|
+
@input=${this.handleInput}
|
|
28
|
+
@change=${this.handleChange}
|
|
29
|
+
@keydown=${this.handleKeyDown}
|
|
30
|
+
@keyup=${this.handleKeyUp}
|
|
31
|
+
></textarea>
|
|
32
|
+
${a?i.html`
|
|
33
|
+
<button
|
|
34
|
+
type="button"
|
|
35
|
+
slot="suffix"
|
|
36
|
+
class="textarea__clear-btn"
|
|
37
|
+
@click=${this.handleClear}
|
|
38
|
+
tabindex="-1"
|
|
39
|
+
>
|
|
40
|
+
<ui-icon name="uil-times" size="14"></ui-icon>
|
|
41
|
+
</button>
|
|
42
|
+
`:i.nothing}
|
|
43
|
+
</logosphere-formfield>
|
|
44
|
+
`}};exports.TextArea.styles=[i.css`${i.unsafeCSS(u)}`];r([t.query("textarea")],exports.TextArea.prototype,"_textareaElement",2);r([t.property({type:String})],exports.TextArea.prototype,"value",2);r([t.property({type:String})],exports.TextArea.prototype,"placeholder",2);r([t.property({type:String})],exports.TextArea.prototype,"name",2);r([t.property({type:String})],exports.TextArea.prototype,"autocomplete",2);r([t.property({type:Number})],exports.TextArea.prototype,"minlength",2);r([t.property({type:Number})],exports.TextArea.prototype,"maxlength",2);r([t.property({type:Number})],exports.TextArea.prototype,"rows",2);r([t.property({type:Number})],exports.TextArea.prototype,"cols",2);r([t.property({type:String})],exports.TextArea.prototype,"wrap",2);r([t.property({type:String})],exports.TextArea.prototype,"resize",2);r([t.property({type:Boolean})],exports.TextArea.prototype,"autoResize",2);r([t.property({type:String})],exports.TextArea.prototype,"size",2);r([t.property({type:String})],exports.TextArea.prototype,"variant",2);r([t.property({type:Boolean})],exports.TextArea.prototype,"showClear",2);r([t.property({type:String})],exports.TextArea.prototype,"label",2);r([t.property({type:String})],exports.TextArea.prototype,"helper",2);r([t.property({type:String})],exports.TextArea.prototype,"error",2);r([t.property({type:Boolean})],exports.TextArea.prototype,"required",2);r([t.property({type:Boolean})],exports.TextArea.prototype,"disabled",2);r([t.property({type:Boolean})],exports.TextArea.prototype,"readonly",2);r([t.state()],exports.TextArea.prototype,"_internalError",2);exports.TextArea=r([t.customElement("logosphere-textarea")],exports.TextArea);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./text-area-eT-oCnqZ.cjs");Object.defineProperty(exports,"TextArea",{enumerable:!0,get:()=>e.TextArea});
|
package/dist/textarea.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";const a=require("lit"),l=require("lit/directives/unsafe-html.js"),n='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13.41,12l4.3-4.29a1,1,0,1,0-1.42-1.42L12,10.59,7.71,6.29A1,1,0,0,0,6.29,7.71L10.59,12l-4.3,4.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L12,13.41l4.29,4.3a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42Z"/></svg>',w='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17,9.17a1,1,0,0,0-1.41,0L12,12.71,8.46,9.17a1,1,0,0,0-1.41,0,1,1,0,0,0,0,1.42l4.24,4.24a1,1,0,0,0,1.42,0L17,10.59A1,1,0,0,0,17,9.17Z"/></svg>',h='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19,4H17V3a1,1,0,0,0-2,0V4H9V3A1,1,0,0,0,7,3V4H5A3,3,0,0,0,2,7V19a3,3,0,0,0,3,3H19a3,3,0,0,0,3-3V7A3,3,0,0,0,19,4Zm1,15a1,1,0,0,1-1,1H5a1,1,0,0,1-1-1V12H20Zm0-9H4V7A1,1,0,0,1,5,6H7V7A1,1,0,0,0,9,7V6h6V7a1,1,0,0,0,2,0V6h2a1,1,0,0,1,1,1Z"/></svg>',i='<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 24 24"><path d="M17,11H9.41l3.3-3.29a1,1,0,1,0-1.42-1.42l-5,5a1,1,0,0,0-.21.33,1,1,0,0,0,0,.76,1,1,0,0,0,.21.33l5,5a1,1,0,0,0,1.42,0,1,1,0,0,0,0-1.42L9.41,13H17a1,1,0,0,0,0-2Z"/></svg>',o='<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 24 24"><path d="M17.92,11.62a1,1,0,0,0-.21-.33l-5-5a1,1,0,0,0-1.42,1.42L14.59,11H7a1,1,0,0,0,0,2h7.59l-3.3,3.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0l5-5a1,1,0,0,0,.21-.33A1,1,0,0,0,17.92,11.62Z"/></svg>',r='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20,6H16V5a3,3,0,0,0-3-3H11A3,3,0,0,0,8,5V6H4A1,1,0,0,0,4,8H5V19a3,3,0,0,0,3,3h8a3,3,0,0,0,3-3V8h1a1,1,0,0,0,0-2ZM10,5a1,1,0,0,1,1-1h2a1,1,0,0,1,1,1V6H10Zm7,14a1,1,0,0,1-1,1H8a1,1,0,0,1-1-1V8H17Z"/></svg>',g='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21.71,2.29a1,1,0,0,0-1.42,0L14.5,8.09V6.5a1,1,0,0,0-2,0v4a1,1,0,0,0,.08.38,1,1,0,0,0,.54.54,1,1,0,0,0,.38.08h4a1,1,0,0,0,0-2H15.91l5.8-5.79A1,1,0,0,0,21.71,2.29ZM10.88,12.58a1,1,0,0,0-.38-.08h-4a1,1,0,0,0,0,2H8.09l-5.8,5.79a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0l5.79-5.8V17.5a1,1,0,0,0,2,0v-4a1,1,0,0,0-.08-.38A1,1,0,0,0,10.88,12.58Z"/></svg>',v='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.79,12.79,4,18.59V17a1,1,0,0,0-2,0v4a1,1,0,0,0,.08.38,1,1,0,0,0,.54.54A1,1,0,0,0,3,22H7a1,1,0,0,0,0-2H5.41l5.8-5.79a1,1,0,0,0-1.42-1.42ZM21.92,2.62a1,1,0,0,0-.54-.54A1,1,0,0,0,21,2H17a1,1,0,0,0,0,2h1.59l-5.8,5.79a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0L20,5.41V7a1,1,0,0,0,2,0V3A1,1,0,0,0,21.92,2.62Z"/></svg>',H='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21,8.94a1.31,1.31,0,0,0-.06-.27l0-.09a1.07,1.07,0,0,0-.19-.28h0l-6-6h0a1.07,1.07,0,0,0-.28-.19.32.32,0,0,0-.09,0A.88.88,0,0,0,14.05,2H10A3,3,0,0,0,7,5V6H6A3,3,0,0,0,3,9V19a3,3,0,0,0,3,3h8a3,3,0,0,0,3-3V18h1a3,3,0,0,0,3-3V9S21,9,21,8.94ZM15,5.41,17.59,8H16a1,1,0,0,1-1-1ZM15,19a1,1,0,0,1-1,1H6a1,1,0,0,1-1-1V9A1,1,0,0,1,6,8H7v7a3,3,0,0,0,3,3h5Zm4-4a1,1,0,0,1-1,1H10a1,1,0,0,1-1-1V5a1,1,0,0,1,1-1h3V7a3,3,0,0,0,3,3h3Z"/></svg>',m='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21.3,10.08A3,3,0,0,0,19,9H14.44L15,7.57A4.13,4.13,0,0,0,11.11,2a1,1,0,0,0-.91.59L7.35,9H5a3,3,0,0,0-3,3v7a3,3,0,0,0,3,3H17.73a3,3,0,0,0,2.95-2.46l1.27-7A3,3,0,0,0,21.3,10.08ZM7,20H5a1,1,0,0,1-1-1V12a1,1,0,0,1,1-1H7Zm13-7.82-1.27,7a1,1,0,0,1-1,.82H9V10.21l2.72-6.12A2.11,2.11,0,0,1,13.1,6.87L12.57,8.3A2,2,0,0,0,14.44,11H19a1,1,0,0,1,.77.36A1,1,0,0,1,20,12.18Z"/></svg>',p='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19,2H6.27A3,3,0,0,0,3.32,4.46l-1.27,7A3,3,0,0,0,5,15H9.56L9,16.43A4.13,4.13,0,0,0,12.89,22a1,1,0,0,0,.91-.59L16.65,15H19a3,3,0,0,0,3-3V5A3,3,0,0,0,19,2ZM15,13.79l-2.72,6.12a2.13,2.13,0,0,1-1.38-2.78l.53-1.43A2,2,0,0,0,9.56,13H5a1,1,0,0,1-.77-.36A1,1,0,0,1,4,11.82l1.27-7a1,1,0,0,1,1-.82H15ZM20,12a1,1,0,0,1-1,1H17V4h2a1,1,0,0,1,1,1Z"/></svg>',c='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.71,12.71a1,1,0,0,0,.21-.33,1,1,0,0,0,0-.76,1,1,0,0,0-.21-.33l-3-3a1,1,0,0,0-1.42,1.42L12.59,11H9a1,1,0,0,0,0,2h3.59l-1.3,1.29a1,1,0,0,0,0,1.42,1,1,0,0,0,1.42,0ZM22,12A10,10,0,1,0,12,22,10,10,0,0,0,22,12ZM4,12a8,8,0,1,1,8,8A8,8,0,0,1,4,12Z"/></svg>',A={"uil-times":n,"uil-angle-down":w,"uil-calendar":h,"uil-arrow-left":i,"uil-arrow-right":o,"uil-trash":r,"uil-compress-alt":g,"uil-expand-alt":v,"uil-copy":H,"uil-thumbs-up":m,"uil-thumbs-down":p,"uil-arrow-circle-right":c},t=class t extends a.LitElement{constructor(){super(...arguments),this.name="",this.size=20}render(){const e=A[this.name];return e?a.html`
|
|
2
|
+
<span
|
|
3
|
+
style="font-size: ${this.size}px;"
|
|
4
|
+
aria-hidden="true"
|
|
5
|
+
>
|
|
6
|
+
${l.unsafeHTML(e)}
|
|
7
|
+
</span>
|
|
8
|
+
`:(console.warn(`Icon "${this.name}" not found.`),a.html``)}};t.properties={name:{type:String},size:{type:Number}},t.styles=a.css`
|
|
9
|
+
:host {
|
|
10
|
+
display: inline-flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
line-height: 0;
|
|
14
|
+
color: inherit;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
svg {
|
|
18
|
+
width: 1em;
|
|
19
|
+
height: 1em;
|
|
20
|
+
fill: currentColor;
|
|
21
|
+
}
|
|
22
|
+
`;let s=t;customElements.define("ui-icon",s);
|