@20baht/ui 0.0.0-stage → 0.1.0

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 +501 -2
  3. package/dist/components/baht-form.d.ts +191 -0
  4. package/dist/components/baht-form.js +614 -0
  5. package/dist/components/baht-workflow.d.ts +173 -0
  6. package/dist/components/baht-workflow.js +430 -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 +45110 -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,39 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ import { FilterCondition, FilterField, FilterOp, FilterValue } from '@20baht/engine';
4
+ export type { FilterCondition, FilterField, FilterOp, FilterValue };
5
+ /** A cell as text: a list or record compares by its JSON. */
6
+ export declare const textOf: (value: unknown) => string;
7
+ /** Does a row pass? A filter with no conditions passes everything. `field` may be dotted. */
8
+ export declare const matchesFilter: (row: Record<string, unknown>, filter: FilterValue) => boolean;
9
+ /** The filter without conditions still waiting for their value: what Run and Save act on. */
10
+ export declare const completeFilter: (filter: FilterValue) => FilterValue;
11
+ /** A condition in words: "State is Open". */
12
+ export declare const conditionText: (c: FilterCondition, fields: FilterField[]) => string;
13
+ /**
14
+ * Builds a filter for a list: rows of column, comparison and value, all or any of them. It only
15
+ * edits the filter; the host applies it.
16
+ *
17
+ * filter.fields = [{ key: 'state', label: 'State', type: 'choice', options: [...] }];
18
+ * filter.addEventListener('baht-change', (e) => load(e.detail.value));
19
+ *
20
+ * @fires {CustomEvent<{ value: FilterValue }>} baht-change - The filter changed. `detail: { value }`.
21
+ */
22
+ export declare class BahtFilterBuilder extends BahtElement {
23
+ fields: FilterField[];
24
+ value: FilterValue;
25
+ private commit;
26
+ private patch;
27
+ private opsFor;
28
+ private fieldFor;
29
+ private add;
30
+ private changeField;
31
+ private renderValue;
32
+ private renderRow;
33
+ protected render(): TemplateResult;
34
+ }
35
+ declare global {
36
+ interface HTMLElementTagNameMap {
37
+ 'baht-filter-builder': BahtFilterBuilder;
38
+ }
39
+ }
@@ -0,0 +1,201 @@
1
+ import { nothing as f, html as s } from "lit";
2
+ import { property as $ } from "lit/decorators.js";
3
+ import { BahtElement as _ } from "../base.js";
4
+ import { t as r } from "@20baht/engine";
5
+ import { customElement as N } from "../define.js";
6
+ import { valueAt as F } from "./column-map.js";
7
+ var w = Object.defineProperty, O = Object.getOwnPropertyDescriptor, d = (t, o, e, i) => {
8
+ for (var n = i > 1 ? void 0 : i ? O(o, e) : o, l = t.length - 1, a; l >= 0; l--)
9
+ (a = t[l]) && (n = (i ? a(o, e, n) : a(n)) || n);
10
+ return i && n && w(o, e, n), n;
11
+ };
12
+ const q = {
13
+ text: ["contains", "eq", "ne", "empty", "not_empty"],
14
+ number: ["eq", "ne", "gt", "lt", "empty", "not_empty"],
15
+ date: ["eq", "gt", "lt", "empty", "not_empty"],
16
+ choice: ["eq", "ne", "empty", "not_empty"]
17
+ }, v = {
18
+ contains: "filterContains",
19
+ eq: "filterIs",
20
+ ne: "filterIsNot",
21
+ gt: "filterGreater",
22
+ lt: "filterLess",
23
+ empty: "filterEmpty",
24
+ not_empty: "filterNotEmpty"
25
+ }, p = (t) => t.target.value, c = (t) => t == null || t === "", u = (t) => c(t) ? "" : typeof t == "string" ? t : typeof t == "number" || typeof t == "boolean" ? String(t) : JSON.stringify(t), b = (t, o) => {
26
+ const e = Number(t), i = Number(o);
27
+ return !Number.isNaN(e) && !Number.isNaN(i) ? e - i : u(t).localeCompare(o);
28
+ }, g = /^\d{4}-\d{2}-\d{2}$/, y = (t) => String(t).padStart(2, "0"), E = (t) => {
29
+ if (typeof t != "string" || g.test(t)) return t;
30
+ const o = new Date(t);
31
+ return Number.isNaN(o.getTime()) ? t : `${String(o.getFullYear())}-${y(o.getMonth() + 1)}-${y(o.getDate())}`;
32
+ }, P = (t, { op: o, value: e }) => {
33
+ const i = g.test(e) ? E(t) : t;
34
+ switch (o) {
35
+ case "empty":
36
+ return c(i);
37
+ case "not_empty":
38
+ return !c(i);
39
+ case "contains":
40
+ return u(i).toLowerCase().includes(e.toLowerCase());
41
+ case "eq":
42
+ return u(i) === e;
43
+ case "ne":
44
+ return u(i) !== e;
45
+ case "gt":
46
+ return !c(i) && b(i, e) > 0;
47
+ case "lt":
48
+ return !c(i) && b(i, e) < 0;
49
+ }
50
+ }, D = (t, o) => {
51
+ if (o.conditions.length === 0) return !0;
52
+ const e = (i) => P(F(t, i.field), i);
53
+ return o.match === "any" ? o.conditions.some(e) : o.conditions.every(e);
54
+ }, V = (t) => ({
55
+ ...t,
56
+ conditions: t.conditions.filter(
57
+ (o) => o.op === "empty" || o.op === "not_empty" || o.value.trim() !== ""
58
+ )
59
+ }), x = (t, o) => {
60
+ var l, a;
61
+ const e = o.find((m) => m.key === t.field), i = r(v[t.op]), n = (e == null ? void 0 : e.label) ?? t.field;
62
+ return t.op === "empty" || t.op === "not_empty" ? `${n} ${i}` : `${n} ${i} ${((a = (l = e == null ? void 0 : e.options) == null ? void 0 : l.find((m) => m.key === t.value)) == null ? void 0 : a.label) ?? t.value}`;
63
+ };
64
+ let h = class extends _ {
65
+ constructor() {
66
+ super(...arguments), this.fields = [], this.value = { match: "all", conditions: [] };
67
+ }
68
+ commit(t) {
69
+ this.value = t, this.emit("baht-change", { value: t });
70
+ }
71
+ patch(t, o) {
72
+ this.commit({
73
+ ...this.value,
74
+ conditions: this.value.conditions.map((e, i) => i === t ? { ...e, ...o } : e)
75
+ });
76
+ }
77
+ opsFor(t) {
78
+ return q[(t == null ? void 0 : t.type) ?? "text"];
79
+ }
80
+ fieldFor(t) {
81
+ return this.fields.find((o) => o.key === t);
82
+ }
83
+ add() {
84
+ const t = this.fields[0];
85
+ t && this.commit({
86
+ ...this.value,
87
+ conditions: [
88
+ ...this.value.conditions,
89
+ { field: t.key, op: this.opsFor(t)[0] ?? "eq", value: "" }
90
+ ]
91
+ });
92
+ }
93
+ changeField(t, o) {
94
+ var n;
95
+ const e = this.opsFor(this.fieldFor(o)), i = (n = this.value.conditions[t]) == null ? void 0 : n.op;
96
+ this.patch(t, {
97
+ field: o,
98
+ op: i && e.includes(i) ? i : e[0] ?? "eq",
99
+ value: ""
100
+ });
101
+ }
102
+ renderValue(t, o) {
103
+ if (t.op === "empty" || t.op === "not_empty") return f;
104
+ const e = this.fieldFor(t.field), i = (n) => {
105
+ this.patch(o, { value: p(n) });
106
+ };
107
+ return (e == null ? void 0 : e.type) === "choice" ? s`<select class="baht-control" aria-label=${r("filterValue")} @change=${i}>
108
+ <option value="" ?selected=${t.value === ""}></option>
109
+ ${(e.options ?? []).map(
110
+ (n) => s`<option value=${n.key} ?selected=${n.key === t.value}>${n.label}</option>`
111
+ )}
112
+ </select>` : s`<input
113
+ class="baht-control"
114
+ type=${(e == null ? void 0 : e.type) === "number" || (e == null ? void 0 : e.type) === "date" ? e.type : "text"}
115
+ aria-label=${r("filterValue")}
116
+ .value=${t.value}
117
+ @change=${i}
118
+ />`;
119
+ }
120
+ renderRow(t, o) {
121
+ return s`<div class="baht-filter-builder-row" data-row=${o}>
122
+ <select
123
+ class="baht-control"
124
+ aria-label=${r("filterField")}
125
+ @change=${(e) => {
126
+ this.changeField(o, p(e));
127
+ }}
128
+ >
129
+ ${this.fields.map(
130
+ (e) => s`<option value=${e.key} ?selected=${e.key === t.field}>${e.label}</option>`
131
+ )}
132
+ </select>
133
+ <select
134
+ class="baht-control"
135
+ aria-label=${r("filterComparison")}
136
+ @change=${(e) => {
137
+ this.patch(o, { op: p(e) });
138
+ }}
139
+ >
140
+ ${this.opsFor(this.fieldFor(t.field)).map(
141
+ (e) => s`<option value=${e} ?selected=${e === t.op}>${r(v[e])}</option>`
142
+ )}
143
+ </select>
144
+ ${this.renderValue(t, o)}
145
+ <button
146
+ type="button"
147
+ class="baht-filter-builder-remove"
148
+ aria-label=${r("removeRowN", { n: o + 1 })}
149
+ @click=${() => {
150
+ this.commit({
151
+ ...this.value,
152
+ conditions: this.value.conditions.filter((e, i) => i !== o)
153
+ });
154
+ }}
155
+ >
156
+ ✕
157
+ </button>
158
+ </div>`;
159
+ }
160
+ render() {
161
+ return s`<div class="baht-filter-builder" role="group" aria-label=${r("filterHeading")}>
162
+ ${this.value.conditions.length > 1 ? s`<select
163
+ class="baht-control baht-filter-builder-match"
164
+ aria-label=${r("filterMatch")}
165
+ @change=${(t) => {
166
+ this.commit({ ...this.value, match: p(t) });
167
+ }}
168
+ >
169
+ <option value="all" ?selected=${this.value.match === "all"}>${r("filterMatchAll")}</option>
170
+ <option value="any" ?selected=${this.value.match === "any"}>${r("filterMatchAny")}</option>
171
+ </select>` : f}
172
+ ${this.value.conditions.map((t, o) => this.renderRow(t, o))}
173
+ <button
174
+ type="button"
175
+ class="baht-filter-builder-add"
176
+ ?disabled=${this.fields.length === 0}
177
+ @click=${() => {
178
+ this.add();
179
+ }}
180
+ >
181
+ + ${r("filterAdd")}
182
+ </button>
183
+ </div>`;
184
+ }
185
+ };
186
+ d([
187
+ $({ attribute: !1 })
188
+ ], h.prototype, "fields", 2);
189
+ d([
190
+ $({ attribute: !1 })
191
+ ], h.prototype, "value", 2);
192
+ h = d([
193
+ N("baht-filter-builder")
194
+ ], h);
195
+ export {
196
+ h as BahtFilterBuilder,
197
+ V as completeFilter,
198
+ x as conditionText,
199
+ D as matchesFilter,
200
+ u as textOf
201
+ };
@@ -0,0 +1,36 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ import { FieldOption } from '@20baht/engine';
4
+ export type FilterVariant = 'chips' | 'segmented';
5
+ /**
6
+ * Filter chip group. Controlled: emits `baht-change { selected }` (array of
7
+ * option keys), host re-feeds `selected`. Typical use: above an <baht-table>,
8
+ * the handler refetches page 1 with the new filters.
9
+ *
10
+ * const f = document.querySelector('baht-filter');
11
+ * f.options = [{ key: 'running', label: 'Running' }, { key: 'failed', label: 'Failed' }];
12
+ * f.selected = ['running'];
13
+ * f.addEventListener('baht-change', (e) => refetch({ status: e.detail.selected }));
14
+ *
15
+ * `variant="segmented"` draws the same options as one joined segmented
16
+ * control (a single bordered group, active segment filled with the ink
17
+ * colour) — for a period switch like Week / Month / Year. Pair it with
18
+ * `multiple="false"`: a segmented control always holds one value, so clicking
19
+ * the active segment does nothing (no `baht-change`) instead of clearing it.
20
+ * @fires {CustomEvent<{ selected: string[] }>} baht-change - The selection changed.
21
+ */
22
+ export declare class BahtFilter extends BahtElement {
23
+ options: FieldOption[];
24
+ selected: string[];
25
+ /** Look: `'chips'` (default) = separate pill chips; `'segmented'` = one joined
26
+ * segmented control. With `multiple=false` a segmented control never clears. */
27
+ variant: FilterVariant;
28
+ /** false = radio behavior (max one active; clicking it again clears — except
29
+ * with `variant="segmented"`, where the active segment stays selected). */
30
+ multiple: boolean;
31
+ disabled: boolean;
32
+ /** Accessible name for the chip group. */
33
+ label: string;
34
+ private toggle;
35
+ protected render(): TemplateResult;
36
+ }
@@ -0,0 +1,64 @@
1
+ import { html as h } from "lit";
2
+ import { property as o } from "lit/decorators.js";
3
+ import { boolOff as d, BahtElement as c } from "../base.js";
4
+ import { customElement as m } from "../define.js";
5
+ var b = Object.defineProperty, f = Object.getOwnPropertyDescriptor, l = (s, e, r, a) => {
6
+ for (var t = a > 1 ? void 0 : a ? f(e, r) : e, p = s.length - 1, n; p >= 0; p--)
7
+ (n = s[p]) && (t = (a ? n(e, r, t) : n(t)) || t);
8
+ return a && t && b(e, r, t), t;
9
+ };
10
+ let i = class extends c {
11
+ constructor() {
12
+ super(...arguments), this.options = [], this.selected = [], this.variant = "chips", this.multiple = !0, this.disabled = !1, this.label = "Filters";
13
+ }
14
+ toggle(s) {
15
+ const e = this.selected.includes(s);
16
+ let r;
17
+ if (this.multiple)
18
+ r = e ? this.selected.filter((t) => t !== s) : [...this.selected, s], r = this.options.map((t) => t.key).filter((t) => r.includes(t));
19
+ else {
20
+ if (e && this.variant === "segmented") return;
21
+ r = e ? [] : [s];
22
+ }
23
+ this.emit("baht-change", { selected: r });
24
+ }
25
+ render() {
26
+ const s = this.variant === "segmented" ? " baht-filter--segmented" : "";
27
+ return h`<div class="baht-filter${s}" role="group" aria-label=${this.label}>
28
+ ${this.options.map(
29
+ (e) => h`<button
30
+ type="button"
31
+ aria-pressed=${this.selected.includes(e.key)}
32
+ ?disabled=${this.disabled}
33
+ @click=${() => {
34
+ this.toggle(e.key);
35
+ }}
36
+ >${e.label}</button>`
37
+ )}
38
+ </div>`;
39
+ }
40
+ };
41
+ l([
42
+ o({ attribute: !1 })
43
+ ], i.prototype, "options", 2);
44
+ l([
45
+ o({ attribute: !1 })
46
+ ], i.prototype, "selected", 2);
47
+ l([
48
+ o()
49
+ ], i.prototype, "variant", 2);
50
+ l([
51
+ o({ converter: d })
52
+ ], i.prototype, "multiple", 2);
53
+ l([
54
+ o({ type: Boolean })
55
+ ], i.prototype, "disabled", 2);
56
+ l([
57
+ o()
58
+ ], i.prototype, "label", 2);
59
+ i = l([
60
+ m("baht-filter")
61
+ ], i);
62
+ export {
63
+ i as BahtFilter
64
+ };
@@ -0,0 +1,49 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtChartBase, ChartDatePoint } from './charts.js';
3
+ /**
4
+ * Calendar heat for one month or N weeks: one cell per day, colored on the
5
+ * sequential ramp, with a weekday header, a per-cell tooltip and a
6
+ * "less / more" scale legend.
7
+ *
8
+ * const el = document.createElement('baht-heatmap');
9
+ * el.values = [{ date: '2026-09-01', value: 420 }];
10
+ * el.from = '2026-09-01'; el.to = '2026-09-30';
11
+ *
12
+ * `show-values` swaps the compact GitHub-style SVG (weeks as columns) for a
13
+ * month grid rendered as HTML (weeks as rows): seven weekday headers, one
14
+ * focusable button per day carrying the day number and the formatted value,
15
+ * today's cell outlined. Being HTML, the grid fills its container while text
16
+ * keeps its real size — nothing is scaled. Cell height follows
17
+ * `--baht-heatmap-cell-min` (56px). The two darkest ramp steps flip to light
18
+ * text.
19
+ *
20
+ * <baht-heatmap show-values format="currency" zero-label="none" .values=${daily}></baht-heatmap>
21
+ */
22
+ export declare class BahtHeatmap extends BahtChartBase {
23
+ /** `{ date: 'YYYY-MM-DD', value }[]`; days with no entry render as empty. */
24
+ values: ChartDatePoint[];
25
+ /** First day (inclusive), `YYYY-MM-DD`. Defaults to the earliest value. */
26
+ from: string;
27
+ /** Last day (inclusive), `YYYY-MM-DD`. Defaults to the latest value. */
28
+ to: string;
29
+ /** Caption on the low end of the scale legend. */
30
+ lessLabel: string;
31
+ /** Caption on the high end of the scale legend. */
32
+ moreLabel: string;
33
+ /** Text shown in a zero/empty cell in `show-values` mode. */
34
+ zeroLabel: string;
35
+ /** Roomier month-grid layout with the day number and value printed in each cell. */
36
+ showValues: boolean;
37
+ /** Accessible summary; falls back to a generated sentence. */
38
+ label: string;
39
+ private get range();
40
+ protected render(): TemplateResult;
41
+ /** Compact GitHub-style layout: weeks as columns, weekdays as rows. */
42
+ private renderCompact;
43
+ /**
44
+ * `show-values` layout: an HTML month grid — weeks as rows, weekdays as
45
+ * columns, the day number and value printed in each cell. Buttons give
46
+ * every day focus and a role for free; the tooltip rides on focus/hover.
47
+ */
48
+ private renderCalendar;
49
+ }
@@ -0,0 +1,168 @@
1
+ import { html as u, nothing as T, svg as k } from "lit";
2
+ import { property as m } from "lit/decorators.js";
3
+ import { arr as S } from "../base.js";
4
+ import { BahtChartBase as z, chartSeqColor as x, renderTableTwin as A } from "./charts.js";
5
+ import { customElement as O } from "../define.js";
6
+ var P = Object.defineProperty, V = Object.getOwnPropertyDescriptor, c = (t, a, n, e) => {
7
+ for (var r = e > 1 ? void 0 : e ? V(a, n) : a, i = t.length - 1, s; i >= 0; i--)
8
+ (s = t[i]) && (r = (e ? s(a, n, r) : s(r)) || r);
9
+ return e && r && P(a, n, r), r;
10
+ };
11
+ const D = 22, y = 24, E = 34, C = 18, B = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
12
+ function M(t) {
13
+ const a = /^(\d{4})-(\d{2})-(\d{2})/.exec(t);
14
+ return a ? new Date(Date.UTC(+a[1], +a[2] - 1, +a[3])) : null;
15
+ }
16
+ function L(t) {
17
+ return t.toISOString().slice(0, 10);
18
+ }
19
+ function R() {
20
+ const t = /* @__PURE__ */ new Date(), a = String(t.getMonth() + 1).padStart(2, "0"), n = String(t.getDate()).padStart(2, "0");
21
+ return `${t.getFullYear()}-${a}-${n}`;
22
+ }
23
+ let p = class extends z {
24
+ constructor() {
25
+ super(...arguments), this.values = [], this.from = "", this.to = "", this.lessLabel = "Less", this.moreLabel = "More", this.zeroLabel = "—", this.showValues = !1, this.label = "";
26
+ }
27
+ get range() {
28
+ const t = S(this.values).map((e) => M(e.date)).filter((e) => !!e), a = M(this.from) ?? (t.length ? new Date(Math.min(...t.map((e) => +e))) : null), n = M(this.to) ?? (t.length ? new Date(Math.max(...t.map((e) => +e))) : null);
29
+ return !a || !n || +n < +a ? null : { start: a, end: n };
30
+ }
31
+ render() {
32
+ const t = this.hold({ values: S(this.values), range: this.range }), a = t.range;
33
+ if (!a || t.values.length === 0)
34
+ return u`<div class=${this.rootClass("baht-heatmap")}>${this.renderEmpty()}</div>`;
35
+ const n = new Map(t.values.map((l) => [l.date.slice(0, 10), l.value])), e = [], r = new Date(a.start), i = (a.start.getUTCDay() + 6) % 7;
36
+ let s = 0;
37
+ for (; +r <= +a.end; ) {
38
+ const l = L(r), v = (r.getUTCDay() + 6) % 7, g = Math.floor((i + s) / 7);
39
+ e.push({ iso: l, value: n.has(l) ? n.get(l) : null, weekday: v, week: g }), r.setUTCDate(r.getUTCDate() + 1), s += 1;
40
+ }
41
+ const h = Math.max(1, ...e.map((l) => l.value ?? 0)), o = (l) => Math.min(4, Math.max(0, Math.ceil(l / h * 5) - 1)), b = e.reduce((l, v) => l + (v.value ?? 0), 0), $ = this.label || `Calendar heatmap, ${e.length} days from ${L(a.start)} to ${L(a.end)}, total ${this.fmt(b)}`, d = R(), f = this.showValues ? this.renderCalendar(e, o, d, $) : this.renderCompact(e, o, $);
42
+ return u`<div class=${this.rootClass("baht-heatmap")}>
43
+ ${f}
44
+ ${this.renderTooltip()}
45
+ <div class="baht-heatmap-scale">
46
+ <span class="baht-heatmap-scale-label">${this.lessLabel}</span>
47
+ ${[0, 1, 2, 3, 4].map(
48
+ (l) => u`<span
49
+ class="baht-chart-swatch"
50
+ style=${`background:${x(l)}`}
51
+ aria-hidden="true"
52
+ ></span>`
53
+ )}
54
+ <span class="baht-heatmap-scale-label">${this.moreLabel}</span>
55
+ </div>
56
+ ${this.showTable ? A(
57
+ this.label || "Calendar heatmap data",
58
+ ["Date", "Value"],
59
+ e.map((l) => [l.iso, l.value == null ? "—" : this.fmt(l.value)])
60
+ ) : T}
61
+ </div>`;
62
+ }
63
+ /** Compact GitHub-style layout: weeks as columns, weekdays as rows. */
64
+ renderCompact(t, a, n) {
65
+ const e = Math.max(1, ...t.map((s) => s.week + 1)), r = E + e * y, i = C + 7 * y + 4;
66
+ return u`<svg
67
+ class="baht-chart-svg baht-heatmap-svg"
68
+ width=${r}
69
+ height=${i}
70
+ viewBox="0 0 ${r} ${i}"
71
+ preserveAspectRatio="xMinYMin meet"
72
+ role="img"
73
+ aria-label=${n}
74
+ >
75
+ ${B.map(
76
+ (s, h) => h % 2 === 0 ? k`<text class="baht-chart-tick" x="0" y=${C + h * y + D / 2 + 4}>${s}</text>` : T
77
+ )}
78
+ ${t.map((s) => {
79
+ const h = s.value == null ? `${s.iso}: no activity` : `${s.iso}: ${this.fmt(s.value)}`, o = s.value == null || s.value <= 0 ? "var(--baht-chart-grid)" : x(a(s.value));
80
+ return k`<rect class="baht-heatmap-cell" x=${E + s.week * y} y=${C + s.weekday * y}
81
+ width=${D} height=${D} rx="3" fill=${o} tabindex="0" role="button" aria-label=${h}
82
+ @pointermove=${(b) => {
83
+ this.showTip(b, h);
84
+ }}
85
+ @pointerleave=${() => {
86
+ this.hideTip();
87
+ }}
88
+ @focus=${(b) => {
89
+ this.showTip(b, h);
90
+ }}
91
+ @blur=${() => {
92
+ this.hideTip();
93
+ }}/>`;
94
+ })}
95
+ </svg>`;
96
+ }
97
+ /**
98
+ * `show-values` layout: an HTML month grid — weeks as rows, weekdays as
99
+ * columns, the day number and value printed in each cell. Buttons give
100
+ * every day focus and a role for free; the tooltip rides on focus/hover.
101
+ */
102
+ renderCalendar(t, a, n, e) {
103
+ var h;
104
+ const r = ((h = t[0]) == null ? void 0 : h.weekday) ?? 0, i = t.length ? 6 - t[t.length - 1].weekday : 0, s = (o) => Array.from(
105
+ { length: o },
106
+ () => u`<span class="baht-heatmap-day baht-heatmap-day--pad" aria-hidden="true"></span>`
107
+ );
108
+ return u`<div class="baht-heatmap-cal" role="group" aria-label=${e}>
109
+ ${B.map((o) => u`<span class="baht-heatmap-weekday" aria-hidden="true">${o}</span>`)}
110
+ ${s(r)}
111
+ ${t.map((o) => {
112
+ const b = o.iso === n, $ = o.value == null || o.value <= 0, d = $ ? null : a(o.value), f = d != null && d >= 3, l = o.value == null ? `${o.iso}: no activity` : `${o.iso}: ${this.fmt(o.value)}`, v = +o.iso.slice(8, 10), g = $ ? this.zeroLabel : this.fmt(o.value), U = `baht-heatmap-day${b ? " baht-heatmap-day--today" : ""}${$ ? " baht-heatmap-day--zero" : ""}${f ? " baht-heatmap-day--dark" : ""}`, _ = d == null ? "" : `--baht-heatmap-fill:${x(d)}`;
113
+ return u`<button
114
+ type="button"
115
+ class=${U}
116
+ style=${_ || T}
117
+ aria-label=${l}
118
+ @pointermove=${(w) => {
119
+ this.showTip(w, l);
120
+ }}
121
+ @pointerleave=${() => {
122
+ this.hideTip();
123
+ }}
124
+ @focus=${(w) => {
125
+ this.showTip(w, l);
126
+ }}
127
+ @blur=${() => {
128
+ this.hideTip();
129
+ }}
130
+ >
131
+ <span class="baht-heatmap-day-num">${v}</span>
132
+ <span class="baht-heatmap-day-value">${g}</span>
133
+ </button>`;
134
+ })}
135
+ ${s(i)}
136
+ </div>`;
137
+ }
138
+ };
139
+ c([
140
+ m({ attribute: !1 })
141
+ ], p.prototype, "values", 2);
142
+ c([
143
+ m()
144
+ ], p.prototype, "from", 2);
145
+ c([
146
+ m()
147
+ ], p.prototype, "to", 2);
148
+ c([
149
+ m({ attribute: "less-label" })
150
+ ], p.prototype, "lessLabel", 2);
151
+ c([
152
+ m({ attribute: "more-label" })
153
+ ], p.prototype, "moreLabel", 2);
154
+ c([
155
+ m({ attribute: "zero-label" })
156
+ ], p.prototype, "zeroLabel", 2);
157
+ c([
158
+ m({ type: Boolean, attribute: "show-values" })
159
+ ], p.prototype, "showValues", 2);
160
+ c([
161
+ m()
162
+ ], p.prototype, "label", 2);
163
+ p = c([
164
+ O("baht-heatmap")
165
+ ], p);
166
+ export {
167
+ p as BahtHeatmap
168
+ };
@@ -0,0 +1,10 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtFieldBase } from '../field-base.js';
3
+ /**
4
+ * text + email + password + time share one control; email differs only in input type +
5
+ * validator, password only in input type (masked, never formatted or logged), time is the
6
+ * browser's time-of-day input (value `HH:mm`, minutes only, bounded by `min` / `max`).
7
+ */
8
+ export declare class BahtInput extends BahtFieldBase {
9
+ protected renderControl(): TemplateResult;
10
+ }
@@ -0,0 +1,44 @@
1
+ import { html as h } from "lit";
2
+ import { ifDefined as e } from "lit/directives/if-defined.js";
3
+ import { live as m } from "lit/directives/live.js";
4
+ import { BahtFieldBase as p } from "../field-base.js";
5
+ import { customElement as c } from "../define.js";
6
+ var f = Object.getOwnPropertyDescriptor, $ = (t, s, n, o) => {
7
+ for (var i = o > 1 ? void 0 : o ? f(s, n) : s, r = t.length - 1, l; r >= 0; r--)
8
+ (l = t[r]) && (i = l(i) || i);
9
+ return i;
10
+ };
11
+ const u = { email: "email", password: "password", time: "time" }, a = (t) => typeof t == "string" && t !== "" ? t : void 0;
12
+ let d = class extends p {
13
+ renderControl() {
14
+ return h`<span class="baht-field-icon-wrap">
15
+ ${this.renderFieldIcon()}
16
+ <input
17
+ class="baht-control baht-control--text${this.hasFieldIcon ? " baht-control--has-icon" : ""}"
18
+ id=${this.controlId}
19
+ type=${u[this.field.type] ?? "text"}
20
+ step=${e(this.field.type === "time" ? "60" : void 0)}
21
+ min=${e(this.field.type === "time" ? a(this.field.min) : void 0)}
22
+ max=${e(this.field.type === "time" ? a(this.field.max) : void 0)}
23
+ .value=${m(this.shownText)}
24
+ placeholder=${e(this.field.placeholder)}
25
+ maxlength=${e(this.field.max_length)}
26
+ autocomplete=${e(this.field.autocomplete)}
27
+ ?disabled=${this.disabled}
28
+ ?readonly=${this.readonly}
29
+ ?required=${this.required}
30
+ aria-invalid=${this.invalidAttr}
31
+ aria-describedby=${this.describedBy}
32
+ @input=${(t) => {
33
+ this.emitTyped(t.target.value);
34
+ }}
35
+ />
36
+ </span>`;
37
+ }
38
+ };
39
+ d = $([
40
+ c("baht-input")
41
+ ], d);
42
+ export {
43
+ d as BahtInput
44
+ };
@@ -0,0 +1,28 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * Inline key = value row editor (field maps, config objects, …).
5
+ * Controlled: set `value`, listen for `baht-change` ({ value }) — rows with an
6
+ * empty key are kept while editing but dropped from the emitted object.
7
+ *
8
+ * const el = document.createElement('baht-keyvalue-editor');
9
+ * el.value = { state: 'resolved' };
10
+ * el.addEventListener('baht-change', (e) => save(e.detail.value));
11
+ * @fires {CustomEvent<{ value: Record<string, string> }>} baht-change - A pair was added, edited or removed.
12
+ */
13
+ export declare class BahtKeyvalueEditor extends BahtElement {
14
+ value: Record<string, unknown>;
15
+ keyPlaceholder: string;
16
+ valuePlaceholder: string;
17
+ add_label: string;
18
+ disabled: boolean;
19
+ private rows;
20
+ /** Last value synced/emitted, serialized — hosts re-feed fresh-but-equal objects. */
21
+ private syncedJson;
22
+ protected willUpdate(changed: Map<PropertyKey, unknown>): void;
23
+ private toRows;
24
+ private commit;
25
+ private edit;
26
+ private readonly addRow;
27
+ protected render(): TemplateResult;
28
+ }