@voidable/ui 0.10.0 → 0.12.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 (177) hide show
  1. package/dist/angular/index.d.ts +2 -2
  2. package/dist/angular/index.js +2 -1
  3. package/dist/base.d.ts +6 -0
  4. package/dist/base.js +2 -2
  5. package/dist/chunks/activation-B8aBarKd.js +4 -0
  6. package/dist/chunks/{base-BxmMM3B7.js → base-BGrS4eIl.js} +9 -0
  7. package/dist/chunks/carousel-C9u0bg5l.js +10 -0
  8. package/dist/chunks/choice-BTrsi7OW.js +16 -0
  9. package/dist/chunks/data-Baycjoo4.js +96 -0
  10. package/dist/chunks/fields-MEqz-olE.js +21 -0
  11. package/dist/chunks/{form-control-C0vH6gii.js → form-control-fL-Hhy91.js} +49 -48
  12. package/dist/chunks/{keyboard-CEhMSkws.js → keyboard-ChtDvhB_.js} +4 -23
  13. package/dist/chunks/{keyboard-activation-CV0m4hkn.js → keyboard-activation-BfEyoaMT.js} +4 -6
  14. package/dist/chunks/menu-CxRRgkJI.js +21 -0
  15. package/dist/chunks/{modal-CgGp_fCs.js → modal-Cz2-Ov76.js} +24 -16
  16. package/dist/chunks/nav-menu-Bx284Dk6.js +12 -0
  17. package/dist/chunks/{overlay-hLJ7IQHx.js → overlay-BuV-4Yvt.js} +76 -69
  18. package/dist/chunks/overlay-K1ilWC1p.js +4 -0
  19. package/dist/chunks/pickers-CjlFgNke.js +36 -0
  20. package/dist/chunks/{projection-SnR79EHI.js → projection-oPe6ipjL.js} +1 -1
  21. package/dist/chunks/table-BBpqwWEi.js +4 -0
  22. package/dist/chunks/tabs-Buf3EBWq.js +10 -0
  23. package/dist/components/accordion.d.ts +7 -0
  24. package/dist/components/accordion.js +23 -15
  25. package/dist/components/action-input.d.ts +2 -1
  26. package/dist/components/action-input.js +60 -56
  27. package/dist/components/alert.d.ts +11 -0
  28. package/dist/components/alert.js +10 -3
  29. package/dist/components/avatar.js +2 -2
  30. package/dist/components/badge.d.ts +8 -2
  31. package/dist/components/badge.js +1 -4
  32. package/dist/components/banner.d.ts +9 -0
  33. package/dist/components/banner.js +10 -3
  34. package/dist/components/bar-chart.d.ts +21 -7
  35. package/dist/components/bar-chart.js +68 -45
  36. package/dist/components/breadcrumbs.d.ts +2 -0
  37. package/dist/components/breadcrumbs.js +16 -12
  38. package/dist/components/button.d.ts +7 -0
  39. package/dist/components/button.js +24 -17
  40. package/dist/components/calendar.d.ts +85 -12
  41. package/dist/components/calendar.js +263 -120
  42. package/dist/components/card.js +1 -1
  43. package/dist/components/carousel.d.ts +22 -0
  44. package/dist/components/carousel.js +66 -37
  45. package/dist/components/charts/data.d.ts +72 -0
  46. package/dist/components/checkbox-group.js +23 -22
  47. package/dist/components/checkbox.d.ts +7 -0
  48. package/dist/components/checkbox.js +30 -25
  49. package/dist/components/collapsible.d.ts +7 -0
  50. package/dist/components/collapsible.js +20 -12
  51. package/dist/components/color-picker.js +29 -28
  52. package/dist/components/combobox.d.ts +13 -1
  53. package/dist/components/combobox.js +55 -42
  54. package/dist/components/compose-input.d.ts +9 -1
  55. package/dist/components/compose-input.js +29 -17
  56. package/dist/components/dialog.js +1 -1
  57. package/dist/components/divider.js +2 -2
  58. package/dist/components/donut-chart.d.ts +22 -6
  59. package/dist/components/donut-chart.js +97 -70
  60. package/dist/components/drawer.js +1 -1
  61. package/dist/components/dropdown-menu.d.ts +22 -0
  62. package/dist/components/dropdown-menu.js +55 -40
  63. package/dist/components/editable.d.ts +11 -1
  64. package/dist/components/editable.js +36 -23
  65. package/dist/components/error-fallback.d.ts +4 -2
  66. package/dist/components/error-fallback.js +35 -29
  67. package/dist/components/field.js +2 -2
  68. package/dist/components/file-upload.d.ts +29 -5
  69. package/dist/components/file-upload.js +84 -28
  70. package/dist/components/gauge.d.ts +32 -8
  71. package/dist/components/gauge.js +206 -133
  72. package/dist/components/hamburger.d.ts +19 -1
  73. package/dist/components/hamburger.js +45 -25
  74. package/dist/components/hover-card.d.ts +7 -0
  75. package/dist/components/hover-card.js +23 -15
  76. package/dist/components/indicator.js +16 -15
  77. package/dist/components/input.js +3 -3
  78. package/dist/components/line-chart.d.ts +22 -7
  79. package/dist/components/line-chart.js +80 -57
  80. package/dist/components/list.js +1 -1
  81. package/dist/components/menu.d.ts +25 -0
  82. package/dist/components/menu.js +56 -34
  83. package/dist/components/multiselect.d.ts +17 -1
  84. package/dist/components/multiselect.js +97 -75
  85. package/dist/components/nav-bar.d.ts +9 -0
  86. package/dist/components/nav-bar.js +16 -3
  87. package/dist/components/nav-menu.d.ts +9 -0
  88. package/dist/components/nav-menu.js +31 -24
  89. package/dist/components/number-input.d.ts +15 -1
  90. package/dist/components/number-input.js +72 -38
  91. package/dist/components/pagination.js +26 -25
  92. package/dist/components/panel.js +1 -1
  93. package/dist/components/pin-input.d.ts +11 -0
  94. package/dist/components/pin-input.js +47 -33
  95. package/dist/components/popover.d.ts +7 -0
  96. package/dist/components/popover.js +22 -14
  97. package/dist/components/progress.js +2 -2
  98. package/dist/components/radio-group.js +3 -3
  99. package/dist/components/radio.d.ts +10 -1
  100. package/dist/components/radio.js +38 -33
  101. package/dist/components/scroll-area.js +2 -2
  102. package/dist/components/segmented-control.d.ts +14 -0
  103. package/dist/components/segmented-control.js +41 -29
  104. package/dist/components/select.js +2 -2
  105. package/dist/components/sidebar.d.ts +1 -0
  106. package/dist/components/sidebar.js +15 -11
  107. package/dist/components/skeleton.js +1 -1
  108. package/dist/components/slider.js +3 -3
  109. package/dist/components/spinner.d.ts +5 -3
  110. package/dist/components/spinner.js +22 -15
  111. package/dist/components/stat.d.ts +13 -1
  112. package/dist/components/stat.js +28 -20
  113. package/dist/components/status-dot.d.ts +2 -2
  114. package/dist/components/status-dot.js +13 -15
  115. package/dist/components/stepper.d.ts +2 -0
  116. package/dist/components/stepper.js +21 -14
  117. package/dist/components/switch.d.ts +7 -0
  118. package/dist/components/switch.js +25 -17
  119. package/dist/components/table.d.ts +81 -1
  120. package/dist/components/table.js +571 -69
  121. package/dist/components/tabs.d.ts +11 -0
  122. package/dist/components/tabs.js +43 -34
  123. package/dist/components/tag.js +13 -12
  124. package/dist/components/tags-input.d.ts +10 -1
  125. package/dist/components/tags-input.js +43 -31
  126. package/dist/components/textarea.js +3 -3
  127. package/dist/components/toast.d.ts +2 -0
  128. package/dist/components/toast.js +36 -29
  129. package/dist/components/toggle-group.d.ts +8 -0
  130. package/dist/components/toggle-group.js +25 -18
  131. package/dist/components/toggle.d.ts +7 -0
  132. package/dist/components/toggle.js +24 -16
  133. package/dist/components/tooltip.d.ts +7 -0
  134. package/dist/components/tooltip.js +21 -13
  135. package/dist/components.json +108 -84
  136. package/dist/custom-elements.json +4520 -236
  137. package/dist/dev/rules.d.ts +0 -1
  138. package/dist/dev/types.d.ts +5 -1
  139. package/dist/dev.js +298 -122
  140. package/dist/index.d.ts +4 -0
  141. package/dist/index.js +69 -67
  142. package/dist/keyboard-activation.d.ts +9 -9
  143. package/dist/keyboard.d.ts +2 -10
  144. package/dist/keymaps/activation.d.ts +8 -0
  145. package/dist/keymaps/carousel.d.ts +9 -0
  146. package/dist/keymaps/choice.d.ts +21 -0
  147. package/dist/keymaps/fields.d.ts +31 -0
  148. package/dist/keymaps/index.d.ts +2 -0
  149. package/dist/keymaps/menu.d.ts +36 -0
  150. package/dist/keymaps/nav-menu.d.ts +11 -0
  151. package/dist/keymaps/overlay.d.ts +4 -0
  152. package/dist/keymaps/pickers.d.ts +36 -0
  153. package/dist/keymaps/table.d.ts +8 -0
  154. package/dist/keymaps/tabs.d.ts +7 -0
  155. package/dist/keymaps.js +51 -0
  156. package/dist/keys.d.ts +46 -0
  157. package/dist/keys.js +57 -0
  158. package/dist/llms.txt +11 -3
  159. package/dist/messages/ar.d.ts +1 -0
  160. package/dist/messages/ar.js +130 -0
  161. package/dist/messages/fr.d.ts +1 -0
  162. package/dist/messages/fr.js +109 -0
  163. package/dist/messages.d.ts +213 -0
  164. package/dist/messages.js +190 -0
  165. package/dist/modal.d.ts +7 -0
  166. package/dist/reference.md +885 -60
  167. package/dist/testing/index.d.ts +46 -0
  168. package/dist/testing.js +79 -0
  169. package/dist/types/elements.d.ts +100 -84
  170. package/dist/types/react.d.ts +7 -3
  171. package/dist/types/solid.d.ts +7 -3
  172. package/dist/types/solid2.d.ts +4 -0
  173. package/dist/types/svelte.d.ts +7 -3
  174. package/dist/types/vue.d.ts +7 -3
  175. package/dist/vscode.html-custom-data.json +478 -38
  176. package/dist/web-types.json +1001 -111
  177. package/package.json +22 -2
