@golemui/gui-lit 1.0.1 → 1.0.2
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/{currency.element-YyL4TeL0.js → currency.element-BHXWcOEu.js} +57 -54
- package/index.js +4 -4
- package/index.umd.cjs +24 -23
- package/{markdown.element-CNp4wbg9.js → markdown.element-p-kC47D7.js} +22 -21
- package/{number.element-B6TsvHMK.js → number.element-BhEyoOtc.js} +6 -6
- package/package.json +6 -6
- package/{textarea.element-Cu9ZW3K4.js → textarea.element-HThYqdR_.js} +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { InputWidgetAdapter as g, formContext as b, inputContext as v } from "@golemui/lit";
|
|
2
|
-
import { LitElement as m, nothing as p, html as
|
|
2
|
+
import { LitElement as m, nothing as p, html as d } from "lit";
|
|
3
3
|
import { property as a, state as f, query as $, customElement as y } from "lit/decorators.js";
|
|
4
4
|
import { classMap as D } from "lit/directives/class-map.js";
|
|
5
5
|
import { G as C, a as x, b as F, c as S } from "./templates-Dk1jxLwS.js";
|
|
6
6
|
import { consume as _, provide as w } from "@lit/context";
|
|
7
7
|
import "rxjs";
|
|
8
|
-
var E = Object.defineProperty, I = Object.getOwnPropertyDescriptor, r = (t,
|
|
9
|
-
for (var s = l > 1 ? void 0 : l ? I(
|
|
10
|
-
(u = t[n]) && (s = (l ? u(
|
|
11
|
-
return l && s && E(
|
|
8
|
+
var E = Object.defineProperty, I = Object.getOwnPropertyDescriptor, r = (t, e, o, l) => {
|
|
9
|
+
for (var s = l > 1 ? void 0 : l ? I(e, o) : e, n = t.length - 1, u; n >= 0; n--)
|
|
10
|
+
(u = t[n]) && (s = (l ? u(e, o, s) : u(s)) || s);
|
|
11
|
+
return l && s && E(e, o, s), s;
|
|
12
12
|
};
|
|
13
|
-
let
|
|
13
|
+
let i = class extends m {
|
|
14
14
|
constructor() {
|
|
15
15
|
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, {
|
|
16
16
|
getTargets: () => this.querySelectorAll(`input[id="${this.uid}"]`),
|
|
@@ -55,11 +55,11 @@ let e = class extends m {
|
|
|
55
55
|
autocomplete: this.autocomplete
|
|
56
56
|
};
|
|
57
57
|
this.displayValue = this.formatCurrency(this.value);
|
|
58
|
-
const
|
|
58
|
+
const e = x("currency", t), o = {
|
|
59
59
|
"gui-widget-input": !0,
|
|
60
60
|
"gui-currency--icon": !!this.icon
|
|
61
61
|
};
|
|
62
|
-
return
|
|
62
|
+
return d`
|
|
63
63
|
${F(this.uid, t)}
|
|
64
64
|
|
|
65
65
|
<div class="gui-widget">
|
|
@@ -80,12 +80,12 @@ let e = class extends m {
|
|
|
80
80
|
@focus=${this.handleFocus}
|
|
81
81
|
@blur=${this.handleBlur}
|
|
82
82
|
/>
|
|
83
|
-
${this.displayValue ?
|
|
83
|
+
${this.displayValue ? d`<label
|
|
84
84
|
for=${this.uid}
|
|
85
85
|
class="gui-currency__format-value ${this.icon ? "gui-currency__format-value--icon" : ""}"
|
|
86
86
|
>${this.displayValue}</label
|
|
87
87
|
>` : p}
|
|
88
|
-
${
|
|
88
|
+
${e.html}
|
|
89
89
|
</div>
|
|
90
90
|
|
|
91
91
|
${S(this.uid, t)}
|
|
@@ -93,10 +93,12 @@ let e = class extends m {
|
|
|
93
93
|
}
|
|
94
94
|
handleInput(t) {
|
|
95
95
|
if (t.stopPropagation(), !this.readOnly) {
|
|
96
|
-
const
|
|
97
|
-
this.displayValue = this.formatCurrency(
|
|
96
|
+
const e = t.target;
|
|
97
|
+
this.displayValue = this.formatCurrency(e.valueAsNumber);
|
|
98
|
+
const o = e.valueAsNumber;
|
|
99
|
+
this.dispatchEvent(
|
|
98
100
|
new CustomEvent("input", {
|
|
99
|
-
detail: { value:
|
|
101
|
+
detail: { value: Number.isNaN(o) ? void 0 : o },
|
|
100
102
|
bubbles: !0,
|
|
101
103
|
composed: !0
|
|
102
104
|
})
|
|
@@ -117,14 +119,15 @@ let e = class extends m {
|
|
|
117
119
|
formatCurrency(t) {
|
|
118
120
|
if (t === "" || t === void 0 || t === null || isNaN(t)) return "";
|
|
119
121
|
try {
|
|
122
|
+
const e = this.maximumFractionDigits ?? Math.max(this.minimumFractionDigits ?? 2, 2), o = Math.min(this.minimumFractionDigits ?? 2, e);
|
|
120
123
|
return new Intl.NumberFormat(this.localeId ?? "en", {
|
|
121
124
|
style: "currency",
|
|
122
125
|
currency: this.currency ?? "USD",
|
|
123
|
-
maximumFractionDigits:
|
|
124
|
-
minimumFractionDigits:
|
|
126
|
+
maximumFractionDigits: e,
|
|
127
|
+
minimumFractionDigits: o
|
|
125
128
|
}).format(t);
|
|
126
|
-
} catch (
|
|
127
|
-
return console.warn("Invalid locale or currency",
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return console.warn("Invalid locale or currency", e), t.toString();
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
133
|
get separators() {
|
|
@@ -137,71 +140,71 @@ let e = class extends m {
|
|
|
137
140
|
};
|
|
138
141
|
r([
|
|
139
142
|
a({ type: String })
|
|
140
|
-
],
|
|
143
|
+
], i.prototype, "uid", 2);
|
|
141
144
|
r([
|
|
142
145
|
a({ type: String })
|
|
143
|
-
],
|
|
146
|
+
], i.prototype, "label", 2);
|
|
144
147
|
r([
|
|
145
148
|
a({ type: String, attribute: "locale-id" })
|
|
146
|
-
],
|
|
149
|
+
], i.prototype, "localeId", 2);
|
|
147
150
|
r([
|
|
148
151
|
a({ type: Array })
|
|
149
|
-
],
|
|
152
|
+
], i.prototype, "errors", 2);
|
|
150
153
|
r([
|
|
151
154
|
a({ type: Boolean })
|
|
152
|
-
],
|
|
155
|
+
], i.prototype, "touched", 2);
|
|
153
156
|
r([
|
|
154
157
|
a({ type: Boolean })
|
|
155
|
-
],
|
|
158
|
+
], i.prototype, "required", 2);
|
|
156
159
|
r([
|
|
157
160
|
a({ type: Boolean })
|
|
158
|
-
],
|
|
161
|
+
], i.prototype, "disabled", 2);
|
|
159
162
|
r([
|
|
160
163
|
a({ type: Boolean, attribute: "readonly" })
|
|
161
|
-
],
|
|
164
|
+
], i.prototype, "readOnly", 2);
|
|
162
165
|
r([
|
|
163
166
|
a({ type: String })
|
|
164
|
-
],
|
|
167
|
+
], i.prototype, "value", 2);
|
|
165
168
|
r([
|
|
166
169
|
a({ type: String })
|
|
167
|
-
],
|
|
170
|
+
], i.prototype, "currency", 2);
|
|
168
171
|
r([
|
|
169
172
|
a({ type: String })
|
|
170
|
-
],
|
|
173
|
+
], i.prototype, "step", 2);
|
|
171
174
|
r([
|
|
172
175
|
a({ type: String })
|
|
173
|
-
],
|
|
176
|
+
], i.prototype, "maximumFractionDigits", 2);
|
|
174
177
|
r([
|
|
175
178
|
a({ type: String })
|
|
176
|
-
],
|
|
179
|
+
], i.prototype, "minimumFractionDigits", 2);
|
|
177
180
|
r([
|
|
178
181
|
a({ type: String })
|
|
179
|
-
],
|
|
182
|
+
], i.prototype, "hint", 2);
|
|
180
183
|
r([
|
|
181
184
|
a({ type: String })
|
|
182
|
-
],
|
|
185
|
+
], i.prototype, "icon", 2);
|
|
183
186
|
r([
|
|
184
187
|
a({ type: String })
|
|
185
|
-
],
|
|
188
|
+
], i.prototype, "placeholder", 2);
|
|
186
189
|
r([
|
|
187
190
|
a({ type: String })
|
|
188
|
-
],
|
|
191
|
+
], i.prototype, "autocomplete", 2);
|
|
189
192
|
r([
|
|
190
193
|
f()
|
|
191
|
-
],
|
|
194
|
+
], i.prototype, "displayValue", 2);
|
|
192
195
|
r([
|
|
193
196
|
$("input")
|
|
194
|
-
],
|
|
195
|
-
|
|
197
|
+
], i.prototype, "inputElement", 2);
|
|
198
|
+
i = r([
|
|
196
199
|
y("gui-currency")
|
|
197
|
-
],
|
|
198
|
-
typeof customElements < "u" && !customElements.get("gui-currency") && customElements.define("gui-currency",
|
|
199
|
-
var O = Object.defineProperty, q = Object.getOwnPropertyDescriptor, h = (t,
|
|
200
|
-
for (var s = l > 1 ? void 0 : l ? q(
|
|
201
|
-
(u = t[n]) && (s = (l ? u(
|
|
202
|
-
return l && s && O(
|
|
200
|
+
], i);
|
|
201
|
+
typeof customElements < "u" && !customElements.get("gui-currency") && customElements.define("gui-currency", i);
|
|
202
|
+
var O = Object.defineProperty, q = Object.getOwnPropertyDescriptor, h = (t, e, o, l) => {
|
|
203
|
+
for (var s = l > 1 ? void 0 : l ? q(e, o) : e, n = t.length - 1, u; n >= 0; n--)
|
|
204
|
+
(u = t[n]) && (s = (l ? u(e, o, s) : u(s)) || s);
|
|
205
|
+
return l && s && O(e, o, s), s;
|
|
203
206
|
};
|
|
204
|
-
let
|
|
207
|
+
let c = class extends m {
|
|
205
208
|
constructor() {
|
|
206
209
|
super(...arguments), this.adapter = new g(), this.subscriptions = [];
|
|
207
210
|
}
|
|
@@ -210,8 +213,8 @@ let d = class extends m {
|
|
|
210
213
|
}
|
|
211
214
|
updated(t) {
|
|
212
215
|
super.updated(t);
|
|
213
|
-
const
|
|
214
|
-
|
|
216
|
+
const e = this.adapter.templateData.size;
|
|
217
|
+
e ? this.style.flex = String(e) : this.style.removeProperty("flex");
|
|
215
218
|
}
|
|
216
219
|
connectedCallback() {
|
|
217
220
|
super.connectedCallback(), this.classList.add("gui-currency", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
|
|
@@ -219,7 +222,7 @@ let d = class extends m {
|
|
|
219
222
|
);
|
|
220
223
|
}
|
|
221
224
|
render() {
|
|
222
|
-
return super.render(),
|
|
225
|
+
return super.render(), d`
|
|
223
226
|
<gui-currency
|
|
224
227
|
.uid=${this.widget.uid}
|
|
225
228
|
.label=${this.adapter.templateData.label}
|
|
@@ -244,8 +247,8 @@ let d = class extends m {
|
|
|
244
247
|
`;
|
|
245
248
|
}
|
|
246
249
|
valueChanged(t) {
|
|
247
|
-
const
|
|
248
|
-
this.adapter.valueChanged(
|
|
250
|
+
const e = t.detail.value;
|
|
251
|
+
this.adapter.valueChanged(e);
|
|
249
252
|
}
|
|
250
253
|
disconnectedCallback() {
|
|
251
254
|
super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
|
|
@@ -254,13 +257,13 @@ let d = class extends m {
|
|
|
254
257
|
h([
|
|
255
258
|
_({ context: b }),
|
|
256
259
|
a({ attribute: !1 })
|
|
257
|
-
],
|
|
260
|
+
], c.prototype, "formContext", 2);
|
|
258
261
|
h([
|
|
259
262
|
w({ context: v })
|
|
260
|
-
],
|
|
261
|
-
|
|
263
|
+
], c.prototype, "adapter", 2);
|
|
264
|
+
c = h([
|
|
262
265
|
y("gui-currency-input")
|
|
263
|
-
],
|
|
266
|
+
], c);
|
|
264
267
|
export {
|
|
265
|
-
|
|
268
|
+
c as CurrencyElement
|
|
266
269
|
};
|
package/index.js
CHANGED
|
@@ -3389,18 +3389,18 @@ const Us = {
|
|
|
3389
3389
|
rangeCalendar: async () => (await import("./range-calendar.element-QTE6vGNP.js")).RangeCalendarElement,
|
|
3390
3390
|
rangeDateInput: async () => (await import("./range-date-input.element-Dj29D_OQ.js")).RangeDateInputElement,
|
|
3391
3391
|
rangeDatePicker: async () => (await import("./range-date-picker.element-CuKIBkIO.js")).RangeDatePickerElement,
|
|
3392
|
-
currency: async () => (await import("./currency.element-
|
|
3392
|
+
currency: async () => (await import("./currency.element-BHXWcOEu.js")).CurrencyElement,
|
|
3393
3393
|
dateInput: async () => (await import("./date.element-BtVJSIRk.js")).DateElement,
|
|
3394
3394
|
datePicker: async () => (await import("./date-picker.element-DabW_-0-.js")).DatePickerElement,
|
|
3395
3395
|
dropdown: async () => (await import("./dropdown.element-DqzC6aXR.js")).DropdownElement,
|
|
3396
3396
|
list: async () => (await import("./list.element-Co3V3Cn5.js")).ListElement,
|
|
3397
|
-
markdown: async () => (await import("./markdown.element-
|
|
3397
|
+
markdown: async () => (await import("./markdown.element-p-kC47D7.js")).MarkdownElement,
|
|
3398
3398
|
password: async () => (await import("./password.element-n-R9RbkB.js")).PasswordElement,
|
|
3399
3399
|
textinput: async () => (await import("./textinput.element-CkXNzMUg.js")).TextinputElement,
|
|
3400
|
-
textarea: async () => (await import("./textarea.element-
|
|
3400
|
+
textarea: async () => (await import("./textarea.element-HThYqdR_.js")).TextareaElement,
|
|
3401
3401
|
toggle: async () => (await import("./toggle.element-C1kCw5H8.js")).ToggleElement,
|
|
3402
3402
|
checkbox: async () => (await import("./checkbox.element-CVskoXEc.js")).CheckboxElement,
|
|
3403
|
-
number: async () => (await import("./number.element-
|
|
3403
|
+
number: async () => (await import("./number.element-BhEyoOtc.js")).NumberElement,
|
|
3404
3404
|
radiogroup: async () => (await import("./radiogroup.element-CeQn623u.js")).RadiogroupElement,
|
|
3405
3405
|
select: async () => (await import("./select.element-jcDF1h-g.js")).SelectElement,
|
|
3406
3406
|
tags: async () => (await import("./tags.element-CX3vQL8L.js")).TagsElement,
|