@golemui/gui-react 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/Accordion-BU3skkjb.js +58 -0
- package/Alert-DpUiDxQT.js +17 -0
- package/Button-BYVR5EKG.js +86 -0
- package/CHANGELOG.md +16 -0
- package/{Calendar-Dxavv2c7.js → Calendar-BmMkpTcV.js} +13 -11
- package/Checkbox-B1Tsf-vi.js +164 -0
- package/Currency-D0pOQwU4.js +233 -0
- package/{DateInput-CdkyyAhc.js → DateInput-CqFHtc9F.js} +12 -10
- package/{DatePicker-TkMCndrw.js → DatePicker-BmW3TO0X.js} +18 -15
- package/{Dropdown-jKk4TyOa.js → Dropdown-C-_zDFCe.js} +5 -3
- package/Flex-Rs-RvIcq.js +20 -0
- package/{Grid-DREMTVQI.js → Grid-BcPUrfRL.js} +3 -2
- package/{List-BjMIo577.js → List-YkH8gdMh.js} +5 -3
- package/Markdown-DeAW4y3P.js +571 -0
- package/MarkdownText-BdISjAsE.js +11 -0
- package/Number-GsGZMR5a.js +247 -0
- package/Password-B8QjtpUe.js +204 -0
- package/RadioGroup-Cd1_Zkkz.js +197 -0
- package/{RangeCalendar-u2vxIhna.js → RangeCalendar-9IJoFEXw.js} +10 -8
- package/{RangeDateInput-CopLdb6J.js → RangeDateInput-DrVR4T_z.js} +21 -19
- package/{RangeDatePicker-DXpV-B_G.js → RangeDatePicker-Cq_Tt6NE.js} +38 -35
- package/{Renderer-B6WmwKDv.js → Renderer-CWqudTUu.js} +4 -2
- package/Repeater-DE-DAylQ.js +124 -0
- package/Select-CCCPYQW6.js +238 -0
- package/{Tabs-C2qqi8xO.js → Tabs-BVgVVvnu.js} +4 -3
- package/TextArea-BlRaVCon.js +202 -0
- package/TextInput-KuHLSN2X.js +169 -0
- package/Toggle-D-bglMPv.js +166 -0
- package/abstract-calendar-JfbbRwFb.js +528 -0
- package/calendar-BgptByan.js +95 -0
- package/class-map-DrTVAYz_.js +26 -0
- package/date-BS1lA1xg.js +786 -0
- package/date-input-Dux0mFJw.js +266 -0
- package/directive-1yd1wdny.js +555 -0
- package/errors-6UKoJh8Y.js +108 -0
- package/index.js +2705 -1171
- package/index.umd.cjs +878 -2
- package/lib/components/Accordion.d.ts +2 -2
- package/lib/components/Alert.d.ts +2 -2
- package/lib/components/Button.d.ts +2 -2
- package/lib/components/Calendar.d.ts +2 -2
- package/lib/components/Checkbox.d.ts +2 -2
- package/lib/components/Currency.d.ts +2 -2
- package/lib/components/DateInput.d.ts +2 -2
- package/lib/components/DatePicker.d.ts +2 -2
- package/lib/components/Dropdown.d.ts +2 -2
- package/lib/components/Flex.d.ts +2 -2
- package/lib/components/Form.d.ts +5 -5
- package/lib/components/Grid.d.ts +2 -2
- package/lib/components/List.d.ts +2 -2
- package/lib/components/Markdown.d.ts +2 -2
- package/lib/components/MarkdownText.d.ts +2 -2
- package/lib/components/Number.d.ts +2 -2
- package/lib/components/Password.d.ts +2 -2
- package/lib/components/RadioGroup.d.ts +2 -2
- package/lib/components/RangeCalendar.d.ts +2 -2
- package/lib/components/RangeDateInput.d.ts +2 -2
- package/lib/components/RangeDatePicker.d.ts +2 -2
- package/lib/components/Renderer.d.ts +2 -2
- package/lib/components/Repeater.d.ts +2 -2
- package/lib/components/Select.d.ts +2 -2
- package/lib/components/Tabs.d.ts +2 -2
- package/lib/components/TextArea.d.ts +2 -2
- package/lib/components/TextInput.d.ts +2 -2
- package/lib/components/Toggle.d.ts +2 -2
- package/lib/widget.loaders.d.ts +2 -2
- package/list-DHX7bG4r.js +282 -0
- package/live-BfTBpQrp.js +24 -0
- package/markdown-text-BUv0K0WF.js +44 -0
- package/one-of-DifUsEYY.js +48 -0
- package/package.json +6 -6
- package/query-h1h36oxg.js +12 -0
- package/range-calendar-SAyiW3EF.js +326 -0
- package/range-date-input-8WtB1urD.js +507 -0
- package/repeat-BucBfSPF.js +79 -0
- package/state-DI9ZsB5W.js +7 -0
- package/style-map-C_0XzJlx.js +29 -0
- package/tabs-DzSCq_98.js +13 -0
- package/templates-DBGyvZtc.js +75 -0
- package/Accordion-Btp_b0xA.js +0 -59
- package/Alert-CBgIsMKO.js +0 -16
- package/Button-DN0G-MUb.js +0 -21
- package/Checkbox-ViM9MktI.js +0 -30
- package/Currency-C4QFWO7Y.js +0 -37
- package/DefaultListItemRenderer-lNc9Kk7x.js +0 -18
- package/Flex-gD893rrB.js +0 -19
- package/Markdown-Ck_88HOR.js +0 -47
- package/MarkdownText-kJVkmihW.js +0 -9
- package/Number-CnQ95aLO.js +0 -35
- package/Password-Bg97DYW3.js +0 -36
- package/RadioGroup-Dldom5ja.js +0 -33
- package/Repeater-BYgXVfbl.js +0 -111
- package/Select-BLUX_W91.js +0 -55
- package/TextArea-cw3Q2v97.js +0 -35
- package/TextInput-geLoAA0c.js +0 -32
- package/Toggle-a7L71GwR.js +0 -30
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
import { jsx as k } from "react/jsx-runtime";
|
|
2
|
+
import { useInputWidget as D } from "@golemui/react";
|
|
3
|
+
import "@golemui/gui-shared";
|
|
4
|
+
import { useCallback as U } from "react";
|
|
5
|
+
import { A as $, i as j, b as m, n as d, t as z } from "./directive-1yd1wdny.js";
|
|
6
|
+
import { r as T } from "./state-DI9ZsB5W.js";
|
|
7
|
+
import { e as y } from "./class-map-DrTVAYz_.js";
|
|
8
|
+
import { G as R, b as N, c as Q } from "./templates-DBGyvZtc.js";
|
|
9
|
+
import { o as W } from "./style-map-C_0XzJlx.js";
|
|
10
|
+
import "./markdown-text-BUv0K0WF.js";
|
|
11
|
+
/* empty css */
|
|
12
|
+
const f = (t) => t ?? $;
|
|
13
|
+
var J = Object.defineProperty, X = Object.getOwnPropertyDescriptor, r = (t, s, i, a) => {
|
|
14
|
+
for (var o = a > 1 ? void 0 : a ? X(s, i) : s, n = t.length - 1, e; n >= 0; n--)
|
|
15
|
+
(e = t[n]) && (o = (a ? e(s, i, o) : e(o)) || o);
|
|
16
|
+
return a && o && J(s, i, o), o;
|
|
17
|
+
};
|
|
18
|
+
let l = class extends j {
|
|
19
|
+
constructor() {
|
|
20
|
+
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 R(this, {
|
|
21
|
+
getTargets: () => this.querySelectorAll(`textarea[id="${this.uid}"]`),
|
|
22
|
+
getState: () => ({
|
|
23
|
+
uid: this.uid,
|
|
24
|
+
templateData: {
|
|
25
|
+
hint: this.hint,
|
|
26
|
+
errors: this.errors,
|
|
27
|
+
readonly: this.readOnly,
|
|
28
|
+
disabled: this.disabled,
|
|
29
|
+
touched: this.touched
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
createRenderRoot() {
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
39
|
+
}
|
|
40
|
+
updated() {
|
|
41
|
+
this.recalculateAutoGrow();
|
|
42
|
+
}
|
|
43
|
+
willUpdate(t) {
|
|
44
|
+
!this.splitViewInitialized && t.has("defaultOpenPreview") && (this.splitViewActive = !!this.defaultOpenPreview, this.splitViewInitialized = !0);
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
super.render();
|
|
48
|
+
const t = {
|
|
49
|
+
uid: this.uid,
|
|
50
|
+
label: this.label,
|
|
51
|
+
errors: this.errors,
|
|
52
|
+
touched: this.touched,
|
|
53
|
+
required: this.required,
|
|
54
|
+
disabled: this.disabled,
|
|
55
|
+
readonly: this.readOnly,
|
|
56
|
+
value: this.value,
|
|
57
|
+
hint: this.hint,
|
|
58
|
+
placeholder: this.placeholder,
|
|
59
|
+
counterMode: this.counterMode ?? "remaining",
|
|
60
|
+
minimumHeight: this.minimumHeight ?? 120,
|
|
61
|
+
autoGrow: this.autoGrow ?? !1,
|
|
62
|
+
defaultOpenPreview: this.defaultOpenPreview ?? !1,
|
|
63
|
+
maxLength: this.maxLength,
|
|
64
|
+
dependencies: this.dependencies
|
|
65
|
+
}, s = {
|
|
66
|
+
"gui-markdown--icon": !1
|
|
67
|
+
};
|
|
68
|
+
let i = m``;
|
|
69
|
+
if (t.counterMode && t.maxLength) {
|
|
70
|
+
const o = {
|
|
71
|
+
"gui-markdown--counter": !0,
|
|
72
|
+
"gui-markdown--counter__error": (t.value?.length ?? 0) > t.maxLength
|
|
73
|
+
}, n = t.counterMode === "current" ? m`<span>${t.value?.length ?? 0}</span>` : m`<span>${t.maxLength - (t.value?.length ?? 0)}</span>`;
|
|
74
|
+
i = m`<div class=${y(o)}>
|
|
75
|
+
${n}
|
|
76
|
+
<span> / ${t.maxLength}</span>
|
|
77
|
+
</div>`;
|
|
78
|
+
}
|
|
79
|
+
const a = {
|
|
80
|
+
"min-height": `${t.minimumHeight}px`
|
|
81
|
+
};
|
|
82
|
+
return m`
|
|
83
|
+
${N(this.uid, t)}
|
|
84
|
+
|
|
85
|
+
<div
|
|
86
|
+
class=${y({
|
|
87
|
+
"gui-widget": !0,
|
|
88
|
+
"gui-markdown--with-preview": this.splitViewActive
|
|
89
|
+
})}
|
|
90
|
+
>
|
|
91
|
+
<nav class="gui-markdown__toolbar">
|
|
92
|
+
<ul>
|
|
93
|
+
${(this.tools ?? ["H", "B", "I", "S", "Q", "L", "|", "OL", "UL"]).map(
|
|
94
|
+
(o) => this.renderToolbarItem(o)
|
|
95
|
+
)}
|
|
96
|
+
<li>
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
tabindex="0"
|
|
100
|
+
class=${y({
|
|
101
|
+
"gui-markdown__toolbar-button": !0,
|
|
102
|
+
"gui-markdown__toolbar-button--active": this.splitViewActive
|
|
103
|
+
})}
|
|
104
|
+
@click=${this.splitView}
|
|
105
|
+
title=${this.splitViewTitle ?? "Split View"}
|
|
106
|
+
>
|
|
107
|
+
<svg
|
|
108
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
109
|
+
width="20"
|
|
110
|
+
height="20"
|
|
111
|
+
viewBox="0 0 256 256"
|
|
112
|
+
>
|
|
113
|
+
<path
|
|
114
|
+
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"
|
|
115
|
+
></path>
|
|
116
|
+
</svg>
|
|
117
|
+
</button>
|
|
118
|
+
</li>
|
|
119
|
+
</ul>
|
|
120
|
+
</nav>
|
|
121
|
+
<textarea
|
|
122
|
+
id=${f(this.uid)}
|
|
123
|
+
class=${y(s)}
|
|
124
|
+
style=${W(a)}
|
|
125
|
+
?required=${t.required}
|
|
126
|
+
?disabled=${t.disabled}
|
|
127
|
+
?readonly=${t.readonly}
|
|
128
|
+
placeholder=${f(t.placeholder)}
|
|
129
|
+
autocomplete=${this.autocomplete || $}
|
|
130
|
+
.value=${this.value || ""}
|
|
131
|
+
@input=${this.valueChanged}
|
|
132
|
+
@keyup=${this.detectFormats}
|
|
133
|
+
@mouseup=${this.detectFormats}
|
|
134
|
+
@blur=${this.onBlur}
|
|
135
|
+
></textarea>
|
|
136
|
+
|
|
137
|
+
${this.splitViewActive ? m`
|
|
138
|
+
<section
|
|
139
|
+
data-cy=${f(this.uid ? `${this.uid}_markdown` : $)}
|
|
140
|
+
class="gui-markdown__preview"
|
|
141
|
+
>
|
|
142
|
+
<gui-markdown-text
|
|
143
|
+
.md=${this.value || ""}
|
|
144
|
+
.dependencies=${this.dependencies}
|
|
145
|
+
></gui-markdown-text>
|
|
146
|
+
</section>
|
|
147
|
+
` : $}
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
<div class="gui-markdown--validation">
|
|
151
|
+
<div>${Q(this.uid, t)}</div>
|
|
152
|
+
${i}
|
|
153
|
+
</div>
|
|
154
|
+
`;
|
|
155
|
+
}
|
|
156
|
+
recalculateAutoGrow() {
|
|
157
|
+
if (!this.autoGrow) return;
|
|
158
|
+
const t = this.querySelector(`textarea[id="${this.uid}"]`);
|
|
159
|
+
if (!t) return;
|
|
160
|
+
const s = window.getComputedStyle(t), i = parseFloat(s.paddingTop), a = parseFloat(s.paddingBottom), o = i + a;
|
|
161
|
+
t.style.height = "auto", t.style.height = `${Math.max(this.minimumHeight ?? 120, t.scrollHeight - o)}px`;
|
|
162
|
+
}
|
|
163
|
+
splitView() {
|
|
164
|
+
this.splitViewActive = !this.splitViewActive;
|
|
165
|
+
}
|
|
166
|
+
renderToolbarItem(t) {
|
|
167
|
+
switch (t) {
|
|
168
|
+
case "H":
|
|
169
|
+
return m`<li>
|
|
170
|
+
<button
|
|
171
|
+
type="button"
|
|
172
|
+
tabindex="0"
|
|
173
|
+
class=${this.toolbarBtnClass("heading")}
|
|
174
|
+
@click=${this.applyFormat("# ", "", "heading")}
|
|
175
|
+
title=${this.headingTitle ?? "Heading"}
|
|
176
|
+
>
|
|
177
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
178
|
+
<path
|
|
179
|
+
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"
|
|
180
|
+
></path>
|
|
181
|
+
</svg>
|
|
182
|
+
</button>
|
|
183
|
+
</li>`;
|
|
184
|
+
case "B":
|
|
185
|
+
return m`<li>
|
|
186
|
+
<button
|
|
187
|
+
type="button"
|
|
188
|
+
tabindex="0"
|
|
189
|
+
class=${this.toolbarBtnClass("bold")}
|
|
190
|
+
@click=${this.applyFormat("**", "**", "bold")}
|
|
191
|
+
title=${this.boldTitle ?? "Bold"}
|
|
192
|
+
>
|
|
193
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
194
|
+
<path
|
|
195
|
+
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"
|
|
196
|
+
></path>
|
|
197
|
+
</svg>
|
|
198
|
+
</button>
|
|
199
|
+
</li>`;
|
|
200
|
+
case "I":
|
|
201
|
+
return m`<li>
|
|
202
|
+
<button
|
|
203
|
+
type="button"
|
|
204
|
+
tabindex="0"
|
|
205
|
+
class=${this.toolbarBtnClass("italic")}
|
|
206
|
+
@click=${this.applyFormat("_", "_", "italic")}
|
|
207
|
+
title=${this.italicTitle ?? "Italic"}
|
|
208
|
+
>
|
|
209
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
210
|
+
<path
|
|
211
|
+
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"
|
|
212
|
+
></path>
|
|
213
|
+
</svg>
|
|
214
|
+
</button>
|
|
215
|
+
</li>`;
|
|
216
|
+
case "S":
|
|
217
|
+
return m`<li>
|
|
218
|
+
<button
|
|
219
|
+
type="button"
|
|
220
|
+
tabindex="0"
|
|
221
|
+
class=${this.toolbarBtnClass("strikethrough")}
|
|
222
|
+
@click=${this.applyFormat("~~", "~~", "strikethrough")}
|
|
223
|
+
title=${this.strikethroughTitle ?? "Strikethrough"}
|
|
224
|
+
>
|
|
225
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
226
|
+
<path
|
|
227
|
+
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"
|
|
228
|
+
></path>
|
|
229
|
+
</svg>
|
|
230
|
+
</button>
|
|
231
|
+
</li>`;
|
|
232
|
+
case "Q":
|
|
233
|
+
return m`<li>
|
|
234
|
+
<button
|
|
235
|
+
type="button"
|
|
236
|
+
tabindex="0"
|
|
237
|
+
class=${this.toolbarBtnClass("quote")}
|
|
238
|
+
@click=${this.applyFormat("> ", "", "quote")}
|
|
239
|
+
title=${this.quoteTitle ?? "Quote"}
|
|
240
|
+
>
|
|
241
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
242
|
+
<path
|
|
243
|
+
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"
|
|
244
|
+
></path>
|
|
245
|
+
</svg>
|
|
246
|
+
</button>
|
|
247
|
+
</li>`;
|
|
248
|
+
case "L":
|
|
249
|
+
return m`<li>
|
|
250
|
+
<button
|
|
251
|
+
type="button"
|
|
252
|
+
tabindex="0"
|
|
253
|
+
class=${this.toolbarBtnClass("link")}
|
|
254
|
+
@click=${this.applyFormat("[", "](url)", "link")}
|
|
255
|
+
title=${this.linkTitle ?? "Link"}
|
|
256
|
+
>
|
|
257
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
258
|
+
<path
|
|
259
|
+
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"
|
|
260
|
+
></path>
|
|
261
|
+
</svg>
|
|
262
|
+
</button>
|
|
263
|
+
</li>`;
|
|
264
|
+
case "OL":
|
|
265
|
+
return m`<li>
|
|
266
|
+
<button
|
|
267
|
+
type="button"
|
|
268
|
+
tabindex="0"
|
|
269
|
+
class=${this.toolbarBtnClass("orderedList")}
|
|
270
|
+
@click=${this.applyFormat("1. ", "", "orderedList")}
|
|
271
|
+
title=${this.orderedListTitle ?? "Ordered List"}
|
|
272
|
+
>
|
|
273
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
274
|
+
<path
|
|
275
|
+
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"
|
|
276
|
+
></path>
|
|
277
|
+
</svg>
|
|
278
|
+
</button>
|
|
279
|
+
</li>`;
|
|
280
|
+
case "UL":
|
|
281
|
+
return m`<li>
|
|
282
|
+
<button
|
|
283
|
+
type="button"
|
|
284
|
+
tabindex="0"
|
|
285
|
+
class=${this.toolbarBtnClass("unorderedList")}
|
|
286
|
+
@click=${this.applyFormat("- ", "", "unorderedList")}
|
|
287
|
+
title=${this.unorderedListTitle ?? "Unordered List"}
|
|
288
|
+
>
|
|
289
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
290
|
+
<path
|
|
291
|
+
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"
|
|
292
|
+
></path>
|
|
293
|
+
</svg>
|
|
294
|
+
</button>
|
|
295
|
+
</li>`;
|
|
296
|
+
case "|":
|
|
297
|
+
return m`<li>
|
|
298
|
+
<span class="gui-markdown__toolbar-separator">
|
|
299
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 256 256">
|
|
300
|
+
<path d="M140,24V232a12,12,0,0,1-24,0V24a12,12,0,0,1,24,0Z"></path>
|
|
301
|
+
</svg>
|
|
302
|
+
</span>
|
|
303
|
+
</li>`;
|
|
304
|
+
default:
|
|
305
|
+
return $;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
toolbarBtnClass(t) {
|
|
309
|
+
return y({
|
|
310
|
+
"gui-markdown__toolbar-button": !0,
|
|
311
|
+
"gui-markdown__toolbar-button--active": !!t && !!this.activeFormats[t]
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
detectFormats() {
|
|
315
|
+
const t = this.querySelector(`textarea[id="${this.uid}"]`);
|
|
316
|
+
if (!t) return;
|
|
317
|
+
const { selectionStart: s, value: i } = t, a = i.lastIndexOf(`
|
|
318
|
+
`, s - 1) + 1, o = i.indexOf(`
|
|
319
|
+
`, s), n = i.substring(a, o === -1 ? i.length : o);
|
|
320
|
+
this.activeFormats = {
|
|
321
|
+
heading: /^#{1,6}\s/.test(n),
|
|
322
|
+
bold: this.isInsideInlineFormat(i, s, "**"),
|
|
323
|
+
italic: this.isInsideInlineFormat(i, s, "_"),
|
|
324
|
+
strikethrough: this.isInsideInlineFormat(i, s, "~~"),
|
|
325
|
+
quote: n.startsWith("> "),
|
|
326
|
+
link: this.isInsideLink(i, s),
|
|
327
|
+
orderedList: /^\d+\.\s/.test(n),
|
|
328
|
+
unorderedList: n.startsWith("- ")
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
isInsideInlineFormat(t, s, i) {
|
|
332
|
+
const a = t.lastIndexOf(`
|
|
333
|
+
`, s - 1) + 1, o = t.indexOf(`
|
|
334
|
+
`, s), n = t.substring(a, o === -1 ? t.length : o), e = s - a;
|
|
335
|
+
let h = 0;
|
|
336
|
+
for (; h < n.length; ) {
|
|
337
|
+
const p = n.indexOf(i, h);
|
|
338
|
+
if (p === -1) break;
|
|
339
|
+
const u = n.indexOf(i, p + i.length);
|
|
340
|
+
if (u === -1) break;
|
|
341
|
+
if (e >= p && e <= u + i.length)
|
|
342
|
+
return !0;
|
|
343
|
+
h = u + i.length;
|
|
344
|
+
}
|
|
345
|
+
return !1;
|
|
346
|
+
}
|
|
347
|
+
isInsideLink(t, s) {
|
|
348
|
+
const i = t.lastIndexOf(`
|
|
349
|
+
`, s - 1) + 1, a = t.indexOf(`
|
|
350
|
+
`, s), o = t.substring(i, a === -1 ? t.length : a), n = s - i, e = /\[[^\]]*\]\([^)]*\)/g;
|
|
351
|
+
let h;
|
|
352
|
+
for (; (h = e.exec(o)) !== null; )
|
|
353
|
+
if (n >= h.index && n <= h.index + h[0].length)
|
|
354
|
+
return !0;
|
|
355
|
+
return !1;
|
|
356
|
+
}
|
|
357
|
+
applyFormat(t, s = "", i = "") {
|
|
358
|
+
return () => {
|
|
359
|
+
const a = this.querySelector(`textarea[id="${this.uid}"]`);
|
|
360
|
+
if (a) {
|
|
361
|
+
if (i && this.activeFormats[i])
|
|
362
|
+
this.removeFormat(a, t, s, i);
|
|
363
|
+
else {
|
|
364
|
+
const { selectionStart: o, selectionEnd: n, value: e } = a, h = e.substring(o, n), p = e.substring(0, o), u = e.substring(n);
|
|
365
|
+
a.value = `${p}${t}${h}${s}${u}`, a.selectionStart = o + t.length, a.selectionEnd = o + t.length + h.length;
|
|
366
|
+
}
|
|
367
|
+
a.focus(), a.dispatchEvent(new Event("input", { bubbles: !0 })), this.detectFormats();
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
removeFormat(t, s, i, a) {
|
|
372
|
+
const { selectionStart: o, value: n } = t, e = n.lastIndexOf(`
|
|
373
|
+
`, o - 1) + 1, h = n.indexOf(`
|
|
374
|
+
`, o), p = n.substring(e, h === -1 ? n.length : h);
|
|
375
|
+
if (i)
|
|
376
|
+
if (a === "link") {
|
|
377
|
+
const u = o - e, w = /\[([^\]]*)\]\([^)]*\)/g;
|
|
378
|
+
let c;
|
|
379
|
+
for (; (c = w.exec(p)) !== null; )
|
|
380
|
+
if (u >= c.index && u <= c.index + c[0].length) {
|
|
381
|
+
const v = c[1], g = e + c.index, b = g + c[0].length;
|
|
382
|
+
t.value = `${n.substring(0, g)}${v}${n.substring(b)}`, t.selectionStart = g, t.selectionEnd = g + v.length;
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
} else {
|
|
386
|
+
const u = o - e;
|
|
387
|
+
let w = 0;
|
|
388
|
+
for (; w < p.length; ) {
|
|
389
|
+
const c = p.indexOf(s, w);
|
|
390
|
+
if (c === -1) break;
|
|
391
|
+
const v = p.indexOf(i, c + s.length);
|
|
392
|
+
if (v === -1) break;
|
|
393
|
+
if (u >= c && u <= v + i.length) {
|
|
394
|
+
const g = p.substring(c + s.length, v), b = e + c, x = e + v + i.length;
|
|
395
|
+
t.value = `${n.substring(0, b)}${g}${n.substring(x)}`, t.selectionStart = b, t.selectionEnd = b + g.length;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
w = v + i.length;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
let u = s;
|
|
403
|
+
if (a === "heading") {
|
|
404
|
+
const g = p.match(/^#{1,6}\s/);
|
|
405
|
+
g && (u = g[0]);
|
|
406
|
+
} else if (a === "orderedList") {
|
|
407
|
+
const g = p.match(/^\d+\.\s/);
|
|
408
|
+
g && (u = g[0]);
|
|
409
|
+
}
|
|
410
|
+
const w = n.substring(0, e), c = p.substring(u.length), v = n.substring(h === -1 ? n.length : h);
|
|
411
|
+
t.value = `${w}${c}${v}`, t.selectionStart = Math.max(e, o - u.length), t.selectionEnd = t.selectionStart;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
valueChanged(t) {
|
|
415
|
+
if (t.stopPropagation(), !this.readOnly) {
|
|
416
|
+
const s = t.target;
|
|
417
|
+
this.dispatchEvent(
|
|
418
|
+
new CustomEvent("input", {
|
|
419
|
+
detail: { value: s.value },
|
|
420
|
+
bubbles: !0,
|
|
421
|
+
composed: !0
|
|
422
|
+
})
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
onBlur() {
|
|
427
|
+
this.dispatchEvent(
|
|
428
|
+
new CustomEvent("blur", {
|
|
429
|
+
bubbles: !0,
|
|
430
|
+
composed: !0
|
|
431
|
+
})
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
r([
|
|
436
|
+
d({ type: String })
|
|
437
|
+
], l.prototype, "uid", 2);
|
|
438
|
+
r([
|
|
439
|
+
d({ type: String })
|
|
440
|
+
], l.prototype, "label", 2);
|
|
441
|
+
r([
|
|
442
|
+
d({ type: String, attribute: "locale-id" })
|
|
443
|
+
], l.prototype, "localeId", 2);
|
|
444
|
+
r([
|
|
445
|
+
d({ type: Array })
|
|
446
|
+
], l.prototype, "errors", 2);
|
|
447
|
+
r([
|
|
448
|
+
d({ type: Boolean })
|
|
449
|
+
], l.prototype, "touched", 2);
|
|
450
|
+
r([
|
|
451
|
+
d({ type: Boolean })
|
|
452
|
+
], l.prototype, "required", 2);
|
|
453
|
+
r([
|
|
454
|
+
d({ type: Boolean })
|
|
455
|
+
], l.prototype, "disabled", 2);
|
|
456
|
+
r([
|
|
457
|
+
d({ type: Boolean, attribute: "readonly" })
|
|
458
|
+
], l.prototype, "readOnly", 2);
|
|
459
|
+
r([
|
|
460
|
+
d({ type: String })
|
|
461
|
+
], l.prototype, "value", 2);
|
|
462
|
+
r([
|
|
463
|
+
d({ type: String })
|
|
464
|
+
], l.prototype, "hint", 2);
|
|
465
|
+
r([
|
|
466
|
+
d({ type: Array })
|
|
467
|
+
], l.prototype, "tools", 2);
|
|
468
|
+
r([
|
|
469
|
+
d({ type: String })
|
|
470
|
+
], l.prototype, "placeholder", 2);
|
|
471
|
+
r([
|
|
472
|
+
d({ type: String })
|
|
473
|
+
], l.prototype, "autocomplete", 2);
|
|
474
|
+
r([
|
|
475
|
+
d({ type: String, attribute: "countermode" })
|
|
476
|
+
], l.prototype, "counterMode", 2);
|
|
477
|
+
r([
|
|
478
|
+
d({ type: Number, attribute: "minimumheight" })
|
|
479
|
+
], l.prototype, "minimumHeight", 2);
|
|
480
|
+
r([
|
|
481
|
+
d({ type: Boolean, attribute: "autogrow" })
|
|
482
|
+
], l.prototype, "autoGrow", 2);
|
|
483
|
+
r([
|
|
484
|
+
d({ type: Boolean, attribute: "defaultopenpreview" })
|
|
485
|
+
], l.prototype, "defaultOpenPreview", 2);
|
|
486
|
+
r([
|
|
487
|
+
d({ type: Number, attribute: "maxlength" })
|
|
488
|
+
], l.prototype, "maxLength", 2);
|
|
489
|
+
r([
|
|
490
|
+
d({ type: String })
|
|
491
|
+
], l.prototype, "headingTitle", 2);
|
|
492
|
+
r([
|
|
493
|
+
d({ type: String })
|
|
494
|
+
], l.prototype, "boldTitle", 2);
|
|
495
|
+
r([
|
|
496
|
+
d({ type: String })
|
|
497
|
+
], l.prototype, "italicTitle", 2);
|
|
498
|
+
r([
|
|
499
|
+
d({ type: String })
|
|
500
|
+
], l.prototype, "strikethroughTitle", 2);
|
|
501
|
+
r([
|
|
502
|
+
d({ type: String })
|
|
503
|
+
], l.prototype, "quoteTitle", 2);
|
|
504
|
+
r([
|
|
505
|
+
d({ type: String })
|
|
506
|
+
], l.prototype, "linkTitle", 2);
|
|
507
|
+
r([
|
|
508
|
+
d({ type: String })
|
|
509
|
+
], l.prototype, "orderedListTitle", 2);
|
|
510
|
+
r([
|
|
511
|
+
d({ type: String })
|
|
512
|
+
], l.prototype, "unorderedListTitle", 2);
|
|
513
|
+
r([
|
|
514
|
+
d({ type: String })
|
|
515
|
+
], l.prototype, "splitViewTitle", 2);
|
|
516
|
+
r([
|
|
517
|
+
d({ type: Object })
|
|
518
|
+
], l.prototype, "dependencies", 2);
|
|
519
|
+
r([
|
|
520
|
+
T()
|
|
521
|
+
], l.prototype, "splitViewActive", 2);
|
|
522
|
+
r([
|
|
523
|
+
T()
|
|
524
|
+
], l.prototype, "activeFormats", 2);
|
|
525
|
+
l = r([
|
|
526
|
+
z("gui-markdown")
|
|
527
|
+
], l);
|
|
528
|
+
typeof customElements < "u" && !customElements.get("gui-markdown") && customElements.define("gui-markdown", l);
|
|
529
|
+
function dt(t) {
|
|
530
|
+
const s = t.widget, { uid: i, errors: a, value: o, isTouched: n, templateData: e, onValueChanged: h, onBlur: p } = D(s), u = U(
|
|
531
|
+
(P) => h(P.nativeEvent.detail.value),
|
|
532
|
+
[h]
|
|
533
|
+
), w = e.label, c = e.hint, v = e.placeholder, g = e.autocomplete, b = e.validator?.maxLength, x = e.counterMode, L = e.autoGrow, H = e.minimumHeight, A = e.tools, V = e.defaultOpenPreview, S = e.headingTitle, I = e.boldTitle, O = e.italicTitle, B = e.strikethroughTitle, M = e.quoteTitle, F = e.linkTitle, Z = e.orderedListTitle, C = e.unorderedListTitle, _ = e.splitViewTitle, q = e.disabled, E = e.readonly, G = e.validator?.required;
|
|
534
|
+
return /* @__PURE__ */ k("div", { className: "gui-markdown gui-field", style: { flex: e.size }, children: /* @__PURE__ */ k(
|
|
535
|
+
"gui-markdown",
|
|
536
|
+
{
|
|
537
|
+
uid: i,
|
|
538
|
+
label: w,
|
|
539
|
+
errors: a,
|
|
540
|
+
touched: n,
|
|
541
|
+
required: G,
|
|
542
|
+
disabled: q,
|
|
543
|
+
readOnly: E,
|
|
544
|
+
value: o,
|
|
545
|
+
hint: c,
|
|
546
|
+
placeholder: v,
|
|
547
|
+
autocomplete: g ?? void 0,
|
|
548
|
+
counterMode: x,
|
|
549
|
+
minimumHeight: H,
|
|
550
|
+
autoGrow: L,
|
|
551
|
+
maxLength: b,
|
|
552
|
+
tools: A,
|
|
553
|
+
defaultOpenPreview: V,
|
|
554
|
+
headingTitle: S,
|
|
555
|
+
boldTitle: I,
|
|
556
|
+
italicTitle: O,
|
|
557
|
+
strikethroughTitle: B,
|
|
558
|
+
quoteTitle: M,
|
|
559
|
+
linkTitle: F,
|
|
560
|
+
orderedListTitle: Z,
|
|
561
|
+
unorderedListTitle: C,
|
|
562
|
+
splitViewTitle: _,
|
|
563
|
+
dependencies: e.deps,
|
|
564
|
+
onInput: u,
|
|
565
|
+
onBlur: p
|
|
566
|
+
}
|
|
567
|
+
) });
|
|
568
|
+
}
|
|
569
|
+
export {
|
|
570
|
+
dt as Markdown
|
|
571
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useDisplayWdiget as m } from "@golemui/react";
|
|
3
|
+
import "@golemui/gui-shared";
|
|
4
|
+
import "./markdown-text-BUv0K0WF.js";
|
|
5
|
+
function l(t) {
|
|
6
|
+
const d = t.widget, { uid: r, templateData: e } = m(d);
|
|
7
|
+
return /* @__PURE__ */ i("div", { className: "gui-markdown-text gui-field", style: { flex: e.size }, children: /* @__PURE__ */ i("div", { className: "gui-widget", id: r, children: /* @__PURE__ */ i("gui-markdown-text", { md: e.md, dependencies: e.deps }) }) });
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
l as MarkdownText
|
|
11
|
+
};
|