@@ -1,15 +1,18 @@
1
- import { t as e } from "../chunks/base-BxmMM3B7.js";
1
+ import { t as e } from "../chunks/base-BGrS4eIl.js";
2
2
  import { t } from "../chunks/decorate-CaYbmmmm.js";
3
- import { t as n } from "../chunks/form-control-C0vH6gii.js";
4
- import { r } from "../chunks/projection-SnR79EHI.js";
5
- import { o as i, r as a } from "../chunks/keyboard-CEhMSkws.js";
6
- import { t as o } from "../chunks/overlay-hLJ7IQHx.js";
7
- import { html as s, nothing as c } from "lit";
8
- import { property as l } from "lit/decorators.js";
9
- import { live as u } from "lit/directives/live.js";
3
+ import { actionFor as n, keysConverter as r } from "../keys.js";
4
+ import { localeOf as i, msg as a, nameHost as o } from "../messages.js";
5
+ import { t as s } from "../chunks/form-control-fL-Hhy91.js";
6
+ import { r as c } from "../chunks/projection-oPe6ipjL.js";
7
+ import { i as l } from "../chunks/keyboard-ChtDvhB_.js";
8
+ import { r as u, t as d } from "../chunks/pickers-CjlFgNke.js";
9
+ import { t as f } from "../chunks/overlay-BuV-4Yvt.js";
10
+ import { html as p, nothing as m } from "lit";
11
+ import { property as h } from "lit/decorators.js";
12
+ import { live as g } from "lit/directives/live.js";
10
13
  //#region src/components/calendar.ts
