@vverchonov/web-components 0.1.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/button-DYrT530y.js +39 -0
- package/dist/button.js +2 -0
- package/dist/components/button/button-types.d.ts +2 -0
- package/dist/components/button/button.d.ts +14 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/dropdown-button/dropdown-button-types.d.ts +13 -0
- package/dist/components/dropdown-button/dropdown-button.d.ts +34 -0
- package/dist/components/dropdown-button/index.d.ts +2 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/input-types.d.ts +2 -0
- package/dist/components/input/input.d.ts +22 -0
- package/dist/components/layouts/form/form-layout-types.d.ts +3 -0
- package/dist/components/layouts/form/form-layout.d.ts +53 -0
- package/dist/components/layouts/form/index.d.ts +2 -0
- package/dist/components/layouts/index.d.ts +3 -0
- package/dist/components/layouts/page/index.d.ts +1 -0
- package/dist/components/layouts/page/layout.d.ts +20 -0
- package/dist/components/menu/index.d.ts +2 -0
- package/dist/components/menu/menu-types.d.ts +16 -0
- package/dist/components/menu/menu.d.ts +36 -0
- package/dist/components/modal/index.d.ts +2 -0
- package/dist/components/modal/modal-types.d.ts +2 -0
- package/dist/components/modal/modal.d.ts +103 -0
- package/dist/components/selector/index.d.ts +2 -0
- package/dist/components/selector/selector-types.d.ts +19 -0
- package/dist/components/selector/selector.d.ts +56 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/table-types.d.ts +35 -0
- package/dist/components/table/table.d.ts +47 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/tabs.d.ts +19 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/toggle-types.d.ts +4 -0
- package/dist/components/toggle/toggle.d.ts +15 -0
- package/dist/dropdown-button-B6XNoy4L.js +172 -0
- package/dist/dropdown-button.js +2 -0
- package/dist/form-layout-DCX8X-8-.js +140 -0
- package/dist/index.d.ts +22 -0
- package/dist/input-BVlPYqTe.js +70 -0
- package/dist/input.js +2 -0
- package/dist/layout-CYvgu_WE.js +23 -0
- package/dist/layouts.js +3 -0
- package/dist/menu-DmAFaVi5.js +248 -0
- package/dist/menu.js +2 -0
- package/dist/mock/table-data.d.ts +16 -0
- package/dist/modal-v1GlqMF_.js +174 -0
- package/dist/modal.js +2 -0
- package/dist/react/button.d.ts +2 -0
- package/dist/react/button.js +9 -0
- package/dist/react/dropdown-button.d.ts +6 -0
- package/dist/react/dropdown-button.js +10 -0
- package/dist/react/form-layout.d.ts +8 -0
- package/dist/react/form-layout.js +14 -0
- package/dist/react/index.d.ts +21 -0
- package/dist/react/input.d.ts +2 -0
- package/dist/react/input.js +9 -0
- package/dist/react/layout.d.ts +2 -0
- package/dist/react/layout.js +9 -0
- package/dist/react/menu.d.ts +7 -0
- package/dist/react/menu.js +13 -0
- package/dist/react/modal.d.ts +7 -0
- package/dist/react/modal.js +14 -0
- package/dist/react/selector.d.ts +6 -0
- package/dist/react/selector.js +10 -0
- package/dist/react/table.d.ts +8 -0
- package/dist/react/table.js +14 -0
- package/dist/react/tabs.d.ts +5 -0
- package/dist/react/tabs.js +10 -0
- package/dist/react/toggle.d.ts +6 -0
- package/dist/react/toggle.js +10 -0
- package/dist/react.js +12 -0
- package/dist/selector-Bl7Nbkqo.js +300 -0
- package/dist/selector.js +2 -0
- package/dist/styles/tailwind-base.d.ts +1 -0
- package/dist/table--O5km0Wv.js +279 -0
- package/dist/table.js +2 -0
- package/dist/tabs-C2lP0uxY.js +94 -0
- package/dist/tabs.js +2 -0
- package/dist/toggle-D6UMZ8UZ.js +59 -0
- package/dist/toggle.js +2 -0
- package/dist/vite.svg +1 -0
- package/dist/web-components.js +24 -0
- package/package.json +153 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { LitElement as e, html as t, nothing as n, unsafeCSS as r } from "lit";
|
|
2
|
+
import { customElement as i, property as a, state as o } from "lit/decorators.js";
|
|
3
|
+
import { repeat as s } from "lit/directives/repeat.js";
|
|
4
|
+
var c = ":host{display:inline-block;position:relative}.trigger{align-items:center;gap:var(--button-icon-gap);margin:var(--button-margin-block) var(--button-margin-inline);padding:var(--button-padding-block) var(--button-padding-inline);font-size:var(--button-font-size);font-weight:var(--button-font-weight);border-radius:var(--radius-button);background:var(--color-primary);color:var(--color-text-inverse);cursor:pointer;transition:background-color var(--button-transition-duration) var(--ease-emphasized);border:none;display:inline-flex}.trigger:hover{background:var(--color-primary-hover)}.trigger:focus{outline:none}.trigger .icon-wrapper{align-items:center;display:inline-flex}.trigger .icon-wrapper:not(:has(*)){display:none}.trigger .label{display:inline}.trigger .label:empty{display:none}.chevron{transition:transform var(--button-transition-duration) var(--ease-emphasized);justify-content:center;align-items:center;display:inline-flex}.trigger[aria-expanded=true] .chevron{transform:rotate(180deg)}.panel{z-index:9999;min-width:180px;max-width:320px;max-height:min(80vh,400px);padding:var(--dropdown-padding,.375rem);background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-card);margin:0;display:none;position:fixed;overflow-y:auto;box-shadow:0 4px 12px oklch(0% 0 0/.12)}.panel.is-open{display:block}.menu{flex-direction:column;gap:2px;margin:0;padding:0;list-style:none;display:flex}.menu-item-wrapper{flex-direction:column;display:flex}.menu-item{align-items:center;gap:var(--dropdown-item-icon-gap,.5rem);width:100%;padding:var(--dropdown-item-padding-block,.375rem) var(--dropdown-item-padding-inline,.5rem);font-size:var(--dropdown-item-font-size,.875rem);text-align:left;color:var(--color-text);border-radius:calc(var(--radius-card) - 2px);cursor:pointer;transition:background-color .15s var(--ease-emphasized);background:0 0;border:none;font-weight:400;display:flex}.menu-item:hover,.menu-item:focus{background:var(--color-primary-muted);outline:none}.menu-item.is-expanded{background:var(--color-primary-muted);color:var(--color-primary)}.menu-item .item-icon{width:1.25em;height:1.25em;color:var(--color-text-muted);flex-shrink:0;justify-content:center;align-items:center;display:inline-flex}.menu-item .item-icon:empty{display:none}.menu-item .item-label{flex:1}.menu-item .submenu-indicator{color:var(--color-text-muted);transition:transform var(--button-transition-duration) var(--ease-emphasized);flex-shrink:0;align-items:center;display:inline-flex;transform:rotate(-90deg)}.menu-item.is-expanded .submenu-indicator{color:var(--color-primary);transform:rotate(0)}.submenu{margin:2px 0 4px calc(var(--dropdown-item-padding-inline,.5rem) + .25rem);border-left:2px solid var(--color-border);padding-left:.5rem;display:none}.submenu.is-open{display:flex}";
|
|
5
|
+
function l(e, t, n, r) {
|
|
6
|
+
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
7
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
8
|
+
else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
|
|
9
|
+
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
10
|
+
}
|
|
11
|
+
var u = t`
|
|
12
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
13
|
+
<polyline points="6 9 12 15 18 9"></polyline>
|
|
14
|
+
</svg>
|
|
15
|
+
`, d = class extends e {
|
|
16
|
+
static {
|
|
17
|
+
this.styles = [r(c)];
|
|
18
|
+
}
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
super.connectedCallback(), document.addEventListener("click", this._onDocumentClick), document.addEventListener("keydown", this._onDocumentKeydown);
|
|
21
|
+
}
|
|
22
|
+
disconnectedCallback() {
|
|
23
|
+
super.disconnectedCallback(), document.removeEventListener("click", this._onDocumentClick), document.removeEventListener("keydown", this._onDocumentKeydown);
|
|
24
|
+
}
|
|
25
|
+
_toggle() {
|
|
26
|
+
this._open = !this._open, this._open || (this._openPaths = /* @__PURE__ */ new Set()), this._open && this.updateComplete.then(() => this._positionPanel());
|
|
27
|
+
}
|
|
28
|
+
_positionPanel() {
|
|
29
|
+
let e = this.shadowRoot?.querySelector(".trigger"), t = this.shadowRoot?.querySelector(".panel");
|
|
30
|
+
if (!e || !t) return;
|
|
31
|
+
let n = e.getBoundingClientRect();
|
|
32
|
+
t.style.right = "auto", t.style.bottom = "auto", t.style.top = "auto", this.placement === "top" ? (t.style.bottom = `${window.innerHeight - n.top + 4}px`, t.style.top = "auto") : t.style.top = `${n.bottom + 4}px`, t.style.left = `${n.left}px`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Toggle an inline submenu open/closed.
|
|
36
|
+
* Closing a parent also removes all its descendant paths.
|
|
37
|
+
* Opening a parent closes any sibling at the same depth+parent.
|
|
38
|
+
*/ _toggleSubmenu(e) {
|
|
39
|
+
let t = new Set(this._openPaths);
|
|
40
|
+
if (t.has(e)) for (let n of [...t]) (n === e || n.startsWith(`${e}-`)) && t.delete(n);
|
|
41
|
+
else {
|
|
42
|
+
let n = e.split("-"), r = n.length, i = n.slice(0, -1).join("-");
|
|
43
|
+
for (let e of [...t]) {
|
|
44
|
+
let n = e.split("-");
|
|
45
|
+
if (n.length === r && n.slice(0, -1).join("-") === i) for (let n of [...t]) (n === e || n.startsWith(`${e}-`)) && t.delete(n);
|
|
46
|
+
}
|
|
47
|
+
t.add(e);
|
|
48
|
+
}
|
|
49
|
+
this._openPaths = t;
|
|
50
|
+
}
|
|
51
|
+
_onTriggerKeydown(e) {
|
|
52
|
+
(e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), this._open || (this._open = !0, this._openPaths = /* @__PURE__ */ new Set(), this.updateComplete.then(() => {
|
|
53
|
+
this._positionPanel(), this.shadowRoot?.querySelector("[role=\"menuitem\"]")?.focus();
|
|
54
|
+
})));
|
|
55
|
+
}
|
|
56
|
+
_onPanelKeydown(e) {
|
|
57
|
+
let t = e.target;
|
|
58
|
+
if (t.getAttribute("role") !== "menuitem") return;
|
|
59
|
+
let n = t.closest(".menu-item-wrapper"), r = n?.getAttribute("data-path") ?? "", i = t.closest(".menu"), a = i ? Array.from(i.children).map((e) => e.querySelector(":scope > [role=\"menuitem\"]")).filter(Boolean) : [], o = !!n?.querySelector(":scope > .submenu");
|
|
60
|
+
switch (e.key) {
|
|
61
|
+
case "ArrowDown": {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
let n = a.indexOf(t);
|
|
64
|
+
n < a.length - 1 && a[n + 1].focus();
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case "ArrowUp": {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
let n = a.indexOf(t);
|
|
70
|
+
n > 0 && a[n - 1].focus();
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case "ArrowRight":
|
|
74
|
+
case "Enter":
|
|
75
|
+
o && (e.preventDefault(), this._openPaths.has(r) || (this._toggleSubmenu(r), this.updateComplete.then(() => {
|
|
76
|
+
(n?.querySelector(".submenu [role=\"menuitem\"]"))?.focus();
|
|
77
|
+
})));
|
|
78
|
+
break;
|
|
79
|
+
case "ArrowLeft":
|
|
80
|
+
if (e.preventDefault(), r.includes("-")) {
|
|
81
|
+
let e = r.split("-").slice(0, -1).join("-"), t = new Set(this._openPaths);
|
|
82
|
+
for (let n of [...t]) (n === e || n.startsWith(`${e}-`)) && t.delete(n);
|
|
83
|
+
this._openPaths = t, (this.shadowRoot?.querySelector(`.menu-item-wrapper[data-path="${e}"]`))?.querySelector(":scope > [role=\"menuitem\"]")?.focus();
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
case "Escape":
|
|
87
|
+
e.preventDefault(), this._openPaths.size > 0 ? this._openPaths = /* @__PURE__ */ new Set() : (this._open = !1, this.shadowRoot?.querySelector(".trigger")?.focus());
|
|
88
|
+
break;
|
|
89
|
+
default: break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
_onItemClick(e, t) {
|
|
93
|
+
if (e.children?.length) {
|
|
94
|
+
this._toggleSubmenu(t);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this._open = !1, this._openPaths = /* @__PURE__ */ new Set(), this.dispatchEvent(new CustomEvent("dropdown-select", {
|
|
98
|
+
detail: {
|
|
99
|
+
item: e,
|
|
100
|
+
value: e.value
|
|
101
|
+
},
|
|
102
|
+
bubbles: !0,
|
|
103
|
+
composed: !0
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
_renderItemIcon(e) {
|
|
107
|
+
return e.icon == null ? t`` : typeof e.icon == "string" ? t`<span class="item-icon"><slot name=${`icon-${e.icon}`}></slot></span>` : t`<span class="item-icon">${e.icon}</span>`;
|
|
108
|
+
}
|
|
109
|
+
_renderMenu(e, r = "") {
|
|
110
|
+
return t`
|
|
111
|
+
<ul class="menu" role="menu">
|
|
112
|
+
${s(e, (e, t) => `${r}-${t}-${e.label}`, (e, i) => {
|
|
113
|
+
let a = r ? `${r}-${i}` : String(i), o = !!e.children?.length, s = this._openPaths.has(a);
|
|
114
|
+
return t`
|
|
115
|
+
<li class="menu-item-wrapper" data-path=${a}>
|
|
116
|
+
<button
|
|
117
|
+
type="button"
|
|
118
|
+
role="menuitem"
|
|
119
|
+
aria-expanded=${o ? s ? "true" : "false" : n}
|
|
120
|
+
class="menu-item ${o ? "has-children" : ""} ${s ? "is-expanded" : ""}"
|
|
121
|
+
@click=${() => this._onItemClick(e, a)}
|
|
122
|
+
>
|
|
123
|
+
${this._renderItemIcon(e)}
|
|
124
|
+
<span class="item-label">${e.label}</span>
|
|
125
|
+
${o ? t`<span class="submenu-indicator" aria-hidden="true">${u}</span>` : ""}
|
|
126
|
+
</button>
|
|
127
|
+
${o ? t`
|
|
128
|
+
<ul class="submenu menu ${s ? "is-open" : ""}" role="menu">
|
|
129
|
+
${this._renderMenu(e.children, a)}
|
|
130
|
+
</ul>
|
|
131
|
+
` : ""}
|
|
132
|
+
</li>
|
|
133
|
+
`;
|
|
134
|
+
})}
|
|
135
|
+
</ul>
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
render() {
|
|
139
|
+
return t`
|
|
140
|
+
<button
|
|
141
|
+
type="button"
|
|
142
|
+
class="trigger"
|
|
143
|
+
aria-haspopup="menu"
|
|
144
|
+
aria-expanded=${this._open ? "true" : "false"}
|
|
145
|
+
@click=${this._toggle}
|
|
146
|
+
@keydown=${this._onTriggerKeydown}
|
|
147
|
+
>
|
|
148
|
+
<span class="icon-wrapper">
|
|
149
|
+
<slot name="icon"></slot>
|
|
150
|
+
</span>
|
|
151
|
+
<span class="label">${this.label}</span>
|
|
152
|
+
<span class="chevron" aria-hidden="true">${u}</span>
|
|
153
|
+
</button>
|
|
154
|
+
<div
|
|
155
|
+
class="panel ${this._open ? "is-open" : ""}"
|
|
156
|
+
role="menu"
|
|
157
|
+
@keydown=${this._onPanelKeydown}
|
|
158
|
+
>
|
|
159
|
+
${this._renderMenu(this.items)}
|
|
160
|
+
</div>
|
|
161
|
+
`;
|
|
162
|
+
}
|
|
163
|
+
constructor(...e) {
|
|
164
|
+
super(...e), this.label = "", this.placement = "bottom", this.items = [], this._open = !1, this._openPaths = /* @__PURE__ */ new Set(), this._onDocumentClick = (e) => {
|
|
165
|
+
this._open && (e.composedPath().includes(this) || (this._open = !1, this._openPaths = /* @__PURE__ */ new Set()));
|
|
166
|
+
}, this._onDocumentKeydown = (e) => {
|
|
167
|
+
e.key === "Escape" && this._open && (this._open = !1, this._openPaths = /* @__PURE__ */ new Set(), this.shadowRoot?.querySelector(".trigger")?.focus());
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
l([a({ type: String })], d.prototype, "label", void 0), l([a({ type: String })], d.prototype, "placement", void 0), l([a({ attribute: !1 })], d.prototype, "items", void 0), l([o()], d.prototype, "_open", void 0), l([o()], d.prototype, "_openPaths", void 0), d = l([i("app-dropdown-button")], d);
|
|
172
|
+
export { d as t };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { LitElement as e, html as t, unsafeCSS as n } from "lit";
|
|
2
|
+
import { customElement as r, property as i, state as a } from "lit/decorators.js";
|
|
3
|
+
var o = ":host{box-sizing:border-box;display:block}.shell{background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-card);overflow:hidden}.shell--seamless{background:0 0;border:none;border-radius:0;overflow:visible}.header{padding:1.5rem 1.75rem 1.25rem}.title{color:var(--color-text);margin:0;font-size:1.125rem;font-weight:600;line-height:1.4}.description{color:var(--color-text-muted);margin:.375rem 0 0;font-size:.875rem;line-height:1.5}.divider{background:var(--color-border);height:1px}.steps{scrollbar-width:none;align-items:center;gap:0;padding:1rem 1.75rem;display:flex;overflow-x:auto}.steps::-webkit-scrollbar{display:none}.step-connector{background:var(--color-border);flex:1;min-width:1rem;max-width:3rem;height:1px}.step{cursor:default;color:var(--color-text-muted);white-space:nowrap;background:0 0;border:none;flex-shrink:0;align-items:center;gap:.5rem;padding:0;font-size:.875rem;font-weight:500;display:flex}.step--done{cursor:pointer;color:var(--color-primary)}.step--done:focus-visible{outline:2px solid var(--color-primary);outline-offset:2px;border-radius:2px}.step--active{color:var(--color-text)}.step-number{border-radius:var(--radius-full);border:2px solid;flex-shrink:0;justify-content:center;align-items:center;width:1.75rem;height:1.75rem;font-size:.8125rem;font-weight:600;transition:background .15s,color .15s,border-color .15s;display:flex}.step--active .step-number,.step--done .step-number{background:var(--color-primary);border-color:var(--color-primary);color:var(--color-text-inverse)}slot{display:contents}[hidden]{display:none!important}.fields{align-items:start;gap:1rem;padding:1.5rem 1.75rem;display:grid}.fields--cols-1{grid-template-columns:1fr}.fields--cols-2{grid-template-columns:repeat(2,1fr)}.fields--cols-3{grid-template-columns:repeat(3,1fr)}@media (width<=640px){.fields--cols-2,.fields--cols-3{grid-template-columns:1fr}}@media (width>=641px) and (width<=900px){.fields--cols-3{grid-template-columns:repeat(2,1fr)}}.actions{justify-content:flex-end;align-items:center;gap:.5rem;padding:1rem 1.75rem;display:flex}.btn{padding:var(--button-padding-block,.5rem) var(--button-padding-inline,1rem);font-size:var(--button-font-size,1rem);font-weight:var(--button-font-weight,500);border-radius:var(--radius-button);cursor:pointer;transition:background var(--button-transition-duration,.2s) var(--ease-emphasized), color var(--button-transition-duration,.2s) var(--ease-emphasized), border-color var(--button-transition-duration,.2s) var(--ease-emphasized);border:1px solid #0000;justify-content:center;align-items:center;min-width:5rem;min-height:2.5rem;line-height:1;display:inline-flex}.btn:focus-visible{outline:var(--button-focus-ring-width,2px) solid var(--color-primary);outline-offset:var(--button-focus-ring-offset,2px)}.btn:disabled{opacity:.4;cursor:not-allowed}.btn--primary{background:var(--color-primary);color:var(--color-text-inverse);border-color:var(--color-primary)}.btn--primary:not(:disabled):hover{background:var(--color-primary-hover);border-color:var(--color-primary-hover)}.btn--ghost{color:var(--color-text);border-color:var(--color-border);background:0 0}.btn--ghost:not(:disabled):hover{background:var(--color-surface-elevated);border-color:var(--color-border-strong)}.sr-only{clip:rect(0 0 0 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}";
|
|
4
|
+
function s(e, t, n, r) {
|
|
5
|
+
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
6
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
7
|
+
else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
|
|
8
|
+
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
9
|
+
}
|
|
10
|
+
var c = class extends e {
|
|
11
|
+
static {
|
|
12
|
+
this.styles = [n(o)];
|
|
13
|
+
}
|
|
14
|
+
willUpdate(e) {
|
|
15
|
+
e.has("currentStage") && (this._stage = this.currentStage);
|
|
16
|
+
}
|
|
17
|
+
get _isMultiStep() {
|
|
18
|
+
return this.stages.length > 0;
|
|
19
|
+
}
|
|
20
|
+
get _isLastStage() {
|
|
21
|
+
return this._stage === this.stages.length - 1;
|
|
22
|
+
}
|
|
23
|
+
_handleBack() {
|
|
24
|
+
this._stage !== 0 && (this._stage--, this.dispatchEvent(new CustomEvent("form-layout-back", {
|
|
25
|
+
detail: { stage: this._stage },
|
|
26
|
+
bubbles: !0,
|
|
27
|
+
composed: !0
|
|
28
|
+
})));
|
|
29
|
+
}
|
|
30
|
+
_handleNext() {
|
|
31
|
+
this._isLastStage || (this._stage++, this.dispatchEvent(new CustomEvent("form-layout-next", {
|
|
32
|
+
detail: { stage: this._stage },
|
|
33
|
+
bubbles: !0,
|
|
34
|
+
composed: !0
|
|
35
|
+
})));
|
|
36
|
+
}
|
|
37
|
+
_handleSubmit() {
|
|
38
|
+
this.dispatchEvent(new CustomEvent("form-layout-submit", {
|
|
39
|
+
detail: { stage: this._stage },
|
|
40
|
+
bubbles: !0,
|
|
41
|
+
composed: !0
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
_renderStepIndicator() {
|
|
45
|
+
return t`
|
|
46
|
+
<nav class="steps" aria-label="Form progress">
|
|
47
|
+
${this.stages.map((e, n) => t`
|
|
48
|
+
${n > 0 ? t`<span class="step-connector" aria-hidden="true"></span>` : ""}
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
class="step ${n === this._stage ? "step--active" : ""} ${n < this._stage ? "step--done" : ""}"
|
|
52
|
+
aria-current=${n === this._stage ? "step" : "false"}
|
|
53
|
+
@click=${() => {
|
|
54
|
+
n < this._stage && (this._stage = n);
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<span class="step-number" aria-hidden="true">${n < this._stage ? t`
|
|
58
|
+
<svg viewBox="0 0 16 16" fill="none" aria-hidden="true" width="14" height="14">
|
|
59
|
+
<path d="M3 8l3.5 3.5L13 5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
60
|
+
</svg>` : n + 1}
|
|
61
|
+
</span>
|
|
62
|
+
<span class="step-label">${e}</span>
|
|
63
|
+
</button>
|
|
64
|
+
`)}
|
|
65
|
+
</nav>
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
_renderFields() {
|
|
69
|
+
return this._isMultiStep ? t`
|
|
70
|
+
${this.stages.map((e, n) => t`
|
|
71
|
+
<div
|
|
72
|
+
class="fields fields--cols-${this.columns}"
|
|
73
|
+
role="group"
|
|
74
|
+
aria-label=${e}
|
|
75
|
+
?hidden=${n !== this._stage}
|
|
76
|
+
>
|
|
77
|
+
<slot name="stage-${n}"></slot>
|
|
78
|
+
</div>
|
|
79
|
+
`)}
|
|
80
|
+
` : t`
|
|
81
|
+
<div class="fields fields--cols-${this.columns}">
|
|
82
|
+
<slot name="fields"></slot>
|
|
83
|
+
</div>
|
|
84
|
+
`;
|
|
85
|
+
}
|
|
86
|
+
_renderActions() {
|
|
87
|
+
return this._isMultiStep ? t`
|
|
88
|
+
<div class="actions">
|
|
89
|
+
<button
|
|
90
|
+
type="button"
|
|
91
|
+
class="btn btn--ghost"
|
|
92
|
+
?disabled=${this._stage === 0}
|
|
93
|
+
@click=${this._handleBack}
|
|
94
|
+
>
|
|
95
|
+
Back
|
|
96
|
+
</button>
|
|
97
|
+
${this._isLastStage ? t`<button type="button" class="btn btn--primary" @click=${this._handleSubmit}>Submit</button>` : t`<button type="button" class="btn btn--primary" @click=${this._handleNext}>Next</button>`}
|
|
98
|
+
</div>
|
|
99
|
+
` : t`
|
|
100
|
+
<div class="actions">
|
|
101
|
+
<button type="button" class="btn btn--primary" @click=${this._handleSubmit}>Submit</button>
|
|
102
|
+
</div>
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
render() {
|
|
106
|
+
return t`
|
|
107
|
+
<div class="shell ${this.seamless ? "shell--seamless" : ""}" role="region" aria-label=${this.title || "Form"}>
|
|
108
|
+
<header class="header">
|
|
109
|
+
<h2 class="title">${this.title}</h2>
|
|
110
|
+
${this.description ? t`<p class="description">${this.description}</p>` : ""}
|
|
111
|
+
</header>
|
|
112
|
+
|
|
113
|
+
${this._isMultiStep ? t`
|
|
114
|
+
<div class="divider" aria-hidden="true"></div>
|
|
115
|
+
${this._renderStepIndicator()}
|
|
116
|
+
` : ""}
|
|
117
|
+
|
|
118
|
+
<div class="divider" aria-hidden="true"></div>
|
|
119
|
+
|
|
120
|
+
${this._renderFields()}
|
|
121
|
+
|
|
122
|
+
<div class="divider" aria-hidden="true"></div>
|
|
123
|
+
|
|
124
|
+
${this._renderActions()}
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<span aria-live="polite" class="sr-only">
|
|
128
|
+
${this._isMultiStep ? `Step ${this._stage + 1} of ${this.stages.length}: ${this.stages[this._stage]}` : ""}
|
|
129
|
+
</span>
|
|
130
|
+
`;
|
|
131
|
+
}
|
|
132
|
+
constructor(...e) {
|
|
133
|
+
super(...e), this.title = "", this.description = "", this.columns = 1, this.stages = [], this.seamless = !1, this.currentStage = 0, this._stage = 0;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
s([i({ type: String })], c.prototype, "title", void 0), s([i({ type: String })], c.prototype, "description", void 0), s([i({ type: Number })], c.prototype, "columns", void 0), s([i({ type: Array })], c.prototype, "stages", void 0), s([i({ type: Boolean })], c.prototype, "seamless", void 0), s([i({
|
|
137
|
+
type: Number,
|
|
138
|
+
attribute: "current-stage"
|
|
139
|
+
})], c.prototype, "currentStage", void 0), s([a()], c.prototype, "_stage", void 0), c = s([r("app-form-layout")], c);
|
|
140
|
+
export { c as t };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { Button } from './components/button';
|
|
2
|
+
export { Table } from './components/table';
|
|
3
|
+
export { DropdownButton } from './components/dropdown-button';
|
|
4
|
+
export { Menu } from './components/menu';
|
|
5
|
+
export { Layout } from './components/layouts';
|
|
6
|
+
export { FormLayout } from './components/layouts';
|
|
7
|
+
export { Toggle } from './components/toggle';
|
|
8
|
+
export { Input } from './components/input';
|
|
9
|
+
export { Modal } from './components/modal';
|
|
10
|
+
export { Tabs } from './components/tabs';
|
|
11
|
+
export { Selector } from './components/selector';
|
|
12
|
+
export type { ButtonIconPosition, ButtonType } from './components/button';
|
|
13
|
+
export type { ColumnDef, SortDir, TableSortEvent, TablePageEvent, TableColumnToggleEvent } from './components/table';
|
|
14
|
+
export type { DropdownItem, DropdownSelectEventDetail, DropdownPlacement } from './components/dropdown-button';
|
|
15
|
+
export type { MenuItem, MenuSelectEventDetail, MenuSearchEventDetail } from './components/menu';
|
|
16
|
+
export type { ToggleIconPosition, ToggleChangeEventDetail } from './components/toggle';
|
|
17
|
+
export type { InputType, InputState } from './components/input';
|
|
18
|
+
export type { ModalVariant, ModalSize } from './components/modal';
|
|
19
|
+
export type { TabItem, TabChangeEventDetail } from './components/tabs';
|
|
20
|
+
export type { SelectorOption, SelectorGroup, SelectorChangeEventDetail, SelectorState } from './components/selector';
|
|
21
|
+
export type { FormLayoutStageEventDetail } from './components/layouts';
|
|
22
|
+
export { tailwindBase } from './styles/tailwind-base.ts';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { LitElement as e, html as t, unsafeCSS as n } from "lit";
|
|
2
|
+
import { customElement as r, property as i, state as a } from "lit/decorators.js";
|
|
3
|
+
var o = ":host{display:block}.wrapper{flex-direction:column;gap:.375rem;display:flex}.label{color:var(--color-text);font-size:.875rem;font-weight:500;line-height:1.25}.input-row{align-items:center;display:flex;position:relative}.icon-wrapper{left:var(--input-padding-inline);color:var(--color-text-muted);pointer-events:none;align-items:center;display:inline-flex;position:absolute}input{box-sizing:border-box;width:100%;font-size:var(--input-font-size);color:var(--color-text);background:var(--color-surface);border:1px solid var(--color-border-strong);border-radius:var(--radius-input);padding-block:var(--input-padding-block);padding-inline:var(--input-padding-inline);transition:border-color var(--input-transition-duration) var(--ease-emphasized), box-shadow var(--input-transition-duration) var(--ease-emphasized);appearance:none;outline:none}.input-row.has-icon input{padding-left:calc(var(--input-padding-inline) + var(--input-icon-size) + var(--input-icon-gap))}:host([state=valid]) input,:host([state=invalid]) input{padding-right:calc(var(--input-padding-inline) + var(--input-icon-size) + var(--input-icon-gap))}input::placeholder{color:var(--color-text-muted)}input:hover:not(:disabled){border-color:var(--color-border-strong);box-shadow:0 0 0 1px var(--color-border-strong)}input:focus-visible{border-color:var(--color-primary);box-shadow:0 0 0 2px var(--color-primary)}input:disabled{opacity:.5;cursor:not-allowed;background:var(--color-surface-elevated)}.state-icon{right:var(--input-padding-inline);pointer-events:none;align-items:center;display:inline-flex;position:absolute}.state-icon--valid{color:var(--color-valid)}.state-icon--invalid{color:var(--color-invalid)}:host([state=valid]) input{border-color:var(--color-valid)}:host([state=valid]) input:focus-visible{box-shadow:0 0 0 2px var(--color-valid)}:host([state=invalid]) input{border-color:var(--color-invalid);background:var(--color-invalid-muted)}:host([state=invalid]) input:focus-visible{box-shadow:0 0 0 2px var(--color-invalid)}.error-text{color:var(--color-invalid);font-size:.8125rem;line-height:1.4}";
|
|
4
|
+
function s(e, t, n, r) {
|
|
5
|
+
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
6
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
7
|
+
else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
|
|
8
|
+
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
9
|
+
}
|
|
10
|
+
var c = 0, l = class extends e {
|
|
11
|
+
static {
|
|
12
|
+
this.styles = [n(o)];
|
|
13
|
+
}
|
|
14
|
+
_handleInput(e) {
|
|
15
|
+
this.value = e.target.value, this.onChange?.(this.value);
|
|
16
|
+
}
|
|
17
|
+
_renderStateIcon() {
|
|
18
|
+
return this.state === "valid" ? t`
|
|
19
|
+
<span class="state-icon state-icon--valid" aria-hidden="true">
|
|
20
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" width="18" height="18">
|
|
21
|
+
<path fill-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z" clip-rule="evenodd" />
|
|
22
|
+
</svg>
|
|
23
|
+
</span>
|
|
24
|
+
` : this.state === "invalid" ? t`
|
|
25
|
+
<span class="state-icon state-icon--invalid" aria-hidden="true">
|
|
26
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" width="18" height="18">
|
|
27
|
+
<path fill-rule="evenodd" d="M18 10a8 8 0 1 1-16 0 8 8 0 0 1 16 0Zm-8-5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0v-4.5A.75.75 0 0 1 10 5Zm0 10a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" clip-rule="evenodd" />
|
|
28
|
+
</svg>
|
|
29
|
+
</span>
|
|
30
|
+
` : t``;
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
let e = `${this._uid}-error`, n = this.state === "invalid" && this.errorMessage;
|
|
34
|
+
return t`
|
|
35
|
+
<div class="wrapper">
|
|
36
|
+
${this.label ? t`<label for=${this._uid} class="label">${this.label}</label>` : ""}
|
|
37
|
+
<div class="input-row ${this._hasIcon ? "has-icon" : ""}">
|
|
38
|
+
<span class="icon-wrapper">
|
|
39
|
+
<slot name="icon" @slotchange=${this._onIconSlotChange}></slot>
|
|
40
|
+
</span>
|
|
41
|
+
<input
|
|
42
|
+
id=${this._uid}
|
|
43
|
+
type=${this.type}
|
|
44
|
+
name=${this.name}
|
|
45
|
+
placeholder=${this.placeholder}
|
|
46
|
+
.value=${this.value}
|
|
47
|
+
?required=${this.required}
|
|
48
|
+
?disabled=${this.disabled}
|
|
49
|
+
?readonly=${this.readonly}
|
|
50
|
+
aria-invalid=${this.state === "invalid" ? "true" : "false"}
|
|
51
|
+
aria-describedby=${n ? e : ""}
|
|
52
|
+
@input=${this._handleInput}
|
|
53
|
+
/>
|
|
54
|
+
${this._renderStateIcon()}
|
|
55
|
+
</div>
|
|
56
|
+
${n ? t`<span id=${e} class="error-text" role="alert">${this.errorMessage}</span>` : ""}
|
|
57
|
+
</div>
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
constructor(...e) {
|
|
61
|
+
super(...e), this._uid = `app-input-${++c}`, this.type = "text", this.label = "", this.placeholder = "", this.value = "", this.name = "", this.required = !1, this.disabled = !1, this.readonly = !1, this.state = "default", this.errorMessage = "", this._hasIcon = !1, this._onIconSlotChange = (e) => {
|
|
62
|
+
this._hasIcon = e.target.assignedNodes({ flatten: !0 }).length > 0;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
s([i({ type: String })], l.prototype, "type", void 0), s([i({ type: String })], l.prototype, "label", void 0), s([i({ type: String })], l.prototype, "placeholder", void 0), s([i({ type: String })], l.prototype, "value", void 0), s([i({ type: String })], l.prototype, "name", void 0), s([i({ type: Boolean })], l.prototype, "required", void 0), s([i({ type: Boolean })], l.prototype, "disabled", void 0), s([i({ type: Boolean })], l.prototype, "readonly", void 0), s([i({ type: String })], l.prototype, "state", void 0), s([i({
|
|
67
|
+
type: String,
|
|
68
|
+
attribute: "error-message"
|
|
69
|
+
})], l.prototype, "errorMessage", void 0), s([i({ attribute: !1 })], l.prototype, "onChange", void 0), s([a()], l.prototype, "_hasIcon", void 0), l = s([r("app-input")], l);
|
|
70
|
+
export { l as t };
|
package/dist/input.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LitElement as e } from "lit";
|
|
2
|
+
import { customElement as t } from "lit/decorators.js";
|
|
3
|
+
var n = "app-layout{box-sizing:border-box;width:100%;min-height:100vh;display:block}app-layout>[slot=sidebar]{z-index:100;height:100vh;position:fixed;top:0;left:0}app-layout>[slot=content]{margin-left:var(--menu-collapsed-width,3.5rem);min-height:100vh;overflow:auto}";
|
|
4
|
+
function r(e, t, n, r) {
|
|
5
|
+
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
6
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
7
|
+
else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
|
|
8
|
+
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
9
|
+
}
|
|
10
|
+
var i = !1;
|
|
11
|
+
function a() {
|
|
12
|
+
if (i) return;
|
|
13
|
+
i = !0;
|
|
14
|
+
let e = document.createElement("style");
|
|
15
|
+
e.dataset.appLayout = "", e.textContent = n, document.head.appendChild(e);
|
|
16
|
+
}
|
|
17
|
+
var o = class extends e {
|
|
18
|
+
createRenderRoot() {
|
|
19
|
+
return a(), this;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
o = r([t("app-layout")], o);
|
|
23
|
+
export { o as t };
|
package/dist/layouts.js
ADDED