@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,134 @@
1
+ import { nothing as n, html as r } from "lit";
2
+ import { ariaKeyshortcuts as u } from "@20baht/engine";
3
+ import { hasDom as l } from "./base.js";
4
+ import { floatPanel as b } from "./floating.js";
5
+ import { isMacPlatform as p, bindShortcut as m } from "./shortcuts.js";
6
+ import { renderKbd as f } from "./primitives/kbd.js";
7
+ import { isIconName as k, renderIcon as $ } from "./primitives/icons.js";
8
+ class M {
9
+ constructor(t, o) {
10
+ this.host = t, this.opts = o, this.open = !1, this.mac = !1, this.unbinders = [], this.onDocMousedown = (e) => {
11
+ (!(e.target instanceof Node) || !this.host.contains(e.target)) && this.setOpen(!1);
12
+ }, this.onTriggerClick = (e) => {
13
+ !this.open && e.detail === 0 ? this.openAndFocus("first") : this.setOpen(!this.open);
14
+ }, this.onTriggerKeydown = (e) => {
15
+ (e.key === "ArrowDown" || e.key === "ArrowUp") && (e.preventDefault(), this.openAndFocus(e.key === "ArrowDown" ? "first" : "last"));
16
+ }, this.onMenuKeydown = (e) => {
17
+ var h;
18
+ const s = this.enabledButtons(), i = s.indexOf(e.target), a = (d) => {
19
+ var c;
20
+ e.preventDefault(), (c = s[(d + s.length) % s.length]) == null || c.focus();
21
+ };
22
+ switch (e.key) {
23
+ case "ArrowDown":
24
+ a(i + 1);
25
+ break;
26
+ case "ArrowUp":
27
+ a(i < 0 ? -1 : i - 1);
28
+ break;
29
+ case "Home":
30
+ a(0);
31
+ break;
32
+ case "End":
33
+ a(s.length - 1);
34
+ break;
35
+ case "Escape":
36
+ e.preventDefault(), this.setOpen(!1), (h = this.opts.trigger()) == null || h.focus();
37
+ break;
38
+ case "Tab":
39
+ this.setOpen(!1);
40
+ break;
41
+ }
42
+ }, t.addController(this), b(t, { panel: ".baht-menu" });
43
+ }
44
+ hostConnected() {
45
+ this.mac = p(), this.rebind();
46
+ }
47
+ hostDisconnected() {
48
+ this.unbindAll(), this.setOpen(!1);
49
+ }
50
+ /** Re-register item shortcuts — call when `items` changes. */
51
+ rebind() {
52
+ this.unbindAll();
53
+ for (const t of this.opts.items())
54
+ t.shortcut && this.unbinders.push(
55
+ m(
56
+ this.host,
57
+ t.shortcut,
58
+ () => {
59
+ this.pick(t);
60
+ },
61
+ () => !this.host.disabled && !t.disabled
62
+ )
63
+ );
64
+ }
65
+ unbindAll() {
66
+ for (const t of this.unbinders) t();
67
+ this.unbinders = [];
68
+ }
69
+ setOpen(t) {
70
+ this.open !== t && (this.open = t, this.host.requestUpdate(), l() && (t ? document.addEventListener("mousedown", this.onDocMousedown) : document.removeEventListener("mousedown", this.onDocMousedown)));
71
+ }
72
+ pick(t) {
73
+ this.host.disabled || t.disabled || (this.setOpen(!1), this.opts.onPick(t));
74
+ }
75
+ enabledButtons() {
76
+ return Array.from(this.host.querySelectorAll(".baht-menu-item")).filter(
77
+ (t) => t.getAttribute("aria-disabled") !== "true"
78
+ );
79
+ }
80
+ async openAndFocus(t) {
81
+ var e;
82
+ this.setOpen(!0), await this.host.updateComplete;
83
+ const o = this.enabledButtons();
84
+ (e = t === "first" ? o[0] : o.at(-1)) == null || e.focus();
85
+ }
86
+ renderItem(t) {
87
+ const o = t.shortcut ? u(t.shortcut, { mac: this.mac }) : "", e = t.checked !== void 0, s = t.icon && k(t.icon) ? $(t.icon) : n, i = [
88
+ "baht-menu-item",
89
+ t.disabled ? "baht-menu-item--disabled" : "",
90
+ t.danger ? "baht-menu-item--danger" : "",
91
+ e ? "baht-menu-item--check" : "",
92
+ s === n ? "" : "baht-menu-item--icon",
93
+ t.class ?? ""
94
+ ].filter(Boolean).join(" ");
95
+ return r`<button
96
+ type="button"
97
+ role=${e ? "menuitemcheckbox" : "menuitem"}
98
+ tabindex="-1"
99
+ class=${i}
100
+ lang=${t.lang ?? n}
101
+ aria-checked=${e ? String(t.checked) : n}
102
+ aria-disabled=${t.disabled ? "true" : n}
103
+ aria-keyshortcuts=${o || n}
104
+ @click=${() => {
105
+ this.pick(t);
106
+ }}
107
+ >
108
+ ${e ? r`<span class="baht-menu-item-box" aria-hidden="true">${t.checked ? "✓" : ""}</span>` : n}
109
+ ${s}
110
+ <span class="baht-menu-item-text">
111
+ <span class="baht-menu-item-label">${t.label}</span>
112
+ ${t.description ? r`<span class="baht-menu-item-desc">${t.description}</span>` : n}
113
+ </span>
114
+ ${t.shortcut ? f(t.shortcut, this.mac) : n}
115
+ </button>`;
116
+ }
117
+ /** The menu panel. `align` picks the edge it lines up with; `heading` is a non-item first line. */
118
+ render(t, o, e, s = "") {
119
+ return r`<div
120
+ class="baht-menu baht-menu--${o === "start" ? "start" : "end"}"
121
+ role="menu"
122
+ id=${t}
123
+ aria-label=${e || n}
124
+ ?hidden=${!this.open}
125
+ @keydown=${this.onMenuKeydown}
126
+ >
127
+ ${s ? r`<div class="baht-menu-heading" role="presentation">${s}</div>` : n}
128
+ ${this.opts.items().map((i) => this.renderItem(i))}
129
+ </div>`;
130
+ }
131
+ }
132
+ export {
133
+ M as MenuController
134
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Call `done` once the CSS animations currently running on `el` (or inside
3
+ * it) have finished — or right away when none play: `prefers-reduced-motion`
4
+ * (the stylesheet sets `animation: none`), a host without the tokens
5
+ * stylesheet, or a DOM without the Web Animations API (happy-dom). Add the
6
+ * `--leaving` class BEFORE calling this so the exit keyframes are the ones
7
+ * being waited on.
8
+ */
9
+ export declare function afterExit(el: Element, done: () => void): void;
@@ -0,0 +1,16 @@
1
+ function r(e, i) {
2
+ const n = typeof e.getAnimations == "function" ? e.getAnimations({ subtree: !0 }) : [];
3
+ if (n.length === 0) {
4
+ i();
5
+ return;
6
+ }
7
+ let s = !1;
8
+ const t = () => {
9
+ s || (s = !0, i());
10
+ };
11
+ Promise.all(n.map((o) => o.finished.catch(() => {
12
+ }))).then(t, t), setTimeout(t, 600);
13
+ }
14
+ export {
15
+ r as afterExit
16
+ };
@@ -0,0 +1,29 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ export interface AccordionItem {
4
+ title: string;
5
+ content: string;
6
+ open?: boolean;
7
+ }
8
+ /**
9
+ * Accordion. `items` drive the panels; `multiple` allows several open at once.
10
+ * Emits `baht-toggle { index, open }`.
11
+ *
12
+ * el.items = [
13
+ * { title: 'What is a workflow?', content: 'Workflows run when something happens…' },
14
+ * { title: 'Pricing', content: '฿20 / month.', open: true },
15
+ * ];
16
+ * @fires {CustomEvent<{ index: number; open: boolean }>} baht-toggle - A section opened or closed.
17
+ */
18
+ export declare class BahtAccordion extends BahtElement {
19
+ items: AccordionItem[];
20
+ multiple: boolean;
21
+ private openSet;
22
+ /** Fingerprint of the panel content and open flags — identity-independent, so an equal
23
+ * re-fed array doesn't look like a "new" set of items. */
24
+ private itemsFingerprint;
25
+ private static fingerprint;
26
+ protected willUpdate(changed: Map<PropertyKey, unknown>): void;
27
+ toggle(index: number): void;
28
+ protected render(): TemplateResult;
29
+ }
@@ -0,0 +1,66 @@
1
+ import { nothing as h, html as c } from "lit";
2
+ import { property as l, state as m } from "lit/decorators.js";
3
+ import { BahtElement as d } from "../base.js";
4
+ import { renderIcon as f } from "./icons.js";
5
+ import { customElement as g } from "../define.js";
6
+ var u = Object.defineProperty, b = Object.getOwnPropertyDescriptor, s = (e, t, o, n) => {
7
+ for (var i = n > 1 ? void 0 : n ? b(t, o) : t, a = e.length - 1, p; a >= 0; a--)
8
+ (p = e[a]) && (i = (n ? p(t, o, i) : p(i)) || i);
9
+ return n && i && u(t, o, i), i;
10
+ };
11
+ let r = class extends d {
12
+ constructor() {
13
+ super(...arguments), this.items = [], this.multiple = !1, this.openSet = /* @__PURE__ */ new Set(), this.itemsFingerprint = "";
14
+ }
15
+ static fingerprint(e) {
16
+ return JSON.stringify(e.map((t) => [t.title, t.content, !!t.open]));
17
+ }
18
+ willUpdate(e) {
19
+ if (e.has("items")) {
20
+ const t = r.fingerprint(this.items);
21
+ t !== this.itemsFingerprint && (this.itemsFingerprint = t, this.openSet = new Set(this.items.flatMap((o, n) => o.open ? [n] : [])));
22
+ }
23
+ }
24
+ toggle(e) {
25
+ const t = !this.openSet.has(e), o = this.multiple ? new Set(this.openSet) : /* @__PURE__ */ new Set();
26
+ t ? o.add(e) : o.delete(e), this.openSet = o, this.emit("baht-toggle", { index: e, open: t });
27
+ }
28
+ render() {
29
+ return c`<div class="baht-accordion">
30
+ ${this.items.map((e, t) => {
31
+ const o = this.openSet.has(t), n = `baht-acc-${this.uid}-t-${t}`, i = `baht-acc-${this.uid}-p-${t}`;
32
+ return c`<div class="baht-accordion-item${o ? " baht-accordion-item--open" : ""}">
33
+ <button
34
+ type="button"
35
+ class="baht-accordion-trigger"
36
+ id=${n}
37
+ aria-expanded=${o}
38
+ aria-controls=${o ? i : h}
39
+ @click=${() => {
40
+ this.toggle(t);
41
+ }}
42
+ >
43
+ <span>${e.title}</span>
44
+ <span class="baht-accordion-chevron" aria-hidden="true">${f("chevron-down")}</span>
45
+ </button>
46
+ ${o ? c`<div class="baht-accordion-content" id=${i} role="region" aria-labelledby=${n}>${e.content}</div>` : h}
47
+ </div>`;
48
+ })}
49
+ </div>`;
50
+ }
51
+ };
52
+ s([
53
+ l({ attribute: !1 })
54
+ ], r.prototype, "items", 2);
55
+ s([
56
+ l({ type: Boolean })
57
+ ], r.prototype, "multiple", 2);
58
+ s([
59
+ m()
60
+ ], r.prototype, "openSet", 2);
61
+ r = s([
62
+ g("baht-accordion")
63
+ ], r);
64
+ export {
65
+ r as BahtAccordion
66
+ };
@@ -0,0 +1,20 @@
1
+ import { nothing, TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * Inline alert / callout.
5
+ *
6
+ * <baht-alert tone="danger" heading="Couldn't reach the webhook"
7
+ * message="Check the URL and try again." dismissible></baht-alert>
8
+ * @fires {CustomEvent<void>} baht-dismiss - The close button was pressed.
9
+ */
10
+ export declare class BahtAlert extends BahtElement {
11
+ tone: 'info' | 'success' | 'warning' | 'danger';
12
+ heading: string;
13
+ message: string;
14
+ dismissible: boolean;
15
+ private dismissed;
16
+ private generation;
17
+ protected willUpdate(changed: Map<PropertyKey, unknown>): void;
18
+ private dismiss;
19
+ protected render(): TemplateResult | typeof nothing;
20
+ }
@@ -0,0 +1,62 @@
1
+ import { nothing as h, html as l } from "lit";
2
+ import { property as n, state as p } from "lit/decorators.js";
3
+ import { BahtElement as f } from "../base.js";
4
+ import { afterExit as b } from "../motion.js";
5
+ import { t as g } from "@20baht/engine";
6
+ import { customElement as c } from "../define.js";
7
+ var v = Object.defineProperty, u = Object.getOwnPropertyDescriptor, a = (t, s, e, o) => {
8
+ for (var i = o > 1 ? void 0 : o ? u(s, e) : s, m = t.length - 1, d; m >= 0; m--)
9
+ (d = t[m]) && (i = (o ? d(s, e, i) : d(i)) || i);
10
+ return o && i && v(s, e, i), i;
11
+ };
12
+ let r = class extends f {
13
+ constructor() {
14
+ super(...arguments), this.tone = "info", this.heading = "", this.message = "", this.dismissible = !1, this.dismissed = !1, this.generation = 0;
15
+ }
16
+ willUpdate(t) {
17
+ (t.has("message") || t.has("heading")) && (this.dismissed = !1, this.generation++);
18
+ }
19
+ dismiss() {
20
+ this.emit("baht-dismiss");
21
+ const t = this.generation, s = () => {
22
+ t === this.generation && (this.dismissed = !0);
23
+ }, e = this.querySelector(".baht-alert");
24
+ if (!e) {
25
+ s();
26
+ return;
27
+ }
28
+ e.classList.add("baht-alert--leaving"), b(e, s);
29
+ }
30
+ render() {
31
+ return this.dismissed ? h : l`<div class="baht-alert baht-alert--${this.tone}" role="alert">
32
+ <div class="baht-alert-main">
33
+ ${this.heading ? l`<div class="baht-alert-title">${this.heading}</div>` : h}
34
+ ${this.message ? l`<div class="baht-alert-message">${this.message}</div>` : h}
35
+ </div>
36
+ ${this.dismissible ? l`<button type="button" class="baht-alert-dismiss" aria-label=${g("dismiss")} @click=${() => {
37
+ this.dismiss();
38
+ }}>×</button>` : h}
39
+ </div>`;
40
+ }
41
+ };
42
+ a([
43
+ n()
44
+ ], r.prototype, "tone", 2);
45
+ a([
46
+ n()
47
+ ], r.prototype, "heading", 2);
48
+ a([
49
+ n()
50
+ ], r.prototype, "message", 2);
51
+ a([
52
+ n({ type: Boolean })
53
+ ], r.prototype, "dismissible", 2);
54
+ a([
55
+ p()
56
+ ], r.prototype, "dismissed", 2);
57
+ r = a([
58
+ c("baht-alert")
59
+ ], r);
60
+ export {
61
+ r as BahtAlert
62
+ };
@@ -0,0 +1,81 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ import { IconName } from './icons.js';
4
+ /** One entry of the `<baht-app-shell>` navigator. */
5
+ export interface ShellNavItem {
6
+ key: string;
7
+ label: string;
8
+ href?: string;
9
+ /** Short count shown at the end of the row. */
10
+ badge?: string | number;
11
+ /** Heading this entry sits under. Consecutive entries with the same group fold together. */
12
+ group?: string;
13
+ /** Leading icon from the curated set; unknown names draw nothing. */
14
+ icon?: IconName;
15
+ }
16
+ /**
17
+ * An application's frame: a header band, a navigator on the left and the page. Children are the
18
+ * page; children with `data-slot="actions"` go at the end of the header, side by side in document
19
+ * order (no wrapper needed). Below 900px the navigator becomes a strip that scrolls sideways.
20
+ * A `data-slot="breadcrumb"` child sits in the header after the brand (a `<baht-breadcrumbs>`,
21
+ * "Workspace / Servers"); a `data-slot="nav-start"` child sits above the navigator (a project
22
+ * or region card).
23
+ *
24
+ * `scroll="main"` keeps the header and the navigator still from 900px up: the shell is the
25
+ * window's height and the page and the navigator scroll on their own. `scroll="page"` (the
26
+ * default) lets the whole frame grow with the page and scroll as one.
27
+ *
28
+ * <baht-app-shell brand="itsm" brand-sub="IT service management" value="home" filterable>
29
+ * <baht-theme-toggle data-slot="actions"></baht-theme-toggle>
30
+ * <baht-menu data-slot="actions" label="Account"></baht-menu>
31
+ * <main-page></main-page>
32
+ * </baht-app-shell>
33
+ * shell.items = [{ key: 'home', label: 'Home', href: '/' }, { key: 'tasks', label: 'My tasks', href: '/tasks', badge: 3 }];
34
+ *
35
+ * Entries with a `group` sit under a heading that folds them away; `collapsed-groups` names the
36
+ * ones folded at first. The group holding the current entry, and every group while filtering,
37
+ * is shown open. Below 900px groups flatten into the one strip.
38
+ *
39
+ * @fires {CustomEvent<{ key: string; href: string | undefined }>} baht-nav - An entry was pressed. `detail: { key, href }`. Cancelable: `preventDefault()`
40
+ * to route yourself. Clicks with a modifier key are left to the browser.
41
+ * @fires {CustomEvent<{ group: string; collapsed: boolean }>} baht-nav-group - A group heading was pressed. `detail: { group, collapsed }`.
42
+ */
43
+ export declare class BahtAppShell extends BahtElement {
44
+ brand: string;
45
+ brandSub: string;
46
+ brandHref: string;
47
+ /** A further line in the header, naming the part of the application. */
48
+ context: string;
49
+ items: ShellNavItem[];
50
+ /** Key of the current entry. */
51
+ value: string;
52
+ /** Show a box that narrows the navigator as you type. */
53
+ filterable: boolean;
54
+ /** Accessible name of the navigator. */
55
+ label: string;
56
+ /** Groups folded away; the shell keeps it in step as headings are pressed. */
57
+ collapsedGroups: string[];
58
+ /**
59
+ * `'page'` (default): the frame grows with the page and the window scrolls. `'main'`: from
60
+ * 900px up the shell is the window's height, header and navigator stay put, and the page
61
+ * scrolls inside `.baht-shell-main` (the navigator on its own too).
62
+ */
63
+ scrollMode: 'page' | 'main';
64
+ private filter;
65
+ private actionsEl;
66
+ private mainEl;
67
+ private shellEl;
68
+ private breadcrumbEl;
69
+ private navStartEl;
70
+ protected adoptChildren(): void;
71
+ private readonly onFilter;
72
+ private toggleGroup;
73
+ private renderRun;
74
+ private renderItem;
75
+ protected render(): TemplateResult;
76
+ }
77
+ declare global {
78
+ interface HTMLElementTagNameMap {
79
+ 'baht-app-shell': BahtAppShell;
80
+ }
81
+ }
@@ -0,0 +1,161 @@
1
+ import { html as i, nothing as n } from "lit";
2
+ import { property as h, state as m, query as b } from "lit/decorators.js";
3
+ import { BahtElement as $, adoptSlotted as y, hasSlotted as d, routeClick as u } from "../base.js";
4
+ import { isSafeUrl as f, t as v } from "@20baht/engine";
5
+ import { customElement as g } from "../define.js";
6
+ import { isIconName as E, renderIcon as S } from "./icons.js";
7
+ var k = Object.defineProperty, G = Object.getOwnPropertyDescriptor, r = (t, a, e, s) => {
8
+ for (var o = s > 1 ? void 0 : s ? G(a, e) : a, c = t.length - 1, p; c >= 0; c--)
9
+ (p = t[c]) && (o = (s ? p(a, e, o) : p(o)) || o);
10
+ return s && o && k(a, e, o), o;
11
+ };
12
+ const x = (t) => {
13
+ const a = [];
14
+ for (const e of t) {
15
+ const s = e.group ?? null, o = a.at(-1);
16
+ (o == null ? void 0 : o.group) === s ? o.items.push(e) : a.push({ group: s, items: [e] });
17
+ }
18
+ return a;
19
+ };
20
+ let l = class extends $ {
21
+ constructor() {
22
+ super(...arguments), this.brand = "", this.brandSub = "", this.brandHref = "/", this.context = "", this.items = [], this.value = "", this.filterable = !1, this.label = "", this.collapsedGroups = [], this.scrollMode = "page", this.filter = "", this.onFilter = (t) => {
23
+ this.filter = t.target.value;
24
+ };
25
+ }
26
+ adoptChildren() {
27
+ const t = {
28
+ actions: this.actionsEl,
29
+ breadcrumb: this.breadcrumbEl,
30
+ "nav-start": this.navStartEl
31
+ };
32
+ y(this, this.mainEl, t), this.shellEl.classList.toggle("baht-shell--breadcrumb", d(this.breadcrumbEl)), this.shellEl.classList.toggle("baht-shell--nav-start", d(this.navStartEl));
33
+ }
34
+ toggleGroup(t) {
35
+ const a = !this.collapsedGroups.includes(t);
36
+ this.collapsedGroups = a ? [...this.collapsedGroups, t] : this.collapsedGroups.filter((e) => e !== t), this.emit("baht-nav-group", { group: t, collapsed: a });
37
+ }
38
+ renderRun(t, a) {
39
+ const e = t.items.map((p) => this.renderItem(p));
40
+ if (t.group === null) return i`${e}`;
41
+ const s = t.group, o = t.items.some((p) => p.key === this.value), c = a || o || !this.collapsedGroups.includes(s);
42
+ return i`<div class="baht-shell-group">
43
+ <button
44
+ type="button"
45
+ class="baht-shell-group-head"
46
+ aria-expanded=${c ? "true" : "false"}
47
+ @click=${() => {
48
+ this.toggleGroup(s);
49
+ }}
50
+ >
51
+ <span>${s}</span>
52
+ </button>
53
+ <div class="baht-shell-group-items" ?hidden=${!c}>${e}</div>
54
+ </div>`;
55
+ }
56
+ renderItem(t) {
57
+ const a = t.href && f(t.href) ? t.href : "#", e = t.key === this.value, s = t.icon && E(t.icon) ? S(t.icon) : n;
58
+ return i`<a
59
+ class="baht-shell-link${e ? " baht-shell-link--on" : ""}${s === n ? "" : " baht-shell-link--icon"}"
60
+ href=${a}
61
+ aria-current=${e ? "page" : n}
62
+ @click=${(o) => {
63
+ u(this, "baht-nav", o, { key: t.key, href: t.href });
64
+ }}
65
+ >
66
+ ${s}<span>${t.label}</span>
67
+ ${t.badge === void 0 || t.badge === "" ? n : i`<span class="baht-shell-badge">${t.badge}</span>`}
68
+ </a>`;
69
+ }
70
+ render() {
71
+ const t = this.filter.trim().toLowerCase(), a = t ? this.items.filter((s) => s.label.toLowerCase().includes(t)) : this.items, e = f(this.brandHref) ? this.brandHref : "/";
72
+ return i`<div class="baht-shell${this.scrollMode === "main" ? " baht-shell--scroll-main" : ""}">
73
+ <header class="baht-shell-header">
74
+ <a
75
+ class="baht-shell-brand"
76
+ href=${e}
77
+ @click=${(s) => {
78
+ u(this, "baht-nav", s, { key: "", href: e });
79
+ }}
80
+ >
81
+ <span class="baht-shell-brand-mark">${this.brand}</span>
82
+ ${this.brandSub ? i`<span class="baht-shell-brand-sub">${this.brandSub}</span>` : n}
83
+ </a>
84
+ ${this.context ? i`<span class="baht-shell-context">${this.context}</span>` : n}
85
+ <div class="baht-shell-breadcrumb"></div>
86
+ <div class="baht-shell-actions"></div>
87
+ </header>
88
+ <div class="baht-shell-body">
89
+ <aside class="baht-shell-side" aria-label=${this.label || n}>
90
+ <div class="baht-shell-nav-start"></div>
91
+ ${this.filterable ? i`<input
92
+ class="baht-shell-filter"
93
+ type="search"
94
+ placeholder=${v("filterNavigator")}
95
+ aria-label=${v("filterNavigator")}
96
+ .value=${this.filter}
97
+ @input=${this.onFilter}
98
+ />` : n}
99
+ <nav class="baht-shell-nav">
100
+ ${x(a).map((s) => this.renderRun(s, t !== ""))}
101
+ </nav>
102
+ </aside>
103
+ <main class="baht-shell-main"></main>
104
+ </div>
105
+ </div>`;
106
+ }
107
+ };
108
+ r([
109
+ h()
110
+ ], l.prototype, "brand", 2);
111
+ r([
112
+ h({ attribute: "brand-sub" })
113
+ ], l.prototype, "brandSub", 2);
114
+ r([
115
+ h({ attribute: "brand-href" })
116
+ ], l.prototype, "brandHref", 2);
117
+ r([
118
+ h()
119
+ ], l.prototype, "context", 2);
120
+ r([
121
+ h({ attribute: !1 })
122
+ ], l.prototype, "items", 2);
123
+ r([
124
+ h()
125
+ ], l.prototype, "value", 2);
126
+ r([
127
+ h({ type: Boolean })
128
+ ], l.prototype, "filterable", 2);
129
+ r([
130
+ h()
131
+ ], l.prototype, "label", 2);
132
+ r([
133
+ h({ attribute: !1 })
134
+ ], l.prototype, "collapsedGroups", 2);
135
+ r([
136
+ h({ attribute: "scroll", reflect: !0 })
137
+ ], l.prototype, "scrollMode", 2);
138
+ r([
139
+ m()
140
+ ], l.prototype, "filter", 2);
141
+ r([
142
+ b(".baht-shell-actions")
143
+ ], l.prototype, "actionsEl", 2);
144
+ r([
145
+ b(".baht-shell-main")
146
+ ], l.prototype, "mainEl", 2);
147
+ r([
148
+ b(".baht-shell")
149
+ ], l.prototype, "shellEl", 2);
150
+ r([
151
+ b(".baht-shell-breadcrumb")
152
+ ], l.prototype, "breadcrumbEl", 2);
153
+ r([
154
+ b(".baht-shell-nav-start")
155
+ ], l.prototype, "navStartEl", 2);
156
+ l = r([
157
+ g("baht-app-shell")
158
+ ], l);
159
+ export {
160
+ l as BahtAppShell
161
+ };
@@ -0,0 +1,59 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ type ChainTone = 'neutral' | 'success' | 'warning' | 'danger' | 'info' | 'outline';
4
+ /** One person on a step of `<baht-approval-chain>`. All wording is the host's. */
5
+ export interface ChainApprover {
6
+ key: string;
7
+ name: string;
8
+ title?: string;
9
+ stateLabel: string;
10
+ tone?: ChainTone;
11
+ /** A small tag beside the state, e.g. "yours". */
12
+ tag?: string;
13
+ /** Further lines: what they must be, when they acted, when it is due. */
14
+ notes?: string[];
15
+ /** Something wrong with this slot, shown as an error. */
16
+ problem?: string;
17
+ comment?: string;
18
+ }
19
+ /** One step of `<baht-approval-chain>`. */
20
+ export interface ChainStep {
21
+ key: string;
22
+ label: string;
23
+ status: 'done' | 'current' | 'upcoming';
24
+ statusLabel: string;
25
+ tone?: ChainTone;
26
+ /** Who it is with, under the label. */
27
+ who?: string;
28
+ /** e.g. "Any one approver". */
29
+ rule?: string;
30
+ /** e.g. "0 of 1 approved". */
31
+ progress?: string;
32
+ /** Set when nobody can act: shown as an alert, and the step opens. */
33
+ stalled?: {
34
+ heading: string;
35
+ message: string;
36
+ };
37
+ approvers?: ChainApprover[];
38
+ }
39
+ /**
40
+ * An approval route: each step in order, who it is with and how far it got. The current step and a
41
+ * stalled one start open; the others fold.
42
+ *
43
+ * <baht-approval-chain heading="Approvals"></baht-approval-chain>
44
+ * chain.steps = [{ key: 'mgr', label: 'Manager', status: 'current', statusLabel: 'Waiting',
45
+ * rule: 'Any one approver', approvers: [{ key: 'a', name: 'Alice', stateLabel: 'Pending' }] }];
46
+ */
47
+ export declare class BahtApprovalChain extends BahtElement {
48
+ heading: string;
49
+ steps: ChainStep[];
50
+ private renderApprover;
51
+ private renderStep;
52
+ protected render(): TemplateResult;
53
+ }
54
+ declare global {
55
+ interface HTMLElementTagNameMap {
56
+ 'baht-approval-chain': BahtApprovalChain;
57
+ }
58
+ }
59
+ export {};