@golemui/gui-lit 0.12.2 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -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,266 @@
|
|
|
1
|
+
import { InputWidgetAdapter as g, formContext as b, inputContext as v } from "@golemui/lit";
|
|
2
|
+
import "@golemui/gui-shared";
|
|
3
|
+
import { LitElement as m, nothing as p, html as d } from "lit";
|
|
4
|
+
import { property as a, state as f, query as $, customElement as y } from "lit/decorators.js";
|
|
5
|
+
import { classMap as D } from "lit/directives/class-map.js";
|
|
6
|
+
import { G as C, a as x, b as F, c as S } from "./templates-Dk1jxLwS.js";
|
|
7
|
+
import { consume as _, provide as w } from "@lit/context";
|
|
8
|
+
import "rxjs";
|
|
9
|
+
var E = Object.defineProperty, I = Object.getOwnPropertyDescriptor, r = (t, i, o, l) => {
|
|
10
|
+
for (var s = l > 1 ? void 0 : l ? I(i, o) : i, n = t.length - 1, u; n >= 0; n--)
|
|
11
|
+
(u = t[n]) && (s = (l ? u(i, o, s) : u(s)) || s);
|
|
12
|
+
return l && s && E(i, o, s), s;
|
|
13
|
+
};
|
|
14
|
+
let e = class extends m {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments), this.uid = void 0, this.label = void 0, this.localeId = void 0, this.errors = [], this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.currency = void 0, this.step = void 0, this.maximumFractionDigits = void 0, this.minimumFractionDigits = void 0, this.hint = void 0, this.icon = void 0, this.placeholder = void 0, this.autocomplete = void 0, this.ariaController = new C(this, {
|
|
17
|
+
getTargets: () => this.querySelectorAll(`input[id="${this.uid}"]`),
|
|
18
|
+
getState: () => ({
|
|
19
|
+
uid: this.uid,
|
|
20
|
+
templateData: {
|
|
21
|
+
hint: this.hint,
|
|
22
|
+
errors: this.errors,
|
|
23
|
+
readonly: this.readOnly,
|
|
24
|
+
disabled: this.disabled,
|
|
25
|
+
touched: this.touched
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
createRenderRoot() {
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
super.connectedCallback(), this.classList.add("gui-field");
|
|
35
|
+
}
|
|
36
|
+
willUpdate(t) {
|
|
37
|
+
t.has("value") && document.activeElement !== this.inputElement && (this.displayValue = this.formatCurrency(this.value));
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
super.render();
|
|
41
|
+
const t = {
|
|
42
|
+
uid: this.uid,
|
|
43
|
+
label: this.label,
|
|
44
|
+
hint: this.hint,
|
|
45
|
+
errors: this.errors,
|
|
46
|
+
touched: this.touched,
|
|
47
|
+
required: this.required,
|
|
48
|
+
disabled: this.disabled,
|
|
49
|
+
readonly: this.readOnly,
|
|
50
|
+
value: this.value,
|
|
51
|
+
currency: this.currency,
|
|
52
|
+
maximumFractionDigits: this.maximumFractionDigits,
|
|
53
|
+
minimumFractionDigits: this.minimumFractionDigits,
|
|
54
|
+
icon: this.icon,
|
|
55
|
+
placeholder: this.placeholder,
|
|
56
|
+
autocomplete: this.autocomplete
|
|
57
|
+
};
|
|
58
|
+
this.displayValue = this.formatCurrency(this.value);
|
|
59
|
+
const i = x("currency", t), o = {
|
|
60
|
+
"gui-currency--icon": !!this.icon
|
|
61
|
+
};
|
|
62
|
+
return d`
|
|
63
|
+
${F(this.uid, t)}
|
|
64
|
+
|
|
65
|
+
<div class="gui-widget">
|
|
66
|
+
<input
|
|
67
|
+
type="number"
|
|
68
|
+
inputmode="decimal"
|
|
69
|
+
id=${this.uid}
|
|
70
|
+
data-cy=${`${this.uid}_currency`}
|
|
71
|
+
class=${D(o)}
|
|
72
|
+
step=${this.step && this.step > 0 ? this.step : p}
|
|
73
|
+
.value=${this.value ?? ""}
|
|
74
|
+
?required=${this.disabled}
|
|
75
|
+
?disabled=${this.disabled}
|
|
76
|
+
?readonly=${this.readOnly}
|
|
77
|
+
placeholder=${this.placeholder || p}
|
|
78
|
+
autocomplete=${this.autocomplete || p}
|
|
79
|
+
@input=${this.handleInput}
|
|
80
|
+
@focus=${this.handleFocus}
|
|
81
|
+
@blur=${this.handleBlur}
|
|
82
|
+
/>
|
|
83
|
+
${this.displayValue ? d`<label
|
|
84
|
+
for=${this.uid}
|
|
85
|
+
class="gui-currency__format-value ${this.icon ? "gui-currency__format-value--icon" : ""}"
|
|
86
|
+
>${this.displayValue}</label
|
|
87
|
+
>` : p}
|
|
88
|
+
${i.html}
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
${S(this.uid, t)}
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
handleInput(t) {
|
|
95
|
+
if (t.stopPropagation(), !this.readOnly) {
|
|
96
|
+
const i = t.target;
|
|
97
|
+
this.displayValue = this.formatCurrency(i.valueAsNumber), this.dispatchEvent(
|
|
98
|
+
new CustomEvent("input", {
|
|
99
|
+
detail: { value: i.valueAsNumber },
|
|
100
|
+
bubbles: !0,
|
|
101
|
+
composed: !0
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
handleFocus() {
|
|
107
|
+
this.displayValue = this.formatCurrency(this.value);
|
|
108
|
+
}
|
|
109
|
+
handleBlur() {
|
|
110
|
+
this.displayValue = this.formatCurrency(this.value), this.dispatchEvent(
|
|
111
|
+
new CustomEvent("blur", {
|
|
112
|
+
bubbles: !0,
|
|
113
|
+
composed: !0
|
|
114
|
+
})
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
formatCurrency(t) {
|
|
118
|
+
if (t === "" || t === void 0 || t === null || isNaN(t)) return "";
|
|
119
|
+
try {
|
|
120
|
+
return new Intl.NumberFormat(this.localeId ?? "en", {
|
|
121
|
+
style: "currency",
|
|
122
|
+
currency: this.currency ?? "USD",
|
|
123
|
+
maximumFractionDigits: this.maximumFractionDigits ?? Math.max(this.minimumFractionDigits ?? 2, 2),
|
|
124
|
+
minimumFractionDigits: this.minimumFractionDigits ?? 2
|
|
125
|
+
}).format(t);
|
|
126
|
+
} catch (i) {
|
|
127
|
+
return console.warn("Invalid locale or currency", i), t.toString();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
get separators() {
|
|
131
|
+
const t = new Intl.NumberFormat(this.localeId ?? "en").format(1111.1);
|
|
132
|
+
return {
|
|
133
|
+
group: t.replace(/1/g, "").replace(/\d/g, "")[0] || ",",
|
|
134
|
+
decimal: t.replace(/1/g, "").replace(/\d/g, "").slice(-1) || "."
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
r([
|
|
139
|
+
a({ type: String })
|
|
140
|
+
], e.prototype, "uid", 2);
|
|
141
|
+
r([
|
|
142
|
+
a({ type: String })
|
|
143
|
+
], e.prototype, "label", 2);
|
|
144
|
+
r([
|
|
145
|
+
a({ type: String, attribute: "locale-id" })
|
|
146
|
+
], e.prototype, "localeId", 2);
|
|
147
|
+
r([
|
|
148
|
+
a({ type: Array })
|
|
149
|
+
], e.prototype, "errors", 2);
|
|
150
|
+
r([
|
|
151
|
+
a({ type: Boolean })
|
|
152
|
+
], e.prototype, "touched", 2);
|
|
153
|
+
r([
|
|
154
|
+
a({ type: Boolean })
|
|
155
|
+
], e.prototype, "required", 2);
|
|
156
|
+
r([
|
|
157
|
+
a({ type: Boolean })
|
|
158
|
+
], e.prototype, "disabled", 2);
|
|
159
|
+
r([
|
|
160
|
+
a({ type: Boolean, attribute: "readonly" })
|
|
161
|
+
], e.prototype, "readOnly", 2);
|
|
162
|
+
r([
|
|
163
|
+
a({ type: String })
|
|
164
|
+
], e.prototype, "value", 2);
|
|
165
|
+
r([
|
|
166
|
+
a({ type: String })
|
|
167
|
+
], e.prototype, "currency", 2);
|
|
168
|
+
r([
|
|
169
|
+
a({ type: String })
|
|
170
|
+
], e.prototype, "step", 2);
|
|
171
|
+
r([
|
|
172
|
+
a({ type: String })
|
|
173
|
+
], e.prototype, "maximumFractionDigits", 2);
|
|
174
|
+
r([
|
|
175
|
+
a({ type: String })
|
|
176
|
+
], e.prototype, "minimumFractionDigits", 2);
|
|
177
|
+
r([
|
|
178
|
+
a({ type: String })
|
|
179
|
+
], e.prototype, "hint", 2);
|
|
180
|
+
r([
|
|
181
|
+
a({ type: String })
|
|
182
|
+
], e.prototype, "icon", 2);
|
|
183
|
+
r([
|
|
184
|
+
a({ type: String })
|
|
185
|
+
], e.prototype, "placeholder", 2);
|
|
186
|
+
r([
|
|
187
|
+
a({ type: String })
|
|
188
|
+
], e.prototype, "autocomplete", 2);
|
|
189
|
+
r([
|
|
190
|
+
f()
|
|
191
|
+
], e.prototype, "displayValue", 2);
|
|
192
|
+
r([
|
|
193
|
+
$("input")
|
|
194
|
+
], e.prototype, "inputElement", 2);
|
|
195
|
+
e = r([
|
|
196
|
+
y("gui-currency")
|
|
197
|
+
], e);
|
|
198
|
+
typeof customElements < "u" && !customElements.get("gui-currency") && customElements.define("gui-currency", e);
|
|
199
|
+
var O = Object.defineProperty, q = Object.getOwnPropertyDescriptor, h = (t, i, o, l) => {
|
|
200
|
+
for (var s = l > 1 ? void 0 : l ? q(i, o) : i, n = t.length - 1, u; n >= 0; n--)
|
|
201
|
+
(u = t[n]) && (s = (l ? u(i, o, s) : u(s)) || s);
|
|
202
|
+
return l && s && O(i, o, s), s;
|
|
203
|
+
};
|
|
204
|
+
let c = class extends m {
|
|
205
|
+
constructor() {
|
|
206
|
+
super(...arguments), this.adapter = new g(), this.subscriptions = [];
|
|
207
|
+
}
|
|
208
|
+
createRenderRoot() {
|
|
209
|
+
return this;
|
|
210
|
+
}
|
|
211
|
+
updated(t) {
|
|
212
|
+
super.updated(t);
|
|
213
|
+
const i = this.adapter.templateData.size;
|
|
214
|
+
i ? this.style.flex = String(i) : this.style.removeProperty("flex");
|
|
215
|
+
}
|
|
216
|
+
connectedCallback() {
|
|
217
|
+
super.connectedCallback(), this.classList.add("gui-currency", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
218
|
+
this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
render() {
|
|
222
|
+
return super.render(), d`
|
|
223
|
+
<gui-currency
|
|
224
|
+
.uid=${this.widget.uid}
|
|
225
|
+
.label=${this.adapter.templateData.label}
|
|
226
|
+
.hint=${this.adapter.templateData.hint}
|
|
227
|
+
.errors=${this.adapter.templateData.errors}
|
|
228
|
+
?touched=${this.adapter.templateData.touched}
|
|
229
|
+
?required=${this.adapter.templateData.validator?.required}
|
|
230
|
+
?disabled=${this.adapter.templateData.disabled}
|
|
231
|
+
?readonly=${this.adapter.templateData.readonly}
|
|
232
|
+
.value=${this.adapter.templateData.value}
|
|
233
|
+
.currency=${this.adapter.templateData.currency}
|
|
234
|
+
.step=${this.adapter.templateData.step}
|
|
235
|
+
.maximumFractionDigits=${this.adapter.templateData.maximumFractionDigits}
|
|
236
|
+
.minimumFractionDigits=${this.adapter.templateData.minimumFractionDigits}
|
|
237
|
+
.icon=${this.adapter.templateData.icon}
|
|
238
|
+
.placeholder=${this.adapter.templateData.placeholder}
|
|
239
|
+
.autocomplete=${this.adapter.templateData.autocomplete}
|
|
240
|
+
.localeId=${this.adapter.templateData.lang}
|
|
241
|
+
@input=${this.valueChanged}
|
|
242
|
+
@blur=${() => this.adapter.onBlur()}
|
|
243
|
+
></gui-currency>
|
|
244
|
+
`;
|
|
245
|
+
}
|
|
246
|
+
valueChanged(t) {
|
|
247
|
+
const i = t.detail.value;
|
|
248
|
+
this.adapter.valueChanged(i);
|
|
249
|
+
}
|
|
250
|
+
disconnectedCallback() {
|
|
251
|
+
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
h([
|
|
255
|
+
_({ context: b }),
|
|
256
|
+
a({ attribute: !1 })
|
|
257
|
+
], c.prototype, "formContext", 2);
|
|
258
|
+
h([
|
|
259
|
+
w({ context: v })
|
|
260
|
+
], c.prototype, "adapter", 2);
|
|
261
|
+
c = h([
|
|
262
|
+
y("gui-currency-input")
|
|
263
|
+
], c);
|
|
264
|
+
export {
|
|
265
|
+
c as CurrencyElement
|
|
266
|
+
};
|