@elyracode/mini-lit 0.9.4
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/LICENSE +21 -0
- package/README.md +22 -0
- package/dist/Alert.d.ts +12 -0
- package/dist/Alert.d.ts.map +1 -0
- package/dist/Alert.js +35 -0
- package/dist/Alert.js.map +1 -0
- package/dist/Badge.d.ts +8 -0
- package/dist/Badge.d.ts.map +1 -0
- package/dist/Badge.js +19 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Button.d.ts +14 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +60 -0
- package/dist/Button.js.map +1 -0
- package/dist/Card.d.ts +19 -0
- package/dist/Card.d.ts.map +1 -0
- package/dist/Card.js +76 -0
- package/dist/Card.js.map +1 -0
- package/dist/Checkbox.d.ts +15 -0
- package/dist/Checkbox.d.ts.map +1 -0
- package/dist/Checkbox.js +49 -0
- package/dist/Checkbox.js.map +1 -0
- package/dist/CodeBlock.d.ts +11 -0
- package/dist/CodeBlock.d.ts.map +1 -0
- package/dist/CodeBlock.js +90 -0
- package/dist/CodeBlock.js.map +1 -0
- package/dist/CopyButton.d.ts +11 -0
- package/dist/CopyButton.d.ts.map +1 -0
- package/dist/CopyButton.js +65 -0
- package/dist/CopyButton.js.map +1 -0
- package/dist/Dialog.d.ts +24 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +72 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/DialogBase.d.ts +13 -0
- package/dist/DialogBase.d.ts.map +1 -0
- package/dist/DialogBase.js +48 -0
- package/dist/DialogBase.js.map +1 -0
- package/dist/Diff.d.ts +8 -0
- package/dist/Diff.d.ts.map +1 -0
- package/dist/Diff.js +47 -0
- package/dist/Diff.js.map +1 -0
- package/dist/DownloadButton.d.ts +16 -0
- package/dist/DownloadButton.d.ts.map +1 -0
- package/dist/DownloadButton.js +53 -0
- package/dist/DownloadButton.js.map +1 -0
- package/dist/FileButton.d.ts +9 -0
- package/dist/FileButton.d.ts.map +1 -0
- package/dist/FileButton.js +53 -0
- package/dist/FileButton.js.map +1 -0
- package/dist/Input.d.ts +28 -0
- package/dist/Input.d.ts.map +1 -0
- package/dist/Input.js +58 -0
- package/dist/Input.js.map +1 -0
- package/dist/Label.d.ts +9 -0
- package/dist/Label.d.ts.map +1 -0
- package/dist/Label.js +17 -0
- package/dist/Label.js.map +1 -0
- package/dist/LanguageSelector.d.ts +14 -0
- package/dist/LanguageSelector.d.ts.map +1 -0
- package/dist/LanguageSelector.js +92 -0
- package/dist/LanguageSelector.js.map +1 -0
- package/dist/MarkdownBlock.d.ts +10 -0
- package/dist/MarkdownBlock.d.ts.map +1 -0
- package/dist/MarkdownBlock.js +257 -0
- package/dist/MarkdownBlock.js.map +1 -0
- package/dist/ModeToggle.d.ts +14 -0
- package/dist/ModeToggle.d.ts.map +1 -0
- package/dist/ModeToggle.js +59 -0
- package/dist/ModeToggle.js.map +1 -0
- package/dist/PreviewCode.d.ts +12 -0
- package/dist/PreviewCode.d.ts.map +1 -0
- package/dist/PreviewCode.js +80 -0
- package/dist/PreviewCode.js.map +1 -0
- package/dist/PreviewCodeToggle.d.ts +15 -0
- package/dist/PreviewCodeToggle.d.ts.map +1 -0
- package/dist/PreviewCodeToggle.js +55 -0
- package/dist/PreviewCodeToggle.js.map +1 -0
- package/dist/Progress.d.ts +10 -0
- package/dist/Progress.d.ts.map +1 -0
- package/dist/Progress.js +27 -0
- package/dist/Progress.js.map +1 -0
- package/dist/PromptDialog.d.ts +20 -0
- package/dist/PromptDialog.d.ts.map +1 -0
- package/dist/PromptDialog.js +114 -0
- package/dist/PromptDialog.js.map +1 -0
- package/dist/Select.d.ts +25 -0
- package/dist/Select.d.ts.map +1 -0
- package/dist/Select.js +335 -0
- package/dist/Select.js.map +1 -0
- package/dist/Separator.d.ts +10 -0
- package/dist/Separator.d.ts.map +1 -0
- package/dist/Separator.js +19 -0
- package/dist/Separator.js.map +1 -0
- package/dist/Sidebar.d.ts +27 -0
- package/dist/Sidebar.d.ts.map +1 -0
- package/dist/Sidebar.js +151 -0
- package/dist/Sidebar.js.map +1 -0
- package/dist/SplitPanel.d.ts +40 -0
- package/dist/SplitPanel.d.ts.map +1 -0
- package/dist/SplitPanel.js +275 -0
- package/dist/SplitPanel.js.map +1 -0
- package/dist/Switch.d.ts +13 -0
- package/dist/Switch.d.ts.map +1 -0
- package/dist/Switch.js +48 -0
- package/dist/Switch.js.map +1 -0
- package/dist/Textarea.d.ts +21 -0
- package/dist/Textarea.d.ts.map +1 -0
- package/dist/Textarea.js +67 -0
- package/dist/Textarea.js.map +1 -0
- package/dist/ThemeToggle.d.ts +11 -0
- package/dist/ThemeToggle.d.ts.map +1 -0
- package/dist/ThemeToggle.js +91 -0
- package/dist/ThemeToggle.js.map +1 -0
- package/dist/component.d.ts +190 -0
- package/dist/component.d.ts.map +1 -0
- package/dist/component.js +241 -0
- package/dist/component.js.map +1 -0
- package/dist/i18n.d.ts +73 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +146 -0
- package/dist/i18n.js.map +1 -0
- package/dist/icons.d.ts +7 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +21 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/mini.d.ts +19 -0
- package/dist/mini.d.ts.map +1 -0
- package/dist/mini.js +29 -0
- package/dist/mini.js.map +1 -0
- package/llms.txt +681 -0
- package/package.json +69 -0
- package/src/styles/base.css +63 -0
- package/src/styles/themes/claude.css +155 -0
- package/src/styles/themes/default.css +102 -0
- package/src/styles/utils/markdown.css +104 -0
- package/src/styles/utils/math.css +7 -0
- package/src/styles/utils/syntax-highlighting.css +134 -0
package/dist/Sidebar.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, LitElement } from "lit";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
|
+
import { Menu, X } from "lucide";
|
|
10
|
+
import { Button } from "./Button.js";
|
|
11
|
+
import { icon } from "./icons.js";
|
|
12
|
+
import { fc } from "./mini.js";
|
|
13
|
+
let Sidebar = class Sidebar extends LitElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.defaultOpen = false;
|
|
17
|
+
this.breakpoint = "md";
|
|
18
|
+
this.className = "";
|
|
19
|
+
this.logo = "";
|
|
20
|
+
this.footer = "";
|
|
21
|
+
this.content = "";
|
|
22
|
+
this.isOpen = false;
|
|
23
|
+
this.toggleSidebar = () => {
|
|
24
|
+
this.isOpen = !this.isOpen;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
createRenderRoot() {
|
|
28
|
+
return this; // Use light DOM for global styles
|
|
29
|
+
}
|
|
30
|
+
connectedCallback() {
|
|
31
|
+
super.connectedCallback();
|
|
32
|
+
this.isOpen = this.defaultOpen;
|
|
33
|
+
}
|
|
34
|
+
render() {
|
|
35
|
+
// Responsive classes based on breakpoint
|
|
36
|
+
const hideOnDesktop = {
|
|
37
|
+
sm: "sm:hidden",
|
|
38
|
+
md: "md:hidden",
|
|
39
|
+
lg: "lg:hidden",
|
|
40
|
+
xl: "xl:hidden",
|
|
41
|
+
}[this.breakpoint];
|
|
42
|
+
const showDesktopSidebar = {
|
|
43
|
+
sm: "sm:translate-x-0",
|
|
44
|
+
md: "md:translate-x-0",
|
|
45
|
+
lg: "lg:translate-x-0",
|
|
46
|
+
xl: "xl:translate-x-0",
|
|
47
|
+
}[this.breakpoint];
|
|
48
|
+
// On mobile, use isOpen state. On desktop, always show.
|
|
49
|
+
const mobileTransform = this.isOpen ? "translate-x-0" : "-translate-x-full";
|
|
50
|
+
return html `
|
|
51
|
+
<!-- Mobile menu button (only visible on mobile when sidebar is closed) -->
|
|
52
|
+
<div
|
|
53
|
+
class="${hideOnDesktop} fixed top-4 left-4 z-50 ${this.isOpen ? "opacity-0 pointer-events-none" : "opacity-100"}"
|
|
54
|
+
>
|
|
55
|
+
${Button({
|
|
56
|
+
variant: "outline",
|
|
57
|
+
size: "icon",
|
|
58
|
+
onClick: this.toggleSidebar,
|
|
59
|
+
children: icon(Menu, "sm"),
|
|
60
|
+
})}
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<!-- Overlay for mobile -->
|
|
64
|
+
<div
|
|
65
|
+
class="fixed inset-0 bg-black/50 z-40 ${hideOnDesktop} ${this.isOpen ? "" : "hidden"}"
|
|
66
|
+
@click=${this.toggleSidebar}
|
|
67
|
+
></div>
|
|
68
|
+
|
|
69
|
+
<!-- Sidebar -->
|
|
70
|
+
<aside
|
|
71
|
+
class="fixed top-0 left-0 z-40 h-full w-64 bg-card border-r border-border transition-transform duration-300
|
|
72
|
+
${mobileTransform}
|
|
73
|
+
${showDesktopSidebar}
|
|
74
|
+
${this.className}"
|
|
75
|
+
>
|
|
76
|
+
<div class="flex flex-col h-full">
|
|
77
|
+
<!-- Close button for mobile -->
|
|
78
|
+
<div class="${hideOnDesktop} absolute top-4 right-4">
|
|
79
|
+
${Button({
|
|
80
|
+
variant: "ghost",
|
|
81
|
+
size: "icon",
|
|
82
|
+
onClick: this.toggleSidebar,
|
|
83
|
+
children: icon(X, "sm"),
|
|
84
|
+
})}
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<!-- Logo/Header -->
|
|
88
|
+
${this.logo ? html ` <div class="p-4">${this.logo}</div> ` : ""}
|
|
89
|
+
|
|
90
|
+
<!-- Scrollable content -->
|
|
91
|
+
<div class="flex-1 overflow-y-auto p-4 space-y-4">${this.content}</div>
|
|
92
|
+
|
|
93
|
+
<!-- Footer -->
|
|
94
|
+
${this.footer ? html ` <div class="p-4">${this.footer}</div> ` : ""}
|
|
95
|
+
</div>
|
|
96
|
+
</aside>
|
|
97
|
+
`;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
__decorate([
|
|
101
|
+
property({ type: Boolean, attribute: "default-open" })
|
|
102
|
+
], Sidebar.prototype, "defaultOpen", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
property({ type: String })
|
|
105
|
+
], Sidebar.prototype, "breakpoint", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
property({ type: String, attribute: "class-name" })
|
|
108
|
+
], Sidebar.prototype, "className", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
property({ type: Object })
|
|
111
|
+
], Sidebar.prototype, "logo", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
property({ type: Object })
|
|
114
|
+
], Sidebar.prototype, "footer", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: Object })
|
|
117
|
+
], Sidebar.prototype, "content", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
state()
|
|
120
|
+
], Sidebar.prototype, "isOpen", void 0);
|
|
121
|
+
Sidebar = __decorate([
|
|
122
|
+
customElement("mini-sidebar")
|
|
123
|
+
], Sidebar);
|
|
124
|
+
export { Sidebar };
|
|
125
|
+
export const SidebarItem = fc(({ href, active = false, onClick, children, className = "" }) => {
|
|
126
|
+
const baseClasses = "block px-2 py-1 text-sm rounded transition-colors";
|
|
127
|
+
const activeClasses = active ? "bg-muted text-foreground font-medium" : "hover:bg-muted text-foreground";
|
|
128
|
+
if (href) {
|
|
129
|
+
return html `
|
|
130
|
+
<a href="${href}" class="${baseClasses} ${activeClasses} ${className}" @click=${onClick}> ${children} </a>
|
|
131
|
+
`;
|
|
132
|
+
}
|
|
133
|
+
return html `
|
|
134
|
+
<button class="${baseClasses} ${activeClasses} ${className} w-full text-left" @click=${onClick}>
|
|
135
|
+
${children}
|
|
136
|
+
</button>
|
|
137
|
+
`;
|
|
138
|
+
});
|
|
139
|
+
export const SidebarSection = fc(({ title, children, className = "" }) => {
|
|
140
|
+
if (!title) {
|
|
141
|
+
// No title means top-level items, no wrapper needed
|
|
142
|
+
return html ` <div class="space-y-1 ${className}">${children}</div> `;
|
|
143
|
+
}
|
|
144
|
+
return html `
|
|
145
|
+
<div class="space-y-2 ${className}">
|
|
146
|
+
<h4 class="font-medium text-sm px-2">${title}</h4>
|
|
147
|
+
<nav class="space-y-1 pl-4">${children}</nav>
|
|
148
|
+
</div>
|
|
149
|
+
`;
|
|
150
|
+
});
|
|
151
|
+
//# sourceMappingURL=Sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sidebar.js","sourceRoot":"","sources":["../src/Sidebar.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAA2B,EAAE,EAAE,MAAM,WAAW,CAAC;AAGjD,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,UAAU;IAAhC;;QACoD,gBAAW,GAAG,KAAK,CAAC;QAChD,eAAU,GAA8B,IAAI,CAAC;QACpB,cAAS,GAAG,EAAE,CAAC;QACxC,SAAI,GAA4B,EAAE,CAAC;QACnC,WAA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E,MAAM,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE;IAC7G,MAAM,WAAW,GAAG,mDAAmD,CAAC;IACxE,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,gCAAgC,CAAC;IAEzG,IAAI,IAAI,EAAE,CAAC;QACR,OAAO,IAAI,CAAA;oBACG,IAAI,YAAY,WAAW,IAAI,aAAa,IAAI,SAAS,YAAY,OAAO,KAAK,QAAQ;OACtG,CAAC;IACL,CAAC;IAED,OAAO,IAAI,CAAA;uBACS,WAAW,IAAI,aAAa,IAAI,SAAS,6BAA6B,OAAO;WACzF,QAAQ;;IAEf,CAAC;AACL,CAAC,CAAC,CAAC;AAMH,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAsB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE;IAC3F,IAAI,CAAC,KAAK,EAAE,CAAC;QACV,oDAAoD;QACpD,OAAO,IAAI,CAAA,0BAA0B,SAAS,KAAK,QAAQ,SAAS,CAAC;IACxE,CAAC;IAED,OAAO,IAAI,CAAA;8BACgB,SAAS;gDACS,KAAK;uCACd,QAAQ;;IAE3C,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { LitElement, type TemplateResult } from "lit";
|
|
2
|
+
export declare class SplitPanel extends LitElement {
|
|
3
|
+
leftPanel?: TemplateResult | HTMLElement;
|
|
4
|
+
rightPanel?: TemplateResult | HTMLElement;
|
|
5
|
+
topPanel?: TemplateResult | HTMLElement;
|
|
6
|
+
bottomPanel?: TemplateResult | HTMLElement;
|
|
7
|
+
initialSplit: number;
|
|
8
|
+
minSize: number;
|
|
9
|
+
hideRight: boolean;
|
|
10
|
+
hideBottom: boolean;
|
|
11
|
+
mobileBreakpoint: number;
|
|
12
|
+
vertical: boolean;
|
|
13
|
+
private currentSplit;
|
|
14
|
+
private isMobile;
|
|
15
|
+
private containerRef;
|
|
16
|
+
private firstPanelRef;
|
|
17
|
+
private secondPanelRef;
|
|
18
|
+
private dividerRef;
|
|
19
|
+
private isDragging;
|
|
20
|
+
private startPos;
|
|
21
|
+
private startSplit;
|
|
22
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment;
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
disconnectedCallback(): void;
|
|
25
|
+
private handleResize;
|
|
26
|
+
private checkMobile;
|
|
27
|
+
private handleMouseDown;
|
|
28
|
+
private handleMouseMove;
|
|
29
|
+
private handleMouseUp;
|
|
30
|
+
private handleTouchStart;
|
|
31
|
+
private handleTouchMove;
|
|
32
|
+
private handleTouchEnd;
|
|
33
|
+
render(): TemplateResult<1>;
|
|
34
|
+
}
|
|
35
|
+
declare global {
|
|
36
|
+
interface HTMLElementTagNameMap {
|
|
37
|
+
"split-panel": SplitPanel;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=SplitPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitPanel.d.ts","sourceRoot":"","sources":["../src/SplitPanel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAK5D,qBACa,UAAW,SAAQ,UAAU;IACX,SAAS,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC;IACzC,UAAU,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC;IAC1C,QAAQ,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC;IACxC,WAAW,CAAC,EAAE,cAAc,GAAG,WAAW,CAAC;IAC3D,YAAY,SAAM;IAClB,OAAO,SAAO;IACd,SAAS,UAAS;IAClB,UAAU,UAAS;IACnB,gBAAgB,SAAQ;IACP,QAAQ,UAAS;IAErC,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,QAAQ,CAAS;IAElC,OAAO,CAAC,YAAY,CAAoC;IACxD,OAAO,CAAC,aAAa,CAAoC;IACzD,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,UAAU,CAAoC;IAEtD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAM;cAEL,gBAAgB,IAAI,WAAW,GAAG,gBAAgB;IAI5D,iBAAiB;IAOjB,oBAAoB;IAK7B,OAAO,CAAC,YAAY,CAElB;IAEF,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,eAAe,CAsBrB;IAEF,OAAO,CAAC,eAAe,CAyCrB;IAEF,OAAO,CAAC,aAAa,CAOnB;IAGF,OAAO,CAAC,gBAAgB,CAQtB;IAEF,OAAO,CAAC,eAAe,CAUrB;IAEF,OAAO,CAAC,cAAc,CAEpB;IAEO,MAAM;CA+FjB;AAED,OAAO,CAAC,MAAM,CAAC;IACZ,UAAU,qBAAqB;QAC5B,aAAa,EAAE,UAAU,CAAC;KAC5B;CACH"}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, LitElement } from "lit";
|
|
8
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
9
|
+
import { createRef, ref } from "lit/directives/ref.js";
|
|
10
|
+
import { i18n } from "./i18n.js";
|
|
11
|
+
let SplitPanel = class SplitPanel extends LitElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.initialSplit = 50; // percentage for left/top panel
|
|
15
|
+
this.minSize = 200; // minimum size in pixels for each panel
|
|
16
|
+
this.hideRight = false; // controls visibility of right panel
|
|
17
|
+
this.hideBottom = false; // controls visibility of bottom panel
|
|
18
|
+
this.mobileBreakpoint = 1024; // px, below this is mobile mode
|
|
19
|
+
this.vertical = false; // vertical split mode
|
|
20
|
+
this.currentSplit = 50;
|
|
21
|
+
this.isMobile = false;
|
|
22
|
+
this.containerRef = createRef();
|
|
23
|
+
this.firstPanelRef = createRef();
|
|
24
|
+
this.secondPanelRef = createRef();
|
|
25
|
+
this.dividerRef = createRef();
|
|
26
|
+
this.isDragging = false;
|
|
27
|
+
this.startPos = 0;
|
|
28
|
+
this.startSplit = 50;
|
|
29
|
+
this.handleResize = () => {
|
|
30
|
+
this.checkMobile();
|
|
31
|
+
};
|
|
32
|
+
this.handleMouseDown = (e) => {
|
|
33
|
+
this.isDragging = true;
|
|
34
|
+
this.startPos = this.vertical ? e.clientY : e.clientX;
|
|
35
|
+
const container = this.containerRef.value;
|
|
36
|
+
if (container) {
|
|
37
|
+
const rect = container.getBoundingClientRect();
|
|
38
|
+
if (this.vertical) {
|
|
39
|
+
const currentTop = this.firstPanelRef.value?.offsetHeight || 0;
|
|
40
|
+
this.startSplit = (currentTop / rect.height) * 100;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const currentLeft = this.firstPanelRef.value?.offsetWidth || 0;
|
|
44
|
+
this.startSplit = (currentLeft / rect.width) * 100;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
document.body.style.userSelect = "none";
|
|
48
|
+
document.body.style.cursor = this.vertical ? "row-resize" : "col-resize";
|
|
49
|
+
document.addEventListener("mousemove", this.handleMouseMove);
|
|
50
|
+
document.addEventListener("mouseup", this.handleMouseUp);
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
};
|
|
53
|
+
this.handleMouseMove = (e) => {
|
|
54
|
+
if (!this.isDragging)
|
|
55
|
+
return;
|
|
56
|
+
const container = this.containerRef.value;
|
|
57
|
+
if (!container)
|
|
58
|
+
return;
|
|
59
|
+
const rect = container.getBoundingClientRect();
|
|
60
|
+
if (this.vertical) {
|
|
61
|
+
const deltaY = e.clientY - this.startPos;
|
|
62
|
+
const deltaPercent = (deltaY / rect.height) * 100;
|
|
63
|
+
let newSplit = this.startSplit + deltaPercent;
|
|
64
|
+
// Apply constraints
|
|
65
|
+
const minPercent = (this.minSize / rect.height) * 100;
|
|
66
|
+
const maxPercent = 100 - minPercent;
|
|
67
|
+
newSplit = Math.max(minPercent, Math.min(maxPercent, newSplit));
|
|
68
|
+
// Update panel sizes directly
|
|
69
|
+
if (this.firstPanelRef.value && this.secondPanelRef.value) {
|
|
70
|
+
this.firstPanelRef.value.style.height = `${newSplit}%`;
|
|
71
|
+
this.secondPanelRef.value.style.height = `${100 - newSplit}%`;
|
|
72
|
+
this.currentSplit = newSplit;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const deltaX = e.clientX - this.startPos;
|
|
77
|
+
const deltaPercent = (deltaX / rect.width) * 100;
|
|
78
|
+
let newSplit = this.startSplit + deltaPercent;
|
|
79
|
+
// Apply constraints
|
|
80
|
+
const minPercent = (this.minSize / rect.width) * 100;
|
|
81
|
+
const maxPercent = 100 - minPercent;
|
|
82
|
+
newSplit = Math.max(minPercent, Math.min(maxPercent, newSplit));
|
|
83
|
+
// Update panel sizes directly
|
|
84
|
+
if (this.firstPanelRef.value && this.secondPanelRef.value) {
|
|
85
|
+
this.firstPanelRef.value.style.width = `${newSplit}%`;
|
|
86
|
+
this.secondPanelRef.value.style.width = `${100 - newSplit}%`;
|
|
87
|
+
this.currentSplit = newSplit;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
this.handleMouseUp = () => {
|
|
92
|
+
this.isDragging = false;
|
|
93
|
+
document.body.style.userSelect = "";
|
|
94
|
+
document.body.style.cursor = "";
|
|
95
|
+
document.removeEventListener("mousemove", this.handleMouseMove);
|
|
96
|
+
document.removeEventListener("mouseup", this.handleMouseUp);
|
|
97
|
+
};
|
|
98
|
+
// Touch support
|
|
99
|
+
this.handleTouchStart = (e) => {
|
|
100
|
+
const touch = e.touches[0];
|
|
101
|
+
const mouseEvent = new MouseEvent("mousedown", {
|
|
102
|
+
clientX: touch.clientX,
|
|
103
|
+
clientY: touch.clientY,
|
|
104
|
+
button: 0,
|
|
105
|
+
});
|
|
106
|
+
this.handleMouseDown(mouseEvent);
|
|
107
|
+
};
|
|
108
|
+
this.handleTouchMove = (e) => {
|
|
109
|
+
if (!this.isDragging)
|
|
110
|
+
return;
|
|
111
|
+
const touch = e.touches[0];
|
|
112
|
+
const mouseEvent = new MouseEvent("mousemove", {
|
|
113
|
+
clientX: touch.clientX,
|
|
114
|
+
clientY: touch.clientY,
|
|
115
|
+
});
|
|
116
|
+
this.handleMouseMove(mouseEvent);
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
};
|
|
119
|
+
this.handleTouchEnd = () => {
|
|
120
|
+
this.handleMouseUp();
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
createRenderRoot() {
|
|
124
|
+
return this; // light DOM
|
|
125
|
+
}
|
|
126
|
+
connectedCallback() {
|
|
127
|
+
super.connectedCallback();
|
|
128
|
+
this.currentSplit = this.initialSplit;
|
|
129
|
+
this.checkMobile();
|
|
130
|
+
window.addEventListener("resize", this.handleResize);
|
|
131
|
+
}
|
|
132
|
+
disconnectedCallback() {
|
|
133
|
+
super.disconnectedCallback();
|
|
134
|
+
window.removeEventListener("resize", this.handleResize);
|
|
135
|
+
}
|
|
136
|
+
checkMobile() {
|
|
137
|
+
const wasMobile = this.isMobile;
|
|
138
|
+
this.isMobile = window.innerWidth < this.mobileBreakpoint;
|
|
139
|
+
if (wasMobile !== this.isMobile) {
|
|
140
|
+
this.requestUpdate();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
render() {
|
|
144
|
+
// Vertical mode
|
|
145
|
+
if (this.vertical) {
|
|
146
|
+
const panel1 = this.topPanel || this.leftPanel;
|
|
147
|
+
const panel2 = this.bottomPanel || this.rightPanel;
|
|
148
|
+
const hideSecond = this.hideBottom || this.hideRight;
|
|
149
|
+
if (!panel1 || !panel2) {
|
|
150
|
+
return html `<div>${i18n("Loading...")}</div>`;
|
|
151
|
+
}
|
|
152
|
+
return html `
|
|
153
|
+
<div class="flex flex-col h-full w-full relative" ${ref(this.containerRef)}>
|
|
154
|
+
<!-- Top Panel -->
|
|
155
|
+
<div
|
|
156
|
+
class="w-full overflow-hidden"
|
|
157
|
+
style="height: ${hideSecond ? "100%" : this.currentSplit + "%"}"
|
|
158
|
+
${ref(this.firstPanelRef)}
|
|
159
|
+
>
|
|
160
|
+
${panel1}
|
|
161
|
+
</div>
|
|
162
|
+
|
|
163
|
+
<!-- Horizontal Divider -->
|
|
164
|
+
<div
|
|
165
|
+
class="h-1 bg-border hover:bg-accent cursor-row-resize relative flex-shrink-0
|
|
166
|
+
before:content-[''] before:absolute before:inset-x-0 before:-top-2 before:-bottom-2 before:h-5
|
|
167
|
+
md:before:-top-1 md:before:-bottom-1 md:before:h-3 ${hideSecond ? "hidden" : ""}"
|
|
168
|
+
@mousedown=${this.handleMouseDown}
|
|
169
|
+
@touchstart=${this.handleTouchStart}
|
|
170
|
+
@touchmove=${this.handleTouchMove}
|
|
171
|
+
@touchend=${this.handleTouchEnd}
|
|
172
|
+
${ref(this.dividerRef)}
|
|
173
|
+
>
|
|
174
|
+
<!-- Grab handle indicator -->
|
|
175
|
+
<div
|
|
176
|
+
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-1 w-8 bg-muted-foreground/30 rounded-full"
|
|
177
|
+
></div>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
<!-- Bottom Panel -->
|
|
181
|
+
<div
|
|
182
|
+
class="w-full overflow-hidden ${hideSecond ? "hidden" : ""}"
|
|
183
|
+
style="height: ${100 - this.currentSplit}%"
|
|
184
|
+
${ref(this.secondPanelRef)}
|
|
185
|
+
>
|
|
186
|
+
${panel2}
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
`;
|
|
190
|
+
}
|
|
191
|
+
// Horizontal mode (default)
|
|
192
|
+
if (!this.leftPanel || !this.rightPanel) {
|
|
193
|
+
return html `<div>${i18n("Loading...")}</div>`;
|
|
194
|
+
}
|
|
195
|
+
return html `
|
|
196
|
+
<div class="flex h-full w-full relative" ${ref(this.containerRef)}>
|
|
197
|
+
<!-- Left Panel -->
|
|
198
|
+
<div
|
|
199
|
+
class="h-full overflow-hidden"
|
|
200
|
+
style="width: ${this.hideRight ? "100%" : this.currentSplit + "%"}"
|
|
201
|
+
${ref(this.firstPanelRef)}
|
|
202
|
+
>
|
|
203
|
+
${this.leftPanel}
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<!-- Vertical Divider -->
|
|
207
|
+
<div
|
|
208
|
+
class="w-1 bg-border hover:bg-accent cursor-col-resize relative flex-shrink-0
|
|
209
|
+
before:content-[''] before:absolute before:inset-y-0 before:-left-2 before:-right-2 before:w-5
|
|
210
|
+
md:before:-left-1 md:before:-right-1 md:before:w-3 ${this.hideRight ? "hidden" : ""}"
|
|
211
|
+
@mousedown=${this.handleMouseDown}
|
|
212
|
+
@touchstart=${this.handleTouchStart}
|
|
213
|
+
@touchmove=${this.handleTouchMove}
|
|
214
|
+
@touchend=${this.handleTouchEnd}
|
|
215
|
+
${ref(this.dividerRef)}
|
|
216
|
+
>
|
|
217
|
+
<!-- Grab handle indicator -->
|
|
218
|
+
<div
|
|
219
|
+
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-8 bg-muted-foreground/30 rounded-full"
|
|
220
|
+
></div>
|
|
221
|
+
</div>
|
|
222
|
+
|
|
223
|
+
<!-- Right Panel -->
|
|
224
|
+
<div
|
|
225
|
+
class="h-full overflow-hidden ${this.hideRight ? "hidden" : ""}"
|
|
226
|
+
style="width: ${100 - this.currentSplit}%"
|
|
227
|
+
${ref(this.secondPanelRef)}
|
|
228
|
+
>
|
|
229
|
+
${this.rightPanel}
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
`;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
__decorate([
|
|
236
|
+
property({ type: Object })
|
|
237
|
+
], SplitPanel.prototype, "leftPanel", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
property({ type: Object })
|
|
240
|
+
], SplitPanel.prototype, "rightPanel", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
property({ type: Object })
|
|
243
|
+
], SplitPanel.prototype, "topPanel", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
property({ type: Object })
|
|
246
|
+
], SplitPanel.prototype, "bottomPanel", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
property()
|
|
249
|
+
], SplitPanel.prototype, "initialSplit", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
property()
|
|
252
|
+
], SplitPanel.prototype, "minSize", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
property()
|
|
255
|
+
], SplitPanel.prototype, "hideRight", void 0);
|
|
256
|
+
__decorate([
|
|
257
|
+
property()
|
|
258
|
+
], SplitPanel.prototype, "hideBottom", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
property()
|
|
261
|
+
], SplitPanel.prototype, "mobileBreakpoint", void 0);
|
|
262
|
+
__decorate([
|
|
263
|
+
property({ type: Boolean })
|
|
264
|
+
], SplitPanel.prototype, "vertical", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
state()
|
|
267
|
+
], SplitPanel.prototype, "currentSplit", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
state()
|
|
270
|
+
], SplitPanel.prototype, "isMobile", void 0);
|
|
271
|
+
SplitPanel = __decorate([
|
|
272
|
+
customElement("split-panel")
|
|
273
|
+
], SplitPanel);
|
|
274
|
+
export { SplitPanel };
|
|
275
|
+
//# sourceMappingURL=SplitPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitPanel.js","sourceRoot":"","sources":["../src/SplitPanel.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAY,GAAG,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAG1B,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,UAAU;IAAnC;;QAKQ,iBAAY,GAAG,EAAE,CAAC,CAAC,gCAAgC;QACnD,YAAO,GAAG,GAAG,CAAC,CAAC,wCAAwC;QACvD,cAAS,GAAG,KAAK,CAAC,CAAC,qCAAqC;QACxD,eAAU,GAAG,KAAK,CAAC,CAAC,sCAAsC;QAC1D,qBAAgB,GAAG,IAAI,CAAC,CAAC,gCAAgC;QACxC,aAAQ,GAAG,KAAK,CAAC,CAAC,sBAAsB;QAEpD,iBAAY,GAAG,EAAE,CAAC;QAClB,aAAQ,GAAG,KAAK,CAAC;QAE1B,iBAAY,GAAwB,SAAS,EAAE,CAAC;QAChD,kBAAa,GAAwB,SAAS,EAAE,CAAC;QACjD,mBAAc,GAAwB,SAAS,EAAE,CAAC;QAClD,eAAU,GAAwB,SAAS,EAAE,CAAC;QAE9C,eAAU,GAAG,KAAK,CAAC;QACnB,aAAQ,GAAG,CAAC,CAAC;QACb,eAAU,GAAG,EAAE,CAAC;QAkBhB,iBAAY,GAAG,GAAG,EAAE;YACzB,IAAI,CAAC,WAAW,EAAE,CAAC;QACtB,CAAC,CAAC;QAUM,oBAAe,GAAG,CAAC,CAAa,EAAE,EAAE;YAC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,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAA4C;AAC3D;IAAX,QAAQ,EAAE;gDAAmB;AAClB;IAAX,QAAQ,EAAE;2CAAe;AACd;IAAX,QAAQ,EAAE;6CAAmB;AAClB;IAAX,QAAQ,EAAE;8CAAoB;AACnB;IAAX,QAAQ,EAAE;oDAAyB;AACP;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAkB;AAE7B;IAAhB,KAAK,EAAE;gDAA2B;AAClB;IAAhB,KAAK,EAAE;4CAA0B;AAbxB,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CA0PtB"}
|
package/dist/Switch.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ComponentPropsWithoutChildren, type TemplateResult } from "./mini.js";
|
|
2
|
+
interface SwitchProps extends ComponentPropsWithoutChildren {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
label?: TemplateResult | string;
|
|
6
|
+
name?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
onChange?: (checked: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function Switch(props: SwitchProps): TemplateResult;
|
|
11
|
+
export declare function Switch(checked?: boolean, onChange?: (checked: boolean) => void, label?: TemplateResult | string, disabled?: boolean, className?: string): TemplateResult;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=Switch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../src/Switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,6BAA6B,EAAY,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAE9F,UAAU,WAAY,SAAQ,6BAA6B;IACxD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;AAqDD,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,cAAc,CAAC;AAC3D,wBAAgB,MAAM,CACnB,OAAO,CAAC,EAAE,OAAO,EACjB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,EACrC,KAAK,CAAC,EAAE,cAAc,GAAG,MAAM,EAC/B,QAAQ,CAAC,EAAE,OAAO,EAClB,SAAS,CAAC,EAAE,MAAM,GAClB,cAAc,CAAC"}
|
package/dist/Switch.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { fc, html } from "./mini.js";
|
|
2
|
+
const _Switch = fc(({ checked = false, disabled = false, label = "", name = "", id = "", onChange, className = "" }) => {
|
|
3
|
+
// Generate a unique ID if label is provided but ID is not
|
|
4
|
+
const switchId = id || (label ? `switch-${Math.random().toString(36).substr(2, 9)}` : "");
|
|
5
|
+
const handleClick = () => {
|
|
6
|
+
if (!disabled) {
|
|
7
|
+
onChange?.(!checked);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const baseClasses = "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50";
|
|
11
|
+
const checkedClasses = "data-[state=checked]:bg-primary data-[state=unchecked]:bg-input";
|
|
12
|
+
const thumbClasses = "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0";
|
|
13
|
+
return html `
|
|
14
|
+
<div class="flex items-center space-x-2 ${className}">
|
|
15
|
+
<button
|
|
16
|
+
type="button"
|
|
17
|
+
role="switch"
|
|
18
|
+
id="${switchId}"
|
|
19
|
+
aria-checked="${checked}"
|
|
20
|
+
data-state="${checked ? "checked" : "unchecked"}"
|
|
21
|
+
?disabled=${disabled}
|
|
22
|
+
class="${baseClasses} ${checkedClasses}"
|
|
23
|
+
@click=${handleClick}
|
|
24
|
+
>
|
|
25
|
+
<span data-state="${checked ? "checked" : "unchecked"}" class="${thumbClasses}"></span>
|
|
26
|
+
</button>
|
|
27
|
+
${label
|
|
28
|
+
? html `
|
|
29
|
+
<label
|
|
30
|
+
for="${switchId}"
|
|
31
|
+
class="text-sm font-medium leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer select-none"
|
|
32
|
+
@click=${handleClick}
|
|
33
|
+
>
|
|
34
|
+
${label}
|
|
35
|
+
</label>
|
|
36
|
+
`
|
|
37
|
+
: ""}
|
|
38
|
+
${name ? html ` <input type="hidden" name="${name}" .value=${checked ? "on" : "off"} /> ` : ""}
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
41
|
+
});
|
|
42
|
+
export function Switch(propsOrChecked = false, onChange, label = "", disabled = false, className = "") {
|
|
43
|
+
if (typeof propsOrChecked === "object" && propsOrChecked !== null) {
|
|
44
|
+
return _Switch(propsOrChecked);
|
|
45
|
+
}
|
|
46
|
+
return _Switch({ checked: propsOrChecked, onChange, label, disabled, className });
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=Switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../src/Switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,EAAE,EAAE,IAAI,EAAuB,MAAM,WAAW,CAAC;AAW9F,MAAM,OAAO,GAAG,EAAE,CACf,CAAC,EAAE,OAAO,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,KAAK,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,EAAE,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B,SAAS,GAAG,EAAE;IAEd,IAAI,OAAO,cAAc,KAAK,QAAQ,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QACjE,OAAO,OAAO,CAAC,cAA6B,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,CAAC,EAAE,OAAO,EAAE,cAAyB,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;AAChG,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type BaseComponentProps, type TemplateResult } from "./mini.js";
|
|
2
|
+
interface TextareaProps extends BaseComponentProps {
|
|
3
|
+
id?: string;
|
|
4
|
+
value?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
error?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
name?: string;
|
|
11
|
+
rows?: number;
|
|
12
|
+
cols?: number;
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
resize?: "none" | "both" | "horizontal" | "vertical";
|
|
15
|
+
onInput?: (e: Event) => void;
|
|
16
|
+
onChange?: (e: Event) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function Textarea(props: TextareaProps): TemplateResult;
|
|
19
|
+
export declare function Textarea(value?: string, placeholder?: string, onInput?: (e: Event) => void, rows?: number, className?: string): TemplateResult;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=Textarea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../src/Textarea.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,kBAAkB,EAAY,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAEnF,UAAU,aAAc,SAAQ,kBAAkB;IAC/C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC;IACrD,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;CAChC;AAgED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,CAAC;AAC/D,wBAAgB,QAAQ,CACrB,KAAK,CAAC,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,EAC5B,IAAI,CAAC,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,GAClB,cAAc,CAAC"}
|
package/dist/Textarea.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { i18n } from "./i18n.js";
|
|
2
|
+
import { fc, html } from "./mini.js";
|
|
3
|
+
const _Textarea = fc(({ id = "", value = "", placeholder = "", label = "", error = "", disabled = false, required = false, name = "", rows = 4, cols, maxLength, resize = "vertical", onInput, onChange, className = "", }) => {
|
|
4
|
+
const resizeClasses = {
|
|
5
|
+
none: "resize-none",
|
|
6
|
+
both: "resize",
|
|
7
|
+
horizontal: "resize-x",
|
|
8
|
+
vertical: "resize-y",
|
|
9
|
+
};
|
|
10
|
+
const baseClasses = "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50";
|
|
11
|
+
const stateClasses = error ? "border-destructive" : "";
|
|
12
|
+
return html `
|
|
13
|
+
<div class="flex flex-col gap-1.5 ${className}">
|
|
14
|
+
${label
|
|
15
|
+
? html `
|
|
16
|
+
<label class="text-sm font-medium text-foreground">
|
|
17
|
+
${label} ${required ? html `<span class="text-destructive">${i18n("*")}</span>` : ""}
|
|
18
|
+
</label>
|
|
19
|
+
`
|
|
20
|
+
: ""}
|
|
21
|
+
<textarea
|
|
22
|
+
id="${id}"
|
|
23
|
+
class="${baseClasses} ${resizeClasses[resize]} ${stateClasses}"
|
|
24
|
+
.value=${value || ""}
|
|
25
|
+
placeholder="${placeholder}"
|
|
26
|
+
?disabled=${disabled}
|
|
27
|
+
?required=${required}
|
|
28
|
+
?aria-invalid=${!!error}
|
|
29
|
+
name="${name}"
|
|
30
|
+
rows="${rows}"
|
|
31
|
+
cols="${cols ?? ""}"
|
|
32
|
+
maxlength="${maxLength ?? ""}"
|
|
33
|
+
@input=${onInput}
|
|
34
|
+
@change=${onChange}
|
|
35
|
+
></textarea>
|
|
36
|
+
${error ? html `<span class="text-sm text-destructive">${error}</span>` : ""}
|
|
37
|
+
</div>
|
|
38
|
+
`;
|
|
39
|
+
});
|
|
40
|
+
export function Textarea(propsOrValue = "", placeholder = "", onInput, rows = 4, className = "") {
|
|
41
|
+
// Check if it's a props object (has any TextareaProps properties)
|
|
42
|
+
if (typeof propsOrValue === "object" && propsOrValue !== null && !Array.isArray(propsOrValue)) {
|
|
43
|
+
// Check if it looks like a props object by checking for common properties
|
|
44
|
+
const obj = propsOrValue;
|
|
45
|
+
if ("value" in obj ||
|
|
46
|
+
"placeholder" in obj ||
|
|
47
|
+
"label" in obj ||
|
|
48
|
+
"rows" in obj ||
|
|
49
|
+
"onInput" in obj ||
|
|
50
|
+
"onChange" in obj ||
|
|
51
|
+
"disabled" in obj ||
|
|
52
|
+
"required" in obj ||
|
|
53
|
+
"error" in obj ||
|
|
54
|
+
"className" in obj ||
|
|
55
|
+
"id" in obj ||
|
|
56
|
+
"name" in obj ||
|
|
57
|
+
"maxLength" in obj ||
|
|
58
|
+
"resize" in obj ||
|
|
59
|
+
"cols" in obj) {
|
|
60
|
+
return _Textarea(propsOrValue);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Convert to string if it's not already
|
|
64
|
+
const valueStr = typeof propsOrValue === "string" ? propsOrValue : "";
|
|
65
|
+
return _Textarea({ value: valueStr, placeholder, onInput, rows, className });
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=Textarea.js.map
|