@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,40 @@
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, m = (e, a, o, i) => {
6
+ for (var t = i > 1 ? void 0 : i ? p(a, o) : a, r = e.length - 1, l; r >= 0; r--)
7
+ (l = e[r]) && (t = l(t) || t);
8
+ return t;
9
+ };
10
+ let s = class extends d {
11
+ /** Label sits beside the box, so suppress the block label. */
12
+ renderLabel() {
13
+ return h;
14
+ }
15
+ renderControl() {
16
+ return n`<label class="baht-control baht-control--checkbox baht-option">
17
+ <input
18
+ type="checkbox"
19
+ id=${this.controlId}
20
+ .checked=${c(this.value === !0)}
21
+ ?disabled=${this.disabled || this.readonly}
22
+ ?required=${this.required}
23
+ aria-invalid=${this.invalidAttr}
24
+ aria-describedby=${this.describedBy}
25
+ @change=${(e) => {
26
+ this.emitInput(e.target.checked);
27
+ }}
28
+ />
29
+ <span class="baht-label"
30
+ >${this.field.label}${this.renderLabelMark()}</span
31
+ >
32
+ </label>`;
33
+ }
34
+ };
35
+ s = m([
36
+ b("baht-checkbox")
37
+ ], s);
38
+ export {
39
+ s as BahtCheckbox
40
+ };
@@ -0,0 +1,52 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ import { IconName } from './icons.js';
4
+ /** One tile of a `<baht-choice-group>`. */
5
+ export interface ChoiceOption {
6
+ /** Sent as `baht-change` `detail.value` and matched against `value`. */
7
+ key: string;
8
+ /** The tile's title. */
9
+ label: string;
10
+ /** A muted line under the title. */
11
+ description?: string;
12
+ /** A small mono line at the foot of the tile ("2 vCPU · 4 GB"). */
13
+ meta?: string;
14
+ /** Leading icon from the curated set; unknown names draw nothing. */
15
+ icon?: IconName;
16
+ disabled?: boolean;
17
+ }
18
+ /**
19
+ * Choice tiles outside a form: a row of cards of which one is picked (a template picker, a
20
+ * plan). Each tile is a real radio, so the group has one tab stop and arrow keys move the
21
+ * pick; the picked tile carries the primary border and wash. Inside a `<baht-form>` use a
22
+ * `radio` field with `variant: 'card'` instead: this element holds no field state and does no
23
+ * validation.
24
+ *
25
+ * <baht-choice-group label="Template" value="web"></baht-choice-group>
26
+ * group.options = [{ key: 'web', label: 'Web server', description: 'nginx', meta: '2 vCPU · 4 GB' }];
27
+ * group.addEventListener('baht-change', (e) => pick(e.detail.value));
28
+ *
29
+ * Tiles share the row (`flex: 1 1 var(--baht-choice-min, 200px)`) and wrap; set
30
+ * `--baht-choice-min` on the element for narrower or wider tiles.
31
+ *
32
+ * @fires {CustomEvent<{ value: string }>} baht-change - A tile was picked; `value` is already set to its key.
33
+ */
34
+ export declare class BahtChoiceGroup extends BahtElement {
35
+ /** The tiles. Set as a property: `el.options = [...]`. */
36
+ options: ChoiceOption[];
37
+ /** Key of the picked tile; empty = none picked. */
38
+ value: string;
39
+ /** Accessible name of the group (there is no visible legend; put a heading beside it). */
40
+ label: string;
41
+ /** Turn every tile off. */
42
+ disabled: boolean;
43
+ private get name();
44
+ private pick;
45
+ private renderTile;
46
+ protected render(): TemplateResult;
47
+ }
48
+ declare global {
49
+ interface HTMLElementTagNameMap {
50
+ 'baht-choice-group': BahtChoiceGroup;
51
+ }
52
+ }
@@ -0,0 +1,71 @@
1
+ import { nothing as r, html as o } from "lit";
2
+ import { property as c } from "lit/decorators.js";
3
+ import { live as d } from "lit/directives/live.js";
4
+ import { BahtElement as b, arr as m } from "../base.js";
5
+ import { isIconName as u, renderIcon as f } from "./icons.js";
6
+ import { customElement as $ } from "../define.js";
7
+ var v = Object.defineProperty, y = Object.getOwnPropertyDescriptor, s = (e, t, p, l) => {
8
+ for (var a = l > 1 ? void 0 : l ? y(t, p) : t, h = e.length - 1, n; h >= 0; h--)
9
+ (n = e[h]) && (a = (l ? n(t, p, a) : n(a)) || a);
10
+ return l && a && v(t, p, a), a;
11
+ };
12
+ let i = class extends b {
13
+ constructor() {
14
+ super(...arguments), this.options = [], this.value = "", this.label = "", this.disabled = !1;
15
+ }
16
+ get name() {
17
+ return `baht-choice-${this.uid}`;
18
+ }
19
+ pick(e) {
20
+ this.value = e, this.emit("baht-change", { value: e });
21
+ }
22
+ renderTile(e) {
23
+ const t = this.disabled || e.disabled === !0;
24
+ return o`<label class="baht-choice${t ? " baht-choice--disabled" : ""}">
25
+ <input
26
+ type="radio"
27
+ name=${this.name}
28
+ value=${e.key}
29
+ .checked=${d(this.value === e.key)}
30
+ ?disabled=${t}
31
+ @change=${() => {
32
+ this.pick(e.key);
33
+ }}
34
+ />
35
+ <span class="baht-choice-head">
36
+ ${e.icon && u(e.icon) ? f(e.icon) : r}
37
+ <span class="baht-choice-title">${e.label}</span>
38
+ </span>
39
+ ${e.description ? o`<span class="baht-choice-desc">${e.description}</span>` : r}
40
+ ${e.meta ? o`<span class="baht-choice-meta">${e.meta}</span>` : r}
41
+ </label>`;
42
+ }
43
+ render() {
44
+ return o`<div
45
+ class="baht-choice-group"
46
+ role="radiogroup"
47
+ aria-label=${this.label || r}
48
+ aria-disabled=${this.disabled ? "true" : r}
49
+ >
50
+ ${m(this.options).map((e) => this.renderTile(e))}
51
+ </div>`;
52
+ }
53
+ };
54
+ s([
55
+ c({ attribute: !1 })
56
+ ], i.prototype, "options", 2);
57
+ s([
58
+ c({ reflect: !0 })
59
+ ], i.prototype, "value", 2);
60
+ s([
61
+ c()
62
+ ], i.prototype, "label", 2);
63
+ s([
64
+ c({ type: Boolean })
65
+ ], i.prototype, "disabled", 2);
66
+ i = s([
67
+ $("baht-choice-group")
68
+ ], i);
69
+ export {
70
+ i as BahtChoiceGroup
71
+ };
@@ -0,0 +1,18 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ export type CodeVariant = 'inline' | 'block';
4
+ /**
5
+ * Monospace code (20baht): an inline chip or a block. Content is the light-DOM
6
+ * children (or the `code` property). Not a syntax highlighter — just the
7
+ * design-system's canonical way to show code/identifiers/tokens.
8
+ *
9
+ * <baht-code>baht-button</baht-code>
10
+ * <baht-code variant="block">npm i @20baht/ui</baht-code>
11
+ */
12
+ export declare class BahtCode extends BahtElement {
13
+ variant: CodeVariant;
14
+ /** Alternative to children for setting the code text programmatically. */
15
+ code: string;
16
+ protected firstUpdated(): void;
17
+ protected render(): TemplateResult;
18
+ }
@@ -0,0 +1,33 @@
1
+ import { html as n } from "lit";
2
+ import { property as d } from "lit/decorators.js";
3
+ import { BahtElement as h, adoptLightChildren as l } from "../base.js";
4
+ import { customElement as m } from "../define.js";
5
+ var f = Object.defineProperty, b = Object.getOwnPropertyDescriptor, p = (e, r, c, o) => {
6
+ for (var t = o > 1 ? void 0 : o ? b(r, c) : r, a = e.length - 1, i; a >= 0; a--)
7
+ (i = e[a]) && (t = (o ? i(r, c, t) : i(t)) || t);
8
+ return o && t && f(r, c, t), t;
9
+ };
10
+ let s = class extends h {
11
+ constructor() {
12
+ super(...arguments), this.variant = "inline", this.code = "";
13
+ }
14
+ firstUpdated() {
15
+ const e = this.renderRoot.querySelector(this.variant === "block" ? "pre" : "code");
16
+ e && l(this, e);
17
+ }
18
+ render() {
19
+ return this.variant === "block" ? n`<pre class="baht-code baht-code--block" tabindex="0">${this.code}</pre>` : n`<code class="baht-code">${this.code}</code>`;
20
+ }
21
+ };
22
+ p([
23
+ d()
24
+ ], s.prototype, "variant", 2);
25
+ p([
26
+ d()
27
+ ], s.prototype, "code", 2);
28
+ s = p([
29
+ m("baht-code")
30
+ ], s);
31
+ export {
32
+ s as BahtCode
33
+ };
@@ -0,0 +1,69 @@
1
+ import { PropertyValues, TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ import { ColumnMap } from './column-map.js';
4
+ /** What the picker committed: dotted keys plus the labels the header shows. */
5
+ export interface ColumnsChangeDetail {
6
+ visibleColumns: string[];
7
+ columns: {
8
+ key: string;
9
+ label: string;
10
+ }[];
11
+ }
12
+ /**
13
+ * The Available / Selected dialog behind a table's Columns button: add, remove and reorder columns,
14
+ * and expand a reference column to dot-walk into its fields.
15
+ *
16
+ * @fires {CustomEvent<ColumnsChangeDetail>} baht-columns-change - OK was pressed. `detail: ColumnsChangeDetail`.
17
+ * @fires {CustomEvent<void>} baht-close - The dialog was dismissed, or OK was pressed.
18
+ */
19
+ export declare class BahtColumnPicker extends BahtElement {
20
+ constructor();
21
+ open: boolean;
22
+ columns: ColumnMap;
23
+ /** The columns showing now, in order. */
24
+ selected: string[];
25
+ /** Working copy edited inside the dialog; committed on OK. */
26
+ private draft;
27
+ /** Highlighted (not yet moved) options in each list. */
28
+ private pickAvail;
29
+ private pickSel;
30
+ /** Reference columns unfolded in the Available tree (dot-walk). */
31
+ private expanded;
32
+ /** Element focused before the picker opened: focus returns there on close. */
33
+ private previousFocus;
34
+ private get titleId();
35
+ private readonly onKeydown;
36
+ private focusables;
37
+ /** Keep Tab cycling inside the dialog (no escape to the page behind). */
38
+ private trapFocus;
39
+ private release;
40
+ disconnectedCallback(): void;
41
+ protected willUpdate(changed: PropertyValues<this>): void;
42
+ protected updated(changed: PropertyValues<this>): void;
43
+ private dismiss;
44
+ private get topKeys();
45
+ private childrenOf;
46
+ private isReference;
47
+ /** Every pickable key, reference fields included (`requester`, `requester.name`, ...). */
48
+ private allPaths;
49
+ private static selectedValues;
50
+ private toggleAvail;
51
+ private toggleExpanded;
52
+ private addToSelected;
53
+ private removeFromSelected;
54
+ private moveSelected;
55
+ private confirm;
56
+ /**
57
+ * One row of the Available tree. A reference column gets an expander that unfolds its fields
58
+ * (the dot-walk); every row is a toggle button so the list works from the keyboard without the
59
+ * native multi-select.
60
+ */
61
+ private renderAvailRow;
62
+ protected render(): TemplateResult;
63
+ private renderDialog;
64
+ }
65
+ declare global {
66
+ interface HTMLElementTagNameMap {
67
+ 'baht-column-picker': BahtColumnPicker;
68
+ }
69
+ }
@@ -0,0 +1,234 @@
1
+ import { nothing as u, html as n } from "lit";
2
+ import { property as b, state as d } from "lit/decorators.js";
3
+ import { BahtElement as m, hasDom as f } from "../base.js";
4
+ import { customElement as v } from "../define.js";
5
+ import { floatLayer as k } from "../floating.js";
6
+ import { specAt as h, labelAt as p } from "./column-map.js";
7
+ import { renderIcon as $ } from "./icons.js";
8
+ var y = Object.defineProperty, g = Object.getOwnPropertyDescriptor, r = (t, e, i, s) => {
9
+ for (var l = s > 1 ? void 0 : s ? g(e, i) : e, a = t.length - 1, o; a >= 0; a--)
10
+ (o = t[a]) && (l = (s ? o(e, i, l) : o(l)) || l);
11
+ return s && l && y(e, i, l), l;
12
+ };
13
+ let c = class extends m {
14
+ constructor() {
15
+ super(), this.open = !1, this.columns = {}, this.selected = [], this.draft = [], this.pickAvail = [], this.pickSel = [], this.expanded = [], this.previousFocus = null, this.onKeydown = (t) => {
16
+ t.key === "Escape" ? (t.stopImmediatePropagation(), this.dismiss()) : t.key === "Tab" && this.trapFocus(t);
17
+ }, k(this, { layer: ".baht-table-picker-scrim" });
18
+ }
19
+ get titleId() {
20
+ return `baht-table-picker-title-${this.uid}`;
21
+ }
22
+ focusables() {
23
+ const t = this.querySelector(".baht-table-picker-modal");
24
+ return t ? Array.from(
25
+ t.querySelectorAll(
26
+ 'button:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
27
+ )
28
+ ) : [];
29
+ }
30
+ /** Keep Tab cycling inside the dialog (no escape to the page behind). */
31
+ trapFocus(t) {
32
+ const e = this.focusables(), i = e[0], s = e[e.length - 1];
33
+ if (!i || !s) return;
34
+ const l = document.activeElement, a = this.querySelector(".baht-table-picker-modal");
35
+ let o = null;
36
+ a != null && a.contains(l) ? t.shiftKey && l === i ? o = s : !t.shiftKey && l === s && (o = i) : o = i, o && (t.preventDefault(), t.stopImmediatePropagation(), o.focus());
37
+ }
38
+ release() {
39
+ document.removeEventListener("keydown", this.onKeydown, !0);
40
+ const t = this.previousFocus;
41
+ this.previousFocus = null, t != null && t.isConnected && t.focus();
42
+ }
43
+ // A host may render this only while it is open, so closing can be removal.
44
+ disconnectedCallback() {
45
+ super.disconnectedCallback(), f() && this.release();
46
+ }
47
+ willUpdate(t) {
48
+ t.has("open") && this.open && (this.draft = this.selected.slice(), this.pickAvail = [], this.pickSel = []);
49
+ }
50
+ updated(t) {
51
+ var e;
52
+ !t.has("open") || !f() || (this.open ? (this.previousFocus = document.activeElement, document.addEventListener("keydown", this.onKeydown, !0), (e = this.focusables()[0]) == null || e.focus()) : t.get("open") && this.release());
53
+ }
54
+ dismiss() {
55
+ this.emit("baht-close");
56
+ }
57
+ get topKeys() {
58
+ return Object.keys(this.columns);
59
+ }
60
+ childrenOf(t) {
61
+ var e;
62
+ return Object.keys(((e = h(this.columns, t)) == null ? void 0 : e.fields) ?? {}).map((i) => `${t}.${i}`);
63
+ }
64
+ isReference(t) {
65
+ var e;
66
+ return ((e = h(this.columns, t)) == null ? void 0 : e.fields) !== void 0;
67
+ }
68
+ /** Every pickable key, reference fields included (`requester`, `requester.name`, ...). */
69
+ allPaths(t = "") {
70
+ return (t ? this.childrenOf(t) : this.topKeys).flatMap((i) => this.isReference(i) ? [i, ...this.allPaths(i)] : [i]);
71
+ }
72
+ static selectedValues(t) {
73
+ return Array.from(t.target.selectedOptions).map((e) => e.value);
74
+ }
75
+ toggleAvail(t) {
76
+ this.pickAvail = this.pickAvail.includes(t) ? this.pickAvail.filter((e) => e !== t) : [...this.pickAvail, t];
77
+ }
78
+ toggleExpanded(t) {
79
+ this.expanded = this.expanded.includes(t) ? this.expanded.filter((e) => e !== t) : [...this.expanded, t];
80
+ }
81
+ addToSelected() {
82
+ this.draft = [...this.draft, ...this.pickAvail.filter((t) => !this.draft.includes(t))], this.pickAvail = [];
83
+ }
84
+ removeFromSelected() {
85
+ this.draft = this.draft.filter((t) => !this.pickSel.includes(t)), this.pickSel = [];
86
+ }
87
+ moveSelected(t) {
88
+ const e = [...this.draft], i = this.pickSel.map((s) => e.indexOf(s)).filter((s) => s >= 0).sort((s, l) => t === -1 ? s - l : l - s);
89
+ for (const s of i) {
90
+ const l = s + t, a = e[s], o = e[l];
91
+ a === void 0 || o === void 0 || (e[s] = o, e[l] = a);
92
+ }
93
+ this.draft = e;
94
+ }
95
+ confirm() {
96
+ const t = {
97
+ visibleColumns: this.draft,
98
+ columns: this.draft.map((e) => ({ key: e, label: p(this.columns, e) }))
99
+ };
100
+ this.emit("baht-columns-change", t), this.dismiss();
101
+ }
102
+ /**
103
+ * One row of the Available tree. A reference column gets an expander that unfolds its fields
104
+ * (the dot-walk); every row is a toggle button so the list works from the keyboard without the
105
+ * native multi-select.
106
+ */
107
+ renderAvailRow(t, e) {
108
+ const i = h(this.columns, t), s = (i == null ? void 0 : i.fields) !== void 0, l = this.expanded.includes(t);
109
+ return n`<li class="baht-table-picker-node" style="--baht-picker-depth:${e}">
110
+ <div class="baht-table-picker-row">
111
+ ${s ? n`<button
112
+ type="button"
113
+ class="baht-table-picker-expand"
114
+ aria-label=${l ? `Collapse ${i.label}` : `Expand ${i.label}`}
115
+ aria-expanded=${l ? "true" : "false"}
116
+ @click=${() => {
117
+ this.toggleExpanded(t);
118
+ }}
119
+ >${$(l ? "chevron-down" : "chevron-right")}</button>` : n`<span class="baht-table-picker-expand baht-table-picker-expand--leaf"></span>`}
120
+ <button
121
+ type="button"
122
+ class="baht-table-picker-option"
123
+ data-key=${t}
124
+ ?disabled=${this.draft.includes(t)}
125
+ aria-pressed=${this.pickAvail.includes(t) ? "true" : "false"}
126
+ @click=${() => {
127
+ this.toggleAvail(t);
128
+ }}
129
+ >${e === 0 ? p(this.columns, t) : (i == null ? void 0 : i.label) ?? t}</button>
130
+ </div>
131
+ ${s && l ? n`<ul class="baht-table-picker-tree">
132
+ ${this.childrenOf(t).map((a) => this.renderAvailRow(a, e + 1))}
133
+ </ul>` : u}
134
+ </li>`;
135
+ }
136
+ // Always a template, closed too: server-rendered markup hydrates against the same shape.
137
+ render() {
138
+ return n`${this.open ? this.renderDialog() : u}`;
139
+ }
140
+ renderDialog() {
141
+ const t = this.allPaths().filter((e) => !this.draft.includes(e)).length;
142
+ return n`<div
143
+ class="baht-table-picker-scrim"
144
+ @click=${(e) => {
145
+ e.target === e.currentTarget && this.dismiss();
146
+ }}
147
+ >
148
+ <div class="baht-table-picker-modal" role="dialog" aria-modal="true" aria-labelledby=${this.titleId}>
149
+ <div class="baht-table-picker-modal-head">
150
+ <b id=${this.titleId}>Choose columns</b>
151
+ <button type="button" class="baht-table-picker-modal-close" aria-label="Close" @click=${() => {
152
+ this.dismiss();
153
+ }}>×</button>
154
+ </div>
155
+ <div class="baht-table-picker-grid">
156
+ <div>
157
+ <div class="baht-table-picker-collabel">Available (${t})</div>
158
+ <ul class="baht-table-picker-tree baht-table-picker-avail" aria-label="Available columns">
159
+ ${this.topKeys.map((e) => this.renderAvailRow(e, 0))}
160
+ </ul>
161
+ </div>
162
+ <div class="baht-table-picker-btns">
163
+ <button type="button" ?disabled=${!this.pickAvail.length} @click=${() => {
164
+ this.addToSelected();
165
+ }}>› Add</button>
166
+ <button type="button" ?disabled=${!this.pickSel.length} @click=${() => {
167
+ this.removeFromSelected();
168
+ }}>‹ Remove</button>
169
+ <button type="button" ?disabled=${!this.pickSel.length} @click=${() => {
170
+ this.moveSelected(-1);
171
+ }}>↑ Up</button>
172
+ <button type="button" ?disabled=${!this.pickSel.length} @click=${() => {
173
+ this.moveSelected(1);
174
+ }}>↓ Down</button>
175
+ </div>
176
+ <div>
177
+ <div class="baht-table-picker-collabel">Selected (${this.draft.length})</div>
178
+ <select
179
+ multiple
180
+ size="10"
181
+ class="baht-table-picker-select"
182
+ aria-label="Selected columns"
183
+ @change=${(e) => {
184
+ this.pickSel = c.selectedValues(e);
185
+ }}
186
+ >
187
+ ${this.draft.map(
188
+ (e) => n`<option value=${e} ?selected=${this.pickSel.includes(e)}>${p(this.columns, e)}</option>`
189
+ )}
190
+ </select>
191
+ </div>
192
+ </div>
193
+ <div class="baht-table-picker-modal-foot">
194
+ <button type="button" @click=${() => this.draft = []}>Clear all</button>
195
+ <button type="button" @click=${() => this.draft = this.topKeys.slice()}>Select all</button>
196
+ <span class="baht-table-picker-spacer"></span>
197
+ <button type="button" @click=${() => {
198
+ this.dismiss();
199
+ }}>Cancel</button>
200
+ <button type="button" class="baht-table-picker-ok" @click=${() => {
201
+ this.confirm();
202
+ }}>OK</button>
203
+ </div>
204
+ </div>
205
+ </div>`;
206
+ }
207
+ };
208
+ r([
209
+ b({ type: Boolean, reflect: !0 })
210
+ ], c.prototype, "open", 2);
211
+ r([
212
+ b({ attribute: !1 })
213
+ ], c.prototype, "columns", 2);
214
+ r([
215
+ b({ attribute: !1 })
216
+ ], c.prototype, "selected", 2);
217
+ r([
218
+ d()
219
+ ], c.prototype, "draft", 2);
220
+ r([
221
+ d()
222
+ ], c.prototype, "pickAvail", 2);
223
+ r([
224
+ d()
225
+ ], c.prototype, "pickSel", 2);
226
+ r([
227
+ d()
228
+ ], c.prototype, "expanded", 2);
229
+ c = r([
230
+ v("baht-column-picker")
231
+ ], c);
232
+ export {
233
+ c as BahtColumnPicker
234
+ };
@@ -0,0 +1,38 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ export interface CommentEntry {
4
+ id: string | number;
5
+ author: string;
6
+ /** Already formatted for display ("1 Nov 2026, 14:44"). */
7
+ time?: string;
8
+ body: string;
9
+ /** An internal note (work note): shown marked, never to the requester. */
10
+ internal?: boolean;
11
+ }
12
+ /**
13
+ * A conversation on a record: the thread, oldest first, and a composer. With
14
+ * `allow-internal` the composer offers "internal note" next to a normal
15
+ * comment (ServiceNow's work notes vs additional comments). Submitting emits
16
+ * `baht-submit` with `{ body, internal }` and clears the box; the host stores
17
+ * it and feeds the new `entries` back.
18
+ *
19
+ * <baht-comments allow-internal></baht-comments>
20
+ * el.entries = [{ id: 1, author: 'Bob', time: '14:44', body: 'Still broken' }];
21
+ * @fires {CustomEvent<{ body: string; internal: boolean }>} baht-submit - The composer was submitted; the box clears.
22
+ */
23
+ export declare class BahtComments extends BahtElement {
24
+ entries: CommentEntry[];
25
+ allowInternal: boolean;
26
+ placeholder: string;
27
+ internalLabel: string;
28
+ emptyMessage: string;
29
+ busy: boolean;
30
+ private draft;
31
+ private internal;
32
+ private readonly onInternal;
33
+ private readonly onDraft;
34
+ private readonly onKeydown;
35
+ private readonly onPost;
36
+ private submit;
37
+ protected render(): TemplateResult;
38
+ }
@@ -0,0 +1,102 @@
1
+ import { nothing as p, html as r } from "lit";
2
+ import { property as o, state as c } from "lit/decorators.js";
3
+ import { BahtElement as b, arr as d } from "../base.js";
4
+ import { customElement as y } from "../define.js";
5
+ var u = Object.defineProperty, f = Object.getOwnPropertyDescriptor, s = (t, e, l, i) => {
6
+ for (var n = i > 1 ? void 0 : i ? f(e, l) : e, h = t.length - 1, m; h >= 0; h--)
7
+ (m = t[h]) && (n = (i ? m(e, l, n) : m(n)) || n);
8
+ return i && n && u(e, l, n), n;
9
+ };
10
+ let a = class extends b {
11
+ constructor() {
12
+ super(...arguments), this.entries = [], this.allowInternal = !1, this.placeholder = "Add a comment…", this.internalLabel = "Internal note", this.emptyMessage = "No comments yet.", this.busy = !1, this.draft = "", this.internal = !1, this.onInternal = (t) => {
13
+ this.internal = t.target.checked;
14
+ }, this.onDraft = (t) => {
15
+ this.draft = t.target.value;
16
+ }, this.onKeydown = (t) => {
17
+ t.key === "Enter" && (t.ctrlKey || t.metaKey) && this.submit();
18
+ }, this.onPost = () => {
19
+ this.submit();
20
+ };
21
+ }
22
+ submit() {
23
+ const t = this.draft.trim();
24
+ !t || this.busy || (this.emit("baht-submit", { body: t, internal: this.allowInternal && this.internal }), this.draft = "");
25
+ }
26
+ render() {
27
+ const t = d(this.entries);
28
+ return r`<div class="baht-comments">
29
+ ${t.length === 0 ? r`<p class="baht-comments-empty">${this.emptyMessage}</p>` : r`<ol class="baht-comments-list">
30
+ ${t.map(
31
+ (e) => r`<li class="baht-comment${e.internal ? " baht-comment--internal" : ""}">
32
+ <div class="baht-comment-head">
33
+ <strong>${e.author}</strong>
34
+ ${e.internal ? r`<span class="baht-comment-tag">${this.internalLabel}</span>` : p}
35
+ ${e.time ? r`<span class="baht-comment-time">${e.time}</span>` : p}
36
+ </div>
37
+ <p class="baht-comment-body">${e.body}</p>
38
+ </li>`
39
+ )}
40
+ </ol>`}
41
+ <div class="baht-comments-composer">
42
+ ${this.allowInternal ? r`<label class="baht-comments-internal"
43
+ ><input
44
+ type="checkbox"
45
+ .checked=${this.internal}
46
+ @change=${this.onInternal}
47
+ />
48
+ ${this.internalLabel}</label
49
+ >` : p}
50
+ <textarea
51
+ class="baht-control baht-comments-input"
52
+ rows="3"
53
+ aria-label=${this.placeholder}
54
+ placeholder=${this.placeholder}
55
+ .value=${this.draft}
56
+ @input=${this.onDraft}
57
+ @keydown=${this.onKeydown}
58
+ ></textarea>
59
+ <div class="baht-comments-actions">
60
+ <button
61
+ type="button"
62
+ class="baht-button baht-button--primary baht-button--sm"
63
+ ?disabled=${this.busy || !this.draft.trim()}
64
+ @click=${this.onPost}
65
+ >
66
+ ${this.allowInternal && this.internal ? `Add ${this.internalLabel.toLowerCase()}` : "Post"}
67
+ </button>
68
+ </div>
69
+ </div>
70
+ </div>`;
71
+ }
72
+ };
73
+ s([
74
+ o({ attribute: !1 })
75
+ ], a.prototype, "entries", 2);
76
+ s([
77
+ o({ type: Boolean, attribute: "allow-internal" })
78
+ ], a.prototype, "allowInternal", 2);
79
+ s([
80
+ o()
81
+ ], a.prototype, "placeholder", 2);
82
+ s([
83
+ o({ attribute: "internal-label" })
84
+ ], a.prototype, "internalLabel", 2);
85
+ s([
86
+ o({ attribute: "empty-message" })
87
+ ], a.prototype, "emptyMessage", 2);
88
+ s([
89
+ o({ type: Boolean })
90
+ ], a.prototype, "busy", 2);
91
+ s([
92
+ c()
93
+ ], a.prototype, "draft", 2);
94
+ s([
95
+ c()
96
+ ], a.prototype, "internal", 2);
97
+ a = s([
98
+ y("baht-comments")
99
+ ], a);
100
+ export {
101
+ a as BahtComments
102
+ };
@@ -0,0 +1,13 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtFieldBase } from '../field-base.js';
3
+ /**
4
+ * Money input: plain digits while typing, thousands-separated on blur.
5
+ * Reformatting every keystroke fights the caret and recomputes on every key
6
+ * for no reason — so the separator only appears once the field is quiet.
7
+ * Emits a plain `number | null`, same as `number` (spec 01 §2).
8
+ */
9
+ export declare class BahtCurrency extends BahtFieldBase {
10
+ private focused;
11
+ private displayFor;
12
+ protected renderControl(): TemplateResult;
13
+ }