@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,164 @@
1
+ import { nothing as a, html as h } from "lit";
2
+ import { property as c, query as m, state as f } from "lit/decorators.js";
3
+ import { boolOff as b, BahtElement as y, hasDom as p, adoptSlotted as v } from "../base.js";
4
+ import { afterExit as $ } from "../motion.js";
5
+ import { topLayer as g, dropLayer as u, pushLayer as C } from "../layers.js";
6
+ import { t as E } from "@20baht/engine";
7
+ import { renderIllustration as w } from "./illustrations.js";
8
+ import { customElement as q } from "../define.js";
9
+ import { floatLayer as S } from "../floating.js";
10
+ var k = Object.defineProperty, O = Object.getOwnPropertyDescriptor, r = (t, o, e, s) => {
11
+ for (var i = s > 1 ? void 0 : s ? O(o, e) : o, n = t.length - 1, d; n >= 0; n--)
12
+ (d = t[n]) && (i = (s ? d(o, e, i) : d(i)) || i);
13
+ return s && i && k(o, e, i), i;
14
+ };
15
+ const x = {
16
+ fromAttribute: (t) => t !== null && t !== "false",
17
+ toAttribute: (t) => t ? "" : null
18
+ };
19
+ let l = class extends y {
20
+ constructor() {
21
+ super(), this.open = !1, this.heading = "", this.description = "", this.showClose = !0, this.placement = "center", this.size = "md", this.closeOnScrim = !1, this.closing = !1, this.closeToken = 0, this.previousFocus = null, this.onKeydown = (t) => {
22
+ !this.open || g() !== this || (t.key === "Escape" ? t.defaultPrevented || this.requestClose("escape") : t.key === "Tab" && this.trapFocus(t));
23
+ }, S(this, {
24
+ layer: ".baht-modal-scrim",
25
+ shown: (t) => t.style.display !== "none"
26
+ });
27
+ }
28
+ get titleId() {
29
+ return `baht-modal-title-${this.uid}`;
30
+ }
31
+ get descriptionId() {
32
+ return `baht-modal-desc-${this.uid}`;
33
+ }
34
+ focusables() {
35
+ const t = this.querySelector(".baht-modal");
36
+ return t ? Array.from(
37
+ t.querySelectorAll(
38
+ 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
39
+ )
40
+ ).filter((o) => {
41
+ if (o.closest("[inert], [hidden]")) return !1;
42
+ for (let e = o; e && e !== t; e = e.parentElement) {
43
+ const s = getComputedStyle(e);
44
+ if (s.display === "none" || s.visibility === "hidden" || s.visibility === "collapse")
45
+ return !1;
46
+ }
47
+ return !0;
48
+ }) : [];
49
+ }
50
+ /** Keep Tab cycling inside the dialog (no keyboard escape to the page behind). */
51
+ trapFocus(t) {
52
+ const o = this.focusables(), e = this.querySelector(".baht-modal");
53
+ if (o.length === 0) {
54
+ e == null || e.focus(), t.preventDefault();
55
+ return;
56
+ }
57
+ const s = o[0], i = o[o.length - 1], n = document.activeElement;
58
+ if (!this.contains(n)) {
59
+ s.focus(), t.preventDefault();
60
+ return;
61
+ }
62
+ t.shiftKey && (n === s || n === e) ? (i.focus(), t.preventDefault()) : !t.shiftKey && n === i && (s.focus(), t.preventDefault());
63
+ }
64
+ connectedCallback() {
65
+ super.connectedCallback(), p() && document.addEventListener("keydown", this.onKeydown);
66
+ }
67
+ disconnectedCallback() {
68
+ p() && document.removeEventListener("keydown", this.onKeydown), u(this), super.disconnectedCallback();
69
+ }
70
+ willUpdate(t) {
71
+ t.has("open") && (this.open ? this.closing = !1 : t.get("open") === !0 && (this.closing = !0));
72
+ }
73
+ // After every render and whenever a framework host adds a child (base.ts): a form
74
+ // that mounts once its definition resolves, footer buttons swapped by an `@if`.
75
+ adoptChildren() {
76
+ v(this, this.bodyEl, { footer: this.footEl });
77
+ }
78
+ updated(t) {
79
+ var o;
80
+ if (t.has("open") && (this.open ? C : u)(this), t.has("open") && !this.open && this.closing) {
81
+ const e = ++this.closeToken, s = this.querySelector(".baht-modal-scrim"), i = () => {
82
+ e === this.closeToken && !this.open && (this.closing = !1);
83
+ };
84
+ s ? $(s, i) : i();
85
+ }
86
+ if (t.has("open") && this.open && (this.previousFocus = document.activeElement, (o = this.querySelector(".baht-modal")) == null || o.focus()), t.has("open") && !this.open && t.get("open") === !0) {
87
+ const e = this.previousFocus;
88
+ this.previousFocus = null, e != null && e.isConnected && (!document.activeElement || document.activeElement === document.body || this.contains(document.activeElement)) && e.focus();
89
+ }
90
+ }
91
+ /** Ask the host to close (the host owns `open`). */
92
+ requestClose(t = "button") {
93
+ this.emit("baht-close", { reason: t });
94
+ }
95
+ render() {
96
+ const t = this.placement === "sheet" || this.placement === "side" ? this.placement : void 0, o = this.size === "sm" || this.size === "lg" ? ` baht-modal--${this.size}` : "";
97
+ return h`<div
98
+ class="baht-modal-scrim${t ? ` baht-modal-scrim--${t}` : ""}${this.closing ? " baht-modal-scrim--closing" : ""}"
99
+ style=${this.open || this.closing ? a : "display:none"}
100
+ @click=${(e) => {
101
+ this.closeOnScrim && e.target === e.currentTarget && this.requestClose("scrim");
102
+ }}
103
+ >
104
+ <div
105
+ class="baht-modal${t ? ` baht-modal--${t}` : ""}${o}"
106
+ role="dialog"
107
+ aria-modal="true"
108
+ aria-labelledby=${this.heading ? this.titleId : a}
109
+ aria-label=${this.heading ? a : "Dialog"}
110
+ aria-describedby=${this.description ? this.descriptionId : a}
111
+ tabindex="-1"
112
+ >
113
+ ${t === "sheet" ? h`<div class="baht-modal-handle" aria-hidden="true"></div>` : a}
114
+ ${this.heading || this.description || this.showClose ? h`<header class="baht-modal-header">
115
+ <div class="baht-modal-heading">
116
+ <div class="baht-modal-title" id=${this.titleId}>${this.heading}</div>
117
+ ${this.description ? h`<p class="baht-modal-description" id=${this.descriptionId}>${this.description}</p>` : a}
118
+ </div>
119
+ ${this.showClose ? h`<button type="button" class="baht-modal-close" aria-label=${E("close")} @click=${() => {
120
+ this.requestClose("button");
121
+ }}>${w("cross-box")}</button>` : a}
122
+ </header>` : a}
123
+ <div class="baht-modal-body"></div>
124
+ <footer class="baht-modal-foot"></footer>
125
+ </div>
126
+ </div>`;
127
+ }
128
+ };
129
+ r([
130
+ c({ type: Boolean, reflect: !0 })
131
+ ], l.prototype, "open", 2);
132
+ r([
133
+ c()
134
+ ], l.prototype, "heading", 2);
135
+ r([
136
+ c()
137
+ ], l.prototype, "description", 2);
138
+ r([
139
+ c({ attribute: "show-close", converter: b })
140
+ ], l.prototype, "showClose", 2);
141
+ r([
142
+ c()
143
+ ], l.prototype, "placement", 2);
144
+ r([
145
+ c({ reflect: !0 })
146
+ ], l.prototype, "size", 2);
147
+ r([
148
+ c({ attribute: "close-on-scrim", converter: x })
149
+ ], l.prototype, "closeOnScrim", 2);
150
+ r([
151
+ m(".baht-modal-body")
152
+ ], l.prototype, "bodyEl", 2);
153
+ r([
154
+ m(".baht-modal-foot")
155
+ ], l.prototype, "footEl", 2);
156
+ r([
157
+ f()
158
+ ], l.prototype, "closing", 2);
159
+ l = r([
160
+ q("baht-modal")
161
+ ], l);
162
+ export {
163
+ l as BahtModal
164
+ };
@@ -0,0 +1,8 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtFieldBase } from '../field-base.js';
3
+ /** Multi-pick rendered as a checkbox group; value = array of option keys. */
4
+ export declare class BahtMultiselect extends BahtFieldBase {
5
+ private get selected();
6
+ private toggle;
7
+ protected renderControl(): TemplateResult;
8
+ }
@@ -0,0 +1,47 @@
1
+ import { nothing as d, html as o } from "lit";
2
+ import { live as h } from "lit/directives/live.js";
3
+ import { BahtFieldBase as n } from "../field-base.js";
4
+ import { customElement as p } from "../define.js";
5
+ var b = Object.getOwnPropertyDescriptor, m = (e, l, i, s) => {
6
+ for (var t = s > 1 ? void 0 : s ? b(l, i) : l, r = e.length - 1, a; r >= 0; r--)
7
+ (a = e[r]) && (t = a(t) || t);
8
+ return t;
9
+ };
10
+ let c = class extends n {
11
+ get selected() {
12
+ return Array.isArray(this.value) ? this.value : [];
13
+ }
14
+ toggle(e, l) {
15
+ const i = l ? [...this.selected, e] : this.selected.filter((t) => t !== e), s = (this.field.options ?? []).map((t) => t.key);
16
+ this.emitInput(s.filter((t) => i.includes(t)));
17
+ }
18
+ renderControl() {
19
+ return o`<div
20
+ class="baht-control baht-control--multiselect"
21
+ role="group"
22
+ aria-labelledby=${this.field.label ? this.labelId : d}
23
+ aria-describedby=${this.describedBy}
24
+ >
25
+ ${(this.field.options ?? []).map(
26
+ (e) => o`<label class="baht-option">
27
+ <input
28
+ type="checkbox"
29
+ value=${e.key}
30
+ .checked=${h(this.selected.includes(e.key))}
31
+ ?disabled=${this.disabled || this.readonly}
32
+ @change=${(l) => {
33
+ this.toggle(e.key, l.target.checked);
34
+ }}
35
+ />
36
+ <span>${e.label}</span>
37
+ </label>`
38
+ )}
39
+ </div>`;
40
+ }
41
+ };
42
+ c = m([
43
+ p("baht-multiselect")
44
+ ], c);
45
+ export {
46
+ c as BahtMultiselect
47
+ };
@@ -0,0 +1,54 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ import { BadgeTone } from './baht-badge.js';
4
+ export interface NotificationItem {
5
+ id: string | number;
6
+ title: string;
7
+ body?: string;
8
+ /** Already formatted for display. */
9
+ time?: string;
10
+ unread?: boolean;
11
+ /** A small badge beside the title (a kind or a scope: "Project", "System"). */
12
+ tag?: {
13
+ label: string;
14
+ tone: BadgeTone;
15
+ };
16
+ /** Where the notification leads: the item renders as a link (an unsafe URL renders a button). */
17
+ href?: string;
18
+ }
19
+ /**
20
+ * Header bell: an icon button with the unread count and a panel listing the
21
+ * notifications. Opening emits `baht-open` (refresh then); picking one emits
22
+ * `baht-select` `{ id, href? }` and closes; "Mark all read" emits `baht-mark-all`.
23
+ * An item with `href` is a link: its `baht-select` is cancelable, `preventDefault()` to route
24
+ * yourself. An item's `tag` draws a `<baht-badge>` beside its title. `all-href` adds a footer
25
+ * link (`all-label`, "See all") that fires a cancelable `baht-all` `{ href }`.
26
+ * Escape and a click outside close the panel. The host owns the data.
27
+ * @fires {CustomEvent<void>} baht-open - The panel opened (refresh the items then).
28
+ * @fires {CustomEvent<{ id: string | number; href?: string }>} baht-select - A notification was picked; the panel closes. Cancelable when the item has an `href`: `preventDefault()` to route yourself.
29
+ * @fires {CustomEvent<void>} baht-mark-all - "Mark all read" was pressed.
30
+ * @fires {CustomEvent<{ href: string }>} baht-all - The footer link (`all-href`) was pressed; the panel closes. Cancelable: `preventDefault()` to route yourself.
31
+ */
32
+ export declare class BahtNotificationBell extends BahtElement {
33
+ items: NotificationItem[];
34
+ /** Unread count on the badge; defaults to the unread items. */
35
+ count: number | null;
36
+ label: string;
37
+ emptyMessage: string;
38
+ /** A page with every notification: a footer link to it (`baht-all`). */
39
+ allHref: string;
40
+ /** The footer link's text. */
41
+ allLabel: string;
42
+ private open;
43
+ constructor();
44
+ private readonly onDocClick;
45
+ private readonly onKey;
46
+ connectedCallback(): void;
47
+ disconnectedCallback(): void;
48
+ private get unread();
49
+ private pick;
50
+ private item;
51
+ private footer;
52
+ private toggle;
53
+ protected render(): TemplateResult;
54
+ }
@@ -0,0 +1,143 @@
1
+ import { nothing as n, html as e } from "lit";
2
+ import { property as h, state as f } from "lit/decorators.js";
3
+ import { BahtElement as $, arr as c, routeClick as d } from "../base.js";
4
+ import { isSafeUrl as u } from "@20baht/engine";
5
+ import { customElement as m } from "../define.js";
6
+ import { floatPanel as g } from "../floating.js";
7
+ import "./baht-badge.js";
8
+ var y = Object.defineProperty, v = Object.getOwnPropertyDescriptor, o = (t, l, r, i) => {
9
+ for (var a = i > 1 ? void 0 : i ? v(l, r) : l, b = t.length - 1, p; b >= 0; b--)
10
+ (p = t[b]) && (a = (i ? p(l, r, a) : p(a)) || a);
11
+ return i && a && y(l, r, a), a;
12
+ };
13
+ let s = class extends $ {
14
+ constructor() {
15
+ super(), this.items = [], this.count = null, this.label = "Notifications", this.emptyMessage = "Nothing yet.", this.allHref = "", this.allLabel = "See all", this.open = !1, this.onDocClick = (t) => {
16
+ this.open && !t.composedPath().includes(this) && (this.open = !1);
17
+ }, this.onKey = (t) => {
18
+ this.open && t.key === "Escape" && (this.open = !1);
19
+ }, g(this, { panel: ".baht-bell-panel", gap: 8, where: () => ({ end: !0 }) });
20
+ }
21
+ connectedCallback() {
22
+ super.connectedCallback(), document.addEventListener("click", this.onDocClick), document.addEventListener("keydown", this.onKey);
23
+ }
24
+ disconnectedCallback() {
25
+ document.removeEventListener("click", this.onDocClick), document.removeEventListener("keydown", this.onKey), super.disconnectedCallback();
26
+ }
27
+ get unread() {
28
+ return this.count ?? c(this.items).filter((t) => t.unread).length;
29
+ }
30
+ pick(t) {
31
+ this.open = !1, this.emit("baht-select", { id: t });
32
+ }
33
+ item(t) {
34
+ const l = `baht-bell-item${t.unread ? " baht-bell-item--unread" : ""}`, r = e`<span class="baht-bell-line">
35
+ <span class="baht-bell-title">${t.title}</span>
36
+ ${t.tag ? e`<baht-badge
37
+ class="baht-bell-tag"
38
+ .tone=${t.tag.tone}
39
+ .label=${t.tag.label}
40
+ ></baht-badge>` : n}
41
+ </span>
42
+ ${t.body ? e`<span class="baht-bell-body">${t.body}</span>` : n}
43
+ ${t.time ? e`<span class="baht-bell-time">${t.time}</span>` : n}`, i = t.href && u(t.href) ? t.href : "";
44
+ return i ? e`<a
45
+ class=${l}
46
+ href=${i}
47
+ @click=${(a) => {
48
+ this.open = !1, d(this, "baht-select", a, { id: t.id, href: i });
49
+ }}
50
+ >${r}</a
51
+ >` : e`<button
52
+ type="button"
53
+ class=${l}
54
+ @click=${() => {
55
+ this.pick(t.id);
56
+ }}
57
+ >
58
+ ${r}
59
+ </button>`;
60
+ }
61
+ footer() {
62
+ const t = this.allHref && u(this.allHref) ? this.allHref : "";
63
+ return t ? e`<div class="baht-bell-foot">
64
+ <a
65
+ class="baht-bell-all"
66
+ href=${t}
67
+ @click=${(l) => {
68
+ this.open = !1, d(this, "baht-all", l, { href: t });
69
+ }}
70
+ >${this.allLabel}</a
71
+ >
72
+ </div>` : n;
73
+ }
74
+ toggle() {
75
+ this.open = !this.open, this.open && this.emit("baht-open");
76
+ }
77
+ render() {
78
+ const t = this.unread;
79
+ return e`<div class="baht-bell">
80
+ <button
81
+ type="button"
82
+ class="baht-bell-button"
83
+ aria-haspopup="true"
84
+ aria-expanded=${this.open ? "true" : "false"}
85
+ aria-label=${t ? `${String(t)} unread ${this.label.toLowerCase()}` : this.label}
86
+ @click=${() => {
87
+ this.toggle();
88
+ }}
89
+ >
90
+ <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
91
+ <path d="M18 8a6 6 0 1 0-12 0c0 7-3 9-3 9h18s-3-2-3-9" />
92
+ <path d="M13.7 21a2 2 0 0 1-3.4 0" />
93
+ </svg>
94
+ ${t ? e`<span class="baht-bell-badge">${t > 99 ? "99+" : t}</span>` : n}
95
+ </button>
96
+ ${this.open ? e`<div class="baht-bell-panel" role="dialog" aria-label=${this.label}>
97
+ <div class="baht-bell-head">
98
+ <strong>${this.label}</strong>
99
+ ${t ? e`<button
100
+ type="button"
101
+ class="baht-bell-link"
102
+ @click=${() => {
103
+ this.emit("baht-mark-all");
104
+ }}
105
+ >
106
+ Mark all read
107
+ </button>` : n}
108
+ </div>
109
+ ${c(this.items).length === 0 ? e`<p class="baht-bell-empty">${this.emptyMessage}</p>` : e`<ul class="baht-bell-list">
110
+ ${c(this.items).map((l) => e`<li>${this.item(l)}</li>`)}
111
+ </ul>`}
112
+ ${this.footer()}
113
+ </div>` : n}
114
+ </div>`;
115
+ }
116
+ };
117
+ o([
118
+ h({ attribute: !1 })
119
+ ], s.prototype, "items", 2);
120
+ o([
121
+ h({ type: Number })
122
+ ], s.prototype, "count", 2);
123
+ o([
124
+ h()
125
+ ], s.prototype, "label", 2);
126
+ o([
127
+ h({ attribute: "empty-message" })
128
+ ], s.prototype, "emptyMessage", 2);
129
+ o([
130
+ h({ attribute: "all-href" })
131
+ ], s.prototype, "allHref", 2);
132
+ o([
133
+ h({ attribute: "all-label" })
134
+ ], s.prototype, "allLabel", 2);
135
+ o([
136
+ f()
137
+ ], s.prototype, "open", 2);
138
+ s = o([
139
+ m("baht-notification-bell")
140
+ ], s);
141
+ export {
142
+ s as BahtNotificationBell
143
+ };
@@ -0,0 +1,5 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtFieldBase } from '../field-base.js';
3
+ export declare class BahtNumber extends BahtFieldBase {
4
+ protected renderControl(): TemplateResult;
5
+ }
@@ -0,0 +1,39 @@
1
+ import { html as n } from "lit";
2
+ import { ifDefined as i } from "lit/directives/if-defined.js";
3
+ import { live as m } from "lit/directives/live.js";
4
+ import { BahtFieldBase as h } from "../field-base.js";
5
+ import { customElement as p } from "../define.js";
6
+ var u = Object.getOwnPropertyDescriptor, b = (t, e, d, s) => {
7
+ for (var r = s > 1 ? void 0 : s ? u(e, d) : e, l = t.length - 1, a; l >= 0; l--)
8
+ (a = t[l]) && (r = a(r) || r);
9
+ return r;
10
+ };
11
+ let o = class extends h {
12
+ renderControl() {
13
+ return n`<input
14
+ class="baht-control baht-control--number"
15
+ id=${this.controlId}
16
+ type="number"
17
+ .value=${m(this.shownText)}
18
+ placeholder=${i(this.field.placeholder)}
19
+ min=${i(this.field.min)}
20
+ max=${i(this.field.max)}
21
+ step=${i(this.field.step)}
22
+ ?disabled=${this.disabled}
23
+ ?readonly=${this.readonly}
24
+ ?required=${this.required}
25
+ aria-invalid=${this.invalidAttr}
26
+ aria-describedby=${this.describedBy}
27
+ @input=${(t) => {
28
+ const e = t.target.value;
29
+ this.emitTyped(e === "" ? null : Number(e));
30
+ }}
31
+ />`;
32
+ }
33
+ };
34
+ o = b([
35
+ p("baht-number")
36
+ ], o);
37
+ export {
38
+ o as BahtNumber
39
+ };
@@ -0,0 +1,24 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * The box beside a catalog item that orders it. Children go between the heading and the button:
5
+ * a price, a quantity.
6
+ *
7
+ * <baht-order-box heading="Order this item" label="Submit"></baht-order-box>
8
+ *
9
+ * @fires {CustomEvent<void>} baht-order - The button was pressed.
10
+ */
11
+ export declare class BahtOrderBox extends BahtElement {
12
+ heading: string;
13
+ /** The button's text. */
14
+ label: string;
15
+ disabled: boolean;
16
+ private bodyEl;
17
+ protected adoptChildren(): void;
18
+ protected render(): TemplateResult;
19
+ }
20
+ declare global {
21
+ interface HTMLElementTagNameMap {
22
+ 'baht-order-box': BahtOrderBox;
23
+ }
24
+ }
@@ -0,0 +1,50 @@
1
+ import { nothing as p, html as l } from "lit";
2
+ import { property as h, query as n } from "lit/decorators.js";
3
+ import { BahtElement as m, adoptLightChildren as y } from "../base.js";
4
+ import { customElement as c } from "../define.js";
5
+ import "./baht-button.js";
6
+ var f = Object.defineProperty, u = Object.getOwnPropertyDescriptor, r = (b, o, a, i) => {
7
+ for (var t = i > 1 ? void 0 : i ? u(o, a) : o, s = b.length - 1, d; s >= 0; s--)
8
+ (d = b[s]) && (t = (i ? d(o, a, t) : d(t)) || t);
9
+ return i && t && f(o, a, t), t;
10
+ };
11
+ let e = class extends m {
12
+ constructor() {
13
+ super(...arguments), this.heading = "", this.label = "", this.disabled = !1;
14
+ }
15
+ adoptChildren() {
16
+ y(this, this.bodyEl);
17
+ }
18
+ render() {
19
+ return l`<aside class="baht-order-box">
20
+ ${this.heading ? l`<p class="baht-order-box-heading">${this.heading}</p>` : p}
21
+ <div class="baht-order-box-body"></div>
22
+ <baht-button
23
+ variant="primary"
24
+ .disabled=${this.disabled}
25
+ @click=${() => {
26
+ this.disabled || this.emit("baht-order");
27
+ }}
28
+ >${this.label}</baht-button
29
+ >
30
+ </aside>`;
31
+ }
32
+ };
33
+ r([
34
+ h()
35
+ ], e.prototype, "heading", 2);
36
+ r([
37
+ h()
38
+ ], e.prototype, "label", 2);
39
+ r([
40
+ h({ type: Boolean })
41
+ ], e.prototype, "disabled", 2);
42
+ r([
43
+ n(".baht-order-box-body")
44
+ ], e.prototype, "bodyEl", 2);
45
+ e = r([
46
+ c("baht-order-box")
47
+ ], e);
48
+ export {
49
+ e as BahtOrderBox
50
+ };
@@ -0,0 +1,49 @@
1
+ import { PropertyValues, TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * One-time-code input: N boxes, auto-advance, backspace steps back, paste
5
+ * distributes. Emits `baht-change { value }` per edit and `baht-otp-complete { value }`
6
+ * when every box is filled.
7
+ *
8
+ * <baht-otp length="6"></baht-otp>
9
+ * @fires {CustomEvent<{ value: string }>} baht-change - A digit changed.
10
+ * @fires {CustomEvent<{ value: string }>} baht-otp-complete - Every box is filled.
11
+ */
12
+ export declare class BahtOtp extends BahtElement {
13
+ length: number;
14
+ value: string;
15
+ disabled: boolean;
16
+ /** 'numeric' restricts to digits; 'text' allows anything. */
17
+ mode: 'numeric' | 'text';
18
+ /** Accessible name for the group of boxes. */
19
+ label: string;
20
+ /**
21
+ * Per-box state, index-aligned; '' marks an empty box. This is the source
22
+ * of truth for rendering so that clearing box N never shifts box N+1's
23
+ * character into its place. `value` stays a derived, compacted (gap-free)
24
+ * string — the existing external contract (docs: a plain "controlled"
25
+ * string of the digits typed so far, in order).
26
+ */
27
+ private _chars;
28
+ /**
29
+ * The compacted string `_chars` currently represents. Lets willUpdate tell
30
+ * an external `el.value = …` write (e.g. the docs' reset-on-failure
31
+ * example) apart from `commit()` echoing its own assignment, without a
32
+ * boolean flag that could get stuck across a no-op property set.
33
+ */
34
+ private _lastValue;
35
+ /** Previous "every box filled" state, so `baht-otp-complete` fires only on the
36
+ * not-full → full transition, not on every edit while already full. */
37
+ private _wasFull;
38
+ private inputs;
39
+ private clean;
40
+ protected willUpdate(changed: PropertyValues<this>): void;
41
+ /** Writes `text` into `_chars` starting at `start`. Returns the index just
42
+ * past the last box written (may equal `this.length`). */
43
+ private fill;
44
+ private commit;
45
+ private onInput;
46
+ private onKeydown;
47
+ private onPaste;
48
+ protected render(): TemplateResult;
49
+ }