@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.
Files changed (96) hide show
  1. package/Accordion-BU3skkjb.js +58 -0
  2. package/Alert-DpUiDxQT.js +17 -0
  3. package/Button-BYVR5EKG.js +86 -0
  4. package/CHANGELOG.md +16 -0
  5. package/{Calendar-Dxavv2c7.js → Calendar-BmMkpTcV.js} +13 -11
  6. package/Checkbox-B1Tsf-vi.js +164 -0
  7. package/Currency-D0pOQwU4.js +233 -0
  8. package/{DateInput-CdkyyAhc.js → DateInput-CqFHtc9F.js} +12 -10
  9. package/{DatePicker-TkMCndrw.js → DatePicker-BmW3TO0X.js} +18 -15
  10. package/{Dropdown-jKk4TyOa.js → Dropdown-C-_zDFCe.js} +5 -3
  11. package/Flex-Rs-RvIcq.js +20 -0
  12. package/{Grid-DREMTVQI.js → Grid-BcPUrfRL.js} +3 -2
  13. package/{List-BjMIo577.js → List-YkH8gdMh.js} +5 -3
  14. package/Markdown-DeAW4y3P.js +571 -0
  15. package/MarkdownText-BdISjAsE.js +11 -0
  16. package/Number-GsGZMR5a.js +247 -0
  17. package/Password-B8QjtpUe.js +204 -0
  18. package/RadioGroup-Cd1_Zkkz.js +197 -0
  19. package/{RangeCalendar-u2vxIhna.js → RangeCalendar-9IJoFEXw.js} +10 -8
  20. package/{RangeDateInput-CopLdb6J.js → RangeDateInput-DrVR4T_z.js} +21 -19
  21. package/{RangeDatePicker-DXpV-B_G.js → RangeDatePicker-Cq_Tt6NE.js} +38 -35
  22. package/{Renderer-B6WmwKDv.js → Renderer-CWqudTUu.js} +4 -2
  23. package/Repeater-DE-DAylQ.js +124 -0
  24. package/Select-CCCPYQW6.js +238 -0
  25. package/{Tabs-C2qqi8xO.js → Tabs-BVgVVvnu.js} +4 -3
  26. package/TextArea-BlRaVCon.js +202 -0
  27. package/TextInput-KuHLSN2X.js +169 -0
  28. package/Toggle-D-bglMPv.js +166 -0
  29. package/abstract-calendar-JfbbRwFb.js +528 -0
  30. package/calendar-BgptByan.js +95 -0
  31. package/class-map-DrTVAYz_.js +26 -0
  32. package/date-BS1lA1xg.js +786 -0
  33. package/date-input-Dux0mFJw.js +266 -0
  34. package/directive-1yd1wdny.js +555 -0
  35. package/errors-6UKoJh8Y.js +108 -0
  36. package/index.js +2705 -1171
  37. package/index.umd.cjs +878 -2
  38. package/lib/components/Accordion.d.ts +2 -2
  39. package/lib/components/Alert.d.ts +2 -2
  40. package/lib/components/Button.d.ts +2 -2
  41. package/lib/components/Calendar.d.ts +2 -2
  42. package/lib/components/Checkbox.d.ts +2 -2
  43. package/lib/components/Currency.d.ts +2 -2
  44. package/lib/components/DateInput.d.ts +2 -2
  45. package/lib/components/DatePicker.d.ts +2 -2
  46. package/lib/components/Dropdown.d.ts +2 -2
  47. package/lib/components/Flex.d.ts +2 -2
  48. package/lib/components/Form.d.ts +5 -5
  49. package/lib/components/Grid.d.ts +2 -2
  50. package/lib/components/List.d.ts +2 -2
  51. package/lib/components/Markdown.d.ts +2 -2
  52. package/lib/components/MarkdownText.d.ts +2 -2
  53. package/lib/components/Number.d.ts +2 -2
  54. package/lib/components/Password.d.ts +2 -2
  55. package/lib/components/RadioGroup.d.ts +2 -2
  56. package/lib/components/RangeCalendar.d.ts +2 -2
  57. package/lib/components/RangeDateInput.d.ts +2 -2
  58. package/lib/components/RangeDatePicker.d.ts +2 -2
  59. package/lib/components/Renderer.d.ts +2 -2
  60. package/lib/components/Repeater.d.ts +2 -2
  61. package/lib/components/Select.d.ts +2 -2
  62. package/lib/components/Tabs.d.ts +2 -2
  63. package/lib/components/TextArea.d.ts +2 -2
  64. package/lib/components/TextInput.d.ts +2 -2
  65. package/lib/components/Toggle.d.ts +2 -2
  66. package/lib/widget.loaders.d.ts +2 -2
  67. package/list-DHX7bG4r.js +282 -0
  68. package/live-BfTBpQrp.js +24 -0
  69. package/markdown-text-BUv0K0WF.js +44 -0
  70. package/one-of-DifUsEYY.js +48 -0
  71. package/package.json +6 -6
  72. package/query-h1h36oxg.js +12 -0
  73. package/range-calendar-SAyiW3EF.js +326 -0
  74. package/range-date-input-8WtB1urD.js +507 -0
  75. package/repeat-BucBfSPF.js +79 -0
  76. package/state-DI9ZsB5W.js +7 -0
  77. package/style-map-C_0XzJlx.js +29 -0
  78. package/tabs-DzSCq_98.js +13 -0
  79. package/templates-DBGyvZtc.js +75 -0
  80. package/Accordion-Btp_b0xA.js +0 -59
  81. package/Alert-CBgIsMKO.js +0 -16
  82. package/Button-DN0G-MUb.js +0 -21
  83. package/Checkbox-ViM9MktI.js +0 -30
  84. package/Currency-C4QFWO7Y.js +0 -37
  85. package/DefaultListItemRenderer-lNc9Kk7x.js +0 -18
  86. package/Flex-gD893rrB.js +0 -19
  87. package/Markdown-Ck_88HOR.js +0 -47
  88. package/MarkdownText-kJVkmihW.js +0 -9
  89. package/Number-CnQ95aLO.js +0 -35
  90. package/Password-Bg97DYW3.js +0 -36
  91. package/RadioGroup-Dldom5ja.js +0 -33
  92. package/Repeater-BYgXVfbl.js +0 -111
  93. package/Select-BLUX_W91.js +0 -55
  94. package/TextArea-cw3Q2v97.js +0 -35
  95. package/TextInput-geLoAA0c.js +0 -32
  96. package/Toggle-a7L71GwR.js +0 -30
