@golemui/gui-lit 0.12.2 → 0.13.1
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/CHANGELOG.md +16 -0
- package/abstract-calendar-YDgwwbqe.js +528 -0
- package/{accordion.element-81uTv6Ms.js → accordion.element-ChLmV6QT.js} +24 -22
- package/{alert.element-DWrS5ggK.js → alert.element-9QFlqjj9.js} +23 -21
- package/button.element-ATNRRDN3.js +121 -0
- package/calendar-P9DzVryu.js +96 -0
- package/{calendar.element-C1rLK7aY.js → calendar.element-O2of7VBr.js} +25 -22
- package/checkbox.element-DMmer4Jw.js +199 -0
- package/currency.element-C7SZkoPP.js +266 -0
- package/date-CG1562vW.js +786 -0
- package/date-input-VJG8lMVN.js +266 -0
- package/{date-picker.element-GNC8f3Qi.js → date-picker.element-Bcyhc0fb.js} +29 -25
- package/{date.element-Dzw-UJzC.js → date.element-DfXmcgZi.js} +25 -22
- package/{dropdown.element-CebROj9s.js → dropdown.element-DCUI5Y7I.js} +24 -22
- package/errors-QjKhr6mA.js +109 -0
- package/{flex.element-BMqqfxjI.js → flex.element-B0sG0YT1.js} +24 -22
- package/{grid.element-CBMoOuLt.js → grid.element-Bf5aEjkj.js} +24 -22
- package/index.js +2708 -1174
- package/index.umd.cjs +982 -108
- package/lib/components/accordion.element.d.ts +7 -7
- package/lib/components/alert.element.d.ts +6 -6
- package/lib/components/button.element.d.ts +6 -6
- package/lib/components/calendar.element.d.ts +6 -6
- package/lib/components/checkbox.element.d.ts +6 -6
- package/lib/components/currency.element.d.ts +6 -6
- package/lib/components/date-picker.element.d.ts +6 -6
- package/lib/components/date.element.d.ts +6 -6
- package/lib/components/dropdown.element.d.ts +6 -6
- package/lib/components/flex.element.d.ts +6 -6
- package/lib/components/grid.element.d.ts +6 -6
- package/lib/components/list.element.d.ts +6 -6
- package/lib/components/markdown-text.element.d.ts +6 -6
- package/lib/components/markdown.element.d.ts +6 -6
- package/lib/components/number.element.d.ts +6 -6
- package/lib/components/password.element.d.ts +6 -6
- package/lib/components/radiogroup.element.d.ts +6 -6
- package/lib/components/range-calendar.element.d.ts +6 -6
- package/lib/components/range-date-input.element.d.ts +6 -6
- package/lib/components/range-date-picker.element.d.ts +6 -6
- package/lib/components/renderer.element.d.ts +6 -6
- package/lib/components/repeater.element.d.ts +6 -6
- package/lib/components/select.element.d.ts +6 -6
- package/lib/components/tabs.element.d.ts +6 -6
- package/lib/components/textarea.element.d.ts +6 -6
- package/lib/components/textinput.element.d.ts +6 -6
- package/lib/components/toggle.element.d.ts +6 -6
- package/lib/widget.loaders.d.ts +2 -2
- package/list-CtFsv7GB.js +284 -0
- package/{list.element-DIIgN_Ww.js → list.element-G8RNRZXU.js} +30 -27
- package/markdown-text-X-BRJT6K.js +30 -0
- package/{markdown-text.element-DY7b-dU5.js → markdown-text.element-C_1OqrGa.js} +23 -20
- package/markdown.element-CT1JOOM3.js +596 -0
- package/number.element-HaXEg_7U.js +282 -0
- package/one-of-DifUsEYY.js +48 -0
- package/package.json +6 -6
- package/password.element-B4-0SCe4.js +238 -0
- package/radiogroup.element-DzHLgRh1.js +232 -0
- package/range-calendar-qpakwAba.js +326 -0
- package/{range-calendar.element-Bli9UfhN.js → range-calendar.element-C-4qqRGK.js} +20 -17
- package/range-date-input-CrNpOVHt.js +507 -0
- package/{range-date-input.element-BwPvGk5F.js → range-date-input.element-Iq5Y7uLQ.js} +20 -17
- package/{range-date-picker.element-DJQOwDPh.js → range-date-picker.element-4bg4Uraq.js} +29 -25
- package/{renderer.element-B99qD2mz.js → renderer.element-DMsheQGi.js} +19 -17
- package/{repeater.element-AaifWsOB.js → repeater.element-Ry8HyMfW.js} +41 -27
- package/select.element-DuGZjlZY.js +257 -0
- package/tabs-DzSCq_98.js +13 -0
- package/{tabs.element-k8JMNDXi.js → tabs.element-VLrtF1j5.js} +31 -29
- package/templates-Dk1jxLwS.js +75 -0
- package/textarea.element-C8yx2u0o.js +237 -0
- package/textinput.element-DKuplF1A.js +204 -0
- package/toggle.element-NXRrhALB.js +201 -0
- package/button.element-hjhVBamJ.js +0 -56
- package/checkbox.element-bu9_MvED.js +0 -65
- package/currency.element-Bxv2WxAx.js +0 -72
- package/default-list-item-renderer-DNVEjKSX.js +0 -23
- package/markdown.element-ZD_n4ObO.js +0 -73
- package/number.element-B0E7W2TK.js +0 -70
- package/password.element-C4_eLdUO.js +0 -71
- package/radiogroup.element-BD8qBNoO.js +0 -68
- package/select.element-BLxtqB0A.js +0 -74
- package/textarea.element-DgDwfzYP.js +0 -70
- package/textinput.element-DSLFDjfb.js +0 -67
- package/toggle.element-BLu6F99u.js +0 -65
|
@@ -0,0 +1,596 @@
|
|
|
1
|
+
import { InputWidgetAdapter as O, formContext as S, inputContext as V } from "@golemui/lit";
|
|
2
|
+
import "@golemui/gui-shared";
|
|
3
|
+
import { LitElement as H, html as u, nothing as $ } from "lit";
|
|
4
|
+
import { property as l, state as L, customElement as A } from "lit/decorators.js";
|
|
5
|
+
import { classMap as y } from "lit/directives/class-map.js";
|
|
6
|
+
import { G as T, b as I, c as M } from "./templates-Dk1jxLwS.js";
|
|
7
|
+
import { styleMap as B } from "lit-html/directives/style-map.js";
|
|
8
|
+
import { ifDefined as x } from "lit/directives/if-defined.js";
|
|
9
|
+
import "./markdown-text-X-BRJT6K.js";
|
|
10
|
+
import { consume as _, provide as F } from "@lit/context";
|
|
11
|
+
import "rxjs";
|
|
12
|
+
var Z = Object.defineProperty, D = Object.getOwnPropertyDescriptor, r = (t, e, i, o) => {
|
|
13
|
+
for (var s = o > 1 ? void 0 : o ? D(e, i) : e, a = t.length - 1, d; a >= 0; a--)
|
|
14
|
+
(d = t[a]) && (s = (o ? d(e, i, s) : d(s)) || s);
|
|
15
|
+
return o && s && Z(e, i, s), s;
|
|
16
|
+
};
|
|
17
|
+
let n = class extends H {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments), this.uid = void 0, this.label = void 0, this.localeId = "en", this.errors = [], this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.hint = void 0, this.tools = void 0, this.placeholder = void 0, this.autocomplete = void 0, this.minimumHeight = void 0, this.autoGrow = !1, this.defaultOpenPreview = void 0, this.maxLength = void 0, this.headingTitle = void 0, this.boldTitle = void 0, this.italicTitle = void 0, this.strikethroughTitle = void 0, this.quoteTitle = void 0, this.linkTitle = void 0, this.orderedListTitle = void 0, this.unorderedListTitle = void 0, this.splitViewTitle = void 0, this.dependencies = void 0, this.splitViewActive = !1, this.activeFormats = {}, this.splitViewInitialized = !1, this.ariaController = new T(this, {
|
|
20
|
+
getTargets: () => this.querySelectorAll(`textarea[id="${this.uid}"]`),
|
|
21
|
+
getState: () => ({
|
|
22
|
+
uid: this.uid,
|
|
23
|
+
templateData: {
|
|
24
|
+
hint: this.hint,
|
|
25
|
+
errors: this.errors,
|
|
26
|
+
readonly: this.readOnly,
|
|
27
|
+
disabled: this.disabled,
|
|
28
|
+
touched: this.touched
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
createRenderRoot() {
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
38
|
+
}
|
|
39
|
+
updated() {
|
|
40
|
+
this.recalculateAutoGrow();
|
|
41
|
+
}
|
|
42
|
+
willUpdate(t) {
|
|
43
|
+
!this.splitViewInitialized && t.has("defaultOpenPreview") && (this.splitViewActive = !!this.defaultOpenPreview, this.splitViewInitialized = !0);
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
super.render();
|
|
47
|
+
const t = {
|
|
48
|
+
uid: this.uid,
|
|
49
|
+
label: this.label,
|
|
50
|
+
errors: this.errors,
|
|
51
|
+
touched: this.touched,
|
|
52
|
+
required: this.required,
|
|
53
|
+
disabled: this.disabled,
|
|
54
|
+
readonly: this.readOnly,
|
|
55
|
+
value: this.value,
|
|
56
|
+
hint: this.hint,
|
|
57
|
+
placeholder: this.placeholder,
|
|
58
|
+
counterMode: this.counterMode ?? "remaining",
|
|
59
|
+
minimumHeight: this.minimumHeight ?? 120,
|
|
60
|
+
autoGrow: this.autoGrow ?? !1,
|
|
61
|
+
defaultOpenPreview: this.defaultOpenPreview ?? !1,
|
|
62
|
+
maxLength: this.maxLength,
|
|
63
|
+
dependencies: this.dependencies
|
|
64
|
+
}, e = {
|
|
65
|
+
"gui-markdown--icon": !1
|
|
66
|
+
};
|
|
67
|
+
let i = u``;
|
|
68
|
+
if (t.counterMode && t.maxLength) {
|
|
69
|
+
const s = {
|
|
70
|
+
"gui-markdown--counter": !0,
|
|
71
|
+
"gui-markdown--counter__error": (t.value?.length ?? 0) > t.maxLength
|
|
72
|
+
}, a = t.counterMode === "current" ? u`<span>${t.value?.length ?? 0}</span>` : u`<span>${t.maxLength - (t.value?.length ?? 0)}</span>`;
|
|
73
|
+
i = u`<div class=${y(s)}>
|
|
74
|
+
${a}
|
|
75
|
+
<span> / ${t.maxLength}</span>
|
|
76
|
+
</div>`;
|
|
77
|
+
}
|
|
78
|
+
const o = {
|
|
79
|
+
"min-height": `${t.minimumHeight}px`
|
|
80
|
+
};
|
|
81
|
+
return u`
|
|
82
|
+
${I(this.uid, t)}
|
|
83
|
+
|
|
84
|
+
<div
|
|
85
|
+
class=${y({
|
|
86
|
+
"gui-widget": !0,
|
|
87
|
+
"gui-markdown--with-preview": this.splitViewActive
|
|
88
|
+
})}
|
|
89
|
+
>
|
|
90
|
+
<nav class="gui-markdown__toolbar">
|
|
91
|
+
<ul>
|
|
92
|
+
${(this.tools ?? ["H", "B", "I", "S", "Q", "L", "|", "OL", "UL"]).map(
|
|
93
|
+
(s) => this.renderToolbarItem(s)
|
|
94
|
+
)}
|
|
95
|
+
<li>
|
|
96
|
+
<button
|
|
97
|
+
type="button"
|
|
98
|
+
tabindex="0"
|
|
99
|
+
class=${y({
|
|
100
|
+
"gui-markdown__toolbar-button": !0,
|
|
101
|
+
"gui-markdown__toolbar-button--active": this.splitViewActive
|
|
102
|
+
})}
|
|
103
|
+
@click=${this.splitView}
|
|
104
|
+
title=${this.splitViewTitle ?? "Split View"}
|
|
105
|
+
>
|
|
106
|
+
<svg
|
|
107
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
108
|
+
width="20"
|
|
109
|
+
height="20"
|
|
110
|
+
viewBox="0 0 256 256"
|
|
111
|
+
>
|
|
112
|
+
<path
|
|
113
|
+
d="M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40ZM56,56h64V200H56ZM200,200H136V56h64V200Z"
|
|
114
|
+
></path>
|
|
115
|
+
</svg>
|
|
116
|
+
</button>
|
|
117
|
+
</li>
|
|
118
|
+
</ul>
|
|
119
|
+
</nav>
|
|
120
|
+
<textarea
|
|
121
|
+
id=${x(this.uid)}
|
|
122
|
+
class=${y(e)}
|
|
123
|
+
style=${B(o)}
|
|
124
|
+
?required=${t.required}
|
|
125
|
+
?disabled=${t.disabled}
|
|
126
|
+
?readonly=${t.readonly}
|
|
127
|
+
placeholder=${x(t.placeholder)}
|
|
128
|
+
autocomplete=${this.autocomplete || $}
|
|
129
|
+
.value=${this.value || ""}
|
|
130
|
+
@input=${this.valueChanged}
|
|
131
|
+
@keyup=${this.detectFormats}
|
|
132
|
+
@mouseup=${this.detectFormats}
|
|
133
|
+
@blur=${this.onBlur}
|
|
134
|
+
></textarea>
|
|
135
|
+
|
|
136
|
+
${this.splitViewActive ? u`
|
|
137
|
+
<section
|
|
138
|
+
data-cy=${x(this.uid ? `${this.uid}_markdown` : $)}
|
|
139
|
+
class="gui-markdown__preview"
|
|
140
|
+
>
|
|
141
|
+
<gui-markdown-text
|
|
142
|
+
.md=${this.value || ""}
|
|
143
|
+
.dependencies=${this.dependencies}
|
|
144
|
+
></gui-markdown-text>
|
|
145
|
+
</section>
|
|
146
|
+
` : $}
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<div class="gui-markdown--validation">
|
|
150
|
+
<div>${M(this.uid, t)}</div>
|
|
151
|
+
${i}
|
|
152
|
+
</div>
|
|
153
|
+
`;
|
|
154
|
+
}
|
|
155
|
+
recalculateAutoGrow() {
|
|
156
|
+
if (!this.autoGrow) return;
|
|
157
|
+
const t = this.querySelector(`textarea[id="${this.uid}"]`);
|
|
158
|
+
if (!t) return;
|
|
159
|
+
const e = window.getComputedStyle(t), i = parseFloat(e.paddingTop), o = parseFloat(e.paddingBottom), s = i + o;
|
|
160
|
+
t.style.height = "auto", t.style.height = `${Math.max(this.minimumHeight ?? 120, t.scrollHeight - s)}px`;
|
|
161
|
+
}
|
|
162
|
+
splitView() {
|
|
163
|
+
this.splitViewActive = !this.splitViewActive;
|
|
164
|
+
}
|
|
165
|
+
renderToolbarItem(t) {
|
|
166
|
+
switch (t) {
|
|
167
|
+
case "H":
|
|
168
|
+
return u`<li>
|
|
169
|
+
<button
|
|
170
|
+
type="button"
|
|
171
|
+
tabindex="0"
|
|
172
|
+
class=${this.toolbarBtnClass("heading")}
|
|
173
|
+
@click=${this.applyFormat("# ", "", "heading")}
|
|
174
|
+
title=${this.headingTitle ?? "Heading"}
|
|
175
|
+
>
|
|
176
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
177
|
+
<path
|
|
178
|
+
d="M212,56V200a12,12,0,0,1-24,0V140H68v60a12,12,0,0,1-24,0V56a12,12,0,0,1,24,0v60H188V56a12,12,0,0,1,24,0Z"
|
|
179
|
+
></path>
|
|
180
|
+
</svg>
|
|
181
|
+
</button>
|
|
182
|
+
</li>`;
|
|
183
|
+
case "B":
|
|
184
|
+
return u`<li>
|
|
185
|
+
<button
|
|
186
|
+
type="button"
|
|
187
|
+
tabindex="0"
|
|
188
|
+
class=${this.toolbarBtnClass("bold")}
|
|
189
|
+
@click=${this.applyFormat("**", "**", "bold")}
|
|
190
|
+
title=${this.boldTitle ?? "Bold"}
|
|
191
|
+
>
|
|
192
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
193
|
+
<path
|
|
194
|
+
d="M185.08,114.46A48,48,0,0,0,148,36H80A12,12,0,0,0,68,48V200a12,12,0,0,0,12,12h80a52,52,0,0,0,25.08-97.54ZM92,60h56a24,24,0,0,1,0,48H92Zm68,128H92V132h68a28,28,0,0,1,0,56Z"
|
|
195
|
+
></path>
|
|
196
|
+
</svg>
|
|
197
|
+
</button>
|
|
198
|
+
</li>`;
|
|
199
|
+
case "I":
|
|
200
|
+
return u`<li>
|
|
201
|
+
<button
|
|
202
|
+
type="button"
|
|
203
|
+
tabindex="0"
|
|
204
|
+
class=${this.toolbarBtnClass("italic")}
|
|
205
|
+
@click=${this.applyFormat("_", "_", "italic")}
|
|
206
|
+
title=${this.italicTitle ?? "Italic"}
|
|
207
|
+
>
|
|
208
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
209
|
+
<path
|
|
210
|
+
d="M204,56a12,12,0,0,1-12,12H160.65l-40,120H144a12,12,0,0,1,0,24H64a12,12,0,0,1,0-24H95.35l40-120H112a12,12,0,0,1,0-24h80A12,12,0,0,1,204,56Z"
|
|
211
|
+
></path>
|
|
212
|
+
</svg>
|
|
213
|
+
</button>
|
|
214
|
+
</li>`;
|
|
215
|
+
case "S":
|
|
216
|
+
return u`<li>
|
|
217
|
+
<button
|
|
218
|
+
type="button"
|
|
219
|
+
tabindex="0"
|
|
220
|
+
class=${this.toolbarBtnClass("strikethrough")}
|
|
221
|
+
@click=${this.applyFormat("~~", "~~", "strikethrough")}
|
|
222
|
+
title=${this.strikethroughTitle ?? "Strikethrough"}
|
|
223
|
+
>
|
|
224
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
225
|
+
<path
|
|
226
|
+
d="M224,128a8,8,0,0,1-8,8H175.93c9.19,7.11,16.07,17.2,16.07,32,0,13.34-7,25.7-19.75,34.79C160.33,211.31,144.61,216,128,216s-32.33-4.69-44.25-13.21C71,193.7,64,181.34,64,168a8,8,0,0,1,16,0c0,17.35,22,32,48,32s48-14.65,48-32c0-14.85-10.54-23.58-38.77-32H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128ZM76.33,104a8,8,0,0,0,7.61-10.49A17.3,17.3,0,0,1,83.11,88c0-18.24,19.3-32,44.89-32,18.84,0,34.16,7.42,41,19.85a8,8,0,0,0,14-7.7C173.33,50.52,152.77,40,128,40,93.29,40,67.11,60.63,67.11,88a33.73,33.73,0,0,0,1.62,10.49A8,8,0,0,0,76.33,104Z"
|
|
227
|
+
></path>
|
|
228
|
+
</svg>
|
|
229
|
+
</button>
|
|
230
|
+
</li>`;
|
|
231
|
+
case "Q":
|
|
232
|
+
return u`<li>
|
|
233
|
+
<button
|
|
234
|
+
type="button"
|
|
235
|
+
tabindex="0"
|
|
236
|
+
class=${this.toolbarBtnClass("quote")}
|
|
237
|
+
@click=${this.applyFormat("> ", "", "quote")}
|
|
238
|
+
title=${this.quoteTitle ?? "Quote"}
|
|
239
|
+
>
|
|
240
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
241
|
+
<path
|
|
242
|
+
d="M100,52H40A20,20,0,0,0,20,72v64a20,20,0,0,0,20,20H96v4a28,28,0,0,1-28,28,12,12,0,0,0,0,24,52.06,52.06,0,0,0,52-52V72A20,20,0,0,0,100,52Zm-4,80H44V76H96ZM216,52H156a20,20,0,0,0-20,20v64a20,20,0,0,0,20,20h56v4a28,28,0,0,1-28,28,12,12,0,0,0,0,24,52.06,52.06,0,0,0,52-52V72A20,20,0,0,0,216,52Zm-4,80H160V76h52Z"
|
|
243
|
+
></path>
|
|
244
|
+
</svg>
|
|
245
|
+
</button>
|
|
246
|
+
</li>`;
|
|
247
|
+
case "L":
|
|
248
|
+
return u`<li>
|
|
249
|
+
<button
|
|
250
|
+
type="button"
|
|
251
|
+
tabindex="0"
|
|
252
|
+
class=${this.toolbarBtnClass("link")}
|
|
253
|
+
@click=${this.applyFormat("[", "](url)", "link")}
|
|
254
|
+
title=${this.linkTitle ?? "Link"}
|
|
255
|
+
>
|
|
256
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
257
|
+
<path
|
|
258
|
+
d="M117.18,188.74a12,12,0,0,1,0,17l-5.12,5.12A58.26,58.26,0,0,1,70.6,228h0A58.62,58.62,0,0,1,29.14,127.92L63.89,93.17a58.64,58.64,0,0,1,98.56,28.11,12,12,0,1,1-23.37,5.44,34.65,34.65,0,0,0-58.22-16.58L46.11,144.89A34.62,34.62,0,0,0,70.57,204h0a34.41,34.41,0,0,0,24.49-10.14l5.11-5.12A12,12,0,0,1,117.18,188.74ZM226.83,45.17a58.65,58.65,0,0,0-82.93,0l-5.11,5.11a12,12,0,0,0,17,17l5.12-5.12a34.63,34.63,0,1,1,49,49L175.1,145.86A34.39,34.39,0,0,1,150.61,156h0a34.63,34.63,0,0,1-33.69-26.72,12,12,0,0,0-23.38,5.44A58.64,58.64,0,0,0,150.56,180h.05a58.28,58.28,0,0,0,41.47-17.17l34.75-34.75a58.62,58.62,0,0,0,0-82.91Z"
|
|
259
|
+
></path>
|
|
260
|
+
</svg>
|
|
261
|
+
</button>
|
|
262
|
+
</li>`;
|
|
263
|
+
case "OL":
|
|
264
|
+
return u`<li>
|
|
265
|
+
<button
|
|
266
|
+
type="button"
|
|
267
|
+
tabindex="0"
|
|
268
|
+
class=${this.toolbarBtnClass("orderedList")}
|
|
269
|
+
@click=${this.applyFormat("1. ", "", "orderedList")}
|
|
270
|
+
title=${this.orderedListTitle ?? "Ordered List"}
|
|
271
|
+
>
|
|
272
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
273
|
+
<path
|
|
274
|
+
d="M228,128a12,12,0,0,1-12,12H116a12,12,0,0,1,0-24H216A12,12,0,0,1,228,128ZM116,76H216a12,12,0,0,0,0-24H116a12,12,0,0,0,0,24ZM216,180H116a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24ZM44,59.31V104a12,12,0,0,0,24,0V40A12,12,0,0,0,50.64,29.27l-16,8a12,12,0,0,0,9.36,22Zm39.73,96.86a27.7,27.7,0,0,0-11.2-18.63A28.89,28.89,0,0,0,32.9,143a27.71,27.71,0,0,0-4.17,7.54,12,12,0,0,0,22.55,8.21,4,4,0,0,1,.58-1,4.78,4.78,0,0,1,6.5-.82,3.82,3.82,0,0,1,1.61,2.6,3.63,3.63,0,0,1-.77,2.77l-.13.17L30.39,200.82A12,12,0,0,0,40,220H72a12,12,0,0,0,0-24H64l14.28-19.11A27.48,27.48,0,0,0,83.73,156.17Z"
|
|
275
|
+
></path>
|
|
276
|
+
</svg>
|
|
277
|
+
</button>
|
|
278
|
+
</li>`;
|
|
279
|
+
case "UL":
|
|
280
|
+
return u`<li>
|
|
281
|
+
<button
|
|
282
|
+
type="button"
|
|
283
|
+
tabindex="0"
|
|
284
|
+
class=${this.toolbarBtnClass("unorderedList")}
|
|
285
|
+
@click=${this.applyFormat("- ", "", "unorderedList")}
|
|
286
|
+
title=${this.unorderedListTitle ?? "Unordered List"}
|
|
287
|
+
>
|
|
288
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
289
|
+
<path
|
|
290
|
+
d="M76,64A12,12,0,0,1,88,52H216a12,12,0,0,1,0,24H88A12,12,0,0,1,76,64Zm140,52H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24Zm0,64H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24ZM44,112a16,16,0,1,0,16,16A16,16,0,0,0,44,112Zm0-64A16,16,0,1,0,60,64,16,16,0,0,0,44,48Zm0,128a16,16,0,1,0,16,16A16,16,0,0,0,44,176Z"
|
|
291
|
+
></path>
|
|
292
|
+
</svg>
|
|
293
|
+
</button>
|
|
294
|
+
</li>`;
|
|
295
|
+
case "|":
|
|
296
|
+
return u`<li>
|
|
297
|
+
<span class="gui-markdown__toolbar-separator">
|
|
298
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
299
|
+
<path d="M140,24V232a12,12,0,0,1-24,0V24a12,12,0,0,1,24,0Z"></path>
|
|
300
|
+
</svg>
|
|
301
|
+
</span>
|
|
302
|
+
</li>`;
|
|
303
|
+
default:
|
|
304
|
+
return $;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
toolbarBtnClass(t) {
|
|
308
|
+
return y({
|
|
309
|
+
"gui-markdown__toolbar-button": !0,
|
|
310
|
+
"gui-markdown__toolbar-button--active": !!t && !!this.activeFormats[t]
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
detectFormats() {
|
|
314
|
+
const t = this.querySelector(`textarea[id="${this.uid}"]`);
|
|
315
|
+
if (!t) return;
|
|
316
|
+
const { selectionStart: e, value: i } = t, o = i.lastIndexOf(`
|
|
317
|
+
`, e - 1) + 1, s = i.indexOf(`
|
|
318
|
+
`, e), a = i.substring(o, s === -1 ? i.length : s);
|
|
319
|
+
this.activeFormats = {
|
|
320
|
+
heading: /^#{1,6}\s/.test(a),
|
|
321
|
+
bold: this.isInsideInlineFormat(i, e, "**"),
|
|
322
|
+
italic: this.isInsideInlineFormat(i, e, "_"),
|
|
323
|
+
strikethrough: this.isInsideInlineFormat(i, e, "~~"),
|
|
324
|
+
quote: a.startsWith("> "),
|
|
325
|
+
link: this.isInsideLink(i, e),
|
|
326
|
+
orderedList: /^\d+\.\s/.test(a),
|
|
327
|
+
unorderedList: a.startsWith("- ")
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
isInsideInlineFormat(t, e, i) {
|
|
331
|
+
const o = t.lastIndexOf(`
|
|
332
|
+
`, e - 1) + 1, s = t.indexOf(`
|
|
333
|
+
`, e), a = t.substring(o, s === -1 ? t.length : s), d = e - o;
|
|
334
|
+
let h = 0;
|
|
335
|
+
for (; h < a.length; ) {
|
|
336
|
+
const g = a.indexOf(i, h);
|
|
337
|
+
if (g === -1) break;
|
|
338
|
+
const p = a.indexOf(i, g + i.length);
|
|
339
|
+
if (p === -1) break;
|
|
340
|
+
if (d >= g && d <= p + i.length)
|
|
341
|
+
return !0;
|
|
342
|
+
h = p + i.length;
|
|
343
|
+
}
|
|
344
|
+
return !1;
|
|
345
|
+
}
|
|
346
|
+
isInsideLink(t, e) {
|
|
347
|
+
const i = t.lastIndexOf(`
|
|
348
|
+
`, e - 1) + 1, o = t.indexOf(`
|
|
349
|
+
`, e), s = t.substring(i, o === -1 ? t.length : o), a = e - i, d = /\[[^\]]*\]\([^)]*\)/g;
|
|
350
|
+
let h;
|
|
351
|
+
for (; (h = d.exec(s)) !== null; )
|
|
352
|
+
if (a >= h.index && a <= h.index + h[0].length)
|
|
353
|
+
return !0;
|
|
354
|
+
return !1;
|
|
355
|
+
}
|
|
356
|
+
applyFormat(t, e = "", i = "") {
|
|
357
|
+
return () => {
|
|
358
|
+
const o = this.querySelector(`textarea[id="${this.uid}"]`);
|
|
359
|
+
if (o) {
|
|
360
|
+
if (i && this.activeFormats[i])
|
|
361
|
+
this.removeFormat(o, t, e, i);
|
|
362
|
+
else {
|
|
363
|
+
const { selectionStart: s, selectionEnd: a, value: d } = o, h = d.substring(s, a), g = d.substring(0, s), p = d.substring(a);
|
|
364
|
+
o.value = `${g}${t}${h}${e}${p}`, o.selectionStart = s + t.length, o.selectionEnd = s + t.length + h.length;
|
|
365
|
+
}
|
|
366
|
+
o.focus(), o.dispatchEvent(new Event("input", { bubbles: !0 })), this.detectFormats();
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
removeFormat(t, e, i, o) {
|
|
371
|
+
const { selectionStart: s, value: a } = t, d = a.lastIndexOf(`
|
|
372
|
+
`, s - 1) + 1, h = a.indexOf(`
|
|
373
|
+
`, s), g = a.substring(d, h === -1 ? a.length : h);
|
|
374
|
+
if (i)
|
|
375
|
+
if (o === "link") {
|
|
376
|
+
const p = s - d, w = /\[([^\]]*)\]\([^)]*\)/g;
|
|
377
|
+
let c;
|
|
378
|
+
for (; (c = w.exec(g)) !== null; )
|
|
379
|
+
if (p >= c.index && p <= c.index + c[0].length) {
|
|
380
|
+
const v = c[1], m = d + c.index, b = m + c[0].length;
|
|
381
|
+
t.value = `${a.substring(0, m)}${v}${a.substring(b)}`, t.selectionStart = m, t.selectionEnd = m + v.length;
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
} else {
|
|
385
|
+
const p = s - d;
|
|
386
|
+
let w = 0;
|
|
387
|
+
for (; w < g.length; ) {
|
|
388
|
+
const c = g.indexOf(e, w);
|
|
389
|
+
if (c === -1) break;
|
|
390
|
+
const v = g.indexOf(i, c + e.length);
|
|
391
|
+
if (v === -1) break;
|
|
392
|
+
if (p >= c && p <= v + i.length) {
|
|
393
|
+
const m = g.substring(c + e.length, v), b = d + c, C = d + v + i.length;
|
|
394
|
+
t.value = `${a.substring(0, b)}${m}${a.substring(C)}`, t.selectionStart = b, t.selectionEnd = b + m.length;
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
w = v + i.length;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
let p = e;
|
|
402
|
+
if (o === "heading") {
|
|
403
|
+
const m = g.match(/^#{1,6}\s/);
|
|
404
|
+
m && (p = m[0]);
|
|
405
|
+
} else if (o === "orderedList") {
|
|
406
|
+
const m = g.match(/^\d+\.\s/);
|
|
407
|
+
m && (p = m[0]);
|
|
408
|
+
}
|
|
409
|
+
const w = a.substring(0, d), c = g.substring(p.length), v = a.substring(h === -1 ? a.length : h);
|
|
410
|
+
t.value = `${w}${c}${v}`, t.selectionStart = Math.max(d, s - p.length), t.selectionEnd = t.selectionStart;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
valueChanged(t) {
|
|
414
|
+
if (t.stopPropagation(), !this.readOnly) {
|
|
415
|
+
const e = t.target;
|
|
416
|
+
this.dispatchEvent(
|
|
417
|
+
new CustomEvent("input", {
|
|
418
|
+
detail: { value: e.value },
|
|
419
|
+
bubbles: !0,
|
|
420
|
+
composed: !0
|
|
421
|
+
})
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
onBlur() {
|
|
426
|
+
this.dispatchEvent(
|
|
427
|
+
new CustomEvent("blur", {
|
|
428
|
+
bubbles: !0,
|
|
429
|
+
composed: !0
|
|
430
|
+
})
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
r([
|
|
435
|
+
l({ type: String })
|
|
436
|
+
], n.prototype, "uid", 2);
|
|
437
|
+
r([
|
|
438
|
+
l({ type: String })
|
|
439
|
+
], n.prototype, "label", 2);
|
|
440
|
+
r([
|
|
441
|
+
l({ type: String, attribute: "locale-id" })
|
|
442
|
+
], n.prototype, "localeId", 2);
|
|
443
|
+
r([
|
|
444
|
+
l({ type: Array })
|
|
445
|
+
], n.prototype, "errors", 2);
|
|
446
|
+
r([
|
|
447
|
+
l({ type: Boolean })
|
|
448
|
+
], n.prototype, "touched", 2);
|
|
449
|
+
r([
|
|
450
|
+
l({ type: Boolean })
|
|
451
|
+
], n.prototype, "required", 2);
|
|
452
|
+
r([
|
|
453
|
+
l({ type: Boolean })
|
|
454
|
+
], n.prototype, "disabled", 2);
|
|
455
|
+
r([
|
|
456
|
+
l({ type: Boolean, attribute: "readonly" })
|
|
457
|
+
], n.prototype, "readOnly", 2);
|
|
458
|
+
r([
|
|
459
|
+
l({ type: String })
|
|
460
|
+
], n.prototype, "value", 2);
|
|
461
|
+
r([
|
|
462
|
+
l({ type: String })
|
|
463
|
+
], n.prototype, "hint", 2);
|
|
464
|
+
r([
|
|
465
|
+
l({ type: Array })
|
|
466
|
+
], n.prototype, "tools", 2);
|
|
467
|
+
r([
|
|
468
|
+
l({ type: String })
|
|
469
|
+
], n.prototype, "placeholder", 2);
|
|
470
|
+
r([
|
|
471
|
+
l({ type: String })
|
|
472
|
+
], n.prototype, "autocomplete", 2);
|
|
473
|
+
r([
|
|
474
|
+
l({ type: String, attribute: "countermode" })
|
|
475
|
+
], n.prototype, "counterMode", 2);
|
|
476
|
+
r([
|
|
477
|
+
l({ type: Number, attribute: "minimumheight" })
|
|
478
|
+
], n.prototype, "minimumHeight", 2);
|
|
479
|
+
r([
|
|
480
|
+
l({ type: Boolean, attribute: "autogrow" })
|
|
481
|
+
], n.prototype, "autoGrow", 2);
|
|
482
|
+
r([
|
|
483
|
+
l({ type: Boolean, attribute: "defaultopenpreview" })
|
|
484
|
+
], n.prototype, "defaultOpenPreview", 2);
|
|
485
|
+
r([
|
|
486
|
+
l({ type: Number, attribute: "maxlength" })
|
|
487
|
+
], n.prototype, "maxLength", 2);
|
|
488
|
+
r([
|
|
489
|
+
l({ type: String })
|
|
490
|
+
], n.prototype, "headingTitle", 2);
|
|
491
|
+
r([
|
|
492
|
+
l({ type: String })
|
|
493
|
+
], n.prototype, "boldTitle", 2);
|
|
494
|
+
r([
|
|
495
|
+
l({ type: String })
|
|
496
|
+
], n.prototype, "italicTitle", 2);
|
|
497
|
+
r([
|
|
498
|
+
l({ type: String })
|
|
499
|
+
], n.prototype, "strikethroughTitle", 2);
|
|
500
|
+
r([
|
|
501
|
+
l({ type: String })
|
|
502
|
+
], n.prototype, "quoteTitle", 2);
|
|
503
|
+
r([
|
|
504
|
+
l({ type: String })
|
|
505
|
+
], n.prototype, "linkTitle", 2);
|
|
506
|
+
r([
|
|
507
|
+
l({ type: String })
|
|
508
|
+
], n.prototype, "orderedListTitle", 2);
|
|
509
|
+
r([
|
|
510
|
+
l({ type: String })
|
|
511
|
+
], n.prototype, "unorderedListTitle", 2);
|
|
512
|
+
r([
|
|
513
|
+
l({ type: String })
|
|
514
|
+
], n.prototype, "splitViewTitle", 2);
|
|
515
|
+
r([
|
|
516
|
+
l({ type: Object })
|
|
517
|
+
], n.prototype, "dependencies", 2);
|
|
518
|
+
r([
|
|
519
|
+
L()
|
|
520
|
+
], n.prototype, "splitViewActive", 2);
|
|
521
|
+
r([
|
|
522
|
+
L()
|
|
523
|
+
], n.prototype, "activeFormats", 2);
|
|
524
|
+
n = r([
|
|
525
|
+
A("gui-markdown")
|
|
526
|
+
], n);
|
|
527
|
+
typeof customElements < "u" && !customElements.get("gui-markdown") && customElements.define("gui-markdown", n);
|
|
528
|
+
var E = Object.defineProperty, q = Object.getOwnPropertyDescriptor, k = (t, e, i, o) => {
|
|
529
|
+
for (var s = o > 1 ? void 0 : o ? q(e, i) : e, a = t.length - 1, d; a >= 0; a--)
|
|
530
|
+
(d = t[a]) && (s = (o ? d(e, i, s) : d(s)) || s);
|
|
531
|
+
return o && s && E(e, i, s), s;
|
|
532
|
+
};
|
|
533
|
+
let f = class extends H {
|
|
534
|
+
constructor() {
|
|
535
|
+
super(...arguments), this.adapter = new O(), this.subscriptions = [];
|
|
536
|
+
}
|
|
537
|
+
createRenderRoot() {
|
|
538
|
+
return this;
|
|
539
|
+
}
|
|
540
|
+
updated(t) {
|
|
541
|
+
super.updated(t);
|
|
542
|
+
const e = this.adapter.templateData.size;
|
|
543
|
+
e ? this.style.flex = String(e) : this.style.removeProperty("flex");
|
|
544
|
+
}
|
|
545
|
+
connectedCallback() {
|
|
546
|
+
super.connectedCallback(), this.classList.add("gui-markdown", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
547
|
+
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
render() {
|
|
551
|
+
return super.render(), u`
|
|
552
|
+
<gui-markdown
|
|
553
|
+
.uid=${this.widget.uid}
|
|
554
|
+
.label=${this.adapter.templateData.label}
|
|
555
|
+
.errors=${this.adapter.templateData.errors}
|
|
556
|
+
?touched=${this.adapter.templateData.touched}
|
|
557
|
+
?required=${this.adapter.templateData.validator?.required}
|
|
558
|
+
?disabled=${this.adapter.templateData.disabled}
|
|
559
|
+
?readonly=${this.adapter.templateData.readonly}
|
|
560
|
+
.value=${this.adapter.templateData.value}
|
|
561
|
+
.hint=${this.adapter.templateData.hint}
|
|
562
|
+
.placeholder=${this.adapter.templateData.placeholder}
|
|
563
|
+
.autocomplete=${this.adapter.templateData.autocomplete}
|
|
564
|
+
.counterMode=${this.adapter.templateData.counterMode}
|
|
565
|
+
.minimumHeight=${this.adapter.templateData.minimumHeight}
|
|
566
|
+
.autoGrow=${this.adapter.templateData.autoGrow}
|
|
567
|
+
.tools=${this.adapter.templateData.tools}
|
|
568
|
+
.defaultOpenPreview=${this.adapter.templateData.defaultOpenPreview}
|
|
569
|
+
.maxLength=${this.adapter.templateData.validator?.maxLength}
|
|
570
|
+
.dependencies=${this.adapter.templateData.deps}
|
|
571
|
+
@input=${this.valueChanged}
|
|
572
|
+
@blur=${() => this.adapter.onBlur()}
|
|
573
|
+
></gui-markdown>
|
|
574
|
+
`;
|
|
575
|
+
}
|
|
576
|
+
valueChanged(t) {
|
|
577
|
+
const e = t.detail.value;
|
|
578
|
+
this.adapter.valueChanged(e);
|
|
579
|
+
}
|
|
580
|
+
disconnectedCallback() {
|
|
581
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
k([
|
|
585
|
+
_({ context: S }),
|
|
586
|
+
l({ attribute: !1 })
|
|
587
|
+
], f.prototype, "formContext", 2);
|
|
588
|
+
k([
|
|
589
|
+
F({ context: V })
|
|
590
|
+
], f.prototype, "adapter", 2);
|
|
591
|
+
f = k([
|
|
592
|
+
A("gui-markdown-input")
|
|
593
|
+
], f);
|
|
594
|
+
export {
|
|
595
|
+
f as MarkdownElement
|
|
596
|
+
};
|