@20baht/ui 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +512 -2
  3. package/dist/components/baht-form.d.ts +206 -0
  4. package/dist/components/baht-form.js +630 -0
  5. package/dist/components/baht-workflow.d.ts +187 -0
  6. package/dist/components/baht-workflow.js +455 -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 +45172 -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,101 @@
1
+ import { html as b } from "lit";
2
+ import { property as n } from "lit/decorators.js";
3
+ import { BahtElement as d, hasDom as m } from "../base.js";
4
+ import { customElement as p } from "../define.js";
5
+ import { t as f } from "@20baht/engine";
6
+ import { renderIcon as u } from "./icons.js";
7
+ var y = Object.defineProperty, v = Object.getOwnPropertyDescriptor, o = (t, e, r, s) => {
8
+ for (var h = s > 1 ? void 0 : s ? v(e, r) : e, l = t.length - 1, c; l >= 0; l--)
9
+ (c = t[l]) && (h = (s ? c(e, r, h) : c(h)) || h);
10
+ return s && h && y(e, r, h), h;
11
+ };
12
+ const a = "data-baht-theme", g = (t) => t === "light" || t === "dark";
13
+ let i = class extends d {
14
+ constructor() {
15
+ super(...arguments), this.theme = "light", this.default = "light", this.target = "", this.storageKey = "baht-theme", this.targetEl = null, this.observer = null;
16
+ }
17
+ connectedCallback() {
18
+ super.connectedCallback(), m() && this.attachTarget();
19
+ }
20
+ disconnectedCallback() {
21
+ var t;
22
+ (t = this.observer) == null || t.disconnect(), this.observer = null, super.disconnectedCallback();
23
+ }
24
+ willUpdate(t) {
25
+ t.has("target") && t.get("target") !== void 0 && this.isConnected && m() && this.attachTarget();
26
+ }
27
+ updated(t) {
28
+ t.has("theme") && this.targetEl && this.targetEl.getAttribute(a) !== this.theme && this.targetEl.setAttribute(a, this.theme);
29
+ }
30
+ attachTarget() {
31
+ var r;
32
+ (r = this.observer) == null || r.disconnect();
33
+ const t = this.target ? document.querySelector(this.target) : null;
34
+ this.target && !t && console.warn(`[bahtui] theme toggle target "${this.target}" not found — using <html>`);
35
+ const e = t ?? document.documentElement;
36
+ this.targetEl = e, this.theme = this.initialTheme(e), e.getAttribute(a) !== this.theme && e.setAttribute(a, this.theme), this.observer = new MutationObserver(() => {
37
+ const s = e.getAttribute(a);
38
+ g(s) && s !== this.theme && (this.theme = s);
39
+ }), this.observer.observe(e, { attributes: !0, attributeFilter: [a] });
40
+ }
41
+ initialTheme(t) {
42
+ const e = this.read();
43
+ if (g(e)) return e;
44
+ const r = t.getAttribute(a);
45
+ return g(r) ? r : this.default === "system" ? typeof window.matchMedia == "function" && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : this.default === "dark" ? "dark" : "light";
46
+ }
47
+ read() {
48
+ if (!this.storageKey) return null;
49
+ try {
50
+ return localStorage.getItem(this.storageKey);
51
+ } catch {
52
+ return null;
53
+ }
54
+ }
55
+ save(t) {
56
+ if (this.storageKey)
57
+ try {
58
+ localStorage.setItem(this.storageKey, t);
59
+ } catch {
60
+ }
61
+ }
62
+ /** Flip light ↔ dark, save it and fire `baht-theme-change` (what a click does). */
63
+ toggle() {
64
+ var e;
65
+ const t = this.theme === "dark" ? "light" : "dark";
66
+ this.theme = t, (e = this.targetEl) == null || e.setAttribute(a, t), this.save(t), this.emit("baht-theme-change", { theme: t });
67
+ }
68
+ render() {
69
+ const t = this.theme === "dark";
70
+ return b`<button
71
+ type="button"
72
+ class="baht-button baht-button--ghost baht-button--icon baht-theme-toggle"
73
+ aria-label=${f("darkTheme")}
74
+ aria-pressed=${t ? "true" : "false"}
75
+ @click=${() => {
76
+ this.toggle();
77
+ }}
78
+ >
79
+ <span class="baht-theme-toggle-icon baht-theme-toggle-icon--sun">${u("sun")}</span>
80
+ <span class="baht-theme-toggle-icon baht-theme-toggle-icon--moon">${u("moon")}</span>
81
+ </button>`;
82
+ }
83
+ };
84
+ o([
85
+ n({ reflect: !0 })
86
+ ], i.prototype, "theme", 2);
87
+ o([
88
+ n()
89
+ ], i.prototype, "default", 2);
90
+ o([
91
+ n()
92
+ ], i.prototype, "target", 2);
93
+ o([
94
+ n({ attribute: "storage-key" })
95
+ ], i.prototype, "storageKey", 2);
96
+ i = o([
97
+ p("baht-theme-toggle")
98
+ ], i);
99
+ export {
100
+ i as BahtThemeToggle
101
+ };
@@ -0,0 +1,21 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ export interface TimelineItem {
4
+ title: string;
5
+ description?: string;
6
+ time?: string;
7
+ tone?: 'primary' | 'success' | 'warning' | 'danger' | 'muted';
8
+ }
9
+ /**
10
+ * Vertical timeline (run history, audit log).
11
+ *
12
+ * el.items = [
13
+ * { title: 'Run started', time: '09:12', tone: 'muted' },
14
+ * { title: 'Webhook sent', time: '09:12' },
15
+ * { title: 'Failed', description: "Couldn't reach the webhook.", time: '09:13', tone: 'danger' },
16
+ * ];
17
+ */
18
+ export declare class BahtTimeline extends BahtElement {
19
+ items: TimelineItem[];
20
+ protected render(): TemplateResult;
21
+ }
@@ -0,0 +1,42 @@
1
+ import { nothing as m, html as s } from "lit";
2
+ import { property as h } from "lit/decorators.js";
3
+ import { BahtElement as c } from "../base.js";
4
+ import { customElement as v } from "../define.js";
5
+ var d = Object.defineProperty, b = Object.getOwnPropertyDescriptor, p = (t, i, a, l) => {
6
+ for (var e = l > 1 ? void 0 : l ? b(i, a) : i, n = t.length - 1, r; n >= 0; n--)
7
+ (r = t[n]) && (e = (l ? r(i, a, e) : r(e)) || e);
8
+ return l && e && d(i, a, e), e;
9
+ };
10
+ let o = class extends c {
11
+ constructor() {
12
+ super(...arguments), this.items = [];
13
+ }
14
+ render() {
15
+ return s`<div class="baht-timeline" role="list">
16
+ ${this.items.map(
17
+ (t, i) => s`<div class="baht-timeline-item" role="listitem">
18
+ <div class="baht-timeline-rail">
19
+ <span class="baht-timeline-dot${t.tone && t.tone !== "primary" ? ` baht-timeline-dot--${t.tone}` : ""}"></span>
20
+ ${i < this.items.length - 1 ? s`<span class="baht-timeline-line"></span>` : m}
21
+ </div>
22
+ <div class="baht-timeline-main">
23
+ <div class="baht-timeline-title">
24
+ ${t.title}
25
+ ${t.time ? s`<span class="baht-timeline-time"> · ${t.time}</span>` : m}
26
+ </div>
27
+ ${t.description ? s`<div class="baht-timeline-desc">${t.description}</div>` : m}
28
+ </div>
29
+ </div>`
30
+ )}
31
+ </div>`;
32
+ }
33
+ };
34
+ p([
35
+ h({ attribute: !1 })
36
+ ], o.prototype, "items", 2);
37
+ o = p([
38
+ v("baht-timeline")
39
+ ], o);
40
+ export {
41
+ o as BahtTimeline
42
+ };
@@ -0,0 +1,29 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ export interface ToastOptions {
4
+ message: string;
5
+ tone?: 'neutral' | 'success' | 'warning' | 'danger' | 'info';
6
+ /** ms until auto-dismiss; 0 = sticky. */
7
+ duration?: number;
8
+ }
9
+ /**
10
+ * Toast host — put ONE <baht-toast> on the page and call show():
11
+ *
12
+ * const toast = document.querySelector('baht-toast');
13
+ * toast.show({ message: 'Saved.', tone: 'success' });
14
+ *
15
+ * Copy: short and dry ("Saved.", not "Successfully saved your changes!").
16
+ * @fires {CustomEvent<{ id: number; message: string }>} baht-dismiss - A toast was dismissed.
17
+ */
18
+ export declare class BahtToast extends BahtElement {
19
+ constructor();
20
+ /** Default auto-dismiss (ms) when show() gets no duration. */
21
+ duration: number;
22
+ private entries;
23
+ private static counter;
24
+ private timers;
25
+ show(options: ToastOptions): number;
26
+ dismiss(id: number): void;
27
+ disconnectedCallback(): void;
28
+ protected render(): TemplateResult;
29
+ }
@@ -0,0 +1,83 @@
1
+ import { nothing as h, html as l } from "lit";
2
+ import { property as u, state as d } from "lit/decorators.js";
3
+ import { BahtElement as c } from "../base.js";
4
+ import { afterExit as p } from "../motion.js";
5
+ import { t as b } from "@20baht/engine";
6
+ import { customElement as f } from "../define.js";
7
+ import { floatLayer as v } from "../floating.js";
8
+ var g = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, m = (t, e, r, i) => {
9
+ for (var s = i > 1 ? void 0 : i ? $(e, r) : e, o = t.length - 1, n; o >= 0; o--)
10
+ (n = t[o]) && (s = (i ? n(e, r, s) : n(s)) || s);
11
+ return i && s && g(e, r, s), s;
12
+ };
13
+ let a = class extends c {
14
+ constructor() {
15
+ super(), this.duration = 4e3, this.entries = [], this.timers = /* @__PURE__ */ new Map(), v(this, {
16
+ layer: ".baht-toaster",
17
+ shown: (t) => t.childElementCount > 0,
18
+ keepOnTop: !0
19
+ });
20
+ }
21
+ show(t) {
22
+ const e = {
23
+ id: ++a.counter,
24
+ message: t.message,
25
+ tone: t.tone ?? "neutral",
26
+ duration: t.duration ?? this.duration
27
+ };
28
+ return this.entries = [...this.entries, e], e.duration > 0 && this.timers.set(
29
+ e.id,
30
+ setTimeout(() => {
31
+ this.dismiss(e.id);
32
+ }, e.duration)
33
+ ), e.id;
34
+ }
35
+ dismiss(t) {
36
+ const e = this.entries.find((s) => s.id === t);
37
+ if (!e || e.leaving) return;
38
+ clearTimeout(this.timers.get(t)), this.timers.delete(t), this.entries = this.entries.map((s) => s.id === t ? { ...s, leaving: !0 } : s), this.emit("baht-dismiss", { id: t, message: e.message });
39
+ const r = () => {
40
+ this.entries = this.entries.filter((s) => s.id !== t);
41
+ }, i = this.querySelector(`.baht-toast[data-toast="${t}"]`);
42
+ if (!i) {
43
+ r();
44
+ return;
45
+ }
46
+ i.classList.add("baht-toast--leaving"), p(i, r);
47
+ }
48
+ disconnectedCallback() {
49
+ this.timers.forEach((t) => {
50
+ clearTimeout(t);
51
+ }), this.timers.clear(), super.disconnectedCallback();
52
+ }
53
+ render() {
54
+ return l`<div class="baht-toaster" role="status" aria-live="polite">
55
+ ${this.entries.map(
56
+ // Danger/warning interrupt (role=alert); the rest ride the polite container.
57
+ (t) => l`<div
58
+ class="baht-toast ${t.tone === "neutral" ? "" : `baht-toast--${t.tone}`}${t.leaving ? " baht-toast--leaving" : ""}"
59
+ data-toast=${t.id}
60
+ role=${t.tone === "danger" || t.tone === "warning" ? "alert" : h}
61
+ >
62
+ <span class="baht-toast-message">${t.message}</span>
63
+ <button type="button" class="baht-toast-dismiss" aria-label=${b("dismiss")} @click=${() => {
64
+ this.dismiss(t.id);
65
+ }}>×</button>
66
+ </div>`
67
+ )}
68
+ </div>`;
69
+ }
70
+ };
71
+ a.counter = 0;
72
+ m([
73
+ u({ type: Number })
74
+ ], a.prototype, "duration", 2);
75
+ m([
76
+ d()
77
+ ], a.prototype, "entries", 2);
78
+ a = m([
79
+ f("baht-toast")
80
+ ], a);
81
+ export {
82
+ a as BahtToast
83
+ };
@@ -0,0 +1,6 @@
1
+ import { nothing, TemplateResult } from 'lit';
2
+ import { BahtFieldBase } from '../field-base.js';
3
+ export declare class BahtToggle extends BahtFieldBase {
4
+ protected renderLabel(): typeof nothing;
5
+ protected renderControl(): TemplateResult;
6
+ }
@@ -0,0 +1,42 @@
1
+ import { nothing as h, html as n } from "lit";
2
+ import { live as c } from "lit/directives/live.js";
3
+ import { BahtFieldBase as d } from "../field-base.js";
4
+ import { customElement as b } from "../define.js";
5
+ var p = Object.getOwnPropertyDescriptor, g = (e, a, o, l) => {
6
+ for (var t = l > 1 ? void 0 : l ? p(a, o) : a, r = e.length - 1, s; r >= 0; r--)
7
+ (s = e[r]) && (t = s(t) || t);
8
+ return t;
9
+ };
10
+ let i = class extends d {
11
+ renderLabel() {
12
+ return h;
13
+ }
14
+ renderControl() {
15
+ return n`<label class="baht-control baht-control--toggle baht-option">
16
+ <input
17
+ type="checkbox"
18
+ role="switch"
19
+ id=${this.controlId}
20
+ aria-checked=${this.value === !0 ? "true" : "false"}
21
+ .checked=${c(this.value === !0)}
22
+ ?disabled=${this.disabled || this.readonly}
23
+ ?required=${this.required}
24
+ aria-invalid=${this.invalidAttr}
25
+ aria-describedby=${this.describedBy}
26
+ @change=${(e) => {
27
+ this.emitInput(e.target.checked);
28
+ }}
29
+ />
30
+ <span class="baht-toggle-track"><span class="baht-toggle-thumb"></span></span>
31
+ <span class="baht-label"
32
+ >${this.field.label}${this.renderLabelMark()}</span
33
+ >
34
+ </label>`;
35
+ }
36
+ };
37
+ i = g([
38
+ b("baht-toggle")
39
+ ], i);
40
+ export {
41
+ i as BahtToggle
42
+ };
@@ -0,0 +1,34 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * Hover/focus tooltip. Wraps its children; pure CSS show/hide (120ms fade). While shown it is
5
+ * drawn in the top layer (`floatTip`), so a scrolling or clipping container cannot cut it off.
6
+ * Escape hides it without moving focus (WCAG 1.4.13); it re-arms on leave/blur.
7
+ *
8
+ * <baht-tooltip text="Posted as JSON when the trigger fires">
9
+ * <baht-button variant="ghost" label="?"></baht-button>
10
+ * </baht-tooltip>
11
+ */
12
+ export declare class BahtTooltip extends BahtElement {
13
+ text: string;
14
+ position: 'top' | 'bottom' | 'left' | 'right';
15
+ private anchorEl;
16
+ private dismissed;
17
+ private describedTarget;
18
+ constructor();
19
+ private get tooltipId();
20
+ /**
21
+ * Point aria-describedby at the tooltip from the focusable child (light DOM,
22
+ * so the id reference works). No focusable child -> the anchor itself becomes
23
+ * one, so keyboard users can still surface the tooltip.
24
+ */
25
+ private wireDescribedBy;
26
+ private unwireDescribedBy;
27
+ disconnectedCallback(): void;
28
+ connectedCallback(): void;
29
+ protected adoptChildren(): void;
30
+ protected firstUpdated(): void;
31
+ private readonly onKeydown;
32
+ private readonly rearm;
33
+ protected render(): TemplateResult;
34
+ }
@@ -0,0 +1,85 @@
1
+ import { html as p } from "lit";
2
+ import { property as d, query as c, state as b } from "lit/decorators.js";
3
+ import { BahtElement as u, adoptLightChildren as m } from "../base.js";
4
+ import { customElement as f } from "../define.js";
5
+ import { floatTip as y } from "../floating.js";
6
+ var g = Object.defineProperty, w = Object.getOwnPropertyDescriptor, a = (t, e, i, h) => {
7
+ for (var s = h > 1 ? void 0 : h ? w(e, i) : e, n = t.length - 1, l; n >= 0; n--)
8
+ (l = t[n]) && (s = (h ? l(e, i, s) : l(s)) || s);
9
+ return h && s && g(e, i, s), s;
10
+ };
11
+ const o = "aria-describedby";
12
+ let r = class extends u {
13
+ constructor() {
14
+ super(), this.text = "", this.position = "top", this.dismissed = !1, this.describedTarget = null, this.onKeydown = (t) => {
15
+ t.key === "Escape" && (this.dismissed = !0);
16
+ }, this.rearm = () => {
17
+ this.dismissed = !1;
18
+ }, y(this, ".baht-tooltip");
19
+ }
20
+ get tooltipId() {
21
+ return `baht-tooltip-${this.uid}`;
22
+ }
23
+ /**
24
+ * Point aria-describedby at the tooltip from the focusable child (light DOM,
25
+ * so the id reference works). No focusable child -> the anchor itself becomes
26
+ * one, so keyboard users can still surface the tooltip.
27
+ */
28
+ wireDescribedBy() {
29
+ const t = this.anchorEl.querySelector(
30
+ "button, a[href], input, select, textarea, [tabindex]"
31
+ ), e = t ?? this.anchorEl;
32
+ this.describedTarget !== e && this.unwireDescribedBy();
33
+ const i = (e.getAttribute(o) ?? "").split(/\s+/).filter(Boolean);
34
+ i.includes(this.tooltipId) || i.push(this.tooltipId), e.setAttribute(o, i.join(" ")), this.describedTarget = e, t ? (this.anchorEl.removeAttribute("tabindex"), this.anchorEl.removeAttribute(o)) : this.anchorEl.setAttribute("tabindex", "0");
35
+ }
36
+ unwireDescribedBy() {
37
+ const t = this.describedTarget;
38
+ if (!t) return;
39
+ const e = (t.getAttribute(o) ?? "").split(/\s+/).filter((i) => i && i !== this.tooltipId);
40
+ e.length ? t.setAttribute(o, e.join(" ")) : t.removeAttribute(o), this.describedTarget = null;
41
+ }
42
+ disconnectedCallback() {
43
+ this.unwireDescribedBy(), super.disconnectedCallback();
44
+ }
45
+ connectedCallback() {
46
+ super.connectedCallback(), this.hasUpdated && this.wireDescribedBy();
47
+ }
48
+ adoptChildren() {
49
+ m(this, this.anchorEl);
50
+ }
51
+ firstUpdated() {
52
+ this.wireDescribedBy(), setTimeout(() => {
53
+ this.isConnected && this.wireDescribedBy();
54
+ }, 0);
55
+ }
56
+ render() {
57
+ return p`<span
58
+ class="baht-tooltip-host${this.dismissed ? " baht-tooltip-host--dismissed" : ""}"
59
+ @keydown=${this.onKeydown}
60
+ @mouseleave=${this.rearm}
61
+ @focusout=${this.rearm}
62
+ >
63
+ <span class="baht-tooltip-anchor"></span>
64
+ <span class="baht-tooltip baht-tooltip--${this.position}" id=${this.tooltipId} role="tooltip">${this.text}</span>
65
+ </span>`;
66
+ }
67
+ };
68
+ a([
69
+ d()
70
+ ], r.prototype, "text", 2);
71
+ a([
72
+ d()
73
+ ], r.prototype, "position", 2);
74
+ a([
75
+ c(".baht-tooltip-anchor")
76
+ ], r.prototype, "anchorEl", 2);
77
+ a([
78
+ b()
79
+ ], r.prototype, "dismissed", 2);
80
+ r = a([
81
+ f("baht-tooltip")
82
+ ], r);
83
+ export {
84
+ r as BahtTooltip
85
+ };
@@ -0,0 +1,58 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ export interface TreeNode {
4
+ /** Unique within the tree: what `selected` and the events name. */
5
+ id: string;
6
+ label: string;
7
+ /** A second, quieter line of text after the label (a head's name, a count). */
8
+ meta?: string;
9
+ /** A short badge at the end of the row. */
10
+ badge?: string;
11
+ children?: TreeNode[];
12
+ /** Start this node open (`true`) or closed (`false`); unset follows `collapsed`. */
13
+ open?: boolean;
14
+ }
15
+ /**
16
+ * Hierarchical tree (an org chart, folders, categories). `items` are the roots, each with
17
+ * optional `children`. Nodes with children start open unless `open: false`, or closed with
18
+ * `collapsed`. Click or Enter selects a row; the chevron opens and closes it. Keyboard
19
+ * follows the APG tree: Up/Down, Home/End, Right opens then enters, Left closes then climbs.
20
+ * `selected` is controlled by the host, like `<baht-tabs value>`.
21
+ *
22
+ * el.items = [
23
+ * { id: 'co', label: 'Company', meta: 'Somchai', badge: '3', children: [
24
+ * { id: 'eng', label: 'Engineering' },
25
+ * ] },
26
+ * ];
27
+ * el.addEventListener('baht-select', (e) => open(e.detail.id));
28
+ * @fires {CustomEvent<{ id: string; node: TreeNode }>} baht-select - A row was chosen.
29
+ * @fires {CustomEvent<{ id: string; open: boolean }>} baht-toggle - A node opened or closed.
30
+ */
31
+ export declare class BahtTree extends BahtElement {
32
+ /** The root nodes (property). */
33
+ items: TreeNode[];
34
+ /** Id of the selected node; null for none. */
35
+ selected: string | null;
36
+ /** Start every node closed unless it says `open: true`. */
37
+ collapsed: boolean;
38
+ /** Accessible name of the tree. */
39
+ label: string;
40
+ /** Shown when there are no items. */
41
+ emptyMessage: string;
42
+ private openSet;
43
+ /** The row that holds the tab stop when nothing visible is selected. */
44
+ private activeId;
45
+ /** Ids, children and `open` flags only, so an equal re-fed array keeps the user's toggles. */
46
+ private shapeFingerprint;
47
+ private static shape;
48
+ protected willUpdate(changed: Map<PropertyKey, unknown>): void;
49
+ /** The rows a reader sees now: every root, and the children of open nodes. */
50
+ private visibleRows;
51
+ /** Opens or closes a node with children. */
52
+ toggle(id: string, open?: boolean): void;
53
+ private select;
54
+ private focusRow;
55
+ private readonly onKeydown;
56
+ protected render(): TemplateResult;
57
+ private renderRow;
58
+ }
@@ -0,0 +1,159 @@
1
+ import { nothing as p, html as c } from "lit";
2
+ import { property as g, state as v } from "lit/decorators.js";
3
+ import { BahtElement as y, arr as h } from "../base.js";
4
+ import { renderIcon as S } from "./icons.js";
5
+ import { customElement as k } from "../define.js";
6
+ var I = Object.defineProperty, R = Object.getOwnPropertyDescriptor, d = (e, s, t, a) => {
7
+ for (var i = a > 1 ? void 0 : a ? R(s, t) : s, r = e.length - 1, o; r >= 0; r--)
8
+ (o = e[r]) && (i = (a ? o(s, t, i) : o(i)) || i);
9
+ return a && i && I(s, t, i), i;
10
+ };
11
+ let n = class extends y {
12
+ constructor() {
13
+ super(...arguments), this.items = [], this.selected = null, this.collapsed = !1, this.label = "", this.emptyMessage = "Nothing here yet.", this.openSet = /* @__PURE__ */ new Set(), this.activeId = null, this.shapeFingerprint = "", this.onKeydown = (e) => {
14
+ var b, f, m, u, $;
15
+ const s = this.visibleRows(), t = e.target instanceof HTMLElement ? e.target.dataset.id : void 0, a = s.findIndex((w) => w.node.id === t), i = s[a];
16
+ if (!i) return;
17
+ const r = h(i.node.children).length > 0, o = this.openSet.has(i.node.id);
18
+ let l;
19
+ switch (e.key) {
20
+ case "ArrowDown":
21
+ l = (b = s[a + 1]) == null ? void 0 : b.node.id;
22
+ break;
23
+ case "ArrowUp":
24
+ l = (f = s[a - 1]) == null ? void 0 : f.node.id;
25
+ break;
26
+ case "Home":
27
+ l = (m = s[0]) == null ? void 0 : m.node.id;
28
+ break;
29
+ case "End":
30
+ l = (u = s.at(-1)) == null ? void 0 : u.node.id;
31
+ break;
32
+ case "ArrowRight":
33
+ r && !o ? this.toggle(i.node.id, !0) : r && (l = ($ = s[a + 1]) == null ? void 0 : $.node.id);
34
+ break;
35
+ case "ArrowLeft":
36
+ r && o ? this.toggle(i.node.id, !1) : l = i.parentId;
37
+ break;
38
+ case "Enter":
39
+ case " ":
40
+ this.select(i.node);
41
+ break;
42
+ default:
43
+ return;
44
+ }
45
+ e.preventDefault(), l && this.focusRow(l);
46
+ };
47
+ }
48
+ static shape(e, s) {
49
+ const t = (a) => a.map((i) => [i.id, i.open ?? null, t(h(i.children))]);
50
+ return JSON.stringify([s, t(e)]);
51
+ }
52
+ willUpdate(e) {
53
+ if (!e.has("items") && !e.has("collapsed")) return;
54
+ const s = n.shape(h(this.items), this.collapsed);
55
+ if (s === this.shapeFingerprint) return;
56
+ this.shapeFingerprint = s;
57
+ const t = /* @__PURE__ */ new Set(), a = (i) => {
58
+ for (const r of i) {
59
+ const o = h(r.children);
60
+ o.length > 0 && (r.open ?? !this.collapsed) && t.add(r.id), a(o);
61
+ }
62
+ };
63
+ a(h(this.items)), this.openSet = t;
64
+ }
65
+ /** The rows a reader sees now: every root, and the children of open nodes. */
66
+ visibleRows() {
67
+ const e = [], s = (t, a, i) => {
68
+ t.forEach((r, o) => {
69
+ e.push({ node: r, depth: a, parentId: i, setsize: t.length, posinset: o + 1 }), this.openSet.has(r.id) && s(h(r.children), a + 1, r.id);
70
+ });
71
+ };
72
+ return s(h(this.items), 1, null), e;
73
+ }
74
+ /** Opens or closes a node with children. */
75
+ toggle(e, s = !this.openSet.has(e)) {
76
+ if (s === this.openSet.has(e)) return;
77
+ const t = new Set(this.openSet);
78
+ s ? t.add(e) : t.delete(e), this.openSet = t, this.emit("baht-toggle", { id: e, open: s });
79
+ }
80
+ select(e) {
81
+ this.activeId = e.id, e.id !== this.selected && (this.selected = e.id, this.emit("baht-select", { id: e.id, node: e }));
82
+ }
83
+ focusRow(e) {
84
+ var s;
85
+ this.activeId = e, (s = this.querySelector(`[role="treeitem"][data-id="${CSS.escape(e)}"]`)) == null || s.focus();
86
+ }
87
+ render() {
88
+ var t;
89
+ const e = this.visibleRows(), s = [this.selected, this.activeId].find((a) => e.some((i) => i.node.id === a)) ?? ((t = e[0]) == null ? void 0 : t.node.id);
90
+ return c`<div class="baht-tree">
91
+ <div class="baht-tree-list" role="tree" aria-label=${this.label || p}>
92
+ ${e.map((a) => this.renderRow(a, a.node.id === s))}
93
+ </div>
94
+ ${e.length === 0 ? c`<p class="baht-tree-empty">${this.emptyMessage}</p>` : p}
95
+ </div>`;
96
+ }
97
+ renderRow(e, s) {
98
+ const { node: t } = e, a = h(t.children).length > 0, i = this.openSet.has(t.id), r = t.id === this.selected;
99
+ return c`<div
100
+ class="baht-tree-row${r ? " baht-tree-row--selected" : ""}"
101
+ role="treeitem"
102
+ data-id=${t.id}
103
+ aria-level=${e.depth}
104
+ aria-setsize=${e.setsize}
105
+ aria-posinset=${e.posinset}
106
+ aria-expanded=${a ? String(i) : p}
107
+ aria-selected=${String(r)}
108
+ tabindex=${s ? "0" : "-1"}
109
+ aria-label=${[t.label, t.meta, t.badge].filter(Boolean).join(", ")}
110
+ style=${`--baht-tree-depth: ${String(e.depth - 1)}`}
111
+ @keydown=${this.onKeydown}
112
+ @click=${() => {
113
+ this.select(t);
114
+ }}
115
+ @focus=${() => {
116
+ this.activeId = t.id;
117
+ }}
118
+ >
119
+ ${a ? c`<span
120
+ class="baht-tree-toggle${i ? " baht-tree-toggle--open" : ""}"
121
+ aria-hidden="true"
122
+ @click=${(o) => {
123
+ o.stopPropagation(), this.toggle(t.id);
124
+ }}
125
+ >${S("chevron-right")}</span
126
+ >` : c`<span class="baht-tree-toggle baht-tree-toggle--leaf" aria-hidden="true"></span>`}
127
+ <span class="baht-tree-label">${t.label}</span>
128
+ ${t.meta ? c`<span class="baht-tree-meta">${t.meta}</span>` : p}
129
+ ${t.badge ? c`<span class="baht-tree-badge">${t.badge}</span>` : p}
130
+ </div>`;
131
+ }
132
+ };
133
+ d([
134
+ g({ attribute: !1 })
135
+ ], n.prototype, "items", 2);
136
+ d([
137
+ g({ reflect: !0 })
138
+ ], n.prototype, "selected", 2);
139
+ d([
140
+ g({ type: Boolean })
141
+ ], n.prototype, "collapsed", 2);
142
+ d([
143
+ g()
144
+ ], n.prototype, "label", 2);
145
+ d([
146
+ g({ attribute: "empty-message" })
147
+ ], n.prototype, "emptyMessage", 2);
148
+ d([
149
+ v()
150
+ ], n.prototype, "openSet", 2);
151
+ d([
152
+ v()
153
+ ], n.prototype, "activeId", 2);
154
+ n = d([
155
+ k("baht-tree")
156
+ ], n);
157
+ export {
158
+ n as BahtTree
159
+ };