@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,176 @@
1
+ import { html as i, nothing as p } from "lit";
2
+ import { property as b, state as c } from "lit/decorators.js";
3
+ import { BahtElement as y, stringOf as d, arr as u } from "../base.js";
4
+ import { customElement as f } from "../define.js";
5
+ var m = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, h = (a, t, e, s) => {
6
+ for (var r = s > 1 ? void 0 : s ? $(t, e) : t, l = a.length - 1, n; l >= 0; l--)
7
+ (n = a[l]) && (r = (s ? n(t, e, r) : n(r)) || r);
8
+ return s && r && m(t, e, r), r;
9
+ };
10
+ let o = class extends y {
11
+ constructor() {
12
+ super(...arguments), this.columns = [], this.rows = [], this.rowKey = "id", this.addable = !1, this.removable = !1, this.label = "Table", this.edits = /* @__PURE__ */ new Map(), this.draft = {};
13
+ }
14
+ willUpdate(a) {
15
+ a.has("rows") && (this.edits = /* @__PURE__ */ new Map());
16
+ }
17
+ setDraft(a, t) {
18
+ this.draft = { ...this.draft, [a]: t };
19
+ }
20
+ addDraft() {
21
+ this.emit("baht-row-add", { row: this.draft }), this.draft = {};
22
+ }
23
+ keyOf(a) {
24
+ return d(a[this.rowKey]);
25
+ }
26
+ editCell(a, t, e) {
27
+ const s = this.keyOf(a), r = new Map(this.edits);
28
+ r.set(s, { ...this.edits.get(s) ?? a, [t.key]: e }), this.edits = r;
29
+ }
30
+ inputValue(a, t) {
31
+ const e = a.target;
32
+ return t.type === "checkbox" ? e.checked : t.type === "number" ? e.value === "" ? null : Number(e.value) : e.value;
33
+ }
34
+ cell(a, t, e) {
35
+ const s = a[t.key], r = t.label;
36
+ switch (t.type) {
37
+ case "readonly":
38
+ return i`<span class="baht-edit-readonly">${d(s)}</span>`;
39
+ case "checkbox":
40
+ return i`<input
41
+ type="checkbox"
42
+ aria-label=${r}
43
+ .checked=${s === !0}
44
+ @change=${(l) => {
45
+ e(this.inputValue(l, t));
46
+ }}
47
+ />`;
48
+ case "select":
49
+ return i`<select
50
+ class="baht-control"
51
+ aria-label=${r}
52
+ @change=${(l) => {
53
+ e(this.inputValue(l, t));
54
+ }}
55
+ >
56
+ <option value="" ?selected=${s == null || s === ""}>—</option>
57
+ ${u(t.options).map(
58
+ (l) => i`<option value=${l.key} ?selected=${d(s) === l.key}>${l.label}</option>`
59
+ )}
60
+ </select>`;
61
+ case "text":
62
+ case "number":
63
+ case void 0:
64
+ default:
65
+ return i`<input
66
+ class="baht-control"
67
+ type=${t.type === "number" ? "number" : "text"}
68
+ aria-label=${r}
69
+ .value=${d(s)}
70
+ @input=${(l) => {
71
+ e(this.inputValue(l, t));
72
+ }}
73
+ />`;
74
+ }
75
+ }
76
+ render() {
77
+ const a = u(this.columns);
78
+ return i`<div class="baht-edit-table-wrap">
79
+ <table class="baht-edit-table" aria-label=${this.label}>
80
+ <thead>
81
+ <tr>
82
+ ${a.map((t) => i`<th scope="col">${t.label}</th>`)}
83
+ <th scope="col"><span class="baht-visually-hidden">Actions</span></th>
84
+ </tr>
85
+ </thead>
86
+ <tbody>
87
+ ${this.addable ? i`<tr class="baht-edit-new">
88
+ ${a.map(
89
+ (t) => i`<td>
90
+ ${this.cell(
91
+ this.draft,
92
+ t.type === "readonly" ? { ...t, type: "text" } : t,
93
+ (e) => {
94
+ this.setDraft(t.key, e);
95
+ }
96
+ )}
97
+ </td>`
98
+ )}
99
+ <td class="baht-edit-actions">
100
+ <button
101
+ type="button"
102
+ class="baht-button baht-button--primary baht-button--sm"
103
+ ?disabled=${a.every((t) => this.draft[t.key] == null || this.draft[t.key] === "")}
104
+ @click=${() => {
105
+ this.addDraft();
106
+ }}
107
+ >
108
+ Add
109
+ </button>
110
+ </td>
111
+ </tr>` : p}
112
+ ${u(this.rows).map((t) => {
113
+ const e = this.keyOf(t), s = this.edits.get(e) ?? t, r = this.edits.has(e);
114
+ return i`<tr class=${r ? "baht-edit-dirty" : ""}>
115
+ ${a.map(
116
+ (l) => i`<td>${this.cell(s, l, (n) => {
117
+ this.editCell(t, l, n);
118
+ })}</td>`
119
+ )}
120
+ <td class="baht-edit-actions">
121
+ ${r ? i`<button
122
+ type="button"
123
+ class="baht-button baht-button--primary baht-button--sm"
124
+ @click=${() => {
125
+ this.emit("baht-row-save", { key: e, row: s });
126
+ }}
127
+ >
128
+ Save
129
+ </button>` : p}
130
+ ${this.removable ? i`<button
131
+ type="button"
132
+ class="baht-button baht-button--ghost baht-button--sm"
133
+ @click=${() => {
134
+ this.emit("baht-row-delete", { key: e, row: t });
135
+ }}
136
+ >
137
+ Remove
138
+ </button>` : p}
139
+ </td>
140
+ </tr>`;
141
+ })}
142
+ </tbody>
143
+ </table>
144
+ </div>`;
145
+ }
146
+ };
147
+ h([
148
+ b({ attribute: !1 })
149
+ ], o.prototype, "columns", 2);
150
+ h([
151
+ b({ attribute: !1 })
152
+ ], o.prototype, "rows", 2);
153
+ h([
154
+ b({ attribute: "row-key" })
155
+ ], o.prototype, "rowKey", 2);
156
+ h([
157
+ b({ type: Boolean })
158
+ ], o.prototype, "addable", 2);
159
+ h([
160
+ b({ type: Boolean })
161
+ ], o.prototype, "removable", 2);
162
+ h([
163
+ b()
164
+ ], o.prototype, "label", 2);
165
+ h([
166
+ c()
167
+ ], o.prototype, "edits", 2);
168
+ h([
169
+ c()
170
+ ], o.prototype, "draft", 2);
171
+ o = h([
172
+ f("baht-edit-table")
173
+ ], o);
174
+ export {
175
+ o as BahtEditTable
176
+ };
@@ -0,0 +1,26 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * Centered "nothing here" placeholder for lists, tables, and searches. Children are the actions,
5
+ * laid out in a row under the hint; a child with `data-slot="art"` (a sticker, a picture) takes the
6
+ * place of the `icon` illustration.
7
+ *
8
+ * <baht-empty-state message="No records to display" hint="Try clearing the filter"></baht-empty-state>
9
+ * <baht-empty-state message="No presets" hint="Make one to launch with a click">
10
+ * <baht-sticker data-slot="art" name="rack"></baht-sticker>
11
+ * <baht-button variant="primary">New preset</baht-button>
12
+ * </baht-empty-state>
13
+ */
14
+ export declare class BahtEmptyState extends BahtElement {
15
+ /** Illustration name (`empty-box`, `search-slash`, `folder`, …), or any emoji / short text. Empty string hides it. Hidden while a `data-slot="art"` child is present. */
16
+ icon: string;
17
+ /** The main line. */
18
+ message: string;
19
+ /** A muted line under the message. */
20
+ hint: string;
21
+ private boxEl;
22
+ private artEl;
23
+ private actionsEl;
24
+ protected adoptChildren(): void;
25
+ protected render(): TemplateResult;
26
+ }
@@ -0,0 +1,51 @@
1
+ import { nothing as c, html as p } from "lit";
2
+ import { property as l, query as n } from "lit/decorators.js";
3
+ import { BahtElement as d, adoptSlotted as b, hasSlotted as y } from "../base.js";
4
+ import { isIllustrationName as v, renderIllustration as E } from "./illustrations.js";
5
+ import { customElement as g } from "../define.js";
6
+ var u = Object.defineProperty, f = Object.getOwnPropertyDescriptor, e = (m, a, o, i) => {
7
+ for (var s = i > 1 ? void 0 : i ? f(a, o) : a, r = m.length - 1, h; r >= 0; r--)
8
+ (h = m[r]) && (s = (i ? h(a, o, s) : h(s)) || s);
9
+ return i && s && u(a, o, s), s;
10
+ };
11
+ let t = class extends d {
12
+ constructor() {
13
+ super(...arguments), this.icon = "empty-box", this.message = "Nothing to display", this.hint = "";
14
+ }
15
+ adoptChildren() {
16
+ b(this, this.actionsEl, { art: this.artEl }), this.boxEl.classList.toggle("baht-empty-state--art", y(this.artEl)), this.boxEl.classList.toggle("baht-empty-state--actions", y(this.actionsEl));
17
+ }
18
+ render() {
19
+ return p`<div class="baht-empty-state">
20
+ <div class="baht-empty-state-art"></div>
21
+ ${this.icon ? p`<div class="baht-empty-state-icon" aria-hidden="true">${v(this.icon) ? E(this.icon) : this.icon}</div>` : c}
22
+ <div class="baht-empty-state-message">${this.message}</div>
23
+ ${this.hint ? p`<div class="baht-empty-state-hint">${this.hint}</div>` : c}
24
+ <div class="baht-empty-state-actions"></div>
25
+ </div>`;
26
+ }
27
+ };
28
+ e([
29
+ l()
30
+ ], t.prototype, "icon", 2);
31
+ e([
32
+ l()
33
+ ], t.prototype, "message", 2);
34
+ e([
35
+ l()
36
+ ], t.prototype, "hint", 2);
37
+ e([
38
+ n(".baht-empty-state")
39
+ ], t.prototype, "boxEl", 2);
40
+ e([
41
+ n(".baht-empty-state-art")
42
+ ], t.prototype, "artEl", 2);
43
+ e([
44
+ n(".baht-empty-state-actions")
45
+ ], t.prototype, "actionsEl", 2);
46
+ t = e([
47
+ g("baht-empty-state")
48
+ ], t);
49
+ export {
50
+ t as BahtEmptyState
51
+ };
@@ -0,0 +1,21 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * Centered failure placeholder with an optional retry action.
5
+ * Emits `baht-retry` when the retry button is clicked.
6
+ *
7
+ * <baht-error-state heading="Backend unavailable"
8
+ * message="The API is not responding."
9
+ * retry-label="Retry"></baht-error-state>
10
+ * @fires {CustomEvent<void>} baht-retry - Retry was pressed.
11
+ */
12
+ export declare class BahtErrorState extends BahtElement {
13
+ /** Illustration name (`error` by default), or any emoji / short text. Empty string hides it. */
14
+ icon: string;
15
+ heading: string;
16
+ message: string;
17
+ /** Renders a retry button with this label; omit for no action. */
18
+ retryLabel: string;
19
+ private readonly onRetry;
20
+ protected render(): TemplateResult;
21
+ }
@@ -0,0 +1,44 @@
1
+ import { nothing as m, html as o } from "lit";
2
+ import { property as a } from "lit/decorators.js";
3
+ import { BahtElement as b } from "../base.js";
4
+ import "./baht-button.js";
5
+ import { isIllustrationName as c, renderIllustration as d } from "./illustrations.js";
6
+ import { customElement as v } from "../define.js";
7
+ var g = Object.defineProperty, u = Object.getOwnPropertyDescriptor, e = (p, s, h, i) => {
8
+ for (var t = i > 1 ? void 0 : i ? u(s, h) : s, n = p.length - 1, l; n >= 0; n--)
9
+ (l = p[n]) && (t = (i ? l(s, h, t) : l(t)) || t);
10
+ return i && t && g(s, h, t), t;
11
+ };
12
+ let r = class extends b {
13
+ constructor() {
14
+ super(...arguments), this.icon = "error", this.heading = "Something went wrong", this.message = "", this.retryLabel = "", this.onRetry = () => {
15
+ this.emit("baht-retry");
16
+ };
17
+ }
18
+ render() {
19
+ return o`<div class="baht-error-state" role="alert">
20
+ ${this.icon ? o`<div class="baht-error-state-icon" aria-hidden="true">${c(this.icon) ? d(this.icon) : this.icon}</div>` : m}
21
+ <div class="baht-error-state-heading">${this.heading}</div>
22
+ ${this.message ? o`<div class="baht-error-state-message">${this.message}</div>` : m}
23
+ ${this.retryLabel ? o`<baht-button size="sm" label=${this.retryLabel} @click=${this.onRetry}></baht-button>` : m}
24
+ </div>`;
25
+ }
26
+ };
27
+ e([
28
+ a()
29
+ ], r.prototype, "icon", 2);
30
+ e([
31
+ a()
32
+ ], r.prototype, "heading", 2);
33
+ e([
34
+ a()
35
+ ], r.prototype, "message", 2);
36
+ e([
37
+ a({ attribute: "retry-label" })
38
+ ], r.prototype, "retryLabel", 2);
39
+ r = e([
40
+ v("baht-error-state")
41
+ ], r);
42
+ export {
43
+ r as BahtErrorState
44
+ };
@@ -0,0 +1,42 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /** One fact of `<baht-facts>`: a label and its value. */
4
+ export interface FactItem {
5
+ label: string;
6
+ /** The value as text; a list is one line per entry (an address pool). */
7
+ value: string | number | string[];
8
+ /** Set the value in the monospace font (addresses, ids, hashes). */
9
+ mono?: boolean;
10
+ /** Names the item, so a child with `data-fact="<key>"` (a Copy button, a badge) joins its value. */
11
+ key?: string;
12
+ }
13
+ /**
14
+ * Label/value facts as a definition list (`<dl>`): labels in a muted column, values beside
15
+ * them. Stacks each label over its value when the element itself is narrow (under 20rem: a
16
+ * drawer, a phone), whatever the viewport.
17
+ *
18
+ * <baht-facts></baht-facts>
19
+ * el.items = [
20
+ * { label: 'Status', value: 'Active' },
21
+ * { label: 'Private IP', value: '10.0.0.12', mono: true },
22
+ * { label: 'Pools', value: ['10.0.0.10-10.0.0.50', '10.0.1.0/24'] },
23
+ * ];
24
+ *
25
+ * A child with `data-fact="<key>"` goes into the value of the item whose `key` matches, after the
26
+ * text: a Copy button beside a command, a badge beside a state.
27
+ *
28
+ * <baht-facts><baht-button data-fact="ssh" size="sm" variant="ghost">Copy</baht-button></baht-facts>
29
+ * el.items = [{ label: 'SSH', value: 'ssh ubuntu@10.0.0.4', key: 'ssh', mono: true }];
30
+ */
31
+ export declare class BahtFacts extends BahtElement {
32
+ /** The facts, in order. Set as a property: `el.items = [...]`. Values render as text. */
33
+ items: FactItem[];
34
+ protected adoptChildren(): void;
35
+ private renderValue;
36
+ protected render(): TemplateResult;
37
+ }
38
+ declare global {
39
+ interface HTMLElementTagNameMap {
40
+ 'baht-facts': BahtFacts;
41
+ }
42
+ }
@@ -0,0 +1,49 @@
1
+ import { html as r, nothing as p } from "lit";
2
+ import { repeat as h } from "lit/directives/repeat.js";
3
+ import { property as i } from "lit/decorators.js";
4
+ import { BahtElement as d, arr as m } from "../base.js";
5
+ import { customElement as b } from "../define.js";
6
+ var u = Object.defineProperty, y = Object.getOwnPropertyDescriptor, f = (t, a, o, s) => {
7
+ for (var e = s > 1 ? void 0 : s ? y(a, o) : a, c = t.length - 1, n; c >= 0; c--)
8
+ (n = t[c]) && (e = (s ? n(a, o, e) : n(e)) || e);
9
+ return s && e && u(a, o, e), e;
10
+ };
11
+ let l = class extends d {
12
+ constructor() {
13
+ super(...arguments), this.items = [];
14
+ }
15
+ // Children marked data-fact="<key>" join the value of the item with that key (base.ts).
16
+ adoptChildren() {
17
+ for (const t of Array.from(this.children)) {
18
+ if (!(t instanceof HTMLElement) || t.dataset.fact === void 0) continue;
19
+ const a = this.querySelector(
20
+ `.baht-facts-slot[data-fact-key="${CSS.escape(t.dataset.fact)}"]`
21
+ );
22
+ a == null || a.append(t);
23
+ }
24
+ }
25
+ renderValue(t) {
26
+ return Array.isArray(t) ? t.map((a) => r`<span class="baht-facts-line">${a}</span>`) : t;
27
+ }
28
+ render() {
29
+ return r`<dl class="baht-facts">
30
+ ${h(
31
+ m(this.items),
32
+ (t, a) => t.key ?? `#${String(a)}`,
33
+ (t) => r`<dt class="baht-facts-label">${t.label}</dt
34
+ ><dd class="baht-facts-value${t.mono ? " baht-facts-value--mono" : ""}"
35
+ ><span class="baht-facts-text">${this.renderValue(t.value)}</span>${t.key === void 0 ? p : r`<span class="baht-facts-slot" data-fact-key=${t.key}></span>`}</dd
36
+ >`
37
+ )}
38
+ </dl>`;
39
+ }
40
+ };
41
+ f([
42
+ i({ attribute: !1 })
43
+ ], l.prototype, "items", 2);
44
+ l = f([
45
+ b("baht-facts")
46
+ ], l);
47
+ export {
48
+ l as BahtFacts
49
+ };
@@ -0,0 +1,19 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * Semantic group wrapper (native <fieldset>/<legend>). Children become the
5
+ * content — typically a set of baht-* fields.
6
+ *
7
+ * <baht-fieldset legend="Billing" help="Shown on invoices">
8
+ * <baht-input>…</baht-input>
9
+ * </baht-fieldset>
10
+ */
11
+ export declare class BahtFieldset extends BahtElement {
12
+ legend: string;
13
+ /** Muted help line under the group (e.g. "Fill both languages for accurate reading"). */
14
+ help: string;
15
+ disabled: boolean;
16
+ private bodyEl;
17
+ protected adoptChildren(): void;
18
+ protected render(): TemplateResult;
19
+ }
@@ -0,0 +1,42 @@
1
+ import { nothing as n, html as p } from "lit";
2
+ import { property as h, query as f } from "lit/decorators.js";
3
+ import { BahtElement as b, adoptLightChildren as m } from "../base.js";
4
+ import { customElement as y } from "../define.js";
5
+ var v = Object.defineProperty, c = Object.getOwnPropertyDescriptor, l = (a, s, d, r) => {
6
+ for (var e = r > 1 ? void 0 : r ? c(s, d) : s, i = a.length - 1, o; i >= 0; i--)
7
+ (o = a[i]) && (e = (r ? o(s, d, e) : o(e)) || e);
8
+ return r && e && v(s, d, e), e;
9
+ };
10
+ let t = class extends b {
11
+ constructor() {
12
+ super(...arguments), this.legend = "", this.help = "", this.disabled = !1;
13
+ }
14
+ adoptChildren() {
15
+ m(this, this.bodyEl);
16
+ }
17
+ render() {
18
+ return p`<fieldset class="baht-fieldset" ?disabled=${this.disabled}>
19
+ ${this.legend ? p`<legend>${this.legend}</legend>` : n}
20
+ <div class="baht-fieldset-body"></div>
21
+ ${this.help ? p`<div class="baht-help">${this.help}</div>` : n}
22
+ </fieldset>`;
23
+ }
24
+ };
25
+ l([
26
+ h()
27
+ ], t.prototype, "legend", 2);
28
+ l([
29
+ h()
30
+ ], t.prototype, "help", 2);
31
+ l([
32
+ h({ type: Boolean })
33
+ ], t.prototype, "disabled", 2);
34
+ l([
35
+ f(".baht-fieldset-body")
36
+ ], t.prototype, "bodyEl", 2);
37
+ t = l([
38
+ y("baht-fieldset")
39
+ ], t);
40
+ export {
41
+ t as BahtFieldset
42
+ };
@@ -0,0 +1,27 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtFieldBase } from '../field-base.js';
3
+ import { UploadedFile } from '@20baht/engine';
4
+ /**
5
+ * File field (spec 01 §2 + §13). Two modes:
6
+ * - capture (default): value = File handle(s); the lib never uploads.
7
+ * - upload (`field.uploader` + host `uploader` fn from the registry):
8
+ * picking uploads immediately, value becomes serializable UploadedFile
9
+ * ref(s), and the control shows chips with remove buttons.
10
+ * max_size (bytes) is enforced here as a soft filter — oversize files rejected.
11
+ */
12
+ export declare class BahtFile extends BahtFieldBase {
13
+ /** Resolved registry uploader — <baht-form> injects it when `field.uploader` is set. */
14
+ uploader?: (file: File) => Promise<UploadedFile>;
15
+ private uploadingCount;
16
+ private uploadError;
17
+ /** Names of files the last pick rejected for being over `field.max_size`. */
18
+ private rejectedNames;
19
+ private get refs();
20
+ private emitRefs;
21
+ private uploadAll;
22
+ private onPick;
23
+ private take;
24
+ private get captured();
25
+ private hintText;
26
+ protected renderControl(): TemplateResult;
27
+ }
@@ -0,0 +1,158 @@
1
+ import { nothing as p, html as s } from "lit";
2
+ import { property as m, state as c } from "lit/decorators.js";
3
+ import { ifDefined as b } from "lit/directives/if-defined.js";
4
+ import { BahtFieldBase as $ } from "../field-base.js";
5
+ import { t as l, isSafeUrl as v } from "@20baht/engine";
6
+ import { renderIcon as z } from "./icons.js";
7
+ import { renderIllustration as g } from "./illustrations.js";
8
+ import { customElement as y } from "../define.js";
9
+ var j = Object.defineProperty, x = Object.getOwnPropertyDescriptor, h = (t, i, r, e) => {
10
+ for (var a = e > 1 ? void 0 : e ? x(i, r) : i, o = t.length - 1, u; o >= 0; o--)
11
+ (u = t[o]) && (a = (e ? u(i, r, a) : u(a)) || a);
12
+ return e && a && j(i, r, a), a;
13
+ };
14
+ function f(t) {
15
+ return t !== null && typeof t == "object" && typeof t.url == "string";
16
+ }
17
+ function d(t) {
18
+ return t >= 1024 * 1024 ? `${(t / 1024 / 1024).toFixed(1)} MB` : t >= 1024 ? `${Math.round(t / 1024)} KB` : `${t} B`;
19
+ }
20
+ let n = class extends $ {
21
+ constructor() {
22
+ super(...arguments), this.uploadingCount = 0, this.uploadError = null, this.rejectedNames = [];
23
+ }
24
+ get refs() {
25
+ return Array.isArray(this.value) ? this.value.filter(f) : f(this.value) ? [this.value] : [];
26
+ }
27
+ emitRefs(t) {
28
+ this.emitInput(this.field.multiple ? t : t[0] ?? null);
29
+ }
30
+ async uploadAll(t) {
31
+ if (!this.uploader) return;
32
+ const i = this.field.multiple ? t : t.slice(0, 1);
33
+ this.uploadError = null, this.uploadingCount += i.length;
34
+ const r = [];
35
+ for (const e of i)
36
+ try {
37
+ r.push(await this.uploader(e));
38
+ } catch {
39
+ this.uploadError = l("uploadFailed");
40
+ } finally {
41
+ this.uploadingCount -= 1;
42
+ }
43
+ r.length !== 0 && this.emitRefs(this.field.multiple ? [...this.refs, ...r] : r);
44
+ }
45
+ onPick(t) {
46
+ const i = t.target;
47
+ this.take(Array.from(i.files ?? []), i);
48
+ }
49
+ take(t, i) {
50
+ const r = this.field.max_size, e = r ? t.filter((o) => o.size <= r) : t, a = r ? t.filter((o) => o.size > r) : [];
51
+ if (this.rejectedNames = a.map((o) => o.name), this.uploader) {
52
+ i && (i.value = ""), this.uploadAll(e);
53
+ return;
54
+ }
55
+ this.emitInput(this.field.multiple ? e : e[0] ?? null);
56
+ }
57
+ get captured() {
58
+ return this.uploader ? [] : Array.isArray(this.value) ? this.value.filter((t) => t instanceof File) : this.value instanceof File ? [this.value] : [];
59
+ }
60
+ hintText() {
61
+ const t = [];
62
+ return this.field.accept && t.push(
63
+ this.field.accept.split(",").map((i) => i.trim()).join(", ")
64
+ ), this.field.max_size && t.push(l("uploadMaxSize", { size: d(this.field.max_size) })), t.join(" · ");
65
+ }
66
+ renderControl() {
67
+ const t = this.disabled || this.readonly || this.uploadingCount > 0, i = this.hintText(), r = [
68
+ "baht-dropzone",
69
+ this.field.variant === "button" ? "baht-dropzone--button" : "",
70
+ t ? "baht-dropzone--disabled" : "",
71
+ this.invalidAttr === "true" ? "baht-dropzone--invalid" : ""
72
+ ].filter(Boolean).join(" ");
73
+ return s`<div
74
+ class=${r}
75
+ @dragover=${(e) => {
76
+ t || (e.preventDefault(), e.currentTarget.classList.add("baht-dropzone--over"));
77
+ }}
78
+ @dragleave=${(e) => {
79
+ e.currentTarget.classList.remove("baht-dropzone--over");
80
+ }}
81
+ @drop=${(e) => {
82
+ var a;
83
+ e.preventDefault(), e.currentTarget.classList.remove("baht-dropzone--over"), t || this.take(Array.from(((a = e.dataTransfer) == null ? void 0 : a.files) ?? []));
84
+ }}
85
+ >
86
+ <input
87
+ class="baht-control baht-control--file baht-dropzone-input"
88
+ id=${this.controlId}
89
+ type="file"
90
+ accept=${b(this.field.accept)}
91
+ ?multiple=${this.field.multiple}
92
+ ?disabled=${t}
93
+ ?required=${this.required}
94
+ aria-invalid=${this.invalidAttr}
95
+ aria-describedby=${this.describedBy}
96
+ @change=${(e) => {
97
+ this.onPick(e);
98
+ }}
99
+ />
100
+ <span class="baht-dropzone-icon" aria-hidden="true">${g("cloud-upload-arrow")}</span>
101
+ <span class="baht-dropzone-text">
102
+ <label class="baht-dropzone-action" for=${this.controlId}
103
+ >${this.field.multiple ? l("chooseFiles") : l("chooseFile")}</label
104
+ >
105
+ <span class="baht-dropzone-or">${l("orDropHere")}</span>
106
+ </span>
107
+ ${i ? s`<span class="baht-dropzone-hint">${i}</span>` : p}
108
+ </div>
109
+ ${this.uploadingCount > 0 ? s`<p class="baht-file-status" role="status">${l("uploading")}</p>` : p}
110
+ ${this.uploadError ? s`<p class="baht-error" role="alert">${this.uploadError}</p>` : p}
111
+ ${this.rejectedNames.length > 0 ? s`<p class="baht-error baht-file-rejected" role="alert">
112
+ ${l("fileRejectedTooLarge", { names: this.rejectedNames.join(", ") })}
113
+ </p>` : p}
114
+ ${this.captured.map(
115
+ (e) => s`<span class="baht-file-chip">
116
+ <span class="baht-file-name">${e.name}</span>
117
+ <span class="baht-file-size">${d(e.size)}</span>
118
+ </span>`
119
+ )}
120
+ ${this.refs.map(
121
+ (e) => s`<span class="baht-file-chip">
122
+ ${v(e.url) ? s`<a href=${e.url} target="_blank" rel="noreferrer"
123
+ >${e.name}<span class="baht-visually-hidden"> (${l("opensInNewTab")})</span></a
124
+ >` : s`<span class="baht-file-name">${e.name}</span>`}
125
+ <span class="baht-file-size">${d(e.size)}</span>
126
+ ${this.disabled || this.readonly ? p : s`<button
127
+ type="button"
128
+ class="baht-file-remove"
129
+ aria-label=${l("removeFile")}
130
+ title=${l("removeFile")}
131
+ @click=${() => {
132
+ this.emitRefs(this.refs.filter((a) => a !== e));
133
+ }}
134
+ >
135
+ ${z("close")}
136
+ </button>`}
137
+ </span>`
138
+ )}`;
139
+ }
140
+ };
141
+ h([
142
+ m({ attribute: !1 })
143
+ ], n.prototype, "uploader", 2);
144
+ h([
145
+ c()
146
+ ], n.prototype, "uploadingCount", 2);
147
+ h([
148
+ c()
149
+ ], n.prototype, "uploadError", 2);
150
+ h([
151
+ c()
152
+ ], n.prototype, "rejectedNames", 2);
153
+ n = h([
154
+ y("baht-file")
155
+ ], n);
156
+ export {
157
+ n as BahtFile
158
+ };