@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,266 @@
|
|
|
1
|
+
import { i as y, A as u, b as l, n as d, t as g } from "./directive-1yd1wdny.js";
|
|
2
|
+
import { r as p } from "./state-DI9ZsB5W.js";
|
|
3
|
+
import { l as m } from "./live-BfTBpQrp.js";
|
|
4
|
+
import { c as _ } from "./repeat-BucBfSPF.js";
|
|
5
|
+
import { e as f } from "./class-map-DrTVAYz_.js";
|
|
6
|
+
import { G as v, b as A, c as S } from "./templates-DBGyvZtc.js";
|
|
7
|
+
import { t as b } from "./date-BS1lA1xg.js";
|
|
8
|
+
import "@golemui/gui-shared";
|
|
9
|
+
var w = Object.defineProperty, I = Object.getOwnPropertyDescriptor, h = (t, e, a, i) => {
|
|
10
|
+
for (var r = i > 1 ? void 0 : i ? I(e, a) : e, n = t.length - 1, s; n >= 0; n--)
|
|
11
|
+
(s = t[n]) && (r = (i ? s(e, a, r) : s(r)) || r);
|
|
12
|
+
return i && r && w(e, a, r), r;
|
|
13
|
+
};
|
|
14
|
+
let o = class extends y {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments), this.uid = void 0, this.label = void 0, this.localeId = void 0, this.errors = [], this.showErrors = !0, this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.icon = "", this.hint = void 0, this._day = "", this._month = "", this._year = "", this.MIN_DAY = 1, this.MAX_DAY = 31, this.MAX_VALID_DAY = (t, e) => t === 2 ? new Date(e, 1, 29).getDate() === 29 || !e ? 29 : 28 : t === 4 || t === 6 || t === 9 || t === 11 ? 30 : 31, this.MIN_MONTH = 1, this.MAX_MONTH = 12, this.MIN_YEAR = 1e3, this.MAX_YEAR = 9999, this.ariaController = new v(this, {
|
|
17
|
+
getTargets: () => this.querySelectorAll(".gui-date-input"),
|
|
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") && this.parseValue(this.value ?? "");
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
const t = {
|
|
41
|
+
uid: this.uid,
|
|
42
|
+
label: this.label,
|
|
43
|
+
errors: this.errors,
|
|
44
|
+
touched: this.touched,
|
|
45
|
+
required: this.required,
|
|
46
|
+
disabled: this.disabled,
|
|
47
|
+
readonly: this.readOnly,
|
|
48
|
+
value: this.value,
|
|
49
|
+
icon: this.icon,
|
|
50
|
+
hint: this.hint
|
|
51
|
+
}, e = new Intl.DateTimeFormat(this.localeId ?? "en", {
|
|
52
|
+
year: "numeric",
|
|
53
|
+
month: "numeric",
|
|
54
|
+
day: "numeric"
|
|
55
|
+
}).formatToParts(/* @__PURE__ */ new Date()), a = {
|
|
56
|
+
"gui-widget-icon": !0,
|
|
57
|
+
[this.icon]: !0
|
|
58
|
+
};
|
|
59
|
+
return l`
|
|
60
|
+
${this.label ? A(this.uid, t) : u}
|
|
61
|
+
|
|
62
|
+
<div class="gui-widget">
|
|
63
|
+
<div class="gui-date-input ${this.icon ? "gui-calendar--icon" : ""}" role="group">
|
|
64
|
+
${_(
|
|
65
|
+
e,
|
|
66
|
+
(i) => i.type,
|
|
67
|
+
(i, r) => {
|
|
68
|
+
const n = r === 0 ? 0 : -1;
|
|
69
|
+
switch (i.type) {
|
|
70
|
+
case "day":
|
|
71
|
+
return this.renderInput("day", "dd", 2, n, this._day);
|
|
72
|
+
case "month":
|
|
73
|
+
return this.renderInput("month", "mm", 2, n, this._month);
|
|
74
|
+
case "year":
|
|
75
|
+
return this.renderInput("year", "yyyy", 4, n, this._year);
|
|
76
|
+
case "literal":
|
|
77
|
+
return l`<span class="gui-date-input__separator">${i.value}</span>`;
|
|
78
|
+
default:
|
|
79
|
+
return "";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
)}
|
|
83
|
+
</div>
|
|
84
|
+
${this.icon ? l`<span class=${f(a)} data-icon=${this.icon}></span>` : u}
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
${this.showErrors && this.errors?.length ? S(this.uid, t) : u}
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
renderInput(t, e, a, i, r) {
|
|
91
|
+
return l`
|
|
92
|
+
<div class="gui-date-input__touch-target">
|
|
93
|
+
<input
|
|
94
|
+
type="text"
|
|
95
|
+
inputmode="numeric"
|
|
96
|
+
class="gui-date-input__part ${t === "year" ? "gui-date-input__year" : ""}"
|
|
97
|
+
data-type=${t}
|
|
98
|
+
maxlength=${a}
|
|
99
|
+
placeholder=${e}
|
|
100
|
+
tabindex=${i}
|
|
101
|
+
?required=${this.required}
|
|
102
|
+
?disabled=${this.disabled}
|
|
103
|
+
?readonly=${this.readOnly}
|
|
104
|
+
autocomplete="off"
|
|
105
|
+
.value=${m(r)}
|
|
106
|
+
@keydown=${this.handleKeyDown}
|
|
107
|
+
@keyup=${(n) => this.handleKeyUp(n, t)}
|
|
108
|
+
@focus=${this.handleFocus}
|
|
109
|
+
@blur=${(n) => this.handleBlur(n, t)}
|
|
110
|
+
@change=${(n) => this.handleChange(n, t)}
|
|
111
|
+
/>
|
|
112
|
+
<div class="gui-date-input__visual-underline"></div>
|
|
113
|
+
</div>
|
|
114
|
+
`;
|
|
115
|
+
}
|
|
116
|
+
parseValue(t) {
|
|
117
|
+
if (!t) {
|
|
118
|
+
this._day = "", this._month = "", this._year = "";
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const e = new Date(t);
|
|
122
|
+
isNaN(e.getTime()) || (this._day = e.getDate().toString().padStart(2, "0"), this._month = (e.getMonth() + 1).toString().padStart(2, "0"), this._year = e.getFullYear().toString());
|
|
123
|
+
}
|
|
124
|
+
handleKeyDown(t) {
|
|
125
|
+
[
|
|
126
|
+
"Backspace",
|
|
127
|
+
"Tab",
|
|
128
|
+
"ArrowUp",
|
|
129
|
+
"ArrowDown",
|
|
130
|
+
"ArrowLeft",
|
|
131
|
+
"ArrowRight",
|
|
132
|
+
"Delete",
|
|
133
|
+
"Enter"
|
|
134
|
+
].includes(t.key) || t.ctrlKey || t.metaKey || this.readOnly || /^[0-9]$/.test(t.key) || t.preventDefault();
|
|
135
|
+
}
|
|
136
|
+
handleFocus(t) {
|
|
137
|
+
this.dispatchEvent(new CustomEvent("focus", { detail: t }));
|
|
138
|
+
}
|
|
139
|
+
handleKeyUp(t, e) {
|
|
140
|
+
if (this.readOnly) return;
|
|
141
|
+
const a = window.getComputedStyle(this).direction === "rtl", i = t.target, r = Array.from(this.querySelectorAll("input")), n = r.indexOf(i);
|
|
142
|
+
switch (i.value.length === i.maxLength && /^[0-9]$/.test(t.key) && (n === r.length - 1 ? r[0].focus() : r[n + 1].focus()), t.key) {
|
|
143
|
+
case "ArrowUp": {
|
|
144
|
+
const s = isNaN(parseInt(i.value, 10) + 1) ? 1 : parseInt(i.value, 10) + 1;
|
|
145
|
+
e === "year" && (this._year = s.toString().padStart(4, "0")), e === "month" && (this._month = s.toString().padStart(2, "0")), e === "day" && (this._day = s.toString().padStart(2, "0")), i.select(), this.validateAndEmit();
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case "ArrowDown": {
|
|
149
|
+
const s = isNaN(parseInt(i.value, 10) - 1) ? 1 : parseInt(i.value, 10) - 1;
|
|
150
|
+
e === "year" && (this._year = s.toString().padStart(4, "0")), e === "month" && (this._month = s.toString().padStart(2, "0")), e === "day" && (this._day = s.toString().padStart(2, "0")), i.select(), this.validateAndEmit();
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case "ArrowLeft": {
|
|
154
|
+
const s = a ? n + 1 : n - 1;
|
|
155
|
+
s >= 0 && s < r.length && (r[s].focus(), r[s].select());
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case "ArrowRight": {
|
|
159
|
+
const s = a ? n - 1 : n + 1;
|
|
160
|
+
s >= 0 && s < r.length && (r[s].focus(), r[s].select());
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
handleChange(t, e) {
|
|
166
|
+
if (t.stopImmediatePropagation(), this.readOnly) return;
|
|
167
|
+
const i = t.target.value.replace(/[^0-9]/g, "");
|
|
168
|
+
switch (e) {
|
|
169
|
+
case "day":
|
|
170
|
+
this._day = i;
|
|
171
|
+
break;
|
|
172
|
+
case "month":
|
|
173
|
+
this._month = i;
|
|
174
|
+
break;
|
|
175
|
+
case "year":
|
|
176
|
+
this._year = i;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
this.validateAndEmit();
|
|
180
|
+
}
|
|
181
|
+
handleBlur(t, e) {
|
|
182
|
+
const a = t.target, i = parseInt(a.value, 10);
|
|
183
|
+
if (!isNaN(i) && i > 0) {
|
|
184
|
+
const r = e === "year" ? 4 : 2;
|
|
185
|
+
a.value = i.toString().padStart(r, "0");
|
|
186
|
+
} else
|
|
187
|
+
this.dispatchEvent(new CustomEvent("change", { detail: { value: null } }));
|
|
188
|
+
this.dispatchEvent(new CustomEvent("blur"));
|
|
189
|
+
}
|
|
190
|
+
validateAndEmit() {
|
|
191
|
+
let t = parseInt(this._year, 10), e = parseInt(this._month, 10), a = parseInt(this._day, 10);
|
|
192
|
+
t > this.MAX_YEAR && (t = this.MAX_YEAR, this._year = t.toString().padStart(4, "0")), t < this.MIN_YEAR && (t = this.MIN_YEAR, this._year = t.toString().padStart(4, "0")), e > this.MAX_MONTH && (e = this.MAX_MONTH, this._month = e.toString().padStart(2, "0")), e < this.MIN_MONTH && (e = this.MIN_MONTH, this._month = e.toString().padStart(2, "0")), a > this.MAX_DAY && (a = this.MAX_DAY, this._day = a.toString().padStart(2, "0")), a < this.MIN_DAY && (a = this.MIN_DAY, this._day = a.toString().padStart(2, "0"));
|
|
193
|
+
const i = !isNaN(t) && String(t).length === 4, r = !isNaN(e) && e > 0;
|
|
194
|
+
if (!isNaN(a) && a > 0 && r && i) {
|
|
195
|
+
const s = this.MAX_VALID_DAY(e, t);
|
|
196
|
+
if (a > s)
|
|
197
|
+
this.dispatchEvent(
|
|
198
|
+
new CustomEvent("inputError", {
|
|
199
|
+
detail: {
|
|
200
|
+
message: "Invalid date: day is greater than the maximum valid day for the month and year."
|
|
201
|
+
},
|
|
202
|
+
bubbles: !0
|
|
203
|
+
})
|
|
204
|
+
);
|
|
205
|
+
else {
|
|
206
|
+
const c = new Date(t, e - 1, a);
|
|
207
|
+
this.value = b(c), this.dispatchEvent(
|
|
208
|
+
new CustomEvent("change", {
|
|
209
|
+
detail: { value: this.value },
|
|
210
|
+
bubbles: !0
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
this.requestUpdate();
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
h([
|
|
219
|
+
d({ type: String })
|
|
220
|
+
], o.prototype, "uid", 2);
|
|
221
|
+
h([
|
|
222
|
+
d({ type: String })
|
|
223
|
+
], o.prototype, "label", 2);
|
|
224
|
+
h([
|
|
225
|
+
d({ type: String, attribute: "locale-id" })
|
|
226
|
+
], o.prototype, "localeId", 2);
|
|
227
|
+
h([
|
|
228
|
+
d({ type: Array })
|
|
229
|
+
], o.prototype, "errors", 2);
|
|
230
|
+
h([
|
|
231
|
+
d({ type: Boolean })
|
|
232
|
+
], o.prototype, "showErrors", 2);
|
|
233
|
+
h([
|
|
234
|
+
d({ type: Boolean })
|
|
235
|
+
], o.prototype, "touched", 2);
|
|
236
|
+
h([
|
|
237
|
+
d({ type: Boolean })
|
|
238
|
+
], o.prototype, "required", 2);
|
|
239
|
+
h([
|
|
240
|
+
d({ type: Boolean })
|
|
241
|
+
], o.prototype, "disabled", 2);
|
|
242
|
+
h([
|
|
243
|
+
d({ type: Boolean, attribute: "readonly" })
|
|
244
|
+
], o.prototype, "readOnly", 2);
|
|
245
|
+
h([
|
|
246
|
+
d({ type: String })
|
|
247
|
+
], o.prototype, "value", 2);
|
|
248
|
+
h([
|
|
249
|
+
d({ type: String })
|
|
250
|
+
], o.prototype, "icon", 2);
|
|
251
|
+
h([
|
|
252
|
+
d({ type: String })
|
|
253
|
+
], o.prototype, "hint", 2);
|
|
254
|
+
h([
|
|
255
|
+
p()
|
|
256
|
+
], o.prototype, "_day", 2);
|
|
257
|
+
h([
|
|
258
|
+
p()
|
|
259
|
+
], o.prototype, "_month", 2);
|
|
260
|
+
h([
|
|
261
|
+
p()
|
|
262
|
+
], o.prototype, "_year", 2);
|
|
263
|
+
o = h([
|
|
264
|
+
g("gui-date")
|
|
265
|
+
], o);
|
|
266
|
+
typeof customElements < "u" && !customElements.get("gui-date") && customElements.define("gui-date", o);
|