@golemui/gui-lit 1.2.0 → 1.2.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/{accordion.element-BIgxl5e9.js → accordion.element-C9GzfKrY.js} +29 -30
  3. package/alert.element-CHn49Yaf.js +55 -0
  4. package/button.element-C9fHivSw.js +59 -0
  5. package/{calendar.element-Cv3RBphf.js → calendar.element-XkojKTJk.js} +30 -31
  6. package/checkbox.element-DU_tVMXu.js +66 -0
  7. package/currency.element-BmAH5KS_.js +73 -0
  8. package/date-picker.element-Bg3rF95F.js +94 -0
  9. package/{date-time-calendar.element-DlbWZjoe.js → date-time-calendar.element-sywQCeQQ.js} +24 -24
  10. package/date-time-picker.element-HHpwjWTQ.js +107 -0
  11. package/{date-time.element-CLLxM2nV.js → date-time.element-ucETvSTC.js} +26 -26
  12. package/{date.element-B8ZHK9KJ.js → date.element-BEHGxRFF.js} +27 -27
  13. package/default-list-item-renderer-CuPJ9jUD.js +24 -0
  14. package/{dropdown.element-DMZ7oL5n.js → dropdown.element-DUqG_p1x.js} +85 -84
  15. package/{flex.element-DG4Uaj_X.js → flex.element-pwba7621.js} +27 -28
  16. package/{grid.element-DCZsh-3J.js → grid.element-C8K7_Qi3.js} +29 -30
  17. package/index.js +1316 -3883
  18. package/index.umd.cjs +117 -2132
  19. package/{list.element-ADtUK2na.js → list.element-ZtEMKE2x.js} +41 -40
  20. package/markdown-text.element-DDm36qD0.js +54 -0
  21. package/markdown.element-DWz3U9rG.js +84 -0
  22. package/number.element-VkG5wScD.js +71 -0
  23. package/package.json +6 -6
  24. package/password.element-C5vQHq5P.js +72 -0
  25. package/radiogroup.element-CKdO9HwO.js +69 -0
  26. package/{range-calendar.element-D5eb2f7p.js → range-calendar.element-BznGrej5.js} +23 -24
  27. package/{range-date-input.element-C35grlYo.js → range-date-input.element-BloTHRDl.js} +24 -24
  28. package/range-date-picker.element-DKhwFasW.js +98 -0
  29. package/{range-date-time-calendar.element-BV0J96Gu.js → range-date-time-calendar.element-CZCET-sb.js} +26 -26
  30. package/{range-date-time-input.element-CzgRbR9F.js → range-date-time-input.element-Dr2VrYhG.js} +24 -24
  31. package/range-date-time-picker.element-CYeIMWLp.js +109 -0
  32. package/{range-time-input.element-BOHLUO8z.js → range-time-input.element-7OZhPQqx.js} +23 -23
  33. package/range-time-picker.element-D0mRFZkK.js +96 -0
  34. package/renderer.element-DbsFoBba.js +48 -0
  35. package/{repeater.element-Da8YN1Vy.js → repeater.element-DGEbwvhY.js} +54 -65
  36. package/select.element-Bb_9jAVB.js +76 -0
  37. package/{tabs.element-CvcIA8P3.js → tabs.element-BYDNF_pm.js} +49 -50
  38. package/tags.element-BSN3i9Gx.js +73 -0
  39. package/textarea.element-Dl1ZEOqO.js +71 -0
  40. package/textinput.element-C5Vbbkxq.js +68 -0
  41. package/{time-picker.element-C3oR0EkQ.js → time-picker.element-Crmj9YDy.js} +26 -26
  42. package/{time.element-X286nthD.js → time.element-DfSeAZp4.js} +29 -29
  43. package/toggle.element-ORsprZ2M.js +66 -0
  44. package/alert.element-DPWq9-0F.js +0 -56
  45. package/button.element-CJay43iR.js +0 -132
  46. package/calendar-DleRbmvP.js +0 -267
  47. package/checkbox.element-CpmrzdH0.js +0 -200
  48. package/currency.element-Cezgzbbs.js +0 -276
  49. package/date-DBuYpvcO.js +0 -849
  50. package/date-input-B3yHsn-g.js +0 -204
  51. package/date-picker.element-ByZefznr.js +0 -357
  52. package/date-time-calendar-CB5cNoOX.js +0 -374
  53. package/date-time-input-DrY68YDX.js +0 -246
  54. package/date-time-picker.element-CYwmumfq.js +0 -440
  55. package/day-status-ljexnwEO.js +0 -554
  56. package/errors-Bs_vYN-_.js +0 -110
  57. package/focus-leave.controller-2gV0pQd5.js +0 -73
  58. package/list-D730tmGN.js +0 -297
  59. package/markdown-text-X-BRJT6K.js +0 -30
  60. package/markdown-text.element-B8TfVLIO.js +0 -55
  61. package/markdown.element-D5zcxAUS.js +0 -693
  62. package/number.element-DEY5tR_y.js +0 -291
  63. package/numeric-jmOOKz30.js +0 -12
  64. package/one-of-anKkm7mD.js +0 -50
  65. package/part-templates-VORbpgs2.js +0 -691
  66. package/password.element-C1aQh_iz.js +0 -240
  67. package/pill-ranges-DpvWwP-3.js +0 -48
  68. package/pills-BDMO2NiR.js +0 -348
  69. package/popup.controller-B33OvX_y.js +0 -86
  70. package/radiogroup.element-B2G-XyGx.js +0 -235
  71. package/range-calendar-D7sG24Kx.js +0 -466
  72. package/range-commit-8-MmYUyo.js +0 -14
  73. package/range-date-input-BChaoBC1.js +0 -311
  74. package/range-date-picker.element-Do5YsL5V.js +0 -434
  75. package/range-date-time-calendar-DulGK2EQ.js +0 -734
  76. package/range-date-time-input-8ggqckP7.js +0 -353
  77. package/range-date-time-picker.element-hi5KdopZ.js +0 -472
  78. package/range-selection-CU3hxLJE.js +0 -25
  79. package/range-time-input-D7GFdDeA.js +0 -348
  80. package/range-time-picker.element-DDNQMA_u.js +0 -470
  81. package/renderer.element-CNyMn2Lu.js +0 -49
  82. package/select.element-SDxBhGjz.js +0 -266
  83. package/tabs-DzSCq_98.js +0 -13
  84. package/tags.element-Bnhfevp3.js +0 -369
  85. package/templates-Df7abEkB.js +0 -92
  86. package/textarea.element-Dx7eYEnl.js +0 -239
  87. package/textinput.element-BnIoDRmY.js +0 -205
  88. package/time-input-Kk4EX6at.js +0 -201
  89. package/time-list-DLcq8BAp.js +0 -217
  90. package/time-picker-DLj1rhOf.js +0 -299
  91. package/toggle.element-Dokdat_o.js +0 -203
