@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,117 @@
1
+ import { html as r, nothing as l } from "lit";
2
+ import { property as s } from "lit/decorators.js";
3
+ import { boolOff as c, BahtElement as b } from "../base.js";
4
+ import { formatValue as h } from "./charts.js";
5
+ import { isIconName as m, renderIcon as v } from "./icons.js";
6
+ import "./baht-sparkline.js";
7
+ import { customElement as y } from "../define.js";
8
+ var f = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, a = (t, i, p, o) => {
9
+ for (var n = o > 1 ? void 0 : o ? $(i, p) : i, u = t.length - 1, d; u >= 0; u--)
10
+ (d = t[u]) && (n = (o ? d(i, p, n) : d(n)) || n);
11
+ return o && n && f(i, p, n), n;
12
+ };
13
+ const g = 5, w = 999;
14
+ let e = class extends b {
15
+ constructor() {
16
+ super(...arguments), this.label = "", this.value = 0, this.format = "number", this.currency = "THB", this.delta = null, this.deltaKind = "pct", this.deltaLabel = "", this.upIsGood = !0, this.trend = [], this.size = "md", this.previous = null, this.deltaTone = "auto";
17
+ }
18
+ /** A previous figure too small for a percentage to mean anything. */
19
+ get tinyBase() {
20
+ const t = this.previous;
21
+ return this.delta == null && t != null && Number.isFinite(t) && Math.abs(t) < g;
22
+ }
23
+ /** The delta shown: the one given, or the % change worked out from `previous`. */
24
+ get change() {
25
+ if (this.delta != null) return Number.isFinite(this.delta) ? this.delta : null;
26
+ const t = this.previous;
27
+ return t == null || !Number.isFinite(t) || this.tinyBase ? null : (this.value - t) / Math.abs(t) * 100;
28
+ }
29
+ /** Direction of the delta paired with whether up is good. */
30
+ get tone() {
31
+ const t = this.change;
32
+ return t == null || t === 0 || this.deltaTone === "neutral" ? "flat" : t > 0 === this.upIsGood ? "good" : "bad";
33
+ }
34
+ get arrow() {
35
+ const t = this.change ?? 0;
36
+ return t > 0 ? "↑" : t < 0 ? "↓" : "→";
37
+ }
38
+ get deltaText() {
39
+ const t = Math.abs(this.change ?? 0);
40
+ return this.delta != null && this.deltaKind === "abs" ? h(t, this.format, this.currency) : t > w ? "10×+" : h(t / 100, "percent");
41
+ }
42
+ renderChange() {
43
+ if (this.tinyBase) {
44
+ const i = h(this.previous ?? 0, this.format, this.currency);
45
+ return r`<span class="baht-stat-delta-value">was ${i}</span>`;
46
+ }
47
+ const t = this.change ?? 0;
48
+ return r`<span class="baht-stat-arrow" aria-hidden="true">${this.arrow}</span>
49
+ <span class="baht-stat-delta-value">${this.deltaText}</span>
50
+ <span class="baht-visually-hidden">${t > 0 ? "up" : t < 0 ? "down" : "flat"}</span>`;
51
+ }
52
+ render() {
53
+ const t = this.tinyBase || this.change != null, i = this.tinyBase ? "flat" : this.tone;
54
+ return r`<div class="baht-stat${this.size === "hero" ? " baht-stat--hero" : ""}">
55
+ ${this.label ? r`<div class="baht-stat-label-row">
56
+ ${this.icon && m(this.icon) ? r`<span class="baht-stat-icon">${v(this.icon)}</span>` : l}
57
+ <span class="baht-stat-label">${this.label}</span>
58
+ </div>` : l}
59
+ <div class="baht-stat-value">${h(this.value, this.format, this.currency)}</div>
60
+ ${t ? r`<div class="baht-stat-delta baht-stat-delta--${i}">
61
+ ${this.renderChange()}
62
+ ${this.deltaLabel ? r`<span class="baht-stat-delta-label">${this.deltaLabel}</span>` : l}
63
+ </div>` : l}
64
+ ${!t && this.deltaLabel ? r`<div class="baht-stat-caption">${this.deltaLabel}</div>` : l}
65
+ ${this.trend.length > 1 ? r`<baht-sparkline
66
+ class="baht-stat-trend"
67
+ .values=${this.trend}
68
+ label=${`${this.label || "Value"} trend, ${this.trend.length} points`}
69
+ ></baht-sparkline>` : l}
70
+ </div>`;
71
+ }
72
+ };
73
+ a([
74
+ s()
75
+ ], e.prototype, "label", 2);
76
+ a([
77
+ s({ type: Number })
78
+ ], e.prototype, "value", 2);
79
+ a([
80
+ s()
81
+ ], e.prototype, "format", 2);
82
+ a([
83
+ s()
84
+ ], e.prototype, "currency", 2);
85
+ a([
86
+ s({ type: Number })
87
+ ], e.prototype, "delta", 2);
88
+ a([
89
+ s({ attribute: "delta-kind" })
90
+ ], e.prototype, "deltaKind", 2);
91
+ a([
92
+ s({ attribute: "delta-label" })
93
+ ], e.prototype, "deltaLabel", 2);
94
+ a([
95
+ s({ attribute: "up-is-good", converter: c })
96
+ ], e.prototype, "upIsGood", 2);
97
+ a([
98
+ s({ type: Array })
99
+ ], e.prototype, "trend", 2);
100
+ a([
101
+ s()
102
+ ], e.prototype, "size", 2);
103
+ a([
104
+ s()
105
+ ], e.prototype, "icon", 2);
106
+ a([
107
+ s({ type: Number })
108
+ ], e.prototype, "previous", 2);
109
+ a([
110
+ s({ attribute: "delta-tone" })
111
+ ], e.prototype, "deltaTone", 2);
112
+ e = a([
113
+ y("baht-stat")
114
+ ], e);
115
+ export {
116
+ e as BahtStat
117
+ };
@@ -0,0 +1,33 @@
1
+ import { TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /**
4
+ * <baht-steps> — wizard progress indicator (spec 03). Standalone display
5
+ * primitive: numbered markers + labels, the current one highlighted, done
6
+ * ones checked. <baht-workflow show-steps> renders it automatically from its
7
+ * visible forms.
8
+ *
9
+ * `variant="compact"` is for narrow places (a modal, a drawer): numbered markers joined by a rule,
10
+ * and only the current step's label, once, under them. Five steps fit in 400px without scrolling;
11
+ * every label stays in the list for assistive tech.
12
+ */
13
+ export declare class BahtSteps extends BahtElement {
14
+ /** Step labels in order. */
15
+ steps: string[];
16
+ /** 0-based index of the current step. */
17
+ current: number;
18
+ /**
19
+ * 'default' = horizontal numbered markers; 'sidebar' = vertical nav list, current pilled;
20
+ * 'chevron' = a joined strip of states, scrolling sideways when it does not fit;
21
+ * 'compact' = markers only, the current label under them (fits a narrow modal).
22
+ */
23
+ variant: 'default' | 'sidebar' | 'chevron' | 'compact';
24
+ /** chevron: tick the steps before the current one. Off when the strip lists states, not progress. */
25
+ showDone: boolean;
26
+ protected render(): TemplateResult;
27
+ private renderList;
28
+ }
29
+ declare global {
30
+ interface HTMLElementTagNameMap {
31
+ 'baht-steps': BahtSteps;
32
+ }
33
+ }
@@ -0,0 +1,60 @@
1
+ import { html as r, nothing as l } from "lit";
2
+ import { property as h } from "lit/decorators.js";
3
+ import { BahtElement as d } from "../base.js";
4
+ import { t as u } from "@20baht/engine";
5
+ import { customElement as b } from "../define.js";
6
+ var m = Object.defineProperty, v = Object.getOwnPropertyDescriptor, i = (a, e, n, p) => {
7
+ for (var t = p > 1 ? void 0 : p ? v(e, n) : e, s = a.length - 1, c; s >= 0; s--)
8
+ (c = a[s]) && (t = (p ? c(e, n, t) : c(t)) || t);
9
+ return p && t && m(e, n, t), t;
10
+ };
11
+ let o = class extends d {
12
+ constructor() {
13
+ super(...arguments), this.steps = [], this.current = 0, this.variant = "default", this.showDone = !1;
14
+ }
15
+ render() {
16
+ return this.variant !== "compact" ? this.renderList() : r`<div class="baht-steps-compact">
17
+ ${this.renderList()}
18
+ <p class="baht-steps-caption" aria-hidden="true">${this.steps[this.current] ?? ""}</p>
19
+ </div>`;
20
+ }
21
+ renderList() {
22
+ const a = this.variant === "sidebar", e = this.variant === "chevron", n = this.variant === "compact";
23
+ return r`<ol
24
+ class="baht-steps ${a ? "baht-steps--sidebar" : ""}${e ? " baht-steps--chevron" : ""}${n ? " baht-steps--compact" : ""}"
25
+ aria-label=${u("step", { current: this.current + 1, total: this.steps.length })}
26
+ >
27
+ ${this.steps.map((p, t) => {
28
+ const s = t < this.current ? "done" : t === this.current ? "current" : "todo";
29
+ return r`<li
30
+ class="baht-step baht-step--${s} ${a ? "baht-step--sidebar" : ""}"
31
+ aria-current=${s === "current" ? "step" : "false"}
32
+ >
33
+ ${a || e ? l : r`<span class="baht-step-marker" aria-hidden="true">${s === "done" ? "✓" : t + 1}</span>`}
34
+ <span class="baht-step-label${n ? " baht-visually-hidden" : ""}"
35
+ >${p}${e && this.showDone && s === "done" ? r` <span aria-hidden="true">✓</span>` : l}</span
36
+ >
37
+ ${s === "done" ? r`<span class="baht-visually-hidden"> (${u("stepDone")})</span>` : s === "current" ? r`<span class="baht-visually-hidden"> (${u("stepCurrent")})</span>` : l}
38
+ </li>`;
39
+ })}
40
+ </ol>`;
41
+ }
42
+ };
43
+ i([
44
+ h({ attribute: !1 })
45
+ ], o.prototype, "steps", 2);
46
+ i([
47
+ h({ type: Number })
48
+ ], o.prototype, "current", 2);
49
+ i([
50
+ h()
51
+ ], o.prototype, "variant", 2);
52
+ i([
53
+ h({ type: Boolean, attribute: "show-done" })
54
+ ], o.prototype, "showDone", 2);
55
+ o = i([
56
+ b("baht-steps")
57
+ ], o);
58
+ export {
59
+ o as BahtSteps
60
+ };
@@ -0,0 +1,64 @@
1
+ import { PropertyValues, TemplateResult } from 'lit';
2
+ import { BahtElement } from '../base.js';
3
+ /** One action behind a swipe row. `tone: 'danger'` paints it in the danger colour. */
4
+ export interface SwipeAction {
5
+ key: string;
6
+ label: string;
7
+ tone?: 'neutral' | 'danger';
8
+ }
9
+ /**
10
+ * Row container for touch lists: the children are the row, `actions` sit behind
11
+ * it on the right and are revealed by swiping the row left.
12
+ *
13
+ * <baht-swipe-row><my-expense-row …></my-expense-row></baht-swipe-row>
14
+ * row.actions = [{ key: 'edit', label: 'Edit' }, { key: 'delete', label: 'Delete', tone: 'danger' }];
15
+ * row.addEventListener('baht-action', (e) => handle(e.detail.key));
16
+ *
17
+ * Pointer events (touch, pen, mouse): a horizontal drag moves the row; released
18
+ * more than 40px left it snaps open, more than 40px right (from open) it snaps
19
+ * shut, otherwise it springs back. Vertical drags are left to the page
20
+ * (`touch-action: pan-y`). An open row closes on a pointerdown outside it, on a
21
+ * tap on the row (that tap is swallowed, so the row's own click handler does not
22
+ * fire), on Escape, and after an action is pressed. The click that ends a drag
23
+ * is swallowed too.
24
+ *
25
+ * Keyboard: the actions are real buttons after the row content in tab order;
26
+ * focusing one reveals the row, focus leaving the row hides it again. The
27
+ * gesture is physical (swipe left, actions on the right) in either text direction.
28
+ * @fires {CustomEvent<{ key: string }>} baht-action - A revealed action was pressed.
29
+ */
30
+ export declare class BahtSwipeRow extends BahtElement {
31
+ /** Actions revealed by the swipe, in order: `{ key, label, tone? }`. */
32
+ actions: SwipeAction[];
33
+ /** Revealed state. Reflected; set it to open or close the row from the host. */
34
+ open: boolean;
35
+ /** Accessible name of the action group (default: the i18n `rowActions` string). */
36
+ label: string;
37
+ /** Content offset in px while a drag is in progress (`null` = not dragging). */
38
+ private dragX;
39
+ private start;
40
+ /** A drag just ended: swallow the click the browser fires after pointerup. */
41
+ private swallowClick;
42
+ private readonly onDocPointerdown;
43
+ disconnectedCallback(): void;
44
+ protected adoptChildren(): void;
45
+ protected updated(changed: PropertyValues<this>): void;
46
+ private get hasActions();
47
+ /** Width of the action strip — how far the row slides when open (0 without layout). */
48
+ private revealWidth;
49
+ private onPointerdown;
50
+ private onPointermove;
51
+ private onPointerup;
52
+ private onPointercancel;
53
+ /** Capture-phase click on the row content: eat the post-drag click and the closing tap. */
54
+ private onContentClick;
55
+ private onFocusout;
56
+ /** Keyboard path: focus on an action uncovers the strip. */
57
+ private reveal;
58
+ private onKeydown;
59
+ private pick;
60
+ private contentStyle;
61
+ /** The row itself: children are adopted in here; it carries the drag. */
62
+ private renderContent;
63
+ protected render(): TemplateResult;
64
+ }
@@ -0,0 +1,178 @@
1
+ import { html as h, nothing as w } from "lit";
2
+ import { property as p, state as m } from "lit/decorators.js";
3
+ import { BahtElement as b, hasDom as c, adoptLightChildren as g, arr as d } from "../base.js";
4
+ import { t as v } from "@20baht/engine";
5
+ import { customElement as y } from "../define.js";
6
+ var P = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, l = (t, e, n, i) => {
7
+ for (var o = i > 1 ? void 0 : i ? $(e, n) : e, r = t.length - 1, s; r >= 0; r--)
8
+ (s = t[r]) && (o = (i ? s(e, n, o) : s(o)) || o);
9
+ return i && o && P(e, n, o), o;
10
+ };
11
+ const u = 8, f = 40;
12
+ let a = class extends b {
13
+ constructor() {
14
+ super(...arguments), this.actions = [], this.open = !1, this.label = "", this.dragX = null, this.start = null, this.swallowClick = !1, this.onDocPointerdown = (t) => {
15
+ t.target instanceof Node && this.contains(t.target) || (this.open = !1);
16
+ };
17
+ }
18
+ disconnectedCallback() {
19
+ super.disconnectedCallback(), c() && document.removeEventListener("pointerdown", this.onDocPointerdown);
20
+ }
21
+ // After every render and whenever a framework host adds a child (base.ts).
22
+ adoptChildren() {
23
+ const t = this.querySelector(".baht-swipe-row-content");
24
+ t && g(this, t);
25
+ }
26
+ updated(t) {
27
+ t.has("open") && c() && (this.open ? document.addEventListener("pointerdown", this.onDocPointerdown) : document.removeEventListener("pointerdown", this.onDocPointerdown));
28
+ }
29
+ get hasActions() {
30
+ return d(this.actions).length > 0;
31
+ }
32
+ /** Width of the action strip — how far the row slides when open (0 without layout). */
33
+ revealWidth() {
34
+ var t;
35
+ return c() ? ((t = this.querySelector(".baht-swipe-row-actions")) == null ? void 0 : t.offsetWidth) ?? 0 : 0;
36
+ }
37
+ onPointerdown(t) {
38
+ !this.hasActions || t.button !== 0 || (this.swallowClick = !1, this.start = {
39
+ id: t.pointerId,
40
+ x: t.clientX,
41
+ y: t.clientY,
42
+ from: this.open ? -this.revealWidth() : 0,
43
+ wasOpen: this.open
44
+ });
45
+ }
46
+ onPointermove(t) {
47
+ const e = this.start;
48
+ if ((e == null ? void 0 : e.id) !== t.pointerId) return;
49
+ const n = t.clientX - e.x, i = t.clientY - e.y;
50
+ if (this.dragX === null) {
51
+ if (Math.abs(i) > u && Math.abs(i) >= Math.abs(n)) {
52
+ this.start = null;
53
+ return;
54
+ }
55
+ if (Math.abs(n) < u) return;
56
+ const s = t.currentTarget;
57
+ if (s instanceof HTMLElement && typeof s.setPointerCapture == "function")
58
+ try {
59
+ s.setPointerCapture(t.pointerId);
60
+ } catch {
61
+ }
62
+ }
63
+ const o = this.revealWidth(), r = Math.min(0, e.from + n);
64
+ this.dragX = o > 0 ? Math.max(-o, r) : r;
65
+ }
66
+ onPointerup(t) {
67
+ const e = this.start;
68
+ if (this.start = null, (e == null ? void 0 : e.id) !== t.pointerId || this.dragX === null) return;
69
+ const n = t.clientX - e.x;
70
+ this.dragX = null, this.swallowClick = !0, this.open = e.wasOpen ? n < f : n <= -f;
71
+ }
72
+ onPointercancel() {
73
+ this.start = null, this.dragX = null;
74
+ }
75
+ /** Capture-phase click on the row content: eat the post-drag click and the closing tap. */
76
+ onContentClick(t) {
77
+ if (this.swallowClick) {
78
+ this.swallowClick = !1, t.stopPropagation(), t.preventDefault();
79
+ return;
80
+ }
81
+ this.open && (t.stopPropagation(), t.preventDefault(), this.open = !1);
82
+ }
83
+ onFocusout(t) {
84
+ const e = t.relatedTarget;
85
+ e instanceof Node && this.contains(e) || (this.open = !1);
86
+ }
87
+ /** Keyboard path: focus on an action uncovers the strip. */
88
+ reveal() {
89
+ this.open = !0;
90
+ }
91
+ onKeydown(t) {
92
+ t.key === "Escape" && this.open && (t.stopPropagation(), this.open = !1);
93
+ }
94
+ pick(t) {
95
+ this.emit("baht-action", { key: t }), this.open = !1;
96
+ }
97
+ contentStyle() {
98
+ return this.dragX !== null ? `transform: translateX(${String(this.dragX)}px)` : this.open ? `transform: translateX(-${String(this.revealWidth())}px)` : "";
99
+ }
100
+ /** The row itself: children are adopted in here; it carries the drag. */
101
+ renderContent() {
102
+ return h`<div
103
+ class="baht-swipe-row-content"
104
+ style=${this.contentStyle()}
105
+ @pointerdown=${(t) => {
106
+ this.onPointerdown(t);
107
+ }}
108
+ @pointermove=${(t) => {
109
+ this.onPointermove(t);
110
+ }}
111
+ @pointerup=${(t) => {
112
+ this.onPointerup(t);
113
+ }}
114
+ @pointercancel=${() => {
115
+ this.onPointercancel();
116
+ }}
117
+ @click=${{
118
+ handleEvent: (t) => {
119
+ this.onContentClick(t);
120
+ },
121
+ capture: !0
122
+ }}
123
+ ></div>`;
124
+ }
125
+ render() {
126
+ const t = d(this.actions), e = `baht-swipe-row${this.open ? " baht-swipe-row--open" : ""}${this.dragX === null ? "" : " baht-swipe-row--dragging"}`;
127
+ return h`<div
128
+ class=${e}
129
+ @focusout=${(n) => {
130
+ this.onFocusout(n);
131
+ }}
132
+ @keydown=${(n) => {
133
+ this.onKeydown(n);
134
+ }}
135
+ >
136
+ ${this.renderContent()}
137
+ ${t.length > 0 ? h`<div
138
+ class="baht-swipe-row-actions"
139
+ role="group"
140
+ aria-label=${this.label || v("rowActions")}
141
+ @focusin=${() => {
142
+ this.reveal();
143
+ }}
144
+ >
145
+ ${t.map(
146
+ (n) => h`<button
147
+ type="button"
148
+ class="baht-swipe-row-action baht-swipe-row-action--${n.tone ?? "neutral"}"
149
+ data-key=${n.key}
150
+ @click=${() => {
151
+ this.pick(n.key);
152
+ }}
153
+ >
154
+ ${n.label}
155
+ </button>`
156
+ )}
157
+ </div>` : w}
158
+ </div>`;
159
+ }
160
+ };
161
+ l([
162
+ p({ attribute: !1 })
163
+ ], a.prototype, "actions", 2);
164
+ l([
165
+ p({ type: Boolean, reflect: !0 })
166
+ ], a.prototype, "open", 2);
167
+ l([
168
+ p()
169
+ ], a.prototype, "label", 2);
170
+ l([
171
+ m()
172
+ ], a.prototype, "dragX", 2);
173
+ a = l([
174
+ y("baht-swipe-row")
175
+ ], a);
176
+ export {
177
+ a as BahtSwipeRow
178
+ };