@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,109 @@
1
+ import { html as c } from "lit";
2
+ import { property as o } from "lit/decorators.js";
3
+ import { BahtElement as p } from "../base.js";
4
+ import { t as m } from "@20baht/engine";
5
+ import { customElement as f } from "../define.js";
6
+ var _ = Object.defineProperty, d = Object.getOwnPropertyDescriptor, n = (t, s, e, h) => {
7
+ for (var i = h > 1 ? void 0 : h ? d(s, e) : s, a = t.length - 1, r; a >= 0; a--)
8
+ (r = t[a]) && (i = (h ? r(s, e, i) : r(i)) || i);
9
+ return h && i && _(s, e, i), i;
10
+ };
11
+ let l = class extends p {
12
+ constructor() {
13
+ super(...arguments), this.length = 6, this.value = "", this.disabled = !1, this.mode = "numeric", this.label = "One-time code", this._chars = [], this._lastValue = "", this._wasFull = !1;
14
+ }
15
+ inputs() {
16
+ return Array.from(this.querySelectorAll("input"));
17
+ }
18
+ clean(t) {
19
+ return this.mode === "numeric" ? t.replace(/\D/g, "") : t;
20
+ }
21
+ willUpdate(t) {
22
+ super.willUpdate(t);
23
+ const s = t.has("value") && this.value !== this._lastValue;
24
+ !this.hasUpdated || s ? (this._chars = Array.from({ length: this.length }, (e, h) => this.value[h] ?? ""), this._lastValue = this.value, this._wasFull = this._chars.length > 0 && this._chars.every((e) => e !== "")) : this._chars.length !== this.length && (this._chars = Array.from({ length: this.length }, (e, h) => this._chars[h] ?? ""));
25
+ }
26
+ /** Writes `text` into `_chars` starting at `start`. Returns the index just
27
+ * past the last box written (may equal `this.length`). */
28
+ fill(t, s) {
29
+ let e = t;
30
+ for (const h of s) {
31
+ if (e >= this.length) break;
32
+ this._chars[e] = h, e += 1;
33
+ }
34
+ return e;
35
+ }
36
+ commit() {
37
+ const t = this._chars.join("").slice(0, this.length);
38
+ this.value = t, this._lastValue = t, this.requestUpdate(), this.emit("baht-change", { value: this.value });
39
+ const s = this._chars.length > 0 && this._chars.every((e) => e !== "");
40
+ s && !this._wasFull && this.emit("baht-otp-complete", { value: this.value }), this._wasFull = s;
41
+ }
42
+ onInput(t, s) {
43
+ var a, r;
44
+ const e = s.target, h = this.clean(e.value);
45
+ if (h.length > 1) {
46
+ const u = this.fill(t, h);
47
+ e.value = this._chars[t] ?? "", this.commit(), (a = this.inputs()[Math.min(u, this.length - 1)]) == null || a.focus();
48
+ return;
49
+ }
50
+ const i = h.slice(-1);
51
+ e.value = i, this._chars[t] = i, this.commit(), i && t < this.length - 1 && ((r = this.inputs()[t + 1]) == null || r.focus());
52
+ }
53
+ onKeydown(t, s) {
54
+ var e;
55
+ s.key === "Backspace" && !this._chars[t] && t > 0 && (this._chars[t - 1] = "", this.commit(), (e = this.inputs()[t - 1]) == null || e.focus(), s.preventDefault());
56
+ }
57
+ onPaste(t) {
58
+ var h, i;
59
+ t.preventDefault();
60
+ const s = this.clean(((h = t.clipboardData) == null ? void 0 : h.getData("text")) ?? "").slice(0, this.length);
61
+ if (!s) return;
62
+ const e = this.fill(0, s);
63
+ this.commit(), (i = this.inputs()[Math.min(e, this.length - 1)]) == null || i.focus();
64
+ }
65
+ render() {
66
+ return c`<div class="baht-otp" role="group" aria-label=${this.label} @paste=${(t) => {
67
+ this.onPaste(t);
68
+ }}>
69
+ ${this._chars.map(
70
+ (t, s) => c`<input
71
+ type="text"
72
+ inputmode=${this.mode === "numeric" ? "numeric" : "text"}
73
+ maxlength="1"
74
+ autocomplete=${s === 0 ? "one-time-code" : "off"}
75
+ aria-label=${m("otpCharacter", { i: s + 1, n: this.length })}
76
+ .value=${t}
77
+ ?disabled=${this.disabled}
78
+ @input=${(e) => {
79
+ this.onInput(s, e);
80
+ }}
81
+ @keydown=${(e) => {
82
+ this.onKeydown(s, e);
83
+ }}
84
+ />`
85
+ )}
86
+ </div>`;
87
+ }
88
+ };
89
+ n([
90
+ o({ type: Number })
91
+ ], l.prototype, "length", 2);
92
+ n([
93
+ o()
94
+ ], l.prototype, "value", 2);
95
+ n([
96
+ o({ type: Boolean })
97
+ ], l.prototype, "disabled", 2);
98
+ n([
99
+ o()
100
+ ], l.prototype, "mode", 2);
101
+ n([
102
+ o()
103
+ ], l.prototype, "label", 2);
104
+ l = n([
105
+ f("baht-otp")
106
+ ], l);
107
+ export {
108
+ l as BahtOtp
109
+ };
@@ -0,0 +1,43 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * The top of a page: a way back, the title, what the page is for and its actions. Children are the
5
+ * actions; a child with `data-slot="meta"` goes under the description, and one with
6
+ * `data-slot="art"` (a sticker, an illustration) at the end of the header, after the actions.
7
+ * `art-position="start"` leads with the art instead: two columns, the art beside the text with the
8
+ * actions under it, one column when the window is narrow (the art's track is
9
+ * `--baht-page-header-art-size`, by default `minmax(180px, 28%)`). `size="lg"` sets a larger title
10
+ * and more room, for a landing page's hero.
11
+ *
12
+ * <baht-page-header heading="Assets" description="Hardware the bank owns" back-label="Admin" back-href="/admin">
13
+ * <baht-button variant="primary">New asset</baht-button>
14
+ * </baht-page-header>
15
+ *
16
+ * @fires {CustomEvent<{ href: string }>} baht-back - The back link was pressed. Cancelable: `preventDefault()` to route yourself.
17
+ */
18
+ export declare class BahtPageHeader extends BahtElement {
19
+ heading: string;
20
+ description: string;
21
+ /** Small line above the title. */
22
+ eyebrow: string;
23
+ backLabel: string;
24
+ backHref: string;
25
+ /** `'md'` (default) or `'lg'`: a larger title and more room (a hero). */
26
+ size: 'md' | 'lg';
27
+ /**
28
+ * Where a `data-slot="art"` child sits: `'end'` (default, after the actions) or `'start'` (first,
29
+ * in a column of its own beside the text and the actions).
30
+ */
31
+ artPosition: 'end' | 'start';
32
+ private actionsEl;
33
+ private metaEl;
34
+ private artEl;
35
+ private headerEl;
36
+ protected adoptChildren(): void;
37
+ protected render(): TemplateResult;
38
+ }
39
+ declare global {
40
+ interface HTMLElementTagNameMap {
41
+ 'baht-page-header': BahtPageHeader;
42
+ }
43
+ }
@@ -0,0 +1,78 @@
1
+ import { nothing as d, html as p } from "lit";
2
+ import { property as r, query as b } from "lit/decorators.js";
3
+ import { BahtElement as n, adoptSlotted as g, hasSlotted as f, routeClick as m } from "../base.js";
4
+ import { isSafeUrl as y } from "@20baht/engine";
5
+ import { customElement as u } from "../define.js";
6
+ var v = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, t = (s, h, i, o) => {
7
+ for (var a = o > 1 ? void 0 : o ? $(h, i) : h, c = s.length - 1, l; c >= 0; c--)
8
+ (l = s[c]) && (a = (o ? l(h, i, a) : l(a)) || a);
9
+ return o && a && v(h, i, a), a;
10
+ };
11
+ let e = class extends n {
12
+ constructor() {
13
+ super(...arguments), this.heading = "", this.description = "", this.eyebrow = "", this.backLabel = "", this.backHref = "", this.size = "md", this.artPosition = "end";
14
+ }
15
+ adoptChildren() {
16
+ g(this, this.actionsEl, { meta: this.metaEl, art: this.artEl }), this.headerEl.classList.toggle("baht-page-header--art", f(this.artEl));
17
+ }
18
+ render() {
19
+ const s = this.backHref && y(this.backHref) ? this.backHref : "", h = `baht-page-header${this.size === "lg" ? " baht-page-header--lg" : ""}${this.artPosition === "start" ? " baht-page-header--art-start" : ""}`;
20
+ return p`<header class=${h}>
21
+ <div class="baht-page-header-text">
22
+ ${this.backLabel && s ? p`<a
23
+ class="baht-page-header-back"
24
+ href=${s}
25
+ @click=${(i) => {
26
+ m(this, "baht-back", i, { href: s });
27
+ }}
28
+ >← ${this.backLabel}</a
29
+ >` : d}
30
+ ${this.eyebrow ? p`<span class="baht-page-header-eyebrow">${this.eyebrow}</span>` : d}
31
+ <h1 class="baht-page-header-title">${this.heading}</h1>
32
+ ${this.description ? p`<p class="baht-page-header-description">${this.description}</p>` : d}
33
+ <div class="baht-page-header-meta"></div>
34
+ </div>
35
+ <div class="baht-page-header-actions"></div>
36
+ <div class="baht-page-header-art"></div>
37
+ </header>`;
38
+ }
39
+ };
40
+ t([
41
+ r()
42
+ ], e.prototype, "heading", 2);
43
+ t([
44
+ r()
45
+ ], e.prototype, "description", 2);
46
+ t([
47
+ r()
48
+ ], e.prototype, "eyebrow", 2);
49
+ t([
50
+ r({ attribute: "back-label" })
51
+ ], e.prototype, "backLabel", 2);
52
+ t([
53
+ r({ attribute: "back-href" })
54
+ ], e.prototype, "backHref", 2);
55
+ t([
56
+ r({ reflect: !0 })
57
+ ], e.prototype, "size", 2);
58
+ t([
59
+ r({ attribute: "art-position", reflect: !0 })
60
+ ], e.prototype, "artPosition", 2);
61
+ t([
62
+ b(".baht-page-header-actions")
63
+ ], e.prototype, "actionsEl", 2);
64
+ t([
65
+ b(".baht-page-header-meta")
66
+ ], e.prototype, "metaEl", 2);
67
+ t([
68
+ b(".baht-page-header-art")
69
+ ], e.prototype, "artEl", 2);
70
+ t([
71
+ b(".baht-page-header")
72
+ ], e.prototype, "headerEl", 2);
73
+ e = t([
74
+ u("baht-page-header")
75
+ ], e);
76
+ export {
77
+ e as BahtPageHeader
78
+ };
@@ -0,0 +1,33 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * Server-side pagination control: it never slices data — it only reports the
5
+ * page the user asked for via `baht-page-change`; the host fetches that page.
6
+ *
7
+ * <baht-pagination page="4" total-pages="20"></baht-pagination>
8
+ * <baht-pagination variant="compact" page="1" total-pages="3"></baht-pagination>
9
+ *
10
+ * `variant="cursor"` drops page numbers entirely — the host doesn't know a
11
+ * total, only whether another page exists in either direction:
12
+ *
13
+ * <baht-pagination variant="cursor" has-next has-prev></baht-pagination>
14
+ * el.addEventListener('baht-cursor-change', (e) => fetchPage(e.detail.direction));
15
+ * @fires {CustomEvent<{ page: number }>} baht-page-change - A page was picked.
16
+ * @fires {CustomEvent<{ direction: 'next' | 'prev' }>} baht-cursor-change - Cursor mode: next or previous was pressed.
17
+ */
18
+ export declare class BahtPagination extends BahtElement {
19
+ page: number;
20
+ totalPages: number;
21
+ /** 'numbered' = 1 … 4 5 6 … 20 · 'compact' = « Page 4 of 20 · 'cursor' = « Prev / Next » */
22
+ variant: 'numbered' | 'compact' | 'cursor';
23
+ /** Numbered pages shown on each side of the current page. */
24
+ siblings: number;
25
+ /** cursor variant only — whether a next/previous page is available. */
26
+ hasNext: boolean;
27
+ hasPrev: boolean;
28
+ private go;
29
+ private goCursor;
30
+ /** Visible page numbers with `null` marking an ellipsis gap. */
31
+ private get pageItems();
32
+ protected render(): TemplateResult;
33
+ }
@@ -0,0 +1,86 @@
1
+ import { html as u, nothing as b } from "lit";
2
+ import { property as l } from "lit/decorators.js";
3
+ import { BahtElement as c } from "../base.js";
4
+ import { customElement as m } from "../define.js";
5
+ var v = Object.defineProperty, f = Object.getOwnPropertyDescriptor, h = (t, a, e, p) => {
6
+ for (var r = p > 1 ? void 0 : p ? f(a, e) : a, n = t.length - 1, i; n >= 0; n--)
7
+ (i = t[n]) && (r = (p ? i(a, e, r) : i(r)) || r);
8
+ return p && r && v(a, e, r), r;
9
+ };
10
+ let o = class extends c {
11
+ constructor() {
12
+ super(...arguments), this.page = 1, this.totalPages = 1, this.variant = "numbered", this.siblings = 1, this.hasNext = !1, this.hasPrev = !1;
13
+ }
14
+ go(t) {
15
+ const a = Math.min(Math.max(1, t), this.totalPages);
16
+ a !== this.page && this.emit("baht-page-change", { page: a });
17
+ }
18
+ goCursor(t) {
19
+ t === "next" && !this.hasNext || t === "prev" && !this.hasPrev || this.emit("baht-cursor-change", { direction: t });
20
+ }
21
+ /** Visible page numbers with `null` marking an ellipsis gap. */
22
+ get pageItems() {
23
+ const { page: t, totalPages: a, siblings: e } = this, p = /* @__PURE__ */ new Set([1, a]);
24
+ for (let s = t - e; s <= t + e; s++)
25
+ s >= 1 && s <= a && p.add(s);
26
+ const r = [...p].sort((s, g) => s - g), n = [];
27
+ let i = 0;
28
+ for (const s of r)
29
+ i && s - i === 2 ? n.push(i + 1) : i && s - i > 2 && n.push(null), n.push(s), i = s;
30
+ return n;
31
+ }
32
+ render() {
33
+ if (this.variant === "cursor")
34
+ return u`<nav class="baht-pagination baht-pagination--cursor" aria-label="Pagination">
35
+ <button type="button" ?disabled=${!this.hasPrev} @click=${() => {
36
+ this.goCursor("prev");
37
+ }}><span aria-hidden="true">« </span>Prev</button>
38
+ <button type="button" ?disabled=${!this.hasNext} @click=${() => {
39
+ this.goCursor("next");
40
+ }}>Next<span aria-hidden="true"> »</span></button>
41
+ </nav>`;
42
+ const t = this.page <= 1, a = this.page >= this.totalPages;
43
+ return u`<nav class="baht-pagination" aria-label="Pagination">
44
+ <button type="button" aria-label="Previous page" ?disabled=${t} @click=${() => {
45
+ this.go(this.page - 1);
46
+ }}><span aria-hidden="true">«</span></button>
47
+ ${this.variant === "compact" ? u`<span class="baht-pagination-label">Page ${this.page} of ${this.totalPages}</span>` : this.pageItems.map(
48
+ (e) => e === null ? u`<span class="baht-pagination-ellipsis" aria-hidden="true">…</span>` : u`<button
49
+ type="button"
50
+ aria-current=${e === this.page ? "page" : b}
51
+ aria-label="Page ${e}"
52
+ @click=${() => {
53
+ this.go(e);
54
+ }}
55
+ >${e}</button>`
56
+ )}
57
+ <button type="button" aria-label="Next page" ?disabled=${a} @click=${() => {
58
+ this.go(this.page + 1);
59
+ }}><span aria-hidden="true">»</span></button>
60
+ </nav>`;
61
+ }
62
+ };
63
+ h([
64
+ l({ type: Number })
65
+ ], o.prototype, "page", 2);
66
+ h([
67
+ l({ type: Number, attribute: "total-pages" })
68
+ ], o.prototype, "totalPages", 2);
69
+ h([
70
+ l()
71
+ ], o.prototype, "variant", 2);
72
+ h([
73
+ l({ type: Number })
74
+ ], o.prototype, "siblings", 2);
75
+ h([
76
+ l({ type: Boolean, attribute: "has-next" })
77
+ ], o.prototype, "hasNext", 2);
78
+ h([
79
+ l({ type: Boolean, attribute: "has-prev" })
80
+ ], o.prototype, "hasPrev", 2);
81
+ o = h([
82
+ m("baht-pagination")
83
+ ], o);
84
+ export {
85
+ o as BahtPagination
86
+ };
@@ -0,0 +1,45 @@
1
+ import { PropertyValues, TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ export type PopoverPlacement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end';
4
+ /**
5
+ * A floating panel anchored to a trigger — filters, a quick-edit form, a hover card you click
6
+ * open. While open it is drawn in the top layer (`floatPanel`), so a modal body, a table or any
7
+ * `overflow` container cannot cut it off; `placement` is where it asks to go, and it moves to the
8
+ * other side of the trigger when there is more room there. The FIRST child is the trigger; everything after it becomes the panel (a non-modal
9
+ * `role="dialog"`, named by `label`).
10
+ *
11
+ * <baht-popover label="Filters" placement="bottom-start">
12
+ * <baht-button variant="secondary" icon="search">Filters</baht-button>
13
+ * <baht-select …></baht-select>
14
+ * <baht-button size="sm">Apply</baht-button>
15
+ * </baht-popover>
16
+ *
17
+ * Clicking the trigger toggles it; opening moves focus to the first field in the panel
18
+ * (or the panel). Escape closes it and returns focus to the trigger (marked handled, so a
19
+ * surrounding `<baht-modal>` stays open); a click outside closes it too. `open` can also be
20
+ * set by the host. The trigger gets `aria-haspopup="dialog"`, `aria-expanded`, `aria-controls`.
21
+ *
22
+ * @fires {CustomEvent<{ open: boolean }>} baht-toggle - The user opened or closed it. `detail: { open }`.
23
+ */
24
+ export declare class BahtPopover extends BahtElement {
25
+ open: boolean;
26
+ /** Accessible name of the panel. */
27
+ label: string;
28
+ /** Where the panel sits relative to the trigger. */
29
+ placement: PopoverPlacement;
30
+ private anchorEl;
31
+ private panelEl;
32
+ constructor();
33
+ private get panelId();
34
+ /** The focusable element that opens the panel (inside the trigger child). */
35
+ private get trigger();
36
+ protected firstUpdated(): void;
37
+ private wireTrigger;
38
+ protected updated(changed: PropertyValues<this>): void;
39
+ connectedCallback(): void;
40
+ disconnectedCallback(): void;
41
+ private setOpen;
42
+ private readonly onDocMousedown;
43
+ private readonly onKeydown;
44
+ protected render(): TemplateResult;
45
+ }
@@ -0,0 +1,112 @@
1
+ import { nothing as u, html as f } from "lit";
2
+ import { property as d, query as c } from "lit/decorators.js";
3
+ import { BahtElement as m, hasDom as l } from "../base.js";
4
+ import { customElement as b } from "../define.js";
5
+ import { floatPanel as v } from "../floating.js";
6
+ var g = Object.defineProperty, E = Object.getOwnPropertyDescriptor, r = (e, n, o, t) => {
7
+ for (var s = t > 1 ? void 0 : t ? E(n, o) : n, a = e.length - 1, p; a >= 0; a--)
8
+ (p = e[a]) && (s = (t ? p(n, o, s) : p(s)) || s);
9
+ return t && s && g(n, o, s), s;
10
+ };
11
+ const w = [
12
+ "bottom-start",
13
+ "bottom-end",
14
+ "top-start",
15
+ "top-end"
16
+ ], h = 'button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
17
+ let i = class extends m {
18
+ constructor() {
19
+ super(), this.open = !1, this.label = "", this.placement = "bottom-start", this.onDocMousedown = (e) => {
20
+ (!(e.target instanceof Node) || !this.contains(e.target)) && this.setOpen(!1, !1);
21
+ }, this.onKeydown = (e) => {
22
+ e.key === "Escape" && this.open && (e.preventDefault(), this.setOpen(!1, !0));
23
+ }, v(this, {
24
+ panel: ".baht-popover-panel",
25
+ gap: 6,
26
+ where: () => ({
27
+ end: this.placement.endsWith("-end"),
28
+ above: this.placement.startsWith("top-")
29
+ })
30
+ });
31
+ }
32
+ get panelId() {
33
+ return `baht-popover-${this.uid}`;
34
+ }
35
+ /** The focusable element that opens the panel (inside the trigger child). */
36
+ get trigger() {
37
+ const e = this.anchorEl.firstElementChild;
38
+ return e instanceof HTMLElement ? e.matches(h) ? e : e.querySelector(h) ?? e : null;
39
+ }
40
+ firstUpdated() {
41
+ let e = this.panelEl;
42
+ for (; e.parentNode && e.parentNode !== this; ) e = e.parentNode;
43
+ const n = Array.from(this.childNodes).filter(
44
+ (t) => t !== e && t.nodeType !== Node.COMMENT_NODE
45
+ ), o = n.find((t) => t instanceof Element);
46
+ o && this.anchorEl.append(o), this.panelEl.append(...n.filter((t) => t !== o)), this.wireTrigger(), setTimeout(() => {
47
+ this.isConnected && this.wireTrigger();
48
+ }, 0);
49
+ }
50
+ wireTrigger() {
51
+ const e = this.trigger;
52
+ e && (e.setAttribute("aria-haspopup", "dialog"), e.setAttribute("aria-expanded", this.open ? "true" : "false"), e.setAttribute("aria-controls", this.panelId));
53
+ }
54
+ updated(e) {
55
+ if (e.has("open")) {
56
+ if (this.wireTrigger(), !l()) return;
57
+ this.open ? document.addEventListener("mousedown", this.onDocMousedown) : document.removeEventListener("mousedown", this.onDocMousedown);
58
+ }
59
+ }
60
+ connectedCallback() {
61
+ super.connectedCallback(), this.open && l() && document.addEventListener("mousedown", this.onDocMousedown);
62
+ }
63
+ disconnectedCallback() {
64
+ l() && document.removeEventListener("mousedown", this.onDocMousedown), super.disconnectedCallback();
65
+ }
66
+ setOpen(e, n) {
67
+ this.open !== e && (this.open = e, this.emit("baht-toggle", { open: e }), n && this.updateComplete.then(() => {
68
+ var o;
69
+ e ? (this.panelEl.querySelector(h) ?? this.panelEl).focus() : (o = this.trigger) == null || o.focus();
70
+ }));
71
+ }
72
+ render() {
73
+ const e = w.includes(this.placement) ? this.placement : "bottom-start";
74
+ return f`<div class="baht-popover" @keydown=${this.onKeydown}>
75
+ <div
76
+ class="baht-popover-anchor"
77
+ @click=${() => {
78
+ this.setOpen(!this.open, !0);
79
+ }}
80
+ ></div>
81
+ <div
82
+ class="baht-popover-panel baht-popover-panel--${e}"
83
+ role="dialog"
84
+ id=${this.panelId}
85
+ aria-label=${this.label || u}
86
+ tabindex="-1"
87
+ ?hidden=${!this.open}
88
+ ></div>
89
+ </div>`;
90
+ }
91
+ };
92
+ r([
93
+ d({ type: Boolean, reflect: !0 })
94
+ ], i.prototype, "open", 2);
95
+ r([
96
+ d()
97
+ ], i.prototype, "label", 2);
98
+ r([
99
+ d()
100
+ ], i.prototype, "placement", 2);
101
+ r([
102
+ c(".baht-popover-anchor")
103
+ ], i.prototype, "anchorEl", 2);
104
+ r([
105
+ c(".baht-popover-panel")
106
+ ], i.prototype, "panelEl", 2);
107
+ i = r([
108
+ b("baht-popover")
109
+ ], i);
110
+ export {
111
+ i as BahtPopover
112
+ };
@@ -0,0 +1,22 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ export type ProgressRingTone = 'primary' | 'success' | 'warning' | 'danger';
4
+ /**
5
+ * Circular single-value "percent used" ring — the round counterpart to
6
+ * `<baht-progress>`'s linear bar. Center shows the rounded percentage; an
7
+ * optional caption reads what it's a percentage of.
8
+ *
9
+ * <baht-progress-ring value="80" label="of budget used"></baht-progress-ring>
10
+ */
11
+ export declare class BahtProgressRing extends BahtElement {
12
+ /** Percent used, 0 to 100 (clamped), not a fraction: `80` reads "80%". */
13
+ value: number;
14
+ tone: ProgressRingTone;
15
+ /** Caption under the percentage, e.g. "of budget used". */
16
+ label: string;
17
+ /** Rendered pixel size (square). */
18
+ size: number;
19
+ private static readonly R;
20
+ private static readonly STROKE;
21
+ protected render(): TemplateResult;
22
+ }
@@ -0,0 +1,62 @@
1
+ import { svg as c, html as p } from "lit";
2
+ import { property as l } from "lit/decorators.js";
3
+ import { BahtElement as g } from "../base.js";
4
+ import { customElement as m } from "../define.js";
5
+ var b = Object.defineProperty, v = Object.getOwnPropertyDescriptor, i = (o, e, s, a) => {
6
+ for (var r = a > 1 ? void 0 : a ? v(e, s) : e, h = o.length - 1, n; h >= 0; h--)
7
+ (n = o[h]) && (r = (a ? n(e, s, r) : n(r)) || r);
8
+ return a && r && b(e, s, r), r;
9
+ };
10
+ let t = class extends g {
11
+ constructor() {
12
+ super(...arguments), this.value = 0, this.tone = "primary", this.label = "", this.size = 112;
13
+ }
14
+ render() {
15
+ const o = t.R, e = 2 * Math.PI * o, s = Math.max(0, Math.min(100, this.value)), a = `${s / 100 * e} ${e}`, r = `${Math.round(s)}%${this.label ? ` ${this.label}` : ""}`;
16
+ return p`<div class="baht-progress-ring baht-progress-ring--${this.tone}">
17
+ <svg width=${this.size} height=${this.size} viewBox="0 0 120 120" role="img" aria-label=${r}>
18
+ <circle
19
+ class="baht-progress-ring-track"
20
+ cx="60"
21
+ cy="60"
22
+ r=${o}
23
+ fill="none"
24
+ stroke-width=${t.STROKE}
25
+ ></circle>
26
+ <circle
27
+ class="baht-progress-ring-fill"
28
+ cx="60"
29
+ cy="60"
30
+ r=${o}
31
+ fill="none"
32
+ stroke-width=${t.STROKE}
33
+ stroke-linecap="round"
34
+ stroke-dasharray=${a}
35
+ transform="rotate(-90 60 60)"
36
+ ></circle>
37
+ <text x="60" y="56" text-anchor="middle" class="baht-progress-ring-value">${Math.round(s)}%</text>
38
+ ${this.label ? c`<text x="60" y="74" text-anchor="middle" class="baht-progress-ring-label">${this.label}</text>` : ""}
39
+ </svg>
40
+ </div>`;
41
+ }
42
+ };
43
+ t.R = 48;
44
+ t.STROKE = 12;
45
+ i([
46
+ l({ type: Number })
47
+ ], t.prototype, "value", 2);
48
+ i([
49
+ l()
50
+ ], t.prototype, "tone", 2);
51
+ i([
52
+ l()
53
+ ], t.prototype, "label", 2);
54
+ i([
55
+ l({ type: Number })
56
+ ], t.prototype, "size", 2);
57
+ t = i([
58
+ m("baht-progress-ring")
59
+ ], t);
60
+ export {
61
+ t as BahtProgressRing
62
+ };
@@ -0,0 +1,17 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * Progress bar. `value` 0–100; omit (null) for indeterminate.
5
+ *
6
+ * <baht-progress value="65" show-label></baht-progress>
7
+ * <baht-progress></baht-progress> <!-- indeterminate -->
8
+ */
9
+ export declare class BahtProgress extends BahtElement {
10
+ /** Percent complete, 0 to 100 (clamped), not a fraction. `null` is indeterminate. */
11
+ value: number | null;
12
+ tone: 'primary' | 'success' | 'warning' | 'danger';
13
+ showLabel: boolean;
14
+ /** Accessible name for the progressbar. */
15
+ label: string;
16
+ protected render(): TemplateResult;
17
+ }
@@ -0,0 +1,48 @@
1
+ import { nothing as n, html as m } from "lit";
2
+ import { property as i } from "lit/decorators.js";
3
+ import { BahtElement as b } from "../base.js";
4
+ import { customElement as v } from "../define.js";
5
+ var u = Object.defineProperty, c = Object.getOwnPropertyDescriptor, o = (e, t, a, l) => {
6
+ for (var r = l > 1 ? void 0 : l ? c(t, a) : t, p = e.length - 1, h; p >= 0; p--)
7
+ (h = e[p]) && (r = (l ? h(t, a, r) : h(r)) || r);
8
+ return l && r && u(t, a, r), r;
9
+ };
10
+ let s = class extends b {
11
+ constructor() {
12
+ super(...arguments), this.value = null, this.tone = "primary", this.showLabel = !1, this.label = "Progress";
13
+ }
14
+ render() {
15
+ const e = this.value == null || Number.isNaN(this.value), t = e ? 0 : Math.min(100, Math.max(0, this.value)), a = this.tone === "primary" ? "" : ` baht-progress--${this.tone}`;
16
+ return m`<div>
17
+ <div
18
+ class="baht-progress${a}${e ? " baht-progress--indeterminate" : ""}"
19
+ role="progressbar"
20
+ aria-label=${this.label}
21
+ aria-valuemin="0"
22
+ aria-valuemax="100"
23
+ aria-valuenow=${e ? n : t}
24
+ >
25
+ <div class="baht-progress-bar" style=${e ? n : `width:${t}%`}></div>
26
+ </div>
27
+ ${this.showLabel && !e ? m`<div class="baht-progress-label">${t}%</div>` : n}
28
+ </div>`;
29
+ }
30
+ };
31
+ o([
32
+ i({ type: Number })
33
+ ], s.prototype, "value", 2);
34
+ o([
35
+ i()
36
+ ], s.prototype, "tone", 2);
37
+ o([
38
+ i({ type: Boolean, attribute: "show-label" })
39
+ ], s.prototype, "showLabel", 2);
40
+ o([
41
+ i()
42
+ ], s.prototype, "label", 2);
43
+ s = o([
44
+ v("baht-progress")
45
+ ], s);
46
+ export {
47
+ s as BahtProgress
48
+ };
@@ -0,0 +1,7 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtFieldBase } from '../field-base.js';
3
+ export declare class BahtRadio extends BahtFieldBase {
4
+ private renderOption;
5
+ private renderCardOption;
6
+ protected renderControl(): TemplateResult;
7
+ }