@@ -1,693 +0,0 @@
1
- import { InputWidgetAdapter as V, formContext as S, inputContext as C } from "@golemui/lit";
2
- import { LitElement as k, html as u, nothing as y } from "lit";
3
- import { property as n, state as H, customElement as A } from "lit/decorators.js";
4
- import { classMap as $ } from "lit/directives/class-map.js";
5
- import { G as D, b as F, c as _ } from "./templates-Df7abEkB.js";
6
- import { styleMap as T } from "lit-html/directives/style-map.js";
7
- import { ifDefined as x } from "lit/directives/if-defined.js";
8
- import "./markdown-text-X-BRJT6K.js";
9
- import { consume as I, provide as B } from "@lit/context";
10
- import "rxjs";
11
- var M = Object.defineProperty, Z = Object.getOwnPropertyDescriptor, o = (t, e, i, r) => {
12
- for (var a = r > 1 ? void 0 : r ? Z(e, i) : e, s = t.length - 1, d; s >= 0; s--)
13
- (d = t[s]) && (a = (r ? d(e, i, a) : d(a)) || a);
14
- return r && a && M(e, i, a), a;
15
- };
16
- let l = class extends k {
17
- constructor() {
18
- 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.toolbarAriaLabel = void 0, this.dependencies = void 0, this.splitViewActive = !1, this.activeFormats = {}, this.splitViewInitialized = !1, this.ariaController = new D(this, {
19
- getTargets: () => this.querySelectorAll(`textarea[id="${this.uid}"]`),
20
- getState: () => ({
21
- uid: this.uid,
22
- templateData: {
23
- hint: this.hint,
24
- errors: this.errors,
25
- readonly: this.readOnly,
26
- disabled: this.disabled,
27
- touched: this.touched,
28
- required: this.required
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-widget-input": !0,
66
- "gui-markdown--icon": !1
67
- };
68
- let i = u``;
69
- if (t.counterMode && t.maxLength) {
70
- const a = {
71
- "gui-markdown--counter": !0,
72
- "gui-markdown--counter__error": (t.value?.length ?? 0) > t.maxLength
73
- }, s = t.counterMode === "current" ? u`<span>${t.value?.length ?? 0}</span>` : u`<span>${t.maxLength - (t.value?.length ?? 0)}</span>`;
74
- i = u`<div class=${$(a)}>
75
- ${s}
76
- <span> / ${t.maxLength}</span>
77
- </div>`;
78
- }
79
- const r = {
80
- "min-height": `${t.minimumHeight}px`
81
- };
82
- return u`
83
- ${F(this.uid, t)}
84
-
85
- <div
86
- class=${$({
87
- "gui-widget": !0,
88
- "gui-markdown--with-preview": this.splitViewActive
89
- })}
90
- >
91
- <nav
92
- class="gui-markdown__toolbar"
93
- role="toolbar"
94
- aria-label=${this.toolbarAriaLabel ?? "Text formatting"}
95
- >
96
- <ul role="presentation">
97
- ${(this.tools ?? ["H", "B", "I", "S", "Q", "L", "|", "OL", "UL"]).map(
98
- (a) => this.renderToolbarItem(a)
99
- )}
100
- <li role="presentation">
101
- <button
102
- type="button"
103
- class=${$({
104
- "gui-markdown__toolbar-button": !0,
105
- "gui-markdown__toolbar-button--active": this.splitViewActive
106
- })}
107
- ?disabled=${this.disabled}
108
- aria-label=${this.splitViewTitle ?? "Split View"}
109
- aria-pressed=${this.splitViewActive ? "true" : "false"}
110
- @click=${this.splitView}
111
- title=${this.splitViewTitle ?? "Split View"}
112
- >
113
- <svg
114
- xmlns="http://www.w3.org/2000/svg"
115
- width="20"
116
- height="20"
117
- viewBox="0 0 256 256"
118
- aria-hidden="true"
119
- >
120
- <path
121
- 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"
122
- ></path>
123
- </svg>
124
- </button>
125
- </li>
126
- </ul>
127
- </nav>
128
-
129
- <div class="gui-markdown__container">
130
- <textarea
131
- id=${x(this.uid)}
132
- class=${$(e)}
133
- style=${T(r)}
134
- ?required=${t.required}
135
- ?disabled=${t.disabled}
136
- ?readonly=${t.readonly}
137
- placeholder=${x(t.placeholder)}
138
- autocomplete=${this.autocomplete || y}
139
- .value=${this.value || ""}
140
- @input=${this.valueChanged}
141
- @keyup=${this.detectFormats}
142
- @mouseup=${this.detectFormats}
143
- @blur=${this.onBlur}
144
- ></textarea>
145
-
146
- ${this.splitViewActive ? u`
147
- <section
148
- data-cy=${x(this.uid ? `${this.uid}_markdown` : y)}
149
- class="gui-markdown__preview"
150
- style=${T(r)}
151
- >
152
- <gui-markdown-text
153
- .md=${this.value || ""}
154
- .dependencies=${this.dependencies}
155
- ></gui-markdown-text>
156
- </section>
157
- ` : y}
158
- </div>
159
- </div>
160
-
161
- <div class="gui-markdown--validation">
162
- <div>${_(this.uid, t)}</div>
163
- ${i}
164
- </div>
165
- `;
166
- }
167
- recalculateAutoGrow() {
168
- if (!this.autoGrow) return;
169
- const t = this.querySelector(`textarea[id="${this.uid}"]`);
170
- if (!t) return;
171
- const e = window.getComputedStyle(t), i = parseFloat(e.paddingTop), r = parseFloat(e.paddingBottom), a = i + r;
172
- t.style.height = "auto", t.style.height = `${Math.max(this.minimumHeight ?? 120, t.scrollHeight - a)}px`;
173
- }
174
- splitView() {
175
- this.disabled || (this.splitViewActive = !this.splitViewActive);
176
- }
177
- renderToolbarItem(t) {
178
- switch (t) {
179
- case "H":
180
- return u`<li role="presentation">
181
- <button
182
- type="button"
183
- class=${this.toolbarBtnClass("heading")}
184
- ?disabled=${this.disabled || this.readOnly}
185
- aria-label=${this.headingTitle ?? "Heading"}
186
- aria-pressed=${this.activeFormats.heading ? "true" : "false"}
187
- @click=${this.applyFormat("# ", "", "heading")}
188
- title=${this.headingTitle ?? "Heading"}
189
- >
190
- <svg
191
- xmlns="http://www.w3.org/2000/svg"
192
- width="20"
193
- height="20"
194
- viewBox="0 0 256 256"
195
- aria-hidden="true"
196
- >
197
- <path
198
- 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"
199
- ></path>
200
- </svg>
201
- </button>
202
- </li>`;
203
- case "B":
204
- return u`<li role="presentation">
205
- <button
206
- type="button"
207
- class=${this.toolbarBtnClass("bold")}
208
- ?disabled=${this.disabled || this.readOnly}
209
- aria-label=${this.boldTitle ?? "Bold"}
210
- aria-pressed=${this.activeFormats.bold ? "true" : "false"}
211
- @click=${this.applyFormat("**", "**", "bold")}
212
- title=${this.boldTitle ?? "Bold"}
213
- >
214
- <svg
215
- xmlns="http://www.w3.org/2000/svg"
216
- width="20"
217
- height="20"
218
- viewBox="0 0 256 256"
219
- aria-hidden="true"
220
- >
221
- <path
222
- 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"
223
- ></path>
224
- </svg>
225
- </button>
226
- </li>`;
227
- case "I":
228
- return u`<li role="presentation">
229
- <button
230
- type="button"
231
- class=${this.toolbarBtnClass("italic")}
232
- ?disabled=${this.disabled || this.readOnly}
233
- aria-label=${this.italicTitle ?? "Italic"}
234
- aria-pressed=${this.activeFormats.italic ? "true" : "false"}
235
- @click=${this.applyFormat("_", "_", "italic")}
236
- title=${this.italicTitle ?? "Italic"}
237
- >
238
- <svg
239
- xmlns="http://www.w3.org/2000/svg"
240
- width="20"
241
- height="20"
242
- viewBox="0 0 256 256"
243
- aria-hidden="true"
244
- >
245
- <path
246
- 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"
247
- ></path>
248
- </svg>
249
- </button>
250
- </li>`;
251
- case "S":
252
- return u`<li role="presentation">
253
- <button
254
- type="button"
255
- class=${this.toolbarBtnClass("strikethrough")}
256
- ?disabled=${this.disabled || this.readOnly}
257
- aria-label=${this.strikethroughTitle ?? "Strikethrough"}
258
- aria-pressed=${this.activeFormats.strikethrough ? "true" : "false"}
259
- @click=${this.applyFormat("~~", "~~", "strikethrough")}
260
- title=${this.strikethroughTitle ?? "Strikethrough"}
261
- >
262
- <svg
263
- xmlns="http://www.w3.org/2000/svg"
264
- width="20"
265
- height="20"
266
- viewBox="0 0 256 256"
267
- aria-hidden="true"
268
- >
269
- <path
270
- 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"
271
- ></path>
272
- </svg>
273
- </button>
274
- </li>`;
275
- case "Q":
276
- return u`<li role="presentation">
277
- <button
278
- type="button"
279
- class=${this.toolbarBtnClass("quote")}
280
- ?disabled=${this.disabled || this.readOnly}
281
- aria-label=${this.quoteTitle ?? "Quote"}
282
- aria-pressed=${this.activeFormats.quote ? "true" : "false"}
283
- @click=${this.applyFormat("> ", "", "quote")}
284
- title=${this.quoteTitle ?? "Quote"}
285
- >
286
- <svg
287
- xmlns="http://www.w3.org/2000/svg"
288
- width="20"
289
- height="20"
290
- viewBox="0 0 256 256"
291
- aria-hidden="true"
292
- >
293
- <path
294
- 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"
295
- ></path>
296
- </svg>
297
- </button>
298
- </li>`;
299
- case "L":
300
- return u`<li role="presentation">
301
- <button
302
- type="button"
303
- class=${this.toolbarBtnClass("link")}
304
- ?disabled=${this.disabled || this.readOnly}
305
- aria-label=${this.linkTitle ?? "Link"}
306
- aria-pressed=${this.activeFormats.link ? "true" : "false"}
307
- @click=${this.applyFormat("[", "](url)", "link")}
308
- title=${this.linkTitle ?? "Link"}
309
- >
310
- <svg
311
- xmlns="http://www.w3.org/2000/svg"
312
- width="20"
313
- height="20"
314
- viewBox="0 0 256 256"
315
- aria-hidden="true"
316
- >
317
- <path
318
- 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"
319
- ></path>
320
- </svg>
321
- </button>
322
- </li>`;
323
- case "OL":
324
- return u`<li role="presentation">
325
- <button
326
- type="button"
327
- class=${this.toolbarBtnClass("orderedList")}
328
- ?disabled=${this.disabled || this.readOnly}
329
- aria-label=${this.orderedListTitle ?? "Ordered List"}
330
- aria-pressed=${this.activeFormats.orderedList ? "true" : "false"}
331
- @click=${this.applyFormat("1. ", "", "orderedList")}
332
- title=${this.orderedListTitle ?? "Ordered List"}
333
- >
334
- <svg
335
- xmlns="http://www.w3.org/2000/svg"
336
- width="20"
337
- height="20"
338
- viewBox="0 0 256 256"
339
- aria-hidden="true"
340
- >
341
- <path
342
- 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"
343
- ></path>
344
- </svg>
345
- </button>
346
- </li>`;
347
- case "UL":
348
- return u`<li role="presentation">
349
- <button
350
- type="button"
351
- class=${this.toolbarBtnClass("unorderedList")}
352
- ?disabled=${this.disabled || this.readOnly}
353
- aria-label=${this.unorderedListTitle ?? "Unordered List"}
354
- aria-pressed=${this.activeFormats.unorderedList ? "true" : "false"}
355
- @click=${this.applyFormat("- ", "", "unorderedList")}
356
- title=${this.unorderedListTitle ?? "Unordered List"}
357
- >
358
- <svg
359
- xmlns="http://www.w3.org/2000/svg"
360
- width="20"
361
- height="20"
362
- viewBox="0 0 256 256"
363
- aria-hidden="true"
364
- >
365
- <path
366
- 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"
367
- ></path>
368
- </svg>
369
- </button>
370
- </li>`;
371
- case "|":
372
- return u`<li role="presentation">
373
- <span class="gui-markdown__toolbar-separator">
374
- <svg
375
- xmlns="http://www.w3.org/2000/svg"
376
- width="20"
377
- height="20"
378
- viewBox="0 0 256 256"
379
- aria-hidden="true"
380
- >
381
- <path d="M140,24V232a12,12,0,0,1-24,0V24a12,12,0,0,1,24,0Z"></path>
382
- </svg>
383
- </span>
384
- </li>`;
385
- default:
386
- return y;
387
- }
388
- }
389
- toolbarBtnClass(t) {
390
- return $({
391
- "gui-markdown__toolbar-button": !0,
392
- "gui-markdown__toolbar-button--disabled": this.disabled === !0 || this.readOnly === !0,
393
- "gui-markdown__toolbar-button--active": !!t && !!this.activeFormats[t]
394
- });
395
- }
396
- detectFormats() {
397
- const t = this.querySelector(`textarea[id="${this.uid}"]`);
398
- if (!t) return;
399
- const { selectionStart: e, value: i } = t, r = i.lastIndexOf(`
400
- `, e - 1) + 1, a = i.indexOf(`
401
- `, e), s = i.substring(r, a === -1 ? i.length : a);
402
- this.activeFormats = {
403
- heading: /^#{1,6}\s/.test(s),
404
- bold: this.isInsideInlineFormat(i, e, "**"),
405
- italic: this.isInsideInlineFormat(i, e, "_"),
406
- strikethrough: this.isInsideInlineFormat(i, e, "~~"),
407
- quote: s.startsWith("> "),
408
- link: this.isInsideLink(i, e),
409
- orderedList: /^\d+\.\s/.test(s),
410
- unorderedList: s.startsWith("- ")
411
- };
412
- }
413
- isInsideInlineFormat(t, e, i) {
414
- const r = t.lastIndexOf(`
415
- `, e - 1) + 1, a = t.indexOf(`
416
- `, e), s = t.substring(r, a === -1 ? t.length : a), d = e - r;
417
- let h = 0;
418
- for (; h < s.length; ) {
419
- const g = s.indexOf(i, h);
420
- if (g === -1) break;
421
- const p = s.indexOf(i, g + i.length);
422
- if (p === -1) break;
423
- if (d >= g && d <= p + i.length)
424
- return !0;
425
- h = p + i.length;
426
- }
427
- return !1;
428
- }
429
- isInsideLink(t, e) {
430
- const i = t.lastIndexOf(`
431
- `, e - 1) + 1, r = t.indexOf(`
432
- `, e), a = t.substring(i, r === -1 ? t.length : r), s = e - i, d = /\[[^\]]*\]\([^)]*\)/g;
433
- let h;
434
- for (; (h = d.exec(a)) !== null; )
435
- if (s >= h.index && s <= h.index + h[0].length)
436
- return !0;
437
- return !1;
438
- }
439
- applyFormat(t, e = "", i = "") {
440
- return () => {
441
- if (this.disabled || this.readOnly) return;
442
- const r = this.querySelector(`textarea[id="${this.uid}"]`);
443
- if (r) {
444
- if (i && this.activeFormats[i])
445
- this.removeFormat(r, t, e, i);
446
- else {
447
- const { selectionStart: a, selectionEnd: s, value: d } = r, h = d.substring(a, s), g = d.substring(0, a), p = d.substring(s);
448
- r.value = `${g}${t}${h}${e}${p}`, r.selectionStart = a + t.length, r.selectionEnd = a + t.length + h.length;
449
- }
450
- r.focus(), r.dispatchEvent(new Event("input", { bubbles: !0 })), this.detectFormats();
451
- }
452
- };
453
- }
454
- removeFormat(t, e, i, r) {
455
- const { selectionStart: a, value: s } = t, d = s.lastIndexOf(`
456
- `, a - 1) + 1, h = s.indexOf(`
457
- `, a), g = s.substring(d, h === -1 ? s.length : h);
458
- if (i)
459
- if (r === "link") {
460
- const p = a - d, v = /\[([^\]]*)\]\([^)]*\)/g;
461
- let c;
462
- for (; (c = v.exec(g)) !== null; )
463
- if (p >= c.index && p <= c.index + c[0].length) {
464
- const b = c[1], m = d + c.index, w = m + c[0].length;
465
- t.value = `${s.substring(0, m)}${b}${s.substring(w)}`, t.selectionStart = m, t.selectionEnd = m + b.length;
466
- break;
467
- }
468
- } else {
469
- const p = a - d;
470
- let v = 0;
471
- for (; v < g.length; ) {
472
- const c = g.indexOf(e, v);
473
- if (c === -1) break;
474
- const b = g.indexOf(i, c + e.length);
475
- if (b === -1) break;
476
- if (p >= c && p <= b + i.length) {
477
- const m = g.substring(c + e.length, b), w = d + c, O = d + b + i.length;
478
- t.value = `${s.substring(0, w)}${m}${s.substring(O)}`, t.selectionStart = w, t.selectionEnd = w + m.length;
479
- break;
480
- }
481
- v = b + i.length;
482
- }
483
- }
484
- else {
485
- let p = e;
486
- if (r === "heading") {
487
- const m = g.match(/^#{1,6}\s/);
488
- m && (p = m[0]);
489
- } else if (r === "orderedList") {
490
- const m = g.match(/^\d+\.\s/);
491
- m && (p = m[0]);
492
- }
493
- const v = s.substring(0, d), c = g.substring(p.length), b = s.substring(h === -1 ? s.length : h);
494
- t.value = `${v}${c}${b}`, t.selectionStart = Math.max(d, a - p.length), t.selectionEnd = t.selectionStart;
495
- }
496
- }
497
- valueChanged(t) {
498
- if (t.stopPropagation(), !this.readOnly) {
499
- const e = t.target;
500
- this.dispatchEvent(
501
- new CustomEvent("input", {
502
- detail: { value: e.value },
503
- bubbles: !0,
504
- composed: !0
505
- })
506
- );
507
- }
508
- }
509
- onBlur() {
510
- this.dispatchEvent(
511
- new CustomEvent("blur", {
512
- bubbles: !0,
513
- composed: !0
514
- })
515
- );
516
- }
517
- };
518
- o([
519
- n({ type: String })
520
- ], l.prototype, "uid", 2);
521
- o([
522
- n({ type: String })
523
- ], l.prototype, "label", 2);
524
- o([
525
- n({ type: String, attribute: "locale-id" })
526
- ], l.prototype, "localeId", 2);
527
- o([
528
- n({ type: Array })
529
- ], l.prototype, "errors", 2);
530
- o([
531
- n({ type: Boolean })
532
- ], l.prototype, "touched", 2);
533
- o([
534
- n({ type: Boolean })
535
- ], l.prototype, "required", 2);
536
- o([
537
- n({ type: Boolean })
538
- ], l.prototype, "disabled", 2);
539
- o([
540
- n({ type: Boolean, attribute: "readonly" })
541
- ], l.prototype, "readOnly", 2);
542
- o([
543
- n({ type: String })
544
- ], l.prototype, "value", 2);
545
- o([
546
- n({ type: String })
547
- ], l.prototype, "hint", 2);
548
- o([
549
- n({ type: Array })
550
- ], l.prototype, "tools", 2);
551
- o([
552
- n({ type: String })
553
- ], l.prototype, "placeholder", 2);
554
- o([
555
- n({ type: String })
556
- ], l.prototype, "autocomplete", 2);
557
- o([
558
- n({ type: String, attribute: "countermode" })
559
- ], l.prototype, "counterMode", 2);
560
- o([
561
- n({ type: Number, attribute: "minimumheight" })
562
- ], l.prototype, "minimumHeight", 2);
563
- o([
564
- n({ type: Boolean, attribute: "autogrow" })
565
- ], l.prototype, "autoGrow", 2);
566
- o([
567
- n({ type: Boolean, attribute: "defaultopenpreview" })
568
- ], l.prototype, "defaultOpenPreview", 2);
569
- o([
570
- n({ type: Number, attribute: "maxlength" })
571
- ], l.prototype, "maxLength", 2);
572
- o([
573
- n({ type: String })
574
- ], l.prototype, "headingTitle", 2);
575
- o([
576
- n({ type: String })
577
- ], l.prototype, "boldTitle", 2);
578
- o([
579
- n({ type: String })
580
- ], l.prototype, "italicTitle", 2);
581
- o([
582
- n({ type: String })
583
- ], l.prototype, "strikethroughTitle", 2);
584
- o([
585
- n({ type: String })
586
- ], l.prototype, "quoteTitle", 2);
587
- o([
588
- n({ type: String })
589
- ], l.prototype, "linkTitle", 2);
590
- o([
591
- n({ type: String })
592
- ], l.prototype, "orderedListTitle", 2);
593
- o([
594
- n({ type: String })
595
- ], l.prototype, "unorderedListTitle", 2);
596
- o([
597
- n({ type: String })
598
- ], l.prototype, "splitViewTitle", 2);
599
- o([
600
- n({ type: String, attribute: "toolbar-aria-label" })
601
- ], l.prototype, "toolbarAriaLabel", 2);
602
- o([
603
- n({ type: Object })
604
- ], l.prototype, "dependencies", 2);
605
- o([
606
- H()
607
- ], l.prototype, "splitViewActive", 2);
608
- o([
609
- H()
610
- ], l.prototype, "activeFormats", 2);
611
- l = o([
612
- A("gui-markdown")
613
- ], l);
614
- typeof customElements < "u" && !customElements.get("gui-markdown") && customElements.define("gui-markdown", l);
615
- var q = Object.defineProperty, E = Object.getOwnPropertyDescriptor, L = (t, e, i, r) => {
616
- for (var a = r > 1 ? void 0 : r ? E(e, i) : e, s = t.length - 1, d; s >= 0; s--)
617
- (d = t[s]) && (a = (r ? d(e, i, a) : d(a)) || a);
618
- return r && a && q(e, i, a), a;
619
- };
620
- let f = class extends k {
621
- constructor() {
622
- super(...arguments), this.adapter = new V(), this.subscriptions = [];
623
- }
624
- createRenderRoot() {
625
- return this;
626
- }
627
- updated(t) {
628
- super.updated(t);
629
- const e = this.adapter.templateData.size;
630
- e ? this.style.flex = String(e) : this.style.removeProperty("flex");
631
- }
632
- connectedCallback() {
633
- super.connectedCallback(), this.classList.add("gui-markdown", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
634
- this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
635
- );
636
- }
637
- render() {
638
- return super.render(), u`
639
- <gui-markdown
640
- .uid=${this.widget.uid}
641
- .label=${this.adapter.templateData.label}
642
- .errors=${this.adapter.templateData.errors}
643
- ?touched=${this.adapter.templateData.touched}
644
- ?required=${this.adapter.templateData.validator?.required}
645
- ?disabled=${this.adapter.templateData.disabled}
646
- ?readonly=${this.adapter.templateData.readonly}
647
- .value=${this.adapter.templateData.value}
648
- .hint=${this.adapter.templateData.hint}
649
- .placeholder=${this.adapter.templateData.placeholder}
650
- .autocomplete=${this.adapter.templateData.autocomplete}
651
- .counterMode=${this.adapter.templateData.counterMode}
652
- .minimumHeight=${this.adapter.templateData.minimumHeight}
653
- .autoGrow=${this.adapter.templateData.autoGrow}
654
- .tools=${this.adapter.templateData.tools}
655
- .headingTitle=${this.adapter.templateData.headingTitle}
656
- .boldTitle=${this.adapter.templateData.boldTitle}
657
- .italicTitle=${this.adapter.templateData.italicTitle}
658
- .strikethroughTitle=${this.adapter.templateData.strikethroughTitle}
659
- .quoteTitle=${this.adapter.templateData.quoteTitle}
660
- .linkTitle=${this.adapter.templateData.linkTitle}
661
- .orderedListTitle=${this.adapter.templateData.orderedListTitle}
662
- .unorderedListTitle=${this.adapter.templateData.unorderedListTitle}
663
- .splitViewTitle=${this.adapter.templateData.splitViewTitle}
664
- .toolbarAriaLabel=${this.adapter.templateData.toolbarAriaLabel}
665
- .defaultOpenPreview=${this.adapter.templateData.defaultOpenPreview}
666
- .maxLength=${this.adapter.templateData.validator?.maxLength}
667
- .dependencies=${this.adapter.templateData.deps}
668
- @input=${this.valueChanged}
669
- @blur=${() => this.adapter.onBlur()}
670
- ></gui-markdown>
671
- `;
672
- }
673
- valueChanged(t) {
674
- const e = t.detail.value;
675
- this.adapter.valueChanged(e);
676
- }
677
- disconnectedCallback() {
678
- super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
679
- }
680
- };
681
- L([
682
- I({ context: S }),
683
- n({ attribute: !1 })
684
- ], f.prototype, "formContext", 2);
685
- L([
686
- B({ context: C })
687
- ], f.prototype, "adapter", 2);
688
- f = L([
689
- A("gui-markdown-input")
690
- ], f);
691
- export {
692
- f as MarkdownElement
693
- };