@20baht/ui 0.0.0-stage → 0.1.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 (246) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +501 -2
  3. package/dist/components/baht-form.d.ts +191 -0
  4. package/dist/components/baht-form.js +614 -0
  5. package/dist/components/baht-workflow.d.ts +173 -0
  6. package/dist/components/baht-workflow.js +430 -0
  7. package/dist/components/base.d.ts +92 -0
  8. package/dist/components/base.js +138 -0
  9. package/dist/components/combobox-controller.d.ts +65 -0
  10. package/dist/components/combobox-controller.js +82 -0
  11. package/dist/components/define.d.ts +7 -0
  12. package/dist/components/define.js +16 -0
  13. package/dist/components/field-base.d.ts +84 -0
  14. package/dist/components/field-base.js +152 -0
  15. package/dist/components/floating.d.ts +84 -0
  16. package/dist/components/floating.js +182 -0
  17. package/dist/components/form-layout.d.ts +39 -0
  18. package/dist/components/form-layout.js +67 -0
  19. package/dist/components/form-options.d.ts +39 -0
  20. package/dist/components/form-options.js +65 -0
  21. package/dist/components/form-readonly.d.ts +20 -0
  22. package/dist/components/form-readonly.js +70 -0
  23. package/dist/components/layers.d.ts +4 -0
  24. package/dist/components/layers.js +15 -0
  25. package/dist/components/menu-controller.d.ts +65 -0
  26. package/dist/components/menu-controller.js +134 -0
  27. package/dist/components/motion.d.ts +9 -0
  28. package/dist/components/motion.js +16 -0
  29. package/dist/components/primitives/baht-accordion.d.ts +29 -0
  30. package/dist/components/primitives/baht-accordion.js +66 -0
  31. package/dist/components/primitives/baht-alert.d.ts +20 -0
  32. package/dist/components/primitives/baht-alert.js +62 -0
  33. package/dist/components/primitives/baht-app-shell.d.ts +81 -0
  34. package/dist/components/primitives/baht-app-shell.js +161 -0
  35. package/dist/components/primitives/baht-approval-chain.d.ts +59 -0
  36. package/dist/components/primitives/baht-approval-chain.js +80 -0
  37. package/dist/components/primitives/baht-avatar.d.ts +19 -0
  38. package/dist/components/primitives/baht-avatar.js +43 -0
  39. package/dist/components/primitives/baht-badge.d.ts +24 -0
  40. package/dist/components/primitives/baht-badge.js +41 -0
  41. package/dist/components/primitives/baht-bar-chart.d.ts +78 -0
  42. package/dist/components/primitives/baht-bar-chart.js +361 -0
  43. package/dist/components/primitives/baht-breadcrumbs.d.ts +23 -0
  44. package/dist/components/primitives/baht-breadcrumbs.js +45 -0
  45. package/dist/components/primitives/baht-button.d.ts +89 -0
  46. package/dist/components/primitives/baht-button.js +146 -0
  47. package/dist/components/primitives/baht-calendar.d.ts +96 -0
  48. package/dist/components/primitives/baht-calendar.js +398 -0
  49. package/dist/components/primitives/baht-card.d.ts +34 -0
  50. package/dist/components/primitives/baht-card.js +70 -0
  51. package/dist/components/primitives/baht-catalog-card.d.ts +52 -0
  52. package/dist/components/primitives/baht-catalog-card.js +90 -0
  53. package/dist/components/primitives/baht-checkbox.d.ts +7 -0
  54. package/dist/components/primitives/baht-checkbox.js +40 -0
  55. package/dist/components/primitives/baht-choice-group.d.ts +52 -0
  56. package/dist/components/primitives/baht-choice-group.js +71 -0
  57. package/dist/components/primitives/baht-code.d.ts +18 -0
  58. package/dist/components/primitives/baht-code.js +33 -0
  59. package/dist/components/primitives/baht-column-picker.d.ts +69 -0
  60. package/dist/components/primitives/baht-column-picker.js +234 -0
  61. package/dist/components/primitives/baht-comments.d.ts +38 -0
  62. package/dist/components/primitives/baht-comments.js +102 -0
  63. package/dist/components/primitives/baht-currency.d.ts +13 -0
  64. package/dist/components/primitives/baht-currency.js +69 -0
  65. package/dist/components/primitives/baht-datepicker.d.ts +77 -0
  66. package/dist/components/primitives/baht-datepicker.js +235 -0
  67. package/dist/components/primitives/baht-donut-chart.d.ts +24 -0
  68. package/dist/components/primitives/baht-donut-chart.js +88 -0
  69. package/dist/components/primitives/baht-edit-table.d.ts +45 -0
  70. package/dist/components/primitives/baht-edit-table.js +176 -0
  71. package/dist/components/primitives/baht-empty-state.d.ts +26 -0
  72. package/dist/components/primitives/baht-empty-state.js +51 -0
  73. package/dist/components/primitives/baht-error-state.d.ts +21 -0
  74. package/dist/components/primitives/baht-error-state.js +44 -0
  75. package/dist/components/primitives/baht-facts.d.ts +42 -0
  76. package/dist/components/primitives/baht-facts.js +49 -0
  77. package/dist/components/primitives/baht-fieldset.d.ts +19 -0
  78. package/dist/components/primitives/baht-fieldset.js +42 -0
  79. package/dist/components/primitives/baht-file.d.ts +27 -0
  80. package/dist/components/primitives/baht-file.js +158 -0
  81. package/dist/components/primitives/baht-filter-builder.d.ts +39 -0
  82. package/dist/components/primitives/baht-filter-builder.js +201 -0
  83. package/dist/components/primitives/baht-filter.d.ts +36 -0
  84. package/dist/components/primitives/baht-filter.js +64 -0
  85. package/dist/components/primitives/baht-heatmap.d.ts +49 -0
  86. package/dist/components/primitives/baht-heatmap.js +168 -0
  87. package/dist/components/primitives/baht-input.d.ts +10 -0
  88. package/dist/components/primitives/baht-input.js +44 -0
  89. package/dist/components/primitives/baht-keyvalue-editor.d.ts +28 -0
  90. package/dist/components/primitives/baht-keyvalue-editor.js +106 -0
  91. package/dist/components/primitives/baht-line-chart.d.ts +45 -0
  92. package/dist/components/primitives/baht-line-chart.js +183 -0
  93. package/dist/components/primitives/baht-link.d.ts +26 -0
  94. package/dist/components/primitives/baht-link.js +48 -0
  95. package/dist/components/primitives/baht-list.d.ts +29 -0
  96. package/dist/components/primitives/baht-list.js +79 -0
  97. package/dist/components/primitives/baht-loading-overlay.d.ts +15 -0
  98. package/dist/components/primitives/baht-loading-overlay.js +33 -0
  99. package/dist/components/primitives/baht-markdown-view.d.ts +17 -0
  100. package/dist/components/primitives/baht-markdown-view.js +39 -0
  101. package/dist/components/primitives/baht-markdown.d.ts +34 -0
  102. package/dist/components/primitives/baht-markdown.js +177 -0
  103. package/dist/components/primitives/baht-menu.d.ts +53 -0
  104. package/dist/components/primitives/baht-menu.js +100 -0
  105. package/dist/components/primitives/baht-meter.d.ts +67 -0
  106. package/dist/components/primitives/baht-meter.js +107 -0
  107. package/dist/components/primitives/baht-modal.d.ts +71 -0
  108. package/dist/components/primitives/baht-modal.js +164 -0
  109. package/dist/components/primitives/baht-multiselect.d.ts +8 -0
  110. package/dist/components/primitives/baht-multiselect.js +47 -0
  111. package/dist/components/primitives/baht-notification-bell.d.ts +54 -0
  112. package/dist/components/primitives/baht-notification-bell.js +143 -0
  113. package/dist/components/primitives/baht-number.d.ts +5 -0
  114. package/dist/components/primitives/baht-number.js +39 -0
  115. package/dist/components/primitives/baht-order-box.d.ts +24 -0
  116. package/dist/components/primitives/baht-order-box.js +50 -0
  117. package/dist/components/primitives/baht-otp.d.ts +49 -0
  118. package/dist/components/primitives/baht-otp.js +109 -0
  119. package/dist/components/primitives/baht-page-header.d.ts +43 -0
  120. package/dist/components/primitives/baht-page-header.js +78 -0
  121. package/dist/components/primitives/baht-pagination.d.ts +33 -0
  122. package/dist/components/primitives/baht-pagination.js +86 -0
  123. package/dist/components/primitives/baht-popover.d.ts +45 -0
  124. package/dist/components/primitives/baht-popover.js +112 -0
  125. package/dist/components/primitives/baht-progress-ring.d.ts +22 -0
  126. package/dist/components/primitives/baht-progress-ring.js +62 -0
  127. package/dist/components/primitives/baht-progress.d.ts +17 -0
  128. package/dist/components/primitives/baht-progress.js +48 -0
  129. package/dist/components/primitives/baht-radio.d.ts +7 -0
  130. package/dist/components/primitives/baht-radio.js +74 -0
  131. package/dist/components/primitives/baht-range.d.ts +38 -0
  132. package/dist/components/primitives/baht-range.js +88 -0
  133. package/dist/components/primitives/baht-rating.d.ts +40 -0
  134. package/dist/components/primitives/baht-rating.js +107 -0
  135. package/dist/components/primitives/baht-record-bar.d.ts +30 -0
  136. package/dist/components/primitives/baht-record-bar.js +60 -0
  137. package/dist/components/primitives/baht-reference-dialog.d.ts +87 -0
  138. package/dist/components/primitives/baht-reference-dialog.js +418 -0
  139. package/dist/components/primitives/baht-reference-picker.d.ts +110 -0
  140. package/dist/components/primitives/baht-reference-picker.js +321 -0
  141. package/dist/components/primitives/baht-repeater.d.ts +59 -0
  142. package/dist/components/primitives/baht-repeater.js +315 -0
  143. package/dist/components/primitives/baht-rule-builder.d.ts +24 -0
  144. package/dist/components/primitives/baht-rule-builder.js +177 -0
  145. package/dist/components/primitives/baht-saved-filters.d.ts +41 -0
  146. package/dist/components/primitives/baht-saved-filters.js +126 -0
  147. package/dist/components/primitives/baht-search.d.ts +34 -0
  148. package/dist/components/primitives/baht-search.js +71 -0
  149. package/dist/components/primitives/baht-section-header.d.ts +28 -0
  150. package/dist/components/primitives/baht-section-header.js +48 -0
  151. package/dist/components/primitives/baht-section.d.ts +23 -0
  152. package/dist/components/primitives/baht-section.js +49 -0
  153. package/dist/components/primitives/baht-select.d.ts +49 -0
  154. package/dist/components/primitives/baht-select.js +197 -0
  155. package/dist/components/primitives/baht-skeleton.d.ts +16 -0
  156. package/dist/components/primitives/baht-skeleton.js +37 -0
  157. package/dist/components/primitives/baht-sparkline.d.ts +23 -0
  158. package/dist/components/primitives/baht-sparkline.js +56 -0
  159. package/dist/components/primitives/baht-spinner.d.ts +13 -0
  160. package/dist/components/primitives/baht-spinner.js +30 -0
  161. package/dist/components/primitives/baht-split-button.d.ts +43 -0
  162. package/dist/components/primitives/baht-split-button.js +87 -0
  163. package/dist/components/primitives/baht-stat-chart.d.ts +14 -0
  164. package/dist/components/primitives/baht-stat-chart.js +38 -0
  165. package/dist/components/primitives/baht-stat.d.ts +56 -0
  166. package/dist/components/primitives/baht-stat.js +117 -0
  167. package/dist/components/primitives/baht-steps.d.ts +33 -0
  168. package/dist/components/primitives/baht-steps.js +60 -0
  169. package/dist/components/primitives/baht-swipe-row.d.ts +64 -0
  170. package/dist/components/primitives/baht-swipe-row.js +178 -0
  171. package/dist/components/primitives/baht-table.d.ts +315 -0
  172. package/dist/components/primitives/baht-table.js +640 -0
  173. package/dist/components/primitives/baht-tabs.d.ts +54 -0
  174. package/dist/components/primitives/baht-tabs.js +128 -0
  175. package/dist/components/primitives/baht-tags.d.ts +96 -0
  176. package/dist/components/primitives/baht-tags.js +323 -0
  177. package/dist/components/primitives/baht-text.d.ts +10 -0
  178. package/dist/components/primitives/baht-text.js +29 -0
  179. package/dist/components/primitives/baht-textarea.d.ts +5 -0
  180. package/dist/components/primitives/baht-textarea.js +40 -0
  181. package/dist/components/primitives/baht-theme-toggle.d.ts +44 -0
  182. package/dist/components/primitives/baht-theme-toggle.js +101 -0
  183. package/dist/components/primitives/baht-timeline.d.ts +21 -0
  184. package/dist/components/primitives/baht-timeline.js +42 -0
  185. package/dist/components/primitives/baht-toast.d.ts +29 -0
  186. package/dist/components/primitives/baht-toast.js +83 -0
  187. package/dist/components/primitives/baht-toggle.d.ts +6 -0
  188. package/dist/components/primitives/baht-toggle.js +42 -0
  189. package/dist/components/primitives/baht-tooltip.d.ts +34 -0
  190. package/dist/components/primitives/baht-tooltip.js +85 -0
  191. package/dist/components/primitives/baht-tree.d.ts +58 -0
  192. package/dist/components/primitives/baht-tree.js +159 -0
  193. package/dist/components/primitives/baht-typeahead.d.ts +92 -0
  194. package/dist/components/primitives/baht-typeahead.js +258 -0
  195. package/dist/components/primitives/baht-upload.d.ts +108 -0
  196. package/dist/components/primitives/baht-upload.js +325 -0
  197. package/dist/components/primitives/baht-wizard.d.ts +57 -0
  198. package/dist/components/primitives/baht-wizard.js +147 -0
  199. package/dist/components/primitives/charts.d.ts +134 -0
  200. package/dist/components/primitives/charts.js +184 -0
  201. package/dist/components/primitives/column-map.d.ts +56 -0
  202. package/dist/components/primitives/column-map.js +70 -0
  203. package/dist/components/primitives/control-icons.d.ts +2 -0
  204. package/dist/components/primitives/control-icons.js +40 -0
  205. package/dist/components/primitives/icons.d.ts +24 -0
  206. package/dist/components/primitives/icons.js +86 -0
  207. package/dist/components/primitives/illustrations.d.ts +21 -0
  208. package/dist/components/primitives/illustrations.js +78 -0
  209. package/dist/components/primitives/index.d.ts +89 -0
  210. package/dist/components/primitives/kbd.d.ts +6 -0
  211. package/dist/components/primitives/kbd.js +9 -0
  212. package/dist/components/primitives/listbox.d.ts +2 -0
  213. package/dist/components/primitives/listbox.js +7 -0
  214. package/dist/components/primitives/markdown-render.d.ts +9 -0
  215. package/dist/components/primitives/markdown-render.js +77 -0
  216. package/dist/components/primitives/rule-rows.d.ts +55 -0
  217. package/dist/components/primitives/rule-rows.js +75 -0
  218. package/dist/components/primitives/tag-map.d.ts +6 -0
  219. package/dist/components/primitives/tag-map.js +39 -0
  220. package/dist/components/reference-labels.d.ts +22 -0
  221. package/dist/components/reference-labels.js +29 -0
  222. package/dist/components/shortcuts.d.ts +7 -0
  223. package/dist/components/shortcuts.js +43 -0
  224. package/dist/css/components.css +7517 -0
  225. package/dist/css/datepicker.css +346 -0
  226. package/dist/css/tokens.css +679 -0
  227. package/dist/custom-elements.json +45110 -0
  228. package/dist/engine.d.ts +1 -0
  229. package/dist/engine.js +1 -0
  230. package/dist/hydrate.d.ts +9 -0
  231. package/dist/hydrate.js +46 -0
  232. package/dist/index.d.ts +7 -0
  233. package/dist/index.js +210 -0
  234. package/dist/overlay.d.ts +50 -0
  235. package/dist/overlay.js +140 -0
  236. package/dist/react.d.ts +557 -0
  237. package/dist/react.js +1 -0
  238. package/dist/register.d.ts +106 -0
  239. package/dist/register.js +99 -0
  240. package/dist/ssr.d.ts +16 -0
  241. package/dist/ssr.js +125 -0
  242. package/dist/tokens.css +8197 -0
  243. package/dist/vscode.css-custom-data.json +6 -0
  244. package/dist/vscode.html-custom-data.json +2261 -0
  245. package/dist/web-types.json +6523 -0
  246. package/package.json +157 -4