11
- r();
12
- function d(e) {
14
+ c();
15
+ function _(e) {
13
16
  let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
14
17
  return t ? [
15
18
  Number(t[1]),
@@ -17,28 +20,72 @@ function d(e) {
17
20
  Number(t[3])
18
21
  ] : null;
19
22
  }
20
- function f(e, t, n) {
23
+ function v(e, t, n) {
21
24
  return `${String(e).padStart(4, "0")}-${String(t + 1).padStart(2, "0")}-${String(n).padStart(2, "0")}`;
22
25
  }
23
- function p() {
26
+ function y() {
24
27
  let e = /* @__PURE__ */ new Date();
25
- return f(e.getFullYear(), e.getMonth(), e.getDate());
28
+ return v(e.getFullYear(), e.getMonth(), e.getDate());
26
29
  }
27
- function m(e, t) {
30
+ function b(e, t) {
28
31
  return new Date(e, t + 1, 0).getDate();
29
32
  }
30
- function h(e, t, n) {
33
+ function x(e, t, n) {
31
34
  return t && e < t ? t : n && e > n ? n : e;
32
35
  }
33
- function g(e, t) {
34
- let n = d(e);
36
+ function S(e, t) {
37
+ let n = _(e);
35
38
  if (!n) return e;
36
39
  let [r, i, a] = n;
37
40
  return t.replace("YYYY", String(r).padStart(4, "0")).replace("MM", String(i + 1).padStart(2, "0")).replace("DD", String(a).padStart(2, "0"));
38
41
  }
39
- var _ = class extends n(e) {
42
+ function C(e, t) {
43
+ let n = e.trim(), r = _(n), i = [], a = "";
44
+ for (let e of t.split(/(YYYY|MM|DD)/)) e === "YYYY" ? (i.push("y"), a += "(\\d{4})") : e === "MM" ? (i.push("m"), a += "(\\d{1,2})") : e === "DD" ? (i.push("d"), a += "(\\d{1,2})") : a += e.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&").replace(/\s+/g, "\\s*");
45
+ let o, s, c, l = r ? null : RegExp(`^${a}$`).exec(n);
46
+ if (r) [o, s, c] = [
47
+ r[0],
48
+ r[1] + 1,
49
+ r[2]
50
+ ];
51
+ else if (l && i.length === 3 && new Set(i).size === 3) {
52
+ let e = (e) => Number(l[i.indexOf(e) + 1]);
53
+ [o, s, c] = [
54
+ e("y"),
55
+ e("m"),
56
+ e("d")
57
+ ];
58
+ } else return null;
59
+ return s < 1 || s > 12 || c < 1 || c > b(o, s - 1) || o < 100 ? null : v(o, s - 1, c);
60
+ }
61
+ function w(e, t) {
62
+ if (t !== null && Number.isFinite(t)) return (Math.trunc(t) % 7 + 7) % 7;
63
+ try {
64
+ let t = new Intl.Locale(e), n = typeof t.getWeekInfo == "function" ? t.getWeekInfo() : t.weekInfo;
65
+ if (n && Number.isInteger(n.firstDay)) return n.firstDay % 7;
66
+ } catch {}
67
+ return 0;
68
+ }
69
+ function T(e, t) {
70
+ try {
71
+ return new Intl.DateTimeFormat(e, {
72
+ ...t,
73
+ calendar: "gregory"
74
+ });
75
+ } catch {
76
+ return new Intl.DateTimeFormat("en-US", t);
77
+ }
78
+ }
79
+ function E(e) {
80
+ try {
81
+ return new Intl.NumberFormat(e, { useGrouping: !1 });
82
+ } catch {
83
+ return new Intl.NumberFormat("en-US", { useGrouping: !1 });
84
+ }
85
+ }
86
+ var D = class extends s(e) {
40
87
  constructor(...e) {
41
- super(...e), this.value = "", this.min = "", this.max = "", this.disabled = !1, this.size = "md", this.locale = "en-US", this.firstDay = 0, this._viewYear = 0, this._viewMonth = 0, this._view = "days", this._focusDate = "", this._yearsPageStart = 0, this._didInit = !1, this._prevMonth = () => {
88
+ super(...e), this.keys = null, this.value = "", this.min = "", this.max = "", this.disabled = !1, this.size = "md", this.locale = "", this.firstDay = null, this._viewYear = 0, this._viewMonth = 0, this._view = "days", this._focusDate = "", this._yearsPageStart = 0, this._didInit = !1, this._prevMonth = () => {
42
89
  this._viewMonth === 0 ? (this._viewMonth = 11, this._viewYear--) : this._viewMonth--, this._syncFocusToView(), this.requestUpdate();
43
90
  }, this._nextMonth = () => {
44
91
  this._viewMonth === 11 ? (this._viewMonth = 0, this._viewYear++) : this._viewMonth++, this._syncFocusToView(), this.requestUpdate();
@@ -58,80 +105,96 @@ var _ = class extends n(e) {
58
105
  if (this.disabled) return;
59
106
  let t = e.target.getAttribute("data-date");
60
107
  if (!t) return;
61
- let n = d(t);
62
- if (!n) return;
63
- let [r, i] = n, o = n[2], s = !0, c = null;
64
- switch (e.key) {
65
- case a(this).prev:
108
+ let r = _(t);
109
+ if (!r) return;
110
+ let [i, a] = r, o = r[2], s = !0, c = null, l = n(this, e);
111
+ switch (l) {
112
+ case "previousDay":
66
113
  o--;
67
114
  break;
68
- case a(this).next:
115
+ case "nextDay":
69
116
  o++;
70
117
  break;
71
- case "ArrowUp":
118
+ case "previousWeek":
72
119
  o -= 7;
73
120
  break;
74
- case "ArrowDown":
121
+ case "nextWeek":
75
122
  o += 7;
76
123
  break;
77
- case "Home":
78
- o -= (new Date(r, i, o).getDay() - this.firstDay + 7) % 7;
124
+ case "startOfWeek":
125
+ o -= (new Date(i, a, o).getDay() - this._week + 7) % 7;
79
126
  break;
80
- case "End":
81
- o += 6 - (new Date(r, i, o).getDay() - this.firstDay + 7) % 7;
127
+ case "endOfWeek":
128
+ o += 6 - (new Date(i, a, o).getDay() - this._week + 7) % 7;
82
129
  break;
83
- case "PageUp":
84
- case "PageDown": {
85
- let t = e.key === "PageUp" ? -1 : 1, n = e.shiftKey ? new Date(r + t, i, 1) : new Date(r, i + t, 1);
86
- o = Math.min(o, m(n.getFullYear(), n.getMonth())), c = n;
130
+ case "previousMonth":
131
+ case "nextMonth":
132
+ case "previousYear":
133
+ case "nextYear": {
134
+ let e = l === "previousMonth" || l === "previousYear" ? -1 : 1, t = l.endsWith("Year") ? new Date(i + e, a, 1) : new Date(i, a + e, 1);
135
+ o = Math.min(o, b(t.getFullYear(), t.getMonth())), c = t;
87
136
  break;
88
137
  }
89
- case "Enter":
90
- case " ":
138
+ case "activate":
91
139
  this._selectDate(t), e.preventDefault();
92
140
  return;
93
141
  default: s = !1;
94
142
  }
95
143
  if (!s) return;
96
144
  e.preventDefault();
97
- let l = c ? new Date(c.getFullYear(), c.getMonth(), o) : new Date(r, i, o), u = h(f(l.getFullYear(), l.getMonth(), l.getDate()), this.min || void 0, this.max || void 0);
98
- this._focusDate = u;
99
- let p = d(u);
100
- p && (this._viewYear = p[0], this._viewMonth = p[1]), this.requestUpdate(), this.updateComplete.then(() => {
101
- this.querySelector(`[data-date="${u}"]`)?.focus();
145
+ let u = c ? new Date(c.getFullYear(), c.getMonth(), o) : new Date(i, a, o), d = x(v(u.getFullYear(), u.getMonth(), u.getDate()), this.min || void 0, this.max || void 0);
146
+ this._focusDate = d;
147
+ let f = _(d);
148
+ f && (this._viewYear = f[0], this._viewMonth = f[1]), this.requestUpdate(), this.updateComplete.then(() => {
149
+ this.querySelector(`[data-date="${d}"]`)?.focus();
102
150
  });
103
151
  };
104
152
  }
153
+ static {
154
+ this.keyMap = d;
155
+ }
156
+ get _locale() {
157
+ return i(this, this.locale);
158
+ }
159
+ get _week() {
160
+ return w(this._locale, this.firstDay);
161
+ }
105
162
  connectedCallback() {
106
- super.connectedCallback(), this.setHostAttribute("role", "group"), this.setHostAttribute("aria-label", "Calendar"), this._didInit || (this._didInit = !0, this._initView());
163
+ super.connectedCallback(), this.setHostAttribute("role", "group"), this._name(), this._didInit || (this._didInit = !0, this._initView());
164
+ }
165
+ _name() {
166
+ o(this, a(this, "calendar.label"), (e, t) => this.setHostAttribute(e, t));
107
167
  }
108
168
  updated(e) {
109
- super.updated(e), e.has("value") && this._syncViewToValue();
169
+ this._name(), super.updated(e), e.has("value") && this._syncViewToValue();
110
170
  }
111
171
  _initView() {
112
- let e = d(this.value);
172
+ let e = _(this.value);
113
173
  if (e) this._viewYear = e[0], this._viewMonth = e[1], this._focusDate = this.value;
114
174
  else {
115
175
  let e = /* @__PURE__ */ new Date();
116
- this._viewYear = e.getFullYear(), this._viewMonth = e.getMonth(), this._focusDate = p();
176
+ this._viewYear = e.getFullYear(), this._viewMonth = e.getMonth(), this._focusDate = y();
117
177
  }
118
178
  this._yearsPageStart = this._viewYear - this._viewYear % 12;
119
179
  }
120
180
  _syncViewToValue() {
121
- let e = d(this.value);
181
+ let e = _(this.value);
122
182
  e && (this._viewYear = e[0], this._viewMonth = e[1], this._focusDate = this.value, this._yearsPageStart = this._viewYear - this._viewYear % 12, this.requestUpdate());
123
183
  }
124
184
  render() {
125
185
  return this._view === "years" ? this._renderYears() : this._view === "months" ? this._renderMonths() : this._renderDays();
126
186
  }
127
187
  _renderDays() {
128
- let e = this._getDayNames(), t = this._buildDayCells(), n = Array.from({ length: t.length / 7 }, (e, n) => t.slice(n * 7, n * 7 + 7)), r = this._getMonthName(this._viewMonth);
129
- return s`
188
+ let e = this._getDayNames(), t = this._buildDayCells(), n = Array.from({ length: t.length / 7 }, (e, n) => t.slice(n * 7, n * 7 + 7)), r = E(this._locale), i = T(this._locale, { dateStyle: "full" }), o = T(this._locale, {
189
+ month: "long",
190
+ year: "numeric"
191
+ }).format(new Date(this._viewYear, this._viewMonth, 1));
192
+ return p`
130
193
  <div class="void-calendar-header">
131
194
  <button
132
195
  type="button"
133
196
  class="void-calendar-nav"
134
- aria-label="Previous month"
197
+ aria-label=${a(this, "calendar.previousMonth")}
135
198
  ?disabled=${this.disabled}
136
199
  @click=${this._prevMonth}
137
200
  >
@@ -140,41 +203,41 @@ var _ = class extends n(e) {
140
203
  <button
141
204
  type="button"
142
205
  class="void-calendar-title"
143
- aria-label="Switch to month picker"
206
+ aria-label=${a(this, "calendar.chooseMonth")}
144
207
  ?disabled=${this.disabled}
145
208
  @click=${this._showMonths}
146
- >${r} ${this._viewYear}</button>
209
+ >${o}</button>
147
210
  <button
148
211
  type="button"
149
212
  class="void-calendar-nav"
150
- aria-label="Next month"
213
+ aria-label=${a(this, "calendar.nextMonth")}
151
214
  ?disabled=${this.disabled}
152
215
  @click=${this._nextMonth}
153
216
  >
154
217
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="var(--void-icon-stroke-width)" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 18 15 12 9 6"></polyline></svg>
155
218
  </button>
156
219
  </div>
157
- <div class="void-calendar-grid" role="grid" aria-label="${r} ${this._viewYear}" @keydown=${this._onDayKeydown}>
220
+ <div class="void-calendar-grid" role="grid" aria-label="${o}" @keydown=${this._onDayKeydown}>
158
221
  <div class="void-calendar-weekdays" role="row">
159
- ${e.map((e) => s`<div class="void-calendar-weekday" role="columnheader" aria-label=${e.long}>${e.short}</div>`)}
222
+ ${e.map((e) => p`<div class="void-calendar-weekday" role="columnheader" aria-label=${e.long}>${e.short}</div>`)}
160
223
  </div>
161
224
  <div class="void-calendar-days" role="rowgroup">
162
- ${n.map((e) => s`
225
+ ${n.map((e) => p`
163
226
  <div class="void-calendar-week" role="row">
164
227
  ${e.map((e) => {
165
- let t = e.iso === this.value, n = e.iso === p(), r = this.disabled || e.disabled;
166
- return s`
228
+ let t = e.iso === this.value, n = e.iso === y(), a = this.disabled || e.disabled;
229
+ return p`
167
230
  <div class="void-calendar-cell" role="gridcell" aria-selected=${t ? "true" : "false"}>
168
231
  <button
169
232
  type="button"
170
233
  class="void-calendar-day${t ? " selected" : ""}${n ? " today" : ""}${e.outside ? " outside" : ""}"
171
- ?disabled=${r}
172
- aria-label=${this._formatFullDate(e.iso)}
173
- aria-current=${n ? "date" : c}
234
+ ?disabled=${a}
235
+ aria-label=${this._formatFullDate(e.iso, i)}
236
+ aria-current=${n ? "date" : m}
174
237
  tabindex=${e.iso === this._focusDate ? "0" : "-1"}
175
238
  data-date=${e.iso}
176
239
  @click=${() => this._selectDate(e.iso)}
177
- >${e.day}</button>
240
+ >${r.format(e.day)}</button>
178
241
  </div>
179
242
  `;
180
243
  })}
@@ -184,19 +247,19 @@ var _ = class extends n(e) {
184
247
  </div>
185
248
  `;
186
249
  }
187
- _formatFullDate(e) {
188
- let t = d(e);
189
- if (!t) return e;
250
+ _formatFullDate(e, t) {
251
+ let n = _(e);
252
+ if (!n) return e;
190
253
  try {
191
- return new Intl.DateTimeFormat(this.locale, { dateStyle: "full" }).format(new Date(t[0], t[1], t[2]));
254
+ return t.format(new Date(n[0], n[1], n[2]));
192
255
  } catch {
193
256
  return e;
194
257
  }
195
258
  }
196
259
  _getDayNames() {
197
- let e = new Intl.DateTimeFormat(this.locale, { weekday: "short" }), t = new Intl.DateTimeFormat(this.locale, { weekday: "long" }), n = [];
260
+ let e = T(this._locale, { weekday: "short" }), t = T(this._locale, { weekday: "long" }), n = [];
198
261
  for (let r = 0; r < 7; r++) {
199
- let i = new Date(2024, 0, 7 + (this.firstDay + r) % 7);
262
+ let i = new Date(2024, 0, 7 + (this._week + r) % 7);
200
263
  n.push({
201
264
  short: e.format(i),
202
265
  long: t.format(i)
@@ -204,13 +267,10 @@ var _ = class extends n(e) {
204
267
  }
205
268
  return n;
206
269
  }
207
- _getMonthName(e) {
208
- return new Intl.DateTimeFormat(this.locale, { month: "long" }).format(new Date(2024, e, 1));
209
- }
210
270
  _buildDayCells() {
211
- let e = this._viewYear, t = this._viewMonth, n = m(e, t), r = (new Date(e, t, 1).getDay() - this.firstDay + 7) % 7, i = [], a = t === 0 ? 11 : t - 1, o = t === 0 ? e - 1 : e, s = m(o, a);
271
+ let e = this._viewYear, t = this._viewMonth, n = b(e, t), r = (new Date(e, t, 1).getDay() - this._week + 7) % 7, i = [], a = t === 0 ? 11 : t - 1, o = t === 0 ? e - 1 : e, s = b(o, a);
212
272
  for (let e = r - 1; e >= 0; e--) {
213
- let t = s - e, n = f(o, a, t);
273
+ let t = s - e, n = v(o, a, t);
214
274
  i.push({
215
275
  day: t,
216
276
  iso: n,
@@ -219,7 +279,7 @@ var _ = class extends n(e) {
219
279
  });
220
280
  }
221
281
  for (let r = 1; r <= n; r++) {
222
- let n = f(e, t, r);
282
+ let n = v(e, t, r);
223
283
  i.push({
224
284
  day: r,
225
285
  iso: n,
@@ -229,7 +289,7 @@ var _ = class extends n(e) {
229
289
  }
230
290
  let c = t === 11 ? 0 : t + 1, l = t === 11 ? e + 1 : e, u = 42 - i.length;
231
291
  for (let e = 1; e <= u; e++) {
232
- let t = f(l, c, e);
292
+ let t = v(l, c, e);
233
293
  i.push({
234
294
  day: e,
235
295
  iso: t,
@@ -243,16 +303,16 @@ var _ = class extends n(e) {
243
303
  return !!(this.min && e < this.min || this.max && e > this.max);
244
304
  }
245
305
  _renderMonths() {
246
- let e = new Intl.DateTimeFormat(this.locale, { month: "short" }), t = Array.from({ length: 12 }, (t, n) => ({
306
+ let e = T(this._locale, { month: "short" }), t = Array.from({ length: 12 }, (t, n) => ({
247
307
  index: n,
248
308
  name: e.format(new Date(2024, n, 1))
249
309
  }));
250
- return s`
310
+ return p`
251
311
  <div class="void-calendar-header">
252
312
  <button
253
313
  type="button"
254
314
  class="void-calendar-nav"
255
- aria-label="Previous year"
315
+ aria-label=${a(this, "calendar.previousYear")}
256
316
  ?disabled=${this.disabled}
257
317
  @click=${this._prevYear}
258
318
  >
@@ -261,14 +321,14 @@ var _ = class extends n(e) {
261
321
  <button
262
322
  type="button"
263
323
  class="void-calendar-title"
264
- aria-label="Switch to year picker"
324
+ aria-label=${a(this, "calendar.chooseYear")}
265
325
  ?disabled=${this.disabled}
266
326
  @click=${this._showYears}
267
- >${this._viewYear}</button>
327
+ >${E(this._locale).format(this._viewYear)}</button>
268
328
  <button
269
329
  type="button"
270
330
  class="void-calendar-nav"
271
- aria-label="Next year"
331
+ aria-label=${a(this, "calendar.nextYear")}
272
332
  ?disabled=${this.disabled}
273
333
  @click=${this._nextYear}
274
334
  >
@@ -276,7 +336,7 @@ var _ = class extends n(e) {
276
336
  </button>
277
337
  </div>
278
338
  <div class="void-calendar-months">
279
- ${t.map((e) => s`
339
+ ${t.map((e) => p`
280
340
  <button
281
341
  type="button"
282
342
  class="void-calendar-month${e.index === this._viewMonth && this._viewYear === (/* @__PURE__ */ new Date()).getFullYear() ? " current" : ""}"
@@ -289,22 +349,22 @@ var _ = class extends n(e) {
289
349
  }
290
350
  _renderYears() {
291
351
  let e = this._yearsPageStart, t = Array.from({ length: 12 }, (t, n) => e + n), n = (/* @__PURE__ */ new Date()).getFullYear();
292
- return s`
352
+ return p`
293
353
  <div class="void-calendar-header">
294
354
  <button
295
355
  type="button"
296
356
  class="void-calendar-nav"
297
- aria-label="Previous years"
357
+ aria-label=${a(this, "calendar.previousYears")}
298
358
  ?disabled=${this.disabled}
299
359
  @click=${this._prevYearsPage}
300
360
  >
301
361
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="var(--void-icon-stroke-width)" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 18 9 12 15 6"></polyline></svg>
302
362
  </button>
303
- <span class="void-calendar-title void-calendar-title--static">${e} – ${e + 11}</span>
363
+ <span class="void-calendar-title void-calendar-title--static">${E(this._locale).format(e)} – ${E(this._locale).format(e + 11)}</span>
304
364
  <button
305
365
  type="button"
306
366
  class="void-calendar-nav"
307
- aria-label="Next years"
367
+ aria-label=${a(this, "calendar.nextYears")}
308
368
  ?disabled=${this.disabled}
309
369
  @click=${this._nextYearsPage}
310
370
  >
@@ -312,13 +372,13 @@ var _ = class extends n(e) {
312
372
  </button>
313
373
  </div>
314
374
  <div class="void-calendar-years">
315
- ${t.map((e) => s`
375
+ ${t.map((e) => p`
316
376
  <button
317
377
  type="button"
318
378
  class="void-calendar-year${e === n ? " current" : ""}"
319
379
  ?disabled=${this.disabled}
320
380
  @click=${() => this._pickYear(e)}
321
- >${e}</button>
381
+ >${E(this._locale).format(e)}</button>
322
382
  `)}
323
383
  </div>
324
384
  `;
@@ -327,12 +387,12 @@ var _ = class extends n(e) {
327
387
  this._viewMonth = e, this._view = "days", this._syncFocusToView(), this.requestUpdate();
328
388
  }
329
389
  _syncFocusToView() {
330
- let e = d(this._focusDate) ?? [
390
+ let e = _(this._focusDate) ?? [
331
391
  this._viewYear,
332
392
  this._viewMonth,
333
393
  1
334
- ], t = Math.min(e[2], m(this._viewYear, this._viewMonth));
335
- this._focusDate = h(f(this._viewYear, this._viewMonth, t), this.min || void 0, this.max || void 0);
394
+ ], t = Math.min(e[2], b(this._viewYear, this._viewMonth));
395
+ this._focusDate = x(v(this._viewYear, this._viewMonth, t), this.min || void 0, this.max || void 0);
336
396
  }
337
397
  _pickYear(e) {
338
398
  this._viewYear = e, this._yearsPageStart = e - e % 12, this._view = "months", this.requestUpdate();
@@ -340,7 +400,7 @@ var _ = class extends n(e) {
340
400
  _selectDate(e) {
341
401
  if (this.disabled || this._isOutOfRange(e)) return;
342
402
  this.value = e, this._focusDate = e;
343
- let t = d(e);
403
+ let t = _(e);
344
404
  this._viewYear = t[0], this._viewMonth = t[1], this._view = "days", this.requestUpdate(), this.dispatchEvent(new CustomEvent("void-change", {
345
405
  bubbles: !0,
346
406
  composed: !0,
@@ -351,22 +411,25 @@ var _ = class extends n(e) {
351
411
  }));
352
412
  }
353
413
  };
354
- t([l({
414
+ t([h({
415
+ attribute: "keys",
416
+ converter: r
417
+ })], D.prototype, "keys", void 0), t([h({
355
418
  type: String,
356
419
  reflect: !0
357
- })], _.prototype, "value", void 0), t([l({ type: String })], _.prototype, "min", void 0), t([l({ type: String })], _.prototype, "max", void 0), t([l({
420
+ })], D.prototype, "value", void 0), t([h({ type: String })], D.prototype, "min", void 0), t([h({ type: String })], D.prototype, "max", void 0), t([h({
358
421
  type: Boolean,
359
422
  reflect: !0
360
- })], _.prototype, "disabled", void 0), t([l({
423
+ })], D.prototype, "disabled", void 0), t([h({
361
424
  type: String,
362
425
  reflect: !0
363
- })], _.prototype, "size", void 0), t([l({ type: String })], _.prototype, "locale", void 0), t([l({
426
+ })], D.prototype, "size", void 0), t([h({ type: String })], D.prototype, "locale", void 0), t([h({
364
427
  attribute: "first-day",
365
428
  type: Number
366
- })], _.prototype, "firstDay", void 0), customElements.get("void-calendar") || customElements.define("void-calendar", _);
367
- var v = class extends n(e) {
429
+ })], D.prototype, "firstDay", void 0), customElements.get("void-calendar") || customElements.define("void-calendar", D);
430
+ var O = class extends s(e) {
368
431
  constructor(...e) {
369
- super(...e), this.value = "", this.min = "", this.max = "", this.disabled = !1, this.size = "md", this.locale = "en-US", this.firstDay = 0, this.open = !1, this.placeholder = "Select date", this.format = "MM/DD/YYYY", this.color = "default", this._dropdownId = i("void-date-picker-dialog"), this._overlay = new o(this, {
432
+ super(...e), this.keys = null, this.value = "", this.min = "", this.max = "", this.disabled = !1, this.size = "md", this.locale = "", this.firstDay = null, this.open = !1, this.placeholder = "", this.format = "MM/DD/YYYY", this.color = "default", this.error = "", this._draft = null, this._rejected = null, this._ownError = "", this._errorId = l("void-date-picker-error"), this._dropdownId = l("void-date-picker-dialog"), this._overlay = new f(this, {
370
433
  kind: "dialog",
371
434
  surface: () => this.querySelector(":scope > .void-date-picker-dropdown"),
372
435
  isOpen: () => this.open,
@@ -380,44 +443,85 @@ var v = class extends n(e) {
380
443
  this.disabled || this._overlay.toggle("trigger");
381
444
  }, this._onInputClick = () => {
382
445
  this.disabled || this._overlay.toggle("focus");
446
+ }, this._onInput = (e) => {
447
+ this._draft = e.target.value;
448
+ }, this._commit = () => {
449
+ if (this._draft === null || this.disabled) return;
450
+ let e = this._draft.trim();
451
+ if (e === this._display) {
452
+ this._draft = null, this._accept();
453
+ return;
454
+ }
455
+ if (e === "") {
456
+ this._draft = null, this._accept(), this._setTyped("");
457
+ return;
458
+ }
459
+ let t = C(e, this.format), n = t ? this.min && t < this.min ? { rangeUnderflow: !0 } : this.max && t > this.max ? { rangeOverflow: !0 } : null : { badInput: !0 };
460
+ if (n || !t) {
461
+ let e = n?.rangeUnderflow ? a(this, "datePicker.tooEarly", { date: S(this.min, this.format) }) : n?.rangeOverflow ? a(this, "datePicker.tooLate", { date: S(this.max, this.format) }) : a(this, "datePicker.invalid", { format: this.format });
462
+ this._rejected = {
463
+ flags: n ?? { badInput: !0 },
464
+ message: e
465
+ }, (!this.error || this.error === this._ownError) && (this.error = e, this._ownError = e), this.requestUpdate();
466
+ return;
467
+ }
468
+ this._draft = null, this._accept(), this._setTyped(t);
383
469
  }, this._onCalendarChange = (e) => {
384
- e.stopPropagation(), this.value = e.detail.value, this._overlay.requestClose("select"), this.dispatchEvent(new CustomEvent("void-change", {
470
+ e.stopPropagation(), this._draft = null, this._accept(), this.value = e.detail.value, this._overlay.requestClose("select"), this.dispatchEvent(new CustomEvent("void-change", {
385
471
  bubbles: !0,
386
472
  composed: !0,
387
473
  detail: e.detail
388
474
  }));
389
475
  }, this._onInputKeydown = (e) => {
390
- e.key === "Enter" || e.key === " " ? (e.preventDefault(), this.disabled || this._overlay.toggle("keyboard")) : e.key === "ArrowDown" && !this.disabled && (e.preventDefault(), this.open ? this._focusDay() : this._overlay.requestOpen("keyboard"));
476
+ let t = n(this, e);
477
+ t === "activate" && e.key === "Enter" && this._draft !== null && this._draft.trim() !== this._display ? (e.preventDefault(), this._commit(), !this._rejected && this.open && this._overlay.requestClose("select")) : t === "activate" && (e.key !== " " || this._draft === null) ? (e.preventDefault(), this.disabled || this._overlay.toggle("keyboard")) : t === "open" && !this.disabled && (e.preventDefault(), this.open ? this._focusDay() : this._overlay.requestOpen("keyboard"));
391
478
  };
392
479
  }
480
+ static {
481
+ this.keyMap = u;
482
+ }
393
483
  static {
394
484
  this.labelTarget = ".void-date-picker-input";
395
485
  }
486
+ get _hint() {
487
+ return this.placeholder || a(this, "datePicker.placeholder");
488
+ }
489
+ static {
490
+ this.clientState = { _draft: "value" };
491
+ }
492
+ static {
493
+ this.editState = ["value"];
494
+ }
396
495
  async _focusDay() {
397
496
  let e = this.querySelector(":scope > .void-date-picker-dropdown > void-calendar");
398
497
  e && (await e.updateComplete, this.open && e.querySelector("[tabindex=\"0\"]")?.focus({ preventScroll: !0 }));
399
498
  }
400
499
  render() {
401
- return s`
500
+ let e = this.value ? S(this.value, this.format) : "", t = this._rejected && this.error === this._ownError ? this.error : "";
501
+ return p`
402
502
  <div class="void-date-picker-anchor">
403
503
  <input
404
504
  class="void-date-picker-input"
405
- .value=${u(this.value ? g(this.value, this.format) : "")}
406
- placeholder=${this.placeholder}
505
+ .value=${g(this._draft ?? e)}
506
+ placeholder=${this._hint}
407
507
  ?disabled=${this.disabled}
408
- readonly
508
+ autocomplete="off"
409
509
  role="combobox"
410
- aria-label=${this.placeholder}
510
+ aria-label=${this._hint}
411
511
  aria-haspopup="dialog"
412
512
  aria-expanded=${String(this.open)}
413
513
  aria-controls=${this._dropdownId}
514
+ aria-invalid=${this.error ? "true" : m}
515
+ aria-describedby=${t ? this._errorId : m}
516
+ @input=${this._onInput}
517
+ @blur=${this._commit}
414
518
  @click=${this._onInputClick}
415
519
  @keydown=${this._onInputKeydown}
416
520
  />
417
521
  <button
418
522
  type="button"
419
523
  class="void-date-picker-icon"
420
- aria-label="Toggle calendar"
524
+ aria-label=${a(this, "datePicker.toggle")}
421
525
  ?disabled=${this.disabled}
422
526
  tabindex="-1"
423
527
  @click=${this._toggle}
@@ -430,41 +534,80 @@ var v = class extends n(e) {
430
534
  </svg>
431
535
  </button>
432
536
  </div>
433
- ${this.open ? s`
434
- <div class="void-date-picker-dropdown" id=${this._dropdownId} role="dialog" aria-label="Choose date" popover="manual">
537
+ ${t ? p`<span class="void-date-picker-error" id=${this._errorId} role="alert">${t}</span>` : m}
538
+ ${this.open ? p`
539
+ <div class="void-date-picker-dropdown" id=${this._dropdownId} role="dialog" aria-label=${a(this, "datePicker.dialog")} popover="manual">
435
540
  <void-calendar
436
541
  value=${this.value}
437
542
  min=${this.min}
438
543
  max=${this.max}
439
544
  ?disabled=${this.disabled}
440
545
  size=${this.size}
441
- locale=${this.locale}
442
- first-day=${this.firstDay}
546
+ locale=${this.locale || m}
547
+ first-day=${this.firstDay ?? m}
443
548
  @void-change=${this._onCalendarChange}
444
549
  ></void-calendar>
445
550
  </div>
446
- ` : c}
551
+ ` : m}
447
552
  `;
448
553
  }
554
+ get _display() {
555
+ return this.value ? S(this.value, this.format) : "";
556
+ }
557
+ _accept(e = !0) {
558
+ this._rejected = null, this._ownError && this.error === this._ownError && (this.error = ""), this._ownError = "", e && this.requestUpdate();
559
+ }
560
+ _setTyped(e) {
561
+ if (e === this.value) return;
562
+ this.value = e;
563
+ let t = _(e);
564
+ this.dispatchEvent(new CustomEvent("void-change", {
565
+ bubbles: !0,
566
+ composed: !0,
567
+ detail: {
568
+ value: e,
569
+ date: t ? new Date(t[0], t[1], t[2]) : null
570
+ }
571
+ }));
572
+ }
573
+ formValidity() {
574
+ return this._rejected ? {
575
+ flags: this._rejected.flags,
576
+ message: this._rejected.message,
577
+ anchor: this.querySelector(".void-date-picker-input") ?? void 0
578
+ } : super.formValidity();
579
+ }
580
+ formRestore(e) {
581
+ this._draft = null, this._accept(), super.formRestore(e);
582
+ }
583
+ willUpdate(e) {
584
+ super.willUpdate(e), e.has("value") && (this._draft = null, this._rejected && this._accept(!1));
585
+ }
449
586
  };
450
- t([l({
587
+ t([h({
588
+ attribute: "keys",
589
+ converter: r
590
+ })], O.prototype, "keys", void 0), t([h({
451
591
  type: String,
452
592
  reflect: !0
453
- })], v.prototype, "value", void 0), t([l({ type: String })], v.prototype, "min", void 0), t([l({ type: String })], v.prototype, "max", void 0), t([l({
593
+ })], O.prototype, "value", void 0), t([h({ type: String })], O.prototype, "min", void 0), t([h({ type: String })], O.prototype, "max", void 0), t([h({
454
594
  type: Boolean,
455
595
  reflect: !0
456
- })], v.prototype, "disabled", void 0), t([l({
596
+ })], O.prototype, "disabled", void 0), t([h({
457
597
  type: String,
458
598
  reflect: !0
459
- })], v.prototype, "size", void 0), t([l({ type: String })], v.prototype, "locale", void 0), t([l({
599
+ })], O.prototype, "size", void 0), t([h({ type: String })], O.prototype, "locale", void 0), t([h({
460
600
  attribute: "first-day",
461
601
  type: Number
462
- })], v.prototype, "firstDay", void 0), t([l({
602
+ })], O.prototype, "firstDay", void 0), t([h({
463
603
  type: Boolean,
464
604
  reflect: !0
465
- })], v.prototype, "open", void 0), t([l({ type: String })], v.prototype, "placeholder", void 0), t([l({ type: String })], v.prototype, "format", void 0), t([l({
605
+ })], O.prototype, "open", void 0), t([h({ type: String })], O.prototype, "placeholder", void 0), t([h({ type: String })], O.prototype, "format", void 0), t([h({
606
+ type: String,
607
+ reflect: !0
608
+ })], O.prototype, "color", void 0), t([h({
466
609
  type: String,
467
610
  reflect: !0
468
- })], v.prototype, "color", void 0), customElements.get("void-date-picker") || customElements.define("void-date-picker", v);
611
+ })], O.prototype, "error", void 0), customElements.get("void-date-picker") || customElements.define("void-date-picker", O);
469
612
  //#endregion
470
- export { _ as VoidCalendar, v as VoidDatePicker };
613
+ export { D as VoidCalendar, O as VoidDatePicker };