@@ -0,0 +1,326 @@
1
+ import { b as v, A as m, n as f, t as R } from "./directive-1yd1wdny.js";
2
+ import { r as g } from "./state-DI9ZsB5W.js";
3
+ import { e as p } from "./class-map-DrTVAYz_.js";
4
+ import { c as $ } from "./repeat-BucBfSPF.js";
5
+ import { i as d, b as A, a as b, g as M, m as P, c as _ } from "./date-BS1lA1xg.js";
6
+ import { c as w } from "./tabs-DzSCq_98.js";
7
+ import { A as k } from "./abstract-calendar-JfbbRwFb.js";
8
+ import "@golemui/gui-shared";
9
+ var V = Object.defineProperty, E = Object.getOwnPropertyDescriptor, h = (e, t, i, a) => {
10
+ for (var n = a > 1 ? void 0 : a ? E(t, i) : t, s = e.length - 1, r; s >= 0; s--)
11
+ (r = e[s]) && (n = (a ? r(t, i, n) : r(n)) || n);
12
+ return a && n && V(t, i, n), n;
13
+ };
14
+ let l = class extends k {
15
+ constructor() {
16
+ super(...arguments), this.value = [], this.focusDate = void 0, this.hidePills = !1, this.removePillAriaLabel = void 0, this._anchorDate = null, this._nextDate = null, this._isSelecting = !1, this._isStartVisible = !0, this._isEndVisible = !0, this._skipValueNavigation = !1;
17
+ }
18
+ createRenderRoot() {
19
+ return this;
20
+ }
21
+ connectedCallback() {
22
+ super.connectedCallback(), this.classList.add("gui-field");
23
+ }
24
+ willUpdate(e) {
25
+ if (e.has("value") && !e.has("focusDate")) {
26
+ if (this._skipValueNavigation)
27
+ this._skipValueNavigation = !1;
28
+ else if (this.value) {
29
+ const t = Array.isArray(this.value) ? this.value : [{ start: this.value }];
30
+ if (t.length > 0 && t[0].start) {
31
+ const i = new Date(t[0].start);
32
+ !isNaN(i.getTime()) && !d(i, this._currentDate, this.numberOfMonths ?? 1) && (this._currentDate = i);
33
+ }
34
+ }
35
+ }
36
+ if (e.has("focusDate") && this.focusDate) {
37
+ const t = new Date(this.focusDate);
38
+ isNaN(t.getTime()) || (d(t, this._currentDate, this.numberOfMonths ?? 1) || (this._currentDate = t), this.focusDate = void 0);
39
+ }
40
+ }
41
+ renderDay(e) {
42
+ const t = {
43
+ "gui-calendar__day-button": !0,
44
+ today: e.isToday,
45
+ "other-month": !e.isCurrentMonth,
46
+ "range-start": e.isRangeStart && !e.isOneDayRange,
47
+ "range-end": e.isRangeEnd && !e.isOneDayRange,
48
+ selected: e.isOneDayRange,
49
+ "in-range": e.isInRange,
50
+ "is-anchor": e.isAnchor,
51
+ "is-selecting": e.isSelecting,
52
+ disabled: e.isDisabled
53
+ };
54
+ return v`
55
+ <button
56
+ type="button"
57
+ role="gridcell"
58
+ class=${p(t)}
59
+ tabindex=${e.isFocusable ? 0 : -1}
60
+ ?disabled=${!e.isCurrentMonth || e.isDisabled}
61
+ data-date=${e.date.toISOString()}
62
+ @click=${(i) => this.selectDate(e, i)}
63
+ @mouseover=${() => this.onMouseOver(e)}
64
+ @focus=${() => this.onMouseOver(e)}
65
+ @keydown=${(i) => this.handleKeydown(i, e)}
66
+ aria-selected=${e.isRangeStart || e.isRangeEnd || e.isInRange ? "true" : "false"}
67
+ >
68
+ ${e.dayLabel}
69
+ </button>
70
+ `;
71
+ }
72
+ getDaysInMonth(e) {
73
+ const t = new Date(this._currentDate);
74
+ t.setDate(1), t.setMonth(t.getMonth() + e);
75
+ const i = this.generateDateGrid(e), a = t.getMonth();
76
+ let n = i.map((s) => {
77
+ const r = s.getMonth() === a, o = this.isDisabled(s), c = A(s), { isRangeStart: u, isRangeEnd: D, isInRange: y, isSelecting: O } = this.checkDateStatus(s), S = c || u, T = this._anchorDate ? b(s, this._anchorDate) : !1;
78
+ return {
79
+ date: s,
80
+ dayLabel: M(this.localeId, s),
81
+ isCurrentMonth: r,
82
+ isToday: c,
83
+ isRangeStart: u,
84
+ isRangeEnd: D,
85
+ isInRange: y,
86
+ isDisabled: o,
87
+ isOneDayRange: u && D,
88
+ isAnchor: T,
89
+ isFocusable: S,
90
+ isSelecting: O && r
91
+ };
92
+ });
93
+ for (let s = 0; s < 2; s++)
94
+ n.slice(-7).every((o) => !o.isCurrentMonth) && (n = n.slice(0, -7));
95
+ if (e === 0 && !n.some((s) => s.isFocusable)) {
96
+ const s = this.numberOfMonths ?? 1, r = d(/* @__PURE__ */ new Date(), this._currentDate, s), o = this.value?.some(
97
+ (c) => d(new Date(c.start), this._currentDate, s)
98
+ ) ?? !1;
99
+ if (!r && !o) {
100
+ const c = n.find((u) => u.isCurrentMonth && !u.isDisabled);
101
+ c && (c.isFocusable = !0);
102
+ }
103
+ }
104
+ return n;
105
+ }
106
+ checkDateStatus(e) {
107
+ let t = !1, i = !1, a = !1, n = !1;
108
+ if (this._isSelecting && this._nextDate && this._anchorDate) {
109
+ const s = this._nextDate.date, r = new Date(this._anchorDate);
110
+ s.getTime() > r.getTime() ? n = e.getTime() >= r.getTime() && e.getTime() <= s.getTime() : n = e.getTime() >= s.getTime() && e.getTime() <= r.getTime();
111
+ }
112
+ if (this.value && Array.isArray(this.value))
113
+ for (const s of this.value) {
114
+ const r = new Date(s.start);
115
+ if (b(e, r) && (t = !0, i = !s.end), s.end) {
116
+ const o = new Date(s.end);
117
+ b(e, o) && (i = !0);
118
+ const c = e.getTime(), u = r.getTime(), D = o.getTime();
119
+ c > u && c < D && (a = !0);
120
+ }
121
+ }
122
+ return { isRangeStart: t, isRangeEnd: i, isInRange: a, isSelecting: n };
123
+ }
124
+ selectDate(e, t = null) {
125
+ if (!e.isCurrentMonth || this.disabled || this.readOnly) return;
126
+ const i = e.date;
127
+ if (!this._anchorDate) {
128
+ this._isSelecting = !0, this._anchorDate = i;
129
+ return;
130
+ }
131
+ let a = this._anchorDate, n = i;
132
+ i < a && (a = i, n = this._anchorDate);
133
+ const s = this.calculateValidRanges(a, n), r = [...this.value || [], ...s];
134
+ this._skipValueNavigation = !0, this.value = P(r), this._isSelecting = !1, this._nextDate = null, this._anchorDate = null, this.dispatchEvent(
135
+ new CustomEvent("change", {
136
+ detail: { value: this.value },
137
+ bubbles: !0,
138
+ composed: !0
139
+ })
140
+ );
141
+ }
142
+ /**
143
+ * Calculates and returns an array of valid date ranges between the given start date and end date.
144
+ * A date range is considered valid if no dates within the range are disabled.
145
+ *
146
+ * @param {Date} startDate - The starting date for the range calculation.
147
+ * @param {Date} endDate - The ending date for the range calculation.
148
+ * @return {DateRange[]} An array of valid date ranges where each range defines consecutive, non-disabled dates.
149
+ */
150
+ calculateValidRanges(e, t) {
151
+ const i = [], a = new Date(e), n = new Date(t);
152
+ a.setHours(0, 0, 0, 0), n.setHours(0, 0, 0, 0);
153
+ let s = null;
154
+ for (; a <= n; ) {
155
+ if (!this.isDisabled(a))
156
+ s || (s = new Date(a));
157
+ else if (s) {
158
+ const o = new Date(a);
159
+ o.setDate(a.getDate() - 1), i.push(_(s, o)), s = null;
160
+ }
161
+ a.setDate(a.getDate() + 1);
162
+ }
163
+ return s && i.push(_(s, t)), i;
164
+ }
165
+ onMouseOver(e) {
166
+ this._isSelecting && (this._nextDate = e);
167
+ }
168
+ // --- Pills ---
169
+ updated() {
170
+ this.hidePills || this.setupObservers();
171
+ }
172
+ disconnectedCallback() {
173
+ super.disconnectedCallback(), this.disconnectObservers();
174
+ }
175
+ renderAboveCalendar() {
176
+ if (this.hidePills) return m;
177
+ const e = this.getSortedPills();
178
+ return e.length === 0 ? m : v`
179
+ <div
180
+ class=${p({
181
+ "gui-range-calendar__pills-wrapper": !0,
182
+ "gui-range-calendar--start-shadow": !this._isStartVisible,
183
+ "gui-range-calendar--end-shadow": !this._isEndVisible
184
+ })}
185
+ >
186
+ <div class="gui-range-calendar__pills" role="list">
187
+ <span class="gui-sentinel gui-sentinel__start"></span>
188
+ ${$(
189
+ e,
190
+ (t) => `${t.start}-${t.end ?? t.start}`,
191
+ (t, i) => this.renderPill(t, i)
192
+ )}
193
+ <span class="gui-sentinel gui-sentinel__end"></span>
194
+ </div>
195
+ </div>
196
+ `;
197
+ }
198
+ renderPill(e, t) {
199
+ const i = this.formatDateForDisplay(e.start), a = e.end ? this.formatDateForDisplay(e.end) : i, n = `${i} - ${a}`;
200
+ return v`
201
+ <div
202
+ class="gui-range-calendar__pill"
203
+ role="listitem"
204
+ tabindex="0"
205
+ aria-label="${this.removePillAriaLabel ?? "Remove date"} ${n}"
206
+ @click=${() => this.navigateToDate(e.start)}
207
+ @keydown=${(s) => this.handlePillKeydown(s, t)}
208
+ >
209
+ <span class="gui-range-calendar__pill-text">${n}</span>
210
+ <button
211
+ type="button"
212
+ class="gui-range-calendar__pill-remove"
213
+ tabindex="-1"
214
+ ?disabled=${this.disabled || this.readOnly}
215
+ @click=${(s) => {
216
+ s.stopPropagation(), this.removePill(t);
217
+ }}
218
+ >
219
+ <svg
220
+ xmlns="http://www.w3.org/2000/svg"
221
+ width="16"
222
+ height="16"
223
+ viewBox="0 0 256 256"
224
+ fill="currentColor"
225
+ aria-hidden="true"
226
+ >
227
+ <path
228
+ d="M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"
229
+ ></path>
230
+ </svg>
231
+ </button>
232
+ </div>
233
+ `;
234
+ }
235
+ formatDateForDisplay(e) {
236
+ const t = new Date(e);
237
+ return isNaN(t.getTime()) ? e : new Intl.DateTimeFormat(this.localeId ?? "en", {
238
+ year: "numeric",
239
+ month: "2-digit",
240
+ day: "2-digit"
241
+ }).format(t);
242
+ }
243
+ getSortedPills() {
244
+ return !this.value || !Array.isArray(this.value) ? [] : [...this.value].sort(
245
+ (e, t) => new Date(e.start).getTime() - new Date(t.start).getTime()
246
+ );
247
+ }
248
+ removePill(e) {
249
+ if (this.disabled || this.readOnly) return;
250
+ const t = this.getSortedPills();
251
+ t.splice(e, 1), this.value = [...t], this.dispatchEvent(
252
+ new CustomEvent("change", {
253
+ detail: { value: this.value },
254
+ bubbles: !0,
255
+ composed: !0
256
+ })
257
+ );
258
+ }
259
+ handlePillKeydown(e, t) {
260
+ if (e.key === "Delete" || e.key === "Backspace") {
261
+ e.preventDefault(), this.removePill(t);
262
+ return;
263
+ }
264
+ if (e.key === "Enter") {
265
+ e.preventDefault();
266
+ const i = this.getSortedPills();
267
+ i[t] && this.navigateToDate(i[t].start);
268
+ return;
269
+ }
270
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
271
+ e.preventDefault();
272
+ const i = this.querySelectorAll(
273
+ ".gui-range-calendar__pills .gui-range-calendar__pill"
274
+ ), a = e.key === "ArrowLeft" ? t - 1 : t + 1;
275
+ a >= 0 && a < i.length && i[a].focus();
276
+ }
277
+ }
278
+ navigateToDate(e) {
279
+ const t = new Date(e);
280
+ !isNaN(t.getTime()) && !d(t, this._currentDate, this.numberOfMonths ?? 1) && (this._currentDate = t);
281
+ }
282
+ setupObservers() {
283
+ const e = this.querySelector(".gui-sentinel__start"), t = this.querySelector(".gui-sentinel__end");
284
+ e && !this.startObserver && (this.startObserver = w(
285
+ e,
286
+ (i) => this._isStartVisible = i
287
+ )), t && !this.endObserver && (this.endObserver = w(
288
+ t,
289
+ (i) => this._isEndVisible = i
290
+ )), !e && this.startObserver && (this.startObserver.disconnect(), this.startObserver = void 0, this._isStartVisible = !0), !t && this.endObserver && (this.endObserver.disconnect(), this.endObserver = void 0, this._isEndVisible = !0);
291
+ }
292
+ disconnectObservers() {
293
+ this.startObserver?.disconnect(), this.endObserver?.disconnect(), this.startObserver = void 0, this.endObserver = void 0;
294
+ }
295
+ };
296
+ h([
297
+ f({ type: Array })
298
+ ], l.prototype, "value", 2);
299
+ h([
300
+ f({ type: String })
301
+ ], l.prototype, "focusDate", 2);
302
+ h([
303
+ f({ type: Boolean })
304
+ ], l.prototype, "hidePills", 2);
305
+ h([
306
+ f({ type: String })
307
+ ], l.prototype, "removePillAriaLabel", 2);
308
+ h([
309
+ g()
310
+ ], l.prototype, "_anchorDate", 2);
311
+ h([
312
+ g()
313
+ ], l.prototype, "_nextDate", 2);
314
+ h([
315
+ g()
316
+ ], l.prototype, "_isSelecting", 2);
317
+ h([
318
+ g()
319
+ ], l.prototype, "_isStartVisible", 2);
320
+ h([
321
+ g()
322
+ ], l.prototype, "_isEndVisible", 2);
323
+ l = h([
324
+ R("gui-range-calendar")
325
+ ], l);
326
+ typeof customElements < "u" && !customElements.get("gui-range-calendar") && customElements.define("gui-range-calendar", l);