@@ -0,0 +1,398 @@
1
+ import { html as i, nothing as v } from "lit";
2
+ import { t as f } from "@20baht/engine";
3
+ import { property as g } from "lit/decorators.js";
4
+ import { BahtElement as O, hasDom as F, arr as M } from "../base.js";
5
+ import { customElement as B } from "../define.js";
6
+ var H = Object.defineProperty, I = Object.getOwnPropertyDescriptor, $ = (t, e, a, s) => {
7
+ for (var l = s > 1 ? void 0 : s ? I(e, a) : e, n = t.length - 1, r; n >= 0; n--)
8
+ (r = t[n]) && (l = (s ? r(e, a, l) : r(l)) || l);
9
+ return s && l && H(e, a, l), l;
10
+ };
11
+ const z = ["day", "week", "month"], P = { day: "Day", week: "Week", month: "Month" }, _ = 1440, Y = 20, j = 30, x = 3, U = 40, E = 48, T = (t) => String(t).padStart(2, "0"), p = (t) => `${String(t.getFullYear())}-${T(t.getMonth() + 1)}-${T(t.getDate())}`, w = (t) => {
12
+ const e = /^(\d{4})-(\d{2})-(\d{2})$/.exec(t);
13
+ if (!e) return null;
14
+ const a = new Date(Number(e[1]), Number(e[2]) - 1, Number(e[3]));
15
+ return Number.isNaN(a.getTime()) ? null : a;
16
+ }, D = (t) => new Date(t.getFullYear(), t.getMonth(), t.getDate()), y = (t, e) => new Date(t.getFullYear(), t.getMonth(), t.getDate() + e, t.getHours(), t.getMinutes()), S = (t, e) => p(t) === p(e), L = (t, e) => {
17
+ const a = D(t);
18
+ return y(a, -((a.getDay() - e + 7) % 7));
19
+ };
20
+ function C(t, e, a) {
21
+ if (t === "day") return [D(e)];
22
+ if (t === "week") {
23
+ const r = L(e, a);
24
+ return Array.from({ length: 7 }, (b, c) => y(r, c));
25
+ }
26
+ const s = L(new Date(e.getFullYear(), e.getMonth(), 1), a), l = new Date(e.getFullYear(), e.getMonth() + 1, 0), n = [];
27
+ for (let r = s; r <= l || n.length % 7 !== 0; r = y(r, 1)) n.push(r);
28
+ return n;
29
+ }
30
+ function W(t, e, a = 1) {
31
+ const s = C(t, w(e) ?? /* @__PURE__ */ new Date(), a), l = s[0] ?? /* @__PURE__ */ new Date();
32
+ return { from: p(l), to: p(s.at(-1) ?? l) };
33
+ }
34
+ function A(t) {
35
+ if (t.allDay) {
36
+ const s = w(t.start.slice(0, 10)), l = w((t.end ?? t.start).slice(0, 10));
37
+ return !s || !l ? null : { event: t, start: s, end: y(l < s ? s : l, 1), allDay: !0 };
38
+ }
39
+ const e = new Date(t.start);
40
+ if (Number.isNaN(e.getTime())) return null;
41
+ const a = t.end ? new Date(t.end) : new Date(e.getTime() + j * 6e4);
42
+ return {
43
+ event: t,
44
+ start: e,
45
+ end: Number.isNaN(a.getTime()) || a < e ? e : a,
46
+ allDay: !1
47
+ };
48
+ }
49
+ const N = (t, e) => {
50
+ const a = D(e), s = y(a, 1);
51
+ return t.start < s && (t.end > a || t.start.getTime() === t.end.getTime());
52
+ };
53
+ function R(t, e) {
54
+ const a = D(e).getTime(), s = t.map((c) => {
55
+ const h = Math.max(0, (c.start.getTime() - a) / 6e4), d = Math.min(_, (c.end.getTime() - a) / 6e4);
56
+ return { s: c, top: h, bottom: Math.max(d, Math.min(_, h + Y)) };
57
+ }).sort((c, h) => c.top - h.top || h.bottom - c.bottom), l = [];
58
+ let n = [], r = -1;
59
+ const b = () => {
60
+ const c = Math.max(0, ...n.map((h) => h.column)) + 1;
61
+ for (const h of n)
62
+ l.push({ event: h.s, top: h.top, height: h.bottom - h.top, column: h.column, columns: c });
63
+ n = [];
64
+ };
65
+ for (const c of s) {
66
+ c.top >= r && n.length > 0 && b();
67
+ const h = new Set(n.filter((o) => o.bottom > c.top).map((o) => o.column));
68
+ let d = 0;
69
+ for (; h.has(d); ) d += 1;
70
+ n.push({ ...c, column: d }), r = Math.max(r, c.bottom);
71
+ }
72
+ return n.length > 0 && b(), l;
73
+ }
74
+ let m = class extends O {
75
+ constructor() {
76
+ super(...arguments), this.view = "week", this.date = "", this.events = [], this.marks = [], this.label = "", this.today = "", this.weekStart = 1, this.locale = "en-GB", this.firstHour = 7.5, this.scrolledFor = "";
77
+ }
78
+ anchor() {
79
+ return w(this.date) ?? this.todayDate();
80
+ }
81
+ todayDate() {
82
+ return w(this.today) ?? D(/* @__PURE__ */ new Date());
83
+ }
84
+ /** Moves to a view and day, as a person did; the host hears of it and fetches. */
85
+ go(t, e) {
86
+ this.view = t, this.date = p(e);
87
+ const a = W(t, this.date, this.weekStart);
88
+ this.emit("baht-navigate", {
89
+ view: t,
90
+ date: this.date,
91
+ ...a
92
+ });
93
+ }
94
+ step(t) {
95
+ const e = this.anchor();
96
+ this.view === "month" ? this.go("month", new Date(e.getFullYear(), e.getMonth() + t, 1)) : this.go(this.view, y(e, this.view === "week" ? 7 * t : t));
97
+ }
98
+ open(t) {
99
+ this.emit("baht-event-open", { id: t.id, event: t });
100
+ }
101
+ heading(t) {
102
+ const e = this.anchor(), a = (r, b) => r.toLocaleDateString(this.locale, b);
103
+ if (this.view === "month") return a(e, { month: "long", year: "numeric" });
104
+ if (this.view === "day")
105
+ return a(e, { weekday: "short", day: "numeric", month: "long", year: "numeric" });
106
+ const s = t[0] ?? e, l = t.at(-1) ?? e;
107
+ return `${a(
108
+ s,
109
+ s.getMonth() === l.getMonth() ? { day: "numeric" } : { day: "numeric", month: "short" }
110
+ )} – ${a(l, { day: "numeric", month: "short", year: "numeric" })}`;
111
+ }
112
+ time(t) {
113
+ return t.toLocaleTimeString(this.locale, { hour: "2-digit", minute: "2-digit", hour12: !1 });
114
+ }
115
+ eventLabel(t) {
116
+ const { event: e } = t, a = t.allDay ? "all day" : e.end ? `${this.time(t.start)} – ${this.time(t.end)}` : this.time(t.start);
117
+ return [e.title, a, e.meta, e.done ? "done" : ""].filter(Boolean).join(", ");
118
+ }
119
+ eventClass(t, e) {
120
+ return [
121
+ t,
122
+ `baht-calendar-event--${e.tone ?? "primary"}`,
123
+ e.outline ? "baht-calendar-event--outline" : "",
124
+ e.done ? "baht-calendar-event--done" : ""
125
+ ].filter(Boolean).join(" ");
126
+ }
127
+ updated(t) {
128
+ if (super.updated(t), !F() || this.view === "month") return;
129
+ const e = this.view;
130
+ if (e === this.scrolledFor) return;
131
+ const a = this.querySelector(".baht-calendar-scroller");
132
+ a && (a.scrollTop = this.firstHour * E, this.scrolledFor = e);
133
+ }
134
+ willUpdate(t) {
135
+ t.has("view") && this.view === "month" && (this.scrolledFor = "");
136
+ }
137
+ render() {
138
+ const t = C(this.view, this.anchor(), this.weekStart), e = M(this.events).map(A).filter((n) => n !== null).sort((n, r) => Number(r.allDay) - Number(n.allDay) || n.start.getTime() - r.start.getTime()), a = /* @__PURE__ */ new Map();
139
+ for (const n of M(this.marks)) {
140
+ const r = a.get(n.date);
141
+ (!r || r.kind === "freeze" && n.kind !== "freeze") && a.set(n.date, n);
142
+ }
143
+ const s = new Set(
144
+ M(this.marks).filter((n) => n.kind === "freeze").map((n) => n.date)
145
+ ), l = this.heading(t);
146
+ return i`<div class="baht-calendar" role="region" aria-label=${this.label || l}>
147
+ <div class="baht-calendar-toolbar">
148
+ <div class="baht-calendar-nav">
149
+ <button
150
+ type="button"
151
+ class="baht-calendar-btn"
152
+ @click=${() => {
153
+ this.go(this.view, this.todayDate());
154
+ }}
155
+ >
156
+ ${f("today")}
157
+ </button>
158
+ <button
159
+ type="button"
160
+ class="baht-calendar-btn baht-calendar-btn--icon"
161
+ aria-label=${f("previous")}
162
+ @click=${() => {
163
+ this.step(-1);
164
+ }}
165
+ >
166
+ ‹
167
+ </button>
168
+ <button
169
+ type="button"
170
+ class="baht-calendar-btn baht-calendar-btn--icon"
171
+ aria-label=${f("next")}
172
+ @click=${() => {
173
+ this.step(1);
174
+ }}
175
+ >
176
+ ›
177
+ </button>
178
+ <h2 class="baht-calendar-title" aria-live="polite">${l}</h2>
179
+ </div>
180
+ <div class="baht-calendar-views" role="group" aria-label="View">
181
+ ${z.map(
182
+ (n) => i`<button
183
+ type="button"
184
+ class="baht-calendar-view${n === this.view ? " baht-calendar-view--on" : ""}"
185
+ aria-pressed=${String(n === this.view)}
186
+ @click=${() => {
187
+ n !== this.view && this.go(n, this.anchor());
188
+ }}
189
+ >
190
+ ${P[n]}
191
+ </button>`
192
+ )}
193
+ </div>
194
+ </div>
195
+ ${this.view === "month" ? this.renderMonth(t, e, a, s) : this.renderWeek(t, e, a, s)}
196
+ </div>`;
197
+ }
198
+ dayClasses(t, e, a, s) {
199
+ var n;
200
+ const l = p(e);
201
+ return [
202
+ t,
203
+ S(e, this.todayDate()) ? `${t}--today` : "",
204
+ ((n = a.get(l)) == null ? void 0 : n.kind) !== "freeze" && a.has(l) ? `${t}--off` : "",
205
+ s.has(l) ? `${t}--freeze` : ""
206
+ ].filter(Boolean).join(" ");
207
+ }
208
+ renderMark(t, e) {
209
+ const a = e.get(p(t));
210
+ return a ? i`<span
211
+ class="baht-calendar-mark${a.kind === "freeze" ? " baht-calendar-mark--freeze" : ""}"
212
+ title=${a.label}
213
+ >${a.label}</span
214
+ >` : v;
215
+ }
216
+ renderMonth(t, e, a, s) {
217
+ const l = this.anchor().getMonth(), n = t.slice(0, 7).map((r) => r.toLocaleDateString(this.locale, { weekday: "short" }));
218
+ return i`<div class="baht-calendar-month">
219
+ <div class="baht-calendar-weekdays" aria-hidden="true">
220
+ ${n.map((r) => i`<div class="baht-calendar-weekday">${r}</div>`)}
221
+ </div>
222
+ <div class="baht-calendar-cells">
223
+ ${t.map((r) => {
224
+ const b = e.filter((d) => N(d, r)), c = b.length - x, h = this.dayClasses("baht-calendar-cell", r, a, s);
225
+ return i`<div
226
+ class="${h}${r.getMonth() === l ? "" : " baht-calendar-cell--out"}"
227
+ data-day=${p(r)}
228
+ >
229
+ <button
230
+ type="button"
231
+ class="baht-calendar-date"
232
+ aria-label=${r.toLocaleDateString(this.locale, {
233
+ weekday: "long",
234
+ day: "numeric",
235
+ month: "long"
236
+ })}
237
+ @click=${() => {
238
+ this.go("day", r);
239
+ }}
240
+ >
241
+ ${r.getDate()}
242
+ </button>
243
+ ${this.renderMark(r, a)}
244
+ ${b.slice(0, x).map(
245
+ (d) => i`<button
246
+ type="button"
247
+ class=${this.eventClass("baht-calendar-chip", d.event)}
248
+ data-id=${d.event.id}
249
+ aria-label=${this.eventLabel(d)}
250
+ @click=${() => {
251
+ this.open(d.event);
252
+ }}
253
+ >
254
+ ${d.allDay ? v : i`<span class="baht-calendar-chip-time">${this.time(d.start)}</span>`}
255
+ <span class="baht-calendar-chip-title">${d.event.title}</span>
256
+ </button>`
257
+ )}
258
+ ${c > 0 ? i`<button
259
+ type="button"
260
+ class="baht-calendar-more"
261
+ @click=${() => {
262
+ this.go("day", r);
263
+ }}
264
+ >
265
+ ${f("calendarMore", { n: c })}
266
+ </button>` : v}
267
+ </div>`;
268
+ })}
269
+ </div>
270
+ </div>`;
271
+ }
272
+ renderWeek(t, e, a, s) {
273
+ const l = this.todayDate(), n = /* @__PURE__ */ new Date(), r = n.getHours() * 60 + n.getMinutes(), b = t.map((o) => e.filter((u) => u.allDay && N(u, o))), c = b.some((o) => o.length > 0), h = `--baht-calendar-days: ${String(t.length)}; --baht-calendar-hour: ${String(E)}px`, d = t.length === 1 ? "baht-calendar-week baht-calendar-week--day" : "baht-calendar-week";
274
+ return i`<div class=${d} style=${h}>
275
+ <div class="baht-calendar-head">
276
+ <div class="baht-calendar-gutter"></div>
277
+ ${t.map(
278
+ (o) => i`<button
279
+ type="button"
280
+ class=${this.dayClasses("baht-calendar-dayhead", o, a, s)}
281
+ data-day=${p(o)}
282
+ @click=${() => {
283
+ this.go("day", o);
284
+ }}
285
+ >
286
+ <span class="baht-calendar-dayname"
287
+ >${o.toLocaleDateString(this.locale, { weekday: "short" })}</span
288
+ >
289
+ <span class="baht-calendar-daynum">${o.getDate()}</span>
290
+ ${this.renderMark(o, a)}
291
+ </button>`
292
+ )}
293
+ </div>
294
+ ${c ? i`<div class="baht-calendar-allday">
295
+ <div class="baht-calendar-gutter baht-calendar-gutter-label">${f("allDay")}</div>
296
+ ${b.map(
297
+ (o) => i`<div class="baht-calendar-allday-col">
298
+ ${o.map(
299
+ (u) => i`<button
300
+ type="button"
301
+ class=${this.eventClass("baht-calendar-chip", u.event)}
302
+ data-id=${u.event.id}
303
+ aria-label=${this.eventLabel(u)}
304
+ @click=${() => {
305
+ this.open(u.event);
306
+ }}
307
+ >
308
+ <span class="baht-calendar-chip-title">${u.event.title}</span>
309
+ </button>`
310
+ )}
311
+ </div>`
312
+ )}
313
+ </div>` : v}
314
+ <div class="baht-calendar-scroller">
315
+ <div class="baht-calendar-grid">
316
+ <div class="baht-calendar-gutter baht-calendar-hours" aria-hidden="true">
317
+ ${Array.from({ length: 23 }, (o, u) => u + 1).map(
318
+ (o) => i`<span class="baht-calendar-hour" style=${`--baht-calendar-at: ${String(o)}`}
319
+ >${T(o)}:00</span
320
+ >`
321
+ )}
322
+ </div>
323
+ ${t.map((o) => {
324
+ const u = e.filter((k) => !k.allDay && N(k, o));
325
+ return i`<div
326
+ class=${this.dayClasses("baht-calendar-col", o, a, s)}
327
+ data-day=${p(o)}
328
+ >
329
+ ${S(o, l) && S(l, n) ? i`<div
330
+ class="baht-calendar-now"
331
+ style=${`top: calc(${String(r)} * var(--baht-calendar-hour) / 60)`}
332
+ aria-hidden="true"
333
+ ></div>` : v}
334
+ ${R(u, o).map((k) => this.renderBlock(k))}
335
+ </div>`;
336
+ })}
337
+ </div>
338
+ </div>
339
+ </div>`;
340
+ }
341
+ renderBlock(t) {
342
+ const e = 100 / t.columns, a = [
343
+ `top: calc(${String(t.top)} * var(--baht-calendar-hour) / 60)`,
344
+ `height: max(calc(${String(t.height)} * var(--baht-calendar-hour) / 60 - 2px), 14px)`,
345
+ `left: calc(${String(t.column * e)}% + 2px)`,
346
+ `width: calc(${String(e)}% - 4px)`
347
+ ].join("; "), { event: s } = t.event, l = s.end ? `${this.time(t.event.start)} – ${this.time(t.event.end)}` : this.time(t.event.start), n = t.height < U;
348
+ return i`<button
349
+ type="button"
350
+ class="${this.eventClass("baht-calendar-block", s)}${n ? " baht-calendar-block--short" : ""}"
351
+ data-id=${s.id}
352
+ style=${a}
353
+ aria-label=${this.eventLabel(t.event)}
354
+ @click=${() => {
355
+ this.open(s);
356
+ }}
357
+ >
358
+ ${n ? i`<span class="baht-calendar-block-meta">${this.time(t.event.start)}</span>
359
+ <span class="baht-calendar-block-title">${s.title}</span>` : i`<span class="baht-calendar-block-title">${s.title}</span>
360
+ <span class="baht-calendar-block-meta">${l}</span>
361
+ ${s.meta ? i`<span class="baht-calendar-block-meta">${s.meta}</span>` : v}`}
362
+ </button>`;
363
+ }
364
+ };
365
+ $([
366
+ g({ reflect: !0 })
367
+ ], m.prototype, "view", 2);
368
+ $([
369
+ g()
370
+ ], m.prototype, "date", 2);
371
+ $([
372
+ g({ attribute: !1 })
373
+ ], m.prototype, "events", 2);
374
+ $([
375
+ g({ attribute: !1 })
376
+ ], m.prototype, "marks", 2);
377
+ $([
378
+ g()
379
+ ], m.prototype, "label", 2);
380
+ $([
381
+ g()
382
+ ], m.prototype, "today", 2);
383
+ $([
384
+ g({ type: Number, attribute: "week-start" })
385
+ ], m.prototype, "weekStart", 2);
386
+ $([
387
+ g()
388
+ ], m.prototype, "locale", 2);
389
+ $([
390
+ g({ type: Number, attribute: "first-hour" })
391
+ ], m.prototype, "firstHour", 2);
392
+ m = $([
393
+ B("baht-calendar")
394
+ ], m);
395
+ export {
396
+ m as BahtCalendar,
397
+ W as calendarRange
398
+ };
@@ -0,0 +1,34 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /** `<baht-card accent>` tones. */
4
+ export type CardAccent = 'primary' | 'success' | 'warning' | 'danger' | 'neutral';
5
+ /**
6
+ * Surface card (20baht: white on cream, 1px border, no shadow at rest — the
7
+ * border carries the separation). Children become the body; a child with
8
+ * `data-slot="actions"` (a badge, a button, a "…" menu) goes in the header,
9
+ * at the end of the heading's row. Several such children sit in a row.
10
+ *
11
+ * <baht-card heading="Runs" subtitle="Last 30 days">…content…</baht-card>
12
+ * <baht-card heading="Rules"><baht-menu data-slot="actions" …></baht-menu>…</baht-card>
13
+ * <baht-card hero>…large feature card (20px radius)…</baht-card>
14
+ * <baht-card heading="Running" accent="success" level="2">…a stat card…</baht-card>
15
+ *
16
+ * `accent` draws a 3px rule along the top edge in a tone (`primary`, `success`, `warning`,
17
+ * `danger`, `neutral`); `level` makes the title a heading for the page outline.
18
+ */
19
+ export declare class BahtCard extends BahtElement {
20
+ /** Title at the top of the card. */
21
+ heading: string;
22
+ /** Muted line under the title. */
23
+ subtitle: string;
24
+ /** hero = 20px radius + roomier padding (large/feature cards). */
25
+ hero: boolean;
26
+ /** A coloured rule along the card's top edge (a stat card's tone). */
27
+ accent: CardAccent | '';
28
+ /** Heading level (2 to 6) for the title, for a page outline; 0 (default) leaves it a plain line. */
29
+ level: number;
30
+ private bodyEl;
31
+ private actionsEl;
32
+ protected adoptChildren(): void;
33
+ protected render(): TemplateResult;
34
+ }
@@ -0,0 +1,70 @@
1
+ import { nothing as o, html as n } from "lit";
2
+ import { property as s, query as p } from "lit/decorators.js";
3
+ import { BahtElement as v, adoptSlotted as b } from "../base.js";
4
+ import { customElement as u } from "../define.js";
5
+ var y = Object.defineProperty, m = Object.getOwnPropertyDescriptor, e = (i, a, h, c) => {
6
+ for (var r = c > 1 ? void 0 : c ? m(a, h) : a, l = i.length - 1, d; l >= 0; l--)
7
+ (d = i[l]) && (r = (c ? d(a, h, r) : d(r)) || r);
8
+ return c && r && y(a, h, r), r;
9
+ };
10
+ const f = /* @__PURE__ */ new Set([
11
+ "primary",
12
+ "success",
13
+ "warning",
14
+ "danger",
15
+ "neutral"
16
+ ]);
17
+ let t = class extends v {
18
+ constructor() {
19
+ super(...arguments), this.heading = "", this.subtitle = "", this.hero = !1, this.accent = "", this.level = 0;
20
+ }
21
+ // After every render and whenever a framework host adds a child (base.ts).
22
+ adoptChildren() {
23
+ b(this, this.bodyEl, { actions: this.actionsEl });
24
+ }
25
+ render() {
26
+ const i = f.has(this.accent) ? ` baht-card--accent baht-card--accent-${this.accent}` : "", a = this.level >= 2 && this.level <= 6 ? String(Math.trunc(this.level)) : "";
27
+ return n`<div class="baht-card${this.hero ? " baht-card--hero" : ""}${i}">
28
+ <div class="baht-card-header">
29
+ <div class="baht-card-heading">
30
+ ${this.heading ? n`<div
31
+ class="baht-card-title"
32
+ role=${a ? "heading" : o}
33
+ aria-level=${a || o}
34
+ >${this.heading}</div
35
+ >` : o}
36
+ ${this.subtitle ? n`<div class="baht-card-subtitle">${this.subtitle}</div>` : o}
37
+ </div>
38
+ <div class="baht-card-actions"></div>
39
+ </div>
40
+ <div class="baht-card-body"></div>
41
+ </div>`;
42
+ }
43
+ };
44
+ e([
45
+ s()
46
+ ], t.prototype, "heading", 2);
47
+ e([
48
+ s()
49
+ ], t.prototype, "subtitle", 2);
50
+ e([
51
+ s({ type: Boolean })
52
+ ], t.prototype, "hero", 2);
53
+ e([
54
+ s({ reflect: !0 })
55
+ ], t.prototype, "accent", 2);
56
+ e([
57
+ s({ type: Number })
58
+ ], t.prototype, "level", 2);
59
+ e([
60
+ p(".baht-card-body")
61
+ ], t.prototype, "bodyEl", 2);
62
+ e([
63
+ p(".baht-card-actions")
64
+ ], t.prototype, "actionsEl", 2);
65
+ t = e([
66
+ u("baht-card")
67
+ ], t);
68
+ export {
69
+ t as BahtCard
70
+ };
@@ -0,0 +1,52 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * A card that opens something: picture, name, one line about it. Lay several out with your own grid.
5
+ *
6
+ * <baht-catalog-card heading="New server" description="Ask for a server" image="/server.png" href="/new"></baht-catalog-card>
7
+ *
8
+ * Children fill three places: `data-slot="art"` (a sticker or any picture; it replaces `image`),
9
+ * `data-slot="facts"` (badges in a row under the description; unmarked children go here too) and
10
+ * `data-slot="actions"` (buttons at the foot of the card). Without actions the whole card is the
11
+ * link; with them only the heading is, so the buttons can be pressed. Without `href` nothing is a
12
+ * link: the heading is plain text (a card that only carries actions). A `data-slot="corner"` child
13
+ * (a `<baht-menu>`, a badge) sits in the top end corner, above the card's link.
14
+ *
15
+ * `layout="stacked"` puts the art above the text instead of beside it; `level` makes the heading a
16
+ * heading (`role="heading"`, `aria-level`) for a page outline.
17
+ *
18
+ * <baht-catalog-card heading="Web server" description="nginx on Ubuntu" href="/presets/web">
19
+ * <baht-sticker data-slot="art" name="rack"></baht-sticker>
20
+ * <baht-badge data-slot="facts" tone="mono" label="2 vCPU · 4 GB"></baht-badge>
21
+ * <baht-button data-slot="actions" variant="primary">Launch</baht-button>
22
+ * </baht-catalog-card>
23
+ *
24
+ * @fires {CustomEvent<{ href: string }>} baht-open - The link was pressed. `detail: { href }`. Cancelable: `preventDefault()` to
25
+ * route yourself.
26
+ */
27
+ export declare class BahtCatalogCard extends BahtElement {
28
+ /** The card's name; also its link. */
29
+ heading: string;
30
+ /** One line about it. */
31
+ description: string;
32
+ /** Picture URL, shown at the start of the card. A `data-slot="art"` child replaces it. */
33
+ image: string;
34
+ /** Where the card goes. Empty: the card is not a link and the heading is plain text. */
35
+ href: string;
36
+ /** `'row'` (default): art beside the text. `'stacked'`: art on top. */
37
+ layout: 'row' | 'stacked';
38
+ /** Heading level (2 to 6) for the page outline; 0 (default) leaves the name a plain link or text. */
39
+ level: number;
40
+ private cardEl;
41
+ private artEl;
42
+ private factsEl;
43
+ private actionsEl;
44
+ private cornerEl;
45
+ protected adoptChildren(): void;
46
+ protected render(): TemplateResult;
47
+ }
48
+ declare global {
49
+ interface HTMLElementTagNameMap {
50
+ 'baht-catalog-card': BahtCatalogCard;
51
+ }
52
+ }
@@ -0,0 +1,90 @@
1
+ import { html as i, nothing as p } from "lit";
2
+ import { property as l, query as h } from "lit/decorators.js";
3
+ import { BahtElement as f, adoptSlotted as m, hasSlotted as v, routeClick as b } from "../base.js";
4
+ import { isSafeUrl as g } from "@20baht/engine";
5
+ import { customElement as y } from "../define.js";
6
+ var u = Object.defineProperty, E = Object.getOwnPropertyDescriptor, a = (s, r, o, c) => {
7
+ for (var e = c > 1 ? void 0 : c ? E(r, o) : r, d = s.length - 1, n; d >= 0; d--)
8
+ (n = s[d]) && (e = (c ? n(r, o, e) : n(e)) || e);
9
+ return c && e && u(r, o, e), e;
10
+ };
11
+ let t = class extends f {
12
+ constructor() {
13
+ super(...arguments), this.heading = "", this.description = "", this.image = "", this.href = "", this.layout = "row", this.level = 0;
14
+ }
15
+ adoptChildren() {
16
+ const s = {
17
+ art: this.artEl,
18
+ facts: this.factsEl,
19
+ actions: this.actionsEl,
20
+ corner: this.cornerEl
21
+ };
22
+ m(this, this.factsEl, s);
23
+ for (const [r, o] of Object.entries(s))
24
+ this.cardEl.classList.toggle(`baht-catalog-card--${r}`, v(o));
25
+ }
26
+ render() {
27
+ const s = this.href && g(this.href) ? this.href : "", r = this.image && g(this.image) ? this.image : "", o = this.level >= 2 && this.level <= 6 ? String(Math.trunc(this.level)) : "", c = s ? i`<a
28
+ class="baht-catalog-card-link"
29
+ href=${s}
30
+ @click=${(e) => {
31
+ b(this, "baht-open", e, { href: this.href });
32
+ }}
33
+ >${this.heading}</a
34
+ >` : i`<span class="baht-catalog-card-name">${this.heading}</span>`;
35
+ return i`<article
36
+ class="baht-catalog-card${this.layout === "stacked" ? " baht-catalog-card--stacked" : ""}"
37
+ >
38
+ <div class="baht-catalog-card-corner"></div>
39
+ <div class="baht-catalog-card-art"></div>
40
+ ${r ? i`<img class="baht-catalog-card-image" src=${r} alt="" />` : p}
41
+ <div class="baht-catalog-card-text">
42
+ ${o ? i`<div class="baht-catalog-card-heading" role="heading" aria-level=${o}>
43
+ ${c}
44
+ </div>` : c}
45
+ ${this.description ? i`<p class="baht-catalog-card-description">${this.description}</p>` : p}
46
+ <div class="baht-catalog-card-facts"></div>
47
+ <div class="baht-catalog-card-actions"></div>
48
+ </div>
49
+ </article>`;
50
+ }
51
+ };
52
+ a([
53
+ l()
54
+ ], t.prototype, "heading", 2);
55
+ a([
56
+ l()
57
+ ], t.prototype, "description", 2);
58
+ a([
59
+ l()
60
+ ], t.prototype, "image", 2);
61
+ a([
62
+ l()
63
+ ], t.prototype, "href", 2);
64
+ a([
65
+ l({ reflect: !0 })
66
+ ], t.prototype, "layout", 2);
67
+ a([
68
+ l({ type: Number })
69
+ ], t.prototype, "level", 2);
70
+ a([
71
+ h(".baht-catalog-card")
72
+ ], t.prototype, "cardEl", 2);
73
+ a([
74
+ h(".baht-catalog-card-art")
75
+ ], t.prototype, "artEl", 2);
76
+ a([
77
+ h(".baht-catalog-card-facts")
78
+ ], t.prototype, "factsEl", 2);
79
+ a([
80
+ h(".baht-catalog-card-actions")
81
+ ], t.prototype, "actionsEl", 2);
82
+ a([
83
+ h(".baht-catalog-card-corner")
84
+ ], t.prototype, "cornerEl", 2);
85
+ t = a([
86
+ y("baht-catalog-card")
87
+ ], t);
88
+ export {
89
+ t as BahtCatalogCard
90
+ };
@@ -0,0 +1,7 @@
1
+ import { nothing, TemplateResult } from 'lit';
2
+ import { BahtFieldBase } from '../field-base.js';
3
+ export declare class BahtCheckbox extends BahtFieldBase {
4
+ /** Label sits beside the box, so suppress the block label. */
5
+ protected renderLabel(): typeof nothing;
6
+ protected renderControl(): TemplateResult;
7
+ }